pi-web-ui 0.104.0 → 0.104.1

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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-28naZdcs.js","assets/rolldown-runtime-hePW80VL.js","assets/react-CR5VJ85Q.js","assets/xterm-Cf5xxe4g.js","assets/xterm-B1njb2Cr.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from"./react-CR5VJ85Q.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./markdown-DXwnfD9T.js";import{n as m,t as h}from"./xterm-Cf5xxe4g.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var g=e(t(),1),_={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},v=g.createContext&&g.createContext(_),y=[`attr`,`size`,`title`];function b(e,t){if(e==null)return{};var n,r,i=x(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function x(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S.apply(null,arguments)}function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?C(Object(n),!0).forEach(function(t){T(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function T(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){var t=D(e,`string`);return typeof t==`symbol`?t:t+``}function D(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function O(e){return e&&e.map((e,t)=>g.createElement(e.tag,w({key:t},e.attr),O(e.child)))}function k(e){return t=>g.createElement(A,S({attr:w({},e.attr)},t),O(e.child))}function A(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=b(e,y),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),g.createElement(`svg`,S({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:w(w({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&g.createElement(`title`,null,i),e.children)};return v===void 0?t(_):g.createElement(v.Consumer,null,e=>t(e))}var j=r(),ee=n();function M(e){return k({tag:`svg`,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:[]}]})(e)}function te(e){return k({tag:`svg`,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:[]}]})(e)}function N(e){return k({tag:`svg`,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:[]}]})(e)}function P(e){return k({tag:`svg`,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:[]}]})(e)}function ne(e){return k({tag:`svg`,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:[]}]})(e)}function F(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2`},child:[]},{tag:`circle`,attr:{cx:`9`,cy:`7`,r:`4`},child:[]},{tag:`path`,attr:{d:`M23 21v-2a4 4 0 0 0-3-3.87`},child:[]},{tag:`path`,attr:{d:`M16 3.13a4 4 0 0 1 0 7.75`},child:[]}]})(e)}function re(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`17 8 12 3 7 8`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`3`,x2:`12`,y2:`15`},child:[]}]})(e)}function I(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`16 16 12 12 8 16`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`12`,x2:`12`,y2:`21`},child:[]},{tag:`path`,attr:{d:`M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3`},child:[]},{tag:`polyline`,attr:{points:`16 16 12 12 8 16`},child:[]}]})(e)}function L(e){return k({tag:`svg`,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:[]}]})(e)}function ie(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 7 4 4 20 4 20 7`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`15`,y2:`20`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`4`,x2:`12`,y2:`20`},child:[]}]})(e)}function R(e){return k({tag:`svg`,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:[]}]})(e)}function z(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function B(e){return k({tag:`svg`,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:[]}]})(e)}function V(e){return k({tag:`svg`,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:[]}]})(e)}function H(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function U(e){return k({tag:`svg`,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:[]}]})(e)}function ae(e){return k({tag:`svg`,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:[]}]})(e)}function oe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`path`,attr:{d:`M16 10a4 4 0 0 1-8 0`},child:[]}]})(e)}function se(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z`},child:[]}]})(e)}function W(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`18`,cy:`5`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`12`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`19`,r:`3`},child:[]},{tag:`line`,attr:{x1:`8.59`,y1:`13.51`,x2:`15.42`,y2:`17.49`},child:[]},{tag:`line`,attr:{x1:`15.41`,y1:`6.51`,x2:`8.59`,y2:`10.49`},child:[]}]})(e)}function ce(e){return k({tag:`svg`,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:[]}]})(e)}function le(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function ue(e){return k({tag:`svg`,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:[]}]})(e)}function de(e){return k({tag:`svg`,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:[]}]})(e)}function fe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`6`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`4`,x2:`8.12`,y2:`15.88`},child:[]},{tag:`line`,attr:{x1:`14.47`,y1:`14.48`,x2:`20`,y2:`20`},child:[]},{tag:`line`,attr:{x1:`8.12`,y1:`8.12`,x2:`12`,y2:`12`},child:[]}]})(e)}function pe(e){return k({tag:`svg`,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:[]}]})(e)}function G(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function K(e){return k({tag:`svg`,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:[]}]})(e)}function me(e){return k({tag:`svg`,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:[]}]})(e)}function he(e){return k({tag:`svg`,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:[]}]})(e)}function ge(e){return k({tag:`svg`,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:[]}]})(e)}function q(e){return k({tag:`svg`,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:[]}]})(e)}function _e(e){return k({tag:`svg`,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:`12`,cy:`5`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`19`,r:`1`},child:[]}]})(e)}function ve(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function ye(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function be(e){return k({tag:`svg`,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:[]}]})(e)}function xe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z`},child:[]},{tag:`path`,attr:{d:`M19 10v2a7 7 0 0 1-14 0v-2`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`23`,x2:`16`,y2:`23`},child:[]}]})(e)}function J(e){return k({tag:`svg`,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:[]}]})(e)}function Se(e){return k({tag:`svg`,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:[]}]})(e)}function Ce(e){return k({tag:`svg`,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:[]}]})(e)}function we(e){return k({tag:`svg`,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:[]}]})(e)}function Te(e){return k({tag:`svg`,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:[]}]})(e)}function Ee(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`2`,x2:`12`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`18`,x2:`12`,y2:`22`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`7.76`,y2:`7.76`},child:[]},{tag:`line`,attr:{x1:`16.24`,y1:`16.24`,x2:`19.07`,y2:`19.07`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`6`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`18`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`19.07`,x2:`7.76`,y2:`16.24`},child:[]},{tag:`line`,attr:{x1:`16.24`,y1:`7.76`,x2:`19.07`,y2:`4.93`},child:[]}]})(e)}function De(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function Oe(e){return k({tag:`svg`,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:[]}]})(e)}function ke(e){return k({tag:`svg`,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:[]}]})(e)}function Ae(e){return k({tag:`svg`,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:[]}]})(e)}function je(e){return k({tag:`svg`,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:[]}]})(e)}function Me(e){return k({tag:`svg`,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:[]}]})(e)}function Ne(e){return k({tag:`svg`,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:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Pe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`14`,y:`3`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`14`,y:`14`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`3`,y:`14`,width:`7`,height:`7`},child:[]}]})(e)}function Fe(e){return k({tag:`svg`,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:[]}]})(e)}function Ie(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22`},child:[]}]})(e)}function Le(e){return k({tag:`svg`,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:[]}]})(e)}function Re(e){return k({tag:`svg`,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:[]}]})(e)}function ze(e){return k({tag:`svg`,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:[]}]})(e)}function Be(e){return k({tag:`svg`,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:[]}]})(e)}function Ve(e){return k({tag:`svg`,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:[]}]})(e)}function He(e){return k({tag:`svg`,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:`12`,y1:`18`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`15`,x2:`15`,y2:`15`},child:[]}]})(e)}function Ue(e){return k({tag:`svg`,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:[]}]})(e)}function We(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`1`,x2:`23`,y2:`23`},child:[]}]})(e)}function Ge(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`},child:[]},{tag:`polyline`,attr:{points:`15 3 21 3 21 9`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`14`,x2:`21`,y2:`3`},child:[]}]})(e)}function Y(e){return k({tag:`svg`,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:[]}]})(e)}function Ke(e){return k({tag:`svg`,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:[]}]})(e)}function qe(e){return k({tag:`svg`,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:[]}]})(e)}function Je(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`23`},child:[]},{tag:`path`,attr:{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`},child:[]}]})(e)}function Ye(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`ellipse`,attr:{cx:`12`,cy:`5`,rx:`9`,ry:`3`},child:[]},{tag:`path`,attr:{d:`M21 12c0 1.66-4 3-9 3s-9-1.34-9-3`},child:[]},{tag:`path`,attr:{d:`M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`},child:[]}]})(e)}function Xe(e){return k({tag:`svg`,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:`22`,y1:`12`,x2:`18`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`12`,x2:`2`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`6`,x2:`12`,y2:`2`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22`,x2:`12`,y2:`18`},child:[]}]})(e)}function Ze(e){return k({tag:`svg`,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:[]}]})(e)}function Qe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function $e(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function et(e){return k({tag:`svg`,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:[]}]})(e)}function tt(e){return k({tag:`svg`,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:[]}]})(e)}function nt(e){return k({tag:`svg`,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:[]}]})(e)}function rt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function it(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`},child:[]},{tag:`rect`,attr:{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`},child:[]}]})(e)}function at(e){return k({tag:`svg`,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:[]}]})(e)}function ot(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`13 17 18 12 13 7`},child:[]},{tag:`polyline`,attr:{points:`6 17 11 12 6 7`},child:[]}]})(e)}function st(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`11 17 6 12 11 7`},child:[]},{tag:`polyline`,attr:{points:`18 17 13 12 18 7`},child:[]}]})(e)}function ct(e){return k({tag:`svg`,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:[]}]})(e)}function lt(e){return k({tag:`svg`,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:[]}]})(e)}function ut(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function dt(e){return k({tag:`svg`,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:[]}]})(e)}function ft(e){return k({tag:`svg`,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:[]}]})(e)}function pt(e){return k({tag:`svg`,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:[]}]})(e)}function mt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`13`,r:`4`},child:[]}]})(e)}function ht(e){return k({tag:`svg`,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:[]}]})(e)}function gt(e){return k({tag:`svg`,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:[]}]})(e)}function _t(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`},child:[]},{tag:`path`,attr:{d:`M13.73 21a2 2 0 0 1-3.46 0`},child:[]}]})(e)}function vt(e){return k({tag:`svg`,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:[]}]})(e)}function yt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`7`,y1:`17`,x2:`17`,y2:`7`},child:[]},{tag:`polyline`,attr:{points:`7 7 17 7 17 17`},child:[]}]})(e)}function bt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 5 19 12 12 19`},child:[]}]})(e)}function xt(e){return k({tag:`svg`,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:[]}]})(e)}function St(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function Ct(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`5`,r:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22`,x2:`12`,y2:`8`},child:[]},{tag:`path`,attr:{d:`M5 12H2a10 10 0 0 0 20 0h-3`},child:[]}]})(e)}function wt(e){return k({tag:`svg`,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:[]}]})(e)}function Tt(e){return k({tag:`svg`,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:[]}]})(e)}function Et(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`22 12 18 12 15 21 9 3 6 12 2 12`},child:[]}]})(e)}function Dt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M11.646 15.146 5.854 9.354a.5.5 0 0 1 .353-.854h11.586a.5.5 0 0 1 .353.854l-5.793 5.792a.5.5 0 0 1-.707 0Z`},child:[]}]})(e)}function Ot(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 17H7l-4 4v-7`},child:[]},{tag:`path`,attr:{d:`M14 17h1`},child:[]},{tag:`path`,attr:{d:`M14 3h1`},child:[]},{tag:`path`,attr:{d:`M19 3a2 2 0 0 1 2 2`},child:[]},{tag:`path`,attr:{d:`M21 14v1a2 2 0 0 1-2 2`},child:[]},{tag:`path`,attr:{d:`M21 9v1`},child:[]},{tag:`path`,attr:{d:`M3 9v1`},child:[]},{tag:`path`,attr:{d:`M5 3a2 2 0 0 0-2 2`},child:[]},{tag:`path`,attr:{d:`M9 3h1`},child:[]}]})(e)}function kt(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${At(e.source??e.name)}`:e.kind===`plugin`?`pi-web-ui install ${e.source??e.name} --name ${e.pluginId??e.name} --force`:`npm i -g ${e.name}@latest`).join(`; `)}function At(e){return e.startsWith(`git:`)?e:`git:${e}`}function jt(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Mt(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,g.useRef)(t);(0,g.useLayoutEffect)(()=>{a.current=t}),(0,g.useEffect)(()=>{if(!r)return;let t=(e,t)=>{if(!t)return!1;let n=`current`in t?t.current:t;return n?n.contains(e):!1},n=n=>{let r=n.target;r instanceof Node&&(e.current?.contains(r)||i&&(Array.isArray(i)?i:[i]).some(e=>t(r,e))||a.current(n))};return document.addEventListener(`mousedown`,n),document.addEventListener(`touchstart`,n),()=>{document.removeEventListener(`mousedown`,n),document.removeEventListener(`touchstart`,n)}},[r,e,i])}var Nt=[],Pt=!1;function Ft(e){if(e.key===`Escape`&&Nt.length!==0)for(let t=Nt.length-1;t>=0;t--){let n=Nt[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function It(){!Pt&&typeof document<`u`&&(document.addEventListener(`keydown`,Ft,!0),Pt=!0)}function Lt(){Pt&&Nt.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,Ft,!0),Pt=!1)}function Rt(e){return Nt.push(e),It(),()=>{let t=Nt.lastIndexOf(e);t>=0&&Nt.splice(t,1),Lt()}}function zt(e,t=!0){let n=(0,g.useRef)(e);(0,g.useLayoutEffect)(()=>{n.current=e}),(0,g.useEffect)(()=>{if(t)return Rt(()=>n.current())},[t])}var X=i();function Bt({align:e,triggerLeft:t,triggerRight:n,menuWidth:r,viewportWidth:i,margin:a=8}){if(r<=0||i<=0)return 0;let o=e===`left`?t:n-r,s=Math.max(a,i-a-r);return Math.round(Math.max(a,Math.min(o,s))-o)}function Vt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,caret:c=!0,menuClassName:l,triggerClassName:u,menuRef:d,menuStyle:f}){let p=(0,g.useRef)(null),m=(0,g.useRef)(null),[h,_]=(0,g.useState)(0),v=e=>{m.current=e,typeof d==`function`?d(e):d&&`current`in d&&(d.current=e)},y=()=>{let e=p.current,t=m.current;if(!e||!t)return;if(window.innerWidth<=768){h!==0&&_(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){h!==0&&_(0);return}let a=n.width,o=Bt({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==h&&_(o)};return(0,g.useLayoutEffect)(()=>{t?y():h!==0&&_(0)}),(0,g.useEffect)(()=>{if(t)return window.addEventListener(`resize`,y),()=>window.removeEventListener(`resize`,y)},[t,h]),Mt(p,()=>n(!1),{enabled:t}),zt(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:p,children:[(0,X.jsxs)(`button`,{type:`button`,className:u??`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,c&&(0,X.jsx)(dt,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${l??``}`,ref:v,style:h===0?f:{...f,transform:f?.transform?`${f.transform} translateX(${h}px)`:`translateX(${h}px)`},children:r})]})}function Ht({active:e,disabled:t=!1,title:n,onClick:r,children:i}){return(0,X.jsx)(`button`,{type:`button`,className:`dd-item ${e?`active`:``}`,disabled:t,title:n,onClick:r,children:i})}var Ut=`pi-web-tts`,Wt={enabled:!1,announce:!0,readReplies:!1,rate:1,voiceURI:``};function Gt(){try{let e=localStorage.getItem(Ut);if(!e)return{...Wt};let t={...Wt,...JSON.parse(e)};for(let e of[`enabled`,`announce`,`readReplies`])typeof t[e]!=`boolean`&&(t[e]=Wt[e]);return t.rate=typeof t.rate!=`number`||!Number.isFinite(t.rate)?Wt.rate:Math.round(Math.max(.5,Math.min(2,t.rate))*10)/10,typeof t.voiceURI!=`string`&&(t.voiceURI=Wt.voiceURI),t}catch{return{...Wt}}}function Kt(e){try{localStorage.setItem(Ut,JSON.stringify(e))}catch{}}function qt(){return typeof window<`u`&&`speechSynthesis`in window}function Jt(e,t,n){if(e){let n=t.find(t=>t.voiceURI===e);if(n)return n}let r=n.split(`-`)[0]?.toLowerCase();return r?t.find(e=>e.lang.toLowerCase().startsWith(r))??null:null}function Yt(e){let t=e??``;return t=t.replace(/```[\s\S]*?(?:```|$)/g,` `),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/!\[[^\]]*\]\([^)]*\)/g,` `),t=t.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`),t=t.replace(/^\s{0,3}#{1,6}\s+/gm,``),t=t.replace(/^\s{0,3}>\s?/gm,``),t=t.replace(/^\s*[-*+]\s+/gm,``),t=t.replace(/^\s*\|?[\s:|-]*\|[\s:|-]*$/gm,``),t=t.replace(/\|/g,` `),t=t.replace(/(\*\*\*|\*\*|__)(.*?)\1/g,`$2`),t=t.replace(/(\*|_)([^*_\n]+)\1/g,`$2`),t=t.replace(/<[^>]+>/g,` `),t=t.replace(/\r/g,``),t=t.replace(/[ \t]+/g,` `),t=t.replace(/\s*\n+\s*/g,` `),t=t.trim(),t.length>600&&(t=`${t.slice(0,600).trimEnd()}…`),t}function Xt(e){if(!Array.isArray(e))return``;for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.role===`assistant`)return Yt((n.content??[]).filter(e=>e?.type===`text`&&typeof e.text==`string`).map(e=>e.text??``).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-CpfPFx32.js","assets/rolldown-runtime-hePW80VL.js","assets/react-CR5VJ85Q.js","assets/xterm-Cf5xxe4g.js","assets/xterm-B1njb2Cr.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from"./react-CR5VJ85Q.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p}from"./markdown-DXwnfD9T.js";import{n as m,t as h}from"./xterm-Cf5xxe4g.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var g=e(t(),1),_={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},v=g.createContext&&g.createContext(_),y=[`attr`,`size`,`title`];function b(e,t){if(e==null)return{};var n,r,i=x(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function x(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function S(){return S=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},S.apply(null,arguments)}function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?C(Object(n),!0).forEach(function(t){T(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function T(e,t,n){return(t=E(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e){var t=D(e,`string`);return typeof t==`symbol`?t:t+``}function D(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function O(e){return e&&e.map((e,t)=>g.createElement(e.tag,w({key:t},e.attr),O(e.child)))}function k(e){return t=>g.createElement(A,S({attr:w({},e.attr)},t),O(e.child))}function A(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=b(e,y),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),g.createElement(`svg`,S({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:w(w({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&g.createElement(`title`,null,i),e.children)};return v===void 0?t(_):g.createElement(v.Consumer,null,e=>t(e))}var j=r(),ee=n();function M(e){return k({tag:`svg`,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:[]}]})(e)}function te(e){return k({tag:`svg`,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:[]}]})(e)}function N(e){return k({tag:`svg`,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:[]}]})(e)}function P(e){return k({tag:`svg`,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:[]}]})(e)}function ne(e){return k({tag:`svg`,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:[]}]})(e)}function F(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2`},child:[]},{tag:`circle`,attr:{cx:`9`,cy:`7`,r:`4`},child:[]},{tag:`path`,attr:{d:`M23 21v-2a4 4 0 0 0-3-3.87`},child:[]},{tag:`path`,attr:{d:`M16 3.13a4 4 0 0 1 0 7.75`},child:[]}]})(e)}function re(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`17 8 12 3 7 8`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`3`,x2:`12`,y2:`15`},child:[]}]})(e)}function ie(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`16 16 12 12 8 16`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`12`,x2:`12`,y2:`21`},child:[]},{tag:`path`,attr:{d:`M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3`},child:[]},{tag:`polyline`,attr:{points:`16 16 12 12 8 16`},child:[]}]})(e)}function ae(e){return k({tag:`svg`,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:[]}]})(e)}function I(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 7 4 4 20 4 20 7`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`15`,y2:`20`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`4`,x2:`12`,y2:`20`},child:[]}]})(e)}function L(e){return k({tag:`svg`,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:[]}]})(e)}function R(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function z(e){return k({tag:`svg`,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:[]}]})(e)}function oe(e){return k({tag:`svg`,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:[]}]})(e)}function B(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function V(e){return k({tag:`svg`,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:[]}]})(e)}function H(e){return k({tag:`svg`,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:[]}]})(e)}function se(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M6 2L3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`path`,attr:{d:`M16 10a4 4 0 0 1-8 0`},child:[]}]})(e)}function ce(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z`},child:[]}]})(e)}function le(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`18`,cy:`5`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`12`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`19`,r:`3`},child:[]},{tag:`line`,attr:{x1:`8.59`,y1:`13.51`,x2:`15.42`,y2:`17.49`},child:[]},{tag:`line`,attr:{x1:`15.41`,y1:`6.51`,x2:`8.59`,y2:`10.49`},child:[]}]})(e)}function ue(e){return k({tag:`svg`,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:[]}]})(e)}function U(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function de(e){return k({tag:`svg`,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:[]}]})(e)}function fe(e){return k({tag:`svg`,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:[]}]})(e)}function W(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`6`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`4`,x2:`8.12`,y2:`15.88`},child:[]},{tag:`line`,attr:{x1:`14.47`,y1:`14.48`,x2:`20`,y2:`20`},child:[]},{tag:`line`,attr:{x1:`8.12`,y1:`8.12`,x2:`12`,y2:`12`},child:[]}]})(e)}function pe(e){return k({tag:`svg`,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:[]}]})(e)}function G(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function K(e){return k({tag:`svg`,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:[]}]})(e)}function me(e){return k({tag:`svg`,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:[]}]})(e)}function he(e){return k({tag:`svg`,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:[]}]})(e)}function ge(e){return k({tag:`svg`,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:[]}]})(e)}function q(e){return k({tag:`svg`,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:[]}]})(e)}function _e(e){return k({tag:`svg`,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:`12`,cy:`5`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`19`,r:`1`},child:[]}]})(e)}function ve(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function ye(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function be(e){return k({tag:`svg`,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:[]}]})(e)}function xe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z`},child:[]},{tag:`path`,attr:{d:`M19 10v2a7 7 0 0 1-14 0v-2`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`23`,x2:`16`,y2:`23`},child:[]}]})(e)}function J(e){return k({tag:`svg`,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:[]}]})(e)}function Se(e){return k({tag:`svg`,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:[]}]})(e)}function Ce(e){return k({tag:`svg`,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:[]}]})(e)}function we(e){return k({tag:`svg`,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:[]}]})(e)}function Te(e){return k({tag:`svg`,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:[]}]})(e)}function Ee(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`2`,x2:`12`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`18`,x2:`12`,y2:`22`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`7.76`,y2:`7.76`},child:[]},{tag:`line`,attr:{x1:`16.24`,y1:`16.24`,x2:`19.07`,y2:`19.07`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`6`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`18`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`19.07`,x2:`7.76`,y2:`16.24`},child:[]},{tag:`line`,attr:{x1:`16.24`,y1:`7.76`,x2:`19.07`,y2:`4.93`},child:[]}]})(e)}function De(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function Oe(e){return k({tag:`svg`,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:[]}]})(e)}function ke(e){return k({tag:`svg`,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:[]}]})(e)}function Ae(e){return k({tag:`svg`,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:[]}]})(e)}function je(e){return k({tag:`svg`,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:[]}]})(e)}function Me(e){return k({tag:`svg`,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:[]}]})(e)}function Ne(e){return k({tag:`svg`,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:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Pe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`14`,y:`3`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`14`,y:`14`,width:`7`,height:`7`},child:[]},{tag:`rect`,attr:{x:`3`,y:`14`,width:`7`,height:`7`},child:[]}]})(e)}function Fe(e){return k({tag:`svg`,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:[]}]})(e)}function Ie(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22`},child:[]}]})(e)}function Le(e){return k({tag:`svg`,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:[]}]})(e)}function Re(e){return k({tag:`svg`,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:[]}]})(e)}function ze(e){return k({tag:`svg`,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:[]}]})(e)}function Be(e){return k({tag:`svg`,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:[]}]})(e)}function Ve(e){return k({tag:`svg`,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:[]}]})(e)}function He(e){return k({tag:`svg`,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:`12`,y1:`18`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`15`,x2:`15`,y2:`15`},child:[]}]})(e)}function Ue(e){return k({tag:`svg`,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:[]}]})(e)}function We(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`1`,x2:`23`,y2:`23`},child:[]}]})(e)}function Ge(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`},child:[]},{tag:`polyline`,attr:{points:`15 3 21 3 21 9`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`14`,x2:`21`,y2:`3`},child:[]}]})(e)}function Y(e){return k({tag:`svg`,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:[]}]})(e)}function Ke(e){return k({tag:`svg`,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:[]}]})(e)}function qe(e){return k({tag:`svg`,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:[]}]})(e)}function Je(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`23`},child:[]},{tag:`path`,attr:{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`},child:[]}]})(e)}function Ye(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`ellipse`,attr:{cx:`12`,cy:`5`,rx:`9`,ry:`3`},child:[]},{tag:`path`,attr:{d:`M21 12c0 1.66-4 3-9 3s-9-1.34-9-3`},child:[]},{tag:`path`,attr:{d:`M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`},child:[]}]})(e)}function Xe(e){return k({tag:`svg`,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:`22`,y1:`12`,x2:`18`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`12`,x2:`2`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`6`,x2:`12`,y2:`2`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22`,x2:`12`,y2:`18`},child:[]}]})(e)}function Ze(e){return k({tag:`svg`,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:[]}]})(e)}function Qe(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function $e(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function et(e){return k({tag:`svg`,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:[]}]})(e)}function tt(e){return k({tag:`svg`,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:[]}]})(e)}function nt(e){return k({tag:`svg`,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:[]}]})(e)}function rt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function it(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`},child:[]},{tag:`rect`,attr:{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`},child:[]}]})(e)}function at(e){return k({tag:`svg`,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:[]}]})(e)}function ot(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`13 17 18 12 13 7`},child:[]},{tag:`polyline`,attr:{points:`6 17 11 12 6 7`},child:[]}]})(e)}function st(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`11 17 6 12 11 7`},child:[]},{tag:`polyline`,attr:{points:`18 17 13 12 18 7`},child:[]}]})(e)}function ct(e){return k({tag:`svg`,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:[]}]})(e)}function lt(e){return k({tag:`svg`,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:[]}]})(e)}function ut(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function dt(e){return k({tag:`svg`,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:[]}]})(e)}function ft(e){return k({tag:`svg`,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:[]}]})(e)}function pt(e){return k({tag:`svg`,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:[]}]})(e)}function mt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`13`,r:`4`},child:[]}]})(e)}function ht(e){return k({tag:`svg`,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:[]}]})(e)}function gt(e){return k({tag:`svg`,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:[]}]})(e)}function _t(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9`},child:[]},{tag:`path`,attr:{d:`M13.73 21a2 2 0 0 1-3.46 0`},child:[]}]})(e)}function vt(e){return k({tag:`svg`,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:[]}]})(e)}function yt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`7`,y1:`17`,x2:`17`,y2:`7`},child:[]},{tag:`polyline`,attr:{points:`7 7 17 7 17 17`},child:[]}]})(e)}function bt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 5 19 12 12 19`},child:[]}]})(e)}function xt(e){return k({tag:`svg`,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:[]}]})(e)}function St(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function Ct(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`5`,r:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`22`,x2:`12`,y2:`8`},child:[]},{tag:`path`,attr:{d:`M5 12H2a10 10 0 0 0 20 0h-3`},child:[]}]})(e)}function wt(e){return k({tag:`svg`,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:[]}]})(e)}function Tt(e){return k({tag:`svg`,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:[]}]})(e)}function Et(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`22 12 18 12 15 21 9 3 6 12 2 12`},child:[]}]})(e)}function Dt(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M11.646 15.146 5.854 9.354a.5.5 0 0 1 .353-.854h11.586a.5.5 0 0 1 .353.854l-5.793 5.792a.5.5 0 0 1-.707 0Z`},child:[]}]})(e)}function Ot(e){return k({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 17H7l-4 4v-7`},child:[]},{tag:`path`,attr:{d:`M14 17h1`},child:[]},{tag:`path`,attr:{d:`M14 3h1`},child:[]},{tag:`path`,attr:{d:`M19 3a2 2 0 0 1 2 2`},child:[]},{tag:`path`,attr:{d:`M21 14v1a2 2 0 0 1-2 2`},child:[]},{tag:`path`,attr:{d:`M21 9v1`},child:[]},{tag:`path`,attr:{d:`M3 9v1`},child:[]},{tag:`path`,attr:{d:`M5 3a2 2 0 0 0-2 2`},child:[]},{tag:`path`,attr:{d:`M9 3h1`},child:[]}]})(e)}function kt(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${At(e.source??e.name)}`:e.kind===`plugin`?`pi-web-ui install ${e.source??e.name} --name ${e.pluginId??e.name} --force`:`npm i -g ${e.name}@latest`).join(`; `)}function At(e){return e.startsWith(`git:`)?e:`git:${e}`}function jt(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Mt(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,g.useRef)(t);(0,g.useLayoutEffect)(()=>{a.current=t}),(0,g.useEffect)(()=>{if(!r)return;let t=(e,t)=>{if(!t)return!1;let n=`current`in t?t.current:t;return n?n.contains(e):!1},n=n=>{let r=n.target;r instanceof Node&&(e.current?.contains(r)||i&&(Array.isArray(i)?i:[i]).some(e=>t(r,e))||a.current(n))};return document.addEventListener(`mousedown`,n),document.addEventListener(`touchstart`,n),()=>{document.removeEventListener(`mousedown`,n),document.removeEventListener(`touchstart`,n)}},[r,e,i])}var Nt=[],Pt=!1;function Ft(e){if(e.key===`Escape`&&Nt.length!==0)for(let t=Nt.length-1;t>=0;t--){let n=Nt[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function It(){!Pt&&typeof document<`u`&&(document.addEventListener(`keydown`,Ft,!0),Pt=!0)}function Lt(){Pt&&Nt.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,Ft,!0),Pt=!1)}function Rt(e){return Nt.push(e),It(),()=>{let t=Nt.lastIndexOf(e);t>=0&&Nt.splice(t,1),Lt()}}function zt(e,t=!0){let n=(0,g.useRef)(e);(0,g.useLayoutEffect)(()=>{n.current=e}),(0,g.useEffect)(()=>{if(t)return Rt(()=>n.current())},[t])}var X=i();function Bt({align:e,triggerLeft:t,triggerRight:n,menuWidth:r,viewportWidth:i,margin:a=8}){if(r<=0||i<=0)return 0;let o=e===`left`?t:n-r,s=Math.max(a,i-a-r);return Math.round(Math.max(a,Math.min(o,s))-o)}function Vt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,caret:c=!0,menuClassName:l,triggerClassName:u,menuRef:d,menuStyle:f}){let p=(0,g.useRef)(null),m=(0,g.useRef)(null),[h,_]=(0,g.useState)(0),v=e=>{m.current=e,typeof d==`function`?d(e):d&&`current`in d&&(d.current=e)},y=()=>{let e=p.current,t=m.current;if(!e||!t)return;if(window.innerWidth<=768){h!==0&&_(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){h!==0&&_(0);return}let a=n.width,o=Bt({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==h&&_(o)};return(0,g.useLayoutEffect)(()=>{t?y():h!==0&&_(0)}),(0,g.useEffect)(()=>{if(t)return window.addEventListener(`resize`,y),()=>window.removeEventListener(`resize`,y)},[t,h]),Mt(p,()=>n(!1),{enabled:t}),zt(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:p,children:[(0,X.jsxs)(`button`,{type:`button`,className:u??`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,c&&(0,X.jsx)(dt,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${l??``}`,ref:v,style:h===0?f:{...f,transform:f?.transform?`${f.transform} translateX(${h}px)`:`translateX(${h}px)`},children:r})]})}function Ht({active:e,disabled:t=!1,title:n,onClick:r,children:i}){return(0,X.jsx)(`button`,{type:`button`,className:`dd-item ${e?`active`:``}`,disabled:t,title:n,onClick:r,children:i})}var Ut=`pi-web-tts`,Wt={enabled:!1,announce:!0,readReplies:!1,rate:1,voiceURI:``};function Gt(){try{let e=localStorage.getItem(Ut);if(!e)return{...Wt};let t={...Wt,...JSON.parse(e)};for(let e of[`enabled`,`announce`,`readReplies`])typeof t[e]!=`boolean`&&(t[e]=Wt[e]);return t.rate=typeof t.rate!=`number`||!Number.isFinite(t.rate)?Wt.rate:Math.round(Math.max(.5,Math.min(2,t.rate))*10)/10,typeof t.voiceURI!=`string`&&(t.voiceURI=Wt.voiceURI),t}catch{return{...Wt}}}function Kt(e){try{localStorage.setItem(Ut,JSON.stringify(e))}catch{}}function qt(){return typeof window<`u`&&`speechSynthesis`in window}function Jt(e,t,n){if(e){let n=t.find(t=>t.voiceURI===e);if(n)return n}let r=n.split(`-`)[0]?.toLowerCase();return r?t.find(e=>e.lang.toLowerCase().startsWith(r))??null:null}function Yt(e){let t=e??``;return t=t.replace(/```[\s\S]*?(?:```|$)/g,` `),t=t.replace(/`([^`]+)`/g,`$1`),t=t.replace(/!\[[^\]]*\]\([^)]*\)/g,` `),t=t.replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`),t=t.replace(/^\s{0,3}#{1,6}\s+/gm,``),t=t.replace(/^\s{0,3}>\s?/gm,``),t=t.replace(/^\s*[-*+]\s+/gm,``),t=t.replace(/^\s*\|?[\s:|-]*\|[\s:|-]*$/gm,``),t=t.replace(/\|/g,` `),t=t.replace(/(\*\*\*|\*\*|__)(.*?)\1/g,`$2`),t=t.replace(/(\*|_)([^*_\n]+)\1/g,`$2`),t=t.replace(/<[^>]+>/g,` `),t=t.replace(/\r/g,``),t=t.replace(/[ \t]+/g,` `),t=t.replace(/\s*\n+\s*/g,` `),t=t.trim(),t.length>600&&(t=`${t.slice(0,600).trimEnd()}…`),t}function Xt(e){if(!Array.isArray(e))return``;for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.role===`assistant`)return Yt((n.content??[]).filter(e=>e?.type===`text`&&typeof e.text==`string`).map(e=>e.text??``).join(`
3
3
  `))}return``}var Zt=!1,Qt=null,$t=null,en=new Set;function tn(e,t=null){e?(Zt=!0,Qt=t):(Zt=!1,Qt=null);for(let t of en)try{t(e)}catch{}}function nn(){return Zt}function rn(){return Zt?Qt:null}function an(e){return en.add(e),()=>en.delete(e)}function on(e,t=Gt(),n){if(e&&qt())try{let r=window.speechSynthesis;r.cancel();let i=new SpeechSynthesisUtterance(e);i.rate=t.rate;let a=Jt(t.voiceURI,r.getVoices(),navigator.language);a&&(i.voice=a),i.onend=()=>{$t===i&&tn(!1)},i.onerror=()=>{$t===i&&tn(!1)},$t=i,tn(!0,n??null),r.speak(i)}catch{$t=null,tn(!1)}}function sn(){if(qt()){try{window.speechSynthesis.cancel()}catch{}$t=null,tn(!1)}}var cn=null;function ln(e){if(e===void 0){let t=globalThis.document;if(t&&typeof t.baseURI==`string`&&t.baseURI)try{e=new URL(t.baseURI).pathname}catch{}if(e===void 0)return`/`}if(!e||e===`/`)return`/`;let t=e.replace(/index\.html$/i,``);return t.endsWith(`/`)||(t+=`/`),t}function un(){return cn===null&&(cn=ln()),cn}function dn(e,t){return t===`/`?e:t+e.replace(/^\/+/,``)}function fn(e){return dn(e,un())}var pn=`pi-web-ui:token`;function mn(){try{let e=new URL(window.location.href),t=e.searchParams.get(`token`);t&&(localStorage.setItem(pn,t.trim()),e.searchParams.delete(`token`),window.history.replaceState(null,``,e.toString()))}catch{}}function hn(){try{return localStorage.getItem(pn)??``}catch{return``}}function gn(e){let t=hn();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}var _n=[`zh`,`en`,`de`,`es`,`fr`,`it`,`ja`,`ko`,`pt`,`ru`];function vn(e,t,n,r=_n){let i=(e??``).trim();if(i)return i;for(let e of t??[]){let t=String(e??``).trim().toLowerCase().replace(/_/g,`-`);if(!t)continue;if(r.includes(t))return t;let n=t.split(`-`)[0];if(n&&r.includes(n))return n}let a=(n??``).trim().toLowerCase();return a&&r.includes(a)?a:`en`}var yn=`pi-web-ui:lang`,bn={docTitle:`pi-web-ui — pi 编码智能体`,cancel:`取消`,ok:`确定`,save:`保存`,close:`关闭`,widgetExpand:`点击放大查看完整输出`,collapsePanel:`收起面板`,expandPanel:`展开面板`,dragToResize:`拖拽调整宽度 · 双击复位`,loading:`加载中…`,connected:`已连接`,connecting:`连接中…`,reconnecting:`重连中…`,language:`语言`,githubRepo:`GitHub 仓库(xing-shuyin/pi-web-ui)`,copy:`复制`,viewSwitch:`视图切换`,chat:`对话`,terminal:`终端`,selectModel:`选择模型`,availableModels:`可用模型`,allProviders:`全部`,providers:`服务商`,noModels:`暂无可用模型(请先配置 API 密钥)`,reasoning:`推理`,vision:`识图`,refreshModels:`刷新模型列表(保留手填,合并新增)`,manageModels:`⚙ 管理模型(新增 / 修改)`,thinkingLevel:`思考强度`,thinking:`思考`,thinkingChip:`{level}`,sound:`声音`,theme:`主题`,themeDefault:`深色(默认)`,themeGroupClassics:`现代经典`,themeGroupBuiltin:`原始预设`,themeLight:`浅色`,themeDark:`深色`,newChat:`新对话`,newChatEphemeral:`临时对话`,newChatEphemeralTip:`临时对话(仅内存,关闭即销毁,不进历史记录)`,ephemeralBadge:`临时`,ephemeralBannerText:`当前为临时对话:消息仅保存在内存中,关闭后自动销毁,不进入历史记录。`,more:`更多`,brand:`品牌`,newChatTip:`新建对话(每个浏览器独立保存会话)`,"thinking.off":`关闭`,"thinking.minimal":`极简`,"thinking.low":`低`,"thinking.medium":`中`,"thinking.high":`高`,"thinking.xhigh":`极高`,"thinking.max":`最大`,thinkingUnsupported:`当前模型不支持该级别,已按模型能力就近生效`,context:`上下文`,contextUsage:`上下文用量`,cumulativeCost:`累计成本`,sessionMessages:`会话消息数`,messages:`消息`,pluginStatus:`插件状态`,engineBadge:`引擎`,working:`工作中`,queued:`排队`,enterPath:`输入路径,Enter 切换`,cwdTip:`工作目录:{path}(点击切换)`,manageProjects:`管理项目和工作目录`,projectPickerTitle:`选择工作目录`,newProject:`新建项目`,projectName:`项目名称`,createAndOpenProject:`创建并打开`,invalidProjectName:`请输入不含路径分隔符的项目名称`,cwdGoUp:`上级目录`,cwdPickCurrent:`选择当前目录`,cwdChoose:`选择`,cwdEnter:`进入`,cwdEmpty:`(空目录)`,cwdNewFolder:`新建文件夹`,cwdNewName:`文件夹名称`,cwdCreate:`创建`,cwdCancel:`取消`,cacheHit:`缓存命中`,cacheHitTip:`缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)`,tps:`t/s`,rateTip:`实时生成速率(估算)`,hostResources:`主机资源`,hostProcessor:`CPU`,hostMemory:`RAM`,hostResourcesTip:`运行 pi-web-ui 服务的主机 · CPU 为约 10 秒平均(2 秒采样),与任务管理器采样时刻不同会有几秒偏差`,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:`智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送`,placeholderStreamingQueued:`智能体正在工作中…回车或点「排队」,回答完全结束后发送(本引擎不支持插队)`,placeholderIdle:`给 pi 发送消息 — Enter 发送,/ 查看命令`,placeholderConnecting:`正在连接服务器…`,stopAgent:`停止智能体`,stop:`停止`,bgTasks:`后台任务`,bgTasksTip:`AI 在后台启动的服务(npm run dev & 等)——可逐个停止或全部关闭,对话结束后仍保留`,bgTasksEmpty:`暂无后台任务`,bgTasksDesc:`AI 运行中启动并仍在监听的进程(按监听端口检测)`,bgTaskPort:`端口`,bgTaskPid:`PID`,bgTaskSince:`启动`,bgTaskStop:`停止`,bgTaskStopAll:`全部关闭`,bgTaskRefresh:`刷新`,bgTaskKeep:`保留(自动清理不碰)`,bgTaskKeepOn:`已保留(自动清理不碰)—— 点一下取消`,bgTaskCleanup:`自动清理遗留`,bgTaskCleanupOff:`关`,bgTaskCleanupMinutes:`闲置 {n} 分钟`,bgTaskCleanupHint:`开启后服务端定期把闲置超阈值的 AI 起后台实例杀掉(📌 钉住的不算);杀完会发一条通知`,bgTaskCleanNow:`立即清理`,bgTaskCleanNowHint:`按当前阈值立刻清一次;阈值为关时按 30 分钟兜底`,bgTaskJustNow:`刚刚`,bgTaskMinutes:`{n} 分钟前`,bgTaskHours:`{n} 小时前`,bgTaskDays:`{n} 天前`,stopBash:`停止`,stopBashTip:`停止正在运行的 bash 命令(对话继续)`,supplement:`排队`,supplementTip:`加入队列:AI 回答完全结束后才发送(不打断)`,steerTip:`插队:立即发送,本回合马上响应(Enter)`,queueSteerTag:`插队`,queueFollowTag:`排队`,queueRemoveTip:`移除此排队消息`,queueRecallTip:`撤回并放回输入框(可编辑后重发)`,sendTip:`发送(Enter)`,composerResize:`拖拽调整输入框高度(双击恢复默认)`,quickPhrases:`快捷短语`,quickPhrasesDesc:`输入框上方的一排常用短语按钮,点击即发送(会带上当前已选的文件附件,不清空输入框草稿)`,quickPhrasesEnabled:`启用快捷短语`,quickPhrasesOffHint:`已关闭:输入框上方不再显示快捷短语按钮(已配置的短语保留,可随时重新启用)`,quickPhrasesPlaceholder:`输入常用短语…(Enter 添加)`,quickPhrasesAdd:`添加`,quickPhrasesEmpty:`还没有快捷短语,在下面添加第一条`,quickPhrasesTip:`点击发送:{text}`,quickPhrasesSendTip:`左键插队发送,右键排队发送`,quickPhrasesMoveUp:`上移`,quickPhrasesMoveDown:`下移`,quickPhrasesDelete:`删除该短语`,quickPhrasesEdit:`编辑该短语`,quickPhrasesEditPh:`修改短语…(Enter 保存,Esc 取消)`,quickPhrasesReset:`恢复默认短语`,slashCommands:`命令`,slashMenuHint:`↑↓ 选择 · Enter/Tab 补全`,atMentions:`提及`,atMenuHint:`↑↓ 选择 · Enter/Tab 插入`,slashHelpTitle:`pi 命令`,slashLoading:`命令列表加载中…(连接服务器后可用)`,slashBuiltin:`内置`,slashExtension:`扩展`,slashPrompt:`模板`,slashSkill:`技能`,slashPlugin:`插件`,slashCopied:`已复制上一条助手回复`,slashCopyFailed:`复制失败,请手动复制`,slashCopyEmpty:`还没有可复制的助手回复`,recentProjects:`最近项目`,runningConversations:`运行的对话`,elsewhereBadge:`另一处`,elsewherePseudoBadge:`无头任务`,elsewhereTip:`在其他标签页 / 设备上打开的对话(运行中或已结束未关闭,右键可过户到本页查看)`,elsewherePseudoTip:`定时任务/插件正在后台会话中执行,报告会自动落回绑定的对话;不支持过户到当前页面`,elsewhereActions:`操作(过户到本页 / 复制 id…)`,takeoverConversation:`过户到当前页面`,takeoverConfirm:`确认过户到当前页面?`,takeoverHasQuestion:`有问卷等答复,点击直接作答`,waitingQuestionBadge:`有问卷等答复,点击查看`,subagentBadge:`子代理`,collapseSubagents:`折叠子代理`,expandSubagents:`展开子代理`,subagentBadgeCount:`{n} 个子代理`,subagentsStreamingTip:`{n} 个子代理(有子代理运行中)`,subagentsQuestionTip:`{n} 个子代理(等待问卷答复)`,subagentsErrorTip:`{n} 个子代理(存在错误)`,subagentsCountTip:`{n} 个子代理`,convErrorBadge:`子代理运行报错:{error}`,subagentTitle:`子代理 · {title}`,historySessions:`历史对话`,openHistory:`历史对话`,openFiles:`文件列表`,openProject:`打开项目`,streaming:`进行中…`,noHistory:`还没有历史对话`,current:`当前`,messageCount:`{n} 条消息`,tuiTip:`pi 终端(TUI)中的对话`,deleteProject:`从最近项目移出`,deleteProjectConfirm:`确认移出`,deleteSession:`删除该对话记录(不可恢复)`,deleteSessionConfirm:`确认删除`,renameSession:`重命名该对话`,renameSessionPlaceholder:`输入新名称…`,dismissConversation:`从运行列表移出(历史记录保留)`,dismissConversationConfirm:`确认移出`,pinConversation:`钉住(切换其他对话也不移出)`,unpinConversation:`取消钉住`,pinnedConversation:`已钉住:切换到其他对话时,本对话会一直留在「运行的对话」里,直到被手动移出`,dismissFinishedSubagents:`关闭已结束的子代理({n} 个)`,dismissFinishedSubagentsScoped:`关闭该对话下已结束的子代理(含嵌套,{n} 个)`,dismissStreamingConfirm:`仍在运行,确认强行关闭?(运行将被中止)`,dismissFinishedOnly:`仅关已结束({n})`,dismissForceAll:`强行全关(含子代理 {n})`,forceDismissTitle:`强行关闭本对话及全部 {n} 个子代理(运行中的 {m} 个将被中止)`,forceDismissConversation:`强行关闭对话(含全部子代理)`,persistSubagent:`固化为普通对话`,saveEphemeral:`保存为正式对话`,forceDismissConfirm:`确认强行关闭?未结束的运行将被中止,再点一次`,noFinishedSubagents:`没有可关闭的已结束子代理`,collapseSection:`折叠`,expandSection:`展开`,emptyChat:`空对话`,reaskDirectly:`直接重问`,reaskDirectlyTip:`直接从这里重新提问(不修改内容,新建分支对话,原对话保留)`,editReask:`编辑重问`,editReaskTip:`修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)`,forkSession:`派生分支`,forkSessionTip:`从此消息处派生新分支会话(截取该位置之前的转录)`,rollbackSession:`回滚到此`,rollbackSessionTip:`丢弃此消息之后的内容,在当前会话直接继续`,rollbackConfirm:`确定要回滚到此消息吗?该消息之后的所有对话将被丢弃,并在当前会话继续。`,rollbackRestoreWorkspace:`同时还原工作区物理文件(Dual-State Rollback)`,rollbackRestoreWorkspaceTip:`还原物理代码到该消息发起时的检查点版本(通过 Git 影子快照)`,toolApprovalTitle:`工具执行待审批(Human-in-the-Loop)`,toolApprovalApprove:`批准执行`,toolApprovalDeny:`拒绝`,toolApprovalEditAndRun:`修改并放行 (Edit & Run)`,toolApprovalRiskAlert:`检测到高危操作或关键配置修改`,toolApprovalHitsTitle:`高危命中清单`,approvalHitPos:`位置:第 {index} 字符起(长 {length} 字符)`,approvalCommandPreview:`高危命令定位`,toolApprovalParams:`工具调用参数`,toolApprovalEditPlaceholder:`就地修改参数 JSON…`,toolApprovalCategory:`规则档位`,toolApprovalAllowCategory:`本对话允许同类`,toolApprovalAllowCategoryHint:`本对话内这一类高危操作后续不再询问(设置 →「工具」页可撤销)`,toolApprovalAllowConversation:`本对话全部允许`,toolApprovalAllowConversationHint:`本对话内所有高危操作后续都不再询问(设置 →「工具」页可撤销)`,toolApprovalEnabled:`工具执行审批(人机协同)`,toolApprovalEnabledDesc:`开:高危操作(rm -rf / 破坏性 git / 敏感文件 / 工作区外写入 / 插件要求确认)弹窗等你批准、拒绝或改参数;关:一切审批都不弹(内置高危检测直接放行,插件要求确认也按放行处理)。`,toolApprovalPolicyTitle:`已记住的放行(本对话)`,toolApprovalPolicyAllowAll:`本对话全部允许审批`,toolApprovalPolicyRevoke:`撤销`,toolApprovalPolicyHint:`只存在内存里:重启服务或新对话即恢复询问;策略跟对话走(手动过户时一起搬)。`,settingsApprovalRules:`审批规则`,settingsApprovalRulesDesc:`全局自定义人机协同拦截规则,支持基于正则/通配符/路径对工具命令或参数配置「需审批」、「直接拒绝」或「免审放行」。规则自顶向下首条匹配优先。`,manageApprovalRules:`管理审批规则`,approvalRuleNew:`新增规则`,approvalRuleEdit:`编辑规则`,approvalRuleDelete:`删除`,approvalRuleReset:`恢复默认`,approvalRuleActionAsk:`需审批`,approvalRuleActionDeny:`直接拒绝`,approvalRuleActionAllow:`免审放行`,approvalRuleTools:`适用工具`,approvalRuleToolsTip:`输入工具名(如 bash、write、edit),以逗号分隔;输入 * 表示匹配所有工具`,approvalRuleField:`检查字段`,approvalRuleFieldCommand:`命令 (command)`,approvalRuleFieldPath:`文件路径 (path)`,approvalRuleFieldParams:`完整参数 JSON (params)`,approvalRuleMatch:`匹配方式`,approvalRuleMatchRegex:`正则表达式 (regex)`,approvalRuleMatchGlob:`通配符 (glob)`,approvalRuleMatchContains:`包含子串 (contains)`,approvalRuleMatchPrefix:`前缀开头 (prefix)`,approvalRuleMatchOutsideWs:`工作区外路径 (outside_workspace)`,approvalRuleValue:`匹配表达式 / 模式串`,approvalRuleValueTip:`根据匹配方式输入对应规则,例如 rm -rf 或 \\.env$`,approvalRuleLabel:`规则名称 (中文)`,approvalRuleLabelEn:`规则名称 (英文)`,approvalRuleReason:`拦截原因说明 (中文)`,approvalRuleReasonEn:`拦截原因说明 (英文)`,approvalRuleEnabled:`启用该规则`,approvalRuleBuiltin:`内置`,approvalRuleEmpty:`当前没有审批规则。点击右上角「+ 新增规则」添加自定义拦截与放行策略。`,approvalRuleMoveUp:`上移`,approvalRuleMoveDown:`下移`,settingsMcp:`MCP 服务器`,settingsMcpDesc:`Model Context Protocol (MCP) 服务器管理。支持通过 stdio 或 HTTP 将外部工具引入 AI 会话。配置支持 Pi 全局 (~/.pi/agent/mcp.json) 与当前项目 (.pi/mcp.json)。`,mcpReload:`重新加载`,mcpAddServer:`添加服务器`,mcpFilterAll:`全部`,mcpFilterGlobal:`全局设置`,mcpFilterProject:`项目级设置`,mcpGlobalPath:`全局配置`,mcpProjectPath:`项目配置`,mcpEmptyTitle:`未配置 MCP 服务器`,mcpEmptyDesc:`Model Context Protocol 让 AI 可以访问本地文件系统、数据库、GitHub 或自定义工具服务器。点击下方快捷预设或右上角按钮添加。`,mcpQuickAdd:`快捷添加预设`,mcpScopeGlobal:`全局设置`,mcpScopeProject:`项目级设置`,mcpScopeGlobalHint:`保存在 ~/.pi/agent/mcp.json,在所有项目中通用生效`,mcpScopeProjectHint:`保存在当前工作区 .pi/mcp.json,仅在当前项目生效`,mcpStatusRunning:`运行中`,mcpStatusStopped:`已停用`,mcpStatusError:`异常`,mcpEnableHint:`启用该 MCP 服务器`,mcpDisableHint:`停用该 MCP 服务器(保留配置)`,mcpToolsCount:`包含 {count} 个工具`,mcpDeleteConfirmTitle:`删除 MCP 服务器`,mcpDeleteConfirmDesc:`确定要从{scope}中删除 MCP 服务器「{name}」吗?该操作不可撤销。`,mcpAddModalTitle:`添加 MCP 服务器`,mcpEditModalTitle:`编辑 MCP 服务器`,mcpPresetSelect:`预设模板(快捷填充)`,mcpScopeLabel:`配置作用域`,mcpNameLabel:`服务器标识名`,mcpNamePlaceholder:`例如 filesystem, github, fetch`,mcpTransportLabel:`传输协议`,mcpTransportStdio:`命令行进程`,mcpTransportHttp:`远程端点`,mcpCommandLabel:`启动命令`,mcpCommandPlaceholder:`例如 npx, uvx, node, python`,mcpArgsLabel:`命令行参数`,mcpArgsPlaceholder:`以空格分隔的参数列表,例如 -y @modelcontextprotocol/server-filesystem .`,mcpCwdLabel:`运行工作目录 (cwd)`,mcpCwdPlaceholder:`留空默认跟随工作区`,mcpEnvLabel:`环境变量 (env)`,mcpAddEnv:`添加变量`,mcpEnvKeyPlaceholder:`变量名(如 API_KEY)`,mcpEnvValuePlaceholder:`变量值`,mcpUrlLabel:`端点 URL`,mcpUrlPlaceholder:`例如 https://mcp.example.com/mcp`,mcpHeadersLabel:`请求头 (Headers)`,mcpAddHeader:`添加请求头`,mcpHeaderKeyPlaceholder:`请求头名称(如 Authorization)`,mcpHeaderValuePlaceholder:`值(如 Bearer token)`,mcpDescriptionLabel:`功能说明`,mcpDescriptionPlaceholder:`简要说明此服务器提供的工具能力`,mcpEnabledLabel:`启用状态`,mcpEnabledDesc:`停用后保留配置但不启动子进程或连接端点`,mcpPresetCustom:`自定义配置`,mcpPresetCustomDesc:`手动输入完整的命令与参数`,mcpPresetFilesystem:`文件系统 (Filesystem)`,mcpPresetFilesystemDesc:`访问指定目录文件的标准 MCP 服务器`,mcpPresetFetch:`网页抓取 (Fetch)`,mcpPresetFetchDesc:`抓取并读取网页内容的 MCP 服务器`,mcpPresetMemory:`持久记忆 (Memory)`,mcpPresetMemoryDesc:`基于知识图谱的持久化记忆管理`,mcpPresetGithub:`GitHub 代码库`,mcpPresetGithubDesc:`GitHub 仓库、Issue 与 PR 操作工具`,mcpPresetSqlite:`SQLite 数据库`,mcpPresetSqliteDesc:`查询与操作本地 SQLite 数据库`,mcpTabConfigured:`已配置`,mcpTabMarket:`MCP 市场`,mcpBrowseMarket:`浏览 MCP 市场`,mcpMarketSearchPlaceholder:`搜索 MCP 服务器名称、包名或能力描述…`,mcpBadgeOfficial:`官方`,mcpConfigured:`已配置`,mcpAddGlobal:`添加全局`,mcpAddProject:`添加项目`,mcpAddGlobalHint:`添加至 Pi 全局配置 (~/.pi/agent/mcp.json),在所有项目生效`,mcpAddProjectHint:`添加至当前项目配置 (.pi/mcp.json),仅在当前项目生效`,skillTabInstalled:`已安装`,skillTabMarket:`技能市场`,skillEmptyDesc:`暂未安装任何技能,前往技能市场发现并一键安装开箱即用的专业工作流技能。`,skillBrowseMarket:`浏览技能市场`,skillMarketSearchPlaceholder:`搜索技能名称、工作流或能力说明…`,skillCatAll:`全部`,skillCatQuality:`代码质量`,skillCatWorkflow:`规范与流程`,skillCatArchitecture:`架构设计`,skillCatDevops:`运维与数据库`,skillCatStack:`语言专项`,skillInspectPrompt:`查看提示词`,skillInstalled:`已安装`,skillInstallGlobal:`全局安装`,skillInstallProject:`项目安装`,skillInstallGlobalHint:`安装到全局用户技能目录 (~/.pi/agent/skills)`,skillInstallProjectHint:`安装到当前工作区技能目录 (.pi/skills)`,skillInspectModalTitle:`技能详情: {name}`,mcpSourceSelectLabel:`源选择`,mcpSourceSmithery:`Smithery 开放注册中心 (api.smithery.ai)`,mcpSourceGithub:`GitHub 官方仓库 (modelcontextprotocol/servers)`,mcpSourceCustom:`自定义 API / 目录源`,mcpSourceCustomPlaceholder:`输入自定义 MCP 注册中心 API 或 JSON 目录 URL`,mcpMarketLoading:`正在检索远程 MCP 服务器…`,mcpMarketRetry:`重试`,skillRepoSelect:`GitHub 仓库源`,skillRepoDefault:`Anthropic 官方技能库 (anthropics/skills)`,skillRepoCustom:`自定义 GitHub 仓库 (owner/repo)`,skillRepoCustomPlaceholder:`输入 GitHub 仓库,例如 your-org/custom-skills`,skillMarketLoading:`正在从 GitHub 检索技能目录…`,skillContentLoading:`正在拉取 SKILL.md 指令内容…`,skillMarketRetry:`重试`,planBoardTitle:`任务`,planBoardCompleted:`已完成`,planBoardInProgress:`进行中`,planBoardPending:`待执行`,planBoardFailed:`失败`,planImplementBtn:`实施`,planImplementTip:`关掉只规划闸门,按上面的计划开始写代码`,planImplementRequest:`按计划看板上的计划开始实施。`,planBoardExportMarkdown:`复制为 Markdown`,planBoardExportSuccess:`计划已复制为 Markdown`,planCleanHandoffBtn:`✨ 净室`,planCleanHandoffTip:`在新会话中开始实施(带走目标与计划,避免历史探索上下文干扰)`,planCleanHandoffPrompt:`我们已在规划期制定了如下任务计划。这是一个全新的净室执行会话,请专注于按照计划步骤推进实施:`,planBoardAddStep:`添加步骤`,planBoardEditStep:`编辑步骤`,planBoardDeleteStep:`删除步骤`,planBoardStepTitlePlaceholder:`步骤标题…`,planBoardStepDescPlaceholder:`步骤描述/验收要求(可选)…`,placeholderPlanMode:`📋 计划模式:只调研与制定计划,代码写入操作将被拦截…`,planModeBadge:`只读规划中`,clear:`清空`,confirm:`确定`,forkBadge:`分支`,forkBadgeTip:`派生自`,reaskFromHere:`从此处重新提问`,editPlaceholder:`修改问题内容…`,editAttachmentHint:`原附件已保留,可粘贴/拖入新图片或文件 · ⌘/Ctrl+Enter 提交 · Esc 取消`,expandMsg:`展开`,collapseMsg:`收起`,toolCalls:`工具调用`,bashRuns:`终端运行`,images:`图片`,update:`更新`,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)。`,updateDesktopNote:`桌面版不走 npm 全局安装:它的服务随应用本身发布,上面的终端命令对它无效。请用下面的应用内更新,或去下载页换包。`,updateDesktopCheck:`检查桌面更新`,updateDesktopChecking:`正在检查桌面更新…`,updateDesktopAvailable:`发现桌面版新版本 v{version}`,updateDesktopDownload:`下载更新`,updateDesktopDownloading:`下载中 {n}%`,updateDesktopDownloaded:`已下载完成,点“安装并重启”生效`,updateDesktopInstall:`安装并重启`,updateDesktopManual:`去下载页手动安装`,updateDesktopError:`桌面更新失败:{error}`,updateDesktopNoBridge:`当前桌面壳太旧,没有内置更新通道,请去下载页换包。`,updatesAllTitle:`全部组件更新`,updatesAllBadge:`{n} 个更新`,updatesAllUpToDate:`全部组件均为最新`,kindWebUi:`Web 界面`,kindPiCore:`核心`,kindPackage:`组件`,kindGitExtension:`Git 组件`,kindPlugin:`插件`,pluginCheckUpdates:`检查插件更新`,pluginCheckUpdatesHint:`检查已安装界面插件是否有新版本(对比远端版本与 commit)`,pluginUpdateAvailableBadge:`可更新`,pluginUpdateAvailableDetail:`可更新:{version}`,updatesAllRefresh:`重新检查全部`,updateCheckFailed:`检查失败`,updateBtn:`更新`,updateAllBtn:`全部更新`,updatePkgTabTitle:`更新 {name}`,updateAllTabTitle:`更新全部组件`,piCoreSplitRun:`服务运行 v{running}`,piSdkSplitNote:`本服务运行的是 pi v{running};机器上装有更新的全局 pi v{installed}。重启服务即可跟上(默认自动选用更新的那份);设了 PI_WEB_SDK=bundled 时会一直用自带副本,升级 pi-web-ui 也可让自带副本跟上。`,piSdkBundledNote:`当前使用随包自带的 pi 引擎 v{running}(随 pi-web-ui 更新)。安装全局引擎后重启服务即可自动切换(服务默认跟随版本更高的那份)。`,installGlobalEngineBtn:`安装全局引擎`,installGlobalEngineTabTitle:`安装全局 pi 引擎`,restartService:`重启服务`,restartingService:`重启中…`,restartServiceTip:`重启 pi-web-ui 服务({name}):本实例由系统服务托管(launchd/systemd/Windows watchdog),进程退出后会被自动拉起,本页会自动重连;更新完成后用它生效`,computer:`此电脑`,workspaceModeLocal:`本地目录`,workspaceModeRemote:`远程 (SSH)`,sshHost:`主机地址`,sshPort:`端口`,sshUser:`用户名`,sshAuthType:`认证方式`,sshPassword:`密码`,sshKeyPath:`私钥路径`,sshAgent:`SSH 代理 (Agent)`,sshSaveProfile:`记住此连接`,sshProfileName:`配置名称 (可选)`,sshConnectAndProbe:`连接并探测环境`,sshConnecting:`正在连接与探测环境…`,sshSavedProfiles:`已保存的远程连接`,sshInstallTool:`一键自动安装`,sshInstalling:`正在安装…`,sshSkipAndBrowse:`跳过并继续浏览`,sshOpenRemoteWorkspace:`打开此远程工作区`,sshDisconnect:`断开连接`,sshDeleteProfileConfirm:`确认删除此连接配置吗?`,rootDir:`根目录`,homeDir:`用户目录`,desktopDir:`桌面`,filesShowHidden:`显示以 . 开头的隐藏文件`,filesHideHidden:`隐藏以 . 开头的文件`,filesHelp:`浏览:点文件夹进入、点文件预览,「..」返回上级;「根目录」回当前项目根,「此电脑」浏览全盘换盘符,「🏠」直达用户目录,「🖥️」直达桌面。
4
4
  文件操作:右键可新建文件/文件夹、重命名、复制/剪切/粘贴、创建副本、删除、上传文件;文件可下载,行尾按钮可复制名称/路径。
5
5
  切换项目:文件夹右键「以项目打开」,或点右下角 📁 路径按钮输入/选择目录。
@@ -324,46 +324,46 @@ Avoid three test anti-patterns: tests coupled to the implementation, tautologica
324
324
 
325
325
  {path}
326
326
 
327
- It only opens after you confirm.`,settingsExtensions:`Extensions`,settingsUiPlugins:`UI plugins`,pluginListTab:`Plugin list`,noUiPlugins:`No UI plugins installed (<dataDir>/plugins/)`,pluginPhaseActive:`Active`,pluginPhaseDisabled:`Disabled`,pluginPhaseFailed:`Failed`,pluginPhaseIdle:`Frontend-only`,pluginRescan:`Rescan`,pluginRescanHint:`Re-scan the plugin directory (picks up new/fixed plugins; failure records are cleared and re-evaluated)`,dshPatches:`DSH user patches`,dshPatchesDesc:`Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.`,dshPatchesRescan:`Rescan`,dshPatchesRescanHint:`Re-scan the patch directory and restart the DSH runtime so new patches take effect`,dshPatchesEmpty:`No patch files yet`,dshPatchesPath:`Patch directory: `,dshPreset:`Agent preset`,dshPresetNewChat:`New chat with this preset`,dshPresetLocked:`Locked`,dshPresetBlankOnly:`Locked after the first message; blank sessions can switch`,dshPresetBroken:` (unavailable)`,dshPresetUser:`custom`,dshPresetDefaultTag:`default`,dshPresetMinimalNote:`Minimal: persistent shell only; host plugin tools and questionnaire unavailable`,dshDefaultPreset:`Default preset`,dshDefaultPresetDesc:`Preset for new chats; blank sessions can switch anytime, locked after the first message`,dshPresetUserNote:`Custom presets come from the user preset directory (trusted like shell access); compositions using bare package names cannot mount here (known limitation)`,"preset.standard":`Full access`,"preset.minimal":`Minimal`,"preset.code":`Code development`,"preset.reader":`Read-only analysis`,"preset.ask":`Chat only`,"preset.standardDesc":`All available tools and extension capabilities (default)`,"preset.minimalDesc":`Keeps only bash and read; plugin tools, skill catalog and terminal guidance are hidden too`,"preset.codeDesc":`Focused on reading, writing and running code (bash, read, edit, write, edit_soft); plugin tools and skill catalog are hidden too`,"preset.readerDesc":`Keeps only read-only tools and forbids writes; plugin tools are hidden too (read/write unknown, handled conservatively)`,"preset.askDesc":`No-tools Q&A: the model never calls a tool; plugin tools and skill catalog are hidden too`,dshPerm:`Permissions`,dshPermReadOnly:`Read Only`,dshPermReadOnlyDesc:`Read files and run read-only commands; writes are always denied, no prompts`,dshPermWorkspaceWrite:`Workspace Write`,dshPermWorkspaceWriteDesc:`Read/write inside the workspace, no prompts; out-of-scope operations are denied directly`,dshPermFullAccess:`Full access`,dshPermFullAccessDesc:`Sandbox off, unrestricted machine access; only for tasks you trust`,dshPermFullAccessTag:`risky`,dshPermCustom:`Custom`,dshPermConfirmFull:`Click again to confirm full access`,dshPermDefault:`Default permission for new chats`,dshPermDefaultDesc:`Initial permission for new chats; the current chat can switch live anytime, no restart`,uiPluginNoSource:`Installed manually — no recorded source, online update unavailable`,uiPluginPerms:`Permissions`,pluginDiagTitle:`Diagnostics`,pluginDiagShow:`Diagnostics`,pluginDiagHide:`Hide`,pluginLogTitle:`Runtime logs`,pluginLogShow:`Logs`,pluginLogHide:`Hide`,pluginLogLevel:`Level`,pluginLogAll:`All`,pluginLogEmpty:`No logs yet`,pluginLogClear:`Clear`,pluginDomNeed:`⚠ Requests full DOM access`,pluginDomDesc:`This plugin can freely read and write the page DOM (bypassing UI layout restrictions). Grant only to plugins from sources you trust; once granted its UI code can touch the topbar, composer and any page element.`,pluginDomGrant:`Grant DOM access`,pluginDomRevoke:`Revoke DOM access`,pluginDomGranted:`Full DOM access granted`,pluginSettingsTitle:`Configuration`,pluginSettingsShow:`Configure`,pluginSettingsHide:`Hide`,pluginSettingsSave:`Save plugin settings`,pluginSettingsSaving:`Saving…`,pluginSettingsReset:`Reset defaults`,pluginSettingsInherit:`Follow global default`,pluginSecretSet:`Set (stored encrypted, leave blank to keep)`,pluginSecretUnset:`Not set (stored encrypted)`,settingsPresets:`Presets`,settingsSubagentTemplates:`Subagent templates`,settingsSubagentTemplatesDesc:`Presets for spawned subagents (role system prompt + skills/extensions whitelist + optional model and thinking level). AI may pick a template (subagent_spawn template param) or spawn without one; disabled templates stay in the panel but are invisible to AI tools.`,noSubagentTemplates:`No subagent templates yet. AI can pick a template when spawning a subagent (role prompt + skills/extensions whitelist + optional model and thinking level), or spawn without a template param for default config.`,subagentTemplateNew:`New template`,subagentTemplateEdit:`Edit`,subagentTemplateClosed:`Disabled`,tplDefaultBadge:`Built-in`,subagentDefaultModelLabel:`Default subagent model`,subagentFollowMain:`Follow the main conversation's current model`,subagentDefaultModelHint:`Fallback model for all subagents (a template's own model and the subagent_spawn model param take priority); does not change the main conversation's model.`,subagentNoModels:`No usable models yet (configure a provider API key first) — subagents will follow the main conversation's model.`,subagentTemplateOffHint:`Disabled templates stay in the panel and can be re-enabled, but AI tools can't see or pick them`,subagentTemplateEnable:`Enable`,subagentTemplateDisable:`Disable`,tplNamePlaceholder:`Template name (referenced by AI via subagent_spawn's template param)…`,tplDescriptionPlaceholder:`Description (AI uses it to judge when to pick this template)…`,tplDescriptionEnPlaceholder:`English description (shown to AI under English UI; falls back to the description above)…`,tplPromptModeLabel:`System prompt mode`,tplModelLabel:`Model (empty = follow main conversation)`,tplThinkingLabel:`Thinking level`,tplThinkingFollowMain:`Follow the main conversation's current thinking level`,tplThinkingHint:`Empty = follow the main conversation's current thinking level (same idea as the model fallback); unsupported levels are clamped to the nearest one the model supports.`,tplSystemPromptLabel:`System prompt`,tplSystemPromptPlaceholder:`Template role system prompt… (may be empty in append mode)`,tplSystemPromptEnPlaceholder:`English system prompt… (used under English UI; falls back to the prompt above)`,tplWhitelistHint:`Whitelist: checked = the subagent only gets these; none checked = follow the main session settings`,tplSkillsLabel:`Skills whitelist`,tplExtensionsLabel:`Extensions whitelist`,tplSave:`Save template`,tplCancel:`Cancel edit`,tplDelete:`Delete template`,settingsScheduler:`Scheduled tasks`,schedulerDesc:`Put the agent on a schedule (dependency audits, test runs, morning briefings…): headless pseudo-client runs, no browser needed; notifies when done, history included.`,schedulerEmpty:`No scheduled tasks yet. Click “New task” above to schedule the first one: a 9 AM daily check or an hourly test run.`,schedulerNew:`New task`,schedulerEdit:`Edit`,schedulerDelete:`Delete`,schedulerRunNow:`Run now`,schedulerRunning:`Running…`,schedulerEnable:`Enable`,schedulerDisable:`Disable`,schedulerEnabled:`Enabled`,schedulerDisabled:`Disabled`,schedulerNamePlaceholder:`E.g. Daily dependency & health check…`,schedulerDescPlaceholder:`Description (optional): what this task does…`,schedulerCwdLabel:`Target project`,schedulerCwdPlaceholder:`/absolute/path/to/project…`,schedulerUseCurrentCwd:`Use current project`,schedulerKindLabel:`Schedule`,schedulerKindCron:`Cron expression`,schedulerKindInterval:`Fixed interval`,schedulerCronPlaceholder:`E.g. 0 9 * * * (daily 9:00 AM)`,schedulerPresetDaily:`Daily 9:00 AM`,schedulerPresetHourly:`Hourly on the hour`,schedulerPresetHalfHour:`Every 30 minutes`,schedulerPresetWorkday:`Weekdays 9:00 AM`,schedulerPresetMonday:`Mondays 9:00 AM`,schedulerPresetCustom:`Custom…`,schedulerIntervalMinutes:`Interval (minutes, min 1)`,schedulerPromptPlaceholder:`The task for the agent, e.g. audit dependencies and report upgrades…`,schedulerModelLabel:`Model (empty = default)`,schedulerThinkingLabel:`Thinking level (empty = default)`,schedulerCatchUp:`Catch up one missed run after restart`,schedulerCatchUpHint:`When checked, a trigger missed during downtime runs once at next startup; otherwise it is skipped.`,schedulerNextFire:`Next`,schedulerLastRun:`Last`,schedulerNeverRun:`Never ran`,schedulerHistory:`History`,schedulerManualBadge:`manual`,schedulerRunOk:`ok`,schedulerRunFail:`failed`,schedulerConfirmDelete:`Delete scheduled task “{name}”? Its history goes with it.`,schedulerSave:`Save task`,schedulerCancelEdit:`Cancel edit`,tplInherit:`Follow main session`,settingsEnabled:`Enabled`,settingsDisabled:`Disabled`,presetNamePlaceholder:`Preset name…`,saveAsPreset:`Save as preset`,applyPreset:`Apply`,deletePreset:`Delete preset`,noSkills:`No skills`,noExtensions:`No extensions`,noPresets:`No presets yet (tune your current settings, then enter a name above to save them as a preset)`,presetShare:`Share presets`,presetShareShareBtn:`Share preset`,presetShareImportBtn:`Import preset`,presetShareBrowseBtn:`Browse shared`,presetShareTabExport:`Export / share`,presetShareTabImport:`Import`,presetShareTabBrowse:`Browse shared`,presetShareSource:`Source`,presetShareSourceCurrent:`Current settings`,presetShareDescription:`Description`,presetShareDescriptionPlaceholder:`What is this preset good for? (optional)`,presetShareTags:`Tags`,presetShareTagsPlaceholder:`Comma separated, e.g. coding, minimal (optional)`,presetShareAuthor:`Author (optional)`,presetExportJson:`Export JSON`,presetExportDownload:`Download file`,presetShareSubmit:`Share to the community repo`,presetShareHint:`Creates a GitHub issue: with the gh CLI or a GitHub token it is submitted for you (the repo bot validates and commits it, and it shows up under "Browse shared" within minutes). With neither, a prefilled new-issue page opens — just hit Submit (for very large presets the JSON is copied to the clipboard instead, so you can paste it).`,presetShareSubmitting:`Submitting…`,presetShareOpenWebTitle:`Submit Issue on GitHub`,presetShareOpenWebBtn:`Open submission page in new window`,presetShareOpenIssueBtn:`View created issue`,presetShareCopyJson:`Copy preset JSON`,presetSharePopupBlocked:`If your browser blocked the popup, click the button below to open:`,presetShareBrowserCopied:`Submission page generated — just hit Submit (for large presets the JSON is on your clipboard, paste it)`,presetImportText:`Paste preset JSON`,presetImportTextPlaceholder:`Paste the exported JSON here (or drop a .json file)…`,presetImportPickFile:`Choose file`,presetImportFromUrl:`Import from URL`,presetImportUrlPlaceholder:`https://raw.githubusercontent.com/…/preset.json`,presetImportPreview:`Preview`,presetImportFields:`{n} fields will be written`,presetImportIgnored:`Unknown fields ignored: {list}`,presetImportRejected:`Dropped (wrong type): {list}`,presetImportReplaces:`A local preset with this name already exists — importing overwrites it`,presetImportApply:`Apply right after importing`,presetImportConfirm:`Import`,presetImportPick:`Import selectively: pick what to write`,presetImportSelectAll:`All`,presetImportSelectNone:`None`,presetImportAllSelected:`All selected`,presetImportNoneSelected:`Select at least one field to import`,presetImportPickHint:`Unchecked fields keep your current values; you can still tweak everything afterwards in Settings.`,presetGroupPrompt:`Prompts`,presetGroupTools:`Tools & switches`,presetGroupTerminal:`Terminal takeover`,presetGroupSkills:`Skills & extensions`,presetGroupAi:`Model behavior & dedicated prompts`,presetGroupUi:`Interface & interaction`,presetGroupEngine:`Engine defaults`,presetGroupOther:`Other`,presetImportImported:`Imported: {name}`,presetBrowseEmpty:`No presets in the shared repo yet`,presetBrowseLoading:`Loading community presets…`,presetBrowseSearch:`Search name / tag / author`,presetBrowseRefresh:`Refresh list`,presetBrowseCached:`List cached at {time} — hit refresh to re-fetch`,presetBrowseImport:`Import`,presetBrowseIssue:`Source issue`,presetBadgeTemplate:`Has template`,presetBadgeReview:`Has review prompt`,loadingSession:`Loading session…`,connectingServer:`Connecting to pi-web-ui server…`,localePacks:`Language packs`,localeGetMore:`Get more languages`,localeInstalled:`Installed`,localeInstall:`Download`,localeRemove:`Remove`,localeDownloading:`Downloading…`,localeRemoving:`Removing…`,localeInstallFailed:`Download failed: {error}`,localeListFailed:`Couldn't load language packs: {error}`,localeRemoveHint:`You can re-download it anytime`,wallpaperTitle:`Chat wallpaper`,wallpaperDesc:`Show a full-window background image (side panels, top and bottom bars included): a theme-provided image applies automatically, a URL here takes precedence; use dim and blur to keep text readable.`,wallpaperUrlPh:`Image URL (https://…, empty = off)`,wallpaperDim:`Dim`,wallpaperBlur:`Blur`,wallpaperClear:`Clear`,wallpaperUpload:`Upload image`,wallpaperUploadFailed:`Couldn't read the image (or it's too big) — try another one`,skillFullTextLabel:`Inject full skill text`,skillFullTextDesc:`Expand skill file contents inline into the system prompt (8KB per file, 32KB total cap); otherwise only a catalog is listed and the model reads files on demand`,skillFullTextShort:`Full`,delegateOpenSubagent:`Open subagent`,delegateSecTask:`Task`,delegateSecExpected:`Expected outcome`,delegateSecTools:`Required tools`,delegateSecMustDo:`Must do`,delegateSecMustNotDo:`Must not do`,delegateSecContext:`Context`,copyConversationId:`Copy conversation ID`,copyConversationPath:`Copy session file path`,copyConversationLink:`Copy link to session`,copyMessageLink:`Copy link to message`,quoteConversation:`Quote into composer (readable by the AI)`,quoteConversationShort:`Quote`,attachConversation:`Conversation reference: {name} (the AI reads it via conversation_read on demand)`,attachConversationShort:`conversation`,quoteSelection:`Quote`,quoteText:`Text quote`,quoteSource:`Source message: {id}`,removeQuote:`Remove quote`,presentOpenLocal:`Open locally`,presentMissing:`File missing or unreadable (moved, deleted, or outside the workspace?)`,presentEmpty:`Nothing to show`,presentAutoOpen:`Auto-open previews the AI presents`,presentAutoOpenDesc:`When the AI presents files with present_files and marks one as 'look at this first', open the file preview dialog automatically. Off (default): the cards stay inline and you open them with one click.`,presentFilesEnabledDesc:`Let the AI push artifacts (screenshots, charts, videos, reports, logs) into the chat as preview cards: images/videos/audio are shown inline, text gets an excerpt plus a one-click preview dialog, and every row carries open-locally / reveal-in-file-manager / download / copy-path actions. The auto-open switch lives on the Chat page.`,presentFilesOffHint:`Disabled: the AI can only tell you the file path — no cards, no open-locally buttons`,skillEnabledDesc:`Load skill bodies by name (the skill catalog stays in the system prompt): the full text is fetched only when a skill is actually needed, instead of making the model guess a path and call read.`,skillOffHint:`Disabled: the AI can no longer load skill bodies by name (the catalog in the prompt is unaffected)`,claimFilesEnabledDesc:`Declare which files you are about to edit so parallel runs in the same project can steer clear (advisory only — it never blocks edits). First-wins; claims expire automatically.`,claimFilesOffHint:`Disabled: the AI can no longer claim files (post-hoc touch reminders still work, only the up-front intent signal is gone)`,planUpdateEnabledDesc:`Structured task plan updates (Plan Mode / Step State Machine): allows the model to break complex tasks into steps and track progress in real time.`,planUpdateOffHint:`Disabled: AI can no longer update the structured plan board`,compactContextEnabledDesc:`Proactively compact context based on the current issue: allows AI to independently specify compression focus, retain core task context, drop irrelevant history, and control retention scope.`,compactContextOffHint:`Disabled: AI cannot proactively invoke context compaction (you can still use /compact or trigger auto-compaction)`,mcpManageEnabledDesc:`MCP server inspection and installation (list / check / install / remove / reload): allows AI to check whether an MCP server is installed and conveniently install/configure npm or remote MCP servers with live hot-reload.`,mcpManageOffHint:`Disabled: AI cannot invoke mcp_manage to check or install MCP servers`,evalEnabledDesc:`Execute Python or JavaScript/TypeScript code in an isolated sandbox with persistent variables; ideal for calculations, data analysis, and algorithm verification (default-off to prevent tool crowding-out).`,evalOffHint:`Disabled: the AI cannot use the persistent code sandbox (can still run scripts via bash)`,patchToolEnabledDesc:`High-reliability structural patch tool (Hashline): line-anchored editing with 4-hex content hashes, syntactic AST block matching, and clipboard registers. Automatically attempts 3-way merge conflict recovery if files diverged.`,patchToolOffHint:`Disabled: AI falls back to basic string replacement via edit`,lspToolEnabledDesc:`Native Language Server Protocol (LSP) tool: IDE-grade semantic code intelligence (definition, references, hover, diagnostics, documentSymbol outline, read_symbol precise slicing, workspaceSymbol search, and cascade impact diagnostics). Multi-agent shared process pool with idle sleep, zero external dependencies.`,lspToolOffHint:`Disabled: AI cannot query LSP semantics and falls back to text search`,codemodeEnabledDesc:`Run JavaScript in a QuickJS WASM sandbox to batch tool calls and filter output: intermediate results never enter LLM context, keeping context concise (default off; requires capable model).`,codemodeOffHint:`Disabled: AI cannot run codemode scripts to batch call tools`,codemodeNestedCalls:`Nested tool calls`,codemodeScript:`JavaScript script`,codemodeFullOutput:`Full output file`,codemodeModeLabel:`Execution Mode`,codemodeModeHint:`In standard mode all tools are directly visible; in strict code mode tools are hidden from the model and must be invoked via sandbox scripts`,codemodeModeOn:`Standard Mode (on)`,codemodeModeOnly:`Strict Code Mode (only)`,codemodeInlineBudgetLabel:`Inline Budget`,codemodeInlineBudgetHint:`Estimated tokens the codemode prompt may spend on tool declarations directly (default: 3000)`,codemodeNestedApprovalBadge:`Nested Call`,codemodeNestedApprovalDesc:`This tool call was triggered by a background codemode sandbox script`,codemodeSavedImages:`Generated Images`,toolSearchEnabledDesc:`BM25-based tool discovery and activation: search and activate tools via natural language queries (ideal for large MCP toolsets to prevent context bloat).`,toolSearchOffHint:`Disabled: AI cannot use tool_search to discover tools`,toolSearchLoaded:`Activated tools`,toolInfoMenuLabel:`Show tool details`,toolInfoTitle:`Tool details`,toolInfoLoading:`Loading tool definition…`,toolInfoUnsupported:`This engine can't show tool definitions`,toolInfoMissing:`No definition found for this tool (it may come from an uninstalled plugin or an older version)`,toolInfoActive:`Enabled`,toolInfoInactive:`Disabled`,toolInfoSource:`Source`,toolInfoDescription:`Description`,toolInfoNoDescription:`This tool has no description`,toolInfoPromptSnippet:`Prompt snippet`,toolInfoGuidelines:`Prompt guidelines`,toolPromptEdit:`Edit description`,toolPromptEdited:`Description customized (click to edit)`,toolPromptHint:`Leave a field empty to use the tool's built-in text. The three fields map to the tool description the model sees, the one-line summary in the system prompt, and the behavioral guidelines.`,toolPromptDescription:`Tool description (how the model understands this tool)`,toolPromptSnippet:`Prompt snippet (the line in the system prompt's Available tools list)`,toolPromptGuidelines:`Behavioral guidelines (Guidelines section, one per line)`,toolPromptDefault:`Built-in text`,toolPromptReset:`Reset to default`,toolPromptSave:`Save`,toolPromptUnavailable:`No definition for this tool (engine unsupported, or the tool is uninstalled) — you can still fill in overrides, but they only apply once the tool exists.`,toolInfoParams:`Parameters`,toolInfoParamsNone:`This tool takes no parameters`,toolInfoSchemaDropped:`The parameter schema is too large and was omitted (see the raw JSON below)`,toolInfoRawSchema:`Raw JSON schema`,toolInfoRequired:`required`,toolInfoFootnote:`This is the tool's definition — not this call's arguments or result.`,elsewhereOfflineBadge:`Offline`,elsewhereOfflineTip:`The page holding this conversation is gone (tab or browser closed) but the run is still on the server — click this row twice to take it over here`,sandboxNewBtn:`Launch Sandbox Project (isolated workspace)`,sandboxModalTitle:`Launch Sandbox Project`,sandboxModalSubtitle:`Experiment freely inside a hard-jailed copy — no changes ever touch your original files.`,sandboxModeLabel:`Initial Content`,sandboxModeBlank:`Blank Sandbox`,sandboxModeBlankDesc:`Clean empty directory for quick prototypes, scripts, or file processing`,sandboxModeImport:`Import Existing Project`,sandboxModeImportDesc:`Clone source project files (auto-skips node_modules/caches); original stays untouched`,sandboxSourceLabel:`Source Project Path`,sandboxSourcePlaceholder:`Enter or select a local project path to import`,sandboxLifecycleLabel:`Lifecycle`,sandboxLifecycleEphemeral:`Temporary (Use & Discard)`,sandboxLifecycleEphemeralDesc:`Ideal for one-off experiments; destroy anytime or convert to permanent`,sandboxLifecyclePermanent:`Permanent Sandbox`,sandboxLifecyclePermanentDesc:`Kept in your projects list for ongoing experimentation`,sandboxNameLabel:`Sandbox Name (optional)`,sandboxNamePlaceholder:`Leave blank to auto-generate`,sandboxCreateSubmit:`Launch Sandbox`,sandboxBadgeEphemeral:`Temp Sandbox`,sandboxBadgePermanent:`Sandbox`,sandboxBannerTitle:`Sandbox Isolation: {name}`,sandboxBannerSourceDesc:`Source: {source} (read-only protected; all edits stay inside this sandbox)`,sandboxBannerBlankDesc:`Isolated workspace (hard jail active; writing outside sandbox is blocked)`,sandboxActionPersist:`Keep Permanently`,sandboxActionPersistTip:`Convert this temporary sandbox into a permanent sandbox project`,sandboxActionApplySource:`Sync to Source`,sandboxActionApplySourceTip:`Sync modified files from this sandbox back to the source project (preserves .git)`,sandboxActionApplyConfirm:`Sync modified files from sandbox "{name}" back to source project ({source})?`,sandboxActionReset:`Reset`,sandboxActionResetTip:`Wipe sandbox and restore initial state (re-clones clean copy from source if imported)`,sandboxActionResetConfirm:`Reset sandbox "{name}"? Unexported changes in the sandbox will be wiped and restored to initial state.`,sandboxActionPromote:`Save as Project`,sandboxActionPromoteTip:`Export this sandbox to a formal project directory outside sandboxes`,sandboxActionDestroy:`Destroy`,sandboxActionDestroyTip:`Permanently delete this sandbox directory and switch back`,sandboxActionDestroyConfirm:`Permanently destroy sandbox "{name}" and delete all its files? This cannot be undone.`,sandboxPromoteTitle:`Save Sandbox as Formal Project`,sandboxPromoteSubtitle:`Export files from sandbox "{name}" to a new directory outside the sandbox jail.`,sandboxPromoteTargetLabel:`Target Directory Path (must be a new or empty directory)`,sandboxPromoteTargetPlaceholder:`e.g. ~/projects/my-new-app`,sandboxPromoteSwitchLabel:`Switch to the exported project immediately`,sandboxPromoteSubmit:`Export Project`,sandboxApplyTitle:`Sync Sandbox Changes to Source Project`,sandboxDiffStats:`+{added} added · ~{modified} modified · -{deleted} deleted in sandbox · {unchanged} unchanged`,sandboxDiffEmpty:`This sandbox is identical to the source project — no modified or added files to sync.`,sandboxDiffDeletedNote:`Note: Syncing only writes added and modified files (preserves source .git and never deletes existing source files).`,sandboxApplySubmit:`Confirm Sync ({count} files)`,sandboxEnabledDesc:`Allow AI to create blank or imported copy-on-write sandbox projects (skipping node_modules/caches), inspect diffs, reset, or destroy; syncing changes back to the source project requires user approval.`,sandboxOffHint:`Disabled: AI cannot invoke the sandbox tool to create or manage isolated sandboxes`},Sn=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],Cn={};function wn(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(Cn[e.code]=e,!0)}function Tn(e){delete Cn[e]}function En(e){return e===`zh`?`中文`:e.toUpperCase()}function Dn(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function On(e){let t=await fetch(gn(fn(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var kn=(0,g.createContext)(null);function An(){try{return localStorage.getItem(yn)}catch{return null}}function jn(){return vn(An(),typeof navigator<`u`?navigator.languages:[],null)}function Mn({children:e}){let[t,n]=(0,g.useState)(jn),[r,i]=(0,g.useState)(0),a=(0,g.useRef)(t);a.current=t;let o=(0,g.useCallback)(e=>{n(e);try{localStorage.setItem(yn,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,g.useCallback)(async()=>{let e,t=null;try{let n=await On(`/api/locales`);e=n.packs??[],t=n.defaultLocale??null}catch{return null}return await Promise.all(e.filter(e=>e.installed).map(async e=>{try{let t=await On(`/api/locales/${e.code}`);return wn({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,g.useEffect)(()=>{s().then(e=>{if(!An()?.trim()){let t=vn(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!Cn[t]){let t=vn(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(yn,t)}catch{}}})},[s]);let c=(0,g.useMemo)(()=>[...Sn,...Object.values(Cn).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,g.useCallback)((e,n)=>{let r=Cn[t]?.strings[e];r&&t!==`zh`&&t!==`ja`&&/[\u4e00-\u9fff]/.test(r)&&(r=void 0);let i=r??(t===`zh`?bn[e]:xn[e]);if(n)for(let[e,t]of Object.entries(n))i=i.replaceAll(`{${e}}`,String(t));return i},[t,r]);(0,g.useEffect)(()=>{document.documentElement.lang=Dn(t)},[t]);let u=(0,g.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(kn.Provider,{value:u,children:e})}function Nn(){let e=(0,g.useContext)(kn);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return Nn().t}var Pn=[{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`},{kind:`approval`,labelKey:`sound.approval`,descKey:`sound.approval.desc`}];function Fn({settings:e,onChange:t,onPreview:n}){let r=Z(),i=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`soundHeader`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(ne,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`enableSound`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:e=>i({enabled:e.target.checked})})]}),Pn.map(({kind:t,labelKey:a,descKey:o})=>(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(a)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(o)})]}),(0,X.jsxs)(`span`,{className:`sound-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`sound-preview`,title:r(`preview`),disabled:!e.enabled,onClick:e=>{e.preventDefault(),n(t)},children:r(`preview`)}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e[t],disabled:!e.enabled,onChange:e=>i({[t]:e.target.checked})})]})]},t)),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`volume`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:e.volume,disabled:!e.enabled,onChange:e=>i({volume:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.volume,`%`]})]})]})}function In(){let[e,t]=(0,g.useState)([]);return(0,g.useEffect)(()=>{if(!qt())return;let e=window.speechSynthesis,n=()=>t(e.getVoices().map(e=>({voiceURI:e.voiceURI,lang:e.lang,name:e.name,localService:e.localService})));return n(),e.addEventListener?.(`voiceschanged`,n),()=>e.removeEventListener?.(`voiceschanged`,n)},[]),e}function Ln({settings:e,onChange:t,onPreview:n}){let r=Z(),i=In(),a=qt(),o=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`ttsHeader`)}),!a&&(0,X.jsx)(`div`,{className:`sound-desc tts-unavailable`,children:r(`ttsUnavailable`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master ${a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(ne,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`ttsEnable`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsEnableDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:!a,onChange:e=>o({enabled:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsAnnounce`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsAnnounceDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.announce,disabled:!e.enabled||!a,onChange:e=>o({announce:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsReadReplies`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsReadRepliesDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.readReplies,disabled:!e.enabled||!a,onChange:e=>o({readReplies:e.target.checked})})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsRate`)}),(0,X.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:e.rate,disabled:!e.enabled||!a,onChange:e=>o({rate:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.rate.toFixed(1),`×`]})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsVoice`)}),(0,X.jsxs)(`select`,{className:`set-input tts-voice-select`,value:e.voiceURI,disabled:!e.enabled||!a,onChange:e=>o({voiceURI:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`ttsVoiceAuto`)}),i.map(e=>(0,X.jsxs)(`option`,{value:e.voiceURI,children:[e.name,` (`,e.lang,`)`,e.localService?``:` · ${r(`ttsVoiceOnline`)}`]},e.voiceURI))]})]}),(0,X.jsx)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:(0,X.jsx)(`button`,{type:`button`,className:`sound-preview tts-preview`,disabled:!e.enabled||!a,onClick:()=>{if(e.voiceURI&&!Jt(e.voiceURI,i,navigator.language)){t({...Wt,...e,voiceURI:``});return}n()},children:r(`preview`)})})]})}function Rn(e){let t=e??(typeof window>`u`?void 0:window);if(!t)return!1;if(t.piDesktop?.isDesktop===!0)return!0;let n=t.navigator?.userAgent;return typeof n==`string`&&n.includes(`Electron/`)}var zn=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),Bn=null,Vn=0;function Hn(){return Bn?.available===!0?Bn.pages??[]:[]}function Un(){Date.now()-Vn<5e3||Wn().catch(()=>{})}async function Wn(){if(Rn())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=zn();if(!e)return{available:!1,pages:[],error:`宿主页面桥不可用:这个 pi-web-ui 页面还没装上扩展桥(装/启用 page-picker 后刷新本页)`};try{let t=await e({op:`status`,timeoutMs:5e3});if(!t.ok)return{available:!1,pages:[],error:t.error??`扩展没有返回状态`};let n=t.result??{},r={available:n.installed===!0,aiControl:n.aiControl===!0,allowEval:n.allowEval===!0,pages:Array.isArray(n.pages)?n.pages:[]};return r.available&&(Bn=r,Vn=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function Gn(e){return e.length===1?e[0]:null}function Kn(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function qn(){let e=zn();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function Jn(e=45e3){let[t,n]=(0,g.useState)(null),r=(0,g.useRef)(!0),i=(0,g.useCallback)(async e=>{let t=await Wn();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,g.useEffect)(()=>{r.current=!0,i(!0);let t=setInterval(()=>void i(!1),Math.max(5e3,e));return()=>{r.current=!1,clearInterval(t)}},[i,e]),{status:t,refresh:()=>void i(!0)}}var Yn=null,Xn=null,Zn=null,Qn=null,$n=null;function er(e){Qn=e}function tr(e){$n=e}function nr(e){return Qn?(Qn(e),!0):!1}function rr(e){return $n?($n(e),!0):!1}function ir(e){Yn=e}function ar(e){Xn=e}function or(e){Zn=e}function sr(){return Zn?(Zn(),!0):!1}function cr(){return!!(Yn||Xn)}function lr(e){let t=typeof e?.text==`string`?e.text:``,n=Array.isArray(e?.attachments)?e.attachments:[],r=t.trim()!==``,i=n.length>0;return!r&&!i||r&&!Yn||i&&!Xn?!1:(i&&Xn?.(n),r&&Yn?.(t),!0)}function ur(){let e=Z(),{status:t,refresh:n}=Jn(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),s=(0,g.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=Gn(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},f=t=>{let n=lr({attachments:[Kn(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},p=()=>{i(!0),n()};return(0,X.jsxs)(`span`,{className:`bc-anchor`,children:[u?(0,X.jsxs)(`span`,{className:`browser-control-split`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control single${l?` attention`:``}`,"data-tip":e(`browserControlSingleTip`,{name:u.title||u.origin}),title:e(`browserControlSingleTip`,{name:u.title||u.origin}),onClick:()=>f(u),children:[(0,X.jsx)(ve,{size:14,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`bc-chip-label`,children:u.title||u.origin})]}),(0,X.jsx)(`button`,{type:`button`,className:`chip browser-control caret`,"data-tip":e(`browserControlOpenPanel`),title:e(`browserControlOpenPanel`),"aria-label":e(`browserControlOpenPanel`),onClick:p,children:`▾`})]}):(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control${l?` attention`:``}`,"data-tip":t?.error??e(l?`browserControlEmpty`:`browserControlTip`),title:t?.error??e(l?`browserControlEmpty`:`browserControlTip`),onClick:p,children:[(0,X.jsx)(ve,{size:14,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[e(`browserControl`),c.length>0?` · ${c.length}`:``]})]}),a&&(0,X.jsx)(`span`,{className:`bc-flash`,children:a}),r&&(0,X.jsx)(dr,{status:t,onRefresh:n,onCite:f,onClose:()=>i(!1)})]})}function dr({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,g.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await qn()||t()}finally{o(!1)}};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:r,children:(0,X.jsxs)(`div`,{className:`modal browser-control-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":i(`close`),onClick:r,children:`✕`}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(ve,{size:16,"aria-hidden":!0}),(0,X.jsx)(`h2`,{children:i(`browserControl`)})]}),(0,X.jsx)(`div`,{className:`modal-desc`,children:i(`browserControlTip`)}),e===null&&(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlChecking`)}),e?.available===!1&&!e.desktop&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlOffline`)}),e?.desktop===!0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlDesktop`)}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlDesktopLead`)}),(0,X.jsx)(`div`,{className:`bc-actions`,style:{marginTop:0},children:(0,X.jsx)(`a`,{className:`btn primary`,href:window.location.href,target:`_blank`,rel:`noreferrer noopener`,children:i(`browserControlOpenInBrowser`)})})]}),e?.available===!1&&!e.desktop&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlInstall`)}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlInstallLead`)}),(0,X.jsx)(`div`,{className:`bc-actions`,style:{marginTop:0},children:(0,X.jsx)(`a`,{className:`btn primary`,href:`https://github.com/xing-shuyin/pi-web-ui/releases/latest/download/page-picker-extension.zip`,target:`_blank`,rel:`noreferrer noopener`,children:i(`browserControlInstallDownload`)})}),(0,X.jsxs)(`ol`,{className:`bc-steps`,children:[(0,X.jsx)(`li`,{children:i(`browserControlInstallStep1`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep2`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep3`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep4`)})]})]}),e?.available===!0&&e.aiControl===!1&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlDisabled`)}),e?.available===!0&&s.length===0&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlEmpty`)}),s.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlPages`)}),(0,X.jsx)(`ul`,{className:`bc-pages`,children:s.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`bc-title`,title:e.title,children:e.title}),(0,X.jsx)(`span`,{className:`bc-origin`,title:e.origin,children:e.origin}),(0,X.jsx)(`span`,{className:`bc-open${e.open?` on`:``}`,children:e.open?i(`browserControlPageOpen`):i(`browserControlPageClosed`)}),(0,X.jsx)(`button`,{type:`button`,className:`bc-cite`,title:i(`browserControlCiteTip`,{name:e.title||e.origin}),onClick:()=>n(e),children:i(`browserControlCite`)})]},e.origin))}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlCiteNote`)})]}),e?.desktop!==!0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlExamples`)}),(0,X.jsxs)(`ul`,{className:`bc-examples`,children:[(0,X.jsx)(`li`,{children:i(`browserControlExample1`)}),(0,X.jsx)(`li`,{children:i(`browserControlExample2`)})]})]}),(0,X.jsxs)(`div`,{className:`bc-actions`,children:[e?.desktop!==!0&&(0,X.jsx)(`button`,{type:`button`,className:`primary`,disabled:a,onClick:()=>void c(),children:i(`browserControlOpenOptions`)}),(0,X.jsx)(`button`,{type:`button`,onClick:t,children:i(`browserControlRefresh`)})]})]})})}var fr=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],pr=[`subagent`],mr=`edit_soft`,hr=`delegate_task`,gr=`ask_user_question`,_r=`todo_list`,vr=`browser_page`,yr=`conversation_read`,br=`skill`,xr=`schedule`,Sr=`eval`,Cr=`present_files`,wr=`claim_files`,Tr=`plan_update`,Er=`compact_context`,Dr=`patch`,Or=`mcp_manage`,kr=`sandbox`,Ar=`codemode`,jr=`tool_search`,Mr=[...fr.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...pr.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:mr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:hr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:gr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:vr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:yr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:wr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:Tr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`planUpdateEnabledDesc`,offHintKey:`planUpdateOffHint`},{name:Dr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`patchToolEnabledDesc`,offHintKey:`patchToolOffHint`},{name:`lsp`,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`lspToolEnabledDesc`,offHintKey:`lspToolOffHint`},{name:Cr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:br,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:Sr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`evalEnabledDesc`,offHintKey:`evalOffHint`},{name:Ar,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`codemodeEnabledDesc`,offHintKey:`codemodeOffHint`},{name:jr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`toolSearchEnabledDesc`,offHintKey:`toolSearchOffHint`},{name:xr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:Er,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`compactContextEnabledDesc`,offHintKey:`compactContextOffHint`},{name:Or,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`mcpManageEnabledDesc`,offHintKey:`mcpManageOffHint`},{name:kr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`sandboxEnabledDesc`,offHintKey:`sandboxOffHint`},{name:_r,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}],Nr=[`bash`,`read`,`edit`,`write`,`powershell`,`ls`,`grep`,`find`];new Set(Mr.map(e=>e.name));var Pr=[...Mr.map(e=>e.name),...Nr];function Fr(e){let t=new Set(e);return Pr.filter(e=>!t.has(e))}function Ir(e,t){let n=Array.from(e);if(!t||t===`standard`)return n;if(t===`ask`)return[];if(t===`minimal`)return n.filter(e=>e===`bash`||e===`read`);if(t===`code`){let e=new Set([`bash`,`read`,`edit`,`write`,`edit_soft`]);return n.filter(t=>e.has(t))}if(t===`reader`){let e=new Set([`write`,`edit`,`edit_soft`,`bash`,`powershell`,`terminal_create`,`terminal_input`,`terminal_close`,`terminal_key`,`codemode`]);return n.filter(t=>!e.has(t))}return n}function Lr(e){return Ir([br],e).includes(br)}var Rr=`pi-web-notify`,zr={enabled:!1};function Br(){try{let e=localStorage.getItem(Rr);if(!e)return{...zr};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:zr.enabled}}catch{return{...zr}}}function Vr(e){try{localStorage.setItem(Rr,JSON.stringify(e))}catch{}}function Hr(){return typeof window<`u`&&`Notification`in window}function Ur(){return Hr()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Wr(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&Gr(t)||Number.isFinite(n)&&Gr(n)?!0:r>0&&r<=400&&i>0&&i<=40}function Gr(e){return e<=-1e4}function Kr(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var qr=Date.now(),Jr=!1;function Yr(){qr=Date.now()}function Xr(){return Math.max(0,Date.now()-qr)}function Zr(){if(Jr||typeof window>`u`)return;Jr=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Yr,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Yr,e)}function Qr(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function $r(){return Zr(),typeof window>`u`||typeof document>`u`?{hasFocus:!0,visibility:`visible`,minimized:!1,idleMs:0,windows:!1}:{hasFocus:typeof document.hasFocus!=`function`||document.hasFocus(),visibility:document.visibilityState??``,minimized:Wr({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Xr(),windows:Qr()}}function ei(){return Hr()?Notification.permission:`denied`}async function ti(){if(!Hr())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function ni(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function ri(e,t=!1){return{body:e,requireInteraction:t,icon:fn(`/icons/icon-192.png`),badge:fn(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:fn(`/`)}}}async function ii(e,t,n=!1){if(!Hr())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=ri(t,n),i;try{let t=await navigator.serviceWorker?.getRegistration();if(t?.active&&typeof t.showNotification==`function`)return await t.showNotification(e,r),{path:`sw`};i=t?`service worker not active`:`no service worker registration`}catch(e){i=ni(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${ni(e)}`}}}async function ai(e,t){Hr()&&(Kr($r())||Br().enabled&&await ii(e,t))}var oi=!1;function si(){let e=Z(),[t,n]=(0,g.useState)(Br),[r,i]=(0,g.useState)(()=>ei()),[a,o]=(0,g.useState)(null),s=Ur(),c=s!==null,l=Qr();(0,g.useEffect)(()=>{let e=()=>i(ei());return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]);let u=async e=>{let r={...t,enabled:e};if(n(r),Vr(r),e){let e=await ti();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Vr(e)}}};return(0,X.jsxs)(`div`,{className:`sound-menu notify-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:e(`notifyHeader`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master${c?` disabled`:``}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(_t,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:e(`notifyEnable`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:t.enabled&&!c,disabled:c,onChange:e=>u(e.target.checked)})]}),(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyEnableDesc`)}),s===`insecure`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyInsecure`)}),s===`unsupported`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyUnsupported`)}),!c&&r===`denied`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyDenied`)}),!c&&l&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyWindowsHint`)}),oi]})}var ci=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),Q=new Set(`viewBox.xmlns.d.fill.stroke.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.opacity.x.y.x1.y1.x2.y2.cx.cy.r.rx.ry.width.height.points.offset.stop-color.stop-opacity.fill-opacity.stroke-opacity.stroke-miterlimit.fill-rule.clip-rule.vector-effect.preserveAspectRatio.transform.clip-path.id.href.xlink:href.xmlns:xlink.gradientUnits.gradientTransform`.split(`.`)),li=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),ui=new Set([...ci].map(e=>e.toLowerCase())),di=new Set([...Q].map(e=>e.toLowerCase()));function fi(e){return ui.has(e.toLowerCase())}function pi(e){return di.has(e.toLowerCase())}function mi(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.length>8192||!/^<svg[\s>]/.test(t.startsWith(`<?xml`)?t.slice(t.indexOf(`?>`)+2).trimStart():t))return null;if(typeof DOMParser>`u`)return/<script[\s>]/i.test(t)||/\son\w+\s*=/i.test(t)||/javascript\s*:/i.test(t)?null:t;let n=new DOMParser().parseFromString(t,`image/svg+xml`);if(n.querySelector(`parsererror`))return null;let r=n.documentElement;if(r.tagName.toLowerCase()!==`svg`)return null;let i=e=>{for(let t of Array.from(e.children)){let e=t.tagName.toLowerCase();if(!fi(e)){li.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of Array.from(t.attributes)){let n=e.name.toLowerCase();(!pi(n)||/^on/i.test(n)||/^(javascript|data|vbscript):/i.test(e.value.trim()))&&t.removeAttribute(e.name)}i(t)}};for(let e of Array.from(r.attributes)){let t=e.name.toLowerCase();(!pi(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function hi({icon:e,iconSvg:t,className:n}){let r=mi(t);return r?(0,X.jsx)(`span`,{className:n??`plugin-icon-svg`,"aria-hidden":!0,dangerouslySetInnerHTML:{__html:r}}):e?(0,X.jsx)(`span`,{className:n?`${n} plugin-icon-glyph`:`plugin-icon-glyph`,"aria-hidden":!0,children:e}):null}var gi={projects:`host:lp-projects`,convs:`host:lp-running`,sessions:`host:lp-history`},_i=[`projects`,`convs`,`sessions`],vi=new Map(Object.keys(gi).map(e=>[gi[e],e])),yi=`plugin:`;function bi(e){return e.startsWith(yi)&&e.length>7}function xi(e){let t=[],n=new Set;for(let r of e??[]){let e=null,i,a=vi.get(r.id);a?e=a:r.source?.startsWith(`plugin:`)&&r.kind===`view`&&(e=`${yi}${r.id}`,i=r),e&&!n.has(e)&&(n.add(e),t.push({key:e,shown:!r.hidden,...i?{entry:i}:{}}))}for(let e of _i)n.has(e)||t.push({key:e,shown:!0});return t}function Si(e,t){return e.filter(e=>e.shown&&t(e.key)).map(e=>e.key)}function Ci(e,t){let n=[];for(let r=0;r+1<e.length;r++){let i=e[r],a=e[r+1];!t(i)&&!t(a)&&n.push([i,a])}return n}function wi(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(!r||typeof r!=`object`||Array.isArray(r))return n;for(let[e,i]of Object.entries(r))(e in t||bi(e))&&typeof i==`number`&&Number.isFinite(i)&&i>0&&(n[e]=i)}catch{}return n}var Ti=new Set([`view`,`action`,`badge`,`menu`,`page`,`organizer`,`divider`,`toggle`,`input`,`progress`,`select`]),Ei=new Set([`disabled`,`always`,`never`,`file.isDir`,`file.isFile`,`session.isRunning`,`message.hasSelection`]),Di=`topbar.primary,topbar.overflow,notice.actions,leftpanel.sections,leftpanel.projects.actions,leftpanel.project,leftpanel.running.actions,leftpanel.running,leftpanel.history.actions,leftpanel.history,leftpanel.sessions,chat.header,chat.empty,message.actions,goalbar.actions,composer.leading,composer.actions,rightpanel.tabs,terminal.toolbar,scm.toolbar,bottombar,file.preview.toolbar,contextmenu.topbar,contextmenu.message,contextmenu.session,contextmenu.project,contextmenu.file,contextmenu.toolcall,settings.pages,tasks.panel,modal.dialog,sidebar.left,sidebar.right`.split(`,`),Oi=Di.map(e=>({slot:e,cardinality:`list`}));function ki(e){return Oi.find(t=>t.slot===e)?.cardinality??`list`}function Ai(e,t){if(t===`list`)return{entries:[...e],conflicts:[]};let n=e.findIndex(e=>!e.hidden);if(n<0)return{entries:[...e],conflicts:[]};let r=e.filter((e,t)=>t!==n&&!e.hidden);return{entries:e.map((e,t)=>t===n||e.hidden?e:{...e,hidden:!0}),winner:e[n],conflicts:r}}var ji=[{id:`host:lp-projects`,slot:`leftpanel.sections`,labelKey:`recentProjects`,icon:`folder`,kind:`action`,order:10},{id:`host:lp-running`,slot:`leftpanel.sections`,labelKey:`runningConversations`,icon:`activity`,kind:`action`,order:20},{id:`host:lp-history`,slot:`leftpanel.sections`,labelKey:`historySessions`,icon:`clock`,kind:`action`,order:30},{id:`host:brand`,slot:`topbar.primary`,labelKey:`brand`,kind:`badge`,order:1,group:`brand`},{id:`host:open-project`,slot:`topbar.primary`,labelKey:`openProject`,icon:`folder`,kind:`action`,order:3,group:`primary`},{id:`host:history`,slot:`topbar.primary`,labelKey:`openHistory`,icon:`menu`,kind:`action`,order:0,group:`panels`},{id:`host:files`,slot:`topbar.primary`,labelKey:`openFiles`,icon:`folder`,kind:`action`,order:97,group:`panels`,align:`end`},{id:`host:new-chat`,slot:`topbar.primary`,labelKey:`newChat`,icon:`plus`,kind:`action`,order:96,group:`primary`,align:`end`},{id:`host:new-ephemeral-chat`,slot:`topbar.primary`,labelKey:`newChatEphemeral`,icon:`chat`,kind:`action`,order:96.5,group:`primary`,align:`end`},{id:`host:chat`,slot:`topbar.primary`,labelKey:`chat`,icon:`chat`,kind:`view`,view:`chat`,order:20,group:`views`,align:`end`},{id:`host:terminal`,slot:`topbar.primary`,labelKey:`terminal`,icon:`terminal`,kind:`view`,view:`terminal`,order:21,group:`views`,align:`end`},{id:`host:git`,slot:`topbar.primary`,labelKey:`scmTab`,icon:`git`,kind:`view`,view:`git`,order:22,group:`views`,align:`end`},{id:`host:plugins`,slot:`topbar.primary`,labelKey:`pluginMenuTitle`,icon:`🧩`,kind:`action`,order:24,group:`views`,align:`end`},{id:`host:search`,slot:`topbar.primary`,labelKey:`searchGlobal`,icon:`search`,kind:`action`,order:40,group:`tools`,align:`end`},{id:`host:browser`,slot:`topbar.primary`,labelKey:`browserControl`,icon:`browser`,kind:`action`,order:41,group:`tools`,align:`end`,hidden:!0},{id:`host:tasks`,slot:`topbar.primary`,labelKey:`bgTasks`,icon:`layers`,kind:`action`,order:42,group:`tools`,align:`end`},{id:`host:settings`,slot:`topbar.primary`,labelKey:`settingsTitle`,icon:`settings`,kind:`action`,order:60,group:`system`,align:`end`},{id:`host:sound`,slot:`topbar.primary`,labelKey:`sound`,icon:`sound`,kind:`action`,order:70,group:`system`,hidden:!0,align:`end`},{id:`host:language`,slot:`topbar.primary`,labelKey:`language`,icon:`globe`,kind:`action`,order:80,group:`system`,hidden:!0,align:`end`},{id:`host:theme`,slot:`topbar.primary`,labelKey:`theme`,icon:`sun`,kind:`action`,order:82,group:`system`,hidden:!0,align:`end`},{id:`host:update`,slot:`topbar.primary`,labelKey:`update`,icon:`download`,kind:`action`,order:90,group:`system`,align:`end`,hidden:!0},{id:`host:github`,slot:`topbar.primary`,labelKey:`githubRepo`,icon:`github`,kind:`action`,order:200,group:`system`,align:`end`,hidden:!0},{id:`host:conn`,slot:`bottombar`,labelKey:`connected`,icon:`dot`,kind:`badge`,order:5,group:`status`},{id:`host:engine`,slot:`bottombar`,labelKey:`engineBadge`,icon:`cpu`,kind:`badge`,order:6,group:`status`},{id:`host:ctx`,slot:`bottombar`,labelKey:`context`,icon:`gauge`,kind:`badge`,order:10,group:`usage`},{id:`host:cost`,slot:`bottombar`,labelKey:`cumulativeCost`,icon:`coins`,kind:`badge`,order:11,group:`usage`},{id:`host:cache`,slot:`bottombar`,labelKey:`cacheHit`,icon:`database`,kind:`badge`,order:12,group:`usage`},{id:`host:msg-count`,slot:`bottombar`,labelKey:`messages`,icon:`message`,kind:`badge`,order:13,group:`usage`},{id:`host:plugin-status`,slot:`bottombar`,labelKey:`pluginStatus`,icon:`activity`,kind:`badge`,order:14,group:`status`},{id:`host:working`,slot:`bottombar`,labelKey:`working`,icon:`activity`,kind:`badge`,order:15,group:`status`},{id:`host:status-delegate`,slot:`bottombar`,labelKey:`delegateModeBadge`,icon:`eye`,kind:`badge`,order:16,group:`status`},{id:`host:host-metrics`,slot:`bottombar`,labelKey:`hostResources`,icon:`cpu`,kind:`badge`,order:19,group:`host`,align:`end`},{id:`host:cwd`,slot:`bottombar`,labelKey:`cwdTip`,icon:`folder`,kind:`action`,order:20,group:`context`,align:`end`},{id:`host:msg-reask`,slot:`message.actions`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,order:9},{id:`host:msg-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{id:`host:msg-fork`,slot:`message.actions`,labelKey:`forkSession`,icon:`branch`,kind:`action`,order:15},{id:`host:msg-rollback`,slot:`message.actions`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,order:16},{id:`host:msg-copy`,slot:`message.actions`,labelKey:`copyMessage`,icon:`copy`,kind:`action`,order:20},{id:`host:msg-copy-text`,slot:`message.actions`,labelKey:`copyText`,icon:`text`,kind:`action`,order:21},{id:`host:msg-copy-markdown`,slot:`message.actions`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,order:22},{id:`host:msg-copy-image`,slot:`message.actions`,labelKey:`copyImage`,icon:`image`,kind:`action`,order:23},{id:`host:msg-speak`,slot:`message.actions`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,order:24},{id:`host:composer-upload`,slot:`composer.actions`,labelKey:`uploadFile`,icon:`upload`,kind:`action`,order:10,align:`start`},{id:`host:composer-templates`,slot:`composer.actions`,labelKey:`tpl.openPicker`,icon:`grid`,kind:`action`,order:110,align:`start`},{id:`host:composer-model`,slot:`composer.actions`,labelKey:`selectModel`,icon:`cpu`,kind:`action`,order:120,align:`start`},{id:`host:composer-thinking`,slot:`composer.actions`,labelKey:`thinkingLevel`,icon:`zap`,kind:`action`,order:130,align:`start`},{id:`host:composer-dsh-perm`,slot:`composer.actions`,labelKey:`dshPerm`,icon:`lock`,kind:`action`,order:140,align:`start`},{id:`host:composer-dsh-preset`,slot:`composer.actions`,labelKey:`dshPreset`,icon:`layers`,kind:`action`,order:150,align:`start`},{id:`host:composer-send`,slot:`composer.actions`,labelKey:`sendTip`,icon:`send`,kind:`action`,order:200,align:`end`},{id:`host:fp-md`,slot:`file.preview.toolbar`,labelKey:`showMarkdownPreview`,icon:`eye`,kind:`action`,order:10},{id:`host:fp-toc`,slot:`file.preview.toolbar`,labelKey:`previewTocLabel`,icon:`list`,kind:`action`,order:15},{id:`host:fp-html`,slot:`file.preview.toolbar`,labelKey:`showHtmlPreview`,icon:`code`,kind:`action`,order:20},{id:`host:fp-edit`,slot:`file.preview.toolbar`,labelKey:`editFile`,icon:`edit`,kind:`action`,order:30},{id:`host:fp-wrap`,slot:`file.preview.toolbar`,labelKey:`enableWrap`,icon:`wrap`,kind:`action`,order:40},{id:`host:fp-zoom`,slot:`file.preview.toolbar`,labelKey:`zoomIn`,icon:`zoom`,kind:`action`,order:50},{id:`host:fp-ref`,slot:`file.preview.toolbar`,labelKey:`referenceTip`,icon:`link`,kind:`action`,order:70},{id:`host:fp-full`,slot:`file.preview.toolbar`,labelKey:`fullscreen`,icon:`maximize`,kind:`action`,order:80},{id:`host:fp-close`,slot:`file.preview.toolbar`,labelKey:`close`,icon:`x`,kind:`action`,order:90},{id:`host:goal-pill`,slot:`goalbar.actions`,labelKey:`goalBarTitle`,icon:`target`,kind:`action`,order:5},{id:`host:goal-set`,slot:`goalbar.actions`,labelKey:`goalBarSet`,icon:`check`,kind:`action`,order:10},{id:`host:goal-wizard`,slot:`goalbar.actions`,labelKey:`goalWizardBtn`,icon:`search`,kind:`action`,order:20},{id:`host:goal-lock`,slot:`goalbar.actions`,labelKey:`goalBarLocked`,icon:`lock`,kind:`action`,order:30},{id:`host:goal-plan`,slot:`goalbar.actions`,labelKey:`planMode`,icon:`list`,kind:`action`,order:25},{id:`host:goal-collapse`,slot:`goalbar.actions`,labelKey:`collapsePanel`,icon:`chevron-up`,kind:`action`,order:40},{id:`host:goal-model`,slot:`goalbar.actions`,labelKey:`goalBarReviewModel`,icon:`cpu`,kind:`action`,order:50},{id:`host:goal-rounds`,slot:`goalbar.actions`,labelKey:`goalBarMaxRounds`,icon:`hash`,kind:`action`,order:60},{id:`host:goal-execmodel`,slot:`goalbar.actions`,labelKey:`goalBarExecModel`,icon:`cpu`,kind:`action`,order:55},{id:`host:goal-openrole`,slot:`goalbar.actions`,labelKey:`goalBarOpenExec`,icon:`search`,kind:`action`,order:65},{id:`host:goal-clear`,slot:`goalbar.actions`,labelKey:`goalBarClear`,icon:`x`,kind:`action`,order:70},{id:`host:scm-changes`,slot:`scm.toolbar`,labelKey:`scmChanges`,icon:`file`,kind:`action`,order:10},{id:`host:scm-history`,slot:`scm.toolbar`,labelKey:`scmHistory`,icon:`clock`,kind:`action`,order:20},{id:`host:scm-refresh`,slot:`scm.toolbar`,labelKey:`scmRefreshTip`,icon:`refresh`,kind:`action`,order:30},{id:`host:scm-branch`,slot:`scm.toolbar`,labelKey:`scmSwitchBranch`,icon:`git`,kind:`action`,order:40},{id:`host:scm-switch`,slot:`scm.toolbar`,labelKey:`scmSwitch`,icon:`git`,kind:`action`,order:50},{id:`host:scm-push`,slot:`scm.toolbar`,labelKey:`scmPush`,icon:`upload`,kind:`action`,order:60},{id:`host:scm-pull`,slot:`scm.toolbar`,labelKey:`scmPull`,icon:`download`,kind:`action`,order:70},{id:`host:scm-input`,slot:`scm.toolbar`,labelKey:`scmCommitPlaceholder`,icon:`edit`,kind:`action`,order:80},{id:`host:scm-genmsg`,slot:`scm.toolbar`,labelKey:`scmGenMsg`,icon:`cpu`,kind:`action`,order:85},{id:`host:scm-commit`,slot:`scm.toolbar`,labelKey:`scmCommit`,icon:`check`,kind:`action`,order:90},{id:`host:scm-commit-all`,slot:`scm.toolbar`,labelKey:`scmCommitAll`,icon:`check`,kind:`action`,order:100},{id:`host:scm-term`,slot:`scm.toolbar`,labelKey:`terminal`,icon:`terminal`,kind:`action`,order:110},{id:`host:term-cmd-refresh`,slot:`terminal.toolbar`,labelKey:`rerun`,icon:`refresh`,kind:`action`,order:10},{id:`host:term-cmd-new`,slot:`terminal.toolbar`,labelKey:`newCommand`,icon:`plus`,kind:`action`,order:20},{id:`host:term-tab-new`,slot:`terminal.toolbar`,labelKey:`newTerminal`,icon:`plus`,kind:`action`,order:30},{id:`host:right-files`,slot:`rightpanel.tabs`,labelKey:`openFiles`,icon:`folder`,kind:`view`,view:`files`,order:10},{id:`host:conv-rename`,slot:`contextmenu.session`,labelKey:`renameSession`,icon:`edit`,kind:`action`,context:`session`,order:1},{id:`host:conv-pin`,slot:`contextmenu.session`,labelKey:`pinConversation`,icon:`pin`,kind:`action`,context:`session`,order:2},{id:`host:conv-takeover`,slot:`contextmenu.session`,labelKey:`takeoverConversation`,icon:`chat`,kind:`action`,context:`session`,order:5},{id:`host:conv-dismiss-subagents`,slot:`contextmenu.session`,labelKey:`dismissFinishedSubagents`,icon:`x`,kind:`action`,context:`session`,order:10},{id:`host:conv-force-dismiss`,slot:`contextmenu.session`,labelKey:`forceDismissConversation`,icon:`x`,kind:`action`,context:`session`,order:20},{id:`host:conv-persist`,slot:`contextmenu.session`,labelKey:`persistSubagent`,icon:`save`,kind:`action`,context:`session`,order:25},{id:`host:conv-copy-id`,slot:`contextmenu.session`,labelKey:`copyConversationId`,icon:`copy`,kind:`action`,context:`session`,order:30},{id:`host:conv-copy-path`,slot:`contextmenu.session`,labelKey:`copyConversationPath`,icon:`copy`,kind:`action`,context:`session`,order:40},{id:`host:conv-copy-link`,slot:`contextmenu.session`,labelKey:`copyConversationLink`,icon:`link`,kind:`action`,context:`session`,order:45},{id:`host:conv-quote`,slot:`contextmenu.session`,labelKey:`quoteConversation`,icon:`chat`,kind:`action`,context:`session`,order:50},{id:`host:file-open`,slot:`contextmenu.file`,labelKey:`fileOpenPreview`,icon:`open`,kind:`action`,context:`file`,order:11,group:`open`},{id:`host:file-enter`,slot:`contextmenu.file`,labelKey:`fileEnterDir`,icon:`folder`,kind:`action`,context:`file`,order:12,group:`open`},{id:`host:file-download`,slot:`contextmenu.file`,labelKey:`downloadFile`,icon:`download`,kind:`action`,context:`file`,order:13,group:`open`},{id:`host:file-compress`,slot:`contextmenu.file`,labelKey:`fileCompress`,icon:`file`,kind:`action`,context:`file`,order:16,group:`archive`},{id:`host:file-extract`,slot:`contextmenu.file`,labelKey:`fileExtract`,icon:`folder`,kind:`action`,context:`file`,order:17,group:`archive`},{id:`host:file-compress-download`,slot:`contextmenu.file`,labelKey:`fileCompressDownload`,icon:`download`,kind:`action`,context:`file`,order:18,group:`archive`},{id:`host:file-upload-folder`,slot:`contextmenu.file`,labelKey:`fileUploadFolder`,icon:`upload`,kind:`action`,context:`file`,order:25,group:`new`},{id:`host:file-open-project`,slot:`contextmenu.file`,labelKey:`openAsProject`,icon:`folder`,kind:`action`,context:`file`,order:14,group:`open`},{id:`host:file-add-root`,slot:`contextmenu.file`,labelKey:`addWorkspaceRoot`,icon:`folder`,kind:`action`,context:`file`,order:15,group:`open`},{id:`host:file-reveal`,slot:`contextmenu.file`,labelKey:`fileReveal`,icon:`folder`,kind:`action`,context:`file`,order:16,group:`open`},{id:`host:file-open-default`,slot:`contextmenu.file`,labelKey:`fileOpenDefault`,icon:`open`,kind:`action`,context:`file`,order:17,group:`open`},{id:`host:file-new-file`,slot:`contextmenu.file`,labelKey:`fileNewFile`,icon:`file`,kind:`action`,context:`file`,order:21,group:`new`},{id:`host:file-new-dir`,slot:`contextmenu.file`,labelKey:`fileNewDir`,icon:`folder`,kind:`action`,context:`file`,order:22,group:`new`},{id:`host:file-upload`,slot:`contextmenu.file`,labelKey:`uploadToFolder`,icon:`upload`,kind:`action`,context:`file`,order:23,group:`new`},{id:`host:file-paste`,slot:`contextmenu.file`,labelKey:`filePaste`,icon:`paste`,kind:`action`,context:`file`,order:24,group:`new`},{id:`host:file-attach-ref`,slot:`contextmenu.file`,labelKey:`referenceTip`,icon:`link`,kind:`action`,context:`file`,order:32,group:`chat`},{id:`host:file-attach-folder`,slot:`contextmenu.file`,labelKey:`linkFolderTip`,icon:`link`,kind:`action`,context:`file`,order:33,group:`chat`},{id:`host:file-rename`,slot:`contextmenu.file`,labelKey:`fileRename`,icon:`edit`,kind:`action`,context:`file`,order:41,group:`edit`},{id:`host:file-duplicate`,slot:`contextmenu.file`,labelKey:`fileDuplicate`,icon:`copy`,kind:`action`,context:`file`,order:42,group:`edit`},{id:`host:file-cut`,slot:`contextmenu.file`,labelKey:`fileCut`,icon:`cut`,kind:`action`,context:`file`,order:43,group:`edit`},{id:`host:file-copy`,slot:`contextmenu.file`,labelKey:`fileCopyEntry`,icon:`copy`,kind:`action`,context:`file`,order:44,group:`edit`},{id:`host:file-copy-name`,slot:`contextmenu.file`,labelKey:`copyName`,icon:`copy`,kind:`action`,context:`file`,order:51,group:`clipboard`},{id:`host:file-copy-path`,slot:`contextmenu.file`,labelKey:`copyPath`,icon:`copy`,kind:`action`,context:`file`,order:52,group:`clipboard`},{id:`host:file-copy-rel`,slot:`contextmenu.file`,labelKey:`fileCopyRelPath`,icon:`copy`,kind:`action`,context:`file`,order:53,group:`clipboard`},{id:`host:file-refresh`,slot:`contextmenu.file`,labelKey:`fileRefresh`,icon:`refresh`,kind:`action`,context:`file`,order:54,group:`clipboard`},{id:`host:file-delete`,slot:`contextmenu.file`,labelKey:`fileDelete`,icon:`trash`,kind:`action`,context:`file`,order:61,group:`danger`},{id:`host:msg-ctx-copy-markdown`,slot:`contextmenu.message`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,context:`message`,order:10,group:`copy`},{id:`host:msg-ctx-copy-text`,slot:`contextmenu.message`,labelKey:`copyText`,icon:`text`,kind:`action`,context:`message`,order:11,group:`copy`},{id:`host:msg-ctx-copy-image`,slot:`contextmenu.message`,labelKey:`copyImage`,icon:`image`,kind:`action`,context:`message`,order:12,group:`copy`},{id:`host:msg-ctx-copy-link`,slot:`contextmenu.message`,labelKey:`copyMessageLink`,icon:`link`,kind:`action`,context:`message`,order:13,group:`copy`},{id:`host:msg-ctx-reask`,slot:`contextmenu.message`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,context:`message`,order:19,group:`action`},{id:`host:msg-ctx-edit-reask`,slot:`contextmenu.message`,labelKey:`editReask`,icon:`edit`,kind:`action`,context:`message`,order:20,group:`action`},{id:`host:msg-ctx-fork`,slot:`contextmenu.message`,labelKey:`forkSession`,icon:`branch`,kind:`action`,context:`message`,order:21,group:`action`},{id:`host:msg-ctx-rollback`,slot:`contextmenu.message`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,context:`message`,order:22,group:`action`},{id:`host:msg-ctx-speak`,slot:`contextmenu.message`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,context:`message`,order:23,group:`action`},{id:`host:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],Mi=`__view`,Ni=new Set([`host:settings`,`host:history`,`host:files`]),Pi=new Set([`host:history`,`host:files`]);function Fi(e){return`${e}:${Mi}`}function Ii(e){return e.source.startsWith(`plugin:`)?e.id===Fi(e.source.slice(7)):!1}function Li(e,t,n){let r=Fi(t),i=(e?.hidden??[]).filter(e=>e!==r),a=(e?.shown??[]).filter(e=>e!==r);return n?a.push(r):i.push(r),{...e,hidden:i,shown:a}}function Ri(e,t){let n=t.map(Fi),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var zi=`host:brand`,Bi=[`host:brand-logo`,`host:brand-name`];function Vi(e){if(!((e.hidden??[]).some(e=>Bi.includes(e))||(e.shown??[]).some(e=>Bi.includes(e))||(e.order??[]).some(e=>Bi.includes(e))||Bi.some(t=>e.align?.[t]!==void 0)||Bi.some(t=>e.groups?.[t]!==void 0)||Bi.some(t=>e.labels?.[t]!==void 0)||Bi.some(t=>e.slots?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=Bi.includes(n)?zi:n;t.includes(e)||t.push(e)}return t},n=(e,t)=>{if(!e)return;let n={};for(let[t,r]of Object.entries(e))Bi.includes(t)||(n[t]=r);if(n[zi]===void 0){let r=t?e[Bi[0]]??e[Bi[1]]:e[Bi[1]]??e[Bi[0]];r!==void 0&&(n[zi]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))Bi.includes(n)||(t[n]=r);if(t[zi]===void 0){let n=e[Bi[0]]??e[Bi[1]];n!==void 0&&(t[zi]=n)}return t},i=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))Bi.includes(n)||(t[n]=r);if(t[zi]===void 0){let n=e[Bi[0]]??e[Bi[1]];n!==void 0&&(t[zi]=n)}return t};return{...e,...e.hidden?{hidden:t(e.hidden)}:{},...e.shown?{shown:t(e.shown)}:{},...e.order?{order:t(e.order)}:{},...e.groups?{groups:n(e.groups,!0)}:{},...e.labels?{labels:n(e.labels,!1)}:{},...e.align?{align:r(e.align)}:{},...e.slots?{slots:i(e.slots)}:{}}}function Hi(e){return e.map(e=>{if(e.view===!1)return e;let t=e.ui?.items??[];if(t.some(e=>e.id===`__view`))return e;let n={id:Mi,slot:`topbar.primary`,label:e.name,...e.icon?{icon:e.icon}:{},...e.iconSvg?{iconSvg:e.iconSvg}:{},kind:`view`,view:`plugin:${e.id}`,order:23,align:`end`,hidden:!0};return{...e,ui:{items:[...t,n],arrange:e.ui?.arrange??[]}}})}function Ui(e){return typeof e==`string`&&Di.includes(e)}function Wi(e,t){return t?e.label:e.labelEn??e.label}function Gi(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function Ki(e,t,n,r,i){let a=`${e}#${r.id}`,o=qi(a,t,n,r.children,i),s=Gi(r,i),c=Ji(r.options,i);return{id:a,slot:t,source:n,label:Wi(r,i),labelExplicit:!0,...r.icon?{icon:r.icon}:{},...r.iconSvg?{iconSvg:r.iconSvg}:{},...s?{hint:s}:{},kind:r.kind??`action`,...r.action?{action:r.action}:{},...r.view?{view:r.view}:{},...r.group?{group:r.group}:{},order:r.order??100,align:`start`,hidden:r.hidden??!1,...r.badge?{badge:r.badge}:{},...r.when?{when:r.when}:{},...c?{options:c}:{},...o.length>0?{children:o}:{},userOverrides:[],arrangedBy:[]}}function qi(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:Ki(e,t,n,r,i),index:a})).sort((e,t)=>e.entry.order===t.entry.order?e.index-t.index:e.entry.order-t.entry.order).map(e=>e.entry):[]}function Ji(e,t){if(e?.length)return e.slice(0,32).map(e=>({value:e.value,label:t?e.label??e.labelEn??e.value:e.labelEn??e.label??e.value}))}function Yi(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Xi(e,t,n,r,i,a){let o=qi(e,t,n,r.children,i),s=Gi(r,i),c=Yi(r.progress),l=Ji(r.options,i);return{id:e,slot:t,source:n,label:Wi(r,i),labelExplicit:!0,...r.icon?{icon:r.icon}:{},...r.iconSvg?{iconSvg:r.iconSvg}:{},...s?{hint:s}:{},kind:r.kind??(t===`settings.pages`?`page`:`action`),...r.action?{action:r.action}:{},...r.view?{view:r.view}:{},...r.group?{group:r.group}:{},order:r.order??100,align:r.align??`start`,hidden:r.hidden??!1,...r.badge?{badge:r.badge}:{},...typeof r.checked==`boolean`?{checked:r.checked}:{},...typeof r.value==`string`?{value:r.value}:{},...c===void 0?{}:{progress:c},...l?{options:l}:{},...r.when?{when:r.when}:{},...o.length>0?{children:o}:{},userOverrides:[],arrangedBy:[],seq:a}}function Zi(e,t){return[...e].sort((e,n)=>{let r=t.get(e.id),i=t.get(n.id);return r!==void 0||i!==void 0?r!==void 0&&i!==void 0?r-i:r===void 0?1:-1:e.order===n.order?e.seq-n.seq:e.order-n.order})}function Qi(e,t){let n=e.filter(e=>Ii(e)&&!t.has(e.id));if(n.length===0)return e;let r=e.filter(e=>!Ii(e)||t.has(e.id)),i=[`host:git`,`host:terminal`,`host:chat`].map(e=>r.findIndex(t=>t.id===e)).find(e=>e>=0)??-1,a=r.findIndex(e=>e.id===`host:plugins`),o=i+1;return a>=o&&(o=a),o=Math.max(0,Math.min(o,r.length)),[...r.slice(0,o),...n,...r.slice(o)]}function $i(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=Vi(t.layout??{}),a=e=>{t.diagnostics?.push({level:e.level??`warn`,...e})},o=new Map,s=0;for(let e of ji)o.set(e.id,{id:e.id,slot:e.slot,source:`host`,label:t.t(e.labelKey),labelKey:e.labelKey,...e.icon?{icon:e.icon}:{},kind:e.kind,...e.view?{view:e.view}:{},...e.group?{group:e.group}:{},order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[],seq:s++});for(let t of e){if(r.has(t.id)){a({pluginId:t.id,message:`plugin "${t.id}" is disabled by the user — its ${t.ui?.items?.length??0} UI item(s) are not rendered`});continue}if(t.error){a({level:`error`,pluginId:t.id,message:`plugin "${t.id}" failed to activate (${t.error}) — its UI items are not rendered`});continue}let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!Ui(r.slot)){a({pluginId:t.id,entryId:r.id,message:`item "${t.id}:${r.id}" declares unknown slot "${String(r.slot)}" — dropped (valid slots: see docs/architecture-plugins.md)`});continue}if(r.slot===`leftpanel.sections`&&r.kind!==`view`){a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" targets leftpanel.sections: only kind="view" (a plugin section) is accepted — dropped`});continue}if(r.kind&&!Ti.has(r.kind)&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares unknown kind "${r.kind}" — the render layer falls back to a plain button`}),Array.isArray(r.when))for(let e of r.when)Ei.has(e)||a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares when:"${e}" which the host does not know — it is ignored (the item still renders)`});else r.when!==void 0&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" has a non-array "when" — ignored`});let i=`${t.id}:${r.id}`,c=o.get(i);c&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item id "${r.id}" is declared more than once — the later declaration wins (order/visibility are inherited from the first)`}),o.set(i,Xi(i,r.slot,e,r,n,c?.seq??s++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[]){let n=o.get(e.id);ta(o,e,t.id),n||a({pluginId:t.id,entryId:e.id,message:`arrange target "${e.id}" does not exist — op ignored (is the providing plugin installed / not disabled?)`})}let c=new Map,l=(e,t)=>{let n=c.get(e)??[];n.includes(t)||n.push(t),c.set(e,n)};for(let e of i.hidden??[]){let t=o.get(e);t&&(t.hidden=!0,l(e,`hidden`))}for(let e of i.shown??[]){let t=o.get(e);t&&(t.hidden=!1,l(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=o.get(e);n&&(n.group=t,l(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=o.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,l(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=o.get(e);n&&(n.label=t,n.labelExplicit=!0,l(e,`label`))}for(let[e,t]of Object.entries(i.slots??{})){let n=o.get(e);n&&Ui(t)&&n.slot!==t&&(n.movedFrom=n.movedFrom??n.slot,n.slot=t,l(e,`slot`))}for(let e of Ni){let t=o.get(e);t&&(i.slots?.[e]||(t.slot=`topbar.primary`),t.hidden=!1)}let u=new Map;(i.order??[]).forEach((e,t)=>{o.has(e)&&(u.has(e)||u.set(e,t),l(e,`order`))});for(let e of Object.values(gi)){let t=o.get(e);t&&t.slot!==`leftpanel.sections`&&(a({entryId:e,slot:t.slot,message:`"${e}" must stay in leftpanel.sections — the move is ignored`}),t.slot=`leftpanel.sections`,delete t.movedFrom)}let d=new Map;for(let e of Di)d.set(e,[]);for(let e of o.values())d.get(e.slot)?.push(e);let f={};for(let e of Di){let t=Zi(d.get(e)??[],u),n=Ai(e===`topbar.primary`?Qi(t,u):t,ki(e));if(n.winner&&n.conflicts.length>0)for(let t of n.conflicts)a({level:`error`,pluginId:t.source.startsWith(`plugin:`)?t.source.slice(7):void 0,entryId:t.id,slot:e,message:`slot "${e}" is single-cardinality; "${n.winner.id}" won and "${t.id}" was hidden`});f[e]=n.entries.map(e=>ea(e,c.get(e.id)??[]))}return f}function ea(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function ta(e,t,n){let r=e.get(t.id);if(!r)return;let i=!1;t.hide!==void 0&&(r.hidden=t.hide,i=!0),t.group!==void 0&&(r.group=t.group,i=!0),t.order!==void 0&&(r.order=t.order,i=!0),t.align!==void 0&&(r.align=t.align,i=!0),t.label!==void 0&&(r.label=t.label,r.labelExplicit=!0,i=!0),t.hint!==void 0&&(r.hint=t.hint,i=!0),t.icon!==void 0&&(r.icon=t.icon,i=!0),t.iconSvg!==void 0&&(r.iconSvg=t.iconSvg||void 0,i=!0),t.slot!==void 0&&Ui(t.slot)&&t.slot!==r.slot&&(r.movedFrom=r.movedFrom??r.slot,r.slot=t.slot,i=!0),i&&r.source!==`plugin:${n}`&&!r.arrangedBy.includes(n)&&r.arrangedBy.push(n)}function na(e){let t=[],n=[],r=[];for(let i of e)i.align===`end`?r.push(i):i.align===`center`?n.push(i):t.push(i);return{start:t,center:n,end:r}}function ra(e,t){let n=e??{},r={},i=t===zi?[t,...Bi]:[t],a=(n.hidden??[]).filter(e=>!i.includes(e)),o=(n.shown??[]).filter(e=>!i.includes(e)),s=(n.order??[]).filter(e=>!i.includes(e));a.length>0&&(r.hidden=a),o.length>0&&(r.shown=o),s.length>0&&(r.order=s);let c=aa(n.groups,t),l=aa(n.labels,t),u=aa(n.align,t),d=aa(n.slots,t);if(t===zi)for(let e of Bi)c=aa(c,e),l=aa(l,e),u=aa(u,e),d=aa(d,e);return c&&(r.groups=c),l&&(r.labels=l),u&&(r.align=u),d&&(r.slots=d),n.topbarText!==void 0&&(r.topbarText=n.topbarText),n.sideDockFloat!==void 0&&(r.sideDockFloat=n.sideDockFloat),r}function ia(){return{}}function aa(e,t){if(!e)return;let n={},r=!1;for(let[i,a]of Object.entries(e))i!==t&&(n[i]=a,r=!0);return r?n:void 0}var oa=new Set([`host:files`]);function sa(e,t){let n=e=>e===`center`?1:e===`end`?2:0;return[...e].sort((e,r)=>n(e.align)-n(r.align)||t(e.id)-t(r.id))}function ca(e,t,n,r,i=new Set){let a=new Set;if(!Number.isFinite(t)||t<=0)return a;let o=e.filter(e=>i.has(e.id)&&e.width>0).reduce((e,t)=>e+t.width+n,0),s=Math.max(0,t-Math.max(0,r)-o),c=0,l=!1;for(let t of e){if(!(t.width>0)||i.has(t.id))continue;let e=t.width+n;if(l||c+e>s){l=!0,a.add(t.id);continue}c+=e}return a}var la=null,ua=new Set;function da(){for(let e of ua)e()}function fa(e){la={x:Number.isFinite(e.x)?e.x:0,y:Number.isFinite(e.y)?e.y:0,slot:e.slot,target:e.target??{id:``},entries:Array.isArray(e.entries)?e.entries:[],...typeof e.onHostAction==`function`?{onHostAction:e.onHostAction}:{}},da()}function pa(){la!==null&&(la=null,da())}function ma(e){return ua.add(e),()=>{ua.delete(e)}}function ha(){return la}function ga(){return(0,g.useSyncExternalStore)(ma,ha,ha)}function _a(e){return Number.isFinite(e)?e:0}function va(e,t,n,r,i,a){let o=Math.max(0,_a(n)),s=Math.max(0,_a(r)),c=Math.max(8,_a(i)-o-8),l=Math.max(8,_a(a)-s-8);return{x:Math.min(Math.max(8,_a(e)),c),y:Math.min(Math.max(8,_a(t)),l)}}function ya(e,t){let n=String(t?.kind??``);if(e===`contextmenu.file`)return{"file.isDir":n===`dir`||n===`list`&&t?.id!==`@root`,"file.isFile":n===`file`};if(e===`contextmenu.session`)return{"session.isRunning":n===`running`};if(e===`contextmenu.message`){let e=!1;try{let t=window.getSelection?.();e=!!t&&!t.isCollapsed&&t.toString().trim().length>0}catch{e=!1}return{"message.hasSelection":e}}return{}}function ba(e,t){if(!Array.isArray(e)||e.length===0)return!1;for(let n of e){if(typeof n!=`string`||!n)continue;let e=n.trim();if(e===`disabled`||e===`never`)return!0;if(e!==`always`){if(e.startsWith(`!`)){let n=e.slice(1).trim();if(!n)continue;if(!t||t[n]!==!0)return!0;continue}if(t&&t[e]===!1)return!0}}return!1}function xa(e,t){return!e||ba(e.when,t)}function Sa(e){let t=new Map;return{items:(Array.isArray(e)?e:[]).map(e=>{if(!e||e.kind!==`select`||!e.options?.length||e.children?.length)return e;let n=e.options.map((t,n)=>({id:`${e.id}#${n}`,slot:e.slot,source:e.source,label:t.label,kind:`action`,order:100,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}));return n.forEach((n,r)=>t.set(n.id,{parent:e,value:e.options[r].value})),{...e,kind:`menu`,children:n}}),selectParents:t}}function Ca(e){if(!Array.isArray(e)||e.length===0)return[];let t=e.filter(e=>e&&e.hidden!==!0),n=t.filter(e=>e.kind!==`divider`),r=new Map,i=new Map;n.forEach((e,t)=>{let n=e.group??``;r.has(n)||r.set(n,t);let a=Number.isFinite(e.order)?e.order:100,o=i.get(n);(o===void 0||a<o)&&i.set(n,a)});let a=[...r.keys()].sort((e,t)=>{let n=i.get(e)??100,a=i.get(t)??100;return n===a?(r.get(e)??0)-(r.get(t)??0):n-a}),o=new Map(a.map((e,t)=>[e,t])),s=new Map;n.forEach((e,t)=>s.set(e,t));let c=[...n].sort((e,t)=>{let n=o.get(e.group??``)??0,r=o.get(t.group??``)??0;if(n!==r)return n-r;let i=Number.isFinite(e.order)?e.order:100,a=Number.isFinite(t.order)?t.order:100;return i===a?(s.get(e)??0)-(s.get(t)??0):i-a}),l=new Map;t.forEach((e,n)=>{if(e.kind!==`divider`)return;let r=t.slice(n+1).find(e=>e.kind!==`divider`);if(!r)return;let i=l.get(r)??[];i.push(e),l.set(r,i)});let u=[];for(let e of c){for(let t of l.get(e)??[])u.push(t);u.push(e)}return u}function wa(e){let t=[],n=null,r=!1;return e.forEach((e,i)=>{if(!e||e.kind===`divider`){r=!0;return}let a=e.group??``;n!==null&&(r||a!==n)&&t.push({kind:`sep`,key:`sep:${i}`}),t.push({kind:`item`,key:`${e.id}#${i}`,index:i,entry:e}),n=a,r=!1}),t}function Ta(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!xa(e,t)}function Ea(e,t,n,r){let i=Array.isArray(e)?e.length:0;if(i===0)return-1;let a=n>=0?1:-1,o=Number.isFinite(t)?Math.trunc(t):-1;(o<0||o>=i)&&(o=a>0?-1:i);for(let t=0;t<i;t++)if(o=(o+a+i)%i,Ta(e[o],r))return o;return-1}var Da={menu:`☰`,folder:`📁`,plus:`+`,chat:`💬`,terminal:`▙`,git:`⎇`,search:`🔍`,browser:`🌐`,layers:`🗂`,settings:`⚙`,sound:`🔊`,globe:`🌍`,sun:`☀`,download:`⤓`,github:`⌗`,x:`✕`,upload:`⬆`,copy:`⧉`,cut:`✂`,paste:`📋`,trash:`🗑`,file:`📄`,open:`↗`,refresh:`⟳`,link:`🔗`,edit:`✎`,dot:`●`,info:`ⓘ`,cpu:`▣`,gauge:`▤`,coins:`◉`,database:`▥`,message:`✉`,activity:`〜`,markdown:`📄`,text:`≡`,image:`🖼`,branch:`⚚`,undo:`↺`,pin:`📌`,volume:`🔊`};function Oa(e){let t=(e??``).trim();return t?Da[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var ka={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},Aa=new Set;function ja(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function Ma(e,t){return e.engine===t.engine&&e.managed===t.managed&&e.appVersion===t.appVersion&&e.serverVersion===t.serverVersion&&e.status===t.status&&e.ready===t.ready&&e.cwd===t.cwd&&ja(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&ja(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function Na(e){let t={...ka,...e};if(!Ma(ka,t)){ka=t;for(let e of Aa)e()}}function Pa(e){return Aa.add(e),()=>{Aa.delete(e)}}function Fa(){return ka}function Ia(){return(0,g.useSyncExternalStore)(Pa,Fa,Fa)}function La(e){return(0,g.useSyncExternalStore)(Pa,()=>ka[e],()=>ka[e])}function Ra(){return La(`engine`)===`dsh`}function za(){return La(`managed`)}function Ba(){return La(`service`)}var Va=null;function Ha(e){Va=e}var $=e=>Va?Va(e):!1,Ua=new Set;function Wa(e){return Ua.add(e),()=>{Ua.delete(e)}}function Ga(e){for(let t of Ua)try{t(e)}catch(e){console.error(`[remote-ssh-client] listener error:`,e)}}function Ka(e,t,n,r){return`ssh://${e}@${t}:${n}${r.startsWith(`/`)?r:`/${r}`}`}function qa(e){return!!(e&&e.startsWith(`ssh://`))}function Ja(e){if(!qa(e))return null;let t=/^ssh:\/\/([^@]+)@([^:]+):(\d+)(\/.*)$/.exec(e);return t?{username:t[1],host:t[2],port:parseInt(t[3],10),remotePath:t[4]}:null}var Ya=1;function Xa(e){let t=`probe_${Date.now()}_${Ya++}`;return new Promise(n=>{let r=Wa(e=>{e.type===`remote_ssh_probe_result`&&e.reqId===t&&(r(),n({ok:e.ok,connectionId:e.connectionId,error:e.error,system:e.system,tools:e.tools,packageManager:e.packageManager,suggestedInstall:e.suggestedInstall}))});$({type:`remote_ssh_probe`,reqId:t,params:e})||(r(),n({ok:!1,error:`WebSocket 连接不可用,请稍候重试`}))})}function Za(e,t){let n=`listdir_${Date.now()}_${Ya++}`;return new Promise(r=>{let i=Wa(e=>{e.type===`remote_ssh_list_dir_result`&&e.reqId===n&&(i(),r({ok:e.ok,connectionId:e.connectionId,path:e.path,parentPath:e.parentPath,items:e.items,error:e.error}))});$({type:`remote_ssh_list_dir`,reqId:n,connectionId:e,path:t})||(i(),r({ok:!1,connectionId:e,path:t||`/`,items:[],error:`WebSocket 连接不可用`}))})}function Qa(e,t){let n=`install_${Date.now()}_${Ya++}`;return new Promise(r=>{let i=Wa(e=>{e.type===`remote_ssh_install_result`&&e.reqId===n&&(i(),r({ok:e.ok,connectionId:e.connectionId,tool:e.tool,output:e.output,error:e.error}))});$({type:`remote_ssh_install_tools`,reqId:n,connectionId:e,tools:t})||(i(),r({ok:!1,connectionId:e,tool:t[0]||``,error:`WebSocket 连接不可用`}))})}function $a(){let e=`profiles_${Date.now()}_${Ya++}`;return new Promise(t=>{let n=Wa(r=>{r.type===`remote_ssh_profiles_result`&&r.reqId===e&&(n(),t(r.profiles))});$({type:`remote_ssh_list_profiles`,reqId:e})||(n(),t([]))})}function eo(e){$({type:`remote_ssh_delete_profile`,name:e})}var to=`@root`,no=e=>e.endsWith(`/`)?e:e+`/`;function ro(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function io(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var ao=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;if(t===`@root`||t===`/`)return null;let n=t.lastIndexOf(`/`);if(n<0)return/^[A-Za-z]:$/.test(t)?to:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function oo({currentCwd:e,pathCompletions:t,workspaceRoots:n,onClose:r,onSelectDirectory:i,mode:a=`folder`,onCreateProject:o,className:s,backdropClassName:c,role:l,ariaLabel:u}){let d=Z(),[f,p]=(0,g.useState)(()=>qa(e)?`remote`:`local`),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(-1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),[k,A]=(0,g.useState)([]),[j,ee]=(0,g.useState)(``),[M,te]=(0,g.useState)(`22`),[N,ne]=(0,g.useState)(``),[F,re]=(0,g.useState)(`password`),[I,L]=(0,g.useState)(``),[ie,z]=(0,g.useState)(`~/.ssh/id_rsa`),[B,V]=(0,g.useState)(!0),[H,U]=(0,g.useState)(``),[ae,oe]=(0,g.useState)(!1),[se,W]=(0,g.useState)(null),[ce,ue]=(0,g.useState)(null),[de,fe]=(0,g.useState)(null),[pe,G]=(0,g.useState)(null),[K,me]=(0,g.useState)([]),[he,ge]=(0,g.useState)(!1),[q,_e]=(0,g.useState)(`/`),[ve,ye]=(0,g.useState)(`/`),[be,xe]=(0,g.useState)([]),[J,Se]=(0,g.useState)(!1),Ce=t.filter(e=>e.type===`dir`);(0,g.useEffect)(()=>{if(qa(e)){let t=Ja(e);t&&(ee(t.host),te(String(t.port)),ne(t.username),_e(t.remotePath),ye(t.remotePath))}else{let t=(e||``).replace(/\\/g,`/`);h(t),v(t)}b(!1),S(``),w(null),E(-1)},[e]),(0,g.useEffect)(()=>{f===`remote`&&$a().then(e=>A(e))},[f]),(0,g.useEffect)(()=>{let e=requestAnimationFrame(()=>{D.current?.focus()});return()=>cancelAnimationFrame(e)},[f]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(y?(b(!1),S(``),w(null)):r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,r]),(0,g.useEffect)(()=>{if(f!==`local`)return;let e=setTimeout(()=>{$({type:`complete_path`,path:no(m)})},60);return()=>clearTimeout(e)},[m,f]),(0,g.useEffect)(()=>{if(f!==`local`||_===m)return;let e=setTimeout(()=>{$({type:`complete_path`,path:_})},150);return()=>clearTimeout(e)},[_,m,f]);let we=e=>{let t=e.trim();t&&t!==`@root`&&i(t)},Te=()=>{let e=x.trim();if(e){if(a===`project`){if(!io(e)){w(d(`invalidProjectName`));return}let t=ro(m,e);o?.(t),b(!1),S(``),w(null),r()}else $({type:`make_dir`,path:`${no(m)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:no(m)})},80),S(``),b(!1)}},Ee=e=>{if(e.key===`Escape`)e.stopPropagation(),y?(b(!1),S(``),w(null)):r();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)we(_);else if(e.key===`Tab`){if(Ce.length===0)return;e.preventDefault();let t=T>=0?(T+1)%Ce.length:0;E(t),v(Ce[t].path),h(Ce[t].path)}},De=async e=>{let t=(e?.host??j).trim(),n=e?.port??(parseInt(M,10)||22),r=(e?.username??N).trim();if(!t||!r){W(`请填写主机地址和用户名`);return}oe(!0),W(null);let i=await Xa({host:t,port:n,username:r,auth:e?.auth??(F===`password`?{type:`password`,password:I}:F===`key`?{type:`key`,privateKeyPath:ie}:{type:`agent`}),saveProfile:B,profileName:e?.profileName||H.trim()||void 0});if(oe(!1),!i.ok||!i.connectionId){W(i.error||`连接远程服务器失败`);return}ue(i.connectionId),fe(i.system??null),G(i.tools??null),me(i.suggestedInstall??[]);let a=i.system?.homeDir||`/`;_e(a),ye(a),Oe(i.connectionId,a),$a().then(e=>A(e))},Oe=async(e,t)=>{Se(!0),W(null);let n=await Za(e,t);Se(!1),n.ok?(_e(n.path),ye(n.path),xe(n.items)):W(n.error||`读取远程目录失败`)},ke=async e=>{if(!ce)return;ge(!0),W(null);let t=await Qa(ce,[e]);ge(!1),t.ok?(me(t=>t.filter(t=>t!==e)),pe&&e===`git`&&G({...pe,git:{installed:!0,version:`已安装`}})):W(t.error||`安装 ${e} 失败,可能需要远端 sudo 权限`)},Ae=e=>{i(Ka(N,j,parseInt(M,10)||22,e)),r()},je=ao(m),Me=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},Ne=Me(m),Pe=!!m&&m!==`@root`&&Ne!==Me(e)&&!n.some(e=>Me(e)===Ne);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop ${c??``}`.trim(),onClick:r}),(0,X.jsxs)(`div`,{className:`cwd-picker ${s??``}`.trim(),role:l,"aria-label":u,children:[(0,X.jsxs)(`div`,{className:`cwd-mode-tabs`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-mode-tab ${f===`local`?`active`:``}`,onClick:()=>p(`local`),children:[`💻 `,d(`workspaceModeLocal`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-mode-tab ${f===`remote`?`active`:``}`,onClick:()=>p(`remote`),children:[`🌐 `,d(`workspaceModeRemote`)]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-close`,title:d(`close`),"aria-label":d(`close`),onClick:r,children:(0,X.jsx)(P,{})})]}),f===`local`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:m===`@root`?d(`computer`):m,children:[m===`@root`?`💻`:(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{children:m===`@root`?d(`computer`):m})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:m===`@root`,title:d(`computer`),onClick:()=>{h(`@root`),v(`@root`),E(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!je,title:d(`cwdGoUp`),onClick:()=>{je&&(h(je),v(je),E(-1))},children:[`↑ `,d(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!Pe,title:d(`addWorkspaceRootHint`),onClick:()=>{Pe&&$({type:`set_workspace_roots`,roots:[...n,m]})},children:[`+ `,d(`addWorkspaceRoot`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:D,className:`status-cwd-input cwd-picker-input`,value:_,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>{v(e.target.value),E(-1)},onKeyDown:Ee}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:d(`cwdPickCurrent`),disabled:m===`@root`,onClick:()=>we(m),children:d(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[Ce.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}),Ce.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${d(`cwdEnter`)} ${e.path}`,onClick:()=>{h(e.path),v(e.path),E(-1)},children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>we(e.path),children:d(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[y?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:O,value:x,autoFocus:!0,spellCheck:!1,placeholder:d(a===`project`?`projectName`:`cwdNewName`),onChange:e=>{S(e.target.value),C&&w(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),Te()):e.key===`Escape`&&(e.stopPropagation(),b(!1),S(``),w(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:Te,children:d(a===`project`?`createAndOpenProject`:`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{b(!1),S(``),w(null)},children:d(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>b(!0),children:[`+ `,d(a===`project`?`newProject`:`cwdNewFolder`)]}),C&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:C})]})]}),f===`remote`&&(0,X.jsx)(`div`,{className:`cwd-ssh-container`,children:ce?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-probe-box`,children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-probe-header`,children:[(0,X.jsxs)(`span`,{children:[`🌐 `,N,`@`,j,` (`,de?.os,` `,de?.arch,`)`]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-ssh-profile-del`,onClick:()=>{ue(null),fe(null),G(null)},children:d(`sshDisconnect`)})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,flexWrap:`wrap`,fontSize:`10px`},children:[(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.git.installed?`ok`:`missing`}`,children:[`Git: `,pe?.git.installed?`✓`:`✗`]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.node.installed?`ok`:`missing`}`,children:[`Node: `,pe?.node.installed?`✓`:`✗`]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.bash.installed?`ok`:`missing`}`,children:[`Bash: `,pe?.bash.installed?`✓`:`✗`]})]}),K.length>0&&(0,X.jsxs)(`div`,{className:`cwd-ssh-install-box`,children:[(0,X.jsx)(`div`,{children:`⚠️ 远端环境未检测到 Git / 基础工具,SCM 与执行功能可能受限。`}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,marginTop:`2px`},children:[(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,disabled:he,onClick:()=>void ke(K[0]),children:he?d(`sshInstalling`):`⚡ ${d(`sshInstallTool`)} ${K[0]}`}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>me([]),children:d(`sshSkipAndBrowse`)})]})]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:q,children:[(0,X.jsx)(Fe,{}),(0,X.jsx)(`span`,{children:q})]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:q===`/`||J,title:d(`cwdGoUp`),onClick:()=>{let e=ao(q)||`/`;ce&&Oe(ce,e)},children:[`↑ `,d(`cwdGoUp`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{className:`status-cwd-input cwd-picker-input`,value:ve,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ce&&Oe(ce,ve)}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:()=>Ae(q),children:d(`sshOpenRemoteWorkspace`)})]}),(0,X.jsx)(`div`,{className:`cwd-list`,children:J?(0,X.jsx)(`div`,{className:`cwd-empty`,children:`正在加载远程目录…`}):be.length===0?(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}):be.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${e.type===`dir`?d(`cwdEnter`):``} ${e.path}`,onClick:()=>{e.type===`dir`&&ce&&Oe(ce,e.path)},children:[e.type===`dir`?(0,X.jsx)(Re,{}):(0,X.jsx)(`span`,{children:`📄`}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),e.type===`dir`&&(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>Ae(e.path),children:d(`cwdChoose`)})]},e.path))})]}):(0,X.jsxs)(`div`,{className:`cwd-ssh-form`,children:[k.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-profiles-title`,children:[`📋 `,d(`sshSavedProfiles`)]}),k.map(e=>(0,X.jsxs)(`div`,{className:`cwd-ssh-profile-card`,onClick:()=>{ee(e.host),te(String(e.port)),ne(e.username),re(e.authType),e.privateKeyPath&&z(e.privateKeyPath),De({host:e.host,port:e.port,username:e.username,profileName:e.name,auth:e.authType===`password`?{type:`password`,password:``}:e.authType===`key`?{type:`key`,privateKeyPath:e.privateKeyPath}:{type:`agent`}})},children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-profile-meta`,children:[(0,X.jsxs)(`span`,{className:`cwd-ssh-profile-name`,children:[(0,X.jsx)(le,{style:{marginRight:`4px`}}),e.name]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-profile-addr`,children:[e.username,`@`,e.host,`:`,e.port]})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-ssh-profile-del`,title:d(`delete`),onClick:t=>{t.stopPropagation(),confirm(d(`sshDeleteProfileConfirm`))&&(eo(e.name),A(t=>t.filter(t=>t.name!==e.name)))},children:(0,X.jsx)(R,{})})]},e.name))]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,style:{marginTop:`4px`},children:[(0,X.jsxs)(`label`,{children:[d(`sshHost`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:j,placeholder:`192.168.1.100`,onChange:e=>ee(e.target.value)}),(0,X.jsxs)(`label`,{style:{width:`32px`,textAlign:`right`},children:[d(`sshPort`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,style:{width:`45px`,flex:`none`},value:M,onChange:e=>te(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshUser`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:N,placeholder:`root / ubuntu`,onChange:e=>ne(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshAuthType`),`:`]}),(0,X.jsxs)(`select`,{className:`cwd-ssh-select`,value:F,onChange:e=>re(e.target.value),children:[(0,X.jsx)(`option`,{value:`password`,children:d(`sshPassword`)}),(0,X.jsx)(`option`,{value:`key`,children:d(`sshKeyPath`)}),(0,X.jsx)(`option`,{value:`agent`,children:d(`sshAgent`)})]})]}),F===`password`&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshPassword`),`:`]}),(0,X.jsx)(`input`,{type:`password`,className:`cwd-ssh-input`,value:I,placeholder:`••••••••`,onChange:e=>L(e.target.value)})]}),F===`key`&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshKeyPath`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:ie,placeholder:`~/.ssh/id_rsa`,onChange:e=>z(e.target.value)})]}),(0,X.jsx)(`div`,{className:`cwd-ssh-row`,style:{fontSize:`11px`,color:`var(--text-dim)`},children:(0,X.jsxs)(`label`,{style:{width:`auto`},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:B,onChange:e=>V(e.target.checked),style:{marginRight:`4px`}}),d(`sshSaveProfile`)]})}),B&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshProfileName`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:H,placeholder:`my-server`,onChange:e=>U(e.target.value)})]}),se&&(0,X.jsxs)(`div`,{style:{color:`var(--red)`,fontSize:`11px`,padding:`2px 0`},children:[`⚠️ `,se]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,style:{marginTop:`4px`},disabled:ae,onClick:()=>void De(),children:d(ae?`sshConnecting`:`sshConnectAndProbe`)})]})})]})]})}function so({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z();return e?(0,X.jsx)(oo,{currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:e=>{a(e),i()},onCreateProject:o,mode:`project`,className:`project-picker`,backdropClassName:`project-picker-backdrop`,role:`dialog`,ariaLabel:s(`projectPickerTitle`)}):null}function co(e){return k({tag:`svg`,attr:{viewBox:`0 0 256 256`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M53.92,34.62A8,8,0,1,0,42.08,45.38L67.37,73.2A69.82,69.82,0,0,0,38,87.63a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33,89.75,89.75,0,0,0,11.58-20.27l21.84,24a8,8,0,1,0,11.84-10.76ZM155.9,208,48,100.08C58.23,91.83,69.2,87.72,80.66,87.81l87.16,95.88C165.59,193.56,160.24,202.23,155.9,208Zm79.42-104-44.64,44.79a8,8,0,1,1-11.33-11.3L224,92.7,163.32,32,122.1,73.35a8,8,0,0,1-11.33-11.29L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.32,104Z`},child:[]}]})(e)}function lo(e){return k({tag:`svg`,attr:{viewBox:`0 0 256 256`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M235.33,104l-53.47,53.65c4.56,12.67,6.45,33.89-13.19,60A15.93,15.93,0,0,1,157,224c-.38,0-.75,0-1.13,0a16,16,0,0,1-11.32-4.69L96.29,171,53.66,213.66a8,8,0,0,1-11.32-11.32L85,159.71l-48.3-48.3A16,16,0,0,1,38,87.63c25.42-20.51,49.75-16.48,60.4-13.14L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.33,104Z`},child:[]}]})(e)}function uo(e,t,n,r={}){let{align:i=`right`,side:a=`bottom`,gap:o=6,margin:s=8}=r,c=t.width,l=t.height,u=Math.max(0,n.width-c-s),d=Math.max(0,n.height-l-s),f=i===`left`?e.left:e.right-c;f=Math.max(s,Math.min(f,u));let p;return a===`top`?(p=e.top-l-o,p<s&&e.bottom+o+l<=n.height-s&&(p=e.bottom+o)):(p=e.bottom+o,p+l>n.height-s&&e.top-l-o>=s&&(p=e.top-l-o)),p>d&&(p=d),p<s&&(p=s),{x:Math.round(f),y:Math.round(p)}}function fo(e){let{open:t=!0,anchor:n,anchorEl:r,onClose:i,isInside:a,align:o=`right`,side:s=`bottom`,gap:c=6,margin:l=8}=e,u=(0,g.useRef)(null),[d,f]=(0,g.useState)(null),p=(0,g.useRef)(i);(0,g.useLayoutEffect)(()=>{p.current=i});let m=()=>{if(!n)return null;if(`current`in n)return n.current?.getBoundingClientRect()??null;if(typeof n.getBoundingClientRect==`function`)return n.getBoundingClientRect();let e=n;return typeof e.left==`number`&&typeof e.right==`number`&&typeof e.top==`number`&&typeof e.bottom==`number`?e:null},h=()=>r||(n&&`current`in n?n.current:n&&typeof n.getBoundingClientRect==`function`?n:null),_=()=>{if(!t)return;let e=u.current;if(!e)return;let n=e.getBoundingClientRect();if(n.width===0&&n.height===0)return;let r=h(),i=r&&r.isConnected?r.getBoundingClientRect():m();if(!i)return;let a=uo(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});f(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,g.useLayoutEffect)(()=>{t?_():f(null)},[t,n,r,o,s,c,l]),zt(()=>{p.current()},t),(0,g.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||h()?.contains(e)||a?.(e)),n=t=>{e(t.target)||p.current()};return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`resize`,_,!0),window.addEventListener(`scroll`,_,!0),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`resize`,_,!0),window.removeEventListener(`scroll`,_,!0)}},[t,n,r]),{panelRef:u,pos:d,style:{position:`fixed`,left:d?.x??-9999,top:d?.y??-9999,visibility:d?`visible`:`hidden`},measure:_}}function po({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=Nn(),{panelRef:d,style:f,measure:p}=fo({anchor:e,anchorEl:t,onClose:l}),[,m]=(0,g.useState)(null),h=(0,g.useRef)(null),[_,v]=(0,g.useState)(null),y=(0,g.useMemo)(()=>{let e=new Map((i??[]).map((e,t)=>[e,t]));return n.map((e,t)=>({plugin:e,index:t})).sort((t,n)=>(e.get(t.plugin.id)??1e6+t.index)-(e.get(n.plugin.id)??1e6+n.index)).map(({plugin:e})=>e)},[n,i]);(0,g.useLayoutEffect)(()=>{p()},[y,p]);let b=(e,t)=>{let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=r+t;if(r<0||i<0||i>=n.length)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))},x=(e,t)=>{if(!e||e===t)return;let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=n.indexOf(t);if(r<0||i<0)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))};return(0,j.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:f,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(ht,{className:`pm-head-icon`,"aria-hidden":!0}),u(`pluginMenuTitle`)]}),(0,X.jsx)(`div`,{className:`pm-list`,children:n.length===0?(0,X.jsx)(`div`,{className:`pm-empty`,children:u(`pluginMenuEmpty`)}):y.map(e=>{let t=e.view===!1||!!e.error,n=!t&&r.has(e.id),i=e.error??(e.view===!1?u(`pluginMenuNoView`):void 0),o=e.iconSvg?void 0:e.icon&&!/[a-z]/i.test(e.icon)?e.icon:void 0;return(0,X.jsxs)(`div`,{className:`pm-row${_===e.id?` drop-target`:``}`,role:`none`,onDragOver:n=>{!t&&h.current&&(n.preventDefault(),v(e.id))},onDrop:t=>{t.preventDefault(),x(t.dataTransfer.getData(`text/plain`)||h.current,e.id),h.current=null,m(null),v(null)},children:[!t&&(0,X.jsx)(`button`,{type:`button`,className:`pm-drag`,draggable:!0,"aria-label":u(`pluginMenuReorder`),title:u(`pluginMenuReorderHint`),onDragStart:t=>{m(e.id),h.current=e.id,t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id);let n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0`,document.body.appendChild(n),t.dataTransfer.setDragImage(n,0,0),requestAnimationFrame(()=>n.remove())},onDragEnd:()=>{h.current=null,m(null),v(null)},onKeyDown:t=>{(t.key===`ArrowUp`||t.key===`ArrowDown`)&&(t.preventDefault(),b(e.id,t.key===`ArrowUp`?-1:1))},children:(0,X.jsx)(Se,{"aria-hidden":!0})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-row-main`,disabled:t,title:i,onClick:()=>s(e.id),children:[o||e.iconSvg?(0,X.jsx)(hi,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(ht,{className:`pm-icon`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`pm-name`,children:e.name}),i&&(0,X.jsx)(`span`,{className:`pm-sub`,children:i})]}),!t&&(0,X.jsx)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":n,"aria-label":u(n?`pluginMenuUnpin`:`pluginMenuPin`),className:`pm-pin${n?` on`:``}`,onClick:()=>a(e.id,!n),children:n?(0,X.jsx)(lo,{"aria-hidden":!0}):(0,X.jsx)(co,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(ce,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function mo({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=Nn(),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``);async function d(){try{let e=await fetch(gn(fn(`/api/locales`)));if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();o(t.packs??[]),c(``)}catch(e){c(t(`localeListFailed`,{error:e instanceof Error?e.message:String(e)}))}}(0,g.useEffect)(()=>{d()},[]);async function f(e){u(e),c(``);try{let t=await fetch(gn(fn(`/api/locales/${e}/install`)),{method:`POST`});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error??e}catch{}throw Error(e)}await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}async function p(e){u(e),c(``);try{let t=await fetch(gn(fn(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);Tn(e),n===e&&r(`zh`),await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:e,children:(0,X.jsxs)(`div`,{className:`bg-task-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`bg-task-head`,children:[(0,X.jsxs)(`span`,{className:`bg-task-title`,children:[(0,X.jsx)(Fe,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(P,{})})]}),s&&(0,X.jsx)(`div`,{className:`bg-task-empty`,children:s}),a===null&&!s?(0,X.jsx)(`div`,{className:`bg-task-empty`,children:t(`loading`)}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:(a??[]).map(e=>{let n=l===e.code;return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[(0,X.jsx)(`span`,{className:`bg-task-port`,children:e.nativeName}),e.installed&&e.version&&(0,X.jsxs)(`span`,{className:`bg-task-name`,children:[`v`,e.version]})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[(0,X.jsx)(`span`,{children:e.code}),e.installed?(0,X.jsxs)(`span`,{children:[t(`localeInstalled`),` · `,t(`localeRemoveHint`)]}):(0,X.jsx)(`span`,{children:t(`localeGetMore`)})]})]}),e.installed?(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,disabled:n,title:t(`localeRemove`),onClick:()=>void p(e.code),children:[(0,X.jsx)(R,{}),(0,X.jsx)(`span`,{children:t(n?`localeRemoving`:`localeRemove`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:n,title:t(`localeInstall`),onClick:()=>void f(e.code),children:[(0,X.jsx)(qe,{}),(0,X.jsx)(`span`,{children:t(n?`localeDownloading`:`localeInstall`)})]})]},e.code)})}),(0,X.jsx)(`div`,{className:`bg-task-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`bgTaskRefresh`),onClick:()=>void d(),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var ho=`xing-shuyin/pi-web-ui`,go={state:`idle`,version:null,percent:0,message:null};function _o(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function vo(e,t){switch(t.state){case`checking`:return{...e,state:`checking`,message:null};case`available`:return{...e,state:`available`,version:t.version??e.version,message:null};case`up-to-date`:return{...e,state:`up-to-date`,version:t.version??e.version,message:null};case`downloading`:return{...e,state:`downloading`,percent:_o(t.percent),message:null};case`downloaded`:return{...e,state:`downloaded`,version:t.version??e.version,percent:100,message:null};case`error`:return{...e,state:`error`,message:t.message??`unknown error`};default:return e}}function yo(e){if(!Rn(e))return null;let t=(e??(typeof window>`u`?void 0:window))?.piDesktop?.updater;return!t||typeof t.check!=`function`||typeof t.download!=`function`?null:t}function bo(e){return e instanceof Error?e.message:String(e)}function xo(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${ho}/releases/tag/v${t}`:`https://github.com/${ho}/releases/latest`}function So(){let[e]=(0,g.useState)(()=>yo()),[t,n]=(0,g.useState)(go);(0,g.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>vo(t,e)))},[e]);let r=(0,g.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:bo(e)}))))},[e]),i=(0,g.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:bo(e)}))))},[e]),a=(0,g.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:bo(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}function Co(e){let t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),r=Math.max(0,e.cacheWrite??0),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0,writeRate:i>0?Math.min(r/i,1):0}}var wo=2e3;function To(e,t,n=wo){return e.filter(e=>t-e.t<=n)}function Eo(e,t=wo){if(e.length<2)return 0;let n=e[e.length-1],r=e.find(e=>e.t>=n.t-t)??e[0],i=(n.t-r.t)/1e3;return i<=0?0:Math.max(0,(n.out-r.out)/i)}function Do(e){if(!e)return 0;let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r>=12352&&r<=12543||r>=13312&&r<=19903||r>=19968&&r<=40959||r>=63744&&r<=64255||r>=65280&&r<=65519||r===12288)&&t++}let n=e.length-t;return Math.round(t+n/4)}function Oo(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=Do(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=Do(n.thinking));return t}function ko(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function Ao(e){return e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}function jo(e){return e.startsWith(`zh`)?`ZH`:e.startsWith(`ja`)?`JA`:e.startsWith(`ko`)?`KO`:e.startsWith(`fr`)?`FR`:e.startsWith(`de`)?`DE`:e.startsWith(`es`)?`ES`:e.startsWith(`ru`)?`RU`:e.startsWith(`pt`)?`PT`:e.startsWith(`it`)?`IT`:`EN`}function Mo({entry:e,bar:t,chat:n,view:r,plugins:i,onViewChange:a,onOpenPanel:o,onOpenSettings:s,onOpenGlobalSearch:c,onOpenBgTasks:l,onOpenProjectPicker:u,onOpenPluginMenu:d,isPluginMenuOpen:f,isProjectPickerOpen:p,onUiAction:m,uiContextEntries:h,dropdownProps:_}){let v=Z(),{locale:y,packs:b,setLocale:x}=Nn(),{engine:S}=Ia(),C=S===`dsh`,[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(!1),[A,j]=(0,g.useState)(!1),ee=n.settings?.uiLayout,M=n.state,te=M?.stats,N=M?.isStreaming??!1,P=(0,g.useRef)([]),F=M?.streamingMessage?Oo(M.streamingMessage.content):0;(0,g.useEffect)(()=>{if(!N){P.current=[];return}let e=Date.now(),t=P.current,n=t[t.length-1];n&&e-n.t<250||(P.current=To([...t,{t:e,out:F}],e))},[N,F]);let re=N?Eo(P.current):0,I=n=>{n.preventDefault(),n.stopPropagation();let r=t=>{let n={...ee?.slots,[e.id]:t};$({type:`set_settings`,uiLayout:{...ee,slots:n}})},i=()=>{let t=new Set(ee?.hidden??[]);t.add(e.id),$({type:`set_settings`,uiLayout:{...ee,hidden:[...t]}})},a=[];t!==`top`&&a.push({id:`host:move-top`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToTop`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`bottom`&&a.push({id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToBottom`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`left`&&a.push({id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToLeft`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`right`&&a.push({id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToRight`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),a.push({id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:v(`uiLayoutRestore`),kind:`action`,order:50,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),h&&h.length>0&&a.push(...h),fa({x:n.clientX,y:n.clientY,slot:`contextmenu.topbar`,target:{id:e.id,label:e.label},entries:a,onHostAction:e=>{e.id===`host:move-top`?r(`topbar.primary`):e.id===`host:move-bottom`?r(`bottombar`):e.id===`host:move-left`?r(`sidebar.left`):e.id===`host:move-right`?r(`sidebar.right`):e.id===`host:hide-item`&&i()}})},L=e.id,ie=e.labelExplicit?e.label:``,R=e=>ie||e,z=e=>ie?`${ie} ${e}`:e;if(e.kind===`select`&&e.options?.length){let t=e.options.some(t=>t.value===e.value)?e.value:e.options[0].value;return(0,X.jsx)(`select`,{className:`bar-item bar-item-select`,title:e.hint??e.label,"data-tip":e.hint??e.label,"aria-label":e.label,value:t,onChange:t=>m?.(e,t.target.value),onContextMenu:I,"data-bar-item":L,children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})}if(L===`host:brand`)return(0,X.jsxs)(`span`,{className:`bar-item brand bar-item-brand`,title:v(`brand`),onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(`span`,{className:`brand-logo bar-item-brand-logo`,children:`π`}),(0,X.jsx)(`span`,{className:`brand-name bar-item-text`,children:R(`pi-web-ui`)})]});if(L===`host:conn`){let e=n.ready?`ok`:n.status===`closed`?`error`:`busy`,t=n.ready?v(`connected`):n.status===`closed`?v(`reconnecting`):v(`connecting`);return(0,X.jsxs)(`span`,{className:`bar-item status-item status-conn ${e} bar-item-conn`,title:t,"data-tip":t,onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(`span`,{className:`status-dot ${e}`}),(0,X.jsx)(`span`,{className:`status-conn-label bar-item-text`,children:z(t)})]})}if(L===`host:engine`)return S===`pi`?null:(0,X.jsx)(`span`,{className:`bar-item status-item engine-badge engine-${S} bar-item-engine`,title:`${v(`engineBadge`)}: ${S}`,"data-tip":`${v(`engineBadge`)}: ${S}`,onContextMenu:I,"data-bar-item":L,children:z(S===`dsh`?`DSH`:S)});if(L===`host:ctx`){let e=te?.contextUsage,t=e?.softCap??null,n=t!==null&&t>0&&t<(e?.contextWindow??0),r=n?t:e?.contextWindow??0,i=e?.tokens!==null&&e?.tokens!==void 0&&r>0?Math.min(100,Math.round(e.tokens/r*100)):null,a=e?.tokens!==null&&e?.tokens!==void 0?ko(e.tokens):null,o=r>0?ko(r):null,s=a!==null&&o!==null&&i!==null?`${a} / ${o}`:`—`,c=i===null?``:i>=80?`warn`:i>=50?`mid`:`ok`,l=n?`${v(`contextUsage`)}: ${ko(e?.tokens??0)} / ${ko(t)} (${v(`softCapMarker`)}, max ${ko(e?.contextWindow??0)})`:t!==null&&t>0?`${v(`contextUsage`)}: ${s} · ${v(`softCapMarker`)}: ${ko(t)}`:`${v(`contextUsage`)}: ${s}`,u=i!==null&&i>0?+(31.42*(1-Math.min(i,100)/100)).toFixed(2):31.42;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-ctx bar-item-ctx`,title:l,"data-tip":l,onContextMenu:I,"data-bar-item":L,children:[(0,X.jsxs)(`svg`,{className:`ctx-ring ${c}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,X.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:31.42,strokeDashoffset:u,"data-percent":i})]}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[ie?`${ie} `:``,a!==null&&o!==null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`ctx-val`,children:a}),(0,X.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,X.jsx)(`span`,{className:`ctx-max`,children:o})]}):s]})]})}if(L===`host:cache`){let e=Co(te?.tokens??{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}),t=e.hitRate*100,n=e.totalInput===0?``:e.hitRate>=.7?`ok`:e.hitRate>=.4?`mid`:`warn`,r=e.totalInput>0?`${t.toFixed(1)}%`:`—`,i=v(`cacheHitTip`,{read:ko(e.read),write:ko(e.write),miss:ko(e.miss),input:ko(e.totalInput)}),a=e.totalInput>0?`${v(`cacheHit`)}: ${r} · ${i}`:v(`cacheHit`),o=e.totalInput===0;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-cache bar-item-cache${o?` is-zero`:``}`,title:a,"data-tip":a,onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(Ye,{className:`bar-item-icon`}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[ie?`${ie} `:``,(0,X.jsx)(`b`,{className:`cache-pct ${n}`,children:r})]})]})}if(L===`host:cost`){let e=te?.cost??0,t=Ao(e),n=v(`cumulativeCost`);return(0,X.jsxs)(`span`,{className:`bar-item status-item status-cost bar-item-cost${e<=0?` is-zero`:``}${ie?` has-name`:``}`,title:n,"data-tip":n,onContextMenu:I,"data-bar-item":L,children:[ie?(0,X.jsx)(`span`,{className:`bar-item-text`,children:ie}):null,(0,X.jsx)(`span`,{className:`bar-item-char`,children:`$`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:t})]})}if(L===`host:msg-count`){let e=te?.totalMessages??0,t=`${v(`sessionMessages`)}: ${e}`;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-msg-count bar-item-msg-count${e===0?` is-zero`:``}`,title:t,"data-tip":t,onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(J,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:z(String(e))})]})}if(L===`host:working`){if(!N)return null;let e=(M?.queue?.steering?.length??0)+(M?.queue?.followUp?.length??0);return(0,X.jsxs)(`span`,{className:`bar-item status-item working bar-item-working`,title:v(`working`),"data-tip":v(`working`),onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(`span`,{className:`working-spin`}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[R(v(`working`)),e>0&&` ⏳ ${e}`]}),(0,X.jsx)(`span`,{className:`status-rate bar-item-rate`,title:v(`rateTip`),children:re>0?`${Math.round(re)}${v(`tps`)}`:`…`})]})}if(L===`host:status-delegate`)return M?.delegateMode?(0,X.jsxs)(`span`,{className:`bar-item status-item delegate-badge bar-item-delegate`,title:M.delegateConvId?v(`delegateModeOpenTip`):v(`delegateModeBadgeTip`),"data-tip":M.delegateConvId?v(`delegateModeOpenTip`):v(`delegateModeBadgeTip`),onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(`span`,{className:`bar-item-icon`,children:`🔎`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:R(v(`delegateModeBadge`))}),M.delegateConvId?(0,X.jsx)(`button`,{type:`button`,className:`delegate-badge-open`,title:v(`delegateModeOpenTip`),onClick:()=>$({type:`switch_conversation`,id:M.delegateConvId}),children:`↗`}):null]}):null;if(L===`host:host-metrics`){let e=n.hostMetrics;if(!e)return null;let t=e.cpuPercent===null||!Number.isFinite(e.cpuPercent)?`—`:`${Math.round(e.cpuPercent)}%`,r=Number.isFinite(e.memoryPercent)?`${Math.round(e.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-host-metrics bar-item-host-metrics`,title:`${v(`hostResourcesTip`)}\n${v(`hostProcessor`)}: ${t} · ${v(`hostMemory`)}: ${r}`,"data-tip":`${v(`hostResourcesTip`)}\n${v(`hostProcessor`)}: ${t} · ${v(`hostMemory`)}: ${r}`,onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(Ze,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:z(`${t} · ${r}`)})]})}if(L===`host:browser`)return n.settings?.disabledAgentTools?.includes(`browser_page`)?null:(0,X.jsx)(`span`,{className:`bar-item-wrap`,onContextMenu:I,"data-bar-item":L,children:(0,X.jsx)(ur,{})});if(L===`host:sound`)return(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:w,onOpenChange:T,tip:R(v(`sound`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`sound`)),"data-tip":R(v(`sound`)),onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(ne,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:R(v(`sound`))})]}),children:[_?.sound&&_?.onSoundChange?(0,X.jsx)(Fn,{settings:_.sound,onChange:_.onSoundChange,onPreview:_.onSoundPreview??(()=>{})}):null,(0,X.jsx)(si,{})]});if(L===`host:language`)return(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:E,onOpenChange:D,tip:R(v(`language`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`language`)),"data-tip":R(v(`language`)),onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(Fe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:z(jo(y))})]}),children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`language`)}),b.map(e=>(0,X.jsx)(Ht,{active:y===e.code,onClick:()=>{x(e.code),D(!1)},children:e.nativeName},e.code)),_?.onLocaleModalOpen?(0,X.jsxs)(Ht,{onClick:()=>{D(!1),_.onLocaleModalOpen?.()},children:[(0,X.jsx)(qe,{}),` `,v(`localeGetMore`)]}):null]});if(L===`host:theme`){let e=_?.themes??[],n=_?.theme??null;return(0,X.jsx)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:O,onOpenChange:t=>{k(t),t&&e.length===0&&_?.reloadThemes?.()},tip:R(v(`theme`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`theme`)),"data-tip":R(v(`theme`)),onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(H,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:R(v(`theme`))})]}),children:(()=>{let t=e.filter(e=>e.group===`classic`),r=e.filter(e=>e.group!==`classic`),i=e=>{let t=y===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?v(`themeLight`):e.scheme===`dark`?v(`themeDark`):``;return n?y===`zh`?`${t}(${n})`:`${t} (${n})`:t};return(0,X.jsxs)(X.Fragment,{children:[t.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`themeGroupClassics`)}),t.map(e=>(0,X.jsx)(Ht,{active:n===e.id,onClick:()=>{_?.onThemeChange?.(e.id),k(!1)},children:i(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:t.length>0?v(`themeGroupBuiltin`):v(`theme`)}),(0,X.jsx)(Ht,{active:n===null,onClick:()=>{_?.onThemeChange?.(null),k(!1)},children:v(`themeDefault`)}),r.map(e=>(0,X.jsx)(Ht,{active:n===e.id,onClick:()=>{_?.onThemeChange?.(e.id),k(!1)},children:i(e)},e.id))]})})()})}if(L===`host:update`){let e=_?.updatesCount??0;return _?.managed?(0,X.jsxs)(`span`,{className:`bar-item chip`,title:v(`updatesManaged`),"data-tip":v(`updatesManaged`),onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(qe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:z(`v${_?.appVersion??n.update?.current??`…`}`)})]}):(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:A,onOpenChange:e=>{j(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},tip:R(v(`update`)),fit:!0,caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`update`)),"data-tip":R(v(`update`)),onContextMenu:I,"data-bar-item":L,children:[(0,X.jsx)(qe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:z(`v${n.update?.current??`…`}`)}),n.update&&!n.update.upToDate&&(0,X.jsx)(`span`,{className:`update-dot`}),e>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:e})]}),children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`update`)}),_?.renderUpdateBody?.(),_?.renderAllUpdatesBody?.()]})}let V=null,U=e.label,ae=null,oe=!1,se=!1,W=``,le,ue;switch(L){case`host:chat`:V=(0,X.jsx)(J,{className:`bar-item-icon`}),U=R(v(`chat`)),oe=r===`chat`,se=!0,ue=()=>a?.(`chat`);break;case`host:terminal`:V=(0,X.jsx)(B,{className:`bar-item-icon`}),U=R(v(`terminal`)),oe=r===`terminal`,se=!0,ue=()=>a?.(`terminal`);break;case`host:git`:V=(0,X.jsx)(Le,{className:`bar-item-icon`}),U=R(v(`scmTab`)),oe=r===`git`,se=!0,ue=()=>a?.(`git`);break;case`host:new-chat`:V=(0,X.jsx)(me,{className:`bar-item-icon`}),U=R(v(`newChat`)),W=`chip newchat`,ue=()=>{a?.(`chat`),$({type:`new_chat`}),sr()};break;case`host:new-ephemeral-chat`:if(C)return null;V=(0,X.jsx)(Ot,{className:`bar-item-icon`}),U=R(v(`newChatEphemeral`)),W=`chip newchat ephemeral-chat-btn`,ue=()=>{a?.(`chat`),$({type:`new_chat`,ephemeral:!0}),sr()};break;case`host:history`:if(r&&r!==`chat`)return null;V=(0,X.jsx)(Se,{className:`bar-item-icon`}),U=R(v(`openHistory`)),W=`panel-toggle`,ue=()=>o?.(`left`);break;case`host:files`:if(r&&r!==`chat`)return null;V=(0,X.jsx)(Re,{className:`bar-item-icon`}),U=R(v(`openFiles`)),W=`panel-toggle has-label`,ue=()=>o?.(`right`);break;case`host:open-project`:V=(0,X.jsx)(ze,{className:`bar-item-icon`}),U=R(v(`openProject`)),W=`chip open-project`,oe=!!p,ue=()=>u?.();break;case`host:search`:V=(0,X.jsx)(de,{className:`bar-item-icon`}),U=R(v(`searchGlobal`)),W=`chip`,ue=()=>c?.();break;case`host:tasks`:V=(0,X.jsx)(ke,{className:`bar-item-icon`}),U=R(v(`bgTasks`)),W=`chip bg-task-chip`,n.bgServers.length>0&&(ae=(0,X.jsx)(`span`,{className:`bg-task-badge bar-item-badge`,children:n.bgServers.length})),ue=()=>l?.();break;case`host:settings`:V=(0,X.jsx)(ce,{className:`bar-item-icon`}),U=R(v(`settings`)),W=`chip`,ue=()=>s?.();break;case`host:plugins`:V=(0,X.jsx)(ht,{className:`bar-item-icon`}),U=R(v(`pluginMenuTitle`)),W=`chip`,ue=e=>{d?d(e.currentTarget):s?.(`plugins`)};break;case`host:github`:V=(0,X.jsx)(Ie,{className:`bar-item-icon`}),U=R(`GitHub`),W=`chip github`,ue=()=>window.open(`https://github.com/xing-shuyin/pi-web-ui`,`_blank`,`noreferrer,noopener`);break;case`host:cwd`:V=(0,X.jsx)(Re,{className:`bar-item-icon`}),U=z(M?.cwd?M.cwd.split(/[/\\]/).pop()||M.cwd:v(`openProject`)),W=`status-item status-cwd`,oe=!!p,ue=()=>u?.();break;case`host:plugin-status`:if(n.statuses.length===0)return null;V=(0,X.jsx)(Et,{className:`bar-item-icon`}),U=z(n.statuses.map(e=>e.text).join(` · `)),W=`status-item ext-status`;break;default:if(e.kind===`view`){let t=e.view??``;oe=r===t,se=!0;let o=(i??n.plugins??[]).find(t=>`plugin:${t.id}`===e.source);W=`plugin-tab${o?.error?` broken`:``}`,o?.error&&(le=`${e.label}: ${o.error}`);let s=e.iconSvg||o?.iconSvg,c=e.icon||o?.icon;V=s?(0,X.jsx)(hi,{icon:c,iconSvg:s,className:`bar-item-icon plugin-icon-svg`}):c?(0,X.jsx)(`span`,{className:`bar-item-icon bar-item-glyph`,children:c}):null,ue=()=>a?.(t)}else{let n=e.iconSvg,r=e.icon;W=t===`bottom`?`status-item status-action chip`:`chip`,V=n?(0,X.jsx)(hi,{icon:r,iconSvg:n,className:`bar-item-icon plugin-icon-svg`}):r?(0,X.jsx)(`span`,{className:`bar-item-icon bar-item-glyph`,children:r}):null,e.badge&&(ae=(0,X.jsx)(`span`,{className:`bar-item-badge`,children:e.badge})),ue=()=>m?.(e)}}let fe=le??e.hint??U,pe=[`bar-item`,se?`tb-tab${oe?` active`:``}`:``,W,oe&&!se?`active`:``].filter(Boolean).join(` `);return(0,X.jsxs)(`button`,{type:`button`,role:se?`tab`:void 0,"aria-selected":se?oe:void 0,"aria-haspopup":L===`host:plugins`?`menu`:void 0,"aria-expanded":L===`host:plugins`?!!f:void 0,className:pe,title:fe,"data-tip":fe,"aria-label":U,onClick:ue,onContextMenu:I,"data-bar-item":L,children:[V,(0,X.jsx)(`span`,{className:`bar-item-text`,children:U}),ae]})}var No={name:`@earendil-works/pi-coding-agent`,kind:`pi-core`,current:``,latest:null,upToDate:!1};function Po({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=fo({open:t,anchor:e,onClose:n});return(0,g.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,j.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Fo(){let[e,t]=(0,g.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,g.useEffect)(()=>{if(typeof window>`u`||window.matchMedia===void 0)return;let e=window.matchMedia(`(max-width: 768px)`),n=e=>t(e.matches);return typeof e.addEventListener==`function`?e.addEventListener(`change`,n):e.addListener(n),()=>{typeof e.removeEventListener==`function`?e.removeEventListener(`change`,n):e.removeListener(n)}},[]),e}function Io({chat:e,terminal:t,view:n,plugins:r,uiPrimary:i,uiOverflow:a,uiContextTopbar:o,onUiAction:s,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onManagePlugins:d,onOpenBgTasks:f,onOpenGlobalSearch:p,sound:m,onSoundChange:h,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x,onOpenIconEdit:S}){let{locale:C,setLocale:w,t:T,packs:E}=Nn(),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(!1),[j,ee]=(0,g.useState)(null),M=La(`cwd`),te=La(`workspaceRoots`),N=Ra(),P=(0,g.useRef)(null),F=t=>!e.tabs||t===`chat`||e.tabs.includes(t),re=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!Ii(e)),I=new Set([...i??[],...a??[]].filter(e=>Ii(e)&&!e.hidden).map(e=>e.source.slice(7))),L=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),ie=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(L.get(`${e.id}:__view`)??1e6+e.index)-(L.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),R=i===void 0?[`host:history`,`host:brand`,`host:open-project`,`host:chat`,`host:terminal`,`host:git`,`host:plugins`,`host:search`,`host:browser`,`host:tasks`,`host:settings`,`host:sound`,`host:language`,`host:theme`,`host:update`,`host:github`,`host:new-chat`,`host:new-ephemeral-chat`,`host:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),z=(F(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!R.some(t=>t.id===`${e.id}:__view`)).map(e=>({id:`${e.id}:__view`,slot:`topbar.primary`,source:`plugin:${e.id}`,label:e.name,kind:`view`,view:`plugin:${e.id}`,order:23,align:`end`,hidden:!1,userOverrides:[],arrangedBy:[]})),V=e=>{if(e.source!==`host`)return!1;switch(e.id){case`host:history`:return l(`left`),!0;case`host:files`:return l(`right`),!0;case`host:new-chat`:return c(`chat`),$({type:`new_chat`}),sr(),!0;case`host:new-ephemeral-chat`:return c(`chat`),$({type:`new_chat`,ephemeral:!0}),sr(),!0;case`host:open-project`:return A(!0),!0;case`host:search`:return p(),!0;case`host:tasks`:return f(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return ee(P.current?{rect:P.current.getBoundingClientRect(),el:P.current}:null),!0;default:return!1}},U=(t,n,r)=>{t.preventDefault(),t.stopPropagation();let i=e.settings?.uiLayout,a=e=>{let t={...i?.slots,[n]:e};$({type:`set_settings`,uiLayout:{...i,slots:t}})},s=()=>{let e=new Set(i?.hidden??[]);e.add(n),$({type:`set_settings`,uiLayout:{...i,hidden:[...e]}})},c=[{id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToBottom`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToLeft`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToRight`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:T(`uiLayoutRestore`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},...o??[]];fa({x:t.clientX,y:t.clientY,slot:`contextmenu.topbar`,target:{id:n,label:r},entries:c,onHostAction:e=>{e.id===`host:move-bottom`?a(`bottombar`):e.id===`host:move-left`?a(`sidebar.left`):e.id===`host:move-right`?a(`sidebar.right`):e.id===`host:hide-item`&&s()}})},{appVersion:ae}=Ia(),oe=za(),se=Ba(),[W,le]=(0,g.useState)(!1);(0,g.useEffect)(()=>{W&&e.status===`open`&&le(!1)},[W,e.status]);let[ue,fe]=(0,g.useState)(!1),[pe,G]=(0,g.useState)(!1),[K,he]=(0,g.useState)(!1),[ge,q]=(0,g.useState)(!1),_e=Rn(),ve=So(),[ye,be]=(0,g.useState)(!1),xe=()=>{if(!e.ready)return;let n=T(`updateTabTitle`),r={name:n,command:`npm i -g pi-web-ui@latest`,cwd:"${pwd}"},i=e.terminals.find(e=>e.title===n);i?(t.restart(i.id),$({type:`run_command`,terminalId:i.id,conversationId:i.conversationId,command:r,cols:80,rows:24})):t.create({id:jt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),q(!1),c(`terminal`)},Ce=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:kt(n),cwd:"${pwd}"},a=e.terminals.find(e=>e.title===r);a?(t.restart(a.id),$({type:`run_command`,terminalId:a.id,conversationId:a.conversationId,command:i,cols:80,rows:24})):t.create({id:jt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),q(!1),c(`terminal`)},we=e.updatesAll??[],Te=e.updatesSdk,Ee=Te&&Te.newerInstalled?{running:Te.running,installed:Te.newerInstalled}:null,De=Te?.bundledInUse===!0,Oe=we.find(e=>e.kind===`pi-core`&&!e.error),Ae=De&&(!Oe||!Oe.upToDate),je=Ae&&!Oe,Me=we.filter(e=>!e.upToDate&&!e.error).length,Ne=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Pe=e=>e.kind===`git-extension`&&e.source?e.source:e.name,Be=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Ve=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},He=(e,t)=>{if(!t)return Ve(e);let n=Ve(e),r=Ve(t);return n===r?n:`${n} → ${r}`},Ue=()=>(0,X.jsxs)(`div`,{className:`dd-updates-all`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`updatesAllTitle`)}),e.updatesAll===null?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`checkingUpdate`)}):we.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:we.map(e=>{let t=Ee!=null&&e.kind===`pi-core`,n=!e.error&&(!e.upToDate||t);return(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:n?` warn`:``}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>Ce([e],T(`updatePkgTabTitle`,{name:e.name})),children:T(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:Be(e),children:Pe(e)}),(0,X.jsxs)(`span`,{className:`dd-all-meta`,children:[(0,X.jsx)(`span`,{className:`dd-all-kind`,children:e.kind===`webui`?T(`kindWebUi`):e.kind===`pi-core`?T(`kindPiCore`):e.kind===`git-extension`?T(`kindGitExtension`):e.kind===`plugin`?T(`kindPlugin`):T(`kindPackage`)}),(0,X.jsx)(`span`,{className:`dd-all-vers`,title:e.error?e.error:e.kind===`git-extension`?e.upToDate?e.current:`${e.current} → ${e.latest}`:void 0,children:e.error?T(`updateCheckFailed`):e.kind===`git-extension`?e.upToDate?Ve(e.current):He(e.current,e.latest):e.kind===`plugin`?e.upToDate?e.current.startsWith(`v`)?e.current:Ve(e.current):He(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})}),t&&!e.error&&(0,X.jsx)(`span`,{className:`dd-split-run`,children:T(`piCoreSplitRun`,{running:Ee.running})})]})]},`${e.kind}:${e.name}`)})}),Ee&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`piSdkSplitNote`,{running:Ee.running,installed:Ee.installed})}),Ae&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`piSdkBundledNote`,{running:Te.running})}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[je&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce([No],T(`installGlobalEngineTabTitle`)),children:T(`installGlobalEngineBtn`)}),Ne.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce(Ne,T(`updateAllTabTitle`)),children:T(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:Ne.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:T(`updatesAllRefresh`)})]})]}),We=()=>{let t=xo(e.update?.latest??ve.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:T(`updateDesktopManual`)});if(!ve.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopNoBridge`)}),n]});switch(ve.state){case`checking`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopChecking`)}),n]});case`available`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopAvailable`,{version:ve.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.download(),children:T(`updateDesktopDownload`)}),n]});case`downloading`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopDownloading`,{n:ve.percent})}),n]});case`downloaded`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`updateDesktopDownloaded`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.quitAndInstall(),children:T(`updateDesktopInstall`)}),n]});case`up-to-date`:return(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`upToDate`)});case`error`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopError`,{error:ve.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>ve.check(),children:T(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.check(),children:T(`updateDesktopCheck`)}),n]})}},Ge=()=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`dd-update`,children:[(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:T(`currentVersion`)}),(0,X.jsxs)(`b`,{children:[`v`,e.update?.current??`…`]})]}),(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:T(`latestVersion`)}),(0,X.jsx)(`b`,{children:e.update===null?T(`checkingUpdate`):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:T(`checkingUpdate`)})]}),e.update&&e.update.upToDate&&(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`upToDate`)}),e.update&&!e.update.upToDate&&e.update.latest&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateAvailable`,{version:e.update.latest})}),e.update?.latestPublishedAt&&Date.now()-new Date(e.update.latestPublishedAt).getTime()<18e5&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateJustPublished`,{version:e.update.latest??``})}),e.update&&!e.update.upToDate&&e.update.latest&&!_e&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&_e&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopNote`)})]}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`check_update`}),children:e.update===null?T(`checkingUpdate`):T(`checkUpdate`)}),e.update&&!e.update.upToDate&&e.update.latest&&!_e&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:xe,children:T(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&_e&&We(),se&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:W,title:T(`restartServiceTip`,{name:se.name}),onClick:()=>{W||(le(!0),$({type:`restart_service`}))},children:T(W?`restartingService`:`restartService`)})]})]}),Y=Fo(),Je={"host:brand":(0,X.jsxs)(`span`,{className:`brand`,children:[(0,X.jsx)(`span`,{className:`brand-logo`,children:`π`}),(0,X.jsx)(`span`,{className:`brand-name`,children:`pi-web-ui`})]}),"host:open-project":(0,X.jsxs)(`button`,{type:`button`,className:`chip open-project`,"data-tip":T(`openProject`),onClick:()=>A(!0),children:[(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`openProject`)})]}),"host:history":n===`chat`&&F(`history`)?(0,X.jsx)(`button`,{type:`button`,className:`panel-toggle`,"data-tip":T(`openHistory`),"aria-label":T(`openHistory`),onClick:()=>l(`left`),children:(0,X.jsx)(Se,{})}):null,"host:files":n===`chat`&&F(`files`)?(0,X.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"data-tip":T(`openFiles`),"aria-label":T(`openFiles`),onClick:()=>l(`right`),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{children:T(`openFiles`)})]}):null,"host:new-chat":F(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":T(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),sr()},children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:T(`newChat`)})]}):null,"host:new-ephemeral-chat":N?null:(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat ephemeral-chat-btn`,"data-tip":T(`newChatEphemeralTip`),onClick:()=>{c(`chat`),$({type:`new_chat`,ephemeral:!0}),sr()},children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(`span`,{children:T(`newChatEphemeral`)})]}),"host:chat":(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`chat`,className:`tb-tab${n===`chat`?` active`:``}`,"data-tip":T(`chat`),onClick:()=>c(`chat`),children:[(0,X.jsx)(J,{}),(0,X.jsx)(`span`,{children:T(`chat`)})]}),"host:terminal":F(`terminal`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`terminal`,className:`tb-tab${n===`terminal`?` active`:``}`,"data-tip":T(`terminal`),onClick:()=>c(`terminal`),children:[(0,X.jsx)(B,{}),(0,X.jsx)(`span`,{children:T(`terminal`)})]}):null,"host:git":F(`git`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`git`,className:`tb-tab${n===`git`?` active`:``}`,"data-tip":T(`scmTab`),onClick:()=>c(`git`),children:[(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{children:T(`scmTab`)})]}):null,"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`pluginMenuTitle`),"aria-haspopup":`menu`,"aria-expanded":j!==null,onClick:e=>{let t=e.currentTarget;ee(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(ht,{"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`pluginMenuTitle`)})]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`searchGlobalTip`),onClick:p,children:[(0,X.jsx)(de,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(ur,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":T(`bgTasksTip`),onClick:f,children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`bgTasks`)}),e.bgServers.length>0&&(0,X.jsx)(`span`,{className:`bg-task-badge`,children:e.bgServers.length})]}),"host:settings":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`settingsTitle`),onClick:u,children:[(0,X.jsx)(ce,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`settings`)})]}),"host:sound":(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`sound`)})]}),tip:T(`sound`),open:ue,onOpenChange:fe,caret:!1,children:[(0,X.jsx)(Fn,{settings:m,onChange:h,onPreview:_}),(0,X.jsx)(si,{})]}),"host:language":(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fe,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:En(C)})]}),tip:T(`language`),open:pe,onOpenChange:G,caret:!1,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`language`)}),E.map(e=>(0,X.jsx)(Ht,{active:C===e.code,onClick:()=>{w(e.code),G(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(Ht,{onClick:()=>{G(!1),be(!0)},children:[(0,X.jsx)(qe,{}),` `,T(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(H,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`theme`)})]}),tip:T(`theme`),open:K,caret:!1,onOpenChange:e=>{he(e),e&&v.length===0&&x()},children:(()=>{let e=v.filter(e=>e.group===`classic`),t=v.filter(e=>e.group!==`classic`),n=e=>{let t=C===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?T(`themeLight`):e.scheme===`dark`?T(`themeDark`):``;return n?C===`zh`?`${t}(${n})`:`${t} (${n})`:t};return(0,X.jsxs)(X.Fragment,{children:[e.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`themeGroupClassics`)}),e.map(e=>(0,X.jsx)(Ht,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:e.length>0?T(`themeGroupBuiltin`):T(`theme`)}),(0,X.jsx)(Ht,{active:y===null,onClick:()=>{b(null),he(!1)},children:T(`themeDefault`)}),t.map(e=>(0,X.jsx)(Ht,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]})})()}),"host:update":oe?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":T(`updatesManaged`),children:[(0,X.jsx)(qe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,ae??e.update?.current??`…`]})]}):(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,e.update?.current??`…`]}),e.update&&!e.update.upToDate&&(0,X.jsx)(`span`,{className:`update-dot`,title:T(`updateAvailable`,{version:e.update.latest??``})}),Me>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:T(`updatesAllBadge`,{n:Me})})]}),tip:T(`update`),open:ge,caret:!1,onOpenChange:e=>{q(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`update`)}),Ge(),Ue()]}),"host:github":(0,X.jsx)(`a`,{className:`chip github`,href:`https://github.com/xing-shuyin/pi-web-ui`,target:`_blank`,rel:`noreferrer noopener`,"data-tip":T(`githubRepo`),children:(0,X.jsx)(Ie,{})}),"host:conn":(0,X.jsxs)(`span`,{className:`chip`,"data-tip":e.status,children:[(0,X.jsx)(`span`,{className:`status-dot ${e.status===`open`?`ok`:`busy`}`}),(0,X.jsx)(`span`,{className:`chip-sub`,children:e.status})]}),"host:engine":(0,X.jsx)(`span`,{className:`chip`,"data-tip":`engine`,children:(0,X.jsx)(`span`,{className:`chip-sub`,children:e.engine??`pi`})}),"host:ctx":(0,X.jsx)(`span`,{className:`chip`,"data-tip":T(`contextUsage`),children:(0,X.jsx)(`span`,{className:`chip-sub`,children:(e.state?.stats?.contextUsage?.tokens??0)>0?`${e.state?.stats?.contextUsage?.tokens}`:T(`contextUsage`)})}),"host:cost":(0,X.jsx)(`span`,{className:`chip`,"data-tip":T(`cumulativeCost`),children:(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`$`,(e.state?.stats?.cost??0).toFixed(4)]})}),"host:cwd":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":e.state?.cwd??``,onClick:()=>A(!0),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:e.state?.cwd?.split(/[/\\]/).pop()||e.state?.cwd})]})},Ye=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Xe=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),Ze=e=>Ye.has(e)&&!F(e.slice(5)),Qe=e=>{if(e.kind===`view`){if(!F(`plugins`))return null;let t=e.view??``,i=r.find(t=>`plugin:${t.id}`===e.source),a=i?.error?`${e.label}: ${i.error}`:e.hint??e.label;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===t,className:`tb-tab plugin-tab${n===t?` active`:``}${i?.error?` broken`:``}`,"data-tip":a,onClick:()=>c(t),onContextMenu:t=>U(t,e.id,e.label),children:[(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`plugin-topbar-item plugin-topbar-select`,title:e.hint??e.label,"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>s?.(e,t.target.value),onContextMenu:t=>U(t,e.id,e.label),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id):(0,X.jsxs)(`button`,{type:`button`,className:`plugin-topbar-item`,"data-tip":e.hint??e.label,onClick:()=>s?.(e),onContextMenu:t=>U(t,e.id,e.label),children:[(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},$e=[];for(let t of R){if(t.entry?.hidden||Ze(t.id))continue;let i=null;t.entry?i=(0,X.jsx)(Mo,{entry:t.entry,bar:`top`,chat:e,view:n,plugins:r,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onOpenGlobalSearch:p,onOpenBgTasks:f,onOpenProjectPicker:()=>A(!0),isProjectPickerOpen:k,onOpenPluginMenu:e=>ee(t=>t?.el===e?null:{rect:e.getBoundingClientRect(),el:e}),isPluginMenuOpen:j!==null,onUiAction:s,uiContextEntries:o,dropdownProps:{sound:m,onSoundChange:h,onSoundPreview:_,theme:y,themes:v,onThemeChange:b,reloadThemes:x,onLocaleModalOpen:()=>be(!0),renderUpdateBody:Ge,renderAllUpdatesBody:Ue,updatesCount:Me,managed:oe,appVersion:ae}},t.id):t.id.startsWith(`host:`)&&Je[t.id]&&(i=Je[t.id]),i&&$e.push({id:t.id,entry:t.entry,node:i})}for(let t of z){let i=(0,X.jsx)(Mo,{entry:t,bar:`top`,chat:e,view:n,plugins:r,onViewChange:c,onUiAction:s,uiContextEntries:o},t.id);i&&$e.push({id:t.id,entry:t,node:i})}let et=e=>e.entry?.align??`start`,[tt,nt]=(0,g.useState)(()=>new Set),rt=(0,g.useRef)(null),it=(0,g.useRef)(new Map),at=$e.filter(e=>!tt.has(e.id)),ot=Y?at.filter(e=>oa.has(e.id)):[],st=Y?at.filter(e=>!oa.has(e.id)):at,ct=Y?$e.filter(e=>!oa.has(e.id)):$e,lt=[...ct.filter(e=>et(e)===`start`),...ct.filter(e=>et(e)===`center`),...ct.filter(e=>et(e)===`end`)],ut=lt.filter(e=>!tt.has(e.id)),dt=(0,g.useRef)(lt),ft=(0,g.useRef)(ut);(0,g.useLayoutEffect)(()=>{dt.current=lt,ft.current=ut});let pt=()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`)),n=ft.current;t.length===n.length&&n.forEach((e,n)=>it.current.set(e.id,t[n].offsetWidth));let r=Number.parseFloat(getComputedStyle(e).columnGap)||0,i=dt.current,a=ca(i.map(e=>({id:e.id,width:e.entry?it.current.get(e.id)??0:0})),e.clientWidth,r,0,Ni);nt(e=>e.size===a.size&&[...a].every(t=>e.has(t))?e:a)},mt=`${at.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Y?`m`:`d`}`;(0,g.useLayoutEffect)(pt,[mt]),(0,g.useEffect)(()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>pt());return t.observe(e),()=>t.disconnect()},[mt]);let gt=st.filter(e=>et(e)===`start`),_t=st.filter(e=>et(e)===`center`),vt=st.filter(e=>et(e)===`end`),yt=$e.filter(e=>tt.has(e.id)&&e.entry).map(e=>e.entry),bt=new Map;[...i??[],...a??[]].forEach((e,t)=>{bt.has(e.id)||bt.set(e.id,t)});let xt=sa([...re,...yt],e=>bt.get(e)??999999),St=e=>e.icon&&!/[a-z]/i.test(e.icon)?e.icon:null,Ct=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${Ct?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:rt,role:`toolbar`,"aria-label":T(`viewSwitch`),children:[gt.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),(_t.length>0||vt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),_t.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),_t.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),vt.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id))]}),(xt.length>0||$e.length>0)&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:P,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":D,"aria-label":T(`pluginTopbarMore`),"data-tip":T(`pluginTopbarMore`),onClick:()=>O(e=>!e),children:(0,X.jsx)(Dt,{})}),(0,X.jsxs)(Po,{anchorRef:P,open:D,onClose:()=>O(!1),children:[xt.map(e=>{let t=e.source===`host`&&Xe.has(e.id)?Je[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(g.Fragment,{children:t},e.id);if(e.source===`host`&&e.id===`host:github`)return(0,X.jsxs)(`a`,{role:`menuitem`,className:`chip github`,href:`https://github.com/xing-shuyin/pi-web-ui`,target:`_blank`,rel:`noreferrer noopener`,title:T(`githubRepo`),onClick:()=>O(!1),children:[(0,X.jsx)(Ie,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=Je[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>O(!1),children:t},e.id)}else{let t=Qe(e);if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>O(!1),children:t},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsxs)(`label`,{className:`plugin-topbar-overflow-select tb-row`,title:e.hint??e.label,children:[St(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:St(e)}):null,(0,X.jsx)(`span`,{className:`tb-row-text`,children:e.label}),(0,X.jsx)(`select`,{"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>{O(!1),V(e)||s?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})]},e.id):(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`tb-row`,title:e.hint??e.label,onClick:()=>{O(!1),V(e)||s?.(e)},children:[St(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:St(e)}):null,(0,X.jsx)(`span`,{className:`tb-row-text`,children:e.label})]},e.id)}),(0,X.jsx)(`div`,{className:`tb-menu-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`tb-row`,onClick:()=>{O(!1),S()},children:[(0,X.jsx)(Ke,{}),(0,X.jsx)(`span`,{className:`tb-row-text`,children:T(`uiIconEdit`)})]})]})]}),ot.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),ye&&(0,X.jsx)(mo,{onClose:()=>be(!1)}),j&&(0,X.jsx)(po,{anchorRect:j.rect,anchorEl:j.el,plugins:r,pinnedIds:I,orderedPluginIds:ie,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:Li(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:Ri(e.settings?.uiLayout,t)}),onOpenView:e=>{ee(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>ee(null)}),k&&(0,X.jsx)(so,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:te,onClose:()=>A(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Lo(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(r&&typeof r==`object`&&!Array.isArray(r))for(let e of Object.keys(t)){let t=r[e];typeof t==`number`&&Number.isFinite(t)&&t>0&&(n[e]=t)}}catch{}return n}function Ro(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function zo(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=e=>e.parentId?r.get(e.parentId)?.cwd??e.cwd:e.cwd,a=e.find(e=>e.id===n),o=a?i(a):t,s=new Map;for(let t of e){let e=i(t),n=s.get(e)??[];n.push(t),s.set(e,n)}let c=[...s.entries()].map(([e,t])=>({cwd:e,isCurrent:e===o,convs:t}));return c.sort((e,t)=>e.isCurrent?-1:t.isCurrent?1:e.cwd<t.cwd?-1:+(e.cwd>t.cwd)),c}function Bo(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.isStreaming),m=t.some(e=>!!e.error),h=t.some(e=>!!e.hasQuestion),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasStreaming:p,hasError:m,hasQuestion:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}function Vo(e){if(!e)return null;let t=e.startsWith(`#`)?e.slice(1):e;if(!t.trim())return null;let n=new URLSearchParams(t),r=n.get(`s`)?.trim()??``;if(!r)return null;let i=n.get(`m`)?.trim()||void 0;return i?{sessionId:r,messageId:i}:{sessionId:r}}function Ho(e){let t=e?.sessionId?.trim()??``;if(!t)return``;let n=e?.messageId?.trim()??``,r=`#s=${encodeURIComponent(t)}`;return n?`${r}&m=${encodeURIComponent(n)}`:r}function Uo(e,t){let n=Ho(t);try{let t=new URL(e);return t.searchParams.delete(`token`),t.hash=n,t.toString()}catch{return`${e.split(`#`)[0]??e}${n}`}}function Wo(e){if(!e)return null;let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);if(!t)return null;let n=t.split(`/`),r=n[n.length-1]??``;if(!r)return null;if(r===`session.jsonl`)return(n[n.length-2]?.trim()??``)||null;let i=r.endsWith(`.jsonl`)?r.slice(0,-6):r;if(!i)return null;let a=i.lastIndexOf(`_`);return(a>=0?i.slice(a+1).trim():i.trim())||null}function Go(e,t){let n=t?.trim()??``;if(!n||e.length===0)return null;let r=e.find(e=>e.id===n);if(r)return r.id;let i=/^([a-z]+-\d+)-\d+$/.exec(n);if(i){let t=`${i[1]}-`,n=e.find(e=>e.id.startsWith(t));if(n)return n.id}return null}function Ko(e,t){let n=t.assistantMessageEvent,r=e.stats.tokens,i=t.usage===null?r:{...r,...t.usage},a=i===r?e.stats:{...e.stats,tokens:i};if(n.type!==`text_delta`&&n.type!==`thinking_delta`)return a===e.stats?e:{...e,stats:a};let o=n.delta??``;if(!o)return a===e.stats?e:{...e,stats:a};let s=e.streamingMessage??null,c=s&&s.id===t.messageId?s:{id:t.messageId,content:[]},l=[...c.content],u=n.type===`thinking_delta`?`thinking`:`text`,d=n.contentIndex??l.length-1;return d>=0&&d<l.length&&l[d].type===u?l[d]=u===`thinking`?{type:`thinking`,thinking:(l[d].thinking??``)+o}:{type:`text`,text:(l[d].text??``)+o}:l.push(u===`thinking`?{type:`thinking`,thinking:o}:{type:`text`,text:o}),{...e,stats:a,streamingMessage:{...c,id:t.messageId,content:l}}}function qo(e){let{current:t,source:n,snapshot:r,answered:i,activeConversationId:a}=e;return r&&r.id&&!i.has(r.id)?t?.id===r.id?{changed:!1,question:t,source:n}:{changed:!0,question:r,source:`snapshot`}:t&&t.conversationId&&a&&t.conversationId!==a||!r&&t&&n===`snapshot`?{changed:!0,question:null,source:`live`}:{changed:!1,question:t,source:n}}var Jo=new Set;function Yo(e){return Jo.add(e),()=>{Jo.delete(e)}}function Xo(e,t){for(let n of Jo)try{n(e,t)}catch(e){console.error(`[tui-overlay-bridge] listener error:`,e)}}function Zo(e){let t=typeof e.name==`string`?e.name:``;if(e.unsupported===!0)return{name:t,status:`unsupported`};if(e.found!==!0)return{name:t,status:`missing`};let n={name:t,status:`ready`};return e.label&&(n.label=e.label),e.description&&(n.description=e.description),e.promptSnippet&&(n.promptSnippet=e.promptSnippet),Array.isArray(e.promptGuidelines)&&e.promptGuidelines.length>0&&(n.promptGuidelines=e.promptGuidelines),e.parameters!==void 0&&(n.parameters=e.parameters),e.parametersDropped===!0&&(n.parametersDropped=!0),(e.active===!0||e.active===!1)&&(n.active=e.active),e.source&&(n.source=e.source),e.scope&&(n.scope=e.scope),n}var Qo=null,$o=new Set;function es(){for(let e of $o)e()}function ts(e){let t=(e??``).trim();t&&(Qo={name:t,status:`loading`},es(),$({type:`get_tool_info`,name:t}))}function ns(){Qo!==null&&(Qo=null,es())}function rs(e){Qo!==null&&Qo.name===e.name&&(Qo=Zo(e),es())}function is(e){return $o.add(e),()=>{$o.delete(e)}}function as(){return Qo}function os(){return(0,g.useSyncExternalStore)(is,as,as)}function ss(e){let t=typeof e.name==`string`?e.name:``;if(e.unsupported===!0)return{name:t,status:`unsupported`};if(e.found!==!0)return{name:t,status:`missing`};let n={name:t,status:`ready`};return e.defaultDescription&&(n.defaultDescription=e.defaultDescription),e.defaultPromptSnippet&&(n.defaultPromptSnippet=e.defaultPromptSnippet),Array.isArray(e.defaultPromptGuidelines)&&e.defaultPromptGuidelines.length>0&&(n.defaultPromptGuidelines=e.defaultPromptGuidelines),e.override&&(n.override=e.override),n}var cs={},ls=new Set;function us(){for(let e of ls)e()}function ds(e){let t=(e??``).trim();t&&(cs[t]&&cs[t].status!==`loading`||(cs={...cs,[t]:{name:t,status:`loading`}},us(),$({type:`get_tool_prompt`,name:t})))}function fs(e){let t=typeof e.name==`string`?e.name:``;t&&cs[t]&&(cs={...cs,[t]:ss(e)},us())}function ps(e){if(!cs[e])return;let t={...cs};delete t[e],cs=t,us()}function ms(e){return ls.add(e),()=>ls.delete(e)}function hs(e){return(0,g.useSyncExternalStore)(ms,()=>e?cs[e]??null:null)}var gs=Object.freeze({status:`idle`,messages:[]}),_s=new Map,vs=new Set,ys=16;function bs(){for(;_s.size>ys;){let e=_s.keys().next().value;if(e===void 0)break;_s.delete(e)}}function xs(){for(let e of vs)e()}function Ss(e,t){let n=(e??``).trim();if(!n)return;let r=_s.get(n);(!r||r.status!==`loading`&&r.status!==`ready`)&&(_s.set(n,{status:`loading`,messages:r?.messages??[]}),bs(),xs(),$({type:`get_compacted_messages`,compactionMessageId:n,conversationId:t}))}function Cs(e){let t=e.compactionMessageId;t&&(e.error?_s.set(t,{status:`error`,messages:[],error:e.error}):_s.set(t,{status:`ready`,messages:e.messages??[]}),bs(),xs())}function ws(e){let t=_s.get(e);return t?(_s.delete(e),_s.set(e,t),t):gs}function Ts(e){return vs.add(e),()=>{vs.delete(e)}}function Es(e){return(0,g.useSyncExternalStore)(Ts,()=>ws(e),()=>gs)}var Ds=`__piWebUiHost`,Os=e=>new Promise(t=>setTimeout(t,e));async function ks(e=3e3){let t=Date.now()+e;for(;;){let e=window.__piBridge;if(e&&typeof e.call==`function`)return e;if(Date.now()>=t)return null;await Os(100)}}var As=Promise.resolve(),js=0;function Ms(e){let t=Math.max(1,Number(e.pollMs??100)),n=Math.max(t,Number(e.timeoutMs??8e3)),r=async e=>{let r=Date.now()+n;for(;;){if(e())return!0;if(Date.now()>=r)return e();await Os(t)}},i=()=>{try{let t=e.listModels?.()??[];return Array.isArray(t)?[...t]:[]}catch{return[]}},a=e=>{if(!e)return!0;try{return i().some(t=>t&&t.id===e)}catch{return!1}},o=async t=>{t&&(e.send({type:`set_model`,modelId:t}),typeof e.getCurrentModelId==`function`&&await r(()=>e.getCurrentModelId?.()===t))},s=async(t,n)=>{let i=String(n.cwd??``).trim();if(i&&e.getCwd()!==i&&(e.send({type:`set_cwd`,path:i}),await r(()=>e.getCwd()===i)),n.newChat!==!1){let t=e.getConversationId();e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank())}let a=String(n.model??``).trim();a&&await o(a),e.send({type:`prompt`,text:t})};return{version:11,setView(t){let n=String(t??``).trim();n&&e.setView(n)},startChat(t){let n=String(t?.prompt??``).trim();if(!n||!e.isReady())return!1;let r=String(t?.model??``).trim();if(r&&!a(r))return!1;let i=()=>s(n,t??{prompt:n}),o;return o=js>0?As.then(i):i(),js++,As=o.then(()=>{js--},()=>{js--}),o.catch(()=>{}),!0},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>cc(e)},compose(e){return cr()?lr({text:typeof e?.text==`string`?e.text:void 0,attachments:Array.isArray(e?.attachments)?e.attachments:void 0}):!1},openModal(t){let n=String(t??``).trim();if(!n||typeof e.openModal!=`function`)return!1;try{return e.openModal(n)}catch{return!1}},closeModal(){if(typeof e.closeModal!=`function`)return!0;try{e.closeModal()}catch{}return!0},async openSession(t){let n=Ls,i=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],c=String(t?.cwd??``).trim(),l=[...new Set([...i,...s])],u=c||l[0]||``;if(!u)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let d=l.filter(e=>e!==u).slice(0,7),f=new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]);for(let t of[u,...d])if(!f.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t,n)}if(e.getCwd()!==u&&(e.send({type:`set_cwd`,path:u}),!await r(()=>e.getCwd()===u)))return{ok:!1,error:`切换工作目录失败或超时:${u}`};(d.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:d});let p=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=p;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),p=e.getConversationId()??void 0}let m=String(t?.model??``).trim();if(m){if(!a(m))return{ok:!1,error:`未知模型:${m}(先调 models.list() 取可用列表)`};await o(m),p=e.getConversationId()??p}let h=String(t?.prompt??``).trim();return h&&e.send({type:`prompt`,text:h}),{ok:!0,...p?{sessionId:p}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=Ls,i=String(t??``).trim();if(!i)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let a=e.listSessions().find(e=>e.id===i);if(!a)return{ok:!1,error:`找不到会话:${i}`};if(a.cwd&&a.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]).has(a.cwd)){if(!(e.confirm&&await e.confirm({path:a.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${a.cwd}`};e.grantPath?.(a.cwd,n)}if(e.send({type:`set_cwd`,path:a.cwd}),!await r(()=>e.getCwd()===a.cwd))return{ok:!1,error:`切换工作目录失败或超时:${a.cwd}`}}let o=e.getConversationId();return a.kind===`running`?e.send({type:`switch_conversation`,id:a.id}):e.send({type:`switch_session`,path:a.id}),await r(()=>e.getConversationId()!==o)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${a.title}`}}},async reloadCatalog(t,n){let r=String(t??``).trim();if(!r)return{ok:!1,error:`reloadCatalog 需要一个目录来源(http(s) URL 或本地文件路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=jt();return new Promise(t=>{let a=setTimeout(()=>{gc.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));gc.set(i,e=>{clearTimeout(a),t(e)}),e.send({type:`plugin_catalog_sync`,requestId:i,source:r,...n?.install?{install:!0}:{},...n?.replace?{replace:!0}:{}})})},onUiAction(e,t){return zs(Fs,String(e??``).trim(),t)},onTopbarAction(e,t){return zs(Fs,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(Rn())return{ok:!1,error:`桌面版(Electron 外壳)不支持 browser_page:窗口里没有 Chrome 扩展运行时。请让用户改用系统浏览器打开同一个 pi-web-ui 地址(网页版)再试。/ The desktop app cannot run browser_page (no Chrome extension runtime); ask the user to open the same pi-web-ui address in a regular browser instead.`};let r=await ks(e.bridgeWaitMs??3e3);if(!r)return{ok:!1,error:`浏览器扩展的页面桥没就绪:确认已安装并启用 page-picker 扩展、本页地址已绑定,然后刷新本页`};try{let e=await r.call({op:n,...t.args===void 0?{}:{args:t.args},...t.target?{to:t.target}:{},...t.timeoutMs?{timeoutMs:t.timeoutMs}:{}});return e===void 0?{ok:!0}:{ok:!0,result:e}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},dom:{anchors(){let e=e=>{try{return document.querySelector(`[data-pi-anchor="${e}"]`)}catch{return null}};return{app:e(`app`),topbar:e(`topbar`),composer:e(`composer`)}}},dialogs:{async select(t){try{let n=e.select;if(typeof n!=`function`)return{ok:!1};let r=Array.isArray(t?.options)?t.options:[],i=await n({title:String(t?.title??``),options:r.filter(e=>typeof e==`object`&&!!e&&typeof e.label==`string`).map(e=>({label:String(e.label),...typeof e.description==`string`?{description:e.description}:{}})),...t?.multi?{multi:!0}:{}});return!i||typeof i!=`object`||i.ok!==!0?{ok:!1,...i&&typeof i==`object`&&typeof i.error==`string`?{error:i.error}:{}}:{ok:!0,selected:Array.isArray(i.selected)?i.selected.filter(e=>typeof e==`string`):[]}}catch{return{ok:!1}}},async confirm(t){let n=String(t?.title??``),r=typeof t?.detail==`string`?t.detail:``;try{if(typeof e.dialogConfirm==`function`)try{return await e.dialogConfirm({title:n,...r?{detail:r}:{}})===!0}catch{}if(typeof window<`u`&&typeof window.confirm==`function`)try{return window.confirm(r?`${n}\n\n${r}`:n)}catch{return!1}return!1}catch{return!1}},async input(t){try{let n=e.input;if(typeof n!=`function`)return{ok:!1};let r=await n({title:String(t?.title??``),...typeof t?.placeholder==`string`?{placeholder:t.placeholder}:{},...typeof t?.initial==`string`?{initial:t.initial}:{}});return!r||typeof r!=`object`||r.ok!==!0?{ok:!1}:typeof r.value==`string`?{ok:!0,value:r.value}:{ok:!0}}catch{return{ok:!1}}}},async notifyAction(t){let n=String(t?.text??``),r=(Array.isArray(t?.actions)?t.actions:[]).filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.label==`string`);try{if(typeof e.notifyAction==`function`){let t=await e.notifyAction({text:n,actions:r});return typeof t==`string`?t:null}}catch{return null}try{typeof window<`u`&&typeof window.dispatchEvent==`function`&&window.dispatchEvent(new CustomEvent(Vs,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>Ys(String(e??``),t)},searchProviders:{register:e=>Zs(e),list:()=>Qs()},composerProviders:{register:e=>ec(e),list:()=>tc()},onTheme:e=>uc(e),onLocale:e=>dc(e),onViewChange:e=>fc(e)}}function Ns(e){try{let t=window;e?t[Ds]=e:delete t[Ds]}catch{}}var Ps=new Map,Fs=null;async function Is(e,t){let n=Fs;Fs=e;try{return await t()}finally{Fs=n}}var Ls=void 0;function Rs(e,t){let n=Ls;Ls=e;try{return t()}finally{Ls=n}}function zs(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=Ps.get(r);i||(i=new Set,Ps.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&Ps.delete(r)}}async function Bs(e,t,n,r){let i=i=>{let a=Ps.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{Rs(e,()=>i(n,r?.value,r?.target))}catch(n){console.error(`[plugin:${e}] 顶栏动作 ${t} 抛错:`,n)}return!0};if(i(`${e}:${t}`)||i(t))return!0;if(r?.loadBundle&&await r.loadBundle(e).catch(()=>!1)){let n=Date.now()+Math.max(100,Number(r.waitMs??1500));for(;;){if(i(`${e}:${t}`)||i(t))return!0;if(Date.now()>=n)break;await new Promise(e=>setTimeout(e,100))}}return!1}var Vs=`pi-web-ui:toast`,Hs=new Map,Us=!1;function Ws(e){let t=e.split(`+`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);if(t.length===0)return null;let n=!1,r=!1,i=!1,a=!1;for(let e of t.slice(0,-1))if(e===`ctrl`||e===`control`)n=!0;else if(e===`shift`)r=!0;else if(e===`alt`||e===`option`)i=!0;else if(e===`meta`||e===`cmd`||e===`command`||e===`win`||e===`super`)a=!0;else return null;let o=t[t.length-1]??``;return!o||[`ctrl`,`control`,`shift`,`alt`,`option`,`meta`,`cmd`,`command`,`win`,`super`].includes(o)?null:{combo:`${n?`ctrl+`:``}${r?`shift+`:``}${i?`alt+`:``}${a?`meta+`:``}${o}`,key:o,ctrl:n,shift:r,alt:i,meta:a}}function Gs(){try{if(typeof document>`u`)return!1;let e=document.activeElement;if(!e)return!1;let t=(e.tagName||``).toUpperCase();return!!(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)}catch{return!1}}function Ks(e){try{if(Gs())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=Hs.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function qs(){if(!Us)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,Ks),Us=!0}catch{}}function Js(){if(!(Hs.size>0||!Us))try{window.removeEventListener(`keydown`,Ks)}catch{}finally{Us=!1}}function Ys(e,t){if(typeof t!=`function`)return()=>{};let n=Ws(e);if(!n)return()=>{};let r=Hs.get(n.combo);r||(r=new Set,Hs.set(n.combo,r));let i=r;return i.add(t),qs(),()=>{i.delete(t),i.size===0&&Hs.delete(n.combo),Js()}}var Xs=new Map;function Zs(e){let t=String(e?.id??``).trim();if(!t||typeof e?.search!=`function`)return()=>{};let n={id:t,label:String(e.label??t),search:e.search};return Xs.set(t,n),()=>{Xs.get(t)===n&&Xs.delete(t)}}function Qs(){return[...Xs.values()].map(e=>({id:e.id,label:e.label}))}var $s=new Map;function ec(e){let t=String(e?.id??``).trim();if(!t||typeof e?.search!=`function`)return()=>{};let n={id:t,label:String(e.label??t),search:e.search};return $s.set(t,n),()=>{$s.get(t)===n&&$s.delete(t)}}function tc(){return[...$s.values()].map(e=>({id:e.id,label:e.label}))}function nc(e){return $s.get(String(e??``))}function rc(e){return Xs.get(String(e??``))}var ic=new Set,ac=new Set,oc=new Set,sc=new Set;function cc(e){return sc.add(e),()=>{sc.delete(e)}}function lc(e){for(let t of sc)try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function uc(e){return typeof e==`function`?(ic.add(e),()=>{ic.delete(e)}):()=>{}}function dc(e){return typeof e==`function`?(ac.add(e),()=>{ac.delete(e)}):()=>{}}function fc(e){return typeof e==`function`?(oc.add(e),()=>{oc.delete(e)}):()=>{}}function pc(e){let t=String(e??``);for(let e of ic)try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function mc(e){let t=String(e??``);for(let e of ac)try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function hc(e){let t=String(e??``);for(let e of oc)try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var gc=new Map;function _c(e){let t=gc.get(e.requestId);if(t){if(gc.delete(e.requestId),!e.ok){t({ok:!1,error:e.error??`目录同步失败`});return}t({ok:!0,...e.entries?{entries:e.entries}:{},...e.installed?{installed:e.installed}:{}})}}var vc=`modulepreload`,yc=function(e){return`/`+e},bc={},xc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=yc(t,n),t=s(t),t in bc)return;bc[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:vc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Sc=`pi-web-ui:plugin-data`;function Cc(e,t){window.dispatchEvent(new CustomEvent(Sc,{detail:{pluginId:e,payload:t}}))}function wc(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(Sc,t),()=>window.removeEventListener(Sc,t)}var Tc=new Map,Ec=new Set,Dc=new Set,Oc=new Set,kc=new Set,Ac=-1;function jc(){return[...Tc.values()]}function Mc(){let e=jc();for(let t of Dc)t(e)}function Nc(){let e=[...Oc];for(let t of kc)t(e)}function Pc(e){return kc.add(e),e([...Oc]),()=>kc.delete(e)}async function Fc(e,t){Oc.delete(e.id),Lc.set(e.id,(Lc.get(e.id)??0)+1),Nc();let n=await Hc(e,t);return Mc(),n}function Ic(e){return Dc.add(e),e(jc()),()=>Dc.delete(e)}var Lc=new Map;function Rc(e,t){let n=Lc.get(e)??0;return fn(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function zc(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>Is(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var Bc=zc(e=>xc(()=>import(e),[]));async function Vc(e,t){if(!e.hasClient||e.error)return null;try{return(await Bc(e.id,Rc(e.id,t))).default??null}catch(t){return console.error(`[plugin:${e.id}] 客户端 bundle 加载失败:`,t),null}}async function Hc(e,t){try{let n=(await Bc(e.id,Rc(e.id,t))).default;return n&&typeof n.mount==`function`?(Tc.set(e.id,{info:e,module:n}),!0):e.preload?(Ec.add(e.id),!0):(Oc.add(e.id),Nc(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return Oc.add(e.id),Nc(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function Uc(e,t){if(Tc.has(e.id)||Ec.has(e.id))return!0;if(Oc.has(e.id)||!e.hasClient)return!1;let n=await Hc(e,t);return Mc(),n}async function Wc(e,t){t!==Ac&&(Ac=t,Tc.clear(),Ec.clear(),Oc.clear(),Lc.clear(),Nc());let n=new Set(e.map(e=>e.id));for(let e of[...Tc.keys()])n.has(e)||Tc.delete(e);for(let e of[...Ec])n.has(e)||Ec.delete(e);for(let e of[...Oc])n.has(e)||Oc.delete(e);Nc(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!Tc.has(e.id)&&!Ec.has(e.id)&&!Oc.has(e.id)).map(e=>Hc(e,t))),Mc()}function Gc(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>wc((n,r)=>{n===e&&t(r)})}}var Kc=[`debug`,`info`,`warn`,`error`];function qc(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function Jc(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function Yc(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.__host!==`logs`||!Array.isArray(t.logs)?!1:t.logs.every(e=>!!e&&typeof e==`object`&&typeof e.ts==`number`&&typeof e.text==`string`&&Kc.includes(String(e.level)))}var Xc=new Map,Zc=new Set;function Qc(){for(let e of[...Zc])try{e()}catch{}}function $c(e){return Zc.add(e),()=>Zc.delete(e)}function el(e){return(Xc.get(e)??[]).map(e=>({...e}))}function tl(e,t){return Yc(t)?(Xc.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),Qc(),!0):!1}function nl(e){switch(e){case`error`:return 6500;case`warning`:return 4200;default:return 2400}}var rl=[/^(已在工作目录|正在切换到工作目录|已切换到工作目录)[::]/,/^(Already in directory|Switching to directory|Switched to directory):/i,/该项目最近的对话.*(为你停在了空白新对话|为你停在了新对话)/,/The most recent conversation .* landed on a (blank|new) chat/i,/^分层上下文预算裁剪生效/,/^Tiered context budget pruning/i,/^发现 \d+ 个内置插件有更新可用/,/^\d+ built-in plugin\(s\) have updates available/i,/^已(创建文件|创建文件夹|重命名|删除|移动|复制)[::]/,/^(Created file|Created folder|Renamed|Deleted|Moved|Copied):/i,/^已重命名当前会话为/,/^Renamed current session to/i,/的消息正在投递,已为你保留该对话$/,/is still sending your message — kept in the running list$/i,/^(计划模式已开启|计划模式已关闭|已进入计划模式|已退出计划模式|审查者模式已开启|审查者模式已关闭)/,/^(Plan mode (enabled|disabled)|Entered plan mode|Exited plan mode|Delegate mode (enabled|disabled))/i,/^已切换(智能体预设|权限预设)/,/^Switched (agent|permission) preset/i];function il(e){if(e.level!==`info`)return!1;let t=(e.text??``).trim(),n=(e.textEn??``).trim();return rl.some(e=>t&&e.test(t)||n&&e.test(n))}function al(e,t,n=2){if(il(t))return e;let r=`${t.level}:${(t.text??``).trim()}`,i=[...e.filter(e=>`${e.level}:${(e.text??``).trim()}`!==r),t];for(;i.length>n;){let e=i.findIndex(e=>e.level!==`error`);e>=0?i.splice(e,1):i.shift()}return i}function ol(){return{flows:[],results:{}}}function sl(e,t){let n=e.findIndex(e=>e.flowId===t.flowId);return n<0?[...e,t]:e.map((e,r)=>r===n?t:e)}function cl(e,t){switch(t.type){case`provider_oauth_started`:{let n={...e.results};return delete n[t.provider],{flows:[...e.flows.filter(e=>e.provider!==t.provider),{flowId:t.flowId,provider:t.provider}],results:n}}case`provider_oauth_flows`:return{...e,flows:t.flows.map(e=>({...e}))};case`provider_oauth_prompt`:{let n=e.flows.find(e=>e.flowId===t.flowId);return{...e,flows:sl(e.flows,{...n,flowId:t.flowId,provider:t.provider,promptId:t.promptId,prompt:t.prompt})}}case`provider_oauth_event`:{let n=e.flows.find(e=>e.flowId===t.flowId);return{...e,flows:sl(e.flows,{...n,flowId:t.flowId,provider:t.provider,event:t.event,promptId:void 0,prompt:void 0})}}case`provider_oauth_result`:return{flows:e.flows.filter(e=>e.flowId!==t.flowId),results:{...e.results,[t.provider]:{ok:t.ok,...t.cancelled===void 0?{}:{cancelled:t.cancelled},...t.error===void 0?{}:{error:t.error}}}};case`provider_oauth_logout_result`:return{...e,results:{...e.results,[t.provider]:{ok:t.ok,...t.error===void 0?{}:{error:t.error}}}}}}var ll=`pi-web-ui:lang`;function ul(){try{return(localStorage.getItem(ll)??``).trim()}catch{return``}}var dl=`pi-web-ui:locale`,fl=2e5,pl=2e5,ml=`LIVE_OMIT`,hl={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 gl(){let e=new Map,t=new Map,n=(e,t)=>`${e}:${t}`;return{write(r,i,a){let o=n(r,i),s=e.get(o);if(s&&s.size>0){for(let e of s)try{e.write(a)}catch{}return}let c=t.get(o)??``,l=c.length+a.length>pl?a:c+a;t.set(o,l)},register(r,i,a){let o=n(r,i),s=e.get(o);s||(s=new Set,e.set(o,s)),s.add(a);let c=t.get(o);if(c){try{a.write(c)}catch{}t.delete(o)}return()=>{let n=e.get(o);n&&(n.delete(a),n.size===0&&e.delete(o)),t.delete(o)}},clear(){e.clear(),t.clear()}}}function _l(e,t){let n=new Set;for(let e of t.messages)e.role===`toolResult`&&e.toolCallId&&n.add(e.toolCallId),e.role===`bashExecution`&&n.add(`bash-${e.id}`);let r=!1;for(let t of e.keys())n.has(t)&&(e.delete(t),r=!0);return r?new Map(e):e}function vl(e,t){if(e.size===0)return e;let n=new Set;for(let e of t.messages)e.role===`toolResult`&&e.toolCallId&&n.add(e.toolCallId);let r=!1;for(let t of e.keys())n.has(t)&&(e.delete(t),r=!0);return r?new Map(e):e}function yl(e,t){switch(t.type){case`status`:return{...e,status:t.status,ready:t.status===`open`&&e.ready,terminals:t.status===`closed`?[]:e.terminals,hostMetrics:t.status===`closed`?null:e.hostMetrics};case`sync_cached_sessions`:return{...e,sessions:t.sessions};case`host_metrics`:return{...e,hostMetrics:t.metrics};case`ready`:return{...e,serverVersion:t.serverVersion,engine:t.engine,appVersion:t.appVersion,managed:t.managed===!0,tabs:t.tabs,ready:!0,protocolMismatch:t.protocolVersion!==void 0&&t.protocolVersion!==29};case`snapshot`:{let n=e.state?.cwd,r=e.state?.conversationId,i=t.state.cwd,a=e.sessions;i&&i!==n&&(a=Nl(i));let o=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),s=e.transition;return s&&(s.phase===`done`||s.phase===`error`||s.kind===`cwd`&&o(t.state.cwd)===o(s.target)||s.kind===`session`&&o(t.state.sessionFile)===o(s.target)||s.kind===`conversation`&&t.state.conversationId===s.target||s.kind===`new_chat`&&(!r||t.state.conversationId!==r||t.state.messages.length===0))&&(s=null),{...e,ready:!0,state:t.state,transition:s,sessions:a,approval:t.state.pendingApproval??null,activeConversationId:t.state.conversationId,liveOutputs:_l(e.liveOutputs,t.state),toolStatuses:vl(e.toolStatuses,t.state)}}case`snapshot_delta`:{let n=e.state,r=t.msg;if(!n||n.conversationId!==r.conversationId||n.rev!==r.baseRev)return e;let i={...n,...r.state,messages:r.appended.length>0?[...n.messages,...r.appended]:n.messages};return{...e,ready:!0,state:i,approval:i.pendingApproval===void 0?e.approval:i.pendingApproval??null,activeConversationId:i.conversationId,liveOutputs:_l(e.liveOutputs,i),toolStatuses:vl(e.toolStatuses,i)}}case`tool_approval`:return{...e,approval:t.approval};case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>fl?`…[${ml}:${n.length-fl}]…\n`+n.slice(n.length-fl):n,i=new Map(e.liveOutputs);return i.set(t.toolCallId,{toolName:t.toolName,text:r}),{...e,liveOutputs:i}}case`message_delta`:{let n=e.state;return!n||n.conversationId!==t.msg.conversationId?e:{...e,state:Ko(n,t.msg)}}case`tool_status`:return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case`notice`:{let n=al(e.notices,t.notice);return n===e.notices?e:{...e,notices:n}}case`dismiss_notice`:return{...e,notices:e.notices.filter(e=>e.id!==t.id)};case`sessions`:return Pl(e.state?.cwd,t.sessions),{...e,sessions:t.sessions};case`conversations`:return{...e,conversations:t.conversations,elsewhere:t.elsewhere??[],activeConversationId:t.activeId};case`projects`:return kl(t.projects),{...e,projects:t.projects};case`sandbox_diff`:return{...e,sandboxDiff:t.diff};case`files`:return{...e,files:t.files};case`file_changed`:return{...e,fileChanged:{path:t.path}};case`file_content`:return{...e,fileContent:t.content};case`models`:return{...e,models:t.models,modelsLoading:t.loading};case`models_config`:return{...e,modelsConfig:t.providers};case`providers_status`:return{...e,providers:t.providers};case`provider_keys`:return{...e,providerKeys:t.keys};case`default_model`:return{...e,defaultModel:t.modelId};case`provider_oauth`:{let n=cl({flows:e.providerOAuthFlows,results:e.providerOAuthResults},t.message);return{...e,providerOAuthFlows:n.flows,providerOAuthResults:n.results}}case`fetch_models_result`:return{...e,fetchModelsResult:t.result};case`test_model_connection_result`:return{...e,testModelConnectionResult:t.result};case`enrich_models_progress`:return{...e,enrichModelsProgress:t.progress};case`enrich_models_result`:return{...e,enrichModelsResult:t.result,enrichModelsProgress:null};case`refresh_provider_result`:return{...e,refreshProviderResult:t.result};case`refresh_builtin_result`:return{...e,refreshBuiltinResult:t.result};case`append_builtin_result`:return{...e,appendBuiltinResult:t.result};case`clone_provider_result`:return{...e,cloneProviderResult:t.result};case`install_result`:return{...e,installResult:t.result};case`scm_data`:return{...e,scmData:t.data};case`file_search_result`:return{...e,fileSearch:t.result};case`session_search_result`:return{...e,sessionSearch:t.result};case`scm_changed`:return{...e,scmDirty:e.scmDirty+1};case`path_completions`:return{...e,pathCompletions:t.completions};case`update_status`:return{...e,update:t.status};case`update_status_all`:return{...e,updatesAll:t.items,updatesSdk:t.piSdk??null};case`updates_check_started`:return{...e,updatesAll:null};case`widgets`:return{...e,widgets:t.widgets};case`statuses`:return{...e,statuses:t.statuses};case`dialog`:return{...e,dialog:t.dialog};case`tui_overlay`:return{...e,tuiOverlay:t.overlay};case`question`:return{...e,question:t.question};case`remote_question`:return{...e,remoteQuestion:t.question};case`commands`:return{...e,commands:t.commands,commandsPath:t.path};case`slash_commands`:return{...e,slashCommands:t.commands};case`goal_status`:return{...e,goal:t.status};case`plan_updated`:{let n=e.state;if(!n)return e;let r=e.activeConversationId||n.conversationId;if(!t.conversationId||t.conversationId!==r)return e;let i={...n,plan:t.plan};return{...e,state:i}}case`settings`:return{...e,settings:t.settings};case`mcp_servers`:return e.settings?{...e,settings:{...e.settings,mcpServers:t.servers,mcpGlobalConfigPath:t.globalConfigPath??e.settings.mcpGlobalConfigPath,mcpProjectConfigPath:t.projectConfigPath??e.settings.mcpProjectConfigPath}}:e;case`mcp_market_result`:return{...e,mcpMarketResult:t.result};case`skill_market_result`:return{...e,skillMarketResult:t.result};case`skill_content_result`:return{...e,skillContentResult:t.result};case`bg_servers`:return{...e,bgServers:t.servers};case`scheduler_tasks`:return{...e,schedulerTasks:t.tasks};case`plugin_panel_items`:return{...e,pluginPanelGroups:t.groups};case`plugins`:return{...e,plugins:t.plugins,pluginsEpoch:t.epoch};case`plugin_updates_check_started`:return{...e,checkingPluginUpdates:!0};case`plugin_updates`:{let n={};for(let e of t.updates)n[e.id]=e;return{...e,pluginUpdates:n,checkingPluginUpdates:!1}}case`plugin_catalog`:return{...e,pluginCatalog:t.entries,pluginCatalogEpoch:t.epoch};case`plugin_grants`:return{...e,pluginGrants:t.grants};case`plugin_permissions`:return{...e,pluginPermissions:t.grants};case`plugin_path_request`:return{...e,pathRequests:[...e.pathRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_path_resolved`:return{...e,pathRequests:e.pathRequests.filter(e=>e.id!==t.id)};case`plugin_permission_request`:return{...e,permRequests:[...e.permRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_permission_resolved`:return{...e,permRequests:e.permRequests.filter(e=>e.id!==t.id)};case`plugin_job`:{let{pluginId:n,phase:r,ok:i,action:a}=t.job,o=e.pluginUpdates;a===`update`&&r===`done`&&i&&e.pluginUpdates?.[n]&&(o={...e.pluginUpdates,[n]:{...e.pluginUpdates[n],updatable:!1}});let s=e.pluginJobs[t.job.jobId],c=t.line?[...s?.lines??[],t.line].slice(-40):s?.lines??[],l={...s,...t.job,lines:c,startedAt:s?.startedAt??Date.now()};return{...e,pluginUpdates:o,pluginJobs:{...e.pluginJobs,[t.job.jobId]:l}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};case`preset_export_result`:return{...e,presetExport:{...t.result,receivedAt:Date.now()}};case`preset_import_result`:return{...e,presetImport:{...t.result,source:t.source,receivedAt:Date.now()}};case`preset_catalog_result`:return{...e,presetCatalog:{...t.result,receivedAt:Date.now()}};case`preset_share_result`:return{...e,presetShare:{...t.result,receivedAt:Date.now()}};case`plugin_install_inspect_result`:return{...e,installInspect:t.result};case`dsh_patches`:return{...e,dshPatches:{patchDir:t.patchDir,files:t.files}};case`dsh_presets`:return{...e,dshPresets:{presets:t.presets,defaultPreset:t.defaultPreset}};case`dsh_permission`:return{...e,dshPermission:{options:t.options,defaultPreset:t.defaultPreset}};case`terminal_add`:return{...e,terminals:[...e.terminals,t.meta]};case`terminal_remove`:return{...e,terminals:e.terminals.filter(e=>e.id!==t.id)};case`terminal_exit`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!1,exitCode:t.exitCode}:e)};case`terminal_restart`:return{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!0,exitCode:null}:e)};case`terminal_list`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:t.terminals.map(n=>({...n,conversationId:t.conversationId??e.state?.conversationId??``}))};case`terminal_active`:return{...e,terminalActiveId:t.id};case`transition_start`:{let n=t.kind===`cwd`?Nl(t.target):null;return{...e,...n&&n.length>0?{sessions:n}:{},transition:{kind:t.kind,target:t.target,phase:`start`,progress:t.progress,text:t.text,textEn:t.textEn,startedAt:Date.now()}}}case`transition_progress`:{let n=t.msg;if(n.phase===`done`||n.phase===`error`)return{...e,transition:e.transition?{...e.transition,phase:n.phase,progress:100,text:n.text,textEn:n.textEn}:null};let r=e.transition;return{...e,transition:{kind:n.kind,target:n.target,phase:n.phase,progress:Math.max(r?.target===n.target?r.progress:0,n.progress),text:n.text,textEn:n.textEn,totalMessages:n.totalMessages??r?.totalMessages,previewMessages:n.previewMessages??r?.previewMessages,startedAt:r?.startedAt??Date.now()}}}case`transition_tick`:{let t=e.transition;if(!t||t.phase===`done`||t.phase===`error`)return e;let n=t.phase===`start`?26:t.phase===`fs`?56:92;if(t.progress>=n)return e;let r=Math.max(1,Math.round((n-t.progress)*.16));return{...e,transition:{...t,progress:Math.min(n,t.progress+r)}}}case`transition_clear`:return e.transition?{...e,transition:null}:e;default:return e}}var bl=`pi-web-client-id`,xl=null;function Sl(){if(xl)return xl;let e=null;try{e=sessionStorage.getItem(bl),e||(e=jt(),sessionStorage.setItem(bl,e))}catch{e??=jt()}return xl=e,e}var Cl=`pi-web-last-cwd`;function wl(){try{return localStorage.getItem(Cl)}catch{return null}}function Tl(e){try{localStorage.setItem(Cl,e)}catch{}}function El(e){try{let t=localStorage.getItem(Cl);if(!t)return;let n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase();(t===e||n(t)===n(e))&&localStorage.removeItem(Cl)}catch{}}var Dl=`pi-web-recent-projects`;function Ol(){try{let e=localStorage.getItem(Dl);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function kl(e){try{localStorage.setItem(Dl,JSON.stringify(e.slice(0,20)))}catch{}}function Al(e){try{let t=Ol(),n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),r=n(e);kl(t.filter(e=>n(e.path)!==r))}catch{}}var jl=`pi-web-recent-sessions:`;function Ml(e){return e?`${jl}${e.trim().replace(/[\\/]+$/,``).toLowerCase()}`:`pi-web-recent-sessions:default`}function Nl(e){try{let t=Ml(e??wl()),n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function Pl(e,t){try{let n=Ml(e??wl());localStorage.setItem(n,JSON.stringify(t.slice(0,50)))}catch{}}function Fl(e,t){try{let n=Nl(t),r=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),i=r(e);Pl(t,n.filter(e=>r(e.path)!==i))}catch{}}function Il(){return gn(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${fn(`/ws`)}`)}function Ll(){let[e,t]=(0,g.useReducer)(yl,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:Nl(),conversations:[],elsewhere:[],activeConversationId:``,projects:Ol(),files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:ol().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,updatesSdk:null,widgets:[],statuses:[],dialog:null,tuiOverlay:null,approval:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:hl,bgServers:[],schedulerTasks:[],pluginPanelGroups:[],settings:null,fetchModelsResult:null,testModelConnectionResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginUpdates:null,checkingPluginUpdates:!1,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,presetExport:null,presetImport:null,presetCatalog:null,presetShare:null,installInspect:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,mcpMarketResult:null,skillMarketResult:null,skillContentResult:null,dshPresets:null,dshPermission:null,protocolMismatch:!1,transition:null,sandboxDiff:null}),n=(0,g.useRef)(null),r=(0,g.useRef)(gl()),i=(0,g.useRef)(0),a=(0,g.useRef)(null),o=(0,g.useRef)(!0),s=(0,g.useRef)(0),c=(0,g.useRef)(0),l=(0,g.useRef)(new Map),u=(0,g.useRef)(null),d=(0,g.useRef)(!1),f=(0,g.useRef)(null),p=(0,g.useRef)(new Set),m=(0,g.useRef)(`live`),h=()=>{u.current||=setTimeout(()=>{u.current=null;let e=n.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`get_state`}))},300)},_=(e,t)=>{let n=l.current,r=n.get(e);if(r!==void 0&&t!==r+1){let t=O.current.chat;e===(t.activeConversationId||t.state?.conversationId)&&h()}n.set(e,t)},v=(0,g.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]);(0,g.useEffect)(()=>{if(!e.transition)return;if(e.transition.phase===`done`||e.transition.phase===`error`){let e=setTimeout(()=>t({type:`transition_clear`}),180);return()=>clearTimeout(e)}let n=setInterval(()=>{if(Date.now()-(e.transition?.startedAt??0)>2e4){t({type:`transition_clear`});return}t({type:`transition_tick`})},160);return()=>clearInterval(n)},[e.transition]);let y=(0,g.useCallback)(e=>{let r=O.current.chat.state;if(e.type===`set_cwd`&&e.path){let n=(r?.cwd??``).trim().replace(/[\\/]+$/,``).toLowerCase(),i=e.path.trim().replace(/[\\/]+$/,``).toLowerCase();i&&i!==n&&t({type:`transition_start`,kind:`cwd`,target:e.path,progress:14,text:`正在切换到工作目录:${e.path}`,textEn:`Switching to workspace: ${e.path}`})}else if(e.type===`switch_session`&&e.path){let n=(r?.sessionFile??``).trim().replace(/[\\/]+$/,``).toLowerCase(),i=e.path.trim().replace(/[\\/]+$/,``).toLowerCase();i&&i!==n&&t({type:`transition_start`,kind:`session`,target:e.path,progress:14,text:`正在流式载入历史会话…`,textEn:`Streaming session history…`})}else e.type===`new_chat`?r&&(r.messages.length>0||r.isStreaming)&&t({type:`transition_start`,kind:`new_chat`,target:r.cwd,progress:22,text:`正在初始化新对话…`,textEn:`Initializing new chat…`}):e.type===`switch_conversation`&&e.id&&r&&e.id!==r.conversationId&&t({type:`transition_start`,kind:`conversation`,target:e.id,progress:35,text:`正在切换对话…`,textEn:`Switching conversation…`});let i=n.current;if(i&&i.readyState===WebSocket.OPEN){if(e.type===`check_updates_all`&&e.force===!0&&t({type:`updates_check_started`}),e.type===`check_plugin_updates`&&t({type:`plugin_updates_check_started`}),i.send(JSON.stringify(e)),e.type===`question_answer`){if(e.owner){let n=O.current.chat.remoteQuestion;n&&n.id===e.id&&t({type:`remote_question`,question:null})}else{if(p.current.add(e.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}m.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,g.useCallback)((e,n)=>{let r=qo({current:O.current.chat.question,source:m.current,snapshot:e,answered:p.current,activeConversationId:n});r.changed&&(m.current=r.source,t({type:`question`,question:r.question}))},[]);Ha(y);let x=(0,g.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(Il());n.current=e,e.onopen=()=>{n.current===e&&(t({type:`status`,status:`open`}),i.current=0,s.current=Date.now(),e.send(JSON.stringify({type:`hello`,clientId:Sl(),locale:ul()})))},e.onmessage=i=>{if(n.current!==e)return;s.current=Date.now();let a;try{a=JSON.parse(i.data)}catch{return}switch(a.type){case`ready`:if((O.current.chat.settings?.autoReload??!0)&&a.buildId&&a.buildId!==`20261011T12545`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}Na({engine:a.engine??`pi`,managed:!!a.managed,tabs:a.tabs,appVersion:a.appVersion,serverVersion:a.serverVersion,service:a.service}),t({type:`ready`,serverVersion:a.serverVersion,protocolVersion:a.protocolVersion,engine:a.engine,appVersion:a.appVersion,managed:a.managed,tabs:a.tabs,service:a.service}),p.current.clear(),t({type:`question`,question:null}),e.send(JSON.stringify({type:`get_state`})),e.send(JSON.stringify({type:`list_files`})),e.send(JSON.stringify({type:`list_models`})),e.send(JSON.stringify({type:`list_commands`})),e.send(JSON.stringify({type:`get_commands`})),a.managed||(e.send(JSON.stringify({type:`check_update`})),e.send(JSON.stringify({type:`check_updates_all`})));break;case`snapshot`:l.current=new Map,t({type:`snapshot`,state:a.state}),b(a.state.pendingQuestion,a.state.conversationId);break;case`snapshot_delta`:{let e=O.current.chat.state;if(e)(e.conversationId!==a.conversationId||e.rev!==a.baseRev)&&h();else{let e=n.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`get_state`}))}t({type:`snapshot_delta`,msg:a}),b(a.state.pendingQuestion,a.conversationId);break}case`tool_delta`:_(a.conversationId,a.seq),t({type:`tool_delta`,toolCallId:a.toolCallId,toolName:a.toolName,delta:a.delta});break;case`tool_status`:t({type:`tool_status`,status:a});break;case`message_delta`:_(a.conversationId,a.seq),t({type:`message_delta`,msg:a});break;case`subagent_handoff`:break;case`notice`:{let e=++c.current;(a.level===`error`||a.level===`warning`)&&t({type:`transition_clear`}),t({type:`notice`,notice:{id:e,level:a.level,text:a.text,textEn:a.textEn}});break}case`transition_progress`:t({type:`transition_progress`,msg:a});break;case`sessions`:t({type:`sessions`,sessions:a.sessions});break;case`conversations`:t({type:`conversations`,conversations:a.conversations,activeId:a.activeId,elsewhere:a.elsewhere});break;case`projects`:t({type:`projects`,projects:a.projects});break;case`sandbox_diff`:t({type:`sandbox_diff`,diff:a.diff});break;case`files`:t({type:`files`,files:a});break;case`file_changed`:t({type:`file_changed`,path:a.path});break;case`file_content`:t({type:`file_content`,content:a});break;case`models`:t({type:`models`,models:a.models,loading:!1});break;case`models_config`:t({type:`models_config`,providers:a.providers});break;case`providers_status`:t({type:`providers_status`,providers:a.providers});break;case`provider_keys`:t({type:`provider_keys`,keys:a.keys});break;case`default_model`:t({type:`default_model`,modelId:a.modelId});break;case`provider_oauth_started`:case`provider_oauth_flows`:case`provider_oauth_prompt`:case`provider_oauth_event`:case`provider_oauth_result`:case`provider_oauth_logout_result`:t({type:`provider_oauth`,message:a});break;case`fetch_models_result`:t({type:`fetch_models_result`,result:{reqId:a.reqId,ok:a.ok,models:a.models,error:a.error}});break;case`test_model_connection_result`:t({type:`test_model_connection_result`,result:{reqId:a.reqId,ok:a.ok,latencyMs:a.latencyMs,error:a.error}});break;case`enrich_models_progress`:t({type:`enrich_models_progress`,progress:{reqId:a.reqId,phase:a.phase,current:a.current,total:a.total,message:a.message}});break;case`enrich_models_result`:t({type:`enrich_models_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,error:a.error}});break;case`refresh_provider_result`:t({type:`refresh_provider_result`,result:{reqId:a.reqId,ok:a.ok,added:a.added,total:a.total,error:a.error}});break;case`refresh_builtin_result`:t({type:`refresh_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`append_builtin_result`:t({type:`append_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`clone_provider_result`:t({type:`clone_provider_result`,result:{reqId:a.reqId,ok:a.ok,config:a.config,configs:a.configs,error:a.error}});break;case`scm_data`:t({type:`scm_data`,data:a});break;case`search_files_result`:t({type:`file_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,truncated:a.truncated}});break;case`session_search_results`:t({type:`session_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results}});break;case`scm_changed`:t({type:`scm_changed`});break;case`tool_info`:rs(a);break;case`tool_prompt`:fs(a);break;case`compacted_messages_result`:Cs(a);break;case`heartbeat`:a.hostMetrics&&t({type:`host_metrics`,metrics:a.hostMetrics});break;case`install_result`:t({type:`install_result`,result:a});break;case`path_completions`:t({type:`path_completions`,completions:a.completions});break;case`update_status`:t({type:`update_status`,status:a});break;case`update_status_all`:t({type:`update_status_all`,items:a.items,piSdk:a.piSdk});break;case`widgets`:t({type:`widgets`,widgets:a.widgets});break;case`statuses`:t({type:`statuses`,statuses:a.statuses});break;case`dialog`:t({type:`dialog`,dialog:{id:a.id,kind:a.kind,title:a.title,args:a.args}});break;case`dialog_closed`:t({type:`dialog`,dialog:null});break;case`tui_overlay_open`:t({type:`tui_overlay`,overlay:{id:a.id,title:a.title,cols:a.cols,rows:a.rows,initialAnsi:a.initialAnsi}});break;case`tui_overlay_render`:Xo(a.id,a.ansi);break;case`tui_overlay_close`:t({type:`tui_overlay`,overlay:null});break;case`question_pending`:m.current=`live`,t({type:`question`,question:{id:a.id,...a.deadline===void 0?{}:{deadline:a.deadline},questions:a.questions,...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_pending`:t({type:`tool_approval`,approval:{id:a.id,toolCallId:a.toolCallId,toolName:a.toolName,params:a.params,reason:a.reason,reasonEn:a.reasonEn,...a.category?{category:a.category}:{},...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_resolved`:t({type:`tool_approval`,approval:null});break;case`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(p.current.add(a.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}m.current=`live`,t({type:`question`,question:null})}break}case`elsewhere_question`:t({type:`remote_question`,question:{owner:a.owner,convId:a.convId,id:a.id,questions:a.questions,...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`page_request`:(async()=>{let e=window.__piWebUiHost,t;if(!e?.pageCall)t={ok:!1,error:`宿主页面桥不可用(页面版本过旧?)—— 刷新本页后再试`};else try{t=await e.pageCall({op:a.op,...a.args===void 0?{}:{args:a.args},...a.target?{target:a.target}:{},timeoutMs:a.timeoutMs})}catch(e){t={ok:!1,error:e instanceof Error?e.message:String(e)}}y({type:`page_response`,id:a.id,ok:t.ok===!0,...t.ok===!0?t.result===void 0?{}:{result:t.result}:{error:t.error??`页面操作失败`}})})();break;case`terminal_output`:r.current.write(a.conversationId??O.current.chat.activeConversationId,a.terminalId,a.data);break;case`terminal_exit`:t({type:`terminal_exit`,conversationId:a.conversationId,terminalId:a.terminalId,exitCode:a.exitCode});break;case`terminal_list`:t({type:`terminal_list`,conversationId:a.conversationId,terminals:a.terminals});break;case`commands`:t({type:`commands`,commands:a.commands,path:a.path});break;case`slash_commands`:t({type:`slash_commands`,commands:a.commands});break;case`goal_status`:t({type:`goal_status`,status:a.status});break;case`plan_updated`:t({type:`plan_updated`,conversationId:a.conversationId,plan:a.plan});break;case`settings_state`:t({type:`settings`,settings:a.settings});break;case`mcp_servers`:t({type:`mcp_servers`,servers:a.servers,globalConfigPath:a.globalConfigPath,projectConfigPath:a.projectConfigPath});break;case`mcp_market_result`:t({type:`mcp_market_result`,result:a});break;case`skill_market_result`:t({type:`skill_market_result`,result:a});break;case`skill_content_result`:t({type:`skill_content_result`,result:a});break;case`bg_servers`:t({type:`bg_servers`,servers:a.servers});break;case`scheduler_tasks`:t({type:`scheduler_tasks`,tasks:a.tasks});break;case`plugin_panel_items`:t({type:`plugin_panel_items`,groups:a.groups});break;case`plugins`:t({type:`plugins`,plugins:a.plugins,epoch:a.epoch});break;case`plugin_updates`:t({type:`plugin_updates`,updates:a.updates});break;case`plugin_catalog`:t({type:`plugin_catalog`,entries:a.entries,epoch:a.epoch});break;case`plugin_grants`:t({type:`plugin_grants`,grants:a.grants});break;case`plugin_permissions`:t({type:`plugin_permissions`,grants:a.grants});break;case`plugin_permission_request`:t({type:`plugin_permission_request`,req:{id:a.id,pluginId:a.pluginId,family:a.family,...a.hosts?{hosts:a.hosts}:{},...a.models?{models:a.models}:{},...a.reason?{reason:a.reason}:{}}});break;case`plugin_permission_resolved`:t({type:`plugin_permission_resolved`,id:a.id});break;case`plugin_path_request`:t({type:`plugin_path_request`,req:{id:a.id,pluginId:a.pluginId,path:a.path,...a.reason?{reason:a.reason}:{}}});break;case`plugin_dom_consent_request`:a.from===Sl()&&e.send(JSON.stringify({type:`plugin_dom_consent_response`,id:a.id,ok:!0}));break;case`plugin_job`:t({type:`plugin_job`,job:{jobId:a.jobId,action:a.action,pluginId:a.pluginId,phase:a.phase,...a.ok===void 0?{}:{ok:a.ok},...a.error?{error:a.error}:{},...a.output?{output:a.output}:{}},...a.line?{line:a.line}:{}});break;case`plugin_install_inspect_result`:t({type:`plugin_install_inspect_result`,result:{requestId:String(a.requestId??``),source:String(a.source??``),kind:a.kind,suggestedId:String(a.suggestedId??``),installed:a.installed===!0,...a.problem?{problem:a.problem}:{},...a.detail?{detail:a.detail}:{},...a.manifest?{manifest:a.manifest}:{}}});break;case`plugin_catalog_sync_result`:_c(a),t({type:`plugin_catalog_sync_result`,result:{requestId:String(a.requestId??``),ok:a.ok===!0,...a.error?{error:a.error}:{},...a.entries?{entryCount:a.entries.length}:{},...a.installed?{installed:a.installed}:{}}});break;case`preset_export_result`:t({type:`preset_export_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,...a.name?{name:a.name}:{},...a.fileName?{fileName:a.fileName}:{},...a.json?{json:a.json}:{},...a.error?{error:a.error}:{}}});break;case`preset_import_result`:{let e=String(a.requestId??``),n=e.startsWith(`url:`)?`url`:e.startsWith(`file:`)?`file`:`paste`;t({type:`preset_import_result`,source:n,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,dryRun:a.dryRun===!0,...a.preview?{preview:a.preview}:{},...a.applied?{applied:!0}:{},...a.error?{error:a.error}:{}}});break}case`preset_catalog_result`:t({type:`preset_catalog_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,entries:a.entries??[],source:a.source??``,cached:a.cached===!0,fetchedAt:a.fetchedAt??0,...a.error?{error:a.error}:{}}});break;case`preset_share_result`:t({type:`preset_share_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,...a.method?{method:a.method}:{},...a.url?{url:a.url}:{},...a.name?{name:a.name}:{},...a.json?{json:a.json}:{},...a.error?{error:a.error}:{}}});break;case`dsh_patches`:t({type:`dsh_patches`,patchDir:a.patchDir,files:a.files});break;case`dsh_presets`:t({type:`dsh_presets`,presets:a.presets,defaultPreset:a.defaultPreset});break;case`dsh_permission`:t({type:`dsh_permission`,options:a.options,defaultPreset:a.defaultPreset});break;case`plugin_data`:tl(a.pluginId,a.payload)||Cc(a.pluginId,a.payload);break;case`remote_ssh_probe_result`:case`remote_ssh_list_dir_result`:case`remote_ssh_install_result`:case`remote_ssh_profiles_result`:Ga(a)}},e.onclose=()=>{if(n.current===e&&(n.current=null),r.current.clear(),!o.current||n.current&&n.current!==e)return;t({type:`status`,status:`closed`});let s=Math.min(1e3*2**i.current,1e4);i.current+=1,a.current=setTimeout(()=>{a.current=null,x()},s)},e.onerror=()=>{}},[]);(0,g.useEffect)(()=>{let e=e=>{let t=e.detail??ul();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(dl,e),()=>window.removeEventListener(dl,e)},[y]),(0,g.useEffect)(()=>{let n=n=>{let r=e.state?.cwd;r&&n.key&&n.key===Ml(r)&&t({type:`sync_cached_sessions`,sessions:Nl(r)})};return window.addEventListener(`storage`,n),()=>window.removeEventListener(`storage`,n)},[e.state?.cwd]),(0,g.useEffect)(()=>{o.current=!0,x();let e=setInterval(()=>{if(!o.current)return;let e=n.current;e&&e.readyState===WebSocket.OPEN&&Date.now()-s.current>3e4&&e.close()},5e3),t=()=>{if(!o.current||typeof document<`u`&&document.visibilityState===`hidden`)return;let e=n.current;if(!e||e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING){a.current&&=(clearTimeout(a.current),null),x();return}e.readyState===WebSocket.OPEN&&(Date.now()-s.current>15e3||!O.current.chat.state)&&e.send(JSON.stringify({type:`get_state`}))};return typeof document<`u`&&document.addEventListener(`visibilitychange`,t),typeof window<`u`&&(window.addEventListener(`pageshow`,t),window.addEventListener(`online`,t)),()=>{o.current=!1,clearInterval(e),a.current&&=(clearTimeout(a.current),null),typeof document<`u`&&document.removeEventListener(`visibilitychange`,t),typeof window<`u`&&(window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,t)),n.current?.close(),n.current=null}},[x]),(0,g.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=wl();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}f.current!==t&&(f.current=t,Tl(t))}},[e.state?.cwd,y]),(0,g.useEffect)(()=>{Na({ready:e.ready,status:e.status,cwd:e.state?.cwd??``,workspaceRoots:e.state?.workspaceRoots??[],homeDir:e.state?.homeDir??``,desktopDir:e.state?.desktopDir??``})},[e.ready,e.status,e.state?.cwd,e.state?.workspaceRoots,e.state?.homeDir,e.state?.desktopDir]);let S=(0,g.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,g.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,g.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,g.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,g.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,g.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,g.useRef)({chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}});return O.current={chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}},O.current}function Rl(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`:`${t.getMonth()+1}/${t.getDate()}`}function zl(e){let t=e instanceof HTMLElement?e:null;if(!t)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable}var Bl=`pi-web-ui:lp-collapse-projects`,Vl=`pi-web-ui:lp-collapse-convs`,Hl=`pi-web-ui:lp-collapse-sessions`,Ul=`pi-web-ui:lp-collapse-subagents`;function Wl(){let[e,t]=(0,g.useState)(()=>{try{let e=localStorage.getItem(Ul);if(e)return new Set(JSON.parse(e))}catch{}return new Set});return[e,(0,g.useCallback)(e=>{t(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(Ul,JSON.stringify([...n]))}catch{}return n})},[])]}function Gl(e,t=!1){let[n,r]=(0,g.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,g.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var Kl=`pi-web-ui:lp-collapse-plugin-sections`;function ql(){let[e,t]=(0,g.useState)(()=>{try{let e=localStorage.getItem(Kl),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}});return[e,(0,g.useCallback)(e=>{t(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(Kl,JSON.stringify([...n]))}catch{}return n})},[])]}var Jl=`pi-web-ui:lp-sizes`,Yl={projects:1,convs:1,sessions:1},Xl=32,Zl={running:`pluginRunStatusRunning`,done:`pluginRunStatusDone`,error:`pluginRunStatusError`},Ql=72;function $l(){try{return wi(localStorage.getItem(Jl),Yl)}catch{return{...Yl}}}var eu=(0,g.memo)(function({sessionFile:e,conversations:t,elsewhere:n,sessions:r,projects:i,activeConversationId:a,panelSend:o,active:s,collapsible:c,onToggleCollapse:l,pathCompletions:u,uiContextSession:d,uiLeftSessions:f,uiContextProject:p,uiProjectsActions:m,uiLeftProject:h,uiRunningActions:_,uiHistoryActions:v,uiSections:y,renderPluginSectionBody:b,uiPluginRunning:x,onPluginRunningAction:S,uiLeftRunning:C,uiLeftHistory:w,onUiAction:T,presetNames:E,transition:D,onOpenSandboxModal:O}){let k=Z(),A=e,j=La(`ready`),ee=La(`status`),M=La(`cwd`),te=La(`workspaceRoots`),N=M,[ne,F]=(0,g.useState)(!1),[re,I]=(0,g.useState)(null),[L,ie]=(0,g.useState)(null),[z,B]=(0,g.useState)(null),[V,H]=(0,g.useState)(``),[U,ae]=Gl(Bl,!1),[oe,se]=Gl(Vl,!1),[W,ce]=Gl(Hl,!1),[le,ue]=ql(),[de,fe]=Wl(),[pe,G]=(0,g.useState)(60);(0,g.useEffect)(()=>{G(60)},[N]);let K=(0,g.useMemo)(()=>{if(r.length<=pe)return r;let e=A?r.findIndex(e=>e.path===A):-1,t=e>=pe?e+10:pe;return r.slice(0,t)},[r,pe,A]),he=(0,g.useCallback)((e,t)=>{if(!t)return e.filter(e=>e.isSubagent&&!e.isStreaming&&e.id!==a).length;let n=new Map(e.map(e=>[e.id,e])),r=e=>{if(e.id===t)return(n.get(t)?.isSubagent??!1)&&!e.isStreaming&&e.id!==a;let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&!e.isStreaming&&e.id!==a&&r(e)).length},[a]),ge=(0,g.useCallback)((e,t)=>{if(!t)return e.filter(e=>e.isSubagent).length;let n=new Map(e.map(e=>[e.id,e])),r=e=>{if(e.id===t)return n.get(t)?.isSubagent??!1;let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&r(e)).length},[]),q=(0,g.useCallback)((e,t)=>{if(!t)return 0;let n=new Map(e.map(e=>[e.id,e])),r=e=>{let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&e.isStreaming&&r(e)).length},[]),ve=(0,g.useRef)(null),ye=(0,g.useRef)(null),be=(0,g.useRef)(()=>{}),xe=Ca(d??[]).length>0,Se=(0,g.useCallback)((e,n,i)=>{ve.current={x:e,y:n,target:i};let a=i.kind===`running`?i.id:void 0,o=i.kind===`elsewhere`,s=a??(o&&i.id||void 0),c=he(t,a),l=c===0?k(`noFinishedSubagents`):k(a?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:c}),u=!!a&&ye.current===a;fa({x:e,y:n,slot:`contextmenu.session`,target:i,entries:(d??[]).map(e=>{if(e.source!==`host`)return e;if(e.id===`host:conv-rename`)return i.kind===`running`||i.kind===`history`?e:{...e,hidden:!0};if(e.id===`host:conv-takeover`)return o&&s&&i.owner&&!i.pseudo?e:{...e,hidden:!0};if(o&&(e.id===`host:conv-dismiss-subagents`||e.id===`host:conv-force-dismiss`))return{...e,hidden:!0};if(e.id===`host:conv-dismiss-subagents`)return{...e,label:l,...c===0?{when:[...e.when??[],`disabled`]}:{}};if(e.id===`host:conv-force-dismiss`)return a?{...e,...u?{label:k(`forceDismissConfirm`)}:{}}:{...e,hidden:!0};if(e.id===`host:conv-pin`){if(i.kind===`history`)return r.find(e=>e.path===i.id)?.pinned?{...e,label:k(`unpinConversation`)}:e;if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return!n||n.isSubagent?{...e,hidden:!0}:n.pinned?{...e,label:k(`unpinConversation`)}:e}if(e.id===`host:conv-persist`){if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return!n||!n.isSubagent&&n.sessionFile?{...e,hidden:!0}:n?.isEphemeral?{...e,label:k(`saveEphemeral`)}:e}if(e.id===`host:conv-copy-id`)return s?e:{...e,hidden:!0};if(e.id===`host:conv-copy-path`)return i.kind===`history`?e:a?t.some(e=>e.id===a&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0};if(e.id===`host:conv-copy-link`){if(i.kind===`history`)return r.find(e=>e.path===i.id)?.sessionId||Wo(i.id)?e:{...e,hidden:!0};if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return n?.sessionId||Wo(n?.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}}return e.id===`host:conv-quote`?s||i.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>be.current(e,t)})},[d,t,he,k]);be.current=(0,g.useCallback)((e,n)=>{let i=n.kind===`running`?n.id:void 0,a=i??(n.kind===`elsewhere`&&n.id||void 0);if(e.id===`host:conv-takeover`){n.kind===`elsewhere`&&a&&n.owner&&o({type:`take_over_conversation`,owner:n.owner,id:a});return}if(e.id===`host:conv-dismiss-subagents`){o(i?{type:`dismiss_finished_subagents`,parentId:i}:{type:`dismiss_finished_subagents`});return}if(e.id===`host:conv-force-dismiss`){let e=ve.current;if(!i||!e)return;if(ye.current!==i)return ye.current=i,Se(e.x,e.y,e.target),!0;ye.current=null,o({type:`dismiss_conversation`,id:i,force:!0});return}if(e.id===`host:conv-persist`){i&&o({type:`persist_conversation`,id:i});return}if(e.id===`host:conv-pin`){if(n.kind===`history`){let e=r.find(e=>e.path===n.id);o({type:`pin_session`,path:n.id,pinned:!e?.pinned});return}i&&o({type:`pin_conversation`,id:i,pinned:!t.find(e=>e.id===i)?.pinned});return}if(e.id===`host:conv-copy-id`&&a){navigator.clipboard?.writeText(a).catch(()=>{});return}if(e.id===`host:conv-copy-path`){let e=n.kind===`history`?n.id:i&&t.find(e=>e.id===i)?.sessionFile||void 0;e&&navigator.clipboard?.writeText(e).catch(()=>{});return}if(e.id===`host:conv-copy-link`){let e=n.kind===`history`?r.find(e=>e.path===n.id)?.sessionId||Wo(n.id):i?t.find(e=>e.id===i)?.sessionId||Wo(t.find(e=>e.id===i)?.sessionFile):null;if(e){let t=Uo(window.location.href,{sessionId:e});navigator.clipboard?.writeText(t).catch(()=>{})}return}if(e.id===`host:conv-quote`){n.kind===`history`&&n.id?lr({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&lr({attachments:[{path:``,key:`conv|${a}|`,name:n.label||a,mode:`conversation`,conversationId:a}]});return}if(e.id===`host:conv-rename`){if(I(null),i){let e=t.find(e=>e.id===i);H(e?.title??n.label??``),B(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);H(e?.name??n.label??``),B(n.id)}return}},[o,Se,t,r]);let Ce=(e,t,n)=>!e||e.length===0?null:(0,X.jsx)(`span`,{className:t,children:e.map((e,t)=>{let r=`${e.id}#${t}`,i=e.label||e.id,a=e.hint||i;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`lp-slot-divider`,"aria-hidden":`true`},r):e.kind===`badge`?(0,X.jsx)(`span`,{className:`lp-slot-badge`,title:a,children:e.badge??i},r):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`lp-slot-select`,title:a,"aria-label":i,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onClick:e=>e.stopPropagation(),onChange:t=>{t.stopPropagation(),T?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r):(0,X.jsx)(`button`,{type:`button`,className:`lp-slot-btn`,title:a,"aria-label":i,onClick:t=>{t.stopPropagation(),n?T?.(e,void 0,n):T?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:i})},r)})}),we=(0,g.useCallback)((e,t)=>{zl(e.target)||xe&&(e.preventDefault(),e.stopPropagation(),ye.current=null,Se(e.clientX,e.clientY,t))},[xe,Se]),Te=(0,g.useRef)(null),[De,Oe]=(0,g.useState)(()=>$l());(0,g.useEffect)(()=>{try{localStorage.setItem(Jl,JSON.stringify(De))}catch{}},[De]);let ke=(0,g.useMemo)(()=>{let e=new Set,r=new Set;for(let n of t)n.sessionFile&&e.add(n.sessionFile),r.add(`${n.cwd}\0${n.title}`);let i=[],a=new Set;for(let t of n){if(t.sessionFile&&e.has(t.sessionFile)||r.has(`${t.cwd}\0${t.title}`))continue;let n=t.sessionFile?`file:${t.sessionFile}`:`title:${t.cwd}\0${t.title}`;a.has(n)||(a.add(n),i.push({id:t.sessionFile?`elsewhere:${t.cwd}:${t.sessionFile}`:`elsewhere:${t.cwd}:${t.title}${t.owner?`:${t.owner}`:``}`,title:t.title,cwd:t.cwd,messageCount:0,isStreaming:t.isStreaming,isSubagent:!1,elsewhere:!0,pseudo:!!t.pseudo,ownerOffline:!!t.ownerOffline,sessionFile:t.sessionFile,...t.owner&&t.convId?{owner:t.owner,convId:t.convId}:{},...t.hasQuestion?{hasQuestion:!0}:{}}))}return[...t,...i]},[t,n]),Ae=xi(y),je=Ae.filter(e=>e.shown),Me=e=>e===`projects`?U:e===`convs`?oe:e===`sessions`?W:le.has(e),Ne=(x??[]).reduce((e,t)=>e+t.items.length,0),Pe=ke.length+Ne,Fe=Si(Ae,e=>e===`projects`?i.length>0:e!==`convs`||Pe>0),Ie=()=>{let e=x??[];return e.length===0?null:e.map(e=>(0,X.jsxs)(`div`,{className:`panel-conv-group lp-plugin-group`,children:[(0,X.jsxs)(`div`,{className:`panel-conv-group-title`,title:e.pluginId,children:[k(`leftPanelPluginGroup`),` · `,e.pluginName]}),e.items.map(t=>(0,X.jsx)(`div`,{className:`lp-row lp-plugin-row`,children:(0,X.jsxs)(`button`,{type:`button`,className:`session-item lp-plugin-item${t.action?``:` is-static`}`,title:t.hint?`${t.title} — ${t.hint}`:t.title,onClick:()=>S?.(e,t),children:[(0,X.jsx)(`span`,{className:`lp-plugin-dot st-${t.status}`,title:k(Zl[t.status])}),t.icon?(0,X.jsx)(`span`,{className:`lp-plugin-icon`,"aria-hidden":!0,children:t.icon}):null,(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:t.title}),t.hint?(0,X.jsx)(`span`,{className:`session-sub`,children:t.hint}):null]})]})},t.id))]},`plugin:${e.pluginId}`))},Le=(0,g.useMemo)(()=>[...f??[],...C??[]],[f,C]),Be=(0,g.useMemo)(()=>[...f??[],...w??[]],[f,w]),Ve=(0,g.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,i=n.clientY,a={...De},o=Te.current;if(!o)return;let s=Fe.filter(e=>Me(e)).length,c=Fe.filter(e=>!Me(e)).reduce((e,t)=>e+(a[t]??1),0)||1,l=Math.max(120,o.clientHeight-s*Xl);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let u=n=>{let{above:r,below:o}=Ro({start:{above:a[e]??1,below:a[t]??1},deltaPx:n.clientY-i,availablePx:l,totalWeight:c,minAbovePx:Ql,minBelowPx:Ql});Oe(n=>({...n,[e]:r,[t]:o}))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),r.classList.remove(`dragging`),document.body.classList.remove(`lp-resizing`)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)},[De,Fe,U,oe,W]);(0,g.useEffect)(()=>{s&&j&&ee===`open`&&M&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,j,ee,M,o]);let He=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:k(`emptyChat`)},Ue=e=>e.split(/[\\/]/).pop()||e,We=Ca(p??[]).length>0,Ge=(0,g.useCallback)((e,t)=>{zl(e.target)||We&&(e.preventDefault(),e.stopPropagation(),fa({x:e.clientX,y:e.clientY,slot:`contextmenu.project`,target:{id:t.path,kind:`project`,label:Ue(t.path)},entries:p??[]}))},[We,p]),Y=(e,t,n,r,i)=>{let a=re===e;return(0,X.jsx)(`button`,{type:`button`,className:`lp-del ${a?`confirm`:``}`,title:a?n:t,onClick:t=>{t.stopPropagation(),a?(I(null),r()):I(e)},children:a?(0,X.jsx)(ft,{}):i??(0,X.jsx)(R,{})})},qe=(e,t,n,r,i,a)=>(0,X.jsxs)(`div`,{className:`lp-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`lp-section-title panel-section-title`,onClick:n,title:k(t?`expandSection`:`collapseSection`),children:[(0,X.jsxs)(`span`,{className:`lp-section-title-text`,children:[e,r===void 0?``:` (${r})`]}),(0,X.jsx)(`span`,{className:`lp-section-chevron`,children:t?(0,X.jsx)(dt,{}):(0,X.jsx)(ct,{})})]}),i||a?(0,X.jsxs)(`div`,{className:`lp-section-actions`,children:[i,a]}):null]}),Je=Fe.filter(e=>!Me(e)),Ye=Je.reduce((e,t)=>e+(De[t]??1),0)||1,Xe=e=>Je.length<=1?1:(De[e]??1)/Ye*Je.length,Ze=new Map(Ci(Fe,Me).map(([e,t])=>[e,(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:Ve(e,t),onDoubleClick:()=>Oe({...Yl}),title:k(`dragToResize`)},`sash-${e}`)])),Qe={projects:(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${U||i.length===0?`collapsed`:``}`,style:i.length>0&&!U?{flex:`${Xe(`projects`)} 1 0px`}:void 0,children:[qe(k(`recentProjects`),U,ae,i.length,(0,X.jsxs)(X.Fragment,{children:[O&&(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action lp-sandbox-action`,title:k(`sandboxNewBtn`),"aria-label":k(`sandboxNewBtn`),onClick:()=>O(),children:(0,X.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:`13px`,lineHeight:1},children:`🧪`})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action`,title:k(`manageProjects`),"aria-label":k(`manageProjects`),onClick:()=>F(!0),children:(0,X.jsx)(ze,{})})]}),Ce(m,`lp-slot-section`)),i.length>0&&!U&&(0,X.jsx)(`div`,{className:`lp-section-body projects-scroll`,children:i.map(e=>{let t=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),n=N===e.path,r=D?.kind===`cwd`&&t(D.target)===t(e.path),i=e.sandbox,a=i?i.name:Ue(e.path);return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>I(t=>t===`proj:${e.path}`?null:t),onContextMenu:t=>Ge(t,e),children:[(0,X.jsxs)(`button`,{type:`button`,className:`project-item ${n?`active`:``} ${r?`switching`:``}`,title:i?.sourcePath?`${a}\n${k(`sandboxSourceLabel`)}: ${i.sourcePath}\n${e.path}`:e.path,disabled:r,onClick:()=>{!n&&!r&&o({type:`set_cwd`,path:e.path})},children:[r?(0,X.jsx)(Ee,{className:`project-icon spin`}):i?(0,X.jsx)(`span`,{className:`project-icon sandbox-icon`,"aria-hidden":!0,children:`🧪`}):(0,X.jsx)(Re,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsxs)(`span`,{className:`project-name`,children:[a,i&&(0,X.jsx)(`span`,{className:`lp-sandbox-badge ${i.ephemeral?`ephemeral`:`permanent`}`,children:i.ephemeral?k(`sandboxBadgeEphemeral`):k(`sandboxBadgePermanent`)})]}),(0,X.jsx)(`span`,{className:`project-path`,children:i?.sourcePath?`← ${Ue(i.sourcePath)} · ${e.path}`:e.path})]}),(0,X.jsx)(`span`,{className:`project-time ${r?`switching-pct`:``}`,children:r?`${D.progress}%`:Rl(e.lastUsed)})]}),Y(`proj:${e.path}`,k(i?`sandboxActionDestroyTip`:`deleteProject`),k(i?`sandboxActionDestroy`:`deleteProjectConfirm`),()=>{El(e.path),Al(e.path),o(i?{type:`destroy_sandbox`,path:e.path}:{type:`remove_project`,path:e.path})}),Ce(h,`lp-slot-project`,{id:e.path,kind:`project`,label:a})]},e.path)})})]})}),convs:(0,X.jsx)(X.Fragment,{children:Pe>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${oe?`collapsed`:``}`,style:oe?void 0:{flex:`${Xe(`convs`)} 1 0px`},onContextMenu:e=>we(e,{id:``,kind:`section`,label:k(`runningConversations`)}),children:[qe(k(`runningConversations`),oe,se,Pe,void 0,Ce(_,`lp-slot-section`)),!oe&&(0,X.jsxs)(`div`,{className:`lp-section-body convs-scroll`,children:[zo(ke,M,a).map(e=>(0,X.jsxs)(`div`,{className:`panel-conv-group`,children:[!e.isCurrent&&(0,X.jsx)(`div`,{className:`panel-conv-group-title`,title:e.cwd,onContextMenu:t=>Ge(t,{path:e.cwd,lastUsed:0}),children:Ue(e.cwd)}),Bo(e.convs,de).map(({c:n,depth:r,hasKids:i,isCollapsed:s,descendantCount:c,hasStreaming:l,hasError:u,hasQuestion:d})=>{if(n.elsewhere){let e=n.owner,t=n.convId,r=!!n.pseudo,i=!!n.ownerOffline&&!r,a=!!(e&&t)&&!r,s=L===n.id,c=s?k(`takeoverConfirm`):r?`${k(`elsewherePseudoTip`)}\n${n.cwd}`:`${k(i?`elsewhereOfflineTip`:`elsewhereTip`)}\n${n.cwd}`;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>ie(e=>e===n.id?null:e),onContextMenu:i=>we(i,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item elsewhere-item${a?``:` elsewhere-static`}${s?` confirm`:``}`,title:c,tabIndex:a?0:-1,onClick:a?()=>{if(!s){ie(n.id);return}ie(null),o({type:`take_over_conversation`,owner:e,id:t})}:void 0,children:[(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsxs)(`span`,{className:`session-title`,children:[(0,X.jsx)(`span`,{className:`elsewhere-badge`,children:k(r?`elsewherePseudoBadge`:`elsewhereBadge`)}),i&&(0,X.jsx)(`span`,{className:`elsewhere-badge offline`,title:k(`elsewhereOfflineTip`),children:k(`elsewhereOfflineBadge`)}),n.hasQuestion&&e&&t&&!r&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:k(`takeoverHasQuestion`),onClick:n=>{n.stopPropagation(),o({type:`peek_elsewhere_question`,owner:e,id:t})},children:`?`}),s?k(`takeoverConfirm`):n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:Ue(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:k(`streaming`)})]}),xe&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-elsewhere-act`,title:k(`elsewhereActions`),onClick:i=>{i.stopPropagation(),ye.current=null;let a=i.currentTarget.getBoundingClientRect();Se(a.left,a.bottom+4,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}})},children:(0,X.jsx)(_e,{})})]},n.id)}let f=a===n.id;return(0,X.jsxs)(`div`,{className:`lp-row${r>0?` lp-sub`:``}${i?` lp-has-kids`:``}`,style:r>0?{marginLeft:r*18}:void 0,onMouseLeave:()=>I(e=>e===`conv:${n.id}`?null:e),onContextMenu:e=>we(e,{id:n.id,kind:`running`,label:n.title}),children:[i&&(0,X.jsx)(`button`,{type:`button`,className:`lp-tree-caret${s?` collapsed`:` expanded`}`,title:k(s?`expandSubagents`:`collapseSubagents`),"aria-label":k(s?`expandSubagents`:`collapseSubagents`),onClick:e=>{e.stopPropagation(),fe(n.id)},children:s?(0,X.jsx)(lt,{}):(0,X.jsx)(dt,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${f?`active`:``}`,title:`${n.title}${e.isCurrent?``:` — ${e.cwd}`}`,onClick:()=>{f||o({type:`switch_conversation`,id:n.id})},children:[(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[z===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:V,placeholder:k(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>H(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=V.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),B(null)}else e.key===`Escape`&&B(null)},onBlur:()=>B(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:k(`pinnedConversation`),children:`📌`}),n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:k(`subagentBadge`)}),n.isEphemeral&&(0,X.jsx)(`span`,{className:`ephemeral-badge`,children:k(`ephemeralBadge`)}),n.forkFrom&&(0,X.jsxs)(`span`,{className:`preset-badge fork-badge`,title:`${k(`forkBadgeTip`)}: ${n.forkFrom.title??n.forkFrom.conversationId}`,children:[`🌿 `,k(`forkBadge`)]}),n.agentPreset&&(0,X.jsx)(`span`,{className:`preset-badge`,title:n.agentPreset,children:E?.[n.agentPreset]??n.agentPreset}),n.title,n.error&&(0,X.jsx)(`span`,{className:`conv-error-badge`,title:k(`convErrorBadge`,{error:n.error})}),n.hasQuestion&&(0,X.jsx)(`span`,{className:`question-badge`,title:k(`waitingQuestionBadge`),children:`?`}),i&&s&&(0,X.jsxs)(`span`,{className:`subagents-collapsed-badge${l?` has-streaming`:d?` has-question`:u?` has-error`:``}`,title:k(l?`subagentsStreamingTip`:d?`subagentsQuestionTip`:u?`subagentsErrorTip`:`subagentsCountTip`,{n:c}),onClick:e=>{e.stopPropagation(),fe(n.id)},children:[l&&(0,X.jsx)(`span`,{className:`subagent-dot streaming`}),d&&(0,X.jsx)(`span`,{className:`subagent-dot question`,children:`?`}),u&&(0,X.jsx)(`span`,{className:`subagent-dot error`}),(0,X.jsx)(`span`,{className:`subagents-count-text`,children:k(`subagentBadgeCount`,{n:c})})]})]}),z===`conv:${n.id}`?null:(0,X.jsx)(`span`,{className:`session-sub`,children:f?k(`current`):k(`messageCount`,{n:n.messageCount})})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:k(`streaming`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:k(`renameSession`),onClick:e=>{e.stopPropagation(),I(null),H(n.title),B(`conv:${n.id}`)},children:(0,X.jsx)(Ke,{})}),(()=>{let e=`conv:${n.id}`,r=re===e,i=he(t,n.id),a=q(t,n.id),s=ge(t,n.id);return s===0&&!n.isStreaming?Y(e,k(`dismissConversation`),k(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(P,{})):s===0?Y(e,k(`dismissConversation`),k(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(P,{})):r?(0,X.jsxs)(`span`,{className:`lp-del-group`,children:[i>0&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt`,title:k(`dismissFinishedSubagentsScoped`,{n:i}),onClick:e=>{e.stopPropagation(),I(null),o({type:`dismiss_finished_subagents`,parentId:n.id})},children:k(`dismissFinishedOnly`,{n:i})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt danger`,title:k(`forceDismissTitle`,{n:s,m:a}),onClick:e=>{e.stopPropagation(),I(null),o({type:`dismiss_conversation`,id:n.id,force:!0})},children:k(`dismissForceAll`,{n:s})})]}):(0,X.jsx)(`button`,{type:`button`,className:`lp-del`,title:k(`dismissConversation`),onClick:t=>{t.stopPropagation(),I(e)},children:(0,X.jsx)(P,{})})})(),Ce(Le,`lp-slot-sessions`),n.isStreaming&&(0,X.jsx)(`span`,{className:`lp-row-stalled`,title:k(`streaming`),style:{position:`absolute`,right:28,top:`50%`,transform:`translateY(-50%)`}})]},n.id)})]},e.cwd)),Ie()]})]})}),sessions:(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${W?`collapsed`:``}`,style:W?void 0:{flex:`${Xe(`sessions`)} 1 0px`},children:[qe(k(`historySessions`),W,ce,r.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-new-chat-action`,title:k(`newChatTip`),"aria-label":k(`newChat`),onClick:()=>{o({type:`new_chat`}),sr()},children:(0,X.jsx)(me,{})}),Ce(v,`lp-slot-section`)),!W&&(0,X.jsxs)(`div`,{className:`lp-section-body sessions-scroll`,onScroll:e=>{if(K.length>=r.length)return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<180&&G(e=>Math.min(r.length,e+60))},children:[r.length===0&&(0,X.jsx)(`div`,{className:`panel-empty`,children:k(`noHistory`)}),K.map(e=>{let t=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),n=A===e.path,r=D?.kind===`session`&&t(D.target)===t(e.path);return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>I(t=>t===`sess:${e.path}`?null:t),onContextMenu:t=>we(t,{id:e.path,kind:`history`,label:He(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${n?`active`:``} ${r?`switching`:``}`,title:e.path,disabled:r,onClick:()=>{z||r||n||o({type:`switch_session`,path:e.path})},children:[r?(0,X.jsx)(Ee,{className:`session-icon spin`}):(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[z===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:V,placeholder:k(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>H(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=V.trim();t&&o({type:`rename_session`,path:e.path,name:t}),B(null)}else t.key===`Escape`&&B(null)},onBlur:()=>B(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[e.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:k(`pinnedConversation`),children:`📌`}),He(e)]}),z===e.path?null:(0,X.jsxs)(`span`,{className:`session-sub`,children:[n?k(`current`):k(`messageCount`,{n:e.messageCount}),e.source===`tui`&&(0,X.jsx)(`span`,{className:`session-src`,title:k(`tuiTip`),children:`TUI`})]})]}),(0,X.jsx)(`span`,{className:`session-time ${r?`switching-pct`:``}`,children:r?`${D.progress}%`:Rl(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:k(`renameSession`),onClick:t=>{t.stopPropagation(),I(null),H(e.name??``),B(e.path)},children:(0,X.jsx)(Ke,{})}),Y(`sess:${e.path}`,k(`deleteSession`),k(`deleteSessionConfirm`),()=>{Fl(e.path,N),o({type:`delete_session`,path:e.path})}),Ce(Be,`lp-slot-sessions`)]},e.path)})]})]})})},$e=e=>{let t=je.find(t=>t.key===e)?.entry;if(!t)return null;let n=Me(e);return(0,X.jsxs)(`div`,{className:`lp-section lp-section-plugin ${n?`collapsed`:``}`,style:n?void 0:{flex:`${Xe(e)} 1 0px`},children:[qe(t.label,n,()=>ue(e)),!n&&(0,X.jsx)(`div`,{className:`lp-section-body lp-plugin-section-body`,children:b?.(t)??null})]})},et=e=>e===`projects`||e===`convs`||e===`sessions`?Qe[e]:$e(e);return(0,X.jsxs)(`aside`,{ref:Te,className:`panel panel-left lp-panel`,children:[c&&l&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:k(`collapsePanel`),onClick:l,children:(0,X.jsx)(st,{})}),je.map(({key:e})=>(0,X.jsxs)(g.Fragment,{children:[et(e),Ze.get(e)??null]},e)),(0,X.jsx)(so,{open:ne,currentCwd:N,pathCompletions:u??[],workspaceRoots:te,onClose:()=>F(!1),onSelectDirectory:e=>o({type:`set_cwd`,path:e}),onCreateProject:e=>o({type:`make_dir`,path:e,setAsCwd:!0})})]})}),tu=209715200,nu=/windows/i.test(navigator.userAgent),ru=/[<>:"/\\|?*\u0000-\u001f]/g,iu=/[. ]+$/,au=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function ou(e){let t=e.replace(ru,`_`).replace(iu,``);return t?au.test(t)?`_${t}`:t:`_`}function su(e,t=!0){return gn(fn(`/api/file?${new URLSearchParams({clientId:Sl(),path:e,...t?{download:`1`}:{}})}`))}async function cu(e,t){let n=nu?ou(t):t;try{let t=await fetch(su(e));if(!t.ok)return{ok:!1,cancelled:!1,error:await t.text().catch(()=>``)||(t.status===404?`FILE_NOT_FOUND`:`HTTP ${t.status}`)};if(Number(t.headers.get(`content-length`)??`0`)>tu)return window.location.assign(su(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?uu(r,n):du(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function lu(e,t){let n=nu?ou(t):t;return window.showSaveFilePicker&&window.isSecureContext?uu(e,n):du(e,n)}async function uu(e,t){let n,r=window.showSaveFilePicker;if(!r)return du(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:du(e,t)}try{let t=await n.createWritable();return await t.write(e),await t.close(),{ok:!0}}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}function du(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);return r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}function fu(e,t,n){let r=e.left-8,i=e.bottom+8;return r+t.width>n.width-8&&(r=Math.max(8,e.right+8-t.width)),i+t.height>n.height-8&&(i=Math.max(8,e.top-8-t.height)),{left:r,top:i}}function pu(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function mu({text:e}){let t=(0,g.useRef)(null),n=(0,g.useRef)(null),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)({left:0,top:0}),s=()=>{let e=t.current?.getBoundingClientRect();e&&(o({left:Math.max(8,e.left-8),top:e.bottom+8}),i(!0))},c=()=>i(!1);return(0,g.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=fu(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,g.useEffect)(()=>{if(!r)return;let e=0,a=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e=t.current,r=n.current;if(!e||!r)return;let a=e.getBoundingClientRect();if(a.bottom<0||a.top>window.innerHeight||a.right<0||a.left>window.innerWidth){i(!1);return}let s=fu(a,r.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)})};return window.addEventListener(`scroll`,a,!0),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(e),window.removeEventListener(`scroll`,a,!0),window.removeEventListener(`resize`,a)}},[r]),(0,X.jsxs)(`span`,{ref:t,className:`set-tip`,tabIndex:0,"aria-label":e,onMouseEnter:s,onMouseLeave:c,onFocus:s,onBlur:c,onKeyDown:e=>{e.key===`Escape`&&e.target.blur()},children:[`?`,r&&(0,j.createPortal)((0,X.jsx)(`span`,{ref:n,className:`set-tip-bubble open`,role:`tooltip`,style:{position:`fixed`,left:a.left,top:a.top},children:e}),document.body)]})}var hu=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function gu(e,t={}){let n={archive:fn(`/api/file-transfer/archive`),upload:fn(`/api/file-transfer/upload`)},r=new URL(gn(`${n[e]}?${new URLSearchParams({clientId:Sl(),...t})}`),window.location.href);if(r.origin!==window.location.origin||r.pathname!==new URL(n[e],window.location.href).pathname)throw Error(`File transfers must use an allowlisted same-origin endpoint`);return r}async function _u(e,t,n){let r=await fetch(gu(`archive`),{method:`POST`,headers:{"Content-Type":`application/json`,"X-File-Operation":`1`},body:JSON.stringify({action:e,path:t,...n})});if(!r.ok)throw Error(await r.text());if(e===`download`){let e=r.headers.get(`content-disposition`)??``,t=/filename\*=UTF-8''([^;]+)/i.exec(e)?.[1],n=/filename="([^"]+)"/i.exec(e)?.[1],i=t?decodeURIComponent(t):n??`archive.tar.gz`,a=await lu(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function vu(){let e=window.showDirectoryPicker;if(!e)return null;let t=await e.call(window),n=[];async function r(e,t){if(n.length>=2e4)throw Error(`Folder exceeds 20,000 entries`);if(n.push(e.kind===`file`?{path:t,file:await e.getFile()}:{path:t}),e.kind===`directory`)for await(let n of e.values())await r(n,`${t}/${n.name}`)}return await r(t,t.name),n}async function yu(e,t,n){if(t.length>2e4)throw Error(`Folder exceeds 20,000 entries`);for(let e of t)if(e.file&&e.file.size>33554432)throw Error(`File exceeds 32 MiB: ${e.path}`);let r=0;for(let i of t){let t=gu(`upload`,{dir:e,name:i.path,kind:i.file?`file`:`directory`}),a=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-File-Operation":`1`},body:i.file??new Blob});if(!a.ok)throw Error(`${i.path}: ${await a.text()}`);n?.(++r)}}function bu({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,g.useState)(e.dir),[o,s]=(0,g.useState)(`skip`),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(0),f=(0,g.useRef)(null),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{v.current?.showModal()},[]);let y=r(e.action===`upload`?`fileUploadFolder`:e.action===`extract`?`fileExtract`:e.action===`download`?`fileCompressDownload`:`fileCompress`);async function b(){try{let e=await vu();e?l(e):f.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),m(!0),_(``);try{e.action===`upload`?await yu(e.dir,c,d):await _u(e.action,e.path,{destination:i,policy:o}),n(),t()}catch(e){_(e instanceof Error?e.message:String(e)),n()}finally{m(!1)}}return(0,j.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),p||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsxs)(`div`,{className:`file-transfer-head`,children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(0,X.jsx)(`button`,{type:`button`,className:`file-transfer-close`,title:r(`close`),"aria-label":r(`close`),disabled:p,onClick:t,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`p`,{className:`file-transfer-path`,children:(e.action===`upload`?e.dir:e.path)||`.`}),(0,X.jsx)(`p`,{children:r(`fileArchiveLimits`)}),e.action===`extract`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{children:[r(`fileExtractDestination`),(0,X.jsx)(`input`,{value:i,disabled:p,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:p,onChange:e=>s(e.target.value),children:[(0,X.jsx)(`option`,{value:`skip`,children:r(`fileConflictSkip`)}),(0,X.jsx)(`option`,{value:`overwrite`,children:r(`fileConflictOverwrite`)}),(0,X.jsx)(`option`,{value:`error`,children:r(`fileConflictError`)})]})]})]}),e.action===`upload`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:r(`fileFolderUploadHint`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:p,ref:e=>{f.current=e,e?.setAttribute(`webkitdirectory`,``)},onChange:e=>l(Array.from(e.target.files??[],e=>({path:e.webkitRelativePath||e.name,file:e})))}),(0,X.jsxs)(`p`,{"aria-live":`polite`,children:[u,` / `,c.length]})]}),h&&(0,X.jsx)(`p`,{role:`alert`,children:r(`fileTransferFailed`,{error:h})}),(0,X.jsxs)(`div`,{className:`file-transfer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:p||e.action===`upload`&&c.length===0,children:p?r(`fileTransferBusy`):y})]})]})}),document.body)}function xu(e){return e.startsWith(`.`)&&e!==`..`}function Su(e,t){return t?e:e.filter(e=>!xu(e.name))}function Cu(e){return e instanceof Error?e.message:String(e)}function wu(e,t,n,r){let i=n===`zh`;switch(e.kind){case`no-client`:return i?`插件 ${t} 没有客户端脚本(client/entry.mjs),无法显示这一页。`:`Plugin ${t} ships no client bundle (client/entry.mjs), so this page cannot be shown.`;case`load`:return i?`插件 ${t} 的页面脚本加载失败:${e.detail}`:`Failed to load plugin ${t}'s page bundle: ${e.detail}`;case`mount`:return`${r(`pluginMountFailed`,{name:t})}:${e.detail}`}}function Tu({plugin:e,epoch:t,send:n,className:r}){let i=(0,g.useRef)(null),{locale:a}=Nn(),o=Z(),[s,c]=(0,g.useState)(null),l=(0,g.useRef)(n);(0,g.useEffect)(()=>{l.current=n},[n]),(0,g.useEffect)(()=>{let n=i.current;if(!n)return;let r=!1,a,o=!1;if(c(null),!e.hasClient){c({kind:`no-client`});return}return(async()=>{try{if(await Uc(e,t),r)return;let i=await Is(e.id,()=>xc(()=>import(Rc(e.id,t)),[]));if(r)return;let s=i.default;if(!s||typeof s.mount!=`function`)throw Error(`client/entry.mjs 没有导出 default.mount()`);o=!0,a=s.mount(n,Gc(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:Cu(t)})}})(),()=>{if(r=!0,typeof a==`function`)try{a()}catch(t){console.error(`[plugin:${e.id}] cleanup 失败:`,t)}n.textContent=``}},[e.id,e.hasClient,t]);let u=r?`plugin-page ${r}`:`plugin-page`;return(0,X.jsxs)(`div`,{className:u,children:[(0,X.jsx)(`div`,{className:`plugin-page-host`,ref:i}),s&&(0,X.jsx)(`div`,{className:`plugin-page-error`,role:`alert`,children:wu(s,e.name,a,o)})]})}function Eu(e){return`pi-web-ui:${e}:tab`}function Du(e,t){try{let n=localStorage.getItem(Eu(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Ou(e,t){try{localStorage.setItem(Eu(e),t)}catch{}}function ku(e){return e.length>0&&!/[a-z]/i.test(e)}function Au(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function ju({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,g.useId)(),[s,c]=(0,g.useState)(()=>Du(e,t)??t[0]?.id??``),l=(0,g.useRef)([]),u=(0,g.useRef)(``),d=t.findIndex(e=>e.id===s),f=d>=0?t[d]:t[0],p=f?t.indexOf(f):-1;(0,g.useEffect)(()=>{if(!f)return;s!==f.id&&c(f.id);let t=`${e}:${f.id}`;u.current!==t&&(u.current=t,Ou(e,f.id))},[f,s,e]);let m=t=>{c(t.id),u.current=`${e}:${t.id}`,Ou(e,t.id)},h=(e,n)=>{let r=t.length,i=-1;if(e.key===`ArrowRight`)i=(n+1)%r;else if(e.key===`ArrowLeft`)i=(n-1+r)%r;else if(e.key===`Home`)i=0;else if(e.key===`End`)i=r-1;else return;let a=t[i];a&&(e.preventDefault(),m(a),l.current[i]?.focus())};if(!f)return null;let _=`${o}-panel-${p}`,v=a?`slot-tabs ${a}`:`slot-tabs`;return(0,X.jsxs)(`div`,{className:v,children:[(0,X.jsxs)(`div`,{className:`slot-tabs-bar`,role:`tablist`,children:[t.map((e,t)=>{let n=t===p;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Au(e),"aria-selected":n,"aria-controls":`${o}-panel-${t}`,tabIndex:n?0:-1,ref:e=>{l.current[t]=e},onClick:()=>m(e),onKeyDown:e=>h(e,t),children:[e.iconSvg?(0,X.jsx)(hi,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&ku(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Au(e)})]},e.id)}),i?(0,X.jsx)(`div`,{className:`slot-tabs-extra`,children:i}):null]}),(0,X.jsx)(`div`,{className:`slot-tabs-body`,id:_,role:`tabpanel`,"aria-labelledby":`${o}-tab-${p}`,children:f.pluginPage?(0,X.jsx)(Tu,{plugin:f.pluginPage.plugin,epoch:n,send:r}):f.element??null})]})}function Mu(e){if(typeof document>`u`)return!1;try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}async function Nu(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Mu(e)}return Mu(e)}function Pu(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,g.useCallback)(()=>{s(),a(!1)},[s]);return(0,g.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,g.useCallback)(async e=>{let i=!1;try{i=await Nu(e)}catch(e){i=!1,r&&r(e)}return i?(a(!0),s(),o.current=setTimeout(()=>{a(!1),o.current=null},t),n?.(e)):r&&!i&&r(Error(`Copy failed`)),i},[t,n,r,s]),reset:c}}var Fu=`@root`,Iu=`pi-web-ui:rp-sizes`,Lu=`pi-web-ui:files-show-hidden`,Ru={files:4,widgets:1},zu=120,Bu=56;function Vu(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var Hu=`files`,Uu=[],Wu=()=>{};function Gu(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function Ku(e){return e===Fu||e===`/`||/^[A-Za-z]:$/.test(e)}function qu(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var Ju=(0,g.memo)(function({files:e,fileChanged:t,widgets:n,panelSend:r,onAttach:i,onPreview:a,onNotice:o,collapsible:s,onToggleCollapse:c,uiRightPanelTabs:l,uiContextFile:u,plugins:d,pluginsEpoch:f,send:p}){let m=Z(),h=d??Uu,_=La(`cwd`),v=La(`workspaceRoots`),y=La(`homeDir`),b=La(`desktopDir`),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),[k,A]=(0,g.useState)(()=>{try{return Lo(localStorage.getItem(Iu),Ru)}catch{return{...Ru}}});(0,g.useEffect)(()=>{try{localStorage.setItem(Iu,JSON.stringify(k))}catch{}},[k]);let[j,ee]=(0,g.useState)(()=>{try{return localStorage.getItem(Lu)===`1`}catch{return!1}});(0,g.useEffect)(()=>{try{localStorage.setItem(Lu,j?`1`:`0`)}catch{}},[j]);let M=n.some(e=>e.lines.length>0),te=(0,g.useCallback)(e=>{e.preventDefault();let t=D.current;if(!t)return;let n=e.currentTarget,r=e.clientY,i={above:k.files,below:k.widgets},a=Math.max(120,t.clientHeight-Vu(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Ro({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:zu,minBelowPx:Bu});A({files:t,widgets:n})},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),n.classList.remove(`dragging`),document.body.classList.remove(`rp-resizing`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},[k.files,k.widgets]),N=(0,g.useRef)(null),ne=(0,g.useRef)(0),F=(0,g.useCallback)(e=>{N.current=e,e&&(e.scrollTop=ne.current)},[]),[re,I]=(0,g.useState)(null),L=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let ie=(0,g.useCallback)(e=>{I(e),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>I(null),1200)},[]),R=(0,g.useCallback)((e,t)=>{e&&Nu(e).then(e=>{e?ie(t):o(`error`,m(`slashCopyFailed`))})},[ie,o,m]),z=(0,g.useCallback)(e=>{if(!e)return _;if(/^[A-Za-z]:$/.test(e))return`${e}/`;if(e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e))return e;let t=_.replace(/\\/g,`/`).replace(/\/+$/,``);return t?`${t}/${e}`:e},[_]),B=(0,g.useCallback)(e=>!e||e===Fu?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),V=104857600,H=(0,g.useCallback)((e,t)=>{for(let n of t){if(n.size>V){o(`warning`,m(`fileTooLarge`,{name:n.name,size:V/1024/1024}));continue}let t=new FileReader;t.onload=()=>{let i=t.result,a=i.slice(i.indexOf(`,`)+1);a&&r({type:`upload_file`,dirPath:e,name:n.name,data:a})},t.readAsDataURL(n)}},[r,o,m]),U=(0,g.useRef)(null),[ae,oe]=(0,g.useState)(null),se=(0,g.useRef)(null),W=(0,g.useCallback)(()=>{let e=U.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),ce=(0,g.useCallback)(()=>{se.current&&(se.current.value=``),se.current?.click()},[]),[le,ue]=(0,g.useState)(null),[de,fe]=(0,g.useState)(null),[pe,G]=(0,g.useState)(``),[K,me]=(0,g.useState)(null),[he,ge]=(0,g.useState)(``),q=(0,g.useCallback)((e,t)=>{cu(e,t).then(e=>{e.ok||e.cancelled||o(`error`,m(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?m(`fileNotFoundShort`):e.error}))})},[o,m]),_e=(0,g.useCallback)(()=>{let e=U.current?.target;e&&e.kind!==`list`&&!Ku(e.id)&&(me(null),G(e.label),fe(e.id))},[]),ve=(0,g.useCallback)(()=>{if(!de)return;let e=pe.trim();fe(null),e&&r({type:`file_rename`,path:de,newName:e})},[de,pe,r]),ye=(0,g.useCallback)(e=>{let t=U.current?.dir??x;fe(null),ge(``),me({dir:t,kind:e})},[x]),be=(0,g.useCallback)(()=>{if(!K)return;let e=he.trim();me(null),e&&r({type:`file_create`,dir:K.dir,name:e,kind:K.kind})},[K,he,r]),xe=(e,t,n,r)=>(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:e,placeholder:m(`fileNamePlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>t(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing?n():e.key===`Escape`&&r()},onBlur:r}),J=(0,g.useCallback)(()=>{let e=U.current?.target;e&&e.kind!==`list`&&!Ku(e.id)&&window.confirm(m(`fileDeleteConfirm`,{name:e.label}))&&(le?.src===e.id&&ue(null),de===e.id&&fe(null),r({type:`file_delete`,path:e.id}))},[r,m,le,de]),Se=(0,g.useCallback)(()=>{let e=U.current?.target;e&&e.kind!==`list`&&!Ku(e.id)&&r({type:`file_copy`,src:e.id,destDir:Gu(e.id)})},[r]),Ce=(0,g.useCallback)(e=>{let t=U.current?.target;t&&t.kind!==`list`&&!Ku(t.id)&&ue({src:t.id,cut:e})},[]),Te=(0,g.useCallback)(()=>{if(!le)return;let e=U.current?.dir??x;le.cut?(r({type:`file_copy`,src:le.src,destDir:e,move:!0}),ue(null)):r({type:`file_copy`,src:le.src,destDir:e})},[le,r,x]),Ee=(0,g.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[De,ke]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(!De)return;let e=e=>{e.target?.closest(`.root-picker`)||ke(!1)},t=e=>{e.key===`Escape`&&ke(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[De]);let Ae=(0,g.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),je=(0,g.useCallback)(()=>{let e=U.current?.target;if(!e||e.kind!==`dir`)return;let t=B(e.id);t&&!v.includes(t)&&Ae([...v,t])},[v,B,Ae]),Me=(0,g.useCallback)(e=>{H(U.current?.dir??x,Array.from(e.target.files??[]))},[H,x]),Ne=(0,g.useCallback)(e=>{let t=U.current?.target;switch(e.id){case`host:file-compress`:case`host:file-extract`:case`host:file-compress-download`:case`host:file-upload-folder`:{if(!t)break;let n=e.id===`host:file-compress`?`compress`:e.id===`host:file-extract`?`extract`:e.id===`host:file-compress-download`?`download`:`upload`;oe({action:n,path:z(t.id),dir:z(n===`upload`?U.current?.dir??x:Gu(t.id))});break}case`host:file-open-project`:W();break;case`host:file-upload`:ce();break;case`host:file-add-root`:je();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Je(t.id);break;case`host:file-download`:t?.kind===`file`&&q(t.id,t.label);break;case`host:file-reveal`:t&&r({type:`file_reveal`,path:t.id});break;case`host:file-open-default`:t?.kind===`file`&&r({type:`file_open_default`,path:t.id});break;case`host:file-attach-ref`:t?.kind===`file`&&i(t.id,t.label,`reference`);break;case`host:file-attach-folder`:t?.kind===`dir`&&i(t.id,t.label,`reference`,!0);break;case`host:file-new-file`:ye(`file`);break;case`host:file-new-dir`:ye(`dir`);break;case`host:file-paste`:Te();break;case`host:file-rename`:_e();break;case`host:file-duplicate`:Se();break;case`host:file-cut`:Ce(!0);break;case`host:file-copy`:Ce(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&R(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&R(z(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&R(t.id,`rel:${t.id}`);break;case`host:file-refresh`:Ee();break;case`host:file-delete`:J()}},[W,x,ce,je,a,i,R,z,q,ye,Te,_e,Se,Ce,Ee,J]),Pe=(0,g.useCallback)((e,t)=>{let n=t.kind===`dir`?B(t.id):null,r={target:t,dir:t.kind===`dir`?t.id:x,project:n?{path:n,name:t.label}:null},i=t.kind,a=i===`file`,o=i===`dir`,s=i===`list`,c=!s&&Ku(t.id),l=!s&&qu(t.id),d=x===Fu,f=(u??[]).map(e=>{if(e.source!==`host`)return e;switch(e.id){case`host:file-upload-folder`:return d?{...e,hidden:!0}:e;case`host:file-compress`:case`host:file-compress-download`:return!s&&!c?e:{...e,hidden:!0};case`host:file-extract`:return a&&hu(t.label)?e:{...e,hidden:!0};case`host:file-upload`:return d?{...e,hidden:!0}:{...e,label:r.dir===x?m(`uploadToCurrentDir`):m(`uploadToFolder`)};case`host:file-open-project`:return n?e:{...e,hidden:!0};case`host:file-add-root`:return n&&n!==_&&!v.includes(n)?e:{...e,hidden:!0};case`host:file-open`:case`host:file-download`:case`host:file-open-default`:case`host:file-attach-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return!d&&t.id!==Fu?e:{...e,hidden:!0};case`host:file-enter`:case`host:file-attach-folder`:return o?e:{...e,hidden:!0};case`host:file-new-file`:case`host:file-new-dir`:return!a&&!d?e:{...e,hidden:!0};case`host:file-paste`:return!a&&!d&&le?e:{...e,hidden:!0};case`host:file-rename`:case`host:file-duplicate`:case`host:file-cut`:case`host:file-copy`:case`host:file-delete`:return!s&&!c?e:{...e,hidden:!0};case`host:file-copy-name`:case`host:file-copy-path`:return s?{...e,hidden:!0}:e;case`host:file-copy-rel`:return!s&&!l?e:{...e,hidden:!0};case`host:file-refresh`:return s?e:{...e,hidden:!0};default:return e}});Ca(f).length!==0&&(e.preventDefault(),e.stopPropagation(),U.current=r,fa({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Ne}))},[u,x,B,m,Ne,_,v,le]),Fe=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),Ie=(0,g.useCallback)(()=>{N.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),N.current?.classList.remove(`drop-root`)},[]),Le=(0,g.useCallback)(e=>{if(Ie(),e==null)return;let t=N.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):N.current?.classList.add(`drop-root`)},[Ie]),ze=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ve=(0,g.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),He=(0,g.useRef)(0),Ge=(0,g.useRef)(void 0),Y=(0,g.useCallback)((e,t)=>{let n=++He.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||He.current===n&&E(!1)},[r]),Ke=(0,g.useCallback)(e=>{let t=v.filter(t=>t!==e);Ae(t),(x===e||x.startsWith(`${e}/`))&&Y(``)},[v,Ae,x,Y]);(0,g.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,g.useEffect)(()=>{if(_!==Ge.current){let e=Ge.current===void 0;Ge.current=_,e?Y(``,{silent:!0}):S(``);return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Y(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Y]),(0,g.useEffect)(()=>{t&&t.path===x&&Y(x,{silent:!0})},[t,x,Y]);let Je=e=>Y(e),Ye=()=>{e?.parent!==null&&e?.parent!==void 0&&Y(e.parent)},Xe=(()=>{if(x===``||x===Fu)return[];let e=x.split(`/`).filter(e=>!!e&&e!==Fu);return x.startsWith(`/`)?[{label:`/`,path:`/`},...e.map((t,n)=>({label:t,path:`/`+e.slice(0,n+1).join(`/`)}))]:e.map((t,n)=>({label:e[n],path:e.slice(0,n+1).join(`/`)}))})(),Ze=[];for(let e of l??[]){if(e.source===`host`||e.hidden||e.kind===`divider`)continue;let t=h.find(t=>t.id===e.source.slice(7));t&&Ze.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let Qe=(l??[]).some(e=>e.id===`host:right-files`&&e.hidden);return(0,X.jsxs)(`aside`,{className:`panel panel-right`,ref:D,children:[s&&c&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:m(`collapsePanel`),onClick:c,children:(0,X.jsx)(ot,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:M?`${k.files} 1 0`:`1 1 0`,minHeight:M?zu:0},children:(0,X.jsx)(ju,{storageKey:`rightpanel`,epoch:f??0,send:p??Wu,tabs:(e=>{let t=(l??[]).filter(e=>!e.hidden);if(t.length===0)return e;let n=new Map(t.map((e,t)=>[e.id,t])),r=e=>n.get(e===Hu?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...Qe?[]:[{id:Hu,label:m(`openFiles`),element:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`panel-crumbs`,children:[(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===``?`active`:``}`,onClick:()=>Y(``),children:m(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===Fu?`active`:``}`,title:m(`computer`),onClick:()=>Y(Fu),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:m(`homeDir`),onClick:()=>Y(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:m(`desktopDir`),onClick:()=>Y(b),children:`🖥️`}),(0,X.jsx)(mu,{text:m(`filesHelp`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${j?`active`:``}`,title:m(j?`filesHideHidden`:`filesShowHidden`),"aria-label":m(j?`filesHideHidden`:`filesShowHidden`),"aria-pressed":j,onClick:()=>ee(e=>!e),children:j?(0,X.jsx)(We,{}):(0,X.jsx)(Ue,{})}),v.length>0&&(0,X.jsxs)(`div`,{className:`root-picker`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`crumb root-picker-trigger`,"aria-haspopup":`menu`,"aria-expanded":De,title:m(`workspaceRoots`),onClick:()=>ke(e=>!e),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:m(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),De&&(0,X.jsxs)(`div`,{className:`root-picker-menu`,role:`menu`,children:[(0,X.jsx)(`div`,{className:`root-picker-row`,children:(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x===``?`root-picker-item active`:`root-picker-item`,title:_,onClick:()=>{ke(!1),Y(``)},children:[m(`rootDir`),(0,X.jsx)(`span`,{className:`root-picker-path`,children:_})]})}),v.map(e=>(0,X.jsxs)(`div`,{className:`root-picker-row`,children:[(0,X.jsx)(`button`,{type:`button`,role:`menuitem`,className:x===e?`root-picker-item active`:`root-picker-item`,title:e,onClick:()=>{ke(!1),Y(e)},children:(0,X.jsx)(`span`,{className:`root-picker-path`,children:e})}),(0,X.jsx)(`button`,{type:`button`,className:`root-picker-remove`,title:m(`removeWorkspaceRoot`),"aria-label":m(`removeWorkspaceRoot`),onClick:()=>Ke(e),children:(0,X.jsx)(P,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:m(`workspaceRootsHint`)})]})]}),Xe.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(lt,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Y(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:F,className:`panel-body`,onScroll:e=>{ne.current=e.currentTarget.scrollTop},onContextMenu:e=>Pe(e,{id:x,kind:`list`,label:x===``?m(`rootDir`):x===Fu?m(`computer`):x}),onDragOver:e=>{Fe(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ve(),Le(ze(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||Ie()},onDrop:e=>{if(Ie(),!Fe(e))return;e.preventDefault(),e.stopPropagation(),Ve();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,m(`foldersNotSupported`));return}H(ze(e.target),t)},onDragEnd:Ie,children:[(0,X.jsx)(`input`,{ref:se,type:`file`,multiple:!0,hidden:!0,onChange:Me}),ae&&(0,X.jsx)(bu,{request:ae,onClose:()=>oe(null),onComplete:Ee}),K&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[K.kind===`dir`?(0,X.jsx)(Re,{className:`file-icon`}):(0,X.jsx)(Be,{className:`file-icon`}),xe(he,ge,be,()=>me(null))]}),T&&(0,X.jsx)(`div`,{className:`panel-empty`,children:m(`loading`)}),!T&&e&&e.path===x&&(0,X.jsxs)(X.Fragment,{children:[e.parent!=null&&(0,X.jsxs)(`button`,{type:`button`,className:`file-item dir`,onClick:Ye,children:[(0,X.jsx)(Re,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),Su(e.entries,j).map(e=>e.type===`dir`?(0,X.jsxs)(`div`,{className:`file-item dir${le?.cut&&le.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`dir`,label:e.name}),children:[de===e.path?xe(pe,G,ve,()=>fe(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Je(e.path),children:[(0,X.jsx)(Re,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":m(`linkFolderTip`),"aria-label":m(`linkFolderTip`),onClick:()=>i(e.path,e.name,`reference`,!0),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`name:${e.path}`?` copied`:``}`,"data-tip":m(`copyName`),"aria-label":m(`copyName`),onClick:()=>R(e.name,`name:${e.path}`),children:re===`name:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`path:${e.path}`?` copied`:``}`,"data-tip":m(`copyPath`),"aria-label":m(`copyPath`),onClick:()=>R(z(e.path),`path:${e.path}`),children:re===`path:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(it,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${le?.cut&&le.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`file`,label:e.name}),children:[de===e.path?xe(pe,G,ve,()=>fe(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-name`,title:`${e.path} — ${m(`previewFile`)}`,onClick:()=>a(e.path,e.name),children:[(0,X.jsx)(Be,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name-text`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach download`,"data-tip":m(`downloadFile`),onClick:()=>q(e.path,e.name),children:(0,X.jsx)(qe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":m(`referenceTip`),"aria-label":m(`referenceTip`),onClick:()=>i(e.path,e.name,`reference`),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`name:${e.path}`?` copied`:``}`,"data-tip":m(`copyName`),"aria-label":m(`copyName`),onClick:()=>R(e.name,`name:${e.path}`),children:re===`name:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`path:${e.path}`?` copied`:``}`,"data-tip":m(`copyPath`),"aria-label":m(`copyPath`),onClick:()=>R(z(e.path),`path:${e.path}`),children:re===`path:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(it,{})})]},e.path)),e.truncated&&(0,X.jsx)(`div`,{className:`panel-empty files-truncated`,children:m(`filesTruncated`)})]}),!T&&!e&&(0,X.jsx)(`div`,{className:`panel-empty`,children:m(`noFiles`)})]})]})}],...Ze])})}),M&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:te,onDoubleClick:()=>A({...Ru}),title:m(`dragToResize`)}),M&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:Bu},children:n.filter(e=>e.lines.length>0).map(e=>(0,X.jsxs)(`div`,{className:`widget`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`widget-title widget-title-btn`,title:m(`widgetExpand`),onClick:()=>w(e.key),children:[(0,X.jsx)(`span`,{children:e.key}),(0,X.jsx)(we,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
327
+ It only opens after you confirm.`,settingsExtensions:`Extensions`,settingsUiPlugins:`UI plugins`,pluginListTab:`Plugin list`,noUiPlugins:`No UI plugins installed (<dataDir>/plugins/)`,pluginPhaseActive:`Active`,pluginPhaseDisabled:`Disabled`,pluginPhaseFailed:`Failed`,pluginPhaseIdle:`Frontend-only`,pluginRescan:`Rescan`,pluginRescanHint:`Re-scan the plugin directory (picks up new/fixed plugins; failure records are cleared and re-evaluated)`,dshPatches:`DSH user patches`,dshPatchesDesc:`Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.`,dshPatchesRescan:`Rescan`,dshPatchesRescanHint:`Re-scan the patch directory and restart the DSH runtime so new patches take effect`,dshPatchesEmpty:`No patch files yet`,dshPatchesPath:`Patch directory: `,dshPreset:`Agent preset`,dshPresetNewChat:`New chat with this preset`,dshPresetLocked:`Locked`,dshPresetBlankOnly:`Locked after the first message; blank sessions can switch`,dshPresetBroken:` (unavailable)`,dshPresetUser:`custom`,dshPresetDefaultTag:`default`,dshPresetMinimalNote:`Minimal: persistent shell only; host plugin tools and questionnaire unavailable`,dshDefaultPreset:`Default preset`,dshDefaultPresetDesc:`Preset for new chats; blank sessions can switch anytime, locked after the first message`,dshPresetUserNote:`Custom presets come from the user preset directory (trusted like shell access); compositions using bare package names cannot mount here (known limitation)`,"preset.standard":`Full access`,"preset.minimal":`Minimal`,"preset.code":`Code development`,"preset.reader":`Read-only analysis`,"preset.ask":`Chat only`,"preset.standardDesc":`All available tools and extension capabilities (default)`,"preset.minimalDesc":`Keeps only bash and read; plugin tools, skill catalog and terminal guidance are hidden too`,"preset.codeDesc":`Focused on reading, writing and running code (bash, read, edit, write, edit_soft); plugin tools and skill catalog are hidden too`,"preset.readerDesc":`Keeps only read-only tools and forbids writes; plugin tools are hidden too (read/write unknown, handled conservatively)`,"preset.askDesc":`No-tools Q&A: the model never calls a tool; plugin tools and skill catalog are hidden too`,dshPerm:`Permissions`,dshPermReadOnly:`Read Only`,dshPermReadOnlyDesc:`Read files and run read-only commands; writes are always denied, no prompts`,dshPermWorkspaceWrite:`Workspace Write`,dshPermWorkspaceWriteDesc:`Read/write inside the workspace, no prompts; out-of-scope operations are denied directly`,dshPermFullAccess:`Full access`,dshPermFullAccessDesc:`Sandbox off, unrestricted machine access; only for tasks you trust`,dshPermFullAccessTag:`risky`,dshPermCustom:`Custom`,dshPermConfirmFull:`Click again to confirm full access`,dshPermDefault:`Default permission for new chats`,dshPermDefaultDesc:`Initial permission for new chats; the current chat can switch live anytime, no restart`,uiPluginNoSource:`Installed manually — no recorded source, online update unavailable`,uiPluginPerms:`Permissions`,pluginDiagTitle:`Diagnostics`,pluginDiagShow:`Diagnostics`,pluginDiagHide:`Hide`,pluginLogTitle:`Runtime logs`,pluginLogShow:`Logs`,pluginLogHide:`Hide`,pluginLogLevel:`Level`,pluginLogAll:`All`,pluginLogEmpty:`No logs yet`,pluginLogClear:`Clear`,pluginDomNeed:`⚠ Requests full DOM access`,pluginDomDesc:`This plugin can freely read and write the page DOM (bypassing UI layout restrictions). Grant only to plugins from sources you trust; once granted its UI code can touch the topbar, composer and any page element.`,pluginDomGrant:`Grant DOM access`,pluginDomRevoke:`Revoke DOM access`,pluginDomGranted:`Full DOM access granted`,pluginSettingsTitle:`Configuration`,pluginSettingsShow:`Configure`,pluginSettingsHide:`Hide`,pluginSettingsSave:`Save plugin settings`,pluginSettingsSaving:`Saving…`,pluginSettingsReset:`Reset defaults`,pluginSettingsInherit:`Follow global default`,pluginSecretSet:`Set (stored encrypted, leave blank to keep)`,pluginSecretUnset:`Not set (stored encrypted)`,settingsPresets:`Presets`,settingsSubagentTemplates:`Subagent templates`,settingsSubagentTemplatesDesc:`Presets for spawned subagents (role system prompt + skills/extensions whitelist + optional model and thinking level). AI may pick a template (subagent_spawn template param) or spawn without one; disabled templates stay in the panel but are invisible to AI tools.`,noSubagentTemplates:`No subagent templates yet. AI can pick a template when spawning a subagent (role prompt + skills/extensions whitelist + optional model and thinking level), or spawn without a template param for default config.`,subagentTemplateNew:`New template`,subagentTemplateEdit:`Edit`,subagentTemplateClosed:`Disabled`,tplDefaultBadge:`Built-in`,subagentDefaultModelLabel:`Default subagent model`,subagentFollowMain:`Follow the main conversation's current model`,subagentDefaultModelHint:`Fallback model for all subagents (a template's own model and the subagent_spawn model param take priority); does not change the main conversation's model.`,subagentNoModels:`No usable models yet (configure a provider API key first) — subagents will follow the main conversation's model.`,subagentTemplateOffHint:`Disabled templates stay in the panel and can be re-enabled, but AI tools can't see or pick them`,subagentTemplateEnable:`Enable`,subagentTemplateDisable:`Disable`,tplNamePlaceholder:`Template name (referenced by AI via subagent_spawn's template param)…`,tplDescriptionPlaceholder:`Description (AI uses it to judge when to pick this template)…`,tplDescriptionEnPlaceholder:`English description (shown to AI under English UI; falls back to the description above)…`,tplPromptModeLabel:`System prompt mode`,tplModelLabel:`Model (empty = follow main conversation)`,tplThinkingLabel:`Thinking level`,tplThinkingFollowMain:`Follow the main conversation's current thinking level`,tplThinkingHint:`Empty = follow the main conversation's current thinking level (same idea as the model fallback); unsupported levels are clamped to the nearest one the model supports.`,tplSystemPromptLabel:`System prompt`,tplSystemPromptPlaceholder:`Template role system prompt… (may be empty in append mode)`,tplSystemPromptEnPlaceholder:`English system prompt… (used under English UI; falls back to the prompt above)`,tplWhitelistHint:`Whitelist: checked = the subagent only gets these; none checked = follow the main session settings`,tplSkillsLabel:`Skills whitelist`,tplExtensionsLabel:`Extensions whitelist`,tplSave:`Save template`,tplCancel:`Cancel edit`,tplDelete:`Delete template`,settingsScheduler:`Scheduled tasks`,schedulerDesc:`Put the agent on a schedule (dependency audits, test runs, morning briefings…): headless pseudo-client runs, no browser needed; notifies when done, history included.`,schedulerEmpty:`No scheduled tasks yet. Click “New task” above to schedule the first one: a 9 AM daily check or an hourly test run.`,schedulerNew:`New task`,schedulerEdit:`Edit`,schedulerDelete:`Delete`,schedulerRunNow:`Run now`,schedulerRunning:`Running…`,schedulerEnable:`Enable`,schedulerDisable:`Disable`,schedulerEnabled:`Enabled`,schedulerDisabled:`Disabled`,schedulerNamePlaceholder:`E.g. Daily dependency & health check…`,schedulerDescPlaceholder:`Description (optional): what this task does…`,schedulerCwdLabel:`Target project`,schedulerCwdPlaceholder:`/absolute/path/to/project…`,schedulerUseCurrentCwd:`Use current project`,schedulerKindLabel:`Schedule`,schedulerKindCron:`Cron expression`,schedulerKindInterval:`Fixed interval`,schedulerCronPlaceholder:`E.g. 0 9 * * * (daily 9:00 AM)`,schedulerPresetDaily:`Daily 9:00 AM`,schedulerPresetHourly:`Hourly on the hour`,schedulerPresetHalfHour:`Every 30 minutes`,schedulerPresetWorkday:`Weekdays 9:00 AM`,schedulerPresetMonday:`Mondays 9:00 AM`,schedulerPresetCustom:`Custom…`,schedulerIntervalMinutes:`Interval (minutes, min 1)`,schedulerPromptPlaceholder:`The task for the agent, e.g. audit dependencies and report upgrades…`,schedulerModelLabel:`Model (empty = default)`,schedulerThinkingLabel:`Thinking level (empty = default)`,schedulerCatchUp:`Catch up one missed run after restart`,schedulerCatchUpHint:`When checked, a trigger missed during downtime runs once at next startup; otherwise it is skipped.`,schedulerNextFire:`Next`,schedulerLastRun:`Last`,schedulerNeverRun:`Never ran`,schedulerHistory:`History`,schedulerManualBadge:`manual`,schedulerRunOk:`ok`,schedulerRunFail:`failed`,schedulerConfirmDelete:`Delete scheduled task “{name}”? Its history goes with it.`,schedulerSave:`Save task`,schedulerCancelEdit:`Cancel edit`,tplInherit:`Follow main session`,settingsEnabled:`Enabled`,settingsDisabled:`Disabled`,presetNamePlaceholder:`Preset name…`,saveAsPreset:`Save as preset`,applyPreset:`Apply`,deletePreset:`Delete preset`,noSkills:`No skills`,noExtensions:`No extensions`,noPresets:`No presets yet (tune your current settings, then enter a name above to save them as a preset)`,presetShare:`Share presets`,presetShareShareBtn:`Share preset`,presetShareImportBtn:`Import preset`,presetShareBrowseBtn:`Browse shared`,presetShareTabExport:`Export / share`,presetShareTabImport:`Import`,presetShareTabBrowse:`Browse shared`,presetShareSource:`Source`,presetShareSourceCurrent:`Current settings`,presetShareDescription:`Description`,presetShareDescriptionPlaceholder:`What is this preset good for? (optional)`,presetShareTags:`Tags`,presetShareTagsPlaceholder:`Comma separated, e.g. coding, minimal (optional)`,presetShareAuthor:`Author (optional)`,presetExportJson:`Export JSON`,presetExportDownload:`Download file`,presetShareSubmit:`Share to the community repo`,presetShareHint:`Creates a GitHub issue: with the gh CLI or a GitHub token it is submitted for you (the repo bot validates and commits it, and it shows up under "Browse shared" within minutes). With neither, a prefilled new-issue page opens — just hit Submit (for very large presets the JSON is copied to the clipboard instead, so you can paste it).`,presetShareSubmitting:`Submitting…`,presetShareOpenWebTitle:`Submit Issue on GitHub`,presetShareOpenWebBtn:`Open submission page in new window`,presetShareOpenIssueBtn:`View created issue`,presetShareCopyJson:`Copy preset JSON`,presetSharePopupBlocked:`If your browser blocked the popup, click the button below to open:`,presetShareBrowserCopied:`Submission page generated — just hit Submit (for large presets the JSON is on your clipboard, paste it)`,presetImportText:`Paste preset JSON`,presetImportTextPlaceholder:`Paste the exported JSON here (or drop a .json file)…`,presetImportPickFile:`Choose file`,presetImportFromUrl:`Import from URL`,presetImportUrlPlaceholder:`https://raw.githubusercontent.com/…/preset.json`,presetImportPreview:`Preview`,presetImportFields:`{n} fields will be written`,presetImportIgnored:`Unknown fields ignored: {list}`,presetImportRejected:`Dropped (wrong type): {list}`,presetImportReplaces:`A local preset with this name already exists — importing overwrites it`,presetImportApply:`Apply right after importing`,presetImportConfirm:`Import`,presetImportPick:`Import selectively: pick what to write`,presetImportSelectAll:`All`,presetImportSelectNone:`None`,presetImportAllSelected:`All selected`,presetImportNoneSelected:`Select at least one field to import`,presetImportPickHint:`Unchecked fields keep your current values; you can still tweak everything afterwards in Settings.`,presetGroupPrompt:`Prompts`,presetGroupTools:`Tools & switches`,presetGroupTerminal:`Terminal takeover`,presetGroupSkills:`Skills & extensions`,presetGroupAi:`Model behavior & dedicated prompts`,presetGroupUi:`Interface & interaction`,presetGroupEngine:`Engine defaults`,presetGroupOther:`Other`,presetImportImported:`Imported: {name}`,presetBrowseEmpty:`No presets in the shared repo yet`,presetBrowseLoading:`Loading community presets…`,presetBrowseSearch:`Search name / tag / author`,presetBrowseRefresh:`Refresh list`,presetBrowseCached:`List cached at {time} — hit refresh to re-fetch`,presetBrowseImport:`Import`,presetBrowseIssue:`Source issue`,presetBadgeTemplate:`Has template`,presetBadgeReview:`Has review prompt`,loadingSession:`Loading session…`,connectingServer:`Connecting to pi-web-ui server…`,localePacks:`Language packs`,localeGetMore:`Get more languages`,localeInstalled:`Installed`,localeInstall:`Download`,localeRemove:`Remove`,localeDownloading:`Downloading…`,localeRemoving:`Removing…`,localeInstallFailed:`Download failed: {error}`,localeListFailed:`Couldn't load language packs: {error}`,localeRemoveHint:`You can re-download it anytime`,wallpaperTitle:`Chat wallpaper`,wallpaperDesc:`Show a full-window background image (side panels, top and bottom bars included): a theme-provided image applies automatically, a URL here takes precedence; use dim and blur to keep text readable.`,wallpaperUrlPh:`Image URL (https://…, empty = off)`,wallpaperDim:`Dim`,wallpaperBlur:`Blur`,wallpaperClear:`Clear`,wallpaperUpload:`Upload image`,wallpaperUploadFailed:`Couldn't read the image (or it's too big) — try another one`,skillFullTextLabel:`Inject full skill text`,skillFullTextDesc:`Expand skill file contents inline into the system prompt (8KB per file, 32KB total cap); otherwise only a catalog is listed and the model reads files on demand`,skillFullTextShort:`Full`,delegateOpenSubagent:`Open subagent`,delegateSecTask:`Task`,delegateSecExpected:`Expected outcome`,delegateSecTools:`Required tools`,delegateSecMustDo:`Must do`,delegateSecMustNotDo:`Must not do`,delegateSecContext:`Context`,copyConversationId:`Copy conversation ID`,copyConversationPath:`Copy session file path`,copyConversationLink:`Copy link to session`,copyMessageLink:`Copy link to message`,quoteConversation:`Quote into composer (readable by the AI)`,quoteConversationShort:`Quote`,attachConversation:`Conversation reference: {name} (the AI reads it via conversation_read on demand)`,attachConversationShort:`conversation`,quoteSelection:`Quote`,quoteText:`Text quote`,quoteSource:`Source message: {id}`,removeQuote:`Remove quote`,presentOpenLocal:`Open locally`,presentMissing:`File missing or unreadable (moved, deleted, or outside the workspace?)`,presentEmpty:`Nothing to show`,presentAutoOpen:`Auto-open previews the AI presents`,presentAutoOpenDesc:`When the AI presents files with present_files and marks one as 'look at this first', open the file preview dialog automatically. Off (default): the cards stay inline and you open them with one click.`,presentFilesEnabledDesc:`Let the AI push artifacts (screenshots, charts, videos, reports, logs) into the chat as preview cards: images/videos/audio are shown inline, text gets an excerpt plus a one-click preview dialog, and every row carries open-locally / reveal-in-file-manager / download / copy-path actions. The auto-open switch lives on the Chat page.`,presentFilesOffHint:`Disabled: the AI can only tell you the file path — no cards, no open-locally buttons`,skillEnabledDesc:`Load skill bodies by name (the skill catalog stays in the system prompt): the full text is fetched only when a skill is actually needed, instead of making the model guess a path and call read.`,skillOffHint:`Disabled: the AI can no longer load skill bodies by name (the catalog in the prompt is unaffected)`,claimFilesEnabledDesc:`Declare which files you are about to edit so parallel runs in the same project can steer clear (advisory only — it never blocks edits). First-wins; claims expire automatically.`,claimFilesOffHint:`Disabled: the AI can no longer claim files (post-hoc touch reminders still work, only the up-front intent signal is gone)`,planUpdateEnabledDesc:`Structured task plan updates (Plan Mode / Step State Machine): allows the model to break complex tasks into steps and track progress in real time.`,planUpdateOffHint:`Disabled: AI can no longer update the structured plan board`,compactContextEnabledDesc:`Proactively compact context based on the current issue: allows AI to independently specify compression focus, retain core task context, drop irrelevant history, and control retention scope.`,compactContextOffHint:`Disabled: AI cannot proactively invoke context compaction (you can still use /compact or trigger auto-compaction)`,mcpManageEnabledDesc:`MCP server inspection and installation (list / check / install / remove / reload): allows AI to check whether an MCP server is installed and conveniently install/configure npm or remote MCP servers with live hot-reload.`,mcpManageOffHint:`Disabled: AI cannot invoke mcp_manage to check or install MCP servers`,evalEnabledDesc:`Execute Python or JavaScript/TypeScript code in an isolated sandbox with persistent variables; ideal for calculations, data analysis, and algorithm verification (default-off to prevent tool crowding-out).`,evalOffHint:`Disabled: the AI cannot use the persistent code sandbox (can still run scripts via bash)`,patchToolEnabledDesc:`High-reliability structural patch tool (Hashline): line-anchored editing with 4-hex content hashes, syntactic AST block matching, and clipboard registers. Automatically attempts 3-way merge conflict recovery if files diverged.`,patchToolOffHint:`Disabled: AI falls back to basic string replacement via edit`,lspToolEnabledDesc:`Native Language Server Protocol (LSP) tool: IDE-grade semantic code intelligence (definition, references, hover, diagnostics, documentSymbol outline, read_symbol precise slicing, workspaceSymbol search, and cascade impact diagnostics). Multi-agent shared process pool with idle sleep, zero external dependencies.`,lspToolOffHint:`Disabled: AI cannot query LSP semantics and falls back to text search`,codemodeEnabledDesc:`Run JavaScript in a QuickJS WASM sandbox to batch tool calls and filter output: intermediate results never enter LLM context, keeping context concise (default off; requires capable model).`,codemodeOffHint:`Disabled: AI cannot run codemode scripts to batch call tools`,codemodeNestedCalls:`Nested tool calls`,codemodeScript:`JavaScript script`,codemodeFullOutput:`Full output file`,codemodeModeLabel:`Execution Mode`,codemodeModeHint:`In standard mode all tools are directly visible; in strict code mode tools are hidden from the model and must be invoked via sandbox scripts`,codemodeModeOn:`Standard Mode (on)`,codemodeModeOnly:`Strict Code Mode (only)`,codemodeInlineBudgetLabel:`Inline Budget`,codemodeInlineBudgetHint:`Estimated tokens the codemode prompt may spend on tool declarations directly (default: 3000)`,codemodeNestedApprovalBadge:`Nested Call`,codemodeNestedApprovalDesc:`This tool call was triggered by a background codemode sandbox script`,codemodeSavedImages:`Generated Images`,toolSearchEnabledDesc:`BM25-based tool discovery and activation: search and activate tools via natural language queries (ideal for large MCP toolsets to prevent context bloat).`,toolSearchOffHint:`Disabled: AI cannot use tool_search to discover tools`,toolSearchLoaded:`Activated tools`,toolInfoMenuLabel:`Show tool details`,toolInfoTitle:`Tool details`,toolInfoLoading:`Loading tool definition…`,toolInfoUnsupported:`This engine can't show tool definitions`,toolInfoMissing:`No definition found for this tool (it may come from an uninstalled plugin or an older version)`,toolInfoActive:`Enabled`,toolInfoInactive:`Disabled`,toolInfoSource:`Source`,toolInfoDescription:`Description`,toolInfoNoDescription:`This tool has no description`,toolInfoPromptSnippet:`Prompt snippet`,toolInfoGuidelines:`Prompt guidelines`,toolPromptEdit:`Edit description`,toolPromptEdited:`Description customized (click to edit)`,toolPromptHint:`Leave a field empty to use the tool's built-in text. The three fields map to the tool description the model sees, the one-line summary in the system prompt, and the behavioral guidelines.`,toolPromptDescription:`Tool description (how the model understands this tool)`,toolPromptSnippet:`Prompt snippet (the line in the system prompt's Available tools list)`,toolPromptGuidelines:`Behavioral guidelines (Guidelines section, one per line)`,toolPromptDefault:`Built-in text`,toolPromptReset:`Reset to default`,toolPromptSave:`Save`,toolPromptUnavailable:`No definition for this tool (engine unsupported, or the tool is uninstalled) — you can still fill in overrides, but they only apply once the tool exists.`,toolInfoParams:`Parameters`,toolInfoParamsNone:`This tool takes no parameters`,toolInfoSchemaDropped:`The parameter schema is too large and was omitted (see the raw JSON below)`,toolInfoRawSchema:`Raw JSON schema`,toolInfoRequired:`required`,toolInfoFootnote:`This is the tool's definition — not this call's arguments or result.`,elsewhereOfflineBadge:`Offline`,elsewhereOfflineTip:`The page holding this conversation is gone (tab or browser closed) but the run is still on the server — click this row twice to take it over here`,sandboxNewBtn:`Launch Sandbox Project (isolated workspace)`,sandboxModalTitle:`Launch Sandbox Project`,sandboxModalSubtitle:`Experiment freely inside a hard-jailed copy — no changes ever touch your original files.`,sandboxModeLabel:`Initial Content`,sandboxModeBlank:`Blank Sandbox`,sandboxModeBlankDesc:`Clean empty directory for quick prototypes, scripts, or file processing`,sandboxModeImport:`Import Existing Project`,sandboxModeImportDesc:`Clone source project files (auto-skips node_modules/caches); original stays untouched`,sandboxSourceLabel:`Source Project Path`,sandboxSourcePlaceholder:`Enter or select a local project path to import`,sandboxLifecycleLabel:`Lifecycle`,sandboxLifecycleEphemeral:`Temporary (Use & Discard)`,sandboxLifecycleEphemeralDesc:`Ideal for one-off experiments; destroy anytime or convert to permanent`,sandboxLifecyclePermanent:`Permanent Sandbox`,sandboxLifecyclePermanentDesc:`Kept in your projects list for ongoing experimentation`,sandboxNameLabel:`Sandbox Name (optional)`,sandboxNamePlaceholder:`Leave blank to auto-generate`,sandboxCreateSubmit:`Launch Sandbox`,sandboxBadgeEphemeral:`Temp Sandbox`,sandboxBadgePermanent:`Sandbox`,sandboxBannerTitle:`Sandbox Isolation: {name}`,sandboxBannerSourceDesc:`Source: {source} (read-only protected; all edits stay inside this sandbox)`,sandboxBannerBlankDesc:`Isolated workspace (hard jail active; writing outside sandbox is blocked)`,sandboxActionPersist:`Keep Permanently`,sandboxActionPersistTip:`Convert this temporary sandbox into a permanent sandbox project`,sandboxActionApplySource:`Sync to Source`,sandboxActionApplySourceTip:`Sync modified files from this sandbox back to the source project (preserves .git)`,sandboxActionApplyConfirm:`Sync modified files from sandbox "{name}" back to source project ({source})?`,sandboxActionReset:`Reset`,sandboxActionResetTip:`Wipe sandbox and restore initial state (re-clones clean copy from source if imported)`,sandboxActionResetConfirm:`Reset sandbox "{name}"? Unexported changes in the sandbox will be wiped and restored to initial state.`,sandboxActionPromote:`Save as Project`,sandboxActionPromoteTip:`Export this sandbox to a formal project directory outside sandboxes`,sandboxActionDestroy:`Destroy`,sandboxActionDestroyTip:`Permanently delete this sandbox directory and switch back`,sandboxActionDestroyConfirm:`Permanently destroy sandbox "{name}" and delete all its files? This cannot be undone.`,sandboxPromoteTitle:`Save Sandbox as Formal Project`,sandboxPromoteSubtitle:`Export files from sandbox "{name}" to a new directory outside the sandbox jail.`,sandboxPromoteTargetLabel:`Target Directory Path (must be a new or empty directory)`,sandboxPromoteTargetPlaceholder:`e.g. ~/projects/my-new-app`,sandboxPromoteSwitchLabel:`Switch to the exported project immediately`,sandboxPromoteSubmit:`Export Project`,sandboxApplyTitle:`Sync Sandbox Changes to Source Project`,sandboxDiffStats:`+{added} added · ~{modified} modified · -{deleted} deleted in sandbox · {unchanged} unchanged`,sandboxDiffEmpty:`This sandbox is identical to the source project — no modified or added files to sync.`,sandboxDiffDeletedNote:`Note: Syncing only writes added and modified files (preserves source .git and never deletes existing source files).`,sandboxApplySubmit:`Confirm Sync ({count} files)`,sandboxEnabledDesc:`Allow AI to create blank or imported copy-on-write sandbox projects (skipping node_modules/caches), inspect diffs, reset, or destroy; syncing changes back to the source project requires user approval.`,sandboxOffHint:`Disabled: AI cannot invoke the sandbox tool to create or manage isolated sandboxes`},Sn=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],Cn={};function wn(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(Cn[e.code]=e,!0)}function Tn(e){delete Cn[e]}function En(e){return e===`zh`?`中文`:e.toUpperCase()}function Dn(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function On(e){let t=await fetch(gn(fn(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var kn=(0,g.createContext)(null);function An(){try{return localStorage.getItem(yn)}catch{return null}}function jn(){return vn(An(),typeof navigator<`u`?navigator.languages:[],null)}function Mn({children:e}){let[t,n]=(0,g.useState)(jn),[r,i]=(0,g.useState)(0),a=(0,g.useRef)(t);a.current=t;let o=(0,g.useCallback)(e=>{n(e);try{localStorage.setItem(yn,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,g.useCallback)(async()=>{let e,t=null;try{let n=await On(`/api/locales`);e=n.packs??[],t=n.defaultLocale??null}catch{return null}return await Promise.all(e.filter(e=>e.installed).map(async e=>{try{let t=await On(`/api/locales/${e.code}`);return wn({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,g.useEffect)(()=>{s().then(e=>{if(!An()?.trim()){let t=vn(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!Cn[t]){let t=vn(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(yn,t)}catch{}}})},[s]);let c=(0,g.useMemo)(()=>[...Sn,...Object.values(Cn).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,g.useCallback)((e,n)=>{let r=Cn[t]?.strings[e];r&&t!==`zh`&&t!==`ja`&&/[\u4e00-\u9fff]/.test(r)&&(r=void 0);let i=r??(t===`zh`?bn[e]:xn[e]);if(n)for(let[e,t]of Object.entries(n))i=i.replaceAll(`{${e}}`,String(t));return i},[t,r]);(0,g.useEffect)(()=>{document.documentElement.lang=Dn(t)},[t]);let u=(0,g.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(kn.Provider,{value:u,children:e})}function Nn(){let e=(0,g.useContext)(kn);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return Nn().t}var Pn=[{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`},{kind:`approval`,labelKey:`sound.approval`,descKey:`sound.approval.desc`}];function Fn({settings:e,onChange:t,onPreview:n}){let r=Z(),i=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`soundHeader`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(ne,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`enableSound`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:e=>i({enabled:e.target.checked})})]}),Pn.map(({kind:t,labelKey:a,descKey:o})=>(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(a)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(o)})]}),(0,X.jsxs)(`span`,{className:`sound-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`sound-preview`,title:r(`preview`),disabled:!e.enabled,onClick:e=>{e.preventDefault(),n(t)},children:r(`preview`)}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e[t],disabled:!e.enabled,onChange:e=>i({[t]:e.target.checked})})]})]},t)),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`volume`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:100,step:5,value:e.volume,disabled:!e.enabled,onChange:e=>i({volume:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.volume,`%`]})]})]})}function In(){let[e,t]=(0,g.useState)([]);return(0,g.useEffect)(()=>{if(!qt())return;let e=window.speechSynthesis,n=()=>t(e.getVoices().map(e=>({voiceURI:e.voiceURI,lang:e.lang,name:e.name,localService:e.localService})));return n(),e.addEventListener?.(`voiceschanged`,n),()=>e.removeEventListener?.(`voiceschanged`,n)},[]),e}function Ln({settings:e,onChange:t,onPreview:n}){let r=Z(),i=In(),a=qt(),o=n=>t({...e,...n});return(0,X.jsxs)(`div`,{className:`sound-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:r(`ttsHeader`)}),!a&&(0,X.jsx)(`div`,{className:`sound-desc tts-unavailable`,children:r(`ttsUnavailable`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master ${a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(ne,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:r(`ttsEnable`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsEnableDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:!a,onChange:e=>o({enabled:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsAnnounce`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsAnnounceDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.announce,disabled:!e.enabled||!a,onChange:e=>o({announce:e.target.checked})})]}),(0,X.jsxs)(`label`,{className:`sound-row ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsReadReplies`)}),(0,X.jsx)(`span`,{className:`sound-desc`,children:r(`ttsReadRepliesDesc`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:e.readReplies,disabled:!e.enabled||!a,onChange:e=>o({readReplies:e.target.checked})})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsRate`)}),(0,X.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:e.rate,disabled:!e.enabled||!a,onChange:e=>o({rate:Number(e.target.value)})}),(0,X.jsxs)(`span`,{className:`sound-vol-num`,children:[e.rate.toFixed(1),`×`]})]}),(0,X.jsxs)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:[(0,X.jsx)(`span`,{className:`sound-name`,children:r(`ttsVoice`)}),(0,X.jsxs)(`select`,{className:`set-input tts-voice-select`,value:e.voiceURI,disabled:!e.enabled||!a,onChange:e=>o({voiceURI:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`ttsVoiceAuto`)}),i.map(e=>(0,X.jsxs)(`option`,{value:e.voiceURI,children:[e.name,` (`,e.lang,`)`,e.localService?``:` · ${r(`ttsVoiceOnline`)}`]},e.voiceURI))]})]}),(0,X.jsx)(`div`,{className:`sound-volume ${e.enabled&&a?``:`disabled`}`,children:(0,X.jsx)(`button`,{type:`button`,className:`sound-preview tts-preview`,disabled:!e.enabled||!a,onClick:()=>{if(e.voiceURI&&!Jt(e.voiceURI,i,navigator.language)){t({...Wt,...e,voiceURI:``});return}n()},children:r(`preview`)})})]})}function Rn(e){let t=e??(typeof window>`u`?void 0:window);if(!t)return!1;if(t.piDesktop?.isDesktop===!0)return!0;let n=t.navigator?.userAgent;return typeof n==`string`&&n.includes(`Electron/`)}var zn=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),Bn=null,Vn=0;function Hn(){return Bn?.available===!0?Bn.pages??[]:[]}function Un(){Date.now()-Vn<5e3||Wn().catch(()=>{})}async function Wn(){if(Rn())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=zn();if(!e)return{available:!1,pages:[],error:`宿主页面桥不可用:这个 pi-web-ui 页面还没装上扩展桥(装/启用 page-picker 后刷新本页)`};try{let t=await e({op:`status`,timeoutMs:5e3});if(!t.ok)return{available:!1,pages:[],error:t.error??`扩展没有返回状态`};let n=t.result??{},r={available:n.installed===!0,aiControl:n.aiControl===!0,allowEval:n.allowEval===!0,pages:Array.isArray(n.pages)?n.pages:[]};return r.available&&(Bn=r,Vn=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function Gn(e){return e.length===1?e[0]:null}function Kn(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function qn(){let e=zn();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function Jn(e=45e3){let[t,n]=(0,g.useState)(null),r=(0,g.useRef)(!0),i=(0,g.useCallback)(async e=>{let t=await Wn();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,g.useEffect)(()=>{r.current=!0,i(!0);let t=setInterval(()=>void i(!1),Math.max(5e3,e));return()=>{r.current=!1,clearInterval(t)}},[i,e]),{status:t,refresh:()=>void i(!0)}}var Yn=null,Xn=null,Zn=null,Qn=null,$n=null;function er(e){Qn=e}function tr(e){$n=e}function nr(e){return Qn?(Qn(e),!0):!1}function rr(e){return $n?($n(e),!0):!1}function ir(e){Yn=e}function ar(e){Xn=e}function or(e){Zn=e}function sr(){return Zn?(Zn(),!0):!1}function cr(){return!!(Yn||Xn)}function lr(e){let t=typeof e?.text==`string`?e.text:``,n=Array.isArray(e?.attachments)?e.attachments:[],r=t.trim()!==``,i=n.length>0;return!r&&!i||r&&!Yn||i&&!Xn?!1:(i&&Xn?.(n),r&&Yn?.(t),!0)}function ur(){let e=Z(),{status:t,refresh:n}=Jn(),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(null),s=(0,g.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=Gn(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},f=t=>{let n=lr({attachments:[Kn(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},p=()=>{i(!0),n()};return(0,X.jsxs)(`span`,{className:`bc-anchor`,children:[u?(0,X.jsxs)(`span`,{className:`browser-control-split`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control single${l?` attention`:``}`,"data-tip":e(`browserControlSingleTip`,{name:u.title||u.origin}),title:e(`browserControlSingleTip`,{name:u.title||u.origin}),onClick:()=>f(u),children:[(0,X.jsx)(ve,{size:14,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`bc-chip-label`,children:u.title||u.origin})]}),(0,X.jsx)(`button`,{type:`button`,className:`chip browser-control caret`,"data-tip":e(`browserControlOpenPanel`),title:e(`browserControlOpenPanel`),"aria-label":e(`browserControlOpenPanel`),onClick:p,children:`▾`})]}):(0,X.jsxs)(`button`,{type:`button`,className:`chip browser-control${l?` attention`:``}`,"data-tip":t?.error??e(l?`browserControlEmpty`:`browserControlTip`),title:t?.error??e(l?`browserControlEmpty`:`browserControlTip`),onClick:p,children:[(0,X.jsx)(ve,{size:14,"aria-hidden":!0}),(0,X.jsxs)(`span`,{children:[e(`browserControl`),c.length>0?` · ${c.length}`:``]})]}),a&&(0,X.jsx)(`span`,{className:`bc-flash`,children:a}),r&&(0,X.jsx)(dr,{status:t,onRefresh:n,onCite:f,onClose:()=>i(!1)})]})}function dr({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,g.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await qn()||t()}finally{o(!1)}};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:r,children:(0,X.jsxs)(`div`,{className:`modal browser-control-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":i(`close`),onClick:r,children:`✕`}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(ve,{size:16,"aria-hidden":!0}),(0,X.jsx)(`h2`,{children:i(`browserControl`)})]}),(0,X.jsx)(`div`,{className:`modal-desc`,children:i(`browserControlTip`)}),e===null&&(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlChecking`)}),e?.available===!1&&!e.desktop&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlOffline`)}),e?.desktop===!0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlDesktop`)}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlDesktopLead`)}),(0,X.jsx)(`div`,{className:`bc-actions`,style:{marginTop:0},children:(0,X.jsx)(`a`,{className:`btn primary`,href:window.location.href,target:`_blank`,rel:`noreferrer noopener`,children:i(`browserControlOpenInBrowser`)})})]}),e?.available===!1&&!e.desktop&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlInstall`)}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlInstallLead`)}),(0,X.jsx)(`div`,{className:`bc-actions`,style:{marginTop:0},children:(0,X.jsx)(`a`,{className:`btn primary`,href:`https://github.com/xing-shuyin/pi-web-ui/releases/latest/download/page-picker-extension.zip`,target:`_blank`,rel:`noreferrer noopener`,children:i(`browserControlInstallDownload`)})}),(0,X.jsxs)(`ol`,{className:`bc-steps`,children:[(0,X.jsx)(`li`,{children:i(`browserControlInstallStep1`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep2`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep3`)}),(0,X.jsx)(`li`,{children:i(`browserControlInstallStep4`)})]})]}),e?.available===!0&&e.aiControl===!1&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlDisabled`)}),e?.available===!0&&s.length===0&&(0,X.jsx)(`div`,{className:`bc-note warn`,children:i(`browserControlEmpty`)}),s.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlPages`)}),(0,X.jsx)(`ul`,{className:`bc-pages`,children:s.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`bc-title`,title:e.title,children:e.title}),(0,X.jsx)(`span`,{className:`bc-origin`,title:e.origin,children:e.origin}),(0,X.jsx)(`span`,{className:`bc-open${e.open?` on`:``}`,children:e.open?i(`browserControlPageOpen`):i(`browserControlPageClosed`)}),(0,X.jsx)(`button`,{type:`button`,className:`bc-cite`,title:i(`browserControlCiteTip`,{name:e.title||e.origin}),onClick:()=>n(e),children:i(`browserControlCite`)})]},e.origin))}),(0,X.jsx)(`div`,{className:`bc-note`,children:i(`browserControlCiteNote`)})]}),e?.desktop!==!0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`bc-section`,children:i(`browserControlExamples`)}),(0,X.jsxs)(`ul`,{className:`bc-examples`,children:[(0,X.jsx)(`li`,{children:i(`browserControlExample1`)}),(0,X.jsx)(`li`,{children:i(`browserControlExample2`)})]})]}),(0,X.jsxs)(`div`,{className:`bc-actions`,children:[e?.desktop!==!0&&(0,X.jsx)(`button`,{type:`button`,className:`primary`,disabled:a,onClick:()=>void c(),children:i(`browserControlOpenOptions`)}),(0,X.jsx)(`button`,{type:`button`,onClick:t,children:i(`browserControlRefresh`)})]})]})})}var fr=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],pr=[`subagent`],mr=`edit_soft`,hr=`delegate_task`,gr=`ask_user_question`,_r=`todo_list`,vr=`browser_page`,yr=`conversation_read`,br=`skill`,xr=`schedule`,Sr=`eval`,Cr=`present_files`,wr=`claim_files`,Tr=`plan_update`,Er=`compact_context`,Dr=`patch`,Or=`mcp_manage`,kr=`sandbox`,Ar=`codemode`,jr=`tool_search`,Mr=[...fr.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...pr.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:mr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:hr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:gr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:vr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:yr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:wr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:Tr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`planUpdateEnabledDesc`,offHintKey:`planUpdateOffHint`},{name:Dr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`patchToolEnabledDesc`,offHintKey:`patchToolOffHint`},{name:`lsp`,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`lspToolEnabledDesc`,offHintKey:`lspToolOffHint`},{name:Cr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:br,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:Sr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`evalEnabledDesc`,offHintKey:`evalOffHint`},{name:Ar,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`codemodeEnabledDesc`,offHintKey:`codemodeOffHint`},{name:jr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`toolSearchEnabledDesc`,offHintKey:`toolSearchOffHint`},{name:xr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:Er,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`compactContextEnabledDesc`,offHintKey:`compactContextOffHint`},{name:Or,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`mcpManageEnabledDesc`,offHintKey:`mcpManageOffHint`},{name:kr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`sandboxEnabledDesc`,offHintKey:`sandboxOffHint`},{name:_r,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}],Nr=[`bash`,`read`,`edit`,`write`,`powershell`,`ls`,`grep`,`find`];new Set(Mr.map(e=>e.name));var Pr=[...Mr.map(e=>e.name),...Nr];function Fr(e){let t=new Set(e);return Pr.filter(e=>!t.has(e))}function Ir(e,t){let n=Array.from(e);if(!t||t===`standard`)return n;if(t===`ask`)return[];if(t===`minimal`)return n.filter(e=>e===`bash`||e===`read`);if(t===`code`){let e=new Set([`bash`,`read`,`edit`,`write`,`edit_soft`]);return n.filter(t=>e.has(t))}if(t===`reader`){let e=new Set([`write`,`edit`,`edit_soft`,`bash`,`powershell`,`terminal_create`,`terminal_input`,`terminal_close`,`terminal_key`,`codemode`]);return n.filter(t=>!e.has(t))}return n}function Lr(e){return Ir([br],e).includes(br)}var Rr=`pi-web-notify`,zr={enabled:!1};function Br(){try{let e=localStorage.getItem(Rr);if(!e)return{...zr};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:zr.enabled}}catch{return{...zr}}}function Vr(e){try{localStorage.setItem(Rr,JSON.stringify(e))}catch{}}function Hr(){return typeof window<`u`&&`Notification`in window}function Ur(){return Hr()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Wr(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&Gr(t)||Number.isFinite(n)&&Gr(n)?!0:r>0&&r<=400&&i>0&&i<=40}function Gr(e){return e<=-1e4}function Kr(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var qr=Date.now(),Jr=!1;function Yr(){qr=Date.now()}function Xr(){return Math.max(0,Date.now()-qr)}function Zr(){if(Jr||typeof window>`u`)return;Jr=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Yr,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Yr,e)}function Qr(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function $r(){return Zr(),typeof window>`u`||typeof document>`u`?{hasFocus:!0,visibility:`visible`,minimized:!1,idleMs:0,windows:!1}:{hasFocus:typeof document.hasFocus!=`function`||document.hasFocus(),visibility:document.visibilityState??``,minimized:Wr({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Xr(),windows:Qr()}}function ei(){return Hr()?Notification.permission:`denied`}async function ti(){if(!Hr())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function ni(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function ri(e,t=!1){return{body:e,requireInteraction:t,icon:fn(`/icons/icon-192.png`),badge:fn(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:fn(`/`)}}}async function ii(e,t,n=!1){if(!Hr())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=ri(t,n),i;try{let t=await navigator.serviceWorker?.getRegistration();if(t?.active&&typeof t.showNotification==`function`)return await t.showNotification(e,r),{path:`sw`};i=t?`service worker not active`:`no service worker registration`}catch(e){i=ni(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${ni(e)}`}}}async function ai(e,t){Hr()&&(Kr($r())||Br().enabled&&await ii(e,t))}var oi=!1;function si(){let e=Z(),[t,n]=(0,g.useState)(Br),[r,i]=(0,g.useState)(()=>ei()),[a,o]=(0,g.useState)(null),s=Ur(),c=s!==null,l=Qr();(0,g.useEffect)(()=>{let e=()=>i(ei());return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},[]);let u=async e=>{let r={...t,enabled:e};if(n(r),Vr(r),e){let e=await ti();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Vr(e)}}};return(0,X.jsxs)(`div`,{className:`sound-menu notify-menu`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:e(`notifyHeader`)}),(0,X.jsxs)(`label`,{className:`sound-row sound-master${c?` disabled`:``}`,children:[(0,X.jsxs)(`span`,{className:`sound-label`,children:[(0,X.jsx)(_t,{className:`sound-icon`}),(0,X.jsx)(`span`,{children:e(`notifyEnable`)})]}),(0,X.jsx)(`input`,{type:`checkbox`,checked:t.enabled&&!c,disabled:c,onChange:e=>u(e.target.checked)})]}),(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyEnableDesc`)}),s===`insecure`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyInsecure`)}),s===`unsupported`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyUnsupported`)}),!c&&r===`denied`&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyDenied`)}),!c&&l&&(0,X.jsx)(`div`,{className:`sound-hint`,children:e(`notifyWindowsHint`)}),oi]})}var ci=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),Q=new Set(`viewBox.xmlns.d.fill.stroke.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.opacity.x.y.x1.y1.x2.y2.cx.cy.r.rx.ry.width.height.points.offset.stop-color.stop-opacity.fill-opacity.stroke-opacity.stroke-miterlimit.fill-rule.clip-rule.vector-effect.preserveAspectRatio.transform.clip-path.id.href.xlink:href.xmlns:xlink.gradientUnits.gradientTransform`.split(`.`)),li=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),ui=new Set([...ci].map(e=>e.toLowerCase())),di=new Set([...Q].map(e=>e.toLowerCase()));function fi(e){return ui.has(e.toLowerCase())}function pi(e){return di.has(e.toLowerCase())}function mi(e){if(typeof e!=`string`)return null;let t=e.trim();if(!t||t.length>8192||!/^<svg[\s>]/.test(t.startsWith(`<?xml`)?t.slice(t.indexOf(`?>`)+2).trimStart():t))return null;if(typeof DOMParser>`u`)return/<script[\s>]/i.test(t)||/\son\w+\s*=/i.test(t)||/javascript\s*:/i.test(t)?null:t;let n=new DOMParser().parseFromString(t,`image/svg+xml`);if(n.querySelector(`parsererror`))return null;let r=n.documentElement;if(r.tagName.toLowerCase()!==`svg`)return null;let i=e=>{for(let t of Array.from(e.children)){let e=t.tagName.toLowerCase();if(!fi(e)){li.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of Array.from(t.attributes)){let n=e.name.toLowerCase();(!pi(n)||/^on/i.test(n)||/^(javascript|data|vbscript):/i.test(e.value.trim()))&&t.removeAttribute(e.name)}i(t)}};for(let e of Array.from(r.attributes)){let t=e.name.toLowerCase();(!pi(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function hi({icon:e,iconSvg:t,className:n}){let r=mi(t);return r?(0,X.jsx)(`span`,{className:n??`plugin-icon-svg`,"aria-hidden":!0,dangerouslySetInnerHTML:{__html:r}}):e?(0,X.jsx)(`span`,{className:n?`${n} plugin-icon-glyph`:`plugin-icon-glyph`,"aria-hidden":!0,children:e}):null}var gi=`pi-web-ui:cost-currency`,_i=null,vi=0,yi=new Set;function bi(){vi+=1;for(let e of[...yi])try{e()}catch{}}function xi(e){return yi.add(e),()=>{yi.delete(e)}}function Si(){return vi}function Ci(e){return!Number.isFinite(e)||e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}function wi(){try{if(typeof localStorage<`u`){let e=localStorage.getItem(gi);if(typeof e==`string`&&e.trim().length>0)return e.trim().slice(0,8)}}catch{}return`$`}function Ti(e){try{if(typeof localStorage<`u`){let t=typeof e==`string`?e.trim().slice(0,8):``;!t||t===`$`?localStorage.removeItem(gi):localStorage.setItem(gi,t)}}catch{}bi()}function Ei(e){return typeof e==`function`?(_i=e,bi(),()=>{_i===e&&(_i=null,bi())}):(_i=null,bi(),()=>{})}function Di(e,t){let n=String(e??``).trim();if(!n)return{symbol:t,value:`0`};let r=n.match(/^([^\d<>+-]+)\s*(.+)$/);return r?{symbol:r[1],value:r[2]}:{symbol:``,value:n}}function Oi(e,t){let n=typeof e==`number`&&Number.isFinite(e)?e:0,r=wi(),i=typeof t?.fixedDigits==`number`?n.toFixed(t.fixedDigits):Ci(n);if(_i)try{let e=_i(n,{defaultSymbol:r,defaultValue:i});if(typeof e==`string`)return Di(e,r);if(e&&typeof e==`object`&&typeof e.value==`string`)return{symbol:typeof e.symbol==`string`?e.symbol:r,value:e.value,tooltip:typeof e.tooltip==`string`?e.tooltip:void 0}}catch(e){console.error(`[cost-format] custom cost formatter threw:`,e)}return{symbol:r,value:i}}function ki(e,t){return(0,g.useSyncExternalStore)(xi,Si,Si),Oi(e,t)}var Ai={projects:`host:lp-projects`,convs:`host:lp-running`,sessions:`host:lp-history`},ji=[`projects`,`convs`,`sessions`],Mi=new Map(Object.keys(Ai).map(e=>[Ai[e],e])),Ni=`plugin:`;function Pi(e){return e.startsWith(Ni)&&e.length>7}function Fi(e){let t=[],n=new Set;for(let r of e??[]){let e=null,i,a=Mi.get(r.id);a?e=a:r.source?.startsWith(`plugin:`)&&r.kind===`view`&&(e=`${Ni}${r.id}`,i=r),e&&!n.has(e)&&(n.add(e),t.push({key:e,shown:!r.hidden,...i?{entry:i}:{}}))}for(let e of ji)n.has(e)||t.push({key:e,shown:!0});return t}function Ii(e,t){return e.filter(e=>e.shown&&t(e.key)).map(e=>e.key)}function Li(e,t){let n=[];for(let r=0;r+1<e.length;r++){let i=e[r],a=e[r+1];!t(i)&&!t(a)&&n.push([i,a])}return n}function Ri(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(!r||typeof r!=`object`||Array.isArray(r))return n;for(let[e,i]of Object.entries(r))(e in t||Pi(e))&&typeof i==`number`&&Number.isFinite(i)&&i>0&&(n[e]=i)}catch{}return n}var zi=new Set([`view`,`action`,`badge`,`menu`,`page`,`organizer`,`divider`,`toggle`,`input`,`progress`,`select`]),Bi=new Set([`disabled`,`always`,`never`,`file.isDir`,`file.isFile`,`session.isRunning`,`message.hasSelection`]),Vi=`topbar.primary,topbar.overflow,notice.actions,leftpanel.sections,leftpanel.projects.actions,leftpanel.project,leftpanel.running.actions,leftpanel.running,leftpanel.history.actions,leftpanel.history,leftpanel.sessions,chat.header,chat.empty,message.actions,goalbar.actions,composer.leading,composer.actions,rightpanel.tabs,terminal.toolbar,scm.toolbar,bottombar,file.preview.toolbar,contextmenu.topbar,contextmenu.message,contextmenu.session,contextmenu.project,contextmenu.file,contextmenu.toolcall,settings.pages,tasks.panel,modal.dialog,sidebar.left,sidebar.right`.split(`,`),Hi=Vi.map(e=>({slot:e,cardinality:`list`}));function Ui(e){return Hi.find(t=>t.slot===e)?.cardinality??`list`}function Wi(e,t){if(t===`list`)return{entries:[...e],conflicts:[]};let n=e.findIndex(e=>!e.hidden);if(n<0)return{entries:[...e],conflicts:[]};let r=e.filter((e,t)=>t!==n&&!e.hidden);return{entries:e.map((e,t)=>t===n||e.hidden?e:{...e,hidden:!0}),winner:e[n],conflicts:r}}var Gi=[{id:`host:lp-projects`,slot:`leftpanel.sections`,labelKey:`recentProjects`,icon:`folder`,kind:`action`,order:10},{id:`host:lp-running`,slot:`leftpanel.sections`,labelKey:`runningConversations`,icon:`activity`,kind:`action`,order:20},{id:`host:lp-history`,slot:`leftpanel.sections`,labelKey:`historySessions`,icon:`clock`,kind:`action`,order:30},{id:`host:brand`,slot:`topbar.primary`,labelKey:`brand`,kind:`badge`,order:1,group:`brand`},{id:`host:open-project`,slot:`topbar.primary`,labelKey:`openProject`,icon:`folder`,kind:`action`,order:3,group:`primary`},{id:`host:history`,slot:`topbar.primary`,labelKey:`openHistory`,icon:`menu`,kind:`action`,order:0,group:`panels`},{id:`host:files`,slot:`topbar.primary`,labelKey:`openFiles`,icon:`folder`,kind:`action`,order:97,group:`panels`,align:`end`},{id:`host:new-chat`,slot:`topbar.primary`,labelKey:`newChat`,icon:`plus`,kind:`action`,order:96,group:`primary`,align:`end`},{id:`host:new-ephemeral-chat`,slot:`topbar.primary`,labelKey:`newChatEphemeral`,icon:`chat`,kind:`action`,order:96.5,group:`primary`,align:`end`},{id:`host:chat`,slot:`topbar.primary`,labelKey:`chat`,icon:`chat`,kind:`view`,view:`chat`,order:20,group:`views`,align:`end`},{id:`host:terminal`,slot:`topbar.primary`,labelKey:`terminal`,icon:`terminal`,kind:`view`,view:`terminal`,order:21,group:`views`,align:`end`},{id:`host:git`,slot:`topbar.primary`,labelKey:`scmTab`,icon:`git`,kind:`view`,view:`git`,order:22,group:`views`,align:`end`},{id:`host:plugins`,slot:`topbar.primary`,labelKey:`pluginMenuTitle`,icon:`🧩`,kind:`action`,order:24,group:`views`,align:`end`},{id:`host:search`,slot:`topbar.primary`,labelKey:`searchGlobal`,icon:`search`,kind:`action`,order:40,group:`tools`,align:`end`},{id:`host:browser`,slot:`topbar.primary`,labelKey:`browserControl`,icon:`browser`,kind:`action`,order:41,group:`tools`,align:`end`,hidden:!0},{id:`host:tasks`,slot:`topbar.primary`,labelKey:`bgTasks`,icon:`layers`,kind:`action`,order:42,group:`tools`,align:`end`},{id:`host:settings`,slot:`topbar.primary`,labelKey:`settingsTitle`,icon:`settings`,kind:`action`,order:60,group:`system`,align:`end`},{id:`host:sound`,slot:`topbar.primary`,labelKey:`sound`,icon:`sound`,kind:`action`,order:70,group:`system`,hidden:!0,align:`end`},{id:`host:language`,slot:`topbar.primary`,labelKey:`language`,icon:`globe`,kind:`action`,order:80,group:`system`,hidden:!0,align:`end`},{id:`host:theme`,slot:`topbar.primary`,labelKey:`theme`,icon:`sun`,kind:`action`,order:82,group:`system`,hidden:!0,align:`end`},{id:`host:update`,slot:`topbar.primary`,labelKey:`update`,icon:`download`,kind:`action`,order:90,group:`system`,align:`end`,hidden:!0},{id:`host:github`,slot:`topbar.primary`,labelKey:`githubRepo`,icon:`github`,kind:`action`,order:200,group:`system`,align:`end`,hidden:!0},{id:`host:conn`,slot:`bottombar`,labelKey:`connected`,icon:`dot`,kind:`badge`,order:5,group:`status`},{id:`host:engine`,slot:`bottombar`,labelKey:`engineBadge`,icon:`cpu`,kind:`badge`,order:6,group:`status`},{id:`host:ctx`,slot:`bottombar`,labelKey:`context`,icon:`gauge`,kind:`badge`,order:10,group:`usage`},{id:`host:cost`,slot:`bottombar`,labelKey:`cumulativeCost`,icon:`coins`,kind:`badge`,order:11,group:`usage`},{id:`host:cache`,slot:`bottombar`,labelKey:`cacheHit`,icon:`database`,kind:`badge`,order:12,group:`usage`},{id:`host:msg-count`,slot:`bottombar`,labelKey:`messages`,icon:`message`,kind:`badge`,order:13,group:`usage`},{id:`host:plugin-status`,slot:`bottombar`,labelKey:`pluginStatus`,icon:`activity`,kind:`badge`,order:14,group:`status`},{id:`host:working`,slot:`bottombar`,labelKey:`working`,icon:`activity`,kind:`badge`,order:15,group:`status`},{id:`host:status-delegate`,slot:`bottombar`,labelKey:`delegateModeBadge`,icon:`eye`,kind:`badge`,order:16,group:`status`},{id:`host:host-metrics`,slot:`bottombar`,labelKey:`hostResources`,icon:`cpu`,kind:`badge`,order:19,group:`host`,align:`end`},{id:`host:cwd`,slot:`bottombar`,labelKey:`cwdTip`,icon:`folder`,kind:`action`,order:20,group:`context`,align:`end`},{id:`host:msg-reask`,slot:`message.actions`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,order:9},{id:`host:msg-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{id:`host:msg-fork`,slot:`message.actions`,labelKey:`forkSession`,icon:`branch`,kind:`action`,order:15},{id:`host:msg-rollback`,slot:`message.actions`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,order:16},{id:`host:msg-copy`,slot:`message.actions`,labelKey:`copyMessage`,icon:`copy`,kind:`action`,order:20},{id:`host:msg-copy-text`,slot:`message.actions`,labelKey:`copyText`,icon:`text`,kind:`action`,order:21},{id:`host:msg-copy-markdown`,slot:`message.actions`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,order:22},{id:`host:msg-copy-image`,slot:`message.actions`,labelKey:`copyImage`,icon:`image`,kind:`action`,order:23},{id:`host:msg-speak`,slot:`message.actions`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,order:24},{id:`host:composer-upload`,slot:`composer.actions`,labelKey:`uploadFile`,icon:`upload`,kind:`action`,order:10,align:`start`},{id:`host:composer-templates`,slot:`composer.actions`,labelKey:`tpl.openPicker`,icon:`grid`,kind:`action`,order:110,align:`start`},{id:`host:composer-model`,slot:`composer.actions`,labelKey:`selectModel`,icon:`cpu`,kind:`action`,order:120,align:`start`},{id:`host:composer-thinking`,slot:`composer.actions`,labelKey:`thinkingLevel`,icon:`zap`,kind:`action`,order:130,align:`start`},{id:`host:composer-dsh-perm`,slot:`composer.actions`,labelKey:`dshPerm`,icon:`lock`,kind:`action`,order:140,align:`start`},{id:`host:composer-dsh-preset`,slot:`composer.actions`,labelKey:`dshPreset`,icon:`layers`,kind:`action`,order:150,align:`start`},{id:`host:composer-send`,slot:`composer.actions`,labelKey:`sendTip`,icon:`send`,kind:`action`,order:200,align:`end`},{id:`host:fp-md`,slot:`file.preview.toolbar`,labelKey:`showMarkdownPreview`,icon:`eye`,kind:`action`,order:10},{id:`host:fp-toc`,slot:`file.preview.toolbar`,labelKey:`previewTocLabel`,icon:`list`,kind:`action`,order:15},{id:`host:fp-html`,slot:`file.preview.toolbar`,labelKey:`showHtmlPreview`,icon:`code`,kind:`action`,order:20},{id:`host:fp-edit`,slot:`file.preview.toolbar`,labelKey:`editFile`,icon:`edit`,kind:`action`,order:30},{id:`host:fp-wrap`,slot:`file.preview.toolbar`,labelKey:`enableWrap`,icon:`wrap`,kind:`action`,order:40},{id:`host:fp-zoom`,slot:`file.preview.toolbar`,labelKey:`zoomIn`,icon:`zoom`,kind:`action`,order:50},{id:`host:fp-ref`,slot:`file.preview.toolbar`,labelKey:`referenceTip`,icon:`link`,kind:`action`,order:70},{id:`host:fp-full`,slot:`file.preview.toolbar`,labelKey:`fullscreen`,icon:`maximize`,kind:`action`,order:80},{id:`host:fp-close`,slot:`file.preview.toolbar`,labelKey:`close`,icon:`x`,kind:`action`,order:90},{id:`host:goal-pill`,slot:`goalbar.actions`,labelKey:`goalBarTitle`,icon:`target`,kind:`action`,order:5},{id:`host:goal-set`,slot:`goalbar.actions`,labelKey:`goalBarSet`,icon:`check`,kind:`action`,order:10},{id:`host:goal-wizard`,slot:`goalbar.actions`,labelKey:`goalWizardBtn`,icon:`search`,kind:`action`,order:20},{id:`host:goal-lock`,slot:`goalbar.actions`,labelKey:`goalBarLocked`,icon:`lock`,kind:`action`,order:30},{id:`host:goal-plan`,slot:`goalbar.actions`,labelKey:`planMode`,icon:`list`,kind:`action`,order:25},{id:`host:goal-collapse`,slot:`goalbar.actions`,labelKey:`collapsePanel`,icon:`chevron-up`,kind:`action`,order:40},{id:`host:goal-model`,slot:`goalbar.actions`,labelKey:`goalBarReviewModel`,icon:`cpu`,kind:`action`,order:50},{id:`host:goal-rounds`,slot:`goalbar.actions`,labelKey:`goalBarMaxRounds`,icon:`hash`,kind:`action`,order:60},{id:`host:goal-execmodel`,slot:`goalbar.actions`,labelKey:`goalBarExecModel`,icon:`cpu`,kind:`action`,order:55},{id:`host:goal-openrole`,slot:`goalbar.actions`,labelKey:`goalBarOpenExec`,icon:`search`,kind:`action`,order:65},{id:`host:goal-clear`,slot:`goalbar.actions`,labelKey:`goalBarClear`,icon:`x`,kind:`action`,order:70},{id:`host:scm-changes`,slot:`scm.toolbar`,labelKey:`scmChanges`,icon:`file`,kind:`action`,order:10},{id:`host:scm-history`,slot:`scm.toolbar`,labelKey:`scmHistory`,icon:`clock`,kind:`action`,order:20},{id:`host:scm-refresh`,slot:`scm.toolbar`,labelKey:`scmRefreshTip`,icon:`refresh`,kind:`action`,order:30},{id:`host:scm-branch`,slot:`scm.toolbar`,labelKey:`scmSwitchBranch`,icon:`git`,kind:`action`,order:40},{id:`host:scm-switch`,slot:`scm.toolbar`,labelKey:`scmSwitch`,icon:`git`,kind:`action`,order:50},{id:`host:scm-push`,slot:`scm.toolbar`,labelKey:`scmPush`,icon:`upload`,kind:`action`,order:60},{id:`host:scm-pull`,slot:`scm.toolbar`,labelKey:`scmPull`,icon:`download`,kind:`action`,order:70},{id:`host:scm-input`,slot:`scm.toolbar`,labelKey:`scmCommitPlaceholder`,icon:`edit`,kind:`action`,order:80},{id:`host:scm-genmsg`,slot:`scm.toolbar`,labelKey:`scmGenMsg`,icon:`cpu`,kind:`action`,order:85},{id:`host:scm-commit`,slot:`scm.toolbar`,labelKey:`scmCommit`,icon:`check`,kind:`action`,order:90},{id:`host:scm-commit-all`,slot:`scm.toolbar`,labelKey:`scmCommitAll`,icon:`check`,kind:`action`,order:100},{id:`host:scm-term`,slot:`scm.toolbar`,labelKey:`terminal`,icon:`terminal`,kind:`action`,order:110},{id:`host:term-cmd-refresh`,slot:`terminal.toolbar`,labelKey:`rerun`,icon:`refresh`,kind:`action`,order:10},{id:`host:term-cmd-new`,slot:`terminal.toolbar`,labelKey:`newCommand`,icon:`plus`,kind:`action`,order:20},{id:`host:term-tab-new`,slot:`terminal.toolbar`,labelKey:`newTerminal`,icon:`plus`,kind:`action`,order:30},{id:`host:right-files`,slot:`rightpanel.tabs`,labelKey:`openFiles`,icon:`folder`,kind:`view`,view:`files`,order:10},{id:`host:conv-rename`,slot:`contextmenu.session`,labelKey:`renameSession`,icon:`edit`,kind:`action`,context:`session`,order:1},{id:`host:conv-pin`,slot:`contextmenu.session`,labelKey:`pinConversation`,icon:`pin`,kind:`action`,context:`session`,order:2},{id:`host:conv-takeover`,slot:`contextmenu.session`,labelKey:`takeoverConversation`,icon:`chat`,kind:`action`,context:`session`,order:5},{id:`host:conv-dismiss-subagents`,slot:`contextmenu.session`,labelKey:`dismissFinishedSubagents`,icon:`x`,kind:`action`,context:`session`,order:10},{id:`host:conv-force-dismiss`,slot:`contextmenu.session`,labelKey:`forceDismissConversation`,icon:`x`,kind:`action`,context:`session`,order:20},{id:`host:conv-persist`,slot:`contextmenu.session`,labelKey:`persistSubagent`,icon:`save`,kind:`action`,context:`session`,order:25},{id:`host:conv-copy-id`,slot:`contextmenu.session`,labelKey:`copyConversationId`,icon:`copy`,kind:`action`,context:`session`,order:30},{id:`host:conv-copy-path`,slot:`contextmenu.session`,labelKey:`copyConversationPath`,icon:`copy`,kind:`action`,context:`session`,order:40},{id:`host:conv-copy-link`,slot:`contextmenu.session`,labelKey:`copyConversationLink`,icon:`link`,kind:`action`,context:`session`,order:45},{id:`host:conv-quote`,slot:`contextmenu.session`,labelKey:`quoteConversation`,icon:`chat`,kind:`action`,context:`session`,order:50},{id:`host:file-open`,slot:`contextmenu.file`,labelKey:`fileOpenPreview`,icon:`open`,kind:`action`,context:`file`,order:11,group:`open`},{id:`host:file-enter`,slot:`contextmenu.file`,labelKey:`fileEnterDir`,icon:`folder`,kind:`action`,context:`file`,order:12,group:`open`},{id:`host:file-download`,slot:`contextmenu.file`,labelKey:`downloadFile`,icon:`download`,kind:`action`,context:`file`,order:13,group:`open`},{id:`host:file-compress`,slot:`contextmenu.file`,labelKey:`fileCompress`,icon:`file`,kind:`action`,context:`file`,order:16,group:`archive`},{id:`host:file-extract`,slot:`contextmenu.file`,labelKey:`fileExtract`,icon:`folder`,kind:`action`,context:`file`,order:17,group:`archive`},{id:`host:file-compress-download`,slot:`contextmenu.file`,labelKey:`fileCompressDownload`,icon:`download`,kind:`action`,context:`file`,order:18,group:`archive`},{id:`host:file-upload-folder`,slot:`contextmenu.file`,labelKey:`fileUploadFolder`,icon:`upload`,kind:`action`,context:`file`,order:25,group:`new`},{id:`host:file-open-project`,slot:`contextmenu.file`,labelKey:`openAsProject`,icon:`folder`,kind:`action`,context:`file`,order:14,group:`open`},{id:`host:file-add-root`,slot:`contextmenu.file`,labelKey:`addWorkspaceRoot`,icon:`folder`,kind:`action`,context:`file`,order:15,group:`open`},{id:`host:file-reveal`,slot:`contextmenu.file`,labelKey:`fileReveal`,icon:`folder`,kind:`action`,context:`file`,order:16,group:`open`},{id:`host:file-open-default`,slot:`contextmenu.file`,labelKey:`fileOpenDefault`,icon:`open`,kind:`action`,context:`file`,order:17,group:`open`},{id:`host:file-new-file`,slot:`contextmenu.file`,labelKey:`fileNewFile`,icon:`file`,kind:`action`,context:`file`,order:21,group:`new`},{id:`host:file-new-dir`,slot:`contextmenu.file`,labelKey:`fileNewDir`,icon:`folder`,kind:`action`,context:`file`,order:22,group:`new`},{id:`host:file-upload`,slot:`contextmenu.file`,labelKey:`uploadToFolder`,icon:`upload`,kind:`action`,context:`file`,order:23,group:`new`},{id:`host:file-paste`,slot:`contextmenu.file`,labelKey:`filePaste`,icon:`paste`,kind:`action`,context:`file`,order:24,group:`new`},{id:`host:file-attach-ref`,slot:`contextmenu.file`,labelKey:`referenceTip`,icon:`link`,kind:`action`,context:`file`,order:32,group:`chat`},{id:`host:file-attach-folder`,slot:`contextmenu.file`,labelKey:`linkFolderTip`,icon:`link`,kind:`action`,context:`file`,order:33,group:`chat`},{id:`host:file-rename`,slot:`contextmenu.file`,labelKey:`fileRename`,icon:`edit`,kind:`action`,context:`file`,order:41,group:`edit`},{id:`host:file-duplicate`,slot:`contextmenu.file`,labelKey:`fileDuplicate`,icon:`copy`,kind:`action`,context:`file`,order:42,group:`edit`},{id:`host:file-cut`,slot:`contextmenu.file`,labelKey:`fileCut`,icon:`cut`,kind:`action`,context:`file`,order:43,group:`edit`},{id:`host:file-copy`,slot:`contextmenu.file`,labelKey:`fileCopyEntry`,icon:`copy`,kind:`action`,context:`file`,order:44,group:`edit`},{id:`host:file-copy-name`,slot:`contextmenu.file`,labelKey:`copyName`,icon:`copy`,kind:`action`,context:`file`,order:51,group:`clipboard`},{id:`host:file-copy-path`,slot:`contextmenu.file`,labelKey:`copyPath`,icon:`copy`,kind:`action`,context:`file`,order:52,group:`clipboard`},{id:`host:file-copy-rel`,slot:`contextmenu.file`,labelKey:`fileCopyRelPath`,icon:`copy`,kind:`action`,context:`file`,order:53,group:`clipboard`},{id:`host:file-refresh`,slot:`contextmenu.file`,labelKey:`fileRefresh`,icon:`refresh`,kind:`action`,context:`file`,order:54,group:`clipboard`},{id:`host:file-delete`,slot:`contextmenu.file`,labelKey:`fileDelete`,icon:`trash`,kind:`action`,context:`file`,order:61,group:`danger`},{id:`host:msg-ctx-copy-markdown`,slot:`contextmenu.message`,labelKey:`copyMarkdown`,icon:`markdown`,kind:`action`,context:`message`,order:10,group:`copy`},{id:`host:msg-ctx-copy-text`,slot:`contextmenu.message`,labelKey:`copyText`,icon:`text`,kind:`action`,context:`message`,order:11,group:`copy`},{id:`host:msg-ctx-copy-image`,slot:`contextmenu.message`,labelKey:`copyImage`,icon:`image`,kind:`action`,context:`message`,order:12,group:`copy`},{id:`host:msg-ctx-copy-link`,slot:`contextmenu.message`,labelKey:`copyMessageLink`,icon:`link`,kind:`action`,context:`message`,order:13,group:`copy`},{id:`host:msg-ctx-reask`,slot:`contextmenu.message`,labelKey:`reaskDirectly`,icon:`refresh`,kind:`action`,context:`message`,order:19,group:`action`},{id:`host:msg-ctx-edit-reask`,slot:`contextmenu.message`,labelKey:`editReask`,icon:`edit`,kind:`action`,context:`message`,order:20,group:`action`},{id:`host:msg-ctx-fork`,slot:`contextmenu.message`,labelKey:`forkSession`,icon:`branch`,kind:`action`,context:`message`,order:21,group:`action`},{id:`host:msg-ctx-rollback`,slot:`contextmenu.message`,labelKey:`rollbackSession`,icon:`undo`,kind:`action`,context:`message`,order:22,group:`action`},{id:`host:msg-ctx-speak`,slot:`contextmenu.message`,labelKey:`speakMsg`,icon:`volume`,kind:`action`,context:`message`,order:23,group:`action`},{id:`host:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],Ki=`__view`,qi=new Set([`host:settings`,`host:history`,`host:files`]),Ji=new Set([`host:history`,`host:files`]);function Yi(e){return`${e}:${Ki}`}function Xi(e){return e.source.startsWith(`plugin:`)?e.id===Yi(e.source.slice(7)):!1}function Zi(e,t,n){let r=Yi(t),i=(e?.hidden??[]).filter(e=>e!==r),a=(e?.shown??[]).filter(e=>e!==r);return n?a.push(r):i.push(r),{...e,hidden:i,shown:a}}function Qi(e,t){let n=t.map(Yi),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var $i=`host:brand`,ea=[`host:brand-logo`,`host:brand-name`];function ta(e){if(!((e.hidden??[]).some(e=>ea.includes(e))||(e.shown??[]).some(e=>ea.includes(e))||(e.order??[]).some(e=>ea.includes(e))||ea.some(t=>e.align?.[t]!==void 0)||ea.some(t=>e.groups?.[t]!==void 0)||ea.some(t=>e.labels?.[t]!==void 0)||ea.some(t=>e.slots?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=ea.includes(n)?$i:n;t.includes(e)||t.push(e)}return t},n=(e,t)=>{if(!e)return;let n={};for(let[t,r]of Object.entries(e))ea.includes(t)||(n[t]=r);if(n[$i]===void 0){let r=t?e[ea[0]]??e[ea[1]]:e[ea[1]]??e[ea[0]];r!==void 0&&(n[$i]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))ea.includes(n)||(t[n]=r);if(t[$i]===void 0){let n=e[ea[0]]??e[ea[1]];n!==void 0&&(t[$i]=n)}return t},i=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))ea.includes(n)||(t[n]=r);if(t[$i]===void 0){let n=e[ea[0]]??e[ea[1]];n!==void 0&&(t[$i]=n)}return t};return{...e,...e.hidden?{hidden:t(e.hidden)}:{},...e.shown?{shown:t(e.shown)}:{},...e.order?{order:t(e.order)}:{},...e.groups?{groups:n(e.groups,!0)}:{},...e.labels?{labels:n(e.labels,!1)}:{},...e.align?{align:r(e.align)}:{},...e.slots?{slots:i(e.slots)}:{}}}function na(e){return e.map(e=>{if(e.view===!1)return e;let t=e.ui?.items??[];if(t.some(e=>e.id===`__view`))return e;let n={id:Ki,slot:`topbar.primary`,label:e.name,...e.icon?{icon:e.icon}:{},...e.iconSvg?{iconSvg:e.iconSvg}:{},kind:`view`,view:`plugin:${e.id}`,order:23,align:`end`,hidden:!0};return{...e,ui:{items:[...t,n],arrange:e.ui?.arrange??[]}}})}function ra(e){return typeof e==`string`&&Vi.includes(e)}function ia(e,t){return t?e.label:e.labelEn??e.label}function aa(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function oa(e,t,n,r,i){let a=`${e}#${r.id}`,o=sa(a,t,n,r.children,i),s=aa(r,i),c=ca(r.options,i);return{id:a,slot:t,source:n,label:ia(r,i),labelExplicit:!0,...r.icon?{icon:r.icon}:{},...r.iconSvg?{iconSvg:r.iconSvg}:{},...s?{hint:s}:{},kind:r.kind??`action`,...r.action?{action:r.action}:{},...r.view?{view:r.view}:{},...r.group?{group:r.group}:{},order:r.order??100,align:`start`,hidden:r.hidden??!1,...r.badge?{badge:r.badge}:{},...r.when?{when:r.when}:{},...c?{options:c}:{},...o.length>0?{children:o}:{},userOverrides:[],arrangedBy:[]}}function sa(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:oa(e,t,n,r,i),index:a})).sort((e,t)=>e.entry.order===t.entry.order?e.index-t.index:e.entry.order-t.entry.order).map(e=>e.entry):[]}function ca(e,t){if(e?.length)return e.slice(0,32).map(e=>({value:e.value,label:t?e.label??e.labelEn??e.value:e.labelEn??e.label??e.value}))}function la(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function ua(e,t,n,r,i,a){let o=sa(e,t,n,r.children,i),s=aa(r,i),c=la(r.progress),l=ca(r.options,i);return{id:e,slot:t,source:n,label:ia(r,i),labelExplicit:!0,...r.icon?{icon:r.icon}:{},...r.iconSvg?{iconSvg:r.iconSvg}:{},...s?{hint:s}:{},kind:r.kind??(t===`settings.pages`?`page`:`action`),...r.action?{action:r.action}:{},...r.view?{view:r.view}:{},...r.group?{group:r.group}:{},order:r.order??100,align:r.align??`start`,hidden:r.hidden??!1,...r.badge?{badge:r.badge}:{},...typeof r.checked==`boolean`?{checked:r.checked}:{},...typeof r.value==`string`?{value:r.value}:{},...c===void 0?{}:{progress:c},...l?{options:l}:{},...r.when?{when:r.when}:{},...o.length>0?{children:o}:{},userOverrides:[],arrangedBy:[],seq:a}}function da(e,t){return[...e].sort((e,n)=>{let r=t.get(e.id),i=t.get(n.id);return r!==void 0||i!==void 0?r!==void 0&&i!==void 0?r-i:r===void 0?1:-1:e.order===n.order?e.seq-n.seq:e.order-n.order})}function fa(e,t){let n=e.filter(e=>Xi(e)&&!t.has(e.id));if(n.length===0)return e;let r=e.filter(e=>!Xi(e)||t.has(e.id)),i=[`host:git`,`host:terminal`,`host:chat`].map(e=>r.findIndex(t=>t.id===e)).find(e=>e>=0)??-1,a=r.findIndex(e=>e.id===`host:plugins`),o=i+1;return a>=o&&(o=a),o=Math.max(0,Math.min(o,r.length)),[...r.slice(0,o),...n,...r.slice(o)]}function pa(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=ta(t.layout??{}),a=e=>{t.diagnostics?.push({level:e.level??`warn`,...e})},o=new Map,s=0;for(let e of Gi)o.set(e.id,{id:e.id,slot:e.slot,source:`host`,label:t.t(e.labelKey),labelKey:e.labelKey,...e.icon?{icon:e.icon}:{},kind:e.kind,...e.view?{view:e.view}:{},...e.group?{group:e.group}:{},order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[],seq:s++});for(let t of e){if(r.has(t.id)){a({pluginId:t.id,message:`plugin "${t.id}" is disabled by the user — its ${t.ui?.items?.length??0} UI item(s) are not rendered`});continue}if(t.error){a({level:`error`,pluginId:t.id,message:`plugin "${t.id}" failed to activate (${t.error}) — its UI items are not rendered`});continue}let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!ra(r.slot)){a({pluginId:t.id,entryId:r.id,message:`item "${t.id}:${r.id}" declares unknown slot "${String(r.slot)}" — dropped (valid slots: see docs/architecture-plugins.md)`});continue}if(r.slot===`leftpanel.sections`&&r.kind!==`view`){a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" targets leftpanel.sections: only kind="view" (a plugin section) is accepted — dropped`});continue}if(r.kind&&!zi.has(r.kind)&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares unknown kind "${r.kind}" — the render layer falls back to a plain button`}),Array.isArray(r.when))for(let e of r.when)Bi.has(e)||a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" declares when:"${e}" which the host does not know — it is ignored (the item still renders)`});else r.when!==void 0&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item "${t.id}:${r.id}" has a non-array "when" — ignored`});let i=`${t.id}:${r.id}`,c=o.get(i);c&&a({pluginId:t.id,entryId:r.id,slot:r.slot,message:`item id "${r.id}" is declared more than once — the later declaration wins (order/visibility are inherited from the first)`}),o.set(i,ua(i,r.slot,e,r,n,c?.seq??s++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[]){let n=o.get(e.id);ha(o,e,t.id),n||a({pluginId:t.id,entryId:e.id,message:`arrange target "${e.id}" does not exist — op ignored (is the providing plugin installed / not disabled?)`})}let c=new Map,l=(e,t)=>{let n=c.get(e)??[];n.includes(t)||n.push(t),c.set(e,n)};for(let e of i.hidden??[]){let t=o.get(e);t&&(t.hidden=!0,l(e,`hidden`))}for(let e of i.shown??[]){let t=o.get(e);t&&(t.hidden=!1,l(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=o.get(e);n&&(n.group=t,l(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=o.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,l(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=o.get(e);n&&(n.label=t,n.labelExplicit=!0,l(e,`label`))}for(let[e,t]of Object.entries(i.slots??{})){let n=o.get(e);n&&ra(t)&&n.slot!==t&&(n.movedFrom=n.movedFrom??n.slot,n.slot=t,l(e,`slot`))}for(let e of qi){let t=o.get(e);t&&(i.slots?.[e]||(t.slot=`topbar.primary`),t.hidden=!1)}let u=new Map;(i.order??[]).forEach((e,t)=>{o.has(e)&&(u.has(e)||u.set(e,t),l(e,`order`))});for(let e of Object.values(Ai)){let t=o.get(e);t&&t.slot!==`leftpanel.sections`&&(a({entryId:e,slot:t.slot,message:`"${e}" must stay in leftpanel.sections — the move is ignored`}),t.slot=`leftpanel.sections`,delete t.movedFrom)}let d=new Map;for(let e of Vi)d.set(e,[]);for(let e of o.values())d.get(e.slot)?.push(e);let f={};for(let e of Vi){let t=da(d.get(e)??[],u),n=Wi(e===`topbar.primary`?fa(t,u):t,Ui(e));if(n.winner&&n.conflicts.length>0)for(let t of n.conflicts)a({level:`error`,pluginId:t.source.startsWith(`plugin:`)?t.source.slice(7):void 0,entryId:t.id,slot:e,message:`slot "${e}" is single-cardinality; "${n.winner.id}" won and "${t.id}" was hidden`});f[e]=n.entries.map(e=>ma(e,c.get(e.id)??[]))}return f}function ma(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function ha(e,t,n){let r=e.get(t.id);if(!r)return;let i=!1;t.hide!==void 0&&(r.hidden=t.hide,i=!0),t.group!==void 0&&(r.group=t.group,i=!0),t.order!==void 0&&(r.order=t.order,i=!0),t.align!==void 0&&(r.align=t.align,i=!0),t.label!==void 0&&(r.label=t.label,r.labelExplicit=!0,i=!0),t.hint!==void 0&&(r.hint=t.hint,i=!0),t.icon!==void 0&&(r.icon=t.icon,i=!0),t.iconSvg!==void 0&&(r.iconSvg=t.iconSvg||void 0,i=!0),t.slot!==void 0&&ra(t.slot)&&t.slot!==r.slot&&(r.movedFrom=r.movedFrom??r.slot,r.slot=t.slot,i=!0),i&&r.source!==`plugin:${n}`&&!r.arrangedBy.includes(n)&&r.arrangedBy.push(n)}function ga(e){let t=[],n=[],r=[];for(let i of e)i.align===`end`?r.push(i):i.align===`center`?n.push(i):t.push(i);return{start:t,center:n,end:r}}function _a(e,t){let n=e??{},r={},i=t===$i?[t,...ea]:[t],a=(n.hidden??[]).filter(e=>!i.includes(e)),o=(n.shown??[]).filter(e=>!i.includes(e)),s=(n.order??[]).filter(e=>!i.includes(e));a.length>0&&(r.hidden=a),o.length>0&&(r.shown=o),s.length>0&&(r.order=s);let c=ya(n.groups,t),l=ya(n.labels,t),u=ya(n.align,t),d=ya(n.slots,t);if(t===$i)for(let e of ea)c=ya(c,e),l=ya(l,e),u=ya(u,e),d=ya(d,e);return c&&(r.groups=c),l&&(r.labels=l),u&&(r.align=u),d&&(r.slots=d),n.topbarText!==void 0&&(r.topbarText=n.topbarText),n.sideDockFloat!==void 0&&(r.sideDockFloat=n.sideDockFloat),r}function va(){return{}}function ya(e,t){if(!e)return;let n={},r=!1;for(let[i,a]of Object.entries(e))i!==t&&(n[i]=a,r=!0);return r?n:void 0}var ba=new Set([`host:files`]);function xa(e,t){let n=e=>e===`center`?1:e===`end`?2:0;return[...e].sort((e,r)=>n(e.align)-n(r.align)||t(e.id)-t(r.id))}function Sa(e,t,n,r,i=new Set){let a=new Set;if(!Number.isFinite(t)||t<=0)return a;let o=e.filter(e=>i.has(e.id)&&e.width>0).reduce((e,t)=>e+t.width+n,0),s=Math.max(0,t-Math.max(0,r)-o),c=0,l=!1;for(let t of e){if(!(t.width>0)||i.has(t.id))continue;let e=t.width+n;if(l||c+e>s){l=!0,a.add(t.id);continue}c+=e}return a}var Ca=null,wa=new Set;function Ta(){for(let e of wa)e()}function Ea(e){Ca={x:Number.isFinite(e.x)?e.x:0,y:Number.isFinite(e.y)?e.y:0,slot:e.slot,target:e.target??{id:``},entries:Array.isArray(e.entries)?e.entries:[],...typeof e.onHostAction==`function`?{onHostAction:e.onHostAction}:{}},Ta()}function Da(){Ca!==null&&(Ca=null,Ta())}function Oa(e){return wa.add(e),()=>{wa.delete(e)}}function ka(){return Ca}function Aa(){return(0,g.useSyncExternalStore)(Oa,ka,ka)}function ja(e){return Number.isFinite(e)?e:0}function Ma(e,t,n,r,i,a){let o=Math.max(0,ja(n)),s=Math.max(0,ja(r)),c=Math.max(8,ja(i)-o-8),l=Math.max(8,ja(a)-s-8);return{x:Math.min(Math.max(8,ja(e)),c),y:Math.min(Math.max(8,ja(t)),l)}}function Na(e,t){let n=String(t?.kind??``);if(e===`contextmenu.file`)return{"file.isDir":n===`dir`||n===`list`&&t?.id!==`@root`,"file.isFile":n===`file`};if(e===`contextmenu.session`)return{"session.isRunning":n===`running`};if(e===`contextmenu.message`){let e=!1;try{let t=window.getSelection?.();e=!!t&&!t.isCollapsed&&t.toString().trim().length>0}catch{e=!1}return{"message.hasSelection":e}}return{}}function Pa(e,t){if(!Array.isArray(e)||e.length===0)return!1;for(let n of e){if(typeof n!=`string`||!n)continue;let e=n.trim();if(e===`disabled`||e===`never`)return!0;if(e!==`always`){if(e.startsWith(`!`)){let n=e.slice(1).trim();if(!n)continue;if(!t||t[n]!==!0)return!0;continue}if(t&&t[e]===!1)return!0}}return!1}function Fa(e,t){return!e||Pa(e.when,t)}function Ia(e){let t=new Map;return{items:(Array.isArray(e)?e:[]).map(e=>{if(!e||e.kind!==`select`||!e.options?.length||e.children?.length)return e;let n=e.options.map((t,n)=>({id:`${e.id}#${n}`,slot:e.slot,source:e.source,label:t.label,kind:`action`,order:100,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}));return n.forEach((n,r)=>t.set(n.id,{parent:e,value:e.options[r].value})),{...e,kind:`menu`,children:n}}),selectParents:t}}function La(e){if(!Array.isArray(e)||e.length===0)return[];let t=e.filter(e=>e&&e.hidden!==!0),n=t.filter(e=>e.kind!==`divider`),r=new Map,i=new Map;n.forEach((e,t)=>{let n=e.group??``;r.has(n)||r.set(n,t);let a=Number.isFinite(e.order)?e.order:100,o=i.get(n);(o===void 0||a<o)&&i.set(n,a)});let a=[...r.keys()].sort((e,t)=>{let n=i.get(e)??100,a=i.get(t)??100;return n===a?(r.get(e)??0)-(r.get(t)??0):n-a}),o=new Map(a.map((e,t)=>[e,t])),s=new Map;n.forEach((e,t)=>s.set(e,t));let c=[...n].sort((e,t)=>{let n=o.get(e.group??``)??0,r=o.get(t.group??``)??0;if(n!==r)return n-r;let i=Number.isFinite(e.order)?e.order:100,a=Number.isFinite(t.order)?t.order:100;return i===a?(s.get(e)??0)-(s.get(t)??0):i-a}),l=new Map;t.forEach((e,n)=>{if(e.kind!==`divider`)return;let r=t.slice(n+1).find(e=>e.kind!==`divider`);if(!r)return;let i=l.get(r)??[];i.push(e),l.set(r,i)});let u=[];for(let e of c){for(let t of l.get(e)??[])u.push(t);u.push(e)}return u}function Ra(e){let t=[],n=null,r=!1;return e.forEach((e,i)=>{if(!e||e.kind===`divider`){r=!0;return}let a=e.group??``;n!==null&&(r||a!==n)&&t.push({kind:`sep`,key:`sep:${i}`}),t.push({kind:`item`,key:`${e.id}#${i}`,index:i,entry:e}),n=a,r=!1}),t}function za(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!Fa(e,t)}function Ba(e,t,n,r){let i=Array.isArray(e)?e.length:0;if(i===0)return-1;let a=n>=0?1:-1,o=Number.isFinite(t)?Math.trunc(t):-1;(o<0||o>=i)&&(o=a>0?-1:i);for(let t=0;t<i;t++)if(o=(o+a+i)%i,za(e[o],r))return o;return-1}var Va={menu:`☰`,folder:`📁`,plus:`+`,chat:`💬`,terminal:`▙`,git:`⎇`,search:`🔍`,browser:`🌐`,layers:`🗂`,settings:`⚙`,sound:`🔊`,globe:`🌍`,sun:`☀`,download:`⤓`,github:`⌗`,x:`✕`,upload:`⬆`,copy:`⧉`,cut:`✂`,paste:`📋`,trash:`🗑`,file:`📄`,open:`↗`,refresh:`⟳`,link:`🔗`,edit:`✎`,dot:`●`,info:`ⓘ`,cpu:`▣`,gauge:`▤`,coins:`◉`,database:`▥`,message:`✉`,activity:`〜`,markdown:`📄`,text:`≡`,image:`🖼`,branch:`⚚`,undo:`↺`,pin:`📌`,volume:`🔊`};function Ha(e){let t=(e??``).trim();return t?Va[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var Ua={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},Wa=new Set;function Ga(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function Ka(e,t){return e.engine===t.engine&&e.managed===t.managed&&e.appVersion===t.appVersion&&e.serverVersion===t.serverVersion&&e.status===t.status&&e.ready===t.ready&&e.cwd===t.cwd&&Ga(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&Ga(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function qa(e){let t={...Ua,...e};if(!Ka(Ua,t)){Ua=t;for(let e of Wa)e()}}function Ja(e){return Wa.add(e),()=>{Wa.delete(e)}}function Ya(){return Ua}function Xa(){return(0,g.useSyncExternalStore)(Ja,Ya,Ya)}function Za(e){return(0,g.useSyncExternalStore)(Ja,()=>Ua[e],()=>Ua[e])}function Qa(){return Za(`engine`)===`dsh`}function $a(){return Za(`managed`)}function eo(){return Za(`service`)}var to=null;function no(e){to=e}var $=e=>to?to(e):!1,ro=new Set;function io(e){return ro.add(e),()=>{ro.delete(e)}}function ao(e){for(let t of ro)try{t(e)}catch(e){console.error(`[remote-ssh-client] listener error:`,e)}}function oo(e,t,n,r){return`ssh://${e}@${t}:${n}${r.startsWith(`/`)?r:`/${r}`}`}function so(e){return!!(e&&e.startsWith(`ssh://`))}function co(e){if(!so(e))return null;let t=/^ssh:\/\/([^@]+)@([^:]+):(\d+)(\/.*)$/.exec(e);return t?{username:t[1],host:t[2],port:parseInt(t[3],10),remotePath:t[4]}:null}var lo=1;function uo(e){let t=`probe_${Date.now()}_${lo++}`;return new Promise(n=>{let r=io(e=>{e.type===`remote_ssh_probe_result`&&e.reqId===t&&(r(),n({ok:e.ok,connectionId:e.connectionId,error:e.error,system:e.system,tools:e.tools,packageManager:e.packageManager,suggestedInstall:e.suggestedInstall}))});$({type:`remote_ssh_probe`,reqId:t,params:e})||(r(),n({ok:!1,error:`WebSocket 连接不可用,请稍候重试`}))})}function fo(e,t){let n=`listdir_${Date.now()}_${lo++}`;return new Promise(r=>{let i=io(e=>{e.type===`remote_ssh_list_dir_result`&&e.reqId===n&&(i(),r({ok:e.ok,connectionId:e.connectionId,path:e.path,parentPath:e.parentPath,items:e.items,error:e.error}))});$({type:`remote_ssh_list_dir`,reqId:n,connectionId:e,path:t})||(i(),r({ok:!1,connectionId:e,path:t||`/`,items:[],error:`WebSocket 连接不可用`}))})}function po(e,t){let n=`install_${Date.now()}_${lo++}`;return new Promise(r=>{let i=io(e=>{e.type===`remote_ssh_install_result`&&e.reqId===n&&(i(),r({ok:e.ok,connectionId:e.connectionId,tool:e.tool,output:e.output,error:e.error}))});$({type:`remote_ssh_install_tools`,reqId:n,connectionId:e,tools:t})||(i(),r({ok:!1,connectionId:e,tool:t[0]||``,error:`WebSocket 连接不可用`}))})}function mo(){let e=`profiles_${Date.now()}_${lo++}`;return new Promise(t=>{let n=io(r=>{r.type===`remote_ssh_profiles_result`&&r.reqId===e&&(n(),t(r.profiles))});$({type:`remote_ssh_list_profiles`,reqId:e})||(n(),t([]))})}function ho(e){$({type:`remote_ssh_delete_profile`,name:e})}var go=`@root`,_o=e=>e.endsWith(`/`)?e:e+`/`;function vo(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function yo(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var bo=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;if(t===`@root`||t===`/`)return null;let n=t.lastIndexOf(`/`);if(n<0)return/^[A-Za-z]:$/.test(t)?go:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function xo({currentCwd:e,pathCompletions:t,workspaceRoots:n,onClose:r,onSelectDirectory:i,mode:a=`folder`,onCreateProject:o,className:s,backdropClassName:c,role:l,ariaLabel:u}){let d=Z(),[f,p]=(0,g.useState)(()=>so(e)?`remote`:`local`),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(-1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),[k,A]=(0,g.useState)([]),[j,ee]=(0,g.useState)(``),[M,te]=(0,g.useState)(`22`),[N,ne]=(0,g.useState)(``),[F,re]=(0,g.useState)(`password`),[ie,ae]=(0,g.useState)(``),[I,R]=(0,g.useState)(`~/.ssh/id_rsa`),[z,oe]=(0,g.useState)(!0),[B,V]=(0,g.useState)(``),[H,se]=(0,g.useState)(!1),[ce,le]=(0,g.useState)(null),[ue,de]=(0,g.useState)(null),[fe,W]=(0,g.useState)(null),[pe,G]=(0,g.useState)(null),[K,me]=(0,g.useState)([]),[he,ge]=(0,g.useState)(!1),[q,_e]=(0,g.useState)(`/`),[ve,ye]=(0,g.useState)(`/`),[be,xe]=(0,g.useState)([]),[J,Se]=(0,g.useState)(!1),Ce=t.filter(e=>e.type===`dir`);(0,g.useEffect)(()=>{if(so(e)){let t=co(e);t&&(ee(t.host),te(String(t.port)),ne(t.username),_e(t.remotePath),ye(t.remotePath))}else{let t=(e||``).replace(/\\/g,`/`);h(t),v(t)}b(!1),S(``),w(null),E(-1)},[e]),(0,g.useEffect)(()=>{f===`remote`&&mo().then(e=>A(e))},[f]),(0,g.useEffect)(()=>{let e=requestAnimationFrame(()=>{D.current?.focus()});return()=>cancelAnimationFrame(e)},[f]),(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(y?(b(!1),S(``),w(null)):r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,r]),(0,g.useEffect)(()=>{if(f!==`local`)return;let e=setTimeout(()=>{$({type:`complete_path`,path:_o(m)})},60);return()=>clearTimeout(e)},[m,f]),(0,g.useEffect)(()=>{if(f!==`local`||_===m)return;let e=setTimeout(()=>{$({type:`complete_path`,path:_})},150);return()=>clearTimeout(e)},[_,m,f]);let we=e=>{let t=e.trim();t&&t!==`@root`&&i(t)},Te=()=>{let e=x.trim();if(e){if(a===`project`){if(!yo(e)){w(d(`invalidProjectName`));return}let t=vo(m,e);o?.(t),b(!1),S(``),w(null),r()}else $({type:`make_dir`,path:`${_o(m)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:_o(m)})},80),S(``),b(!1)}},Ee=e=>{if(e.key===`Escape`)e.stopPropagation(),y?(b(!1),S(``),w(null)):r();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)we(_);else if(e.key===`Tab`){if(Ce.length===0)return;e.preventDefault();let t=T>=0?(T+1)%Ce.length:0;E(t),v(Ce[t].path),h(Ce[t].path)}},De=async e=>{let t=(e?.host??j).trim(),n=e?.port??(parseInt(M,10)||22),r=(e?.username??N).trim();if(!t||!r){le(`请填写主机地址和用户名`);return}se(!0),le(null);let i=await uo({host:t,port:n,username:r,auth:e?.auth??(F===`password`?{type:`password`,password:ie}:F===`key`?{type:`key`,privateKeyPath:I}:{type:`agent`}),saveProfile:z,profileName:e?.profileName||B.trim()||void 0});if(se(!1),!i.ok||!i.connectionId){le(i.error||`连接远程服务器失败`);return}de(i.connectionId),W(i.system??null),G(i.tools??null),me(i.suggestedInstall??[]);let a=i.system?.homeDir||`/`;_e(a),ye(a),Oe(i.connectionId,a),mo().then(e=>A(e))},Oe=async(e,t)=>{Se(!0),le(null);let n=await fo(e,t);Se(!1),n.ok?(_e(n.path),ye(n.path),xe(n.items)):le(n.error||`读取远程目录失败`)},ke=async e=>{if(!ue)return;ge(!0),le(null);let t=await po(ue,[e]);ge(!1),t.ok?(me(t=>t.filter(t=>t!==e)),pe&&e===`git`&&G({...pe,git:{installed:!0,version:`已安装`}})):le(t.error||`安装 ${e} 失败,可能需要远端 sudo 权限`)},Ae=e=>{i(oo(N,j,parseInt(M,10)||22,e)),r()},je=bo(m),Me=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},Ne=Me(m),Pe=!!m&&m!==`@root`&&Ne!==Me(e)&&!n.some(e=>Me(e)===Ne);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop ${c??``}`.trim(),onClick:r}),(0,X.jsxs)(`div`,{className:`cwd-picker ${s??``}`.trim(),role:l,"aria-label":u,children:[(0,X.jsxs)(`div`,{className:`cwd-mode-tabs`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-mode-tab ${f===`local`?`active`:``}`,onClick:()=>p(`local`),children:[`💻 `,d(`workspaceModeLocal`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-mode-tab ${f===`remote`?`active`:``}`,onClick:()=>p(`remote`),children:[`🌐 `,d(`workspaceModeRemote`)]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-close`,title:d(`close`),"aria-label":d(`close`),onClick:r,children:(0,X.jsx)(P,{})})]}),f===`local`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:m===`@root`?d(`computer`):m,children:[m===`@root`?`💻`:(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{children:m===`@root`?d(`computer`):m})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:m===`@root`,title:d(`computer`),onClick:()=>{h(`@root`),v(`@root`),E(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!je,title:d(`cwdGoUp`),onClick:()=>{je&&(h(je),v(je),E(-1))},children:[`↑ `,d(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!Pe,title:d(`addWorkspaceRootHint`),onClick:()=>{Pe&&$({type:`set_workspace_roots`,roots:[...n,m]})},children:[`+ `,d(`addWorkspaceRoot`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:D,className:`status-cwd-input cwd-picker-input`,value:_,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>{v(e.target.value),E(-1)},onKeyDown:Ee}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:d(`cwdPickCurrent`),disabled:m===`@root`,onClick:()=>we(m),children:d(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[Ce.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}),Ce.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${d(`cwdEnter`)} ${e.path}`,onClick:()=>{h(e.path),v(e.path),E(-1)},children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>we(e.path),children:d(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[y?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:O,value:x,autoFocus:!0,spellCheck:!1,placeholder:d(a===`project`?`projectName`:`cwdNewName`),onChange:e=>{S(e.target.value),C&&w(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),Te()):e.key===`Escape`&&(e.stopPropagation(),b(!1),S(``),w(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:Te,children:d(a===`project`?`createAndOpenProject`:`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{b(!1),S(``),w(null)},children:d(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>b(!0),children:[`+ `,d(a===`project`?`newProject`:`cwdNewFolder`)]}),C&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:C})]})]}),f===`remote`&&(0,X.jsx)(`div`,{className:`cwd-ssh-container`,children:ue?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-probe-box`,children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-probe-header`,children:[(0,X.jsxs)(`span`,{children:[`🌐 `,N,`@`,j,` (`,fe?.os,` `,fe?.arch,`)`]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-ssh-profile-del`,onClick:()=>{de(null),W(null),G(null)},children:d(`sshDisconnect`)})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,flexWrap:`wrap`,fontSize:`10px`},children:[(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.git.installed?`ok`:`missing`}`,children:[`Git: `,pe?.git.installed?`✓`:`✗`]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.node.installed?`ok`:`missing`}`,children:[`Node: `,pe?.node.installed?`✓`:`✗`]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-tool-badge ${pe?.bash.installed?`ok`:`missing`}`,children:[`Bash: `,pe?.bash.installed?`✓`:`✗`]})]}),K.length>0&&(0,X.jsxs)(`div`,{className:`cwd-ssh-install-box`,children:[(0,X.jsx)(`div`,{children:`⚠️ 远端环境未检测到 Git / 基础工具,SCM 与执行功能可能受限。`}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`6px`,marginTop:`2px`},children:[(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,disabled:he,onClick:()=>void ke(K[0]),children:he?d(`sshInstalling`):`⚡ ${d(`sshInstallTool`)} ${K[0]}`}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>me([]),children:d(`sshSkipAndBrowse`)})]})]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:q,children:[(0,X.jsx)(Fe,{}),(0,X.jsx)(`span`,{children:q})]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:q===`/`||J,title:d(`cwdGoUp`),onClick:()=>{let e=bo(q)||`/`;ue&&Oe(ue,e)},children:[`↑ `,d(`cwdGoUp`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{className:`status-cwd-input cwd-picker-input`,value:ve,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>ye(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ue&&Oe(ue,ve)}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:()=>Ae(q),children:d(`sshOpenRemoteWorkspace`)})]}),(0,X.jsx)(`div`,{className:`cwd-list`,children:J?(0,X.jsx)(`div`,{className:`cwd-empty`,children:`正在加载远程目录…`}):be.length===0?(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}):be.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${e.type===`dir`?d(`cwdEnter`):``} ${e.path}`,onClick:()=>{e.type===`dir`&&ue&&Oe(ue,e.path)},children:[e.type===`dir`?(0,X.jsx)(Re,{}):(0,X.jsx)(`span`,{children:`📄`}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),e.type===`dir`&&(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>Ae(e.path),children:d(`cwdChoose`)})]},e.path))})]}):(0,X.jsxs)(`div`,{className:`cwd-ssh-form`,children:[k.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-profiles-title`,children:[`📋 `,d(`sshSavedProfiles`)]}),k.map(e=>(0,X.jsxs)(`div`,{className:`cwd-ssh-profile-card`,onClick:()=>{ee(e.host),te(String(e.port)),ne(e.username),re(e.authType),e.privateKeyPath&&R(e.privateKeyPath),De({host:e.host,port:e.port,username:e.username,profileName:e.name,auth:e.authType===`password`?{type:`password`,password:``}:e.authType===`key`?{type:`key`,privateKeyPath:e.privateKeyPath}:{type:`agent`}})},children:[(0,X.jsxs)(`div`,{className:`cwd-ssh-profile-meta`,children:[(0,X.jsxs)(`span`,{className:`cwd-ssh-profile-name`,children:[(0,X.jsx)(U,{style:{marginRight:`4px`}}),e.name]}),(0,X.jsxs)(`span`,{className:`cwd-ssh-profile-addr`,children:[e.username,`@`,e.host,`:`,e.port]})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-ssh-profile-del`,title:d(`delete`),onClick:t=>{t.stopPropagation(),confirm(d(`sshDeleteProfileConfirm`))&&(ho(e.name),A(t=>t.filter(t=>t.name!==e.name)))},children:(0,X.jsx)(L,{})})]},e.name))]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,style:{marginTop:`4px`},children:[(0,X.jsxs)(`label`,{children:[d(`sshHost`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:j,placeholder:`192.168.1.100`,onChange:e=>ee(e.target.value)}),(0,X.jsxs)(`label`,{style:{width:`32px`,textAlign:`right`},children:[d(`sshPort`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,style:{width:`45px`,flex:`none`},value:M,onChange:e=>te(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshUser`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:N,placeholder:`root / ubuntu`,onChange:e=>ne(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshAuthType`),`:`]}),(0,X.jsxs)(`select`,{className:`cwd-ssh-select`,value:F,onChange:e=>re(e.target.value),children:[(0,X.jsx)(`option`,{value:`password`,children:d(`sshPassword`)}),(0,X.jsx)(`option`,{value:`key`,children:d(`sshKeyPath`)}),(0,X.jsx)(`option`,{value:`agent`,children:d(`sshAgent`)})]})]}),F===`password`&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshPassword`),`:`]}),(0,X.jsx)(`input`,{type:`password`,className:`cwd-ssh-input`,value:ie,placeholder:`••••••••`,onChange:e=>ae(e.target.value)})]}),F===`key`&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshKeyPath`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:I,placeholder:`~/.ssh/id_rsa`,onChange:e=>R(e.target.value)})]}),(0,X.jsx)(`div`,{className:`cwd-ssh-row`,style:{fontSize:`11px`,color:`var(--text-dim)`},children:(0,X.jsxs)(`label`,{style:{width:`auto`},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:z,onChange:e=>oe(e.target.checked),style:{marginRight:`4px`}}),d(`sshSaveProfile`)]})}),z&&(0,X.jsxs)(`div`,{className:`cwd-ssh-row`,children:[(0,X.jsxs)(`label`,{children:[d(`sshProfileName`),`:`]}),(0,X.jsx)(`input`,{className:`cwd-ssh-input`,value:B,placeholder:`my-server`,onChange:e=>V(e.target.value)})]}),ce&&(0,X.jsxs)(`div`,{style:{color:`var(--red)`,fontSize:`11px`,padding:`2px 0`},children:[`⚠️ `,ce]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,style:{marginTop:`4px`},disabled:H,onClick:()=>void De(),children:d(H?`sshConnecting`:`sshConnectAndProbe`)})]})})]})]})}function So({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z();return e?(0,X.jsx)(xo,{currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:e=>{a(e),i()},onCreateProject:o,mode:`project`,className:`project-picker`,backdropClassName:`project-picker-backdrop`,role:`dialog`,ariaLabel:s(`projectPickerTitle`)}):null}function Co(e){return k({tag:`svg`,attr:{viewBox:`0 0 256 256`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M53.92,34.62A8,8,0,1,0,42.08,45.38L67.37,73.2A69.82,69.82,0,0,0,38,87.63a16,16,0,0,0-1.29,23.78L85,159.71,42.34,202.34a8,8,0,0,0,11.32,11.32L96.29,171l48.29,48.29A16,16,0,0,0,155.9,224c.38,0,.75,0,1.13,0a15.93,15.93,0,0,0,11.64-6.33,89.75,89.75,0,0,0,11.58-20.27l21.84,24a8,8,0,1,0,11.84-10.76ZM155.9,208,48,100.08C58.23,91.83,69.2,87.72,80.66,87.81l87.16,95.88C165.59,193.56,160.24,202.23,155.9,208Zm79.42-104-44.64,44.79a8,8,0,1,1-11.33-11.3L224,92.7,163.32,32,122.1,73.35a8,8,0,0,1-11.33-11.29L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.32,104Z`},child:[]}]})(e)}function wo(e){return k({tag:`svg`,attr:{viewBox:`0 0 256 256`,fill:`currentColor`},child:[{tag:`path`,attr:{d:`M235.33,104l-53.47,53.65c4.56,12.67,6.45,33.89-13.19,60A15.93,15.93,0,0,1,157,224c-.38,0-.75,0-1.13,0a16,16,0,0,1-11.32-4.69L96.29,171,53.66,213.66a8,8,0,0,1-11.32-11.32L85,159.71l-48.3-48.3A16,16,0,0,1,38,87.63c25.42-20.51,49.75-16.48,60.4-13.14L152,20.7a16,16,0,0,1,22.63,0l60.69,60.68A16,16,0,0,1,235.33,104Z`},child:[]}]})(e)}function To(e,t,n,r={}){let{align:i=`right`,side:a=`bottom`,gap:o=6,margin:s=8}=r,c=t.width,l=t.height,u=Math.max(0,n.width-c-s),d=Math.max(0,n.height-l-s),f=i===`left`?e.left:e.right-c;f=Math.max(s,Math.min(f,u));let p;return a===`top`?(p=e.top-l-o,p<s&&e.bottom+o+l<=n.height-s&&(p=e.bottom+o)):(p=e.bottom+o,p+l>n.height-s&&e.top-l-o>=s&&(p=e.top-l-o)),p>d&&(p=d),p<s&&(p=s),{x:Math.round(f),y:Math.round(p)}}function Eo(e){let{open:t=!0,anchor:n,anchorEl:r,onClose:i,isInside:a,align:o=`right`,side:s=`bottom`,gap:c=6,margin:l=8}=e,u=(0,g.useRef)(null),[d,f]=(0,g.useState)(null),p=(0,g.useRef)(i);(0,g.useLayoutEffect)(()=>{p.current=i});let m=()=>{if(!n)return null;if(`current`in n)return n.current?.getBoundingClientRect()??null;if(typeof n.getBoundingClientRect==`function`)return n.getBoundingClientRect();let e=n;return typeof e.left==`number`&&typeof e.right==`number`&&typeof e.top==`number`&&typeof e.bottom==`number`?e:null},h=()=>r||(n&&`current`in n?n.current:n&&typeof n.getBoundingClientRect==`function`?n:null),_=()=>{if(!t)return;let e=u.current;if(!e)return;let n=e.getBoundingClientRect();if(n.width===0&&n.height===0)return;let r=h(),i=r&&r.isConnected?r.getBoundingClientRect():m();if(!i)return;let a=To(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});f(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,g.useLayoutEffect)(()=>{t?_():f(null)},[t,n,r,o,s,c,l]),zt(()=>{p.current()},t),(0,g.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||h()?.contains(e)||a?.(e)),n=t=>{e(t.target)||p.current()};return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`resize`,_,!0),window.addEventListener(`scroll`,_,!0),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`resize`,_,!0),window.removeEventListener(`scroll`,_,!0)}},[t,n,r]),{panelRef:u,pos:d,style:{position:`fixed`,left:d?.x??-9999,top:d?.y??-9999,visibility:d?`visible`:`hidden`},measure:_}}function Do({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=Nn(),{panelRef:d,style:f,measure:p}=Eo({anchor:e,anchorEl:t,onClose:l}),[,m]=(0,g.useState)(null),h=(0,g.useRef)(null),[_,v]=(0,g.useState)(null),y=(0,g.useMemo)(()=>{let e=new Map((i??[]).map((e,t)=>[e,t]));return n.map((e,t)=>({plugin:e,index:t})).sort((t,n)=>(e.get(t.plugin.id)??1e6+t.index)-(e.get(n.plugin.id)??1e6+n.index)).map(({plugin:e})=>e)},[n,i]);(0,g.useLayoutEffect)(()=>{p()},[y,p]);let b=(e,t)=>{let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=r+t;if(r<0||i<0||i>=n.length)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))},x=(e,t)=>{if(!e||e===t)return;let n=y.filter(e=>e.view!==!1&&!e.error).map(e=>e.id),r=n.indexOf(e),i=n.indexOf(t);if(r<0||i<0)return;let[a]=n.splice(r,1);a&&(n.splice(i,0,a),o(n))};return(0,j.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:f,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(ht,{className:`pm-head-icon`,"aria-hidden":!0}),u(`pluginMenuTitle`)]}),(0,X.jsx)(`div`,{className:`pm-list`,children:n.length===0?(0,X.jsx)(`div`,{className:`pm-empty`,children:u(`pluginMenuEmpty`)}):y.map(e=>{let t=e.view===!1||!!e.error,n=!t&&r.has(e.id),i=e.error??(e.view===!1?u(`pluginMenuNoView`):void 0),o=e.iconSvg?void 0:e.icon&&!/[a-z]/i.test(e.icon)?e.icon:void 0;return(0,X.jsxs)(`div`,{className:`pm-row${_===e.id?` drop-target`:``}`,role:`none`,onDragOver:n=>{!t&&h.current&&(n.preventDefault(),v(e.id))},onDrop:t=>{t.preventDefault(),x(t.dataTransfer.getData(`text/plain`)||h.current,e.id),h.current=null,m(null),v(null)},children:[!t&&(0,X.jsx)(`button`,{type:`button`,className:`pm-drag`,draggable:!0,"aria-label":u(`pluginMenuReorder`),title:u(`pluginMenuReorderHint`),onDragStart:t=>{m(e.id),h.current=e.id,t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id);let n=document.createElement(`div`);n.style.cssText=`position:fixed;left:-9999px;top:-9999px;width:1px;height:1px;opacity:0`,document.body.appendChild(n),t.dataTransfer.setDragImage(n,0,0),requestAnimationFrame(()=>n.remove())},onDragEnd:()=>{h.current=null,m(null),v(null)},onKeyDown:t=>{(t.key===`ArrowUp`||t.key===`ArrowDown`)&&(t.preventDefault(),b(e.id,t.key===`ArrowUp`?-1:1))},children:(0,X.jsx)(Se,{"aria-hidden":!0})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-row-main`,disabled:t,title:i,onClick:()=>s(e.id),children:[o||e.iconSvg?(0,X.jsx)(hi,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(ht,{className:`pm-icon`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`pm-name`,children:e.name}),i&&(0,X.jsx)(`span`,{className:`pm-sub`,children:i})]}),!t&&(0,X.jsx)(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":n,"aria-label":u(n?`pluginMenuUnpin`:`pluginMenuPin`),className:`pm-pin${n?` on`:``}`,onClick:()=>a(e.id,!n),children:n?(0,X.jsx)(wo,{"aria-hidden":!0}):(0,X.jsx)(Co,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(ue,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Oo({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=Nn(),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(``);async function d(){try{let e=await fetch(gn(fn(`/api/locales`)));if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();o(t.packs??[]),c(``)}catch(e){c(t(`localeListFailed`,{error:e instanceof Error?e.message:String(e)}))}}(0,g.useEffect)(()=>{d()},[]);async function f(e){u(e),c(``);try{let t=await fetch(gn(fn(`/api/locales/${e}/install`)),{method:`POST`});if(!t.ok){let e=`HTTP ${t.status}`;try{e=(await t.json()).error??e}catch{}throw Error(e)}await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}async function p(e){u(e),c(``);try{let t=await fetch(gn(fn(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);Tn(e),n===e&&r(`zh`),await i(),await d()}catch(e){c(t(`localeInstallFailed`,{error:e instanceof Error?e.message:String(e)}))}finally{u(``)}}return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:e,children:(0,X.jsxs)(`div`,{className:`bg-task-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`bg-task-head`,children:[(0,X.jsxs)(`span`,{className:`bg-task-title`,children:[(0,X.jsx)(Fe,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(P,{})})]}),s&&(0,X.jsx)(`div`,{className:`bg-task-empty`,children:s}),a===null&&!s?(0,X.jsx)(`div`,{className:`bg-task-empty`,children:t(`loading`)}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:(a??[]).map(e=>{let n=l===e.code;return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[(0,X.jsx)(`span`,{className:`bg-task-port`,children:e.nativeName}),e.installed&&e.version&&(0,X.jsxs)(`span`,{className:`bg-task-name`,children:[`v`,e.version]})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[(0,X.jsx)(`span`,{children:e.code}),e.installed?(0,X.jsxs)(`span`,{children:[t(`localeInstalled`),` · `,t(`localeRemoveHint`)]}):(0,X.jsx)(`span`,{children:t(`localeGetMore`)})]})]}),e.installed?(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,disabled:n,title:t(`localeRemove`),onClick:()=>void p(e.code),children:[(0,X.jsx)(L,{}),(0,X.jsx)(`span`,{children:t(n?`localeRemoving`:`localeRemove`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:n,title:t(`localeInstall`),onClick:()=>void f(e.code),children:[(0,X.jsx)(qe,{}),(0,X.jsx)(`span`,{children:t(n?`localeDownloading`:`localeInstall`)})]})]},e.code)})}),(0,X.jsx)(`div`,{className:`bg-task-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`bgTaskRefresh`),onClick:()=>void d(),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var ko=`xing-shuyin/pi-web-ui`,Ao={state:`idle`,version:null,percent:0,message:null};function jo(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Mo(e,t){switch(t.state){case`checking`:return{...e,state:`checking`,message:null};case`available`:return{...e,state:`available`,version:t.version??e.version,message:null};case`up-to-date`:return{...e,state:`up-to-date`,version:t.version??e.version,message:null};case`downloading`:return{...e,state:`downloading`,percent:jo(t.percent),message:null};case`downloaded`:return{...e,state:`downloaded`,version:t.version??e.version,percent:100,message:null};case`error`:return{...e,state:`error`,message:t.message??`unknown error`};default:return e}}function No(e){if(!Rn(e))return null;let t=(e??(typeof window>`u`?void 0:window))?.piDesktop?.updater;return!t||typeof t.check!=`function`||typeof t.download!=`function`?null:t}function Po(e){return e instanceof Error?e.message:String(e)}function Fo(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${ko}/releases/tag/v${t}`:`https://github.com/${ko}/releases/latest`}function Io(){let[e]=(0,g.useState)(()=>No()),[t,n]=(0,g.useState)(Ao);(0,g.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>Mo(t,e)))},[e]);let r=(0,g.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:Po(e)}))))},[e]),i=(0,g.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:Po(e)}))))},[e]),a=(0,g.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:Po(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}function Lo(e){let t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),r=Math.max(0,e.cacheWrite??0),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0,writeRate:i>0?Math.min(r/i,1):0}}var Ro=2e3;function zo(e,t,n=Ro){return e.filter(e=>t-e.t<=n)}function Bo(e,t=Ro){if(e.length<2)return 0;let n=e[e.length-1],r=e.find(e=>e.t>=n.t-t)??e[0],i=(n.t-r.t)/1e3;return i<=0?0:Math.max(0,(n.out-r.out)/i)}function Vo(e){if(!e)return 0;let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r>=12352&&r<=12543||r>=13312&&r<=19903||r>=19968&&r<=40959||r>=63744&&r<=64255||r>=65280&&r<=65519||r===12288)&&t++}let n=e.length-t;return Math.round(t+n/4)}function Ho(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=Vo(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=Vo(n.thinking));return t}function Uo(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function Wo(e){return e.startsWith(`zh`)?`ZH`:e.startsWith(`ja`)?`JA`:e.startsWith(`ko`)?`KO`:e.startsWith(`fr`)?`FR`:e.startsWith(`de`)?`DE`:e.startsWith(`es`)?`ES`:e.startsWith(`ru`)?`RU`:e.startsWith(`pt`)?`PT`:e.startsWith(`it`)?`IT`:`EN`}function Go({entry:e,bar:t,chat:n,view:r,plugins:i,onViewChange:a,onOpenPanel:o,onOpenSettings:s,onOpenGlobalSearch:c,onOpenBgTasks:l,onOpenProjectPicker:u,onOpenPluginMenu:d,isPluginMenuOpen:f,isProjectPickerOpen:p,onUiAction:m,uiContextEntries:h,dropdownProps:_}){let v=Z(),{locale:y,packs:b,setLocale:x}=Nn(),{engine:S}=Xa(),C=S===`dsh`,[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(!1),[A,j]=(0,g.useState)(!1),ee=n.settings?.uiLayout,M=n.state,te=M?.stats,N=M?.isStreaming??!1,P=ki(te?.cost??0),F=(0,g.useRef)([]),re=M?.streamingMessage?Ho(M.streamingMessage.content):0;(0,g.useEffect)(()=>{if(!N){F.current=[];return}let e=Date.now(),t=F.current,n=t[t.length-1];n&&e-n.t<250||(F.current=zo([...t,{t:e,out:re}],e))},[N,re]);let ie=N?Bo(F.current):0,ae=n=>{n.preventDefault(),n.stopPropagation();let r=t=>{let n={...ee?.slots,[e.id]:t};$({type:`set_settings`,uiLayout:{...ee,slots:n}})},i=()=>{let t=new Set(ee?.hidden??[]);t.add(e.id),$({type:`set_settings`,uiLayout:{...ee,hidden:[...t]}})},a=[];t!==`top`&&a.push({id:`host:move-top`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToTop`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`bottom`&&a.push({id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToBottom`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`left`&&a.push({id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToLeft`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),t!==`right`&&a.push({id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:v(`moveToRight`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),a.push({id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:v(`uiLayoutRestore`),kind:`action`,order:50,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}),h&&h.length>0&&a.push(...h),Ea({x:n.clientX,y:n.clientY,slot:`contextmenu.topbar`,target:{id:e.id,label:e.label},entries:a,onHostAction:e=>{e.id===`host:move-top`?r(`topbar.primary`):e.id===`host:move-bottom`?r(`bottombar`):e.id===`host:move-left`?r(`sidebar.left`):e.id===`host:move-right`?r(`sidebar.right`):e.id===`host:hide-item`&&i()}})},I=e.id,L=e.labelExplicit?e.label:``,R=e=>L||e,oe=e=>L?`${L} ${e}`:e;if(e.kind===`select`&&e.options?.length){let t=e.options.some(t=>t.value===e.value)?e.value:e.options[0].value;return(0,X.jsx)(`select`,{className:`bar-item bar-item-select`,title:e.hint??e.label,"data-tip":e.hint??e.label,"aria-label":e.label,value:t,onChange:t=>m?.(e,t.target.value),onContextMenu:ae,"data-bar-item":I,children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})}if(I===`host:brand`)return(0,X.jsxs)(`span`,{className:`bar-item brand bar-item-brand`,title:v(`brand`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`brand-logo bar-item-brand-logo`,children:`π`}),(0,X.jsx)(`span`,{className:`brand-name bar-item-text`,children:R(`pi-web-ui`)})]});if(I===`host:conn`){let e=n.ready?`ok`:n.status===`closed`?`error`:`busy`,t=n.ready?v(`connected`):n.status===`closed`?v(`reconnecting`):v(`connecting`);return(0,X.jsxs)(`span`,{className:`bar-item status-item status-conn ${e} bar-item-conn`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`status-dot ${e}`}),(0,X.jsx)(`span`,{className:`status-conn-label bar-item-text`,children:oe(t)})]})}if(I===`host:engine`)return S===`pi`?null:(0,X.jsx)(`span`,{className:`bar-item status-item engine-badge engine-${S} bar-item-engine`,title:`${v(`engineBadge`)}: ${S}`,"data-tip":`${v(`engineBadge`)}: ${S}`,onContextMenu:ae,"data-bar-item":I,children:oe(S===`dsh`?`DSH`:S)});if(I===`host:ctx`){let e=te?.contextUsage,t=e?.softCap??null,n=t!==null&&t>0&&t<(e?.contextWindow??0),r=n?t:e?.contextWindow??0,i=e?.tokens!==null&&e?.tokens!==void 0&&r>0?Math.min(100,Math.round(e.tokens/r*100)):null,a=e?.tokens!==null&&e?.tokens!==void 0?Uo(e.tokens):null,o=r>0?Uo(r):null,s=a!==null&&o!==null&&i!==null?`${a} / ${o}`:`—`,c=i===null?``:i>=80?`warn`:i>=50?`mid`:`ok`,l=n?`${v(`contextUsage`)}: ${Uo(e?.tokens??0)} / ${Uo(t)} (${v(`softCapMarker`)}, max ${Uo(e?.contextWindow??0)})`:t!==null&&t>0?`${v(`contextUsage`)}: ${s} · ${v(`softCapMarker`)}: ${Uo(t)}`:`${v(`contextUsage`)}: ${s}`,u=i!==null&&i>0?+(31.42*(1-Math.min(i,100)/100)).toFixed(2):31.42;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-ctx bar-item-ctx`,title:l,"data-tip":l,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsxs)(`svg`,{className:`ctx-ring ${c}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,X.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:31.42,strokeDashoffset:u,"data-percent":i})]}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[L?`${L} `:``,a!==null&&o!==null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`ctx-val`,children:a}),(0,X.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,X.jsx)(`span`,{className:`ctx-max`,children:o})]}):s]})]})}if(I===`host:cache`){let e=Lo(te?.tokens??{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}),t=e.hitRate*100,n=e.totalInput===0?``:e.hitRate>=.7?`ok`:e.hitRate>=.4?`mid`:`warn`,r=e.totalInput>0?`${t.toFixed(1)}%`:`—`,i=v(`cacheHitTip`,{read:Uo(e.read),write:Uo(e.write),miss:Uo(e.miss),input:Uo(e.totalInput)}),a=e.totalInput>0?`${v(`cacheHit`)}: ${r} · ${i}`:v(`cacheHit`),o=e.totalInput===0;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-cache bar-item-cache${o?` is-zero`:``}`,title:a,"data-tip":a,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Ye,{className:`bar-item-icon`}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[L?`${L} `:``,(0,X.jsx)(`b`,{className:`cache-pct ${n}`,children:r})]})]})}if(I===`host:cost`){let e=te?.cost??0,t=P.tooltip||v(`cumulativeCost`);return(0,X.jsxs)(`span`,{className:`bar-item status-item status-cost bar-item-cost${e<=0?` is-zero`:``}${L?` has-name`:``}`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[L?(0,X.jsx)(`span`,{className:`bar-item-text`,children:L}):null,P.symbol?(0,X.jsx)(`span`,{className:`bar-item-char`,children:P.symbol}):null,(0,X.jsx)(`span`,{className:`bar-item-text`,children:P.value})]})}if(I===`host:msg-count`){let e=te?.totalMessages??0,t=`${v(`sessionMessages`)}: ${e}`;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-msg-count bar-item-msg-count${e===0?` is-zero`:``}`,title:t,"data-tip":t,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(J,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:oe(String(e))})]})}if(I===`host:working`){if(!N)return null;let e=(M?.queue?.steering?.length??0)+(M?.queue?.followUp?.length??0);return(0,X.jsxs)(`span`,{className:`bar-item status-item working bar-item-working`,title:v(`working`),"data-tip":v(`working`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`working-spin`}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[R(v(`working`)),e>0&&` ⏳ ${e}`]}),(0,X.jsx)(`span`,{className:`status-rate bar-item-rate`,title:v(`rateTip`),children:ie>0?`${Math.round(ie)}${v(`tps`)}`:`…`})]})}if(I===`host:status-delegate`)return M?.delegateMode?(0,X.jsxs)(`span`,{className:`bar-item status-item delegate-badge bar-item-delegate`,title:M.delegateConvId?v(`delegateModeOpenTip`):v(`delegateModeBadgeTip`),"data-tip":M.delegateConvId?v(`delegateModeOpenTip`):v(`delegateModeBadgeTip`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(`span`,{className:`bar-item-icon`,children:`🔎`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:R(v(`delegateModeBadge`))}),M.delegateConvId?(0,X.jsx)(`button`,{type:`button`,className:`delegate-badge-open`,title:v(`delegateModeOpenTip`),onClick:()=>$({type:`switch_conversation`,id:M.delegateConvId}),children:`↗`}):null]}):null;if(I===`host:host-metrics`){let e=n.hostMetrics;if(!e)return null;let t=e.cpuPercent===null||!Number.isFinite(e.cpuPercent)?`—`:`${Math.round(e.cpuPercent)}%`,r=Number.isFinite(e.memoryPercent)?`${Math.round(e.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`bar-item status-item status-host-metrics bar-item-host-metrics`,title:`${v(`hostResourcesTip`)}\n${v(`hostProcessor`)}: ${t} · ${v(`hostMemory`)}: ${r}`,"data-tip":`${v(`hostResourcesTip`)}\n${v(`hostProcessor`)}: ${t} · ${v(`hostMemory`)}: ${r}`,onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Ze,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:oe(`${t} · ${r}`)})]})}if(I===`host:browser`)return n.settings?.disabledAgentTools?.includes(`browser_page`)?null:(0,X.jsx)(`span`,{className:`bar-item-wrap`,onContextMenu:ae,"data-bar-item":I,children:(0,X.jsx)(ur,{})});if(I===`host:sound`)return(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:w,onOpenChange:T,tip:R(v(`sound`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`sound`)),"data-tip":R(v(`sound`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(ne,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:R(v(`sound`))})]}),children:[_?.sound&&_?.onSoundChange?(0,X.jsx)(Fn,{settings:_.sound,onChange:_.onSoundChange,onPreview:_.onSoundPreview??(()=>{})}):null,(0,X.jsx)(si,{})]});if(I===`host:language`)return(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:E,onOpenChange:D,tip:R(v(`language`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`language`)),"data-tip":R(v(`language`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(Fe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(Wo(y))})]}),children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`language`)}),b.map(e=>(0,X.jsx)(Ht,{active:y===e.code,onClick:()=>{x(e.code),D(!1)},children:e.nativeName},e.code)),_?.onLocaleModalOpen?(0,X.jsxs)(Ht,{onClick:()=>{D(!1),_.onLocaleModalOpen?.()},children:[(0,X.jsx)(qe,{}),` `,v(`localeGetMore`)]}):null]});if(I===`host:theme`){let e=_?.themes??[],n=_?.theme??null;return(0,X.jsx)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:O,onOpenChange:t=>{k(t),t&&e.length===0&&_?.reloadThemes?.()},tip:R(v(`theme`)),caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`theme`)),"data-tip":R(v(`theme`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(B,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:R(v(`theme`))})]}),children:(()=>{let t=e.filter(e=>e.group===`classic`),r=e.filter(e=>e.group!==`classic`),i=e=>{let t=y===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?v(`themeLight`):e.scheme===`dark`?v(`themeDark`):``;return n?y===`zh`?`${t}(${n})`:`${t} (${n})`:t};return(0,X.jsxs)(X.Fragment,{children:[t.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`themeGroupClassics`)}),t.map(e=>(0,X.jsx)(Ht,{active:n===e.id,onClick:()=>{_?.onThemeChange?.(e.id),k(!1)},children:i(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:t.length>0?v(`themeGroupBuiltin`):v(`theme`)}),(0,X.jsx)(Ht,{active:n===null,onClick:()=>{_?.onThemeChange?.(null),k(!1)},children:v(`themeDefault`)}),r.map(e=>(0,X.jsx)(Ht,{active:n===e.id,onClick:()=>{_?.onThemeChange?.(e.id),k(!1)},children:i(e)},e.id))]})})()})}if(I===`host:update`){let e=_?.updatesCount??0;return _?.managed?(0,X.jsxs)(`span`,{className:`bar-item chip`,title:v(`updatesManaged`),"data-tip":v(`updatesManaged`),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(qe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(`v${_?.appVersion??n.update?.current??`…`}`)})]}):(0,X.jsxs)(Vt,{direction:t===`bottom`?`up`:`down`,align:t===`right`?`right`:`left`,open:A,onOpenChange:e=>{j(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},tip:R(v(`update`)),fit:!0,caret:!1,trigger:(0,X.jsxs)(`button`,{type:`button`,className:`bar-item chip`,title:R(v(`update`)),"data-tip":R(v(`update`)),onContextMenu:ae,"data-bar-item":I,children:[(0,X.jsx)(qe,{className:`bar-item-icon`}),(0,X.jsx)(`span`,{className:`chip-sub bar-item-text`,children:oe(`v${n.update?.current??`…`}`)}),n.update&&!n.update.upToDate&&(0,X.jsx)(`span`,{className:`update-dot`}),e>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:e})]}),children:[(0,X.jsx)(`div`,{className:`dd-header`,children:v(`update`)}),_?.renderUpdateBody?.(),_?.renderAllUpdatesBody?.()]})}let V=null,H=e.label,se=null,ce=!1,le=!1,U=``,de,W;switch(I){case`host:chat`:V=(0,X.jsx)(J,{className:`bar-item-icon`}),H=R(v(`chat`)),ce=r===`chat`,le=!0,W=()=>a?.(`chat`);break;case`host:terminal`:V=(0,X.jsx)(z,{className:`bar-item-icon`}),H=R(v(`terminal`)),ce=r===`terminal`,le=!0,W=()=>a?.(`terminal`);break;case`host:git`:V=(0,X.jsx)(Le,{className:`bar-item-icon`}),H=R(v(`scmTab`)),ce=r===`git`,le=!0,W=()=>a?.(`git`);break;case`host:new-chat`:V=(0,X.jsx)(me,{className:`bar-item-icon`}),H=R(v(`newChat`)),U=`chip newchat`,W=()=>{a?.(`chat`),$({type:`new_chat`}),sr()};break;case`host:new-ephemeral-chat`:if(C)return null;V=(0,X.jsx)(Ot,{className:`bar-item-icon`}),H=R(v(`newChatEphemeral`)),U=`chip newchat ephemeral-chat-btn`,W=()=>{a?.(`chat`),$({type:`new_chat`,ephemeral:!0}),sr()};break;case`host:history`:if(r&&r!==`chat`)return null;V=(0,X.jsx)(Se,{className:`bar-item-icon`}),H=R(v(`openHistory`)),U=`panel-toggle`,W=()=>o?.(`left`);break;case`host:files`:if(r&&r!==`chat`)return null;V=(0,X.jsx)(Re,{className:`bar-item-icon`}),H=R(v(`openFiles`)),U=`panel-toggle has-label`,W=()=>o?.(`right`);break;case`host:open-project`:V=(0,X.jsx)(ze,{className:`bar-item-icon`}),H=R(v(`openProject`)),U=`chip open-project`,ce=!!p,W=()=>u?.();break;case`host:search`:V=(0,X.jsx)(fe,{className:`bar-item-icon`}),H=R(v(`searchGlobal`)),U=`chip`,W=()=>c?.();break;case`host:tasks`:V=(0,X.jsx)(ke,{className:`bar-item-icon`}),H=R(v(`bgTasks`)),U=`chip bg-task-chip`,n.bgServers.length>0&&(se=(0,X.jsx)(`span`,{className:`bg-task-badge bar-item-badge`,children:n.bgServers.length})),W=()=>l?.();break;case`host:settings`:V=(0,X.jsx)(ue,{className:`bar-item-icon`}),H=R(v(`settings`)),U=`chip`,W=()=>s?.();break;case`host:plugins`:V=(0,X.jsx)(ht,{className:`bar-item-icon`}),H=R(v(`pluginMenuTitle`)),U=`chip`,W=e=>{d?d(e.currentTarget):s?.(`plugins`)};break;case`host:github`:V=(0,X.jsx)(Ie,{className:`bar-item-icon`}),H=R(`GitHub`),U=`chip github`,W=()=>window.open(`https://github.com/xing-shuyin/pi-web-ui`,`_blank`,`noreferrer,noopener`);break;case`host:cwd`:V=(0,X.jsx)(Re,{className:`bar-item-icon`}),H=oe(M?.cwd?M.cwd.split(/[/\\]/).pop()||M.cwd:v(`openProject`)),U=`status-item status-cwd`,ce=!!p,W=()=>u?.();break;case`host:plugin-status`:if(n.statuses.length===0)return null;V=(0,X.jsx)(Et,{className:`bar-item-icon`}),H=oe(n.statuses.map(e=>e.text).join(` · `)),U=`status-item ext-status`;break;default:if(e.kind===`view`){let t=e.view??``;ce=r===t,le=!0;let o=(i??n.plugins??[]).find(t=>`plugin:${t.id}`===e.source);U=`plugin-tab${o?.error?` broken`:``}`,o?.error&&(de=`${e.label}: ${o.error}`);let s=e.iconSvg||o?.iconSvg,c=e.icon||o?.icon;V=s?(0,X.jsx)(hi,{icon:c,iconSvg:s,className:`bar-item-icon plugin-icon-svg`}):c?(0,X.jsx)(`span`,{className:`bar-item-icon bar-item-glyph`,children:c}):null,W=()=>a?.(t)}else{let n=e.iconSvg,r=e.icon;U=t===`bottom`?`status-item status-action chip`:`chip`,V=n?(0,X.jsx)(hi,{icon:r,iconSvg:n,className:`bar-item-icon plugin-icon-svg`}):r?(0,X.jsx)(`span`,{className:`bar-item-icon bar-item-glyph`,children:r}):null,e.badge&&(se=(0,X.jsx)(`span`,{className:`bar-item-badge`,children:e.badge})),W=()=>m?.(e)}}let pe=de??e.hint??H,G=[`bar-item`,le?`tb-tab${ce?` active`:``}`:``,U,ce&&!le?`active`:``].filter(Boolean).join(` `);return(0,X.jsxs)(`button`,{type:`button`,role:le?`tab`:void 0,"aria-selected":le?ce:void 0,"aria-haspopup":I===`host:plugins`?`menu`:void 0,"aria-expanded":I===`host:plugins`?!!f:void 0,className:G,title:pe,"data-tip":pe,"aria-label":H,onClick:W,onContextMenu:ae,"data-bar-item":I,children:[V,(0,X.jsx)(`span`,{className:`bar-item-text`,children:H}),se]})}var Ko={name:`@earendil-works/pi-coding-agent`,kind:`pi-core`,current:``,latest:null,upToDate:!1};function qo({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=Eo({open:t,anchor:e,onClose:n});return(0,g.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,j.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Jo(){let[e,t]=(0,g.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,g.useEffect)(()=>{if(typeof window>`u`||window.matchMedia===void 0)return;let e=window.matchMedia(`(max-width: 768px)`),n=e=>t(e.matches);return typeof e.addEventListener==`function`?e.addEventListener(`change`,n):e.addListener(n),()=>{typeof e.removeEventListener==`function`?e.removeEventListener(`change`,n):e.removeListener(n)}},[]),e}function Yo({chat:e,terminal:t,view:n,plugins:r,uiPrimary:i,uiOverflow:a,uiContextTopbar:o,onUiAction:s,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onManagePlugins:d,onOpenBgTasks:f,onOpenGlobalSearch:p,sound:m,onSoundChange:h,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x,onOpenIconEdit:S}){let{locale:C,setLocale:w,t:T,packs:E}=Nn(),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(!1),[j,ee]=(0,g.useState)(null),M=Za(`cwd`),te=Za(`workspaceRoots`),N=Qa(),P=(0,g.useRef)(null),F=t=>!e.tabs||t===`chat`||e.tabs.includes(t),re=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!Xi(e)),ie=new Set([...i??[],...a??[]].filter(e=>Xi(e)&&!e.hidden).map(e=>e.source.slice(7))),ae=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),I=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(ae.get(`${e.id}:__view`)??1e6+e.index)-(ae.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),L=i===void 0?[`host:history`,`host:brand`,`host:open-project`,`host:chat`,`host:terminal`,`host:git`,`host:plugins`,`host:search`,`host:browser`,`host:tasks`,`host:settings`,`host:sound`,`host:language`,`host:theme`,`host:update`,`host:github`,`host:new-chat`,`host:new-ephemeral-chat`,`host:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),R=(F(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!L.some(t=>t.id===`${e.id}:__view`)).map(e=>({id:`${e.id}:__view`,slot:`topbar.primary`,source:`plugin:${e.id}`,label:e.name,kind:`view`,view:`plugin:${e.id}`,order:23,align:`end`,hidden:!1,userOverrides:[],arrangedBy:[]})),oe=e=>{if(e.source!==`host`)return!1;switch(e.id){case`host:history`:return l(`left`),!0;case`host:files`:return l(`right`),!0;case`host:new-chat`:return c(`chat`),$({type:`new_chat`}),sr(),!0;case`host:new-ephemeral-chat`:return c(`chat`),$({type:`new_chat`,ephemeral:!0}),sr(),!0;case`host:open-project`:return A(!0),!0;case`host:search`:return p(),!0;case`host:tasks`:return f(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return ee(P.current?{rect:P.current.getBoundingClientRect(),el:P.current}:null),!0;default:return!1}},V=(t,n,r)=>{t.preventDefault(),t.stopPropagation();let i=e.settings?.uiLayout,a=e=>{let t={...i?.slots,[n]:e};$({type:`set_settings`,uiLayout:{...i,slots:t}})},s=()=>{let e=new Set(i?.hidden??[]);e.add(n),$({type:`set_settings`,uiLayout:{...i,hidden:[...e]}})},c=[{id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToBottom`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToLeft`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:T(`moveToRight`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:T(`uiLayoutRestore`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},...o??[]];Ea({x:t.clientX,y:t.clientY,slot:`contextmenu.topbar`,target:{id:n,label:r},entries:c,onHostAction:e=>{e.id===`host:move-bottom`?a(`bottombar`):e.id===`host:move-left`?a(`sidebar.left`):e.id===`host:move-right`?a(`sidebar.right`):e.id===`host:hide-item`&&s()}})},{appVersion:H}=Xa(),se=$a(),ce=eo(),[le,U]=(0,g.useState)(!1);(0,g.useEffect)(()=>{le&&e.status===`open`&&U(!1)},[le,e.status]);let[de,W]=(0,g.useState)(!1),[pe,G]=(0,g.useState)(!1),[K,he]=(0,g.useState)(!1),[ge,q]=(0,g.useState)(!1),_e=Rn(),ve=Io(),[ye,be]=(0,g.useState)(!1),xe=()=>{if(!e.ready)return;let n=T(`updateTabTitle`),r={name:n,command:`npm i -g pi-web-ui@latest`,cwd:"${pwd}"},i=e.terminals.find(e=>e.title===n);i?(t.restart(i.id),$({type:`run_command`,terminalId:i.id,conversationId:i.conversationId,command:r,cols:80,rows:24})):t.create({id:jt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),q(!1),c(`terminal`)},Ce=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:kt(n),cwd:"${pwd}"},a=e.terminals.find(e=>e.title===r);a?(t.restart(a.id),$({type:`run_command`,terminalId:a.id,conversationId:a.conversationId,command:i,cols:80,rows:24})):t.create({id:jt(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),q(!1),c(`terminal`)},we=e.updatesAll??[],Te=e.updatesSdk,Ee=Te&&Te.newerInstalled?{running:Te.running,installed:Te.newerInstalled}:null,De=Te?.bundledInUse===!0,Oe=we.find(e=>e.kind===`pi-core`&&!e.error),Ae=De&&(!Oe||!Oe.upToDate),je=Ae&&!Oe,Me=we.filter(e=>!e.upToDate&&!e.error).length,Ne=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Pe=e=>e.kind===`git-extension`&&e.source?e.source:e.name,Be=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Ve=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},He=(e,t)=>{if(!t)return Ve(e);let n=Ve(e),r=Ve(t);return n===r?n:`${n} → ${r}`},Ue=()=>(0,X.jsxs)(`div`,{className:`dd-updates-all`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`updatesAllTitle`)}),e.updatesAll===null?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`checkingUpdate`)}):we.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:we.map(e=>{let t=Ee!=null&&e.kind===`pi-core`,n=!e.error&&(!e.upToDate||t);return(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:n?` warn`:``}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>Ce([e],T(`updatePkgTabTitle`,{name:e.name})),children:T(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:Be(e),children:Pe(e)}),(0,X.jsxs)(`span`,{className:`dd-all-meta`,children:[(0,X.jsx)(`span`,{className:`dd-all-kind`,children:e.kind===`webui`?T(`kindWebUi`):e.kind===`pi-core`?T(`kindPiCore`):e.kind===`git-extension`?T(`kindGitExtension`):e.kind===`plugin`?T(`kindPlugin`):T(`kindPackage`)}),(0,X.jsx)(`span`,{className:`dd-all-vers`,title:e.error?e.error:e.kind===`git-extension`?e.upToDate?e.current:`${e.current} → ${e.latest}`:void 0,children:e.error?T(`updateCheckFailed`):e.kind===`git-extension`?e.upToDate?Ve(e.current):He(e.current,e.latest):e.kind===`plugin`?e.upToDate?e.current.startsWith(`v`)?e.current:Ve(e.current):He(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})}),t&&!e.error&&(0,X.jsx)(`span`,{className:`dd-split-run`,children:T(`piCoreSplitRun`,{running:Ee.running})})]})]},`${e.kind}:${e.name}`)})}),Ee&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`piSdkSplitNote`,{running:Ee.running,installed:Ee.installed})}),Ae&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`piSdkBundledNote`,{running:Te.running})}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[je&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce([Ko],T(`installGlobalEngineTabTitle`)),children:T(`installGlobalEngineBtn`)}),Ne.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ce(Ne,T(`updateAllTabTitle`)),children:T(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:Ne.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:T(`updatesAllRefresh`)})]})]}),We=()=>{let t=Fo(e.update?.latest??ve.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:T(`updateDesktopManual`)});if(!ve.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopNoBridge`)}),n]});switch(ve.state){case`checking`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopChecking`)}),n]});case`available`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopAvailable`,{version:ve.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.download(),children:T(`updateDesktopDownload`)}),n]});case`downloading`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopDownloading`,{n:ve.percent})}),n]});case`downloaded`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`updateDesktopDownloaded`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.quitAndInstall(),children:T(`updateDesktopInstall`)}),n]});case`up-to-date`:return(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`upToDate`)});case`error`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopError`,{error:ve.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>ve.check(),children:T(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>ve.check(),children:T(`updateDesktopCheck`)}),n]})}},Ge=()=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`dd-update`,children:[(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:T(`currentVersion`)}),(0,X.jsxs)(`b`,{children:[`v`,e.update?.current??`…`]})]}),(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:T(`latestVersion`)}),(0,X.jsx)(`b`,{children:e.update===null?T(`checkingUpdate`):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:T(`checkingUpdate`)})]}),e.update&&e.update.upToDate&&(0,X.jsx)(`div`,{className:`dd-note ok`,children:T(`upToDate`)}),e.update&&!e.update.upToDate&&e.update.latest&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateAvailable`,{version:e.update.latest})}),e.update?.latestPublishedAt&&Date.now()-new Date(e.update.latestPublishedAt).getTime()<18e5&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateJustPublished`,{version:e.update.latest??``})}),e.update&&!e.update.upToDate&&e.update.latest&&!_e&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&_e&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateDesktopNote`)})]}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`check_update`}),children:e.update===null?T(`checkingUpdate`):T(`checkUpdate`)}),e.update&&!e.update.upToDate&&e.update.latest&&!_e&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:xe,children:T(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&_e&&We(),ce&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:le,title:T(`restartServiceTip`,{name:ce.name}),onClick:()=>{le||(U(!0),$({type:`restart_service`}))},children:T(le?`restartingService`:`restartService`)})]})]}),Y=Jo(),Je={"host:brand":(0,X.jsxs)(`span`,{className:`brand`,children:[(0,X.jsx)(`span`,{className:`brand-logo`,children:`π`}),(0,X.jsx)(`span`,{className:`brand-name`,children:`pi-web-ui`})]}),"host:open-project":(0,X.jsxs)(`button`,{type:`button`,className:`chip open-project`,"data-tip":T(`openProject`),onClick:()=>A(!0),children:[(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`openProject`)})]}),"host:history":n===`chat`&&F(`history`)?(0,X.jsx)(`button`,{type:`button`,className:`panel-toggle`,"data-tip":T(`openHistory`),"aria-label":T(`openHistory`),onClick:()=>l(`left`),children:(0,X.jsx)(Se,{})}):null,"host:files":n===`chat`&&F(`files`)?(0,X.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"data-tip":T(`openFiles`),"aria-label":T(`openFiles`),onClick:()=>l(`right`),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{children:T(`openFiles`)})]}):null,"host:new-chat":F(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":T(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),sr()},children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:T(`newChat`)})]}):null,"host:new-ephemeral-chat":N?null:(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat ephemeral-chat-btn`,"data-tip":T(`newChatEphemeralTip`),onClick:()=>{c(`chat`),$({type:`new_chat`,ephemeral:!0}),sr()},children:[(0,X.jsx)(Ot,{}),(0,X.jsx)(`span`,{children:T(`newChatEphemeral`)})]}),"host:chat":(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`chat`,className:`tb-tab${n===`chat`?` active`:``}`,"data-tip":T(`chat`),onClick:()=>c(`chat`),children:[(0,X.jsx)(J,{}),(0,X.jsx)(`span`,{children:T(`chat`)})]}),"host:terminal":F(`terminal`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`terminal`,className:`tb-tab${n===`terminal`?` active`:``}`,"data-tip":T(`terminal`),onClick:()=>c(`terminal`),children:[(0,X.jsx)(z,{}),(0,X.jsx)(`span`,{children:T(`terminal`)})]}):null,"host:git":F(`git`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`git`,className:`tb-tab${n===`git`?` active`:``}`,"data-tip":T(`scmTab`),onClick:()=>c(`git`),children:[(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{children:T(`scmTab`)})]}):null,"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`pluginMenuTitle`),"aria-haspopup":`menu`,"aria-expanded":j!==null,onClick:e=>{let t=e.currentTarget;ee(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(ht,{"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`pluginMenuTitle`)})]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`searchGlobalTip`),onClick:p,children:[(0,X.jsx)(fe,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(ur,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":T(`bgTasksTip`),onClick:f,children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`bgTasks`)}),e.bgServers.length>0&&(0,X.jsx)(`span`,{className:`bg-task-badge`,children:e.bgServers.length})]}),"host:settings":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":T(`settingsTitle`),onClick:u,children:[(0,X.jsx)(ue,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`settings`)})]}),"host:sound":(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`sound`)})]}),tip:T(`sound`),open:de,onOpenChange:W,caret:!1,children:[(0,X.jsx)(Fn,{settings:m,onChange:h,onPreview:_}),(0,X.jsx)(si,{})]}),"host:language":(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fe,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:En(C)})]}),tip:T(`language`),open:pe,onOpenChange:G,caret:!1,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`language`)}),E.map(e=>(0,X.jsx)(Ht,{active:C===e.code,onClick:()=>{w(e.code),G(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(Ht,{onClick:()=>{G(!1),be(!0)},children:[(0,X.jsx)(qe,{}),` `,T(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(B,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`theme`)})]}),tip:T(`theme`),open:K,caret:!1,onOpenChange:e=>{he(e),e&&v.length===0&&x()},children:(()=>{let e=v.filter(e=>e.group===`classic`),t=v.filter(e=>e.group!==`classic`),n=e=>{let t=C===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?T(`themeLight`):e.scheme===`dark`?T(`themeDark`):``;return n?C===`zh`?`${t}(${n})`:`${t} (${n})`:t};return(0,X.jsxs)(X.Fragment,{children:[e.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`themeGroupClassics`)}),e.map(e=>(0,X.jsx)(Ht,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:e.length>0?T(`themeGroupBuiltin`):T(`theme`)}),(0,X.jsx)(Ht,{active:y===null,onClick:()=>{b(null),he(!1)},children:T(`themeDefault`)}),t.map(e=>(0,X.jsx)(Ht,{active:y===e.id,onClick:()=>{b(e.id),he(!1)},children:n(e)},e.id))]})})()}),"host:update":se?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":T(`updatesManaged`),children:[(0,X.jsx)(qe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,H??e.update?.current??`…`]})]}):(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,e.update?.current??`…`]}),e.update&&!e.update.upToDate&&(0,X.jsx)(`span`,{className:`update-dot`,title:T(`updateAvailable`,{version:e.update.latest??``})}),Me>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:T(`updatesAllBadge`,{n:Me})})]}),tip:T(`update`),open:ge,caret:!1,onOpenChange:e=>{q(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`update`)}),Ge(),Ue()]}),"host:github":(0,X.jsx)(`a`,{className:`chip github`,href:`https://github.com/xing-shuyin/pi-web-ui`,target:`_blank`,rel:`noreferrer noopener`,"data-tip":T(`githubRepo`),children:(0,X.jsx)(Ie,{})}),"host:conn":(0,X.jsxs)(`span`,{className:`chip`,"data-tip":e.status,children:[(0,X.jsx)(`span`,{className:`status-dot ${e.status===`open`?`ok`:`busy`}`}),(0,X.jsx)(`span`,{className:`chip-sub`,children:e.status})]}),"host:engine":(0,X.jsx)(`span`,{className:`chip`,"data-tip":`engine`,children:(0,X.jsx)(`span`,{className:`chip-sub`,children:e.engine??`pi`})}),"host:ctx":(0,X.jsx)(`span`,{className:`chip`,"data-tip":T(`contextUsage`),children:(0,X.jsx)(`span`,{className:`chip-sub`,children:(e.state?.stats?.contextUsage?.tokens??0)>0?`${e.state?.stats?.contextUsage?.tokens}`:T(`contextUsage`)})}),"host:cost":(()=>{let t=Oi(e.state?.stats?.cost??0,{fixedDigits:4});return(0,X.jsx)(`span`,{className:`chip`,"data-tip":t.tooltip||T(`cumulativeCost`),children:(0,X.jsxs)(`span`,{className:`chip-sub`,children:[t.symbol,t.value]})})})(),"host:cwd":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":e.state?.cwd??``,onClick:()=>A(!0),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:e.state?.cwd?.split(/[/\\]/).pop()||e.state?.cwd})]})},Ye=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Xe=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),Ze=e=>Ye.has(e)&&!F(e.slice(5)),Qe=e=>{if(e.kind===`view`){if(!F(`plugins`))return null;let t=e.view??``,i=r.find(t=>`plugin:${t.id}`===e.source),a=i?.error?`${e.label}: ${i.error}`:e.hint??e.label;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===t,className:`tb-tab plugin-tab${n===t?` active`:``}${i?.error?` broken`:``}`,"data-tip":a,onClick:()=>c(t),onContextMenu:t=>V(t,e.id,e.label),children:[(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`plugin-topbar-item plugin-topbar-select`,title:e.hint??e.label,"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>s?.(e,t.target.value),onContextMenu:t=>V(t,e.id,e.label),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id):(0,X.jsxs)(`button`,{type:`button`,className:`plugin-topbar-item`,"data-tip":e.hint??e.label,onClick:()=>s?.(e),onContextMenu:t=>V(t,e.id,e.label),children:[(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},$e=[];for(let t of L){if(t.entry?.hidden||Ze(t.id))continue;let i=null;t.entry?i=(0,X.jsx)(Go,{entry:t.entry,bar:`top`,chat:e,view:n,plugins:r,onViewChange:c,onOpenPanel:l,onOpenSettings:u,onOpenGlobalSearch:p,onOpenBgTasks:f,onOpenProjectPicker:()=>A(!0),isProjectPickerOpen:k,onOpenPluginMenu:e=>ee(t=>t?.el===e?null:{rect:e.getBoundingClientRect(),el:e}),isPluginMenuOpen:j!==null,onUiAction:s,uiContextEntries:o,dropdownProps:{sound:m,onSoundChange:h,onSoundPreview:_,theme:y,themes:v,onThemeChange:b,reloadThemes:x,onLocaleModalOpen:()=>be(!0),renderUpdateBody:Ge,renderAllUpdatesBody:Ue,updatesCount:Me,managed:se,appVersion:H}},t.id):t.id.startsWith(`host:`)&&Je[t.id]&&(i=Je[t.id]),i&&$e.push({id:t.id,entry:t.entry,node:i})}for(let t of R){let i=(0,X.jsx)(Go,{entry:t,bar:`top`,chat:e,view:n,plugins:r,onViewChange:c,onUiAction:s,uiContextEntries:o},t.id);i&&$e.push({id:t.id,entry:t,node:i})}let et=e=>e.entry?.align??`start`,[tt,nt]=(0,g.useState)(()=>new Set),rt=(0,g.useRef)(null),it=(0,g.useRef)(new Map),at=$e.filter(e=>!tt.has(e.id)),ot=Y?at.filter(e=>ba.has(e.id)):[],st=Y?at.filter(e=>!ba.has(e.id)):at,ct=Y?$e.filter(e=>!ba.has(e.id)):$e,lt=[...ct.filter(e=>et(e)===`start`),...ct.filter(e=>et(e)===`center`),...ct.filter(e=>et(e)===`end`)],ut=lt.filter(e=>!tt.has(e.id)),dt=(0,g.useRef)(lt),ft=(0,g.useRef)(ut);(0,g.useLayoutEffect)(()=>{dt.current=lt,ft.current=ut});let pt=()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`)),n=ft.current;t.length===n.length&&n.forEach((e,n)=>it.current.set(e.id,t[n].offsetWidth));let r=Number.parseFloat(getComputedStyle(e).columnGap)||0,i=dt.current,a=Sa(i.map(e=>({id:e.id,width:e.entry?it.current.get(e.id)??0:0})),e.clientWidth,r,0,qi);nt(e=>e.size===a.size&&[...a].every(t=>e.has(t))?e:a)},mt=`${at.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Y?`m`:`d`}`;(0,g.useLayoutEffect)(pt,[mt]),(0,g.useEffect)(()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>pt());return t.observe(e),()=>t.disconnect()},[mt]);let gt=st.filter(e=>et(e)===`start`),_t=st.filter(e=>et(e)===`center`),vt=st.filter(e=>et(e)===`end`),yt=$e.filter(e=>tt.has(e.id)&&e.entry).map(e=>e.entry),bt=new Map;[...i??[],...a??[]].forEach((e,t)=>{bt.has(e.id)||bt.set(e.id,t)});let xt=xa([...re,...yt],e=>bt.get(e)??999999),St=e=>e.icon&&!/[a-z]/i.test(e.icon)?e.icon:null,Ct=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${Ct?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:rt,role:`toolbar`,"aria-label":T(`viewSwitch`),children:[gt.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),(_t.length>0||vt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),_t.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),_t.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),vt.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id))]}),(xt.length>0||$e.length>0)&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:P,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":D,"aria-label":T(`pluginTopbarMore`),"data-tip":T(`pluginTopbarMore`),onClick:()=>O(e=>!e),children:(0,X.jsx)(Dt,{})}),(0,X.jsxs)(qo,{anchorRef:P,open:D,onClose:()=>O(!1),children:[xt.map(e=>{let t=e.source===`host`&&Xe.has(e.id)?Je[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(g.Fragment,{children:t},e.id);if(e.source===`host`&&e.id===`host:github`)return(0,X.jsxs)(`a`,{role:`menuitem`,className:`chip github`,href:`https://github.com/xing-shuyin/pi-web-ui`,target:`_blank`,rel:`noreferrer noopener`,title:T(`githubRepo`),onClick:()=>O(!1),children:[(0,X.jsx)(Ie,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=Je[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>O(!1),children:t},e.id)}else{let t=Qe(e);if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>O(!1),children:t},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsxs)(`label`,{className:`plugin-topbar-overflow-select tb-row`,title:e.hint??e.label,children:[St(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:St(e)}):null,(0,X.jsx)(`span`,{className:`tb-row-text`,children:e.label}),(0,X.jsx)(`select`,{"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>{O(!1),oe(e)||s?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))})]},e.id):(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`tb-row`,title:e.hint??e.label,onClick:()=>{O(!1),oe(e)||s?.(e)},children:[St(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:St(e)}):null,(0,X.jsx)(`span`,{className:`tb-row-text`,children:e.label})]},e.id)}),(0,X.jsx)(`div`,{className:`tb-menu-divider`,"aria-hidden":`true`}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`tb-row`,onClick:()=>{O(!1),S()},children:[(0,X.jsx)(Ke,{}),(0,X.jsx)(`span`,{className:`tb-row-text`,children:T(`uiIconEdit`)})]})]})]}),ot.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.id)),ye&&(0,X.jsx)(Oo,{onClose:()=>be(!1)}),j&&(0,X.jsx)(Do,{anchorRect:j.rect,anchorEl:j.el,plugins:r,pinnedIds:ie,orderedPluginIds:I,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:Zi(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:Qi(e.settings?.uiLayout,t)}),onOpenView:e=>{ee(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>ee(null)}),k&&(0,X.jsx)(So,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:te,onClose:()=>A(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Xo(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(r&&typeof r==`object`&&!Array.isArray(r))for(let e of Object.keys(t)){let t=r[e];typeof t==`number`&&Number.isFinite(t)&&t>0&&(n[e]=t)}}catch{}return n}function Zo(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function Qo(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=e=>e.parentId?r.get(e.parentId)?.cwd??e.cwd:e.cwd,a=e.find(e=>e.id===n),o=a?i(a):t,s=new Map;for(let t of e){let e=i(t),n=s.get(e)??[];n.push(t),s.set(e,n)}let c=[...s.entries()].map(([e,t])=>({cwd:e,isCurrent:e===o,convs:t}));return c.sort((e,t)=>e.isCurrent?-1:t.isCurrent?1:e.cwd<t.cwd?-1:+(e.cwd>t.cwd)),c}function $o(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.isStreaming),m=t.some(e=>!!e.error),h=t.some(e=>!!e.hasQuestion),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasStreaming:p,hasError:m,hasQuestion:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}function es(e){if(!e)return null;let t=e.startsWith(`#`)?e.slice(1):e;if(!t.trim())return null;let n=new URLSearchParams(t),r=n.get(`s`)?.trim()??``;if(!r)return null;let i=n.get(`m`)?.trim()||void 0;return i?{sessionId:r,messageId:i}:{sessionId:r}}function ts(e){let t=e?.sessionId?.trim()??``;if(!t)return``;let n=e?.messageId?.trim()??``,r=`#s=${encodeURIComponent(t)}`;return n?`${r}&m=${encodeURIComponent(n)}`:r}function ns(e,t){let n=ts(t);try{let t=new URL(e);return t.searchParams.delete(`token`),t.hash=n,t.toString()}catch{return`${e.split(`#`)[0]??e}${n}`}}function rs(e){if(!e)return null;let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);if(!t)return null;let n=t.split(`/`),r=n[n.length-1]??``;if(!r)return null;if(r===`session.jsonl`)return(n[n.length-2]?.trim()??``)||null;let i=r.endsWith(`.jsonl`)?r.slice(0,-6):r;if(!i)return null;let a=i.lastIndexOf(`_`);return(a>=0?i.slice(a+1).trim():i.trim())||null}function is(e,t){let n=t?.trim()??``;if(!n||e.length===0)return null;let r=e.find(e=>e.id===n);if(r)return r.id;let i=/^([a-z]+-\d+)-\d+$/.exec(n);if(i){let t=`${i[1]}-`,n=e.find(e=>e.id.startsWith(t));if(n)return n.id}return null}function as(e,t){let n=t.assistantMessageEvent,r=e.stats.tokens,i=t.usage===null?r:{...r,...t.usage},a=i===r?e.stats:{...e.stats,tokens:i};if(n.type!==`text_delta`&&n.type!==`thinking_delta`)return a===e.stats?e:{...e,stats:a};let o=n.delta??``;if(!o)return a===e.stats?e:{...e,stats:a};let s=e.streamingMessage??null,c=s&&s.id===t.messageId?s:{id:t.messageId,content:[]},l=[...c.content],u=n.type===`thinking_delta`?`thinking`:`text`,d=n.contentIndex??l.length-1;return d>=0&&d<l.length&&l[d].type===u?l[d]=u===`thinking`?{type:`thinking`,thinking:(l[d].thinking??``)+o}:{type:`text`,text:(l[d].text??``)+o}:l.push(u===`thinking`?{type:`thinking`,thinking:o}:{type:`text`,text:o}),{...e,stats:a,streamingMessage:{...c,id:t.messageId,content:l}}}function os(e){let{current:t,source:n,snapshot:r,answered:i,activeConversationId:a}=e;return r&&r.id&&!i.has(r.id)?t?.id===r.id?{changed:!1,question:t,source:n}:{changed:!0,question:r,source:`snapshot`}:t&&t.conversationId&&a&&t.conversationId!==a||!r&&t&&n===`snapshot`?{changed:!0,question:null,source:`live`}:{changed:!1,question:t,source:n}}var ss=new Set;function cs(e){return ss.add(e),()=>{ss.delete(e)}}function ls(e,t){for(let n of ss)try{n(e,t)}catch(e){console.error(`[tui-overlay-bridge] listener error:`,e)}}function us(e){let t=typeof e.name==`string`?e.name:``;if(e.unsupported===!0)return{name:t,status:`unsupported`};if(e.found!==!0)return{name:t,status:`missing`};let n={name:t,status:`ready`};return e.label&&(n.label=e.label),e.description&&(n.description=e.description),e.promptSnippet&&(n.promptSnippet=e.promptSnippet),Array.isArray(e.promptGuidelines)&&e.promptGuidelines.length>0&&(n.promptGuidelines=e.promptGuidelines),e.parameters!==void 0&&(n.parameters=e.parameters),e.parametersDropped===!0&&(n.parametersDropped=!0),(e.active===!0||e.active===!1)&&(n.active=e.active),e.source&&(n.source=e.source),e.scope&&(n.scope=e.scope),n}var ds=null,fs=new Set;function ps(){for(let e of fs)e()}function ms(e){let t=(e??``).trim();t&&(ds={name:t,status:`loading`},ps(),$({type:`get_tool_info`,name:t}))}function hs(){ds!==null&&(ds=null,ps())}function gs(e){ds!==null&&ds.name===e.name&&(ds=us(e),ps())}function _s(e){return fs.add(e),()=>{fs.delete(e)}}function vs(){return ds}function ys(){return(0,g.useSyncExternalStore)(_s,vs,vs)}function bs(e){let t=typeof e.name==`string`?e.name:``;if(e.unsupported===!0)return{name:t,status:`unsupported`};if(e.found!==!0)return{name:t,status:`missing`};let n={name:t,status:`ready`};return e.defaultDescription&&(n.defaultDescription=e.defaultDescription),e.defaultPromptSnippet&&(n.defaultPromptSnippet=e.defaultPromptSnippet),Array.isArray(e.defaultPromptGuidelines)&&e.defaultPromptGuidelines.length>0&&(n.defaultPromptGuidelines=e.defaultPromptGuidelines),e.override&&(n.override=e.override),n}var xs={},Ss=new Set;function Cs(){for(let e of Ss)e()}function ws(e){let t=(e??``).trim();t&&(xs[t]&&xs[t].status!==`loading`||(xs={...xs,[t]:{name:t,status:`loading`}},Cs(),$({type:`get_tool_prompt`,name:t})))}function Ts(e){let t=typeof e.name==`string`?e.name:``;t&&xs[t]&&(xs={...xs,[t]:bs(e)},Cs())}function Es(e){if(!xs[e])return;let t={...xs};delete t[e],xs=t,Cs()}function Ds(e){return Ss.add(e),()=>Ss.delete(e)}function Os(e){return(0,g.useSyncExternalStore)(Ds,()=>e?xs[e]??null:null)}var ks=Object.freeze({status:`idle`,messages:[]}),As=new Map,js=new Set,Ms=16;function Ns(){for(;As.size>Ms;){let e=As.keys().next().value;if(e===void 0)break;As.delete(e)}}function Ps(){for(let e of js)e()}function Fs(e,t){let n=(e??``).trim();if(!n)return;let r=As.get(n);(!r||r.status!==`loading`&&r.status!==`ready`)&&(As.set(n,{status:`loading`,messages:r?.messages??[]}),Ns(),Ps(),$({type:`get_compacted_messages`,compactionMessageId:n,conversationId:t}))}function Is(e){let t=e.compactionMessageId;t&&(e.error?As.set(t,{status:`error`,messages:[],error:e.error}):As.set(t,{status:`ready`,messages:e.messages??[]}),Ns(),Ps())}function Ls(e){let t=As.get(e);return t?(As.delete(e),As.set(e,t),t):ks}function Rs(e){return js.add(e),()=>{js.delete(e)}}function zs(e){return(0,g.useSyncExternalStore)(Rs,()=>Ls(e),()=>ks)}var Bs=`__piWebUiHost`,Vs=e=>new Promise(t=>setTimeout(t,e));async function Hs(e=3e3){let t=Date.now()+e;for(;;){let e=window.__piBridge;if(e&&typeof e.call==`function`)return e;if(Date.now()>=t)return null;await Vs(100)}}var Us=Promise.resolve(),Ws=0;function Gs(e){let t=Math.max(1,Number(e.pollMs??100)),n=Math.max(t,Number(e.timeoutMs??8e3)),r=async e=>{let r=Date.now()+n;for(;;){if(e())return!0;if(Date.now()>=r)return e();await Vs(t)}},i=()=>{try{let t=e.listModels?.()??[];return Array.isArray(t)?[...t]:[]}catch{return[]}},a=e=>{if(!e)return!0;try{return i().some(t=>t&&t.id===e)}catch{return!1}},o=async t=>{t&&(e.send({type:`set_model`,modelId:t}),typeof e.getCurrentModelId==`function`&&await r(()=>e.getCurrentModelId?.()===t))},s=async(t,n)=>{let i=String(n.cwd??``).trim();if(i&&e.getCwd()!==i&&(e.send({type:`set_cwd`,path:i}),await r(()=>e.getCwd()===i)),n.newChat!==!1){let t=e.getConversationId();e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank())}let a=String(n.model??``).trim();a&&await o(a),e.send({type:`prompt`,text:t})};return{version:11,setView(t){let n=String(t??``).trim();n&&e.setView(n)},startChat(t){let n=String(t?.prompt??``).trim();if(!n||!e.isReady())return!1;let r=String(t?.model??``).trim();if(r&&!a(r))return!1;let i=()=>s(n,t??{prompt:n}),o;return o=Ws>0?Us.then(i):i(),Ws++,Us=o.then(()=>{Ws--},()=>{Ws--}),o.catch(()=>{}),!0},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>xc(e)},compose(e){return cr()?lr({text:typeof e?.text==`string`?e.text:void 0,attachments:Array.isArray(e?.attachments)?e.attachments:void 0}):!1},openModal(t){let n=String(t??``).trim();if(!n||typeof e.openModal!=`function`)return!1;try{return e.openModal(n)}catch{return!1}},closeModal(){if(typeof e.closeModal!=`function`)return!0;try{e.closeModal()}catch{}return!0},async openSession(t){let n=Xs,i=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],c=String(t?.cwd??``).trim(),l=[...new Set([...i,...s])],u=c||l[0]||``;if(!u)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let d=l.filter(e=>e!==u).slice(0,7),f=new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]);for(let t of[u,...d])if(!f.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t,n)}if(e.getCwd()!==u&&(e.send({type:`set_cwd`,path:u}),!await r(()=>e.getCwd()===u)))return{ok:!1,error:`切换工作目录失败或超时:${u}`};(d.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:d});let p=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=p;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),p=e.getConversationId()??void 0}let m=String(t?.model??``).trim();if(m){if(!a(m))return{ok:!1,error:`未知模型:${m}(先调 models.list() 取可用列表)`};await o(m),p=e.getConversationId()??p}let h=String(t?.prompt??``).trim();return h&&e.send({type:`prompt`,text:h}),{ok:!0,...p?{sessionId:p}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=Xs,i=String(t??``).trim();if(!i)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let a=e.listSessions().find(e=>e.id===i);if(!a)return{ok:!1,error:`找不到会话:${i}`};if(a.cwd&&a.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.(n)??[]]).has(a.cwd)){if(!(e.confirm&&await e.confirm({path:a.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${a.cwd}`};e.grantPath?.(a.cwd,n)}if(e.send({type:`set_cwd`,path:a.cwd}),!await r(()=>e.getCwd()===a.cwd))return{ok:!1,error:`切换工作目录失败或超时:${a.cwd}`}}let o=e.getConversationId();return a.kind===`running`?e.send({type:`switch_conversation`,id:a.id}):e.send({type:`switch_session`,path:a.id}),await r(()=>e.getConversationId()!==o)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${a.title}`}}},async reloadCatalog(t,n){let r=String(t??``).trim();if(!r)return{ok:!1,error:`reloadCatalog 需要一个目录来源(http(s) URL 或本地文件路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=jt();return new Promise(t=>{let a=setTimeout(()=>{kc.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));kc.set(i,e=>{clearTimeout(a),t(e)}),e.send({type:`plugin_catalog_sync`,requestId:i,source:r,...n?.install?{install:!0}:{},...n?.replace?{replace:!0}:{}})})},onUiAction(e,t){return Qs(Js,String(e??``).trim(),t)},onTopbarAction(e,t){return Qs(Js,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(Rn())return{ok:!1,error:`桌面版(Electron 外壳)不支持 browser_page:窗口里没有 Chrome 扩展运行时。请让用户改用系统浏览器打开同一个 pi-web-ui 地址(网页版)再试。/ The desktop app cannot run browser_page (no Chrome extension runtime); ask the user to open the same pi-web-ui address in a regular browser instead.`};let r=await Hs(e.bridgeWaitMs??3e3);if(!r)return{ok:!1,error:`浏览器扩展的页面桥没就绪:确认已安装并启用 page-picker 扩展、本页地址已绑定,然后刷新本页`};try{let e=await r.call({op:n,...t.args===void 0?{}:{args:t.args},...t.target?{to:t.target}:{},...t.timeoutMs?{timeoutMs:t.timeoutMs}:{}});return e===void 0?{ok:!0}:{ok:!0,result:e}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}},dom:{anchors(){let e=e=>{try{return document.querySelector(`[data-pi-anchor="${e}"]`)}catch{return null}};return{app:e(`app`),topbar:e(`topbar`),composer:e(`composer`)}}},dialogs:{async select(t){try{let n=e.select;if(typeof n!=`function`)return{ok:!1};let r=Array.isArray(t?.options)?t.options:[],i=await n({title:String(t?.title??``),options:r.filter(e=>typeof e==`object`&&!!e&&typeof e.label==`string`).map(e=>({label:String(e.label),...typeof e.description==`string`?{description:e.description}:{}})),...t?.multi?{multi:!0}:{}});return!i||typeof i!=`object`||i.ok!==!0?{ok:!1,...i&&typeof i==`object`&&typeof i.error==`string`?{error:i.error}:{}}:{ok:!0,selected:Array.isArray(i.selected)?i.selected.filter(e=>typeof e==`string`):[]}}catch{return{ok:!1}}},async confirm(t){let n=String(t?.title??``),r=typeof t?.detail==`string`?t.detail:``;try{if(typeof e.dialogConfirm==`function`)try{return await e.dialogConfirm({title:n,...r?{detail:r}:{}})===!0}catch{}if(typeof window<`u`&&typeof window.confirm==`function`)try{return window.confirm(r?`${n}\n\n${r}`:n)}catch{return!1}return!1}catch{return!1}},async input(t){try{let n=e.input;if(typeof n!=`function`)return{ok:!1};let r=await n({title:String(t?.title??``),...typeof t?.placeholder==`string`?{placeholder:t.placeholder}:{},...typeof t?.initial==`string`?{initial:t.initial}:{}});return!r||typeof r!=`object`||r.ok!==!0?{ok:!1}:typeof r.value==`string`?{ok:!0,value:r.value}:{ok:!0}}catch{return{ok:!1}}}},async notifyAction(t){let n=String(t?.text??``),r=(Array.isArray(t?.actions)?t.actions:[]).filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`&&typeof e.label==`string`);try{if(typeof e.notifyAction==`function`){let t=await e.notifyAction({text:n,actions:r});return typeof t==`string`?t:null}}catch{return null}try{typeof window<`u`&&typeof window.dispatchEvent==`function`&&window.dispatchEvent(new CustomEvent(ec,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>cc(String(e??``),t)},searchProviders:{register:e=>uc(e),list:()=>dc()},composerProviders:{register:e=>pc(e),list:()=>mc()},onTheme:e=>Cc(e),onLocale:e=>wc(e),onViewChange:e=>Tc(e),setCostFormatter:e=>Ei(e),setCostCurrency:e=>Ti(e),getCostCurrency:()=>wi()}}function Ks(e){try{let t=window;e?t[Bs]=e:delete t[Bs]}catch{}}var qs=new Map,Js=null;async function Ys(e,t){let n=Js;Js=e;try{return await t()}finally{Js=n}}var Xs=void 0;function Zs(e,t){let n=Xs;Xs=e;try{return t()}finally{Xs=n}}function Qs(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=qs.get(r);i||(i=new Set,qs.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&qs.delete(r)}}async function $s(e,t,n,r){let i=i=>{let a=qs.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{Zs(e,()=>i(n,r?.value,r?.target))}catch(n){console.error(`[plugin:${e}] 顶栏动作 ${t} 抛错:`,n)}return!0};if(i(`${e}:${t}`)||i(t))return!0;if(r?.loadBundle&&await r.loadBundle(e).catch(()=>!1)){let n=Date.now()+Math.max(100,Number(r.waitMs??1500));for(;;){if(i(`${e}:${t}`)||i(t))return!0;if(Date.now()>=n)break;await new Promise(e=>setTimeout(e,100))}}return!1}var ec=`pi-web-ui:toast`,tc=new Map,nc=!1;function rc(e){let t=e.split(`+`).map(e=>e.trim().toLowerCase()).filter(e=>e.length>0);if(t.length===0)return null;let n=!1,r=!1,i=!1,a=!1;for(let e of t.slice(0,-1))if(e===`ctrl`||e===`control`)n=!0;else if(e===`shift`)r=!0;else if(e===`alt`||e===`option`)i=!0;else if(e===`meta`||e===`cmd`||e===`command`||e===`win`||e===`super`)a=!0;else return null;let o=t[t.length-1]??``;return!o||[`ctrl`,`control`,`shift`,`alt`,`option`,`meta`,`cmd`,`command`,`win`,`super`].includes(o)?null:{combo:`${n?`ctrl+`:``}${r?`shift+`:``}${i?`alt+`:``}${a?`meta+`:``}${o}`,key:o,ctrl:n,shift:r,alt:i,meta:a}}function ic(){try{if(typeof document>`u`)return!1;let e=document.activeElement;if(!e)return!1;let t=(e.tagName||``).toUpperCase();return!!(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)}catch{return!1}}function ac(e){try{if(ic())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=tc.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function oc(){if(!nc)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,ac),nc=!0}catch{}}function sc(){if(!(tc.size>0||!nc))try{window.removeEventListener(`keydown`,ac)}catch{}finally{nc=!1}}function cc(e,t){if(typeof t!=`function`)return()=>{};let n=rc(e);if(!n)return()=>{};let r=tc.get(n.combo);r||(r=new Set,tc.set(n.combo,r));let i=r;return i.add(t),oc(),()=>{i.delete(t),i.size===0&&tc.delete(n.combo),sc()}}var lc=new Map;function uc(e){let t=String(e?.id??``).trim();if(!t||typeof e?.search!=`function`)return()=>{};let n={id:t,label:String(e.label??t),search:e.search};return lc.set(t,n),()=>{lc.get(t)===n&&lc.delete(t)}}function dc(){return[...lc.values()].map(e=>({id:e.id,label:e.label}))}var fc=new Map;function pc(e){let t=String(e?.id??``).trim();if(!t||typeof e?.search!=`function`)return()=>{};let n={id:t,label:String(e.label??t),search:e.search};return fc.set(t,n),()=>{fc.get(t)===n&&fc.delete(t)}}function mc(){return[...fc.values()].map(e=>({id:e.id,label:e.label}))}function hc(e){return fc.get(String(e??``))}function gc(e){return lc.get(String(e??``))}var _c=new Set,vc=new Set,yc=new Set,bc=new Set;function xc(e){return bc.add(e),()=>{bc.delete(e)}}function Sc(e){for(let t of bc)try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function Cc(e){return typeof e==`function`?(_c.add(e),()=>{_c.delete(e)}):()=>{}}function wc(e){return typeof e==`function`?(vc.add(e),()=>{vc.delete(e)}):()=>{}}function Tc(e){return typeof e==`function`?(yc.add(e),()=>{yc.delete(e)}):()=>{}}function Ec(e){let t=String(e??``);for(let e of _c)try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function Dc(e){let t=String(e??``);for(let e of vc)try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function Oc(e){let t=String(e??``);for(let e of yc)try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var kc=new Map;function Ac(e){let t=kc.get(e.requestId);if(t){if(kc.delete(e.requestId),!e.ok){t({ok:!1,error:e.error??`目录同步失败`});return}t({ok:!0,...e.entries?{entries:e.entries}:{},...e.installed?{installed:e.installed}:{}})}}var jc=`modulepreload`,Mc=function(e){return`/`+e},Nc={},Pc=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Mc(t,n),t=s(t),t in Nc)return;Nc[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:jc,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Fc=`pi-web-ui:plugin-data`;function Ic(e,t){window.dispatchEvent(new CustomEvent(Fc,{detail:{pluginId:e,payload:t}}))}function Lc(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(Fc,t),()=>window.removeEventListener(Fc,t)}var Rc=new Map,zc=new Set,Bc=new Set,Vc=new Set,Hc=new Set,Uc=-1;function Wc(){return[...Rc.values()]}function Gc(){let e=Wc();for(let t of Bc)t(e)}function Kc(){let e=[...Vc];for(let t of Hc)t(e)}function qc(e){return Hc.add(e),e([...Vc]),()=>Hc.delete(e)}async function Jc(e,t){Vc.delete(e.id),Xc.set(e.id,(Xc.get(e.id)??0)+1),Kc();let n=await tl(e,t);return Gc(),n}function Yc(e){return Bc.add(e),e(Wc()),()=>Bc.delete(e)}var Xc=new Map;function Zc(e,t){let n=Xc.get(e)??0;return fn(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function Qc(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>Ys(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var $c=Qc(e=>Pc(()=>import(e),[]));async function el(e,t){if(!e.hasClient||e.error)return null;try{return(await $c(e.id,Zc(e.id,t))).default??null}catch(t){return console.error(`[plugin:${e.id}] 客户端 bundle 加载失败:`,t),null}}async function tl(e,t){try{let n=(await $c(e.id,Zc(e.id,t))).default;return n&&typeof n.mount==`function`?(Rc.set(e.id,{info:e,module:n}),!0):e.preload?(zc.add(e.id),!0):(Vc.add(e.id),Kc(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return Vc.add(e.id),Kc(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function nl(e,t){if(Rc.has(e.id)||zc.has(e.id))return!0;if(Vc.has(e.id)||!e.hasClient)return!1;let n=await tl(e,t);return Gc(),n}async function rl(e,t){t!==Uc&&(Uc=t,Rc.clear(),zc.clear(),Vc.clear(),Xc.clear(),Kc());let n=new Set(e.map(e=>e.id));for(let e of[...Rc.keys()])n.has(e)||Rc.delete(e);for(let e of[...zc])n.has(e)||zc.delete(e);for(let e of[...Vc])n.has(e)||Vc.delete(e);Kc(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!Rc.has(e.id)&&!zc.has(e.id)&&!Vc.has(e.id)).map(e=>tl(e,t))),Gc()}function il(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>Lc((n,r)=>{n===e&&t(r)})}}var al=[`debug`,`info`,`warn`,`error`];function ol(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function sl(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function cl(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.__host!==`logs`||!Array.isArray(t.logs)?!1:t.logs.every(e=>!!e&&typeof e==`object`&&typeof e.ts==`number`&&typeof e.text==`string`&&al.includes(String(e.level)))}var ll=new Map,ul=new Set;function dl(){for(let e of[...ul])try{e()}catch{}}function fl(e){return ul.add(e),()=>ul.delete(e)}function pl(e){return(ll.get(e)??[]).map(e=>({...e}))}function ml(e,t){return cl(t)?(ll.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),dl(),!0):!1}function hl(e){switch(e){case`error`:return 6500;case`warning`:return 4200;default:return 2400}}var gl=[/^(已在工作目录|正在切换到工作目录|已切换到工作目录)[::]/,/^(Already in directory|Switching to directory|Switched to directory):/i,/该项目最近的对话.*(为你停在了空白新对话|为你停在了新对话)/,/The most recent conversation .* landed on a (blank|new) chat/i,/^分层上下文预算裁剪生效/,/^Tiered context budget pruning/i,/^发现 \d+ 个内置插件有更新可用/,/^\d+ built-in plugin\(s\) have updates available/i,/^已(创建文件|创建文件夹|重命名|删除|移动|复制)[::]/,/^(Created file|Created folder|Renamed|Deleted|Moved|Copied):/i,/^已重命名当前会话为/,/^Renamed current session to/i,/的消息正在投递,已为你保留该对话$/,/is still sending your message — kept in the running list$/i,/^(计划模式已开启|计划模式已关闭|已进入计划模式|已退出计划模式|审查者模式已开启|审查者模式已关闭)/,/^(Plan mode (enabled|disabled)|Entered plan mode|Exited plan mode|Delegate mode (enabled|disabled))/i,/^已切换(智能体预设|权限预设)/,/^Switched (agent|permission) preset/i];function _l(e){if(e.level!==`info`)return!1;let t=(e.text??``).trim(),n=(e.textEn??``).trim();return gl.some(e=>t&&e.test(t)||n&&e.test(n))}function vl(e,t,n=2){if(_l(t))return e;let r=`${t.level}:${(t.text??``).trim()}`,i=[...e.filter(e=>`${e.level}:${(e.text??``).trim()}`!==r),t];for(;i.length>n;){let e=i.findIndex(e=>e.level!==`error`);e>=0?i.splice(e,1):i.shift()}return i}function yl(){return{flows:[],results:{}}}function bl(e,t){let n=e.findIndex(e=>e.flowId===t.flowId);return n<0?[...e,t]:e.map((e,r)=>r===n?t:e)}function xl(e,t){switch(t.type){case`provider_oauth_started`:{let n={...e.results};return delete n[t.provider],{flows:[...e.flows.filter(e=>e.provider!==t.provider),{flowId:t.flowId,provider:t.provider}],results:n}}case`provider_oauth_flows`:return{...e,flows:t.flows.map(e=>({...e}))};case`provider_oauth_prompt`:{let n=e.flows.find(e=>e.flowId===t.flowId);return{...e,flows:bl(e.flows,{...n,flowId:t.flowId,provider:t.provider,promptId:t.promptId,prompt:t.prompt})}}case`provider_oauth_event`:{let n=e.flows.find(e=>e.flowId===t.flowId);return{...e,flows:bl(e.flows,{...n,flowId:t.flowId,provider:t.provider,event:t.event,promptId:void 0,prompt:void 0})}}case`provider_oauth_result`:return{flows:e.flows.filter(e=>e.flowId!==t.flowId),results:{...e.results,[t.provider]:{ok:t.ok,...t.cancelled===void 0?{}:{cancelled:t.cancelled},...t.error===void 0?{}:{error:t.error}}}};case`provider_oauth_logout_result`:return{...e,results:{...e.results,[t.provider]:{ok:t.ok,...t.error===void 0?{}:{error:t.error}}}}}}var Sl=`pi-web-ui:lang`;function Cl(){try{return(localStorage.getItem(Sl)??``).trim()}catch{return``}}var wl=`pi-web-ui:locale`,Tl=2e5,El=2e5,Dl=`LIVE_OMIT`,Ol={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 kl(){let e=new Map,t=new Map,n=(e,t)=>`${e}:${t}`;return{write(r,i,a){let o=n(r,i),s=e.get(o);if(s&&s.size>0){for(let e of s)try{e.write(a)}catch{}return}let c=t.get(o)??``,l=c.length+a.length>El?a:c+a;t.set(o,l)},register(r,i,a){let o=n(r,i),s=e.get(o);s||(s=new Set,e.set(o,s)),s.add(a);let c=t.get(o);if(c){try{a.write(c)}catch{}t.delete(o)}return()=>{let n=e.get(o);n&&(n.delete(a),n.size===0&&e.delete(o)),t.delete(o)}},clear(){e.clear(),t.clear()}}}function Al(e,t){let n=new Set;for(let e of t.messages)e.role===`toolResult`&&e.toolCallId&&n.add(e.toolCallId),e.role===`bashExecution`&&n.add(`bash-${e.id}`);let r=!1;for(let t of e.keys())n.has(t)&&(e.delete(t),r=!0);return r?new Map(e):e}function jl(e,t){if(e.size===0)return e;let n=new Set;for(let e of t.messages)e.role===`toolResult`&&e.toolCallId&&n.add(e.toolCallId);let r=!1;for(let t of e.keys())n.has(t)&&(e.delete(t),r=!0);return r?new Map(e):e}function Ml(e,t){switch(t.type){case`status`:return{...e,status:t.status,ready:t.status===`open`&&e.ready,terminals:t.status===`closed`?[]:e.terminals,hostMetrics:t.status===`closed`?null:e.hostMetrics};case`sync_cached_sessions`:return{...e,sessions:t.sessions};case`host_metrics`:return{...e,hostMetrics:t.metrics};case`ready`:return{...e,serverVersion:t.serverVersion,engine:t.engine,appVersion:t.appVersion,managed:t.managed===!0,tabs:t.tabs,ready:!0,protocolMismatch:t.protocolVersion!==void 0&&t.protocolVersion!==29};case`snapshot`:{let n=e.state?.cwd,r=e.state?.conversationId,i=t.state.cwd,a=e.sessions;i&&i!==n&&(a=Kl(i));let o=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),s=e.transition;return s&&(s.phase===`done`||s.phase===`error`||s.kind===`cwd`&&o(t.state.cwd)===o(s.target)||s.kind===`session`&&o(t.state.sessionFile)===o(s.target)||s.kind===`conversation`&&t.state.conversationId===s.target||s.kind===`new_chat`&&(!r||t.state.conversationId!==r||t.state.messages.length===0))&&(s=null),{...e,ready:!0,state:t.state,transition:s,sessions:a,approval:t.state.pendingApproval??null,activeConversationId:t.state.conversationId,liveOutputs:Al(e.liveOutputs,t.state),toolStatuses:jl(e.toolStatuses,t.state)}}case`snapshot_delta`:{let n=e.state,r=t.msg;if(!n||n.conversationId!==r.conversationId||n.rev!==r.baseRev)return e;let i={...n,...r.state,messages:r.appended.length>0?[...n.messages,...r.appended]:n.messages};return{...e,ready:!0,state:i,approval:i.pendingApproval===void 0?e.approval:i.pendingApproval??null,activeConversationId:i.conversationId,liveOutputs:Al(e.liveOutputs,i),toolStatuses:jl(e.toolStatuses,i)}}case`tool_approval`:return{...e,approval:t.approval};case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>Tl?`…[${Dl}:${n.length-Tl}]…\n`+n.slice(n.length-Tl):n,i=new Map(e.liveOutputs);return i.set(t.toolCallId,{toolName:t.toolName,text:r}),{...e,liveOutputs:i}}case`message_delta`:{let n=e.state;return!n||n.conversationId!==t.msg.conversationId?e:{...e,state:as(n,t.msg)}}case`tool_status`:return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case`notice`:{let n=vl(e.notices,t.notice);return n===e.notices?e:{...e,notices:n}}case`dismiss_notice`:return{...e,notices:e.notices.filter(e=>e.id!==t.id)};case`sessions`:return ql(e.state?.cwd,t.sessions),{...e,sessions:t.sessions};case`conversations`:return{...e,conversations:t.conversations,elsewhere:t.elsewhere??[],activeConversationId:t.activeId};case`projects`:return Hl(t.projects),{...e,projects:t.projects};case`sandbox_diff`:return{...e,sandboxDiff:t.diff};case`files`:return{...e,files:t.files};case`file_changed`:return{...e,fileChanged:{path:t.path}};case`file_content`:return{...e,fileContent:t.content};case`models`:return{...e,models:t.models,modelsLoading:t.loading};case`models_config`:return{...e,modelsConfig:t.providers};case`providers_status`:return{...e,providers:t.providers};case`provider_keys`:return{...e,providerKeys:t.keys};case`default_model`:return{...e,defaultModel:t.modelId};case`provider_oauth`:{let n=xl({flows:e.providerOAuthFlows,results:e.providerOAuthResults},t.message);return{...e,providerOAuthFlows:n.flows,providerOAuthResults:n.results}}case`fetch_models_result`:return{...e,fetchModelsResult:t.result};case`test_model_connection_result`:return{...e,testModelConnectionResult:t.result};case`enrich_models_progress`:return{...e,enrichModelsProgress:t.progress};case`enrich_models_result`:return{...e,enrichModelsResult:t.result,enrichModelsProgress:null};case`refresh_provider_result`:return{...e,refreshProviderResult:t.result};case`refresh_builtin_result`:return{...e,refreshBuiltinResult:t.result};case`append_builtin_result`:return{...e,appendBuiltinResult:t.result};case`clone_provider_result`:return{...e,cloneProviderResult:t.result};case`install_result`:return{...e,installResult:t.result};case`scm_data`:return{...e,scmData:t.data};case`file_search_result`:return{...e,fileSearch:t.result};case`session_search_result`:return{...e,sessionSearch:t.result};case`scm_changed`:return{...e,scmDirty:e.scmDirty+1};case`path_completions`:return{...e,pathCompletions:t.completions};case`update_status`:return{...e,update:t.status};case`update_status_all`:return{...e,updatesAll:t.items,updatesSdk:t.piSdk??null};case`updates_check_started`:return{...e,updatesAll:null};case`widgets`:return{...e,widgets:t.widgets};case`statuses`:return{...e,statuses:t.statuses};case`dialog`:return{...e,dialog:t.dialog};case`tui_overlay`:return{...e,tuiOverlay:t.overlay};case`question`:return{...e,question:t.question};case`remote_question`:return{...e,remoteQuestion:t.question};case`commands`:return{...e,commands:t.commands,commandsPath:t.path};case`slash_commands`:return{...e,slashCommands:t.commands};case`goal_status`:return{...e,goal:t.status};case`plan_updated`:{let n=e.state;if(!n)return e;let r=e.activeConversationId||n.conversationId;if(!t.conversationId||t.conversationId!==r)return e;let i={...n,plan:t.plan};return{...e,state:i}}case`settings`:return{...e,settings:t.settings};case`mcp_servers`:return e.settings?{...e,settings:{...e.settings,mcpServers:t.servers,mcpGlobalConfigPath:t.globalConfigPath??e.settings.mcpGlobalConfigPath,mcpProjectConfigPath:t.projectConfigPath??e.settings.mcpProjectConfigPath}}:e;case`mcp_market_result`:return{...e,mcpMarketResult:t.result};case`skill_market_result`:return{...e,skillMarketResult:t.result};case`skill_content_result`:return{...e,skillContentResult:t.result};case`bg_servers`:return{...e,bgServers:t.servers};case`scheduler_tasks`:return{...e,schedulerTasks:t.tasks};case`plugin_panel_items`:return{...e,pluginPanelGroups:t.groups};case`plugins`:return{...e,plugins:t.plugins,pluginsEpoch:t.epoch};case`plugin_updates_check_started`:return{...e,checkingPluginUpdates:!0};case`plugin_updates`:{let n={};for(let e of t.updates)n[e.id]=e;return{...e,pluginUpdates:n,checkingPluginUpdates:!1}}case`plugin_catalog`:return{...e,pluginCatalog:t.entries,pluginCatalogEpoch:t.epoch};case`plugin_grants`:return{...e,pluginGrants:t.grants};case`plugin_permissions`:return{...e,pluginPermissions:t.grants};case`plugin_path_request`:return{...e,pathRequests:[...e.pathRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_path_resolved`:return{...e,pathRequests:e.pathRequests.filter(e=>e.id!==t.id)};case`plugin_permission_request`:return{...e,permRequests:[...e.permRequests.filter(e=>e.id!==t.req.id),t.req]};case`plugin_permission_resolved`:return{...e,permRequests:e.permRequests.filter(e=>e.id!==t.id)};case`plugin_job`:{let{pluginId:n,phase:r,ok:i,action:a}=t.job,o=e.pluginUpdates;a===`update`&&r===`done`&&i&&e.pluginUpdates?.[n]&&(o={...e.pluginUpdates,[n]:{...e.pluginUpdates[n],updatable:!1}});let s=e.pluginJobs[t.job.jobId],c=t.line?[...s?.lines??[],t.line].slice(-40):s?.lines??[],l={...s,...t.job,lines:c,startedAt:s?.startedAt??Date.now()};return{...e,pluginUpdates:o,pluginJobs:{...e.pluginJobs,[t.job.jobId]:l}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};case`preset_export_result`:return{...e,presetExport:{...t.result,receivedAt:Date.now()}};case`preset_import_result`:return{...e,presetImport:{...t.result,source:t.source,receivedAt:Date.now()}};case`preset_catalog_result`:return{...e,presetCatalog:{...t.result,receivedAt:Date.now()}};case`preset_share_result`:return{...e,presetShare:{...t.result,receivedAt:Date.now()}};case`plugin_install_inspect_result`:return{...e,installInspect:t.result};case`dsh_patches`:return{...e,dshPatches:{patchDir:t.patchDir,files:t.files}};case`dsh_presets`:return{...e,dshPresets:{presets:t.presets,defaultPreset:t.defaultPreset}};case`dsh_permission`:return{...e,dshPermission:{options:t.options,defaultPreset:t.defaultPreset}};case`terminal_add`:return{...e,terminals:[...e.terminals,t.meta]};case`terminal_remove`:return{...e,terminals:e.terminals.filter(e=>e.id!==t.id)};case`terminal_exit`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!1,exitCode:t.exitCode}:e)};case`terminal_restart`:return{...e,terminals:e.terminals.map(e=>e.id===t.terminalId?{...e,running:!0,exitCode:null}:e)};case`terminal_list`:return t.conversationId&&(e.activeConversationId||e.state?.conversationId)&&t.conversationId!==(e.activeConversationId||e.state?.conversationId)?e:{...e,terminals:t.terminals.map(n=>({...n,conversationId:t.conversationId??e.state?.conversationId??``}))};case`terminal_active`:return{...e,terminalActiveId:t.id};case`transition_start`:{let n=t.kind===`cwd`?Kl(t.target):null;return{...e,...n&&n.length>0?{sessions:n}:{},transition:{kind:t.kind,target:t.target,phase:`start`,progress:t.progress,text:t.text,textEn:t.textEn,startedAt:Date.now()}}}case`transition_progress`:{let n=t.msg;if(n.phase===`done`||n.phase===`error`)return{...e,transition:e.transition?{...e.transition,phase:n.phase,progress:100,text:n.text,textEn:n.textEn}:null};let r=e.transition;return{...e,transition:{kind:n.kind,target:n.target,phase:n.phase,progress:Math.max(r?.target===n.target?r.progress:0,n.progress),text:n.text,textEn:n.textEn,totalMessages:n.totalMessages??r?.totalMessages,previewMessages:n.previewMessages??r?.previewMessages,startedAt:r?.startedAt??Date.now()}}}case`transition_tick`:{let t=e.transition;if(!t||t.phase===`done`||t.phase===`error`)return e;let n=t.phase===`start`?26:t.phase===`fs`?56:92;if(t.progress>=n)return e;let r=Math.max(1,Math.round((n-t.progress)*.16));return{...e,transition:{...t,progress:Math.min(n,t.progress+r)}}}case`transition_clear`:return e.transition?{...e,transition:null}:e;default:return e}}var Nl=`pi-web-client-id`,Pl=null;function Fl(){if(Pl)return Pl;let e=null;try{e=sessionStorage.getItem(Nl),e||(e=jt(),sessionStorage.setItem(Nl,e))}catch{e??=jt()}return Pl=e,e}var Il=`pi-web-last-cwd`;function Ll(){try{return localStorage.getItem(Il)}catch{return null}}function Rl(e){try{localStorage.setItem(Il,e)}catch{}}function zl(e){try{let t=localStorage.getItem(Il);if(!t)return;let n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase();(t===e||n(t)===n(e))&&localStorage.removeItem(Il)}catch{}}var Bl=`pi-web-recent-projects`;function Vl(){try{let e=localStorage.getItem(Bl);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function Hl(e){try{localStorage.setItem(Bl,JSON.stringify(e.slice(0,20)))}catch{}}function Ul(e){try{let t=Vl(),n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),r=n(e);Hl(t.filter(e=>n(e.path)!==r))}catch{}}var Wl=`pi-web-recent-sessions:`;function Gl(e){return e?`${Wl}${e.trim().replace(/[\\/]+$/,``).toLowerCase()}`:`pi-web-recent-sessions:default`}function Kl(e){try{let t=Gl(e??Ll()),n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function ql(e,t){try{let n=Gl(e??Ll());localStorage.setItem(n,JSON.stringify(t.slice(0,50)))}catch{}}function Jl(e,t){try{let n=Kl(t),r=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),i=r(e);ql(t,n.filter(e=>r(e.path)!==i))}catch{}}function Yl(){return gn(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${fn(`/ws`)}`)}function Xl(){let[e,t]=(0,g.useReducer)(Ml,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:Kl(),conversations:[],elsewhere:[],activeConversationId:``,projects:Vl(),files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:yl().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,updatesSdk:null,widgets:[],statuses:[],dialog:null,tuiOverlay:null,approval:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:Ol,bgServers:[],schedulerTasks:[],pluginPanelGroups:[],settings:null,fetchModelsResult:null,testModelConnectionResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginUpdates:null,checkingPluginUpdates:!1,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,presetExport:null,presetImport:null,presetCatalog:null,presetShare:null,installInspect:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,mcpMarketResult:null,skillMarketResult:null,skillContentResult:null,dshPresets:null,dshPermission:null,protocolMismatch:!1,transition:null,sandboxDiff:null}),n=(0,g.useRef)(null),r=(0,g.useRef)(kl()),i=(0,g.useRef)(0),a=(0,g.useRef)(null),o=(0,g.useRef)(!0),s=(0,g.useRef)(0),c=(0,g.useRef)(0),l=(0,g.useRef)(new Map),u=(0,g.useRef)(null),d=(0,g.useRef)(!1),f=(0,g.useRef)(null),p=(0,g.useRef)(new Set),m=(0,g.useRef)(`live`),h=()=>{u.current||=setTimeout(()=>{u.current=null;let e=n.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`get_state`}))},300)},_=(e,t)=>{let n=l.current,r=n.get(e);if(r!==void 0&&t!==r+1){let t=O.current.chat;e===(t.activeConversationId||t.state?.conversationId)&&h()}n.set(e,t)},v=(0,g.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]);(0,g.useEffect)(()=>{if(!e.transition)return;if(e.transition.phase===`done`||e.transition.phase===`error`){let e=setTimeout(()=>t({type:`transition_clear`}),180);return()=>clearTimeout(e)}let n=setInterval(()=>{if(Date.now()-(e.transition?.startedAt??0)>2e4){t({type:`transition_clear`});return}t({type:`transition_tick`})},160);return()=>clearInterval(n)},[e.transition]);let y=(0,g.useCallback)(e=>{let r=O.current.chat.state;if(e.type===`set_cwd`&&e.path){let n=(r?.cwd??``).trim().replace(/[\\/]+$/,``).toLowerCase(),i=e.path.trim().replace(/[\\/]+$/,``).toLowerCase();i&&i!==n&&t({type:`transition_start`,kind:`cwd`,target:e.path,progress:14,text:`正在切换到工作目录:${e.path}`,textEn:`Switching to workspace: ${e.path}`})}else if(e.type===`switch_session`&&e.path){let n=(r?.sessionFile??``).trim().replace(/[\\/]+$/,``).toLowerCase(),i=e.path.trim().replace(/[\\/]+$/,``).toLowerCase();i&&i!==n&&t({type:`transition_start`,kind:`session`,target:e.path,progress:14,text:`正在流式载入历史会话…`,textEn:`Streaming session history…`})}else e.type===`new_chat`?r&&(r.messages.length>0||r.isStreaming)&&t({type:`transition_start`,kind:`new_chat`,target:r.cwd,progress:22,text:`正在初始化新对话…`,textEn:`Initializing new chat…`}):e.type===`switch_conversation`&&e.id&&r&&e.id!==r.conversationId&&t({type:`transition_start`,kind:`conversation`,target:e.id,progress:35,text:`正在切换对话…`,textEn:`Switching conversation…`});let i=n.current;if(i&&i.readyState===WebSocket.OPEN){if(e.type===`check_updates_all`&&e.force===!0&&t({type:`updates_check_started`}),e.type===`check_plugin_updates`&&t({type:`plugin_updates_check_started`}),i.send(JSON.stringify(e)),e.type===`question_answer`){if(e.owner){let n=O.current.chat.remoteQuestion;n&&n.id===e.id&&t({type:`remote_question`,question:null})}else{if(p.current.add(e.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}m.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,g.useCallback)((e,n)=>{let r=os({current:O.current.chat.question,source:m.current,snapshot:e,answered:p.current,activeConversationId:n});r.changed&&(m.current=r.source,t({type:`question`,question:r.question}))},[]);no(y);let x=(0,g.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(Yl());n.current=e,e.onopen=()=>{n.current===e&&(t({type:`status`,status:`open`}),i.current=0,s.current=Date.now(),e.send(JSON.stringify({type:`hello`,clientId:Fl(),locale:Cl()})))},e.onmessage=i=>{if(n.current!==e)return;s.current=Date.now();let a;try{a=JSON.parse(i.data)}catch{return}switch(a.type){case`ready`:if((O.current.chat.settings?.autoReload??!0)&&a.buildId&&a.buildId!==`20261011T13070`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}qa({engine:a.engine??`pi`,managed:!!a.managed,tabs:a.tabs,appVersion:a.appVersion,serverVersion:a.serverVersion,service:a.service}),t({type:`ready`,serverVersion:a.serverVersion,protocolVersion:a.protocolVersion,engine:a.engine,appVersion:a.appVersion,managed:a.managed,tabs:a.tabs,service:a.service}),p.current.clear(),t({type:`question`,question:null}),e.send(JSON.stringify({type:`get_state`})),e.send(JSON.stringify({type:`list_files`})),e.send(JSON.stringify({type:`list_models`})),e.send(JSON.stringify({type:`list_commands`})),e.send(JSON.stringify({type:`get_commands`})),a.managed||(e.send(JSON.stringify({type:`check_update`})),e.send(JSON.stringify({type:`check_updates_all`})));break;case`snapshot`:l.current=new Map,t({type:`snapshot`,state:a.state}),b(a.state.pendingQuestion,a.state.conversationId);break;case`snapshot_delta`:{let e=O.current.chat.state;if(e)(e.conversationId!==a.conversationId||e.rev!==a.baseRev)&&h();else{let e=n.current;e&&e.readyState===WebSocket.OPEN&&e.send(JSON.stringify({type:`get_state`}))}t({type:`snapshot_delta`,msg:a}),b(a.state.pendingQuestion,a.conversationId);break}case`tool_delta`:_(a.conversationId,a.seq),t({type:`tool_delta`,toolCallId:a.toolCallId,toolName:a.toolName,delta:a.delta});break;case`tool_status`:t({type:`tool_status`,status:a});break;case`message_delta`:_(a.conversationId,a.seq),t({type:`message_delta`,msg:a});break;case`subagent_handoff`:break;case`notice`:{let e=++c.current;(a.level===`error`||a.level===`warning`)&&t({type:`transition_clear`}),t({type:`notice`,notice:{id:e,level:a.level,text:a.text,textEn:a.textEn}});break}case`transition_progress`:t({type:`transition_progress`,msg:a});break;case`sessions`:t({type:`sessions`,sessions:a.sessions});break;case`conversations`:t({type:`conversations`,conversations:a.conversations,activeId:a.activeId,elsewhere:a.elsewhere});break;case`projects`:t({type:`projects`,projects:a.projects});break;case`sandbox_diff`:t({type:`sandbox_diff`,diff:a.diff});break;case`files`:t({type:`files`,files:a});break;case`file_changed`:t({type:`file_changed`,path:a.path});break;case`file_content`:t({type:`file_content`,content:a});break;case`models`:t({type:`models`,models:a.models,loading:!1});break;case`models_config`:t({type:`models_config`,providers:a.providers});break;case`providers_status`:t({type:`providers_status`,providers:a.providers});break;case`provider_keys`:t({type:`provider_keys`,keys:a.keys});break;case`default_model`:t({type:`default_model`,modelId:a.modelId});break;case`provider_oauth_started`:case`provider_oauth_flows`:case`provider_oauth_prompt`:case`provider_oauth_event`:case`provider_oauth_result`:case`provider_oauth_logout_result`:t({type:`provider_oauth`,message:a});break;case`fetch_models_result`:t({type:`fetch_models_result`,result:{reqId:a.reqId,ok:a.ok,models:a.models,error:a.error}});break;case`test_model_connection_result`:t({type:`test_model_connection_result`,result:{reqId:a.reqId,ok:a.ok,latencyMs:a.latencyMs,error:a.error}});break;case`enrich_models_progress`:t({type:`enrich_models_progress`,progress:{reqId:a.reqId,phase:a.phase,current:a.current,total:a.total,message:a.message}});break;case`enrich_models_result`:t({type:`enrich_models_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,error:a.error}});break;case`refresh_provider_result`:t({type:`refresh_provider_result`,result:{reqId:a.reqId,ok:a.ok,added:a.added,total:a.total,error:a.error}});break;case`refresh_builtin_result`:t({type:`refresh_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`append_builtin_result`:t({type:`append_builtin_result`,result:{reqId:a.reqId,ok:a.ok,error:a.error}});break;case`clone_provider_result`:t({type:`clone_provider_result`,result:{reqId:a.reqId,ok:a.ok,config:a.config,configs:a.configs,error:a.error}});break;case`scm_data`:t({type:`scm_data`,data:a});break;case`search_files_result`:t({type:`file_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results,truncated:a.truncated}});break;case`session_search_results`:t({type:`session_search_result`,result:{reqId:a.reqId,ok:a.ok,results:a.results}});break;case`scm_changed`:t({type:`scm_changed`});break;case`tool_info`:gs(a);break;case`tool_prompt`:Ts(a);break;case`compacted_messages_result`:Is(a);break;case`heartbeat`:a.hostMetrics&&t({type:`host_metrics`,metrics:a.hostMetrics});break;case`install_result`:t({type:`install_result`,result:a});break;case`path_completions`:t({type:`path_completions`,completions:a.completions});break;case`update_status`:t({type:`update_status`,status:a});break;case`update_status_all`:t({type:`update_status_all`,items:a.items,piSdk:a.piSdk});break;case`widgets`:t({type:`widgets`,widgets:a.widgets});break;case`statuses`:t({type:`statuses`,statuses:a.statuses});break;case`dialog`:t({type:`dialog`,dialog:{id:a.id,kind:a.kind,title:a.title,args:a.args}});break;case`dialog_closed`:t({type:`dialog`,dialog:null});break;case`tui_overlay_open`:t({type:`tui_overlay`,overlay:{id:a.id,title:a.title,cols:a.cols,rows:a.rows,initialAnsi:a.initialAnsi}});break;case`tui_overlay_render`:ls(a.id,a.ansi);break;case`tui_overlay_close`:t({type:`tui_overlay`,overlay:null});break;case`question_pending`:m.current=`live`,t({type:`question`,question:{id:a.id,...a.deadline===void 0?{}:{deadline:a.deadline},questions:a.questions,...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_pending`:t({type:`tool_approval`,approval:{id:a.id,toolCallId:a.toolCallId,toolName:a.toolName,params:a.params,reason:a.reason,reasonEn:a.reasonEn,...a.category?{category:a.category}:{},...a.conversationId===void 0?{}:{conversationId:a.conversationId},...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`tool_approval_resolved`:t({type:`tool_approval`,approval:null});break;case`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(p.current.add(a.id),p.current.size>64){let e=p.current.values().next().value;e!==void 0&&p.current.delete(e)}m.current=`live`,t({type:`question`,question:null})}break}case`elsewhere_question`:t({type:`remote_question`,question:{owner:a.owner,convId:a.convId,id:a.id,questions:a.questions,...a.conversationTitle===void 0?{}:{conversationTitle:a.conversationTitle}}});break;case`page_request`:(async()=>{let e=window.__piWebUiHost,t;if(!e?.pageCall)t={ok:!1,error:`宿主页面桥不可用(页面版本过旧?)—— 刷新本页后再试`};else try{t=await e.pageCall({op:a.op,...a.args===void 0?{}:{args:a.args},...a.target?{target:a.target}:{},timeoutMs:a.timeoutMs})}catch(e){t={ok:!1,error:e instanceof Error?e.message:String(e)}}y({type:`page_response`,id:a.id,ok:t.ok===!0,...t.ok===!0?t.result===void 0?{}:{result:t.result}:{error:t.error??`页面操作失败`}})})();break;case`terminal_output`:r.current.write(a.conversationId??O.current.chat.activeConversationId,a.terminalId,a.data);break;case`terminal_exit`:t({type:`terminal_exit`,conversationId:a.conversationId,terminalId:a.terminalId,exitCode:a.exitCode});break;case`terminal_list`:t({type:`terminal_list`,conversationId:a.conversationId,terminals:a.terminals});break;case`commands`:t({type:`commands`,commands:a.commands,path:a.path});break;case`slash_commands`:t({type:`slash_commands`,commands:a.commands});break;case`goal_status`:t({type:`goal_status`,status:a.status});break;case`plan_updated`:t({type:`plan_updated`,conversationId:a.conversationId,plan:a.plan});break;case`settings_state`:t({type:`settings`,settings:a.settings});break;case`mcp_servers`:t({type:`mcp_servers`,servers:a.servers,globalConfigPath:a.globalConfigPath,projectConfigPath:a.projectConfigPath});break;case`mcp_market_result`:t({type:`mcp_market_result`,result:a});break;case`skill_market_result`:t({type:`skill_market_result`,result:a});break;case`skill_content_result`:t({type:`skill_content_result`,result:a});break;case`bg_servers`:t({type:`bg_servers`,servers:a.servers});break;case`scheduler_tasks`:t({type:`scheduler_tasks`,tasks:a.tasks});break;case`plugin_panel_items`:t({type:`plugin_panel_items`,groups:a.groups});break;case`plugins`:t({type:`plugins`,plugins:a.plugins,epoch:a.epoch});break;case`plugin_updates`:t({type:`plugin_updates`,updates:a.updates});break;case`plugin_catalog`:t({type:`plugin_catalog`,entries:a.entries,epoch:a.epoch});break;case`plugin_grants`:t({type:`plugin_grants`,grants:a.grants});break;case`plugin_permissions`:t({type:`plugin_permissions`,grants:a.grants});break;case`plugin_permission_request`:t({type:`plugin_permission_request`,req:{id:a.id,pluginId:a.pluginId,family:a.family,...a.hosts?{hosts:a.hosts}:{},...a.models?{models:a.models}:{},...a.reason?{reason:a.reason}:{}}});break;case`plugin_permission_resolved`:t({type:`plugin_permission_resolved`,id:a.id});break;case`plugin_path_request`:t({type:`plugin_path_request`,req:{id:a.id,pluginId:a.pluginId,path:a.path,...a.reason?{reason:a.reason}:{}}});break;case`plugin_dom_consent_request`:a.from===Fl()&&e.send(JSON.stringify({type:`plugin_dom_consent_response`,id:a.id,ok:!0}));break;case`plugin_job`:t({type:`plugin_job`,job:{jobId:a.jobId,action:a.action,pluginId:a.pluginId,phase:a.phase,...a.ok===void 0?{}:{ok:a.ok},...a.error?{error:a.error}:{},...a.output?{output:a.output}:{}},...a.line?{line:a.line}:{}});break;case`plugin_install_inspect_result`:t({type:`plugin_install_inspect_result`,result:{requestId:String(a.requestId??``),source:String(a.source??``),kind:a.kind,suggestedId:String(a.suggestedId??``),installed:a.installed===!0,...a.problem?{problem:a.problem}:{},...a.detail?{detail:a.detail}:{},...a.manifest?{manifest:a.manifest}:{}}});break;case`plugin_catalog_sync_result`:Ac(a),t({type:`plugin_catalog_sync_result`,result:{requestId:String(a.requestId??``),ok:a.ok===!0,...a.error?{error:a.error}:{},...a.entries?{entryCount:a.entries.length}:{},...a.installed?{installed:a.installed}:{}}});break;case`preset_export_result`:t({type:`preset_export_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,...a.name?{name:a.name}:{},...a.fileName?{fileName:a.fileName}:{},...a.json?{json:a.json}:{},...a.error?{error:a.error}:{}}});break;case`preset_import_result`:{let e=String(a.requestId??``),n=e.startsWith(`url:`)?`url`:e.startsWith(`file:`)?`file`:`paste`;t({type:`preset_import_result`,source:n,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,dryRun:a.dryRun===!0,...a.preview?{preview:a.preview}:{},...a.applied?{applied:!0}:{},...a.error?{error:a.error}:{}}});break}case`preset_catalog_result`:t({type:`preset_catalog_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,entries:a.entries??[],source:a.source??``,cached:a.cached===!0,fetchedAt:a.fetchedAt??0,...a.error?{error:a.error}:{}}});break;case`preset_share_result`:t({type:`preset_share_result`,result:{...a.requestId?{requestId:a.requestId}:{},ok:a.ok===!0,...a.method?{method:a.method}:{},...a.url?{url:a.url}:{},...a.name?{name:a.name}:{},...a.json?{json:a.json}:{},...a.error?{error:a.error}:{}}});break;case`dsh_patches`:t({type:`dsh_patches`,patchDir:a.patchDir,files:a.files});break;case`dsh_presets`:t({type:`dsh_presets`,presets:a.presets,defaultPreset:a.defaultPreset});break;case`dsh_permission`:t({type:`dsh_permission`,options:a.options,defaultPreset:a.defaultPreset});break;case`plugin_data`:ml(a.pluginId,a.payload)||Ic(a.pluginId,a.payload);break;case`remote_ssh_probe_result`:case`remote_ssh_list_dir_result`:case`remote_ssh_install_result`:case`remote_ssh_profiles_result`:ao(a)}},e.onclose=()=>{if(n.current===e&&(n.current=null),r.current.clear(),!o.current||n.current&&n.current!==e)return;t({type:`status`,status:`closed`});let s=Math.min(1e3*2**i.current,1e4);i.current+=1,a.current=setTimeout(()=>{a.current=null,x()},s)},e.onerror=()=>{}},[]);(0,g.useEffect)(()=>{let e=e=>{let t=e.detail??Cl();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(wl,e),()=>window.removeEventListener(wl,e)},[y]),(0,g.useEffect)(()=>{let n=n=>{let r=e.state?.cwd;r&&n.key&&n.key===Gl(r)&&t({type:`sync_cached_sessions`,sessions:Kl(r)})};return window.addEventListener(`storage`,n),()=>window.removeEventListener(`storage`,n)},[e.state?.cwd]),(0,g.useEffect)(()=>{o.current=!0,x();let e=setInterval(()=>{if(!o.current)return;let e=n.current;e&&e.readyState===WebSocket.OPEN&&Date.now()-s.current>3e4&&e.close()},5e3),t=()=>{if(!o.current||typeof document<`u`&&document.visibilityState===`hidden`)return;let e=n.current;if(!e||e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING){a.current&&=(clearTimeout(a.current),null),x();return}e.readyState===WebSocket.OPEN&&(Date.now()-s.current>15e3||!O.current.chat.state)&&e.send(JSON.stringify({type:`get_state`}))};return typeof document<`u`&&document.addEventListener(`visibilitychange`,t),typeof window<`u`&&(window.addEventListener(`pageshow`,t),window.addEventListener(`online`,t)),()=>{o.current=!1,clearInterval(e),a.current&&=(clearTimeout(a.current),null),typeof document<`u`&&document.removeEventListener(`visibilitychange`,t),typeof window<`u`&&(window.removeEventListener(`pageshow`,t),window.removeEventListener(`online`,t)),n.current?.close(),n.current=null}},[x]),(0,g.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=Ll();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}f.current!==t&&(f.current=t,Rl(t))}},[e.state?.cwd,y]),(0,g.useEffect)(()=>{qa({ready:e.ready,status:e.status,cwd:e.state?.cwd??``,workspaceRoots:e.state?.workspaceRoots??[],homeDir:e.state?.homeDir??``,desktopDir:e.state?.desktopDir??``})},[e.ready,e.status,e.state?.cwd,e.state?.workspaceRoots,e.state?.homeDir,e.state?.desktopDir]);let S=(0,g.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,g.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,g.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,g.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,g.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,g.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,g.useRef)({chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}});return O.current={chat:e,send:y,pushNotice:v,dismissNotice:S,terminal:{create:C,close:w,register:D,restart:T,select:E}},O.current}function Zl(e){let t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`:`${t.getMonth()+1}/${t.getDate()}`}function Ql(e){let t=e instanceof HTMLElement?e:null;if(!t)return!1;let n=t.tagName;return n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.isContentEditable}var $l=`pi-web-ui:lp-collapse-projects`,eu=`pi-web-ui:lp-collapse-convs`,tu=`pi-web-ui:lp-collapse-sessions`,nu=`pi-web-ui:lp-collapse-subagents`;function ru(){let[e,t]=(0,g.useState)(()=>{try{let e=localStorage.getItem(nu);if(e)return new Set(JSON.parse(e))}catch{}return new Set});return[e,(0,g.useCallback)(e=>{t(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(nu,JSON.stringify([...n]))}catch{}return n})},[])]}function iu(e,t=!1){let[n,r]=(0,g.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,g.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var au=`pi-web-ui:lp-collapse-plugin-sections`;function ou(){let[e,t]=(0,g.useState)(()=>{try{let e=localStorage.getItem(au),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}});return[e,(0,g.useCallback)(e=>{t(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{localStorage.setItem(au,JSON.stringify([...n]))}catch{}return n})},[])]}var su=`pi-web-ui:lp-sizes`,cu={projects:1,convs:1,sessions:1},lu=32,uu={running:`pluginRunStatusRunning`,done:`pluginRunStatusDone`,error:`pluginRunStatusError`},du=72;function fu(){try{return Ri(localStorage.getItem(su),cu)}catch{return{...cu}}}var pu=(0,g.memo)(function({sessionFile:e,conversations:t,elsewhere:n,sessions:r,projects:i,activeConversationId:a,panelSend:o,active:s,collapsible:c,onToggleCollapse:l,pathCompletions:u,uiContextSession:d,uiLeftSessions:f,uiContextProject:p,uiProjectsActions:m,uiLeftProject:h,uiRunningActions:_,uiHistoryActions:v,uiSections:y,renderPluginSectionBody:b,uiPluginRunning:x,onPluginRunningAction:S,uiLeftRunning:C,uiLeftHistory:w,onUiAction:T,presetNames:E,transition:D,onOpenSandboxModal:O}){let k=Z(),A=e,j=Za(`ready`),ee=Za(`status`),M=Za(`cwd`),te=Za(`workspaceRoots`),N=M,[ne,F]=(0,g.useState)(!1),[re,ie]=(0,g.useState)(null),[ae,I]=(0,g.useState)(null),[R,z]=(0,g.useState)(null),[oe,B]=(0,g.useState)(``),[V,H]=iu($l,!1),[se,ce]=iu(eu,!1),[le,ue]=iu(tu,!1),[U,de]=ou(),[fe,W]=ru(),[pe,G]=(0,g.useState)(60);(0,g.useEffect)(()=>{G(60)},[N]);let K=(0,g.useMemo)(()=>{if(r.length<=pe)return r;let e=A?r.findIndex(e=>e.path===A):-1,t=e>=pe?e+10:pe;return r.slice(0,t)},[r,pe,A]),he=(0,g.useCallback)((e,t)=>{if(!t)return e.filter(e=>e.isSubagent&&!e.isStreaming&&e.id!==a).length;let n=new Map(e.map(e=>[e.id,e])),r=e=>{if(e.id===t)return(n.get(t)?.isSubagent??!1)&&!e.isStreaming&&e.id!==a;let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&!e.isStreaming&&e.id!==a&&r(e)).length},[a]),ge=(0,g.useCallback)((e,t)=>{if(!t)return e.filter(e=>e.isSubagent).length;let n=new Map(e.map(e=>[e.id,e])),r=e=>{if(e.id===t)return n.get(t)?.isSubagent??!1;let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&r(e)).length},[]),q=(0,g.useCallback)((e,t)=>{if(!t)return 0;let n=new Map(e.map(e=>[e.id,e])),r=e=>{let r=e,i=new Set;for(;r?.parentId;){if(r.parentId===t)return!0;if(i.has(r.parentId)||(i.add(r.parentId),r=n.get(r.parentId),!r))return!1}return!1};return e.filter(e=>e.isSubagent&&e.isStreaming&&r(e)).length},[]),ve=(0,g.useRef)(null),ye=(0,g.useRef)(null),be=(0,g.useRef)(()=>{}),xe=La(d??[]).length>0,Se=(0,g.useCallback)((e,n,i)=>{ve.current={x:e,y:n,target:i};let a=i.kind===`running`?i.id:void 0,o=i.kind===`elsewhere`,s=a??(o&&i.id||void 0),c=he(t,a),l=c===0?k(`noFinishedSubagents`):k(a?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:c}),u=!!a&&ye.current===a;Ea({x:e,y:n,slot:`contextmenu.session`,target:i,entries:(d??[]).map(e=>{if(e.source!==`host`)return e;if(e.id===`host:conv-rename`)return i.kind===`running`||i.kind===`history`?e:{...e,hidden:!0};if(e.id===`host:conv-takeover`)return o&&s&&i.owner&&!i.pseudo?e:{...e,hidden:!0};if(o&&(e.id===`host:conv-dismiss-subagents`||e.id===`host:conv-force-dismiss`))return{...e,hidden:!0};if(e.id===`host:conv-dismiss-subagents`)return{...e,label:l,...c===0?{when:[...e.when??[],`disabled`]}:{}};if(e.id===`host:conv-force-dismiss`)return a?{...e,...u?{label:k(`forceDismissConfirm`)}:{}}:{...e,hidden:!0};if(e.id===`host:conv-pin`){if(i.kind===`history`)return r.find(e=>e.path===i.id)?.pinned?{...e,label:k(`unpinConversation`)}:e;if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return!n||n.isSubagent?{...e,hidden:!0}:n.pinned?{...e,label:k(`unpinConversation`)}:e}if(e.id===`host:conv-persist`){if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return!n||!n.isSubagent&&n.sessionFile?{...e,hidden:!0}:n?.isEphemeral?{...e,label:k(`saveEphemeral`)}:e}if(e.id===`host:conv-copy-id`)return s?e:{...e,hidden:!0};if(e.id===`host:conv-copy-path`)return i.kind===`history`?e:a?t.some(e=>e.id===a&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0};if(e.id===`host:conv-copy-link`){if(i.kind===`history`)return r.find(e=>e.path===i.id)?.sessionId||rs(i.id)?e:{...e,hidden:!0};if(!a)return{...e,hidden:!0};let n=t.find(e=>e.id===a);return n?.sessionId||rs(n?.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}}return e.id===`host:conv-quote`?s||i.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>be.current(e,t)})},[d,t,he,k]);be.current=(0,g.useCallback)((e,n)=>{let i=n.kind===`running`?n.id:void 0,a=i??(n.kind===`elsewhere`&&n.id||void 0);if(e.id===`host:conv-takeover`){n.kind===`elsewhere`&&a&&n.owner&&o({type:`take_over_conversation`,owner:n.owner,id:a});return}if(e.id===`host:conv-dismiss-subagents`){o(i?{type:`dismiss_finished_subagents`,parentId:i}:{type:`dismiss_finished_subagents`});return}if(e.id===`host:conv-force-dismiss`){let e=ve.current;if(!i||!e)return;if(ye.current!==i)return ye.current=i,Se(e.x,e.y,e.target),!0;ye.current=null,o({type:`dismiss_conversation`,id:i,force:!0});return}if(e.id===`host:conv-persist`){i&&o({type:`persist_conversation`,id:i});return}if(e.id===`host:conv-pin`){if(n.kind===`history`){let e=r.find(e=>e.path===n.id);o({type:`pin_session`,path:n.id,pinned:!e?.pinned});return}i&&o({type:`pin_conversation`,id:i,pinned:!t.find(e=>e.id===i)?.pinned});return}if(e.id===`host:conv-copy-id`&&a){navigator.clipboard?.writeText(a).catch(()=>{});return}if(e.id===`host:conv-copy-path`){let e=n.kind===`history`?n.id:i&&t.find(e=>e.id===i)?.sessionFile||void 0;e&&navigator.clipboard?.writeText(e).catch(()=>{});return}if(e.id===`host:conv-copy-link`){let e=n.kind===`history`?r.find(e=>e.path===n.id)?.sessionId||rs(n.id):i?t.find(e=>e.id===i)?.sessionId||rs(t.find(e=>e.id===i)?.sessionFile):null;if(e){let t=ns(window.location.href,{sessionId:e});navigator.clipboard?.writeText(t).catch(()=>{})}return}if(e.id===`host:conv-quote`){n.kind===`history`&&n.id?lr({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&lr({attachments:[{path:``,key:`conv|${a}|`,name:n.label||a,mode:`conversation`,conversationId:a}]});return}if(e.id===`host:conv-rename`){if(ie(null),i){let e=t.find(e=>e.id===i);B(e?.title??n.label??``),z(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);B(e?.name??n.label??``),z(n.id)}return}},[o,Se,t,r]);let Ce=(e,t,n)=>!e||e.length===0?null:(0,X.jsx)(`span`,{className:t,children:e.map((e,t)=>{let r=`${e.id}#${t}`,i=e.label||e.id,a=e.hint||i;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`lp-slot-divider`,"aria-hidden":`true`},r):e.kind===`badge`?(0,X.jsx)(`span`,{className:`lp-slot-badge`,title:a,children:e.badge??i},r):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`lp-slot-select`,title:a,"aria-label":i,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onClick:e=>e.stopPropagation(),onChange:t=>{t.stopPropagation(),T?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r):(0,X.jsx)(`button`,{type:`button`,className:`lp-slot-btn`,title:a,"aria-label":i,onClick:t=>{t.stopPropagation(),n?T?.(e,void 0,n):T?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:i})},r)})}),we=(0,g.useCallback)((e,t)=>{Ql(e.target)||xe&&(e.preventDefault(),e.stopPropagation(),ye.current=null,Se(e.clientX,e.clientY,t))},[xe,Se]),Te=(0,g.useRef)(null),[De,Oe]=(0,g.useState)(()=>fu());(0,g.useEffect)(()=>{try{localStorage.setItem(su,JSON.stringify(De))}catch{}},[De]);let ke=(0,g.useMemo)(()=>{let e=new Set,r=new Set;for(let n of t)n.sessionFile&&e.add(n.sessionFile),r.add(`${n.cwd}\0${n.title}`);let i=[],a=new Set;for(let t of n){if(t.sessionFile&&e.has(t.sessionFile)||r.has(`${t.cwd}\0${t.title}`))continue;let n=t.sessionFile?`file:${t.sessionFile}`:`title:${t.cwd}\0${t.title}`;a.has(n)||(a.add(n),i.push({id:t.sessionFile?`elsewhere:${t.cwd}:${t.sessionFile}`:`elsewhere:${t.cwd}:${t.title}${t.owner?`:${t.owner}`:``}`,title:t.title,cwd:t.cwd,messageCount:0,isStreaming:t.isStreaming,isSubagent:!1,elsewhere:!0,pseudo:!!t.pseudo,ownerOffline:!!t.ownerOffline,sessionFile:t.sessionFile,...t.owner&&t.convId?{owner:t.owner,convId:t.convId}:{},...t.hasQuestion?{hasQuestion:!0}:{}}))}return[...t,...i]},[t,n]),Ae=Fi(y),je=Ae.filter(e=>e.shown),Me=e=>e===`projects`?V:e===`convs`?se:e===`sessions`?le:U.has(e),Ne=(x??[]).reduce((e,t)=>e+t.items.length,0),Pe=ke.length+Ne,Fe=Ii(Ae,e=>e===`projects`?i.length>0:e!==`convs`||Pe>0),Ie=()=>{let e=x??[];return e.length===0?null:e.map(e=>(0,X.jsxs)(`div`,{className:`panel-conv-group lp-plugin-group`,children:[(0,X.jsxs)(`div`,{className:`panel-conv-group-title`,title:e.pluginId,children:[k(`leftPanelPluginGroup`),` · `,e.pluginName]}),e.items.map(t=>(0,X.jsx)(`div`,{className:`lp-row lp-plugin-row`,children:(0,X.jsxs)(`button`,{type:`button`,className:`session-item lp-plugin-item${t.action?``:` is-static`}`,title:t.hint?`${t.title} — ${t.hint}`:t.title,onClick:()=>S?.(e,t),children:[(0,X.jsx)(`span`,{className:`lp-plugin-dot st-${t.status}`,title:k(uu[t.status])}),t.icon?(0,X.jsx)(`span`,{className:`lp-plugin-icon`,"aria-hidden":!0,children:t.icon}):null,(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:t.title}),t.hint?(0,X.jsx)(`span`,{className:`session-sub`,children:t.hint}):null]})]})},t.id))]},`plugin:${e.pluginId}`))},Le=(0,g.useMemo)(()=>[...f??[],...C??[]],[f,C]),Be=(0,g.useMemo)(()=>[...f??[],...w??[]],[f,w]),Ve=(0,g.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,i=n.clientY,a={...De},o=Te.current;if(!o)return;let s=Fe.filter(e=>Me(e)).length,c=Fe.filter(e=>!Me(e)).reduce((e,t)=>e+(a[t]??1),0)||1,l=Math.max(120,o.clientHeight-s*lu);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let u=n=>{let{above:r,below:o}=Zo({start:{above:a[e]??1,below:a[t]??1},deltaPx:n.clientY-i,availablePx:l,totalWeight:c,minAbovePx:du,minBelowPx:du});Oe(n=>({...n,[e]:r,[t]:o}))},d=()=>{window.removeEventListener(`pointermove`,u),window.removeEventListener(`pointerup`,d),r.classList.remove(`dragging`),document.body.classList.remove(`lp-resizing`)};window.addEventListener(`pointermove`,u),window.addEventListener(`pointerup`,d)},[De,Fe,V,se,le]);(0,g.useEffect)(()=>{s&&j&&ee===`open`&&M&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,j,ee,M,o]);let He=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:k(`emptyChat`)},Ue=e=>e.split(/[\\/]/).pop()||e,We=La(p??[]).length>0,Ge=(0,g.useCallback)((e,t)=>{Ql(e.target)||We&&(e.preventDefault(),e.stopPropagation(),Ea({x:e.clientX,y:e.clientY,slot:`contextmenu.project`,target:{id:t.path,kind:`project`,label:Ue(t.path)},entries:p??[]}))},[We,p]),Y=(e,t,n,r,i)=>{let a=re===e;return(0,X.jsx)(`button`,{type:`button`,className:`lp-del ${a?`confirm`:``}`,title:a?n:t,onClick:t=>{t.stopPropagation(),a?(ie(null),r()):ie(e)},children:a?(0,X.jsx)(ft,{}):i??(0,X.jsx)(L,{})})},qe=(e,t,n,r,i,a)=>(0,X.jsxs)(`div`,{className:`lp-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`lp-section-title panel-section-title`,onClick:n,title:k(t?`expandSection`:`collapseSection`),children:[(0,X.jsxs)(`span`,{className:`lp-section-title-text`,children:[e,r===void 0?``:` (${r})`]}),(0,X.jsx)(`span`,{className:`lp-section-chevron`,children:t?(0,X.jsx)(dt,{}):(0,X.jsx)(ct,{})})]}),i||a?(0,X.jsxs)(`div`,{className:`lp-section-actions`,children:[i,a]}):null]}),Je=Fe.filter(e=>!Me(e)),Ye=Je.reduce((e,t)=>e+(De[t]??1),0)||1,Xe=e=>Je.length<=1?1:(De[e]??1)/Ye*Je.length,Ze=new Map(Li(Fe,Me).map(([e,t])=>[e,(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:Ve(e,t),onDoubleClick:()=>Oe({...cu}),title:k(`dragToResize`)},`sash-${e}`)])),Qe={projects:(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${V||i.length===0?`collapsed`:``}`,style:i.length>0&&!V?{flex:`${Xe(`projects`)} 1 0px`}:void 0,children:[qe(k(`recentProjects`),V,H,i.length,(0,X.jsxs)(X.Fragment,{children:[O&&(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action lp-sandbox-action`,title:k(`sandboxNewBtn`),"aria-label":k(`sandboxNewBtn`),onClick:()=>O(),children:(0,X.jsx)(`span`,{"aria-hidden":!0,style:{fontSize:`13px`,lineHeight:1},children:`🧪`})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action`,title:k(`manageProjects`),"aria-label":k(`manageProjects`),onClick:()=>F(!0),children:(0,X.jsx)(ze,{})})]}),Ce(m,`lp-slot-section`)),i.length>0&&!V&&(0,X.jsx)(`div`,{className:`lp-section-body projects-scroll`,children:i.map(e=>{let t=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),n=N===e.path,r=D?.kind===`cwd`&&t(D.target)===t(e.path),i=e.sandbox,a=i?i.name:Ue(e.path);return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>ie(t=>t===`proj:${e.path}`?null:t),onContextMenu:t=>Ge(t,e),children:[(0,X.jsxs)(`button`,{type:`button`,className:`project-item ${n?`active`:``} ${r?`switching`:``}`,title:i?.sourcePath?`${a}\n${k(`sandboxSourceLabel`)}: ${i.sourcePath}\n${e.path}`:e.path,disabled:r,onClick:()=>{!n&&!r&&o({type:`set_cwd`,path:e.path})},children:[r?(0,X.jsx)(Ee,{className:`project-icon spin`}):i?(0,X.jsx)(`span`,{className:`project-icon sandbox-icon`,"aria-hidden":!0,children:`🧪`}):(0,X.jsx)(Re,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsxs)(`span`,{className:`project-name`,children:[a,i&&(0,X.jsx)(`span`,{className:`lp-sandbox-badge ${i.ephemeral?`ephemeral`:`permanent`}`,children:i.ephemeral?k(`sandboxBadgeEphemeral`):k(`sandboxBadgePermanent`)})]}),(0,X.jsx)(`span`,{className:`project-path`,children:i?.sourcePath?`← ${Ue(i.sourcePath)} · ${e.path}`:e.path})]}),(0,X.jsx)(`span`,{className:`project-time ${r?`switching-pct`:``}`,children:r?`${D.progress}%`:Zl(e.lastUsed)})]}),Y(`proj:${e.path}`,k(i?`sandboxActionDestroyTip`:`deleteProject`),k(i?`sandboxActionDestroy`:`deleteProjectConfirm`),()=>{zl(e.path),Ul(e.path),o(i?{type:`destroy_sandbox`,path:e.path}:{type:`remove_project`,path:e.path})}),Ce(h,`lp-slot-project`,{id:e.path,kind:`project`,label:a})]},e.path)})})]})}),convs:(0,X.jsx)(X.Fragment,{children:Pe>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${se?`collapsed`:``}`,style:se?void 0:{flex:`${Xe(`convs`)} 1 0px`},onContextMenu:e=>we(e,{id:``,kind:`section`,label:k(`runningConversations`)}),children:[qe(k(`runningConversations`),se,ce,Pe,void 0,Ce(_,`lp-slot-section`)),!se&&(0,X.jsxs)(`div`,{className:`lp-section-body convs-scroll`,children:[Qo(ke,M,a).map(e=>(0,X.jsxs)(`div`,{className:`panel-conv-group`,children:[!e.isCurrent&&(0,X.jsx)(`div`,{className:`panel-conv-group-title`,title:e.cwd,onContextMenu:t=>Ge(t,{path:e.cwd,lastUsed:0}),children:Ue(e.cwd)}),$o(e.convs,fe).map(({c:n,depth:r,hasKids:i,isCollapsed:s,descendantCount:c,hasStreaming:l,hasError:u,hasQuestion:d})=>{if(n.elsewhere){let e=n.owner,t=n.convId,r=!!n.pseudo,i=!!n.ownerOffline&&!r,a=!!(e&&t)&&!r,s=ae===n.id,c=s?k(`takeoverConfirm`):r?`${k(`elsewherePseudoTip`)}\n${n.cwd}`:`${k(i?`elsewhereOfflineTip`:`elsewhereTip`)}\n${n.cwd}`;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>I(e=>e===n.id?null:e),onContextMenu:i=>we(i,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item elsewhere-item${a?``:` elsewhere-static`}${s?` confirm`:``}`,title:c,tabIndex:a?0:-1,onClick:a?()=>{if(!s){I(n.id);return}I(null),o({type:`take_over_conversation`,owner:e,id:t})}:void 0,children:[(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsxs)(`span`,{className:`session-title`,children:[(0,X.jsx)(`span`,{className:`elsewhere-badge`,children:k(r?`elsewherePseudoBadge`:`elsewhereBadge`)}),i&&(0,X.jsx)(`span`,{className:`elsewhere-badge offline`,title:k(`elsewhereOfflineTip`),children:k(`elsewhereOfflineBadge`)}),n.hasQuestion&&e&&t&&!r&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:k(`takeoverHasQuestion`),onClick:n=>{n.stopPropagation(),o({type:`peek_elsewhere_question`,owner:e,id:t})},children:`?`}),s?k(`takeoverConfirm`):n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:Ue(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:k(`streaming`)})]}),xe&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-elsewhere-act`,title:k(`elsewhereActions`),onClick:i=>{i.stopPropagation(),ye.current=null;let a=i.currentTarget.getBoundingClientRect();Se(a.left,a.bottom+4,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}})},children:(0,X.jsx)(_e,{})})]},n.id)}let f=a===n.id;return(0,X.jsxs)(`div`,{className:`lp-row${r>0?` lp-sub`:``}${i?` lp-has-kids`:``}`,style:r>0?{marginLeft:r*18}:void 0,onMouseLeave:()=>ie(e=>e===`conv:${n.id}`?null:e),onContextMenu:e=>we(e,{id:n.id,kind:`running`,label:n.title}),children:[i&&(0,X.jsx)(`button`,{type:`button`,className:`lp-tree-caret${s?` collapsed`:` expanded`}`,title:k(s?`expandSubagents`:`collapseSubagents`),"aria-label":k(s?`expandSubagents`:`collapseSubagents`),onClick:e=>{e.stopPropagation(),W(n.id)},children:s?(0,X.jsx)(lt,{}):(0,X.jsx)(dt,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${f?`active`:``}`,title:`${n.title}${e.isCurrent?``:` — ${e.cwd}`}`,onClick:()=>{f||o({type:`switch_conversation`,id:n.id})},children:[(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[R===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:oe,placeholder:k(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>B(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=oe.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),z(null)}else e.key===`Escape`&&z(null)},onBlur:()=>z(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:k(`pinnedConversation`),children:`📌`}),n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:k(`subagentBadge`)}),n.isEphemeral&&(0,X.jsx)(`span`,{className:`ephemeral-badge`,children:k(`ephemeralBadge`)}),n.forkFrom&&(0,X.jsxs)(`span`,{className:`preset-badge fork-badge`,title:`${k(`forkBadgeTip`)}: ${n.forkFrom.title??n.forkFrom.conversationId}`,children:[`🌿 `,k(`forkBadge`)]}),n.agentPreset&&(0,X.jsx)(`span`,{className:`preset-badge`,title:n.agentPreset,children:E?.[n.agentPreset]??n.agentPreset}),n.title,n.error&&(0,X.jsx)(`span`,{className:`conv-error-badge`,title:k(`convErrorBadge`,{error:n.error})}),n.hasQuestion&&(0,X.jsx)(`span`,{className:`question-badge`,title:k(`waitingQuestionBadge`),children:`?`}),i&&s&&(0,X.jsxs)(`span`,{className:`subagents-collapsed-badge${l?` has-streaming`:d?` has-question`:u?` has-error`:``}`,title:k(l?`subagentsStreamingTip`:d?`subagentsQuestionTip`:u?`subagentsErrorTip`:`subagentsCountTip`,{n:c}),onClick:e=>{e.stopPropagation(),W(n.id)},children:[l&&(0,X.jsx)(`span`,{className:`subagent-dot streaming`}),d&&(0,X.jsx)(`span`,{className:`subagent-dot question`,children:`?`}),u&&(0,X.jsx)(`span`,{className:`subagent-dot error`}),(0,X.jsx)(`span`,{className:`subagents-count-text`,children:k(`subagentBadgeCount`,{n:c})})]})]}),R===`conv:${n.id}`?null:(0,X.jsx)(`span`,{className:`session-sub`,children:f?k(`current`):k(`messageCount`,{n:n.messageCount})})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:k(`streaming`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:k(`renameSession`),onClick:e=>{e.stopPropagation(),ie(null),B(n.title),z(`conv:${n.id}`)},children:(0,X.jsx)(Ke,{})}),(()=>{let e=`conv:${n.id}`,r=re===e,i=he(t,n.id),a=q(t,n.id),s=ge(t,n.id);return s===0&&!n.isStreaming?Y(e,k(`dismissConversation`),k(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(P,{})):s===0?Y(e,k(`dismissConversation`),k(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(P,{})):r?(0,X.jsxs)(`span`,{className:`lp-del-group`,children:[i>0&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt`,title:k(`dismissFinishedSubagentsScoped`,{n:i}),onClick:e=>{e.stopPropagation(),ie(null),o({type:`dismiss_finished_subagents`,parentId:n.id})},children:k(`dismissFinishedOnly`,{n:i})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt danger`,title:k(`forceDismissTitle`,{n:s,m:a}),onClick:e=>{e.stopPropagation(),ie(null),o({type:`dismiss_conversation`,id:n.id,force:!0})},children:k(`dismissForceAll`,{n:s})})]}):(0,X.jsx)(`button`,{type:`button`,className:`lp-del`,title:k(`dismissConversation`),onClick:t=>{t.stopPropagation(),ie(e)},children:(0,X.jsx)(P,{})})})(),Ce(Le,`lp-slot-sessions`),n.isStreaming&&(0,X.jsx)(`span`,{className:`lp-row-stalled`,title:k(`streaming`),style:{position:`absolute`,right:28,top:`50%`,transform:`translateY(-50%)`}})]},n.id)})]},e.cwd)),Ie()]})]})}),sessions:(0,X.jsx)(X.Fragment,{children:(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${le?`collapsed`:``}`,style:le?void 0:{flex:`${Xe(`sessions`)} 1 0px`},children:[qe(k(`historySessions`),le,ue,r.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-new-chat-action`,title:k(`newChatTip`),"aria-label":k(`newChat`),onClick:()=>{o({type:`new_chat`}),sr()},children:(0,X.jsx)(me,{})}),Ce(v,`lp-slot-section`)),!le&&(0,X.jsxs)(`div`,{className:`lp-section-body sessions-scroll`,onScroll:e=>{if(K.length>=r.length)return;let t=e.currentTarget;t.scrollHeight-t.scrollTop-t.clientHeight<180&&G(e=>Math.min(r.length,e+60))},children:[r.length===0&&(0,X.jsx)(`div`,{className:`panel-empty`,children:k(`noHistory`)}),K.map(e=>{let t=e=>(e??``).trim().replace(/[\\/]+$/,``).toLowerCase(),n=A===e.path,r=D?.kind===`session`&&t(D.target)===t(e.path);return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>ie(t=>t===`sess:${e.path}`?null:t),onContextMenu:t=>we(t,{id:e.path,kind:`history`,label:He(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${n?`active`:``} ${r?`switching`:``}`,title:e.path,disabled:r,onClick:()=>{R||r||n||o({type:`switch_session`,path:e.path})},children:[r?(0,X.jsx)(Ee,{className:`session-icon spin`}):(0,X.jsx)(J,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[R===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:oe,placeholder:k(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>B(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=oe.trim();t&&o({type:`rename_session`,path:e.path,name:t}),z(null)}else t.key===`Escape`&&z(null)},onBlur:()=>z(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[e.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:k(`pinnedConversation`),children:`📌`}),He(e)]}),R===e.path?null:(0,X.jsxs)(`span`,{className:`session-sub`,children:[n?k(`current`):k(`messageCount`,{n:e.messageCount}),e.source===`tui`&&(0,X.jsx)(`span`,{className:`session-src`,title:k(`tuiTip`),children:`TUI`})]})]}),(0,X.jsx)(`span`,{className:`session-time ${r?`switching-pct`:``}`,children:r?`${D.progress}%`:Zl(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:k(`renameSession`),onClick:t=>{t.stopPropagation(),ie(null),B(e.name??``),z(e.path)},children:(0,X.jsx)(Ke,{})}),Y(`sess:${e.path}`,k(`deleteSession`),k(`deleteSessionConfirm`),()=>{Jl(e.path,N),o({type:`delete_session`,path:e.path})}),Ce(Be,`lp-slot-sessions`)]},e.path)})]})]})})},$e=e=>{let t=je.find(t=>t.key===e)?.entry;if(!t)return null;let n=Me(e);return(0,X.jsxs)(`div`,{className:`lp-section lp-section-plugin ${n?`collapsed`:``}`,style:n?void 0:{flex:`${Xe(e)} 1 0px`},children:[qe(t.label,n,()=>de(e)),!n&&(0,X.jsx)(`div`,{className:`lp-section-body lp-plugin-section-body`,children:b?.(t)??null})]})},et=e=>e===`projects`||e===`convs`||e===`sessions`?Qe[e]:$e(e);return(0,X.jsxs)(`aside`,{ref:Te,className:`panel panel-left lp-panel`,children:[c&&l&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:k(`collapsePanel`),onClick:l,children:(0,X.jsx)(st,{})}),je.map(({key:e})=>(0,X.jsxs)(g.Fragment,{children:[et(e),Ze.get(e)??null]},e)),(0,X.jsx)(So,{open:ne,currentCwd:N,pathCompletions:u??[],workspaceRoots:te,onClose:()=>F(!1),onSelectDirectory:e=>o({type:`set_cwd`,path:e}),onCreateProject:e=>o({type:`make_dir`,path:e,setAsCwd:!0})})]})}),mu=209715200,hu=/windows/i.test(navigator.userAgent),gu=/[<>:"/\\|?*\u0000-\u001f]/g,_u=/[. ]+$/,vu=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function yu(e){let t=e.replace(gu,`_`).replace(_u,``);return t?vu.test(t)?`_${t}`:t:`_`}function bu(e,t=!0){return gn(fn(`/api/file?${new URLSearchParams({clientId:Fl(),path:e,...t?{download:`1`}:{}})}`))}async function xu(e,t){let n=hu?yu(t):t;try{let t=await fetch(bu(e));if(!t.ok)return{ok:!1,cancelled:!1,error:await t.text().catch(()=>``)||(t.status===404?`FILE_NOT_FOUND`:`HTTP ${t.status}`)};if(Number(t.headers.get(`content-length`)??`0`)>mu)return window.location.assign(bu(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?Cu(r,n):wu(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function Su(e,t){let n=hu?yu(t):t;return window.showSaveFilePicker&&window.isSecureContext?Cu(e,n):wu(e,n)}async function Cu(e,t){let n,r=window.showSaveFilePicker;if(!r)return wu(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:wu(e,t)}try{let t=await n.createWritable();return await t.write(e),await t.close(),{ok:!0}}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}function wu(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);return r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}function Tu(e,t,n){let r=e.left-8,i=e.bottom+8;return r+t.width>n.width-8&&(r=Math.max(8,e.right+8-t.width)),i+t.height>n.height-8&&(i=Math.max(8,e.top-8-t.height)),{left:r,top:i}}function Eu(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function Du({text:e}){let t=(0,g.useRef)(null),n=(0,g.useRef)(null),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)({left:0,top:0}),s=()=>{let e=t.current?.getBoundingClientRect();e&&(o({left:Math.max(8,e.left-8),top:e.bottom+8}),i(!0))},c=()=>i(!1);return(0,g.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=Tu(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,g.useEffect)(()=>{if(!r)return;let e=0,a=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e=t.current,r=n.current;if(!e||!r)return;let a=e.getBoundingClientRect();if(a.bottom<0||a.top>window.innerHeight||a.right<0||a.left>window.innerWidth){i(!1);return}let s=Tu(a,r.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)})};return window.addEventListener(`scroll`,a,!0),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(e),window.removeEventListener(`scroll`,a,!0),window.removeEventListener(`resize`,a)}},[r]),(0,X.jsxs)(`span`,{ref:t,className:`set-tip`,tabIndex:0,"aria-label":e,onMouseEnter:s,onMouseLeave:c,onFocus:s,onBlur:c,onKeyDown:e=>{e.key===`Escape`&&e.target.blur()},children:[`?`,r&&(0,j.createPortal)((0,X.jsx)(`span`,{ref:n,className:`set-tip-bubble open`,role:`tooltip`,style:{position:`fixed`,left:a.left,top:a.top},children:e}),document.body)]})}var Ou=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function ku(e,t={}){let n={archive:fn(`/api/file-transfer/archive`),upload:fn(`/api/file-transfer/upload`)},r=new URL(gn(`${n[e]}?${new URLSearchParams({clientId:Fl(),...t})}`),window.location.href);if(r.origin!==window.location.origin||r.pathname!==new URL(n[e],window.location.href).pathname)throw Error(`File transfers must use an allowlisted same-origin endpoint`);return r}async function Au(e,t,n){let r=await fetch(ku(`archive`),{method:`POST`,headers:{"Content-Type":`application/json`,"X-File-Operation":`1`},body:JSON.stringify({action:e,path:t,...n})});if(!r.ok)throw Error(await r.text());if(e===`download`){let e=r.headers.get(`content-disposition`)??``,t=/filename\*=UTF-8''([^;]+)/i.exec(e)?.[1],n=/filename="([^"]+)"/i.exec(e)?.[1],i=t?decodeURIComponent(t):n??`archive.tar.gz`,a=await Su(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function ju(){let e=window.showDirectoryPicker;if(!e)return null;let t=await e.call(window),n=[];async function r(e,t){if(n.length>=2e4)throw Error(`Folder exceeds 20,000 entries`);if(n.push(e.kind===`file`?{path:t,file:await e.getFile()}:{path:t}),e.kind===`directory`)for await(let n of e.values())await r(n,`${t}/${n.name}`)}return await r(t,t.name),n}async function Mu(e,t,n){if(t.length>2e4)throw Error(`Folder exceeds 20,000 entries`);for(let e of t)if(e.file&&e.file.size>33554432)throw Error(`File exceeds 32 MiB: ${e.path}`);let r=0;for(let i of t){let t=ku(`upload`,{dir:e,name:i.path,kind:i.file?`file`:`directory`}),a=await fetch(t,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-File-Operation":`1`},body:i.file??new Blob});if(!a.ok)throw Error(`${i.path}: ${await a.text()}`);n?.(++r)}}function Nu({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,g.useState)(e.dir),[o,s]=(0,g.useState)(`skip`),[c,l]=(0,g.useState)([]),[u,d]=(0,g.useState)(0),f=(0,g.useRef)(null),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{v.current?.showModal()},[]);let y=r(e.action===`upload`?`fileUploadFolder`:e.action===`extract`?`fileExtract`:e.action===`download`?`fileCompressDownload`:`fileCompress`);async function b(){try{let e=await ju();e?l(e):f.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),m(!0),_(``);try{e.action===`upload`?await Mu(e.dir,c,d):await Au(e.action,e.path,{destination:i,policy:o}),n(),t()}catch(e){_(e instanceof Error?e.message:String(e)),n()}finally{m(!1)}}return(0,j.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),p||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsxs)(`div`,{className:`file-transfer-head`,children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(0,X.jsx)(`button`,{type:`button`,className:`file-transfer-close`,title:r(`close`),"aria-label":r(`close`),disabled:p,onClick:t,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`p`,{className:`file-transfer-path`,children:(e.action===`upload`?e.dir:e.path)||`.`}),(0,X.jsx)(`p`,{children:r(`fileArchiveLimits`)}),e.action===`extract`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{children:[r(`fileExtractDestination`),(0,X.jsx)(`input`,{value:i,disabled:p,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:p,onChange:e=>s(e.target.value),children:[(0,X.jsx)(`option`,{value:`skip`,children:r(`fileConflictSkip`)}),(0,X.jsx)(`option`,{value:`overwrite`,children:r(`fileConflictOverwrite`)}),(0,X.jsx)(`option`,{value:`error`,children:r(`fileConflictError`)})]})]})]}),e.action===`upload`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:r(`fileFolderUploadHint`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:p,ref:e=>{f.current=e,e?.setAttribute(`webkitdirectory`,``)},onChange:e=>l(Array.from(e.target.files??[],e=>({path:e.webkitRelativePath||e.name,file:e})))}),(0,X.jsxs)(`p`,{"aria-live":`polite`,children:[u,` / `,c.length]})]}),h&&(0,X.jsx)(`p`,{role:`alert`,children:r(`fileTransferFailed`,{error:h})}),(0,X.jsxs)(`div`,{className:`file-transfer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:p,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:p||e.action===`upload`&&c.length===0,children:p?r(`fileTransferBusy`):y})]})]})}),document.body)}function Pu(e){return e.startsWith(`.`)&&e!==`..`}function Fu(e,t){return t?e:e.filter(e=>!Pu(e.name))}function Iu(e){return e instanceof Error?e.message:String(e)}function Lu(e,t,n,r){let i=n===`zh`;switch(e.kind){case`no-client`:return i?`插件 ${t} 没有客户端脚本(client/entry.mjs),无法显示这一页。`:`Plugin ${t} ships no client bundle (client/entry.mjs), so this page cannot be shown.`;case`load`:return i?`插件 ${t} 的页面脚本加载失败:${e.detail}`:`Failed to load plugin ${t}'s page bundle: ${e.detail}`;case`mount`:return`${r(`pluginMountFailed`,{name:t})}:${e.detail}`}}function Ru({plugin:e,epoch:t,send:n,className:r}){let i=(0,g.useRef)(null),{locale:a}=Nn(),o=Z(),[s,c]=(0,g.useState)(null),l=(0,g.useRef)(n);(0,g.useEffect)(()=>{l.current=n},[n]),(0,g.useEffect)(()=>{let n=i.current;if(!n)return;let r=!1,a,o=!1;if(c(null),!e.hasClient){c({kind:`no-client`});return}return(async()=>{try{if(await nl(e,t),r)return;let i=await Ys(e.id,()=>Pc(()=>import(Zc(e.id,t)),[]));if(r)return;let s=i.default;if(!s||typeof s.mount!=`function`)throw Error(`client/entry.mjs 没有导出 default.mount()`);o=!0,a=s.mount(n,il(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:Iu(t)})}})(),()=>{if(r=!0,typeof a==`function`)try{a()}catch(t){console.error(`[plugin:${e.id}] cleanup 失败:`,t)}n.textContent=``}},[e.id,e.hasClient,t]);let u=r?`plugin-page ${r}`:`plugin-page`;return(0,X.jsxs)(`div`,{className:u,children:[(0,X.jsx)(`div`,{className:`plugin-page-host`,ref:i}),s&&(0,X.jsx)(`div`,{className:`plugin-page-error`,role:`alert`,children:Lu(s,e.name,a,o)})]})}function zu(e){return`pi-web-ui:${e}:tab`}function Bu(e,t){try{let n=localStorage.getItem(zu(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Vu(e,t){try{localStorage.setItem(zu(e),t)}catch{}}function Hu(e){return e.length>0&&!/[a-z]/i.test(e)}function Uu(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function Wu({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,g.useId)(),[s,c]=(0,g.useState)(()=>Bu(e,t)??t[0]?.id??``),l=(0,g.useRef)([]),u=(0,g.useRef)(``),d=t.findIndex(e=>e.id===s),f=d>=0?t[d]:t[0],p=f?t.indexOf(f):-1;(0,g.useEffect)(()=>{if(!f)return;s!==f.id&&c(f.id);let t=`${e}:${f.id}`;u.current!==t&&(u.current=t,Vu(e,f.id))},[f,s,e]);let m=t=>{c(t.id),u.current=`${e}:${t.id}`,Vu(e,t.id)},h=(e,n)=>{let r=t.length,i=-1;if(e.key===`ArrowRight`)i=(n+1)%r;else if(e.key===`ArrowLeft`)i=(n-1+r)%r;else if(e.key===`Home`)i=0;else if(e.key===`End`)i=r-1;else return;let a=t[i];a&&(e.preventDefault(),m(a),l.current[i]?.focus())};if(!f)return null;let _=`${o}-panel-${p}`,v=a?`slot-tabs ${a}`:`slot-tabs`;return(0,X.jsxs)(`div`,{className:v,children:[(0,X.jsxs)(`div`,{className:`slot-tabs-bar`,role:`tablist`,children:[t.map((e,t)=>{let n=t===p;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Uu(e),"aria-selected":n,"aria-controls":`${o}-panel-${t}`,tabIndex:n?0:-1,ref:e=>{l.current[t]=e},onClick:()=>m(e),onKeyDown:e=>h(e,t),children:[e.iconSvg?(0,X.jsx)(hi,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&Hu(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Uu(e)})]},e.id)}),i?(0,X.jsx)(`div`,{className:`slot-tabs-extra`,children:i}):null]}),(0,X.jsx)(`div`,{className:`slot-tabs-body`,id:_,role:`tabpanel`,"aria-labelledby":`${o}-tab-${p}`,children:f.pluginPage?(0,X.jsx)(Ru,{plugin:f.pluginPage.plugin,epoch:n,send:r}):f.element??null})]})}function Gu(e){if(typeof document>`u`)return!1;try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.style.top=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}async function Ku(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Gu(e)}return Gu(e)}function qu(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,g.useCallback)(()=>{s(),a(!1)},[s]);return(0,g.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,g.useCallback)(async e=>{let i=!1;try{i=await Ku(e)}catch(e){i=!1,r&&r(e)}return i?(a(!0),s(),o.current=setTimeout(()=>{a(!1),o.current=null},t),n?.(e)):r&&!i&&r(Error(`Copy failed`)),i},[t,n,r,s]),reset:c}}var Ju=`@root`,Yu=`pi-web-ui:rp-sizes`,Xu=`pi-web-ui:files-show-hidden`,Zu={files:4,widgets:1},Qu=120,$u=56;function ed(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var td=`files`,nd=[],rd=()=>{};function id(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function ad(e){return e===Ju||e===`/`||/^[A-Za-z]:$/.test(e)}function od(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var sd=(0,g.memo)(function({files:e,fileChanged:t,widgets:n,panelSend:r,onAttach:i,onPreview:a,onNotice:o,collapsible:s,onToggleCollapse:c,uiRightPanelTabs:l,uiContextFile:u,plugins:d,pluginsEpoch:f,send:p}){let m=Z(),h=d??nd,_=Za(`cwd`),v=Za(`workspaceRoots`),y=Za(`homeDir`),b=Za(`desktopDir`),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),[k,A]=(0,g.useState)(()=>{try{return Xo(localStorage.getItem(Yu),Zu)}catch{return{...Zu}}});(0,g.useEffect)(()=>{try{localStorage.setItem(Yu,JSON.stringify(k))}catch{}},[k]);let[j,ee]=(0,g.useState)(()=>{try{return localStorage.getItem(Xu)===`1`}catch{return!1}});(0,g.useEffect)(()=>{try{localStorage.setItem(Xu,j?`1`:`0`)}catch{}},[j]);let M=n.some(e=>e.lines.length>0),te=(0,g.useCallback)(e=>{e.preventDefault();let t=D.current;if(!t)return;let n=e.currentTarget,r=e.clientY,i={above:k.files,below:k.widgets},a=Math.max(120,t.clientHeight-ed(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Zo({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:Qu,minBelowPx:$u});A({files:t,widgets:n})},s=()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),n.classList.remove(`dragging`),document.body.classList.remove(`rp-resizing`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},[k.files,k.widgets]),N=(0,g.useRef)(null),ne=(0,g.useRef)(0),F=(0,g.useCallback)(e=>{N.current=e,e&&(e.scrollTop=ne.current)},[]),[re,ie]=(0,g.useState)(null),ae=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{ae.current&&clearTimeout(ae.current)},[]);let I=(0,g.useCallback)(e=>{ie(e),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>ie(null),1200)},[]),L=(0,g.useCallback)((e,t)=>{e&&Ku(e).then(e=>{e?I(t):o(`error`,m(`slashCopyFailed`))})},[I,o,m]),R=(0,g.useCallback)(e=>{if(!e)return _;if(/^[A-Za-z]:$/.test(e))return`${e}/`;if(e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e))return e;let t=_.replace(/\\/g,`/`).replace(/\/+$/,``);return t?`${t}/${e}`:e},[_]),z=(0,g.useCallback)(e=>!e||e===Ju?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),oe=104857600,B=(0,g.useCallback)((e,t)=>{for(let n of t){if(n.size>oe){o(`warning`,m(`fileTooLarge`,{name:n.name,size:oe/1024/1024}));continue}let t=new FileReader;t.onload=()=>{let i=t.result,a=i.slice(i.indexOf(`,`)+1);a&&r({type:`upload_file`,dirPath:e,name:n.name,data:a})},t.readAsDataURL(n)}},[r,o,m]),V=(0,g.useRef)(null),[H,se]=(0,g.useState)(null),ce=(0,g.useRef)(null),le=(0,g.useCallback)(()=>{let e=V.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),ue=(0,g.useCallback)(()=>{ce.current&&(ce.current.value=``),ce.current?.click()},[]),[U,de]=(0,g.useState)(null),[fe,W]=(0,g.useState)(null),[pe,G]=(0,g.useState)(``),[K,me]=(0,g.useState)(null),[he,ge]=(0,g.useState)(``),q=(0,g.useCallback)((e,t)=>{xu(e,t).then(e=>{e.ok||e.cancelled||o(`error`,m(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?m(`fileNotFoundShort`):e.error}))})},[o,m]),_e=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&(me(null),G(e.label),W(e.id))},[]),ve=(0,g.useCallback)(()=>{if(!fe)return;let e=pe.trim();W(null),e&&r({type:`file_rename`,path:fe,newName:e})},[fe,pe,r]),ye=(0,g.useCallback)(e=>{let t=V.current?.dir??x;W(null),ge(``),me({dir:t,kind:e})},[x]),be=(0,g.useCallback)(()=>{if(!K)return;let e=he.trim();me(null),e&&r({type:`file_create`,dir:K.dir,name:e,kind:K.kind})},[K,he,r]),xe=(e,t,n,r)=>(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:e,placeholder:m(`fileNamePlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>t(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing?n():e.key===`Escape`&&r()},onBlur:r}),J=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&window.confirm(m(`fileDeleteConfirm`,{name:e.label}))&&(U?.src===e.id&&de(null),fe===e.id&&W(null),r({type:`file_delete`,path:e.id}))},[r,m,U,fe]),Se=(0,g.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!ad(e.id)&&r({type:`file_copy`,src:e.id,destDir:id(e.id)})},[r]),Ce=(0,g.useCallback)(e=>{let t=V.current?.target;t&&t.kind!==`list`&&!ad(t.id)&&de({src:t.id,cut:e})},[]),Te=(0,g.useCallback)(()=>{if(!U)return;let e=V.current?.dir??x;U.cut?(r({type:`file_copy`,src:U.src,destDir:e,move:!0}),de(null)):r({type:`file_copy`,src:U.src,destDir:e})},[U,r,x]),Ee=(0,g.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[De,ke]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(!De)return;let e=e=>{e.target?.closest(`.root-picker`)||ke(!1)},t=e=>{e.key===`Escape`&&ke(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[De]);let Ae=(0,g.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),je=(0,g.useCallback)(()=>{let e=V.current?.target;if(!e||e.kind!==`dir`)return;let t=z(e.id);t&&!v.includes(t)&&Ae([...v,t])},[v,z,Ae]),Me=(0,g.useCallback)(e=>{B(V.current?.dir??x,Array.from(e.target.files??[]))},[B,x]),Ne=(0,g.useCallback)(e=>{let t=V.current?.target;switch(e.id){case`host:file-compress`:case`host:file-extract`:case`host:file-compress-download`:case`host:file-upload-folder`:{if(!t)break;let n=e.id===`host:file-compress`?`compress`:e.id===`host:file-extract`?`extract`:e.id===`host:file-compress-download`?`download`:`upload`;se({action:n,path:R(t.id),dir:R(n===`upload`?V.current?.dir??x:id(t.id))});break}case`host:file-open-project`:le();break;case`host:file-upload`:ue();break;case`host:file-add-root`:je();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Je(t.id);break;case`host:file-download`:t?.kind===`file`&&q(t.id,t.label);break;case`host:file-reveal`:t&&r({type:`file_reveal`,path:t.id});break;case`host:file-open-default`:t?.kind===`file`&&r({type:`file_open_default`,path:t.id});break;case`host:file-attach-ref`:t?.kind===`file`&&i(t.id,t.label,`reference`);break;case`host:file-attach-folder`:t?.kind===`dir`&&i(t.id,t.label,`reference`,!0);break;case`host:file-new-file`:ye(`file`);break;case`host:file-new-dir`:ye(`dir`);break;case`host:file-paste`:Te();break;case`host:file-rename`:_e();break;case`host:file-duplicate`:Se();break;case`host:file-cut`:Ce(!0);break;case`host:file-copy`:Ce(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&L(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&L(R(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&L(t.id,`rel:${t.id}`);break;case`host:file-refresh`:Ee();break;case`host:file-delete`:J()}},[le,x,ue,je,a,i,L,R,q,ye,Te,_e,Se,Ce,Ee,J]),Pe=(0,g.useCallback)((e,t)=>{let n=t.kind===`dir`?z(t.id):null,r={target:t,dir:t.kind===`dir`?t.id:x,project:n?{path:n,name:t.label}:null},i=t.kind,a=i===`file`,o=i===`dir`,s=i===`list`,c=!s&&ad(t.id),l=!s&&od(t.id),d=x===Ju,f=(u??[]).map(e=>{if(e.source!==`host`)return e;switch(e.id){case`host:file-upload-folder`:return d?{...e,hidden:!0}:e;case`host:file-compress`:case`host:file-compress-download`:return!s&&!c?e:{...e,hidden:!0};case`host:file-extract`:return a&&Ou(t.label)?e:{...e,hidden:!0};case`host:file-upload`:return d?{...e,hidden:!0}:{...e,label:r.dir===x?m(`uploadToCurrentDir`):m(`uploadToFolder`)};case`host:file-open-project`:return n?e:{...e,hidden:!0};case`host:file-add-root`:return n&&n!==_&&!v.includes(n)?e:{...e,hidden:!0};case`host:file-open`:case`host:file-download`:case`host:file-open-default`:case`host:file-attach-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return!d&&t.id!==Ju?e:{...e,hidden:!0};case`host:file-enter`:case`host:file-attach-folder`:return o?e:{...e,hidden:!0};case`host:file-new-file`:case`host:file-new-dir`:return!a&&!d?e:{...e,hidden:!0};case`host:file-paste`:return!a&&!d&&U?e:{...e,hidden:!0};case`host:file-rename`:case`host:file-duplicate`:case`host:file-cut`:case`host:file-copy`:case`host:file-delete`:return!s&&!c?e:{...e,hidden:!0};case`host:file-copy-name`:case`host:file-copy-path`:return s?{...e,hidden:!0}:e;case`host:file-copy-rel`:return!s&&!l?e:{...e,hidden:!0};case`host:file-refresh`:return s?e:{...e,hidden:!0};default:return e}});La(f).length!==0&&(e.preventDefault(),e.stopPropagation(),V.current=r,Ea({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Ne}))},[u,x,z,m,Ne,_,v,U]),Fe=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),Ie=(0,g.useCallback)(()=>{N.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),N.current?.classList.remove(`drop-root`)},[]),Le=(0,g.useCallback)(e=>{if(Ie(),e==null)return;let t=N.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):N.current?.classList.add(`drop-root`)},[Ie]),ze=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ve=(0,g.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),He=(0,g.useRef)(0),Ge=(0,g.useRef)(void 0),Y=(0,g.useCallback)((e,t)=>{let n=++He.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||He.current===n&&E(!1)},[r]),Ke=(0,g.useCallback)(e=>{let t=v.filter(t=>t!==e);Ae(t),(x===e||x.startsWith(`${e}/`))&&Y(``)},[v,Ae,x,Y]);(0,g.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,g.useEffect)(()=>{if(_!==Ge.current){let e=Ge.current===void 0;Ge.current=_,e?Y(``,{silent:!0}):S(``);return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Y(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Y]),(0,g.useEffect)(()=>{t&&t.path===x&&Y(x,{silent:!0})},[t,x,Y]);let Je=e=>Y(e),Ye=()=>{e?.parent!==null&&e?.parent!==void 0&&Y(e.parent)},Xe=(()=>{if(x===``||x===Ju)return[];let e=x.split(`/`).filter(e=>!!e&&e!==Ju);return x.startsWith(`/`)?[{label:`/`,path:`/`},...e.map((t,n)=>({label:t,path:`/`+e.slice(0,n+1).join(`/`)}))]:e.map((t,n)=>({label:e[n],path:e.slice(0,n+1).join(`/`)}))})(),Ze=[];for(let e of l??[]){if(e.source===`host`||e.hidden||e.kind===`divider`)continue;let t=h.find(t=>t.id===e.source.slice(7));t&&Ze.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let Qe=(l??[]).some(e=>e.id===`host:right-files`&&e.hidden);return(0,X.jsxs)(`aside`,{className:`panel panel-right`,ref:D,children:[s&&c&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:m(`collapsePanel`),onClick:c,children:(0,X.jsx)(ot,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:M?`${k.files} 1 0`:`1 1 0`,minHeight:M?Qu:0},children:(0,X.jsx)(Wu,{storageKey:`rightpanel`,epoch:f??0,send:p??rd,tabs:(e=>{let t=(l??[]).filter(e=>!e.hidden);if(t.length===0)return e;let n=new Map(t.map((e,t)=>[e.id,t])),r=e=>n.get(e===td?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...Qe?[]:[{id:td,label:m(`openFiles`),element:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`panel-crumbs`,children:[(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===``?`active`:``}`,onClick:()=>Y(``),children:m(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===Ju?`active`:``}`,title:m(`computer`),onClick:()=>Y(Ju),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:m(`homeDir`),onClick:()=>Y(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:m(`desktopDir`),onClick:()=>Y(b),children:`🖥️`}),(0,X.jsx)(Du,{text:m(`filesHelp`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${j?`active`:``}`,title:m(j?`filesHideHidden`:`filesShowHidden`),"aria-label":m(j?`filesHideHidden`:`filesShowHidden`),"aria-pressed":j,onClick:()=>ee(e=>!e),children:j?(0,X.jsx)(We,{}):(0,X.jsx)(Ue,{})}),v.length>0&&(0,X.jsxs)(`div`,{className:`root-picker`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`crumb root-picker-trigger`,"aria-haspopup":`menu`,"aria-expanded":De,title:m(`workspaceRoots`),onClick:()=>ke(e=>!e),children:[(0,X.jsx)(Re,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:m(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),De&&(0,X.jsxs)(`div`,{className:`root-picker-menu`,role:`menu`,children:[(0,X.jsx)(`div`,{className:`root-picker-row`,children:(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:x===``?`root-picker-item active`:`root-picker-item`,title:_,onClick:()=>{ke(!1),Y(``)},children:[m(`rootDir`),(0,X.jsx)(`span`,{className:`root-picker-path`,children:_})]})}),v.map(e=>(0,X.jsxs)(`div`,{className:`root-picker-row`,children:[(0,X.jsx)(`button`,{type:`button`,role:`menuitem`,className:x===e?`root-picker-item active`:`root-picker-item`,title:e,onClick:()=>{ke(!1),Y(e)},children:(0,X.jsx)(`span`,{className:`root-picker-path`,children:e})}),(0,X.jsx)(`button`,{type:`button`,className:`root-picker-remove`,title:m(`removeWorkspaceRoot`),"aria-label":m(`removeWorkspaceRoot`),onClick:()=>Ke(e),children:(0,X.jsx)(P,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:m(`workspaceRootsHint`)})]})]}),Xe.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(lt,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Y(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:F,className:`panel-body`,onScroll:e=>{ne.current=e.currentTarget.scrollTop},onContextMenu:e=>Pe(e,{id:x,kind:`list`,label:x===``?m(`rootDir`):x===Ju?m(`computer`):x}),onDragOver:e=>{Fe(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ve(),Le(ze(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||Ie()},onDrop:e=>{if(Ie(),!Fe(e))return;e.preventDefault(),e.stopPropagation(),Ve();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,m(`foldersNotSupported`));return}B(ze(e.target),t)},onDragEnd:Ie,children:[(0,X.jsx)(`input`,{ref:ce,type:`file`,multiple:!0,hidden:!0,onChange:Me}),H&&(0,X.jsx)(Nu,{request:H,onClose:()=>se(null),onComplete:Ee}),K&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[K.kind===`dir`?(0,X.jsx)(Re,{className:`file-icon`}):(0,X.jsx)(Be,{className:`file-icon`}),xe(he,ge,be,()=>me(null))]}),T&&(0,X.jsx)(`div`,{className:`panel-empty`,children:m(`loading`)}),!T&&e&&e.path===x&&(0,X.jsxs)(X.Fragment,{children:[e.parent!=null&&(0,X.jsxs)(`button`,{type:`button`,className:`file-item dir`,onClick:Ye,children:[(0,X.jsx)(Re,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),Fu(e.entries,j).map(e=>e.type===`dir`?(0,X.jsxs)(`div`,{className:`file-item dir${U?.cut&&U.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`dir`,label:e.name}),children:[fe===e.path?xe(pe,G,ve,()=>W(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Je(e.path),children:[(0,X.jsx)(Re,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":m(`linkFolderTip`),"aria-label":m(`linkFolderTip`),onClick:()=>i(e.path,e.name,`reference`,!0),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`name:${e.path}`?` copied`:``}`,"data-tip":m(`copyName`),"aria-label":m(`copyName`),onClick:()=>L(e.name,`name:${e.path}`),children:re===`name:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`path:${e.path}`?` copied`:``}`,"data-tip":m(`copyPath`),"aria-label":m(`copyPath`),onClick:()=>L(R(e.path),`path:${e.path}`),children:re===`path:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(it,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${U?.cut&&U.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Pe(t,{id:e.path,kind:`file`,label:e.name}),children:[fe===e.path?xe(pe,G,ve,()=>W(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-name`,title:`${e.path} — ${m(`previewFile`)}`,onClick:()=>a(e.path,e.name),children:[(0,X.jsx)(Be,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name-text`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach download`,"data-tip":m(`downloadFile`),onClick:()=>q(e.path,e.name),children:(0,X.jsx)(qe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":m(`referenceTip`),"aria-label":m(`referenceTip`),onClick:()=>i(e.path,e.name,`reference`),children:(0,X.jsx)(Oe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`name:${e.path}`?` copied`:``}`,"data-tip":m(`copyName`),"aria-label":m(`copyName`),onClick:()=>L(e.name,`name:${e.path}`),children:re===`name:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${re===`path:${e.path}`?` copied`:``}`,"data-tip":m(`copyPath`),"aria-label":m(`copyPath`),onClick:()=>L(R(e.path),`path:${e.path}`),children:re===`path:${e.path}`?(0,X.jsx)(ft,{}):(0,X.jsx)(it,{})})]},e.path)),e.truncated&&(0,X.jsx)(`div`,{className:`panel-empty files-truncated`,children:m(`filesTruncated`)})]}),!T&&!e&&(0,X.jsx)(`div`,{className:`panel-empty`,children:m(`noFiles`)})]})]})}],...Ze])})}),M&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:te,onDoubleClick:()=>A({...Zu}),title:m(`dragToResize`)}),M&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:$u},children:n.filter(e=>e.lines.length>0).map(e=>(0,X.jsxs)(`div`,{className:`widget`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`widget-title widget-title-btn`,title:m(`widgetExpand`),onClick:()=>w(e.key),children:[(0,X.jsx)(`span`,{children:e.key}),(0,X.jsx)(we,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
328
328
  `)})]},e.key))}),C&&(()=>{let e=n.find(e=>e.key===C);return e?(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>w(null),children:(0,X.jsxs)(`div`,{className:`widget-expand`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`widget-expand-head`,children:[(0,X.jsx)(`span`,{className:`widget-expand-title`,children:e.key}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:m(`close`),onClick:()=>w(null),children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`pre`,{className:`widget-expand-lines`,children:e.lines.join(`
329
- `)})]})}):null})()]})});function Yu(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.text!=`string`||!t.text.trim()||typeof t.messageId!=`string`||!t.messageId||typeof t.role!=`string`||!t.role?null:{text:t.text,messageId:t.messageId,role:t.role,...typeof t.sessionId==`string`&&t.sessionId?{sessionId:t.sessionId}:{}}}function Xu(e){let t=/^<quoted-text>\n([^\n]*)\n<\/quoted-text>$/.exec(e);if(!t)return null;try{return Yu(JSON.parse(t[1]))}catch{return null}}function Zu(e){let t=e,n=[];for(;;){let e=/(?:^|\n\n)(<quoted-text>\n[^\n]*\n<\/quoted-text>)$/.exec(t),r=e?Xu(e[1]):null;if(!e||!r)break;n.unshift(r),t=t.slice(0,e.index)}return{text:t,quotes:n}}var Qu=[{id:`builtin.bash.rm-rf`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\brm\\s+((-[a-zA-Z0-9]*[rf][a-zA-Z0-9]*|--recursive|--force)\\s+)+(((\\/)|(~)|(\\.\\.)|(\\*)|(\\.\\/))|[a-zA-Z]:[\\\\/])`,action:`ask`,label:`递归/强制删除 (rm -rf)`,labelEn:`Recursive/force delete (rm -rf)`,reason:`检测到高风险的递归/强制删除大范围路径命令 (rm -rf)`,reasonEn:`Detected high-risk recursive/force deletion of wide paths (rm -rf)`,categoryId:`bash.rm-rf`,builtin:!0},{id:`builtin.bash.win-del`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\b(del|rmdir|rd)\\s+[/\\-][fsq]`,action:`ask`,label:`Windows 强制删除 (del/rmdir/rd)`,labelEn:`Windows force delete (del/rmdir/rd)`,reason:`检测到高风险的 Windows 强制/递归删除目录命令 (del/rmdir/rd /s /q)`,reasonEn:`Detected high-risk Windows force/recursive deletion command (del/rmdir/rd /s /q)`,categoryId:`bash.win-del`,builtin:!0},{id:`builtin.bash.disk`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\b(mkfs|format\\s+[a-zA-Z]:|dd\\s+if=)`,action:`ask`,label:`磁盘格式化/底层写入`,labelEn:`Disk format / raw block write`,reason:`检测到磁盘格式化或底层块写入危险命令 (format/mkfs/dd)`,reasonEn:`Detected dangerous disk formatting or raw block write command (format/mkfs/dd)`,categoryId:`bash.disk`,builtin:!0},{id:`builtin.bash.git-destructive`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\bgit(?:\\.exe)?(?:\\s+(?:-[cC]\\s+\\S+|--[a-zA-Z-]+=\\S+))*\\s+(?:push\\s+(?:[^;&|\\n]*?\\s)?(?:--force|-[a-zA-Z0-9]*f)\\b|push\\s+(?:[^;&|\\n]*?\\s)?(?:\\+\\S+|:[^\\s/]\\S*)|reset\\s+--hard|clean\\s+(?:-[a-zA-Z]+\\s+)*-[a-zA-Z0-9]*f[a-zA-Z0-9]*|branch\\s+-[dD]\\b|checkout\\s+(?:--\\s+)?\\.(?=\\s|$|[;&|])|restore\\s+(?:--(?!staged\\b)\\S+\\s+)*\\.(?=\\s|$|[;&|])|stash\\s+(?:drop|clear)\\b)`,action:`ask`,label:`破坏性 Git 操作`,labelEn:`Destructive git operation`,reason:`检测到不可逆的破坏性 Git 操作 (force push / reset --hard / clean -f / checkout . / stash drop|clear / branch -D)`,reasonEn:`Detected irreversible destructive Git operation (force push / reset --hard / clean -f / checkout . / stash drop|clear / branch -D)`,categoryId:`bash.git-destructive`,builtin:!0},{id:`builtin.bash.chmod`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\bchmod\\s+(-R\\s+)?(777|000)\\b`,action:`ask`,label:`危险权限修改 (chmod)`,labelEn:`Dangerous permission change (chmod)`,reason:`检测到过度开放或全局破坏性的文件权限修改 (chmod 777/000)`,reasonEn:`Detected overly permissive or globally destructive file permission change (chmod 777/000)`,categoryId:`bash.chmod`,builtin:!0},{id:`builtin.bash.system-redirect`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`>\\s*(\\/etc\\/|\\/boot\\/|C:\\\\Windows)`,action:`ask`,label:`写入系统关键目录`,labelEn:`Write into system directories`,reason:`检测到重定向写入系统关键目录的危险操作`,reasonEn:`Detected dangerous redirection writing into critical system directories`,categoryId:`bash.system-redirect`,builtin:!0},{id:`builtin.file.sensitive.env`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])\\.env(\\.[a-zA-Z0-9_-]+)?$`,action:`ask`,label:`敏感配置 (.env)`,labelEn:`Sensitive config (.env)`,reason:`尝试修改敏感环境变量/密钥配置文件 (.env)`,reasonEn:`Attempting to modify sensitive environment/secret configuration (.env)`,categoryId:`file.sensitive.env`,builtin:!0},{id:`builtin.file.sensitive.ssh`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])(id_rsa|id_ed25519|authorized_keys|known_hosts)$`,action:`ask`,label:`SSH 密钥/凭据`,labelEn:`SSH keys / credentials`,reason:`尝试修改 SSH 密钥或认证凭据文件`,reasonEn:`Attempting to modify SSH keys or authentication credentials`,categoryId:`file.sensitive.ssh`,builtin:!0},{id:`builtin.file.sensitive.shell`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])(\\.bashrc|\\.zshrc|\\.profile|\\.bash_profile)$`,action:`ask`,label:`Shell 启动配置`,labelEn:`Shell profile`,reason:`尝试修改用户全局 Shell 启动配置文件`,reasonEn:`Attempting to modify user global Shell profile configuration`,categoryId:`file.sensitive.shell`,builtin:!0},{id:`builtin.file.outside-workspace`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`outside_workspace`,value:``,action:`ask`,label:`工作区外写入`,labelEn:`Write outside workspace`,reason:`尝试在工作区外部写入/修改文件`,reasonEn:`Attempting to write/modify file outside the workspace`,categoryId:`file.outside-workspace`,builtin:!0}].filter(e=>e.enabled&&e.field===`command`&&e.match===`regex`&&e.tools.some(e=>e.trim().toLowerCase()===`bash`));function $u(e){if(e.length<=1)return e;let t=[...e].sort((e,t)=>e.start-t.start),n=[t[0]];for(let e=1;e<t.length;e++){let r=t[e],i=n[n.length-1];r.start<=i.end?(i.end=Math.max(i.end,r.end),r.label&&(!i.label||!i.label.includes(r.label))&&(i.label=i.label?`${i.label} / ${r.label}`:r.label)):n.push(r)}return n}function ed(e,t){if(!e||typeof e!=`string`)return[];if(t&&t.length>0){let n=[];for(let r of t)if(r.field===`command`&&r.length>0){let t=Math.max(0,r.index),i=Math.min(e.length,t+r.length);i>t&&n.push({start:t,end:i,label:r.label})}if(n.length>0)return $u(n)}let n=[];for(let t of Qu){let r;try{r=new RegExp(t.value,`gi`)}catch{continue}for(let i of e.matchAll(r)){let e=i.index??0;i[0].length>0&&n.push({start:e,end:e+i[0].length,label:t.label})}}return $u(n)}function td(e,t){let n=ed(e,t);if(n.length===0)return e;let r=[],i=0;return n.forEach((t,n)=>{t.start>i&&r.push(e.slice(i,t.start));let a=e.slice(t.start,t.end);r.push((0,X.jsx)(`mark`,{className:`bash-danger-hit`,title:t.label??`高危命令片段`,children:a},n)),i=t.end}),i<e.length&&r.push(e.slice(i)),(0,X.jsx)(X.Fragment,{children:r})}function nd({quote:e,onRemove:t,forceOpen:n=!1}){let r=Z(),[i,a]=(0,g.useState)(!1),o=e.role===`user`?`role.user`:e.role===`assistant`?`role.assistant`:e.role===`toolResult`?`role.tool`:e.role===`bashExecution`?`role.bash`:`attachment`;return(0,X.jsxs)(`div`,{className:`quote-card`,children:[(0,X.jsxs)(`details`,{open:i||n,onToggle:e=>a(e.currentTarget.open),children:[(0,X.jsxs)(`summary`,{title:r(`quoteSource`,{id:e.messageId}),children:[(0,X.jsxs)(`span`,{className:`quote-source`,children:[`↪ `,r(`quoteText`),` · `,r(o)]}),(0,X.jsx)(`span`,{className:`quote-preview`,children:e.text.replace(/\s+/g,` `).slice(0,80)})]}),(0,X.jsx)(`pre`,{className:`quote-content`,children:e.text})]}),t&&(0,X.jsx)(`button`,{type:`button`,className:`quote-remove`,"aria-label":r(`removeQuote`),title:r(`removeQuote`),onClick:t,children:`×`})]})}var rd=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],id={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...rd,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...rd],h2:[[`className`,`sr-only`]],img:[...rd,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...rd,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...rd],table:[...rd],ul:[...rd,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)},ad={}.hasOwnProperty;function od(e,t){let n={type:`root`,children:[]},r=sd({schema:t?{...id,...t}:id,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function sd(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return cd(e,n);case`doctype`:return ld(e,n);case`element`:return ud(e,n);case`root`:return dd(e,n);case`text`:return fd(e,n)}}}function cd(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return yd(r,t),r}}function ld(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return yd(e,t),e}}function ud(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=pd(e,t.children),i=md(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&ad.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return yd(o,t),o}function dd(e,t){let n={type:`root`,children:pd(e,t.children)};return yd(n,t),n}function fd(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return yd(n,t),n}function pd(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=sd(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function md(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&ad.call(r,n)?r[n]:void 0,o=r&&ad.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},c={},l;for(l in s)if(ad.call(s,l)){let t=s[l],n=hd(e,bd(a,l),l,t);n??=hd(e,bd(o,l),l,t),n!=null&&(c[l]=n)}if(i&&ad.call(i,n)){let e=i[n];for(l in e)ad.call(e,l)&&!ad.call(c,l)&&(c[l]=e[l])}return c}function hd(e,t,n,r){return t?Array.isArray(r)?gd(e,t,n,r):_d(e,t,n,r):void 0}function gd(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=_d(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function _d(e,t,n,r){if((typeof r==`boolean`||typeof r==`number`||typeof r==`string`)&&vd(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function vd(e,t,n){let r=e.schema.protocols&&ad.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),s=i.indexOf(`#`),c=i.indexOf(`/`);if(a<0||c>-1&&a>c||o>-1&&a>o||s>-1&&a>s)return!0;let l=-1;for(;++l<r.length;){let e=r[l];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function yd(e,t){let n=c(t);t.data&&(e.data=o(t.data)),n&&(e.position=n)}function bd(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}function xd(e){return function(t){return od(t,e)}}var Sd=(0,g.memo)(function({text:e}){let t=Z(),{copied:n,copy:r}=Pu({duration:1200});return e?(0,X.jsx)(`button`,{type:`button`,className:`copy-btn`,title:t(`copy`),onClick:()=>void r(e),children:n?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}):null});function Cd(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
330
- `).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,g.createElement)(n.type,i)]]:a.map(e=>[(0,g.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function wd(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(wd).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return wd(t?.children)}return``}function Td(e){let t=Array.isArray(e)?e[0]:e;return!t||typeof t!=`object`||!(`props`in t)?null:t}function Ed(e){let t=Td(e)?.props?.className;if(typeof t!=`string`)return null;let n=t.match(/(?:^|\s)language-([A-Za-z0-9_+-]+)(?:\s|$)/);return n?n[1]:null}var Dd=`pi-web-ui:plugin-data`,Od=new Map,kd=new Map,Ad=new Set,jd=-1,Md=0,Nd=new Set;function Pd(){Md++;for(let e of Nd)e()}function Fd(e){return Nd.add(e),()=>{Nd.delete(e)}}function Id(){return Md}var Ld=null;function Rd(e){Ld=e}function zd(e,t){t!==jd&&(jd=t,kd.clear(),Ad.clear());let n=new Map;for(let t of e)if(!t.error&&t.renderers)for(let e of t.renderers)n.has(e)||n.set(e,t.id);let r=n.size!==Od.size;if(!r){for(let[e,t]of n)if(Od.get(e)!==t){r=!0;break}}if(r){for(let e of kd.keys())n.has(e)||kd.delete(e);for(let e of Ad)n.has(e)||Ad.delete(e);Od=n,Pd()}}async function Bd(e,t){let n=Od.get(e);if(!n)return null;let r=kd.get(e);if(!r&&!Ad.has(e))try{let t=(await xc(()=>import(fn(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${jd}`)),[])).default?.renderers?.[e];typeof t==`function`?(r={pluginId:n,renderer:t},kd.set(e,r)):(Ad.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(t){Ad.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,t)}if(!r)return null;let i={pluginId:r.pluginId,send:e=>{Ld?.({type:`plugin_message`,pluginId:r.pluginId,payload:e})},onData:e=>{let t=t=>{let n=t.detail;n.pluginId===r.pluginId&&e(n.payload)};return window.addEventListener(Dd,t),()=>window.removeEventListener(Dd,t)}};try{let e=await r.renderer(t,i);return e instanceof HTMLElement?e:null}catch(t){return console.error(`[plugin:${r.pluginId}] renderer("${e}") 执行失败:`,t),null}}function Vd(e){return Od.has(e)}var Hd=new Map,Ud=new Map,Wd=new Set,Gd=-1;function Kd(e,t){t!==Gd&&(Gd=t,Ud.clear(),Wd.clear());let n=new Map;for(let t of e){if(t.error)continue;let e=t.messageWidgets;if(Array.isArray(e))for(let r of e)typeof r==`string`&&r&&(n.has(r)||n.set(r,t.id))}for(let e of Array.from(Hd.keys()))n.has(e)||Hd.delete(e);for(let[e,t]of n)Hd.set(e,t);for(let e of Ud.keys())n.has(e)||Ud.delete(e);for(let e of Wd)n.has(e)||Wd.delete(e)}function qd(e){return Hd.has(e)}async function Jd(e){let t=Hd.get(e);if(!t)return null;let n=Ud.get(e);if(!n&&!Wd.has(e))try{let r=(await xc(()=>import(fn(`/plugins/${encodeURIComponent(t)}/client/entry.mjs?e=${Gd}`)),[])).default?.messageWidgets?.[e];typeof r==`function`?(n={pluginId:t,renderer:r},Ud.set(e,n)):(Wd.add(e),console.error(`[plugin:${t}] entry.mjs 未提供 messageWidgets["${e}"]`))}catch(n){Wd.add(e),console.error(`[plugin:${t}] messageWidget 加载失败(${e}):`,n)}return n?.renderer??null}var Yd=`pi-web-ui:theme`,Xd=`dark`,Zd=`theme-stylesheet`,Qd=`pi-web-ui:theme-change`;function $d(){try{let e=localStorage.getItem(Yd);if(e&&e!==Xd)return e}catch{}return null}function ef(e){try{e?localStorage.setItem(Yd,e):localStorage.removeItem(Yd)}catch{}}function tf(e){let t=document.getElementById(Zd);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Qd));return}t||(t=document.createElement(`link`),t.id=Zd,t.rel=`stylesheet`,document.head.appendChild(t)),t.href=fn(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Qd))}async function nf(){try{let e=await fetch(gn(fn(`/api/themes`)));if(!e.ok)return[];let t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function rf(){let[e,t]=(0,g.useState)([]),[n,r]=(0,g.useState)(()=>$d());(0,g.useEffect)(()=>{let e=!1;return nf().then(n=>{e||t(n)}),()=>{e=!0}},[]);let i=(0,g.useCallback)(()=>{nf().then(t)},[]);return(0,g.useEffect)(()=>{tf(n),ef(n)},[n]),{themes:e,theme:n,switchTheme:e=>r(e===Xd?null:e),reloadThemes:i}}function af(){let e=getComputedStyle(document.documentElement),t=(t,n)=>e.getPropertyValue(t).trim()||n;return{background:t(`--term-bg`,`#0b0d12`),foreground:t(`--term-fg`,`#e6e8ef`),cursor:t(`--term-cursor`,`#8b5cf6`),cursorAccent:t(`--term-cursor-accent`,`#0b0d12`),selectionBackground:t(`--term-selection`,`rgba(139, 92, 246, 0.35)`),black:t(`--term-black`,`#1a1d26`),red:t(`--term-red`,`#f87171`),green:t(`--term-green`,`#34d399`),yellow:t(`--term-yellow`,`#fbbf24`),blue:t(`--term-blue`,`#60a5fa`),magenta:t(`--term-magenta`,`#c084fc`),cyan:t(`--term-cyan`,`#22d3ee`),white:t(`--term-white`,`#e6e8ef`),brightBlack:t(`--term-bright-black`,`#6b7284`),brightRed:t(`--term-bright-red`,`#f87171`),brightGreen:t(`--term-bright-green`,`#34d399`),brightYellow:t(`--term-bright-yellow`,`#fbbf24`),brightBlue:t(`--term-bright-blue`,`#60a5fa`),brightMagenta:t(`--term-bright-magenta`,`#c084fc`),brightCyan:t(`--term-bright-cyan`,`#22d3ee`),brightWhite:t(`--term-bright-white`,`#ffffff`)}}function of({lang:e,code:t}){let n=(0,g.useRef)(null),r=(0,g.useRef)(null),i=(0,g.useRef)(0),a=(0,g.useRef)(new WeakMap),[o,s]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let e=()=>{let e=++i.current,t=r.current;t&&(t.dispatchEvent(new CustomEvent(Qd)),a.current.set(t,e))};return window.addEventListener(Qd,e),()=>window.removeEventListener(Qd,e)},[]),(0,g.useEffect)(()=>{let n=!1,r=i.current;return s(null),Bd(e,t).then(e=>{n||(e&&a.current.set(e,r),s(e))}),()=>{n=!0}},[e,t]),(0,g.useEffect)(()=>{r.current=o;let e=n.current;return e&&(e.replaceChildren(),o&&(e.appendChild(o),(a.current.get(o)??i.current)<i.current&&(o.dispatchEvent(new CustomEvent(Qd)),a.current.set(o,i.current)))),()=>{r.current===o&&(r.current=null)}},[o]),o?(0,X.jsx)(`div`,{className:`plugin-fence`,ref:n}):(0,X.jsxs)(`div`,{className:`codeblock`,children:[(0,X.jsx)(Sd,{text:t}),(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:t})})]})}var sf=null,cf=null;function lf(e){sf=e?.open??null,cf=e?.isOpen??null}function uf(){return cf?cf():!1}function df(e){return!sf||!e?.path?!1:(sf(e),!0)}var ff=[u,s],pf=[u,a,s],mf=[[l,{strict:!1,throwOnError:!1}],[d,{detect:!0,ignoreMissing:!0}]];function hf(e){if(!e||!e.includes(`@`))return e;let t=e.split(RegExp("(```[\\s\\S]*?```|`[^`\\r\\n]+`)",`g`)),n=/(^|[\s((“"'[])@((?:[\w.-]+\/)*[\w.-]+\.(?:[a-zA-Z0-9]{1,10}))(?=[)\s\],.;:!?,。!?’”"']|$)/g;for(let e=0;e<t.length;e+=2)t[e]&&(t[e]=t[e].replace(n,(e,t,n)=>t+`[@`+n+`](pi-file://`+encodeURIComponent(n)+`)`));return t.join(``)}function gf({text:e,rawHtml:t=!1,hardBreaks:n=!1}){let r=t?[p,xd,...mf]:mf,i=(0,g.useMemo)(()=>hf(e),[e]);return(0,X.jsx)(f,{remarkPlugins:n?pf:ff,rehypePlugins:r,components:{pre:yf,a:vf},children:i})}var _f=(0,g.memo)(function({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(gf,{text:e,rawHtml:t,hardBreaks:n})})});function vf({node:e,href:t,children:n,...r}){let i=String(t??``);if(i.startsWith(`pi-file://`)){let e=i.slice(10),t=e;try{t=decodeURIComponent(e)}catch{t=e}let r=typeof n==`string`&&n.trim()?n.trim():t.split(`/`).pop()??t;return(0,X.jsxs)(`button`,{type:`button`,className:`file-pill`,title:`点击预览文件: `+t,onClick:e=>{e.preventDefault(),e.stopPropagation(),df({path:t,name:r.replace(/^@/,``)})},children:[(0,X.jsx)(`span`,{className:`file-pill-icon`,"aria-hidden":`true`,children:`📄`}),(0,X.jsx)(`span`,{className:`file-pill-name`,children:r})]})}return/^(https?:|mailto:|tel:)/i.test(i)?(0,X.jsx)(`a`,{...r,href:t,target:`_blank`,rel:`noreferrer noopener`,children:n}):(0,X.jsx)(`a`,{href:t,...r,children:n})}function yf({children:e,...t}){(0,g.useSyncExternalStore)(Fd,Id,Id);let n=Ed(e);return n&&Vd(n)?(0,X.jsx)(of,{lang:n,code:wd(e)}):(0,X.jsx)(bf,{children:e,...t})}function bf({children:e,...t}){let n=Cd(e&&typeof e==`object`&&`props`in e?e.props?.children:e),r=n.length>1,i=r?`${String(n.length).length+1}ch`:void 0;return(0,X.jsxs)(`div`,{className:`codeblock`,children:[(0,X.jsx)(Sd,{text:xf(e)}),(0,X.jsx)(`pre`,{...t,children:n.map((e,t)=>(0,X.jsxs)(`div`,{className:`code-line`,children:[r&&(0,X.jsx)(`span`,{className:`code-num`,style:i?{width:i}:void 0,children:t+1}),(0,X.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function xf(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(xf).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return xf(t?.children)}return``}function Sf({type:e,code:t,children:n}){let r=(0,g.useRef)(null),[i,a]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!1;if(a(null),qd(e))return Jd(e).then(async r=>{if(!n&&r)try{let i=await r(t,{pluginId:Hd.get(e)??e,send:()=>void 0,onData:()=>()=>void 0});!n&&i instanceof HTMLElement&&a(i)}catch(t){console.error(`[plugin-widget:${e}] 渲染失败:`,t)}}),()=>{n=!0}},[e,t]),(0,g.useEffect)(()=>{let e=r.current;e&&(e.replaceChildren(),i&&e.appendChild(i))},[i]),i?(0,X.jsx)(`div`,{className:`plugin-widget`,ref:r}):(0,X.jsx)(X.Fragment,{children:n})}var Cf=/^\s{0,3}(`{3,}|~{3,})/,wf=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Tf(e){return e.trim()===``}function Ef(e){let t=Cf.exec(e);return t?t[1]:null}function Df(e){let t=e.split(`
331
- `),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=Ef(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=Ef(a);if(o&&!Tf(a)){i=o,r.push(a);continue}if(Tf(a)){let i=e;for(;i<t.length&&Tf(t[i]);)i++;if(!(i<t.length&&wf.test(t[i]))&&r.length>0){n.push(r.join(`
329
+ `)})]})}):null})()]})});function cd(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.text!=`string`||!t.text.trim()||typeof t.messageId!=`string`||!t.messageId||typeof t.role!=`string`||!t.role?null:{text:t.text,messageId:t.messageId,role:t.role,...typeof t.sessionId==`string`&&t.sessionId?{sessionId:t.sessionId}:{}}}function ld(e){let t=/^<quoted-text>\n([^\n]*)\n<\/quoted-text>$/.exec(e);if(!t)return null;try{return cd(JSON.parse(t[1]))}catch{return null}}function ud(e){let t=e,n=[];for(;;){let e=/(?:^|\n\n)(<quoted-text>\n[^\n]*\n<\/quoted-text>)$/.exec(t),r=e?ld(e[1]):null;if(!e||!r)break;n.unshift(r),t=t.slice(0,e.index)}return{text:t,quotes:n}}var dd=[{id:`builtin.bash.rm-rf`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\brm\\s+((-[a-zA-Z0-9]*[rf][a-zA-Z0-9]*|--recursive|--force)\\s+)+(((\\/)|(~)|(\\.\\.)|(\\*)|(\\.\\/))|[a-zA-Z]:[\\\\/])`,action:`ask`,label:`递归/强制删除 (rm -rf)`,labelEn:`Recursive/force delete (rm -rf)`,reason:`检测到高风险的递归/强制删除大范围路径命令 (rm -rf)`,reasonEn:`Detected high-risk recursive/force deletion of wide paths (rm -rf)`,categoryId:`bash.rm-rf`,builtin:!0},{id:`builtin.bash.win-del`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\b(del|rmdir|rd)\\s+[/\\-][fsq]`,action:`ask`,label:`Windows 强制删除 (del/rmdir/rd)`,labelEn:`Windows force delete (del/rmdir/rd)`,reason:`检测到高风险的 Windows 强制/递归删除目录命令 (del/rmdir/rd /s /q)`,reasonEn:`Detected high-risk Windows force/recursive deletion command (del/rmdir/rd /s /q)`,categoryId:`bash.win-del`,builtin:!0},{id:`builtin.bash.disk`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\b(mkfs|format\\s+[a-zA-Z]:|dd\\s+if=)`,action:`ask`,label:`磁盘格式化/底层写入`,labelEn:`Disk format / raw block write`,reason:`检测到磁盘格式化或底层块写入危险命令 (format/mkfs/dd)`,reasonEn:`Detected dangerous disk formatting or raw block write command (format/mkfs/dd)`,categoryId:`bash.disk`,builtin:!0},{id:`builtin.bash.git-destructive`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\bgit(?:\\.exe)?(?:\\s+(?:-[cC]\\s+\\S+|--[a-zA-Z-]+=\\S+))*\\s+(?:push\\s+(?:[^;&|\\n]*?\\s)?(?:--force|-[a-zA-Z0-9]*f)\\b|push\\s+(?:[^;&|\\n]*?\\s)?(?:\\+\\S+|:[^\\s/]\\S*)|reset\\s+--hard|clean\\s+(?:-[a-zA-Z]+\\s+)*-[a-zA-Z0-9]*f[a-zA-Z0-9]*|branch\\s+-[dD]\\b|checkout\\s+(?:--\\s+)?\\.(?=\\s|$|[;&|])|restore\\s+(?:--(?!staged\\b)\\S+\\s+)*\\.(?=\\s|$|[;&|])|stash\\s+(?:drop|clear)\\b)`,action:`ask`,label:`破坏性 Git 操作`,labelEn:`Destructive git operation`,reason:`检测到不可逆的破坏性 Git 操作 (force push / reset --hard / clean -f / checkout . / stash drop|clear / branch -D)`,reasonEn:`Detected irreversible destructive Git operation (force push / reset --hard / clean -f / checkout . / stash drop|clear / branch -D)`,categoryId:`bash.git-destructive`,builtin:!0},{id:`builtin.bash.chmod`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`\\bchmod\\s+(-R\\s+)?(777|000)\\b`,action:`ask`,label:`危险权限修改 (chmod)`,labelEn:`Dangerous permission change (chmod)`,reason:`检测到过度开放或全局破坏性的文件权限修改 (chmod 777/000)`,reasonEn:`Detected overly permissive or globally destructive file permission change (chmod 777/000)`,categoryId:`bash.chmod`,builtin:!0},{id:`builtin.bash.system-redirect`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:`>\\s*(\\/etc\\/|\\/boot\\/|C:\\\\Windows)`,action:`ask`,label:`写入系统关键目录`,labelEn:`Write into system directories`,reason:`检测到重定向写入系统关键目录的危险操作`,reasonEn:`Detected dangerous redirection writing into critical system directories`,categoryId:`bash.system-redirect`,builtin:!0},{id:`builtin.file.sensitive.env`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])\\.env(\\.[a-zA-Z0-9_-]+)?$`,action:`ask`,label:`敏感配置 (.env)`,labelEn:`Sensitive config (.env)`,reason:`尝试修改敏感环境变量/密钥配置文件 (.env)`,reasonEn:`Attempting to modify sensitive environment/secret configuration (.env)`,categoryId:`file.sensitive.env`,builtin:!0},{id:`builtin.file.sensitive.ssh`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])(id_rsa|id_ed25519|authorized_keys|known_hosts)$`,action:`ask`,label:`SSH 密钥/凭据`,labelEn:`SSH keys / credentials`,reason:`尝试修改 SSH 密钥或认证凭据文件`,reasonEn:`Attempting to modify SSH keys or authentication credentials`,categoryId:`file.sensitive.ssh`,builtin:!0},{id:`builtin.file.sensitive.shell`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`regex`,value:`(^|[\\/\\\\])(\\.bashrc|\\.zshrc|\\.profile|\\.bash_profile)$`,action:`ask`,label:`Shell 启动配置`,labelEn:`Shell profile`,reason:`尝试修改用户全局 Shell 启动配置文件`,reasonEn:`Attempting to modify user global Shell profile configuration`,categoryId:`file.sensitive.shell`,builtin:!0},{id:`builtin.file.outside-workspace`,enabled:!0,tools:[`write`,`edit`,`edit_soft`],field:`path`,match:`outside_workspace`,value:``,action:`ask`,label:`工作区外写入`,labelEn:`Write outside workspace`,reason:`尝试在工作区外部写入/修改文件`,reasonEn:`Attempting to write/modify file outside the workspace`,categoryId:`file.outside-workspace`,builtin:!0}].filter(e=>e.enabled&&e.field===`command`&&e.match===`regex`&&e.tools.some(e=>e.trim().toLowerCase()===`bash`));function fd(e){if(e.length<=1)return e;let t=[...e].sort((e,t)=>e.start-t.start),n=[t[0]];for(let e=1;e<t.length;e++){let r=t[e],i=n[n.length-1];r.start<=i.end?(i.end=Math.max(i.end,r.end),r.label&&(!i.label||!i.label.includes(r.label))&&(i.label=i.label?`${i.label} / ${r.label}`:r.label)):n.push(r)}return n}function pd(e,t){if(!e||typeof e!=`string`)return[];if(t&&t.length>0){let n=[];for(let r of t)if(r.field===`command`&&r.length>0){let t=Math.max(0,r.index),i=Math.min(e.length,t+r.length);i>t&&n.push({start:t,end:i,label:r.label})}if(n.length>0)return fd(n)}let n=[];for(let t of dd){let r;try{r=new RegExp(t.value,`gi`)}catch{continue}for(let i of e.matchAll(r)){let e=i.index??0;i[0].length>0&&n.push({start:e,end:e+i[0].length,label:t.label})}}return fd(n)}function md(e,t){let n=pd(e,t);if(n.length===0)return e;let r=[],i=0;return n.forEach((t,n)=>{t.start>i&&r.push(e.slice(i,t.start));let a=e.slice(t.start,t.end);r.push((0,X.jsx)(`mark`,{className:`bash-danger-hit`,title:t.label??`高危命令片段`,children:a},n)),i=t.end}),i<e.length&&r.push(e.slice(i)),(0,X.jsx)(X.Fragment,{children:r})}function hd({quote:e,onRemove:t,forceOpen:n=!1}){let r=Z(),[i,a]=(0,g.useState)(!1),o=e.role===`user`?`role.user`:e.role===`assistant`?`role.assistant`:e.role===`toolResult`?`role.tool`:e.role===`bashExecution`?`role.bash`:`attachment`;return(0,X.jsxs)(`div`,{className:`quote-card`,children:[(0,X.jsxs)(`details`,{open:i||n,onToggle:e=>a(e.currentTarget.open),children:[(0,X.jsxs)(`summary`,{title:r(`quoteSource`,{id:e.messageId}),children:[(0,X.jsxs)(`span`,{className:`quote-source`,children:[`↪ `,r(`quoteText`),` · `,r(o)]}),(0,X.jsx)(`span`,{className:`quote-preview`,children:e.text.replace(/\s+/g,` `).slice(0,80)})]}),(0,X.jsx)(`pre`,{className:`quote-content`,children:e.text})]}),t&&(0,X.jsx)(`button`,{type:`button`,className:`quote-remove`,"aria-label":r(`removeQuote`),title:r(`removeQuote`),onClick:t,children:`×`})]})}var gd=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],_d={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...gd,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...gd],h2:[[`className`,`sr-only`]],img:[...gd,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...gd,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...gd],table:[...gd],ul:[...gd,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)},vd={}.hasOwnProperty;function yd(e,t){let n={type:`root`,children:[]},r=bd({schema:t?{..._d,...t}:_d,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function bd(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return xd(e,n);case`doctype`:return Sd(e,n);case`element`:return Cd(e,n);case`root`:return wd(e,n);case`text`:return Td(e,n)}}}function xd(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return Md(r,t),r}}function Sd(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return Md(e,t),e}}function Cd(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=Ed(e,t.children),i=Dd(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&vd.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return Md(o,t),o}function wd(e,t){let n={type:`root`,children:Ed(e,t.children)};return Md(n,t),n}function Td(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return Md(n,t),n}function Ed(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=bd(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function Dd(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&vd.call(r,n)?r[n]:void 0,o=r&&vd.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},c={},l;for(l in s)if(vd.call(s,l)){let t=s[l],n=Od(e,Nd(a,l),l,t);n??=Od(e,Nd(o,l),l,t),n!=null&&(c[l]=n)}if(i&&vd.call(i,n)){let e=i[n];for(l in e)vd.call(e,l)&&!vd.call(c,l)&&(c[l]=e[l])}return c}function Od(e,t,n,r){return t?Array.isArray(r)?kd(e,t,n,r):Ad(e,t,n,r):void 0}function kd(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=Ad(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function Ad(e,t,n,r){if((typeof r==`boolean`||typeof r==`number`||typeof r==`string`)&&jd(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function jd(e,t,n){let r=e.schema.protocols&&vd.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),s=i.indexOf(`#`),c=i.indexOf(`/`);if(a<0||c>-1&&a>c||o>-1&&a>o||s>-1&&a>s)return!0;let l=-1;for(;++l<r.length;){let e=r[l];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function Md(e,t){let n=c(t);t.data&&(e.data=o(t.data)),n&&(e.position=n)}function Nd(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}function Pd(e){return function(t){return yd(t,e)}}var Fd=(0,g.memo)(function({text:e}){let t=Z(),{copied:n,copy:r}=qu({duration:1200});return e?(0,X.jsx)(`button`,{type:`button`,className:`copy-btn`,title:t(`copy`),onClick:()=>void r(e),children:n?(0,X.jsx)(ft,{}):(0,X.jsx)(tt,{})}):null});function Id(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
330
+ `).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,g.createElement)(n.type,i)]]:a.map(e=>[(0,g.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function Ld(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Ld).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Ld(t?.children)}return``}function Rd(e){let t=Array.isArray(e)?e[0]:e;return!t||typeof t!=`object`||!(`props`in t)?null:t}function zd(e){let t=Rd(e)?.props?.className;if(typeof t!=`string`)return null;let n=t.match(/(?:^|\s)language-([A-Za-z0-9_+-]+)(?:\s|$)/);return n?n[1]:null}var Bd=`pi-web-ui:plugin-data`,Vd=new Map,Hd=new Map,Ud=new Set,Wd=-1,Gd=0,Kd=new Set;function qd(){Gd++;for(let e of Kd)e()}function Jd(e){return Kd.add(e),()=>{Kd.delete(e)}}function Yd(){return Gd}var Xd=null;function Zd(e){Xd=e}function Qd(e,t){t!==Wd&&(Wd=t,Hd.clear(),Ud.clear());let n=new Map;for(let t of e)if(!t.error&&t.renderers)for(let e of t.renderers)n.has(e)||n.set(e,t.id);let r=n.size!==Vd.size;if(!r){for(let[e,t]of n)if(Vd.get(e)!==t){r=!0;break}}if(r){for(let e of Hd.keys())n.has(e)||Hd.delete(e);for(let e of Ud)n.has(e)||Ud.delete(e);Vd=n,qd()}}async function $d(e,t){let n=Vd.get(e);if(!n)return null;let r=Hd.get(e);if(!r&&!Ud.has(e))try{let t=(await Pc(()=>import(fn(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${Wd}`)),[])).default?.renderers?.[e];typeof t==`function`?(r={pluginId:n,renderer:t},Hd.set(e,r)):(Ud.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(t){Ud.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,t)}if(!r)return null;let i={pluginId:r.pluginId,send:e=>{Xd?.({type:`plugin_message`,pluginId:r.pluginId,payload:e})},onData:e=>{let t=t=>{let n=t.detail;n.pluginId===r.pluginId&&e(n.payload)};return window.addEventListener(Bd,t),()=>window.removeEventListener(Bd,t)}};try{let e=await r.renderer(t,i);return e instanceof HTMLElement?e:null}catch(t){return console.error(`[plugin:${r.pluginId}] renderer("${e}") 执行失败:`,t),null}}function ef(e){return Vd.has(e)}var tf=new Map,nf=new Map,rf=new Set,af=-1;function of(e,t){t!==af&&(af=t,nf.clear(),rf.clear());let n=new Map;for(let t of e){if(t.error)continue;let e=t.messageWidgets;if(Array.isArray(e))for(let r of e)typeof r==`string`&&r&&(n.has(r)||n.set(r,t.id))}for(let e of Array.from(tf.keys()))n.has(e)||tf.delete(e);for(let[e,t]of n)tf.set(e,t);for(let e of nf.keys())n.has(e)||nf.delete(e);for(let e of rf)n.has(e)||rf.delete(e)}function sf(e){return tf.has(e)}async function cf(e){let t=tf.get(e);if(!t)return null;let n=nf.get(e);if(!n&&!rf.has(e))try{let r=(await Pc(()=>import(fn(`/plugins/${encodeURIComponent(t)}/client/entry.mjs?e=${af}`)),[])).default?.messageWidgets?.[e];typeof r==`function`?(n={pluginId:t,renderer:r},nf.set(e,n)):(rf.add(e),console.error(`[plugin:${t}] entry.mjs 未提供 messageWidgets["${e}"]`))}catch(n){rf.add(e),console.error(`[plugin:${t}] messageWidget 加载失败(${e}):`,n)}return n?.renderer??null}var lf=`pi-web-ui:theme`,uf=`dark`,df=`theme-stylesheet`,ff=`pi-web-ui:theme-change`;function pf(){try{let e=localStorage.getItem(lf);if(e&&e!==uf)return e}catch{}return null}function mf(e){try{e?localStorage.setItem(lf,e):localStorage.removeItem(lf)}catch{}}function hf(e){let t=document.getElementById(df);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(ff));return}t||(t=document.createElement(`link`),t.id=df,t.rel=`stylesheet`,document.head.appendChild(t)),t.href=fn(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(ff))}async function gf(){try{let e=await fetch(gn(fn(`/api/themes`)));if(!e.ok)return[];let t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function _f(){let[e,t]=(0,g.useState)([]),[n,r]=(0,g.useState)(()=>pf());(0,g.useEffect)(()=>{let e=!1;return gf().then(n=>{e||t(n)}),()=>{e=!0}},[]);let i=(0,g.useCallback)(()=>{gf().then(t)},[]);return(0,g.useEffect)(()=>{hf(n),mf(n)},[n]),{themes:e,theme:n,switchTheme:e=>r(e===uf?null:e),reloadThemes:i}}function vf(){let e=getComputedStyle(document.documentElement),t=(t,n)=>e.getPropertyValue(t).trim()||n;return{background:t(`--term-bg`,`#0b0d12`),foreground:t(`--term-fg`,`#e6e8ef`),cursor:t(`--term-cursor`,`#8b5cf6`),cursorAccent:t(`--term-cursor-accent`,`#0b0d12`),selectionBackground:t(`--term-selection`,`rgba(139, 92, 246, 0.35)`),black:t(`--term-black`,`#1a1d26`),red:t(`--term-red`,`#f87171`),green:t(`--term-green`,`#34d399`),yellow:t(`--term-yellow`,`#fbbf24`),blue:t(`--term-blue`,`#60a5fa`),magenta:t(`--term-magenta`,`#c084fc`),cyan:t(`--term-cyan`,`#22d3ee`),white:t(`--term-white`,`#e6e8ef`),brightBlack:t(`--term-bright-black`,`#6b7284`),brightRed:t(`--term-bright-red`,`#f87171`),brightGreen:t(`--term-bright-green`,`#34d399`),brightYellow:t(`--term-bright-yellow`,`#fbbf24`),brightBlue:t(`--term-bright-blue`,`#60a5fa`),brightMagenta:t(`--term-bright-magenta`,`#c084fc`),brightCyan:t(`--term-bright-cyan`,`#22d3ee`),brightWhite:t(`--term-bright-white`,`#ffffff`)}}function yf({lang:e,code:t}){let n=(0,g.useRef)(null),r=(0,g.useRef)(null),i=(0,g.useRef)(0),a=(0,g.useRef)(new WeakMap),[o,s]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let e=()=>{let e=++i.current,t=r.current;t&&(t.dispatchEvent(new CustomEvent(ff)),a.current.set(t,e))};return window.addEventListener(ff,e),()=>window.removeEventListener(ff,e)},[]),(0,g.useEffect)(()=>{let n=!1,r=i.current;return s(null),$d(e,t).then(e=>{n||(e&&a.current.set(e,r),s(e))}),()=>{n=!0}},[e,t]),(0,g.useEffect)(()=>{r.current=o;let e=n.current;return e&&(e.replaceChildren(),o&&(e.appendChild(o),(a.current.get(o)??i.current)<i.current&&(o.dispatchEvent(new CustomEvent(ff)),a.current.set(o,i.current)))),()=>{r.current===o&&(r.current=null)}},[o]),o?(0,X.jsx)(`div`,{className:`plugin-fence`,ref:n}):(0,X.jsxs)(`div`,{className:`codeblock`,children:[(0,X.jsx)(Fd,{text:t}),(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:t})})]})}var bf=null,xf=null;function Sf(e){bf=e?.open??null,xf=e?.isOpen??null}function Cf(){return xf?xf():!1}function wf(e){return!bf||!e?.path?!1:(bf(e),!0)}var Tf=[u,s],Ef=[u,a,s],Df=[[l,{strict:!1,throwOnError:!1}],[d,{detect:!0,ignoreMissing:!0}]];function Of(e){if(!e||!e.includes(`@`))return e;let t=e.split(RegExp("(```[\\s\\S]*?```|`[^`\\r\\n]+`)",`g`)),n=/(^|[\s((“"'[])@((?:[\w.-]+\/)*[\w.-]+\.(?:[a-zA-Z0-9]{1,10}))(?=[)\s\],.;:!?,。!?’”"']|$)/g;for(let e=0;e<t.length;e+=2)t[e]&&(t[e]=t[e].replace(n,(e,t,n)=>t+`[@`+n+`](pi-file://`+encodeURIComponent(n)+`)`));return t.join(``)}function kf({text:e,rawHtml:t=!1,hardBreaks:n=!1}){let r=t?[p,Pd,...Df]:Df,i=(0,g.useMemo)(()=>Of(e),[e]);return(0,X.jsx)(f,{remarkPlugins:n?Ef:Tf,rehypePlugins:r,components:{pre:Mf,a:jf},children:i})}var Af=(0,g.memo)(function({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(kf,{text:e,rawHtml:t,hardBreaks:n})})});function jf({node:e,href:t,children:n,...r}){let i=String(t??``);if(i.startsWith(`pi-file://`)){let e=i.slice(10),t=e;try{t=decodeURIComponent(e)}catch{t=e}let r=typeof n==`string`&&n.trim()?n.trim():t.split(`/`).pop()??t;return(0,X.jsxs)(`button`,{type:`button`,className:`file-pill`,title:`点击预览文件: `+t,onClick:e=>{e.preventDefault(),e.stopPropagation(),wf({path:t,name:r.replace(/^@/,``)})},children:[(0,X.jsx)(`span`,{className:`file-pill-icon`,"aria-hidden":`true`,children:`📄`}),(0,X.jsx)(`span`,{className:`file-pill-name`,children:r})]})}return/^(https?:|mailto:|tel:)/i.test(i)?(0,X.jsx)(`a`,{...r,href:t,target:`_blank`,rel:`noreferrer noopener`,children:n}):(0,X.jsx)(`a`,{href:t,...r,children:n})}function Mf({children:e,...t}){(0,g.useSyncExternalStore)(Jd,Yd,Yd);let n=zd(e);return n&&ef(n)?(0,X.jsx)(yf,{lang:n,code:Ld(e)}):(0,X.jsx)(Nf,{children:e,...t})}function Nf({children:e,...t}){let n=Id(e&&typeof e==`object`&&`props`in e?e.props?.children:e),r=n.length>1,i=r?`${String(n.length).length+1}ch`:void 0;return(0,X.jsxs)(`div`,{className:`codeblock`,children:[(0,X.jsx)(Fd,{text:Pf(e)}),(0,X.jsx)(`pre`,{...t,children:n.map((e,t)=>(0,X.jsxs)(`div`,{className:`code-line`,children:[r&&(0,X.jsx)(`span`,{className:`code-num`,style:i?{width:i}:void 0,children:t+1}),(0,X.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function Pf(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Pf).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Pf(t?.children)}return``}function Ff({type:e,code:t,children:n}){let r=(0,g.useRef)(null),[i,a]=(0,g.useState)(null);return(0,g.useEffect)(()=>{let n=!1;if(a(null),sf(e))return cf(e).then(async r=>{if(!n&&r)try{let i=await r(t,{pluginId:tf.get(e)??e,send:()=>void 0,onData:()=>()=>void 0});!n&&i instanceof HTMLElement&&a(i)}catch(t){console.error(`[plugin-widget:${e}] 渲染失败:`,t)}}),()=>{n=!0}},[e,t]),(0,g.useEffect)(()=>{let e=r.current;e&&(e.replaceChildren(),i&&e.appendChild(i))},[i]),i?(0,X.jsx)(`div`,{className:`plugin-widget`,ref:r}):(0,X.jsx)(X.Fragment,{children:n})}var If=/^\s{0,3}(`{3,}|~{3,})/,Lf=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Rf(e){return e.trim()===``}function zf(e){let t=If.exec(e);return t?t[1]:null}function Bf(e){let t=e.split(`
331
+ `),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=zf(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=zf(a);if(o&&!Rf(a)){i=o,r.push(a);continue}if(Rf(a)){let i=e;for(;i<t.length&&Rf(t[i]);)i++;if(!(i<t.length&&Lf.test(t[i]))&&r.length>0){n.push(r.join(`
332
332
  `)),r=[];continue}r.push(a);continue}r.push(a)}return{frozen:n,active:r.join(`
333
- `),inFence:i!==null}}var Of=(0,g.memo)(function({text:e}){return(0,X.jsx)(gf,{text:e})}),kf=200;function Af({text:e,inFence:t}){let[n,r]=(0,g.useState)(e),i=(0,g.useRef)(0),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(t)return;let n=Date.now()-i.current,o=()=>{i.current=Date.now(),r(e)};if(n>=kf){o();return}return a.current=setTimeout(o,kf-n),()=>{a.current&&clearTimeout(a.current)}},[e,t]),t?(0,X.jsx)(`div`,{className:`codeblock`,children:(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:e})})}):(0,X.jsx)(gf,{text:n})}var jf=(0,g.memo)(function({text:e}){let{frozen:t,active:n,inFence:r}=(0,g.useMemo)(()=>Df(e),[e]);return(0,X.jsxs)(`div`,{className:`md`,children:[t.map((e,t)=>(0,X.jsx)(Of,{text:e},t)),n.length>0&&(0,X.jsx)(Af,{text:n,inFence:r},t.length)]})});function Mf({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,X.jsxs)(`div`,{className:`chead ${n}`,role:`button`,tabIndex:0,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},children:[c===void 0?(0,X.jsx)(`button`,{type:`button`,className:s?`chead-toggle ${s}`:`chead-toggle`,title:r,"aria-label":r,"aria-expanded":e,onClick:e=>{e.stopPropagation(),t()},children:e?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}):c,(0,X.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,X.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u}),d]})}function Nf(e,t){return t?e.trimEnd().slice(-80):e.split(`
334
- `)[0].slice(0,80)}function Pf({thinking:e,streaming:t,wrap:n=!0,forceOpen:r=!1}){let i=Z(),[a,o]=(0,g.useState)(null),s=a??n,c=s||r,l=Nf(e,t),{copied:u,copy:d}=Pu({duration:1200}),f=()=>{d(e)};return(0,X.jsxs)(`div`,{className:`thinking ${c?`open`:``} ${t?`live`:``}`,children:[(0,X.jsx)(Mf,{open:c,headClassName:`thinking-head`,toggleClassName:`thinking-toggle`,titleText:i(c?`collapseMsg`:`expandMsg`),onToggle:()=>o(!s),icon:(0,X.jsx)(Ze,{}),iconClassName:`thinking-icon`,titleClassName:`thinking-label`,after:(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy thinking-copy${u?` copied`:``}`,title:i(u?`copied`:`copyMessage`),"aria-label":i(`copyMessage`),onClick:e=>{e.stopPropagation(),f()},children:u?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})})}),children:t&&c?(0,X.jsxs)(`span`,{className:`thinking-live-label`,children:[i(`thinkingNow`),(0,X.jsx)(`span`,{className:`dots`})]}):c?i(`thinking`):i(`thinkingPreview`,{preview:l})}),c&&(0,X.jsx)(`div`,{className:`thinking-body`,children:e})]})}var Ff=262144,If=300,Lf=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,Rf=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,zf=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,Bf=/"(query|q|search)"\s*:\s*"((?:[^"\\\n]|\\.){0,400})"/,Vf=1e9;function Hf(e){if(!e)return{};let t=e.length>Ff?e.slice(0,Ff):e;return{path:qf(t),timeout:Jf(t),command:Xf(e),agent:Uf(t),codeLines:$f(e),query:Yf(t),questionTitle:tp(t)}}function Uf(e){let t=Rf.exec(e);if(!t)return;let n=t[1].replace(/[\u0000-\u001f\u007f]/g,``).trim();if(n)return n.length>If?`${n.slice(0,If)}…`:n}var Wf=[`task`,`expected_outcome`,`required_tools`,`must_do`,`must_not_do`,`context`];function Gf(e){if(!e||e.length>Ff)return{};try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n=t,r={};for(let e of[...Wf,`agent`,`model`])typeof n[e]==`string`&&n[e].trim()&&(r[e]=n[e]);return r}catch{return{}}}function Kf(e,t=56){if(e.length<=t)return e;let n=e.split(/[\\/]+/).filter(Boolean),r=n[n.length-1];if(!r||n.length<=1)return`…${e.slice(-(t-1))}`;let i=r;for(let e=n.length-2;e>=0;e--){let r=`${n[e]}/${i}`;if(r.length+2>t)break;i=r}return`…/${i}`}function qf(e){let t=Lf.exec(e);if(!t)return;let n=Zf(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>If?`${n.slice(0,299)}…`:n}function Jf(e){let t=zf.exec(e);if(!t)return;let n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>Vf)return;let r=t[1].toLowerCase();return!r.endsWith(`ms`)&&!r.endsWith(`milliseconds`)?`${n}s`:n<1e3?`${n}ms`:`${Math.round(n/100)/10}s`}function Yf(e){let t=Bf.exec(e);if(!t)return;let n=Zf(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>60?`${n.slice(0,57)}…`:n}function Xf(e){if(!(e.length>Ff))try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?void 0:typeof t.command==`string`&&t.command.trim()?t.command:void 0}catch{return}}function Zf(e){try{let t=JSON.parse(`"${e}"`);return typeof t==`string`?t:e}catch{return e}}function Qf(e){if(!e)return{};let t,n=e.trim();if(n.startsWith(`{`))try{let e=JSON.parse(n);typeof e?.code==`string`&&(t=e.code)}catch{let e=/"code"\s*:\s*"((?:[^"\\]|\\.)*)/.exec(n);e&&(t=Zf(e[1]))}else n&&(t=e);if(!t)return{};let r=t.indexOf(`
335
- `),i=r===-1?t.trim():t.slice(0,r).trim(),a;if(i.startsWith(`// @options:`))try{a=JSON.parse(i.slice(12).trim())}catch{}return{code:t,options:a}}function $f(e){let t=Qf(e);if(!t.code)return;let n=t.code.split(`
336
- `).length;return n>0?n:void 0}var ep=/"(?:header|question)"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/;function tp(e){let t=ep.exec(e);if(!t)return;let n=Zf(t[1]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>40?`${n.slice(0,38)}…`:n}function np(e){if(!e||e.length>Ff)return null;try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.questions;return Array.isArray(n)&&n.length>0?{questions:n}:null}catch{return null}}var rp=new Set([`image`,`video`,`audio`,`markdown`,`html`,`pdf`,`text`,`binary`,`dir`,`missing`]);function ip(e){let t=String(e??``).trim().replace(/\\/g,`/`);return t.length>1?t.replace(/\/+$/,``):t}function ap(e){let t=ip(e).split(`/`);return(t[t.length-1]??``)||String(e??``)}function op(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function sp(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function cp(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=op(t);if(!n)return null;let r=Array.isArray(n.items)?n.items:[],i=[];for(let e of r){if(typeof e==`string`){let t=e.trim();t&&i.push({path:t});continue}let t=op(e),n=t?sp(t.path):void 0;if(!n)continue;let r={path:n},a=sp(t?.caption);a&&(r.caption=a),t?.focus===!0&&(r.focus=!0),i.push(r)}if(i.length===0)return null;let a={items:i},o=sp(n.title);o&&(a.title=o);let s=sp(n.note);return s&&(a.note=s),a}function lp(e,t){let n=op(t),r=Array.isArray(n?.items)?n.items.map(op):[],i=new Map;for(let e of r){if(!e)continue;let t=ip(String(e.path??e.abs??``));t&&!i.has(t)&&i.set(t,e)}return e.items.map((e,t)=>{let n=i.get(ip(e.path))??r[t]??null,a=sp(n?.kind),o={path:e.path,target:sp(n?.abs)??e.path,name:ap(sp(n?.name)??e.path),kind:a&&rp.has(a)?a:`unknown`,focus:e.focus===!0};e.caption&&(o.caption=e.caption),typeof n?.size==`number`&&Number.isFinite(n.size)&&(o.size=n.size),typeof n?.mtime==`number`&&Number.isFinite(n.mtime)&&(o.mtime=n.mtime);let s=sp(n?.excerpt);return s&&(o.excerpt=s),n?.excerptTruncated===!0&&(o.excerptTruncated=!0),o})}function up(e,t){return sp(op(t)?.title)??e.title}function dp(e,t){return sp(op(t)?.note)??e.note}function fp(e){return e===`image`||e===`video`||e===`audio`?e:null}function pp(e){return e!==`dir`&&e!==`missing`}function mp(e){switch(e){case`image`:return`🖼`;case`video`:return`🎬`;case`audio`:return`🎵`;case`markdown`:return`📝`;case`html`:return`🌐`;case`pdf`:return`📕`;case`text`:return`📄`;case`dir`:return`📁`;case`missing`:return`⚠`;default:return`📦`}}function hp(e){if(!(e===void 0||!Number.isFinite(e)||e<0))return e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function gp(e){return e.find(e=>e.focus&&pp(e.kind))}function _p(e){if(!e.enabled||e.seen||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))return!1;let t=e.now-e.timestamp;return t>=0&&t<=e.maxAgeMs}var vp=`pi-web-ui:present-auto-open`,yp=3e4,bp=`pi-web-ui:present-auto-opened`;function xp(){try{return localStorage.getItem(vp)===`1`}catch{return!1}}function Sp(e){try{localStorage.setItem(vp,e?`1`:`0`)}catch{}Ep=e,wp()}var Cp=new Set;function wp(){for(let e of Cp)e()}function Tp(e){return Cp.add(e),()=>{Cp.delete(e)}}var Ep=null;function Dp(){return Ep===null&&(Ep=xp()),Ep}function Op(){return(0,g.useSyncExternalStore)(Tp,Dp)}function kp(){try{let e=sessionStorage.getItem(bp);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ap(e){if(!e)return!1;let t=kp();if(t.includes(e))return!1;let n=[...t,e].slice(-200);try{sessionStorage.setItem(bp,JSON.stringify(n))}catch{}return!0}function jp(e,t,n=Date.now()){return _p({enabled:xp(),seen:!1,timestamp:t,now:n,maxAgeMs:yp})?Ap(e):!1}var Mp=(0,g.memo)(function({args:e,details:t,toolCallId:n,resultTimestamp:r}){let i=Z(),a=Op(),o=(0,g.useMemo)(()=>lp(e,t),[e,t]),s=up(e,t),c=dp(e,t),l=(0,g.useMemo)(()=>gp(o),[o]);return(0,g.useEffect)(()=>{a&&l&&n&&(uf()||jp(n,r)&&df({path:l.target,name:l.name}))},[a,l,n,r]),o.length===0?(0,X.jsx)(`div`,{className:`present-empty`,children:i(`presentEmpty`)}):(0,X.jsxs)(`div`,{className:`present-card`,children:[s&&(0,X.jsx)(`div`,{className:`present-title`,children:s}),c&&(0,X.jsx)(`div`,{className:`present-note`,children:(0,X.jsx)(_f,{text:c,rawHtml:!0})}),(0,X.jsx)(`div`,{className:`present-items`,children:o.map(e=>(0,X.jsx)(Pp,{item:e},`${e.target}\u0000${e.path}`))})]})});function Np(e){return typeof e.mtime==`number`?`${e.path}\n${new Date(e.mtime).toLocaleString()}`:e.path}function Pp({item:e}){let t=Z(),{copied:n,copy:r}=Pu({duration:1200}),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(``),c=i?null:fp(e.kind),l=hp(e.size),u=e.kind===`missing`,d={path:e.target,name:e.name};return(0,X.jsxs)(`div`,{className:`present-item${u?` missing`:``}`,children:[(0,X.jsxs)(`div`,{className:`present-item-head`,children:[(0,X.jsx)(`span`,{className:`present-item-icon`,"aria-hidden":`true`,children:mp(e.kind)}),(0,X.jsx)(`span`,{className:`present-item-name`,title:Np(e),children:e.name}),e.caption&&(0,X.jsx)(`span`,{className:`present-item-caption`,children:e.caption}),l&&!u&&(0,X.jsx)(`span`,{className:`present-item-meta`,children:l}),(0,X.jsx)(`span`,{className:`present-item-spacer`}),!u&&(0,X.jsxs)(X.Fragment,{children:[pp(e.kind)&&(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`previewFile`),"aria-label":t(`previewFile`),onClick:()=>df(d),children:(0,X.jsx)(Ue,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`present-btn labeled`,title:t(`fileOpenDefault`),onClick:()=>$({type:`file_open_default`,path:e.target}),children:[(0,X.jsx)(Ge,{}),(0,X.jsx)(`span`,{children:t(`presentOpenLocal`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`fileReveal`),"aria-label":t(`fileReveal`),onClick:()=>$({type:`file_reveal`,path:e.target}),children:(0,X.jsx)(Re,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`downloadFile`),"aria-label":t(`downloadFile`),onClick:()=>{s(``),cu(e.target,e.name).then(e=>{e.ok||e.cancelled||s(e.error===`FILE_NOT_FOUND`?t(`fileNotFoundShort`):e.error)})},children:(0,X.jsx)(qe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn${n?` on`:``}`,title:t(`copyPath`),"aria-label":t(`copyPath`),onClick:()=>{r(e.path)},children:(0,X.jsx)(tt,{})})]})]}),u&&(0,X.jsx)(`div`,{className:`present-item-warn`,children:t(`presentMissing`)}),o&&(0,X.jsx)(`div`,{className:`present-item-warn`,children:t(`downloadFailed`,{error:o})}),c===`image`&&(0,X.jsx)(`button`,{type:`button`,className:`present-media`,title:t(`previewFile`),onClick:()=>df(d),children:(0,X.jsx)(`img`,{src:su(e.target,!1),alt:e.name,loading:`lazy`,onError:()=>a(!0)})}),c===`video`&&(0,X.jsx)(`video`,{className:`present-media-video`,src:su(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),c===`audio`&&(0,X.jsx)(`audio`,{className:`present-media-audio`,src:su(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),e.excerpt&&(0,X.jsxs)(`pre`,{className:`present-excerpt`,children:[e.excerpt,e.excerptTruncated?`…`:``]})]})}function Fp(e,t){let n=new Map,r=e?.answers;if(Array.isArray(r)){for(let e of r)e&&typeof e.id==`string`&&n.set(e.id,{id:e.id,selected:Array.isArray(e.selected)?e.selected:[],custom:typeof e.custom==`string`?e.custom:void 0});if(n.size>0)return n}if(t&&!t.includes(`User cancelled`)){let e=t.split(`
337
- `).filter(e=>e.trim());for(let t of e){let e=t.indexOf(`:`);if(e===-1)continue;let r=t.slice(0,e).trim(),i=t.slice(e+1).trim(),a=[],o,s=/\s*\(wrote:\s*(.*?)\)$/i.exec(i),c=i;s&&(o=s[1],c=i.slice(0,s.index).trim()),c&&c!==`(no selection)`&&(a=c.split(`,`).map(e=>e.trim()).filter(Boolean)),n.set(r,{id:r,selected:a,custom:o})}}return n}function Ip(e){if(!e)return;let t=/(?:User note \/ 附言|附言)[::]\s*([^\n\r]+)/.exec(e);return t?t[1].trim():void 0}var Lp=(0,g.memo)(function({questions:e,details:t,output:n,isError:r=!1,waiting:i=!1}){let a=Z(),o=(0,g.useMemo)(()=>Fp(t,n),[t,n]),s=(0,g.useMemo)(()=>r?Ip(n):void 0,[r,n]);return(0,X.jsxs)(`div`,{className:`qcard-wrap`,children:[r&&(0,X.jsxs)(`div`,{className:`qcard-status qcard-status-cancelled`,children:[(0,X.jsx)(`span`,{className:`qcard-status-icon`,children:(0,X.jsx)(P,{})}),(0,X.jsx)(`span`,{className:`qcard-status-text`,children:a(`questionCardCancelled`)}),s&&(0,X.jsxs)(`div`,{className:`qcard-reject-reason`,children:[(0,X.jsx)($e,{className:`qcard-note-icon`}),(0,X.jsxs)(`span`,{children:[(0,X.jsxs)(`strong`,{children:[a(`questionCardRejectReason`),`:`]}),` `,s]})]})]}),i&&!r&&(0,X.jsxs)(`div`,{className:`qcard-status qcard-status-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),(0,X.jsx)(`span`,{className:`qcard-status-text`,children:a(`questionCardWaiting`)})]}),(0,X.jsx)(`div`,{className:`qcard-items`,children:e.map((e,t)=>{let n=o.get(e.id)??o.get(e.header??``),r=new Set(n?.selected??[]),i=n!==void 0,s=e.options??[];return(0,X.jsxs)(`div`,{className:`qcard-item`,children:[(0,X.jsxs)(`div`,{className:`qcard-header`,children:[(0,X.jsx)(`span`,{className:`qcard-idx`,children:t+1}),(0,X.jsx)(`span`,{className:`qcard-title`,children:e.header??`${a(`modelQuestion`)} ${t+1}`})]}),(0,X.jsx)(`div`,{className:`qcard-question`,children:(0,X.jsx)(_f,{text:e.question,rawHtml:!0})}),e.detail&&(0,X.jsx)(`div`,{className:`qcard-detail`,children:(0,X.jsx)(_f,{text:e.detail,rawHtml:!0})}),s.length>0&&(0,X.jsx)(`div`,{className:`qcard-options`,children:s.map((t,n)=>{let o=r.has(t.label),c=t.recommended??(n===0&&s.length>1);return(0,X.jsxs)(`div`,{className:`qcard-option${o?` selected`:``}${i&&!o?` dimmed`:``}`,children:[(0,X.jsx)(`span`,{className:`qcard-opt-mark`,children:e.multiSelect?o?(0,X.jsx)(ft,{className:`qcard-check-icon`}):`☐`:o?`●`:`○`}),(0,X.jsxs)(`div`,{className:`qcard-opt-content`,children:[(0,X.jsxs)(`div`,{className:`qcard-opt-label`,children:[(0,X.jsx)(_f,{text:t.label,rawHtml:!0}),c&&(0,X.jsx)(`span`,{className:`question-recommended-badge`,children:a(`recommended`)})]}),t.description&&(0,X.jsx)(`div`,{className:`qcard-opt-desc`,children:(0,X.jsx)(_f,{text:t.description,rawHtml:!0})})]})]},t.label)})}),i&&r.size===0&&!n.custom&&(0,X.jsx)(`div`,{className:`qcard-empty-sel`,children:a(`questionCardNoSelection`)}),n?.custom&&(0,X.jsxs)(`div`,{className:`qcard-custom-note`,children:[(0,X.jsx)(J,{className:`qcard-note-icon`}),(0,X.jsxs)(`span`,{className:`qcard-custom-label`,children:[a(`questionCardUserCustom`),`:`]}),(0,X.jsx)(`span`,{className:`qcard-custom-text`,children:n.custom})]})]},e.id)})})]})}),Rp={bash:`$`,delegate_task:`◈`,read:`📄`,write:`✍️`,edit:`✏️`,edit_soft:`✏️`,grep:`🔍`,find:`🧭`,ls:`📂`,codemode:`⚡`,tool_search:`🔎`,ask_user_question:`❓`,[Cr]:`🖼`};function zp(e){return Rp[e]??`🛠`}var Bp=(0,g.memo)(function({block:e,view:t,onKillBash:n,wrap:r=!0,showImages:i=!0,forceOpen:a=!1,uiContextToolCall:o,onUiAction:s}){let c=Z(),[l,u]=(0,g.useState)(null),d=e.name===Cr,f=l??(d?!0:r),p=f||a,{copied:m,copy:h}=Pu({duration:1200}),_=!t.result&&t.streaming&&!t.status,v=e.name===`bash`&&_,y=t.result!==void 0,b=!t.result&&!!t.status,x=t.result?.isError??t.status?.isError??!1,S=t.result?t.result.content.map(e=>e.type===`text`?e.text:``).join(``):t.liveOutput??``,C=S.replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(e,t)=>c(`liveOutputOmitted`,{n:t})),w=(0,g.useMemo)(()=>i?(t.result?.content??[]).filter(e=>e.type===`image`&&typeof e.dataUrl==`string`&&(e.dataUrl.startsWith(`data:`)||e.dataUrl.startsWith(`/`))):[],[i,t.result]),[T,E]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!T)return;let e=e=>{e.key===`Escape`&&E(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[T]);let D=e.name===`delegate_task`,O=D?Gf(e.argumentsText):{},k=e.name===`codemode`,A=(0,g.useMemo)(()=>k?Qf(e.argumentsText):null,[k,e.argumentsText]),ee=e.name===`ask_user_question`,M=(0,g.useMemo)(()=>ee?np(e.argumentsText):null,[ee,e.argumentsText]),te=(0,g.useMemo)(()=>d?cp(e.argumentsText):null,[d,e.argumentsText]),N=D&&t.result&&typeof t.result.details==`object`&&t.result.details!==null?t.result.details.convId:void 0,ne=typeof N==`string`&&N?N:/sa-[0-9a-f]{8}/.exec(S)?.[0],F=(0,g.useRef)(void 0),re=t.status?.durationMs,I=t.result?.durationMs;(0,g.useEffect)(()=>{re!==void 0&&(F.current=re),typeof I==`number`&&(F.current=I)},[re,I]);let L=typeof I==`number`?I:re??F.current,ie=x?`err`:y?`ok`:_||b?`run`:`idle`,R=c(x?`error`:y?`done`:_?`running`:b?`toolDoneWaitingModel`:`toolQueued`),z=(b||y)&&L!==void 0?Kp(L):``;(b||y)&&z&&(R=`${R} · ${z}`);let B=b&&t.status?.exitCode!==void 0?`exit ${t.status.exitCode}`:``,V=Hf(e.argumentsText),H=e.name===`bash`?V.command:void 0,ae=!p&&H?Gp(H):void 0,oe=()=>{e.argumentsText&&h(e.argumentsText)},se=(o??[]).some(e=>e&&e.hidden!==!0&&e.kind!==`divider`);return(0,X.jsxs)(`div`,{className:`toolcall ${ie}`,children:[(0,X.jsx)(Mf,{open:p,headClassName:`toolcall-head`,toggleClassName:`toolcall-toggle`,titleText:c(p?`collapseMsg`:`expandMsg`),onToggle:()=>u(!f),onHeadContextMenu:t=>{if(!se)return;let n=t.target;if(n instanceof Element&&n.closest(`pre, code, a, input, textarea, [contenteditable='true']`))return;let r=window.getSelection?.();r&&!r.isCollapsed&&r.toString().trim().length>0||(t.preventDefault(),t.stopPropagation(),fa({x:t.clientX,y:t.clientY,slot:`contextmenu.toolcall`,target:{id:e.id,kind:`toolcall`,label:e.name},entries:o??[],onHostAction:t=>{if(t.id===`host:tool-info`){ts(e.name);return}s?.(t)}}))},icon:zp(e.name),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`toolcall-status`,title:B?`${R} · ${B}`:R,"aria-label":B?`${R} · ${B}`:R,children:x?(0,X.jsx)(P,{}):y?(0,X.jsx)(ft,{}):_?(0,X.jsx)(Ee,{}):b?(0,X.jsx)(rt,{}):(0,X.jsx)(ye,{})}),z&&(0,X.jsx)(`span`,{className:`toolcall-duration toolcall-timeout`,style:{marginLeft:-2,fontFamily:`var(--mono)`},title:B?`${R} · ${B}`:R,children:z}),ae&&(0,X.jsxs)(`span`,{className:`toolcall-cmd`,title:H,children:[`$ `,ae]}),V.path&&(0,X.jsx)(`span`,{className:`toolcall-path`,title:V.path,children:Kf(V.path)}),V.codeLines&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,title:`${V.codeLines} lines`,children:[`λ `,V.codeLines,`L`]}),V.query&&e.name===`tool_search`&&(0,X.jsxs)(`span`,{className:`toolcall-query`,title:V.query,children:[`🔎 `,V.query]}),V.questionTitle&&ee&&(0,X.jsxs)(`span`,{className:`toolcall-query`,title:V.questionTitle,children:[`❓ `,V.questionTitle]}),V.timeout&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,children:[`⏱ `,V.timeout]}),D&&V.agent&&(0,X.jsxs)(`span`,{className:`toolcall-agent`,title:V.agent,children:[`◈ `,V.agent]}),(0,X.jsx)(`span`,{className:`toolcall-spacer`}),v&&n&&(0,X.jsxs)(`button`,{type:`button`,className:`toolcall-kill`,title:c(`stopBashTip`),onClick:e=>{e.stopPropagation(),n?.()},children:[(0,X.jsx)(U,{}),(0,X.jsx)(`span`,{children:c(`stopBash`)})]}),D&&y&&ne&&(0,X.jsxs)(`button`,{type:`button`,className:`toolcall-open`,title:c(`delegateOpenSubagent`),onClick:e=>{e.stopPropagation(),window.dispatchEvent(new CustomEvent(`pi-web-ui:switch-conversation`,{detail:ne}))},children:[(0,X.jsx)(bt,{}),(0,X.jsx)(`span`,{children:c(`delegateOpenSubagent`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy${m?` copied`:``}`,title:c(`copyArgs`),"aria-label":c(`copyArgs`),onClick:e=>{e.stopPropagation(),oe()},children:m?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})})]}),children:e.name}),w.length>0&&(0,X.jsx)(`div`,{className:`toolcall-images`,children:w.map((e,t)=>{let n=e.dataUrl.startsWith(`/`)?fn(e.dataUrl):e.dataUrl;return(0,X.jsx)(`button`,{type:`button`,className:`toolcall-image`,title:c(`toolImageZoom`),"aria-label":c(`toolImageZoom`),onClick:e=>{e.stopPropagation(),E(n)},children:(0,X.jsx)(`img`,{src:n,loading:`lazy`,decoding:`async`,alt:`tool result image ${t+1}`})},t)})}),T&&(0,j.createPortal)((0,X.jsxs)(`div`,{className:`img-lightbox`,role:`dialog`,"aria-label":c(`toolImageZoom`),onClick:()=>E(null),children:[(0,X.jsx)(`button`,{type:`button`,className:`img-lightbox-close`,title:c(`close`),"aria-label":c(`close`),onClick:e=>{e.stopPropagation(),E(null)},children:(0,X.jsx)(P,{})}),(0,X.jsx)(`img`,{src:T,alt:`tool result preview`})]}),document.body),p&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[d&&te?(0,X.jsx)(Mp,{args:te,details:t.result?.details,toolCallId:t.result?.toolCallId??e.id,resultTimestamp:t.result?.timestamp}):D?(0,X.jsx)(Up,{args:O}):k&&A?.code?(0,X.jsx)(Wp,{code:A.code,options:A.options,details:t.result?.details,output:C}):ee&&M?(0,X.jsx)(Lp,{questions:M.questions,details:t.result?.details,output:C,isError:x,waiting:_||b}):e.argumentsText&&(0,X.jsx)(`div`,{className:`toolcall-args`,children:H?(0,X.jsx)(Vp,{command:H}):(0,X.jsx)(`pre`,{children:e.argumentsText})}),e.name===`tool_search`&&(0,X.jsx)(Hp,{details:t.result?.details}),C.length>0&&!(ee&&M)&&(0,X.jsxs)(`div`,{className:`toolcall-output`,children:[(0,X.jsxs)(`div`,{className:`toolcall-output-label`,children:[c(x?`errorOutput`:`output`),(_||b)&&(0,X.jsx)(`span`,{className:`cursor`})]}),(0,X.jsx)(`pre`,{children:C})]}),_&&C.length===0&&(0,X.jsxs)(`div`,{className:`toolcall-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,c(`waitingOutput`)]}),b&&C.length===0&&(0,X.jsxs)(`div`,{className:`toolcall-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,c(`waitingModel`)]})]})]})});function Vp({command:e}){return(0,X.jsxs)(`div`,{className:`termline`,children:[(0,X.jsx)(B,{className:`termline-icon`}),(0,X.jsx)(`code`,{children:td(e)})]})}function Hp({details:e}){let t=Z(),n=Array.isArray(e?.loaded)?e.loaded:[];return n.length===0?null:(0,X.jsxs)(`div`,{className:`tool-search-loaded-box`,children:[(0,X.jsxs)(`span`,{className:`tool-search-loaded-label`,children:[t(`toolSearchLoaded`),`:`]}),(0,X.jsx)(`div`,{className:`tool-search-tags`,children:n.map(e=>(0,X.jsx)(`span`,{className:`tool-search-tag`,children:e},e))})]})}function Up({args:e}){let t=Z(),n=[{field:`task`,label:t(`delegateSecTask`)},{field:`expected_outcome`,label:t(`delegateSecExpected`)},{field:`required_tools`,label:t(`delegateSecTools`)},{field:`must_do`,label:t(`delegateSecMustDo`)},{field:`must_not_do`,label:t(`delegateSecMustNotDo`)},{field:`context`,label:t(`delegateSecContext`)}].filter(({field:t})=>e[t]?.trim());return n.length===0?null:(0,X.jsx)(`div`,{className:`delegate-brief`,children:n.map(({field:t,label:n})=>(0,X.jsxs)(`div`,{className:`delegate-sec`,children:[(0,X.jsx)(`div`,{className:`delegate-sec-label`,children:n}),(0,X.jsx)(`div`,{className:`delegate-sec-text`,children:e[t]})]},t))})}function Wp({code:e,options:t,details:n,output:r}){let i=Z(),a=n,o=Array.isArray(a?.calls)?a.calls:[],s=typeof a?.fullOutputPath==`string`?a.fullOutputPath:void 0,c=(0,g.useMemo)(()=>{if(!r)return[];let e=/\[Image saved to (.*?) \((.*?)\)\]/g,t=[],n;for(;(n=e.exec(r))!==null;)t.push({path:n[1],info:n[2]});return t},[r]);return(0,X.jsxs)(`div`,{className:`codemode-card`,children:[(0,X.jsxs)(`div`,{className:`codemode-sec`,children:[(0,X.jsxs)(`div`,{className:`codemode-sec-head`,children:[(0,X.jsx)(`span`,{className:`codemode-sec-title`,children:i(`codemodeScript`)}),t&&Object.keys(t).length>0&&(0,X.jsx)(`span`,{className:`codemode-options-badge`,children:JSON.stringify(t)})]}),(0,X.jsx)(`pre`,{className:`codemode-code`,children:(0,X.jsx)(`code`,{children:e})})]}),o.length>0&&(0,X.jsxs)(`div`,{className:`codemode-sec codemode-calls-sec`,children:[(0,X.jsxs)(`div`,{className:`codemode-sec-head`,children:[(0,X.jsx)(`span`,{className:`codemode-sec-title`,children:i(`codemodeNestedCalls`)}),(0,X.jsx)(`span`,{className:`codemode-count-badge`,children:o.length})]}),(0,X.jsx)(`div`,{className:`codemode-calls-list`,children:o.map((e,t)=>(0,X.jsxs)(`div`,{className:`codemode-call-item status-${e.status}`,children:[(0,X.jsx)(`span`,{className:`codemode-call-status`,children:e.status===`ok`?`✓`:e.status===`error`?`✗`:e.status===`running`?`…`:`⊘`}),(0,X.jsx)(`span`,{className:`codemode-call-name`,children:e.name}),e.args&&(0,X.jsx)(`span`,{className:`codemode-call-args`,children:e.args}),typeof e.durationMs==`number`&&(0,X.jsx)(`span`,{className:`codemode-call-duration`,children:Kp(e.durationMs)}),e.error&&(0,X.jsx)(`div`,{className:`codemode-call-error`,children:e.error})]},e.id||t))})]}),c.length>0&&(0,X.jsxs)(`div`,{className:`codemode-sec codemode-images-sec`,children:[(0,X.jsxs)(`div`,{className:`codemode-sec-head`,children:[(0,X.jsx)(`span`,{className:`codemode-sec-title`,children:i(`codemodeSavedImages`)}),(0,X.jsx)(`span`,{className:`codemode-count-badge`,children:c.length})]}),(0,X.jsx)(`div`,{className:`codemode-images-list`,children:c.map((e,t)=>(0,X.jsxs)(`div`,{className:`codemode-image-item`,children:[(0,X.jsx)(Me,{className:`codemode-image-icon`}),(0,X.jsx)(`code`,{className:`codemode-image-path`,title:e.path,children:e.path}),(0,X.jsx)(`span`,{className:`codemode-image-info`,children:e.info}),(0,X.jsx)(`button`,{type:`button`,className:`btn-ghost codemode-image-copy`,title:i(`copy`),onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.path)},children:(0,X.jsx)(tt,{})})]},t))})]}),s&&(0,X.jsxs)(`div`,{className:`codemode-full-output`,children:[(0,X.jsxs)(`span`,{className:`codemode-sec-title`,children:[i(`codemodeFullOutput`),`:`]}),(0,X.jsx)(`code`,{children:s})]})]})}function Gp(e){let t=e.split(`
338
- `),n=t[0].replace(/\s+/g,` `).trim();if(!n)return;let r=t.length-1,i=n.length>80?`${n.slice(0,80)}…`:n;return r>0?`${i} +${r}`:i}function Kp(e){if(e===void 0||e<0||!Number.isFinite(e))return``;if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`${n}m ${String(r).padStart(2,`0`)}s`}var qp=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function Jp(e){let t=e.match(qp);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}var Yp=1568,Xp=2097152;function Zp(e){return e.startsWith(`image/`)&&e!==`image/svg+xml`&&e!==`image/svg`}async function Qp(e){if(!e.type.startsWith(`image/`))return null;let t;try{t=await createImageBitmap(e,{imageOrientation:`from-image`})}catch{return null}try{let n=Math.min(1,Yp/Math.max(t.width,t.height)),r=Math.max(1,Math.round(t.width*n)),i=Math.max(1,Math.round(t.height*n)),a=e.type===`image/jpeg`||e.type===`image/jpg`?[[`image/jpeg`,.85],[`image/jpeg`,.6],[`image/webp`,.8]]:[[`image/png`,1],[`image/jpeg`,.85],[`image/jpeg`,.6]],o=null;for(let[n,s]of a){let a=document.createElement(`canvas`);a.width=r,a.height=i;let c=a.getContext(`2d`);if(!c)continue;n!==`image/png`&&(c.fillStyle=`#ffffff`,c.fillRect(0,0,r,i)),c.drawImage(t,0,0,r,i);let l=a.toDataURL(n,s),u=l.match(/^data:([^;]+);base64,/),d=u?u[1]:n,f=l.replace(/^data:[^;]*;base64,/,``),p=Math.floor(f.length*3/4);if(o={data:f,mimeType:d,name:e.name,size:p},p<=Xp)return o}return o}finally{t.close()}}function $p(e){let t=[];for(let n of e)n?.type===`text`&&typeof n.text==`string`&&n.text.length>0&&t.push(n.text);return t}function em(e){return $p(e).join(`
339
-
340
- `)}function tm(e){return nm(em(e))}function nm(e){let t=e.split(`
333
+ `),inFence:i!==null}}var Vf=(0,g.memo)(function({text:e}){return(0,X.jsx)(kf,{text:e})}),Hf=200;function Uf({text:e,inFence:t}){let[n,r]=(0,g.useState)(e),i=(0,g.useRef)(0),a=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(t)return;let n=Date.now()-i.current,o=()=>{i.current=Date.now(),r(e)};if(n>=Hf){o();return}return a.current=setTimeout(o,Hf-n),()=>{a.current&&clearTimeout(a.current)}},[e,t]),t?(0,X.jsx)(`div`,{className:`codeblock`,children:(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:e})})}):(0,X.jsx)(kf,{text:n})}var Wf=(0,g.memo)(function({text:e}){let{frozen:t,active:n,inFence:r}=(0,g.useMemo)(()=>Bf(e),[e]);return(0,X.jsxs)(`div`,{className:`md`,children:[t.map((e,t)=>(0,X.jsx)(Vf,{text:e},t)),n.length>0&&(0,X.jsx)(Uf,{text:n,inFence:r},t.length)]})});function Gf({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,X.jsxs)(`div`,{className:`chead ${n}`,role:`button`,tabIndex:0,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())},children:[c===void 0?(0,X.jsx)(`button`,{type:`button`,className:s?`chead-toggle ${s}`:`chead-toggle`,title:r,"aria-label":r,"aria-expanded":e,onClick:e=>{e.stopPropagation(),t()},children:e?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}):c,(0,X.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,X.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u}),d]})}function Kf(e,t){return t?e.trimEnd().slice(-80):e.split(`
334
+ `)[0].slice(0,80)}function qf({thinking:e,streaming:t,wrap:n=!0,forceOpen:r=!1}){let i=Z(),[a,o]=(0,g.useState)(null),s=a??n,c=s||r,l=Kf(e,t),{copied:u,copy:d}=qu({duration:1200}),f=()=>{d(e)};return(0,X.jsxs)(`div`,{className:`thinking ${c?`open`:``} ${t?`live`:``}`,children:[(0,X.jsx)(Gf,{open:c,headClassName:`thinking-head`,toggleClassName:`thinking-toggle`,titleText:i(c?`collapseMsg`:`expandMsg`),onToggle:()=>o(!s),icon:(0,X.jsx)(Ze,{}),iconClassName:`thinking-icon`,titleClassName:`thinking-label`,after:(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy thinking-copy${u?` copied`:``}`,title:i(u?`copied`:`copyMessage`),"aria-label":i(`copyMessage`),onClick:e=>{e.stopPropagation(),f()},children:u?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})})}),children:t&&c?(0,X.jsxs)(`span`,{className:`thinking-live-label`,children:[i(`thinkingNow`),(0,X.jsx)(`span`,{className:`dots`})]}):c?i(`thinking`):i(`thinkingPreview`,{preview:l})}),c&&(0,X.jsx)(`div`,{className:`thinking-body`,children:e})]})}var Jf=262144,Yf=300,Xf=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,Zf=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,Qf=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,$f=/"(query|q|search)"\s*:\s*"((?:[^"\\\n]|\\.){0,400})"/,ep=1e9;function tp(e){if(!e)return{};let t=e.length>Jf?e.slice(0,Jf):e;return{path:op(t),timeout:sp(t),command:lp(e),agent:np(t),codeLines:fp(e),query:cp(t),questionTitle:mp(t)}}function np(e){let t=Zf.exec(e);if(!t)return;let n=t[1].replace(/[\u0000-\u001f\u007f]/g,``).trim();if(n)return n.length>Yf?`${n.slice(0,Yf)}…`:n}var rp=[`task`,`expected_outcome`,`required_tools`,`must_do`,`must_not_do`,`context`];function ip(e){if(!e||e.length>Jf)return{};try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n=t,r={};for(let e of[...rp,`agent`,`model`])typeof n[e]==`string`&&n[e].trim()&&(r[e]=n[e]);return r}catch{return{}}}function ap(e,t=56){if(e.length<=t)return e;let n=e.split(/[\\/]+/).filter(Boolean),r=n[n.length-1];if(!r||n.length<=1)return`…${e.slice(-(t-1))}`;let i=r;for(let e=n.length-2;e>=0;e--){let r=`${n[e]}/${i}`;if(r.length+2>t)break;i=r}return`…/${i}`}function op(e){let t=Xf.exec(e);if(!t)return;let n=up(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>Yf?`${n.slice(0,299)}…`:n}function sp(e){let t=Qf.exec(e);if(!t)return;let n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>ep)return;let r=t[1].toLowerCase();return!r.endsWith(`ms`)&&!r.endsWith(`milliseconds`)?`${n}s`:n<1e3?`${n}ms`:`${Math.round(n/100)/10}s`}function cp(e){let t=$f.exec(e);if(!t)return;let n=up(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>60?`${n.slice(0,57)}…`:n}function lp(e){if(!(e.length>Jf))try{let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?void 0:typeof t.command==`string`&&t.command.trim()?t.command:void 0}catch{return}}function up(e){try{let t=JSON.parse(`"${e}"`);return typeof t==`string`?t:e}catch{return e}}function dp(e){if(!e)return{};let t,n=e.trim();if(n.startsWith(`{`))try{let e=JSON.parse(n);typeof e?.code==`string`&&(t=e.code)}catch{let e=/"code"\s*:\s*"((?:[^"\\]|\\.)*)/.exec(n);e&&(t=up(e[1]))}else n&&(t=e);if(!t)return{};let r=t.indexOf(`
335
+ `),i=r===-1?t.trim():t.slice(0,r).trim(),a;if(i.startsWith(`// @options:`))try{a=JSON.parse(i.slice(12).trim())}catch{}return{code:t,options:a}}function fp(e){let t=dp(e);if(!t.code)return;let n=t.code.split(`
336
+ `).length;return n>0?n:void 0}var pp=/"(?:header|question)"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/;function mp(e){let t=pp.exec(e);if(!t)return;let n=up(t[1]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>40?`${n.slice(0,38)}…`:n}function hp(e){if(!e||e.length>Jf)return null;try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.questions;return Array.isArray(n)&&n.length>0?{questions:n}:null}catch{return null}}var gp=new Set([`image`,`video`,`audio`,`markdown`,`html`,`pdf`,`text`,`binary`,`dir`,`missing`]);function _p(e){let t=String(e??``).trim().replace(/\\/g,`/`);return t.length>1?t.replace(/\/+$/,``):t}function vp(e){let t=_p(e).split(`/`);return(t[t.length-1]??``)||String(e??``)}function yp(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function bp(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function xp(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=yp(t);if(!n)return null;let r=Array.isArray(n.items)?n.items:[],i=[];for(let e of r){if(typeof e==`string`){let t=e.trim();t&&i.push({path:t});continue}let t=yp(e),n=t?bp(t.path):void 0;if(!n)continue;let r={path:n},a=bp(t?.caption);a&&(r.caption=a),t?.focus===!0&&(r.focus=!0),i.push(r)}if(i.length===0)return null;let a={items:i},o=bp(n.title);o&&(a.title=o);let s=bp(n.note);return s&&(a.note=s),a}function Sp(e,t){let n=yp(t),r=Array.isArray(n?.items)?n.items.map(yp):[],i=new Map;for(let e of r){if(!e)continue;let t=_p(String(e.path??e.abs??``));t&&!i.has(t)&&i.set(t,e)}return e.items.map((e,t)=>{let n=i.get(_p(e.path))??r[t]??null,a=bp(n?.kind),o={path:e.path,target:bp(n?.abs)??e.path,name:vp(bp(n?.name)??e.path),kind:a&&gp.has(a)?a:`unknown`,focus:e.focus===!0};e.caption&&(o.caption=e.caption),typeof n?.size==`number`&&Number.isFinite(n.size)&&(o.size=n.size),typeof n?.mtime==`number`&&Number.isFinite(n.mtime)&&(o.mtime=n.mtime);let s=bp(n?.excerpt);return s&&(o.excerpt=s),n?.excerptTruncated===!0&&(o.excerptTruncated=!0),o})}function Cp(e,t){return bp(yp(t)?.title)??e.title}function wp(e,t){return bp(yp(t)?.note)??e.note}function Tp(e){return e===`image`||e===`video`||e===`audio`?e:null}function Ep(e){return e!==`dir`&&e!==`missing`}function Dp(e){switch(e){case`image`:return`🖼`;case`video`:return`🎬`;case`audio`:return`🎵`;case`markdown`:return`📝`;case`html`:return`🌐`;case`pdf`:return`📕`;case`text`:return`📄`;case`dir`:return`📁`;case`missing`:return`⚠`;default:return`📦`}}function Op(e){if(!(e===void 0||!Number.isFinite(e)||e<0))return e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(+(e<10240))} KB`:e<1073741824?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function kp(e){return e.find(e=>e.focus&&Ep(e.kind))}function Ap(e){if(!e.enabled||e.seen||typeof e.timestamp!=`number`||!Number.isFinite(e.timestamp))return!1;let t=e.now-e.timestamp;return t>=0&&t<=e.maxAgeMs}var jp=`pi-web-ui:present-auto-open`,Mp=3e4,Np=`pi-web-ui:present-auto-opened`;function Pp(){try{return localStorage.getItem(jp)===`1`}catch{return!1}}function Fp(e){try{localStorage.setItem(jp,e?`1`:`0`)}catch{}zp=e,Lp()}var Ip=new Set;function Lp(){for(let e of Ip)e()}function Rp(e){return Ip.add(e),()=>{Ip.delete(e)}}var zp=null;function Bp(){return zp===null&&(zp=Pp()),zp}function Vp(){return(0,g.useSyncExternalStore)(Rp,Bp)}function Hp(){try{let e=sessionStorage.getItem(Np);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Up(e){if(!e)return!1;let t=Hp();if(t.includes(e))return!1;let n=[...t,e].slice(-200);try{sessionStorage.setItem(Np,JSON.stringify(n))}catch{}return!0}function Wp(e,t,n=Date.now()){return Ap({enabled:Pp(),seen:!1,timestamp:t,now:n,maxAgeMs:Mp})?Up(e):!1}var Gp=(0,g.memo)(function({args:e,details:t,toolCallId:n,resultTimestamp:r}){let i=Z(),a=Vp(),o=(0,g.useMemo)(()=>Sp(e,t),[e,t]),s=Cp(e,t),c=wp(e,t),l=(0,g.useMemo)(()=>kp(o),[o]);return(0,g.useEffect)(()=>{a&&l&&n&&(Cf()||Wp(n,r)&&wf({path:l.target,name:l.name}))},[a,l,n,r]),o.length===0?(0,X.jsx)(`div`,{className:`present-empty`,children:i(`presentEmpty`)}):(0,X.jsxs)(`div`,{className:`present-card`,children:[s&&(0,X.jsx)(`div`,{className:`present-title`,children:s}),c&&(0,X.jsx)(`div`,{className:`present-note`,children:(0,X.jsx)(Af,{text:c,rawHtml:!0})}),(0,X.jsx)(`div`,{className:`present-items`,children:o.map(e=>(0,X.jsx)(qp,{item:e},`${e.target}\u0000${e.path}`))})]})});function Kp(e){return typeof e.mtime==`number`?`${e.path}\n${new Date(e.mtime).toLocaleString()}`:e.path}function qp({item:e}){let t=Z(),{copied:n,copy:r}=qu({duration:1200}),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(``),c=i?null:Tp(e.kind),l=Op(e.size),u=e.kind===`missing`,d={path:e.target,name:e.name};return(0,X.jsxs)(`div`,{className:`present-item${u?` missing`:``}`,children:[(0,X.jsxs)(`div`,{className:`present-item-head`,children:[(0,X.jsx)(`span`,{className:`present-item-icon`,"aria-hidden":`true`,children:Dp(e.kind)}),(0,X.jsx)(`span`,{className:`present-item-name`,title:Kp(e),children:e.name}),e.caption&&(0,X.jsx)(`span`,{className:`present-item-caption`,children:e.caption}),l&&!u&&(0,X.jsx)(`span`,{className:`present-item-meta`,children:l}),(0,X.jsx)(`span`,{className:`present-item-spacer`}),!u&&(0,X.jsxs)(X.Fragment,{children:[Ep(e.kind)&&(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`previewFile`),"aria-label":t(`previewFile`),onClick:()=>wf(d),children:(0,X.jsx)(Ue,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`present-btn labeled`,title:t(`fileOpenDefault`),onClick:()=>$({type:`file_open_default`,path:e.target}),children:[(0,X.jsx)(Ge,{}),(0,X.jsx)(`span`,{children:t(`presentOpenLocal`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`fileReveal`),"aria-label":t(`fileReveal`),onClick:()=>$({type:`file_reveal`,path:e.target}),children:(0,X.jsx)(Re,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`downloadFile`),"aria-label":t(`downloadFile`),onClick:()=>{s(``),xu(e.target,e.name).then(e=>{e.ok||e.cancelled||s(e.error===`FILE_NOT_FOUND`?t(`fileNotFoundShort`):e.error)})},children:(0,X.jsx)(qe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn${n?` on`:``}`,title:t(`copyPath`),"aria-label":t(`copyPath`),onClick:()=>{r(e.path)},children:(0,X.jsx)(tt,{})})]})]}),u&&(0,X.jsx)(`div`,{className:`present-item-warn`,children:t(`presentMissing`)}),o&&(0,X.jsx)(`div`,{className:`present-item-warn`,children:t(`downloadFailed`,{error:o})}),c===`image`&&(0,X.jsx)(`button`,{type:`button`,className:`present-media`,title:t(`previewFile`),onClick:()=>wf(d),children:(0,X.jsx)(`img`,{src:bu(e.target,!1),alt:e.name,loading:`lazy`,onError:()=>a(!0)})}),c===`video`&&(0,X.jsx)(`video`,{className:`present-media-video`,src:bu(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),c===`audio`&&(0,X.jsx)(`audio`,{className:`present-media-audio`,src:bu(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),e.excerpt&&(0,X.jsxs)(`pre`,{className:`present-excerpt`,children:[e.excerpt,e.excerptTruncated?`…`:``]})]})}function Jp(e,t){let n=new Map,r=e?.answers;if(Array.isArray(r)){for(let e of r)e&&typeof e.id==`string`&&n.set(e.id,{id:e.id,selected:Array.isArray(e.selected)?e.selected:[],custom:typeof e.custom==`string`?e.custom:void 0});if(n.size>0)return n}if(t&&!t.includes(`User cancelled`)){let e=t.split(`
337
+ `).filter(e=>e.trim());for(let t of e){let e=t.indexOf(`:`);if(e===-1)continue;let r=t.slice(0,e).trim(),i=t.slice(e+1).trim(),a=[],o,s=/\s*\(wrote:\s*(.*?)\)$/i.exec(i),c=i;s&&(o=s[1],c=i.slice(0,s.index).trim()),c&&c!==`(no selection)`&&(a=c.split(`,`).map(e=>e.trim()).filter(Boolean)),n.set(r,{id:r,selected:a,custom:o})}}return n}function Yp(e){if(!e)return;let t=/(?:User note \/ 附言|附言)[::]\s*([^\n\r]+)/.exec(e);return t?t[1].trim():void 0}var Xp=(0,g.memo)(function({questions:e,details:t,output:n,isError:r=!1,waiting:i=!1}){let a=Z(),o=(0,g.useMemo)(()=>Jp(t,n),[t,n]),s=(0,g.useMemo)(()=>r?Yp(n):void 0,[r,n]);return(0,X.jsxs)(`div`,{className:`qcard-wrap`,children:[r&&(0,X.jsxs)(`div`,{className:`qcard-status qcard-status-cancelled`,children:[(0,X.jsx)(`span`,{className:`qcard-status-icon`,children:(0,X.jsx)(P,{})}),(0,X.jsx)(`span`,{className:`qcard-status-text`,children:a(`questionCardCancelled`)}),s&&(0,X.jsxs)(`div`,{className:`qcard-reject-reason`,children:[(0,X.jsx)($e,{className:`qcard-note-icon`}),(0,X.jsxs)(`span`,{children:[(0,X.jsxs)(`strong`,{children:[a(`questionCardRejectReason`),`:`]}),` `,s]})]})]}),i&&!r&&(0,X.jsxs)(`div`,{className:`qcard-status qcard-status-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),(0,X.jsx)(`span`,{className:`qcard-status-text`,children:a(`questionCardWaiting`)})]}),(0,X.jsx)(`div`,{className:`qcard-items`,children:e.map((e,t)=>{let n=o.get(e.id)??o.get(e.header??``),r=new Set(n?.selected??[]),i=n!==void 0,s=e.options??[];return(0,X.jsxs)(`div`,{className:`qcard-item`,children:[(0,X.jsxs)(`div`,{className:`qcard-header`,children:[(0,X.jsx)(`span`,{className:`qcard-idx`,children:t+1}),(0,X.jsx)(`span`,{className:`qcard-title`,children:e.header??`${a(`modelQuestion`)} ${t+1}`})]}),(0,X.jsx)(`div`,{className:`qcard-question`,children:(0,X.jsx)(Af,{text:e.question,rawHtml:!0})}),e.detail&&(0,X.jsx)(`div`,{className:`qcard-detail`,children:(0,X.jsx)(Af,{text:e.detail,rawHtml:!0})}),s.length>0&&(0,X.jsx)(`div`,{className:`qcard-options`,children:s.map((t,n)=>{let o=r.has(t.label),c=t.recommended??(n===0&&s.length>1);return(0,X.jsxs)(`div`,{className:`qcard-option${o?` selected`:``}${i&&!o?` dimmed`:``}`,children:[(0,X.jsx)(`span`,{className:`qcard-opt-mark`,children:e.multiSelect?o?(0,X.jsx)(ft,{className:`qcard-check-icon`}):`☐`:o?`●`:`○`}),(0,X.jsxs)(`div`,{className:`qcard-opt-content`,children:[(0,X.jsxs)(`div`,{className:`qcard-opt-label`,children:[(0,X.jsx)(Af,{text:t.label,rawHtml:!0}),c&&(0,X.jsx)(`span`,{className:`question-recommended-badge`,children:a(`recommended`)})]}),t.description&&(0,X.jsx)(`div`,{className:`qcard-opt-desc`,children:(0,X.jsx)(Af,{text:t.description,rawHtml:!0})})]})]},t.label)})}),i&&r.size===0&&!n.custom&&(0,X.jsx)(`div`,{className:`qcard-empty-sel`,children:a(`questionCardNoSelection`)}),n?.custom&&(0,X.jsxs)(`div`,{className:`qcard-custom-note`,children:[(0,X.jsx)(J,{className:`qcard-note-icon`}),(0,X.jsxs)(`span`,{className:`qcard-custom-label`,children:[a(`questionCardUserCustom`),`:`]}),(0,X.jsx)(`span`,{className:`qcard-custom-text`,children:n.custom})]})]},e.id)})})]})}),Zp={bash:`$`,delegate_task:`◈`,read:`📄`,write:`✍️`,edit:`✏️`,edit_soft:`✏️`,grep:`🔍`,find:`🧭`,ls:`📂`,codemode:`⚡`,tool_search:`🔎`,ask_user_question:`❓`,[Cr]:`🖼`};function Qp(e){return Zp[e]??`🛠`}var $p=(0,g.memo)(function({block:e,view:t,onKillBash:n,wrap:r=!0,showImages:i=!0,forceOpen:a=!1,uiContextToolCall:o,onUiAction:s}){let c=Z(),[l,u]=(0,g.useState)(null),d=e.name===Cr,f=l??(d?!0:r),p=f||a,{copied:m,copy:h}=qu({duration:1200}),_=!t.result&&t.streaming&&!t.status,v=e.name===`bash`&&_,y=t.result!==void 0,b=!t.result&&!!t.status,x=t.result?.isError??t.status?.isError??!1,S=t.result?t.result.content.map(e=>e.type===`text`?e.text:``).join(``):t.liveOutput??``,C=S.replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(e,t)=>c(`liveOutputOmitted`,{n:t})),w=(0,g.useMemo)(()=>i?(t.result?.content??[]).filter(e=>e.type===`image`&&typeof e.dataUrl==`string`&&(e.dataUrl.startsWith(`data:`)||e.dataUrl.startsWith(`/`))):[],[i,t.result]),[T,E]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!T)return;let e=e=>{e.key===`Escape`&&E(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[T]);let D=e.name===`delegate_task`,O=D?ip(e.argumentsText):{},k=e.name===`codemode`,A=(0,g.useMemo)(()=>k?dp(e.argumentsText):null,[k,e.argumentsText]),ee=e.name===`ask_user_question`,M=(0,g.useMemo)(()=>ee?hp(e.argumentsText):null,[ee,e.argumentsText]),te=(0,g.useMemo)(()=>d?xp(e.argumentsText):null,[d,e.argumentsText]),N=D&&t.result&&typeof t.result.details==`object`&&t.result.details!==null?t.result.details.convId:void 0,ne=typeof N==`string`&&N?N:/sa-[0-9a-f]{8}/.exec(S)?.[0],F=(0,g.useRef)(void 0),re=t.status?.durationMs,ie=t.result?.durationMs;(0,g.useEffect)(()=>{re!==void 0&&(F.current=re),typeof ie==`number`&&(F.current=ie)},[re,ie]);let ae=typeof ie==`number`?ie:re??F.current,I=x?`err`:y?`ok`:_||b?`run`:`idle`,L=c(x?`error`:y?`done`:_?`running`:b?`toolDoneWaitingModel`:`toolQueued`),R=(b||y)&&ae!==void 0?am(ae):``;(b||y)&&R&&(L=`${L} · ${R}`);let z=b&&t.status?.exitCode!==void 0?`exit ${t.status.exitCode}`:``,oe=tp(e.argumentsText),B=e.name===`bash`?oe.command:void 0,H=!p&&B?im(B):void 0,se=()=>{e.argumentsText&&h(e.argumentsText)},ce=(o??[]).some(e=>e&&e.hidden!==!0&&e.kind!==`divider`);return(0,X.jsxs)(`div`,{className:`toolcall ${I}`,children:[(0,X.jsx)(Gf,{open:p,headClassName:`toolcall-head`,toggleClassName:`toolcall-toggle`,titleText:c(p?`collapseMsg`:`expandMsg`),onToggle:()=>u(!f),onHeadContextMenu:t=>{if(!ce)return;let n=t.target;if(n instanceof Element&&n.closest(`pre, code, a, input, textarea, [contenteditable='true']`))return;let r=window.getSelection?.();r&&!r.isCollapsed&&r.toString().trim().length>0||(t.preventDefault(),t.stopPropagation(),Ea({x:t.clientX,y:t.clientY,slot:`contextmenu.toolcall`,target:{id:e.id,kind:`toolcall`,label:e.name},entries:o??[],onHostAction:t=>{if(t.id===`host:tool-info`){ms(e.name);return}s?.(t)}}))},icon:Qp(e.name),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`toolcall-status`,title:z?`${L} · ${z}`:L,"aria-label":z?`${L} · ${z}`:L,children:x?(0,X.jsx)(P,{}):y?(0,X.jsx)(ft,{}):_?(0,X.jsx)(Ee,{}):b?(0,X.jsx)(rt,{}):(0,X.jsx)(ye,{})}),R&&(0,X.jsx)(`span`,{className:`toolcall-duration toolcall-timeout`,style:{marginLeft:-2,fontFamily:`var(--mono)`},title:z?`${L} · ${z}`:L,children:R}),H&&(0,X.jsxs)(`span`,{className:`toolcall-cmd`,title:B,children:[`$ `,H]}),oe.path&&(0,X.jsx)(`span`,{className:`toolcall-path`,title:oe.path,children:ap(oe.path)}),oe.codeLines&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,title:`${oe.codeLines} lines`,children:[`λ `,oe.codeLines,`L`]}),oe.query&&e.name===`tool_search`&&(0,X.jsxs)(`span`,{className:`toolcall-query`,title:oe.query,children:[`🔎 `,oe.query]}),oe.questionTitle&&ee&&(0,X.jsxs)(`span`,{className:`toolcall-query`,title:oe.questionTitle,children:[`❓ `,oe.questionTitle]}),oe.timeout&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,children:[`⏱ `,oe.timeout]}),D&&oe.agent&&(0,X.jsxs)(`span`,{className:`toolcall-agent`,title:oe.agent,children:[`◈ `,oe.agent]}),(0,X.jsx)(`span`,{className:`toolcall-spacer`}),v&&n&&(0,X.jsxs)(`button`,{type:`button`,className:`toolcall-kill`,title:c(`stopBashTip`),onClick:e=>{e.stopPropagation(),n?.()},children:[(0,X.jsx)(V,{}),(0,X.jsx)(`span`,{children:c(`stopBash`)})]}),D&&y&&ne&&(0,X.jsxs)(`button`,{type:`button`,className:`toolcall-open`,title:c(`delegateOpenSubagent`),onClick:e=>{e.stopPropagation(),window.dispatchEvent(new CustomEvent(`pi-web-ui:switch-conversation`,{detail:ne}))},children:[(0,X.jsx)(bt,{}),(0,X.jsx)(`span`,{children:c(`delegateOpenSubagent`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy${m?` copied`:``}`,title:c(`copyArgs`),"aria-label":c(`copyArgs`),onClick:e=>{e.stopPropagation(),se()},children:m?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})})]}),children:e.name}),w.length>0&&(0,X.jsx)(`div`,{className:`toolcall-images`,children:w.map((e,t)=>{let n=e.dataUrl.startsWith(`/`)?fn(e.dataUrl):e.dataUrl;return(0,X.jsx)(`button`,{type:`button`,className:`toolcall-image`,title:c(`toolImageZoom`),"aria-label":c(`toolImageZoom`),onClick:e=>{e.stopPropagation(),E(n)},children:(0,X.jsx)(`img`,{src:n,loading:`lazy`,decoding:`async`,alt:`tool result image ${t+1}`})},t)})}),T&&(0,j.createPortal)((0,X.jsxs)(`div`,{className:`img-lightbox`,role:`dialog`,"aria-label":c(`toolImageZoom`),onClick:()=>E(null),children:[(0,X.jsx)(`button`,{type:`button`,className:`img-lightbox-close`,title:c(`close`),"aria-label":c(`close`),onClick:e=>{e.stopPropagation(),E(null)},children:(0,X.jsx)(P,{})}),(0,X.jsx)(`img`,{src:T,alt:`tool result preview`})]}),document.body),p&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[d&&te?(0,X.jsx)(Gp,{args:te,details:t.result?.details,toolCallId:t.result?.toolCallId??e.id,resultTimestamp:t.result?.timestamp}):D?(0,X.jsx)(nm,{args:O}):k&&A?.code?(0,X.jsx)(rm,{code:A.code,options:A.options,details:t.result?.details,output:C}):ee&&M?(0,X.jsx)(Xp,{questions:M.questions,details:t.result?.details,output:C,isError:x,waiting:_||b}):e.argumentsText&&(0,X.jsx)(`div`,{className:`toolcall-args`,children:B?(0,X.jsx)(em,{command:B}):(0,X.jsx)(`pre`,{children:e.argumentsText})}),e.name===`tool_search`&&(0,X.jsx)(tm,{details:t.result?.details}),C.length>0&&!(ee&&M)&&(0,X.jsxs)(`div`,{className:`toolcall-output`,children:[(0,X.jsxs)(`div`,{className:`toolcall-output-label`,children:[c(x?`errorOutput`:`output`),(_||b)&&(0,X.jsx)(`span`,{className:`cursor`})]}),(0,X.jsx)(`pre`,{children:C})]}),_&&C.length===0&&(0,X.jsxs)(`div`,{className:`toolcall-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,c(`waitingOutput`)]}),b&&C.length===0&&(0,X.jsxs)(`div`,{className:`toolcall-waiting`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,c(`waitingModel`)]})]})]})});function em({command:e}){return(0,X.jsxs)(`div`,{className:`termline`,children:[(0,X.jsx)(z,{className:`termline-icon`}),(0,X.jsx)(`code`,{children:md(e)})]})}function tm({details:e}){let t=Z(),n=Array.isArray(e?.loaded)?e.loaded:[];return n.length===0?null:(0,X.jsxs)(`div`,{className:`tool-search-loaded-box`,children:[(0,X.jsxs)(`span`,{className:`tool-search-loaded-label`,children:[t(`toolSearchLoaded`),`:`]}),(0,X.jsx)(`div`,{className:`tool-search-tags`,children:n.map(e=>(0,X.jsx)(`span`,{className:`tool-search-tag`,children:e},e))})]})}function nm({args:e}){let t=Z(),n=[{field:`task`,label:t(`delegateSecTask`)},{field:`expected_outcome`,label:t(`delegateSecExpected`)},{field:`required_tools`,label:t(`delegateSecTools`)},{field:`must_do`,label:t(`delegateSecMustDo`)},{field:`must_not_do`,label:t(`delegateSecMustNotDo`)},{field:`context`,label:t(`delegateSecContext`)}].filter(({field:t})=>e[t]?.trim());return n.length===0?null:(0,X.jsx)(`div`,{className:`delegate-brief`,children:n.map(({field:t,label:n})=>(0,X.jsxs)(`div`,{className:`delegate-sec`,children:[(0,X.jsx)(`div`,{className:`delegate-sec-label`,children:n}),(0,X.jsx)(`div`,{className:`delegate-sec-text`,children:e[t]})]},t))})}function rm({code:e,options:t,details:n,output:r}){let i=Z(),a=n,o=Array.isArray(a?.calls)?a.calls:[],s=typeof a?.fullOutputPath==`string`?a.fullOutputPath:void 0,c=(0,g.useMemo)(()=>{if(!r)return[];let e=/\[Image saved to (.*?) \((.*?)\)\]/g,t=[],n;for(;(n=e.exec(r))!==null;)t.push({path:n[1],info:n[2]});return t},[r]);return(0,X.jsxs)(`div`,{className:`codemode-card`,children:[(0,X.jsxs)(`div`,{className:`codemode-sec`,children:[(0,X.jsxs)(`div`,{className:`codemode-sec-head`,children:[(0,X.jsx)(`span`,{className:`codemode-sec-title`,children:i(`codemodeScript`)}),t&&Object.keys(t).length>0&&(0,X.jsx)(`span`,{className:`codemode-options-badge`,children:JSON.stringify(t)})]}),(0,X.jsx)(`pre`,{className:`codemode-code`,children:(0,X.jsx)(`code`,{children:e})})]}),o.length>0&&(0,X.jsxs)(`div`,{className:`codemode-sec codemode-calls-sec`,children:[(0,X.jsxs)(`div`,{className:`codemode-sec-head`,children:[(0,X.jsx)(`span`,{className:`codemode-sec-title`,children:i(`codemodeNestedCalls`)}),(0,X.jsx)(`span`,{className:`codemode-count-badge`,children:o.length})]}),(0,X.jsx)(`div`,{className:`codemode-calls-list`,children:o.map((e,t)=>(0,X.jsxs)(`div`,{className:`codemode-call-item status-${e.status}`,children:[(0,X.jsx)(`span`,{className:`codemode-call-status`,children:e.status===`ok`?`✓`:e.status===`error`?`✗`:e.status===`running`?`…`:`⊘`}),(0,X.jsx)(`span`,{className:`codemode-call-name`,children:e.name}),e.args&&(0,X.jsx)(`span`,{className:`codemode-call-args`,children:e.args}),typeof e.durationMs==`number`&&(0,X.jsx)(`span`,{className:`codemode-call-duration`,children:am(e.durationMs)}),e.error&&(0,X.jsx)(`div`,{className:`codemode-call-error`,children:e.error})]},e.id||t))})]}),c.length>0&&(0,X.jsxs)(`div`,{className:`codemode-sec codemode-images-sec`,children:[(0,X.jsxs)(`div`,{className:`codemode-sec-head`,children:[(0,X.jsx)(`span`,{className:`codemode-sec-title`,children:i(`codemodeSavedImages`)}),(0,X.jsx)(`span`,{className:`codemode-count-badge`,children:c.length})]}),(0,X.jsx)(`div`,{className:`codemode-images-list`,children:c.map((e,t)=>(0,X.jsxs)(`div`,{className:`codemode-image-item`,children:[(0,X.jsx)(Me,{className:`codemode-image-icon`}),(0,X.jsx)(`code`,{className:`codemode-image-path`,title:e.path,children:e.path}),(0,X.jsx)(`span`,{className:`codemode-image-info`,children:e.info}),(0,X.jsx)(`button`,{type:`button`,className:`btn-ghost codemode-image-copy`,title:i(`copy`),onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.path)},children:(0,X.jsx)(tt,{})})]},t))})]}),s&&(0,X.jsxs)(`div`,{className:`codemode-full-output`,children:[(0,X.jsxs)(`span`,{className:`codemode-sec-title`,children:[i(`codemodeFullOutput`),`:`]}),(0,X.jsx)(`code`,{children:s})]})]})}function im(e){let t=e.split(`
338
+ `),n=t[0].replace(/\s+/g,` `).trim();if(!n)return;let r=t.length-1,i=n.length>80?`${n.slice(0,80)}…`:n;return r>0?`${i} +${r}`:i}function am(e){if(e===void 0||e<0||!Number.isFinite(e))return``;if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`${n}m ${String(r).padStart(2,`0`)}s`}var om=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function sm(e){let t=e.match(om);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}var cm=1568,lm=2097152;function um(e){return e.startsWith(`image/`)&&e!==`image/svg+xml`&&e!==`image/svg`}async function dm(e){if(!e.type.startsWith(`image/`))return null;let t;try{t=await createImageBitmap(e,{imageOrientation:`from-image`})}catch{return null}try{let n=Math.min(1,cm/Math.max(t.width,t.height)),r=Math.max(1,Math.round(t.width*n)),i=Math.max(1,Math.round(t.height*n)),a=e.type===`image/jpeg`||e.type===`image/jpg`?[[`image/jpeg`,.85],[`image/jpeg`,.6],[`image/webp`,.8]]:[[`image/png`,1],[`image/jpeg`,.85],[`image/jpeg`,.6]],o=null;for(let[n,s]of a){let a=document.createElement(`canvas`);a.width=r,a.height=i;let c=a.getContext(`2d`);if(!c)continue;n!==`image/png`&&(c.fillStyle=`#ffffff`,c.fillRect(0,0,r,i)),c.drawImage(t,0,0,r,i);let l=a.toDataURL(n,s),u=l.match(/^data:([^;]+);base64,/),d=u?u[1]:n,f=l.replace(/^data:[^;]*;base64,/,``),p=Math.floor(f.length*3/4);if(o={data:f,mimeType:d,name:e.name,size:p},p<=lm)return o}return o}finally{t.close()}}function fm(e){let t=[];for(let n of e)n?.type===`text`&&typeof n.text==`string`&&n.text.length>0&&t.push(n.text);return t}function pm(e){return fm(e).join(`
339
+
340
+ `)}function mm(e){return hm(pm(e))}function hm(e){let t=e.split(`
341
341
  `),n=[],r=!1;for(let e of t){if(/^\s*```/.test(e)){r=!r;continue}if(r){n.push(e);continue}e=e.replace(/^\s{0,3}#{1,6}\s+/,``).replace(/^\s*(>\s*)+/,``).replace(/^\s*(?:[-*+]\s+|\d{1,9}[.)]\s+)/,``).replace(/^\s*\[[ xX]\]\s+/,``),!(/^\s*\|?\s*[:-]+\s*(\|\s*[:-]+\s*)*\|?\s*$/.test(e)&&/[-:]/.test(e))&&n.push(e)}return n.join(`
342
342
  `).replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/`([^`]*)`/g,`$1`).replace(/(\*\*|__)(.+?)\1/g,`$2`).replace(/(^|\W)\*([^*\n]+)\*(?=\W|$)/g,`$1$2`).replace(/(^|\W)_([^_\n]+)_(?=\W|$)/g,`$1$2`).replace(/~~(.+?)~~/g,`$1`).replace(/^\s*\|/gm,``).replace(/\|\s*$/gm,``).replace(/\|/g,` `).replace(/<[^>]+>/g,``).replace(/\s+#+\s*$/gm,``).split(`
343
343
  `).map(e=>e.replace(/[ \t]+/g,` `).replace(/^\s+|\s+$/g,``)).join(`
344
344
  `).replace(/\n{3,}/g,`
345
345
 
346
- `).trim()}function rm(e,t=1){return e==null||!Number.isFinite(e)?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(t)} KB`:e<1073741824?`${(e/1048576).toFixed(t)} MB`:`${(e/1073741824).toFixed(t)} GB`}function im(e){return e==null||!Number.isFinite(e)?``:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var am={open:!1,triggerId:``,selectedIds:[],includeTools:!1,includeThinking:!1},om=am,sm=[],cm=new Set;function lm(){for(let e of cm)e()}function um(e){return(e.role===`user`||e.role===`assistant`)&&em(e.content).length>0}function dm(e,t=sm){let n=new Map(t.map((e,t)=>[e.id,t]));return[...new Set(e)].filter(e=>n.has(e)).sort((e,t)=>(n.get(e)??0)-(n.get(t)??0))}function fm(e){if(sm=e,om.open){let e=dm(om.selectedIds,sm);e.join(`\0`)!==om.selectedIds.join(`\0`)&&(om={...om,selectedIds:e},lm())}}function pm(){return om}function mm(e){return cm.add(e),()=>{cm.delete(e)}}function hm(){return(0,g.useSyncExternalStore)(mm,pm,pm)}function gm(){om.open&&(om=am,lm())}function _m(e){let t=sm.find(t=>t.id===e);if(t&&um(t)){if(om.open){om={...om,selectedIds:dm([...om.selectedIds,e])},lm();return}om={open:!0,triggerId:e,selectedIds:[e],includeTools:!1,includeThinking:!1},lm()}}function vm(e){om.open&&(om={...om,includeTools:e.includeTools??om.includeTools,includeThinking:e.includeThinking??om.includeThinking},lm())}function ym(e){if(!om.open||!sm.filter(um).map(e=>e.id).includes(e))return;let t=om.selectedIds.includes(e)?om.selectedIds.filter(t=>t!==e):dm([...om.selectedIds,e]);om={...om,selectedIds:t},lm()}var bm=null,xm=new Set;function Sm(){for(let e of xm)e()}function Cm(e){bm=e,Sm()}function wm(){bm=null,Sm()}function Tm(e){bm&&($({type:`rollback_session`,messageId:bm.messageId,conversationId:bm.conversationId,restoreWorkspace:e}),bm=null,Sm())}function Em(){return(0,g.useSyncExternalStore)(e=>(xm.add(e),()=>xm.delete(e)),()=>bm)}var Dm=/^(This operation was aborted|Request aborted)$/;function Om(e){return e.stopReason===`aborted`||e.stopReason===`error`&&Dm.test((e.errorMessage??``).trim())}var km=20971520;function Am(e){return e.type===`text`&&typeof e.text==`string`?e:null}function jm(e){return e.type===`thinking`&&typeof e.thinking==`string`?e:null}function Mm(e){return e.type===`toolCall`&&typeof e.id==`string`&&typeof e.name==`string`?e:null}function Nm(e){return e.type===`image`&&typeof e.dataUrl==`string`?e:null}function Pm(e){return e.type===`bash`&&typeof e.command==`string`?e:null}function Fm(e){return e.imageData?`image`:e.uploadPath?`upload`:e.fileData?`file`:`path`}function Im(e,t){if(e.mode===`quote`&&e.quote)return e.quote.text;if(e.imageData)return t(`attachImage`,{name:e.name??`image`});if(e.uploadPath)return t(`attachFile`,{name:e.name??e.uploadPath});if(e.fileData)return t(`attachFile`,{name:e.name??`file`});let n=e.path.split(`/`).pop()??e.path;return e.mode===`lines`&&e.lines?t(`attachLines`,{path:n,start:e.lines.start,end:e.lines.end}):e.mode===`page`?t(`attachPage`,{name:e.name??e.path}):e.mode===`conversation`?t(`attachConversation`,{name:e.name??e.path}):e.mode===`reference`?t(`refOnly`,{path:n}):t(`attachContent`,{path:n})}var Lm={edit:(0,X.jsx)(Y,{}),copy:(0,X.jsx)(tt,{}),branch:(0,X.jsx)(Le,{}),text:(0,X.jsx)(Ve,{}),markdown:(0,X.jsx)(nt,{}),image:(0,X.jsx)(Me,{}),undo:(0,X.jsx)(G,{}),volume:(0,X.jsx)(ne,{}),refresh:(0,X.jsx)(K,{}),x:(0,X.jsx)(P,{})};function Rm(e){let t=(e??``).trim();return t?Lm[t.toLowerCase()]||(!/[\p{L}\p{N}]/u.test(t)&&t.length<=4?(0,X.jsx)(`span`,{className:`msg-action-glyph`,children:t}):(0,X.jsx)(N,{})):(0,X.jsx)(N,{})}function zm(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}var Bm=(0,g.memo)(function({message:e,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onEdit:o,onKillBash:s,onRetry:c,onCollapse:l,questionAttachments:u,qnIndex:d,qnActive:f,onJump:p,thinkingWrap:m,toolsWrap:h,toolImages:_,searchActive:v,autoExpand:y,uiMessageActions:b,uiContextMessage:x,uiContextToolCall:S,onUiAction:C,readOnly:w=!1}){let T=Z(),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(``),[A,j]=(0,g.useState)([]),[ee,M]=(0,g.useState)(!1),[te,N]=(0,g.useState)(null),F=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{F.current&&clearTimeout(F.current)},[]);let re=e=>{N(e),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>N(t=>t===e?null:t),4e3)};if(e.role===`toolResult`||e.role===`system`)return null;if(e.role===`compactionSummary`)return(0,X.jsx)(Um,{message:e,forceOpen:v,autoExpand:y});let I=e.role===`custom`&&e.customType===`file`,L=I&&e.details?.mode===`quote`?Yu(e.details.quote):null,ie=e.details?.quotes,R=e.role===`user`&&Array.isArray(ie)?ie.map(Yu).filter(e=>e!==null):[],z=e.content.map(e=>Am(e)?.text??``).filter(Boolean).join(`
347
- `),B=e.role===`user`?Jp(z):null,V=B?B.userMessage??`skill:${B.name}`:z.split(`
348
- `).join(` `).trim(),H=i&&a&&e.content.length===0,ae=!w&&e.role===`user`&&!i&&!H&&!!o,oe=async e=>{let t=[];for(let n of e){if(!Zp(n.type))continue;let e=await Qp(n);e&&t.push({path:``,imageData:e.data,mimeType:e.mimeType,name:e.name})}t.length>0&&j(e=>[...e,...t])},se=async e=>{if(e.size>km){re(T(`fileTooLarge`,{name:e.name,size:20}));return}let t;try{t=(await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(e)})).replace(/^data:[^;]*;base64,/,``)}catch{re(T(`fileLoadFailed`,{name:e.name}));return}j(n=>[...n,{path:``,fileData:t,name:e.name,size:e.size,mimeType:e.type||void 0}])},W=async e=>{let t=[];for(let n of e)Zp(n.type)?t.push(n):se(n);t.length>0&&await oe(t)},ce=()=>{let t=(B?`/skill:`+B.name+(B.userMessage?` `+B.userMessage:``):e.content.map(e=>Am(e)?.text??``).filter(Boolean).join(`
349
- `)).trim(),n=!!(u&&u.length>0);(t||n)&&o?.(e.id,t,n?u:void 0)},le=()=>{k(B?`/skill:${B.name}${B.userMessage?` ${B.userMessage}`:``}`:e.content.map(e=>Am(e)?.text??``).filter(Boolean).join(`
350
- `)),j(u??[]),D(!0)},ue=()=>{let t=O.trim();(t||A.some(e=>e.mode===`quote`&&Yu(e.quote)))&&(o?.(e.id,t,A.length>0?A:void 0),D(!1))},de=!b||b.some(e=>e?.id===`host:msg-copy`&&e.hidden!==!0),fe=(0,g.useRef)(null),[pe,G]=(0,g.useState)(null),me=hm(),he=(0,g.useRef)(0),ge=em(e.content),q=(e.role===`assistant`||e.role===`user`)&&ge.length>0&&!i,_e=async t=>{try{let n=!1;if(t===`host:msg-copy-text`)n=await Nu(tm(e.content));else if(t===`host:msg-copy-markdown`)n=await Nu(ge);else{_m(e.id);return}window.clearTimeout(he.current),G({id:t,ok:n}),he.current=window.setTimeout(()=>G(null),1600)}catch{window.clearTimeout(he.current),G({id:t,ok:!1}),he.current=window.setTimeout(()=>G(null),1600)}},ve=zm(tm(e.content),40)||qm(e.role,T),[ye,be]=(0,g.useState)(nn());(0,g.useEffect)(()=>an(be),[]);let xe=e.role===`assistant`&&tm(e.content).trim().length>0&&!i&&qt(),J=xe&&rn()===e.id,Se=()=>{if(J){sn();return}on(Yt(tm(e.content)),{...Gt(),enabled:!0},e.id)},[Ce,we]=(0,g.useState)(!1),Te=(0,g.useRef)(null);(0,g.useEffect)(()=>{if(!Ce)return;let e=e=>{Te.current&&!Te.current.contains(e.target)&&we(!1)},t=e=>{e.key===`Escape`&&we(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[Ce]);let Ee=e=>xe?(0,X.jsxs)(`button`,{type:`button`,className:`msg-action${J?` msg-action-speaking`:``}`,title:T(J?`stopSpeakingMsg`:`speakMsg`),"aria-label":T(J?`stopSpeakingMsg`:`speakMsg`),onClick:Se,children:[J?(0,X.jsx)(U,{}):(0,X.jsx)(ne,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(J?`stopSpeakingMsg`:`speakMsg`)})]},e):null,De=()=>ji.filter(e=>e.slot===`contextmenu.message`).map(e=>({id:e.id,slot:e.slot,source:`host`,label:T(e.labelKey),labelKey:e.labelKey,icon:e.icon,kind:e.kind,group:e.group,order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[]})),Oe=t=>{let n=t.target;if(n instanceof Element&&n.closest(`a, input, textarea, [contenteditable='true']`))return;let r=window.getSelection?.();if(r&&!r.isCollapsed&&r.toString().trim().length>0)return;let a=(x&&x.length>0?x:De()).map(t=>{if(t.source!==`host`)return t;switch(t.id){case`host:msg-ctx-copy-markdown`:case`host:msg-ctx-copy-text`:return q?t:{...t,hidden:!0};case`host:msg-ctx-copy-image`:return q&&!w?t:{...t,hidden:!0};case`host:msg-ctx-copy-link`:{let n=Vo(window.location.hash)?.sessionId;return!i&&n&&e.id?t:{...t,hidden:!0}}case`host:msg-ctx-reask`:case`host:msg-ctx-edit-reask`:return ae?t:{...t,hidden:!0};case`host:msg-ctx-fork`:case`host:msg-ctx-rollback`:return!w&&!i&&!E?t:{...t,hidden:!0};case`host:msg-ctx-speak`:return xe?J?{...t,label:T(`stopSpeakingMsg`),icon:`square`}:t:{...t,hidden:!0};default:return t}});Ca(a).length!==0&&(t.preventDefault(),fa({x:t.clientX,y:t.clientY,slot:`contextmenu.message`,target:{id:e.id,kind:`message`,label:ve},entries:a,onHostAction:t=>{switch(t.id){case`host:msg-ctx-copy-markdown`:_e(`host:msg-copy-markdown`);return;case`host:msg-ctx-copy-text`:_e(`host:msg-copy-text`);return;case`host:msg-ctx-copy-image`:_e(`host:msg-copy-image`);return;case`host:msg-ctx-copy-link`:{let t=Vo(window.location.hash)?.sessionId;t&&e.id&&Nu(Uo(window.location.href,{sessionId:t,messageId:e.id}));return}case`host:msg-ctx-reask`:ce();return;case`host:msg-ctx-edit-reask`:le();return;case`host:msg-ctx-fork`:$({type:`fork_session`,messageId:e.id,position:`before`});return;case`host:msg-ctx-rollback`:Cm({messageId:e.id});return;case`host:msg-ctx-speak`:Se();return;default:C?.(t);return}}}))},ke=(e,t)=>{if(!q)return null;let n=[{id:`host:msg-copy-markdown`,label:T(`copyMarkdown`),icon:(0,X.jsx)(nt,{})},{id:`host:msg-copy-text`,label:T(`copyText`),icon:(0,X.jsx)(Ve,{})},{id:`host:msg-copy-image`,label:T(`copyImage`),icon:(0,X.jsx)(Me,{})}].filter(e=>{if(!t)return!0;let n=t.find(t=>t.id===e.id);return!n||n.hidden!==!0});if(n.length===0)return null;let r=pe!==null,i=pe?.ok;return(0,X.jsxs)(`div`,{ref:Te,className:`msg-copy-group${Ce?` has-open-dropdown`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action msg-copy-main-btn${i?` msg-copy-success`:``}`,title:T(i?`copied`:r&&!i?`copyFailed`:`copyMarkdown`),"aria-label":T(`copyMarkdown`),onClick:()=>void _e(`host:msg-copy-markdown`),children:[i?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{}),(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(i?`copied`:`copy`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-action msg-copy-caret-btn${Ce?` active`:``}`,title:T(`copyMessage`),"aria-label":T(`copyMessage`),"aria-expanded":Ce,onClick:e=>{e.stopPropagation(),we(e=>!e)},children:(0,X.jsx)(dt,{className:`msg-copy-caret-icon${Ce?` open`:``}`})}),Ce&&(0,X.jsx)(`div`,{className:`msg-copy-dropdown`,role:`menu`,children:n.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`msg-copy-menu-item`,role:`menuitem`,onClick:()=>{we(!1),_e(e.id)},children:[e.icon,(0,X.jsx)(`span`,{children:e.label})]},e.id))})]},e)},Ae=()=>{if(!b){let e=ke(`fb-copy`),t=Ee(`fb-speak`);if(!ae&&!e&&!t)return null;let n=[];return ae&&n.push((0,X.jsxs)(g.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`reaskDirectlyTip`),"aria-label":T(`reaskDirectly`),onClick:ce,children:[(0,X.jsx)(K,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(`reaskDirectly`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`editReaskTip`),"aria-label":T(`editReask`),onClick:le,children:[(0,X.jsx)(Y,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(`editReask`)})]})]},`fb-reask`)),e&&n.push(e),t&&n.push(t),n}let t=[],n=!1;return b.forEach((r,a)=>{if(!r||r.hidden===!0||r.id===`host:msg-copy`)return;let o=`${r.id}#${a}`,s=r.label||r.id;if(r.id===`host:msg-copy-text`||r.id===`host:msg-copy-markdown`||r.id===`host:msg-copy-image`){if(!n){n=!0;let e=ke(`copy-dropdown`,b);e&&t.push(e)}return}if(r.id===`host:msg-speak`){let e=Ee(o);e&&t.push(e);return}if(r.id===`host:msg-reask`){if(!ae)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`reaskDirectlyTip`),"aria-label":s,onClick:ce,children:[Rm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-edit-reask`){if(!ae)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`editReaskTip`),onClick:le,children:[Rm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-fork`){if(i||E)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`forkSessionTip`),"aria-label":s,onClick:()=>$({type:`fork_session`,messageId:e.id,position:`before`}),children:[Rm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-rollback`){if(w||i||E)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`rollbackSessionTip`),"aria-label":s,onClick:()=>{Cm({messageId:e.id})},children:[Rm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.kind===`divider`){t.push((0,X.jsx)(`span`,{className:`msg-action-divider`,"aria-hidden":`true`},o));return}if(r.kind===`badge`){t.push((0,X.jsx)(`span`,{className:`msg-action-badge`,title:s,children:r.badge??s},o));return}if(r.kind===`select`&&r.options?.length){t.push((0,X.jsx)(`select`,{className:`msg-action msg-action-select`,title:s,"aria-label":s,value:r.options.some(e=>e.value===r.value)?r.value:r.options[0].value,onChange:e=>C?.(r,e.target.value),children:r.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},o));return}t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:s,"aria-label":s,onClick:()=>C?.(r),children:[Rm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s}),r.badge?(0,X.jsx)(`span`,{className:`msg-action-count`,children:r.badge}):null]},o))}),t.length===0?null:t},je=()=>{let e=Ae();return e?(0,X.jsx)(`div`,{className:`msg-actions${Ce?` has-open-dropdown`:``}`,children:e}):null},Ne=e.role===`custom`&&(e.customType===`goal-review`||e.customType===`goal-wizard`),Pe=e.role===`custom`&&e.customType===`goal-wizard`,Fe=e.role===`custom`&&!!e.customType&&e.customType!==`file`&&!Ne&&qd(e.customType),Ie=Fe?JSON.stringify({customType:e.customType,details:e.details??{}}):``,Le=me.open&&me.selectedIds.includes(e.id),Re=me.open&&q,ze=Le&&me.includeThinking,Be=Le&&me.includeTools,He=!E&&(e.role===`user`||q),Ue=(0,g.useMemo)(()=>{if(e.role!==`assistant`)return-1;for(let t=e.content.length-1;t>=0;t--)if(Am(e.content[t]))return t;return-1},[e.role,e.content]);return(0,X.jsxs)(`div`,{ref:fe,className:`msg msg-${e.role}${Ne?` msg-goal-review`:``}${Le?` msg-export-selected`:``}${w?` msg-readonly`:``}`,"data-role":e.role,"data-msg-id":e.id,onContextMenu:Oe,children:[Re&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:Le,title:T(`copyImage`),"aria-label":T(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>ym(e.id)}),(0,X.jsxs)(`div`,{className:`msg-meta`,children:[l&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-collapse-btn`,title:T(`collapseMsg`),onClick:()=>l(e.id),children:[(0,X.jsx)(ct,{}),` `,T(`collapseMsg`)]}),(0,X.jsx)(`span`,{className:`msg-role`,children:e.role===`custom`?Pe?T(`goalWizardCard`):Ne?T(`goalBarTitle`):e.customType===`file`?T(`attachment`):`${T(`plugin`)} · ${e.customType??T(`unknown`)}`:qm(e.role,T)}),e.model&&(0,X.jsx)(`span`,{className:`msg-model`,children:e.model}),e.timestamp&&(0,X.jsx)(`span`,{className:`msg-time`,children:Jm(e.timestamp)}),d!==void 0&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`qn-tag ${f?`active`:``}`,title:`${d+1}. ${V}`,"aria-label":`${d+1}. ${V}`,onClick:()=>p(e.id),children:[(0,X.jsx)(`span`,{className:`qn-tag-bar`}),(0,X.jsx)(`span`,{className:`qn-tag-idx`,children:d+1})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:E?(0,X.jsxs)(`div`,{className:`msg-editor${ee?` drag-over`:``}`,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),M(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||M(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),M(!1),W(Array.from(e.dataTransfer?.files??[]))},children:[A.length>0&&(0,X.jsx)(`div`,{className:`msg-editor-images`,children:A.map((e,t)=>{if(e.mode===`quote`&&e.quote)return(0,X.jsx)(nd,{quote:e.quote,onRemove:()=>j(e=>e.filter((e,n)=>n!==t))},`quote-${t}`);let n=Fm(e);return(0,X.jsxs)(`span`,{className:`msg-editor-img ${n===`image`?``:`file-chip`}`,title:Im(e,T),children:[n===`image`?(0,X.jsx)(`img`,{src:`data:${e.mimeType??`image/png`};base64,${e.imageData}`,alt:e.name}):(0,X.jsxs)(`span`,{className:`msg-editor-file`,children:[(0,X.jsx)(`span`,{className:`msg-editor-file-icon`,children:n===`path`?e.mode===`page`?`🌐`:e.mode===`reference`?`🔗`:`📎`:`📄`}),(0,X.jsx)(`span`,{className:`msg-editor-file-name`,children:e.name??e.path?.split(`/`).pop()})]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-editor-img-remove`,title:T(`removeAttachment`),onClick:()=>j(e=>e.filter((e,n)=>n!==t)),children:(0,X.jsx)(P,{})})]},`${e.name??e.path??`att`}-${t}`)})}),te&&(0,X.jsx)(`div`,{className:`msg-editor-notice`,children:te}),(0,X.jsx)(`textarea`,{className:`msg-editor-input`,value:O,autoFocus:!0,placeholder:T(`editPlaceholder`),rows:Math.max(2,Math.min(10,O.split(`
351
- `).length+1)),onChange:e=>k(e.target.value),onPaste:e=>{let t=[];for(let n of e.clipboardData?.items??[])if(n.kind===`file`&&Zp(n.type)){let e=n.getAsFile();e&&t.push(e)}t.length!==0&&(e.preventDefault(),oe(t))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),ue()):e.key===`Escape`&&D(!1)}}),(0,X.jsxs)(`div`,{className:`msg-editor-actions`,children:[(0,X.jsxs)(`span`,{className:`msg-editor-hint`,children:[(0,X.jsx)(Me,{}),` `,T(`editAttachmentHint`)]}),(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>D(!1),children:T(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip primary`,disabled:!O.trim()&&!A.some(e=>e.mode===`quote`&&Yu(e.quote)),title:T(`reaskFromHere`),onClick:ue,children:[(0,X.jsx)(Y,{}),` `,T(`reaskFromHere`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[Om(e)?(0,X.jsx)(`div`,{className:`msg-stopped`,role:`status`,children:T(`turnStopped`)}):e.errorMessage&&(0,X.jsxs)(`div`,{className:`msg-error`,children:[(0,X.jsx)(`span`,{className:`msg-error-text`,children:e.errorMessage}),a&&!i&&c&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-retry-btn`,title:T(`retryLastTip`),onClick:c,children:[(0,X.jsx)(K,{}),` `,T(`retryNow`)]})]}),R.map((e,t)=>(0,X.jsx)(nd,{quote:e,forceOpen:v},`quote-${t}`)),L?(0,X.jsx)(nd,{quote:L,forceOpen:v}):I?(0,X.jsx)(Vm,{message:e,forceOpen:v}):B?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Gm,{block:B,forceOpen:v}),B.userMessage&&(0,X.jsx)(`div`,{className:`msg-text`,children:(0,X.jsx)(_f,{text:B.userMessage,hardBreaks:!0})}),e.content.map((o,c)=>o.type===`text`?null:(0,X.jsx)(Km,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:h,toolImages:_,thinkingWrap:m,searchActive:v,forceThinking:ze,forceTools:Be,role:e.role,showCopy:de,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))]}):Fe?(0,X.jsx)(Sf,{type:e.customType??``,code:Ie,children:e.content.map((o,c)=>(0,X.jsx)(Km,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:h,toolImages:_,thinkingWrap:m,searchActive:v,forceThinking:ze,forceTools:Be,role:e.role,showCopy:de,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))}):e.content.map((o,c)=>(0,X.jsxs)(g.Fragment,{children:[(0,X.jsx)(Km,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:h,toolImages:_,thinkingWrap:m,searchActive:v,forceThinking:ze,forceTools:Be,role:e.role,showCopy:de,uiContextToolCall:S,onUiAction:C}),c===Ue&&He&&je()]},`${e.id}-${c}`)),H&&(0,X.jsxs)(`div`,{className:`thinking-wait`,children:[T(`thinkingWait`),(0,X.jsx)(`span`,{className:`dot`})]}),i&&a&&!H&&(0,X.jsx)(`span`,{className:`stream-cursor`})]})}),He&&Ue<0&&je()]})});function Vm({message:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,g.useState)(!1),{copied:a,copy:o}=Pu({duration:1200}),s=r||t,c=e.details??{},l=c.name??c.path??n(`attachment`),u=c.type===`folder`,d=c.mode===`reference`,f=c.mode===`bridged`,p=c.mode===`page`,m=c.mode===`conversation`,h=c.path&&/^https?:\/\//i.test(c.path.trim())?c.path.trim():null,_=Hm(e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
346
+ `).trim()}function gm(e,t=1){return e==null||!Number.isFinite(e)?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(t)} KB`:e<1073741824?`${(e/1048576).toFixed(t)} MB`:`${(e/1073741824).toFixed(t)} GB`}function _m(e){return e==null||!Number.isFinite(e)?``:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var vm={open:!1,triggerId:``,selectedIds:[],includeTools:!1,includeThinking:!1},ym=vm,bm=[],xm=new Set;function Sm(){for(let e of xm)e()}function Cm(e){return(e.role===`user`||e.role===`assistant`)&&pm(e.content).length>0}function wm(e,t=bm){let n=new Map(t.map((e,t)=>[e.id,t]));return[...new Set(e)].filter(e=>n.has(e)).sort((e,t)=>(n.get(e)??0)-(n.get(t)??0))}function Tm(e){if(bm=e,ym.open){let e=wm(ym.selectedIds,bm);e.join(`\0`)!==ym.selectedIds.join(`\0`)&&(ym={...ym,selectedIds:e},Sm())}}function Em(){return ym}function Dm(e){return xm.add(e),()=>{xm.delete(e)}}function Om(){return(0,g.useSyncExternalStore)(Dm,Em,Em)}function km(){ym.open&&(ym=vm,Sm())}function Am(e){let t=bm.find(t=>t.id===e);if(t&&Cm(t)){if(ym.open){ym={...ym,selectedIds:wm([...ym.selectedIds,e])},Sm();return}ym={open:!0,triggerId:e,selectedIds:[e],includeTools:!1,includeThinking:!1},Sm()}}function jm(e){ym.open&&(ym={...ym,includeTools:e.includeTools??ym.includeTools,includeThinking:e.includeThinking??ym.includeThinking},Sm())}function Mm(e){if(!ym.open||!bm.filter(Cm).map(e=>e.id).includes(e))return;let t=ym.selectedIds.includes(e)?ym.selectedIds.filter(t=>t!==e):wm([...ym.selectedIds,e]);ym={...ym,selectedIds:t},Sm()}var Nm=null,Pm=new Set;function Fm(){for(let e of Pm)e()}function Im(e){Nm=e,Fm()}function Lm(){Nm=null,Fm()}function Rm(e){Nm&&($({type:`rollback_session`,messageId:Nm.messageId,conversationId:Nm.conversationId,restoreWorkspace:e}),Nm=null,Fm())}function zm(){return(0,g.useSyncExternalStore)(e=>(Pm.add(e),()=>Pm.delete(e)),()=>Nm)}var Bm=/^(This operation was aborted|Request aborted)$/;function Vm(e){return e.stopReason===`aborted`||e.stopReason===`error`&&Bm.test((e.errorMessage??``).trim())}var Hm=20971520;function Um(e){return e.type===`text`&&typeof e.text==`string`?e:null}function Wm(e){return e.type===`thinking`&&typeof e.thinking==`string`?e:null}function Gm(e){return e.type===`toolCall`&&typeof e.id==`string`&&typeof e.name==`string`?e:null}function Km(e){return e.type===`image`&&typeof e.dataUrl==`string`?e:null}function qm(e){return e.type===`bash`&&typeof e.command==`string`?e:null}function Jm(e){return e.imageData?`image`:e.uploadPath?`upload`:e.fileData?`file`:`path`}function Ym(e,t){if(e.mode===`quote`&&e.quote)return e.quote.text;if(e.imageData)return t(`attachImage`,{name:e.name??`image`});if(e.uploadPath)return t(`attachFile`,{name:e.name??e.uploadPath});if(e.fileData)return t(`attachFile`,{name:e.name??`file`});let n=e.path.split(`/`).pop()??e.path;return e.mode===`lines`&&e.lines?t(`attachLines`,{path:n,start:e.lines.start,end:e.lines.end}):e.mode===`page`?t(`attachPage`,{name:e.name??e.path}):e.mode===`conversation`?t(`attachConversation`,{name:e.name??e.path}):e.mode===`reference`?t(`refOnly`,{path:n}):t(`attachContent`,{path:n})}var Xm={edit:(0,X.jsx)(Y,{}),copy:(0,X.jsx)(tt,{}),branch:(0,X.jsx)(Le,{}),text:(0,X.jsx)(Ve,{}),markdown:(0,X.jsx)(nt,{}),image:(0,X.jsx)(Me,{}),undo:(0,X.jsx)(G,{}),volume:(0,X.jsx)(ne,{}),refresh:(0,X.jsx)(K,{}),x:(0,X.jsx)(P,{})};function Zm(e){let t=(e??``).trim();return t?Xm[t.toLowerCase()]||(!/[\p{L}\p{N}]/u.test(t)&&t.length<=4?(0,X.jsx)(`span`,{className:`msg-action-glyph`,children:t}):(0,X.jsx)(N,{})):(0,X.jsx)(N,{})}function Qm(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}var $m=(0,g.memo)(function({message:e,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onEdit:o,onKillBash:s,onRetry:c,onCollapse:l,questionAttachments:u,qnIndex:d,qnActive:f,onJump:p,thinkingWrap:m,toolsWrap:h,toolImages:_,searchActive:v,autoExpand:y,uiMessageActions:b,uiContextMessage:x,uiContextToolCall:S,onUiAction:C,readOnly:w=!1}){let T=Z(),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(``),[A,j]=(0,g.useState)([]),[ee,M]=(0,g.useState)(!1),[te,N]=(0,g.useState)(null),F=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{F.current&&clearTimeout(F.current)},[]);let re=e=>{N(e),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>N(t=>t===e?null:t),4e3)};if(e.role===`toolResult`||e.role===`system`)return null;if(e.role===`compactionSummary`)return(0,X.jsx)(nh,{message:e,forceOpen:v,autoExpand:y});let ie=e.role===`custom`&&e.customType===`file`,ae=ie&&e.details?.mode===`quote`?cd(e.details.quote):null,I=e.details?.quotes,L=e.role===`user`&&Array.isArray(I)?I.map(cd).filter(e=>e!==null):[],R=e.content.map(e=>Um(e)?.text??``).filter(Boolean).join(`
347
+ `),z=e.role===`user`?sm(R):null,oe=z?z.userMessage??`skill:${z.name}`:R.split(`
348
+ `).join(` `).trim(),B=i&&a&&e.content.length===0,H=!w&&e.role===`user`&&!i&&!B&&!!o,se=async e=>{let t=[];for(let n of e){if(!um(n.type))continue;let e=await dm(n);e&&t.push({path:``,imageData:e.data,mimeType:e.mimeType,name:e.name})}t.length>0&&j(e=>[...e,...t])},ce=async e=>{if(e.size>Hm){re(T(`fileTooLarge`,{name:e.name,size:20}));return}let t;try{t=(await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(e)})).replace(/^data:[^;]*;base64,/,``)}catch{re(T(`fileLoadFailed`,{name:e.name}));return}j(n=>[...n,{path:``,fileData:t,name:e.name,size:e.size,mimeType:e.type||void 0}])},le=async e=>{let t=[];for(let n of e)um(n.type)?t.push(n):ce(n);t.length>0&&await se(t)},ue=()=>{let t=(z?`/skill:`+z.name+(z.userMessage?` `+z.userMessage:``):e.content.map(e=>Um(e)?.text??``).filter(Boolean).join(`
349
+ `)).trim(),n=!!(u&&u.length>0);(t||n)&&o?.(e.id,t,n?u:void 0)},U=()=>{k(z?`/skill:${z.name}${z.userMessage?` ${z.userMessage}`:``}`:e.content.map(e=>Um(e)?.text??``).filter(Boolean).join(`
350
+ `)),j(u??[]),D(!0)},de=()=>{let t=O.trim();(t||A.some(e=>e.mode===`quote`&&cd(e.quote)))&&(o?.(e.id,t,A.length>0?A:void 0),D(!1))},fe=!b||b.some(e=>e?.id===`host:msg-copy`&&e.hidden!==!0),W=(0,g.useRef)(null),[pe,G]=(0,g.useState)(null),me=Om(),he=(0,g.useRef)(0),ge=pm(e.content),q=(e.role===`assistant`||e.role===`user`)&&ge.length>0&&!i,_e=async t=>{try{let n=!1;if(t===`host:msg-copy-text`)n=await Ku(mm(e.content));else if(t===`host:msg-copy-markdown`)n=await Ku(ge);else{Am(e.id);return}window.clearTimeout(he.current),G({id:t,ok:n}),he.current=window.setTimeout(()=>G(null),1600)}catch{window.clearTimeout(he.current),G({id:t,ok:!1}),he.current=window.setTimeout(()=>G(null),1600)}},ve=Qm(mm(e.content),40)||oh(e.role,T),[ye,be]=(0,g.useState)(nn());(0,g.useEffect)(()=>an(be),[]);let xe=e.role===`assistant`&&mm(e.content).trim().length>0&&!i&&qt(),J=xe&&rn()===e.id,Se=()=>{if(J){sn();return}on(Yt(mm(e.content)),{...Gt(),enabled:!0},e.id)},[Ce,we]=(0,g.useState)(!1),Te=(0,g.useRef)(null);(0,g.useEffect)(()=>{if(!Ce)return;let e=e=>{Te.current&&!Te.current.contains(e.target)&&we(!1)},t=e=>{e.key===`Escape`&&we(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[Ce]);let Ee=e=>xe?(0,X.jsxs)(`button`,{type:`button`,className:`msg-action${J?` msg-action-speaking`:``}`,title:T(J?`stopSpeakingMsg`:`speakMsg`),"aria-label":T(J?`stopSpeakingMsg`:`speakMsg`),onClick:Se,children:[J?(0,X.jsx)(V,{}):(0,X.jsx)(ne,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(J?`stopSpeakingMsg`:`speakMsg`)})]},e):null,De=()=>Gi.filter(e=>e.slot===`contextmenu.message`).map(e=>({id:e.id,slot:e.slot,source:`host`,label:T(e.labelKey),labelKey:e.labelKey,icon:e.icon,kind:e.kind,group:e.group,order:e.order??100,align:e.align??`start`,hidden:e.hidden??!1,userOverrides:[],arrangedBy:[]})),Oe=t=>{let n=t.target;if(n instanceof Element&&n.closest(`a, input, textarea, [contenteditable='true']`))return;let r=window.getSelection?.();if(r&&!r.isCollapsed&&r.toString().trim().length>0)return;let a=(x&&x.length>0?x:De()).map(t=>{if(t.source!==`host`)return t;switch(t.id){case`host:msg-ctx-copy-markdown`:case`host:msg-ctx-copy-text`:return q?t:{...t,hidden:!0};case`host:msg-ctx-copy-image`:return q&&!w?t:{...t,hidden:!0};case`host:msg-ctx-copy-link`:{let n=es(window.location.hash)?.sessionId;return!i&&n&&e.id?t:{...t,hidden:!0}}case`host:msg-ctx-reask`:case`host:msg-ctx-edit-reask`:return H?t:{...t,hidden:!0};case`host:msg-ctx-fork`:case`host:msg-ctx-rollback`:return!w&&!i&&!E?t:{...t,hidden:!0};case`host:msg-ctx-speak`:return xe?J?{...t,label:T(`stopSpeakingMsg`),icon:`square`}:t:{...t,hidden:!0};default:return t}});La(a).length!==0&&(t.preventDefault(),Ea({x:t.clientX,y:t.clientY,slot:`contextmenu.message`,target:{id:e.id,kind:`message`,label:ve},entries:a,onHostAction:t=>{switch(t.id){case`host:msg-ctx-copy-markdown`:_e(`host:msg-copy-markdown`);return;case`host:msg-ctx-copy-text`:_e(`host:msg-copy-text`);return;case`host:msg-ctx-copy-image`:_e(`host:msg-copy-image`);return;case`host:msg-ctx-copy-link`:{let t=es(window.location.hash)?.sessionId;t&&e.id&&Ku(ns(window.location.href,{sessionId:t,messageId:e.id}));return}case`host:msg-ctx-reask`:ue();return;case`host:msg-ctx-edit-reask`:U();return;case`host:msg-ctx-fork`:$({type:`fork_session`,messageId:e.id,position:`before`});return;case`host:msg-ctx-rollback`:Im({messageId:e.id});return;case`host:msg-ctx-speak`:Se();return;default:C?.(t);return}}}))},ke=(e,t)=>{if(!q)return null;let n=[{id:`host:msg-copy-markdown`,label:T(`copyMarkdown`),icon:(0,X.jsx)(nt,{})},{id:`host:msg-copy-text`,label:T(`copyText`),icon:(0,X.jsx)(Ve,{})},{id:`host:msg-copy-image`,label:T(`copyImage`),icon:(0,X.jsx)(Me,{})}].filter(e=>{if(!t)return!0;let n=t.find(t=>t.id===e.id);return!n||n.hidden!==!0});if(n.length===0)return null;let r=pe!==null,i=pe?.ok;return(0,X.jsxs)(`div`,{ref:Te,className:`msg-copy-group${Ce?` has-open-dropdown`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action msg-copy-main-btn${i?` msg-copy-success`:``}`,title:T(i?`copied`:r&&!i?`copyFailed`:`copyMarkdown`),"aria-label":T(`copyMarkdown`),onClick:()=>void _e(`host:msg-copy-markdown`),children:[i?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{}),(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(i?`copied`:`copy`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-action msg-copy-caret-btn${Ce?` active`:``}`,title:T(`copyMessage`),"aria-label":T(`copyMessage`),"aria-expanded":Ce,onClick:e=>{e.stopPropagation(),we(e=>!e)},children:(0,X.jsx)(dt,{className:`msg-copy-caret-icon${Ce?` open`:``}`})}),Ce&&(0,X.jsx)(`div`,{className:`msg-copy-dropdown`,role:`menu`,children:n.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`msg-copy-menu-item`,role:`menuitem`,onClick:()=>{we(!1),_e(e.id)},children:[e.icon,(0,X.jsx)(`span`,{children:e.label})]},e.id))})]},e)},Ae=()=>{if(!b){let e=ke(`fb-copy`),t=Ee(`fb-speak`);if(!H&&!e&&!t)return null;let n=[];return H&&n.push((0,X.jsxs)(g.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`reaskDirectlyTip`),"aria-label":T(`reaskDirectly`),onClick:ue,children:[(0,X.jsx)(K,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(`reaskDirectly`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`editReaskTip`),"aria-label":T(`editReask`),onClick:U,children:[(0,X.jsx)(Y,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(`editReask`)})]})]},`fb-reask`)),e&&n.push(e),t&&n.push(t),n}let t=[],n=!1;return b.forEach((r,a)=>{if(!r||r.hidden===!0||r.id===`host:msg-copy`)return;let o=`${r.id}#${a}`,s=r.label||r.id;if(r.id===`host:msg-copy-text`||r.id===`host:msg-copy-markdown`||r.id===`host:msg-copy-image`){if(!n){n=!0;let e=ke(`copy-dropdown`,b);e&&t.push(e)}return}if(r.id===`host:msg-speak`){let e=Ee(o);e&&t.push(e);return}if(r.id===`host:msg-reask`){if(!H)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`reaskDirectlyTip`),"aria-label":s,onClick:ue,children:[Zm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-edit-reask`){if(!H)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`editReaskTip`),onClick:U,children:[Zm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-fork`){if(i||E)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`forkSessionTip`),"aria-label":s,onClick:()=>$({type:`fork_session`,messageId:e.id,position:`before`}),children:[Zm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-rollback`){if(w||i||E)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`rollbackSessionTip`),"aria-label":s,onClick:()=>{Im({messageId:e.id})},children:[Zm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.kind===`divider`){t.push((0,X.jsx)(`span`,{className:`msg-action-divider`,"aria-hidden":`true`},o));return}if(r.kind===`badge`){t.push((0,X.jsx)(`span`,{className:`msg-action-badge`,title:s,children:r.badge??s},o));return}if(r.kind===`select`&&r.options?.length){t.push((0,X.jsx)(`select`,{className:`msg-action msg-action-select`,title:s,"aria-label":s,value:r.options.some(e=>e.value===r.value)?r.value:r.options[0].value,onChange:e=>C?.(r,e.target.value),children:r.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},o));return}t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:s,"aria-label":s,onClick:()=>C?.(r),children:[Zm(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s}),r.badge?(0,X.jsx)(`span`,{className:`msg-action-count`,children:r.badge}):null]},o))}),t.length===0?null:t},je=()=>{let e=Ae();return e?(0,X.jsx)(`div`,{className:`msg-actions${Ce?` has-open-dropdown`:``}`,children:e}):null},Ne=e.role===`custom`&&(e.customType===`goal-review`||e.customType===`goal-wizard`),Pe=e.role===`custom`&&e.customType===`goal-wizard`,Fe=e.role===`custom`&&!!e.customType&&e.customType!==`file`&&!Ne&&sf(e.customType),Ie=Fe?JSON.stringify({customType:e.customType,details:e.details??{}}):``,Le=me.open&&me.selectedIds.includes(e.id),Re=me.open&&q,ze=Le&&me.includeThinking,Be=Le&&me.includeTools,He=!E&&(e.role===`user`||q),Ue=(0,g.useMemo)(()=>{if(e.role!==`assistant`)return-1;for(let t=e.content.length-1;t>=0;t--)if(Um(e.content[t]))return t;return-1},[e.role,e.content]);return(0,X.jsxs)(`div`,{ref:W,className:`msg msg-${e.role}${Ne?` msg-goal-review`:``}${Le?` msg-export-selected`:``}${w?` msg-readonly`:``}`,"data-role":e.role,"data-msg-id":e.id,onContextMenu:Oe,children:[Re&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:Le,title:T(`copyImage`),"aria-label":T(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>Mm(e.id)}),(0,X.jsxs)(`div`,{className:`msg-meta`,children:[l&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-collapse-btn`,title:T(`collapseMsg`),onClick:()=>l(e.id),children:[(0,X.jsx)(ct,{}),` `,T(`collapseMsg`)]}),(0,X.jsx)(`span`,{className:`msg-role`,children:e.role===`custom`?Pe?T(`goalWizardCard`):Ne?T(`goalBarTitle`):e.customType===`file`?T(`attachment`):`${T(`plugin`)} · ${e.customType??T(`unknown`)}`:oh(e.role,T)}),e.model&&(0,X.jsx)(`span`,{className:`msg-model`,children:e.model}),e.timestamp&&(0,X.jsx)(`span`,{className:`msg-time`,children:sh(e.timestamp)}),d!==void 0&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`qn-tag ${f?`active`:``}`,title:`${d+1}. ${oe}`,"aria-label":`${d+1}. ${oe}`,onClick:()=>p(e.id),children:[(0,X.jsx)(`span`,{className:`qn-tag-bar`}),(0,X.jsx)(`span`,{className:`qn-tag-idx`,children:d+1})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:E?(0,X.jsxs)(`div`,{className:`msg-editor${ee?` drag-over`:``}`,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),M(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||M(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),M(!1),le(Array.from(e.dataTransfer?.files??[]))},children:[A.length>0&&(0,X.jsx)(`div`,{className:`msg-editor-images`,children:A.map((e,t)=>{if(e.mode===`quote`&&e.quote)return(0,X.jsx)(hd,{quote:e.quote,onRemove:()=>j(e=>e.filter((e,n)=>n!==t))},`quote-${t}`);let n=Jm(e);return(0,X.jsxs)(`span`,{className:`msg-editor-img ${n===`image`?``:`file-chip`}`,title:Ym(e,T),children:[n===`image`?(0,X.jsx)(`img`,{src:`data:${e.mimeType??`image/png`};base64,${e.imageData}`,alt:e.name}):(0,X.jsxs)(`span`,{className:`msg-editor-file`,children:[(0,X.jsx)(`span`,{className:`msg-editor-file-icon`,children:n===`path`?e.mode===`page`?`🌐`:e.mode===`reference`?`🔗`:`📎`:`📄`}),(0,X.jsx)(`span`,{className:`msg-editor-file-name`,children:e.name??e.path?.split(`/`).pop()})]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-editor-img-remove`,title:T(`removeAttachment`),onClick:()=>j(e=>e.filter((e,n)=>n!==t)),children:(0,X.jsx)(P,{})})]},`${e.name??e.path??`att`}-${t}`)})}),te&&(0,X.jsx)(`div`,{className:`msg-editor-notice`,children:te}),(0,X.jsx)(`textarea`,{className:`msg-editor-input`,value:O,autoFocus:!0,placeholder:T(`editPlaceholder`),rows:Math.max(2,Math.min(10,O.split(`
351
+ `).length+1)),onChange:e=>k(e.target.value),onPaste:e=>{let t=[];for(let n of e.clipboardData?.items??[])if(n.kind===`file`&&um(n.type)){let e=n.getAsFile();e&&t.push(e)}t.length!==0&&(e.preventDefault(),se(t))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),de()):e.key===`Escape`&&D(!1)}}),(0,X.jsxs)(`div`,{className:`msg-editor-actions`,children:[(0,X.jsxs)(`span`,{className:`msg-editor-hint`,children:[(0,X.jsx)(Me,{}),` `,T(`editAttachmentHint`)]}),(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>D(!1),children:T(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip primary`,disabled:!O.trim()&&!A.some(e=>e.mode===`quote`&&cd(e.quote)),title:T(`reaskFromHere`),onClick:de,children:[(0,X.jsx)(Y,{}),` `,T(`reaskFromHere`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[Vm(e)?(0,X.jsx)(`div`,{className:`msg-stopped`,role:`status`,children:T(`turnStopped`)}):e.errorMessage&&(0,X.jsxs)(`div`,{className:`msg-error`,children:[(0,X.jsx)(`span`,{className:`msg-error-text`,children:e.errorMessage}),a&&!i&&c&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-retry-btn`,title:T(`retryLastTip`),onClick:c,children:[(0,X.jsx)(K,{}),` `,T(`retryNow`)]})]}),L.map((e,t)=>(0,X.jsx)(hd,{quote:e,forceOpen:v},`quote-${t}`)),ae?(0,X.jsx)(hd,{quote:ae,forceOpen:v}):ie?(0,X.jsx)(eh,{message:e,forceOpen:v}):z?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ih,{block:z,forceOpen:v}),z.userMessage&&(0,X.jsx)(`div`,{className:`msg-text`,children:(0,X.jsx)(Af,{text:z.userMessage,hardBreaks:!0})}),e.content.map((o,c)=>o.type===`text`?null:(0,X.jsx)(ah,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:h,toolImages:_,thinkingWrap:m,searchActive:v,forceThinking:ze,forceTools:Be,role:e.role,showCopy:fe,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))]}):Fe?(0,X.jsx)(Ff,{type:e.customType??``,code:Ie,children:e.content.map((o,c)=>(0,X.jsx)(ah,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:h,toolImages:_,thinkingWrap:m,searchActive:v,forceThinking:ze,forceTools:Be,role:e.role,showCopy:fe,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))}):e.content.map((o,c)=>(0,X.jsxs)(g.Fragment,{children:[(0,X.jsx)(ah,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:h,toolImages:_,thinkingWrap:m,searchActive:v,forceThinking:ze,forceTools:Be,role:e.role,showCopy:fe,uiContextToolCall:S,onUiAction:C}),c===Ue&&He&&je()]},`${e.id}-${c}`)),B&&(0,X.jsxs)(`div`,{className:`thinking-wait`,children:[T(`thinkingWait`),(0,X.jsx)(`span`,{className:`dot`})]}),i&&a&&!B&&(0,X.jsx)(`span`,{className:`stream-cursor`})]})}),He&&Ue<0&&je()]})});function eh({message:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,g.useState)(!1),{copied:a,copy:o}=qu({duration:1200}),s=r||t,c=e.details??{},l=c.name??c.path??n(`attachment`),u=c.type===`folder`,d=c.mode===`reference`,f=c.mode===`bridged`,p=c.mode===`page`,m=c.mode===`conversation`,h=c.path&&/^https?:\/\//i.test(c.path.trim())?c.path.trim():null,_=th(e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
352
352
  `)),v=e.content.find(e=>e.type===`image`),y=_.split(`
353
- `).length,b=!d&&!p&&!m&&_.length>0;return(0,X.jsxs)(`div`,{className:`attachcard ${d?`reference`:``}${p?` page`:``}${m?` conversation`:``}`,children:[(0,X.jsx)(Mf,{open:s,headClassName:`attachcard-head`,titleText:n(s?`collapseMsg`:`expandMsg`),onToggle:()=>i(e=>t?!0:!e),toggle:!d&&!p&&!m?(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}):null,icon:u?`📁`:p?`🌐`:m?`💬`:`📎`,iconClassName:`attachcard-icon`,titleClassName:`attachcard-name`,after:(0,X.jsxs)(X.Fragment,{children:[c.path&&(p&&h?(0,X.jsx)(`a`,{className:`attachcard-path attachcard-link`,href:h,target:`_blank`,rel:`noreferrer`,children:c.path}):(0,X.jsx)(`span`,{className:`attachcard-path`,children:c.path})),(0,X.jsx)(`span`,{className:`attachcard-mode ${c.mode===`lines`?`lines`:d?`ref`:p?`page`:m?`conversation`:f?`bridged`:`inline`}`,children:p?n(`attachPageShort`):m?n(`attachConversationShort`):d?u?n(`folderRefShort`):`${n(`refOnlyShort`)} · ${im(c.size)}`:f?n(`bridgedVision`):v?n(`image`):c.mode===`lines`?n(`inlineLinesRange`,{start:c.startLine??1,end:c.endLine??c.lines??1}):n(`inlineLines`,{n:c.lines??y})}),b&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:n(a?`copied`:`copyMessage`),"aria-label":n(`copyMessage`),onClick:e=>{e.stopPropagation(),o(_)},children:a?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})})]}),children:l}),!d&&s&&(()=>{let e=v?.dataUrl?v.dataUrl.startsWith(`/`)?fn(v.dataUrl):v.dataUrl:void 0;return f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`attachcard-bridgenote`,children:n(`bridgedVisionDetail`)}),e&&(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:e,loading:`lazy`,decoding:`async`,alt:l})}),_&&(0,X.jsx)(`pre`,{className:`attachcard-content`,children:_})]}):e?(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:e,loading:`lazy`,decoding:`async`,alt:l})}):(0,X.jsx)(`pre`,{className:`attachcard-content`,children:_})})(),d&&(0,X.jsx)(`div`,{className:`attachcard-refnote`,children:u?n(`folderNotExpanded`):n(`fileNotExpanded`,{size:im(c.size)})})]})}function Hm(e){let t=e.match(/^\s*<file path="[^"]*"(?:\s+lines="[^"]*")?>\s*```\s*\n?([\s\S]*?)\n?```\s*<\/file>\s*$/);if(t)return t[1].trim();let n=e.match(/^\s*<vision-bridge>\s*([\s\S]*?)\s*<\/vision-bridge>\s*$/);return n?n[1].trim():e.trim()}function Um({message:e,forceOpen:t=!1,autoExpand:n=!1}){let r=Z(),[i,a]=(0,g.useState)(!1),{copied:o,copy:s}=Pu({duration:1200}),[c,l]=(0,g.useState)(n);n!==c&&(l(n),n&&a(!0));let u=i||t,d=Es(e.id),[f,p]=(0,g.useState)(!1),m=()=>{f?p(!1):(p(!0),d.status===`idle`&&Ss(e.id))},h=e.content.map(e=>Am(e)?.text??``).filter(Boolean).join(`
354
- `),_=typeof e.tokensBefore==`number`?e.tokensBefore.toLocaleString():null;return(0,X.jsxs)(`div`,{className:`msg msg-compactionSummary`,"data-role":e.role,"data-msg-id":e.id,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:r(`role.compaction`)}),e.timestamp&&(0,X.jsx)(`span`,{className:`msg-time`,children:Jm(e.timestamp)})]}),(0,X.jsxs)(`div`,{className:`compaction-card${i?` expanded`:``}`,children:[(0,X.jsx)(Mf,{open:u,headClassName:`compaction-head`,titleText:r(u?`collapseMsg`:`expandMsg`),onToggle:()=>a(e=>t?!0:!e),toggle:(0,X.jsx)(`span`,{className:`chead-toggle`,children:u?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}),icon:(0,X.jsx)(St,{}),iconClassName:`compaction-icon`,titleClassName:`compaction-title`,after:h&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:r(o?`copied`:`copyMessage`),"aria-label":r(`copyMessage`),onClick:e=>{e.stopPropagation(),s(h)},children:o?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})}),children:_?r(`compactionFrom`,{tokens:_}):r(`role.compaction`)}),u&&(0,X.jsxs)(`div`,{className:`compaction-body`,children:[(0,X.jsx)(_f,{text:h}),(0,X.jsx)(`div`,{className:`compaction-hint`,children:r(`compactionKeptHint`)}),(0,X.jsx)(`div`,{className:`compacted-history-action`,children:(0,X.jsxs)(`button`,{type:`button`,className:`compacted-history-toggle-btn`,onClick:m,"aria-expanded":f,children:[(0,X.jsx)(`span`,{className:`compacted-history-chevron`,children:f?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}),(0,X.jsx)(rt,{className:`compacted-history-clock-icon`}),(0,X.jsx)(`span`,{className:`compacted-history-btn-text`,children:r(f?`hideCompactedHistory`:`viewCompactedHistory`)}),d.status===`ready`&&d.messages.length>0&&(0,X.jsx)(`span`,{className:`compacted-history-count-pill`,children:r(`compactedHistoryTurns`,{count:d.messages.length})})]})}),f&&(0,X.jsxs)(`div`,{className:`compacted-history-panel`,children:[d.status===`loading`&&(0,X.jsxs)(`div`,{className:`compacted-history-loading`,children:[(0,X.jsx)(`span`,{className:`compact-pulse`}),(0,X.jsx)(`span`,{children:r(`compactedHistoryLoading`)})]}),d.status===`error`&&(0,X.jsx)(`div`,{className:`compacted-history-error`,children:(0,X.jsx)(`span`,{children:d.error===`compactedHistoryNotFound`||d.error===`Compaction entry not found`?r(`compactedHistoryNotFound`):d.error||r(`compactedHistoryEmpty`)})}),d.status===`ready`&&d.messages.length===0&&(0,X.jsx)(`div`,{className:`compacted-history-empty`,children:r(`compactedHistoryEmpty`)}),d.status===`ready`&&d.messages.length>0&&(0,X.jsx)(Wm,{messages:d.messages})]})]})]})]})}function Wm({messages:e}){let t=Z(),n=(0,g.useMemo)(()=>{let t=new Map;for(let n of e)n.role===`toolResult`&&n.toolCallId&&t.set(n.toolCallId,n);return t},[e]),r=(0,g.useMemo)(()=>new Map,[]);return(0,X.jsxs)(`div`,{className:`compacted-history-stream`,children:[(0,X.jsxs)(`div`,{className:`compacted-history-stream-header`,children:[(0,X.jsxs)(`span`,{className:`compacted-history-badge`,children:[(0,X.jsx)(St,{}),` `,t(`compactedHistoryBadge`)]}),(0,X.jsx)(`span`,{className:`compacted-history-count`,children:t(`compactedHistoryTurns`,{count:e.length})})]}),(0,X.jsx)(`div`,{className:`compacted-history-messages`,children:e.map(e=>(0,X.jsx)(Bm,{message:e,toolResults:n,liveOutputs:r,toolStatuses:r,streaming:!1,isLast:!1,readOnly:!0},e.id))})]})}function Gm({block:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,g.useState)(!1),{copied:a,copy:o}=Pu({duration:1200}),s=r||t;return(0,X.jsxs)(`div`,{className:`skillcard${r?` expanded`:``}`,children:[(0,X.jsx)(Mf,{open:s,headClassName:`skillcard-head`,titleText:e.location,onToggle:()=>i(e=>t?!0:!e),toggle:(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}),icon:(0,X.jsx)(gt,{}),iconClassName:`skillcard-icon`,titleClassName:`skillcard-name`,after:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`skillcard-path`,children:e.location}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:n(a?`copied`:`copyMessage`),"aria-label":n(`copyMessage`),onClick:t=>{t.stopPropagation(),o(e.content)},children:a?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})})]}),children:e.name}),s&&(0,X.jsx)(`div`,{className:`skillcard-body`,children:(0,X.jsx)(_f,{text:e.content})})]})}function Km({block:e,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:o,thinkingWrap:s,toolsWrap:c,toolImages:l,searchActive:u,forceThinking:d,forceTools:f,role:p,showCopy:m,uiContextToolCall:h,onUiAction:g}){let _=Z(),{copied:v,copy:y}=Pu({duration:1200}),b=Am(e);if(b){let e=i&&a,t=(p===`assistant`||p===`user`)&&m!==!1,n=t&&!b.text.includes(`
355
- `)&&!b.truncated,r=p===`user`?(0,X.jsx)(_f,{text:b.text,hardBreaks:!0}):e?(0,X.jsx)(jf,{text:b.text}):(0,X.jsx)(_f,{text:b.text}),o=t?(0,X.jsx)(`button`,{type:`button`,className:`msg-text-copy${v?` copied`:``}`,title:_(v?`copied`:`copyMessage`),"aria-label":_(`copyMessage`),onClick:()=>{y(b.text)},children:v?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})},`msg-text-copy`):null;return(0,X.jsx)(`div`,{className:`msg-text${n?` single`:``}`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`msg-text-main`,children:r}),o]}):(0,X.jsxs)(X.Fragment,{children:[o,r,b.truncated&&(0,X.jsx)(`div`,{className:`trunc-note`,children:_(`truncated`)})]})})}let x=jm(e);if(x)return(0,X.jsx)(Pf,{thinking:x.thinking,streaming:i&&a,wrap:s,forceOpen:u||d});let S=Mm(e);if(S){let e={result:t.get(S.id),liveOutput:n.get(S.id)?.text,streaming:i,status:r.get(S.id)};return(0,X.jsx)(Bp,{block:S,view:e,onKillBash:o,wrap:c,showImages:l??!0,forceOpen:u||f,uiContextToolCall:h,onUiAction:g})}let C=Nm(e);if(C&&C.dataUrl){let e=C.dataUrl.startsWith(`/`)?fn(C.dataUrl):C.dataUrl;return(0,X.jsx)(`div`,{className:`msg-image`,children:(0,X.jsx)(`img`,{src:e,loading:`lazy`,decoding:`async`,alt:`attachment`})})}let w=Pm(e);return w?(0,X.jsxs)(`div`,{className:`bashblock`,children:[(0,X.jsxs)(`div`,{className:`bashblock-command`,children:[(0,X.jsx)(`span`,{className:`bashblock-prompt`,children:`$`}),(0,X.jsx)(`code`,{children:td(w.command)}),w.exitCode!==void 0&&(0,X.jsx)(`span`,{className:`bashblock-exit ${w.exitCode===0?`ok`:`err`}`,children:_(`exitCode`,{code:w.exitCode})}),w.cancelled&&(0,X.jsx)(`span`,{className:`bashblock-exit err`,children:_(`cancelled`)})]}),w.output&&(0,X.jsx)(`pre`,{className:`bashblock-output`,children:w.output}),w.truncated&&(0,X.jsx)(`div`,{className:`trunc-note`,children:_(`outputTruncated`)})]}):null}function qm(e,t){switch(e){case`user`:return t(`role.user`);case`assistant`:return t(`role.assistant`);case`toolResult`:return t(`role.tool`);case`bashExecution`:return t(`role.bash`);case`branchSummary`:return t(`role.branch`);case`compactionSummary`:return t(`role.compaction`);default:return e}}function Jm(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Ym(e,t,n){let r=!1;for(let i of t){let t=i;if(t.type!==`image`||typeof t.dataUrl!=`string`||!t.dataUrl.startsWith(`data:`))continue;let a=t.dataUrl.match(/^data:([^;]*);base64,(.+)$/);a&&(r=!0,e.push({path:``,imageData:a[2],mimeType:a[1]||`image/png`,name:n??`image.${(a[1]||`image/png`).split(`/`)[1]??`png`}`}))}return r}function Xm(e){let t=e.details??{};if(t.mode===`quote`){let e=Yu(t.quote);return e?{path:``,mode:`quote`,quote:e}:null}let n=[];if(Ym(n,e.content,t.name))return n[0]??null;if(t.upload&&t.path)return{path:``,uploadPath:t.path,name:t.name??t.path,size:t.size};if(t.mode===`page`&&t.path)return{path:t.path,mode:`page`,name:t.name??t.path};if(t.mode===`conversation`){let e=t,n=typeof e.conversationId==`string`&&e.conversationId?e.conversationId:void 0,r=typeof e.sessionPath==`string`&&e.sessionPath?e.sessionPath:void 0;return n||r?{path:``,mode:`conversation`,name:t.name??n??r,...n?{conversationId:n}:{},...r?{sessionPath:r}:{}}:null}if(t.path&&t.mode){let e=t.mode===`lines`?`lines`:`reference`,n={path:t.path,mode:e};return t.mode===`lines`&&typeof t.startLine==`number`&&typeof t.endLine==`number`&&(n.lines={start:t.startLine,end:t.endLine}),n}return null}function Zm(e){let t=new Map;for(let n=0;n<e.length;n++){let r=e[n];if(r.role!==`user`||!r.id)continue;let i=[];Ym(i,r.content);let a=r.details?.quotes;for(let e of Array.isArray(a)?a:[]){let t=Yu(e);t&&i.push({path:``,mode:`quote`,quote:t})}let o=[];for(let t=n-1;t>=0&&e[t].role===`custom`&&e[t].customType===`file`;t--){let n=Xm(e[t]);n&&o.unshift(n)}i.push(...o);for(let t=n+1;t<e.length&&e[t].role===`custom`&&e[t].customType===`file`;t++){let n=Xm(e[t]);n&&i.push(n)}i.length>0&&t.set(r.id,i)}return t}var Qm=(0,g.memo)(function({message:e,onExpand:t,summary:n}){let r=Z(),i=hm(),a=um(e),o=i.open&&i.selectedIds.includes(e.id),s=i.open&&a,c=n??``;if(!c)for(let t of e.content){let e=Am(t);if(e&&e.text.trim()){let t=Jp(e.text);c=t?`skill:${t.name}`+(t.userMessage?` · ${t.userMessage.replace(/\s+/g,` `).trim()}`:``):e.text.replace(/\s+/g,` `).trim();break}}if(!c&&e.role===`custom`&&e.customType===`file`){let t=e.details??{};c=t.name??t.path??``}c.length>90&&(c=`${c.slice(0,90)}…`);let l=0,u=0,d=0,f=0;for(let t of e.content)jm(t)?l++:Mm(t)?u++:Pm(t)?d++:Nm(t)&&f++;let p=[];return l&&p.push(`${r(`thinking`)} ${l}`),u&&p.push(`${r(`toolCalls`)} ${u}`),d&&p.push(`${r(`bashRuns`)} ${d}`),f&&p.push(`${r(`images`)} ${f}`),(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,className:`msg-collapsed${o?` msg-export-selected`:``}`,"data-msg-id":e.id,title:`${r(`expandMsg`)} · ${c||p.join(` · `)||e.role}`,onClick:()=>t(e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.id))},children:[s&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:o,title:r(`copyImage`),"aria-label":r(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>ym(e.id)}),(0,X.jsx)(`span`,{className:`msg-collapsed-role role-${e.role}`,children:e.role===`custom`&&e.customType===`file`?r(`attachment`):qm(e.role,r)}),(0,X.jsxs)(`span`,{className:`msg-collapsed-body`,children:[c&&(0,X.jsx)(`span`,{className:`msg-collapsed-preview`,children:c}),p.length>0&&(0,X.jsx)(`span`,{className:`msg-collapsed-chips`,children:p.map((e,t)=>(0,X.jsx)(`span`,{className:`msg-collapsed-chip`,children:e},t))})]}),e.timestamp?(0,X.jsx)(`span`,{className:`msg-collapsed-time`,children:$m(e.timestamp)}):null,(0,X.jsx)(`span`,{className:`msg-collapsed-action`,children:r(`expandMsg`)})]})});function $m(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}var eh=`[goal-review]`;function th(e){for(let t of e.content??[]){let e=Am(t);if(e&&e.text.trim())return e.text}return``}function nh(e){if(e.role!==`assistant`)return;let t=th(e).trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&(e.verdict===`pass`||e.verdict===`fail`))return e.verdict}catch{}let n=t.match(/^\{\s*"verdict"\s*:\s*"(pass|fail)"[^}]*\}$/);return n?n[1]:void 0}function rh(e){if(e.role===`user`&&th(e).includes(eh))return{kind:`prompt`};let t=nh(e);if(t)return{kind:`verdict`,verdict:t}}var ih=(0,g.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,g.useRef)(null),c=(0,g.useRef)(null);return(0,g.useLayoutEffect)(()=>{let a=c.current;if(c.current=t,!t||a!==!1)return;let o=s.current,l=r.current;if(!o||!l)return;let u=o.offsetHeight;i?.(e,u);let d=u-n;if(d!==0){let e=o.parentElement;e&&e.getBoundingClientRect().bottom<=l.getBoundingClientRect().top&&(l.scrollTop+=d)}},[t]),t?(0,X.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,X.jsx)(`div`,{ref:s,children:o})}):(0,X.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})});function ah(e,t,n,r){let i=[],a=[],o=0;for(let s of e)n.has(s.id)||(s.top<t.bottom&&s.bottom>t.top?r.has(s.id)&&i.push(s.id):r.has(s.id)||(a.push(s.id),s.bottom<=t.top&&(o+=s.bottom-s.top)));return{show:i,hide:a,shrinkAbove:o}}function oh(e,t){if(t.show.length===0&&t.hide.length===0)return e;let n=new Set(e);for(let e of t.show)n.delete(e);for(let e of t.hide)n.add(e);return n}function sh(e,t,n){let r=new Set,i=0;for(let a=e.length-1;a>=0&&!(a<e.length-1&&i>=n);a--){let n=e[a];r.add(n.id),i+=t.get(n.id)??ch(n.role,n.customType)}return r}function ch(e,t){switch(e){case`user`:return 72;case`assistant`:return 280;case`toolResult`:return 8;case`custom`:return t===`file`?96:72;default:return 60}}var lh=[`text`,`thinking`,`argumentsText`,`output`,`command`];function uh(e){let t=0;for(let n of e.content){n.type===`image`&&(t+=1);for(let e of lh){let r=n[e];typeof r==`string`&&(t+=r.length)}}return t}function dh(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function fh(e){let t=[];for(let n of e.content)n.type===`text`&&typeof n.text==`string`&&t.push(n.text);return t.join(`
356
- `)}function ph(e,t){let n=[];for(let r of e.content)if(r.type===`text`&&typeof r.text==`string`)n.push(r.text);else if(r.type===`thinking`&&typeof r.thinking==`string`)n.push(r.thinking);else if(r.type===`toolCall`){if(typeof r.name==`string`&&n.push(r.name),typeof r.argumentsText==`string`&&n.push(r.argumentsText),typeof r.id==`string`){let e=t.get(r.id);if(e){let t=fh(e);t&&n.push(t)}}}else r.type===`bash`&&(typeof r.command==`string`&&n.push(r.command),typeof r.output==`string`&&n.push(r.output));return n.join(`
357
- `)}function mh(e,t){let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}function hh(e,t,n,r){let i=new Map,a=n.toLowerCase();if(!a)return i;for(let n of e){if(!t.has(n.id))continue;let e=mh(ph(n,r).toLowerCase(),a);e>0&&i.set(n.id,e)}return i}function gh(e,t){let n=[],r=t.toLowerCase();if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.closest(`.search-bar`)||t.closest(`.msg-collapsed`)?NodeFilter.FILTER_REJECT:(e.textContent??``).toLowerCase().includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=(e.textContent??``).toLowerCase();if(!e.parentElement?.closest(`[data-msg-id]`))continue;let i=t.indexOf(r);for(;i!==-1;){let a=document.createRange();a.setStart(e,i),a.setEnd(e,i+r.length),n.push(a),i=t.indexOf(r,i+r.length)}}return n}function _h(e,t,n,r,i){let a=hh(n,r,t,i),o=new Map;for(let n of gh(e,t)){let e=n.startContainer.parentElement?.closest(`[data-msg-id]`);if(!e?.dataset.msgId)continue;let t=o.get(e.dataset.msgId);t?t.push(n):o.set(e.dataset.msgId,[n])}let s=[];for(let e of n){let t=o.get(e.id);if(t)for(let n=0;n<t.length;n++)s.push({kind:`dom`,range:t[n],msgId:e.id,k:n});let n=a.get(e.id);if(n)for(let t=0;t<n;t++)s.push({kind:`folded`,msgId:e.id,k:t})}return s}function vh(e,t){return e.findIndex(e=>e.msgId===t.msgId&&e.k===t.k)}function yh(e,t){let n=CSS;if(!n.highlights)return;if(t.length===0){n.highlights.delete(e);return}let r=window.Highlight;r&&n.highlights.set(e,new r(...t))}function bh(e,t){let n=[],r=e;for(;r&&r!==t;){let e=getComputedStyle(r);/(auto|scroll|hidden)/.test(e.overflowY+e.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function xh(e,t){let n=t.startContainer.parentElement;for(let r of bh(n,e)){let e=t.getBoundingClientRect(),n=r.getBoundingClientRect();if(e.height<=0||e.width<=0)return;e.top>=n.top+4&&e.bottom<=n.bottom-4||(r.scrollTop+=e.top-n.top-(r.clientHeight-e.height)/2),e.left>=n.left+4&&e.right<=n.right-4||(r.scrollLeft+=e.left-n.left-(r.clientWidth-e.width)/2)}let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.height<=0||r.width<=0)return;let a=r.top>=i.top+6&&r.bottom<=i.bottom-6,o=r.left>=i.left+6&&r.right<=i.right-6;a&&o||(a||(e.scrollTop+=r.top-i.top-(i.height-r.height)/2),o||(e.scrollLeft+=r.left-i.left-(i.width-r.width)/2))}function Sh({containerRef:e,messages:t,collapsedIds:n,toolResults:r,onExpand:i,onProgrammaticScroll:a,open:o,onClose:s}){let c=Z(),l=(0,g.useRef)(null),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(0),[,_]=(0,g.useState)(0),v=(0,g.useDeferredValue)(u),y=o?v.trim():``,b=(0,g.useRef)(null);b.current=f;let x=(0,g.useRef)([]),S=(0,g.useRef)({key:null}),C=(0,g.useRef)(``);(0,g.useEffect)(()=>{o&&(p(null),requestAnimationFrame(()=>l.current?.select()))},[o]),(0,g.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),s())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,s]),(0,g.useEffect)(()=>(o||(yh(`msg-search`,[]),yh(`msg-search-active`,[])),()=>{yh(`msg-search`,[]),yh(`msg-search-active`,[])}),[o]),(0,g.useLayoutEffect)(()=>{let s=()=>{h(0),p(null),_(0),x.current=[],yh(`msg-search`,[]),yh(`msg-search-active`,[]),S.current={key:null},C.current=``};if(!o||!y){s();return}let c=e.current;if(!c)return;let l=!1,u=0;return u=requestAnimationFrame(()=>{if(l)return;let e=_h(c,y,t,n,r);x.current=e;let o=e.length;if(h(o),o===0){p(null),_(0),yh(`msg-search`,[]),yh(`msg-search-active`,[]),S.current={key:null},C.current=y;return}let s=b.current,u;if(s){if(u=vh(e,s),u===-1){let t=[];for(let n=0;n<e.length;n++)e[n].msgId===s.msgId&&t.push(n);u=t.length>0?t[Math.min(s.k,t.length-1)]:0}}else u=0;u<0&&(u=0),u>=o&&(u=o-1),(!s||s.msgId!==e[u].msgId||s.k!==e[u].k)&&p({msgId:e[u].msgId,k:e[u].k}),_(u);let d=e[u],f=S.current,m=f.key?.msgId!==d.msgId||f.key?.k!==d.k||f.kind===`folded`&&d.kind===`dom`||y!==C.current;if(S.current={key:{msgId:d.msgId,k:d.k},kind:d.kind},C.current=y,yh(`msg-search`,e.filter(e=>e.kind===`dom`).map(e=>e.range)),d.kind===`folded`){yh(`msg-search-active`,[]),m&&i(d.msgId);return}yh(`msg-search-active`,[d.range]),m&&(a?.(),xh(c,d.range))}),()=>{l=!0,cancelAnimationFrame(u)}},[o,y,t,e,f,n,r,i,a]);let w=(0,g.useCallback)(e=>{let t=x.current,n=t.length;if(n===0)return;let r=b.current,i=t[((r?vh(t,r):0)+e+n)%n];p(i.kind===`dom`||i.kind===`folded`?{msgId:i.msgId,k:i.k}:null)},[]);if(!o)return null;let T=f?(()=>{let e=vh(x.current,f);return e===-1?0:e})():0;return(0,X.jsxs)(`div`,{className:`search-bar`,role:`search`,children:[(0,X.jsx)(`input`,{ref:l,className:`search-input`,type:`text`,value:u,placeholder:c(`searchPlaceholder`),onChange:e=>{d(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w(e.shiftKey?-1:1))}}),(0,X.jsx)(`span`,{className:`search-count ${m===0?`empty`:``}`,children:m===0?c(`searchNoResults`):`${Math.min(T+1,m)}/${m}`}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchPrev`),disabled:m===0,onClick:()=>w(-1),children:(0,X.jsx)(ct,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchNext`),disabled:m===0,onClick:()=>w(1),children:(0,X.jsx)(dt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchClose`),onClick:s,children:(0,X.jsx)(P,{})})]})}function Ch(e){let{dSt:t,dSh:n,escaped:r,graceActive:i,stuck:a}=e;return i||t>=-4||t<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:a&&!r}:{flipEscape:!0,reassert:!1}}var wh=`pi-web-model-usage`;function Th(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){let e=typeof r==`number`?Math.floor(r):0;Number.isFinite(e)&&e>0&&(t[n]=e)}return t}function Eh(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Dh(e,t){let n=t;return e.map((e,t)=>({m:e,i:t,count:n[e.id]??0})).sort((e,t)=>t.count-e.count||e.i-t.i).map(e=>e.m)}function Oh(){try{let e=localStorage.getItem(wh);return e?Th(JSON.parse(e)):{}}catch{return{}}}function kh(e){try{localStorage.setItem(wh,JSON.stringify(e))}catch{}}function Ah(e){let t=Eh(Oh(),e);return kh(t),t}var jh=[{id:`setup-matt-pocock-skills`,icon:`🛠`,titleKey:`tpl.sk.setup`,descKey:`tpl.sk.setup.desc`,promptKey:`tpl.sk.setup.prompt`},{id:`ask-matt`,icon:`🧭`,titleKey:`tpl.sk.ask`,descKey:`tpl.sk.ask.desc`,promptKey:`tpl.sk.ask.prompt`},{id:`grill-with-docs`,icon:`🗣`,titleKey:`tpl.sk.grilldocs`,descKey:`tpl.sk.grilldocs.desc`,promptKey:`tpl.sk.grilldocs.prompt`},{id:`to-spec`,icon:`📝`,titleKey:`tpl.sk.tospec`,descKey:`tpl.sk.tospec.desc`,promptKey:`tpl.sk.tospec.prompt`},{id:`to-tickets`,icon:`🎫`,titleKey:`tpl.sk.totickets`,descKey:`tpl.sk.totickets.desc`,promptKey:`tpl.sk.totickets.prompt`},{id:`implement`,icon:`🏗`,titleKey:`tpl.sk.implement`,descKey:`tpl.sk.implement.desc`,promptKey:`tpl.sk.implement.prompt`},{id:`code-review`,icon:`🧹`,titleKey:`tpl.sk.codeview`,descKey:`tpl.sk.codeview.desc`,promptKey:`tpl.sk.codeview.prompt`},{id:`wayfinder`,icon:`🗺`,titleKey:`tpl.sk.wayfinder`,descKey:`tpl.sk.wayfinder.desc`,promptKey:`tpl.sk.wayfinder.prompt`},{id:`prototype`,icon:`🔬`,titleKey:`tpl.sk.prototype`,descKey:`tpl.sk.prototype.desc`,promptKey:`tpl.sk.prototype.prompt`},{id:`research`,icon:`📚`,titleKey:`tpl.sk.research`,descKey:`tpl.sk.research.desc`,promptKey:`tpl.sk.research.prompt`},{id:`improve-codebase-architecture`,icon:`🏛`,titleKey:`tpl.sk.arch`,descKey:`tpl.sk.arch.desc`,promptKey:`tpl.sk.arch.prompt`},{id:`diagnosing-bugs`,icon:`🐛`,titleKey:`tpl.sk.debug`,descKey:`tpl.sk.debug.desc`,promptKey:`tpl.sk.debug.prompt`},{id:`resolving-merge-conflicts`,icon:`🔀`,titleKey:`tpl.sk.merge`,descKey:`tpl.sk.merge.desc`,promptKey:`tpl.sk.merge.prompt`},{id:`triage`,icon:`🗂`,titleKey:`tpl.sk.triage`,descKey:`tpl.sk.triage.desc`,promptKey:`tpl.sk.triage.prompt`},{id:`wizard`,icon:`✨`,titleKey:`tpl.sk.wizard`,descKey:`tpl.sk.wizard.desc`,promptKey:`tpl.sk.wizard.prompt`},{id:`grill-me`,icon:`🔍`,titleKey:`tpl.sk.grillme`,descKey:`tpl.sk.grillme.desc`,promptKey:`tpl.sk.grillme.prompt`},{id:`handoff`,icon:`🤝`,titleKey:`tpl.sk.handoff`,descKey:`tpl.sk.handoff.desc`,promptKey:`tpl.sk.handoff.prompt`},{id:`to-questionnaire`,icon:`📋`,titleKey:`tpl.sk.questionnaire`,descKey:`tpl.sk.questionnaire.desc`,promptKey:`tpl.sk.questionnaire.prompt`},{id:`teach`,icon:`🎓`,titleKey:`tpl.sk.teach`,descKey:`tpl.sk.teach.desc`,promptKey:`tpl.sk.teach.prompt`},{id:`wait-what`,icon:`💬`,titleKey:`tpl.sk.ww`,descKey:`tpl.sk.ww.desc`,promptKey:`tpl.sk.ww.prompt`},{id:`writing-for-agents`,icon:`📄`,titleKey:`tpl.sk.wfa`,descKey:`tpl.sk.wfa.desc`,promptKey:`tpl.sk.wfa.prompt`},{id:`codebase-design`,icon:`🧱`,titleKey:`tpl.sk.codesign`,descKey:`tpl.sk.codesign.desc`,promptKey:`tpl.sk.codesign.prompt`},{id:`domain-modeling`,icon:`🏷`,titleKey:`tpl.sk.domain`,descKey:`tpl.sk.domain.desc`,promptKey:`tpl.sk.domain.prompt`},{id:`grilling`,icon:`🔥`,titleKey:`tpl.sk.grilling`,descKey:`tpl.sk.grilling.desc`,promptKey:`tpl.sk.grilling.prompt`},{id:`tdd`,icon:`🧪`,titleKey:`tpl.sk.tdd`,descKey:`tpl.sk.tdd.desc`,promptKey:`tpl.sk.tdd.prompt`}],Mh=`pi-web-ui:prompt-templates`;function Nh(){try{let e=localStorage.getItem(Mh);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`):[]}catch{return[]}}function Ph(e){return jh.some(t=>t.id===e)}function Fh(e){return typeof e.title==`string`}var Ih=(0,g.createContext)(null);function Lh(){let e=(0,g.useContext)(Ih);if(!e)throw Error(`useTemplates must be used within TemplateProvider`);return e}function Rh({children:e,currentModelId:t}){let n=Z(),[r,i]=(0,g.useState)(Nh),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(!1);(0,g.useEffect)(()=>{try{localStorage.setItem(Mh,JSON.stringify(r))}catch{}},[r]);let h=(0,g.useMemo)(()=>{let e=new Map,t=new Set;for(let n of r)n.hidden?t.add(n.id):(Fh(n)&&!Ph(n.id)||Fh(n))&&e.set(n.id,n);let i=jh.filter(e=>!t.has(e.id)).map(t=>{let r=e.get(t.id);return{id:t.id,icon:r?.icon??t.icon,title:r?.title??n(t.titleKey),desc:r?.desc??n(t.descKey),prompt:r?.prompt??n(t.promptKey),builtin:!0}}),a=r.filter(e=>Fh(e)&&!Ph(e.id)).map(e=>({id:e.id,icon:e.icon??`📌`,title:e.title??``,desc:e.desc??``,prompt:e.prompt??``}));return[...i,...a]},[r,n]),_=(0,g.useCallback)(()=>o(!0),[]),v=(0,g.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:e}))},[]),y=(0,g.useCallback)((e,t=!1)=>{m(t),e?(u(!1),c({...e})):(u(!0),c({id:jt(),icon:`📌`,title:``,desc:``,prompt:``}))},[]),b=(0,g.useCallback)(()=>{o(!1),c(null),m(!1)},[]),x=(0,g.useCallback)(()=>{d?(i([]),f(!1)):f(!0)},[d]);(0,g.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),5e3);return()=>clearTimeout(e)},[d]);let S=(0,g.useCallback)(e=>{o(!1),v(e.prompt)},[v]),C=(0,g.useCallback)(e=>{o(!1),y(e,!0)},[y]),w=(0,g.useCallback)(()=>{o(!1),y(void 0,!0)},[y]),T=(0,g.useCallback)(e=>{i(t=>{let n=t.findIndex(t=>t.id===e.id);if(n>=0){let r=[...t];return r[n]=e,r}return[...t,e]}),c(null),p&&(o(!0),m(!1))},[p]),E=(0,g.useCallback)(e=>{i(t=>e.builtin?[...t.filter(t=>t.id!==e.id),{id:e.id,hidden:!0}]:t.filter(t=>t.id!==e.id)),c(null),p&&(o(!0),m(!1))},[p]),D=(0,g.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e.id||t.hidden)),c(null),p&&(o(!0),m(!1))},[p]),O=(0,g.useMemo)(()=>({templates:h,fill:v,openPicker:_,openEdit:y,resetConfirm:d,toggleReset:x}),[h,v,_,y,d,x]),k=s?r.some(e=>e.id===s.id&&!e.hidden&&Fh(e)):!1;return(0,X.jsxs)(Ih.Provider,{value:O,children:[e,a&&(0,X.jsx)(Vh,{templates:h,resetConfirm:d,onFill:S,onEditTpl:C,onNew:w,onResetToggle:x,onClose:b}),s&&(0,X.jsx)(Hh,{editing:s,isNew:l,hasOverride:k,onDraft:c,onSave:T,onRestore:()=>D(s),onRemove:()=>E(s),onFill:()=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:s.prompt})),b()},onSend:()=>{let e=s.prompt.trim();e&&$({type:`prompt`,text:e,queue:!1})&&(t&&Ah(t),b())},onClose:b})]})}function zh(){let e=Z(),{templates:t,fill:n,openEdit:r,toggleReset:i,resetConfirm:a}=Lh();return(0,X.jsxs)(`div`,{className:`empty-templates`,children:[(0,X.jsxs)(`div`,{className:`empty-templates-head`,children:[(0,X.jsx)(`span`,{className:`empty-templates-title`,children:e(`tpl.title`)}),(0,X.jsx)(`span`,{className:`empty-templates-hint`,children:e(`tpl.hint`)})]}),(0,X.jsxs)(`div`,{className:`empty-templates-grid`,children:[t.map(t=>(0,X.jsx)(Bh,{tpl:t,title:e(`tpl.clickCard`),onFill:()=>n(t.prompt),onEdit:()=>r(t),editTitle:e(`tpl.editTpl`)},t.id)),(0,X.jsxs)(`button`,{type:`button`,className:`empty-template add`,onClick:()=>r(),title:e(`tpl.add`),children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:(0,X.jsx)(me,{})}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:e(`tpl.add`)}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:e(`tpl.addDesc`)})]})]})]}),(0,X.jsx)(`div`,{className:`empty-templates-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`empty-templates-reset`,onClick:i,children:[(0,X.jsx)(G,{}),e(a?`tpl.resetConfirm`:`tpl.reset`)]})})]})}function Bh({tpl:e,title:t,onFill:n,onEdit:r,editTitle:i}){let a=Z();return(0,X.jsxs)(`button`,{type:`button`,className:`empty-template`,title:t,onClick:n,children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:e.icon}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:e.title}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:e.desc})]}),(0,X.jsx)(`span`,{className:`template-card-ops`,role:`button`,title:i??a(`tpl.editTpl`),onClick:e=>{e.stopPropagation(),r()},children:(0,X.jsx)(Ke,{})})]})}function Vh({templates:e,resetConfirm:t,onFill:n,onEditTpl:r,onNew:i,onResetToggle:a,onClose:o}){let s=Z();return(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:o,children:(0,X.jsxs)(`div`,{className:`modal template-picker`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`template-picker-top`,children:[(0,X.jsxs)(`div`,{className:`template-picker-head`,children:[(0,X.jsx)(`span`,{className:`template-picker-title`,children:s(`tpl.pickerTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-modal-close`,title:s(`close`),onClick:o,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`div`,{className:`template-picker-hint`,children:s(`tpl.pickerHint`)})]}),(0,X.jsx)(`div`,{className:`template-picker-scroll`,children:(0,X.jsxs)(`div`,{className:`template-picker-grid`,children:[e.map(e=>(0,X.jsx)(Bh,{tpl:e,title:s(`tpl.clickCard`),onFill:()=>n(e),onEdit:()=>r(e),editTitle:s(`tpl.editTpl`)},e.id)),(0,X.jsxs)(`button`,{type:`button`,className:`empty-template add`,onClick:i,title:s(`tpl.add`),children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:(0,X.jsx)(me,{})}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:s(`tpl.add`)}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:s(`tpl.addDesc`)})]})]})]})}),(0,X.jsx)(`div`,{className:`template-picker-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`empty-templates-reset`,onClick:a,children:[(0,X.jsx)(G,{}),s(t?`tpl.resetConfirm`:`tpl.reset`)]})})]})})}function Hh({editing:e,isNew:t,hasOverride:n,onDraft:r,onSave:i,onRestore:a,onRemove:o,onFill:s,onSend:c,onClose:l}){let u=Z(),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,g.useEffect)(()=>{let e=d.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>300;e.style.height=`${Math.min(e.scrollHeight,300)}px`,e.style.overflowY=t?`auto`:`hidden`},[e.prompt]);let f=()=>{let t=e.title.trim(),n=e.prompt.trim();if(!t||!n){r({...e,error:u(`tpl.required`)});return}i({id:e.id,icon:e.icon.trim()||`📌`,title:t,desc:e.desc.trim(),prompt:n})},p=!!e.builtin&&!t;return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:l,children:(0,X.jsxs)(`div`,{className:`modal template-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`template-modal-head`,children:[(0,X.jsx)(`span`,{className:`template-modal-icon`,children:e.icon}),(0,X.jsx)(`span`,{className:`template-modal-badge`,children:u(p?`tpl.builtin`:`tpl.custom`)}),(0,X.jsx)(`span`,{className:`template-modal-title`,children:u(t?`tpl.newTitle`:`tpl.editTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-modal-close`,title:u(`close`),onClick:l,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`template-modal-body`,children:[(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldIcon`)}),(0,X.jsx)(`input`,{className:`template-field-input icon`,value:e.icon,maxLength:4,onChange:t=>r({...e,icon:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldTitle`)}),(0,X.jsx)(`input`,{className:`template-field-input`,value:e.title,placeholder:u(`tpl.fieldTitlePh`),onChange:t=>r({...e,title:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldDesc`)}),(0,X.jsx)(`input`,{className:`template-field-input`,value:e.desc,placeholder:u(`tpl.fieldDescPh`),onChange:t=>r({...e,desc:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldPrompt`)}),(0,X.jsx)(`textarea`,{ref:d,className:`template-field-prompt`,value:e.prompt,placeholder:u(`tpl.fieldPromptPh`),onChange:t=>r({...e,prompt:t.target.value})})]})]}),e.error&&(0,X.jsx)(`div`,{className:`template-error`,children:e.error}),(0,X.jsxs)(`div`,{className:`template-modal-actions`,children:[(0,X.jsxs)(`div`,{className:`template-modal-actions-left`,children:[!t&&p&&n&&(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn ghost`,title:u(`tpl.restoreTip`),onClick:a,children:u(`tpl.restore`)}),!t&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.removeTip`),onClick:o,children:[(0,X.jsx)(R,{}),` `,u(`tpl.remove`)]}),!t&&!p&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.deleteTip`),onClick:o,children:[(0,X.jsx)(R,{}),` `,u(`tpl.delete`)]})]}),(0,X.jsxs)(`div`,{className:`template-modal-actions-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn`,onClick:f,children:u(`tpl.save`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn fill`,onClick:s,title:u(`tpl.fillTip`),children:u(`tpl.fill`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn send`,onClick:c,title:u(`tpl.sendTip`),children:[(0,X.jsx)(ue,{}),` `,u(`tpl.sendNow`)]})]})]})]})})}var Uh=class extends g.Component{state={message:null};static getDerivedStateFromError(e){return{message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`[ui-slot] entry "${this.props.entryId??this.props.label}" in slot "${this.props.slot??`?`}" crashed:`,e,t.componentStack)}render(){if(this.state.message===null)return this.props.children;let e=`slot=${this.props.slot??`?`} entry=${this.props.entryId??this.props.label}: ${this.state.message}`;return(0,X.jsxs)(`button`,{type:`button`,className:`slot-error`,title:e,"aria-label":this.props.label,onClick:()=>console.error(`[ui-slot] ${e}`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`⚠`}),(0,X.jsx)(`span`,{children:this.props.label})]})}};function Wh(e,t){return!e||e.length===0?null:(0,X.jsx)(`span`,{className:`slot-toolbar`,children:e.map((e,n)=>(0,X.jsx)(Uh,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:Gh(e,n,t)},`${e.id}#${n}`))})}function Gh(e,t,n){let r=`${e.id}#${t}`,i=e.label||e.id,a=e.hint||i;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`slot-divider`,"aria-hidden":`true`},r):e.kind===`badge`?(0,X.jsx)(`span`,{className:`slot-badge`,title:a,children:e.badge??i},r):e.kind===`toggle`?(0,X.jsxs)(`button`,{type:`button`,className:`slot-btn${e.checked?` on`:``}`,title:a,"aria-label":i,"aria-pressed":!!e.checked,onClick:()=>n?.(e),children:[e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):null,(0,X.jsx)(`span`,{children:i})]},r):e.kind===`progress`?(0,X.jsx)(`span`,{className:`slot-progress`,title:`${a} ${e.progress??0}%`,children:(0,X.jsx)(`progress`,{value:e.progress??0,max:100})},r):e.kind===`input`?(0,X.jsx)(`input`,{className:`slot-input`,defaultValue:e.value??``,placeholder:i,title:a,"aria-label":i,onKeyDown:t=>{t.key===`Enter`&&!t.nativeEvent.isComposing&&n?.(e,t.target.value)}},`${r}:${e.value??``}`):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`slot-select`,title:a,"aria-label":i,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>n?.(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r):(0,X.jsxs)(`button`,{type:`button`,className:`slot-btn`,title:a,"aria-label":i,onClick:()=>n?.(e),children:[e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):null,(0,X.jsx)(`span`,{children:i})]},r)}function Kh(e,t,n){let r=[],i=[],a=!1,o=e=>{i.length!==0&&(a=!0,r.push((0,X.jsx)(`span`,{className:`slot-toolbar`,children:i.map((e,t)=>(0,X.jsx)(Uh,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:Gh(e,t,n)},`${e.id}#${t}`))},e)),i=[])};return e.forEach((e,n)=>{if(e.source===`host`){o(`gap${n}`);let i=t[e.id]??null;i&&(a=!0),r.push((0,X.jsx)(g.Fragment,{children:i},e.id))}else i.push(e)}),o(`tail`),a?(0,X.jsx)(X.Fragment,{children:r}):null}var qh=`#ffffff`,Jh=`#1e1e1e`,Yh=`.msg-actions, .msg-text-copy, .chead-copy, .stream-cursor, .msg-editor, .msg-collapse-btn, .msg-export-check, .toolcall-kill, .toolcall-open`,Xh=16384;function Zh(e,t=800,n=2){let r=Math.max(e,t,1);return r*n<=Xh?n:+(r<=Xh)}function Qh(e){let t=e.trim().toLowerCase();if(!t)return null;if(t===`transparent`)return{r:0,g:0,b:0,a:0};if(t.startsWith(`#`)){let e=t.slice(1);if(e.length===3||e.length===4){let t=Number.parseInt(e[0]+e[0],16),n=Number.parseInt(e[1]+e[1],16),r=Number.parseInt(e[2]+e[2],16),i=e.length===4?Number.parseInt(e[3]+e[3],16)/255:1;return[t,n,r,i].some(e=>Number.isNaN(e))?null:{r:t,g:n,b:r,a:i}}if(e.length===6||e.length===8){let t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),r=Number.parseInt(e.slice(4,6),16),i=e.length===8?Number.parseInt(e.slice(6,8),16)/255:1;return[t,n,r,i].some(e=>Number.isNaN(e))?null:{r:t,g:n,b:r,a:i}}return null}let n=t.match(/^rgba?\(\s*([\s\S]+)\)$/);if(!n)return null;let r=n[1].trim(),i,a=1;if(r.includes(`/`)){let[e,t]=r.split(`/`);i=e.trim().split(/[\s,]+/).filter(Boolean),a=eg(t.trim())}else if(r.includes(`,`)){let e=r.split(`,`).map(e=>e.trim());e.length===4&&(a=eg(e.pop())),i=e}else i=r.split(/\s+/).filter(Boolean),i.length===4&&(a=eg(i.pop()));if(i.length!==3)return null;let o=$h(i[0]),s=$h(i[1]),c=$h(i[2]);return[o,s,c,a].some(e=>Number.isNaN(e))?null:{r:o,g:s,b:c,a}}function $h(e){return e.endsWith(`%`)?Math.round(tg(Number.parseFloat(e),0,100)*2.55):Math.round(tg(Number.parseFloat(e),0,255))}function eg(e){return e.endsWith(`%`)?tg(Number.parseFloat(e)/100,0,1):tg(Number.parseFloat(e),0,1)}function tg(e,t,n){return Math.min(n,Math.max(t,e))}function ng(e){let t=tg(Math.round(e.r),0,255),n=tg(Math.round(e.g),0,255),r=tg(Math.round(e.b),0,255);return e.a<.996?`rgba(${t}, ${n}, ${r}, ${Math.round(tg(e.a,0,1)*1e3)/1e3})`:`rgb(${t}, ${n}, ${r})`}function rg(e,t){let n=tg(e.a,0,1);return n<=0?{r:t.r,g:t.g,b:t.b,a:t.a}:n>=1?{r:e.r,g:e.g,b:e.b,a:1}:{r:e.r*n+t.r*(1-n),g:e.g*n+t.g*(1-n),b:e.b*n+t.b*(1-n),a:1}}function ig(e,t){let n=Qh(t)??{r:255,g:255,b:255,a:1},r=Qh(e);return!r||r.a<=.004?ng({...n,a:1}):ng(rg(r,{...n,a:1}))}function ag(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function og(e){return ag(e)>.45}function sg(e){let t=document.createElement(`div`);t.style.cssText=`position:fixed;left:-99999px;top:0;width:8px;height:8px;pointer-events:none;background:${e}`,document.body.appendChild(t);let n=getComputedStyle(t).backgroundColor;return t.remove(),n}function cg(){return getComputedStyle(document.documentElement).colorScheme.split(/\s+/).includes(`light`)?qh:Jh}function lg(e){let t=cg(),n=t;try{n=ig(sg(`var(--bg)`),t)}catch{n=t}try{let e=ig(sg(`var(--card-bg, var(--msgs-bg, var(--bg)))`),n),t=Qh(e);if(t&&ag(t)+t.a>0)return e}catch{}let r=e??null;for(;r;){let e=getComputedStyle(r).backgroundColor;if(e&&e!==`transparent`&&e!==`rgba(0, 0, 0, 0)`){let t=ig(e,n),r=Qh(e);if(r&&r.a>.04)return t}r=r.parentElement}return n}function ug(e){return e instanceof HTMLElement||e instanceof SVGElement?e.style:null}function dg(e,t){let n=Qh(e);return n?n.a<=.004?`transparent`:n.a>=.996?ng({...n,a:1}):ng(rg(n,{...Qh(t)??{r:255,g:255,b:255,a:1},a:1})):null}function fg(e,t,n){let r=getComputedStyle(e),i=ug(t),a=n;if(i){let e=dg(r.backgroundColor,n);e===`transparent`?i.backgroundColor=`transparent`:e&&(i.backgroundColor=e,a=e);let t=dg(r.color,a);t&&t!==`transparent`&&(i.color=t);for(let[e]of[[`borderTopColor`,`border-top-color`],[`borderRightColor`,`border-right-color`],[`borderBottomColor`,`border-bottom-color`],[`borderLeftColor`,`border-left-color`],[`outlineColor`,`outline-color`],[`textDecorationColor`,`text-decoration-color`]]){let t=dg(r[e],a);t&&t!==`transparent`&&(i[e]=t)}let o=dg(r.fill,a);o&&o!==`transparent`&&r.fill!==`none`&&(i.fill=o);let s=dg(r.stroke,a);s&&s!==`transparent`&&r.stroke!==`none`&&(i.stroke=s),i.backdropFilter=`none`,i.setProperty(`-webkit-backdrop-filter`,`none`),r.mixBlendMode&&r.mixBlendMode!==`normal`&&(i.mixBlendMode=`normal`),i.caretColor=`transparent`}let o=Array.from(e.children),s=Array.from(t.children),c=Math.min(o.length,s.length);for(let e=0;e<c;e++)fg(o[e],s[e],a)}function pg(e){e.querySelectorAll(Yh).forEach(e=>e.remove())}function mg(e,t={}){t.includeThinking||e.querySelectorAll(`.thinking`).forEach(e=>e.remove()),t.includeTools||e.querySelectorAll(`.toolcall`).forEach(e=>e.remove())}function hg(e,t,n={}){let r=e.cloneNode(!0);return fg(e,r,t),mg(r,n),pg(r),r.classList.remove(`msg-export-selected`),r.style.margin=`0`,r.style.paddingLeft=``,r.removeAttribute(`id`),r.querySelectorAll(`[id]`).forEach(e=>e.removeAttribute(`id`)),r}async function gg(e,t={}){let{toBlob:n}=await xc(async()=>{let{toBlob:e}=await import(`./es-DIDZppIF.js`);return{toBlob:e}},[]),r=t.backgroundColor??lg(e),i=Qh(r),a=await n(e,{pixelRatio:t.pixelRatio??2,backgroundColor:r,cacheBust:!1,style:{colorScheme:i&&!og(i)?`dark`:`light`}});if(!a)throw Error(`toBlob returned null`);return a}function _g(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function vg(e){return document.querySelector(`.msg[data-msg-id="${_g(e)}"]`)??document.querySelector(`[data-msg-id="${_g(e)}"]`)}function yg(){let e=Z(),t=hm(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(`pi-web-ui`),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(``),y=(0,g.useRef)(null),b=(0,g.useRef)(null),x=(0,g.useRef)(`#ffffff`);if((0,g.useEffect)(()=>{t.open&&(d(!1),h(!1),v(``))},[t.open]),zt(()=>{gm()},t.open),(0,g.useLayoutEffect)(()=>{if(!t.open)return;let e=!1,n=0;p(!0);let r=()=>{if(e||!b.current)return;let i=[],a=!1;for(let e of t.selectedIds){let t=vg(e);t?i.push(t):a=!0}let o=t.includeThinking&&i.some(e=>e.querySelector(`.thinking`)&&!e.querySelector(`.thinking-body`))||t.includeTools&&i.some(e=>e.querySelector(`.toolcall`)&&!e.querySelector(`.toolcall-body`));if((a||o)&&n<12){n+=1,requestAnimationFrame(r);return}let s=i[0],c=lg(s??void 0);x.current=c;let l=document.createDocumentFragment();for(let e of i)l.appendChild(hg(e,c,{includeThinking:t.includeThinking,includeTools:t.includeTools}));b.current.replaceChildren(l);let u=y.current;if(u){u.style.backgroundColor=c;let e=Qh(c);if(u.style.colorScheme=e&&!og(e)?`dark`:`light`,s){let e=getComputedStyle(s).color;e&&(u.style.color=e)}}p(!1)},i=requestAnimationFrame(()=>requestAnimationFrame(r));return()=>{e=!0,cancelAnimationFrame(i),b.current?.replaceChildren()}},[t.open,t.selectedIds,t.includeThinking,t.includeTools]),!t.open)return null;let S=async()=>{let n=y.current;if(n&&!u&&t.selectedIds.length!==0){d(!0),v(``);try{let t=Zh(n.scrollHeight,n.scrollWidth);if(t===0){v(e(`exportTooLong`));return}let r=await gg(n,{backgroundColor:x.current,pixelRatio:t});await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),h(!0),window.setTimeout(()=>h(!1),1500)}catch(t){let n=t instanceof Error?t.message:String(t);v(`${e(`copyFailed`)}: ${n}`)}finally{d(!1)}}};return(0,X.jsxs)(`aside`,{className:`saveimg-dock`,role:`dialog`,"aria-label":e(`saveAsImage`),children:[(0,X.jsxs)(`div`,{className:`saveimg-head`,children:[(0,X.jsx)(`span`,{className:`saveimg-title`,children:e(`saveAsImage`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`close`),"aria-label":e(`close`),onClick:()=>gm(),children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`p`,{className:`saveimg-hint`,children:e(`exportSelectHint`)}),(0,X.jsxs)(`div`,{className:`saveimg-body`,children:[(0,X.jsx)(`div`,{className:`saveimg-preview`,children:(0,X.jsxs)(`div`,{ref:y,className:`saveimg-card${i?` saveimg-card--border`:``}`,children:[n.trim()?(0,X.jsx)(`div`,{className:`saveimg-card-title`,children:n.trim()}):null,(0,X.jsx)(`div`,{ref:b,className:`saveimg-card-md`}),o&&c.trim()?(0,X.jsx)(`div`,{className:`saveimg-card-wm`,children:c.trim()}):null]})}),(0,X.jsxs)(`div`,{className:`saveimg-options`,children:[(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.includeTools,onChange:e=>vm({includeTools:e.target.checked})}),(0,X.jsx)(`span`,{children:e(`exportIncludeTools`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.includeThinking,onChange:e=>vm({includeThinking:e.target.checked})}),(0,X.jsx)(`span`,{children:e(`exportIncludeThinking`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt`,children:[(0,X.jsx)(`span`,{children:e(`imageTitle`)}),(0,X.jsx)(`input`,{type:`text`,className:`dialog-input saveimg-input`,value:n,onChange:e=>r(e.target.value),placeholder:e(`imageTitlePlaceholder`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),(0,X.jsx)(`span`,{children:e(`imageBorder`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),(0,X.jsx)(`span`,{children:e(`imageWatermark`)})]}),(0,X.jsx)(`input`,{type:`text`,className:`dialog-input saveimg-input`,value:c,disabled:!o,onChange:e=>l(e.target.value),placeholder:e(`imageWatermarkPlaceholder`)}),(0,X.jsxs)(`div`,{className:`saveimg-copy-row`,children:[(0,X.jsx)(`span`,{className:`saveimg-count`,children:e(`exportSelectedCount`,{n:t.selectedIds.length})}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary saveimg-copy`,onClick:()=>void S(),disabled:u||f||t.selectedIds.length===0,title:e(`copyImageBtn`),children:[u||f?(0,X.jsx)(Ee,{className:`saveimg-spin`}):m?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{}),(0,X.jsx)(`span`,{children:e(u||f?`savingImage`:m?`copied`:`copyImageBtn`)})]})]})]}),_?(0,X.jsx)(`div`,{className:`saveimg-error`,children:_}):null]})]})}var bg=`.msg-text, .attachcard-content, .toolcall-output pre, .bashblock-output, .quote-content`,xg=`button, input, textarea, [contenteditable], .msg-meta, .msg-actions, .chead, .toolcall-output-label`;function Sg(e){return e.nodeType===1?e:e.parentElement}function Cg(e,t,n){if(!t||t.isCollapsed||t.rangeCount!==1)return null;let r=t.getRangeAt(0),i=Sg(r.startContainer),a=Sg(r.endContainer);if(!i||!a||!e.contains(i)||!e.contains(a)||!i.closest(bg)||!a.closest(bg)||i.closest(xg)||a.closest(xg))return null;let o=i.closest(`.msg[data-msg-id]`);if(!o||o!==a.closest(`.msg[data-msg-id]`))return null;for(let e of o.querySelectorAll(xg))if(r.intersectsNode(e))return null;let s=t.toString(),c=o.dataset.msgId,l=o.dataset.role;return!s.trim()||!c||!l?null:{text:s,messageId:c,role:l,...n?{sessionId:n}:{}}}function wg({rootRef:e,sessionId:t,enabled:n=!0,onSelect:r}){let i=Z(),[a,o]=(0,g.useState)(null);return(0,g.useEffect)(()=>{o(null);let i=e.current;if(!i||!n)return;let a=!1,s=0,c=()=>{cancelAnimationFrame(s),o(null)},l=()=>{cancelAnimationFrame(s),s=requestAnimationFrame(()=>{let e=window.getSelection(),n=Cg(i,e,t);if(!n||!e){o(null);return}let a=e.getRangeAt(0).getBoundingClientRect();if(!a.width&&!a.height){o(null);return}r?.(),o({quote:n,left:Math.max(8,Math.min(a.right-88,window.innerWidth-96)),top:Math.max(8,Math.min(a.top>=44?a.top-40:a.bottom+8,window.innerHeight-42))})})},u=e=>{e.target?.closest?.(`.quote-selection-button`)||(a=e.button===0&&i.contains(e.target),c())},d=e=>{a=!1,e.button===0&&l()},f=()=>{a||l()},p=e=>{e.key===`Escape`&&c()};return document.addEventListener(`mousedown`,u),document.addEventListener(`mouseup`,d),document.addEventListener(`selectionchange`,f),document.addEventListener(`keydown`,p),window.addEventListener(`scroll`,c,!0),window.addEventListener(`resize`,c),window.addEventListener(`blur`,c),()=>{cancelAnimationFrame(s),document.removeEventListener(`mousedown`,u),document.removeEventListener(`mouseup`,d),document.removeEventListener(`selectionchange`,f),document.removeEventListener(`keydown`,p),window.removeEventListener(`scroll`,c,!0),window.removeEventListener(`resize`,c),window.removeEventListener(`blur`,c)}},[e,t,n,r]),!a||!n||a.quote.sessionId!==t?null:(0,j.createPortal)((0,X.jsxs)(`button`,{type:`button`,className:`quote-selection-button`,style:{left:a.left,top:a.top},onMouseDown:e=>e.preventDefault(),onClick:()=>{lr({attachments:[{path:``,name:i(`quoteText`),mode:`quote`,quote:a.quote,key:jt()}]})&&(o(null),window.getSelection()?.removeAllRanges(),sr())},children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`↪`}),` `,i(`quoteSelection`)]}),document.body)}var Tg=new Map,Eg=15,Dg=5,Og=100,kg=30,Ag=250,jg=1200,Mg=1600;function Ng({kind:e,text:t,index:n,onRemoveQueued:r,onRecallQueued:i}){let a=Z(),o=Zu(t);return(0,X.jsxs)(`div`,{className:`msg msg-user msg-queued`,"data-role":`user`,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:a(`role.user`)}),(0,X.jsx)(`span`,{className:`queued-tag ${e===`steer`?`steer`:`follow`}`,children:a(e===`steer`?`queueSteerTag`:`queueFollowTag`)}),(0,X.jsxs)(`div`,{className:`msg-queued-actions`,children:[i&&(0,X.jsx)(`button`,{type:`button`,className:`msg-queued-recall`,title:a(`queueRecallTip`),"aria-label":a(`queueRecallTip`),onClick:()=>i(e,t,n),children:`↩`}),r&&(0,X.jsx)(`button`,{type:`button`,className:`msg-queued-remove`,title:a(`queueRemoveTip`),"aria-label":a(`queueRemoveTip`),onClick:()=>r(e,t,n),children:`✕`})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:(0,X.jsxs)(`div`,{className:`msg-text`,children:[o.quotes.map((e,t)=>(0,X.jsx)(nd,{quote:e},`quote-${t}`)),(0,X.jsx)(_f,{text:o.text,hardBreaks:!0})]})})]})}function Pg({compaction:e}){let t=Z(),[,n]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3)),i=e.reason===`manual`?t(`compactingReasonManual`):e.reason===`overflow`?t(`compactingReasonOverflow`):t(`compactingReasonThreshold`);return(0,X.jsxs)(`div`,{className:`compact-notice`,role:`status`,children:[(0,X.jsx)(`span`,{className:`compact-pulse`}),(0,X.jsxs)(`span`,{className:`compact-text`,children:[t(`compactingContext`),` · `,r,`s`]}),(0,X.jsx)(`span`,{className:`compact-reason`,children:i})]})}function Fg(e){return e.content.some(e=>e.type===`toolCall`)}function Ig({state:e,liveOutputs:t,toolStatuses:n,onEdit:r,onKillBash:i,onRetry:a,onRemoveQueued:o,onRecallQueued:s,thinkingWrap:c,toolsWrap:l,toolImages:u,keepRecent:d,jumpTarget:f,onJumpDone:p,urlJumpMessageId:m,onUrlJumpDone:h,uiMessageActions:_,uiContextMessage:v,uiContextToolCall:y,uiChatEmpty:b,onUiAction:x}){let S=Z(),C=hm(),w=(0,g.useRef)(null),[T,E]=(0,g.useState)(!0),D=(0,g.useRef)(!0),O=(0,g.useRef)(0),k=(0,g.useRef)(0),A=(0,g.useRef)(!1),ee=(0,g.useCallback)(()=>{A.current=!0,D.current=!1,E(!1)},[]),M=(0,g.useRef)(0),[te,N]=(0,g.useState)(()=>new Set),[P,ne]=(0,g.useState)(!1),F=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,re=(0,g.useMemo)(()=>{let t=new Map;for(let n of e.messages)n.role===`toolResult`&&n.toolCallId&&t.set(n.toolCallId,n);return t},[e.messages]),I=(0,g.useMemo)(()=>Zm(e.messages),[e.messages]),L=[...F].reverse().find(e=>e.role!==`system`),ie=L?L.id:null,R=Math.min(Og,Math.max(Dg,Math.floor(Number(d)||Eg))),z=Math.max(R*2,kg),B=e.messages.length>z?Math.max(0,e.messages.length-R):0,V=(0,g.useMemo)(()=>{let t=new Set;for(let n=0;n<B;n++){let r=e.messages[n];r.role!==`toolResult`&&(te.has(r.id)||t.add(r.id))}return t},[e.messages,B,te]),[H,U]=(0,g.useState)(()=>new Set),[ae,oe]=(0,g.useState)(()=>new Set),se=(0,g.useRef)(new Map),W=(0,g.useRef)(new Map),ce=(0,g.useRef)(new Map),le=(0,g.useRef)(0),ue=(0,g.useMemo)(()=>{let t=new Map;for(let n of e.messages)t.set(n.id,uh(n));return t},[e.messages]),de=(0,g.useRef)(ue);de.current=ue;let fe=(0,g.useRef)(H);fe.current=H;let pe=e.messages.length>kg&&!P,G=(0,g.useRef)(pe);G.current=pe;let K=sh(e.messages,se.current,Mg),me=(0,g.useRef)(K);me.current=K;let he=(0,g.useCallback)(()=>{let e=w.current;if(!e)return;if(!G.current){U(e=>e.size?new Set:e);return}let t=e.getBoundingClientRect(),n={top:t.top-jg,bottom:t.bottom+jg},r=[];for(let[e,t]of ce.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),fe.current.has(e)||_e(e,n.bottom-n.top,de.current.get(e))}let i=ah(r,n,me.current,fe.current);for(let e of i.hide){let t=ce.current.get(e);t&&_e(e,t.offsetHeight,de.current.get(e))}U(e=>oh(e,i))},[]),ge=(0,g.useCallback)(()=>{le.current||=requestAnimationFrame(()=>{le.current=0,he()})},[he]);(0,g.useLayoutEffect)(()=>{he()},[he,e.conversationId,e.sessionFile,e.messages.length]);let q=(0,g.useRef)(P);(0,g.useLayoutEffect)(()=>{q.current&&!P&&he(),q.current=P},[P,he]);let _e=(0,g.useCallback)((e,t,n)=>{n!==void 0&&(W.current.set(e,{h:t,len:n}),se.current.set(e,t))},[]),ve=(0,g.useCallback)((e,t)=>{_e(e,t,de.current.get(e))},[_e]),ye=(0,g.useCallback)(e=>{e&&ce.current.set(e.dataset.lazyId??``,e)},[]);(0,g.useEffect)(()=>{let t=new Set(e.messages.map(e=>e.id));for(let e of ce.current.keys())t.has(e)||(ce.current.delete(e),se.current.delete(e),W.current.delete(e));U(e=>{let n=!1,r=new Set;for(let i of e)t.has(i)?r.add(i):n=!0;return n?r:e})},[e.messages,te]),(0,g.useEffect)(()=>()=>cancelAnimationFrame(le.current),[]);let be=(0,g.useMemo)(()=>{let t=[];for(let n of e.messages){if(n.role!==`user`)continue;let e=n.content.map(e=>Am(e)?.text??``).filter(Boolean).join(` `),r=Jp(e),i=r?r.userMessage??`skill:${r.name}`:e.trim();i&&t.push({id:n.id,text:i})}return t},[e.messages]),xe=(0,g.useMemo)(()=>{let e=new Map;return be.forEach((t,n)=>e.set(t.id,n)),e},[be]),[J,Se]=(0,g.useState)(-1),Ce=(0,g.useRef)(-1),we=(0,g.useRef)(be);(0,g.useEffect)(()=>{we.current=be},[be]);let Te=(0,g.useCallback)(()=>{let e=w.current,t=we.current;if(!e||t.length===0)return;let n=e.getBoundingClientRect().top,r=-1;for(let i=0;i<t.length;i++){let a=e.querySelector(`[data-msg-id="${t[i].id}"]`);if(a){if(a.getBoundingClientRect().top<=n+140)r=i;else break}}r!==Ce.current&&(Ce.current=r,Se(r))},[]);(0,g.useEffect)(()=>{Te()},[be,Te]);let Ee=(0,g.useCallback)(e=>{N(t=>t.has(e)?t:new Set(t).add(e))},[]);(0,g.useLayoutEffect)(()=>{fm(e.messages.filter(um).map(e=>({id:e.id,role:e.role,content:e.content})))},[e.messages]),(0,g.useEffect)(()=>{if(C.open){for(let e of C.selectedIds)Ee(e);oe(e=>{let t=!1,n=new Set(e);for(let e of C.selectedIds)n.has(e)||(n.add(e),t=!0);return t?n:e})}},[C.open,C.selectedIds,Ee]),(0,g.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||e.key.toLowerCase()!==`f`)return;let t=e.target;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&(e.preventDefault(),ne(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let De=(0,g.useCallback)(e=>{N(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Oe=(0,g.useCallback)(t=>{let n=e.messages.findIndex(e=>e.id===t);(0,j.flushSync)(()=>{n>=0&&n<B&&!te.has(t)&&Ee(t),oe(e=>e.has(t)?e:new Set(e).add(t))});let r=we.current.findIndex(e=>e.id===t);Ce.current=r,Se(r),requestAnimationFrame(()=>{let e=w.current?.querySelector(`[data-msg-id="${t}"]`);e&&(w.current?.querySelectorAll(`.msg-flash`).forEach(e=>e.classList.remove(`msg-flash`)),e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),e!==w.current?.lastElementChild&&(A.current=!0))})},[e.messages,B,te,Ee]),[ke,Ae]=(0,g.useState)(null),je=(0,g.useRef)(null),Me=(0,g.useRef)(null);(0,g.useEffect)(()=>{let t=je.current;if(!t||t.convId!==e.conversationId){je.current={convId:e.conversationId,ids:new Set(e.messages.filter(e=>e.role===`compactionSummary`).map(e=>e.id))},Me.current=null,Ae(null);return}for(let n of e.messages)if(n.role===`compactionSummary`&&!t.ids.has(n.id)){t.ids.add(n.id),Ae(n.id);break}},[e.messages,e.conversationId]),(0,g.useEffect)(()=>{ke&&Me.current!==ke&&(Me.current=ke,Oe(ke))},[ke,Oe]);let Ne=(0,g.useMemo)(()=>f?e.messages.find(e=>e.role===f.role&&e.timestamp===f.timestamp)?.id??null:null,[e.messages,f]);(0,g.useEffect)(()=>{if(f){if(Ne){Oe(Ne),p?.();return}e.sessionFile===f.path&&e.messages.length>0&&p?.()}},[Ne,Oe,p,f,e.sessionFile,e.messages.length]),(0,g.useEffect)(()=>{if(!m)return;let t=Go(e.messages,m);if(t){Oe(t),h?.();return}e.messages.length>0&&h?.()},[m,e.messages,Oe,h]);let Pe=(0,g.useCallback)(()=>{let e=w.current;if(!e)return;let t=e.scrollTop-O.current,n=e.scrollHeight-k.current;O.current=e.scrollTop,k.current=e.scrollHeight;let r=e.scrollHeight-e.scrollTop-e.clientHeight<80,i=Date.now()<M.current,a=Ch({dSt:t,dSh:n,escaped:A.current,graceActive:i,stuck:D.current});a.reassert&&(M.current=Date.now()+Ag,e.scrollTop=e.scrollHeight),a.flipEscape&&(A.current=!0),r&&t>=0&&(A.current=!1),i||(t<0?D.current=r&&!A.current:r&&(D.current=!0)),E(D.current),Te(),ge()},[Te,ge]),Fe=(0,g.useRef)(!1);(0,g.useEffect)(()=>{let t=Fe.current;if(Fe.current=!!e.isStreaming,t&&!e.isStreaming&&!A.current){let e=()=>{let e=w.current;e&&!A.current&&(e.scrollTop=e.scrollHeight,D.current=!0,E(!0))};requestAnimationFrame(()=>requestAnimationFrame(e));let t=setTimeout(e,180);return()=>clearTimeout(t)}},[e.isStreaming]),(0,g.useEffect)(()=>{let e=w.current;e&&D.current&&(e.scrollTop=e.scrollHeight)},[F,e.isStreaming,t]);let Ie=e.queue.steering.join(`\0`)+``+e.queue.followUp.join(`\0`);(0,g.useEffect)(()=>{let e=w.current;e&&D.current&&(e.scrollTop=e.scrollHeight)},[Ie]),(0,g.useEffect)(()=>{let e=w.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientHeight,n=new ResizeObserver(()=>{let n=e.clientHeight,r=n-t;t=n,r>0&&(e.scrollTop=Math.min(e.scrollTop,e.scrollHeight-e.clientHeight))});return n.observe(e),()=>n.disconnect()},[]),(0,g.useEffect)(()=>{let e=w.current;if(!e||typeof MutationObserver>`u`)return;let t=!1,n=new MutationObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let e=w.current;e&&D.current&&!A.current&&(e.scrollTop=e.scrollHeight,E(!0))}))});return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[]);let Le=(0,g.useCallback)(()=>{if(!w.current)return;D.current=!0,A.current=!1,E(!0),M.current=Date.now()+Ag;let e=()=>{let e=w.current;e&&D.current&&!A.current&&(M.current=Date.now()+Ag,e.scrollTop=e.scrollHeight)};e(),requestAnimationFrame(()=>requestAnimationFrame(e)),setTimeout(e,120),setTimeout(e,300),setTimeout(e,600)},[]),Re=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=Re.current,t=w.current;if(!e||!t)return;let n=n=>{n.preventDefault();let r=e.querySelector(`.qn-list`);if(r&&r.contains(n.target)&&r.scrollHeight>r.clientHeight){r.scrollTop+=n.deltaY;return}t.scrollTop+=n.deltaY};return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},[]);let[ze,Be]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=()=>{Be(w.current?.clientHeight??0),ge()};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[ge]);let Ve=be.length,He=(0,g.useMemo)(()=>Ve===0?27:Math.max(4,Math.min(27,Math.floor(((ze||600)-16)/Ve)-3)),[Ve,ze]),Ue=He<20;return(0,X.jsxs)(`div`,{className:`messages-wrap${C.open?` messages-exporting`:``}`,children:[(0,X.jsx)(wg,{rootRef:w,sessionId:e.sessionId,enabled:!C.open,onSelect:ee}),(0,X.jsxs)(`div`,{className:`messages${P||T?``:` anchor-live`}`,ref:w,onScroll:Pe,children:[e.messages.length===0&&!e.streamingMessage&&(0,X.jsxs)(`div`,{className:`empty-state`,children:[(0,X.jsx)(zh,{}),b&&b.length>0&&(0,X.jsx)(`div`,{className:`chat-empty-slots`,children:Wh(b,x)})]}),e.messages.map((o,s)=>{if(o.role===`system`)return null;let d=rh(o);if(d&&!te.has(o.id))return(0,X.jsx)(Qm,{message:o,onExpand:Ee,summary:d.kind===`prompt`?S(`goalBarReviewing`):d.verdict===`pass`?S(`goalBarPassed`):S(`goalBarFailed`)},o.id);let f=s<B,p=f&&te.has(o.id);if(f&&!p)return o.role===`toolResult`?null:(0,X.jsx)(Qm,{message:o,onExpand:Ee},o.id);let m=o.role===`user`?xe.get(o.id):void 0,h=!pe||K.has(o.id)||ae.has(o.id)||!H.has(o.id);return(0,X.jsx)(ih,{id:o.id,show:h,height:dh(o.id,ue.get(o.id)??-1,W.current,ch(o.role,o.customType)),containerRef:w,onMeasured:ve,lazyRef:ye,children:(0,X.jsx)(Bm,{uiMessageActions:_,uiContextMessage:v,uiContextToolCall:y,onUiAction:x,message:o,qnIndex:m,qnActive:m===void 0?void 0:m===J,onJump:Oe,toolResults:re,liveOutputs:Fg(o)?t:Tg,toolStatuses:n,streaming:e.isStreaming,onKillBash:i,onRetry:o.id===ie?a:void 0,toolsWrap:l,toolImages:u,thinkingWrap:c,isLast:o.id===ie,onEdit:r,questionAttachments:I.get(o.id),onCollapse:p?De:void 0,searchActive:P,autoExpand:o.id===ke},o.id)},o.id)}),e.streamingMessage&&(0,X.jsx)(Bm,{uiMessageActions:_,uiContextMessage:v,uiContextToolCall:y,onUiAction:x,message:e.streamingMessage,toolResults:re,liveOutputs:Fg(e.streamingMessage)?t:Tg,toolStatuses:n,streaming:!0,isLast:!0,onEdit:r,onKillBash:i,toolsWrap:l,toolImages:u,thinkingWrap:c,searchActive:P},e.streamingMessage.id),e.retry&&e.isStreaming&&(0,X.jsxs)(`div`,{className:`retry-notice`,role:`status`,title:e.retry.errorMessage||void 0,children:[(0,X.jsx)(`span`,{className:`retry-pulse`}),(0,X.jsx)(`span`,{className:`retry-text`,children:e.retry.maxAttempts>0?S(`retryingApi`,{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):S(`retryingApiSoon`,{error:e.retry.errorMessage})})]}),e.compaction&&(0,X.jsx)(Pg,{compaction:e.compaction}),e.isStreaming&&F.length===0&&(0,X.jsx)(`div`,{className:`streaming-wait`,children:S(`waitingResponse`)}),e.queue.steering.map((e,t)=>(0,X.jsx)(Ng,{kind:`steer`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-steer-${t}`)),e.queue.followUp.map((e,t)=>(0,X.jsx)(Ng,{kind:`followUp`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-fu-${t}`)),e.actionSuggestions&&e.actionSuggestions.length>0&&(0,X.jsx)(`div`,{className:`action-suggestions`,"aria-label":S(`actionSuggestions`),children:(0,X.jsx)(`div`,{className:`action-suggestions-list`,children:e.actionSuggestions.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`action-suggestion-chip`,title:t.prompt===t.label?t.label:S(`actionSuggestionsTip`,{prompt:t.prompt}),disabled:e.isStreaming,onClick:()=>{$({type:`prompt`,text:t.prompt})},children:[(0,X.jsx)(`span`,{className:`action-suggestion-label`,children:t.label}),(0,X.jsx)(`span`,{className:`action-suggestion-icon`,"aria-hidden":`true`,children:`↵`})]},t.id))})})]}),!T&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,title:S(`backToBottom`),"aria-label":S(`backToBottom`),onClick:Le,children:[(0,X.jsx)(xt,{}),(0,X.jsx)(`span`,{className:`scroll-bottom-label`,children:S(`backToBottom`)})]}),(0,X.jsx)(Sh,{containerRef:w,messages:F,collapsedIds:V,toolResults:re,onExpand:Ee,onProgrammaticScroll:()=>{A.current=!0,D.current=!1,E(!1)},open:P,onClose:()=>ne(!1)}),be.length>0&&(0,X.jsxs)(`div`,{className:`qn-rail ${Ue?`many`:``}`,ref:Re,"aria-label":S(`questionNavTitle`),style:{"--rail-gap":`${He}px`},children:[be.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`qn-bar ${t===J?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Oe(e.id),children:(0,X.jsxs)(`span`,{className:`qn-bar-text`,children:[t+1,`. `,e.text]})},e.id)),Ue&&(0,X.jsx)(`div`,{className:`qn-list`,children:be.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`qn-list-item ${t===J?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Oe(e.id),children:[(0,X.jsx)(`span`,{className:`qn-list-idx`,children:t+1}),(0,X.jsx)(`span`,{className:`qn-list-text`,children:e.text})]},e.id))})]}),(0,X.jsx)(yg,{})]})}function Lg(e,t){return t?e.trim()?`${e.replace(/\s+$/,``)}\n${t}`:t:e}function Rg(e,t,n){let r=null;return e&&e.text&&e.ts>0&&(r={text:e.text,ts:e.ts}),t&&t.text&&t.ts>(r?.ts??0)&&(r=t),!r||r.ts<=n?null:r}function zg(e){return e.mode===`quote`&&e.quote?`quote:${JSON.stringify([e.quote.sessionId??``,e.quote.messageId,e.quote.role,e.quote.text])}`:e.key?`key:${e.key}`:e.mode===`conversation`?e.conversationId?`conv:id:${e.conversationId}`:e.sessionPath?`conv:path:${e.sessionPath}`:null:e.path?`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`:null}function Bg(e,t){return t?e?{key:t,clear:e!==t}:{key:t,clear:!1}:{key:e,clear:!1}}function Vg(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=new Set(e.map(zg).filter(e=>e!==null)),r=[...e];for(let e of t){let t=zg(e);if(t!==null){if(n.has(t))continue;n.add(t)}r.push(e)}return r}function Hg(e,t,n){return!(!e||!e.trim()||t>0||n)}function Ug(e,t){if(!t||!t.trim())return!1;let n=e.trim();return!(!n||n===t.trim())}function Wg(e,t,n){switch(n){case`cancel`:return null;case`append`:return Lg(e,t);case`overwrite`:return t}}function Gg(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Kg=`​`;function qg(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function Jg(e,t){return{first:!e.slice(0,t).includes(`
353
+ `).length,b=!d&&!p&&!m&&_.length>0;return(0,X.jsxs)(`div`,{className:`attachcard ${d?`reference`:``}${p?` page`:``}${m?` conversation`:``}`,children:[(0,X.jsx)(Gf,{open:s,headClassName:`attachcard-head`,titleText:n(s?`collapseMsg`:`expandMsg`),onToggle:()=>i(e=>t?!0:!e),toggle:!d&&!p&&!m?(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}):null,icon:u?`📁`:p?`🌐`:m?`💬`:`📎`,iconClassName:`attachcard-icon`,titleClassName:`attachcard-name`,after:(0,X.jsxs)(X.Fragment,{children:[c.path&&(p&&h?(0,X.jsx)(`a`,{className:`attachcard-path attachcard-link`,href:h,target:`_blank`,rel:`noreferrer`,children:c.path}):(0,X.jsx)(`span`,{className:`attachcard-path`,children:c.path})),(0,X.jsx)(`span`,{className:`attachcard-mode ${c.mode===`lines`?`lines`:d?`ref`:p?`page`:m?`conversation`:f?`bridged`:`inline`}`,children:p?n(`attachPageShort`):m?n(`attachConversationShort`):d?u?n(`folderRefShort`):`${n(`refOnlyShort`)} · ${_m(c.size)}`:f?n(`bridgedVision`):v?n(`image`):c.mode===`lines`?n(`inlineLinesRange`,{start:c.startLine??1,end:c.endLine??c.lines??1}):n(`inlineLines`,{n:c.lines??y})}),b&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:n(a?`copied`:`copyMessage`),"aria-label":n(`copyMessage`),onClick:e=>{e.stopPropagation(),o(_)},children:a?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})})]}),children:l}),!d&&s&&(()=>{let e=v?.dataUrl?v.dataUrl.startsWith(`/`)?fn(v.dataUrl):v.dataUrl:void 0;return f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`attachcard-bridgenote`,children:n(`bridgedVisionDetail`)}),e&&(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:e,loading:`lazy`,decoding:`async`,alt:l})}),_&&(0,X.jsx)(`pre`,{className:`attachcard-content`,children:_})]}):e?(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:e,loading:`lazy`,decoding:`async`,alt:l})}):(0,X.jsx)(`pre`,{className:`attachcard-content`,children:_})})(),d&&(0,X.jsx)(`div`,{className:`attachcard-refnote`,children:u?n(`folderNotExpanded`):n(`fileNotExpanded`,{size:_m(c.size)})})]})}function th(e){let t=e.match(/^\s*<file path="[^"]*"(?:\s+lines="[^"]*")?>\s*```\s*\n?([\s\S]*?)\n?```\s*<\/file>\s*$/);if(t)return t[1].trim();let n=e.match(/^\s*<vision-bridge>\s*([\s\S]*?)\s*<\/vision-bridge>\s*$/);return n?n[1].trim():e.trim()}function nh({message:e,forceOpen:t=!1,autoExpand:n=!1}){let r=Z(),[i,a]=(0,g.useState)(!1),{copied:o,copy:s}=qu({duration:1200}),[c,l]=(0,g.useState)(n);n!==c&&(l(n),n&&a(!0));let u=i||t,d=zs(e.id),[f,p]=(0,g.useState)(!1),m=()=>{f?p(!1):(p(!0),d.status===`idle`&&Fs(e.id))},h=e.content.map(e=>Um(e)?.text??``).filter(Boolean).join(`
354
+ `),_=typeof e.tokensBefore==`number`?e.tokensBefore.toLocaleString():null;return(0,X.jsxs)(`div`,{className:`msg msg-compactionSummary`,"data-role":e.role,"data-msg-id":e.id,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:r(`role.compaction`)}),e.timestamp&&(0,X.jsx)(`span`,{className:`msg-time`,children:sh(e.timestamp)})]}),(0,X.jsxs)(`div`,{className:`compaction-card${i?` expanded`:``}`,children:[(0,X.jsx)(Gf,{open:u,headClassName:`compaction-head`,titleText:r(u?`collapseMsg`:`expandMsg`),onToggle:()=>a(e=>t?!0:!e),toggle:(0,X.jsx)(`span`,{className:`chead-toggle`,children:u?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}),icon:(0,X.jsx)(St,{}),iconClassName:`compaction-icon`,titleClassName:`compaction-title`,after:h&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:r(o?`copied`:`copyMessage`),"aria-label":r(`copyMessage`),onClick:e=>{e.stopPropagation(),s(h)},children:o?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})}),children:_?r(`compactionFrom`,{tokens:_}):r(`role.compaction`)}),u&&(0,X.jsxs)(`div`,{className:`compaction-body`,children:[(0,X.jsx)(Af,{text:h}),(0,X.jsx)(`div`,{className:`compaction-hint`,children:r(`compactionKeptHint`)}),(0,X.jsx)(`div`,{className:`compacted-history-action`,children:(0,X.jsxs)(`button`,{type:`button`,className:`compacted-history-toggle-btn`,onClick:m,"aria-expanded":f,children:[(0,X.jsx)(`span`,{className:`compacted-history-chevron`,children:f?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}),(0,X.jsx)(rt,{className:`compacted-history-clock-icon`}),(0,X.jsx)(`span`,{className:`compacted-history-btn-text`,children:r(f?`hideCompactedHistory`:`viewCompactedHistory`)}),d.status===`ready`&&d.messages.length>0&&(0,X.jsx)(`span`,{className:`compacted-history-count-pill`,children:r(`compactedHistoryTurns`,{count:d.messages.length})})]})}),f&&(0,X.jsxs)(`div`,{className:`compacted-history-panel`,children:[d.status===`loading`&&(0,X.jsxs)(`div`,{className:`compacted-history-loading`,children:[(0,X.jsx)(`span`,{className:`compact-pulse`}),(0,X.jsx)(`span`,{children:r(`compactedHistoryLoading`)})]}),d.status===`error`&&(0,X.jsx)(`div`,{className:`compacted-history-error`,children:(0,X.jsx)(`span`,{children:d.error===`compactedHistoryNotFound`||d.error===`Compaction entry not found`?r(`compactedHistoryNotFound`):d.error||r(`compactedHistoryEmpty`)})}),d.status===`ready`&&d.messages.length===0&&(0,X.jsx)(`div`,{className:`compacted-history-empty`,children:r(`compactedHistoryEmpty`)}),d.status===`ready`&&d.messages.length>0&&(0,X.jsx)(rh,{messages:d.messages})]})]})]})]})}function rh({messages:e}){let t=Z(),n=(0,g.useMemo)(()=>{let t=new Map;for(let n of e)n.role===`toolResult`&&n.toolCallId&&t.set(n.toolCallId,n);return t},[e]),r=(0,g.useMemo)(()=>new Map,[]);return(0,X.jsxs)(`div`,{className:`compacted-history-stream`,children:[(0,X.jsxs)(`div`,{className:`compacted-history-stream-header`,children:[(0,X.jsxs)(`span`,{className:`compacted-history-badge`,children:[(0,X.jsx)(St,{}),` `,t(`compactedHistoryBadge`)]}),(0,X.jsx)(`span`,{className:`compacted-history-count`,children:t(`compactedHistoryTurns`,{count:e.length})})]}),(0,X.jsx)(`div`,{className:`compacted-history-messages`,children:e.map(e=>(0,X.jsx)($m,{message:e,toolResults:n,liveOutputs:r,toolStatuses:r,streaming:!1,isLast:!1,readOnly:!0},e.id))})]})}function ih({block:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,g.useState)(!1),{copied:a,copy:o}=qu({duration:1200}),s=r||t;return(0,X.jsxs)(`div`,{className:`skillcard${r?` expanded`:``}`,children:[(0,X.jsx)(Gf,{open:s,headClassName:`skillcard-head`,titleText:e.location,onToggle:()=>i(e=>t?!0:!e),toggle:(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(dt,{}):(0,X.jsx)(lt,{})}),icon:(0,X.jsx)(gt,{}),iconClassName:`skillcard-icon`,titleClassName:`skillcard-name`,after:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`skillcard-path`,children:e.location}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:n(a?`copied`:`copyMessage`),"aria-label":n(`copyMessage`),onClick:t=>{t.stopPropagation(),o(e.content)},children:a?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})})]}),children:e.name}),s&&(0,X.jsx)(`div`,{className:`skillcard-body`,children:(0,X.jsx)(Af,{text:e.content})})]})}function ah({block:e,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:o,thinkingWrap:s,toolsWrap:c,toolImages:l,searchActive:u,forceThinking:d,forceTools:f,role:p,showCopy:m,uiContextToolCall:h,onUiAction:g}){let _=Z(),{copied:v,copy:y}=qu({duration:1200}),b=Um(e);if(b){let e=i&&a,t=(p===`assistant`||p===`user`)&&m!==!1,n=t&&!b.text.includes(`
355
+ `)&&!b.truncated,r=p===`user`?(0,X.jsx)(Af,{text:b.text,hardBreaks:!0}):e?(0,X.jsx)(Wf,{text:b.text}):(0,X.jsx)(Af,{text:b.text}),o=t?(0,X.jsx)(`button`,{type:`button`,className:`msg-text-copy${v?` copied`:``}`,title:_(v?`copied`:`copyMessage`),"aria-label":_(`copyMessage`),onClick:()=>{y(b.text)},children:v?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{})},`msg-text-copy`):null;return(0,X.jsx)(`div`,{className:`msg-text${n?` single`:``}`,children:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`msg-text-main`,children:r}),o]}):(0,X.jsxs)(X.Fragment,{children:[o,r,b.truncated&&(0,X.jsx)(`div`,{className:`trunc-note`,children:_(`truncated`)})]})})}let x=Wm(e);if(x)return(0,X.jsx)(qf,{thinking:x.thinking,streaming:i&&a,wrap:s,forceOpen:u||d});let S=Gm(e);if(S){let e={result:t.get(S.id),liveOutput:n.get(S.id)?.text,streaming:i,status:r.get(S.id)};return(0,X.jsx)($p,{block:S,view:e,onKillBash:o,wrap:c,showImages:l??!0,forceOpen:u||f,uiContextToolCall:h,onUiAction:g})}let C=Km(e);if(C&&C.dataUrl){let e=C.dataUrl.startsWith(`/`)?fn(C.dataUrl):C.dataUrl;return(0,X.jsx)(`div`,{className:`msg-image`,children:(0,X.jsx)(`img`,{src:e,loading:`lazy`,decoding:`async`,alt:`attachment`})})}let w=qm(e);return w?(0,X.jsxs)(`div`,{className:`bashblock`,children:[(0,X.jsxs)(`div`,{className:`bashblock-command`,children:[(0,X.jsx)(`span`,{className:`bashblock-prompt`,children:`$`}),(0,X.jsx)(`code`,{children:md(w.command)}),w.exitCode!==void 0&&(0,X.jsx)(`span`,{className:`bashblock-exit ${w.exitCode===0?`ok`:`err`}`,children:_(`exitCode`,{code:w.exitCode})}),w.cancelled&&(0,X.jsx)(`span`,{className:`bashblock-exit err`,children:_(`cancelled`)})]}),w.output&&(0,X.jsx)(`pre`,{className:`bashblock-output`,children:w.output}),w.truncated&&(0,X.jsx)(`div`,{className:`trunc-note`,children:_(`outputTruncated`)})]}):null}function oh(e,t){switch(e){case`user`:return t(`role.user`);case`assistant`:return t(`role.assistant`);case`toolResult`:return t(`role.tool`);case`bashExecution`:return t(`role.bash`);case`branchSummary`:return t(`role.branch`);case`compactionSummary`:return t(`role.compaction`);default:return e}}function sh(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function ch(e,t,n){let r=!1;for(let i of t){let t=i;if(t.type!==`image`||typeof t.dataUrl!=`string`||!t.dataUrl.startsWith(`data:`))continue;let a=t.dataUrl.match(/^data:([^;]*);base64,(.+)$/);a&&(r=!0,e.push({path:``,imageData:a[2],mimeType:a[1]||`image/png`,name:n??`image.${(a[1]||`image/png`).split(`/`)[1]??`png`}`}))}return r}function lh(e){let t=e.details??{};if(t.mode===`quote`){let e=cd(t.quote);return e?{path:``,mode:`quote`,quote:e}:null}let n=[];if(ch(n,e.content,t.name))return n[0]??null;if(t.upload&&t.path)return{path:``,uploadPath:t.path,name:t.name??t.path,size:t.size};if(t.mode===`page`&&t.path)return{path:t.path,mode:`page`,name:t.name??t.path};if(t.mode===`conversation`){let e=t,n=typeof e.conversationId==`string`&&e.conversationId?e.conversationId:void 0,r=typeof e.sessionPath==`string`&&e.sessionPath?e.sessionPath:void 0;return n||r?{path:``,mode:`conversation`,name:t.name??n??r,...n?{conversationId:n}:{},...r?{sessionPath:r}:{}}:null}if(t.path&&t.mode){let e=t.mode===`lines`?`lines`:`reference`,n={path:t.path,mode:e};return t.mode===`lines`&&typeof t.startLine==`number`&&typeof t.endLine==`number`&&(n.lines={start:t.startLine,end:t.endLine}),n}return null}function uh(e){let t=new Map;for(let n=0;n<e.length;n++){let r=e[n];if(r.role!==`user`||!r.id)continue;let i=[];ch(i,r.content);let a=r.details?.quotes;for(let e of Array.isArray(a)?a:[]){let t=cd(e);t&&i.push({path:``,mode:`quote`,quote:t})}let o=[];for(let t=n-1;t>=0&&e[t].role===`custom`&&e[t].customType===`file`;t--){let n=lh(e[t]);n&&o.unshift(n)}i.push(...o);for(let t=n+1;t<e.length&&e[t].role===`custom`&&e[t].customType===`file`;t++){let n=lh(e[t]);n&&i.push(n)}i.length>0&&t.set(r.id,i)}return t}var dh=(0,g.memo)(function({message:e,onExpand:t,summary:n}){let r=Z(),i=Om(),a=Cm(e),o=i.open&&i.selectedIds.includes(e.id),s=i.open&&a,c=n??``;if(!c)for(let t of e.content){let e=Um(t);if(e&&e.text.trim()){let t=sm(e.text);c=t?`skill:${t.name}`+(t.userMessage?` · ${t.userMessage.replace(/\s+/g,` `).trim()}`:``):e.text.replace(/\s+/g,` `).trim();break}}if(!c&&e.role===`custom`&&e.customType===`file`){let t=e.details??{};c=t.name??t.path??``}c.length>90&&(c=`${c.slice(0,90)}…`);let l=0,u=0,d=0,f=0;for(let t of e.content)Wm(t)?l++:Gm(t)?u++:qm(t)?d++:Km(t)&&f++;let p=[];return l&&p.push(`${r(`thinking`)} ${l}`),u&&p.push(`${r(`toolCalls`)} ${u}`),d&&p.push(`${r(`bashRuns`)} ${d}`),f&&p.push(`${r(`images`)} ${f}`),(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,className:`msg-collapsed${o?` msg-export-selected`:``}`,"data-msg-id":e.id,title:`${r(`expandMsg`)} · ${c||p.join(` · `)||e.role}`,onClick:()=>t(e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.id))},children:[s&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:o,title:r(`copyImage`),"aria-label":r(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>Mm(e.id)}),(0,X.jsx)(`span`,{className:`msg-collapsed-role role-${e.role}`,children:e.role===`custom`&&e.customType===`file`?r(`attachment`):oh(e.role,r)}),(0,X.jsxs)(`span`,{className:`msg-collapsed-body`,children:[c&&(0,X.jsx)(`span`,{className:`msg-collapsed-preview`,children:c}),p.length>0&&(0,X.jsx)(`span`,{className:`msg-collapsed-chips`,children:p.map((e,t)=>(0,X.jsx)(`span`,{className:`msg-collapsed-chip`,children:e},t))})]}),e.timestamp?(0,X.jsx)(`span`,{className:`msg-collapsed-time`,children:fh(e.timestamp)}):null,(0,X.jsx)(`span`,{className:`msg-collapsed-action`,children:r(`expandMsg`)})]})});function fh(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}var ph=`[goal-review]`;function mh(e){for(let t of e.content??[]){let e=Um(t);if(e&&e.text.trim())return e.text}return``}function hh(e){if(e.role!==`assistant`)return;let t=mh(e).trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&(e.verdict===`pass`||e.verdict===`fail`))return e.verdict}catch{}let n=t.match(/^\{\s*"verdict"\s*:\s*"(pass|fail)"[^}]*\}$/);return n?n[1]:void 0}function gh(e){if(e.role===`user`&&mh(e).includes(ph))return{kind:`prompt`};let t=hh(e);if(t)return{kind:`verdict`,verdict:t}}var _h=(0,g.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,g.useRef)(null),c=(0,g.useRef)(null);return(0,g.useLayoutEffect)(()=>{let a=c.current;if(c.current=t,!t||a!==!1)return;let o=s.current,l=r.current;if(!o||!l)return;let u=o.offsetHeight;i?.(e,u);let d=u-n;if(d!==0){let e=o.parentElement;e&&e.getBoundingClientRect().bottom<=l.getBoundingClientRect().top&&(l.scrollTop+=d)}},[t]),t?(0,X.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,X.jsx)(`div`,{ref:s,children:o})}):(0,X.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})});function vh(e,t,n,r){let i=[],a=[],o=0;for(let s of e)n.has(s.id)||(s.top<t.bottom&&s.bottom>t.top?r.has(s.id)&&i.push(s.id):r.has(s.id)||(a.push(s.id),s.bottom<=t.top&&(o+=s.bottom-s.top)));return{show:i,hide:a,shrinkAbove:o}}function yh(e,t){if(t.show.length===0&&t.hide.length===0)return e;let n=new Set(e);for(let e of t.show)n.delete(e);for(let e of t.hide)n.add(e);return n}function bh(e,t,n){let r=new Set,i=0;for(let a=e.length-1;a>=0&&!(a<e.length-1&&i>=n);a--){let n=e[a];r.add(n.id),i+=t.get(n.id)??xh(n.role,n.customType)}return r}function xh(e,t){switch(e){case`user`:return 72;case`assistant`:return 280;case`toolResult`:return 8;case`custom`:return t===`file`?96:72;default:return 60}}var Sh=[`text`,`thinking`,`argumentsText`,`output`,`command`];function Ch(e){let t=0;for(let n of e.content){n.type===`image`&&(t+=1);for(let e of Sh){let r=n[e];typeof r==`string`&&(t+=r.length)}}return t}function wh(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Th(e){let t=[];for(let n of e.content)n.type===`text`&&typeof n.text==`string`&&t.push(n.text);return t.join(`
356
+ `)}function Eh(e,t){let n=[];for(let r of e.content)if(r.type===`text`&&typeof r.text==`string`)n.push(r.text);else if(r.type===`thinking`&&typeof r.thinking==`string`)n.push(r.thinking);else if(r.type===`toolCall`){if(typeof r.name==`string`&&n.push(r.name),typeof r.argumentsText==`string`&&n.push(r.argumentsText),typeof r.id==`string`){let e=t.get(r.id);if(e){let t=Th(e);t&&n.push(t)}}}else r.type===`bash`&&(typeof r.command==`string`&&n.push(r.command),typeof r.output==`string`&&n.push(r.output));return n.join(`
357
+ `)}function Dh(e,t){let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}function Oh(e,t,n,r){let i=new Map,a=n.toLowerCase();if(!a)return i;for(let n of e){if(!t.has(n.id))continue;let e=Dh(Eh(n,r).toLowerCase(),a);e>0&&i.set(n.id,e)}return i}function kh(e,t){let n=[],r=t.toLowerCase();if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.closest(`.search-bar`)||t.closest(`.msg-collapsed`)?NodeFilter.FILTER_REJECT:(e.textContent??``).toLowerCase().includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=(e.textContent??``).toLowerCase();if(!e.parentElement?.closest(`[data-msg-id]`))continue;let i=t.indexOf(r);for(;i!==-1;){let a=document.createRange();a.setStart(e,i),a.setEnd(e,i+r.length),n.push(a),i=t.indexOf(r,i+r.length)}}return n}function Ah(e,t,n,r,i){let a=Oh(n,r,t,i),o=new Map;for(let n of kh(e,t)){let e=n.startContainer.parentElement?.closest(`[data-msg-id]`);if(!e?.dataset.msgId)continue;let t=o.get(e.dataset.msgId);t?t.push(n):o.set(e.dataset.msgId,[n])}let s=[];for(let e of n){let t=o.get(e.id);if(t)for(let n=0;n<t.length;n++)s.push({kind:`dom`,range:t[n],msgId:e.id,k:n});let n=a.get(e.id);if(n)for(let t=0;t<n;t++)s.push({kind:`folded`,msgId:e.id,k:t})}return s}function jh(e,t){return e.findIndex(e=>e.msgId===t.msgId&&e.k===t.k)}function Mh(e,t){let n=CSS;if(!n.highlights)return;if(t.length===0){n.highlights.delete(e);return}let r=window.Highlight;r&&n.highlights.set(e,new r(...t))}function Nh(e,t){let n=[],r=e;for(;r&&r!==t;){let e=getComputedStyle(r);/(auto|scroll|hidden)/.test(e.overflowY+e.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function Ph(e,t){let n=t.startContainer.parentElement;for(let r of Nh(n,e)){let e=t.getBoundingClientRect(),n=r.getBoundingClientRect();if(e.height<=0||e.width<=0)return;e.top>=n.top+4&&e.bottom<=n.bottom-4||(r.scrollTop+=e.top-n.top-(r.clientHeight-e.height)/2),e.left>=n.left+4&&e.right<=n.right-4||(r.scrollLeft+=e.left-n.left-(r.clientWidth-e.width)/2)}let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.height<=0||r.width<=0)return;let a=r.top>=i.top+6&&r.bottom<=i.bottom-6,o=r.left>=i.left+6&&r.right<=i.right-6;a&&o||(a||(e.scrollTop+=r.top-i.top-(i.height-r.height)/2),o||(e.scrollLeft+=r.left-i.left-(i.width-r.width)/2))}function Fh({containerRef:e,messages:t,collapsedIds:n,toolResults:r,onExpand:i,onProgrammaticScroll:a,open:o,onClose:s}){let c=Z(),l=(0,g.useRef)(null),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(0),[,_]=(0,g.useState)(0),v=(0,g.useDeferredValue)(u),y=o?v.trim():``,b=(0,g.useRef)(null);b.current=f;let x=(0,g.useRef)([]),S=(0,g.useRef)({key:null}),C=(0,g.useRef)(``);(0,g.useEffect)(()=>{o&&(p(null),requestAnimationFrame(()=>l.current?.select()))},[o]),(0,g.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),s())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,s]),(0,g.useEffect)(()=>(o||(Mh(`msg-search`,[]),Mh(`msg-search-active`,[])),()=>{Mh(`msg-search`,[]),Mh(`msg-search-active`,[])}),[o]),(0,g.useLayoutEffect)(()=>{let s=()=>{h(0),p(null),_(0),x.current=[],Mh(`msg-search`,[]),Mh(`msg-search-active`,[]),S.current={key:null},C.current=``};if(!o||!y){s();return}let c=e.current;if(!c)return;let l=!1,u=0;return u=requestAnimationFrame(()=>{if(l)return;let e=Ah(c,y,t,n,r);x.current=e;let o=e.length;if(h(o),o===0){p(null),_(0),Mh(`msg-search`,[]),Mh(`msg-search-active`,[]),S.current={key:null},C.current=y;return}let s=b.current,u;if(s){if(u=jh(e,s),u===-1){let t=[];for(let n=0;n<e.length;n++)e[n].msgId===s.msgId&&t.push(n);u=t.length>0?t[Math.min(s.k,t.length-1)]:0}}else u=0;u<0&&(u=0),u>=o&&(u=o-1),(!s||s.msgId!==e[u].msgId||s.k!==e[u].k)&&p({msgId:e[u].msgId,k:e[u].k}),_(u);let d=e[u],f=S.current,m=f.key?.msgId!==d.msgId||f.key?.k!==d.k||f.kind===`folded`&&d.kind===`dom`||y!==C.current;if(S.current={key:{msgId:d.msgId,k:d.k},kind:d.kind},C.current=y,Mh(`msg-search`,e.filter(e=>e.kind===`dom`).map(e=>e.range)),d.kind===`folded`){Mh(`msg-search-active`,[]),m&&i(d.msgId);return}Mh(`msg-search-active`,[d.range]),m&&(a?.(),Ph(c,d.range))}),()=>{l=!0,cancelAnimationFrame(u)}},[o,y,t,e,f,n,r,i,a]);let w=(0,g.useCallback)(e=>{let t=x.current,n=t.length;if(n===0)return;let r=b.current,i=t[((r?jh(t,r):0)+e+n)%n];p(i.kind===`dom`||i.kind===`folded`?{msgId:i.msgId,k:i.k}:null)},[]);if(!o)return null;let T=f?(()=>{let e=jh(x.current,f);return e===-1?0:e})():0;return(0,X.jsxs)(`div`,{className:`search-bar`,role:`search`,children:[(0,X.jsx)(`input`,{ref:l,className:`search-input`,type:`text`,value:u,placeholder:c(`searchPlaceholder`),onChange:e=>{d(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w(e.shiftKey?-1:1))}}),(0,X.jsx)(`span`,{className:`search-count ${m===0?`empty`:``}`,children:m===0?c(`searchNoResults`):`${Math.min(T+1,m)}/${m}`}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchPrev`),disabled:m===0,onClick:()=>w(-1),children:(0,X.jsx)(ct,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchNext`),disabled:m===0,onClick:()=>w(1),children:(0,X.jsx)(dt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchClose`),onClick:s,children:(0,X.jsx)(P,{})})]})}function Ih(e){let{dSt:t,dSh:n,escaped:r,graceActive:i,stuck:a}=e;return i||t>=-4||t<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:a&&!r}:{flipEscape:!0,reassert:!1}}var Lh=`pi-web-model-usage`;function Rh(e){if(!e||typeof e!=`object`)return{};let t={};for(let[n,r]of Object.entries(e)){let e=typeof r==`number`?Math.floor(r):0;Number.isFinite(e)&&e>0&&(t[n]=e)}return t}function zh(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Bh(e,t){let n=t;return e.map((e,t)=>({m:e,i:t,count:n[e.id]??0})).sort((e,t)=>t.count-e.count||e.i-t.i).map(e=>e.m)}function Vh(){try{let e=localStorage.getItem(Lh);return e?Rh(JSON.parse(e)):{}}catch{return{}}}function Hh(e){try{localStorage.setItem(Lh,JSON.stringify(e))}catch{}}function Uh(e){let t=zh(Vh(),e);return Hh(t),t}var Wh=[{id:`setup-matt-pocock-skills`,icon:`🛠`,titleKey:`tpl.sk.setup`,descKey:`tpl.sk.setup.desc`,promptKey:`tpl.sk.setup.prompt`},{id:`ask-matt`,icon:`🧭`,titleKey:`tpl.sk.ask`,descKey:`tpl.sk.ask.desc`,promptKey:`tpl.sk.ask.prompt`},{id:`grill-with-docs`,icon:`🗣`,titleKey:`tpl.sk.grilldocs`,descKey:`tpl.sk.grilldocs.desc`,promptKey:`tpl.sk.grilldocs.prompt`},{id:`to-spec`,icon:`📝`,titleKey:`tpl.sk.tospec`,descKey:`tpl.sk.tospec.desc`,promptKey:`tpl.sk.tospec.prompt`},{id:`to-tickets`,icon:`🎫`,titleKey:`tpl.sk.totickets`,descKey:`tpl.sk.totickets.desc`,promptKey:`tpl.sk.totickets.prompt`},{id:`implement`,icon:`🏗`,titleKey:`tpl.sk.implement`,descKey:`tpl.sk.implement.desc`,promptKey:`tpl.sk.implement.prompt`},{id:`code-review`,icon:`🧹`,titleKey:`tpl.sk.codeview`,descKey:`tpl.sk.codeview.desc`,promptKey:`tpl.sk.codeview.prompt`},{id:`wayfinder`,icon:`🗺`,titleKey:`tpl.sk.wayfinder`,descKey:`tpl.sk.wayfinder.desc`,promptKey:`tpl.sk.wayfinder.prompt`},{id:`prototype`,icon:`🔬`,titleKey:`tpl.sk.prototype`,descKey:`tpl.sk.prototype.desc`,promptKey:`tpl.sk.prototype.prompt`},{id:`research`,icon:`📚`,titleKey:`tpl.sk.research`,descKey:`tpl.sk.research.desc`,promptKey:`tpl.sk.research.prompt`},{id:`improve-codebase-architecture`,icon:`🏛`,titleKey:`tpl.sk.arch`,descKey:`tpl.sk.arch.desc`,promptKey:`tpl.sk.arch.prompt`},{id:`diagnosing-bugs`,icon:`🐛`,titleKey:`tpl.sk.debug`,descKey:`tpl.sk.debug.desc`,promptKey:`tpl.sk.debug.prompt`},{id:`resolving-merge-conflicts`,icon:`🔀`,titleKey:`tpl.sk.merge`,descKey:`tpl.sk.merge.desc`,promptKey:`tpl.sk.merge.prompt`},{id:`triage`,icon:`🗂`,titleKey:`tpl.sk.triage`,descKey:`tpl.sk.triage.desc`,promptKey:`tpl.sk.triage.prompt`},{id:`wizard`,icon:`✨`,titleKey:`tpl.sk.wizard`,descKey:`tpl.sk.wizard.desc`,promptKey:`tpl.sk.wizard.prompt`},{id:`grill-me`,icon:`🔍`,titleKey:`tpl.sk.grillme`,descKey:`tpl.sk.grillme.desc`,promptKey:`tpl.sk.grillme.prompt`},{id:`handoff`,icon:`🤝`,titleKey:`tpl.sk.handoff`,descKey:`tpl.sk.handoff.desc`,promptKey:`tpl.sk.handoff.prompt`},{id:`to-questionnaire`,icon:`📋`,titleKey:`tpl.sk.questionnaire`,descKey:`tpl.sk.questionnaire.desc`,promptKey:`tpl.sk.questionnaire.prompt`},{id:`teach`,icon:`🎓`,titleKey:`tpl.sk.teach`,descKey:`tpl.sk.teach.desc`,promptKey:`tpl.sk.teach.prompt`},{id:`wait-what`,icon:`💬`,titleKey:`tpl.sk.ww`,descKey:`tpl.sk.ww.desc`,promptKey:`tpl.sk.ww.prompt`},{id:`writing-for-agents`,icon:`📄`,titleKey:`tpl.sk.wfa`,descKey:`tpl.sk.wfa.desc`,promptKey:`tpl.sk.wfa.prompt`},{id:`codebase-design`,icon:`🧱`,titleKey:`tpl.sk.codesign`,descKey:`tpl.sk.codesign.desc`,promptKey:`tpl.sk.codesign.prompt`},{id:`domain-modeling`,icon:`🏷`,titleKey:`tpl.sk.domain`,descKey:`tpl.sk.domain.desc`,promptKey:`tpl.sk.domain.prompt`},{id:`grilling`,icon:`🔥`,titleKey:`tpl.sk.grilling`,descKey:`tpl.sk.grilling.desc`,promptKey:`tpl.sk.grilling.prompt`},{id:`tdd`,icon:`🧪`,titleKey:`tpl.sk.tdd`,descKey:`tpl.sk.tdd.desc`,promptKey:`tpl.sk.tdd.prompt`}],Gh=`pi-web-ui:prompt-templates`;function Kh(){try{let e=localStorage.getItem(Gh);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`):[]}catch{return[]}}function qh(e){return Wh.some(t=>t.id===e)}function Jh(e){return typeof e.title==`string`}var Yh=(0,g.createContext)(null);function Xh(){let e=(0,g.useContext)(Yh);if(!e)throw Error(`useTemplates must be used within TemplateProvider`);return e}function Zh({children:e,currentModelId:t}){let n=Z(),[r,i]=(0,g.useState)(Kh),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(!1);(0,g.useEffect)(()=>{try{localStorage.setItem(Gh,JSON.stringify(r))}catch{}},[r]);let h=(0,g.useMemo)(()=>{let e=new Map,t=new Set;for(let n of r)n.hidden?t.add(n.id):(Jh(n)&&!qh(n.id)||Jh(n))&&e.set(n.id,n);let i=Wh.filter(e=>!t.has(e.id)).map(t=>{let r=e.get(t.id);return{id:t.id,icon:r?.icon??t.icon,title:r?.title??n(t.titleKey),desc:r?.desc??n(t.descKey),prompt:r?.prompt??n(t.promptKey),builtin:!0}}),a=r.filter(e=>Jh(e)&&!qh(e.id)).map(e=>({id:e.id,icon:e.icon??`📌`,title:e.title??``,desc:e.desc??``,prompt:e.prompt??``}));return[...i,...a]},[r,n]),_=(0,g.useCallback)(()=>o(!0),[]),v=(0,g.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:e}))},[]),y=(0,g.useCallback)((e,t=!1)=>{m(t),e?(u(!1),c({...e})):(u(!0),c({id:jt(),icon:`📌`,title:``,desc:``,prompt:``}))},[]),b=(0,g.useCallback)(()=>{o(!1),c(null),m(!1)},[]),x=(0,g.useCallback)(()=>{d?(i([]),f(!1)):f(!0)},[d]);(0,g.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),5e3);return()=>clearTimeout(e)},[d]);let S=(0,g.useCallback)(e=>{o(!1),v(e.prompt)},[v]),C=(0,g.useCallback)(e=>{o(!1),y(e,!0)},[y]),w=(0,g.useCallback)(()=>{o(!1),y(void 0,!0)},[y]),T=(0,g.useCallback)(e=>{i(t=>{let n=t.findIndex(t=>t.id===e.id);if(n>=0){let r=[...t];return r[n]=e,r}return[...t,e]}),c(null),p&&(o(!0),m(!1))},[p]),E=(0,g.useCallback)(e=>{i(t=>e.builtin?[...t.filter(t=>t.id!==e.id),{id:e.id,hidden:!0}]:t.filter(t=>t.id!==e.id)),c(null),p&&(o(!0),m(!1))},[p]),D=(0,g.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e.id||t.hidden)),c(null),p&&(o(!0),m(!1))},[p]),O=(0,g.useMemo)(()=>({templates:h,fill:v,openPicker:_,openEdit:y,resetConfirm:d,toggleReset:x}),[h,v,_,y,d,x]),k=s?r.some(e=>e.id===s.id&&!e.hidden&&Jh(e)):!1;return(0,X.jsxs)(Yh.Provider,{value:O,children:[e,a&&(0,X.jsx)(eg,{templates:h,resetConfirm:d,onFill:S,onEditTpl:C,onNew:w,onResetToggle:x,onClose:b}),s&&(0,X.jsx)(tg,{editing:s,isNew:l,hasOverride:k,onDraft:c,onSave:T,onRestore:()=>D(s),onRemove:()=>E(s),onFill:()=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:s.prompt})),b()},onSend:()=>{let e=s.prompt.trim();e&&$({type:`prompt`,text:e,queue:!1})&&(t&&Uh(t),b())},onClose:b})]})}function Qh(){let e=Z(),{templates:t,fill:n,openEdit:r,toggleReset:i,resetConfirm:a}=Xh();return(0,X.jsxs)(`div`,{className:`empty-templates`,children:[(0,X.jsxs)(`div`,{className:`empty-templates-head`,children:[(0,X.jsx)(`span`,{className:`empty-templates-title`,children:e(`tpl.title`)}),(0,X.jsx)(`span`,{className:`empty-templates-hint`,children:e(`tpl.hint`)})]}),(0,X.jsxs)(`div`,{className:`empty-templates-grid`,children:[t.map(t=>(0,X.jsx)($h,{tpl:t,title:e(`tpl.clickCard`),onFill:()=>n(t.prompt),onEdit:()=>r(t),editTitle:e(`tpl.editTpl`)},t.id)),(0,X.jsxs)(`button`,{type:`button`,className:`empty-template add`,onClick:()=>r(),title:e(`tpl.add`),children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:(0,X.jsx)(me,{})}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:e(`tpl.add`)}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:e(`tpl.addDesc`)})]})]})]}),(0,X.jsx)(`div`,{className:`empty-templates-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`empty-templates-reset`,onClick:i,children:[(0,X.jsx)(G,{}),e(a?`tpl.resetConfirm`:`tpl.reset`)]})})]})}function $h({tpl:e,title:t,onFill:n,onEdit:r,editTitle:i}){let a=Z();return(0,X.jsxs)(`button`,{type:`button`,className:`empty-template`,title:t,onClick:n,children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:e.icon}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:e.title}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:e.desc})]}),(0,X.jsx)(`span`,{className:`template-card-ops`,role:`button`,title:i??a(`tpl.editTpl`),onClick:e=>{e.stopPropagation(),r()},children:(0,X.jsx)(Ke,{})})]})}function eg({templates:e,resetConfirm:t,onFill:n,onEditTpl:r,onNew:i,onResetToggle:a,onClose:o}){let s=Z();return(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:o,children:(0,X.jsxs)(`div`,{className:`modal template-picker`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`template-picker-top`,children:[(0,X.jsxs)(`div`,{className:`template-picker-head`,children:[(0,X.jsx)(`span`,{className:`template-picker-title`,children:s(`tpl.pickerTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-modal-close`,title:s(`close`),onClick:o,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`div`,{className:`template-picker-hint`,children:s(`tpl.pickerHint`)})]}),(0,X.jsx)(`div`,{className:`template-picker-scroll`,children:(0,X.jsxs)(`div`,{className:`template-picker-grid`,children:[e.map(e=>(0,X.jsx)($h,{tpl:e,title:s(`tpl.clickCard`),onFill:()=>n(e),onEdit:()=>r(e),editTitle:s(`tpl.editTpl`)},e.id)),(0,X.jsxs)(`button`,{type:`button`,className:`empty-template add`,onClick:i,title:s(`tpl.add`),children:[(0,X.jsx)(`span`,{className:`empty-template-icon`,children:(0,X.jsx)(me,{})}),(0,X.jsxs)(`span`,{className:`empty-template-main`,children:[(0,X.jsx)(`span`,{className:`empty-template-title`,children:s(`tpl.add`)}),(0,X.jsx)(`span`,{className:`empty-template-desc`,children:s(`tpl.addDesc`)})]})]})]})}),(0,X.jsx)(`div`,{className:`template-picker-foot`,children:(0,X.jsxs)(`button`,{type:`button`,className:`empty-templates-reset`,onClick:a,children:[(0,X.jsx)(G,{}),s(t?`tpl.resetConfirm`:`tpl.reset`)]})})]})})}function tg({editing:e,isNew:t,hasOverride:n,onDraft:r,onSave:i,onRestore:a,onRemove:o,onFill:s,onSend:c,onClose:l}){let u=Z(),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,g.useEffect)(()=>{let e=d.current;if(!e)return;e.style.height=`auto`;let t=e.scrollHeight>300;e.style.height=`${Math.min(e.scrollHeight,300)}px`,e.style.overflowY=t?`auto`:`hidden`},[e.prompt]);let f=()=>{let t=e.title.trim(),n=e.prompt.trim();if(!t||!n){r({...e,error:u(`tpl.required`)});return}i({id:e.id,icon:e.icon.trim()||`📌`,title:t,desc:e.desc.trim(),prompt:n})},p=!!e.builtin&&!t;return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:l,children:(0,X.jsxs)(`div`,{className:`modal template-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`template-modal-head`,children:[(0,X.jsx)(`span`,{className:`template-modal-icon`,children:e.icon}),(0,X.jsx)(`span`,{className:`template-modal-badge`,children:u(p?`tpl.builtin`:`tpl.custom`)}),(0,X.jsx)(`span`,{className:`template-modal-title`,children:u(t?`tpl.newTitle`:`tpl.editTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-modal-close`,title:u(`close`),onClick:l,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`template-modal-body`,children:[(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldIcon`)}),(0,X.jsx)(`input`,{className:`template-field-input icon`,value:e.icon,maxLength:4,onChange:t=>r({...e,icon:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldTitle`)}),(0,X.jsx)(`input`,{className:`template-field-input`,value:e.title,placeholder:u(`tpl.fieldTitlePh`),onChange:t=>r({...e,title:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldDesc`)}),(0,X.jsx)(`input`,{className:`template-field-input`,value:e.desc,placeholder:u(`tpl.fieldDescPh`),onChange:t=>r({...e,desc:t.target.value})})]}),(0,X.jsxs)(`label`,{className:`template-field`,children:[(0,X.jsx)(`span`,{className:`template-field-label`,children:u(`tpl.fieldPrompt`)}),(0,X.jsx)(`textarea`,{ref:d,className:`template-field-prompt`,value:e.prompt,placeholder:u(`tpl.fieldPromptPh`),onChange:t=>r({...e,prompt:t.target.value})})]})]}),e.error&&(0,X.jsx)(`div`,{className:`template-error`,children:e.error}),(0,X.jsxs)(`div`,{className:`template-modal-actions`,children:[(0,X.jsxs)(`div`,{className:`template-modal-actions-left`,children:[!t&&p&&n&&(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn ghost`,title:u(`tpl.restoreTip`),onClick:a,children:u(`tpl.restore`)}),!t&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.removeTip`),onClick:o,children:[(0,X.jsx)(L,{}),` `,u(`tpl.remove`)]}),!t&&!p&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.deleteTip`),onClick:o,children:[(0,X.jsx)(L,{}),` `,u(`tpl.delete`)]})]}),(0,X.jsxs)(`div`,{className:`template-modal-actions-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn`,onClick:f,children:u(`tpl.save`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn fill`,onClick:s,title:u(`tpl.fillTip`),children:u(`tpl.fill`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn send`,onClick:c,title:u(`tpl.sendTip`),children:[(0,X.jsx)(de,{}),` `,u(`tpl.sendNow`)]})]})]})]})})}var ng=class extends g.Component{state={message:null};static getDerivedStateFromError(e){return{message:e instanceof Error?e.message:String(e)}}componentDidCatch(e,t){console.error(`[ui-slot] entry "${this.props.entryId??this.props.label}" in slot "${this.props.slot??`?`}" crashed:`,e,t.componentStack)}render(){if(this.state.message===null)return this.props.children;let e=`slot=${this.props.slot??`?`} entry=${this.props.entryId??this.props.label}: ${this.state.message}`;return(0,X.jsxs)(`button`,{type:`button`,className:`slot-error`,title:e,"aria-label":this.props.label,onClick:()=>console.error(`[ui-slot] ${e}`),children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`⚠`}),(0,X.jsx)(`span`,{children:this.props.label})]})}};function rg(e,t){return!e||e.length===0?null:(0,X.jsx)(`span`,{className:`slot-toolbar`,children:e.map((e,n)=>(0,X.jsx)(ng,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:ig(e,n,t)},`${e.id}#${n}`))})}function ig(e,t,n){let r=`${e.id}#${t}`,i=e.label||e.id,a=e.hint||i;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`slot-divider`,"aria-hidden":`true`},r):e.kind===`badge`?(0,X.jsx)(`span`,{className:`slot-badge`,title:a,children:e.badge??i},r):e.kind===`toggle`?(0,X.jsxs)(`button`,{type:`button`,className:`slot-btn${e.checked?` on`:``}`,title:a,"aria-label":i,"aria-pressed":!!e.checked,onClick:()=>n?.(e),children:[e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):null,(0,X.jsx)(`span`,{children:i})]},r):e.kind===`progress`?(0,X.jsx)(`span`,{className:`slot-progress`,title:`${a} ${e.progress??0}%`,children:(0,X.jsx)(`progress`,{value:e.progress??0,max:100})},r):e.kind===`input`?(0,X.jsx)(`input`,{className:`slot-input`,defaultValue:e.value??``,placeholder:i,title:a,"aria-label":i,onKeyDown:t=>{t.key===`Enter`&&!t.nativeEvent.isComposing&&n?.(e,t.target.value)}},`${r}:${e.value??``}`):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`slot-select`,title:a,"aria-label":i,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>n?.(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r):(0,X.jsxs)(`button`,{type:`button`,className:`slot-btn`,title:a,"aria-label":i,onClick:()=>n?.(e),children:[e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):null,(0,X.jsx)(`span`,{children:i})]},r)}function ag(e,t,n){let r=[],i=[],a=!1,o=e=>{i.length!==0&&(a=!0,r.push((0,X.jsx)(`span`,{className:`slot-toolbar`,children:i.map((e,t)=>(0,X.jsx)(ng,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:ig(e,t,n)},`${e.id}#${t}`))},e)),i=[])};return e.forEach((e,n)=>{if(e.source===`host`){o(`gap${n}`);let i=t[e.id]??null;i&&(a=!0),r.push((0,X.jsx)(g.Fragment,{children:i},e.id))}else i.push(e)}),o(`tail`),a?(0,X.jsx)(X.Fragment,{children:r}):null}var og=`#ffffff`,sg=`#1e1e1e`,cg=`.msg-actions, .msg-text-copy, .chead-copy, .stream-cursor, .msg-editor, .msg-collapse-btn, .msg-export-check, .toolcall-kill, .toolcall-open`,lg=16384;function ug(e,t=800,n=2){let r=Math.max(e,t,1);return r*n<=lg?n:+(r<=lg)}function dg(e){let t=e.trim().toLowerCase();if(!t)return null;if(t===`transparent`)return{r:0,g:0,b:0,a:0};if(t.startsWith(`#`)){let e=t.slice(1);if(e.length===3||e.length===4){let t=Number.parseInt(e[0]+e[0],16),n=Number.parseInt(e[1]+e[1],16),r=Number.parseInt(e[2]+e[2],16),i=e.length===4?Number.parseInt(e[3]+e[3],16)/255:1;return[t,n,r,i].some(e=>Number.isNaN(e))?null:{r:t,g:n,b:r,a:i}}if(e.length===6||e.length===8){let t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),r=Number.parseInt(e.slice(4,6),16),i=e.length===8?Number.parseInt(e.slice(6,8),16)/255:1;return[t,n,r,i].some(e=>Number.isNaN(e))?null:{r:t,g:n,b:r,a:i}}return null}let n=t.match(/^rgba?\(\s*([\s\S]+)\)$/);if(!n)return null;let r=n[1].trim(),i,a=1;if(r.includes(`/`)){let[e,t]=r.split(`/`);i=e.trim().split(/[\s,]+/).filter(Boolean),a=pg(t.trim())}else if(r.includes(`,`)){let e=r.split(`,`).map(e=>e.trim());e.length===4&&(a=pg(e.pop())),i=e}else i=r.split(/\s+/).filter(Boolean),i.length===4&&(a=pg(i.pop()));if(i.length!==3)return null;let o=fg(i[0]),s=fg(i[1]),c=fg(i[2]);return[o,s,c,a].some(e=>Number.isNaN(e))?null:{r:o,g:s,b:c,a}}function fg(e){return e.endsWith(`%`)?Math.round(mg(Number.parseFloat(e),0,100)*2.55):Math.round(mg(Number.parseFloat(e),0,255))}function pg(e){return e.endsWith(`%`)?mg(Number.parseFloat(e)/100,0,1):mg(Number.parseFloat(e),0,1)}function mg(e,t,n){return Math.min(n,Math.max(t,e))}function hg(e){let t=mg(Math.round(e.r),0,255),n=mg(Math.round(e.g),0,255),r=mg(Math.round(e.b),0,255);return e.a<.996?`rgba(${t}, ${n}, ${r}, ${Math.round(mg(e.a,0,1)*1e3)/1e3})`:`rgb(${t}, ${n}, ${r})`}function gg(e,t){let n=mg(e.a,0,1);return n<=0?{r:t.r,g:t.g,b:t.b,a:t.a}:n>=1?{r:e.r,g:e.g,b:e.b,a:1}:{r:e.r*n+t.r*(1-n),g:e.g*n+t.g*(1-n),b:e.b*n+t.b*(1-n),a:1}}function _g(e,t){let n=dg(t)??{r:255,g:255,b:255,a:1},r=dg(e);return!r||r.a<=.004?hg({...n,a:1}):hg(gg(r,{...n,a:1}))}function vg(e){let t=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*t(e.r)+.7152*t(e.g)+.0722*t(e.b)}function yg(e){return vg(e)>.45}function bg(e){let t=document.createElement(`div`);t.style.cssText=`position:fixed;left:-99999px;top:0;width:8px;height:8px;pointer-events:none;background:${e}`,document.body.appendChild(t);let n=getComputedStyle(t).backgroundColor;return t.remove(),n}function xg(){return getComputedStyle(document.documentElement).colorScheme.split(/\s+/).includes(`light`)?og:sg}function Sg(e){let t=xg(),n=t;try{n=_g(bg(`var(--bg)`),t)}catch{n=t}try{let e=_g(bg(`var(--card-bg, var(--msgs-bg, var(--bg)))`),n),t=dg(e);if(t&&vg(t)+t.a>0)return e}catch{}let r=e??null;for(;r;){let e=getComputedStyle(r).backgroundColor;if(e&&e!==`transparent`&&e!==`rgba(0, 0, 0, 0)`){let t=_g(e,n),r=dg(e);if(r&&r.a>.04)return t}r=r.parentElement}return n}function Cg(e){return e instanceof HTMLElement||e instanceof SVGElement?e.style:null}function wg(e,t){let n=dg(e);return n?n.a<=.004?`transparent`:n.a>=.996?hg({...n,a:1}):hg(gg(n,{...dg(t)??{r:255,g:255,b:255,a:1},a:1})):null}function Tg(e,t,n){let r=getComputedStyle(e),i=Cg(t),a=n;if(i){let e=wg(r.backgroundColor,n);e===`transparent`?i.backgroundColor=`transparent`:e&&(i.backgroundColor=e,a=e);let t=wg(r.color,a);t&&t!==`transparent`&&(i.color=t);for(let[e]of[[`borderTopColor`,`border-top-color`],[`borderRightColor`,`border-right-color`],[`borderBottomColor`,`border-bottom-color`],[`borderLeftColor`,`border-left-color`],[`outlineColor`,`outline-color`],[`textDecorationColor`,`text-decoration-color`]]){let t=wg(r[e],a);t&&t!==`transparent`&&(i[e]=t)}let o=wg(r.fill,a);o&&o!==`transparent`&&r.fill!==`none`&&(i.fill=o);let s=wg(r.stroke,a);s&&s!==`transparent`&&r.stroke!==`none`&&(i.stroke=s),i.backdropFilter=`none`,i.setProperty(`-webkit-backdrop-filter`,`none`),r.mixBlendMode&&r.mixBlendMode!==`normal`&&(i.mixBlendMode=`normal`),i.caretColor=`transparent`}let o=Array.from(e.children),s=Array.from(t.children),c=Math.min(o.length,s.length);for(let e=0;e<c;e++)Tg(o[e],s[e],a)}function Eg(e){e.querySelectorAll(cg).forEach(e=>e.remove())}function Dg(e,t={}){t.includeThinking||e.querySelectorAll(`.thinking`).forEach(e=>e.remove()),t.includeTools||e.querySelectorAll(`.toolcall`).forEach(e=>e.remove())}function Og(e,t,n={}){let r=e.cloneNode(!0);return Tg(e,r,t),Dg(r,n),Eg(r),r.classList.remove(`msg-export-selected`),r.style.margin=`0`,r.style.paddingLeft=``,r.removeAttribute(`id`),r.querySelectorAll(`[id]`).forEach(e=>e.removeAttribute(`id`)),r}async function kg(e,t={}){let{toBlob:n}=await Pc(async()=>{let{toBlob:e}=await import(`./es-DIDZppIF.js`);return{toBlob:e}},[]),r=t.backgroundColor??Sg(e),i=dg(r),a=await n(e,{pixelRatio:t.pixelRatio??2,backgroundColor:r,cacheBust:!1,style:{colorScheme:i&&!yg(i)?`dark`:`light`}});if(!a)throw Error(`toBlob returned null`);return a}function Ag(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function jg(e){return document.querySelector(`.msg[data-msg-id="${Ag(e)}"]`)??document.querySelector(`[data-msg-id="${Ag(e)}"]`)}function Mg(){let e=Z(),t=Om(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(`pi-web-ui`),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(``),y=(0,g.useRef)(null),b=(0,g.useRef)(null),x=(0,g.useRef)(`#ffffff`);if((0,g.useEffect)(()=>{t.open&&(d(!1),h(!1),v(``))},[t.open]),zt(()=>{km()},t.open),(0,g.useLayoutEffect)(()=>{if(!t.open)return;let e=!1,n=0;p(!0);let r=()=>{if(e||!b.current)return;let i=[],a=!1;for(let e of t.selectedIds){let t=jg(e);t?i.push(t):a=!0}let o=t.includeThinking&&i.some(e=>e.querySelector(`.thinking`)&&!e.querySelector(`.thinking-body`))||t.includeTools&&i.some(e=>e.querySelector(`.toolcall`)&&!e.querySelector(`.toolcall-body`));if((a||o)&&n<12){n+=1,requestAnimationFrame(r);return}let s=i[0],c=Sg(s??void 0);x.current=c;let l=document.createDocumentFragment();for(let e of i)l.appendChild(Og(e,c,{includeThinking:t.includeThinking,includeTools:t.includeTools}));b.current.replaceChildren(l);let u=y.current;if(u){u.style.backgroundColor=c;let e=dg(c);if(u.style.colorScheme=e&&!yg(e)?`dark`:`light`,s){let e=getComputedStyle(s).color;e&&(u.style.color=e)}}p(!1)},i=requestAnimationFrame(()=>requestAnimationFrame(r));return()=>{e=!0,cancelAnimationFrame(i),b.current?.replaceChildren()}},[t.open,t.selectedIds,t.includeThinking,t.includeTools]),!t.open)return null;let S=async()=>{let n=y.current;if(n&&!u&&t.selectedIds.length!==0){d(!0),v(``);try{let t=ug(n.scrollHeight,n.scrollWidth);if(t===0){v(e(`exportTooLong`));return}let r=await kg(n,{backgroundColor:x.current,pixelRatio:t});await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),h(!0),window.setTimeout(()=>h(!1),1500)}catch(t){let n=t instanceof Error?t.message:String(t);v(`${e(`copyFailed`)}: ${n}`)}finally{d(!1)}}};return(0,X.jsxs)(`aside`,{className:`saveimg-dock`,role:`dialog`,"aria-label":e(`saveAsImage`),children:[(0,X.jsxs)(`div`,{className:`saveimg-head`,children:[(0,X.jsx)(`span`,{className:`saveimg-title`,children:e(`saveAsImage`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`close`),"aria-label":e(`close`),onClick:()=>km(),children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`p`,{className:`saveimg-hint`,children:e(`exportSelectHint`)}),(0,X.jsxs)(`div`,{className:`saveimg-body`,children:[(0,X.jsx)(`div`,{className:`saveimg-preview`,children:(0,X.jsxs)(`div`,{ref:y,className:`saveimg-card${i?` saveimg-card--border`:``}`,children:[n.trim()?(0,X.jsx)(`div`,{className:`saveimg-card-title`,children:n.trim()}):null,(0,X.jsx)(`div`,{ref:b,className:`saveimg-card-md`}),o&&c.trim()?(0,X.jsx)(`div`,{className:`saveimg-card-wm`,children:c.trim()}):null]})}),(0,X.jsxs)(`div`,{className:`saveimg-options`,children:[(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.includeTools,onChange:e=>jm({includeTools:e.target.checked})}),(0,X.jsx)(`span`,{children:e(`exportIncludeTools`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.includeThinking,onChange:e=>jm({includeThinking:e.target.checked})}),(0,X.jsx)(`span`,{children:e(`exportIncludeThinking`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt`,children:[(0,X.jsx)(`span`,{children:e(`imageTitle`)}),(0,X.jsx)(`input`,{type:`text`,className:`dialog-input saveimg-input`,value:n,onChange:e=>r(e.target.value),placeholder:e(`imageTitlePlaceholder`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),(0,X.jsx)(`span`,{children:e(`imageBorder`)})]}),(0,X.jsxs)(`label`,{className:`saveimg-opt saveimg-opt--toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),(0,X.jsx)(`span`,{children:e(`imageWatermark`)})]}),(0,X.jsx)(`input`,{type:`text`,className:`dialog-input saveimg-input`,value:c,disabled:!o,onChange:e=>l(e.target.value),placeholder:e(`imageWatermarkPlaceholder`)}),(0,X.jsxs)(`div`,{className:`saveimg-copy-row`,children:[(0,X.jsx)(`span`,{className:`saveimg-count`,children:e(`exportSelectedCount`,{n:t.selectedIds.length})}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary saveimg-copy`,onClick:()=>void S(),disabled:u||f||t.selectedIds.length===0,title:e(`copyImageBtn`),children:[u||f?(0,X.jsx)(Ee,{className:`saveimg-spin`}):m?(0,X.jsx)(pt,{}):(0,X.jsx)(tt,{}),(0,X.jsx)(`span`,{children:e(u||f?`savingImage`:m?`copied`:`copyImageBtn`)})]})]})]}),_?(0,X.jsx)(`div`,{className:`saveimg-error`,children:_}):null]})]})}var Ng=`.msg-text, .attachcard-content, .toolcall-output pre, .bashblock-output, .quote-content`,Pg=`button, input, textarea, [contenteditable], .msg-meta, .msg-actions, .chead, .toolcall-output-label`;function Fg(e){return e.nodeType===1?e:e.parentElement}function Ig(e,t,n){if(!t||t.isCollapsed||t.rangeCount!==1)return null;let r=t.getRangeAt(0),i=Fg(r.startContainer),a=Fg(r.endContainer);if(!i||!a||!e.contains(i)||!e.contains(a)||!i.closest(Ng)||!a.closest(Ng)||i.closest(Pg)||a.closest(Pg))return null;let o=i.closest(`.msg[data-msg-id]`);if(!o||o!==a.closest(`.msg[data-msg-id]`))return null;for(let e of o.querySelectorAll(Pg))if(r.intersectsNode(e))return null;let s=t.toString(),c=o.dataset.msgId,l=o.dataset.role;return!s.trim()||!c||!l?null:{text:s,messageId:c,role:l,...n?{sessionId:n}:{}}}function Lg({rootRef:e,sessionId:t,enabled:n=!0,onSelect:r}){let i=Z(),[a,o]=(0,g.useState)(null);return(0,g.useEffect)(()=>{o(null);let i=e.current;if(!i||!n)return;let a=!1,s=0,c=()=>{cancelAnimationFrame(s),o(null)},l=()=>{cancelAnimationFrame(s),s=requestAnimationFrame(()=>{let e=window.getSelection(),n=Ig(i,e,t);if(!n||!e){o(null);return}let a=e.getRangeAt(0).getBoundingClientRect();if(!a.width&&!a.height){o(null);return}r?.(),o({quote:n,left:Math.max(8,Math.min(a.right-88,window.innerWidth-96)),top:Math.max(8,Math.min(a.top>=44?a.top-40:a.bottom+8,window.innerHeight-42))})})},u=e=>{e.target?.closest?.(`.quote-selection-button`)||(a=e.button===0&&i.contains(e.target),c())},d=e=>{a=!1,e.button===0&&l()},f=()=>{a||l()},p=e=>{e.key===`Escape`&&c()};return document.addEventListener(`mousedown`,u),document.addEventListener(`mouseup`,d),document.addEventListener(`selectionchange`,f),document.addEventListener(`keydown`,p),window.addEventListener(`scroll`,c,!0),window.addEventListener(`resize`,c),window.addEventListener(`blur`,c),()=>{cancelAnimationFrame(s),document.removeEventListener(`mousedown`,u),document.removeEventListener(`mouseup`,d),document.removeEventListener(`selectionchange`,f),document.removeEventListener(`keydown`,p),window.removeEventListener(`scroll`,c,!0),window.removeEventListener(`resize`,c),window.removeEventListener(`blur`,c)}},[e,t,n,r]),!a||!n||a.quote.sessionId!==t?null:(0,j.createPortal)((0,X.jsxs)(`button`,{type:`button`,className:`quote-selection-button`,style:{left:a.left,top:a.top},onMouseDown:e=>e.preventDefault(),onClick:()=>{lr({attachments:[{path:``,name:i(`quoteText`),mode:`quote`,quote:a.quote,key:jt()}]})&&(o(null),window.getSelection()?.removeAllRanges(),sr())},children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`↪`}),` `,i(`quoteSelection`)]}),document.body)}var Rg=new Map,zg=15,Bg=5,Vg=100,Hg=30,Ug=250,Wg=1200,Gg=1600;function Kg({kind:e,text:t,index:n,onRemoveQueued:r,onRecallQueued:i}){let a=Z(),o=ud(t);return(0,X.jsxs)(`div`,{className:`msg msg-user msg-queued`,"data-role":`user`,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:a(`role.user`)}),(0,X.jsx)(`span`,{className:`queued-tag ${e===`steer`?`steer`:`follow`}`,children:a(e===`steer`?`queueSteerTag`:`queueFollowTag`)}),(0,X.jsxs)(`div`,{className:`msg-queued-actions`,children:[i&&(0,X.jsx)(`button`,{type:`button`,className:`msg-queued-recall`,title:a(`queueRecallTip`),"aria-label":a(`queueRecallTip`),onClick:()=>i(e,t,n),children:`↩`}),r&&(0,X.jsx)(`button`,{type:`button`,className:`msg-queued-remove`,title:a(`queueRemoveTip`),"aria-label":a(`queueRemoveTip`),onClick:()=>r(e,t,n),children:`✕`})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:(0,X.jsxs)(`div`,{className:`msg-text`,children:[o.quotes.map((e,t)=>(0,X.jsx)(hd,{quote:e},`quote-${t}`)),(0,X.jsx)(Af,{text:o.text,hardBreaks:!0})]})})]})}function qg({compaction:e}){let t=Z(),[,n]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=setInterval(()=>n(e=>e+1),1e3);return()=>clearInterval(e)},[]);let r=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3)),i=e.reason===`manual`?t(`compactingReasonManual`):e.reason===`overflow`?t(`compactingReasonOverflow`):t(`compactingReasonThreshold`);return(0,X.jsxs)(`div`,{className:`compact-notice`,role:`status`,children:[(0,X.jsx)(`span`,{className:`compact-pulse`}),(0,X.jsxs)(`span`,{className:`compact-text`,children:[t(`compactingContext`),` · `,r,`s`]}),(0,X.jsx)(`span`,{className:`compact-reason`,children:i})]})}function Jg(e){return e.content.some(e=>e.type===`toolCall`)}function Yg({state:e,liveOutputs:t,toolStatuses:n,onEdit:r,onKillBash:i,onRetry:a,onRemoveQueued:o,onRecallQueued:s,thinkingWrap:c,toolsWrap:l,toolImages:u,keepRecent:d,jumpTarget:f,onJumpDone:p,urlJumpMessageId:m,onUrlJumpDone:h,uiMessageActions:_,uiContextMessage:v,uiContextToolCall:y,uiChatEmpty:b,onUiAction:x}){let S=Z(),C=Om(),w=(0,g.useRef)(null),[T,E]=(0,g.useState)(!0),D=(0,g.useRef)(!0),O=(0,g.useRef)(0),k=(0,g.useRef)(0),A=(0,g.useRef)(!1),ee=(0,g.useCallback)(()=>{A.current=!0,D.current=!1,E(!1)},[]),M=(0,g.useRef)(0),[te,N]=(0,g.useState)(()=>new Set),[P,ne]=(0,g.useState)(!1),F=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,re=(0,g.useMemo)(()=>{let t=new Map;for(let n of e.messages)n.role===`toolResult`&&n.toolCallId&&t.set(n.toolCallId,n);return t},[e.messages]),ie=(0,g.useMemo)(()=>uh(e.messages),[e.messages]),ae=[...F].reverse().find(e=>e.role!==`system`),I=ae?ae.id:null,L=Math.min(Vg,Math.max(Bg,Math.floor(Number(d)||zg))),R=Math.max(L*2,Hg),z=e.messages.length>R?Math.max(0,e.messages.length-L):0,oe=(0,g.useMemo)(()=>{let t=new Set;for(let n=0;n<z;n++){let r=e.messages[n];r.role!==`toolResult`&&(te.has(r.id)||t.add(r.id))}return t},[e.messages,z,te]),[B,V]=(0,g.useState)(()=>new Set),[H,se]=(0,g.useState)(()=>new Set),ce=(0,g.useRef)(new Map),le=(0,g.useRef)(new Map),ue=(0,g.useRef)(new Map),U=(0,g.useRef)(0),de=(0,g.useMemo)(()=>{let t=new Map;for(let n of e.messages)t.set(n.id,Ch(n));return t},[e.messages]),fe=(0,g.useRef)(de);fe.current=de;let W=(0,g.useRef)(B);W.current=B;let pe=e.messages.length>Hg&&!P,G=(0,g.useRef)(pe);G.current=pe;let K=bh(e.messages,ce.current,Gg),me=(0,g.useRef)(K);me.current=K;let he=(0,g.useCallback)(()=>{let e=w.current;if(!e)return;if(!G.current){V(e=>e.size?new Set:e);return}let t=e.getBoundingClientRect(),n={top:t.top-Wg,bottom:t.bottom+Wg},r=[];for(let[e,t]of ue.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),W.current.has(e)||_e(e,n.bottom-n.top,fe.current.get(e))}let i=vh(r,n,me.current,W.current);for(let e of i.hide){let t=ue.current.get(e);t&&_e(e,t.offsetHeight,fe.current.get(e))}V(e=>yh(e,i))},[]),ge=(0,g.useCallback)(()=>{U.current||=requestAnimationFrame(()=>{U.current=0,he()})},[he]);(0,g.useLayoutEffect)(()=>{he()},[he,e.conversationId,e.sessionFile,e.messages.length]);let q=(0,g.useRef)(P);(0,g.useLayoutEffect)(()=>{q.current&&!P&&he(),q.current=P},[P,he]);let _e=(0,g.useCallback)((e,t,n)=>{n!==void 0&&(le.current.set(e,{h:t,len:n}),ce.current.set(e,t))},[]),ve=(0,g.useCallback)((e,t)=>{_e(e,t,fe.current.get(e))},[_e]),ye=(0,g.useCallback)(e=>{e&&ue.current.set(e.dataset.lazyId??``,e)},[]);(0,g.useEffect)(()=>{let t=new Set(e.messages.map(e=>e.id));for(let e of ue.current.keys())t.has(e)||(ue.current.delete(e),ce.current.delete(e),le.current.delete(e));V(e=>{let n=!1,r=new Set;for(let i of e)t.has(i)?r.add(i):n=!0;return n?r:e})},[e.messages,te]),(0,g.useEffect)(()=>()=>cancelAnimationFrame(U.current),[]);let be=(0,g.useMemo)(()=>{let t=[];for(let n of e.messages){if(n.role!==`user`)continue;let e=n.content.map(e=>Um(e)?.text??``).filter(Boolean).join(` `),r=sm(e),i=r?r.userMessage??`skill:${r.name}`:e.trim();i&&t.push({id:n.id,text:i})}return t},[e.messages]),xe=(0,g.useMemo)(()=>{let e=new Map;return be.forEach((t,n)=>e.set(t.id,n)),e},[be]),[J,Se]=(0,g.useState)(-1),Ce=(0,g.useRef)(-1),we=(0,g.useRef)(be);(0,g.useEffect)(()=>{we.current=be},[be]);let Te=(0,g.useCallback)(()=>{let e=w.current,t=we.current;if(!e||t.length===0)return;let n=e.getBoundingClientRect().top,r=-1;for(let i=0;i<t.length;i++){let a=e.querySelector(`[data-msg-id="${t[i].id}"]`);if(a){if(a.getBoundingClientRect().top<=n+140)r=i;else break}}r!==Ce.current&&(Ce.current=r,Se(r))},[]);(0,g.useEffect)(()=>{Te()},[be,Te]);let Ee=(0,g.useCallback)(e=>{N(t=>t.has(e)?t:new Set(t).add(e))},[]);(0,g.useLayoutEffect)(()=>{Tm(e.messages.filter(Cm).map(e=>({id:e.id,role:e.role,content:e.content})))},[e.messages]),(0,g.useEffect)(()=>{if(C.open){for(let e of C.selectedIds)Ee(e);se(e=>{let t=!1,n=new Set(e);for(let e of C.selectedIds)n.has(e)||(n.add(e),t=!0);return t?n:e})}},[C.open,C.selectedIds,Ee]),(0,g.useEffect)(()=>{let e=e=>{if(!(e.ctrlKey||e.metaKey)||e.key.toLowerCase()!==`f`)return;let t=e.target;(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable)&&(e.preventDefault(),ne(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let De=(0,g.useCallback)(e=>{N(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Oe=(0,g.useCallback)(t=>{let n=e.messages.findIndex(e=>e.id===t);(0,j.flushSync)(()=>{n>=0&&n<z&&!te.has(t)&&Ee(t),se(e=>e.has(t)?e:new Set(e).add(t))});let r=we.current.findIndex(e=>e.id===t);Ce.current=r,Se(r),requestAnimationFrame(()=>{let e=w.current?.querySelector(`[data-msg-id="${t}"]`);e&&(w.current?.querySelectorAll(`.msg-flash`).forEach(e=>e.classList.remove(`msg-flash`)),e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),e!==w.current?.lastElementChild&&(A.current=!0))})},[e.messages,z,te,Ee]),[ke,Ae]=(0,g.useState)(null),je=(0,g.useRef)(null),Me=(0,g.useRef)(null);(0,g.useEffect)(()=>{let t=je.current;if(!t||t.convId!==e.conversationId){je.current={convId:e.conversationId,ids:new Set(e.messages.filter(e=>e.role===`compactionSummary`).map(e=>e.id))},Me.current=null,Ae(null);return}for(let n of e.messages)if(n.role===`compactionSummary`&&!t.ids.has(n.id)){t.ids.add(n.id),Ae(n.id);break}},[e.messages,e.conversationId]),(0,g.useEffect)(()=>{ke&&Me.current!==ke&&(Me.current=ke,Oe(ke))},[ke,Oe]);let Ne=(0,g.useMemo)(()=>f?e.messages.find(e=>e.role===f.role&&e.timestamp===f.timestamp)?.id??null:null,[e.messages,f]);(0,g.useEffect)(()=>{if(f){if(Ne){Oe(Ne),p?.();return}e.sessionFile===f.path&&e.messages.length>0&&p?.()}},[Ne,Oe,p,f,e.sessionFile,e.messages.length]),(0,g.useEffect)(()=>{if(!m)return;let t=is(e.messages,m);if(t){Oe(t),h?.();return}e.messages.length>0&&h?.()},[m,e.messages,Oe,h]);let Pe=(0,g.useCallback)(()=>{let e=w.current;if(!e)return;let t=e.scrollTop-O.current,n=e.scrollHeight-k.current;O.current=e.scrollTop,k.current=e.scrollHeight;let r=e.scrollHeight-e.scrollTop-e.clientHeight<80,i=Date.now()<M.current,a=Ih({dSt:t,dSh:n,escaped:A.current,graceActive:i,stuck:D.current});a.reassert&&(M.current=Date.now()+Ug,e.scrollTop=e.scrollHeight),a.flipEscape&&(A.current=!0),r&&t>=0&&(A.current=!1),i||(t<0?D.current=r&&!A.current:r&&(D.current=!0)),E(D.current),Te(),ge()},[Te,ge]),Fe=(0,g.useRef)(!1);(0,g.useEffect)(()=>{let t=Fe.current;if(Fe.current=!!e.isStreaming,t&&!e.isStreaming&&!A.current){let e=()=>{let e=w.current;e&&!A.current&&(e.scrollTop=e.scrollHeight,D.current=!0,E(!0))};requestAnimationFrame(()=>requestAnimationFrame(e));let t=setTimeout(e,180);return()=>clearTimeout(t)}},[e.isStreaming]),(0,g.useEffect)(()=>{let e=w.current;e&&D.current&&(e.scrollTop=e.scrollHeight)},[F,e.isStreaming,t]);let Ie=e.queue.steering.join(`\0`)+``+e.queue.followUp.join(`\0`);(0,g.useEffect)(()=>{let e=w.current;e&&D.current&&(e.scrollTop=e.scrollHeight)},[Ie]),(0,g.useEffect)(()=>{let e=w.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.clientHeight,n=new ResizeObserver(()=>{let n=e.clientHeight,r=n-t;t=n,r>0&&(e.scrollTop=Math.min(e.scrollTop,e.scrollHeight-e.clientHeight))});return n.observe(e),()=>n.disconnect()},[]),(0,g.useEffect)(()=>{let e=w.current;if(!e||typeof MutationObserver>`u`)return;let t=!1,n=new MutationObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let e=w.current;e&&D.current&&!A.current&&(e.scrollTop=e.scrollHeight,E(!0))}))});return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[]);let Le=(0,g.useCallback)(()=>{if(!w.current)return;D.current=!0,A.current=!1,E(!0),M.current=Date.now()+Ug;let e=()=>{let e=w.current;e&&D.current&&!A.current&&(M.current=Date.now()+Ug,e.scrollTop=e.scrollHeight)};e(),requestAnimationFrame(()=>requestAnimationFrame(e)),setTimeout(e,120),setTimeout(e,300),setTimeout(e,600)},[]),Re=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=Re.current,t=w.current;if(!e||!t)return;let n=n=>{n.preventDefault();let r=e.querySelector(`.qn-list`);if(r&&r.contains(n.target)&&r.scrollHeight>r.clientHeight){r.scrollTop+=n.deltaY;return}t.scrollTop+=n.deltaY};return e.addEventListener(`wheel`,n,{passive:!1}),()=>e.removeEventListener(`wheel`,n)},[]);let[ze,Be]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=()=>{Be(w.current?.clientHeight??0),ge()};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[ge]);let Ve=be.length,He=(0,g.useMemo)(()=>Ve===0?27:Math.max(4,Math.min(27,Math.floor(((ze||600)-16)/Ve)-3)),[Ve,ze]),Ue=He<20;return(0,X.jsxs)(`div`,{className:`messages-wrap${C.open?` messages-exporting`:``}`,children:[(0,X.jsx)(Lg,{rootRef:w,sessionId:e.sessionId,enabled:!C.open,onSelect:ee}),(0,X.jsxs)(`div`,{className:`messages${P||T?``:` anchor-live`}`,ref:w,onScroll:Pe,children:[e.messages.length===0&&!e.streamingMessage&&(0,X.jsxs)(`div`,{className:`empty-state`,children:[(0,X.jsx)(Qh,{}),b&&b.length>0&&(0,X.jsx)(`div`,{className:`chat-empty-slots`,children:rg(b,x)})]}),e.messages.map((o,s)=>{if(o.role===`system`)return null;let d=gh(o);if(d&&!te.has(o.id))return(0,X.jsx)(dh,{message:o,onExpand:Ee,summary:d.kind===`prompt`?S(`goalBarReviewing`):d.verdict===`pass`?S(`goalBarPassed`):S(`goalBarFailed`)},o.id);let f=s<z,p=f&&te.has(o.id);if(f&&!p)return o.role===`toolResult`?null:(0,X.jsx)(dh,{message:o,onExpand:Ee},o.id);let m=o.role===`user`?xe.get(o.id):void 0,h=!pe||K.has(o.id)||H.has(o.id)||!B.has(o.id);return(0,X.jsx)(_h,{id:o.id,show:h,height:wh(o.id,de.get(o.id)??-1,le.current,xh(o.role,o.customType)),containerRef:w,onMeasured:ve,lazyRef:ye,children:(0,X.jsx)($m,{uiMessageActions:_,uiContextMessage:v,uiContextToolCall:y,onUiAction:x,message:o,qnIndex:m,qnActive:m===void 0?void 0:m===J,onJump:Oe,toolResults:re,liveOutputs:Jg(o)?t:Rg,toolStatuses:n,streaming:e.isStreaming,onKillBash:i,onRetry:o.id===I?a:void 0,toolsWrap:l,toolImages:u,thinkingWrap:c,isLast:o.id===I,onEdit:r,questionAttachments:ie.get(o.id),onCollapse:p?De:void 0,searchActive:P,autoExpand:o.id===ke},o.id)},o.id)}),e.streamingMessage&&(0,X.jsx)($m,{uiMessageActions:_,uiContextMessage:v,uiContextToolCall:y,onUiAction:x,message:e.streamingMessage,toolResults:re,liveOutputs:Jg(e.streamingMessage)?t:Rg,toolStatuses:n,streaming:!0,isLast:!0,onEdit:r,onKillBash:i,toolsWrap:l,toolImages:u,thinkingWrap:c,searchActive:P},e.streamingMessage.id),e.retry&&e.isStreaming&&(0,X.jsxs)(`div`,{className:`retry-notice`,role:`status`,title:e.retry.errorMessage||void 0,children:[(0,X.jsx)(`span`,{className:`retry-pulse`}),(0,X.jsx)(`span`,{className:`retry-text`,children:e.retry.maxAttempts>0?S(`retryingApi`,{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):S(`retryingApiSoon`,{error:e.retry.errorMessage})})]}),e.compaction&&(0,X.jsx)(qg,{compaction:e.compaction}),e.isStreaming&&F.length===0&&(0,X.jsx)(`div`,{className:`streaming-wait`,children:S(`waitingResponse`)}),e.queue.steering.map((e,t)=>(0,X.jsx)(Kg,{kind:`steer`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-steer-${t}`)),e.queue.followUp.map((e,t)=>(0,X.jsx)(Kg,{kind:`followUp`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-fu-${t}`)),e.actionSuggestions&&e.actionSuggestions.length>0&&(0,X.jsx)(`div`,{className:`action-suggestions`,"aria-label":S(`actionSuggestions`),children:(0,X.jsx)(`div`,{className:`action-suggestions-list`,children:e.actionSuggestions.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`action-suggestion-chip`,title:t.prompt===t.label?t.label:S(`actionSuggestionsTip`,{prompt:t.prompt}),disabled:e.isStreaming,onClick:()=>{$({type:`prompt`,text:t.prompt})},children:[(0,X.jsx)(`span`,{className:`action-suggestion-label`,children:t.label}),(0,X.jsx)(`span`,{className:`action-suggestion-icon`,"aria-hidden":`true`,children:`↵`})]},t.id))})})]}),!T&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,title:S(`backToBottom`),"aria-label":S(`backToBottom`),onClick:Le,children:[(0,X.jsx)(xt,{}),(0,X.jsx)(`span`,{className:`scroll-bottom-label`,children:S(`backToBottom`)})]}),(0,X.jsx)(Fh,{containerRef:w,messages:F,collapsedIds:oe,toolResults:re,onExpand:Ee,onProgrammaticScroll:()=>{A.current=!0,D.current=!1,E(!1)},open:P,onClose:()=>ne(!1)}),be.length>0&&(0,X.jsxs)(`div`,{className:`qn-rail ${Ue?`many`:``}`,ref:Re,"aria-label":S(`questionNavTitle`),style:{"--rail-gap":`${He}px`},children:[be.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`qn-bar ${t===J?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Oe(e.id),children:(0,X.jsxs)(`span`,{className:`qn-bar-text`,children:[t+1,`. `,e.text]})},e.id)),Ue&&(0,X.jsx)(`div`,{className:`qn-list`,children:be.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`qn-list-item ${t===J?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Oe(e.id),children:[(0,X.jsx)(`span`,{className:`qn-list-idx`,children:t+1}),(0,X.jsx)(`span`,{className:`qn-list-text`,children:e.text})]},e.id))})]}),(0,X.jsx)(Mg,{})]})}function Xg(e,t){return t?e.trim()?`${e.replace(/\s+$/,``)}\n${t}`:t:e}function Zg(e,t,n){let r=null;return e&&e.text&&e.ts>0&&(r={text:e.text,ts:e.ts}),t&&t.text&&t.ts>(r?.ts??0)&&(r=t),!r||r.ts<=n?null:r}function Qg(e){return e.mode===`quote`&&e.quote?`quote:${JSON.stringify([e.quote.sessionId??``,e.quote.messageId,e.quote.role,e.quote.text])}`:e.key?`key:${e.key}`:e.mode===`conversation`?e.conversationId?`conv:id:${e.conversationId}`:e.sessionPath?`conv:path:${e.sessionPath}`:null:e.path?`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`:null}function $g(e,t){return t?e?{key:t,clear:e!==t}:{key:t,clear:!1}:{key:e,clear:!1}}function e_(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=new Set(e.map(Qg).filter(e=>e!==null)),r=[...e];for(let e of t){let t=Qg(e);if(t!==null){if(n.has(t))continue;n.add(t)}r.push(e)}return r}function t_(e,t,n){return!(!e||!e.trim()||t>0||n)}function n_(e,t){if(!t||!t.trim())return!1;let n=e.trim();return!(!n||n===t.trim())}function r_(e,t,n){switch(n){case`cancel`:return null;case`append`:return Xg(e,t);case`overwrite`:return t}}function i_(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var a_=`​`;function o_(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function s_(e,t){return{first:!e.slice(0,t).includes(`
358
358
  `),last:!e.slice(t).includes(`
359
- `)}}var Yg=null;function Xg(){if(Yg?.isConnected)return Yg;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),Yg=e,e}function Zg(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function Qg(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=Kg,e.appendChild(n),n.offsetTop}function $g(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=Jg(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=Xg();if(Zg(e,i)<=0)return r;let a=Qg(i,t.slice(0,n)),o=Qg(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:qg(a,o,Gg(e))}function e_(e,t){let n=[],r=e?.length??0;for(let t=0;t<r;t++){let r=e?.[t];if(!r||r.kind!==`file`)continue;let i=r.getAsFile();i&&n.push(i)}if(n.length===0&&t)for(let e=0;e<t.length;e++){let r=t[e];r&&n.push(r)}return n}var t_=`pi-web-ui:prompt-history`,n_=`pi-web-ui:prompt-history-settings`,r_={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function i_(e){let t=r_;if(!e||typeof e!=`object`)return{...t};let n=e,r=typeof n.maxEntries==`number`?Math.floor(n.maxEntries):t.maxEntries;(!Number.isFinite(r)||r<1)&&(r=1),r>500&&(r=500);let i=typeof n.charLimit==`number`?Math.floor(n.charLimit):t.charLimit;(!Number.isFinite(i)||i<100)&&(i=100),i>2e4&&(i=2e4);let a=typeof n.charLimitEnabled==`boolean`?n.charLimitEnabled:t.charLimitEnabled;return{maxEntries:r,charLimitEnabled:a,charLimit:i}}function a_(){try{let e=localStorage.getItem(n_);return e?i_(JSON.parse(e)):{...r_}}catch{return{...r_}}}function o_(e){let t=i_(e);try{localStorage.setItem(n_,JSON.stringify(t))}catch{}try{let e=l_();t.charLimitEnabled&&(e=e.map(e=>e.length>t.charLimit?e.slice(0,t.charLimit):e)),e.length>t.maxEntries&&(e=e.slice(e.length-t.maxEntries)),u_(e)}catch{}}function s_(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function c_(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function l_(){try{let e=localStorage.getItem(t_);return e?s_(JSON.parse(e)):[]}catch{return[]}}function u_(e){let t=e;for(;t;)try{localStorage.setItem(t_,JSON.stringify(t));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||t.length<=1)return;t=t.slice(Math.ceil(t.length/2))}}function d_(e){let t=e.trim();if(!t)return;let n=a_();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));let r=l_(),i=c_(r,t,n.maxEntries);i!==r&&u_(i)}function f_(){try{localStorage.removeItem(t_)}catch{}}var p_=`skill:`;function m_(e,t){let n=e.toLowerCase();return t===`skill`&&n.startsWith(`skill:`)?[n,n.slice(6)]:[n]}function h_(e,t){let n=t.toLowerCase();return n?e.filter(e=>m_(e.name,e.source).some(e=>e.startsWith(n))):[...e]}var g_=new Set([`p`,`page`,`pages`,`web`,`网页`,`页面`]);function __(e,t,n,r=10){if(!Array.isArray(t))return[];let i=String(n??``).toLowerCase(),a=i===``||g_.has(i),o=[];for(let n of t){if(!n||typeof n.origin!=`string`||!n.origin||n.open!==!0)continue;let t=typeof n.title==`string`&&n.title.trim()?n.title.trim():n.origin;if(!a&&!t.toLowerCase().includes(i)&&!n.origin.toLowerCase().includes(i))continue;let s=t.indexOf(` · `),c=s===-1?`page · ${t}`:`page · ${t.slice(s+3)}`;if(o.push({providerId:`host:pages`,providerLabel:e,title:c,hint:n.origin,text:t,attachments:[{path:n.origin,name:t,mode:`page`}]}),o.length>=Math.max(0,r))break}return o}function v_(e,t,n=10){if(!Array.isArray(t))return[];let r=[];for(let i of t.slice(0,Math.max(0,n))){if(!i||typeof i!=`object`)continue;let t=i;typeof t.path==`string`&&t.path&&typeof t.name==`string`&&t.name&&r.push({providerId:`host:files`,providerLabel:e,title:t.name,hint:t.path,text:`@${t.path}`,attachments:[{path:t.path,name:t.name,mode:`reference`,...t.type===`dir`?{isDir:!0}:{}}]})}return r}function y_(e,t,n,r=10){if(!Array.isArray(n))return[];let i=[];for(let a of n.slice(0,Math.max(0,r))){if(!a||typeof a!=`object`)continue;let n=a;if(typeof n.title!=`string`||!n.title.trim())continue;let r=Array.isArray(n.attachments)?n.attachments.filter(e=>!!e&&typeof e==`object`&&typeof e.path==`string`).slice(0,4).map(e=>{let t=e.mode;return{path:e.path,...typeof e.name==`string`?{name:e.name}:{},...t===`inline`||t===`reference`||t===`lines`||t===`page`?{mode:t}:{},...typeof e.isDir==`boolean`?{isDir:e.isDir}:{}}}):void 0;i.push({providerId:e,providerLabel:t,title:n.title.trim(),...typeof n.hint==`string`&&n.hint?{hint:n.hint}:{},...typeof n.text==`string`&&n.text?{text:n.text}:{},...r?.length?{attachments:r}:{}})}return i}function b_(e,t,n,r=15,i){if(!Array.isArray(t)||r<=0)return[];let a=String(n??``).toLowerCase(),o=a.startsWith(p_),s=o?a.slice(p_.length):a,c=[],l=[],u=o||s.length>=3;for(let n of t){if(n.source!==`skill`)continue;let t=n.name.startsWith(`skill:`)?n.name.slice(p_.length):n.name,r=t.toLowerCase(),a=i?i(n):n.description??``,o=a.toLowerCase(),d=(n.descriptionEn??``).toLowerCase(),f={providerId:`host:skills`,providerLabel:e,title:t,hint:a||`Skill ${t}`,text:`@skill:${t}`};s?r.includes(s)?c.push(f):u&&(o.includes(s)||d.includes(s))&&l.push(f):c.push(f)}return[...c,...l].slice(0,Math.max(0,r))}function x_(e,t,n=30){let r=String(t??``).toLowerCase(),i=e.pages??[],a=e.skills??[],o=e.files??[],s=e.plugins??[],c;return c=r.startsWith(`skill:`)?[...a,...i,...o,...s]:[...i,...a,...o,...s],c.slice(0,Math.max(0,n))}function S_(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function C_(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!S_(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function w_(e){let t=e.query;if(!t||!t(`(pointer: coarse)`)||!t(`(hover: none)`))return!1;let n=e.userAgent??``;return!(/Windows|CrOS/i.test(n)||/Linux/i.test(n)&&!/Android/i.test(n)||/Macintosh/i.test(n)&&(e.maxTouchPoints??0)<=1)}function T_(){return typeof window>`u`||typeof navigator>`u`||typeof window.matchMedia!=`function`?!1:w_({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}function E_(e,t,n){if(t<=0||!e)return null;let r=null;for(let t of n){let n=[t.mode===`page`||t.mode===`conversation`?t.name:t.path,t.name].filter(e=>typeof e==`string`&&e.trim().length>0);for(let i of n){let n=`@`+i,a=e.endsWith(n+` `);if(a||e.endsWith(n)){let e=n.length;(!r||e>r.tokenLen)&&(r={attachment:t,tokenLen:e,withSpace:a})}}}let i=-1,a=r?.attachment;if(r){let n=t-(r.withSpace?r.tokenLen+1:r.tokenLen);n>0&&/[\w.\-/]/.test(e[n-1])?(i=-1,a=void 0):i=n}if(i<0){let r=/(^|[\s(("'"“‘[【])(@[^\s@,.;:!?,。!?)\]】」]+)(\s?)$/.exec(e);if(r){i=t-r[2].length-r[3].length;let o=e.slice(i,t).trim().replace(/^@/,``),s=o.split(`/`).pop()??o;a=n.find(e=>e.path&&e.path===o)??n.find(e=>e.name&&e.name===o)??n.find(e=>e.mode!==`page`&&e.mode!==`conversation`&&e.name===s)}}return i>=0&&i<t?{tokenStart:i,...a?{attachment:a}:{}}:null}function D_(e,t=0,n=Date.now()){return!!(e.isComposing||e.keyCode===229||t>0&&n-t<50)}function O_(){let e=(0,g.useRef)(0);return{onCompositionEnd:()=>{e.current=Date.now()},isImeKey:t=>D_(t,e.current)}}var k_=1;function A_(){return++k_}var j_=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],M_=(0,g.memo)(function({state:e,models:t,modelsLoading:n,onManageModels:r,providerKeys:i,defaultModel:a,compact:o=!1,only:s}){let c=Z(),l=e?.model,u=l?`${l.provider}/${l.id}`:null,[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(null),[b,x]=(0,g.useState)({}),S=(0,g.useRef)(null),C=(0,g.useRef)(null),[w,T]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!d){T(null);return}if(t.length===0)return;let e=requestAnimationFrame(()=>{let e=C.current;e&&T(e.offsetWidth)});return()=>cancelAnimationFrame(e)},[d,t.length]),(0,g.useEffect)(()=>{d&&x(Oh())},[d]),(0,g.useEffect)(()=>{d||(_(``),y(null))},[d]);let E=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.provider,(e.get(n.provider)??0)+1);let n=[];for(let[t,r]of[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))){let e=i[t];if(e&&e.length>1)for(let i of e)n.push({provider:t,keyName:i.name,count:r});else n.push({provider:t,keyName:null,count:r})}return n},[t,i]),D=(0,g.useMemo)(()=>Dh(t,b),[t,b]),O=(0,g.useMemo)(()=>{let e=D;v&&(e=e.filter(e=>e.provider===v.provider));let t=h.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)):e},[D,h,v]),k=(0,g.useMemo)(()=>{let e=[];for(let t of O){let n=i[t.provider];if(!n||n.length<=1){e.push({model:t,key:null});continue}let r=n.find(e=>e.active)??n[0];if(v?.provider===t.provider&&v.keyName){let e=n.find(e=>e.name===v.keyName);e&&(r=e)}e.push({model:t,key:r})}return e},[O,i,v]),[A,j]=(0,g.useState)(!1),ee=e?.availableThinkingLevels&&e.availableThinkingLevels.length>0?new Set(e.availableThinkingLevels):null,M=j_.map(e=>({value:e,label:c(`thinking.${e}`),supported:!ee||ee.has(e)})),te=e=>M.find(t=>t.value===e)?.label??e,P=(0,g.useRef)(!1);(0,g.useEffect)(()=>{if(!d){P.current=!1;return}P.current||t.length>0||n||(P.current=!0,j(!0),$({type:`list_models`})||j(!1))},[d,t.length,n]),(0,g.useEffect)(()=>{j(!1)},[t]),(0,g.useEffect)(()=>{d&&(S.current?.querySelector(`.dd-item.active`))?.scrollIntoView({block:`nearest`})},[d,u,t.length]);let ne=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`availableModels`)}),(0,X.jsxs)(`div`,{className:`dd-search-row`,children:[(0,X.jsx)(de,{}),(0,X.jsx)(`input`,{className:`dd-search`,type:`text`,placeholder:c(`searchModels`),value:h,onChange:e=>_(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`dd-model-body`,children:[E.length>1&&(0,X.jsxs)(`div`,{className:`dd-provider-col`,children:[(0,X.jsx)(`div`,{className:`dd-provider-head`,children:c(`providers`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-provider-item ${v===null?`active`:``}`,onClick:()=>y(null),children:(0,X.jsx)(`span`,{children:c(`allProviders`)})}),E.map(e=>{let t=v?.provider===e.provider&&v?.keyName===e.keyName;return(0,X.jsxs)(`button`,{type:`button`,className:`dd-provider-item ${t?`active`:``}`,onClick:()=>y(t?null:{provider:e.provider,keyName:e.keyName}),title:e.keyName?`${e.provider} · ${e.keyName}`:`${e.provider} · ${e.count}`,children:[(0,X.jsxs)(`span`,{className:`dd-provider-txt`,children:[(0,X.jsx)(`span`,{className:`dd-provider-name`,children:e.provider}),e.keyName&&(0,X.jsx)(`span`,{className:`dd-provider-key`,children:e.keyName})]}),(0,X.jsx)(`span`,{className:`dd-provider-count`,children:e.count})]},e.keyName?`${e.provider}::${e.keyName}`:e.provider)})]}),(0,X.jsxs)(`div`,{className:`dd-model-scroll`,ref:S,children:[(A||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`loading`)}),t.length===0&&!A&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`noModels`)}),O.length===0&&t.length>0&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`noModelMatches`)}),k.map(e=>{let t=e.model,n=u===t.id&&(!e.key||e.key.active),r=a!==void 0&&a===t.id;return(0,X.jsxs)(Ht,{active:n,onClick:()=>{e.key&&!e.key.active&&$({type:`activate_provider_key`,provider:t.provider,keyName:e.key.name}),u!==t.id&&$({type:`set_model`,modelId:t.id}),f(!1)},children:[(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:t.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:t.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:t.id.split(`/`).slice(1).join(`/`)}),e.key&&(0,X.jsxs)(`span`,{className:`dd-model-key ${e.key.active?`active`:``}`,children:[e.key.active?`●`:`○`,` `,e.key.name]}),(b[t.id]??0)>0&&(0,X.jsx)(`span`,{className:`dd-model-usage`,children:c(`modelUsedCount`,{n:b[t.id]})}),(t.reasoning||t.vision)&&(0,X.jsxs)(`span`,{className:`dd-model-badges`,children:[t.reasoning&&(0,X.jsx)(`span`,{className:`dd-model-badge`,children:c(`reasoning`)}),t.vision&&(0,X.jsx)(`span`,{className:`dd-model-badge`,children:c(`vision`)})]})]})]}),a!==void 0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-star-btn ${r?`active`:``}`,title:r?`当前全局默认模型(点击取消默认)`:`设为全局默认模型`,onClick:e=>{e.stopPropagation(),$(r?{type:`clear_default_model`}:{type:`set_default_model`,modelId:t.id})},children:r?`★`:`☆`})]},e.key?`${t.id}::${e.key.name}`:t.id)})]})]}),(0,X.jsxs)(`div`,{className:`dd-footer`,children:[a!==void 0&&a&&(0,X.jsxs)(`div`,{className:`dd-default-banner`,children:[(0,X.jsxs)(`div`,{className:`dd-default-banner-left`,children:[(0,X.jsx)(`span`,{className:`dd-default-banner-star`,children:`★`}),(0,X.jsx)(`span`,{className:`dd-default-banner-label`,children:`默认模型`}),(0,X.jsx)(`span`,{className:`dd-default-banner-name`,title:`默认模型: ${a}`,children:a.split(`/`).slice(1).join(`/`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`dd-default-banner-clear`,title:`清除全局默认模型`,onClick:()=>$({type:`clear_default_model`}),children:`✕ 清除`})]}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`list_models`}),children:c(`refreshModels`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{f(!1),r()},children:c(`manageModels`)})]})]}),F=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`thinkingLevel`)}),M.map(t=>(0,X.jsx)(Ht,{active:e?.thinkingLevel===t.value,disabled:!t.supported,title:t.supported?void 0:c(`thinkingUnsupported`),onClick:()=>{e?.thinkingLevel!==t.value&&$({type:`set_thinking`,level:t.value}),m(!1)},children:t.label},t.value))]}),re=(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ze,{}),(0,X.jsx)(`span`,{className:`chip-model`,children:l?l.name:c(`selectModel`)}),!o&&l?.vision&&(0,X.jsx)(`span`,{className:`chip-vision`,title:c(`vision`),children:`🖼`}),!o&&l&&(0,X.jsx)(`span`,{className:`chip-sub`,children:l.provider})]}),open:d,onOpenChange:f,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:ne}),I=(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:c(`thinkingChip`,{level:e?te(e.thinkingLevel):`—`})})]}),tip:c(`thinkingLevel`),open:p,onOpenChange:m,align:`left`,direction:`up`,children:F});if(s===`model`)return re;if(s===`thinking`)return I;let L=e?.thinkingLevel&&e.thinkingLevel!==`off`;return(0,X.jsxs)(`div`,{className:`model-thinking-capsule`,children:[(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ze,{}),(0,X.jsx)(`span`,{className:`capsule-model-name`,children:l?l.name:c(`selectModel`)}),!o&&l?.vision&&(0,X.jsx)(`span`,{className:`chip-vision`,title:c(`vision`),children:`🖼`})]}),triggerClassName:`capsule-segment capsule-model`,open:d,onOpenChange:f,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:ne}),(0,X.jsx)(`div`,{className:`capsule-divider`}),(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`thinking-pulse-dot ${L?`on`:``}`}),(0,X.jsx)(`span`,{className:`capsule-thinking-text`,children:e?te(e.thinkingLevel):`—`})]}),triggerClassName:`capsule-segment capsule-thinking`,open:p,onOpenChange:m,align:`left`,direction:`up`,children:F})]})}),N_=[`standard`,`ptc`,`minimal`,`cordis`],P_={standard:`preset.standard`,minimal:`preset.minimal`,code:`preset.code`,reader:`preset.reader`,ask:`preset.ask`},F_={standard:`preset.standardDesc`,minimal:`preset.minimalDesc`,code:`preset.codeDesc`,reader:`preset.readerDesc`,ask:`preset.askDesc`};function I_(e){return P_[e]??null}function L_(e){return F_[e]??null}function R_(e,t,n){let r=t===`zh`,i=I_(e.id),a=L_(e.id);return i&&a?{name:n(i),description:n(a)}:{name:r?e.name??e.id:e.nameEn??e.name??e.id,description:r?e.description:e.descriptionEn??e.description}}function z_(e){return[...e].sort((e,t)=>{let n=Number.isSafeInteger(e.order)?e.order:N_.indexOf(e.id),r=Number.isSafeInteger(t.order)?t.order:N_.indexOf(t.id),i=n>=0?n:1e3,a=r>=0?r:1e3;return i===a?e.id.localeCompare(t.id):i-a})}var B_=(0,g.memo)(function({preset:e,presets:t,defaultPreset:n,blank:r,conversationId:i,compact:a=!1}){let o=Z(),{locale:s}=Nn(),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(e?.id??n);if((0,g.useEffect)(()=>{d(e?.id??n)},[i,e?.id,n]),t.length===0)return null;let f=e?.locked||!r,p=z_(t),m=p.find(t=>t.id===e?.id),h=p.find(e=>e.id===u)??m,_=e=>R_(e,s,o),v=m?_(m):void 0,y=t=>{d(t),l(!1),r&&t!==e?.id&&$({type:`dsh_preset_select`,preset:t})};if(a){let t=v?.description??m?.id??o(`dshPreset`);return(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ae,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:f?`${t}(${o(`dshPresetLocked`)})`:t,children:[v?.name??m?.id??e?.name??o(`dshPreset`),f&&(0,X.jsx)(Te,{style:{marginLeft:3}})]})]}),open:c&&!f,onOpenChange:l,direction:`up`,align:`left`,children:p.map(t=>{let r=_(t);return(0,X.jsxs)(Ht,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??r.description??t.id,onClick:()=>y(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[r.name,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetUser`)}),t.id===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:o(`dshPresetBroken`)})]}),r.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:r.description})]},t.id)})})}return(0,X.jsxs)(`div`,{className:`dsh-presetbar`,"data-testid":`dsh-presetbar`,children:[(0,X.jsxs)(`span`,{className:`dsh-preset-label`,children:[(0,X.jsx)(ae,{}),o(`dshPreset`)]}),(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(`span`,{title:v?.description??m?.id??``,children:[v?.name??m?.id??e?.name??`…`,f&&(0,X.jsxs)(`span`,{className:`dsh-preset-lock`,title:o(`dshPresetBlankOnly`),children:[(0,X.jsx)(Te,{}),` `,o(`dshPresetLocked`)]})]}),open:c&&!f,onOpenChange:l,children:p.map(t=>{let r=_(t);return(0,X.jsxs)(Ht,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??r.description??t.id,onClick:()=>y(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[r.name,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetUser`)}),t.id===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:o(`dshPresetBroken`)})]}),r.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:r.description})]},t.id)})}),!f&&(0,X.jsx)(`span`,{className:`dsh-preset-hint`,title:o(`dshPresetBlankOnly`),children:o(`dshPresetBlankOnly`)}),h?.id===`minimal`&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:o(`dshPresetMinimalNote`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip`,title:o(`dshPresetNewChat`),onClick:()=>{$({type:`new_chat`,preset:h?.id??u}),sr()},children:[(0,X.jsx)(me,{}),` `,o(`dshPresetNewChat`)]})]})}),V_=[`read-only`,`workspace-write-never`,`danger-full-access`],H_=[`read-only`,`workspace-write-never`,`danger-full-access`];function U_(e){return e===`read-only`?`dshPermReadOnly`:e===`danger-full-access`?`dshPermFullAccess`:`dshPermWorkspaceWrite`}function W_(e){return e===`read-only`?`dshPermReadOnlyDesc`:e===`danger-full-access`?`dshPermFullAccessDesc`:`dshPermWorkspaceWriteDesc`}var G_=(0,g.memo)(function({current:e,options:t,defaultPreset:n,conversationId:r,compact:i=!1}){let a=Z(),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(!1);(0,g.useEffect)(()=>{l(!1),s(!1)},[r]);let u=V_.filter(e=>t.some(t=>t.value===e));if(u.length===0)return null;let d=e??n,f=!!e&&!u.includes(e),p=e=>{if(e===`danger-full-access`&&e!==d&&!c){l(!0);return}l(!1),s(!1),e!==d&&$({type:`dsh_permission_set`,preset:e})};if(i){let t=a(f?`dshPermCustom`:U_(d)),r=f?e??t:a(W_(d));return(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(se,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:r,children:[t,d===`danger-full-access`&&(0,X.jsx)(wt,{style:{marginLeft:3}})]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},direction:`up`,align:`left`,children:[u.map(e=>(0,X.jsxs)(Ht,{active:e===d,title:a(W_(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(U_(e)),e===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),e===`danger-full-access`&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPermFullAccessTag`)})]}),(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:a(W_(e))})]},e)),c&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:a(`dshPermConfirmFull`)})]})}return(0,X.jsxs)(`div`,{className:`dsh-presetbar`,"data-testid":`dsh-permissionbar`,children:[(0,X.jsxs)(`span`,{className:`dsh-preset-label`,children:[(0,X.jsx)(se,{}),a(`dshPerm`)]}),(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(`span`,{title:f?e:a(W_(d)),children:[a(f?`dshPermCustom`:U_(d)),d===`danger-full-access`&&(0,X.jsxs)(`span`,{className:`dd-preset-tag warn`,children:[(0,X.jsx)(wt,{}),` `,a(`dshPermFullAccessTag`)]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},children:u.map(e=>(0,X.jsxs)(Ht,{active:e===d,title:a(W_(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(U_(e)),e===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),e===`danger-full-access`&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPermFullAccessTag`)})]}),(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:a(W_(e))})]},e))}),c&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:a(`dshPermConfirmFull`)})]})}),K_=T_(),q_=40,J_=220,Y_=720,X_=`pi-web-ui:composer-height`,Z_=(0,g.memo)(function({streaming:e,planMode:t,messages:n,slashCommands:r,modelState:i,models:a,modelsLoading:o,attachments:s,onRemoveAttachment:c,onAddImageFiles:l,onAddLocalFiles:u,onAddPathAttachment:d,fileSearch:f,onSearchFiles:p,onNotice:m,onSent:h,onManageModels:_,providerKeys:v,defaultModel:y,quickPhrases:b,quickPhrasesEnabled:x,recallDrafts:S,composerLeading:C,composerActions:w,onUiAction:T,dshPermCurrent:E,dshPermOptions:D,dshPermDefault:O,dshPreset:k,dshPresets:A,dshPresetDefault:j,dshBlank:ee,conversationId:M,sessionDraft:te,sessionId:N}){let P=Z(),ne=La(`ready`),F=Ra(),{locale:re}=Nn(),{openPicker:I}=Lh(),L=e=>re!==`zh`&&e.descriptionEn?e.descriptionEn:e.description??``,ie=e=>re!==`zh`&&e.argumentHintEn?e.argumentHintEn:e.argumentHint??``,[R,z]=(0,g.useState)(``),[B,V]=(0,g.useState)(()=>{try{let e=Number(localStorage.getItem(X_));if(Number.isFinite(e)&&e>=q_&&e<=Y_)return e}catch{}return null}),H=(0,g.useRef)(null),[ae,oe]=(0,g.useState)(null),[se,W]=(0,g.useState)(0),ce=(0,g.useRef)(0),le=(0,g.useRef)(new Map),ue=(0,g.useRef)(``),[de,fe]=(0,g.useState)(!1),[pe,G]=(0,g.useState)(void 0),K=(0,g.useRef)(null),me=(0,g.useRef)(null),he=(0,g.useRef)(null),q=(0,g.useRef)(-1),_e=(0,g.useRef)(``),ve=(0,g.useRef)(0);(0,g.useEffect)(()=>{if(!S||S.length===0)return;let e=S.filter(e=>e.text&&e.seq>ve.current);e.length!==0&&(ve.current=e[e.length-1].seq,oe(null),z(t=>{let n=e.reduce((e,t)=>Lg(e,t.text),t);return ue.current=n,n}),q.current=-1,_e.current=``,requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}))},[S]),(0,g.useEffect)(()=>(ir(e=>{oe(null),z(t=>{let n=Lg(t,e);return ue.current=n,n}),q.current=-1,_e.current=``,requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)})}),()=>ir(null)),[]),(0,g.useEffect)(()=>(or(()=>{K_||requestAnimationFrame(()=>{K.current?.focus()})}),()=>or(null)),[]);let ye=(0,g.useRef)(``);ye.current=R,(0,g.useEffect)(()=>(er(e=>{{let t=e.trim(),n=new Set([`.`,`*`,`+`,`?`,`^`,`$`,`{`,`}`,`(`,`)`,`|`,`[`,`]`,`\\`]),r=t.split(``).map(e=>n.has(e)?`\\`+e:e).join(``),i=RegExp(`(^|[\\s(("'“‘[【])`+r+`(?=[\\s,.;:!?,。!?)\\]】」]|$)`);if(t&&i.test(ye.current))return}let t=K.current;if(!t){z(t=>{let n=t+(t&&!t.endsWith(` `)?` `:``)+e;return ue.current=n,n});return}let n=t.selectionStart??ye.current.length,r=t.selectionEnd??ye.current.length,i=ye.current,a=(n>0&&!/[\s([{]$/.test(i.slice(0,n))?` `:``)+e,o=i.slice(0,n)+a+i.slice(r);ue.current=o,z(o);let s=n+a.length;requestAnimationFrame(()=>{t.focus(),t.selectionStart=t.selectionEnd=s})}),()=>er(null)),[]),(0,g.useEffect)(()=>(tr(e=>{z(t=>{let n=new Set([`.`,`*`,`+`,`?`,`^`,`$`,`{`,`}`,`(`,`)`,`|`,`[`,`]`,`\\`]),r=e.split(``).map(e=>n.has(e)?`\\`+e:e).join(``),i=RegExp(`(^|\\s)`+r+`(?:\\s|$)`,`g`),a=t.replace(i,(e,t)=>t===` `?` `:``);return a=a.replace(/ {2,}/g,` `).trim(),ue.current=a,a})}),()=>tr(null)),[]);let be=2e4,J=!F&&N?`${M??``}${N}`:null,Se=J&&N?`pi-web-ui:composer-draft:${N}`:null,Ce=(0,g.useRef)(``),we=(0,g.useRef)(0),Te=(0,g.useRef)(!1),Ee=(0,g.useRef)(0),Oe=(0,g.useRef)(null),ke=(0,g.useRef)(null),Ae=(0,g.useRef)(null),je=O_(),Me=e=>{try{let t=localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return typeof n.text!=`string`||!n.text||typeof n.ts!=`number`?null:{text:n.text.slice(0,be),ts:n.ts}}catch{return null}},Ne=(e,t,n,r)=>{let i=n.slice(0,be);try{i.trim()?localStorage.setItem(t,JSON.stringify({text:i,ts:r})):localStorage.removeItem(t)}catch{}$({type:`draft_update`,sessionId:e,text:i,ts:r})},Pe=()=>{Oe.current&&=(clearTimeout(Oe.current),null),Te.current&&J&&Se&&N&&Xe&&Ne(N,Se,Ce.current,we.current)},Fe=e=>{if(Ce.current=e,Te.current=!0,we.current=Date.now(),Se){let t=e.slice(0,be);try{t.trim()?localStorage.setItem(Se,JSON.stringify({text:t,ts:we.current})):localStorage.removeItem(Se)}catch{}}if(J&&N&&Xe){Oe.current&&clearTimeout(Oe.current);let e=N,t=Se,n=we.current,r=J;Oe.current=setTimeout(()=>{Oe.current=null,r===ke.current&&t&&Ne(e,t,Ce.current,n)},2e3)}},Ie=(e,t)=>{q.current=-1,z(e),ze(e,t),Fe(e)};(0,g.useEffect)(()=>{let e=J,t=N,n=Se;return()=>{Oe.current&&=(clearTimeout(Oe.current),null),Te.current&&Ce.current.trim()?(e&&t&&n&&Ne(t,n,Ce.current,we.current),Ae.current=Ce.current):Ae.current=null}},[J]),(0,g.useEffect)(()=>{ke.current=J;let e=Ae.current;Ae.current=null;let t=Se?Me(Se):null,r=!!(te&&te.text?.trim()&&te.ts>0||t&&t.text?.trim());e!==null&&Hg(e,n.length,r)&&Se&&N?(Te.current=!0,Ee.current=Date.now(),Ce.current=e,we.current=Ee.current,z(e),Ne(N,Se,e,we.current)):(Te.current=!1,Ee.current=0,Ce.current=``,we.current=0,z(``)),oe(null),q.current=-1},[J]);let Le=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=n.length===0,t=Le.current!==J;Le.current=J,ne&&e&&(!K_||t)&&requestAnimationFrame(()=>{K.current?.focus()})},[J,n.length,ne]),(0,g.useEffect)(()=>{if(!J||!Se||Te.current||Ce.current!==``)return;let e=Rg(te&&te.text?{text:te.text.slice(0,be),ts:te.ts}:null,Me(Se),Ee.current);e&&(Ee.current=e.ts,Ce.current=e.text,we.current=e.ts,z(e.text),ze(e.text,null))});let Re={builtin:P(`slashBuiltin`),extension:P(`slashExtension`),prompt:P(`slashPrompt`),skill:P(`slashSkill`),plugin:P(`slashPlugin`)},ze=(e,t)=>{ue.current=e;let n=e.match(/^\/([^\s]*)$/);if(n&&ne){let e=h_(r,n[1].toLowerCase());oe(e.length>0?{kind:`slash`,items:e}:null),W(0);return}if(t===null||!ne){oe(null);return}let i=C_(e,t);if(!i){oe(null);return}let a=[];try{a=tc()}catch{a=[]}let o=++ce.current,s=e,c=i.start,l=i.query,u=c+1+l.length,d=a.map(e=>({id:e.id,label:e.label,run:()=>{let t;try{t=nc(e.id)?.search}catch{t=void 0}return typeof t==`function`?t(l):Promise.resolve([])}}));l&&typeof p==`function`&&d.push({id:`host:files`,label:P(`openFiles`),run:()=>Be(l)}),Un();let f=__(P(`browserControl`),Hn(),l);if(d.push({id:`host:pages`,label:P(`browserControl`),run:()=>Promise.resolve(f)}),d.length===0){oe(null);return}let m=b_(P(`slashSkill`),r,l,15,L),h=x_({pages:f,skills:m},l,30),g=!1;h.length>0&&(g=!0,oe({kind:`at`,start:c,end:u,items:h}),W(0)),Promise.allSettled(d.map(e=>Promise.race([e.run(),new Promise((e,t)=>setTimeout(()=>t(Error(`at-mention timeout`)),2e3))]))).then(e=>{if(ce.current!==o||ue.current!==s)return;let t=[],n=[],r=[];e.forEach((e,i)=>{e.status===`fulfilled`&&(d[i].id===`host:pages`&&Array.isArray(e.value)?t.push(...e.value):d[i].id===`host:files`?n.push(...v_(d[i].label,e.value)):r.push(...y_(d[i].id,d[i].label,e.value)))});let i=x_({pages:t,skills:m,files:n,plugins:r},l,30);oe(i.length>0?{kind:`at`,start:c,end:u,items:i}:null),!g&&i.length>0&&W(0)})},Be=e=>{if(typeof p!=`function`)return Promise.resolve([]);let t=A_();return new Promise(n=>{le.current.set(t,n);try{p(t,e)}catch{le.current.delete(t),n([]);return}setTimeout(()=>{le.current.get(t)===n&&(le.current.delete(t),n([]))},3e3)})};(0,g.useEffect)(()=>{if(!f||!f.ok)return;let e=le.current.get(f.reqId);e&&(le.current.delete(f.reqId),e(f.results??[]))},[f]);let Ve=e=>ze(e,null);(0,g.useEffect)(()=>{(he.current?.querySelector(`.slash-item.active`))?.scrollIntoView({block:`nearest`})},[se,ae]);let He=e=>{let t=ae?.kind===`slash`?ae.items:[],n=e??t[se%Math.max(t.length,1)];if(!n){oe(null);return}let r=R.match(/^\/([^\s]*)([\s\S]*)$/),i=r?r[2]:``,a=`/${n.name} ${i}`;ue.current=a,z(a),Fe(a),oe(null),K.current?.focus()},Ue=(e,t)=>{let n=ae?.kind===`at`?ae:null,r=n?.items??[],i=e??r[se%Math.max(r.length,1)],a=t??n?.start;if(!i||a===void 0){oe(null);return}let o=K.current,s=o?o.selectionStart??R.length:R.length,c=n?.end!==void 0&&n.end>=a?n.end:s,l=i.attachments??[],u=i.text??i.title,f=l.length>0&&!u.startsWith(`@`)?`@${u} `:`${u} `,p=`${R.slice(0,a)}${f}${R.slice(c)}`;ue.current=p,z(p),Fe(p),oe(null);for(let e of l)try{d?.({path:e.path,name:e.name??e.path.split(`/`).pop()??e.path,...e.mode?{mode:e.mode}:{mode:`reference`},...typeof e.isDir==`boolean`?{isDir:e.isDir}:{},...e.lines?{lines:e.lines}:{},silent:!0})}catch{}requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=a+f.length)})},We=()=>ae?.kind===`slash`?ae.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===se?` active`:``}`,onMouseEnter:()=>W(t),onClick:()=>Y(e),children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Re[e.source]}),(0,X.jsxs)(`span`,{className:`slash-desc`,children:[L(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:ie(e)})]})]},e.name)):null,Ge=()=>ae?.kind===`at`?ae.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===se?` active`:``}`,onMouseEnter:()=>W(t),onClick:()=>Y(e),title:e.hint??e.title,children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`@`,e.title]}),(0,X.jsx)(`span`,{className:`slash-source ${e.providerId===`host:skills`?`skill`:`plugin`}`,children:e.providerLabel}),e.hint&&(0,X.jsx)(`span`,{className:`slash-desc`,children:e.hint})]},`${e.providerId}:${e.title}:${t}`)):null,Y=e=>{ae&&(ae.kind===`slash`?He(e):Ue(e,ae.start))},Ke=async()=>{let e=[...n].reverse().find(e=>e.role===`assistant`&&e.content.some(e=>e.type===`text`&&e.text))?.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
360
- `);if(!e){m(`warning`,P(`slashCopyEmpty`));return}await Nu(e)?m(`info`,P(`slashCopied`)):m(`error`,P(`slashCopyFailed`))},qe=e=>{if(!e||e.length===0){m(`warning`,P(`foldersNotSupported`));return}let t=Array.from(e).filter(e=>Zp(e.type)),n=Array.from(e).filter(e=>!Zp(e.type)),r=Ye();t.length>0&&r?m(`warning`,r):t.length>0&&l(t),n.length>0&&u(n)},Je=e=>{let t=e_(e.clipboardData?.items,e.clipboardData?.files);t.length!==0&&(e.preventDefault(),qe(t))},Ye=()=>{let e=i?.model;if(!e?.id)return null;let t=a.find(t=>t.id===e.id);return t&&t.vision===!1?P(`modelNoVision`,{name:t.name}):null},Xe=ne,Ze=(0,g.useRef)(R);(0,g.useEffect)(()=>{Ze.current=R},[R]),(0,g.useEffect)(()=>{Ve(Ze.current)},[r]);let[Qe,$e]=(0,g.useState)(null),et=e=>{let t=Qe;if($e(null),t===null)return;let n=Wg(Ze.current,t,e);n!==null&&(oe(null),ue.current=n,z(n)),requestAnimationFrame(()=>K.current?.focus())};(0,g.useEffect)(()=>{let e=e=>{let t=e.detail;if(typeof t==`string`){if(Ug(Ze.current,t)){$e(t);return}oe(null),ue.current=t,z(t),K.current?.focus()}};return window.addEventListener(`pi-web:fill`,e),()=>window.removeEventListener(`pi-web:fill`,e)},[]),(0,g.useEffect)(()=>{if(!de&&Qe===null)return;let e=e=>{e.key===`Escape`&&(Qe===null?fe(!1):($e(null),requestAnimationFrame(()=>K.current?.focus())))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[de,Qe]);let tt=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=K.current,t=tt.current;if(!e||!t)return;let n=e.closest(`main`)?.querySelector(`.messages`),r=t.getBoundingClientRect().height,i=n?.scrollTop??0;e.style.height=`auto`;let a=B==null?J_:Y_;e.style.maxHeight=`${a}px`;let o=Math.min(Math.max(e.scrollHeight,B??0),a);e.style.height=`${o}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`,n&&(n.scrollTop=i+(t.getBoundingClientRect().height-r))},[R,B]);let nt=(0,g.useRef)(null),rt=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=nt.current,t=rt.current,n=document.documentElement;if(!e&&!t){n.style.removeProperty(`--quick-row-h`);return}let r=()=>{let r=e?e.offsetHeight:0,i=t?t.offsetHeight:0,a=e&&t?6:0;n.style.setProperty(`--quick-row-h`,`${r+a+i}px`)};r();let i=new ResizeObserver(r);return e&&i.observe(e),t&&i.observe(t),()=>{i.disconnect(),n.style.removeProperty(`--quick-row-h`)}},[s.length,x,b.length]);let it=()=>s.map(e=>e.mode===`quote`?{path:``,mode:`quote`,quote:e.quote}:e.imageData?{path:``,imageData:e.imageData,mimeType:e.mimeType,name:e.name}:e.fileData?{path:``,fileData:e.fileData,mimeType:e.mimeType,name:e.name,size:e.size}:{path:e.path,mode:e.mode,...e.lines?{lines:e.lines}:{},...e.mode===`page`?{name:e.name}:{},...e.mode===`conversation`?{name:e.name,...e.conversationId?{conversationId:e.conversationId}:{},...e.sessionPath?{sessionPath:e.sessionPath}:{}}:{}}),at=(e=!1)=>{let t=R.trim(),n=s.length>0;if(t||n){if(!Xe){m(`error`,P(`netDisconnected`));return}if(t===`/help`){let e=K.current?.closest(`.inputbox`)?.getBoundingClientRect();G(e?.width),fe(!0),z(``),K.current?.focus();return}if(t===`/copy`){z(``),K.current?.focus(),Ke();return}if($({type:`prompt`,text:t,queue:e,attachments:it()})){if(t&&d_(t),q.current=-1,_e.current=``,z(``),Se)try{localStorage.removeItem(Se)}catch{}Oe.current&&=(clearTimeout(Oe.current),null),Te.current=!1,Ee.current=Date.now(),Ce.current=``,we.current=0,h();let e=i?.model;e&&Ah(`${e.provider}/${e.id}`),K.current?.focus()}else m(`error`,P(`netDisconnected`))}},ot=(e,t=!1)=>{let n=e.trim();if(n){if(!Xe){m(`error`,P(`netDisconnected`));return}if($({type:`prompt`,text:n,queue:t,attachments:it()})){n&&d_(n),q.current=-1,_e.current=``,Pe(),h();let e=i?.model;e&&Ah(`${e.provider}/${e.id}`),K_||K.current?.focus()}else m(`error`,P(`netDisconnected`))}},st=e=>{if(!je.isImeKey(e.nativeEvent)){if(ae&&ae.items.length>0){let t=ae.items.length;switch(e.key){case`ArrowDown`:e.preventDefault(),W(e=>(e+1)%t);return;case`ArrowUp`:e.preventDefault(),W(e=>(e-1+t)%t);return;case`Tab`:case`Enter`:e.preventDefault(),Y();return;case`Escape`:e.preventDefault(),oe(null);return}}if(e.key===`Backspace`&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=K.current;if(t&&t.selectionStart===t.selectionEnd&&t.selectionStart>0){let n=t.selectionStart,r=E_(R.slice(0,n),n,s);if(r&&r.tokenStart>=0&&r.tokenStart<n){e.preventDefault();let t=r.tokenStart,i=R.slice(0,t)+R.slice(n);ue.current=i,z(i),requestAnimationFrame(()=>{K.current&&(K.current.selectionStart=K.current.selectionEnd=t)});let a=r.attachment;a&&c(a.key??(a.mode===`conversation`?`conv|${a.conversationId??``}|${a.sessionPath??``}`:a.path));return}}}if(e.key===`ArrowUp`||e.key===`ArrowDown`){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=K.current;if(!t)return;let n=e.key===`ArrowUp`,r=$g(t);if(n&&!r.first||!n&&!r.last||!n&&q.current===-1)return;let i=l_();if(i.length===0)return;if(e.preventDefault(),n){if(q.current===-1){_e.current=R;let e=i.length-1;q.current=e;let t=i[e];z(t),Ve(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else if(q.current>0){let e=q.current-1;q.current=e;let t=i[e];z(t),Ve(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}}else{let e=q.current+1;if(e<i.length){q.current=e;let t=i[e];z(t),Ve(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else{q.current=-1;let e=_e.current;z(e),Ve(e),requestAnimationFrame(()=>{let t=K.current;t&&(t.selectionStart=t.selectionEnd=e.length)})}}return}if(e.key===`Escape`&&q.current!==-1){e.preventDefault();let t=_e.current;q.current=-1,z(t),Ve(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)});return}if(e.key===`Enter`){if(K_&&!e.shiftKey&&!(e.ctrlKey||e.metaKey))return;e.shiftKey||(e.preventDefault(),at())}}},ct=Xe&&(R.trim()!==``||s.length>0),lt=(0,g.useMemo)(()=>na((w??[]).filter(e=>e.source!==`host`&&!e.hidden)),[w]),ut=(0,g.useMemo)(()=>(C??[]).filter(e=>e.source!==`host`&&!e.hidden),[C]),dt=w!==void 0,ft=(0,g.useMemo)(()=>na((w??[]).filter(e=>!e.hidden)),[w]),pt=e=>{if(e.kind===`select`&&e.options?.length){let t=e.options.some(t=>t.value===e.value)?e.value:e.options[0].value;return(0,X.jsx)(`select`,{className:`composer-plugin-select`,title:e.hint||e.label,"aria-label":e.label,value:t,onChange:t=>T?.(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id)}let t=e.icon===`mic`?(0,X.jsx)(xe,{}):e.icon===`camera`?(0,X.jsx)(mt,{}):e.icon||e.label;return(0,X.jsx)(`button`,{type:`button`,className:`btn composer-plugin-action`,title:e.hint||e.label,"aria-label":e.label,onClick:()=>T?.(e),children:t},e.id)},ht=()=>(0,X.jsx)(`div`,{className:`inputbox-actions`,children:e?ct?(0,X.jsxs)(`div`,{className:`split-send${F?` single`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`split-queue`,title:P(`supplementTip`),"aria-label":P(`queueFollowTag`),onClick:()=>at(!0),children:(0,X.jsx)(De,{})}),!F&&(0,X.jsx)(`button`,{type:`button`,className:`split-steer`,title:P(`steerTip`),"aria-label":P(`queueSteerTag`),onClick:()=>at(),children:(0,X.jsx)(vt,{})})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn stop`,title:P(`stopAgent`),onClick:()=>$({type:`abort`}),children:(0,X.jsx)(U,{})}):(0,X.jsx)(`button`,{type:`button`,className:`btn send`,title:P(`sendTip`),disabled:!ct,onClick:()=>at(),children:(0,X.jsx)(vt,{})})}),_t={"host:composer-upload":(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:P(`uploadFile`),disabled:!Xe,onClick:()=>me.current?.click(),children:(0,X.jsx)(ge,{})}),"host:composer-templates":(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:P(`tpl.openPicker`),onClick:I,children:(0,X.jsx)(gt,{})}),"host:composer-model":(0,X.jsx)(M_,{only:`model`,state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,defaultModel:y,compact:!0}),"host:composer-thinking":(0,X.jsx)(M_,{only:`thinking`,state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,compact:!0}),"host:composer-dsh-perm":D&&D.length>0&&O!==void 0?(0,X.jsx)(G_,{compact:!0,current:E??null,options:D,defaultPreset:O,conversationId:M??``}):null,"host:composer-dsh-preset":A&&A.length>0&&j!==void 0?(0,X.jsx)(B_,{compact:!0,preset:k??null,presets:A,defaultPreset:j,blank:ee??!1,conversationId:M??``}):null,"host:composer-send":ht()},yt=e=>e.source===`host`?(0,X.jsx)(g.Fragment,{children:_t[e.id]??null},e.id):pt(e);return(0,X.jsxs)(`div`,{ref:tt,className:`inputbar`,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),qe(e.dataTransfer?.files??null)},children:[s.length>0&&(0,X.jsxs)(`div`,{className:`attach-row`,ref:nt,children:[s.map(e=>e.mode===`quote`&&e.quote?(0,X.jsx)(nd,{quote:e.quote,onRemove:()=>c(e.key??``)},e.key):(0,X.jsxs)(`span`,{className:`attach-chip ${e.imageData?`image`:e.fileData?`file`:e.mode}`,title:e.imageData?P(`attachImage`,{name:e.name}):e.fileData?P(`attachFile`,{name:e.name}):e.isDir?P(`folderRef`,{path:e.path}):e.mode===`page`?P(`attachPage`,{name:e.name}):e.mode===`conversation`?P(`attachConversation`,{name:e.name}):e.mode===`reference`?P(`refOnly`,{path:e.path}):e.mode===`lines`&&e.lines?P(`attachLines`,{path:e.path,start:e.lines.start,end:e.lines.end}):P(`attachContent`,{path:e.path}),children:[e.imageData?`🖼`:e.fileData?`📄`:e.isDir?`📁`:e.mode===`page`?`🌐`:e.mode===`conversation`?`💬`:e.mode===`reference`?`🔗`:`📎`,e.name,e.mode===`lines`&&e.lines&&(0,X.jsxs)(`span`,{className:`attach-range`,children:[`L`,e.lines.start,`-`,e.lines.end]}),(0,X.jsx)(`button`,{type:`button`,className:`attach-remove`,title:P(`removeAttachment`),onClick:()=>c(e.key??(e.mode===`conversation`?`conv|${e.conversationId??``}|${e.sessionPath??``}`:e.path)),children:`×`})]},e.key??(e.mode===`conversation`?`conv|${e.conversationId??``}|${e.sessionPath??``}`:`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`))),(0,X.jsx)(`span`,{className:`attach-hint`,children:P(`attachHint`)})]}),ae&&ae.items.length>0&&(0,X.jsxs)(`div`,{className:`slash-menu`,role:`listbox`,ref:he,"aria-label":ae.kind===`slash`?P(`slashCommands`):P(`atMentions`),"data-menu-kind":ae.kind,children:[(0,X.jsxs)(`div`,{className:`slash-menu-hint`,children:[(0,X.jsx)(`span`,{children:ae.kind===`slash`?P(`slashMenuHint`):P(`atMenuHint`)}),(0,X.jsx)(`span`,{className:`slash-menu-close`,onClick:()=>oe(null),children:`Esc`})]}),ae.kind===`slash`?We():Ge()]}),Qe!==null&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>et(`cancel`),children:(0,X.jsxs)(`div`,{className:`slash-help`,role:`dialog`,"aria-modal":`true`,"aria-label":P(`tpl.confirmFillTitle`),style:{maxWidth:420},onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`div`,{className:`slash-help-head`,children:(0,X.jsx)(`span`,{children:P(`tpl.confirmFillTitle`)})}),(0,X.jsxs)(`div`,{className:`slash-help-body`,style:{padding:`12px 16px`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 14px`,lineHeight:1.5},children:P(`tpl.confirmFillDesc`)}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,flexWrap:`wrap`},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,autoFocus:!0,onClick:()=>et(`cancel`),children:P(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>et(`append`),children:P(`tpl.confirmFillAppend`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>et(`overwrite`),children:P(`tpl.confirmFillOverwrite`)})]})]})]})}),de&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>fe(!1),children:(0,X.jsxs)(`div`,{className:`slash-help`,style:pe?{width:pe}:void 0,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`slash-help-head`,children:[(0,X.jsxs)(`span`,{children:[`⚡ `,P(`slashHelpTitle`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>fe(!1),children:P(`close`)})]}),(0,X.jsx)(`div`,{className:`slash-help-body`,children:r.length===0?(0,X.jsx)(`div`,{className:`slash-help-empty`,children:P(`slashLoading`)}):r.map(e=>(0,X.jsxs)(`div`,{className:`slash-help-row`,children:[(0,X.jsxs)(`span`,{className:`slash-help-cmd`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Re[e.source]}),(0,X.jsxs)(`span`,{className:`slash-help-desc`,children:[L(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:ie(e)})]})]},e.name))})]})}),x&&b.length>0&&(0,X.jsx)(`div`,{className:`quick-row`,"aria-label":P(`quickPhrases`),ref:rt,children:b.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`quick-chip`,title:`${P(`quickPhrasesTip`,{text:e})}(${P(`quickPhrasesSendTip`)})`,disabled:!Xe,onClick:()=>ot(e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),ot(e,!0)},children:e},e))}),(0,X.jsxs)(`div`,{className:`inputbox`,"data-pi-anchor":`composer`,children:[(0,X.jsx)(`div`,{className:`composer-resize`,title:P(`composerResize`),"aria-label":P(`composerResize`),role:`separator`,"aria-orientation":`horizontal`,"aria-valuenow":Math.round(B??J_),"aria-valuemin":q_,"aria-valuemax":Y_,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId);let t=K.current?.getBoundingClientRect().height;H.current={startY:e.clientY,startH:typeof t==`number`&&Number.isFinite(t)?t:B??J_,next:null}},onPointerMove:e=>{let t=H.current;if(!t)return;let n=Math.min(Y_,Math.max(q_,t.startH+(t.startY-e.clientY)));t.next=n,V(n)},onPointerUp:()=>{let e=H.current?.next;if(H.current=null,e!=null)try{localStorage.setItem(X_,String(Math.round(e)))}catch{}},onPointerCancel:()=>{H.current=null},onDoubleClick:()=>{V(null);try{localStorage.removeItem(X_)}catch{}}}),(0,X.jsx)(`input`,{ref:me,type:`file`,multiple:!0,hidden:!0,onChange:e=>{qe(e.target.files),e.target.value=``}}),(0,X.jsx)(`textarea`,{ref:K,value:R,rows:1,placeholder:P(Xe?e?F?`placeholderStreamingQueued`:`placeholderStreaming`:t?`placeholderPlanMode`:`placeholderIdle`:`placeholderConnecting`),disabled:!Xe,onChange:e=>{Ie(e.target.value,e.target.selectionStart??e.target.value.length)},onSelect:e=>{if(ae?.kind===`at`){let t=e.target.selectionStart;(t<ae.start||t>ae.end)&&oe(null)}},onCompositionEnd:je.onCompositionEnd,onBlur:Pe,onKeyDown:st,onPaste:Je}),t&&(0,X.jsxs)(`button`,{type:`button`,style:{display:`inline-flex`,alignItems:`center`,gap:4,fontSize:11,color:`var(--accent, #38bdf8)`,background:`var(--accent-soft, rgba(56, 189, 248, 0.1))`,padding:`2px 8px`,borderRadius:12,position:`absolute`,right:12,top:8,cursor:`pointer`,border:`1px solid var(--border, rgba(255, 255, 255, 0.1))`,zIndex:2},onClick:()=>$({type:`set_plan_mode`,enabled:!1}),title:P(`planModeTip`),children:[`📋 `,P(`planModeBadge`),` `,(0,X.jsx)(`span`,{style:{marginLeft:2,opacity:.7},children:`✕`})]}),(0,X.jsx)(`div`,{className:`composer-tools`,children:dt?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[ut.map(pt),ft.start.map(yt)]}),ft.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:ft.center.map(yt)}),(0,X.jsx)(`div`,{className:`composer-tools-right`,children:ft.end.map(yt)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[ut.map(pt),(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:P(`uploadFile`),disabled:!Xe,onClick:()=>me.current?.click(),children:(0,X.jsx)(ge,{})}),lt.start.map(pt),(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:P(`tpl.openPicker`),onClick:I,children:(0,X.jsx)(gt,{})}),(0,X.jsx)(M_,{state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,defaultModel:y,compact:!0}),D&&D.length>0&&O!==void 0&&(0,X.jsx)(G_,{compact:!0,current:E??null,options:D,defaultPreset:O,conversationId:M??``}),A&&A.length>0&&j!==void 0&&(0,X.jsx)(B_,{compact:!0,preset:k??null,presets:A,defaultPreset:j,blank:ee??!1,conversationId:M??``})]}),lt.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:lt.center.map(pt)}),(0,X.jsxs)(`div`,{className:`composer-tools-right`,children:[lt.end.map(pt),ht()]})]})})]})]})}),Q_=(0,g.memo)(function({goal:e,models:t,modelsLoading:n,activeConversationId:r,uiGoalbarActions:i,onUiAction:a}){let o=Z(),{locale:s}=Nn(),c=s!==`zh`&&e.statusEn?e.statusEn:e.status||``,l=s!==`zh`&&e.wizard?.statusEn?e.wizard.statusEn:e.wizard?.status||``,u=Ra(),d=!e.conversationId||e.conversationId===r,f=e.goal!==null&&d,p=d?e.roles?.executor:void 0,m=p?.convId,h=p?.activity?s!==`zh`&&p.activityEn?p.activityEn:p.activity:p?.streaming?`…`:void 0,_=e.locked&&e.maxRounds>0?e.maxRounds:0,v=_>0?s===`zh`?`第 ${e.round}/${_} 轮`:`Round ${e.round}/${_}`:`${o(`goalBarRound`,{n:e.round})}${e.locked?` · ${o(`goalBarUnlimitedShort`)}`:``}`,y=(e.usage?.inputTokens??0)+(e.usage?.outputTokens??0),b=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`,x=!u&&e.execModel===void 0,[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(e.reviewModel??``),[E,D]=(0,g.useState)(e.maxRounds),[O,k]=(0,g.useState)(e.locked),[A,j]=(0,g.useState)(e.execModel??``),[ee,M]=(0,g.useState)(!1),[te,N]=(0,g.useState)(!1),[ne,F]=(0,g.useState)(!1),[re,I]=(0,g.useState)(!1),[ie,R]=(0,g.useState)(!0);(0,g.useEffect)(()=>{T(e.reviewModel??``),D(e.maxRounds||0),k(e.locked),j(e.execModel??``)},[e.goal,e.reviewModel,e.maxRounds,e.locked,e.execModel]),(0,g.useEffect)(()=>{ee&&t.length===0&&!re&&!n&&(I(!0),$({type:`list_models`}))},[ee,t.length,re,n]),(0,g.useEffect)(()=>{t.length>0&&I(!1)},[t.length]);let z=()=>w?t.find(e=>e.id===w)?.name??w:o(`goalBarUseMainModel`),B=()=>A?t.find(e=>e.id===A)?.name??A:o(`goalBarUseMainModel`),H=()=>{let e=S.trim();e&&($({type:`set_goal`,goal:e,...w?{reviewModel:w}:{},maxRounds:E,locked:O,...A?{execModel:A}:{}}),C(``),R(!1))},ae=()=>{let e=S.trim();$({type:`set_plan_mode`,enabled:!0}),e&&($({type:`prompt`,text:e}),C(``))},oe=()=>{let e=S.trim();e&&($({type:`start_goal_wizard`,text:e,...w?{wizardModel:w}:{},maxRounds:E,locked:O}),C(``),R(!1))},se=i===void 0?[`host:goal-pill`,`host:goal-set`,`host:goal-wizard`,`host:goal-plan`,`host:goal-lock`,`host:goal-collapse`,`host:goal-model`,`host:goal-execmodel`,`host:goal-rounds`,`host:goal-openrole`,`host:goal-clear`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),W=e=>{let t=new Set(e);return se.filter(e=>t.has(e.id)||e.source!==`host`)},ce=(e,t)=>{let n=se.find(t=>t.id===e);return n?.labelExplicit?n.label:t},le={"host:goal-pill":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-hint`,title:o(`goalBarPlaceholder`),onClick:()=>R(!1),children:[(0,X.jsx)(V,{}),` `,(0,X.jsx)(`span`,{children:ce(`host:goal-pill`,o(`goalBarTitle`))})]}),"host:goal-set":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn`,disabled:!S.trim(),onClick:H,children:ce(`host:goal-set`,o(`goalBarSet`))}),"host:goal-wizard":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn action wizard`,disabled:!S.trim(),title:o(`goalWizardTip`),onClick:oe,children:ce(`host:goal-wizard`,o(`goalWizardBtn`))}),"host:goal-plan":u?null:(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn action plan`,disabled:!S.trim(),title:o(`planActionTip`),onClick:ae,children:ce(`host:goal-plan`,o(`planActionBtn`))}),"host:goal-lock":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(O?`goalBarLocked`:`goalBarUnlocked`),onClick:()=>k(e=>($({type:`set_goal_prefs`,locked:!e}),!e)),children:O?(0,X.jsx)(Te,{}):(0,X.jsx)(L,{})}),"host:goal-collapse":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarClear`),onClick:()=>R(!0),children:(0,X.jsx)(ct,{})}),"host:goal-model":u?(0,X.jsx)(`p`,{className:`goalbar-dsh-note`,children:o(`dshNoReviewModel`)}):(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:`${o(`goalBarReviewModel`)}: ${z()}`,children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${ce(`host:goal-model`,o(`goalBarReviewModel`))}:`}),(0,X.jsx)(`b`,{children:z()})]}),open:ee,onOpenChange:M,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarReviewModel`)}),(re||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!re&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(Ht,{active:w===``,onClick:()=>{T(``),M(!1),$({type:`set_goal_prefs`,reviewModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(Ht,{active:w===e.id,onClick:()=>{T(e.id),M(!1),$({type:`set_goal_prefs`,reviewModel:e.id})},children:(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:e.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:e.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:e.id.split(`/`).slice(1).join(`/`)})]})]})},e.id)),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`list_models`}),children:o(`refreshModels`)})]}),"host:goal-rounds":(0,X.jsxs)(`label`,{className:`goalbar-round`,title:o(`goalBarMaxRoundsTip`),children:[(0,X.jsx)(`span`,{children:ce(`host:goal-rounds`,o(`goalBarMaxRounds`))}),(0,X.jsx)(`input`,{type:`number`,min:0,step:1,value:E,placeholder:o(`goalBarUnlimitedShort`),onChange:e=>{let t=parseInt(e.target.value,10);if(Number.isNaN(t)||t<0){D(0);return}D(t)},onBlur:()=>$({type:`set_goal_prefs`,maxRounds:E}),onKeyDown:e=>{e.key===`Enter`&&($({type:`set_goal_prefs`,maxRounds:E}),e.target.blur())}})]}),"host:goal-execmodel":u?null:(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:`${o(`goalBarExecModel`)}: ${B()} · ${o(`goalBarExecModelTip`)}`,children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${ce(`host:goal-execmodel`,o(`goalBarExecModel`))}:`}),(0,X.jsx)(`b`,{children:B()})]}),open:te,onOpenChange:N,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarExecModel`)}),(re||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!re&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(Ht,{active:A===``,onClick:()=>{j(``),N(!1),$({type:`set_goal_prefs`,execModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(Ht,{active:A===e.id,onClick:()=>{j(e.id),N(!1),$({type:`set_goal_prefs`,execModel:e.id})},children:(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:e.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:e.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:e.id.split(`/`).slice(1).join(`/`)})]})]})},e.id))]})},ue=(e.wizard?.active??!1)&&d;if(ue)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${ue?`wizard`:``}`,children:(0,X.jsxs)(`div`,{className:`goalbar-active-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:(0,X.jsx)(`span`,{className:`goalbar-spin`,children:`🔍`})}),(0,X.jsxs)(`span`,{className:`goalbar-text`,title:e.wizard?.draft??``,children:[o(`goalWizardRunning`),`: `,e.wizard?.draft]}),(0,X.jsxs)(`span`,{className:`goalbar-chip reviewing`,children:[o(`goalBarRound`,{n:(e.wizard?.step??0)+1}),` / `,e.wizard?.maxSteps??6]}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:l||o(`goalBarReviewing`)}),Kh(W([`host:goal-clear`]),{...le,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),onClick:()=>{$({type:`clear_goal`}),R(!0)},children:(0,X.jsx)(P,{})})},a)]})});if(f)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${e.reviewing?`reviewing`:``}`,children:(0,X.jsxs)(`div`,{className:`goalbar-active-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:e.reviewing?(0,X.jsx)(`span`,{className:`goalbar-spin`,children:`◌`}):`🎯`}),(0,X.jsx)(`span`,{className:`goalbar-text`,title:e.goal??``,children:e.goal}),e.reviewing?(0,X.jsxs)(`span`,{className:`goalbar-chip reviewing`,children:[e.phase===`executing`?o(`goalBarExecuting`):o(`goalBarReviewing`),` `,v]}):(0,X.jsx)(`span`,{className:`goalbar-chip ${e.verdict===`pass`?`pass`:e.verdict===`fail`?`fail`:e.verdict===`blocked`?`blocked`:``}`,children:e.verdict===`pass`?o(`goalBarPassed`):e.verdict===`fail`?o(`goalBarFailed`):e.verdict===`blocked`?o(`goalBarBlocked`):`${o(`goalBarRound`,{n:e.round||1})} · ${e.locked?o(`goalBarLocked`):o(`goalBarUnlocked`)}`}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:c}),h&&(0,X.jsxs)(`span`,{className:`goalbar-detail`,title:p?.convId,children:[`· `,h]}),y>0&&(0,X.jsxs)(`span`,{className:`goalbar-detail`,title:`${e.usage?.inputTokens??0} in / ${e.usage?.outputTokens??0} out`,children:[`· `,b(y),` tokens`]}),x&&(0,X.jsx)(`span`,{className:`goalbar-stale`,children:o(`goalBarStaleBackend`)}),Kh(W([`host:goal-openrole`,`host:goal-clear`]),{...le,"host:goal-openrole":m?(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarOpenExecTip`),onClick:()=>$({type:`switch_conversation`,id:m}),children:(0,X.jsx)(yt,{})}):null,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x${e.reviewing?` stopping`:``}`,title:ce(`host:goal-clear`,e.reviewing?o(`goalBarStop`):o(`goalBarClear`)),onClick:()=>{e.goal&&C(e.goal),$({type:`clear_goal`}),R(!1)},children:e.reviewing?(0,X.jsx)(U,{}):(0,X.jsx)(P,{})})},a)]})});if(ie){let e=Kh(W([`host:goal-pill`]),le,a);return e?(0,X.jsx)(`div`,{className:`goalbar-collapsed`,children:e}):null}return(0,X.jsxs)(`div`,{className:`goalbar`,children:[(0,X.jsxs)(`div`,{className:`goalbar-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:(0,X.jsx)(V,{})}),(0,X.jsx)(`input`,{className:`goalbar-input`,value:S,placeholder:o(`goalBarPlaceholder`),title:o(`goalBarPlaceholder`),onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&H()}}),Kh(W([`host:goal-set`,`host:goal-wizard`,`host:goal-plan`,`host:goal-lock`,`host:goal-collapse`]),le,a)]}),(0,X.jsxs)(`div`,{className:`goalbar-opts`,children:[W([`host:goal-model`,`host:goal-execmodel`,`host:goal-rounds`]).filter(e=>e.source===`host`).map(e=>(0,X.jsx)(g.Fragment,{children:le[e.id]},e.id)),e.history&&e.history.length>0&&(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:o(`goalHistory`),children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${o(`goalHistory`)}:`}),(0,X.jsx)(`b`,{children:e.history.length})]}),open:ne,onOpenChange:F,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalHistory`)}),e.history.map((e,t)=>(0,X.jsx)(Ht,{onClick:()=>{C(e.goal),F(!1)},children:(0,X.jsxs)(`span`,{className:`dd-model-cell`,title:e.goal,children:[(0,X.jsxs)(`span`,{className:`dd-model-name`,children:[e.verdict===`pass`?`✅ `:e.verdict===`fail`?`❌ `:`⚠️ `,e.goal.length>42?`${e.goal.slice(0,42)}…`:e.goal]}),(0,X.jsx)(`span`,{className:`dd-model-meta`,children:(0,X.jsxs)(`span`,{className:`dd-model-id`,children:[o(`goalBarRound`,{n:e.rounds}),` · `,new Date(e.finishedAt).toLocaleString()]})})]})},`${e.finishedAt}-${t}`))]}),(0,X.jsx)(`span`,{className:`goalbar-lock-hint`,children:o(O?`goalBarLocked`:`goalBarUnlocked`)}),x&&(0,X.jsx)(`span`,{className:`goalbar-stale`,children:o(`goalBarStaleBackend`)})]})]})});function $_(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e}function ev({mode:e,currentCwd:t,currentSandbox:n,sandboxDiff:r,projects:i,send:a,onClose:o}){let s=Z(),c=n?.sourcePath||(!n&&t?t:i.find(e=>!e.sandbox)?.path||t||``),[l,u]=(0,g.useState)(c?`import`:`blank`),[d,f]=(0,g.useState)(c),[p,m]=(0,g.useState)(!0),[h,_]=(0,g.useState)(``),v=n?.sourcePath?`${n.sourcePath}-exp`:`~/projects/${(n?.name||`sandbox-app`).replace(/[^a-zA-Z0-9_-]+/g,`-`).replace(/^-|-$/g,``)||`sandbox-app`}`,[y,b]=(0,g.useState)(v),[x,S]=(0,g.useState)(!0);(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),(0,g.useEffect)(()=>{e===`apply`&&n?.path&&a({type:`diff_sandbox`,path:n.path})},[e,n?.path,a]);let C=i.filter(e=>!e.sandbox),w=e=>{e.preventDefault();let t=l===`import`?d.trim():void 0;(l!==`import`||t)&&(a({type:`create_sandbox`,name:h.trim()||void 0,sourcePath:t,ephemeral:p}),o())},T=e=>{e.preventDefault();let t=y.trim();t&&(a({type:`promote_sandbox`,path:n?.path,targetPath:t,switchToTarget:x}),o())},E=e=>{e.preventDefault(),n?.path&&(a({type:`apply_sandbox_to_source`,path:n.path}),o())},D=r&&n&&(r.sandboxId===n.id||r.path===n.path),O=D?r.added.length+r.modified.length:0,k=s(e===`create`?`sandboxModalTitle`:e===`promote`?`sandboxPromoteTitle`:`sandboxApplyTitle`);return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:o,children:(0,X.jsxs)(`div`,{className:`modal sandbox-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,onClick:o,title:s(`close`),"aria-label":s(`close`),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(`span`,{className:`modal-head-icon`,"aria-hidden":!0,children:`🧪`}),(0,X.jsx)(`h2`,{children:k})]}),e===`create`?(0,X.jsxs)(`form`,{className:`modal-body sandbox-modal-body`,onSubmit:w,children:[(0,X.jsx)(`p`,{className:`sandbox-modal-subtitle`,children:s(`sandboxModalSubtitle`)}),(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxModeLabel`)}),(0,X.jsxs)(`div`,{className:`sandbox-choice-grid`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-choice-card ${l===`import`?`active`:``}`,onClick:()=>u(`import`),children:[(0,X.jsxs)(`div`,{className:`sandbox-choice-title`,children:[`📦 `,s(`sandboxModeImport`)]}),(0,X.jsx)(`div`,{className:`sandbox-choice-desc`,children:s(`sandboxModeImportDesc`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-choice-card ${l===`blank`?`active`:``}`,onClick:()=>u(`blank`),children:[(0,X.jsxs)(`div`,{className:`sandbox-choice-title`,children:[`✨ `,s(`sandboxModeBlank`)]}),(0,X.jsx)(`div`,{className:`sandbox-choice-desc`,children:s(`sandboxModeBlankDesc`)})]})]})]}),l===`import`&&(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxSourceLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`sandbox-text-input`,value:d,onChange:e=>f(e.target.value),placeholder:s(`sandboxSourcePlaceholder`),required:!0}),C.length>0&&(0,X.jsx)(`div`,{className:`sandbox-source-chips`,children:C.slice(0,6).map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-source-chip ${d===e.path?`active`:``}`,onClick:()=>f(e.path),title:e.path,children:[`📁 `,$_(e.path)]},e.path))})]}),(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxLifecycleLabel`)}),(0,X.jsxs)(`div`,{className:`sandbox-choice-grid`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-choice-card ${p?`active`:``}`,onClick:()=>m(!0),children:[(0,X.jsxs)(`div`,{className:`sandbox-choice-title`,children:[`⏱ `,s(`sandboxLifecycleEphemeral`)]}),(0,X.jsx)(`div`,{className:`sandbox-choice-desc`,children:s(`sandboxLifecycleEphemeralDesc`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-choice-card ${p?``:`active`}`,onClick:()=>m(!1),children:[(0,X.jsxs)(`div`,{className:`sandbox-choice-title`,children:[`📌 `,s(`sandboxLifecyclePermanent`)]}),(0,X.jsx)(`div`,{className:`sandbox-choice-desc`,children:s(`sandboxLifecyclePermanentDesc`)})]})]})]}),(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxNameLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`sandbox-text-input`,value:h,onChange:e=>_(e.target.value),placeholder:l===`import`&&d.trim()?`${$_(d.trim())} (Sandbox)`:s(`sandboxNamePlaceholder`)})]}),(0,X.jsxs)(`div`,{className:`sandbox-modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`submit`,className:`btn primary`,disabled:l===`import`&&!d.trim(),children:[`🧪 `,s(`sandboxCreateSubmit`)]})]})]}):e===`promote`?(0,X.jsxs)(`form`,{className:`modal-body sandbox-modal-body`,onSubmit:T,children:[(0,X.jsx)(`p`,{className:`sandbox-modal-subtitle`,children:s(`sandboxPromoteSubtitle`,{name:n?.name||``})}),(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxPromoteTargetLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`sandbox-text-input`,value:y,onChange:e=>b(e.target.value),placeholder:s(`sandboxPromoteTargetPlaceholder`),autoFocus:!0,required:!0})]}),(0,X.jsxs)(`label`,{className:`sandbox-checkbox-row`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,X.jsx)(`span`,{children:s(`sandboxPromoteSwitchLabel`)})]}),(0,X.jsxs)(`div`,{className:`sandbox-modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`submit`,className:`btn primary`,disabled:!y.trim(),children:[`📤 `,s(`sandboxPromoteSubmit`)]})]})]}):(0,X.jsxs)(`form`,{className:`modal-body sandbox-modal-body`,onSubmit:E,children:[(0,X.jsx)(`p`,{className:`sandbox-modal-subtitle`,children:s(`sandboxActionApplyConfirm`,{name:n?.name||``,source:n?.sourcePath||``})}),D?r.error?(0,X.jsx)(`div`,{className:`sandbox-diff-empty`,children:r.error}):(0,X.jsxs)(`div`,{className:`sandbox-diff-box`,children:[(0,X.jsx)(`div`,{className:`sandbox-diff-stats`,children:s(`sandboxDiffStats`,{added:r.added.length,modified:r.modified.length,deleted:r.deleted.length,unchanged:r.unchangedCount})}),r.added.length+r.modified.length+r.deleted.length===0?(0,X.jsx)(`div`,{className:`sandbox-diff-empty`,children:s(`sandboxDiffEmpty`)}):(0,X.jsxs)(`div`,{className:`sandbox-diff-list`,children:[r.added.map(e=>(0,X.jsxs)(`div`,{className:`sandbox-diff-item added`,children:[(0,X.jsx)(`span`,{className:`sandbox-diff-tag added`,children:`+`}),(0,X.jsx)(`span`,{className:`sandbox-diff-path`,children:e})]},`a:${e}`)),r.modified.map(e=>(0,X.jsxs)(`div`,{className:`sandbox-diff-item modified`,children:[(0,X.jsx)(`span`,{className:`sandbox-diff-tag modified`,children:`~`}),(0,X.jsx)(`span`,{className:`sandbox-diff-path`,children:e})]},`m:${e}`)),r.deleted.map(e=>(0,X.jsxs)(`div`,{className:`sandbox-diff-item deleted`,children:[(0,X.jsx)(`span`,{className:`sandbox-diff-tag deleted`,children:`-`}),(0,X.jsx)(`span`,{className:`sandbox-diff-path`,children:e})]},`d:${e}`))]}),r.deleted.length>0&&(0,X.jsx)(`div`,{className:`sandbox-diff-note`,children:s(`sandboxDiffDeletedNote`)})]}):(0,X.jsx)(`div`,{className:`sandbox-diff-loading`,children:s(`loading`)}),(0,X.jsxs)(`div`,{className:`sandbox-modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`submit`,className:`btn primary`,disabled:!D||O===0,children:[`✅ `,s(`sandboxApplySubmit`,{count:O})]})]})]})]})})}var tv=[{id:`host:conn`,align:`start`},{id:`host:engine`,align:`start`},{id:`host:ctx`,align:`start`},{id:`host:cost`,align:`start`},{id:`host:cache`,align:`start`},{id:`host:msg-count`,align:`start`},{id:`host:plugin-status`,align:`start`},{id:`host:status-delegate`,align:`start`},{id:`host:working`,align:`start`},{id:`host:host-metrics`,align:`end`},{id:`host:cwd`,align:`end`}];function nv({chat:e,bottombarItems:t,onUiAction:n,onOpenSettings:r,onViewChange:i,onOpenGlobalSearch:a,onOpenBgTasks:o}){let s=La(`workspaceRoots`),c=e.state,[l,u]=(0,g.useState)(!1);if(!c)return null;let d=t?t.map(e=>({id:e.id,entry:e,fallbackAlign:`start`})):tv.map(({id:e,align:t})=>({id:e,entry:null,fallbackAlign:t})),f=[],p=[],m=[];for(let{id:t,entry:s,fallbackAlign:c}of d){if(s?.hidden)continue;let d=s??{id:t,slot:`bottombar`,source:`host`,label:t.slice(5),kind:`action`,order:100,align:c,hidden:!1,userOverrides:[],arrangedBy:[]},h=(0,X.jsx)(Mo,{entry:d,bar:`bottom`,chat:e,view:void 0,onViewChange:i,onOpenSettings:r,onOpenGlobalSearch:a,onOpenBgTasks:o,onOpenProjectPicker:()=>u(!0),isProjectPickerOpen:l,onUiAction:n});if(!h)continue;let g=d.align??c;g===`end`?m.push({key:t,node:h}):g===`center`?p.push({key:t,node:h}):f.push({key:t,node:h})}let h=e=>e.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.key));return(0,X.jsxs)(`footer`,{className:`statusbar`,children:[(0,X.jsx)(`div`,{className:`statusbar-left`,children:h(f)}),p.length>0&&(0,X.jsx)(`div`,{className:`statusbar-center`,children:h(p)}),(0,X.jsx)(`div`,{className:`statusbar-right`,children:h(m)}),l&&(0,X.jsx)(oo,{currentCwd:c.cwd,pathCompletions:e.pathCompletions,workspaceRoots:s,onClose:()=>u(!1),onSelectDirectory:e=>{e&&e!==c.cwd&&$({type:`set_cwd`,path:e}),u(!1)},mode:`folder`})]})}var rv=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`,alignable:!0,vertical:!1},{slot:`bottombar`,labelKey:`uiLayoutBottombar`,alignable:!0,vertical:!1},{slot:`sidebar.left`,labelKey:`uiLayoutSidebarLeft`,alignable:!0,vertical:!0},{slot:`sidebar.right`,labelKey:`uiLayoutSidebarRight`,alignable:!0,vertical:!0}],iv=`__tray`,av=[`start`,`center`,`end`];function ov(e,t){return e(t===`start`?`uiLayoutAlignTop`:t===`end`?`uiLayoutAlignBottom`:`uiLayoutAlignMiddle`)}function sv(e,t=new Set){let n={},r=[],i=new Set;for(let a of rv){let o=(e[a.slot]??[]).filter(e=>!t.has(e.id));n[a.slot]=o;for(let e of o)e.hidden&&(r.push(e),i.add(e.id))}for(let n of e[`topbar.overflow`]??[])t.has(n.id)||i.has(n.id)||(r.push(n),i.add(n.id));return{zones:n,tray:r}}function cv(e,t){for(let n of Object.values(e.zones)){let e=n.find(e=>e.id===t);if(e)return e}return e.tray.find(e=>e.id===t)}function lv(e){return(e??[]).filter(e=>!e.hidden)}function uv(e,t){let n=lv(e);return t===void 0?n:n.filter(e=>(e.align??`start`)===t)}function dv(e){return[...new Set(e)]}function fv(e,t,n){let r=e??{},i=cv(t,n.id);if(!i)return r;let a={...r};i.hidden&&(a.hidden=(r.hidden??[]).filter(e=>e!==n.id),a.shown=dv([...r.shown??[],n.id])),i.slot!==n.slot&&(a.slots={...r.slots,[n.id]:n.slot});let o=n.align;o!==void 0&&(i.align??`start`)!==o&&(a.align={...r.align,[n.id]:o});let s=t.zones[n.slot]??[],c=lv(s),l=e=>o===void 0||(e.align??`start`)===o,u=c.filter(e=>e.id!==n.id&&l(e)).map(e=>e.id),d=Math.max(0,Math.min(Math.trunc(n.index)||0,u.length));u.splice(d,0,n.id);let f=o===void 0?[]:c.filter(e=>e.id!==n.id&&!l(e)).map(e=>e.id),p=new Set(s.map(e=>e.id));return a.order=dv([...(r.order??[]).filter(e=>!p.has(e)&&e!==n.id),...u,...f]),a}function pv(e,t){let n=e??{};return{...n,hidden:dv([...n.hidden??[],t]),shown:(n.shown??[]).filter(e=>e!==t)}}function mv({side:e,items:t,chat:n,view:r,onViewChange:i,onOpenPanel:a,onOpenSettings:o,onOpenBgTasks:s,onOpenGlobalSearch:c,onUiAction:l,uiContextTopbar:u,onOpenProjectPicker:d,onThemeToggle:f,onSoundToggle:p}){let{t:m}=Nn(),[h,_]=(0,g.useState)(!1),v=(0,g.useRef)(null),y=n.settings?.uiLayout?.sideDockFloat===!0,b=y?` side-dock-float`:``,x=t.filter(e=>!e.hidden);if(x.length===0)return null;if(y&&h)return(0,X.jsx)(`div`,{ref:v,className:`side-dock side-dock-${e} side-dock-collapsed${b}`,children:(0,X.jsx)(`button`,{type:`button`,className:`side-dock-btn side-dock-toggle-btn`,"data-tip":`${m(`sideDockExpand`)} (${x.length})`,onClick:()=>_(!1),"aria-label":m(`sideDockExpand`),children:e===`left`?(0,X.jsx)(lt,{}):(0,X.jsx)(ut,{})})});let S=na(x),C=t=>(0,X.jsx)(Mo,{entry:t,bar:e,chat:n,view:r,onViewChange:i,onOpenPanel:a,onOpenSettings:o,onOpenGlobalSearch:c,onOpenBgTasks:s,onOpenProjectPicker:d,onUiAction:l,uiContextEntries:u},t.id);return(0,X.jsxs)(`div`,{ref:v,className:`side-dock side-dock-${e}${b}`,children:[y&&(0,X.jsx)(`button`,{type:`button`,className:`side-dock-btn side-dock-collapse-btn`,"data-tip":m(`sideDockCollapse`),onClick:()=>_(!0),"aria-label":m(`sideDockCollapse`),children:e===`left`?(0,X.jsx)(ut,{}):(0,X.jsx)(lt,{})}),av.map(e=>(0,X.jsx)(`div`,{className:`side-dock-slot side-dock-slot-${e}`,children:S[e].length>0&&(0,X.jsx)(`div`,{className:`side-dock-seg`,children:S[e].map(C)})},e))]})}function hv({dialog:e}){let t=Z(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(0),o=t=>{$({type:`dialog_response`,id:e.id,value:t})};(0,g.useEffect)(()=>{r(``),a(0)},[e.id]),zt(()=>o(null));let s=Array.isArray(e.args[0])?e.args[0]:[],c=typeof e.args[0]==`string`?e.args[0]:``;return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":e.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:t(`pluginRequest`)}),e.title&&e.title!==t(`pluginRequest`)&&(0,X.jsx)(`span`,{className:`dialog-title`,children:e.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:t(`cancel`),onClick:()=>o(null),children:`✕`})]}),e.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[s.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`dialog-option ${t===i?`sel`:``}`,onMouseEnter:()=>a(t),onClick:()=>o(e),children:(0,X.jsx)(_f,{text:e,rawHtml:!0})},t)),s.length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:t(`noOptions`)}),(0,X.jsxs)(`div`,{className:`dialog-custom-row`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:n,placeholder:t(`modelQuestionCustom`),onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&n.trim()&&o(n.trim())}}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!n.trim(),onClick:()=>{n.trim()&&o(n.trim())},children:t(`ok`)})]})]}),e.kind===`confirm`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(_f,{text:c,rawHtml:!0}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o(!1),children:t(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>o(!0),children:t(`ok`)})]})]}),e.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:n,placeholder:c||t(`inputPlaceholder`),autoFocus:!0,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&o(n)}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o(null),children:t(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>o(n),children:t(`ok`)})]})]})]})}var gv=150;function _v({anchorRef:e,enabled:t=!0,className:n,children:r}){let i=(0,g.useRef)(null),a=(0,g.useRef)(null),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)({left:0,top:0}),u=(0,g.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},[]),d=(0,g.useCallback)(()=>{u(),a.current=setTimeout(()=>s(!1),gv)},[u]);return(0,g.useEffect)(()=>{let n=e.current;if(!n)return;let r=()=>{u(),s(!0)};n.addEventListener(`mouseenter`,r);let a=e=>{let t=e.relatedTarget;t&&i.current?.contains(t)||d()};return n.addEventListener(`mouseleave`,a),t&&(n.addEventListener(`focus`,r),n.addEventListener(`blur`,d)),()=>{u(),n.removeEventListener(`mouseenter`,r),n.removeEventListener(`mouseleave`,a),n.removeEventListener(`focus`,r),n.removeEventListener(`blur`,d)}},[e,t,u,d]),(0,g.useLayoutEffect)(()=>{if(!o)return;let t=e.current?.getBoundingClientRect();if(!t)return;let n={left:Math.max(8,t.left-8),top:t.bottom+8};l(e=>e.left===n.left&&e.top===n.top?e:n)},[o,e]),(0,g.useLayoutEffect)(()=>{if(!o)return;let t=i.current,n=e.current;if(!t||!n)return;let r=fu(n.getBoundingClientRect(),t.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});l(e=>e.left===r.left&&e.top===r.top?e:r)},[o,e,r]),(0,g.useEffect)(()=>{if(!o)return;let e=()=>s(!1);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[o]),o?(0,j.createPortal)((0,X.jsx)(`div`,{ref:i,className:`set-tip-bubble open${n?` ${n}`:``}`,role:`tooltip`,style:{position:`fixed`,left:c.left,top:c.top},onMouseEnter:u,onMouseLeave:d,children:r}),document.body):null}var vv=`pi_web_qdraft_`,yv=864e5,bv=new Map;function xv(e){return`${vv}${e}`}function Sv(e){if(!e)return null;try{if(typeof window<`u`&&window.sessionStorage){let t=window.sessionStorage.getItem(xv(e));if(t){let n=JSON.parse(t);if(n&&typeof n==`object`&&n.selections&&typeof n.selections==`object`&&n.customs&&typeof n.customs==`object`&&typeof n.step==`number`)return n.updatedAt&&Date.now()-n.updatedAt>yv?(wv(e),null):n}}}catch{}let t=bv.get(e);return t?t.updatedAt&&Date.now()-t.updatedAt>yv?(bv.delete(e),null):t:null}function Cv(e,t){if(!e)return;let n=Object.values(t.selections).some(e=>e&&e.length>0),r=Object.values(t.customs).some(e=>e&&e.trim().length>0),i=t.step>0;if(!n&&!r&&!i){wv(e);return}let a={selections:{...t.selections},customs:{...t.customs},step:t.step,updatedAt:Date.now()};bv.set(e,a);try{typeof window<`u`&&window.sessionStorage&&window.sessionStorage.setItem(xv(e),JSON.stringify(a))}catch{}}function wv(e){if(e){bv.delete(e);try{typeof window<`u`&&window.sessionStorage&&window.sessionStorage.removeItem(xv(e))}catch{}}}function Tv({question:e,owner:t,conversationTitle:n}){let r=Z(),i=e.conversationTitle||n,[a,o]=(0,g.useState)(()=>Sv(e.id)?.selections??{}),[s,c]=(0,g.useState)(()=>Sv(e.id)?.customs??{}),[l,u]=(0,g.useState)(!1),d=O_(),[f,p]=(0,g.useState)(()=>Sv(e.id)?.step??0),[m,h]=(0,g.useState)(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1),_=(0,g.useRef)(!1);(0,g.useEffect)(()=>{_.current=!1;let n=Sv(e.id);n?(o(n.selections),c(n.customs),p(n.step)):(o({}),c({}),p(0)),u(!1);let r=e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1;h(r),e.deadline&&r<=0&&(wv(e.id),$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}}))},[e.id,e.deadline,t]),(0,g.useEffect)(()=>{_.current||Cv(e.id,{selections:a,customs:s,step:f})},[e.id,a,s,f]),(0,g.useEffect)(()=>{if(!e.deadline)return;let n=setInterval(()=>{h(n=>{let r=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return r<=0&&n>0&&(wv(e.id),$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})),r})},1e3);return()=>clearInterval(n)},[e.id,e.deadline]);let v=(0,g.useCallback)(n=>{_.current=!0,wv(e.id),$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...n?.trim()?{cancelReason:n.trim()}:{},...t?{owner:t}:{}})},[e.id,t]);zt(()=>{v()},!l);let y=(e,t)=>{if(!e.dependsOn)return!0;let n=t[e.dependsOn.questionId]??[];if(e.dependsOn.value===void 0)return n.length>0;let r=Array.isArray(e.dependsOn.value)?e.dependsOn.value:[e.dependsOn.value];return n.some(e=>r.includes(e))},b=e.questions.filter(e=>y(e,a)),x=b.length;(0,g.useEffect)(()=>{if(e.questions.length===0||x>0)return;let n=setTimeout(()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},1500);return()=>clearTimeout(n)},[e.id,e.questions.length,x,t]);let S=Math.min(f,Math.max(0,x-1)),C=b[S];if(!C)return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":`select`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:r(`modelQuestion`)}),i&&(0,X.jsx)(`span`,{className:`question-conv-title`,title:i,children:i}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:()=>v(),children:`✕`})]}),(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-hint`,children:r(`questionNoneAvailable`)})})]});let w=(()=>{if(!C)return[];if(C.optionsMap&&C.dependsOn){let e=a[C.dependsOn.questionId]??[];for(let t of e)if(C.optionsMap[t])return C.optionsMap[t]}return C.options??[]})(),T=n=>{_.current=!0,wv(e.id);let r=e.questions.map(e=>{let t=n[e.id]??[],r=(s[e.id]??``).trim();return{id:e.id,selected:t,...r?{custom:r}:{}}});$({type:`question_answer`,id:e.id,answers:r,...t?{owner:t}:{}})},E=(e,t)=>{o(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},D=(t,n,r)=>{if(r){E(t,n);return}let i={...a,[t]:[n]};o(i);let s=e.questions.filter(e=>y(e,i));S>=s.length-1?T(i):p(S+1)},O=()=>{S>=x-1?T(a):p(S+1)},k=t=>{let n=e.questions.find(e=>e.id===t);return w.length===0&&(n?.options?.length??0)===0||(a[t]?.length??0)>0||(s[t]??``).trim()!==``},A=w.filter(e=>(a[C.id]??[]).includes(e.label)&&e.preview).map(e=>e.preview),j=(C.header||C.question).replace(/\s+/g,` `).trim(),ee=(s[C.id]??``).trim(),M=Object.values(s).map(e=>e?.trim()).filter(Boolean).join(`;
361
- `),te=ee.length>0||M.length>0,N=ee||M;return(0,g.useEffect)(()=>{if(l)return;let e=e=>{let t=e.target;if(!(t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable)){if(e.key>=`1`&&e.key<=`9`){let t=parseInt(e.key,10)-1;if(t<w.length){e.preventDefault(),D(C.id,w[t].label,!!C.multiSelect);return}}if(e.key===`ArrowLeft`&&S>0){e.preventDefault(),p(S-1);return}if(e.key===`ArrowRight`&&S<x-1&&k(C.id)){e.preventDefault(),p(S+1);return}e.key===`Enter`&&k(C.id)&&(e.preventDefault(),O())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,w,C.id,C.multiSelect,S,x,k,O,D]),(0,X.jsxs)(`div`,{className:`dialog-inline${l?` collapsed`:``}`,"data-dialog-kind":`select`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,onClick:l?()=>u(!1):void 0,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:r(`modelQuestion`)}),i&&(0,X.jsx)(`span`,{className:`question-conv-title`,title:i,children:i}),x>1&&(0,X.jsx)(`span`,{className:`question-progress`,children:r(`questionStep`,{cur:S+1,total:x})}),m>=0&&(0,X.jsx)(`span`,{className:`question-timer`,children:m>0?r(`questionTimeout`,{s:m}):r(`questionTimeoutExpired`)}),l&&(0,X.jsx)(`span`,{className:`question-collapsed-preview`,title:j,children:j}),(0,X.jsxs)(`div`,{className:`dialog-head-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-toggle-collapse`,title:r(l?`expandSection`:`collapseSection`),onClick:e=>{e.stopPropagation(),u(e=>!e)},children:l?(0,X.jsx)(ct,{}):(0,X.jsx)(dt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(te?`modelQuestionRejectWithNoteTip`:`cancel`),onClick:e=>{e.stopPropagation(),v(te?N:void 0)},children:`✕`})]})]}),!l&&(0,X.jsxs)(X.Fragment,{children:[x>1&&(0,X.jsx)(`div`,{className:`question-step-pills`,role:`tablist`,children:b.map((e,t)=>{let n=t===S,i=k(e.id),a=e.header||`${r(`modelQuestion`)} ${t+1}`;return(0,X.jsxs)(`button`,{type:`button`,className:`question-step-pill${n?` active`:``}${i?` done`:``}`,onClick:()=>p(t),title:a,"aria-selected":n,children:[(0,X.jsx)(`span`,{className:`question-step-pill-idx`,children:i&&!n?`✓`:t+1}),(0,X.jsx)(`span`,{className:`question-step-pill-label`,children:a})]},e.id)})}),(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,children:C.header??`${r(`modelQuestion`)} ${S+1}`}),(0,X.jsx)(`div`,{className:`question-head`,children:(0,X.jsx)(_f,{text:C.question,rawHtml:!0})}),C.detail&&(0,X.jsx)(`div`,{className:`set-hint`,children:(0,X.jsx)(_f,{text:C.detail,rawHtml:!0})}),w.length>0&&(0,X.jsx)(`div`,{className:`set-list`,children:w.map((e,t)=>{let n=(a[C.id]??[]).includes(e.label),r=e.recommended??(t===0&&w.length>1),i=t<9?t+1:void 0;return(0,X.jsx)(Ev,{label:e.label,description:e.description,mark:C.multiSelect?n?`☑ `:`☐ `:n?`● `:`○ `,active:n,keyNumber:i,recommended:r,onPick:()=>D(C.id,e.label,!!C.multiSelect)},e.label)})}),A.length>0&&(0,X.jsxs)(`div`,{className:`question-preview`,children:[(0,X.jsx)(`div`,{className:`question-preview-label`,children:r(`optionPreview`)}),A.map((e,t)=>(0,X.jsx)(`div`,{className:`question-preview-body`,children:(0,X.jsx)(_f,{text:e,rawHtml:!0})},t))]}),(0,X.jsx)(`input`,{className:`set-prompt-input question-custom`,placeholder:r(`modelQuestionCustom`),value:s[C.id]??``,onChange:e=>c(t=>({...t,[C.id]:e.target.value})),onCompositionEnd:d.onCompositionEnd,onKeyDown:e=>{d.isImeKey(e.nativeEvent)||e.key===`Enter`&&(e.preventDefault(),k(C.id)&&O())}})]},C.id),(0,X.jsxs)(`div`,{className:`dialog-nav`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss-inline${te?` reject-note`:``}`,onClick:()=>v(te?N:void 0),title:r(te?`modelQuestionRejectWithNoteTip`:`cancel`),children:r(te?`modelQuestionRejectWithNote`:`cancel`)}),(0,X.jsxs)(`div`,{className:`dialog-nav-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-prev`,disabled:S===0,onClick:()=>p(S-1),children:r(`previous`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-submit`,disabled:!k(C.id),onClick:O,children:S===x-1?r(`modelQuestionSubmit`):r(`next`)})]})]})]})]})}function Ev({label:e,description:t,mark:n,active:r,keyNumber:i,recommended:a,onPick:o}){let s=(0,g.useRef)(null),c=Z();return(0,X.jsxs)(`button`,{type:`button`,ref:s,className:`set-row question-option${r?` active`:``}`,onClick:o,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:`question-key-badge`,title:c(`keyShortcutTip`,{key:i}),children:i}),(0,X.jsx)(`span`,{className:`question-mark`,children:n}),(0,X.jsx)(_f,{text:e,rawHtml:!0}),a&&(0,X.jsx)(`span`,{className:`question-recommended-badge`,children:c(`recommended`)})]}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-desc`,children:(0,X.jsx)(_f,{text:t,rawHtml:!0})}),(0,X.jsx)(_v,{anchorRef:s,enabled:pu(),className:`question-desc-tip`,children:(0,X.jsx)(_f,{text:t,rawHtml:!0})})]})]})}var Dv=e=>`'${e.replace(/'/g,`'\\''`)}'`,Ov=`pi-web-ui:scm-sidebar-width`;function kv(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function Av(e){return e===null||e.trim()===``?300:kv(Number(e))}function jv(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function Mv(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>jv(e,t)))}var Nv=`scm-commit-history`;function Pv(e=localStorage){try{let t=e.getItem(Nv);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Fv(e,t=localStorage){let n=e.trim();if(!n)return Pv(t);let r=[n,...Pv(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(Nv,JSON.stringify(r))}catch{}return r}var Iv={idx:-1,draft:``};function Lv(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:Iv,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}function Rv(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function zv({chat:e,terminal:t,active:n,onSwitchToTerminal:r,uiScmToolbar:i,onUiAction:a}){let o=Z(),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)([]),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(new Map),[h,_]=(0,g.useState)(`changes`),[v,y]=(0,g.useState)([]),[b,x]=(0,g.useState)(null),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(null),[O,k]=(0,g.useState)(null),[A,j]=(0,g.useState)(!1),[ee,M]=(0,g.useState)(!1),[te,N]=(0,g.useState)(!1),[P,ne]=(0,g.useState)(null),[F,re]=(0,g.useState)(!1),[I,L]=(0,g.useState)(!1),[ie,R]=(0,g.useState)(null),[z,V]=(0,g.useState)(()=>Av(localStorage.getItem(Ov))),[H,U]=(0,g.useState)(``),[ae,oe]=(0,g.useState)(``),[se,W]=(0,g.useState)(()=>Pv()),ce=(0,g.useRef)(Iv),le=(0,g.useRef)(0),ue=(0,g.useRef)(-1),de=(0,g.useRef)(-1),fe=(0,g.useRef)(-1),pe=(0,g.useRef)(-1),G=(0,g.useRef)(-1),me=(0,g.useRef)(void 0),he=(0,g.useRef)(null),ge=(0,g.useRef)([]),q=(0,g.useRef)(z);q.current=z;let _e=(0,g.useRef)(null),ve=(0,g.useCallback)(e=>{try{localStorage.setItem(Ov,String(e))}catch{}},[]),ye=(0,g.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=q.current,r=_e.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=kv(n+(e.clientX-t),r),V(i)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.classList.remove(`panel-resizing`),ve(i)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),document.body.classList.add(`panel-resizing`)},[ve]),be=(0,g.useCallback)(()=>{V(300),ve(300)},[ve]),xe=(0,g.useCallback)(e=>{if(e.reqId===ue.current){if(ue.current=-1,M(!1),ne(null),!e.ok){ne(e.error??o(`scmQueryFailedShort`));return}if(e.notRepo){re(!0),c(null),u([]),m(new Map),y([]),x(null),C(``),k(null);return}re(!1);let t={branch:e.branch??``,detached:!!e.detached,upstream:e.upstream??null,ahead:e.ahead??0,behind:e.behind??0,upstreamGone:!!e.upstreamGone,files:(e.files??[]).map(e=>({...e}))},n=(e.branches??[]).map(e=>({...e})),r=new Map;for(let[t,n]of Object.entries(e.stats??{}))r.set(t,{add:n[0],del:n[1]});c(t),u(n),m(r),f(e=>t.detached?e||``:t.branch&&n.some(e=>e.name===t.branch)?t.branch:e&&n.some(t=>t.name===e)?e:n[0]?.name??``),k(e=>e&&!t.files.some(t=>t.path===e.file.path)?null:e)}else if(e.reqId===de.current){if(de.current=-1,j(!1),!e.ok){ne(e.error??o(`scmQueryFailedShort`));return}let t=he.current;if(!t)return;k({file:t,staged:e.stagedText??``,worktree:e.worktreeText??``,untracked:!1})}else if(e.reqId===pe.current){if(pe.current=-1,N(!1),!e.ok){ne(e.error??o(`scmQueryFailedShort`));return}y((e.history??[]).map(e=>({...e})))}else if(e.reqId===fe.current){if(fe.current=-1,T(!1),!e.ok){ne(e.error??o(`scmQueryFailedShort`));return}C(e.text??``)}else if(e.reqId===G.current){if(G.current=-1,L(!1),!e.ok){R(e.error??o(`scmGenMsgFail`));return}R(null),U(e.text??``)}},[]);(0,g.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&xe(t)},[e.scmData,xe]);let J=(0,g.useCallback)((t,n)=>{if(!e.ready||e.status!==`open`)return!1;let r=++le.current;return $({...t,reqId:r})?(n.current=r,!0):(--le.current,!1)},[e.ready,e.status]),Se=(0,g.useCallback)((t=!1,n=!1)=>{e.ready&&e.status===`open`&&e.state?.cwd&&(me.current!==void 0&&me.current!==e.state.cwd&&(c(null),u([]),m(new Map),y([]),oe(``),N(!1),pe.current=-1,x(null),C(``),k(null),D(null),R(null),L(!1),G.current=-1),me.current=e.state.cwd,ne(null),J({type:`scm_status`},ue)&&(n||M(!0)))},[e.ready,e.state?.cwd,e.status,J]),Ce=(0,g.useCallback)(e=>{if(D(e),x(null),he.current=e,e.x===`?`&&e.y===`?`){k({file:e,staged:``,worktree:``,untracked:!0});return}j(!0),ne(null),J({type:`scm_filediff`,path:e.path},de)||j(!1)},[J]),we=(0,g.useCallback)(e=>{x(e),D(null),k(null),C(``),T(!0),ne(null),J({type:`scm_commit`,hash:e.hash},fe)||T(!1)},[J]),Te=(0,g.useCallback)((n,i)=>{if(!e.ready)return;let a={name:n,command:i,cwd:"${pwd}"},o,s=e.terminals.find(e=>e.title===n);s?(t.restart(s.id),$({type:`run_command`,terminalId:s.id,conversationId:s.conversationId,command:a,cols:80,rows:24}),o=s.id):(o=jt(),t.create({id:o,conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:a})),t.select(o),r()},[e.ready,e.state?.cwd,e.terminals,r,t]),Ee=(0,g.useCallback)(()=>{let e=H.trim();if(!e||F)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);Te(`git commit`,`git commit -m "${t}"`),W(Fv(e)),U(``),ce.current=Iv},[H,F,Te]),De=(0,g.useCallback)(()=>{let e=H.trim();if(!e||F)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);Te(`git commit`,`git add -A && git commit -m "${t}"`),W(Fv(e)),U(``),ce.current=Iv},[H,F,Te]),Oe=(0,g.useCallback)(e=>{F||Te(`git add`,`git add -- ${Dv(e.path)}`)},[F,Te]),ke=(0,g.useCallback)(e=>{F||Te(`git reset`,`git reset HEAD -- ${Dv(e.path)}`)},[F,Te]),Ae=(0,g.useCallback)(()=>{if(!d||F)return;let e=l.find(e=>e.name===d);if(e?.remote&&typeof e.remote==`string`){let t=d.slice(e.remote.length+1);Te(`git checkout`,`git checkout -b ${t} ${d} || git checkout ${d}`)}else Te(`git checkout`,`git checkout ${d}`)},[d,l,F,Te]),je=(0,g.useCallback)(()=>Te(`git push`,`git push`),[Te]),Me=(0,g.useCallback)(()=>Te(`git pull`,`git pull`),[Te]),Ne=(0,g.useCallback)(()=>{I||F||!e.ready||e.status!==`open`||(R(null),J({type:`scm_commitmsg`},G)?L(!0):R(o(`scmGenMsgFail`)))},[I,F,e.ready,e.status,J,o]),Pe=(0,g.useCallback)(()=>{J({type:`scm_history`},pe)||(pe.current=-1)},[J]);(0,g.useEffect)(()=>{n&&Se()},[n,Se]),(0,g.useEffect)(()=>{h===`history`&&s&&Pe()},[h,s,Pe]),(0,g.useEffect)(()=>{e.scmDirty>0&&n&&Se(!1,!0)},[e.scmDirty]),(0,g.useEffect)(()=>{if(!n||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&Se(!1,!0)},3e4);return()=>clearInterval(t)},[n,e.ready,e.status,Se]),(0,g.useEffect)(()=>{let t=ge.current;ge.current=e.terminals,n&&e.terminals.some(e=>e.running===!1&&t.find(t=>t.id===e.id)?.running===!0&&e.title.startsWith(`git `))&&e.ready&&e.status===`open`&&(Se(!1,!0),h===`history`&&s&&Pe())},[e.terminals,n,e.ready,e.status,Se,h,s,Pe]);let Fe={staged:o(`scmStaged`),unstaged:o(`scmUnstaged`),untracked:o(`scmUntracked`),both:o(`scmStagedUnstaged`)},Ie=Mv(v,ae),Re=e=>{let t=e.split(`
362
- `);return(0,X.jsx)(`pre`,{className:`scm-diff-pre`,children:t.map((e,t)=>{let n=``;return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,X.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})},ze=i===void 0?[`host:scm-changes`,`host:scm-history`,`host:scm-refresh`,`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`,`host:scm-term`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),Be=[`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`],Ve=(e,t)=>{let n=new Set(e);return ze.filter(e=>n.has(e.id)||t&&e.source!==`host`)},He=e=>i===void 0||!i.some(t=>t.id===e&&t.hidden),Ue=(e,t)=>{let n=ze.find(t=>t.id===e);return n?.labelExplicit?n.label:t},We={"host:scm-changes":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`changes`,className:h===`changes`?`active`:``,onClick:()=>{_(`changes`),ne(null)},children:Ue(`host:scm-changes`,o(`scmChanges`))}),"host:scm-history":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`history`,className:h===`history`?`active`:``,onClick:()=>{_(`history`),ne(null)},children:Ue(`host:scm-history`,o(`scmHistory`))}),"host:scm-refresh":(0,X.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:o(`scmRefreshTip`),disabled:ee,onClick:()=>Se(!0),children:(0,X.jsx)(K,{className:ee?`scm-spin`:``})}),"host:scm-branch":(0,X.jsxs)(`select`,{className:`scm-select`,value:d,disabled:F||l.length===0,title:Ue(`host:scm-branch`,o(`scmSwitchBranch`)),onChange:e=>f(e.target.value),children:[(0,X.jsx)(`option`,{value:``,disabled:!0,children:o(`scmSelectBranch`)}),l.filter(e=>!e.remote).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.current?`* ${e.name}`:e.name},e.name)),l.some(e=>e.remote)&&(0,X.jsx)(`optgroup`,{label:o(`scmRemoteBranches`),children:l.filter(e=>e.remote).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),"host:scm-switch":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!d||d===s?.branch||F,title:o(`scmSwitchBranchTip`,{branch:d}),onClick:Ae,children:[(0,X.jsx)(Le,{}),Ue(`host:scm-switch`,o(`scmSwitch`))]}),"host:scm-push":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||F,title:o(`scmPushTip`),onClick:je,children:[(0,X.jsx)(vt,{}),Ue(`host:scm-push`,o(`scmPush`))]}),"host:scm-pull":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||F,title:o(`scmPullTip`),onClick:Me,children:[(0,X.jsx)(xt,{}),Ue(`host:scm-pull`,o(`scmPull`))]}),"host:scm-input":(0,X.jsx)(`input`,{className:`scm-commit-input`,value:H,placeholder:o(`scmCommitPlaceholder`),disabled:F,title:se.length>0?o(`scmCommitHistoryTip`):void 0,onChange:e=>{U(e.target.value),ce.current=Iv},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){Ee();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=Lv(se,ce.current,H,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),ce.current=t.state,U(t.text))}}}}),"host:scm-genmsg":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:I||F||!s||s.files.length===0,title:o(`scmGenMsgTip`),onClick:Ne,children:[(0,X.jsx)(Ze,{className:I?`scm-spin`:``}),I?o(`scmGenMsgRunning`):Ue(`host:scm-genmsg`,o(`scmGenMsg`))]}),"host:scm-commit":(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!H.trim()||F,title:o(`scmCommitTip`),onClick:Ee,children:[(0,X.jsx)(ft,{}),Ue(`host:scm-commit`,o(`scmCommit`))]}),"host:scm-commit-all":(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!H.trim()||F,title:o(`scmCommitAllTip`),onClick:De,children:Ue(`host:scm-commit-all`,o(`scmCommitAll`))})};return(0,X.jsxs)(`div`,{className:`scm-view`,children:[(0,X.jsxs)(`div`,{className:`scm-header`,children:[(0,X.jsxs)(`div`,{className:`scm-title-row`,children:[(0,X.jsxs)(`span`,{className:`scm-title`,children:[(0,X.jsx)(Le,{}),o(`scmTitle`)]}),(0,X.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:Kh(Ve([`host:scm-changes`,`host:scm-history`],!1),We,a)}),Kh(Ve([`host:scm-refresh`],!0),We,a)]}),(0,X.jsxs)(`div`,{className:`scm-row`,children:[(0,X.jsxs)(`span`,{className:`scm-branch-current`,title:o(`scmCurrentBranch`),children:[(0,X.jsx)(Le,{}),s?s.detached?o(`scmDetached`):s.branch:`…`,s?.upstream&&(0,X.jsx)(`span`,{className:`scm-upstream`,children:s.upstreamGone?o(`scmUpstreamGone`):s.ahead>0||s.behind>0?o(`scmAheadBehind`,{ahead:s.ahead,behind:s.behind}):s.upstream})]}),Kh(Ve(Be,!1),We,a)]}),ie&&(0,X.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:o(`close`),onClick:()=>R(null),children:ie})]}),(0,X.jsxs)(`div`,{className:`scm-body`,ref:_e,style:{"--scm-sidebar-w":`${z}px`},children:[h===`history`?(0,X.jsxs)(`div`,{className:`scm-history`,children:[(0,X.jsxs)(`div`,{className:`scm-files-header`,children:[(0,X.jsx)(`span`,{children:o(`scmHistory`)}),v.length>0&&(0,X.jsx)(`span`,{className:`scm-files-count`,children:ae.trim()?`${Ie.length}/${v.length}`:v.length})]}),v.length>0&&!F&&(0,X.jsx)(`input`,{className:`scm-history-filter`,value:ae,placeholder:o(`scmHistoryFilterPlaceholder`),title:o(`scmHistoryFilterTip`),onChange:e=>oe(e.target.value)}),(0,X.jsx)(`div`,{className:`scm-history-list`,children:F?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):!s||te?(0,X.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?o(`scmLoading`):o(`scmConnecting`)}):v.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoHistory`)}):Ie.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmHistoryFilterEmpty`)}):Ie.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`scm-commit ${b?.hash===e.hash?`active`:``}`,onClick:()=>we(e),title:e.hash,children:[(0,X.jsx)(`span`,{className:`scm-commit-graph`,"aria-hidden":`true`,children:e.graph||`* `}),(0,X.jsxs)(`span`,{className:`scm-commit-info`,children:[(0,X.jsx)(`span`,{className:`scm-commit-subject`,children:e.subject}),(0,X.jsxs)(`span`,{className:`scm-commit-meta`,children:[e.shortHash,` · `,e.author,` · `,e.date]}),e.decorations&&(0,X.jsx)(`span`,{className:`scm-commit-refs`,children:e.decorations})]})]},e.hash))})]}):(0,X.jsxs)(`div`,{className:`scm-files`,children:[(0,X.jsxs)(`div`,{className:`scm-files-header`,children:[(0,X.jsx)(`span`,{children:o(`scmChanges`)}),s&&s.files.length>0&&(0,X.jsx)(`span`,{className:`scm-files-count`,children:s.files.length})]}),(0,X.jsx)(`div`,{className:`scm-files-list`,children:F?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):s?s.files.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoChanges`)}):s.files.map(e=>{let t=Rv(e),n=p.get(e.path);return(0,X.jsxs)(`div`,{className:`scm-file ${E?.path===e.path?`active`:``}`,title:Fe[t],onClick:()=>Ce(e),children:[(0,X.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`x`}`,children:e.x===` `?`\xA0`:e.x}),(0,X.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`y`}`,children:e.y===` `?`\xA0`:e.y}),(0,X.jsx)(`span`,{className:`scm-file-path`,children:e.path}),n&&(n.add>0||n.del>0)&&(0,X.jsxs)(`span`,{className:`scm-file-stat`,children:[n.add>0&&(0,X.jsxs)(`span`,{className:`add`,children:[`+`,n.add]}),n.del>0&&(0,X.jsxs)(`span`,{className:`del`,children:[`-`,n.del]})]}),(0,X.jsxs)(`span`,{className:`scm-file-actions`,children:[(e.y!==` `||t===`untracked`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-act`,title:o(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),Oe(e)},children:`+`}),t===`staged`||t===`both`?(0,X.jsx)(`button`,{type:`button`,className:`scm-act`,title:o(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),ke(e)},children:`−`}):null]})]},e.path)}):(0,X.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?o(`scmLoading`):o(`scmConnecting`)})})]}),(0,X.jsx)(`div`,{className:`scm-divider`,role:`separator`,"aria-orientation":`vertical`,title:o(`dragToResize`),onPointerDown:ye,onDoubleClick:be}),(0,X.jsxs)(`div`,{className:`scm-diff`,children:[(0,X.jsxs)(`div`,{className:`scm-diff-header`,children:[(0,X.jsx)(`span`,{children:h===`history`?b?`${b.shortHash} ${b.subject}`:o(`scmCommitDetail`):E?E.path:o(`scmDiff`)}),(h===`history`?w:A)&&(0,X.jsx)(`span`,{className:`scm-diff-loading`,children:o(`scmLoading`)})]}),(0,X.jsx)(`div`,{className:`scm-diff-body`,children:h===`history`?(0,X.jsxs)(X.Fragment,{children:[P&&(0,X.jsx)(`div`,{className:`scm-error`,children:P}),!b&&!P&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectCommitHint`)}),b&&w&&!P&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),b&&!w&&!P&&S?Re(S):null]}):(0,X.jsxs)(X.Fragment,{children:[P&&(0,X.jsx)(`div`,{className:`scm-error`,children:P}),!E&&!P&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectFileHint`)}),E&&!O&&!P&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),E&&O&&O.untracked&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmUntrackedNote`)}),E&&O&&!O.untracked&&(0,X.jsxs)(X.Fragment,{children:[O.staged&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmStaged`)}),Re(O.staged)]}),O.worktree&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmUnstaged`)}),Re(O.worktree)]}),!O.staged&&!O.worktree&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoDiff`)})]})]})})]})]}),(0,X.jsxs)(`div`,{className:`scm-hint`,children:[(0,X.jsx)(B,{}),(0,X.jsx)(`span`,{children:o(`scmRunsInTerminal`)}),He(`host:scm-term`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:r,children:Ue(`host:scm-term`,o(`scmViewTerminal`))})]})]})}function Bv({entry:e}){let t=(0,g.useRef)(null),n=Z();return(0,g.useEffect)(()=>{let r=t.current;if(!r)return;let i;try{i=e.module.mount(r,Gc(e.info.id,e=>$(e)))}catch(t){console.error(`[plugin:${e.info.id}] mount failed:`,t),r.textContent=n(`pluginMountFailed`,{name:e.info.name})}return()=>{if(typeof i==`function`)try{i()}catch(t){console.error(`[plugin:${e.info.id}] cleanup failed:`,t)}r.textContent=``}},[e]),(0,X.jsx)(`div`,{className:`plugin-view`,ref:t})}function Vv({pluginId:e,info:t,epoch:n,failed:r}){let i=Z(),[a,o]=(0,g.useState)(!1),s=t?.name||e;return r?(0,X.jsx)(`div`,{className:`view-pane`,children:(0,X.jsxs)(`div`,{className:`plugin-view-fallback`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`plugin-view-fallback-title`,children:[i(`pluginViewLoadFailed`),`:`,s]}),(0,X.jsx)(`div`,{className:`plugin-view-fallback-hint`,children:i(`pluginViewLoadFailedHint`)}),t&&(0,X.jsx)(`button`,{type:`button`,className:`plugin-view-fallback-retry`,onClick:()=>{t&&!a&&(o(!0),Fc(t,n).finally(()=>o(!1)))},disabled:a,children:i(a?`pluginViewLoading`:`pluginViewRetry`)})]})}):(0,X.jsx)(`div`,{className:`view-pane`,children:(0,X.jsx)(`div`,{className:`plugin-view-fallback`,role:`status`,children:i(`pluginViewLoading`)})})}function Hv({onAction:e}){let t=ga(),n=(0,g.useMemo)(()=>t?Ca(t.entries):[],[t]),{items:r,selectParents:i}=(0,g.useMemo)(()=>Sa(n),[n]),a=(0,g.useMemo)(()=>wa(r),[r]),o=(0,g.useMemo)(()=>t?ya(t.slot,t.target):void 0,[t,t?.slot,t?.target.kind]),s=(0,g.useRef)(null),c=(0,g.useRef)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(-1),[p,m]=(0,g.useState)(-1),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(0),b=(0,g.useRef)(-1),x=e=>{b.current=e,f(e)},S=(0,g.useMemo)(()=>p>=0?Ca(r[p]?.children??[]):[],[r,p]),C=(0,g.useMemo)(()=>wa(S),[S]),w=e=>{let n=r[e];if(t&&n&&!xa(n,o)){if(n.children?.length){m(e);return}T(n,t)||pa()}},T=(t,n,r)=>t.source===`host`&&n.onHostAction?n.onHostAction(t,n.target)===!0:(e(t,n.target,r),!1),E=(0,g.useRef)(w);if((0,g.useLayoutEffect)(()=>{E.current=w}),(0,g.useEffect)(()=>{if(!t){b.current=-1,f(-1),m(-1);return}let e=Ea(r,-1,1,o);b.current=e,f(e),m(-1),s.current?.focus()},[t,r,o]),(0,g.useLayoutEffect)(()=>{if(!t){u(null);return}let e=s.current;if(!e)return;let n=e.getBoundingClientRect();u(va(t.x,t.y,n.width,n.height,window.innerWidth,window.innerHeight))},[t,r]),(0,g.useLayoutEffect)(()=>{let e=c.current,t=s.current;if(p<0||!e||!t){_(!1),y(0);return}let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth-r.right,a=r.left;_(i<n.width+8&&a>i);let o=n.bottom-(window.innerHeight-8);y(o>0?-Math.min(o,Math.max(0,n.top-8)):0)},[p,r]),(0,g.useEffect)(()=>{if(!t)return;let e=e=>s.current&&e instanceof Node&&s.current.contains(e),n=t=>{e(t.target)||pa()},r=t=>{e(t.target)||pa()},i=()=>pa();return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`wheel`,r,!0),window.addEventListener(`resize`,i),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`wheel`,r,!0),window.removeEventListener(`resize`,i)}},[t]),(0,g.useEffect)(()=>{if(!t)return;let e=e=>{let t=Ea(r,b.current,e,o);b.current=t,f(t)},n=t=>{switch(t.key){case`Escape`:t.preventDefault(),pa();return;case`Tab`:pa();return;case`ArrowDown`:t.preventDefault(),e(1);return;case`ArrowUp`:t.preventDefault(),e(-1);return;case`ArrowRight`:r[b.current]?.children?.length&&(t.preventDefault(),m(b.current));return;case`ArrowLeft`:p>=0&&(t.preventDefault(),m(-1));return;case`Enter`:case` `:t.preventDefault(),E.current(b.current);return;default:return}};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[t,r,p,o]),(0,g.useEffect)(()=>{d<0||s.current?.querySelector(`[data-ctx-active="true"]`)?.scrollIntoView?.({block:`nearest`})},[d]),!t)return null;let D=e=>{let n=i.get(e.id);if(n){if(xa(n.parent,o))return;t&&!T(n.parent,t,n.value)&&pa();return}xa(e,o)||T(e,t)||pa()},O=(e,t,n)=>{let r=xa(e,o),i=!!e.children?.length,a=Oa(e.icon),s=n&&d===t;return(0,X.jsxs)(`div`,{className:`ctx-menu-itemwrap`,role:`none`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item${r?` disabled`:``}${s?` active`:``}${i?` has-sub`:``}`,"aria-label":e.label,title:e.hint,"aria-disabled":r||void 0,"aria-haspopup":i?`menu`:void 0,"aria-expanded":i?p===t:void 0,"data-ctx-active":s?`true`:void 0,onMouseEnter:n?()=>{x(t),i&&!r&&m(t)}:void 0,onClick:()=>n?w(t):D(e),children:[a?(0,X.jsx)(`span`,{className:`ctx-menu-icon`,"aria-hidden":`true`,children:a}):null,(0,X.jsx)(`span`,{className:`ctx-menu-label`,children:e.label}),e.badge?(0,X.jsx)(`span`,{className:`ctx-menu-badge`,children:e.badge}):null,i?(0,X.jsx)(`span`,{className:`ctx-menu-caret`,"aria-hidden":`true`,children:`▸`}):null]}),n&&i&&p===t?(0,X.jsx)(`div`,{ref:c,className:`ctx-menu-sub${h?` left`:``}`,role:`menu`,"aria-label":e.label,style:v?{marginTop:v}:void 0,children:C.map(e=>e.kind===`sep`?(0,X.jsx)(`div`,{className:`ctx-menu-sep`,role:`separator`},e.key):O(e.entry,e.index,!1))}):null]},`${e.id}#${t}`)};return(0,j.createPortal)((0,X.jsx)(`div`,{ref:s,className:`ctx-menu`,role:`menu`,"aria-label":t.target.label?`${t.slot}: ${t.target.label}`:t.slot,tabIndex:-1,style:{left:l?.x??t.x,top:l?.y??t.y,visibility:l?`visible`:`hidden`},onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},children:a.map(e=>e.kind===`sep`?(0,X.jsx)(`div`,{className:`ctx-menu-sep`,role:`separator`},e.key):O(e.entry,e.index,!0))}),document.body)}var Uv=0,Wv=[],Gv=new Map,Kv=new Set;function qv(){for(let e of Kv)try{e()}catch{}}function Jv(e){let t=Gv.get(e);t!==void 0&&(clearTimeout(t),Gv.delete(e))}function Yv(e){let t=e.id||`banner-${Date.now()}-${++Uv}`,n={...e,id:t,type:e.type||`info`,persistent:!!e.persistent,timeoutMs:e.timeoutMs??5e3,dismissible:e.dismissible!==!1};if(Jv(t),!n.persistent&&n.timeoutMs&&n.timeoutMs>0){let e=setTimeout(()=>{Xv(t)},n.timeoutMs);Gv.set(t,e)}let r=Wv.findIndex(e=>e.id===t);if(r>=0){let e=[...Wv];e[r]=n,Wv=e}else Wv=[...Wv,n];return qv(),t}function Xv(e,t){Jv(e);let n=Wv.find(t=>t.id===e);if(n){if(Wv=Wv.filter(t=>t.id!==e),!t?.silent)try{n.onClose?.()}catch{}qv()}}function Zv(e,t){let n=Wv.filter(e);if(n.length!==0){for(let e of n)if(Jv(e.id),!t?.silent)try{e.onClose?.()}catch{}Wv=Wv.filter(t=>!e(t)),qv()}}function Qv(){return Wv}function $v(e){return Kv.add(e),()=>{Kv.delete(e)}}function ey(){return(0,g.useSyncExternalStore)($v,Qv,Qv)}function ty({type:e}){switch(e){case`question`:return(0,X.jsx)(Ne,{className:`banner-icon banner-icon-question`});case`warning`:return(0,X.jsx)(wt,{className:`banner-icon banner-icon-warning`});case`error`:return(0,X.jsx)(Tt,{className:`banner-icon banner-icon-error`});case`success`:return(0,X.jsx)(pt,{className:`banner-icon banner-icon-success`});default:return(0,X.jsx)(je,{className:`banner-icon banner-icon-info`})}}var ny=(0,g.memo)(function({banner:e}){let t=typeof e.onClick==`function`;return(0,X.jsxs)(`div`,{className:`banner-card banner-type-${e.type||`info`} ${t?`banner-clickable`:``}`,onClick:t?e.onClick:void 0,role:t?`button`:`status`,tabIndex:t?0:void 0,onKeyDown:t?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onClick?.())}:void 0,children:[(0,X.jsx)(`div`,{className:`banner-icon-col`,children:(0,X.jsx)(ty,{type:e.type})}),(0,X.jsxs)(`div`,{className:`banner-content-col`,children:[e.title&&(0,X.jsx)(`div`,{className:`banner-title`,title:e.title,children:e.title}),(0,X.jsx)(`div`,{className:`banner-message`,title:e.message,children:e.message})]}),e.dismissible&&(0,X.jsx)(`button`,{type:`button`,className:`banner-close`,onClick:t=>{t.stopPropagation(),Xv(e.id)},"aria-label":`Close banner`,title:`关闭通知`,children:(0,X.jsx)(P,{})})]})}),ry=(0,g.memo)(function(){let e=ey();return e.length===0?null:(0,X.jsx)(`aside`,{className:`banner-container`,"aria-label":`Notifications`,children:e.map(e=>(0,X.jsx)(ny,{banner:e},e.id))})}),iy={activity:(0,X.jsx)(Et,{}),branch:(0,X.jsx)(Le,{}),browser:(0,X.jsx)(Fe,{}),chat:(0,X.jsx)(J,{}),check:(0,X.jsx)(ft,{}),"chevron-up":(0,X.jsx)(ct,{}),clock:(0,X.jsx)(rt,{}),code:(0,X.jsx)(nt,{}),coins:(0,X.jsx)(Je,{}),copy:(0,X.jsx)(tt,{}),cpu:(0,X.jsx)(Ze,{}),cut:(0,X.jsx)(fe,{}),database:(0,X.jsx)(Ye,{}),dot:(0,X.jsx)(`span`,{className:`host-icon-char`,children:`●`}),download:(0,X.jsx)(qe,{}),edit:(0,X.jsx)(Ke,{}),eye:(0,X.jsx)(Ue,{}),file:(0,X.jsx)(Be,{}),folder:(0,X.jsx)(Re,{}),gauge:(0,X.jsx)(Et,{}),git:(0,X.jsx)(Le,{}),github:(0,X.jsx)(Ie,{}),globe:(0,X.jsx)(Fe,{}),grid:(0,X.jsx)(Pe,{}),hash:(0,X.jsx)(`span`,{className:`host-icon-char`,children:`#`}),image:(0,X.jsx)(Me,{}),info:(0,X.jsx)(je,{}),layers:(0,X.jsx)(ke,{}),link:(0,X.jsx)(Oe,{}),list:(0,X.jsx)(De,{}),lock:(0,X.jsx)(Te,{}),markdown:(0,X.jsx)(Ve,{}),maximize:(0,X.jsx)(we,{}),menu:(0,X.jsx)(Se,{}),message:(0,X.jsx)(J,{}),open:(0,X.jsx)(Ge,{}),paste:(0,X.jsx)(it,{}),pin:(0,X.jsx)(Ct,{}),plus:(0,X.jsx)(me,{}),refresh:(0,X.jsx)(K,{}),save:(0,X.jsx)(pe,{}),search:(0,X.jsx)(de,{}),send:(0,X.jsx)(ue,{}),settings:(0,X.jsx)(ce,{}),sound:(0,X.jsx)(ne,{}),sun:(0,X.jsx)(H,{}),target:(0,X.jsx)(Xe,{}),terminal:(0,X.jsx)(B,{}),text:(0,X.jsx)(ie,{}),trash:(0,X.jsx)(R,{}),undo:(0,X.jsx)(Qe,{}),upload:(0,X.jsx)(re,{}),volume:(0,X.jsx)(ne,{}),wrap:(0,X.jsx)(et,{}),x:(0,X.jsx)(P,{}),zap:(0,X.jsx)(N,{}),zoom:(0,X.jsx)(te,{})};Object.keys(iy);function ay(e){if(e.iconSvg)return(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg});if(!e.icon)return null;let t=iy[e.icon];return t===void 0?/[a-z]/i.test(e.icon)?null:(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:e.icon}):t}function oy({slots:e,layout:t,exclude:n,onClose:r}){let i=Z(),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),l=(0,g.useMemo)(()=>sv(e,n),[e,n]),u=(0,g.useRef)(null),d=(0,g.useRef)(null),f=(0,g.useRef)(l),p=(0,g.useRef)(t),m=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{f.current=l,p.current=t}),(0,g.useEffect)(()=>{m.current=null},[t]);let h=(e,t)=>{let n=document.elementFromPoint(e,t)?.closest(`[data-drop-slot]`);if(!n)return null;let r=n.dataset.dropSlot;if(!r)return null;let i=n.dataset.dropAlign,a=u.current,o=Array.from(n.querySelectorAll(`[data-chip]`)).filter(e=>e.dataset.chip!==a),s=o.length;for(let n=0;n<o.length;n++){let r=o[n].getBoundingClientRect();if(t<r.top){s=n;break}if(t<=r.bottom+4&&e<r.left+r.width/2){s=n;break}}return{slot:r,align:i,index:s}},_=()=>{let e=u.current,t=d.current;if(u.current=null,d.current=null,o(null),c(null),!e||!t)return;let n=m.current??p.current,r=t.slot===`__tray`?pv(n,e):fv(n,f.current,{id:e,slot:t.slot,...t.align===void 0?{}:{align:t.align},index:t.index});m.current=r,$({type:`set_settings`,uiLayout:r})};(0,g.useEffect)(()=>{if(!a)return;let e=e=>{e.preventDefault();let t=h(e.clientX,e.clientY);d.current=t,c(t)},t=()=>_();return window.addEventListener(`pointermove`,e,{passive:!1}),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[a]),zt(()=>{u.current||r()});let v=(e,t)=>{(e.pointerType!==`mouse`||e.button===0)&&(e.preventDefault(),u.current=t,d.current=null,o(t),c(null))},y=e=>(0,X.jsxs)(`button`,{type:`button`,"data-chip":e.id,className:`icon-editor-chip${a===e.id?` dragging`:``}`,title:e.label,onPointerDown:t=>v(t,e.id),children:[(0,X.jsx)(`span`,{className:`icon-editor-chip-icon`,children:ay(e)}),(0,X.jsx)(`span`,{className:`icon-editor-chip-label`,children:e.label})]},e.id),b=(e,t,n,r)=>{let o=s?.slot===e&&(s.align??null)===(t??null),c=r.map(y);return o&&s&&c.splice(Math.max(0,Math.min(s.index,c.length)),0,(0,X.jsx)(`span`,{className:`icon-editor-caret`,"aria-hidden":`true`},`__caret`)),(0,X.jsxs)(`div`,{className:`icon-editor-strip${o?` drop-over`:``}${a?` dragging-active`:``}`,"data-drop-slot":e,...t===void 0?{}:{"data-drop-align":t},children:[n!==null&&(0,X.jsx)(`span`,{className:`icon-editor-strip-label`,children:n}),c,r.length===0&&(0,X.jsx)(`span`,{className:`icon-editor-empty`,children:i(`uiIconEditDropHere`)})]},t??`__all`)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`icon-editor-backdrop`,onClick:r}),(0,X.jsxs)(`div`,{className:`icon-editor`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`uiIconEditTitle`),children:[(0,X.jsxs)(`div`,{className:`icon-editor-head`,children:[(0,X.jsx)(`span`,{className:`icon-editor-title`,children:i(`uiIconEditTitle`)}),(0,X.jsx)(`span`,{className:`icon-editor-hint`,children:i(`uiIconEditHint`)}),(0,X.jsx)(`button`,{type:`button`,className:`icon-editor-close`,onClick:r,"aria-label":i(`close`),title:i(`close`),children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`icon-editor-body`,children:[rv.map(e=>{let t=l.zones[e.slot]??[],n=lv(t);return(0,X.jsxs)(`div`,{className:`icon-editor-zone`,children:[(0,X.jsxs)(`div`,{className:`icon-editor-zone-title`,children:[i(e.labelKey),a&&(0,X.jsx)(`span`,{className:`icon-editor-zone-count`,children:n.length})]}),e.alignable?av.map(n=>b(e.slot,n,e.vertical?ov(i,n):n,uv(t,n))):b(e.slot,void 0,null,n)]},e.slot)}),(0,X.jsxs)(`div`,{className:`icon-editor-zone icon-editor-zone-tray`,children:[(0,X.jsxs)(`div`,{className:`icon-editor-zone-title`,children:[i(`uiIconEditTray`),(0,X.jsx)(`span`,{className:`icon-editor-zone-count`,children:l.tray.length})]}),b(iv,void 0,null,l.tray)]})]})]})]})}function sy(e,t){let n=(0,g.useRef)(``);(0,g.useEffect)(()=>{let r=Bg(n.current,e);n.current=r.key,r.clear&&t()},[e,t])}var cy=new Map,ly=-1;function uy(e){let t=e.trim().toLowerCase();return t.startsWith(`.`)?t:`.${t}`}function dy(e){let t=e.replace(/\\/g,`/`).split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n).toLowerCase():``}function fy(e,t){ly!==t&&(ly=t);let n=new Map;for(let t of e){let e=t;if(!e.error&&e.hasClient&&Array.isArray(e.fileHandlers)){for(let t of e.fileHandlers)if(t&&t.id&&Array.isArray(t.extensions))for(let r of t.extensions){if(typeof r!=`string`)continue;let i=uy(r);if(!/^\.[a-z0-9][a-z0-9._-]*$/.test(i))continue;let a=n.get(i)??[];a.push({plugin:e,declaration:t}),n.set(i,a)}}}for(let e of n.values())e.sort((e,t)=>t.declaration.priority-e.declaration.priority||e.plugin.id.localeCompare(t.plugin.id));cy=n}function py(e){return cy.get(dy(e))?.[0]??null}async function my(e){let t=await Vc(e.plugin,ly);if(!t)return null;let n=t.fileHandlers,r;if(Array.isArray(n))r=n.find(t=>t&&t.id===e.declaration.id),!r&&n.length===1&&typeof n[0]?.mount==`function`&&(r=n[0]);else if(n&&typeof n==`object`){r=n[e.declaration.id];let t=Object.values(n);!r&&t.length===1&&typeof t[0]?.mount==`function`&&(r=t[0])}return!r||typeof r.mount!=`function`?null:{handler:r,pluginId:e.plugin.id}}function hy({provider:e,flow:t,result:n}){let r=Z(),i=t?.event,a=e.oauthName??e.name,[o,s]=(0,g.useState)(``);return(0,g.useEffect)(()=>s(``),[t?.promptId]),e.usingOAuth?(0,X.jsxs)(`div`,{className:`provider-oauth`,children:[(0,X.jsx)(`span`,{className:`provider-oauth-status`,children:r(`oauthConnected`,{name:a})}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-provider-oauth-logout":e.id,onClick:()=>$({type:`provider_oauth_logout`,provider:e.id}),children:r(`oauthLogout`)}),n?.error&&(0,X.jsx)(`div`,{className:`provider-oauth-error`,children:n.error})]}):(0,X.jsxs)(`div`,{className:`provider-oauth`,children:[t?(0,X.jsxs)(X.Fragment,{children:[i?.type===`device_code`&&(0,X.jsxs)(`div`,{className:`provider-oauth-device`,children:[(0,X.jsx)(`div`,{children:r(`oauthDeviceCode`)}),(0,X.jsx)(`code`,{"data-oauth-device-code":!0,children:i.userCode}),(0,X.jsx)(`a`,{"data-oauth-verification-url":!0,href:i.verificationUri,target:`_blank`,rel:`noreferrer`,children:r(`oauthOpenVerification`)})]}),i?.type===`auth_url`&&(0,X.jsxs)(`div`,{className:`provider-oauth-event`,children:[i.instructions&&(0,X.jsx)(`div`,{children:i.instructions}),(0,X.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,children:r(`oauthOpenVerification`)})]}),i?.type===`progress`&&(0,X.jsx)(`div`,{className:`provider-oauth-message`,children:i.message}),i?.type===`info`&&(0,X.jsxs)(`div`,{className:`provider-oauth-event`,children:[(0,X.jsx)(`div`,{children:i.message}),i.links?.map(e=>(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.label??e.url},e.url))]}),t.prompt&&(0,X.jsx)(`div`,{className:`provider-oauth-message`,children:t.prompt.message}),t.prompt?.type===`select`&&t.promptId&&(0,X.jsx)(`div`,{className:`provider-oauth-options`,children:t.prompt.options.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,"data-oauth-option":e.id,onClick:()=>$({type:`provider_oauth_reply`,flowId:t.flowId,promptId:t.promptId,value:e.id}),children:e.label},e.id))}),t.prompt&&t.prompt.type!==`select`&&t.promptId&&(0,X.jsxs)(`form`,{className:`provider-oauth-prompt`,onSubmit:e=>{e.preventDefault(),o.trim()&&$({type:`provider_oauth_reply`,flowId:t.flowId,promptId:t.promptId,value:o.trim()})},children:[(0,X.jsx)(`input`,{"data-oauth-prompt-input":!0,type:t.prompt.type===`secret`?`password`:`text`,className:`key-input`,placeholder:t.prompt.placeholder,value:o,onChange:e=>s(e.target.value)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary sm`,"data-oauth-prompt-submit":!0,disabled:!o.trim(),children:r(`oauthContinue`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-oauth-cancel":t.flowId,onClick:()=>$({type:`provider_oauth_cancel`,flowId:t.flowId}),children:r(`cancel`)})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,"data-provider-oauth-login":e.id,onClick:()=>$({type:`provider_oauth_start`,provider:e.id}),children:r(`oauthLogin`,{name:a})}),n?.error&&(0,X.jsx)(`div`,{className:`provider-oauth-error`,children:n.error})]})}function gy({piConfigured:e,piAgentInstalled:t,providers:n,providerOAuthFlows:r,providerOAuthResults:i,installResult:a,onClose:o}){let s=Z(),c=za(),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(!1);(0,g.useEffect)(()=>{$({type:`list_providers`}),$({type:`list_provider_oauth_flows`})},[]),(0,g.useEffect)(()=>{e&&o()},[e,o]),(0,g.useEffect)(()=>{a&&u(!1)},[a]),(0,g.useEffect)(()=>{!d&&n.length>0&&f(n.find(e=>!e.configured)?.id??n[0].id)},[n,d]);let v=()=>{l||(u(!0),$({type:`install_pi_agent`}))},y=()=>{p.trim()&&!h&&(_(!0),$({type:`set_provider_api_key`,provider:d.trim(),apiKey:p.trim()}),setTimeout(()=>_(!1),3e3))},b=()=>{$({type:`get_state`}),$({type:`list_providers`})},x=n.find(e=>e.id===d),S=a!==null&&!a.ok;return(0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`modal setup-modal`,children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":s(`close`),onClick:o,children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ze,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:s(`setupTitle`)})]}),(0,X.jsx)(`p`,{className:`modal-desc`,children:s(`setupDesc`)}),S?(0,X.jsxs)(`div`,{className:`setup-failed`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:s(`installFailed`)}),(0,X.jsx)(`pre`,{className:`setup-detail`,children:a.detail}),(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:l,onClick:v,children:s(`retryInstall`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]})]}):t||a?.ok?(0,X.jsxs)(`div`,{className:`setup-key-form`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:a?.ok?s(`installDone`):s(`cliReadyHint`)}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:s(`provider`)}),(0,X.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),children:[n.length===0&&(0,X.jsx)(`option`,{value:``,children:s(`loading`)}),n.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name,`(`,e.id,`)`,e.configured?` · ${s(`configured`)}`:``]},e.id))]}),x?.configured&&(0,X.jsx)(`div`,{className:`field-hint`,children:s(`providerKeyReady`)})]}),x?.supportsOAuth&&(0,X.jsx)(hy,{provider:x,flow:r.find(e=>e.provider===x.id),result:i[x.id]}),x?.supportsApiKey&&(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:s(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:`sk-…`})]}),(0,X.jsxs)(`div`,{className:`setup-actions`,children:[x?.supportsApiKey&&(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!p.trim()||h||!d,onClick:y,children:s(h?`saving`:`saveAndStart`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:b,children:[(0,X.jsx)(K,{}),` `,s(`recheck`)]})]})]}):c?(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:s(`updatesManaged`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]}):(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:l,onClick:v,children:s(l?`installing`:`autoInstall`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]})]})})}var _y=[`openai-completions`,`openai-responses`,`anthropic-messages`,`google-generative-ai`],vy=[{id:`deepseek`,name:`DeepSeek`,api:`openai-completions`,baseUrl:`https://api.deepseek.com/v1`,authHeader:!0,tag:`官方`},{id:`openrouter`,name:`OpenRouter`,api:`openai-completions`,baseUrl:`https://openrouter.ai/api/v1`,authHeader:!0,tag:`聚合`},{id:`moonshot`,name:`Moonshot (Kimi)`,api:`openai-completions`,baseUrl:`https://api.moonshot.cn/v1`,authHeader:!0,tag:`官方`},{id:`zhipu`,name:`智谱 GLM`,api:`openai-completions`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,authHeader:!0,tag:`官方`},{id:`siliconflow`,name:`硅基流动`,api:`openai-completions`,baseUrl:`https://api.siliconflow.cn/v1`,authHeader:!0,tag:`云端`},{id:`ollama`,name:`Ollama`,api:`openai-completions`,baseUrl:`http://127.0.0.1:11434/v1`,authHeader:!0,tag:`本地`},{id:`vllm`,name:`vLLM / LM Studio`,api:`openai-completions`,baseUrl:`http://127.0.0.1:8000/v1`,authHeader:!0,tag:`本地`},{id:`antigravity`,name:`Antigravity (OpenAI)`,api:`openai-completions`,baseUrl:`http://127.0.0.1:8045/v1`,authHeader:!0,tag:`反代`},{id:`antigravity-anthropic`,name:`Antigravity (Anthropic)`,api:`anthropic-messages`,baseUrl:`http://127.0.0.1:8045`,authHeader:!0,tag:`反代`}],yy=[{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`},{label:`128K`,value:`131072`},{label:`200K`,value:`200000`},{label:`1M`,value:`1000000`}],by=[{label:`2K`,value:`2048`},{label:`4K`,value:`4096`},{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`}],xy=()=>({id:``,name:``,reasoning:!1,input:`text`,contextWindow:``,maxTokens:``}),Sy=()=>({providerId:``,name:``,api:`openai-completions`,baseUrl:``,apiKey:``,hasApiKey:!1,authHeader:!0,models:[xy()]});function Cy(e){return{providerId:e.providerId,name:e.name??``,api:e.api??`openai-completions`,baseUrl:e.baseUrl??``,apiKey:``,hasApiKey:e.hasApiKey??!1,authHeader:e.authHeader??!1,models:(e.models.length?e.models:[xy()]).map(e=>({id:e.id,name:e.name??``,reasoning:e.reasoning??!1,input:e.input?.includes(`image`)?`text-image`:`text`,contextWindow:e.contextWindow?String(e.contextWindow):``,maxTokens:e.maxTokens?String(e.maxTokens):``}))}}function wy(e){let t={};for(let n of e.split(`
363
- `)){let e=n.indexOf(`=`);if(e<=0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}return t}function Ty({candidates:e,onAdopt:t,onClose:n}){let r=Z(),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(()=>{let t=new Set;for(let n of e){let e=n.id.toLowerCase();!e.includes(`embed`)&&!e.includes(`audio`)&&!e.includes(`tts`)&&!e.includes(`whisper`)&&t.add(n.id)}if(t.size===0)for(let n of e)t.add(n.id);return t}),c=(0,g.useMemo)(()=>{let t=i.trim().toLowerCase();return t?e.filter(e=>e.id.toLowerCase().includes(t)||e.name&&e.name.toLowerCase().includes(t)):e},[e,i]),l=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,X.jsx)(`div`,{className:`candidate-picker-backdrop`,onClick:n,children:(0,X.jsxs)(`div`,{className:`candidate-picker-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`candidate-header`,children:[(0,X.jsxs)(`div`,{className:`candidate-title-group`,children:[(0,X.jsx)(`span`,{className:`candidate-title`,children:`候选模型采纳器 (Candidate Picker)`}),(0,X.jsxs)(`span`,{className:`candidate-subtitle`,children:[`已探测到 `,e.length,` 个模型,请勾选需要采纳的模型`]})]}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,onClick:n,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`candidate-filter-bar`,children:[(0,X.jsx)(de,{style:{color:`var(--text-faint)`,flexShrink:0}}),(0,X.jsx)(`input`,{type:`text`,className:`candidate-search-input`,placeholder:`搜索模型 ID 或名称…`,value:i,onChange:e=>a(e.target.value),autoFocus:!0}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:6,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{s(new Set(c.map(e=>e.id)))},children:`全选`}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{s(new Set)},children:`全不选`})]})]}),(0,X.jsxs)(`div`,{className:`candidate-list-scroll`,children:[c.length===0&&(0,X.jsx)(`div`,{style:{padding:`32px 0`,textAlign:`center`,color:`var(--text-faint)`,fontSize:13},children:`未匹配到模型`}),c.map(e=>{let t=o.has(e.id);return(0,X.jsxs)(`div`,{className:`candidate-item-card ${t?`selected`:``}`,onClick:()=>l(e.id),children:[(0,X.jsxs)(`div`,{className:`candidate-item-left`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`candidate-checkbox`,checked:t,onChange:()=>{},onClick:e=>e.stopPropagation()}),(0,X.jsxs)(`div`,{className:`candidate-id-info`,children:[(0,X.jsx)(`span`,{className:`candidate-id-name`,children:e.id}),e.name&&e.name!==e.id&&(0,X.jsx)(`span`,{style:{fontSize:11.5,color:`var(--text-dim)`},children:e.name})]})]}),(0,X.jsxs)(`div`,{className:`candidate-item-meta`,children:[e.contextWindow&&(0,X.jsx)(`span`,{className:`spec-badge ctx`,title:`上下文窗口`,children:e.contextWindow>=1e6?`${Math.round(e.contextWindow/1e6)}M`:`${Math.round(e.contextWindow/1024)}K`}),e.reasoning&&(0,X.jsxs)(`span`,{className:`spec-badge reasoning`,title:`支持深度思考 / 推理`,children:[(0,X.jsx)(N,{}),` 推理`]}),e.input?.includes(`image`)&&(0,X.jsx)(`span`,{className:`spec-badge vision`,title:`支持图像视觉`,children:`视觉`})]})]},e.id)})]}),(0,X.jsxs)(`div`,{className:`candidate-actions-footer`,children:[(0,X.jsxs)(`span`,{className:`candidate-select-summary`,children:[`已勾选 `,o.size,` / `,e.length,` 个模型`]}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,children:r(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:o.size===0,onClick:()=>{t(e.filter(e=>o.has(e.id)))},children:[`采纳所选模型 (`,o.size,`)`]})]})]})]})})}function Ey({providers:e,providerStatus:t,providerKeys:n,providerOAuthFlows:r,providerOAuthResults:i,fetchModelsResult:a,testModelConnectionResult:o,enrichModelsResult:s,enrichModelsProgress:c,cloneProviderResult:l,refreshBuiltinResult:u,refreshProviderResult:d,appendBuiltinResult:f,defaultModel:p,onClose:m}){let h=Z(),[_,v]=(0,g.useState)(()=>e.length>0?{type:`custom`,id:e[0].providerId}:t.length>0?{type:`builtin`,id:t[0].id}:{type:`custom`,id:``}),[y,b]=(0,g.useState)(()=>e.length>0?Cy(e[0]):t.length>0?null:Sy()),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(0),[D,O]=(0,g.useState)(null),k=(0,g.useRef)(0),[A,j]=(0,g.useState)({}),[ee,M]=(0,g.useState)({}),[te,N]=(0,g.useState)(null),ne=(0,g.useRef)(n),F=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=te;e&&n[e]!==ne.current[e]&&(N(null),j(t=>({...t,[e]:``})),M(t=>({...t,[e]:``})),F.current&&clearTimeout(F.current)),ne.current=n},[n,te]),(0,g.useEffect)(()=>()=>{F.current&&clearTimeout(F.current)},[]);let[re,I]=(0,g.useState)(!1),[L,ie]=(0,g.useState)(0),[z,B]=(0,g.useState)(null),V=(0,g.useRef)(0),[H,U]=(0,g.useState)(!1),[ae,oe]=(0,g.useState)(!1),[se,W]=(0,g.useState)(0),[ce,le]=(0,g.useState)(null),[ue,de]=(0,g.useState)([]),[fe]=(0,g.useState)(``),pe=(0,g.useRef)(0),[G,he]=(0,g.useState)(!1),[ge,q]=(0,g.useState)(0),[_e,ve]=(0,g.useState)(null),ye=(0,g.useRef)(0),[be,xe]=(0,g.useState)(null),[J,Se]=(0,g.useState)(``),[Ce,we]=(0,g.useState)(``),[Te,Ee]=(0,g.useState)(``),[De,Oe]=(0,g.useState)(``),[ke,Ae]=(0,g.useState)(!1),[je,Me]=(0,g.useState)(0),[Ne,Pe]=(0,g.useState)(null),Fe=(0,g.useRef)(0),[Ie,Le]=(0,g.useState)(null),[Re,ze]=(0,g.useState)(``),[Be,Ve]=(0,g.useState)(null),[He,Ue]=(0,g.useState)({}),We=(0,g.useRef)(0),Ge=(0,g.useRef)(0),[Y,Ke]=(0,g.useState)(null),Je=(0,g.useRef)(0),Ye=(0,g.useRef)(0),Xe=e=>{if(He[e])return;let t=++We.current+Date.now();Ue(t=>({...t,[e]:!0})),$({type:`refresh_provider_models`,providerId:e,reqId:t})};(0,g.useEffect)(()=>{d&&d.reqId!==Ge.current&&(Ge.current=d.reqId,Ue({}))},[d]);let Qe=e=>{if(Y)return;Ke(e.id);let t=++Je.current+Date.now();$({type:`clone_provider`,provider:e.id,reqId:t})||Ke(null)};(0,g.useEffect)(()=>{$({type:`list_models_config`}),$({type:`list_providers`}),$({type:`list_provider_keys`}),$({type:`list_provider_oauth_flows`})},[]),(0,g.useEffect)(()=>{o&&o.reqId!==k.current&&(k.current=o.reqId,w(!1),O({ok:o.ok,latencyMs:o.latencyMs,error:o.error}))},[o]),(0,g.useEffect)(()=>{a&&a.reqId!==V.current&&(V.current=a.reqId,I(!1),a.ok&&a.models?.length?(S(a.models),B({ok:!0,text:h(`fetchModelsOk`,{n:a.models.length})})):B({ok:!1,text:a.error||h(`fetchModelsEmpty`)}))},[a,h]),(0,g.useEffect)(()=>{if(s&&s.reqId!==pe.current){if(pe.current=s.reqId,U(!1),oe(!1),s.ok&&s.results?.length){let e=s.results,t=new Map(e.map(e=>[e.id.trim(),e]));b(e=>e&&{...e,models:e.models.map(e=>{let n=t.get(e.id.trim());return!n||n.status!==`matched`?e:{...e,name:e.name||n.name||``,contextWindow:e.contextWindow||(n.contextWindow?String(n.contextWindow):``),maxTokens:e.maxTokens||(n.maxTokens?String(n.maxTokens):``),input:e.input===`text`&&n.input?.includes(`image`)?`text-image`:e.input,reasoning:e.reasoning||(n.reasoning??!1),src:n.source}})});let n=e.filter(e=>e.status===`matched`).length,r=e.length-n;le({ok:!0,text:h(`enrichModelsOk`,{n,m:r})});let i=e.filter(e=>e.status!==`matched`&&(e.suggestions?.length||e.note)).map(e=>({id:e.id,suggestions:e.suggestions??[],note:e.note}));de(i)}else le({ok:!1,text:s.error||h(`enrichModelsErr`,{msg:``})})}},[s,h]),(0,g.useEffect)(()=>{u&&u.reqId!==ye.current&&(ye.current=u.reqId,he(!1),u.ok?ve({ok:!0,text:h(`refreshBuiltinOk`)}):ve({ok:!1,text:u.error||h(`refreshBuiltinFail`)}))},[u,h]),(0,g.useEffect)(()=>{f&&f.reqId!==Fe.current&&(Fe.current=f.reqId,Ae(!1),f.ok?(Pe({ok:!0,text:h(`appendModelOk`)}),Se(``),we(``),Ee(``),Oe(``),xe(null),$({type:`list_models_config`})):Pe({ok:!1,text:f.error||h(`appendModelFail`)}))},[f,h]),(0,g.useEffect)(()=>{if(l&&l.reqId!==Ye.current&&(Ye.current=l.reqId,Ke(null),l.ok)){let e=l.configs;if(e&&e.length>1){Le(e.map(e=>Cy(e))),ze(``);return}l.config&&Ve(Cy(l.config))}},[l]);let $e=()=>{if(!y)return;let e=y.baseUrl.trim();if(!e){O({ok:!1,error:h(`fetchModelsNeedBaseUrl`)});return}w(!0),O(null);let t=T+1;E(t),$({type:`test_model_connection`,reqId:t,baseUrl:e,apiKey:y.apiKey.trim()||void 0,...y.apiKey.trim()?{}:y.hasApiKey?{providerId:y.providerId.trim()}:{},authHeader:y.authHeader,api:y.api})},et=()=>{if(!y)return;let e=y.baseUrl.trim();if(!e){B({ok:!1,text:h(`fetchModelsNeedBaseUrl`)});return}if(re)return;I(!0),B(null);let t=L+1;ie(t),$({type:`fetch_models`,reqId:t,baseUrl:e,apiKey:y.apiKey.trim()||void 0,...y.apiKey.trim()?{}:y.hasApiKey?{providerId:y.providerId.trim()}:{},authHeader:y.authHeader,api:y.api})},nt=e=>{y&&(b(t=>{if(!t)return t;let n=t.models.filter(e=>e.id.trim()),r=new Set(n.map(e=>e.id.trim())),i=e.filter(e=>!r.has(e.id)).map(e=>({id:e.id,name:e.name??``,reasoning:e.reasoning??!1,input:e.input?.includes(`image`)?`text-image`:`text`,contextWindow:e.contextWindow?String(e.contextWindow):``,maxTokens:e.maxTokens?String(e.maxTokens):``}));return{...t,models:n.length===0?i:[...n,...i]}}),S(null))},rt=()=>{if(!y||H)return;let e=y.models.map(e=>e.id.trim()).filter(Boolean);if(e.length===0){le({ok:!1,text:h(`enrichModelsNeedIds`)});return}U(!0),oe(!1),le(null),de([]);let t=se+1;W(t),$({type:`enrich_models`,reqId:t,ids:e,hints:wy(fe)})},it=()=>{H&&!ae&&(oe(!0),$({type:`abort_enrich_models`,reqId:se}))},at=e=>{b(t=>({providerId:t?.providerId.trim()||e.id,name:t?.name.trim()||e.name,api:e.api,baseUrl:e.baseUrl,apiKey:t?.apiKey||``,hasApiKey:t?.hasApiKey??!1,authHeader:e.authHeader,models:t?.models.length?t.models:[xy()]})),O(null),B(null)},ot=()=>{if(!y)return;let e=y.providerId.trim();if(!e)return;let t=y.models.filter(e=>e.id.trim()).map(e=>({id:e.id.trim(),name:e.name.trim()||void 0,reasoning:e.reasoning||void 0,input:e.input===`text-image`?[`text`,`image`]:void 0,contextWindow:e.contextWindow?Number(e.contextWindow):void 0,maxTokens:e.maxTokens?Number(e.maxTokens):void 0}));$({type:`save_model_config`,providerId:e,config:{providerId:e,name:y.name.trim()||void 0,api:y.api.trim()||void 0,baseUrl:y.baseUrl.trim()||void 0,...y.apiKey.trim()?{apiKey:y.apiKey.trim()}:{},authHeader:y.authHeader||void 0,models:t}}),m()},st=(e,t)=>{y&&b({...y,models:y.models.map((n,r)=>r===e?{...n,...t}:n)})},ct=()=>{y&&b({...y,models:[...y.models,xy()]})},lt=e=>{y&&b({...y,models:y.models.filter((t,n)=>n!==e)})},ut=e=>{let t=(A[e.id]??``).trim();t&&!te&&(N(e.id),$({type:`add_provider_key`,provider:e.id,apiKey:t,name:(ee[e.id]??``).trim()||void 0}),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{N(t=>t===e.id?null:t)},1e4))},dt=(e,t)=>{$({type:`activate_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`})},pt=(e,t)=>{window.confirm(h(`removeKeyConfirm`))&&($({type:`remove_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`}))},mt=e=>{window.confirm(h(`clearKeyConfirm`,{id:e}))&&$({type:`clear_provider_api_key`,provider:e})},ht=t=>{if(window.confirm(h(`deleteProviderConfirm`,{id:t.providerId,n:t.models.length}))&&($({type:`delete_model_config`,providerId:t.providerId}),_.type===`custom`&&_.id===t.providerId)){let n=e.filter(e=>e.providerId!==t.providerId);n.length>0?(v({type:`custom`,id:n[0].providerId}),b(Cy(n[0]))):(v({type:`custom`,id:``}),b(Sy()))}},gt=e=>{let t=J.trim();if(!t||ke)return;Ae(!0),Pe(null);let n=je+1;Me(n),$({type:`append_builtin_model`,providerId:e,model:{id:t,...Ce.trim()?{name:Ce.trim()}:{},...Te?{api:Te}:{},...De.trim()?{baseUrl:De.trim()}:{}},reqId:n})};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:m,children:(0,X.jsxs)(`div`,{className:`modal model-studio-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`studio-header`,children:[(0,X.jsxs)(`div`,{className:`studio-header-left`,children:[(0,X.jsx)(`div`,{className:`studio-header-icon-box`,children:(0,X.jsx)(Ze,{})}),(0,X.jsxs)(`div`,{className:`studio-header-title-wrap`,children:[(0,X.jsx)(`h2`,{className:`studio-header-title`,children:`模型管理`}),(0,X.jsx)(`span`,{className:`studio-header-badge`,children:`Studio`})]})]}),(0,X.jsxs)(`div`,{className:`studio-header-actions`,children:[p!==void 0&&p&&(0,X.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:5,padding:`3px 8px`,borderRadius:6,background:`rgba(251, 191, 36, 0.08)`,border:`1px solid rgba(251, 191, 36, 0.3)`,fontSize:11.5,color:`var(--amber)`},title:`全局默认模型: ${p}`,children:[(0,X.jsx)(`span`,{children:`★`}),(0,X.jsx)(`span`,{style:{maxWidth:120,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`var(--mono)`},children:p.split(`/`).slice(1).join(`/`)}),(0,X.jsx)(`button`,{type:`button`,style:{background:`transparent`,border:`none`,color:`var(--amber)`,cursor:`pointer`,fontSize:10,padding:`0 2px`,opacity:.7},title:`清除全局默认模型`,onClick:()=>$({type:`clear_default_model`}),children:`✕`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`studio-header-btn`,title:h(`refreshBuiltinHint`),disabled:G,onClick:()=>{if(G)return;he(!0),ve(null);let e=ge+1;q(e),$({type:`refresh_builtin_models`,reqId:e})},children:[(0,X.jsx)(qe,{}),(0,X.jsx)(`span`,{children:G?h(`refreshBuiltinBusy`):`刷新官方目录`})]}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn`,title:h(`reloadModelsHint`),onClick:()=>$({type:`reload_models_config`}),children:(0,X.jsx)(K,{})}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn close-btn`,"aria-label":h(`close`),onClick:m,children:(0,X.jsx)(P,{})})]})]}),_e&&(0,X.jsx)(`div`,{style:{padding:`6px 20px`,background:`var(--bg-elev2)`,fontSize:12,borderBottom:`1px solid var(--border-soft)`},children:(0,X.jsx)(`span`,{className:`fetch-msg ${_e.ok?`ok`:`err`}`,children:_e.text})}),(0,X.jsxs)(`div`,{className:`model-studio-body`,children:[(0,X.jsxs)(`div`,{className:`model-studio-sidebar`,children:[(0,X.jsx)(`div`,{style:{padding:`12px 10px 6px`},children:(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,style:{width:`100%`,justifyContent:`center`},onClick:()=>{v({type:`custom`,id:``}),b(Sy()),O(null),B(null)},children:[(0,X.jsx)(me,{}),` 添加自定义服务商`]})}),(0,X.jsxs)(`div`,{className:`studio-sidebar-section`,children:[(0,X.jsxs)(`span`,{className:`studio-sidebar-title`,children:[`自定义服务商 (`,e.length,`)`]}),e.length===0&&(0,X.jsx)(`div`,{style:{fontSize:11.5,color:`var(--text-faint)`,padding:`6px 8px`},children:`暂无配置`}),e.map(e=>{let t=_.type===`custom`&&_.id===e.providerId;return(0,X.jsxs)(`div`,{className:`studio-nav-item ${t?`active`:``}`,onClick:()=>{v({type:`custom`,id:e.providerId}),b(Cy(e)),O(null),B(null)},children:[(0,X.jsxs)(`span`,{className:`studio-nav-label`,children:[(0,X.jsx)(`span`,{className:`studio-nav-dot configured`}),(0,X.jsx)(`span`,{children:e.name||e.providerId})]}),(0,X.jsxs)(`span`,{style:{fontSize:10.5,color:`var(--text-faint)`,fontFamily:`var(--mono)`},children:[e.models.length,`m`]})]},e.providerId)})]}),(0,X.jsxs)(`div`,{className:`studio-sidebar-section`,children:[(0,X.jsxs)(`span`,{className:`studio-sidebar-title`,children:[`官方内置服务商 (`,t.length,`)`]}),t.map(e=>{let t=_.type===`builtin`&&_.id===e.id,r=n[e.id]??[];return(0,X.jsxs)(`div`,{className:`studio-nav-item ${t?`active`:``}`,onClick:()=>{v({type:`builtin`,id:e.id}),b(null)},children:[(0,X.jsxs)(`span`,{className:`studio-nav-label`,children:[(0,X.jsx)(`span`,{className:`studio-nav-dot ${e.configured?`configured`:``}`}),(0,X.jsx)(`span`,{children:e.name})]}),r.length>0&&(0,X.jsxs)(`span`,{style:{fontSize:10.5,color:`var(--text-faint)`,fontFamily:`var(--mono)`},children:[r.length,`k`]})]},e.id)})]})]}),(0,X.jsxs)(`div`,{className:`model-studio-main`,children:[y&&(0,X.jsxs)(`div`,{className:`studio-card`,children:[(0,X.jsxs)(`div`,{className:`studio-card-head`,children:[(0,X.jsxs)(`div`,{className:`studio-card-title`,children:[(0,X.jsx)(`span`,{children:y.providerId?`编辑服务商:${y.providerId}`:`新建自定义服务商`}),y.providerId&&e.some(e=>e.providerId===y.providerId)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`iconbtn sm`,title:h(`refreshModels`),disabled:He[y.providerId],onClick:()=>Xe(y.providerId),children:(0,X.jsx)(K,{className:He[y.providerId]?`spin`:``})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger sm`,title:`删除此服务商`,onClick:()=>{let t=e.find(e=>e.providerId===y.providerId);t&&ht(t)},children:(0,X.jsx)(R,{})})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,X.jsxs)(`div`,{className:`conn-test-box`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`conn-test-btn`,disabled:C||!y.baseUrl.trim(),onClick:$e,children:[(0,X.jsx)(Et,{}),` `,C?`测试中…`:`测试连接`]}),D&&(0,X.jsxs)(`span`,{className:`ping-indicator ${D.ok?`ok`:`err`}`,children:[(0,X.jsx)(`span`,{className:`ping-dot`}),(0,X.jsx)(`span`,{children:D.ok?`${D.latencyMs??0}ms 连通正常`:`连接失败`})]})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,onClick:ot,children:h(`save`)})]})]}),(0,X.jsxs)(`div`,{className:`quick-chips-wrapper`,children:[(0,X.jsx)(`span`,{className:`quick-chips-label`,children:`快捷预设模板 (Quick Presets)`}),(0,X.jsx)(`div`,{className:`quick-chips-grid`,children:vy.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`quick-chip`,onClick:()=>at(e),children:[(0,X.jsx)(`span`,{className:`quick-chip-name`,children:e.name}),e.tag&&(0,X.jsx)(`span`,{className:`quick-chip-tag`,children:e.tag})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`form-grid`,children:[(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[h(`providerId`),` `,(0,X.jsx)(`em`,{children:h(`providerIdHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:y.providerId,disabled:e.some(e=>e.providerId===y.providerId),onChange:e=>b({...y,providerId:e.target.value}),placeholder:`例如 deepseek`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`displayName`)}),(0,X.jsx)(`input`,{type:`text`,value:y.name,onChange:e=>b({...y,name:e.target.value}),placeholder:h(`displayNamePh`)})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`apiType`)}),(0,X.jsx)(`select`,{value:y.api,onChange:e=>b({...y,api:e.target.value}),children:_y.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[`baseUrl `,(0,X.jsx)(`em`,{children:h(`baseUrlHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:y.baseUrl,onChange:e=>b({...y,baseUrl:e.target.value}),placeholder:`https://api.deepseek.com/v1`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:y.apiKey,onChange:e=>b({...y,apiKey:e.target.value}),placeholder:y.hasApiKey?h(`apiKeySavedHint`):h(`apiKeyHint`)})]}),(0,X.jsxs)(`label`,{className:`field check`,style:{alignSelf:`center`,paddingTop:16},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:y.authHeader,onChange:e=>b({...y,authHeader:e.target.checked})}),(0,X.jsx)(`span`,{children:h(`authHeader`)})]})]}),(0,X.jsxs)(`div`,{style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`model-section-head`,children:[(0,X.jsxs)(`span`,{className:`form-section-title`,style:{fontSize:13,fontWeight:600},children:[`模型矩阵 (`,y.models.filter(e=>e.id.trim()).length,`)`]}),(0,X.jsxs)(`div`,{className:`model-section-actions`,children:[z&&(0,X.jsx)(`span`,{className:`fetch-msg ${z.ok?`ok`:`err`}`,title:z.text,children:z.text}),ce&&(0,X.jsx)(`span`,{className:`fetch-msg ${ce.ok?`ok`:`err`}`,title:ce.text,children:ce.text}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:re||!y.baseUrl.trim(),title:h(`fetchModelsHint`),onClick:et,children:[(0,X.jsx)(qe,{}),` `,re?h(`fetchingModels`):`自动获取并采纳模型`]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:H,title:h(`enrichModelsHint`),onClick:rt,children:[(0,X.jsx)(qe,{}),` `,h(H?`enrichingModels`:`enrichModels`)]}),H&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:ae,title:h(`enrichModelsAbort`),onClick:it,style:{color:`var(--red)`},children:[(0,X.jsx)(P,{}),` `,h(ae?`enrichCancelling`:`enrichModelsCancel`)]})]})]}),(0,X.jsxs)(`div`,{className:`model-matrix-list`,children:[y.models.map((e,t)=>(0,X.jsxs)(`div`,{className:`model-matrix-card`,children:[(0,X.jsxs)(`div`,{className:`matrix-main-row`,children:[(0,X.jsxs)(`div`,{className:`matrix-input-group id-group`,children:[(0,X.jsxs)(`span`,{className:`matrix-input-prefix`,children:[(0,X.jsx)(Ze,{}),` ID`]}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field mono`,value:e.id,onChange:e=>st(t,{id:e.target.value}),placeholder:`例如 deepseek-chat`})]}),(0,X.jsxs)(`div`,{className:`matrix-input-group name-group`,children:[(0,X.jsx)(`span`,{className:`matrix-input-prefix`,children:`别名`}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field`,value:e.name,onChange:e=>st(t,{name:e.target.value}),placeholder:`显示名称 (选填)`})]}),(0,X.jsxs)(`div`,{className:`matrix-toggles`,children:[(0,X.jsx)(`button`,{type:`button`,className:`matrix-toggle-tag ${e.input===`text-image`?`active vision`:``}`,onClick:()=>st(t,{input:e.input===`text-image`?`text`:`text-image`}),title:`是否支持图像识图输入`,children:`🖼 视觉`}),(0,X.jsx)(`button`,{type:`button`,className:`matrix-toggle-tag ${e.reasoning?`active reasoning`:``}`,onClick:()=>st(t,{reasoning:!e.reasoning}),title:`是否支持深度思考推理`,children:`⚡ 推理`}),p!==void 0&&e.id.trim()&&(()=>{let t=`${y.providerId}/${e.id.trim()}`,n=p===t||p===e.id.trim();return(0,X.jsxs)(`button`,{type:`button`,className:`matrix-star-btn ${n?`active`:``}`,title:n?`当前全局默认模型(点击取消默认)`:`设为全局默认模型`,onClick:()=>{$(n?{type:`clear_default_model`}:{type:`set_default_model`,modelId:t})},children:[(0,X.jsx)(`span`,{className:`matrix-star-icon`,children:n?`★`:`☆`}),(0,X.jsx)(`span`,{children:n?`默认`:`设为默认`})]})})(),(0,X.jsx)(`button`,{type:`button`,className:`matrix-delete-btn`,title:h(`delete`),onClick:()=>lt(t),children:(0,X.jsx)(R,{})})]})]}),(0,X.jsxs)(`div`,{className:`matrix-spec-bar`,children:[(0,X.jsxs)(`div`,{className:`spec-combobox`,children:[(0,X.jsx)(`span`,{className:`spec-combobox-label`,children:`上下文`}),(0,X.jsxs)(`select`,{className:`spec-combobox-select`,value:yy.some(t=>t.value===e.contextWindow)?e.contextWindow:`custom`,onChange:e=>{e.target.value!==`custom`&&st(t,{contextWindow:e.target.value})},children:[yy.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[e.label,` (`,Math.round(Number(e.value)/1024),`K)`]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:`自定义…`})]}),(!yy.some(t=>t.value===e.contextWindow)||e.contextWindow===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.contextWindow,onChange:e=>st(t,{contextWindow:e.target.value}),placeholder:`如 131072`})]}),(0,X.jsxs)(`div`,{className:`spec-combobox`,children:[(0,X.jsx)(`span`,{className:`spec-combobox-label`,children:`最大输出`}),(0,X.jsxs)(`select`,{className:`spec-combobox-select`,value:by.some(t=>t.value===e.maxTokens)?e.maxTokens:`custom`,onChange:e=>{e.target.value!==`custom`&&st(t,{maxTokens:e.target.value})},children:[by.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[e.label,` (`,Math.round(Number(e.value)/1024),`K)`]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:`自定义…`})]}),(!by.some(t=>t.value===e.maxTokens)||e.maxTokens===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.maxTokens,onChange:e=>st(t,{maxTokens:e.target.value}),placeholder:`如 8192`})]}),(0,X.jsx)(`div`,{className:`matrix-spec-quick-pills`,children:[`32K`,`128K`,`200K`].map(n=>{let r=yy.find(e=>e.label===n);return r?(0,X.jsx)(`button`,{type:`button`,className:`param-pill ${e.contextWindow===r.value?`active`:``}`,onClick:()=>st(t,{contextWindow:r.value}),title:`快捷设为 ${n} 上下文`,children:n},n):null})})]})]},t)),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,style:{alignSelf:`flex-start`,marginTop:4},onClick:ct,children:[(0,X.jsx)(me,{}),` 添加模型行`]})]})]})]}),_.type===`builtin`&&(()=>{let e=t.find(e=>e.id===_.id);if(!e)return null;let a=n[e.id]??[];return(0,X.jsxs)(`div`,{className:`studio-card`,children:[(0,X.jsxs)(`div`,{className:`studio-card-head`,children:[(0,X.jsxs)(`div`,{className:`studio-card-title`,children:[(0,X.jsxs)(`span`,{children:[`官方内置服务商:`,e.name]}),e.configured&&(0,X.jsx)(`span`,{className:`auth-badge`,children:h(`configuredBadge`)}),e.source&&!e.configured&&(0,X.jsx)(`span`,{className:`auth-badge dim`,children:e.source})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,title:h(`cloneProvider`),disabled:Y===e.id,onClick:()=>Qe(e),children:[(0,X.jsx)(tt,{}),` `,h(`cloneProvider`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{xe(be===e.id?null:e.id),Pe(null)},children:[(0,X.jsx)(me,{}),` `,h(`appendModel`)]}),e.supportsApiKey&&e.source===`stored`&&!e.usingOAuth&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm danger`,title:h(`clearKeyTitle`),onClick:()=>mt(e.id),children:[(0,X.jsx)(R,{}),` `,h(`clearKey`)]})]})]}),e.supportsOAuth&&(0,X.jsx)(hy,{provider:e,flow:r.find(t=>t.provider===e.id),result:i[e.id]}),e.supportsApiKey&&(0,X.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,X.jsx)(`span`,{style:{fontSize:12.5,fontWeight:600},children:`API 密钥管理`}),(0,X.jsxs)(`div`,{className:`provider-keys`,children:[a.length===0&&(0,X.jsx)(`div`,{className:`provider-key-empty`,children:h(`noKeyYet`)}),a.map(t=>(0,X.jsxs)(`div`,{className:`provider-key-item ${t.active?`active`:``}`,children:[(0,X.jsx)(`span`,{className:`provider-key-dot`,children:t.active?`●`:`○`}),(0,X.jsx)(`span`,{className:`provider-key-label`,children:t.name}),!t.active&&(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:h(`activateKey`),onClick:()=>dt(e.id,t.name),children:(0,X.jsx)(ft,{})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:h(`removeKey`),onClick:()=>pt(e.id,t.name),children:(0,X.jsx)(R,{})})]},t.name))]}),(0,X.jsxs)(`div`,{className:`provider-add-key`,style:{marginTop:6},children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input key-input-name`,placeholder:h(`keyNamePh`),value:ee[e.id]??``,onChange:t=>M(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsx)(`input`,{type:`password`,className:`key-input key-input-value`,placeholder:h(`addKeyPlaceholder`),value:A[e.id]??``,onChange:t=>j(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!(A[e.id]??``).trim()||te===e.id,onClick:()=>ut(e),children:[(0,X.jsx)(me,{}),` `,te===e.id?h(`savingKey`):h(`addKey`)]})]})]}),be===e.id&&(0,X.jsxs)(`div`,{style:{marginTop:12,padding:12,background:`var(--bg)`,borderRadius:8,border:`1px dashed var(--border-soft)`},children:[(0,X.jsx)(`span`,{style:{fontSize:12,fontWeight:600,display:`block`,marginBottom:8},children:`追加官方模型覆盖 (Overlay)`}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`模型 ID (必填)`,value:J,onChange:e=>Se(e.target.value)}),(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`显示名称 (选填)`,value:Ce,onChange:e=>we(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!J.trim()||ke,onClick:()=>gt(e.id),children:[(0,X.jsx)(me,{}),` 提交追加`]})]}),Ne&&(0,X.jsx)(`span`,{style:{fontSize:12,color:Ne.ok?`var(--green)`:`var(--red)`,marginTop:6},children:Ne.text})]})]})})()]})]}),x&&(0,X.jsx)(Ty,{candidates:x,onAdopt:nt,onClose:()=>S(null)})]})})}function Dy(e,t=[],n){let r=[],i=e=>{r.includes(e)||r.push(e)};e.optionsFrom&&i(``);for(let t of e.options??[])i(t);if(e.optionsFrom===`models`)for(let e of t)i(`${e.provider}/${e.id}`);else if(e.optionsFrom===`thinkingLevels`)for(let e of j_)i(e);let a=typeof n==`string`?n:n==null?``:String(n);return a&&i(a),r}function Oy({plugin:e,models:t=[]}){let n=Z(),r=e.settingsSchema??[],[i,a]=(0,g.useState)(()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);return t}),[o,s]=(0,g.useState)(!1);if(r.length===0)return null;let c=(e,t)=>a(n=>({...n,[e]:t})),l=e=>Dy(e,t,i[e.key]).map(r=>{if(r===``)return{value:``,label:n(`pluginSettingsInherit`)};if(e.optionsFrom===`thinkingLevels`&&j_.includes(r))return{value:r,label:n(`thinking.${r}`)};if(e.optionsFrom===`models`){let e=t.find(e=>`${e.provider}/${e.id}`===r);if(e)return{value:r,label:e.label}}return{value:r,label:r}}),u=r.some(t=>t.type===`secret`?String(i[t.key]??``)!==``:i[t.key]!==e.settingsValues?.[t.key]);return(0,X.jsxs)(`div`,{className:`plugin-settings-form`,children:[(0,X.jsx)(`div`,{className:`plugin-settings-fields`,children:r.map(t=>(0,X.jsxs)(`label`,{className:`plugin-settings-field`,"data-key":t.key,title:t.hint,children:[(0,X.jsxs)(`span`,{className:`plugin-settings-label`,children:[(0,X.jsx)(`span`,{className:`plugin-settings-label-text`,title:t.label,children:t.label}),t.hint&&(0,X.jsx)(`span`,{className:`plugin-settings-hint`,children:t.hint})]}),(0,X.jsx)(`span`,{className:`plugin-settings-control`,children:t.type===`boolean`?(0,X.jsx)(`input`,{type:`checkbox`,checked:!!i[t.key],onChange:e=>c(t.key,e.target.checked)}):t.type===`secret`?(0,X.jsx)(`input`,{type:`password`,value:String(i[t.key]??``),placeholder:n(e.settingsValues?.[t.key]?`pluginSecretSet`:`pluginSecretUnset`),autoComplete:`new-password`,onChange:e=>c(t.key,e.target.value)}):t.type===`select`?(0,X.jsx)(`select`,{value:String(i[t.key]??``),onChange:e=>c(t.key,e.target.value),children:l(t).map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,X.jsx)(`input`,{type:t.type===`password`?`password`:t.type===`number`?`number`:`text`,value:String(i[t.key]??``),min:t.min,max:t.max,onChange:e=>c(t.key,t.type===`number`?Number(e.target.value):e.target.value)})})]},t.key))}),(0,X.jsxs)(`div`,{className:`plugin-settings-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn plugin-settings-save`,disabled:!u||o,onClick:()=>{s(!0),$({type:`plugin_settings`,pluginId:e.id,values:i}),setTimeout(()=>s(!1),800)},children:n(o?`pluginSettingsSaving`:`pluginSettingsSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn plugin-settings-reset`,onClick:()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);a(t)},children:n(`pluginSettingsReset`)})]})]})}var ky=0,Ay=``;function jy(){typeof document<`u`&&(ky===0&&(Ay=document.body.style.overflow,document.body.style.overflow=`hidden`),ky++)}function My(){typeof document<`u`&&(ky=Math.max(0,ky-1),ky===0&&(document.body.style.overflow=Ay))}function Ny({open:e=!0,onClose:t,title:n,icon:r,children:i,className:a=``,backdropClassName:o=``,style:s,closeOnBackdropClick:c=!0,closeOnEscape:l=!0,showCloseButton:u=!0,ariaLabel:d,lockScroll:f=!0}){let p=Z(),m=(0,g.useRef)(t);if((0,g.useLayoutEffect)(()=>{m.current=t}),zt(()=>l?(m.current(),!0):!1,e),(0,g.useEffect)(()=>{if(e&&f)return jy(),()=>{My()}},[e,f]),!e)return null;let h=e=>{e.target===e.currentTarget&&c&&m.current()},_=d??(typeof n==`string`?n:void 0);return(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop ${o}`.trim(),onClick:h,role:`presentation`,children:(0,X.jsxs)(`div`,{className:`modal ${a}`.trim(),role:`dialog`,"aria-modal":`true`,"aria-label":_,style:s,onClick:e=>e.stopPropagation(),children:[u&&(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":p(`close`),onClick:()=>m.current(),children:`✕`}),n?(0,X.jsxs)(`div`,{className:`modal-head`,children:[r?(0,X.jsx)(`span`,{className:`modal-head-icon`,"aria-hidden":!0,children:r}):null,(0,X.jsx)(`span`,{children:n})]}):null,i]})}),document.body)}function Py({name:e,override:t,onApply:n,onClose:r}){let i=Z(),a=hs(e),[o,s]=(0,g.useState)(()=>t?.description??``),[c,l]=(0,g.useState)(()=>t?.promptSnippet??``),[u,d]=(0,g.useState)(()=>(t?.promptGuidelines??[]).join(`
364
- `));(0,g.useEffect)(()=>{ds(e)},[e]);let f=(0,g.useMemo)(()=>(a?.defaultPromptGuidelines??[]).join(`
365
- `),[a]),p=a?.status===`unsupported`||a?.status===`missing`;return(0,X.jsx)(Ny,{className:`tool-prompt-editor`,title:`${i(`toolPromptEdit`)} · ${e}`,icon:(0,X.jsx)(Y,{}),onClose:r,children:(0,X.jsxs)(`div`,{className:`tool-prompt-body`,children:[p&&(0,X.jsx)(`p`,{className:`set-note`,children:i(`toolPromptUnavailable`)}),(0,X.jsx)(`p`,{className:`set-note`,children:i(`toolPromptHint`)}),(0,X.jsxs)(`label`,{className:`tool-prompt-field`,children:[(0,X.jsx)(`span`,{className:`set-field-label`,children:i(`toolPromptDescription`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,value:o,placeholder:a?.defaultDescription??``,onChange:e=>s(e.target.value)}),a?.defaultDescription&&(0,X.jsxs)(`details`,{className:`tool-prompt-default`,children:[(0,X.jsx)(`summary`,{children:i(`toolPromptDefault`)}),(0,X.jsx)(`pre`,{children:a.defaultDescription})]})]}),(0,X.jsxs)(`label`,{className:`tool-prompt-field`,children:[(0,X.jsx)(`span`,{className:`set-field-label`,children:i(`toolPromptSnippet`)}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,value:c,placeholder:a?.defaultPromptSnippet??``,onChange:e=>l(e.target.value)}),a?.defaultPromptSnippet&&(0,X.jsxs)(`details`,{className:`tool-prompt-default`,children:[(0,X.jsx)(`summary`,{children:i(`toolPromptDefault`)}),(0,X.jsx)(`pre`,{children:a.defaultPromptSnippet})]})]}),(0,X.jsxs)(`label`,{className:`tool-prompt-field`,children:[(0,X.jsx)(`span`,{className:`set-field-label`,children:i(`toolPromptGuidelines`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input tool-prompt-guidelines`,rows:4,value:u,placeholder:f,onChange:e=>d(e.target.value)}),f&&(0,X.jsxs)(`details`,{className:`tool-prompt-default`,children:[(0,X.jsx)(`summary`,{children:i(`toolPromptDefault`)}),(0,X.jsx)(`pre`,{children:f})]})]}),(0,X.jsxs)(`div`,{className:`tool-prompt-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{n(e,null),ps(e),r()},children:i(`toolPromptReset`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let t={},i=o.trim();i&&(t.description=i);let a=c.trim();a&&(t.promptSnippet=a);let s=u.split(`
366
- `).map(e=>e.trim()).filter(Boolean);s.length>0&&(t.promptGuidelines=s),n(e,Object.keys(t).length>0?t:null),ps(e),r()},children:i(`toolPromptSave`)})]})]})})}var Fy=[{id:`filesystem`,name:`Filesystem`,nameZh:`本地文件系统`,description:`Secure file operations allowing reading, writing, and directory traversal with configurable allowed paths.`,descriptionZh:`官方文件系统工具,支持安全的文件读写、内容检索与目录遍历。`,category:`core`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-filesystem`,`.`],package:`@modelcontextprotocol/server-filesystem`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem`},{id:`fetch`,name:`Web Fetch`,nameZh:`网页抓取与提取`,description:`Fetches and converts web pages to clean Markdown for model consumption and research.`,descriptionZh:`抓取指定 URL 网页正文并转换为结构化 Markdown 供智能体分析与阅读。`,category:`search`,transport:`stdio`,command:`uvx`,args:[`mcp-server-fetch`],package:`mcp-server-fetch`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/fetch`},{id:`memory`,name:`Knowledge Graph Memory`,nameZh:`持久化知识记忆图谱`,description:`Knowledge-graph based persistent memory system storing entities and relations locally.`,descriptionZh:`基于实体与关联知识图谱的本地持久化记忆系统,赋予 AI 跨会话的长期记忆能力。`,category:`core`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-memory`],package:`@modelcontextprotocol/server-memory`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/memory`},{id:`github`,name:`GitHub`,nameZh:`GitHub 仓库与协作`,description:`Interact with GitHub repositories, search code, manage issues, and review pull requests.`,descriptionZh:`访问 GitHub 远程仓库、搜索代码、创建与检索 Issue、查看与操作 Pull Request。`,category:`dev`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-github`],package:`@modelcontextprotocol/server-github`,env:[{key:`GITHUB_PERSONAL_ACCESS_TOKEN`,value:``,placeholder:`ghp_xxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!0,requiresKey:!0,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/github`},{id:`git`,name:`Git Repository`,nameZh:`本地 Git 版本控制`,description:`Local Git repository operations including inspecting diffs, viewing history, and staging changes.`,descriptionZh:`本地 Git 仓库操作,支持查看提交历史、变更 Diff、分支切换与暂存区管理。`,category:`dev`,transport:`stdio`,command:`uvx`,args:[`mcp-server-git`,`--repository`,`.`],package:`mcp-server-git`,official:!1,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/git`},{id:`sqlite`,name:`SQLite Database`,nameZh:`SQLite 数据库操作`,description:`Query and inspect local SQLite databases with automatic schema discovery and safety checks.`,descriptionZh:`连接并查询本地 SQLite 数据库文件,支持执行 SQL 语句、表结构探查与业务数据分析。`,category:`db`,transport:`stdio`,command:`uvx`,args:[`mcp-server-sqlite`,`--db-path`,`./app.db`],package:`mcp-server-sqlite`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite`},{id:`postgres`,name:`PostgreSQL Database`,nameZh:`PostgreSQL 数据库`,description:`Read-only and read-write operations on PostgreSQL databases with schema inspection.`,descriptionZh:`连接 PostgreSQL 数据库,支持执行参数化查询、表与索引分析及数据检索。`,category:`db`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-postgres`,`postgresql://user:password@localhost:5432/dbname`],package:`@modelcontextprotocol/server-postgres`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/postgres`},{id:`brave-search`,name:`Brave Search`,nameZh:`Brave 全球网页搜索`,description:`Web search and local search capabilities powered by the privacy-preserving Brave Search API.`,descriptionZh:`基于 Brave Search API 的全球互联网网页与资讯搜索工具,提供干净的搜索结果。`,category:`search`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-brave-search`],package:`@modelcontextprotocol/server-brave-search`,env:[{key:`BRAVE_API_KEY`,value:``,placeholder:`BSAxxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!0,requiresKey:!0,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search`},{id:`tavily`,name:`Tavily AI Search`,nameZh:`Tavily 智能搜索`,description:`Search engine built specifically for AI agents, providing synthesized real-time web results.`,descriptionZh:`专为 AI 智能体设计的搜索引擎,提供实时、高相关度、深度提炼的互联网内容检索结果。`,category:`search`,transport:`stdio`,command:`uvx`,args:[`mcp-server-tavily`],package:`mcp-server-tavily`,env:[{key:`TAVILY_API_KEY`,value:``,placeholder:`tvly-xxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!1,requiresKey:!0,homepage:`https://tavily.com`},{id:`puppeteer`,name:`Puppeteer Web Browser`,nameZh:`Puppeteer 浏览器自动化`,description:`Automate browser interactions, take page screenshots, and interact with dynamic JavaScript apps.`,descriptionZh:`无头浏览器自动化控制,支持截取网页长图、模拟点击、输入表单与渲染复杂动态页面。`,category:`automation`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-puppeteer`],package:`@modelcontextprotocol/server-puppeteer`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/puppeteer`},{id:`docker`,name:`Docker Manager`,nameZh:`Docker 容器与镜像管理`,description:`Inspect containers, check runtime logs, and manage local Docker images and volumes.`,descriptionZh:`操作与监视本地 Docker 引擎,支持查询运行中容器、查看容器日志、启停与镜像管理。`,category:`tools`,transport:`stdio`,command:`uvx`,args:[`mcp-server-docker`],package:`mcp-server-docker`,official:!1,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers`},{id:`slack`,name:`Slack Integration`,nameZh:`Slack 频道与消息互动`,description:`Post messages, read channel transcripts, and manage conversations in Slack workspaces.`,descriptionZh:`连接 Slack 工作区,支持读取频道历史消息、发送团队通知与讨论串交互。`,category:`tools`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-slack`],package:`@modelcontextprotocol/server-slack`,env:[{key:`SLACK_BOT_TOKEN`,value:``,placeholder:`xoxb-xxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!0,requiresKey:!0,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/slack`},{id:`time`,name:`Time & Timezones`,nameZh:`世界时间与时区计算`,description:`Get current time in multiple formats, calculate offsets, and perform timezone conversions.`,descriptionZh:`精准查询当前本地与 UTC 时间、全球时区转换及时间戳日期运算。`,category:`tools`,transport:`stdio`,command:`uvx`,args:[`mcp-server-time`],package:`mcp-server-time`,official:!1,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/time`},{id:`sentry`,name:`Sentry Error Tracking`,nameZh:`Sentry 异常与崩溃追踪`,description:`Retrieve error traces, analyze crash dumps, and inspect recent issues from Sentry projects.`,descriptionZh:`从 Sentry 平台检索应用报错堆栈、异常统计与崩溃事件,辅助快速定位生产故障。`,category:`dev`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-sentry`],package:`@modelcontextprotocol/server-sentry`,env:[{key:`SENTRY_AUTH_TOKEN`,value:``,placeholder:`sntrys_xxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!0,requiresKey:!0,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/sentry`}],Iy=[{id:`custom`,label:`mcpPresetCustom`,description:`mcpPresetCustomDesc`,transport:`stdio`},{id:`filesystem`,label:`mcpPresetFilesystem`,description:`mcpPresetFilesystemDesc`,transport:`stdio`,command:`npx`,args:`-y @modelcontextprotocol/server-filesystem .`},{id:`fetch`,label:`mcpPresetFetch`,description:`mcpPresetFetchDesc`,transport:`stdio`,command:`uvx`,args:`mcp-server-fetch`},{id:`memory`,label:`mcpPresetMemory`,description:`mcpPresetMemoryDesc`,transport:`stdio`,command:`npx`,args:`-y @modelcontextprotocol/server-memory`},{id:`github`,label:`mcpPresetGithub`,description:`mcpPresetGithubDesc`,transport:`stdio`,command:`npx`,args:`-y @modelcontextprotocol/server-github`,env:[{key:`GITHUB_PERSONAL_ACCESS_TOKEN`,value:``}]},{id:`sqlite`,label:`mcpPresetSqlite`,description:`mcpPresetSqliteDesc`,transport:`stdio`,command:`uvx`,args:`mcp-server-sqlite --db-path ./app.db`}];function Ly({settings:e,chat:t}){let n=Z(),{locale:r}=Nn(),[i,a]=(0,g.useState)(`configured`),[o,s]=(0,g.useState)(`all`),[c,l]=(0,g.useState)(`smithery`),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)({}),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(`custom`),D=e.mcpServers??[],O=e.mcpGlobalConfigPath||``,k=e.mcpProjectConfigPath||``,A=(0,g.useMemo)(()=>o===`all`?D:D.filter(e=>e.scope===o),[D,o]),j=(0,g.useMemo)(()=>new Set(D.map(e=>e.name.toLowerCase())),[D]),ee=(e=!1)=>{let t=c===`custom`?u.trim():c;t&&(h(!0),$({type:`fetch_mcp_market`,source:t,query:f.trim()||void 0,refresh:e}))};(0,g.useEffect)(()=>{if(i!==`market`)return;let e=c===`custom`?u.trim():c;if(!e)return;h(!0);let t=setTimeout(()=>{$({type:`fetch_mcp_market`,source:e,query:f.trim()||void 0})},350);return()=>clearTimeout(t)},[i,c,f,u]),(0,g.useEffect)(()=>{t.mcpMarketResult&&h(!1)},[t.mcpMarketResult]);let M=(0,g.useMemo)(()=>t.mcpMarketResult?.ok&&t.mcpMarketResult.servers?.length>0?t.mcpMarketResult.servers:Fy.map(e=>({id:e.id,name:e.name,displayName:r===`zh`?e.nameZh:e.name,description:r===`zh`?e.descriptionZh:e.description,homepage:e.homepage,package:e.package,command:e.command,args:e.args,transport:e.transport,source:`builtin`,verified:e.official})),[t.mcpMarketResult,r]),te=(0,g.useMemo)(()=>D.filter(e=>e.scope===`global`).length,[D]),N=(0,g.useMemo)(()=>D.filter(e=>e.scope===`project`).length,[D]),ne=()=>{b(!0),$({type:`reload_mcp`}),setTimeout(()=>b(!1),800)},F=e=>{$({type:`toggle_mcp_server`,name:e.name,scope:e.scope,enabled:!e.enabled})},re=(e,t)=>{$({type:`delete_mcp_server`,name:e,scope:t}),w(null)},I=e=>{v(t=>({...t,[e]:!t[e]}))},L=(e=`global`,t=`custom`)=>{let n=Iy.find(e=>e.id===t)||Iy[0];E(n.id),S({name:n.id===`custom`?``:n.id,scope:e,transport:n.transport,command:n.command??``,args:n.args??``,cwd:``,env:n.env?[...n.env]:[],url:n.url??``,headers:[],timeout:``,description:``,enabled:!0,isNew:!0})},ie=(e,t)=>{let n=[];if(e.env)for(let[t,r]of Object.entries(e.env))n.push({key:t,value:String(r)});E(`custom`),S({name:e.id,scope:t,transport:e.transport||(e.url?`http`:`stdio`),command:e.command||(e.package,`npx`),args:e.args?.length?e.args.join(` `):e.package?`-y ${e.package}`:``,cwd:``,env:n,url:e.url||``,headers:[],timeout:``,description:e.description||``,enabled:!0,isNew:!0})},z=e=>{let t=[];if(e.env)for(let[n,r]of Object.entries(e.env))t.push({key:n,value:String(r)});let n=[];if(e.headers)for(let[t,r]of Object.entries(e.headers))n.push({key:t,value:String(r)});E(`custom`),S({name:e.name,scope:e.scope,transport:e.url?`http`:`stdio`,command:e.command??``,args:Array.isArray(e.args)?e.args.join(` `):``,cwd:e.cwd??``,env:t,url:e.url??``,headers:n,timeout:e.timeout===void 0?``:String(e.timeout),description:e.description??``,enabled:e.enabled!==!1,isNew:!1,prevName:e.name,prevScope:e.scope})},V=e=>{E(e);let t=Iy.find(t=>t.id===e);t&&x&&e!==`custom`&&S(e=>e?{...e,name:e.name?e.name:t.id,transport:t.transport,command:t.command??e.command,args:t.args??e.args,env:t.env?[...t.env]:e.env,url:t.url??e.url}:null)};return(0,X.jsxs)(`div`,{className:`set-section mcp-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(le,{className:`set-section-icon`}),n(`settingsMcp`),(0,X.jsx)(mu,{text:n(`settingsMcpDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:D.length}),(0,X.jsxs)(`div`,{className:`mcp-title-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn mcp-reload-btn${y?` spinning`:``}`,title:n(`mcpReload`),onClick:ne,children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:n(`mcpReload`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn mcp-add-btn`,title:n(`mcpAddServer`),onClick:()=>L(o===`project`?`project`:`global`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:n(`mcpAddServer`)})]})]})]}),(0,X.jsxs)(`div`,{className:`mcp-tab-bar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tab-btn${i===`configured`?` active`:``}`,onClick:()=>a(`configured`),children:[(0,X.jsx)(le,{}),(0,X.jsx)(`span`,{children:n(`mcpTabConfigured`)}),(0,X.jsx)(`span`,{className:`set-count`,children:D.length})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tab-btn${i===`market`?` active`:``}`,onClick:()=>a(`market`),children:[(0,X.jsx)(oe,{}),(0,X.jsx)(`span`,{children:n(`mcpTabMarket`)}),(0,X.jsx)(`span`,{className:`set-count`,children:Fy.length})]})]}),i===`configured`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mcp-meta-card`,children:[(0,X.jsxs)(`div`,{className:`mcp-scope-filter`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-scope-btn${o===`all`?` active`:``}`,onClick:()=>s(`all`),children:[n(`mcpFilterAll`),(0,X.jsx)(`span`,{className:`mcp-filter-count`,children:D.length})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-scope-btn${o===`global`?` active`:``}`,onClick:()=>s(`global`),children:[n(`mcpFilterGlobal`),(0,X.jsx)(`span`,{className:`mcp-filter-count`,children:te})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-scope-btn${o===`project`?` active`:``}`,onClick:()=>s(`project`),children:[n(`mcpFilterProject`),(0,X.jsx)(`span`,{className:`mcp-filter-count`,children:N})]})]}),(0,X.jsxs)(`div`,{className:`mcp-paths-summary`,children:[O&&(0,X.jsxs)(`div`,{className:`mcp-path-row`,children:[(0,X.jsxs)(`span`,{className:`mcp-path-label`,children:[n(`mcpGlobalPath`),`:`]}),(0,X.jsx)(`code`,{className:`mcp-path-text`,title:O,children:O}),(0,X.jsx)(Sd,{text:O})]}),k&&(0,X.jsxs)(`div`,{className:`mcp-path-row`,children:[(0,X.jsxs)(`span`,{className:`mcp-path-label`,children:[n(`mcpProjectPath`),`:`]}),(0,X.jsx)(`code`,{className:`mcp-path-text`,title:k,children:k}),(0,X.jsx)(Sd,{text:k})]})]})]}),A.length===0?(0,X.jsxs)(`div`,{className:`mcp-empty-card`,children:[(0,X.jsx)(`div`,{className:`mcp-empty-icon`,children:(0,X.jsx)(le,{})}),(0,X.jsx)(`div`,{className:`mcp-empty-title`,children:n(`mcpEmptyTitle`)}),(0,X.jsx)(`div`,{className:`mcp-empty-desc`,children:n(`mcpEmptyDesc`)}),(0,X.jsxs)(`div`,{className:`mcp-empty-quick-presets`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-goto-market-btn`,onClick:()=>a(`market`),children:[(0,X.jsx)(oe,{}),n(`mcpBrowseMarket`)]}),(0,X.jsxs)(`span`,{className:`mcp-quick-label`,children:[n(`mcpQuickAdd`),`:`]}),Iy.filter(e=>e.id!==`custom`).map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`mcp-quick-btn`,onClick:()=>L(`global`,e.id),children:[(0,X.jsx)(me,{}),n(e.label)]},e.id))]})]}):(0,X.jsx)(`div`,{className:`mcp-servers-list`,children:A.map(e=>{let t=`${e.scope}:${e.name}`,r=!!_[t],i=e.tools?.length??0;return(0,X.jsxs)(`div`,{className:`mcp-server-card${e.enabled?``:` disabled`}`,children:[(0,X.jsxs)(`div`,{className:`mcp-card-head`,children:[(0,X.jsxs)(`div`,{className:`mcp-card-title-group`,children:[(0,X.jsx)(`span`,{className:`mcp-server-name`,children:e.name}),(0,X.jsx)(`span`,{className:`mcp-scope-badge scope-${e.scope}`,children:e.scope===`global`?n(`mcpScopeGlobal`):n(`mcpScopeProject`)}),(0,X.jsx)(`span`,{className:`mcp-transport-badge`,children:e.url?`HTTP`:`stdio`}),(0,X.jsxs)(`span`,{className:`mcp-status-pill status-${e.status??(e.enabled?`running`:`stopped`)}`,children:[(0,X.jsx)(`span`,{className:`mcp-status-dot`}),e.status===`error`?n(`mcpStatusError`):e.enabled?`${n(`mcpStatusRunning`)}${i>0?` (${i})`:``}`:n(`mcpStatusStopped`)]})]}),(0,X.jsxs)(`div`,{className:`mcp-card-actions`,children:[(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,className:`set-switch${e.enabled?` on`:``}`,title:e.enabled?n(`mcpDisableHint`):n(`mcpEnableHint`),onClick:()=>F(e),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn mcp-action-btn`,title:n(`edit`),onClick:()=>z(e),children:(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn mcp-action-btn delete-btn`,title:n(`delete`),onClick:()=>w({name:e.name,scope:e.scope}),children:(0,X.jsx)(R,{})})]})]}),(0,X.jsxs)(`div`,{className:`mcp-card-body`,children:[e.description&&(0,X.jsx)(`div`,{className:`mcp-server-desc`,children:e.description}),(0,X.jsx)(`div`,{className:`mcp-spec-line`,children:e.url?(0,X.jsxs)(`div`,{className:`mcp-spec-http`,children:[(0,X.jsx)(Fe,{className:`mcp-spec-icon`}),(0,X.jsx)(`code`,{className:`mcp-spec-code`,children:e.url})]}):(0,X.jsxs)(`div`,{className:`mcp-spec-cmd`,children:[(0,X.jsx)(B,{className:`mcp-spec-icon`}),(0,X.jsxs)(`code`,{className:`mcp-spec-code`,children:[e.command,` `,e.args?.join(` `)]})]})}),e.cwd&&(0,X.jsxs)(`div`,{className:`mcp-spec-detail`,children:[(0,X.jsx)(Re,{className:`mcp-detail-icon`}),(0,X.jsx)(`span`,{className:`mcp-detail-label`,children:`cwd:`}),(0,X.jsx)(`code`,{children:e.cwd})]}),e.env&&Object.keys(e.env).length>0&&(0,X.jsxs)(`div`,{className:`mcp-spec-detail`,children:[(0,X.jsx)(`span`,{className:`mcp-detail-label`,children:`env:`}),(0,X.jsx)(`span`,{className:`mcp-env-tags`,children:Object.keys(e.env).map(e=>(0,X.jsx)(`span`,{className:`mcp-env-tag`,children:e},e))})]}),e.status===`error`&&e.error&&(0,X.jsxs)(`div`,{className:`mcp-error-box`,children:[(0,X.jsx)(wt,{className:`mcp-error-icon`}),(0,X.jsx)(`div`,{className:`mcp-error-text`,children:e.error})]}),i>0&&(0,X.jsxs)(`div`,{className:`mcp-tools-accordion`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tools-toggle`,onClick:()=>I(t),children:[(0,X.jsx)(ke,{className:`mcp-tools-icon`}),(0,X.jsx)(`span`,{children:n(`mcpToolsCount`,{count:i})}),r?(0,X.jsx)(ct,{}):(0,X.jsx)(dt,{})]}),r&&(0,X.jsx)(`div`,{className:`mcp-tools-content`,children:e.tools?.map(e=>(0,X.jsxs)(`div`,{className:`mcp-tool-item`,children:[(0,X.jsx)(`span`,{className:`mcp-tool-name`,children:e.name}),e.description&&(0,X.jsx)(`span`,{className:`mcp-tool-desc`,children:e.description})]},e.name))})]})]})]},t)})})]}),i===`market`&&(0,X.jsxs)(`div`,{className:`mcp-market-view`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-toolbar`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-source-row`,children:[(0,X.jsxs)(`div`,{className:`mcp-source-select-wrap`,children:[(0,X.jsxs)(`label`,{className:`mcp-source-label`,children:[n(`mcpSourceSelectLabel`),`:`]}),(0,X.jsxs)(`select`,{className:`set-select mcp-source-select`,value:c,onChange:e=>l(e.target.value),children:[(0,X.jsx)(`option`,{value:`smithery`,children:n(`mcpSourceSmithery`)}),(0,X.jsx)(`option`,{value:`github`,children:n(`mcpSourceGithub`)}),(0,X.jsx)(`option`,{value:`custom`,children:n(`mcpSourceCustom`)})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn mcp-sync-btn${m?` spinning`:``}`,title:n(`mcpReload`),onClick:()=>ee(!0),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:n(`mcpReload`)})]})]}),c===`custom`&&(0,X.jsx)(`div`,{className:`mcp-custom-source-row`,children:(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-custom-input`,placeholder:n(`mcpSourceCustomPlaceholder`),value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ee(!0)}})}),(0,X.jsxs)(`div`,{className:`mcp-search-wrap`,children:[(0,X.jsx)(de,{className:`mcp-search-icon`}),(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-search-input`,placeholder:n(`mcpMarketSearchPlaceholder`),value:f,onChange:e=>p(e.target.value)}),f&&(0,X.jsx)(`button`,{type:`button`,className:`mcp-search-clear`,onClick:()=>p(``),children:(0,X.jsx)(P,{})})]})]}),t.mcpMarketResult?.error&&(0,X.jsxs)(`div`,{className:`mcp-error-box`,children:[(0,X.jsx)(wt,{className:`mcp-error-icon`}),(0,X.jsx)(`div`,{className:`mcp-error-text`,children:t.mcpMarketResult.error}),(0,X.jsx)(`button`,{type:`button`,className:`mcp-mini-btn`,onClick:()=>ee(!0),children:n(`mcpMarketRetry`)})]}),m&&(0,X.jsxs)(`div`,{className:`mcp-market-loading`,children:[(0,X.jsx)(K,{className:`spinning`}),(0,X.jsx)(`span`,{children:n(`mcpMarketLoading`)})]}),(0,X.jsx)(`div`,{className:`mcp-market-grid`,children:M.map(e=>{let t=j.has(e.id.toLowerCase());return(0,X.jsxs)(`div`,{className:`mcp-market-card`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-card-head`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-title-wrap`,children:[e.iconUrl?(0,X.jsx)(`img`,{src:e.iconUrl,alt:``,className:`mcp-market-icon-img`}):(0,X.jsx)(le,{className:`mcp-market-icon-fallback`}),(0,X.jsx)(`span`,{className:`mcp-market-name`,children:e.displayName||e.name}),e.displayName&&e.displayName!==e.name&&(0,X.jsxs)(`span`,{className:`mcp-market-subname`,children:[`(`,e.name,`)`]}),e.verified&&(0,X.jsx)(`span`,{className:`mcp-badge-official`,children:n(`mcpBadgeOfficial`)})]}),e.homepage&&(0,X.jsx)(`a`,{href:e.homepage,target:`_blank`,rel:`noreferrer`,className:`mcp-market-link`,title:e.homepage,children:(0,X.jsx)(Ge,{})})]}),(0,X.jsx)(`p`,{className:`mcp-market-desc`,children:e.description}),(0,X.jsxs)(`div`,{className:`mcp-market-pkg`,children:[(0,X.jsx)(`code`,{className:`mcp-market-pkg-code`,children:e.package||e.id}),typeof e.downloads==`number`&&e.downloads>0&&(0,X.jsxs)(`span`,{className:`mcp-downloads-tag`,children:[e.downloads.toLocaleString(),` downloads`]})]}),(0,X.jsxs)(`div`,{className:`mcp-market-card-actions`,children:[t&&(0,X.jsxs)(`span`,{className:`mcp-market-configured-badge`,children:[(0,X.jsx)(ft,{}),n(`mcpConfigured`)]}),(0,X.jsxs)(`div`,{className:`mcp-market-add-btns`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-btn-add global`,title:n(`mcpAddGlobalHint`),onClick:()=>ie(e,`global`),children:[(0,X.jsx)(me,{}),n(`mcpAddGlobal`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-btn-add project`,title:n(`mcpAddProjectHint`),onClick:()=>ie(e,`project`),children:[(0,X.jsx)(me,{}),n(`mcpAddProject`)]})]})]})]},`${e.source}-${e.id}`)})})]}),C&&(0,X.jsx)(`div`,{className:`modal-backdrop sub-modal`,onClick:()=>w(null),children:(0,X.jsxs)(`div`,{className:`modal confirm-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(wt,{className:`modal-head-icon`}),(0,X.jsx)(`h3`,{children:n(`mcpDeleteConfirmTitle`)})]}),(0,X.jsx)(`div`,{className:`modal-body`,children:(0,X.jsx)(`p`,{children:n(`mcpDeleteConfirmDesc`,{name:C.name,scope:C.scope===`global`?n(`mcpScopeGlobal`):n(`mcpScopeProject`)})})}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-cancel-btn`,onClick:()=>w(null),children:n(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn-danger`,onClick:()=>re(C.name,C.scope),children:n(`delete`)})]})]})}),x&&(0,X.jsx)(`div`,{className:`modal-backdrop sub-modal`,onClick:()=>S(null),children:(0,X.jsxs)(`div`,{className:`modal mcp-edit-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":n(`close`),onClick:()=>S(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(le,{className:`modal-head-icon`}),(0,X.jsx)(`h3`,{children:x.isNew?n(`mcpAddModalTitle`):n(`mcpEditModalTitle`)})]}),(0,X.jsxs)(`div`,{className:`modal-body mcp-form-body`,children:[x.isNew&&(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpPresetSelect`)}),(0,X.jsx)(`select`,{className:`set-select`,value:T,onChange:e=>V(e.target.value),children:Iy.map(e=>(0,X.jsx)(`option`,{value:e.id,children:n(e.label)},e.id))})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[n(`mcpScopeLabel`),(0,X.jsx)(`span`,{className:`field-required`,children:`*`})]}),(0,X.jsxs)(`div`,{className:`mcp-scope-selector`,children:[(0,X.jsxs)(`label`,{className:`mcp-scope-radio${x.scope===`global`?` selected`:``}`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`scope`,checked:x.scope===`global`,onChange:()=>S(e=>e?{...e,scope:`global`}:null)}),(0,X.jsxs)(`div`,{className:`mcp-radio-content`,children:[(0,X.jsx)(`div`,{className:`mcp-radio-title`,children:n(`mcpScopeGlobal`)}),(0,X.jsx)(`div`,{className:`mcp-radio-hint`,children:n(`mcpScopeGlobalHint`)})]})]}),(0,X.jsxs)(`label`,{className:`mcp-scope-radio${x.scope===`project`?` selected`:``}`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`scope`,checked:x.scope===`project`,onChange:()=>S(e=>e?{...e,scope:`project`}:null)}),(0,X.jsxs)(`div`,{className:`mcp-radio-content`,children:[(0,X.jsx)(`div`,{className:`mcp-radio-title`,children:n(`mcpScopeProject`)}),(0,X.jsx)(`div`,{className:`mcp-radio-hint`,children:n(`mcpScopeProjectHint`)})]})]})]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[n(`mcpNameLabel`),(0,X.jsx)(`span`,{className:`field-required`,children:`*`})]}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpNamePlaceholder`),value:x.name,onChange:e=>S(t=>t?{...t,name:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpTransportLabel`)}),(0,X.jsxs)(`div`,{className:`mcp-transport-selector`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-transport-btn${x.transport===`stdio`?` active`:``}`,onClick:()=>S(e=>e?{...e,transport:`stdio`}:null),children:[(0,X.jsx)(B,{}),`stdio (`,n(`mcpTransportStdio`),`)`]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-transport-btn${x.transport===`http`?` active`:``}`,onClick:()=>S(e=>e?{...e,transport:`http`}:null),children:[(0,X.jsx)(Fe,{}),`HTTP (`,n(`mcpTransportHttp`),`)`]})]})]}),x.transport===`stdio`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[n(`mcpCommandLabel`),(0,X.jsx)(`span`,{className:`field-required`,children:`*`})]}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpCommandPlaceholder`),value:x.command,onChange:e=>S(t=>t?{...t,command:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpArgsLabel`)}),(0,X.jsx)(`textarea`,{className:`set-input mcp-args-input`,rows:2,placeholder:n(`mcpArgsPlaceholder`),value:x.args,onChange:e=>S(t=>t?{...t,args:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpCwdLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpCwdPlaceholder`),value:x.cwd,onChange:e=>S(t=>t?{...t,cwd:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`div`,{className:`mcp-field-header`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpEnvLabel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-mini-btn`,onClick:()=>S(e=>e?{...e,env:[...e.env,{key:``,value:``}]}:null),children:[(0,X.jsx)(me,{}),n(`mcpAddEnv`)]})]}),x.env.map((e,t)=>(0,X.jsxs)(`div`,{className:`mcp-kv-row`,children:[(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-kv-key`,placeholder:n(`mcpEnvKeyPlaceholder`),value:e.key,onChange:e=>{let n=[...x.env];n[t].key=e.target.value,S(e=>e?{...e,env:n}:null)}}),(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-kv-val`,placeholder:n(`mcpEnvValuePlaceholder`),value:e.value,onChange:e=>{let n=[...x.env];n[t].value=e.target.value,S(e=>e?{...e,env:n}:null)}}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn delete-btn`,onClick:()=>{let e=x.env.filter((e,n)=>n!==t);S(t=>t?{...t,env:e}:null)},children:(0,X.jsx)(R,{})})]},t))]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[n(`mcpUrlLabel`),(0,X.jsx)(`span`,{className:`field-required`,children:`*`})]}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpUrlPlaceholder`),value:x.url,onChange:e=>S(t=>t?{...t,url:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`div`,{className:`mcp-field-header`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpHeadersLabel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-mini-btn`,onClick:()=>S(e=>e?{...e,headers:[...e.headers,{key:``,value:``}]}:null),children:[(0,X.jsx)(me,{}),n(`mcpAddHeader`)]})]}),x.headers.map((e,t)=>(0,X.jsxs)(`div`,{className:`mcp-kv-row`,children:[(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-kv-key`,placeholder:n(`mcpHeaderKeyPlaceholder`),value:e.key,onChange:e=>{let n=[...x.headers];n[t].key=e.target.value,S(e=>e?{...e,headers:n}:null)}}),(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-kv-val`,placeholder:n(`mcpHeaderValuePlaceholder`),value:e.value,onChange:e=>{let n=[...x.headers];n[t].value=e.target.value,S(e=>e?{...e,headers:n}:null)}}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn delete-btn`,onClick:()=>{let e=x.headers.filter((e,n)=>n!==t);S(t=>t?{...t,headers:e}:null)},children:(0,X.jsx)(R,{})})]},t))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpDescriptionLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpDescriptionPlaceholder`),value:x.description,onChange:e=>S(t=>t?{...t,description:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-text`,children:[(0,X.jsx)(`div`,{className:`set-row-label`,children:n(`mcpEnabledLabel`)}),(0,X.jsx)(`div`,{className:`set-row-desc`,children:n(`mcpEnabledDesc`)})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":x.enabled,className:`set-switch${x.enabled?` on`:``}`,onClick:()=>S(e=>e?{...e,enabled:!e.enabled}:null),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})]}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-cancel-btn`,onClick:()=>S(null),children:n(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!x.name.trim()||x.transport===`stdio`&&!x.command.trim()||x.transport===`http`&&!x.url.trim(),onClick:()=>{if(!x)return;let e=x.name.trim();if(!e)return;let t={};for(let e of x.env){let n=e.key.trim();n&&(t[n]=e.value)}let n={};for(let e of x.headers){let t=e.key.trim();t&&(n[t]=e.value)}let r=x.args.trim().split(/\s+/).filter(e=>e.length>0),i=Number(x.timeout);$({type:`save_mcp_server`,server:{name:e,scope:x.scope,type:x.transport,command:x.transport===`stdio`&&x.command.trim()||void 0,args:x.transport===`stdio`&&r.length>0?r:void 0,cwd:x.transport===`stdio`&&x.cwd.trim()?x.cwd.trim():void 0,env:x.transport===`stdio`&&Object.keys(t).length>0?t:void 0,url:x.transport===`http`&&x.url.trim()?x.url.trim():void 0,headers:x.transport===`http`&&Object.keys(n).length>0?n:void 0,timeout:!isNaN(i)&&i>0?i:void 0,description:x.description.trim()||void 0,enabled:x.enabled},prevName:x.isNew?void 0:x.prevName,prevScope:x.isNew?void 0:x.prevScope}),S(null)},children:[(0,X.jsx)(ft,{}),(0,X.jsx)(`span`,{children:n(`save`)})]})]})]})})]})}var Ry=[{id:`code-review`,name:`Code Review`,nameZh:`代码审查与质量把关`,description:`Comprehensive code review guidelines for security vulnerabilities, logic bugs, concurrency flaws, and boundary conditions.`,descriptionZh:`全方位代码审查:深度排查安全漏洞、并发竞争隐患、边界异常以及性能退化。`,category:`quality`,content:`---
359
+ `)}}var c_=null;function l_(){if(c_?.isConnected)return c_;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),c_=e,e}function u_(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function d_(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=a_,e.appendChild(n),n.offsetTop}function f_(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=s_(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=l_();if(u_(e,i)<=0)return r;let a=d_(i,t.slice(0,n)),o=d_(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:o_(a,o,i_(e))}function p_(e,t){let n=[],r=e?.length??0;for(let t=0;t<r;t++){let r=e?.[t];if(!r||r.kind!==`file`)continue;let i=r.getAsFile();i&&n.push(i)}if(n.length===0&&t)for(let e=0;e<t.length;e++){let r=t[e];r&&n.push(r)}return n}var m_=`pi-web-ui:prompt-history`,h_=`pi-web-ui:prompt-history-settings`,g_={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function __(e){let t=g_;if(!e||typeof e!=`object`)return{...t};let n=e,r=typeof n.maxEntries==`number`?Math.floor(n.maxEntries):t.maxEntries;(!Number.isFinite(r)||r<1)&&(r=1),r>500&&(r=500);let i=typeof n.charLimit==`number`?Math.floor(n.charLimit):t.charLimit;(!Number.isFinite(i)||i<100)&&(i=100),i>2e4&&(i=2e4);let a=typeof n.charLimitEnabled==`boolean`?n.charLimitEnabled:t.charLimitEnabled;return{maxEntries:r,charLimitEnabled:a,charLimit:i}}function v_(){try{let e=localStorage.getItem(h_);return e?__(JSON.parse(e)):{...g_}}catch{return{...g_}}}function y_(e){let t=__(e);try{localStorage.setItem(h_,JSON.stringify(t))}catch{}try{let e=S_();t.charLimitEnabled&&(e=e.map(e=>e.length>t.charLimit?e.slice(0,t.charLimit):e)),e.length>t.maxEntries&&(e=e.slice(e.length-t.maxEntries)),C_(e)}catch{}}function b_(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function x_(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function S_(){try{let e=localStorage.getItem(m_);return e?b_(JSON.parse(e)):[]}catch{return[]}}function C_(e){let t=e;for(;t;)try{localStorage.setItem(m_,JSON.stringify(t));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||t.length<=1)return;t=t.slice(Math.ceil(t.length/2))}}function w_(e){let t=e.trim();if(!t)return;let n=v_();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));let r=S_(),i=x_(r,t,n.maxEntries);i!==r&&C_(i)}function T_(){try{localStorage.removeItem(m_)}catch{}}var E_=`skill:`;function D_(e,t){let n=e.toLowerCase();return t===`skill`&&n.startsWith(`skill:`)?[n,n.slice(6)]:[n]}function O_(e,t){let n=t.toLowerCase();return n?e.filter(e=>D_(e.name,e.source).some(e=>e.startsWith(n))):[...e]}var k_=new Set([`p`,`page`,`pages`,`web`,`网页`,`页面`]);function A_(e,t,n,r=10){if(!Array.isArray(t))return[];let i=String(n??``).toLowerCase(),a=i===``||k_.has(i),o=[];for(let n of t){if(!n||typeof n.origin!=`string`||!n.origin||n.open!==!0)continue;let t=typeof n.title==`string`&&n.title.trim()?n.title.trim():n.origin;if(!a&&!t.toLowerCase().includes(i)&&!n.origin.toLowerCase().includes(i))continue;let s=t.indexOf(` · `),c=s===-1?`page · ${t}`:`page · ${t.slice(s+3)}`;if(o.push({providerId:`host:pages`,providerLabel:e,title:c,hint:n.origin,text:t,attachments:[{path:n.origin,name:t,mode:`page`}]}),o.length>=Math.max(0,r))break}return o}function j_(e,t,n=10){if(!Array.isArray(t))return[];let r=[];for(let i of t.slice(0,Math.max(0,n))){if(!i||typeof i!=`object`)continue;let t=i;typeof t.path==`string`&&t.path&&typeof t.name==`string`&&t.name&&r.push({providerId:`host:files`,providerLabel:e,title:t.name,hint:t.path,text:`@${t.path}`,attachments:[{path:t.path,name:t.name,mode:`reference`,...t.type===`dir`?{isDir:!0}:{}}]})}return r}function M_(e,t,n,r=10){if(!Array.isArray(n))return[];let i=[];for(let a of n.slice(0,Math.max(0,r))){if(!a||typeof a!=`object`)continue;let n=a;if(typeof n.title!=`string`||!n.title.trim())continue;let r=Array.isArray(n.attachments)?n.attachments.filter(e=>!!e&&typeof e==`object`&&typeof e.path==`string`).slice(0,4).map(e=>{let t=e.mode;return{path:e.path,...typeof e.name==`string`?{name:e.name}:{},...t===`inline`||t===`reference`||t===`lines`||t===`page`?{mode:t}:{},...typeof e.isDir==`boolean`?{isDir:e.isDir}:{}}}):void 0;i.push({providerId:e,providerLabel:t,title:n.title.trim(),...typeof n.hint==`string`&&n.hint?{hint:n.hint}:{},...typeof n.text==`string`&&n.text?{text:n.text}:{},...r?.length?{attachments:r}:{}})}return i}function N_(e,t,n,r=15,i){if(!Array.isArray(t)||r<=0)return[];let a=String(n??``).toLowerCase(),o=a.startsWith(E_),s=o?a.slice(E_.length):a,c=[],l=[],u=o||s.length>=3;for(let n of t){if(n.source!==`skill`)continue;let t=n.name.startsWith(`skill:`)?n.name.slice(E_.length):n.name,r=t.toLowerCase(),a=i?i(n):n.description??``,o=a.toLowerCase(),d=(n.descriptionEn??``).toLowerCase(),f={providerId:`host:skills`,providerLabel:e,title:t,hint:a||`Skill ${t}`,text:`@skill:${t}`};s?r.includes(s)?c.push(f):u&&(o.includes(s)||d.includes(s))&&l.push(f):c.push(f)}return[...c,...l].slice(0,Math.max(0,r))}function P_(e,t,n=30){let r=String(t??``).toLowerCase(),i=e.pages??[],a=e.skills??[],o=e.files??[],s=e.plugins??[],c;return c=r.startsWith(`skill:`)?[...a,...i,...o,...s]:[...i,...a,...o,...s],c.slice(0,Math.max(0,n))}function F_(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function I_(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!F_(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function L_(e){let t=e.query;if(!t||!t(`(pointer: coarse)`)||!t(`(hover: none)`))return!1;let n=e.userAgent??``;return!(/Windows|CrOS/i.test(n)||/Linux/i.test(n)&&!/Android/i.test(n)||/Macintosh/i.test(n)&&(e.maxTouchPoints??0)<=1)}function R_(){return typeof window>`u`||typeof navigator>`u`||typeof window.matchMedia!=`function`?!1:L_({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}function z_(e,t,n){if(t<=0||!e)return null;let r=null;for(let t of n){let n=[t.mode===`page`||t.mode===`conversation`?t.name:t.path,t.name].filter(e=>typeof e==`string`&&e.trim().length>0);for(let i of n){let n=`@`+i,a=e.endsWith(n+` `);if(a||e.endsWith(n)){let e=n.length;(!r||e>r.tokenLen)&&(r={attachment:t,tokenLen:e,withSpace:a})}}}let i=-1,a=r?.attachment;if(r){let n=t-(r.withSpace?r.tokenLen+1:r.tokenLen);n>0&&/[\w.\-/]/.test(e[n-1])?(i=-1,a=void 0):i=n}if(i<0){let r=/(^|[\s(("'"“‘[【])(@[^\s@,.;:!?,。!?)\]】」]+)(\s?)$/.exec(e);if(r){i=t-r[2].length-r[3].length;let o=e.slice(i,t).trim().replace(/^@/,``),s=o.split(`/`).pop()??o;a=n.find(e=>e.path&&e.path===o)??n.find(e=>e.name&&e.name===o)??n.find(e=>e.mode!==`page`&&e.mode!==`conversation`&&e.name===s)}}return i>=0&&i<t?{tokenStart:i,...a?{attachment:a}:{}}:null}function B_(e,t=0,n=Date.now()){return!!(e.isComposing||e.keyCode===229||t>0&&n-t<50)}function V_(){let e=(0,g.useRef)(0);return{onCompositionEnd:()=>{e.current=Date.now()},isImeKey:t=>B_(t,e.current)}}var H_=1;function U_(){return++H_}var W_=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],G_=(0,g.memo)(function({state:e,models:t,modelsLoading:n,onManageModels:r,providerKeys:i,defaultModel:a,compact:o=!1,only:s}){let c=Z(),l=e?.model,u=l?`${l.provider}/${l.id}`:null,[d,f]=(0,g.useState)(!1),[p,m]=(0,g.useState)(!1),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(null),[b,x]=(0,g.useState)({}),S=(0,g.useRef)(null),C=(0,g.useRef)(null),[w,T]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!d){T(null);return}if(t.length===0)return;let e=requestAnimationFrame(()=>{let e=C.current;e&&T(e.offsetWidth)});return()=>cancelAnimationFrame(e)},[d,t.length]),(0,g.useEffect)(()=>{d&&x(Vh())},[d]),(0,g.useEffect)(()=>{d||(_(``),y(null))},[d]);let E=(0,g.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.provider,(e.get(n.provider)??0)+1);let n=[];for(let[t,r]of[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))){let e=i[t];if(e&&e.length>1)for(let i of e)n.push({provider:t,keyName:i.name,count:r});else n.push({provider:t,keyName:null,count:r})}return n},[t,i]),D=(0,g.useMemo)(()=>Bh(t,b),[t,b]),O=(0,g.useMemo)(()=>{let e=D;v&&(e=e.filter(e=>e.provider===v.provider));let t=h.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)):e},[D,h,v]),k=(0,g.useMemo)(()=>{let e=[];for(let t of O){let n=i[t.provider];if(!n||n.length<=1){e.push({model:t,key:null});continue}let r=n.find(e=>e.active)??n[0];if(v?.provider===t.provider&&v.keyName){let e=n.find(e=>e.name===v.keyName);e&&(r=e)}e.push({model:t,key:r})}return e},[O,i,v]),[A,j]=(0,g.useState)(!1),ee=e?.availableThinkingLevels&&e.availableThinkingLevels.length>0?new Set(e.availableThinkingLevels):null,M=W_.map(e=>({value:e,label:c(`thinking.${e}`),supported:!ee||ee.has(e)})),te=e=>M.find(t=>t.value===e)?.label??e,P=(0,g.useRef)(!1);(0,g.useEffect)(()=>{if(!d){P.current=!1;return}P.current||t.length>0||n||(P.current=!0,j(!0),$({type:`list_models`})||j(!1))},[d,t.length,n]),(0,g.useEffect)(()=>{j(!1)},[t]),(0,g.useEffect)(()=>{d&&(S.current?.querySelector(`.dd-item.active`))?.scrollIntoView({block:`nearest`})},[d,u,t.length]);let ne=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`availableModels`)}),(0,X.jsxs)(`div`,{className:`dd-search-row`,children:[(0,X.jsx)(fe,{}),(0,X.jsx)(`input`,{className:`dd-search`,type:`text`,placeholder:c(`searchModels`),value:h,onChange:e=>_(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`dd-model-body`,children:[E.length>1&&(0,X.jsxs)(`div`,{className:`dd-provider-col`,children:[(0,X.jsx)(`div`,{className:`dd-provider-head`,children:c(`providers`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-provider-item ${v===null?`active`:``}`,onClick:()=>y(null),children:(0,X.jsx)(`span`,{children:c(`allProviders`)})}),E.map(e=>{let t=v?.provider===e.provider&&v?.keyName===e.keyName;return(0,X.jsxs)(`button`,{type:`button`,className:`dd-provider-item ${t?`active`:``}`,onClick:()=>y(t?null:{provider:e.provider,keyName:e.keyName}),title:e.keyName?`${e.provider} · ${e.keyName}`:`${e.provider} · ${e.count}`,children:[(0,X.jsxs)(`span`,{className:`dd-provider-txt`,children:[(0,X.jsx)(`span`,{className:`dd-provider-name`,children:e.provider}),e.keyName&&(0,X.jsx)(`span`,{className:`dd-provider-key`,children:e.keyName})]}),(0,X.jsx)(`span`,{className:`dd-provider-count`,children:e.count})]},e.keyName?`${e.provider}::${e.keyName}`:e.provider)})]}),(0,X.jsxs)(`div`,{className:`dd-model-scroll`,ref:S,children:[(A||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`loading`)}),t.length===0&&!A&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`noModels`)}),O.length===0&&t.length>0&&(0,X.jsx)(`div`,{className:`dd-loading`,children:c(`noModelMatches`)}),k.map(e=>{let t=e.model,n=u===t.id&&(!e.key||e.key.active),r=a!==void 0&&a===t.id;return(0,X.jsxs)(Ht,{active:n,onClick:()=>{e.key&&!e.key.active&&$({type:`activate_provider_key`,provider:t.provider,keyName:e.key.name}),u!==t.id&&$({type:`set_model`,modelId:t.id}),f(!1)},children:[(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:t.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:t.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:t.id.split(`/`).slice(1).join(`/`)}),e.key&&(0,X.jsxs)(`span`,{className:`dd-model-key ${e.key.active?`active`:``}`,children:[e.key.active?`●`:`○`,` `,e.key.name]}),(b[t.id]??0)>0&&(0,X.jsx)(`span`,{className:`dd-model-usage`,children:c(`modelUsedCount`,{n:b[t.id]})}),(t.reasoning||t.vision)&&(0,X.jsxs)(`span`,{className:`dd-model-badges`,children:[t.reasoning&&(0,X.jsx)(`span`,{className:`dd-model-badge`,children:c(`reasoning`)}),t.vision&&(0,X.jsx)(`span`,{className:`dd-model-badge`,children:c(`vision`)})]})]})]}),a!==void 0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-star-btn ${r?`active`:``}`,title:r?`当前全局默认模型(点击取消默认)`:`设为全局默认模型`,onClick:e=>{e.stopPropagation(),$(r?{type:`clear_default_model`}:{type:`set_default_model`,modelId:t.id})},children:r?`★`:`☆`})]},e.key?`${t.id}::${e.key.name}`:t.id)})]})]}),(0,X.jsxs)(`div`,{className:`dd-footer`,children:[a!==void 0&&a&&(0,X.jsxs)(`div`,{className:`dd-default-banner`,children:[(0,X.jsxs)(`div`,{className:`dd-default-banner-left`,children:[(0,X.jsx)(`span`,{className:`dd-default-banner-star`,children:`★`}),(0,X.jsx)(`span`,{className:`dd-default-banner-label`,children:`默认模型`}),(0,X.jsx)(`span`,{className:`dd-default-banner-name`,title:`默认模型: ${a}`,children:a.split(`/`).slice(1).join(`/`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`dd-default-banner-clear`,title:`清除全局默认模型`,onClick:()=>$({type:`clear_default_model`}),children:`✕ 清除`})]}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`list_models`}),children:c(`refreshModels`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{f(!1),r()},children:c(`manageModels`)})]})]}),F=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`thinkingLevel`)}),M.map(t=>(0,X.jsx)(Ht,{active:e?.thinkingLevel===t.value,disabled:!t.supported,title:t.supported?void 0:c(`thinkingUnsupported`),onClick:()=>{e?.thinkingLevel!==t.value&&$({type:`set_thinking`,level:t.value}),m(!1)},children:t.label},t.value))]}),re=(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ze,{}),(0,X.jsx)(`span`,{className:`chip-model`,children:l?l.name:c(`selectModel`)}),!o&&l?.vision&&(0,X.jsx)(`span`,{className:`chip-vision`,title:c(`vision`),children:`🖼`}),!o&&l&&(0,X.jsx)(`span`,{className:`chip-sub`,children:l.provider})]}),open:d,onOpenChange:f,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:ne}),ie=(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:c(`thinkingChip`,{level:e?te(e.thinkingLevel):`—`})})]}),tip:c(`thinkingLevel`),open:p,onOpenChange:m,align:`left`,direction:`up`,children:F});if(s===`model`)return re;if(s===`thinking`)return ie;let ae=e?.thinkingLevel&&e.thinkingLevel!==`off`;return(0,X.jsxs)(`div`,{className:`model-thinking-capsule`,children:[(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ze,{}),(0,X.jsx)(`span`,{className:`capsule-model-name`,children:l?l.name:c(`selectModel`)}),!o&&l?.vision&&(0,X.jsx)(`span`,{className:`chip-vision`,title:c(`vision`),children:`🖼`})]}),triggerClassName:`capsule-segment capsule-model`,open:d,onOpenChange:f,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:ne}),(0,X.jsx)(`div`,{className:`capsule-divider`}),(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`thinking-pulse-dot ${ae?`on`:``}`}),(0,X.jsx)(`span`,{className:`capsule-thinking-text`,children:e?te(e.thinkingLevel):`—`})]}),triggerClassName:`capsule-segment capsule-thinking`,open:p,onOpenChange:m,align:`left`,direction:`up`,children:F})]})}),K_=[`standard`,`ptc`,`minimal`,`cordis`],q_={standard:`preset.standard`,minimal:`preset.minimal`,code:`preset.code`,reader:`preset.reader`,ask:`preset.ask`},J_={standard:`preset.standardDesc`,minimal:`preset.minimalDesc`,code:`preset.codeDesc`,reader:`preset.readerDesc`,ask:`preset.askDesc`};function Y_(e){return q_[e]??null}function X_(e){return J_[e]??null}function Z_(e,t,n){let r=t===`zh`,i=Y_(e.id),a=X_(e.id);return i&&a?{name:n(i),description:n(a)}:{name:r?e.name??e.id:e.nameEn??e.name??e.id,description:r?e.description:e.descriptionEn??e.description}}function Q_(e){return[...e].sort((e,t)=>{let n=Number.isSafeInteger(e.order)?e.order:K_.indexOf(e.id),r=Number.isSafeInteger(t.order)?t.order:K_.indexOf(t.id),i=n>=0?n:1e3,a=r>=0?r:1e3;return i===a?e.id.localeCompare(t.id):i-a})}var $_=(0,g.memo)(function({preset:e,presets:t,defaultPreset:n,blank:r,conversationId:i,compact:a=!1}){let o=Z(),{locale:s}=Nn(),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(e?.id??n);if((0,g.useEffect)(()=>{d(e?.id??n)},[i,e?.id,n]),t.length===0)return null;let f=e?.locked||!r,p=Q_(t),m=p.find(t=>t.id===e?.id),h=p.find(e=>e.id===u)??m,_=e=>Z_(e,s,o),v=m?_(m):void 0,y=t=>{d(t),l(!1),r&&t!==e?.id&&$({type:`dsh_preset_select`,preset:t})};if(a){let t=v?.description??m?.id??o(`dshPreset`);return(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(H,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:f?`${t}(${o(`dshPresetLocked`)})`:t,children:[v?.name??m?.id??e?.name??o(`dshPreset`),f&&(0,X.jsx)(Te,{style:{marginLeft:3}})]})]}),open:c&&!f,onOpenChange:l,direction:`up`,align:`left`,children:p.map(t=>{let r=_(t);return(0,X.jsxs)(Ht,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??r.description??t.id,onClick:()=>y(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[r.name,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetUser`)}),t.id===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:o(`dshPresetBroken`)})]}),r.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:r.description})]},t.id)})})}return(0,X.jsxs)(`div`,{className:`dsh-presetbar`,"data-testid":`dsh-presetbar`,children:[(0,X.jsxs)(`span`,{className:`dsh-preset-label`,children:[(0,X.jsx)(H,{}),o(`dshPreset`)]}),(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(`span`,{title:v?.description??m?.id??``,children:[v?.name??m?.id??e?.name??`…`,f&&(0,X.jsxs)(`span`,{className:`dsh-preset-lock`,title:o(`dshPresetBlankOnly`),children:[(0,X.jsx)(Te,{}),` `,o(`dshPresetLocked`)]})]}),open:c&&!f,onOpenChange:l,children:p.map(t=>{let r=_(t);return(0,X.jsxs)(Ht,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??r.description??t.id,onClick:()=>y(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[r.name,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetUser`)}),t.id===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:o(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:o(`dshPresetBroken`)})]}),r.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:r.description})]},t.id)})}),!f&&(0,X.jsx)(`span`,{className:`dsh-preset-hint`,title:o(`dshPresetBlankOnly`),children:o(`dshPresetBlankOnly`)}),h?.id===`minimal`&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:o(`dshPresetMinimalNote`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip`,title:o(`dshPresetNewChat`),onClick:()=>{$({type:`new_chat`,preset:h?.id??u}),sr()},children:[(0,X.jsx)(me,{}),` `,o(`dshPresetNewChat`)]})]})}),ev=[`read-only`,`workspace-write-never`,`danger-full-access`],tv=[`read-only`,`workspace-write-never`,`danger-full-access`];function nv(e){return e===`read-only`?`dshPermReadOnly`:e===`danger-full-access`?`dshPermFullAccess`:`dshPermWorkspaceWrite`}function rv(e){return e===`read-only`?`dshPermReadOnlyDesc`:e===`danger-full-access`?`dshPermFullAccessDesc`:`dshPermWorkspaceWriteDesc`}var iv=(0,g.memo)(function({current:e,options:t,defaultPreset:n,conversationId:r,compact:i=!1}){let a=Z(),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(!1);(0,g.useEffect)(()=>{l(!1),s(!1)},[r]);let u=ev.filter(e=>t.some(t=>t.value===e));if(u.length===0)return null;let d=e??n,f=!!e&&!u.includes(e),p=e=>{if(e===`danger-full-access`&&e!==d&&!c){l(!0);return}l(!1),s(!1),e!==d&&$({type:`dsh_permission_set`,preset:e})};if(i){let t=a(f?`dshPermCustom`:nv(d)),r=f?e??t:a(rv(d));return(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ce,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:r,children:[t,d===`danger-full-access`&&(0,X.jsx)(wt,{style:{marginLeft:3}})]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},direction:`up`,align:`left`,children:[u.map(e=>(0,X.jsxs)(Ht,{active:e===d,title:a(rv(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(nv(e)),e===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),e===`danger-full-access`&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPermFullAccessTag`)})]}),(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:a(rv(e))})]},e)),c&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:a(`dshPermConfirmFull`)})]})}return(0,X.jsxs)(`div`,{className:`dsh-presetbar`,"data-testid":`dsh-permissionbar`,children:[(0,X.jsxs)(`span`,{className:`dsh-preset-label`,children:[(0,X.jsx)(ce,{}),a(`dshPerm`)]}),(0,X.jsx)(Vt,{trigger:(0,X.jsxs)(`span`,{title:f?e:a(rv(d)),children:[a(f?`dshPermCustom`:nv(d)),d===`danger-full-access`&&(0,X.jsxs)(`span`,{className:`dd-preset-tag warn`,children:[(0,X.jsx)(wt,{}),` `,a(`dshPermFullAccessTag`)]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},children:u.map(e=>(0,X.jsxs)(Ht,{active:e===d,title:a(rv(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(nv(e)),e===n&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),e===`danger-full-access`&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPermFullAccessTag`)})]}),(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:a(rv(e))})]},e))}),c&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:a(`dshPermConfirmFull`)})]})}),av=R_(),ov=40,sv=220,cv=720,lv=`pi-web-ui:composer-height`,uv=(0,g.memo)(function({streaming:e,planMode:t,messages:n,slashCommands:r,modelState:i,models:a,modelsLoading:o,attachments:s,onRemoveAttachment:c,onAddImageFiles:l,onAddLocalFiles:u,onAddPathAttachment:d,fileSearch:f,onSearchFiles:p,onNotice:m,onSent:h,onManageModels:_,providerKeys:v,defaultModel:y,quickPhrases:b,quickPhrasesEnabled:x,recallDrafts:S,composerLeading:C,composerActions:w,onUiAction:T,dshPermCurrent:E,dshPermOptions:D,dshPermDefault:O,dshPreset:k,dshPresets:A,dshPresetDefault:j,dshBlank:ee,conversationId:M,sessionDraft:te,sessionId:N}){let P=Z(),ne=Za(`ready`),F=Qa(),{locale:re}=Nn(),{openPicker:ie}=Xh(),ae=e=>re!==`zh`&&e.descriptionEn?e.descriptionEn:e.description??``,I=e=>re!==`zh`&&e.argumentHintEn?e.argumentHintEn:e.argumentHint??``,[L,R]=(0,g.useState)(``),[z,oe]=(0,g.useState)(()=>{try{let e=Number(localStorage.getItem(lv));if(Number.isFinite(e)&&e>=ov&&e<=cv)return e}catch{}return null}),B=(0,g.useRef)(null),[H,se]=(0,g.useState)(null),[ce,le]=(0,g.useState)(0),ue=(0,g.useRef)(0),U=(0,g.useRef)(new Map),de=(0,g.useRef)(``),[fe,W]=(0,g.useState)(!1),[pe,G]=(0,g.useState)(void 0),K=(0,g.useRef)(null),me=(0,g.useRef)(null),he=(0,g.useRef)(null),q=(0,g.useRef)(-1),_e=(0,g.useRef)(``),ve=(0,g.useRef)(0);(0,g.useEffect)(()=>{if(!S||S.length===0)return;let e=S.filter(e=>e.text&&e.seq>ve.current);e.length!==0&&(ve.current=e[e.length-1].seq,se(null),R(t=>{let n=e.reduce((e,t)=>Xg(e,t.text),t);return de.current=n,n}),q.current=-1,_e.current=``,requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}))},[S]),(0,g.useEffect)(()=>(ir(e=>{se(null),R(t=>{let n=Xg(t,e);return de.current=n,n}),q.current=-1,_e.current=``,requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)})}),()=>ir(null)),[]),(0,g.useEffect)(()=>(or(()=>{av||requestAnimationFrame(()=>{K.current?.focus()})}),()=>or(null)),[]);let ye=(0,g.useRef)(``);ye.current=L,(0,g.useEffect)(()=>(er(e=>{{let t=e.trim(),n=new Set([`.`,`*`,`+`,`?`,`^`,`$`,`{`,`}`,`(`,`)`,`|`,`[`,`]`,`\\`]),r=t.split(``).map(e=>n.has(e)?`\\`+e:e).join(``),i=RegExp(`(^|[\\s(("'“‘[【])`+r+`(?=[\\s,.;:!?,。!?)\\]】」]|$)`);if(t&&i.test(ye.current))return}let t=K.current;if(!t){R(t=>{let n=t+(t&&!t.endsWith(` `)?` `:``)+e;return de.current=n,n});return}let n=t.selectionStart??ye.current.length,r=t.selectionEnd??ye.current.length,i=ye.current,a=(n>0&&!/[\s([{]$/.test(i.slice(0,n))?` `:``)+e,o=i.slice(0,n)+a+i.slice(r);de.current=o,R(o);let s=n+a.length;requestAnimationFrame(()=>{t.focus(),t.selectionStart=t.selectionEnd=s})}),()=>er(null)),[]),(0,g.useEffect)(()=>(tr(e=>{R(t=>{let n=new Set([`.`,`*`,`+`,`?`,`^`,`$`,`{`,`}`,`(`,`)`,`|`,`[`,`]`,`\\`]),r=e.split(``).map(e=>n.has(e)?`\\`+e:e).join(``),i=RegExp(`(^|\\s)`+r+`(?:\\s|$)`,`g`),a=t.replace(i,(e,t)=>t===` `?` `:``);return a=a.replace(/ {2,}/g,` `).trim(),de.current=a,a})}),()=>tr(null)),[]);let be=2e4,J=!F&&N?`${M??``}${N}`:null,Se=J&&N?`pi-web-ui:composer-draft:${N}`:null,Ce=(0,g.useRef)(``),we=(0,g.useRef)(0),Te=(0,g.useRef)(!1),Ee=(0,g.useRef)(0),Oe=(0,g.useRef)(null),ke=(0,g.useRef)(null),Ae=(0,g.useRef)(null),je=V_(),Me=e=>{try{let t=localStorage.getItem(e);if(!t)return null;let n=JSON.parse(t);return typeof n.text!=`string`||!n.text||typeof n.ts!=`number`?null:{text:n.text.slice(0,be),ts:n.ts}}catch{return null}},Ne=(e,t,n,r)=>{let i=n.slice(0,be);try{i.trim()?localStorage.setItem(t,JSON.stringify({text:i,ts:r})):localStorage.removeItem(t)}catch{}$({type:`draft_update`,sessionId:e,text:i,ts:r})},Pe=()=>{Oe.current&&=(clearTimeout(Oe.current),null),Te.current&&J&&Se&&N&&Xe&&Ne(N,Se,Ce.current,we.current)},Fe=e=>{if(Ce.current=e,Te.current=!0,we.current=Date.now(),Se){let t=e.slice(0,be);try{t.trim()?localStorage.setItem(Se,JSON.stringify({text:t,ts:we.current})):localStorage.removeItem(Se)}catch{}}if(J&&N&&Xe){Oe.current&&clearTimeout(Oe.current);let e=N,t=Se,n=we.current,r=J;Oe.current=setTimeout(()=>{Oe.current=null,r===ke.current&&t&&Ne(e,t,Ce.current,n)},2e3)}},Ie=(e,t)=>{q.current=-1,R(e),ze(e,t),Fe(e)};(0,g.useEffect)(()=>{let e=J,t=N,n=Se;return()=>{Oe.current&&=(clearTimeout(Oe.current),null),Te.current&&Ce.current.trim()?(e&&t&&n&&Ne(t,n,Ce.current,we.current),Ae.current=Ce.current):Ae.current=null}},[J]),(0,g.useEffect)(()=>{ke.current=J;let e=Ae.current;Ae.current=null;let t=Se?Me(Se):null,r=!!(te&&te.text?.trim()&&te.ts>0||t&&t.text?.trim());e!==null&&t_(e,n.length,r)&&Se&&N?(Te.current=!0,Ee.current=Date.now(),Ce.current=e,we.current=Ee.current,R(e),Ne(N,Se,e,we.current)):(Te.current=!1,Ee.current=0,Ce.current=``,we.current=0,R(``)),se(null),q.current=-1},[J]);let Le=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=n.length===0,t=Le.current!==J;Le.current=J,ne&&e&&(!av||t)&&requestAnimationFrame(()=>{K.current?.focus()})},[J,n.length,ne]),(0,g.useEffect)(()=>{if(!J||!Se||Te.current||Ce.current!==``)return;let e=Zg(te&&te.text?{text:te.text.slice(0,be),ts:te.ts}:null,Me(Se),Ee.current);e&&(Ee.current=e.ts,Ce.current=e.text,we.current=e.ts,R(e.text),ze(e.text,null))});let Re={builtin:P(`slashBuiltin`),extension:P(`slashExtension`),prompt:P(`slashPrompt`),skill:P(`slashSkill`),plugin:P(`slashPlugin`)},ze=(e,t)=>{de.current=e;let n=e.match(/^\/([^\s]*)$/);if(n&&ne){let e=O_(r,n[1].toLowerCase());se(e.length>0?{kind:`slash`,items:e}:null),le(0);return}if(t===null||!ne){se(null);return}let i=I_(e,t);if(!i){se(null);return}let a=[];try{a=mc()}catch{a=[]}let o=++ue.current,s=e,c=i.start,l=i.query,u=c+1+l.length,d=a.map(e=>({id:e.id,label:e.label,run:()=>{let t;try{t=hc(e.id)?.search}catch{t=void 0}return typeof t==`function`?t(l):Promise.resolve([])}}));l&&typeof p==`function`&&d.push({id:`host:files`,label:P(`openFiles`),run:()=>Be(l)}),Un();let f=A_(P(`browserControl`),Hn(),l);if(d.push({id:`host:pages`,label:P(`browserControl`),run:()=>Promise.resolve(f)}),d.length===0){se(null);return}let m=N_(P(`slashSkill`),r,l,15,ae),h=P_({pages:f,skills:m},l,30),g=!1;h.length>0&&(g=!0,se({kind:`at`,start:c,end:u,items:h}),le(0)),Promise.allSettled(d.map(e=>Promise.race([e.run(),new Promise((e,t)=>setTimeout(()=>t(Error(`at-mention timeout`)),2e3))]))).then(e=>{if(ue.current!==o||de.current!==s)return;let t=[],n=[],r=[];e.forEach((e,i)=>{e.status===`fulfilled`&&(d[i].id===`host:pages`&&Array.isArray(e.value)?t.push(...e.value):d[i].id===`host:files`?n.push(...j_(d[i].label,e.value)):r.push(...M_(d[i].id,d[i].label,e.value)))});let i=P_({pages:t,skills:m,files:n,plugins:r},l,30);se(i.length>0?{kind:`at`,start:c,end:u,items:i}:null),!g&&i.length>0&&le(0)})},Be=e=>{if(typeof p!=`function`)return Promise.resolve([]);let t=U_();return new Promise(n=>{U.current.set(t,n);try{p(t,e)}catch{U.current.delete(t),n([]);return}setTimeout(()=>{U.current.get(t)===n&&(U.current.delete(t),n([]))},3e3)})};(0,g.useEffect)(()=>{if(!f||!f.ok)return;let e=U.current.get(f.reqId);e&&(U.current.delete(f.reqId),e(f.results??[]))},[f]);let Ve=e=>ze(e,null);(0,g.useEffect)(()=>{(he.current?.querySelector(`.slash-item.active`))?.scrollIntoView({block:`nearest`})},[ce,H]);let He=e=>{let t=H?.kind===`slash`?H.items:[],n=e??t[ce%Math.max(t.length,1)];if(!n){se(null);return}let r=L.match(/^\/([^\s]*)([\s\S]*)$/),i=r?r[2]:``,a=`/${n.name} ${i}`;de.current=a,R(a),Fe(a),se(null),K.current?.focus()},Ue=(e,t)=>{let n=H?.kind===`at`?H:null,r=n?.items??[],i=e??r[ce%Math.max(r.length,1)],a=t??n?.start;if(!i||a===void 0){se(null);return}let o=K.current,s=o?o.selectionStart??L.length:L.length,c=n?.end!==void 0&&n.end>=a?n.end:s,l=i.attachments??[],u=i.text??i.title,f=l.length>0&&!u.startsWith(`@`)?`@${u} `:`${u} `,p=`${L.slice(0,a)}${f}${L.slice(c)}`;de.current=p,R(p),Fe(p),se(null);for(let e of l)try{d?.({path:e.path,name:e.name??e.path.split(`/`).pop()??e.path,...e.mode?{mode:e.mode}:{mode:`reference`},...typeof e.isDir==`boolean`?{isDir:e.isDir}:{},...e.lines?{lines:e.lines}:{},silent:!0})}catch{}requestAnimationFrame(()=>{let e=K.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=a+f.length)})},We=()=>H?.kind===`slash`?H.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===ce?` active`:``}`,onMouseEnter:()=>le(t),onClick:()=>Y(e),children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Re[e.source]}),(0,X.jsxs)(`span`,{className:`slash-desc`,children:[ae(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:I(e)})]})]},e.name)):null,Ge=()=>H?.kind===`at`?H.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===ce?` active`:``}`,onMouseEnter:()=>le(t),onClick:()=>Y(e),title:e.hint??e.title,children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`@`,e.title]}),(0,X.jsx)(`span`,{className:`slash-source ${e.providerId===`host:skills`?`skill`:`plugin`}`,children:e.providerLabel}),e.hint&&(0,X.jsx)(`span`,{className:`slash-desc`,children:e.hint})]},`${e.providerId}:${e.title}:${t}`)):null,Y=e=>{H&&(H.kind===`slash`?He(e):Ue(e,H.start))},Ke=async()=>{let e=[...n].reverse().find(e=>e.role===`assistant`&&e.content.some(e=>e.type===`text`&&e.text))?.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
360
+ `);if(!e){m(`warning`,P(`slashCopyEmpty`));return}await Ku(e)?m(`info`,P(`slashCopied`)):m(`error`,P(`slashCopyFailed`))},qe=e=>{if(!e||e.length===0){m(`warning`,P(`foldersNotSupported`));return}let t=Array.from(e).filter(e=>um(e.type)),n=Array.from(e).filter(e=>!um(e.type)),r=Ye();t.length>0&&r?m(`warning`,r):t.length>0&&l(t),n.length>0&&u(n)},Je=e=>{let t=p_(e.clipboardData?.items,e.clipboardData?.files);t.length!==0&&(e.preventDefault(),qe(t))},Ye=()=>{let e=i?.model;if(!e?.id)return null;let t=a.find(t=>t.id===e.id);return t&&t.vision===!1?P(`modelNoVision`,{name:t.name}):null},Xe=ne,Ze=(0,g.useRef)(L);(0,g.useEffect)(()=>{Ze.current=L},[L]),(0,g.useEffect)(()=>{Ve(Ze.current)},[r]);let[Qe,$e]=(0,g.useState)(null),et=e=>{let t=Qe;if($e(null),t===null)return;let n=r_(Ze.current,t,e);n!==null&&(se(null),de.current=n,R(n)),requestAnimationFrame(()=>K.current?.focus())};(0,g.useEffect)(()=>{let e=e=>{let t=e.detail;if(typeof t==`string`){if(n_(Ze.current,t)){$e(t);return}se(null),de.current=t,R(t),K.current?.focus()}};return window.addEventListener(`pi-web:fill`,e),()=>window.removeEventListener(`pi-web:fill`,e)},[]),(0,g.useEffect)(()=>{if(!fe&&Qe===null)return;let e=e=>{e.key===`Escape`&&(Qe===null?W(!1):($e(null),requestAnimationFrame(()=>K.current?.focus())))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[fe,Qe]);let tt=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=K.current,t=tt.current;if(!e||!t)return;let n=e.closest(`main`)?.querySelector(`.messages`),r=t.getBoundingClientRect().height,i=n?.scrollTop??0;e.style.height=`auto`;let a=z==null?sv:cv;e.style.maxHeight=`${a}px`;let o=Math.min(Math.max(e.scrollHeight,z??0),a);e.style.height=`${o}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`,n&&(n.scrollTop=i+(t.getBoundingClientRect().height-r))},[L,z]);let nt=(0,g.useRef)(null),rt=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=nt.current,t=rt.current,n=document.documentElement;if(!e&&!t){n.style.removeProperty(`--quick-row-h`);return}let r=()=>{let r=e?e.offsetHeight:0,i=t?t.offsetHeight:0,a=e&&t?6:0;n.style.setProperty(`--quick-row-h`,`${r+a+i}px`)};r();let i=new ResizeObserver(r);return e&&i.observe(e),t&&i.observe(t),()=>{i.disconnect(),n.style.removeProperty(`--quick-row-h`)}},[s.length,x,b.length]);let it=()=>s.map(e=>e.mode===`quote`?{path:``,mode:`quote`,quote:e.quote}:e.imageData?{path:``,imageData:e.imageData,mimeType:e.mimeType,name:e.name}:e.fileData?{path:``,fileData:e.fileData,mimeType:e.mimeType,name:e.name,size:e.size}:{path:e.path,mode:e.mode,...e.lines?{lines:e.lines}:{},...e.mode===`page`?{name:e.name}:{},...e.mode===`conversation`?{name:e.name,...e.conversationId?{conversationId:e.conversationId}:{},...e.sessionPath?{sessionPath:e.sessionPath}:{}}:{}}),at=(e=!1)=>{let t=L.trim(),n=s.length>0;if(t||n){if(!Xe){m(`error`,P(`netDisconnected`));return}if(t===`/help`){let e=K.current?.closest(`.inputbox`)?.getBoundingClientRect();G(e?.width),W(!0),R(``),K.current?.focus();return}if(t===`/copy`){R(``),K.current?.focus(),Ke();return}if($({type:`prompt`,text:t,queue:e,attachments:it()})){if(t&&w_(t),q.current=-1,_e.current=``,R(``),Se)try{localStorage.removeItem(Se)}catch{}Oe.current&&=(clearTimeout(Oe.current),null),Te.current=!1,Ee.current=Date.now(),Ce.current=``,we.current=0,h();let e=i?.model;e&&Uh(`${e.provider}/${e.id}`),K.current?.focus()}else m(`error`,P(`netDisconnected`))}},ot=(e,t=!1)=>{let n=e.trim();if(n){if(!Xe){m(`error`,P(`netDisconnected`));return}if($({type:`prompt`,text:n,queue:t,attachments:it()})){n&&w_(n),q.current=-1,_e.current=``,Pe(),h();let e=i?.model;e&&Uh(`${e.provider}/${e.id}`),av||K.current?.focus()}else m(`error`,P(`netDisconnected`))}},st=e=>{if(!je.isImeKey(e.nativeEvent)){if(H&&H.items.length>0){let t=H.items.length;switch(e.key){case`ArrowDown`:e.preventDefault(),le(e=>(e+1)%t);return;case`ArrowUp`:e.preventDefault(),le(e=>(e-1+t)%t);return;case`Tab`:case`Enter`:e.preventDefault(),Y();return;case`Escape`:e.preventDefault(),se(null);return}}if(e.key===`Backspace`&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=K.current;if(t&&t.selectionStart===t.selectionEnd&&t.selectionStart>0){let n=t.selectionStart,r=z_(L.slice(0,n),n,s);if(r&&r.tokenStart>=0&&r.tokenStart<n){e.preventDefault();let t=r.tokenStart,i=L.slice(0,t)+L.slice(n);de.current=i,R(i),requestAnimationFrame(()=>{K.current&&(K.current.selectionStart=K.current.selectionEnd=t)});let a=r.attachment;a&&c(a.key??(a.mode===`conversation`?`conv|${a.conversationId??``}|${a.sessionPath??``}`:a.path));return}}}if(e.key===`ArrowUp`||e.key===`ArrowDown`){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=K.current;if(!t)return;let n=e.key===`ArrowUp`,r=f_(t);if(n&&!r.first||!n&&!r.last||!n&&q.current===-1)return;let i=S_();if(i.length===0)return;if(e.preventDefault(),n){if(q.current===-1){_e.current=L;let e=i.length-1;q.current=e;let t=i[e];R(t),Ve(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else if(q.current>0){let e=q.current-1;q.current=e;let t=i[e];R(t),Ve(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}}else{let e=q.current+1;if(e<i.length){q.current=e;let t=i[e];R(t),Ve(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else{q.current=-1;let e=_e.current;R(e),Ve(e),requestAnimationFrame(()=>{let t=K.current;t&&(t.selectionStart=t.selectionEnd=e.length)})}}return}if(e.key===`Escape`&&q.current!==-1){e.preventDefault();let t=_e.current;q.current=-1,R(t),Ve(t),requestAnimationFrame(()=>{let e=K.current;e&&(e.selectionStart=e.selectionEnd=t.length)});return}if(e.key===`Enter`){if(av&&!e.shiftKey&&!(e.ctrlKey||e.metaKey))return;e.shiftKey||(e.preventDefault(),at())}}},ct=Xe&&(L.trim()!==``||s.length>0),lt=(0,g.useMemo)(()=>ga((w??[]).filter(e=>e.source!==`host`&&!e.hidden)),[w]),ut=(0,g.useMemo)(()=>(C??[]).filter(e=>e.source!==`host`&&!e.hidden),[C]),dt=w!==void 0,ft=(0,g.useMemo)(()=>ga((w??[]).filter(e=>!e.hidden)),[w]),pt=e=>{if(e.kind===`select`&&e.options?.length){let t=e.options.some(t=>t.value===e.value)?e.value:e.options[0].value;return(0,X.jsx)(`select`,{className:`composer-plugin-select`,title:e.hint||e.label,"aria-label":e.label,value:t,onChange:t=>T?.(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id)}let t=e.icon===`mic`?(0,X.jsx)(xe,{}):e.icon===`camera`?(0,X.jsx)(mt,{}):e.icon||e.label;return(0,X.jsx)(`button`,{type:`button`,className:`btn composer-plugin-action`,title:e.hint||e.label,"aria-label":e.label,onClick:()=>T?.(e),children:t},e.id)},ht=()=>(0,X.jsx)(`div`,{className:`inputbox-actions`,children:e?ct?(0,X.jsxs)(`div`,{className:`split-send${F?` single`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`split-queue`,title:P(`supplementTip`),"aria-label":P(`queueFollowTag`),onClick:()=>at(!0),children:(0,X.jsx)(De,{})}),!F&&(0,X.jsx)(`button`,{type:`button`,className:`split-steer`,title:P(`steerTip`),"aria-label":P(`queueSteerTag`),onClick:()=>at(),children:(0,X.jsx)(vt,{})})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn stop`,title:P(`stopAgent`),onClick:()=>$({type:`abort`}),children:(0,X.jsx)(V,{})}):(0,X.jsx)(`button`,{type:`button`,className:`btn send`,title:P(`sendTip`),disabled:!ct,onClick:()=>at(),children:(0,X.jsx)(vt,{})})}),_t={"host:composer-upload":(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:P(`uploadFile`),disabled:!Xe,onClick:()=>me.current?.click(),children:(0,X.jsx)(ge,{})}),"host:composer-templates":(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:P(`tpl.openPicker`),onClick:ie,children:(0,X.jsx)(gt,{})}),"host:composer-model":(0,X.jsx)(G_,{only:`model`,state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,defaultModel:y,compact:!0}),"host:composer-thinking":(0,X.jsx)(G_,{only:`thinking`,state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,compact:!0}),"host:composer-dsh-perm":D&&D.length>0&&O!==void 0?(0,X.jsx)(iv,{compact:!0,current:E??null,options:D,defaultPreset:O,conversationId:M??``}):null,"host:composer-dsh-preset":A&&A.length>0&&j!==void 0?(0,X.jsx)($_,{compact:!0,preset:k??null,presets:A,defaultPreset:j,blank:ee??!1,conversationId:M??``}):null,"host:composer-send":ht()},yt=e=>e.source===`host`?(0,X.jsx)(g.Fragment,{children:_t[e.id]??null},e.id):pt(e);return(0,X.jsxs)(`div`,{ref:tt,className:`inputbar`,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),qe(e.dataTransfer?.files??null)},children:[s.length>0&&(0,X.jsxs)(`div`,{className:`attach-row`,ref:nt,children:[s.map(e=>e.mode===`quote`&&e.quote?(0,X.jsx)(hd,{quote:e.quote,onRemove:()=>c(e.key??``)},e.key):(0,X.jsxs)(`span`,{className:`attach-chip ${e.imageData?`image`:e.fileData?`file`:e.mode}`,title:e.imageData?P(`attachImage`,{name:e.name}):e.fileData?P(`attachFile`,{name:e.name}):e.isDir?P(`folderRef`,{path:e.path}):e.mode===`page`?P(`attachPage`,{name:e.name}):e.mode===`conversation`?P(`attachConversation`,{name:e.name}):e.mode===`reference`?P(`refOnly`,{path:e.path}):e.mode===`lines`&&e.lines?P(`attachLines`,{path:e.path,start:e.lines.start,end:e.lines.end}):P(`attachContent`,{path:e.path}),children:[e.imageData?`🖼`:e.fileData?`📄`:e.isDir?`📁`:e.mode===`page`?`🌐`:e.mode===`conversation`?`💬`:e.mode===`reference`?`🔗`:`📎`,e.name,e.mode===`lines`&&e.lines&&(0,X.jsxs)(`span`,{className:`attach-range`,children:[`L`,e.lines.start,`-`,e.lines.end]}),(0,X.jsx)(`button`,{type:`button`,className:`attach-remove`,title:P(`removeAttachment`),onClick:()=>c(e.key??(e.mode===`conversation`?`conv|${e.conversationId??``}|${e.sessionPath??``}`:e.path)),children:`×`})]},e.key??(e.mode===`conversation`?`conv|${e.conversationId??``}|${e.sessionPath??``}`:`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`))),(0,X.jsx)(`span`,{className:`attach-hint`,children:P(`attachHint`)})]}),H&&H.items.length>0&&(0,X.jsxs)(`div`,{className:`slash-menu`,role:`listbox`,ref:he,"aria-label":H.kind===`slash`?P(`slashCommands`):P(`atMentions`),"data-menu-kind":H.kind,children:[(0,X.jsxs)(`div`,{className:`slash-menu-hint`,children:[(0,X.jsx)(`span`,{children:H.kind===`slash`?P(`slashMenuHint`):P(`atMenuHint`)}),(0,X.jsx)(`span`,{className:`slash-menu-close`,onClick:()=>se(null),children:`Esc`})]}),H.kind===`slash`?We():Ge()]}),Qe!==null&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>et(`cancel`),children:(0,X.jsxs)(`div`,{className:`slash-help`,role:`dialog`,"aria-modal":`true`,"aria-label":P(`tpl.confirmFillTitle`),style:{maxWidth:420},onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`div`,{className:`slash-help-head`,children:(0,X.jsx)(`span`,{children:P(`tpl.confirmFillTitle`)})}),(0,X.jsxs)(`div`,{className:`slash-help-body`,style:{padding:`12px 16px`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 14px`,lineHeight:1.5},children:P(`tpl.confirmFillDesc`)}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,flexWrap:`wrap`},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,autoFocus:!0,onClick:()=>et(`cancel`),children:P(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>et(`append`),children:P(`tpl.confirmFillAppend`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>et(`overwrite`),children:P(`tpl.confirmFillOverwrite`)})]})]})]})}),fe&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>W(!1),children:(0,X.jsxs)(`div`,{className:`slash-help`,style:pe?{width:pe}:void 0,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`slash-help-head`,children:[(0,X.jsxs)(`span`,{children:[`⚡ `,P(`slashHelpTitle`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>W(!1),children:P(`close`)})]}),(0,X.jsx)(`div`,{className:`slash-help-body`,children:r.length===0?(0,X.jsx)(`div`,{className:`slash-help-empty`,children:P(`slashLoading`)}):r.map(e=>(0,X.jsxs)(`div`,{className:`slash-help-row`,children:[(0,X.jsxs)(`span`,{className:`slash-help-cmd`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Re[e.source]}),(0,X.jsxs)(`span`,{className:`slash-help-desc`,children:[ae(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:I(e)})]})]},e.name))})]})}),x&&b.length>0&&(0,X.jsx)(`div`,{className:`quick-row`,"aria-label":P(`quickPhrases`),ref:rt,children:b.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`quick-chip`,title:`${P(`quickPhrasesTip`,{text:e})}(${P(`quickPhrasesSendTip`)})`,disabled:!Xe,onClick:()=>ot(e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),ot(e,!0)},children:e},e))}),(0,X.jsxs)(`div`,{className:`inputbox`,"data-pi-anchor":`composer`,children:[(0,X.jsx)(`div`,{className:`composer-resize`,title:P(`composerResize`),"aria-label":P(`composerResize`),role:`separator`,"aria-orientation":`horizontal`,"aria-valuenow":Math.round(z??sv),"aria-valuemin":ov,"aria-valuemax":cv,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId);let t=K.current?.getBoundingClientRect().height;B.current={startY:e.clientY,startH:typeof t==`number`&&Number.isFinite(t)?t:z??sv,next:null}},onPointerMove:e=>{let t=B.current;if(!t)return;let n=Math.min(cv,Math.max(ov,t.startH+(t.startY-e.clientY)));t.next=n,oe(n)},onPointerUp:()=>{let e=B.current?.next;if(B.current=null,e!=null)try{localStorage.setItem(lv,String(Math.round(e)))}catch{}},onPointerCancel:()=>{B.current=null},onDoubleClick:()=>{oe(null);try{localStorage.removeItem(lv)}catch{}}}),(0,X.jsx)(`input`,{ref:me,type:`file`,multiple:!0,hidden:!0,onChange:e=>{qe(e.target.files),e.target.value=``}}),(0,X.jsx)(`textarea`,{ref:K,value:L,rows:1,placeholder:P(Xe?e?F?`placeholderStreamingQueued`:`placeholderStreaming`:t?`placeholderPlanMode`:`placeholderIdle`:`placeholderConnecting`),disabled:!Xe,onChange:e=>{Ie(e.target.value,e.target.selectionStart??e.target.value.length)},onSelect:e=>{if(H?.kind===`at`){let t=e.target.selectionStart;(t<H.start||t>H.end)&&se(null)}},onCompositionEnd:je.onCompositionEnd,onBlur:Pe,onKeyDown:st,onPaste:Je}),t&&(0,X.jsxs)(`button`,{type:`button`,style:{display:`inline-flex`,alignItems:`center`,gap:4,fontSize:11,color:`var(--accent, #38bdf8)`,background:`var(--accent-soft, rgba(56, 189, 248, 0.1))`,padding:`2px 8px`,borderRadius:12,position:`absolute`,right:12,top:8,cursor:`pointer`,border:`1px solid var(--border, rgba(255, 255, 255, 0.1))`,zIndex:2},onClick:()=>$({type:`set_plan_mode`,enabled:!1}),title:P(`planModeTip`),children:[`📋 `,P(`planModeBadge`),` `,(0,X.jsx)(`span`,{style:{marginLeft:2,opacity:.7},children:`✕`})]}),(0,X.jsx)(`div`,{className:`composer-tools`,children:dt?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[ut.map(pt),ft.start.map(yt)]}),ft.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:ft.center.map(yt)}),(0,X.jsx)(`div`,{className:`composer-tools-right`,children:ft.end.map(yt)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[ut.map(pt),(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:P(`uploadFile`),disabled:!Xe,onClick:()=>me.current?.click(),children:(0,X.jsx)(ge,{})}),lt.start.map(pt),(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:P(`tpl.openPicker`),onClick:ie,children:(0,X.jsx)(gt,{})}),(0,X.jsx)(G_,{state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,defaultModel:y,compact:!0}),D&&D.length>0&&O!==void 0&&(0,X.jsx)(iv,{compact:!0,current:E??null,options:D,defaultPreset:O,conversationId:M??``}),A&&A.length>0&&j!==void 0&&(0,X.jsx)($_,{compact:!0,preset:k??null,presets:A,defaultPreset:j,blank:ee??!1,conversationId:M??``})]}),lt.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:lt.center.map(pt)}),(0,X.jsxs)(`div`,{className:`composer-tools-right`,children:[lt.end.map(pt),ht()]})]})})]})]})}),dv=(0,g.memo)(function({goal:e,models:t,modelsLoading:n,activeConversationId:r,uiGoalbarActions:i,onUiAction:a}){let o=Z(),{locale:s}=Nn(),c=s!==`zh`&&e.statusEn?e.statusEn:e.status||``,l=s!==`zh`&&e.wizard?.statusEn?e.wizard.statusEn:e.wizard?.status||``,u=Qa(),d=!e.conversationId||e.conversationId===r,f=e.goal!==null&&d,p=d?e.roles?.executor:void 0,m=p?.convId,h=p?.activity?s!==`zh`&&p.activityEn?p.activityEn:p.activity:p?.streaming?`…`:void 0,_=e.locked&&e.maxRounds>0?e.maxRounds:0,v=_>0?s===`zh`?`第 ${e.round}/${_} 轮`:`Round ${e.round}/${_}`:`${o(`goalBarRound`,{n:e.round})}${e.locked?` · ${o(`goalBarUnlimitedShort`)}`:``}`,y=(e.usage?.inputTokens??0)+(e.usage?.outputTokens??0),b=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`,x=!u&&e.execModel===void 0,[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(e.reviewModel??``),[E,D]=(0,g.useState)(e.maxRounds),[O,k]=(0,g.useState)(e.locked),[A,j]=(0,g.useState)(e.execModel??``),[ee,M]=(0,g.useState)(!1),[te,N]=(0,g.useState)(!1),[ne,F]=(0,g.useState)(!1),[re,ie]=(0,g.useState)(!1),[I,L]=(0,g.useState)(!0);(0,g.useEffect)(()=>{T(e.reviewModel??``),D(e.maxRounds||0),k(e.locked),j(e.execModel??``)},[e.goal,e.reviewModel,e.maxRounds,e.locked,e.execModel]),(0,g.useEffect)(()=>{ee&&t.length===0&&!re&&!n&&(ie(!0),$({type:`list_models`}))},[ee,t.length,re,n]),(0,g.useEffect)(()=>{t.length>0&&ie(!1)},[t.length]);let R=()=>w?t.find(e=>e.id===w)?.name??w:o(`goalBarUseMainModel`),z=()=>A?t.find(e=>e.id===A)?.name??A:o(`goalBarUseMainModel`),B=()=>{let e=S.trim();e&&($({type:`set_goal`,goal:e,...w?{reviewModel:w}:{},maxRounds:E,locked:O,...A?{execModel:A}:{}}),C(``),L(!1))},H=()=>{let e=S.trim();$({type:`set_plan_mode`,enabled:!0}),e&&($({type:`prompt`,text:e}),C(``))},se=()=>{let e=S.trim();e&&($({type:`start_goal_wizard`,text:e,...w?{wizardModel:w}:{},maxRounds:E,locked:O}),C(``),L(!1))},ce=i===void 0?[`host:goal-pill`,`host:goal-set`,`host:goal-wizard`,`host:goal-plan`,`host:goal-lock`,`host:goal-collapse`,`host:goal-model`,`host:goal-execmodel`,`host:goal-rounds`,`host:goal-openrole`,`host:goal-clear`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),le=e=>{let t=new Set(e);return ce.filter(e=>t.has(e.id)||e.source!==`host`)},ue=(e,t)=>{let n=ce.find(t=>t.id===e);return n?.labelExplicit?n.label:t},U={"host:goal-pill":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-hint`,title:o(`goalBarPlaceholder`),onClick:()=>L(!1),children:[(0,X.jsx)(oe,{}),` `,(0,X.jsx)(`span`,{children:ue(`host:goal-pill`,o(`goalBarTitle`))})]}),"host:goal-set":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn`,disabled:!S.trim(),onClick:B,children:ue(`host:goal-set`,o(`goalBarSet`))}),"host:goal-wizard":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn action wizard`,disabled:!S.trim(),title:o(`goalWizardTip`),onClick:se,children:ue(`host:goal-wizard`,o(`goalWizardBtn`))}),"host:goal-plan":u?null:(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn action plan`,disabled:!S.trim(),title:o(`planActionTip`),onClick:H,children:ue(`host:goal-plan`,o(`planActionBtn`))}),"host:goal-lock":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(O?`goalBarLocked`:`goalBarUnlocked`),onClick:()=>k(e=>($({type:`set_goal_prefs`,locked:!e}),!e)),children:O?(0,X.jsx)(Te,{}):(0,X.jsx)(ae,{})}),"host:goal-collapse":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarClear`),onClick:()=>L(!0),children:(0,X.jsx)(ct,{})}),"host:goal-model":u?(0,X.jsx)(`p`,{className:`goalbar-dsh-note`,children:o(`dshNoReviewModel`)}):(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:`${o(`goalBarReviewModel`)}: ${R()}`,children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${ue(`host:goal-model`,o(`goalBarReviewModel`))}:`}),(0,X.jsx)(`b`,{children:R()})]}),open:ee,onOpenChange:M,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarReviewModel`)}),(re||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!re&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(Ht,{active:w===``,onClick:()=>{T(``),M(!1),$({type:`set_goal_prefs`,reviewModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(Ht,{active:w===e.id,onClick:()=>{T(e.id),M(!1),$({type:`set_goal_prefs`,reviewModel:e.id})},children:(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:e.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:e.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:e.id.split(`/`).slice(1).join(`/`)})]})]})},e.id)),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`list_models`}),children:o(`refreshModels`)})]}),"host:goal-rounds":(0,X.jsxs)(`label`,{className:`goalbar-round`,title:o(`goalBarMaxRoundsTip`),children:[(0,X.jsx)(`span`,{children:ue(`host:goal-rounds`,o(`goalBarMaxRounds`))}),(0,X.jsx)(`input`,{type:`number`,min:0,step:1,value:E,placeholder:o(`goalBarUnlimitedShort`),onChange:e=>{let t=parseInt(e.target.value,10);if(Number.isNaN(t)||t<0){D(0);return}D(t)},onBlur:()=>$({type:`set_goal_prefs`,maxRounds:E}),onKeyDown:e=>{e.key===`Enter`&&($({type:`set_goal_prefs`,maxRounds:E}),e.target.blur())}})]}),"host:goal-execmodel":u?null:(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:`${o(`goalBarExecModel`)}: ${z()} · ${o(`goalBarExecModelTip`)}`,children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${ue(`host:goal-execmodel`,o(`goalBarExecModel`))}:`}),(0,X.jsx)(`b`,{children:z()})]}),open:te,onOpenChange:N,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarExecModel`)}),(re||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!re&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(Ht,{active:A===``,onClick:()=>{j(``),N(!1),$({type:`set_goal_prefs`,execModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(Ht,{active:A===e.id,onClick:()=>{j(e.id),N(!1),$({type:`set_goal_prefs`,execModel:e.id})},children:(0,X.jsxs)(`span`,{className:`dd-model-cell`,children:[(0,X.jsx)(`span`,{className:`dd-model-name`,children:e.name}),(0,X.jsxs)(`span`,{className:`dd-model-meta`,children:[(0,X.jsx)(`span`,{className:`dd-model-provider`,children:e.provider}),(0,X.jsx)(`span`,{className:`dd-model-id`,children:e.id.split(`/`).slice(1).join(`/`)})]})]})},e.id))]})},de=(e.wizard?.active??!1)&&d;if(de)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${de?`wizard`:``}`,children:(0,X.jsxs)(`div`,{className:`goalbar-active-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:(0,X.jsx)(`span`,{className:`goalbar-spin`,children:`🔍`})}),(0,X.jsxs)(`span`,{className:`goalbar-text`,title:e.wizard?.draft??``,children:[o(`goalWizardRunning`),`: `,e.wizard?.draft]}),(0,X.jsxs)(`span`,{className:`goalbar-chip reviewing`,children:[o(`goalBarRound`,{n:(e.wizard?.step??0)+1}),` / `,e.wizard?.maxSteps??6]}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:l||o(`goalBarReviewing`)}),ag(le([`host:goal-clear`]),{...U,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),onClick:()=>{$({type:`clear_goal`}),L(!0)},children:(0,X.jsx)(P,{})})},a)]})});if(f)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${e.reviewing?`reviewing`:``}`,children:(0,X.jsxs)(`div`,{className:`goalbar-active-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:e.reviewing?(0,X.jsx)(`span`,{className:`goalbar-spin`,children:`◌`}):`🎯`}),(0,X.jsx)(`span`,{className:`goalbar-text`,title:e.goal??``,children:e.goal}),e.reviewing?(0,X.jsxs)(`span`,{className:`goalbar-chip reviewing`,children:[e.phase===`executing`?o(`goalBarExecuting`):o(`goalBarReviewing`),` `,v]}):(0,X.jsx)(`span`,{className:`goalbar-chip ${e.verdict===`pass`?`pass`:e.verdict===`fail`?`fail`:e.verdict===`blocked`?`blocked`:``}`,children:e.verdict===`pass`?o(`goalBarPassed`):e.verdict===`fail`?o(`goalBarFailed`):e.verdict===`blocked`?o(`goalBarBlocked`):`${o(`goalBarRound`,{n:e.round||1})} · ${e.locked?o(`goalBarLocked`):o(`goalBarUnlocked`)}`}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:c}),h&&(0,X.jsxs)(`span`,{className:`goalbar-detail`,title:p?.convId,children:[`· `,h]}),y>0&&(0,X.jsxs)(`span`,{className:`goalbar-detail`,title:`${e.usage?.inputTokens??0} in / ${e.usage?.outputTokens??0} out`,children:[`· `,b(y),` tokens`]}),x&&(0,X.jsx)(`span`,{className:`goalbar-stale`,children:o(`goalBarStaleBackend`)}),ag(le([`host:goal-openrole`,`host:goal-clear`]),{...U,"host:goal-openrole":m?(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarOpenExecTip`),onClick:()=>$({type:`switch_conversation`,id:m}),children:(0,X.jsx)(yt,{})}):null,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x${e.reviewing?` stopping`:``}`,title:ue(`host:goal-clear`,e.reviewing?o(`goalBarStop`):o(`goalBarClear`)),onClick:()=>{e.goal&&C(e.goal),$({type:`clear_goal`}),L(!1)},children:e.reviewing?(0,X.jsx)(V,{}):(0,X.jsx)(P,{})})},a)]})});if(I){let e=ag(le([`host:goal-pill`]),U,a);return e?(0,X.jsx)(`div`,{className:`goalbar-collapsed`,children:e}):null}return(0,X.jsxs)(`div`,{className:`goalbar`,children:[(0,X.jsxs)(`div`,{className:`goalbar-row`,children:[(0,X.jsx)(`span`,{className:`goalbar-icon`,children:(0,X.jsx)(oe,{})}),(0,X.jsx)(`input`,{className:`goalbar-input`,value:S,placeholder:o(`goalBarPlaceholder`),title:o(`goalBarPlaceholder`),onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&B()}}),ag(le([`host:goal-set`,`host:goal-wizard`,`host:goal-plan`,`host:goal-lock`,`host:goal-collapse`]),U,a)]}),(0,X.jsxs)(`div`,{className:`goalbar-opts`,children:[le([`host:goal-model`,`host:goal-execmodel`,`host:goal-rounds`]).filter(e=>e.source===`host`).map(e=>(0,X.jsx)(g.Fragment,{children:U[e.id]},e.id)),e.history&&e.history.length>0&&(0,X.jsxs)(Vt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:o(`goalHistory`),children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${o(`goalHistory`)}:`}),(0,X.jsx)(`b`,{children:e.history.length})]}),open:ne,onOpenChange:F,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalHistory`)}),e.history.map((e,t)=>(0,X.jsx)(Ht,{onClick:()=>{C(e.goal),F(!1)},children:(0,X.jsxs)(`span`,{className:`dd-model-cell`,title:e.goal,children:[(0,X.jsxs)(`span`,{className:`dd-model-name`,children:[e.verdict===`pass`?`✅ `:e.verdict===`fail`?`❌ `:`⚠️ `,e.goal.length>42?`${e.goal.slice(0,42)}…`:e.goal]}),(0,X.jsx)(`span`,{className:`dd-model-meta`,children:(0,X.jsxs)(`span`,{className:`dd-model-id`,children:[o(`goalBarRound`,{n:e.rounds}),` · `,new Date(e.finishedAt).toLocaleString()]})})]})},`${e.finishedAt}-${t}`))]}),(0,X.jsx)(`span`,{className:`goalbar-lock-hint`,children:o(O?`goalBarLocked`:`goalBarUnlocked`)}),x&&(0,X.jsx)(`span`,{className:`goalbar-stale`,children:o(`goalBarStaleBackend`)})]})]})});function fv(e){return e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e}function pv({mode:e,currentCwd:t,currentSandbox:n,sandboxDiff:r,projects:i,send:a,onClose:o}){let s=Z(),c=n?.sourcePath||(!n&&t?t:i.find(e=>!e.sandbox)?.path||t||``),[l,u]=(0,g.useState)(c?`import`:`blank`),[d,f]=(0,g.useState)(c),[p,m]=(0,g.useState)(!0),[h,_]=(0,g.useState)(``),v=n?.sourcePath?`${n.sourcePath}-exp`:`~/projects/${(n?.name||`sandbox-app`).replace(/[^a-zA-Z0-9_-]+/g,`-`).replace(/^-|-$/g,``)||`sandbox-app`}`,[y,b]=(0,g.useState)(v),[x,S]=(0,g.useState)(!0);(0,g.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]),(0,g.useEffect)(()=>{e===`apply`&&n?.path&&a({type:`diff_sandbox`,path:n.path})},[e,n?.path,a]);let C=i.filter(e=>!e.sandbox),w=e=>{e.preventDefault();let t=l===`import`?d.trim():void 0;(l!==`import`||t)&&(a({type:`create_sandbox`,name:h.trim()||void 0,sourcePath:t,ephemeral:p}),o())},T=e=>{e.preventDefault();let t=y.trim();t&&(a({type:`promote_sandbox`,path:n?.path,targetPath:t,switchToTarget:x}),o())},E=e=>{e.preventDefault(),n?.path&&(a({type:`apply_sandbox_to_source`,path:n.path}),o())},D=r&&n&&(r.sandboxId===n.id||r.path===n.path),O=D?r.added.length+r.modified.length:0,k=s(e===`create`?`sandboxModalTitle`:e===`promote`?`sandboxPromoteTitle`:`sandboxApplyTitle`);return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:o,children:(0,X.jsxs)(`div`,{className:`modal sandbox-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,onClick:o,title:s(`close`),"aria-label":s(`close`),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(`span`,{className:`modal-head-icon`,"aria-hidden":!0,children:`🧪`}),(0,X.jsx)(`h2`,{children:k})]}),e===`create`?(0,X.jsxs)(`form`,{className:`modal-body sandbox-modal-body`,onSubmit:w,children:[(0,X.jsx)(`p`,{className:`sandbox-modal-subtitle`,children:s(`sandboxModalSubtitle`)}),(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxModeLabel`)}),(0,X.jsxs)(`div`,{className:`sandbox-choice-grid`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-choice-card ${l===`import`?`active`:``}`,onClick:()=>u(`import`),children:[(0,X.jsxs)(`div`,{className:`sandbox-choice-title`,children:[`📦 `,s(`sandboxModeImport`)]}),(0,X.jsx)(`div`,{className:`sandbox-choice-desc`,children:s(`sandboxModeImportDesc`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-choice-card ${l===`blank`?`active`:``}`,onClick:()=>u(`blank`),children:[(0,X.jsxs)(`div`,{className:`sandbox-choice-title`,children:[`✨ `,s(`sandboxModeBlank`)]}),(0,X.jsx)(`div`,{className:`sandbox-choice-desc`,children:s(`sandboxModeBlankDesc`)})]})]})]}),l===`import`&&(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxSourceLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`sandbox-text-input`,value:d,onChange:e=>f(e.target.value),placeholder:s(`sandboxSourcePlaceholder`),required:!0}),C.length>0&&(0,X.jsx)(`div`,{className:`sandbox-source-chips`,children:C.slice(0,6).map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-source-chip ${d===e.path?`active`:``}`,onClick:()=>f(e.path),title:e.path,children:[`📁 `,fv(e.path)]},e.path))})]}),(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxLifecycleLabel`)}),(0,X.jsxs)(`div`,{className:`sandbox-choice-grid`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-choice-card ${p?`active`:``}`,onClick:()=>m(!0),children:[(0,X.jsxs)(`div`,{className:`sandbox-choice-title`,children:[`⏱ `,s(`sandboxLifecycleEphemeral`)]}),(0,X.jsx)(`div`,{className:`sandbox-choice-desc`,children:s(`sandboxLifecycleEphemeralDesc`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-choice-card ${p?``:`active`}`,onClick:()=>m(!1),children:[(0,X.jsxs)(`div`,{className:`sandbox-choice-title`,children:[`📌 `,s(`sandboxLifecyclePermanent`)]}),(0,X.jsx)(`div`,{className:`sandbox-choice-desc`,children:s(`sandboxLifecyclePermanentDesc`)})]})]})]}),(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxNameLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`sandbox-text-input`,value:h,onChange:e=>_(e.target.value),placeholder:l===`import`&&d.trim()?`${fv(d.trim())} (Sandbox)`:s(`sandboxNamePlaceholder`)})]}),(0,X.jsxs)(`div`,{className:`sandbox-modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`submit`,className:`btn primary`,disabled:l===`import`&&!d.trim(),children:[`🧪 `,s(`sandboxCreateSubmit`)]})]})]}):e===`promote`?(0,X.jsxs)(`form`,{className:`modal-body sandbox-modal-body`,onSubmit:T,children:[(0,X.jsx)(`p`,{className:`sandbox-modal-subtitle`,children:s(`sandboxPromoteSubtitle`,{name:n?.name||``})}),(0,X.jsxs)(`div`,{className:`sandbox-field-group`,children:[(0,X.jsx)(`label`,{className:`sandbox-field-label`,children:s(`sandboxPromoteTargetLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`sandbox-text-input`,value:y,onChange:e=>b(e.target.value),placeholder:s(`sandboxPromoteTargetPlaceholder`),autoFocus:!0,required:!0})]}),(0,X.jsxs)(`label`,{className:`sandbox-checkbox-row`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),(0,X.jsx)(`span`,{children:s(`sandboxPromoteSwitchLabel`)})]}),(0,X.jsxs)(`div`,{className:`sandbox-modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`submit`,className:`btn primary`,disabled:!y.trim(),children:[`📤 `,s(`sandboxPromoteSubmit`)]})]})]}):(0,X.jsxs)(`form`,{className:`modal-body sandbox-modal-body`,onSubmit:E,children:[(0,X.jsx)(`p`,{className:`sandbox-modal-subtitle`,children:s(`sandboxActionApplyConfirm`,{name:n?.name||``,source:n?.sourcePath||``})}),D?r.error?(0,X.jsx)(`div`,{className:`sandbox-diff-empty`,children:r.error}):(0,X.jsxs)(`div`,{className:`sandbox-diff-box`,children:[(0,X.jsx)(`div`,{className:`sandbox-diff-stats`,children:s(`sandboxDiffStats`,{added:r.added.length,modified:r.modified.length,deleted:r.deleted.length,unchanged:r.unchangedCount})}),r.added.length+r.modified.length+r.deleted.length===0?(0,X.jsx)(`div`,{className:`sandbox-diff-empty`,children:s(`sandboxDiffEmpty`)}):(0,X.jsxs)(`div`,{className:`sandbox-diff-list`,children:[r.added.map(e=>(0,X.jsxs)(`div`,{className:`sandbox-diff-item added`,children:[(0,X.jsx)(`span`,{className:`sandbox-diff-tag added`,children:`+`}),(0,X.jsx)(`span`,{className:`sandbox-diff-path`,children:e})]},`a:${e}`)),r.modified.map(e=>(0,X.jsxs)(`div`,{className:`sandbox-diff-item modified`,children:[(0,X.jsx)(`span`,{className:`sandbox-diff-tag modified`,children:`~`}),(0,X.jsx)(`span`,{className:`sandbox-diff-path`,children:e})]},`m:${e}`)),r.deleted.map(e=>(0,X.jsxs)(`div`,{className:`sandbox-diff-item deleted`,children:[(0,X.jsx)(`span`,{className:`sandbox-diff-tag deleted`,children:`-`}),(0,X.jsx)(`span`,{className:`sandbox-diff-path`,children:e})]},`d:${e}`))]}),r.deleted.length>0&&(0,X.jsx)(`div`,{className:`sandbox-diff-note`,children:s(`sandboxDiffDeletedNote`)})]}):(0,X.jsx)(`div`,{className:`sandbox-diff-loading`,children:s(`loading`)}),(0,X.jsxs)(`div`,{className:`sandbox-modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`submit`,className:`btn primary`,disabled:!D||O===0,children:[`✅ `,s(`sandboxApplySubmit`,{count:O})]})]})]})]})})}var mv=[{id:`host:conn`,align:`start`},{id:`host:engine`,align:`start`},{id:`host:ctx`,align:`start`},{id:`host:cost`,align:`start`},{id:`host:cache`,align:`start`},{id:`host:msg-count`,align:`start`},{id:`host:plugin-status`,align:`start`},{id:`host:status-delegate`,align:`start`},{id:`host:working`,align:`start`},{id:`host:host-metrics`,align:`end`},{id:`host:cwd`,align:`end`}];function hv({chat:e,bottombarItems:t,onUiAction:n,onOpenSettings:r,onViewChange:i,onOpenGlobalSearch:a,onOpenBgTasks:o}){let s=Za(`workspaceRoots`),c=e.state,[l,u]=(0,g.useState)(!1);if(!c)return null;let d=t?t.map(e=>({id:e.id,entry:e,fallbackAlign:`start`})):mv.map(({id:e,align:t})=>({id:e,entry:null,fallbackAlign:t})),f=[],p=[],m=[];for(let{id:t,entry:s,fallbackAlign:c}of d){if(s?.hidden)continue;let d=s??{id:t,slot:`bottombar`,source:`host`,label:t.slice(5),kind:`action`,order:100,align:c,hidden:!1,userOverrides:[],arrangedBy:[]},h=(0,X.jsx)(Go,{entry:d,bar:`bottom`,chat:e,view:void 0,onViewChange:i,onOpenSettings:r,onOpenGlobalSearch:a,onOpenBgTasks:o,onOpenProjectPicker:()=>u(!0),isProjectPickerOpen:l,onUiAction:n});if(!h)continue;let g=d.align??c;g===`end`?m.push({key:t,node:h}):g===`center`?p.push({key:t,node:h}):f.push({key:t,node:h})}let h=e=>e.map(e=>(0,X.jsx)(g.Fragment,{children:e.node},e.key));return(0,X.jsxs)(`footer`,{className:`statusbar`,children:[(0,X.jsx)(`div`,{className:`statusbar-left`,children:h(f)}),p.length>0&&(0,X.jsx)(`div`,{className:`statusbar-center`,children:h(p)}),(0,X.jsx)(`div`,{className:`statusbar-right`,children:h(m)}),l&&(0,X.jsx)(xo,{currentCwd:c.cwd,pathCompletions:e.pathCompletions,workspaceRoots:s,onClose:()=>u(!1),onSelectDirectory:e=>{e&&e!==c.cwd&&$({type:`set_cwd`,path:e}),u(!1)},mode:`folder`})]})}var gv=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`,alignable:!0,vertical:!1},{slot:`bottombar`,labelKey:`uiLayoutBottombar`,alignable:!0,vertical:!1},{slot:`sidebar.left`,labelKey:`uiLayoutSidebarLeft`,alignable:!0,vertical:!0},{slot:`sidebar.right`,labelKey:`uiLayoutSidebarRight`,alignable:!0,vertical:!0}],_v=`__tray`,vv=[`start`,`center`,`end`];function yv(e,t){return e(t===`start`?`uiLayoutAlignTop`:t===`end`?`uiLayoutAlignBottom`:`uiLayoutAlignMiddle`)}function bv(e,t=new Set){let n={},r=[],i=new Set;for(let a of gv){let o=(e[a.slot]??[]).filter(e=>!t.has(e.id));n[a.slot]=o;for(let e of o)e.hidden&&(r.push(e),i.add(e.id))}for(let n of e[`topbar.overflow`]??[])t.has(n.id)||i.has(n.id)||(r.push(n),i.add(n.id));return{zones:n,tray:r}}function xv(e,t){for(let n of Object.values(e.zones)){let e=n.find(e=>e.id===t);if(e)return e}return e.tray.find(e=>e.id===t)}function Sv(e){return(e??[]).filter(e=>!e.hidden)}function Cv(e,t){let n=Sv(e);return t===void 0?n:n.filter(e=>(e.align??`start`)===t)}function wv(e){return[...new Set(e)]}function Tv(e,t,n){let r=e??{},i=xv(t,n.id);if(!i)return r;let a={...r};i.hidden&&(a.hidden=(r.hidden??[]).filter(e=>e!==n.id),a.shown=wv([...r.shown??[],n.id])),i.slot!==n.slot&&(a.slots={...r.slots,[n.id]:n.slot});let o=n.align;o!==void 0&&(i.align??`start`)!==o&&(a.align={...r.align,[n.id]:o});let s=t.zones[n.slot]??[],c=Sv(s),l=e=>o===void 0||(e.align??`start`)===o,u=c.filter(e=>e.id!==n.id&&l(e)).map(e=>e.id),d=Math.max(0,Math.min(Math.trunc(n.index)||0,u.length));u.splice(d,0,n.id);let f=o===void 0?[]:c.filter(e=>e.id!==n.id&&!l(e)).map(e=>e.id),p=new Set(s.map(e=>e.id));return a.order=wv([...(r.order??[]).filter(e=>!p.has(e)&&e!==n.id),...u,...f]),a}function Ev(e,t){let n=e??{};return{...n,hidden:wv([...n.hidden??[],t]),shown:(n.shown??[]).filter(e=>e!==t)}}function Dv({side:e,items:t,chat:n,view:r,onViewChange:i,onOpenPanel:a,onOpenSettings:o,onOpenBgTasks:s,onOpenGlobalSearch:c,onUiAction:l,uiContextTopbar:u,onOpenProjectPicker:d,onThemeToggle:f,onSoundToggle:p}){let{t:m}=Nn(),[h,_]=(0,g.useState)(!1),v=(0,g.useRef)(null),y=n.settings?.uiLayout?.sideDockFloat===!0,b=y?` side-dock-float`:``,x=t.filter(e=>!e.hidden);if(x.length===0)return null;if(y&&h)return(0,X.jsx)(`div`,{ref:v,className:`side-dock side-dock-${e} side-dock-collapsed${b}`,children:(0,X.jsx)(`button`,{type:`button`,className:`side-dock-btn side-dock-toggle-btn`,"data-tip":`${m(`sideDockExpand`)} (${x.length})`,onClick:()=>_(!1),"aria-label":m(`sideDockExpand`),children:e===`left`?(0,X.jsx)(lt,{}):(0,X.jsx)(ut,{})})});let S=ga(x),C=t=>(0,X.jsx)(Go,{entry:t,bar:e,chat:n,view:r,onViewChange:i,onOpenPanel:a,onOpenSettings:o,onOpenGlobalSearch:c,onOpenBgTasks:s,onOpenProjectPicker:d,onUiAction:l,uiContextEntries:u},t.id);return(0,X.jsxs)(`div`,{ref:v,className:`side-dock side-dock-${e}${b}`,children:[y&&(0,X.jsx)(`button`,{type:`button`,className:`side-dock-btn side-dock-collapse-btn`,"data-tip":m(`sideDockCollapse`),onClick:()=>_(!0),"aria-label":m(`sideDockCollapse`),children:e===`left`?(0,X.jsx)(ut,{}):(0,X.jsx)(lt,{})}),vv.map(e=>(0,X.jsx)(`div`,{className:`side-dock-slot side-dock-slot-${e}`,children:S[e].length>0&&(0,X.jsx)(`div`,{className:`side-dock-seg`,children:S[e].map(C)})},e))]})}function Ov({dialog:e}){let t=Z(),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(0),o=t=>{$({type:`dialog_response`,id:e.id,value:t})};(0,g.useEffect)(()=>{r(``),a(0)},[e.id]),zt(()=>o(null));let s=Array.isArray(e.args[0])?e.args[0]:[],c=typeof e.args[0]==`string`?e.args[0]:``;return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":e.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:t(`pluginRequest`)}),e.title&&e.title!==t(`pluginRequest`)&&(0,X.jsx)(`span`,{className:`dialog-title`,children:e.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:t(`cancel`),onClick:()=>o(null),children:`✕`})]}),e.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[s.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`dialog-option ${t===i?`sel`:``}`,onMouseEnter:()=>a(t),onClick:()=>o(e),children:(0,X.jsx)(Af,{text:e,rawHtml:!0})},t)),s.length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:t(`noOptions`)}),(0,X.jsxs)(`div`,{className:`dialog-custom-row`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:n,placeholder:t(`modelQuestionCustom`),onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&n.trim()&&o(n.trim())}}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!n.trim(),onClick:()=>{n.trim()&&o(n.trim())},children:t(`ok`)})]})]}),e.kind===`confirm`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(Af,{text:c,rawHtml:!0}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o(!1),children:t(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>o(!0),children:t(`ok`)})]})]}),e.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:n,placeholder:c||t(`inputPlaceholder`),autoFocus:!0,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&o(n)}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>o(null),children:t(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>o(n),children:t(`ok`)})]})]})]})}var kv=150;function Av({anchorRef:e,enabled:t=!0,className:n,children:r}){let i=(0,g.useRef)(null),a=(0,g.useRef)(null),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)({left:0,top:0}),u=(0,g.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},[]),d=(0,g.useCallback)(()=>{u(),a.current=setTimeout(()=>s(!1),kv)},[u]);return(0,g.useEffect)(()=>{let n=e.current;if(!n)return;let r=()=>{u(),s(!0)};n.addEventListener(`mouseenter`,r);let a=e=>{let t=e.relatedTarget;t&&i.current?.contains(t)||d()};return n.addEventListener(`mouseleave`,a),t&&(n.addEventListener(`focus`,r),n.addEventListener(`blur`,d)),()=>{u(),n.removeEventListener(`mouseenter`,r),n.removeEventListener(`mouseleave`,a),n.removeEventListener(`focus`,r),n.removeEventListener(`blur`,d)}},[e,t,u,d]),(0,g.useLayoutEffect)(()=>{if(!o)return;let t=e.current?.getBoundingClientRect();if(!t)return;let n={left:Math.max(8,t.left-8),top:t.bottom+8};l(e=>e.left===n.left&&e.top===n.top?e:n)},[o,e]),(0,g.useLayoutEffect)(()=>{if(!o)return;let t=i.current,n=e.current;if(!t||!n)return;let r=Tu(n.getBoundingClientRect(),t.getBoundingClientRect(),{width:window.innerWidth,height:window.innerHeight});l(e=>e.left===r.left&&e.top===r.top?e:r)},[o,e,r]),(0,g.useEffect)(()=>{if(!o)return;let e=()=>s(!1);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[o]),o?(0,j.createPortal)((0,X.jsx)(`div`,{ref:i,className:`set-tip-bubble open${n?` ${n}`:``}`,role:`tooltip`,style:{position:`fixed`,left:c.left,top:c.top},onMouseEnter:u,onMouseLeave:d,children:r}),document.body):null}var jv=`pi_web_qdraft_`,Mv=864e5,Nv=new Map;function Pv(e){return`${jv}${e}`}function Fv(e){if(!e)return null;try{if(typeof window<`u`&&window.sessionStorage){let t=window.sessionStorage.getItem(Pv(e));if(t){let n=JSON.parse(t);if(n&&typeof n==`object`&&n.selections&&typeof n.selections==`object`&&n.customs&&typeof n.customs==`object`&&typeof n.step==`number`)return n.updatedAt&&Date.now()-n.updatedAt>Mv?(Lv(e),null):n}}}catch{}let t=Nv.get(e);return t?t.updatedAt&&Date.now()-t.updatedAt>Mv?(Nv.delete(e),null):t:null}function Iv(e,t){if(!e)return;let n=Object.values(t.selections).some(e=>e&&e.length>0),r=Object.values(t.customs).some(e=>e&&e.trim().length>0),i=t.step>0;if(!n&&!r&&!i){Lv(e);return}let a={selections:{...t.selections},customs:{...t.customs},step:t.step,updatedAt:Date.now()};Nv.set(e,a);try{typeof window<`u`&&window.sessionStorage&&window.sessionStorage.setItem(Pv(e),JSON.stringify(a))}catch{}}function Lv(e){if(e){Nv.delete(e);try{typeof window<`u`&&window.sessionStorage&&window.sessionStorage.removeItem(Pv(e))}catch{}}}function Rv({question:e,owner:t,conversationTitle:n}){let r=Z(),i=e.conversationTitle||n,[a,o]=(0,g.useState)(()=>Fv(e.id)?.selections??{}),[s,c]=(0,g.useState)(()=>Fv(e.id)?.customs??{}),[l,u]=(0,g.useState)(!1),d=V_(),[f,p]=(0,g.useState)(()=>Fv(e.id)?.step??0),[m,h]=(0,g.useState)(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1),_=(0,g.useRef)(!1);(0,g.useEffect)(()=>{_.current=!1;let n=Fv(e.id);n?(o(n.selections),c(n.customs),p(n.step)):(o({}),c({}),p(0)),u(!1);let r=e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1;h(r),e.deadline&&r<=0&&(Lv(e.id),$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}}))},[e.id,e.deadline,t]),(0,g.useEffect)(()=>{_.current||Iv(e.id,{selections:a,customs:s,step:f})},[e.id,a,s,f]),(0,g.useEffect)(()=>{if(!e.deadline)return;let n=setInterval(()=>{h(n=>{let r=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return r<=0&&n>0&&(Lv(e.id),$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})),r})},1e3);return()=>clearInterval(n)},[e.id,e.deadline]);let v=(0,g.useCallback)(n=>{_.current=!0,Lv(e.id),$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...n?.trim()?{cancelReason:n.trim()}:{},...t?{owner:t}:{}})},[e.id,t]);zt(()=>{v()},!l);let y=(e,t)=>{if(!e.dependsOn)return!0;let n=t[e.dependsOn.questionId]??[];if(e.dependsOn.value===void 0)return n.length>0;let r=Array.isArray(e.dependsOn.value)?e.dependsOn.value:[e.dependsOn.value];return n.some(e=>r.includes(e))},b=e.questions.filter(e=>y(e,a)),x=b.length;(0,g.useEffect)(()=>{if(e.questions.length===0||x>0)return;let n=setTimeout(()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},1500);return()=>clearTimeout(n)},[e.id,e.questions.length,x,t]);let S=Math.min(f,Math.max(0,x-1)),C=b[S];if(!C)return(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":`select`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:r(`modelQuestion`)}),i&&(0,X.jsx)(`span`,{className:`question-conv-title`,title:i,children:i}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:()=>v(),children:`✕`})]}),(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-hint`,children:r(`questionNoneAvailable`)})})]});let w=(()=>{if(!C)return[];if(C.optionsMap&&C.dependsOn){let e=a[C.dependsOn.questionId]??[];for(let t of e)if(C.optionsMap[t])return C.optionsMap[t]}return C.options??[]})(),T=n=>{_.current=!0,Lv(e.id);let r=e.questions.map(e=>{let t=n[e.id]??[],r=(s[e.id]??``).trim();return{id:e.id,selected:t,...r?{custom:r}:{}}});$({type:`question_answer`,id:e.id,answers:r,...t?{owner:t}:{}})},E=(e,t)=>{o(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},D=(t,n,r)=>{if(r){E(t,n);return}let i={...a,[t]:[n]};o(i);let s=e.questions.filter(e=>y(e,i));S>=s.length-1?T(i):p(S+1)},O=()=>{S>=x-1?T(a):p(S+1)},k=t=>{let n=e.questions.find(e=>e.id===t);return w.length===0&&(n?.options?.length??0)===0||(a[t]?.length??0)>0||(s[t]??``).trim()!==``},A=w.filter(e=>(a[C.id]??[]).includes(e.label)&&e.preview).map(e=>e.preview),j=(C.header||C.question).replace(/\s+/g,` `).trim(),ee=(s[C.id]??``).trim(),M=Object.values(s).map(e=>e?.trim()).filter(Boolean).join(`;
361
+ `),te=ee.length>0||M.length>0,N=ee||M;return(0,g.useEffect)(()=>{if(l)return;let e=e=>{let t=e.target;if(!(t?.tagName===`INPUT`||t?.tagName===`TEXTAREA`||t?.isContentEditable)){if(e.key>=`1`&&e.key<=`9`){let t=parseInt(e.key,10)-1;if(t<w.length){e.preventDefault(),D(C.id,w[t].label,!!C.multiSelect);return}}if(e.key===`ArrowLeft`&&S>0){e.preventDefault(),p(S-1);return}if(e.key===`ArrowRight`&&S<x-1&&k(C.id)){e.preventDefault(),p(S+1);return}e.key===`Enter`&&k(C.id)&&(e.preventDefault(),O())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,w,C.id,C.multiSelect,S,x,k,O,D]),(0,X.jsxs)(`div`,{className:`dialog-inline${l?` collapsed`:``}`,"data-dialog-kind":`select`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,onClick:l?()=>u(!1):void 0,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:r(`modelQuestion`)}),i&&(0,X.jsx)(`span`,{className:`question-conv-title`,title:i,children:i}),x>1&&(0,X.jsx)(`span`,{className:`question-progress`,children:r(`questionStep`,{cur:S+1,total:x})}),m>=0&&(0,X.jsx)(`span`,{className:`question-timer`,children:m>0?r(`questionTimeout`,{s:m}):r(`questionTimeoutExpired`)}),l&&(0,X.jsx)(`span`,{className:`question-collapsed-preview`,title:j,children:j}),(0,X.jsxs)(`div`,{className:`dialog-head-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-toggle-collapse`,title:r(l?`expandSection`:`collapseSection`),onClick:e=>{e.stopPropagation(),u(e=>!e)},children:l?(0,X.jsx)(ct,{}):(0,X.jsx)(dt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(te?`modelQuestionRejectWithNoteTip`:`cancel`),onClick:e=>{e.stopPropagation(),v(te?N:void 0)},children:`✕`})]})]}),!l&&(0,X.jsxs)(X.Fragment,{children:[x>1&&(0,X.jsx)(`div`,{className:`question-step-pills`,role:`tablist`,children:b.map((e,t)=>{let n=t===S,i=k(e.id),a=e.header||`${r(`modelQuestion`)} ${t+1}`;return(0,X.jsxs)(`button`,{type:`button`,className:`question-step-pill${n?` active`:``}${i?` done`:``}`,onClick:()=>p(t),title:a,"aria-selected":n,children:[(0,X.jsx)(`span`,{className:`question-step-pill-idx`,children:i&&!n?`✓`:t+1}),(0,X.jsx)(`span`,{className:`question-step-pill-label`,children:a})]},e.id)})}),(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,children:C.header??`${r(`modelQuestion`)} ${S+1}`}),(0,X.jsx)(`div`,{className:`question-head`,children:(0,X.jsx)(Af,{text:C.question,rawHtml:!0})}),C.detail&&(0,X.jsx)(`div`,{className:`set-hint`,children:(0,X.jsx)(Af,{text:C.detail,rawHtml:!0})}),w.length>0&&(0,X.jsx)(`div`,{className:`set-list`,children:w.map((e,t)=>{let n=(a[C.id]??[]).includes(e.label),r=e.recommended??(t===0&&w.length>1),i=t<9?t+1:void 0;return(0,X.jsx)(zv,{label:e.label,description:e.description,mark:C.multiSelect?n?`☑ `:`☐ `:n?`● `:`○ `,active:n,keyNumber:i,recommended:r,onPick:()=>D(C.id,e.label,!!C.multiSelect)},e.label)})}),A.length>0&&(0,X.jsxs)(`div`,{className:`question-preview`,children:[(0,X.jsx)(`div`,{className:`question-preview-label`,children:r(`optionPreview`)}),A.map((e,t)=>(0,X.jsx)(`div`,{className:`question-preview-body`,children:(0,X.jsx)(Af,{text:e,rawHtml:!0})},t))]}),(0,X.jsx)(`input`,{className:`set-prompt-input question-custom`,placeholder:r(`modelQuestionCustom`),value:s[C.id]??``,onChange:e=>c(t=>({...t,[C.id]:e.target.value})),onCompositionEnd:d.onCompositionEnd,onKeyDown:e=>{d.isImeKey(e.nativeEvent)||e.key===`Enter`&&(e.preventDefault(),k(C.id)&&O())}})]},C.id),(0,X.jsxs)(`div`,{className:`dialog-nav`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss-inline${te?` reject-note`:``}`,onClick:()=>v(te?N:void 0),title:r(te?`modelQuestionRejectWithNoteTip`:`cancel`),children:r(te?`modelQuestionRejectWithNote`:`cancel`)}),(0,X.jsxs)(`div`,{className:`dialog-nav-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-prev`,disabled:S===0,onClick:()=>p(S-1),children:r(`previous`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-submit`,disabled:!k(C.id),onClick:O,children:S===x-1?r(`modelQuestionSubmit`):r(`next`)})]})]})]})]})}function zv({label:e,description:t,mark:n,active:r,keyNumber:i,recommended:a,onPick:o}){let s=(0,g.useRef)(null),c=Z();return(0,X.jsxs)(`button`,{type:`button`,ref:s,className:`set-row question-option${r?` active`:``}`,onClick:o,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[i!==void 0&&(0,X.jsx)(`span`,{className:`question-key-badge`,title:c(`keyShortcutTip`,{key:i}),children:i}),(0,X.jsx)(`span`,{className:`question-mark`,children:n}),(0,X.jsx)(Af,{text:e,rawHtml:!0}),a&&(0,X.jsx)(`span`,{className:`question-recommended-badge`,children:c(`recommended`)})]}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-desc`,children:(0,X.jsx)(Af,{text:t,rawHtml:!0})}),(0,X.jsx)(Av,{anchorRef:s,enabled:Eu(),className:`question-desc-tip`,children:(0,X.jsx)(Af,{text:t,rawHtml:!0})})]})]})}var Bv=e=>`'${e.replace(/'/g,`'\\''`)}'`,Vv=`pi-web-ui:scm-sidebar-width`;function Hv(e,t=0){if(!Number.isFinite(e))return 300;let n=Math.max(200,Math.min(720,t>0?t-220:720));return Math.min(n,Math.max(200,Math.round(e)))}function Uv(e){return e===null||e.trim()===``?300:Hv(Number(e))}function Wv(e,t){let n=t.toLowerCase();return e.subject.toLowerCase().includes(n)||e.author.toLowerCase().includes(n)||e.shortHash.toLowerCase().includes(n)||e.hash.toLowerCase().includes(n)||e.decorations!==void 0&&e.decorations.toLowerCase().includes(n)}function Gv(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>Wv(e,t)))}var Kv=`scm-commit-history`;function qv(e=localStorage){try{let t=e.getItem(Kv);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Jv(e,t=localStorage){let n=e.trim();if(!n)return qv(t);let r=[n,...qv(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(Kv,JSON.stringify(r))}catch{}return r}var Yv={idx:-1,draft:``};function Xv(e,t,n,r){return e.length===0?null:r===`up`?t.idx>=e.length-1?null:t.idx===-1?{state:{idx:0,draft:n},text:e[0]}:{state:{idx:t.idx+1,draft:t.draft},text:e[t.idx+1]}:t.idx===-1?null:t.idx===0?{state:Yv,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}function Zv(e){if(e.x===`?`&&e.y===`?`)return`untracked`;let t=e.x!==` `&&e.x!==`?`,n=e.y!==` `&&e.y!==`?`;return t&&n?`both`:t?`staged`:`unstaged`}function Qv({chat:e,terminal:t,active:n,onSwitchToTerminal:r,uiScmToolbar:i,onUiAction:a}){let o=Z(),[s,c]=(0,g.useState)(null),[l,u]=(0,g.useState)([]),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(new Map),[h,_]=(0,g.useState)(`changes`),[v,y]=(0,g.useState)([]),[b,x]=(0,g.useState)(null),[S,C]=(0,g.useState)(``),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(null),[O,k]=(0,g.useState)(null),[A,j]=(0,g.useState)(!1),[ee,M]=(0,g.useState)(!1),[te,N]=(0,g.useState)(!1),[P,ne]=(0,g.useState)(null),[F,re]=(0,g.useState)(!1),[ie,ae]=(0,g.useState)(!1),[I,L]=(0,g.useState)(null),[R,oe]=(0,g.useState)(()=>Uv(localStorage.getItem(Vv))),[B,V]=(0,g.useState)(``),[H,se]=(0,g.useState)(``),[ce,le]=(0,g.useState)(()=>qv()),ue=(0,g.useRef)(Yv),U=(0,g.useRef)(0),de=(0,g.useRef)(-1),fe=(0,g.useRef)(-1),W=(0,g.useRef)(-1),pe=(0,g.useRef)(-1),G=(0,g.useRef)(-1),me=(0,g.useRef)(void 0),he=(0,g.useRef)(null),ge=(0,g.useRef)([]),q=(0,g.useRef)(R);q.current=R;let _e=(0,g.useRef)(null),ve=(0,g.useCallback)(e=>{try{localStorage.setItem(Vv,String(e))}catch{}},[]),ye=(0,g.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=q.current,r=_e.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=Hv(n+(e.clientX-t),r),oe(i)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.classList.remove(`panel-resizing`),ve(i)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),document.body.classList.add(`panel-resizing`)},[ve]),be=(0,g.useCallback)(()=>{oe(300),ve(300)},[ve]),xe=(0,g.useCallback)(e=>{if(e.reqId===de.current){if(de.current=-1,M(!1),ne(null),!e.ok){ne(e.error??o(`scmQueryFailedShort`));return}if(e.notRepo){re(!0),c(null),u([]),m(new Map),y([]),x(null),C(``),k(null);return}re(!1);let t={branch:e.branch??``,detached:!!e.detached,upstream:e.upstream??null,ahead:e.ahead??0,behind:e.behind??0,upstreamGone:!!e.upstreamGone,files:(e.files??[]).map(e=>({...e}))},n=(e.branches??[]).map(e=>({...e})),r=new Map;for(let[t,n]of Object.entries(e.stats??{}))r.set(t,{add:n[0],del:n[1]});c(t),u(n),m(r),f(e=>t.detached?e||``:t.branch&&n.some(e=>e.name===t.branch)?t.branch:e&&n.some(t=>t.name===e)?e:n[0]?.name??``),k(e=>e&&!t.files.some(t=>t.path===e.file.path)?null:e)}else if(e.reqId===fe.current){if(fe.current=-1,j(!1),!e.ok){ne(e.error??o(`scmQueryFailedShort`));return}let t=he.current;if(!t)return;k({file:t,staged:e.stagedText??``,worktree:e.worktreeText??``,untracked:!1})}else if(e.reqId===pe.current){if(pe.current=-1,N(!1),!e.ok){ne(e.error??o(`scmQueryFailedShort`));return}y((e.history??[]).map(e=>({...e})))}else if(e.reqId===W.current){if(W.current=-1,T(!1),!e.ok){ne(e.error??o(`scmQueryFailedShort`));return}C(e.text??``)}else if(e.reqId===G.current){if(G.current=-1,ae(!1),!e.ok){L(e.error??o(`scmGenMsgFail`));return}L(null),V(e.text??``)}},[]);(0,g.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&xe(t)},[e.scmData,xe]);let J=(0,g.useCallback)((t,n)=>{if(!e.ready||e.status!==`open`)return!1;let r=++U.current;return $({...t,reqId:r})?(n.current=r,!0):(--U.current,!1)},[e.ready,e.status]),Se=(0,g.useCallback)((t=!1,n=!1)=>{e.ready&&e.status===`open`&&e.state?.cwd&&(me.current!==void 0&&me.current!==e.state.cwd&&(c(null),u([]),m(new Map),y([]),se(``),N(!1),pe.current=-1,x(null),C(``),k(null),D(null),L(null),ae(!1),G.current=-1),me.current=e.state.cwd,ne(null),J({type:`scm_status`},de)&&(n||M(!0)))},[e.ready,e.state?.cwd,e.status,J]),Ce=(0,g.useCallback)(e=>{if(D(e),x(null),he.current=e,e.x===`?`&&e.y===`?`){k({file:e,staged:``,worktree:``,untracked:!0});return}j(!0),ne(null),J({type:`scm_filediff`,path:e.path},fe)||j(!1)},[J]),we=(0,g.useCallback)(e=>{x(e),D(null),k(null),C(``),T(!0),ne(null),J({type:`scm_commit`,hash:e.hash},W)||T(!1)},[J]),Te=(0,g.useCallback)((n,i)=>{if(!e.ready)return;let a={name:n,command:i,cwd:"${pwd}"},o,s=e.terminals.find(e=>e.title===n);s?(t.restart(s.id),$({type:`run_command`,terminalId:s.id,conversationId:s.conversationId,command:a,cols:80,rows:24}),o=s.id):(o=jt(),t.create({id:o,conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:a})),t.select(o),r()},[e.ready,e.state?.cwd,e.terminals,r,t]),Ee=(0,g.useCallback)(()=>{let e=B.trim();if(!e||F)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);Te(`git commit`,`git commit -m "${t}"`),le(Jv(e)),V(``),ue.current=Yv},[B,F,Te]),De=(0,g.useCallback)(()=>{let e=B.trim();if(!e||F)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);Te(`git commit`,`git add -A && git commit -m "${t}"`),le(Jv(e)),V(``),ue.current=Yv},[B,F,Te]),Oe=(0,g.useCallback)(e=>{F||Te(`git add`,`git add -- ${Bv(e.path)}`)},[F,Te]),ke=(0,g.useCallback)(e=>{F||Te(`git reset`,`git reset HEAD -- ${Bv(e.path)}`)},[F,Te]),Ae=(0,g.useCallback)(()=>{if(!d||F)return;let e=l.find(e=>e.name===d);if(e?.remote&&typeof e.remote==`string`){let t=d.slice(e.remote.length+1);Te(`git checkout`,`git checkout -b ${t} ${d} || git checkout ${d}`)}else Te(`git checkout`,`git checkout ${d}`)},[d,l,F,Te]),je=(0,g.useCallback)(()=>Te(`git push`,`git push`),[Te]),Me=(0,g.useCallback)(()=>Te(`git pull`,`git pull`),[Te]),Ne=(0,g.useCallback)(()=>{ie||F||!e.ready||e.status!==`open`||(L(null),J({type:`scm_commitmsg`},G)?ae(!0):L(o(`scmGenMsgFail`)))},[ie,F,e.ready,e.status,J,o]),Pe=(0,g.useCallback)(()=>{J({type:`scm_history`},pe)||(pe.current=-1)},[J]);(0,g.useEffect)(()=>{n&&Se()},[n,Se]),(0,g.useEffect)(()=>{h===`history`&&s&&Pe()},[h,s,Pe]),(0,g.useEffect)(()=>{e.scmDirty>0&&n&&Se(!1,!0)},[e.scmDirty]),(0,g.useEffect)(()=>{if(!n||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&Se(!1,!0)},3e4);return()=>clearInterval(t)},[n,e.ready,e.status,Se]),(0,g.useEffect)(()=>{let t=ge.current;ge.current=e.terminals,n&&e.terminals.some(e=>e.running===!1&&t.find(t=>t.id===e.id)?.running===!0&&e.title.startsWith(`git `))&&e.ready&&e.status===`open`&&(Se(!1,!0),h===`history`&&s&&Pe())},[e.terminals,n,e.ready,e.status,Se,h,s,Pe]);let Fe={staged:o(`scmStaged`),unstaged:o(`scmUnstaged`),untracked:o(`scmUntracked`),both:o(`scmStagedUnstaged`)},Ie=Gv(v,H),Re=e=>{let t=e.split(`
362
+ `);return(0,X.jsx)(`pre`,{className:`scm-diff-pre`,children:t.map((e,t)=>{let n=``;return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,X.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})},ze=i===void 0?[`host:scm-changes`,`host:scm-history`,`host:scm-refresh`,`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`,`host:scm-term`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),Be=[`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`],Ve=(e,t)=>{let n=new Set(e);return ze.filter(e=>n.has(e.id)||t&&e.source!==`host`)},He=e=>i===void 0||!i.some(t=>t.id===e&&t.hidden),Ue=(e,t)=>{let n=ze.find(t=>t.id===e);return n?.labelExplicit?n.label:t},We={"host:scm-changes":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`changes`,className:h===`changes`?`active`:``,onClick:()=>{_(`changes`),ne(null)},children:Ue(`host:scm-changes`,o(`scmChanges`))}),"host:scm-history":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`history`,className:h===`history`?`active`:``,onClick:()=>{_(`history`),ne(null)},children:Ue(`host:scm-history`,o(`scmHistory`))}),"host:scm-refresh":(0,X.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:o(`scmRefreshTip`),disabled:ee,onClick:()=>Se(!0),children:(0,X.jsx)(K,{className:ee?`scm-spin`:``})}),"host:scm-branch":(0,X.jsxs)(`select`,{className:`scm-select`,value:d,disabled:F||l.length===0,title:Ue(`host:scm-branch`,o(`scmSwitchBranch`)),onChange:e=>f(e.target.value),children:[(0,X.jsx)(`option`,{value:``,disabled:!0,children:o(`scmSelectBranch`)}),l.filter(e=>!e.remote).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.current?`* ${e.name}`:e.name},e.name)),l.some(e=>e.remote)&&(0,X.jsx)(`optgroup`,{label:o(`scmRemoteBranches`),children:l.filter(e=>e.remote).map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),"host:scm-switch":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!d||d===s?.branch||F,title:o(`scmSwitchBranchTip`,{branch:d}),onClick:Ae,children:[(0,X.jsx)(Le,{}),Ue(`host:scm-switch`,o(`scmSwitch`))]}),"host:scm-push":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||F,title:o(`scmPushTip`),onClick:je,children:[(0,X.jsx)(vt,{}),Ue(`host:scm-push`,o(`scmPush`))]}),"host:scm-pull":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||F,title:o(`scmPullTip`),onClick:Me,children:[(0,X.jsx)(xt,{}),Ue(`host:scm-pull`,o(`scmPull`))]}),"host:scm-input":(0,X.jsx)(`input`,{className:`scm-commit-input`,value:B,placeholder:o(`scmCommitPlaceholder`),disabled:F,title:ce.length>0?o(`scmCommitHistoryTip`):void 0,onChange:e=>{V(e.target.value),ue.current=Yv},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){Ee();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=Xv(ce,ue.current,B,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),ue.current=t.state,V(t.text))}}}}),"host:scm-genmsg":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:ie||F||!s||s.files.length===0,title:o(`scmGenMsgTip`),onClick:Ne,children:[(0,X.jsx)(Ze,{className:ie?`scm-spin`:``}),ie?o(`scmGenMsgRunning`):Ue(`host:scm-genmsg`,o(`scmGenMsg`))]}),"host:scm-commit":(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!B.trim()||F,title:o(`scmCommitTip`),onClick:Ee,children:[(0,X.jsx)(ft,{}),Ue(`host:scm-commit`,o(`scmCommit`))]}),"host:scm-commit-all":(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!B.trim()||F,title:o(`scmCommitAllTip`),onClick:De,children:Ue(`host:scm-commit-all`,o(`scmCommitAll`))})};return(0,X.jsxs)(`div`,{className:`scm-view`,children:[(0,X.jsxs)(`div`,{className:`scm-header`,children:[(0,X.jsxs)(`div`,{className:`scm-title-row`,children:[(0,X.jsxs)(`span`,{className:`scm-title`,children:[(0,X.jsx)(Le,{}),o(`scmTitle`)]}),(0,X.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:ag(Ve([`host:scm-changes`,`host:scm-history`],!1),We,a)}),ag(Ve([`host:scm-refresh`],!0),We,a)]}),(0,X.jsxs)(`div`,{className:`scm-row`,children:[(0,X.jsxs)(`span`,{className:`scm-branch-current`,title:o(`scmCurrentBranch`),children:[(0,X.jsx)(Le,{}),s?s.detached?o(`scmDetached`):s.branch:`…`,s?.upstream&&(0,X.jsx)(`span`,{className:`scm-upstream`,children:s.upstreamGone?o(`scmUpstreamGone`):s.ahead>0||s.behind>0?o(`scmAheadBehind`,{ahead:s.ahead,behind:s.behind}):s.upstream})]}),ag(Ve(Be,!1),We,a)]}),I&&(0,X.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:o(`close`),onClick:()=>L(null),children:I})]}),(0,X.jsxs)(`div`,{className:`scm-body`,ref:_e,style:{"--scm-sidebar-w":`${R}px`},children:[h===`history`?(0,X.jsxs)(`div`,{className:`scm-history`,children:[(0,X.jsxs)(`div`,{className:`scm-files-header`,children:[(0,X.jsx)(`span`,{children:o(`scmHistory`)}),v.length>0&&(0,X.jsx)(`span`,{className:`scm-files-count`,children:H.trim()?`${Ie.length}/${v.length}`:v.length})]}),v.length>0&&!F&&(0,X.jsx)(`input`,{className:`scm-history-filter`,value:H,placeholder:o(`scmHistoryFilterPlaceholder`),title:o(`scmHistoryFilterTip`),onChange:e=>se(e.target.value)}),(0,X.jsx)(`div`,{className:`scm-history-list`,children:F?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):!s||te?(0,X.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?o(`scmLoading`):o(`scmConnecting`)}):v.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoHistory`)}):Ie.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmHistoryFilterEmpty`)}):Ie.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`scm-commit ${b?.hash===e.hash?`active`:``}`,onClick:()=>we(e),title:e.hash,children:[(0,X.jsx)(`span`,{className:`scm-commit-graph`,"aria-hidden":`true`,children:e.graph||`* `}),(0,X.jsxs)(`span`,{className:`scm-commit-info`,children:[(0,X.jsx)(`span`,{className:`scm-commit-subject`,children:e.subject}),(0,X.jsxs)(`span`,{className:`scm-commit-meta`,children:[e.shortHash,` · `,e.author,` · `,e.date]}),e.decorations&&(0,X.jsx)(`span`,{className:`scm-commit-refs`,children:e.decorations})]})]},e.hash))})]}):(0,X.jsxs)(`div`,{className:`scm-files`,children:[(0,X.jsxs)(`div`,{className:`scm-files-header`,children:[(0,X.jsx)(`span`,{children:o(`scmChanges`)}),s&&s.files.length>0&&(0,X.jsx)(`span`,{className:`scm-files-count`,children:s.files.length})]}),(0,X.jsx)(`div`,{className:`scm-files-list`,children:F?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):s?s.files.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoChanges`)}):s.files.map(e=>{let t=Zv(e),n=p.get(e.path);return(0,X.jsxs)(`div`,{className:`scm-file ${E?.path===e.path?`active`:``}`,title:Fe[t],onClick:()=>Ce(e),children:[(0,X.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`x`}`,children:e.x===` `?`\xA0`:e.x}),(0,X.jsx)(`span`,{className:`scm-file-xy ${t===`untracked`?`q`:`y`}`,children:e.y===` `?`\xA0`:e.y}),(0,X.jsx)(`span`,{className:`scm-file-path`,children:e.path}),n&&(n.add>0||n.del>0)&&(0,X.jsxs)(`span`,{className:`scm-file-stat`,children:[n.add>0&&(0,X.jsxs)(`span`,{className:`add`,children:[`+`,n.add]}),n.del>0&&(0,X.jsxs)(`span`,{className:`del`,children:[`-`,n.del]})]}),(0,X.jsxs)(`span`,{className:`scm-file-actions`,children:[(e.y!==` `||t===`untracked`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-act`,title:o(`scmStageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),Oe(e)},children:`+`}),t===`staged`||t===`both`?(0,X.jsx)(`button`,{type:`button`,className:`scm-act`,title:o(`scmUnstageTip`,{path:e.path}),onClick:t=>{t.stopPropagation(),ke(e)},children:`−`}):null]})]},e.path)}):(0,X.jsx)(`div`,{className:`scm-empty`,children:e.status===`open`?o(`scmLoading`):o(`scmConnecting`)})})]}),(0,X.jsx)(`div`,{className:`scm-divider`,role:`separator`,"aria-orientation":`vertical`,title:o(`dragToResize`),onPointerDown:ye,onDoubleClick:be}),(0,X.jsxs)(`div`,{className:`scm-diff`,children:[(0,X.jsxs)(`div`,{className:`scm-diff-header`,children:[(0,X.jsx)(`span`,{children:h===`history`?b?`${b.shortHash} ${b.subject}`:o(`scmCommitDetail`):E?E.path:o(`scmDiff`)}),(h===`history`?w:A)&&(0,X.jsx)(`span`,{className:`scm-diff-loading`,children:o(`scmLoading`)})]}),(0,X.jsx)(`div`,{className:`scm-diff-body`,children:h===`history`?(0,X.jsxs)(X.Fragment,{children:[P&&(0,X.jsx)(`div`,{className:`scm-error`,children:P}),!b&&!P&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectCommitHint`)}),b&&w&&!P&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),b&&!w&&!P&&S?Re(S):null]}):(0,X.jsxs)(X.Fragment,{children:[P&&(0,X.jsx)(`div`,{className:`scm-error`,children:P}),!E&&!P&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectFileHint`)}),E&&!O&&!P&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),E&&O&&O.untracked&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmUntrackedNote`)}),E&&O&&!O.untracked&&(0,X.jsxs)(X.Fragment,{children:[O.staged&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmStaged`)}),Re(O.staged)]}),O.worktree&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmUnstaged`)}),Re(O.worktree)]}),!O.staged&&!O.worktree&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoDiff`)})]})]})})]})]}),(0,X.jsxs)(`div`,{className:`scm-hint`,children:[(0,X.jsx)(z,{}),(0,X.jsx)(`span`,{children:o(`scmRunsInTerminal`)}),He(`host:scm-term`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:r,children:Ue(`host:scm-term`,o(`scmViewTerminal`))})]})]})}function $v({entry:e}){let t=(0,g.useRef)(null),n=Z();return(0,g.useEffect)(()=>{let r=t.current;if(!r)return;let i;try{i=e.module.mount(r,il(e.info.id,e=>$(e)))}catch(t){console.error(`[plugin:${e.info.id}] mount failed:`,t),r.textContent=n(`pluginMountFailed`,{name:e.info.name})}return()=>{if(typeof i==`function`)try{i()}catch(t){console.error(`[plugin:${e.info.id}] cleanup failed:`,t)}r.textContent=``}},[e]),(0,X.jsx)(`div`,{className:`plugin-view`,ref:t})}function ey({pluginId:e,info:t,epoch:n,failed:r}){let i=Z(),[a,o]=(0,g.useState)(!1),s=t?.name||e;return r?(0,X.jsx)(`div`,{className:`view-pane`,children:(0,X.jsxs)(`div`,{className:`plugin-view-fallback`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`plugin-view-fallback-title`,children:[i(`pluginViewLoadFailed`),`:`,s]}),(0,X.jsx)(`div`,{className:`plugin-view-fallback-hint`,children:i(`pluginViewLoadFailedHint`)}),t&&(0,X.jsx)(`button`,{type:`button`,className:`plugin-view-fallback-retry`,onClick:()=>{t&&!a&&(o(!0),Jc(t,n).finally(()=>o(!1)))},disabled:a,children:i(a?`pluginViewLoading`:`pluginViewRetry`)})]})}):(0,X.jsx)(`div`,{className:`view-pane`,children:(0,X.jsx)(`div`,{className:`plugin-view-fallback`,role:`status`,children:i(`pluginViewLoading`)})})}function ty({onAction:e}){let t=Aa(),n=(0,g.useMemo)(()=>t?La(t.entries):[],[t]),{items:r,selectParents:i}=(0,g.useMemo)(()=>Ia(n),[n]),a=(0,g.useMemo)(()=>Ra(r),[r]),o=(0,g.useMemo)(()=>t?Na(t.slot,t.target):void 0,[t,t?.slot,t?.target.kind]),s=(0,g.useRef)(null),c=(0,g.useRef)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(-1),[p,m]=(0,g.useState)(-1),[h,_]=(0,g.useState)(!1),[v,y]=(0,g.useState)(0),b=(0,g.useRef)(-1),x=e=>{b.current=e,f(e)},S=(0,g.useMemo)(()=>p>=0?La(r[p]?.children??[]):[],[r,p]),C=(0,g.useMemo)(()=>Ra(S),[S]),w=e=>{let n=r[e];if(t&&n&&!Fa(n,o)){if(n.children?.length){m(e);return}T(n,t)||Da()}},T=(t,n,r)=>t.source===`host`&&n.onHostAction?n.onHostAction(t,n.target)===!0:(e(t,n.target,r),!1),E=(0,g.useRef)(w);if((0,g.useLayoutEffect)(()=>{E.current=w}),(0,g.useEffect)(()=>{if(!t){b.current=-1,f(-1),m(-1);return}let e=Ba(r,-1,1,o);b.current=e,f(e),m(-1),s.current?.focus()},[t,r,o]),(0,g.useLayoutEffect)(()=>{if(!t){u(null);return}let e=s.current;if(!e)return;let n=e.getBoundingClientRect();u(Ma(t.x,t.y,n.width,n.height,window.innerWidth,window.innerHeight))},[t,r]),(0,g.useLayoutEffect)(()=>{let e=c.current,t=s.current;if(p<0||!e||!t){_(!1),y(0);return}let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth-r.right,a=r.left;_(i<n.width+8&&a>i);let o=n.bottom-(window.innerHeight-8);y(o>0?-Math.min(o,Math.max(0,n.top-8)):0)},[p,r]),(0,g.useEffect)(()=>{if(!t)return;let e=e=>s.current&&e instanceof Node&&s.current.contains(e),n=t=>{e(t.target)||Da()},r=t=>{e(t.target)||Da()},i=()=>Da();return document.addEventListener(`mousedown`,n,!0),window.addEventListener(`wheel`,r,!0),window.addEventListener(`resize`,i),()=>{document.removeEventListener(`mousedown`,n,!0),window.removeEventListener(`wheel`,r,!0),window.removeEventListener(`resize`,i)}},[t]),(0,g.useEffect)(()=>{if(!t)return;let e=e=>{let t=Ba(r,b.current,e,o);b.current=t,f(t)},n=t=>{switch(t.key){case`Escape`:t.preventDefault(),Da();return;case`Tab`:Da();return;case`ArrowDown`:t.preventDefault(),e(1);return;case`ArrowUp`:t.preventDefault(),e(-1);return;case`ArrowRight`:r[b.current]?.children?.length&&(t.preventDefault(),m(b.current));return;case`ArrowLeft`:p>=0&&(t.preventDefault(),m(-1));return;case`Enter`:case` `:t.preventDefault(),E.current(b.current);return;default:return}};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[t,r,p,o]),(0,g.useEffect)(()=>{d<0||s.current?.querySelector(`[data-ctx-active="true"]`)?.scrollIntoView?.({block:`nearest`})},[d]),!t)return null;let D=e=>{let n=i.get(e.id);if(n){if(Fa(n.parent,o))return;t&&!T(n.parent,t,n.value)&&Da();return}Fa(e,o)||T(e,t)||Da()},O=(e,t,n)=>{let r=Fa(e,o),i=!!e.children?.length,a=Ha(e.icon),s=n&&d===t;return(0,X.jsxs)(`div`,{className:`ctx-menu-itemwrap`,role:`none`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`ctx-menu-item${r?` disabled`:``}${s?` active`:``}${i?` has-sub`:``}`,"aria-label":e.label,title:e.hint,"aria-disabled":r||void 0,"aria-haspopup":i?`menu`:void 0,"aria-expanded":i?p===t:void 0,"data-ctx-active":s?`true`:void 0,onMouseEnter:n?()=>{x(t),i&&!r&&m(t)}:void 0,onClick:()=>n?w(t):D(e),children:[a?(0,X.jsx)(`span`,{className:`ctx-menu-icon`,"aria-hidden":`true`,children:a}):null,(0,X.jsx)(`span`,{className:`ctx-menu-label`,children:e.label}),e.badge?(0,X.jsx)(`span`,{className:`ctx-menu-badge`,children:e.badge}):null,i?(0,X.jsx)(`span`,{className:`ctx-menu-caret`,"aria-hidden":`true`,children:`▸`}):null]}),n&&i&&p===t?(0,X.jsx)(`div`,{ref:c,className:`ctx-menu-sub${h?` left`:``}`,role:`menu`,"aria-label":e.label,style:v?{marginTop:v}:void 0,children:C.map(e=>e.kind===`sep`?(0,X.jsx)(`div`,{className:`ctx-menu-sep`,role:`separator`},e.key):O(e.entry,e.index,!1))}):null]},`${e.id}#${t}`)};return(0,j.createPortal)((0,X.jsx)(`div`,{ref:s,className:`ctx-menu`,role:`menu`,"aria-label":t.target.label?`${t.slot}: ${t.target.label}`:t.slot,tabIndex:-1,style:{left:l?.x??t.x,top:l?.y??t.y,visibility:l?`visible`:`hidden`},onContextMenu:e=>{e.preventDefault(),e.stopPropagation()},children:a.map(e=>e.kind===`sep`?(0,X.jsx)(`div`,{className:`ctx-menu-sep`,role:`separator`},e.key):O(e.entry,e.index,!0))}),document.body)}var ny=0,ry=[],iy=new Map,ay=new Set;function oy(){for(let e of ay)try{e()}catch{}}function sy(e){let t=iy.get(e);t!==void 0&&(clearTimeout(t),iy.delete(e))}function cy(e){let t=e.id||`banner-${Date.now()}-${++ny}`,n={...e,id:t,type:e.type||`info`,persistent:!!e.persistent,timeoutMs:e.timeoutMs??5e3,dismissible:e.dismissible!==!1};if(sy(t),!n.persistent&&n.timeoutMs&&n.timeoutMs>0){let e=setTimeout(()=>{ly(t)},n.timeoutMs);iy.set(t,e)}let r=ry.findIndex(e=>e.id===t);if(r>=0){let e=[...ry];e[r]=n,ry=e}else ry=[...ry,n];return oy(),t}function ly(e,t){sy(e);let n=ry.find(t=>t.id===e);if(n){if(ry=ry.filter(t=>t.id!==e),!t?.silent)try{n.onClose?.()}catch{}oy()}}function uy(e,t){let n=ry.filter(e);if(n.length!==0){for(let e of n)if(sy(e.id),!t?.silent)try{e.onClose?.()}catch{}ry=ry.filter(t=>!e(t)),oy()}}function dy(){return ry}function fy(e){return ay.add(e),()=>{ay.delete(e)}}function py(){return(0,g.useSyncExternalStore)(fy,dy,dy)}function my({type:e}){switch(e){case`question`:return(0,X.jsx)(Ne,{className:`banner-icon banner-icon-question`});case`warning`:return(0,X.jsx)(wt,{className:`banner-icon banner-icon-warning`});case`error`:return(0,X.jsx)(Tt,{className:`banner-icon banner-icon-error`});case`success`:return(0,X.jsx)(pt,{className:`banner-icon banner-icon-success`});default:return(0,X.jsx)(je,{className:`banner-icon banner-icon-info`})}}var hy=(0,g.memo)(function({banner:e}){let t=typeof e.onClick==`function`;return(0,X.jsxs)(`div`,{className:`banner-card banner-type-${e.type||`info`} ${t?`banner-clickable`:``}`,onClick:t?e.onClick:void 0,role:t?`button`:`status`,tabIndex:t?0:void 0,onKeyDown:t?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onClick?.())}:void 0,children:[(0,X.jsx)(`div`,{className:`banner-icon-col`,children:(0,X.jsx)(my,{type:e.type})}),(0,X.jsxs)(`div`,{className:`banner-content-col`,children:[e.title&&(0,X.jsx)(`div`,{className:`banner-title`,title:e.title,children:e.title}),(0,X.jsx)(`div`,{className:`banner-message`,title:e.message,children:e.message})]}),e.dismissible&&(0,X.jsx)(`button`,{type:`button`,className:`banner-close`,onClick:t=>{t.stopPropagation(),ly(e.id)},"aria-label":`Close banner`,title:`关闭通知`,children:(0,X.jsx)(P,{})})]})}),gy=(0,g.memo)(function(){let e=py();return e.length===0?null:(0,X.jsx)(`aside`,{className:`banner-container`,"aria-label":`Notifications`,children:e.map(e=>(0,X.jsx)(hy,{banner:e},e.id))})}),_y={activity:(0,X.jsx)(Et,{}),branch:(0,X.jsx)(Le,{}),browser:(0,X.jsx)(Fe,{}),chat:(0,X.jsx)(J,{}),check:(0,X.jsx)(ft,{}),"chevron-up":(0,X.jsx)(ct,{}),clock:(0,X.jsx)(rt,{}),code:(0,X.jsx)(nt,{}),coins:(0,X.jsx)(Je,{}),copy:(0,X.jsx)(tt,{}),cpu:(0,X.jsx)(Ze,{}),cut:(0,X.jsx)(W,{}),database:(0,X.jsx)(Ye,{}),dot:(0,X.jsx)(`span`,{className:`host-icon-char`,children:`●`}),download:(0,X.jsx)(qe,{}),edit:(0,X.jsx)(Ke,{}),eye:(0,X.jsx)(Ue,{}),file:(0,X.jsx)(Be,{}),folder:(0,X.jsx)(Re,{}),gauge:(0,X.jsx)(Et,{}),git:(0,X.jsx)(Le,{}),github:(0,X.jsx)(Ie,{}),globe:(0,X.jsx)(Fe,{}),grid:(0,X.jsx)(Pe,{}),hash:(0,X.jsx)(`span`,{className:`host-icon-char`,children:`#`}),image:(0,X.jsx)(Me,{}),info:(0,X.jsx)(je,{}),layers:(0,X.jsx)(ke,{}),link:(0,X.jsx)(Oe,{}),list:(0,X.jsx)(De,{}),lock:(0,X.jsx)(Te,{}),markdown:(0,X.jsx)(Ve,{}),maximize:(0,X.jsx)(we,{}),menu:(0,X.jsx)(Se,{}),message:(0,X.jsx)(J,{}),open:(0,X.jsx)(Ge,{}),paste:(0,X.jsx)(it,{}),pin:(0,X.jsx)(Ct,{}),plus:(0,X.jsx)(me,{}),refresh:(0,X.jsx)(K,{}),save:(0,X.jsx)(pe,{}),search:(0,X.jsx)(fe,{}),send:(0,X.jsx)(de,{}),settings:(0,X.jsx)(ue,{}),sound:(0,X.jsx)(ne,{}),sun:(0,X.jsx)(B,{}),target:(0,X.jsx)(Xe,{}),terminal:(0,X.jsx)(z,{}),text:(0,X.jsx)(I,{}),trash:(0,X.jsx)(L,{}),undo:(0,X.jsx)(Qe,{}),upload:(0,X.jsx)(re,{}),volume:(0,X.jsx)(ne,{}),wrap:(0,X.jsx)(et,{}),x:(0,X.jsx)(P,{}),zap:(0,X.jsx)(N,{}),zoom:(0,X.jsx)(te,{})};Object.keys(_y);function vy(e){if(e.iconSvg)return(0,X.jsx)(hi,{icon:e.icon,iconSvg:e.iconSvg});if(!e.icon)return null;let t=_y[e.icon];return t===void 0?/[a-z]/i.test(e.icon)?null:(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:e.icon}):t}function yy({slots:e,layout:t,exclude:n,onClose:r}){let i=Z(),[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(null),l=(0,g.useMemo)(()=>bv(e,n),[e,n]),u=(0,g.useRef)(null),d=(0,g.useRef)(null),f=(0,g.useRef)(l),p=(0,g.useRef)(t),m=(0,g.useRef)(null);(0,g.useLayoutEffect)(()=>{f.current=l,p.current=t}),(0,g.useEffect)(()=>{m.current=null},[t]);let h=(e,t)=>{let n=document.elementFromPoint(e,t)?.closest(`[data-drop-slot]`);if(!n)return null;let r=n.dataset.dropSlot;if(!r)return null;let i=n.dataset.dropAlign,a=u.current,o=Array.from(n.querySelectorAll(`[data-chip]`)).filter(e=>e.dataset.chip!==a),s=o.length;for(let n=0;n<o.length;n++){let r=o[n].getBoundingClientRect();if(t<r.top){s=n;break}if(t<=r.bottom+4&&e<r.left+r.width/2){s=n;break}}return{slot:r,align:i,index:s}},_=()=>{let e=u.current,t=d.current;if(u.current=null,d.current=null,o(null),c(null),!e||!t)return;let n=m.current??p.current,r=t.slot===`__tray`?Ev(n,e):Tv(n,f.current,{id:e,slot:t.slot,...t.align===void 0?{}:{align:t.align},index:t.index});m.current=r,$({type:`set_settings`,uiLayout:r})};(0,g.useEffect)(()=>{if(!a)return;let e=e=>{e.preventDefault();let t=h(e.clientX,e.clientY);d.current=t,c(t)},t=()=>_();return window.addEventListener(`pointermove`,e,{passive:!1}),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[a]),zt(()=>{u.current||r()});let v=(e,t)=>{(e.pointerType!==`mouse`||e.button===0)&&(e.preventDefault(),u.current=t,d.current=null,o(t),c(null))},y=e=>(0,X.jsxs)(`button`,{type:`button`,"data-chip":e.id,className:`icon-editor-chip${a===e.id?` dragging`:``}`,title:e.label,onPointerDown:t=>v(t,e.id),children:[(0,X.jsx)(`span`,{className:`icon-editor-chip-icon`,children:vy(e)}),(0,X.jsx)(`span`,{className:`icon-editor-chip-label`,children:e.label})]},e.id),b=(e,t,n,r)=>{let o=s?.slot===e&&(s.align??null)===(t??null),c=r.map(y);return o&&s&&c.splice(Math.max(0,Math.min(s.index,c.length)),0,(0,X.jsx)(`span`,{className:`icon-editor-caret`,"aria-hidden":`true`},`__caret`)),(0,X.jsxs)(`div`,{className:`icon-editor-strip${o?` drop-over`:``}${a?` dragging-active`:``}`,"data-drop-slot":e,...t===void 0?{}:{"data-drop-align":t},children:[n!==null&&(0,X.jsx)(`span`,{className:`icon-editor-strip-label`,children:n}),c,r.length===0&&(0,X.jsx)(`span`,{className:`icon-editor-empty`,children:i(`uiIconEditDropHere`)})]},t??`__all`)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`icon-editor-backdrop`,onClick:r}),(0,X.jsxs)(`div`,{className:`icon-editor`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`uiIconEditTitle`),children:[(0,X.jsxs)(`div`,{className:`icon-editor-head`,children:[(0,X.jsx)(`span`,{className:`icon-editor-title`,children:i(`uiIconEditTitle`)}),(0,X.jsx)(`span`,{className:`icon-editor-hint`,children:i(`uiIconEditHint`)}),(0,X.jsx)(`button`,{type:`button`,className:`icon-editor-close`,onClick:r,"aria-label":i(`close`),title:i(`close`),children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`icon-editor-body`,children:[gv.map(e=>{let t=l.zones[e.slot]??[],n=Sv(t);return(0,X.jsxs)(`div`,{className:`icon-editor-zone`,children:[(0,X.jsxs)(`div`,{className:`icon-editor-zone-title`,children:[i(e.labelKey),a&&(0,X.jsx)(`span`,{className:`icon-editor-zone-count`,children:n.length})]}),e.alignable?vv.map(n=>b(e.slot,n,e.vertical?yv(i,n):n,Cv(t,n))):b(e.slot,void 0,null,n)]},e.slot)}),(0,X.jsxs)(`div`,{className:`icon-editor-zone icon-editor-zone-tray`,children:[(0,X.jsxs)(`div`,{className:`icon-editor-zone-title`,children:[i(`uiIconEditTray`),(0,X.jsx)(`span`,{className:`icon-editor-zone-count`,children:l.tray.length})]}),b(_v,void 0,null,l.tray)]})]})]})]})}function by(e,t){let n=(0,g.useRef)(``);(0,g.useEffect)(()=>{let r=$g(n.current,e);n.current=r.key,r.clear&&t()},[e,t])}var xy=new Map,Sy=-1;function Cy(e){let t=e.trim().toLowerCase();return t.startsWith(`.`)?t:`.${t}`}function wy(e){let t=e.replace(/\\/g,`/`).split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n).toLowerCase():``}function Ty(e,t){Sy!==t&&(Sy=t);let n=new Map;for(let t of e){let e=t;if(!e.error&&e.hasClient&&Array.isArray(e.fileHandlers)){for(let t of e.fileHandlers)if(t&&t.id&&Array.isArray(t.extensions))for(let r of t.extensions){if(typeof r!=`string`)continue;let i=Cy(r);if(!/^\.[a-z0-9][a-z0-9._-]*$/.test(i))continue;let a=n.get(i)??[];a.push({plugin:e,declaration:t}),n.set(i,a)}}}for(let e of n.values())e.sort((e,t)=>t.declaration.priority-e.declaration.priority||e.plugin.id.localeCompare(t.plugin.id));xy=n}function Ey(e){return xy.get(wy(e))?.[0]??null}async function Dy(e){let t=await el(e.plugin,Sy);if(!t)return null;let n=t.fileHandlers,r;if(Array.isArray(n))r=n.find(t=>t&&t.id===e.declaration.id),!r&&n.length===1&&typeof n[0]?.mount==`function`&&(r=n[0]);else if(n&&typeof n==`object`){r=n[e.declaration.id];let t=Object.values(n);!r&&t.length===1&&typeof t[0]?.mount==`function`&&(r=t[0])}return!r||typeof r.mount!=`function`?null:{handler:r,pluginId:e.plugin.id}}function Oy({provider:e,flow:t,result:n}){let r=Z(),i=t?.event,a=e.oauthName??e.name,[o,s]=(0,g.useState)(``);return(0,g.useEffect)(()=>s(``),[t?.promptId]),e.usingOAuth?(0,X.jsxs)(`div`,{className:`provider-oauth`,children:[(0,X.jsx)(`span`,{className:`provider-oauth-status`,children:r(`oauthConnected`,{name:a})}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-provider-oauth-logout":e.id,onClick:()=>$({type:`provider_oauth_logout`,provider:e.id}),children:r(`oauthLogout`)}),n?.error&&(0,X.jsx)(`div`,{className:`provider-oauth-error`,children:n.error})]}):(0,X.jsxs)(`div`,{className:`provider-oauth`,children:[t?(0,X.jsxs)(X.Fragment,{children:[i?.type===`device_code`&&(0,X.jsxs)(`div`,{className:`provider-oauth-device`,children:[(0,X.jsx)(`div`,{children:r(`oauthDeviceCode`)}),(0,X.jsx)(`code`,{"data-oauth-device-code":!0,children:i.userCode}),(0,X.jsx)(`a`,{"data-oauth-verification-url":!0,href:i.verificationUri,target:`_blank`,rel:`noreferrer`,children:r(`oauthOpenVerification`)})]}),i?.type===`auth_url`&&(0,X.jsxs)(`div`,{className:`provider-oauth-event`,children:[i.instructions&&(0,X.jsx)(`div`,{children:i.instructions}),(0,X.jsx)(`a`,{href:i.url,target:`_blank`,rel:`noreferrer`,children:r(`oauthOpenVerification`)})]}),i?.type===`progress`&&(0,X.jsx)(`div`,{className:`provider-oauth-message`,children:i.message}),i?.type===`info`&&(0,X.jsxs)(`div`,{className:`provider-oauth-event`,children:[(0,X.jsx)(`div`,{children:i.message}),i.links?.map(e=>(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:e.label??e.url},e.url))]}),t.prompt&&(0,X.jsx)(`div`,{className:`provider-oauth-message`,children:t.prompt.message}),t.prompt?.type===`select`&&t.promptId&&(0,X.jsx)(`div`,{className:`provider-oauth-options`,children:t.prompt.options.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,"data-oauth-option":e.id,onClick:()=>$({type:`provider_oauth_reply`,flowId:t.flowId,promptId:t.promptId,value:e.id}),children:e.label},e.id))}),t.prompt&&t.prompt.type!==`select`&&t.promptId&&(0,X.jsxs)(`form`,{className:`provider-oauth-prompt`,onSubmit:e=>{e.preventDefault(),o.trim()&&$({type:`provider_oauth_reply`,flowId:t.flowId,promptId:t.promptId,value:o.trim()})},children:[(0,X.jsx)(`input`,{"data-oauth-prompt-input":!0,type:t.prompt.type===`secret`?`password`:`text`,className:`key-input`,placeholder:t.prompt.placeholder,value:o,onChange:e=>s(e.target.value)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary sm`,"data-oauth-prompt-submit":!0,disabled:!o.trim(),children:r(`oauthContinue`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger`,"data-oauth-cancel":t.flowId,onClick:()=>$({type:`provider_oauth_cancel`,flowId:t.flowId}),children:r(`cancel`)})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,"data-provider-oauth-login":e.id,onClick:()=>$({type:`provider_oauth_start`,provider:e.id}),children:r(`oauthLogin`,{name:a})}),n?.error&&(0,X.jsx)(`div`,{className:`provider-oauth-error`,children:n.error})]})}function ky({piConfigured:e,piAgentInstalled:t,providers:n,providerOAuthFlows:r,providerOAuthResults:i,installResult:a,onClose:o}){let s=Z(),c=$a(),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(!1);(0,g.useEffect)(()=>{$({type:`list_providers`}),$({type:`list_provider_oauth_flows`})},[]),(0,g.useEffect)(()=>{e&&o()},[e,o]),(0,g.useEffect)(()=>{a&&u(!1)},[a]),(0,g.useEffect)(()=>{!d&&n.length>0&&f(n.find(e=>!e.configured)?.id??n[0].id)},[n,d]);let v=()=>{l||(u(!0),$({type:`install_pi_agent`}))},y=()=>{p.trim()&&!h&&(_(!0),$({type:`set_provider_api_key`,provider:d.trim(),apiKey:p.trim()}),setTimeout(()=>_(!1),3e3))},b=()=>{$({type:`get_state`}),$({type:`list_providers`})},x=n.find(e=>e.id===d),S=a!==null&&!a.ok;return(0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`modal setup-modal`,children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":s(`close`),onClick:o,children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ze,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:s(`setupTitle`)})]}),(0,X.jsx)(`p`,{className:`modal-desc`,children:s(`setupDesc`)}),S?(0,X.jsxs)(`div`,{className:`setup-failed`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:s(`installFailed`)}),(0,X.jsx)(`pre`,{className:`setup-detail`,children:a.detail}),(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:l,onClick:v,children:s(`retryInstall`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]})]}):t||a?.ok?(0,X.jsxs)(`div`,{className:`setup-key-form`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:a?.ok?s(`installDone`):s(`cliReadyHint`)}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:s(`provider`)}),(0,X.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),children:[n.length===0&&(0,X.jsx)(`option`,{value:``,children:s(`loading`)}),n.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name,`(`,e.id,`)`,e.configured?` · ${s(`configured`)}`:``]},e.id))]}),x?.configured&&(0,X.jsx)(`div`,{className:`field-hint`,children:s(`providerKeyReady`)})]}),x?.supportsOAuth&&(0,X.jsx)(Oy,{provider:x,flow:r.find(e=>e.provider===x.id),result:i[x.id]}),x?.supportsApiKey&&(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:s(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:`sk-…`})]}),(0,X.jsxs)(`div`,{className:`setup-actions`,children:[x?.supportsApiKey&&(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!p.trim()||h||!d,onClick:y,children:s(h?`saving`:`saveAndStart`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:b,children:[(0,X.jsx)(K,{}),` `,s(`recheck`)]})]})]}):c?(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`div`,{className:`setup-done`,children:s(`updatesManaged`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]}):(0,X.jsxs)(`div`,{className:`setup-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:l,onClick:v,children:s(l?`installing`:`autoInstall`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:o,children:s(`skip`)})]})]})})}var Ay=[`openai-completions`,`openai-responses`,`anthropic-messages`,`google-generative-ai`],jy=[{id:`deepseek`,name:`DeepSeek`,api:`openai-completions`,baseUrl:`https://api.deepseek.com/v1`,authHeader:!0,tag:`官方`},{id:`openrouter`,name:`OpenRouter`,api:`openai-completions`,baseUrl:`https://openrouter.ai/api/v1`,authHeader:!0,tag:`聚合`},{id:`moonshot`,name:`Moonshot (Kimi)`,api:`openai-completions`,baseUrl:`https://api.moonshot.cn/v1`,authHeader:!0,tag:`官方`},{id:`zhipu`,name:`智谱 GLM`,api:`openai-completions`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,authHeader:!0,tag:`官方`},{id:`siliconflow`,name:`硅基流动`,api:`openai-completions`,baseUrl:`https://api.siliconflow.cn/v1`,authHeader:!0,tag:`云端`},{id:`ollama`,name:`Ollama`,api:`openai-completions`,baseUrl:`http://127.0.0.1:11434/v1`,authHeader:!0,tag:`本地`},{id:`vllm`,name:`vLLM / LM Studio`,api:`openai-completions`,baseUrl:`http://127.0.0.1:8000/v1`,authHeader:!0,tag:`本地`},{id:`antigravity`,name:`Antigravity (OpenAI)`,api:`openai-completions`,baseUrl:`http://127.0.0.1:8045/v1`,authHeader:!0,tag:`反代`},{id:`antigravity-anthropic`,name:`Antigravity (Anthropic)`,api:`anthropic-messages`,baseUrl:`http://127.0.0.1:8045`,authHeader:!0,tag:`反代`}],My=[{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`},{label:`128K`,value:`131072`},{label:`200K`,value:`200000`},{label:`1M`,value:`1000000`}],Ny=[{label:`2K`,value:`2048`},{label:`4K`,value:`4096`},{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`}],Py=()=>({id:``,name:``,reasoning:!1,input:`text`,contextWindow:``,maxTokens:``}),Fy=()=>({providerId:``,name:``,api:`openai-completions`,baseUrl:``,apiKey:``,hasApiKey:!1,authHeader:!0,models:[Py()]});function Iy(e){return{providerId:e.providerId,name:e.name??``,api:e.api??`openai-completions`,baseUrl:e.baseUrl??``,apiKey:``,hasApiKey:e.hasApiKey??!1,authHeader:e.authHeader??!1,models:(e.models.length?e.models:[Py()]).map(e=>({id:e.id,name:e.name??``,reasoning:e.reasoning??!1,input:e.input?.includes(`image`)?`text-image`:`text`,contextWindow:e.contextWindow?String(e.contextWindow):``,maxTokens:e.maxTokens?String(e.maxTokens):``}))}}function Ly(e){let t={};for(let n of e.split(`
363
+ `)){let e=n.indexOf(`=`);if(e<=0)continue;let r=n.slice(0,e).trim(),i=n.slice(e+1).trim();r&&i&&(t[r]=i)}return t}function Ry({candidates:e,onAdopt:t,onClose:n}){let r=Z(),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(()=>{let t=new Set;for(let n of e){let e=n.id.toLowerCase();!e.includes(`embed`)&&!e.includes(`audio`)&&!e.includes(`tts`)&&!e.includes(`whisper`)&&t.add(n.id)}if(t.size===0)for(let n of e)t.add(n.id);return t}),c=(0,g.useMemo)(()=>{let t=i.trim().toLowerCase();return t?e.filter(e=>e.id.toLowerCase().includes(t)||e.name&&e.name.toLowerCase().includes(t)):e},[e,i]),l=e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,X.jsx)(`div`,{className:`candidate-picker-backdrop`,onClick:n,children:(0,X.jsxs)(`div`,{className:`candidate-picker-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`candidate-header`,children:[(0,X.jsxs)(`div`,{className:`candidate-title-group`,children:[(0,X.jsx)(`span`,{className:`candidate-title`,children:`候选模型采纳器 (Candidate Picker)`}),(0,X.jsxs)(`span`,{className:`candidate-subtitle`,children:[`已探测到 `,e.length,` 个模型,请勾选需要采纳的模型`]})]}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,onClick:n,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`candidate-filter-bar`,children:[(0,X.jsx)(fe,{style:{color:`var(--text-faint)`,flexShrink:0}}),(0,X.jsx)(`input`,{type:`text`,className:`candidate-search-input`,placeholder:`搜索模型 ID 或名称…`,value:i,onChange:e=>a(e.target.value),autoFocus:!0}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:6,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{s(new Set(c.map(e=>e.id)))},children:`全选`}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{s(new Set)},children:`全不选`})]})]}),(0,X.jsxs)(`div`,{className:`candidate-list-scroll`,children:[c.length===0&&(0,X.jsx)(`div`,{style:{padding:`32px 0`,textAlign:`center`,color:`var(--text-faint)`,fontSize:13},children:`未匹配到模型`}),c.map(e=>{let t=o.has(e.id);return(0,X.jsxs)(`div`,{className:`candidate-item-card ${t?`selected`:``}`,onClick:()=>l(e.id),children:[(0,X.jsxs)(`div`,{className:`candidate-item-left`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`candidate-checkbox`,checked:t,onChange:()=>{},onClick:e=>e.stopPropagation()}),(0,X.jsxs)(`div`,{className:`candidate-id-info`,children:[(0,X.jsx)(`span`,{className:`candidate-id-name`,children:e.id}),e.name&&e.name!==e.id&&(0,X.jsx)(`span`,{style:{fontSize:11.5,color:`var(--text-dim)`},children:e.name})]})]}),(0,X.jsxs)(`div`,{className:`candidate-item-meta`,children:[e.contextWindow&&(0,X.jsx)(`span`,{className:`spec-badge ctx`,title:`上下文窗口`,children:e.contextWindow>=1e6?`${Math.round(e.contextWindow/1e6)}M`:`${Math.round(e.contextWindow/1024)}K`}),e.reasoning&&(0,X.jsxs)(`span`,{className:`spec-badge reasoning`,title:`支持深度思考 / 推理`,children:[(0,X.jsx)(N,{}),` 推理`]}),e.input?.includes(`image`)&&(0,X.jsx)(`span`,{className:`spec-badge vision`,title:`支持图像视觉`,children:`视觉`})]})]},e.id)})]}),(0,X.jsxs)(`div`,{className:`candidate-actions-footer`,children:[(0,X.jsxs)(`span`,{className:`candidate-select-summary`,children:[`已勾选 `,o.size,` / `,e.length,` 个模型`]}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:8},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:n,children:r(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:o.size===0,onClick:()=>{t(e.filter(e=>o.has(e.id)))},children:[`采纳所选模型 (`,o.size,`)`]})]})]})]})})}function zy({providers:e,providerStatus:t,providerKeys:n,providerOAuthFlows:r,providerOAuthResults:i,fetchModelsResult:a,testModelConnectionResult:o,enrichModelsResult:s,enrichModelsProgress:c,cloneProviderResult:l,refreshBuiltinResult:u,refreshProviderResult:d,appendBuiltinResult:f,defaultModel:p,onClose:m}){let h=Z(),[_,v]=(0,g.useState)(()=>e.length>0?{type:`custom`,id:e[0].providerId}:t.length>0?{type:`builtin`,id:t[0].id}:{type:`custom`,id:``}),[y,b]=(0,g.useState)(()=>e.length>0?Iy(e[0]):t.length>0?null:Fy()),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(0),[D,O]=(0,g.useState)(null),k=(0,g.useRef)(0),[A,j]=(0,g.useState)({}),[ee,M]=(0,g.useState)({}),[te,N]=(0,g.useState)(null),ne=(0,g.useRef)(n),F=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=te;e&&n[e]!==ne.current[e]&&(N(null),j(t=>({...t,[e]:``})),M(t=>({...t,[e]:``})),F.current&&clearTimeout(F.current)),ne.current=n},[n,te]),(0,g.useEffect)(()=>()=>{F.current&&clearTimeout(F.current)},[]);let[re,ie]=(0,g.useState)(!1),[ae,I]=(0,g.useState)(0),[R,z]=(0,g.useState)(null),oe=(0,g.useRef)(0),[B,V]=(0,g.useState)(!1),[H,se]=(0,g.useState)(!1),[ce,le]=(0,g.useState)(0),[ue,U]=(0,g.useState)(null),[de,fe]=(0,g.useState)([]),[W]=(0,g.useState)(``),pe=(0,g.useRef)(0),[G,he]=(0,g.useState)(!1),[ge,q]=(0,g.useState)(0),[_e,ve]=(0,g.useState)(null),ye=(0,g.useRef)(0),[be,xe]=(0,g.useState)(null),[J,Se]=(0,g.useState)(``),[Ce,we]=(0,g.useState)(``),[Te,Ee]=(0,g.useState)(``),[De,Oe]=(0,g.useState)(``),[ke,Ae]=(0,g.useState)(!1),[je,Me]=(0,g.useState)(0),[Ne,Pe]=(0,g.useState)(null),Fe=(0,g.useRef)(0),[Ie,Le]=(0,g.useState)(null),[Re,ze]=(0,g.useState)(``),[Be,Ve]=(0,g.useState)(null),[He,Ue]=(0,g.useState)({}),We=(0,g.useRef)(0),Ge=(0,g.useRef)(0),[Y,Ke]=(0,g.useState)(null),Je=(0,g.useRef)(0),Ye=(0,g.useRef)(0),Xe=e=>{if(He[e])return;let t=++We.current+Date.now();Ue(t=>({...t,[e]:!0})),$({type:`refresh_provider_models`,providerId:e,reqId:t})};(0,g.useEffect)(()=>{d&&d.reqId!==Ge.current&&(Ge.current=d.reqId,Ue({}))},[d]);let Qe=e=>{if(Y)return;Ke(e.id);let t=++Je.current+Date.now();$({type:`clone_provider`,provider:e.id,reqId:t})||Ke(null)};(0,g.useEffect)(()=>{$({type:`list_models_config`}),$({type:`list_providers`}),$({type:`list_provider_keys`}),$({type:`list_provider_oauth_flows`})},[]),(0,g.useEffect)(()=>{o&&o.reqId!==k.current&&(k.current=o.reqId,w(!1),O({ok:o.ok,latencyMs:o.latencyMs,error:o.error}))},[o]),(0,g.useEffect)(()=>{a&&a.reqId!==oe.current&&(oe.current=a.reqId,ie(!1),a.ok&&a.models?.length?(S(a.models),z({ok:!0,text:h(`fetchModelsOk`,{n:a.models.length})})):z({ok:!1,text:a.error||h(`fetchModelsEmpty`)}))},[a,h]),(0,g.useEffect)(()=>{if(s&&s.reqId!==pe.current){if(pe.current=s.reqId,V(!1),se(!1),s.ok&&s.results?.length){let e=s.results,t=new Map(e.map(e=>[e.id.trim(),e]));b(e=>e&&{...e,models:e.models.map(e=>{let n=t.get(e.id.trim());return!n||n.status!==`matched`?e:{...e,name:e.name||n.name||``,contextWindow:e.contextWindow||(n.contextWindow?String(n.contextWindow):``),maxTokens:e.maxTokens||(n.maxTokens?String(n.maxTokens):``),input:e.input===`text`&&n.input?.includes(`image`)?`text-image`:e.input,reasoning:e.reasoning||(n.reasoning??!1),src:n.source}})});let n=e.filter(e=>e.status===`matched`).length,r=e.length-n;U({ok:!0,text:h(`enrichModelsOk`,{n,m:r})});let i=e.filter(e=>e.status!==`matched`&&(e.suggestions?.length||e.note)).map(e=>({id:e.id,suggestions:e.suggestions??[],note:e.note}));fe(i)}else U({ok:!1,text:s.error||h(`enrichModelsErr`,{msg:``})})}},[s,h]),(0,g.useEffect)(()=>{u&&u.reqId!==ye.current&&(ye.current=u.reqId,he(!1),u.ok?ve({ok:!0,text:h(`refreshBuiltinOk`)}):ve({ok:!1,text:u.error||h(`refreshBuiltinFail`)}))},[u,h]),(0,g.useEffect)(()=>{f&&f.reqId!==Fe.current&&(Fe.current=f.reqId,Ae(!1),f.ok?(Pe({ok:!0,text:h(`appendModelOk`)}),Se(``),we(``),Ee(``),Oe(``),xe(null),$({type:`list_models_config`})):Pe({ok:!1,text:f.error||h(`appendModelFail`)}))},[f,h]),(0,g.useEffect)(()=>{if(l&&l.reqId!==Ye.current&&(Ye.current=l.reqId,Ke(null),l.ok)){let e=l.configs;if(e&&e.length>1){Le(e.map(e=>Iy(e))),ze(``);return}l.config&&Ve(Iy(l.config))}},[l]);let $e=()=>{if(!y)return;let e=y.baseUrl.trim();if(!e){O({ok:!1,error:h(`fetchModelsNeedBaseUrl`)});return}w(!0),O(null);let t=T+1;E(t),$({type:`test_model_connection`,reqId:t,baseUrl:e,apiKey:y.apiKey.trim()||void 0,...y.apiKey.trim()?{}:y.hasApiKey?{providerId:y.providerId.trim()}:{},authHeader:y.authHeader,api:y.api})},et=()=>{if(!y)return;let e=y.baseUrl.trim();if(!e){z({ok:!1,text:h(`fetchModelsNeedBaseUrl`)});return}if(re)return;ie(!0),z(null);let t=ae+1;I(t),$({type:`fetch_models`,reqId:t,baseUrl:e,apiKey:y.apiKey.trim()||void 0,...y.apiKey.trim()?{}:y.hasApiKey?{providerId:y.providerId.trim()}:{},authHeader:y.authHeader,api:y.api})},nt=e=>{y&&(b(t=>{if(!t)return t;let n=t.models.filter(e=>e.id.trim()),r=new Set(n.map(e=>e.id.trim())),i=e.filter(e=>!r.has(e.id)).map(e=>({id:e.id,name:e.name??``,reasoning:e.reasoning??!1,input:e.input?.includes(`image`)?`text-image`:`text`,contextWindow:e.contextWindow?String(e.contextWindow):``,maxTokens:e.maxTokens?String(e.maxTokens):``}));return{...t,models:n.length===0?i:[...n,...i]}}),S(null))},rt=()=>{if(!y||B)return;let e=y.models.map(e=>e.id.trim()).filter(Boolean);if(e.length===0){U({ok:!1,text:h(`enrichModelsNeedIds`)});return}V(!0),se(!1),U(null),fe([]);let t=ce+1;le(t),$({type:`enrich_models`,reqId:t,ids:e,hints:Ly(W)})},it=()=>{B&&!H&&(se(!0),$({type:`abort_enrich_models`,reqId:ce}))},at=e=>{b(t=>({providerId:t?.providerId.trim()||e.id,name:t?.name.trim()||e.name,api:e.api,baseUrl:e.baseUrl,apiKey:t?.apiKey||``,hasApiKey:t?.hasApiKey??!1,authHeader:e.authHeader,models:t?.models.length?t.models:[Py()]})),O(null),z(null)},ot=()=>{if(!y)return;let e=y.providerId.trim();if(!e)return;let t=y.models.filter(e=>e.id.trim()).map(e=>({id:e.id.trim(),name:e.name.trim()||void 0,reasoning:e.reasoning||void 0,input:e.input===`text-image`?[`text`,`image`]:void 0,contextWindow:e.contextWindow?Number(e.contextWindow):void 0,maxTokens:e.maxTokens?Number(e.maxTokens):void 0}));$({type:`save_model_config`,providerId:e,config:{providerId:e,name:y.name.trim()||void 0,api:y.api.trim()||void 0,baseUrl:y.baseUrl.trim()||void 0,...y.apiKey.trim()?{apiKey:y.apiKey.trim()}:{},authHeader:y.authHeader||void 0,models:t}}),m()},st=(e,t)=>{y&&b({...y,models:y.models.map((n,r)=>r===e?{...n,...t}:n)})},ct=()=>{y&&b({...y,models:[...y.models,Py()]})},lt=e=>{y&&b({...y,models:y.models.filter((t,n)=>n!==e)})},ut=e=>{let t=(A[e.id]??``).trim();t&&!te&&(N(e.id),$({type:`add_provider_key`,provider:e.id,apiKey:t,name:(ee[e.id]??``).trim()||void 0}),F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{N(t=>t===e.id?null:t)},1e4))},dt=(e,t)=>{$({type:`activate_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`})},pt=(e,t)=>{window.confirm(h(`removeKeyConfirm`))&&($({type:`remove_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`}))},mt=e=>{window.confirm(h(`clearKeyConfirm`,{id:e}))&&$({type:`clear_provider_api_key`,provider:e})},ht=t=>{if(window.confirm(h(`deleteProviderConfirm`,{id:t.providerId,n:t.models.length}))&&($({type:`delete_model_config`,providerId:t.providerId}),_.type===`custom`&&_.id===t.providerId)){let n=e.filter(e=>e.providerId!==t.providerId);n.length>0?(v({type:`custom`,id:n[0].providerId}),b(Iy(n[0]))):(v({type:`custom`,id:``}),b(Fy()))}},gt=e=>{let t=J.trim();if(!t||ke)return;Ae(!0),Pe(null);let n=je+1;Me(n),$({type:`append_builtin_model`,providerId:e,model:{id:t,...Ce.trim()?{name:Ce.trim()}:{},...Te?{api:Te}:{},...De.trim()?{baseUrl:De.trim()}:{}},reqId:n})};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:m,children:(0,X.jsxs)(`div`,{className:`modal model-studio-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`studio-header`,children:[(0,X.jsxs)(`div`,{className:`studio-header-left`,children:[(0,X.jsx)(`div`,{className:`studio-header-icon-box`,children:(0,X.jsx)(Ze,{})}),(0,X.jsxs)(`div`,{className:`studio-header-title-wrap`,children:[(0,X.jsx)(`h2`,{className:`studio-header-title`,children:`模型管理`}),(0,X.jsx)(`span`,{className:`studio-header-badge`,children:`Studio`})]})]}),(0,X.jsxs)(`div`,{className:`studio-header-actions`,children:[p!==void 0&&p&&(0,X.jsxs)(`div`,{style:{display:`inline-flex`,alignItems:`center`,gap:5,padding:`3px 8px`,borderRadius:6,background:`rgba(251, 191, 36, 0.08)`,border:`1px solid rgba(251, 191, 36, 0.3)`,fontSize:11.5,color:`var(--amber)`},title:`全局默认模型: ${p}`,children:[(0,X.jsx)(`span`,{children:`★`}),(0,X.jsx)(`span`,{style:{maxWidth:120,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`var(--mono)`},children:p.split(`/`).slice(1).join(`/`)}),(0,X.jsx)(`button`,{type:`button`,style:{background:`transparent`,border:`none`,color:`var(--amber)`,cursor:`pointer`,fontSize:10,padding:`0 2px`,opacity:.7},title:`清除全局默认模型`,onClick:()=>$({type:`clear_default_model`}),children:`✕`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`studio-header-btn`,title:h(`refreshBuiltinHint`),disabled:G,onClick:()=>{if(G)return;he(!0),ve(null);let e=ge+1;q(e),$({type:`refresh_builtin_models`,reqId:e})},children:[(0,X.jsx)(qe,{}),(0,X.jsx)(`span`,{children:G?h(`refreshBuiltinBusy`):`刷新官方目录`})]}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn`,title:h(`reloadModelsHint`),onClick:()=>$({type:`reload_models_config`}),children:(0,X.jsx)(K,{})}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn close-btn`,"aria-label":h(`close`),onClick:m,children:(0,X.jsx)(P,{})})]})]}),_e&&(0,X.jsx)(`div`,{style:{padding:`6px 20px`,background:`var(--bg-elev2)`,fontSize:12,borderBottom:`1px solid var(--border-soft)`},children:(0,X.jsx)(`span`,{className:`fetch-msg ${_e.ok?`ok`:`err`}`,children:_e.text})}),(0,X.jsxs)(`div`,{className:`model-studio-body`,children:[(0,X.jsxs)(`div`,{className:`model-studio-sidebar`,children:[(0,X.jsx)(`div`,{style:{padding:`12px 10px 6px`},children:(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,style:{width:`100%`,justifyContent:`center`},onClick:()=>{v({type:`custom`,id:``}),b(Fy()),O(null),z(null)},children:[(0,X.jsx)(me,{}),` 添加自定义服务商`]})}),(0,X.jsxs)(`div`,{className:`studio-sidebar-section`,children:[(0,X.jsxs)(`span`,{className:`studio-sidebar-title`,children:[`自定义服务商 (`,e.length,`)`]}),e.length===0&&(0,X.jsx)(`div`,{style:{fontSize:11.5,color:`var(--text-faint)`,padding:`6px 8px`},children:`暂无配置`}),e.map(e=>{let t=_.type===`custom`&&_.id===e.providerId;return(0,X.jsxs)(`div`,{className:`studio-nav-item ${t?`active`:``}`,onClick:()=>{v({type:`custom`,id:e.providerId}),b(Iy(e)),O(null),z(null)},children:[(0,X.jsxs)(`span`,{className:`studio-nav-label`,children:[(0,X.jsx)(`span`,{className:`studio-nav-dot configured`}),(0,X.jsx)(`span`,{children:e.name||e.providerId})]}),(0,X.jsxs)(`span`,{style:{fontSize:10.5,color:`var(--text-faint)`,fontFamily:`var(--mono)`},children:[e.models.length,`m`]})]},e.providerId)})]}),(0,X.jsxs)(`div`,{className:`studio-sidebar-section`,children:[(0,X.jsxs)(`span`,{className:`studio-sidebar-title`,children:[`官方内置服务商 (`,t.length,`)`]}),t.map(e=>{let t=_.type===`builtin`&&_.id===e.id,r=n[e.id]??[];return(0,X.jsxs)(`div`,{className:`studio-nav-item ${t?`active`:``}`,onClick:()=>{v({type:`builtin`,id:e.id}),b(null)},children:[(0,X.jsxs)(`span`,{className:`studio-nav-label`,children:[(0,X.jsx)(`span`,{className:`studio-nav-dot ${e.configured?`configured`:``}`}),(0,X.jsx)(`span`,{children:e.name})]}),r.length>0&&(0,X.jsxs)(`span`,{style:{fontSize:10.5,color:`var(--text-faint)`,fontFamily:`var(--mono)`},children:[r.length,`k`]})]},e.id)})]})]}),(0,X.jsxs)(`div`,{className:`model-studio-main`,children:[y&&(0,X.jsxs)(`div`,{className:`studio-card`,children:[(0,X.jsxs)(`div`,{className:`studio-card-head`,children:[(0,X.jsxs)(`div`,{className:`studio-card-title`,children:[(0,X.jsx)(`span`,{children:y.providerId?`编辑服务商:${y.providerId}`:`新建自定义服务商`}),y.providerId&&e.some(e=>e.providerId===y.providerId)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`iconbtn sm`,title:h(`refreshModels`),disabled:He[y.providerId],onClick:()=>Xe(y.providerId),children:(0,X.jsx)(K,{className:He[y.providerId]?`spin`:``})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger sm`,title:`删除此服务商`,onClick:()=>{let t=e.find(e=>e.providerId===y.providerId);t&&ht(t)},children:(0,X.jsx)(L,{})})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,X.jsxs)(`div`,{className:`conn-test-box`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`conn-test-btn`,disabled:C||!y.baseUrl.trim(),onClick:$e,children:[(0,X.jsx)(Et,{}),` `,C?`测试中…`:`测试连接`]}),D&&(0,X.jsxs)(`span`,{className:`ping-indicator ${D.ok?`ok`:`err`}`,children:[(0,X.jsx)(`span`,{className:`ping-dot`}),(0,X.jsx)(`span`,{children:D.ok?`${D.latencyMs??0}ms 连通正常`:`连接失败`})]})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,onClick:ot,children:h(`save`)})]})]}),(0,X.jsxs)(`div`,{className:`quick-chips-wrapper`,children:[(0,X.jsx)(`span`,{className:`quick-chips-label`,children:`快捷预设模板 (Quick Presets)`}),(0,X.jsx)(`div`,{className:`quick-chips-grid`,children:jy.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`quick-chip`,onClick:()=>at(e),children:[(0,X.jsx)(`span`,{className:`quick-chip-name`,children:e.name}),e.tag&&(0,X.jsx)(`span`,{className:`quick-chip-tag`,children:e.tag})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`form-grid`,children:[(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[h(`providerId`),` `,(0,X.jsx)(`em`,{children:h(`providerIdHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:y.providerId,disabled:e.some(e=>e.providerId===y.providerId),onChange:e=>b({...y,providerId:e.target.value}),placeholder:`例如 deepseek`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`displayName`)}),(0,X.jsx)(`input`,{type:`text`,value:y.name,onChange:e=>b({...y,name:e.target.value}),placeholder:h(`displayNamePh`)})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`apiType`)}),(0,X.jsx)(`select`,{value:y.api,onChange:e=>b({...y,api:e.target.value}),children:Ay.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[`baseUrl `,(0,X.jsx)(`em`,{children:h(`baseUrlHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:y.baseUrl,onChange:e=>b({...y,baseUrl:e.target.value}),placeholder:`https://api.deepseek.com/v1`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:h(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:y.apiKey,onChange:e=>b({...y,apiKey:e.target.value}),placeholder:y.hasApiKey?h(`apiKeySavedHint`):h(`apiKeyHint`)})]}),(0,X.jsxs)(`label`,{className:`field check`,style:{alignSelf:`center`,paddingTop:16},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:y.authHeader,onChange:e=>b({...y,authHeader:e.target.checked})}),(0,X.jsx)(`span`,{children:h(`authHeader`)})]})]}),(0,X.jsxs)(`div`,{style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`model-section-head`,children:[(0,X.jsxs)(`span`,{className:`form-section-title`,style:{fontSize:13,fontWeight:600},children:[`模型矩阵 (`,y.models.filter(e=>e.id.trim()).length,`)`]}),(0,X.jsxs)(`div`,{className:`model-section-actions`,children:[R&&(0,X.jsx)(`span`,{className:`fetch-msg ${R.ok?`ok`:`err`}`,title:R.text,children:R.text}),ue&&(0,X.jsx)(`span`,{className:`fetch-msg ${ue.ok?`ok`:`err`}`,title:ue.text,children:ue.text}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:re||!y.baseUrl.trim(),title:h(`fetchModelsHint`),onClick:et,children:[(0,X.jsx)(qe,{}),` `,re?h(`fetchingModels`):`自动获取并采纳模型`]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:B,title:h(`enrichModelsHint`),onClick:rt,children:[(0,X.jsx)(qe,{}),` `,h(B?`enrichingModels`:`enrichModels`)]}),B&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:H,title:h(`enrichModelsAbort`),onClick:it,style:{color:`var(--red)`},children:[(0,X.jsx)(P,{}),` `,h(H?`enrichCancelling`:`enrichModelsCancel`)]})]})]}),(0,X.jsxs)(`div`,{className:`model-matrix-list`,children:[y.models.map((e,t)=>(0,X.jsxs)(`div`,{className:`model-matrix-card`,children:[(0,X.jsxs)(`div`,{className:`matrix-main-row`,children:[(0,X.jsxs)(`div`,{className:`matrix-input-group id-group`,children:[(0,X.jsxs)(`span`,{className:`matrix-input-prefix`,children:[(0,X.jsx)(Ze,{}),` ID`]}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field mono`,value:e.id,onChange:e=>st(t,{id:e.target.value}),placeholder:`例如 deepseek-chat`})]}),(0,X.jsxs)(`div`,{className:`matrix-input-group name-group`,children:[(0,X.jsx)(`span`,{className:`matrix-input-prefix`,children:`别名`}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field`,value:e.name,onChange:e=>st(t,{name:e.target.value}),placeholder:`显示名称 (选填)`})]}),(0,X.jsxs)(`div`,{className:`matrix-toggles`,children:[(0,X.jsx)(`button`,{type:`button`,className:`matrix-toggle-tag ${e.input===`text-image`?`active vision`:``}`,onClick:()=>st(t,{input:e.input===`text-image`?`text`:`text-image`}),title:`是否支持图像识图输入`,children:`🖼 视觉`}),(0,X.jsx)(`button`,{type:`button`,className:`matrix-toggle-tag ${e.reasoning?`active reasoning`:``}`,onClick:()=>st(t,{reasoning:!e.reasoning}),title:`是否支持深度思考推理`,children:`⚡ 推理`}),p!==void 0&&e.id.trim()&&(()=>{let t=`${y.providerId}/${e.id.trim()}`,n=p===t||p===e.id.trim();return(0,X.jsxs)(`button`,{type:`button`,className:`matrix-star-btn ${n?`active`:``}`,title:n?`当前全局默认模型(点击取消默认)`:`设为全局默认模型`,onClick:()=>{$(n?{type:`clear_default_model`}:{type:`set_default_model`,modelId:t})},children:[(0,X.jsx)(`span`,{className:`matrix-star-icon`,children:n?`★`:`☆`}),(0,X.jsx)(`span`,{children:n?`默认`:`设为默认`})]})})(),(0,X.jsx)(`button`,{type:`button`,className:`matrix-delete-btn`,title:h(`delete`),onClick:()=>lt(t),children:(0,X.jsx)(L,{})})]})]}),(0,X.jsxs)(`div`,{className:`matrix-spec-bar`,children:[(0,X.jsxs)(`div`,{className:`spec-combobox`,children:[(0,X.jsx)(`span`,{className:`spec-combobox-label`,children:`上下文`}),(0,X.jsxs)(`select`,{className:`spec-combobox-select`,value:My.some(t=>t.value===e.contextWindow)?e.contextWindow:`custom`,onChange:e=>{e.target.value!==`custom`&&st(t,{contextWindow:e.target.value})},children:[My.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[e.label,` (`,Math.round(Number(e.value)/1024),`K)`]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:`自定义…`})]}),(!My.some(t=>t.value===e.contextWindow)||e.contextWindow===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.contextWindow,onChange:e=>st(t,{contextWindow:e.target.value}),placeholder:`如 131072`})]}),(0,X.jsxs)(`div`,{className:`spec-combobox`,children:[(0,X.jsx)(`span`,{className:`spec-combobox-label`,children:`最大输出`}),(0,X.jsxs)(`select`,{className:`spec-combobox-select`,value:Ny.some(t=>t.value===e.maxTokens)?e.maxTokens:`custom`,onChange:e=>{e.target.value!==`custom`&&st(t,{maxTokens:e.target.value})},children:[Ny.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[e.label,` (`,Math.round(Number(e.value)/1024),`K)`]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:`自定义…`})]}),(!Ny.some(t=>t.value===e.maxTokens)||e.maxTokens===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.maxTokens,onChange:e=>st(t,{maxTokens:e.target.value}),placeholder:`如 8192`})]}),(0,X.jsx)(`div`,{className:`matrix-spec-quick-pills`,children:[`32K`,`128K`,`200K`].map(n=>{let r=My.find(e=>e.label===n);return r?(0,X.jsx)(`button`,{type:`button`,className:`param-pill ${e.contextWindow===r.value?`active`:``}`,onClick:()=>st(t,{contextWindow:r.value}),title:`快捷设为 ${n} 上下文`,children:n},n):null})})]})]},t)),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,style:{alignSelf:`flex-start`,marginTop:4},onClick:ct,children:[(0,X.jsx)(me,{}),` 添加模型行`]})]})]})]}),_.type===`builtin`&&(()=>{let e=t.find(e=>e.id===_.id);if(!e)return null;let a=n[e.id]??[];return(0,X.jsxs)(`div`,{className:`studio-card`,children:[(0,X.jsxs)(`div`,{className:`studio-card-head`,children:[(0,X.jsxs)(`div`,{className:`studio-card-title`,children:[(0,X.jsxs)(`span`,{children:[`官方内置服务商:`,e.name]}),e.configured&&(0,X.jsx)(`span`,{className:`auth-badge`,children:h(`configuredBadge`)}),e.source&&!e.configured&&(0,X.jsx)(`span`,{className:`auth-badge dim`,children:e.source})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,title:h(`cloneProvider`),disabled:Y===e.id,onClick:()=>Qe(e),children:[(0,X.jsx)(tt,{}),` `,h(`cloneProvider`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{xe(be===e.id?null:e.id),Pe(null)},children:[(0,X.jsx)(me,{}),` `,h(`appendModel`)]}),e.supportsApiKey&&e.source===`stored`&&!e.usingOAuth&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm danger`,title:h(`clearKeyTitle`),onClick:()=>mt(e.id),children:[(0,X.jsx)(L,{}),` `,h(`clearKey`)]})]})]}),e.supportsOAuth&&(0,X.jsx)(Oy,{provider:e,flow:r.find(t=>t.provider===e.id),result:i[e.id]}),e.supportsApiKey&&(0,X.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:10},children:[(0,X.jsx)(`span`,{style:{fontSize:12.5,fontWeight:600},children:`API 密钥管理`}),(0,X.jsxs)(`div`,{className:`provider-keys`,children:[a.length===0&&(0,X.jsx)(`div`,{className:`provider-key-empty`,children:h(`noKeyYet`)}),a.map(t=>(0,X.jsxs)(`div`,{className:`provider-key-item ${t.active?`active`:``}`,children:[(0,X.jsx)(`span`,{className:`provider-key-dot`,children:t.active?`●`:`○`}),(0,X.jsx)(`span`,{className:`provider-key-label`,children:t.name}),!t.active&&(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:h(`activateKey`),onClick:()=>dt(e.id,t.name),children:(0,X.jsx)(ft,{})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:h(`removeKey`),onClick:()=>pt(e.id,t.name),children:(0,X.jsx)(L,{})})]},t.name))]}),(0,X.jsxs)(`div`,{className:`provider-add-key`,style:{marginTop:6},children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input key-input-name`,placeholder:h(`keyNamePh`),value:ee[e.id]??``,onChange:t=>M(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsx)(`input`,{type:`password`,className:`key-input key-input-value`,placeholder:h(`addKeyPlaceholder`),value:A[e.id]??``,onChange:t=>j(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!(A[e.id]??``).trim()||te===e.id,onClick:()=>ut(e),children:[(0,X.jsx)(me,{}),` `,te===e.id?h(`savingKey`):h(`addKey`)]})]})]}),be===e.id&&(0,X.jsxs)(`div`,{style:{marginTop:12,padding:12,background:`var(--bg)`,borderRadius:8,border:`1px dashed var(--border-soft)`},children:[(0,X.jsx)(`span`,{style:{fontSize:12,fontWeight:600,display:`block`,marginBottom:8},children:`追加官方模型覆盖 (Overlay)`}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:8,flexWrap:`wrap`},children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`模型 ID (必填)`,value:J,onChange:e=>Se(e.target.value)}),(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`显示名称 (选填)`,value:Ce,onChange:e=>we(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!J.trim()||ke,onClick:()=>gt(e.id),children:[(0,X.jsx)(me,{}),` 提交追加`]})]}),Ne&&(0,X.jsx)(`span`,{style:{fontSize:12,color:Ne.ok?`var(--green)`:`var(--red)`,marginTop:6},children:Ne.text})]})]})})()]})]}),x&&(0,X.jsx)(Ry,{candidates:x,onAdopt:nt,onClose:()=>S(null)})]})})}function By(e,t=[],n){let r=[],i=e=>{r.includes(e)||r.push(e)};e.optionsFrom&&i(``);for(let t of e.options??[])i(t);if(e.optionsFrom===`models`)for(let e of t)i(`${e.provider}/${e.id}`);else if(e.optionsFrom===`thinkingLevels`)for(let e of W_)i(e);let a=typeof n==`string`?n:n==null?``:String(n);return a&&i(a),r}function Vy({plugin:e,models:t=[]}){let n=Z(),r=e.settingsSchema??[],[i,a]=(0,g.useState)(()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);return t}),[o,s]=(0,g.useState)(!1);if(r.length===0)return null;let c=(e,t)=>a(n=>({...n,[e]:t})),l=e=>By(e,t,i[e.key]).map(r=>{if(r===``)return{value:``,label:n(`pluginSettingsInherit`)};if(e.optionsFrom===`thinkingLevels`&&W_.includes(r))return{value:r,label:n(`thinking.${r}`)};if(e.optionsFrom===`models`){let e=t.find(e=>`${e.provider}/${e.id}`===r);if(e)return{value:r,label:e.label}}return{value:r,label:r}}),u=r.some(t=>t.type===`secret`?String(i[t.key]??``)!==``:i[t.key]!==e.settingsValues?.[t.key]);return(0,X.jsxs)(`div`,{className:`plugin-settings-form`,children:[(0,X.jsx)(`div`,{className:`plugin-settings-fields`,children:r.map(t=>(0,X.jsxs)(`label`,{className:`plugin-settings-field`,"data-key":t.key,title:t.hint,children:[(0,X.jsxs)(`span`,{className:`plugin-settings-label`,children:[(0,X.jsx)(`span`,{className:`plugin-settings-label-text`,title:t.label,children:t.label}),t.hint&&(0,X.jsx)(`span`,{className:`plugin-settings-hint`,children:t.hint})]}),(0,X.jsx)(`span`,{className:`plugin-settings-control`,children:t.type===`boolean`?(0,X.jsx)(`input`,{type:`checkbox`,checked:!!i[t.key],onChange:e=>c(t.key,e.target.checked)}):t.type===`secret`?(0,X.jsx)(`input`,{type:`password`,value:String(i[t.key]??``),placeholder:n(e.settingsValues?.[t.key]?`pluginSecretSet`:`pluginSecretUnset`),autoComplete:`new-password`,onChange:e=>c(t.key,e.target.value)}):t.type===`select`?(0,X.jsx)(`select`,{value:String(i[t.key]??``),onChange:e=>c(t.key,e.target.value),children:l(t).map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,X.jsx)(`input`,{type:t.type===`password`?`password`:t.type===`number`?`number`:`text`,value:String(i[t.key]??``),min:t.min,max:t.max,onChange:e=>c(t.key,t.type===`number`?Number(e.target.value):e.target.value)})})]},t.key))}),(0,X.jsxs)(`div`,{className:`plugin-settings-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn plugin-settings-save`,disabled:!u||o,onClick:()=>{s(!0),$({type:`plugin_settings`,pluginId:e.id,values:i}),setTimeout(()=>s(!1),800)},children:n(o?`pluginSettingsSaving`:`pluginSettingsSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn plugin-settings-reset`,onClick:()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);a(t)},children:n(`pluginSettingsReset`)})]})]})}var Hy=0,Uy=``;function Wy(){typeof document<`u`&&(Hy===0&&(Uy=document.body.style.overflow,document.body.style.overflow=`hidden`),Hy++)}function Gy(){typeof document<`u`&&(Hy=Math.max(0,Hy-1),Hy===0&&(document.body.style.overflow=Uy))}function Ky({open:e=!0,onClose:t,title:n,icon:r,children:i,className:a=``,backdropClassName:o=``,style:s,closeOnBackdropClick:c=!0,closeOnEscape:l=!0,showCloseButton:u=!0,ariaLabel:d,lockScroll:f=!0}){let p=Z(),m=(0,g.useRef)(t);if((0,g.useLayoutEffect)(()=>{m.current=t}),zt(()=>l?(m.current(),!0):!1,e),(0,g.useEffect)(()=>{if(e&&f)return Wy(),()=>{Gy()}},[e,f]),!e)return null;let h=e=>{e.target===e.currentTarget&&c&&m.current()},_=d??(typeof n==`string`?n:void 0);return(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop ${o}`.trim(),onClick:h,role:`presentation`,children:(0,X.jsxs)(`div`,{className:`modal ${a}`.trim(),role:`dialog`,"aria-modal":`true`,"aria-label":_,style:s,onClick:e=>e.stopPropagation(),children:[u&&(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":p(`close`),onClick:()=>m.current(),children:`✕`}),n?(0,X.jsxs)(`div`,{className:`modal-head`,children:[r?(0,X.jsx)(`span`,{className:`modal-head-icon`,"aria-hidden":!0,children:r}):null,(0,X.jsx)(`span`,{children:n})]}):null,i]})}),document.body)}function qy({name:e,override:t,onApply:n,onClose:r}){let i=Z(),a=Os(e),[o,s]=(0,g.useState)(()=>t?.description??``),[c,l]=(0,g.useState)(()=>t?.promptSnippet??``),[u,d]=(0,g.useState)(()=>(t?.promptGuidelines??[]).join(`
364
+ `));(0,g.useEffect)(()=>{ws(e)},[e]);let f=(0,g.useMemo)(()=>(a?.defaultPromptGuidelines??[]).join(`
365
+ `),[a]),p=a?.status===`unsupported`||a?.status===`missing`;return(0,X.jsx)(Ky,{className:`tool-prompt-editor`,title:`${i(`toolPromptEdit`)} · ${e}`,icon:(0,X.jsx)(Y,{}),onClose:r,children:(0,X.jsxs)(`div`,{className:`tool-prompt-body`,children:[p&&(0,X.jsx)(`p`,{className:`set-note`,children:i(`toolPromptUnavailable`)}),(0,X.jsx)(`p`,{className:`set-note`,children:i(`toolPromptHint`)}),(0,X.jsxs)(`label`,{className:`tool-prompt-field`,children:[(0,X.jsx)(`span`,{className:`set-field-label`,children:i(`toolPromptDescription`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,value:o,placeholder:a?.defaultDescription??``,onChange:e=>s(e.target.value)}),a?.defaultDescription&&(0,X.jsxs)(`details`,{className:`tool-prompt-default`,children:[(0,X.jsx)(`summary`,{children:i(`toolPromptDefault`)}),(0,X.jsx)(`pre`,{children:a.defaultDescription})]})]}),(0,X.jsxs)(`label`,{className:`tool-prompt-field`,children:[(0,X.jsx)(`span`,{className:`set-field-label`,children:i(`toolPromptSnippet`)}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,value:c,placeholder:a?.defaultPromptSnippet??``,onChange:e=>l(e.target.value)}),a?.defaultPromptSnippet&&(0,X.jsxs)(`details`,{className:`tool-prompt-default`,children:[(0,X.jsx)(`summary`,{children:i(`toolPromptDefault`)}),(0,X.jsx)(`pre`,{children:a.defaultPromptSnippet})]})]}),(0,X.jsxs)(`label`,{className:`tool-prompt-field`,children:[(0,X.jsx)(`span`,{className:`set-field-label`,children:i(`toolPromptGuidelines`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input tool-prompt-guidelines`,rows:4,value:u,placeholder:f,onChange:e=>d(e.target.value)}),f&&(0,X.jsxs)(`details`,{className:`tool-prompt-default`,children:[(0,X.jsx)(`summary`,{children:i(`toolPromptDefault`)}),(0,X.jsx)(`pre`,{children:f})]})]}),(0,X.jsxs)(`div`,{className:`tool-prompt-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{n(e,null),Es(e),r()},children:i(`toolPromptReset`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let t={},i=o.trim();i&&(t.description=i);let a=c.trim();a&&(t.promptSnippet=a);let s=u.split(`
366
+ `).map(e=>e.trim()).filter(Boolean);s.length>0&&(t.promptGuidelines=s),n(e,Object.keys(t).length>0?t:null),Es(e),r()},children:i(`toolPromptSave`)})]})]})})}var Jy=[{id:`filesystem`,name:`Filesystem`,nameZh:`本地文件系统`,description:`Secure file operations allowing reading, writing, and directory traversal with configurable allowed paths.`,descriptionZh:`官方文件系统工具,支持安全的文件读写、内容检索与目录遍历。`,category:`core`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-filesystem`,`.`],package:`@modelcontextprotocol/server-filesystem`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/filesystem`},{id:`fetch`,name:`Web Fetch`,nameZh:`网页抓取与提取`,description:`Fetches and converts web pages to clean Markdown for model consumption and research.`,descriptionZh:`抓取指定 URL 网页正文并转换为结构化 Markdown 供智能体分析与阅读。`,category:`search`,transport:`stdio`,command:`uvx`,args:[`mcp-server-fetch`],package:`mcp-server-fetch`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/fetch`},{id:`memory`,name:`Knowledge Graph Memory`,nameZh:`持久化知识记忆图谱`,description:`Knowledge-graph based persistent memory system storing entities and relations locally.`,descriptionZh:`基于实体与关联知识图谱的本地持久化记忆系统,赋予 AI 跨会话的长期记忆能力。`,category:`core`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-memory`],package:`@modelcontextprotocol/server-memory`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/memory`},{id:`github`,name:`GitHub`,nameZh:`GitHub 仓库与协作`,description:`Interact with GitHub repositories, search code, manage issues, and review pull requests.`,descriptionZh:`访问 GitHub 远程仓库、搜索代码、创建与检索 Issue、查看与操作 Pull Request。`,category:`dev`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-github`],package:`@modelcontextprotocol/server-github`,env:[{key:`GITHUB_PERSONAL_ACCESS_TOKEN`,value:``,placeholder:`ghp_xxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!0,requiresKey:!0,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/github`},{id:`git`,name:`Git Repository`,nameZh:`本地 Git 版本控制`,description:`Local Git repository operations including inspecting diffs, viewing history, and staging changes.`,descriptionZh:`本地 Git 仓库操作,支持查看提交历史、变更 Diff、分支切换与暂存区管理。`,category:`dev`,transport:`stdio`,command:`uvx`,args:[`mcp-server-git`,`--repository`,`.`],package:`mcp-server-git`,official:!1,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/git`},{id:`sqlite`,name:`SQLite Database`,nameZh:`SQLite 数据库操作`,description:`Query and inspect local SQLite databases with automatic schema discovery and safety checks.`,descriptionZh:`连接并查询本地 SQLite 数据库文件,支持执行 SQL 语句、表结构探查与业务数据分析。`,category:`db`,transport:`stdio`,command:`uvx`,args:[`mcp-server-sqlite`,`--db-path`,`./app.db`],package:`mcp-server-sqlite`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/sqlite`},{id:`postgres`,name:`PostgreSQL Database`,nameZh:`PostgreSQL 数据库`,description:`Read-only and read-write operations on PostgreSQL databases with schema inspection.`,descriptionZh:`连接 PostgreSQL 数据库,支持执行参数化查询、表与索引分析及数据检索。`,category:`db`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-postgres`,`postgresql://user:password@localhost:5432/dbname`],package:`@modelcontextprotocol/server-postgres`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/postgres`},{id:`brave-search`,name:`Brave Search`,nameZh:`Brave 全球网页搜索`,description:`Web search and local search capabilities powered by the privacy-preserving Brave Search API.`,descriptionZh:`基于 Brave Search API 的全球互联网网页与资讯搜索工具,提供干净的搜索结果。`,category:`search`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-brave-search`],package:`@modelcontextprotocol/server-brave-search`,env:[{key:`BRAVE_API_KEY`,value:``,placeholder:`BSAxxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!0,requiresKey:!0,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/brave-search`},{id:`tavily`,name:`Tavily AI Search`,nameZh:`Tavily 智能搜索`,description:`Search engine built specifically for AI agents, providing synthesized real-time web results.`,descriptionZh:`专为 AI 智能体设计的搜索引擎,提供实时、高相关度、深度提炼的互联网内容检索结果。`,category:`search`,transport:`stdio`,command:`uvx`,args:[`mcp-server-tavily`],package:`mcp-server-tavily`,env:[{key:`TAVILY_API_KEY`,value:``,placeholder:`tvly-xxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!1,requiresKey:!0,homepage:`https://tavily.com`},{id:`puppeteer`,name:`Puppeteer Web Browser`,nameZh:`Puppeteer 浏览器自动化`,description:`Automate browser interactions, take page screenshots, and interact with dynamic JavaScript apps.`,descriptionZh:`无头浏览器自动化控制,支持截取网页长图、模拟点击、输入表单与渲染复杂动态页面。`,category:`automation`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-puppeteer`],package:`@modelcontextprotocol/server-puppeteer`,official:!0,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/puppeteer`},{id:`docker`,name:`Docker Manager`,nameZh:`Docker 容器与镜像管理`,description:`Inspect containers, check runtime logs, and manage local Docker images and volumes.`,descriptionZh:`操作与监视本地 Docker 引擎,支持查询运行中容器、查看容器日志、启停与镜像管理。`,category:`tools`,transport:`stdio`,command:`uvx`,args:[`mcp-server-docker`],package:`mcp-server-docker`,official:!1,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers`},{id:`slack`,name:`Slack Integration`,nameZh:`Slack 频道与消息互动`,description:`Post messages, read channel transcripts, and manage conversations in Slack workspaces.`,descriptionZh:`连接 Slack 工作区,支持读取频道历史消息、发送团队通知与讨论串交互。`,category:`tools`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-slack`],package:`@modelcontextprotocol/server-slack`,env:[{key:`SLACK_BOT_TOKEN`,value:``,placeholder:`xoxb-xxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!0,requiresKey:!0,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/slack`},{id:`time`,name:`Time & Timezones`,nameZh:`世界时间与时区计算`,description:`Get current time in multiple formats, calculate offsets, and perform timezone conversions.`,descriptionZh:`精准查询当前本地与 UTC 时间、全球时区转换及时间戳日期运算。`,category:`tools`,transport:`stdio`,command:`uvx`,args:[`mcp-server-time`],package:`mcp-server-time`,official:!1,requiresKey:!1,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/time`},{id:`sentry`,name:`Sentry Error Tracking`,nameZh:`Sentry 异常与崩溃追踪`,description:`Retrieve error traces, analyze crash dumps, and inspect recent issues from Sentry projects.`,descriptionZh:`从 Sentry 平台检索应用报错堆栈、异常统计与崩溃事件,辅助快速定位生产故障。`,category:`dev`,transport:`stdio`,command:`npx`,args:[`-y`,`@modelcontextprotocol/server-sentry`],package:`@modelcontextprotocol/server-sentry`,env:[{key:`SENTRY_AUTH_TOKEN`,value:``,placeholder:`sntrys_xxxxxxxxxxxxxxxxxxxx`,required:!0}],official:!0,requiresKey:!0,homepage:`https://github.com/modelcontextprotocol/servers/tree/main/src/sentry`}],Yy=[{id:`custom`,label:`mcpPresetCustom`,description:`mcpPresetCustomDesc`,transport:`stdio`},{id:`filesystem`,label:`mcpPresetFilesystem`,description:`mcpPresetFilesystemDesc`,transport:`stdio`,command:`npx`,args:`-y @modelcontextprotocol/server-filesystem .`},{id:`fetch`,label:`mcpPresetFetch`,description:`mcpPresetFetchDesc`,transport:`stdio`,command:`uvx`,args:`mcp-server-fetch`},{id:`memory`,label:`mcpPresetMemory`,description:`mcpPresetMemoryDesc`,transport:`stdio`,command:`npx`,args:`-y @modelcontextprotocol/server-memory`},{id:`github`,label:`mcpPresetGithub`,description:`mcpPresetGithubDesc`,transport:`stdio`,command:`npx`,args:`-y @modelcontextprotocol/server-github`,env:[{key:`GITHUB_PERSONAL_ACCESS_TOKEN`,value:``}]},{id:`sqlite`,label:`mcpPresetSqlite`,description:`mcpPresetSqliteDesc`,transport:`stdio`,command:`uvx`,args:`mcp-server-sqlite --db-path ./app.db`}];function Xy({settings:e,chat:t}){let n=Z(),{locale:r}=Nn(),[i,a]=(0,g.useState)(`configured`),[o,s]=(0,g.useState)(`all`),[c,l]=(0,g.useState)(`smithery`),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)({}),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(null),[T,E]=(0,g.useState)(`custom`),D=e.mcpServers??[],O=e.mcpGlobalConfigPath||``,k=e.mcpProjectConfigPath||``,A=(0,g.useMemo)(()=>o===`all`?D:D.filter(e=>e.scope===o),[D,o]),j=(0,g.useMemo)(()=>new Set(D.map(e=>e.name.toLowerCase())),[D]),ee=(e=!1)=>{let t=c===`custom`?u.trim():c;t&&(h(!0),$({type:`fetch_mcp_market`,source:t,query:f.trim()||void 0,refresh:e}))};(0,g.useEffect)(()=>{if(i!==`market`)return;let e=c===`custom`?u.trim():c;if(!e)return;h(!0);let t=setTimeout(()=>{$({type:`fetch_mcp_market`,source:e,query:f.trim()||void 0})},350);return()=>clearTimeout(t)},[i,c,f,u]),(0,g.useEffect)(()=>{t.mcpMarketResult&&h(!1)},[t.mcpMarketResult]);let M=(0,g.useMemo)(()=>t.mcpMarketResult?.ok&&t.mcpMarketResult.servers?.length>0?t.mcpMarketResult.servers:Jy.map(e=>({id:e.id,name:e.name,displayName:r===`zh`?e.nameZh:e.name,description:r===`zh`?e.descriptionZh:e.description,homepage:e.homepage,package:e.package,command:e.command,args:e.args,transport:e.transport,source:`builtin`,verified:e.official})),[t.mcpMarketResult,r]),te=(0,g.useMemo)(()=>D.filter(e=>e.scope===`global`).length,[D]),N=(0,g.useMemo)(()=>D.filter(e=>e.scope===`project`).length,[D]),ne=()=>{b(!0),$({type:`reload_mcp`}),setTimeout(()=>b(!1),800)},F=e=>{$({type:`toggle_mcp_server`,name:e.name,scope:e.scope,enabled:!e.enabled})},re=(e,t)=>{$({type:`delete_mcp_server`,name:e,scope:t}),w(null)},ie=e=>{v(t=>({...t,[e]:!t[e]}))},ae=(e=`global`,t=`custom`)=>{let n=Yy.find(e=>e.id===t)||Yy[0];E(n.id),S({name:n.id===`custom`?``:n.id,scope:e,transport:n.transport,command:n.command??``,args:n.args??``,cwd:``,env:n.env?[...n.env]:[],url:n.url??``,headers:[],timeout:``,description:``,enabled:!0,isNew:!0})},I=(e,t)=>{let n=[];if(e.env)for(let[t,r]of Object.entries(e.env))n.push({key:t,value:String(r)});E(`custom`),S({name:e.id,scope:t,transport:e.transport||(e.url?`http`:`stdio`),command:e.command||(e.package,`npx`),args:e.args?.length?e.args.join(` `):e.package?`-y ${e.package}`:``,cwd:``,env:n,url:e.url||``,headers:[],timeout:``,description:e.description||``,enabled:!0,isNew:!0})},R=e=>{let t=[];if(e.env)for(let[n,r]of Object.entries(e.env))t.push({key:n,value:String(r)});let n=[];if(e.headers)for(let[t,r]of Object.entries(e.headers))n.push({key:t,value:String(r)});E(`custom`),S({name:e.name,scope:e.scope,transport:e.url?`http`:`stdio`,command:e.command??``,args:Array.isArray(e.args)?e.args.join(` `):``,cwd:e.cwd??``,env:t,url:e.url??``,headers:n,timeout:e.timeout===void 0?``:String(e.timeout),description:e.description??``,enabled:e.enabled!==!1,isNew:!1,prevName:e.name,prevScope:e.scope})},oe=e=>{E(e);let t=Yy.find(t=>t.id===e);t&&x&&e!==`custom`&&S(e=>e?{...e,name:e.name?e.name:t.id,transport:t.transport,command:t.command??e.command,args:t.args??e.args,env:t.env?[...t.env]:e.env,url:t.url??e.url}:null)};return(0,X.jsxs)(`div`,{className:`set-section mcp-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(U,{className:`set-section-icon`}),n(`settingsMcp`),(0,X.jsx)(Du,{text:n(`settingsMcpDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:D.length}),(0,X.jsxs)(`div`,{className:`mcp-title-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn mcp-reload-btn${y?` spinning`:``}`,title:n(`mcpReload`),onClick:ne,children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:n(`mcpReload`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn mcp-add-btn`,title:n(`mcpAddServer`),onClick:()=>ae(o===`project`?`project`:`global`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:n(`mcpAddServer`)})]})]})]}),(0,X.jsxs)(`div`,{className:`mcp-tab-bar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tab-btn${i===`configured`?` active`:``}`,onClick:()=>a(`configured`),children:[(0,X.jsx)(U,{}),(0,X.jsx)(`span`,{children:n(`mcpTabConfigured`)}),(0,X.jsx)(`span`,{className:`set-count`,children:D.length})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tab-btn${i===`market`?` active`:``}`,onClick:()=>a(`market`),children:[(0,X.jsx)(se,{}),(0,X.jsx)(`span`,{children:n(`mcpTabMarket`)}),(0,X.jsx)(`span`,{className:`set-count`,children:Jy.length})]})]}),i===`configured`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mcp-meta-card`,children:[(0,X.jsxs)(`div`,{className:`mcp-scope-filter`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-scope-btn${o===`all`?` active`:``}`,onClick:()=>s(`all`),children:[n(`mcpFilterAll`),(0,X.jsx)(`span`,{className:`mcp-filter-count`,children:D.length})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-scope-btn${o===`global`?` active`:``}`,onClick:()=>s(`global`),children:[n(`mcpFilterGlobal`),(0,X.jsx)(`span`,{className:`mcp-filter-count`,children:te})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-scope-btn${o===`project`?` active`:``}`,onClick:()=>s(`project`),children:[n(`mcpFilterProject`),(0,X.jsx)(`span`,{className:`mcp-filter-count`,children:N})]})]}),(0,X.jsxs)(`div`,{className:`mcp-paths-summary`,children:[O&&(0,X.jsxs)(`div`,{className:`mcp-path-row`,children:[(0,X.jsxs)(`span`,{className:`mcp-path-label`,children:[n(`mcpGlobalPath`),`:`]}),(0,X.jsx)(`code`,{className:`mcp-path-text`,title:O,children:O}),(0,X.jsx)(Fd,{text:O})]}),k&&(0,X.jsxs)(`div`,{className:`mcp-path-row`,children:[(0,X.jsxs)(`span`,{className:`mcp-path-label`,children:[n(`mcpProjectPath`),`:`]}),(0,X.jsx)(`code`,{className:`mcp-path-text`,title:k,children:k}),(0,X.jsx)(Fd,{text:k})]})]})]}),A.length===0?(0,X.jsxs)(`div`,{className:`mcp-empty-card`,children:[(0,X.jsx)(`div`,{className:`mcp-empty-icon`,children:(0,X.jsx)(U,{})}),(0,X.jsx)(`div`,{className:`mcp-empty-title`,children:n(`mcpEmptyTitle`)}),(0,X.jsx)(`div`,{className:`mcp-empty-desc`,children:n(`mcpEmptyDesc`)}),(0,X.jsxs)(`div`,{className:`mcp-empty-quick-presets`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-goto-market-btn`,onClick:()=>a(`market`),children:[(0,X.jsx)(se,{}),n(`mcpBrowseMarket`)]}),(0,X.jsxs)(`span`,{className:`mcp-quick-label`,children:[n(`mcpQuickAdd`),`:`]}),Yy.filter(e=>e.id!==`custom`).map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`mcp-quick-btn`,onClick:()=>ae(`global`,e.id),children:[(0,X.jsx)(me,{}),n(e.label)]},e.id))]})]}):(0,X.jsx)(`div`,{className:`mcp-servers-list`,children:A.map(e=>{let t=`${e.scope}:${e.name}`,r=!!_[t],i=e.tools?.length??0;return(0,X.jsxs)(`div`,{className:`mcp-server-card${e.enabled?``:` disabled`}`,children:[(0,X.jsxs)(`div`,{className:`mcp-card-head`,children:[(0,X.jsxs)(`div`,{className:`mcp-card-title-group`,children:[(0,X.jsx)(`span`,{className:`mcp-server-name`,children:e.name}),(0,X.jsx)(`span`,{className:`mcp-scope-badge scope-${e.scope}`,children:e.scope===`global`?n(`mcpScopeGlobal`):n(`mcpScopeProject`)}),(0,X.jsx)(`span`,{className:`mcp-transport-badge`,children:e.url?`HTTP`:`stdio`}),(0,X.jsxs)(`span`,{className:`mcp-status-pill status-${e.status??(e.enabled?`running`:`stopped`)}`,children:[(0,X.jsx)(`span`,{className:`mcp-status-dot`}),e.status===`error`?n(`mcpStatusError`):e.enabled?`${n(`mcpStatusRunning`)}${i>0?` (${i})`:``}`:n(`mcpStatusStopped`)]})]}),(0,X.jsxs)(`div`,{className:`mcp-card-actions`,children:[(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,className:`set-switch${e.enabled?` on`:``}`,title:e.enabled?n(`mcpDisableHint`):n(`mcpEnableHint`),onClick:()=>F(e),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn mcp-action-btn`,title:n(`edit`),onClick:()=>R(e),children:(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn mcp-action-btn delete-btn`,title:n(`delete`),onClick:()=>w({name:e.name,scope:e.scope}),children:(0,X.jsx)(L,{})})]})]}),(0,X.jsxs)(`div`,{className:`mcp-card-body`,children:[e.description&&(0,X.jsx)(`div`,{className:`mcp-server-desc`,children:e.description}),(0,X.jsx)(`div`,{className:`mcp-spec-line`,children:e.url?(0,X.jsxs)(`div`,{className:`mcp-spec-http`,children:[(0,X.jsx)(Fe,{className:`mcp-spec-icon`}),(0,X.jsx)(`code`,{className:`mcp-spec-code`,children:e.url})]}):(0,X.jsxs)(`div`,{className:`mcp-spec-cmd`,children:[(0,X.jsx)(z,{className:`mcp-spec-icon`}),(0,X.jsxs)(`code`,{className:`mcp-spec-code`,children:[e.command,` `,e.args?.join(` `)]})]})}),e.cwd&&(0,X.jsxs)(`div`,{className:`mcp-spec-detail`,children:[(0,X.jsx)(Re,{className:`mcp-detail-icon`}),(0,X.jsx)(`span`,{className:`mcp-detail-label`,children:`cwd:`}),(0,X.jsx)(`code`,{children:e.cwd})]}),e.env&&Object.keys(e.env).length>0&&(0,X.jsxs)(`div`,{className:`mcp-spec-detail`,children:[(0,X.jsx)(`span`,{className:`mcp-detail-label`,children:`env:`}),(0,X.jsx)(`span`,{className:`mcp-env-tags`,children:Object.keys(e.env).map(e=>(0,X.jsx)(`span`,{className:`mcp-env-tag`,children:e},e))})]}),e.status===`error`&&e.error&&(0,X.jsxs)(`div`,{className:`mcp-error-box`,children:[(0,X.jsx)(wt,{className:`mcp-error-icon`}),(0,X.jsx)(`div`,{className:`mcp-error-text`,children:e.error})]}),i>0&&(0,X.jsxs)(`div`,{className:`mcp-tools-accordion`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tools-toggle`,onClick:()=>ie(t),children:[(0,X.jsx)(ke,{className:`mcp-tools-icon`}),(0,X.jsx)(`span`,{children:n(`mcpToolsCount`,{count:i})}),r?(0,X.jsx)(ct,{}):(0,X.jsx)(dt,{})]}),r&&(0,X.jsx)(`div`,{className:`mcp-tools-content`,children:e.tools?.map(e=>(0,X.jsxs)(`div`,{className:`mcp-tool-item`,children:[(0,X.jsx)(`span`,{className:`mcp-tool-name`,children:e.name}),e.description&&(0,X.jsx)(`span`,{className:`mcp-tool-desc`,children:e.description})]},e.name))})]})]})]},t)})})]}),i===`market`&&(0,X.jsxs)(`div`,{className:`mcp-market-view`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-toolbar`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-source-row`,children:[(0,X.jsxs)(`div`,{className:`mcp-source-select-wrap`,children:[(0,X.jsxs)(`label`,{className:`mcp-source-label`,children:[n(`mcpSourceSelectLabel`),`:`]}),(0,X.jsxs)(`select`,{className:`set-select mcp-source-select`,value:c,onChange:e=>l(e.target.value),children:[(0,X.jsx)(`option`,{value:`smithery`,children:n(`mcpSourceSmithery`)}),(0,X.jsx)(`option`,{value:`github`,children:n(`mcpSourceGithub`)}),(0,X.jsx)(`option`,{value:`custom`,children:n(`mcpSourceCustom`)})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn mcp-sync-btn${m?` spinning`:``}`,title:n(`mcpReload`),onClick:()=>ee(!0),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:n(`mcpReload`)})]})]}),c===`custom`&&(0,X.jsx)(`div`,{className:`mcp-custom-source-row`,children:(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-custom-input`,placeholder:n(`mcpSourceCustomPlaceholder`),value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ee(!0)}})}),(0,X.jsxs)(`div`,{className:`mcp-search-wrap`,children:[(0,X.jsx)(fe,{className:`mcp-search-icon`}),(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-search-input`,placeholder:n(`mcpMarketSearchPlaceholder`),value:f,onChange:e=>p(e.target.value)}),f&&(0,X.jsx)(`button`,{type:`button`,className:`mcp-search-clear`,onClick:()=>p(``),children:(0,X.jsx)(P,{})})]})]}),t.mcpMarketResult?.error&&(0,X.jsxs)(`div`,{className:`mcp-error-box`,children:[(0,X.jsx)(wt,{className:`mcp-error-icon`}),(0,X.jsx)(`div`,{className:`mcp-error-text`,children:t.mcpMarketResult.error}),(0,X.jsx)(`button`,{type:`button`,className:`mcp-mini-btn`,onClick:()=>ee(!0),children:n(`mcpMarketRetry`)})]}),m&&(0,X.jsxs)(`div`,{className:`mcp-market-loading`,children:[(0,X.jsx)(K,{className:`spinning`}),(0,X.jsx)(`span`,{children:n(`mcpMarketLoading`)})]}),(0,X.jsx)(`div`,{className:`mcp-market-grid`,children:M.map(e=>{let t=j.has(e.id.toLowerCase());return(0,X.jsxs)(`div`,{className:`mcp-market-card`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-card-head`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-title-wrap`,children:[e.iconUrl?(0,X.jsx)(`img`,{src:e.iconUrl,alt:``,className:`mcp-market-icon-img`}):(0,X.jsx)(U,{className:`mcp-market-icon-fallback`}),(0,X.jsx)(`span`,{className:`mcp-market-name`,children:e.displayName||e.name}),e.displayName&&e.displayName!==e.name&&(0,X.jsxs)(`span`,{className:`mcp-market-subname`,children:[`(`,e.name,`)`]}),e.verified&&(0,X.jsx)(`span`,{className:`mcp-badge-official`,children:n(`mcpBadgeOfficial`)})]}),e.homepage&&(0,X.jsx)(`a`,{href:e.homepage,target:`_blank`,rel:`noreferrer`,className:`mcp-market-link`,title:e.homepage,children:(0,X.jsx)(Ge,{})})]}),(0,X.jsx)(`p`,{className:`mcp-market-desc`,children:e.description}),(0,X.jsxs)(`div`,{className:`mcp-market-pkg`,children:[(0,X.jsx)(`code`,{className:`mcp-market-pkg-code`,children:e.package||e.id}),typeof e.downloads==`number`&&e.downloads>0&&(0,X.jsxs)(`span`,{className:`mcp-downloads-tag`,children:[e.downloads.toLocaleString(),` downloads`]})]}),(0,X.jsxs)(`div`,{className:`mcp-market-card-actions`,children:[t&&(0,X.jsxs)(`span`,{className:`mcp-market-configured-badge`,children:[(0,X.jsx)(ft,{}),n(`mcpConfigured`)]}),(0,X.jsxs)(`div`,{className:`mcp-market-add-btns`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-btn-add global`,title:n(`mcpAddGlobalHint`),onClick:()=>I(e,`global`),children:[(0,X.jsx)(me,{}),n(`mcpAddGlobal`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-btn-add project`,title:n(`mcpAddProjectHint`),onClick:()=>I(e,`project`),children:[(0,X.jsx)(me,{}),n(`mcpAddProject`)]})]})]})]},`${e.source}-${e.id}`)})})]}),C&&(0,X.jsx)(`div`,{className:`modal-backdrop sub-modal`,onClick:()=>w(null),children:(0,X.jsxs)(`div`,{className:`modal confirm-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(wt,{className:`modal-head-icon`}),(0,X.jsx)(`h3`,{children:n(`mcpDeleteConfirmTitle`)})]}),(0,X.jsx)(`div`,{className:`modal-body`,children:(0,X.jsx)(`p`,{children:n(`mcpDeleteConfirmDesc`,{name:C.name,scope:C.scope===`global`?n(`mcpScopeGlobal`):n(`mcpScopeProject`)})})}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-cancel-btn`,onClick:()=>w(null),children:n(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn-danger`,onClick:()=>re(C.name,C.scope),children:n(`delete`)})]})]})}),x&&(0,X.jsx)(`div`,{className:`modal-backdrop sub-modal`,onClick:()=>S(null),children:(0,X.jsxs)(`div`,{className:`modal mcp-edit-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":n(`close`),onClick:()=>S(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(U,{className:`modal-head-icon`}),(0,X.jsx)(`h3`,{children:x.isNew?n(`mcpAddModalTitle`):n(`mcpEditModalTitle`)})]}),(0,X.jsxs)(`div`,{className:`modal-body mcp-form-body`,children:[x.isNew&&(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpPresetSelect`)}),(0,X.jsx)(`select`,{className:`set-select`,value:T,onChange:e=>oe(e.target.value),children:Yy.map(e=>(0,X.jsx)(`option`,{value:e.id,children:n(e.label)},e.id))})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[n(`mcpScopeLabel`),(0,X.jsx)(`span`,{className:`field-required`,children:`*`})]}),(0,X.jsxs)(`div`,{className:`mcp-scope-selector`,children:[(0,X.jsxs)(`label`,{className:`mcp-scope-radio${x.scope===`global`?` selected`:``}`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`scope`,checked:x.scope===`global`,onChange:()=>S(e=>e?{...e,scope:`global`}:null)}),(0,X.jsxs)(`div`,{className:`mcp-radio-content`,children:[(0,X.jsx)(`div`,{className:`mcp-radio-title`,children:n(`mcpScopeGlobal`)}),(0,X.jsx)(`div`,{className:`mcp-radio-hint`,children:n(`mcpScopeGlobalHint`)})]})]}),(0,X.jsxs)(`label`,{className:`mcp-scope-radio${x.scope===`project`?` selected`:``}`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`scope`,checked:x.scope===`project`,onChange:()=>S(e=>e?{...e,scope:`project`}:null)}),(0,X.jsxs)(`div`,{className:`mcp-radio-content`,children:[(0,X.jsx)(`div`,{className:`mcp-radio-title`,children:n(`mcpScopeProject`)}),(0,X.jsx)(`div`,{className:`mcp-radio-hint`,children:n(`mcpScopeProjectHint`)})]})]})]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[n(`mcpNameLabel`),(0,X.jsx)(`span`,{className:`field-required`,children:`*`})]}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpNamePlaceholder`),value:x.name,onChange:e=>S(t=>t?{...t,name:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpTransportLabel`)}),(0,X.jsxs)(`div`,{className:`mcp-transport-selector`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-transport-btn${x.transport===`stdio`?` active`:``}`,onClick:()=>S(e=>e?{...e,transport:`stdio`}:null),children:[(0,X.jsx)(z,{}),`stdio (`,n(`mcpTransportStdio`),`)`]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-transport-btn${x.transport===`http`?` active`:``}`,onClick:()=>S(e=>e?{...e,transport:`http`}:null),children:[(0,X.jsx)(Fe,{}),`HTTP (`,n(`mcpTransportHttp`),`)`]})]})]}),x.transport===`stdio`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[n(`mcpCommandLabel`),(0,X.jsx)(`span`,{className:`field-required`,children:`*`})]}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpCommandPlaceholder`),value:x.command,onChange:e=>S(t=>t?{...t,command:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpArgsLabel`)}),(0,X.jsx)(`textarea`,{className:`set-input mcp-args-input`,rows:2,placeholder:n(`mcpArgsPlaceholder`),value:x.args,onChange:e=>S(t=>t?{...t,args:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpCwdLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpCwdPlaceholder`),value:x.cwd,onChange:e=>S(t=>t?{...t,cwd:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`div`,{className:`mcp-field-header`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpEnvLabel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-mini-btn`,onClick:()=>S(e=>e?{...e,env:[...e.env,{key:``,value:``}]}:null),children:[(0,X.jsx)(me,{}),n(`mcpAddEnv`)]})]}),x.env.map((e,t)=>(0,X.jsxs)(`div`,{className:`mcp-kv-row`,children:[(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-kv-key`,placeholder:n(`mcpEnvKeyPlaceholder`),value:e.key,onChange:e=>{let n=[...x.env];n[t].key=e.target.value,S(e=>e?{...e,env:n}:null)}}),(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-kv-val`,placeholder:n(`mcpEnvValuePlaceholder`),value:e.value,onChange:e=>{let n=[...x.env];n[t].value=e.target.value,S(e=>e?{...e,env:n}:null)}}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn delete-btn`,onClick:()=>{let e=x.env.filter((e,n)=>n!==t);S(t=>t?{...t,env:e}:null)},children:(0,X.jsx)(L,{})})]},t))]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[n(`mcpUrlLabel`),(0,X.jsx)(`span`,{className:`field-required`,children:`*`})]}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpUrlPlaceholder`),value:x.url,onChange:e=>S(t=>t?{...t,url:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsxs)(`div`,{className:`mcp-field-header`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpHeadersLabel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-mini-btn`,onClick:()=>S(e=>e?{...e,headers:[...e.headers,{key:``,value:``}]}:null),children:[(0,X.jsx)(me,{}),n(`mcpAddHeader`)]})]}),x.headers.map((e,t)=>(0,X.jsxs)(`div`,{className:`mcp-kv-row`,children:[(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-kv-key`,placeholder:n(`mcpHeaderKeyPlaceholder`),value:e.key,onChange:e=>{let n=[...x.headers];n[t].key=e.target.value,S(e=>e?{...e,headers:n}:null)}}),(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-kv-val`,placeholder:n(`mcpHeaderValuePlaceholder`),value:e.value,onChange:e=>{let n=[...x.headers];n[t].value=e.target.value,S(e=>e?{...e,headers:n}:null)}}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn delete-btn`,onClick:()=>{let e=x.headers.filter((e,n)=>n!==t);S(t=>t?{...t,headers:e}:null)},children:(0,X.jsx)(L,{})})]},t))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:n(`mcpDescriptionLabel`)}),(0,X.jsx)(`input`,{type:`text`,className:`set-input`,placeholder:n(`mcpDescriptionPlaceholder`),value:x.description,onChange:e=>S(t=>t?{...t,description:e.target.value}:null)})]}),(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-text`,children:[(0,X.jsx)(`div`,{className:`set-row-label`,children:n(`mcpEnabledLabel`)}),(0,X.jsx)(`div`,{className:`set-row-desc`,children:n(`mcpEnabledDesc`)})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":x.enabled,className:`set-switch${x.enabled?` on`:``}`,onClick:()=>S(e=>e?{...e,enabled:!e.enabled}:null),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})]}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-cancel-btn`,onClick:()=>S(null),children:n(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!x.name.trim()||x.transport===`stdio`&&!x.command.trim()||x.transport===`http`&&!x.url.trim(),onClick:()=>{if(!x)return;let e=x.name.trim();if(!e)return;let t={};for(let e of x.env){let n=e.key.trim();n&&(t[n]=e.value)}let n={};for(let e of x.headers){let t=e.key.trim();t&&(n[t]=e.value)}let r=x.args.trim().split(/\s+/).filter(e=>e.length>0),i=Number(x.timeout);$({type:`save_mcp_server`,server:{name:e,scope:x.scope,type:x.transport,command:x.transport===`stdio`&&x.command.trim()||void 0,args:x.transport===`stdio`&&r.length>0?r:void 0,cwd:x.transport===`stdio`&&x.cwd.trim()?x.cwd.trim():void 0,env:x.transport===`stdio`&&Object.keys(t).length>0?t:void 0,url:x.transport===`http`&&x.url.trim()?x.url.trim():void 0,headers:x.transport===`http`&&Object.keys(n).length>0?n:void 0,timeout:!isNaN(i)&&i>0?i:void 0,description:x.description.trim()||void 0,enabled:x.enabled},prevName:x.isNew?void 0:x.prevName,prevScope:x.isNew?void 0:x.prevScope}),S(null)},children:[(0,X.jsx)(ft,{}),(0,X.jsx)(`span`,{children:n(`save`)})]})]})]})})]})}var Zy=[{id:`code-review`,name:`Code Review`,nameZh:`代码审查与质量把关`,description:`Comprehensive code review guidelines for security vulnerabilities, logic bugs, concurrency flaws, and boundary conditions.`,descriptionZh:`全方位代码审查:深度排查安全漏洞、并发竞争隐患、边界异常以及性能退化。`,category:`quality`,content:`---
367
367
  name: code-review
368
368
  description: Comprehensive code review guidelines for security vulnerabilities, logic bugs, concurrency flaws, and boundary conditions. Use when reviewing code changes, pull requests, or diffs.
369
369
  ---
@@ -660,7 +660,7 @@ Systematic steps for investigating and resolving software defects:
660
660
  ## 3. Defect Remediation
661
661
  - Fix the root cause, not merely the symptom (avoid simply wrapping in try/catch or adding null checks without understanding why the value was null).
662
662
  - Add automated regression tests that fail before the fix and pass after.
663
- `}],zy=[{value:`0 9 * * *`,key:`schedulerPresetDaily`},{value:`0 * * * *`,key:`schedulerPresetHourly`},{value:`*/30 * * * *`,key:`schedulerPresetHalfHour`},{value:`0 9 * * 1-5`,key:`schedulerPresetWorkday`},{value:`0 9 * * 1`,key:`schedulerPresetMonday`}];function By(e){return{id:``,name:``,description:``,cwd:e,kind:`cron`,cron:`0 9 * * *`,preset:`0 9 * * *`,intervalMinutes:`60`,prompt:``,model:``,thinkingLevel:``,catchUp:!1}}function Vy(e){let t=e.kind===`cron`&&zy.some(t=>t.value===e.spec);return{id:e.id,name:e.name,description:e.description,cwd:e.cwd,kind:e.kind,cron:e.kind===`cron`?e.spec:`0 9 * * *`,preset:t?e.spec:`custom`,intervalMinutes:e.kind===`interval`?String(Math.max(1,Math.round(Number(e.spec)/6e4))):`60`,prompt:e.prompt,model:e.model,thinkingLevel:e.thinkingLevel,catchUp:e.catchUp===`once`}}function Hy(e,t){if(e.kind===`interval`){let n=Math.round(Number(e.spec)/6e4);return n<60?`${t(`schedulerKindInterval`)} · ${n} min`:n%60==0?`${t(`schedulerKindInterval`)} · ${n/60} h`:`${t(`schedulerKindInterval`)} · ${n} min`}let n=zy.find(t=>t.value===e.spec);return n?t(n.key):e.spec}function Uy(e){if(!e)return``;try{return new Date(e).toLocaleString()}catch{return String(e)}}function Wy({tasks:e,cwd:t,models:n}){let r=Z(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(new Set);(0,g.useEffect)(()=>{$({type:`schedule_list`})},[]);let u=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(rt,{className:`set-section-icon`}),r(`settingsScheduler`),(0,X.jsx)(mu,{text:r(`schedulerDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:r(`schedulerNew`),onClick:()=>{a(By(t)),s(!0)},children:[(0,X.jsx)(me,{}),` `,r(`schedulerNew`)]})]}),e.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:r(`schedulerEmpty`)}):(0,X.jsx)(`ul`,{className:`scheduler-list`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`scheduler-item ${e.enabled?``:`off`}`,children:[(0,X.jsxs)(`div`,{className:`scheduler-line1`,children:[(0,X.jsxs)(`span`,{className:`scheduler-name`,title:e.description||e.name,children:[e.running?`${r(`schedulerRunning`)} `:``,e.name]}),(0,X.jsx)(`span`,{className:`scheduler-badge ${e.enabled?`on`:``}`,children:e.enabled?r(`schedulerEnabled`):r(`schedulerDisabled`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-switch ${e.enabled?`on`:``}`,title:e.enabled?r(`schedulerDisable`):r(`schedulerEnable`),onClick:()=>$({type:`schedule_toggle`,id:e.id,enabled:!e.enabled}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsx)(`span`,{title:e.cwd,children:e.cwd}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsx)(`span`,{title:e.kind===`cron`?e.spec:`${e.spec} ms`,children:Hy(e,r)})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsxs)(`span`,{children:[r(`schedulerNextFire`),`: `,e.nextFire?Uy(e.nextFire):`—`]}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsxs)(`span`,{children:[r(`schedulerLastRun`),`:`,` `,e.lastRun?(0,X.jsxs)(X.Fragment,{children:[Uy(e.lastRun.at),` ·`,` `,(0,X.jsx)(`span`,{className:e.lastRun.ok?`scheduler-ok`:`scheduler-fail`,children:e.lastRun.ok?r(`schedulerRunOk`):r(`schedulerRunFail`)}),e.lastRun.manual?` · ${r(`schedulerManualBadge`)}`:``,e.lastRun.error?` · ${e.lastRun.error}`:``]}):r(`schedulerNeverRun`)]}),e.history.length>1&&(0,X.jsxs)(`button`,{type:`button`,className:`scheduler-link`,onClick:()=>u(e.id),children:[r(`schedulerHistory`),` (`,e.history.length,`)`]})]}),c.has(e.id)&&e.history.length>0&&(0,X.jsx)(`ul`,{className:`scheduler-history`,children:e.history.map((e,t)=>(0,X.jsxs)(`li`,{children:[Uy(e.at),` ·`,` `,(0,X.jsx)(`span`,{className:e.ok?`scheduler-ok`:`scheduler-fail`,children:e.ok?r(`schedulerRunOk`):r(`schedulerRunFail`)}),` · ${(e.durationMs/1e3).toFixed(0)}s`,e.manual?` · ${r(`schedulerManualBadge`)}`:``,e.error?` · ${e.error}`:``]},`${e.at}-${t}`))}),(0,X.jsxs)(`div`,{className:`scheduler-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:e.running,title:r(`schedulerRunNow`),onClick:()=>$({type:`schedule_run`,id:e.id}),children:[(0,X.jsx)(he,{}),` `,r(`schedulerRunNow`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerEdit`),onClick:()=>{a(Vy(e)),s(!1)},children:[(0,X.jsx)(Y,{}),` `,r(`schedulerEdit`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerDelete`),onClick:()=>{window.confirm(r(`schedulerConfirmDelete`,{name:e.name}))&&$({type:`schedule_delete`,id:e.id})},children:[(0,X.jsx)(R,{}),` `,r(`schedulerDelete`)]})]})]},e.id))}),i&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>a(null),children:(0,X.jsxs)(`div`,{className:`modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":r(`close`),onClick:()=>a(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(rt,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:o?r(`schedulerNew`):`${r(`schedulerEdit`)} · ${i.name||``}`})]}),(0,X.jsxs)(`div`,{className:`modal-body`,children:[(0,X.jsxs)(`div`,{className:`tpl-fields`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerNamePlaceholder`),value:i.name,onChange:e=>a({...i,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerDescPlaceholder`),value:i.description,onChange:e=>a({...i,description:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerCwdLabel`)}),(0,X.jsxs)(`div`,{className:`scheduler-cwd-row`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerCwdPlaceholder`),value:i.cwd,onChange:e=>a({...i,cwd:e.target.value})}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>a({...i,cwd:t}),children:r(`schedulerUseCurrentCwd`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.kind,onChange:e=>a({...i,kind:e.target.value}),children:[(0,X.jsx)(`option`,{value:`cron`,children:r(`schedulerKindCron`)}),(0,X.jsx)(`option`,{value:`interval`,children:r(`schedulerKindInterval`)})]})]}),i.kind===`cron`?(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindCron`)}),(0,X.jsxs)(`div`,{className:`scheduler-cwd-row`,children:[(0,X.jsxs)(`select`,{className:`set-select`,value:i.preset,onChange:e=>{let t=e.target.value;a({...i,preset:t,...t===`custom`?{}:{cron:t}})},children:[zy.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[r(e.key),` · `,e.value]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:r(`schedulerPresetCustom`)})]}),i.preset===`custom`&&(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerCronPlaceholder`),value:i.cron,onChange:e=>a({...i,cron:e.target.value})})]})]}):(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindInterval`)}),(0,X.jsx)(`input`,{className:`set-input`,type:`number`,min:1,placeholder:r(`schedulerIntervalMinutes`),value:i.intervalMinutes,onChange:e=>a({...i,intervalMinutes:e.target.value})})]}),(0,X.jsx)(`div`,{className:`tpl-fields`,children:(0,X.jsx)(`textarea`,{className:`set-input`,rows:4,placeholder:r(`schedulerPromptPlaceholder`),value:i.prompt,onChange:e=>a({...i,prompt:e.target.value})})}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.model,onChange:e=>a({...i,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`subagentFollowMain`)}),n.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})]}),n.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:r(`subagentNoModels`)}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[r(`schedulerThinkingLabel`),` `,(0,X.jsx)(mu,{text:r(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.thinkingLevel,onChange:e=>a({...i,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`tplThinkingFollowMain`)}),j_.map(e=>(0,X.jsx)(`option`,{value:e,children:r(`thinking.${e}`)},e))]})]}),(0,X.jsxs)(`label`,{className:`scheduler-check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.catchUp,onChange:e=>a({...i,catchUp:e.target.checked})}),(0,X.jsxs)(`span`,{children:[r(`schedulerCatchUp`),` `,(0,X.jsx)(mu,{text:r(`schedulerCatchUpHint`)})]})]}),(0,X.jsxs)(`div`,{className:`scheduler-foot`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>a(null),children:r(`schedulerCancelEdit`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!i.name.trim()||!i.cwd.trim()||!i.prompt.trim(),onClick:()=>{if(!i)return;let e=i.kind;$({type:`schedule_save`,task:{...i.id?{id:i.id}:{},name:i.name.trim(),description:i.description.trim(),cwd:i.cwd.trim(),kind:e,spec:e===`cron`?i.cron.trim():String(Math.max(1,Math.floor(Number(i.intervalMinutes)||0))*6e4),prompt:i.prompt.trim(),...i.model.trim()?{model:i.model.trim()}:{},...i.thinkingLevel.trim()?{thinkingLevel:i.thinkingLevel.trim()}:{},catchUp:i.catchUp?`once`:`skip`}}),a(null)},children:r(`schedulerSave`)})]})]})]})})]})}var Gy=`pi-web-sounds`,Ky={enabled:!0,question:!0,done:!0,start:!1,error:!0,approval:!0,volume:100};function qy(){try{let e=localStorage.getItem(Gy);if(!e)return{...Ky};let t=JSON.parse(e),n={...Ky,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`,`approval`])typeof n[e]!=`boolean`&&(n[e]=Ky[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?Ky.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...Ky}}}function Jy(e){try{localStorage.setItem(Gy,JSON.stringify(e))}catch{}}var Yy=null;function Xy(){try{if(!Yy){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Yy=new e}return Yy.state===`suspended`&&Yy.resume(),Yy}catch{return null}}var Zy={question:[{type:`sine`,freq:587.33,start:0,dur:.13,peak:.5},{type:`sine`,freq:880,start:.11,dur:.24,peak:.5}],done:[{type:`sine`,freq:880,start:0,dur:.15,peak:.35},{type:`sine`,freq:587.33,start:.15,dur:.32,peak:.35}],start:[{type:`triangle`,freq:660,start:0,dur:.08,peak:.22}],error:[{type:`square`,freq:220,start:0,dur:.16,peak:.18},{type:`square`,freq:174.61,start:.18,dur:.26,peak:.18}],approval:[{type:`sine`,freq:659.25,start:0,dur:.11,peak:.45},{type:`sine`,freq:659.25,start:.14,dur:.11,peak:.45},{type:`sine`,freq:880,start:.28,dur:.26,peak:.5}]};function Qy(e,t,n){let r=e.createOscillator(),i=e.createGain();r.type=t.type,r.frequency.value=t.freq;let a=e.currentTime+t.start,o=Math.max(1e-4,t.peak*n);i.gain.setValueAtTime(1e-4,a),i.gain.exponentialRampToValueAtTime(o,a+.012),i.gain.exponentialRampToValueAtTime(1e-4,a+t.dur),r.connect(i),i.connect(e.destination),r.start(a),r.stop(a+t.dur+.05)}function $y(e,t=qy()){if(!t.enabled||!t[e])return;let n=Xy();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of Zy[e])Qy(n,t,r)}function eb(e){if(e==null)return 0;if(typeof e==`number`){if(!Number.isFinite(e)||e<=0)return 0;let t=Math.floor(e);return t<=1e3?t*1e3:Math.min(1e7,t)}let t=String(e).trim().toLowerCase().replace(/[,_\s]/g,``);if(!t)return 0;let n=t.match(/^(\d+(?:\.\d+)?)([km])?$/);if(!n)return 0;let r=parseFloat(n[1]);if(!Number.isFinite(r)||r<=0)return 0;let i=n[2],a;return i===`k`?a=Math.floor(r*1e3):i===`m`?a=Math.floor(r*1e6):(a=Math.floor(r),a<=1e3&&(a*=1e3)),Math.min(1e7,Math.max(0,a))}function tb(e){return!e||e<=0||!Number.isFinite(e)?``:e>=1e6&&e%1e5==0?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3&&e%1e3==0?`${e/1e3}k`:String(e)}var nb=`pi-web-ui:wide-chat`,rb={wide:!1};function ib(e){if(!e||typeof e!=`object`)return{...rb};let t=e;return{wide:typeof t.wide==`boolean`?t.wide:rb.wide}}function ab(){try{let e=localStorage.getItem(nb);return e?ib(JSON.parse(e)):{...rb}}catch{return{...rb}}}function ob(e){let t=ib(e);try{localStorage.setItem(nb,JSON.stringify(t))}catch{}sb=t;for(let e of cb)e()}var sb=null,cb=new Set;function lb(e){return cb.add(e),()=>{cb.delete(e)}}function ub(){return sb||=ab(),sb.wide}function db(){return(0,g.useSyncExternalStore)(lb,ub)}var fb=`pi-web-ui:project-title`,pb={projectName:!0};function mb(e){if(!e||typeof e!=`object`)return{...pb};let t=e;return{projectName:typeof t.projectName==`boolean`?t.projectName:pb.projectName}}function hb(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``:``}function gb(){try{let e=localStorage.getItem(fb);return e?mb(JSON.parse(e)):{...pb}}catch{return{...pb}}}function _b(e){let t=mb(e);try{localStorage.setItem(fb,JSON.stringify(t))}catch{}vb=t;for(let e of yb)e()}var vb=null,yb=new Set;function bb(e){return yb.add(e),()=>{yb.delete(e)}}function xb(){return vb||=gb(),vb.projectName}function Sb(){return(0,g.useSyncExternalStore)(bb,xb)}var Cb=`pi-web-ui:wallpaper`,wb=`has-wallpaper`,Tb={url:``,dim:78,blur:0},Eb=2e3,Db=28e5;function Ob(e){if(typeof e!=`string`)return``;let t=e.trim();if(!t)return``;let n=t.toLowerCase().startsWith(`data:image/`)?Db:Eb;return t.length>n?``:/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith(`/`)&&!t.startsWith(`//`)?t:``}var kb=(e,t,n,r)=>typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)));function Ab(e){if(!e||typeof e!=`object`)return{...Tb};let t=e;return{url:Ob(t.url),dim:kb(t.dim,0,95,Tb.dim),blur:kb(t.blur,0,24,Tb.blur)}}function jb(){try{let e=localStorage.getItem(Cb);return e?Ab(JSON.parse(e)):{...Tb}}catch{return{...Tb}}}function Mb(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/[\r\n]/g,``)}async function Nb(e){let t=await Qp(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function Pb(){let e=Ib??jb(),t=document.documentElement;e.url?(t.style.setProperty(`--bg-image`,`url("${Mb(e.url)}")`),t.style.setProperty(`--bg-image-dim`,String(e.dim/100)),t.style.setProperty(`--bg-image-blur`,`${e.blur}px`)):(t.style.removeProperty(`--bg-image`),t.style.removeProperty(`--bg-image-dim`),t.style.removeProperty(`--bg-image-blur`));let n=getComputedStyle(t).getPropertyValue(`--bg-image`).trim();document.body.classList.toggle(wb,e.url!==``||n!==``&&n!==`none`)}function Fb(e){let t=Ab(e);Ib=t;try{localStorage.setItem(Cb,JSON.stringify(t))}catch{}for(let e of Lb)e();Pb()}var Ib=null,Lb=new Set;function Rb(e){return Lb.add(e),()=>{Lb.delete(e)}}function zb(){return Ib||=jb(),Ib}function Bb(){return(0,g.useSyncExternalStore)(Rb,zb)}function Vb(){let e=Bb();(0,g.useEffect)(()=>{Pb()},[e]),(0,g.useEffect)(()=>{let e=()=>Pb();return window.addEventListener(Qd,e),Pb(),()=>window.removeEventListener(Qd,e)},[])}var Hb=[`prompt`,`tools`,`terminal`,`skills`,`ai`,`ui`,`engine`],Ub={prompt:[`promptMode`,`customSystemPrompt`,`promptTemplate`,`promptOverrides`,`reviewPrompt`,`reviewDisabledSkills`],tools:[`disabledAgentTools`,`disabledPluginTools`,`toolPromptOverrides`,`toolLazyLoading`,`codemodeMode`,`codemodeInlineBudget`,`readDirEnabled`,`toolApprovalEnabled`,`toolWatchdogTimeoutMs`,`questionnaireEnabled`,`editSoftEnabled`,`terminalToolsEnabled`],terminal:[`terminalBash`,`terminalBashIdleMs`,`terminalBashMaxForegroundMs`],skills:[`disabledSkills`,`disabledExtensions`,`skillsFullText`],ai:[`retryMaxAttempts`,`softCapTokens`,`softCapByModel`,`subagentDefaultModel`,`visionBridgeEnabled`,`visionBridgeModel`,`visionBridgePromptMode`,`visionBridgePrompt`,`scmCommitMsgPromptMode`,`scmCommitMsgPrompt`,`planModePromptMode`,`planModePrompt`,`goalModeEnabled`,`parallelReminderEnabled`],ui:[`uiLayout`,`disabledPlugins`,`thinkingWrap`,`toolsWrap`,`toolImagesEnabled`,`keepRecentMessages`,`bgAutoCleanupMin`,`quickPhrases`,`quickPhrasesEnabled`,`devNoCache`,`autoReload`],engine:[`defaultAgentPreset`,`defaultPermissionPreset`]};(()=>{let e=[];for(let t of Hb)for(let n of Ub[t])e.includes(n)||e.push(n);return e})();function Wb(e){let t=new Set(e),n=[];for(let e of Hb){let r=Ub[e].filter(e=>t.has(e));r.length>0&&n.push({group:e,fields:r})}return n}var Gb={promptMode:{labelZh:`提示词模式`,labelEn:`Prompt Mode`,hintZh:`追加到内置提示词 (append) 或完全替换系统内置提示词 (replace)`,hintEn:`Append to built-in prompt or completely replace it`},customSystemPrompt:{labelZh:`自定义系统提示词`,labelEn:`Custom System Prompt`,hintZh:`定制 AI 基础人设与工作规约的主提示词`,hintEn:`Main prompt customizing AI persona and instructions`},promptTemplate:{labelZh:`组合模板`,labelEn:`Prompt Template`,hintZh:`高级提示词组装模板(包含各个 slot 占位符)`,hintEn:`Advanced prompt composition template with slot placeholders`},promptOverrides:{labelZh:`逐段提示词覆盖`,labelEn:`Sectional Prompt Overrides`,hintZh:`微调特定提示词段落(如 soul/cwd/skills 等)`,hintEn:`Overrides for specific prompt sections (soul, cwd, skills, etc.)`},reviewPrompt:{labelZh:`目标模式审查提示词`,labelEn:`Goal Mode Review Prompt`,hintZh:`目标模式 2.0 中审查者专用的判定与指导提示词`,hintEn:`Prompt for the reviewer in Goal Mode 2.0`},reviewDisabledSkills:{labelZh:`审查时禁用的技能`,labelEn:`Skills Disabled in Review`,hintZh:`仅在目标审查阶段禁止审查者调用的技能列表`,hintEn:`Skills unavailable to the reviewer in Goal Mode`},disabledAgentTools:{labelZh:`禁用的内置工具`,labelEn:`Disabled Agent Tools`,hintZh:`不在 AI 可用工具列表中暴露的内置工具`,hintEn:`Built-in tools removed from agent visibility`},disabledPluginTools:{labelZh:`禁用的插件工具`,labelEn:`Disabled Plugin Tools`,hintZh:`禁止向 AI 注册的第三方插件工具`,hintEn:`Plugin-provided tools removed from agent visibility`},toolPromptOverrides:{labelZh:`工具提示词覆盖`,labelEn:`Tool Prompt Overrides`,hintZh:`微调工具在模型视野中的描述、触发条件与使用指南`,hintEn:`Custom descriptions, snippets and guidelines for tools`},toolLazyLoading:{labelZh:`工具按需延迟加载`,labelEn:`Tool Lazy Loading`,hintZh:`仅常驻核心工具,其余工具通过 load_tools 按需动态引入(节省上下文)`,hintEn:`Keep only core tools active; load others on demand (saves context)`},codemodeMode:{labelZh:`codemode 运行模式`,labelEn:`Codemode Execution Mode`,hintZh:`常规模式(on)或纯代码模式(only,仅通过沙箱脚本调用工具)`,hintEn:`Regular mode (on) or strict code mode (only, all tool calls run via sandbox script)`},codemodeInlineBudget:{labelZh:`codemode 工具声明预算`,labelEn:`Codemode Inline Budget`,hintZh:`直接嵌入在 codemode 系统提示词中的工具声明 Token 预算(默认 3000)`,hintEn:`Token budget for tool declarations directly embedded in the codemode prompt (default: 3000)`},readDirEnabled:{labelZh:`read 工具列目录`,labelEn:`Directory Listing in read`,hintZh:`允许 read 工具在路径为目录时直接返回文件列表`,hintEn:`Allow read tool to list directory entries when target is a folder`},toolApprovalEnabled:{labelZh:`工具执行审批门禁`,labelEn:`Tool Execution Approval`,hintZh:`执行危险或写操作工具前弹出用户确认确认框`,hintEn:`Require user approval before executing tools`},bgAutoCleanupMin:{labelZh:`后台任务自动清理`,labelEn:`Background Task Auto-cleanup`,hintZh:`定期清理闲置超阈值的 AI 起后台实例(分钟;0 = 关;面板里📌钉住的不算)`,hintEn:`Periodically clean AI-started background instances idle past the threshold (minutes; 0 = off; pinned ones skipped)`},toolWatchdogTimeoutMs:{labelZh:`工具看门狗超时`,labelEn:`Tool Watchdog Timeout`,hintZh:`工具长时间未返回时的最长等待熔断时间`,hintEn:`Maximum execution time before aborting stuck tools`},questionnaireEnabled:{labelZh:`问卷模式 (ask_user_question)`,labelEn:`Questionnaire Mode`,hintZh:`允许 AI 遇到歧义时弹窗向用户多选/单选确认`,hintEn:`Allow agent to ask interactive multiple-choice questions`},editSoftEnabled:{labelZh:`宽松缩进编辑 (edit_soft)`,labelEn:`Soft Indentation Edit`,hintZh:`提供忽略前导空白缩进差异的鲁棒编辑工具`,hintEn:`Provide indentation-tolerant text replacement tool`},terminalToolsEnabled:{labelZh:`终端工具集`,labelEn:`Terminal Toolset`,hintZh:`向 AI 开放持久交互式 PTY 终端驱动工具`,hintEn:`Enable persistent PTY interactive terminal tools`},terminalBash:{labelZh:`终端接管 Bash`,labelEn:`Terminal Takes Over Bash`,hintZh:`将 bash 工具调用分流至可见交互终端并实时回显`,hintEn:`Route bash execution into the visible interactive terminal`},terminalBashIdleMs:{labelZh:`终端静默超时`,labelEn:`Terminal Idle Timeout`,hintZh:`终端无新输出时判定为完成的静默时间`,hintEn:`Idle duration before assuming command finished`},terminalBashMaxForegroundMs:{labelZh:`前台最长运行时间`,labelEn:`Max Foreground Runtime`,hintZh:`前台命令超时未退出的强制截断时间`,hintEn:`Timeout before cutting off long foreground commands`},disabledSkills:{labelZh:`禁用的技能`,labelEn:`Disabled Skills`,hintZh:`在当前工作区中禁用的技能列表`,hintEn:`Skills excluded in the current workspace`},disabledExtensions:{labelZh:`禁用的扩展`,labelEn:`Disabled Extensions`,hintZh:`在当前项目中禁用的扩展列表`,hintEn:`Extensions excluded in the current project`},skillsFullText:{labelZh:`技能全文常驻`,labelEn:`Skills Full Text in Context`,hintZh:`将指定技能的完整正文直接注入上下文,跳过 skill 工具按需载入`,hintEn:`Inject full text of selected skills directly into context`},retryMaxAttempts:{labelZh:`网络重试上限`,labelEn:`Network Retry Attempts`,hintZh:`模型网络请求失败时的最大自动重试次数`,hintEn:`Max auto-retries when model requests fail`},softCapTokens:{labelZh:`上下文压缩软上限`,labelEn:`Context Soft-Cap Tokens`,hintZh:`提前触发上下文平滑压缩的 token 阈值(默认 16384)`,hintEn:`Token threshold to trigger context compaction early`},softCapByModel:{labelZh:`分模型压缩软上限`,labelEn:`Per-Model Soft-Cap`,hintZh:`针对不同模型单独设置的上下文压缩阈值`,hintEn:`Custom soft-cap thresholds configured per model`},subagentDefaultModel:{labelZh:`子代理默认模型`,labelEn:`Subagent Default Model`,hintZh:`派生子代理时优先使用的专用模型(留空跟随主对话)`,hintEn:`Dedicated model for subagents (empty to follow main chat)`},visionBridgeEnabled:{labelZh:`视觉桥 (看图转写)`,labelEn:`Vision Bridge`,hintZh:`主模型不具备识图能力时,自动使用带视觉的模型预先转写图片`,hintEn:`Use vision model to describe images when main model is text-only`},visionBridgeModel:{labelZh:`视觉桥专属模型`,labelEn:`Vision Bridge Model`,hintZh:`用于看图转写的视觉模型 ID`,hintEn:`Model ID used for vision transcription`},visionBridgePromptMode:{labelZh:`视觉桥提示词模式`,labelEn:`Vision Bridge Prompt Mode`,hintZh:`视觉桥转写提示词的追加/替换模式`,hintEn:`Append or replace mode for vision bridge prompt`},visionBridgePrompt:{labelZh:`视觉桥提示词`,labelEn:`Vision Bridge Prompt`,hintZh:`指导视觉模型如何描述图片的系统提示词`,hintEn:`System prompt guiding image transcription`},scmCommitMsgPromptMode:{labelZh:`Git 提交信息提示词模式`,labelEn:`Git Commit Prompt Mode`,hintZh:`AI 生成 Git 提交信息时的提示词模式`,hintEn:`Prompt mode for AI-generated Git commit messages`},scmCommitMsgPrompt:{labelZh:`Git 提交信息提示词`,labelEn:`Git Commit Prompt`,hintZh:`指导 AI 根据 git diff 撰写提交信息的规范提示词`,hintEn:`Prompt guiding AI to write commit messages from git diff`},planModePromptMode:{labelZh:`计划模式提示词模式`,labelEn:`Plan Mode Prompt Mode`,hintZh:`计划模式提示词的追加/替换模式`,hintEn:`Append or replace mode for Plan Mode prompt`},planModePrompt:{labelZh:`计划模式提示词`,labelEn:`Plan Mode Prompt`,hintZh:`计划模式下限制模型只规划不施工的系统提示词`,hintEn:`System prompt restricting agent to planning only`},goalModeEnabled:{labelZh:`目标模式 2.0`,labelEn:`Goal Mode 2.0`,hintZh:`主对话当审查者,服务端常驻执行对话协同干活`,hintEn:`Reviewer/executor loop architecture for goal tasks`},parallelReminderEnabled:{labelZh:`并行编辑提醒`,labelEn:`Parallel Edit Reminder`,hintZh:`多个标签页同时编辑同一会话时的冲突告警`,hintEn:`Warn when multiple tabs edit the same session`},uiLayout:{labelZh:`界面布局与图标排列`,labelEn:`UI Layout & Icons`,hintZh:`顶栏、底栏、左右侧边栏按钮的自定义顺序、可见性与对齐`,hintEn:`Custom order, visibility and alignment for bars and docks`},disabledPlugins:{labelZh:`禁用的插件`,labelEn:`Disabled Plugins`,hintZh:`停用的 UI 插件列表`,hintEn:`List of deactivated UI plugins`},thinkingWrap:{labelZh:`思考区自动折行`,labelEn:`Thinking Block Word Wrap`,hintZh:`思考展开区长文本是否自动折行`,hintEn:`Enable word wrap inside thinking blocks`},toolsWrap:{labelZh:`工具调用自动折行`,labelEn:`Tool Call Word Wrap`,hintZh:`工具调用参数与结果长文本是否自动折行`,hintEn:`Enable word wrap for tool parameters and results`},toolImagesEnabled:{labelZh:`工具调用图片渲染`,labelEn:`Tool Image Preview`,hintZh:`直接在工具卡片内渲染输出的图片文件`,hintEn:`Render image output directly in tool cards`},keepRecentMessages:{labelZh:`常驻渲染消息数`,labelEn:`Messages Kept In Full`,hintZh:`消息列表尾部保持完整渲染的消息条数;更早的折叠为摘要行`,hintEn:`Recent messages rendered in full; older ones collapse to summary rows`},quickPhrases:{labelZh:`快捷短语列表`,labelEn:`Quick Phrases List`,hintZh:`输入框上方的常用提示短语快捷按钮`,hintEn:`Quick prompt phrase buttons above composer`},quickPhrasesEnabled:{labelZh:`启用快捷短语`,labelEn:`Enable Quick Phrases`,hintZh:`是否在输入框上方显示快捷短语药丸栏`,hintEn:`Display quick phrases bar above composer`},devNoCache:{labelZh:`开发者免缓存模式`,labelEn:`Developer No-Cache Mode`,hintZh:`前端静态资源强制请求最新,不走缓存`,hintEn:`Bypass browser cache for static frontend assets`},autoReload:{labelZh:`插件自动热重载`,labelEn:`Auto Reload on File Change`,hintZh:`本地插件文件变更时自动刷新插件运行时`,hintEn:`Automatically reload plugins when files change`},defaultAgentPreset:{labelZh:`默认智能体预设`,labelEn:`Default Agent Preset`,hintZh:`新建会话时默认加载的智能体预设(DSH 多引擎)`,hintEn:`Default agent preset applied to new sessions (DSH)`},defaultPermissionPreset:{labelZh:`默认权限预设`,labelEn:`Default Permission Preset`,hintZh:`新建会话时默认加载的权限预设`,hintEn:`Default permission preset applied to new sessions`}};function Kb(e,t=`zh`){let n=Gb[e];return n?t===`zh`?n.labelZh:n.labelEn:e}function qb(e,t=`zh`){let n=Gb[e];return n&&(t===`zh`?n.hintZh:n.hintEn)||``}function Jb(e,t,n=`zh`){let r=n===`zh`;if(t==null)return{summary:r?`未配置(跟随当前值)`:`Not configured (keeps current)`};if(e===`disabledAgentTools`){let e=Array.isArray(t)?t.filter(e=>typeof e==`string`&&!!e):[],n=Fr(e);return e.length===0?{summary:r?`全部启用(共 ${n.length} 个可用工具)`:`All enabled (${n.length} available tools)`,detail:[`[${r?`已启用可用工具`:`Enabled Tools`} (${n.length})]`,...n.map(e=>` ✓ ${e}`)].join(`
663
+ `}],Qy=[{value:`0 9 * * *`,key:`schedulerPresetDaily`},{value:`0 * * * *`,key:`schedulerPresetHourly`},{value:`*/30 * * * *`,key:`schedulerPresetHalfHour`},{value:`0 9 * * 1-5`,key:`schedulerPresetWorkday`},{value:`0 9 * * 1`,key:`schedulerPresetMonday`}];function $y(e){return{id:``,name:``,description:``,cwd:e,kind:`cron`,cron:`0 9 * * *`,preset:`0 9 * * *`,intervalMinutes:`60`,prompt:``,model:``,thinkingLevel:``,catchUp:!1}}function eb(e){let t=e.kind===`cron`&&Qy.some(t=>t.value===e.spec);return{id:e.id,name:e.name,description:e.description,cwd:e.cwd,kind:e.kind,cron:e.kind===`cron`?e.spec:`0 9 * * *`,preset:t?e.spec:`custom`,intervalMinutes:e.kind===`interval`?String(Math.max(1,Math.round(Number(e.spec)/6e4))):`60`,prompt:e.prompt,model:e.model,thinkingLevel:e.thinkingLevel,catchUp:e.catchUp===`once`}}function tb(e,t){if(e.kind===`interval`){let n=Math.round(Number(e.spec)/6e4);return n<60?`${t(`schedulerKindInterval`)} · ${n} min`:n%60==0?`${t(`schedulerKindInterval`)} · ${n/60} h`:`${t(`schedulerKindInterval`)} · ${n} min`}let n=Qy.find(t=>t.value===e.spec);return n?t(n.key):e.spec}function nb(e){if(!e)return``;try{return new Date(e).toLocaleString()}catch{return String(e)}}function rb({tasks:e,cwd:t,models:n}){let r=Z(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(new Set);(0,g.useEffect)(()=>{$({type:`schedule_list`})},[]);let u=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(rt,{className:`set-section-icon`}),r(`settingsScheduler`),(0,X.jsx)(Du,{text:r(`schedulerDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:r(`schedulerNew`),onClick:()=>{a($y(t)),s(!0)},children:[(0,X.jsx)(me,{}),` `,r(`schedulerNew`)]})]}),e.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:r(`schedulerEmpty`)}):(0,X.jsx)(`ul`,{className:`scheduler-list`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`scheduler-item ${e.enabled?``:`off`}`,children:[(0,X.jsxs)(`div`,{className:`scheduler-line1`,children:[(0,X.jsxs)(`span`,{className:`scheduler-name`,title:e.description||e.name,children:[e.running?`${r(`schedulerRunning`)} `:``,e.name]}),(0,X.jsx)(`span`,{className:`scheduler-badge ${e.enabled?`on`:``}`,children:e.enabled?r(`schedulerEnabled`):r(`schedulerDisabled`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-switch ${e.enabled?`on`:``}`,title:e.enabled?r(`schedulerDisable`):r(`schedulerEnable`),onClick:()=>$({type:`schedule_toggle`,id:e.id,enabled:!e.enabled}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsx)(`span`,{title:e.cwd,children:e.cwd}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsx)(`span`,{title:e.kind===`cron`?e.spec:`${e.spec} ms`,children:tb(e,r)})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsxs)(`span`,{children:[r(`schedulerNextFire`),`: `,e.nextFire?nb(e.nextFire):`—`]}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsxs)(`span`,{children:[r(`schedulerLastRun`),`:`,` `,e.lastRun?(0,X.jsxs)(X.Fragment,{children:[nb(e.lastRun.at),` ·`,` `,(0,X.jsx)(`span`,{className:e.lastRun.ok?`scheduler-ok`:`scheduler-fail`,children:e.lastRun.ok?r(`schedulerRunOk`):r(`schedulerRunFail`)}),e.lastRun.manual?` · ${r(`schedulerManualBadge`)}`:``,e.lastRun.error?` · ${e.lastRun.error}`:``]}):r(`schedulerNeverRun`)]}),e.history.length>1&&(0,X.jsxs)(`button`,{type:`button`,className:`scheduler-link`,onClick:()=>u(e.id),children:[r(`schedulerHistory`),` (`,e.history.length,`)`]})]}),c.has(e.id)&&e.history.length>0&&(0,X.jsx)(`ul`,{className:`scheduler-history`,children:e.history.map((e,t)=>(0,X.jsxs)(`li`,{children:[nb(e.at),` ·`,` `,(0,X.jsx)(`span`,{className:e.ok?`scheduler-ok`:`scheduler-fail`,children:e.ok?r(`schedulerRunOk`):r(`schedulerRunFail`)}),` · ${(e.durationMs/1e3).toFixed(0)}s`,e.manual?` · ${r(`schedulerManualBadge`)}`:``,e.error?` · ${e.error}`:``]},`${e.at}-${t}`))}),(0,X.jsxs)(`div`,{className:`scheduler-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:e.running,title:r(`schedulerRunNow`),onClick:()=>$({type:`schedule_run`,id:e.id}),children:[(0,X.jsx)(he,{}),` `,r(`schedulerRunNow`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerEdit`),onClick:()=>{a(eb(e)),s(!1)},children:[(0,X.jsx)(Y,{}),` `,r(`schedulerEdit`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerDelete`),onClick:()=>{window.confirm(r(`schedulerConfirmDelete`,{name:e.name}))&&$({type:`schedule_delete`,id:e.id})},children:[(0,X.jsx)(L,{}),` `,r(`schedulerDelete`)]})]})]},e.id))}),i&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>a(null),children:(0,X.jsxs)(`div`,{className:`modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":r(`close`),onClick:()=>a(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(rt,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:o?r(`schedulerNew`):`${r(`schedulerEdit`)} · ${i.name||``}`})]}),(0,X.jsxs)(`div`,{className:`modal-body`,children:[(0,X.jsxs)(`div`,{className:`tpl-fields`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerNamePlaceholder`),value:i.name,onChange:e=>a({...i,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerDescPlaceholder`),value:i.description,onChange:e=>a({...i,description:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerCwdLabel`)}),(0,X.jsxs)(`div`,{className:`scheduler-cwd-row`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerCwdPlaceholder`),value:i.cwd,onChange:e=>a({...i,cwd:e.target.value})}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>a({...i,cwd:t}),children:r(`schedulerUseCurrentCwd`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.kind,onChange:e=>a({...i,kind:e.target.value}),children:[(0,X.jsx)(`option`,{value:`cron`,children:r(`schedulerKindCron`)}),(0,X.jsx)(`option`,{value:`interval`,children:r(`schedulerKindInterval`)})]})]}),i.kind===`cron`?(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindCron`)}),(0,X.jsxs)(`div`,{className:`scheduler-cwd-row`,children:[(0,X.jsxs)(`select`,{className:`set-select`,value:i.preset,onChange:e=>{let t=e.target.value;a({...i,preset:t,...t===`custom`?{}:{cron:t}})},children:[Qy.map(e=>(0,X.jsxs)(`option`,{value:e.value,children:[r(e.key),` · `,e.value]},e.value)),(0,X.jsx)(`option`,{value:`custom`,children:r(`schedulerPresetCustom`)})]}),i.preset===`custom`&&(0,X.jsx)(`input`,{className:`set-input`,placeholder:r(`schedulerCronPlaceholder`),value:i.cron,onChange:e=>a({...i,cron:e.target.value})})]})]}):(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerKindInterval`)}),(0,X.jsx)(`input`,{className:`set-input`,type:`number`,min:1,placeholder:r(`schedulerIntervalMinutes`),value:i.intervalMinutes,onChange:e=>a({...i,intervalMinutes:e.target.value})})]}),(0,X.jsx)(`div`,{className:`tpl-fields`,children:(0,X.jsx)(`textarea`,{className:`set-input`,rows:4,placeholder:r(`schedulerPromptPlaceholder`),value:i.prompt,onChange:e=>a({...i,prompt:e.target.value})})}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:r(`schedulerModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.model,onChange:e=>a({...i,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`subagentFollowMain`)}),n.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})]}),n.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:r(`subagentNoModels`)}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[r(`schedulerThinkingLabel`),` `,(0,X.jsx)(Du,{text:r(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:i.thinkingLevel,onChange:e=>a({...i,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:r(`tplThinkingFollowMain`)}),W_.map(e=>(0,X.jsx)(`option`,{value:e,children:r(`thinking.${e}`)},e))]})]}),(0,X.jsxs)(`label`,{className:`scheduler-check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:i.catchUp,onChange:e=>a({...i,catchUp:e.target.checked})}),(0,X.jsxs)(`span`,{children:[r(`schedulerCatchUp`),` `,(0,X.jsx)(Du,{text:r(`schedulerCatchUpHint`)})]})]}),(0,X.jsxs)(`div`,{className:`scheduler-foot`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>a(null),children:r(`schedulerCancelEdit`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!i.name.trim()||!i.cwd.trim()||!i.prompt.trim(),onClick:()=>{if(!i)return;let e=i.kind;$({type:`schedule_save`,task:{...i.id?{id:i.id}:{},name:i.name.trim(),description:i.description.trim(),cwd:i.cwd.trim(),kind:e,spec:e===`cron`?i.cron.trim():String(Math.max(1,Math.floor(Number(i.intervalMinutes)||0))*6e4),prompt:i.prompt.trim(),...i.model.trim()?{model:i.model.trim()}:{},...i.thinkingLevel.trim()?{thinkingLevel:i.thinkingLevel.trim()}:{},catchUp:i.catchUp?`once`:`skip`}}),a(null)},children:r(`schedulerSave`)})]})]})]})})]})}var ib=`pi-web-sounds`,ab={enabled:!0,question:!0,done:!0,start:!1,error:!0,approval:!0,volume:100};function ob(){try{let e=localStorage.getItem(ib);if(!e)return{...ab};let t=JSON.parse(e),n={...ab,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`,`approval`])typeof n[e]!=`boolean`&&(n[e]=ab[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?ab.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...ab}}}function sb(e){try{localStorage.setItem(ib,JSON.stringify(e))}catch{}}var cb=null;function lb(){try{if(!cb){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;cb=new e}return cb.state===`suspended`&&cb.resume(),cb}catch{return null}}var ub={question:[{type:`sine`,freq:587.33,start:0,dur:.13,peak:.5},{type:`sine`,freq:880,start:.11,dur:.24,peak:.5}],done:[{type:`sine`,freq:880,start:0,dur:.15,peak:.35},{type:`sine`,freq:587.33,start:.15,dur:.32,peak:.35}],start:[{type:`triangle`,freq:660,start:0,dur:.08,peak:.22}],error:[{type:`square`,freq:220,start:0,dur:.16,peak:.18},{type:`square`,freq:174.61,start:.18,dur:.26,peak:.18}],approval:[{type:`sine`,freq:659.25,start:0,dur:.11,peak:.45},{type:`sine`,freq:659.25,start:.14,dur:.11,peak:.45},{type:`sine`,freq:880,start:.28,dur:.26,peak:.5}]};function db(e,t,n){let r=e.createOscillator(),i=e.createGain();r.type=t.type,r.frequency.value=t.freq;let a=e.currentTime+t.start,o=Math.max(1e-4,t.peak*n);i.gain.setValueAtTime(1e-4,a),i.gain.exponentialRampToValueAtTime(o,a+.012),i.gain.exponentialRampToValueAtTime(1e-4,a+t.dur),r.connect(i),i.connect(e.destination),r.start(a),r.stop(a+t.dur+.05)}function fb(e,t=ob()){if(!t.enabled||!t[e])return;let n=lb();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of ub[e])db(n,t,r)}function pb(e){if(e==null)return 0;if(typeof e==`number`){if(!Number.isFinite(e)||e<=0)return 0;let t=Math.floor(e);return t<=1e3?t*1e3:Math.min(1e7,t)}let t=String(e).trim().toLowerCase().replace(/[,_\s]/g,``);if(!t)return 0;let n=t.match(/^(\d+(?:\.\d+)?)([km])?$/);if(!n)return 0;let r=parseFloat(n[1]);if(!Number.isFinite(r)||r<=0)return 0;let i=n[2],a;return i===`k`?a=Math.floor(r*1e3):i===`m`?a=Math.floor(r*1e6):(a=Math.floor(r),a<=1e3&&(a*=1e3)),Math.min(1e7,Math.max(0,a))}function mb(e){return!e||e<=0||!Number.isFinite(e)?``:e>=1e6&&e%1e5==0?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3&&e%1e3==0?`${e/1e3}k`:String(e)}var hb=`pi-web-ui:wide-chat`,gb={wide:!1};function _b(e){if(!e||typeof e!=`object`)return{...gb};let t=e;return{wide:typeof t.wide==`boolean`?t.wide:gb.wide}}function vb(){try{let e=localStorage.getItem(hb);return e?_b(JSON.parse(e)):{...gb}}catch{return{...gb}}}function yb(e){let t=_b(e);try{localStorage.setItem(hb,JSON.stringify(t))}catch{}bb=t;for(let e of xb)e()}var bb=null,xb=new Set;function Sb(e){return xb.add(e),()=>{xb.delete(e)}}function Cb(){return bb||=vb(),bb.wide}function wb(){return(0,g.useSyncExternalStore)(Sb,Cb)}var Tb=`pi-web-ui:project-title`,Eb={projectName:!0};function Db(e){if(!e||typeof e!=`object`)return{...Eb};let t=e;return{projectName:typeof t.projectName==`boolean`?t.projectName:Eb.projectName}}function Ob(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``:``}function kb(){try{let e=localStorage.getItem(Tb);return e?Db(JSON.parse(e)):{...Eb}}catch{return{...Eb}}}function Ab(e){let t=Db(e);try{localStorage.setItem(Tb,JSON.stringify(t))}catch{}jb=t;for(let e of Mb)e()}var jb=null,Mb=new Set;function Nb(e){return Mb.add(e),()=>{Mb.delete(e)}}function Pb(){return jb||=kb(),jb.projectName}function Fb(){return(0,g.useSyncExternalStore)(Nb,Pb)}var Ib=`pi-web-ui:wallpaper`,Lb=`has-wallpaper`,Rb={url:``,dim:78,blur:0},zb=2e3,Bb=28e5;function Vb(e){if(typeof e!=`string`)return``;let t=e.trim();if(!t)return``;let n=t.toLowerCase().startsWith(`data:image/`)?Bb:zb;return t.length>n?``:/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith(`/`)&&!t.startsWith(`//`)?t:``}var Hb=(e,t,n,r)=>typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)));function Ub(e){if(!e||typeof e!=`object`)return{...Rb};let t=e;return{url:Vb(t.url),dim:Hb(t.dim,0,95,Rb.dim),blur:Hb(t.blur,0,24,Rb.blur)}}function Wb(){try{let e=localStorage.getItem(Ib);return e?Ub(JSON.parse(e)):{...Rb}}catch{return{...Rb}}}function Gb(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/[\r\n]/g,``)}async function Kb(e){let t=await dm(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function qb(){let e=Yb??Wb(),t=document.documentElement;e.url?(t.style.setProperty(`--bg-image`,`url("${Gb(e.url)}")`),t.style.setProperty(`--bg-image-dim`,String(e.dim/100)),t.style.setProperty(`--bg-image-blur`,`${e.blur}px`)):(t.style.removeProperty(`--bg-image`),t.style.removeProperty(`--bg-image-dim`),t.style.removeProperty(`--bg-image-blur`));let n=getComputedStyle(t).getPropertyValue(`--bg-image`).trim();document.body.classList.toggle(Lb,e.url!==``||n!==``&&n!==`none`)}function Jb(e){let t=Ub(e);Yb=t;try{localStorage.setItem(Ib,JSON.stringify(t))}catch{}for(let e of Xb)e();qb()}var Yb=null,Xb=new Set;function Zb(e){return Xb.add(e),()=>{Xb.delete(e)}}function Qb(){return Yb||=Wb(),Yb}function $b(){return(0,g.useSyncExternalStore)(Zb,Qb)}function ex(){let e=$b();(0,g.useEffect)(()=>{qb()},[e]),(0,g.useEffect)(()=>{let e=()=>qb();return window.addEventListener(ff,e),qb(),()=>window.removeEventListener(ff,e)},[])}var tx=[`prompt`,`tools`,`terminal`,`skills`,`ai`,`ui`,`engine`],nx={prompt:[`promptMode`,`customSystemPrompt`,`promptTemplate`,`promptOverrides`,`reviewPrompt`,`reviewDisabledSkills`],tools:[`disabledAgentTools`,`disabledPluginTools`,`toolPromptOverrides`,`toolLazyLoading`,`codemodeMode`,`codemodeInlineBudget`,`readDirEnabled`,`toolApprovalEnabled`,`toolWatchdogTimeoutMs`,`questionnaireEnabled`,`editSoftEnabled`,`terminalToolsEnabled`],terminal:[`terminalBash`,`terminalBashIdleMs`,`terminalBashMaxForegroundMs`],skills:[`disabledSkills`,`disabledExtensions`,`skillsFullText`],ai:[`retryMaxAttempts`,`softCapTokens`,`softCapByModel`,`subagentDefaultModel`,`visionBridgeEnabled`,`visionBridgeModel`,`visionBridgePromptMode`,`visionBridgePrompt`,`scmCommitMsgPromptMode`,`scmCommitMsgPrompt`,`planModePromptMode`,`planModePrompt`,`goalModeEnabled`,`parallelReminderEnabled`],ui:[`uiLayout`,`disabledPlugins`,`thinkingWrap`,`toolsWrap`,`toolImagesEnabled`,`keepRecentMessages`,`bgAutoCleanupMin`,`quickPhrases`,`quickPhrasesEnabled`,`devNoCache`,`autoReload`],engine:[`defaultAgentPreset`,`defaultPermissionPreset`]};(()=>{let e=[];for(let t of tx)for(let n of nx[t])e.includes(n)||e.push(n);return e})();function rx(e){let t=new Set(e),n=[];for(let e of tx){let r=nx[e].filter(e=>t.has(e));r.length>0&&n.push({group:e,fields:r})}return n}var ix={promptMode:{labelZh:`提示词模式`,labelEn:`Prompt Mode`,hintZh:`追加到内置提示词 (append) 或完全替换系统内置提示词 (replace)`,hintEn:`Append to built-in prompt or completely replace it`},customSystemPrompt:{labelZh:`自定义系统提示词`,labelEn:`Custom System Prompt`,hintZh:`定制 AI 基础人设与工作规约的主提示词`,hintEn:`Main prompt customizing AI persona and instructions`},promptTemplate:{labelZh:`组合模板`,labelEn:`Prompt Template`,hintZh:`高级提示词组装模板(包含各个 slot 占位符)`,hintEn:`Advanced prompt composition template with slot placeholders`},promptOverrides:{labelZh:`逐段提示词覆盖`,labelEn:`Sectional Prompt Overrides`,hintZh:`微调特定提示词段落(如 soul/cwd/skills 等)`,hintEn:`Overrides for specific prompt sections (soul, cwd, skills, etc.)`},reviewPrompt:{labelZh:`目标模式审查提示词`,labelEn:`Goal Mode Review Prompt`,hintZh:`目标模式 2.0 中审查者专用的判定与指导提示词`,hintEn:`Prompt for the reviewer in Goal Mode 2.0`},reviewDisabledSkills:{labelZh:`审查时禁用的技能`,labelEn:`Skills Disabled in Review`,hintZh:`仅在目标审查阶段禁止审查者调用的技能列表`,hintEn:`Skills unavailable to the reviewer in Goal Mode`},disabledAgentTools:{labelZh:`禁用的内置工具`,labelEn:`Disabled Agent Tools`,hintZh:`不在 AI 可用工具列表中暴露的内置工具`,hintEn:`Built-in tools removed from agent visibility`},disabledPluginTools:{labelZh:`禁用的插件工具`,labelEn:`Disabled Plugin Tools`,hintZh:`禁止向 AI 注册的第三方插件工具`,hintEn:`Plugin-provided tools removed from agent visibility`},toolPromptOverrides:{labelZh:`工具提示词覆盖`,labelEn:`Tool Prompt Overrides`,hintZh:`微调工具在模型视野中的描述、触发条件与使用指南`,hintEn:`Custom descriptions, snippets and guidelines for tools`},toolLazyLoading:{labelZh:`工具按需延迟加载`,labelEn:`Tool Lazy Loading`,hintZh:`仅常驻核心工具,其余工具通过 load_tools 按需动态引入(节省上下文)`,hintEn:`Keep only core tools active; load others on demand (saves context)`},codemodeMode:{labelZh:`codemode 运行模式`,labelEn:`Codemode Execution Mode`,hintZh:`常规模式(on)或纯代码模式(only,仅通过沙箱脚本调用工具)`,hintEn:`Regular mode (on) or strict code mode (only, all tool calls run via sandbox script)`},codemodeInlineBudget:{labelZh:`codemode 工具声明预算`,labelEn:`Codemode Inline Budget`,hintZh:`直接嵌入在 codemode 系统提示词中的工具声明 Token 预算(默认 3000)`,hintEn:`Token budget for tool declarations directly embedded in the codemode prompt (default: 3000)`},readDirEnabled:{labelZh:`read 工具列目录`,labelEn:`Directory Listing in read`,hintZh:`允许 read 工具在路径为目录时直接返回文件列表`,hintEn:`Allow read tool to list directory entries when target is a folder`},toolApprovalEnabled:{labelZh:`工具执行审批门禁`,labelEn:`Tool Execution Approval`,hintZh:`执行危险或写操作工具前弹出用户确认确认框`,hintEn:`Require user approval before executing tools`},bgAutoCleanupMin:{labelZh:`后台任务自动清理`,labelEn:`Background Task Auto-cleanup`,hintZh:`定期清理闲置超阈值的 AI 起后台实例(分钟;0 = 关;面板里📌钉住的不算)`,hintEn:`Periodically clean AI-started background instances idle past the threshold (minutes; 0 = off; pinned ones skipped)`},toolWatchdogTimeoutMs:{labelZh:`工具看门狗超时`,labelEn:`Tool Watchdog Timeout`,hintZh:`工具长时间未返回时的最长等待熔断时间`,hintEn:`Maximum execution time before aborting stuck tools`},questionnaireEnabled:{labelZh:`问卷模式 (ask_user_question)`,labelEn:`Questionnaire Mode`,hintZh:`允许 AI 遇到歧义时弹窗向用户多选/单选确认`,hintEn:`Allow agent to ask interactive multiple-choice questions`},editSoftEnabled:{labelZh:`宽松缩进编辑 (edit_soft)`,labelEn:`Soft Indentation Edit`,hintZh:`提供忽略前导空白缩进差异的鲁棒编辑工具`,hintEn:`Provide indentation-tolerant text replacement tool`},terminalToolsEnabled:{labelZh:`终端工具集`,labelEn:`Terminal Toolset`,hintZh:`向 AI 开放持久交互式 PTY 终端驱动工具`,hintEn:`Enable persistent PTY interactive terminal tools`},terminalBash:{labelZh:`终端接管 Bash`,labelEn:`Terminal Takes Over Bash`,hintZh:`将 bash 工具调用分流至可见交互终端并实时回显`,hintEn:`Route bash execution into the visible interactive terminal`},terminalBashIdleMs:{labelZh:`终端静默超时`,labelEn:`Terminal Idle Timeout`,hintZh:`终端无新输出时判定为完成的静默时间`,hintEn:`Idle duration before assuming command finished`},terminalBashMaxForegroundMs:{labelZh:`前台最长运行时间`,labelEn:`Max Foreground Runtime`,hintZh:`前台命令超时未退出的强制截断时间`,hintEn:`Timeout before cutting off long foreground commands`},disabledSkills:{labelZh:`禁用的技能`,labelEn:`Disabled Skills`,hintZh:`在当前工作区中禁用的技能列表`,hintEn:`Skills excluded in the current workspace`},disabledExtensions:{labelZh:`禁用的扩展`,labelEn:`Disabled Extensions`,hintZh:`在当前项目中禁用的扩展列表`,hintEn:`Extensions excluded in the current project`},skillsFullText:{labelZh:`技能全文常驻`,labelEn:`Skills Full Text in Context`,hintZh:`将指定技能的完整正文直接注入上下文,跳过 skill 工具按需载入`,hintEn:`Inject full text of selected skills directly into context`},retryMaxAttempts:{labelZh:`网络重试上限`,labelEn:`Network Retry Attempts`,hintZh:`模型网络请求失败时的最大自动重试次数`,hintEn:`Max auto-retries when model requests fail`},softCapTokens:{labelZh:`上下文压缩软上限`,labelEn:`Context Soft-Cap Tokens`,hintZh:`提前触发上下文平滑压缩的 token 阈值(默认 16384)`,hintEn:`Token threshold to trigger context compaction early`},softCapByModel:{labelZh:`分模型压缩软上限`,labelEn:`Per-Model Soft-Cap`,hintZh:`针对不同模型单独设置的上下文压缩阈值`,hintEn:`Custom soft-cap thresholds configured per model`},subagentDefaultModel:{labelZh:`子代理默认模型`,labelEn:`Subagent Default Model`,hintZh:`派生子代理时优先使用的专用模型(留空跟随主对话)`,hintEn:`Dedicated model for subagents (empty to follow main chat)`},visionBridgeEnabled:{labelZh:`视觉桥 (看图转写)`,labelEn:`Vision Bridge`,hintZh:`主模型不具备识图能力时,自动使用带视觉的模型预先转写图片`,hintEn:`Use vision model to describe images when main model is text-only`},visionBridgeModel:{labelZh:`视觉桥专属模型`,labelEn:`Vision Bridge Model`,hintZh:`用于看图转写的视觉模型 ID`,hintEn:`Model ID used for vision transcription`},visionBridgePromptMode:{labelZh:`视觉桥提示词模式`,labelEn:`Vision Bridge Prompt Mode`,hintZh:`视觉桥转写提示词的追加/替换模式`,hintEn:`Append or replace mode for vision bridge prompt`},visionBridgePrompt:{labelZh:`视觉桥提示词`,labelEn:`Vision Bridge Prompt`,hintZh:`指导视觉模型如何描述图片的系统提示词`,hintEn:`System prompt guiding image transcription`},scmCommitMsgPromptMode:{labelZh:`Git 提交信息提示词模式`,labelEn:`Git Commit Prompt Mode`,hintZh:`AI 生成 Git 提交信息时的提示词模式`,hintEn:`Prompt mode for AI-generated Git commit messages`},scmCommitMsgPrompt:{labelZh:`Git 提交信息提示词`,labelEn:`Git Commit Prompt`,hintZh:`指导 AI 根据 git diff 撰写提交信息的规范提示词`,hintEn:`Prompt guiding AI to write commit messages from git diff`},planModePromptMode:{labelZh:`计划模式提示词模式`,labelEn:`Plan Mode Prompt Mode`,hintZh:`计划模式提示词的追加/替换模式`,hintEn:`Append or replace mode for Plan Mode prompt`},planModePrompt:{labelZh:`计划模式提示词`,labelEn:`Plan Mode Prompt`,hintZh:`计划模式下限制模型只规划不施工的系统提示词`,hintEn:`System prompt restricting agent to planning only`},goalModeEnabled:{labelZh:`目标模式 2.0`,labelEn:`Goal Mode 2.0`,hintZh:`主对话当审查者,服务端常驻执行对话协同干活`,hintEn:`Reviewer/executor loop architecture for goal tasks`},parallelReminderEnabled:{labelZh:`并行编辑提醒`,labelEn:`Parallel Edit Reminder`,hintZh:`多个标签页同时编辑同一会话时的冲突告警`,hintEn:`Warn when multiple tabs edit the same session`},uiLayout:{labelZh:`界面布局与图标排列`,labelEn:`UI Layout & Icons`,hintZh:`顶栏、底栏、左右侧边栏按钮的自定义顺序、可见性与对齐`,hintEn:`Custom order, visibility and alignment for bars and docks`},disabledPlugins:{labelZh:`禁用的插件`,labelEn:`Disabled Plugins`,hintZh:`停用的 UI 插件列表`,hintEn:`List of deactivated UI plugins`},thinkingWrap:{labelZh:`思考区自动折行`,labelEn:`Thinking Block Word Wrap`,hintZh:`思考展开区长文本是否自动折行`,hintEn:`Enable word wrap inside thinking blocks`},toolsWrap:{labelZh:`工具调用自动折行`,labelEn:`Tool Call Word Wrap`,hintZh:`工具调用参数与结果长文本是否自动折行`,hintEn:`Enable word wrap for tool parameters and results`},toolImagesEnabled:{labelZh:`工具调用图片渲染`,labelEn:`Tool Image Preview`,hintZh:`直接在工具卡片内渲染输出的图片文件`,hintEn:`Render image output directly in tool cards`},keepRecentMessages:{labelZh:`常驻渲染消息数`,labelEn:`Messages Kept In Full`,hintZh:`消息列表尾部保持完整渲染的消息条数;更早的折叠为摘要行`,hintEn:`Recent messages rendered in full; older ones collapse to summary rows`},quickPhrases:{labelZh:`快捷短语列表`,labelEn:`Quick Phrases List`,hintZh:`输入框上方的常用提示短语快捷按钮`,hintEn:`Quick prompt phrase buttons above composer`},quickPhrasesEnabled:{labelZh:`启用快捷短语`,labelEn:`Enable Quick Phrases`,hintZh:`是否在输入框上方显示快捷短语药丸栏`,hintEn:`Display quick phrases bar above composer`},devNoCache:{labelZh:`开发者免缓存模式`,labelEn:`Developer No-Cache Mode`,hintZh:`前端静态资源强制请求最新,不走缓存`,hintEn:`Bypass browser cache for static frontend assets`},autoReload:{labelZh:`插件自动热重载`,labelEn:`Auto Reload on File Change`,hintZh:`本地插件文件变更时自动刷新插件运行时`,hintEn:`Automatically reload plugins when files change`},defaultAgentPreset:{labelZh:`默认智能体预设`,labelEn:`Default Agent Preset`,hintZh:`新建会话时默认加载的智能体预设(DSH 多引擎)`,hintEn:`Default agent preset applied to new sessions (DSH)`},defaultPermissionPreset:{labelZh:`默认权限预设`,labelEn:`Default Permission Preset`,hintZh:`新建会话时默认加载的权限预设`,hintEn:`Default permission preset applied to new sessions`}};function ax(e,t=`zh`){let n=ix[e];return n?t===`zh`?n.labelZh:n.labelEn:e}function ox(e,t=`zh`){let n=ix[e];return n&&(t===`zh`?n.hintZh:n.hintEn)||``}function sx(e,t,n=`zh`){let r=n===`zh`;if(t==null)return{summary:r?`未配置(跟随当前值)`:`Not configured (keeps current)`};if(e===`disabledAgentTools`){let e=Array.isArray(t)?t.filter(e=>typeof e==`string`&&!!e):[],n=Fr(e);return e.length===0?{summary:r?`全部启用(共 ${n.length} 个可用工具)`:`All enabled (${n.length} available tools)`,detail:[`[${r?`已启用可用工具`:`Enabled Tools`} (${n.length})]`,...n.map(e=>` ✓ ${e}`)].join(`
664
664
  `)}:{summary:r?`启用 ${n.length} 个,禁用 ${e.length} 个(默认没开即关)`:`Enabled ${n.length}, disabled ${e.length} (defaults to off)`,detail:[`[${r?`已启用可用配置`:`Enabled Tools`} (${n.length})]`,...n.map(e=>` ✓ ${e}`),``,`[${r?`已禁用(默认没开即关)`:`Disabled Tools (defaults to off)`} (${e.length})]`,...e.map(e=>` ✗ ${e}`)].join(`
665
665
  `)}}if(e===`disabledPluginTools`){let e=Array.isArray(t)?t.filter(e=>typeof e==`string`&&!!e):[];return e.length===0?{summary:r?`全部启用(无禁用)`:`All enabled (none disabled)`}:{summary:r?`禁用 ${e.length} 个插件工具(${e.join(`, `)})`:`Disabled ${e.length} plugin tool(s): ${e.join(`, `)}`,detail:e.map(e=>`- ${e}`).join(`
666
666
  `)}}if(e===`toolPromptOverrides`){if(!t||typeof t!=`object`||Array.isArray(t))return{summary:r?`无覆盖`:`No overrides`};let e=t,n=Object.keys(e);if(n.length===0)return{summary:r?`无覆盖(使用官方出厂提示词)`:`No overrides (uses factory defaults)`};let i=[];for(let[t,n]of Object.entries(e)){if(i.push(`[${t}]`),n.description&&i.push(` ${r?`描述`:`Description`}: ${n.description}`),n.promptSnippet&&i.push(` ${r?`触发摘要`:`Snippet`}: ${n.promptSnippet}`),n.promptGuidelines&&n.promptGuidelines.length>0){i.push(` ${r?`使用指南`:`Guidelines`}:`);for(let e of n.promptGuidelines)i.push(` • ${e}`)}i.push(``)}return{summary:r?`覆盖了 ${n.length} 个工具的提示词(${n.join(`, `)})`:`Overrides prompts for ${n.length} tool(s): ${n.join(`, `)}`,detail:i.join(`
@@ -668,13 +668,13 @@ Systematic steps for investigating and resolving software defects:
668
668
  `)}}if(e===`skillsFullText`){let e=Array.isArray(t)?t.filter(e=>typeof e==`string`&&!!e):[];return e.length===0?{summary:r?`无(全部按需加载)`:`None (loaded on demand)`}:{summary:r?`常驻 ${e.length} 项技能全文(${e.join(`, `)})`:`Pinned full text for ${e.length} skill(s): ${e.join(`, `)}`,detail:e.map(e=>`- ${e}`).join(`
669
669
  `)}}if(e===`customSystemPrompt`||e===`promptTemplate`||e===`reviewPrompt`||e===`visionBridgePrompt`||e===`scmCommitMsgPrompt`||e===`planModePrompt`){let e=typeof t==`string`?t:``;if(!e.trim())return{summary:r?`(空)`:`(empty)`};let n=e.length>60?`${e.slice(0,60)}…`:e;return{summary:r?`包含 ${e.length} 字符:${n.replace(/\s+/g,` `)}`:`${e.length} chars: ${n.replace(/\s+/g,` `)}`,detail:e}}if(e===`promptOverrides`){if(!t||typeof t!=`object`||Array.isArray(t))return{summary:r?`无覆盖`:`No overrides`};let e=t,n=Object.keys(e);if(n.length===0)return{summary:r?`无覆盖`:`No overrides`};let i=[];for(let[t,n]of Object.entries(e))i.push(`[${t}] (${n.length} chars)`),i.push(n),i.push(``);return{summary:r?`覆盖 ${n.length} 个内置段落(${n.join(`, `)})`:`Overrides ${n.length} section(s): ${n.join(`, `)}`,detail:i.join(`
670
670
  `).trimEnd()}}if(e===`codemodeMode`)return{summary:t===`only`?r?`纯代码模式 (only,仅通过沙箱脚本调用工具)`:`Strict code mode (only, sandbox scripts only)`:r?`常规模式 (on,常规可用,支持脚本批处理)`:`Standard mode (on, direct & scripts)`};if(e===`promptMode`||e===`visionBridgePromptMode`||e===`scmCommitMsgPromptMode`||e===`planModePromptMode`)return{summary:t===`replace`?r?`替换内置系统提示词 (replace)`:`Replaces built-in system prompt (replace)`:r?`追加到系统提示词后 (append)`:`Appends to system prompt (append)`};if(e===`uiLayout`)return!t||typeof t!=`object`?{summary:r?`默认布局`:`Default layout`}:{summary:r?`包含自定义工具栏、停靠栏排列与对齐设置`:`Custom layout, bar order and dock alignment`};if(typeof t==`boolean`)return e===`toolLazyLoading`?{summary:t?r?`开启(仅核心工具常驻,其余按需加载)`:`Enabled (core only, others on-demand)`:r?`关闭(所有工具全部直接挂载)`:`Disabled (all tools loaded)`}:e===`terminalBash`?{summary:t?r?`开启(命令分流到可见交互终端)`:`Enabled (routes to interactive terminal)`:r?`关闭(后台执行)`:`Disabled (runs in background)`}:e===`toolApprovalEnabled`?{summary:t?r?`开启(写操作与高危工具需人工审批)`:`Enabled (approval needed for write tools)`:r?`关闭(直接放行执行)`:`Disabled (auto allow)`}:e===`questionnaireEnabled`?{summary:t?r?`开启(遇到歧义向用户发起交互问答)`:`Enabled (interactive questions allowed)`:r?`关闭`:`Disabled`}:{summary:t?r?`开启`:`Enabled`:r?`关闭`:`Disabled`};if(typeof t==`number`)return e===`codemodeInlineBudget`?{summary:`${t} tokens`}:e===`softCapTokens`?{summary:t>0?`${t} tokens`:r?`跟随默认 (16384 tokens)`:`Default (16384 tokens)`}:e===`retryMaxAttempts`?{summary:r?`最大重试 ${t} 次`:`Max ${t} attempts`}:e===`toolWatchdogTimeoutMs`?{summary:r?`${Math.round(t/6e4)} 分钟`:`${Math.round(t/6e4)} min`}:e===`bgAutoCleanupMin`?{summary:t>0?r?`闲置 ${t} 分钟后清理`:`clean after ${t} min idle`:r?`关闭`:`Off`}:e===`terminalBashIdleMs`||e===`terminalBashMaxForegroundMs`?{summary:r?`${Math.round(t/1e3)} 秒`:`${Math.round(t/1e3)} s`}:{summary:String(t)};if(e===`quickPhrases`){let e=Array.isArray(t)?t.filter(e=>typeof e==`string`):[];return{summary:r?`包含 ${e.length} 条快捷短语`:`${e.length} quick phrase(s)`,detail:e.map((e,t)=>`${t+1}. ${e}`).join(`
671
- `)}}if(e===`subagentDefaultModel`||e===`visionBridgeModel`){let e=typeof t==`string`?t.trim():``;return{summary:e?r?`指定模型:${e}`:`Model: ${e}`:r?`跟随主对话模型`:`Follows main chat model`}}return{summary:String(t)}}function Yb(e){return`${e===`paste`?`paste`:e}:${jt()}`}function Xb(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString()}function Zb(e){switch(e){case`prompt`:return`presetGroupPrompt`;case`tools`:return`presetGroupTools`;case`terminal`:return`presetGroupTerminal`;case`skills`:return`presetGroupSkills`;case`ai`:return`presetGroupAi`;case`ui`:return`presetGroupUi`;case`engine`:return`presetGroupEngine`}return`presetGroupOther`}function Qb({presets:e,presetExport:t,presetImport:n,presetCatalog:r,presetShare:i,initialPreset:a=``,initialTab:o=`export`,onClose:s}){let c=Z(),[l,u]=(0,g.useState)(o),[d,f]=(0,g.useState)(a),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(!1),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(``),[O,k]=(0,g.useState)(null),[A,j]=(0,g.useState)(!1),[ee,M]=(0,g.useState)(null),[te,N]=(0,g.useState)(new Set),ne=(0,g.useRef)(null),[F,re]=(0,g.useState)(``),[L,ie]=(0,g.useState)(!1);(0,g.useEffect)(()=>{$({type:`preset_catalog`,requestId:`catalog:${jt()}`})},[]);let R=(0,g.useRef)(0);(0,g.useEffect)(()=>{r&&r.receivedAt!==R.current&&(R.current=r.receivedAt,ie(!1))},[r]);let z=(0,g.useRef)(0);(0,g.useEffect)(()=>{if(i&&i.receivedAt!==z.current){if(z.current=i.receivedAt,C(!1),i.method===`browser`){i.json&&navigator.clipboard?.writeText(i.json).catch(()=>{}),i.url&&window.open(i.url,`_blank`,`noopener,noreferrer`);return}i.ok&&i.url&&window.open(i.url,`_blank`,`noopener,noreferrer`)}},[i]);let B=(0,g.useRef)(0);(0,g.useEffect)(()=>{n&&n.receivedAt!==B.current&&(B.current=n.receivedAt,n.dryRun&&n.preview&&M(new Set(n.preview.fields)),n.ok&&!n.dryRun&&(T(``),D(``),k(null),M(null)))},[n]);let V=(0,g.useMemo)(()=>{let e=h.split(/[,,]/).map(e=>e.trim()).filter(Boolean);return{source:d?`preset`:`current`,name:d,...p.trim()?{description:p.trim()}:{},...v.trim()?{author:v.trim()}:{},...e.length>0?{tags:e}:{}}},[d,p,h,v]),H=()=>$({type:`preset_export`,...V,requestId:`export:${jt()}`}),U=()=>{C(!0),$({type:`preset_share`,...V,requestId:`share:${jt()}`})},ae=()=>{t?.json&&lu(new Blob([t.json],{type:`application/json`}),t.fileName||`${t.name||`preset`}.json`)},oe=()=>{t?.json&&navigator.clipboard?.writeText(t.json).then(()=>{x(!0),window.setTimeout(()=>x(!1),1500)}).catch(()=>{})},se=(e,t)=>{e.trim()&&(k({source:t,json:e}),$({type:`preset_import`,json:e,dryRun:!0,requestId:Yb(t)}))},ce=(e,t=`url`)=>{e.trim()&&(k({source:t,url:e}),$({type:`preset_import_url`,url:e,dryRun:!0,requestId:Yb(t)}))},le=()=>{if(!O||_e.size===0)return;let e={dryRun:!1,name:n?.preview?.name,apply:A,fields:[..._e],requestId:Yb(O.source)};O.url?$({type:`preset_import_url`,url:O.url,...e}):O.json&&$({type:`preset_import`,json:O.json,...e})},ue=e=>{if(!e)return;let t=new FileReader;t.onload=()=>se(String(t.result??``),`file`),t.readAsText(e)},de=()=>{ie(!0),$({type:`preset_catalog`,refresh:!0,requestId:`catalog:${jt()}`})},fe=r?.entries??[],pe=(0,g.useMemo)(()=>{let e=F.trim().toLowerCase();return e?fe.filter(t=>[t.name,t.description,t.author,t.tags.join(` `)].some(t=>t.toLowerCase().includes(e))):fe},[fe,F]),G=n?.dryRun?n.preview:void 0,me=n?.ok&&!n.dryRun?n.preview:void 0,he=c(`ok`)===`确定`,ge=he?`zh`:`en`,q=G?.fields??[],_e=ee??new Set(q),ve=Wb(q),ye=q.length>0&&q.every(e=>_e.has(e)),be=e=>M(()=>{let t=new Set(_e);return t.has(e)?t.delete(e):t.add(e),t}),xe=e=>N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=(e,t)=>M(()=>{let n=new Set(_e);for(let r of e)t?n.add(r):n.delete(r);return n});return(0,X.jsxs)(Ny,{className:`preset-share-modal`,onClose:s,showCloseButton:!1,children:[(0,X.jsxs)(`div`,{className:`preset-share-head`,children:[(0,X.jsxs)(`span`,{className:`preset-share-title`,children:[(0,X.jsx)(W,{}),` `,c(`presetShare`)]}),(0,X.jsx)(`div`,{className:`preset-share-tabs`,children:[[`export`,`presetShareTabExport`],[`import`,`presetShareTabImport`],[`browse`,`presetShareTabBrowse`]].map(([e,t])=>(0,X.jsxs)(`button`,{type:`button`,className:`preset-share-tab${l===e?` active`:``}`,onClick:()=>u(e),children:[c(t),e===`browse`&&fe.length>0&&(0,X.jsx)(`em`,{className:`preset-share-badge`,children:fe.length})]},e))}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:c(`close`),onClick:s,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`preset-share-body`,children:[l===`export`&&(0,X.jsxs)(`div`,{className:`preset-share-pane`,children:[(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetShareSource`)}),(0,X.jsxs)(`select`,{className:`set-input`,value:d,onChange:e=>f(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:c(`presetShareSourceCurrent`)}),e.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]})]}),(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetShareDescription`)}),(0,X.jsx)(`input`,{className:`set-input`,value:p,placeholder:c(`presetShareDescriptionPlaceholder`),onChange:e=>m(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetShareTags`)}),(0,X.jsx)(`input`,{className:`set-input`,value:h,placeholder:c(`presetShareTagsPlaceholder`),onChange:e=>_(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetShareAuthor`)}),(0,X.jsx)(`input`,{className:`set-input`,value:v,onChange:e=>y(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:H,children:[(0,X.jsx)(qe,{}),` `,c(`presetExportJson`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:U,disabled:S,children:[S?(0,X.jsx)(K,{className:`preset-share-spin`}):(0,X.jsx)(W,{}),c(S?`presetShareSubmitting`:`presetShareSubmit`)]})]}),(0,X.jsx)(`p`,{className:`preset-share-hint`,children:c(`presetShareHint`)}),i&&i.method===`browser`&&(0,X.jsxs)(`div`,{className:`preset-share-result-box`,children:[(0,X.jsxs)(`div`,{className:`preset-share-result-head`,children:[(0,X.jsx)(Ge,{}),` `,(0,X.jsx)(`strong`,{children:c(`presetShareOpenWebTitle`)})]}),i.error&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:i.error}),(0,X.jsxs)(`p`,{className:`preset-share-hint`,children:[c(`presetShareBrowserCopied`),i.url&&` ${c(`presetSharePopupBlocked`)}`]}),(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[i.url&&(0,X.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noopener noreferrer`,className:`btn primary`,children:[(0,X.jsx)(Ge,{}),` `,c(`presetShareOpenWebBtn`)]}),i.json&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{i.json&&navigator.clipboard?.writeText(i.json).then(()=>{x(!0),window.setTimeout(()=>x(!1),1500)})},children:c(b?`copied`:`presetShareCopyJson`)})]})]}),i?.ok&&(i.method===`gh`||i.method===`api`)&&i.url&&(0,X.jsxs)(`div`,{className:`preset-share-result-box preset-share-result-success`,children:[(0,X.jsx)(`p`,{className:`preset-share-ok`,children:c(`presetImportImported`,{name:i.name||``})}),(0,X.jsx)(`div`,{className:`preset-share-actions`,children:(0,X.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noopener noreferrer`,className:`btn`,children:[(0,X.jsx)(Ge,{}),` `,c(`presetShareOpenIssueBtn`)]})})]}),i?.ok===!1&&!i.method&&i.error&&(0,X.jsx)(`p`,{className:`preset-share-error`,children:i.error}),t?.ok===!1&&t.error&&(0,X.jsx)(`p`,{className:`preset-share-error`,children:t.error}),t?.ok&&t.json&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:oe,children:c(b?`copied`:`copy`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:ae,children:[(0,X.jsx)(qe,{}),` `,c(`presetExportDownload`)]})]}),(0,X.jsx)(`textarea`,{className:`preset-share-json`,readOnly:!0,value:t.json,spellCheck:!1})]})]}),l===`import`&&(0,X.jsxs)(`div`,{className:`preset-share-pane`,children:[(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetImportText`)}),(0,X.jsx)(`textarea`,{className:`preset-share-input`,value:w,placeholder:c(`presetImportTextPlaceholder`),spellCheck:!1,onChange:e=>T(e.target.value),onBlur:()=>se(w,`paste`)})]}),(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>se(w,`paste`),disabled:!w.trim(),children:[(0,X.jsx)(I,{}),` `,c(`preview`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>ne.current?.click(),children:[(0,X.jsx)(He,{}),` `,c(`presetImportPickFile`)]}),(0,X.jsx)(`input`,{ref:ne,type:`file`,accept:`.json,application/json`,style:{display:`none`},onChange:e=>{ue(e.target.files?.[0]),e.target.value=``}})]}),(0,X.jsxs)(`div`,{className:`preset-share-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input`,value:E,placeholder:c(`presetImportUrlPlaceholder`),onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ce(E)}}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>ce(E),disabled:!E.trim(),children:[(0,X.jsx)(Fe,{}),` `,c(`presetImportFromUrl`)]})]}),n?.ok===!1&&n.error&&(0,X.jsx)(`p`,{className:`preset-share-error`,children:n.error}),G&&(0,X.jsxs)(`div`,{className:`preset-share-preview`,children:[(0,X.jsxs)(`div`,{className:`preset-share-preview-head`,children:[(0,X.jsx)(`strong`,{children:c(`presetImportPreview`)}),(0,X.jsx)(`span`,{className:`preset-share-preview-name`,children:G.name})]}),G.description&&(0,X.jsx)(`p`,{className:`preset-share-preview-desc`,children:G.description}),(0,X.jsxs)(`ul`,{className:`preset-share-meta`,children:[(0,X.jsx)(`li`,{children:c(`presetImportFields`,{n:G.fields.length})}),G.author&&(0,X.jsx)(`li`,{children:G.author}),G.tags.length>0&&(0,X.jsx)(`li`,{children:G.tags.join(` · `)}),G.summary.skills>0&&(0,X.jsx)(`li`,{children:`${c(`settingsSkills`)} ${G.summary.skills}`}),G.summary.agentTools>0&&(0,X.jsx)(`li`,{children:`${c(`settingsTools`)} ${G.summary.agentTools}`})]}),G.ignored.length>0&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:c(`presetImportIgnored`,{list:G.ignored.join(`, `)})}),G.rejected.length>0&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:c(`presetImportRejected`,{list:G.rejected.join(`, `)})}),G.customSystemPrompt&&(0,X.jsx)(`pre`,{className:`preset-share-snippet`,children:G.customSystemPrompt}),G.reviewPrompt&&(0,X.jsx)(`pre`,{className:`preset-share-snippet`,children:G.reviewPrompt}),G.replaces&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:c(`presetImportReplaces`)}),q.length>0&&(0,X.jsxs)(`div`,{className:`preset-share-pick`,children:[(0,X.jsxs)(`div`,{className:`preset-share-pick-head`,children:[(0,X.jsx)(`strong`,{children:c(`presetImportPick`)}),(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>M(new Set(q)),children:c(`presetImportSelectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>M(new Set),children:c(`presetImportSelectNone`)})]}),(0,X.jsx)(`p`,{className:`set-note`,children:c(`presetImportPickHint`)}),ye&&(0,X.jsx)(`span`,{className:`preset-share-pick-all`,children:c(`presetImportAllSelected`)}),ve.map(({group:e,fields:t})=>(0,X.jsxs)(`div`,{className:`preset-share-pick-group`,children:[(0,X.jsxs)(`label`,{className:`preset-share-check preset-share-pick-grouptitle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.every(e=>_e.has(e)),onChange:e=>J(t,e.target.checked)}),c(Zb(e)),(0,X.jsxs)(`span`,{className:`set-count`,children:[t.filter(e=>_e.has(e)).length,`/`,t.length]})]}),(0,X.jsx)(`div`,{className:`preset-share-pick-fields`,children:t.map(e=>{let t=G.settings?.[e],{summary:n,detail:r}=Jb(e,t,ge),i=Kb(e,ge),a=qb(e,ge),o=te.has(e);return(0,X.jsxs)(`div`,{className:`preset-share-pick-item`,children:[(0,X.jsxs)(`div`,{className:`preset-share-pick-item-head`,children:[(0,X.jsxs)(`label`,{className:`preset-share-check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:_e.has(e),onChange:()=>be(e)}),(0,X.jsx)(`span`,{className:`preset-share-pick-label`,children:i})]}),(0,X.jsx)(`code`,{className:`preset-share-pick-code`,children:e}),n&&(0,X.jsx)(`span`,{className:`preset-share-pick-summary`,children:n}),r&&(0,X.jsx)(`button`,{type:`button`,className:`preset-share-pick-toggle`,onClick:()=>xe(e),children:o?he?`收起 ▲`:`Collapse ▲`:he?`查看详情 ▼`:`Details ▼`})]}),a&&(0,X.jsx)(`p`,{className:`preset-share-pick-hint`,children:a}),r&&o&&(0,X.jsx)(`pre`,{className:`preset-share-pick-detail`,children:r})]},e)})})]},e)),_e.size===0&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:c(`presetImportNoneSelected`)})]}),(0,X.jsxs)(`label`,{className:`preset-share-check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked)}),c(`presetImportApply`)]}),(0,X.jsx)(`div`,{className:`preset-share-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:_e.size===0,onClick:le,children:c(`presetImportConfirm`)})})]}),me&&(0,X.jsx)(`p`,{className:`preset-share-ok`,children:c(`presetImportImported`,{name:me.name})})]}),l===`browse`&&(0,X.jsxs)(`div`,{className:`preset-share-pane`,children:[(0,X.jsxs)(`div`,{className:`preset-share-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input`,value:F,placeholder:c(`presetBrowseSearch`),onChange:e=>re(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:de,disabled:L,children:[(0,X.jsx)(K,{className:L?`preset-share-spin`:void 0}),` `,c(`presetBrowseRefresh`)]})]}),r?.error&&(0,X.jsx)(`p`,{className:`preset-share-error`,children:r.error}),r?.cached&&r.fetchedAt>0&&(0,X.jsx)(`p`,{className:`preset-share-hint`,children:c(`presetBrowseCached`,{time:Xb(new Date(r.fetchedAt).toISOString())})}),pe.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:c(!r||L?`presetBrowseLoading`:`presetBrowseEmpty`)}):(0,X.jsx)(`ul`,{className:`preset-share-list`,children:pe.map(e=>(0,X.jsxs)(`li`,{className:`preset-share-item`,children:[(0,X.jsxs)(`div`,{className:`preset-share-item-head`,children:[(0,X.jsx)(`strong`,{children:e.name}),e.author&&(0,X.jsx)(`span`,{className:`preset-share-item-author`,children:e.author}),e.updatedAt&&(0,X.jsx)(`span`,{className:`preset-share-item-date`,children:Xb(e.updatedAt)})]}),e.description&&(0,X.jsx)(`p`,{className:`preset-share-item-desc`,children:e.description}),(0,X.jsxs)(`div`,{className:`preset-share-item-tags`,children:[e.tags.map(e=>(0,X.jsx)(`span`,{className:`preset-share-tag`,children:e},e)),e.summary?.hasTemplate&&(0,X.jsx)(`span`,{className:`preset-share-tag`,children:c(`presetBadgeTemplate`)}),e.summary?.hasReviewPrompt&&(0,X.jsx)(`span`,{className:`preset-share-tag`,children:c(`presetBadgeReview`)})]}),(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{u(`import`),D(e.url),ce(e.url)},children:c(`presetBrowseImport`)}),e.issueUrl&&(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:c(`presetBrowseIssue`),onClick:()=>window.open(e.issueUrl,`_blank`,`noopener,noreferrer`),children:[(0,X.jsx)(Ge,{}),` `,c(`presetBrowseIssue`)]})]})]},e.id))})]})]})]})}function $b(e,t){return e.error?`failed`:t?`disabled`:e.active===!0?`active`:`idle`}function ex(e,t){let n={active:0,disabled:0,failed:0,idle:0};for(let r of e)n[$b(r,t.has(r.id))]+=1;return n}var tx={zh:[`继续`,`总结一下`,`详细解释一下`,`检查并修复问题`,`补充测试覆盖`,`发布上传`],en:[`Continue`,`Summarize`,`Explain in detail`,`Check and fix issues`,`Add test coverage`,`Publish release`],it:[`Continua`,`Riassumi`,`Spiega in dettaglio`,`Verifica e correggi i problemi`,`Aggiungi copertura dei test`,`Pubblica la release`],ja:[`続ける`,`要約して`,`詳しく説明して`,`問題を確認して修正`,`テストカバレッジを追加`,`公開・リリース`],ko:[`계속`,`요약해줘`,`자세히 설명해줘`,`문제를 확인하고 수정`,`테스트 커버리지 추가`,`게시/릴리스`],fr:[`Continuer`,`Résumer`,`Expliquer en détail`,`Vérifier et corriger les problèmes`,`Ajouter des tests`,`Publier`],de:[`Weiter`,`Zusammenfassen`,`Ausführlich erklären`,`Probleme prüfen und beheben`,`Testabdeckung ergänzen`,`Veröffentlichen`],es:[`Continuar`,`Resumir`,`Explicar en detalle`,`Revisar y corregir problemas`,`Añadir cobertura de pruebas`,`Publicar`],ru:[`Продолжить`,`Подведи итог`,`Объясни подробно`,`Проверь и исправь проблемы`,`Добавь покрытие тестами`,`Опубликовать`],pt:[`Continuar`,`Resumir`,`Explique em detalhes`,`Verifique e corrija os problemas`,`Adicione cobertura de testes`,`Publique a release`]},nx=[`soul`,`tools`,`guidelines`,`pi_docs`,`append`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`],rx=[`tools`,`pi_docs`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`];function ix(e){return rx.includes(e)}var ax=nx.map(e=>`{{${e}}}`).join(`
671
+ `)}}if(e===`subagentDefaultModel`||e===`visionBridgeModel`){let e=typeof t==`string`?t.trim():``;return{summary:e?r?`指定模型:${e}`:`Model: ${e}`:r?`跟随主对话模型`:`Follows main chat model`}}return{summary:String(t)}}function cx(e){return`${e===`paste`?`paste`:e}:${jt()}`}function lx(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleDateString()}function ux(e){switch(e){case`prompt`:return`presetGroupPrompt`;case`tools`:return`presetGroupTools`;case`terminal`:return`presetGroupTerminal`;case`skills`:return`presetGroupSkills`;case`ai`:return`presetGroupAi`;case`ui`:return`presetGroupUi`;case`engine`:return`presetGroupEngine`}return`presetGroupOther`}function dx({presets:e,presetExport:t,presetImport:n,presetCatalog:r,presetShare:i,initialPreset:a=``,initialTab:o=`export`,onClose:s}){let c=Z(),[l,u]=(0,g.useState)(o),[d,f]=(0,g.useState)(a),[p,m]=(0,g.useState)(``),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(!1),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(``),[O,k]=(0,g.useState)(null),[A,j]=(0,g.useState)(!1),[ee,M]=(0,g.useState)(null),[te,N]=(0,g.useState)(new Set),ne=(0,g.useRef)(null),[F,re]=(0,g.useState)(``),[ae,I]=(0,g.useState)(!1);(0,g.useEffect)(()=>{$({type:`preset_catalog`,requestId:`catalog:${jt()}`})},[]);let L=(0,g.useRef)(0);(0,g.useEffect)(()=>{r&&r.receivedAt!==L.current&&(L.current=r.receivedAt,I(!1))},[r]);let R=(0,g.useRef)(0);(0,g.useEffect)(()=>{if(i&&i.receivedAt!==R.current){if(R.current=i.receivedAt,C(!1),i.method===`browser`){i.json&&navigator.clipboard?.writeText(i.json).catch(()=>{}),i.url&&window.open(i.url,`_blank`,`noopener,noreferrer`);return}i.ok&&i.url&&window.open(i.url,`_blank`,`noopener,noreferrer`)}},[i]);let z=(0,g.useRef)(0);(0,g.useEffect)(()=>{n&&n.receivedAt!==z.current&&(z.current=n.receivedAt,n.dryRun&&n.preview&&M(new Set(n.preview.fields)),n.ok&&!n.dryRun&&(T(``),D(``),k(null),M(null)))},[n]);let oe=(0,g.useMemo)(()=>{let e=h.split(/[,,]/).map(e=>e.trim()).filter(Boolean);return{source:d?`preset`:`current`,name:d,...p.trim()?{description:p.trim()}:{},...v.trim()?{author:v.trim()}:{},...e.length>0?{tags:e}:{}}},[d,p,h,v]),B=()=>$({type:`preset_export`,...oe,requestId:`export:${jt()}`}),V=()=>{C(!0),$({type:`preset_share`,...oe,requestId:`share:${jt()}`})},H=()=>{t?.json&&Su(new Blob([t.json],{type:`application/json`}),t.fileName||`${t.name||`preset`}.json`)},se=()=>{t?.json&&navigator.clipboard?.writeText(t.json).then(()=>{x(!0),window.setTimeout(()=>x(!1),1500)}).catch(()=>{})},ce=(e,t)=>{e.trim()&&(k({source:t,json:e}),$({type:`preset_import`,json:e,dryRun:!0,requestId:cx(t)}))},ue=(e,t=`url`)=>{e.trim()&&(k({source:t,url:e}),$({type:`preset_import_url`,url:e,dryRun:!0,requestId:cx(t)}))},U=()=>{if(!O||_e.size===0)return;let e={dryRun:!1,name:n?.preview?.name,apply:A,fields:[..._e],requestId:cx(O.source)};O.url?$({type:`preset_import_url`,url:O.url,...e}):O.json&&$({type:`preset_import`,json:O.json,...e})},de=e=>{if(!e)return;let t=new FileReader;t.onload=()=>ce(String(t.result??``),`file`),t.readAsText(e)},fe=()=>{I(!0),$({type:`preset_catalog`,refresh:!0,requestId:`catalog:${jt()}`})},W=r?.entries??[],pe=(0,g.useMemo)(()=>{let e=F.trim().toLowerCase();return e?W.filter(t=>[t.name,t.description,t.author,t.tags.join(` `)].some(t=>t.toLowerCase().includes(e))):W},[W,F]),G=n?.dryRun?n.preview:void 0,me=n?.ok&&!n.dryRun?n.preview:void 0,he=c(`ok`)===`确定`,ge=he?`zh`:`en`,q=G?.fields??[],_e=ee??new Set(q),ve=rx(q),ye=q.length>0&&q.every(e=>_e.has(e)),be=e=>M(()=>{let t=new Set(_e);return t.has(e)?t.delete(e):t.add(e),t}),xe=e=>N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=(e,t)=>M(()=>{let n=new Set(_e);for(let r of e)t?n.add(r):n.delete(r);return n});return(0,X.jsxs)(Ky,{className:`preset-share-modal`,onClose:s,showCloseButton:!1,children:[(0,X.jsxs)(`div`,{className:`preset-share-head`,children:[(0,X.jsxs)(`span`,{className:`preset-share-title`,children:[(0,X.jsx)(le,{}),` `,c(`presetShare`)]}),(0,X.jsx)(`div`,{className:`preset-share-tabs`,children:[[`export`,`presetShareTabExport`],[`import`,`presetShareTabImport`],[`browse`,`presetShareTabBrowse`]].map(([e,t])=>(0,X.jsxs)(`button`,{type:`button`,className:`preset-share-tab${l===e?` active`:``}`,onClick:()=>u(e),children:[c(t),e===`browse`&&W.length>0&&(0,X.jsx)(`em`,{className:`preset-share-badge`,children:W.length})]},e))}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:c(`close`),onClick:s,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`preset-share-body`,children:[l===`export`&&(0,X.jsxs)(`div`,{className:`preset-share-pane`,children:[(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetShareSource`)}),(0,X.jsxs)(`select`,{className:`set-input`,value:d,onChange:e=>f(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:c(`presetShareSourceCurrent`)}),e.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]})]}),(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetShareDescription`)}),(0,X.jsx)(`input`,{className:`set-input`,value:p,placeholder:c(`presetShareDescriptionPlaceholder`),onChange:e=>m(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetShareTags`)}),(0,X.jsx)(`input`,{className:`set-input`,value:h,placeholder:c(`presetShareTagsPlaceholder`),onChange:e=>_(e.target.value)})]}),(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetShareAuthor`)}),(0,X.jsx)(`input`,{className:`set-input`,value:v,onChange:e=>y(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:B,children:[(0,X.jsx)(qe,{}),` `,c(`presetExportJson`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:V,disabled:S,children:[S?(0,X.jsx)(K,{className:`preset-share-spin`}):(0,X.jsx)(le,{}),c(S?`presetShareSubmitting`:`presetShareSubmit`)]})]}),(0,X.jsx)(`p`,{className:`preset-share-hint`,children:c(`presetShareHint`)}),i&&i.method===`browser`&&(0,X.jsxs)(`div`,{className:`preset-share-result-box`,children:[(0,X.jsxs)(`div`,{className:`preset-share-result-head`,children:[(0,X.jsx)(Ge,{}),` `,(0,X.jsx)(`strong`,{children:c(`presetShareOpenWebTitle`)})]}),i.error&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:i.error}),(0,X.jsxs)(`p`,{className:`preset-share-hint`,children:[c(`presetShareBrowserCopied`),i.url&&` ${c(`presetSharePopupBlocked`)}`]}),(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[i.url&&(0,X.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noopener noreferrer`,className:`btn primary`,children:[(0,X.jsx)(Ge,{}),` `,c(`presetShareOpenWebBtn`)]}),i.json&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{i.json&&navigator.clipboard?.writeText(i.json).then(()=>{x(!0),window.setTimeout(()=>x(!1),1500)})},children:c(b?`copied`:`presetShareCopyJson`)})]})]}),i?.ok&&(i.method===`gh`||i.method===`api`)&&i.url&&(0,X.jsxs)(`div`,{className:`preset-share-result-box preset-share-result-success`,children:[(0,X.jsx)(`p`,{className:`preset-share-ok`,children:c(`presetImportImported`,{name:i.name||``})}),(0,X.jsx)(`div`,{className:`preset-share-actions`,children:(0,X.jsxs)(`a`,{href:i.url,target:`_blank`,rel:`noopener noreferrer`,className:`btn`,children:[(0,X.jsx)(Ge,{}),` `,c(`presetShareOpenIssueBtn`)]})})]}),i?.ok===!1&&!i.method&&i.error&&(0,X.jsx)(`p`,{className:`preset-share-error`,children:i.error}),t?.ok===!1&&t.error&&(0,X.jsx)(`p`,{className:`preset-share-error`,children:t.error}),t?.ok&&t.json&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:se,children:c(b?`copied`:`copy`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:H,children:[(0,X.jsx)(qe,{}),` `,c(`presetExportDownload`)]})]}),(0,X.jsx)(`textarea`,{className:`preset-share-json`,readOnly:!0,value:t.json,spellCheck:!1})]})]}),l===`import`&&(0,X.jsxs)(`div`,{className:`preset-share-pane`,children:[(0,X.jsxs)(`label`,{className:`preset-share-field`,children:[(0,X.jsx)(`span`,{children:c(`presetImportText`)}),(0,X.jsx)(`textarea`,{className:`preset-share-input`,value:w,placeholder:c(`presetImportTextPlaceholder`),spellCheck:!1,onChange:e=>T(e.target.value),onBlur:()=>ce(w,`paste`)})]}),(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>ce(w,`paste`),disabled:!w.trim(),children:[(0,X.jsx)(ie,{}),` `,c(`preview`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>ne.current?.click(),children:[(0,X.jsx)(He,{}),` `,c(`presetImportPickFile`)]}),(0,X.jsx)(`input`,{ref:ne,type:`file`,accept:`.json,application/json`,style:{display:`none`},onChange:e=>{de(e.target.files?.[0]),e.target.value=``}})]}),(0,X.jsxs)(`div`,{className:`preset-share-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input`,value:E,placeholder:c(`presetImportUrlPlaceholder`),onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ue(E)}}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>ue(E),disabled:!E.trim(),children:[(0,X.jsx)(Fe,{}),` `,c(`presetImportFromUrl`)]})]}),n?.ok===!1&&n.error&&(0,X.jsx)(`p`,{className:`preset-share-error`,children:n.error}),G&&(0,X.jsxs)(`div`,{className:`preset-share-preview`,children:[(0,X.jsxs)(`div`,{className:`preset-share-preview-head`,children:[(0,X.jsx)(`strong`,{children:c(`presetImportPreview`)}),(0,X.jsx)(`span`,{className:`preset-share-preview-name`,children:G.name})]}),G.description&&(0,X.jsx)(`p`,{className:`preset-share-preview-desc`,children:G.description}),(0,X.jsxs)(`ul`,{className:`preset-share-meta`,children:[(0,X.jsx)(`li`,{children:c(`presetImportFields`,{n:G.fields.length})}),G.author&&(0,X.jsx)(`li`,{children:G.author}),G.tags.length>0&&(0,X.jsx)(`li`,{children:G.tags.join(` · `)}),G.summary.skills>0&&(0,X.jsx)(`li`,{children:`${c(`settingsSkills`)} ${G.summary.skills}`}),G.summary.agentTools>0&&(0,X.jsx)(`li`,{children:`${c(`settingsTools`)} ${G.summary.agentTools}`})]}),G.ignored.length>0&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:c(`presetImportIgnored`,{list:G.ignored.join(`, `)})}),G.rejected.length>0&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:c(`presetImportRejected`,{list:G.rejected.join(`, `)})}),G.customSystemPrompt&&(0,X.jsx)(`pre`,{className:`preset-share-snippet`,children:G.customSystemPrompt}),G.reviewPrompt&&(0,X.jsx)(`pre`,{className:`preset-share-snippet`,children:G.reviewPrompt}),G.replaces&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:c(`presetImportReplaces`)}),q.length>0&&(0,X.jsxs)(`div`,{className:`preset-share-pick`,children:[(0,X.jsxs)(`div`,{className:`preset-share-pick-head`,children:[(0,X.jsx)(`strong`,{children:c(`presetImportPick`)}),(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>M(new Set(q)),children:c(`presetImportSelectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>M(new Set),children:c(`presetImportSelectNone`)})]}),(0,X.jsx)(`p`,{className:`set-note`,children:c(`presetImportPickHint`)}),ye&&(0,X.jsx)(`span`,{className:`preset-share-pick-all`,children:c(`presetImportAllSelected`)}),ve.map(({group:e,fields:t})=>(0,X.jsxs)(`div`,{className:`preset-share-pick-group`,children:[(0,X.jsxs)(`label`,{className:`preset-share-check preset-share-pick-grouptitle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:t.every(e=>_e.has(e)),onChange:e=>J(t,e.target.checked)}),c(ux(e)),(0,X.jsxs)(`span`,{className:`set-count`,children:[t.filter(e=>_e.has(e)).length,`/`,t.length]})]}),(0,X.jsx)(`div`,{className:`preset-share-pick-fields`,children:t.map(e=>{let t=G.settings?.[e],{summary:n,detail:r}=sx(e,t,ge),i=ax(e,ge),a=ox(e,ge),o=te.has(e);return(0,X.jsxs)(`div`,{className:`preset-share-pick-item`,children:[(0,X.jsxs)(`div`,{className:`preset-share-pick-item-head`,children:[(0,X.jsxs)(`label`,{className:`preset-share-check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:_e.has(e),onChange:()=>be(e)}),(0,X.jsx)(`span`,{className:`preset-share-pick-label`,children:i})]}),(0,X.jsx)(`code`,{className:`preset-share-pick-code`,children:e}),n&&(0,X.jsx)(`span`,{className:`preset-share-pick-summary`,children:n}),r&&(0,X.jsx)(`button`,{type:`button`,className:`preset-share-pick-toggle`,onClick:()=>xe(e),children:o?he?`收起 ▲`:`Collapse ▲`:he?`查看详情 ▼`:`Details ▼`})]}),a&&(0,X.jsx)(`p`,{className:`preset-share-pick-hint`,children:a}),r&&o&&(0,X.jsx)(`pre`,{className:`preset-share-pick-detail`,children:r})]},e)})})]},e)),_e.size===0&&(0,X.jsx)(`p`,{className:`preset-share-warn`,children:c(`presetImportNoneSelected`)})]}),(0,X.jsxs)(`label`,{className:`preset-share-check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked)}),c(`presetImportApply`)]}),(0,X.jsx)(`div`,{className:`preset-share-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:_e.size===0,onClick:U,children:c(`presetImportConfirm`)})})]}),me&&(0,X.jsx)(`p`,{className:`preset-share-ok`,children:c(`presetImportImported`,{name:me.name})})]}),l===`browse`&&(0,X.jsxs)(`div`,{className:`preset-share-pane`,children:[(0,X.jsxs)(`div`,{className:`preset-share-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input`,value:F,placeholder:c(`presetBrowseSearch`),onChange:e=>re(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:fe,disabled:ae,children:[(0,X.jsx)(K,{className:ae?`preset-share-spin`:void 0}),` `,c(`presetBrowseRefresh`)]})]}),r?.error&&(0,X.jsx)(`p`,{className:`preset-share-error`,children:r.error}),r?.cached&&r.fetchedAt>0&&(0,X.jsx)(`p`,{className:`preset-share-hint`,children:c(`presetBrowseCached`,{time:lx(new Date(r.fetchedAt).toISOString())})}),pe.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:c(!r||ae?`presetBrowseLoading`:`presetBrowseEmpty`)}):(0,X.jsx)(`ul`,{className:`preset-share-list`,children:pe.map(e=>(0,X.jsxs)(`li`,{className:`preset-share-item`,children:[(0,X.jsxs)(`div`,{className:`preset-share-item-head`,children:[(0,X.jsx)(`strong`,{children:e.name}),e.author&&(0,X.jsx)(`span`,{className:`preset-share-item-author`,children:e.author}),e.updatedAt&&(0,X.jsx)(`span`,{className:`preset-share-item-date`,children:lx(e.updatedAt)})]}),e.description&&(0,X.jsx)(`p`,{className:`preset-share-item-desc`,children:e.description}),(0,X.jsxs)(`div`,{className:`preset-share-item-tags`,children:[e.tags.map(e=>(0,X.jsx)(`span`,{className:`preset-share-tag`,children:e},e)),e.summary?.hasTemplate&&(0,X.jsx)(`span`,{className:`preset-share-tag`,children:c(`presetBadgeTemplate`)}),e.summary?.hasReviewPrompt&&(0,X.jsx)(`span`,{className:`preset-share-tag`,children:c(`presetBadgeReview`)})]}),(0,X.jsxs)(`div`,{className:`preset-share-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{u(`import`),D(e.url),ue(e.url)},children:c(`presetBrowseImport`)}),e.issueUrl&&(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:c(`presetBrowseIssue`),onClick:()=>window.open(e.issueUrl,`_blank`,`noopener,noreferrer`),children:[(0,X.jsx)(Ge,{}),` `,c(`presetBrowseIssue`)]})]})]},e.id))})]})]})]})}function fx(e,t){return e.error?`failed`:t?`disabled`:e.active===!0?`active`:`idle`}function px(e,t){let n={active:0,disabled:0,failed:0,idle:0};for(let r of e)n[fx(r,t.has(r.id))]+=1;return n}var mx={zh:[`继续`,`总结一下`,`详细解释一下`,`检查并修复问题`,`补充测试覆盖`,`发布上传`],en:[`Continue`,`Summarize`,`Explain in detail`,`Check and fix issues`,`Add test coverage`,`Publish release`],it:[`Continua`,`Riassumi`,`Spiega in dettaglio`,`Verifica e correggi i problemi`,`Aggiungi copertura dei test`,`Pubblica la release`],ja:[`続ける`,`要約して`,`詳しく説明して`,`問題を確認して修正`,`テストカバレッジを追加`,`公開・リリース`],ko:[`계속`,`요약해줘`,`자세히 설명해줘`,`문제를 확인하고 수정`,`테스트 커버리지 추가`,`게시/릴리스`],fr:[`Continuer`,`Résumer`,`Expliquer en détail`,`Vérifier et corriger les problèmes`,`Ajouter des tests`,`Publier`],de:[`Weiter`,`Zusammenfassen`,`Ausführlich erklären`,`Probleme prüfen und beheben`,`Testabdeckung ergänzen`,`Veröffentlichen`],es:[`Continuar`,`Resumir`,`Explicar en detalle`,`Revisar y corregir problemas`,`Añadir cobertura de pruebas`,`Publicar`],ru:[`Продолжить`,`Подведи итог`,`Объясни подробно`,`Проверь и исправь проблемы`,`Добавь покрытие тестами`,`Опубликовать`],pt:[`Continuar`,`Resumir`,`Explique em detalhes`,`Verifique e corrija os problemas`,`Adicione cobertura de testes`,`Publique a release`]},hx=[`soul`,`tools`,`guidelines`,`pi_docs`,`append`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`],gx=[`tools`,`pi_docs`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`];function _x(e){return gx.includes(e)}var vx=hx.map(e=>`{{${e}}}`).join(`
672
672
 
673
- `),ox=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]/gu;function sx(e){if(!e)return 0;let t=e.match(ox)?.length??0;return Math.ceil(t+(e.length-t)/4)}var cx=Mr.filter(e=>e.group===`other`&&e.name!==`todo_list`),lx=`pi-web-ui:catalog-sync-urls`,ux=8;function dx(){try{let e=localStorage.getItem(lx);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim()!==``).slice(0,ux):[]}catch{return[]}}function fx(e){let t=e.trim();if(!t)return dx();let n=[t,...dx().filter(e=>e!==t)].slice(0,ux);try{localStorage.setItem(lx,JSON.stringify(n))}catch{}return n}function px(e){return e===`append`?0:ix(e)?2:1}function mx({title:e,subtitle:t,tip:n,enabled:r,onToggle:i,action:a,disabled:o}){let s=Z();return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[e,n&&(0,X.jsx)(mu,{text:n})]}),t&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t})]}),a,(0,X.jsx)(`button`,{type:`button`,className:`set-switch ${r?`on`:``}`,role:`switch`,"aria-checked":r,disabled:o,title:s(r?`settingsEnabled`:`settingsDisabled`),onClick:o?void 0:i,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})}function hx({name:e,edited:t,onEdit:n}){let r=Z();return(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn tool-prompt-edit${t?` edited`:``}`,title:r(t?`toolPromptEdited`:`toolPromptEdit`),"aria-label":r(`toolPromptEdit`),onClick:()=>n(e),children:(0,X.jsx)(Y,{})})}function gx(e){return e===`active`?`pluginPhaseActive`:e===`disabled`?`pluginPhaseDisabled`:e===`failed`?`pluginPhaseFailed`:`pluginPhaseIdle`}function _x({phase:e,label:t}){return(0,X.jsx)(`span`,{className:`inv-dot inv-dot-${e}`,title:t,"aria-label":t})}function vx(e){if(e?.homepage&&/^https?:\/\//i.test(e.homepage))return e.homepage;let t=e?.source?.trim();if(!t)return null;if(/^https?:\/\//i.test(t))return t;if(t.startsWith(`git@github.com:`))return`https://github.com/${t.slice(15).replace(/\.git$/,``)}`;let n=t.split(`/`);return n.length===2&&!n[0].includes(`:`)&&!n[1].includes(`:`)?`https://github.com/${n[0]}/${n[1]}`:n.length>2&&!t.includes(`:`)?`https://github.com/${n[0]}/${n[1]}/tree/main/${n.slice(2).join(`/`)}`:null}function yx({plugins:e,disabledIds:t}){let n=Z(),r=ex(e,t),i={active:n(`pluginPhaseActive`),disabled:n(`pluginPhaseDisabled`),failed:n(`pluginPhaseFailed`),idle:n(`pluginPhaseIdle`)};return(0,X.jsx)(`div`,{className:`set-note inv-strip`,children:[`active`,`disabled`,`failed`,`idle`].map(e=>(0,X.jsxs)(`span`,{className:`inv-item`,title:i[e],children:[(0,X.jsx)(_x,{phase:e,label:i[e]}),r[e]]},e))})}function bx({label:e,tip:t,htmlFor:n,children:r}){return(0,X.jsxs)(`div`,{className:`set-row set-field-row`,children:[(0,X.jsxs)(`label`,{className:`set-row-name`,htmlFor:n,children:[e,t&&(0,X.jsx)(mu,{text:t})]}),r]})}function xx({mode:e,onModeChange:t,draft:n,onDraftChange:r,defaultPrompt:i,placeholder:a,rows:o=4,onCommit:s,modeLabel:c,hint:l,focusRef:u}){let d=Z(),f=(e,t)=>{s(e,e===`replace`&&i&&t===i?``:t)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(bx,{label:c??d(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:e,onChange:e=>{let r=e.target.value;t(r),f(r,n)},children:[(0,X.jsx)(`option`,{value:`append`,children:d(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:d(`promptModeReplace`)})]})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:o,placeholder:a,value:n,onFocus:()=>{u&&(u.current=!0)},onBlur:()=>{u&&(u.current=!1),f(e,n)},onChange:e=>r(e.target.value)}),l&&(0,X.jsx)(`p`,{className:`set-hint`,children:l})]})}function Sx({pluginId:e}){let t=Z(),[n,r]=(0,g.useState)(`all`),i=el(e),a=n===`all`?i:i.filter(e=>e.level===n);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-log-filter`,children:[(0,X.jsx)(`span`,{className:`set-log-filter-label`,children:t(`pluginLogLevel`)}),[`all`,...Kc].map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-log-filter-btn${n===e?` on`:``}`,onClick:()=>r(e),children:e===`all`?t(`pluginLogAll`):e.toUpperCase()},e)),(0,X.jsxs)(`button`,{type:`button`,className:`set-log-clear`,title:t(`pluginLogClear`),onClick:()=>$(Jc(e)),children:[(0,X.jsx)(R,{}),t(`pluginLogClear`)]})]}),a.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:t(`pluginLogEmpty`)}):(0,X.jsx)(`ul`,{className:`set-diag-list set-log-list`,children:a.map((t,n)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`set-log-time`,children:new Date(t.ts).toLocaleTimeString()}),` `,(0,X.jsx)(`span`,{className:`set-log-level lv-${t.level}`,children:t.level.toUpperCase()}),` `,(0,X.jsx)(`span`,{className:`set-log-text`,children:t.text})]},`${e}-${t.ts}-${n}`))})]})}function Cx(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}var wx=1e4;function Tx({chat:e,terminal:t,initialSection:n,onSwitchToTerminal:r,onClose:i,onOpenIconEdit:a,sound:o,onSoundChange:s,tts:c,onTtsChange:l}){let u=Z(),{locale:d}=Nn(),f=e=>u(e),p=e.settings,[m,h]=(0,g.useState)({}),_=(0,g.useMemo)(()=>{if(!p)return null;if(Object.keys(m).length===0)return p;let e={...p};for(let[t,{value:n}]of Object.entries(m))e[t]=n;return e},[p,m]);(0,g.useEffect)(()=>{p&&h(e=>{if(Object.keys(e).length===0)return e;let t={},n=Date.now();for(let[r,{value:i,at:a}]of Object.entries(e))!Cx(p[r],i)&&n-a<wx&&(t[r]={value:i,at:a});return Object.keys(t).length===Object.keys(e).length?e:t})},[p]);let v=_?.approvalPolicy,{engine:y,managed:b}=Ia(),x=y===`dsh`,[S,C]=(0,g.useState)(n??`prompt`),[w,T]=(0,g.useState)(`market`),E=(0,g.useRef)(null);(0,g.useEffect)(()=>{E.current?.scrollTo({top:0})},[S]);let D=(0,g.useRef)(null);(0,g.useEffect)(()=>{D.current?.querySelector(`.settings-tab.active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[S]);let[O,k]=(0,g.useState)(`installed`),[A,j]=(0,g.useState)(`all`),[ee,M]=(0,g.useState)(``),[te,I]=(0,g.useState)(`anthropics/skills`),[L,ie]=(0,g.useState)(``),[B,V]=(0,g.useState)(!1),[H,U]=(0,g.useState)(null),[fe,pe]=(0,g.useState)({}),[G,he]=(0,g.useState)(null),ge=(0,g.useMemo)(()=>new Set((_?.skills??[]).map(e=>e.name.toLowerCase())),[_?.skills]),_e=te===`custom`?L.trim():te,ve=(e=!1)=>{_e&&(V(!0),$({type:`fetch_skill_market`,repo:_e,refresh:e}))};(0,g.useEffect)(()=>{if(S!==`skills`||O!==`market`||!_e)return;V(!0);let e=setTimeout(()=>{$({type:`fetch_skill_market`,repo:_e})},350);return()=>clearTimeout(e)},[S,O,te,L]),(0,g.useEffect)(()=>{e.skillMarketResult&&V(!1)},[e.skillMarketResult]),(0,g.useEffect)(()=>{if(e.skillContentResult?.ok&&e.skillContentResult.skillId){let t=e.skillContentResult.skillId,n=e.skillContentResult.content;pe(e=>({...e,[t]:n})),he(null),H&&H.id===t&&U(e=>e?{...e,content:n}:null)}},[e.skillContentResult]);let ye=(0,g.useMemo)(()=>e.skillMarketResult?.ok&&e.skillMarketResult.skills?.length>0?e.skillMarketResult.skills.map(e=>({id:e.id,name:e.name,nameZh:e.name,description:e.description,descriptionZh:e.description,category:`workflow`,content:fe[e.id]||``})):Ry,[e.skillMarketResult,fe]),be=(0,g.useMemo)(()=>ye.filter(e=>{if(A!==`all`&&e.category!==A)return!1;if(ee.trim()){let t=ee.trim().toLowerCase(),n=e.name.toLowerCase().includes(t)||e.nameZh.toLowerCase().includes(t),r=e.description.toLowerCase().includes(t)||e.descriptionZh.toLowerCase().includes(t);return n||r}return!0}),[ye,A,ee]),xe=(e,t)=>{let n=fe[e.id]||e.content;n?($({type:`install_skill`,name:e.id,scope:t,content:n}),U(null)):(he(e.id),$({type:`fetch_skill_content`,repo:_e,skillId:e.id}))},Se=(e,t)=>{$({type:`uninstall_skill`,name:e,scope:t})},Ce=e=>{switch(e){case`quality`:return u(`skillCatQuality`);case`workflow`:return u(`skillCatWorkflow`);case`architecture`:return u(`skillCatArchitecture`);case`devops`:return u(`skillCatDevops`);case`stack`:return u(`skillCatStack`);default:return u(`skillCatAll`)}};(0,g.useEffect)(()=>{S===`plugins`&&x&&$({type:`dsh_patches_list`})},[S,x]),(0,g.useEffect)(()=>{$({type:`get_settings`})},[e.state?.cwd,e.activeConversationId]);let[we,Te]=(0,g.useState)(``),Ee=(0,g.useRef)(we);Ee.current=we;let De=(0,g.useRef)(null),[Oe,ke]=(0,g.useState)({}),je=(0,g.useRef)(Oe);je.current=Oe;let Me=(0,g.useRef)(!1),Pe=(0,g.useRef)(null),Ie=[...nx].sort((e,t)=>px(e)-px(t)),[ze,Be]=(0,g.useState)(null),[He,We]=(0,g.useState)({}),[Je,Ye]=(0,g.useState)(``),[Xe,Qe]=(0,g.useState)(`append`),$e=(0,g.useRef)(!1),[et,tt]=(0,g.useState)(``),[nt,it]=(0,g.useState)(`append`),at=(0,g.useRef)(!1),[ot,st]=(0,g.useState)(``),[lt,ut]=(0,g.useState)(`append`),pt=(0,g.useRef)(!1),[mt,gt]=(0,g.useState)(``),_t=(0,g.useRef)(!1),[vt,yt]=(0,g.useState)(``),[bt,xt]=(0,g.useState)(null),[Ct,Tt]=(0,g.useState)(null),[Et,Dt]=(0,g.useState)(!1),[Ot,kt]=(0,g.useState)(null),[At,Mt]=(0,g.useState)(null),[Nt,Pt]=(0,g.useState)(!1),[Ft,It]=(0,g.useState)(``),[Lt,Rt]=(0,g.useState)(null),[Bt,Vt]=(0,g.useState)(null),[Ht,Ut]=(0,g.useState)(null),[Wt,Gt]=(0,g.useState)(!1),[Kt,qt]=(0,g.useState)(!1),[Jt,Yt]=(0,g.useState)(null),Xt=_?.toolPromptOverrides??{},Zt=(0,g.useMemo)(()=>new Set(Object.keys(Xt)),[Xt]),Qt=e=>x?null:(0,X.jsx)(hx,{name:e,edited:Zt.has(e),onEdit:Yt}),$t=(e,t)=>Q({toolPromptOverrides:{[e]:t??{}}}),en=(0,g.useMemo)(()=>sx(_?.effectiveSystemPrompt??``),[_?.effectiveSystemPrompt]),tn=(0,g.useMemo)(()=>sx(_?.toolsSchema??``),[_?.toolsSchema]),nn=en+tn,rn=db(),an=Op(),sn=Sb(),cn=Bb(),[ln,un]=(0,g.useState)(cn.url),dn=(0,g.useRef)(!1),fn=(0,g.useRef)(null),[pn,mn]=(0,g.useState)(!1),[hn,gn]=(0,g.useState)(!1);(0,g.useEffect)(()=>{dn.current||un(cn.url.startsWith(`data:`)?``:cn.url)},[cn.url]);let _n=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){mn(!0),gn(!1);try{let e=await Nb(t),n=e?Ob(e):``;if(!n){gn(!0);return}un(``),Fb({...cn,url:n})}finally{mn(!1)}}},[vn,yn]=(0,g.useState)(()=>a_()),[bn,xn]=(0,g.useState)(()=>{try{return l_().length}catch{return 0}}),[Sn,Cn]=(0,g.useState)(!1),wn=()=>{try{xn(l_().length)}catch{xn(0)}};(0,g.useEffect)(()=>{S===`prompt-history`&&wn()},[S]),(0,g.useEffect)(()=>{if(!Sn)return;let e=window.setTimeout(()=>Cn(!1),3e3);return()=>window.clearTimeout(e)},[Sn]);let[Tn,En]=(0,g.useState)(null),[Dn,On]=(0,g.useState)(null),[kn,An]=(0,g.useState)(null),[jn,Mn]=(0,g.useState)(null),[Pn,In]=(0,g.useState)({}),[,Rn]=(0,g.useState)(0);(0,g.useEffect)(()=>$c(()=>Rn(e=>e+1)),[]);let[zn,Bn]=(0,g.useState)(``),[Vn,Hn]=(0,g.useState)(``),[Un,Wn]=(0,g.useState)(``),[Gn,Kn]=(0,g.useState)(``),[qn,Jn]=(0,g.useState)(``),[Yn,Xn]=(0,g.useState)(!1),[Zn,Qn]=(0,g.useState)(!1),[$n,er]=(0,g.useState)(!1),[tr,nr]=(0,g.useState)(``),[rr,ir]=(0,g.useState)(!1),[ar,or]=(0,g.useState)(!1),[sr,cr]=(0,g.useState)(null),[lr,ur]=(0,g.useState)(``),[dr,mr]=(0,g.useState)(()=>dx()),[hr,gr]=(0,g.useState)(``),[_r,vr]=(0,g.useState)(null);(0,g.useEffect)(()=>{_&&(Me.current||(Te(_.promptTemplate??``),Ee.current=_.promptTemplate??``),ke(e=>{let t={};for(let[e,n]of Object.entries(_.promptOverrides??{}))t[e]=n??``;return Pe.current&&(t[Pe.current]=e[Pe.current]??``),je.current=t,t}),Qe(_.visionBridgePromptMode),!$e.current&&(Ye(Xe===`append`||_.visionBridgePrompt?_.visionBridgePrompt:_.visionBridgeDefaultPrompt||``),it(_.scmCommitMsgPromptMode),at.current||tt(_.scmCommitMsgPromptMode===`append`||_.scmCommitMsgPrompt?_.scmCommitMsgPrompt:_.scmCommitMsgDefaultPrompt||``),ut(_.planModePromptMode),pt.current||st(_.planModePromptMode===`append`||_.planModePrompt?_.planModePrompt:_.planModeDefaultPrompt||``),_t.current||gt(_.reviewPrompt)))},[_,Xe,nt,lt]);let[yr,br]=(0,g.useState)(String(_?.terminalBashIdleMs??15e3));(0,g.useEffect)(()=>{br(String(_?.terminalBashIdleMs??15e3))},[_?.terminalBashIdleMs]);let[xr,Sr]=(0,g.useState)(String(_?.terminalBashMaxForegroundMs??6e4));(0,g.useEffect)(()=>{Sr(String(_?.terminalBashMaxForegroundMs??6e4))},[_?.terminalBashMaxForegroundMs]);let[Cr,wr]=(0,g.useState)(String(Math.round((_?.toolWatchdogTimeoutMs??12e5)/6e4)));(0,g.useEffect)(()=>{wr(String(Math.round((_?.toolWatchdogTimeoutMs??12e5)/6e4)))},[_?.toolWatchdogTimeoutMs]);let[Tr,Er]=(0,g.useState)(String(_?.retryMaxAttempts??6));(0,g.useEffect)(()=>{Er(String(_?.retryMaxAttempts??6))},[_?.retryMaxAttempts]);let[Dr,Or]=(0,g.useState)(String(_?.keepRecentMessages??15));(0,g.useEffect)(()=>{Or(String(_?.keepRecentMessages??15))},[_?.keepRecentMessages]);let[kr,Ar]=(0,g.useState)(_?.softCapTokens&&_.softCapTokens>0?tb(_.softCapTokens):``);(0,g.useEffect)(()=>{Ar(_?.softCapTokens&&_.softCapTokens>0?tb(_.softCapTokens):``)},[_?.softCapTokens]);let[jr,Pr]=(0,g.useState)(``),[Fr,Rr]=(0,g.useState)(``),zr=[],Br=$i(Hi(e.plugins),{locale:d,t:e=>u(e),disabledPlugins:e.settings?.disabledPlugins??[],layout:e.settings?.uiLayout,diagnostics:zr}),Vr=[];for(let t of Br[`settings.pages`]){if(t.source===`host`||t.hidden||t.kind===`divider`)continue;let n=e.plugins.find(e=>e.id===t.source.slice(7));n&&Vr.push({entry:t,plugin:n})}let Hr=e=>`plugin-page:${e}`;if((0,g.useEffect)(()=>{S.startsWith(`plugin-page:`)&&(Vr.some(e=>Hr(e.entry.id)===S)||C(`prompt`))},[S,Vr]),!_)return null;let Ur=new Set(_.disabledAgentTools??[]),Wr=Ur.size,Gr=x?null:e.dshPresets?.defaultPreset??null,Kr=!!Gr&&Gr!==`standard`,qr=Kr?new Set(Ir([...Mr.map(e=>e.name),`bash`,`read`,`edit`,`write`],Gr??void 0)):new Set(Mr.map(e=>e.name)),Jr=R_(e.dshPresets?.presets.find(e=>e.id===Gr)??{id:Gr??``,trust:`system`,isDefault:!1},d,u).name,Yr=e=>Kr&&!qr.has(e),Xr=Kr?Mr.filter(e=>!qr.has(e.name)).length:0,Zr=Kr?e.plugins.flatMap(e=>e.agentTools??[]).filter(e=>!(_.disabledPluginTools??[]).includes(e.name)).length:0,Qr=e.dshPresets?z_(e.dshPresets.presets).find(t=>t.id===e.dshPresets.defaultPreset):void 0,$r=Qr?Qr.broken??R_(Qr,d,u).description:void 0,ei=!!e.dshPresets?.presets.some(e=>e.trust===`user`),ti=!!(e.dshPresets&&e.dshPresets.presets.length>0)||!!(e.dshPermission&&e.dshPermission.options.length>0),ni=e.pluginUpdates,ri=Object.values(ni??{}).some(e=>e.updatable&&(e.builtin??!1)),ii=Object.values(ni??{}).some(e=>e.updatable),ai=[{id:`prompt`,icon:(0,X.jsx)(Ve,{}),label:u(`settingsSystemPrompt`)},{id:`prompt-history`,icon:(0,X.jsx)(rt,{}),label:u(`settingsPromptHistory`),count:bn},...x?[]:[{id:`scheduler`,icon:(0,X.jsx)(rt,{}),label:u(`settingsScheduler`),count:e.schedulerTasks.length||void 0}],...x?[{id:`question`,icon:(0,X.jsx)(Ne,{}),label:u(`settingsQuestionnaire`)}]:[{id:`tools`,icon:(0,X.jsx)(z,{}),label:u(`settingsTools`),count:Wr+(_.disabledMarkers?.length??0)||void 0},{id:`approval-rules`,icon:(0,X.jsx)(se,{}),label:u(`settingsApprovalRules`),count:(_.approvalRules??[]).length||void 0}],{id:`display`,icon:(0,X.jsx)(J,{}),label:u(`settingsMessageDisplay`)},{id:`sound`,icon:(0,X.jsx)(ne,{}),label:u(`settingsSoundVoice`)},{id:`quick`,icon:(0,X.jsx)(ue,{}),label:u(`quickPhrases`),count:_.quickPhrases.length},{id:`skills`,icon:(0,X.jsx)(Ze,{}),label:u(`settingsSkills`),count:_.skills.length},{id:`extensions`,icon:(0,X.jsx)(q,{}),label:u(`settingsExtensions`),count:_.extensions.length},{id:`plugins`,icon:(0,X.jsx)(ht,{}),label:u(`settingsUiPlugins`),count:e.plugins.length,dot:ri||ii},{id:`mcp`,icon:(0,X.jsx)(le,{}),label:u(`settingsMcp`),count:(_.mcpServers??[]).length||void 0,dot:(_.mcpServers??[]).some(e=>e.status===`error`)},{id:`layout`,icon:(0,X.jsx)(ae,{}),label:u(`uiLayoutTitle`)},{id:`review`,icon:(0,X.jsx)(N,{}),label:u(`settingsReview`),count:_.reviewSkills.length},...x?[]:[{id:`vision`,icon:(0,X.jsx)(Ue,{}),label:u(`settingsVisionBridge`)}],{id:`presets`,icon:(0,X.jsx)(ae,{}),label:u(`settingsPresets`),count:_.presets.length},...x?[]:[{id:`subagent-templates`,icon:(0,X.jsx)(F,{}),label:u(`settingsSubagentTemplates`),count:_.subagentTemplates.length}],...Vr.map(e=>({id:Hr(e.entry.id),icon:e.entry.iconSvg?(0,X.jsx)(hi,{iconSvg:e.entry.iconSvg}):e.entry.icon&&!/[a-z]/i.test(e.entry.icon)?(0,X.jsx)(`span`,{children:e.entry.icon}):(0,X.jsx)(ht,{}),label:e.entry.label,pluginPage:{plugin:e.plugin,entry:e.entry}}))],oi=S.startsWith(`plugin-page:`)?Vr.find(e=>Hr(e.entry.id)===S)??null:null,si=new Set(_.disabledSkills),ci=new Set(_.disabledExtensions),Q=e=>{let t=Date.now();h(n=>{let r={...n};for(let[n,i]of Object.entries(e))r[n]={value:i,at:t};return r}),$({type:`set_settings`,...e})},li=()=>{if(!_r||!_)return;let e=_r.value.trim(),t=_r.index;if(vr(null),!e||e===_.quickPhrases[t])return;let n=[..._.quickPhrases];n[t]=e,Q({quickPhrases:n})},ui=e=>{let t=new Set(si);t.has(e.name)?t.delete(e.name):t.add(e.name),Q({disabledSkills:[...t]})},di=new Set(_.skillsFullText??[]),fi=e=>{let t=new Set(di);t.has(e)?t.delete(e):t.add(e),Q({skillsFullText:[...t]})},pi=new Set(_.disabledPlugins??[]),mi=new Set(e.plugins.map(e=>e.id)),gi=e=>{let t=new Set(pi);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledPlugins:[...t]})},_i=e=>{let t=new Set(ci);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledExtensions:[...t]})},vi={subagent:u(`toolDescSubagent`),subagent_spawn:u(`toolDescSubagentSpawn`),subagent_get_result:u(`toolDescSubagentGetResult`),subagent_steer:u(`toolDescSubagentSteer`),subagent_list:u(`toolDescSubagentList`),subagent_stop:u(`toolDescSubagentStop`),subagent_wait_all:u(`toolDescSubagentWaitAll`),subagent_templates:u(`toolDescSubagentTemplates`)},yi={bash:u(`toolCoreBashDesc`),read:u(`toolCoreReadDesc`),edit:u(`toolCoreEditDesc`),write:u(`toolCoreWriteDesc`),powershell:u(`toolCorePowershellDesc`),ls:u(`toolCoreLsDesc`),grep:u(`toolCoreGrepDesc`),find:u(`toolCoreFindDesc`)},bi=e=>{let t=new Set(Ur);t.has(e)?t.delete(e):t.add(e),Q({disabledAgentTools:[...t]})},xi=new Set(_.disabledPluginTools??[]),Si=e=>{let t=new Set(xi);t.has(e)?t.delete(e):t.add(e),Q({disabledPluginTools:[...t]})},Ci=e.plugins.map(e=>({plugin:e,tools:[...e.agentTools??[]].sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.tools.length>0),wi=_.markersEnabled??!0,Ti=new Set(_.disabledMarkers??[]),Ei=e=>{let t=new Set(Ti);t.has(e)?t.delete(e):t.add(e),Q({disabledMarkers:[...t]})},Di=(n,a)=>{let o={name:n,command:a,cwd:"${pwd}"},s,c=e.terminals.find(e=>e.title===n);c?(t.restart(c.id),$({type:`run_command`,terminalId:c.id,conversationId:c.conversationId,command:o,cols:80,rows:24}),s=c.id):(s=jt(),t.create({id:s,conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:o})),t.select(s),r(),i()},Oi=e=>{En(null),Di(`${u(`uninstallTitle`)} ${e}`,`pi remove npm:${e}`)},ki=(e,t,n)=>{$({type:`plugin_job`,jobId:jt(),action:e,id:t,...n?{source:n}:{},...e!==`uninstall`&&Zn?{build:!0}:{}})},Ai=t=>{let n=null;for(let r of Object.values(e.pluginJobs??{}))r.pluginId===t&&(!n||r.startedAt>=n.startedAt)&&(n=r);return n},ji=e=>e?e.problem===`already-installed`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:u(`pluginInspectAlreadyInstalled`,{id:e.suggestedId})}):e.problem===`network`?(0,X.jsx)(`div`,{className:`set-catalog-hint`,"data-problem":e.problem,children:u(`pluginInspectNetwork`)}):e.problem===`invalid-spec`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:u(`pluginInspectInvalid`)}):e.problem===`not-found`||e.problem===`not-a-package`||e.problem===`not-a-bundle`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:u(`pluginInspectNotPlugin`)}):e.problem?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,children:e.detail}):e.manifest?(0,X.jsxs)(`div`,{className:`set-catalog-hint ok`,"data-problem":`ok`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`✓ `}),e.manifest.name??e.manifest.id??e.suggestedId,e.manifest.version?` v${e.manifest.version}`:``,e.manifest.description?` · ${e.manifest.description}`:``]}):null:null,Mi=e=>{let t=Ai(e);if(!t)return null;if(t.phase!==`done`){let e=t.lines[t.lines.length-1]??``;return(0,X.jsxs)(`div`,{className:`set-catalog-job running`,title:e,children:[(0,X.jsx)(K,{className:`set-job-spin`}),u(`pluginJobRunning`),(0,X.jsx)(`span`,{className:`set-catalog-job-line`,children:e}),(0,X.jsx)(`button`,{type:`button`,className:`set-job-cancel`,onClick:()=>$({type:`plugin_job_cancel`,jobId:t.jobId}),children:u(`cancel`)})]})}return t.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[`✓ `,u(`pluginJobDone`)]}):(0,X.jsxs)(`div`,{className:`set-catalog-job error`,children:[(0,X.jsxs)(`span`,{children:[`✗ `,t.error||u(`pluginJobFailed`)]}),t.output?(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:t.output}):null]})},Fi=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`},{slot:`topbar.overflow`,labelKey:`uiLayoutTopbarOverflow`},{slot:`notice.actions`,labelKey:`uiLayoutNotice`},{slot:`leftpanel.sections`,labelKey:`uiLayoutLeftSections`},{slot:`leftpanel.projects.actions`,labelKey:`uiLayoutLeftProjectsActions`},{slot:`leftpanel.project`,labelKey:`uiLayoutLeftProject`},{slot:`leftpanel.running.actions`,labelKey:`uiLayoutLeftRunningActions`},{slot:`leftpanel.running`,labelKey:`uiLayoutLeftRunning`},{slot:`leftpanel.history.actions`,labelKey:`uiLayoutLeftHistoryActions`},{slot:`leftpanel.history`,labelKey:`uiLayoutLeftHistory`},{slot:`leftpanel.sessions`,labelKey:`uiLayoutLeftSessions`},{slot:`chat.header`,labelKey:`uiLayoutChatHeader`},{slot:`chat.empty`,labelKey:`uiLayoutChatEmpty`},{slot:`message.actions`,labelKey:`uiLayoutMessage`},{slot:`goalbar.actions`,labelKey:`uiLayoutGoalbar`},{slot:`composer.leading`,labelKey:`uiLayoutComposerLeading`},{slot:`composer.actions`,labelKey:`uiLayoutComposer`},{slot:`rightpanel.tabs`,labelKey:`uiLayoutRightPanel`},{slot:`terminal.toolbar`,labelKey:`uiLayoutTerminal`},{slot:`scm.toolbar`,labelKey:`uiLayoutScm`},{slot:`bottombar`,labelKey:`uiLayoutBottombar`},{slot:`file.preview.toolbar`,labelKey:`uiLayoutFilePreview`},{slot:`contextmenu.topbar`,labelKey:`uiLayoutContextTopbar`},{slot:`contextmenu.message`,labelKey:`uiLayoutContextMessage`},{slot:`contextmenu.session`,labelKey:`uiLayoutContextSession`},{slot:`contextmenu.project`,labelKey:`uiLayoutContextProject`},{slot:`contextmenu.file`,labelKey:`uiLayoutContextFile`},{slot:`contextmenu.toolcall`,labelKey:`uiLayoutContextToolcall`},{slot:`settings.pages`,labelKey:`uiLayoutSettingsPages`},{slot:`tasks.panel`,labelKey:`uiLayoutTasksPanel`},{slot:`modal.dialog`,labelKey:`uiLayoutModal`},{slot:`sidebar.left`,labelKey:`uiLayoutSidebarLeft`},{slot:`sidebar.right`,labelKey:`uiLayoutSidebarRight`}],Ii=[`bottombar`,`composer.actions`,`topbar.primary`,`sidebar.left`,`sidebar.right`],Li=e=>e===`sidebar.left`||e===`sidebar.right`,Ri=[`topbar.primary`,`bottombar`,`sidebar.left`,`sidebar.right`],[zi,Bi]=(0,g.useState)(``),Vi=e=>{let t=Fi.find(t=>t.slot===e);return t?u(t.labelKey):e},Ui=e.settings?.uiLayout,Wi=e=>Q({uiLayout:{...Ui,...e}}),Gi=e=>{let t=new Set(Ui?.hidden??[]),n=new Set(Ui?.shown??[]);e.hidden?(t.delete(e.id),n.add(e.id)):(t.add(e.id),n.delete(e.id)),Wi({hidden:[...t],shown:[...n]})},Ki=(e,t,n,r)=>{let i=t.map(e=>e.id),a=i.indexOf(n),o=a+r;if(a<0||o<0||o>=i.length)return;let s=[...i],[c]=s.splice(a,1);if(c===void 0)return;s.splice(o,0,c);let l=new Set(i),u=[...s],d=e.map(e=>l.has(e.id)?u.shift():e.id),f=new Set(e.map(e=>e.id)),p=(Ui?.order??[]).filter(e=>!f.has(e));Wi({order:[...p,...d]})},qi=(e,t)=>{(t===`start`||t===`center`||t===`end`)&&Wi({align:{...Ui?.align,[e]:t}})},Ji=(e,t)=>{let n={...Ui?.slots,[e]:t};Wi({slots:n})},Yi=(e,t)=>{let n={...Ui?.labels},r=t.trim().slice(0,60);r?n[e]=r:delete n[e],Wi({labels:n})},Xi=e=>Q({uiLayout:ra(Ui,e)}),Zi=()=>Q({uiLayout:ia()}),Qi=e=>{On(null),ki(`uninstall`,e)},ea=(e,t)=>{ki(`update`,e,t)},ta=e=>{ki(`install`,e.id,e.source)},na=e=>{$({type:`plugin_catalog_remove`,id:e})},aa=()=>{let e=zn.trim();e&&($({type:`plugin_catalog_add`,entry:{source:e,...Vn.trim()?{id:Vn.trim()}:{},...Un.trim()?{name:Un.trim()}:{},...Gn.trim()?{description:Gn.trim()}:{},...qn.trim()?{icon:qn.trim()}:{}}}),Bn(``),Hn(``),Wn(``),Kn(``),Jn(``),Xn(!1))},oa=e=>{let t=e.trim();if(!t)return;let n=jt();cr(n),ur(t),$({type:`plugin_catalog_sync`,requestId:n,source:t,...rr?{install:!0}:{},...ar?{replace:!0}:{}})},[sa,ca]=(0,g.useState)(``);(0,g.useEffect)(()=>{let e=zn.trim();if(!e){ca(``);return}let t=setTimeout(()=>{let t=jt();ca(t),$({type:`plugin_install_inspect`,requestId:t,source:e,...Vn.trim()?{explicitId:Vn.trim()}:{}})},500);return()=>clearTimeout(t)},[zn,Vn]);let la=e.installInspect,ua=la&&la.requestId===sa&&la.source===zn.trim()?la:null,da=e.catalogSync&&e.catalogSync.requestId===sr?e.catalogSync:null;(0,g.useEffect)(()=>{da?.ok&&lr&&mr(fx(lr))},[da?.requestId,da?.ok]);let fa=e=>{let t=new Set(_.reviewSkills.filter(e=>!e.enabled).map(e=>e.name));t.has(e.name)?t.delete(e.name):t.add(e.name),Q({reviewDisabledSkills:[...t]})},pa=()=>{De.current&&=(clearTimeout(De.current),null);let e=Ee.current;e!==(_?.promptTemplate??``)&&Q({promptTemplate:e})},ma=e=>{let t=je.current[e]??``;Q({promptOverrides:{[e]:t}})},ha=e=>{Pe.current===e&&(Pe.current=null),Be(null),ke(t=>{let n={...t};return delete n[e],je.current=n,n}),Q({promptOverrides:{[e]:``}})},ga=e=>We(t=>({...t,[e]:!t[e]})),_a=(e,t)=>{ke(n=>{let r={...n,[e]:t};return je.current=r,r}),Be(e)},va=()=>{De.current&&=(clearTimeout(De.current),null),Me.current=!1,Pe.current=null,Te(ax),Ee.current=ax,ke({}),je.current={},Q({promptTemplate:ax,promptOverrides:{}})},ya=e=>{De.current&&=(clearTimeout(De.current),null);let t=Ee.current,n=t.trim()?`${t}\n\n{{${e}}}`:`{{${e}}}`;Te(n),Ee.current=n,Q({promptTemplate:n})},ba=()=>{De.current&&=(clearTimeout(De.current),null);let e=Ee.current;e!==(_?.promptTemplate??``)&&Q({promptTemplate:e}),Me.current=!1;let t=je.current,n=_?.promptOverrides??{},r={},i=!1;for(let[e,a]of Object.entries(t)){let t=_?.promptSourceDefaults?.[e]??``,o=a.trim()&&a===t?``:a;o!==(n[e]??``)&&(r[e]=o,i=!0)}i&&Q({promptOverrides:r}),Pe.current=null},xa=()=>{ba(),i()},Sa=e=>{ba(),C(e)};zt(xa,!Ct&&!At&&!Jt&&!bt&&!H),(0,g.useEffect)(()=>()=>{ba()},[]);let Ca=we.trim()&&we.trim()!==ax||Object.values(Oe).some(e=>e.trim());return(0,X.jsxs)(`div`,{className:`modal-backdrop`,onClick:xa,children:[(0,X.jsxs)(`div`,{className:`modal settings-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":u(`close`),onClick:xa,children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(ce,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:u(`settingsTitle`)}),(0,X.jsx)(mu,{text:u(`settingsDesc`)})]}),(0,X.jsxs)(`div`,{className:`settings-layout`,children:[(0,X.jsx)(`nav`,{className:`settings-rail`,"aria-label":u(`settingsTitle`),ref:D,children:ai.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-tab":e.id,className:`settings-tab${S===e.id?` active`:``}`,"aria-current":S===e.id?`true`:void 0,title:e.hint??e.label,onClick:()=>Sa(e.id),children:[(0,X.jsx)(`span`,{className:`settings-tab-icon`,children:e.icon}),(0,X.jsx)(`span`,{className:`settings-tab-label`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`set-count`,children:e.count}),e.dot&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]},e.id))}),(0,X.jsxs)(`div`,{className:`modal-body`,ref:E,children:[S===`prompt`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(N,{className:`set-section-icon`}),u(`settingsSystemPrompt`),(0,X.jsx)(mu,{text:`${u(`promptComposeHint`)}\n${u(`promptComposeDesc`)}`})]}),(0,X.jsxs)(`div`,{className:`set-prompt-view-triggers`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":Wt,onClick:()=>Gt(e=>!e),children:[(0,X.jsx)(`span`,{children:u(`settingsViewPrompt`)}),en>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:u(`settingsViewPromptTokens`,{n:en.toLocaleString()})}),(0,X.jsx)(`span`,{children:Wt?`▴`:`▾`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":Kt,onClick:()=>qt(e=>!e),children:[(0,X.jsx)(`span`,{children:u(`settingsViewToolsSchema`)}),tn>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:u(`settingsViewPromptTokens`,{n:tn.toLocaleString()})}),(0,X.jsx)(`span`,{children:Kt?`▴`:`▾`})]}),nn>0&&(0,X.jsx)(`span`,{className:`set-prompt-total-est`,children:u(`settingsPromptContextTotal`,{n:nn.toLocaleString()})})]}),Wt&&(0,X.jsxs)(`div`,{className:`set-prompt-view`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:u(`settingsViewPrompt`)}),(0,X.jsx)(mu,{text:u(`settingsViewPromptHint`)}),(0,X.jsx)(Sd,{text:_.effectiveSystemPrompt})]}),_.effectiveSystemPrompt?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:_.effectiveSystemPrompt}):(0,X.jsx)(`p`,{className:`set-empty`,children:u(`settingsViewPromptEmpty`)})]}),Kt&&(0,X.jsx)(`div`,{className:`set-prompt-view`,children:(0,X.jsxs)(`div`,{className:`set-prompt-tools`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:u(`settingsViewToolsSchema`)}),(0,X.jsx)(mu,{text:u(`settingsViewToolsSchemaHint`)}),(0,X.jsx)(Sd,{text:_.toolsSchema})]}),_.toolsSchema?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:_.toolsSchema}):(0,X.jsx)(`p`,{className:`set-empty`,children:u(`settingsViewToolsSchemaEmpty`)})]})}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`promptTemplateLabel`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:6,spellCheck:!1,placeholder:ax,value:we,onFocus:()=>Me.current=!0,onBlur:()=>{Me.current=!1,pa()},onChange:e=>{let t=e.target.value;Te(t),Ee.current=t,De.current&&clearTimeout(De.current),De.current=setTimeout(()=>{De.current=null,t!==(_?.promptTemplate??``)&&Q({promptTemplate:t})},800)}}),(0,X.jsxs)(`div`,{className:`compose-toolbar`,children:[(0,X.jsx)(`span`,{className:`set-field-label set-muted`,children:u(`promptInsertTokens`)}),Ie.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`token-chip`,title:f(`promptTok_${e}_desc`),onClick:()=>ya(e),children:`{{${e}}}`},e))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`promptSourcesLabel`)}),Ie.map(e=>{let t=Oe[e]??``,n=_.promptSourceDefaults?.[e]??``,r=ze===e,i=n.split(`
674
- `).length>6||n.length>480;if(ix(e)){let r=t.trim()?t:n;return(0,X.jsxs)(`div`,{className:`override-row readonly`,children:[(0,X.jsxs)(`div`,{className:`override-row-head`,children:[`{{${e}}}`,(0,X.jsxs)(`span`,{className:`set-muted`,children:[f(`promptTok_${e}`),` `,(0,X.jsx)(mu,{text:f(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,title:u(`promptReadonlyLockedHint`),onClick:()=>ha(e),children:u(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:u(`promptReadonlyBadge`)})]}),(0,X.jsx)(`div`,{className:`source-default readonly${r.trim()?``:` empty`}`,title:u(`promptReadonlyTitle`),children:r.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?He[e]?` expanded`:` clamped`:``}`,children:r}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ga(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ga(e))},children:He[e]?u(`promptSourceCollapse`):u(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:u(`promptSourceDefaultEmpty`)})})]},e)}return(0,X.jsxs)(`div`,{className:`override-row`,children:[(0,X.jsxs)(`div`,{className:`override-row-head`,children:[`{{${e}}}`,(0,X.jsxs)(`span`,{className:`set-muted`,children:[f(`promptTok_${e}`),` `,(0,X.jsx)(mu,{text:f(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,onClick:()=>ha(e),children:u(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:u(`promptAutoBadge`)})]}),t.trim()||r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`set-prompt-input override-input`,rows:Math.min(10,Math.max(1,t.split(`
675
- `).length)),autoFocus:r,placeholder:u(`promptOverridePlaceholder`),value:t,onFocus:t=>{Pe.current=e,Be(e);let r=t.currentTarget;r.value&&r.value===n&&r.setSelectionRange(r.value.length,r.value.length)},onBlur:()=>{Pe.current===e&&(Pe.current=null);let t=Oe[e]??``;if(t.trim()&&t===n){ha(e);return}ma(e),t.trim()||Be(null)},onChange:t=>{let n=t.target.value;ke(t=>{let r={...t,[e]:n};return je.current=r,r})}}),(0,X.jsxs)(`div`,{className:`override-edit-foot`,children:[(0,X.jsxs)(`div`,{className:`override-edit-foot-head`,children:[(0,X.jsx)(`span`,{className:`set-muted`,children:u(`promptSourceRefLabel`)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`source-default-toggle`,onClick:()=>ga(e),children:He[e]?u(`promptSourceCollapse`):u(`promptSourceExpand`)})]}),n.trim()?(0,X.jsx)(`pre`,{className:`source-default-text${i?He[e]?` expanded`:` clamped`:``}`,children:n}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:u(`promptSourceDefaultEmpty`)}),!t.trim()&&n.trim()&&(0,X.jsx)(`button`,{type:`button`,className:`override-seed-btn`,title:u(`promptSourceSeedTip`),onClick:()=>_a(e,n),children:u(`promptSourceSeedButton`)})]})]}):(0,X.jsx)(`div`,{className:`source-default`,title:u(`promptSourceDefaultEditHint`),role:`button`,tabIndex:0,onClick:()=>_a(e,n),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),_a(e,n))},children:n.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?He[e]?` expanded`:` clamped`:``}`,children:n}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ga(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ga(e))},children:He[e]?u(`promptSourceCollapse`):u(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:u(`promptSourceDefaultEmpty`)})})]},e)}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-btn`,onClick:va,disabled:!Ca,children:u(`promptResetAll`)})})]})]}),S===`prompt`&&!x&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Le,{className:`set-section-icon`}),u(`scmCommitMsgSettingsTitle`),(0,X.jsx)(mu,{text:u(`scmCommitMsgSettingsDesc`)})]}),(0,X.jsx)(xx,{mode:nt,onModeChange:it,draft:et,onDraftChange:tt,defaultPrompt:_.scmCommitMsgDefaultPrompt,placeholder:u(`scmCommitMsgPromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({scmCommitMsgPromptMode:e,scmCommitMsgPrompt:t})},hint:u(`scmCommitMsgSettingsHint`),focusRef:at})]}),S===`prompt`&&!x&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Y,{className:`set-section-icon`}),u(`planModePromptSettingsTitle`),(0,X.jsx)(mu,{text:u(`planModePromptSettingsDesc`)})]}),(0,X.jsx)(xx,{mode:lt,onModeChange:ut,draft:ot,onDraftChange:st,defaultPrompt:_.planModeDefaultPrompt,placeholder:u(`planModePromptPlaceholder`),rows:8,onCommit:(e,t)=>{Q({planModePromptMode:e,planModePrompt:t})},modeLabel:u(`planModePromptMode`),hint:u(`planModePromptSettingsHint`),focusRef:pt})]}),S===`scheduler`&&!x&&(0,X.jsx)(Wy,{tasks:e.schedulerTasks,cwd:e.state?.cwd??``,models:_.subagentModels}),S===`prompt-history`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(rt,{className:`set-section-icon`}),u(`settingsPromptHistory`),(0,X.jsx)(mu,{text:u(`settingsPromptHistoryDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:u(`promptHistoryCount`,{n:String(bn)})})]}),bn===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`promptHistoryEmpty`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:u(`promptHistoryCount`,{n:String(bn)})}),(0,X.jsx)(bx,{label:u(`promptHistoryMax`),tip:u(`promptHistoryMaxHint`),htmlFor:`ph-max`,children:(0,X.jsx)(`input`,{id:`ph-max`,className:`set-input`,type:`number`,min:1,max:500,step:1,value:String(vn.maxEntries),onChange:e=>{let t=Math.floor(Number(e.target.value)||0),n={...vn,maxEntries:t};yn(n)},onBlur:()=>{let e={...vn};(!Number.isFinite(e.maxEntries)||e.maxEntries<1)&&(e.maxEntries=1),e.maxEntries>500&&(e.maxEntries=500),e.maxEntries=Math.floor(e.maxEntries),yn(e),o_(e),wn()}})}),(0,X.jsx)(mx,{title:u(`promptHistoryCharLimit`),tip:u(`promptHistoryCharLimitHint`),enabled:vn.charLimitEnabled,onToggle:()=>{let e={...vn,charLimitEnabled:!vn.charLimitEnabled};yn(e),o_(e),wn()}}),vn.charLimitEnabled&&(0,X.jsx)(bx,{label:u(`promptHistoryCharLimit`),htmlFor:`ph-char-limit`,children:(0,X.jsx)(`input`,{id:`ph-char-limit`,className:`set-input`,type:`number`,min:100,max:2e4,step:100,placeholder:u(`promptHistoryCharLimitPlaceholder`),value:String(vn.charLimit),onChange:e=>{let t=Math.floor(Number(e.target.value)||0);yn({...vn,charLimit:t})},onBlur:()=>{let e=Math.floor(Number(vn.charLimit)||0);(!Number.isFinite(e)||e<100)&&(e=100),e>2e4&&(e=2e4);let t={...vn,charLimit:e};yn(t),o_(t),wn()}})}),(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:12},children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${Sn?` confirm`:``}`,disabled:bn===0,title:u(bn===0?`promptHistoryEmpty`:`promptHistoryClear`),onClick:()=>{if(!Sn){Cn(!0);return}f_(),Cn(!1),wn()},children:[(0,X.jsx)(R,{}),` `,u(Sn?`promptHistoryClearConfirm`:`promptHistoryClear`)]}),bn>0&&(0,X.jsx)(`span`,{className:`set-hint`,style:{marginLeft:8},children:u(`promptHistoryCount`,{n:String(bn)})})]}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[(0,X.jsx)(St,{style:{verticalAlign:`-2px`,marginRight:4}}),u(`settingsPromptHistoryDesc`)]})]}),S===`tools`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(z,{className:`set-section-icon`}),u(`settingsTools`)]}),Kr&&(0,X.jsxs)(`p`,{className:`set-catalog-hint warn`,children:[u(`toolsPresetBanner`,{name:Jr,count:Xr+Zr}),` `,(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>$({type:`dsh_preset_default`,preset:`standard`}),children:u(`toolsBackToStandard`)})]}),(0,X.jsx)(mx,{title:u(`readDirEnabled`),tip:u(`readDirEnabledDesc`),enabled:_.readDirEnabled!==!1,onToggle:()=>Q({readDirEnabled:_.readDirEnabled===!1})}),!x&&(0,X.jsx)(mx,{title:u(`toolLazyLoading`),tip:u(`toolLazyLoadingDesc`),enabled:_.toolLazyLoading!==!1,onToggle:()=>Q({toolLazyLoading:_.toolLazyLoading===!1})}),(0,X.jsx)(mx,{title:u(`toolApprovalEnabled`),tip:u(`toolApprovalEnabledDesc`),enabled:_.toolApprovalEnabled!==!1,onToggle:()=>Q({toolApprovalEnabled:_.toolApprovalEnabled===!1}),action:x?void 0:(0,X.jsxs)(`button`,{type:`button`,className:`tpl-chip`,onClick:()=>C(`approval-rules`),title:u(`settingsApprovalRulesDesc`),children:[(0,X.jsx)(se,{}),` `,u(`manageApprovalRules`)]})}),e.dshPermission&&e.dshPermission.options.length>0&&(0,X.jsxs)(`div`,{className:`set-mode-row`,style:{marginTop:8,marginBottom:8},children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`dshPermDefault`),(0,X.jsx)(mu,{text:u(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:H_.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:u(U_(e))},e))})]}),v?.allowAll||(v?.categories.length??0)>0?(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`toolApprovalPolicyTitle`),(0,X.jsx)(mu,{text:u(`toolApprovalPolicyHint`)})]}),v?.allowAll&&(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:u(`toolApprovalPolicyAllowAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,allowAll:!1}),children:u(`toolApprovalPolicyRevoke`)})]}),(v?.categories??[]).map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:d===`zh`?e.label:e.labelEn}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,categories:(v?.categories??[]).filter(t=>t.id!==e.id).map(e=>e.id)}),children:u(`toolApprovalPolicyRevoke`)})]},e.id))]}):null,(0,X.jsx)(bx,{label:u(`toolWatchdogTimeout`),tip:u(`toolWatchdogTimeoutDesc`),htmlFor:`tool-watchdog-timeout`,children:(0,X.jsx)(`input`,{id:`tool-watchdog-timeout`,className:`set-input`,type:`number`,min:0,step:1,placeholder:u(`toolWatchdogOff`),value:Cr,onChange:e=>wr(e.target.value),onBlur:()=>{let e=Cr.trim(),t=e===``?20:Math.max(0,Math.floor(Number(e)||0));wr(String(t));let n=t*6e4;n!==_.toolWatchdogTimeoutMs&&Q({toolWatchdogTimeoutMs:n})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`toolsSectionCore`),(0,X.jsx)(mu,{text:u(`toolsCoreHint`)})]}),Nr.map(e=>{let t=Yr(e);return(0,X.jsx)(mx,{title:e,tip:yi[e],action:Qt(e),subtitle:t?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Ur.has(e),disabled:t,onToggle:()=>bi(e)},e)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:u(`toolsSectionTerminal`)}),fr.map(e=>{let t=Yr(e);return(0,X.jsx)(mx,{title:e,tip:u(`settingsTerminalToolsDesc`),action:Qt(e),subtitle:t?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Ur.has(e),disabled:t,onToggle:()=>bi(e)},e)}),(0,X.jsx)(mx,{title:u(`terminalBashTakeover`),tip:u(`terminalBashTakeoverDesc`),enabled:_.terminalBash,onToggle:()=>Q({terminalBash:!_.terminalBash})}),_.terminalBash&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(bx,{label:u(`terminalBashIdleMs`),tip:u(`terminalBashIdleMsDesc`),htmlFor:`tb-idle-ms`,children:(0,X.jsx)(`input`,{id:`tb-idle-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:yr,onChange:e=>br(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(yr)||0));br(String(e)),e!==_.terminalBashIdleMs&&Q({terminalBashIdleMs:e})}})}),(0,X.jsx)(bx,{label:u(`terminalBashMaxForegroundMs`),tip:u(`terminalBashMaxForegroundMsDesc`),htmlFor:`tb-max-ms`,children:(0,X.jsx)(`input`,{id:`tb-max-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:xr,onChange:e=>Sr(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(xr)||0));Sr(String(e)),e!==_.terminalBashMaxForegroundMs&&Q({terminalBashMaxForegroundMs:e})}})})]}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`toolsSectionSubagent`),` `,(0,X.jsx)(mu,{text:u(`toolsSubagentDepHint`)})]}),pr.map(e=>{let t=Yr(e);return(0,X.jsx)(mx,{title:e,tip:vi[e],action:Qt(e),subtitle:t?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Ur.has(e),disabled:t,onToggle:()=>bi(e)},e)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`settingsMarkers`),(0,X.jsx)(mu,{text:`${u(`settingsMarkersDesc`)}\n${u(`markerRenameTip`)}`})]}),(0,X.jsx)(mx,{title:u(`markersEnabled`),tip:`${u(`markersEnabledDesc`)}\n${u(`markersOffHint`)}`,enabled:wi,onToggle:()=>Q({markersEnabled:!wi})}),wi&&(_.markers?.length??0)===0&&(0,X.jsxs)(`p`,{className:`set-empty`,children:[u(`loading`),`...`]}),wi&&_.markers&&_.markers.length>0&&_.markers.map(e=>(0,X.jsx)(mx,{title:e.name===`todo`?u(`markerGroupTodo`):e.name===`notify`?u(`markerGroupNotify`):e.name===`conv`?u(`markerGroupRename`):e.name===`action`?u(`markerGroupAction`):e.name,tip:e.guidance.join(`
676
- `),enabled:e.enabled,onToggle:()=>Ei(e.name)},e.name)),(0,X.jsx)(mx,{title:`todo_list`,tip:`${u(`todoListEnabledDesc`)}\n${u(`todoListOffHint`)}`,action:Qt(`todo_list`),subtitle:Yr(`todo_list`)?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!Yr(`todo_list`)&&!Ur.has(`todo_list`),disabled:Yr(`todo_list`),onToggle:()=>bi(`todo_list`)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:u(`toolsSectionOther`)}),cx.map(e=>{let t=Yr(e.name),n=e.name===`codemode`&&!t&&!Ur.has(e.name);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(mx,{title:e.name,tip:`${f(e.descKey??e.name)}\n${f(e.offHintKey??e.name)}`,action:Qt(e.name),subtitle:t?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Ur.has(e.name),disabled:t,onToggle:()=>bi(e.name)}),n&&(0,X.jsxs)(`div`,{className:`sub-settings-block`,style:{marginLeft:24,marginTop:-6,marginBottom:12,padding:`10px 14px`,borderRadius:6,backgroundColor:`var(--bg-elev2, rgba(255,255,255,0.03))`,border:`1px solid var(--border-subtle, rgba(255,255,255,0.08))`,display:`flex`,flexDirection:`column`,gap:8},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,X.jsxs)(`label`,{className:`set-field-label`,style:{margin:0,fontSize:13},children:[u(`codemodeModeLabel`),(0,X.jsx)(mu,{text:u(`codemodeModeHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,style:{width:`auto`,minWidth:140},value:_.codemodeMode??`on`,onChange:e=>Q({codemodeMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`on`,children:u(`codemodeModeOn`)}),(0,X.jsx)(`option`,{value:`only`,children:u(`codemodeModeOnly`)})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,X.jsxs)(`label`,{className:`set-field-label`,style:{margin:0,fontSize:13},children:[u(`codemodeInlineBudgetLabel`),(0,X.jsx)(mu,{text:u(`codemodeInlineBudgetHint`)})]}),(0,X.jsx)(`input`,{type:`number`,className:`set-input`,style:{width:100,textAlign:`right`},min:500,max:5e4,step:500,value:_.codemodeInlineBudget??3e3,onChange:e=>{let t=parseInt(e.target.value,10);!isNaN(t)&&t>0&&Q({codemodeInlineBudget:t})}})]})]})]},e.name)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`toolsSectionPlugin`),(0,X.jsx)(mu,{text:u(`toolsPluginHint`)})]}),Ci.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:e.plugins.length===0?u(`noUiPlugins`):u(`pluginToolsEmpty`)}):Ci.map(e=>{let t=pi.has(e.plugin.id);return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[e.plugin.icon?`${e.plugin.icon} `:``,e.plugin.name,` · `,e.plugin.id,t?` (${u(`pluginDisabledInPlugins`)})`:``]}),e.tools.map(e=>(0,X.jsx)(mx,{title:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name,tip:e.description?`${e.description}\n${u(`pluginToolOffHint`)}`:u(`pluginToolOffHint`),action:Qt(e.name),subtitle:t?u(`pluginToolsDisabledByPlugin`):Kr?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Kr&&!xi.has(e.name),disabled:t||Kr,onToggle:()=>!t&&!Kr&&Si(e.name)},e.name))]},e.plugin.id)})]}),S===`question`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ne,{className:`set-section-icon`}),u(`settingsQuestionnaire`)]}),(0,X.jsx)(mx,{title:u(`questionnaireEnabled`),tip:`${u(`questionnaireEnabledDesc`)}\n${u(`questionnaireOffHint`)}`,enabled:_.questionnaireEnabled,onToggle:()=>Q({questionnaireEnabled:!_.questionnaireEnabled})})]}),S===`display`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(J,{className:`set-section-icon`}),u(`settingsMessageDisplay`)]}),(0,X.jsx)(bx,{label:u(`softCapTokens`),tip:u(`softCapHint`),htmlFor:`soft-cap-max`,children:(0,X.jsx)(`input`,{id:`soft-cap-max`,className:`set-input`,type:`text`,placeholder:u(`softCapOff`),value:kr,onChange:e=>Ar(e.target.value),onBlur:()=>{let e=eb(kr);Ar(tb(e)),e!==(_.softCapTokens??0)&&Q({softCapTokens:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-section-title`,children:[u(`softCapByModel`),(0,X.jsx)(mu,{text:u(`softCapByModelHint`)})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`softCapModelId`),value:jr,maxLength:200,onChange:e=>Pr(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,placeholder:u(`softCapTokens`),value:Fr,onChange:e=>Rr(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&jr.trim()&&eb(Fr)>0){let e=eb(Fr);Q({softCapByModel:{..._.softCapByModel,[jr.trim()]:e}}),Pr(``),Rr(``)}}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!jr.trim()||eb(Fr)<=0,onClick:()=>{let e=jr.trim(),t=eb(Fr);!e||t<=0||(Q({softCapByModel:{..._.softCapByModel,[e]:t}}),Pr(``),Rr(``))},children:[(0,X.jsx)(me,{}),` `,u(`softCapAdd`)]})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Object.entries(_.softCapByModel).map(([e,t])=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-row-name`,children:e}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,defaultValue:tb(t),onBlur:t=>{let n=eb(t.target.value);t.target.value=tb(n);let r={..._.softCapByModel};n>0?r[e]=n:delete r[e],Q({softCapByModel:r})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}},`${e}:${t}`),(0,X.jsxs)(`button`,{type:`button`,className:`chip`,title:u(`softCapRemove`),onClick:()=>{let t={..._.softCapByModel};delete t[e],Q({softCapByModel:t})},children:[(0,X.jsx)(P,{}),` `,u(`softCapRemove`)]})]},e))}),(0,X.jsx)(bx,{label:u(`modelRetryAttempts`),tip:u(`modelRetryHint`),htmlFor:`model-retry-max`,children:(0,X.jsx)(`input`,{id:`model-retry-max`,className:`set-input`,type:`number`,min:0,max:100,step:1,value:Tr,onChange:e=>Er(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(0,Math.floor(Number(Tr)||0)));Er(String(e)),e!==_.retryMaxAttempts&&Q({retryMaxAttempts:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(mx,{title:u(`thinkingWrap`),tip:u(`thinkingWrapDesc`),enabled:_.thinkingWrap??!0,onToggle:()=>Q({thinkingWrap:!(_.thinkingWrap??!0)})}),(0,X.jsx)(mx,{title:u(`toolsWrap`),tip:u(`toolsWrapDesc`),enabled:_.toolsWrap??!0,onToggle:()=>Q({toolsWrap:!(_.toolsWrap??!0)})}),(0,X.jsx)(mx,{title:u(`toolImages`),tip:u(`toolImagesDesc`),enabled:_.toolImagesEnabled??!0,onToggle:()=>Q({toolImagesEnabled:!(_.toolImagesEnabled??!0)})}),(0,X.jsx)(bx,{label:u(`keepRecent`),tip:u(`keepRecentDesc`),htmlFor:`keep-recent`,children:(0,X.jsx)(`input`,{id:`keep-recent`,className:`set-input`,type:`number`,min:5,max:100,step:1,value:Dr,onChange:e=>Or(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(5,Math.floor(Number(Dr)||15)));Or(String(e)),e!==_.keepRecentMessages&&Q({keepRecentMessages:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(mx,{title:u(`presentAutoOpen`),tip:u(`presentAutoOpenDesc`),enabled:an,onToggle:()=>Sp(!an)}),(0,X.jsx)(mx,{title:u(`parallelReminderEnabled`),tip:`${u(`parallelReminderEnabledDesc`)}\n${u(`parallelReminderOffHint`)}`,enabled:_.parallelReminderEnabled??!0,onToggle:()=>Q({parallelReminderEnabled:!(_.parallelReminderEnabled??!0)})}),(0,X.jsx)(mx,{title:u(`devNoCache`),tip:u(`devNoCacheDesc`),enabled:_.devNoCache??!0,onToggle:()=>Q({devNoCache:!(_.devNoCache??!0)})}),(0,X.jsx)(mx,{title:u(`autoReload`),tip:u(`autoReloadDesc`),enabled:_.autoReload??!0,onToggle:()=>Q({autoReload:!(_.autoReload??!0)})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsx)(mx,{title:u(`wideChat`),tip:u(`wideChatDesc`),enabled:rn,onToggle:()=>ob({wide:!rn})}),(0,X.jsx)(mx,{title:u(`projectTitle`),tip:u(`projectTitleDesc`),enabled:sn,onToggle:()=>_b({projectName:!sn})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[u(`wallpaperTitle`),(0,X.jsx)(mu,{text:u(`wallpaperDesc`)})]}),(0,X.jsxs)(`div`,{className:`wallpaper-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input wallpaper-url`,placeholder:u(`wallpaperUrlPh`),value:ln,maxLength:2e3,spellCheck:!1,onFocus:()=>{dn.current=!0},onChange:e=>un(e.target.value),onBlur:()=>{if(dn.current=!1,!ln.trim()&&cn.url.startsWith(`data:`)){un(``);return}let e=Ob(ln);un(e),e!==cn.url&&Fb({...cn,url:e})},onKeyDown:e=>{e.key===`Enter`?e.target.blur():e.key===`Escape`&&(un(cn.url.startsWith(`data:`)?``:cn.url),e.target.blur())}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:pn,onClick:()=>fn.current?.click(),children:[(0,X.jsx)(re,{}),` `,u(`wallpaperUpload`)]}),(0,X.jsx)(`input`,{ref:fn,type:`file`,accept:`image/*`,hidden:!0,onChange:_n})]}),hn&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`wallpaperUploadFailed`)}),(0,X.jsxs)(`div`,{className:`wallpaper-sliders`,children:[(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:u(`wallpaperDim`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:95,step:1,value:cn.dim,onChange:e=>Fb({...cn,dim:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[cn.dim,`%`]})]}),(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:u(`wallpaperBlur`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:24,step:1,value:cn.blur,onChange:e=>Fb({...cn,blur:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[cn.blur,`px`]})]})]})]}),cn.url&&(0,X.jsxs)(`div`,{className:`wallpaper-current`,children:[(0,X.jsx)(`img`,{className:`wallpaper-preview`,src:cn.url,alt:``}),(0,X.jsx)(`button`,{type:`button`,className:`wallpaper-clear`,onClick:()=>{un(``),Fb({...cn,url:``})},children:u(`wallpaperClear`)})]})]})]}),S===`sound`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ne,{className:`set-section-icon`}),u(`settingsSoundVoice`)]}),(0,X.jsx)(Fn,{settings:o,onChange:s,onPreview:e=>$y(e,o)}),(0,X.jsx)(Ln,{settings:c,onChange:l,onPreview:()=>on(u(`ttsPreviewLine`),{...c,enabled:!0})})]}),S===`quick`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ue,{className:`set-section-icon`}),u(`quickPhrases`),(0,X.jsx)(mu,{text:u(`quickPhrasesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.quickPhrases.length})]}),(0,X.jsx)(mx,{title:u(`quickPhrasesEnabled`),tip:u(`quickPhrasesDesc`),enabled:_.quickPhrasesEnabled,onToggle:()=>Q({quickPhrasesEnabled:!_.quickPhrasesEnabled})}),!_.quickPhrasesEnabled&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`quickPhrasesOffHint`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`quickPhrasesPlaceholder`),value:hr,maxLength:200,onChange:e=>gr(e.target.value),onKeyDown:e=>{e.key===`Enter`&&hr.trim()&&(Q({quickPhrases:[..._.quickPhrases,hr.trim()]}),gr(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!hr.trim(),onClick:()=>{Q({quickPhrases:[..._.quickPhrases,hr.trim()]}),gr(``)},children:[(0,X.jsx)(me,{}),` `,u(`quickPhrasesAdd`)]})]}),_.quickPhrases.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`quickPhrasesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.quickPhrases.map((e,t)=>(0,X.jsx)(`div`,{className:`set-row`,children:_r?.index===t?(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`input`,{className:`set-input`,autoFocus:!0,value:_r.value,maxLength:200,placeholder:u(`quickPhrasesEditPh`),onChange:e=>vr({index:t,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?li():e.key===`Escape`&&vr(null)},onBlur:li})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`div`,{className:`set-row-name`,title:e,children:e})}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`quickPhrasesEdit`),onClick:()=>vr({index:t,value:e}),children:(0,X.jsx)(Y,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`quickPhrasesMoveUp`),disabled:t===0,onClick:()=>{let e=[..._.quickPhrases];[e[t-1],e[t]]=[e[t],e[t-1]],Q({quickPhrases:e})},children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`quickPhrasesMoveDown`),disabled:t===_.quickPhrases.length-1,onClick:()=>{let e=[..._.quickPhrases];[e[t],e[t+1]]=[e[t+1],e[t]],Q({quickPhrases:e})},children:`↓`}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`quickPhrasesDelete`),onClick:()=>Q({quickPhrases:_.quickPhrases.filter((e,n)=>n!==t)}),children:(0,X.jsx)(R,{})})]})]})},`${t}:${e}`))}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{vr(null),Q({quickPhrases:tx[d]??tx.en})},children:u(`quickPhrasesReset`)})})]}),S===`skills`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ze,{className:`set-section-icon`}),u(`settingsSkills`),(0,X.jsx)(mu,{text:`${u(`skillFullTextLabel`)}:${u(`skillFullTextDesc`)}`}),(0,X.jsx)(`span`,{className:`set-count`,children:_.skills.length})]}),(0,X.jsxs)(`div`,{className:`mcp-tab-bar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tab-btn${O===`installed`?` active`:``}`,onClick:()=>k(`installed`),children:[(0,X.jsx)(Ze,{}),(0,X.jsx)(`span`,{children:u(`skillTabInstalled`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.skills.length})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tab-btn${O===`market`?` active`:``}`,onClick:()=>k(`market`),children:[(0,X.jsx)(oe,{}),(0,X.jsx)(`span`,{children:u(`skillTabMarket`)}),(0,X.jsx)(`span`,{className:`set-count`,children:Ry.length})]})]}),O===`installed`&&(0,X.jsxs)(X.Fragment,{children:[!x&&Kr&&!Lr(Gr??void 0)&&(0,X.jsx)(`p`,{className:`set-catalog-hint warn`,children:u(`skillsHiddenByPreset`,{name:Jr})}),_.skills.length===0?(0,X.jsxs)(`div`,{className:`mcp-empty-card`,children:[(0,X.jsx)(`div`,{className:`mcp-empty-icon`,children:(0,X.jsx)(Ze,{})}),(0,X.jsx)(`div`,{className:`mcp-empty-title`,children:u(x?`dshSkillsNote`:`noSkills`)}),(0,X.jsx)(`div`,{className:`mcp-empty-desc`,children:u(`skillEmptyDesc`)}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-goto-market-btn`,onClick:()=>k(`market`),children:[(0,X.jsx)(oe,{}),u(`skillBrowseMarket`)]})]}):(0,X.jsx)(`div`,{className:`set-list`,children:_.skills.map(e=>(0,X.jsx)(mx,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>ui(e),action:(0,X.jsx)(`button`,{type:`button`,className:`tpl-chip${di.has(e.name)?` on`:``}`,title:u(`skillFullTextDesc`),onClick:()=>fi(e.name),children:u(`skillFullTextShort`)})},e.name))})]}),O===`market`&&(0,X.jsxs)(`div`,{className:`skill-market-view`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-toolbar`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-source-row`,children:[(0,X.jsxs)(`div`,{className:`mcp-source-select-wrap`,children:[(0,X.jsxs)(`label`,{className:`mcp-source-label`,children:[u(`skillRepoSelect`),`:`]}),(0,X.jsxs)(`select`,{className:`set-select mcp-source-select`,value:te,onChange:e=>I(e.target.value),children:[(0,X.jsx)(`option`,{value:`anthropics/skills`,children:u(`skillRepoDefault`)}),(0,X.jsx)(`option`,{value:`custom`,children:u(`skillRepoCustom`)})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn mcp-sync-btn${B?` spinning`:``}`,title:u(`mcpReload`),onClick:()=>ve(!0),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:u(`mcpReload`)})]})]}),te===`custom`&&(0,X.jsx)(`div`,{className:`mcp-custom-source-row`,children:(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-custom-input`,placeholder:u(`skillRepoCustomPlaceholder`),value:L,onChange:e=>ie(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ve(!0)}})}),(0,X.jsxs)(`div`,{className:`mcp-search-wrap`,children:[(0,X.jsx)(de,{className:`mcp-search-icon`}),(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-search-input`,placeholder:u(`skillMarketSearchPlaceholder`),value:ee,onChange:e=>M(e.target.value)}),ee&&(0,X.jsx)(`button`,{type:`button`,className:`mcp-search-clear`,onClick:()=>M(``),children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`div`,{className:`mcp-category-chips`,children:[{id:`all`,label:u(`skillCatAll`)},{id:`quality`,label:u(`skillCatQuality`)},{id:`workflow`,label:u(`skillCatWorkflow`)},{id:`architecture`,label:u(`skillCatArchitecture`)},{id:`devops`,label:u(`skillCatDevops`)},{id:`stack`,label:u(`skillCatStack`)}].map(e=>(0,X.jsx)(`button`,{type:`button`,className:`mcp-cat-chip${A===e.id?` active`:``}`,onClick:()=>j(e.id),children:e.label},e.id))})]}),e.skillMarketResult?.error&&(0,X.jsxs)(`div`,{className:`mcp-error-box`,children:[(0,X.jsx)(wt,{className:`mcp-error-icon`}),(0,X.jsx)(`div`,{className:`mcp-error-text`,children:e.skillMarketResult.error}),(0,X.jsx)(`button`,{type:`button`,className:`mcp-mini-btn`,onClick:()=>ve(!0),children:u(`skillMarketRetry`)})]}),B&&(0,X.jsxs)(`div`,{className:`mcp-market-loading`,children:[(0,X.jsx)(K,{className:`spinning`}),(0,X.jsx)(`span`,{children:u(`skillMarketLoading`)})]}),(0,X.jsx)(`div`,{className:`mcp-market-grid`,children:be.map(e=>{let t=ge.has(e.id.toLowerCase()),n=d===`zh`?e.descriptionZh:e.description,r=d===`zh`?e.nameZh:e.name;return(0,X.jsxs)(`div`,{className:`mcp-market-card skill-market-card`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-card-head`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-title-wrap`,children:[(0,X.jsx)(`span`,{className:`mcp-market-name`,children:e.name}),d===`zh`&&(0,X.jsxs)(`span`,{className:`mcp-market-subname`,children:[`(`,r,`)`]})]}),(0,X.jsx)(`span`,{className:`mcp-badge-official`,children:Ce(e.category)})]}),(0,X.jsx)(`p`,{className:`mcp-market-desc`,children:n}),(0,X.jsxs)(`div`,{className:`skill-market-card-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`skill-inspect-btn`,onClick:()=>U(e),children:[(0,X.jsx)(Ue,{}),u(`skillInspectPrompt`)]}),(0,X.jsx)(`div`,{className:`skill-action-btns`,children:t?(0,X.jsxs)(`div`,{className:`skill-installed-group`,children:[(0,X.jsxs)(`span`,{className:`mcp-market-configured-badge`,children:[(0,X.jsx)(ft,{}),u(`skillInstalled`)]}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn delete-btn`,title:u(`uninstallTitle`),onClick:()=>Se(e.id,`global`),children:(0,X.jsx)(R,{})})]}):(0,X.jsxs)(`div`,{className:`mcp-market-add-btns`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-btn-add global`,title:u(`skillInstallGlobalHint`),onClick:()=>xe(e,`global`),children:[(0,X.jsx)(me,{}),u(`skillInstallGlobal`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-btn-add project`,title:u(`skillInstallProjectHint`),onClick:()=>xe(e,`project`),children:[(0,X.jsx)(me,{}),u(`skillInstallProject`)]})]})})]})]},e.id)})})]}),H&&(0,X.jsx)(`div`,{className:`modal-backdrop sub-modal`,onClick:()=>U(null),children:(0,X.jsxs)(`div`,{className:`modal skill-inspect-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":u(`close`),onClick:()=>U(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ze,{className:`modal-head-icon`}),(0,X.jsx)(`h3`,{children:u(`skillInspectModalTitle`,{name:H.name})})]}),(0,X.jsx)(`div`,{className:`modal-body skill-inspect-body`,children:G===H.id&&!H.content?(0,X.jsxs)(`div`,{className:`mcp-market-loading`,children:[(0,X.jsx)(K,{className:`spinning`}),(0,X.jsx)(`span`,{children:u(`skillContentLoading`)})]}):(0,X.jsx)(`pre`,{className:`skill-code-preview`,children:(0,X.jsx)(`code`,{children:H.content})})}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-cancel-btn`,onClick:()=>U(null),children:u(`close`)}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn global`,onClick:()=>xe(H,`global`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:u(`skillInstallGlobal`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn project`,onClick:()=>xe(H,`project`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:u(`skillInstallProject`)})]})]})]})})]}),S===`extensions`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(q,{className:`set-section-icon`}),u(`settingsExtensions`),(0,X.jsx)(`span`,{className:`set-count`,children:_.extensions.length})]}),_.extensions.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(x?`dshExtensionsNote`:`noExtensions`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.extensions.map(e=>{let t=e.id.startsWith(`npm:`)?e.id.slice(4):null;return(0,X.jsx)(mx,{title:e.name,subtitle:e.path,enabled:e.enabled,onToggle:()=>_i(e),action:t?Tn===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:u(`uninstallConfirmHint`),onClick:()=>Oi(t),children:u(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`uninstallHint`),onClick:()=>En(e.id),children:[(0,X.jsx)(R,{}),u(`uninstallExt`)]}):void 0},e.id)})})]}),S===`layout`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ae,{className:`set-section-icon`}),u(`uiLayoutTitle`),a&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,style:{marginLeft:`auto`},title:u(`uiIconEditHint`),onClick:a,children:[(0,X.jsx)(Ke,{}),u(`uiIconEdit`)]}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,style:a?void 0:{marginLeft:`auto`},onClick:Zi,children:u(`uiLayoutRestoreAll`)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:u(`uiLayoutHint`)}),(0,X.jsxs)(`label`,{className:`set-toggle`,title:`sideDockFloat`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ui?.sideDockFloat===!0,onChange:e=>Wi({sideDockFloat:e.target.checked})}),(0,X.jsx)(`span`,{children:u(`uiLayoutSideDockFloat`)})]}),zr.length>0&&(0,X.jsxs)(`details`,{className:`set-ui-diag`,open:zr.some(e=>e.level===`error`),children:[(0,X.jsxs)(`summary`,{children:[`⚠ `,u(`uiLayoutDiagTitle`,{n:zr.length})]}),(0,X.jsx)(`ul`,{className:`set-ui-diag-list`,children:zr.map((e,t)=>(0,X.jsxs)(`li`,{className:`set-ui-diag-item ${e.level}`,children:[e.pluginId?(0,X.jsx)(`code`,{children:e.pluginId}):null,e.entryId?(0,X.jsx)(`code`,{children:e.entryId}):null,(0,X.jsx)(`span`,{children:e.message})]},`${e.pluginId??`host`}:${e.entryId??t}`))}),(0,X.jsx)(`div`,{className:`set-ui-diag-hint`,children:u(`uiLayoutDiagHint`)})]}),(0,X.jsx)(`input`,{className:`set-ui-filter`,value:zi,placeholder:u(`uiLayoutSearch`),"aria-label":u(`uiLayoutSearch`),onChange:e=>Bi(e.target.value)}),Fi.map(({slot:e,labelKey:t})=>{let n=(Br[e]??[]).filter(e=>(x||e.id!==`host:composer-dsh-perm`&&e.id!==`host:composer-dsh-preset`&&e.id!==`host:goal-plan`)&&!Pi.has(e.id)),r=zi.trim().toLowerCase(),i=!r&&Ii.includes(e)?[`start`,`center`,`end`].map(e=>({align:e,items:n.filter(t=>t.align===e)})).filter(e=>e.items.length>0):[{align:null,items:r?n.filter(e=>`${e.label} ${e.id} ${e.source}`.toLowerCase().includes(r)):n}],a=i.reduce((e,t)=>e+t.items.length,0);if(r&&a===0)return null;let o=(t,i)=>{let a=i.findIndex(e=>e.id===t.id),o=Ni.has(t.id);return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`label`,{className:`set-toggle`,title:o?u(`uiLayoutRequired`):t.id,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!t.hidden,disabled:o,onChange:()=>Gi(t)}),(0,X.jsxs)(`span`,{children:[t.icon?`${t.icon} `:``,t.label]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t.arrangedBy.length>0&&(0,X.jsx)(`span`,{className:`set-ui-source`,title:t.arrangedBy.join(`, `),children:u(`uiLayoutArranged`)}),t.movedFrom&&(0,X.jsxs)(`span`,{className:`set-ui-source`,title:t.id,children:[u(`uiLayoutMovedFrom`),`: `,Vi(t.movedFrom)]}),Ri.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:u(`uiLayoutPosition`),children:(0,X.jsxs)(`select`,{value:e,onChange:e=>Ji(t.id,e.target.value),"aria-label":u(`uiLayoutPosition`),children:[(0,X.jsx)(`option`,{value:`topbar.primary`,children:u(`uiLayoutPosTop`)}),(0,X.jsx)(`option`,{value:`bottombar`,children:u(`uiLayoutPosBottom`)}),(0,X.jsx)(`option`,{value:`sidebar.left`,children:u(`uiLayoutPosLeft`)}),(0,X.jsx)(`option`,{value:`sidebar.right`,children:u(`uiLayoutPosRight`)})]})}),Ii.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:u(`uiLayoutAlign`),children:(0,X.jsx)(`select`,{value:t.align,onChange:e=>qi(t.id,e.target.value),"aria-label":u(`uiLayoutAlign`),children:Li(e)?av.map(e=>(0,X.jsx)(`option`,{value:e,children:ov(u,e)},e)):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`option`,{value:`start`,children:`start`}),(0,X.jsx)(`option`,{value:`center`,children:`center`}),(0,X.jsx)(`option`,{value:`end`,children:`end`})]})})}),(0,X.jsx)(`input`,{className:`set-ui-label`,defaultValue:Ui?.labels?.[t.id]??``,placeholder:u(`uiLayoutRename`),title:u(`uiLayoutRename`),"aria-label":u(`uiLayoutRename`),onBlur:e=>{e.target.value!==(Ui?.labels?.[t.id]??``)&&Yi(t.id,e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.target.blur()}},`${t.id}:${Ui?.labels?.[t.id]??``}`),t.userOverrides.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Xi(t.id),children:u(`uiLayoutRestore`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<=0,onClick:()=>Ki(n,i,t.id,-1),children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<0||a>=i.length-1,onClick:()=>Ki(n,i,t.id,1),children:`↓`})]})]},t.id)};return(0,X.jsxs)(`div`,{className:`set-ui-slot`,children:[(0,X.jsx)(`div`,{className:`set-ui-slot-title`,children:u(t)}),e===`topbar.primary`&&(0,X.jsxs)(`label`,{className:`set-toggle`,title:`topbarText`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ui?.topbarText!==!1,onChange:e=>Wi({topbarText:e.target.checked})}),(0,X.jsx)(`span`,{children:u(`uiLayoutTopbarText`)})]}),n.length===0?(0,X.jsx)(`div`,{className:`set-empty`,children:u(`uiLayoutEmpty`)}):i.map(t=>(0,X.jsxs)(g.Fragment,{children:[t.align&&(0,X.jsx)(`div`,{className:`set-ui-slot-title set-ui-seg`,children:Li(e)?ov(u,t.align):t.align}),t.items.map(e=>o(e,t.items))]},t.align??`all`))]},e)})]}),S===`plugins`&&!b&&(0,X.jsxs)(`div`,{className:`set-subtabs`,role:`tablist`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":w===`market`,className:`set-subtab${w===`market`?` active`:``}`,onClick:()=>{T(`market`),E.current?.scrollTo({top:0})},children:[u(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":w===`installed`,className:`set-subtab${w===`installed`?` active`:``}`,onClick:()=>{T(`installed`),E.current?.scrollTo({top:0})},children:[(0,X.jsx)(ht,{}),u(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(ri||ii)&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]})]}),S===`plugins`&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Re,{className:`set-section-icon`}),u(`pluginGrantsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginGrants.reduce((e,t)=>e+t.paths.length,0)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:u(`pluginGrantsHint`)}),e.pluginGrants.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`pluginGrantsEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:e.pluginGrants.map(e=>(0,X.jsxs)(`div`,{className:`set-grant-row`,children:[(0,X.jsx)(`div`,{className:`set-catalog-title`,children:(0,X.jsx)(`span`,{children:e.pluginId})}),e.paths.map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_path_revoke`,pluginId:e.pluginId,path:t}),children:u(`pluginGrantsRevoke`)})]},t))]},e.pluginId))})]}),S===`plugins`&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ae,{className:`set-section-icon`}),u(`pluginPermsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:(e.pluginPermissions??[]).length})]}),(0,X.jsx)(`div`,{className:`set-note`,children:u(`pluginPermsHint`)}),(e.pluginPermissions??[]).length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`pluginPermsEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:(e.pluginPermissions??[]).map((e,t)=>(0,X.jsxs)(`div`,{className:`set-grant-row`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-title`,children:[(0,X.jsx)(`span`,{children:e.pluginId}),(0,X.jsxs)(`span`,{className:`set-catalog-source`,children:[e.family===`net`?u(`pluginPermNet`):u(`pluginPermLlm`),e.session?` · ${u(`pluginPermSession`)}`:``]})]}),(e.hosts??[]).map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:`net`,host:t}),children:u(`pluginGrantsRevoke`)})]},t)),(e.models??[]).map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:`llm`,model:t}),children:u(`pluginGrantsRevoke`)})]},t)),!(e.hosts??[]).length&&!(e.models??[]).length&&(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:e.reason??u(`pluginPermUnscoped`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:e.family}),children:u(`pluginGrantsRevoke`)})]}),e.reason&&((e.hosts??[]).length>0||(e.models??[]).length>0)&&(0,X.jsx)(`div`,{className:`set-note`,children:e.reason})]},`${e.pluginId}|${e.family}|${t}`))})]}),S===`plugins`&&b&&(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-note`,children:u(`updatesManaged`)})}),S===`plugins`&&!b&&w===`market`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(q,{className:`set-section-icon`}),u(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`div`,{className:`set-toolbar`,children:[(0,X.jsxs)(`a`,{href:`https://github.com/xing-shuyin/pi-web-ui-plugins`,target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialMarketHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialMarket`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:u(`pluginBuildHint`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Zn,onChange:e=>Qn(e.target.checked)}),u(`pluginBuildSource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCatalogSyncHint`),onClick:()=>er(e=>!e),children:[(0,X.jsx)(K,{}),u(`pluginCatalogSync`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCatalogAddHint`),onClick:()=>Xn(e=>!e),children:[(0,X.jsx)(me,{}),u(`pluginCatalogAdd`)]})]}),$n&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`div`,{className:`set-note`,children:u(`pluginCatalogSyncHint`)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogSyncSource`),value:tr,onChange:e=>nr(e.target.value),onKeyDown:e=>{e.key===`Enter`&&oa(tr)}}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:u(`pluginCatalogSyncInstall`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:rr,onChange:e=>ir(e.target.checked)}),u(`pluginCatalogSyncInstall`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:u(`pluginCatalogSyncReplace`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:ar,onChange:e=>or(e.target.checked)}),u(`pluginCatalogSyncReplace`)]}),dr.length>0&&(0,X.jsxs)(`div`,{className:`set-catalog-recent`,children:[(0,X.jsx)(`span`,{className:`set-catalog-recent-label`,children:u(`pluginCatalogSyncRecent`)}),dr.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-catalog-recent-item`,title:e,onClick:()=>{nr(e),oa(e)},children:e},e))]}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!tr.trim(),onClick:()=>oa(tr),children:u(`pluginCatalogSyncSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>er(!1),children:u(`cancel`)})]}),da&&(da.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[(0,X.jsxs)(`span`,{children:[`✓ `,u(`pluginCatalogSyncOk`,{n:da.entryCount??0}),da.installed?` · ${u(`pluginCatalogSyncInstalled`,{ok:da.installed.filter(e=>e.ok).length,fail:da.installed.filter(e=>!e.ok).length})}`:null]}),da.installed?.some(e=>!e.ok)&&(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:da.installed.filter(e=>!e.ok).map(e=>`${e.id}:${e.error??`?`}`).join(`
677
- `)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,da.error||u(`pluginJobFailed`)]})}))]}),Yn&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogSource`),value:zn,onChange:e=>Bn(e.target.value)}),ji(ua),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogId`),value:Vn,onChange:e=>Hn(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogName`),value:Un,onChange:e=>Wn(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogIcon`),value:qn,onChange:e=>Jn(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:u(`pluginCatalogDesc`),value:Gn,onChange:e=>Kn(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!zn.trim(),onClick:aa,children:u(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Xn(!1),children:u(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(t=>{let n=mi.has(t.id),r=e.pluginUpdates?.[t.id],i=n&&r?.updatable===!0,a=!!(Ai(t.id)&&Ai(t.id)?.phase!==`done`),o=d!==`zh`&&t.nameEn?t.nameEn:t.name,s=d!==`zh`&&t.descriptionEn?t.descriptionEn:t.description;return(0,X.jsxs)(`div`,{className:`set-catalog-row`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-main`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-title`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(hi,{icon:t.icon,iconSvg:t.iconSvg}),` `,o]}),n&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:u(`pluginInstalled`)}),!t.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:u(`pluginCatalogCustom`)}),i&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:r?.latestVersion?`${r?.version??``} → v${r.latestVersion}`:r?.remoteSha??``,children:[u(`pluginUpdateAvailableBadge`),r?.latestVersion?` v${r.latestVersion}`:``]})]}),s&&(0,X.jsx)(`div`,{className:`set-catalog-desc`,children:s}),(0,X.jsx)(`div`,{className:`set-catalog-source`,children:t.source}),Mi(t.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[vx(t)&&(0,X.jsxs)(`a`,{href:vx(t),target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialLinkHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialLink`)]}),n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${i?` accent`:``}`,disabled:a,title:i&&r?.latestVersion?u(`pluginUpdateAvailableDetail`,{version:`v${r.latestVersion}`}):u(`pluginUpdateHint`),onClick:()=>ea(t.id,t.source),children:[(0,X.jsx)(K,{className:a?`set-job-spin`:``}),u(a?`pluginJobRunning`:`pluginUpdate`)]}),Dn===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:a,title:u(`pluginUninstallHint`),onClick:()=>Qi(t.id),children:u(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:a,title:u(`pluginUninstallHint`),onClick:()=>On(t.id),children:[(0,X.jsx)(R,{}),u(`uninstallExt`)]})]}):(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginInstallHint`),disabled:a,onClick:()=>ta(t),children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{className:`set-job-spin`}),u(`pluginJobRunning`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{}),u(`pluginInstall`)]})}),!t.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCatalogRemoveHint`),onClick:()=>na(t.id),children:(0,X.jsx)(P,{})})]})]},t.id)})})]}),S===`plugins`&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ht,{className:`set-section-icon`}),u(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`a`,{href:`https://github.com/xing-shuyin/pi-web-ui-plugins`,target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialMarketHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialMarket`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCheckUpdatesHint`),disabled:e.checkingPluginUpdates,onClick:()=>$({type:`check_plugin_updates`}),children:[(0,X.jsx)(K,{className:e.checkingPluginUpdates?`spin`:``}),e.checkingPluginUpdates?u(`checkingUpdate`):u(`pluginCheckUpdates`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(K,{}),u(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(yx,{plugins:e.plugins,disabledIds:pi}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noUiPlugins`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.plugins.map(t=>{let n=e.pluginUpdates?.[t.id],r=n?.updatable===!0,i=!!(Ai(t.id)&&Ai(t.id)?.phase!==`done`);return(0,X.jsxs)(g.Fragment,{children:[(0,X.jsx)(mx,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_x,{phase:$b(t,pi.has(t.id)),label:f(gx($b(t,pi.has(t.id))))}),(0,X.jsx)(hi,{icon:t.icon,iconSvg:t.iconSvg}),` `,t.name,r&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:n?.latestVersion?`v${t.version??`0.0.0`} → v${n.latestVersion}`:n?.remoteSha??``,children:[u(`pluginUpdateAvailableBadge`),n?.latestVersion?` v${n.latestVersion}`:``]})]}),subtitle:(t.error?`${t.id} · ${t.error}`:t.source?`${t.id} · ${t.source}`:`${t.id} · ${u(`uiPluginNoSource`)}`)+(t.permissions?.length?` · ${u(`uiPluginPerms`)}: ${t.permissions.join(`, `)}`:``),enabled:!pi.has(t.id)&&!t.error,onToggle:()=>!t.error&&gi(t),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(()=>{let n=vx(e.pluginCatalog.find(e=>e.id===t.id))||vx(t);return n?(0,X.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialLinkHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialLink`)]}):null})(),t.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${r?` accent`:``}`,disabled:i,title:r&&n?.latestVersion?u(`pluginUpdateAvailableDetail`,{version:`v${n.latestVersion}`}):u(`pluginUpdateHint`),onClick:()=>ea(t.id,t.source),children:[(0,X.jsx)(K,{className:i?`set-job-spin`:``}),u(i?`pluginJobRunning`:`pluginUpdate`)]}),Dn===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:i,title:u(`pluginUninstallHint`),onClick:()=>Qi(t.id),children:u(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:i,title:u(`pluginUninstallHint`),onClick:()=>On(t.id),children:[(0,X.jsx)(R,{}),u(`uninstallExt`)]})]})},t.id),Mi(t.id),t.agentTools&&t.agentTools.length>0&&!x&&(0,X.jsxs)(`div`,{className:`set-row`,title:u(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[u(`pluginToolsSection`),` (`,t.agentTools.length,`)`,t.agentTools.some(e=>xi.has(e.name))?` · ${u(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>C(`tools`),children:[u(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{jn===t.id?Mn(null):(Mn(t.id),$(qc(t.id)))},children:[(0,X.jsx)(Ve,{}),u(`pluginLogTitle`),` (`,el(t.id).length,`) ·`,` `,jn===t.id?u(`pluginLogHide`):u(`pluginLogShow`)]}),jn===t.id&&(0,X.jsx)(Sx,{pluginId:t.id})]}),t.diagnostics&&t.diagnostics.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-diag-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>An(kn===t.id?null:t.id),children:[(0,X.jsx)(wt,{}),u(`pluginDiagTitle`),` (`,t.diagnostics.length,`) ·`,` `,kn===t.id?u(`pluginDiagHide`):u(`pluginDiagShow`)]}),kn===t.id&&(0,X.jsx)(`ul`,{className:`set-diag-list`,children:t.diagnostics.map((e,n)=>(0,X.jsx)(`li`,{children:e},`${t.id}-${n}`))})]}),t.wantsDom&&(0,X.jsxs)(`div`,{className:`set-row`,title:u(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:t.domGranted?u(`pluginDomGranted`):u(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${t.domGranted?``:` confirm`}`,title:u(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:t.id,granted:!t.domGranted}),children:t.domGranted?u(`pluginDomRevoke`):u(`pluginDomGrant`)})})]}),t.settingsSchema&&t.settingsSchema.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-settings-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>In(e=>({...e,[t.id]:!e[t.id]})),children:[(0,X.jsx)(ae,{}),u(`pluginSettingsTitle`),` (`,t.settingsSchema.length,`) ·`,` `,Pn[t.id]?u(`pluginSettingsHide`):u(`pluginSettingsShow`)]}),Pn[t.id]&&(0,X.jsx)(Oy,{plugin:t,models:_?.subagentModels??[]})]})]},t.id)})})]}),S===`plugins`&&x&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ht,{className:`set-section-icon`}),u(`dshPatches`),(0,X.jsx)(mu,{text:u(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(K,{}),u(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`dshPatchesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:e.dshPatches.files.map(e=>(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsx)(`div`,{className:`set-row-name`,children:e.name}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[rm(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[u(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),S===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(N,{className:`set-section-icon`}),u(`settingsReview`),(0,X.jsx)(mu,{text:u(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.reviewSkills.length})]}),(0,X.jsx)(mx,{title:u(`goalModeEnabled`),tip:`${u(`goalModeEnabledDesc`)}\n${u(`goalModeOffHint`)}`,enabled:_.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!_.goalModeEnabled})}),(0,X.jsx)(mx,{title:u(`delegateMode`),tip:`${u(`delegateModeDesc`)}\n${u(`delegateModeOffHint`)}`,enabled:e.state?.delegateMode===!0,onToggle:()=>$({type:`set_delegate_mode`,enabled:e.state?.delegateMode!==!0})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,placeholder:u(`reviewPromptPlaceholder`),value:mt,onFocus:()=>_t.current=!0,onBlur:()=>{_t.current=!1,Q({reviewPrompt:mt})},onChange:e=>gt(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`settingsReviewSkills`),x&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(mu,{text:u(`dshReviewPromptNote`)})]})]}),_.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.reviewSkills.map(e=>(0,X.jsx)(mx,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>fa(e)},`review-${e.name}`))})]}),S===`vision`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ue,{className:`set-section-icon`}),u(`settingsVisionBridge`)]}),(0,X.jsx)(mx,{title:u(`visionBridgeEnabled`),tip:`${u(`settingsVisionBridgeDesc`)}\n${u(`visionBridgeOffHint`)}`,enabled:_.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!_.visionBridgeEnabled})}),_.visionBridgeEnabled&&(0,X.jsx)(bx,{label:u(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:_.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:u(`visionBridgeAuto`)}),_.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),_.visionBridgeEnabled&&(0,X.jsx)(xx,{mode:Xe,onModeChange:Qe,draft:Je,onDraftChange:Ye,defaultPrompt:_.visionBridgeDefaultPrompt,placeholder:u(`visionBridgePromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({visionBridgePromptMode:e,visionBridgePrompt:t})},hint:_.visionModels.length===0?u(`visionBridgeNoModels`):u(`visionBridgeCurrent`,{model:_.visionBridgeModel??u(`visionBridgeAuto`)}),focusRef:$e})]}),S===`presets`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ae,{className:`set-section-icon`}),u(`settingsPresets`),(0,X.jsx)(mu,{text:u(`dshPresetUserNote`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-share-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn primary`,title:u(`presetShareShareBtn`),onClick:()=>xt({name:_.presets[0]?.name??``,tab:`export`}),children:[(0,X.jsx)(W,{}),u(`presetShareShareBtn`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn`,title:u(`presetShareImportBtn`),onClick:()=>xt({name:``,tab:`import`}),children:[(0,X.jsx)(re,{}),u(`presetShareImportBtn`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn`,title:u(`presetShareBrowseBtn`),onClick:()=>xt({name:``,tab:`browse`}),children:[(0,X.jsx)(Fe,{}),u(`presetShareBrowseBtn`)]})]}),ti&&(0,X.jsxs)(`div`,{className:`set-preset-config`,children:[e.dshPresets&&e.dshPresets.presets.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`dshDefaultPreset`),(0,X.jsx)(mu,{text:u(`dshDefaultPresetDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:z_(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[R_(e,d,u).name,e.trust===`user`?` · ${u(`dshPresetUser`)}`:``,e.broken?` · ${u(`dshPresetBroken`)}`:``]},e.id))})]}),$r&&(0,X.jsx)(`p`,{className:`set-preset-config-desc`,children:$r})]}),e.dshPermission&&e.dshPermission.options.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`dshPermDefault`),(0,X.jsx)(mu,{text:u(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:H_.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:u(U_(e))},e))})]}),(0,X.jsx)(`p`,{className:`set-preset-config-desc`,children:u(W_(e.dshPermission.defaultPreset))})]})]}),ei&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`dshPresetUserNote`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`presetNamePlaceholder`),value:vt,onChange:e=>yt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&vt.trim()&&($({type:`save_preset`,name:vt.trim()}),yt(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!vt.trim(),onClick:()=>{$({type:`save_preset`,name:vt.trim()}),yt(``)},children:[(0,X.jsx)(me,{}),` `,u(`saveAsPreset`)]})]}),_.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.presets.map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsx)(`div`,{className:`set-row-name`,children:e.name}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[e.promptMode===`replace`?u(`promptModeReplace`):u(`promptModeAppend`),e.disabledSkills.length>0&&` · ${u(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${u(`settingsExtensions`)} ${e.disabledExtensions.length}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`presetShare`),onClick:()=>xt({name:e.name,tab:`export`}),children:(0,X.jsx)(W,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`apply_preset`,name:e.name}),children:u(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),S===`mcp`&&(0,X.jsx)(Ly,{settings:_,chat:e}),S===`subagent-templates`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(F,{className:`set-section-icon`}),u(`settingsSubagentTemplates`),(0,X.jsx)(mu,{text:u(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:u(`subagentTemplateNew`),onClick:()=>{Tt({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),Dt(!0)},children:[(0,X.jsx)(me,{}),` `,u(`subagentTemplateNew`)]})]}),(0,X.jsx)(bx,{label:u(`subagentDefaultModelLabel`),tip:u(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:_.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:u(`subagentFollowMain`)}),_.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),_.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`subagentNoModels`)}),Ct&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>Tt(null),children:(0,X.jsxs)(`div`,{className:`modal tpl-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":u(`close`),onClick:()=>Tt(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(F,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:Et?u(`subagentTemplateNew`):`${u(`subagentTemplateEdit`)} · ${Ct.name}`})]}),(0,X.jsxs)(`div`,{className:`modal-body`,children:[(0,X.jsxs)(`div`,{className:`tpl-fields`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplNamePlaceholder`),value:Ct.name,onChange:e=>Tt({...Ct,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplDescriptionPlaceholder`),value:Ct.description,onChange:e=>Tt({...Ct,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplDescriptionEnPlaceholder`),value:Ct.descriptionEn??``,onChange:e=>Tt({...Ct,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.promptMode,onChange:e=>Tt({...Ct,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:u(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:u(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.model??``,onChange:e=>Tt({...Ct,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:u(`subagentFollowMain`)}),_.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`tplThinkingLabel`),` `,(0,X.jsx)(mu,{text:u(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.thinkingLevel??``,onChange:e=>Tt({...Ct,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:u(`tplThinkingFollowMain`)}),j_.map(e=>(0,X.jsx)(`option`,{value:e,children:u(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${u(`tplSystemPromptLabel`)}${d===`zh`?`:`:`: `}${u(`tplSystemPromptPlaceholder`)}`,value:Ct.systemPrompt,onChange:e=>Tt({...Ct,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${u(`tplSystemPromptLabel`)}: ${u(`tplSystemPromptEnPlaceholder`)}`,value:Ct.systemPromptEn??``,onChange:e=>Tt({...Ct,systemPromptEn:e.target.value})}),(0,X.jsxs)(`div`,{className:`tpl-pick-block`,children:[(0,X.jsx)(`div`,{className:`tpl-pick-head`,children:(0,X.jsxs)(`span`,{children:[u(`tplSkillsLabel`),` · `,u(`tplWhitelistHint`)]})}),_.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:_.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${Ct.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ct.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;Tt({...Ct,enabledSkills:n?[...Ct.enabledSkills,e.name]:Ct.enabledSkills.filter(t=>t!==e.name)})}}),e.name]},e.name))})]}),(0,X.jsxs)(`div`,{className:`tpl-pick-block`,children:[(0,X.jsx)(`div`,{className:`tpl-pick-head`,children:(0,X.jsxs)(`span`,{children:[u(`tplExtensionsLabel`),` · `,u(`tplWhitelistHint`)]})}),_.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:_.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${Ct.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ct.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;Tt({...Ct,enabledExtensions:n?[...Ct.enabledExtensions,e.id]:Ct.enabledExtensions.filter(t=>t!==e.id)})}}),e.name]},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Ct.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...Ct,name:Ct.name.trim()}}),Tt(null)},children:u(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>Tt(null),children:u(`tplCancel`)})]})]})}),_.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:_.subagentTemplates.map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[e.name,_.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:u(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:u(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(d!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?u(`promptModeReplace`):u(`promptModeAppend`)}`,e.model?` · ${u(`tplModelLabel`)} ${e.model}`:` · ${u(`subagentFollowMain`)}`,e.thinkingLevel?` · ${u(`tplThinkingLabel`)} ${f(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${u(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${u(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${u(`tplInherit`)}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-switch${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,title:`${e.enabled?u(`subagentTemplateDisable`):u(`subagentTemplateEnable`)} · ${u(`subagentTemplateOffHint`)}`,onClick:()=>$({type:`save_subagent_template`,template:{...e,enabled:!e.enabled}}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`subagentTemplateEdit`),onClick:()=>{Tt({...e}),Dt(!1)},children:u(`subagentTemplateEdit`)}),Ot===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:u(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),kt(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`tplDelete`),onClick:()=>kt(e.name),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),S===`approval-rules`&&!x&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(se,{className:`set-section-icon`}),u(`settingsApprovalRules`),(0,X.jsx)(mu,{text:u(`settingsApprovalRulesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.approvalRules?.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:u(`approvalRuleNew`),onClick:()=>{Mt({id:`custom.${jt().slice(0,8)}`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:``,action:`ask`,label:``,labelEn:``,reason:``,reasonEn:``}),It(`bash`),Pt(!0),Rt(null)},children:[(0,X.jsx)(me,{}),` `,u(`approvalRuleNew`)]})]}),At&&(0,X.jsxs)(`div`,{className:`rule-editor`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,style:{fontSize:13,marginBottom:4},children:Nt?u(`approvalRuleNew`):`${u(`approvalRuleEdit`)} · ${At.label}`}),(0,X.jsx)(bx,{label:u(`approvalRuleLabel`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.label,placeholder:`例如:拦截 Docker 危险操作`,onChange:e=>Mt({...At,label:e.target.value})})}),(0,X.jsx)(bx,{label:u(`approvalRuleLabelEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.labelEn??``,placeholder:`e.g. Block dangerous Docker commands`,onChange:e=>Mt({...At,labelEn:e.target.value})})}),(0,X.jsx)(bx,{label:u(`approvalRuleTools`),tip:u(`approvalRuleToolsTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Ft,placeholder:`bash, write, edit (或 * 通配)`,onChange:e=>{It(e.target.value);let t=e.target.value.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);Mt({...At,tools:t.length>0?t:[`*`]})}})}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:10,flexWrap:`wrap`},children:[(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(bx,{label:u(`approvalRuleField`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.field,onChange:e=>Mt({...At,field:e.target.value}),children:[(0,X.jsx)(`option`,{value:`command`,children:u(`approvalRuleFieldCommand`)}),(0,X.jsx)(`option`,{value:`path`,children:u(`approvalRuleFieldPath`)}),(0,X.jsx)(`option`,{value:`params`,children:u(`approvalRuleFieldParams`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(bx,{label:u(`approvalRuleMatch`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.match,onChange:e=>Mt({...At,match:e.target.value}),children:[(0,X.jsx)(`option`,{value:`regex`,children:u(`approvalRuleMatchRegex`)}),(0,X.jsx)(`option`,{value:`glob`,children:u(`approvalRuleMatchGlob`)}),(0,X.jsx)(`option`,{value:`contains`,children:u(`approvalRuleMatchContains`)}),(0,X.jsx)(`option`,{value:`prefix`,children:u(`approvalRuleMatchPrefix`)}),(0,X.jsx)(`option`,{value:`outside_workspace`,children:u(`approvalRuleMatchOutsideWs`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(bx,{label:`命中动作`,children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.action,onChange:e=>Mt({...At,action:e.target.value}),children:[(0,X.jsx)(`option`,{value:`ask`,children:u(`approvalRuleActionAsk`)}),(0,X.jsx)(`option`,{value:`deny`,children:u(`approvalRuleActionDeny`)}),(0,X.jsx)(`option`,{value:`allow`,children:u(`approvalRuleActionAllow`)})]})})})]}),At.match!==`outside_workspace`&&(0,X.jsx)(bx,{label:u(`approvalRuleValue`),tip:u(`approvalRuleValueTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.value,placeholder:`匹配表达式或关键字…`,onChange:e=>Mt({...At,value:e.target.value})})}),(0,X.jsx)(bx,{label:u(`approvalRuleReason`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.reason??``,placeholder:`例如:检测到删除镜像或容器操作`,onChange:e=>Mt({...At,reason:e.target.value})})}),(0,X.jsx)(bx,{label:u(`approvalRuleReasonEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.reasonEn??``,placeholder:`e.g. Detected docker image/container removal`,onChange:e=>Mt({...At,reasonEn:e.target.value})})}),(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`label`,{className:`set-checkbox-label`,style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:At.enabled,onChange:e=>Mt({...At,enabled:e.target.checked})}),u(`approvalRuleEnabled`)]})}),Lt&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12},children:Lt}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:4},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Mt(null),Rt(null)},children:u(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{if(!At.label.trim()){Rt(`请填写规则名称`);return}if(At.match===`regex`)try{new RegExp(At.value)}catch(e){Rt(`正则表达式非法:${e.message}`);return}$({type:`save_approval_rule`,rule:At}),Mt(null),Rt(null)},children:u(`save`)})]})]}),(_.approvalRules??[]).length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`approvalRuleEmpty`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:(_.approvalRules??[]).map((e,t)=>{let n=e.builtin===!0;return(0,X.jsxs)(`div`,{className:`set-row${e.enabled?``:` rule-row-disabled`}`,style:{alignItems:`flex-start`,padding:`12px 0`},children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,style:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:6},children:[(0,X.jsx)(`span`,{className:`rule-badge ${e.action}`,children:e.action===`deny`?u(`approvalRuleActionDeny`):e.action===`allow`?u(`approvalRuleActionAllow`):u(`approvalRuleActionAsk`)}),(0,X.jsx)(`strong`,{style:{fontSize:13},children:d===`zh`?e.label:e.labelEn||e.label}),n&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:u(`approvalRuleBuiltin`)}),(0,X.jsx)(`span`,{className:`rule-meta-code`,children:e.tools.join(`, `)})]}),(0,X.jsxs)(`div`,{className:`set-hint`,style:{marginTop:6,display:`flex`,flexDirection:`column`,gap:3},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6,flexWrap:`wrap`},children:[(0,X.jsxs)(`span`,{style:{opacity:.85,fontSize:11,fontFamily:`var(--mono)`},children:[`[`,e.field,` · `,e.match,`]`]}),e.match!==`outside_workspace`&&(0,X.jsx)(`code`,{className:`rule-pattern-code`,children:e.value})]}),(e.reason||e.reasonEn)&&(0,X.jsx)(`div`,{style:{opacity:.75,fontSize:11},children:d===`zh`?e.reason:e.reasonEn||e.reason})]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,style:{marginLeft:12,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`set-switch${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,title:e.enabled?u(`settingsEnabled`):u(`settingsDisabled`),onClick:()=>$({type:`save_approval_rule`,rule:{...e,enabled:!e.enabled}}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),!n&&t>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleMoveUp`),onClick:()=>{let e=[..._.approvalRules??[]],n=e[t-1];e[t-1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(ct,{})}),!n&&t<(_.approvalRules?.length??0)-1&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleMoveDown`),onClick:()=>{let e=[..._.approvalRules??[]],n=e[t+1];e[t+1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(dt,{})}),n&&(Ht===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`reset_builtin_approval_rule`,id:e.id}),Ut(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleReset`),onClick:()=>Ut(e.id),children:(0,X.jsx)(K,{})})),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleEdit`),onClick:()=>{Mt({...e}),It(e.tools.join(`, `)),Pt(!1),Rt(null)},children:(0,X.jsx)(Y,{})}),!n&&(Bt===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`delete_approval_rule`,id:e.id}),Vt(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`approvalRuleDelete`),onClick:()=>Vt(e.id),children:(0,X.jsx)(R,{})}))]})]},e.id)})})]}),oi&&(0,X.jsx)(Tu,{plugin:oi.plugin,epoch:e.pluginsEpoch,send:$,className:`set-plugin-page`}),Jt&&(0,X.jsx)(Py,{name:Jt,override:Xt[Jt]??null,onApply:$t,onClose:()=>Yt(null)})]})]}),(0,X.jsx)(`div`,{className:`modal-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:xa,children:u(`close`)})})]}),bt!==null&&(0,X.jsx)(Qb,{presets:_.presets.map(e=>e.name),presetExport:e.presetExport,presetImport:e.presetImport,presetCatalog:e.presetCatalog,presetShare:e.presetShare,initialPreset:bt.name,initialTab:bt.tab,onClose:()=>xt(null)})]})}function Ex(e,t){let n=Math.max(0,Date.now()-e),r=Math.floor(n/6e4);if(r<1)return t(`bgTaskJustNow`);if(r<60)return t(`bgTaskMinutes`,{n:r});let i=Math.floor(r/60);return i<24?t(`bgTaskHours`,{n:i}):t(`bgTaskDays`,{n:Math.floor(i/24)})}function Dx({servers:e,onClose:t,plugins:n=[],epoch:r=0,send:i,onUiAction:a,autoCleanupMin:o=0}){let s=Z(),{locale:c}=Nn(),[l,u]=(0,g.useState)(new Set),d=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});(0,g.useEffect)(()=>{$({type:`list_bg_servers`})},[]);let f=(0,g.useMemo)(()=>($i(Hi(n),{locale:c,t:e=>s(e)})[`tasks.panel`]??[]).filter(e=>!e.hidden&&e.source!==`host`&&e.kind!==`divider`),[n,c,s]);return(0,X.jsxs)(Ny,{className:`bg-task-modal`,onClose:t,showCloseButton:!1,children:[(0,X.jsxs)(`div`,{className:`bg-task-head`,children:[(0,X.jsxs)(`span`,{className:`bg-task-title`,children:[(0,X.jsx)(ke,{}),` `,s(`bgTasks`),e.length>0&&(0,X.jsx)(`em`,{className:`bg-task-count`,children:e.length})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:s(`close`),onClick:t,children:(0,X.jsx)(P,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{children:s(`bgTasksEmpty`)}),(0,X.jsx)(`small`,{children:s(`bgTasksDesc`)})]}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:e.map(e=>{let t=!!e.taskId,n=e.taskId??String(e.port);return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsx)(`span`,{className:`bg-task-icon`,title:t?e.plugin:s(`bgTaskPort`)}),(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[t?(0,X.jsxs)(`span`,{className:`bg-task-port`,title:e.taskId,children:[`🧩 `,e.plugin]}):(0,X.jsxs)(`span`,{className:`bg-task-port`,children:[`:`,e.port]}),e.name&&(0,X.jsx)(`span`,{className:`bg-task-name`,children:e.name})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[!t&&(0,X.jsxs)(`span`,{children:[s(`bgTaskPid`),` `,e.pid]}),(0,X.jsxs)(`span`,{children:[s(`bgTaskSince`),` `,Ex(e.since,s)]}),t&&e.status&&(0,X.jsx)(`span`,{className:`bg-task-status`,children:e.status})]}),e.command&&(0,X.jsxs)(`button`,{type:`button`,className:`bg-task-cmd ${l.has(n)?`open`:``}`,title:`${s(`bgTaskCommand`)}: ${e.command}`,onClick:()=>d(n),children:[(0,X.jsx)(B,{}),(0,X.jsx)(`code`,{children:e.command})]})]}),!t&&(0,X.jsx)(`button`,{type:`button`,className:`btn bg-task-keep`,title:e.keep?s(`bgTaskKeepOn`):s(`bgTaskKeep`),"aria-pressed":!!e.keep,onClick:()=>$({type:`set_bg_keep`,port:e.port??0,keep:!e.keep}),children:e.keep?`📌`:`📍`}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,title:s(`bgTaskStop`),onClick:()=>$(t?{type:`kill_background_server`,taskId:e.taskId}:{type:`kill_background_server`,port:e.port}),children:[(0,X.jsx)(U,{}),(0,X.jsx)(`span`,{children:s(`bgTaskStop`)})]})]},n)})}),f.map(e=>{let t=n.find(t=>t.id===e.source.slice(7));return e.kind===`view`?t?(0,X.jsx)(`div`,{children:(0,X.jsx)(Tu,{plugin:t,epoch:r,send:i??(()=>{})})},e.id):null:(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e.hint??e.label,onClick:()=>a?.(e),children:e.label},e.id)}),(0,X.jsxs)(`div`,{className:`bg-task-foot`,children:[(0,X.jsxs)(`label`,{className:`bg-task-cleanup`,title:s(`bgTaskCleanupHint`),children:[(0,X.jsx)(`span`,{children:s(`bgTaskCleanup`)}),(0,X.jsxs)(`select`,{className:`btn`,value:String(o),onChange:e=>$({type:`set_settings`,bgAutoCleanupMin:Number(e.target.value)}),children:[(0,X.jsx)(`option`,{value:`0`,children:s(`bgTaskCleanupOff`)}),[15,30,60,120].map(e=>(0,X.jsx)(`option`,{value:String(e),children:s(`bgTaskCleanupMinutes`,{n:e})},e))]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:s(`bgTaskCleanNowHint`),onClick:()=>$({type:`clean_bg_leftovers`}),children:[(0,X.jsx)(R,{}),(0,X.jsx)(`span`,{children:s(`bgTaskCleanNow`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:s(`bgTaskRefresh`),onClick:()=>$({type:`list_bg_servers`}),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:s(`bgTaskRefresh`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stopall`,disabled:e.length===0,title:s(`bgTaskStopAll`),onClick:()=>$({type:`kill_background_servers`}),children:[(0,X.jsx)(U,{}),(0,X.jsx)(`span`,{children:s(`bgTaskStopAll`)})]})]})]})}function Ox(){let e=Z(),t=Em(),[n,r]=(0,g.useState)(!0),i=(0,g.useRef)(null);return(0,g.useEffect)(()=>{t&&r(!0)},[t]),zt(()=>{t&&wm()},!!t),(0,g.useEffect)(()=>{if(!t)return;let e=e=>{if(e.key!==`Enter`||e.shiftKey||e.ctrlKey||e.metaKey)return;let t=e.target;(!t||t===document.body||i.current?.contains(t))&&(e.preventDefault(),Tm(n))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,n]),t?(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:wm,children:(0,X.jsxs)(`div`,{ref:i,className:`tool-info-modal rollback-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`rollbackSession`),onClick:e=>e.stopPropagation(),style:{maxWidth:520},children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(wt,{}),e(`rollbackSession`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`cancel`),onClick:wm,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 16px 0`,fontSize:14,lineHeight:1.6},children:e(`rollbackConfirm`)}),(0,X.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`12px 14px`,borderRadius:8,backgroundColor:`var(--bg-elev, rgba(255, 255, 255, 0.04))`,border:`1px solid var(--border-subtle, rgba(255, 255, 255, 0.1))`,cursor:`pointer`,marginBottom:20},title:e(`rollbackRestoreWorkspaceTip`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),style:{marginTop:3,cursor:`pointer`}}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text, #e2e8f0)`},children:e(`rollbackRestoreWorkspace`)}),(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2},children:e(`rollbackRestoreWorkspaceTip`)})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:wm,children:e(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>Tm(n),children:[(0,X.jsx)(ft,{}),e(`confirm`)]})]})]})]})}),document.body):null}function kx({approval:e}){let t=Z(),{locale:n}=Nn(),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(null);if((0,g.useEffect)(()=>{if(e){let t=e.params;i(typeof t==`object`&&t?JSON.stringify(t,null,2):t==null?`{}`:String(t)),o(null)}},[e]),!e)return null;let s=t=>{$({type:`tool_approval_response`,id:e.id,decision:`approve`,...t&&t!==`once`?{scope:t}:{}})},c=()=>{$({type:`tool_approval_response`,id:e.id,decision:`deny`,reason:`Operation rejected by user`})};return(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`tool-info-modal approval-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`toolApprovalTitle`),style:{maxWidth:640,borderTop:`4px solid var(--amber, #f59e0b)`},onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(wt,{}),t(`toolApprovalTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,style:{fontWeight:700},children:e.toolName}),e.parentTool===`codemode`&&(0,X.jsxs)(`span`,{className:`tool-info-label`,style:{backgroundColor:`rgba(245, 158, 11, 0.15)`,color:`var(--amber, #f59e0b)`,border:`1px solid rgba(245, 158, 11, 0.35)`,fontWeight:600},children:[`⚡ `,t(`codemodeNestedApprovalBadge`)]}),e.conversationTitle&&(0,X.jsx)(`span`,{className:`tool-info-label`,children:e.conversationTitle}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalDeny`),onClick:c,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[e.parentTool===`codemode`&&(0,X.jsxs)(`div`,{style:{padding:`8px 12px`,borderRadius:6,backgroundColor:`rgba(99, 102, 241, 0.12)`,border:`1px solid rgba(99, 102, 241, 0.25)`,marginBottom:12,color:`var(--text, #e2e8f0)`,fontSize:12.5,display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`span`,{style:{fontSize:14},children:`⚡`}),(0,X.jsx)(`span`,{children:t(`codemodeNestedApprovalDesc`)})]}),(e.reason||e.reasonEn)&&(0,X.jsxs)(`div`,{style:{padding:`10px 14px`,borderRadius:6,backgroundColor:`rgba(245, 158, 11, 0.12)`,border:`1px solid rgba(245, 158, 11, 0.3)`,marginBottom:16,color:`var(--amber, #f59e0b)`,fontSize:13,lineHeight:1.5,fontWeight:500},children:[(0,X.jsxs)(`div`,{style:{fontWeight:600,marginBottom:2},children:[t(`toolApprovalRiskAlert`),`:`]}),(0,X.jsx)(`div`,{children:n===`zh`?e.reason||e.reasonEn:e.reasonEn||e.reason}),e.category&&(0,X.jsxs)(`div`,{style:{marginTop:6,fontSize:12,opacity:.85},children:[t(`toolApprovalCategory`),`:`,n===`zh`?e.category.label:e.category.labelEn]}),e.hits&&e.hits.length>0&&(0,X.jsxs)(`div`,{className:`approval-hits-panel`,children:[(0,X.jsxs)(`div`,{className:`approval-hits-title`,children:[t(`toolApprovalHitsTitle`),` (`,e.hits.length,`)`]}),(0,X.jsx)(`div`,{className:`approval-hits-list`,children:e.hits.map((e,r)=>(0,X.jsxs)(`div`,{className:`approval-hit-item`,children:[(0,X.jsxs)(`div`,{className:`approval-hit-header`,children:[(0,X.jsx)(`span`,{className:`approval-hit-badge`,children:n===`zh`?e.label:e.labelEn||e.label}),(0,X.jsx)(`span`,{className:`approval-hit-field`,children:e.field}),(0,X.jsx)(`span`,{className:`approval-hit-pos`,children:t(`approvalHitPos`,{index:e.index+1,length:e.length})})]}),(0,X.jsx)(`div`,{className:`approval-hit-text`,children:(0,X.jsx)(`mark`,{className:`approval-danger-hit`,children:e.text})})]},r))})]})]}),e.toolName===`bash`&&typeof e.params?.command==`string`&&(0,X.jsxs)(`div`,{className:`approval-cmd-preview`,children:[(0,X.jsxs)(`div`,{className:`approval-cmd-preview-label`,children:[t(`approvalCommandPreview`),`:`]}),(0,X.jsxs)(`div`,{className:`approval-cmd-preview-box`,children:[(0,X.jsx)(`span`,{className:`bashblock-prompt`,children:`$`}),(0,X.jsx)(`code`,{children:td(e.params.command,e.hits)})]})]}),(0,X.jsxs)(`div`,{style:{marginBottom:16},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:6},children:[(0,X.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text, #e2e8f0)`},children:t(`toolApprovalParams`)}),(0,X.jsx)(`span`,{style:{fontSize:11,color:`var(--text-dim, #9aa1b4)`},children:t(`toolApprovalEditPlaceholder`)})]}),(0,X.jsx)(`textarea`,{rows:8,value:r,onChange:e=>{i(e.target.value),a&&o(null)},style:{width:`100%`,fontFamily:`var(--mono, monospace)`,fontSize:12,lineHeight:1.5,padding:10,borderRadius:6,backgroundColor:`var(--bg-elev, #111827)`,color:`var(--text, #f8fafc)`,border:a?`1px solid var(--red, #ef4444)`:`1px solid var(--border-subtle, rgba(255,255,255,0.1))`,boxSizing:`border-box`,resize:`vertical`}}),a&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12,marginTop:4},children:a})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,justifyContent:`flex-end`,gap:10},children:[e.category&&(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowCategoryHint`),onClick:()=>s(`category`),children:[(0,X.jsx)(ke,{}),t(`toolApprovalAllowCategory`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowConversationHint`),onClick:()=>s(`all`),children:[(0,X.jsx)(pt,{}),t(`toolApprovalAllowConversation`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,style:{color:`var(--red, #ef4444)`},onClick:c,children:[(0,X.jsx)(P,{}),t(`toolApprovalDeny`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>s(),style:{fontWeight:500},children:[(0,X.jsx)(ft,{}),t(`toolApprovalApprove`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>{try{let t=e.params,n;n=typeof t==`object`&&t||t==null?JSON.parse(r):r,o(null),$({type:`tool_approval_response`,id:e.id,decision:`edit`,editedParams:n})}catch(e){o(`JSON 格式错误:${e.message}`)}},children:[(0,X.jsx)(Y,{}),t(`toolApprovalEditAndRun`)]})]})]})]})}),document.body)}function Ax({overlay:e}){let t=Z(),n=(0,g.useRef)(null),r=(0,g.useRef)(null),i=(0,g.useCallback)(()=>{$({type:`tui_overlay_cancel`,id:e.id})},[e.id]);(0,g.useEffect)(()=>{let t=n.current;if(!t)return;let i=new m({theme:af(),fontFamily:`"SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace`,fontSize:13,cursorBlink:!0,scrollback:1e3,cols:e.cols||80,rows:e.rows||24}),a=new h;i.loadAddon(a),i.open(t),r.current={term:i,fit:a},e.initialAnsi&&i.write(e.initialAnsi);let o=i.onData(t=>{$({type:`tui_overlay_input`,id:e.id,data:t})}),s=Yo((t,n)=>{t===e.id&&i.write(n)});try{a.fit(),(i.cols!==e.cols||i.rows!==e.rows)&&$({type:`tui_overlay_resize`,id:e.id,cols:i.cols,rows:i.rows})}catch{}let c=new ResizeObserver(()=>{try{a.fit(),i.cols&&i.rows&&$({type:`tui_overlay_resize`,id:e.id,cols:i.cols,rows:i.rows})}catch{}});c.observe(t);let l=setTimeout(()=>{i.focus()},50);return()=>{clearTimeout(l),c.disconnect(),o.dispose(),s(),i.dispose(),r.current=null}},[e.id,e.cols,e.rows,e.initialAnsi]);let a=e.title||t(`tuiOverlayTitle`);return(0,X.jsx)(Ny,{open:!0,onClose:i,title:a,icon:(0,X.jsx)(B,{}),className:`tui-overlay-modal`,closeOnBackdropClick:!1,closeOnEscape:!0,children:(0,X.jsx)(`div`,{className:`tui-overlay-body`,children:(0,X.jsx)(`div`,{className:`tui-overlay-xterm`,ref:n})})})}var jx={pending:`in_progress`,in_progress:`done`,done:`failed`,failed:`pending`};function Mx({plan:e}){let t=Z(),[n,r]=(0,g.useState)(!1),{copied:i,copy:a}=Pu({duration:2e3}),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``);if(!e||!e.steps||e.steps.length===0)return null;let f=e.steps,p=f.filter(e=>e.status===`done`).length,m=f.length,h=Math.round(p/m*100),_=f.find(t=>t.id===e.activeStepId)??f.find(e=>e.status===`in_progress`),v=()=>{window.confirm(`确定要清空当前任务计划看板吗?`)&&$({type:`plan_update`,steps:[]})},y=()=>{$({type:`set_plan_mode`,enabled:!1}),$({type:`prompt`,text:t(`planImplementRequest`)})},b=()=>{let e=f.map((e,t)=>`${t+1}. ${e.title}${e.description?` (${e.description})`:``}`).join(`
673
+ `),yx=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]/gu;function bx(e){if(!e)return 0;let t=e.match(yx)?.length??0;return Math.ceil(t+(e.length-t)/4)}var xx=Mr.filter(e=>e.group===`other`&&e.name!==`todo_list`),Sx=`pi-web-ui:catalog-sync-urls`,Cx=8;function wx(){try{let e=localStorage.getItem(Sx);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim()!==``).slice(0,Cx):[]}catch{return[]}}function Tx(e){let t=e.trim();if(!t)return wx();let n=[t,...wx().filter(e=>e!==t)].slice(0,Cx);try{localStorage.setItem(Sx,JSON.stringify(n))}catch{}return n}function Ex(e){return e===`append`?0:_x(e)?2:1}function Dx({title:e,subtitle:t,tip:n,enabled:r,onToggle:i,action:a,disabled:o}){let s=Z();return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[e,n&&(0,X.jsx)(Du,{text:n})]}),t&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t})]}),a,(0,X.jsx)(`button`,{type:`button`,className:`set-switch ${r?`on`:``}`,role:`switch`,"aria-checked":r,disabled:o,title:s(r?`settingsEnabled`:`settingsDisabled`),onClick:o?void 0:i,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})}function Ox({name:e,edited:t,onEdit:n}){let r=Z();return(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn tool-prompt-edit${t?` edited`:``}`,title:r(t?`toolPromptEdited`:`toolPromptEdit`),"aria-label":r(`toolPromptEdit`),onClick:()=>n(e),children:(0,X.jsx)(Y,{})})}function kx(e){return e===`active`?`pluginPhaseActive`:e===`disabled`?`pluginPhaseDisabled`:e===`failed`?`pluginPhaseFailed`:`pluginPhaseIdle`}function Ax({phase:e,label:t}){return(0,X.jsx)(`span`,{className:`inv-dot inv-dot-${e}`,title:t,"aria-label":t})}function jx(e){if(e?.homepage&&/^https?:\/\//i.test(e.homepage))return e.homepage;let t=e?.source?.trim();if(!t)return null;if(/^https?:\/\//i.test(t))return t;if(t.startsWith(`git@github.com:`))return`https://github.com/${t.slice(15).replace(/\.git$/,``)}`;let n=t.split(`/`);return n.length===2&&!n[0].includes(`:`)&&!n[1].includes(`:`)?`https://github.com/${n[0]}/${n[1]}`:n.length>2&&!t.includes(`:`)?`https://github.com/${n[0]}/${n[1]}/tree/main/${n.slice(2).join(`/`)}`:null}function Mx({plugins:e,disabledIds:t}){let n=Z(),r=px(e,t),i={active:n(`pluginPhaseActive`),disabled:n(`pluginPhaseDisabled`),failed:n(`pluginPhaseFailed`),idle:n(`pluginPhaseIdle`)};return(0,X.jsx)(`div`,{className:`set-note inv-strip`,children:[`active`,`disabled`,`failed`,`idle`].map(e=>(0,X.jsxs)(`span`,{className:`inv-item`,title:i[e],children:[(0,X.jsx)(Ax,{phase:e,label:i[e]}),r[e]]},e))})}function Nx({label:e,tip:t,htmlFor:n,children:r}){return(0,X.jsxs)(`div`,{className:`set-row set-field-row`,children:[(0,X.jsxs)(`label`,{className:`set-row-name`,htmlFor:n,children:[e,t&&(0,X.jsx)(Du,{text:t})]}),r]})}function Px({mode:e,onModeChange:t,draft:n,onDraftChange:r,defaultPrompt:i,placeholder:a,rows:o=4,onCommit:s,modeLabel:c,hint:l,focusRef:u}){let d=Z(),f=(e,t)=>{s(e,e===`replace`&&i&&t===i?``:t)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Nx,{label:c??d(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:e,onChange:e=>{let r=e.target.value;t(r),f(r,n)},children:[(0,X.jsx)(`option`,{value:`append`,children:d(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:d(`promptModeReplace`)})]})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:o,placeholder:a,value:n,onFocus:()=>{u&&(u.current=!0)},onBlur:()=>{u&&(u.current=!1),f(e,n)},onChange:e=>r(e.target.value)}),l&&(0,X.jsx)(`p`,{className:`set-hint`,children:l})]})}function Fx({pluginId:e}){let t=Z(),[n,r]=(0,g.useState)(`all`),i=pl(e),a=n===`all`?i:i.filter(e=>e.level===n);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-log-filter`,children:[(0,X.jsx)(`span`,{className:`set-log-filter-label`,children:t(`pluginLogLevel`)}),[`all`,...al].map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-log-filter-btn${n===e?` on`:``}`,onClick:()=>r(e),children:e===`all`?t(`pluginLogAll`):e.toUpperCase()},e)),(0,X.jsxs)(`button`,{type:`button`,className:`set-log-clear`,title:t(`pluginLogClear`),onClick:()=>$(sl(e)),children:[(0,X.jsx)(L,{}),t(`pluginLogClear`)]})]}),a.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:t(`pluginLogEmpty`)}):(0,X.jsx)(`ul`,{className:`set-diag-list set-log-list`,children:a.map((t,n)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`set-log-time`,children:new Date(t.ts).toLocaleTimeString()}),` `,(0,X.jsx)(`span`,{className:`set-log-level lv-${t.level}`,children:t.level.toUpperCase()}),` `,(0,X.jsx)(`span`,{className:`set-log-text`,children:t.text})]},`${e}-${t.ts}-${n}`))})]})}function Ix(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}var Lx=1e4;function Rx({chat:e,terminal:t,initialSection:n,onSwitchToTerminal:r,onClose:i,onOpenIconEdit:a,sound:o,onSoundChange:s,tts:c,onTtsChange:l}){let u=Z(),{locale:d}=Nn(),f=e=>u(e),p=e.settings,[m,h]=(0,g.useState)({}),_=(0,g.useMemo)(()=>{if(!p)return null;if(Object.keys(m).length===0)return p;let e={...p};for(let[t,{value:n}]of Object.entries(m))e[t]=n;return e},[p,m]);(0,g.useEffect)(()=>{p&&h(e=>{if(Object.keys(e).length===0)return e;let t={},n=Date.now();for(let[r,{value:i,at:a}]of Object.entries(e))!Ix(p[r],i)&&n-a<Lx&&(t[r]={value:i,at:a});return Object.keys(t).length===Object.keys(e).length?e:t})},[p]);let v=_?.approvalPolicy,{engine:y,managed:b}=Xa(),x=y===`dsh`,[S,C]=(0,g.useState)(n??`prompt`),[w,T]=(0,g.useState)(`market`),E=(0,g.useRef)(null);(0,g.useEffect)(()=>{E.current?.scrollTo({top:0})},[S]);let D=(0,g.useRef)(null);(0,g.useEffect)(()=>{D.current?.querySelector(`.settings-tab.active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[S]);let[O,k]=(0,g.useState)(`installed`),[A,j]=(0,g.useState)(`all`),[ee,M]=(0,g.useState)(``),[te,ie]=(0,g.useState)(`anthropics/skills`),[ae,I]=(0,g.useState)(``),[z,oe]=(0,g.useState)(!1),[B,V]=(0,g.useState)(null),[W,pe]=(0,g.useState)({}),[G,he]=(0,g.useState)(null),ge=(0,g.useMemo)(()=>new Set((_?.skills??[]).map(e=>e.name.toLowerCase())),[_?.skills]),_e=te===`custom`?ae.trim():te,ve=(e=!1)=>{_e&&(oe(!0),$({type:`fetch_skill_market`,repo:_e,refresh:e}))};(0,g.useEffect)(()=>{if(S!==`skills`||O!==`market`||!_e)return;oe(!0);let e=setTimeout(()=>{$({type:`fetch_skill_market`,repo:_e})},350);return()=>clearTimeout(e)},[S,O,te,ae]),(0,g.useEffect)(()=>{e.skillMarketResult&&oe(!1)},[e.skillMarketResult]),(0,g.useEffect)(()=>{if(e.skillContentResult?.ok&&e.skillContentResult.skillId){let t=e.skillContentResult.skillId,n=e.skillContentResult.content;pe(e=>({...e,[t]:n})),he(null),B&&B.id===t&&V(e=>e?{...e,content:n}:null)}},[e.skillContentResult]);let ye=(0,g.useMemo)(()=>e.skillMarketResult?.ok&&e.skillMarketResult.skills?.length>0?e.skillMarketResult.skills.map(e=>({id:e.id,name:e.name,nameZh:e.name,description:e.description,descriptionZh:e.description,category:`workflow`,content:W[e.id]||``})):Zy,[e.skillMarketResult,W]),be=(0,g.useMemo)(()=>ye.filter(e=>{if(A!==`all`&&e.category!==A)return!1;if(ee.trim()){let t=ee.trim().toLowerCase(),n=e.name.toLowerCase().includes(t)||e.nameZh.toLowerCase().includes(t),r=e.description.toLowerCase().includes(t)||e.descriptionZh.toLowerCase().includes(t);return n||r}return!0}),[ye,A,ee]),xe=(e,t)=>{let n=W[e.id]||e.content;n?($({type:`install_skill`,name:e.id,scope:t,content:n}),V(null)):(he(e.id),$({type:`fetch_skill_content`,repo:_e,skillId:e.id}))},Se=(e,t)=>{$({type:`uninstall_skill`,name:e,scope:t})},Ce=e=>{switch(e){case`quality`:return u(`skillCatQuality`);case`workflow`:return u(`skillCatWorkflow`);case`architecture`:return u(`skillCatArchitecture`);case`devops`:return u(`skillCatDevops`);case`stack`:return u(`skillCatStack`);default:return u(`skillCatAll`)}};(0,g.useEffect)(()=>{S===`plugins`&&x&&$({type:`dsh_patches_list`})},[S,x]),(0,g.useEffect)(()=>{$({type:`get_settings`})},[e.state?.cwd,e.activeConversationId]);let[we,Te]=(0,g.useState)(``),Ee=(0,g.useRef)(we);Ee.current=we;let De=(0,g.useRef)(null),[Oe,ke]=(0,g.useState)({}),je=(0,g.useRef)(Oe);je.current=Oe;let Me=(0,g.useRef)(!1),Pe=(0,g.useRef)(null),Ie=[...hx].sort((e,t)=>Ex(e)-Ex(t)),[ze,Be]=(0,g.useState)(null),[He,We]=(0,g.useState)({}),[Je,Ye]=(0,g.useState)(``),[Xe,Qe]=(0,g.useState)(`append`),$e=(0,g.useRef)(!1),[et,tt]=(0,g.useState)(``),[nt,it]=(0,g.useState)(`append`),at=(0,g.useRef)(!1),[ot,st]=(0,g.useState)(``),[lt,ut]=(0,g.useState)(`append`),pt=(0,g.useRef)(!1),[mt,gt]=(0,g.useState)(``),_t=(0,g.useRef)(!1),[vt,yt]=(0,g.useState)(``),[bt,xt]=(0,g.useState)(null),[Ct,Tt]=(0,g.useState)(null),[Et,Dt]=(0,g.useState)(!1),[Ot,kt]=(0,g.useState)(null),[At,Mt]=(0,g.useState)(null),[Nt,Pt]=(0,g.useState)(!1),[Ft,It]=(0,g.useState)(``),[Lt,Rt]=(0,g.useState)(null),[Bt,Vt]=(0,g.useState)(null),[Ht,Ut]=(0,g.useState)(null),[Wt,Gt]=(0,g.useState)(!1),[Kt,qt]=(0,g.useState)(!1),[Jt,Yt]=(0,g.useState)(null),Xt=_?.toolPromptOverrides??{},Zt=(0,g.useMemo)(()=>new Set(Object.keys(Xt)),[Xt]),Qt=e=>x?null:(0,X.jsx)(Ox,{name:e,edited:Zt.has(e),onEdit:Yt}),$t=(e,t)=>Q({toolPromptOverrides:{[e]:t??{}}}),en=(0,g.useMemo)(()=>bx(_?.effectiveSystemPrompt??``),[_?.effectiveSystemPrompt]),tn=(0,g.useMemo)(()=>bx(_?.toolsSchema??``),[_?.toolsSchema]),nn=en+tn,rn=wb(),an=Vp(),sn=Fb(),cn=$b(),[ln,un]=(0,g.useState)(cn.url),dn=(0,g.useRef)(!1),fn=(0,g.useRef)(null),[pn,mn]=(0,g.useState)(!1),[hn,gn]=(0,g.useState)(!1);(0,g.useEffect)(()=>{dn.current||un(cn.url.startsWith(`data:`)?``:cn.url)},[cn.url]);let _n=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){mn(!0),gn(!1);try{let e=await Kb(t),n=e?Vb(e):``;if(!n){gn(!0);return}un(``),Jb({...cn,url:n})}finally{mn(!1)}}},[vn,yn]=(0,g.useState)(()=>v_()),[bn,xn]=(0,g.useState)(()=>{try{return S_().length}catch{return 0}}),[Sn,Cn]=(0,g.useState)(!1),wn=()=>{try{xn(S_().length)}catch{xn(0)}};(0,g.useEffect)(()=>{S===`prompt-history`&&wn()},[S]),(0,g.useEffect)(()=>{if(!Sn)return;let e=window.setTimeout(()=>Cn(!1),3e3);return()=>window.clearTimeout(e)},[Sn]);let[Tn,En]=(0,g.useState)(null),[Dn,On]=(0,g.useState)(null),[kn,An]=(0,g.useState)(null),[jn,Mn]=(0,g.useState)(null),[Pn,In]=(0,g.useState)({}),[,Rn]=(0,g.useState)(0);(0,g.useEffect)(()=>fl(()=>Rn(e=>e+1)),[]);let[zn,Bn]=(0,g.useState)(``),[Vn,Hn]=(0,g.useState)(``),[Un,Wn]=(0,g.useState)(``),[Gn,Kn]=(0,g.useState)(``),[qn,Jn]=(0,g.useState)(``),[Yn,Xn]=(0,g.useState)(!1),[Zn,Qn]=(0,g.useState)(!1),[$n,er]=(0,g.useState)(!1),[tr,nr]=(0,g.useState)(``),[rr,ir]=(0,g.useState)(!1),[ar,or]=(0,g.useState)(!1),[sr,cr]=(0,g.useState)(null),[lr,ur]=(0,g.useState)(``),[dr,mr]=(0,g.useState)(()=>wx()),[hr,gr]=(0,g.useState)(``),[_r,vr]=(0,g.useState)(null);(0,g.useEffect)(()=>{_&&(Me.current||(Te(_.promptTemplate??``),Ee.current=_.promptTemplate??``),ke(e=>{let t={};for(let[e,n]of Object.entries(_.promptOverrides??{}))t[e]=n??``;return Pe.current&&(t[Pe.current]=e[Pe.current]??``),je.current=t,t}),Qe(_.visionBridgePromptMode),!$e.current&&(Ye(Xe===`append`||_.visionBridgePrompt?_.visionBridgePrompt:_.visionBridgeDefaultPrompt||``),it(_.scmCommitMsgPromptMode),at.current||tt(_.scmCommitMsgPromptMode===`append`||_.scmCommitMsgPrompt?_.scmCommitMsgPrompt:_.scmCommitMsgDefaultPrompt||``),ut(_.planModePromptMode),pt.current||st(_.planModePromptMode===`append`||_.planModePrompt?_.planModePrompt:_.planModeDefaultPrompt||``),_t.current||gt(_.reviewPrompt)))},[_,Xe,nt,lt]);let[yr,br]=(0,g.useState)(String(_?.terminalBashIdleMs??15e3));(0,g.useEffect)(()=>{br(String(_?.terminalBashIdleMs??15e3))},[_?.terminalBashIdleMs]);let[xr,Sr]=(0,g.useState)(String(_?.terminalBashMaxForegroundMs??6e4));(0,g.useEffect)(()=>{Sr(String(_?.terminalBashMaxForegroundMs??6e4))},[_?.terminalBashMaxForegroundMs]);let[Cr,wr]=(0,g.useState)(String(Math.round((_?.toolWatchdogTimeoutMs??12e5)/6e4)));(0,g.useEffect)(()=>{wr(String(Math.round((_?.toolWatchdogTimeoutMs??12e5)/6e4)))},[_?.toolWatchdogTimeoutMs]);let[Tr,Er]=(0,g.useState)(String(_?.retryMaxAttempts??6));(0,g.useEffect)(()=>{Er(String(_?.retryMaxAttempts??6))},[_?.retryMaxAttempts]);let[Dr,Or]=(0,g.useState)(String(_?.keepRecentMessages??15));(0,g.useEffect)(()=>{Or(String(_?.keepRecentMessages??15))},[_?.keepRecentMessages]);let[kr,Ar]=(0,g.useState)(_?.softCapTokens&&_.softCapTokens>0?mb(_.softCapTokens):``);(0,g.useEffect)(()=>{Ar(_?.softCapTokens&&_.softCapTokens>0?mb(_.softCapTokens):``)},[_?.softCapTokens]);let[jr,Pr]=(0,g.useState)(``),[Fr,Rr]=(0,g.useState)(``),zr=[],Br=pa(na(e.plugins),{locale:d,t:e=>u(e),disabledPlugins:e.settings?.disabledPlugins??[],layout:e.settings?.uiLayout,diagnostics:zr}),Vr=[];for(let t of Br[`settings.pages`]){if(t.source===`host`||t.hidden||t.kind===`divider`)continue;let n=e.plugins.find(e=>e.id===t.source.slice(7));n&&Vr.push({entry:t,plugin:n})}let Hr=e=>`plugin-page:${e}`;if((0,g.useEffect)(()=>{S.startsWith(`plugin-page:`)&&(Vr.some(e=>Hr(e.entry.id)===S)||C(`prompt`))},[S,Vr]),!_)return null;let Ur=new Set(_.disabledAgentTools??[]),Wr=Ur.size,Gr=x?null:e.dshPresets?.defaultPreset??null,Kr=!!Gr&&Gr!==`standard`,qr=Kr?new Set(Ir([...Mr.map(e=>e.name),`bash`,`read`,`edit`,`write`],Gr??void 0)):new Set(Mr.map(e=>e.name)),Jr=Z_(e.dshPresets?.presets.find(e=>e.id===Gr)??{id:Gr??``,trust:`system`,isDefault:!1},d,u).name,Yr=e=>Kr&&!qr.has(e),Xr=Kr?Mr.filter(e=>!qr.has(e.name)).length:0,Zr=Kr?e.plugins.flatMap(e=>e.agentTools??[]).filter(e=>!(_.disabledPluginTools??[]).includes(e.name)).length:0,Qr=e.dshPresets?Q_(e.dshPresets.presets).find(t=>t.id===e.dshPresets.defaultPreset):void 0,$r=Qr?Qr.broken??Z_(Qr,d,u).description:void 0,ei=!!e.dshPresets?.presets.some(e=>e.trust===`user`),ti=!!(e.dshPresets&&e.dshPresets.presets.length>0)||!!(e.dshPermission&&e.dshPermission.options.length>0),ni=e.pluginUpdates,ri=Object.values(ni??{}).some(e=>e.updatable&&(e.builtin??!1)),ii=Object.values(ni??{}).some(e=>e.updatable),ai=[{id:`prompt`,icon:(0,X.jsx)(Ve,{}),label:u(`settingsSystemPrompt`)},{id:`prompt-history`,icon:(0,X.jsx)(rt,{}),label:u(`settingsPromptHistory`),count:bn},...x?[]:[{id:`scheduler`,icon:(0,X.jsx)(rt,{}),label:u(`settingsScheduler`),count:e.schedulerTasks.length||void 0}],...x?[{id:`question`,icon:(0,X.jsx)(Ne,{}),label:u(`settingsQuestionnaire`)}]:[{id:`tools`,icon:(0,X.jsx)(R,{}),label:u(`settingsTools`),count:Wr+(_.disabledMarkers?.length??0)||void 0},{id:`approval-rules`,icon:(0,X.jsx)(ce,{}),label:u(`settingsApprovalRules`),count:(_.approvalRules??[]).length||void 0}],{id:`display`,icon:(0,X.jsx)(J,{}),label:u(`settingsMessageDisplay`)},{id:`sound`,icon:(0,X.jsx)(ne,{}),label:u(`settingsSoundVoice`)},{id:`quick`,icon:(0,X.jsx)(de,{}),label:u(`quickPhrases`),count:_.quickPhrases.length},{id:`skills`,icon:(0,X.jsx)(Ze,{}),label:u(`settingsSkills`),count:_.skills.length},{id:`extensions`,icon:(0,X.jsx)(q,{}),label:u(`settingsExtensions`),count:_.extensions.length},{id:`plugins`,icon:(0,X.jsx)(ht,{}),label:u(`settingsUiPlugins`),count:e.plugins.length,dot:ri||ii},{id:`mcp`,icon:(0,X.jsx)(U,{}),label:u(`settingsMcp`),count:(_.mcpServers??[]).length||void 0,dot:(_.mcpServers??[]).some(e=>e.status===`error`)},{id:`layout`,icon:(0,X.jsx)(H,{}),label:u(`uiLayoutTitle`)},{id:`review`,icon:(0,X.jsx)(N,{}),label:u(`settingsReview`),count:_.reviewSkills.length},...x?[]:[{id:`vision`,icon:(0,X.jsx)(Ue,{}),label:u(`settingsVisionBridge`)}],{id:`presets`,icon:(0,X.jsx)(H,{}),label:u(`settingsPresets`),count:_.presets.length},...x?[]:[{id:`subagent-templates`,icon:(0,X.jsx)(F,{}),label:u(`settingsSubagentTemplates`),count:_.subagentTemplates.length}],...Vr.map(e=>({id:Hr(e.entry.id),icon:e.entry.iconSvg?(0,X.jsx)(hi,{iconSvg:e.entry.iconSvg}):e.entry.icon&&!/[a-z]/i.test(e.entry.icon)?(0,X.jsx)(`span`,{children:e.entry.icon}):(0,X.jsx)(ht,{}),label:e.entry.label,pluginPage:{plugin:e.plugin,entry:e.entry}}))],oi=S.startsWith(`plugin-page:`)?Vr.find(e=>Hr(e.entry.id)===S)??null:null,si=new Set(_.disabledSkills),ci=new Set(_.disabledExtensions),Q=e=>{let t=Date.now();h(n=>{let r={...n};for(let[n,i]of Object.entries(e))r[n]={value:i,at:t};return r}),$({type:`set_settings`,...e})},li=()=>{if(!_r||!_)return;let e=_r.value.trim(),t=_r.index;if(vr(null),!e||e===_.quickPhrases[t])return;let n=[..._.quickPhrases];n[t]=e,Q({quickPhrases:n})},ui=e=>{let t=new Set(si);t.has(e.name)?t.delete(e.name):t.add(e.name),Q({disabledSkills:[...t]})},di=new Set(_.skillsFullText??[]),fi=e=>{let t=new Set(di);t.has(e)?t.delete(e):t.add(e),Q({skillsFullText:[...t]})},pi=new Set(_.disabledPlugins??[]),mi=new Set(e.plugins.map(e=>e.id)),gi=e=>{let t=new Set(pi);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledPlugins:[...t]})},_i=e=>{let t=new Set(ci);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledExtensions:[...t]})},vi={subagent:u(`toolDescSubagent`),subagent_spawn:u(`toolDescSubagentSpawn`),subagent_get_result:u(`toolDescSubagentGetResult`),subagent_steer:u(`toolDescSubagentSteer`),subagent_list:u(`toolDescSubagentList`),subagent_stop:u(`toolDescSubagentStop`),subagent_wait_all:u(`toolDescSubagentWaitAll`),subagent_templates:u(`toolDescSubagentTemplates`)},yi={bash:u(`toolCoreBashDesc`),read:u(`toolCoreReadDesc`),edit:u(`toolCoreEditDesc`),write:u(`toolCoreWriteDesc`),powershell:u(`toolCorePowershellDesc`),ls:u(`toolCoreLsDesc`),grep:u(`toolCoreGrepDesc`),find:u(`toolCoreFindDesc`)},bi=e=>{let t=new Set(Ur);t.has(e)?t.delete(e):t.add(e),Q({disabledAgentTools:[...t]})},xi=new Set(_.disabledPluginTools??[]),Si=e=>{let t=new Set(xi);t.has(e)?t.delete(e):t.add(e),Q({disabledPluginTools:[...t]})},Ci=e.plugins.map(e=>({plugin:e,tools:[...e.agentTools??[]].sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.tools.length>0),wi=_.markersEnabled??!0,Ti=new Set(_.disabledMarkers??[]),Ei=e=>{let t=new Set(Ti);t.has(e)?t.delete(e):t.add(e),Q({disabledMarkers:[...t]})},Di=(n,a)=>{let o={name:n,command:a,cwd:"${pwd}"},s,c=e.terminals.find(e=>e.title===n);c?(t.restart(c.id),$({type:`run_command`,terminalId:c.id,conversationId:c.conversationId,command:o,cols:80,rows:24}),s=c.id):(s=jt(),t.create({id:s,conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:o})),t.select(s),r(),i()},Oi=e=>{En(null),Di(`${u(`uninstallTitle`)} ${e}`,`pi remove npm:${e}`)},ki=(e,t,n)=>{$({type:`plugin_job`,jobId:jt(),action:e,id:t,...n?{source:n}:{},...e!==`uninstall`&&Zn?{build:!0}:{}})},Ai=t=>{let n=null;for(let r of Object.values(e.pluginJobs??{}))r.pluginId===t&&(!n||r.startedAt>=n.startedAt)&&(n=r);return n},ji=e=>e?e.problem===`already-installed`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:u(`pluginInspectAlreadyInstalled`,{id:e.suggestedId})}):e.problem===`network`?(0,X.jsx)(`div`,{className:`set-catalog-hint`,"data-problem":e.problem,children:u(`pluginInspectNetwork`)}):e.problem===`invalid-spec`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:u(`pluginInspectInvalid`)}):e.problem===`not-found`||e.problem===`not-a-package`||e.problem===`not-a-bundle`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:u(`pluginInspectNotPlugin`)}):e.problem?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,children:e.detail}):e.manifest?(0,X.jsxs)(`div`,{className:`set-catalog-hint ok`,"data-problem":`ok`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,children:`✓ `}),e.manifest.name??e.manifest.id??e.suggestedId,e.manifest.version?` v${e.manifest.version}`:``,e.manifest.description?` · ${e.manifest.description}`:``]}):null:null,Mi=e=>{let t=Ai(e);if(!t)return null;if(t.phase!==`done`){let e=t.lines[t.lines.length-1]??``;return(0,X.jsxs)(`div`,{className:`set-catalog-job running`,title:e,children:[(0,X.jsx)(K,{className:`set-job-spin`}),u(`pluginJobRunning`),(0,X.jsx)(`span`,{className:`set-catalog-job-line`,children:e}),(0,X.jsx)(`button`,{type:`button`,className:`set-job-cancel`,onClick:()=>$({type:`plugin_job_cancel`,jobId:t.jobId}),children:u(`cancel`)})]})}return t.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[`✓ `,u(`pluginJobDone`)]}):(0,X.jsxs)(`div`,{className:`set-catalog-job error`,children:[(0,X.jsxs)(`span`,{children:[`✗ `,t.error||u(`pluginJobFailed`)]}),t.output?(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:t.output}):null]})},Ni=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`},{slot:`topbar.overflow`,labelKey:`uiLayoutTopbarOverflow`},{slot:`notice.actions`,labelKey:`uiLayoutNotice`},{slot:`leftpanel.sections`,labelKey:`uiLayoutLeftSections`},{slot:`leftpanel.projects.actions`,labelKey:`uiLayoutLeftProjectsActions`},{slot:`leftpanel.project`,labelKey:`uiLayoutLeftProject`},{slot:`leftpanel.running.actions`,labelKey:`uiLayoutLeftRunningActions`},{slot:`leftpanel.running`,labelKey:`uiLayoutLeftRunning`},{slot:`leftpanel.history.actions`,labelKey:`uiLayoutLeftHistoryActions`},{slot:`leftpanel.history`,labelKey:`uiLayoutLeftHistory`},{slot:`leftpanel.sessions`,labelKey:`uiLayoutLeftSessions`},{slot:`chat.header`,labelKey:`uiLayoutChatHeader`},{slot:`chat.empty`,labelKey:`uiLayoutChatEmpty`},{slot:`message.actions`,labelKey:`uiLayoutMessage`},{slot:`goalbar.actions`,labelKey:`uiLayoutGoalbar`},{slot:`composer.leading`,labelKey:`uiLayoutComposerLeading`},{slot:`composer.actions`,labelKey:`uiLayoutComposer`},{slot:`rightpanel.tabs`,labelKey:`uiLayoutRightPanel`},{slot:`terminal.toolbar`,labelKey:`uiLayoutTerminal`},{slot:`scm.toolbar`,labelKey:`uiLayoutScm`},{slot:`bottombar`,labelKey:`uiLayoutBottombar`},{slot:`file.preview.toolbar`,labelKey:`uiLayoutFilePreview`},{slot:`contextmenu.topbar`,labelKey:`uiLayoutContextTopbar`},{slot:`contextmenu.message`,labelKey:`uiLayoutContextMessage`},{slot:`contextmenu.session`,labelKey:`uiLayoutContextSession`},{slot:`contextmenu.project`,labelKey:`uiLayoutContextProject`},{slot:`contextmenu.file`,labelKey:`uiLayoutContextFile`},{slot:`contextmenu.toolcall`,labelKey:`uiLayoutContextToolcall`},{slot:`settings.pages`,labelKey:`uiLayoutSettingsPages`},{slot:`tasks.panel`,labelKey:`uiLayoutTasksPanel`},{slot:`modal.dialog`,labelKey:`uiLayoutModal`},{slot:`sidebar.left`,labelKey:`uiLayoutSidebarLeft`},{slot:`sidebar.right`,labelKey:`uiLayoutSidebarRight`}],Pi=[`bottombar`,`composer.actions`,`topbar.primary`,`sidebar.left`,`sidebar.right`],Fi=e=>e===`sidebar.left`||e===`sidebar.right`,Ii=[`topbar.primary`,`bottombar`,`sidebar.left`,`sidebar.right`],[Li,Ri]=(0,g.useState)(``),zi=e=>{let t=Ni.find(t=>t.slot===e);return t?u(t.labelKey):e},Bi=e.settings?.uiLayout,Vi=e=>Q({uiLayout:{...Bi,...e}}),Hi=e=>{let t=new Set(Bi?.hidden??[]),n=new Set(Bi?.shown??[]);e.hidden?(t.delete(e.id),n.add(e.id)):(t.add(e.id),n.delete(e.id)),Vi({hidden:[...t],shown:[...n]})},Ui=(e,t,n,r)=>{let i=t.map(e=>e.id),a=i.indexOf(n),o=a+r;if(a<0||o<0||o>=i.length)return;let s=[...i],[c]=s.splice(a,1);if(c===void 0)return;s.splice(o,0,c);let l=new Set(i),u=[...s],d=e.map(e=>l.has(e.id)?u.shift():e.id),f=new Set(e.map(e=>e.id)),p=(Bi?.order??[]).filter(e=>!f.has(e));Vi({order:[...p,...d]})},Wi=(e,t)=>{(t===`start`||t===`center`||t===`end`)&&Vi({align:{...Bi?.align,[e]:t}})},Gi=(e,t)=>{let n={...Bi?.slots,[e]:t};Vi({slots:n})},Ki=(e,t)=>{let n={...Bi?.labels},r=t.trim().slice(0,60);r?n[e]=r:delete n[e],Vi({labels:n})},Yi=e=>Q({uiLayout:_a(Bi,e)}),Xi=()=>Q({uiLayout:va()}),Zi=e=>{On(null),ki(`uninstall`,e)},Qi=(e,t)=>{ki(`update`,e,t)},$i=e=>{ki(`install`,e.id,e.source)},ea=e=>{$({type:`plugin_catalog_remove`,id:e})},ta=()=>{let e=zn.trim();e&&($({type:`plugin_catalog_add`,entry:{source:e,...Vn.trim()?{id:Vn.trim()}:{},...Un.trim()?{name:Un.trim()}:{},...Gn.trim()?{description:Gn.trim()}:{},...qn.trim()?{icon:qn.trim()}:{}}}),Bn(``),Hn(``),Wn(``),Kn(``),Jn(``),Xn(!1))},ra=e=>{let t=e.trim();if(!t)return;let n=jt();cr(n),ur(t),$({type:`plugin_catalog_sync`,requestId:n,source:t,...rr?{install:!0}:{},...ar?{replace:!0}:{}})},[ia,aa]=(0,g.useState)(``);(0,g.useEffect)(()=>{let e=zn.trim();if(!e){aa(``);return}let t=setTimeout(()=>{let t=jt();aa(t),$({type:`plugin_install_inspect`,requestId:t,source:e,...Vn.trim()?{explicitId:Vn.trim()}:{}})},500);return()=>clearTimeout(t)},[zn,Vn]);let oa=e.installInspect,sa=oa&&oa.requestId===ia&&oa.source===zn.trim()?oa:null,ca=e.catalogSync&&e.catalogSync.requestId===sr?e.catalogSync:null;(0,g.useEffect)(()=>{ca?.ok&&lr&&mr(Tx(lr))},[ca?.requestId,ca?.ok]);let la=e=>{let t=new Set(_.reviewSkills.filter(e=>!e.enabled).map(e=>e.name));t.has(e.name)?t.delete(e.name):t.add(e.name),Q({reviewDisabledSkills:[...t]})},ua=()=>{De.current&&=(clearTimeout(De.current),null);let e=Ee.current;e!==(_?.promptTemplate??``)&&Q({promptTemplate:e})},da=e=>{let t=je.current[e]??``;Q({promptOverrides:{[e]:t}})},fa=e=>{Pe.current===e&&(Pe.current=null),Be(null),ke(t=>{let n={...t};return delete n[e],je.current=n,n}),Q({promptOverrides:{[e]:``}})},ma=e=>We(t=>({...t,[e]:!t[e]})),ha=(e,t)=>{ke(n=>{let r={...n,[e]:t};return je.current=r,r}),Be(e)},ga=()=>{De.current&&=(clearTimeout(De.current),null),Me.current=!1,Pe.current=null,Te(vx),Ee.current=vx,ke({}),je.current={},Q({promptTemplate:vx,promptOverrides:{}})},ya=e=>{De.current&&=(clearTimeout(De.current),null);let t=Ee.current,n=t.trim()?`${t}\n\n{{${e}}}`:`{{${e}}}`;Te(n),Ee.current=n,Q({promptTemplate:n})},ba=()=>{De.current&&=(clearTimeout(De.current),null);let e=Ee.current;e!==(_?.promptTemplate??``)&&Q({promptTemplate:e}),Me.current=!1;let t=je.current,n=_?.promptOverrides??{},r={},i=!1;for(let[e,a]of Object.entries(t)){let t=_?.promptSourceDefaults?.[e]??``,o=a.trim()&&a===t?``:a;o!==(n[e]??``)&&(r[e]=o,i=!0)}i&&Q({promptOverrides:r}),Pe.current=null},xa=()=>{ba(),i()},Sa=e=>{ba(),C(e)};zt(xa,!Ct&&!At&&!Jt&&!bt&&!B),(0,g.useEffect)(()=>()=>{ba()},[]);let Ca=we.trim()&&we.trim()!==vx||Object.values(Oe).some(e=>e.trim());return(0,X.jsxs)(`div`,{className:`modal-backdrop`,onClick:xa,children:[(0,X.jsxs)(`div`,{className:`modal settings-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":u(`close`),onClick:xa,children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(ue,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:u(`settingsTitle`)}),(0,X.jsx)(Du,{text:u(`settingsDesc`)})]}),(0,X.jsxs)(`div`,{className:`settings-layout`,children:[(0,X.jsx)(`nav`,{className:`settings-rail`,"aria-label":u(`settingsTitle`),ref:D,children:ai.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-tab":e.id,className:`settings-tab${S===e.id?` active`:``}`,"aria-current":S===e.id?`true`:void 0,title:e.hint??e.label,onClick:()=>Sa(e.id),children:[(0,X.jsx)(`span`,{className:`settings-tab-icon`,children:e.icon}),(0,X.jsx)(`span`,{className:`settings-tab-label`,children:e.label}),e.count!==void 0&&(0,X.jsx)(`span`,{className:`set-count`,children:e.count}),e.dot&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]},e.id))}),(0,X.jsxs)(`div`,{className:`modal-body`,ref:E,children:[S===`prompt`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(N,{className:`set-section-icon`}),u(`settingsSystemPrompt`),(0,X.jsx)(Du,{text:`${u(`promptComposeHint`)}\n${u(`promptComposeDesc`)}`})]}),(0,X.jsxs)(`div`,{className:`set-prompt-view-triggers`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":Wt,onClick:()=>Gt(e=>!e),children:[(0,X.jsx)(`span`,{children:u(`settingsViewPrompt`)}),en>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:u(`settingsViewPromptTokens`,{n:en.toLocaleString()})}),(0,X.jsx)(`span`,{children:Wt?`▴`:`▾`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":Kt,onClick:()=>qt(e=>!e),children:[(0,X.jsx)(`span`,{children:u(`settingsViewToolsSchema`)}),tn>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:u(`settingsViewPromptTokens`,{n:tn.toLocaleString()})}),(0,X.jsx)(`span`,{children:Kt?`▴`:`▾`})]}),nn>0&&(0,X.jsx)(`span`,{className:`set-prompt-total-est`,children:u(`settingsPromptContextTotal`,{n:nn.toLocaleString()})})]}),Wt&&(0,X.jsxs)(`div`,{className:`set-prompt-view`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:u(`settingsViewPrompt`)}),(0,X.jsx)(Du,{text:u(`settingsViewPromptHint`)}),(0,X.jsx)(Fd,{text:_.effectiveSystemPrompt})]}),_.effectiveSystemPrompt?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:_.effectiveSystemPrompt}):(0,X.jsx)(`p`,{className:`set-empty`,children:u(`settingsViewPromptEmpty`)})]}),Kt&&(0,X.jsx)(`div`,{className:`set-prompt-view`,children:(0,X.jsxs)(`div`,{className:`set-prompt-tools`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:u(`settingsViewToolsSchema`)}),(0,X.jsx)(Du,{text:u(`settingsViewToolsSchemaHint`)}),(0,X.jsx)(Fd,{text:_.toolsSchema})]}),_.toolsSchema?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:_.toolsSchema}):(0,X.jsx)(`p`,{className:`set-empty`,children:u(`settingsViewToolsSchemaEmpty`)})]})}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`promptTemplateLabel`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:6,spellCheck:!1,placeholder:vx,value:we,onFocus:()=>Me.current=!0,onBlur:()=>{Me.current=!1,ua()},onChange:e=>{let t=e.target.value;Te(t),Ee.current=t,De.current&&clearTimeout(De.current),De.current=setTimeout(()=>{De.current=null,t!==(_?.promptTemplate??``)&&Q({promptTemplate:t})},800)}}),(0,X.jsxs)(`div`,{className:`compose-toolbar`,children:[(0,X.jsx)(`span`,{className:`set-field-label set-muted`,children:u(`promptInsertTokens`)}),Ie.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`token-chip`,title:f(`promptTok_${e}_desc`),onClick:()=>ya(e),children:`{{${e}}}`},e))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`promptSourcesLabel`)}),Ie.map(e=>{let t=Oe[e]??``,n=_.promptSourceDefaults?.[e]??``,r=ze===e,i=n.split(`
674
+ `).length>6||n.length>480;if(_x(e)){let r=t.trim()?t:n;return(0,X.jsxs)(`div`,{className:`override-row readonly`,children:[(0,X.jsxs)(`div`,{className:`override-row-head`,children:[`{{${e}}}`,(0,X.jsxs)(`span`,{className:`set-muted`,children:[f(`promptTok_${e}`),` `,(0,X.jsx)(Du,{text:f(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,title:u(`promptReadonlyLockedHint`),onClick:()=>fa(e),children:u(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:u(`promptReadonlyBadge`)})]}),(0,X.jsx)(`div`,{className:`source-default readonly${r.trim()?``:` empty`}`,title:u(`promptReadonlyTitle`),children:r.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?He[e]?` expanded`:` clamped`:``}`,children:r}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ma(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ma(e))},children:He[e]?u(`promptSourceCollapse`):u(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:u(`promptSourceDefaultEmpty`)})})]},e)}return(0,X.jsxs)(`div`,{className:`override-row`,children:[(0,X.jsxs)(`div`,{className:`override-row-head`,children:[`{{${e}}}`,(0,X.jsxs)(`span`,{className:`set-muted`,children:[f(`promptTok_${e}`),` `,(0,X.jsx)(Du,{text:f(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,onClick:()=>fa(e),children:u(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:u(`promptAutoBadge`)})]}),t.trim()||r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`set-prompt-input override-input`,rows:Math.min(10,Math.max(1,t.split(`
675
+ `).length)),autoFocus:r,placeholder:u(`promptOverridePlaceholder`),value:t,onFocus:t=>{Pe.current=e,Be(e);let r=t.currentTarget;r.value&&r.value===n&&r.setSelectionRange(r.value.length,r.value.length)},onBlur:()=>{Pe.current===e&&(Pe.current=null);let t=Oe[e]??``;if(t.trim()&&t===n){fa(e);return}da(e),t.trim()||Be(null)},onChange:t=>{let n=t.target.value;ke(t=>{let r={...t,[e]:n};return je.current=r,r})}}),(0,X.jsxs)(`div`,{className:`override-edit-foot`,children:[(0,X.jsxs)(`div`,{className:`override-edit-foot-head`,children:[(0,X.jsx)(`span`,{className:`set-muted`,children:u(`promptSourceRefLabel`)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`source-default-toggle`,onClick:()=>ma(e),children:He[e]?u(`promptSourceCollapse`):u(`promptSourceExpand`)})]}),n.trim()?(0,X.jsx)(`pre`,{className:`source-default-text${i?He[e]?` expanded`:` clamped`:``}`,children:n}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:u(`promptSourceDefaultEmpty`)}),!t.trim()&&n.trim()&&(0,X.jsx)(`button`,{type:`button`,className:`override-seed-btn`,title:u(`promptSourceSeedTip`),onClick:()=>ha(e,n),children:u(`promptSourceSeedButton`)})]})]}):(0,X.jsx)(`div`,{className:`source-default`,title:u(`promptSourceDefaultEditHint`),role:`button`,tabIndex:0,onClick:()=>ha(e,n),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),ha(e,n))},children:n.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?He[e]?` expanded`:` clamped`:``}`,children:n}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ma(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ma(e))},children:He[e]?u(`promptSourceCollapse`):u(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:u(`promptSourceDefaultEmpty`)})})]},e)}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-btn`,onClick:ga,disabled:!Ca,children:u(`promptResetAll`)})})]})]}),S===`prompt`&&!x&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Le,{className:`set-section-icon`}),u(`scmCommitMsgSettingsTitle`),(0,X.jsx)(Du,{text:u(`scmCommitMsgSettingsDesc`)})]}),(0,X.jsx)(Px,{mode:nt,onModeChange:it,draft:et,onDraftChange:tt,defaultPrompt:_.scmCommitMsgDefaultPrompt,placeholder:u(`scmCommitMsgPromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({scmCommitMsgPromptMode:e,scmCommitMsgPrompt:t})},hint:u(`scmCommitMsgSettingsHint`),focusRef:at})]}),S===`prompt`&&!x&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Y,{className:`set-section-icon`}),u(`planModePromptSettingsTitle`),(0,X.jsx)(Du,{text:u(`planModePromptSettingsDesc`)})]}),(0,X.jsx)(Px,{mode:lt,onModeChange:ut,draft:ot,onDraftChange:st,defaultPrompt:_.planModeDefaultPrompt,placeholder:u(`planModePromptPlaceholder`),rows:8,onCommit:(e,t)=>{Q({planModePromptMode:e,planModePrompt:t})},modeLabel:u(`planModePromptMode`),hint:u(`planModePromptSettingsHint`),focusRef:pt})]}),S===`scheduler`&&!x&&(0,X.jsx)(rb,{tasks:e.schedulerTasks,cwd:e.state?.cwd??``,models:_.subagentModels}),S===`prompt-history`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(rt,{className:`set-section-icon`}),u(`settingsPromptHistory`),(0,X.jsx)(Du,{text:u(`settingsPromptHistoryDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:u(`promptHistoryCount`,{n:String(bn)})})]}),bn===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`promptHistoryEmpty`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:u(`promptHistoryCount`,{n:String(bn)})}),(0,X.jsx)(Nx,{label:u(`promptHistoryMax`),tip:u(`promptHistoryMaxHint`),htmlFor:`ph-max`,children:(0,X.jsx)(`input`,{id:`ph-max`,className:`set-input`,type:`number`,min:1,max:500,step:1,value:String(vn.maxEntries),onChange:e=>{let t=Math.floor(Number(e.target.value)||0),n={...vn,maxEntries:t};yn(n)},onBlur:()=>{let e={...vn};(!Number.isFinite(e.maxEntries)||e.maxEntries<1)&&(e.maxEntries=1),e.maxEntries>500&&(e.maxEntries=500),e.maxEntries=Math.floor(e.maxEntries),yn(e),y_(e),wn()}})}),(0,X.jsx)(Dx,{title:u(`promptHistoryCharLimit`),tip:u(`promptHistoryCharLimitHint`),enabled:vn.charLimitEnabled,onToggle:()=>{let e={...vn,charLimitEnabled:!vn.charLimitEnabled};yn(e),y_(e),wn()}}),vn.charLimitEnabled&&(0,X.jsx)(Nx,{label:u(`promptHistoryCharLimit`),htmlFor:`ph-char-limit`,children:(0,X.jsx)(`input`,{id:`ph-char-limit`,className:`set-input`,type:`number`,min:100,max:2e4,step:100,placeholder:u(`promptHistoryCharLimitPlaceholder`),value:String(vn.charLimit),onChange:e=>{let t=Math.floor(Number(e.target.value)||0);yn({...vn,charLimit:t})},onBlur:()=>{let e=Math.floor(Number(vn.charLimit)||0);(!Number.isFinite(e)||e<100)&&(e=100),e>2e4&&(e=2e4);let t={...vn,charLimit:e};yn(t),y_(t),wn()}})}),(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:12},children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${Sn?` confirm`:``}`,disabled:bn===0,title:u(bn===0?`promptHistoryEmpty`:`promptHistoryClear`),onClick:()=>{if(!Sn){Cn(!0);return}T_(),Cn(!1),wn()},children:[(0,X.jsx)(L,{}),` `,u(Sn?`promptHistoryClearConfirm`:`promptHistoryClear`)]}),bn>0&&(0,X.jsx)(`span`,{className:`set-hint`,style:{marginLeft:8},children:u(`promptHistoryCount`,{n:String(bn)})})]}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[(0,X.jsx)(St,{style:{verticalAlign:`-2px`,marginRight:4}}),u(`settingsPromptHistoryDesc`)]})]}),S===`tools`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(R,{className:`set-section-icon`}),u(`settingsTools`)]}),Kr&&(0,X.jsxs)(`p`,{className:`set-catalog-hint warn`,children:[u(`toolsPresetBanner`,{name:Jr,count:Xr+Zr}),` `,(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>$({type:`dsh_preset_default`,preset:`standard`}),children:u(`toolsBackToStandard`)})]}),(0,X.jsx)(Dx,{title:u(`readDirEnabled`),tip:u(`readDirEnabledDesc`),enabled:_.readDirEnabled!==!1,onToggle:()=>Q({readDirEnabled:_.readDirEnabled===!1})}),!x&&(0,X.jsx)(Dx,{title:u(`toolLazyLoading`),tip:u(`toolLazyLoadingDesc`),enabled:_.toolLazyLoading!==!1,onToggle:()=>Q({toolLazyLoading:_.toolLazyLoading===!1})}),(0,X.jsx)(Dx,{title:u(`toolApprovalEnabled`),tip:u(`toolApprovalEnabledDesc`),enabled:_.toolApprovalEnabled!==!1,onToggle:()=>Q({toolApprovalEnabled:_.toolApprovalEnabled===!1}),action:x?void 0:(0,X.jsxs)(`button`,{type:`button`,className:`tpl-chip`,onClick:()=>C(`approval-rules`),title:u(`settingsApprovalRulesDesc`),children:[(0,X.jsx)(ce,{}),` `,u(`manageApprovalRules`)]})}),e.dshPermission&&e.dshPermission.options.length>0&&(0,X.jsxs)(`div`,{className:`set-mode-row`,style:{marginTop:8,marginBottom:8},children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`dshPermDefault`),(0,X.jsx)(Du,{text:u(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:tv.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:u(nv(e))},e))})]}),v?.allowAll||(v?.categories.length??0)>0?(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`toolApprovalPolicyTitle`),(0,X.jsx)(Du,{text:u(`toolApprovalPolicyHint`)})]}),v?.allowAll&&(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:u(`toolApprovalPolicyAllowAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,allowAll:!1}),children:u(`toolApprovalPolicyRevoke`)})]}),(v?.categories??[]).map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:d===`zh`?e.label:e.labelEn}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,categories:(v?.categories??[]).filter(t=>t.id!==e.id).map(e=>e.id)}),children:u(`toolApprovalPolicyRevoke`)})]},e.id))]}):null,(0,X.jsx)(Nx,{label:u(`toolWatchdogTimeout`),tip:u(`toolWatchdogTimeoutDesc`),htmlFor:`tool-watchdog-timeout`,children:(0,X.jsx)(`input`,{id:`tool-watchdog-timeout`,className:`set-input`,type:`number`,min:0,step:1,placeholder:u(`toolWatchdogOff`),value:Cr,onChange:e=>wr(e.target.value),onBlur:()=>{let e=Cr.trim(),t=e===``?20:Math.max(0,Math.floor(Number(e)||0));wr(String(t));let n=t*6e4;n!==_.toolWatchdogTimeoutMs&&Q({toolWatchdogTimeoutMs:n})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`toolsSectionCore`),(0,X.jsx)(Du,{text:u(`toolsCoreHint`)})]}),Nr.map(e=>{let t=Yr(e);return(0,X.jsx)(Dx,{title:e,tip:yi[e],action:Qt(e),subtitle:t?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Ur.has(e),disabled:t,onToggle:()=>bi(e)},e)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:u(`toolsSectionTerminal`)}),fr.map(e=>{let t=Yr(e);return(0,X.jsx)(Dx,{title:e,tip:u(`settingsTerminalToolsDesc`),action:Qt(e),subtitle:t?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Ur.has(e),disabled:t,onToggle:()=>bi(e)},e)}),(0,X.jsx)(Dx,{title:u(`terminalBashTakeover`),tip:u(`terminalBashTakeoverDesc`),enabled:_.terminalBash,onToggle:()=>Q({terminalBash:!_.terminalBash})}),_.terminalBash&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Nx,{label:u(`terminalBashIdleMs`),tip:u(`terminalBashIdleMsDesc`),htmlFor:`tb-idle-ms`,children:(0,X.jsx)(`input`,{id:`tb-idle-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:yr,onChange:e=>br(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(yr)||0));br(String(e)),e!==_.terminalBashIdleMs&&Q({terminalBashIdleMs:e})}})}),(0,X.jsx)(Nx,{label:u(`terminalBashMaxForegroundMs`),tip:u(`terminalBashMaxForegroundMsDesc`),htmlFor:`tb-max-ms`,children:(0,X.jsx)(`input`,{id:`tb-max-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:xr,onChange:e=>Sr(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(xr)||0));Sr(String(e)),e!==_.terminalBashMaxForegroundMs&&Q({terminalBashMaxForegroundMs:e})}})})]}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`toolsSectionSubagent`),` `,(0,X.jsx)(Du,{text:u(`toolsSubagentDepHint`)})]}),pr.map(e=>{let t=Yr(e);return(0,X.jsx)(Dx,{title:e,tip:vi[e],action:Qt(e),subtitle:t?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Ur.has(e),disabled:t,onToggle:()=>bi(e)},e)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`settingsMarkers`),(0,X.jsx)(Du,{text:`${u(`settingsMarkersDesc`)}\n${u(`markerRenameTip`)}`})]}),(0,X.jsx)(Dx,{title:u(`markersEnabled`),tip:`${u(`markersEnabledDesc`)}\n${u(`markersOffHint`)}`,enabled:wi,onToggle:()=>Q({markersEnabled:!wi})}),wi&&(_.markers?.length??0)===0&&(0,X.jsxs)(`p`,{className:`set-empty`,children:[u(`loading`),`...`]}),wi&&_.markers&&_.markers.length>0&&_.markers.map(e=>(0,X.jsx)(Dx,{title:e.name===`todo`?u(`markerGroupTodo`):e.name===`notify`?u(`markerGroupNotify`):e.name===`conv`?u(`markerGroupRename`):e.name===`action`?u(`markerGroupAction`):e.name,tip:e.guidance.join(`
676
+ `),enabled:e.enabled,onToggle:()=>Ei(e.name)},e.name)),(0,X.jsx)(Dx,{title:`todo_list`,tip:`${u(`todoListEnabledDesc`)}\n${u(`todoListOffHint`)}`,action:Qt(`todo_list`),subtitle:Yr(`todo_list`)?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!Yr(`todo_list`)&&!Ur.has(`todo_list`),disabled:Yr(`todo_list`),onToggle:()=>bi(`todo_list`)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:u(`toolsSectionOther`)}),xx.map(e=>{let t=Yr(e.name),n=e.name===`codemode`&&!t&&!Ur.has(e.name);return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(Dx,{title:e.name,tip:`${f(e.descKey??e.name)}\n${f(e.offHintKey??e.name)}`,action:Qt(e.name),subtitle:t?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Ur.has(e.name),disabled:t,onToggle:()=>bi(e.name)}),n&&(0,X.jsxs)(`div`,{className:`sub-settings-block`,style:{marginLeft:24,marginTop:-6,marginBottom:12,padding:`10px 14px`,borderRadius:6,backgroundColor:`var(--bg-elev2, rgba(255,255,255,0.03))`,border:`1px solid var(--border-subtle, rgba(255,255,255,0.08))`,display:`flex`,flexDirection:`column`,gap:8},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,X.jsxs)(`label`,{className:`set-field-label`,style:{margin:0,fontSize:13},children:[u(`codemodeModeLabel`),(0,X.jsx)(Du,{text:u(`codemodeModeHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,style:{width:`auto`,minWidth:140},value:_.codemodeMode??`on`,onChange:e=>Q({codemodeMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`on`,children:u(`codemodeModeOn`)}),(0,X.jsx)(`option`,{value:`only`,children:u(`codemodeModeOnly`)})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,X.jsxs)(`label`,{className:`set-field-label`,style:{margin:0,fontSize:13},children:[u(`codemodeInlineBudgetLabel`),(0,X.jsx)(Du,{text:u(`codemodeInlineBudgetHint`)})]}),(0,X.jsx)(`input`,{type:`number`,className:`set-input`,style:{width:100,textAlign:`right`},min:500,max:5e4,step:500,value:_.codemodeInlineBudget??3e3,onChange:e=>{let t=parseInt(e.target.value,10);!isNaN(t)&&t>0&&Q({codemodeInlineBudget:t})}})]})]})]},e.name)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`toolsSectionPlugin`),(0,X.jsx)(Du,{text:u(`toolsPluginHint`)})]}),Ci.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:e.plugins.length===0?u(`noUiPlugins`):u(`pluginToolsEmpty`)}):Ci.map(e=>{let t=pi.has(e.plugin.id);return(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[e.plugin.icon?`${e.plugin.icon} `:``,e.plugin.name,` · `,e.plugin.id,t?` (${u(`pluginDisabledInPlugins`)})`:``]}),e.tools.map(e=>(0,X.jsx)(Dx,{title:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name,tip:e.description?`${e.description}\n${u(`pluginToolOffHint`)}`:u(`pluginToolOffHint`),action:Qt(e.name),subtitle:t?u(`pluginToolsDisabledByPlugin`):Kr?u(`toolsBlockedByPreset`,{name:Jr}):void 0,enabled:!t&&!Kr&&!xi.has(e.name),disabled:t||Kr,onToggle:()=>!t&&!Kr&&Si(e.name)},e.name))]},e.plugin.id)})]}),S===`question`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ne,{className:`set-section-icon`}),u(`settingsQuestionnaire`)]}),(0,X.jsx)(Dx,{title:u(`questionnaireEnabled`),tip:`${u(`questionnaireEnabledDesc`)}\n${u(`questionnaireOffHint`)}`,enabled:_.questionnaireEnabled,onToggle:()=>Q({questionnaireEnabled:!_.questionnaireEnabled})})]}),S===`display`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(J,{className:`set-section-icon`}),u(`settingsMessageDisplay`)]}),(0,X.jsx)(Nx,{label:u(`softCapTokens`),tip:u(`softCapHint`),htmlFor:`soft-cap-max`,children:(0,X.jsx)(`input`,{id:`soft-cap-max`,className:`set-input`,type:`text`,placeholder:u(`softCapOff`),value:kr,onChange:e=>Ar(e.target.value),onBlur:()=>{let e=pb(kr);Ar(mb(e)),e!==(_.softCapTokens??0)&&Q({softCapTokens:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-section-title`,children:[u(`softCapByModel`),(0,X.jsx)(Du,{text:u(`softCapByModelHint`)})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`softCapModelId`),value:jr,maxLength:200,onChange:e=>Pr(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,placeholder:u(`softCapTokens`),value:Fr,onChange:e=>Rr(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&jr.trim()&&pb(Fr)>0){let e=pb(Fr);Q({softCapByModel:{..._.softCapByModel,[jr.trim()]:e}}),Pr(``),Rr(``)}}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!jr.trim()||pb(Fr)<=0,onClick:()=>{let e=jr.trim(),t=pb(Fr);!e||t<=0||(Q({softCapByModel:{..._.softCapByModel,[e]:t}}),Pr(``),Rr(``))},children:[(0,X.jsx)(me,{}),` `,u(`softCapAdd`)]})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Object.entries(_.softCapByModel).map(([e,t])=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-row-name`,children:e}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,defaultValue:mb(t),onBlur:t=>{let n=pb(t.target.value);t.target.value=mb(n);let r={..._.softCapByModel};n>0?r[e]=n:delete r[e],Q({softCapByModel:r})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}},`${e}:${t}`),(0,X.jsxs)(`button`,{type:`button`,className:`chip`,title:u(`softCapRemove`),onClick:()=>{let t={..._.softCapByModel};delete t[e],Q({softCapByModel:t})},children:[(0,X.jsx)(P,{}),` `,u(`softCapRemove`)]})]},e))}),(0,X.jsx)(Nx,{label:u(`modelRetryAttempts`),tip:u(`modelRetryHint`),htmlFor:`model-retry-max`,children:(0,X.jsx)(`input`,{id:`model-retry-max`,className:`set-input`,type:`number`,min:0,max:100,step:1,value:Tr,onChange:e=>Er(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(0,Math.floor(Number(Tr)||0)));Er(String(e)),e!==_.retryMaxAttempts&&Q({retryMaxAttempts:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(Dx,{title:u(`thinkingWrap`),tip:u(`thinkingWrapDesc`),enabled:_.thinkingWrap??!0,onToggle:()=>Q({thinkingWrap:!(_.thinkingWrap??!0)})}),(0,X.jsx)(Dx,{title:u(`toolsWrap`),tip:u(`toolsWrapDesc`),enabled:_.toolsWrap??!0,onToggle:()=>Q({toolsWrap:!(_.toolsWrap??!0)})}),(0,X.jsx)(Dx,{title:u(`toolImages`),tip:u(`toolImagesDesc`),enabled:_.toolImagesEnabled??!0,onToggle:()=>Q({toolImagesEnabled:!(_.toolImagesEnabled??!0)})}),(0,X.jsx)(Nx,{label:u(`keepRecent`),tip:u(`keepRecentDesc`),htmlFor:`keep-recent`,children:(0,X.jsx)(`input`,{id:`keep-recent`,className:`set-input`,type:`number`,min:5,max:100,step:1,value:Dr,onChange:e=>Or(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(5,Math.floor(Number(Dr)||15)));Or(String(e)),e!==_.keepRecentMessages&&Q({keepRecentMessages:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(Dx,{title:u(`presentAutoOpen`),tip:u(`presentAutoOpenDesc`),enabled:an,onToggle:()=>Fp(!an)}),(0,X.jsx)(Dx,{title:u(`parallelReminderEnabled`),tip:`${u(`parallelReminderEnabledDesc`)}\n${u(`parallelReminderOffHint`)}`,enabled:_.parallelReminderEnabled??!0,onToggle:()=>Q({parallelReminderEnabled:!(_.parallelReminderEnabled??!0)})}),(0,X.jsx)(Dx,{title:u(`devNoCache`),tip:u(`devNoCacheDesc`),enabled:_.devNoCache??!0,onToggle:()=>Q({devNoCache:!(_.devNoCache??!0)})}),(0,X.jsx)(Dx,{title:u(`autoReload`),tip:u(`autoReloadDesc`),enabled:_.autoReload??!0,onToggle:()=>Q({autoReload:!(_.autoReload??!0)})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsx)(Dx,{title:u(`wideChat`),tip:u(`wideChatDesc`),enabled:rn,onToggle:()=>yb({wide:!rn})}),(0,X.jsx)(Dx,{title:u(`projectTitle`),tip:u(`projectTitleDesc`),enabled:sn,onToggle:()=>Ab({projectName:!sn})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[u(`wallpaperTitle`),(0,X.jsx)(Du,{text:u(`wallpaperDesc`)})]}),(0,X.jsxs)(`div`,{className:`wallpaper-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input wallpaper-url`,placeholder:u(`wallpaperUrlPh`),value:ln,maxLength:2e3,spellCheck:!1,onFocus:()=>{dn.current=!0},onChange:e=>un(e.target.value),onBlur:()=>{if(dn.current=!1,!ln.trim()&&cn.url.startsWith(`data:`)){un(``);return}let e=Vb(ln);un(e),e!==cn.url&&Jb({...cn,url:e})},onKeyDown:e=>{e.key===`Enter`?e.target.blur():e.key===`Escape`&&(un(cn.url.startsWith(`data:`)?``:cn.url),e.target.blur())}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:pn,onClick:()=>fn.current?.click(),children:[(0,X.jsx)(re,{}),` `,u(`wallpaperUpload`)]}),(0,X.jsx)(`input`,{ref:fn,type:`file`,accept:`image/*`,hidden:!0,onChange:_n})]}),hn&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`wallpaperUploadFailed`)}),(0,X.jsxs)(`div`,{className:`wallpaper-sliders`,children:[(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:u(`wallpaperDim`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:95,step:1,value:cn.dim,onChange:e=>Jb({...cn,dim:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[cn.dim,`%`]})]}),(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:u(`wallpaperBlur`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:24,step:1,value:cn.blur,onChange:e=>Jb({...cn,blur:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[cn.blur,`px`]})]})]})]}),cn.url&&(0,X.jsxs)(`div`,{className:`wallpaper-current`,children:[(0,X.jsx)(`img`,{className:`wallpaper-preview`,src:cn.url,alt:``}),(0,X.jsx)(`button`,{type:`button`,className:`wallpaper-clear`,onClick:()=>{un(``),Jb({...cn,url:``})},children:u(`wallpaperClear`)})]})]})]}),S===`sound`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ne,{className:`set-section-icon`}),u(`settingsSoundVoice`)]}),(0,X.jsx)(Fn,{settings:o,onChange:s,onPreview:e=>fb(e,o)}),(0,X.jsx)(Ln,{settings:c,onChange:l,onPreview:()=>on(u(`ttsPreviewLine`),{...c,enabled:!0})})]}),S===`quick`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(de,{className:`set-section-icon`}),u(`quickPhrases`),(0,X.jsx)(Du,{text:u(`quickPhrasesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.quickPhrases.length})]}),(0,X.jsx)(Dx,{title:u(`quickPhrasesEnabled`),tip:u(`quickPhrasesDesc`),enabled:_.quickPhrasesEnabled,onToggle:()=>Q({quickPhrasesEnabled:!_.quickPhrasesEnabled})}),!_.quickPhrasesEnabled&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`quickPhrasesOffHint`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`quickPhrasesPlaceholder`),value:hr,maxLength:200,onChange:e=>gr(e.target.value),onKeyDown:e=>{e.key===`Enter`&&hr.trim()&&(Q({quickPhrases:[..._.quickPhrases,hr.trim()]}),gr(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!hr.trim(),onClick:()=>{Q({quickPhrases:[..._.quickPhrases,hr.trim()]}),gr(``)},children:[(0,X.jsx)(me,{}),` `,u(`quickPhrasesAdd`)]})]}),_.quickPhrases.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`quickPhrasesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.quickPhrases.map((e,t)=>(0,X.jsx)(`div`,{className:`set-row`,children:_r?.index===t?(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`input`,{className:`set-input`,autoFocus:!0,value:_r.value,maxLength:200,placeholder:u(`quickPhrasesEditPh`),onChange:e=>vr({index:t,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?li():e.key===`Escape`&&vr(null)},onBlur:li})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`div`,{className:`set-row-name`,title:e,children:e})}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`quickPhrasesEdit`),onClick:()=>vr({index:t,value:e}),children:(0,X.jsx)(Y,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`quickPhrasesMoveUp`),disabled:t===0,onClick:()=>{let e=[..._.quickPhrases];[e[t-1],e[t]]=[e[t],e[t-1]],Q({quickPhrases:e})},children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`quickPhrasesMoveDown`),disabled:t===_.quickPhrases.length-1,onClick:()=>{let e=[..._.quickPhrases];[e[t],e[t+1]]=[e[t+1],e[t]],Q({quickPhrases:e})},children:`↓`}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`quickPhrasesDelete`),onClick:()=>Q({quickPhrases:_.quickPhrases.filter((e,n)=>n!==t)}),children:(0,X.jsx)(L,{})})]})]})},`${t}:${e}`))}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{vr(null),Q({quickPhrases:mx[d]??mx.en})},children:u(`quickPhrasesReset`)})})]}),S===`skills`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ze,{className:`set-section-icon`}),u(`settingsSkills`),(0,X.jsx)(Du,{text:`${u(`skillFullTextLabel`)}:${u(`skillFullTextDesc`)}`}),(0,X.jsx)(`span`,{className:`set-count`,children:_.skills.length})]}),(0,X.jsxs)(`div`,{className:`mcp-tab-bar`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tab-btn${O===`installed`?` active`:``}`,onClick:()=>k(`installed`),children:[(0,X.jsx)(Ze,{}),(0,X.jsx)(`span`,{children:u(`skillTabInstalled`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.skills.length})]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-tab-btn${O===`market`?` active`:``}`,onClick:()=>k(`market`),children:[(0,X.jsx)(se,{}),(0,X.jsx)(`span`,{children:u(`skillTabMarket`)}),(0,X.jsx)(`span`,{className:`set-count`,children:Zy.length})]})]}),O===`installed`&&(0,X.jsxs)(X.Fragment,{children:[!x&&Kr&&!Lr(Gr??void 0)&&(0,X.jsx)(`p`,{className:`set-catalog-hint warn`,children:u(`skillsHiddenByPreset`,{name:Jr})}),_.skills.length===0?(0,X.jsxs)(`div`,{className:`mcp-empty-card`,children:[(0,X.jsx)(`div`,{className:`mcp-empty-icon`,children:(0,X.jsx)(Ze,{})}),(0,X.jsx)(`div`,{className:`mcp-empty-title`,children:u(x?`dshSkillsNote`:`noSkills`)}),(0,X.jsx)(`div`,{className:`mcp-empty-desc`,children:u(`skillEmptyDesc`)}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-goto-market-btn`,onClick:()=>k(`market`),children:[(0,X.jsx)(se,{}),u(`skillBrowseMarket`)]})]}):(0,X.jsx)(`div`,{className:`set-list`,children:_.skills.map(e=>(0,X.jsx)(Dx,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>ui(e),action:(0,X.jsx)(`button`,{type:`button`,className:`tpl-chip${di.has(e.name)?` on`:``}`,title:u(`skillFullTextDesc`),onClick:()=>fi(e.name),children:u(`skillFullTextShort`)})},e.name))})]}),O===`market`&&(0,X.jsxs)(`div`,{className:`skill-market-view`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-toolbar`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-source-row`,children:[(0,X.jsxs)(`div`,{className:`mcp-source-select-wrap`,children:[(0,X.jsxs)(`label`,{className:`mcp-source-label`,children:[u(`skillRepoSelect`),`:`]}),(0,X.jsxs)(`select`,{className:`set-select mcp-source-select`,value:te,onChange:e=>ie(e.target.value),children:[(0,X.jsx)(`option`,{value:`anthropics/skills`,children:u(`skillRepoDefault`)}),(0,X.jsx)(`option`,{value:`custom`,children:u(`skillRepoCustom`)})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn mcp-sync-btn${z?` spinning`:``}`,title:u(`mcpReload`),onClick:()=>ve(!0),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:u(`mcpReload`)})]})]}),te===`custom`&&(0,X.jsx)(`div`,{className:`mcp-custom-source-row`,children:(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-custom-input`,placeholder:u(`skillRepoCustomPlaceholder`),value:ae,onChange:e=>I(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ve(!0)}})}),(0,X.jsxs)(`div`,{className:`mcp-search-wrap`,children:[(0,X.jsx)(fe,{className:`mcp-search-icon`}),(0,X.jsx)(`input`,{type:`text`,className:`set-input mcp-search-input`,placeholder:u(`skillMarketSearchPlaceholder`),value:ee,onChange:e=>M(e.target.value)}),ee&&(0,X.jsx)(`button`,{type:`button`,className:`mcp-search-clear`,onClick:()=>M(``),children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`div`,{className:`mcp-category-chips`,children:[{id:`all`,label:u(`skillCatAll`)},{id:`quality`,label:u(`skillCatQuality`)},{id:`workflow`,label:u(`skillCatWorkflow`)},{id:`architecture`,label:u(`skillCatArchitecture`)},{id:`devops`,label:u(`skillCatDevops`)},{id:`stack`,label:u(`skillCatStack`)}].map(e=>(0,X.jsx)(`button`,{type:`button`,className:`mcp-cat-chip${A===e.id?` active`:``}`,onClick:()=>j(e.id),children:e.label},e.id))})]}),e.skillMarketResult?.error&&(0,X.jsxs)(`div`,{className:`mcp-error-box`,children:[(0,X.jsx)(wt,{className:`mcp-error-icon`}),(0,X.jsx)(`div`,{className:`mcp-error-text`,children:e.skillMarketResult.error}),(0,X.jsx)(`button`,{type:`button`,className:`mcp-mini-btn`,onClick:()=>ve(!0),children:u(`skillMarketRetry`)})]}),z&&(0,X.jsxs)(`div`,{className:`mcp-market-loading`,children:[(0,X.jsx)(K,{className:`spinning`}),(0,X.jsx)(`span`,{children:u(`skillMarketLoading`)})]}),(0,X.jsx)(`div`,{className:`mcp-market-grid`,children:be.map(e=>{let t=ge.has(e.id.toLowerCase()),n=d===`zh`?e.descriptionZh:e.description,r=d===`zh`?e.nameZh:e.name;return(0,X.jsxs)(`div`,{className:`mcp-market-card skill-market-card`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-card-head`,children:[(0,X.jsxs)(`div`,{className:`mcp-market-title-wrap`,children:[(0,X.jsx)(`span`,{className:`mcp-market-name`,children:e.name}),d===`zh`&&(0,X.jsxs)(`span`,{className:`mcp-market-subname`,children:[`(`,r,`)`]})]}),(0,X.jsx)(`span`,{className:`mcp-badge-official`,children:Ce(e.category)})]}),(0,X.jsx)(`p`,{className:`mcp-market-desc`,children:n}),(0,X.jsxs)(`div`,{className:`skill-market-card-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`skill-inspect-btn`,onClick:()=>V(e),children:[(0,X.jsx)(Ue,{}),u(`skillInspectPrompt`)]}),(0,X.jsx)(`div`,{className:`skill-action-btns`,children:t?(0,X.jsxs)(`div`,{className:`skill-installed-group`,children:[(0,X.jsxs)(`span`,{className:`mcp-market-configured-badge`,children:[(0,X.jsx)(ft,{}),u(`skillInstalled`)]}),(0,X.jsx)(`button`,{type:`button`,className:`icon-btn delete-btn`,title:u(`uninstallTitle`),onClick:()=>Se(e.id,`global`),children:(0,X.jsx)(L,{})})]}):(0,X.jsxs)(`div`,{className:`mcp-market-add-btns`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mcp-btn-add global`,title:u(`skillInstallGlobalHint`),onClick:()=>xe(e,`global`),children:[(0,X.jsx)(me,{}),u(`skillInstallGlobal`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`mcp-btn-add project`,title:u(`skillInstallProjectHint`),onClick:()=>xe(e,`project`),children:[(0,X.jsx)(me,{}),u(`skillInstallProject`)]})]})})]})]},e.id)})})]}),B&&(0,X.jsx)(`div`,{className:`modal-backdrop sub-modal`,onClick:()=>V(null),children:(0,X.jsxs)(`div`,{className:`modal skill-inspect-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":u(`close`),onClick:()=>V(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ze,{className:`modal-head-icon`}),(0,X.jsx)(`h3`,{children:u(`skillInspectModalTitle`,{name:B.name})})]}),(0,X.jsx)(`div`,{className:`modal-body skill-inspect-body`,children:G===B.id&&!B.content?(0,X.jsxs)(`div`,{className:`mcp-market-loading`,children:[(0,X.jsx)(K,{className:`spinning`}),(0,X.jsx)(`span`,{children:u(`skillContentLoading`)})]}):(0,X.jsx)(`pre`,{className:`skill-code-preview`,children:(0,X.jsx)(`code`,{children:B.content})})}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-cancel-btn`,onClick:()=>V(null),children:u(`close`)}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn global`,onClick:()=>xe(B,`global`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:u(`skillInstallGlobal`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn project`,onClick:()=>xe(B,`project`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:u(`skillInstallProject`)})]})]})]})})]}),S===`extensions`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(q,{className:`set-section-icon`}),u(`settingsExtensions`),(0,X.jsx)(`span`,{className:`set-count`,children:_.extensions.length})]}),_.extensions.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(x?`dshExtensionsNote`:`noExtensions`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.extensions.map(e=>{let t=e.id.startsWith(`npm:`)?e.id.slice(4):null;return(0,X.jsx)(Dx,{title:e.name,subtitle:e.path,enabled:e.enabled,onToggle:()=>_i(e),action:t?Tn===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:u(`uninstallConfirmHint`),onClick:()=>Oi(t),children:u(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`uninstallHint`),onClick:()=>En(e.id),children:[(0,X.jsx)(L,{}),u(`uninstallExt`)]}):void 0},e.id)})})]}),S===`layout`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(H,{className:`set-section-icon`}),u(`uiLayoutTitle`),a&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,style:{marginLeft:`auto`},title:u(`uiIconEditHint`),onClick:a,children:[(0,X.jsx)(Ke,{}),u(`uiIconEdit`)]}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,style:a?void 0:{marginLeft:`auto`},onClick:Xi,children:u(`uiLayoutRestoreAll`)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:u(`uiLayoutHint`)}),(0,X.jsxs)(`label`,{className:`set-toggle`,title:`sideDockFloat`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Bi?.sideDockFloat===!0,onChange:e=>Vi({sideDockFloat:e.target.checked})}),(0,X.jsx)(`span`,{children:u(`uiLayoutSideDockFloat`)})]}),zr.length>0&&(0,X.jsxs)(`details`,{className:`set-ui-diag`,open:zr.some(e=>e.level===`error`),children:[(0,X.jsxs)(`summary`,{children:[`⚠ `,u(`uiLayoutDiagTitle`,{n:zr.length})]}),(0,X.jsx)(`ul`,{className:`set-ui-diag-list`,children:zr.map((e,t)=>(0,X.jsxs)(`li`,{className:`set-ui-diag-item ${e.level}`,children:[e.pluginId?(0,X.jsx)(`code`,{children:e.pluginId}):null,e.entryId?(0,X.jsx)(`code`,{children:e.entryId}):null,(0,X.jsx)(`span`,{children:e.message})]},`${e.pluginId??`host`}:${e.entryId??t}`))}),(0,X.jsx)(`div`,{className:`set-ui-diag-hint`,children:u(`uiLayoutDiagHint`)})]}),(0,X.jsx)(`input`,{className:`set-ui-filter`,value:Li,placeholder:u(`uiLayoutSearch`),"aria-label":u(`uiLayoutSearch`),onChange:e=>Ri(e.target.value)}),Ni.map(({slot:e,labelKey:t})=>{let n=(Br[e]??[]).filter(e=>(x||e.id!==`host:composer-dsh-perm`&&e.id!==`host:composer-dsh-preset`&&e.id!==`host:goal-plan`)&&!Ji.has(e.id)),r=Li.trim().toLowerCase(),i=!r&&Pi.includes(e)?[`start`,`center`,`end`].map(e=>({align:e,items:n.filter(t=>t.align===e)})).filter(e=>e.items.length>0):[{align:null,items:r?n.filter(e=>`${e.label} ${e.id} ${e.source}`.toLowerCase().includes(r)):n}],a=i.reduce((e,t)=>e+t.items.length,0);if(r&&a===0)return null;let o=(t,i)=>{let a=i.findIndex(e=>e.id===t.id),o=qi.has(t.id);return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`label`,{className:`set-toggle`,title:o?u(`uiLayoutRequired`):t.id,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!t.hidden,disabled:o,onChange:()=>Hi(t)}),(0,X.jsxs)(`span`,{children:[t.icon?`${t.icon} `:``,t.label]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t.arrangedBy.length>0&&(0,X.jsx)(`span`,{className:`set-ui-source`,title:t.arrangedBy.join(`, `),children:u(`uiLayoutArranged`)}),t.movedFrom&&(0,X.jsxs)(`span`,{className:`set-ui-source`,title:t.id,children:[u(`uiLayoutMovedFrom`),`: `,zi(t.movedFrom)]}),Ii.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:u(`uiLayoutPosition`),children:(0,X.jsxs)(`select`,{value:e,onChange:e=>Gi(t.id,e.target.value),"aria-label":u(`uiLayoutPosition`),children:[(0,X.jsx)(`option`,{value:`topbar.primary`,children:u(`uiLayoutPosTop`)}),(0,X.jsx)(`option`,{value:`bottombar`,children:u(`uiLayoutPosBottom`)}),(0,X.jsx)(`option`,{value:`sidebar.left`,children:u(`uiLayoutPosLeft`)}),(0,X.jsx)(`option`,{value:`sidebar.right`,children:u(`uiLayoutPosRight`)})]})}),Pi.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:u(`uiLayoutAlign`),children:(0,X.jsx)(`select`,{value:t.align,onChange:e=>Wi(t.id,e.target.value),"aria-label":u(`uiLayoutAlign`),children:Fi(e)?vv.map(e=>(0,X.jsx)(`option`,{value:e,children:yv(u,e)},e)):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`option`,{value:`start`,children:`start`}),(0,X.jsx)(`option`,{value:`center`,children:`center`}),(0,X.jsx)(`option`,{value:`end`,children:`end`})]})})}),(0,X.jsx)(`input`,{className:`set-ui-label`,defaultValue:Bi?.labels?.[t.id]??``,placeholder:u(`uiLayoutRename`),title:u(`uiLayoutRename`),"aria-label":u(`uiLayoutRename`),onBlur:e=>{e.target.value!==(Bi?.labels?.[t.id]??``)&&Ki(t.id,e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.target.blur()}},`${t.id}:${Bi?.labels?.[t.id]??``}`),t.userOverrides.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Yi(t.id),children:u(`uiLayoutRestore`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<=0,onClick:()=>Ui(n,i,t.id,-1),children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<0||a>=i.length-1,onClick:()=>Ui(n,i,t.id,1),children:`↓`})]})]},t.id)};return(0,X.jsxs)(`div`,{className:`set-ui-slot`,children:[(0,X.jsx)(`div`,{className:`set-ui-slot-title`,children:u(t)}),e===`topbar.primary`&&(0,X.jsxs)(`label`,{className:`set-toggle`,title:`topbarText`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Bi?.topbarText!==!1,onChange:e=>Vi({topbarText:e.target.checked})}),(0,X.jsx)(`span`,{children:u(`uiLayoutTopbarText`)})]}),n.length===0?(0,X.jsx)(`div`,{className:`set-empty`,children:u(`uiLayoutEmpty`)}):i.map(t=>(0,X.jsxs)(g.Fragment,{children:[t.align&&(0,X.jsx)(`div`,{className:`set-ui-slot-title set-ui-seg`,children:Fi(e)?yv(u,t.align):t.align}),t.items.map(e=>o(e,t.items))]},t.align??`all`))]},e)})]}),S===`plugins`&&!b&&(0,X.jsxs)(`div`,{className:`set-subtabs`,role:`tablist`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":w===`market`,className:`set-subtab${w===`market`?` active`:``}`,onClick:()=>{T(`market`),E.current?.scrollTo({top:0})},children:[u(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":w===`installed`,className:`set-subtab${w===`installed`?` active`:``}`,onClick:()=>{T(`installed`),E.current?.scrollTo({top:0})},children:[(0,X.jsx)(ht,{}),u(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(ri||ii)&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]})]}),S===`plugins`&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Re,{className:`set-section-icon`}),u(`pluginGrantsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginGrants.reduce((e,t)=>e+t.paths.length,0)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:u(`pluginGrantsHint`)}),e.pluginGrants.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`pluginGrantsEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:e.pluginGrants.map(e=>(0,X.jsxs)(`div`,{className:`set-grant-row`,children:[(0,X.jsx)(`div`,{className:`set-catalog-title`,children:(0,X.jsx)(`span`,{children:e.pluginId})}),e.paths.map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_path_revoke`,pluginId:e.pluginId,path:t}),children:u(`pluginGrantsRevoke`)})]},t))]},e.pluginId))})]}),S===`plugins`&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ae,{className:`set-section-icon`}),u(`pluginPermsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:(e.pluginPermissions??[]).length})]}),(0,X.jsx)(`div`,{className:`set-note`,children:u(`pluginPermsHint`)}),(e.pluginPermissions??[]).length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`pluginPermsEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:(e.pluginPermissions??[]).map((e,t)=>(0,X.jsxs)(`div`,{className:`set-grant-row`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-title`,children:[(0,X.jsx)(`span`,{children:e.pluginId}),(0,X.jsxs)(`span`,{className:`set-catalog-source`,children:[e.family===`net`?u(`pluginPermNet`):u(`pluginPermLlm`),e.session?` · ${u(`pluginPermSession`)}`:``]})]}),(e.hosts??[]).map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:`net`,host:t}),children:u(`pluginGrantsRevoke`)})]},t)),(e.models??[]).map(t=>(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:t}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:`llm`,model:t}),children:u(`pluginGrantsRevoke`)})]},t)),!(e.hosts??[]).length&&!(e.models??[]).length&&(0,X.jsxs)(`div`,{className:`set-grant-path`,children:[(0,X.jsx)(`span`,{className:`set-catalog-source`,children:e.reason??u(`pluginPermUnscoped`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:e.family}),children:u(`pluginGrantsRevoke`)})]}),e.reason&&((e.hosts??[]).length>0||(e.models??[]).length>0)&&(0,X.jsx)(`div`,{className:`set-note`,children:e.reason})]},`${e.pluginId}|${e.family}|${t}`))})]}),S===`plugins`&&b&&(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-note`,children:u(`updatesManaged`)})}),S===`plugins`&&!b&&w===`market`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(q,{className:`set-section-icon`}),u(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`div`,{className:`set-toolbar`,children:[(0,X.jsxs)(`a`,{href:`https://github.com/xing-shuyin/pi-web-ui-plugins`,target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialMarketHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialMarket`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:u(`pluginBuildHint`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Zn,onChange:e=>Qn(e.target.checked)}),u(`pluginBuildSource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCatalogSyncHint`),onClick:()=>er(e=>!e),children:[(0,X.jsx)(K,{}),u(`pluginCatalogSync`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCatalogAddHint`),onClick:()=>Xn(e=>!e),children:[(0,X.jsx)(me,{}),u(`pluginCatalogAdd`)]})]}),$n&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`div`,{className:`set-note`,children:u(`pluginCatalogSyncHint`)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogSyncSource`),value:tr,onChange:e=>nr(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ra(tr)}}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:u(`pluginCatalogSyncInstall`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:rr,onChange:e=>ir(e.target.checked)}),u(`pluginCatalogSyncInstall`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:u(`pluginCatalogSyncReplace`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:ar,onChange:e=>or(e.target.checked)}),u(`pluginCatalogSyncReplace`)]}),dr.length>0&&(0,X.jsxs)(`div`,{className:`set-catalog-recent`,children:[(0,X.jsx)(`span`,{className:`set-catalog-recent-label`,children:u(`pluginCatalogSyncRecent`)}),dr.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-catalog-recent-item`,title:e,onClick:()=>{nr(e),ra(e)},children:e},e))]}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!tr.trim(),onClick:()=>ra(tr),children:u(`pluginCatalogSyncSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>er(!1),children:u(`cancel`)})]}),ca&&(ca.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[(0,X.jsxs)(`span`,{children:[`✓ `,u(`pluginCatalogSyncOk`,{n:ca.entryCount??0}),ca.installed?` · ${u(`pluginCatalogSyncInstalled`,{ok:ca.installed.filter(e=>e.ok).length,fail:ca.installed.filter(e=>!e.ok).length})}`:null]}),ca.installed?.some(e=>!e.ok)&&(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:ca.installed.filter(e=>!e.ok).map(e=>`${e.id}:${e.error??`?`}`).join(`
677
+ `)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,ca.error||u(`pluginJobFailed`)]})}))]}),Yn&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogSource`),value:zn,onChange:e=>Bn(e.target.value)}),ji(sa),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogId`),value:Vn,onChange:e=>Hn(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogName`),value:Un,onChange:e=>Wn(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`pluginCatalogIcon`),value:qn,onChange:e=>Jn(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:u(`pluginCatalogDesc`),value:Gn,onChange:e=>Kn(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!zn.trim(),onClick:ta,children:u(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Xn(!1),children:u(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(t=>{let n=mi.has(t.id),r=e.pluginUpdates?.[t.id],i=n&&r?.updatable===!0,a=!!(Ai(t.id)&&Ai(t.id)?.phase!==`done`),o=d!==`zh`&&t.nameEn?t.nameEn:t.name,s=d!==`zh`&&t.descriptionEn?t.descriptionEn:t.description;return(0,X.jsxs)(`div`,{className:`set-catalog-row`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-main`,children:[(0,X.jsxs)(`div`,{className:`set-catalog-title`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(hi,{icon:t.icon,iconSvg:t.iconSvg}),` `,o]}),n&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:u(`pluginInstalled`)}),!t.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:u(`pluginCatalogCustom`)}),i&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:r?.latestVersion?`${r?.version??``} → v${r.latestVersion}`:r?.remoteSha??``,children:[u(`pluginUpdateAvailableBadge`),r?.latestVersion?` v${r.latestVersion}`:``]})]}),s&&(0,X.jsx)(`div`,{className:`set-catalog-desc`,children:s}),(0,X.jsx)(`div`,{className:`set-catalog-source`,children:t.source}),Mi(t.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[jx(t)&&(0,X.jsxs)(`a`,{href:jx(t),target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialLinkHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialLink`)]}),n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${i?` accent`:``}`,disabled:a,title:i&&r?.latestVersion?u(`pluginUpdateAvailableDetail`,{version:`v${r.latestVersion}`}):u(`pluginUpdateHint`),onClick:()=>Qi(t.id,t.source),children:[(0,X.jsx)(K,{className:a?`set-job-spin`:``}),u(a?`pluginJobRunning`:`pluginUpdate`)]}),Dn===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:a,title:u(`pluginUninstallHint`),onClick:()=>Zi(t.id),children:u(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:a,title:u(`pluginUninstallHint`),onClick:()=>On(t.id),children:[(0,X.jsx)(L,{}),u(`uninstallExt`)]})]}):(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginInstallHint`),disabled:a,onClick:()=>$i(t),children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{className:`set-job-spin`}),u(`pluginJobRunning`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qe,{}),u(`pluginInstall`)]})}),!t.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCatalogRemoveHint`),onClick:()=>ea(t.id),children:(0,X.jsx)(P,{})})]})]},t.id)})})]}),S===`plugins`&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ht,{className:`set-section-icon`}),u(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`a`,{href:`https://github.com/xing-shuyin/pi-web-ui-plugins`,target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialMarketHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialMarket`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginCheckUpdatesHint`),disabled:e.checkingPluginUpdates,onClick:()=>$({type:`check_plugin_updates`}),children:[(0,X.jsx)(K,{className:e.checkingPluginUpdates?`spin`:``}),e.checkingPluginUpdates?u(`checkingUpdate`):u(`pluginCheckUpdates`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(K,{}),u(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(Mx,{plugins:e.plugins,disabledIds:pi}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noUiPlugins`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.plugins.map(t=>{let n=e.pluginUpdates?.[t.id],r=n?.updatable===!0,i=!!(Ai(t.id)&&Ai(t.id)?.phase!==`done`);return(0,X.jsxs)(g.Fragment,{children:[(0,X.jsx)(Dx,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ax,{phase:fx(t,pi.has(t.id)),label:f(kx(fx(t,pi.has(t.id))))}),(0,X.jsx)(hi,{icon:t.icon,iconSvg:t.iconSvg}),` `,t.name,r&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:n?.latestVersion?`v${t.version??`0.0.0`} → v${n.latestVersion}`:n?.remoteSha??``,children:[u(`pluginUpdateAvailableBadge`),n?.latestVersion?` v${n.latestVersion}`:``]})]}),subtitle:(t.error?`${t.id} · ${t.error}`:t.source?`${t.id} · ${t.source}`:`${t.id} · ${u(`uiPluginNoSource`)}`)+(t.permissions?.length?` · ${u(`uiPluginPerms`)}: ${t.permissions.join(`, `)}`:``),enabled:!pi.has(t.id)&&!t.error,onToggle:()=>!t.error&&gi(t),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(()=>{let n=jx(e.pluginCatalog.find(e=>e.id===t.id))||jx(t);return n?(0,X.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer noopener`,className:`set-uninstall link`,title:u(`pluginOfficialLinkHint`),children:[(0,X.jsx)(Ge,{}),u(`pluginOfficialLink`)]}):null})(),t.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${r?` accent`:``}`,disabled:i,title:r&&n?.latestVersion?u(`pluginUpdateAvailableDetail`,{version:`v${n.latestVersion}`}):u(`pluginUpdateHint`),onClick:()=>Qi(t.id,t.source),children:[(0,X.jsx)(K,{className:i?`set-job-spin`:``}),u(i?`pluginJobRunning`:`pluginUpdate`)]}),Dn===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:i,title:u(`pluginUninstallHint`),onClick:()=>Zi(t.id),children:u(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:i,title:u(`pluginUninstallHint`),onClick:()=>On(t.id),children:[(0,X.jsx)(L,{}),u(`uninstallExt`)]})]})},t.id),Mi(t.id),t.agentTools&&t.agentTools.length>0&&!x&&(0,X.jsxs)(`div`,{className:`set-row`,title:u(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[u(`pluginToolsSection`),` (`,t.agentTools.length,`)`,t.agentTools.some(e=>xi.has(e.name))?` · ${u(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>C(`tools`),children:[u(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{jn===t.id?Mn(null):(Mn(t.id),$(ol(t.id)))},children:[(0,X.jsx)(Ve,{}),u(`pluginLogTitle`),` (`,pl(t.id).length,`) ·`,` `,jn===t.id?u(`pluginLogHide`):u(`pluginLogShow`)]}),jn===t.id&&(0,X.jsx)(Fx,{pluginId:t.id})]}),t.diagnostics&&t.diagnostics.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-diag-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>An(kn===t.id?null:t.id),children:[(0,X.jsx)(wt,{}),u(`pluginDiagTitle`),` (`,t.diagnostics.length,`) ·`,` `,kn===t.id?u(`pluginDiagHide`):u(`pluginDiagShow`)]}),kn===t.id&&(0,X.jsx)(`ul`,{className:`set-diag-list`,children:t.diagnostics.map((e,n)=>(0,X.jsx)(`li`,{children:e},`${t.id}-${n}`))})]}),t.wantsDom&&(0,X.jsxs)(`div`,{className:`set-row`,title:u(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:t.domGranted?u(`pluginDomGranted`):u(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${t.domGranted?``:` confirm`}`,title:u(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:t.id,granted:!t.domGranted}),children:t.domGranted?u(`pluginDomRevoke`):u(`pluginDomGrant`)})})]}),t.settingsSchema&&t.settingsSchema.length>0&&(0,X.jsxs)(`div`,{className:`set-row set-settings-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>In(e=>({...e,[t.id]:!e[t.id]})),children:[(0,X.jsx)(H,{}),u(`pluginSettingsTitle`),` (`,t.settingsSchema.length,`) ·`,` `,Pn[t.id]?u(`pluginSettingsHide`):u(`pluginSettingsShow`)]}),Pn[t.id]&&(0,X.jsx)(Vy,{plugin:t,models:_?.subagentModels??[]})]})]},t.id)})})]}),S===`plugins`&&x&&w===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ht,{className:`set-section-icon`}),u(`dshPatches`),(0,X.jsx)(Du,{text:u(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:u(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(K,{}),u(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`dshPatchesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:e.dshPatches.files.map(e=>(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsx)(`div`,{className:`set-row-name`,children:e.name}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[gm(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[u(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),S===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(N,{className:`set-section-icon`}),u(`settingsReview`),(0,X.jsx)(Du,{text:u(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.reviewSkills.length})]}),(0,X.jsx)(Dx,{title:u(`goalModeEnabled`),tip:`${u(`goalModeEnabledDesc`)}\n${u(`goalModeOffHint`)}`,enabled:_.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!_.goalModeEnabled})}),(0,X.jsx)(Dx,{title:u(`delegateMode`),tip:`${u(`delegateModeDesc`)}\n${u(`delegateModeOffHint`)}`,enabled:e.state?.delegateMode===!0,onToggle:()=>$({type:`set_delegate_mode`,enabled:e.state?.delegateMode!==!0})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,placeholder:u(`reviewPromptPlaceholder`),value:mt,onFocus:()=>_t.current=!0,onBlur:()=>{_t.current=!1,Q({reviewPrompt:mt})},onChange:e=>gt(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[u(`settingsReviewSkills`),x&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(Du,{text:u(`dshReviewPromptNote`)})]})]}),_.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.reviewSkills.map(e=>(0,X.jsx)(Dx,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>la(e)},`review-${e.name}`))})]}),S===`vision`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ue,{className:`set-section-icon`}),u(`settingsVisionBridge`)]}),(0,X.jsx)(Dx,{title:u(`visionBridgeEnabled`),tip:`${u(`settingsVisionBridgeDesc`)}\n${u(`visionBridgeOffHint`)}`,enabled:_.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!_.visionBridgeEnabled})}),_.visionBridgeEnabled&&(0,X.jsx)(Nx,{label:u(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:_.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:u(`visionBridgeAuto`)}),_.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),_.visionBridgeEnabled&&(0,X.jsx)(Px,{mode:Xe,onModeChange:Qe,draft:Je,onDraftChange:Ye,defaultPrompt:_.visionBridgeDefaultPrompt,placeholder:u(`visionBridgePromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({visionBridgePromptMode:e,visionBridgePrompt:t})},hint:_.visionModels.length===0?u(`visionBridgeNoModels`):u(`visionBridgeCurrent`,{model:_.visionBridgeModel??u(`visionBridgeAuto`)}),focusRef:$e})]}),S===`presets`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(H,{className:`set-section-icon`}),u(`settingsPresets`),(0,X.jsx)(Du,{text:u(`dshPresetUserNote`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-share-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn primary`,title:u(`presetShareShareBtn`),onClick:()=>xt({name:_.presets[0]?.name??``,tab:`export`}),children:[(0,X.jsx)(le,{}),u(`presetShareShareBtn`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn`,title:u(`presetShareImportBtn`),onClick:()=>xt({name:``,tab:`import`}),children:[(0,X.jsx)(re,{}),u(`presetShareImportBtn`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-preset-share-btn`,title:u(`presetShareBrowseBtn`),onClick:()=>xt({name:``,tab:`browse`}),children:[(0,X.jsx)(Fe,{}),u(`presetShareBrowseBtn`)]})]}),ti&&(0,X.jsxs)(`div`,{className:`set-preset-config`,children:[e.dshPresets&&e.dshPresets.presets.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`dshDefaultPreset`),(0,X.jsx)(Du,{text:u(`dshDefaultPresetDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:Q_(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[Z_(e,d,u).name,e.trust===`user`?` · ${u(`dshPresetUser`)}`:``,e.broken?` · ${u(`dshPresetBroken`)}`:``]},e.id))})]}),$r&&(0,X.jsx)(`p`,{className:`set-preset-config-desc`,children:$r})]}),e.dshPermission&&e.dshPermission.options.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`dshPermDefault`),(0,X.jsx)(Du,{text:u(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:tv.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:u(nv(e))},e))})]}),(0,X.jsx)(`p`,{className:`set-preset-config-desc`,children:u(rv(e.dshPermission.defaultPreset))})]})]}),ei&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`dshPresetUserNote`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`presetNamePlaceholder`),value:vt,onChange:e=>yt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&vt.trim()&&($({type:`save_preset`,name:vt.trim()}),yt(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!vt.trim(),onClick:()=>{$({type:`save_preset`,name:vt.trim()}),yt(``)},children:[(0,X.jsx)(me,{}),` `,u(`saveAsPreset`)]})]}),_.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:_.presets.map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsx)(`div`,{className:`set-row-name`,children:e.name}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[e.promptMode===`replace`?u(`promptModeReplace`):u(`promptModeAppend`),e.disabledSkills.length>0&&` · ${u(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${u(`settingsExtensions`)} ${e.disabledExtensions.length}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`presetShare`),onClick:()=>xt({name:e.name,tab:`export`}),children:(0,X.jsx)(le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`apply_preset`,name:e.name}),children:u(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(L,{})})]})]},e.name))})]}),S===`mcp`&&(0,X.jsx)(Xy,{settings:_,chat:e}),S===`subagent-templates`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(F,{className:`set-section-icon`}),u(`settingsSubagentTemplates`),(0,X.jsx)(Du,{text:u(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:u(`subagentTemplateNew`),onClick:()=>{Tt({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),Dt(!0)},children:[(0,X.jsx)(me,{}),` `,u(`subagentTemplateNew`)]})]}),(0,X.jsx)(Nx,{label:u(`subagentDefaultModelLabel`),tip:u(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:_.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:u(`subagentFollowMain`)}),_.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),_.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:u(`subagentNoModels`)}),Ct&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>Tt(null),children:(0,X.jsxs)(`div`,{className:`modal tpl-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":u(`close`),onClick:()=>Tt(null),children:(0,X.jsx)(P,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(F,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:Et?u(`subagentTemplateNew`):`${u(`subagentTemplateEdit`)} · ${Ct.name}`})]}),(0,X.jsxs)(`div`,{className:`modal-body`,children:[(0,X.jsxs)(`div`,{className:`tpl-fields`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplNamePlaceholder`),value:Ct.name,onChange:e=>Tt({...Ct,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplDescriptionPlaceholder`),value:Ct.description,onChange:e=>Tt({...Ct,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:u(`tplDescriptionEnPlaceholder`),value:Ct.descriptionEn??``,onChange:e=>Tt({...Ct,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.promptMode,onChange:e=>Tt({...Ct,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:u(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:u(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:u(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.model??``,onChange:e=>Tt({...Ct,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:u(`subagentFollowMain`)}),_.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsxs)(`label`,{className:`set-field-label`,children:[u(`tplThinkingLabel`),` `,(0,X.jsx)(Du,{text:u(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:Ct.thinkingLevel??``,onChange:e=>Tt({...Ct,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:u(`tplThinkingFollowMain`)}),W_.map(e=>(0,X.jsx)(`option`,{value:e,children:u(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${u(`tplSystemPromptLabel`)}${d===`zh`?`:`:`: `}${u(`tplSystemPromptPlaceholder`)}`,value:Ct.systemPrompt,onChange:e=>Tt({...Ct,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${u(`tplSystemPromptLabel`)}: ${u(`tplSystemPromptEnPlaceholder`)}`,value:Ct.systemPromptEn??``,onChange:e=>Tt({...Ct,systemPromptEn:e.target.value})}),(0,X.jsxs)(`div`,{className:`tpl-pick-block`,children:[(0,X.jsx)(`div`,{className:`tpl-pick-head`,children:(0,X.jsxs)(`span`,{children:[u(`tplSkillsLabel`),` · `,u(`tplWhitelistHint`)]})}),_.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:_.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${Ct.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ct.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;Tt({...Ct,enabledSkills:n?[...Ct.enabledSkills,e.name]:Ct.enabledSkills.filter(t=>t!==e.name)})}}),e.name]},e.name))})]}),(0,X.jsxs)(`div`,{className:`tpl-pick-block`,children:[(0,X.jsx)(`div`,{className:`tpl-pick-head`,children:(0,X.jsxs)(`span`,{children:[u(`tplExtensionsLabel`),` · `,u(`tplWhitelistHint`)]})}),_.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:_.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${Ct.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ct.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;Tt({...Ct,enabledExtensions:n?[...Ct.enabledExtensions,e.id]:Ct.enabledExtensions.filter(t=>t!==e.id)})}}),e.name]},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Ct.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...Ct,name:Ct.name.trim()}}),Tt(null)},children:u(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>Tt(null),children:u(`tplCancel`)})]})]})}),_.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:u(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:_.subagentTemplates.map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[e.name,_.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:u(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:u(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(d!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?u(`promptModeReplace`):u(`promptModeAppend`)}`,e.model?` · ${u(`tplModelLabel`)} ${e.model}`:` · ${u(`subagentFollowMain`)}`,e.thinkingLevel?` · ${u(`tplThinkingLabel`)} ${f(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${u(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${u(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${u(`tplInherit`)}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-switch${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,title:`${e.enabled?u(`subagentTemplateDisable`):u(`subagentTemplateEnable`)} · ${u(`subagentTemplateOffHint`)}`,onClick:()=>$({type:`save_subagent_template`,template:{...e,enabled:!e.enabled}}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:u(`subagentTemplateEdit`),onClick:()=>{Tt({...e}),Dt(!1)},children:u(`subagentTemplateEdit`)}),Ot===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:u(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),kt(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`tplDelete`),onClick:()=>kt(e.name),children:(0,X.jsx)(L,{})})]})]},e.name))})]}),S===`approval-rules`&&!x&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ce,{className:`set-section-icon`}),u(`settingsApprovalRules`),(0,X.jsx)(Du,{text:u(`settingsApprovalRulesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:_.approvalRules?.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:u(`approvalRuleNew`),onClick:()=>{Mt({id:`custom.${jt().slice(0,8)}`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:``,action:`ask`,label:``,labelEn:``,reason:``,reasonEn:``}),It(`bash`),Pt(!0),Rt(null)},children:[(0,X.jsx)(me,{}),` `,u(`approvalRuleNew`)]})]}),At&&(0,X.jsxs)(`div`,{className:`rule-editor`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,style:{fontSize:13,marginBottom:4},children:Nt?u(`approvalRuleNew`):`${u(`approvalRuleEdit`)} · ${At.label}`}),(0,X.jsx)(Nx,{label:u(`approvalRuleLabel`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.label,placeholder:`例如:拦截 Docker 危险操作`,onChange:e=>Mt({...At,label:e.target.value})})}),(0,X.jsx)(Nx,{label:u(`approvalRuleLabelEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.labelEn??``,placeholder:`e.g. Block dangerous Docker commands`,onChange:e=>Mt({...At,labelEn:e.target.value})})}),(0,X.jsx)(Nx,{label:u(`approvalRuleTools`),tip:u(`approvalRuleToolsTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Ft,placeholder:`bash, write, edit (或 * 通配)`,onChange:e=>{It(e.target.value);let t=e.target.value.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);Mt({...At,tools:t.length>0?t:[`*`]})}})}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:10,flexWrap:`wrap`},children:[(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(Nx,{label:u(`approvalRuleField`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.field,onChange:e=>Mt({...At,field:e.target.value}),children:[(0,X.jsx)(`option`,{value:`command`,children:u(`approvalRuleFieldCommand`)}),(0,X.jsx)(`option`,{value:`path`,children:u(`approvalRuleFieldPath`)}),(0,X.jsx)(`option`,{value:`params`,children:u(`approvalRuleFieldParams`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(Nx,{label:u(`approvalRuleMatch`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.match,onChange:e=>Mt({...At,match:e.target.value}),children:[(0,X.jsx)(`option`,{value:`regex`,children:u(`approvalRuleMatchRegex`)}),(0,X.jsx)(`option`,{value:`glob`,children:u(`approvalRuleMatchGlob`)}),(0,X.jsx)(`option`,{value:`contains`,children:u(`approvalRuleMatchContains`)}),(0,X.jsx)(`option`,{value:`prefix`,children:u(`approvalRuleMatchPrefix`)}),(0,X.jsx)(`option`,{value:`outside_workspace`,children:u(`approvalRuleMatchOutsideWs`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(Nx,{label:`命中动作`,children:(0,X.jsxs)(`select`,{className:`set-select`,value:At.action,onChange:e=>Mt({...At,action:e.target.value}),children:[(0,X.jsx)(`option`,{value:`ask`,children:u(`approvalRuleActionAsk`)}),(0,X.jsx)(`option`,{value:`deny`,children:u(`approvalRuleActionDeny`)}),(0,X.jsx)(`option`,{value:`allow`,children:u(`approvalRuleActionAllow`)})]})})})]}),At.match!==`outside_workspace`&&(0,X.jsx)(Nx,{label:u(`approvalRuleValue`),tip:u(`approvalRuleValueTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.value,placeholder:`匹配表达式或关键字…`,onChange:e=>Mt({...At,value:e.target.value})})}),(0,X.jsx)(Nx,{label:u(`approvalRuleReason`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.reason??``,placeholder:`例如:检测到删除镜像或容器操作`,onChange:e=>Mt({...At,reason:e.target.value})})}),(0,X.jsx)(Nx,{label:u(`approvalRuleReasonEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:At.reasonEn??``,placeholder:`e.g. Detected docker image/container removal`,onChange:e=>Mt({...At,reasonEn:e.target.value})})}),(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`label`,{className:`set-checkbox-label`,style:{display:`inline-flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:At.enabled,onChange:e=>Mt({...At,enabled:e.target.checked})}),u(`approvalRuleEnabled`)]})}),Lt&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12},children:Lt}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:4},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Mt(null),Rt(null)},children:u(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{if(!At.label.trim()){Rt(`请填写规则名称`);return}if(At.match===`regex`)try{new RegExp(At.value)}catch(e){Rt(`正则表达式非法:${e.message}`);return}$({type:`save_approval_rule`,rule:At}),Mt(null),Rt(null)},children:u(`save`)})]})]}),(_.approvalRules??[]).length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:u(`approvalRuleEmpty`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:(_.approvalRules??[]).map((e,t)=>{let n=e.builtin===!0;return(0,X.jsxs)(`div`,{className:`set-row${e.enabled?``:` rule-row-disabled`}`,style:{alignItems:`flex-start`,padding:`12px 0`},children:[(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,style:{display:`flex`,alignItems:`center`,flexWrap:`wrap`,gap:6},children:[(0,X.jsx)(`span`,{className:`rule-badge ${e.action}`,children:e.action===`deny`?u(`approvalRuleActionDeny`):e.action===`allow`?u(`approvalRuleActionAllow`):u(`approvalRuleActionAsk`)}),(0,X.jsx)(`strong`,{style:{fontSize:13},children:d===`zh`?e.label:e.labelEn||e.label}),n&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:u(`approvalRuleBuiltin`)}),(0,X.jsx)(`span`,{className:`rule-meta-code`,children:e.tools.join(`, `)})]}),(0,X.jsxs)(`div`,{className:`set-hint`,style:{marginTop:6,display:`flex`,flexDirection:`column`,gap:3},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`baseline`,gap:6,flexWrap:`wrap`},children:[(0,X.jsxs)(`span`,{style:{opacity:.85,fontSize:11,fontFamily:`var(--mono)`},children:[`[`,e.field,` · `,e.match,`]`]}),e.match!==`outside_workspace`&&(0,X.jsx)(`code`,{className:`rule-pattern-code`,children:e.value})]}),(e.reason||e.reasonEn)&&(0,X.jsx)(`div`,{style:{opacity:.75,fontSize:11},children:d===`zh`?e.reason:e.reasonEn||e.reason})]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,style:{marginLeft:12,flexShrink:0},children:[(0,X.jsx)(`button`,{type:`button`,className:`set-switch${e.enabled?` on`:``}`,role:`switch`,"aria-checked":e.enabled,title:e.enabled?u(`settingsEnabled`):u(`settingsDisabled`),onClick:()=>$({type:`save_approval_rule`,rule:{...e,enabled:!e.enabled}}),children:(0,X.jsx)(`span`,{className:`set-switch-knob`})}),!n&&t>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleMoveUp`),onClick:()=>{let e=[..._.approvalRules??[]],n=e[t-1];e[t-1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(ct,{})}),!n&&t<(_.approvalRules?.length??0)-1&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleMoveDown`),onClick:()=>{let e=[..._.approvalRules??[]],n=e[t+1];e[t+1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(dt,{})}),n&&(Ht===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`reset_builtin_approval_rule`,id:e.id}),Ut(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleReset`),onClick:()=>Ut(e.id),children:(0,X.jsx)(K,{})})),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:u(`approvalRuleEdit`),onClick:()=>{Mt({...e}),It(e.tools.join(`, `)),Pt(!1),Rt(null)},children:(0,X.jsx)(Y,{})}),!n&&(Bt===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`delete_approval_rule`,id:e.id}),Vt(null)},children:u(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:u(`approvalRuleDelete`),onClick:()=>Vt(e.id),children:(0,X.jsx)(L,{})}))]})]},e.id)})})]}),oi&&(0,X.jsx)(Ru,{plugin:oi.plugin,epoch:e.pluginsEpoch,send:$,className:`set-plugin-page`}),Jt&&(0,X.jsx)(qy,{name:Jt,override:Xt[Jt]??null,onApply:$t,onClose:()=>Yt(null)})]})]}),(0,X.jsx)(`div`,{className:`modal-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:xa,children:u(`close`)})})]}),bt!==null&&(0,X.jsx)(dx,{presets:_.presets.map(e=>e.name),presetExport:e.presetExport,presetImport:e.presetImport,presetCatalog:e.presetCatalog,presetShare:e.presetShare,initialPreset:bt.name,initialTab:bt.tab,onClose:()=>xt(null)})]})}function zx(e,t){let n=Math.max(0,Date.now()-e),r=Math.floor(n/6e4);if(r<1)return t(`bgTaskJustNow`);if(r<60)return t(`bgTaskMinutes`,{n:r});let i=Math.floor(r/60);return i<24?t(`bgTaskHours`,{n:i}):t(`bgTaskDays`,{n:Math.floor(i/24)})}function Bx({servers:e,onClose:t,plugins:n=[],epoch:r=0,send:i,onUiAction:a,autoCleanupMin:o=0}){let s=Z(),{locale:c}=Nn(),[l,u]=(0,g.useState)(new Set),d=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});(0,g.useEffect)(()=>{$({type:`list_bg_servers`})},[]);let f=(0,g.useMemo)(()=>(pa(na(n),{locale:c,t:e=>s(e)})[`tasks.panel`]??[]).filter(e=>!e.hidden&&e.source!==`host`&&e.kind!==`divider`),[n,c,s]);return(0,X.jsxs)(Ky,{className:`bg-task-modal`,onClose:t,showCloseButton:!1,children:[(0,X.jsxs)(`div`,{className:`bg-task-head`,children:[(0,X.jsxs)(`span`,{className:`bg-task-title`,children:[(0,X.jsx)(ke,{}),` `,s(`bgTasks`),e.length>0&&(0,X.jsx)(`em`,{className:`bg-task-count`,children:e.length})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:s(`close`),onClick:t,children:(0,X.jsx)(P,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{children:s(`bgTasksEmpty`)}),(0,X.jsx)(`small`,{children:s(`bgTasksDesc`)})]}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:e.map(e=>{let t=!!e.taskId,n=e.taskId??String(e.port);return(0,X.jsxs)(`li`,{className:`bg-task-item`,children:[(0,X.jsx)(`span`,{className:`bg-task-icon`,title:t?e.plugin:s(`bgTaskPort`)}),(0,X.jsxs)(`div`,{className:`bg-task-info`,children:[(0,X.jsxs)(`div`,{className:`bg-task-line1`,children:[t?(0,X.jsxs)(`span`,{className:`bg-task-port`,title:e.taskId,children:[`🧩 `,e.plugin]}):(0,X.jsxs)(`span`,{className:`bg-task-port`,children:[`:`,e.port]}),e.name&&(0,X.jsx)(`span`,{className:`bg-task-name`,children:e.name})]}),(0,X.jsxs)(`div`,{className:`bg-task-line2`,children:[!t&&(0,X.jsxs)(`span`,{children:[s(`bgTaskPid`),` `,e.pid]}),(0,X.jsxs)(`span`,{children:[s(`bgTaskSince`),` `,zx(e.since,s)]}),t&&e.status&&(0,X.jsx)(`span`,{className:`bg-task-status`,children:e.status})]}),e.command&&(0,X.jsxs)(`button`,{type:`button`,className:`bg-task-cmd ${l.has(n)?`open`:``}`,title:`${s(`bgTaskCommand`)}: ${e.command}`,onClick:()=>d(n),children:[(0,X.jsx)(z,{}),(0,X.jsx)(`code`,{children:e.command})]})]}),!t&&(0,X.jsx)(`button`,{type:`button`,className:`btn bg-task-keep`,title:e.keep?s(`bgTaskKeepOn`):s(`bgTaskKeep`),"aria-pressed":!!e.keep,onClick:()=>$({type:`set_bg_keep`,port:e.port??0,keep:!e.keep}),children:e.keep?`📌`:`📍`}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,title:s(`bgTaskStop`),onClick:()=>$(t?{type:`kill_background_server`,taskId:e.taskId}:{type:`kill_background_server`,port:e.port}),children:[(0,X.jsx)(V,{}),(0,X.jsx)(`span`,{children:s(`bgTaskStop`)})]})]},n)})}),f.map(e=>{let t=n.find(t=>t.id===e.source.slice(7));return e.kind===`view`?t?(0,X.jsx)(`div`,{children:(0,X.jsx)(Ru,{plugin:t,epoch:r,send:i??(()=>{})})},e.id):null:(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e.hint??e.label,onClick:()=>a?.(e),children:e.label},e.id)}),(0,X.jsxs)(`div`,{className:`bg-task-foot`,children:[(0,X.jsxs)(`label`,{className:`bg-task-cleanup`,title:s(`bgTaskCleanupHint`),children:[(0,X.jsx)(`span`,{children:s(`bgTaskCleanup`)}),(0,X.jsxs)(`select`,{className:`btn`,value:String(o),onChange:e=>$({type:`set_settings`,bgAutoCleanupMin:Number(e.target.value)}),children:[(0,X.jsx)(`option`,{value:`0`,children:s(`bgTaskCleanupOff`)}),[15,30,60,120].map(e=>(0,X.jsx)(`option`,{value:String(e),children:s(`bgTaskCleanupMinutes`,{n:e})},e))]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:s(`bgTaskCleanNowHint`),onClick:()=>$({type:`clean_bg_leftovers`}),children:[(0,X.jsx)(L,{}),(0,X.jsx)(`span`,{children:s(`bgTaskCleanNow`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:s(`bgTaskRefresh`),onClick:()=>$({type:`list_bg_servers`}),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:s(`bgTaskRefresh`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stopall`,disabled:e.length===0,title:s(`bgTaskStopAll`),onClick:()=>$({type:`kill_background_servers`}),children:[(0,X.jsx)(V,{}),(0,X.jsx)(`span`,{children:s(`bgTaskStopAll`)})]})]})]})}function Vx(){let e=Z(),t=zm(),[n,r]=(0,g.useState)(!0),i=(0,g.useRef)(null);return(0,g.useEffect)(()=>{t&&r(!0)},[t]),zt(()=>{t&&Lm()},!!t),(0,g.useEffect)(()=>{if(!t)return;let e=e=>{if(e.key!==`Enter`||e.shiftKey||e.ctrlKey||e.metaKey)return;let t=e.target;(!t||t===document.body||i.current?.contains(t))&&(e.preventDefault(),Rm(n))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,n]),t?(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:Lm,children:(0,X.jsxs)(`div`,{ref:i,className:`tool-info-modal rollback-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`rollbackSession`),onClick:e=>e.stopPropagation(),style:{maxWidth:520},children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(wt,{}),e(`rollbackSession`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`cancel`),onClick:Lm,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 16px 0`,fontSize:14,lineHeight:1.6},children:e(`rollbackConfirm`)}),(0,X.jsxs)(`label`,{style:{display:`flex`,alignItems:`flex-start`,gap:10,padding:`12px 14px`,borderRadius:8,backgroundColor:`var(--bg-elev, rgba(255, 255, 255, 0.04))`,border:`1px solid var(--border-subtle, rgba(255, 255, 255, 0.1))`,cursor:`pointer`,marginBottom:20},title:e(`rollbackRestoreWorkspaceTip`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked),style:{marginTop:3,cursor:`pointer`}}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{style:{fontWeight:600,fontSize:13,color:`var(--text, #e2e8f0)`},children:e(`rollbackRestoreWorkspace`)}),(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2},children:e(`rollbackRestoreWorkspaceTip`)})]})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:10},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:Lm,children:e(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>Rm(n),children:[(0,X.jsx)(ft,{}),e(`confirm`)]})]})]})]})}),document.body):null}function Hx({approval:e}){let t=Z(),{locale:n}=Nn(),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(null);if((0,g.useEffect)(()=>{if(e){let t=e.params;i(typeof t==`object`&&t?JSON.stringify(t,null,2):t==null?`{}`:String(t)),o(null)}},[e]),!e)return null;let s=t=>{$({type:`tool_approval_response`,id:e.id,decision:`approve`,...t&&t!==`once`?{scope:t}:{}})},c=()=>{$({type:`tool_approval_response`,id:e.id,decision:`deny`,reason:`Operation rejected by user`})};return(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,children:(0,X.jsxs)(`div`,{className:`tool-info-modal approval-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":t(`toolApprovalTitle`),style:{maxWidth:640,borderTop:`4px solid var(--amber, #f59e0b)`},onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,style:{color:`var(--amber, #f59e0b)`},children:[(0,X.jsx)(wt,{}),t(`toolApprovalTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,style:{fontWeight:700},children:e.toolName}),e.parentTool===`codemode`&&(0,X.jsxs)(`span`,{className:`tool-info-label`,style:{backgroundColor:`rgba(245, 158, 11, 0.15)`,color:`var(--amber, #f59e0b)`,border:`1px solid rgba(245, 158, 11, 0.35)`,fontWeight:600},children:[`⚡ `,t(`codemodeNestedApprovalBadge`)]}),e.conversationTitle&&(0,X.jsx)(`span`,{className:`tool-info-label`,children:e.conversationTitle}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalDeny`),onClick:c,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[e.parentTool===`codemode`&&(0,X.jsxs)(`div`,{style:{padding:`8px 12px`,borderRadius:6,backgroundColor:`rgba(99, 102, 241, 0.12)`,border:`1px solid rgba(99, 102, 241, 0.25)`,marginBottom:12,color:`var(--text, #e2e8f0)`,fontSize:12.5,display:`flex`,alignItems:`center`,gap:6},children:[(0,X.jsx)(`span`,{style:{fontSize:14},children:`⚡`}),(0,X.jsx)(`span`,{children:t(`codemodeNestedApprovalDesc`)})]}),(e.reason||e.reasonEn)&&(0,X.jsxs)(`div`,{style:{padding:`10px 14px`,borderRadius:6,backgroundColor:`rgba(245, 158, 11, 0.12)`,border:`1px solid rgba(245, 158, 11, 0.3)`,marginBottom:16,color:`var(--amber, #f59e0b)`,fontSize:13,lineHeight:1.5,fontWeight:500},children:[(0,X.jsxs)(`div`,{style:{fontWeight:600,marginBottom:2},children:[t(`toolApprovalRiskAlert`),`:`]}),(0,X.jsx)(`div`,{children:n===`zh`?e.reason||e.reasonEn:e.reasonEn||e.reason}),e.category&&(0,X.jsxs)(`div`,{style:{marginTop:6,fontSize:12,opacity:.85},children:[t(`toolApprovalCategory`),`:`,n===`zh`?e.category.label:e.category.labelEn]}),e.hits&&e.hits.length>0&&(0,X.jsxs)(`div`,{className:`approval-hits-panel`,children:[(0,X.jsxs)(`div`,{className:`approval-hits-title`,children:[t(`toolApprovalHitsTitle`),` (`,e.hits.length,`)`]}),(0,X.jsx)(`div`,{className:`approval-hits-list`,children:e.hits.map((e,r)=>(0,X.jsxs)(`div`,{className:`approval-hit-item`,children:[(0,X.jsxs)(`div`,{className:`approval-hit-header`,children:[(0,X.jsx)(`span`,{className:`approval-hit-badge`,children:n===`zh`?e.label:e.labelEn||e.label}),(0,X.jsx)(`span`,{className:`approval-hit-field`,children:e.field}),(0,X.jsx)(`span`,{className:`approval-hit-pos`,children:t(`approvalHitPos`,{index:e.index+1,length:e.length})})]}),(0,X.jsx)(`div`,{className:`approval-hit-text`,children:(0,X.jsx)(`mark`,{className:`approval-danger-hit`,children:e.text})})]},r))})]})]}),e.toolName===`bash`&&typeof e.params?.command==`string`&&(0,X.jsxs)(`div`,{className:`approval-cmd-preview`,children:[(0,X.jsxs)(`div`,{className:`approval-cmd-preview-label`,children:[t(`approvalCommandPreview`),`:`]}),(0,X.jsxs)(`div`,{className:`approval-cmd-preview-box`,children:[(0,X.jsx)(`span`,{className:`bashblock-prompt`,children:`$`}),(0,X.jsx)(`code`,{children:md(e.params.command,e.hits)})]})]}),(0,X.jsxs)(`div`,{style:{marginBottom:16},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:6},children:[(0,X.jsx)(`span`,{style:{fontSize:13,fontWeight:600,color:`var(--text, #e2e8f0)`},children:t(`toolApprovalParams`)}),(0,X.jsx)(`span`,{style:{fontSize:11,color:`var(--text-dim, #9aa1b4)`},children:t(`toolApprovalEditPlaceholder`)})]}),(0,X.jsx)(`textarea`,{rows:8,value:r,onChange:e=>{i(e.target.value),a&&o(null)},style:{width:`100%`,fontFamily:`var(--mono, monospace)`,fontSize:12,lineHeight:1.5,padding:10,borderRadius:6,backgroundColor:`var(--bg-elev, #111827)`,color:`var(--text, #f8fafc)`,border:a?`1px solid var(--red, #ef4444)`:`1px solid var(--border-subtle, rgba(255,255,255,0.1))`,boxSizing:`border-box`,resize:`vertical`}}),a&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12,marginTop:4},children:a})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,flexWrap:`wrap`,justifyContent:`flex-end`,gap:10},children:[e.category&&(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowCategoryHint`),onClick:()=>s(`category`),children:[(0,X.jsx)(ke,{}),t(`toolApprovalAllowCategory`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowConversationHint`),onClick:()=>s(`all`),children:[(0,X.jsx)(pt,{}),t(`toolApprovalAllowConversation`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,style:{color:`var(--red, #ef4444)`},onClick:c,children:[(0,X.jsx)(P,{}),t(`toolApprovalDeny`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>s(),style:{fontWeight:500},children:[(0,X.jsx)(ft,{}),t(`toolApprovalApprove`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,style:{display:`inline-flex`,alignItems:`center`,gap:6,backgroundColor:`var(--amber, #f59e0b)`,borderColor:`var(--amber, #f59e0b)`,color:`#000`,fontWeight:600},onClick:()=>{try{let t=e.params,n;n=typeof t==`object`&&t||t==null?JSON.parse(r):r,o(null),$({type:`tool_approval_response`,id:e.id,decision:`edit`,editedParams:n})}catch(e){o(`JSON 格式错误:${e.message}`)}},children:[(0,X.jsx)(Y,{}),t(`toolApprovalEditAndRun`)]})]})]})]})}),document.body)}function Ux({overlay:e}){let t=Z(),n=(0,g.useRef)(null),r=(0,g.useRef)(null),i=(0,g.useCallback)(()=>{$({type:`tui_overlay_cancel`,id:e.id})},[e.id]);(0,g.useEffect)(()=>{let t=n.current;if(!t)return;let i=new m({theme:vf(),fontFamily:`"SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace`,fontSize:13,cursorBlink:!0,scrollback:1e3,cols:e.cols||80,rows:e.rows||24}),a=new h;i.loadAddon(a),i.open(t),r.current={term:i,fit:a},e.initialAnsi&&i.write(e.initialAnsi);let o=i.onData(t=>{$({type:`tui_overlay_input`,id:e.id,data:t})}),s=cs((t,n)=>{t===e.id&&i.write(n)});try{a.fit(),(i.cols!==e.cols||i.rows!==e.rows)&&$({type:`tui_overlay_resize`,id:e.id,cols:i.cols,rows:i.rows})}catch{}let c=new ResizeObserver(()=>{try{a.fit(),i.cols&&i.rows&&$({type:`tui_overlay_resize`,id:e.id,cols:i.cols,rows:i.rows})}catch{}});c.observe(t);let l=setTimeout(()=>{i.focus()},50);return()=>{clearTimeout(l),c.disconnect(),o.dispose(),s(),i.dispose(),r.current=null}},[e.id,e.cols,e.rows,e.initialAnsi]);let a=e.title||t(`tuiOverlayTitle`);return(0,X.jsx)(Ky,{open:!0,onClose:i,title:a,icon:(0,X.jsx)(z,{}),className:`tui-overlay-modal`,closeOnBackdropClick:!1,closeOnEscape:!0,children:(0,X.jsx)(`div`,{className:`tui-overlay-body`,children:(0,X.jsx)(`div`,{className:`tui-overlay-xterm`,ref:n})})})}var Wx={pending:`in_progress`,in_progress:`done`,done:`failed`,failed:`pending`};function Gx({plan:e}){let t=Z(),[n,r]=(0,g.useState)(!1),{copied:i,copy:a}=qu({duration:2e3}),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``);if(!e||!e.steps||e.steps.length===0)return null;let f=e.steps,p=f.filter(e=>e.status===`done`).length,m=f.length,h=Math.round(p/m*100),_=f.find(t=>t.id===e.activeStepId)??f.find(e=>e.status===`in_progress`),v=()=>{window.confirm(`确定要清空当前任务计划看板吗?`)&&$({type:`plan_update`,steps:[]})},y=()=>{$({type:`set_plan_mode`,enabled:!1}),$({type:`prompt`,text:t(`planImplementRequest`)})},b=()=>{let e=f.map((e,t)=>`${t+1}. ${e.title}${e.description?` (${e.description})`:``}`).join(`
678
678
  `);$({type:`plan_clean_handoff`,steps:f,prompt:`${t(`planCleanHandoffPrompt`)}\n\n${e}`})},x=async()=>{let e=[`# ${t(`planBoardTitle`)} (${p}/${m})`,``,...f.map((e,t)=>{let n=`${e.status===`done`?`[x]`:e.status===`in_progress`?`[>]`:e.status===`failed`?`[!]`:`[ ]`} ${t+1}. ${e.title}`;return e.description&&(n+=`\n ${e.description}`),n})];await a(e.join(`
679
- `))},S=e=>{s(e.id),l(e.title),d(e.description||``)},C=()=>{s(null),l(``),d(``)},w=e=>{let t=c.trim();if(!t)return;let n={title:t};n.description=u.trim()?u.trim():void 0,$({type:`plan_step_update`,stepId:e,patch:n}),s(null)},T=e=>{$({type:`plan_step_delete`,stepId:e})},E=e=>{let t=f.find(t=>t.id===e);t&&$({type:`plan_step_update`,stepId:e,patch:{status:jx[t.status]}})},D=()=>{let e={id:`step-${Date.now()}`,title:t(`planBoardAddStep`),status:`pending`};$({type:`plan_step_add`,step:e}),S(e)},O=(e,n)=>{let r=(()=>{switch(e){case`done`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pt,{}),t(`planBoardCompleted`)]});case`in_progress`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(rt,{}),t(`planBoardInProgress`)]});case`failed`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Tt,{}),t(`planBoardFailed`)]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(at,{}),t(`planBoardPending`)]})}})();return(0,X.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),E(n)},title:`点击切换状态 (pending / in_progress / done / failed)`,style:{display:`inline-flex`,alignItems:`center`,gap:4,color:e===`done`?`var(--green, #22c55e)`:e===`in_progress`?`var(--accent, #38bdf8)`:e===`failed`?`var(--red, #ef4444)`:`var(--text-dim, #9aa1b4)`,fontSize:12,fontWeight:e===`pending`?400:600,background:`none`,border:`none`,cursor:`pointer`,padding:`2px 4px`,borderRadius:4},children:r})};return(0,X.jsxs)(`div`,{className:`plan-board ${n?``:`plan-board-collapsed`}`.trim(),children:[(0,X.jsxs)(`div`,{className:`plan-board-head`,onClick:()=>r(!n),children:[(0,X.jsxs)(`div`,{className:`plan-board-head-main`,children:[(0,X.jsx)(De,{className:`plan-board-icon`}),(0,X.jsx)(`span`,{className:`plan-board-title`,children:t(`planBoardTitle`)}),(0,X.jsxs)(`span`,{className:`plan-board-count ${h===100?`plan-board-count-done`:``}`.trim(),children:[p,`/`,m]}),!n&&_&&(0,X.jsx)(`span`,{className:`plan-board-active`,title:_.title,children:_.title})]}),(0,X.jsxs)(`div`,{className:`plan-board-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`plan-board-implement`,title:t(`planImplementTip`),onClick:e=>{e.stopPropagation(),y()},children:t(`planImplementBtn`)}),n&&(0,X.jsx)(`button`,{type:`button`,className:`plan-board-clean-handoff`,title:t(`planCleanHandoffTip`),onClick:e=>{e.stopPropagation(),b()},children:t(`planCleanHandoffBtn`)}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(i?`planBoardExportSuccess`:`planBoardExportMarkdown`),onClick:e=>{e.stopPropagation(),x()},children:i?(0,X.jsx)(ft,{style:{color:`var(--green, #22c55e)`}}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`clear`),onClick:e=>{e.stopPropagation(),v()},children:(0,X.jsx)(R,{})})]}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(n?`collapseSection`:`expandSection`),children:n?(0,X.jsx)(ct,{}):(0,X.jsx)(dt,{})})]}),n&&(0,X.jsx)(`div`,{className:`plan-board-head-divider`,children:(0,X.jsx)(`div`,{className:`plan-board-head-divider-fill`,style:{width:`${h}%`,backgroundColor:h===100?`var(--green, #22c55e)`:`var(--accent, #38bdf8)`}})})]}),!n&&(0,X.jsx)(`div`,{className:`plan-board-progress-line`,children:(0,X.jsx)(`div`,{className:`plan-board-progress-line-fill`,style:{width:`${h}%`,backgroundColor:h===100?`var(--green, #22c55e)`:`var(--accent, #38bdf8)`}})}),n&&(0,X.jsxs)(`div`,{className:`plan-board-steps`,style:{marginTop:8,display:`flex`,flexDirection:`column`,gap:8},children:[f.map((n,r)=>{let i=n.id===e.activeStepId||n.status===`in_progress`;return o===n.id?(0,X.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,padding:`8px 10px`,borderRadius:6,backgroundColor:`var(--bg-elev2, rgba(0, 0, 0, 0.2))`,border:`1px solid var(--accent, #38bdf8)`},children:[(0,X.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:t(`planBoardStepTitlePlaceholder`),style:{width:`100%`,padding:`4px 8px`,borderRadius:4,border:`1px solid var(--border-subtle)`,background:`var(--bg, #0b0f17)`,color:`var(--text, #f1f5f9)`,fontSize:13},autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),w(n.id)):e.key===`Escape`&&C()}}),(0,X.jsx)(`textarea`,{rows:2,value:u,onChange:e=>d(e.target.value),placeholder:t(`planBoardStepDescPlaceholder`),style:{width:`100%`,padding:`4px 8px`,borderRadius:4,border:`1px solid var(--border-subtle)`,background:`var(--bg, #0b0f17)`,color:`var(--text-dim, #9aa1b4)`,fontSize:12,resize:`vertical`},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),w(n.id)):e.key===`Escape`&&C()}}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:6,marginTop:2},children:[(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-iconbtn`,onClick:C,title:t(`cancel`),style:{padding:`3px 8px`,fontSize:12},children:[(0,X.jsx)(P,{}),` `,t(`cancel`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-implement`,onClick:()=>w(n.id),title:t(`confirm`),style:{padding:`3px 10px`,fontSize:12},children:[(0,X.jsx)(ft,{}),` `,t(`confirm`)]})]})]},n.id||r):(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,flexWrap:`wrap`,rowGap:4,minWidth:0,padding:`6px 10px`,borderRadius:6,backgroundColor:i?`rgba(56, 189, 248, 0.08)`:`var(--bg-elev2, rgba(0, 0, 0, 0.2))`,border:i?`1px solid rgba(56, 189, 248, 0.25)`:`1px solid transparent`},children:[(0,X.jsxs)(`div`,{style:{flex:`1 1 180px`,minWidth:0,paddingRight:10},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:6,minWidth:0},children:[(0,X.jsxs)(`span`,{style:{fontSize:11,fontWeight:700,color:i?`var(--accent, #38bdf8)`:`var(--text-dim, #9aa1b4)`,minWidth:16},children:[r+1,`.`]}),(0,X.jsx)(`span`,{style:{fontWeight:i?600:500,color:n.status===`done`?`var(--text-dim, #9aa1b4)`:`var(--text, #f1f5f9)`,textDecoration:n.status===`done`?`line-through`:`none`,minWidth:0,overflowWrap:`anywhere`,wordBreak:`break-word`},children:n.title})]}),n.description&&(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2,paddingLeft:22,lineHeight:1.4,overflowWrap:`anywhere`,wordBreak:`break-word`},children:n.description})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,flexShrink:0,marginTop:2},children:[O(n.status,n.id),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`planBoardEditStep`),onClick:()=>S(n),children:(0,X.jsx)(Ke,{size:12})}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`planBoardDeleteStep`),onClick:()=>T(n.id),children:(0,X.jsx)(R,{size:12})})]})]},n.id||r)}),(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-add-btn`,onClick:D,children:[(0,X.jsx)(me,{}),` `,t(`planBoardAddStep`)]})]})]})}var Nx=3,Px=200;function Fx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ix(e){return typeof e==`string`&&e.trim()||void 0}function Lx(e,t){let n=[];for(let r of e){let e=zx(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function Rx(e){let t=e.slice(0,6).map(e=>typeof e==`string`?e:JSON.stringify(e)??String(e));if(t.length!==0)return`enum: ${t.join(` | `)}${e.length>t.length?` | …`:``}`}function zx(e,t=0){if(t>6||!Fx(e))return`any`;if(Ix(e.$ref))return`ref`;let n=Ix(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:zx(n,t+1)}>`}if(n)return n;for(let n of[`anyOf`,`oneOf`,`allOf`]){let r=e[n];if(Array.isArray(r)&&r.length>0)return Lx(r,t+1)}return Fx(e.properties)?`object`:Fx(e.additionalProperties)?`record<${zx(e.additionalProperties,t+1)}>`:`any`}function Bx(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=Rx(n);e&&t.push(e)}return e.const!==void 0&&t.push(`const: ${JSON.stringify(e.const)}`),e.default!==void 0&&t.push(`default: ${JSON.stringify(e.default)}`),t.length>0?t.join(` · `):void 0}function Vx(e,t={}){let n=t.maxDepth??Nx,r=t.maxRows??Px,i=e;if(!Fx(i))return[];let a=i.properties;if(!Fx(a))return[];let o=[],s=new Set((Array.isArray(i.required)?i.required:[]).filter(e=>typeof e==`string`)),c=(e,t,i,a)=>{if(!(o.length>=r))for(let[s,l]of Object.entries(e)){if(o.length>=r)return;let e=Fx(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:zx(e,i),required:a.has(s),depth:i},f=Ix(e.description);f&&(d.description=f);let p=Bx(e);if(p&&(d.hint=p),o.push(d),i+1<n&&Fx(e.properties)){let t=new Set((Array.isArray(e.required)?e.required:[]).filter(e=>typeof e==`string`));c(e.properties,u,i+1,t)}}};return c(a,``,0,s),o}function Hx(){let e=Z(),t=os();return zt(()=>{ns()},!!t),t?(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:ns,children:(0,X.jsxs)(`div`,{className:`tool-info-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`toolInfoTitle`),onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,children:[(0,X.jsx)(je,{}),e(`toolInfoTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,children:t.name}),t.label&&t.label!==t.name&&(0,X.jsx)(`span`,{className:`tool-info-label`,children:t.label}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`close`),onClick:ns,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(Ux,{info:t})})]})}),document.body):null}function Ux({info:e}){let t=Z();if(e.status===`loading`)return(0,X.jsxs)(`div`,{className:`tool-info-state`,role:`status`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,t(`toolInfoLoading`)]});if(e.status===`unsupported`)return(0,X.jsx)(`div`,{className:`tool-info-state`,children:t(`toolInfoUnsupported`)});if(e.status===`missing`)return(0,X.jsx)(`div`,{className:`tool-info-state`,children:t(`toolInfoMissing`)});let n=e.parameters===void 0?[]:Vx(e.parameters),r=e.parameters===void 0?``:Gx(e.parameters);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`tool-info-badges`,children:[e.active!==void 0&&(0,X.jsx)(`span`,{className:`tool-info-badge ${e.active?`on`:`off`}`,children:e.active?t(`toolInfoActive`):t(`toolInfoInactive`)}),e.source&&(0,X.jsxs)(`span`,{className:`tool-info-badge`,children:[t(`toolInfoSource`),`: `,e.source,e.scope?` · ${e.scope}`:``]})]}),(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoDescription`)}),(0,X.jsx)(`div`,{className:`tool-info-text`,children:e.description||t(`toolInfoNoDescription`)})]}),e.promptSnippet&&(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoPromptSnippet`)}),(0,X.jsx)(`div`,{className:`tool-info-text dim`,children:e.promptSnippet})]}),e.promptGuidelines&&e.promptGuidelines.length>0&&(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoGuidelines`)}),(0,X.jsx)(`ul`,{className:`tool-info-list`,children:e.promptGuidelines.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoParams`)}),n.length>0?(0,X.jsx)(Wx,{rows:n}):(0,X.jsx)(`div`,{className:`tool-info-text dim`,children:t(`toolInfoParamsNone`)}),e.parametersDropped&&(0,X.jsx)(`div`,{className:`tool-info-text warn`,children:t(`toolInfoSchemaDropped`)}),r&&(0,X.jsxs)(`details`,{className:`tool-info-raw`,children:[(0,X.jsxs)(`summary`,{children:[t(`toolInfoRawSchema`),(0,X.jsx)(Sd,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function Wx({rows:e}){let t=Z();return(0,X.jsx)(`div`,{className:`tool-schema-table`,role:`table`,children:e.map(e=>(0,X.jsxs)(`div`,{className:`tool-schema-row`,role:`row`,style:{paddingLeft:8+e.depth*14},children:[(0,X.jsxs)(`div`,{className:`tool-schema-name`,children:[(0,X.jsx)(`code`,{children:e.name}),e.required&&(0,X.jsx)(`span`,{className:`tool-schema-req`,children:t(`toolInfoRequired`)})]}),(0,X.jsxs)(`div`,{className:`tool-schema-type`,children:[e.type,e.hint&&(0,X.jsx)(`span`,{className:`tool-schema-hint`,children:e.hint})]}),e.description&&(0,X.jsx)(`div`,{className:`tool-schema-desc`,children:e.description})]},e.name))})}function Gx(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function Kx(e,t){return e.toLowerCase().includes(t)}function qx({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=Nn(),u=l===`en`?`Plugins`:`插件`,d=La(`cwd`),f=(0,g.useRef)(null),[p,m]=(0,g.useState)(``),h=(0,g.useDeferredValue)(p),[_,v]=(0,g.useState)(0),y=(0,g.useRef)(0),b=(0,g.useRef)(null),[x,S]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=p.trim();if(t){let e=A_();y.current=e,w(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}requestAnimationFrame(()=>f.current?.select())},[e]);let[C,w]=(0,g.useState)(!1);(0,g.useEffect)(()=>{b.current&&clearTimeout(b.current);let e=h.trim();if(!e){w(!1),S(null);return}return b.current=setTimeout(()=>{let t=A_();y.current=t,w(!0),$({type:`search_files`,reqId:t,query:e}),$({type:`search_sessions`,reqId:t,query:e})},300),()=>{b.current&&clearTimeout(b.current)}},[h]),(0,g.useEffect)(()=>{n&&n.reqId===y.current&&S(n)},[n]);let T=h.trim().toLowerCase(),E=(0,g.useMemo)(()=>!T||!r||r.reqId!==y.current||!r.ok?[]:r.results,[r,T]),D=(0,g.useMemo)(()=>T?t.filter(e=>Kx(e.path,T)).slice(0,10):[],[t,T]),O=(0,g.useMemo)(()=>!T||!x||!x.ok?[]:x.results,[x,T]);(0,g.useEffect)(()=>{x&&x.reqId===y.current&&r&&r.reqId===y.current&&y.current!==0&&w(!1)},[x,r]);let k=!!x&&x.ok&&x.truncated,[A,j]=(0,g.useState)([]);(0,g.useEffect)(()=>{if(!e)return;let t=h.trim();if(!t){j([]);return}let n=!1,r=[];try{let e=window,t=e.__piWebUiHost?.searchProviders?.list;if(typeof t==`function`){let n=t.call(e.__piWebUiHost);Array.isArray(n)&&(r=n)}else typeof Qs==`function`&&(r=Qs())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=rc(e.id);return t&&typeof t.search==`function`?{...e,search:t.search}:null}catch{return null}}).filter(e=>!!e);if(i.length===0){j([]);return}return Promise.allSettled(i.map(e=>Promise.race([e.search(t),new Promise((e,t)=>setTimeout(()=>t(Error(`timeout`)),3e3))]).then(t=>({provider:e,items:Array.isArray(t)?t:[]}),()=>({provider:e,items:[]})))).then(e=>{if(n)return;let t=[];for(let n of e)if(n.status===`fulfilled`)for(let e of n.value.items){if(!e||typeof e!=`object`)continue;let r=e;typeof r.title==`string`&&typeof r.action==`string`&&t.push({providerId:n.value.provider.id,providerLabel:n.value.provider.label,title:r.title,...typeof r.hint==`string`?{hint:r.hint}:{},action:r.action})}j(t.slice(0,20))}),()=>{n=!0}},[e,h]);let ee=(0,g.useMemo)(()=>[...E.map(e=>({kind:`session`,path:e.path,anchors:e.anchors})),...D.map(e=>({kind:`project`,path:e.path})),...O.filter(e=>e.type===`file`).map(e=>({kind:`file`,path:e.path,name:e.name})),...A.map(e=>({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}))],[E,D,O,A]);(0,g.useEffect)(()=>{v(0)},[h]);let M=(0,g.useCallback)(e=>{if(e){if(e.kind===`session`)a(e.path,e.anchors),i();else if(e.kind===`project`){o(e.path),$({type:`list_sessions`}),$({type:`list_projects`});let t=h.trim();if(t){let e=A_();y.current=e,w(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}}else e.kind===`plugin`?Bs(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,h]);(0,g.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),i()):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.max(0,Math.min(e+1,ee.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),M(ee[_]))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[ee,_,M,i,e]);let te=E.length+D.length+O.length+A.length,N=(e,t,n)=>(0,X.jsxs)(`div`,{className:`gs-section-head`,children:[n,(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`em`,{children:t})]}),ne=-1;return e?(0,X.jsx)(`div`,{className:`modal-backdrop gs-backdrop`,onClick:i,children:(0,X.jsxs)(`div`,{className:`gs-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`gs-input-row`,children:[(0,X.jsx)(de,{}),(0,X.jsx)(`input`,{ref:f,type:`text`,value:p,placeholder:c(`gsPlaceholder`),onChange:e=>m(e.target.value)}),(0,X.jsx)(`button`,{type:`button`,className:`gs-close`,title:c(`close`),onClick:i,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!T&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),T&&te===0&&!k&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(C?`gsSearching`:`gsNoResults`)}),E.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsSessions`),E.length,(0,X.jsx)(J,{})),E.map(e=>{ne++;let t=ne,n=e.name||e.path.split(/[\\/]/).pop()||e.path;return(0,X.jsxs)(`div`,{className:`gs-item-wrap`,children:[(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>M({kind:`session`,path:e.path,anchors:e.anchors}),children:[(0,X.jsxs)(`span`,{className:`gs-item-title`,children:[n,(0,X.jsx)(`em`,{className:`gs-item-meta`,children:e.messageCount})]}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.firstMessage})]}),(0,X.jsxs)(`button`,{type:`button`,className:`gs-quote`,title:c(`quoteConversation`),onClick:t=>{t.stopPropagation(),lr({attachments:[{path:``,key:`conv||${e.path}`,name:n,mode:`conversation`,sessionPath:e.path}]})},children:[`💬 `,c(`quoteConversationShort`)]})]},e.path)})]}),D.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsProjects`),D.length,(0,X.jsx)(Re,{})),D.map(e=>{ne++;let t=ne,n=d&&e.path===d;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>M({kind:`project`,path:e.path}),children:[(0,X.jsxs)(`span`,{className:`gs-item-title`,children:[e.path.split(/[\\/]/).pop(),n&&(0,X.jsx)(`em`,{className:`gs-item-meta`,children:c(`gsCurrentProject`)})]}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.path})]},e.path)})]}),(O.length>0||T&&k)&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsFiles`),O.length,(0,X.jsx)(Ve,{})),O.map(e=>{ne++;let t=ne;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,disabled:e.type===`dir`,title:e.type===`dir`?void 0:c(`gsOpenPreview`),onMouseEnter:()=>v(t),onClick:()=>{e.type===`file`&&M({kind:`file`,path:e.path,name:e.name})},children:[(0,X.jsx)(`span`,{className:`gs-item-title`,children:e.name}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.path})]},`${e.type}:${e.path}`)}),k&&(0,X.jsx)(`div`,{className:`gs-truncated`,children:c(`gsTruncated`)})]}),A.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(u,A.length,(0,X.jsx)(q,{})),A.map((e,t)=>{ne++;let n=ne;return(0,X.jsxs)(`button`,{type:`button`,className:n===_?`gs-item active`:`gs-item`,title:e.providerLabel,onMouseEnter:()=>v(n),onClick:()=>M({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}),children:[(0,X.jsx)(`span`,{className:`gs-item-title`,children:e.title}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.hint??e.providerLabel})]},`${e.providerId}:${e.action}:${t}`)})]})]}),(0,X.jsxs)(`div`,{className:`gs-foot`,children:[(0,X.jsxs)(`span`,{children:[`↑↓ `,c(`gsNavigate`)]}),(0,X.jsxs)(`span`,{children:[`Enter `,c(`gsOpen`)]}),(0,X.jsxs)(`span`,{children:[`Esc `,c(`gsCloseHint`)]})]})]})}):null}function Jx({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(Ny,{className:`plugin-modal`,title:a,icon:e.icon,onClose:r,children:(0,X.jsx)(`div`,{className:`modal-body plugin-modal-body`,children:o?t?(0,X.jsx)(Bv,{entry:t}):(0,X.jsx)(`div`,{className:`plugin-modal-loading`,children:i(`loading`)}):e.kind===`divider`?(0,X.jsx)(`hr`,{className:`plugin-modal-divider`}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary plugin-modal-action`,onClick:()=>n?.(e),children:e.badge??a})})})}var Yx=`未命名章节`;function Xx(e){return String(e??``).trim().replace(/[\s\u3000]+/g,`-`).replace(/[^\p{L}\p{N}_-]+/gu,`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`section`}function Zx(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=Xx(r||Yx),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Yx}})}function Qx(e){return e.length>=2}var $x=5e3,eS=`pi-web-ui:preview-toc`;function tS({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!0),[T,E]=(0,g.useState)(!0),[D,O]=(0,g.useState)(!1),k=(0,g.useRef)(!1),[A,j]=(0,g.useState)(!0),[ee,N]=(0,g.useState)(!1),[ne,F]=(0,g.useState)(100),re=(0,g.useRef)(0),I=(0,g.useRef)(!1),L=(0,g.useRef)(null),[ie,R]=(0,g.useState)(!1),[z,B]=(0,g.useState)(!1),V=(0,g.useRef)(!1),H=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{L.current&&clearTimeout(L.current),H.current&&clearTimeout(H.current)},[]),(0,g.useEffect)(()=>{d(!0),l(null),p(null),b(!1),S(``),w(!0),E(!0),O(!1),k.current=!1,V.current=!1,R(!1),B(!1),H.current&&clearTimeout(H.current),$({type:`read_file`,path:e.path})},[e.path]),(0,g.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1),V.current&&(V.current=!1,H.current&&clearTimeout(H.current),R(!1),B(!1),b(!1),S(t.text),k.current&&(nS(e.name)&&w(!0),iS(e.name)&&E(!0)),p(null)))},[t,y,e.path]),(0,g.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){G();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&y){e.preventDefault(),fe();return}let t=e.target,n=t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable);(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`&&!n&&(e.preventDefault(),W())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,g.useEffect)(()=>{let e=()=>{I.current=!1,h(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let U=(0,g.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
680
- `);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,$x)},[c]),ae=c?.lines??0,oe=ae>$x,se=(e,t)=>{if(t){let t=re.current>0?re.current:e;p({start:Math.min(t,e),end:Math.max(t,e)})}else re.current=e,p({start:e,end:e})},W=()=>{U.length!==0&&(re.current=1,p({start:1,end:U.length}))},ce=()=>{f&&(n(e.path,e.name,f.start,f.end),v(!0),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>v(!1),1400))},le=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated&&!rS(e.name),ue=()=>{V.current=!1,H.current&&clearTimeout(H.current),R(!1),B(!1),S(c?.text??``),b(!1),k.current&&(nS(e.name)&&w(!0),iS(e.name)&&E(!0))},de=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;ue();return}le&&c&&(k.current=nS(e.name)&&C||iS(e.name)&&T,nS(e.name)&&w(!1),iS(e.name)&&E(!1),p(null),S(c.text),b(!0))},fe=()=>{y&&c&&le&&$({type:`write_file`,path:e.path,text:x})&&(V.current=!0,B(!1),R(!0),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{V.current=!1,R(!1),B(!0)},5e3))},G=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},K=e=>{F(Math.min(200,Math.max(50,e)))},me=f?f.end-f.start+1:0,he=c?.binary??!1,ge=c?.truncated??!1,q=c?.kind??`text`,_e=nS(e.name)||rS(e.name),ve=iS(e.name),ye=_e&&C&&!y&&q===`text`&&!he,xe=ve&&T&&!y&&q===`text`&&!he,[J,Se]=(0,g.useState)(()=>{try{return localStorage.getItem(eS)===`1`}catch{return!1}});(0,g.useEffect)(()=>{try{localStorage.setItem(eS,J?`1`:`0`)}catch{}},[J]);let[we,Te]=(0,g.useState)([]),[Ee,ke]=(0,g.useState)(``),Ae=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=Ae.current;if(!e||!ye){Te([]);return}let t=[...e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)],n=Zx(t.map(e=>({level:Number(e.tagName.slice(1)),label:e.textContent??``})));t.forEach((e,t)=>{e.id||=n[t].id}),Te(n)},[ye,c?.text,e.path]),(0,g.useEffect)(()=>{let e=Ae.current;if(!e||!J||!Qx(we))return;let t=we.map(t=>e.querySelector(`#${CSS.escape(t.id)}`)).filter(e=>e!==null);if(t.length===0)return;let n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];t?.target.id&&ke(t.target.id)},{rootMargin:`0px 0px -70% 0px`});for(let e of t)n.observe(e);return()=>n.disconnect()},[we,J]);let je={"host:fp-md":_e&&q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach markdown ${C?`on`:``}`,"data-tip":s(C?`showMarkdownSource`:`showMarkdownPreview`),disabled:y,onClick:()=>w(e=>!e),children:C?(0,X.jsx)(Ue,{}):(0,X.jsx)(nt,{})}):null,"host:fp-toc":ye&&Qx(we)?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach toc ${J?`on`:``}`,"data-tip":s(J?`previewTocHide`:`previewTocShow`),onClick:()=>Se(e=>!e),children:(0,X.jsx)(De,{})}):null,"host:fp-html":ve&&q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach html ${T?`on`:``}`,"data-tip":s(T?`showHtmlSource`:`showHtmlPreview`),disabled:y,onClick:()=>E(e=>!e),children:T?(0,X.jsx)(nt,{}):(0,X.jsx)(Ue,{})}):null,"host:fp-edit":q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(ge?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!le&&!y,onClick:de,children:(0,X.jsx)(Y,{})}):null,"host:fp-wrap":q===`text`&&!he&&!ye&&!xe?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${A?`on`:``}`,"data-tip":s(A?`disableWrap`:`enableWrap`),onClick:()=>j(e=>!e),children:(0,X.jsx)(et,{})}):null,"host:fp-zoom":q===`text`&&c?(0,X.jsxs)(`span`,{className:`fp-zoom`,children:[(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-out`,"data-tip":s(`zoomOut`),disabled:ne<=50,onClick:()=>K(ne-10),children:(0,X.jsx)(M,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>F(100),children:[ne,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:ne>=200,onClick:()=>K(ne+10),children:(0,X.jsx)(te,{})})]}):null,"host:fp-ref":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach ref`,"data-tip":s(`referenceTip`),onClick:()=>r(e.path,e.name,`reference`),children:(0,X.jsx)(Oe,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${ee?`on`:``}`,"data-tip":s(ee?`exitFullscreen`:`fullscreen`),onClick:()=>N(e=>!e),children:ee?(0,X.jsx)(be,{}):(0,X.jsx)(Ce,{})}),"host:fp-close":null},Me=a===void 0?[`host:fp-md`,`host:fp-toc`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-ref`,`host:fp-full`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden&&e.id!==`host:fp-close`),Ne=e=>gn(fn(`/api/file?clientId=${encodeURIComponent(Sl())}&path=${encodeURIComponent(e)}`)),Pe=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return gn(fn(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(Sl())}${D?`&allowJs=1`:``}`))};return(0,X.jsx)(`div`,{className:`fp-overlay ${ee?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&G()},children:(0,X.jsxs)(`div`,{className:`fp ${ee?`fullscreen`:``}`,style:{"--fp-zoom":ne/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,onDoubleClick:e=>{let t=e.target;t&&!t.closest(`button, a, input`)&&N(e=>!e)},children:[(0,X.jsx)(`span`,{className:`fp-name`,title:e.path,children:e.name}),(0,X.jsx)(`span`,{className:`fp-path`,children:e.path}),(0,X.jsxs)(`span`,{className:`fp-meta`,children:[c&&q===`text`&&!he&&s(`fileLines`,{n:ae}),c&&` · ${im(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:Kh(Me,je,o)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),"aria-label":s(`close`),onClick:G,children:(0,X.jsx)(P,{})})]}),ge&&q===`text`&&!he&&(0,X.jsx)(`div`,{className:`fp-notice`,children:rS(e.name)?s(`previewLinesTruncated`,{n:U.length}):s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&q===`none`&&!he&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&q===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap clickable`,onClick:G,title:s(`clickToCloseImage`),children:(0,X.jsx)(`img`,{className:`fp-media fp-media-clickable`,src:Ne(e.path),alt:e.name,onClick:G,title:s(`clickToCloseImage`)})}),!u&&q===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Ne(e.path),controls:!0,preload:`metadata`})}),!u&&xe&&c&&(0,X.jsxs)(`div`,{className:`fp-html`,children:[(0,X.jsxs)(`div`,{className:`fp-html-bar`,children:[(0,X.jsx)(`span`,{className:`fp-html-hint`,title:s(D?`htmlJsOnTip`:`htmlJsOffTip`),children:s(D?`htmlJsOn`:`htmlJsOff`)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-html-js ${D?`on`:``}`,"data-tip":s(D?`htmlDisableJs`:`htmlEnableJs`),onClick:()=>O(e=>!e),children:s(D?`htmlDisableJs`:`htmlEnableJs`)}),(0,X.jsxs)(`a`,{className:`fp-html-btn fp-html-external`,href:Pe(e.path),target:`_blank`,rel:`noopener noreferrer`,title:s(`openInNewTab`),children:[(0,X.jsx)(Ge,{}),(0,X.jsx)(`span`,{children:s(`openInNewTab`)})]})]}),(0,X.jsx)(`iframe`,{className:`fp-html-frame`,src:Pe(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&ye&&c&&(0,X.jsx)(`div`,{className:rS(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,X.jsxs)(`div`,{className:J&&Qx(we)?`fp-toc-layout`:void 0,children:[J&&Qx(we)&&(0,X.jsx)(`nav`,{className:`fp-toc`,"aria-label":s(`previewTocLabel`),children:we.map(e=>(0,X.jsx)(`a`,{className:`l${Math.min(e.level,6)}${e.id===Ee?` on`:``}`,href:`#${e.id}`,title:e.label,onClick:t=>{t.preventDefault(),Ae.current?.querySelector(`#${CSS.escape(e.id)}`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:e.label},e.id))}),(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,ref:Ae,children:(0,X.jsx)(_f,{text:c.text})})]})}),!u&&he&&q!==`image`&&q!==`video`&&c&&(0,X.jsxs)(`div`,{className:`fp-hex-wrap`,children:[(0,X.jsxs)(`div`,{className:`fp-notice`,children:[s(`binaryFile`),c.truncated&&s(`binaryHexTruncated`)]}),(0,X.jsx)(`pre`,{className:`fp-hex`,children:c.text})]}),!u&&y&&q===`text`&&!he&&c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`fp-editor ${A?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:A?`soft`:`off`,spellCheck:!1,autoFocus:!0}),z&&(0,X.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:s(`saveResultUnknown`)})]}),!u&&!ye&&!xe&&!y&&q===`text`&&!he&&c&&U.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!ye&&!xe&&!y&&q===`text`&&!he&&U.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${m?`dragging`:``} ${A?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[U.map((e,t)=>{let n=t+1,r=f!==null&&n>=f.start&&n<=f.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(se(n,e.shiftKey),I.current=!0,h(!0))},onMouseEnter:()=>{I.current&&se(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),oe&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:$x})})]}),(y||!ye&&!xe&&q===`text`)&&(0,X.jsx)(`div`,{className:`fp-foot`,children:y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:s(`editFile`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:de,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:ie||x===(c?.text??``),onClick:fe,children:[(0,X.jsx)(pe,{}),` `,s(`saveFile`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:f?s(`selectedRange`,{n:me,start:f.start,end:f.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:U.length===0,onClick:W,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!f,onClick:()=>p(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!f||he,onClick:ce,children:[_?(0,X.jsx)(ft,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function nS(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function rS(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)}function iS(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function aS({file:e,plugin:t,declaration:n,epoch:r,send:i,onClose:a,onFallback:o}){let s=Z(),c=(0,g.useRef)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(!1),p=(0,g.useRef)(o);p.current=o;let m=n.label??t.name;return(0,g.useEffect)(()=>{let r=c.current;if(!r)return;let a=!1,o;return u(null),f(!1),(async()=>{try{let s=await my({plugin:t,declaration:n});if(a)return;if(!s)throw Error(`插件没有提供可用的文件查看器`);let c=`/plugins-api/${encodeURIComponent(t.id)}`,l={...Gc(t.id,i),file:e,apiUrl:(e,t)=>{let n=String(e??``).startsWith(`/`)?String(e):`/${String(e??``)}`,r=new URLSearchParams;for(let[e,n]of Object.entries(t??{}))n!==void 0&&r.set(e,String(n));let i=r.toString();return gn(fn(`${c}${n}${i?`?${i}`:``}`))}};o=s.handler.mount(r,e,l),a||f(!0)}catch(e){a||(console.error(`[plugin:${t.id}] file handler failed:`,e),p.current())}})(),()=>{if(a=!0,typeof o==`function`)try{o()}catch(e){console.error(`[plugin:${t.id}] file handler cleanup failed:`,e)}r.textContent=``}},[e,t,n,r,i]),(0,X.jsx)(Ny,{className:`plugin-file-preview`,title:m,icon:t.icon,onClose:a,children:(0,X.jsxs)(`div`,{className:`modal-body plugin-file-preview-body`,children:[(0,X.jsx)(`div`,{className:`plugin-file-preview-file`,title:e.path,children:e.name}),l?(0,X.jsx)(`div`,{className:`plugin-file-preview-error`,children:l}):null,!l&&!d?(0,X.jsx)(`div`,{children:s(`loading`)}):null,(0,X.jsx)(`div`,{ref:c,className:`plugin-file-preview-host`})]})})}var oS=.4,sS=1.05;function cS(e){return Math.min(300,e*.86)}function lS(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function uS(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function dS(e,t){return e===`left`?t:-t}function fS(e,t){return Math.max(-e,Math.min(0,-e+t))}function pS(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function mS(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:pS(r*sS,n,t)>=oS}var hS=new Set([`auto`,`scroll`,`overlay`]);function gS(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&hS.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function _S(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function vS(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,g.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0],i=lS(r.clientX,window.innerWidth,n);i&&!gS(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0],d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=uS(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=cS(window.innerWidth),h=m*sS;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=dS(r,d);let b=fS(h,f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(pS(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?mS({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(_S(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}function yS(e,t,n,r,i){let a=new Map;for(let e of r)a.set(e.id,!!e.isStreaming);if(t&&a.set(t,n),e===null)return{startCue:!1,finishedConvs:[],nextMap:a};let o=!1;if(t&&(i===void 0||i===t)){let n=e.get(t),r=a.get(t)??!1;n===!1&&r===!0&&(o=!0)}let s=[];for(let[n,i]of e.entries())if(i&&a.has(n)&&!a.get(n)){let e=r.find(e=>e.id===n);s.push({id:n,title:e?.title,isActive:n===t})}return{startCue:o,finishedConvs:s,nextMap:a}}var bS=(0,g.lazy)(()=>xc(()=>import(`./TerminalPanel-28naZdcs.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function xS({notice:e,onDismiss:t}){let n=Z(),{locale:r}=Nn(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(a)return;let n=setTimeout(()=>t(e.id),nl(e.level));return()=>clearTimeout(n)},[a,e.id,e.level,t]);let s=e.level===`error`?Tt:e.level===`warning`?wt:je;return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${a?` paused`:``}`,role:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onClick:()=>{window.getSelection?.()?.toString()||t(e.id)},children:[(0,X.jsx)(s,{className:`notice-icon`}),(0,X.jsx)(`span`,{className:`notice-text`,children:i}),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:n(`close`),onClick:n=>{n.stopPropagation(),t(e.id)},children:(0,X.jsx)(P,{})})]})}var SS=[],CS=180,wS=520,TS=240,ES=e=>`pi-web-ui:${e}-panel-width`;function DS(e){try{let t=Number(localStorage.getItem(ES(e)));return Number.isFinite(t)&&t>=CS&&t<=wS?t:TS}catch{return TS}}var OS=e=>`pi-web-ui:${e}-panel-collapsed`;function kS(e){try{return localStorage.getItem(OS(e))===`1`}catch{return!1}}function AS({side:e,width:t,onResize:n}){let r=Z(),i=(0,g.useCallback)(r=>{r.preventDefault();let i=r.clientX,a=t,o=a,s=t=>{let r=e===`left`?t.clientX-i:i-t.clientX;o=Math.min(wS,Math.max(CS,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`);try{localStorage.setItem(ES(e),String(o))}catch{}};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),document.body.classList.add(`panel-resizing`)},[e,t,n]);return(0,X.jsx)(`div`,{className:`resize-handle resize-${e}`,title:r(`dragToResize`),onPointerDown:i,onDoubleClick:()=>n(TS)})}function jS({side:e,onClick:t}){let n=Z();return(0,X.jsx)(`button`,{type:`button`,className:`panel-rail panel-rail-${e}`,title:n(`expandPanel`),onClick:t,children:e===`left`?(0,X.jsx)(ot,{}):(0,X.jsx)(st,{})})}var MS=`pi-web-ui:plugin-path-grants`,NS=e=>e?`${MS}:${e}`:MS;function PS(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function FS(e){try{let t=NS(e);if(localStorage.getItem(t)!==null)return PS(localStorage.getItem(t));if(!e)return[];let n=PS(localStorage.getItem(MS));return localStorage.setItem(t,JSON.stringify(n)),n}catch{return[]}}function IS(e,t){try{let n=[...new Set([...FS(t),e])];localStorage.setItem(NS(t),JSON.stringify(n))}catch{}}function LS(){let e=Z(),{locale:t}=Nn(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=Ll(),s=(0,g.useRef)(!1);(0,g.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:tx[t]??tx.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=Sb();(0,g.useEffect)(()=>{let t=l?hb(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,g.useState)([]);(0,g.useEffect)(()=>(ar(e=>d(t=>Vg(t,e))),()=>ar(null)),[]);let[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(null),_=(0,g.useRef)(!1),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{_.current=f!==null,v.current=m},[f,m]);let y=(0,g.useCallback)((e,t)=>{let n=py(t);if(n){p(null),h({file:{path:e,name:t},plugin:n.plugin,declaration:n.declaration});return}h(null),p({path:e,name:t})},[]);(0,g.useEffect)(()=>(lf({open:e=>y(e.path,e.name),isOpen:()=>_.current||v.current!==null}),()=>lf(null)),[y]);let[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=()=>x(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[S,C]=(0,g.useState)(`chat`),w=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(S.startsWith(`plugin:`)?`plugins`:S)?S:`chat`,T=(0,g.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),E=(0,g.useMemo)(()=>{let r=[],i=$i(Hi(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout,diagnostics:r});for(let e of r)console.warn(`[ui-slot] ${e.pluginId?`[${e.pluginId}] `:``}${e.message}`);return i},[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),D=(0,g.useMemo)(()=>E[`topbar.primary`].filter(e=>!e.hidden),[E]),O=(0,g.useMemo)(()=>[...E[`topbar.primary`].filter(e=>e.hidden),...E[`topbar.overflow`]],[E]),k=(0,g.useMemo)(()=>E[`leftpanel.sessions`].filter(e=>!e.hidden),[E]),A=(0,g.useMemo)(()=>E[`leftpanel.projects.actions`].filter(e=>!e.hidden),[E]),j=(0,g.useMemo)(()=>E[`leftpanel.project`].filter(e=>!e.hidden),[E]),ee=(0,g.useMemo)(()=>E[`leftpanel.running.actions`].filter(e=>!e.hidden),[E]),M=(0,g.useMemo)(()=>E[`leftpanel.history.actions`].filter(e=>!e.hidden),[E]),te=E[`leftpanel.sections`],N=(0,g.useMemo)(()=>E[`leftpanel.running`].filter(e=>!e.hidden),[E]),ne=(0,g.useMemo)(()=>E[`leftpanel.history`].filter(e=>!e.hidden),[E]),F=(0,g.useMemo)(()=>E[`terminal.toolbar`].filter(e=>!e.hidden),[E]),re=(0,g.useMemo)(()=>E[`scm.toolbar`].filter(e=>!e.hidden),[E]),I=(0,g.useMemo)(()=>E[`goalbar.actions`].filter(e=>!e.hidden),[E]),L=(0,g.useMemo)(()=>E[`chat.header`].filter(e=>!e.hidden),[E]),ie=(0,g.useMemo)(()=>E[`chat.empty`].filter(e=>!e.hidden),[E]),R=(0,g.useMemo)(()=>E[`file.preview.toolbar`].filter(e=>!e.hidden),[E]),z=(0,g.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(n=>[n.id,R_(n,t,e).name])),[n.dshPresets,t]),B=(0,g.useMemo)(()=>E[`notice.actions`].filter(e=>!e.hidden),[E]),V=(0,g.useMemo)(()=>E[`sidebar.left`]??[],[E]),H=(0,g.useMemo)(()=>E[`sidebar.right`]??[],[E]),U=(0,g.useCallback)((t,n,i)=>{if(t.id===`host:msg-fork`){i?.id&&r({type:`fork_session`,messageId:i.id,position:`before`});return}if(t.id===`host:msg-rollback`){i?.id&&Cm({messageId:i.id});return}let o=(t.action??``).trim();if(t.kind===`view`||(!o||o===`view`)&&t.source!==`host`){C(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}o&&Bs(t.source.startsWith(`plugin:`)?t.source.slice(7):``,o,t.id,{...n===void 0?{}:{value:n},...i===void 0?{}:{target:i},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?Uc(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),ae=(0,g.useCallback)(e=>{let t=n.plugins.find(t=>t.id===e.source.slice(7));return t?(0,X.jsx)(Tu,{plugin:t,epoch:n.pluginsEpoch,send:r,className:`lp-plugin-page`}):null},[n.plugins,n.pluginsEpoch,r]),oe=(0,g.useCallback)((t,n)=>{n.action&&Bs(t.pluginId,n.action,n.id,{target:{id:n.id,kind:`plugin-running`,label:n.title},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?Uc(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[se,W]=(0,g.useState)([]);(0,g.useEffect)(()=>Ic(W),[]);let[ce,le]=(0,g.useState)([]);(0,g.useEffect)(()=>Pc(le),[]);let[ue,de]=(0,g.useState)(null),fe=ue?E[`modal.dialog`].find(e=>e.id===ue&&!e.hidden):void 0,pe=(0,g.useMemo)(()=>{if(!fe||fe.kind!==`view`)return``;let e=fe.view??``;return e.startsWith(`plugin:`)?e.slice(7):fe.source.startsWith(`plugin:`)?fe.source.slice(7):``},[fe]);(0,g.useEffect)(()=>{if(!fe||!pe||se.some(e=>e.info.id===pe))return;let e=G.current.plugins.find(e=>e.id===pe);e&&Uc(e,G.current.pluginsEpoch)},[fe,pe,se,n.pluginsEpoch]),(0,g.useEffect)(()=>{Rd(r),zd(T,n.pluginsEpoch),Kd(T,n.pluginsEpoch),fy(T,n.pluginsEpoch),Wc(T,n.pluginsEpoch)},[T,n.pluginsEpoch,r]);let G=(0,g.useRef)(n);G.current=n;let me=(0,g.useRef)(C);me.current=C;let he=(0,g.useRef)(E);he.current=E,(0,g.useEffect)(()=>(Ns(Ms({send:r,isReady:()=>!!G.current.state,setView:e=>me.current(e),getCwd:()=>G.current.state?.cwd??``,getWorkspaceRoots:()=>G.current.state?.workspaceRoots??[],listSessions:()=>{let e=G.current,t=e.state?.cwd??``;return[...e.conversations.map(e=>({id:e.id,title:e.title,cwd:e.cwd||t,kind:`running`,isStreaming:e.isStreaming})),...e.sessions.map(e=>({id:e.path,title:e.name||e.firstMessage||e.path,cwd:t,kind:`history`}))]},getConversationId:()=>G.current.state?.conversationId??null,isConversationBlank:()=>(G.current.state?.messages.length??0)===0,listModels:()=>G.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=G.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>G.current.projects.map(e=>e.path),grantedPaths:FS,grantPath:IS,confirm:e=>new Promise(t=>{if(Ue.current){t(!1);return}let n={path:e.path,resolve:t};Ue.current=n,He(n)}),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=he.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(de(t),!0)},closeModal:()=>de(null),dialogConfirm:e=>new Promise(t=>{if(Y.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Y.current=n,Ge(n)}),select:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Y.current=n,qe([]),Ge(n)}),input:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`input`,title:e.title,...typeof e.placeholder==`string`?{placeholder:e.placeholder}:{},...typeof e.initial==`string`?{initial:e.initial}:{},resolve:t};Y.current=n,Ye(e.initial??``),Ge(n)}),notifyAction:e=>new Promise(t=>{try{let n=Qe.current;Qe.current=null,Ze(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Qe.current=r,Ze(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=G.current.plugins.find(t=>t.id===e);return t?Uc(t,G.current.pluginsEpoch):Promise.resolve(!1)}})),()=>Ns(null)),[r]);let[ge,q]=(0,g.useState)(()=>DS(`left`)),[_e,ve]=(0,g.useState)(()=>DS(`right`)),ye=(0,g.useCallback)(e=>q(e),[]),be=(0,g.useCallback)(e=>ve(e),[]),[xe,J]=(0,g.useState)(()=>kS(`left`)),[Se,Ce]=(0,g.useState)(()=>kS(`right`)),we=(0,g.useCallback)(()=>{J(e=>{try{localStorage.setItem(OS(`left`),e?`0`:`1`)}catch{}return!e})},[]),Te=(0,g.useCallback)(()=>{Ce(e=>{try{localStorage.setItem(OS(`right`),e?`0`:`1`)}catch{}return!e})},[]),[Ee,De]=(0,g.useState)(null),Oe=(0,g.useRef)(null),[ke,Ae]=(0,g.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,g.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>Ae(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),vS({enabled:ke&&w===`chat`,open:Ee,onOpenChange:De,container:Oe,backdropSelector:`.drawer-backdrop.persistent`});let[je,Me]=(0,g.useState)(!1),[Ne,Pe]=(0,g.useState)(!1),[Fe,Ie]=(0,g.useState)(!1),[Le,Re]=(0,g.useState)(),[ze,Be]=(0,g.useState)(null),[Ve,He]=(0,g.useState)(null),Ue=(0,g.useRef)(null),[We,Ge]=(0,g.useState)(null),Y=(0,g.useRef)(null),[Ke,qe]=(0,g.useState)([]),[Je,Ye]=(0,g.useState)(``),[Xe,Ze]=(0,g.useState)(null),Qe=(0,g.useRef)(null),[$e,et]=(0,g.useState)(()=>new Set),tt=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),et(t=>new Set(t).add(e))},nt=n.pathRequests.find(e=>!$e.has(e.id))??null,[rt,it]=(0,g.useState)(()=>new Set),at=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),it(t=>new Set(t).add(e))},ot=n.permRequests.find(e=>!rt.has(e.id))??null,st=db(),[ct,lt]=(0,g.useState)(!1),[ut,dt]=(0,g.useState)(!1),[ft,pt]=(0,g.useState)(!1),[mt,ht]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!mt)return;let e=setTimeout(()=>ht(null),15e3);return()=>clearTimeout(e)},[mt]);let[gt,_t]=(0,g.useState)(null),vt=(0,g.useRef)(null),yt=(0,g.useRef)(null),bt=n.state?.sessionId??``,xt=(0,g.useRef)(bt);xt.current=bt;let St=(0,g.useRef)(n.ready);St.current=n.ready,(0,g.useEffect)(()=>{let e=()=>{let e=Vo(window.location.hash);if(e){if(e.messageId?_t({sessionId:e.sessionId,messageId:e.messageId}):_t(null),!St.current||!xt.current){vt.current=e.sessionId;return}xt.current!==e.sessionId&&(yt.current=e.sessionId,C(`chat`),r({type:`switch_session`,path:``,sessionId:e.sessionId}))}};return e(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[r]),(0,g.useEffect)(()=>{let e=yt.current;if(e&&n.notices.some(t=>t.text.includes(e)&&(t.text.includes(`未找到会话`)||t.text.includes(`Session not found`)))&&(yt.current=null,_t(null),bt)){let e=Ho({sessionId:bt});window.location.hash!==e&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${e}`)}},[n.notices,bt]),(0,g.useEffect)(()=>{if(!n.ready||!bt)return;if(vt.current){let e=vt.current;if(vt.current=null,e!==bt){yt.current=e,C(`chat`),r({type:`switch_session`,path:``,sessionId:e});return}}if(yt.current){if(bt===yt.current)yt.current=null;else return}let e=Vo(window.location.hash),t=e?.sessionId===bt?e.messageId:void 0,i=Ho({sessionId:bt,...t?{messageId:t}:{}});window.location.hash!==i&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${i}`)},[n.ready,bt,r]),(0,g.useEffect)(()=>{let t=t=>{let i=t.detail,a=i?.title||e(`pluginCommandFallback`),s=i?.command;if(!s||!n.ready)return;let c={name:a,command:s,cwd:"${pwd}"},l=n.terminals.find(e=>e.title===a);if(l)o.restart(l.id),r({type:`run_command`,terminalId:l.id,conversationId:l.conversationId,command:c,cols:80,rows:24});else{let e=jt();o.create({id:e,conversationId:n.activeConversationId||n.state?.conversationId||``,title:a,cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:c})}C(`terminal`)};window.addEventListener(`pi-web-ui:plugin-run-command`,t);let i=e=>{let t=e.detail;typeof t==`string`&&t&&r({type:`switch_conversation`,id:t})};return window.addEventListener(`pi-web-ui:switch-conversation`,i),()=>{window.removeEventListener(`pi-web-ui:plugin-run-command`,t),window.removeEventListener(`pi-web-ui:switch-conversation`,i)}},[n,o,r]),(0,g.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),dt(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[Ct,wt]=(0,g.useState)(qy),[Tt,Et]=(0,g.useState)(Gt),{themes:Dt,theme:Ot,switchTheme:kt,reloadThemes:At}=rf();Vb(),(0,g.useEffect)(()=>{try{typeof pc==`function`&&pc(Ot??``)}catch{}},[Ot]),(0,g.useEffect)(()=>{try{typeof mc==`function`&&mc(t)}catch{}},[t]),(0,g.useEffect)(()=>{try{typeof hc==`function`&&hc(w)}catch{}},[w]),(0,g.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof lc==`function`&&lc(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,g.useEffect)(()=>{if(!We)return;let e=e=>{if(e.key!==`Escape`)return;let t=Y.current;Y.current=null,Ge(null);try{if(!t)return;t.kind===`confirm`?t.resolve(!1):t.resolve({ok:!1})}catch{}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[We]),(0,g.useEffect)(()=>{if(!Xe)return;let e=setTimeout(()=>{let e=Qe.current;Qe.current=null,Ze(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Xe]);let Mt=(0,g.useRef)(null),Nt=(0,g.useRef)(null),Pt=(0,g.useRef)(n.state?.messages);Pt.current=n.state?.messages;let Ft=(0,g.useRef)(new Set),It=(0,g.useRef)(new Set),Lt=(0,g.useRef)(new Set),Rt=(0,g.useRef)(0),zt=(0,g.useRef)(!1),Bt=(0,g.useRef)(n.terminals);(0,g.useEffect)(()=>{Jy(Ct)},[Ct]),(0,g.useEffect)(()=>{Kt(Tt)},[Tt]),(0,g.useEffect)(()=>{let e=Bt.current;Bt.current=n.terminals;for(let t of n.terminals){let n=t.command?.command??``;e.find(e=>e.id===t.id)?.running&&!t.running&&(n.startsWith(`pi remove `)?r({type:`extensions_reload`}):n.startsWith(`pi-web-ui install `)||n.startsWith(`pi-web-ui uninstall `)?r({type:`plugins_reload`}):n.startsWith(`npm i -g `)&&(r({type:`extensions_reload`}),r({type:`plugins_reload`}),r({type:`check_updates_all`,force:!0})))}},[n.terminals,r]),(0,g.useEffect)(()=>{let t=n.state?.conversationId??null,r=yS(Mt.current,t,n.state?.isStreaming??!1,n.conversations,Nt.current);if(Mt.current=r.nextMap,Nt.current=t,r.startCue&&$y(`start`,Ct),r.finishedConvs.length>0){$y(`done`,Ct);let t=r.finishedConvs.find(e=>e.isActive);if(t&&(ai(e(`notifyDoneTitle`),e(`notifyDoneBody`)),Tt.enabled&&!Kr($r()))){if(Tt.readReplies){let t=Xt(Pt.current);t?on(t,Tt):Tt.announce&&on(e(`ttsAnnounceDone`),Tt)}else Tt.announce&&on(e(`ttsAnnounceDone`),Tt)}for(let t of r.finishedConvs.filter(e=>!e.isActive)){let n=t.title?`${t.title}:${e(`notifyDoneBody`)}`:e(`notifyDoneBody`);ai(e(`notifyDoneTitle`),n)}!t&&Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceDone`),Tt)}},[n.state?.conversationId,n.state?.isStreaming,n.conversations,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.dialog?.id??null;if(t!==null&&!Ft.current.has(t)){if(Ft.current.add(t),Ft.current.size>64){let e=Ft.current.values().next().value;e!==void 0&&Ft.current.delete(e)}$y(`question`,Ct),ai(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceQuestion`),Tt)}},[n.dialog,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null,i=!1;t!==null&&!It.current.has(t)&&(It.current.add(t),i=!0),r!==null&&!It.current.has(r)&&(It.current.add(r),i=!0);for(let e of n.conversations){if(!e.hasQuestion)continue;let n=e.questionId?`q:${e.questionId}`:`conv-q:${e.id}`;It.current.has(n)||(It.current.add(n),e.questionId&&It.current.add(e.questionId),t!==e.questionId&&(i=!0))}if(It.current.size>64){let e=It.current.values().next().value;e!==void 0&&It.current.delete(e)}i&&($y(`question`,Ct),ai(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceQuestion`),Tt))},[n.question,n.remoteQuestion,n.conversations,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.approval,r=t?.id??null;if(r!==null&&!Lt.current.has(r)){if(Lt.current.add(r),Lt.current.size>64){let e=Lt.current.values().next().value;e!==void 0&&Lt.current.delete(e)}$y(`approval`,Ct);let n=typeof t?.toolName==`string`?t.toolName:``;ai(e(`notifyApprovalTitle`),n?e(`notifyApprovalBodyTool`,{tool:n}):e(`notifyApprovalBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceApproval`),Tt)}},[n.approval,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==Rt.current&&(Rt.current=t.id,$y(`error`,Ct),ai(e(`notifyErrorTitle`),e(`notifyErrorBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceError`),Tt))},[n.notices,Ct,Tt,e]);let Vt=(0,g.useRef)(new Set);(0,g.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||Vt.current.has(t.id))continue;Vt.current.add(t.id);let e=``;for(let n of t.content??[]){if(n.type!==`text`)continue;let t=/🔗 已自动在浏览器打开\]\((\/(?!\/)[^)\s]+)\)/.exec(n.text??``);if(t?.[1]){e=t[1];break}}if(!e)continue;let n=null;try{let t=new URL(fn(e),window.location.href);t.origin===window.location.origin&&document.hasFocus()&&(n=window.open(t.href,`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let Ht=(e,t,n,r=!1,i,a=!1)=>{let o=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(a=>a.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===o)?a:[...a,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}]);let s=n===`page`?t:e;!a&&s&&nr(`@${s} `)},Ut=e=>{let t=``;d(n=>n.filter(n=>{let r=n.key?n.key===e:n.mode===`conversation`?`conv|${n.conversationId??``}|${n.sessionPath??``}`===e:n.path===e;return r&&!t&&(t=n.mode===`page`||n.mode===`conversation`?n.name:n.path),!r})),t&&rr(`@${t}`)},Wt=(0,g.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&De(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&C(e=>e===`chat`?e:`chat`),r(e)),[r]),qt=(0,g.useRef)(new Set),Jt=n.activeConversationId||n.state?.conversationId||``;(0,g.useEffect)(()=>{let t=n.conversations.filter(e=>e.hasQuestion),r=new Set(t.map(e=>e.id)),i=new Set(t.map(e=>e.questionId).filter(Boolean));for(let e of qt.current)i.has(e)||qt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===Jt){Xv(t,{silent:!0});continue}n.questionId&&qt.current.has(n.questionId)||Yv({id:t,type:`question`,title:n.title||e(`chat`),message:n.questionTitle||e(`waitingQuestionBadge`),persistent:!0,dismissible:!0,data:{conversationId:n.id,questionId:n.questionId},onClose:()=>{n.questionId&&qt.current.add(n.questionId)},onClick:()=>{Wt({type:`switch_conversation`,id:n.id}),Xv(t,{silent:!0})}})}Zv(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===Jt:!1},{silent:!0})},[n.conversations,Jt,Wt,e]);let Yt=(0,g.useRef)(0),Zt=(0,g.useRef)(0),Qt=(0,g.useCallback)(t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-Zt.current>1e4&&(Zt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++Yt.current}`;d(e=>[...e,{path:``,key:i,name:t.name,imageData:t.data,mimeType:t.mimeType}])},[n.state?.model,a,e]),$t=(0,g.useCallback)(async t=>{for(let n of t){let t=await Qp(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}Qt(t)}},[Qt,a,e]),en=20971520,tn=(0,g.useRef)(0),nn=(0,g.useCallback)(async t=>{if(t.size>en){a(`warning`,e(`fileTooLarge`,{name:t.name,size:en/1024/1024}));return}let n;try{n=(await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(t)})).replace(/^data:[^;]*;base64,/,``)}catch{a(`error`,e(`fileLoadFailed`,{name:t.name}));return}let r=`upload-${++tn.current}`;d(e=>[...e,{path:``,key:r,name:t.name,fileData:n,size:t.size,mimeType:t.type||void 0}])},[en,a,e]),rn=(0,g.useCallback)(async e=>{for(let t of e)Zp(t.type)?await $t([t]):await nn(t)},[$t,nn]),an=(0,g.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),sn=(0,g.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[cn,ln]=(0,g.useState)([]),un=(0,g.useRef)(0),dn=(0,g.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),un.current+=1;let i=Zu(t),a={text:i.text,seq:un.current};i.quotes.length&&d(e=>Vg(e,i.quotes.map(e=>({path:``,name:``,mode:`quote`,quote:e,key:jt()})))),ln(e=>[...e.slice(-9),a])},[r]),pn=(0,g.useCallback)(()=>Pe(!0),[]),mn=(0,g.useCallback)(()=>d([]),[]);sy(n.state?.sessionId??``,mn);let hn=(0,g.useCallback)(Ut,[]),gn=$t,_n=rn,vn=(0,g.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),yn=(0,g.useCallback)(e=>Ht(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines,e.silent??!1),[]),bn=n.state?.model,xn=n.state?.thinkingLevel,Sn=n.state?.availableThinkingLevels,Cn=(0,g.useMemo)(()=>bn?{model:bn,thinkingLevel:xn??`off`,availableThinkingLevels:Sn??[]}:null,[bn,xn,Sn]),wn=(0,g.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:jt(),conversationId:n.activeConversationId||n.state?.conversationId||``,title:e(`terminalTitle`,{n:1}),cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null}),!0),[n.ready,n.state?.cwd,n.terminals.length,e,o]);return(0,g.useEffect)(()=>{if(zt.current){if(w!==`terminal`||n.terminals.length!==0){zt.current=!1;return}wn()&&(zt.current=!1)}},[n.terminals.length,wn,w]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),x(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(!1)},onDrop:t=>{if(x(!1),!Array.from(t.dataTransfer?.types??[]).includes(`Files`))return;t.preventDefault();let n=Array.from(t.dataTransfer?.files??[]);if(n.length===0){a(`warning`,e(`foldersNotSupported`));return}let r=n.filter(e=>Zp(e.type)),i=n.filter(e=>!Zp(e.type));r.length>0&&$t(r),i.length>0&&rn(i)},children:[b&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Io,{chat:n,terminal:o,view:w,plugins:T,uiPrimary:D,uiOverflow:O,uiContextTopbar:E[`contextmenu.topbar`],onUiAction:U,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:()=>{Re(void 0),Ie(!0)},onManagePlugins:()=>{Re(`plugins`),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onOpenIconEdit:()=>pt(!0),sound:Ct,onSoundChange:wt,onSoundPreview:e=>$y(e,Ct),themes:Dt,theme:Ot,onThemeChange:kt,reloadThemes:At}),ft&&(0,X.jsx)(oy,{slots:E,layout:n.settings?.uiLayout,exclude:Pi,onClose:()=>pt(!1)}),n.protocolMismatch&&(0,X.jsxs)(`div`,{className:`protocol-banner`,children:[`⚠ `,e(`protocolMismatch`)]}),(0,X.jsxs)(`div`,{className:`notices`,children:[n.notices.map(e=>(0,X.jsx)(xS,{notice:e,onDismiss:i},e.id)),Xe&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Xe.text}),Xe.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Qe.current;Qe.current=null,Ze(null);try{t?.resolve(e.id)}catch{}},children:e.label},e.id)),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:e(`close`),onClick:()=>{let e=Qe.current;Qe.current=null,Ze(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(P,{})})]}),B.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:B.map(e=>e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`btn btn-slot notice-select`,title:e.hint??e.label,"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>U(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id):(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-slot`,title:e.hint??e.label,onClick:()=>U(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(Rh,{currentModelId:bn?`${bn.provider}/${bn.id}`:null,children:(0,X.jsxs)(`div`,{ref:Oe,className:`layout`,style:{"--left-w":`${ge}px`,"--right-w":`${_e}px`},children:[ke?(0,X.jsx)(`div`,{className:`drawer-backdrop persistent${Ee?` on`:``}`,onClick:()=>De(null)}):Ee&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>De(null)}),(0,X.jsx)(mv,{side:`left`,items:V,chat:n,view:w,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:e=>{Re(e),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onUiAction:U,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>kt(Ot===`light`?null:`light`),onSoundToggle:()=>wt({...Ct,enabled:!Ct.enabled})}),(0,X.jsxs)(`div`,{className:`view-pane ${w===`chat`?``:`hidden`}`,children:[!ke&&xe&&(0,X.jsx)(jS,{side:`left`,onClick:we}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${Ee===`left`?`open`:``}${ke?``:xe?` hidden`:``}`,children:(0,X.jsx)(eu,{collapsible:!ke,onToggleCollapse:we,panelSend:Wt,active:!ke||Ee===`left`,sessionFile:n.state?.sessionFile??null,conversations:n.conversations,elsewhere:n.elsewhere,sessions:n.sessions,projects:n.projects,pathCompletions:n.pathCompletions,activeConversationId:n.activeConversationId,uiContextSession:E[`contextmenu.session`],uiLeftSessions:k,uiContextProject:E[`contextmenu.project`],uiProjectsActions:A,uiLeftProject:j,uiRunningActions:ee,uiHistoryActions:M,uiSections:te,renderPluginSectionBody:ae,uiLeftRunning:N,uiLeftHistory:ne,uiPluginRunning:n.pluginPanelGroups,onPluginRunningAction:oe,onUiAction:U,presetNames:z,transition:n.transition,onOpenSandboxModal:()=>Be(`create`)})}),!ke&&(0,X.jsx)(AS,{side:`left`,width:ge,onResize:ye}),(0,X.jsxs)(`main`,{className:`${st?`main wide-chat`:`main`}${n.transition&&!n.transition.previewMessages?.length?` main-transitioning`:``}`,children:[n.transition&&(0,X.jsxs)(`div`,{className:`workspace-transition-bar phase-${n.transition.phase}`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`div`,{className:`workspace-transition-track`,children:(0,X.jsx)(`div`,{className:`workspace-transition-fill`,style:{width:`${Math.min(100,Math.max(8,n.transition.progress))}%`}})}),(0,X.jsxs)(`div`,{className:`workspace-transition-pill`,children:[(0,X.jsx)(`span`,{className:`workspace-transition-spinner`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`workspace-transition-text`,children:t!==`zh`&&n.transition.textEn?n.transition.textEn:n.transition.text}),(0,X.jsxs)(`span`,{className:`workspace-transition-pct`,children:[n.transition.progress,`%`]})]})]}),L.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:Wh(L,U)}),n.state?(0,X.jsxs)(X.Fragment,{children:[n.state.sandbox&&(0,X.jsxs)(`div`,{className:`sandbox-banner`,role:`region`,"aria-label":n.state.sandbox.name,children:[(0,X.jsxs)(`div`,{className:`sandbox-banner-info`,children:[(0,X.jsxs)(`span`,{className:`sandbox-banner-title`,children:[`🧪 `,e(`sandboxBannerTitle`,{name:n.state.sandbox.name}),(0,X.jsx)(`span`,{className:`lp-sandbox-badge ${n.state.sandbox.ephemeral?`ephemeral`:`permanent`}`,children:n.state.sandbox.ephemeral?e(`sandboxBadgeEphemeral`):e(`sandboxBadgePermanent`)})]}),(0,X.jsx)(`span`,{className:`sandbox-banner-desc`,children:n.state.sandbox.sourcePath?e(`sandboxBannerSourceDesc`,{source:n.state.sandbox.sourcePath}):e(`sandboxBannerBlankDesc`)})]}),(0,X.jsxs)(`div`,{className:`sandbox-banner-actions`,children:[n.state.sandbox.ephemeral&&(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionPersistTip`),onClick:()=>r({type:`persist_sandbox`,path:n.state?.sandbox?.path}),children:[`📌 `,e(`sandboxActionPersist`)]}),n.state.sandbox.sourcePath&&(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn primary`,title:e(`sandboxActionApplySourceTip`),onClick:()=>Be(`apply`),children:[`✅ `,e(`sandboxActionApplySource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionPromoteTip`),onClick:()=>Be(`promote`),children:[`📤 `,e(`sandboxActionPromote`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionResetTip`),onClick:()=>{let t=n.state?.sandbox;t&&window.confirm(e(`sandboxActionResetConfirm`,{name:t.name}))&&r({type:`reset_sandbox`,path:t.path})},children:[`🔄 `,e(`sandboxActionReset`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn danger`,title:e(`sandboxActionDestroyTip`),onClick:()=>{let t=n.state?.sandbox;t&&window.confirm(e(`sandboxActionDestroyConfirm`,{name:t.name}))&&r({type:`destroy_sandbox`,path:t.path})},children:[`🗑️ `,e(`sandboxActionDestroy`)]})]})]}),n.state.isEphemeral&&(0,X.jsxs)(`div`,{className:`ephemeral-banner`,children:[(0,X.jsxs)(`span`,{children:[`🎭 `,e(`ephemeralBannerText`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`ephemeral-save`,onClick:()=>r({type:`persist_conversation`,id:Jt}),children:[`💾 `,e(`saveEphemeral`)]})]}),(0,X.jsx)(Ig,{uiMessageActions:E[`message.actions`],uiContextMessage:E[`contextmenu.message`],uiContextToolCall:E[`contextmenu.toolcall`],uiChatEmpty:ie,onUiAction:U,state:n.transition?.previewMessages?.length?{...n.state,messages:n.transition.previewMessages,streamingMessage:null,isStreaming:!1}:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:an,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Ah(`${e.provider}/${e.id}`)}},onRemoveQueued:sn,onRecallQueued:dn,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,keepRecent:n.settings?.keepRecentMessages,jumpTarget:mt,onJumpDone:()=>ht(null),urlJumpMessageId:gt&&gt.sessionId===n.state.sessionId?gt.messageId:null,onUrlJumpDone:()=>_t(null)},n.transition?.previewMessages?.length?`preview:${n.transition.target}`:n.state.conversationId??`boot`)]}):(0,X.jsx)(`div`,{className:`boot-wait`,children:n.ready?e(`loadingSession`):e(`connectingServer`)}),n.settings?.goalModeEnabled!==!1&&(0,X.jsx)(`div`,{className:`goalbar-slot`,children:(0,X.jsx)(Q_,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:I,onUiAction:U})}),(0,X.jsx)(Hv,{onAction:(e,t,n)=>U(e,n,t)}),n.dialog&&(0,X.jsx)(hv,{dialog:n.dialog}),We&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":We.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),We.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:We.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),We.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(We.options??[]).map((e,t)=>{let n=We.multi?Ke.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(We.multi){qe(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Y.current;Y.current=null,Ge(null);try{n?.resolve({ok:!0,selected:[e.label]})}catch{}},children:[e.label,e.description&&(0,X.jsx)(`span`,{className:`dialog-hint`,children:e.description})]},t)}),(We.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),We.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current,t=(e?.options??[]).filter((e,t)=>Ke.includes(t)).map(e=>e.label);Y.current=null,Ge(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),We.kind===`confirm`&&(0,X.jsx)(`div`,{className:`dialog-body`,children:(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),We.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Je,placeholder:We.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>Ye(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!0,value:Je})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!0,value:Je})}catch{}},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Tv,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||Jt))?.title}),n.remoteQuestion&&(0,X.jsx)(Tv,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(Mx,{plan:n.activeConversationId&&n.state?.conversationId!==n.activeConversationId?null:n.state?.plan}),(0,X.jsx)(Z_,{composerLeading:E[`composer.leading`],composerActions:E[`composer.actions`],onUiAction:U,streaming:n.state?.isStreaming??!1,planMode:n.state?.planMode??!1,messages:n.state?.messages??SS,slashCommands:n.slashCommands,modelState:Cn,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:hn,onAddImageFiles:gn,onAddLocalFiles:_n,onAddPathAttachment:yn,fileSearch:n.fileSearch,onSearchFiles:vn,onNotice:a,onManageModels:pn,onSent:mn,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:cn,dshPermCurrent:n.state?.permission??null,dshPermOptions:n.dshPermission?.options??void 0,dshPermDefault:n.dshPermission?.defaultPreset,dshPreset:n.state?.agentPreset??null,dshPresets:n.dshPresets?.presets??void 0,dshPresetDefault:n.dshPresets?.defaultPreset,dshBlank:(n.state?.messages?.length??0)===0,conversationId:n.activeConversationId||n.state?.conversationId||``,sessionDraft:n.engine===`pi`?n.state?.draft??null:null,sessionId:n.state?.sessionId??``})]}),!ke&&(0,X.jsx)(AS,{side:`right`,width:_e,onResize:be}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${Ee===`right`?`open`:``}${ke?``:Se?` hidden`:``}`,children:(0,X.jsx)(Ju,{collapsible:!ke,onToggleCollapse:Te,panelSend:Wt,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{De(null),Ht(e,t,n,r)},onPreview:(e,t)=>{De(null),y(e,t)},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:E[`rightpanel.tabs`],uiContextFile:E[`contextmenu.file`],plugins:T,pluginsEpoch:n.pluginsEpoch,send:r})}),!ke&&Se&&(0,X.jsx)(jS,{side:`right`,onClick:Te})]}),(0,X.jsx)(`div`,{className:`view-pane ${w===`terminal`?``:`hidden`}`,children:(0,X.jsx)(g.Suspense,{fallback:null,children:(0,X.jsx)(bS,{chat:n,terminal:o,uiTerminalToolbar:F,onUiAction:U})})}),(0,X.jsx)(`div`,{className:`view-pane ${w===`git`?``:`hidden`}`,children:(0,X.jsx)(zv,{chat:n,terminal:o,active:w===`git`,onSwitchToTerminal:()=>C(`terminal`),uiScmToolbar:re,onUiAction:U})}),se.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${w===t?``:`hidden`}`,children:(0,X.jsx)(Bv,{entry:e})},e.info.id)}),w.startsWith(`plugin:`)&&!se.some(e=>`plugin:${e.info.id}`===w)&&(0,X.jsx)(Vv,{pluginId:w.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===w),epoch:n.pluginsEpoch,failed:ce.includes(w.slice(7))}),(0,X.jsx)(mv,{side:`right`,items:H,chat:n,view:w,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:e=>{Re(e),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onUiAction:U,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>kt(Ot===`light`?null:`light`),onSoundToggle:()=>wt({...Ct,enabled:!Ct.enabled})})]})}),(0,X.jsx)(nv,{chat:n,bottombarItems:E.bottombar,onUiAction:U,onOpenSettings:()=>{Re(void 0),Ie(!0)},onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenGlobalSearch:()=>dt(!0),onOpenBgTasks:()=>lt(!0)}),f&&(0,X.jsx)(tS,{file:f,content:n.fileContent,onAddLines:(e,t,n,r)=>Ht(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>Ht(e,t,n),onClose:()=>p(null),uiFilePreviewToolbar:R,onUiAction:U}),m&&(0,X.jsx)(aS,{file:m.file,plugin:m.plugin,declaration:m.declaration,epoch:n.pluginsEpoch,send:r,onClose:()=>h(null),onFallback:()=>{h(null),p(m.file)}}),n.ready&&n.state&&n.state.piConfigured===!1&&!je&&!Ne&&(0,X.jsx)(gy,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>Me(!0)}),Ne&&(0,X.jsx)(Ey,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,testModelConnectionResult:n.testModelConnectionResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,refreshProviderResult:n.refreshProviderResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,defaultModel:n.defaultModel,onClose:()=>Pe(!1)}),Fe&&(0,X.jsx)(Tx,{chat:n,terminal:o,initialSection:Le,onSwitchToTerminal:()=>C(`terminal`),onClose:()=>Ie(!1),onOpenIconEdit:()=>pt(!0),sound:Ct,onSoundChange:wt,tts:Tt,onTtsChange:Et}),ct&&(0,X.jsx)(Dx,{servers:n.bgServers,plugins:n.plugins,epoch:n.pluginsEpoch,send:r,onUiAction:U,autoCleanupMin:n.settings?.bgAutoCleanupMin??0,onClose:()=>lt(!1)}),(0,X.jsx)(Hx,{}),(0,X.jsx)(Ox,{}),(0,X.jsx)(kx,{approval:n.approval}),n.tuiOverlay&&(0,X.jsx)(Ax,{overlay:n.tuiOverlay}),fe&&(0,X.jsx)(Jx,{entry:fe,pluginView:pe?se.find(e=>e.info.id===pe):void 0,onUiAction:(e,t)=>{U(e,t),de(null)},onClose:()=>de(null)}),(0,X.jsx)(qx,{open:ut,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>dt(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];ht(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{y(e,t)}}),(ot||nt||Ve)&&(0,X.jsxs)(`div`,{className:`modal-backdrop perm-modal-backdrop`,children:[ot&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginPermTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>at(ot.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[ot.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,ot.pluginId).replace(`{hosts}`,(ot.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,ot.pluginId).replace(`{models}`,(ot.models??[]).length>0?` ${(ot.models??[]).join(`, `)}`:``),ot.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:ot.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>at(ot.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>at(ot.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>at(ot.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),nt&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginGrantRequestTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>tt(nt.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,nt.pluginId).replace(`{path}`,nt.path),nt.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:nt.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>tt(nt.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>tt(nt.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),Ve&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginSessionGrantTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{Ue.current=null,Ve.resolve(!1),He(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,Ve.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Ue.current=null,Ve.resolve(!1),He(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{Ue.current=null,Ve.resolve(!0),He(null)},children:e(`ok`)})]})]})]})]}),!Fe&&Object.values(n.pluginJobs??{}).some(e=>e.phase!==`done`)&&(0,X.jsxs)(`div`,{className:`active-plugin-jobs-bar`,onClick:()=>{Re(`plugins`),Ie(!0)},title:e(`pluginJobRunning`),children:[(0,X.jsx)(K,{className:`spin`}),(0,X.jsxs)(`span`,{className:`active-plugin-jobs-title`,children:[e(`pluginJobRunning`),`:`,` `,Object.values(n.pluginJobs??{}).filter(e=>e.phase!==`done`).map(e=>e.pluginId).join(`, `)]}),(()=>{let e=Object.values(n.pluginJobs??{}).find(e=>e.phase!==`done`),t=e?.lines[e.lines.length-1];return t?(0,X.jsx)(`span`,{className:`active-plugin-jobs-line`,children:t}):null})()]}),ze&&(0,X.jsx)(ev,{mode:ze,currentCwd:n.state?.cwd,currentSandbox:n.state?.sandbox,sandboxDiff:n.sandboxDiff,projects:n.projects,send:r,onClose:()=>Be(null)}),(0,X.jsx)(ry,{})]})}function RS(){typeof document<`u`&&(zS(BS()),HS())}function zS(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function BS(){let e=document.createElement(`div`);e.style.cssText=`position:fixed;top:-9999px;left:0;width:100px;height:100px;overflow-y:auto;scrollbar-gutter:stable both-edges;visibility:hidden;pointer-events:none;`,document.body.appendChild(e);let t=(e.offsetWidth-e.clientWidth)/2;return e.remove(),t}function VS(e){let t=document.createElement(`div`);t.style.cssText=`width:0;height:0;pointer-events:none;`,e.appendChild(t);let n=getComputedStyle(e),r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=Number.parseFloat(n.borderLeftWidth)||0,o=Number.parseFloat(n.paddingLeft)||0,s=i.left-(r.left+a+o);return t.remove(),s}function HS(){let e=()=>{let e=document.querySelector(`.messages`);return e?(zS(VS(e)),!0):!1},t=0;if(window.addEventListener(`resize`,()=>{t||=window.requestAnimationFrame(()=>{t=0,e()})}),e())return;let n=new MutationObserver(()=>{e()&&n.disconnect()});n.observe(document.documentElement,{childList:!0,subtree:!0}),window.setTimeout(()=>n.disconnect(),6e4)}mn(),tf($d()),RS(),(0,ee.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(g.StrictMode,{children:(0,X.jsx)(Mn,{children:(0,X.jsx)(LS,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=un();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,jt as c,he as d,me as f,P as g,R as h,af as i,Ke as l,B as m,Wh as n,Nn as o,K as p,Qd as r,Z as s,Kh as t,Se as u};
679
+ `))},S=e=>{s(e.id),l(e.title),d(e.description||``)},C=()=>{s(null),l(``),d(``)},w=e=>{let t=c.trim();if(!t)return;let n={title:t};n.description=u.trim()?u.trim():void 0,$({type:`plan_step_update`,stepId:e,patch:n}),s(null)},T=e=>{$({type:`plan_step_delete`,stepId:e})},E=e=>{let t=f.find(t=>t.id===e);t&&$({type:`plan_step_update`,stepId:e,patch:{status:Wx[t.status]}})},D=()=>{let e={id:`step-${Date.now()}`,title:t(`planBoardAddStep`),status:`pending`};$({type:`plan_step_add`,step:e}),S(e)},O=(e,n)=>{let r=(()=>{switch(e){case`done`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pt,{}),t(`planBoardCompleted`)]});case`in_progress`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(rt,{}),t(`planBoardInProgress`)]});case`failed`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Tt,{}),t(`planBoardFailed`)]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(at,{}),t(`planBoardPending`)]})}})();return(0,X.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),E(n)},title:`点击切换状态 (pending / in_progress / done / failed)`,style:{display:`inline-flex`,alignItems:`center`,gap:4,color:e===`done`?`var(--green, #22c55e)`:e===`in_progress`?`var(--accent, #38bdf8)`:e===`failed`?`var(--red, #ef4444)`:`var(--text-dim, #9aa1b4)`,fontSize:12,fontWeight:e===`pending`?400:600,background:`none`,border:`none`,cursor:`pointer`,padding:`2px 4px`,borderRadius:4},children:r})};return(0,X.jsxs)(`div`,{className:`plan-board ${n?``:`plan-board-collapsed`}`.trim(),children:[(0,X.jsxs)(`div`,{className:`plan-board-head`,onClick:()=>r(!n),children:[(0,X.jsxs)(`div`,{className:`plan-board-head-main`,children:[(0,X.jsx)(De,{className:`plan-board-icon`}),(0,X.jsx)(`span`,{className:`plan-board-title`,children:t(`planBoardTitle`)}),(0,X.jsxs)(`span`,{className:`plan-board-count ${h===100?`plan-board-count-done`:``}`.trim(),children:[p,`/`,m]}),!n&&_&&(0,X.jsx)(`span`,{className:`plan-board-active`,title:_.title,children:_.title})]}),(0,X.jsxs)(`div`,{className:`plan-board-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`plan-board-implement`,title:t(`planImplementTip`),onClick:e=>{e.stopPropagation(),y()},children:t(`planImplementBtn`)}),n&&(0,X.jsx)(`button`,{type:`button`,className:`plan-board-clean-handoff`,title:t(`planCleanHandoffTip`),onClick:e=>{e.stopPropagation(),b()},children:t(`planCleanHandoffBtn`)}),n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(i?`planBoardExportSuccess`:`planBoardExportMarkdown`),onClick:e=>{e.stopPropagation(),x()},children:i?(0,X.jsx)(ft,{style:{color:`var(--green, #22c55e)`}}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`clear`),onClick:e=>{e.stopPropagation(),v()},children:(0,X.jsx)(L,{})})]}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(n?`collapseSection`:`expandSection`),children:n?(0,X.jsx)(ct,{}):(0,X.jsx)(dt,{})})]}),n&&(0,X.jsx)(`div`,{className:`plan-board-head-divider`,children:(0,X.jsx)(`div`,{className:`plan-board-head-divider-fill`,style:{width:`${h}%`,backgroundColor:h===100?`var(--green, #22c55e)`:`var(--accent, #38bdf8)`}})})]}),!n&&(0,X.jsx)(`div`,{className:`plan-board-progress-line`,children:(0,X.jsx)(`div`,{className:`plan-board-progress-line-fill`,style:{width:`${h}%`,backgroundColor:h===100?`var(--green, #22c55e)`:`var(--accent, #38bdf8)`}})}),n&&(0,X.jsxs)(`div`,{className:`plan-board-steps`,style:{marginTop:8,display:`flex`,flexDirection:`column`,gap:8},children:[f.map((n,r)=>{let i=n.id===e.activeStepId||n.status===`in_progress`;return o===n.id?(0,X.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:6,padding:`8px 10px`,borderRadius:6,backgroundColor:`var(--bg-elev2, rgba(0, 0, 0, 0.2))`,border:`1px solid var(--accent, #38bdf8)`},children:[(0,X.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:t(`planBoardStepTitlePlaceholder`),style:{width:`100%`,padding:`4px 8px`,borderRadius:4,border:`1px solid var(--border-subtle)`,background:`var(--bg, #0b0f17)`,color:`var(--text, #f1f5f9)`,fontSize:13},autoFocus:!0,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),w(n.id)):e.key===`Escape`&&C()}}),(0,X.jsx)(`textarea`,{rows:2,value:u,onChange:e=>d(e.target.value),placeholder:t(`planBoardStepDescPlaceholder`),style:{width:`100%`,padding:`4px 8px`,borderRadius:4,border:`1px solid var(--border-subtle)`,background:`var(--bg, #0b0f17)`,color:`var(--text-dim, #9aa1b4)`,fontSize:12,resize:`vertical`},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),w(n.id)):e.key===`Escape`&&C()}}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:6,marginTop:2},children:[(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-iconbtn`,onClick:C,title:t(`cancel`),style:{padding:`3px 8px`,fontSize:12},children:[(0,X.jsx)(P,{}),` `,t(`cancel`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-implement`,onClick:()=>w(n.id),title:t(`confirm`),style:{padding:`3px 10px`,fontSize:12},children:[(0,X.jsx)(ft,{}),` `,t(`confirm`)]})]})]},n.id||r):(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,flexWrap:`wrap`,rowGap:4,minWidth:0,padding:`6px 10px`,borderRadius:6,backgroundColor:i?`rgba(56, 189, 248, 0.08)`:`var(--bg-elev2, rgba(0, 0, 0, 0.2))`,border:i?`1px solid rgba(56, 189, 248, 0.25)`:`1px solid transparent`},children:[(0,X.jsxs)(`div`,{style:{flex:`1 1 180px`,minWidth:0,paddingRight:10},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:6,minWidth:0},children:[(0,X.jsxs)(`span`,{style:{fontSize:11,fontWeight:700,color:i?`var(--accent, #38bdf8)`:`var(--text-dim, #9aa1b4)`,minWidth:16},children:[r+1,`.`]}),(0,X.jsx)(`span`,{style:{fontWeight:i?600:500,color:n.status===`done`?`var(--text-dim, #9aa1b4)`:`var(--text, #f1f5f9)`,textDecoration:n.status===`done`?`line-through`:`none`,minWidth:0,overflowWrap:`anywhere`,wordBreak:`break-word`},children:n.title})]}),n.description&&(0,X.jsx)(`div`,{style:{fontSize:12,color:`var(--text-dim, #9aa1b4)`,marginTop:2,paddingLeft:22,lineHeight:1.4,overflowWrap:`anywhere`,wordBreak:`break-word`},children:n.description})]}),(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:4,flexShrink:0,marginTop:2},children:[O(n.status,n.id),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`planBoardEditStep`),onClick:()=>S(n),children:(0,X.jsx)(Ke,{size:12})}),(0,X.jsx)(`button`,{type:`button`,className:`plan-board-iconbtn`,title:t(`planBoardDeleteStep`),onClick:()=>T(n.id),children:(0,X.jsx)(L,{size:12})})]})]},n.id||r)}),(0,X.jsxs)(`button`,{type:`button`,className:`plan-board-add-btn`,onClick:D,children:[(0,X.jsx)(me,{}),` `,t(`planBoardAddStep`)]})]})]})}var Kx=3,qx=200;function Jx(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Yx(e){return typeof e==`string`&&e.trim()||void 0}function Xx(e,t){let n=[];for(let r of e){let e=Qx(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function Zx(e){let t=e.slice(0,6).map(e=>typeof e==`string`?e:JSON.stringify(e)??String(e));if(t.length!==0)return`enum: ${t.join(` | `)}${e.length>t.length?` | …`:``}`}function Qx(e,t=0){if(t>6||!Jx(e))return`any`;if(Yx(e.$ref))return`ref`;let n=Yx(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:Qx(n,t+1)}>`}if(n)return n;for(let n of[`anyOf`,`oneOf`,`allOf`]){let r=e[n];if(Array.isArray(r)&&r.length>0)return Xx(r,t+1)}return Jx(e.properties)?`object`:Jx(e.additionalProperties)?`record<${Qx(e.additionalProperties,t+1)}>`:`any`}function $x(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=Zx(n);e&&t.push(e)}return e.const!==void 0&&t.push(`const: ${JSON.stringify(e.const)}`),e.default!==void 0&&t.push(`default: ${JSON.stringify(e.default)}`),t.length>0?t.join(` · `):void 0}function eS(e,t={}){let n=t.maxDepth??Kx,r=t.maxRows??qx,i=e;if(!Jx(i))return[];let a=i.properties;if(!Jx(a))return[];let o=[],s=new Set((Array.isArray(i.required)?i.required:[]).filter(e=>typeof e==`string`)),c=(e,t,i,a)=>{if(!(o.length>=r))for(let[s,l]of Object.entries(e)){if(o.length>=r)return;let e=Jx(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:Qx(e,i),required:a.has(s),depth:i},f=Yx(e.description);f&&(d.description=f);let p=$x(e);if(p&&(d.hint=p),o.push(d),i+1<n&&Jx(e.properties)){let t=new Set((Array.isArray(e.required)?e.required:[]).filter(e=>typeof e==`string`));c(e.properties,u,i+1,t)}}};return c(a,``,0,s),o}function tS(){let e=Z(),t=ys();return zt(()=>{hs()},!!t),t?(0,j.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:hs,children:(0,X.jsxs)(`div`,{className:`tool-info-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e(`toolInfoTitle`),onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`tool-info-head`,children:[(0,X.jsxs)(`span`,{className:`tool-info-title`,children:[(0,X.jsx)(je,{}),e(`toolInfoTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,children:t.name}),t.label&&t.label!==t.name&&(0,X.jsx)(`span`,{className:`tool-info-label`,children:t.label}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`close`),onClick:hs,children:(0,X.jsx)(P,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(nS,{info:t})})]})}),document.body):null}function nS({info:e}){let t=Z();if(e.status===`loading`)return(0,X.jsxs)(`div`,{className:`tool-info-state`,role:`status`,children:[(0,X.jsx)(`span`,{className:`cursor`}),` `,t(`toolInfoLoading`)]});if(e.status===`unsupported`)return(0,X.jsx)(`div`,{className:`tool-info-state`,children:t(`toolInfoUnsupported`)});if(e.status===`missing`)return(0,X.jsx)(`div`,{className:`tool-info-state`,children:t(`toolInfoMissing`)});let n=e.parameters===void 0?[]:eS(e.parameters),r=e.parameters===void 0?``:iS(e.parameters);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`tool-info-badges`,children:[e.active!==void 0&&(0,X.jsx)(`span`,{className:`tool-info-badge ${e.active?`on`:`off`}`,children:e.active?t(`toolInfoActive`):t(`toolInfoInactive`)}),e.source&&(0,X.jsxs)(`span`,{className:`tool-info-badge`,children:[t(`toolInfoSource`),`: `,e.source,e.scope?` · ${e.scope}`:``]})]}),(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoDescription`)}),(0,X.jsx)(`div`,{className:`tool-info-text`,children:e.description||t(`toolInfoNoDescription`)})]}),e.promptSnippet&&(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoPromptSnippet`)}),(0,X.jsx)(`div`,{className:`tool-info-text dim`,children:e.promptSnippet})]}),e.promptGuidelines&&e.promptGuidelines.length>0&&(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoGuidelines`)}),(0,X.jsx)(`ul`,{className:`tool-info-list`,children:e.promptGuidelines.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),(0,X.jsxs)(`section`,{className:`tool-info-sec`,children:[(0,X.jsx)(`div`,{className:`tool-info-sec-label`,children:t(`toolInfoParams`)}),n.length>0?(0,X.jsx)(rS,{rows:n}):(0,X.jsx)(`div`,{className:`tool-info-text dim`,children:t(`toolInfoParamsNone`)}),e.parametersDropped&&(0,X.jsx)(`div`,{className:`tool-info-text warn`,children:t(`toolInfoSchemaDropped`)}),r&&(0,X.jsxs)(`details`,{className:`tool-info-raw`,children:[(0,X.jsxs)(`summary`,{children:[t(`toolInfoRawSchema`),(0,X.jsx)(Fd,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function rS({rows:e}){let t=Z();return(0,X.jsx)(`div`,{className:`tool-schema-table`,role:`table`,children:e.map(e=>(0,X.jsxs)(`div`,{className:`tool-schema-row`,role:`row`,style:{paddingLeft:8+e.depth*14},children:[(0,X.jsxs)(`div`,{className:`tool-schema-name`,children:[(0,X.jsx)(`code`,{children:e.name}),e.required&&(0,X.jsx)(`span`,{className:`tool-schema-req`,children:t(`toolInfoRequired`)})]}),(0,X.jsxs)(`div`,{className:`tool-schema-type`,children:[e.type,e.hint&&(0,X.jsx)(`span`,{className:`tool-schema-hint`,children:e.hint})]}),e.description&&(0,X.jsx)(`div`,{className:`tool-schema-desc`,children:e.description})]},e.name))})}function iS(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function aS(e,t){return e.toLowerCase().includes(t)}function oS({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=Nn(),u=l===`en`?`Plugins`:`插件`,d=Za(`cwd`),f=(0,g.useRef)(null),[p,m]=(0,g.useState)(``),h=(0,g.useDeferredValue)(p),[_,v]=(0,g.useState)(0),y=(0,g.useRef)(0),b=(0,g.useRef)(null),[x,S]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=p.trim();if(t){let e=U_();y.current=e,w(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}requestAnimationFrame(()=>f.current?.select())},[e]);let[C,w]=(0,g.useState)(!1);(0,g.useEffect)(()=>{b.current&&clearTimeout(b.current);let e=h.trim();if(!e){w(!1),S(null);return}return b.current=setTimeout(()=>{let t=U_();y.current=t,w(!0),$({type:`search_files`,reqId:t,query:e}),$({type:`search_sessions`,reqId:t,query:e})},300),()=>{b.current&&clearTimeout(b.current)}},[h]),(0,g.useEffect)(()=>{n&&n.reqId===y.current&&S(n)},[n]);let T=h.trim().toLowerCase(),E=(0,g.useMemo)(()=>!T||!r||r.reqId!==y.current||!r.ok?[]:r.results,[r,T]),D=(0,g.useMemo)(()=>T?t.filter(e=>aS(e.path,T)).slice(0,10):[],[t,T]),O=(0,g.useMemo)(()=>!T||!x||!x.ok?[]:x.results,[x,T]);(0,g.useEffect)(()=>{x&&x.reqId===y.current&&r&&r.reqId===y.current&&y.current!==0&&w(!1)},[x,r]);let k=!!x&&x.ok&&x.truncated,[A,j]=(0,g.useState)([]);(0,g.useEffect)(()=>{if(!e)return;let t=h.trim();if(!t){j([]);return}let n=!1,r=[];try{let e=window,t=e.__piWebUiHost?.searchProviders?.list;if(typeof t==`function`){let n=t.call(e.__piWebUiHost);Array.isArray(n)&&(r=n)}else typeof dc==`function`&&(r=dc())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=gc(e.id);return t&&typeof t.search==`function`?{...e,search:t.search}:null}catch{return null}}).filter(e=>!!e);if(i.length===0){j([]);return}return Promise.allSettled(i.map(e=>Promise.race([e.search(t),new Promise((e,t)=>setTimeout(()=>t(Error(`timeout`)),3e3))]).then(t=>({provider:e,items:Array.isArray(t)?t:[]}),()=>({provider:e,items:[]})))).then(e=>{if(n)return;let t=[];for(let n of e)if(n.status===`fulfilled`)for(let e of n.value.items){if(!e||typeof e!=`object`)continue;let r=e;typeof r.title==`string`&&typeof r.action==`string`&&t.push({providerId:n.value.provider.id,providerLabel:n.value.provider.label,title:r.title,...typeof r.hint==`string`?{hint:r.hint}:{},action:r.action})}j(t.slice(0,20))}),()=>{n=!0}},[e,h]);let ee=(0,g.useMemo)(()=>[...E.map(e=>({kind:`session`,path:e.path,anchors:e.anchors})),...D.map(e=>({kind:`project`,path:e.path})),...O.filter(e=>e.type===`file`).map(e=>({kind:`file`,path:e.path,name:e.name})),...A.map(e=>({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}))],[E,D,O,A]);(0,g.useEffect)(()=>{v(0)},[h]);let M=(0,g.useCallback)(e=>{if(e){if(e.kind===`session`)a(e.path,e.anchors),i();else if(e.kind===`project`){o(e.path),$({type:`list_sessions`}),$({type:`list_projects`});let t=h.trim();if(t){let e=U_();y.current=e,w(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}}else e.kind===`plugin`?$s(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,h]);(0,g.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),i()):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.max(0,Math.min(e+1,ee.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),M(ee[_]))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[ee,_,M,i,e]);let te=E.length+D.length+O.length+A.length,N=(e,t,n)=>(0,X.jsxs)(`div`,{className:`gs-section-head`,children:[n,(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`em`,{children:t})]}),ne=-1;return e?(0,X.jsx)(`div`,{className:`modal-backdrop gs-backdrop`,onClick:i,children:(0,X.jsxs)(`div`,{className:`gs-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`gs-input-row`,children:[(0,X.jsx)(fe,{}),(0,X.jsx)(`input`,{ref:f,type:`text`,value:p,placeholder:c(`gsPlaceholder`),onChange:e=>m(e.target.value)}),(0,X.jsx)(`button`,{type:`button`,className:`gs-close`,title:c(`close`),onClick:i,children:(0,X.jsx)(P,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!T&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),T&&te===0&&!k&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(C?`gsSearching`:`gsNoResults`)}),E.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsSessions`),E.length,(0,X.jsx)(J,{})),E.map(e=>{ne++;let t=ne,n=e.name||e.path.split(/[\\/]/).pop()||e.path;return(0,X.jsxs)(`div`,{className:`gs-item-wrap`,children:[(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>M({kind:`session`,path:e.path,anchors:e.anchors}),children:[(0,X.jsxs)(`span`,{className:`gs-item-title`,children:[n,(0,X.jsx)(`em`,{className:`gs-item-meta`,children:e.messageCount})]}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.firstMessage})]}),(0,X.jsxs)(`button`,{type:`button`,className:`gs-quote`,title:c(`quoteConversation`),onClick:t=>{t.stopPropagation(),lr({attachments:[{path:``,key:`conv||${e.path}`,name:n,mode:`conversation`,sessionPath:e.path}]})},children:[`💬 `,c(`quoteConversationShort`)]})]},e.path)})]}),D.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsProjects`),D.length,(0,X.jsx)(Re,{})),D.map(e=>{ne++;let t=ne,n=d&&e.path===d;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,onMouseEnter:()=>v(t),onClick:()=>M({kind:`project`,path:e.path}),children:[(0,X.jsxs)(`span`,{className:`gs-item-title`,children:[e.path.split(/[\\/]/).pop(),n&&(0,X.jsx)(`em`,{className:`gs-item-meta`,children:c(`gsCurrentProject`)})]}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.path})]},e.path)})]}),(O.length>0||T&&k)&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(c(`gsFiles`),O.length,(0,X.jsx)(Ve,{})),O.map(e=>{ne++;let t=ne;return(0,X.jsxs)(`button`,{type:`button`,className:t===_?`gs-item active`:`gs-item`,disabled:e.type===`dir`,title:e.type===`dir`?void 0:c(`gsOpenPreview`),onMouseEnter:()=>v(t),onClick:()=>{e.type===`file`&&M({kind:`file`,path:e.path,name:e.name})},children:[(0,X.jsx)(`span`,{className:`gs-item-title`,children:e.name}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.path})]},`${e.type}:${e.path}`)}),k&&(0,X.jsx)(`div`,{className:`gs-truncated`,children:c(`gsTruncated`)})]}),A.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[N(u,A.length,(0,X.jsx)(q,{})),A.map((e,t)=>{ne++;let n=ne;return(0,X.jsxs)(`button`,{type:`button`,className:n===_?`gs-item active`:`gs-item`,title:e.providerLabel,onMouseEnter:()=>v(n),onClick:()=>M({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}),children:[(0,X.jsx)(`span`,{className:`gs-item-title`,children:e.title}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.hint??e.providerLabel})]},`${e.providerId}:${e.action}:${t}`)})]})]}),(0,X.jsxs)(`div`,{className:`gs-foot`,children:[(0,X.jsxs)(`span`,{children:[`↑↓ `,c(`gsNavigate`)]}),(0,X.jsxs)(`span`,{children:[`Enter `,c(`gsOpen`)]}),(0,X.jsxs)(`span`,{children:[`Esc `,c(`gsCloseHint`)]})]})]})}):null}function sS({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(Ky,{className:`plugin-modal`,title:a,icon:e.icon,onClose:r,children:(0,X.jsx)(`div`,{className:`modal-body plugin-modal-body`,children:o?t?(0,X.jsx)($v,{entry:t}):(0,X.jsx)(`div`,{className:`plugin-modal-loading`,children:i(`loading`)}):e.kind===`divider`?(0,X.jsx)(`hr`,{className:`plugin-modal-divider`}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary plugin-modal-action`,onClick:()=>n?.(e),children:e.badge??a})})})}var cS=`未命名章节`;function lS(e){return String(e??``).trim().replace(/[\s\u3000]+/g,`-`).replace(/[^\p{L}\p{N}_-]+/gu,`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`section`}function uS(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=lS(r||cS),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||cS}})}function dS(e){return e.length>=2}var fS=5e3,pS=`pi-web-ui:preview-toc`;function mS({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,g.useState)(null),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!0),[T,E]=(0,g.useState)(!0),[D,O]=(0,g.useState)(!1),k=(0,g.useRef)(!1),[A,j]=(0,g.useState)(!0),[ee,N]=(0,g.useState)(!1),[ne,F]=(0,g.useState)(100),re=(0,g.useRef)(0),ie=(0,g.useRef)(!1),ae=(0,g.useRef)(null),[I,L]=(0,g.useState)(!1),[R,z]=(0,g.useState)(!1),oe=(0,g.useRef)(!1),B=(0,g.useRef)(null);(0,g.useEffect)(()=>()=>{ae.current&&clearTimeout(ae.current),B.current&&clearTimeout(B.current)},[]),(0,g.useEffect)(()=>{d(!0),l(null),p(null),b(!1),S(``),w(!0),E(!0),O(!1),k.current=!1,oe.current=!1,L(!1),z(!1),B.current&&clearTimeout(B.current),$({type:`read_file`,path:e.path})},[e.path]),(0,g.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1),oe.current&&(oe.current=!1,B.current&&clearTimeout(B.current),L(!1),z(!1),b(!1),S(t.text),k.current&&(hS(e.name)&&w(!0),_S(e.name)&&E(!0)),p(null)))},[t,y,e.path]),(0,g.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){G();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&y){e.preventDefault(),W();return}let t=e.target,n=t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable);(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`a`&&!n&&(e.preventDefault(),le())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,g.useEffect)(()=>{let e=()=>{ie.current=!1,h(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let V=(0,g.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
680
+ `);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,fS)},[c]),H=c?.lines??0,se=H>fS,ce=(e,t)=>{if(t){let t=re.current>0?re.current:e;p({start:Math.min(t,e),end:Math.max(t,e)})}else re.current=e,p({start:e,end:e})},le=()=>{V.length!==0&&(re.current=1,p({start:1,end:V.length}))},ue=()=>{f&&(n(e.path,e.name,f.start,f.end),v(!0),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>v(!1),1400))},U=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated&&!gS(e.name),de=()=>{oe.current=!1,B.current&&clearTimeout(B.current),L(!1),z(!1),S(c?.text??``),b(!1),k.current&&(hS(e.name)&&w(!0),_S(e.name)&&E(!0))},fe=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;de();return}U&&c&&(k.current=hS(e.name)&&C||_S(e.name)&&T,hS(e.name)&&w(!1),_S(e.name)&&E(!1),p(null),S(c.text),b(!0))},W=()=>{y&&c&&U&&$({type:`write_file`,path:e.path,text:x})&&(oe.current=!0,z(!1),L(!0),B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{oe.current=!1,L(!1),z(!0)},5e3))},G=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},K=e=>{F(Math.min(200,Math.max(50,e)))},me=f?f.end-f.start+1:0,he=c?.binary??!1,ge=c?.truncated??!1,q=c?.kind??`text`,_e=hS(e.name)||gS(e.name),ve=_S(e.name),ye=_e&&C&&!y&&q===`text`&&!he,xe=ve&&T&&!y&&q===`text`&&!he,[J,Se]=(0,g.useState)(()=>{try{return localStorage.getItem(pS)===`1`}catch{return!1}});(0,g.useEffect)(()=>{try{localStorage.setItem(pS,J?`1`:`0`)}catch{}},[J]);let[we,Te]=(0,g.useState)([]),[Ee,ke]=(0,g.useState)(``),Ae=(0,g.useRef)(null);(0,g.useEffect)(()=>{let e=Ae.current;if(!e||!ye){Te([]);return}let t=[...e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)],n=uS(t.map(e=>({level:Number(e.tagName.slice(1)),label:e.textContent??``})));t.forEach((e,t)=>{e.id||=n[t].id}),Te(n)},[ye,c?.text,e.path]),(0,g.useEffect)(()=>{let e=Ae.current;if(!e||!J||!dS(we))return;let t=we.map(t=>e.querySelector(`#${CSS.escape(t.id)}`)).filter(e=>e!==null);if(t.length===0)return;let n=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>e.boundingClientRect.top-t.boundingClientRect.top)[0];t?.target.id&&ke(t.target.id)},{rootMargin:`0px 0px -70% 0px`});for(let e of t)n.observe(e);return()=>n.disconnect()},[we,J]);let je={"host:fp-md":_e&&q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach markdown ${C?`on`:``}`,"data-tip":s(C?`showMarkdownSource`:`showMarkdownPreview`),disabled:y,onClick:()=>w(e=>!e),children:C?(0,X.jsx)(Ue,{}):(0,X.jsx)(nt,{})}):null,"host:fp-toc":ye&&dS(we)?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach toc ${J?`on`:``}`,"data-tip":s(J?`previewTocHide`:`previewTocShow`),onClick:()=>Se(e=>!e),children:(0,X.jsx)(De,{})}):null,"host:fp-html":ve&&q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach html ${T?`on`:``}`,"data-tip":s(T?`showHtmlSource`:`showHtmlPreview`),disabled:y,onClick:()=>E(e=>!e),children:T?(0,X.jsx)(nt,{}):(0,X.jsx)(Ue,{})}):null,"host:fp-edit":q===`text`&&!he&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(ge?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!U&&!y,onClick:fe,children:(0,X.jsx)(Y,{})}):null,"host:fp-wrap":q===`text`&&!he&&!ye&&!xe?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${A?`on`:``}`,"data-tip":s(A?`disableWrap`:`enableWrap`),onClick:()=>j(e=>!e),children:(0,X.jsx)(et,{})}):null,"host:fp-zoom":q===`text`&&c?(0,X.jsxs)(`span`,{className:`fp-zoom`,children:[(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-out`,"data-tip":s(`zoomOut`),disabled:ne<=50,onClick:()=>K(ne-10),children:(0,X.jsx)(M,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>F(100),children:[ne,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:ne>=200,onClick:()=>K(ne+10),children:(0,X.jsx)(te,{})})]}):null,"host:fp-ref":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach ref`,"data-tip":s(`referenceTip`),onClick:()=>r(e.path,e.name,`reference`),children:(0,X.jsx)(Oe,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${ee?`on`:``}`,"data-tip":s(ee?`exitFullscreen`:`fullscreen`),onClick:()=>N(e=>!e),children:ee?(0,X.jsx)(be,{}):(0,X.jsx)(Ce,{})}),"host:fp-close":null},Me=a===void 0?[`host:fp-md`,`host:fp-toc`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-ref`,`host:fp-full`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden&&e.id!==`host:fp-close`),Ne=e=>gn(fn(`/api/file?clientId=${encodeURIComponent(Fl())}&path=${encodeURIComponent(e)}`)),Pe=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return gn(fn(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(Fl())}${D?`&allowJs=1`:``}`))};return(0,X.jsx)(`div`,{className:`fp-overlay ${ee?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&G()},children:(0,X.jsxs)(`div`,{className:`fp ${ee?`fullscreen`:``}`,style:{"--fp-zoom":ne/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,onDoubleClick:e=>{let t=e.target;t&&!t.closest(`button, a, input`)&&N(e=>!e)},children:[(0,X.jsx)(`span`,{className:`fp-name`,title:e.path,children:e.name}),(0,X.jsx)(`span`,{className:`fp-path`,children:e.path}),(0,X.jsxs)(`span`,{className:`fp-meta`,children:[c&&q===`text`&&!he&&s(`fileLines`,{n:H}),c&&` · ${_m(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:ag(Me,je,o)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),"aria-label":s(`close`),onClick:G,children:(0,X.jsx)(P,{})})]}),ge&&q===`text`&&!he&&(0,X.jsx)(`div`,{className:`fp-notice`,children:gS(e.name)?s(`previewLinesTruncated`,{n:V.length}):s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&q===`none`&&!he&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&q===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap clickable`,onClick:G,title:s(`clickToCloseImage`),children:(0,X.jsx)(`img`,{className:`fp-media fp-media-clickable`,src:Ne(e.path),alt:e.name,onClick:G,title:s(`clickToCloseImage`)})}),!u&&q===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Ne(e.path),controls:!0,preload:`metadata`})}),!u&&xe&&c&&(0,X.jsxs)(`div`,{className:`fp-html`,children:[(0,X.jsxs)(`div`,{className:`fp-html-bar`,children:[(0,X.jsx)(`span`,{className:`fp-html-hint`,title:s(D?`htmlJsOnTip`:`htmlJsOffTip`),children:s(D?`htmlJsOn`:`htmlJsOff`)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-html-js ${D?`on`:``}`,"data-tip":s(D?`htmlDisableJs`:`htmlEnableJs`),onClick:()=>O(e=>!e),children:s(D?`htmlDisableJs`:`htmlEnableJs`)}),(0,X.jsxs)(`a`,{className:`fp-html-btn fp-html-external`,href:Pe(e.path),target:`_blank`,rel:`noopener noreferrer`,title:s(`openInNewTab`),children:[(0,X.jsx)(Ge,{}),(0,X.jsx)(`span`,{children:s(`openInNewTab`)})]})]}),(0,X.jsx)(`iframe`,{className:`fp-html-frame`,src:Pe(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&ye&&c&&(0,X.jsx)(`div`,{className:gS(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,X.jsxs)(`div`,{className:J&&dS(we)?`fp-toc-layout`:void 0,children:[J&&dS(we)&&(0,X.jsx)(`nav`,{className:`fp-toc`,"aria-label":s(`previewTocLabel`),children:we.map(e=>(0,X.jsx)(`a`,{className:`l${Math.min(e.level,6)}${e.id===Ee?` on`:``}`,href:`#${e.id}`,title:e.label,onClick:t=>{t.preventDefault(),Ae.current?.querySelector(`#${CSS.escape(e.id)}`)?.scrollIntoView({behavior:`smooth`,block:`start`})},children:e.label},e.id))}),(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,ref:Ae,children:(0,X.jsx)(Af,{text:c.text})})]})}),!u&&he&&q!==`image`&&q!==`video`&&c&&(0,X.jsxs)(`div`,{className:`fp-hex-wrap`,children:[(0,X.jsxs)(`div`,{className:`fp-notice`,children:[s(`binaryFile`),c.truncated&&s(`binaryHexTruncated`)]}),(0,X.jsx)(`pre`,{className:`fp-hex`,children:c.text})]}),!u&&y&&q===`text`&&!he&&c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`textarea`,{className:`fp-editor ${A?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:A?`soft`:`off`,spellCheck:!1,autoFocus:!0}),R&&(0,X.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:s(`saveResultUnknown`)})]}),!u&&!ye&&!xe&&!y&&q===`text`&&!he&&c&&V.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!ye&&!xe&&!y&&q===`text`&&!he&&V.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${m?`dragging`:``} ${A?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[V.map((e,t)=>{let n=t+1,r=f!==null&&n>=f.start&&n<=f.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(ce(n,e.shiftKey),ie.current=!0,h(!0))},onMouseEnter:()=>{ie.current&&ce(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),se&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:fS})})]}),(y||!ye&&!xe&&q===`text`)&&(0,X.jsx)(`div`,{className:`fp-foot`,children:y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:s(`editFile`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:fe,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:I||x===(c?.text??``),onClick:W,children:[(0,X.jsx)(pe,{}),` `,s(`saveFile`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:f?s(`selectedRange`,{n:me,start:f.start,end:f.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:V.length===0,onClick:le,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!f,onClick:()=>p(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!f||he,onClick:ue,children:[_?(0,X.jsx)(ft,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function hS(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function gS(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)}function _S(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function vS({file:e,plugin:t,declaration:n,epoch:r,send:i,onClose:a,onFallback:o}){let s=Z(),c=(0,g.useRef)(null),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(!1),p=(0,g.useRef)(o);p.current=o;let m=n.label??t.name;return(0,g.useEffect)(()=>{let r=c.current;if(!r)return;let a=!1,o;return u(null),f(!1),(async()=>{try{let s=await Dy({plugin:t,declaration:n});if(a)return;if(!s)throw Error(`插件没有提供可用的文件查看器`);let c=`/plugins-api/${encodeURIComponent(t.id)}`,l={...il(t.id,i),file:e,apiUrl:(e,t)=>{let n=String(e??``).startsWith(`/`)?String(e):`/${String(e??``)}`,r=new URLSearchParams;for(let[e,n]of Object.entries(t??{}))n!==void 0&&r.set(e,String(n));let i=r.toString();return gn(fn(`${c}${n}${i?`?${i}`:``}`))}};o=s.handler.mount(r,e,l),a||f(!0)}catch(e){a||(console.error(`[plugin:${t.id}] file handler failed:`,e),p.current())}})(),()=>{if(a=!0,typeof o==`function`)try{o()}catch(e){console.error(`[plugin:${t.id}] file handler cleanup failed:`,e)}r.textContent=``}},[e,t,n,r,i]),(0,X.jsx)(Ky,{className:`plugin-file-preview`,title:m,icon:t.icon,onClose:a,children:(0,X.jsxs)(`div`,{className:`modal-body plugin-file-preview-body`,children:[(0,X.jsx)(`div`,{className:`plugin-file-preview-file`,title:e.path,children:e.name}),l?(0,X.jsx)(`div`,{className:`plugin-file-preview-error`,children:l}):null,!l&&!d?(0,X.jsx)(`div`,{children:s(`loading`)}):null,(0,X.jsx)(`div`,{ref:c,className:`plugin-file-preview-host`})]})})}var yS=.4,bS=1.05;function xS(e){return Math.min(300,e*.86)}function SS(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function CS(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function wS(e,t){return e===`left`?t:-t}function TS(e,t){return Math.max(-e,Math.min(0,-e+t))}function ES(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function DS(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:ES(r*bS,n,t)>=yS}var OS=new Set([`auto`,`scroll`,`overlay`]);function kS(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&OS.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function AS(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function jS(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,g.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0],i=SS(r.clientX,window.innerWidth,n);i&&!kS(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0],d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=CS(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=xS(window.innerWidth),h=m*bS;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=wS(r,d);let b=TS(h,f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(ES(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?DS({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(AS(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}function MS(e,t,n,r,i){let a=new Map;for(let e of r)a.set(e.id,!!e.isStreaming);if(t&&a.set(t,n),e===null)return{startCue:!1,finishedConvs:[],nextMap:a};let o=!1;if(t&&(i===void 0||i===t)){let n=e.get(t),r=a.get(t)??!1;n===!1&&r===!0&&(o=!0)}let s=[];for(let[n,i]of e.entries())if(i&&a.has(n)&&!a.get(n)){let e=r.find(e=>e.id===n);s.push({id:n,title:e?.title,isActive:n===t})}return{startCue:o,finishedConvs:s,nextMap:a}}var NS=(0,g.lazy)(()=>Pc(()=>import(`./TerminalPanel-CpfPFx32.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function PS({notice:e,onDismiss:t}){let n=Z(),{locale:r}=Nn(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(a)return;let n=setTimeout(()=>t(e.id),hl(e.level));return()=>clearTimeout(n)},[a,e.id,e.level,t]);let s=e.level===`error`?Tt:e.level===`warning`?wt:je;return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${a?` paused`:``}`,role:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onClick:()=>{window.getSelection?.()?.toString()||t(e.id)},children:[(0,X.jsx)(s,{className:`notice-icon`}),(0,X.jsx)(`span`,{className:`notice-text`,children:i}),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:n(`close`),onClick:n=>{n.stopPropagation(),t(e.id)},children:(0,X.jsx)(P,{})})]})}var FS=[],IS=180,LS=520,RS=240,zS=e=>`pi-web-ui:${e}-panel-width`;function BS(e){try{let t=Number(localStorage.getItem(zS(e)));return Number.isFinite(t)&&t>=IS&&t<=LS?t:RS}catch{return RS}}var VS=e=>`pi-web-ui:${e}-panel-collapsed`;function HS(e){try{return localStorage.getItem(VS(e))===`1`}catch{return!1}}function US({side:e,width:t,onResize:n}){let r=Z(),i=(0,g.useCallback)(r=>{r.preventDefault();let i=r.clientX,a=t,o=a,s=t=>{let r=e===`left`?t.clientX-i:i-t.clientX;o=Math.min(LS,Math.max(IS,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`);try{localStorage.setItem(zS(e),String(o))}catch{}};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),document.body.classList.add(`panel-resizing`)},[e,t,n]);return(0,X.jsx)(`div`,{className:`resize-handle resize-${e}`,title:r(`dragToResize`),onPointerDown:i,onDoubleClick:()=>n(RS)})}function WS({side:e,onClick:t}){let n=Z();return(0,X.jsx)(`button`,{type:`button`,className:`panel-rail panel-rail-${e}`,title:n(`expandPanel`),onClick:t,children:e===`left`?(0,X.jsx)(ot,{}):(0,X.jsx)(st,{})})}var GS=`pi-web-ui:plugin-path-grants`,KS=e=>e?`${GS}:${e}`:GS;function qS(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function JS(e){try{let t=KS(e);if(localStorage.getItem(t)!==null)return qS(localStorage.getItem(t));if(!e)return[];let n=qS(localStorage.getItem(GS));return localStorage.setItem(t,JSON.stringify(n)),n}catch{return[]}}function YS(e,t){try{let n=[...new Set([...JS(t),e])];localStorage.setItem(KS(t),JSON.stringify(n))}catch{}}function XS(){let e=Z(),{locale:t}=Nn(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=Xl(),s=(0,g.useRef)(!1);(0,g.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:mx[t]??mx.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=Fb();(0,g.useEffect)(()=>{let t=l?Ob(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,g.useState)([]);(0,g.useEffect)(()=>(ar(e=>d(t=>e_(t,e))),()=>ar(null)),[]);let[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(null),_=(0,g.useRef)(!1),v=(0,g.useRef)(null);(0,g.useEffect)(()=>{_.current=f!==null,v.current=m},[f,m]);let y=(0,g.useCallback)((e,t)=>{let n=Ey(t);if(n){p(null),h({file:{path:e,name:t},plugin:n.plugin,declaration:n.declaration});return}h(null),p({path:e,name:t})},[]);(0,g.useEffect)(()=>(Sf({open:e=>y(e.path,e.name),isOpen:()=>_.current||v.current!==null}),()=>Sf(null)),[y]);let[b,x]=(0,g.useState)(!1);(0,g.useEffect)(()=>{let e=()=>x(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[S,C]=(0,g.useState)(`chat`),w=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(S.startsWith(`plugin:`)?`plugins`:S)?S:`chat`,T=(0,g.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),E=(0,g.useMemo)(()=>{let r=[],i=pa(na(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout,diagnostics:r});for(let e of r)console.warn(`[ui-slot] ${e.pluginId?`[${e.pluginId}] `:``}${e.message}`);return i},[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),D=(0,g.useMemo)(()=>E[`topbar.primary`].filter(e=>!e.hidden),[E]),O=(0,g.useMemo)(()=>[...E[`topbar.primary`].filter(e=>e.hidden),...E[`topbar.overflow`]],[E]),k=(0,g.useMemo)(()=>E[`leftpanel.sessions`].filter(e=>!e.hidden),[E]),A=(0,g.useMemo)(()=>E[`leftpanel.projects.actions`].filter(e=>!e.hidden),[E]),j=(0,g.useMemo)(()=>E[`leftpanel.project`].filter(e=>!e.hidden),[E]),ee=(0,g.useMemo)(()=>E[`leftpanel.running.actions`].filter(e=>!e.hidden),[E]),M=(0,g.useMemo)(()=>E[`leftpanel.history.actions`].filter(e=>!e.hidden),[E]),te=E[`leftpanel.sections`],N=(0,g.useMemo)(()=>E[`leftpanel.running`].filter(e=>!e.hidden),[E]),ne=(0,g.useMemo)(()=>E[`leftpanel.history`].filter(e=>!e.hidden),[E]),F=(0,g.useMemo)(()=>E[`terminal.toolbar`].filter(e=>!e.hidden),[E]),re=(0,g.useMemo)(()=>E[`scm.toolbar`].filter(e=>!e.hidden),[E]),ie=(0,g.useMemo)(()=>E[`goalbar.actions`].filter(e=>!e.hidden),[E]),ae=(0,g.useMemo)(()=>E[`chat.header`].filter(e=>!e.hidden),[E]),I=(0,g.useMemo)(()=>E[`chat.empty`].filter(e=>!e.hidden),[E]),L=(0,g.useMemo)(()=>E[`file.preview.toolbar`].filter(e=>!e.hidden),[E]),R=(0,g.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(n=>[n.id,Z_(n,t,e).name])),[n.dshPresets,t]),z=(0,g.useMemo)(()=>E[`notice.actions`].filter(e=>!e.hidden),[E]),oe=(0,g.useMemo)(()=>E[`sidebar.left`]??[],[E]),B=(0,g.useMemo)(()=>E[`sidebar.right`]??[],[E]),V=(0,g.useCallback)((t,n,i)=>{if(t.id===`host:msg-fork`){i?.id&&r({type:`fork_session`,messageId:i.id,position:`before`});return}if(t.id===`host:msg-rollback`){i?.id&&Im({messageId:i.id});return}let o=(t.action??``).trim();if(t.kind===`view`||(!o||o===`view`)&&t.source!==`host`){C(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}o&&$s(t.source.startsWith(`plugin:`)?t.source.slice(7):``,o,t.id,{...n===void 0?{}:{value:n},...i===void 0?{}:{target:i},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),H=(0,g.useCallback)(e=>{let t=n.plugins.find(t=>t.id===e.source.slice(7));return t?(0,X.jsx)(Ru,{plugin:t,epoch:n.pluginsEpoch,send:r,className:`lp-plugin-page`}):null},[n.plugins,n.pluginsEpoch,r]),se=(0,g.useCallback)((t,n)=>{n.action&&$s(t.pluginId,n.action,n.id,{target:{id:n.id,kind:`plugin-running`,label:n.title},loadBundle:async e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[ce,le]=(0,g.useState)([]);(0,g.useEffect)(()=>Yc(le),[]);let[ue,U]=(0,g.useState)([]);(0,g.useEffect)(()=>qc(U),[]);let[de,fe]=(0,g.useState)(null),W=de?E[`modal.dialog`].find(e=>e.id===de&&!e.hidden):void 0,pe=(0,g.useMemo)(()=>{if(!W||W.kind!==`view`)return``;let e=W.view??``;return e.startsWith(`plugin:`)?e.slice(7):W.source.startsWith(`plugin:`)?W.source.slice(7):``},[W]);(0,g.useEffect)(()=>{if(!W||!pe||ce.some(e=>e.info.id===pe))return;let e=G.current.plugins.find(e=>e.id===pe);e&&nl(e,G.current.pluginsEpoch)},[W,pe,ce,n.pluginsEpoch]),(0,g.useEffect)(()=>{Zd(r),Qd(T,n.pluginsEpoch),of(T,n.pluginsEpoch),Ty(T,n.pluginsEpoch),rl(T,n.pluginsEpoch)},[T,n.pluginsEpoch,r]);let G=(0,g.useRef)(n);G.current=n;let me=(0,g.useRef)(C);me.current=C;let he=(0,g.useRef)(E);he.current=E,(0,g.useEffect)(()=>(Ks(Gs({send:r,isReady:()=>!!G.current.state,setView:e=>me.current(e),getCwd:()=>G.current.state?.cwd??``,getWorkspaceRoots:()=>G.current.state?.workspaceRoots??[],listSessions:()=>{let e=G.current,t=e.state?.cwd??``;return[...e.conversations.map(e=>({id:e.id,title:e.title,cwd:e.cwd||t,kind:`running`,isStreaming:e.isStreaming})),...e.sessions.map(e=>({id:e.path,title:e.name||e.firstMessage||e.path,cwd:t,kind:`history`}))]},getConversationId:()=>G.current.state?.conversationId??null,isConversationBlank:()=>(G.current.state?.messages.length??0)===0,listModels:()=>G.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=G.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>G.current.projects.map(e=>e.path),grantedPaths:JS,grantPath:YS,confirm:e=>new Promise(t=>{if(Ue.current){t(!1);return}let n={path:e.path,resolve:t};Ue.current=n,He(n)}),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=he.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(fe(t),!0)},closeModal:()=>fe(null),dialogConfirm:e=>new Promise(t=>{if(Y.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Y.current=n,Ge(n)}),select:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Y.current=n,qe([]),Ge(n)}),input:e=>new Promise(t=>{if(Y.current){t({ok:!1,error:`busy`});return}let n={kind:`input`,title:e.title,...typeof e.placeholder==`string`?{placeholder:e.placeholder}:{},...typeof e.initial==`string`?{initial:e.initial}:{},resolve:t};Y.current=n,Ye(e.initial??``),Ge(n)}),notifyAction:e=>new Promise(t=>{try{let n=Qe.current;Qe.current=null,Ze(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Qe.current=r,Ze(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=G.current.plugins.find(t=>t.id===e);return t?nl(t,G.current.pluginsEpoch):Promise.resolve(!1)}})),()=>Ks(null)),[r]);let[ge,q]=(0,g.useState)(()=>BS(`left`)),[_e,ve]=(0,g.useState)(()=>BS(`right`)),ye=(0,g.useCallback)(e=>q(e),[]),be=(0,g.useCallback)(e=>ve(e),[]),[xe,J]=(0,g.useState)(()=>HS(`left`)),[Se,Ce]=(0,g.useState)(()=>HS(`right`)),we=(0,g.useCallback)(()=>{J(e=>{try{localStorage.setItem(VS(`left`),e?`0`:`1`)}catch{}return!e})},[]),Te=(0,g.useCallback)(()=>{Ce(e=>{try{localStorage.setItem(VS(`right`),e?`0`:`1`)}catch{}return!e})},[]),[Ee,De]=(0,g.useState)(null),Oe=(0,g.useRef)(null),[ke,Ae]=(0,g.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,g.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>Ae(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),jS({enabled:ke&&w===`chat`,open:Ee,onOpenChange:De,container:Oe,backdropSelector:`.drawer-backdrop.persistent`});let[je,Me]=(0,g.useState)(!1),[Ne,Pe]=(0,g.useState)(!1),[Fe,Ie]=(0,g.useState)(!1),[Le,Re]=(0,g.useState)(),[ze,Be]=(0,g.useState)(null),[Ve,He]=(0,g.useState)(null),Ue=(0,g.useRef)(null),[We,Ge]=(0,g.useState)(null),Y=(0,g.useRef)(null),[Ke,qe]=(0,g.useState)([]),[Je,Ye]=(0,g.useState)(``),[Xe,Ze]=(0,g.useState)(null),Qe=(0,g.useRef)(null),[$e,et]=(0,g.useState)(()=>new Set),tt=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),et(t=>new Set(t).add(e))},nt=n.pathRequests.find(e=>!$e.has(e.id))??null,[rt,it]=(0,g.useState)(()=>new Set),at=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),it(t=>new Set(t).add(e))},ot=n.permRequests.find(e=>!rt.has(e.id))??null,st=wb(),[ct,lt]=(0,g.useState)(!1),[ut,dt]=(0,g.useState)(!1),[ft,pt]=(0,g.useState)(!1),[mt,ht]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!mt)return;let e=setTimeout(()=>ht(null),15e3);return()=>clearTimeout(e)},[mt]);let[gt,_t]=(0,g.useState)(null),vt=(0,g.useRef)(null),yt=(0,g.useRef)(null),bt=n.state?.sessionId??``,xt=(0,g.useRef)(bt);xt.current=bt;let St=(0,g.useRef)(n.ready);St.current=n.ready,(0,g.useEffect)(()=>{let e=()=>{let e=es(window.location.hash);if(e){if(e.messageId?_t({sessionId:e.sessionId,messageId:e.messageId}):_t(null),!St.current||!xt.current){vt.current=e.sessionId;return}xt.current!==e.sessionId&&(yt.current=e.sessionId,C(`chat`),r({type:`switch_session`,path:``,sessionId:e.sessionId}))}};return e(),window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[r]),(0,g.useEffect)(()=>{let e=yt.current;if(e&&n.notices.some(t=>t.text.includes(e)&&(t.text.includes(`未找到会话`)||t.text.includes(`Session not found`)))&&(yt.current=null,_t(null),bt)){let e=ts({sessionId:bt});window.location.hash!==e&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${e}`)}},[n.notices,bt]),(0,g.useEffect)(()=>{if(!n.ready||!bt)return;if(vt.current){let e=vt.current;if(vt.current=null,e!==bt){yt.current=e,C(`chat`),r({type:`switch_session`,path:``,sessionId:e});return}}if(yt.current){if(bt===yt.current)yt.current=null;else return}let e=es(window.location.hash),t=e?.sessionId===bt?e.messageId:void 0,i=ts({sessionId:bt,...t?{messageId:t}:{}});window.location.hash!==i&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}${i}`)},[n.ready,bt,r]),(0,g.useEffect)(()=>{let t=t=>{let i=t.detail,a=i?.title||e(`pluginCommandFallback`),s=i?.command;if(!s||!n.ready)return;let c={name:a,command:s,cwd:"${pwd}"},l=n.terminals.find(e=>e.title===a);if(l)o.restart(l.id),r({type:`run_command`,terminalId:l.id,conversationId:l.conversationId,command:c,cols:80,rows:24});else{let e=jt();o.create({id:e,conversationId:n.activeConversationId||n.state?.conversationId||``,title:a,cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:c})}C(`terminal`)};window.addEventListener(`pi-web-ui:plugin-run-command`,t);let i=e=>{let t=e.detail;typeof t==`string`&&t&&r({type:`switch_conversation`,id:t})};return window.addEventListener(`pi-web-ui:switch-conversation`,i),()=>{window.removeEventListener(`pi-web-ui:plugin-run-command`,t),window.removeEventListener(`pi-web-ui:switch-conversation`,i)}},[n,o,r]),(0,g.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),dt(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[Ct,wt]=(0,g.useState)(ob),[Tt,Et]=(0,g.useState)(Gt),{themes:Dt,theme:Ot,switchTheme:kt,reloadThemes:At}=_f();ex(),(0,g.useEffect)(()=>{try{typeof Ec==`function`&&Ec(Ot??``)}catch{}},[Ot]),(0,g.useEffect)(()=>{try{typeof Dc==`function`&&Dc(t)}catch{}},[t]),(0,g.useEffect)(()=>{try{typeof Oc==`function`&&Oc(w)}catch{}},[w]),(0,g.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof Sc==`function`&&Sc(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,g.useEffect)(()=>{if(!We)return;let e=e=>{if(e.key!==`Escape`)return;let t=Y.current;Y.current=null,Ge(null);try{if(!t)return;t.kind===`confirm`?t.resolve(!1):t.resolve({ok:!1})}catch{}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[We]),(0,g.useEffect)(()=>{if(!Xe)return;let e=setTimeout(()=>{let e=Qe.current;Qe.current=null,Ze(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Xe]);let Mt=(0,g.useRef)(null),Nt=(0,g.useRef)(null),Pt=(0,g.useRef)(n.state?.messages);Pt.current=n.state?.messages;let Ft=(0,g.useRef)(new Set),It=(0,g.useRef)(new Set),Lt=(0,g.useRef)(new Set),Rt=(0,g.useRef)(0),zt=(0,g.useRef)(!1),Bt=(0,g.useRef)(n.terminals);(0,g.useEffect)(()=>{sb(Ct)},[Ct]),(0,g.useEffect)(()=>{Kt(Tt)},[Tt]),(0,g.useEffect)(()=>{let e=Bt.current;Bt.current=n.terminals;for(let t of n.terminals){let n=t.command?.command??``;e.find(e=>e.id===t.id)?.running&&!t.running&&(n.startsWith(`pi remove `)?r({type:`extensions_reload`}):n.startsWith(`pi-web-ui install `)||n.startsWith(`pi-web-ui uninstall `)?r({type:`plugins_reload`}):n.startsWith(`npm i -g `)&&(r({type:`extensions_reload`}),r({type:`plugins_reload`}),r({type:`check_updates_all`,force:!0})))}},[n.terminals,r]),(0,g.useEffect)(()=>{let t=n.state?.conversationId??null,r=MS(Mt.current,t,n.state?.isStreaming??!1,n.conversations,Nt.current);if(Mt.current=r.nextMap,Nt.current=t,r.startCue&&fb(`start`,Ct),r.finishedConvs.length>0){fb(`done`,Ct);let t=r.finishedConvs.find(e=>e.isActive);if(t&&(ai(e(`notifyDoneTitle`),e(`notifyDoneBody`)),Tt.enabled&&!Kr($r()))){if(Tt.readReplies){let t=Xt(Pt.current);t?on(t,Tt):Tt.announce&&on(e(`ttsAnnounceDone`),Tt)}else Tt.announce&&on(e(`ttsAnnounceDone`),Tt)}for(let t of r.finishedConvs.filter(e=>!e.isActive)){let n=t.title?`${t.title}:${e(`notifyDoneBody`)}`:e(`notifyDoneBody`);ai(e(`notifyDoneTitle`),n)}!t&&Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceDone`),Tt)}},[n.state?.conversationId,n.state?.isStreaming,n.conversations,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.dialog?.id??null;if(t!==null&&!Ft.current.has(t)){if(Ft.current.add(t),Ft.current.size>64){let e=Ft.current.values().next().value;e!==void 0&&Ft.current.delete(e)}fb(`question`,Ct),ai(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceQuestion`),Tt)}},[n.dialog,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null,i=!1;t!==null&&!It.current.has(t)&&(It.current.add(t),i=!0),r!==null&&!It.current.has(r)&&(It.current.add(r),i=!0);for(let e of n.conversations){if(!e.hasQuestion)continue;let n=e.questionId?`q:${e.questionId}`:`conv-q:${e.id}`;It.current.has(n)||(It.current.add(n),e.questionId&&It.current.add(e.questionId),t!==e.questionId&&(i=!0))}if(It.current.size>64){let e=It.current.values().next().value;e!==void 0&&It.current.delete(e)}i&&(fb(`question`,Ct),ai(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceQuestion`),Tt))},[n.question,n.remoteQuestion,n.conversations,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=n.approval,r=t?.id??null;if(r!==null&&!Lt.current.has(r)){if(Lt.current.add(r),Lt.current.size>64){let e=Lt.current.values().next().value;e!==void 0&&Lt.current.delete(e)}fb(`approval`,Ct);let n=typeof t?.toolName==`string`?t.toolName:``;ai(e(`notifyApprovalTitle`),n?e(`notifyApprovalBodyTool`,{tool:n}):e(`notifyApprovalBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceApproval`),Tt)}},[n.approval,Ct,Tt,e]),(0,g.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==Rt.current&&(Rt.current=t.id,fb(`error`,Ct),ai(e(`notifyErrorTitle`),e(`notifyErrorBody`)),Tt.enabled&&Tt.announce&&!Kr($r())&&on(e(`ttsAnnounceError`),Tt))},[n.notices,Ct,Tt,e]);let Vt=(0,g.useRef)(new Set);(0,g.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||Vt.current.has(t.id))continue;Vt.current.add(t.id);let e=``;for(let n of t.content??[]){if(n.type!==`text`)continue;let t=/🔗 已自动在浏览器打开\]\((\/(?!\/)[^)\s]+)\)/.exec(n.text??``);if(t?.[1]){e=t[1];break}}if(!e)continue;let n=null;try{let t=new URL(fn(e),window.location.href);t.origin===window.location.origin&&document.hasFocus()&&(n=window.open(t.href,`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let Ht=(e,t,n,r=!1,i,a=!1)=>{let o=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(a=>a.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===o)?a:[...a,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}]);let s=n===`page`?t:e;!a&&s&&nr(`@${s} `)},Ut=e=>{let t=``;d(n=>n.filter(n=>{let r=n.key?n.key===e:n.mode===`conversation`?`conv|${n.conversationId??``}|${n.sessionPath??``}`===e:n.path===e;return r&&!t&&(t=n.mode===`page`||n.mode===`conversation`?n.name:n.path),!r})),t&&rr(`@${t}`)},Wt=(0,g.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&De(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&C(e=>e===`chat`?e:`chat`),r(e)),[r]),qt=(0,g.useRef)(new Set),Jt=n.activeConversationId||n.state?.conversationId||``;(0,g.useEffect)(()=>{let t=n.conversations.filter(e=>e.hasQuestion),r=new Set(t.map(e=>e.id)),i=new Set(t.map(e=>e.questionId).filter(Boolean));for(let e of qt.current)i.has(e)||qt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===Jt){ly(t,{silent:!0});continue}n.questionId&&qt.current.has(n.questionId)||cy({id:t,type:`question`,title:n.title||e(`chat`),message:n.questionTitle||e(`waitingQuestionBadge`),persistent:!0,dismissible:!0,data:{conversationId:n.id,questionId:n.questionId},onClose:()=>{n.questionId&&qt.current.add(n.questionId)},onClick:()=>{Wt({type:`switch_conversation`,id:n.id}),ly(t,{silent:!0})}})}uy(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===Jt:!1},{silent:!0})},[n.conversations,Jt,Wt,e]);let Yt=(0,g.useRef)(0),Zt=(0,g.useRef)(0),Qt=(0,g.useCallback)(t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-Zt.current>1e4&&(Zt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++Yt.current}`;d(e=>[...e,{path:``,key:i,name:t.name,imageData:t.data,mimeType:t.mimeType}])},[n.state?.model,a,e]),$t=(0,g.useCallback)(async t=>{for(let n of t){let t=await dm(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}Qt(t)}},[Qt,a,e]),en=20971520,tn=(0,g.useRef)(0),nn=(0,g.useCallback)(async t=>{if(t.size>en){a(`warning`,e(`fileTooLarge`,{name:t.name,size:en/1024/1024}));return}let n;try{n=(await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(r.error??Error(`read failed`)),r.readAsDataURL(t)})).replace(/^data:[^;]*;base64,/,``)}catch{a(`error`,e(`fileLoadFailed`,{name:t.name}));return}let r=`upload-${++tn.current}`;d(e=>[...e,{path:``,key:r,name:t.name,fileData:n,size:t.size,mimeType:t.type||void 0}])},[en,a,e]),rn=(0,g.useCallback)(async e=>{for(let t of e)um(t.type)?await $t([t]):await nn(t)},[$t,nn]),an=(0,g.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),sn=(0,g.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[cn,ln]=(0,g.useState)([]),un=(0,g.useRef)(0),dn=(0,g.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),un.current+=1;let i=ud(t),a={text:i.text,seq:un.current};i.quotes.length&&d(e=>e_(e,i.quotes.map(e=>({path:``,name:``,mode:`quote`,quote:e,key:jt()})))),ln(e=>[...e.slice(-9),a])},[r]),pn=(0,g.useCallback)(()=>Pe(!0),[]),mn=(0,g.useCallback)(()=>d([]),[]);by(n.state?.sessionId??``,mn);let hn=(0,g.useCallback)(Ut,[]),gn=$t,_n=rn,vn=(0,g.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),yn=(0,g.useCallback)(e=>Ht(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines,e.silent??!1),[]),bn=n.state?.model,xn=n.state?.thinkingLevel,Sn=n.state?.availableThinkingLevels,Cn=(0,g.useMemo)(()=>bn?{model:bn,thinkingLevel:xn??`off`,availableThinkingLevels:Sn??[]}:null,[bn,xn,Sn]),wn=(0,g.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:jt(),conversationId:n.activeConversationId||n.state?.conversationId||``,title:e(`terminalTitle`,{n:1}),cwd:n.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null}),!0),[n.ready,n.state?.cwd,n.terminals.length,e,o]);return(0,g.useEffect)(()=>{if(zt.current){if(w!==`terminal`||n.terminals.length!==0){zt.current=!1;return}wn()&&(zt.current=!1)}},[n.terminals.length,wn,w]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),x(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(!1)},onDrop:t=>{if(x(!1),!Array.from(t.dataTransfer?.types??[]).includes(`Files`))return;t.preventDefault();let n=Array.from(t.dataTransfer?.files??[]);if(n.length===0){a(`warning`,e(`foldersNotSupported`));return}let r=n.filter(e=>um(e.type)),i=n.filter(e=>!um(e.type));r.length>0&&$t(r),i.length>0&&rn(i)},children:[b&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Yo,{chat:n,terminal:o,view:w,plugins:T,uiPrimary:D,uiOverflow:O,uiContextTopbar:E[`contextmenu.topbar`],onUiAction:V,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:()=>{Re(void 0),Ie(!0)},onManagePlugins:()=>{Re(`plugins`),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onOpenIconEdit:()=>pt(!0),sound:Ct,onSoundChange:wt,onSoundPreview:e=>fb(e,Ct),themes:Dt,theme:Ot,onThemeChange:kt,reloadThemes:At}),ft&&(0,X.jsx)(yy,{slots:E,layout:n.settings?.uiLayout,exclude:Ji,onClose:()=>pt(!1)}),n.protocolMismatch&&(0,X.jsxs)(`div`,{className:`protocol-banner`,children:[`⚠ `,e(`protocolMismatch`)]}),(0,X.jsxs)(`div`,{className:`notices`,children:[n.notices.map(e=>(0,X.jsx)(PS,{notice:e,onDismiss:i},e.id)),Xe&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Xe.text}),Xe.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Qe.current;Qe.current=null,Ze(null);try{t?.resolve(e.id)}catch{}},children:e.label},e.id)),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:e(`close`),onClick:()=>{let e=Qe.current;Qe.current=null,Ze(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(P,{})})]}),z.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:z.map(e=>e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`btn btn-slot notice-select`,title:e.hint??e.label,"aria-label":e.label,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onChange:t=>V(e,t.target.value),children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},e.id):(0,X.jsxs)(`button`,{type:`button`,className:`btn btn-slot`,title:e.hint??e.label,onClick:()=>V(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(Zh,{currentModelId:bn?`${bn.provider}/${bn.id}`:null,children:(0,X.jsxs)(`div`,{ref:Oe,className:`layout`,style:{"--left-w":`${ge}px`,"--right-w":`${_e}px`},children:[ke?(0,X.jsx)(`div`,{className:`drawer-backdrop persistent${Ee?` on`:``}`,onClick:()=>De(null)}):Ee&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>De(null)}),(0,X.jsx)(Dv,{side:`left`,items:oe,chat:n,view:w,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:e=>{Re(e),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onUiAction:V,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>kt(Ot===`light`?null:`light`),onSoundToggle:()=>wt({...Ct,enabled:!Ct.enabled})}),(0,X.jsxs)(`div`,{className:`view-pane ${w===`chat`?``:`hidden`}`,children:[!ke&&xe&&(0,X.jsx)(WS,{side:`left`,onClick:we}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${Ee===`left`?`open`:``}${ke?``:xe?` hidden`:``}`,children:(0,X.jsx)(pu,{collapsible:!ke,onToggleCollapse:we,panelSend:Wt,active:!ke||Ee===`left`,sessionFile:n.state?.sessionFile??null,conversations:n.conversations,elsewhere:n.elsewhere,sessions:n.sessions,projects:n.projects,pathCompletions:n.pathCompletions,activeConversationId:n.activeConversationId,uiContextSession:E[`contextmenu.session`],uiLeftSessions:k,uiContextProject:E[`contextmenu.project`],uiProjectsActions:A,uiLeftProject:j,uiRunningActions:ee,uiHistoryActions:M,uiSections:te,renderPluginSectionBody:H,uiLeftRunning:N,uiLeftHistory:ne,uiPluginRunning:n.pluginPanelGroups,onPluginRunningAction:se,onUiAction:V,presetNames:R,transition:n.transition,onOpenSandboxModal:()=>Be(`create`)})}),!ke&&(0,X.jsx)(US,{side:`left`,width:ge,onResize:ye}),(0,X.jsxs)(`main`,{className:`${st?`main wide-chat`:`main`}${n.transition&&!n.transition.previewMessages?.length?` main-transitioning`:``}`,children:[n.transition&&(0,X.jsxs)(`div`,{className:`workspace-transition-bar phase-${n.transition.phase}`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`div`,{className:`workspace-transition-track`,children:(0,X.jsx)(`div`,{className:`workspace-transition-fill`,style:{width:`${Math.min(100,Math.max(8,n.transition.progress))}%`}})}),(0,X.jsxs)(`div`,{className:`workspace-transition-pill`,children:[(0,X.jsx)(`span`,{className:`workspace-transition-spinner`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`workspace-transition-text`,children:t!==`zh`&&n.transition.textEn?n.transition.textEn:n.transition.text}),(0,X.jsxs)(`span`,{className:`workspace-transition-pct`,children:[n.transition.progress,`%`]})]})]}),ae.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:rg(ae,V)}),n.state?(0,X.jsxs)(X.Fragment,{children:[n.state.sandbox&&(0,X.jsxs)(`div`,{className:`sandbox-banner`,role:`region`,"aria-label":n.state.sandbox.name,children:[(0,X.jsxs)(`div`,{className:`sandbox-banner-info`,children:[(0,X.jsxs)(`span`,{className:`sandbox-banner-title`,children:[`🧪 `,e(`sandboxBannerTitle`,{name:n.state.sandbox.name}),(0,X.jsx)(`span`,{className:`lp-sandbox-badge ${n.state.sandbox.ephemeral?`ephemeral`:`permanent`}`,children:n.state.sandbox.ephemeral?e(`sandboxBadgeEphemeral`):e(`sandboxBadgePermanent`)})]}),(0,X.jsx)(`span`,{className:`sandbox-banner-desc`,children:n.state.sandbox.sourcePath?e(`sandboxBannerSourceDesc`,{source:n.state.sandbox.sourcePath}):e(`sandboxBannerBlankDesc`)})]}),(0,X.jsxs)(`div`,{className:`sandbox-banner-actions`,children:[n.state.sandbox.ephemeral&&(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionPersistTip`),onClick:()=>r({type:`persist_sandbox`,path:n.state?.sandbox?.path}),children:[`📌 `,e(`sandboxActionPersist`)]}),n.state.sandbox.sourcePath&&(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn primary`,title:e(`sandboxActionApplySourceTip`),onClick:()=>Be(`apply`),children:[`✅ `,e(`sandboxActionApplySource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionPromoteTip`),onClick:()=>Be(`promote`),children:[`📤 `,e(`sandboxActionPromote`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn`,title:e(`sandboxActionResetTip`),onClick:()=>{let t=n.state?.sandbox;t&&window.confirm(e(`sandboxActionResetConfirm`,{name:t.name}))&&r({type:`reset_sandbox`,path:t.path})},children:[`🔄 `,e(`sandboxActionReset`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`sandbox-banner-btn danger`,title:e(`sandboxActionDestroyTip`),onClick:()=>{let t=n.state?.sandbox;t&&window.confirm(e(`sandboxActionDestroyConfirm`,{name:t.name}))&&r({type:`destroy_sandbox`,path:t.path})},children:[`🗑️ `,e(`sandboxActionDestroy`)]})]})]}),n.state.isEphemeral&&(0,X.jsxs)(`div`,{className:`ephemeral-banner`,children:[(0,X.jsxs)(`span`,{children:[`🎭 `,e(`ephemeralBannerText`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`ephemeral-save`,onClick:()=>r({type:`persist_conversation`,id:Jt}),children:[`💾 `,e(`saveEphemeral`)]})]}),(0,X.jsx)(Yg,{uiMessageActions:E[`message.actions`],uiContextMessage:E[`contextmenu.message`],uiContextToolCall:E[`contextmenu.toolcall`],uiChatEmpty:I,onUiAction:V,state:n.transition?.previewMessages?.length?{...n.state,messages:n.transition.previewMessages,streamingMessage:null,isStreaming:!1}:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:an,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Uh(`${e.provider}/${e.id}`)}},onRemoveQueued:sn,onRecallQueued:dn,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,keepRecent:n.settings?.keepRecentMessages,jumpTarget:mt,onJumpDone:()=>ht(null),urlJumpMessageId:gt&&gt.sessionId===n.state.sessionId?gt.messageId:null,onUrlJumpDone:()=>_t(null)},n.transition?.previewMessages?.length?`preview:${n.transition.target}`:n.state.conversationId??`boot`)]}):(0,X.jsx)(`div`,{className:`boot-wait`,children:n.ready?e(`loadingSession`):e(`connectingServer`)}),n.settings?.goalModeEnabled!==!1&&(0,X.jsx)(`div`,{className:`goalbar-slot`,children:(0,X.jsx)(dv,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:ie,onUiAction:V})}),(0,X.jsx)(ty,{onAction:(e,t,n)=>V(e,n,t)}),n.dialog&&(0,X.jsx)(Ov,{dialog:n.dialog}),We&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":We.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),We.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:We.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),We.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(We.options??[]).map((e,t)=>{let n=We.multi?Ke.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(We.multi){qe(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Y.current;Y.current=null,Ge(null);try{n?.resolve({ok:!0,selected:[e.label]})}catch{}},children:[e.label,e.description&&(0,X.jsx)(`span`,{className:`dialog-hint`,children:e.description})]},t)}),(We.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),We.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current,t=(e?.options??[]).filter((e,t)=>Ke.includes(t)).map(e=>e.label);Y.current=null,Ge(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),We.kind===`confirm`&&(0,X.jsx)(`div`,{className:`dialog-body`,children:(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),We.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Je,placeholder:We.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>Ye(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!0,value:Je})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Y.current;Y.current=null,Ge(null);try{e?.resolve({ok:!0,value:Je})}catch{}},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Rv,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||Jt))?.title}),n.remoteQuestion&&(0,X.jsx)(Rv,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(Gx,{plan:n.activeConversationId&&n.state?.conversationId!==n.activeConversationId?null:n.state?.plan}),(0,X.jsx)(uv,{composerLeading:E[`composer.leading`],composerActions:E[`composer.actions`],onUiAction:V,streaming:n.state?.isStreaming??!1,planMode:n.state?.planMode??!1,messages:n.state?.messages??FS,slashCommands:n.slashCommands,modelState:Cn,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:hn,onAddImageFiles:gn,onAddLocalFiles:_n,onAddPathAttachment:yn,fileSearch:n.fileSearch,onSearchFiles:vn,onNotice:a,onManageModels:pn,onSent:mn,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:cn,dshPermCurrent:n.state?.permission??null,dshPermOptions:n.dshPermission?.options??void 0,dshPermDefault:n.dshPermission?.defaultPreset,dshPreset:n.state?.agentPreset??null,dshPresets:n.dshPresets?.presets??void 0,dshPresetDefault:n.dshPresets?.defaultPreset,dshBlank:(n.state?.messages?.length??0)===0,conversationId:n.activeConversationId||n.state?.conversationId||``,sessionDraft:n.engine===`pi`?n.state?.draft??null:null,sessionId:n.state?.sessionId??``})]}),!ke&&(0,X.jsx)(US,{side:`right`,width:_e,onResize:be}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${Ee===`right`?`open`:``}${ke?``:Se?` hidden`:``}`,children:(0,X.jsx)(sd,{collapsible:!ke,onToggleCollapse:Te,panelSend:Wt,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{De(null),Ht(e,t,n,r)},onPreview:(e,t)=>{De(null),y(e,t)},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:E[`rightpanel.tabs`],uiContextFile:E[`contextmenu.file`],plugins:T,pluginsEpoch:n.pluginsEpoch,send:r})}),!ke&&Se&&(0,X.jsx)(WS,{side:`right`,onClick:Te})]}),(0,X.jsx)(`div`,{className:`view-pane ${w===`terminal`?``:`hidden`}`,children:(0,X.jsx)(g.Suspense,{fallback:null,children:(0,X.jsx)(NS,{chat:n,terminal:o,uiTerminalToolbar:F,onUiAction:V})})}),(0,X.jsx)(`div`,{className:`view-pane ${w===`git`?``:`hidden`}`,children:(0,X.jsx)(Qv,{chat:n,terminal:o,active:w===`git`,onSwitchToTerminal:()=>C(`terminal`),uiScmToolbar:re,onUiAction:V})}),ce.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${w===t?``:`hidden`}`,children:(0,X.jsx)($v,{entry:e})},e.info.id)}),w.startsWith(`plugin:`)&&!ce.some(e=>`plugin:${e.info.id}`===w)&&(0,X.jsx)(ey,{pluginId:w.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===w),epoch:n.pluginsEpoch,failed:ue.includes(w.slice(7))}),(0,X.jsx)(Dv,{side:`right`,items:B,chat:n,view:w,onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenPanel:De,onOpenSettings:e=>{Re(e),Ie(!0)},onOpenBgTasks:()=>lt(!0),onOpenGlobalSearch:()=>dt(!0),onUiAction:V,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>kt(Ot===`light`?null:`light`),onSoundToggle:()=>wt({...Ct,enabled:!Ct.enabled})})]})}),(0,X.jsx)(hv,{chat:n,bottombarItems:E.bottombar,onUiAction:V,onOpenSettings:()=>{Re(void 0),Ie(!0)},onViewChange:e=>{zt.current=e===`terminal`&&n.terminals.length===0,zt.current&&wn()&&(zt.current=!1),C(e),De(null)},onOpenGlobalSearch:()=>dt(!0),onOpenBgTasks:()=>lt(!0)}),f&&(0,X.jsx)(mS,{file:f,content:n.fileContent,onAddLines:(e,t,n,r)=>Ht(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>Ht(e,t,n),onClose:()=>p(null),uiFilePreviewToolbar:L,onUiAction:V}),m&&(0,X.jsx)(vS,{file:m.file,plugin:m.plugin,declaration:m.declaration,epoch:n.pluginsEpoch,send:r,onClose:()=>h(null),onFallback:()=>{h(null),p(m.file)}}),n.ready&&n.state&&n.state.piConfigured===!1&&!je&&!Ne&&(0,X.jsx)(ky,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>Me(!0)}),Ne&&(0,X.jsx)(zy,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,testModelConnectionResult:n.testModelConnectionResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,refreshProviderResult:n.refreshProviderResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,defaultModel:n.defaultModel,onClose:()=>Pe(!1)}),Fe&&(0,X.jsx)(Rx,{chat:n,terminal:o,initialSection:Le,onSwitchToTerminal:()=>C(`terminal`),onClose:()=>Ie(!1),onOpenIconEdit:()=>pt(!0),sound:Ct,onSoundChange:wt,tts:Tt,onTtsChange:Et}),ct&&(0,X.jsx)(Bx,{servers:n.bgServers,plugins:n.plugins,epoch:n.pluginsEpoch,send:r,onUiAction:V,autoCleanupMin:n.settings?.bgAutoCleanupMin??0,onClose:()=>lt(!1)}),(0,X.jsx)(tS,{}),(0,X.jsx)(Vx,{}),(0,X.jsx)(Hx,{approval:n.approval}),n.tuiOverlay&&(0,X.jsx)(Ux,{overlay:n.tuiOverlay}),W&&(0,X.jsx)(sS,{entry:W,pluginView:pe?ce.find(e=>e.info.id===pe):void 0,onUiAction:(e,t)=>{V(e,t),fe(null)},onClose:()=>fe(null)}),(0,X.jsx)(oS,{open:ut,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>dt(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];ht(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{y(e,t)}}),(ot||nt||Ve)&&(0,X.jsxs)(`div`,{className:`modal-backdrop perm-modal-backdrop`,children:[ot&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginPermTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>at(ot.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[ot.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,ot.pluginId).replace(`{hosts}`,(ot.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,ot.pluginId).replace(`{models}`,(ot.models??[]).length>0?` ${(ot.models??[]).join(`, `)}`:``),ot.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:ot.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>at(ot.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>at(ot.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>at(ot.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),nt&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginGrantRequestTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>tt(nt.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,nt.pluginId).replace(`{path}`,nt.path),nt.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:nt.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>tt(nt.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>tt(nt.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),Ve&&(0,X.jsxs)(`div`,{className:`dialog-inline perm-dialog-card`,"data-dialog-kind":`confirm`,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),(0,X.jsx)(`span`,{className:`dialog-title`,children:e(`pluginSessionGrantTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{Ue.current=null,Ve.resolve(!1),He(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,Ve.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Ue.current=null,Ve.resolve(!1),He(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{Ue.current=null,Ve.resolve(!0),He(null)},children:e(`ok`)})]})]})]})]}),!Fe&&Object.values(n.pluginJobs??{}).some(e=>e.phase!==`done`)&&(0,X.jsxs)(`div`,{className:`active-plugin-jobs-bar`,onClick:()=>{Re(`plugins`),Ie(!0)},title:e(`pluginJobRunning`),children:[(0,X.jsx)(K,{className:`spin`}),(0,X.jsxs)(`span`,{className:`active-plugin-jobs-title`,children:[e(`pluginJobRunning`),`:`,` `,Object.values(n.pluginJobs??{}).filter(e=>e.phase!==`done`).map(e=>e.pluginId).join(`, `)]}),(()=>{let e=Object.values(n.pluginJobs??{}).find(e=>e.phase!==`done`),t=e?.lines[e.lines.length-1];return t?(0,X.jsx)(`span`,{className:`active-plugin-jobs-line`,children:t}):null})()]}),ze&&(0,X.jsx)(pv,{mode:ze,currentCwd:n.state?.cwd,currentSandbox:n.state?.sandbox,sandboxDiff:n.sandboxDiff,projects:n.projects,send:r,onClose:()=>Be(null)}),(0,X.jsx)(gy,{})]})}function ZS(){typeof document<`u`&&(QS($S()),tC())}function QS(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function $S(){let e=document.createElement(`div`);e.style.cssText=`position:fixed;top:-9999px;left:0;width:100px;height:100px;overflow-y:auto;scrollbar-gutter:stable both-edges;visibility:hidden;pointer-events:none;`,document.body.appendChild(e);let t=(e.offsetWidth-e.clientWidth)/2;return e.remove(),t}function eC(e){let t=document.createElement(`div`);t.style.cssText=`width:0;height:0;pointer-events:none;`,e.appendChild(t);let n=getComputedStyle(e),r=e.getBoundingClientRect(),i=t.getBoundingClientRect(),a=Number.parseFloat(n.borderLeftWidth)||0,o=Number.parseFloat(n.paddingLeft)||0,s=i.left-(r.left+a+o);return t.remove(),s}function tC(){let e=()=>{let e=document.querySelector(`.messages`);return e?(QS(eC(e)),!0):!1},t=0;if(window.addEventListener(`resize`,()=>{t||=window.requestAnimationFrame(()=>{t=0,e()})}),e())return;let n=new MutationObserver(()=>{e()&&n.disconnect()});n.observe(document.documentElement,{childList:!0,subtree:!0}),window.setTimeout(()=>n.disconnect(),6e4)}mn(),hf(pf()),ZS(),(0,ee.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(g.StrictMode,{children:(0,X.jsx)(Mn,{children:(0,X.jsx)(XS,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=un();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,jt as c,he as d,me as f,P as g,L as h,vf as i,Ke as l,z as m,rg as n,Nn as o,K as p,ff as r,Z as s,ag as t,Se as u};