pi-web-ui 0.98.0 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -4
- package/dist/server/agent-service.js +9 -3
- package/dist/server/eval-tool.js +22 -1
- package/dist/server/goal-service.js +30 -7
- package/dist/server/model-enrich.js +2 -0
- package/dist/server/patch-tool.js +65 -30
- package/dist/server/plan-manager.js +71 -30
- package/dist/server/terminals.js +13 -6
- package/dist/server/update-check.js +0 -15
- package/package.json +1 -1
- package/web/dist/assets/{TerminalPanel-C88r3r3Q.js → TerminalPanel-NerrJlTS.js} +1 -1
- package/web/dist/assets/index-BdMaGCcs.css +1 -0
- package/web/dist/assets/{index-BjdK7s1M.js → index-ByCBN4Kt.js} +32 -32
- package/web/dist/index.html +2 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-2jDtjHvW.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-
|
|
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";(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 m=e(t(),1),h={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},g=m.createContext&&m.createContext(h),_=[`attr`,`size`,`title`];function v(e,t){if(e==null)return{};var n,r,i=y(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 y(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 b(){return b=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},b.apply(null,arguments)}function x(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 S(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?x(Object(n),!0).forEach(function(t){C(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function C(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){var t=T(e,`string`);return typeof t==`symbol`?t:t+``}function T(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 E(e){return e&&e.map((e,t)=>m.createElement(e.tag,S({key:t},e.attr),E(e.child)))}function D(e){return t=>m.createElement(O,b({attr:S({},e.attr)},t),E(e.child))}function O(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=v(e,_),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),m.createElement(`svg`,b({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:S(S({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&m.createElement(`title`,null,i),e.children)};return g===void 0?t(h):m.createElement(g.Consumer,null,e=>t(e))}var k=r(),A=n();function j(e){return D({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 ee(e){return D({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 M(e){return D({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 N(e){return D({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 P(e){return D({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 D({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 I(e){return D({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 L(e){return D({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 te(e){return D({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 D({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 D({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 ne(e){return D({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 re(e){return D({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 D({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 ie(e){return D({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 V(e){return D({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 ae(e){return D({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 H(e){return D({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 D({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 W(e){return D({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 oe(e){return D({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 se(e){return D({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 ce(e){return D({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 G(e){return D({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 le(e){return D({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 ue(e){return D({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 de(e){return D({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 fe(e){return D({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 pe(e){return D({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 me(e){return D({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 he(e){return D({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 ge(e){return D({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 _e(e){return D({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 ve(e){return D({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 K(e){return D({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 ye(e){return D({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 be(e){return D({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 xe(e){return D({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 Se(e){return D({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 Ce(e){return D({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 we(e){return D({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 Te(e){return D({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 Ee(e){return D({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 q(e){return D({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 J(e){return D({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 De(e){return D({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 Oe(e){return D({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 ke(e){return D({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 Ae(e){return D({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 je(e){return D({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 Me(e){return D({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 Ne(e){return D({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 Y(e){return D({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 Pe(e){return D({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 Fe(e){return D({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 Ie(e){return D({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 Le(e){return D({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 Re(e){return D({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 ze(e){return D({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 Be(e){return D({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 Ve(e){return D({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 He(e){return D({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 Ue(e){return D({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 We(e){return D({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 Ge(e){return D({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 Ke(e){return D({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 qe(e){return D({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:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function Je(e){return D({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 Ye(e){return D({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 Xe(e){return D({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 Ze(e){return D({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 Qe(e){return D({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 $e(e){return D({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 et(e){return D({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 tt(e){return D({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 nt(e){return D({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 rt(e){return D({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 it(e){return D({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 at(e){return D({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 ot(e){return D({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 st(e){return D({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 ct(e){return D({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 lt(e){return D({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 ut(e){return D({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 dt(e){return D({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 ft(e){return D({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 pt(e){return D({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 mt(e){return D({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 ht(e){return D({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 gt(e){return D({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 _t(e){return D({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 vt(e){return D({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 yt(e){return D({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 bt(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${xt(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 xt(e){return e.startsWith(`git:`)?e:`git:${e}`}function St(){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 Ct(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,m.useRef)(t);(0,m.useLayoutEffect)(()=>{a.current=t}),(0,m.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 wt=[],Tt=!1;function Et(e){if(e.key===`Escape`&&wt.length!==0)for(let t=wt.length-1;t>=0;t--){let n=wt[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function Dt(){!Tt&&typeof document<`u`&&(document.addEventListener(`keydown`,Et,!0),Tt=!0)}function Ot(){Tt&&wt.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,Et,!0),Tt=!1)}function kt(e){return wt.push(e),Dt(),()=>{let t=wt.lastIndexOf(e);t>=0&&wt.splice(t,1),Ot()}}function At(e,t=!0){let n=(0,m.useRef)(e);(0,m.useLayoutEffect)(()=>{n.current=e}),(0,m.useEffect)(()=>{if(t)return kt(()=>n.current())},[t])}var X=i();function jt({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 Mt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,menuClassName:c,triggerClassName:l,menuRef:u,menuStyle:d}){let f=(0,m.useRef)(null),p=(0,m.useRef)(null),[h,g]=(0,m.useState)(0),_=e=>{p.current=e,typeof u==`function`?u(e):u&&`current`in u&&(u.current=e)},v=()=>{let e=f.current,t=p.current;if(!e||!t)return;if(window.innerWidth<=768){h!==0&&g(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){h!==0&&g(0);return}let a=n.width,o=jt({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==h&&g(o)};return(0,m.useLayoutEffect)(()=>{t?v():h!==0&&g(0)}),(0,m.useEffect)(()=>{if(t)return window.addEventListener(`resize`,v),()=>window.removeEventListener(`resize`,v)},[t,h]),Ct(f,()=>n(!1),{enabled:t}),At(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:f,children:[(0,X.jsxs)(`button`,{type:`button`,className:l??`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,(0,X.jsx)(rt,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${c??``}`,ref:_,style:h===0?d:{...d,transform:d?.transform?`${d.transform} translateX(${h}px)`:`translateX(${h}px)`},children:r})]})}function Nt({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 Pt=`pi-web-tts`,Ft={enabled:!1,announce:!0,readReplies:!1,rate:1,voiceURI:``};function It(){try{let e=localStorage.getItem(Pt);if(!e)return{...Ft};let t={...Ft,...JSON.parse(e)};for(let e of[`enabled`,`announce`,`readReplies`])typeof t[e]!=`boolean`&&(t[e]=Ft[e]);return t.rate=typeof t.rate!=`number`||!Number.isFinite(t.rate)?Ft.rate:Math.round(Math.max(.5,Math.min(2,t.rate))*10)/10,typeof t.voiceURI!=`string`&&(t.voiceURI=Ft.voiceURI),t}catch{return{...Ft}}}function Lt(e){try{localStorage.setItem(Pt,JSON.stringify(e))}catch{}}function Rt(){return typeof window<`u`&&`speechSynthesis`in window}function zt(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 Bt(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 Vt(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 Bt((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-NerrJlTS.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";(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 m=e(t(),1),h={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},g=m.createContext&&m.createContext(h),_=[`attr`,`size`,`title`];function v(e,t){if(e==null)return{};var n,r,i=y(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 y(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 b(){return b=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},b.apply(null,arguments)}function x(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 S(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?x(Object(n),!0).forEach(function(t){C(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function C(e,t,n){return(t=w(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function w(e){var t=T(e,`string`);return typeof t==`symbol`?t:t+``}function T(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 E(e){return e&&e.map((e,t)=>m.createElement(e.tag,S({key:t},e.attr),E(e.child)))}function D(e){return t=>m.createElement(O,b({attr:S({},e.attr)},t),E(e.child))}function O(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=v(e,_),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),m.createElement(`svg`,b({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:S(S({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&m.createElement(`title`,null,i),e.children)};return g===void 0?t(h):m.createElement(g.Consumer,null,e=>t(e))}var k=r(),A=n();function j(e){return D({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 ee(e){return D({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 M(e){return D({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 N(e){return D({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 P(e){return D({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 D({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 I(e){return D({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 L(e){return D({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 te(e){return D({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 D({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 D({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 ne(e){return D({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 re(e){return D({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 D({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 ie(e){return D({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 V(e){return D({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 H(e){return D({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 U(e){return D({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 W(e){return D({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 G(e){return D({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 ae(e){return D({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 oe(e){return D({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 se(e){return D({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 D({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 ce(e){return D({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 le(e){return D({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 ue(e){return D({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 de(e){return D({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 fe(e){return D({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 pe(e){return D({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 me(e){return D({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 he(e){return D({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 ge(e){return D({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 _e(e){return D({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 q(e){return D({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 ve(e){return D({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 ye(e){return D({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 be(e){return D({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 xe(e){return D({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 Se(e){return D({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 Ce(e){return D({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 we(e){return D({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 Te(e){return D({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 J(e){return D({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 Ee(e){return D({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 De(e){return D({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 Oe(e){return D({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 ke(e){return D({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 Ae(e){return D({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 je(e){return D({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 Me(e){return D({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 Ne(e){return D({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 Y(e){return D({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 Pe(e){return D({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 Fe(e){return D({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 Ie(e){return D({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 Le(e){return D({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 Re(e){return D({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 ze(e){return D({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 Be(e){return D({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 Ve(e){return D({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 He(e){return D({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 Ue(e){return D({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 We(e){return D({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 Ge(e){return D({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 Ke(e){return D({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 qe(e){return D({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:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function Je(e){return D({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 Ye(e){return D({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 Xe(e){return D({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 Ze(e){return D({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 Qe(e){return D({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 $e(e){return D({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 et(e){return D({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 tt(e){return D({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 nt(e){return D({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 rt(e){return D({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 it(e){return D({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 at(e){return D({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 ot(e){return D({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 st(e){return D({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 ct(e){return D({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 lt(e){return D({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 ut(e){return D({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 dt(e){return D({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 ft(e){return D({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 pt(e){return D({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 mt(e){return D({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 ht(e){return D({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 gt(e){return D({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 _t(e){return D({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 vt(e){return D({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 yt(e){return D({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 bt(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${xt(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 xt(e){return e.startsWith(`git:`)?e:`git:${e}`}function St(){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 Ct(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,m.useRef)(t);(0,m.useLayoutEffect)(()=>{a.current=t}),(0,m.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 wt=[],Tt=!1;function Et(e){if(e.key===`Escape`&&wt.length!==0)for(let t=wt.length-1;t>=0;t--){let n=wt[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function Dt(){!Tt&&typeof document<`u`&&(document.addEventListener(`keydown`,Et,!0),Tt=!0)}function Ot(){Tt&&wt.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,Et,!0),Tt=!1)}function kt(e){return wt.push(e),Dt(),()=>{let t=wt.lastIndexOf(e);t>=0&&wt.splice(t,1),Ot()}}function At(e,t=!0){let n=(0,m.useRef)(e);(0,m.useLayoutEffect)(()=>{n.current=e}),(0,m.useEffect)(()=>{if(t)return kt(()=>n.current())},[t])}var X=i();function jt({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 Mt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,menuClassName:c,triggerClassName:l,menuRef:u,menuStyle:d}){let f=(0,m.useRef)(null),p=(0,m.useRef)(null),[h,g]=(0,m.useState)(0),_=e=>{p.current=e,typeof u==`function`?u(e):u&&`current`in u&&(u.current=e)},v=()=>{let e=f.current,t=p.current;if(!e||!t)return;if(window.innerWidth<=768){h!==0&&g(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){h!==0&&g(0);return}let a=n.width,o=jt({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==h&&g(o)};return(0,m.useLayoutEffect)(()=>{t?v():h!==0&&g(0)}),(0,m.useEffect)(()=>{if(t)return window.addEventListener(`resize`,v),()=>window.removeEventListener(`resize`,v)},[t,h]),Ct(f,()=>n(!1),{enabled:t}),At(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:f,children:[(0,X.jsxs)(`button`,{type:`button`,className:l??`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,(0,X.jsx)(rt,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${c??``}`,ref:_,style:h===0?d:{...d,transform:d?.transform?`${d.transform} translateX(${h}px)`:`translateX(${h}px)`},children:r})]})}function Nt({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 Pt=`pi-web-tts`,Ft={enabled:!1,announce:!0,readReplies:!1,rate:1,voiceURI:``};function It(){try{let e=localStorage.getItem(Pt);if(!e)return{...Ft};let t={...Ft,...JSON.parse(e)};for(let e of[`enabled`,`announce`,`readReplies`])typeof t[e]!=`boolean`&&(t[e]=Ft[e]);return t.rate=typeof t.rate!=`number`||!Number.isFinite(t.rate)?Ft.rate:Math.round(Math.max(.5,Math.min(2,t.rate))*10)/10,typeof t.voiceURI!=`string`&&(t.voiceURI=Ft.voiceURI),t}catch{return{...Ft}}}function Lt(e){try{localStorage.setItem(Pt,JSON.stringify(e))}catch{}}function Rt(){return typeof window<`u`&&`speechSynthesis`in window}function zt(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 Bt(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 Vt(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 Bt((n.content??[]).filter(e=>e?.type===`text`&&typeof e.text==`string`).map(e=>e.text??``).join(`
|
|
3
3
|
`))}return``}var Ht=!1,Ut=null,Wt=null,Gt=new Set;function Kt(e,t=null){e?(Ht=!0,Ut=t):(Ht=!1,Ut=null);for(let t of Gt)try{t(e)}catch{}}function qt(){return Ht}function Jt(){return Ht?Ut:null}function Yt(e){return Gt.add(e),()=>Gt.delete(e)}function Xt(e,t=It(),n){if(e&&Rt())try{let r=window.speechSynthesis;r.cancel();let i=new SpeechSynthesisUtterance(e);i.rate=t.rate;let a=zt(t.voiceURI,r.getVoices(),navigator.language);a&&(i.voice=a),i.onend=()=>{Wt===i&&Kt(!1)},i.onerror=()=>{Wt===i&&Kt(!1)},Wt=i,Kt(!0,n??null),r.speak(i)}catch{Wt=null,Kt(!1)}}function Zt(){if(Rt()){try{window.speechSynthesis.cancel()}catch{}Wt=null,Kt(!1)}}var Qt=null;function $t(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 en(){return Qt===null&&(Qt=$t()),Qt}function tn(e,t){return t===`/`?e:t+e.replace(/^\/+/,``)}function nn(e){return tn(e,en())}var rn=`pi-web-ui:token`;function an(){try{let e=new URL(window.location.href),t=e.searchParams.get(`token`);t&&(localStorage.setItem(rn,t.trim()),e.searchParams.delete(`token`),window.history.replaceState(null,``,e.toString()))}catch{}}function on(){try{return localStorage.getItem(rn)??``}catch{return``}}function sn(e){let t=on();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}var cn=[`zh`,`en`,`de`,`es`,`fr`,`it`,`ja`,`ko`,`pt`,`ru`];function ln(e,t,n,r=cn){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 un=`pi-web-ui:lang`,dn={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:`刷新`,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:`子代理`,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:`检测到高危操作或关键配置修改`,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:`下移`,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:`此电脑`,rootDir:`根目录`,homeDir:`用户目录`,desktopDir:`桌面`,filesHelp:`浏览:点文件夹进入、点文件预览,「..」返回上级;「根目录」回当前项目根,「此电脑」浏览全盘换盘符,「🏠」直达用户目录,「🖥️」直达桌面。
|
|
4
4
|
文件操作:右键可新建文件/文件夹、重命名、复制/剪切/粘贴、创建副本、删除、上传文件;文件可下载,行尾按钮可复制名称/路径。
|
|
5
5
|
切换项目:文件夹右键「以项目打开」,或点右下角 📁 路径按钮输入/选择目录。
|
|
@@ -154,7 +154,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n,r,t as i}from
|
|
|
154
154
|
2. 用最小实现让测试通过
|
|
155
155
|
3. 重构并保持测试通过
|
|
156
156
|
|
|
157
|
-
避免三种反模式:与实现耦合的测试、空洞断言(永远为真)、横向切片(只测表面)。每步汇报并运行测试。`,error:`出错`,done:`完成`,running:`执行中…`,toolQueued:`排队中`,copyArgs:`复制参数`,copyMessage:`复制消息`,copied:`已复制`,copyText:`复制纯文本`,copyMarkdown:`复制 Markdown`,copyImage:`复制为图片`,speakMsg:`朗读`,stopSpeakingMsg:`停止朗读`,copyFailed:`复制失败`,saveAsImage:`保存为图片`,copyImageBtn:`复制图片`,savingImage:`正在生成图片…`,imageTitle:`标题`,imageTitlePlaceholder:`可选,显示在图片顶部`,imageBorder:`边框`,imageWatermark:`水印`,imageWatermarkPlaceholder:`水印文字`,exportSelectHint:`勾选对话中的消息拼进图片(越早的越靠上)`,exportTooLong:`选中内容太长,请减少条数后再复制`,exportSelectedCount:`已选 {n} 条`,exportIncludeTools:`包含工具调用`,exportIncludeThinking:`包含思考过程`,errorOutput:`错误输出`,output:`输出`,waitingOutput:`等待输出…`,toolDoneWaitingModel:`已结束 · 等模型`,waitingModel:`等待模型响应…`,thinkingNow:`思考中`,thinkingPreview:`思考:{preview}`,commands:`命令`,newCommand:`新建命令`,newTerminal:`新建终端`,name:`名称`,command:`命令`,cwdHint:"(${pwd} = 当前工作目录)",noCommands:`还没有命令,点 + 添加一个`,clickToRun:`点击运行`,edit:`编辑`,delete:`删除`,confirmQ:`确认?`,builtinTerminal:`内置终端`,termEmptySub:`点击左侧命令运行,或点右侧 + 新建终端`,noTerminal:`暂无终端`,exited:`(已退出{code})`,exitBanner:`[进程已退出,退出码 {code}]`,closeTerminal:`关闭终端`,renameTerminal:`重命名终端`,rerun:`重新读取 .pi/commands.json`,terminalTitle:`终端 {n}`,aiBashGroup:`终端接管 bash`,exampleName:`例如:启动开发服务器`,exampleCommand:`例如:npm run dev`,scmTab:`Git`,scmTitle:`源代码管理`,scmRefreshTip:`重新查询 Git 状态与差异`,scmCurrentBranch:`当前分支`,scmUpstreamGone:`上游已删除`,scmAheadBehind:`↑{ahead} ↓{behind}`,scmDetached:`分离 HEAD`,scmSelectBranch:`选择分支…`,scmRemoteBranches:`远程分支`,scmStageTip:`暂存 {path}`,scmUnstageTip:`取消暂存 {path}`,scmSwitch:`切换`,scmSwitchBranch:`切换分支`,scmSwitchBranchTip:`在终端中执行 git checkout {branch}`,scmPush:`推送`,scmPushTip:`在终端中执行 git push`,scmPull:`拉取`,scmPullTip:`在终端中执行 git pull`,scmCommit:`提交`,scmCommitTip:`在终端中执行 git commit -m "…"(仅提交已暂存的更改)`,scmCommitAll:`全部提交`,scmCommitAllTip:`在终端中执行 git add -A && git commit -m "…"(暂存全部更改含未跟踪并提交)`,scmCommitPlaceholder:`输入提交信息…`,scmGenMsg:`AI 生成`,scmGenMsgRunning:`生成中…`,scmGenMsgTip:`用当前模型生成提交信息:有暂存改动按暂存内容,否则按全部改动(含未跟踪);语言风格跟随本仓库近期提交`,scmGenMsgFail:`生成提交信息失败`,scmChanges:`更改`,scmHistory:`提交树`,scmCommitDetail:`提交详情`,scmSelectCommitHint:`点击左侧提交查看详情`,scmNoHistory:`暂无提交记录`,scmHistoryFilterPlaceholder:`过滤提交(主题 / 作者 / hash)…`,scmHistoryFilterTip:`空格分隔多关键字(AND 语义);匹配主题 / 作者 / hash / 分支·标签`,scmHistoryFilterEmpty:`没有匹配的提交`,scmCommitHistoryTip:`按 ↑/↓ 回溯最近用过的提交信息`,scmNoChanges:`工作区干净,没有更改`,scmNotGitRepo:`当前目录不是 Git 仓库`,scmLoading:`查询中…`,scmConnecting:`等待连接…`,scmDiff:`差异`,scmSelectFileHint:`点击左侧文件查看差异`,scmNoDiff:`(无差异)`,scmStaged:`已暂存`,scmUnstaged:`未暂存`,scmStagedUnstaged:`已暂存 + 未暂存`,scmUntracked:`未跟踪`,scmUntrackedNote:`未跟踪文件:需先用 + 暂存,或使用“全部提交”才会包含`,scmQueryFailedShort:`查询失败`,pluginCommandFallback:`插件命令`,scmRunsInTerminal:`提交 / 切换分支 / 推送 / 拉取在终端中执行`,scmViewTerminal:`去终端`,oauthLogin:`使用 {name} 登录`,oauthLogout:`退出登录`,oauthConnected:`已通过 {name} 登录`,oauthDeviceCode:`设备验证码`,oauthOpenVerification:`打开验证页面`,oauthContinue:`继续`,configuredBadge:`✓ 已配置`,clearKey:`清空`,clearKeyTitle:`清除该服务商保存在 auth.json 的密钥,回到未配置状态(环境变量来源的无法在此清除)`,clearKeyConfirm:`清空 {id} 已保存的密钥?其模型将从列表消失,直到重新配置。`,cloneProvider:`添加密钥`,cloning:`添加中`,savingKey:`保存中`,saveKey:`保存密钥`,addKey:`添加密钥`,addKeyPlaceholder:`粘贴密钥值…`,keyNamePh:`名称(可留空,如 备用)`,netDisconnected:`网络连接已断开,请重连后重试`,noKeyYet:`尚无密钥,添加一把即可用`,activateKey:`设为当前`,removeKey:`移除`,removeKeyConfirm:`确定移除该密钥?移除后需重新配置才能使用。`,reloadModelsConfig:`重新加载配置`,reloadModelsHint:`直接改过 models.json(手工或脚本)?点下面的「重新加载配置」从磁盘重读,无需重启服务。`,refreshBuiltinHint:`内置供应商(opencode 等)的模型来自 pi 官方目录,本地缓存 4 小时。官方已上新但下拉里没有时,点这里绕过缓存直拉最新(约半分钟)。`,refreshBuiltinBusy:`正在拉取官方目录…`,refreshBuiltinOk:`官方目录已更新,模型下拉已刷新`,refreshBuiltinFail:`强制刷新失败,稍后重试`,appendModel:`加模型`,appendModelOk:`已添加,模型下拉已更新`,appendModelFail:`添加失败`,providerId:`服务商 ID`,providerIdHint:`(必填,如 ollama / my-proxy)`,displayName:`显示名`,displayNamePh:`我的代理`,apiType:`API 类型`,baseUrlHint:`(OpenAI 兼容端点)`,apiKeyHint:`sk-…(可留空,用 auth.json 的密钥)`,apiKeySavedHint:`已保存,留空不修改`,authHeader:`自动添加 Authorization 请求头`,text:`文本`,contextWindow:`上下文`,deleteProviderConfirm:`删除服务商 {id} 及其 {n} 个模型?`,fetchModels:`自动获取模型列表`,fetchModelsHint:`从 baseUrl 的 /models 接口自动拉取模型 ID(服务端请求,不受 CORS 限制)`,fetchingModels:`获取中…`,fetchModelsOk:`已获取 {n} 个模型`,fetchModelsEmpty:`接口未返回任何模型`,fetchModelsNeedBaseUrl:`请先填写 baseUrl 再获取`,enrichModels:`补参数`,enrichModelsHint:`按模型 id 查 OpenRouter / models.dev 目录补上下文、输出上限、识图与推理(只填空,不覆盖手填)`,enrichingModels:`补参中…`,enrichModelsCancel:`取消`,enrichModelsAbort:`中断补参数`,enrichCancelling:`正在取消…`,enrichModelsOk:`已补 {n} 个,未匹配 {m} 个`,enrichModelsErr:`补参数失败:{msg}`,enrichModelsNeedIds:`先填写至少一个模型 ID`,goalBarTitle:`目标`,goalBarPlaceholder:`输入要达成的目标…`,goalBarSet:`发送`,goalBarClear:`取消`,goalBarLocked:`锁定:应用到后续所有回合`,goalBarUnlocked:`仅本回合(改完自动清除)`,goalBarReviewModel:`调研模型`,goalBarUseMainModel:`使用主模型`,goalBarMaxRounds:`最大轮数`,goalBarMaxRoundsTip:`最大执行/重审轮数;0 或不填 = 不限(持续改到通过)`,goalBarUnlimitedShort:`不限`,goalBarExecModel:`执行模型`,goalBarExecModelTip:`执行对话的模型;空 = 跟随当前对话`,goalBarOpenExec:`执行对话`,goalBarOpenExecTip:`打开执行者对话(左栏可随时点开)`,goalBarStaleBackend:`⚠️ 服务端版本较旧(进程未重启):目标模式 2.0 不会生效,请重启 pi-web-ui 服务`,goalBarStop:`停止目标(并停掉执行对话)`,goalBarReviewing:`审查中…`,goalBarExecuting:`执行中…`,goalHistory:`历史`,goalBarRound:`第 {n} 轮`,goalBarPassed:`已通过`,goalBarFailed:`未通过`,goalBarBlocked:`⚠️ 受阻`,goalWizardBtn:`提炼`,goalWizardTip:`让 AI 通过问卷调研细化需求,收敛为目标`,goalWizardRunning:`目标调研中`,goalWizardCard:`目标调研`,settings:`设置`,settingsTitle:`设置`,settingsDesc:`修改立即生效:系统提示词、技能与插件开关会重建当前会话;审查提示词与审查技能只影响后续目标审查(回复进行中则主会话变更自动延迟)。`,settingsSystemPrompt:`系统提示词`,settingsPromptHistory:`输入历史`,settingsPromptHistoryDesc:`用 ↑↓ 在输入框循环历史提问,全局跨对话共享(localStorage)`,promptHistoryMax:`最大条数`,promptHistoryMaxHint:`超过上限时最旧的自动丢弃,可设 1–500`,promptHistoryCharLimit:`限制单条字数`,promptHistoryCharLimitHint:`开启后超长输入截断后保存,避免大段粘贴占满存储`,promptHistoryCharLimitPlaceholder:`最大字数(100–20000)`,promptHistoryClear:`清空历史`,promptHistoryClearConfirm:`确认清空?`,promptHistoryCount:`当前 {n} 条`,promptHistoryEmpty:`暂无历史记录,上/下键暂无可循环内容`,promptModeAppend:`追加`,promptModeReplace:`替换`,promptComposeHint:`模板里的 {{token}} 在每次对话时展开为对应「来源」的提示词;未覆盖的来源用自动内容(工具列表/项目上下文/技能等永远用最新数据生成)。`,promptComposeDesc:`组合模板:{{token}} 自由排序/删改/穿插自己的话;空 = 默认模板。下面每个来源可单独覆盖(留空 = 自动内容),也可逐块恢复默认。`,promptTemplateLabel:`组合模板`,promptSourcesLabel:`各来源(可单独覆盖)`,promptInsertTokens:`插入段落:`,promptResetAll:`恢复默认模板并清空所有覆盖`,promptResetSource:`恢复默认`,promptAutoBadge:`自动`,promptOverridePlaceholder:`输入覆盖内容(留空 = 用自动内容)…`,promptSourceDefaultEmpty:`(该来源当前无自动内容)`,promptReadonlyBadge:`系统自动生成(只读)`,promptReadonlyLockedHint:`该来源由系统自动生成,只读;此覆盖不会被设置面板编辑,服务端仍按原样生效。`,promptReadonlyTitle:`系统自动生成的来源,仅只读展示,不可编辑`,promptSourceDefaultEditHint:`该来源当前的默认(自动)内容 —— 点击可直接输入覆盖文字`,promptSourceExpand:`展开全文`,promptSourceCollapse:`收起`,promptSourceRefLabel:`默认(自动)内容(可对照 / 复制)`,promptSourceSeedButton:`填入默认内容,只改一小部分`,promptSourceSeedTip:`把该来源当前的默认内容复制进覆盖框:只想改一小部分时直接改这里。填入后此来源内容固定,不再随每次对话自动重新生成。`,promptTok_soul:`灵魂提示词`,promptTok_soul_desc:`agent 人物设定(无 SYSTEM.md 时内置默认)`,promptTok_tools:`工具列表`,promptTok_tools_desc:`Available tools(各工具说明,每次自动生成)`,promptTok_guidelines:`行为准则`,promptTok_guidelines_desc:`Guidelines:各工具引导 + 通用规则`,promptTok_pi_docs:`Pi 文档指引`,promptTok_pi_docs_desc:`指向 pi 包文档的提示段`,promptTok_append:`追加段`,promptTok_append_desc:`APPEND_SYSTEM.md 内容;覆盖 = 自定义追加文字`,promptTok_persona:`Windows 约束`,promptTok_persona_desc:`Windows persona(仅 win32;超时/PTY/GBK 注意事项)`,promptTok_terminal:`终端工具引导`,promptTok_terminal_desc:`持久终端使用引导(「终端工具」开时注入)`,promptTok_markers:`标记工具引导`,promptTok_markers_desc:`内置标记工具使用说明(markers 开时注入)`,promptTok_context:`项目上下文`,promptTok_context_desc:`<project_context>:AGENTS.md/CLAUDE.md 收集结果`,promptTok_skills:`技能段`,promptTok_skills_desc:`<available_skills>:可用技能清单`,promptTok_cwd:`工作目录行`,promptTok_cwd_desc:`Current working directory 行`,settingsViewPrompt:`查看当前完整提示词`,settingsViewPromptTokens:`{n} tokens`,settingsViewPromptHint:`当前会话实际生效的完整系统提示词(含自定义追加/替换内容、项目上下文、技能说明与工具引导),只读。`,settingsViewPromptEmpty:`会话尚未就绪,暂无系统提示词。`,settingsViewToolsSchema:`查看工具 schema`,settingsViewToolsSchemaHint:`发给模型的 function-calling 工具定义(name / description / parameters),与系统提示词正文拼成完整初始上下文,只读。`,settingsViewToolsSchemaEmpty:`会话尚未就绪,暂无工具 schema。`,settingsPromptContextTotal:`合计: {n} tokens`,settingsSkills:`技能`,settingsReview:`目标审查`,settingsReviewDesc:`为独立的目标审查会话配置额外提示词和技能;不会改变主会话设置。`,settingsReviewSkills:`审查可用技能`,reviewPromptPlaceholder:`输入审查自定义提示词…(失焦后自动应用)`,goalModeEnabled:`启用目标模式`,goalModeEnabledDesc:`目标条 / 目标调研向导 / 审查循环的总开关(默认开)。关闭后目标条隐藏,无法设置目标、启动调研或触发审查。`,goalModeOffHint:`目标模式已关闭:目标条已隐藏,已有的目标将不再触发审查。`,delegateMode:`审查者模式(自动委派)`,delegateModeDesc:`开启后本对话**只审阅不施工**:你发的每条请求由服务端自动转给一个常驻的落盘执行对话去干活,本对话负责看结果、提要求。写文件/跑命令/再派子代理会被服务端硬闸门拒绝。`,delegateModeOffHint:`审查者模式已关闭:恢复普通对话,本对话可以直接改代码。`,delegateModeBadge:`审查者`,delegateModeBadgeTip:`审查者模式已开:活由常驻执行对话执行(还没派过活)`,delegateModeOpenTip:`打开常驻执行对话,看它干了什么`,settingsVisionBridge:`视觉桥`,settingsVisionBridgeDesc:`当前模型不支持识图时,把图片交给已配置的视觉模型转写为文字证据,再让模型回答`,visionBridgeEnabled:`启用视觉桥`,visionBridgeModel:`转写模型`,visionBridgeAuto:`自动选择(按顺序)`,visionBridgeNoModels:`未找到已配置的视觉模型:在模型配置里添加任意支持图片的模型(如 qwen-vl、GLM-4V、Gemini)即可自动启用`,visionBridgeOffHint:`已关闭:图片将原样发送,纯文本模型可能看不到图片内容`,visionBridgeCurrent:`当前转写模型:{model}`,visionBridgePromptMode:`转写提示词`,settingsMarkers:`标记工具`,settingsMarkersDesc:`让 AI 用 [[todo:...]] / [[notify:...]] / [[conv:rename:...]] 内联标记在正文里改状态,无需工具往返。全局关闭则全部停用;分组开关可细粒度控制。`,markersEnabled:`启用标记工具(全局)`,markersEnabledDesc:`关闭后 AI 不再收到任何标记引导,解析也跳过(所有标记原文原样保留,不执行)。`,markersOffHint:`已全局关闭:所有标记停用,AI 不会写标记,也不会触发任务/重命名等副作用。`,markerGroupTodo:`任务标记 todo`,markerGroupNotify:`提醒标记 notify`,markerGroupRename:`重命名标记 conv/rename`,markerRenameTip:`[[conv:rename:新标题]] 重命名当前对话(标题 ≤80 字;在回复第一条消息末尾根据情况重命名)`,terminalToolsEnabled:`启用持久终端工具`,settingsTerminalToolsDesc:`让 AI 在交互式程序(REPL/vim)、长驻服务、需要持续观察输出或你要求在可见终端操作时,使用内置终端;普通命令仍走一次性 bash 工具`,editSoftEnabled:`启用编辑工具 edit_soft`,editSoftEnabledDesc:`让 AI 用一个独立、不严格要求缩进的编辑工具:当你的 oldText 与文件缩进/空白不一致(如 JS/JSON)时可避免因缩进差异导致编辑失败。命中后按你给出的 newText 原样写入(缩进即最终缩进)。`,editSoftOffHint:`已关闭:AI 无法使用 edit_soft 工具,也不会收到相关使用引导`,settingsQuestionnaire:`问卷提问`,questionnaireEnabled:`允许模型向我提问(问卷)`,questionnaireEnabledDesc:`开启默认值:模型可用 ask_user_question 弹出可回复的问卷/提问对话框(含选项、多选、自定义输入)。关闭后模型将不再弹出问卷,调用也会直接返回已禁用。`,questionnaireOffHint:`已关闭:模型不能再向你弹出问卷/提问对话框`,parallelReminderEnabled:`同项目并行提醒`,parallelReminderEnabledDesc:`同一项目有别的对话正在运行时,新一轮开始前提醒一次(默认开)。提醒同时告诉 AI 评估冲突,拿不准就问你:并行 / 等它跑完 / 只读围观。`,parallelReminderOffHint:`已关闭:并行时不再提醒,AI 也收不到冲突提示`,browserPageEnabledDesc:`让模型操作浏览器里被授权的页面(page-picker 扩展的 browser_page 工具:读内容 / 点击 / 输入 / 滚动 / 跳转,eval 另有单独开关)。需要先在扩展选项页授权目标页面。`,browserPageOffHint:`已关闭:模型不能再点你的页面、也不能在页面里执行脚本`,conversationReadEnabledDesc:`让 AI 按需读取别的对话(含运行中子代理的实时消息与历史转录):只读的小引用,不占 token,需要时才取。`,conversationReadOffHint:`已关闭:AI 无法再读取别的对话内容`,scheduleTaskEnabledDesc:`让 AI 创建定时/延时唤醒(schedule_task 建任务、schedule_list 查看、schedule_cancel 取消):到期自动把指令投回发起对话执行并汇报;默认单次,用完即删。`,scheduleTaskOffHint:`已关闭:AI 无法再建定时任务(已建任务不受影响)`,browserControl:`浏览器操作`,browserControlTip:`让 AI 操作你在浏览器里授权的页面(读内容 / 点按钮 / 填表单 / 滚动),需要 page-picker 扩展;授权与开关都在扩展设置页里。`,browserControlChecking:`正在查询扩展状态…`,browserControlOffline:`还没连上浏览器扩展:装好(或启用)page-picker 扩展,在本页点一次扩展图标绑定地址,然后刷新本页。`,browserControlInstall:`装扩展(两分钟)`,browserControlInstallLead:`扩展不在 Chrome 应用商店,不用去商店搜,按下面四步装:`,browserControlInstallDownload:`下载 page-picker-extension.zip(永远是最新版)`,browserControlInstallStep1:`解压 zip(得到含 manifest.json 的目录)。`,browserControlInstallStep2:`Chrome / Edge 打开 chrome://extensions(Edge 是 edge://extensions),右上角打开「开发者模式」。`,browserControlInstallStep3:`点「加载已解压的扩展程序」,选中第 1 步解压出的目录。`,browserControlInstallStep4:`回到这个 pi-web-ui 页面点一下扩展图标,按提示「设为服务地址」——地址端口不用手填。`,browserControlEmpty:`扩展已就绪,但还没授权任何页面 —— 点下面的「打开扩展设置页」,在那里授权一个页面。`,browserControlDisabled:`「允许 AI 操作页面」总开关是关的 —— 在扩展设置页打开它。`,browserControlPages:`已授权的页面`,browserControlPageOpen:`开着`,browserControlPageClosed:`没打开`,browserControlExamples:`可以这样让它干活`,browserControlExample1:`「把那个页面上的订单读出来,按金额排序」`,browserControlExample2:`「在搜索框输入 张三,点查询,等结果出来告诉我第一条」`,browserControlOpenOptions:`打开扩展设置页`,browserControlRefresh:`刷新状态`,browserControlCite:`引用到对话`,browserControlCiteTip:`把 {name} 作为网页引用放进输入框(不自动发送,你补一句话再发)`,browserControlCiteNote:`点「引用到对话」会把网页引用放进输入框:模型据此知道操作哪个页面,不必再手打网址。`,browserControlCited:`已引用到输入框 —— 补一句话再发`,browserControlCiteFailed:`输入框还没准备好,稍后再试`,browserControlOpenPanel:`打开面板(状态 / 授权管理)`,browserControlSingleTip:`点击把 {name} 引用到对话;右侧 ▾ 打开面板`,browserControlDesktop:`桌面版用不了浏览器操作 —— 不是你装错了`,browserControlDesktopLead:`桌面窗口里没有 Chrome 扩展运行时,page-picker 扩展装不上。用下面的按钮在系统浏览器里打开同一个地址,再按网页版的四步装扩展即可。`,browserControlOpenInBrowser:`用默认浏览器打开当前地址`,attachPage:`网页引用:{name}(AI 已获授权操作这个页面)`,attachPageShort:`网页`,settingsTools:`工具`,toolsSectionCore:`核心工具`,toolsCoreHint:`bash / read / edit / write / powershell 是模型干活的基本盘,不在下方目录开关里。关闭后模型无法执行对应操作:关 bash 不能跑命令,关 read 不能读文件,关 edit / write 不能改文件,关 powershell 不能跑 PowerShell 命令(仅 Windows)。`,toolCoreBashDesc:`执行 shell 命令。关闭后模型不能跑命令、装依赖、跑测试。`,toolCoreReadDesc:`读取文件与目录。关闭后模型只能靠对话里已有的内容干活。`,toolCoreEditDesc:`精确编辑文件。关闭后模型不能局部修改代码。`,toolCoreWriteDesc:`新建或整写文件。关闭后模型不能创建、覆盖文件。`,toolCorePowershellDesc:`执行 PowerShell 命令(仅 Windows 有效)。关闭后模型不能运行 PowerShell 命令。`,toolCoreLsDesc:`列出目录内容。关闭后模型无法调用 ls 列目录(可被 read 目录模式完全替代)。`,toolCoreGrepDesc:`正则搜索文件内容,返回匹配行与行号。关闭后模型不能直接调 grep(可用 bash 命令替代)。`,toolCoreFindDesc:`按 glob 规则搜索文件名与相对路径。关闭后模型不能直接调 find(可用 bash 命令替代)。`,toolsSectionTerminal:`持久终端`,toolsSectionSubagent:`子代理`,toolsSectionOther:`其他工具`,toolsSectionPlugin:`插件工具`,toolsPluginHint:`插件经 registerAgentTool 注册的 AI 工具:关掉即从会话里移除,AI 调不动;重开立即加回,无需 reload。禁掉的条目会保留,插件重装后仍保持关闭。`,pluginToolsSection:`注册的 AI 工具`,pluginToolsEmpty:`已安装的插件都没有注册 AI 工具`,pluginToolOffHint:`已关闭:AI 无法调用该工具(重开立即恢复,无需 reload)`,toolsPresetBanner:`默认预设「{name}」正在过滤工具:新对话有 {count} 个工具开关暂不生效(切回全功能即恢复)`,toolsBackToStandard:`切回全功能`,toolsBlockedByPreset:`当前默认预设「{name}」下不可用,切回「全功能」恢复`,pluginToolsDisabledByPlugin:`所属插件已在「界面插件」中禁用,重新启用插件后恢复`,pluginDisabledInPlugins:`插件已禁用`,skillsHiddenByPreset:`技能名录被默认预设「{name}」隐藏(skill 加载工具不可用时不同步展示),切回全功能恢复`,toolsSubagentDepHint:`子代理统一入口:合并 spawn/wait/get/steer/stop/list/templates/handoff;delegate_task 走 spawn 通道,关闭子代理后 delegate_task 也无法派单。`,delegateTaskEnabledDesc:`把定义清楚的任务派给 specialist 子代理模板:六段派单(TASK/EXPECTED OUTCOME/REQUIRED TOOLS/MUST DO/MUST NOT DO/CONTEXT)在服务端校验,缺段或含糊直接报错打回。执行体复用子代理 spawn 通道。`,delegateTaskOffHint:`已关闭:AI 无法使用 delegate_task 派单(可用 subagent 自由派单,不带六段校验)`,todoListEnabledDesc:`只读查询当前任务列表,删除项需显式传参;写操作不走工具,直接写内联标记。`,todoListOffHint:`已关闭:AI 不能再调查询工具(内联标记的写入不受影响)`,toolDescSubagent:`后台子代理对话管理(左栏可见):统一支持 spawn(派发)、wait_all(等待收口)、get_result(查询结果)、steer(改向追加)、stop(中止)、list(运行态)、templates(模板名录)、handoff(同行协作)。`,toolDescSubagentSpawn:`后台起独立子代理对话(左栏可见),做可独立交付的任务;可并行多个。`,toolDescSubagentGetResult:`取单个子代理的结果或当前进度;未完成返回现状和部分输出。`,toolDescSubagentSteer:`向运行中的子代理注入消息,改向或补充要求。`,toolDescSubagentList:`列出全部子代理的运行态(id/类型/状态/标题)。`,toolDescSubagentStop:`停止运行中的子代理(等同中止它那路对话)。`,toolDescSubagentWaitAll:`一次等多个子代理全部完成并汇总结果,不用轮询。`,toolDescSubagentTemplates:`列出可用的子代理模板(停用的不出现),供 spawn 选用。`,settingsMessageDisplay:`对话`,thinkingWrap:`完整显示思考`,thinkingWrapDesc:`开启:思考内容始终完整展开并自动换行(流式推理过程也实时可见);关闭:折叠成一行摘要,流式中一行实时显示最新文本`,toolsWrap:`完整显示工具`,toolsWrapDesc:`开启:工具调用始终完整展开显示参数和输出;关闭:默认折叠,点击展开`,toolImages:`直接显示工具结果图片`,toolImagesDesc:`开启:截图这类工具结果图片在卡片里直接显示、点击放大;关闭:不显示图片`,toolImageZoom:`点击预览大图`,devNoCache:`开发模式:不缓存页面`,devNoCacheDesc:`开启:每次加载都取最新页面(源码开发用);关闭:允许浏览器缓存(安装包默认)`,autoReload:`新构建自动重载页面`,autoReloadDesc:`开启:服务端重建后页面自动重载(源码开发用);关闭:只重连不断页面(安装包默认)`,wideChat:`宽屏聊天列`,wideChatDesc:`开启:中央列铺满宽度(超宽屏有用);关闭:保持 860px 上限`,projectTitle:`标题显示项目名`,projectTitleDesc:`开启:浏览器标签页标题为「项目目录名 — pi-web-ui」,切项目即时更新(多标签页开多个项目时好区分);关闭:固定显示应用名`,terminalBashTakeover:`终端接管 bash`,terminalBashTakeoverDesc:`此开关决定 bash 是否覆盖为终端版:关 = 原生 SDK bash(纯进程、不开终端);开 = 跑进可见终端,且 persist 参数在本开关的基础上决定一次性(false,命令跑完进程退出、输出留档)还是持久(true,shell 状态跨调用保留、静默自动转后台并通知 AI)`,terminalBashIdleMs:`静默转后台阈值(毫秒)`,terminalBashIdleMsDesc:`持久终端模式下,命令连续无输出达到该时长即不再阻塞等待,转入后台继续运行并通知 AI;0 = 一直等到命令结束(默认 15000)`,terminalBashMaxForegroundMs:`前台最长等待(毫秒)`,terminalBashMaxForegroundMsDesc:`接管模式下,命令在前台执行的总时长达到该值后,无论是否有输出,均自动转入后台继续执行并解阻模型;0 = 不限(默认 60000)`,readDirEnabled:`read 读目录`,readDirEnabledDesc:`开启:read 工具传目录路径时列出目录条目(一行一项、目录带 / 后缀,此时 limit 是条目上限);关闭:目录参数原样交给内置 read(报 EISDIR,看目录得用 bash 的 ls)。DSH 引擎没有该覆盖,仅 pi 引擎生效`,toolWatchdogTimeout:`工具看门狗超时(分钟)`,toolWatchdogTimeoutDesc:`单个工具调用的最长执行时长(默认 20 分钟,0 = 禁用看门狗)。超时自动终止以防挂死;若工具调用显式指定了更长超时(如 bash timeout),看门狗将自动顺延`,toolWatchdogOff:`0 = 禁用`,visionBridgePromptPlaceholder:`输入自定义转写提示词…(留空 = 使用内置默认提示词,失焦后自动应用)`,scmCommitMsgSettingsTitle:`AI 提交信息(源代码管理)`,scmCommitMsgSettingsDesc:`源代码管理面板「AI 生成」按钮的提示词:模型按仓库近期提交的语言与风格,把当前改动提炼成一行提交信息并填入提交输入框`,scmCommitMsgPromptPlaceholder:`输入自定义提示词…(留空 = 使用内置默认提示词,失焦后自动应用)`,scmCommitMsgSettingsHint:`追加模式把自定义内容拼在内置提示词末尾;替换模式完全使用自定义内容(切换后输入框会显示内置默认,可直接修改,不改动失焦则仍使用默认)`,planModePromptSettingsTitle:`计划模式提示词`,planModePromptSettingsDesc:`计划模式(目标条里的「计划」按钮)开启时追加给模型的提示词:只调研 + 出计划,不实施。内置默认含「禁止把实现代码写进回复」「小需求可跳过计划看板走短计划」两条硬规则`,planModePromptMode:`计划模式提示词`,planModePromptPlaceholder:`输入自定义提示词…(留空 = 使用内置默认提示词,失焦后自动应用)`,planModePromptSettingsHint:`追加模式把自定义内容拼在内置提示词末尾;替换模式完全使用自定义内容(切换后输入框会显示内置默认,可直接修改,不改动失焦则仍使用默认)。仅影响提示词,服务端的只读硬闸门始终生效`,uninstallExt:`卸载`,uninstallConfirm:`确认卸载?`,uninstallConfirmHint:`再次点击确认,将在终端执行 pi remove`,uninstallHint:`通过可见终端执行 pi remove 卸载此包,完成后自动刷新列表`,uninstallTitle:`卸载`,pluginUpdate:`更新`,pluginUpdateHint:`从安装来源重新拉取并覆盖安装(保留 config.json 配置);后台执行,设置面板不用关,进度就地显示`,pluginMarket:`插件市场`,updatesManaged:`本实例由部署方管理:更新与插件安装不在此进行`,pluginCatalogAdd:`添加插件`,pluginCatalogAddHint:`把第三方插件填进可安装列表(owner/repo 或完整 GitHub 地址)`,pluginCatalogSource:`来源 owner/repo 或 owner/repo/子目录(必填)`,pluginCatalogId:`id(可选,默认取仓库/子目录名)`,pluginCatalogName:`名称(可选)`,pluginCatalogIcon:`图标 emoji(可选)`,pluginCatalogDesc:`简介(可选)`,pluginCatalogAddSubmit:`添加到列表`,pluginInspectAlreadyInstalled:`已安装同名插件「{id}」—— 用「更新」覆盖,或换个 id`,pluginInspectInvalid:`认不出这个来源 —— 应为 owner/repo、owner/repo/子目录[#ref]、GitHub 链接或 npm 包名`,pluginInspectNotPlugin:`远端没找到 manifest.json —— 这不是 pi-web-ui 插件(或仓库/子目录/分支写错了)`,pluginInspectNetwork:`没能连上远端核对(不影响安装)—— 网络/代理正常时可再试`,noPluginCatalog:`列表为空 —— 点「添加插件」把第三方插件填进列表`,pluginInstalled:`已安装`,pluginCatalogCustom:`自定义`,pluginInstall:`安装`,pluginInstallHint:`后台安装到界面插件(不用关设置面板,进度就地显示)`,pluginCatalogRemoveHint:`从列表移除这条自定义插件`,pluginUninstallHint:`后台卸载此插件(再次点击确认),完成后自动刷新列表`,pluginJobRunning:`后台执行中…`,pluginJobDone:`已完成`,pluginJobFailed:`插件操作失败`,pluginBuildSource:`源码构建`,pluginBuildHint:`安装/更新前先在隔离目录里构建(等价 CLI --build;只有源码没有产物时会自动构建,无需勾选)`,pluginCatalogSync:`从目录同步`,pluginCatalogSyncHint:`从目录文档同步可安装列表(与插件的 reloadCatalog 同一通道)`,pluginCatalogSyncSource:`目录 URL(http(s))或本地绝对路径`,pluginCatalogSyncSubmit:`同步`,pluginCatalogSyncInstall:`同步后安装全部条目`,pluginCatalogSyncReplace:`整体替换(默认按 id 合并)`,pluginCatalogSyncRecent:`最近同步`,pluginCatalogSyncOk:`同步成功:列表共 {n} 条`,pluginCatalogSyncInstalled:`安装结果:{ok} 成功,{fail} 失败`,uiLayoutTitle:`界面布局`,uiLayoutHint:`插件可以调整这里的条目(包括宿主内置入口);你随时能改回来:取消勾选=隐藏,↑/↓ 调顺序,改过的条目会显示「恢复」。隐藏的条目仍能在顶栏溢出菜单里点到。`,uiLayoutDiagTitle:`布局诊断({n} 条)`,uiLayoutDiagHint:`这些条目没有出现在界面上。原因见上;多半是插件的 manifest/注册写错了 slot、kind 或 arrange 目标。改好插件后重扫即可。`,pluginTopbarMore:`更多插件按钮`,pluginMenuTitle:`插件`,pluginMenuPin:`钉到顶栏`,pluginMenuUnpin:`取消钉住`,pluginMenuReorder:`调整插件顺序`,pluginMenuReorderHint:`拖动排序;聚焦后可用上下方向键`,pluginMenuManage:`管理插件`,pluginMenuEmpty:`未安装界面插件(<dataDir>/plugins/)`,pluginMenuNoView:`无独立界面`,uiLayoutTopbar:`顶栏`,uiLayoutRequired:`此入口固定显示,不能隐藏`,uiLayoutTopbarText:`显示按钮文字`,uiLayoutSideDockFloat:`侧边图标悬浮显示`,uiIconEdit:`编辑图标`,uiIconEditTitle:`图标编辑`,uiIconEditHint:`拖动图标即可调整:栏内前后、start/center/end 分段、换到另一个栏;拖进「待放回」即隐藏。`,uiIconEditTray:`待放回`,uiIconEditDropHere:`拖到这里`,uiLayoutTopbarOverflow:`顶栏溢出菜单`,uiLayoutBottombar:`底栏`,uiLayoutComposerLeading:`输入框前置区(上传按钮左侧)`,uiLayoutComposer:`输入框动作`,uiLayoutMessage:`消息工具条`,uiLayoutRightPanel:`右侧面板`,uiLayoutSettingsPages:`设置页`,uiLayoutModal:`弹窗`,uiLayoutContextTopbar:`顶栏右键菜单`,uiLayoutContextMessage:`消息右键菜单`,uiLayoutContextSession:`会话右键菜单`,uiLayoutContextFile:`文件右键菜单`,uiLayoutContextToolcall:`工具卡右键菜单`,uiLayoutLeftSessions:`左栏会话行`,uiLayoutChatHeader:`对话头部条`,uiLayoutChatEmpty:`空对话占位区`,uiLayoutFilePreview:`文件预览工具条`,uiLayoutTerminal:`终端工具条`,uiLayoutScm:`SCM 工具条`,uiLayoutGoalbar:`目标条动作`,uiLayoutNotice:`通知条动作`,uiLayoutSidebarLeft:`左侧悬浮栏`,uiLayoutSidebarRight:`右侧悬浮栏`,uiLayoutPosition:`位置`,uiLayoutPosTop:`顶部`,uiLayoutPosBottom:`底部`,uiLayoutPosLeft:`左侧悬浮`,uiLayoutPosRight:`右侧悬浮`,uiLayoutSearch:`搜索条目…`,uiLayoutMovedFrom:`移自`,uiLayoutAlign:`对齐`,uiLayoutRename:`改名`,uiLayoutRestore:`恢复`,uiLayoutRestoreAll:`全部恢复默认`,uiLayoutArranged:`插件调整过`,uiLayoutEmpty:`(无)`,moveToTop:`移到顶部`,moveToBottom:`移到底部`,moveToLeft:`移到左侧悬浮`,moveToRight:`移到右侧悬浮`,sideDockCollapse:`收起悬浮栏`,sideDockExpand:`展开悬浮栏`,pluginGrantsTitle:`已授权目录`,pluginGrantsHint:`插件要访问工作区之外的目录时必须先经你确认(确认过的会记在这里,可随时撤销)。`,pluginGrantsEmpty:`还没有插件获得过工作区外的目录授权`,pluginGrantsRevoke:`撤销`,pluginGrantRequestTitle:`插件请求访问目录`,pluginGrantRequestBody:`{plugin} 想访问下面这个目录:
|
|
157
|
+
避免三种反模式:与实现耦合的测试、空洞断言(永远为真)、横向切片(只测表面)。每步汇报并运行测试。`,error:`出错`,done:`完成`,running:`执行中…`,toolQueued:`排队中`,copyArgs:`复制参数`,copyMessage:`复制消息`,copied:`已复制`,copyText:`复制纯文本`,copyMarkdown:`复制 Markdown`,copyImage:`复制为图片`,speakMsg:`朗读`,stopSpeakingMsg:`停止朗读`,copyFailed:`复制失败`,saveAsImage:`保存为图片`,copyImageBtn:`复制图片`,savingImage:`正在生成图片…`,imageTitle:`标题`,imageTitlePlaceholder:`可选,显示在图片顶部`,imageBorder:`边框`,imageWatermark:`水印`,imageWatermarkPlaceholder:`水印文字`,exportSelectHint:`勾选对话中的消息拼进图片(越早的越靠上)`,exportTooLong:`选中内容太长,请减少条数后再复制`,exportSelectedCount:`已选 {n} 条`,exportIncludeTools:`包含工具调用`,exportIncludeThinking:`包含思考过程`,errorOutput:`错误输出`,output:`输出`,waitingOutput:`等待输出…`,toolDoneWaitingModel:`已结束 · 等模型`,waitingModel:`等待模型响应…`,thinkingNow:`思考中`,thinkingPreview:`思考:{preview}`,commands:`命令`,newCommand:`新建命令`,newTerminal:`新建终端`,name:`名称`,command:`命令`,cwdHint:"(${pwd} = 当前工作目录)",noCommands:`还没有命令,点 + 添加一个`,clickToRun:`点击运行`,edit:`编辑`,delete:`删除`,confirmQ:`确认?`,builtinTerminal:`内置终端`,termEmptySub:`点击左侧命令运行,或点右侧 + 新建终端`,noTerminal:`暂无终端`,exited:`(已退出{code})`,exitBanner:`[进程已退出,退出码 {code}]`,closeTerminal:`关闭终端`,renameTerminal:`重命名终端`,rerun:`重新读取 .pi/commands.json`,terminalTitle:`终端 {n}`,aiBashGroup:`终端接管 bash`,exampleName:`例如:启动开发服务器`,exampleCommand:`例如:npm run dev`,scmTab:`Git`,scmTitle:`源代码管理`,scmRefreshTip:`重新查询 Git 状态与差异`,scmCurrentBranch:`当前分支`,scmUpstreamGone:`上游已删除`,scmAheadBehind:`↑{ahead} ↓{behind}`,scmDetached:`分离 HEAD`,scmSelectBranch:`选择分支…`,scmRemoteBranches:`远程分支`,scmStageTip:`暂存 {path}`,scmUnstageTip:`取消暂存 {path}`,scmSwitch:`切换`,scmSwitchBranch:`切换分支`,scmSwitchBranchTip:`在终端中执行 git checkout {branch}`,scmPush:`推送`,scmPushTip:`在终端中执行 git push`,scmPull:`拉取`,scmPullTip:`在终端中执行 git pull`,scmCommit:`提交`,scmCommitTip:`在终端中执行 git commit -m "…"(仅提交已暂存的更改)`,scmCommitAll:`全部提交`,scmCommitAllTip:`在终端中执行 git add -A && git commit -m "…"(暂存全部更改含未跟踪并提交)`,scmCommitPlaceholder:`输入提交信息…`,scmGenMsg:`AI 生成`,scmGenMsgRunning:`生成中…`,scmGenMsgTip:`用当前模型生成提交信息:有暂存改动按暂存内容,否则按全部改动(含未跟踪);语言风格跟随本仓库近期提交`,scmGenMsgFail:`生成提交信息失败`,scmChanges:`更改`,scmHistory:`提交树`,scmCommitDetail:`提交详情`,scmSelectCommitHint:`点击左侧提交查看详情`,scmNoHistory:`暂无提交记录`,scmHistoryFilterPlaceholder:`过滤提交(主题 / 作者 / hash)…`,scmHistoryFilterTip:`空格分隔多关键字(AND 语义);匹配主题 / 作者 / hash / 分支·标签`,scmHistoryFilterEmpty:`没有匹配的提交`,scmCommitHistoryTip:`按 ↑/↓ 回溯最近用过的提交信息`,scmNoChanges:`工作区干净,没有更改`,scmNotGitRepo:`当前目录不是 Git 仓库`,scmLoading:`查询中…`,scmConnecting:`等待连接…`,scmDiff:`差异`,scmSelectFileHint:`点击左侧文件查看差异`,scmNoDiff:`(无差异)`,scmStaged:`已暂存`,scmUnstaged:`未暂存`,scmStagedUnstaged:`已暂存 + 未暂存`,scmUntracked:`未跟踪`,scmUntrackedNote:`未跟踪文件:需先用 + 暂存,或使用“全部提交”才会包含`,scmQueryFailedShort:`查询失败`,pluginCommandFallback:`插件命令`,scmRunsInTerminal:`提交 / 切换分支 / 推送 / 拉取在终端中执行`,scmViewTerminal:`去终端`,oauthLogin:`使用 {name} 登录`,oauthLogout:`退出登录`,oauthConnected:`已通过 {name} 登录`,oauthDeviceCode:`设备验证码`,oauthOpenVerification:`打开验证页面`,oauthContinue:`继续`,configuredBadge:`✓ 已配置`,clearKey:`清空`,clearKeyTitle:`清除该服务商保存在 auth.json 的密钥,回到未配置状态(环境变量来源的无法在此清除)`,clearKeyConfirm:`清空 {id} 已保存的密钥?其模型将从列表消失,直到重新配置。`,cloneProvider:`添加密钥`,cloning:`添加中`,savingKey:`保存中`,saveKey:`保存密钥`,addKey:`添加密钥`,addKeyPlaceholder:`粘贴密钥值…`,keyNamePh:`名称(可留空,如 备用)`,netDisconnected:`网络连接已断开,请重连后重试`,noKeyYet:`尚无密钥,添加一把即可用`,activateKey:`设为当前`,removeKey:`移除`,removeKeyConfirm:`确定移除该密钥?移除后需重新配置才能使用。`,reloadModelsConfig:`重新加载配置`,reloadModelsHint:`直接改过 models.json(手工或脚本)?点下面的「重新加载配置」从磁盘重读,无需重启服务。`,refreshBuiltinHint:`内置供应商(opencode 等)的模型来自 pi 官方目录,本地缓存 4 小时。官方已上新但下拉里没有时,点这里绕过缓存直拉最新(约半分钟)。`,refreshBuiltinBusy:`正在拉取官方目录…`,refreshBuiltinOk:`官方目录已更新,模型下拉已刷新`,refreshBuiltinFail:`强制刷新失败,稍后重试`,appendModel:`加模型`,appendModelOk:`已添加,模型下拉已更新`,appendModelFail:`添加失败`,providerId:`服务商 ID`,providerIdHint:`(必填,如 ollama / my-proxy)`,displayName:`显示名`,displayNamePh:`我的代理`,apiType:`API 类型`,baseUrlHint:`(OpenAI 兼容端点)`,apiKeyHint:`sk-…(可留空,用 auth.json 的密钥)`,apiKeySavedHint:`已保存,留空不修改`,authHeader:`自动添加 Authorization 请求头`,text:`文本`,contextWindow:`上下文`,deleteProviderConfirm:`删除服务商 {id} 及其 {n} 个模型?`,fetchModels:`自动获取模型列表`,fetchModelsHint:`从 baseUrl 的 /models 接口自动拉取模型 ID(服务端请求,不受 CORS 限制)`,fetchingModels:`获取中…`,fetchModelsOk:`已获取 {n} 个模型`,fetchModelsEmpty:`接口未返回任何模型`,fetchModelsNeedBaseUrl:`请先填写 baseUrl 再获取`,enrichModels:`补参数`,enrichModelsHint:`按模型 id 查 OpenRouter / models.dev 目录补上下文、输出上限、识图与推理(只填空,不覆盖手填)`,enrichingModels:`补参中…`,enrichModelsCancel:`取消`,enrichModelsAbort:`中断补参数`,enrichCancelling:`正在取消…`,enrichModelsOk:`已补 {n} 个,未匹配 {m} 个`,enrichModelsErr:`补参数失败:{msg}`,enrichModelsNeedIds:`先填写至少一个模型 ID`,goalBarTitle:`目标`,goalBarPlaceholder:`输入要达成的目标…`,goalBarSet:`发送`,goalBarClear:`取消`,goalBarLocked:`锁定:应用到后续所有回合`,goalBarUnlocked:`仅本回合(改完自动清除)`,goalBarReviewModel:`调研模型`,goalBarUseMainModel:`使用主模型`,goalBarMaxRounds:`最大轮数`,goalBarMaxRoundsTip:`最大执行/重审轮数;0 或不填 = 不限(持续改到通过)`,goalBarUnlimitedShort:`不限`,goalBarExecModel:`执行模型`,goalBarExecModelTip:`执行对话的模型;空 = 跟随当前对话`,goalBarOpenExec:`执行对话`,goalBarOpenExecTip:`打开执行者对话(左栏可随时点开)`,goalBarStaleBackend:`⚠️ 服务端版本较旧(进程未重启):目标模式 2.0 不会生效,请重启 pi-web-ui 服务`,goalBarStop:`停止目标(并停掉执行对话)`,goalBarReviewing:`审查中…`,goalBarExecuting:`执行中…`,goalHistory:`历史`,goalBarRound:`第 {n} 轮`,goalBarPassed:`已通过`,goalBarFailed:`未通过`,goalBarBlocked:`⚠️ 受阻`,goalWizardBtn:`提炼`,goalWizardTip:`让 AI 通过问卷调研细化需求,收敛为目标`,goalWizardRunning:`目标调研中`,goalWizardCard:`目标调研`,settings:`设置`,settingsTitle:`设置`,settingsDesc:`修改立即生效:系统提示词、技能与插件开关会重建当前会话;审查提示词与审查技能只影响后续目标审查(回复进行中则主会话变更自动延迟)。`,settingsSystemPrompt:`系统提示词`,settingsPromptHistory:`输入历史`,settingsPromptHistoryDesc:`用 ↑↓ 在输入框循环历史提问,全局跨对话共享(localStorage)`,promptHistoryMax:`最大条数`,promptHistoryMaxHint:`超过上限时最旧的自动丢弃,可设 1–500`,promptHistoryCharLimit:`限制单条字数`,promptHistoryCharLimitHint:`开启后超长输入截断后保存,避免大段粘贴占满存储`,promptHistoryCharLimitPlaceholder:`最大字数(100–20000)`,promptHistoryClear:`清空历史`,promptHistoryClearConfirm:`确认清空?`,promptHistoryCount:`当前 {n} 条`,promptHistoryEmpty:`暂无历史记录,上/下键暂无可循环内容`,promptModeAppend:`追加`,promptModeReplace:`替换`,promptComposeHint:`模板里的 {{token}} 在每次对话时展开为对应「来源」的提示词;未覆盖的来源用自动内容(工具列表/项目上下文/技能等永远用最新数据生成)。`,promptComposeDesc:`组合模板:{{token}} 自由排序/删改/穿插自己的话;空 = 默认模板。下面每个来源可单独覆盖(留空 = 自动内容),也可逐块恢复默认。`,promptTemplateLabel:`组合模板`,promptSourcesLabel:`各来源(可单独覆盖)`,promptInsertTokens:`插入段落:`,promptResetAll:`恢复默认模板并清空所有覆盖`,promptResetSource:`恢复默认`,promptAutoBadge:`自动`,promptOverridePlaceholder:`输入覆盖内容(留空 = 用自动内容)…`,promptSourceDefaultEmpty:`(该来源当前无自动内容)`,promptReadonlyBadge:`系统自动生成(只读)`,promptReadonlyLockedHint:`该来源由系统自动生成,只读;此覆盖不会被设置面板编辑,服务端仍按原样生效。`,promptReadonlyTitle:`系统自动生成的来源,仅只读展示,不可编辑`,promptSourceDefaultEditHint:`该来源当前的默认(自动)内容 —— 点击可直接输入覆盖文字`,promptSourceExpand:`展开全文`,promptSourceCollapse:`收起`,promptSourceRefLabel:`默认(自动)内容(可对照 / 复制)`,promptSourceSeedButton:`填入默认内容,只改一小部分`,promptSourceSeedTip:`把该来源当前的默认内容复制进覆盖框:只想改一小部分时直接改这里。填入后此来源内容固定,不再随每次对话自动重新生成。`,promptTok_soul:`灵魂提示词`,promptTok_soul_desc:`agent 人物设定(无 SYSTEM.md 时内置默认)`,promptTok_tools:`工具列表`,promptTok_tools_desc:`Available tools(各工具说明,每次自动生成)`,promptTok_guidelines:`行为准则`,promptTok_guidelines_desc:`Guidelines:各工具引导 + 通用规则`,promptTok_pi_docs:`Pi 文档指引`,promptTok_pi_docs_desc:`指向 pi 包文档的提示段`,promptTok_append:`追加段`,promptTok_append_desc:`APPEND_SYSTEM.md 内容;覆盖 = 自定义追加文字`,promptTok_persona:`Windows 约束`,promptTok_persona_desc:`Windows persona(仅 win32;超时/PTY/GBK 注意事项)`,promptTok_terminal:`终端工具引导`,promptTok_terminal_desc:`持久终端使用引导(「终端工具」开时注入)`,promptTok_markers:`标记工具引导`,promptTok_markers_desc:`内置标记工具使用说明(markers 开时注入)`,promptTok_context:`项目上下文`,promptTok_context_desc:`<project_context>:AGENTS.md/CLAUDE.md 收集结果`,promptTok_skills:`技能段`,promptTok_skills_desc:`<available_skills>:可用技能清单`,promptTok_cwd:`工作目录行`,promptTok_cwd_desc:`Current working directory 行`,settingsViewPrompt:`查看当前完整提示词`,settingsViewPromptTokens:`{n} tokens`,settingsViewPromptHint:`当前会话实际生效的完整系统提示词(含自定义追加/替换内容、项目上下文、技能说明与工具引导),只读。`,settingsViewPromptEmpty:`会话尚未就绪,暂无系统提示词。`,settingsViewToolsSchema:`查看工具 schema`,settingsViewToolsSchemaHint:`发给模型的 function-calling 工具定义(name / description / parameters),与系统提示词正文拼成完整初始上下文,只读。`,settingsViewToolsSchemaEmpty:`会话尚未就绪,暂无工具 schema。`,settingsPromptContextTotal:`合计: {n} tokens`,settingsSkills:`技能`,settingsReview:`目标审查`,settingsReviewDesc:`为独立的目标审查会话配置额外提示词和技能;不会改变主会话设置。`,settingsReviewSkills:`审查可用技能`,reviewPromptPlaceholder:`输入审查自定义提示词…(失焦后自动应用)`,goalModeEnabled:`启用目标模式`,goalModeEnabledDesc:`目标条 / 目标调研向导 / 审查循环的总开关(默认开)。关闭后目标条隐藏,无法设置目标、启动调研或触发审查。`,goalModeOffHint:`目标模式已关闭:目标条已隐藏,已有的目标将不再触发审查。`,delegateMode:`审查者模式(自动委派)`,delegateModeDesc:`开启后本对话**只审阅不施工**:你发的每条请求由服务端自动转给一个常驻的落盘执行对话去干活,本对话负责看结果、提要求。写文件/跑命令/再派子代理会被服务端硬闸门拒绝。`,delegateModeOffHint:`审查者模式已关闭:恢复普通对话,本对话可以直接改代码。`,delegateModeBadge:`审查者`,delegateModeBadgeTip:`审查者模式已开:活由常驻执行对话执行(还没派过活)`,delegateModeOpenTip:`打开常驻执行对话,看它干了什么`,settingsVisionBridge:`视觉桥`,settingsVisionBridgeDesc:`当前模型不支持识图时,把图片交给已配置的视觉模型转写为文字证据,再让模型回答`,visionBridgeEnabled:`启用视觉桥`,visionBridgeModel:`转写模型`,visionBridgeAuto:`自动选择(按顺序)`,visionBridgeNoModels:`未找到已配置的视觉模型:在模型配置里添加任意支持图片的模型(如 qwen-vl、GLM-4V、Gemini)即可自动启用`,visionBridgeOffHint:`已关闭:图片将原样发送,纯文本模型可能看不到图片内容`,visionBridgeCurrent:`当前转写模型:{model}`,visionBridgePromptMode:`转写提示词`,settingsMarkers:`标记工具`,settingsMarkersDesc:`让 AI 用 [[todo:...]] / [[notify:...]] / [[conv:rename:...]] 内联标记在正文里改状态,无需工具往返。全局关闭则全部停用;分组开关可细粒度控制。`,markersEnabled:`启用标记工具(全局)`,markersEnabledDesc:`关闭后 AI 不再收到任何标记引导,解析也跳过(所有标记原文原样保留,不执行)。`,markersOffHint:`已全局关闭:所有标记停用,AI 不会写标记,也不会触发任务/重命名等副作用。`,markerGroupTodo:`任务标记 todo`,markerGroupNotify:`提醒标记 notify`,markerGroupRename:`重命名标记 conv/rename`,markerRenameTip:`[[conv:rename:新标题]] 重命名当前对话(标题 ≤80 字;在回复第一条消息末尾根据情况重命名)`,terminalToolsEnabled:`启用持久终端工具`,settingsTerminalToolsDesc:`让 AI 在交互式程序(REPL/vim)、长驻服务、需要持续观察输出或你要求在可见终端操作时,使用内置终端;普通命令仍走一次性 bash 工具`,editSoftEnabled:`启用编辑工具 edit_soft`,editSoftEnabledDesc:`让 AI 用一个独立、不严格要求缩进的编辑工具:当你的 oldText 与文件缩进/空白不一致(如 JS/JSON)时可避免因缩进差异导致编辑失败。命中后按你给出的 newText 原样写入(缩进即最终缩进)。`,editSoftOffHint:`已关闭:AI 无法使用 edit_soft 工具,也不会收到相关使用引导`,settingsQuestionnaire:`问卷提问`,questionnaireEnabled:`允许模型向我提问(问卷)`,questionnaireEnabledDesc:`开启默认值:模型可用 ask_user_question 弹出可回复的问卷/提问对话框(含选项、多选、自定义输入)。关闭后模型将不再弹出问卷,调用也会直接返回已禁用。`,questionnaireOffHint:`已关闭:模型不能再向你弹出问卷/提问对话框`,parallelReminderEnabled:`同项目并行提醒`,parallelReminderEnabledDesc:`同一项目有别的对话正在运行时,新一轮开始前提醒一次(默认开)。提醒同时告诉 AI 评估冲突,拿不准就问你:并行 / 等它跑完 / 只读围观。`,parallelReminderOffHint:`已关闭:并行时不再提醒,AI 也收不到冲突提示`,browserPageEnabledDesc:`让模型操作浏览器里被授权的页面(page-picker 扩展的 browser_page 工具:读内容 / 点击 / 输入 / 滚动 / 跳转,eval 另有单独开关)。需要先在扩展选项页授权目标页面。`,browserPageOffHint:`已关闭:模型不能再点你的页面、也不能在页面里执行脚本`,conversationReadEnabledDesc:`让 AI 按需读取别的对话(含运行中子代理的实时消息与历史转录):只读的小引用,不占 token,需要时才取。`,conversationReadOffHint:`已关闭:AI 无法再读取别的对话内容`,scheduleTaskEnabledDesc:`让 AI 创建定时/延时唤醒(schedule_task 建任务、schedule_list 查看、schedule_cancel 取消):到期自动把指令投回发起对话执行并汇报;默认单次,用完即删。`,scheduleTaskOffHint:`已关闭:AI 无法再建定时任务(已建任务不受影响)`,browserControl:`浏览器操作`,browserControlTip:`让 AI 操作你在浏览器里授权的页面(读内容 / 点按钮 / 填表单 / 滚动),需要 page-picker 扩展;授权与开关都在扩展设置页里。`,browserControlChecking:`正在查询扩展状态…`,browserControlOffline:`还没连上浏览器扩展:装好(或启用)page-picker 扩展,在本页点一次扩展图标绑定地址,然后刷新本页。`,browserControlInstall:`装扩展(两分钟)`,browserControlInstallLead:`扩展不在 Chrome 应用商店,不用去商店搜,按下面四步装:`,browserControlInstallDownload:`下载 page-picker-extension.zip(永远是最新版)`,browserControlInstallStep1:`解压 zip(得到含 manifest.json 的目录)。`,browserControlInstallStep2:`Chrome / Edge 打开 chrome://extensions(Edge 是 edge://extensions),右上角打开「开发者模式」。`,browserControlInstallStep3:`点「加载已解压的扩展程序」,选中第 1 步解压出的目录。`,browserControlInstallStep4:`回到这个 pi-web-ui 页面点一下扩展图标,按提示「设为服务地址」——地址端口不用手填。`,browserControlEmpty:`扩展已就绪,但还没授权任何页面 —— 点下面的「打开扩展设置页」,在那里授权一个页面。`,browserControlDisabled:`「允许 AI 操作页面」总开关是关的 —— 在扩展设置页打开它。`,browserControlPages:`已授权的页面`,browserControlPageOpen:`开着`,browserControlPageClosed:`没打开`,browserControlExamples:`可以这样让它干活`,browserControlExample1:`「把那个页面上的订单读出来,按金额排序」`,browserControlExample2:`「在搜索框输入 张三,点查询,等结果出来告诉我第一条」`,browserControlOpenOptions:`打开扩展设置页`,browserControlRefresh:`刷新状态`,browserControlCite:`引用到对话`,browserControlCiteTip:`把 {name} 作为网页引用放进输入框(不自动发送,你补一句话再发)`,browserControlCiteNote:`点「引用到对话」会把网页引用放进输入框:模型据此知道操作哪个页面,不必再手打网址。`,browserControlCited:`已引用到输入框 —— 补一句话再发`,browserControlCiteFailed:`输入框还没准备好,稍后再试`,browserControlOpenPanel:`打开面板(状态 / 授权管理)`,browserControlSingleTip:`点击把 {name} 引用到对话;右侧 ▾ 打开面板`,browserControlDesktop:`桌面版用不了浏览器操作 —— 不是你装错了`,browserControlDesktopLead:`桌面窗口里没有 Chrome 扩展运行时,page-picker 扩展装不上。用下面的按钮在系统浏览器里打开同一个地址,再按网页版的四步装扩展即可。`,browserControlOpenInBrowser:`用默认浏览器打开当前地址`,attachPage:`网页引用:{name}(AI 已获授权操作这个页面)`,attachPageShort:`网页`,settingsTools:`工具`,toolsSectionCore:`核心工具`,toolsCoreHint:`bash / read / edit / write / powershell 是模型干活的基本盘,不在下方目录开关里。关闭后模型无法执行对应操作:关 bash 不能跑命令,关 read 不能读文件,关 edit / write 不能改文件,关 powershell 不能跑 PowerShell 命令(仅 Windows)。`,toolCoreBashDesc:`执行 shell 命令。关闭后模型不能跑命令、装依赖、跑测试。`,toolCoreReadDesc:`读取文件与目录。关闭后模型只能靠对话里已有的内容干活。`,toolCoreEditDesc:`精确编辑文件。关闭后模型不能局部修改代码。`,toolCoreWriteDesc:`新建或整写文件。关闭后模型不能创建、覆盖文件。`,toolCorePowershellDesc:`执行 PowerShell 命令(仅 Windows 有效)。关闭后模型不能运行 PowerShell 命令。`,toolCoreLsDesc:`列出目录内容。关闭后模型无法调用 ls 列目录(可被 read 目录模式完全替代)。`,toolCoreGrepDesc:`正则搜索文件内容,返回匹配行与行号。关闭后模型不能直接调 grep(可用 bash 命令替代)。`,toolCoreFindDesc:`按 glob 规则搜索文件名与相对路径。关闭后模型不能直接调 find(可用 bash 命令替代)。`,toolsSectionTerminal:`持久终端`,toolsSectionSubagent:`子代理`,toolsSectionOther:`其他工具`,toolsSectionPlugin:`插件工具`,toolsPluginHint:`插件经 registerAgentTool 注册的 AI 工具:关掉即从会话里移除,AI 调不动;重开立即加回,无需 reload。禁掉的条目会保留,插件重装后仍保持关闭。`,pluginToolsSection:`注册的 AI 工具`,pluginToolsEmpty:`已安装的插件都没有注册 AI 工具`,pluginToolOffHint:`已关闭:AI 无法调用该工具(重开立即恢复,无需 reload)`,toolsPresetBanner:`默认预设「{name}」正在过滤工具:新对话有 {count} 个工具开关暂不生效(切回全功能即恢复)`,toolsBackToStandard:`切回全功能`,toolsBlockedByPreset:`当前默认预设「{name}」下不可用,切回「全功能」恢复`,pluginToolsDisabledByPlugin:`所属插件已在「界面插件」中禁用,重新启用插件后恢复`,pluginDisabledInPlugins:`插件已禁用`,skillsHiddenByPreset:`技能名录被默认预设「{name}」隐藏(skill 加载工具不可用时不同步展示),切回全功能恢复`,toolsSubagentDepHint:`子代理统一入口:合并 spawn/wait/get/steer/stop/list/templates/handoff;delegate_task 走 spawn 通道,关闭子代理后 delegate_task 也无法派单。`,delegateTaskEnabledDesc:`把定义清楚的任务派给 specialist 子代理模板:六段派单(TASK/EXPECTED OUTCOME/REQUIRED TOOLS/MUST DO/MUST NOT DO/CONTEXT)在服务端校验,缺段或含糊直接报错打回。执行体复用子代理 spawn 通道。`,delegateTaskOffHint:`已关闭:AI 无法使用 delegate_task 派单(可用 subagent 自由派单,不带六段校验)`,todoListEnabledDesc:`只读查询当前任务列表,删除项需显式传参;写操作不走工具,直接写内联标记。`,todoListOffHint:`已关闭:AI 不能再调查询工具(内联标记的写入不受影响)`,toolDescSubagent:`后台子代理对话管理(左栏可见):统一支持 spawn(派发)、wait_all(等待收口)、get_result(查询结果)、steer(改向追加)、stop(中止)、list(运行态)、templates(模板名录)、handoff(同行协作)。`,toolDescSubagentSpawn:`后台起独立子代理对话(左栏可见),做可独立交付的任务;可并行多个。`,toolDescSubagentGetResult:`取单个子代理的结果或当前进度;未完成返回现状和部分输出。`,toolDescSubagentSteer:`向运行中的子代理注入消息,改向或补充要求。`,toolDescSubagentList:`列出全部子代理的运行态(id/类型/状态/标题)。`,toolDescSubagentStop:`停止运行中的子代理(等同中止它那路对话)。`,toolDescSubagentWaitAll:`一次等多个子代理全部完成并汇总结果,不用轮询。`,toolDescSubagentTemplates:`列出可用的子代理模板(停用的不出现),供 spawn 选用。`,settingsMessageDisplay:`对话`,thinkingWrap:`完整显示思考`,thinkingWrapDesc:`开启:思考内容始终完整展开并自动换行(流式推理过程也实时可见);关闭:折叠成一行摘要,流式中一行实时显示最新文本`,toolsWrap:`完整显示工具`,toolsWrapDesc:`开启:工具调用始终完整展开显示参数和输出;关闭:默认折叠,点击展开`,toolImages:`直接显示工具结果图片`,toolImagesDesc:`开启:截图这类工具结果图片在卡片里直接显示、点击放大;关闭:不显示图片`,toolImageZoom:`点击预览大图`,devNoCache:`开发模式:不缓存页面`,devNoCacheDesc:`开启:每次加载都取最新页面(源码开发用);关闭:允许浏览器缓存(安装包默认)`,autoReload:`新构建自动重载页面`,autoReloadDesc:`开启:服务端重建后页面自动重载(源码开发用);关闭:只重连不断页面(安装包默认)`,wideChat:`宽屏聊天列`,wideChatDesc:`开启:中央列铺满宽度(超宽屏有用);关闭:保持 860px 上限`,projectTitle:`标题显示项目名`,projectTitleDesc:`开启:浏览器标签页标题为「项目目录名 — pi-web-ui」,切项目即时更新(多标签页开多个项目时好区分);关闭:固定显示应用名`,terminalBashTakeover:`终端接管 bash`,terminalBashTakeoverDesc:`此开关决定 bash 是否覆盖为终端版:关 = 原生 SDK bash(纯进程、不开终端);开 = 跑进可见终端,且 persist 参数在本开关的基础上决定一次性(false,命令跑完进程退出、输出留档)还是持久(true,shell 状态跨调用保留、静默自动转后台并通知 AI)`,terminalBashIdleMs:`静默转后台阈值(毫秒)`,terminalBashIdleMsDesc:`持久终端模式下,命令连续无输出达到该时长即不再阻塞等待,转入后台继续运行并通知 AI;0 = 一直等到命令结束(默认 15000)`,terminalBashMaxForegroundMs:`前台最长等待(毫秒)`,terminalBashMaxForegroundMsDesc:`接管模式下,命令在前台执行的总时长达到该值后,无论是否有输出,均自动转入后台继续执行并解阻模型;0 = 不限(默认 60000)`,readDirEnabled:`read 读目录`,readDirEnabledDesc:`开启:read 工具传目录路径时列出目录条目(一行一项、目录带 / 后缀,此时 limit 是条目上限);关闭:目录参数原样交给内置 read(报 EISDIR,看目录得用 bash 的 ls)。DSH 引擎没有该覆盖,仅 pi 引擎生效`,toolWatchdogTimeout:`工具看门狗超时(分钟)`,toolWatchdogTimeoutDesc:`单个工具调用的最长执行时长(默认 20 分钟,0 = 禁用看门狗)。超时自动终止以防挂死;若工具调用显式指定了更长超时(如 bash timeout),看门狗将自动顺延`,toolWatchdogOff:`0 = 禁用`,visionBridgePromptPlaceholder:`输入自定义转写提示词…(留空 = 使用内置默认提示词,失焦后自动应用)`,scmCommitMsgSettingsTitle:`AI 提交信息(源代码管理)`,scmCommitMsgSettingsDesc:`源代码管理面板「AI 生成」按钮的提示词:模型按仓库近期提交的语言与风格,把当前改动提炼成一行提交信息并填入提交输入框`,scmCommitMsgPromptPlaceholder:`输入自定义提示词…(留空 = 使用内置默认提示词,失焦后自动应用)`,scmCommitMsgSettingsHint:`追加模式把自定义内容拼在内置提示词末尾;替换模式完全使用自定义内容(切换后输入框会显示内置默认,可直接修改,不改动失焦则仍使用默认)`,planModePromptSettingsTitle:`计划模式提示词`,planModePromptSettingsDesc:`计划模式(目标条里的「计划」按钮)开启时追加给模型的提示词:只调研 + 出计划,不实施。内置默认含「禁止把实现代码写进回复」「小需求可跳过计划看板走短计划」两条硬规则`,planModePromptMode:`计划模式提示词`,planModePromptPlaceholder:`输入自定义提示词…(留空 = 使用内置默认提示词,失焦后自动应用)`,planModePromptSettingsHint:`追加模式把自定义内容拼在内置提示词末尾;替换模式完全使用自定义内容(切换后输入框会显示内置默认,可直接修改,不改动失焦则仍使用默认)。仅影响提示词,服务端的只读硬闸门始终生效`,uninstallExt:`卸载`,uninstallConfirm:`确认卸载?`,uninstallConfirmHint:`再次点击确认,将在终端执行 pi remove`,uninstallHint:`通过可见终端执行 pi remove 卸载此包,完成后自动刷新列表`,uninstallTitle:`卸载`,pluginUpdate:`更新`,pluginUpdateHint:`从安装来源重新拉取并覆盖安装(保留 config.json 配置);后台执行,设置面板不用关,进度就地显示`,pluginMarket:`插件市场`,updatesManaged:`本实例由部署方管理:更新与插件安装不在此进行`,pluginCatalogAdd:`添加插件`,pluginCatalogAddHint:`把第三方插件填进可安装列表(owner/repo 或完整 GitHub 地址)`,pluginCatalogSource:`来源 owner/repo 或 owner/repo/子目录(必填)`,pluginCatalogId:`id(可选,默认取仓库/子目录名)`,pluginCatalogName:`名称(可选)`,pluginCatalogIcon:`图标 emoji(可选)`,pluginCatalogDesc:`简介(可选)`,pluginCatalogAddSubmit:`添加到列表`,pluginInspectAlreadyInstalled:`已安装同名插件「{id}」—— 用「更新」覆盖,或换个 id`,pluginInspectInvalid:`认不出这个来源 —— 应为 owner/repo、owner/repo/子目录[#ref]、GitHub 链接或 npm 包名`,pluginInspectNotPlugin:`远端没找到 manifest.json —— 这不是 pi-web-ui 插件(或仓库/子目录/分支写错了)`,pluginInspectNetwork:`没能连上远端核对(不影响安装)—— 网络/代理正常时可再试`,noPluginCatalog:`列表为空 —— 点「添加插件」把第三方插件填进列表`,pluginInstalled:`已安装`,pluginCatalogCustom:`自定义`,pluginInstall:`安装`,pluginInstallHint:`后台安装到界面插件(不用关设置面板,进度就地显示)`,pluginCatalogRemoveHint:`从列表移除这条自定义插件`,pluginUninstallHint:`后台卸载此插件(再次点击确认),完成后自动刷新列表`,pluginJobRunning:`后台执行中…`,pluginJobDone:`已完成`,pluginJobFailed:`插件操作失败`,pluginBuildSource:`源码构建`,pluginBuildHint:`安装/更新前先在隔离目录里构建(等价 CLI --build;只有源码没有产物时会自动构建,无需勾选)`,pluginCatalogSync:`从目录同步`,pluginCatalogSyncHint:`从目录文档同步可安装列表(与插件的 reloadCatalog 同一通道)`,pluginCatalogSyncSource:`目录 URL(http(s))或本地绝对路径`,pluginCatalogSyncSubmit:`同步`,pluginCatalogSyncInstall:`同步后安装全部条目`,pluginCatalogSyncReplace:`整体替换(默认按 id 合并)`,pluginCatalogSyncRecent:`最近同步`,pluginCatalogSyncOk:`同步成功:列表共 {n} 条`,pluginCatalogSyncInstalled:`安装结果:{ok} 成功,{fail} 失败`,uiLayoutTitle:`界面布局`,uiLayoutHint:`插件可以调整这里的条目(包括宿主内置入口);你随时能改回来:取消勾选=隐藏,↑/↓ 调顺序,改过的条目会显示「恢复」。隐藏的条目仍能在顶栏溢出菜单里点到。`,uiLayoutDiagTitle:`布局诊断({n} 条)`,uiLayoutDiagHint:`这些条目没有出现在界面上。原因见上;多半是插件的 manifest/注册写错了 slot、kind 或 arrange 目标。改好插件后重扫即可。`,pluginTopbarMore:`更多插件按钮`,pluginMenuTitle:`插件`,pluginMenuPin:`钉到顶栏`,pluginMenuUnpin:`取消钉住`,pluginMenuReorder:`调整插件顺序`,pluginMenuReorderHint:`拖动排序;聚焦后可用上下方向键`,pluginMenuManage:`管理插件`,pluginMenuEmpty:`未安装界面插件(<dataDir>/plugins/)`,pluginMenuNoView:`无独立界面`,uiLayoutTopbar:`顶栏`,uiLayoutRequired:`此入口固定显示,不能隐藏`,uiLayoutTopbarText:`显示按钮文字`,uiLayoutSideDockFloat:`侧边图标悬浮显示`,uiIconEdit:`编辑图标`,uiIconEditTitle:`图标编辑`,uiIconEditHint:`拖动图标即可调整:栏内前后、start/center/end 分段、换到另一个栏;拖进「待放回」即隐藏。`,uiIconEditTray:`待放回`,uiIconEditDropHere:`拖到这里`,uiLayoutTopbarOverflow:`顶栏溢出菜单`,uiLayoutBottombar:`底栏`,uiLayoutComposerLeading:`输入框前置区(上传按钮左侧)`,uiLayoutComposer:`输入框动作`,uiLayoutMessage:`消息工具条`,uiLayoutRightPanel:`右侧面板`,uiLayoutSettingsPages:`设置页`,uiLayoutModal:`弹窗`,uiLayoutContextTopbar:`顶栏右键菜单`,uiLayoutContextMessage:`消息右键菜单`,uiLayoutContextSession:`会话右键菜单`,uiLayoutContextFile:`文件右键菜单`,uiLayoutContextToolcall:`工具卡右键菜单`,uiLayoutLeftSessions:`左栏会话行`,uiLayoutChatHeader:`对话头部条`,uiLayoutChatEmpty:`空对话占位区`,uiLayoutFilePreview:`文件预览工具条`,uiLayoutTerminal:`终端工具条`,uiLayoutScm:`SCM 工具条`,uiLayoutGoalbar:`目标条动作`,uiLayoutNotice:`通知条动作`,uiLayoutSidebarLeft:`左侧悬浮栏`,uiLayoutSidebarRight:`右侧悬浮栏`,uiLayoutPosition:`位置`,uiLayoutPosTop:`顶部`,uiLayoutPosBottom:`底部`,uiLayoutPosLeft:`左侧悬浮`,uiLayoutPosRight:`右侧悬浮`,uiLayoutSearch:`搜索条目…`,uiLayoutMovedFrom:`移自`,uiLayoutAlign:`对齐`,uiLayoutAlignTop:`靠上`,uiLayoutAlignMiddle:`居中`,uiLayoutAlignBottom:`靠下`,uiLayoutRename:`改名`,uiLayoutRestore:`恢复`,uiLayoutRestoreAll:`全部恢复默认`,uiLayoutArranged:`插件调整过`,uiLayoutEmpty:`(无)`,moveToTop:`移到顶部`,moveToBottom:`移到底部`,moveToLeft:`移到左侧悬浮`,moveToRight:`移到右侧悬浮`,sideDockCollapse:`收起悬浮栏`,sideDockExpand:`展开悬浮栏`,pluginGrantsTitle:`已授权目录`,pluginGrantsHint:`插件要访问工作区之外的目录时必须先经你确认(确认过的会记在这里,可随时撤销)。`,pluginGrantsEmpty:`还没有插件获得过工作区外的目录授权`,pluginGrantsRevoke:`撤销`,pluginGrantRequestTitle:`插件请求访问目录`,pluginGrantRequestBody:`{plugin} 想访问下面这个目录:
|
|
158
158
|
|
|
159
159
|
{path}`,pluginGrantAllow:`允许`,pluginGrantDeny:`拒绝`,pluginPermTitle:`插件请求能力授权`,pluginPermBodyNet:`{plugin} 想访问下面这些网络主机(不再改配置重装):
|
|
160
160
|
|
|
@@ -316,7 +316,7 @@ Keep going until the plan holds up.`,"tpl.sk.tdd":`Test-driven`,"tpl.sk.tdd.desc
|
|
|
316
316
|
2. Make them pass with the minimal implementation
|
|
317
317
|
3. Refactor while keeping tests green
|
|
318
318
|
|
|
319
|
-
Avoid three test anti-patterns: tests coupled to the implementation, tautological assertions (always true), and horizontal slicing (surface only). Report after each step and run the tests.`,error:`Error`,done:`Done`,running:`Running…`,toolQueued:`Queued`,copyArgs:`Copy args`,copyMessage:`Copy message`,copied:`Copied`,copyText:`Copy as text`,copyMarkdown:`Copy as Markdown`,copyImage:`Copy as image`,speakMsg:`Read aloud`,stopSpeakingMsg:`Stop reading`,copyFailed:`Copy failed`,saveAsImage:`Save as image`,copyImageBtn:`Copy image`,savingImage:`Saving image…`,imageTitle:`Title`,imageTitlePlaceholder:`Optional, shown at the top of the image`,imageBorder:`Border`,imageWatermark:`Watermark`,imageWatermarkPlaceholder:`Watermark text`,exportSelectHint:`Check messages in the chat to add them to the image (oldest at the top).`,exportTooLong:`Selection is too long. Uncheck some messages and try again.`,exportSelectedCount:`{n} selected`,exportIncludeTools:`Include tool calls`,exportIncludeThinking:`Include thinking`,errorOutput:`Error output`,output:`Output`,waitingOutput:`Waiting for output…`,toolDoneWaitingModel:`Done · waiting on model`,waitingModel:`Waiting for model response…`,thinkingNow:`Thinking`,thinkingPreview:`Thinking: {preview}`,commands:`Commands`,newCommand:`New command`,newTerminal:`New terminal`,name:`Name`,command:`Command`,cwdHint:"(${pwd} = current working directory)",noCommands:`No commands yet — click + to add one`,clickToRun:`Click to run`,edit:`Edit`,delete:`Delete`,confirmQ:`Confirm?`,builtinTerminal:`Built-in terminal`,termEmptySub:`Click a command on the left to run it, or + on the right for a new terminal`,noTerminal:`No terminals`,exited:`(exited{code})`,exitBanner:`[Process exited with code {code}]`,closeTerminal:`Close terminal`,renameTerminal:`Rename terminal`,rerun:`Reload .pi/commands.json`,terminalTitle:`Terminal {n}`,aiBashGroup:`Terminal-backed bash`,exampleName:`e.g. start dev server`,exampleCommand:`e.g. npm run dev`,scmTab:`Git`,scmTitle:`Source Control`,scmRefreshTip:`Re-query git status & diff`,scmCurrentBranch:`Current branch`,scmUpstreamGone:`Upstream deleted`,scmAheadBehind:`↑{ahead} ↓{behind}`,scmDetached:`Detached HEAD`,scmSelectBranch:`Select branch…`,scmRemoteBranches:`Remote branches`,scmStageTip:`Stage {path}`,scmUnstageTip:`Unstage {path}`,scmSwitch:`Switch`,scmSwitchBranch:`Switch branch`,scmSwitchBranchTip:`Runs git checkout {branch} in the terminal`,scmPush:`Push`,scmPushTip:`Runs git push in the terminal`,scmPull:`Pull`,scmPullTip:`Runs git pull in the terminal`,scmCommit:`Commit`,scmCommitTip:`Runs git commit -m "…" in the terminal (commits staged changes only)`,scmCommitAll:`Commit All`,scmCommitAllTip:`Runs git add -A && git commit -m "…" in the terminal (stages all changes incl. untracked and commits)`,scmCommitPlaceholder:`Type a commit message…`,scmGenMsg:`Generate`,scmGenMsgRunning:`Generating…`,scmGenMsgTip:`Generate a commit message with the current model: staged changes when any, otherwise all changes (incl. untracked); style follows this repo's recent commits`,scmGenMsgFail:`Failed to generate a commit message`,scmChanges:`Changes`,scmHistory:`Commit tree`,scmCommitDetail:`Commit details`,scmSelectCommitHint:`Click a commit on the left to view its details`,scmNoHistory:`No commits yet`,scmHistoryFilterPlaceholder:`Filter commits (subject / author / hash)…`,scmHistoryFilterTip:`Space separates keywords (AND); matches subject / author / hash / decorations`,scmHistoryFilterEmpty:`No commits match the filter`,scmCommitHistoryTip:`Press ↑/↓ to recall recent commit messages`,scmNoChanges:`Working tree clean — no changes`,scmNotGitRepo:`Current directory is not a Git repository`,scmLoading:`Querying…`,scmConnecting:`Waiting for connection…`,scmDiff:`Diff`,scmSelectFileHint:`Click a file on the left to view its diff`,scmNoDiff:`(no diff)`,scmStaged:`Staged`,scmUnstaged:`Unstaged`,scmStagedUnstaged:`Staged + unstaged`,scmUntracked:`Untracked`,scmUntrackedNote:`Untracked file — stage it with + to include (or use Commit All)`,scmQueryFailedShort:`Query failed`,pluginCommandFallback:`Plugin command`,scmRunsInTerminal:`Commit / branch switch / push / pull run in the terminal`,scmViewTerminal:`Open terminal`,oauthLogin:`Sign in with {name}`,oauthLogout:`Sign out`,oauthConnected:`Signed in with {name}`,oauthDeviceCode:`Device code`,oauthOpenVerification:`Open verification page`,oauthContinue:`Continue`,configuredBadge:`✓ Configured`,clearKey:`Clear`,clearKeyTitle:`Remove this provider's key stored in auth.json; it returns to unconfigured (env-var sourced keys can't be cleared here)`,clearKeyConfirm:`Clear the stored key for {id}? Its models will leave the list until you configure it again.`,cloneProvider:`Add key`,cloning:`Adding`,savingKey:`Saving`,saveKey:`Save key`,addKey:`Add key`,addKeyPlaceholder:`Paste the key value…`,keyNamePh:`Name (optional, e.g. backup)`,netDisconnected:`Network disconnected — reconnect and retry`,noKeyYet:`No key yet — add one to use this provider`,activateKey:`Set active`,removeKey:`Remove`,removeKeyConfirm:`Remove this key? It must be re-configured to be used again.`,reloadModelsConfig:`Reload config`,reloadModelsHint:`Edited models.json by hand or with a script? Hit “Reload config” below to re-read it from disk — no restart needed.`,refreshBuiltinHint:`Built-in providers (opencode, etc.) list models from pi's official catalog, cached locally for 4h. When pi.dev already lists a new model but the picker doesn't, use this to bypass the cache and fetch latest (~30s).`,refreshBuiltinBusy:`Fetching official catalogs…`,refreshBuiltinOk:`Official catalogs updated, model picker refreshed`,refreshBuiltinFail:`Force-refresh failed, try again later`,appendModel:`Add model`,appendModelOk:`Added, model picker updated`,appendModelFail:`Failed to add`,providerId:`Provider ID`,providerIdHint:`(required, e.g. ollama / my-proxy)`,displayName:`Display name`,displayNamePh:`My proxy`,apiType:`API type`,baseUrlHint:`(OpenAI-compatible endpoint)`,apiKeyHint:`sk-… (optional — uses the auth.json key)`,apiKeySavedHint:`Saved — leave blank to keep unchanged`,authHeader:`Auto-add Authorization header`,text:`Text`,contextWindow:`Context`,deleteProviderConfirm:`Delete provider {id} and its {n} models?`,fetchModels:`Fetch model list`,fetchModelsHint:`Pull model IDs from the baseUrl /models endpoint (server-side, no CORS)`,fetchingModels:`Fetching…`,fetchModelsOk:`Fetched {n} models`,fetchModelsEmpty:`The endpoint returned no models`,fetchModelsNeedBaseUrl:`Enter a baseUrl first`,enrichModels:`Enrich params`,enrichModelsHint:`Look up model ids on OpenRouter / models.dev to fill context, max output, vision and reasoning (blanks only, manual values kept)`,enrichingModels:`Enriching…`,enrichModelsCancel:`Cancel`,enrichModelsAbort:`Abort enrichment`,enrichCancelling:`Cancelling…`,enrichModelsOk:`Enriched {n}, unmatched {m}`,enrichModelsErr:`Enrich failed: {msg}`,enrichModelsNeedIds:`Enter at least one model id`,goalBarTitle:`Goal`,goalBarPlaceholder:`Enter the goal to achieve…`,goalBarSet:`Send`,goalBarClear:`Cancel`,goalBarLocked:`Locked: applies to every later turn`,goalBarUnlocked:`This turn only (cleared afterwards)`,goalBarReviewModel:`Scoping model`,goalBarUseMainModel:`Use the main model`,goalBarMaxRounds:`Max rounds`,goalBarMaxRoundsTip:`Max execution/review rounds; 0 or empty = unlimited (keep revising until it passes)`,goalBarUnlimitedShort:`Unlimited`,goalBarExecModel:`Executor model`,goalBarExecModelTip:`Model for the executor conversation; empty = follow the main conversation`,goalBarOpenExec:`Executor chat`,goalBarOpenExecTip:`Open the executor conversation (also reachable from the left panel)`,goalBarStaleBackend:`⚠️ Stale server build (process not restarted): goal mode 2.0 will not take effect — restart the pi-web-ui service`,goalBarStop:`Stop goal (also stops the executor conversation)`,goalBarReviewing:`Reviewing…`,goalBarExecuting:`Executing…`,goalHistory:`History`,goalBarRound:`Round {n}`,goalBarPassed:`Passed`,goalBarFailed:`Failed`,goalBarBlocked:`⚠️ Blocked`,goalWizardBtn:`Refine`,goalWizardTip:`Let AI refine the requirement into a goal via a Q&A survey`,goalWizardRunning:`Scoping the goal`,goalWizardCard:`Goal survey`,settings:`Settings`,settingsTitle:`Settings`,settingsDesc:`Changes apply immediately: system prompt, skill and extension toggles rebuild the current session; review instructions and review skills affect later goal reviews (main-session changes are deferred while streaming).`,settingsSystemPrompt:`System prompt`,settingsPromptHistory:`Input history`,settingsPromptHistoryDesc:`Cycle previous prompts with ↑/↓ in the input — global across conversations (localStorage)`,promptHistoryMax:`Max entries`,promptHistoryMaxHint:`Oldest entries are dropped when exceeded (1–500)`,promptHistoryCharLimit:`Limit characters per entry`,promptHistoryCharLimitHint:`When enabled, overlong prompts are truncated before saving`,promptHistoryCharLimitPlaceholder:`Max chars (100–20000)`,promptHistoryClear:`Clear history`,promptHistoryClearConfirm:`Confirm clear?`,promptHistoryCount:`{n} entries`,promptHistoryEmpty:`No history yet — ↑/↓ has nothing to cycle`,promptModeAppend:`Append`,promptModeReplace:`Replace`,promptComposeHint:`Each {{token}} in the template expands to that source's prompt on every run; non-overridden sources use auto content (tools list / project context / skills are always regenerated from the latest data).`,promptComposeDesc:`Compose: reorder / drop / annotate {{token}} blocks freely; empty = the default template. Each source below can be overridden individually (leave empty = auto content) and reset back to default.`,promptTemplateLabel:`Compose template`,promptSourcesLabel:`Sources (override individually)`,promptInsertTokens:`Insert block: `,promptResetAll:`Restore default template and clear all overrides`,promptResetSource:`Restore default`,promptAutoBadge:`auto`,promptOverridePlaceholder:`Override text (leave empty = auto content)…`,promptSourceDefaultEmpty:`(no auto content for this source right now)`,promptReadonlyBadge:`System-generated (read-only)`,promptReadonlyLockedHint:`This source is system-generated and read-only; the override won't be edited here, but the server still applies it as-is.`,promptReadonlyTitle:`System-generated source — read-only display, not editable`,promptSourceDefaultEditHint:`This source's current default (auto) content — click to type an override`,promptSourceExpand:`Show more`,promptSourceCollapse:`Show less`,promptSourceRefLabel:`Default (auto) content — for reference / copying`,promptSourceSeedButton:`Load default text to tweak`,promptSourceSeedTip:`Copies this source's current default text into the override box so you can tweak just a part. Once filled, this source stays fixed and is no longer auto-regenerated each run.`,promptTok_soul:`Soul / persona`,promptTok_soul_desc:`the agent persona (built-in default unless a SYSTEM.md exists)`,promptTok_tools:`Tools list`,promptTok_tools_desc:`Available tools with snippets, regenerated each run`,promptTok_guidelines:`Guidelines`,promptTok_guidelines_desc:`per-tool guidance + generic rules`,promptTok_pi_docs:`Pi docs pointer`,promptTok_pi_docs_desc:`the block pointing at the pi package docs`,promptTok_append:`Append block`,promptTok_append_desc:`APPEND_SYSTEM.md content; override = custom appended text`,promptTok_persona:`Windows persona`,promptTok_persona_desc:`win32-only safety rules (timeout / PTY / GBK)`,promptTok_terminal:`Terminal guidance`,promptTok_terminal_desc:`persistent-terminal usage guide (injected when terminal tools are on)`,promptTok_markers:`Markers guidance`,promptTok_markers_desc:`built-in marker tools usage (injected when markers are on)`,promptTok_context:`Project context`,promptTok_context_desc:`<project_context>: AGENTS.md / CLAUDE.md collection`,promptTok_skills:`Skills`,promptTok_skills_desc:`<available_skills> list of usable skills`,promptTok_cwd:`Working dir line`,promptTok_cwd_desc:`the Current working directory line`,settingsViewPrompt:`View the current full prompt`,settingsViewPromptTokens:`{n} tokens`,settingsViewPromptHint:`The full system prompt actually in effect for this conversation (custom append/replace text, project context, skills and tool guidance). Read-only.`,settingsViewPromptEmpty:`Session not ready yet — no system prompt available.`,settingsViewToolsSchema:`View tools schema`,settingsViewToolsSchemaHint:`The function-calling tool definitions sent to the model (name / description / parameters), combining with the system prompt text to form the full initial context. Read-only.`,settingsViewToolsSchemaEmpty:`Session not ready yet — no tools schema available.`,settingsPromptContextTotal:`Total: {n} tokens`,settingsSkills:`Skills`,settingsReview:`Goal review`,settingsReviewDesc:`Configure extra instructions and skills for the isolated goal-review session; the main session is unaffected.`,settingsReviewSkills:`Skills available to review`,reviewPromptPlaceholder:`Type custom review instructions… (applied on blur)`,goalModeEnabled:`Enable goal mode`,goalModeEnabledDesc:`Master switch for the goal bar, the goal wizard and the review loop (on by default). When off, the goal bar is hidden and you cannot set a goal, run the wizard, or trigger reviews.`,goalModeOffHint:`Goal mode is off: the goal bar is hidden and existing goals no longer trigger reviews.`,delegateMode:`Reviewer mode (auto-delegate)`,delegateModeDesc:`When on, this conversation reviews instead of building: the server forwards every request you send to one persistent executor conversation that does the work, and this conversation inspects the result and states follow-ups. Writing files, running commands and dispatching more subagents are blocked by a server-side gate.`,delegateModeOffHint:`Reviewer mode is off: back to a normal conversation — this one can change code again.`,delegateModeBadge:`Reviewer`,delegateModeBadgeTip:`Reviewer mode is on: work runs in the persistent executor conversation (nothing dispatched yet)`,delegateModeOpenTip:`Open the persistent executor conversation to see what it did`,settingsVisionBridge:`Vision bridge`,settingsVisionBridgeDesc:`When the current model can't see images, send them to a configured vision model and transcribe into text evidence first`,visionBridgeEnabled:`Enable vision bridge`,visionBridgeModel:`Transcription model`,visionBridgeAuto:`Auto (in order)`,visionBridgeNoModels:`No configured vision model found: add any image-capable model (e.g. qwen-vl, GLM-4V, Gemini) in Model config to enable automatically`,visionBridgeOffHint:`Disabled: images are sent as-is, a text-only model may not see them`,visionBridgeCurrent:`Current transcription model: {model}`,visionBridgePromptMode:`Transcription prompt`,settingsMarkers:`Markers`,settingsMarkersDesc:`Let the AI write [[todo:...]] / [[notify:...]] / [[conv:rename:...]] inline markers in replies to update state without a tool round-trip. Global off disables all; per-marker toggles give fine control.`,markersEnabled:`Markers enabled (global)`,markersEnabledDesc:`Off = no marker guidance injected and no parsing; markers stay as plain text.`,markersOffHint:`Globally off: all markers disabled — the AI won't write markers and no side effects fire.`,markerGroupTodo:`todo — tasks`,markerGroupNotify:`notify — non-blocking hints`,markerGroupRename:`conv/rename — rename chat`,markerRenameTip:`[[conv:rename:Title]] renames the current conversation (≤80 chars; rename at the end of the first reply)`,terminalToolsEnabled:`Enable persistent terminal tools`,settingsTerminalToolsDesc:`Let the AI use the built-in terminal for interactive programs (REPLs/vim), long-running servers, continuous output watching, or when you ask it to work in the visible terminal; ordinary commands still go through the one-shot bash tool`,editSoftEnabled:`Enable edit_soft tool`,editSoftEnabledDesc:`Let the AI use a separate indentation-insensitive edit tool: avoids edit failures when your oldText spacing differs from the file (e.g. JS/JSON). On a match, newText is written verbatim as you provide it (its indentation is final).`,editSoftOffHint:`Disabled: the AI has no edit_soft tool and receives no usage guidance`,settingsQuestionnaire:`Questionnaire`,questionnaireEnabled:`Allow the model to ask me questions`,questionnaireEnabledDesc:`On by default: the model may use ask_user_question to pop up an answerable question dialog (options, multi-select, custom input). Off: the model no longer pops up questionnaires; a call also returns disabled immediately.`,questionnaireOffHint:`Disabled: the model can no longer pop up question dialogs`,parallelReminderEnabled:`Parallel-work reminder in the same project`,parallelReminderEnabledDesc:`When another conversation is running in the same project, remind once before a new turn starts (on by default). The reminder also tells the AI to assess conflicts and ask you when unsure: continue in parallel / wait / watch read-only.`,parallelReminderOffHint:`Disabled: no parallel-work reminders; the AI gets no conflict hint either`,browserPageEnabledDesc:`Let the model act on pages you granted in the page-picker extension (browser_page tool: read / click / type / scroll / goto; eval has its own switch). Grant the target page in the extension options first.`,browserPageOffHint:`Disabled: the model can no longer click your pages or run scripts in them`,conversationReadEnabledDesc:`Let the AI read other conversations on demand (live messages from running subagents plus history transcripts): small read-only references, no tokens until fetched.`,conversationReadOffHint:`Disabled: the AI can no longer read other conversations`,scheduleTaskEnabledDesc:`Let the AI create scheduled/delayed wake-ups (schedule_task creates, schedule_list lists, schedule_cancel cancels): on fire the prompt is delivered back into the originating conversation to run and report; one-shot by default, auto-deleted after firing.`,scheduleTaskOffHint:`Disabled: the AI can no longer create scheduled tasks (existing tasks keep running)`,browserControl:`Browser control`,browserControlTip:`Let the AI act on pages you grant in your browser (read / click / type / scroll). Needs the page-picker extension — granting and the switches live in its options page.`,browserControlChecking:`Checking the extension status…`,browserControlOffline:`No browser extension yet: install (or enable) page-picker, click its icon on this page once to bind the address, then reload this page.`,browserControlInstall:`Install the extension (2 minutes)`,browserControlInstallLead:`The extension is not on the Chrome Web Store — no need to search there, follow these four steps:`,browserControlInstallDownload:`Download page-picker-extension.zip (always the latest)`,browserControlInstallStep1:`Unzip it (you get a folder containing manifest.json).`,browserControlInstallStep2:`In Chrome / Edge open chrome://extensions (Edge uses edge://extensions) and switch on “Developer mode” (top right).`,browserControlInstallStep3:`Click “Load unpacked” and pick the folder from step 1.`,browserControlInstallStep4:`Back on this pi-web-ui page, click the extension icon once and choose “Set as service address” — no typing addresses or ports.`,browserControlEmpty:`The extension is ready, but no page is granted yet — open its options page below and grant one.`,browserControlDisabled:`The “allow AI to control pages” master switch is off — turn it on in the extension options.`,browserControlPages:`Granted pages`,browserControlPageOpen:`open`,browserControlPageClosed:`not open`,browserControlExamples:`You can ask for things like`,browserControlExample1:`"Read the orders on that page and sort them by amount"`,browserControlExample2:`"Type John Doe in the search box, click search, and tell me the first result"`,browserControlOpenOptions:`Open extension options`,browserControlRefresh:`Refresh status`,browserControlCite:`Mention in chat`,browserControlCiteTip:`Add {name} to the input as a page reference (you still write the instruction before sending)`,browserControlCiteNote:`“Mention in chat” puts a page reference into the input — the model then knows which page to act on, no typing URLs.`,browserControlCited:`Added to the input — write a line and send`,browserControlCiteFailed:`The input is not ready yet, try again in a moment`,browserControlOpenPanel:`Open panel (status / grants)`,browserControlSingleTip:`Click to mention {name} in the chat; the ▾ on the right opens the panel`,browserControlDesktop:`Browser control isn't available in the desktop app — nothing you did wrong`,browserControlDesktopLead:`The desktop window has no Chrome extension runtime, so the page-picker extension can't be installed there. Open this same address in your system browser with the button below, then follow the four web steps to install the extension.`,browserControlOpenInBrowser:`Open this address in the default browser`,attachPage:`Page reference: {name} (the AI is granted access to this page)`,attachPageShort:`page`,settingsTools:`Tools`,toolsSectionCore:`Core tools`,toolsCoreHint:`bash / read / edit / write / powershell are the model's basic toolkit and are not part of the catalog toggles below. Turning one off removes that ability: no bash = no command execution, no read = no file reading, no edit / write = no file modification, no powershell = no PowerShell command execution (Windows only).`,toolCoreBashDesc:`Run shell commands. When off, the model cannot execute commands, install dependencies, or run tests.`,toolCoreReadDesc:`Read files and directories. When off, the model can only work with content already in the conversation.`,toolCoreEditDesc:`Make precise file edits. When off, the model cannot modify code in place.`,toolCoreWriteDesc:`Create or overwrite files. When off, the model cannot create or overwrite files.`,toolCorePowershellDesc:`Run PowerShell commands (Windows only). When off, the model cannot execute PowerShell commands.`,toolCoreLsDesc:`List directory contents. When off, the model cannot call ls (fully substituted by read directory mode).`,toolCoreGrepDesc:`Search file contents by regex. When off, the model cannot call grep (substitutable by bash commands).`,toolCoreFindDesc:`Search files by glob pattern. When off, the model cannot call find (substitutable by bash commands).`,toolsSectionTerminal:`Persistent terminal`,toolsSectionSubagent:`Subagents`,toolsSectionOther:`Other tools`,toolsSectionPlugin:`Plugin tools`,toolsPluginHint:`AI tools registered by plugins via registerAgentTool: turning one off removes it from sessions so the AI cannot call it; re-enabling adds it back with no reload. Disabled entries are kept, so reinstalling the plugin stays off.`,pluginToolsSection:`Registered AI tools`,pluginToolsEmpty:`None of the installed plugins register AI tools`,pluginToolOffHint:`Disabled: the AI cannot call this tool (re-enable to restore immediately, no reload)`,toolsPresetBanner:`Default preset “{name}” is filtering tools: {count} tool switches have no effect on new conversations until you switch back to full features`,toolsBackToStandard:`Back to full features`,toolsBlockedByPreset:`Unavailable under default preset “{name}”; switch back to full features to restore`,pluginToolsDisabledByPlugin:`Disabled because the owning plugin is disabled in “Plugins”; re-enable the plugin to restore`,pluginDisabledInPlugins:`Plugin disabled`,skillsHiddenByPreset:`Skill catalog hidden by default preset “{name}” (not shown while the skill loader is unavailable); switch back to full features to restore`,toolsSubagentDepHint:`Unified subagent entrypoint combining spawn/wait/get/steer/stop/list/templates/handoff; delegate_task rides the spawn channel, so it cannot dispatch if subagents are disabled.`,delegateTaskEnabledDesc:`Delegate a well-defined task to a specialist subagent template: the six-section brief (TASK/EXPECTED OUTCOME/REQUIRED TOOLS/MUST DO/MUST NOT DO/CONTEXT) is validated server-side; missing or vague sections are rejected. Runs on the subagent spawn channel.`,delegateTaskOffHint:`Disabled: the AI cannot delegate via delegate_task (free-form delegation via subagent still works, without six-section validation)`,todoListEnabledDesc:`Read-only query of the current task list (deleted items need an explicit flag); writes never go through tools — use inline markers.`,todoListOffHint:`Disabled: the AI can no longer call the query tool (inline-marker writes are unaffected)`,toolDescSubagent:`Background subagent management (visible in the left panel): unifies spawn (dispatch), wait_all (collect), get_result (inspect), steer (redirect), stop (abort), list (status), templates (catalog), and handoff (peer collaboration).`,toolDescSubagentSpawn:`Spawn an independent background subagent conversation (visible on the left) for a self-contained task; several may run in parallel.`,toolDescSubagentGetResult:`Fetch one subagent's result or current progress; unfinished ones return status plus partial output.`,toolDescSubagentSteer:`Inject a message into a running subagent to redirect or supplement its work.`,toolDescSubagentList:`List all subagents with live status (id/type/state/title).`,toolDescSubagentStop:`Stop a running subagent (same as aborting its conversation).`,toolDescSubagentWaitAll:`Wait for multiple subagents at once and collect results — no polling.`,toolDescSubagentTemplates:`List available subagent templates (disabled ones hidden) for spawn to use.`,settingsMessageDisplay:`Conversation`,thinkingWrap:`Show full thinking`,thinkingWrapDesc:`On: thinking always expands fully and wraps (live reasoning visible while streaming); Off: collapses to a one-line summary with the latest text shown live while streaming`,toolsWrap:`Show full tools`,toolsWrapDesc:`On: tool calls always expand fully showing arguments and output; Off: collapsed by default, click to expand`,toolImages:`Show tool result images inline`,toolImagesDesc:`On: image tool results (e.g. screenshots) render in the card, click to zoom; Off: images are hidden`,toolImageZoom:`Click to preview`,devNoCache:`Dev mode: no page cache`,devNoCacheDesc:`On: always fetch a fresh page (for source development); Off: allow browser caching (install default)`,autoReload:`Auto-reload on new build`,autoReloadDesc:`On: page reloads itself after a server rebuild (for source development); Off: reconnect only (install default)`,wideChat:`Wide chat column`,wideChatDesc:`On: the center column fills the width (useful on ultrawide monitors); Off: keep the 860px cap`,projectTitle:`Show project name in title`,projectTitleDesc:`On: the browser tab title becomes “<project folder> — pi-web-ui” and updates when you switch projects (handy with several tabs open); Off: always show the app name`,terminalBashTakeover:`Terminal-backed bash`,terminalBashTakeoverDesc:`This switch decides whether bash is overridden to a terminal version: OFF = native SDK bash (process spawn, no terminal); ON = runs in a visible terminal, where the persist parameter decides (on top of the switch) one-shot (false — process exits when the command finishes, output retained) vs persistent (true — shell state retained across calls, silent commands move to the background and notify the AI)`,terminalBashIdleMs:`Silence-to-background threshold (ms)`,terminalBashIdleMsDesc:`In persistent-terminal mode, when a command produces no output for this long, stop blocking and let it keep running in the background; the AI is notified when it finishes. 0 = always wait until completion (default 15000)`,terminalBashMaxForegroundMs:`Max foreground wait (ms)`,terminalBashMaxForegroundMsDesc:`In terminal-takeover mode, when a command's total foreground runtime reaches this threshold, it is automatically moved to the background regardless of output activity, unblocking the model. 0 = unlimited (default 60000)`,readDirEnabled:`read a directory`,readDirEnabledDesc:`On: passing a directory path to read lists its entries (one per line, directories end with '/'; limit then caps the entry count); Off: a directory path goes to the built-in read unchanged (EISDIR — use bash ls to browse). DSH engine has no such override; pi engine only`,toolWatchdogTimeout:`Tool watchdog timeout (min)`,toolWatchdogTimeoutDesc:`Max execution time for a single tool call (default 20 min, 0 = disable). Auto-aborts to prevent hangs; if a tool call explicitly specifies a longer timeout (e.g. bash timeout), the watchdog extends automatically`,toolWatchdogOff:`0 = disable`,visionBridgePromptPlaceholder:`Type a custom transcription prompt… (empty = built-in default, applied on blur)`,scmCommitMsgSettingsTitle:`AI commit message (source control)`,scmCommitMsgSettingsDesc:`Prompt for the source-control panel's Generate button: the model distills the current changes into a one-line commit message, following this repo's recent commit language and style, and fills it into the commit input`,scmCommitMsgPromptPlaceholder:`Type a custom prompt… (empty = built-in default prompt, applied on blur)`,scmCommitMsgSettingsHint:`Append mode adds custom text after the built-in prompt; replace mode uses the custom text entirely (after switching, the editor shows the built-in default ready to edit — blurring without changes keeps the default)`,planModePromptSettingsTitle:`Plan mode prompt`,planModePromptSettingsDesc:`Prompt appended to the model while plan mode is on (the Plan button in the goal bar): research and plan only, no implementation. The built-in default carries two hard rules — never paste the implementation into the reply, and skip the plan board for small unambiguous requests`,planModePromptMode:`Plan mode prompt`,planModePromptPlaceholder:`Type a custom prompt… (empty = built-in default prompt, applied on blur)`,planModePromptSettingsHint:`Append mode adds custom text after the built-in prompt; replace mode uses the custom text entirely (after switching, the editor shows the built-in default ready to edit — blurring without changes keeps the default). Prompt only — the server-side read-only gate always applies`,uninstallExt:`Uninstall`,uninstallConfirm:`Confirm?`,uninstallConfirmHint:`Click again to confirm — runs pi remove in the terminal`,uninstallHint:`Runs pi remove in a visible terminal, then refreshes the list automatically`,uninstallTitle:`Uninstall`,pluginUpdate:`Update`,pluginUpdateHint:`Re-installs from the recorded source (--force, keeps config.json); runs in the background with in-place progress`,pluginMarket:`Plugin marketplace`,updatesManaged:`Managed instance: updates and plugin installs are handled by whoever deploys it`,pluginCatalogAdd:`Add plugin`,pluginCatalogAddHint:`Drop a third-party plugin into the installable list (owner/repo or full GitHub URL)`,pluginCatalogSource:`Source owner/repo or owner/repo/subdir (required)`,pluginCatalogId:`id (optional, defaults to repo/subdir name)`,pluginCatalogName:`Name (optional)`,pluginCatalogIcon:`Icon emoji (optional)`,pluginCatalogDesc:`Description (optional)`,pluginCatalogAddSubmit:`Add to list`,pluginInspectAlreadyInstalled:`A plugin named "{id}" is already installed — use Update to replace it, or pick another id`,pluginInspectInvalid:`Unrecognized source — expected owner/repo, owner/repo/subdir[#ref], a GitHub URL, or an npm package name`,pluginInspectNotPlugin:`No manifest.json at the remote source — not a pi-web-ui plugin (or the repo/subdir/ref is wrong)`,pluginInspectNetwork:`Could not reach the remote to verify (install still works) — retry when the network/proxy is fine`,noPluginCatalog:`List is empty — click "Add plugin" to drop a third-party plugin in`,pluginInstalled:`Installed`,pluginCatalogCustom:`custom`,pluginInstall:`Install`,pluginInstallHint:`Installs into UI plugins in the background (settings stay open, progress shown in place)`,pluginCatalogRemoveHint:`Remove this custom plugin from the list`,pluginUninstallHint:`Uninstalls this plugin in the background (click again to confirm), then refreshes the list`,pluginJobRunning:`Running…`,pluginJobDone:`Done`,pluginJobFailed:`Plugin operation failed`,pluginBuildSource:`Build from source`,pluginBuildHint:`Build in an isolated directory before install/update (same as CLI --build; source-only plugins without artifacts are built automatically even when unchecked)`,pluginCatalogSync:`Sync from catalog`,pluginCatalogSyncHint:`Sync the installable list from a catalog document (same channel as plugin reloadCatalog)`,pluginCatalogSyncSource:`Catalog URL (http(s)) or absolute local path`,pluginCatalogSyncSubmit:`Sync`,pluginCatalogSyncInstall:`Install all entries after sync`,pluginCatalogSyncReplace:`Replace wholesale (default merges by id)`,pluginCatalogSyncRecent:`Recent`,pluginCatalogSyncOk:`Catalog synced: {n} entries in the list`,pluginCatalogSyncInstalled:`Install results: {ok} succeeded, {fail} failed`,uiLayoutTitle:`Interface layout`,uiLayoutHint:`Plugins can rearrange these entries (built-in ones included). You can always change them back: uncheck to hide, ↑/↓ to reorder; changed rows offer “Restore”. Hidden entries stay reachable from the top-bar overflow menu.`,uiLayoutDiagTitle:`Layout diagnostics ({n})`,uiLayoutDiagHint:`These entries never made it to the UI. The reason is listed above — usually a plugin manifest/registration with a wrong slot, kind or arrange target. Fix the plugin and rescan.`,pluginTopbarMore:`More plugin buttons`,pluginMenuTitle:`Plugins`,pluginMenuPin:`Pin to top bar`,pluginMenuUnpin:`Unpin from top bar`,pluginMenuReorder:`Reorder plugin`,pluginMenuReorderHint:`Drag to reorder, or use Up and Down arrow keys`,pluginMenuManage:`Manage plugins`,pluginMenuEmpty:`No UI plugins installed (<dataDir>/plugins/)`,pluginMenuNoView:`No standalone view`,uiLayoutTopbar:`Top bar`,uiLayoutRequired:`This item is always visible and cannot be hidden`,uiLayoutTopbarText:`Show button labels`,uiLayoutSideDockFloat:`Float side icons`,uiIconEdit:`Edit icons`,uiIconEditTitle:`Icon editor`,uiIconEditHint:`Drag an icon to reorder it, move it to another section (start/center/end) or another bar; drop it on "Hidden" to hide it.`,uiIconEditTray:`Hidden`,uiIconEditDropHere:`Drop here`,uiLayoutTopbarOverflow:`Top-bar overflow`,uiLayoutBottombar:`Bottom bar`,uiLayoutComposerLeading:`Composer leading (left of upload)`,uiLayoutComposer:`Composer actions`,uiLayoutMessage:`Message actions`,uiLayoutRightPanel:`Right panel`,uiLayoutSettingsPages:`Settings pages`,uiLayoutModal:`Modal`,uiLayoutContextTopbar:`Top-bar context menu`,uiLayoutContextMessage:`Message context menu`,uiLayoutContextSession:`Session context menu`,uiLayoutContextFile:`File context menu`,uiLayoutContextToolcall:`Tool-card context menu`,uiLayoutLeftSessions:`Left-panel session rows`,uiLayoutChatHeader:`Chat header`,uiLayoutChatEmpty:`Empty chat`,uiLayoutFilePreview:`File preview toolbar`,uiLayoutTerminal:`Terminal toolbar`,uiLayoutScm:`SCM toolbar`,uiLayoutGoalbar:`Goal-bar actions`,uiLayoutNotice:`Notice actions`,uiLayoutSidebarLeft:`Left floating dock`,uiLayoutSidebarRight:`Right floating dock`,uiLayoutPosition:`Position`,uiLayoutPosTop:`Top`,uiLayoutPosBottom:`Bottom`,uiLayoutPosLeft:`Left dock`,uiLayoutPosRight:`Right dock`,uiLayoutSearch:`Filter entries…`,uiLayoutMovedFrom:`moved from`,uiLayoutAlign:`Align`,uiLayoutRename:`Rename`,uiLayoutRestore:`Restore`,uiLayoutRestoreAll:`Restore all`,uiLayoutArranged:`Changed by a plugin`,uiLayoutEmpty:`(none)`,moveToTop:`Move to top`,moveToBottom:`Move to bottom`,moveToLeft:`Move to left dock`,moveToRight:`Move to right dock`,sideDockCollapse:`Collapse dock`,sideDockExpand:`Expand dock`,pluginGrantsTitle:`Granted directories`,pluginGrantsHint:`Plugins must ask before touching directories outside the workspace. Approved ones are listed here and can be revoked at any time.`,pluginGrantsEmpty:`No plugin has been granted a directory outside the workspace yet`,pluginGrantsRevoke:`Revoke`,pluginGrantRequestTitle:`A plugin wants to access a directory`,pluginGrantRequestBody:`{plugin} wants to access this directory:
|
|
319
|
+
Avoid three test anti-patterns: tests coupled to the implementation, tautological assertions (always true), and horizontal slicing (surface only). Report after each step and run the tests.`,error:`Error`,done:`Done`,running:`Running…`,toolQueued:`Queued`,copyArgs:`Copy args`,copyMessage:`Copy message`,copied:`Copied`,copyText:`Copy as text`,copyMarkdown:`Copy as Markdown`,copyImage:`Copy as image`,speakMsg:`Read aloud`,stopSpeakingMsg:`Stop reading`,copyFailed:`Copy failed`,saveAsImage:`Save as image`,copyImageBtn:`Copy image`,savingImage:`Saving image…`,imageTitle:`Title`,imageTitlePlaceholder:`Optional, shown at the top of the image`,imageBorder:`Border`,imageWatermark:`Watermark`,imageWatermarkPlaceholder:`Watermark text`,exportSelectHint:`Check messages in the chat to add them to the image (oldest at the top).`,exportTooLong:`Selection is too long. Uncheck some messages and try again.`,exportSelectedCount:`{n} selected`,exportIncludeTools:`Include tool calls`,exportIncludeThinking:`Include thinking`,errorOutput:`Error output`,output:`Output`,waitingOutput:`Waiting for output…`,toolDoneWaitingModel:`Done · waiting on model`,waitingModel:`Waiting for model response…`,thinkingNow:`Thinking`,thinkingPreview:`Thinking: {preview}`,commands:`Commands`,newCommand:`New command`,newTerminal:`New terminal`,name:`Name`,command:`Command`,cwdHint:"(${pwd} = current working directory)",noCommands:`No commands yet — click + to add one`,clickToRun:`Click to run`,edit:`Edit`,delete:`Delete`,confirmQ:`Confirm?`,builtinTerminal:`Built-in terminal`,termEmptySub:`Click a command on the left to run it, or + on the right for a new terminal`,noTerminal:`No terminals`,exited:`(exited{code})`,exitBanner:`[Process exited with code {code}]`,closeTerminal:`Close terminal`,renameTerminal:`Rename terminal`,rerun:`Reload .pi/commands.json`,terminalTitle:`Terminal {n}`,aiBashGroup:`Terminal-backed bash`,exampleName:`e.g. start dev server`,exampleCommand:`e.g. npm run dev`,scmTab:`Git`,scmTitle:`Source Control`,scmRefreshTip:`Re-query git status & diff`,scmCurrentBranch:`Current branch`,scmUpstreamGone:`Upstream deleted`,scmAheadBehind:`↑{ahead} ↓{behind}`,scmDetached:`Detached HEAD`,scmSelectBranch:`Select branch…`,scmRemoteBranches:`Remote branches`,scmStageTip:`Stage {path}`,scmUnstageTip:`Unstage {path}`,scmSwitch:`Switch`,scmSwitchBranch:`Switch branch`,scmSwitchBranchTip:`Runs git checkout {branch} in the terminal`,scmPush:`Push`,scmPushTip:`Runs git push in the terminal`,scmPull:`Pull`,scmPullTip:`Runs git pull in the terminal`,scmCommit:`Commit`,scmCommitTip:`Runs git commit -m "…" in the terminal (commits staged changes only)`,scmCommitAll:`Commit All`,scmCommitAllTip:`Runs git add -A && git commit -m "…" in the terminal (stages all changes incl. untracked and commits)`,scmCommitPlaceholder:`Type a commit message…`,scmGenMsg:`Generate`,scmGenMsgRunning:`Generating…`,scmGenMsgTip:`Generate a commit message with the current model: staged changes when any, otherwise all changes (incl. untracked); style follows this repo's recent commits`,scmGenMsgFail:`Failed to generate a commit message`,scmChanges:`Changes`,scmHistory:`Commit tree`,scmCommitDetail:`Commit details`,scmSelectCommitHint:`Click a commit on the left to view its details`,scmNoHistory:`No commits yet`,scmHistoryFilterPlaceholder:`Filter commits (subject / author / hash)…`,scmHistoryFilterTip:`Space separates keywords (AND); matches subject / author / hash / decorations`,scmHistoryFilterEmpty:`No commits match the filter`,scmCommitHistoryTip:`Press ↑/↓ to recall recent commit messages`,scmNoChanges:`Working tree clean — no changes`,scmNotGitRepo:`Current directory is not a Git repository`,scmLoading:`Querying…`,scmConnecting:`Waiting for connection…`,scmDiff:`Diff`,scmSelectFileHint:`Click a file on the left to view its diff`,scmNoDiff:`(no diff)`,scmStaged:`Staged`,scmUnstaged:`Unstaged`,scmStagedUnstaged:`Staged + unstaged`,scmUntracked:`Untracked`,scmUntrackedNote:`Untracked file — stage it with + to include (or use Commit All)`,scmQueryFailedShort:`Query failed`,pluginCommandFallback:`Plugin command`,scmRunsInTerminal:`Commit / branch switch / push / pull run in the terminal`,scmViewTerminal:`Open terminal`,oauthLogin:`Sign in with {name}`,oauthLogout:`Sign out`,oauthConnected:`Signed in with {name}`,oauthDeviceCode:`Device code`,oauthOpenVerification:`Open verification page`,oauthContinue:`Continue`,configuredBadge:`✓ Configured`,clearKey:`Clear`,clearKeyTitle:`Remove this provider's key stored in auth.json; it returns to unconfigured (env-var sourced keys can't be cleared here)`,clearKeyConfirm:`Clear the stored key for {id}? Its models will leave the list until you configure it again.`,cloneProvider:`Add key`,cloning:`Adding`,savingKey:`Saving`,saveKey:`Save key`,addKey:`Add key`,addKeyPlaceholder:`Paste the key value…`,keyNamePh:`Name (optional, e.g. backup)`,netDisconnected:`Network disconnected — reconnect and retry`,noKeyYet:`No key yet — add one to use this provider`,activateKey:`Set active`,removeKey:`Remove`,removeKeyConfirm:`Remove this key? It must be re-configured to be used again.`,reloadModelsConfig:`Reload config`,reloadModelsHint:`Edited models.json by hand or with a script? Hit “Reload config” below to re-read it from disk — no restart needed.`,refreshBuiltinHint:`Built-in providers (opencode, etc.) list models from pi's official catalog, cached locally for 4h. When pi.dev already lists a new model but the picker doesn't, use this to bypass the cache and fetch latest (~30s).`,refreshBuiltinBusy:`Fetching official catalogs…`,refreshBuiltinOk:`Official catalogs updated, model picker refreshed`,refreshBuiltinFail:`Force-refresh failed, try again later`,appendModel:`Add model`,appendModelOk:`Added, model picker updated`,appendModelFail:`Failed to add`,providerId:`Provider ID`,providerIdHint:`(required, e.g. ollama / my-proxy)`,displayName:`Display name`,displayNamePh:`My proxy`,apiType:`API type`,baseUrlHint:`(OpenAI-compatible endpoint)`,apiKeyHint:`sk-… (optional — uses the auth.json key)`,apiKeySavedHint:`Saved — leave blank to keep unchanged`,authHeader:`Auto-add Authorization header`,text:`Text`,contextWindow:`Context`,deleteProviderConfirm:`Delete provider {id} and its {n} models?`,fetchModels:`Fetch model list`,fetchModelsHint:`Pull model IDs from the baseUrl /models endpoint (server-side, no CORS)`,fetchingModels:`Fetching…`,fetchModelsOk:`Fetched {n} models`,fetchModelsEmpty:`The endpoint returned no models`,fetchModelsNeedBaseUrl:`Enter a baseUrl first`,enrichModels:`Enrich params`,enrichModelsHint:`Look up model ids on OpenRouter / models.dev to fill context, max output, vision and reasoning (blanks only, manual values kept)`,enrichingModels:`Enriching…`,enrichModelsCancel:`Cancel`,enrichModelsAbort:`Abort enrichment`,enrichCancelling:`Cancelling…`,enrichModelsOk:`Enriched {n}, unmatched {m}`,enrichModelsErr:`Enrich failed: {msg}`,enrichModelsNeedIds:`Enter at least one model id`,goalBarTitle:`Goal`,goalBarPlaceholder:`Enter the goal to achieve…`,goalBarSet:`Send`,goalBarClear:`Cancel`,goalBarLocked:`Locked: applies to every later turn`,goalBarUnlocked:`This turn only (cleared afterwards)`,goalBarReviewModel:`Scoping model`,goalBarUseMainModel:`Use the main model`,goalBarMaxRounds:`Max rounds`,goalBarMaxRoundsTip:`Max execution/review rounds; 0 or empty = unlimited (keep revising until it passes)`,goalBarUnlimitedShort:`Unlimited`,goalBarExecModel:`Executor model`,goalBarExecModelTip:`Model for the executor conversation; empty = follow the main conversation`,goalBarOpenExec:`Executor chat`,goalBarOpenExecTip:`Open the executor conversation (also reachable from the left panel)`,goalBarStaleBackend:`⚠️ Stale server build (process not restarted): goal mode 2.0 will not take effect — restart the pi-web-ui service`,goalBarStop:`Stop goal (also stops the executor conversation)`,goalBarReviewing:`Reviewing…`,goalBarExecuting:`Executing…`,goalHistory:`History`,goalBarRound:`Round {n}`,goalBarPassed:`Passed`,goalBarFailed:`Failed`,goalBarBlocked:`⚠️ Blocked`,goalWizardBtn:`Refine`,goalWizardTip:`Let AI refine the requirement into a goal via a Q&A survey`,goalWizardRunning:`Scoping the goal`,goalWizardCard:`Goal survey`,settings:`Settings`,settingsTitle:`Settings`,settingsDesc:`Changes apply immediately: system prompt, skill and extension toggles rebuild the current session; review instructions and review skills affect later goal reviews (main-session changes are deferred while streaming).`,settingsSystemPrompt:`System prompt`,settingsPromptHistory:`Input history`,settingsPromptHistoryDesc:`Cycle previous prompts with ↑/↓ in the input — global across conversations (localStorage)`,promptHistoryMax:`Max entries`,promptHistoryMaxHint:`Oldest entries are dropped when exceeded (1–500)`,promptHistoryCharLimit:`Limit characters per entry`,promptHistoryCharLimitHint:`When enabled, overlong prompts are truncated before saving`,promptHistoryCharLimitPlaceholder:`Max chars (100–20000)`,promptHistoryClear:`Clear history`,promptHistoryClearConfirm:`Confirm clear?`,promptHistoryCount:`{n} entries`,promptHistoryEmpty:`No history yet — ↑/↓ has nothing to cycle`,promptModeAppend:`Append`,promptModeReplace:`Replace`,promptComposeHint:`Each {{token}} in the template expands to that source's prompt on every run; non-overridden sources use auto content (tools list / project context / skills are always regenerated from the latest data).`,promptComposeDesc:`Compose: reorder / drop / annotate {{token}} blocks freely; empty = the default template. Each source below can be overridden individually (leave empty = auto content) and reset back to default.`,promptTemplateLabel:`Compose template`,promptSourcesLabel:`Sources (override individually)`,promptInsertTokens:`Insert block: `,promptResetAll:`Restore default template and clear all overrides`,promptResetSource:`Restore default`,promptAutoBadge:`auto`,promptOverridePlaceholder:`Override text (leave empty = auto content)…`,promptSourceDefaultEmpty:`(no auto content for this source right now)`,promptReadonlyBadge:`System-generated (read-only)`,promptReadonlyLockedHint:`This source is system-generated and read-only; the override won't be edited here, but the server still applies it as-is.`,promptReadonlyTitle:`System-generated source — read-only display, not editable`,promptSourceDefaultEditHint:`This source's current default (auto) content — click to type an override`,promptSourceExpand:`Show more`,promptSourceCollapse:`Show less`,promptSourceRefLabel:`Default (auto) content — for reference / copying`,promptSourceSeedButton:`Load default text to tweak`,promptSourceSeedTip:`Copies this source's current default text into the override box so you can tweak just a part. Once filled, this source stays fixed and is no longer auto-regenerated each run.`,promptTok_soul:`Soul / persona`,promptTok_soul_desc:`the agent persona (built-in default unless a SYSTEM.md exists)`,promptTok_tools:`Tools list`,promptTok_tools_desc:`Available tools with snippets, regenerated each run`,promptTok_guidelines:`Guidelines`,promptTok_guidelines_desc:`per-tool guidance + generic rules`,promptTok_pi_docs:`Pi docs pointer`,promptTok_pi_docs_desc:`the block pointing at the pi package docs`,promptTok_append:`Append block`,promptTok_append_desc:`APPEND_SYSTEM.md content; override = custom appended text`,promptTok_persona:`Windows persona`,promptTok_persona_desc:`win32-only safety rules (timeout / PTY / GBK)`,promptTok_terminal:`Terminal guidance`,promptTok_terminal_desc:`persistent-terminal usage guide (injected when terminal tools are on)`,promptTok_markers:`Markers guidance`,promptTok_markers_desc:`built-in marker tools usage (injected when markers are on)`,promptTok_context:`Project context`,promptTok_context_desc:`<project_context>: AGENTS.md / CLAUDE.md collection`,promptTok_skills:`Skills`,promptTok_skills_desc:`<available_skills> list of usable skills`,promptTok_cwd:`Working dir line`,promptTok_cwd_desc:`the Current working directory line`,settingsViewPrompt:`View the current full prompt`,settingsViewPromptTokens:`{n} tokens`,settingsViewPromptHint:`The full system prompt actually in effect for this conversation (custom append/replace text, project context, skills and tool guidance). Read-only.`,settingsViewPromptEmpty:`Session not ready yet — no system prompt available.`,settingsViewToolsSchema:`View tools schema`,settingsViewToolsSchemaHint:`The function-calling tool definitions sent to the model (name / description / parameters), combining with the system prompt text to form the full initial context. Read-only.`,settingsViewToolsSchemaEmpty:`Session not ready yet — no tools schema available.`,settingsPromptContextTotal:`Total: {n} tokens`,settingsSkills:`Skills`,settingsReview:`Goal review`,settingsReviewDesc:`Configure extra instructions and skills for the isolated goal-review session; the main session is unaffected.`,settingsReviewSkills:`Skills available to review`,reviewPromptPlaceholder:`Type custom review instructions… (applied on blur)`,goalModeEnabled:`Enable goal mode`,goalModeEnabledDesc:`Master switch for the goal bar, the goal wizard and the review loop (on by default). When off, the goal bar is hidden and you cannot set a goal, run the wizard, or trigger reviews.`,goalModeOffHint:`Goal mode is off: the goal bar is hidden and existing goals no longer trigger reviews.`,delegateMode:`Reviewer mode (auto-delegate)`,delegateModeDesc:`When on, this conversation reviews instead of building: the server forwards every request you send to one persistent executor conversation that does the work, and this conversation inspects the result and states follow-ups. Writing files, running commands and dispatching more subagents are blocked by a server-side gate.`,delegateModeOffHint:`Reviewer mode is off: back to a normal conversation — this one can change code again.`,delegateModeBadge:`Reviewer`,delegateModeBadgeTip:`Reviewer mode is on: work runs in the persistent executor conversation (nothing dispatched yet)`,delegateModeOpenTip:`Open the persistent executor conversation to see what it did`,settingsVisionBridge:`Vision bridge`,settingsVisionBridgeDesc:`When the current model can't see images, send them to a configured vision model and transcribe into text evidence first`,visionBridgeEnabled:`Enable vision bridge`,visionBridgeModel:`Transcription model`,visionBridgeAuto:`Auto (in order)`,visionBridgeNoModels:`No configured vision model found: add any image-capable model (e.g. qwen-vl, GLM-4V, Gemini) in Model config to enable automatically`,visionBridgeOffHint:`Disabled: images are sent as-is, a text-only model may not see them`,visionBridgeCurrent:`Current transcription model: {model}`,visionBridgePromptMode:`Transcription prompt`,settingsMarkers:`Markers`,settingsMarkersDesc:`Let the AI write [[todo:...]] / [[notify:...]] / [[conv:rename:...]] inline markers in replies to update state without a tool round-trip. Global off disables all; per-marker toggles give fine control.`,markersEnabled:`Markers enabled (global)`,markersEnabledDesc:`Off = no marker guidance injected and no parsing; markers stay as plain text.`,markersOffHint:`Globally off: all markers disabled — the AI won't write markers and no side effects fire.`,markerGroupTodo:`todo — tasks`,markerGroupNotify:`notify — non-blocking hints`,markerGroupRename:`conv/rename — rename chat`,markerRenameTip:`[[conv:rename:Title]] renames the current conversation (≤80 chars; rename at the end of the first reply)`,terminalToolsEnabled:`Enable persistent terminal tools`,settingsTerminalToolsDesc:`Let the AI use the built-in terminal for interactive programs (REPLs/vim), long-running servers, continuous output watching, or when you ask it to work in the visible terminal; ordinary commands still go through the one-shot bash tool`,editSoftEnabled:`Enable edit_soft tool`,editSoftEnabledDesc:`Let the AI use a separate indentation-insensitive edit tool: avoids edit failures when your oldText spacing differs from the file (e.g. JS/JSON). On a match, newText is written verbatim as you provide it (its indentation is final).`,editSoftOffHint:`Disabled: the AI has no edit_soft tool and receives no usage guidance`,settingsQuestionnaire:`Questionnaire`,questionnaireEnabled:`Allow the model to ask me questions`,questionnaireEnabledDesc:`On by default: the model may use ask_user_question to pop up an answerable question dialog (options, multi-select, custom input). Off: the model no longer pops up questionnaires; a call also returns disabled immediately.`,questionnaireOffHint:`Disabled: the model can no longer pop up question dialogs`,parallelReminderEnabled:`Parallel-work reminder in the same project`,parallelReminderEnabledDesc:`When another conversation is running in the same project, remind once before a new turn starts (on by default). The reminder also tells the AI to assess conflicts and ask you when unsure: continue in parallel / wait / watch read-only.`,parallelReminderOffHint:`Disabled: no parallel-work reminders; the AI gets no conflict hint either`,browserPageEnabledDesc:`Let the model act on pages you granted in the page-picker extension (browser_page tool: read / click / type / scroll / goto; eval has its own switch). Grant the target page in the extension options first.`,browserPageOffHint:`Disabled: the model can no longer click your pages or run scripts in them`,conversationReadEnabledDesc:`Let the AI read other conversations on demand (live messages from running subagents plus history transcripts): small read-only references, no tokens until fetched.`,conversationReadOffHint:`Disabled: the AI can no longer read other conversations`,scheduleTaskEnabledDesc:`Let the AI create scheduled/delayed wake-ups (schedule_task creates, schedule_list lists, schedule_cancel cancels): on fire the prompt is delivered back into the originating conversation to run and report; one-shot by default, auto-deleted after firing.`,scheduleTaskOffHint:`Disabled: the AI can no longer create scheduled tasks (existing tasks keep running)`,browserControl:`Browser control`,browserControlTip:`Let the AI act on pages you grant in your browser (read / click / type / scroll). Needs the page-picker extension — granting and the switches live in its options page.`,browserControlChecking:`Checking the extension status…`,browserControlOffline:`No browser extension yet: install (or enable) page-picker, click its icon on this page once to bind the address, then reload this page.`,browserControlInstall:`Install the extension (2 minutes)`,browserControlInstallLead:`The extension is not on the Chrome Web Store — no need to search there, follow these four steps:`,browserControlInstallDownload:`Download page-picker-extension.zip (always the latest)`,browserControlInstallStep1:`Unzip it (you get a folder containing manifest.json).`,browserControlInstallStep2:`In Chrome / Edge open chrome://extensions (Edge uses edge://extensions) and switch on “Developer mode” (top right).`,browserControlInstallStep3:`Click “Load unpacked” and pick the folder from step 1.`,browserControlInstallStep4:`Back on this pi-web-ui page, click the extension icon once and choose “Set as service address” — no typing addresses or ports.`,browserControlEmpty:`The extension is ready, but no page is granted yet — open its options page below and grant one.`,browserControlDisabled:`The “allow AI to control pages” master switch is off — turn it on in the extension options.`,browserControlPages:`Granted pages`,browserControlPageOpen:`open`,browserControlPageClosed:`not open`,browserControlExamples:`You can ask for things like`,browserControlExample1:`"Read the orders on that page and sort them by amount"`,browserControlExample2:`"Type John Doe in the search box, click search, and tell me the first result"`,browserControlOpenOptions:`Open extension options`,browserControlRefresh:`Refresh status`,browserControlCite:`Mention in chat`,browserControlCiteTip:`Add {name} to the input as a page reference (you still write the instruction before sending)`,browserControlCiteNote:`“Mention in chat” puts a page reference into the input — the model then knows which page to act on, no typing URLs.`,browserControlCited:`Added to the input — write a line and send`,browserControlCiteFailed:`The input is not ready yet, try again in a moment`,browserControlOpenPanel:`Open panel (status / grants)`,browserControlSingleTip:`Click to mention {name} in the chat; the ▾ on the right opens the panel`,browserControlDesktop:`Browser control isn't available in the desktop app — nothing you did wrong`,browserControlDesktopLead:`The desktop window has no Chrome extension runtime, so the page-picker extension can't be installed there. Open this same address in your system browser with the button below, then follow the four web steps to install the extension.`,browserControlOpenInBrowser:`Open this address in the default browser`,attachPage:`Page reference: {name} (the AI is granted access to this page)`,attachPageShort:`page`,settingsTools:`Tools`,toolsSectionCore:`Core tools`,toolsCoreHint:`bash / read / edit / write / powershell are the model's basic toolkit and are not part of the catalog toggles below. Turning one off removes that ability: no bash = no command execution, no read = no file reading, no edit / write = no file modification, no powershell = no PowerShell command execution (Windows only).`,toolCoreBashDesc:`Run shell commands. When off, the model cannot execute commands, install dependencies, or run tests.`,toolCoreReadDesc:`Read files and directories. When off, the model can only work with content already in the conversation.`,toolCoreEditDesc:`Make precise file edits. When off, the model cannot modify code in place.`,toolCoreWriteDesc:`Create or overwrite files. When off, the model cannot create or overwrite files.`,toolCorePowershellDesc:`Run PowerShell commands (Windows only). When off, the model cannot execute PowerShell commands.`,toolCoreLsDesc:`List directory contents. When off, the model cannot call ls (fully substituted by read directory mode).`,toolCoreGrepDesc:`Search file contents by regex. When off, the model cannot call grep (substitutable by bash commands).`,toolCoreFindDesc:`Search files by glob pattern. When off, the model cannot call find (substitutable by bash commands).`,toolsSectionTerminal:`Persistent terminal`,toolsSectionSubagent:`Subagents`,toolsSectionOther:`Other tools`,toolsSectionPlugin:`Plugin tools`,toolsPluginHint:`AI tools registered by plugins via registerAgentTool: turning one off removes it from sessions so the AI cannot call it; re-enabling adds it back with no reload. Disabled entries are kept, so reinstalling the plugin stays off.`,pluginToolsSection:`Registered AI tools`,pluginToolsEmpty:`None of the installed plugins register AI tools`,pluginToolOffHint:`Disabled: the AI cannot call this tool (re-enable to restore immediately, no reload)`,toolsPresetBanner:`Default preset “{name}” is filtering tools: {count} tool switches have no effect on new conversations until you switch back to full features`,toolsBackToStandard:`Back to full features`,toolsBlockedByPreset:`Unavailable under default preset “{name}”; switch back to full features to restore`,pluginToolsDisabledByPlugin:`Disabled because the owning plugin is disabled in “Plugins”; re-enable the plugin to restore`,pluginDisabledInPlugins:`Plugin disabled`,skillsHiddenByPreset:`Skill catalog hidden by default preset “{name}” (not shown while the skill loader is unavailable); switch back to full features to restore`,toolsSubagentDepHint:`Unified subagent entrypoint combining spawn/wait/get/steer/stop/list/templates/handoff; delegate_task rides the spawn channel, so it cannot dispatch if subagents are disabled.`,delegateTaskEnabledDesc:`Delegate a well-defined task to a specialist subagent template: the six-section brief (TASK/EXPECTED OUTCOME/REQUIRED TOOLS/MUST DO/MUST NOT DO/CONTEXT) is validated server-side; missing or vague sections are rejected. Runs on the subagent spawn channel.`,delegateTaskOffHint:`Disabled: the AI cannot delegate via delegate_task (free-form delegation via subagent still works, without six-section validation)`,todoListEnabledDesc:`Read-only query of the current task list (deleted items need an explicit flag); writes never go through tools — use inline markers.`,todoListOffHint:`Disabled: the AI can no longer call the query tool (inline-marker writes are unaffected)`,toolDescSubagent:`Background subagent management (visible in the left panel): unifies spawn (dispatch), wait_all (collect), get_result (inspect), steer (redirect), stop (abort), list (status), templates (catalog), and handoff (peer collaboration).`,toolDescSubagentSpawn:`Spawn an independent background subagent conversation (visible on the left) for a self-contained task; several may run in parallel.`,toolDescSubagentGetResult:`Fetch one subagent's result or current progress; unfinished ones return status plus partial output.`,toolDescSubagentSteer:`Inject a message into a running subagent to redirect or supplement its work.`,toolDescSubagentList:`List all subagents with live status (id/type/state/title).`,toolDescSubagentStop:`Stop a running subagent (same as aborting its conversation).`,toolDescSubagentWaitAll:`Wait for multiple subagents at once and collect results — no polling.`,toolDescSubagentTemplates:`List available subagent templates (disabled ones hidden) for spawn to use.`,settingsMessageDisplay:`Conversation`,thinkingWrap:`Show full thinking`,thinkingWrapDesc:`On: thinking always expands fully and wraps (live reasoning visible while streaming); Off: collapses to a one-line summary with the latest text shown live while streaming`,toolsWrap:`Show full tools`,toolsWrapDesc:`On: tool calls always expand fully showing arguments and output; Off: collapsed by default, click to expand`,toolImages:`Show tool result images inline`,toolImagesDesc:`On: image tool results (e.g. screenshots) render in the card, click to zoom; Off: images are hidden`,toolImageZoom:`Click to preview`,devNoCache:`Dev mode: no page cache`,devNoCacheDesc:`On: always fetch a fresh page (for source development); Off: allow browser caching (install default)`,autoReload:`Auto-reload on new build`,autoReloadDesc:`On: page reloads itself after a server rebuild (for source development); Off: reconnect only (install default)`,wideChat:`Wide chat column`,wideChatDesc:`On: the center column fills the width (useful on ultrawide monitors); Off: keep the 860px cap`,projectTitle:`Show project name in title`,projectTitleDesc:`On: the browser tab title becomes “<project folder> — pi-web-ui” and updates when you switch projects (handy with several tabs open); Off: always show the app name`,terminalBashTakeover:`Terminal-backed bash`,terminalBashTakeoverDesc:`This switch decides whether bash is overridden to a terminal version: OFF = native SDK bash (process spawn, no terminal); ON = runs in a visible terminal, where the persist parameter decides (on top of the switch) one-shot (false — process exits when the command finishes, output retained) vs persistent (true — shell state retained across calls, silent commands move to the background and notify the AI)`,terminalBashIdleMs:`Silence-to-background threshold (ms)`,terminalBashIdleMsDesc:`In persistent-terminal mode, when a command produces no output for this long, stop blocking and let it keep running in the background; the AI is notified when it finishes. 0 = always wait until completion (default 15000)`,terminalBashMaxForegroundMs:`Max foreground wait (ms)`,terminalBashMaxForegroundMsDesc:`In terminal-takeover mode, when a command's total foreground runtime reaches this threshold, it is automatically moved to the background regardless of output activity, unblocking the model. 0 = unlimited (default 60000)`,readDirEnabled:`read a directory`,readDirEnabledDesc:`On: passing a directory path to read lists its entries (one per line, directories end with '/'; limit then caps the entry count); Off: a directory path goes to the built-in read unchanged (EISDIR — use bash ls to browse). DSH engine has no such override; pi engine only`,toolWatchdogTimeout:`Tool watchdog timeout (min)`,toolWatchdogTimeoutDesc:`Max execution time for a single tool call (default 20 min, 0 = disable). Auto-aborts to prevent hangs; if a tool call explicitly specifies a longer timeout (e.g. bash timeout), the watchdog extends automatically`,toolWatchdogOff:`0 = disable`,visionBridgePromptPlaceholder:`Type a custom transcription prompt… (empty = built-in default, applied on blur)`,scmCommitMsgSettingsTitle:`AI commit message (source control)`,scmCommitMsgSettingsDesc:`Prompt for the source-control panel's Generate button: the model distills the current changes into a one-line commit message, following this repo's recent commit language and style, and fills it into the commit input`,scmCommitMsgPromptPlaceholder:`Type a custom prompt… (empty = built-in default prompt, applied on blur)`,scmCommitMsgSettingsHint:`Append mode adds custom text after the built-in prompt; replace mode uses the custom text entirely (after switching, the editor shows the built-in default ready to edit — blurring without changes keeps the default)`,planModePromptSettingsTitle:`Plan mode prompt`,planModePromptSettingsDesc:`Prompt appended to the model while plan mode is on (the Plan button in the goal bar): research and plan only, no implementation. The built-in default carries two hard rules — never paste the implementation into the reply, and skip the plan board for small unambiguous requests`,planModePromptMode:`Plan mode prompt`,planModePromptPlaceholder:`Type a custom prompt… (empty = built-in default prompt, applied on blur)`,planModePromptSettingsHint:`Append mode adds custom text after the built-in prompt; replace mode uses the custom text entirely (after switching, the editor shows the built-in default ready to edit — blurring without changes keeps the default). Prompt only — the server-side read-only gate always applies`,uninstallExt:`Uninstall`,uninstallConfirm:`Confirm?`,uninstallConfirmHint:`Click again to confirm — runs pi remove in the terminal`,uninstallHint:`Runs pi remove in a visible terminal, then refreshes the list automatically`,uninstallTitle:`Uninstall`,pluginUpdate:`Update`,pluginUpdateHint:`Re-installs from the recorded source (--force, keeps config.json); runs in the background with in-place progress`,pluginMarket:`Plugin marketplace`,updatesManaged:`Managed instance: updates and plugin installs are handled by whoever deploys it`,pluginCatalogAdd:`Add plugin`,pluginCatalogAddHint:`Drop a third-party plugin into the installable list (owner/repo or full GitHub URL)`,pluginCatalogSource:`Source owner/repo or owner/repo/subdir (required)`,pluginCatalogId:`id (optional, defaults to repo/subdir name)`,pluginCatalogName:`Name (optional)`,pluginCatalogIcon:`Icon emoji (optional)`,pluginCatalogDesc:`Description (optional)`,pluginCatalogAddSubmit:`Add to list`,pluginInspectAlreadyInstalled:`A plugin named "{id}" is already installed — use Update to replace it, or pick another id`,pluginInspectInvalid:`Unrecognized source — expected owner/repo, owner/repo/subdir[#ref], a GitHub URL, or an npm package name`,pluginInspectNotPlugin:`No manifest.json at the remote source — not a pi-web-ui plugin (or the repo/subdir/ref is wrong)`,pluginInspectNetwork:`Could not reach the remote to verify (install still works) — retry when the network/proxy is fine`,noPluginCatalog:`List is empty — click "Add plugin" to drop a third-party plugin in`,pluginInstalled:`Installed`,pluginCatalogCustom:`custom`,pluginInstall:`Install`,pluginInstallHint:`Installs into UI plugins in the background (settings stay open, progress shown in place)`,pluginCatalogRemoveHint:`Remove this custom plugin from the list`,pluginUninstallHint:`Uninstalls this plugin in the background (click again to confirm), then refreshes the list`,pluginJobRunning:`Running…`,pluginJobDone:`Done`,pluginJobFailed:`Plugin operation failed`,pluginBuildSource:`Build from source`,pluginBuildHint:`Build in an isolated directory before install/update (same as CLI --build; source-only plugins without artifacts are built automatically even when unchecked)`,pluginCatalogSync:`Sync from catalog`,pluginCatalogSyncHint:`Sync the installable list from a catalog document (same channel as plugin reloadCatalog)`,pluginCatalogSyncSource:`Catalog URL (http(s)) or absolute local path`,pluginCatalogSyncSubmit:`Sync`,pluginCatalogSyncInstall:`Install all entries after sync`,pluginCatalogSyncReplace:`Replace wholesale (default merges by id)`,pluginCatalogSyncRecent:`Recent`,pluginCatalogSyncOk:`Catalog synced: {n} entries in the list`,pluginCatalogSyncInstalled:`Install results: {ok} succeeded, {fail} failed`,uiLayoutTitle:`Interface layout`,uiLayoutHint:`Plugins can rearrange these entries (built-in ones included). You can always change them back: uncheck to hide, ↑/↓ to reorder; changed rows offer “Restore”. Hidden entries stay reachable from the top-bar overflow menu.`,uiLayoutDiagTitle:`Layout diagnostics ({n})`,uiLayoutDiagHint:`These entries never made it to the UI. The reason is listed above — usually a plugin manifest/registration with a wrong slot, kind or arrange target. Fix the plugin and rescan.`,pluginTopbarMore:`More plugin buttons`,pluginMenuTitle:`Plugins`,pluginMenuPin:`Pin to top bar`,pluginMenuUnpin:`Unpin from top bar`,pluginMenuReorder:`Reorder plugin`,pluginMenuReorderHint:`Drag to reorder, or use Up and Down arrow keys`,pluginMenuManage:`Manage plugins`,pluginMenuEmpty:`No UI plugins installed (<dataDir>/plugins/)`,pluginMenuNoView:`No standalone view`,uiLayoutTopbar:`Top bar`,uiLayoutRequired:`This item is always visible and cannot be hidden`,uiLayoutTopbarText:`Show button labels`,uiLayoutSideDockFloat:`Float side icons`,uiIconEdit:`Edit icons`,uiIconEditTitle:`Icon editor`,uiIconEditHint:`Drag an icon to reorder it, move it to another section (start/center/end) or another bar; drop it on "Hidden" to hide it.`,uiIconEditTray:`Hidden`,uiIconEditDropHere:`Drop here`,uiLayoutTopbarOverflow:`Top-bar overflow`,uiLayoutBottombar:`Bottom bar`,uiLayoutComposerLeading:`Composer leading (left of upload)`,uiLayoutComposer:`Composer actions`,uiLayoutMessage:`Message actions`,uiLayoutRightPanel:`Right panel`,uiLayoutSettingsPages:`Settings pages`,uiLayoutModal:`Modal`,uiLayoutContextTopbar:`Top-bar context menu`,uiLayoutContextMessage:`Message context menu`,uiLayoutContextSession:`Session context menu`,uiLayoutContextFile:`File context menu`,uiLayoutContextToolcall:`Tool-card context menu`,uiLayoutLeftSessions:`Left-panel session rows`,uiLayoutChatHeader:`Chat header`,uiLayoutChatEmpty:`Empty chat`,uiLayoutFilePreview:`File preview toolbar`,uiLayoutTerminal:`Terminal toolbar`,uiLayoutScm:`SCM toolbar`,uiLayoutGoalbar:`Goal-bar actions`,uiLayoutNotice:`Notice actions`,uiLayoutSidebarLeft:`Left floating dock`,uiLayoutSidebarRight:`Right floating dock`,uiLayoutPosition:`Position`,uiLayoutPosTop:`Top`,uiLayoutPosBottom:`Bottom`,uiLayoutPosLeft:`Left dock`,uiLayoutPosRight:`Right dock`,uiLayoutSearch:`Filter entries…`,uiLayoutMovedFrom:`moved from`,uiLayoutAlign:`Align`,uiLayoutAlignTop:`Top`,uiLayoutAlignMiddle:`Middle`,uiLayoutAlignBottom:`Bottom`,uiLayoutRename:`Rename`,uiLayoutRestore:`Restore`,uiLayoutRestoreAll:`Restore all`,uiLayoutArranged:`Changed by a plugin`,uiLayoutEmpty:`(none)`,moveToTop:`Move to top`,moveToBottom:`Move to bottom`,moveToLeft:`Move to left dock`,moveToRight:`Move to right dock`,sideDockCollapse:`Collapse dock`,sideDockExpand:`Expand dock`,pluginGrantsTitle:`Granted directories`,pluginGrantsHint:`Plugins must ask before touching directories outside the workspace. Approved ones are listed here and can be revoked at any time.`,pluginGrantsEmpty:`No plugin has been granted a directory outside the workspace yet`,pluginGrantsRevoke:`Revoke`,pluginGrantRequestTitle:`A plugin wants to access a directory`,pluginGrantRequestBody:`{plugin} wants to access this directory:
|
|
320
320
|
|
|
321
321
|
{path}`,pluginGrantAllow:`Allow`,pluginGrantDeny:`Deny`,pluginPermTitle:`A plugin requests capability access`,pluginPermBodyNet:`{plugin} wants to reach these network hosts (no reinstall needed):
|
|
322
322
|
|
|
@@ -324,45 +324,45 @@ 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)`,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`,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)`,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`,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`,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.`},pn=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],mn={};function hn(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(mn[e.code]=e,!0)}function gn(e){delete mn[e]}function _n(e){return e===`zh`?`中文`:e.toUpperCase()}function vn(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function yn(e){let t=await fetch(sn(nn(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var bn=(0,m.createContext)(null);function xn(){try{return localStorage.getItem(un)}catch{return null}}function Sn(){return ln(xn(),typeof navigator<`u`?navigator.languages:[],null)}function Cn({children:e}){let[t,n]=(0,m.useState)(Sn),[r,i]=(0,m.useState)(0),a=(0,m.useRef)(t);a.current=t;let o=(0,m.useCallback)(e=>{n(e);try{localStorage.setItem(un,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,m.useCallback)(async()=>{let e,t=null;try{let n=await yn(`/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 yn(`/api/locales/${e.code}`);return hn({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,m.useEffect)(()=>{s().then(e=>{if(!xn()?.trim()){let t=ln(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!mn[t]){let t=ln(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(un,t)}catch{}}})},[s]);let c=(0,m.useMemo)(()=>[...pn,...Object.values(mn).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,m.useCallback)((e,n)=>{let r=mn[t]?.strings[e];r&&t!==`zh`&&t!==`ja`&&/[\u4e00-\u9fff]/.test(r)&&(r=void 0);let i=r??(t===`zh`?dn[e]:fn[e]);if(n)for(let[e,t]of Object.entries(n))i=i.replaceAll(`{${e}}`,String(t));return i},[t,r]);(0,m.useEffect)(()=>{document.documentElement.lang=vn(t)},[t]);let u=(0,m.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(bn.Provider,{value:u,children:e})}function wn(){let e=(0,m.useContext)(bn);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return wn().t}var Tn=[{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 En({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)(P,{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})})]}),Tn.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 Dn(){let[e,t]=(0,m.useState)([]);return(0,m.useEffect)(()=>{if(!Rt())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 On({settings:e,onChange:t,onPreview:n}){let r=Z(),i=Dn(),a=Rt(),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)(P,{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&&!zt(e.voiceURI,i,navigator.language)){t({...Ft,...e,voiceURI:``});return}n()},children:r(`preview`)})})]})}function kn(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 An=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),jn=null,Mn=0;function Nn(){return jn?.available===!0?jn.pages??[]:[]}function Pn(){Date.now()-Mn<5e3||Fn().catch(()=>{})}async function Fn(){if(kn())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=An();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&&(jn=r,Mn=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function In(e){return e.length===1?e[0]:null}function Ln(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function Rn(){let e=An();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function zn(e=45e3){let[t,n]=(0,m.useState)(null),r=(0,m.useRef)(!0),i=(0,m.useCallback)(async e=>{let t=await Fn();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,m.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 Bn=null,Vn=null,Hn=null,Un=null,Wn=null;function Gn(e){Un=e}function Kn(e){Wn=e}function qn(e){return Un?(Un(e),!0):!1}function Jn(e){return Wn?(Wn(e),!0):!1}function Yn(e){Bn=e}function Xn(e){Vn=e}function Zn(e){Hn=e}function Qn(){return Hn?(Hn(),!0):!1}function $n(){return!!(Bn||Vn)}function er(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&&!Bn||i&&!Vn?!1:(i&&Vn?.(n),r&&Bn?.(t),!0)}function tr(){let e=Z(),{status:t,refresh:n}=zn(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(null),s=(0,m.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=In(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},f=t=>{let n=er({attachments:[Ln(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)(me,{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)(me,{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)(nr,{status:t,onRefresh:n,onCite:f,onClose:()=>i(!1)})]})}function nr({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,m.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await Rn()||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)(me,{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 rr=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],ir=[`subagent`],ar=`edit_soft`,Q=`delegate_task`,or=`ask_user_question`,sr=`todo_list`,cr=`browser_page`,lr=`conversation_read`,ur=`skill`,dr=`schedule_task`,fr=`schedule_list`,pr=`schedule_cancel`,mr=`eval`,hr=`present_files`,gr=`claim_files`,_r=`plan_update`,vr=`compact_context`,yr=`patch`,br=[...rr.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...ir.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:ar,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:Q,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:or,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:cr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:lr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:gr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:_r,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`planUpdateEnabledDesc`,offHintKey:`planUpdateOffHint`},{name:yr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`patchToolEnabledDesc`,offHintKey:`patchToolOffHint`},{name:`lsp`,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`lspToolEnabledDesc`,offHintKey:`lspToolOffHint`},{name:hr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:ur,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:mr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`evalEnabledDesc`,offHintKey:`evalOffHint`},{name:dr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:fr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:pr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:vr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`compactContextEnabledDesc`,offHintKey:`compactContextOffHint`},{name:sr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}],xr=[`bash`,`read`,`edit`,`write`,`powershell`,`ls`,`grep`,`find`];new Set(br.map(e=>e.name));function Sr(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`]);return n.filter(t=>!e.has(t))}return n}function Cr(e){return Sr([ur],e).includes(ur)}var wr=`pi-web-notify`,Tr={enabled:!1};function Er(){try{let e=localStorage.getItem(wr);if(!e)return{...Tr};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:Tr.enabled}}catch{return{...Tr}}}function Dr(e){try{localStorage.setItem(wr,JSON.stringify(e))}catch{}}function Or(){return typeof window<`u`&&`Notification`in window}function kr(){return Or()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Ar(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&jr(t)||Number.isFinite(n)&&jr(n)?!0:r>0&&r<=400&&i>0&&i<=40}function jr(e){return e<=-1e4}function Mr(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var Nr=Date.now(),Pr=!1;function Fr(){Nr=Date.now()}function Ir(){return Math.max(0,Date.now()-Nr)}function Lr(){if(Pr||typeof window>`u`)return;Pr=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Fr,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Fr,e)}function Rr(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function zr(){return Lr(),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:Ar({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Ir(),windows:Rr()}}function Br(){return Or()?Notification.permission:`denied`}async function Vr(){if(!Or())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function Hr(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Ur(e,t=!1){return{body:e,requireInteraction:t,icon:nn(`/icons/icon-192.png`),badge:nn(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:nn(`/`)}}}async function Wr(e,t,n=!1){if(!Or())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=Ur(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=Hr(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${Hr(e)}`}}}async function Gr(e,t){Or()&&(Mr(zr())||Er().enabled&&await Wr(e,t))}var Kr=!1;function qr(){let e=Z(),[t,n]=(0,m.useState)(Er),[r,i]=(0,m.useState)(()=>Br()),[a,o]=(0,m.useState)(null),s=kr(),c=s!==null,l=Rr();(0,m.useEffect)(()=>{let e=()=>i(Br());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),Dr(r),e){let e=await Vr();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Dr(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)(lt,{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`)}),Kr]})}var Jr=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),Yr=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(`.`)),Xr=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),Zr=new Set([...Jr].map(e=>e.toLowerCase())),Qr=new Set([...Yr].map(e=>e.toLowerCase()));function $r(e){return Zr.has(e.toLowerCase())}function ei(e){return Qr.has(e.toLowerCase())}function ti(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[...e.children]){let e=t.tagName.toLowerCase();if(!$r(e)){Xr.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of[...t.attributes]){let n=e.name.toLowerCase();(!ei(n)||/^on/i.test(n)||/^(javascript|data|vbscript):/i.test(e.value.trim()))&&t.removeAttribute(e.name)}i(t)}};for(let e of[...r.attributes]){let t=e.name.toLowerCase();(!ei(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function ni({icon:e,iconSvg:t,className:n}){let r=ti(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 ri=new Set([`view`,`action`,`badge`,`menu`,`page`,`organizer`,`divider`,`toggle`,`input`,`progress`,`select`]),ii=new Set([`disabled`,`always`,`never`,`file.isDir`,`file.isFile`,`session.isRunning`,`message.hasSelection`]),ai=[`topbar.primary`,`topbar.overflow`,`notice.actions`,`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.file`,`contextmenu.toolcall`,`settings.pages`,`modal.dialog`,`sidebar.left`,`sidebar.right`],oi=ai.map(e=>({slot:e,cardinality:`list`}));function si(e){return oi.find(t=>t.slot===e)?.cardinality??`list`}function ci(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 li=[{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-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-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-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}],ui=`__view`,di=new Set([`host:settings`,`host:history`,`host:files`]),fi=new Set([`host:history`,`host:files`]);function pi(e){return`${e}:${ui}`}function mi(e){return e.source.startsWith(`plugin:`)?e.id===pi(e.source.slice(7)):!1}function hi(e,t,n){let r=pi(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 gi(e,t){let n=t.map(pi),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var _i=`host:brand`,vi=[`host:brand-logo`,`host:brand-name`];function yi(e){if(!((e.hidden??[]).some(e=>vi.includes(e))||(e.shown??[]).some(e=>vi.includes(e))||(e.order??[]).some(e=>vi.includes(e))||vi.some(t=>e.align?.[t]!==void 0)||vi.some(t=>e.groups?.[t]!==void 0)||vi.some(t=>e.labels?.[t]!==void 0)||vi.some(t=>e.slots?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=vi.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))vi.includes(t)||(n[t]=r);if(n[_i]===void 0){let r=t?e[vi[0]]??e[vi[1]]:e[vi[1]]??e[vi[0]];r!==void 0&&(n[_i]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))vi.includes(n)||(t[n]=r);if(t[_i]===void 0){let n=e[vi[0]]??e[vi[1]];n!==void 0&&(t[_i]=n)}return t},i=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))vi.includes(n)||(t[n]=r);if(t[_i]===void 0){let n=e[vi[0]]??e[vi[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 bi(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:ui,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 xi(e){return typeof e==`string`&&ai.includes(e)}function Si(e,t){return t?e.label:e.labelEn??e.label}function Ci(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function wi(e,t,n,r,i){let a=`${e}#${r.id}`,o=Ti(a,t,n,r.children,i),s=Ci(r,i),c=Ei(r.options,i);return{id:a,slot:t,source:n,label:Si(r,i),...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 Ti(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:wi(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 Ei(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 Di(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Oi(e,t,n,r,i,a){let o=Ti(e,t,n,r.children,i),s=Ci(r,i),c=Di(r.progress),l=Ei(r.options,i);return{id:e,slot:t,source:n,label:Si(r,i),...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 ki(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 Ai(e){let t=e.filter(e=>mi(e));if(t.length===0)return e;let n=e.filter(e=>!mi(e)),r=[`host:git`,`host:terminal`,`host:chat`].map(e=>n.findIndex(t=>t.id===e)).find(e=>e>=0)??-1,i=n.findIndex(e=>e.id===`host:plugins`),a=r+1;return i>=a&&(a=i),a=Math.max(0,Math.min(a,n.length)),[...n.slice(0,a),...t,...n.slice(a)]}function ji(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=yi(t.layout??{}),a=e=>{t.diagnostics?.push({level:e.level??`warn`,...e})},o=new Map,s=0;for(let e of li)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(!xi(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.kind&&!ri.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)ii.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,Oi(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);Ni(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,l(e,`label`))}for(let[e,t]of Object.entries(i.slots??{})){let n=o.get(e);n&&xi(t)&&n.slot!==t&&(n.movedFrom=n.movedFrom??n.slot,n.slot=t,l(e,`slot`))}for(let e of di){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`))});let d=new Map;for(let e of ai)d.set(e,[]);for(let e of o.values())d.get(e.slot)?.push(e);let f={};for(let e of ai){let t=ki(d.get(e)??[],u),n=ci(e===`topbar.primary`?Ai(t):t,si(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=>Mi(e,c.get(e.id)??[]))}return f}function Mi(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function Ni(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,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&&xi(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 Pi(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 Fi(e,t){let n=e??{},r={},i=t===_i?[t,...vi]:[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=Li(n.groups,t),l=Li(n.labels,t),u=Li(n.align,t),d=Li(n.slots,t);if(t===_i)for(let e of vi)c=Li(c,e),l=Li(l,e),u=Li(u,e),d=Li(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 Ii(){return{}}function Li(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 Ri=new Set([`host:files`]);function zi(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 Bi(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 Vi=null,Hi=new Set;function Ui(){for(let e of Hi)e()}function Wi(e){Vi={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}:{}},Ui()}function Gi(){Vi!==null&&(Vi=null,Ui())}function Ki(e){return Hi.add(e),()=>{Hi.delete(e)}}function qi(){return Vi}function Ji(){return(0,m.useSyncExternalStore)(Ki,qi,qi)}function Yi(e){return Number.isFinite(e)?e:0}function Xi(e,t,n,r,i,a){let o=Math.max(0,Yi(n)),s=Math.max(0,Yi(r)),c=Math.max(8,Yi(i)-o-8),l=Math.max(8,Yi(a)-s-8);return{x:Math.min(Math.max(8,Yi(e)),c),y:Math.min(Math.max(8,Yi(t)),l)}}function Zi(e,t){let n=String(t?.kind??``);if(e===`contextmenu.file`)return{"file.isDir":n===`dir`,"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 Qi(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 $i(e,t){return!e||Qi(e.when,t)}function ea(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 ta(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 na(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 ra(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!$i(e,t)}function ia(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,ra(e[o],r))return o;return-1}var aa={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?aa[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var sa={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},ca=new Set;function la(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function ua(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&&la(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&la(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function da(e){let t={...sa,...e};if(!ua(sa,t)){sa=t;for(let e of ca)e()}}function fa(e){return ca.add(e),()=>{ca.delete(e)}}function pa(){return sa}function ma(){return(0,m.useSyncExternalStore)(fa,pa,pa)}function ha(e){return(0,m.useSyncExternalStore)(fa,()=>sa[e],()=>sa[e])}function ga(){return ha(`engine`)===`dsh`}function _a(){return ha(`managed`)}function va(){return ha(`service`)}var ya=null;function ba(e){ya=e}var $=e=>ya?ya(e):!1,xa=`@root`,Sa=e=>e.endsWith(`/`)?e:e+`/`;function Ca(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function wa(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var Ta=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)?xa:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function Ea({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,m.useState)(``),[h,g]=(0,m.useState)(``),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(``),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(-1),T=(0,m.useRef)(null),E=(0,m.useRef)(null),D=t.filter(e=>e.type===`dir`);(0,m.useEffect)(()=>{let t=(e||``).replace(/\\/g,`/`);p(t),g(t),v(!1),b(``),S(null),w(-1)},[e]),(0,m.useEffect)(()=>{let e=requestAnimationFrame(()=>{T.current?.focus()});return()=>cancelAnimationFrame(e)},[]),(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(_?(v(!1),b(``),S(null)):r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,r]),(0,m.useEffect)(()=>{let e=setTimeout(()=>{$({type:`complete_path`,path:Sa(f)})},60);return()=>clearTimeout(e)},[f]),(0,m.useEffect)(()=>{if(h===f)return;let e=setTimeout(()=>{$({type:`complete_path`,path:h})},150);return()=>clearTimeout(e)},[h,f]);let O=e=>{let t=e.trim();t&&t!==`@root`&&i(t)},k=()=>{let e=y.trim();if(e){if(a===`project`){if(!wa(e)){S(d(`invalidProjectName`));return}let t=Ca(f,e);o?.(t),v(!1),b(``),S(null),r()}else $({type:`make_dir`,path:`${Sa(f)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:Sa(f)})},80),b(``),v(!1)}},A=e=>{if(e.key===`Escape`)e.stopPropagation(),_?(v(!1),b(``),S(null)):r();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)O(h);else if(e.key===`Tab`){if(D.length===0)return;e.preventDefault();let t=C>=0?(C+1)%D.length:0;w(t),g(D[t].path),p(D[t].path)}},j=Ta(f),ee=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},M=ee(f),P=!!f&&f!==`@root`&&M!==ee(e)&&!n.some(e=>ee(e)===M);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-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:f===`@root`?d(`computer`):f,children:[f===`@root`?`💻`:(0,X.jsx)(Me,{}),(0,X.jsx)(`span`,{children:f===`@root`?d(`computer`):f})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:f===xa,title:d(`computer`),onClick:()=>{p(xa),g(xa),w(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!j,title:d(`cwdGoUp`),onClick:()=>{j&&(p(j),g(j),w(-1))},children:[`↑ `,d(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!P,title:d(`addWorkspaceRootHint`),onClick:()=>{P&&$({type:`set_workspace_roots`,roots:[...n,f]})},children:[`+ `,d(`addWorkspaceRoot`)]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-close`,title:d(`close`),"aria-label":d(`close`),onClick:r,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:T,className:`status-cwd-input cwd-picker-input`,value:h,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>{g(e.target.value),w(-1)},onKeyDown:A}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:d(`cwdPickCurrent`),disabled:f===xa,onClick:()=>O(f),children:d(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[D.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}),D.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:()=>{p(e.path),g(e.path),w(-1)},children:[(0,X.jsx)(Me,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>O(e.path),children:d(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[_?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:E,value:y,autoFocus:!0,spellCheck:!1,placeholder:d(a===`project`?`projectName`:`cwdNewName`),onChange:e=>{b(e.target.value),x&&S(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),k()):e.key===`Escape`&&(e.stopPropagation(),v(!1),b(``),S(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:k,children:d(a===`project`?`createAndOpenProject`:`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{v(!1),b(``),S(null)},children:d(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>v(!0),children:[`+ `,d(a===`project`?`newProject`:`cwdNewFolder`)]}),x&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:x})]})]})]})}function Da({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z();return e?(0,X.jsx)(Ea,{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 Oa(e){return D({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 ka(e){return D({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 Aa(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 ja(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,m.useRef)(null),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(i);(0,m.useLayoutEffect)(()=>{p.current=i});let h=()=>{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},g=()=>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=g(),i=r&&r.isConnected?r.getBoundingClientRect():h();if(!i)return;let a=Aa(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,m.useLayoutEffect)(()=>{t?_():f(null)},[t,n,r,o,s,c,l]),At(()=>{p.current()},t),(0,m.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||g()?.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 Ma({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=wn(),{panelRef:d,style:f,measure:p}=ja({anchor:e,anchorEl:t,onClose:l}),[,h]=(0,m.useState)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null),y=(0,m.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,m.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,k.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)(st,{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&&g.current&&(n.preventDefault(),v(e.id))},onDrop:t=>{t.preventDefault(),x(t.dataTransfer.getData(`text/plain`)||g.current,e.id),g.current=null,h(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=>{h(e.id),g.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:()=>{g.current=null,h(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)(K,{"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)(ni,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(st,{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)(ka,{"aria-hidden":!0}):(0,X.jsx)(Oa,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(H,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Na({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=wn(),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(``);async function d(){try{let e=await fetch(sn(nn(`/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,m.useEffect)(()=>{d()},[]);async function f(e){u(e),c(``);try{let t=await fetch(sn(nn(`/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(sn(nn(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);gn(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)(ke,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(N,{})})]}),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)(ze,{}),(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)(G,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var Pa=`xing-shuyin/pi-web-ui`,Fa={state:`idle`,version:null,percent:0,message:null};function Ia(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function La(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:Ia(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 Ra(e){if(!kn(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 za(e){return e instanceof Error?e.message:String(e)}function Ba(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${Pa}/releases/tag/v${t}`:`https://github.com/${Pa}/releases/latest`}function Va(){let[e]=(0,m.useState)(()=>Ra()),[t,n]=(0,m.useState)(Fa);(0,m.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>La(t,e)))},[e]);let r=(0,m.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:za(e)}))))},[e]),i=(0,m.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:za(e)}))))},[e]),a=(0,m.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:za(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}var Ha={name:`@earendil-works/pi-coding-agent`,kind:`pi-core`,current:``,latest:null,upToDate:!1};function Ua({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=ja({open:t,anchor:e,onClose:n});return(0,m.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,k.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Wa(){let[e,t]=(0,m.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,m.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 Ga({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:h,onSoundChange:g,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x,onOpenIconEdit:S}){let{locale:C,setLocale:w,t:T,packs:E}=wn(),[D,O]=(0,m.useState)(!1),[k,A]=(0,m.useState)(!1),[j,ee]=(0,m.useState)(null),M=ha(`cwd`),N=ha(`workspaceRoots`),F=ga(),I=(0,m.useRef)(null),L=t=>!e.tabs||t===`chat`||e.tabs.includes(t),te=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!mi(e)),R=new Set([...i??[],...a??[]].filter(e=>mi(e)&&!e.hidden).map(e=>e.source.slice(7))),z=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),re=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(z.get(`${e.id}:__view`)??1e6+e.index)-(z.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),ie=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})),V=(L(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!ie.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:[]})),ae=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`}),Qn(),!0;case`host:new-ephemeral-chat`:return c(`chat`),$({type:`new_chat`,ephemeral:!0}),Qn(),!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(I.current?{rect:I.current.getBoundingClientRect(),el:I.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??[]];Wi({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:oe}=ma(),se=_a(),ce=va(),[G,ue]=(0,m.useState)(!1);(0,m.useEffect)(()=>{G&&e.status===`open`&&ue(!1)},[G,e.status]);let[de,fe]=(0,m.useState)(!1),[pe,me]=(0,m.useState)(!1),[he,ge]=(0,m.useState)(!1),[_e,ye]=(0,m.useState)(!1),be=kn(),xe=Va(),[Se,Ce]=(0,m.useState)(!1),we=()=>{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:St(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),ye(!1),c(`terminal`)},Ee=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:bt(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:St(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),ye(!1),c(`terminal`)},q=e.updatesAll??[],J=e.updatesSdk,De=J&&J.newerInstalled?{running:J.running,installed:J.newerInstalled}:null,Oe=J?.bundledInUse===!0,Y=q.find(e=>e.kind===`pi-core`&&!e.error),Pe=Oe&&(!Y||!Y.upToDate),Fe=Pe&&!Y,Ie=q.filter(e=>!e.upToDate&&!e.error).length,Le=q.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Be=e=>e.kind===`git-extension`&&e.source?e.source:e.name,Ve=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,He=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},Ue=(e,t)=>{if(!t)return He(e);let n=He(e),r=He(t);return n===r?n:`${n} → ${r}`},We=()=>(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`)}):q.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:q.map(e=>{let t=De!=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:()=>Ee([e],T(`updatePkgTabTitle`,{name:e.name})),children:T(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:Ve(e),children:Be(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?He(e.current):Ue(e.current,e.latest):e.kind===`plugin`?e.upToDate?e.current.startsWith(`v`)?e.current:He(e.current):Ue(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:De.running})})]})]},`${e.kind}:${e.name}`)})}),De&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`piSdkSplitNote`,{running:De.running,installed:De.installed})}),Pe&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`piSdkBundledNote`,{running:J.running})}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[Fe&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ee([Ha],T(`installGlobalEngineTabTitle`)),children:T(`installGlobalEngineBtn`)}),Le.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Ee(Le,T(`updateAllTabTitle`)),children:T(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:Le.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:T(`updatesAllRefresh`)})]})]}),Ge=()=>{let t=Ba(e.update?.latest??xe.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:T(`updateDesktopManual`)});if(!xe.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopNoBridge`)}),n]});switch(xe.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:xe.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>xe.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:xe.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:()=>xe.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:xe.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>xe.check(),children:T(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>xe.check(),children:T(`updateDesktopCheck`)}),n]})}},Ke=()=>(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&&!be&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&be&&(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&&!be&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:we,children:T(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&be&&Ge(),ce&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:G,title:T(`restartServiceTip`,{name:ce.name}),onClick:()=>{G||(ue(!0),$({type:`restart_service`}))},children:T(G?`restartingService`:`restartService`)})]})]}),qe=Wa(),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)(Ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`openProject`)})]}),"host:history":n===`chat`&&L(`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)(K,{})}):null,"host:files":n===`chat`&&L(`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)(Me,{}),(0,X.jsx)(`span`,{children:T(`openFiles`)})]}):null,"host:new-chat":L(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":T(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),Qn()},children:[(0,X.jsx)(le,{}),(0,X.jsx)(`span`,{children:T(`newChat`)})]}):null,"host:new-ephemeral-chat":F?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}),Qn()},children:[(0,X.jsx)(yt,{}),(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)(ve,{}),(0,X.jsx)(`span`,{children:T(`chat`)})]}),"host:terminal":L(`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)(ne,{}),(0,X.jsx)(`span`,{children:T(`terminal`)})]}):null,"host:git":L(`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)(je,{}),(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)(st,{"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)(W,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(tr,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":T(`bgTasksTip`),onClick:f,children:[(0,X.jsx)(Te,{}),(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)(H,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`settings`)})]}),"host:sound":(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(P,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`sound`)})]}),tip:T(`sound`),open:de,onOpenChange:fe,children:[(0,X.jsx)(En,{settings:h,onChange:g,onPreview:_}),(0,X.jsx)(qr,{})]}),"host:language":(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:_n(C)})]}),tip:T(`language`),open:pe,onOpenChange:me,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`language`)}),E.map(e=>(0,X.jsx)(Nt,{active:C===e.code,onClick:()=>{w(e.code),me(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(Nt,{onClick:()=>{me(!1),Ce(!0)},children:[(0,X.jsx)(ze,{}),` `,T(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(Mt,{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:he,onOpenChange:e=>{ge(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)(Nt,{active:y===e.id,onClick:()=>{b(e.id),ge(!1)},children:n(e)},e.id))]}),(0,X.jsx)(`div`,{className:`dd-header`,children:e.length>0?T(`themeGroupBuiltin`):T(`theme`)}),(0,X.jsx)(Nt,{active:y===null,onClick:()=>{b(null),ge(!1)},children:T(`themeDefault`)}),t.map(e=>(0,X.jsx)(Nt,{active:y===e.id,onClick:()=>{b(e.id),ge(!1)},children:n(e)},e.id))]})})()}),"host:update":se?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":T(`updatesManaged`),children:[(0,X.jsx)(ze,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,oe??e.update?.current??`…`]})]}):(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ze,{}),(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??``})}),Ie>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:T(`updatesAllBadge`,{n:Ie})})]}),tip:T(`update`),open:_e,onOpenChange:e=>{ye(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`update`)}),Ke(),We()]}),"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)(Ae,{})}),"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)(Me,{}),(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)&&!L(e.slice(5)),Qe=e=>{if(e.kind===`view`){if(!L(`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)(ni,{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)(ni,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},$e=[];for(let e of ie){if(e.entry?.hidden||Ze(e.id))continue;let t=e.id.startsWith(`host:`)?Je[e.id]??null:e.entry?Qe(e.entry):null;t&&$e.push({id:e.id,entry:e.entry,node:t})}for(let e of V){let t=Qe(e);t&&$e.push({id:e.id,entry:e,node:t})}let et=e=>e.entry?.align??`start`,[tt,nt]=(0,m.useState)(()=>new Set),rt=(0,m.useRef)(null),it=(0,m.useRef)(new Map),at=$e.filter(e=>!tt.has(e.id)),ot=qe?at.filter(e=>Ri.has(e.id)):[],ct=qe?at.filter(e=>!Ri.has(e.id)):at,lt=qe?$e.filter(e=>!Ri.has(e.id)):$e,ut=[...lt.filter(e=>et(e)===`start`),...lt.filter(e=>et(e)===`center`),...lt.filter(e=>et(e)===`end`)],dt=ut.filter(e=>!tt.has(e.id)),ft=(0,m.useRef)(ut),pt=(0,m.useRef)(dt);(0,m.useLayoutEffect)(()=>{ft.current=ut,pt.current=dt});let mt=()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`)),n=pt.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=ft.current,a=Bi(i.map(e=>({id:e.id,width:e.entry?it.current.get(e.id)??0:0})),e.clientWidth,r,0,di);nt(e=>e.size===a.size&&[...a].every(t=>e.has(t))?e:a)},ht=`${at.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${qe?`m`:`d`}`;(0,m.useLayoutEffect)(mt,[ht]),(0,m.useEffect)(()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>mt());return t.observe(e),()=>t.disconnect()},[ht]);let gt=ct.filter(e=>et(e)===`start`),_t=ct.filter(e=>et(e)===`center`),vt=ct.filter(e=>et(e)===`end`),xt=$e.filter(e=>tt.has(e.id)&&e.entry).map(e=>e.entry),Ct=new Map;[...i??[],...a??[]].forEach((e,t)=>{Ct.has(e.id)||Ct.set(e.id,t)});let wt=zi([...te,...xt],e=>Ct.get(e)??999999),Tt=e=>e.icon&&!/[a-z]/i.test(e.icon)?e.icon:null,Et=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${Et?` 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)(m.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)(m.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)(m.Fragment,{children:e.node},e.id))]}),(wt.length>0||$e.length>0)&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:I,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":D,"data-tip":T(`pluginTopbarMore`),onClick:()=>O(e=>!e),children:`⋯`}),(0,X.jsxs)(Ua,{anchorRef:I,open:D,onClose:()=>O(!1),children:[wt.map(e=>{let t=e.source===`host`&&Xe.has(e.id)?Je[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(m.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)(Ae,{}),(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:[Tt(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:Tt(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),ae(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),ae(e)||s?.(e)},children:[Tt(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:Tt(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)(`span`,{className:`plugin-icon-glyph`,children:(0,X.jsx)(Re,{})}),(0,X.jsx)(`span`,{className:`tb-row-text`,children:T(`uiIconEdit`)})]})]})]}),ot.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id)),Se&&(0,X.jsx)(Na,{onClose:()=>Ce(!1)}),j&&(0,X.jsx)(Ma,{anchorRect:j.rect,anchorEl:j.el,plugins:r,pinnedIds:R,orderedPluginIds:re,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:hi(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:gi(e.settings?.uiLayout,t)}),onOpenView:e=>{ee(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>ee(null)}),k&&(0,X.jsx)(Da,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:N,onClose:()=>A(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Ka(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 qa(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 Ja(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 Ya(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 Xa(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}}function Za(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 Qa=null,$a=new Set;function eo(){for(let e of $a)e()}function to(e){let t=(e??``).trim();t&&(Qa={name:t,status:`loading`},eo(),$({type:`get_tool_info`,name:t}))}function no(){Qa!==null&&(Qa=null,eo())}function ro(e){Qa!==null&&Qa.name===e.name&&(Qa=Za(e),eo())}function io(e){return $a.add(e),()=>{$a.delete(e)}}function ao(){return Qa}function oo(){return(0,m.useSyncExternalStore)(io,ao,ao)}var so=Object.freeze({status:`idle`,messages:[]}),co=new Map,lo=new Set,uo=16;function fo(){for(;co.size>uo;){let e=co.keys().next().value;if(e===void 0)break;co.delete(e)}}function po(){for(let e of lo)e()}function mo(e,t){let n=(e??``).trim();if(!n)return;let r=co.get(n);(!r||r.status!==`loading`&&r.status!==`ready`)&&(co.set(n,{status:`loading`,messages:r?.messages??[]}),fo(),po(),$({type:`get_compacted_messages`,compactionMessageId:n,conversationId:t}))}function ho(e){let t=e.compactionMessageId;t&&(e.error?co.set(t,{status:`error`,messages:[],error:e.error}):co.set(t,{status:`ready`,messages:e.messages??[]}),fo(),po())}function go(e){let t=co.get(e);return t?(co.delete(e),co.set(e,t),t):so}function _o(e){return lo.add(e),()=>{lo.delete(e)}}function vo(e){return(0,m.useSyncExternalStore)(_o,()=>go(e),()=>so)}var yo=`__piWebUiHost`,bo=e=>new Promise(t=>setTimeout(t,e));async function xo(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 bo(100)}}var So=Promise.resolve(),Co=0;function wo(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 bo(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=Co>0?So.then(i):i(),Co++,So=o.then(()=>{Co--},()=>{Co--}),o.catch(()=>{}),!0},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>es(e)},compose(e){return $n()?er({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=ko,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=ko,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=St();return new Promise(t=>{let a=setTimeout(()=>{cs.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));cs.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 jo(Do,String(e??``).trim(),t)},onTopbarAction(e,t){return jo(Do,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(kn())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 xo(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(No,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>Vo(String(e??``),t)},searchProviders:{register:e=>Uo(e),list:()=>Wo()},composerProviders:{register:e=>Ko(e),list:()=>qo()},onTheme:e=>ns(e),onLocale:e=>rs(e),onViewChange:e=>is(e)}}function To(e){try{let t=window;e?t[yo]=e:delete t[yo]}catch{}}var Eo=new Map,Do=null;async function Oo(e,t){let n=Do;Do=e;try{return await t()}finally{Do=n}}var ko=void 0;function Ao(e,t){let n=ko;ko=e;try{return t()}finally{ko=n}}function jo(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=Eo.get(r);i||(i=new Set,Eo.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&Eo.delete(r)}}async function Mo(e,t,n,r){let i=i=>{let a=Eo.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{Ao(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 No=`pi-web-ui:toast`,Po=new Map,Fo=!1;function Io(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 Lo(){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 Ro(e){try{if(Lo())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=Po.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function zo(){if(!Fo)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,Ro),Fo=!0}catch{}}function Bo(){if(!(Po.size>0||!Fo))try{window.removeEventListener(`keydown`,Ro)}catch{}finally{Fo=!1}}function Vo(e,t){if(typeof t!=`function`)return()=>{};let n=Io(e);if(!n)return()=>{};let r=Po.get(n.combo);r||(r=new Set,Po.set(n.combo,r));let i=r;return i.add(t),zo(),()=>{i.delete(t),i.size===0&&Po.delete(n.combo),Bo()}}var Ho=new Map;function Uo(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 Ho.set(t,n),()=>{Ho.get(t)===n&&Ho.delete(t)}}function Wo(){return[...Ho.values()].map(e=>({id:e.id,label:e.label}))}var Go=new Map;function Ko(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 Go.set(t,n),()=>{Go.get(t)===n&&Go.delete(t)}}function qo(){return[...Go.values()].map(e=>({id:e.id,label:e.label}))}function Jo(e){return Go.get(String(e??``))}function Yo(e){return Ho.get(String(e??``))}var Xo=new Set,Zo=new Set,Qo=new Set,$o=new Set;function es(e){return $o.add(e),()=>{$o.delete(e)}}function ts(e){for(let t of[...$o])try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function ns(e){return typeof e==`function`?(Xo.add(e),()=>{Xo.delete(e)}):()=>{}}function rs(e){return typeof e==`function`?(Zo.add(e),()=>{Zo.delete(e)}):()=>{}}function is(e){return typeof e==`function`?(Qo.add(e),()=>{Qo.delete(e)}):()=>{}}function as(e){let t=String(e??``);for(let e of[...Xo])try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function os(e){let t=String(e??``);for(let e of[...Zo])try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function ss(e){let t=String(e??``);for(let e of[...Qo])try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var cs=new Map;function ls(e){let t=cs.get(e.requestId);if(t){if(cs.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 us=`modulepreload`,ds=function(e){return`/`+e},fs={},ps=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=ds(t,n),t=s(t),t in fs)return;fs[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`:us,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)})},ms=`pi-web-ui:plugin-data`;function hs(e,t){window.dispatchEvent(new CustomEvent(ms,{detail:{pluginId:e,payload:t}}))}function gs(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(ms,t),()=>window.removeEventListener(ms,t)}var _s=new Map,vs=new Set,ys=new Set,bs=new Set,xs=new Set,Ss=-1;function Cs(){return[..._s.values()]}function ws(){let e=Cs();for(let t of ys)t(e)}function Ts(){let e=[...bs];for(let t of xs)t(e)}function Es(e){return xs.add(e),e([...bs]),()=>xs.delete(e)}async function Ds(e,t){bs.delete(e.id),ks.set(e.id,(ks.get(e.id)??0)+1),Ts();let n=await Ps(e,t);return ws(),n}function Os(e){return ys.add(e),e(Cs()),()=>ys.delete(e)}var ks=new Map;function As(e,t){let n=ks.get(e)??0;return nn(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function js(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>Oo(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var Ms=js(e=>ps(()=>import(e),[]));async function Ns(e,t){if(!e.hasClient||e.error)return null;try{return(await Ms(e.id,As(e.id,t))).default??null}catch(t){return console.error(`[plugin:${e.id}] 客户端 bundle 加载失败:`,t),null}}async function Ps(e,t){try{let n=(await Ms(e.id,As(e.id,t))).default;return n&&typeof n.mount==`function`?(_s.set(e.id,{info:e,module:n}),!0):e.preload?(vs.add(e.id),!0):(bs.add(e.id),Ts(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return bs.add(e.id),Ts(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function Fs(e,t){if(_s.has(e.id)||vs.has(e.id))return!0;if(bs.has(e.id)||!e.hasClient)return!1;let n=await Ps(e,t);return ws(),n}async function Is(e,t){t!==Ss&&(Ss=t,_s.clear(),vs.clear(),bs.clear(),ks.clear(),Ts());let n=new Set(e.map(e=>e.id));for(let e of[..._s.keys()])n.has(e)||_s.delete(e);for(let e of[...vs])n.has(e)||vs.delete(e);for(let e of[...bs])n.has(e)||bs.delete(e);Ts(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!_s.has(e.id)&&!vs.has(e.id)&&!bs.has(e.id)).map(e=>Ps(e,t))),ws()}function Ls(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>gs((n,r)=>{n===e&&t(r)})}}var Rs=[`debug`,`info`,`warn`,`error`];function zs(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function Bs(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function Vs(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`&&Rs.includes(String(e.level)))}var Hs=new Map,Us=new Set;function Ws(){for(let e of[...Us])try{e()}catch{}}function Gs(e){return Us.add(e),()=>Us.delete(e)}function Ks(e){return(Hs.get(e)??[]).map(e=>({...e}))}function qs(e,t){return Vs(t)?(Hs.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),Ws(),!0):!1}function Js(){return{flows:[],results:{}}}function Ys(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 Xs(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:Ys(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:Ys(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 Zs=`pi-web-ui:lang`;function Qs(){try{return(localStorage.getItem(Zs)??``).trim()}catch{return``}}var $s=`pi-web-ui:locale`,ec=2e5,tc=2e5,nc=`LIVE_OMIT`,rc={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 ic(){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>tc?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 ac(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 oc(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 sc(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!==22};case`snapshot`:{let n=e.state?.cwd,r=t.state.cwd,i=e.sessions;return r&&r!==n&&(i=xc(r)),{...e,ready:!0,state:t.state,sessions:i,approval:t.state.pendingApproval??null,activeConversationId:t.state.conversationId,liveOutputs:ac(e.liveOutputs,t.state),toolStatuses:oc(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:ac(e.liveOutputs,i),toolStatuses:oc(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>ec?`…[${nc}:${n.length-ec}]…\n`+n.slice(n.length-ec):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:Ya(n,t.msg)}}case`tool_status`:return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case`notice`:return{...e,notices:[...e.notices,t.notice].slice(-6)};case`dismiss_notice`:return{...e,notices:e.notices.filter(e=>e.id!==t.id)};case`sessions`:return Sc(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 _c(t.projects),{...e,projects:t.projects};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=Xs({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`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||t.conversationId&&t.conversationId!==n.conversationId)return e;let r={...n,plan:t.plan};return{...e,state:r}}case`settings`:return{...e,settings:t.settings};case`bg_servers`:return{...e,bgServers:t.servers};case`scheduler_tasks`:return{...e,schedulerTasks:t.tasks};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`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};default:return e}}var cc=`pi-web-client-id`,lc=null;function uc(){if(lc)return lc;let e=null;try{e=sessionStorage.getItem(cc),e||(e=St(),sessionStorage.setItem(cc,e))}catch{e??=St()}return lc=e,e}var dc=`pi-web-last-cwd`;function fc(){try{return localStorage.getItem(dc)}catch{return null}}function pc(e){try{localStorage.setItem(dc,e)}catch{}}function mc(e){try{let t=localStorage.getItem(dc);if(!t)return;let n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase();(t===e||n(t)===n(e))&&localStorage.removeItem(dc)}catch{}}var hc=`pi-web-recent-projects`;function gc(){try{let e=localStorage.getItem(hc);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function _c(e){try{localStorage.setItem(hc,JSON.stringify(e.slice(0,20)))}catch{}}function vc(e){try{let t=gc(),n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),r=n(e);_c(t.filter(e=>n(e.path)!==r))}catch{}}var yc=`pi-web-recent-sessions:`;function bc(e){return e?`${yc}${e.trim().replace(/[\\/]+$/,``).toLowerCase()}`:`pi-web-recent-sessions:default`}function xc(e){try{let t=bc(e??fc()),n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function Sc(e,t){try{let n=bc(e??fc());localStorage.setItem(n,JSON.stringify(t.slice(0,50)))}catch{}}function Cc(e,t){try{let n=xc(t),r=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),i=r(e);Sc(t,n.filter(e=>r(e.path)!==i))}catch{}}function wc(){return sn(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${nn(`/ws`)}`)}function Tc(){let[e,t]=(0,m.useReducer)(sc,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:xc(),conversations:[],elsewhere:[],activeConversationId:``,projects:gc(),files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:Js().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,updatesSdk:null,widgets:[],statuses:[],dialog:null,approval:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:rc,bgServers:[],schedulerTasks:[],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,installInspect:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,dshPresets:null,dshPermission:null,protocolMismatch:!1}),n=(0,m.useRef)(null),r=(0,m.useRef)(ic()),i=(0,m.useRef)(0),a=(0,m.useRef)(null),o=(0,m.useRef)(!0),s=(0,m.useRef)(0),c=(0,m.useRef)(0),l=(0,m.useRef)(new Map),u=(0,m.useRef)(null),d=(0,m.useRef)(!1),f=(0,m.useRef)(null),p=(0,m.useRef)(new Set),h=(0,m.useRef)(`live`),g=()=>{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)&&g()}n.set(e,t)},v=(0,m.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]),y=(0,m.useCallback)(e=>{let r=n.current;if(r&&r.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`}),r.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)}h.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,m.useCallback)((e,n)=>{let r=Xa({current:O.current.chat.question,source:h.current,snapshot:e,answered:p.current,activeConversationId:n});r.changed&&(h.current=r.source,t({type:`question`,question:r.question}))},[]);ba(y);let x=(0,m.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(wc());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:uc(),locale:Qs()})))},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!==`20261002T22482`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}da({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;(!e||e.conversationId!==a.conversationId||e.rev!==a.baseRev)&&g(),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;t({type:`notice`,notice:{id:e,level:a.level,text:a.text,textEn:a.textEn}});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`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`:ro(a);break;case`compacted_messages_result`:ho(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`question_pending`:h.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)}h.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`bg_servers`:t({type:`bg_servers`,servers:a.servers});break;case`scheduler_tasks`:t({type:`scheduler_tasks`,tasks:a.tasks});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===uc()&&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`:ls(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`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`:qs(a.pluginId,a.payload)||hs(a.pluginId,a.payload)}},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,m.useEffect)(()=>{let e=e=>{let t=e.detail??Qs();t&&y({type:`set_locale`,locale:t})};return window.addEventListener($s,e),()=>window.removeEventListener($s,e)},[y]),(0,m.useEffect)(()=>{let n=n=>{let r=e.state?.cwd;r&&n.key&&n.key===bc(r)&&t({type:`sync_cached_sessions`,sessions:xc(r)})};return window.addEventListener(`storage`,n),()=>window.removeEventListener(`storage`,n)},[e.state?.cwd]),(0,m.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);return()=>{o.current=!1,clearInterval(e),a.current&&=(clearTimeout(a.current),null),n.current?.close(),n.current=null}},[x]),(0,m.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=fc();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}f.current!==t&&(f.current=t,pc(t))}},[e.state?.cwd,y]),(0,m.useEffect)(()=>{da({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,m.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,m.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,m.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,m.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,m.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,m.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,m.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 Ec(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 Dc(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 Oc=`pi-web-ui:lp-collapse-projects`,kc=`pi-web-ui:lp-collapse-convs`,Ac=`pi-web-ui:lp-collapse-sessions`;function jc(e,t=!1){let[n,r]=(0,m.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,m.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var Mc=`pi-web-ui:lp-sizes`,Nc={projects:1,convs:1,sessions:1},Pc=32,Fc=72;function Ic(){try{return Ka(localStorage.getItem(Mc),Nc)}catch{return{...Nc}}}var Lc=(0,m.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,onUiAction:p,presetNames:h}){let g=Z(),_=e,v=ha(`ready`),y=ha(`status`),b=ha(`cwd`),x=ha(`workspaceRoots`),S=b,[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(null),[D,O]=(0,m.useState)(null),[k,A]=(0,m.useState)(null),[j,ee]=(0,m.useState)(``),[M,P]=jc(Oc,!1),[F,I]=jc(kc,!1),[L,te]=jc(Ac,!1),z=(0,m.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]),ne=(0,m.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},[]),re=(0,m.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},[]),B=(0,m.useRef)(null),ie=(0,m.useRef)(null),V=(0,m.useRef)(()=>{}),ae=ta(d??[]).length>0,H=(0,m.useCallback)((e,n,i)=>{B.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=z(t,a),l=c===0?g(`noFinishedSubagents`):g(a?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:c}),u=!!a&&ie.current===a;Wi({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:g(`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:g(`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:g(`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:g(`saveEphemeral`)}:e}return e.id===`host:conv-copy-id`?s?e:{...e,hidden:!0}:e.id===`host:conv-copy-path`?i.kind===`history`?e:a?t.some(e=>e.id===a&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0}:e.id===`host:conv-quote`?s||i.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>V.current(e,t)})},[d,t,z,g]);V.current=(0,m.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=B.current;if(!i||!e)return;if(ie.current!==i)return ie.current=i,H(e.x,e.y,e.target),!0;ie.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-quote`){n.kind===`history`&&n.id?er({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&er({attachments:[{path:``,key:`conv|${a}|`,name:n.label||a,mode:`conversation`,conversationId:a}]});return}if(e.id===`host:conv-rename`){if(E(null),i){let e=t.find(e=>e.id===i);ee(e?.title??n.label??``),A(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);ee(e?.name??n.label??``),A(n.id)}return}},[o,H,t,r]);let U=()=>{let e=f??[];return e.length===0?null:(0,X.jsx)(`span`,{className:`lp-slot-sessions`,children:e.map((e,t)=>{let n=`${e.id}#${t}`,r=e.label||e.id,i=e.hint||r;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`lp-slot-divider`,"aria-hidden":`true`},n):e.kind===`badge`?(0,X.jsx)(`span`,{className:`lp-slot-badge`,title:i,children:e.badge??r},n):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`lp-slot-select`,title:i,"aria-label":r,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onClick:e=>e.stopPropagation(),onChange:t=>{t.stopPropagation(),p?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},n):(0,X.jsx)(`button`,{type:`button`,className:`lp-slot-btn`,title:i,"aria-label":r,onClick:t=>{t.stopPropagation(),p?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:r})},n)})})},W=(0,m.useCallback)((e,t)=>{Dc(e.target)||ae&&(e.preventDefault(),e.stopPropagation(),ie.current=null,H(e.clientX,e.clientY,t))},[ae,H]),oe=(0,m.useRef)(null),[se,ce]=(0,m.useState)(()=>Ic());(0,m.useEffect)(()=>{try{localStorage.setItem(Mc,JSON.stringify(se))}catch{}},[se]);let G=[...t,...n.map((e,t)=>({id:`elsewhere:${e.cwd}:${e.title}:${t}`,title:e.title,cwd:e.cwd,messageCount:0,isStreaming:e.isStreaming,isSubagent:!1,elsewhere:!0,pseudo:!!e.pseudo,...e.owner&&e.convId?{owner:e.owner,convId:e.convId}:{},...e.hasQuestion?{hasQuestion:!0}:{}}))],ue=(0,m.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,a=n.clientY,o={...se},s=oe.current;if(!s)return;let c=[{key:`projects`,visible:i.length>0,collapsed:M},{key:`convs`,visible:G.length>0,collapsed:F},{key:`sessions`,visible:!0,collapsed:L}].filter(e=>e.visible),l=c.filter(e=>e.collapsed).length,u=c.filter(e=>!e.collapsed).map(e=>e.key).reduce((e,t)=>e+(o[t]??1),0)||1,d=Math.max(120,s.clientHeight-l*Pc);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let f=n=>{let{above:r,below:i}=qa({start:{above:o[e]??1,below:o[t]??1},deltaPx:n.clientY-a,availablePx:d,totalWeight:u,minAbovePx:Fc,minBelowPx:Fc});ce(n=>({...n,[e]:r,[t]:i}))},p=()=>{window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),r.classList.remove(`dragging`),document.body.classList.remove(`lp-resizing`)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p)},[se,i.length,G.length,M,F,L]);(0,m.useEffect)(()=>{s&&v&&y===`open`&&b&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,v,y,b,o]);let de=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:g(`emptyChat`)},fe=e=>e.split(/[\\/]/).pop()||e,me=(e,t,n,r,i)=>{let a=T===e;return(0,X.jsx)(`button`,{type:`button`,className:`lp-del ${a?`confirm`:``}`,title:a?n:t,onClick:t=>{t.stopPropagation(),a?(E(null),r()):E(e)},children:a?(0,X.jsx)(it,{}):i??(0,X.jsx)(R,{})})},he=(e,t,n,r,i)=>(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:g(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)(rt,{}):(0,X.jsx)(et,{})})]}),i?(0,X.jsx)(`div`,{className:`lp-section-actions`,children:i}):null]}),ge=[{key:`projects`,visible:i.length>0,collapsed:M},{key:`convs`,visible:G.length>0,collapsed:F},{key:`sessions`,visible:!0,collapsed:L}].filter(e=>e.visible).filter(e=>!e.collapsed),_e=ge.reduce((e,t)=>e+(se[t.key]??1),0)||1,K=e=>ge.length<=1?1:(se[e]??1)/_e*ge.length;return(0,X.jsxs)(`aside`,{ref:oe,className:`panel panel-left lp-panel`,children:[c&&l&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:g(`collapsePanel`),onClick:l,children:(0,X.jsx)($e,{})}),(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${M||i.length===0?`collapsed`:``}`,style:i.length>0&&!M?{flex:`${K(`projects`)} 1 0px`}:void 0,children:[he(g(`recentProjects`),M,P,i.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action`,title:g(`manageProjects`),"aria-label":g(`manageProjects`),onClick:()=>w(!0),children:(0,X.jsx)(Ne,{})})),i.length>0&&!M&&(0,X.jsx)(`div`,{className:`lp-section-body projects-scroll`,children:i.map(e=>{let t=S===e.path;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>E(t=>t===`proj:${e.path}`?null:t),children:[(0,X.jsxs)(`button`,{type:`button`,className:`project-item ${t?`active`:``}`,title:e.path,onClick:()=>{t||o({type:`set_cwd`,path:e.path})},children:[(0,X.jsx)(Me,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsx)(`span`,{className:`project-name`,children:fe(e.path)}),(0,X.jsx)(`span`,{className:`project-path`,children:e.path})]}),(0,X.jsx)(`span`,{className:`project-time`,children:Ec(e.lastUsed)})]}),me(`proj:${e.path}`,g(`deleteProject`),g(`deleteProjectConfirm`),()=>{mc(e.path),vc(e.path),o({type:`remove_project`,path:e.path})})]},e.path)})})]}),i.length>0&&!M&&(G.length>0?!F:!L)&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`projects`,G.length>0?`convs`:`sessions`),onDoubleClick:()=>ce({...Nc}),title:g(`dragToResize`)}),G.length>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${F?`collapsed`:``}`,style:F?void 0:{flex:`${K(`convs`)} 1 0px`},onContextMenu:e=>W(e,{id:``,kind:`section`,label:g(`runningConversations`)}),children:[he(g(`runningConversations`),F,I,G.length),!F&&(0,X.jsx)(`div`,{className:`lp-section-body convs-scroll`,children:Ja(G,b,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,children:fe(e.cwd)}),(()=>{let n=new Map(e.convs.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e.convs)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 s=[],c=new Set,l=(e,t)=>{if(!c.has(e.id)){c.add(e.id),s.push({c:e,depth:t});for(let n of r.get(e.id)??[])l(n,t+1)}};for(let e of i)l(e,0);for(let t of e.convs)l(t,0);return s.map(({c:n,depth:r})=>{if(n.elsewhere){let e=n.owner,t=n.convId,r=!!n.pseudo,i=!!(e&&t)&&!r,a=D===n.id,s=a?g(`takeoverConfirm`):r?`${g(`elsewherePseudoTip`)}\n${n.cwd}`:`${g(`elsewhereTip`)}\n${n.cwd}`;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>O(e=>e===n.id?null:e),onContextMenu:i=>W(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${i?``:` elsewhere-static`}${a?` confirm`:``}`,title:s,tabIndex:i?0:-1,onClick:i?()=>{if(!a){O(n.id);return}O(null),o({type:`take_over_conversation`,owner:e,id:t})}:void 0,children:[(0,X.jsx)(ve,{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:g(r?`elsewherePseudoBadge`:`elsewhereBadge`)}),n.hasQuestion&&e&&t&&!r&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:g(`takeoverHasQuestion`),onClick:n=>{n.stopPropagation(),o({type:`peek_elsewhere_question`,owner:e,id:t})},children:`?`}),a?g(`takeoverConfirm`):n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:fe(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]}),ae&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-elsewhere-act`,title:g(`elsewhereActions`),onClick:i=>{i.stopPropagation(),ie.current=null;let a=i.currentTarget.getBoundingClientRect();H(a.left,a.bottom+4,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}})},children:(0,X.jsx)(pe,{})})]},n.id)}let i=a===n.id;return(0,X.jsxs)(`div`,{className:`lp-row${r>0?` lp-sub`:``}`,style:r>0?{marginLeft:r*18}:void 0,onMouseLeave:()=>E(e=>e===`conv:${n.id}`?null:e),onContextMenu:e=>W(e,{id:n.id,kind:`running`,label:n.title}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${i?`active`:``}`,title:`${n.title}${e.isCurrent?``:` — ${e.cwd}`}`,onClick:()=>{i||o({type:`switch_conversation`,id:n.id})},children:[(0,X.jsx)(ve,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[k===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:j,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>ee(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=j.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),A(null)}else e.key===`Escape`&&A(null)},onBlur:()=>A(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:g(`subagentBadge`)}),n.isEphemeral&&(0,X.jsx)(`span`,{className:`ephemeral-badge`,children:g(`ephemeralBadge`)}),n.forkFrom&&(0,X.jsxs)(`span`,{className:`preset-badge fork-badge`,title:`${g(`forkBadgeTip`)}: ${n.forkFrom.title??n.forkFrom.conversationId}`,children:[`🌿 `,g(`forkBadge`)]}),n.agentPreset&&(0,X.jsx)(`span`,{className:`preset-badge`,title:n.agentPreset,children:h?.[n.agentPreset]??n.agentPreset}),n.title,n.error&&(0,X.jsx)(`span`,{className:`conv-error-badge`,title:g(`convErrorBadge`,{error:n.error})}),n.hasQuestion&&(0,X.jsx)(`span`,{className:`question-badge`,title:g(`waitingQuestionBadge`),children:`?`}),n.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:g(`pinnedConversation`),children:`📌`})]}),k===`conv:${n.id}`?null:(0,X.jsx)(`span`,{className:`session-sub`,children:i?g(`current`):g(`messageCount`,{n:n.messageCount})})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:e=>{e.stopPropagation(),E(null),ee(n.title),A(`conv:${n.id}`)},children:(0,X.jsx)(Re,{})}),(()=>{let e=`conv:${n.id}`,r=T===e,i=z(t,n.id),a=re(t,n.id),s=ne(t,n.id);return s===0&&!n.isStreaming?me(e,g(`dismissConversation`),g(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(N,{})):s===0?me(e,g(`dismissConversation`),g(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(N,{})):r?(0,X.jsxs)(`span`,{className:`lp-del-group`,children:[i>0&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt`,title:g(`dismissFinishedSubagentsScoped`,{n:i}),onClick:e=>{e.stopPropagation(),E(null),o({type:`dismiss_finished_subagents`,parentId:n.id})},children:g(`dismissFinishedOnly`,{n:i})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt danger`,title:g(`forceDismissTitle`,{n:s,m:a}),onClick:e=>{e.stopPropagation(),E(null),o({type:`dismiss_conversation`,id:n.id,force:!0})},children:g(`dismissForceAll`,{n:s})})]}):(0,X.jsx)(`button`,{type:`button`,className:`lp-del`,title:g(`dismissConversation`),onClick:t=>{t.stopPropagation(),E(e)},children:(0,X.jsx)(N,{})})})(),U(),n.isStreaming&&(0,X.jsx)(`span`,{className:`lp-row-stalled`,title:g(`streaming`),style:{position:`absolute`,right:28,top:`50%`,transform:`translateY(-50%)`}})]},n.id)})})()]},e.cwd))})]}),G.length>0&&!F&&!L&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`convs`,`sessions`),onDoubleClick:()=>ce({...Nc}),title:g(`dragToResize`)}),(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${L?`collapsed`:``}`,style:L?void 0:{flex:`${K(`sessions`)} 1 0px`},children:[he(g(`historySessions`),L,te,r.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-new-chat-action`,title:g(`newChatTip`),"aria-label":g(`newChat`),onClick:()=>{o({type:`new_chat`}),Qn()},children:(0,X.jsx)(le,{})})),!L&&(0,X.jsxs)(`div`,{className:`lp-section-body sessions-scroll`,children:[r.length===0&&(0,X.jsx)(`div`,{className:`panel-empty`,children:g(`noHistory`)}),r.map(e=>{let t=_===e.path;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>E(t=>t===`sess:${e.path}`?null:t),onContextMenu:t=>W(t,{id:e.path,kind:`history`,label:de(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${t?`active`:``}`,title:e.path,onClick:()=>{k||t||o({type:`switch_session`,path:e.path})},children:[(0,X.jsx)(ve,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[k===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:j,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>ee(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=j.trim();t&&o({type:`rename_session`,path:e.path,name:t}),A(null)}else t.key===`Escape`&&A(null)},onBlur:()=>A(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[de(e),e.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:g(`pinnedConversation`),children:`📌`})]}),k===e.path?null:(0,X.jsxs)(`span`,{className:`session-sub`,children:[t?g(`current`):g(`messageCount`,{n:e.messageCount}),e.source===`tui`&&(0,X.jsx)(`span`,{className:`session-src`,title:g(`tuiTip`),children:`TUI`})]})]}),(0,X.jsx)(`span`,{className:`session-time`,children:Ec(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:t=>{t.stopPropagation(),E(null),ee(e.name??``),A(e.path)},children:(0,X.jsx)(Re,{})}),me(`sess:${e.path}`,g(`deleteSession`),g(`deleteSessionConfirm`),()=>{Cc(e.path,S),o({type:`delete_session`,path:e.path})}),U()]},e.path)})]})]}),(0,X.jsx)(Da,{open:C,currentCwd:S,pathCompletions:u??[],workspaceRoots:x,onClose:()=>w(!1),onSelectDirectory:e=>o({type:`set_cwd`,path:e}),onCreateProject:e=>o({type:`make_dir`,path:e,setAsCwd:!0})})]})}),Rc=209715200,zc=/windows/i.test(navigator.userAgent),Bc=/[<>:"/\\|?*\u0000-\u001f]/g,Vc=/[. ]+$/,Hc=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Uc(e){let t=e.replace(Bc,`_`).replace(Vc,``);return t?Hc.test(t)?`_${t}`:t:`_`}function Wc(e,t=!0){return sn(nn(`/api/file?${new URLSearchParams({clientId:uc(),path:e,...t?{download:`1`}:{}})}`))}async function Gc(e,t){let n=zc?Uc(t):t;try{let t=await fetch(Wc(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`)>Rc)return window.location.assign(Wc(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?qc(r,n):Jc(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function Kc(e,t){let n=zc?Uc(t):t;return window.showSaveFilePicker&&window.isSecureContext?qc(e,n):Jc(e,n)}async function qc(e,t){let n,r=window.showSaveFilePicker;if(!r)return Jc(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:Jc(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 Jc(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 Yc(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 Xc(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function Zc({text:e}){let t=(0,m.useRef)(null),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.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,m.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=Yc(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,m.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=Yc(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,k.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 Qc=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function $c(e,t={}){let n={archive:nn(`/api/file-transfer/archive`),upload:nn(`/api/file-transfer/upload`)},r=new URL(sn(`${n[e]}?${new URLSearchParams({clientId:uc(),...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 el(e,t,n){let r=await fetch($c(`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 Kc(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function tl(){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 nl(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=$c(`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 rl({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,m.useState)(e.dir),[o,s]=(0,m.useState)(`skip`),[c,l]=(0,m.useState)([]),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),v=(0,m.useRef)(null);(0,m.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 tl();e?l(e):f.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),h(!0),_(``);try{e.action===`upload`?await nl(e.dir,c,d):await el(e.action,e.path,{destination:i,policy:o}),n(),t()}catch(e){_(e instanceof Error?e.message:String(e)),n()}finally{h(!1)}}return(0,k.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)(N,{})})]}),(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]})]}),g&&(0,X.jsx)(`p`,{role:`alert`,children:r(`fileTransferFailed`,{error:g})}),(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 il(e){return e instanceof Error?e.message:String(e)}function al(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 ol({plugin:e,epoch:t,send:n,className:r}){let i=(0,m.useRef)(null),{locale:a}=wn(),o=Z(),[s,c]=(0,m.useState)(null),l=(0,m.useRef)(n);(0,m.useEffect)(()=>{l.current=n},[n]),(0,m.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 Fs(e,t),r)return;let i=await Oo(e.id,()=>ps(()=>import(As(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,Ls(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:il(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:al(s,e.name,a,o)})]})}function sl(e){return`pi-web-ui:${e}:tab`}function cl(e,t){try{let n=localStorage.getItem(sl(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function ll(e,t){try{localStorage.setItem(sl(e),t)}catch{}}function ul(e){return e.length>0&&!/[a-z]/i.test(e)}function dl(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function fl({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,m.useId)(),[s,c]=(0,m.useState)(()=>cl(e,t)??t[0]?.id??``),l=(0,m.useRef)([]),u=(0,m.useRef)(``),d=t.findIndex(e=>e.id===s),f=d>=0?t[d]:t[0],p=f?t.indexOf(f):-1;(0,m.useEffect)(()=>{if(!f)return;s!==f.id&&c(f.id);let t=`${e}:${f.id}`;u.current!==t&&(u.current=t,ll(e,f.id))},[f,s,e]);let h=t=>{c(t.id),u.current=`${e}:${t.id}`,ll(e,t.id)},g=(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(),h(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??dl(e),"aria-selected":n,"aria-controls":`${o}-panel-${t}`,tabIndex:n?0:-1,ref:e=>{l.current[t]=e},onClick:()=>h(e),onKeyDown:e=>g(e,t),children:[e.iconSvg?(0,X.jsx)(ni,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&ul(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:dl(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)(ol,{plugin:f.pluginPage.plugin,epoch:n,send:r}):f.element??null})]})}function pl(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 ml(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return pl(e)}return pl(e)}function hl(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,m.useCallback)(()=>{s(),a(!1)},[s]);return(0,m.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,m.useCallback)(async e=>{let i=!1;try{i=await ml(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 gl=`@root`,_l=`pi-web-ui:rp-sizes`,vl={files:4,widgets:1},yl=120,bl=56;function xl(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var Sl=`files`,Cl=[],wl=()=>{};function Tl(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function El(e){return e===gl||e===`/`||/^[A-Za-z]:$/.test(e)}function Dl(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var Ol=(0,m.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 h=Z(),g=d??Cl,_=ha(`cwd`),v=ha(`workspaceRoots`),y=ha(`homeDir`),b=ha(`desktopDir`),[x,S]=(0,m.useState)(``),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(!1),D=(0,m.useRef)(null),O=(0,m.useRef)(null),[k,A]=(0,m.useState)(()=>{try{return Ka(localStorage.getItem(_l),vl)}catch{return{...vl}}});(0,m.useEffect)(()=>{try{localStorage.setItem(_l,JSON.stringify(k))}catch{}},[k]);let j=n.some(e=>e.lines.length>0),ee=(0,m.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-xl(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=qa({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:yl,minBelowPx:bl});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]),M=(0,m.useRef)(null),P=(0,m.useRef)(0),F=(0,m.useCallback)(e=>{M.current=e,e&&(e.scrollTop=P.current)},[]),[I,L]=(0,m.useState)(null),te=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{te.current&&clearTimeout(te.current)},[]);let R=(0,m.useCallback)(e=>{L(e),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>L(null),1200)},[]),z=(0,m.useCallback)((e,t)=>{e&&ml(e).then(e=>{e?R(t):o(`error`,h(`slashCopyFailed`))})},[R,o,h]),ne=(0,m.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},[_]),re=(0,m.useCallback)(e=>!e||e===gl?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),B=104857600,ie=(0,m.useCallback)((e,t)=>{for(let n of t){if(n.size>B){o(`warning`,h(`fileTooLarge`,{name:n.name,size:B/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,h]),V=(0,m.useRef)(null),[ae,H]=(0,m.useState)(null),U=(0,m.useRef)(null),W=(0,m.useCallback)(()=>{let e=V.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),oe=(0,m.useCallback)(()=>{U.current&&(U.current.value=``),U.current?.click()},[]),[se,ce]=(0,m.useState)(null),[G,le]=(0,m.useState)(null),[ue,de]=(0,m.useState)(``),[fe,pe]=(0,m.useState)(null),[me,he]=(0,m.useState)(``),ge=(0,m.useCallback)((e,t)=>{Gc(e,t).then(e=>{e.ok||e.cancelled||o(`error`,h(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?h(`fileNotFoundShort`):e.error}))})},[o,h]),_e=(0,m.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!El(e.id)&&(pe(null),de(e.label),le(e.id))},[]),ve=(0,m.useCallback)(()=>{if(!G)return;let e=ue.trim();le(null),e&&r({type:`file_rename`,path:G,newName:e})},[G,ue,r]),K=(0,m.useCallback)(e=>{let t=V.current?.dir??x;le(null),he(``),pe({dir:t,kind:e})},[x]),ye=(0,m.useCallback)(()=>{if(!fe)return;let e=me.trim();pe(null),e&&r({type:`file_create`,dir:fe.dir,name:e,kind:fe.kind})},[fe,me,r]),xe=(e,t,n,r)=>(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:e,placeholder:h(`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}),Se=(0,m.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!El(e.id)&&window.confirm(h(`fileDeleteConfirm`,{name:e.label}))&&(se?.src===e.id&&ce(null),G===e.id&&le(null),r({type:`file_delete`,path:e.id}))},[r,h,se,G]),Ce=(0,m.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!El(e.id)&&r({type:`file_copy`,src:e.id,destDir:Tl(e.id)})},[r]),Te=(0,m.useCallback)(e=>{let t=V.current?.target;t&&t.kind!==`list`&&!El(t.id)&&ce({src:t.id,cut:e})},[]),Ee=(0,m.useCallback)(()=>{if(!se)return;let e=V.current?.dir??x;se.cut?(r({type:`file_copy`,src:se.src,destDir:e,move:!0}),ce(null)):r({type:`file_copy`,src:se.src,destDir:e})},[se,r,x]),q=(0,m.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[J,De]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(!J)return;let e=e=>{e.target?.closest(`.root-picker`)||De(!1)},t=e=>{e.key===`Escape`&&De(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[J]);let Oe=(0,m.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),ke=(0,m.useCallback)(()=>{let e=V.current?.target;if(!e||e.kind!==`dir`)return;let t=re(e.id);t&&!v.includes(t)&&Oe([...v,t])},[v,re,Oe]),Ae=(0,m.useCallback)(e=>{ie(V.current?.dir??x,Array.from(e.target.files??[]))},[ie,x]),je=(0,m.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`;H({action:n,path:ne(t.id),dir:ne(n===`upload`?V.current?.dir??x:Tl(t.id))});break}case`host:file-open-project`:W();break;case`host:file-upload`:oe();break;case`host:file-add-root`:ke();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&We(t.id);break;case`host:file-download`:t?.kind===`file`&&ge(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`:K(`file`);break;case`host:file-new-dir`:K(`dir`);break;case`host:file-paste`:Ee();break;case`host:file-rename`:_e();break;case`host:file-duplicate`:Ce();break;case`host:file-cut`:Te(!0);break;case`host:file-copy`:Te(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&z(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&z(ne(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&z(t.id,`rel:${t.id}`);break;case`host:file-refresh`:q();break;case`host:file-delete`:Se()}},[W,x,oe,ke,a,i,z,ne,ge,K,Ee,_e,Ce,Te,q,Se]),Ne=(0,m.useCallback)((e,t)=>{let n=t.kind===`dir`?re(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&&El(t.id),l=!s&&Dl(t.id),d=x===gl,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&&Qc(t.label)?e:{...e,hidden:!0};case`host:file-upload`:return d?{...e,hidden:!0}:{...e,label:r.dir===x?h(`uploadToCurrentDir`):h(`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!==gl?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&&se?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}});ta(f).length!==0&&(e.preventDefault(),e.stopPropagation(),V.current=r,Wi({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:je}))},[u,x,re,h,je,_,v,se]),Pe=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),Fe=(0,m.useCallback)(()=>{M.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),M.current?.classList.remove(`drop-root`)},[]),Ie=(0,m.useCallback)(e=>{if(Fe(),e==null)return;let t=M.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):M.current?.classList.add(`drop-root`)},[Fe]),Le=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Re=(0,m.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),Be=(0,m.useRef)(0),Ve=(0,m.useRef)(void 0),He=(0,m.useCallback)((e,t)=>{let n=++Be.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||Be.current===n&&E(!1)},[r]),Ue=(0,m.useCallback)(e=>{let t=v.filter(t=>t!==e);Oe(t),(x===e||x.startsWith(`${e}/`))&&He(``)},[v,Oe,x,He]);(0,m.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,m.useEffect)(()=>{if(_!==Ve.current){Ve.current=_,He(``,{silent:!0});return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&He(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,He]),(0,m.useEffect)(()=>{t&&t.path===x&&He(x,{silent:!0})},[t,x,He]);let We=e=>He(e),Ge=()=>{e?.parent!==null&&e?.parent!==void 0&&He(e.parent)},qe=(()=>{if(x===``||x===gl)return[];let e=x.split(`/`).filter(e=>!!e&&e!==gl);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(`/`)}))})(),Je=[];for(let e of l??[]){if(e.source===`host`||e.hidden||e.kind===`divider`)continue;let t=g.find(t=>t.id===e.source.slice(7));t&&Je.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let Ye=(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:h(`collapsePanel`),onClick:c,children:(0,X.jsx)(Qe,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:j?`${k.files} 1 0`:`1 1 0`,minHeight:j?yl:0},children:(0,X.jsx)(fl,{storageKey:`rightpanel`,epoch:f??0,send:p??wl,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===Sl?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...Ye?[]:[{id:Sl,label:h(`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:()=>He(``),children:h(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===gl?`active`:``}`,title:h(`computer`),onClick:()=>He(gl),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:h(`homeDir`),onClick:()=>He(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:h(`desktopDir`),onClick:()=>He(b),children:`🖥️`}),(0,X.jsx)(Zc,{text:h(`filesHelp`)}),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":J,title:h(`workspaceRoots`),onClick:()=>De(e=>!e),children:[(0,X.jsx)(Me,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:h(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),J&&(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:()=>{De(!1),He(``)},children:[h(`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:()=>{De(!1),He(e)},children:(0,X.jsx)(`span`,{className:`root-picker-path`,children:e})}),(0,X.jsx)(`button`,{type:`button`,className:`root-picker-remove`,title:h(`removeWorkspaceRoot`),"aria-label":h(`removeWorkspaceRoot`),onClick:()=>Ue(e),children:(0,X.jsx)(N,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:h(`workspaceRootsHint`)})]})]}),qe.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(tt,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>He(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:F,className:`panel-body`,onScroll:e=>{P.current=e.currentTarget.scrollTop},onContextMenu:e=>Ne(e,{id:x,kind:`list`,label:x===``?h(`rootDir`):x===gl?h(`computer`):x}),onDragOver:e=>{Pe(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Re(),Ie(Le(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||Fe()},onDrop:e=>{if(Fe(),!Pe(e))return;e.preventDefault(),e.stopPropagation(),Re();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,h(`foldersNotSupported`));return}ie(Le(e.target),t)},onDragEnd:Fe,children:[(0,X.jsx)(`input`,{ref:U,type:`file`,multiple:!0,hidden:!0,onChange:Ae}),ae&&(0,X.jsx)(rl,{request:ae,onClose:()=>H(null),onComplete:q}),fe&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[fe.kind===`dir`?(0,X.jsx)(Me,{className:`file-icon`}):(0,X.jsx)(Y,{className:`file-icon`}),xe(me,he,ye,()=>pe(null))]}),T&&(0,X.jsx)(`div`,{className:`panel-empty`,children:h(`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:Ge,children:[(0,X.jsx)(Me,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),e.entries.map(e=>e.type===`dir`?(0,X.jsxs)(`div`,{className:`file-item dir${se?.cut&&se.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Ne(t,{id:e.path,kind:`dir`,label:e.name}),children:[G===e.path?xe(ue,de,ve,()=>le(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>We(e.path),children:[(0,X.jsx)(Me,{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":h(`linkFolderTip`),"aria-label":h(`linkFolderTip`),onClick:()=>i(e.path,e.name,`reference`,!0),children:(0,X.jsx)(we,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:I===`name:${e.path}`?(0,X.jsx)(it,{}):(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(ne(e.path),`path:${e.path}`),children:I===`path:${e.path}`?(0,X.jsx)(it,{}):(0,X.jsx)(Xe,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${se?.cut&&se.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Ne(t,{id:e.path,kind:`file`,label:e.name}),children:[G===e.path?xe(ue,de,ve,()=>le(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-name`,title:`${e.path} — ${h(`previewFile`)}`,onClick:()=>a(e.path,e.name),children:[(0,X.jsx)(Y,{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":h(`downloadFile`),onClick:()=>ge(e.path,e.name),children:(0,X.jsx)(ze,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":h(`referenceTip`),"aria-label":h(`referenceTip`),onClick:()=>i(e.path,e.name,`reference`),children:(0,X.jsx)(we,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:I===`name:${e.path}`?(0,X.jsx)(it,{}):(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(ne(e.path),`path:${e.path}`),children:I===`path:${e.path}`?(0,X.jsx)(it,{}):(0,X.jsx)(Xe,{})})]},e.path)),e.truncated&&(0,X.jsx)(`div`,{className:`panel-empty files-truncated`,children:h(`filesTruncated`)})]}),!T&&!e&&(0,X.jsx)(`div`,{className:`panel-empty`,children:h(`noFiles`)})]})]})}],...Je])})}),j&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:ee,onDoubleClick:()=>A({...vl}),title:h(`dragToResize`)}),j&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:bl},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:h(`widgetExpand`),onClick:()=>w(e.key),children:[(0,X.jsx)(`span`,{children:e.key}),(0,X.jsx)(be,{})]}),(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)`,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`,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)`,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`,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`,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.`},pn=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],mn={};function hn(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(mn[e.code]=e,!0)}function gn(e){delete mn[e]}function _n(e){return e===`zh`?`中文`:e.toUpperCase()}function vn(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function yn(e){let t=await fetch(sn(nn(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var bn=(0,m.createContext)(null);function xn(){try{return localStorage.getItem(un)}catch{return null}}function Sn(){return ln(xn(),typeof navigator<`u`?navigator.languages:[],null)}function Cn({children:e}){let[t,n]=(0,m.useState)(Sn),[r,i]=(0,m.useState)(0),a=(0,m.useRef)(t);a.current=t;let o=(0,m.useCallback)(e=>{n(e);try{localStorage.setItem(un,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,m.useCallback)(async()=>{let e,t=null;try{let n=await yn(`/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 yn(`/api/locales/${e.code}`);return hn({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,m.useEffect)(()=>{s().then(e=>{if(!xn()?.trim()){let t=ln(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!mn[t]){let t=ln(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(un,t)}catch{}}})},[s]);let c=(0,m.useMemo)(()=>[...pn,...Object.values(mn).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,m.useCallback)((e,n)=>{let r=mn[t]?.strings[e];r&&t!==`zh`&&t!==`ja`&&/[\u4e00-\u9fff]/.test(r)&&(r=void 0);let i=r??(t===`zh`?dn[e]:fn[e]);if(n)for(let[e,t]of Object.entries(n))i=i.replaceAll(`{${e}}`,String(t));return i},[t,r]);(0,m.useEffect)(()=>{document.documentElement.lang=vn(t)},[t]);let u=(0,m.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(bn.Provider,{value:u,children:e})}function wn(){let e=(0,m.useContext)(bn);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return wn().t}var Tn=[{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 En({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)(P,{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})})]}),Tn.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 Dn(){let[e,t]=(0,m.useState)([]);return(0,m.useEffect)(()=>{if(!Rt())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 On({settings:e,onChange:t,onPreview:n}){let r=Z(),i=Dn(),a=Rt(),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)(P,{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&&!zt(e.voiceURI,i,navigator.language)){t({...Ft,...e,voiceURI:``});return}n()},children:r(`preview`)})})]})}function kn(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 An=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),jn=null,Mn=0;function Nn(){return jn?.available===!0?jn.pages??[]:[]}function Pn(){Date.now()-Mn<5e3||Fn().catch(()=>{})}async function Fn(){if(kn())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=An();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&&(jn=r,Mn=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function In(e){return e.length===1?e[0]:null}function Ln(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function Rn(){let e=An();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function zn(e=45e3){let[t,n]=(0,m.useState)(null),r=(0,m.useRef)(!0),i=(0,m.useCallback)(async e=>{let t=await Fn();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,m.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 Bn=null,Vn=null,Hn=null,Un=null,Wn=null;function Gn(e){Un=e}function Kn(e){Wn=e}function qn(e){return Un?(Un(e),!0):!1}function Jn(e){return Wn?(Wn(e),!0):!1}function Yn(e){Bn=e}function Xn(e){Vn=e}function Zn(e){Hn=e}function Qn(){return Hn?(Hn(),!0):!1}function $n(){return!!(Bn||Vn)}function er(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&&!Bn||i&&!Vn?!1:(i&&Vn?.(n),r&&Bn?.(t),!0)}function tr(){let e=Z(),{status:t,refresh:n}=zn(),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(null),s=(0,m.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=In(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},f=t=>{let n=er({attachments:[Ln(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)(pe,{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)(pe,{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)(nr,{status:t,onRefresh:n,onCite:f,onClose:()=>i(!1)})]})}function nr({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,m.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await Rn()||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)(pe,{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 rr=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],ir=[`subagent`],ar=`edit_soft`,Q=`delegate_task`,or=`ask_user_question`,sr=`todo_list`,cr=`browser_page`,lr=`conversation_read`,ur=`skill`,dr=`schedule_task`,fr=`schedule_list`,pr=`schedule_cancel`,mr=`eval`,hr=`present_files`,gr=`claim_files`,_r=`plan_update`,vr=`compact_context`,yr=`patch`,br=[...rr.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...ir.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:ar,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:Q,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:or,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:cr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:lr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:gr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:_r,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`planUpdateEnabledDesc`,offHintKey:`planUpdateOffHint`},{name:yr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`patchToolEnabledDesc`,offHintKey:`patchToolOffHint`},{name:`lsp`,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`lspToolEnabledDesc`,offHintKey:`lspToolOffHint`},{name:hr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:ur,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:mr,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`evalEnabledDesc`,offHintKey:`evalOffHint`},{name:dr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:fr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:pr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:vr,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`compactContextEnabledDesc`,offHintKey:`compactContextOffHint`},{name:sr,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}],xr=[`bash`,`read`,`edit`,`write`,`powershell`,`ls`,`grep`,`find`];new Set(br.map(e=>e.name));function Sr(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`]);return n.filter(t=>!e.has(t))}return n}function Cr(e){return Sr([ur],e).includes(ur)}var wr=`pi-web-notify`,Tr={enabled:!1};function Er(){try{let e=localStorage.getItem(wr);if(!e)return{...Tr};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:Tr.enabled}}catch{return{...Tr}}}function Dr(e){try{localStorage.setItem(wr,JSON.stringify(e))}catch{}}function Or(){return typeof window<`u`&&`Notification`in window}function kr(){return Or()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Ar(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&jr(t)||Number.isFinite(n)&&jr(n)?!0:r>0&&r<=400&&i>0&&i<=40}function jr(e){return e<=-1e4}function Mr(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var Nr=Date.now(),Pr=!1;function Fr(){Nr=Date.now()}function Ir(){return Math.max(0,Date.now()-Nr)}function Lr(){if(Pr||typeof window>`u`)return;Pr=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Fr,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Fr,e)}function Rr(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function zr(){return Lr(),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:Ar({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Ir(),windows:Rr()}}function Br(){return Or()?Notification.permission:`denied`}async function Vr(){if(!Or())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function Hr(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Ur(e,t=!1){return{body:e,requireInteraction:t,icon:nn(`/icons/icon-192.png`),badge:nn(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:nn(`/`)}}}async function Wr(e,t,n=!1){if(!Or())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=Ur(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=Hr(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${Hr(e)}`}}}async function Gr(e,t){Or()&&(Mr(zr())||Er().enabled&&await Wr(e,t))}var Kr=!1;function qr(){let e=Z(),[t,n]=(0,m.useState)(Er),[r,i]=(0,m.useState)(()=>Br()),[a,o]=(0,m.useState)(null),s=kr(),c=s!==null,l=Rr();(0,m.useEffect)(()=>{let e=()=>i(Br());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),Dr(r),e){let e=await Vr();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Dr(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)(lt,{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`)}),Kr]})}var Jr=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),Yr=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(`.`)),Xr=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),Zr=new Set([...Jr].map(e=>e.toLowerCase())),Qr=new Set([...Yr].map(e=>e.toLowerCase()));function $r(e){return Zr.has(e.toLowerCase())}function ei(e){return Qr.has(e.toLowerCase())}function ti(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[...e.children]){let e=t.tagName.toLowerCase();if(!$r(e)){Xr.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of[...t.attributes]){let n=e.name.toLowerCase();(!ei(n)||/^on/i.test(n)||/^(javascript|data|vbscript):/i.test(e.value.trim()))&&t.removeAttribute(e.name)}i(t)}};for(let e of[...r.attributes]){let t=e.name.toLowerCase();(!ei(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function ni({icon:e,iconSvg:t,className:n}){let r=ti(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 ri=new Set([`view`,`action`,`badge`,`menu`,`page`,`organizer`,`divider`,`toggle`,`input`,`progress`,`select`]),ii=new Set([`disabled`,`always`,`never`,`file.isDir`,`file.isFile`,`session.isRunning`,`message.hasSelection`]),ai=[`topbar.primary`,`topbar.overflow`,`notice.actions`,`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.file`,`contextmenu.toolcall`,`settings.pages`,`modal.dialog`,`sidebar.left`,`sidebar.right`],oi=ai.map(e=>({slot:e,cardinality:`list`}));function si(e){return oi.find(t=>t.slot===e)?.cardinality??`list`}function ci(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 li=[{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-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-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-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}],ui=`__view`,di=new Set([`host:settings`,`host:history`,`host:files`]),fi=new Set([`host:history`,`host:files`]);function pi(e){return`${e}:${ui}`}function mi(e){return e.source.startsWith(`plugin:`)?e.id===pi(e.source.slice(7)):!1}function hi(e,t,n){let r=pi(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 gi(e,t){let n=t.map(pi),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var _i=`host:brand`,vi=[`host:brand-logo`,`host:brand-name`];function yi(e){if(!((e.hidden??[]).some(e=>vi.includes(e))||(e.shown??[]).some(e=>vi.includes(e))||(e.order??[]).some(e=>vi.includes(e))||vi.some(t=>e.align?.[t]!==void 0)||vi.some(t=>e.groups?.[t]!==void 0)||vi.some(t=>e.labels?.[t]!==void 0)||vi.some(t=>e.slots?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=vi.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))vi.includes(t)||(n[t]=r);if(n[_i]===void 0){let r=t?e[vi[0]]??e[vi[1]]:e[vi[1]]??e[vi[0]];r!==void 0&&(n[_i]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))vi.includes(n)||(t[n]=r);if(t[_i]===void 0){let n=e[vi[0]]??e[vi[1]];n!==void 0&&(t[_i]=n)}return t},i=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))vi.includes(n)||(t[n]=r);if(t[_i]===void 0){let n=e[vi[0]]??e[vi[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 bi(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:ui,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 xi(e){return typeof e==`string`&&ai.includes(e)}function Si(e,t){return t?e.label:e.labelEn??e.label}function Ci(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function wi(e,t,n,r,i){let a=`${e}#${r.id}`,o=Ti(a,t,n,r.children,i),s=Ci(r,i),c=Ei(r.options,i);return{id:a,slot:t,source:n,label:Si(r,i),...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 Ti(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:wi(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 Ei(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 Di(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Oi(e,t,n,r,i,a){let o=Ti(e,t,n,r.children,i),s=Ci(r,i),c=Di(r.progress),l=Ei(r.options,i);return{id:e,slot:t,source:n,label:Si(r,i),...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 ki(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 Ai(e){let t=e.filter(e=>mi(e));if(t.length===0)return e;let n=e.filter(e=>!mi(e)),r=[`host:git`,`host:terminal`,`host:chat`].map(e=>n.findIndex(t=>t.id===e)).find(e=>e>=0)??-1,i=n.findIndex(e=>e.id===`host:plugins`),a=r+1;return i>=a&&(a=i),a=Math.max(0,Math.min(a,n.length)),[...n.slice(0,a),...t,...n.slice(a)]}function ji(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=yi(t.layout??{}),a=e=>{t.diagnostics?.push({level:e.level??`warn`,...e})},o=new Map,s=0;for(let e of li)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(!xi(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.kind&&!ri.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)ii.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,Oi(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);Ni(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,l(e,`label`))}for(let[e,t]of Object.entries(i.slots??{})){let n=o.get(e);n&&xi(t)&&n.slot!==t&&(n.movedFrom=n.movedFrom??n.slot,n.slot=t,l(e,`slot`))}for(let e of di){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`))});let d=new Map;for(let e of ai)d.set(e,[]);for(let e of o.values())d.get(e.slot)?.push(e);let f={};for(let e of ai){let t=ki(d.get(e)??[],u),n=ci(e===`topbar.primary`?Ai(t):t,si(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=>Mi(e,c.get(e.id)??[]))}return f}function Mi(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function Ni(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,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&&xi(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 Pi(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 Fi(e,t){let n=e??{},r={},i=t===_i?[t,...vi]:[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=Li(n.groups,t),l=Li(n.labels,t),u=Li(n.align,t),d=Li(n.slots,t);if(t===_i)for(let e of vi)c=Li(c,e),l=Li(l,e),u=Li(u,e),d=Li(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 Ii(){return{}}function Li(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 Ri=new Set([`host:files`]);function zi(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 Bi(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 Vi=null,Hi=new Set;function Ui(){for(let e of Hi)e()}function Wi(e){Vi={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}:{}},Ui()}function Gi(){Vi!==null&&(Vi=null,Ui())}function Ki(e){return Hi.add(e),()=>{Hi.delete(e)}}function qi(){return Vi}function Ji(){return(0,m.useSyncExternalStore)(Ki,qi,qi)}function Yi(e){return Number.isFinite(e)?e:0}function Xi(e,t,n,r,i,a){let o=Math.max(0,Yi(n)),s=Math.max(0,Yi(r)),c=Math.max(8,Yi(i)-o-8),l=Math.max(8,Yi(a)-s-8);return{x:Math.min(Math.max(8,Yi(e)),c),y:Math.min(Math.max(8,Yi(t)),l)}}function Zi(e,t){let n=String(t?.kind??``);if(e===`contextmenu.file`)return{"file.isDir":n===`dir`,"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 Qi(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 $i(e,t){return!e||Qi(e.when,t)}function ea(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 ta(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 na(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 ra(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!$i(e,t)}function ia(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,ra(e[o],r))return o;return-1}var aa={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?aa[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var sa={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},ca=new Set;function la(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function ua(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&&la(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&la(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function da(e){let t={...sa,...e};if(!ua(sa,t)){sa=t;for(let e of ca)e()}}function fa(e){return ca.add(e),()=>{ca.delete(e)}}function pa(){return sa}function ma(){return(0,m.useSyncExternalStore)(fa,pa,pa)}function ha(e){return(0,m.useSyncExternalStore)(fa,()=>sa[e],()=>sa[e])}function ga(){return ha(`engine`)===`dsh`}function _a(){return ha(`managed`)}function va(){return ha(`service`)}var ya=null;function ba(e){ya=e}var $=e=>ya?ya(e):!1,xa=`@root`,Sa=e=>e.endsWith(`/`)?e:e+`/`;function Ca(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function wa(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var Ta=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)?xa:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function Ea({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,m.useState)(``),[h,g]=(0,m.useState)(``),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(``),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(-1),T=(0,m.useRef)(null),E=(0,m.useRef)(null),D=t.filter(e=>e.type===`dir`);(0,m.useEffect)(()=>{let t=(e||``).replace(/\\/g,`/`);p(t),g(t),v(!1),b(``),S(null),w(-1)},[e]),(0,m.useEffect)(()=>{let e=requestAnimationFrame(()=>{T.current?.focus()});return()=>cancelAnimationFrame(e)},[]),(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(_?(v(!1),b(``),S(null)):r())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,r]),(0,m.useEffect)(()=>{let e=setTimeout(()=>{$({type:`complete_path`,path:Sa(f)})},60);return()=>clearTimeout(e)},[f]),(0,m.useEffect)(()=>{if(h===f)return;let e=setTimeout(()=>{$({type:`complete_path`,path:h})},150);return()=>clearTimeout(e)},[h,f]);let O=e=>{let t=e.trim();t&&t!==`@root`&&i(t)},k=()=>{let e=y.trim();if(e){if(a===`project`){if(!wa(e)){S(d(`invalidProjectName`));return}let t=Ca(f,e);o?.(t),v(!1),b(``),S(null),r()}else $({type:`make_dir`,path:`${Sa(f)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:Sa(f)})},80),b(``),v(!1)}},A=e=>{if(e.key===`Escape`)e.stopPropagation(),_?(v(!1),b(``),S(null)):r();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)O(h);else if(e.key===`Tab`){if(D.length===0)return;e.preventDefault();let t=C>=0?(C+1)%D.length:0;w(t),g(D[t].path),p(D[t].path)}},j=Ta(f),ee=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},M=ee(f),P=!!f&&f!==`@root`&&M!==ee(e)&&!n.some(e=>ee(e)===M);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-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:f===`@root`?d(`computer`):f,children:[f===`@root`?`💻`:(0,X.jsx)(Me,{}),(0,X.jsx)(`span`,{children:f===`@root`?d(`computer`):f})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:f===xa,title:d(`computer`),onClick:()=>{p(xa),g(xa),w(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!j,title:d(`cwdGoUp`),onClick:()=>{j&&(p(j),g(j),w(-1))},children:[`↑ `,d(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!P,title:d(`addWorkspaceRootHint`),onClick:()=>{P&&$({type:`set_workspace_roots`,roots:[...n,f]})},children:[`+ `,d(`addWorkspaceRoot`)]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-close`,title:d(`close`),"aria-label":d(`close`),onClick:r,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:T,className:`status-cwd-input cwd-picker-input`,value:h,placeholder:d(`enterPath`),spellCheck:!1,onChange:e=>{g(e.target.value),w(-1)},onKeyDown:A}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:d(`cwdPickCurrent`),disabled:f===xa,onClick:()=>O(f),children:d(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[D.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:d(`cwdEmpty`)}),D.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:()=>{p(e.path),g(e.path),w(-1)},children:[(0,X.jsx)(Me,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:d(`cwdChoose`),onClick:()=>O(e.path),children:d(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[_?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:E,value:y,autoFocus:!0,spellCheck:!1,placeholder:d(a===`project`?`projectName`:`cwdNewName`),onChange:e=>{b(e.target.value),x&&S(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),k()):e.key===`Escape`&&(e.stopPropagation(),v(!1),b(``),S(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:k,children:d(a===`project`?`createAndOpenProject`:`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{v(!1),b(``),S(null)},children:d(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>v(!0),children:[`+ `,d(a===`project`?`newProject`:`cwdNewFolder`)]}),x&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:x})]})]})]})}function Da({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z();return e?(0,X.jsx)(Ea,{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 Oa(e){return D({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 ka(e){return D({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 Aa(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 ja(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,m.useRef)(null),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(i);(0,m.useLayoutEffect)(()=>{p.current=i});let h=()=>{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},g=()=>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=g(),i=r&&r.isConnected?r.getBoundingClientRect():h();if(!i)return;let a=Aa(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,m.useLayoutEffect)(()=>{t?_():f(null)},[t,n,r,o,s,c,l]),At(()=>{p.current()},t),(0,m.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||g()?.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 Ma({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=wn(),{panelRef:d,style:f,measure:p}=ja({anchor:e,anchorEl:t,onClose:l}),[,h]=(0,m.useState)(null),g=(0,m.useRef)(null),[_,v]=(0,m.useState)(null),y=(0,m.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,m.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,k.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)(st,{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&&g.current&&(n.preventDefault(),v(e.id))},onDrop:t=>{t.preventDefault(),x(t.dataTransfer.getData(`text/plain`)||g.current,e.id),g.current=null,h(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=>{h(e.id),g.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:()=>{g.current=null,h(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)(q,{"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)(ni,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(st,{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)(ka,{"aria-hidden":!0}):(0,X.jsx)(Oa,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(U,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Na({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=wn(),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(``);async function d(){try{let e=await fetch(sn(nn(`/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,m.useEffect)(()=>{d()},[]);async function f(e){u(e),c(``);try{let t=await fetch(sn(nn(`/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(sn(nn(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);gn(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)(ke,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(N,{})})]}),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)(ze,{}),(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 Pa=`xing-shuyin/pi-web-ui`,Fa={state:`idle`,version:null,percent:0,message:null};function Ia(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function La(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:Ia(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 Ra(e){if(!kn(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 za(e){return e instanceof Error?e.message:String(e)}function Ba(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${Pa}/releases/tag/v${t}`:`https://github.com/${Pa}/releases/latest`}function Va(){let[e]=(0,m.useState)(()=>Ra()),[t,n]=(0,m.useState)(Fa);(0,m.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>La(t,e)))},[e]);let r=(0,m.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:za(e)}))))},[e]),i=(0,m.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:za(e)}))))},[e]),a=(0,m.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:za(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}var Ha={name:`@earendil-works/pi-coding-agent`,kind:`pi-core`,current:``,latest:null,upToDate:!1};function Ua({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=ja({open:t,anchor:e,onClose:n});return(0,m.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,k.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Wa(){let[e,t]=(0,m.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,m.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 Ga({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:h,onSoundChange:g,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x,onOpenIconEdit:S}){let{locale:C,setLocale:w,t:T,packs:E}=wn(),[D,O]=(0,m.useState)(!1),[k,A]=(0,m.useState)(!1),[j,ee]=(0,m.useState)(null),M=ha(`cwd`),N=ha(`workspaceRoots`),F=ga(),I=(0,m.useRef)(null),L=t=>!e.tabs||t===`chat`||e.tabs.includes(t),te=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!mi(e)),R=new Set([...i??[],...a??[]].filter(e=>mi(e)&&!e.hidden).map(e=>e.source.slice(7))),z=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),re=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(z.get(`${e.id}:__view`)??1e6+e.index)-(z.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),ie=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})),V=(L(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!ie.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:[]})),H=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`}),Qn(),!0;case`host:new-ephemeral-chat`:return c(`chat`),$({type:`new_chat`,ephemeral:!0}),Qn(),!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(I.current?{rect:I.current.getBoundingClientRect(),el:I.current}:null),!0;default:return!1}},W=(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??[]];Wi({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}=ma(),oe=_a(),se=va(),[K,le]=(0,m.useState)(!1);(0,m.useEffect)(()=>{K&&e.status===`open`&&le(!1)},[K,e.status]);let[ue,de]=(0,m.useState)(!1),[fe,pe]=(0,m.useState)(!1),[me,he]=(0,m.useState)(!1),[ge,ve]=(0,m.useState)(!1),ye=kn(),be=Va(),[xe,Se]=(0,m.useState)(!1),Ce=()=>{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:St(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:n,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:r}),ve(!1),c(`terminal`)},Te=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:bt(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:St(),conversationId:e.activeConversationId||e.state?.conversationId||``,title:r,cwd:e.state?.cwd??``,cols:80,rows:24,running:!0,exitCode:null,command:i}),ve(!1),c(`terminal`)},J=e.updatesAll??[],Ee=e.updatesSdk,De=Ee&&Ee.newerInstalled?{running:Ee.running,installed:Ee.newerInstalled}:null,Oe=Ee?.bundledInUse===!0,Y=J.find(e=>e.kind===`pi-core`&&!e.error),Pe=Oe&&(!Y||!Y.upToDate),Fe=Pe&&!Y,Ie=J.filter(e=>!e.upToDate&&!e.error).length,Le=J.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Be=e=>e.kind===`git-extension`&&e.source?e.source:e.name,Ve=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,He=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},Ue=(e,t)=>{if(!t)return He(e);let n=He(e),r=He(t);return n===r?n:`${n} → ${r}`},We=()=>(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`)}):J.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:J.map(e=>{let t=De!=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:()=>Te([e],T(`updatePkgTabTitle`,{name:e.name})),children:T(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:Ve(e),children:Be(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?He(e.current):Ue(e.current,e.latest):e.kind===`plugin`?e.upToDate?e.current.startsWith(`v`)?e.current:He(e.current):Ue(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:De.running})})]})]},`${e.kind}:${e.name}`)})}),De&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`piSdkSplitNote`,{running:De.running,installed:De.installed})}),Pe&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`piSdkBundledNote`,{running:Ee.running})}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[Fe&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Te([Ha],T(`installGlobalEngineTabTitle`)),children:T(`installGlobalEngineBtn`)}),Le.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>Te(Le,T(`updateAllTabTitle`)),children:T(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:Le.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:T(`updatesAllRefresh`)})]})]}),Ge=()=>{let t=Ba(e.update?.latest??be.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:T(`updateDesktopManual`)});if(!be.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:T(`updateDesktopNoBridge`)}),n]});switch(be.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:be.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>be.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:be.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:()=>be.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:be.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>be.check(),children:T(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>be.check(),children:T(`updateDesktopCheck`)}),n]})}},Ke=()=>(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&&!ye&&(0,X.jsx)(`div`,{className:`dd-note`,children:T(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&ye&&(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&&!ye&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:Ce,children:T(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&ye&&Ge(),se&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:K,title:T(`restartServiceTip`,{name:se.name}),onClick:()=>{K||(le(!0),$({type:`restart_service`}))},children:T(K?`restartingService`:`restartService`)})]})]}),qe=Wa(),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)(Ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`openProject`)})]}),"host:history":n===`chat`&&L(`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)(q,{})}):null,"host:files":n===`chat`&&L(`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)(Me,{}),(0,X.jsx)(`span`,{children:T(`openFiles`)})]}):null,"host:new-chat":L(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":T(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),Qn()},children:[(0,X.jsx)(ce,{}),(0,X.jsx)(`span`,{children:T(`newChat`)})]}):null,"host:new-ephemeral-chat":F?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}),Qn()},children:[(0,X.jsx)(yt,{}),(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)(_e,{}),(0,X.jsx)(`span`,{children:T(`chat`)})]}),"host:terminal":L(`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)(ne,{}),(0,X.jsx)(`span`,{children:T(`terminal`)})]}):null,"host:git":L(`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)(je,{}),(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)(st,{"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)(G,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(tr,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":T(`bgTasksTip`),onClick:f,children:[(0,X.jsx)(we,{}),(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)(U,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`settings`)})]}),"host:sound":(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(P,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:T(`sound`)})]}),tip:T(`sound`),open:ue,onOpenChange:de,children:[(0,X.jsx)(En,{settings:h,onChange:g,onPreview:_}),(0,X.jsx)(qr,{})]}),"host:language":(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ke,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:_n(C)})]}),tip:T(`language`),open:fe,onOpenChange:pe,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`language`)}),E.map(e=>(0,X.jsx)(Nt,{active:C===e.code,onClick:()=>{w(e.code),pe(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(Nt,{onClick:()=>{pe(!1),Se(!0)},children:[(0,X.jsx)(ze,{}),` `,T(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(Mt,{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:me,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)(Nt,{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)(Nt,{active:y===null,onClick:()=>{b(null),he(!1)},children:T(`themeDefault`)}),t.map(e=>(0,X.jsx)(Nt,{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)(ze,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,ae??e.update?.current??`…`]})]}):(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ze,{}),(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??``})}),Ie>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:T(`updatesAllBadge`,{n:Ie})})]}),tip:T(`update`),open:ge,onOpenChange:e=>{ve(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:T(`update`)}),Ke(),We()]}),"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)(Ae,{})}),"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)(Me,{}),(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)&&!L(e.slice(5)),Qe=e=>{if(e.kind===`view`){if(!L(`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=>W(t,e.id,e.label),children:[(0,X.jsx)(ni,{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=>W(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=>W(t,e.id,e.label),children:[(0,X.jsx)(ni,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},$e=[];for(let e of ie){if(e.entry?.hidden||Ze(e.id))continue;let t=e.id.startsWith(`host:`)?Je[e.id]??null:e.entry?Qe(e.entry):null;t&&$e.push({id:e.id,entry:e.entry,node:t})}for(let e of V){let t=Qe(e);t&&$e.push({id:e.id,entry:e,node:t})}let et=e=>e.entry?.align??`start`,[tt,nt]=(0,m.useState)(()=>new Set),rt=(0,m.useRef)(null),it=(0,m.useRef)(new Map),at=$e.filter(e=>!tt.has(e.id)),ot=qe?at.filter(e=>Ri.has(e.id)):[],ct=qe?at.filter(e=>!Ri.has(e.id)):at,lt=qe?$e.filter(e=>!Ri.has(e.id)):$e,ut=[...lt.filter(e=>et(e)===`start`),...lt.filter(e=>et(e)===`center`),...lt.filter(e=>et(e)===`end`)],dt=ut.filter(e=>!tt.has(e.id)),ft=(0,m.useRef)(ut),pt=(0,m.useRef)(dt);(0,m.useLayoutEffect)(()=>{ft.current=ut,pt.current=dt});let mt=()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`)),n=pt.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=ft.current,a=Bi(i.map(e=>({id:e.id,width:e.entry?it.current.get(e.id)??0:0})),e.clientWidth,r,0,di);nt(e=>e.size===a.size&&[...a].every(t=>e.has(t))?e:a)},ht=`${at.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${qe?`m`:`d`}`;(0,m.useLayoutEffect)(mt,[ht]),(0,m.useEffect)(()=>{let e=rt.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>mt());return t.observe(e),()=>t.disconnect()},[ht]);let gt=ct.filter(e=>et(e)===`start`),_t=ct.filter(e=>et(e)===`center`),vt=ct.filter(e=>et(e)===`end`),xt=$e.filter(e=>tt.has(e.id)&&e.entry).map(e=>e.entry),Ct=new Map;[...i??[],...a??[]].forEach((e,t)=>{Ct.has(e.id)||Ct.set(e.id,t)});let wt=zi([...te,...xt],e=>Ct.get(e)??999999),Tt=e=>e.icon&&!/[a-z]/i.test(e.icon)?e.icon:null,Et=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${Et?` 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)(m.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)(m.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)(m.Fragment,{children:e.node},e.id))]}),(wt.length>0||$e.length>0)&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:I,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":D,"data-tip":T(`pluginTopbarMore`),onClick:()=>O(e=>!e),children:`⋯`}),(0,X.jsxs)(Ua,{anchorRef:I,open:D,onClose:()=>O(!1),children:[wt.map(e=>{let t=e.source===`host`&&Xe.has(e.id)?Je[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(m.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)(Ae,{}),(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:[Tt(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:Tt(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),H(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),H(e)||s?.(e)},children:[Tt(e)?(0,X.jsx)(`span`,{className:`plugin-icon-glyph`,children:Tt(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)(Re,{}),(0,X.jsx)(`span`,{className:`tb-row-text`,children:T(`uiIconEdit`)})]})]})]}),ot.map(e=>(0,X.jsx)(m.Fragment,{children:e.node},e.id)),xe&&(0,X.jsx)(Na,{onClose:()=>Se(!1)}),j&&(0,X.jsx)(Ma,{anchorRect:j.rect,anchorEl:j.el,plugins:r,pinnedIds:R,orderedPluginIds:re,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:hi(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:gi(e.settings?.uiLayout,t)}),onOpenView:e=>{ee(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>ee(null)}),k&&(0,X.jsx)(Da,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:N,onClose:()=>A(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Ka(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 qa(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 Ja(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 Ya(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 Xa(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}}function Za(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 Qa=null,$a=new Set;function eo(){for(let e of $a)e()}function to(e){let t=(e??``).trim();t&&(Qa={name:t,status:`loading`},eo(),$({type:`get_tool_info`,name:t}))}function no(){Qa!==null&&(Qa=null,eo())}function ro(e){Qa!==null&&Qa.name===e.name&&(Qa=Za(e),eo())}function io(e){return $a.add(e),()=>{$a.delete(e)}}function ao(){return Qa}function oo(){return(0,m.useSyncExternalStore)(io,ao,ao)}var so=Object.freeze({status:`idle`,messages:[]}),co=new Map,lo=new Set,uo=16;function fo(){for(;co.size>uo;){let e=co.keys().next().value;if(e===void 0)break;co.delete(e)}}function po(){for(let e of lo)e()}function mo(e,t){let n=(e??``).trim();if(!n)return;let r=co.get(n);(!r||r.status!==`loading`&&r.status!==`ready`)&&(co.set(n,{status:`loading`,messages:r?.messages??[]}),fo(),po(),$({type:`get_compacted_messages`,compactionMessageId:n,conversationId:t}))}function ho(e){let t=e.compactionMessageId;t&&(e.error?co.set(t,{status:`error`,messages:[],error:e.error}):co.set(t,{status:`ready`,messages:e.messages??[]}),fo(),po())}function go(e){let t=co.get(e);return t?(co.delete(e),co.set(e,t),t):so}function _o(e){return lo.add(e),()=>{lo.delete(e)}}function vo(e){return(0,m.useSyncExternalStore)(_o,()=>go(e),()=>so)}var yo=`__piWebUiHost`,bo=e=>new Promise(t=>setTimeout(t,e));async function xo(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 bo(100)}}var So=Promise.resolve(),Co=0;function wo(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 bo(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=Co>0?So.then(i):i(),Co++,So=o.then(()=>{Co--},()=>{Co--}),o.catch(()=>{}),!0},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>es(e)},compose(e){return $n()?er({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=ko,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=ko,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=St();return new Promise(t=>{let a=setTimeout(()=>{cs.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));cs.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 jo(Do,String(e??``).trim(),t)},onTopbarAction(e,t){return jo(Do,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(kn())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 xo(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(No,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>Vo(String(e??``),t)},searchProviders:{register:e=>Uo(e),list:()=>Wo()},composerProviders:{register:e=>Ko(e),list:()=>qo()},onTheme:e=>ns(e),onLocale:e=>rs(e),onViewChange:e=>is(e)}}function To(e){try{let t=window;e?t[yo]=e:delete t[yo]}catch{}}var Eo=new Map,Do=null;async function Oo(e,t){let n=Do;Do=e;try{return await t()}finally{Do=n}}var ko=void 0;function Ao(e,t){let n=ko;ko=e;try{return t()}finally{ko=n}}function jo(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=Eo.get(r);i||(i=new Set,Eo.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&Eo.delete(r)}}async function Mo(e,t,n,r){let i=i=>{let a=Eo.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{Ao(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 No=`pi-web-ui:toast`,Po=new Map,Fo=!1;function Io(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 Lo(){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 Ro(e){try{if(Lo())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=Po.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function zo(){if(!Fo)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,Ro),Fo=!0}catch{}}function Bo(){if(!(Po.size>0||!Fo))try{window.removeEventListener(`keydown`,Ro)}catch{}finally{Fo=!1}}function Vo(e,t){if(typeof t!=`function`)return()=>{};let n=Io(e);if(!n)return()=>{};let r=Po.get(n.combo);r||(r=new Set,Po.set(n.combo,r));let i=r;return i.add(t),zo(),()=>{i.delete(t),i.size===0&&Po.delete(n.combo),Bo()}}var Ho=new Map;function Uo(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 Ho.set(t,n),()=>{Ho.get(t)===n&&Ho.delete(t)}}function Wo(){return[...Ho.values()].map(e=>({id:e.id,label:e.label}))}var Go=new Map;function Ko(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 Go.set(t,n),()=>{Go.get(t)===n&&Go.delete(t)}}function qo(){return[...Go.values()].map(e=>({id:e.id,label:e.label}))}function Jo(e){return Go.get(String(e??``))}function Yo(e){return Ho.get(String(e??``))}var Xo=new Set,Zo=new Set,Qo=new Set,$o=new Set;function es(e){return $o.add(e),()=>{$o.delete(e)}}function ts(e){for(let t of[...$o])try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function ns(e){return typeof e==`function`?(Xo.add(e),()=>{Xo.delete(e)}):()=>{}}function rs(e){return typeof e==`function`?(Zo.add(e),()=>{Zo.delete(e)}):()=>{}}function is(e){return typeof e==`function`?(Qo.add(e),()=>{Qo.delete(e)}):()=>{}}function as(e){let t=String(e??``);for(let e of[...Xo])try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function os(e){let t=String(e??``);for(let e of[...Zo])try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function ss(e){let t=String(e??``);for(let e of[...Qo])try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var cs=new Map;function ls(e){let t=cs.get(e.requestId);if(t){if(cs.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 us=`modulepreload`,ds=function(e){return`/`+e},fs={},ps=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=ds(t,n),t=s(t),t in fs)return;fs[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`:us,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)})},ms=`pi-web-ui:plugin-data`;function hs(e,t){window.dispatchEvent(new CustomEvent(ms,{detail:{pluginId:e,payload:t}}))}function gs(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(ms,t),()=>window.removeEventListener(ms,t)}var _s=new Map,vs=new Set,ys=new Set,bs=new Set,xs=new Set,Ss=-1;function Cs(){return[..._s.values()]}function ws(){let e=Cs();for(let t of ys)t(e)}function Ts(){let e=[...bs];for(let t of xs)t(e)}function Es(e){return xs.add(e),e([...bs]),()=>xs.delete(e)}async function Ds(e,t){bs.delete(e.id),ks.set(e.id,(ks.get(e.id)??0)+1),Ts();let n=await Ps(e,t);return ws(),n}function Os(e){return ys.add(e),e(Cs()),()=>ys.delete(e)}var ks=new Map;function As(e,t){let n=ks.get(e)??0;return nn(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function js(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>Oo(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var Ms=js(e=>ps(()=>import(e),[]));async function Ns(e,t){if(!e.hasClient||e.error)return null;try{return(await Ms(e.id,As(e.id,t))).default??null}catch(t){return console.error(`[plugin:${e.id}] 客户端 bundle 加载失败:`,t),null}}async function Ps(e,t){try{let n=(await Ms(e.id,As(e.id,t))).default;return n&&typeof n.mount==`function`?(_s.set(e.id,{info:e,module:n}),!0):e.preload?(vs.add(e.id),!0):(bs.add(e.id),Ts(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return bs.add(e.id),Ts(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function Fs(e,t){if(_s.has(e.id)||vs.has(e.id))return!0;if(bs.has(e.id)||!e.hasClient)return!1;let n=await Ps(e,t);return ws(),n}async function Is(e,t){t!==Ss&&(Ss=t,_s.clear(),vs.clear(),bs.clear(),ks.clear(),Ts());let n=new Set(e.map(e=>e.id));for(let e of[..._s.keys()])n.has(e)||_s.delete(e);for(let e of[...vs])n.has(e)||vs.delete(e);for(let e of[...bs])n.has(e)||bs.delete(e);Ts(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!_s.has(e.id)&&!vs.has(e.id)&&!bs.has(e.id)).map(e=>Ps(e,t))),ws()}function Ls(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>gs((n,r)=>{n===e&&t(r)})}}var Rs=[`debug`,`info`,`warn`,`error`];function zs(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function Bs(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function Vs(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`&&Rs.includes(String(e.level)))}var Hs=new Map,Us=new Set;function Ws(){for(let e of[...Us])try{e()}catch{}}function Gs(e){return Us.add(e),()=>Us.delete(e)}function Ks(e){return(Hs.get(e)??[]).map(e=>({...e}))}function qs(e,t){return Vs(t)?(Hs.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),Ws(),!0):!1}function Js(){return{flows:[],results:{}}}function Ys(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 Xs(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:Ys(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:Ys(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 Zs=`pi-web-ui:lang`;function Qs(){try{return(localStorage.getItem(Zs)??``).trim()}catch{return``}}var $s=`pi-web-ui:locale`,ec=2e5,tc=2e5,nc=`LIVE_OMIT`,rc={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 ic(){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>tc?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 ac(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 oc(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 sc(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!==22};case`snapshot`:{let n=e.state?.cwd,r=t.state.cwd,i=e.sessions;return r&&r!==n&&(i=xc(r)),{...e,ready:!0,state:t.state,sessions:i,approval:t.state.pendingApproval??null,activeConversationId:t.state.conversationId,liveOutputs:ac(e.liveOutputs,t.state),toolStatuses:oc(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:ac(e.liveOutputs,i),toolStatuses:oc(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>ec?`…[${nc}:${n.length-ec}]…\n`+n.slice(n.length-ec):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:Ya(n,t.msg)}}case`tool_status`:return{...e,toolStatuses:new Map(e.toolStatuses).set(t.status.toolCallId,t.status)};case`notice`:return{...e,notices:[...e.notices,t.notice].slice(-6)};case`dismiss_notice`:return{...e,notices:e.notices.filter(e=>e.id!==t.id)};case`sessions`:return Sc(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 _c(t.projects),{...e,projects:t.projects};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=Xs({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`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`bg_servers`:return{...e,bgServers:t.servers};case`scheduler_tasks`:return{...e,schedulerTasks:t.tasks};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`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};default:return e}}var cc=`pi-web-client-id`,lc=null;function uc(){if(lc)return lc;let e=null;try{e=sessionStorage.getItem(cc),e||(e=St(),sessionStorage.setItem(cc,e))}catch{e??=St()}return lc=e,e}var dc=`pi-web-last-cwd`;function fc(){try{return localStorage.getItem(dc)}catch{return null}}function pc(e){try{localStorage.setItem(dc,e)}catch{}}function mc(e){try{let t=localStorage.getItem(dc);if(!t)return;let n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase();(t===e||n(t)===n(e))&&localStorage.removeItem(dc)}catch{}}var hc=`pi-web-recent-projects`;function gc(){try{let e=localStorage.getItem(hc);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function _c(e){try{localStorage.setItem(hc,JSON.stringify(e.slice(0,20)))}catch{}}function vc(e){try{let t=gc(),n=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),r=n(e);_c(t.filter(e=>n(e.path)!==r))}catch{}}var yc=`pi-web-recent-sessions:`;function bc(e){return e?`${yc}${e.trim().replace(/[\\/]+$/,``).toLowerCase()}`:`pi-web-recent-sessions:default`}function xc(e){try{let t=bc(e??fc()),n=localStorage.getItem(t);if(!n)return[];let r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function Sc(e,t){try{let n=bc(e??fc());localStorage.setItem(n,JSON.stringify(t.slice(0,50)))}catch{}}function Cc(e,t){try{let n=xc(t),r=e=>e.trim().replace(/[\\/]+$/,``).toLowerCase(),i=r(e);Sc(t,n.filter(e=>r(e.path)!==i))}catch{}}function wc(){return sn(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${nn(`/ws`)}`)}function Tc(){let[e,t]=(0,m.useReducer)(sc,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:xc(),conversations:[],elsewhere:[],activeConversationId:``,projects:gc(),files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:Js().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,updatesSdk:null,widgets:[],statuses:[],dialog:null,approval:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:rc,bgServers:[],schedulerTasks:[],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,installInspect:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,dshPresets:null,dshPermission:null,protocolMismatch:!1}),n=(0,m.useRef)(null),r=(0,m.useRef)(ic()),i=(0,m.useRef)(0),a=(0,m.useRef)(null),o=(0,m.useRef)(!0),s=(0,m.useRef)(0),c=(0,m.useRef)(0),l=(0,m.useRef)(new Map),u=(0,m.useRef)(null),d=(0,m.useRef)(!1),f=(0,m.useRef)(null),p=(0,m.useRef)(new Set),h=(0,m.useRef)(`live`),g=()=>{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)&&g()}n.set(e,t)},v=(0,m.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]),y=(0,m.useCallback)(e=>{let r=n.current;if(r&&r.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`}),r.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)}h.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,m.useCallback)((e,n)=>{let r=Xa({current:O.current.chat.question,source:h.current,snapshot:e,answered:p.current,activeConversationId:n});r.changed&&(h.current=r.source,t({type:`question`,question:r.question}))},[]);ba(y);let x=(0,m.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(wc());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:uc(),locale:Qs()})))},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!==`20261003T11380`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}da({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;(!e||e.conversationId!==a.conversationId||e.rev!==a.baseRev)&&g(),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;t({type:`notice`,notice:{id:e,level:a.level,text:a.text,textEn:a.textEn}});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`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`:ro(a);break;case`compacted_messages_result`:ho(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`question_pending`:h.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)}h.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`bg_servers`:t({type:`bg_servers`,servers:a.servers});break;case`scheduler_tasks`:t({type:`scheduler_tasks`,tasks:a.tasks});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===uc()&&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`:ls(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`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`:qs(a.pluginId,a.payload)||hs(a.pluginId,a.payload)}},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,m.useEffect)(()=>{let e=e=>{let t=e.detail??Qs();t&&y({type:`set_locale`,locale:t})};return window.addEventListener($s,e),()=>window.removeEventListener($s,e)},[y]),(0,m.useEffect)(()=>{let n=n=>{let r=e.state?.cwd;r&&n.key&&n.key===bc(r)&&t({type:`sync_cached_sessions`,sessions:xc(r)})};return window.addEventListener(`storage`,n),()=>window.removeEventListener(`storage`,n)},[e.state?.cwd]),(0,m.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);return()=>{o.current=!1,clearInterval(e),a.current&&=(clearTimeout(a.current),null),n.current?.close(),n.current=null}},[x]),(0,m.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=fc();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}f.current!==t&&(f.current=t,pc(t))}},[e.state?.cwd,y]),(0,m.useEffect)(()=>{da({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,m.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,m.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,m.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,m.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,m.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,m.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,m.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 Ec(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 Dc(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 Oc=`pi-web-ui:lp-collapse-projects`,kc=`pi-web-ui:lp-collapse-convs`,Ac=`pi-web-ui:lp-collapse-sessions`;function jc(e,t=!1){let[n,r]=(0,m.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,m.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var Mc=`pi-web-ui:lp-sizes`,Nc={projects:1,convs:1,sessions:1},Pc=32,Fc=72;function Ic(){try{return Ka(localStorage.getItem(Mc),Nc)}catch{return{...Nc}}}var Lc=(0,m.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,onUiAction:p,presetNames:h}){let g=Z(),_=e,v=ha(`ready`),y=ha(`status`),b=ha(`cwd`),x=ha(`workspaceRoots`),S=b,[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(null),[D,O]=(0,m.useState)(null),[k,A]=(0,m.useState)(null),[j,ee]=(0,m.useState)(``),[M,P]=jc(Oc,!1),[F,I]=jc(kc,!1),[L,te]=jc(Ac,!1),z=(0,m.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]),ne=(0,m.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},[]),re=(0,m.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},[]),B=(0,m.useRef)(null),ie=(0,m.useRef)(null),V=(0,m.useRef)(()=>{}),H=ta(d??[]).length>0,U=(0,m.useCallback)((e,n,i)=>{B.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=z(t,a),l=c===0?g(`noFinishedSubagents`):g(a?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:c}),u=!!a&&ie.current===a;Wi({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:g(`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:g(`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:g(`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:g(`saveEphemeral`)}:e}return e.id===`host:conv-copy-id`?s?e:{...e,hidden:!0}:e.id===`host:conv-copy-path`?i.kind===`history`?e:a?t.some(e=>e.id===a&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0}:e.id===`host:conv-quote`?s||i.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>V.current(e,t)})},[d,t,z,g]);V.current=(0,m.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=B.current;if(!i||!e)return;if(ie.current!==i)return ie.current=i,U(e.x,e.y,e.target),!0;ie.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-quote`){n.kind===`history`&&n.id?er({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&er({attachments:[{path:``,key:`conv|${a}|`,name:n.label||a,mode:`conversation`,conversationId:a}]});return}if(e.id===`host:conv-rename`){if(E(null),i){let e=t.find(e=>e.id===i);ee(e?.title??n.label??``),A(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);ee(e?.name??n.label??``),A(n.id)}return}},[o,U,t,r]);let W=()=>{let e=f??[];return e.length===0?null:(0,X.jsx)(`span`,{className:`lp-slot-sessions`,children:e.map((e,t)=>{let n=`${e.id}#${t}`,r=e.label||e.id,i=e.hint||r;return e.kind===`divider`?(0,X.jsx)(`span`,{className:`lp-slot-divider`,"aria-hidden":`true`},n):e.kind===`badge`?(0,X.jsx)(`span`,{className:`lp-slot-badge`,title:i,children:e.badge??r},n):e.kind===`select`&&e.options?.length?(0,X.jsx)(`select`,{className:`lp-slot-select`,title:i,"aria-label":r,value:e.options.some(t=>t.value===e.value)?e.value:e.options[0].value,onClick:e=>e.stopPropagation(),onChange:t=>{t.stopPropagation(),p?.(e,t.target.value)},children:e.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},n):(0,X.jsx)(`button`,{type:`button`,className:`lp-slot-btn`,title:i,"aria-label":r,onClick:t=>{t.stopPropagation(),p?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:r})},n)})})},G=(0,m.useCallback)((e,t)=>{Dc(e.target)||H&&(e.preventDefault(),e.stopPropagation(),ie.current=null,U(e.clientX,e.clientY,t))},[H,U]),ae=(0,m.useRef)(null),[oe,se]=(0,m.useState)(()=>Ic());(0,m.useEffect)(()=>{try{localStorage.setItem(Mc,JSON.stringify(oe))}catch{}},[oe]);let K=[...t,...n.map((e,t)=>({id:`elsewhere:${e.cwd}:${e.title}:${t}`,title:e.title,cwd:e.cwd,messageCount:0,isStreaming:e.isStreaming,isSubagent:!1,elsewhere:!0,pseudo:!!e.pseudo,...e.owner&&e.convId?{owner:e.owner,convId:e.convId}:{},...e.hasQuestion?{hasQuestion:!0}:{}}))],le=(0,m.useCallback)((e,t)=>n=>{n.preventDefault();let r=n.currentTarget,a=n.clientY,o={...oe},s=ae.current;if(!s)return;let c=[{key:`projects`,visible:i.length>0,collapsed:M},{key:`convs`,visible:K.length>0,collapsed:F},{key:`sessions`,visible:!0,collapsed:L}].filter(e=>e.visible),l=c.filter(e=>e.collapsed).length,u=c.filter(e=>!e.collapsed).map(e=>e.key).reduce((e,t)=>e+(o[t]??1),0)||1,d=Math.max(120,s.clientHeight-l*Pc);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let f=n=>{let{above:r,below:i}=qa({start:{above:o[e]??1,below:o[t]??1},deltaPx:n.clientY-a,availablePx:d,totalWeight:u,minAbovePx:Fc,minBelowPx:Fc});se(n=>({...n,[e]:r,[t]:i}))},p=()=>{window.removeEventListener(`pointermove`,f),window.removeEventListener(`pointerup`,p),r.classList.remove(`dragging`),document.body.classList.remove(`lp-resizing`)};window.addEventListener(`pointermove`,f),window.addEventListener(`pointerup`,p)},[oe,i.length,K.length,M,F,L]);(0,m.useEffect)(()=>{s&&v&&y===`open`&&b&&(o({type:`list_sessions`}),o({type:`list_projects`}))},[s,v,y,b,o]);let ue=e=>{let t=e.name||e.firstMessage.trim();return t.length>0?t:g(`emptyChat`)},de=e=>e.split(/[\\/]/).pop()||e,pe=(e,t,n,r,i)=>{let a=T===e;return(0,X.jsx)(`button`,{type:`button`,className:`lp-del ${a?`confirm`:``}`,title:a?n:t,onClick:t=>{t.stopPropagation(),a?(E(null),r()):E(e)},children:a?(0,X.jsx)(it,{}):i??(0,X.jsx)(R,{})})},me=(e,t,n,r,i)=>(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:g(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)(rt,{}):(0,X.jsx)(et,{})})]}),i?(0,X.jsx)(`div`,{className:`lp-section-actions`,children:i}):null]}),he=[{key:`projects`,visible:i.length>0,collapsed:M},{key:`convs`,visible:K.length>0,collapsed:F},{key:`sessions`,visible:!0,collapsed:L}].filter(e=>e.visible).filter(e=>!e.collapsed),ge=he.reduce((e,t)=>e+(oe[t.key]??1),0)||1,q=e=>he.length<=1?1:(oe[e]??1)/ge*he.length;return(0,X.jsxs)(`aside`,{ref:ae,className:`panel panel-left lp-panel`,children:[c&&l&&(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,title:g(`collapsePanel`),onClick:l,children:(0,X.jsx)($e,{})}),(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${M||i.length===0?`collapsed`:``}`,style:i.length>0&&!M?{flex:`${q(`projects`)} 1 0px`}:void 0,children:[me(g(`recentProjects`),M,P,i.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-project-action`,title:g(`manageProjects`),"aria-label":g(`manageProjects`),onClick:()=>w(!0),children:(0,X.jsx)(Ne,{})})),i.length>0&&!M&&(0,X.jsx)(`div`,{className:`lp-section-body projects-scroll`,children:i.map(e=>{let t=S===e.path;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>E(t=>t===`proj:${e.path}`?null:t),children:[(0,X.jsxs)(`button`,{type:`button`,className:`project-item ${t?`active`:``}`,title:e.path,onClick:()=>{t||o({type:`set_cwd`,path:e.path})},children:[(0,X.jsx)(Me,{className:`project-icon`}),(0,X.jsxs)(`span`,{className:`project-info`,children:[(0,X.jsx)(`span`,{className:`project-name`,children:de(e.path)}),(0,X.jsx)(`span`,{className:`project-path`,children:e.path})]}),(0,X.jsx)(`span`,{className:`project-time`,children:Ec(e.lastUsed)})]}),pe(`proj:${e.path}`,g(`deleteProject`),g(`deleteProjectConfirm`),()=>{mc(e.path),vc(e.path),o({type:`remove_project`,path:e.path})})]},e.path)})})]}),i.length>0&&!M&&(K.length>0?!F:!L)&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:le(`projects`,K.length>0?`convs`:`sessions`),onDoubleClick:()=>se({...Nc}),title:g(`dragToResize`)}),K.length>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${F?`collapsed`:``}`,style:F?void 0:{flex:`${q(`convs`)} 1 0px`},onContextMenu:e=>G(e,{id:``,kind:`section`,label:g(`runningConversations`)}),children:[me(g(`runningConversations`),F,I,K.length),!F&&(0,X.jsx)(`div`,{className:`lp-section-body convs-scroll`,children:Ja(K,b,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,children:de(e.cwd)}),(()=>{let n=new Map(e.convs.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e.convs)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 s=[],c=new Set,l=(e,t)=>{if(!c.has(e.id)){c.add(e.id),s.push({c:e,depth:t});for(let n of r.get(e.id)??[])l(n,t+1)}};for(let e of i)l(e,0);for(let t of e.convs)l(t,0);return s.map(({c:n,depth:r})=>{if(n.elsewhere){let e=n.owner,t=n.convId,r=!!n.pseudo,i=!!(e&&t)&&!r,a=D===n.id,s=a?g(`takeoverConfirm`):r?`${g(`elsewherePseudoTip`)}\n${n.cwd}`:`${g(`elsewhereTip`)}\n${n.cwd}`;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>O(e=>e===n.id?null:e),onContextMenu:i=>G(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${i?``:` elsewhere-static`}${a?` confirm`:``}`,title:s,tabIndex:i?0:-1,onClick:i?()=>{if(!a){O(n.id);return}O(null),o({type:`take_over_conversation`,owner:e,id:t})}:void 0,children:[(0,X.jsx)(_e,{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:g(r?`elsewherePseudoBadge`:`elsewhereBadge`)}),n.hasQuestion&&e&&t&&!r&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:g(`takeoverHasQuestion`),onClick:n=>{n.stopPropagation(),o({type:`peek_elsewhere_question`,owner:e,id:t})},children:`?`}),a?g(`takeoverConfirm`):n.title]}),(0,X.jsx)(`span`,{className:`session-sub`,children:de(n.cwd)})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]}),H&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-elsewhere-act`,title:g(`elsewhereActions`),onClick:i=>{i.stopPropagation(),ie.current=null;let a=i.currentTarget.getBoundingClientRect();U(a.left,a.bottom+4,{id:t??n.id,kind:`elsewhere`,label:n.title,...e?{owner:e}:{},...r?{pseudo:!0}:{}})},children:(0,X.jsx)(fe,{})})]},n.id)}let i=a===n.id;return(0,X.jsxs)(`div`,{className:`lp-row${r>0?` lp-sub`:``}`,style:r>0?{marginLeft:r*18}:void 0,onMouseLeave:()=>E(e=>e===`conv:${n.id}`?null:e),onContextMenu:e=>G(e,{id:n.id,kind:`running`,label:n.title}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${i?`active`:``}`,title:`${n.title}${e.isCurrent?``:` — ${e.cwd}`}`,onClick:()=>{i||o({type:`switch_conversation`,id:n.id})},children:[(0,X.jsx)(_e,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[k===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:j,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>ee(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=j.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),A(null)}else e.key===`Escape`&&A(null)},onBlur:()=>A(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:g(`subagentBadge`)}),n.isEphemeral&&(0,X.jsx)(`span`,{className:`ephemeral-badge`,children:g(`ephemeralBadge`)}),n.forkFrom&&(0,X.jsxs)(`span`,{className:`preset-badge fork-badge`,title:`${g(`forkBadgeTip`)}: ${n.forkFrom.title??n.forkFrom.conversationId}`,children:[`🌿 `,g(`forkBadge`)]}),n.agentPreset&&(0,X.jsx)(`span`,{className:`preset-badge`,title:n.agentPreset,children:h?.[n.agentPreset]??n.agentPreset}),n.title,n.error&&(0,X.jsx)(`span`,{className:`conv-error-badge`,title:g(`convErrorBadge`,{error:n.error})}),n.hasQuestion&&(0,X.jsx)(`span`,{className:`question-badge`,title:g(`waitingQuestionBadge`),children:`?`}),n.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:g(`pinnedConversation`),children:`📌`})]}),k===`conv:${n.id}`?null:(0,X.jsx)(`span`,{className:`session-sub`,children:i?g(`current`):g(`messageCount`,{n:n.messageCount})})]}),n.isStreaming&&(0,X.jsx)(`span`,{className:`conv-streaming`,title:g(`streaming`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:e=>{e.stopPropagation(),E(null),ee(n.title),A(`conv:${n.id}`)},children:(0,X.jsx)(Re,{})}),(()=>{let e=`conv:${n.id}`,r=T===e,i=z(t,n.id),a=re(t,n.id),s=ne(t,n.id);return s===0&&!n.isStreaming?pe(e,g(`dismissConversation`),g(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(N,{})):s===0?pe(e,g(`dismissConversation`),g(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(N,{})):r?(0,X.jsxs)(`span`,{className:`lp-del-group`,children:[i>0&&(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt`,title:g(`dismissFinishedSubagentsScoped`,{n:i}),onClick:e=>{e.stopPropagation(),E(null),o({type:`dismiss_finished_subagents`,parentId:n.id})},children:g(`dismissFinishedOnly`,{n:i})}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del-opt danger`,title:g(`forceDismissTitle`,{n:s,m:a}),onClick:e=>{e.stopPropagation(),E(null),o({type:`dismiss_conversation`,id:n.id,force:!0})},children:g(`dismissForceAll`,{n:s})})]}):(0,X.jsx)(`button`,{type:`button`,className:`lp-del`,title:g(`dismissConversation`),onClick:t=>{t.stopPropagation(),E(e)},children:(0,X.jsx)(N,{})})})(),W(),n.isStreaming&&(0,X.jsx)(`span`,{className:`lp-row-stalled`,title:g(`streaming`),style:{position:`absolute`,right:28,top:`50%`,transform:`translateY(-50%)`}})]},n.id)})})()]},e.cwd))})]}),K.length>0&&!F&&!L&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:le(`convs`,`sessions`),onDoubleClick:()=>se({...Nc}),title:g(`dragToResize`)}),(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${L?`collapsed`:``}`,style:L?void 0:{flex:`${q(`sessions`)} 1 0px`},children:[me(g(`historySessions`),L,te,r.length,(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action lp-new-chat-action`,title:g(`newChatTip`),"aria-label":g(`newChat`),onClick:()=>{o({type:`new_chat`}),Qn()},children:(0,X.jsx)(ce,{})})),!L&&(0,X.jsxs)(`div`,{className:`lp-section-body sessions-scroll`,children:[r.length===0&&(0,X.jsx)(`div`,{className:`panel-empty`,children:g(`noHistory`)}),r.map(e=>{let t=_===e.path;return(0,X.jsxs)(`div`,{className:`lp-row`,onMouseLeave:()=>E(t=>t===`sess:${e.path}`?null:t),onContextMenu:t=>G(t,{id:e.path,kind:`history`,label:ue(e)}),children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item ${t?`active`:``}`,title:e.path,onClick:()=>{k||t||o({type:`switch_session`,path:e.path})},children:[(0,X.jsx)(_e,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[k===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:j,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>ee(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=j.trim();t&&o({type:`rename_session`,path:e.path,name:t}),A(null)}else t.key===`Escape`&&A(null)},onBlur:()=>A(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[ue(e),e.pinned&&(0,X.jsx)(`span`,{className:`pin-badge`,title:g(`pinnedConversation`),children:`📌`})]}),k===e.path?null:(0,X.jsxs)(`span`,{className:`session-sub`,children:[t?g(`current`):g(`messageCount`,{n:e.messageCount}),e.source===`tui`&&(0,X.jsx)(`span`,{className:`session-src`,title:g(`tuiTip`),children:`TUI`})]})]}),(0,X.jsx)(`span`,{className:`session-time`,children:Ec(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:t=>{t.stopPropagation(),E(null),ee(e.name??``),A(e.path)},children:(0,X.jsx)(Re,{})}),pe(`sess:${e.path}`,g(`deleteSession`),g(`deleteSessionConfirm`),()=>{Cc(e.path,S),o({type:`delete_session`,path:e.path})}),W()]},e.path)})]})]}),(0,X.jsx)(Da,{open:C,currentCwd:S,pathCompletions:u??[],workspaceRoots:x,onClose:()=>w(!1),onSelectDirectory:e=>o({type:`set_cwd`,path:e}),onCreateProject:e=>o({type:`make_dir`,path:e,setAsCwd:!0})})]})}),Rc=209715200,zc=/windows/i.test(navigator.userAgent),Bc=/[<>:"/\\|?*\u0000-\u001f]/g,Vc=/[. ]+$/,Hc=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Uc(e){let t=e.replace(Bc,`_`).replace(Vc,``);return t?Hc.test(t)?`_${t}`:t:`_`}function Wc(e,t=!0){return sn(nn(`/api/file?${new URLSearchParams({clientId:uc(),path:e,...t?{download:`1`}:{}})}`))}async function Gc(e,t){let n=zc?Uc(t):t;try{let t=await fetch(Wc(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`)>Rc)return window.location.assign(Wc(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?qc(r,n):Jc(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function Kc(e,t){let n=zc?Uc(t):t;return window.showSaveFilePicker&&window.isSecureContext?qc(e,n):Jc(e,n)}async function qc(e,t){let n,r=window.showSaveFilePicker;if(!r)return Jc(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:Jc(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 Jc(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 Yc(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 Xc(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function Zc({text:e}){let t=(0,m.useRef)(null),n=(0,m.useRef)(null),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.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,m.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=Yc(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,m.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=Yc(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,k.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 Qc=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function $c(e,t={}){let n={archive:nn(`/api/file-transfer/archive`),upload:nn(`/api/file-transfer/upload`)},r=new URL(sn(`${n[e]}?${new URLSearchParams({clientId:uc(),...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 el(e,t,n){let r=await fetch($c(`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 Kc(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function tl(){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 nl(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=$c(`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 rl({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,m.useState)(e.dir),[o,s]=(0,m.useState)(`skip`),[c,l]=(0,m.useState)([]),[u,d]=(0,m.useState)(0),f=(0,m.useRef)(null),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),v=(0,m.useRef)(null);(0,m.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 tl();e?l(e):f.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),h(!0),_(``);try{e.action===`upload`?await nl(e.dir,c,d):await el(e.action,e.path,{destination:i,policy:o}),n(),t()}catch(e){_(e instanceof Error?e.message:String(e)),n()}finally{h(!1)}}return(0,k.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)(N,{})})]}),(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]})]}),g&&(0,X.jsx)(`p`,{role:`alert`,children:r(`fileTransferFailed`,{error:g})}),(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 il(e){return e instanceof Error?e.message:String(e)}function al(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 ol({plugin:e,epoch:t,send:n,className:r}){let i=(0,m.useRef)(null),{locale:a}=wn(),o=Z(),[s,c]=(0,m.useState)(null),l=(0,m.useRef)(n);(0,m.useEffect)(()=>{l.current=n},[n]),(0,m.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 Fs(e,t),r)return;let i=await Oo(e.id,()=>ps(()=>import(As(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,Ls(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:il(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:al(s,e.name,a,o)})]})}function sl(e){return`pi-web-ui:${e}:tab`}function cl(e,t){try{let n=localStorage.getItem(sl(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function ll(e,t){try{localStorage.setItem(sl(e),t)}catch{}}function ul(e){return e.length>0&&!/[a-z]/i.test(e)}function dl(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function fl({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,m.useId)(),[s,c]=(0,m.useState)(()=>cl(e,t)??t[0]?.id??``),l=(0,m.useRef)([]),u=(0,m.useRef)(``),d=t.findIndex(e=>e.id===s),f=d>=0?t[d]:t[0],p=f?t.indexOf(f):-1;(0,m.useEffect)(()=>{if(!f)return;s!==f.id&&c(f.id);let t=`${e}:${f.id}`;u.current!==t&&(u.current=t,ll(e,f.id))},[f,s,e]);let h=t=>{c(t.id),u.current=`${e}:${t.id}`,ll(e,t.id)},g=(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(),h(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??dl(e),"aria-selected":n,"aria-controls":`${o}-panel-${t}`,tabIndex:n?0:-1,ref:e=>{l.current[t]=e},onClick:()=>h(e),onKeyDown:e=>g(e,t),children:[e.iconSvg?(0,X.jsx)(ni,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&ul(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:dl(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)(ol,{plugin:f.pluginPage.plugin,epoch:n,send:r}):f.element??null})]})}function pl(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 ml(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return pl(e)}return pl(e)}function hl(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,m.useState)(!1),o=(0,m.useRef)(null),s=(0,m.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,m.useCallback)(()=>{s(),a(!1)},[s]);return(0,m.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,m.useCallback)(async e=>{let i=!1;try{i=await ml(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 gl=`@root`,_l=`pi-web-ui:rp-sizes`,vl={files:4,widgets:1},yl=120,bl=56;function xl(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var Sl=`files`,Cl=[],wl=()=>{};function Tl(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function El(e){return e===gl||e===`/`||/^[A-Za-z]:$/.test(e)}function Dl(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var Ol=(0,m.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 h=Z(),g=d??Cl,_=ha(`cwd`),v=ha(`workspaceRoots`),y=ha(`homeDir`),b=ha(`desktopDir`),[x,S]=(0,m.useState)(``),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(!1),D=(0,m.useRef)(null),O=(0,m.useRef)(null),[k,A]=(0,m.useState)(()=>{try{return Ka(localStorage.getItem(_l),vl)}catch{return{...vl}}});(0,m.useEffect)(()=>{try{localStorage.setItem(_l,JSON.stringify(k))}catch{}},[k]);let j=n.some(e=>e.lines.length>0),ee=(0,m.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-xl(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=qa({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:yl,minBelowPx:bl});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]),M=(0,m.useRef)(null),P=(0,m.useRef)(0),F=(0,m.useCallback)(e=>{M.current=e,e&&(e.scrollTop=P.current)},[]),[I,L]=(0,m.useState)(null),te=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{te.current&&clearTimeout(te.current)},[]);let R=(0,m.useCallback)(e=>{L(e),te.current&&clearTimeout(te.current),te.current=setTimeout(()=>L(null),1200)},[]),z=(0,m.useCallback)((e,t)=>{e&&ml(e).then(e=>{e?R(t):o(`error`,h(`slashCopyFailed`))})},[R,o,h]),ne=(0,m.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},[_]),re=(0,m.useCallback)(e=>!e||e===gl?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),B=104857600,ie=(0,m.useCallback)((e,t)=>{for(let n of t){if(n.size>B){o(`warning`,h(`fileTooLarge`,{name:n.name,size:B/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,h]),V=(0,m.useRef)(null),[H,U]=(0,m.useState)(null),W=(0,m.useRef)(null),G=(0,m.useCallback)(()=>{let e=V.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),ae=(0,m.useCallback)(()=>{W.current&&(W.current.value=``),W.current?.click()},[]),[oe,se]=(0,m.useState)(null),[K,ce]=(0,m.useState)(null),[le,ue]=(0,m.useState)(``),[de,fe]=(0,m.useState)(null),[pe,me]=(0,m.useState)(``),he=(0,m.useCallback)((e,t)=>{Gc(e,t).then(e=>{e.ok||e.cancelled||o(`error`,h(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?h(`fileNotFoundShort`):e.error}))})},[o,h]),ge=(0,m.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!El(e.id)&&(fe(null),ue(e.label),ce(e.id))},[]),_e=(0,m.useCallback)(()=>{if(!K)return;let e=le.trim();ce(null),e&&r({type:`file_rename`,path:K,newName:e})},[K,le,r]),q=(0,m.useCallback)(e=>{let t=V.current?.dir??x;ce(null),me(``),fe({dir:t,kind:e})},[x]),ve=(0,m.useCallback)(()=>{if(!de)return;let e=pe.trim();fe(null),e&&r({type:`file_create`,dir:de.dir,name:e,kind:de.kind})},[de,pe,r]),be=(e,t,n,r)=>(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:e,placeholder:h(`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}),xe=(0,m.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!El(e.id)&&window.confirm(h(`fileDeleteConfirm`,{name:e.label}))&&(oe?.src===e.id&&se(null),K===e.id&&ce(null),r({type:`file_delete`,path:e.id}))},[r,h,oe,K]),Se=(0,m.useCallback)(()=>{let e=V.current?.target;e&&e.kind!==`list`&&!El(e.id)&&r({type:`file_copy`,src:e.id,destDir:Tl(e.id)})},[r]),we=(0,m.useCallback)(e=>{let t=V.current?.target;t&&t.kind!==`list`&&!El(t.id)&&se({src:t.id,cut:e})},[]),Te=(0,m.useCallback)(()=>{if(!oe)return;let e=V.current?.dir??x;oe.cut?(r({type:`file_copy`,src:oe.src,destDir:e,move:!0}),se(null)):r({type:`file_copy`,src:oe.src,destDir:e})},[oe,r,x]),J=(0,m.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[Ee,De]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(!Ee)return;let e=e=>{e.target?.closest(`.root-picker`)||De(!1)},t=e=>{e.key===`Escape`&&De(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[Ee]);let Oe=(0,m.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),ke=(0,m.useCallback)(()=>{let e=V.current?.target;if(!e||e.kind!==`dir`)return;let t=re(e.id);t&&!v.includes(t)&&Oe([...v,t])},[v,re,Oe]),Ae=(0,m.useCallback)(e=>{ie(V.current?.dir??x,Array.from(e.target.files??[]))},[ie,x]),je=(0,m.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`;U({action:n,path:ne(t.id),dir:ne(n===`upload`?V.current?.dir??x:Tl(t.id))});break}case`host:file-open-project`:G();break;case`host:file-upload`:ae();break;case`host:file-add-root`:ke();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&We(t.id);break;case`host:file-download`:t?.kind===`file`&&he(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`:q(`file`);break;case`host:file-new-dir`:q(`dir`);break;case`host:file-paste`:Te();break;case`host:file-rename`:ge();break;case`host:file-duplicate`:Se();break;case`host:file-cut`:we(!0);break;case`host:file-copy`:we(!1);break;case`host:file-copy-name`:t&&t.kind!==`list`&&z(t.label,`name:${t.id}`);break;case`host:file-copy-path`:t&&t.kind!==`list`&&z(ne(t.id),`path:${t.id}`);break;case`host:file-copy-rel`:t&&t.kind!==`list`&&z(t.id,`rel:${t.id}`);break;case`host:file-refresh`:J();break;case`host:file-delete`:xe()}},[G,x,ae,ke,a,i,z,ne,he,q,Te,ge,Se,we,J,xe]),Ne=(0,m.useCallback)((e,t)=>{let n=t.kind===`dir`?re(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&&El(t.id),l=!s&&Dl(t.id),d=x===gl,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&&Qc(t.label)?e:{...e,hidden:!0};case`host:file-upload`:return d?{...e,hidden:!0}:{...e,label:r.dir===x?h(`uploadToCurrentDir`):h(`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!==gl?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&&oe?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}});ta(f).length!==0&&(e.preventDefault(),e.stopPropagation(),V.current=r,Wi({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:je}))},[u,x,re,h,je,_,v,oe]),Pe=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),Fe=(0,m.useCallback)(()=>{M.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),M.current?.classList.remove(`drop-root`)},[]),Ie=(0,m.useCallback)(e=>{if(Fe(),e==null)return;let t=M.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):M.current?.classList.add(`drop-root`)},[Fe]),Le=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Re=(0,m.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),Be=(0,m.useRef)(0),Ve=(0,m.useRef)(void 0),He=(0,m.useCallback)((e,t)=>{let n=++Be.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||Be.current===n&&E(!1)},[r]),Ue=(0,m.useCallback)(e=>{let t=v.filter(t=>t!==e);Oe(t),(x===e||x.startsWith(`${e}/`))&&He(``)},[v,Oe,x,He]);(0,m.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,m.useEffect)(()=>{if(_!==Ve.current){Ve.current=_,He(``,{silent:!0});return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&He(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,He]),(0,m.useEffect)(()=>{t&&t.path===x&&He(x,{silent:!0})},[t,x,He]);let We=e=>He(e),Ge=()=>{e?.parent!==null&&e?.parent!==void 0&&He(e.parent)},qe=(()=>{if(x===``||x===gl)return[];let e=x.split(`/`).filter(e=>!!e&&e!==gl);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(`/`)}))})(),Je=[];for(let e of l??[]){if(e.source===`host`||e.hidden||e.kind===`divider`)continue;let t=g.find(t=>t.id===e.source.slice(7));t&&Je.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let Ye=(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:h(`collapsePanel`),onClick:c,children:(0,X.jsx)(Qe,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:j?`${k.files} 1 0`:`1 1 0`,minHeight:j?yl:0},children:(0,X.jsx)(fl,{storageKey:`rightpanel`,epoch:f??0,send:p??wl,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===Sl?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...Ye?[]:[{id:Sl,label:h(`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:()=>He(``),children:h(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===gl?`active`:``}`,title:h(`computer`),onClick:()=>He(gl),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:h(`homeDir`),onClick:()=>He(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:h(`desktopDir`),onClick:()=>He(b),children:`🖥️`}),(0,X.jsx)(Zc,{text:h(`filesHelp`)}),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":Ee,title:h(`workspaceRoots`),onClick:()=>De(e=>!e),children:[(0,X.jsx)(Me,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:h(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),Ee&&(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:()=>{De(!1),He(``)},children:[h(`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:()=>{De(!1),He(e)},children:(0,X.jsx)(`span`,{className:`root-picker-path`,children:e})}),(0,X.jsx)(`button`,{type:`button`,className:`root-picker-remove`,title:h(`removeWorkspaceRoot`),"aria-label":h(`removeWorkspaceRoot`),onClick:()=>Ue(e),children:(0,X.jsx)(N,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:h(`workspaceRootsHint`)})]})]}),qe.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(tt,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>He(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:F,className:`panel-body`,onScroll:e=>{P.current=e.currentTarget.scrollTop},onContextMenu:e=>Ne(e,{id:x,kind:`list`,label:x===``?h(`rootDir`):x===gl?h(`computer`):x}),onDragOver:e=>{Pe(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Re(),Ie(Le(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||Fe()},onDrop:e=>{if(Fe(),!Pe(e))return;e.preventDefault(),e.stopPropagation(),Re();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,h(`foldersNotSupported`));return}ie(Le(e.target),t)},onDragEnd:Fe,children:[(0,X.jsx)(`input`,{ref:W,type:`file`,multiple:!0,hidden:!0,onChange:Ae}),H&&(0,X.jsx)(rl,{request:H,onClose:()=>U(null),onComplete:J}),de&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[de.kind===`dir`?(0,X.jsx)(Me,{className:`file-icon`}):(0,X.jsx)(Y,{className:`file-icon`}),be(pe,me,ve,()=>fe(null))]}),T&&(0,X.jsx)(`div`,{className:`panel-empty`,children:h(`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:Ge,children:[(0,X.jsx)(Me,{className:`file-icon`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),e.entries.map(e=>e.type===`dir`?(0,X.jsxs)(`div`,{className:`file-item dir${oe?.cut&&oe.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Ne(t,{id:e.path,kind:`dir`,label:e.name}),children:[K===e.path?be(le,ue,_e,()=>ce(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>We(e.path),children:[(0,X.jsx)(Me,{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":h(`linkFolderTip`),"aria-label":h(`linkFolderTip`),onClick:()=>i(e.path,e.name,`reference`,!0),children:(0,X.jsx)(Ce,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:I===`name:${e.path}`?(0,X.jsx)(it,{}):(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(ne(e.path),`path:${e.path}`),children:I===`path:${e.path}`?(0,X.jsx)(it,{}):(0,X.jsx)(Xe,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${oe?.cut&&oe.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Ne(t,{id:e.path,kind:`file`,label:e.name}),children:[K===e.path?be(le,ue,_e,()=>ce(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-name`,title:`${e.path} — ${h(`previewFile`)}`,onClick:()=>a(e.path,e.name),children:[(0,X.jsx)(Y,{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":h(`downloadFile`),onClick:()=>he(e.path,e.name),children:(0,X.jsx)(ze,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"data-tip":h(`referenceTip`),"aria-label":h(`referenceTip`),onClick:()=>i(e.path,e.name,`reference`),children:(0,X.jsx)(Ce,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:I===`name:${e.path}`?(0,X.jsx)(it,{}):(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${I===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(ne(e.path),`path:${e.path}`),children:I===`path:${e.path}`?(0,X.jsx)(it,{}):(0,X.jsx)(Xe,{})})]},e.path)),e.truncated&&(0,X.jsx)(`div`,{className:`panel-empty files-truncated`,children:h(`filesTruncated`)})]}),!T&&!e&&(0,X.jsx)(`div`,{className:`panel-empty`,children:h(`noFiles`)})]})]})}],...Je])})}),j&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:ee,onDoubleClick:()=>A({...vl}),title:h(`dragToResize`)}),j&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:bl},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:h(`widgetExpand`),onClick:()=>w(e.key),children:[(0,X.jsx)(`span`,{children:e.key}),(0,X.jsx)(ye,{})]}),(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:h(`close`),onClick:()=>w(null),children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`pre`,{className:`widget-expand-lines`,children:e.lines.join(`
|
|
329
329
|
`)})]})}):null})()]})});function kl(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 Al(e){let t=/^<quoted-text>\n([^\n]*)\n<\/quoted-text>$/.exec(e);if(!t)return null;try{return kl(JSON.parse(t[1]))}catch{return null}}function jl(e){let t=e,n=[];for(;;){let e=/(?:^|\n\n)(<quoted-text>\n[^\n]*\n<\/quoted-text>)$/.exec(t),r=e?Al(e[1]):null;if(!e||!r)break;n.unshift(r),t=t.slice(0,e.index)}return{text:t,quotes:n}}function Ml({quote:e,onRemove:t,forceOpen:n=!1}){let r=Z(),[i,a]=(0,m.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 Nl=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],Pl={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...Nl,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...Nl],h2:[[`className`,`sr-only`]],img:[...Nl,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...Nl,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...Nl],table:[...Nl],ul:[...Nl,[`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(`.`)},Fl={}.hasOwnProperty;function Il(e,t){let n={type:`root`,children:[]},r=Ll({schema:t?{...Pl,...t}:Pl,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function Ll(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return Rl(e,n);case`doctype`:return zl(e,n);case`element`:return Bl(e,n);case`root`:return Vl(e,n);case`text`:return Hl(e,n)}}}function Rl(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 Yl(r,t),r}}function zl(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return Yl(e,t),e}}function Bl(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=Ul(e,t.children),i=Wl(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&&Fl.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 Yl(o,t),o}function Vl(e,t){let n={type:`root`,children:Ul(e,t.children)};return Yl(n,t),n}function Hl(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return Yl(n,t),n}function Ul(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=Ll(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function Wl(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&Fl.call(r,n)?r[n]:void 0,o=r&&Fl.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},c={},l;for(l in s)if(Fl.call(s,l)){let t=s[l],n=Gl(e,Xl(a,l),l,t);n??=Gl(e,Xl(o,l),l,t),n!=null&&(c[l]=n)}if(i&&Fl.call(i,n)){let e=i[n];for(l in e)Fl.call(e,l)&&!Fl.call(c,l)&&(c[l]=e[l])}return c}function Gl(e,t,n,r){return t?Array.isArray(r)?Kl(e,t,n,r):ql(e,t,n,r):void 0}function Kl(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=ql(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function ql(e,t,n,r){if((typeof r==`boolean`||typeof r==`number`||typeof r==`string`)&&Jl(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 Jl(e,t,n){let r=e.schema.protocols&&Fl.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 Yl(e,t){let n=c(t);t.data&&(e.data=o(t.data)),n&&(e.position=n)}function Xl(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 Zl(e){return function(t){return Il(t,e)}}var Ql=(0,m.memo)(function({text:e}){let t=Z(),{copied:n,copy:r}=hl({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)(it,{}):(0,X.jsx)(Ke,{})}):null});function $l(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
330
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,m.createElement)(n.type,i)]]:a.map(e=>[(0,m.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function eu(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(eu).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return eu(t?.children)}return``}function tu(e){let t=Array.isArray(e)?e[0]:e;return!t||typeof t!=`object`||!(`props`in t)?null:t}function nu(e){let t=tu(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 ru=`pi-web-ui:plugin-data`,iu=new Map,au=new Map,ou=new Set,su=-1,cu=0,lu=new Set;function uu(){cu++;for(let e of lu)e()}function du(e){return lu.add(e),()=>{lu.delete(e)}}function fu(){return cu}var pu=null;function mu(e){pu=e}function hu(e,t){t!==su&&(su=t,au.clear(),ou.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!==iu.size;if(!r){for(let[e,t]of n)if(iu.get(e)!==t){r=!0;break}}if(r){for(let e of au.keys())n.has(e)||au.delete(e);for(let e of ou)n.has(e)||ou.delete(e);iu=n,uu()}}async function gu(e,t){let n=iu.get(e);if(!n)return null;let r=au.get(e);if(!r&&!ou.has(e))try{let t=(await ps(()=>import(nn(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${su}`)),[])).default?.renderers?.[e];typeof t==`function`?(r={pluginId:n,renderer:t},au.set(e,r)):(ou.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(t){ou.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,t)}if(!r)return null;let i={pluginId:r.pluginId,send:e=>{pu?.({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(ru,t),()=>window.removeEventListener(ru,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 _u(e){return iu.has(e)}var vu=new Map,yu=new Map,bu=new Set,xu=-1;function Su(e,t){t!==xu&&(xu=t,yu.clear(),bu.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[...vu.keys()])n.has(e)||vu.delete(e);for(let[e,t]of n)vu.set(e,t);for(let e of yu.keys())n.has(e)||yu.delete(e);for(let e of bu)n.has(e)||bu.delete(e)}function Cu(e){return vu.has(e)}async function wu(e){let t=vu.get(e);if(!t)return null;let n=yu.get(e);if(!n&&!bu.has(e))try{let r=(await ps(()=>import(nn(`/plugins/${encodeURIComponent(t)}/client/entry.mjs?e=${xu}`)),[])).default?.messageWidgets?.[e];typeof r==`function`?(n={pluginId:t,renderer:r},yu.set(e,n)):(bu.add(e),console.error(`[plugin:${t}] entry.mjs 未提供 messageWidgets["${e}"]`))}catch(n){bu.add(e),console.error(`[plugin:${t}] messageWidget 加载失败(${e}):`,n)}return n?.renderer??null}var Tu=`pi-web-ui:theme`,Eu=`dark`,Du=`theme-stylesheet`,Ou=`pi-web-ui:theme-change`;function ku(){try{let e=localStorage.getItem(Tu);if(e&&e!==Eu)return e}catch{}return null}function Au(e){try{e?localStorage.setItem(Tu,e):localStorage.removeItem(Tu)}catch{}}function ju(e){let t=document.getElementById(Du);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Ou));return}t||(t=document.createElement(`link`),t.id=Du,t.rel=`stylesheet`,document.head.appendChild(t)),t.href=nn(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Ou))}async function Mu(){try{let e=await fetch(sn(nn(`/api/themes`)));if(!e.ok)return[];let t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function Nu(){let[e,t]=(0,m.useState)([]),[n,r]=(0,m.useState)(()=>ku());(0,m.useEffect)(()=>{let e=!1;return Mu().then(n=>{e||t(n)}),()=>{e=!0}},[]);let i=(0,m.useCallback)(()=>{Mu().then(t)},[]);return(0,m.useEffect)(()=>{ju(n),Au(n)},[n]),{themes:e,theme:n,switchTheme:e=>r(e===Eu?null:e),reloadThemes:i}}function Pu(){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 Fu({lang:e,code:t}){let n=(0,m.useRef)(null),r=(0,m.useRef)(null),i=(0,m.useRef)(0),a=(0,m.useRef)(new WeakMap),[o,s]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let e=()=>{let e=++i.current,t=r.current;t&&(t.dispatchEvent(new CustomEvent(Ou)),a.current.set(t,e))};return window.addEventListener(Ou,e),()=>window.removeEventListener(Ou,e)},[]),(0,m.useEffect)(()=>{let n=!1,r=i.current;return s(null),gu(e,t).then(e=>{n||(e&&a.current.set(e,r),s(e))}),()=>{n=!0}},[e,t]),(0,m.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(Ou)),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)(Ql,{text:t}),(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:t})})]})}var Iu=null,Lu=null;function Ru(e){Iu=e?.open??null,Lu=e?.isOpen??null}function zu(){return Lu?Lu():!1}function Bu(e){return!Iu||!e?.path?!1:(Iu(e),!0)}var Vu=[u,s],Hu=[u,a,s],Uu=[[l,{strict:!1,throwOnError:!1}],[d,{detect:!0,ignoreMissing:!0}]];function Wu(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 Gu({text:e,rawHtml:t=!1,hardBreaks:n=!1}){let r=t?[p,Zl,...Uu]:Uu,i=(0,m.useMemo)(()=>Wu(e),[e]);return(0,X.jsx)(f,{remarkPlugins:n?Hu:Vu,rehypePlugins:r,components:{pre:Ju,a:qu},children:i})}var Ku=(0,m.memo)(function({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(Gu,{text:e,rawHtml:t,hardBreaks:n})})});function qu({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(),Bu({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 Ju({children:e,...t}){(0,m.useSyncExternalStore)(du,fu,fu);let n=nu(e);return n&&_u(n)?(0,X.jsx)(Fu,{lang:n,code:eu(e)}):(0,X.jsx)(Yu,{children:e,...t})}function Yu({children:e,...t}){let n=$l(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)(Ql,{text:Xu(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 Xu(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Xu).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Xu(t?.children)}return``}function Zu({type:e,code:t,children:n}){let r=(0,m.useRef)(null),[i,a]=(0,m.useState)(null);return(0,m.useEffect)(()=>{let n=!1;if(a(null),Cu(e))return wu(e).then(async r=>{if(!n&&r)try{let i=await r(t,{pluginId:vu.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,m.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 Qu=/^\s{0,3}(`{3,}|~{3,})/,$u=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function ed(e){return e.trim()===``}function td(e){let t=Qu.exec(e);return t?t[1]:null}function nd(e){let t=e.split(`
|
|
331
331
|
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=td(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=td(a);if(o&&!ed(a)){i=o,r.push(a);continue}if(ed(a)){let i=e;for(;i<t.length&&ed(t[i]);)i++;if(!(i<t.length&&$u.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 rd=(0,m.memo)(function({text:e}){return(0,X.jsx)(Gu,{text:e})}),id=200;function ad({text:e,inFence:t}){let[n,r]=(0,m.useState)(e),i=(0,m.useRef)(0),a=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(t)return;let n=Date.now()-i.current,o=()=>{i.current=Date.now(),r(e)};if(n>=id){o();return}return a.current=setTimeout(o,id-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)(Gu,{text:n})}var od=(0,m.memo)(function({text:e}){let{frozen:t,active:n,inFence:r}=(0,m.useMemo)(()=>nd(e),[e]);return(0,X.jsxs)(`div`,{className:`md`,children:[t.map((e,t)=>(0,X.jsx)(rd,{text:e},t)),n.length>0&&(0,X.jsx)(ad,{text:n,inFence:r},t.length)]})});function sd(e,t){return t?e.trimEnd().slice(-80):e.split(`
|
|
334
|
-
`)[0].slice(0,80)}function cd({thinking:e,streaming:t,wrap:n=!0,forceOpen:r=!1}){let i=Z(),[a,o]=(0,m.useState)(null),s=a??n,c=s||r,l=sd(e,t),{copied:u,copy:d}=hl({duration:1200}),f=()=>{d(e)};return(0,X.jsxs)(`div`,{className:`thinking ${c?`open`:``} ${t?`live`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead thinking-head`,role:`button`,tabIndex:0,"aria-expanded":c,title:i(c?`collapseMsg`:`expandMsg`),onClick:()=>o(!s),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o(!s))},children:[(0,X.jsx)(`button`,{type:`button`,className:`chead-toggle thinking-toggle`,title:i(c?`collapseMsg`:`expandMsg`),"aria-label":i(c?`collapseMsg`:`expandMsg`),"aria-expanded":c,onClick:e=>{e.stopPropagation(),o(!s)},children:c?(0,X.jsx)(rt,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`span`,{className:`chead-icon thinking-icon`,children:(0,X.jsx)(Ue,{})}),(0,X.jsx)(`span`,{className:`chead-title thinking-label`,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})}),(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)(at,{}):(0,X.jsx)(Ke,{})})]}),c&&(0,X.jsx)(`div`,{className:`thinking-body`,children:e})]})}var ld=262144,ud=300,dd=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,fd=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,pd=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,md=1e9;function hd(e){if(!e)return{};let t=e.length>ld?e.slice(0,ld):e;return{path:bd(t),timeout:xd(t),command:Sd(e),agent:gd(t)}}function gd(e){let t=fd.exec(e);if(!t)return;let n=t[1].replace(/[\u0000-\u001f\u007f]/g,``).trim();if(n)return n.length>ud?`${n.slice(0,ud)}…`:n}var _d=[`task`,`expected_outcome`,`required_tools`,`must_do`,`must_not_do`,`context`];function vd(e){if(!e||e.length>ld)return{};try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n=t,r={};for(let e of[..._d,`agent`,`model`])typeof n[e]==`string`&&n[e].trim()&&(r[e]=n[e]);return r}catch{return{}}}function yd(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 bd(e){let t=dd.exec(e);if(!t)return;let n=Cd(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>ud?`${n.slice(0,299)}…`:n}function xd(e){let t=pd.exec(e);if(!t)return;let n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>md)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 Sd(e){if(!(e.length>ld))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 Cd(e){try{let t=JSON.parse(`"${e}"`);return typeof t==`string`?t:e}catch{return e}}var wd=new Set([`image`,`video`,`audio`,`markdown`,`html`,`pdf`,`text`,`binary`,`dir`,`missing`]);function Td(e){let t=String(e??``).trim().replace(/\\/g,`/`);return t.length>1?t.replace(/\/+$/,``):t}function Ed(e){let t=Td(e).split(`/`);return(t[t.length-1]??``)||String(e??``)}function Dd(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Od(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function kd(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Dd(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=Dd(e),n=t?Od(t.path):void 0;if(!n)continue;let r={path:n},a=Od(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=Od(n.title);o&&(a.title=o);let s=Od(n.note);return s&&(a.note=s),a}function Ad(e,t){let n=Dd(t),r=Array.isArray(n?.items)?n.items.map(Dd):[],i=new Map;for(let e of r){if(!e)continue;let t=Td(String(e.path??e.abs??``));t&&!i.has(t)&&i.set(t,e)}return e.items.map((e,t)=>{let n=i.get(Td(e.path))??r[t]??null,a=Od(n?.kind),o={path:e.path,target:Od(n?.abs)??e.path,name:Ed(Od(n?.name)??e.path),kind:a&&wd.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=Od(n?.excerpt);return s&&(o.excerpt=s),n?.excerptTruncated===!0&&(o.excerptTruncated=!0),o})}function jd(e,t){return Od(Dd(t)?.title)??e.title}function Md(e,t){return Od(Dd(t)?.note)??e.note}function Nd(e){return e===`image`||e===`video`||e===`audio`?e:null}function Pd(e){return e!==`dir`&&e!==`missing`}function Fd(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 Id(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 Ld(e){return e.find(e=>e.focus&&Pd(e.kind))}function Rd(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 zd=`pi-web-ui:present-auto-open`,Bd=3e4,Vd=`pi-web-ui:present-auto-opened`;function Hd(){try{return localStorage.getItem(zd)===`1`}catch{return!1}}function Ud(e){try{localStorage.setItem(zd,e?`1`:`0`)}catch{}qd=e,Gd()}var Wd=new Set;function Gd(){for(let e of Wd)e()}function Kd(e){return Wd.add(e),()=>{Wd.delete(e)}}var qd=null;function Jd(){return qd===null&&(qd=Hd()),qd}function Yd(){return(0,m.useSyncExternalStore)(Kd,Jd)}function Xd(){try{let e=sessionStorage.getItem(Vd);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Zd(e){if(!e)return!1;let t=Xd();if(t.includes(e))return!1;let n=[...t,e].slice(-200);try{sessionStorage.setItem(Vd,JSON.stringify(n))}catch{}return!0}function Qd(e,t,n=Date.now()){return Rd({enabled:Hd(),seen:!1,timestamp:t,now:n,maxAgeMs:Bd})?Zd(e):!1}var $d=(0,m.memo)(function({args:e,details:t,toolCallId:n,resultTimestamp:r}){let i=Z(),a=Yd(),o=(0,m.useMemo)(()=>Ad(e,t),[e,t]),s=jd(e,t),c=Md(e,t),l=(0,m.useMemo)(()=>Ld(o),[o]);return(0,m.useEffect)(()=>{a&&l&&n&&(zu()||Qd(n,r)&&Bu({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)(Ku,{text:c,rawHtml:!0})}),(0,X.jsx)(`div`,{className:`present-items`,children:o.map(e=>(0,X.jsx)(tf,{item:e},`${e.target}\u0000${e.path}`))})]})});function ef(e){return typeof e.mtime==`number`?`${e.path}\n${new Date(e.mtime).toLocaleString()}`:e.path}function tf({item:e}){let t=Z(),{copied:n,copy:r}=hl({duration:1200}),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=i?null:Nd(e.kind),l=Id(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:Fd(e.kind)}),(0,X.jsx)(`span`,{className:`present-item-name`,title:ef(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:[Pd(e.kind)&&(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`previewFile`),"aria-label":t(`previewFile`),onClick:()=>Bu(d),children:(0,X.jsx)(Fe,{})}),(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)(Ie,{}),(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)(Me,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`downloadFile`),"aria-label":t(`downloadFile`),onClick:()=>{s(``),Gc(e.target,e.name).then(e=>{e.ok||e.cancelled||s(e.error===`FILE_NOT_FOUND`?t(`fileNotFoundShort`):e.error)})},children:(0,X.jsx)(ze,{})}),(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)(Ke,{})})]})]}),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:()=>Bu(d),children:(0,X.jsx)(`img`,{src:Wc(e.target,!1),alt:e.name,loading:`lazy`,onError:()=>a(!0)})}),c===`video`&&(0,X.jsx)(`video`,{className:`present-media-video`,src:Wc(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),c===`audio`&&(0,X.jsx)(`audio`,{className:`present-media-audio`,src:Wc(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),e.excerpt&&(0,X.jsxs)(`pre`,{className:`present-excerpt`,children:[e.excerpt,e.excerptTruncated?`…`:``]})]})}var nf={bash:`$`,delegate_task:`◈`,read:`📄`,write:`✍️`,edit:`✏️`,edit_soft:`✏️`,grep:`🔍`,find:`🧭`,ls:`📂`,[hr]:`🖼`};function rf(e){return nf[e]??`🛠`}var af=(0,m.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,m.useState)(null),d=e.name===hr,f=l??(d?!0:r),p=f||a,{copied:h,copy:g}=hl({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,m.useMemo)(()=>i?(t.result?.content??[]).filter(e=>e.type===`image`&&typeof e.dataUrl==`string`&&e.dataUrl.startsWith(`data:`)):[],[i,t.result]),[T,E]=(0,m.useState)(null);(0,m.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?vd(e.argumentsText):{},A=(0,m.useMemo)(()=>d?kd(e.argumentsText):null,[d,e.argumentsText]),j=D&&t.result&&typeof t.result.details==`object`&&t.result.details!==null?t.result.details.convId:void 0,ee=typeof j==`string`&&j?j:/sa-[0-9a-f]{8}/.exec(S)?.[0],M=(0,m.useRef)(void 0),P=t.status?.durationMs,F=t.result?.durationMs;(0,m.useEffect)(()=>{P!==void 0&&(M.current=P),typeof F==`number`&&(M.current=F)},[P,F]);let I=typeof F==`number`?F:P??M.current,L=x?`err`:y?`ok`:_||b?`run`:`idle`,te=c(x?`error`:y?`done`:_?`running`:b?`toolDoneWaitingModel`:`toolQueued`),R=(b||y)&&I!==void 0?lf(I):``;(b||y)&&R&&(te=`${te} · ${R}`);let z=b&&t.status?.exitCode!==void 0?`exit ${t.status.exitCode}`:``,ne=hd(e.argumentsText),re=e.name===`bash`?ne.command:void 0,B=!p&&re?cf(re):void 0,V=()=>{e.argumentsText&&g(e.argumentsText)},ae=(o??[]).some(e=>e&&e.hidden!==!0&&e.kind!==`divider`);return(0,X.jsxs)(`div`,{className:`toolcall ${L}`,children:[(0,X.jsxs)(`div`,{className:`chead toolcall-head`,role:`button`,tabIndex:0,"aria-expanded":p,title:c(p?`collapseMsg`:`expandMsg`),onClick:()=>u(!f),onContextMenu:t=>{if(!ae)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(),Wi({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`){to(e.name);return}s?.(t)}}))},onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(!f))},children:[(0,X.jsx)(`button`,{type:`button`,className:`chead-toggle toolcall-toggle`,title:c(p?`collapseMsg`:`expandMsg`),"aria-label":c(p?`collapseMsg`:`expandMsg`),"aria-expanded":p,onClick:e=>{e.stopPropagation(),u(!f)},children:p?(0,X.jsx)(rt,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`span`,{className:`chead-icon toolcall-icon`,children:rf(e.name)}),(0,X.jsx)(`span`,{className:`chead-title toolcall-name`,children:e.name}),(0,X.jsx)(`span`,{className:`toolcall-status`,title:z?`${te} · ${z}`:te,"aria-label":z?`${te} · ${z}`:te,children:x?(0,X.jsx)(N,{}):y?(0,X.jsx)(it,{}):_?(0,X.jsx)(Se,{}):b?(0,X.jsx)(Ye,{}):(0,X.jsx)(he,{})}),R&&(0,X.jsx)(`span`,{className:`toolcall-duration toolcall-timeout`,style:{marginLeft:-2,fontFamily:`var(--mono)`},title:z?`${te} · ${z}`:te,children:R}),B&&(0,X.jsxs)(`span`,{className:`toolcall-cmd`,title:re,children:[`$ `,B]}),ne.path&&(0,X.jsx)(`span`,{className:`toolcall-path`,title:ne.path,children:yd(ne.path)}),ne.timeout&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,children:[`⏱ `,ne.timeout]}),D&&ne.agent&&(0,X.jsxs)(`span`,{className:`toolcall-agent`,title:ne.agent,children:[`◈ `,ne.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)(ie,{}),(0,X.jsx)(`span`,{children:c(`stopBash`)})]}),D&&y&&ee&&(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:ee}))},children:[(0,X.jsx)(ft,{}),(0,X.jsx)(`span`,{children:c(`delegateOpenSubagent`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy${h?` copied`:``}`,title:c(`copyArgs`),"aria-label":c(`copyArgs`),onClick:e=>{e.stopPropagation(),V()},children:h?(0,X.jsx)(at,{}):(0,X.jsx)(Ke,{})})]}),w.length>0&&(0,X.jsx)(`div`,{className:`toolcall-images`,children:w.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`toolcall-image`,title:c(`toolImageZoom`),"aria-label":c(`toolImageZoom`),onClick:t=>{t.stopPropagation(),E(e.dataUrl)},children:(0,X.jsx)(`img`,{src:e.dataUrl,alt:`tool result image ${t+1}`})},t))}),T&&(0,k.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)(N,{})}),(0,X.jsx)(`img`,{src:T,alt:`tool result preview`})]}),document.body),p&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[d&&A?(0,X.jsx)($d,{args:A,details:t.result?.details,toolCallId:t.result?.toolCallId??e.id,resultTimestamp:t.result?.timestamp}):D?(0,X.jsx)(sf,{args:O}):e.argumentsText&&(0,X.jsx)(`div`,{className:`toolcall-args`,children:re?(0,X.jsx)(of,{command:re}):(0,X.jsx)(`pre`,{children:e.argumentsText})}),C.length>0&&(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 of({command:e}){return(0,X.jsxs)(`div`,{className:`termline`,children:[(0,X.jsx)(ne,{className:`termline-icon`}),(0,X.jsx)(`code`,{children:e})]})}function sf({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 cf(e){let t=e.split(`
|
|
335
|
-
`),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
|
|
333
|
+
`),inFence:i!==null}}var rd=(0,m.memo)(function({text:e}){return(0,X.jsx)(Gu,{text:e})}),id=200;function ad({text:e,inFence:t}){let[n,r]=(0,m.useState)(e),i=(0,m.useRef)(0),a=(0,m.useRef)(null);return(0,m.useEffect)(()=>{if(t)return;let n=Date.now()-i.current,o=()=>{i.current=Date.now(),r(e)};if(n>=id){o();return}return a.current=setTimeout(o,id-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)(Gu,{text:n})}var od=(0,m.memo)(function({text:e}){let{frozen:t,active:n,inFence:r}=(0,m.useMemo)(()=>nd(e),[e]);return(0,X.jsxs)(`div`,{className:`md`,children:[t.map((e,t)=>(0,X.jsx)(rd,{text:e},t)),n.length>0&&(0,X.jsx)(ad,{text:n,inFence:r},t.length)]})});function sd({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)(rt,{}):(0,X.jsx)(tt,{})}):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 cd(e,t){return t?e.trimEnd().slice(-80):e.split(`
|
|
334
|
+
`)[0].slice(0,80)}function ld({thinking:e,streaming:t,wrap:n=!0,forceOpen:r=!1}){let i=Z(),[a,o]=(0,m.useState)(null),s=a??n,c=s||r,l=cd(e,t),{copied:u,copy:d}=hl({duration:1200}),f=()=>{d(e)};return(0,X.jsxs)(`div`,{className:`thinking ${c?`open`:``} ${t?`live`:``}`,children:[(0,X.jsx)(sd,{open:c,headClassName:`thinking-head`,toggleClassName:`thinking-toggle`,titleText:i(c?`collapseMsg`:`expandMsg`),onToggle:()=>o(!s),icon:(0,X.jsx)(Ue,{}),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)(at,{}):(0,X.jsx)(Ke,{})})}),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 ud=262144,dd=300,fd=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,pd=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,md=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,hd=1e9;function gd(e){if(!e)return{};let t=e.length>ud?e.slice(0,ud):e;return{path:xd(t),timeout:Sd(t),command:Cd(e),agent:_d(t)}}function _d(e){let t=pd.exec(e);if(!t)return;let n=t[1].replace(/[\u0000-\u001f\u007f]/g,``).trim();if(n)return n.length>dd?`${n.slice(0,dd)}…`:n}var vd=[`task`,`expected_outcome`,`required_tools`,`must_do`,`must_not_do`,`context`];function yd(e){if(!e||e.length>ud)return{};try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n=t,r={};for(let e of[...vd,`agent`,`model`])typeof n[e]==`string`&&n[e].trim()&&(r[e]=n[e]);return r}catch{return{}}}function bd(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 xd(e){let t=fd.exec(e);if(!t)return;let n=wd(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>dd?`${n.slice(0,299)}…`:n}function Sd(e){let t=md.exec(e);if(!t)return;let n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>hd)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 Cd(e){if(!(e.length>ud))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 wd(e){try{let t=JSON.parse(`"${e}"`);return typeof t==`string`?t:e}catch{return e}}var Td=new Set([`image`,`video`,`audio`,`markdown`,`html`,`pdf`,`text`,`binary`,`dir`,`missing`]);function Ed(e){let t=String(e??``).trim().replace(/\\/g,`/`);return t.length>1?t.replace(/\/+$/,``):t}function Dd(e){let t=Ed(e).split(`/`);return(t[t.length-1]??``)||String(e??``)}function Od(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function kd(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Ad(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Od(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=Od(e),n=t?kd(t.path):void 0;if(!n)continue;let r={path:n},a=kd(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=kd(n.title);o&&(a.title=o);let s=kd(n.note);return s&&(a.note=s),a}function jd(e,t){let n=Od(t),r=Array.isArray(n?.items)?n.items.map(Od):[],i=new Map;for(let e of r){if(!e)continue;let t=Ed(String(e.path??e.abs??``));t&&!i.has(t)&&i.set(t,e)}return e.items.map((e,t)=>{let n=i.get(Ed(e.path))??r[t]??null,a=kd(n?.kind),o={path:e.path,target:kd(n?.abs)??e.path,name:Dd(kd(n?.name)??e.path),kind:a&&Td.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=kd(n?.excerpt);return s&&(o.excerpt=s),n?.excerptTruncated===!0&&(o.excerptTruncated=!0),o})}function Md(e,t){return kd(Od(t)?.title)??e.title}function Nd(e,t){return kd(Od(t)?.note)??e.note}function Pd(e){return e===`image`||e===`video`||e===`audio`?e:null}function Fd(e){return e!==`dir`&&e!==`missing`}function Id(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 Ld(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 Rd(e){return e.find(e=>e.focus&&Fd(e.kind))}function zd(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 Bd=`pi-web-ui:present-auto-open`,Vd=3e4,Hd=`pi-web-ui:present-auto-opened`;function Ud(){try{return localStorage.getItem(Bd)===`1`}catch{return!1}}function Wd(e){try{localStorage.setItem(Bd,e?`1`:`0`)}catch{}Jd=e,Kd()}var Gd=new Set;function Kd(){for(let e of Gd)e()}function qd(e){return Gd.add(e),()=>{Gd.delete(e)}}var Jd=null;function Yd(){return Jd===null&&(Jd=Ud()),Jd}function Xd(){return(0,m.useSyncExternalStore)(qd,Yd)}function Zd(){try{let e=sessionStorage.getItem(Hd);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Qd(e){if(!e)return!1;let t=Zd();if(t.includes(e))return!1;let n=[...t,e].slice(-200);try{sessionStorage.setItem(Hd,JSON.stringify(n))}catch{}return!0}function $d(e,t,n=Date.now()){return zd({enabled:Ud(),seen:!1,timestamp:t,now:n,maxAgeMs:Vd})?Qd(e):!1}var ef=(0,m.memo)(function({args:e,details:t,toolCallId:n,resultTimestamp:r}){let i=Z(),a=Xd(),o=(0,m.useMemo)(()=>jd(e,t),[e,t]),s=Md(e,t),c=Nd(e,t),l=(0,m.useMemo)(()=>Rd(o),[o]);return(0,m.useEffect)(()=>{a&&l&&n&&(zu()||$d(n,r)&&Bu({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)(Ku,{text:c,rawHtml:!0})}),(0,X.jsx)(`div`,{className:`present-items`,children:o.map(e=>(0,X.jsx)(nf,{item:e},`${e.target}\u0000${e.path}`))})]})});function tf(e){return typeof e.mtime==`number`?`${e.path}\n${new Date(e.mtime).toLocaleString()}`:e.path}function nf({item:e}){let t=Z(),{copied:n,copy:r}=hl({duration:1200}),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),c=i?null:Pd(e.kind),l=Ld(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:Id(e.kind)}),(0,X.jsx)(`span`,{className:`present-item-name`,title:tf(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:[Fd(e.kind)&&(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`previewFile`),"aria-label":t(`previewFile`),onClick:()=>Bu(d),children:(0,X.jsx)(Fe,{})}),(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)(Ie,{}),(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)(Me,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`downloadFile`),"aria-label":t(`downloadFile`),onClick:()=>{s(``),Gc(e.target,e.name).then(e=>{e.ok||e.cancelled||s(e.error===`FILE_NOT_FOUND`?t(`fileNotFoundShort`):e.error)})},children:(0,X.jsx)(ze,{})}),(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)(Ke,{})})]})]}),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:()=>Bu(d),children:(0,X.jsx)(`img`,{src:Wc(e.target,!1),alt:e.name,loading:`lazy`,onError:()=>a(!0)})}),c===`video`&&(0,X.jsx)(`video`,{className:`present-media-video`,src:Wc(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),c===`audio`&&(0,X.jsx)(`audio`,{className:`present-media-audio`,src:Wc(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),e.excerpt&&(0,X.jsxs)(`pre`,{className:`present-excerpt`,children:[e.excerpt,e.excerptTruncated?`…`:``]})]})}var rf={bash:`$`,delegate_task:`◈`,read:`📄`,write:`✍️`,edit:`✏️`,edit_soft:`✏️`,grep:`🔍`,find:`🧭`,ls:`📂`,[hr]:`🖼`};function af(e){return rf[e]??`🛠`}var of=(0,m.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,m.useState)(null),d=e.name===hr,f=l??(d?!0:r),p=f||a,{copied:h,copy:g}=hl({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,m.useMemo)(()=>i?(t.result?.content??[]).filter(e=>e.type===`image`&&typeof e.dataUrl==`string`&&e.dataUrl.startsWith(`data:`)):[],[i,t.result]),[T,E]=(0,m.useState)(null);(0,m.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?yd(e.argumentsText):{},A=(0,m.useMemo)(()=>d?Ad(e.argumentsText):null,[d,e.argumentsText]),j=D&&t.result&&typeof t.result.details==`object`&&t.result.details!==null?t.result.details.convId:void 0,ee=typeof j==`string`&&j?j:/sa-[0-9a-f]{8}/.exec(S)?.[0],M=(0,m.useRef)(void 0),P=t.status?.durationMs,F=t.result?.durationMs;(0,m.useEffect)(()=>{P!==void 0&&(M.current=P),typeof F==`number`&&(M.current=F)},[P,F]);let I=typeof F==`number`?F:P??M.current,L=x?`err`:y?`ok`:_||b?`run`:`idle`,te=c(x?`error`:y?`done`:_?`running`:b?`toolDoneWaitingModel`:`toolQueued`),R=(b||y)&&I!==void 0?uf(I):``;(b||y)&&R&&(te=`${te} · ${R}`);let z=b&&t.status?.exitCode!==void 0?`exit ${t.status.exitCode}`:``,ne=gd(e.argumentsText),re=e.name===`bash`?ne.command:void 0,B=!p&&re?lf(re):void 0,V=()=>{e.argumentsText&&g(e.argumentsText)},H=(o??[]).some(e=>e&&e.hidden!==!0&&e.kind!==`divider`);return(0,X.jsxs)(`div`,{className:`toolcall ${L}`,children:[(0,X.jsx)(sd,{open:p,headClassName:`toolcall-head`,toggleClassName:`toolcall-toggle`,titleText:c(p?`collapseMsg`:`expandMsg`),onToggle:()=>u(!f),onHeadContextMenu:t=>{if(!H)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(),Wi({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`){to(e.name);return}s?.(t)}}))},icon:af(e.name),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`toolcall-status`,title:z?`${te} · ${z}`:te,"aria-label":z?`${te} · ${z}`:te,children:x?(0,X.jsx)(N,{}):y?(0,X.jsx)(it,{}):_?(0,X.jsx)(xe,{}):b?(0,X.jsx)(Ye,{}):(0,X.jsx)(me,{})}),R&&(0,X.jsx)(`span`,{className:`toolcall-duration toolcall-timeout`,style:{marginLeft:-2,fontFamily:`var(--mono)`},title:z?`${te} · ${z}`:te,children:R}),B&&(0,X.jsxs)(`span`,{className:`toolcall-cmd`,title:re,children:[`$ `,B]}),ne.path&&(0,X.jsx)(`span`,{className:`toolcall-path`,title:ne.path,children:bd(ne.path)}),ne.timeout&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,children:[`⏱ `,ne.timeout]}),D&&ne.agent&&(0,X.jsxs)(`span`,{className:`toolcall-agent`,title:ne.agent,children:[`◈ `,ne.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)(ie,{}),(0,X.jsx)(`span`,{children:c(`stopBash`)})]}),D&&y&&ee&&(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:ee}))},children:[(0,X.jsx)(ft,{}),(0,X.jsx)(`span`,{children:c(`delegateOpenSubagent`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy${h?` copied`:``}`,title:c(`copyArgs`),"aria-label":c(`copyArgs`),onClick:e=>{e.stopPropagation(),V()},children:h?(0,X.jsx)(at,{}):(0,X.jsx)(Ke,{})})]}),children:e.name}),w.length>0&&(0,X.jsx)(`div`,{className:`toolcall-images`,children:w.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`toolcall-image`,title:c(`toolImageZoom`),"aria-label":c(`toolImageZoom`),onClick:t=>{t.stopPropagation(),E(e.dataUrl)},children:(0,X.jsx)(`img`,{src:e.dataUrl,alt:`tool result image ${t+1}`})},t))}),T&&(0,k.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)(N,{})}),(0,X.jsx)(`img`,{src:T,alt:`tool result preview`})]}),document.body),p&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[d&&A?(0,X.jsx)(ef,{args:A,details:t.result?.details,toolCallId:t.result?.toolCallId??e.id,resultTimestamp:t.result?.timestamp}):D?(0,X.jsx)(cf,{args:O}):e.argumentsText&&(0,X.jsx)(`div`,{className:`toolcall-args`,children:re?(0,X.jsx)(sf,{command:re}):(0,X.jsx)(`pre`,{children:e.argumentsText})}),C.length>0&&(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 sf({command:e}){return(0,X.jsxs)(`div`,{className:`termline`,children:[(0,X.jsx)(ne,{className:`termline-icon`}),(0,X.jsx)(`code`,{children:e})]})}function cf({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 lf(e){let t=e.split(`
|
|
335
|
+
`),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 uf(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 df=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function ff(e){let t=e.match(df);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}var pf=1568,mf=2097152;function hf(e){return e.startsWith(`image/`)&&e!==`image/svg+xml`&&e!==`image/svg`}async function gf(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,pf/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<=mf)return o}return o}finally{t.close()}}function _f(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 vf(e){return _f(e).join(`
|
|
336
336
|
|
|
337
|
-
`)}function
|
|
337
|
+
`)}function yf(e){return bf(vf(e))}function bf(e){let t=e.split(`
|
|
338
338
|
`),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(`
|
|
339
339
|
`).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(`
|
|
340
340
|
`).map(e=>e.replace(/[ \t]+/g,` `).replace(/^\s+|\s+$/g,``)).join(`
|
|
341
341
|
`).replace(/\n{3,}/g,`
|
|
342
342
|
|
|
343
|
-
`).trim()}function
|
|
344
|
-
`),V=e.role===`user`?
|
|
345
|
-
`).join(` `).trim(),
|
|
346
|
-
`)).trim(),n=!!(u&&u.length>0);(t||n)&&o?.(e.id,t,n?u:void 0)},
|
|
347
|
-
`)),j(u??[]),D(!0)},ue=()=>{let t=O.trim();(t||A.some(e=>e.mode===`quote`&&kl(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,m.useRef)(null),[pe,me]=(0,m.useState)(null),he=Mf(),ge=(0,m.useRef)(0),_e=_f(e.content),ve=(e.role===`assistant`||e.role===`user`)&&_e.length>0&&!i,K=async t=>{try{let n=!1;if(t===`host:msg-copy-text`)n=await ml(vf(e.content));else if(t===`host:msg-copy-markdown`)n=await ml(_e);else{Pf(e.id);return}window.clearTimeout(ge.current),me({id:t,ok:n}),ge.current=window.setTimeout(()=>me(null),1600)}catch{window.clearTimeout(ge.current),me({id:t,ok:!1}),ge.current=window.setTimeout(()=>me(null),1600)}},ye=ep(vf(e.content),40)||cp(e.role,T),[be,xe]=(0,m.useState)(qt());(0,m.useEffect)(()=>Yt(xe),[]);let Se=e.role===`assistant`&&vf(e.content).trim().length>0&&!i&&Rt(),Ce=Se&&Jt()===e.id,we=()=>{if(Ce){Zt();return}Xt(Bt(vf(e.content)),{...It(),enabled:!0},e.id)},[Te,Ee]=(0,m.useState)(!1),q=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!Te)return;let e=e=>{q.current&&!q.current.contains(e.target)&&Ee(!1)},t=e=>{e.key===`Escape`&&Ee(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[Te]);let De=e=>Se?(0,X.jsxs)(`button`,{type:`button`,className:`msg-action${Ce?` msg-action-speaking`:``}`,title:T(Ce?`stopSpeakingMsg`:`speakMsg`),"aria-label":T(Ce?`stopSpeakingMsg`:`speakMsg`),onClick:we,children:[Ce?(0,X.jsx)(ie,{}):(0,X.jsx)(P,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(Ce?`stopSpeakingMsg`:`speakMsg`)})]},e):null,Oe=()=>li.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:[]})),ke=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:Oe()).map(e=>{if(e.source!==`host`)return e;switch(e.id){case`host:msg-ctx-copy-markdown`:case`host:msg-ctx-copy-text`:return ve?e:{...e,hidden:!0};case`host:msg-ctx-copy-image`:return ve&&!w?e:{...e,hidden:!0};case`host:msg-ctx-reask`:case`host:msg-ctx-edit-reask`:return U?e:{...e,hidden:!0};case`host:msg-ctx-fork`:case`host:msg-ctx-rollback`:return!w&&!i&&!E?e:{...e,hidden:!0};case`host:msg-ctx-speak`:return Se?Ce?{...e,label:T(`stopSpeakingMsg`),icon:`square`}:e:{...e,hidden:!0};default:return e}});ta(a).length!==0&&(t.preventDefault(),Wi({x:t.clientX,y:t.clientY,slot:`contextmenu.message`,target:{id:e.id,kind:`message`,label:ye},entries:a,onHostAction:t=>{switch(t.id){case`host:msg-ctx-copy-markdown`:K(`host:msg-copy-markdown`);return;case`host:msg-ctx-copy-text`:K(`host:msg-copy-text`);return;case`host:msg-ctx-copy-image`:K(`host:msg-copy-image`);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`:Bf({messageId:e.id});return;case`host:msg-ctx-speak`:we();return;default:C?.(t);return}}}))},Ae=(e,t)=>{if(!ve)return null;let n=[{id:`host:msg-copy-markdown`,label:T(`copyMarkdown`),icon:(0,X.jsx)(Je,{})},{id:`host:msg-copy-text`,label:T(`copyText`),icon:(0,X.jsx)(Pe,{})},{id:`host:msg-copy-image`,label:T(`copyImage`),icon:(0,X.jsx)(J,{})}].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:q,className:`msg-copy-group${Te?` 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 K(`host:msg-copy-markdown`),children:[i?(0,X.jsx)(at,{}):(0,X.jsx)(Ke,{}),(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${Te?` active`:``}`,title:T(`copyMessage`),"aria-label":T(`copyMessage`),"aria-expanded":Te,onClick:e=>{e.stopPropagation(),Ee(e=>!e)},children:(0,X.jsx)(rt,{className:`msg-copy-caret-icon${Te?` open`:``}`})}),Te&&(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:()=>{Ee(!1),K(e.id)},children:[e.icon,(0,X.jsx)(`span`,{children:e.label})]},e.id))})]},e)},je=()=>{if(!b){let e=Ae(`fb-copy`),t=De(`fb-speak`);if(!U&&!e&&!t)return null;let n=[];return U&&n.push((0,X.jsxs)(m.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`reaskDirectlyTip`),"aria-label":T(`reaskDirectly`),onClick:ce,children:[(0,X.jsx)(G,{}),` `,(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)(Le,{}),` `,(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=Ae(`copy-dropdown`,b);e&&t.push(e)}return}if(r.id===`host:msg-speak`){let e=De(o);e&&t.push(e);return}if(r.id===`host:msg-reask`){if(!U)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`reaskDirectlyTip`),"aria-label":s,onClick:ce,children:[$f(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-edit-reask`){if(!U)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`editReaskTip`),onClick:le,children:[$f(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:[$f(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:()=>{Bf({messageId:e.id})},children:[$f(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:[$f(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},Me=()=>{let e=je();return e?(0,X.jsx)(`div`,{className:`msg-actions${Te?` has-open-dropdown`:``}`,children:e}):null},Ne=e.role===`custom`&&(e.customType===`goal-review`||e.customType===`goal-wizard`),Y=e.role===`custom`&&e.customType===`goal-wizard`,Fe=e.role===`custom`&&!!e.customType&&e.customType!==`file`&&!Ne&&Cu(e.customType),Ie=Fe?JSON.stringify({customType:e.customType,details:e.details??{}}):``,Re=he.open&&he.selectedIds.includes(e.id),ze=he.open&&ve,Be=Re&&he.includeThinking,Ve=Re&&he.includeTools,He=!E&&(e.role===`user`||ve),Ue=(0,m.useMemo)(()=>{if(e.role!==`assistant`)return-1;for(let t=e.content.length-1;t>=0;t--)if(Gf(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`:``}${Re?` msg-export-selected`:``}${w?` msg-readonly`:``}`,"data-role":e.role,"data-msg-id":e.id,onContextMenu:ke,children:[ze&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:Re,title:T(`copyImage`),"aria-label":T(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>If(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)(et,{}),` `,T(`collapseMsg`)]}),(0,X.jsx)(`span`,{className:`msg-role`,children:e.role===`custom`?Y?T(`goalWizardCard`):Ne?T(`goalBarTitle`):e.customType===`file`?T(`attachment`):`${T(`plugin`)} · ${e.customType??T(`unknown`)}`:cp(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:lp(e.timestamp)}),d!==void 0&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`qn-tag ${f?`active`:``}`,title:`${d+1}. ${ae}`,"aria-label":`${d+1}. ${ae}`,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),se(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)(Ml,{quote:e.quote,onRemove:()=>j(e=>e.filter((e,n)=>n!==t))},`quote-${t}`);let n=Xf(e);return(0,X.jsxs)(`span`,{className:`msg-editor-img ${n===`image`?``:`file-chip`}`,title:Zf(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)(N,{})})]},`${e.name??e.path??`att`}-${t}`)})}),F&&(0,X.jsx)(`div`,{className:`msg-editor-notice`,children:F}),(0,X.jsx)(`textarea`,{className:`msg-editor-input`,value:O,autoFocus:!0,placeholder:T(`editPlaceholder`),rows:Math.max(2,Math.min(10,O.split(`
|
|
348
|
-
`).length+1)),onChange:e=>k(e.target.value),onPaste:e=>{let t=[];for(let n of e.clipboardData?.items??[])if(n.kind===`file`&&
|
|
343
|
+
`).trim()}function xf(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 Sf(e){return e==null||!Number.isFinite(e)?``:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var Cf={open:!1,triggerId:``,selectedIds:[],includeTools:!1,includeThinking:!1},wf=Cf,Tf=[],Ef=new Set;function Df(){for(let e of Ef)e()}function Of(e){return(e.role===`user`||e.role===`assistant`)&&vf(e.content).length>0}function kf(e,t=Tf){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 Af(e){if(Tf=e,wf.open){let e=kf(wf.selectedIds,Tf);e.join(`\0`)!==wf.selectedIds.join(`\0`)&&(wf={...wf,selectedIds:e},Df())}}function jf(){return wf}function Mf(e){return Ef.add(e),()=>{Ef.delete(e)}}function Nf(){return(0,m.useSyncExternalStore)(Mf,jf,jf)}function Pf(){wf.open&&(wf=Cf,Df())}function Ff(e){let t=Tf.find(t=>t.id===e);if(t&&Of(t)){if(wf.open){wf={...wf,selectedIds:kf([...wf.selectedIds,e])},Df();return}wf={open:!0,triggerId:e,selectedIds:[e],includeTools:!1,includeThinking:!1},Df()}}function If(e){wf.open&&(wf={...wf,includeTools:e.includeTools??wf.includeTools,includeThinking:e.includeThinking??wf.includeThinking},Df())}function Lf(e){if(!wf.open||!Tf.filter(Of).map(e=>e.id).includes(e))return;let t=wf.selectedIds.includes(e)?wf.selectedIds.filter(t=>t!==e):kf([...wf.selectedIds,e]);wf={...wf,selectedIds:t},Df()}var Rf=null,zf=new Set;function Bf(){for(let e of zf)e()}function Vf(e){Rf=e,Bf()}function Hf(){Rf=null,Bf()}function Uf(e){Rf&&($({type:`rollback_session`,messageId:Rf.messageId,conversationId:Rf.conversationId,restoreWorkspace:e}),Rf=null,Bf())}function Wf(){return(0,m.useSyncExternalStore)(e=>(zf.add(e),()=>zf.delete(e)),()=>Rf)}var Gf=20971520;function Kf(e){return e.type===`text`&&typeof e.text==`string`?e:null}function qf(e){return e.type===`thinking`&&typeof e.thinking==`string`?e:null}function Jf(e){return e.type===`toolCall`&&typeof e.id==`string`&&typeof e.name==`string`?e:null}function Yf(e){return e.type===`image`&&typeof e.dataUrl==`string`?e:null}function Xf(e){return e.type===`bash`&&typeof e.command==`string`?e:null}function Zf(e){return e.imageData?`image`:e.uploadPath?`upload`:e.fileData?`file`:`path`}function Qf(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 $f={edit:(0,X.jsx)(Le,{}),copy:(0,X.jsx)(Ke,{}),branch:(0,X.jsx)(je,{}),text:(0,X.jsx)(Pe,{}),markdown:(0,X.jsx)(Je,{}),image:(0,X.jsx)(Ee,{}),undo:(0,X.jsx)(se,{}),volume:(0,X.jsx)(P,{}),refresh:(0,X.jsx)(K,{}),x:(0,X.jsx)(N,{})};function ep(e){let t=(e??``).trim();return t?$f[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)(M,{})):(0,X.jsx)(M,{})}function tp(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}var np=(0,m.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:h,toolsWrap:g,toolImages:_,searchActive:v,autoExpand:y,uiMessageActions:b,uiContextMessage:x,uiContextToolCall:S,onUiAction:C,readOnly:w=!1}){let T=Z(),[E,D]=(0,m.useState)(!1),[O,k]=(0,m.useState)(``),[A,j]=(0,m.useState)([]),[ee,M]=(0,m.useState)(!1),[F,I]=(0,m.useState)(null),L=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let te=e=>{I(e),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>I(t=>t===e?null:t),4e3)};if(e.role===`toolResult`||e.role===`system`)return null;if(e.role===`compactionSummary`)return(0,X.jsx)(ap,{message:e,forceOpen:v,autoExpand:y});let R=e.role===`custom`&&e.customType===`file`,z=R&&e.details?.mode===`quote`?kl(e.details.quote):null,ne=e.details?.quotes,re=e.role===`user`&&Array.isArray(ne)?ne.map(kl).filter(e=>e!==null):[],B=e.content.map(e=>Kf(e)?.text??``).filter(Boolean).join(`
|
|
344
|
+
`),V=e.role===`user`?ff(B):null,H=V?V.userMessage??`skill:${V.name}`:B.split(`
|
|
345
|
+
`).join(` `).trim(),U=i&&a&&e.content.length===0,W=!w&&e.role===`user`&&!i&&!U&&!!o,G=async e=>{let t=[];for(let n of e){if(!hf(n.type))continue;let e=await gf(n);e&&t.push({path:``,imageData:e.data,mimeType:e.mimeType,name:e.name})}t.length>0&&j(e=>[...e,...t])},ae=async e=>{if(e.size>Gf){te(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{te(T(`fileLoadFailed`,{name:e.name}));return}j(n=>[...n,{path:``,fileData:t,name:e.name,size:e.size,mimeType:e.type||void 0}])},oe=async e=>{let t=[];for(let n of e)hf(n.type)?t.push(n):ae(n);t.length>0&&await G(t)},se=()=>{let t=(V?`/skill:`+V.name+(V.userMessage?` `+V.userMessage:``):e.content.map(e=>Kf(e)?.text??``).filter(Boolean).join(`
|
|
346
|
+
`)).trim(),n=!!(u&&u.length>0);(t||n)&&o?.(e.id,t,n?u:void 0)},ce=()=>{k(V?`/skill:${V.name}${V.userMessage?` ${V.userMessage}`:``}`:e.content.map(e=>Kf(e)?.text??``).filter(Boolean).join(`
|
|
347
|
+
`)),j(u??[]),D(!0)},le=()=>{let t=O.trim();(t||A.some(e=>e.mode===`quote`&&kl(e.quote)))&&(o?.(e.id,t,A.length>0?A:void 0),D(!1))},ue=!b||b.some(e=>e?.id===`host:msg-copy`&&e.hidden!==!0),de=(0,m.useRef)(null),[fe,pe]=(0,m.useState)(null),me=Nf(),he=(0,m.useRef)(0),ge=vf(e.content),_e=(e.role===`assistant`||e.role===`user`)&&ge.length>0&&!i,q=async t=>{try{let n=!1;if(t===`host:msg-copy-text`)n=await ml(yf(e.content));else if(t===`host:msg-copy-markdown`)n=await ml(ge);else{Ff(e.id);return}window.clearTimeout(he.current),pe({id:t,ok:n}),he.current=window.setTimeout(()=>pe(null),1600)}catch{window.clearTimeout(he.current),pe({id:t,ok:!1}),he.current=window.setTimeout(()=>pe(null),1600)}},ve=tp(yf(e.content),40)||lp(e.role,T),[ye,be]=(0,m.useState)(qt());(0,m.useEffect)(()=>Yt(be),[]);let xe=e.role===`assistant`&&yf(e.content).trim().length>0&&!i&&Rt(),Se=xe&&Jt()===e.id,Ce=()=>{if(Se){Zt();return}Xt(Bt(yf(e.content)),{...It(),enabled:!0},e.id)},[we,Te]=(0,m.useState)(!1),J=(0,m.useRef)(null);(0,m.useEffect)(()=>{if(!we)return;let e=e=>{J.current&&!J.current.contains(e.target)&&Te(!1)},t=e=>{e.key===`Escape`&&Te(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[we]);let De=e=>xe?(0,X.jsxs)(`button`,{type:`button`,className:`msg-action${Se?` msg-action-speaking`:``}`,title:T(Se?`stopSpeakingMsg`:`speakMsg`),"aria-label":T(Se?`stopSpeakingMsg`:`speakMsg`),onClick:Ce,children:[Se?(0,X.jsx)(ie,{}):(0,X.jsx)(P,{}),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:T(Se?`stopSpeakingMsg`:`speakMsg`)})]},e):null,Oe=()=>li.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:[]})),ke=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:Oe()).map(e=>{if(e.source!==`host`)return e;switch(e.id){case`host:msg-ctx-copy-markdown`:case`host:msg-ctx-copy-text`:return _e?e:{...e,hidden:!0};case`host:msg-ctx-copy-image`:return _e&&!w?e:{...e,hidden:!0};case`host:msg-ctx-reask`:case`host:msg-ctx-edit-reask`:return W?e:{...e,hidden:!0};case`host:msg-ctx-fork`:case`host:msg-ctx-rollback`:return!w&&!i&&!E?e:{...e,hidden:!0};case`host:msg-ctx-speak`:return xe?Se?{...e,label:T(`stopSpeakingMsg`),icon:`square`}:e:{...e,hidden:!0};default:return e}});ta(a).length!==0&&(t.preventDefault(),Wi({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`:q(`host:msg-copy-markdown`);return;case`host:msg-ctx-copy-text`:q(`host:msg-copy-text`);return;case`host:msg-ctx-copy-image`:q(`host:msg-copy-image`);return;case`host:msg-ctx-reask`:se();return;case`host:msg-ctx-edit-reask`:ce();return;case`host:msg-ctx-fork`:$({type:`fork_session`,messageId:e.id,position:`before`});return;case`host:msg-ctx-rollback`:Vf({messageId:e.id});return;case`host:msg-ctx-speak`:Ce();return;default:C?.(t);return}}}))},Ae=(e,t)=>{if(!_e)return null;let n=[{id:`host:msg-copy-markdown`,label:T(`copyMarkdown`),icon:(0,X.jsx)(Je,{})},{id:`host:msg-copy-text`,label:T(`copyText`),icon:(0,X.jsx)(Pe,{})},{id:`host:msg-copy-image`,label:T(`copyImage`),icon:(0,X.jsx)(Ee,{})}].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=fe!==null,i=fe?.ok;return(0,X.jsxs)(`div`,{ref:J,className:`msg-copy-group${we?` 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 q(`host:msg-copy-markdown`),children:[i?(0,X.jsx)(at,{}):(0,X.jsx)(Ke,{}),(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${we?` active`:``}`,title:T(`copyMessage`),"aria-label":T(`copyMessage`),"aria-expanded":we,onClick:e=>{e.stopPropagation(),Te(e=>!e)},children:(0,X.jsx)(rt,{className:`msg-copy-caret-icon${we?` open`:``}`})}),we&&(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:()=>{Te(!1),q(e.id)},children:[e.icon,(0,X.jsx)(`span`,{children:e.label})]},e.id))})]},e)},je=()=>{if(!b){let e=Ae(`fb-copy`),t=De(`fb-speak`);if(!W&&!e&&!t)return null;let n=[];return W&&n.push((0,X.jsxs)(m.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`reaskDirectlyTip`),"aria-label":T(`reaskDirectly`),onClick:se,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:ce,children:[(0,X.jsx)(Le,{}),` `,(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=Ae(`copy-dropdown`,b);e&&t.push(e)}return}if(r.id===`host:msg-speak`){let e=De(o);e&&t.push(e);return}if(r.id===`host:msg-reask`){if(!W)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`reaskDirectlyTip`),"aria-label":s,onClick:se,children:[ep(r.icon),` `,(0,X.jsx)(`span`,{className:`msg-action-label`,children:s})]},o));return}if(r.id===`host:msg-edit-reask`){if(!W)return;t.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:T(`editReaskTip`),onClick:ce,children:[ep(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:[ep(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:()=>{Vf({messageId:e.id})},children:[ep(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:[ep(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},Me=()=>{let e=je();return e?(0,X.jsx)(`div`,{className:`msg-actions${we?` has-open-dropdown`:``}`,children:e}):null},Ne=e.role===`custom`&&(e.customType===`goal-review`||e.customType===`goal-wizard`),Y=e.role===`custom`&&e.customType===`goal-wizard`,Fe=e.role===`custom`&&!!e.customType&&e.customType!==`file`&&!Ne&&Cu(e.customType),Ie=Fe?JSON.stringify({customType:e.customType,details:e.details??{}}):``,Re=me.open&&me.selectedIds.includes(e.id),ze=me.open&&_e,Be=Re&&me.includeThinking,Ve=Re&&me.includeTools,He=!E&&(e.role===`user`||_e),Ue=(0,m.useMemo)(()=>{if(e.role!==`assistant`)return-1;for(let t=e.content.length-1;t>=0;t--)if(Kf(e.content[t]))return t;return-1},[e.role,e.content]);return(0,X.jsxs)(`div`,{ref:de,className:`msg msg-${e.role}${Ne?` msg-goal-review`:``}${Re?` msg-export-selected`:``}${w?` msg-readonly`:``}`,"data-role":e.role,"data-msg-id":e.id,onContextMenu:ke,children:[ze&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:Re,title:T(`copyImage`),"aria-label":T(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>Lf(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)(et,{}),` `,T(`collapseMsg`)]}),(0,X.jsx)(`span`,{className:`msg-role`,children:e.role===`custom`?Y?T(`goalWizardCard`):Ne?T(`goalBarTitle`):e.customType===`file`?T(`attachment`):`${T(`plugin`)} · ${e.customType??T(`unknown`)}`:lp(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:up(e.timestamp)}),d!==void 0&&p&&(0,X.jsxs)(`button`,{type:`button`,className:`qn-tag ${f?`active`:``}`,title:`${d+1}. ${H}`,"aria-label":`${d+1}. ${H}`,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),oe(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)(Ml,{quote:e.quote,onRemove:()=>j(e=>e.filter((e,n)=>n!==t))},`quote-${t}`);let n=Zf(e);return(0,X.jsxs)(`span`,{className:`msg-editor-img ${n===`image`?``:`file-chip`}`,title:Qf(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)(N,{})})]},`${e.name??e.path??`att`}-${t}`)})}),F&&(0,X.jsx)(`div`,{className:`msg-editor-notice`,children:F}),(0,X.jsx)(`textarea`,{className:`msg-editor-input`,value:O,autoFocus:!0,placeholder:T(`editPlaceholder`),rows:Math.max(2,Math.min(10,O.split(`
|
|
348
|
+
`).length+1)),onChange:e=>k(e.target.value),onPaste:e=>{let t=[];for(let n of e.clipboardData?.items??[])if(n.kind===`file`&&hf(n.type)){let e=n.getAsFile();e&&t.push(e)}t.length!==0&&(e.preventDefault(),G(t))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),le()):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)(Ee,{}),` `,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`&&kl(e.quote)),title:T(`reaskFromHere`),onClick:le,children:[(0,X.jsx)(Le,{}),` `,T(`reaskFromHere`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[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`)]})]}),re.map((e,t)=>(0,X.jsx)(Ml,{quote:e,forceOpen:v},`quote-${t}`)),z?(0,X.jsx)(Ml,{quote:z,forceOpen:v}):R?(0,X.jsx)(rp,{message:e,forceOpen:v}):V?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(sp,{block:V,forceOpen:v}),V.userMessage&&(0,X.jsx)(`div`,{className:`msg-text`,children:(0,X.jsx)(Ku,{text:V.userMessage,hardBreaks:!0})}),e.content.map((o,c)=>o.type===`text`?null:(0,X.jsx)(cp,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Be,forceTools:Ve,role:e.role,showCopy:ue,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))]}):Fe?(0,X.jsx)(Zu,{type:e.customType??``,code:Ie,children:e.content.map((o,c)=>(0,X.jsx)(cp,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Be,forceTools:Ve,role:e.role,showCopy:ue,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))}):e.content.map((o,c)=>(0,X.jsxs)(m.Fragment,{children:[(0,X.jsx)(cp,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Be,forceTools:Ve,role:e.role,showCopy:ue,uiContextToolCall:S,onUiAction:C}),c===Ue&&He&&Me()]},`${e.id}-${c}`)),U&&(0,X.jsxs)(`div`,{className:`thinking-wait`,children:[T(`thinkingWait`),(0,X.jsx)(`span`,{className:`dot`})]}),i&&a&&!U&&(0,X.jsx)(`span`,{className:`stream-cursor`})]})}),He&&Ue<0&&Me()]})});function rp({message:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,m.useState)(!1),{copied:a,copy:o}=hl({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`,h=c.mode===`conversation`,g=c.path&&/^https?:\/\//i.test(c.path.trim())?c.path.trim():null,_=ip(e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
349
349
|
`)),v=e.content.find(e=>e.type===`image`),y=_.split(`
|
|
350
|
-
`).length,b=!d&&!p&&!h&&_.length>0;return(0,X.jsxs)(`div`,{className:`attachcard ${d?`reference`:``}${p?` page`:``}${h?` conversation`:``}`,children:[(0,X.
|
|
351
|
-
`),_=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:
|
|
352
|
-
`)&&!b.truncated,r=p===`user`?(0,X.jsx)(Ku,{text:b.text,hardBreaks:!0}):e?(0,X.jsx)(od,{text:b.text}):(0,X.jsx)(Ku,{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)(at,{}):(0,X.jsx)(Ke,{})},`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=
|
|
353
|
-
`)}function
|
|
354
|
-
`)}function kp(e,t){let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}function Ap(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=kp(Op(n,r).toLowerCase(),a);e>0&&i.set(n.id,e)}return i}function jp(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 Mp(e,t,n,r,i){let a=Ap(n,r,t,i),o=new Map;for(let n of jp(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 Np(e,t){return e.findIndex(e=>e.msgId===t.msgId&&e.k===t.k)}function Pp(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 Fp(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 Ip(e,t){let n=t.startContainer.parentElement;for(let r of Fp(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 Lp({containerRef:e,messages:t,collapsedIds:n,toolResults:r,onExpand:i,onProgrammaticScroll:a,open:o,onClose:s}){let c=Z(),l=(0,m.useRef)(null),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(0),[,_]=(0,m.useState)(0),v=(0,m.useDeferredValue)(u),y=o?v.trim():``,b=(0,m.useRef)(null);b.current=f;let x=(0,m.useRef)([]),S=(0,m.useRef)({key:null}),C=(0,m.useRef)(``);(0,m.useEffect)(()=>{o&&(p(null),requestAnimationFrame(()=>l.current?.select()))},[o]),(0,m.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,m.useEffect)(()=>(o||(Pp(`msg-search`,[]),Pp(`msg-search-active`,[])),()=>{Pp(`msg-search`,[]),Pp(`msg-search-active`,[])}),[o]),(0,m.useLayoutEffect)(()=>{let s=()=>{g(0),p(null),_(0),x.current=[],Pp(`msg-search`,[]),Pp(`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=Mp(c,y,t,n,r);x.current=e;let o=e.length;if(g(o),o===0){p(null),_(0),Pp(`msg-search`,[]),Pp(`msg-search-active`,[]),S.current={key:null},C.current=y;return}let s=b.current,u;if(s){if(u=Np(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,Pp(`msg-search`,e.filter(e=>e.kind===`dom`).map(e=>e.range)),d.kind===`folded`){Pp(`msg-search-active`,[]),m&&i(d.msgId);return}Pp(`msg-search-active`,[d.range]),m&&(a?.(),Ip(c,d.range))}),()=>{l=!0,cancelAnimationFrame(u)}},[o,y,t,e,f,n,r,i,a]);let w=(0,m.useCallback)(e=>{let t=x.current,n=t.length;if(n===0)return;let r=b.current,i=t[((r?Np(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=Np(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 ${h===0?`empty`:``}`,children:h===0?c(`searchNoResults`):`${Math.min(T+1,h)}/${h}`}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchPrev`),disabled:h===0,onClick:()=>w(-1),children:(0,X.jsx)(et,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchNext`),disabled:h===0,onClick:()=>w(1),children:(0,X.jsx)(rt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchClose`),onClick:s,children:(0,X.jsx)(N,{})})]})}function Rp(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 zp=`pi-web-model-usage`;function Bp(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 Vp(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Hp(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 Up(){try{let e=localStorage.getItem(zp);return e?Bp(JSON.parse(e)):{}}catch{return{}}}function Wp(e){try{localStorage.setItem(zp,JSON.stringify(e))}catch{}}function Gp(e){let t=Vp(Up(),e);return Wp(t),t}var Kp=[{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`}],qp=`pi-web-ui:prompt-templates`;function Jp(){try{let e=localStorage.getItem(qp);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 Yp(e){return Kp.some(t=>t.id===e)}function Xp(e){return typeof e.title==`string`}var Zp=(0,m.createContext)(null);function Qp(){let e=(0,m.useContext)(Zp);if(!e)throw Error(`useTemplates must be used within TemplateProvider`);return e}function $p({children:e,currentModelId:t}){let n=Z(),[r,i]=(0,m.useState)(Jp),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1);(0,m.useEffect)(()=>{try{localStorage.setItem(qp,JSON.stringify(r))}catch{}},[r]);let g=(0,m.useMemo)(()=>{let e=new Map,t=new Set;for(let n of r)n.hidden?t.add(n.id):(Xp(n)&&!Yp(n.id)||Xp(n))&&e.set(n.id,n);let i=Kp.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=>Xp(e)&&!Yp(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,m.useCallback)(()=>o(!0),[]),v=(0,m.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:e}))},[]),y=(0,m.useCallback)((e,t=!1)=>{h(t),e?(u(!1),c({...e})):(u(!0),c({id:St(),icon:`📌`,title:``,desc:``,prompt:``}))},[]),b=(0,m.useCallback)(()=>{o(!1),c(null),h(!1)},[]),x=(0,m.useCallback)(()=>{d?(i([]),f(!1)):f(!0)},[d]);(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),5e3);return()=>clearTimeout(e)},[d]);let S=(0,m.useCallback)(e=>{o(!1),v(e.prompt)},[v]),C=(0,m.useCallback)(e=>{o(!1),y(e,!0)},[y]),w=(0,m.useCallback)(()=>{o(!1),y(void 0,!0)},[y]),T=(0,m.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),h(!1))},[p]),E=(0,m.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),h(!1))},[p]),D=(0,m.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e.id||t.hidden)),c(null),p&&(o(!0),h(!1))},[p]),O=(0,m.useMemo)(()=>({templates:g,fill:v,openPicker:_,openEdit:y,resetConfirm:d,toggleReset:x}),[g,v,_,y,d,x]),k=s?r.some(e=>e.id===s.id&&!e.hidden&&Xp(e)):!1;return(0,X.jsxs)(Zp.Provider,{value:O,children:[e,a&&(0,X.jsx)(nm,{templates:g,resetConfirm:d,onFill:S,onEditTpl:C,onNew:w,onResetToggle:x,onClose:b}),s&&(0,X.jsx)(rm,{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&&Gp(t),b())},onClose:b})]})}function em(){let e=Z(),{templates:t,fill:n,openEdit:r,toggleReset:i,resetConfirm:a}=Qp();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)(tm,{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)(le,{})}),(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)(ce,{}),e(a?`tpl.resetConfirm`:`tpl.reset`)]})})]})}function tm({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)(Re,{})})]})}function nm({templates:e,resetConfirm:t,onFill:n,onEditTpl:r,onNew:i,onResetToggle:a,onClose:o}){let s=Z();return(0,m.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)(N,{})})]}),(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)(tm,{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)(le,{})}),(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)(ce,{}),s(t?`tpl.resetConfirm`:`tpl.reset`)]})})]})})}function rm({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,m.useRef)(null);(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,m.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)(N,{})})]}),(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)(U,{}),` `,u(`tpl.sendNow`)]})]})]})]})})}var im=class extends m.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 am(e,t){return!e||e.length===0?null:(0,X.jsx)(`span`,{className:`slot-toolbar`,children:e.map((e,n)=>(0,X.jsx)(im,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:om(e,n,t)},`${e.id}#${n}`))})}function om(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 sm(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)(im,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:om(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)(m.Fragment,{children:i},e.id))}else i.push(e)}),o(`tail`),a?(0,X.jsx)(X.Fragment,{children:r}):null}var cm=`#ffffff`,lm=`#1e1e1e`,um=`.msg-actions, .msg-text-copy, .chead-copy, .stream-cursor, .msg-editor, .msg-collapse-btn, .msg-export-check, .toolcall-kill, .toolcall-open`,dm=16384;function fm(e,t=800,n=2){let r=Math.max(e,t,1);return r*n<=dm?n:+(r<=dm)}function pm(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=hm(t.trim())}else if(r.includes(`,`)){let e=r.split(`,`).map(e=>e.trim());e.length===4&&(a=hm(e.pop())),i=e}else i=r.split(/\s+/).filter(Boolean),i.length===4&&(a=hm(i.pop()));if(i.length!==3)return null;let o=mm(i[0]),s=mm(i[1]),c=mm(i[2]);return[o,s,c,a].some(e=>Number.isNaN(e))?null:{r:o,g:s,b:c,a}}function mm(e){return e.endsWith(`%`)?Math.round(gm(Number.parseFloat(e),0,100)*2.55):Math.round(gm(Number.parseFloat(e),0,255))}function hm(e){return e.endsWith(`%`)?gm(Number.parseFloat(e)/100,0,1):gm(Number.parseFloat(e),0,1)}function gm(e,t,n){return Math.min(n,Math.max(t,e))}function _m(e){let t=gm(Math.round(e.r),0,255),n=gm(Math.round(e.g),0,255),r=gm(Math.round(e.b),0,255);return e.a<.996?`rgba(${t}, ${n}, ${r}, ${Math.round(gm(e.a,0,1)*1e3)/1e3})`:`rgb(${t}, ${n}, ${r})`}function vm(e,t){let n=gm(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 ym(e,t){let n=pm(t)??{r:255,g:255,b:255,a:1},r=pm(e);return!r||r.a<=.004?_m({...n,a:1}):_m(vm(r,{...n,a:1}))}function bm(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 xm(e){return bm(e)>.45}function Sm(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 Cm(){return getComputedStyle(document.documentElement).colorScheme.split(/\s+/).includes(`light`)?cm:lm}function wm(e){let t=Cm(),n=t;try{n=ym(Sm(`var(--bg)`),t)}catch{n=t}try{let e=ym(Sm(`var(--card-bg, var(--msgs-bg, var(--bg)))`),n),t=pm(e);if(t&&bm(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=ym(e,n),r=pm(e);if(r&&r.a>.04)return t}r=r.parentElement}return n}function Tm(e){return e instanceof HTMLElement||e instanceof SVGElement?e.style:null}function Em(e,t){let n=pm(e);return n?n.a<=.004?`transparent`:n.a>=.996?_m({...n,a:1}):_m(vm(n,{...pm(t)??{r:255,g:255,b:255,a:1},a:1})):null}function Dm(e,t,n){let r=getComputedStyle(e),i=Tm(t),a=n;if(i){let e=Em(r.backgroundColor,n);e===`transparent`?i.backgroundColor=`transparent`:e&&(i.backgroundColor=e,a=e);let t=Em(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=Em(r[e],a);t&&t!==`transparent`&&(i[e]=t)}let o=Em(r.fill,a);o&&o!==`transparent`&&r.fill!==`none`&&(i.fill=o);let s=Em(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++)Dm(o[e],s[e],a)}function Om(e){e.querySelectorAll(um).forEach(e=>e.remove())}function km(e,t={}){t.includeThinking||e.querySelectorAll(`.thinking`).forEach(e=>e.remove()),t.includeTools||e.querySelectorAll(`.toolcall`).forEach(e=>e.remove())}function Am(e,t,n={}){let r=e.cloneNode(!0);return Dm(e,r,t),km(r,n),Om(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 jm(e,t={}){let{toBlob:n}=await ps(async()=>{let{toBlob:e}=await import(`./es-DIDZppIF.js`);return{toBlob:e}},[]),r=t.backgroundColor??wm(e),i=pm(r),a=await n(e,{pixelRatio:t.pixelRatio??2,backgroundColor:r,cacheBust:!1,style:{colorScheme:i&&!xm(i)?`dark`:`light`}});if(!a)throw Error(`toBlob returned null`);return a}function Mm(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Nm(e){return document.querySelector(`.msg[data-msg-id="${Mm(e)}"]`)??document.querySelector(`[data-msg-id="${Mm(e)}"]`)}function Pm(){let e=Z(),t=Mf(),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(`pi-web-ui`),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(``),y=(0,m.useRef)(null),b=(0,m.useRef)(null),x=(0,m.useRef)(`#ffffff`);if((0,m.useEffect)(()=>{t.open&&(d(!1),g(!1),v(``))},[t.open]),At(()=>{Nf()},t.open),(0,m.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=Nm(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=wm(s??void 0);x.current=c;let l=document.createDocumentFragment();for(let e of i)l.appendChild(Am(e,c,{includeThinking:t.includeThinking,includeTools:t.includeTools}));b.current.replaceChildren(l);let u=y.current;if(u){u.style.backgroundColor=c;let e=pm(c);if(u.style.colorScheme=e&&!xm(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=fm(n.scrollHeight,n.scrollWidth);if(t===0){v(e(`exportTooLong`));return}let r=await jm(n,{backgroundColor:x.current,pixelRatio:t});await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),g(!0),window.setTimeout(()=>g(!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:()=>Nf(),children:(0,X.jsx)(N,{})})]}),(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=>Ff({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=>Ff({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)(Se,{className:`saveimg-spin`}):h?(0,X.jsx)(at,{}):(0,X.jsx)(Ke,{}),(0,X.jsx)(`span`,{children:e(u||f?`savingImage`:h?`copied`:`copyImageBtn`)})]})]})]}),_?(0,X.jsx)(`div`,{className:`saveimg-error`,children:_}):null]})]})}var Fm=`.msg-text, .attachcard-content, .toolcall-output pre, .bashblock-output, .quote-content`,Im=`button, input, textarea, [contenteditable], .msg-meta, .msg-actions, .chead, .toolcall-output-label`;function Lm(e){return e.nodeType===1?e:e.parentElement}function Rm(e,t,n){if(!t||t.isCollapsed||t.rangeCount!==1)return null;let r=t.getRangeAt(0),i=Lm(r.startContainer),a=Lm(r.endContainer);if(!i||!a||!e.contains(i)||!e.contains(a)||!i.closest(Fm)||!a.closest(Fm)||i.closest(Im)||a.closest(Im))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(Im))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 zm({rootRef:e,sessionId:t,enabled:n=!0,onSelect:r}){let i=Z(),[a,o]=(0,m.useState)(null);return(0,m.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=Rm(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,k.createPortal)((0,X.jsxs)(`button`,{type:`button`,className:`quote-selection-button`,style:{left:a.left,top:a.top},onMouseDown:e=>e.preventDefault(),onClick:()=>{er({attachments:[{path:``,name:i(`quoteText`),mode:`quote`,quote:a.quote,key:St()}]})&&(o(null),window.getSelection()?.removeAllRanges(),Qn())},children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`↪`}),` `,i(`quoteSelection`)]}),document.body)}var Bm=new Map,Vm=15,Hm=30,Um=250,Wm=1200,Gm=1600;function Km({kind:e,text:t,index:n,onRemoveQueued:r,onRecallQueued:i}){let a=Z(),o=jl(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)(Ml,{quote:e},`quote-${t}`)),(0,X.jsx)(Ku,{text:o.text,hardBreaks:!0})]})})]})}function qm({compaction:e}){let t=Z(),[,n]=(0,m.useState)(0);(0,m.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 Jm(e){return e.content.some(e=>e.type===`toolCall`)}function Ym({state:e,liveOutputs:t,toolStatuses:n,onEdit:r,onKillBash:i,onRetry:a,onRemoveQueued:o,onRecallQueued:s,thinkingWrap:c,toolsWrap:l,toolImages:u,jumpTarget:d,onJumpDone:f,uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,uiChatEmpty:_,onUiAction:v}){let y=Z(),b=Mf(),x=(0,m.useRef)(null),[S,C]=(0,m.useState)(!0),w=(0,m.useRef)(!0),T=(0,m.useRef)(0),E=(0,m.useRef)(0),D=(0,m.useRef)(!1),O=(0,m.useCallback)(()=>{D.current=!0,w.current=!1,C(!1)},[]),A=(0,m.useRef)(0),[j,ee]=(0,m.useState)(()=>new Set),[M,N]=(0,m.useState)(!1),P=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,F=(0,m.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,m.useMemo)(()=>fp(e.messages),[e.messages]),L=[...P].reverse().find(e=>e.role!==`system`),te=L?L.id:null,R=e.messages.length>Hm?Math.max(0,e.messages.length-Vm):0,z=(0,m.useMemo)(()=>{let t=new Set;for(let n=0;n<R;n++){let r=e.messages[n];r.role!==`toolResult`&&(j.has(r.id)||t.add(r.id))}return t},[e.messages,R,j]),[ne,re]=(0,m.useState)(()=>new Set),[B,ie]=(0,m.useState)(()=>new Set),V=(0,m.useRef)(new Map),ae=(0,m.useRef)(new Map),H=(0,m.useRef)(new Map),U=(0,m.useRef)(0),W=(0,m.useMemo)(()=>{let t=new Map;for(let n of e.messages)t.set(n.id,Tp(n));return t},[e.messages]),oe=(0,m.useRef)(W);oe.current=W;let se=(0,m.useRef)(ne);se.current=ne;let ce=e.messages.length>Hm&&!M,G=(0,m.useRef)(ce);G.current=ce;let le=Sp(e.messages,V.current,Gm),ue=(0,m.useRef)(le);ue.current=le;let de=(0,m.useCallback)(()=>{let e=x.current;if(!e)return;if(!G.current){re(e=>e.size?new Set:e);return}let t=e.getBoundingClientRect(),n={top:t.top-Wm,bottom:t.bottom+Wm},r=[];for(let[e,t]of H.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),se.current.has(e)||me(e,n.bottom-n.top,oe.current.get(e))}let i=bp(r,n,ue.current,se.current);for(let e of i.hide){let t=H.current.get(e);t&&me(e,t.offsetHeight,oe.current.get(e))}re(e=>xp(e,i))},[]),fe=(0,m.useCallback)(()=>{U.current||=requestAnimationFrame(()=>{U.current=0,de()})},[de]);(0,m.useLayoutEffect)(()=>{de()},[de]);let pe=(0,m.useRef)(M);(0,m.useLayoutEffect)(()=>{pe.current&&!M&&de(),pe.current=M},[M,de]);let me=(0,m.useCallback)((e,t,n)=>{n!==void 0&&(ae.current.set(e,{h:t,len:n}),V.current.set(e,t))},[]),he=(0,m.useCallback)((e,t)=>{me(e,t,oe.current.get(e))},[me]),ge=(0,m.useCallback)(e=>{e&&H.current.set(e.dataset.lazyId??``,e)},[]);(0,m.useEffect)(()=>{let t=new Set(e.messages.map(e=>e.id));for(let e of H.current.keys())t.has(e)||(H.current.delete(e),V.current.delete(e),ae.current.delete(e));re(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,j]),(0,m.useEffect)(()=>()=>cancelAnimationFrame(U.current),[]);let _e=(0,m.useMemo)(()=>{let t=[];for(let n of e.messages){if(n.role!==`user`)continue;let e=n.content.map(e=>Gf(e)?.text??``).filter(Boolean).join(` `),r=df(e),i=r?r.userMessage??`skill:${r.name}`:e.trim();i&&t.push({id:n.id,text:i})}return t},[e.messages]),ve=(0,m.useMemo)(()=>{let e=new Map;return _e.forEach((t,n)=>e.set(t.id,n)),e},[_e]),[K,ye]=(0,m.useState)(-1),be=(0,m.useRef)(-1),xe=(0,m.useRef)(_e);(0,m.useEffect)(()=>{xe.current=_e},[_e]);let Se=(0,m.useCallback)(()=>{let e=x.current,t=xe.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!==be.current&&(be.current=r,ye(r))},[]);(0,m.useEffect)(()=>{Se()},[_e,Se]);let Ce=(0,m.useCallback)(e=>{ee(t=>t.has(e)?t:new Set(t).add(e))},[]);(0,m.useLayoutEffect)(()=>{kf(e.messages.filter(Df).map(e=>({id:e.id,role:e.role,content:e.content})))},[e.messages]),(0,m.useEffect)(()=>{if(b.open){for(let e of b.selectedIds)Ce(e);ie(e=>{let t=!1,n=new Set(e);for(let e of b.selectedIds)n.has(e)||(n.add(e),t=!0);return t?n:e})}},[b.open,b.selectedIds,Ce]),(0,m.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(),N(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let we=(0,m.useCallback)(e=>{ee(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Te=(0,m.useCallback)(t=>{let n=e.messages.findIndex(e=>e.id===t);(0,k.flushSync)(()=>{n>=0&&n<R&&!j.has(t)&&Ce(t),ie(e=>e.has(t)?e:new Set(e).add(t))});let r=xe.current.findIndex(e=>e.id===t);be.current=r,ye(r),requestAnimationFrame(()=>{let e=x.current?.querySelector(`[data-msg-id="${t}"]`);e&&(x.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!==x.current?.lastElementChild&&(D.current=!0))})},[e.messages,R,j,Ce]),[Ee,q]=(0,m.useState)(null),J=(0,m.useRef)(null),De=(0,m.useRef)(null);(0,m.useEffect)(()=>{let t=J.current;if(!t||t.convId!==e.conversationId){J.current={convId:e.conversationId,ids:new Set(e.messages.filter(e=>e.role===`compactionSummary`).map(e=>e.id))},De.current=null,q(null);return}for(let n of e.messages)if(n.role===`compactionSummary`&&!t.ids.has(n.id)){t.ids.add(n.id),q(n.id);break}},[e.messages,e.conversationId]),(0,m.useEffect)(()=>{Ee&&De.current!==Ee&&(De.current=Ee,Te(Ee))},[Ee,Te]);let Oe=(0,m.useMemo)(()=>d?e.messages.find(e=>e.role===d.role&&e.timestamp===d.timestamp)?.id??null:null,[e.messages,d]);(0,m.useEffect)(()=>{if(d){if(Oe){Te(Oe),f?.();return}e.sessionFile===d.path&&e.messages.length>0&&f?.()}},[Oe,Te,f,d,e.sessionFile,e.messages.length]);let ke=(0,m.useCallback)(()=>{let e=x.current;if(!e)return;let t=e.scrollTop-T.current,n=e.scrollHeight-E.current;T.current=e.scrollTop,E.current=e.scrollHeight;let r=e.scrollHeight-e.scrollTop-e.clientHeight<80,i=Date.now()<A.current,a=Rp({dSt:t,dSh:n,escaped:D.current,graceActive:i,stuck:w.current});a.reassert&&(A.current=Date.now()+Um,e.scrollTop=e.scrollHeight),a.flipEscape&&(D.current=!0),r&&t>=0&&(D.current=!1),i||(t<0?w.current=r&&!D.current:r&&(w.current=!0)),C(w.current),Se(),fe()},[Se,fe]),Ae=(0,m.useRef)(!1);(0,m.useEffect)(()=>{let t=Ae.current;if(Ae.current=!!e.isStreaming,t&&!e.isStreaming&&!D.current){let e=()=>{let e=x.current;e&&!D.current&&(e.scrollTop=e.scrollHeight,w.current=!0,C(!0))};requestAnimationFrame(()=>requestAnimationFrame(e));let t=setTimeout(e,180);return()=>clearTimeout(t)}},[e.isStreaming]),(0,m.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[P,e.isStreaming,t]);let je=e.queue.steering.join(`\0`)+``+e.queue.followUp.join(`\0`);(0,m.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[je]),(0,m.useEffect)(()=>{let e=x.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,m.useEffect)(()=>{let e=x.current;if(!e||typeof MutationObserver>`u`)return;let t=!1,n=new MutationObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let e=x.current;e&&w.current&&!D.current&&(e.scrollTop=e.scrollHeight,C(!0))}))});return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[]);let Me=(0,m.useCallback)(()=>{if(!x.current)return;w.current=!0,D.current=!1,C(!0),A.current=Date.now()+Um;let e=()=>{let e=x.current;e&&w.current&&!D.current&&(A.current=Date.now()+Um,e.scrollTop=e.scrollHeight)};e(),requestAnimationFrame(()=>requestAnimationFrame(e)),setTimeout(e,120),setTimeout(e,300),setTimeout(e,600)},[]),Ne=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=Ne.current,t=x.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[Y,Pe]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=()=>{Pe(x.current?.clientHeight??0),fe()};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[fe]);let Fe=_e.length,Ie=(0,m.useMemo)(()=>Fe===0?27:Math.max(4,Math.min(27,Math.floor(((Y||600)-16)/Fe)-3)),[Fe,Y]),Le=Ie<20;return(0,X.jsxs)(`div`,{className:`messages-wrap${b.open?` messages-exporting`:``}`,children:[(0,X.jsx)(zm,{rootRef:x,sessionId:e.sessionId,enabled:!b.open,onSelect:O}),(0,X.jsxs)(`div`,{className:`messages${M||S?``:` anchor-live`}`,ref:x,onScroll:ke,children:[e.messages.length===0&&!e.streamingMessage&&(0,X.jsxs)(`div`,{className:`empty-state`,children:[(0,X.jsx)(em,{}),_&&_.length>0&&(0,X.jsx)(`div`,{className:`chat-empty-slots`,children:am(_,v)})]}),e.messages.map((o,s)=>{if(o.role===`system`)return null;let d=vp(o);if(d&&!j.has(o.id))return(0,X.jsx)(pp,{message:o,onExpand:Ce,summary:d.kind===`prompt`?y(`goalBarReviewing`):d.verdict===`pass`?y(`goalBarPassed`):y(`goalBarFailed`)},o.id);let f=s<R,m=f&&j.has(o.id);if(f&&!m)return o.role===`toolResult`?null:(0,X.jsx)(pp,{message:o,onExpand:Ce},o.id);let _=o.role===`user`?ve.get(o.id):void 0,b=!ce||le.has(o.id)||B.has(o.id)||!ne.has(o.id);return(0,X.jsx)(yp,{id:o.id,show:b,height:Ep(o.id,W.get(o.id)??-1,ae.current,Cp(o.role,o.customType)),containerRef:x,onMeasured:he,lazyRef:ge,children:(0,X.jsx)(tp,{uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:o,qnIndex:_,qnActive:_===void 0?void 0:_===K,onJump:Te,toolResults:F,liveOutputs:Jm(o)?t:Bm,toolStatuses:n,streaming:e.isStreaming,onKillBash:i,onRetry:o.id===te?a:void 0,toolsWrap:l,toolImages:u,thinkingWrap:c,isLast:o.id===te,onEdit:r,questionAttachments:I.get(o.id),onCollapse:m?we:void 0,searchActive:M,autoExpand:o.id===Ee},o.id)},o.id)}),e.streamingMessage&&(0,X.jsx)(tp,{uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:e.streamingMessage,toolResults:F,liveOutputs:Jm(e.streamingMessage)?t:Bm,toolStatuses:n,streaming:!0,isLast:!0,onEdit:r,onKillBash:i,toolsWrap:l,toolImages:u,thinkingWrap:c,searchActive:M},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?y(`retryingApi`,{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):y(`retryingApiSoon`,{error:e.retry.errorMessage})})]}),e.compaction&&(0,X.jsx)(qm,{compaction:e.compaction}),e.isStreaming&&P.length===0&&(0,X.jsx)(`div`,{className:`streaming-wait`,children:y(`waitingResponse`)}),e.queue.steering.map((e,t)=>(0,X.jsx)(Km,{kind:`steer`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-steer-${t}`)),e.queue.followUp.map((e,t)=>(0,X.jsx)(Km,{kind:`followUp`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-fu-${t}`))]}),!S&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,title:y(`backToBottom`),"aria-label":y(`backToBottom`),onClick:Me,children:[(0,X.jsx)(pt,{}),(0,X.jsx)(`span`,{className:`scroll-bottom-label`,children:y(`backToBottom`)})]}),(0,X.jsx)(Lp,{containerRef:x,messages:P,collapsedIds:z,toolResults:F,onExpand:Ce,onProgrammaticScroll:()=>{D.current=!0,w.current=!1,C(!1)},open:M,onClose:()=>N(!1)}),_e.length>0&&(0,X.jsxs)(`div`,{className:`qn-rail ${Le?`many`:``}`,ref:Ne,"aria-label":y(`questionNavTitle`),style:{"--rail-gap":`${Ie}px`},children:[_e.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`qn-bar ${t===K?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Te(e.id),children:(0,X.jsxs)(`span`,{className:`qn-bar-text`,children:[t+1,`. `,e.text]})},e.id)),Le&&(0,X.jsx)(`div`,{className:`qn-list`,children:_e.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`qn-list-item ${t===K?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Te(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)(Pm,{})]})}function Xm(e,t){return t?e.trim()?`${e.replace(/\s+$/,``)}\n${t}`:t:e}function Zm(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 Qm(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 $m(e,t){return t?e?{key:t,clear:e!==t}:{key:t,clear:!1}:{key:e,clear:!1}}function eh(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=new Set(e.map(Qm).filter(e=>e!==null)),r=[...e];for(let e of t){let t=Qm(e);if(t!==null){if(n.has(t))continue;n.add(t)}r.push(e)}return r}function th(e,t,n){return!(!e||!e.trim()||t>0||n)}function nh(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var rh=``;function ih(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function ah(e,t){return{first:!e.slice(0,t).includes(`
|
|
350
|
+
`).length,b=!d&&!p&&!h&&_.length>0;return(0,X.jsxs)(`div`,{className:`attachcard ${d?`reference`:``}${p?` page`:``}${h?` conversation`:``}`,children:[(0,X.jsx)(sd,{open:s,headClassName:`attachcard-head`,titleText:n(s?`collapseMsg`:`expandMsg`),onToggle:()=>i(e=>t?!0:!e),toggle:!d&&!p&&!h?(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(rt,{}):(0,X.jsx)(tt,{})}):null,icon:u?`📁`:p?`🌐`:h?`💬`:`📎`,iconClassName:`attachcard-icon`,titleClassName:`attachcard-name`,after:(0,X.jsxs)(X.Fragment,{children:[c.path&&(p&&g?(0,X.jsx)(`a`,{className:`attachcard-path attachcard-link`,href:g,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`:h?`conversation`:f?`bridged`:`inline`}`,children:p?n(`attachPageShort`):h?n(`attachConversationShort`):d?u?n(`folderRefShort`):`${n(`refOnlyShort`)} · ${Sf(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)(at,{}):(0,X.jsx)(Ke,{})})]}),children:l}),!d&&s&&(f?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`attachcard-bridgenote`,children:n(`bridgedVisionDetail`)}),v?.dataUrl&&(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:v.dataUrl,alt:l})}),_&&(0,X.jsx)(`pre`,{className:`attachcard-content`,children:_})]}):v?.dataUrl?(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:v.dataUrl,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:Sf(c.size)})})]})}function ip(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 ap({message:e,forceOpen:t=!1,autoExpand:n=!1}){let r=Z(),[i,a]=(0,m.useState)(!1),{copied:o,copy:s}=hl({duration:1200}),[c,l]=(0,m.useState)(n);n!==c&&(l(n),n&&a(!0));let u=i||t,d=vo(e.id),[f,p]=(0,m.useState)(!1),h=()=>{f?p(!1):(p(!0),d.status===`idle`&&mo(e.id))},g=e.content.map(e=>Kf(e)?.text??``).filter(Boolean).join(`
|
|
351
|
+
`),_=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:up(e.timestamp)})]}),(0,X.jsxs)(`div`,{className:`compaction-card${i?` expanded`:``}`,children:[(0,X.jsx)(sd,{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)(rt,{}):(0,X.jsx)(tt,{})}),icon:(0,X.jsx)(mt,{}),iconClassName:`compaction-icon`,titleClassName:`compaction-title`,after:g&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:r(o?`copied`:`copyMessage`),"aria-label":r(`copyMessage`),onClick:e=>{e.stopPropagation(),s(g)},children:o?(0,X.jsx)(at,{}):(0,X.jsx)(Ke,{})}),children:_?r(`compactionFrom`,{tokens:_}):r(`role.compaction`)}),u&&(0,X.jsxs)(`div`,{className:`compaction-body`,children:[(0,X.jsx)(Ku,{text:g}),(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:h,"aria-expanded":f,children:[(0,X.jsx)(`span`,{className:`compacted-history-chevron`,children:f?(0,X.jsx)(rt,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(Ye,{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)(op,{messages:d.messages})]})]})]})]})}function op({messages:e}){let t=Z(),n=(0,m.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,m.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)(mt,{}),` `,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)(np,{message:e,toolResults:n,liveOutputs:r,toolStatuses:r,streaming:!1,isLast:!1,readOnly:!0},e.id))})]})}function sp({block:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,m.useState)(!1),{copied:a,copy:o}=hl({duration:1200}),s=r||t;return(0,X.jsxs)(`div`,{className:`skillcard${r?` expanded`:``}`,children:[(0,X.jsx)(sd,{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)(rt,{}):(0,X.jsx)(tt,{})}),icon:(0,X.jsx)(ct,{}),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)(at,{}):(0,X.jsx)(Ke,{})})]}),children:e.name}),s&&(0,X.jsx)(`div`,{className:`skillcard-body`,children:(0,X.jsx)(Ku,{text:e.content})})]})}function cp({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}=hl({duration:1200}),b=Kf(e);if(b){let e=i&&a,t=(p===`assistant`||p===`user`)&&m!==!1,n=t&&!b.text.includes(`
|
|
352
|
+
`)&&!b.truncated,r=p===`user`?(0,X.jsx)(Ku,{text:b.text,hardBreaks:!0}):e?(0,X.jsx)(od,{text:b.text}):(0,X.jsx)(Ku,{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)(at,{}):(0,X.jsx)(Ke,{})},`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=qf(e);if(x)return(0,X.jsx)(ld,{thinking:x.thinking,streaming:i&&a,wrap:s,forceOpen:u||d});let S=Jf(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)(of,{block:S,view:e,onKillBash:o,wrap:c,showImages:l??!0,forceOpen:u||f,uiContextToolCall:h,onUiAction:g})}let C=Yf(e);if(C&&C.dataUrl)return(0,X.jsx)(`div`,{className:`msg-image`,children:(0,X.jsx)(`img`,{src:C.dataUrl,alt:`attachment`})});let w=Xf(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: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 lp(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 up(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function dp(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 fp(e){let t=e.details??{};if(t.mode===`quote`){let e=kl(t.quote);return e?{path:``,mode:`quote`,quote:e}:null}let n=[];if(dp(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 pp(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=[];dp(i,r.content);let a=r.details?.quotes;for(let e of Array.isArray(a)?a:[]){let t=kl(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=fp(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=fp(e[t]);n&&i.push(n)}i.length>0&&t.set(r.id,i)}return t}var mp=(0,m.memo)(function({message:e,onExpand:t,summary:n}){let r=Z(),i=Nf(),a=Of(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=Kf(t);if(e&&e.text.trim()){let t=ff(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)qf(t)?l++:Jf(t)?u++:Xf(t)?d++:Yf(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:()=>Lf(e.id)}),(0,X.jsx)(`span`,{className:`msg-collapsed-role role-${e.role}`,children:e.role===`custom`&&e.customType===`file`?r(`attachment`):lp(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:hp(e.timestamp)}):null,(0,X.jsx)(`span`,{className:`msg-collapsed-action`,children:r(`expandMsg`)})]})});function hp(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}var gp=`[goal-review]`;function _p(e){for(let t of e.content??[]){let e=Kf(t);if(e&&e.text.trim())return e.text}return``}function vp(e){if(e.role!==`assistant`)return;let t=_p(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 yp(e){if(e.role===`user`&&_p(e).includes(gp))return{kind:`prompt`};let t=vp(e);if(t)return{kind:`verdict`,verdict:t}}var bp=(0,m.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,m.useRef)(null),c=(0,m.useRef)(null);return(0,m.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 xp(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 Sp(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 Cp(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)??wp(n.role,n.customType)}return r}function wp(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 Tp=[`text`,`thinking`,`argumentsText`,`output`,`command`];function Ep(e){let t=0;for(let n of e.content){n.type===`image`&&(t+=1);for(let e of Tp){let r=n[e];typeof r==`string`&&(t+=r.length)}}return t}function Dp(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Op(e){let t=[];for(let n of e.content)n.type===`text`&&typeof n.text==`string`&&t.push(n.text);return t.join(`
|
|
353
|
+
`)}function kp(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=Op(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(`
|
|
354
|
+
`)}function Ap(e,t){let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}function jp(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=Ap(kp(n,r).toLowerCase(),a);e>0&&i.set(n.id,e)}return i}function Mp(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 Np(e,t,n,r,i){let a=jp(n,r,t,i),o=new Map;for(let n of Mp(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 Pp(e,t){return e.findIndex(e=>e.msgId===t.msgId&&e.k===t.k)}function Fp(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 Ip(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 Lp(e,t){let n=t.startContainer.parentElement;for(let r of Ip(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 Rp({containerRef:e,messages:t,collapsedIds:n,toolResults:r,onExpand:i,onProgrammaticScroll:a,open:o,onClose:s}){let c=Z(),l=(0,m.useRef)(null),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(0),[,_]=(0,m.useState)(0),v=(0,m.useDeferredValue)(u),y=o?v.trim():``,b=(0,m.useRef)(null);b.current=f;let x=(0,m.useRef)([]),S=(0,m.useRef)({key:null}),C=(0,m.useRef)(``);(0,m.useEffect)(()=>{o&&(p(null),requestAnimationFrame(()=>l.current?.select()))},[o]),(0,m.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,m.useEffect)(()=>(o||(Fp(`msg-search`,[]),Fp(`msg-search-active`,[])),()=>{Fp(`msg-search`,[]),Fp(`msg-search-active`,[])}),[o]),(0,m.useLayoutEffect)(()=>{let s=()=>{g(0),p(null),_(0),x.current=[],Fp(`msg-search`,[]),Fp(`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=Np(c,y,t,n,r);x.current=e;let o=e.length;if(g(o),o===0){p(null),_(0),Fp(`msg-search`,[]),Fp(`msg-search-active`,[]),S.current={key:null},C.current=y;return}let s=b.current,u;if(s){if(u=Pp(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,Fp(`msg-search`,e.filter(e=>e.kind===`dom`).map(e=>e.range)),d.kind===`folded`){Fp(`msg-search-active`,[]),m&&i(d.msgId);return}Fp(`msg-search-active`,[d.range]),m&&(a?.(),Lp(c,d.range))}),()=>{l=!0,cancelAnimationFrame(u)}},[o,y,t,e,f,n,r,i,a]);let w=(0,m.useCallback)(e=>{let t=x.current,n=t.length;if(n===0)return;let r=b.current,i=t[((r?Pp(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=Pp(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 ${h===0?`empty`:``}`,children:h===0?c(`searchNoResults`):`${Math.min(T+1,h)}/${h}`}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchPrev`),disabled:h===0,onClick:()=>w(-1),children:(0,X.jsx)(et,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchNext`),disabled:h===0,onClick:()=>w(1),children:(0,X.jsx)(rt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchClose`),onClick:s,children:(0,X.jsx)(N,{})})]})}function zp(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 Bp=`pi-web-model-usage`;function Vp(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 Hp(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Up(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 Wp(){try{let e=localStorage.getItem(Bp);return e?Vp(JSON.parse(e)):{}}catch{return{}}}function Gp(e){try{localStorage.setItem(Bp,JSON.stringify(e))}catch{}}function Kp(e){let t=Hp(Wp(),e);return Gp(t),t}var qp=[{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`}],Jp=`pi-web-ui:prompt-templates`;function Yp(){try{let e=localStorage.getItem(Jp);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 Xp(e){return qp.some(t=>t.id===e)}function Zp(e){return typeof e.title==`string`}var Qp=(0,m.createContext)(null);function $p(){let e=(0,m.useContext)(Qp);if(!e)throw Error(`useTemplates must be used within TemplateProvider`);return e}function em({children:e,currentModelId:t}){let n=Z(),[r,i]=(0,m.useState)(Yp),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(!1),[p,h]=(0,m.useState)(!1);(0,m.useEffect)(()=>{try{localStorage.setItem(Jp,JSON.stringify(r))}catch{}},[r]);let g=(0,m.useMemo)(()=>{let e=new Map,t=new Set;for(let n of r)n.hidden?t.add(n.id):(Zp(n)&&!Xp(n.id)||Zp(n))&&e.set(n.id,n);let i=qp.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=>Zp(e)&&!Xp(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,m.useCallback)(()=>o(!0),[]),v=(0,m.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:e}))},[]),y=(0,m.useCallback)((e,t=!1)=>{h(t),e?(u(!1),c({...e})):(u(!0),c({id:St(),icon:`📌`,title:``,desc:``,prompt:``}))},[]),b=(0,m.useCallback)(()=>{o(!1),c(null),h(!1)},[]),x=(0,m.useCallback)(()=>{d?(i([]),f(!1)):f(!0)},[d]);(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),5e3);return()=>clearTimeout(e)},[d]);let S=(0,m.useCallback)(e=>{o(!1),v(e.prompt)},[v]),C=(0,m.useCallback)(e=>{o(!1),y(e,!0)},[y]),w=(0,m.useCallback)(()=>{o(!1),y(void 0,!0)},[y]),T=(0,m.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),h(!1))},[p]),E=(0,m.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),h(!1))},[p]),D=(0,m.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e.id||t.hidden)),c(null),p&&(o(!0),h(!1))},[p]),O=(0,m.useMemo)(()=>({templates:g,fill:v,openPicker:_,openEdit:y,resetConfirm:d,toggleReset:x}),[g,v,_,y,d,x]),k=s?r.some(e=>e.id===s.id&&!e.hidden&&Zp(e)):!1;return(0,X.jsxs)(Qp.Provider,{value:O,children:[e,a&&(0,X.jsx)(rm,{templates:g,resetConfirm:d,onFill:S,onEditTpl:C,onNew:w,onResetToggle:x,onClose:b}),s&&(0,X.jsx)(im,{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&&Kp(t),b())},onClose:b})]})}function tm(){let e=Z(),{templates:t,fill:n,openEdit:r,toggleReset:i,resetConfirm:a}=$p();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)(nm,{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)(ce,{})}),(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)(se,{}),e(a?`tpl.resetConfirm`:`tpl.reset`)]})})]})}function nm({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)(Re,{})})]})}function rm({templates:e,resetConfirm:t,onFill:n,onEditTpl:r,onNew:i,onResetToggle:a,onClose:o}){let s=Z();return(0,m.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)(N,{})})]}),(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)(nm,{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)(ce,{})}),(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)(se,{}),s(t?`tpl.resetConfirm`:`tpl.reset`)]})})]})})}function im({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,m.useRef)(null);(0,m.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,m.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)(N,{})})]}),(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)(W,{}),` `,u(`tpl.sendNow`)]})]})]})]})})}var am=class extends m.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 om(e,t){return!e||e.length===0?null:(0,X.jsx)(`span`,{className:`slot-toolbar`,children:e.map((e,n)=>(0,X.jsx)(am,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:sm(e,n,t)},`${e.id}#${n}`))})}function sm(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 cm(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)(am,{label:e.label||e.id,slot:e.slot,entryId:e.id,children:sm(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)(m.Fragment,{children:i},e.id))}else i.push(e)}),o(`tail`),a?(0,X.jsx)(X.Fragment,{children:r}):null}var lm=`#ffffff`,um=`#1e1e1e`,dm=`.msg-actions, .msg-text-copy, .chead-copy, .stream-cursor, .msg-editor, .msg-collapse-btn, .msg-export-check, .toolcall-kill, .toolcall-open`,fm=16384;function pm(e,t=800,n=2){let r=Math.max(e,t,1);return r*n<=fm?n:+(r<=fm)}function mm(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=gm(t.trim())}else if(r.includes(`,`)){let e=r.split(`,`).map(e=>e.trim());e.length===4&&(a=gm(e.pop())),i=e}else i=r.split(/\s+/).filter(Boolean),i.length===4&&(a=gm(i.pop()));if(i.length!==3)return null;let o=hm(i[0]),s=hm(i[1]),c=hm(i[2]);return[o,s,c,a].some(e=>Number.isNaN(e))?null:{r:o,g:s,b:c,a}}function hm(e){return e.endsWith(`%`)?Math.round(_m(Number.parseFloat(e),0,100)*2.55):Math.round(_m(Number.parseFloat(e),0,255))}function gm(e){return e.endsWith(`%`)?_m(Number.parseFloat(e)/100,0,1):_m(Number.parseFloat(e),0,1)}function _m(e,t,n){return Math.min(n,Math.max(t,e))}function vm(e){let t=_m(Math.round(e.r),0,255),n=_m(Math.round(e.g),0,255),r=_m(Math.round(e.b),0,255);return e.a<.996?`rgba(${t}, ${n}, ${r}, ${Math.round(_m(e.a,0,1)*1e3)/1e3})`:`rgb(${t}, ${n}, ${r})`}function ym(e,t){let n=_m(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 bm(e,t){let n=mm(t)??{r:255,g:255,b:255,a:1},r=mm(e);return!r||r.a<=.004?vm({...n,a:1}):vm(ym(r,{...n,a:1}))}function xm(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 Sm(e){return xm(e)>.45}function Cm(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 wm(){return getComputedStyle(document.documentElement).colorScheme.split(/\s+/).includes(`light`)?lm:um}function Tm(e){let t=wm(),n=t;try{n=bm(Cm(`var(--bg)`),t)}catch{n=t}try{let e=bm(Cm(`var(--card-bg, var(--msgs-bg, var(--bg)))`),n),t=mm(e);if(t&&xm(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=bm(e,n),r=mm(e);if(r&&r.a>.04)return t}r=r.parentElement}return n}function Em(e){return e instanceof HTMLElement||e instanceof SVGElement?e.style:null}function Dm(e,t){let n=mm(e);return n?n.a<=.004?`transparent`:n.a>=.996?vm({...n,a:1}):vm(ym(n,{...mm(t)??{r:255,g:255,b:255,a:1},a:1})):null}function Om(e,t,n){let r=getComputedStyle(e),i=Em(t),a=n;if(i){let e=Dm(r.backgroundColor,n);e===`transparent`?i.backgroundColor=`transparent`:e&&(i.backgroundColor=e,a=e);let t=Dm(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=Dm(r[e],a);t&&t!==`transparent`&&(i[e]=t)}let o=Dm(r.fill,a);o&&o!==`transparent`&&r.fill!==`none`&&(i.fill=o);let s=Dm(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++)Om(o[e],s[e],a)}function km(e){e.querySelectorAll(dm).forEach(e=>e.remove())}function Am(e,t={}){t.includeThinking||e.querySelectorAll(`.thinking`).forEach(e=>e.remove()),t.includeTools||e.querySelectorAll(`.toolcall`).forEach(e=>e.remove())}function jm(e,t,n={}){let r=e.cloneNode(!0);return Om(e,r,t),Am(r,n),km(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 Mm(e,t={}){let{toBlob:n}=await ps(async()=>{let{toBlob:e}=await import(`./es-DIDZppIF.js`);return{toBlob:e}},[]),r=t.backgroundColor??Tm(e),i=mm(r),a=await n(e,{pixelRatio:t.pixelRatio??2,backgroundColor:r,cacheBust:!1,style:{colorScheme:i&&!Sm(i)?`dark`:`light`}});if(!a)throw Error(`toBlob returned null`);return a}function Nm(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function Pm(e){return document.querySelector(`.msg[data-msg-id="${Nm(e)}"]`)??document.querySelector(`[data-msg-id="${Nm(e)}"]`)}function Fm(){let e=Z(),t=Nf(),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(`pi-web-ui`),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(``),y=(0,m.useRef)(null),b=(0,m.useRef)(null),x=(0,m.useRef)(`#ffffff`);if((0,m.useEffect)(()=>{t.open&&(d(!1),g(!1),v(``))},[t.open]),At(()=>{Pf()},t.open),(0,m.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=Pm(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=Tm(s??void 0);x.current=c;let l=document.createDocumentFragment();for(let e of i)l.appendChild(jm(e,c,{includeThinking:t.includeThinking,includeTools:t.includeTools}));b.current.replaceChildren(l);let u=y.current;if(u){u.style.backgroundColor=c;let e=mm(c);if(u.style.colorScheme=e&&!Sm(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=pm(n.scrollHeight,n.scrollWidth);if(t===0){v(e(`exportTooLong`));return}let r=await Mm(n,{backgroundColor:x.current,pixelRatio:t});await navigator.clipboard.write([new ClipboardItem({"image/png":r})]),g(!0),window.setTimeout(()=>g(!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:()=>Pf(),children:(0,X.jsx)(N,{})})]}),(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=>If({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=>If({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)(xe,{className:`saveimg-spin`}):h?(0,X.jsx)(at,{}):(0,X.jsx)(Ke,{}),(0,X.jsx)(`span`,{children:e(u||f?`savingImage`:h?`copied`:`copyImageBtn`)})]})]})]}),_?(0,X.jsx)(`div`,{className:`saveimg-error`,children:_}):null]})]})}var Im=`.msg-text, .attachcard-content, .toolcall-output pre, .bashblock-output, .quote-content`,Lm=`button, input, textarea, [contenteditable], .msg-meta, .msg-actions, .chead, .toolcall-output-label`;function Rm(e){return e.nodeType===1?e:e.parentElement}function zm(e,t,n){if(!t||t.isCollapsed||t.rangeCount!==1)return null;let r=t.getRangeAt(0),i=Rm(r.startContainer),a=Rm(r.endContainer);if(!i||!a||!e.contains(i)||!e.contains(a)||!i.closest(Im)||!a.closest(Im)||i.closest(Lm)||a.closest(Lm))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(Lm))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 Bm({rootRef:e,sessionId:t,enabled:n=!0,onSelect:r}){let i=Z(),[a,o]=(0,m.useState)(null);return(0,m.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=zm(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,k.createPortal)((0,X.jsxs)(`button`,{type:`button`,className:`quote-selection-button`,style:{left:a.left,top:a.top},onMouseDown:e=>e.preventDefault(),onClick:()=>{er({attachments:[{path:``,name:i(`quoteText`),mode:`quote`,quote:a.quote,key:St()}]})&&(o(null),window.getSelection()?.removeAllRanges(),Qn())},children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`↪`}),` `,i(`quoteSelection`)]}),document.body)}var Vm=new Map,Hm=15,Um=30,Wm=250,Gm=1200,Km=1600;function qm({kind:e,text:t,index:n,onRemoveQueued:r,onRecallQueued:i}){let a=Z(),o=jl(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)(Ml,{quote:e},`quote-${t}`)),(0,X.jsx)(Ku,{text:o.text,hardBreaks:!0})]})})]})}function Jm({compaction:e}){let t=Z(),[,n]=(0,m.useState)(0);(0,m.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 Ym(e){return e.content.some(e=>e.type===`toolCall`)}function Xm({state:e,liveOutputs:t,toolStatuses:n,onEdit:r,onKillBash:i,onRetry:a,onRemoveQueued:o,onRecallQueued:s,thinkingWrap:c,toolsWrap:l,toolImages:u,jumpTarget:d,onJumpDone:f,uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,uiChatEmpty:_,onUiAction:v}){let y=Z(),b=Nf(),x=(0,m.useRef)(null),[S,C]=(0,m.useState)(!0),w=(0,m.useRef)(!0),T=(0,m.useRef)(0),E=(0,m.useRef)(0),D=(0,m.useRef)(!1),O=(0,m.useCallback)(()=>{D.current=!0,w.current=!1,C(!1)},[]),A=(0,m.useRef)(0),[j,ee]=(0,m.useState)(()=>new Set),[M,N]=(0,m.useState)(!1),P=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,F=(0,m.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,m.useMemo)(()=>pp(e.messages),[e.messages]),L=[...P].reverse().find(e=>e.role!==`system`),te=L?L.id:null,R=e.messages.length>Um?Math.max(0,e.messages.length-Hm):0,z=(0,m.useMemo)(()=>{let t=new Set;for(let n=0;n<R;n++){let r=e.messages[n];r.role!==`toolResult`&&(j.has(r.id)||t.add(r.id))}return t},[e.messages,R,j]),[ne,re]=(0,m.useState)(()=>new Set),[B,ie]=(0,m.useState)(()=>new Set),V=(0,m.useRef)(new Map),H=(0,m.useRef)(new Map),U=(0,m.useRef)(new Map),W=(0,m.useRef)(0),G=(0,m.useMemo)(()=>{let t=new Map;for(let n of e.messages)t.set(n.id,Ep(n));return t},[e.messages]),ae=(0,m.useRef)(G);ae.current=G;let oe=(0,m.useRef)(ne);oe.current=ne;let se=e.messages.length>Um&&!M,K=(0,m.useRef)(se);K.current=se;let ce=Cp(e.messages,V.current,Km),le=(0,m.useRef)(ce);le.current=ce;let ue=(0,m.useCallback)(()=>{let e=x.current;if(!e)return;if(!K.current){re(e=>e.size?new Set:e);return}let t=e.getBoundingClientRect(),n={top:t.top-Gm,bottom:t.bottom+Gm},r=[];for(let[e,t]of U.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),oe.current.has(e)||pe(e,n.bottom-n.top,ae.current.get(e))}let i=xp(r,n,le.current,oe.current);for(let e of i.hide){let t=U.current.get(e);t&&pe(e,t.offsetHeight,ae.current.get(e))}re(e=>Sp(e,i))},[]),de=(0,m.useCallback)(()=>{W.current||=requestAnimationFrame(()=>{W.current=0,ue()})},[ue]);(0,m.useLayoutEffect)(()=>{ue()},[ue]);let fe=(0,m.useRef)(M);(0,m.useLayoutEffect)(()=>{fe.current&&!M&&ue(),fe.current=M},[M,ue]);let pe=(0,m.useCallback)((e,t,n)=>{n!==void 0&&(H.current.set(e,{h:t,len:n}),V.current.set(e,t))},[]),me=(0,m.useCallback)((e,t)=>{pe(e,t,ae.current.get(e))},[pe]),he=(0,m.useCallback)(e=>{e&&U.current.set(e.dataset.lazyId??``,e)},[]);(0,m.useEffect)(()=>{let t=new Set(e.messages.map(e=>e.id));for(let e of U.current.keys())t.has(e)||(U.current.delete(e),V.current.delete(e),H.current.delete(e));re(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,j]),(0,m.useEffect)(()=>()=>cancelAnimationFrame(W.current),[]);let ge=(0,m.useMemo)(()=>{let t=[];for(let n of e.messages){if(n.role!==`user`)continue;let e=n.content.map(e=>Kf(e)?.text??``).filter(Boolean).join(` `),r=ff(e),i=r?r.userMessage??`skill:${r.name}`:e.trim();i&&t.push({id:n.id,text:i})}return t},[e.messages]),_e=(0,m.useMemo)(()=>{let e=new Map;return ge.forEach((t,n)=>e.set(t.id,n)),e},[ge]),[q,ve]=(0,m.useState)(-1),ye=(0,m.useRef)(-1),be=(0,m.useRef)(ge);(0,m.useEffect)(()=>{be.current=ge},[ge]);let xe=(0,m.useCallback)(()=>{let e=x.current,t=be.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!==ye.current&&(ye.current=r,ve(r))},[]);(0,m.useEffect)(()=>{xe()},[ge,xe]);let Se=(0,m.useCallback)(e=>{ee(t=>t.has(e)?t:new Set(t).add(e))},[]);(0,m.useLayoutEffect)(()=>{Af(e.messages.filter(Of).map(e=>({id:e.id,role:e.role,content:e.content})))},[e.messages]),(0,m.useEffect)(()=>{if(b.open){for(let e of b.selectedIds)Se(e);ie(e=>{let t=!1,n=new Set(e);for(let e of b.selectedIds)n.has(e)||(n.add(e),t=!0);return t?n:e})}},[b.open,b.selectedIds,Se]),(0,m.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(),N(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let Ce=(0,m.useCallback)(e=>{ee(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),we=(0,m.useCallback)(t=>{let n=e.messages.findIndex(e=>e.id===t);(0,k.flushSync)(()=>{n>=0&&n<R&&!j.has(t)&&Se(t),ie(e=>e.has(t)?e:new Set(e).add(t))});let r=be.current.findIndex(e=>e.id===t);ye.current=r,ve(r),requestAnimationFrame(()=>{let e=x.current?.querySelector(`[data-msg-id="${t}"]`);e&&(x.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!==x.current?.lastElementChild&&(D.current=!0))})},[e.messages,R,j,Se]),[Te,J]=(0,m.useState)(null),Ee=(0,m.useRef)(null),De=(0,m.useRef)(null);(0,m.useEffect)(()=>{let t=Ee.current;if(!t||t.convId!==e.conversationId){Ee.current={convId:e.conversationId,ids:new Set(e.messages.filter(e=>e.role===`compactionSummary`).map(e=>e.id))},De.current=null,J(null);return}for(let n of e.messages)if(n.role===`compactionSummary`&&!t.ids.has(n.id)){t.ids.add(n.id),J(n.id);break}},[e.messages,e.conversationId]),(0,m.useEffect)(()=>{Te&&De.current!==Te&&(De.current=Te,we(Te))},[Te,we]);let Oe=(0,m.useMemo)(()=>d?e.messages.find(e=>e.role===d.role&&e.timestamp===d.timestamp)?.id??null:null,[e.messages,d]);(0,m.useEffect)(()=>{if(d){if(Oe){we(Oe),f?.();return}e.sessionFile===d.path&&e.messages.length>0&&f?.()}},[Oe,we,f,d,e.sessionFile,e.messages.length]);let ke=(0,m.useCallback)(()=>{let e=x.current;if(!e)return;let t=e.scrollTop-T.current,n=e.scrollHeight-E.current;T.current=e.scrollTop,E.current=e.scrollHeight;let r=e.scrollHeight-e.scrollTop-e.clientHeight<80,i=Date.now()<A.current,a=zp({dSt:t,dSh:n,escaped:D.current,graceActive:i,stuck:w.current});a.reassert&&(A.current=Date.now()+Wm,e.scrollTop=e.scrollHeight),a.flipEscape&&(D.current=!0),r&&t>=0&&(D.current=!1),i||(t<0?w.current=r&&!D.current:r&&(w.current=!0)),C(w.current),xe(),de()},[xe,de]),Ae=(0,m.useRef)(!1);(0,m.useEffect)(()=>{let t=Ae.current;if(Ae.current=!!e.isStreaming,t&&!e.isStreaming&&!D.current){let e=()=>{let e=x.current;e&&!D.current&&(e.scrollTop=e.scrollHeight,w.current=!0,C(!0))};requestAnimationFrame(()=>requestAnimationFrame(e));let t=setTimeout(e,180);return()=>clearTimeout(t)}},[e.isStreaming]),(0,m.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[P,e.isStreaming,t]);let je=e.queue.steering.join(`\0`)+``+e.queue.followUp.join(`\0`);(0,m.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[je]),(0,m.useEffect)(()=>{let e=x.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,m.useEffect)(()=>{let e=x.current;if(!e||typeof MutationObserver>`u`)return;let t=!1,n=new MutationObserver(()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let e=x.current;e&&w.current&&!D.current&&(e.scrollTop=e.scrollHeight,C(!0))}))});return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[]);let Me=(0,m.useCallback)(()=>{if(!x.current)return;w.current=!0,D.current=!1,C(!0),A.current=Date.now()+Wm;let e=()=>{let e=x.current;e&&w.current&&!D.current&&(A.current=Date.now()+Wm,e.scrollTop=e.scrollHeight)};e(),requestAnimationFrame(()=>requestAnimationFrame(e)),setTimeout(e,120),setTimeout(e,300),setTimeout(e,600)},[]),Ne=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=Ne.current,t=x.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[Y,Pe]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=()=>{Pe(x.current?.clientHeight??0),de()};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[de]);let Fe=ge.length,Ie=(0,m.useMemo)(()=>Fe===0?27:Math.max(4,Math.min(27,Math.floor(((Y||600)-16)/Fe)-3)),[Fe,Y]),Le=Ie<20;return(0,X.jsxs)(`div`,{className:`messages-wrap${b.open?` messages-exporting`:``}`,children:[(0,X.jsx)(Bm,{rootRef:x,sessionId:e.sessionId,enabled:!b.open,onSelect:O}),(0,X.jsxs)(`div`,{className:`messages${M||S?``:` anchor-live`}`,ref:x,onScroll:ke,children:[e.messages.length===0&&!e.streamingMessage&&(0,X.jsxs)(`div`,{className:`empty-state`,children:[(0,X.jsx)(tm,{}),_&&_.length>0&&(0,X.jsx)(`div`,{className:`chat-empty-slots`,children:om(_,v)})]}),e.messages.map((o,s)=>{if(o.role===`system`)return null;let d=yp(o);if(d&&!j.has(o.id))return(0,X.jsx)(mp,{message:o,onExpand:Se,summary:d.kind===`prompt`?y(`goalBarReviewing`):d.verdict===`pass`?y(`goalBarPassed`):y(`goalBarFailed`)},o.id);let f=s<R,m=f&&j.has(o.id);if(f&&!m)return o.role===`toolResult`?null:(0,X.jsx)(mp,{message:o,onExpand:Se},o.id);let _=o.role===`user`?_e.get(o.id):void 0,b=!se||ce.has(o.id)||B.has(o.id)||!ne.has(o.id);return(0,X.jsx)(bp,{id:o.id,show:b,height:Dp(o.id,G.get(o.id)??-1,H.current,wp(o.role,o.customType)),containerRef:x,onMeasured:me,lazyRef:he,children:(0,X.jsx)(np,{uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:o,qnIndex:_,qnActive:_===void 0?void 0:_===q,onJump:we,toolResults:F,liveOutputs:Ym(o)?t:Vm,toolStatuses:n,streaming:e.isStreaming,onKillBash:i,onRetry:o.id===te?a:void 0,toolsWrap:l,toolImages:u,thinkingWrap:c,isLast:o.id===te,onEdit:r,questionAttachments:I.get(o.id),onCollapse:m?Ce:void 0,searchActive:M,autoExpand:o.id===Te},o.id)},o.id)}),e.streamingMessage&&(0,X.jsx)(np,{uiMessageActions:p,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:e.streamingMessage,toolResults:F,liveOutputs:Ym(e.streamingMessage)?t:Vm,toolStatuses:n,streaming:!0,isLast:!0,onEdit:r,onKillBash:i,toolsWrap:l,toolImages:u,thinkingWrap:c,searchActive:M},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?y(`retryingApi`,{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):y(`retryingApiSoon`,{error:e.retry.errorMessage})})]}),e.compaction&&(0,X.jsx)(Jm,{compaction:e.compaction}),e.isStreaming&&P.length===0&&(0,X.jsx)(`div`,{className:`streaming-wait`,children:y(`waitingResponse`)}),e.queue.steering.map((e,t)=>(0,X.jsx)(qm,{kind:`steer`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-steer-${t}`)),e.queue.followUp.map((e,t)=>(0,X.jsx)(qm,{kind:`followUp`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-fu-${t}`))]}),!S&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,title:y(`backToBottom`),"aria-label":y(`backToBottom`),onClick:Me,children:[(0,X.jsx)(pt,{}),(0,X.jsx)(`span`,{className:`scroll-bottom-label`,children:y(`backToBottom`)})]}),(0,X.jsx)(Rp,{containerRef:x,messages:P,collapsedIds:z,toolResults:F,onExpand:Se,onProgrammaticScroll:()=>{D.current=!0,w.current=!1,C(!1)},open:M,onClose:()=>N(!1)}),ge.length>0&&(0,X.jsxs)(`div`,{className:`qn-rail ${Le?`many`:``}`,ref:Ne,"aria-label":y(`questionNavTitle`),style:{"--rail-gap":`${Ie}px`},children:[ge.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`qn-bar ${t===q?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>we(e.id),children:(0,X.jsxs)(`span`,{className:`qn-bar-text`,children:[t+1,`. `,e.text]})},e.id)),Le&&(0,X.jsx)(`div`,{className:`qn-list`,children:ge.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`qn-list-item ${t===q?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>we(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)(Fm,{})]})}function Zm(e,t){return t?e.trim()?`${e.replace(/\s+$/,``)}\n${t}`:t:e}function Qm(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 $m(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 eh(e,t){return t?e?{key:t,clear:e!==t}:{key:t,clear:!1}:{key:e,clear:!1}}function th(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=new Set(e.map($m).filter(e=>e!==null)),r=[...e];for(let e of t){let t=$m(e);if(t!==null){if(n.has(t))continue;n.add(t)}r.push(e)}return r}function nh(e,t,n){return!(!e||!e.trim()||t>0||n)}function rh(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var ih=``;function ah(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function oh(e,t){return{first:!e.slice(0,t).includes(`
|
|
355
355
|
`),last:!e.slice(t).includes(`
|
|
356
|
-
`)}}var oh=null;function sh(){if(oh?.isConnected)return oh;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),oh=e,e}function ch(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 lh(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=rh,e.appendChild(n),n.offsetTop}function uh(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=ah(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=sh();if(ch(e,i)<=0)return r;let a=lh(i,t.slice(0,n)),o=lh(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:ih(a,o,nh(e))}function dh(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 fh=`pi-web-ui:prompt-history`,ph=`pi-web-ui:prompt-history-settings`,mh={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function hh(e){let t=mh;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 gh(){try{let e=localStorage.getItem(ph);return e?hh(JSON.parse(e)):{...mh}}catch{return{...mh}}}function _h(e){let t=hh(e);try{localStorage.setItem(ph,JSON.stringify(t))}catch{}try{let e=bh();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)),xh(e)}catch{}}function vh(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 yh(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 bh(){try{let e=localStorage.getItem(fh);return e?vh(JSON.parse(e)):[]}catch{return[]}}function xh(e){let t=e;for(;t;)try{localStorage.setItem(fh,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 Sh(e){let t=e.trim();if(!t)return;let n=gh();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));let r=bh(),i=yh(r,t,n.maxEntries);i!==r&&xh(i)}function Ch(){try{localStorage.removeItem(fh)}catch{}}var wh=`skill:`;function Th(e,t){let n=e.toLowerCase();return t===`skill`&&n.startsWith(`skill:`)?[n,n.slice(6)]:[n]}function Eh(e,t){let n=t.toLowerCase();return n?e.filter(e=>Th(e.name,e.source).some(e=>e.startsWith(n))):[...e]}var Dh=new Set([`p`,`page`,`pages`,`web`,`网页`,`页面`]);function Oh(e,t,n,r=10){if(!Array.isArray(t))return[];let i=String(n??``).toLowerCase(),a=i===``||Dh.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 kh(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 Ah(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 jh(e,t,n,r=15,i){if(!Array.isArray(t)||r<=0)return[];let a=String(n??``).toLowerCase(),o=a.startsWith(wh),s=o?a.slice(wh.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(wh.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 Mh(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 Nh(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function Ph(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||!Nh(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 Fh(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 Ih(){return typeof window>`u`||typeof navigator>`u`||typeof window.matchMedia!=`function`?!1:Fh({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}function Lh(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}var Rh=1;function zh(){return++Rh}var Bh=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Vh=(0,m.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,m.useState)(!1),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),[v,y]=(0,m.useState)(null),[b,x]=(0,m.useState)({}),S=(0,m.useRef)(null),C=(0,m.useRef)(null),[w,T]=(0,m.useState)(null);(0,m.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,m.useEffect)(()=>{d&&x(Up())},[d]),(0,m.useEffect)(()=>{d||(_(``),y(null))},[d]);let E=(0,m.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,m.useMemo)(()=>Hp(t,b),[t,b]),O=(0,m.useMemo)(()=>{let e=D;v&&(e=e.filter(e=>e.provider===v.provider));let t=g.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)):e},[D,g,v]),k=(0,m.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,m.useState)(!1),ee=e?.availableThinkingLevels&&e.availableThinkingLevels.length>0?new Set(e.availableThinkingLevels):null,N=Bh.map(e=>({value:e,label:c(`thinking.${e}`),supported:!ee||ee.has(e)})),P=e=>N.find(t=>t.value===e)?.label??e,F=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!d){F.current=!1;return}F.current||t.length>0||n||(F.current=!0,j(!0),$({type:`list_models`})||j(!1))},[d,t.length,n]),(0,m.useEffect)(()=>{j(!1)},[t]),(0,m.useEffect)(()=>{d&&(S.current?.querySelector(`.dd-item.active`))?.scrollIntoView({block:`nearest`})},[d,u,t.length]);let I=(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)(W,{}),(0,X.jsx)(`input`,{className:`dd-search`,type:`text`,placeholder:c(`searchModels`),value:g,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)(Nt,{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`)})]})]}),L=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`thinkingLevel`)}),N.map(t=>(0,X.jsx)(Nt,{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}),h(!1)},children:t.label},t.value))]}),te=(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ue,{}),(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:I}),R=(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:c(`thinkingChip`,{level:e?P(e.thinkingLevel):`—`})})]}),tip:c(`thinkingLevel`),open:p,onOpenChange:h,align:`left`,direction:`up`,children:L});if(s===`model`)return te;if(s===`thinking`)return R;let z=e?.thinkingLevel&&e.thinkingLevel!==`off`;return(0,X.jsxs)(`div`,{className:`model-thinking-capsule`,children:[(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ue,{}),(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:I}),(0,X.jsx)(`div`,{className:`capsule-divider`}),(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`thinking-pulse-dot ${z?`on`:``}`}),(0,X.jsx)(`span`,{className:`capsule-thinking-text`,children:e?P(e.thinkingLevel):`—`})]}),triggerClassName:`capsule-segment capsule-thinking`,open:p,onOpenChange:h,align:`left`,direction:`up`,children:L})]})}),Hh=[`standard`,`ptc`,`minimal`,`cordis`],Uh={standard:`preset.standard`,minimal:`preset.minimal`,code:`preset.code`,reader:`preset.reader`,ask:`preset.ask`},Wh={standard:`preset.standardDesc`,minimal:`preset.minimalDesc`,code:`preset.codeDesc`,reader:`preset.readerDesc`,ask:`preset.askDesc`};function Gh(e){return Uh[e]??null}function Kh(e){return Wh[e]??null}function qh(e,t,n){let r=t===`zh`,i=Gh(e.id),a=Kh(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 Jh(e){return[...e].sort((e,t)=>{let n=Number.isSafeInteger(e.order)?e.order:Hh.indexOf(e.id),r=Number.isSafeInteger(t.order)?t.order:Hh.indexOf(t.id),i=n>=0?n:1e3,a=r>=0?r:1e3;return i===a?e.id.localeCompare(t.id):i-a})}var Yh=(0,m.memo)(function({preset:e,presets:t,defaultPreset:n,blank:r,conversationId:i,compact:a=!1}){let o=Z(),{locale:s}=wn(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(e?.id??n);if((0,m.useEffect)(()=>{d(e?.id??n)},[i,e?.id,n]),t.length===0)return null;let f=e?.locked||!r,p=Jh(t),h=p.find(t=>t.id===e?.id),g=p.find(e=>e.id===u)??h,_=e=>qh(e,s,o),v=h?_(h):void 0,y=t=>{d(t),l(!1),r&&t!==e?.id&&$({type:`dsh_preset_select`,preset:t})};if(a){let t=v?.description??h?.id??o(`dshPreset`);return(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:f?`${t}(${o(`dshPresetLocked`)})`:t,children:[v?.name??h?.id??e?.name??o(`dshPreset`),f&&(0,X.jsx)(xe,{style:{marginLeft:3}})]})]}),open:c&&!f,onOpenChange:l,direction:`up`,align:`left`,children:p.map(t=>{let r=_(t);return(0,X.jsxs)(Nt,{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)(V,{}),o(`dshPreset`)]}),(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(`span`,{title:v?.description??h?.id??``,children:[v?.name??h?.id??e?.name??`…`,f&&(0,X.jsxs)(`span`,{className:`dsh-preset-lock`,title:o(`dshPresetBlankOnly`),children:[(0,X.jsx)(xe,{}),` `,o(`dshPresetLocked`)]})]}),open:c&&!f,onOpenChange:l,children:p.map(t=>{let r=_(t);return(0,X.jsxs)(Nt,{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`)}),g?.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:g?.id??u}),Qn()},children:[(0,X.jsx)(le,{}),` `,o(`dshPresetNewChat`)]})]})}),Xh=[`read-only`,`workspace-write-never`,`danger-full-access`],Zh=[`read-only`,`workspace-write-never`,`danger-full-access`];function Qh(e){return e===`read-only`?`dshPermReadOnly`:e===`danger-full-access`?`dshPermFullAccess`:`dshPermWorkspaceWrite`}function $h(e){return e===`read-only`?`dshPermReadOnlyDesc`:e===`danger-full-access`?`dshPermFullAccessDesc`:`dshPermWorkspaceWriteDesc`}var eg=(0,m.memo)(function({current:e,options:t,defaultPreset:n,conversationId:r,compact:i=!1}){let a=Z(),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1);(0,m.useEffect)(()=>{l(!1),s(!1)},[r]);let u=Xh.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`:Qh(d)),r=f?e??t:a($h(d));return(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ae,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:r,children:[t,d===`danger-full-access`&&(0,X.jsx)(gt,{style:{marginLeft:3}})]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},direction:`up`,align:`left`,children:[u.map(e=>(0,X.jsxs)(Nt,{active:e===d,title:a($h(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(Qh(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($h(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)(ae,{}),a(`dshPerm`)]}),(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(`span`,{title:f?e:a($h(d)),children:[a(f?`dshPermCustom`:Qh(d)),d===`danger-full-access`&&(0,X.jsxs)(`span`,{className:`dd-preset-tag warn`,children:[(0,X.jsx)(gt,{}),` `,a(`dshPermFullAccessTag`)]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},children:u.map(e=>(0,X.jsxs)(Nt,{active:e===d,title:a($h(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(Qh(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($h(e))})]},e))}),c&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:a(`dshPermConfirmFull`)})]})}),tg=Ih(),ng=40,rg=220,ig=720,ag=`pi-web-ui:composer-height`,og=(0,m.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:h,onSent:g,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:N,sessionId:P}){let F=Z(),I=ha(`ready`),L=ga(),{locale:te}=wn(),{openPicker:R}=Qp(),z=e=>te!==`zh`&&e.descriptionEn?e.descriptionEn:e.description??``,ne=e=>te!==`zh`&&e.argumentHintEn?e.argumentHintEn:e.argumentHint??``,[re,B]=(0,m.useState)(``),[V,ae]=(0,m.useState)(()=>{try{let e=Number(localStorage.getItem(ag));if(Number.isFinite(e)&&e>=ng&&e<=ig)return e}catch{}return null}),H=(0,m.useRef)(null),[U,W]=(0,m.useState)(null),[oe,se]=(0,m.useState)(0),ce=(0,m.useRef)(0),G=(0,m.useRef)(new Map),le=(0,m.useRef)(``),[ue,fe]=(0,m.useState)(!1),[pe,me]=(0,m.useState)(void 0),he=(0,m.useRef)(null),ge=(0,m.useRef)(null),ve=(0,m.useRef)(null),K=(0,m.useRef)(-1),ye=(0,m.useRef)(``),be=(0,m.useRef)(0);(0,m.useEffect)(()=>{if(!S||S.length===0)return;let e=S.filter(e=>e.text&&e.seq>be.current);e.length!==0&&(be.current=e[e.length-1].seq,W(null),B(t=>{let n=e.reduce((e,t)=>Xm(e,t.text),t);return le.current=n,n}),K.current=-1,ye.current=``,requestAnimationFrame(()=>{let e=he.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}))},[S]),(0,m.useEffect)(()=>(Yn(e=>{W(null),B(t=>{let n=Xm(t,e);return le.current=n,n}),K.current=-1,ye.current=``,requestAnimationFrame(()=>{let e=he.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)})}),()=>Yn(null)),[]),(0,m.useEffect)(()=>(Zn(()=>{tg||requestAnimationFrame(()=>{he.current?.focus()})}),()=>Zn(null)),[]);let xe=(0,m.useRef)(``);xe.current=re,(0,m.useEffect)(()=>(Gn(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(xe.current))return}let t=he.current;if(!t){B(t=>{let n=t+(t&&!t.endsWith(` `)?` `:``)+e;return le.current=n,n});return}let n=t.selectionStart??xe.current.length,r=t.selectionEnd??xe.current.length,i=xe.current,a=(n>0&&!/[\s([{]$/.test(i.slice(0,n))?` `:``)+e,o=i.slice(0,n)+a+i.slice(r);le.current=o,B(o);let s=n+a.length;requestAnimationFrame(()=>{t.focus(),t.selectionStart=t.selectionEnd=s})}),()=>Gn(null)),[]),(0,m.useEffect)(()=>(Kn(e=>{B(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(),le.current=a,a})}),()=>Kn(null)),[]);let Se=2e4,we=!L&&P?`${M??``}${P}`:null,Te=we&&P?`pi-web-ui:composer-draft:${P}`:null,Ee=(0,m.useRef)(``),q=(0,m.useRef)(0),J=(0,m.useRef)(!1),De=(0,m.useRef)(0),Oe=(0,m.useRef)(null),ke=(0,m.useRef)(null),Ae=(0,m.useRef)(null),je=(0,m.useRef)(0),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,Se),ts:n.ts}}catch{return null}},Ne=(e,t,n,r)=>{let i=n.slice(0,Se);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})},Y=()=>{Oe.current&&=(clearTimeout(Oe.current),null),J.current&&we&&Te&&P&&Xe&&Ne(P,Te,Ee.current,q.current)},Pe=e=>{if(Ee.current=e,J.current=!0,q.current=Date.now(),Te){let t=e.slice(0,Se);try{t.trim()?localStorage.setItem(Te,JSON.stringify({text:t,ts:q.current})):localStorage.removeItem(Te)}catch{}}if(we&&P&&Xe){Oe.current&&clearTimeout(Oe.current);let e=P,t=Te,n=q.current,r=we;Oe.current=setTimeout(()=>{Oe.current=null,r===ke.current&&t&&Ne(e,t,Ee.current,n)},2e3)}},Fe=(e,t)=>{K.current=-1,B(e),Re(e,t),Pe(e)};(0,m.useEffect)(()=>{let e=we,t=P,n=Te;return()=>{Oe.current&&=(clearTimeout(Oe.current),null),J.current&&Ee.current.trim()?(e&&t&&n&&Ne(t,n,Ee.current,q.current),Ae.current=Ee.current):Ae.current=null}},[we]),(0,m.useEffect)(()=>{ke.current=we;let e=Ae.current;Ae.current=null;let t=Te?Me(Te):null,r=!!(N&&N.text?.trim()&&N.ts>0||t&&t.text?.trim());e!==null&&th(e,n.length,r)&&Te&&P?(J.current=!0,De.current=Date.now(),Ee.current=e,q.current=De.current,B(e),Ne(P,Te,e,q.current)):(J.current=!1,De.current=0,Ee.current=``,q.current=0,B(``)),W(null),K.current=-1},[we]);let Ie=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=n.length===0,t=Ie.current!==we;Ie.current=we,I&&e&&(!tg||t)&&requestAnimationFrame(()=>{he.current?.focus()})},[we,n.length,I]),(0,m.useEffect)(()=>{if(!we||!Te||J.current||Ee.current!==``)return;let e=Zm(N&&N.text?{text:N.text.slice(0,Se),ts:N.ts}:null,Me(Te),De.current);e&&(De.current=e.ts,Ee.current=e.text,q.current=e.ts,B(e.text),Re(e.text,null))});let Le={builtin:F(`slashBuiltin`),extension:F(`slashExtension`),prompt:F(`slashPrompt`),skill:F(`slashSkill`),plugin:F(`slashPlugin`)},Re=(e,t)=>{le.current=e;let n=e.match(/^\/([^\s]*)$/);if(n&&I){let e=Eh(r,n[1].toLowerCase());W(e.length>0?{kind:`slash`,items:e}:null),se(0);return}if(t===null||!I){W(null);return}let i=Ph(e,t);if(!i){W(null);return}let a=[];try{a=qo()}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=Jo(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:F(`openFiles`),run:()=>ze(l)}),Pn();let f=Oh(F(`browserControl`),Nn(),l);if(d.push({id:`host:pages`,label:F(`browserControl`),run:()=>Promise.resolve(f)}),d.length===0){W(null);return}let m=jh(F(`slashSkill`),r,l,15,z),h=Mh({pages:f,skills:m},l,30),g=!1;h.length>0&&(g=!0,W({kind:`at`,start:c,end:u,items:h}),se(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||le.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(...kh(d[i].label,e.value)):r.push(...Ah(d[i].id,d[i].label,e.value)))});let i=Mh({pages:t,skills:m,files:n,plugins:r},l,30);W(i.length>0?{kind:`at`,start:c,end:u,items:i}:null),!g&&i.length>0&&se(0)})},ze=e=>{if(typeof p!=`function`)return Promise.resolve([]);let t=zh();return new Promise(n=>{G.current.set(t,n);try{p(t,e)}catch{G.current.delete(t),n([]);return}setTimeout(()=>{G.current.get(t)===n&&(G.current.delete(t),n([]))},3e3)})};(0,m.useEffect)(()=>{if(!f||!f.ok)return;let e=G.current.get(f.reqId);e&&(G.current.delete(f.reqId),e(f.results??[]))},[f]);let Be=e=>Re(e,null);(0,m.useEffect)(()=>{(ve.current?.querySelector(`.slash-item.active`))?.scrollIntoView({block:`nearest`})},[oe,U]);let Ve=e=>{let t=U?.kind===`slash`?U.items:[],n=e??t[oe%Math.max(t.length,1)];if(!n){W(null);return}let r=re.match(/^\/([^\s]*)([\s\S]*)$/),i=r?r[2]:``,a=`/${n.name} ${i}`;le.current=a,B(a),Pe(a),W(null),he.current?.focus()},He=(e,t)=>{let n=U?.kind===`at`?U:null,r=n?.items??[],i=e??r[oe%Math.max(r.length,1)],a=t??n?.start;if(!i||a===void 0){W(null);return}let o=he.current,s=o?o.selectionStart??re.length:re.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=`${re.slice(0,a)}${f}${re.slice(c)}`;le.current=p,B(p),Pe(p),W(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=he.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=a+f.length)})},Ue=()=>U?.kind===`slash`?U.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===oe?` active`:``}`,onMouseEnter:()=>se(t),onClick:()=>Ge(e),children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Le[e.source]}),(0,X.jsxs)(`span`,{className:`slash-desc`,children:[z(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:ne(e)})]})]},e.name)):null,We=()=>U?.kind===`at`?U.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===oe?` active`:``}`,onMouseEnter:()=>se(t),onClick:()=>Ge(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,Ge=e=>{U&&(U.kind===`slash`?Ve(e):He(e,U.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(`
|
|
357
|
-
`);if(!e){h(`warning`,F(`slashCopyEmpty`));return}await ml(e)?h(`info`,F(`slashCopied`)):h(`error`,F(`slashCopyFailed`))},qe=e=>{if(!e||e.length===0){h(`warning`,F(`foldersNotSupported`));return}let t=Array.from(e).filter(e=>mf(e.type)),n=Array.from(e).filter(e=>!mf(e.type)),r=Ye();t.length>0&&r?h(`warning`,r):t.length>0&&l(t),n.length>0&&u(n)},Je=e=>{let t=dh(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?F(`modelNoVision`,{name:t.name}):null},Xe=I,Ze=(0,m.useRef)(re);(0,m.useEffect)(()=>{Ze.current=re},[re]),(0,m.useEffect)(()=>{Be(Ze.current)},[r]),(0,m.useEffect)(()=>{let e=e=>{let t=e.detail;W(null),le.current=t,B(t),he.current?.focus()};return window.addEventListener(`pi-web:fill`,e),()=>window.removeEventListener(`pi-web:fill`,e)},[]),(0,m.useEffect)(()=>{if(!ue)return;let e=e=>{e.key===`Escape`&&fe(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ue]);let Qe=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=he.current,t=Qe.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=V==null?rg:ig;e.style.maxHeight=`${a}px`;let o=Math.min(Math.max(e.scrollHeight,V??0),a);e.style.height=`${o}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`,n&&(n.scrollTop=i+(t.getBoundingClientRect().height-r))},[re,V]);let $e=()=>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}:{}}:{}}),et=(e=!1)=>{let t=re.trim(),n=s.length>0;if(t||n){if(!Xe){h(`error`,F(`netDisconnected`));return}if(t===`/help`){let e=he.current?.closest(`.inputbox`)?.getBoundingClientRect();me(e?.width),fe(!0),B(``),he.current?.focus();return}if(t===`/copy`){B(``),he.current?.focus(),Ke();return}if($({type:`prompt`,text:t,queue:e,attachments:$e()})){if(t&&Sh(t),K.current=-1,ye.current=``,B(``),Te)try{localStorage.removeItem(Te)}catch{}Oe.current&&=(clearTimeout(Oe.current),null),J.current=!1,De.current=Date.now(),Ee.current=``,q.current=0,g();let e=i?.model;e&&Gp(`${e.provider}/${e.id}`),he.current?.focus()}else h(`error`,F(`netDisconnected`))}},tt=(e,t=!1)=>{let n=e.trim();if(n){if(!Xe){h(`error`,F(`netDisconnected`));return}if($({type:`prompt`,text:n,queue:t,attachments:$e()})){n&&Sh(n),K.current=-1,ye.current=``,Y(),g();let e=i?.model;e&&Gp(`${e.provider}/${e.id}`),tg||he.current?.focus()}else h(`error`,F(`netDisconnected`))}},nt=e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229||Date.now()-je.current<50)){if(U&&U.items.length>0){let t=U.items.length;switch(e.key){case`ArrowDown`:e.preventDefault(),se(e=>(e+1)%t);return;case`ArrowUp`:e.preventDefault(),se(e=>(e-1+t)%t);return;case`Tab`:case`Enter`:e.preventDefault(),Ge();return;case`Escape`:e.preventDefault(),W(null);return}}if(e.key===`Backspace`&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=he.current;if(t&&t.selectionStart===t.selectionEnd&&t.selectionStart>0){let n=t.selectionStart,r=Lh(re.slice(0,n),n,s);if(r&&r.tokenStart>=0&&r.tokenStart<n){e.preventDefault();let t=r.tokenStart,i=re.slice(0,t)+re.slice(n);le.current=i,B(i),requestAnimationFrame(()=>{he.current&&(he.current.selectionStart=he.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=he.current;if(!t)return;let n=e.key===`ArrowUp`,r=uh(t);if(n&&!r.first||!n&&!r.last||!n&&K.current===-1)return;let i=bh();if(i.length===0)return;if(e.preventDefault(),n){if(K.current===-1){ye.current=re;let e=i.length-1;K.current=e;let t=i[e];B(t),Be(t),requestAnimationFrame(()=>{let e=he.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else if(K.current>0){let e=K.current-1;K.current=e;let t=i[e];B(t),Be(t),requestAnimationFrame(()=>{let e=he.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}}else{let e=K.current+1;if(e<i.length){K.current=e;let t=i[e];B(t),Be(t),requestAnimationFrame(()=>{let e=he.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else{K.current=-1;let e=ye.current;B(e),Be(e),requestAnimationFrame(()=>{let t=he.current;t&&(t.selectionStart=t.selectionEnd=e.length)})}}return}if(e.key===`Escape`&&K.current!==-1){e.preventDefault();let t=ye.current;K.current=-1,B(t),Be(t),requestAnimationFrame(()=>{let e=he.current;e&&(e.selectionStart=e.selectionEnd=t.length)});return}if(e.key===`Enter`){if(tg&&!e.shiftKey&&!(e.ctrlKey||e.metaKey))return;e.shiftKey||(e.preventDefault(),et())}}},rt=Xe&&(re.trim()!==``||s.length>0),it=(0,m.useMemo)(()=>Pi((w??[]).filter(e=>e.source!==`host`&&!e.hidden)),[w]),at=(0,m.useMemo)(()=>(C??[]).filter(e=>e.source!==`host`&&!e.hidden),[C]),st=w!==void 0,lt=(0,m.useMemo)(()=>Pi((w??[]).filter(e=>!e.hidden)),[w]),dt=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)(_e,{}):e.icon===`camera`?(0,X.jsx)(ot,{}):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)},ft=()=>(0,X.jsx)(`div`,{className:`inputbox-actions`,children:e?rt?(0,X.jsxs)(`div`,{className:`split-send${L?` single`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`split-queue`,title:F(`supplementTip`),"aria-label":F(`queueFollowTag`),onClick:()=>et(!0),children:(0,X.jsx)(Ce,{})}),!L&&(0,X.jsx)(`button`,{type:`button`,className:`split-steer`,title:F(`steerTip`),"aria-label":F(`queueSteerTag`),onClick:()=>et(),children:(0,X.jsx)(ut,{})})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn stop`,title:F(`stopAgent`),onClick:()=>$({type:`abort`}),children:(0,X.jsx)(ie,{})}):(0,X.jsx)(`button`,{type:`button`,className:`btn send`,title:F(`sendTip`),disabled:!rt,onClick:()=>et(),children:(0,X.jsx)(ut,{})})}),pt={"host:composer-upload":(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:F(`uploadFile`),disabled:!Xe,onClick:()=>ge.current?.click(),children:(0,X.jsx)(de,{})}),"host:composer-templates":(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:F(`tpl.openPicker`),onClick:R,children:(0,X.jsx)(ct,{})}),"host:composer-model":(0,X.jsx)(Vh,{only:`model`,state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,defaultModel:y,compact:!0}),"host:composer-thinking":(0,X.jsx)(Vh,{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)(eg,{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)(Yh,{compact:!0,preset:k??null,presets:A,defaultPreset:j,blank:ee??!1,conversationId:M??``}):null,"host:composer-send":ft()},mt=e=>e.source===`host`?(0,X.jsx)(m.Fragment,{children:pt[e.id]??null},e.id):dt(e);return(0,X.jsxs)(`div`,{ref:Qe,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`,children:[s.map(e=>e.mode===`quote`&&e.quote?(0,X.jsx)(Ml,{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?F(`attachImage`,{name:e.name}):e.fileData?F(`attachFile`,{name:e.name}):e.isDir?F(`folderRef`,{path:e.path}):e.mode===`page`?F(`attachPage`,{name:e.name}):e.mode===`conversation`?F(`attachConversation`,{name:e.name}):e.mode===`reference`?F(`refOnly`,{path:e.path}):e.mode===`lines`&&e.lines?F(`attachLines`,{path:e.path,start:e.lines.start,end:e.lines.end}):F(`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:F(`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:F(`attachHint`)})]}),U&&U.items.length>0&&(0,X.jsxs)(`div`,{className:`slash-menu`,role:`listbox`,ref:ve,"aria-label":U.kind===`slash`?F(`slashCommands`):F(`atMentions`),"data-menu-kind":U.kind,children:[(0,X.jsxs)(`div`,{className:`slash-menu-hint`,children:[(0,X.jsx)(`span`,{children:U.kind===`slash`?F(`slashMenuHint`):F(`atMenuHint`)}),(0,X.jsx)(`span`,{className:`slash-menu-close`,onClick:()=>W(null),children:`Esc`})]}),U.kind===`slash`?Ue():We()]}),ue&&(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:[`⚡ `,F(`slashHelpTitle`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>fe(!1),children:F(`close`)})]}),(0,X.jsx)(`div`,{className:`slash-help-body`,children:r.length===0?(0,X.jsx)(`div`,{className:`slash-help-empty`,children:F(`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:Le[e.source]}),(0,X.jsxs)(`span`,{className:`slash-help-desc`,children:[z(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:ne(e)})]})]},e.name))})]})}),x&&b.length>0&&(0,X.jsx)(`div`,{className:`quick-row`,"aria-label":F(`quickPhrases`),children:b.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`quick-chip`,title:`${F(`quickPhrasesTip`,{text:e})}(${F(`quickPhrasesSendTip`)})`,disabled:!Xe,onClick:()=>tt(e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),tt(e,!0)},children:e},e))}),(0,X.jsxs)(`div`,{className:`inputbox`,"data-pi-anchor":`composer`,children:[(0,X.jsx)(`div`,{className:`composer-resize`,title:F(`composerResize`),"aria-label":F(`composerResize`),role:`separator`,"aria-orientation":`horizontal`,"aria-valuenow":Math.round(V??rg),"aria-valuemin":ng,"aria-valuemax":ig,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId);let t=he.current?.getBoundingClientRect().height;H.current={startY:e.clientY,startH:typeof t==`number`&&Number.isFinite(t)?t:V??rg,next:null}},onPointerMove:e=>{let t=H.current;if(!t)return;let n=Math.min(ig,Math.max(ng,t.startH+(t.startY-e.clientY)));t.next=n,ae(n)},onPointerUp:()=>{let e=H.current?.next;if(H.current=null,e!=null)try{localStorage.setItem(ag,String(Math.round(e)))}catch{}},onPointerCancel:()=>{H.current=null},onDoubleClick:()=>{ae(null);try{localStorage.removeItem(ag)}catch{}}}),(0,X.jsx)(`input`,{ref:ge,type:`file`,multiple:!0,hidden:!0,onChange:e=>{qe(e.target.files),e.target.value=``}}),(0,X.jsx)(`textarea`,{ref:he,value:re,rows:1,placeholder:F(Xe?e?L?`placeholderStreamingQueued`:`placeholderStreaming`:t?`placeholderPlanMode`:`placeholderIdle`:`placeholderConnecting`),disabled:!Xe,onChange:e=>{Fe(e.target.value,e.target.selectionStart??e.target.value.length)},onSelect:e=>{if(U?.kind===`at`){let t=e.target.selectionStart;(t<U.start||t>U.end)&&W(null)}},onCompositionEnd:()=>{je.current=Date.now()},onBlur:Y,onKeyDown:nt,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:F(`planModeTip`),children:[`📋 `,F(`planModeBadge`),` `,(0,X.jsx)(`span`,{style:{marginLeft:2,opacity:.7},children:`✕`})]}),(0,X.jsx)(`div`,{className:`composer-tools`,children:st?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[at.map(dt),lt.start.map(mt)]}),lt.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:lt.center.map(mt)}),(0,X.jsx)(`div`,{className:`composer-tools-right`,children:lt.end.map(mt)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[at.map(dt),(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:F(`uploadFile`),disabled:!Xe,onClick:()=>ge.current?.click(),children:(0,X.jsx)(de,{})}),it.start.map(dt),(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:F(`tpl.openPicker`),onClick:R,children:(0,X.jsx)(ct,{})}),(0,X.jsx)(Vh,{state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,defaultModel:y,compact:!0}),D&&D.length>0&&O!==void 0&&(0,X.jsx)(eg,{compact:!0,current:E??null,options:D,defaultPreset:O,conversationId:M??``}),A&&A.length>0&&j!==void 0&&(0,X.jsx)(Yh,{compact:!0,preset:k??null,presets:A,defaultPreset:j,blank:ee??!1,conversationId:M??``})]}),it.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:it.center.map(dt)}),(0,X.jsxs)(`div`,{className:`composer-tools-right`,children:[it.end.map(dt),ft()]})]})})]})]})}),sg=(0,m.memo)(function({goal:e,models:t,modelsLoading:n,activeConversationId:r,uiGoalbarActions:i,onUiAction:a}){let o=Z(),{locale:s}=wn(),c=s!==`zh`&&e.statusEn?e.statusEn:e.status||``,l=s!==`zh`&&e.wizard?.statusEn?e.wizard.statusEn:e.wizard?.status||``,u=ga(),d=!e.conversationId||e.conversationId===r,f=e.goal!==null&&d,p=d?e.roles?.executor:void 0,h=p?.convId,g=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,m.useState)(``),[w,T]=(0,m.useState)(e.reviewModel??``),[E,D]=(0,m.useState)(e.maxRounds),[O,k]=(0,m.useState)(e.locked),[A,j]=(0,m.useState)(e.execModel??``),[ee,M]=(0,m.useState)(!1),[P,F]=(0,m.useState)(!1),[I,te]=(0,m.useState)(!1),[R,z]=(0,m.useState)(!1),[ne,B]=(0,m.useState)(!0);(0,m.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,m.useEffect)(()=>{ee&&t.length===0&&!R&&!n&&(z(!0),$({type:`list_models`}))},[ee,t.length,R,n]),(0,m.useEffect)(()=>{t.length>0&&z(!1)},[t.length]);let V=()=>w?t.find(e=>e.id===w)?.name??w:o(`goalBarUseMainModel`),ae=()=>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(``),B(!1))},U=()=>{let e=S.trim();$({type:`set_plan_mode`,enabled:!0}),e&&($({type:`prompt`,text:e}),C(``))},W=()=>{let e=S.trim();e&&($({type:`start_goal_wizard`,text:e,...w?{wizardModel:w}:{},maxRounds:E,locked:O}),C(``),B(!1))},oe=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),se=e=>{let t=new Set(e);return oe.filter(e=>t.has(e.id)||e.source!==`host`)},ce={"host:goal-pill":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-hint`,title:o(`goalBarPlaceholder`),onClick:()=>B(!1),children:[(0,X.jsx)(re,{}),` `,(0,X.jsx)(`span`,{children:o(`goalBarTitle`)})]}),"host:goal-set":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn`,disabled:!S.trim(),onClick:H,children:o(`goalBarSet`)}),"host:goal-wizard":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn action wizard`,disabled:!S.trim(),title:o(`goalWizardTip`),onClick:W,children: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:U,children: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)(xe,{}):(0,X.jsx)(L,{})}),"host:goal-collapse":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarClear`),onClick:()=>B(!0),children:(0,X.jsx)(et,{})}),"host:goal-model":u?(0,X.jsx)(`p`,{className:`goalbar-dsh-note`,children:o(`dshNoReviewModel`)}):(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:`${o(`goalBarReviewModel`)}: ${V()}`,children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${o(`goalBarReviewModel`)}:`}),(0,X.jsx)(`b`,{children:V()})]}),open:ee,onOpenChange:M,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarReviewModel`)}),(R||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!R&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(Nt,{active:w===``,onClick:()=>{T(``),M(!1),$({type:`set_goal_prefs`,reviewModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(Nt,{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: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)(Mt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:`${o(`goalBarExecModel`)}: ${ae()} · ${o(`goalBarExecModelTip`)}`,children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${o(`goalBarExecModel`)}:`}),(0,X.jsx)(`b`,{children:ae()})]}),open:P,onOpenChange:F,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarExecModel`)}),(R||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!R&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(Nt,{active:A===``,onClick:()=>{j(``),F(!1),$({type:`set_goal_prefs`,execModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(Nt,{active:A===e.id,onClick:()=>{j(e.id),F(!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))]})},G=(e.wizard?.active??!1)&&d;if(G)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${G?`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`)}),sm(se([`host:goal-clear`]),{...ce,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),onClick:()=>{$({type:`clear_goal`}),B(!0)},children:(0,X.jsx)(N,{})})},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}),g&&(0,X.jsxs)(`span`,{className:`goalbar-detail`,title:p?.convId,children:[`· `,g]}),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`)}),sm(se([`host:goal-openrole`,`host:goal-clear`]),{...ce,"host:goal-openrole":h?(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarOpenExecTip`),onClick:()=>$({type:`switch_conversation`,id:h}),children:(0,X.jsx)(dt,{})}):null,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x${e.reviewing?` stopping`:``}`,title:e.reviewing?o(`goalBarStop`):o(`goalBarClear`),onClick:()=>{e.goal&&C(e.goal),$({type:`clear_goal`}),B(!1)},children:e.reviewing?(0,X.jsx)(ie,{}):(0,X.jsx)(N,{})})},a)]})});if(ne){let e=sm(se([`host:goal-pill`]),ce,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)(re,{})}),(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()}}),sm(se([`host:goal-set`,`host:goal-wizard`,`host:goal-plan`,`host:goal-lock`,`host:goal-collapse`]),ce,a)]}),(0,X.jsxs)(`div`,{className:`goalbar-opts`,children:[se([`host:goal-model`,`host:goal-execmodel`,`host:goal-rounds`]).filter(e=>e.source===`host`).map(e=>(0,X.jsx)(m.Fragment,{children:ce[e.id]},e.id)),e.history&&e.history.length>0&&(0,X.jsxs)(Mt,{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:I,onOpenChange:te,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalHistory`)}),e.history.map((e,t)=>(0,X.jsx)(Nt,{onClick:()=>{C(e.goal),te(!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 cg(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 lg=2e3;function ug(e,t,n=lg){return e.filter(e=>t-e.t<=n)}function dg(e,t=lg){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 fg(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 pg(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=fg(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=fg(n.thinking));return t}var mg=[{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 hg({chat:e,bottombarItems:t,onUiAction:n,onOpenSettings:r,onViewChange:i,onOpenGlobalSearch:a,onOpenBgTasks:o}){let s=Z(),{engine:c}=ma(),l=ha(`workspaceRoots`),u=e.state,[d,f]=(0,m.useState)(!1),p=(0,m.useRef)([]),h=u?.isStreaming??!1,g=u?.streamingMessage?pg(u.streamingMessage.content):0;if((0,m.useEffect)(()=>{if(!h){p.current=[];return}let e=Date.now(),t=p.current,n=t[t.length-1];n&&e-n.t<250||(p.current=ug([...t,{t:e,out:g}],e))},[h,g]),!u)return null;let _=u.stats,v=cg(_.tokens),y=v.hitRate*100,b=v.totalInput===0?``:v.hitRate>=.7?`ok`:v.hitRate>=.4?`mid`:`warn`,x=v.totalInput>0?`${y.toFixed(1)}%`:`—`,S=h?dg(p.current):0,C=e.ready?`ok`:e.status===`closed`?`error`:`busy`,w=e.ready?s(`connected`):e.status===`closed`?s(`reconnecting`):s(`connecting`),T=_.contextUsage,E=T.softCap??null,D=E!==null&&E>0&&E<T.contextWindow,O=D?E:T.contextWindow,k=T.tokens!==null&&O>0?Math.min(100,Math.round(T.tokens/O*100)):null,A=T.tokens!==null&&k!==null?`${gg(T.tokens)} / ${gg(O)}`:`—`,j=k===null?``:k>=80?`warn`:k>=50?`mid`:`ok`,ee=u.queue.steering.length+u.queue.followUp.length,M={"host:conn":(0,X.jsxs)(`span`,{className:`status-item status-conn ${C}`,title:w,children:[(0,X.jsx)(`span`,{className:`status-dot ${C}`}),(0,X.jsx)(`span`,{className:`status-conn-label`,children:w})]}),"host:engine":c===`pi`?null:(0,X.jsx)(`span`,{className:`status-item engine-badge engine-${c}`,title:`${s(`engineBadge`)}: ${c}`,children:c===`dsh`?`DSH`:c}),"host:ctx":(()=>{let e=D?`${s(`contextUsage`)}: ${gg(T.tokens??0)} / ${gg(E)} (${s(`softCapMarker`)}, max ${gg(T.contextWindow)})`:E!==null&&E>0?`${s(`contextUsage`)} · ${s(`softCapMarker`)}: ${gg(E)}`:s(`contextUsage`);return(0,X.jsxs)(`span`,{className:`status-item status-ctx`,title:e,children:[(0,X.jsx)(`span`,{className:`ctx-label`,children:s(`context`)}),(0,X.jsx)(`span`,{className:`ctx-bar ${j}`,children:k!==null&&(0,X.jsx)(`span`,{className:`ctx-bar-fill`,style:{width:`${Math.min(k,100)}%`}})}),A]})})(),"host:cost":(0,X.jsxs)(`span`,{className:`status-item status-cost`,title:s(`cumulativeCost`),children:[`$`,_g(_.cost)]}),"host:cache":(0,X.jsxs)(`span`,{className:`status-item status-cache`,title:s(`cacheHitTip`,{read:gg(v.read),write:gg(v.write),miss:gg(v.miss),input:gg(v.totalInput)}),children:[(0,X.jsx)(`span`,{className:`status-cache-label`,children:s(`cacheHit`)}),(0,X.jsx)(`b`,{className:`cache-pct ${b}`,children:x})]}),"host:msg-count":(0,X.jsxs)(`span`,{className:`status-item`,title:s(`sessionMessages`),children:[s(`messages`),` `,_.totalMessages]}),"host:plugin-status":e.statuses.length>0?(0,X.jsx)(`span`,{className:`status-item ext-status`,title:s(`pluginStatus`),children:e.statuses.map(e=>e.text).join(` · `)}):null,"host:working":u.isStreaming?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`status-item working`,children:[(0,X.jsx)(`span`,{className:`working-spin`}),s(`working`),ee>0&&(0,X.jsxs)(`span`,{className:`status-queue`,children:[`⏳ `,ee,` `,s(`queued`)]})]}),(0,X.jsxs)(`span`,{className:`status-item status-rate`,title:s(`rateTip`),children:[(0,X.jsx)(`span`,{className:`working-spin rate-spin`}),S>0?`${Math.round(S)}${s(`tps`)}`:`…`]})]}):null,"host:status-delegate":u?.delegateMode?(0,X.jsxs)(`span`,{className:`status-item delegate-badge`,title:u.delegateConvId?s(`delegateModeOpenTip`):s(`delegateModeBadgeTip`),children:[`🔎 `,s(`delegateModeBadge`),u.delegateConvId?(0,X.jsx)(`button`,{type:`button`,className:`delegate-badge-open`,title:s(`delegateModeOpenTip`),onClick:()=>$({type:`switch_conversation`,id:u.delegateConvId}),children:`↗`}):null]}):null,"host:host-metrics":(()=>{let t=e.hostMetrics;if(!t)return null;let n=t.cpuPercent===null||!Number.isFinite(t.cpuPercent)?`—`:`${Math.round(t.cpuPercent)}%`,r=Number.isFinite(t.memoryPercent)?`${Math.round(t.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`status-item status-host-metrics`,title:`${s(`hostResourcesTip`)}\n${s(`hostProcessor`)}: ${n} · ${s(`hostMemory`)}: ${r}`,children:[s(`hostProcessor`),` `,n,` · `,s(`hostMemory`),` `,r]})})(),"host:cwd":d?(0,X.jsx)(Ea,{currentCwd:u.cwd,pathCompletions:e.pathCompletions,workspaceRoots:l,onClose:()=>f(!1),onSelectDirectory:e=>{e&&e!==u.cwd&&$({type:`set_cwd`,path:e}),f(!1)},mode:`folder`}):(0,X.jsxs)(`button`,{type:`button`,className:`status-item status-cwd`,title:s(`cwdTip`,{path:u.cwd}),onClick:()=>f(!0),children:[`📁 `,u.cwd]}),"host:new-chat":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`newChat`),onClick:()=>{i?.(`chat`),$({type:`new_chat`}),Qn()},children:[(0,X.jsx)(le,{}),` `,s(`newChat`)]}),"host:settings":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`settings`),onClick:()=>r?.(),children:[(0,X.jsx)(H,{}),` `,s(`settings`)]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`searchGlobal`),onClick:()=>a?.(),children:[(0,X.jsx)(W,{}),` `,s(`searchGlobal`)]}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`bgTasks`),onClick:()=>o?.(),children:[(0,X.jsx)(Te,{}),` `,s(`bgTasks`),e.bgServers.length>0&&(0,X.jsx)(`span`,{className:`status-badge`,children:e.bgServers.length})]}),"host:chat":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`chat`),onClick:()=>i?.(`chat`),children:[(0,X.jsx)(ve,{}),` `,s(`chat`)]}),"host:terminal":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`terminal`),onClick:()=>i?.(`terminal`),children:[(0,X.jsx)(ne,{}),` `,s(`terminal`)]}),"host:git":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`scmTab`),onClick:()=>i?.(`git`),children:[(0,X.jsx)(je,{}),` `,s(`scmTab`)]}),"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`pluginMenuTitle`),onClick:()=>r?.(),children:[(0,X.jsx)(st,{}),` `,s(`pluginMenuTitle`)]})},N=(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}})},o=()=>{let e=new Set(i?.hidden??[]);e.add(n),$({type:`set_settings`,uiLayout:{...i,hidden:[...e]}})},c=[{id:`host:move-top`,slot:`contextmenu.topbar`,source:`host`,label:s(`moveToTop`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:s(`moveToLeft`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:s(`moveToRight`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:s(`uiLayoutRestore`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}];Wi({x:t.clientX,y:t.clientY,slot:`contextmenu.topbar`,target:{id:n,label:r},entries:c,onHostAction:e=>{e.id===`host:move-top`?a(`topbar.primary`):e.id===`host:move-left`?a(`sidebar.left`):e.id===`host:move-right`?a(`sidebar.right`):e.id===`host:hide-item`&&o()}})},P=t?t.map(e=>({id:e.id,entry:e,fallbackAlign:`start`})):mg.map(({id:e,align:t})=>({id:e,entry:null,fallbackAlign:t})),F=[],I=[],L=[];for(let{id:e,entry:t,fallbackAlign:r}of P){if(t?.hidden)continue;let i=null;if(e.startsWith(`host:`)?i=M[e]:t&&(i=t.kind===`select`&&t.options?.length?(0,X.jsx)(`select`,{className:`status-select`,title:t.hint??t.label,"aria-label":t.label,value:t.options.some(e=>e.value===t.value)?t.value:t.options[0].value,onChange:e=>n?.(t,e.target.value),children:t.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:t.hint??t.label,onClick:()=>n?.(t),children:[t.icon?`${t.icon} `:``,t.label,t.badge?(0,X.jsx)(`span`,{className:`status-badge`,children:t.badge}):null]})),!i)continue;let a=(0,X.jsx)(`span`,{className:`status-item-wrap`,onContextMenu:n=>N(n,e,t?.label??e),children:i},e),o=t?.align??r;o===`end`?L.push({key:e,node:a}):o===`center`?I.push({key:e,node:a}):F.push({key:e,node:a})}let te=e=>e.map((e,t)=>(0,X.jsxs)(m.Fragment,{children:[t>0&&(0,X.jsx)(`span`,{className:`status-sep`,children:`·`}),e.node]},e.key));return(0,X.jsxs)(`footer`,{className:`statusbar`,children:[(0,X.jsx)(`div`,{className:`statusbar-left`,children:te(F)}),I.length>0&&(0,X.jsx)(`div`,{className:`statusbar-center`,children:te(I)}),(0,X.jsx)(`div`,{className:`statusbar-right`,children:te(L)})]})}function gg(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function _g(e){return e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}function vg({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:h}=wn(),[g,_]=(0,m.useState)(!1),v=(0,m.useRef)(null),y=n.settings?.uiLayout,b=y?.sideDockFloat?` side-dock-float`:``,x=(t,n)=>{t.preventDefault(),t.stopPropagation();let r=e=>{let t={...y?.slots,[n.id]:e};$({type:`set_settings`,uiLayout:{...y,slots:t}})},i=()=>{let e=new Set(y?.hidden??[]);e.add(n.id),$({type:`set_settings`,uiLayout:{...y,hidden:[...e]}})},a=[{id:`host:move-top`,slot:`contextmenu.topbar`,source:`host`,label:h(`moveToTop`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:h(`moveToBottom`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:h(`moveToLeft`),kind:`action`,order:30,align:`start`,hidden:e===`left`,userOverrides:[],arrangedBy:[]},{id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:h(`moveToRight`),kind:`action`,order:40,align:`start`,hidden:e===`right`,userOverrides:[],arrangedBy:[]},{id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:h(`uiLayoutRestore`),kind:`action`,order:50,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},...u??[]];Wi({x:t.clientX,y:t.clientY,slot:`contextmenu.topbar`,target:{id:n.id,label:n.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()}})},S=e=>{switch(e.id){case`host:new-chat`:i(`chat`),$({type:`new_chat`}),Qn();break;case`host:new-ephemeral-chat`:i(`chat`),$({type:`new_chat`,ephemeral:!0}),Qn();break;case`host:chat`:i(`chat`);break;case`host:terminal`:i(`terminal`);break;case`host:git`:i(`git`);break;case`host:open-project`:d?.();break;case`host:history`:a(`left`);break;case`host:files`:a(`right`);break;case`host:search`:c();break;case`host:tasks`:s();break;case`host:settings`:o();break;case`host:plugins`:o(`plugins`);break;case`host:sound`:p?.();break;case`host:theme`:f?.();break;case`host:update`:$({type:`check_update`}),$({type:`check_updates_all`});break;case`host:github`:window.open(`https://github.com/xing-shuyin/pi-web-ui`,`_blank`,`noreferrer,noopener`);break;default:e.view?i(e.view):l?.(e)}},C=e=>{switch(e.id){case`host:brand`:return(0,X.jsx)(`span`,{className:`side-dock-brand`,children:`π`});case`host:open-project`:return(0,X.jsx)(Ne,{});case`host:history`:return(0,X.jsx)(K,{});case`host:files`:return(0,X.jsx)(Me,{});case`host:new-chat`:return(0,X.jsx)(le,{});case`host:new-ephemeral-chat`:return(0,X.jsx)(yt,{});case`host:chat`:return(0,X.jsx)(ve,{});case`host:terminal`:return(0,X.jsx)(ne,{});case`host:git`:return(0,X.jsx)(je,{});case`host:plugins`:return(0,X.jsx)(st,{});case`host:search`:return(0,X.jsx)(W,{});case`host:browser`:return(0,X.jsx)(ke,{});case`host:tasks`:return(0,X.jsx)(Te,{});case`host:settings`:return(0,X.jsx)(H,{});case`host:sound`:return(0,X.jsx)(P,{});case`host:language`:return(0,X.jsx)(ke,{});case`host:theme`:return(0,X.jsx)(B,{});case`host:update`:return(0,X.jsx)(ze,{});case`host:github`:return(0,X.jsx)(Ae,{});case`host:conn`:return(0,X.jsx)(`span`,{className:`status-dot ok`});case`host:engine`:return(0,X.jsx)(Ue,{});case`host:ctx`:return(0,X.jsx)(vt,{});case`host:cost`:return(0,X.jsx)(`span`,{className:`side-dock-char`,children:`$`});case`host:cache`:return(0,X.jsx)(qe,{});case`host:msg-count`:return(0,X.jsx)(`span`,{className:`side-dock-char`,children:`#`});case`host:cwd`:return(0,X.jsx)(Me,{});default:return e.iconSvg||e.icon?(0,X.jsx)(ni,{icon:e.icon,iconSvg:e.iconSvg}):(0,X.jsx)(ht,{})}},w=t.filter(e=>!e.hidden);return w.length===0?null:g?(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":`${h(`sideDockExpand`)} (${w.length})`,onClick:()=>_(!1),"aria-label":h(`sideDockExpand`),children:e===`left`?(0,X.jsx)(tt,{}):(0,X.jsx)(nt,{})})}):(0,X.jsxs)(`div`,{ref:v,className:`side-dock side-dock-${e}${b}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`side-dock-btn side-dock-collapse-btn`,"data-tip":h(`sideDockCollapse`),onClick:()=>_(!0),"aria-label":h(`sideDockCollapse`),children:e===`left`?(0,X.jsx)(nt,{}):(0,X.jsx)(tt,{})}),(0,X.jsx)(`div`,{className:`side-dock-items`,children:w.map(e=>{let t=e.id===`host:chat`&&r===`chat`||e.id===`host:terminal`&&r===`terminal`||e.id===`host:git`&&r===`git`||e.view&&r===e.view;return(0,X.jsxs)(`button`,{type:`button`,className:`side-dock-btn${t?` active`:``}`,"data-tip":e.hint??e.label,onClick:()=>S(e),onContextMenu:t=>x(t,e),"aria-label":e.label,children:[C(e),e.id===`host:tasks`&&n.bgServers.length>0&&(0,X.jsx)(`span`,{className:`side-dock-badge`,children:n.bgServers.length})]},e.id)})})]})}function yg({dialog:e}){let t=Z(),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(0),o=t=>{$({type:`dialog_response`,id:e.id,value:t})};(0,m.useEffect)(()=>{r(``),a(0)},[e.id]),At(()=>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)(Ku,{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)(Ku,{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 bg=150;function xg({anchorRef:e,enabled:t=!0,className:n,children:r}){let i=(0,m.useRef)(null),a=(0,m.useRef)(null),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)({left:0,top:0}),u=(0,m.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},[]),d=(0,m.useCallback)(()=>{u(),a.current=setTimeout(()=>s(!1),bg)},[u]);return(0,m.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,m.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,m.useLayoutEffect)(()=>{if(!o)return;let t=i.current,n=e.current;if(!t||!n)return;let r=Yc(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,m.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,k.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}function Sg({question:e,owner:t,conversationTitle:n}){let r=Z(),i=e.conversationTitle||n,[a,o]=(0,m.useState)({}),[s,c]=(0,m.useState)({}),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(0),[p,h]=(0,m.useState)(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);(0,m.useEffect)(()=>{o({}),c({}),f(0),u(!1);let n=e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1;h(n),e.deadline&&n<=0&&$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},[e.id,e.deadline,t]),(0,m.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&&$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}}),r})},1e3);return()=>clearInterval(n)},[e.id,e.deadline]);let g=()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})};At(()=>{g()},!l);let _=(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))},v=e.questions.filter(e=>_(e,a)),y=v.length;(0,m.useEffect)(()=>{if(e.questions.length===0||y>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,y,t]);let b=Math.min(d,Math.max(0,y-1)),x=v[b];if(!x)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:g,children:`✕`})]}),(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-hint`,children:r(`questionNoneAvailable`)})})]});let S=(()=>{if(!x)return[];if(x.optionsMap&&x.dependsOn){let e=a[x.dependsOn.questionId]??[];for(let t of e)if(x.optionsMap[t])return x.optionsMap[t]}return x.options??[]})(),C=n=>{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}:{}})},w=(e,t)=>{o(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},T=(t,n,r)=>{if(r){w(t,n);return}let i={...a,[t]:[n]};o(i);let s=e.questions.filter(e=>_(e,i));b>=s.length-1?C(i):f(b+1)},E=()=>{b>=y-1?C(a):f(b+1)},D=t=>{let n=e.questions.find(e=>e.id===t);return S.length===0&&(n?.options?.length??0)===0||(a[t]?.length??0)>0||(s[t]??``).trim()!==``},O=S.filter(e=>(a[x.id]??[]).includes(e.label)&&e.preview).map(e=>e.preview),k=(x.header||x.question).replace(/\s+/g,` `).trim();return(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}),y>1&&(0,X.jsx)(`span`,{className:`question-progress`,children:r(`questionStep`,{cur:b+1,total:y})}),p>=0&&(0,X.jsx)(`span`,{className:`question-timer`,children:p>0?r(`questionTimeout`,{s:p}):r(`questionTimeoutExpired`)}),l&&(0,X.jsx)(`span`,{className:`question-collapsed-preview`,title:k,children:k}),(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)(et,{}):(0,X.jsx)(rt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:e=>{e.stopPropagation(),g()},children:`✕`})]})]}),!l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,children:x.header??`${r(`modelQuestion`)} ${b+1}`}),(0,X.jsx)(`div`,{className:`question-head`,children:(0,X.jsx)(Ku,{text:x.question,rawHtml:!0})}),x.detail&&(0,X.jsx)(`div`,{className:`set-hint`,children:(0,X.jsx)(Ku,{text:x.detail,rawHtml:!0})}),S.length>0&&(0,X.jsx)(`div`,{className:`set-list`,children:S.map(e=>{let t=(a[x.id]??[]).includes(e.label);return(0,X.jsx)(Cg,{label:e.label,description:e.description,mark:x.multiSelect?t?`☑ `:`☐ `:t?`● `:`○ `,active:t,onPick:()=>T(x.id,e.label,!!x.multiSelect)},e.label)})}),O.length>0&&(0,X.jsxs)(`div`,{className:`question-preview`,children:[(0,X.jsx)(`div`,{className:`question-preview-label`,children:r(`optionPreview`)}),O.map((e,t)=>(0,X.jsx)(`div`,{className:`question-preview-body`,children:(0,X.jsx)(Ku,{text:e,rawHtml:!0})},t))]}),(0,X.jsx)(`input`,{className:`set-prompt-input question-custom`,placeholder:r(`modelQuestionCustom`),value:s[x.id]??``,onChange:e=>c(t=>({...t,[x.id]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D(x.id)&&E())}})]},x.id),(0,X.jsxs)(`div`,{className:`dialog-nav`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss-inline`,onClick:g,children:r(`cancel`)}),(0,X.jsxs)(`div`,{className:`dialog-nav-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-prev`,disabled:b===0,onClick:()=>f(b-1),children:r(`previous`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-submit`,disabled:!D(x.id),onClick:E,children:b===y-1?r(`modelQuestionSubmit`):r(`next`)})]})]})]})]})}function Cg({label:e,description:t,mark:n,active:r,onPick:i}){let a=(0,m.useRef)(null);return(0,X.jsxs)(`button`,{type:`button`,ref:a,className:`set-row question-option${r?` active`:``}`,onClick:i,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[(0,X.jsx)(`span`,{className:`question-mark`,children:n}),(0,X.jsx)(Ku,{text:e,rawHtml:!0})]}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-desc`,children:(0,X.jsx)(Ku,{text:t,rawHtml:!0})}),(0,X.jsx)(xg,{anchorRef:a,enabled:Xc(),className:`question-desc-tip`,children:(0,X.jsx)(Ku,{text:t,rawHtml:!0})})]})]})}var wg=e=>`'${e.replace(/'/g,`'\\''`)}'`,Tg=`pi-web-ui:scm-sidebar-width`;function Eg(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 Dg(e){return e===null||e.trim()===``?300:Eg(Number(e))}function Og(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 kg(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>Og(e,t)))}var Ag=`scm-commit-history`;function jg(e=localStorage){try{let t=e.getItem(Ag);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Mg(e,t=localStorage){let n=e.trim();if(!n)return jg(t);let r=[n,...jg(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(Ag,JSON.stringify(r))}catch{}return r}var Ng={idx:-1,draft:``};function Pg(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:Ng,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}function Fg(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 Ig({chat:e,terminal:t,active:n,onSwitchToTerminal:r,uiScmToolbar:i,onUiAction:a}){let o=Z(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)([]),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(new Map),[g,_]=(0,m.useState)(`changes`),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[A,j]=(0,m.useState)(!1),[ee,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(!1),[F,I]=(0,m.useState)(null),[L,te]=(0,m.useState)(!1),[R,z]=(0,m.useState)(!1),[re,B]=(0,m.useState)(null),[ie,V]=(0,m.useState)(()=>Dg(localStorage.getItem(Tg))),[ae,H]=(0,m.useState)(``),[U,W]=(0,m.useState)(``),[oe,se]=(0,m.useState)(()=>jg()),ce=(0,m.useRef)(Ng),le=(0,m.useRef)(0),ue=(0,m.useRef)(-1),de=(0,m.useRef)(-1),fe=(0,m.useRef)(-1),pe=(0,m.useRef)(-1),me=(0,m.useRef)(-1),he=(0,m.useRef)(void 0),ge=(0,m.useRef)(null),_e=(0,m.useRef)([]),ve=(0,m.useRef)(ie);ve.current=ie;let K=(0,m.useRef)(null),ye=(0,m.useCallback)(e=>{try{localStorage.setItem(Tg,String(e))}catch{}},[]),be=(0,m.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=ve.current,r=K.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=Eg(n+(e.clientX-t),r),V(i)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.classList.remove(`panel-resizing`),ye(i)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),document.body.classList.add(`panel-resizing`)},[ye]),xe=(0,m.useCallback)(()=>{V(300),ye(300)},[ye]),Se=(0,m.useCallback)(e=>{if(e.reqId===ue.current){if(ue.current=-1,M(!1),I(null),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}if(e.notRepo){te(!0),c(null),u([]),h(new Map),y([]),x(null),C(``),k(null);return}te(!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),h(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){I(e.error??o(`scmQueryFailedShort`));return}let t=ge.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,P(!1),!e.ok){I(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){I(e.error??o(`scmQueryFailedShort`));return}C(e.text??``)}else if(e.reqId===me.current){if(me.current=-1,z(!1),!e.ok){B(e.error??o(`scmGenMsgFail`));return}B(null),H(e.text??``)}},[]);(0,m.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&Se(t)},[e.scmData,Se]);let Ce=(0,m.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]),we=(0,m.useCallback)((t=!1,n=!1)=>{e.ready&&e.status===`open`&&e.state?.cwd&&(he.current!==void 0&&he.current!==e.state.cwd&&(c(null),u([]),h(new Map),y([]),W(``),P(!1),pe.current=-1,x(null),C(``),k(null),D(null),B(null),z(!1),me.current=-1),he.current=e.state.cwd,I(null),Ce({type:`scm_status`},ue)&&(n||M(!0)))},[e.ready,e.state?.cwd,e.status,Ce]),Te=(0,m.useCallback)(e=>{if(D(e),x(null),ge.current=e,e.x===`?`&&e.y===`?`){k({file:e,staged:``,worktree:``,untracked:!0});return}j(!0),I(null),Ce({type:`scm_filediff`,path:e.path},de)||j(!1)},[Ce]),Ee=(0,m.useCallback)(e=>{x(e),D(null),k(null),C(``),T(!0),I(null),Ce({type:`scm_commit`,hash:e.hash},fe)||T(!1)},[Ce]),q=(0,m.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=St(),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]),J=(0,m.useCallback)(()=>{let e=ae.trim();if(!e||L)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);q(`git commit`,`git commit -m "${t}"`),se(Mg(e)),H(``),ce.current=Ng},[ae,L,q]),De=(0,m.useCallback)(()=>{let e=ae.trim();if(!e||L)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);q(`git commit`,`git add -A && git commit -m "${t}"`),se(Mg(e)),H(``),ce.current=Ng},[ae,L,q]),Oe=(0,m.useCallback)(e=>{L||q(`git add`,`git add -- ${wg(e.path)}`)},[L,q]),ke=(0,m.useCallback)(e=>{L||q(`git reset`,`git reset HEAD -- ${wg(e.path)}`)},[L,q]),Ae=(0,m.useCallback)(()=>{if(!d||L)return;let e=l.find(e=>e.name===d);if(e?.remote&&typeof e.remote==`string`){let t=d.slice(e.remote.length+1);q(`git checkout`,`git checkout -b ${t} ${d} || git checkout ${d}`)}else q(`git checkout`,`git checkout ${d}`)},[d,l,L,q]),Me=(0,m.useCallback)(()=>q(`git push`,`git push`),[q]),Ne=(0,m.useCallback)(()=>q(`git pull`,`git pull`),[q]),Y=(0,m.useCallback)(()=>{R||L||!e.ready||e.status!==`open`||(B(null),Ce({type:`scm_commitmsg`},me)?z(!0):B(o(`scmGenMsgFail`)))},[R,L,e.ready,e.status,Ce,o]),Pe=(0,m.useCallback)(()=>{Ce({type:`scm_history`},pe)||(pe.current=-1)},[Ce]);(0,m.useEffect)(()=>{n&&we()},[n,we]),(0,m.useEffect)(()=>{g===`history`&&s&&Pe()},[g,s,Pe]),(0,m.useEffect)(()=>{e.scmDirty>0&&n&&we(!1,!0)},[e.scmDirty]),(0,m.useEffect)(()=>{if(!n||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&we(!1,!0)},3e4);return()=>clearInterval(t)},[n,e.ready,e.status,we]),(0,m.useEffect)(()=>{let t=_e.current;_e.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`&&(we(!1,!0),g===`history`&&s&&Pe())},[e.terminals,n,e.ready,e.status,we,g,s,Pe]);let Fe={staged:o(`scmStaged`),unstaged:o(`scmUnstaged`),untracked:o(`scmUntracked`),both:o(`scmStagedUnstaged`)},Ie=kg(v,U),Le=e=>{let t=e.split(`
|
|
358
|
-
`);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)})})},Re=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),ze=[`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`],Be=(e,t)=>{let n=new Set(e);return Re.filter(e=>n.has(e.id)||t&&e.source!==`host`)},Ve=e=>i===void 0||!i.some(t=>t.id===e&&t.hidden),He={"host:scm-changes":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`changes`,className:g===`changes`?`active`:``,onClick:()=>{_(`changes`),I(null)},children:o(`scmChanges`)}),"host:scm-history":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`history`,className:g===`history`?`active`:``,onClick:()=>{_(`history`),I(null)},children:o(`scmHistory`)}),"host:scm-refresh":(0,X.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:o(`scmRefreshTip`),disabled:ee,onClick:()=>we(!0),children:(0,X.jsx)(G,{className:ee?`scm-spin`:``})}),"host:scm-branch":(0,X.jsxs)(`select`,{className:`scm-select`,value:d,disabled:L||l.length===0,title: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||L,title:o(`scmSwitchBranchTip`,{branch:d}),onClick:Ae,children:[(0,X.jsx)(je,{}),o(`scmSwitch`)]}),"host:scm-push":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||L,title:o(`scmPushTip`),onClick:Me,children:[(0,X.jsx)(ut,{}),o(`scmPush`)]}),"host:scm-pull":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||L,title:o(`scmPullTip`),onClick:Ne,children:[(0,X.jsx)(pt,{}),o(`scmPull`)]}),"host:scm-input":(0,X.jsx)(`input`,{className:`scm-commit-input`,value:ae,placeholder:o(`scmCommitPlaceholder`),disabled:L,title:oe.length>0?o(`scmCommitHistoryTip`):void 0,onChange:e=>{H(e.target.value),ce.current=Ng},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){J();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=Pg(oe,ce.current,ae,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),ce.current=t.state,H(t.text))}}}}),"host:scm-genmsg":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:R||L||!s||s.files.length===0,title:o(`scmGenMsgTip`),onClick:Y,children:[(0,X.jsx)(Ue,{className:R?`scm-spin`:``}),o(R?`scmGenMsgRunning`:`scmGenMsg`)]}),"host:scm-commit":(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!ae.trim()||L,title:o(`scmCommitTip`),onClick:J,children:[(0,X.jsx)(it,{}),o(`scmCommit`)]}),"host:scm-commit-all":(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!ae.trim()||L,title:o(`scmCommitAllTip`),onClick:De,children: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)(je,{}),o(`scmTitle`)]}),(0,X.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:sm(Be([`host:scm-changes`,`host:scm-history`],!1),He,a)}),sm(Be([`host:scm-refresh`],!0),He,a)]}),(0,X.jsxs)(`div`,{className:`scm-row`,children:[(0,X.jsxs)(`span`,{className:`scm-branch-current`,title:o(`scmCurrentBranch`),children:[(0,X.jsx)(je,{}),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})]}),sm(Be(ze,!1),He,a)]}),re&&(0,X.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:o(`close`),onClick:()=>B(null),children:re})]}),(0,X.jsxs)(`div`,{className:`scm-body`,ref:K,style:{"--scm-sidebar-w":`${ie}px`},children:[g===`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:U.trim()?`${Ie.length}/${v.length}`:v.length})]}),v.length>0&&!L&&(0,X.jsx)(`input`,{className:`scm-history-filter`,value:U,placeholder:o(`scmHistoryFilterPlaceholder`),title:o(`scmHistoryFilterTip`),onChange:e=>W(e.target.value)}),(0,X.jsx)(`div`,{className:`scm-history-list`,children:L?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):!s||N?(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:()=>Ee(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:L?(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=Fg(e),n=p.get(e.path);return(0,X.jsxs)(`div`,{className:`scm-file ${E?.path===e.path?`active`:``}`,title:Fe[t],onClick:()=>Te(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:be,onDoubleClick:xe}),(0,X.jsxs)(`div`,{className:`scm-diff`,children:[(0,X.jsxs)(`div`,{className:`scm-diff-header`,children:[(0,X.jsx)(`span`,{children:g===`history`?b?`${b.shortHash} ${b.subject}`:o(`scmCommitDetail`):E?E.path:o(`scmDiff`)}),(g===`history`?w:A)&&(0,X.jsx)(`span`,{className:`scm-diff-loading`,children:o(`scmLoading`)})]}),(0,X.jsx)(`div`,{className:`scm-diff-body`,children:g===`history`?(0,X.jsxs)(X.Fragment,{children:[F&&(0,X.jsx)(`div`,{className:`scm-error`,children:F}),!b&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectCommitHint`)}),b&&w&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),b&&!w&&!F&&S?Le(S):null]}):(0,X.jsxs)(X.Fragment,{children:[F&&(0,X.jsx)(`div`,{className:`scm-error`,children:F}),!E&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectFileHint`)}),E&&!O&&!F&&(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`)}),Le(O.staged)]}),O.worktree&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmUnstaged`)}),Le(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)(ne,{}),(0,X.jsx)(`span`,{children:o(`scmRunsInTerminal`)}),Ve(`host:scm-term`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:r,children:o(`scmViewTerminal`)})]})]})}function Lg({entry:e}){let t=(0,m.useRef)(null),n=Z();return(0,m.useEffect)(()=>{let r=t.current;if(!r)return;let i;try{i=e.module.mount(r,Ls(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 Rg({pluginId:e,info:t,epoch:n,failed:r}){let i=Z(),[a,o]=(0,m.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),Ds(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 zg({onAction:e}){let t=Ji(),n=(0,m.useMemo)(()=>t?ta(t.entries):[],[t]),{items:r,selectParents:i}=(0,m.useMemo)(()=>ea(n),[n]),a=(0,m.useMemo)(()=>na(r),[r]),o=(0,m.useMemo)(()=>t?Zi(t.slot,t.target):void 0,[t,t?.slot,t?.target.kind]),s=(0,m.useRef)(null),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(-1),[p,h]=(0,m.useState)(-1),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(0),b=(0,m.useRef)(-1),x=e=>{b.current=e,f(e)},S=(0,m.useMemo)(()=>p>=0?ta(r[p]?.children??[]):[],[r,p]),C=(0,m.useMemo)(()=>na(S),[S]),w=e=>{let n=r[e];if(t&&n&&!$i(n,o)){if(n.children?.length){h(e);return}T(n,t)||Gi()}},T=(t,n,r)=>t.source===`host`&&n.onHostAction?n.onHostAction(t,n.target)===!0:(e(t,n.target,r),!1),E=(0,m.useRef)(w);if((0,m.useLayoutEffect)(()=>{E.current=w}),(0,m.useEffect)(()=>{if(!t){b.current=-1,f(-1),h(-1);return}let e=ia(r,-1,1,o);b.current=e,f(e),h(-1),s.current?.focus()},[t,r,o]),(0,m.useLayoutEffect)(()=>{if(!t){u(null);return}let e=s.current;if(!e)return;let n=e.getBoundingClientRect();u(Xi(t.x,t.y,n.width,n.height,window.innerWidth,window.innerHeight))},[t,r]),(0,m.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,m.useEffect)(()=>{if(!t)return;let e=e=>s.current&&e instanceof Node&&s.current.contains(e),n=t=>{e(t.target)||Gi()},r=t=>{e(t.target)||Gi()},i=()=>Gi();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,m.useEffect)(()=>{if(!t)return;let e=e=>{let t=ia(r,b.current,e,o);b.current=t,f(t)},n=t=>{switch(t.key){case`Escape`:t.preventDefault(),Gi();return;case`Tab`:Gi();return;case`ArrowDown`:t.preventDefault(),e(1);return;case`ArrowUp`:t.preventDefault(),e(-1);return;case`ArrowRight`:r[b.current]?.children?.length&&(t.preventDefault(),h(b.current));return;case`ArrowLeft`:p>=0&&(t.preventDefault(),h(-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,m.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($i(n.parent,o))return;t&&!T(n.parent,t,n.value)&&Gi();return}$i(e,o)||T(e,t)||Gi()},O=(e,t,n)=>{let r=$i(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&&h(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${g?` 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,k.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 Bg=0,Vg=[],Hg=new Map,Ug=new Set;function Wg(){for(let e of Ug)try{e()}catch{}}function Gg(e){let t=Hg.get(e);t!==void 0&&(clearTimeout(t),Hg.delete(e))}function Kg(e){let t=e.id||`banner-${Date.now()}-${++Bg}`,n={...e,id:t,type:e.type||`info`,persistent:!!e.persistent,timeoutMs:e.timeoutMs??5e3,dismissible:e.dismissible!==!1};if(Gg(t),!n.persistent&&n.timeoutMs&&n.timeoutMs>0){let e=setTimeout(()=>{qg(t)},n.timeoutMs);Hg.set(t,e)}let r=Vg.findIndex(e=>e.id===t);if(r>=0){let e=[...Vg];e[r]=n,Vg=e}else Vg=[...Vg,n];return Wg(),t}function qg(e,t){Gg(e);let n=Vg.find(t=>t.id===e);if(n){if(Vg=Vg.filter(t=>t.id!==e),!t?.silent)try{n.onClose?.()}catch{}Wg()}}function Jg(e,t){let n=Vg.filter(e);if(n.length!==0){for(let e of n)if(Gg(e.id),!t?.silent)try{e.onClose?.()}catch{}Vg=Vg.filter(t=>!e(t)),Wg()}}function Yg(){return Vg}function Xg(e){return Ug.add(e),()=>{Ug.delete(e)}}function Zg(){return(0,m.useSyncExternalStore)(Xg,Yg,Yg)}function Qg({type:e}){switch(e){case`question`:return(0,X.jsx)(De,{className:`banner-icon banner-icon-question`});case`warning`:return(0,X.jsx)(gt,{className:`banner-icon banner-icon-warning`});case`error`:return(0,X.jsx)(_t,{className:`banner-icon banner-icon-error`});case`success`:return(0,X.jsx)(at,{className:`banner-icon banner-icon-success`});default:return(0,X.jsx)(q,{className:`banner-icon banner-icon-info`})}}var $g=(0,m.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)(Qg,{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(),qg(e.id)},"aria-label":`Close banner`,title:`关闭通知`,children:(0,X.jsx)(N,{})})]})}),e_=(0,m.memo)(function(){let e=Zg();return e.length===0?null:(0,X.jsx)(`aside`,{className:`banner-container`,"aria-label":`Notifications`,children:e.map(e=>(0,X.jsx)($g,{banner:e},e.id))})}),t_={activity:(0,X.jsx)(vt,{}),branch:(0,X.jsx)(je,{}),browser:(0,X.jsx)(ke,{}),chat:(0,X.jsx)(ve,{}),check:(0,X.jsx)(it,{}),"chevron-up":(0,X.jsx)(et,{}),clock:(0,X.jsx)(Ye,{}),code:(0,X.jsx)(Je,{}),coins:(0,X.jsx)(Be,{}),copy:(0,X.jsx)(Ke,{}),cpu:(0,X.jsx)(Ue,{}),cut:(0,X.jsx)(oe,{}),database:(0,X.jsx)(Ve,{}),dot:(0,X.jsx)(`span`,{className:`host-icon-char`,children:`●`}),download:(0,X.jsx)(ze,{}),edit:(0,X.jsx)(Re,{}),eye:(0,X.jsx)(Fe,{}),file:(0,X.jsx)(Y,{}),folder:(0,X.jsx)(Me,{}),gauge:(0,X.jsx)(vt,{}),git:(0,X.jsx)(je,{}),github:(0,X.jsx)(Ae,{}),globe:(0,X.jsx)(ke,{}),grid:(0,X.jsx)(Oe,{}),hash:(0,X.jsx)(`span`,{className:`host-icon-char`,children:`#`}),image:(0,X.jsx)(J,{}),info:(0,X.jsx)(q,{}),layers:(0,X.jsx)(Te,{}),link:(0,X.jsx)(we,{}),list:(0,X.jsx)(Ce,{}),lock:(0,X.jsx)(xe,{}),markdown:(0,X.jsx)(Pe,{}),maximize:(0,X.jsx)(be,{}),menu:(0,X.jsx)(K,{}),message:(0,X.jsx)(ve,{}),open:(0,X.jsx)(Ie,{}),paste:(0,X.jsx)(Xe,{}),pin:(0,X.jsx)(ht,{}),plus:(0,X.jsx)(le,{}),refresh:(0,X.jsx)(G,{}),save:(0,X.jsx)(se,{}),search:(0,X.jsx)(W,{}),send:(0,X.jsx)(U,{}),settings:(0,X.jsx)(H,{}),sound:(0,X.jsx)(P,{}),sun:(0,X.jsx)(B,{}),target:(0,X.jsx)(He,{}),terminal:(0,X.jsx)(ne,{}),text:(0,X.jsx)(te,{}),trash:(0,X.jsx)(R,{}),undo:(0,X.jsx)(We,{}),upload:(0,X.jsx)(I,{}),volume:(0,X.jsx)(P,{}),wrap:(0,X.jsx)(Ge,{}),x:(0,X.jsx)(N,{}),zap:(0,X.jsx)(M,{}),zoom:(0,X.jsx)(ee,{})};Object.keys(t_);function n_(e){if(e.iconSvg)return(0,X.jsx)(ni,{icon:e.icon,iconSvg:e.iconSvg});if(!e.icon)return null;let t=t_[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}var r_=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`,alignable:!0},{slot:`bottombar`,labelKey:`uiLayoutBottombar`,alignable:!0},{slot:`sidebar.left`,labelKey:`uiLayoutSidebarLeft`,alignable:!1},{slot:`sidebar.right`,labelKey:`uiLayoutSidebarRight`,alignable:!1}],i_=`__tray`,a_=[`start`,`center`,`end`];function o_(e,t=new Set){let n={},r=[],i=new Set;for(let a of r_){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 s_(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 c_(e){return(e??[]).filter(e=>!e.hidden)}function l_(e,t){let n=c_(e);return t===void 0?n:n.filter(e=>(e.align??`start`)===t)}function u_(e){return[...new Set(e)]}function d_(e,t,n){let r=e??{},i=s_(t,n.id);if(!i)return r;let a={...r};i.hidden&&(a.hidden=(r.hidden??[]).filter(e=>e!==n.id),a.shown=u_([...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=c_(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=u_([...(r.order??[]).filter(e=>!p.has(e)&&e!==n.id),...u,...f]),a}function f_(e,t){let n=e??{};return{...n,hidden:u_([...n.hidden??[],t]),shown:(n.shown??[]).filter(e=>e!==t)}}function p_({slots:e,layout:t,exclude:n,onClose:r}){let i=Z(),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(null),l=(0,m.useMemo)(()=>o_(e,n),[e,n]),u=(0,m.useRef)(null),d=(0,m.useRef)(null),f=(0,m.useRef)(l),p=(0,m.useRef)(t),h=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{f.current=l,p.current=t}),(0,m.useEffect)(()=>{h.current=null},[t]);let g=(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=h.current??p.current,r=t.slot===`__tray`?f_(n,e):d_(n,f.current,{id:e,slot:t.slot,...t.align===void 0?{}:{align:t.align},index:t.index});h.current=r,$({type:`set_settings`,uiLayout:r})};(0,m.useEffect)(()=>{if(!a)return;let e=e=>{e.preventDefault();let t=g(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]),At(()=>{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:n_(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)(N,{})})]}),(0,X.jsxs)(`div`,{className:`icon-editor-body`,children:[r_.map(e=>{let t=l.zones[e.slot]??[],n=c_(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?a_.map(n=>b(e.slot,n,n,l_(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(i_,void 0,null,l.tray)]})]})]})]})}function m_(e,t){let n=(0,m.useRef)(``);(0,m.useEffect)(()=>{let r=$m(n.current,e);n.current=r.key,r.clear&&t()},[e,t])}var h_=new Map,g_=-1;function __(e){let t=e.trim().toLowerCase();return t.startsWith(`.`)?t:`.${t}`}function v_(e){let t=e.replace(/\\/g,`/`).split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n).toLowerCase():``}function y_(e,t){g_!==t&&(g_=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=__(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));h_=n}function b_(e){return h_.get(v_(e))?.[0]??null}async function x_(e){let t=await Ns(e.plugin,g_);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 S_({provider:e,flow:t,result:n}){let r=Z(),i=t?.event,a=e.oauthName??e.name,[o,s]=(0,m.useState)(``);return(0,m.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 C_({piConfigured:e,piAgentInstalled:t,providers:n,providerOAuthFlows:r,providerOAuthResults:i,installResult:a,onClose:o}){let s=Z(),c=_a(),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(!1);(0,m.useEffect)(()=>{$({type:`list_providers`}),$({type:`list_provider_oauth_flows`})},[]),(0,m.useEffect)(()=>{e&&o()},[e,o]),(0,m.useEffect)(()=>{a&&u(!1)},[a]),(0,m.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()&&!g&&(_(!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)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ue,{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)(S_,{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=>h(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()||g||!d,onClick:y,children:s(g?`saving`:`saveAndStart`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:b,children:[(0,X.jsx)(G,{}),` `,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 w_=[`openai-completions`,`openai-responses`,`anthropic-messages`,`google-generative-ai`],T_=[{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:`反代`}],E_=[{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`}],D_=[{label:`2K`,value:`2048`},{label:`4K`,value:`4096`},{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`}],O_=()=>({id:``,name:``,reasoning:!1,input:`text`,contextWindow:``,maxTokens:``}),k_=()=>({providerId:``,name:``,api:`openai-completions`,baseUrl:``,apiKey:``,hasApiKey:!1,authHeader:!0,models:[O_()]});function A_(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:[O_()]).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 j_(e){let t={};for(let n of e.split(`
|
|
359
|
-
`)){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 M_({candidates:e,onAdopt:t,onClose:n}){let r=Z(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.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,m.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)(N,{})})]}),(0,X.jsxs)(`div`,{className:`candidate-filter-bar`,children:[(0,X.jsx)(W,{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)(M,{}),` 推理`]}),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 N_({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:h}){let g=Z(),[_,v]=(0,m.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,m.useState)(()=>e.length>0?A_(e[0]):t.length>0?null:k_()),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(0),[D,O]=(0,m.useState)(null),k=(0,m.useRef)(0),[A,j]=(0,m.useState)({}),[ee,M]=(0,m.useState)({}),[P,F]=(0,m.useState)(null),I=(0,m.useRef)(n),L=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=P;e&&n[e]!==I.current[e]&&(F(null),j(t=>({...t,[e]:``})),M(t=>({...t,[e]:``})),L.current&&clearTimeout(L.current)),I.current=n},[n,P]),(0,m.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let[te,z]=(0,m.useState)(!1),[ne,re]=(0,m.useState)(0),[B,ie]=(0,m.useState)(null),V=(0,m.useRef)(0),[ae,H]=(0,m.useState)(!1),[U,W]=(0,m.useState)(!1),[oe,se]=(0,m.useState)(0),[ce,ue]=(0,m.useState)(null),[de,fe]=(0,m.useState)([]),[pe]=(0,m.useState)(``),me=(0,m.useRef)(0),[he,ge]=(0,m.useState)(!1),[_e,ve]=(0,m.useState)(0),[K,ye]=(0,m.useState)(null),be=(0,m.useRef)(0),[xe,Se]=(0,m.useState)(null),[Ce,we]=(0,m.useState)(``),[Te,Ee]=(0,m.useState)(``),[q,J]=(0,m.useState)(``),[De,Oe]=(0,m.useState)(``),[ke,Ae]=(0,m.useState)(!1),[je,Me]=(0,m.useState)(0),[Ne,Y]=(0,m.useState)(null),Pe=(0,m.useRef)(0),[Fe,Ie]=(0,m.useState)(null),[Le,Re]=(0,m.useState)(``),[Be,Ve]=(0,m.useState)(null),[He,We]=(0,m.useState)({}),Ge=(0,m.useRef)(0),qe=(0,m.useRef)(0),[Je,Ye]=(0,m.useState)(null),Xe=(0,m.useRef)(0),Ze=(0,m.useRef)(0),Qe=e=>{if(He[e])return;let t=++Ge.current+Date.now();We(t=>({...t,[e]:!0})),$({type:`refresh_provider_models`,providerId:e,reqId:t})};(0,m.useEffect)(()=>{d&&d.reqId!==qe.current&&(qe.current=d.reqId,We({}))},[d]);let $e=e=>{if(Je)return;Ye(e.id);let t=++Xe.current+Date.now();$({type:`clone_provider`,provider:e.id,reqId:t})||Ye(null)};(0,m.useEffect)(()=>{$({type:`list_models_config`}),$({type:`list_providers`}),$({type:`list_provider_keys`}),$({type:`list_provider_oauth_flows`})},[]),(0,m.useEffect)(()=>{o&&o.reqId!==k.current&&(k.current=o.reqId,w(!1),O({ok:o.ok,latencyMs:o.latencyMs,error:o.error}))},[o]),(0,m.useEffect)(()=>{a&&a.reqId!==V.current&&(V.current=a.reqId,z(!1),a.ok&&a.models?.length?(S(a.models),ie({ok:!0,text:g(`fetchModelsOk`,{n:a.models.length})})):ie({ok:!1,text:a.error||g(`fetchModelsEmpty`)}))},[a,g]),(0,m.useEffect)(()=>{if(s&&s.reqId!==me.current){if(me.current=s.reqId,H(!1),W(!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;ue({ok:!0,text:g(`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 ue({ok:!1,text:s.error||g(`enrichModelsErr`,{msg:``})})}},[s,g]),(0,m.useEffect)(()=>{u&&u.reqId!==be.current&&(be.current=u.reqId,ge(!1),u.ok?ye({ok:!0,text:g(`refreshBuiltinOk`)}):ye({ok:!1,text:u.error||g(`refreshBuiltinFail`)}))},[u,g]),(0,m.useEffect)(()=>{f&&f.reqId!==Pe.current&&(Pe.current=f.reqId,Ae(!1),f.ok?(Y({ok:!0,text:g(`appendModelOk`)}),we(``),Ee(``),J(``),Oe(``),Se(null),$({type:`list_models_config`})):Y({ok:!1,text:f.error||g(`appendModelFail`)}))},[f,g]),(0,m.useEffect)(()=>{if(l&&l.reqId!==Ze.current&&(Ze.current=l.reqId,Ye(null),l.ok)){let e=l.configs;if(e&&e.length>1){Ie(e.map(e=>A_(e))),Re(``);return}l.config&&Ve(A_(l.config))}},[l]);let et=()=>{if(!y)return;let e=y.baseUrl.trim();if(!e){O({ok:!1,error:g(`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})},tt=()=>{if(!y)return;let e=y.baseUrl.trim();if(!e){ie({ok:!1,text:g(`fetchModelsNeedBaseUrl`)});return}if(te)return;z(!0),ie(null);let t=ne+1;re(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||ae)return;let e=y.models.map(e=>e.id.trim()).filter(Boolean);if(e.length===0){ue({ok:!1,text:g(`enrichModelsNeedIds`)});return}H(!0),W(!1),ue(null),fe([]);let t=oe+1;se(t),$({type:`enrich_models`,reqId:t,ids:e,hints:j_(pe)})},at=()=>{ae&&!U&&(W(!0),$({type:`abort_enrich_models`,reqId:oe}))},ot=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:[O_()]})),O(null),ie(null)},st=()=>{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}}),h()},ct=(e,t)=>{y&&b({...y,models:y.models.map((n,r)=>r===e?{...n,...t}:n)})},lt=()=>{y&&b({...y,models:[...y.models,O_()]})},ut=e=>{y&&b({...y,models:y.models.filter((t,n)=>n!==e)})},dt=e=>{let t=(A[e.id]??``).trim();t&&!P&&(F(e.id),$({type:`add_provider_key`,provider:e.id,apiKey:t,name:(ee[e.id]??``).trim()||void 0}),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{F(t=>t===e.id?null:t)},1e4))},ft=(e,t)=>{$({type:`activate_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`})},pt=(e,t)=>{window.confirm(g(`removeKeyConfirm`))&&($({type:`remove_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`}))},mt=e=>{window.confirm(g(`clearKeyConfirm`,{id:e}))&&$({type:`clear_provider_api_key`,provider:e})},ht=t=>{if(window.confirm(g(`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(A_(n[0]))):(v({type:`custom`,id:``}),b(k_()))}},gt=e=>{let t=Ce.trim();if(!t||ke)return;Ae(!0),Y(null);let n=je+1;Me(n),$({type:`append_builtin_model`,providerId:e,model:{id:t,...Te.trim()?{name:Te.trim()}:{},...q?{api:q}:{},...De.trim()?{baseUrl:De.trim()}:{}},reqId:n})};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:h,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)(Ue,{})}),(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:g(`refreshBuiltinHint`),disabled:he,onClick:()=>{if(he)return;ge(!0),ye(null);let e=_e+1;ve(e),$({type:`refresh_builtin_models`,reqId:e})},children:[(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{children:he?g(`refreshBuiltinBusy`):`刷新官方目录`})]}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn`,title:g(`reloadModelsHint`),onClick:()=>$({type:`reload_models_config`}),children:(0,X.jsx)(G,{})}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn close-btn`,"aria-label":g(`close`),onClick:h,children:(0,X.jsx)(N,{})})]})]}),K&&(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 ${K.ok?`ok`:`err`}`,children:K.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(k_()),O(null),ie(null)},children:[(0,X.jsx)(le,{}),` 添加自定义服务商`]})}),(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(A_(e)),O(null),ie(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:g(`refreshModels`),disabled:He[y.providerId],onClick:()=>Qe(y.providerId),children:(0,X.jsx)(G,{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:et,children:[(0,X.jsx)(vt,{}),` `,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:st,children:g(`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:T_.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`quick-chip`,onClick:()=>ot(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:[g(`providerId`),` `,(0,X.jsx)(`em`,{children:g(`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:g(`displayName`)}),(0,X.jsx)(`input`,{type:`text`,value:y.name,onChange:e=>b({...y,name:e.target.value}),placeholder:g(`displayNamePh`)})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:g(`apiType`)}),(0,X.jsx)(`select`,{value:y.api,onChange:e=>b({...y,api:e.target.value}),children:w_.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:g(`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:g(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:y.apiKey,onChange:e=>b({...y,apiKey:e.target.value}),placeholder:y.hasApiKey?g(`apiKeySavedHint`):g(`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:g(`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:[B&&(0,X.jsx)(`span`,{className:`fetch-msg ${B.ok?`ok`:`err`}`,title:B.text,children:B.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:te||!y.baseUrl.trim(),title:g(`fetchModelsHint`),onClick:tt,children:[(0,X.jsx)(ze,{}),` `,te?g(`fetchingModels`):`自动获取并采纳模型`]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:ae,title:g(`enrichModelsHint`),onClick:rt,children:[(0,X.jsx)(ze,{}),` `,g(ae?`enrichingModels`:`enrichModels`)]}),ae&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:U,title:g(`enrichModelsAbort`),onClick:at,style:{color:`var(--red)`},children:[(0,X.jsx)(N,{}),` `,g(U?`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)(Ue,{}),` ID`]}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field mono`,value:e.id,onChange:e=>ct(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=>ct(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:()=>ct(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:()=>ct(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:g(`delete`),onClick:()=>ut(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:E_.some(t=>t.value===e.contextWindow)?e.contextWindow:`custom`,onChange:e=>{e.target.value!==`custom`&&ct(t,{contextWindow:e.target.value})},children:[E_.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:`自定义…`})]}),(!E_.some(t=>t.value===e.contextWindow)||e.contextWindow===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.contextWindow,onChange:e=>ct(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:D_.some(t=>t.value===e.maxTokens)?e.maxTokens:`custom`,onChange:e=>{e.target.value!==`custom`&&ct(t,{maxTokens:e.target.value})},children:[D_.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:`自定义…`})]}),(!D_.some(t=>t.value===e.maxTokens)||e.maxTokens===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.maxTokens,onChange:e=>ct(t,{maxTokens:e.target.value}),placeholder:`如 8192`})]}),(0,X.jsx)(`div`,{className:`matrix-spec-quick-pills`,children:[`32K`,`128K`,`200K`].map(n=>{let r=E_.find(e=>e.label===n);return r?(0,X.jsx)(`button`,{type:`button`,className:`param-pill ${e.contextWindow===r.value?`active`:``}`,onClick:()=>ct(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:lt,children:[(0,X.jsx)(le,{}),` 添加模型行`]})]})]})]}),_.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:g(`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:g(`cloneProvider`),disabled:Je===e.id,onClick:()=>$e(e),children:[(0,X.jsx)(Ke,{}),` `,g(`cloneProvider`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{Se(xe===e.id?null:e.id),Y(null)},children:[(0,X.jsx)(le,{}),` `,g(`appendModel`)]}),e.supportsApiKey&&e.source===`stored`&&!e.usingOAuth&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm danger`,title:g(`clearKeyTitle`),onClick:()=>mt(e.id),children:[(0,X.jsx)(R,{}),` `,g(`clearKey`)]})]})]}),e.supportsOAuth&&(0,X.jsx)(S_,{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:g(`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:g(`activateKey`),onClick:()=>ft(e.id,t.name),children:(0,X.jsx)(it,{})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:g(`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:g(`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:g(`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()||P===e.id,onClick:()=>dt(e),children:[(0,X.jsx)(le,{}),` `,P===e.id?g(`savingKey`):g(`addKey`)]})]})]}),xe===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:Ce,onChange:e=>we(e.target.value)}),(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`显示名称 (选填)`,value:Te,onChange:e=>Ee(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!Ce.trim()||ke,onClick:()=>gt(e.id),children:[(0,X.jsx)(le,{}),` 提交追加`]})]}),Ne&&(0,X.jsx)(`span`,{style:{fontSize:12,color:Ne.ok?`var(--green)`:`var(--red)`,marginTop:6},children:Ne.text})]})]})})()]})]}),x&&(0,X.jsx)(M_,{candidates:x,onAdopt:nt,onClose:()=>S(null)})]})})}function P_(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 Bh)i(e);let a=typeof n==`string`?n:n==null?``:String(n);return a&&i(a),r}function F_({plugin:e,models:t=[]}){let n=Z(),r=e.settingsSchema??[],[i,a]=(0,m.useState)(()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);return t}),[o,s]=(0,m.useState)(!1);if(r.length===0)return null;let c=(e,t)=>a(n=>({...n,[e]:t})),l=e=>P_(e,t,i[e.key]).map(r=>{if(r===``)return{value:``,label:n(`pluginSettingsInherit`)};if(e.optionsFrom===`thinkingLevels`&&Bh.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 I_=[{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 L_(e){return{id:``,name:``,description:``,cwd:e,kind:`cron`,cron:`0 9 * * *`,preset:`0 9 * * *`,intervalMinutes:`60`,prompt:``,model:``,thinkingLevel:``,catchUp:!1}}function R_(e){let t=e.kind===`cron`&&I_.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 z_(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=I_.find(t=>t.value===e.spec);return n?t(n.key):e.spec}function B_(e){if(!e)return``;try{return new Date(e).toLocaleString()}catch{return String(e)}}function V_({tasks:e,cwd:t,models:n}){let r=Z(),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(new Set);(0,m.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)(Ye,{className:`set-section-icon`}),r(`settingsScheduler`),(0,X.jsx)(Zc,{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(L_(t)),s(!0)},children:[(0,X.jsx)(le,{}),` `,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:z_(e,r)})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsxs)(`span`,{children:[r(`schedulerNextFire`),`: `,e.nextFire?B_(e.nextFire):`—`]}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsxs)(`span`,{children:[r(`schedulerLastRun`),`:`,` `,e.lastRun?(0,X.jsxs)(X.Fragment,{children:[B_(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:[B_(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)(ue,{}),` `,r(`schedulerRunNow`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerEdit`),onClick:()=>{a(R_(e)),s(!1)},children:[(0,X.jsx)(Le,{}),` `,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)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ye,{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:[I_.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)(Zc,{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`)}),Bh.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)(Zc,{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 H_=`pi-web-sounds`,U_={enabled:!0,question:!0,done:!0,start:!1,error:!0,approval:!0,volume:100};function W_(){try{let e=localStorage.getItem(H_);if(!e)return{...U_};let t=JSON.parse(e),n={...U_,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`,`approval`])typeof n[e]!=`boolean`&&(n[e]=U_[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?U_.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...U_}}}function G_(e){try{localStorage.setItem(H_,JSON.stringify(e))}catch{}}var K_=null;function q_(){try{if(!K_){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;K_=new e}return K_.state===`suspended`&&K_.resume(),K_}catch{return null}}var J_={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 Y_(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 X_(e,t=W_()){if(!t.enabled||!t[e])return;let n=q_();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of J_[e])Y_(n,t,r)}function Z_(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 Q_(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 $_=`pi-web-ui:wide-chat`,ev={wide:!1};function tv(e){if(!e||typeof e!=`object`)return{...ev};let t=e;return{wide:typeof t.wide==`boolean`?t.wide:ev.wide}}function nv(){try{let e=localStorage.getItem($_);return e?tv(JSON.parse(e)):{...ev}}catch{return{...ev}}}function rv(e){let t=tv(e);try{localStorage.setItem($_,JSON.stringify(t))}catch{}iv=t;for(let e of av)e()}var iv=null,av=new Set;function ov(e){return av.add(e),()=>{av.delete(e)}}function sv(){return iv||=nv(),iv.wide}function cv(){return(0,m.useSyncExternalStore)(ov,sv)}var lv=`pi-web-ui:project-title`,uv={projectName:!0};function dv(e){if(!e||typeof e!=`object`)return{...uv};let t=e;return{projectName:typeof t.projectName==`boolean`?t.projectName:uv.projectName}}function fv(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``:``}function pv(){try{let e=localStorage.getItem(lv);return e?dv(JSON.parse(e)):{...uv}}catch{return{...uv}}}function mv(e){let t=dv(e);try{localStorage.setItem(lv,JSON.stringify(t))}catch{}hv=t;for(let e of gv)e()}var hv=null,gv=new Set;function _v(e){return gv.add(e),()=>{gv.delete(e)}}function vv(){return hv||=pv(),hv.projectName}function yv(){return(0,m.useSyncExternalStore)(_v,vv)}var bv=`pi-web-ui:wallpaper`,xv=`has-wallpaper`,Sv={url:``,dim:78,blur:0},Cv=2e3,wv=28e5;function Tv(e){if(typeof e!=`string`)return``;let t=e.trim();if(!t)return``;let n=t.toLowerCase().startsWith(`data:image/`)?wv:Cv;return t.length>n?``:/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith(`/`)&&!t.startsWith(`//`)?t:``}var Ev=(e,t,n,r)=>typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)));function Dv(e){if(!e||typeof e!=`object`)return{...Sv};let t=e;return{url:Tv(t.url),dim:Ev(t.dim,0,95,Sv.dim),blur:Ev(t.blur,0,24,Sv.blur)}}function Ov(){try{let e=localStorage.getItem(bv);return e?Dv(JSON.parse(e)):{...Sv}}catch{return{...Sv}}}function kv(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/[\r\n]/g,``)}async function Av(e){let t=await hf(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function jv(){let e=Nv??Ov(),t=document.documentElement;e.url?(t.style.setProperty(`--bg-image`,`url("${kv(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(xv,e.url!==``||n!==``&&n!==`none`)}function Mv(e){let t=Dv(e);Nv=t;try{localStorage.setItem(bv,JSON.stringify(t))}catch{}for(let e of Pv)e();jv()}var Nv=null,Pv=new Set;function Fv(e){return Pv.add(e),()=>{Pv.delete(e)}}function Iv(){return Nv||=Ov(),Nv}function Lv(){return(0,m.useSyncExternalStore)(Fv,Iv)}function Rv(){let e=Lv();(0,m.useEffect)(()=>{jv()},[e]),(0,m.useEffect)(()=>{let e=()=>jv();return window.addEventListener(Ou,e),jv(),()=>window.removeEventListener(Ou,e)},[])}function zv(e,t){return e.error?`failed`:t?`disabled`:e.active===!0?`active`:`idle`}function Bv(e,t){let n={active:0,disabled:0,failed:0,idle:0};for(let r of e)n[zv(r,t.has(r.id))]+=1;return n}var Vv={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`]},Hv=[`soul`,`tools`,`guidelines`,`pi_docs`,`append`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`],Uv=[`tools`,`pi_docs`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`];function Wv(e){return Uv.includes(e)}var Gv=Hv.map(e=>`{{${e}}}`).join(`
|
|
360
|
-
|
|
361
|
-
`),Kv=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]/gu;function qv(e){if(!e)return 0;let t=e.match(Kv)?.length??0;return Math.ceil(t+(e.length-t)/4)}var Jv=br.filter(e=>e.group===`other`&&e.name!==`todo_list`),Yv=`pi-web-ui:catalog-sync-urls`,Xv=8;function Zv(){try{let e=localStorage.getItem(Yv);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim()!==``).slice(0,Xv):[]}catch{return[]}}function Qv(e){let t=e.trim();if(!t)return Zv();let n=[t,...Zv().filter(e=>e!==t)].slice(0,Xv);try{localStorage.setItem(Yv,JSON.stringify(n))}catch{}return n}function $v(e){return e===`append`?0:Wv(e)?2:1}function ey({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)(Zc,{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 ty(e){return e===`active`?`pluginPhaseActive`:e===`disabled`?`pluginPhaseDisabled`:e===`failed`?`pluginPhaseFailed`:`pluginPhaseIdle`}function ny({phase:e,label:t}){return(0,X.jsx)(`span`,{className:`inv-dot inv-dot-${e}`,title:t,"aria-label":t})}function ry({plugins:e,disabledIds:t}){let n=Z(),r=Bv(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)(ny,{phase:e,label:i[e]}),r[e]]},e))})}function iy({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)(Zc,{text:t})]}),r]})}function ay({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)(iy,{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 oy({pluginId:e}){let t=Z(),[n,r]=(0,m.useState)(`all`),i=Ks(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`,...Rs].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:()=>$(Bs(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 sy(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}var cy=1e4;function ly({chat:e,terminal:t,initialSection:n,onSwitchToTerminal:r,onClose:i,sound:a,onSoundChange:o,tts:s,onTtsChange:c}){let l=Z(),{locale:u}=wn(),d=e=>l(e),f=e.settings,[p,h]=(0,m.useState)({}),g=(0,m.useMemo)(()=>{if(!f)return null;if(Object.keys(p).length===0)return f;let e={...f};for(let[t,{value:n}]of Object.entries(p))e[t]=n;return e},[f,p]);(0,m.useEffect)(()=>{f&&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))!sy(f[r],i)&&n-a<cy&&(t[r]={value:i,at:a});return Object.keys(t).length===Object.keys(e).length?e:t})},[f]);let _=g?.approvalPolicy,{engine:v,managed:y}=ma(),b=v===`dsh`,[x,S]=(0,m.useState)(n??`prompt`),[C,w]=(0,m.useState)(`market`),T=(0,m.useRef)(null);(0,m.useEffect)(()=>{T.current?.scrollTo({top:0})},[x]);let E=(0,m.useRef)(null);(0,m.useEffect)(()=>{E.current?.querySelector(`.settings-tab.active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[x]),(0,m.useEffect)(()=>{x===`plugins`&&b&&$({type:`dsh_patches_list`})},[x,b]),(0,m.useEffect)(()=>{$({type:`get_settings`})},[e.state?.cwd,e.activeConversationId]);let[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)({}),j=(0,m.useRef)(!1),ee=(0,m.useRef)(null),L=[...Hv].sort((e,t)=>$v(e)-$v(t)),[te,ne]=(0,m.useState)(null),[re,B]=(0,m.useState)({}),[ie,W]=(0,m.useState)(``),[oe,se]=(0,m.useState)(`append`),ce=(0,m.useRef)(!1),[ue,de]=(0,m.useState)(``),[pe,me]=(0,m.useState)(`append`),he=(0,m.useRef)(!1),[ge,_e]=(0,m.useState)(``),[K,ye]=(0,m.useState)(`append`),be=(0,m.useRef)(!1),[xe,Se]=(0,m.useState)(``),Ce=(0,m.useRef)(!1),[we,Te]=(0,m.useState)(``),[q,J]=(0,m.useState)(null),[Oe,ke]=(0,m.useState)(!1),[Ae,Ne]=(0,m.useState)(null),[Y,Ie]=(0,m.useState)(null),[Re,Be]=(0,m.useState)(!1),[Ve,He]=(0,m.useState)(``),[We,Ge]=(0,m.useState)(null),[Ke,qe]=(0,m.useState)(null),[Je,Xe]=(0,m.useState)(null),[Ze,Qe]=(0,m.useState)(!1),[$e,tt]=(0,m.useState)(!1),nt=(0,m.useMemo)(()=>qv(g?.effectiveSystemPrompt??``),[g?.effectiveSystemPrompt]),it=(0,m.useMemo)(()=>qv(g?.toolsSchema??``),[g?.toolsSchema]),at=nt+it,ot=cv(),ct=Yd(),lt=yv(),ut=Lv(),[dt,ft]=(0,m.useState)(ut.url),pt=(0,m.useRef)(!1),ht=(0,m.useRef)(null),[_t,vt]=(0,m.useState)(!1),[yt,bt]=(0,m.useState)(!1);(0,m.useEffect)(()=>{pt.current||ft(ut.url.startsWith(`data:`)?``:ut.url)},[ut.url]);let xt=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){vt(!0),bt(!1);try{let e=await Av(t),n=e?Tv(e):``;if(!n){bt(!0);return}ft(``),Mv({...ut,url:n})}finally{vt(!1)}}},[Ct,wt]=(0,m.useState)(()=>gh()),[Tt,Et]=(0,m.useState)(()=>{try{return bh().length}catch{return 0}}),[Dt,Ot]=(0,m.useState)(!1),kt=()=>{try{Et(bh().length)}catch{Et(0)}};(0,m.useEffect)(()=>{x===`prompt-history`&&kt()},[x]),(0,m.useEffect)(()=>{if(!Dt)return;let e=window.setTimeout(()=>Ot(!1),3e3);return()=>window.clearTimeout(e)},[Dt]);let[At,jt]=(0,m.useState)(null),[Mt,Nt]=(0,m.useState)(null),[Pt,Ft]=(0,m.useState)(null),[It,Lt]=(0,m.useState)(null),[Rt,zt]=(0,m.useState)({}),[,Bt]=(0,m.useState)(0);(0,m.useEffect)(()=>Gs(()=>Bt(e=>e+1)),[]);let[Vt,Ht]=(0,m.useState)(``),[Ut,Wt]=(0,m.useState)(``),[Gt,Kt]=(0,m.useState)(``),[qt,Jt]=(0,m.useState)(``),[Yt,Zt]=(0,m.useState)(``),[Qt,$t]=(0,m.useState)(!1),[en,tn]=(0,m.useState)(!1),[nn,rn]=(0,m.useState)(!1),[an,on]=(0,m.useState)(``),[sn,cn]=(0,m.useState)(!1),[ln,un]=(0,m.useState)(!1),[dn,fn]=(0,m.useState)(null),[pn,mn]=(0,m.useState)(``),[hn,gn]=(0,m.useState)(()=>Zv()),[_n,vn]=(0,m.useState)(``),[yn,bn]=(0,m.useState)(null);(0,m.useEffect)(()=>{g&&(j.current||O(g.promptTemplate??``),A(e=>{let t={};for(let[e,n]of Object.entries(g.promptOverrides??{}))t[e]=n??``;return ee.current&&(t[ee.current]=e[ee.current]??``),t}),se(g.visionBridgePromptMode),!ce.current&&(W(oe===`append`||g.visionBridgePrompt?g.visionBridgePrompt:g.visionBridgeDefaultPrompt||``),me(g.scmCommitMsgPromptMode),he.current||de(g.scmCommitMsgPromptMode===`append`||g.scmCommitMsgPrompt?g.scmCommitMsgPrompt:g.scmCommitMsgDefaultPrompt||``),ye(g.planModePromptMode),be.current||_e(g.planModePromptMode===`append`||g.planModePrompt?g.planModePrompt:g.planModeDefaultPrompt||``),Ce.current||Se(g.reviewPrompt)))},[g,oe,pe,K]);let[xn,Sn]=(0,m.useState)(String(g?.terminalBashIdleMs??15e3));(0,m.useEffect)(()=>{Sn(String(g?.terminalBashIdleMs??15e3))},[g?.terminalBashIdleMs]);let[Cn,Tn]=(0,m.useState)(String(g?.terminalBashMaxForegroundMs??6e4));(0,m.useEffect)(()=>{Tn(String(g?.terminalBashMaxForegroundMs??6e4))},[g?.terminalBashMaxForegroundMs]);let[Dn,kn]=(0,m.useState)(String(Math.round((g?.toolWatchdogTimeoutMs??12e5)/6e4)));(0,m.useEffect)(()=>{kn(String(Math.round((g?.toolWatchdogTimeoutMs??12e5)/6e4)))},[g?.toolWatchdogTimeoutMs]);let[An,jn]=(0,m.useState)(String(g?.retryMaxAttempts??6));(0,m.useEffect)(()=>{jn(String(g?.retryMaxAttempts??6))},[g?.retryMaxAttempts]);let[Mn,Nn]=(0,m.useState)(g?.softCapTokens&&g.softCapTokens>0?Q_(g.softCapTokens):``);(0,m.useEffect)(()=>{Nn(g?.softCapTokens&&g.softCapTokens>0?Q_(g.softCapTokens):``)},[g?.softCapTokens]);let[Pn,Fn]=(0,m.useState)(``),[In,Ln]=(0,m.useState)(``),Rn=[],zn=ji(bi(e.plugins),{locale:u,t:e=>l(e),disabledPlugins:e.settings?.disabledPlugins??[],layout:e.settings?.uiLayout,diagnostics:Rn}),Bn=[];for(let t of zn[`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&&Bn.push({entry:t,plugin:n})}let Vn=e=>`plugin-page:${e}`;if((0,m.useEffect)(()=>{x.startsWith(`plugin-page:`)&&(Bn.some(e=>Vn(e.entry.id)===x)||S(`prompt`))},[x,Bn]),!g)return null;let Hn=new Set(g.disabledAgentTools??[]),Un=Hn.size,Wn=b?null:e.dshPresets?.defaultPreset??null,Gn=!!Wn&&Wn!==`standard`,Kn=Gn?new Set(Sr([...br.map(e=>e.name),`bash`,`read`,`edit`,`write`],Wn??void 0)):new Set(br.map(e=>e.name)),qn=qh(e.dshPresets?.presets.find(e=>e.id===Wn)??{id:Wn??``,trust:`system`,isDefault:!1},u,l).name,Jn=e=>Gn&&!Kn.has(e),Yn=Gn?br.filter(e=>!Kn.has(e.name)).length:0,Xn=Gn?e.plugins.flatMap(e=>e.agentTools??[]).filter(e=>!(g.disabledPluginTools??[]).includes(e.name)).length:0,Zn=e.pluginUpdates,Qn=Object.values(Zn??{}).some(e=>e.updatable&&(e.builtin??!1)),$n=Object.values(Zn??{}).some(e=>e.updatable),er=[{id:`prompt`,icon:(0,X.jsx)(Pe,{}),label:l(`settingsSystemPrompt`)},{id:`prompt-history`,icon:(0,X.jsx)(Ye,{}),label:l(`settingsPromptHistory`),count:Tt},...b?[]:[{id:`scheduler`,icon:(0,X.jsx)(Ye,{}),label:l(`settingsScheduler`),count:e.schedulerTasks.length||void 0}],...b?[{id:`question`,icon:(0,X.jsx)(De,{}),label:l(`settingsQuestionnaire`)}]:[{id:`tools`,icon:(0,X.jsx)(z,{}),label:l(`settingsTools`),count:Un+(g.disabledMarkers?.length??0)||void 0},{id:`approval-rules`,icon:(0,X.jsx)(ae,{}),label:l(`settingsApprovalRules`),count:(g.approvalRules??[]).length||void 0}],{id:`display`,icon:(0,X.jsx)(ve,{}),label:l(`settingsMessageDisplay`)},{id:`sound`,icon:(0,X.jsx)(P,{}),label:l(`settingsSoundVoice`)},{id:`quick`,icon:(0,X.jsx)(U,{}),label:l(`quickPhrases`),count:g.quickPhrases.length},{id:`skills`,icon:(0,X.jsx)(Ue,{}),label:l(`settingsSkills`),count:g.skills.length},{id:`extensions`,icon:(0,X.jsx)(fe,{}),label:l(`settingsExtensions`),count:g.extensions.length},{id:`plugins`,icon:(0,X.jsx)(st,{}),label:l(`settingsUiPlugins`),count:e.plugins.length,dot:Qn||$n},{id:`layout`,icon:(0,X.jsx)(V,{}),label:l(`uiLayoutTitle`)},{id:`review`,icon:(0,X.jsx)(M,{}),label:l(`settingsReview`),count:g.reviewSkills.length},...b?[]:[{id:`vision`,icon:(0,X.jsx)(Fe,{}),label:l(`settingsVisionBridge`)}],{id:`presets`,icon:(0,X.jsx)(V,{}),label:l(`settingsPresets`),count:g.presets.length},...b?[]:[{id:`subagent-templates`,icon:(0,X.jsx)(F,{}),label:l(`settingsSubagentTemplates`),count:g.subagentTemplates.length}],...Bn.map(e=>({id:Vn(e.entry.id),icon:e.entry.iconSvg?(0,X.jsx)(ni,{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)(st,{}),label:e.entry.label,pluginPage:{plugin:e.plugin,entry:e.entry}}))],tr=x.startsWith(`plugin-page:`)?Bn.find(e=>Vn(e.entry.id)===x)??null:null,nr=new Set(g.disabledSkills),ar=new Set(g.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})},or=()=>{if(!yn||!g)return;let e=yn.value.trim(),t=yn.index;if(bn(null),!e||e===g.quickPhrases[t])return;let n=[...g.quickPhrases];n[t]=e,Q({quickPhrases:n})},sr=e=>{let t=new Set(nr);t.has(e.name)?t.delete(e.name):t.add(e.name),Q({disabledSkills:[...t]})},cr=new Set(g.skillsFullText??[]),lr=e=>{let t=new Set(cr);t.has(e)?t.delete(e):t.add(e),Q({skillsFullText:[...t]})},ur=new Set(g.disabledPlugins??[]),dr=new Set(e.plugins.map(e=>e.id)),fr=e=>{let t=new Set(ur);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledPlugins:[...t]})},pr=e=>{let t=new Set(ar);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledExtensions:[...t]})},mr={subagent:l(`toolDescSubagent`),subagent_spawn:l(`toolDescSubagentSpawn`),subagent_get_result:l(`toolDescSubagentGetResult`),subagent_steer:l(`toolDescSubagentSteer`),subagent_list:l(`toolDescSubagentList`),subagent_stop:l(`toolDescSubagentStop`),subagent_wait_all:l(`toolDescSubagentWaitAll`),subagent_templates:l(`toolDescSubagentTemplates`)},hr={bash:l(`toolCoreBashDesc`),read:l(`toolCoreReadDesc`),edit:l(`toolCoreEditDesc`),write:l(`toolCoreWriteDesc`),powershell:l(`toolCorePowershellDesc`),ls:l(`toolCoreLsDesc`),grep:l(`toolCoreGrepDesc`),find:l(`toolCoreFindDesc`)},gr=e=>{let t=new Set(Hn);t.has(e)?t.delete(e):t.add(e),Q({disabledAgentTools:[...t]})},_r=new Set(g.disabledPluginTools??[]),vr=e=>{let t=new Set(_r);t.has(e)?t.delete(e):t.add(e),Q({disabledPluginTools:[...t]})},yr=e.plugins.map(e=>({plugin:e,tools:[...e.agentTools??[]].sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.tools.length>0),wr=g.markersEnabled??!0,Tr=new Set(g.disabledMarkers??[]),Er=e=>{let t=new Set(Tr);t.has(e)?t.delete(e):t.add(e),Q({disabledMarkers:[...t]})},Dr=(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=St(),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()},Or=e=>{jt(null),Dr(`${l(`uninstallTitle`)} ${e}`,`pi remove npm:${e}`)},kr=(e,t,n)=>{$({type:`plugin_job`,jobId:St(),action:e,id:t,...n?{source:n}:{},...e!==`uninstall`&&en?{build:!0}:{}})},Ar=t=>{let n=null;for(let r of Object.values(e.pluginJobs??{}))r.pluginId===t&&(!n||r.startedAt>=n.startedAt)&&(n=r);return n},jr=e=>e?e.problem===`already-installed`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`pluginInspectAlreadyInstalled`,{id:e.suggestedId})}):e.problem===`network`?(0,X.jsx)(`div`,{className:`set-catalog-hint`,"data-problem":e.problem,children:l(`pluginInspectNetwork`)}):e.problem===`invalid-spec`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`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:l(`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,Mr=e=>{let t=Ar(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)(G,{className:`set-job-spin`}),l(`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:l(`cancel`)})]})}return t.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[`✓ `,l(`pluginJobDone`)]}):(0,X.jsxs)(`div`,{className:`set-catalog-job error`,children:[(0,X.jsxs)(`span`,{children:[`✗ `,t.error||l(`pluginJobFailed`)]}),t.output?(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:t.output}):null]})},Nr=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`},{slot:`topbar.overflow`,labelKey:`uiLayoutTopbarOverflow`},{slot:`notice.actions`,labelKey:`uiLayoutNotice`},{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.file`,labelKey:`uiLayoutContextFile`},{slot:`contextmenu.toolcall`,labelKey:`uiLayoutContextToolcall`},{slot:`settings.pages`,labelKey:`uiLayoutSettingsPages`},{slot:`modal.dialog`,labelKey:`uiLayoutModal`},{slot:`sidebar.left`,labelKey:`uiLayoutSidebarLeft`},{slot:`sidebar.right`,labelKey:`uiLayoutSidebarRight`}],Pr=[`bottombar`,`composer.actions`,`topbar.primary`,`sidebar.left`,`sidebar.right`],Fr=[`topbar.primary`,`bottombar`,`sidebar.left`,`sidebar.right`],[Ir,Lr]=(0,m.useState)(``),Rr=e=>{let t=Nr.find(t=>t.slot===e);return t?l(t.labelKey):e},zr=e.settings?.uiLayout,Br=e=>Q({uiLayout:{...zr,...e}}),Vr=e=>{let t=new Set(zr?.hidden??[]),n=new Set(zr?.shown??[]);e.hidden?(t.delete(e.id),n.add(e.id)):(t.add(e.id),n.delete(e.id)),Br({hidden:[...t],shown:[...n]})},Hr=(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=(zr?.order??[]).filter(e=>!f.has(e));Br({order:[...p,...d]})},Ur=(e,t)=>{(t===`start`||t===`center`||t===`end`)&&Br({align:{...zr?.align,[e]:t}})},Wr=(e,t)=>{let n={...zr?.slots,[e]:t};Br({slots:n})},Gr=(e,t)=>{let n={...zr?.labels},r=t.trim().slice(0,60);r?n[e]=r:delete n[e],Br({labels:n})},Kr=e=>Q({uiLayout:Fi(zr,e)}),qr=()=>Q({uiLayout:Ii()}),Jr=e=>{Nt(null),kr(`uninstall`,e)},Yr=(e,t)=>{kr(`update`,e,t)},Xr=e=>{kr(`install`,e.id,e.source)},Zr=e=>{$({type:`plugin_catalog_remove`,id:e})},Qr=()=>{let e=Vt.trim();e&&($({type:`plugin_catalog_add`,entry:{source:e,...Ut.trim()?{id:Ut.trim()}:{},...Gt.trim()?{name:Gt.trim()}:{},...qt.trim()?{description:qt.trim()}:{},...Yt.trim()?{icon:Yt.trim()}:{}}}),Ht(``),Wt(``),Kt(``),Jt(``),Zt(``),$t(!1))},$r=e=>{let t=e.trim();if(!t)return;let n=St();fn(n),mn(t),$({type:`plugin_catalog_sync`,requestId:n,source:t,...sn?{install:!0}:{},...ln?{replace:!0}:{}})},[ei,ti]=(0,m.useState)(``);(0,m.useEffect)(()=>{let e=Vt.trim();if(!e){ti(``);return}let t=setTimeout(()=>{let t=St();ti(t),$({type:`plugin_install_inspect`,requestId:t,source:e,...Ut.trim()?{explicitId:Ut.trim()}:{}})},500);return()=>clearTimeout(t)},[Vt,Ut]);let ri=e.installInspect,ii=ri&&ri.requestId===ei&&ri.source===Vt.trim()?ri:null,ai=e.catalogSync&&e.catalogSync.requestId===dn?e.catalogSync:null;(0,m.useEffect)(()=>{ai?.ok&&pn&&gn(Qv(pn))},[ai?.requestId,ai?.ok]);let oi=e=>{let t=new Set(g.reviewSkills.filter(e=>!e.enabled).map(e=>e.name));t.has(e.name)?t.delete(e.name):t.add(e.name),Q({reviewDisabledSkills:[...t]})},si=()=>Q({promptTemplate:D}),ci=e=>{Q({promptOverrides:{[e]:k[e]??``}})},li=e=>{ee.current===e&&(ee.current=null),ne(null),A(t=>{let n={...t};return delete n[e],n}),Q({promptOverrides:{[e]:``}})},ui=e=>B(t=>({...t,[e]:!t[e]})),pi=(e,t)=>{A(n=>({...n,[e]:t})),ne(e)},mi=()=>{j.current=!1,ee.current=null,O(Gv),A({}),Q({promptTemplate:Gv,promptOverrides:{}})},hi=e=>{O(t=>t.trim()?`${t}\n\n{{${e}}}`:`{{${e}}}`)},gi=D.trim()&&D.trim()!==Gv||Object.values(k).some(e=>e.trim());return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:i,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":l(`close`),onClick:i,children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(H,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:l(`settingsTitle`)}),(0,X.jsx)(Zc,{text:l(`settingsDesc`)})]}),(0,X.jsxs)(`div`,{className:`settings-layout`,children:[(0,X.jsx)(`nav`,{className:`settings-rail`,"aria-label":l(`settingsTitle`),ref:E,children:er.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-tab":e.id,className:`settings-tab${x===e.id?` active`:``}`,"aria-current":x===e.id?`true`:void 0,title:e.hint??e.label,onClick:()=>S(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:T,children:[x===`prompt`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(M,{className:`set-section-icon`}),l(`settingsSystemPrompt`),(0,X.jsx)(Zc,{text:`${l(`promptComposeHint`)}\n${l(`promptComposeDesc`)}`})]}),(0,X.jsxs)(`div`,{className:`set-prompt-view-triggers`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":Ze,onClick:()=>Qe(e=>!e),children:[(0,X.jsx)(`span`,{children:l(`settingsViewPrompt`)}),nt>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:l(`settingsViewPromptTokens`,{n:nt.toLocaleString()})}),(0,X.jsx)(`span`,{children:Ze?`▴`:`▾`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":$e,onClick:()=>tt(e=>!e),children:[(0,X.jsx)(`span`,{children:l(`settingsViewToolsSchema`)}),it>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:l(`settingsViewPromptTokens`,{n:it.toLocaleString()})}),(0,X.jsx)(`span`,{children:$e?`▴`:`▾`})]}),at>0&&(0,X.jsx)(`span`,{className:`set-prompt-total-est`,children:l(`settingsPromptContextTotal`,{n:at.toLocaleString()})})]}),Ze&&(0,X.jsxs)(`div`,{className:`set-prompt-view`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:l(`settingsViewPrompt`)}),(0,X.jsx)(Zc,{text:l(`settingsViewPromptHint`)}),(0,X.jsx)(Ql,{text:g.effectiveSystemPrompt})]}),g.effectiveSystemPrompt?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:g.effectiveSystemPrompt}):(0,X.jsx)(`p`,{className:`set-empty`,children:l(`settingsViewPromptEmpty`)})]}),$e&&(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:l(`settingsViewToolsSchema`)}),(0,X.jsx)(Zc,{text:l(`settingsViewToolsSchemaHint`)}),(0,X.jsx)(Ql,{text:g.toolsSchema})]}),g.toolsSchema?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:g.toolsSchema}):(0,X.jsx)(`p`,{className:`set-empty`,children:l(`settingsViewToolsSchemaEmpty`)})]})}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`promptTemplateLabel`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:6,spellCheck:!1,placeholder:Gv,value:D,onFocus:()=>j.current=!0,onBlur:()=>{j.current=!1,si()},onChange:e=>O(e.target.value)}),(0,X.jsxs)(`div`,{className:`compose-toolbar`,children:[(0,X.jsx)(`span`,{className:`set-field-label set-muted`,children:l(`promptInsertTokens`)}),L.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`token-chip`,title:d(`promptTok_${e}_desc`),onClick:()=>hi(e),children:`{{${e}}}`},e))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`promptSourcesLabel`)}),L.map(e=>{let t=k[e]??``,n=g.promptSourceDefaults?.[e]??``,r=te===e,i=n.split(`
|
|
362
|
-
`).length>6||n.length>480;if(
|
|
363
|
-
`).length)),autoFocus:r,placeholder:l(`promptOverridePlaceholder`),value:t,onFocus:t=>{ee.current=e,ne(e);let r=t.currentTarget;r.value&&r.value===n&&r.setSelectionRange(r.value.length,r.value.length)},onBlur:()=>{ee.current===e&&(ee.current=null);let t=k[e]??``;if(t.trim()&&t===n){li(e);return}ci(e),t.trim()||ne(null)},onChange:t=>A(n=>({...n,[e]:t.target.value}))}),(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:l(`promptSourceRefLabel`)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`source-default-toggle`,onClick:()=>ui(e),children:re[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}),n.trim()?(0,X.jsx)(`pre`,{className:`source-default-text${i?re[e]?` expanded`:` clamped`:``}`,children:n}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)}),!t.trim()&&n.trim()&&(0,X.jsx)(`button`,{type:`button`,className:`override-seed-btn`,title:l(`promptSourceSeedTip`),onClick:()=>pi(e,n),children:l(`promptSourceSeedButton`)})]})]}):(0,X.jsx)(`div`,{className:`source-default`,title:l(`promptSourceDefaultEditHint`),role:`button`,tabIndex:0,onClick:()=>pi(e,n),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),pi(e,n))},children:n.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?re[e]?` expanded`:` clamped`:``}`,children:n}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ui(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ui(e))},children:re[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)})})]},e)}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-btn`,onClick:mi,disabled:!gi,children:l(`promptResetAll`)})})]})]}),x===`prompt`&&!b&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(je,{className:`set-section-icon`}),l(`scmCommitMsgSettingsTitle`),(0,X.jsx)(Zc,{text:l(`scmCommitMsgSettingsDesc`)})]}),(0,X.jsx)(ay,{mode:pe,onModeChange:me,draft:ue,onDraftChange:de,defaultPrompt:g.scmCommitMsgDefaultPrompt,placeholder:l(`scmCommitMsgPromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({scmCommitMsgPromptMode:e,scmCommitMsgPrompt:t})},hint:l(`scmCommitMsgSettingsHint`),focusRef:he})]}),x===`prompt`&&!b&&(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`}),l(`planModePromptSettingsTitle`),(0,X.jsx)(Zc,{text:l(`planModePromptSettingsDesc`)})]}),(0,X.jsx)(ay,{mode:K,onModeChange:ye,draft:ge,onDraftChange:_e,defaultPrompt:g.planModeDefaultPrompt,placeholder:l(`planModePromptPlaceholder`),rows:8,onCommit:(e,t)=>{Q({planModePromptMode:e,planModePrompt:t})},modeLabel:l(`planModePromptMode`),hint:l(`planModePromptSettingsHint`),focusRef:be})]}),x===`scheduler`&&!b&&(0,X.jsx)(V_,{tasks:e.schedulerTasks,cwd:e.state?.cwd??``,models:g.subagentModels}),x===`prompt-history`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ye,{className:`set-section-icon`}),l(`settingsPromptHistory`),(0,X.jsx)(Zc,{text:l(`settingsPromptHistoryDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:l(`promptHistoryCount`,{n:String(Tt)})})]}),Tt===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`promptHistoryEmpty`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:l(`promptHistoryCount`,{n:String(Tt)})}),(0,X.jsx)(iy,{label:l(`promptHistoryMax`),tip:l(`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(Ct.maxEntries),onChange:e=>{let t=Math.floor(Number(e.target.value)||0),n={...Ct,maxEntries:t};wt(n)},onBlur:()=>{let e={...Ct};(!Number.isFinite(e.maxEntries)||e.maxEntries<1)&&(e.maxEntries=1),e.maxEntries>500&&(e.maxEntries=500),e.maxEntries=Math.floor(e.maxEntries),wt(e),_h(e),kt()}})}),(0,X.jsx)(ey,{title:l(`promptHistoryCharLimit`),tip:l(`promptHistoryCharLimitHint`),enabled:Ct.charLimitEnabled,onToggle:()=>{let e={...Ct,charLimitEnabled:!Ct.charLimitEnabled};wt(e),_h(e),kt()}}),Ct.charLimitEnabled&&(0,X.jsx)(iy,{label:l(`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:l(`promptHistoryCharLimitPlaceholder`),value:String(Ct.charLimit),onChange:e=>{let t=Math.floor(Number(e.target.value)||0);wt({...Ct,charLimit:t})},onBlur:()=>{let e=Math.floor(Number(Ct.charLimit)||0);(!Number.isFinite(e)||e<100)&&(e=100),e>2e4&&(e=2e4);let t={...Ct,charLimit:e};wt(t),_h(t),kt()}})}),(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:12},children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${Dt?` confirm`:``}`,disabled:Tt===0,title:l(Tt===0?`promptHistoryEmpty`:`promptHistoryClear`),onClick:()=>{if(!Dt){Ot(!0);return}Ch(),Ot(!1),kt()},children:[(0,X.jsx)(R,{}),` `,l(Dt?`promptHistoryClearConfirm`:`promptHistoryClear`)]}),Tt>0&&(0,X.jsx)(`span`,{className:`set-hint`,style:{marginLeft:8},children:l(`promptHistoryCount`,{n:String(Tt)})})]}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[(0,X.jsx)(mt,{style:{verticalAlign:`-2px`,marginRight:4}}),l(`settingsPromptHistoryDesc`)]})]}),x===`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`}),l(`settingsTools`)]}),Gn&&(0,X.jsxs)(`p`,{className:`set-catalog-hint warn`,children:[l(`toolsPresetBanner`,{name:qn,count:Yn+Xn}),` `,(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>$({type:`dsh_preset_default`,preset:`standard`}),children:l(`toolsBackToStandard`)})]}),(0,X.jsx)(ey,{title:l(`readDirEnabled`),tip:l(`readDirEnabledDesc`),enabled:g.readDirEnabled!==!1,onToggle:()=>Q({readDirEnabled:g.readDirEnabled===!1})}),(0,X.jsx)(ey,{title:l(`toolApprovalEnabled`),tip:l(`toolApprovalEnabledDesc`),enabled:g.toolApprovalEnabled!==!1,onToggle:()=>Q({toolApprovalEnabled:g.toolApprovalEnabled===!1}),action:b?void 0:(0,X.jsxs)(`button`,{type:`button`,className:`tpl-chip`,onClick:()=>S(`approval-rules`),title:l(`settingsApprovalRulesDesc`),children:[(0,X.jsx)(ae,{}),` `,l(`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:[l(`dshPermDefault`),(0,X.jsx)(Zc,{text:l(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:Zh.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:l(Qh(e))},e))})]}),_?.allowAll||(_?.categories.length??0)>0?(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolApprovalPolicyTitle`),(0,X.jsx)(Zc,{text:l(`toolApprovalPolicyHint`)})]}),_?.allowAll&&(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:l(`toolApprovalPolicyAllowAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,allowAll:!1}),children:l(`toolApprovalPolicyRevoke`)})]}),(_?.categories??[]).map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:u===`zh`?e.label:e.labelEn}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,categories:(_?.categories??[]).filter(t=>t.id!==e.id).map(e=>e.id)}),children:l(`toolApprovalPolicyRevoke`)})]},e.id))]}):null,(0,X.jsx)(iy,{label:l(`toolWatchdogTimeout`),tip:l(`toolWatchdogTimeoutDesc`),htmlFor:`tool-watchdog-timeout`,children:(0,X.jsx)(`input`,{id:`tool-watchdog-timeout`,className:`set-input`,type:`number`,min:0,step:1,placeholder:l(`toolWatchdogOff`),value:Dn,onChange:e=>kn(e.target.value),onBlur:()=>{let e=Dn.trim(),t=e===``?20:Math.max(0,Math.floor(Number(e)||0));kn(String(t));let n=t*6e4;n!==g.toolWatchdogTimeoutMs&&Q({toolWatchdogTimeoutMs:n})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionCore`),(0,X.jsx)(Zc,{text:l(`toolsCoreHint`)})]}),xr.map(e=>{let t=Jn(e);return(0,X.jsx)(ey,{title:e,tip:hr[e],subtitle:t?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Hn.has(e),disabled:t,onToggle:()=>gr(e)},e)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:l(`toolsSectionTerminal`)}),rr.map(e=>{let t=Jn(e);return(0,X.jsx)(ey,{title:e,tip:l(`settingsTerminalToolsDesc`),subtitle:t?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Hn.has(e),disabled:t,onToggle:()=>gr(e)},e)}),(0,X.jsx)(ey,{title:l(`terminalBashTakeover`),tip:l(`terminalBashTakeoverDesc`),enabled:g.terminalBash,onToggle:()=>Q({terminalBash:!g.terminalBash})}),g.terminalBash&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(iy,{label:l(`terminalBashIdleMs`),tip:l(`terminalBashIdleMsDesc`),htmlFor:`tb-idle-ms`,children:(0,X.jsx)(`input`,{id:`tb-idle-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:xn,onChange:e=>Sn(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(xn)||0));Sn(String(e)),e!==g.terminalBashIdleMs&&Q({terminalBashIdleMs:e})}})}),(0,X.jsx)(iy,{label:l(`terminalBashMaxForegroundMs`),tip:l(`terminalBashMaxForegroundMsDesc`),htmlFor:`tb-max-ms`,children:(0,X.jsx)(`input`,{id:`tb-max-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:Cn,onChange:e=>Tn(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(Cn)||0));Tn(String(e)),e!==g.terminalBashMaxForegroundMs&&Q({terminalBashMaxForegroundMs:e})}})})]}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionSubagent`),` `,(0,X.jsx)(Zc,{text:l(`toolsSubagentDepHint`)})]}),ir.map(e=>{let t=Jn(e);return(0,X.jsx)(ey,{title:e,tip:mr[e],subtitle:t?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Hn.has(e),disabled:t,onToggle:()=>gr(e)},e)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`settingsMarkers`),(0,X.jsx)(Zc,{text:`${l(`settingsMarkersDesc`)}\n${l(`markerRenameTip`)}`})]}),(0,X.jsx)(ey,{title:l(`markersEnabled`),tip:`${l(`markersEnabledDesc`)}\n${l(`markersOffHint`)}`,enabled:wr,onToggle:()=>Q({markersEnabled:!wr})}),wr&&(g.markers?.length??0)===0&&(0,X.jsxs)(`p`,{className:`set-empty`,children:[l(`loading`),`...`]}),wr&&g.markers&&g.markers.length>0&&g.markers.map(e=>(0,X.jsx)(ey,{title:e.name===`todo`?l(`markerGroupTodo`):e.name===`notify`?l(`markerGroupNotify`):e.name===`conv`?l(`markerGroupRename`):e.name,tip:e.guidance.join(`
|
|
364
|
-
`),enabled:e.enabled,onToggle:()=>Er(e.name)},e.name)),(0,X.jsx)(ey,{title:`todo_list`,tip:`${l(`todoListEnabledDesc`)}\n${l(`todoListOffHint`)}`,subtitle:Jn(`todo_list`)?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!Jn(`todo_list`)&&!Hn.has(`todo_list`),disabled:Jn(`todo_list`),onToggle:()=>gr(`todo_list`)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:l(`toolsSectionOther`)}),Jv.map(e=>{let t=Jn(e.name);return(0,X.jsx)(ey,{title:e.name,tip:`${d(e.descKey??e.name)}\n${d(e.offHintKey??e.name)}`,subtitle:t?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Hn.has(e.name),disabled:t,onToggle:()=>gr(e.name)},e.name)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionPlugin`),(0,X.jsx)(Zc,{text:l(`toolsPluginHint`)})]}),yr.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:e.plugins.length===0?l(`noUiPlugins`):l(`pluginToolsEmpty`)}):yr.map(e=>{let t=ur.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?` (${l(`pluginDisabledInPlugins`)})`:``]}),e.tools.map(e=>(0,X.jsx)(ey,{title:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name,tip:e.description?`${e.description}\n${l(`pluginToolOffHint`)}`:l(`pluginToolOffHint`),subtitle:t?l(`pluginToolsDisabledByPlugin`):Gn?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Gn&&!_r.has(e.name),disabled:t||Gn,onToggle:()=>!t&&!Gn&&vr(e.name)},e.name))]},e.plugin.id)})]}),x===`question`&&(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`}),l(`settingsQuestionnaire`)]}),(0,X.jsx)(ey,{title:l(`questionnaireEnabled`),tip:`${l(`questionnaireEnabledDesc`)}\n${l(`questionnaireOffHint`)}`,enabled:g.questionnaireEnabled,onToggle:()=>Q({questionnaireEnabled:!g.questionnaireEnabled})})]}),x===`display`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ve,{className:`set-section-icon`}),l(`settingsMessageDisplay`)]}),(0,X.jsx)(iy,{label:l(`softCapTokens`),tip:l(`softCapHint`),htmlFor:`soft-cap-max`,children:(0,X.jsx)(`input`,{id:`soft-cap-max`,className:`set-input`,type:`text`,placeholder:l(`softCapOff`),value:Mn,onChange:e=>Nn(e.target.value),onBlur:()=>{let e=Z_(Mn);Nn(Q_(e)),e!==(g.softCapTokens??0)&&Q({softCapTokens:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-section-title`,children:[l(`softCapByModel`),(0,X.jsx)(Zc,{text:l(`softCapByModelHint`)})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`softCapModelId`),value:Pn,maxLength:200,onChange:e=>Fn(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,placeholder:l(`softCapTokens`),value:In,onChange:e=>Ln(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&Pn.trim()&&Z_(In)>0){let e=Z_(In);Q({softCapByModel:{...g.softCapByModel,[Pn.trim()]:e}}),Fn(``),Ln(``)}}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Pn.trim()||Z_(In)<=0,onClick:()=>{let e=Pn.trim(),t=Z_(In);!e||t<=0||(Q({softCapByModel:{...g.softCapByModel,[e]:t}}),Fn(``),Ln(``))},children:[(0,X.jsx)(le,{}),` `,l(`softCapAdd`)]})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Object.entries(g.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:Q_(t),onBlur:t=>{let n=Z_(t.target.value);t.target.value=Q_(n);let r={...g.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:l(`softCapRemove`),onClick:()=>{let t={...g.softCapByModel};delete t[e],Q({softCapByModel:t})},children:[(0,X.jsx)(N,{}),` `,l(`softCapRemove`)]})]},e))}),(0,X.jsx)(iy,{label:l(`modelRetryAttempts`),tip:l(`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:An,onChange:e=>jn(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(0,Math.floor(Number(An)||0)));jn(String(e)),e!==g.retryMaxAttempts&&Q({retryMaxAttempts:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(ey,{title:l(`thinkingWrap`),tip:l(`thinkingWrapDesc`),enabled:g.thinkingWrap??!0,onToggle:()=>Q({thinkingWrap:!(g.thinkingWrap??!0)})}),(0,X.jsx)(ey,{title:l(`toolsWrap`),tip:l(`toolsWrapDesc`),enabled:g.toolsWrap??!0,onToggle:()=>Q({toolsWrap:!(g.toolsWrap??!0)})}),(0,X.jsx)(ey,{title:l(`toolImages`),tip:l(`toolImagesDesc`),enabled:g.toolImagesEnabled??!0,onToggle:()=>Q({toolImagesEnabled:!(g.toolImagesEnabled??!0)})}),(0,X.jsx)(ey,{title:l(`presentAutoOpen`),tip:l(`presentAutoOpenDesc`),enabled:ct,onToggle:()=>Ud(!ct)}),(0,X.jsx)(ey,{title:l(`parallelReminderEnabled`),tip:`${l(`parallelReminderEnabledDesc`)}\n${l(`parallelReminderOffHint`)}`,enabled:g.parallelReminderEnabled??!0,onToggle:()=>Q({parallelReminderEnabled:!(g.parallelReminderEnabled??!0)})}),(0,X.jsx)(ey,{title:l(`devNoCache`),tip:l(`devNoCacheDesc`),enabled:g.devNoCache??!0,onToggle:()=>Q({devNoCache:!(g.devNoCache??!0)})}),(0,X.jsx)(ey,{title:l(`autoReload`),tip:l(`autoReloadDesc`),enabled:g.autoReload??!0,onToggle:()=>Q({autoReload:!(g.autoReload??!0)})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsx)(ey,{title:l(`wideChat`),tip:l(`wideChatDesc`),enabled:ot,onToggle:()=>rv({wide:!ot})}),(0,X.jsx)(ey,{title:l(`projectTitle`),tip:l(`projectTitleDesc`),enabled:lt,onToggle:()=>mv({projectName:!lt})}),(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:[l(`wallpaperTitle`),(0,X.jsx)(Zc,{text:l(`wallpaperDesc`)})]}),(0,X.jsxs)(`div`,{className:`wallpaper-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input wallpaper-url`,placeholder:l(`wallpaperUrlPh`),value:dt,maxLength:2e3,spellCheck:!1,onFocus:()=>{pt.current=!0},onChange:e=>ft(e.target.value),onBlur:()=>{if(pt.current=!1,!dt.trim()&&ut.url.startsWith(`data:`)){ft(``);return}let e=Tv(dt);ft(e),e!==ut.url&&Mv({...ut,url:e})},onKeyDown:e=>{e.key===`Enter`?e.target.blur():e.key===`Escape`&&(ft(ut.url.startsWith(`data:`)?``:ut.url),e.target.blur())}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:_t,onClick:()=>ht.current?.click(),children:[(0,X.jsx)(I,{}),` `,l(`wallpaperUpload`)]}),(0,X.jsx)(`input`,{ref:ht,type:`file`,accept:`image/*`,hidden:!0,onChange:xt})]}),yt&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`wallpaperUploadFailed`)}),(0,X.jsxs)(`div`,{className:`wallpaper-sliders`,children:[(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:l(`wallpaperDim`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:95,step:1,value:ut.dim,onChange:e=>Mv({...ut,dim:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[ut.dim,`%`]})]}),(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:l(`wallpaperBlur`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:24,step:1,value:ut.blur,onChange:e=>Mv({...ut,blur:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[ut.blur,`px`]})]})]})]}),ut.url&&(0,X.jsxs)(`div`,{className:`wallpaper-current`,children:[(0,X.jsx)(`img`,{className:`wallpaper-preview`,src:ut.url,alt:``}),(0,X.jsx)(`button`,{type:`button`,className:`wallpaper-clear`,onClick:()=>{ft(``),Mv({...ut,url:``})},children:l(`wallpaperClear`)})]})]})]}),x===`sound`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(P,{className:`set-section-icon`}),l(`settingsSoundVoice`)]}),(0,X.jsx)(En,{settings:a,onChange:o,onPreview:e=>X_(e,a)}),(0,X.jsx)(On,{settings:s,onChange:c,onPreview:()=>Xt(l(`ttsPreviewLine`),{...s,enabled:!0})})]}),x===`quick`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(U,{className:`set-section-icon`}),l(`quickPhrases`),(0,X.jsx)(Zc,{text:l(`quickPhrasesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.quickPhrases.length})]}),(0,X.jsx)(ey,{title:l(`quickPhrasesEnabled`),tip:l(`quickPhrasesDesc`),enabled:g.quickPhrasesEnabled,onToggle:()=>Q({quickPhrasesEnabled:!g.quickPhrasesEnabled})}),!g.quickPhrasesEnabled&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`quickPhrasesOffHint`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`quickPhrasesPlaceholder`),value:_n,maxLength:200,onChange:e=>vn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_n.trim()&&(Q({quickPhrases:[...g.quickPhrases,_n.trim()]}),vn(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!_n.trim(),onClick:()=>{Q({quickPhrases:[...g.quickPhrases,_n.trim()]}),vn(``)},children:[(0,X.jsx)(le,{}),` `,l(`quickPhrasesAdd`)]})]}),g.quickPhrases.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`quickPhrasesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.quickPhrases.map((e,t)=>(0,X.jsx)(`div`,{className:`set-row`,children:yn?.index===t?(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`input`,{className:`set-input`,autoFocus:!0,value:yn.value,maxLength:200,placeholder:l(`quickPhrasesEditPh`),onChange:e=>bn({index:t,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?or():e.key===`Escape`&&bn(null)},onBlur:or})}):(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:l(`quickPhrasesEdit`),onClick:()=>bn({index:t,value:e}),children:(0,X.jsx)(Le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`quickPhrasesMoveUp`),disabled:t===0,onClick:()=>{let e=[...g.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:l(`quickPhrasesMoveDown`),disabled:t===g.quickPhrases.length-1,onClick:()=>{let e=[...g.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:l(`quickPhrasesDelete`),onClick:()=>Q({quickPhrases:g.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:()=>{bn(null),Q({quickPhrases:Vv[u]??Vv.en})},children:l(`quickPhrasesReset`)})})]}),x===`skills`&&(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`}),l(`settingsSkills`),(0,X.jsx)(Zc,{text:`${l(`skillFullTextLabel`)}:${l(`skillFullTextDesc`)}`}),(0,X.jsx)(`span`,{className:`set-count`,children:g.skills.length})]}),!b&&Gn&&!Cr(Wn??void 0)&&(0,X.jsx)(`p`,{className:`set-catalog-hint warn`,children:l(`skillsHiddenByPreset`,{name:qn})}),g.skills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(b?`dshSkillsNote`:`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.skills.map(e=>(0,X.jsx)(ey,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>sr(e),action:(0,X.jsx)(`button`,{type:`button`,className:`tpl-chip${cr.has(e.name)?` on`:``}`,title:l(`skillFullTextDesc`),onClick:()=>lr(e.name),children:l(`skillFullTextShort`)})},e.name))})]}),x===`extensions`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(fe,{className:`set-section-icon`}),l(`settingsExtensions`),(0,X.jsx)(`span`,{className:`set-count`,children:g.extensions.length})]}),g.extensions.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(b?`dshExtensionsNote`:`noExtensions`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.extensions.map(e=>{let t=e.id.startsWith(`npm:`)?e.id.slice(4):null;return(0,X.jsx)(ey,{title:e.name,subtitle:e.path,enabled:e.enabled,onToggle:()=>pr(e),action:t?At===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`uninstallConfirmHint`),onClick:()=>Or(t),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`uninstallHint`),onClick:()=>jt(e.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]}):void 0},e.id)})})]}),x===`layout`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(V,{className:`set-section-icon`}),l(`uiLayoutTitle`),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:qr,children:l(`uiLayoutRestoreAll`)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:l(`uiLayoutHint`)}),(0,X.jsxs)(`label`,{className:`set-toggle`,title:`sideDockFloat`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:zr?.sideDockFloat===!0,onChange:e=>Br({sideDockFloat:e.target.checked})}),(0,X.jsx)(`span`,{children:l(`uiLayoutSideDockFloat`)})]}),Rn.length>0&&(0,X.jsxs)(`details`,{className:`set-ui-diag`,open:Rn.some(e=>e.level===`error`),children:[(0,X.jsxs)(`summary`,{children:[`⚠ `,l(`uiLayoutDiagTitle`,{n:Rn.length})]}),(0,X.jsx)(`ul`,{className:`set-ui-diag-list`,children:Rn.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:l(`uiLayoutDiagHint`)})]}),(0,X.jsx)(`input`,{className:`set-ui-filter`,value:Ir,placeholder:l(`uiLayoutSearch`),"aria-label":l(`uiLayoutSearch`),onChange:e=>Lr(e.target.value)}),Nr.map(({slot:e,labelKey:t})=>{let n=(zn[e]??[]).filter(e=>(b||e.id!==`host:composer-dsh-perm`&&e.id!==`host:composer-dsh-preset`&&e.id!==`host:goal-plan`)&&!fi.has(e.id)),r=Ir.trim().toLowerCase(),i=!r&&Pr.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=di.has(t.id);return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`label`,{className:`set-toggle`,title:o?l(`uiLayoutRequired`):t.id,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!t.hidden,disabled:o,onChange:()=>Vr(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:l(`uiLayoutArranged`)}),t.movedFrom&&(0,X.jsxs)(`span`,{className:`set-ui-source`,title:t.id,children:[l(`uiLayoutMovedFrom`),`: `,Rr(t.movedFrom)]}),Fr.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:l(`uiLayoutPosition`),children:(0,X.jsxs)(`select`,{value:e,onChange:e=>Wr(t.id,e.target.value),"aria-label":l(`uiLayoutPosition`),children:[(0,X.jsx)(`option`,{value:`topbar.primary`,children:l(`uiLayoutPosTop`)}),(0,X.jsx)(`option`,{value:`bottombar`,children:l(`uiLayoutPosBottom`)}),(0,X.jsx)(`option`,{value:`sidebar.left`,children:l(`uiLayoutPosLeft`)}),(0,X.jsx)(`option`,{value:`sidebar.right`,children:l(`uiLayoutPosRight`)})]})}),Pr.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:l(`uiLayoutAlign`),children:(0,X.jsxs)(`select`,{value:t.align,onChange:e=>Ur(t.id,e.target.value),"aria-label":l(`uiLayoutAlign`),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:zr?.labels?.[t.id]??``,placeholder:l(`uiLayoutRename`),title:l(`uiLayoutRename`),"aria-label":l(`uiLayoutRename`),onBlur:e=>{e.target.value!==(zr?.labels?.[t.id]??``)&&Gr(t.id,e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.target.blur()}},`${t.id}:${zr?.labels?.[t.id]??``}`),t.userOverrides.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Kr(t.id),children:l(`uiLayoutRestore`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<=0,onClick:()=>Hr(n,i,t.id,-1),children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<0||a>=i.length-1,onClick:()=>Hr(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:l(t)}),e===`topbar.primary`&&(0,X.jsxs)(`label`,{className:`set-toggle`,title:`topbarText`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:zr?.topbarText!==!1,onChange:e=>Br({topbarText:e.target.checked})}),(0,X.jsx)(`span`,{children:l(`uiLayoutTopbarText`)})]}),n.length===0?(0,X.jsx)(`div`,{className:`set-empty`,children:l(`uiLayoutEmpty`)}):i.map(e=>(0,X.jsxs)(m.Fragment,{children:[e.align&&(0,X.jsx)(`div`,{className:`set-ui-slot-title set-ui-seg`,children:e.align}),e.items.map(t=>o(t,e.items))]},e.align??`all`))]},e)})]}),x===`plugins`&&!y&&(0,X.jsxs)(`div`,{className:`set-subtabs`,role:`tablist`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`market`,className:`set-subtab${C===`market`?` active`:``}`,onClick:()=>{w(`market`),T.current?.scrollTo({top:0})},children:[l(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`installed`,className:`set-subtab${C===`installed`?` active`:``}`,onClick:()=>{w(`installed`),T.current?.scrollTo({top:0})},children:[(0,X.jsx)(st,{}),l(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(Qn||$n)&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Me,{className:`set-section-icon`}),l(`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:l(`pluginGrantsHint`)}),e.pluginGrants.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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:l(`pluginGrantsRevoke`)})]},t))]},e.pluginId))})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ee,{className:`set-section-icon`}),l(`pluginPermsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:(e.pluginPermissions??[]).length})]}),(0,X.jsx)(`div`,{className:`set-note`,children:l(`pluginPermsHint`)}),(e.pluginPermissions??[]).length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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`?l(`pluginPermNet`):l(`pluginPermLlm`),e.session?` · ${l(`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:l(`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:l(`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??l(`pluginPermUnscoped`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:e.family}),children:l(`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}`))})]}),x===`plugins`&&y&&(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-note`,children:l(`updatesManaged`)})}),x===`plugins`&&!y&&C===`market`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(fe,{className:`set-section-icon`}),l(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`div`,{className:`set-toolbar`,children:[(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginBuildHint`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:en,onChange:e=>tn(e.target.checked)}),l(`pluginBuildSource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogSyncHint`),onClick:()=>rn(e=>!e),children:[(0,X.jsx)(G,{}),l(`pluginCatalogSync`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogAddHint`),onClick:()=>$t(e=>!e),children:[(0,X.jsx)(le,{}),l(`pluginCatalogAdd`)]})]}),nn&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`div`,{className:`set-note`,children:l(`pluginCatalogSyncHint`)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogSyncSource`),value:an,onChange:e=>on(e.target.value),onKeyDown:e=>{e.key===`Enter`&&$r(an)}}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginCatalogSyncInstall`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:sn,onChange:e=>cn(e.target.checked)}),l(`pluginCatalogSyncInstall`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginCatalogSyncReplace`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:ln,onChange:e=>un(e.target.checked)}),l(`pluginCatalogSyncReplace`)]}),hn.length>0&&(0,X.jsxs)(`div`,{className:`set-catalog-recent`,children:[(0,X.jsx)(`span`,{className:`set-catalog-recent-label`,children:l(`pluginCatalogSyncRecent`)}),hn.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-catalog-recent-item`,title:e,onClick:()=>{on(e),$r(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:!an.trim(),onClick:()=>$r(an),children:l(`pluginCatalogSyncSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>rn(!1),children:l(`cancel`)})]}),ai&&(ai.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[(0,X.jsxs)(`span`,{children:[`✓ `,l(`pluginCatalogSyncOk`,{n:ai.entryCount??0}),ai.installed?` · ${l(`pluginCatalogSyncInstalled`,{ok:ai.installed.filter(e=>e.ok).length,fail:ai.installed.filter(e=>!e.ok).length})}`:null]}),ai.installed?.some(e=>!e.ok)&&(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:ai.installed.filter(e=>!e.ok).map(e=>`${e.id}:${e.error??`?`}`).join(`
|
|
365
|
-
`)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,ai.error||l(`pluginJobFailed`)]})}))]}),Qt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogSource`),value:Vt,onChange:e=>Ht(e.target.value)}),jr(ii),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogId`),value:Ut,onChange:e=>Wt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogName`),value:Gt,onChange:e=>Kt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogIcon`),value:Yt,onChange:e=>Zt(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:l(`pluginCatalogDesc`),value:qt,onChange:e=>Jt(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!Vt.trim(),onClick:Qr,children:l(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$t(!1),children:l(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(t=>{let n=dr.has(t.id),r=e.pluginUpdates?.[t.id],i=n&&r?.updatable===!0,a=!!(Ar(t.id)&&Ar(t.id)?.phase!==`done`),o=u!==`zh`&&t.nameEn?t.nameEn:t.name,s=u!==`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)(ni,{icon:t.icon,iconSvg:t.iconSvg}),` `,o]}),n&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:l(`pluginInstalled`)}),!t.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:l(`pluginCatalogCustom`)}),i&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:r?.latestVersion?`${r?.version??``} → v${r.latestVersion}`:r?.remoteSha??``,children:[l(`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}),Mr(t.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${i?` accent`:``}`,disabled:a,title:i&&r?.latestVersion?l(`pluginUpdateAvailableDetail`,{version:`v${r.latestVersion}`}):l(`pluginUpdateHint`),onClick:()=>Yr(t.id,t.source),children:[(0,X.jsx)(G,{className:a?`set-job-spin`:``}),l(a?`pluginJobRunning`:`pluginUpdate`)]}),Mt===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:a,title:l(`pluginUninstallHint`),onClick:()=>Jr(t.id),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:a,title:l(`pluginUninstallHint`),onClick:()=>Nt(t.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]})]}):(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginInstallHint`),disabled:a,onClick:()=>Xr(t),children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(G,{className:`set-job-spin`}),l(`pluginJobRunning`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ze,{}),l(`pluginInstall`)]})}),!t.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogRemoveHint`),onClick:()=>Zr(t.id),children:(0,X.jsx)(N,{})})]})]},t.id)})})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(st,{className:`set-section-icon`}),l(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCheckUpdatesHint`),disabled:e.checkingPluginUpdates,onClick:()=>$({type:`check_plugin_updates`}),children:[(0,X.jsx)(G,{className:e.checkingPluginUpdates?`spin`:``}),e.checkingPluginUpdates?l(`checkingUpdate`):l(`pluginCheckUpdates`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(G,{}),l(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(ry,{plugins:e.plugins,disabledIds:ur}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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=!!(Ar(t.id)&&Ar(t.id)?.phase!==`done`);return(0,X.jsxs)(m.Fragment,{children:[(0,X.jsx)(ey,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ny,{phase:zv(t,ur.has(t.id)),label:d(ty(zv(t,ur.has(t.id))))}),(0,X.jsx)(ni,{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:[l(`pluginUpdateAvailableBadge`),n?.latestVersion?` v${n.latestVersion}`:``]})]}),subtitle:(t.error?`${t.id} · ${t.error}`:t.source?`${t.id} · ${t.source}`:`${t.id} · ${l(`uiPluginNoSource`)}`)+(t.permissions?.length?` · ${l(`uiPluginPerms`)}: ${t.permissions.join(`, `)}`:``),enabled:!ur.has(t.id)&&!t.error,onToggle:()=>!t.error&&fr(t),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${r?` accent`:``}`,disabled:i,title:r&&n?.latestVersion?l(`pluginUpdateAvailableDetail`,{version:`v${n.latestVersion}`}):l(`pluginUpdateHint`),onClick:()=>Yr(t.id,t.source),children:[(0,X.jsx)(G,{className:i?`set-job-spin`:``}),l(i?`pluginJobRunning`:`pluginUpdate`)]}),Mt===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:i,title:l(`pluginUninstallHint`),onClick:()=>Jr(t.id),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:i,title:l(`pluginUninstallHint`),onClick:()=>Nt(t.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]})]})},t.id),Mr(t.id),t.agentTools&&t.agentTools.length>0&&!b&&(0,X.jsxs)(`div`,{className:`set-row`,title:l(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[l(`pluginToolsSection`),` (`,t.agentTools.length,`)`,t.agentTools.some(e=>_r.has(e.name))?` · ${l(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>S(`tools`),children:[l(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{It===t.id?Lt(null):(Lt(t.id),$(zs(t.id)))},children:[(0,X.jsx)(Pe,{}),l(`pluginLogTitle`),` (`,Ks(t.id).length,`) ·`,` `,It===t.id?l(`pluginLogHide`):l(`pluginLogShow`)]}),It===t.id&&(0,X.jsx)(oy,{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:()=>Ft(Pt===t.id?null:t.id),children:[(0,X.jsx)(gt,{}),l(`pluginDiagTitle`),` (`,t.diagnostics.length,`) ·`,` `,Pt===t.id?l(`pluginDiagHide`):l(`pluginDiagShow`)]}),Pt===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:l(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:t.domGranted?l(`pluginDomGranted`):l(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${t.domGranted?``:` confirm`}`,title:l(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:t.id,granted:!t.domGranted}),children:t.domGranted?l(`pluginDomRevoke`):l(`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:()=>zt(e=>({...e,[t.id]:!e[t.id]})),children:[(0,X.jsx)(V,{}),l(`pluginSettingsTitle`),` (`,t.settingsSchema.length,`) ·`,` `,Rt[t.id]?l(`pluginSettingsHide`):l(`pluginSettingsShow`)]}),Rt[t.id]&&(0,X.jsx)(F_,{plugin:t,models:g?.subagentModels??[]})]})]},t.id)})})]}),x===`plugins`&&b&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(st,{className:`set-section-icon`}),l(`dshPatches`),(0,X.jsx)(Zc,{text:l(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(G,{}),l(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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:[bf(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[l(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),x===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(M,{className:`set-section-icon`}),l(`settingsReview`),(0,X.jsx)(Zc,{text:l(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.reviewSkills.length})]}),(0,X.jsx)(ey,{title:l(`goalModeEnabled`),tip:`${l(`goalModeEnabledDesc`)}\n${l(`goalModeOffHint`)}`,enabled:g.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!g.goalModeEnabled})}),(0,X.jsx)(ey,{title:l(`delegateMode`),tip:`${l(`delegateModeDesc`)}\n${l(`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:l(`reviewPromptPlaceholder`),value:xe,onFocus:()=>Ce.current=!0,onBlur:()=>{Ce.current=!1,Q({reviewPrompt:xe})},onChange:e=>Se(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`settingsReviewSkills`),b&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(Zc,{text:l(`dshReviewPromptNote`)})]})]}),g.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.reviewSkills.map(e=>(0,X.jsx)(ey,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>oi(e)},`review-${e.name}`))})]}),x===`vision`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Fe,{className:`set-section-icon`}),l(`settingsVisionBridge`)]}),(0,X.jsx)(ey,{title:l(`visionBridgeEnabled`),tip:`${l(`settingsVisionBridgeDesc`)}\n${l(`visionBridgeOffHint`)}`,enabled:g.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!g.visionBridgeEnabled})}),g.visionBridgeEnabled&&(0,X.jsx)(iy,{label:l(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:g.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:l(`visionBridgeAuto`)}),g.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),g.visionBridgeEnabled&&(0,X.jsx)(ay,{mode:oe,onModeChange:se,draft:ie,onDraftChange:W,defaultPrompt:g.visionBridgeDefaultPrompt,placeholder:l(`visionBridgePromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({visionBridgePromptMode:e,visionBridgePrompt:t})},hint:g.visionModels.length===0?l(`visionBridgeNoModels`):l(`visionBridgeCurrent`,{model:g.visionBridgeModel??l(`visionBridgeAuto`)}),focusRef:ce})]}),x===`presets`&&e.dshPresets&&e.dshPresets.presets.length>0&&(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`}),l(`dshPreset`),(0,X.jsx)(Zc,{text:l(`dshDefaultPresetDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPresets.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`dshDefaultPreset`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:Jh(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[qh(e,u,l).name,e.trust===`user`?` · ${l(`dshPresetUser`)}`:``]},e.id))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Jh(e.dshPresets.presets).map(t=>{let n=qh(t,u,l);return(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[n.name,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetUser`)}),t.id===e.dshPresets.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:l(`dshPresetBroken`)})]}),n.description&&!t.broken&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:n.description}),t.broken&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t.broken})]})},t.id)})}),(0,X.jsx)(`p`,{className:`set-hint`,children:l(`dshPresetUserNote`)})]}),x===`presets`&&e.dshPermission&&e.dshPermission.options.length>0&&(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`}),l(`dshPerm`),(0,X.jsx)(Zc,{text:l(`dshPermDefaultDesc`)})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`dshPermDefault`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:Zh.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:l(Qh(e))},e))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Zh.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(t=>(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[l(Qh(t)),t===e.dshPermission.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetDefaultTag`)})]}),(0,X.jsx)(`div`,{className:`set-row-desc`,children:l($h(t))})]})},t))})]}),x===`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`}),l(`settingsPresets`),(0,X.jsx)(`span`,{className:`set-count`,children:g.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`presetNamePlaceholder`),value:we,onChange:e=>Te(e.target.value),onKeyDown:e=>{e.key===`Enter`&&we.trim()&&($({type:`save_preset`,name:we.trim()}),Te(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!we.trim(),onClick:()=>{$({type:`save_preset`,name:we.trim()}),Te(``)},children:[(0,X.jsx)(le,{}),` `,l(`saveAsPreset`)]})]}),g.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.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`?l(`promptModeReplace`):l(`promptModeAppend`),e.disabledSkills.length>0&&` · ${l(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${l(`settingsExtensions`)} ${e.disabledExtensions.length}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`apply_preset`,name:e.name}),children:l(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),x===`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`}),l(`settingsSubagentTemplates`),(0,X.jsx)(Zc,{text:l(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:l(`subagentTemplateNew`),onClick:()=>{J({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),ke(!0)},children:[(0,X.jsx)(le,{}),` `,l(`subagentTemplateNew`)]})]}),(0,X.jsx)(iy,{label:l(`subagentDefaultModelLabel`),tip:l(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:g.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:l(`subagentFollowMain`)}),g.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),g.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`subagentNoModels`)}),q&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>J(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":l(`close`),onClick:()=>J(null),children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(F,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:Oe?l(`subagentTemplateNew`):`${l(`subagentTemplateEdit`)} · ${q.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:l(`tplNamePlaceholder`),value:q.name,onChange:e=>J({...q,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`tplDescriptionPlaceholder`),value:q.description,onChange:e=>J({...q,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`tplDescriptionEnPlaceholder`),value:q.descriptionEn??``,onChange:e=>J({...q,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:q.promptMode,onChange:e=>J({...q,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:l(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:l(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:q.model??``,onChange:e=>J({...q,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:l(`subagentFollowMain`)}),g.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:[l(`tplThinkingLabel`),` `,(0,X.jsx)(Zc,{text:l(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:q.thinkingLevel??``,onChange:e=>J({...q,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:l(`tplThinkingFollowMain`)}),Bh.map(e=>(0,X.jsx)(`option`,{value:e,children:l(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${l(`tplSystemPromptLabel`)}${u===`zh`?`:`:`: `}${l(`tplSystemPromptPlaceholder`)}`,value:q.systemPrompt,onChange:e=>J({...q,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${l(`tplSystemPromptLabel`)}: ${l(`tplSystemPromptEnPlaceholder`)}`,value:q.systemPromptEn??``,onChange:e=>J({...q,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:[l(`tplSkillsLabel`),` · `,l(`tplWhitelistHint`)]})}),g.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:g.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${q.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:q.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;J({...q,enabledSkills:n?[...q.enabledSkills,e.name]:q.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:[l(`tplExtensionsLabel`),` · `,l(`tplWhitelistHint`)]})}),g.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:g.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${q.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:q.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;J({...q,enabledExtensions:n?[...q.enabledExtensions,e.id]:q.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:!q.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...q,name:q.name.trim()}}),J(null)},children:l(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>J(null),children:l(`tplCancel`)})]})]})}),g.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:g.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,g.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:l(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:l(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(u!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?l(`promptModeReplace`):l(`promptModeAppend`)}`,e.model?` · ${l(`tplModelLabel`)} ${e.model}`:` · ${l(`subagentFollowMain`)}`,e.thinkingLevel?` · ${l(`tplThinkingLabel`)} ${d(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${l(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${l(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${l(`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?l(`subagentTemplateDisable`):l(`subagentTemplateEnable`)} · ${l(`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:l(`subagentTemplateEdit`),onClick:()=>{J({...e}),ke(!1)},children:l(`subagentTemplateEdit`)}),Ae===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),Ne(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`tplDelete`),onClick:()=>Ne(e.name),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),x===`approval-rules`&&!b&&(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`}),l(`settingsApprovalRules`),(0,X.jsx)(Zc,{text:l(`settingsApprovalRulesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.approvalRules?.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:l(`approvalRuleNew`),onClick:()=>{Ie({id:`custom.${St().slice(0,8)}`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:``,action:`ask`,label:``,labelEn:``,reason:``,reasonEn:``}),He(`bash`),Be(!0),Ge(null)},children:[(0,X.jsx)(le,{}),` `,l(`approvalRuleNew`)]})]}),Y&&(0,X.jsxs)(`div`,{className:`rule-editor`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,style:{fontSize:13,marginBottom:4},children:Re?l(`approvalRuleNew`):`${l(`approvalRuleEdit`)} · ${Y.label}`}),(0,X.jsx)(iy,{label:l(`approvalRuleLabel`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.label,placeholder:`例如:拦截 Docker 危险操作`,onChange:e=>Ie({...Y,label:e.target.value})})}),(0,X.jsx)(iy,{label:l(`approvalRuleLabelEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.labelEn??``,placeholder:`e.g. Block dangerous Docker commands`,onChange:e=>Ie({...Y,labelEn:e.target.value})})}),(0,X.jsx)(iy,{label:l(`approvalRuleTools`),tip:l(`approvalRuleToolsTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Ve,placeholder:`bash, write, edit (或 * 通配)`,onChange:e=>{He(e.target.value);let t=e.target.value.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);Ie({...Y,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)(iy,{label:l(`approvalRuleField`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.field,onChange:e=>Ie({...Y,field:e.target.value}),children:[(0,X.jsx)(`option`,{value:`command`,children:l(`approvalRuleFieldCommand`)}),(0,X.jsx)(`option`,{value:`path`,children:l(`approvalRuleFieldPath`)}),(0,X.jsx)(`option`,{value:`params`,children:l(`approvalRuleFieldParams`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(iy,{label:l(`approvalRuleMatch`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.match,onChange:e=>Ie({...Y,match:e.target.value}),children:[(0,X.jsx)(`option`,{value:`regex`,children:l(`approvalRuleMatchRegex`)}),(0,X.jsx)(`option`,{value:`glob`,children:l(`approvalRuleMatchGlob`)}),(0,X.jsx)(`option`,{value:`contains`,children:l(`approvalRuleMatchContains`)}),(0,X.jsx)(`option`,{value:`prefix`,children:l(`approvalRuleMatchPrefix`)}),(0,X.jsx)(`option`,{value:`outside_workspace`,children:l(`approvalRuleMatchOutsideWs`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(iy,{label:`命中动作`,children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.action,onChange:e=>Ie({...Y,action:e.target.value}),children:[(0,X.jsx)(`option`,{value:`ask`,children:l(`approvalRuleActionAsk`)}),(0,X.jsx)(`option`,{value:`deny`,children:l(`approvalRuleActionDeny`)}),(0,X.jsx)(`option`,{value:`allow`,children:l(`approvalRuleActionAllow`)})]})})})]}),Y.match!==`outside_workspace`&&(0,X.jsx)(iy,{label:l(`approvalRuleValue`),tip:l(`approvalRuleValueTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.value,placeholder:`匹配表达式或关键字…`,onChange:e=>Ie({...Y,value:e.target.value})})}),(0,X.jsx)(iy,{label:l(`approvalRuleReason`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.reason??``,placeholder:`例如:检测到删除镜像或容器操作`,onChange:e=>Ie({...Y,reason:e.target.value})})}),(0,X.jsx)(iy,{label:l(`approvalRuleReasonEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.reasonEn??``,placeholder:`e.g. Detected docker image/container removal`,onChange:e=>Ie({...Y,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:Y.enabled,onChange:e=>Ie({...Y,enabled:e.target.checked})}),l(`approvalRuleEnabled`)]})}),We&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12},children:We}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:4},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Ie(null),Ge(null)},children:l(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{if(!Y.label.trim()){Ge(`请填写规则名称`);return}if(Y.match===`regex`)try{new RegExp(Y.value)}catch(e){Ge(`正则表达式非法:${e.message}`);return}$({type:`save_approval_rule`,rule:Y}),Ie(null),Ge(null)},children:l(`save`)})]})]}),(g.approvalRules??[]).length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`approvalRuleEmpty`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:(g.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`?l(`approvalRuleActionDeny`):e.action===`allow`?l(`approvalRuleActionAllow`):l(`approvalRuleActionAsk`)}),(0,X.jsx)(`strong`,{style:{fontSize:13},children:u===`zh`?e.label:e.labelEn||e.label}),n&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:l(`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:u===`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?l(`settingsEnabled`):l(`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:l(`approvalRuleMoveUp`),onClick:()=>{let e=[...g.approvalRules??[]],n=e[t-1];e[t-1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(et,{})}),!n&&t<(g.approvalRules?.length??0)-1&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleMoveDown`),onClick:()=>{let e=[...g.approvalRules??[]],n=e[t+1];e[t+1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(rt,{})}),n&&(Je===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`reset_builtin_approval_rule`,id:e.id}),Xe(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleReset`),onClick:()=>Xe(e.id),children:(0,X.jsx)(G,{})})),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleEdit`),onClick:()=>{Ie({...e}),He(e.tools.join(`, `)),Be(!1),Ge(null)},children:(0,X.jsx)(Le,{})}),!n&&(Ke===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`delete_approval_rule`,id:e.id}),qe(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`approvalRuleDelete`),onClick:()=>qe(e.id),children:(0,X.jsx)(R,{})}))]})]},e.id)})})]}),tr&&(0,X.jsx)(ol,{plugin:tr.plugin,epoch:e.pluginsEpoch,send:$,className:`set-plugin-page`})]})]}),(0,X.jsx)(`div`,{className:`modal-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:i,children:l(`close`)})})]})})}var uy=0,dy=``;function fy(){typeof document<`u`&&(uy===0&&(dy=document.body.style.overflow,document.body.style.overflow=`hidden`),uy++)}function py(){typeof document<`u`&&(uy=Math.max(0,uy-1),uy===0&&(document.body.style.overflow=dy))}function my({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(),h=(0,m.useRef)(t);if((0,m.useLayoutEffect)(()=>{h.current=t}),At(()=>l?(h.current(),!0):!1,e),(0,m.useEffect)(()=>{if(e&&f)return fy(),()=>{py()}},[e,f]),!e)return null;let g=e=>{e.target===e.currentTarget&&c&&h.current()},_=d??(typeof n==`string`?n:void 0);return(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop ${o}`.trim(),onClick:g,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:()=>h.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 hy(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 gy({servers:e,onClose:t}){let n=Z(),[r,i]=(0,m.useState)(new Set),a=e=>i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,m.useEffect)(()=>{$({type:`list_bg_servers`})},[]),(0,X.jsxs)(my,{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)(Te,{}),` `,n(`bgTasks`),e.length>0&&(0,X.jsx)(`em`,{className:`bg-task-count`,children:e.length})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:n(`close`),onClick:t,children:(0,X.jsx)(N,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(Te,{}),(0,X.jsx)(`span`,{children:n(`bgTasksEmpty`)}),(0,X.jsx)(`small`,{children:n(`bgTasksDesc`)})]}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:e.map(e=>{let t=!!e.taskId,i=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:n(`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:[n(`bgTaskPid`),` `,e.pid]}),(0,X.jsxs)(`span`,{children:[n(`bgTaskSince`),` `,hy(e.since,n)]}),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 ${r.has(i)?`open`:``}`,title:`${n(`bgTaskCommand`)}: ${e.command}`,onClick:()=>a(i),children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`code`,{children:e.command})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,title:n(`bgTaskStop`),onClick:()=>$(t?{type:`kill_background_server`,taskId:e.taskId}:{type:`kill_background_server`,port:e.port}),children:[(0,X.jsx)(ie,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStop`)})]})]},i)})}),(0,X.jsxs)(`div`,{className:`bg-task-foot`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:n(`bgTaskRefresh`),onClick:()=>$({type:`list_bg_servers`}),children:[(0,X.jsx)(G,{}),(0,X.jsx)(`span`,{children:n(`bgTaskRefresh`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stopall`,disabled:e.length===0,title:n(`bgTaskStopAll`),onClick:()=>$({type:`kill_background_servers`}),children:[(0,X.jsx)(ie,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStopAll`)})]})]})]})}function _y(){let e=Z(),t=Uf(),[n,r]=(0,m.useState)(!0),i=(0,m.useRef)(null);return(0,m.useEffect)(()=>{t&&r(!0)},[t]),At(()=>{t&&Vf()},!!t),(0,m.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(),Hf(n))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,n]),t?(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:Vf,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)(gt,{}),e(`rollbackSession`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`cancel`),onClick:Vf,children:(0,X.jsx)(N,{})})]}),(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:Vf,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:()=>Hf(n),children:[(0,X.jsx)(it,{}),e(`confirm`)]})]})]})]})}),document.body):null}function vy({approval:e}){let t=Z(),{locale:n}=wn(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(null);if((0,m.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,k.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)(gt,{}),t(`toolApprovalTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,style:{fontWeight:700},children:e.toolName}),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)(N,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(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]})]}),(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)(Te,{}),t(`toolApprovalAllowCategory`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowConversationHint`),onClick:()=>s(`all`),children:[(0,X.jsx)(at,{}),t(`toolApprovalAllowConversation`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,style:{color:`var(--red, #ef4444)`},onClick:c,children:[(0,X.jsx)(N,{}),t(`toolApprovalDeny`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>s(),style:{fontWeight:500},children:[(0,X.jsx)(it,{}),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)(Le,{}),t(`toolApprovalEditAndRun`)]})]})]})]})}),document.body)}var yy={pending:`in_progress`,in_progress:`done`,done:`failed`,failed:`pending`};function by({plan:e}){let t=Z(),[n,r]=(0,m.useState)(!1),{copied:i,copy:a}=hl({duration:2e3}),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``);if(!e||!e.steps||e.steps.length===0)return null;let f=e.steps,p=f.filter(e=>e.status===`done`).length,h=f.length,g=Math.round(p/h*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(`
|
|
356
|
+
`)}}var sh=null;function ch(){if(sh?.isConnected)return sh;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),sh=e,e}function lh(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 uh(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=ih,e.appendChild(n),n.offsetTop}function dh(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=oh(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=ch();if(lh(e,i)<=0)return r;let a=uh(i,t.slice(0,n)),o=uh(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:ah(a,o,rh(e))}function fh(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 ph=`pi-web-ui:prompt-history`,mh=`pi-web-ui:prompt-history-settings`,hh={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function gh(e){let t=hh;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 _h(){try{let e=localStorage.getItem(mh);return e?gh(JSON.parse(e)):{...hh}}catch{return{...hh}}}function vh(e){let t=gh(e);try{localStorage.setItem(mh,JSON.stringify(t))}catch{}try{let e=xh();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)),Sh(e)}catch{}}function yh(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 bh(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 xh(){try{let e=localStorage.getItem(ph);return e?yh(JSON.parse(e)):[]}catch{return[]}}function Sh(e){let t=e;for(;t;)try{localStorage.setItem(ph,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 Ch(e){let t=e.trim();if(!t)return;let n=_h();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));let r=xh(),i=bh(r,t,n.maxEntries);i!==r&&Sh(i)}function wh(){try{localStorage.removeItem(ph)}catch{}}var Th=`skill:`;function Eh(e,t){let n=e.toLowerCase();return t===`skill`&&n.startsWith(`skill:`)?[n,n.slice(6)]:[n]}function Dh(e,t){let n=t.toLowerCase();return n?e.filter(e=>Eh(e.name,e.source).some(e=>e.startsWith(n))):[...e]}var Oh=new Set([`p`,`page`,`pages`,`web`,`网页`,`页面`]);function kh(e,t,n,r=10){if(!Array.isArray(t))return[];let i=String(n??``).toLowerCase(),a=i===``||Oh.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 Ah(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 jh(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 Mh(e,t,n,r=15,i){if(!Array.isArray(t)||r<=0)return[];let a=String(n??``).toLowerCase(),o=a.startsWith(Th),s=o?a.slice(Th.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(Th.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 Nh(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 Ph(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function Fh(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||!Ph(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 Ih(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 Lh(){return typeof window>`u`||typeof navigator>`u`||typeof window.matchMedia!=`function`?!1:Ih({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}function Rh(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}var zh=1;function Bh(){return++zh}var Vh=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],Hh=(0,m.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,m.useState)(!1),[p,h]=(0,m.useState)(!1),[g,_]=(0,m.useState)(``),[v,y]=(0,m.useState)(null),[b,x]=(0,m.useState)({}),S=(0,m.useRef)(null),C=(0,m.useRef)(null),[w,T]=(0,m.useState)(null);(0,m.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,m.useEffect)(()=>{d&&x(Wp())},[d]),(0,m.useEffect)(()=>{d||(_(``),y(null))},[d]);let E=(0,m.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,m.useMemo)(()=>Up(t,b),[t,b]),O=(0,m.useMemo)(()=>{let e=D;v&&(e=e.filter(e=>e.provider===v.provider));let t=g.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||e.provider.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)):e},[D,g,v]),k=(0,m.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,m.useState)(!1),ee=e?.availableThinkingLevels&&e.availableThinkingLevels.length>0?new Set(e.availableThinkingLevels):null,N=Vh.map(e=>({value:e,label:c(`thinking.${e}`),supported:!ee||ee.has(e)})),P=e=>N.find(t=>t.value===e)?.label??e,F=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!d){F.current=!1;return}F.current||t.length>0||n||(F.current=!0,j(!0),$({type:`list_models`})||j(!1))},[d,t.length,n]),(0,m.useEffect)(()=>{j(!1)},[t]),(0,m.useEffect)(()=>{d&&(S.current?.querySelector(`.dd-item.active`))?.scrollIntoView({block:`nearest`})},[d,u,t.length]);let I=(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)(G,{}),(0,X.jsx)(`input`,{className:`dd-search`,type:`text`,placeholder:c(`searchModels`),value:g,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)(Nt,{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`)})]})]}),L=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`thinkingLevel`)}),N.map(t=>(0,X.jsx)(Nt,{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}),h(!1)},children:t.label},t.value))]}),te=(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ue,{}),(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:I}),R=(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(M,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:c(`thinkingChip`,{level:e?P(e.thinkingLevel):`—`})})]}),tip:c(`thinkingLevel`),open:p,onOpenChange:h,align:`left`,direction:`up`,children:L});if(s===`model`)return te;if(s===`thinking`)return R;let z=e?.thinkingLevel&&e.thinkingLevel!==`off`;return(0,X.jsxs)(`div`,{className:`model-thinking-capsule`,children:[(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ue,{}),(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:I}),(0,X.jsx)(`div`,{className:`capsule-divider`}),(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`thinking-pulse-dot ${z?`on`:``}`}),(0,X.jsx)(`span`,{className:`capsule-thinking-text`,children:e?P(e.thinkingLevel):`—`})]}),triggerClassName:`capsule-segment capsule-thinking`,open:p,onOpenChange:h,align:`left`,direction:`up`,children:L})]})}),Uh=[`standard`,`ptc`,`minimal`,`cordis`],Wh={standard:`preset.standard`,minimal:`preset.minimal`,code:`preset.code`,reader:`preset.reader`,ask:`preset.ask`},Gh={standard:`preset.standardDesc`,minimal:`preset.minimalDesc`,code:`preset.codeDesc`,reader:`preset.readerDesc`,ask:`preset.askDesc`};function Kh(e){return Wh[e]??null}function qh(e){return Gh[e]??null}function Jh(e,t,n){let r=t===`zh`,i=Kh(e.id),a=qh(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 Yh(e){return[...e].sort((e,t)=>{let n=Number.isSafeInteger(e.order)?e.order:Uh.indexOf(e.id),r=Number.isSafeInteger(t.order)?t.order:Uh.indexOf(t.id),i=n>=0?n:1e3,a=r>=0?r:1e3;return i===a?e.id.localeCompare(t.id):i-a})}var Xh=(0,m.memo)(function({preset:e,presets:t,defaultPreset:n,blank:r,conversationId:i,compact:a=!1}){let o=Z(),{locale:s}=wn(),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(e?.id??n);if((0,m.useEffect)(()=>{d(e?.id??n)},[i,e?.id,n]),t.length===0)return null;let f=e?.locked||!r,p=Yh(t),h=p.find(t=>t.id===e?.id),g=p.find(e=>e.id===u)??h,_=e=>Jh(e,s,o),v=h?_(h):void 0,y=t=>{d(t),l(!1),r&&t!==e?.id&&$({type:`dsh_preset_select`,preset:t})};if(a){let t=v?.description??h?.id??o(`dshPreset`);return(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:f?`${t}(${o(`dshPresetLocked`)})`:t,children:[v?.name??h?.id??e?.name??o(`dshPreset`),f&&(0,X.jsx)(be,{style:{marginLeft:3}})]})]}),open:c&&!f,onOpenChange:l,direction:`up`,align:`left`,children:p.map(t=>{let r=_(t);return(0,X.jsxs)(Nt,{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)(V,{}),o(`dshPreset`)]}),(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(`span`,{title:v?.description??h?.id??``,children:[v?.name??h?.id??e?.name??`…`,f&&(0,X.jsxs)(`span`,{className:`dsh-preset-lock`,title:o(`dshPresetBlankOnly`),children:[(0,X.jsx)(be,{}),` `,o(`dshPresetLocked`)]})]}),open:c&&!f,onOpenChange:l,children:p.map(t=>{let r=_(t);return(0,X.jsxs)(Nt,{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`)}),g?.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:g?.id??u}),Qn()},children:[(0,X.jsx)(ce,{}),` `,o(`dshPresetNewChat`)]})]})}),Zh=[`read-only`,`workspace-write-never`,`danger-full-access`],Qh=[`read-only`,`workspace-write-never`,`danger-full-access`];function $h(e){return e===`read-only`?`dshPermReadOnly`:e===`danger-full-access`?`dshPermFullAccess`:`dshPermWorkspaceWrite`}function eg(e){return e===`read-only`?`dshPermReadOnlyDesc`:e===`danger-full-access`?`dshPermFullAccessDesc`:`dshPermWorkspaceWriteDesc`}var tg=(0,m.memo)(function({current:e,options:t,defaultPreset:n,conversationId:r,compact:i=!1}){let a=Z(),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(!1);(0,m.useEffect)(()=>{l(!1),s(!1)},[r]);let u=Zh.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`:$h(d)),r=f?e??t:a(eg(d));return(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(H,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:r,children:[t,d===`danger-full-access`&&(0,X.jsx)(gt,{style:{marginLeft:3}})]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},direction:`up`,align:`left`,children:[u.map(e=>(0,X.jsxs)(Nt,{active:e===d,title:a(eg(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a($h(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(eg(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)(H,{}),a(`dshPerm`)]}),(0,X.jsx)(Mt,{trigger:(0,X.jsxs)(`span`,{title:f?e:a(eg(d)),children:[a(f?`dshPermCustom`:$h(d)),d===`danger-full-access`&&(0,X.jsxs)(`span`,{className:`dd-preset-tag warn`,children:[(0,X.jsx)(gt,{}),` `,a(`dshPermFullAccessTag`)]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},children:u.map(e=>(0,X.jsxs)(Nt,{active:e===d,title:a(eg(e)),onClick:()=>p(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a($h(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(eg(e))})]},e))}),c&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:a(`dshPermConfirmFull`)})]})}),ng=Lh(),rg=40,ig=220,ag=720,og=`pi-web-ui:composer-height`,sg=(0,m.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:h,onSent:g,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:N,sessionId:P}){let F=Z(),I=ha(`ready`),L=ga(),{locale:te}=wn(),{openPicker:R}=$p(),z=e=>te!==`zh`&&e.descriptionEn?e.descriptionEn:e.description??``,ne=e=>te!==`zh`&&e.argumentHintEn?e.argumentHintEn:e.argumentHint??``,[re,B]=(0,m.useState)(``),[V,H]=(0,m.useState)(()=>{try{let e=Number(localStorage.getItem(og));if(Number.isFinite(e)&&e>=rg&&e<=ag)return e}catch{}return null}),U=(0,m.useRef)(null),[W,G]=(0,m.useState)(null),[ae,oe]=(0,m.useState)(0),se=(0,m.useRef)(0),K=(0,m.useRef)(new Map),ce=(0,m.useRef)(``),[le,de]=(0,m.useState)(!1),[fe,pe]=(0,m.useState)(void 0),me=(0,m.useRef)(null),he=(0,m.useRef)(null),_e=(0,m.useRef)(null),q=(0,m.useRef)(-1),ve=(0,m.useRef)(``),ye=(0,m.useRef)(0);(0,m.useEffect)(()=>{if(!S||S.length===0)return;let e=S.filter(e=>e.text&&e.seq>ye.current);e.length!==0&&(ye.current=e[e.length-1].seq,G(null),B(t=>{let n=e.reduce((e,t)=>Zm(e,t.text),t);return ce.current=n,n}),q.current=-1,ve.current=``,requestAnimationFrame(()=>{let e=me.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}))},[S]),(0,m.useEffect)(()=>(Yn(e=>{G(null),B(t=>{let n=Zm(t,e);return ce.current=n,n}),q.current=-1,ve.current=``,requestAnimationFrame(()=>{let e=me.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)})}),()=>Yn(null)),[]),(0,m.useEffect)(()=>(Zn(()=>{ng||requestAnimationFrame(()=>{me.current?.focus()})}),()=>Zn(null)),[]);let be=(0,m.useRef)(``);be.current=re,(0,m.useEffect)(()=>(Gn(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(be.current))return}let t=me.current;if(!t){B(t=>{let n=t+(t&&!t.endsWith(` `)?` `:``)+e;return ce.current=n,n});return}let n=t.selectionStart??be.current.length,r=t.selectionEnd??be.current.length,i=be.current,a=(n>0&&!/[\s([{]$/.test(i.slice(0,n))?` `:``)+e,o=i.slice(0,n)+a+i.slice(r);ce.current=o,B(o);let s=n+a.length;requestAnimationFrame(()=>{t.focus(),t.selectionStart=t.selectionEnd=s})}),()=>Gn(null)),[]),(0,m.useEffect)(()=>(Kn(e=>{B(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(),ce.current=a,a})}),()=>Kn(null)),[]);let xe=2e4,Ce=!L&&P?`${M??``}${P}`:null,we=Ce&&P?`pi-web-ui:composer-draft:${P}`:null,Te=(0,m.useRef)(``),J=(0,m.useRef)(0),Ee=(0,m.useRef)(!1),De=(0,m.useRef)(0),Oe=(0,m.useRef)(null),ke=(0,m.useRef)(null),Ae=(0,m.useRef)(null),je=(0,m.useRef)(0),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,xe),ts:n.ts}}catch{return null}},Ne=(e,t,n,r)=>{let i=n.slice(0,xe);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})},Y=()=>{Oe.current&&=(clearTimeout(Oe.current),null),Ee.current&&Ce&&we&&P&&Xe&&Ne(P,we,Te.current,J.current)},Pe=e=>{if(Te.current=e,Ee.current=!0,J.current=Date.now(),we){let t=e.slice(0,xe);try{t.trim()?localStorage.setItem(we,JSON.stringify({text:t,ts:J.current})):localStorage.removeItem(we)}catch{}}if(Ce&&P&&Xe){Oe.current&&clearTimeout(Oe.current);let e=P,t=we,n=J.current,r=Ce;Oe.current=setTimeout(()=>{Oe.current=null,r===ke.current&&t&&Ne(e,t,Te.current,n)},2e3)}},Fe=(e,t)=>{q.current=-1,B(e),Re(e,t),Pe(e)};(0,m.useEffect)(()=>{let e=Ce,t=P,n=we;return()=>{Oe.current&&=(clearTimeout(Oe.current),null),Ee.current&&Te.current.trim()?(e&&t&&n&&Ne(t,n,Te.current,J.current),Ae.current=Te.current):Ae.current=null}},[Ce]),(0,m.useEffect)(()=>{ke.current=Ce;let e=Ae.current;Ae.current=null;let t=we?Me(we):null,r=!!(N&&N.text?.trim()&&N.ts>0||t&&t.text?.trim());e!==null&&nh(e,n.length,r)&&we&&P?(Ee.current=!0,De.current=Date.now(),Te.current=e,J.current=De.current,B(e),Ne(P,we,e,J.current)):(Ee.current=!1,De.current=0,Te.current=``,J.current=0,B(``)),G(null),q.current=-1},[Ce]);let Ie=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=n.length===0,t=Ie.current!==Ce;Ie.current=Ce,I&&e&&(!ng||t)&&requestAnimationFrame(()=>{me.current?.focus()})},[Ce,n.length,I]),(0,m.useEffect)(()=>{if(!Ce||!we||Ee.current||Te.current!==``)return;let e=Qm(N&&N.text?{text:N.text.slice(0,xe),ts:N.ts}:null,Me(we),De.current);e&&(De.current=e.ts,Te.current=e.text,J.current=e.ts,B(e.text),Re(e.text,null))});let Le={builtin:F(`slashBuiltin`),extension:F(`slashExtension`),prompt:F(`slashPrompt`),skill:F(`slashSkill`),plugin:F(`slashPlugin`)},Re=(e,t)=>{ce.current=e;let n=e.match(/^\/([^\s]*)$/);if(n&&I){let e=Dh(r,n[1].toLowerCase());G(e.length>0?{kind:`slash`,items:e}:null),oe(0);return}if(t===null||!I){G(null);return}let i=Fh(e,t);if(!i){G(null);return}let a=[];try{a=qo()}catch{a=[]}let o=++se.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=Jo(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:F(`openFiles`),run:()=>ze(l)}),Pn();let f=kh(F(`browserControl`),Nn(),l);if(d.push({id:`host:pages`,label:F(`browserControl`),run:()=>Promise.resolve(f)}),d.length===0){G(null);return}let m=Mh(F(`slashSkill`),r,l,15,z),h=Nh({pages:f,skills:m},l,30),g=!1;h.length>0&&(g=!0,G({kind:`at`,start:c,end:u,items:h}),oe(0)),Promise.allSettled(d.map(e=>Promise.race([e.run(),new Promise((e,t)=>setTimeout(()=>t(Error(`at-mention timeout`)),2e3))]))).then(e=>{if(se.current!==o||ce.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(...Ah(d[i].label,e.value)):r.push(...jh(d[i].id,d[i].label,e.value)))});let i=Nh({pages:t,skills:m,files:n,plugins:r},l,30);G(i.length>0?{kind:`at`,start:c,end:u,items:i}:null),!g&&i.length>0&&oe(0)})},ze=e=>{if(typeof p!=`function`)return Promise.resolve([]);let t=Bh();return new Promise(n=>{K.current.set(t,n);try{p(t,e)}catch{K.current.delete(t),n([]);return}setTimeout(()=>{K.current.get(t)===n&&(K.current.delete(t),n([]))},3e3)})};(0,m.useEffect)(()=>{if(!f||!f.ok)return;let e=K.current.get(f.reqId);e&&(K.current.delete(f.reqId),e(f.results??[]))},[f]);let Be=e=>Re(e,null);(0,m.useEffect)(()=>{(_e.current?.querySelector(`.slash-item.active`))?.scrollIntoView({block:`nearest`})},[ae,W]);let Ve=e=>{let t=W?.kind===`slash`?W.items:[],n=e??t[ae%Math.max(t.length,1)];if(!n){G(null);return}let r=re.match(/^\/([^\s]*)([\s\S]*)$/),i=r?r[2]:``,a=`/${n.name} ${i}`;ce.current=a,B(a),Pe(a),G(null),me.current?.focus()},He=(e,t)=>{let n=W?.kind===`at`?W:null,r=n?.items??[],i=e??r[ae%Math.max(r.length,1)],a=t??n?.start;if(!i||a===void 0){G(null);return}let o=me.current,s=o?o.selectionStart??re.length:re.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=`${re.slice(0,a)}${f}${re.slice(c)}`;ce.current=p,B(p),Pe(p),G(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=me.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=a+f.length)})},Ue=()=>W?.kind===`slash`?W.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===ae?` active`:``}`,onMouseEnter:()=>oe(t),onClick:()=>Ge(e),children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Le[e.source]}),(0,X.jsxs)(`span`,{className:`slash-desc`,children:[z(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:ne(e)})]})]},e.name)):null,We=()=>W?.kind===`at`?W.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===ae?` active`:``}`,onMouseEnter:()=>oe(t),onClick:()=>Ge(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,Ge=e=>{W&&(W.kind===`slash`?Ve(e):He(e,W.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(`
|
|
357
|
+
`);if(!e){h(`warning`,F(`slashCopyEmpty`));return}await ml(e)?h(`info`,F(`slashCopied`)):h(`error`,F(`slashCopyFailed`))},qe=e=>{if(!e||e.length===0){h(`warning`,F(`foldersNotSupported`));return}let t=Array.from(e).filter(e=>hf(e.type)),n=Array.from(e).filter(e=>!hf(e.type)),r=Ye();t.length>0&&r?h(`warning`,r):t.length>0&&l(t),n.length>0&&u(n)},Je=e=>{let t=fh(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?F(`modelNoVision`,{name:t.name}):null},Xe=I,Ze=(0,m.useRef)(re);(0,m.useEffect)(()=>{Ze.current=re},[re]),(0,m.useEffect)(()=>{Be(Ze.current)},[r]),(0,m.useEffect)(()=>{let e=e=>{let t=e.detail;G(null),ce.current=t,B(t),me.current?.focus()};return window.addEventListener(`pi-web:fill`,e),()=>window.removeEventListener(`pi-web:fill`,e)},[]),(0,m.useEffect)(()=>{if(!le)return;let e=e=>{e.key===`Escape`&&de(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[le]);let Qe=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=me.current,t=Qe.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=V==null?ig:ag;e.style.maxHeight=`${a}px`;let o=Math.min(Math.max(e.scrollHeight,V??0),a);e.style.height=`${o}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`,n&&(n.scrollTop=i+(t.getBoundingClientRect().height-r))},[re,V]);let $e=()=>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}:{}}:{}}),et=(e=!1)=>{let t=re.trim(),n=s.length>0;if(t||n){if(!Xe){h(`error`,F(`netDisconnected`));return}if(t===`/help`){let e=me.current?.closest(`.inputbox`)?.getBoundingClientRect();pe(e?.width),de(!0),B(``),me.current?.focus();return}if(t===`/copy`){B(``),me.current?.focus(),Ke();return}if($({type:`prompt`,text:t,queue:e,attachments:$e()})){if(t&&Ch(t),q.current=-1,ve.current=``,B(``),we)try{localStorage.removeItem(we)}catch{}Oe.current&&=(clearTimeout(Oe.current),null),Ee.current=!1,De.current=Date.now(),Te.current=``,J.current=0,g();let e=i?.model;e&&Kp(`${e.provider}/${e.id}`),me.current?.focus()}else h(`error`,F(`netDisconnected`))}},tt=(e,t=!1)=>{let n=e.trim();if(n){if(!Xe){h(`error`,F(`netDisconnected`));return}if($({type:`prompt`,text:n,queue:t,attachments:$e()})){n&&Ch(n),q.current=-1,ve.current=``,Y(),g();let e=i?.model;e&&Kp(`${e.provider}/${e.id}`),ng||me.current?.focus()}else h(`error`,F(`netDisconnected`))}},nt=e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229||Date.now()-je.current<50)){if(W&&W.items.length>0){let t=W.items.length;switch(e.key){case`ArrowDown`:e.preventDefault(),oe(e=>(e+1)%t);return;case`ArrowUp`:e.preventDefault(),oe(e=>(e-1+t)%t);return;case`Tab`:case`Enter`:e.preventDefault(),Ge();return;case`Escape`:e.preventDefault(),G(null);return}}if(e.key===`Backspace`&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=me.current;if(t&&t.selectionStart===t.selectionEnd&&t.selectionStart>0){let n=t.selectionStart,r=Rh(re.slice(0,n),n,s);if(r&&r.tokenStart>=0&&r.tokenStart<n){e.preventDefault();let t=r.tokenStart,i=re.slice(0,t)+re.slice(n);ce.current=i,B(i),requestAnimationFrame(()=>{me.current&&(me.current.selectionStart=me.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=me.current;if(!t)return;let n=e.key===`ArrowUp`,r=dh(t);if(n&&!r.first||!n&&!r.last||!n&&q.current===-1)return;let i=xh();if(i.length===0)return;if(e.preventDefault(),n){if(q.current===-1){ve.current=re;let e=i.length-1;q.current=e;let t=i[e];B(t),Be(t),requestAnimationFrame(()=>{let e=me.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];B(t),Be(t),requestAnimationFrame(()=>{let e=me.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];B(t),Be(t),requestAnimationFrame(()=>{let e=me.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else{q.current=-1;let e=ve.current;B(e),Be(e),requestAnimationFrame(()=>{let t=me.current;t&&(t.selectionStart=t.selectionEnd=e.length)})}}return}if(e.key===`Escape`&&q.current!==-1){e.preventDefault();let t=ve.current;q.current=-1,B(t),Be(t),requestAnimationFrame(()=>{let e=me.current;e&&(e.selectionStart=e.selectionEnd=t.length)});return}if(e.key===`Enter`){if(ng&&!e.shiftKey&&!(e.ctrlKey||e.metaKey))return;e.shiftKey||(e.preventDefault(),et())}}},rt=Xe&&(re.trim()!==``||s.length>0),it=(0,m.useMemo)(()=>Pi((w??[]).filter(e=>e.source!==`host`&&!e.hidden)),[w]),at=(0,m.useMemo)(()=>(C??[]).filter(e=>e.source!==`host`&&!e.hidden),[C]),st=w!==void 0,lt=(0,m.useMemo)(()=>Pi((w??[]).filter(e=>!e.hidden)),[w]),dt=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)(ge,{}):e.icon===`camera`?(0,X.jsx)(ot,{}):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)},ft=()=>(0,X.jsx)(`div`,{className:`inputbox-actions`,children:e?rt?(0,X.jsxs)(`div`,{className:`split-send${L?` single`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`split-queue`,title:F(`supplementTip`),"aria-label":F(`queueFollowTag`),onClick:()=>et(!0),children:(0,X.jsx)(Se,{})}),!L&&(0,X.jsx)(`button`,{type:`button`,className:`split-steer`,title:F(`steerTip`),"aria-label":F(`queueSteerTag`),onClick:()=>et(),children:(0,X.jsx)(ut,{})})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn stop`,title:F(`stopAgent`),onClick:()=>$({type:`abort`}),children:(0,X.jsx)(ie,{})}):(0,X.jsx)(`button`,{type:`button`,className:`btn send`,title:F(`sendTip`),disabled:!rt,onClick:()=>et(),children:(0,X.jsx)(ut,{})})}),pt={"host:composer-upload":(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:F(`uploadFile`),disabled:!Xe,onClick:()=>he.current?.click(),children:(0,X.jsx)(ue,{})}),"host:composer-templates":(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:F(`tpl.openPicker`),onClick:R,children:(0,X.jsx)(ct,{})}),"host:composer-model":(0,X.jsx)(Hh,{only:`model`,state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,defaultModel:y,compact:!0}),"host:composer-thinking":(0,X.jsx)(Hh,{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)(tg,{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)(Xh,{compact:!0,preset:k??null,presets:A,defaultPreset:j,blank:ee??!1,conversationId:M??``}):null,"host:composer-send":ft()},mt=e=>e.source===`host`?(0,X.jsx)(m.Fragment,{children:pt[e.id]??null},e.id):dt(e);return(0,X.jsxs)(`div`,{ref:Qe,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`,children:[s.map(e=>e.mode===`quote`&&e.quote?(0,X.jsx)(Ml,{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?F(`attachImage`,{name:e.name}):e.fileData?F(`attachFile`,{name:e.name}):e.isDir?F(`folderRef`,{path:e.path}):e.mode===`page`?F(`attachPage`,{name:e.name}):e.mode===`conversation`?F(`attachConversation`,{name:e.name}):e.mode===`reference`?F(`refOnly`,{path:e.path}):e.mode===`lines`&&e.lines?F(`attachLines`,{path:e.path,start:e.lines.start,end:e.lines.end}):F(`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:F(`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:F(`attachHint`)})]}),W&&W.items.length>0&&(0,X.jsxs)(`div`,{className:`slash-menu`,role:`listbox`,ref:_e,"aria-label":W.kind===`slash`?F(`slashCommands`):F(`atMentions`),"data-menu-kind":W.kind,children:[(0,X.jsxs)(`div`,{className:`slash-menu-hint`,children:[(0,X.jsx)(`span`,{children:W.kind===`slash`?F(`slashMenuHint`):F(`atMenuHint`)}),(0,X.jsx)(`span`,{className:`slash-menu-close`,onClick:()=>G(null),children:`Esc`})]}),W.kind===`slash`?Ue():We()]}),le&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>de(!1),children:(0,X.jsxs)(`div`,{className:`slash-help`,style:fe?{width:fe}:void 0,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`slash-help-head`,children:[(0,X.jsxs)(`span`,{children:[`⚡ `,F(`slashHelpTitle`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>de(!1),children:F(`close`)})]}),(0,X.jsx)(`div`,{className:`slash-help-body`,children:r.length===0?(0,X.jsx)(`div`,{className:`slash-help-empty`,children:F(`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:Le[e.source]}),(0,X.jsxs)(`span`,{className:`slash-help-desc`,children:[z(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:ne(e)})]})]},e.name))})]})}),x&&b.length>0&&(0,X.jsx)(`div`,{className:`quick-row`,"aria-label":F(`quickPhrases`),children:b.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`quick-chip`,title:`${F(`quickPhrasesTip`,{text:e})}(${F(`quickPhrasesSendTip`)})`,disabled:!Xe,onClick:()=>tt(e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),tt(e,!0)},children:e},e))}),(0,X.jsxs)(`div`,{className:`inputbox`,"data-pi-anchor":`composer`,children:[(0,X.jsx)(`div`,{className:`composer-resize`,title:F(`composerResize`),"aria-label":F(`composerResize`),role:`separator`,"aria-orientation":`horizontal`,"aria-valuenow":Math.round(V??ig),"aria-valuemin":rg,"aria-valuemax":ag,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId);let t=me.current?.getBoundingClientRect().height;U.current={startY:e.clientY,startH:typeof t==`number`&&Number.isFinite(t)?t:V??ig,next:null}},onPointerMove:e=>{let t=U.current;if(!t)return;let n=Math.min(ag,Math.max(rg,t.startH+(t.startY-e.clientY)));t.next=n,H(n)},onPointerUp:()=>{let e=U.current?.next;if(U.current=null,e!=null)try{localStorage.setItem(og,String(Math.round(e)))}catch{}},onPointerCancel:()=>{U.current=null},onDoubleClick:()=>{H(null);try{localStorage.removeItem(og)}catch{}}}),(0,X.jsx)(`input`,{ref:he,type:`file`,multiple:!0,hidden:!0,onChange:e=>{qe(e.target.files),e.target.value=``}}),(0,X.jsx)(`textarea`,{ref:me,value:re,rows:1,placeholder:F(Xe?e?L?`placeholderStreamingQueued`:`placeholderStreaming`:t?`placeholderPlanMode`:`placeholderIdle`:`placeholderConnecting`),disabled:!Xe,onChange:e=>{Fe(e.target.value,e.target.selectionStart??e.target.value.length)},onSelect:e=>{if(W?.kind===`at`){let t=e.target.selectionStart;(t<W.start||t>W.end)&&G(null)}},onCompositionEnd:()=>{je.current=Date.now()},onBlur:Y,onKeyDown:nt,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:F(`planModeTip`),children:[`📋 `,F(`planModeBadge`),` `,(0,X.jsx)(`span`,{style:{marginLeft:2,opacity:.7},children:`✕`})]}),(0,X.jsx)(`div`,{className:`composer-tools`,children:st?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[at.map(dt),lt.start.map(mt)]}),lt.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:lt.center.map(mt)}),(0,X.jsx)(`div`,{className:`composer-tools-right`,children:lt.end.map(mt)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[at.map(dt),(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:F(`uploadFile`),disabled:!Xe,onClick:()=>he.current?.click(),children:(0,X.jsx)(ue,{})}),it.start.map(dt),(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:F(`tpl.openPicker`),onClick:R,children:(0,X.jsx)(ct,{})}),(0,X.jsx)(Hh,{state:i,models:a,modelsLoading:o,onManageModels:_,providerKeys:v,defaultModel:y,compact:!0}),D&&D.length>0&&O!==void 0&&(0,X.jsx)(tg,{compact:!0,current:E??null,options:D,defaultPreset:O,conversationId:M??``}),A&&A.length>0&&j!==void 0&&(0,X.jsx)(Xh,{compact:!0,preset:k??null,presets:A,defaultPreset:j,blank:ee??!1,conversationId:M??``})]}),it.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:it.center.map(dt)}),(0,X.jsxs)(`div`,{className:`composer-tools-right`,children:[it.end.map(dt),ft()]})]})})]})]})}),cg=(0,m.memo)(function({goal:e,models:t,modelsLoading:n,activeConversationId:r,uiGoalbarActions:i,onUiAction:a}){let o=Z(),{locale:s}=wn(),c=s!==`zh`&&e.statusEn?e.statusEn:e.status||``,l=s!==`zh`&&e.wizard?.statusEn?e.wizard.statusEn:e.wizard?.status||``,u=ga(),d=!e.conversationId||e.conversationId===r,f=e.goal!==null&&d,p=d?e.roles?.executor:void 0,h=p?.convId,g=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,m.useState)(``),[w,T]=(0,m.useState)(e.reviewModel??``),[E,D]=(0,m.useState)(e.maxRounds),[O,k]=(0,m.useState)(e.locked),[A,j]=(0,m.useState)(e.execModel??``),[ee,M]=(0,m.useState)(!1),[P,F]=(0,m.useState)(!1),[I,te]=(0,m.useState)(!1),[R,z]=(0,m.useState)(!1),[ne,B]=(0,m.useState)(!0);(0,m.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,m.useEffect)(()=>{ee&&t.length===0&&!R&&!n&&(z(!0),$({type:`list_models`}))},[ee,t.length,R,n]),(0,m.useEffect)(()=>{t.length>0&&z(!1)},[t.length]);let V=()=>w?t.find(e=>e.id===w)?.name??w:o(`goalBarUseMainModel`),H=()=>A?t.find(e=>e.id===A)?.name??A:o(`goalBarUseMainModel`),U=()=>{let e=S.trim();e&&($({type:`set_goal`,goal:e,...w?{reviewModel:w}:{},maxRounds:E,locked:O,...A?{execModel:A}:{}}),C(``),B(!1))},W=()=>{let e=S.trim();$({type:`set_plan_mode`,enabled:!0}),e&&($({type:`prompt`,text:e}),C(``))},G=()=>{let e=S.trim();e&&($({type:`start_goal_wizard`,text:e,...w?{wizardModel:w}:{},maxRounds:E,locked:O}),C(``),B(!1))},ae=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),oe=e=>{let t=new Set(e);return ae.filter(e=>t.has(e.id)||e.source!==`host`)},se={"host:goal-pill":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-hint`,title:o(`goalBarPlaceholder`),onClick:()=>B(!1),children:[(0,X.jsx)(re,{}),` `,(0,X.jsx)(`span`,{children:o(`goalBarTitle`)})]}),"host:goal-set":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn`,disabled:!S.trim(),onClick:U,children:o(`goalBarSet`)}),"host:goal-wizard":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn action wizard`,disabled:!S.trim(),title:o(`goalWizardTip`),onClick:G,children: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:W,children: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)(be,{}):(0,X.jsx)(L,{})}),"host:goal-collapse":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarClear`),onClick:()=>B(!0),children:(0,X.jsx)(et,{})}),"host:goal-model":u?(0,X.jsx)(`p`,{className:`goalbar-dsh-note`,children:o(`dshNoReviewModel`)}):(0,X.jsxs)(Mt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:`${o(`goalBarReviewModel`)}: ${V()}`,children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${o(`goalBarReviewModel`)}:`}),(0,X.jsx)(`b`,{children:V()})]}),open:ee,onOpenChange:M,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarReviewModel`)}),(R||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!R&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(Nt,{active:w===``,onClick:()=>{T(``),M(!1),$({type:`set_goal_prefs`,reviewModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(Nt,{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: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)(Mt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,title:`${o(`goalBarExecModel`)}: ${H()} · ${o(`goalBarExecModelTip`)}`,children:[(0,X.jsx)(`span`,{className:`goalbar-opt-label`,children:`${o(`goalBarExecModel`)}:`}),(0,X.jsx)(`b`,{children:H()})]}),open:P,onOpenChange:F,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarExecModel`)}),(R||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!R&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(Nt,{active:A===``,onClick:()=>{j(``),F(!1),$({type:`set_goal_prefs`,execModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(Nt,{active:A===e.id,onClick:()=>{j(e.id),F(!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))]})},K=(e.wizard?.active??!1)&&d;if(K)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${K?`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`)}),cm(oe([`host:goal-clear`]),{...se,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),onClick:()=>{$({type:`clear_goal`}),B(!0)},children:(0,X.jsx)(N,{})})},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}),g&&(0,X.jsxs)(`span`,{className:`goalbar-detail`,title:p?.convId,children:[`· `,g]}),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`)}),cm(oe([`host:goal-openrole`,`host:goal-clear`]),{...se,"host:goal-openrole":h?(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarOpenExecTip`),onClick:()=>$({type:`switch_conversation`,id:h}),children:(0,X.jsx)(dt,{})}):null,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x${e.reviewing?` stopping`:``}`,title:e.reviewing?o(`goalBarStop`):o(`goalBarClear`),onClick:()=>{e.goal&&C(e.goal),$({type:`clear_goal`}),B(!1)},children:e.reviewing?(0,X.jsx)(ie,{}):(0,X.jsx)(N,{})})},a)]})});if(ne){let e=cm(oe([`host:goal-pill`]),se,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)(re,{})}),(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`&&U()}}),cm(oe([`host:goal-set`,`host:goal-wizard`,`host:goal-plan`,`host:goal-lock`,`host:goal-collapse`]),se,a)]}),(0,X.jsxs)(`div`,{className:`goalbar-opts`,children:[oe([`host:goal-model`,`host:goal-execmodel`,`host:goal-rounds`]).filter(e=>e.source===`host`).map(e=>(0,X.jsx)(m.Fragment,{children:se[e.id]},e.id)),e.history&&e.history.length>0&&(0,X.jsxs)(Mt,{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:I,onOpenChange:te,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalHistory`)}),e.history.map((e,t)=>(0,X.jsx)(Nt,{onClick:()=>{C(e.goal),te(!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 lg(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 ug=2e3;function dg(e,t,n=ug){return e.filter(e=>t-e.t<=n)}function fg(e,t=ug){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 pg(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 mg(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=pg(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=pg(n.thinking));return t}var hg=[{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 gg({chat:e,bottombarItems:t,onUiAction:n,onOpenSettings:r,onViewChange:i,onOpenGlobalSearch:a,onOpenBgTasks:o}){let s=Z(),{engine:c}=ma(),l=ha(`workspaceRoots`),u=e.state,[d,f]=(0,m.useState)(!1),p=(0,m.useRef)([]),h=u?.isStreaming??!1,g=u?.streamingMessage?mg(u.streamingMessage.content):0;if((0,m.useEffect)(()=>{if(!h){p.current=[];return}let e=Date.now(),t=p.current,n=t[t.length-1];n&&e-n.t<250||(p.current=dg([...t,{t:e,out:g}],e))},[h,g]),!u)return null;let _=u.stats,v=lg(_.tokens),y=v.hitRate*100,b=v.totalInput===0?``:v.hitRate>=.7?`ok`:v.hitRate>=.4?`mid`:`warn`,x=v.totalInput>0?`${y.toFixed(1)}%`:`—`,S=h?fg(p.current):0,C=e.ready?`ok`:e.status===`closed`?`error`:`busy`,w=e.ready?s(`connected`):e.status===`closed`?s(`reconnecting`):s(`connecting`),T=_.contextUsage,E=T.softCap??null,D=E!==null&&E>0&&E<T.contextWindow,O=D?E:T.contextWindow,k=T.tokens!==null&&O>0?Math.min(100,Math.round(T.tokens/O*100)):null,A=T.tokens!==null&&k!==null?`${_g(T.tokens)} / ${_g(O)}`:`—`,j=k===null?``:k>=80?`warn`:k>=50?`mid`:`ok`,ee=u.queue.steering.length+u.queue.followUp.length,M={"host:conn":(0,X.jsxs)(`span`,{className:`status-item status-conn ${C}`,title:w,children:[(0,X.jsx)(`span`,{className:`status-dot ${C}`}),(0,X.jsx)(`span`,{className:`status-conn-label`,children:w})]}),"host:engine":c===`pi`?null:(0,X.jsx)(`span`,{className:`status-item engine-badge engine-${c}`,title:`${s(`engineBadge`)}: ${c}`,children:c===`dsh`?`DSH`:c}),"host:ctx":(()=>{let e=D?`${s(`contextUsage`)}: ${_g(T.tokens??0)} / ${_g(E)} (${s(`softCapMarker`)}, max ${_g(T.contextWindow)})`:E!==null&&E>0?`${s(`contextUsage`)} · ${s(`softCapMarker`)}: ${_g(E)}`:s(`contextUsage`);return(0,X.jsxs)(`span`,{className:`status-item status-ctx`,title:e,children:[(0,X.jsx)(`span`,{className:`ctx-label`,children:s(`context`)}),(0,X.jsx)(`span`,{className:`ctx-bar ${j}`,children:k!==null&&(0,X.jsx)(`span`,{className:`ctx-bar-fill`,style:{width:`${Math.min(k,100)}%`}})}),A]})})(),"host:cost":(0,X.jsxs)(`span`,{className:`status-item status-cost`,title:s(`cumulativeCost`),children:[`$`,vg(_.cost)]}),"host:cache":(0,X.jsxs)(`span`,{className:`status-item status-cache`,title:s(`cacheHitTip`,{read:_g(v.read),write:_g(v.write),miss:_g(v.miss),input:_g(v.totalInput)}),children:[(0,X.jsx)(`span`,{className:`status-cache-label`,children:s(`cacheHit`)}),(0,X.jsx)(`b`,{className:`cache-pct ${b}`,children:x})]}),"host:msg-count":(0,X.jsxs)(`span`,{className:`status-item`,title:s(`sessionMessages`),children:[s(`messages`),` `,_.totalMessages]}),"host:plugin-status":e.statuses.length>0?(0,X.jsx)(`span`,{className:`status-item ext-status`,title:s(`pluginStatus`),children:e.statuses.map(e=>e.text).join(` · `)}):null,"host:working":u.isStreaming?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`status-item working`,children:[(0,X.jsx)(`span`,{className:`working-spin`}),s(`working`),ee>0&&(0,X.jsxs)(`span`,{className:`status-queue`,children:[`⏳ `,ee,` `,s(`queued`)]})]}),(0,X.jsxs)(`span`,{className:`status-item status-rate`,title:s(`rateTip`),children:[(0,X.jsx)(`span`,{className:`working-spin rate-spin`}),S>0?`${Math.round(S)}${s(`tps`)}`:`…`]})]}):null,"host:status-delegate":u?.delegateMode?(0,X.jsxs)(`span`,{className:`status-item delegate-badge`,title:u.delegateConvId?s(`delegateModeOpenTip`):s(`delegateModeBadgeTip`),children:[`🔎 `,s(`delegateModeBadge`),u.delegateConvId?(0,X.jsx)(`button`,{type:`button`,className:`delegate-badge-open`,title:s(`delegateModeOpenTip`),onClick:()=>$({type:`switch_conversation`,id:u.delegateConvId}),children:`↗`}):null]}):null,"host:host-metrics":(()=>{let t=e.hostMetrics;if(!t)return null;let n=t.cpuPercent===null||!Number.isFinite(t.cpuPercent)?`—`:`${Math.round(t.cpuPercent)}%`,r=Number.isFinite(t.memoryPercent)?`${Math.round(t.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`status-item status-host-metrics`,title:`${s(`hostResourcesTip`)}\n${s(`hostProcessor`)}: ${n} · ${s(`hostMemory`)}: ${r}`,children:[s(`hostProcessor`),` `,n,` · `,s(`hostMemory`),` `,r]})})(),"host:cwd":d?(0,X.jsx)(Ea,{currentCwd:u.cwd,pathCompletions:e.pathCompletions,workspaceRoots:l,onClose:()=>f(!1),onSelectDirectory:e=>{e&&e!==u.cwd&&$({type:`set_cwd`,path:e}),f(!1)},mode:`folder`}):(0,X.jsxs)(`button`,{type:`button`,className:`status-item status-cwd`,title:s(`cwdTip`,{path:u.cwd}),onClick:()=>f(!0),children:[`📁 `,u.cwd]}),"host:new-chat":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`newChat`),onClick:()=>{i?.(`chat`),$({type:`new_chat`}),Qn()},children:[(0,X.jsx)(ce,{}),` `,s(`newChat`)]}),"host:settings":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`settings`),onClick:()=>r?.(),children:[(0,X.jsx)(U,{}),` `,s(`settings`)]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`searchGlobal`),onClick:()=>a?.(),children:[(0,X.jsx)(G,{}),` `,s(`searchGlobal`)]}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`bgTasks`),onClick:()=>o?.(),children:[(0,X.jsx)(we,{}),` `,s(`bgTasks`),e.bgServers.length>0&&(0,X.jsx)(`span`,{className:`status-badge`,children:e.bgServers.length})]}),"host:chat":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`chat`),onClick:()=>i?.(`chat`),children:[(0,X.jsx)(_e,{}),` `,s(`chat`)]}),"host:terminal":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`terminal`),onClick:()=>i?.(`terminal`),children:[(0,X.jsx)(ne,{}),` `,s(`terminal`)]}),"host:git":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`scmTab`),onClick:()=>i?.(`git`),children:[(0,X.jsx)(je,{}),` `,s(`scmTab`)]}),"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:s(`pluginMenuTitle`),onClick:()=>r?.(),children:[(0,X.jsx)(st,{}),` `,s(`pluginMenuTitle`)]})},N=(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}})},o=()=>{let e=new Set(i?.hidden??[]);e.add(n),$({type:`set_settings`,uiLayout:{...i,hidden:[...e]}})},c=[{id:`host:move-top`,slot:`contextmenu.topbar`,source:`host`,label:s(`moveToTop`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:s(`moveToLeft`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:s(`moveToRight`),kind:`action`,order:30,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:s(`uiLayoutRestore`),kind:`action`,order:40,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]}];Wi({x:t.clientX,y:t.clientY,slot:`contextmenu.topbar`,target:{id:n,label:r},entries:c,onHostAction:e=>{e.id===`host:move-top`?a(`topbar.primary`):e.id===`host:move-left`?a(`sidebar.left`):e.id===`host:move-right`?a(`sidebar.right`):e.id===`host:hide-item`&&o()}})},P=t?t.map(e=>({id:e.id,entry:e,fallbackAlign:`start`})):hg.map(({id:e,align:t})=>({id:e,entry:null,fallbackAlign:t})),F=[],I=[],L=[];for(let{id:e,entry:t,fallbackAlign:r}of P){if(t?.hidden)continue;let i=null;if(e.startsWith(`host:`)?i=M[e]:t&&(i=t.kind===`select`&&t.options?.length?(0,X.jsx)(`select`,{className:`status-select`,title:t.hint??t.label,"aria-label":t.label,value:t.options.some(e=>e.value===t.value)?t.value:t.options[0].value,onChange:e=>n?.(t,e.target.value),children:t.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,X.jsxs)(`button`,{type:`button`,className:`status-action`,title:t.hint??t.label,onClick:()=>n?.(t),children:[t.icon?`${t.icon} `:``,t.label,t.badge?(0,X.jsx)(`span`,{className:`status-badge`,children:t.badge}):null]})),!i)continue;let a=(0,X.jsx)(`span`,{className:`status-item-wrap`,onContextMenu:n=>N(n,e,t?.label??e),children:i},e),o=t?.align??r;o===`end`?L.push({key:e,node:a}):o===`center`?I.push({key:e,node:a}):F.push({key:e,node:a})}let te=e=>e.map((e,t)=>(0,X.jsxs)(m.Fragment,{children:[t>0&&(0,X.jsx)(`span`,{className:`status-sep`,children:`·`}),e.node]},e.key));return(0,X.jsxs)(`footer`,{className:`statusbar`,children:[(0,X.jsx)(`div`,{className:`statusbar-left`,children:te(F)}),I.length>0&&(0,X.jsx)(`div`,{className:`statusbar-center`,children:te(I)}),(0,X.jsx)(`div`,{className:`statusbar-right`,children:te(L)})]})}function _g(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function vg(e){return e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}var yg=[{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}],bg=`__tray`,xg=[`start`,`center`,`end`];function Sg(e,t){return e(t===`start`?`uiLayoutAlignTop`:t===`end`?`uiLayoutAlignBottom`:`uiLayoutAlignMiddle`)}function Cg(e,t=new Set){let n={},r=[],i=new Set;for(let a of yg){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 wg(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 Tg(e){return(e??[]).filter(e=>!e.hidden)}function Eg(e,t){let n=Tg(e);return t===void 0?n:n.filter(e=>(e.align??`start`)===t)}function Dg(e){return[...new Set(e)]}function Og(e,t,n){let r=e??{},i=wg(t,n.id);if(!i)return r;let a={...r};i.hidden&&(a.hidden=(r.hidden??[]).filter(e=>e!==n.id),a.shown=Dg([...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=Tg(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=Dg([...(r.order??[]).filter(e=>!p.has(e)&&e!==n.id),...u,...f]),a}function kg(e,t){let n=e??{};return{...n,hidden:Dg([...n.hidden??[],t]),shown:(n.shown??[]).filter(e=>e!==t)}}function Ag({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:h}=wn(),[g,_]=(0,m.useState)(!1),v=(0,m.useRef)(null),y=n.settings?.uiLayout,b=y?.sideDockFloat===!0,x=b?` side-dock-float`:``,S=(t,n)=>{t.preventDefault(),t.stopPropagation();let r=e=>{let t={...y?.slots,[n.id]:e};$({type:`set_settings`,uiLayout:{...y,slots:t}})},i=()=>{let e=new Set(y?.hidden??[]);e.add(n.id),$({type:`set_settings`,uiLayout:{...y,hidden:[...e]}})},a=[{id:`host:move-top`,slot:`contextmenu.topbar`,source:`host`,label:h(`moveToTop`),kind:`action`,order:10,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-bottom`,slot:`contextmenu.topbar`,source:`host`,label:h(`moveToBottom`),kind:`action`,order:20,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},{id:`host:move-left`,slot:`contextmenu.topbar`,source:`host`,label:h(`moveToLeft`),kind:`action`,order:30,align:`start`,hidden:e===`left`,userOverrides:[],arrangedBy:[]},{id:`host:move-right`,slot:`contextmenu.topbar`,source:`host`,label:h(`moveToRight`),kind:`action`,order:40,align:`start`,hidden:e===`right`,userOverrides:[],arrangedBy:[]},{id:`host:hide-item`,slot:`contextmenu.topbar`,source:`host`,label:h(`uiLayoutRestore`),kind:`action`,order:50,align:`start`,hidden:!1,userOverrides:[],arrangedBy:[]},...u??[]];Wi({x:t.clientX,y:t.clientY,slot:`contextmenu.topbar`,target:{id:n.id,label:n.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()}})},C=e=>{switch(e.id){case`host:new-chat`:i(`chat`),$({type:`new_chat`}),Qn();break;case`host:new-ephemeral-chat`:i(`chat`),$({type:`new_chat`,ephemeral:!0}),Qn();break;case`host:chat`:i(`chat`);break;case`host:terminal`:i(`terminal`);break;case`host:git`:i(`git`);break;case`host:open-project`:d?.();break;case`host:history`:a(`left`);break;case`host:files`:a(`right`);break;case`host:search`:c();break;case`host:tasks`:s();break;case`host:settings`:o();break;case`host:plugins`:o(`plugins`);break;case`host:sound`:p?.();break;case`host:theme`:f?.();break;case`host:update`:$({type:`check_update`}),$({type:`check_updates_all`});break;case`host:github`:window.open(`https://github.com/xing-shuyin/pi-web-ui`,`_blank`,`noreferrer,noopener`);break;default:e.view?i(e.view):l?.(e)}},w=e=>{switch(e.id){case`host:brand`:return(0,X.jsx)(`span`,{className:`side-dock-brand`,children:`π`});case`host:open-project`:return(0,X.jsx)(Ne,{});case`host:history`:return(0,X.jsx)(q,{});case`host:files`:return(0,X.jsx)(Me,{});case`host:new-chat`:return(0,X.jsx)(ce,{});case`host:new-ephemeral-chat`:return(0,X.jsx)(yt,{});case`host:chat`:return(0,X.jsx)(_e,{});case`host:terminal`:return(0,X.jsx)(ne,{});case`host:git`:return(0,X.jsx)(je,{});case`host:plugins`:return(0,X.jsx)(st,{});case`host:search`:return(0,X.jsx)(G,{});case`host:browser`:return(0,X.jsx)(ke,{});case`host:tasks`:return(0,X.jsx)(we,{});case`host:settings`:return(0,X.jsx)(U,{});case`host:sound`:return(0,X.jsx)(P,{});case`host:language`:return(0,X.jsx)(ke,{});case`host:theme`:return(0,X.jsx)(B,{});case`host:update`:return(0,X.jsx)(ze,{});case`host:github`:return(0,X.jsx)(Ae,{});case`host:conn`:return(0,X.jsx)(`span`,{className:`status-dot ok`});case`host:engine`:return(0,X.jsx)(Ue,{});case`host:ctx`:return(0,X.jsx)(vt,{});case`host:cost`:return(0,X.jsx)(`span`,{className:`side-dock-char`,children:`$`});case`host:cache`:return(0,X.jsx)(qe,{});case`host:msg-count`:return(0,X.jsx)(`span`,{className:`side-dock-char`,children:`#`});case`host:cwd`:return(0,X.jsx)(Me,{});default:return e.iconSvg||e.icon?(0,X.jsx)(ni,{icon:e.icon,iconSvg:e.iconSvg}):(0,X.jsx)(ht,{})}},T=t.filter(e=>!e.hidden);if(T.length===0)return null;if(b&&g)return(0,X.jsx)(`div`,{ref:v,className:`side-dock side-dock-${e} side-dock-collapsed${x}`,children:(0,X.jsx)(`button`,{type:`button`,className:`side-dock-btn side-dock-toggle-btn`,"data-tip":`${h(`sideDockExpand`)} (${T.length})`,onClick:()=>_(!1),"aria-label":h(`sideDockExpand`),children:e===`left`?(0,X.jsx)(tt,{}):(0,X.jsx)(nt,{})})});let E=Pi(T),D=e=>{let t=e.id===`host:chat`&&r===`chat`||e.id===`host:terminal`&&r===`terminal`||e.id===`host:git`&&r===`git`||e.view&&r===e.view;return(0,X.jsxs)(`button`,{type:`button`,className:`side-dock-btn${t?` active`:``}`,"data-tip":e.hint??e.label,onClick:()=>C(e),onContextMenu:t=>S(t,e),"aria-label":e.label,children:[w(e),e.id===`host:tasks`&&n.bgServers.length>0&&(0,X.jsx)(`span`,{className:`side-dock-badge`,children:n.bgServers.length})]},e.id)};return(0,X.jsxs)(`div`,{ref:v,className:`side-dock side-dock-${e}${x}`,children:[b&&(0,X.jsx)(`button`,{type:`button`,className:`side-dock-btn side-dock-collapse-btn`,"data-tip":h(`sideDockCollapse`),onClick:()=>_(!0),"aria-label":h(`sideDockCollapse`),children:e===`left`?(0,X.jsx)(nt,{}):(0,X.jsx)(tt,{})}),xg.map(e=>(0,X.jsx)(`div`,{className:`side-dock-slot side-dock-slot-${e}`,children:E[e].length>0&&(0,X.jsx)(`div`,{className:`side-dock-seg`,children:E[e].map(D)})},e))]})}function jg({dialog:e}){let t=Z(),[n,r]=(0,m.useState)(``),[i,a]=(0,m.useState)(0),o=t=>{$({type:`dialog_response`,id:e.id,value:t})};(0,m.useEffect)(()=>{r(``),a(0)},[e.id]),At(()=>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)(Ku,{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)(Ku,{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 Mg=150;function Ng({anchorRef:e,enabled:t=!0,className:n,children:r}){let i=(0,m.useRef)(null),a=(0,m.useRef)(null),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)({left:0,top:0}),u=(0,m.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},[]),d=(0,m.useCallback)(()=>{u(),a.current=setTimeout(()=>s(!1),Mg)},[u]);return(0,m.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,m.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,m.useLayoutEffect)(()=>{if(!o)return;let t=i.current,n=e.current;if(!t||!n)return;let r=Yc(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,m.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,k.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}function Pg({question:e,owner:t,conversationTitle:n}){let r=Z(),i=e.conversationTitle||n,[a,o]=(0,m.useState)({}),[s,c]=(0,m.useState)({}),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(0),[p,h]=(0,m.useState)(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);(0,m.useEffect)(()=>{o({}),c({}),f(0),u(!1);let n=e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1;h(n),e.deadline&&n<=0&&$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},[e.id,e.deadline,t]),(0,m.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&&$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}}),r})},1e3);return()=>clearInterval(n)},[e.id,e.deadline]);let g=()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})};At(()=>{g()},!l);let _=(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))},v=e.questions.filter(e=>_(e,a)),y=v.length;(0,m.useEffect)(()=>{if(e.questions.length===0||y>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,y,t]);let b=Math.min(d,Math.max(0,y-1)),x=v[b];if(!x)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:g,children:`✕`})]}),(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-hint`,children:r(`questionNoneAvailable`)})})]});let S=(()=>{if(!x)return[];if(x.optionsMap&&x.dependsOn){let e=a[x.dependsOn.questionId]??[];for(let t of e)if(x.optionsMap[t])return x.optionsMap[t]}return x.options??[]})(),C=n=>{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}:{}})},w=(e,t)=>{o(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},T=(t,n,r)=>{if(r){w(t,n);return}let i={...a,[t]:[n]};o(i);let s=e.questions.filter(e=>_(e,i));b>=s.length-1?C(i):f(b+1)},E=()=>{b>=y-1?C(a):f(b+1)},D=t=>{let n=e.questions.find(e=>e.id===t);return S.length===0&&(n?.options?.length??0)===0||(a[t]?.length??0)>0||(s[t]??``).trim()!==``},O=S.filter(e=>(a[x.id]??[]).includes(e.label)&&e.preview).map(e=>e.preview),k=(x.header||x.question).replace(/\s+/g,` `).trim();return(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}),y>1&&(0,X.jsx)(`span`,{className:`question-progress`,children:r(`questionStep`,{cur:b+1,total:y})}),p>=0&&(0,X.jsx)(`span`,{className:`question-timer`,children:p>0?r(`questionTimeout`,{s:p}):r(`questionTimeoutExpired`)}),l&&(0,X.jsx)(`span`,{className:`question-collapsed-preview`,title:k,children:k}),(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)(et,{}):(0,X.jsx)(rt,{})}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:e=>{e.stopPropagation(),g()},children:`✕`})]})]}),!l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,children:x.header??`${r(`modelQuestion`)} ${b+1}`}),(0,X.jsx)(`div`,{className:`question-head`,children:(0,X.jsx)(Ku,{text:x.question,rawHtml:!0})}),x.detail&&(0,X.jsx)(`div`,{className:`set-hint`,children:(0,X.jsx)(Ku,{text:x.detail,rawHtml:!0})}),S.length>0&&(0,X.jsx)(`div`,{className:`set-list`,children:S.map(e=>{let t=(a[x.id]??[]).includes(e.label);return(0,X.jsx)(Fg,{label:e.label,description:e.description,mark:x.multiSelect?t?`☑ `:`☐ `:t?`● `:`○ `,active:t,onPick:()=>T(x.id,e.label,!!x.multiSelect)},e.label)})}),O.length>0&&(0,X.jsxs)(`div`,{className:`question-preview`,children:[(0,X.jsx)(`div`,{className:`question-preview-label`,children:r(`optionPreview`)}),O.map((e,t)=>(0,X.jsx)(`div`,{className:`question-preview-body`,children:(0,X.jsx)(Ku,{text:e,rawHtml:!0})},t))]}),(0,X.jsx)(`input`,{className:`set-prompt-input question-custom`,placeholder:r(`modelQuestionCustom`),value:s[x.id]??``,onChange:e=>c(t=>({...t,[x.id]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D(x.id)&&E())}})]},x.id),(0,X.jsxs)(`div`,{className:`dialog-nav`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss-inline`,onClick:g,children:r(`cancel`)}),(0,X.jsxs)(`div`,{className:`dialog-nav-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-prev`,disabled:b===0,onClick:()=>f(b-1),children:r(`previous`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-submit`,disabled:!D(x.id),onClick:E,children:b===y-1?r(`modelQuestionSubmit`):r(`next`)})]})]})]})]})}function Fg({label:e,description:t,mark:n,active:r,onPick:i}){let a=(0,m.useRef)(null);return(0,X.jsxs)(`button`,{type:`button`,ref:a,className:`set-row question-option${r?` active`:``}`,onClick:i,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[(0,X.jsx)(`span`,{className:`question-mark`,children:n}),(0,X.jsx)(Ku,{text:e,rawHtml:!0})]}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-desc`,children:(0,X.jsx)(Ku,{text:t,rawHtml:!0})}),(0,X.jsx)(Ng,{anchorRef:a,enabled:Xc(),className:`question-desc-tip`,children:(0,X.jsx)(Ku,{text:t,rawHtml:!0})})]})]})}var Ig=e=>`'${e.replace(/'/g,`'\\''`)}'`,Lg=`pi-web-ui:scm-sidebar-width`;function Rg(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 zg(e){return e===null||e.trim()===``?300:Rg(Number(e))}function Bg(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 Vg(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>Bg(e,t)))}var Hg=`scm-commit-history`;function Ug(e=localStorage){try{let t=e.getItem(Hg);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Wg(e,t=localStorage){let n=e.trim();if(!n)return Ug(t);let r=[n,...Ug(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(Hg,JSON.stringify(r))}catch{}return r}var Gg={idx:-1,draft:``};function Kg(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:Gg,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}function qg(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 Jg({chat:e,terminal:t,active:n,onSwitchToTerminal:r,uiScmToolbar:i,onUiAction:a}){let o=Z(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)([]),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(new Map),[g,_]=(0,m.useState)(`changes`),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(null),[S,C]=(0,m.useState)(``),[w,T]=(0,m.useState)(!1),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(null),[A,j]=(0,m.useState)(!1),[ee,M]=(0,m.useState)(!1),[N,P]=(0,m.useState)(!1),[F,I]=(0,m.useState)(null),[L,te]=(0,m.useState)(!1),[R,z]=(0,m.useState)(!1),[re,B]=(0,m.useState)(null),[ie,V]=(0,m.useState)(()=>zg(localStorage.getItem(Lg))),[H,U]=(0,m.useState)(``),[W,G]=(0,m.useState)(``),[ae,oe]=(0,m.useState)(()=>Ug()),se=(0,m.useRef)(Gg),ce=(0,m.useRef)(0),le=(0,m.useRef)(-1),ue=(0,m.useRef)(-1),de=(0,m.useRef)(-1),fe=(0,m.useRef)(-1),pe=(0,m.useRef)(-1),me=(0,m.useRef)(void 0),he=(0,m.useRef)(null),ge=(0,m.useRef)([]),_e=(0,m.useRef)(ie);_e.current=ie;let q=(0,m.useRef)(null),ve=(0,m.useCallback)(e=>{try{localStorage.setItem(Lg,String(e))}catch{}},[]),ye=(0,m.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=_e.current,r=q.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=Rg(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,m.useCallback)(()=>{V(300),ve(300)},[ve]),xe=(0,m.useCallback)(e=>{if(e.reqId===le.current){if(le.current=-1,M(!1),I(null),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}if(e.notRepo){te(!0),c(null),u([]),h(new Map),y([]),x(null),C(``),k(null);return}te(!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),h(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===ue.current){if(ue.current=-1,j(!1),!e.ok){I(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===fe.current){if(fe.current=-1,P(!1),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}y((e.history??[]).map(e=>({...e})))}else if(e.reqId===de.current){if(de.current=-1,T(!1),!e.ok){I(e.error??o(`scmQueryFailedShort`));return}C(e.text??``)}else if(e.reqId===pe.current){if(pe.current=-1,z(!1),!e.ok){B(e.error??o(`scmGenMsgFail`));return}B(null),U(e.text??``)}},[]);(0,m.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&xe(t)},[e.scmData,xe]);let Se=(0,m.useCallback)((t,n)=>{if(!e.ready||e.status!==`open`)return!1;let r=++ce.current;return $({...t,reqId:r})?(n.current=r,!0):(--ce.current,!1)},[e.ready,e.status]),Ce=(0,m.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([]),h(new Map),y([]),G(``),P(!1),fe.current=-1,x(null),C(``),k(null),D(null),B(null),z(!1),pe.current=-1),me.current=e.state.cwd,I(null),Se({type:`scm_status`},le)&&(n||M(!0)))},[e.ready,e.state?.cwd,e.status,Se]),we=(0,m.useCallback)(e=>{if(D(e),x(null),he.current=e,e.x===`?`&&e.y===`?`){k({file:e,staged:``,worktree:``,untracked:!0});return}j(!0),I(null),Se({type:`scm_filediff`,path:e.path},ue)||j(!1)},[Se]),Te=(0,m.useCallback)(e=>{x(e),D(null),k(null),C(``),T(!0),I(null),Se({type:`scm_commit`,hash:e.hash},de)||T(!1)},[Se]),J=(0,m.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=St(),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,m.useCallback)(()=>{let e=H.trim();if(!e||L)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);J(`git commit`,`git commit -m "${t}"`),oe(Wg(e)),U(``),se.current=Gg},[H,L,J]),De=(0,m.useCallback)(()=>{let e=H.trim();if(!e||L)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);J(`git commit`,`git add -A && git commit -m "${t}"`),oe(Wg(e)),U(``),se.current=Gg},[H,L,J]),Oe=(0,m.useCallback)(e=>{L||J(`git add`,`git add -- ${Ig(e.path)}`)},[L,J]),ke=(0,m.useCallback)(e=>{L||J(`git reset`,`git reset HEAD -- ${Ig(e.path)}`)},[L,J]),Ae=(0,m.useCallback)(()=>{if(!d||L)return;let e=l.find(e=>e.name===d);if(e?.remote&&typeof e.remote==`string`){let t=d.slice(e.remote.length+1);J(`git checkout`,`git checkout -b ${t} ${d} || git checkout ${d}`)}else J(`git checkout`,`git checkout ${d}`)},[d,l,L,J]),Me=(0,m.useCallback)(()=>J(`git push`,`git push`),[J]),Ne=(0,m.useCallback)(()=>J(`git pull`,`git pull`),[J]),Y=(0,m.useCallback)(()=>{R||L||!e.ready||e.status!==`open`||(B(null),Se({type:`scm_commitmsg`},pe)?z(!0):B(o(`scmGenMsgFail`)))},[R,L,e.ready,e.status,Se,o]),Pe=(0,m.useCallback)(()=>{Se({type:`scm_history`},fe)||(fe.current=-1)},[Se]);(0,m.useEffect)(()=>{n&&Ce()},[n,Ce]),(0,m.useEffect)(()=>{g===`history`&&s&&Pe()},[g,s,Pe]),(0,m.useEffect)(()=>{e.scmDirty>0&&n&&Ce(!1,!0)},[e.scmDirty]),(0,m.useEffect)(()=>{if(!n||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&Ce(!1,!0)},3e4);return()=>clearInterval(t)},[n,e.ready,e.status,Ce]),(0,m.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`&&(Ce(!1,!0),g===`history`&&s&&Pe())},[e.terminals,n,e.ready,e.status,Ce,g,s,Pe]);let Fe={staged:o(`scmStaged`),unstaged:o(`scmUnstaged`),untracked:o(`scmUntracked`),both:o(`scmStagedUnstaged`)},Ie=Vg(v,W),Le=e=>{let t=e.split(`
|
|
358
|
+
`);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)})})},Re=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),ze=[`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`],Be=(e,t)=>{let n=new Set(e);return Re.filter(e=>n.has(e.id)||t&&e.source!==`host`)},Ve=e=>i===void 0||!i.some(t=>t.id===e&&t.hidden),He={"host:scm-changes":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`changes`,className:g===`changes`?`active`:``,onClick:()=>{_(`changes`),I(null)},children:o(`scmChanges`)}),"host:scm-history":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`history`,className:g===`history`?`active`:``,onClick:()=>{_(`history`),I(null)},children:o(`scmHistory`)}),"host:scm-refresh":(0,X.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:o(`scmRefreshTip`),disabled:ee,onClick:()=>Ce(!0),children:(0,X.jsx)(K,{className:ee?`scm-spin`:``})}),"host:scm-branch":(0,X.jsxs)(`select`,{className:`scm-select`,value:d,disabled:L||l.length===0,title: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||L,title:o(`scmSwitchBranchTip`,{branch:d}),onClick:Ae,children:[(0,X.jsx)(je,{}),o(`scmSwitch`)]}),"host:scm-push":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||L,title:o(`scmPushTip`),onClick:Me,children:[(0,X.jsx)(ut,{}),o(`scmPush`)]}),"host:scm-pull":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||L,title:o(`scmPullTip`),onClick:Ne,children:[(0,X.jsx)(pt,{}),o(`scmPull`)]}),"host:scm-input":(0,X.jsx)(`input`,{className:`scm-commit-input`,value:H,placeholder:o(`scmCommitPlaceholder`),disabled:L,title:ae.length>0?o(`scmCommitHistoryTip`):void 0,onChange:e=>{U(e.target.value),se.current=Gg},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){Ee();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=Kg(ae,se.current,H,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),se.current=t.state,U(t.text))}}}}),"host:scm-genmsg":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:R||L||!s||s.files.length===0,title:o(`scmGenMsgTip`),onClick:Y,children:[(0,X.jsx)(Ue,{className:R?`scm-spin`:``}),o(R?`scmGenMsgRunning`:`scmGenMsg`)]}),"host:scm-commit":(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!H.trim()||L,title:o(`scmCommitTip`),onClick:Ee,children:[(0,X.jsx)(it,{}),o(`scmCommit`)]}),"host:scm-commit-all":(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!H.trim()||L,title:o(`scmCommitAllTip`),onClick:De,children: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)(je,{}),o(`scmTitle`)]}),(0,X.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:cm(Be([`host:scm-changes`,`host:scm-history`],!1),He,a)}),cm(Be([`host:scm-refresh`],!0),He,a)]}),(0,X.jsxs)(`div`,{className:`scm-row`,children:[(0,X.jsxs)(`span`,{className:`scm-branch-current`,title:o(`scmCurrentBranch`),children:[(0,X.jsx)(je,{}),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})]}),cm(Be(ze,!1),He,a)]}),re&&(0,X.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:o(`close`),onClick:()=>B(null),children:re})]}),(0,X.jsxs)(`div`,{className:`scm-body`,ref:q,style:{"--scm-sidebar-w":`${ie}px`},children:[g===`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:W.trim()?`${Ie.length}/${v.length}`:v.length})]}),v.length>0&&!L&&(0,X.jsx)(`input`,{className:`scm-history-filter`,value:W,placeholder:o(`scmHistoryFilterPlaceholder`),title:o(`scmHistoryFilterTip`),onChange:e=>G(e.target.value)}),(0,X.jsx)(`div`,{className:`scm-history-list`,children:L?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):!s||N?(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:()=>Te(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:L?(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=qg(e),n=p.get(e.path);return(0,X.jsxs)(`div`,{className:`scm-file ${E?.path===e.path?`active`:``}`,title:Fe[t],onClick:()=>we(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:g===`history`?b?`${b.shortHash} ${b.subject}`:o(`scmCommitDetail`):E?E.path:o(`scmDiff`)}),(g===`history`?w:A)&&(0,X.jsx)(`span`,{className:`scm-diff-loading`,children:o(`scmLoading`)})]}),(0,X.jsx)(`div`,{className:`scm-diff-body`,children:g===`history`?(0,X.jsxs)(X.Fragment,{children:[F&&(0,X.jsx)(`div`,{className:`scm-error`,children:F}),!b&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectCommitHint`)}),b&&w&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),b&&!w&&!F&&S?Le(S):null]}):(0,X.jsxs)(X.Fragment,{children:[F&&(0,X.jsx)(`div`,{className:`scm-error`,children:F}),!E&&!F&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectFileHint`)}),E&&!O&&!F&&(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`)}),Le(O.staged)]}),O.worktree&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmUnstaged`)}),Le(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)(ne,{}),(0,X.jsx)(`span`,{children:o(`scmRunsInTerminal`)}),Ve(`host:scm-term`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:r,children:o(`scmViewTerminal`)})]})]})}function Yg({entry:e}){let t=(0,m.useRef)(null),n=Z();return(0,m.useEffect)(()=>{let r=t.current;if(!r)return;let i;try{i=e.module.mount(r,Ls(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 Xg({pluginId:e,info:t,epoch:n,failed:r}){let i=Z(),[a,o]=(0,m.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),Ds(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 Zg({onAction:e}){let t=Ji(),n=(0,m.useMemo)(()=>t?ta(t.entries):[],[t]),{items:r,selectParents:i}=(0,m.useMemo)(()=>ea(n),[n]),a=(0,m.useMemo)(()=>na(r),[r]),o=(0,m.useMemo)(()=>t?Zi(t.slot,t.target):void 0,[t,t?.slot,t?.target.kind]),s=(0,m.useRef)(null),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(-1),[p,h]=(0,m.useState)(-1),[g,_]=(0,m.useState)(!1),[v,y]=(0,m.useState)(0),b=(0,m.useRef)(-1),x=e=>{b.current=e,f(e)},S=(0,m.useMemo)(()=>p>=0?ta(r[p]?.children??[]):[],[r,p]),C=(0,m.useMemo)(()=>na(S),[S]),w=e=>{let n=r[e];if(t&&n&&!$i(n,o)){if(n.children?.length){h(e);return}T(n,t)||Gi()}},T=(t,n,r)=>t.source===`host`&&n.onHostAction?n.onHostAction(t,n.target)===!0:(e(t,n.target,r),!1),E=(0,m.useRef)(w);if((0,m.useLayoutEffect)(()=>{E.current=w}),(0,m.useEffect)(()=>{if(!t){b.current=-1,f(-1),h(-1);return}let e=ia(r,-1,1,o);b.current=e,f(e),h(-1),s.current?.focus()},[t,r,o]),(0,m.useLayoutEffect)(()=>{if(!t){u(null);return}let e=s.current;if(!e)return;let n=e.getBoundingClientRect();u(Xi(t.x,t.y,n.width,n.height,window.innerWidth,window.innerHeight))},[t,r]),(0,m.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,m.useEffect)(()=>{if(!t)return;let e=e=>s.current&&e instanceof Node&&s.current.contains(e),n=t=>{e(t.target)||Gi()},r=t=>{e(t.target)||Gi()},i=()=>Gi();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,m.useEffect)(()=>{if(!t)return;let e=e=>{let t=ia(r,b.current,e,o);b.current=t,f(t)},n=t=>{switch(t.key){case`Escape`:t.preventDefault(),Gi();return;case`Tab`:Gi();return;case`ArrowDown`:t.preventDefault(),e(1);return;case`ArrowUp`:t.preventDefault(),e(-1);return;case`ArrowRight`:r[b.current]?.children?.length&&(t.preventDefault(),h(b.current));return;case`ArrowLeft`:p>=0&&(t.preventDefault(),h(-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,m.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($i(n.parent,o))return;t&&!T(n.parent,t,n.value)&&Gi();return}$i(e,o)||T(e,t)||Gi()},O=(e,t,n)=>{let r=$i(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&&h(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${g?` 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,k.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 Qg=0,$g=[],e_=new Map,t_=new Set;function n_(){for(let e of t_)try{e()}catch{}}function r_(e){let t=e_.get(e);t!==void 0&&(clearTimeout(t),e_.delete(e))}function i_(e){let t=e.id||`banner-${Date.now()}-${++Qg}`,n={...e,id:t,type:e.type||`info`,persistent:!!e.persistent,timeoutMs:e.timeoutMs??5e3,dismissible:e.dismissible!==!1};if(r_(t),!n.persistent&&n.timeoutMs&&n.timeoutMs>0){let e=setTimeout(()=>{a_(t)},n.timeoutMs);e_.set(t,e)}let r=$g.findIndex(e=>e.id===t);if(r>=0){let e=[...$g];e[r]=n,$g=e}else $g=[...$g,n];return n_(),t}function a_(e,t){r_(e);let n=$g.find(t=>t.id===e);if(n){if($g=$g.filter(t=>t.id!==e),!t?.silent)try{n.onClose?.()}catch{}n_()}}function o_(e,t){let n=$g.filter(e);if(n.length!==0){for(let e of n)if(r_(e.id),!t?.silent)try{e.onClose?.()}catch{}$g=$g.filter(t=>!e(t)),n_()}}function s_(){return $g}function c_(e){return t_.add(e),()=>{t_.delete(e)}}function l_(){return(0,m.useSyncExternalStore)(c_,s_,s_)}function u_({type:e}){switch(e){case`question`:return(0,X.jsx)(De,{className:`banner-icon banner-icon-question`});case`warning`:return(0,X.jsx)(gt,{className:`banner-icon banner-icon-warning`});case`error`:return(0,X.jsx)(_t,{className:`banner-icon banner-icon-error`});case`success`:return(0,X.jsx)(at,{className:`banner-icon banner-icon-success`});default:return(0,X.jsx)(J,{className:`banner-icon banner-icon-info`})}}var d_=(0,m.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)(u_,{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(),a_(e.id)},"aria-label":`Close banner`,title:`关闭通知`,children:(0,X.jsx)(N,{})})]})}),f_=(0,m.memo)(function(){let e=l_();return e.length===0?null:(0,X.jsx)(`aside`,{className:`banner-container`,"aria-label":`Notifications`,children:e.map(e=>(0,X.jsx)(d_,{banner:e},e.id))})}),p_={activity:(0,X.jsx)(vt,{}),branch:(0,X.jsx)(je,{}),browser:(0,X.jsx)(ke,{}),chat:(0,X.jsx)(_e,{}),check:(0,X.jsx)(it,{}),"chevron-up":(0,X.jsx)(et,{}),clock:(0,X.jsx)(Ye,{}),code:(0,X.jsx)(Je,{}),coins:(0,X.jsx)(Be,{}),copy:(0,X.jsx)(Ke,{}),cpu:(0,X.jsx)(Ue,{}),cut:(0,X.jsx)(ae,{}),database:(0,X.jsx)(Ve,{}),dot:(0,X.jsx)(`span`,{className:`host-icon-char`,children:`●`}),download:(0,X.jsx)(ze,{}),edit:(0,X.jsx)(Re,{}),eye:(0,X.jsx)(Fe,{}),file:(0,X.jsx)(Y,{}),folder:(0,X.jsx)(Me,{}),gauge:(0,X.jsx)(vt,{}),git:(0,X.jsx)(je,{}),github:(0,X.jsx)(Ae,{}),globe:(0,X.jsx)(ke,{}),grid:(0,X.jsx)(Oe,{}),hash:(0,X.jsx)(`span`,{className:`host-icon-char`,children:`#`}),image:(0,X.jsx)(Ee,{}),info:(0,X.jsx)(J,{}),layers:(0,X.jsx)(we,{}),link:(0,X.jsx)(Ce,{}),list:(0,X.jsx)(Se,{}),lock:(0,X.jsx)(be,{}),markdown:(0,X.jsx)(Pe,{}),maximize:(0,X.jsx)(ye,{}),menu:(0,X.jsx)(q,{}),message:(0,X.jsx)(_e,{}),open:(0,X.jsx)(Ie,{}),paste:(0,X.jsx)(Xe,{}),pin:(0,X.jsx)(ht,{}),plus:(0,X.jsx)(ce,{}),refresh:(0,X.jsx)(K,{}),save:(0,X.jsx)(oe,{}),search:(0,X.jsx)(G,{}),send:(0,X.jsx)(W,{}),settings:(0,X.jsx)(U,{}),sound:(0,X.jsx)(P,{}),sun:(0,X.jsx)(B,{}),target:(0,X.jsx)(He,{}),terminal:(0,X.jsx)(ne,{}),text:(0,X.jsx)(te,{}),trash:(0,X.jsx)(R,{}),undo:(0,X.jsx)(We,{}),upload:(0,X.jsx)(I,{}),volume:(0,X.jsx)(P,{}),wrap:(0,X.jsx)(Ge,{}),x:(0,X.jsx)(N,{}),zap:(0,X.jsx)(M,{}),zoom:(0,X.jsx)(ee,{})};Object.keys(p_);function m_(e){if(e.iconSvg)return(0,X.jsx)(ni,{icon:e.icon,iconSvg:e.iconSvg});if(!e.icon)return null;let t=p_[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 h_({slots:e,layout:t,exclude:n,onClose:r}){let i=Z(),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(null),l=(0,m.useMemo)(()=>Cg(e,n),[e,n]),u=(0,m.useRef)(null),d=(0,m.useRef)(null),f=(0,m.useRef)(l),p=(0,m.useRef)(t),h=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{f.current=l,p.current=t}),(0,m.useEffect)(()=>{h.current=null},[t]);let g=(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=h.current??p.current,r=t.slot===`__tray`?kg(n,e):Og(n,f.current,{id:e,slot:t.slot,...t.align===void 0?{}:{align:t.align},index:t.index});h.current=r,$({type:`set_settings`,uiLayout:r})};(0,m.useEffect)(()=>{if(!a)return;let e=e=>{e.preventDefault();let t=g(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]),At(()=>{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:m_(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)(N,{})})]}),(0,X.jsxs)(`div`,{className:`icon-editor-body`,children:[yg.map(e=>{let t=l.zones[e.slot]??[],n=Tg(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?xg.map(n=>b(e.slot,n,e.vertical?Sg(i,n):n,Eg(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(bg,void 0,null,l.tray)]})]})]})]})}function g_(e,t){let n=(0,m.useRef)(``);(0,m.useEffect)(()=>{let r=eh(n.current,e);n.current=r.key,r.clear&&t()},[e,t])}var __=new Map,v_=-1;function y_(e){let t=e.trim().toLowerCase();return t.startsWith(`.`)?t:`.${t}`}function b_(e){let t=e.replace(/\\/g,`/`).split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n>0?t.slice(n).toLowerCase():``}function x_(e,t){v_!==t&&(v_=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=y_(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));__=n}function S_(e){return __.get(b_(e))?.[0]??null}async function C_(e){let t=await Ns(e.plugin,v_);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 w_({provider:e,flow:t,result:n}){let r=Z(),i=t?.event,a=e.oauthName??e.name,[o,s]=(0,m.useState)(``);return(0,m.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 T_({piConfigured:e,piAgentInstalled:t,providers:n,providerOAuthFlows:r,providerOAuthResults:i,installResult:a,onClose:o}){let s=Z(),c=_a(),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(``),[p,h]=(0,m.useState)(``),[g,_]=(0,m.useState)(!1);(0,m.useEffect)(()=>{$({type:`list_providers`}),$({type:`list_provider_oauth_flows`})},[]),(0,m.useEffect)(()=>{e&&o()},[e,o]),(0,m.useEffect)(()=>{a&&u(!1)},[a]),(0,m.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()&&!g&&(_(!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)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ue,{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)(w_,{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=>h(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()||g||!d,onClick:y,children:s(g?`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 E_=[`openai-completions`,`openai-responses`,`anthropic-messages`,`google-generative-ai`],D_=[{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:`反代`}],O_=[{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`}],k_=[{label:`2K`,value:`2048`},{label:`4K`,value:`4096`},{label:`8K`,value:`8192`},{label:`16K`,value:`16384`},{label:`32K`,value:`32768`},{label:`64K`,value:`65536`}],A_=()=>({id:``,name:``,reasoning:!1,input:`text`,contextWindow:``,maxTokens:``}),j_=()=>({providerId:``,name:``,api:`openai-completions`,baseUrl:``,apiKey:``,hasApiKey:!1,authHeader:!0,models:[A_()]});function M_(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:[A_()]).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 N_(e){let t={};for(let n of e.split(`
|
|
359
|
+
`)){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 P_({candidates:e,onAdopt:t,onClose:n}){let r=Z(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.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,m.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)(N,{})})]}),(0,X.jsxs)(`div`,{className:`candidate-filter-bar`,children:[(0,X.jsx)(G,{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)(M,{}),` 推理`]}),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 F_({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:h}){let g=Z(),[_,v]=(0,m.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,m.useState)(()=>e.length>0?M_(e[0]):t.length>0?null:j_()),[x,S]=(0,m.useState)(null),[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(0),[D,O]=(0,m.useState)(null),k=(0,m.useRef)(0),[A,j]=(0,m.useState)({}),[ee,M]=(0,m.useState)({}),[P,F]=(0,m.useState)(null),I=(0,m.useRef)(n),L=(0,m.useRef)(null);(0,m.useEffect)(()=>{let e=P;e&&n[e]!==I.current[e]&&(F(null),j(t=>({...t,[e]:``})),M(t=>({...t,[e]:``})),L.current&&clearTimeout(L.current)),I.current=n},[n,P]),(0,m.useEffect)(()=>()=>{L.current&&clearTimeout(L.current)},[]);let[te,z]=(0,m.useState)(!1),[ne,re]=(0,m.useState)(0),[B,ie]=(0,m.useState)(null),V=(0,m.useRef)(0),[H,U]=(0,m.useState)(!1),[W,G]=(0,m.useState)(!1),[ae,oe]=(0,m.useState)(0),[se,le]=(0,m.useState)(null),[ue,de]=(0,m.useState)([]),[fe]=(0,m.useState)(``),pe=(0,m.useRef)(0),[me,he]=(0,m.useState)(!1),[ge,_e]=(0,m.useState)(0),[q,ve]=(0,m.useState)(null),ye=(0,m.useRef)(0),[be,xe]=(0,m.useState)(null),[Se,Ce]=(0,m.useState)(``),[we,Te]=(0,m.useState)(``),[J,Ee]=(0,m.useState)(``),[De,Oe]=(0,m.useState)(``),[ke,Ae]=(0,m.useState)(!1),[je,Me]=(0,m.useState)(0),[Ne,Y]=(0,m.useState)(null),Pe=(0,m.useRef)(0),[Fe,Ie]=(0,m.useState)(null),[Le,Re]=(0,m.useState)(``),[Be,Ve]=(0,m.useState)(null),[He,We]=(0,m.useState)({}),Ge=(0,m.useRef)(0),qe=(0,m.useRef)(0),[Je,Ye]=(0,m.useState)(null),Xe=(0,m.useRef)(0),Ze=(0,m.useRef)(0),Qe=e=>{if(He[e])return;let t=++Ge.current+Date.now();We(t=>({...t,[e]:!0})),$({type:`refresh_provider_models`,providerId:e,reqId:t})};(0,m.useEffect)(()=>{d&&d.reqId!==qe.current&&(qe.current=d.reqId,We({}))},[d]);let $e=e=>{if(Je)return;Ye(e.id);let t=++Xe.current+Date.now();$({type:`clone_provider`,provider:e.id,reqId:t})||Ye(null)};(0,m.useEffect)(()=>{$({type:`list_models_config`}),$({type:`list_providers`}),$({type:`list_provider_keys`}),$({type:`list_provider_oauth_flows`})},[]),(0,m.useEffect)(()=>{o&&o.reqId!==k.current&&(k.current=o.reqId,w(!1),O({ok:o.ok,latencyMs:o.latencyMs,error:o.error}))},[o]),(0,m.useEffect)(()=>{a&&a.reqId!==V.current&&(V.current=a.reqId,z(!1),a.ok&&a.models?.length?(S(a.models),ie({ok:!0,text:g(`fetchModelsOk`,{n:a.models.length})})):ie({ok:!1,text:a.error||g(`fetchModelsEmpty`)}))},[a,g]),(0,m.useEffect)(()=>{if(s&&s.reqId!==pe.current){if(pe.current=s.reqId,U(!1),G(!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:g(`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||g(`enrichModelsErr`,{msg:``})})}},[s,g]),(0,m.useEffect)(()=>{u&&u.reqId!==ye.current&&(ye.current=u.reqId,he(!1),u.ok?ve({ok:!0,text:g(`refreshBuiltinOk`)}):ve({ok:!1,text:u.error||g(`refreshBuiltinFail`)}))},[u,g]),(0,m.useEffect)(()=>{f&&f.reqId!==Pe.current&&(Pe.current=f.reqId,Ae(!1),f.ok?(Y({ok:!0,text:g(`appendModelOk`)}),Ce(``),Te(``),Ee(``),Oe(``),xe(null),$({type:`list_models_config`})):Y({ok:!1,text:f.error||g(`appendModelFail`)}))},[f,g]),(0,m.useEffect)(()=>{if(l&&l.reqId!==Ze.current&&(Ze.current=l.reqId,Ye(null),l.ok)){let e=l.configs;if(e&&e.length>1){Ie(e.map(e=>M_(e))),Re(``);return}l.config&&Ve(M_(l.config))}},[l]);let et=()=>{if(!y)return;let e=y.baseUrl.trim();if(!e){O({ok:!1,error:g(`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})},tt=()=>{if(!y)return;let e=y.baseUrl.trim();if(!e){ie({ok:!1,text:g(`fetchModelsNeedBaseUrl`)});return}if(te)return;z(!0),ie(null);let t=ne+1;re(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:g(`enrichModelsNeedIds`)});return}U(!0),G(!1),le(null),de([]);let t=ae+1;oe(t),$({type:`enrich_models`,reqId:t,ids:e,hints:N_(fe)})},at=()=>{H&&!W&&(G(!0),$({type:`abort_enrich_models`,reqId:ae}))},ot=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:[A_()]})),O(null),ie(null)},st=()=>{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}}),h()},ct=(e,t)=>{y&&b({...y,models:y.models.map((n,r)=>r===e?{...n,...t}:n)})},lt=()=>{y&&b({...y,models:[...y.models,A_()]})},ut=e=>{y&&b({...y,models:y.models.filter((t,n)=>n!==e)})},dt=e=>{let t=(A[e.id]??``).trim();t&&!P&&(F(e.id),$({type:`add_provider_key`,provider:e.id,apiKey:t,name:(ee[e.id]??``).trim()||void 0}),L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{F(t=>t===e.id?null:t)},1e4))},ft=(e,t)=>{$({type:`activate_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`})},pt=(e,t)=>{window.confirm(g(`removeKeyConfirm`))&&($({type:`remove_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`}))},mt=e=>{window.confirm(g(`clearKeyConfirm`,{id:e}))&&$({type:`clear_provider_api_key`,provider:e})},ht=t=>{if(window.confirm(g(`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(M_(n[0]))):(v({type:`custom`,id:``}),b(j_()))}},gt=e=>{let t=Se.trim();if(!t||ke)return;Ae(!0),Y(null);let n=je+1;Me(n),$({type:`append_builtin_model`,providerId:e,model:{id:t,...we.trim()?{name:we.trim()}:{},...J?{api:J}:{},...De.trim()?{baseUrl:De.trim()}:{}},reqId:n})};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:h,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)(Ue,{})}),(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:g(`refreshBuiltinHint`),disabled:me,onClick:()=>{if(me)return;he(!0),ve(null);let e=ge+1;_e(e),$({type:`refresh_builtin_models`,reqId:e})},children:[(0,X.jsx)(ze,{}),(0,X.jsx)(`span`,{children:me?g(`refreshBuiltinBusy`):`刷新官方目录`})]}),(0,X.jsx)(`button`,{type:`button`,className:`studio-header-iconbtn`,title:g(`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":g(`close`),onClick:h,children:(0,X.jsx)(N,{})})]})]}),q&&(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 ${q.ok?`ok`:`err`}`,children:q.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(j_()),O(null),ie(null)},children:[(0,X.jsx)(ce,{}),` 添加自定义服务商`]})}),(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(M_(e)),O(null),ie(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:g(`refreshModels`),disabled:He[y.providerId],onClick:()=>Qe(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:et,children:[(0,X.jsx)(vt,{}),` `,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:st,children:g(`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:D_.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:`quick-chip`,onClick:()=>ot(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:[g(`providerId`),` `,(0,X.jsx)(`em`,{children:g(`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:g(`displayName`)}),(0,X.jsx)(`input`,{type:`text`,value:y.name,onChange:e=>b({...y,name:e.target.value}),placeholder:g(`displayNamePh`)})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:g(`apiType`)}),(0,X.jsx)(`select`,{value:y.api,onChange:e=>b({...y,api:e.target.value}),children:E_.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:g(`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:g(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:y.apiKey,onChange:e=>b({...y,apiKey:e.target.value}),placeholder:y.hasApiKey?g(`apiKeySavedHint`):g(`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:g(`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:[B&&(0,X.jsx)(`span`,{className:`fetch-msg ${B.ok?`ok`:`err`}`,title:B.text,children:B.text}),se&&(0,X.jsx)(`span`,{className:`fetch-msg ${se.ok?`ok`:`err`}`,title:se.text,children:se.text}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:te||!y.baseUrl.trim(),title:g(`fetchModelsHint`),onClick:tt,children:[(0,X.jsx)(ze,{}),` `,te?g(`fetchingModels`):`自动获取并采纳模型`]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:H,title:g(`enrichModelsHint`),onClick:rt,children:[(0,X.jsx)(ze,{}),` `,g(H?`enrichingModels`:`enrichModels`)]}),H&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:W,title:g(`enrichModelsAbort`),onClick:at,style:{color:`var(--red)`},children:[(0,X.jsx)(N,{}),` `,g(W?`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)(Ue,{}),` ID`]}),(0,X.jsx)(`input`,{type:`text`,className:`matrix-input-field mono`,value:e.id,onChange:e=>ct(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=>ct(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:()=>ct(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:()=>ct(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:g(`delete`),onClick:()=>ut(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:O_.some(t=>t.value===e.contextWindow)?e.contextWindow:`custom`,onChange:e=>{e.target.value!==`custom`&&ct(t,{contextWindow:e.target.value})},children:[O_.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:`自定义…`})]}),(!O_.some(t=>t.value===e.contextWindow)||e.contextWindow===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.contextWindow,onChange:e=>ct(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:k_.some(t=>t.value===e.maxTokens)?e.maxTokens:`custom`,onChange:e=>{e.target.value!==`custom`&&ct(t,{maxTokens:e.target.value})},children:[k_.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:`自定义…`})]}),(!k_.some(t=>t.value===e.maxTokens)||e.maxTokens===``)&&(0,X.jsx)(`input`,{type:`text`,className:`spec-combobox-custom-input`,value:e.maxTokens,onChange:e=>ct(t,{maxTokens:e.target.value}),placeholder:`如 8192`})]}),(0,X.jsx)(`div`,{className:`matrix-spec-quick-pills`,children:[`32K`,`128K`,`200K`].map(n=>{let r=O_.find(e=>e.label===n);return r?(0,X.jsx)(`button`,{type:`button`,className:`param-pill ${e.contextWindow===r.value?`active`:``}`,onClick:()=>ct(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:lt,children:[(0,X.jsx)(ce,{}),` 添加模型行`]})]})]})]}),_.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:g(`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:g(`cloneProvider`),disabled:Je===e.id,onClick:()=>$e(e),children:[(0,X.jsx)(Ke,{}),` `,g(`cloneProvider`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{xe(be===e.id?null:e.id),Y(null)},children:[(0,X.jsx)(ce,{}),` `,g(`appendModel`)]}),e.supportsApiKey&&e.source===`stored`&&!e.usingOAuth&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm danger`,title:g(`clearKeyTitle`),onClick:()=>mt(e.id),children:[(0,X.jsx)(R,{}),` `,g(`clearKey`)]})]})]}),e.supportsOAuth&&(0,X.jsx)(w_,{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:g(`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:g(`activateKey`),onClick:()=>ft(e.id,t.name),children:(0,X.jsx)(it,{})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:g(`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:g(`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:g(`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()||P===e.id,onClick:()=>dt(e),children:[(0,X.jsx)(ce,{}),` `,P===e.id?g(`savingKey`):g(`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:Se,onChange:e=>Ce(e.target.value)}),(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:`显示名称 (选填)`,value:we,onChange:e=>Te(e.target.value)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!Se.trim()||ke,onClick:()=>gt(e.id),children:[(0,X.jsx)(ce,{}),` 提交追加`]})]}),Ne&&(0,X.jsx)(`span`,{style:{fontSize:12,color:Ne.ok?`var(--green)`:`var(--red)`,marginTop:6},children:Ne.text})]})]})})()]})]}),x&&(0,X.jsx)(P_,{candidates:x,onAdopt:nt,onClose:()=>S(null)})]})})}function I_(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 Vh)i(e);let a=typeof n==`string`?n:n==null?``:String(n);return a&&i(a),r}function L_({plugin:e,models:t=[]}){let n=Z(),r=e.settingsSchema??[],[i,a]=(0,m.useState)(()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);return t}),[o,s]=(0,m.useState)(!1);if(r.length===0)return null;let c=(e,t)=>a(n=>({...n,[e]:t})),l=e=>I_(e,t,i[e.key]).map(r=>{if(r===``)return{value:``,label:n(`pluginSettingsInherit`)};if(e.optionsFrom===`thinkingLevels`&&Vh.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 R_=[{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 z_(e){return{id:``,name:``,description:``,cwd:e,kind:`cron`,cron:`0 9 * * *`,preset:`0 9 * * *`,intervalMinutes:`60`,prompt:``,model:``,thinkingLevel:``,catchUp:!1}}function B_(e){let t=e.kind===`cron`&&R_.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 V_(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=R_.find(t=>t.value===e.spec);return n?t(n.key):e.spec}function H_(e){if(!e)return``;try{return new Date(e).toLocaleString()}catch{return String(e)}}function U_({tasks:e,cwd:t,models:n}){let r=Z(),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(new Set);(0,m.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)(Ye,{className:`set-section-icon`}),r(`settingsScheduler`),(0,X.jsx)(Zc,{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(z_(t)),s(!0)},children:[(0,X.jsx)(ce,{}),` `,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:V_(e,r)})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsxs)(`span`,{children:[r(`schedulerNextFire`),`: `,e.nextFire?H_(e.nextFire):`—`]}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsxs)(`span`,{children:[r(`schedulerLastRun`),`:`,` `,e.lastRun?(0,X.jsxs)(X.Fragment,{children:[H_(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:[H_(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)(le,{}),` `,r(`schedulerRunNow`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerEdit`),onClick:()=>{a(B_(e)),s(!1)},children:[(0,X.jsx)(Le,{}),` `,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)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Ye,{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:[R_.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)(Zc,{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`)}),Vh.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)(Zc,{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 W_=`pi-web-sounds`,G_={enabled:!0,question:!0,done:!0,start:!1,error:!0,approval:!0,volume:100};function K_(){try{let e=localStorage.getItem(W_);if(!e)return{...G_};let t=JSON.parse(e),n={...G_,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`,`approval`])typeof n[e]!=`boolean`&&(n[e]=G_[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?G_.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...G_}}}function q_(e){try{localStorage.setItem(W_,JSON.stringify(e))}catch{}}var J_=null;function Y_(){try{if(!J_){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;J_=new e}return J_.state===`suspended`&&J_.resume(),J_}catch{return null}}var X_={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 Z_(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 Q_(e,t=K_()){if(!t.enabled||!t[e])return;let n=Y_();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of X_[e])Z_(n,t,r)}function $_(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 ev(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 tv=`pi-web-ui:wide-chat`,nv={wide:!1};function rv(e){if(!e||typeof e!=`object`)return{...nv};let t=e;return{wide:typeof t.wide==`boolean`?t.wide:nv.wide}}function iv(){try{let e=localStorage.getItem(tv);return e?rv(JSON.parse(e)):{...nv}}catch{return{...nv}}}function av(e){let t=rv(e);try{localStorage.setItem(tv,JSON.stringify(t))}catch{}ov=t;for(let e of sv)e()}var ov=null,sv=new Set;function cv(e){return sv.add(e),()=>{sv.delete(e)}}function lv(){return ov||=iv(),ov.wide}function uv(){return(0,m.useSyncExternalStore)(cv,lv)}var dv=`pi-web-ui:project-title`,fv={projectName:!0};function pv(e){if(!e||typeof e!=`object`)return{...fv};let t=e;return{projectName:typeof t.projectName==`boolean`?t.projectName:fv.projectName}}function mv(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``:``}function hv(){try{let e=localStorage.getItem(dv);return e?pv(JSON.parse(e)):{...fv}}catch{return{...fv}}}function gv(e){let t=pv(e);try{localStorage.setItem(dv,JSON.stringify(t))}catch{}_v=t;for(let e of vv)e()}var _v=null,vv=new Set;function yv(e){return vv.add(e),()=>{vv.delete(e)}}function bv(){return _v||=hv(),_v.projectName}function xv(){return(0,m.useSyncExternalStore)(yv,bv)}var Sv=`pi-web-ui:wallpaper`,Cv=`has-wallpaper`,wv={url:``,dim:78,blur:0},Tv=2e3,Ev=28e5;function Dv(e){if(typeof e!=`string`)return``;let t=e.trim();if(!t)return``;let n=t.toLowerCase().startsWith(`data:image/`)?Ev:Tv;return t.length>n?``:/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith(`/`)&&!t.startsWith(`//`)?t:``}var Ov=(e,t,n,r)=>typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)));function kv(e){if(!e||typeof e!=`object`)return{...wv};let t=e;return{url:Dv(t.url),dim:Ov(t.dim,0,95,wv.dim),blur:Ov(t.blur,0,24,wv.blur)}}function Av(){try{let e=localStorage.getItem(Sv);return e?kv(JSON.parse(e)):{...wv}}catch{return{...wv}}}function jv(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/[\r\n]/g,``)}async function Mv(e){let t=await gf(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function Nv(){let e=Fv??Av(),t=document.documentElement;e.url?(t.style.setProperty(`--bg-image`,`url("${jv(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(Cv,e.url!==``||n!==``&&n!==`none`)}function Pv(e){let t=kv(e);Fv=t;try{localStorage.setItem(Sv,JSON.stringify(t))}catch{}for(let e of Iv)e();Nv()}var Fv=null,Iv=new Set;function Lv(e){return Iv.add(e),()=>{Iv.delete(e)}}function Rv(){return Fv||=Av(),Fv}function zv(){return(0,m.useSyncExternalStore)(Lv,Rv)}function Bv(){let e=zv();(0,m.useEffect)(()=>{Nv()},[e]),(0,m.useEffect)(()=>{let e=()=>Nv();return window.addEventListener(Ou,e),Nv(),()=>window.removeEventListener(Ou,e)},[])}function Vv(e,t){return e.error?`failed`:t?`disabled`:e.active===!0?`active`:`idle`}function Hv(e,t){let n={active:0,disabled:0,failed:0,idle:0};for(let r of e)n[Vv(r,t.has(r.id))]+=1;return n}var Uv={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`]},Wv=[`soul`,`tools`,`guidelines`,`pi_docs`,`append`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`],Gv=[`tools`,`pi_docs`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`];function Kv(e){return Gv.includes(e)}var qv=Wv.map(e=>`{{${e}}}`).join(`
|
|
360
|
+
|
|
361
|
+
`),Jv=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uac00-\ud7af]/gu;function Yv(e){if(!e)return 0;let t=e.match(Jv)?.length??0;return Math.ceil(t+(e.length-t)/4)}var Xv=br.filter(e=>e.group===`other`&&e.name!==`todo_list`),Zv=`pi-web-ui:catalog-sync-urls`,Qv=8;function $v(){try{let e=localStorage.getItem(Zv);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim()!==``).slice(0,Qv):[]}catch{return[]}}function ey(e){let t=e.trim();if(!t)return $v();let n=[t,...$v().filter(e=>e!==t)].slice(0,Qv);try{localStorage.setItem(Zv,JSON.stringify(n))}catch{}return n}function ty(e){return e===`append`?0:Kv(e)?2:1}function ny({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)(Zc,{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 ry(e){return e===`active`?`pluginPhaseActive`:e===`disabled`?`pluginPhaseDisabled`:e===`failed`?`pluginPhaseFailed`:`pluginPhaseIdle`}function iy({phase:e,label:t}){return(0,X.jsx)(`span`,{className:`inv-dot inv-dot-${e}`,title:t,"aria-label":t})}function ay({plugins:e,disabledIds:t}){let n=Z(),r=Hv(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)(iy,{phase:e,label:i[e]}),r[e]]},e))})}function oy({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)(Zc,{text:t})]}),r]})}function sy({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)(oy,{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 cy({pluginId:e}){let t=Z(),[n,r]=(0,m.useState)(`all`),i=Ks(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`,...Rs].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:()=>$(Bs(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 ly(e,t){if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}var uy=1e4;function dy({chat:e,terminal:t,initialSection:n,onSwitchToTerminal:r,onClose:i,sound:a,onSoundChange:o,tts:s,onTtsChange:c}){let l=Z(),{locale:u}=wn(),d=e=>l(e),f=e.settings,[p,h]=(0,m.useState)({}),g=(0,m.useMemo)(()=>{if(!f)return null;if(Object.keys(p).length===0)return f;let e={...f};for(let[t,{value:n}]of Object.entries(p))e[t]=n;return e},[f,p]);(0,m.useEffect)(()=>{f&&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))!ly(f[r],i)&&n-a<uy&&(t[r]={value:i,at:a});return Object.keys(t).length===Object.keys(e).length?e:t})},[f]);let _=g?.approvalPolicy,{engine:v,managed:y}=ma(),b=v===`dsh`,[x,S]=(0,m.useState)(n??`prompt`),[C,w]=(0,m.useState)(`market`),T=(0,m.useRef)(null);(0,m.useEffect)(()=>{T.current?.scrollTo({top:0})},[x]);let E=(0,m.useRef)(null);(0,m.useEffect)(()=>{E.current?.querySelector(`.settings-tab.active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[x]),(0,m.useEffect)(()=>{x===`plugins`&&b&&$({type:`dsh_patches_list`})},[x,b]),(0,m.useEffect)(()=>{$({type:`get_settings`})},[e.state?.cwd,e.activeConversationId]);let[D,O]=(0,m.useState)(``),[k,A]=(0,m.useState)({}),j=(0,m.useRef)(!1),ee=(0,m.useRef)(null),L=[...Wv].sort((e,t)=>ty(e)-ty(t)),[te,ne]=(0,m.useState)(null),[re,B]=(0,m.useState)({}),[ie,G]=(0,m.useState)(``),[ae,oe]=(0,m.useState)(`append`),se=(0,m.useRef)(!1),[le,ue]=(0,m.useState)(``),[fe,pe]=(0,m.useState)(`append`),me=(0,m.useRef)(!1),[he,ge]=(0,m.useState)(``),[q,ve]=(0,m.useState)(`append`),ye=(0,m.useRef)(!1),[be,xe]=(0,m.useState)(``),Se=(0,m.useRef)(!1),[Ce,we]=(0,m.useState)(``),[J,Ee]=(0,m.useState)(null),[Oe,ke]=(0,m.useState)(!1),[Ae,Ne]=(0,m.useState)(null),[Y,Ie]=(0,m.useState)(null),[Re,Be]=(0,m.useState)(!1),[Ve,He]=(0,m.useState)(``),[We,Ge]=(0,m.useState)(null),[Ke,qe]=(0,m.useState)(null),[Je,Xe]=(0,m.useState)(null),[Ze,Qe]=(0,m.useState)(!1),[$e,tt]=(0,m.useState)(!1),nt=(0,m.useMemo)(()=>Yv(g?.effectiveSystemPrompt??``),[g?.effectiveSystemPrompt]),it=(0,m.useMemo)(()=>Yv(g?.toolsSchema??``),[g?.toolsSchema]),at=nt+it,ot=uv(),ct=Xd(),lt=xv(),ut=zv(),[dt,ft]=(0,m.useState)(ut.url),pt=(0,m.useRef)(!1),ht=(0,m.useRef)(null),[_t,vt]=(0,m.useState)(!1),[yt,bt]=(0,m.useState)(!1);(0,m.useEffect)(()=>{pt.current||ft(ut.url.startsWith(`data:`)?``:ut.url)},[ut.url]);let xt=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){vt(!0),bt(!1);try{let e=await Mv(t),n=e?Dv(e):``;if(!n){bt(!0);return}ft(``),Pv({...ut,url:n})}finally{vt(!1)}}},[Ct,wt]=(0,m.useState)(()=>_h()),[Tt,Et]=(0,m.useState)(()=>{try{return xh().length}catch{return 0}}),[Dt,Ot]=(0,m.useState)(!1),kt=()=>{try{Et(xh().length)}catch{Et(0)}};(0,m.useEffect)(()=>{x===`prompt-history`&&kt()},[x]),(0,m.useEffect)(()=>{if(!Dt)return;let e=window.setTimeout(()=>Ot(!1),3e3);return()=>window.clearTimeout(e)},[Dt]);let[At,jt]=(0,m.useState)(null),[Mt,Nt]=(0,m.useState)(null),[Pt,Ft]=(0,m.useState)(null),[It,Lt]=(0,m.useState)(null),[Rt,zt]=(0,m.useState)({}),[,Bt]=(0,m.useState)(0);(0,m.useEffect)(()=>Gs(()=>Bt(e=>e+1)),[]);let[Vt,Ht]=(0,m.useState)(``),[Ut,Wt]=(0,m.useState)(``),[Gt,Kt]=(0,m.useState)(``),[qt,Jt]=(0,m.useState)(``),[Yt,Zt]=(0,m.useState)(``),[Qt,$t]=(0,m.useState)(!1),[en,tn]=(0,m.useState)(!1),[nn,rn]=(0,m.useState)(!1),[an,on]=(0,m.useState)(``),[sn,cn]=(0,m.useState)(!1),[ln,un]=(0,m.useState)(!1),[dn,fn]=(0,m.useState)(null),[pn,mn]=(0,m.useState)(``),[hn,gn]=(0,m.useState)(()=>$v()),[_n,vn]=(0,m.useState)(``),[yn,bn]=(0,m.useState)(null);(0,m.useEffect)(()=>{g&&(j.current||O(g.promptTemplate??``),A(e=>{let t={};for(let[e,n]of Object.entries(g.promptOverrides??{}))t[e]=n??``;return ee.current&&(t[ee.current]=e[ee.current]??``),t}),oe(g.visionBridgePromptMode),!se.current&&(G(ae===`append`||g.visionBridgePrompt?g.visionBridgePrompt:g.visionBridgeDefaultPrompt||``),pe(g.scmCommitMsgPromptMode),me.current||ue(g.scmCommitMsgPromptMode===`append`||g.scmCommitMsgPrompt?g.scmCommitMsgPrompt:g.scmCommitMsgDefaultPrompt||``),ve(g.planModePromptMode),ye.current||ge(g.planModePromptMode===`append`||g.planModePrompt?g.planModePrompt:g.planModeDefaultPrompt||``),Se.current||xe(g.reviewPrompt)))},[g,ae,fe,q]);let[xn,Sn]=(0,m.useState)(String(g?.terminalBashIdleMs??15e3));(0,m.useEffect)(()=>{Sn(String(g?.terminalBashIdleMs??15e3))},[g?.terminalBashIdleMs]);let[Cn,Tn]=(0,m.useState)(String(g?.terminalBashMaxForegroundMs??6e4));(0,m.useEffect)(()=>{Tn(String(g?.terminalBashMaxForegroundMs??6e4))},[g?.terminalBashMaxForegroundMs]);let[Dn,kn]=(0,m.useState)(String(Math.round((g?.toolWatchdogTimeoutMs??12e5)/6e4)));(0,m.useEffect)(()=>{kn(String(Math.round((g?.toolWatchdogTimeoutMs??12e5)/6e4)))},[g?.toolWatchdogTimeoutMs]);let[An,jn]=(0,m.useState)(String(g?.retryMaxAttempts??6));(0,m.useEffect)(()=>{jn(String(g?.retryMaxAttempts??6))},[g?.retryMaxAttempts]);let[Mn,Nn]=(0,m.useState)(g?.softCapTokens&&g.softCapTokens>0?ev(g.softCapTokens):``);(0,m.useEffect)(()=>{Nn(g?.softCapTokens&&g.softCapTokens>0?ev(g.softCapTokens):``)},[g?.softCapTokens]);let[Pn,Fn]=(0,m.useState)(``),[In,Ln]=(0,m.useState)(``),Rn=[],zn=ji(bi(e.plugins),{locale:u,t:e=>l(e),disabledPlugins:e.settings?.disabledPlugins??[],layout:e.settings?.uiLayout,diagnostics:Rn}),Bn=[];for(let t of zn[`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&&Bn.push({entry:t,plugin:n})}let Vn=e=>`plugin-page:${e}`;if((0,m.useEffect)(()=>{x.startsWith(`plugin-page:`)&&(Bn.some(e=>Vn(e.entry.id)===x)||S(`prompt`))},[x,Bn]),!g)return null;let Hn=new Set(g.disabledAgentTools??[]),Un=Hn.size,Wn=b?null:e.dshPresets?.defaultPreset??null,Gn=!!Wn&&Wn!==`standard`,Kn=Gn?new Set(Sr([...br.map(e=>e.name),`bash`,`read`,`edit`,`write`],Wn??void 0)):new Set(br.map(e=>e.name)),qn=Jh(e.dshPresets?.presets.find(e=>e.id===Wn)??{id:Wn??``,trust:`system`,isDefault:!1},u,l).name,Jn=e=>Gn&&!Kn.has(e),Yn=Gn?br.filter(e=>!Kn.has(e.name)).length:0,Xn=Gn?e.plugins.flatMap(e=>e.agentTools??[]).filter(e=>!(g.disabledPluginTools??[]).includes(e.name)).length:0,Zn=e.pluginUpdates,Qn=Object.values(Zn??{}).some(e=>e.updatable&&(e.builtin??!1)),$n=Object.values(Zn??{}).some(e=>e.updatable),er=[{id:`prompt`,icon:(0,X.jsx)(Pe,{}),label:l(`settingsSystemPrompt`)},{id:`prompt-history`,icon:(0,X.jsx)(Ye,{}),label:l(`settingsPromptHistory`),count:Tt},...b?[]:[{id:`scheduler`,icon:(0,X.jsx)(Ye,{}),label:l(`settingsScheduler`),count:e.schedulerTasks.length||void 0}],...b?[{id:`question`,icon:(0,X.jsx)(De,{}),label:l(`settingsQuestionnaire`)}]:[{id:`tools`,icon:(0,X.jsx)(z,{}),label:l(`settingsTools`),count:Un+(g.disabledMarkers?.length??0)||void 0},{id:`approval-rules`,icon:(0,X.jsx)(H,{}),label:l(`settingsApprovalRules`),count:(g.approvalRules??[]).length||void 0}],{id:`display`,icon:(0,X.jsx)(_e,{}),label:l(`settingsMessageDisplay`)},{id:`sound`,icon:(0,X.jsx)(P,{}),label:l(`settingsSoundVoice`)},{id:`quick`,icon:(0,X.jsx)(W,{}),label:l(`quickPhrases`),count:g.quickPhrases.length},{id:`skills`,icon:(0,X.jsx)(Ue,{}),label:l(`settingsSkills`),count:g.skills.length},{id:`extensions`,icon:(0,X.jsx)(de,{}),label:l(`settingsExtensions`),count:g.extensions.length},{id:`plugins`,icon:(0,X.jsx)(st,{}),label:l(`settingsUiPlugins`),count:e.plugins.length,dot:Qn||$n},{id:`layout`,icon:(0,X.jsx)(V,{}),label:l(`uiLayoutTitle`)},{id:`review`,icon:(0,X.jsx)(M,{}),label:l(`settingsReview`),count:g.reviewSkills.length},...b?[]:[{id:`vision`,icon:(0,X.jsx)(Fe,{}),label:l(`settingsVisionBridge`)}],{id:`presets`,icon:(0,X.jsx)(V,{}),label:l(`settingsPresets`),count:g.presets.length},...b?[]:[{id:`subagent-templates`,icon:(0,X.jsx)(F,{}),label:l(`settingsSubagentTemplates`),count:g.subagentTemplates.length}],...Bn.map(e=>({id:Vn(e.entry.id),icon:e.entry.iconSvg?(0,X.jsx)(ni,{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)(st,{}),label:e.entry.label,pluginPage:{plugin:e.plugin,entry:e.entry}}))],tr=x.startsWith(`plugin-page:`)?Bn.find(e=>Vn(e.entry.id)===x)??null:null,nr=new Set(g.disabledSkills),ar=new Set(g.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})},or=()=>{if(!yn||!g)return;let e=yn.value.trim(),t=yn.index;if(bn(null),!e||e===g.quickPhrases[t])return;let n=[...g.quickPhrases];n[t]=e,Q({quickPhrases:n})},sr=e=>{let t=new Set(nr);t.has(e.name)?t.delete(e.name):t.add(e.name),Q({disabledSkills:[...t]})},cr=new Set(g.skillsFullText??[]),lr=e=>{let t=new Set(cr);t.has(e)?t.delete(e):t.add(e),Q({skillsFullText:[...t]})},ur=new Set(g.disabledPlugins??[]),dr=new Set(e.plugins.map(e=>e.id)),fr=e=>{let t=new Set(ur);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledPlugins:[...t]})},pr=e=>{let t=new Set(ar);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledExtensions:[...t]})},mr={subagent:l(`toolDescSubagent`),subagent_spawn:l(`toolDescSubagentSpawn`),subagent_get_result:l(`toolDescSubagentGetResult`),subagent_steer:l(`toolDescSubagentSteer`),subagent_list:l(`toolDescSubagentList`),subagent_stop:l(`toolDescSubagentStop`),subagent_wait_all:l(`toolDescSubagentWaitAll`),subagent_templates:l(`toolDescSubagentTemplates`)},hr={bash:l(`toolCoreBashDesc`),read:l(`toolCoreReadDesc`),edit:l(`toolCoreEditDesc`),write:l(`toolCoreWriteDesc`),powershell:l(`toolCorePowershellDesc`),ls:l(`toolCoreLsDesc`),grep:l(`toolCoreGrepDesc`),find:l(`toolCoreFindDesc`)},gr=e=>{let t=new Set(Hn);t.has(e)?t.delete(e):t.add(e),Q({disabledAgentTools:[...t]})},_r=new Set(g.disabledPluginTools??[]),vr=e=>{let t=new Set(_r);t.has(e)?t.delete(e):t.add(e),Q({disabledPluginTools:[...t]})},yr=e.plugins.map(e=>({plugin:e,tools:[...e.agentTools??[]].sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.tools.length>0),wr=g.markersEnabled??!0,Tr=new Set(g.disabledMarkers??[]),Er=e=>{let t=new Set(Tr);t.has(e)?t.delete(e):t.add(e),Q({disabledMarkers:[...t]})},Dr=(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=St(),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()},Or=e=>{jt(null),Dr(`${l(`uninstallTitle`)} ${e}`,`pi remove npm:${e}`)},kr=(e,t,n)=>{$({type:`plugin_job`,jobId:St(),action:e,id:t,...n?{source:n}:{},...e!==`uninstall`&&en?{build:!0}:{}})},Ar=t=>{let n=null;for(let r of Object.values(e.pluginJobs??{}))r.pluginId===t&&(!n||r.startedAt>=n.startedAt)&&(n=r);return n},jr=e=>e?e.problem===`already-installed`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`pluginInspectAlreadyInstalled`,{id:e.suggestedId})}):e.problem===`network`?(0,X.jsx)(`div`,{className:`set-catalog-hint`,"data-problem":e.problem,children:l(`pluginInspectNetwork`)}):e.problem===`invalid-spec`?(0,X.jsx)(`div`,{className:`set-catalog-hint warn`,"data-problem":e.problem,children:l(`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:l(`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,Mr=e=>{let t=Ar(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`}),l(`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:l(`cancel`)})]})}return t.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[`✓ `,l(`pluginJobDone`)]}):(0,X.jsxs)(`div`,{className:`set-catalog-job error`,children:[(0,X.jsxs)(`span`,{children:[`✗ `,t.error||l(`pluginJobFailed`)]}),t.output?(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:t.output}):null]})},Nr=[{slot:`topbar.primary`,labelKey:`uiLayoutTopbar`},{slot:`topbar.overflow`,labelKey:`uiLayoutTopbarOverflow`},{slot:`notice.actions`,labelKey:`uiLayoutNotice`},{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.file`,labelKey:`uiLayoutContextFile`},{slot:`contextmenu.toolcall`,labelKey:`uiLayoutContextToolcall`},{slot:`settings.pages`,labelKey:`uiLayoutSettingsPages`},{slot:`modal.dialog`,labelKey:`uiLayoutModal`},{slot:`sidebar.left`,labelKey:`uiLayoutSidebarLeft`},{slot:`sidebar.right`,labelKey:`uiLayoutSidebarRight`}],Pr=[`bottombar`,`composer.actions`,`topbar.primary`,`sidebar.left`,`sidebar.right`],Fr=e=>e===`sidebar.left`||e===`sidebar.right`,Ir=[`topbar.primary`,`bottombar`,`sidebar.left`,`sidebar.right`],[Lr,Rr]=(0,m.useState)(``),zr=e=>{let t=Nr.find(t=>t.slot===e);return t?l(t.labelKey):e},Br=e.settings?.uiLayout,Vr=e=>Q({uiLayout:{...Br,...e}}),Hr=e=>{let t=new Set(Br?.hidden??[]),n=new Set(Br?.shown??[]);e.hidden?(t.delete(e.id),n.add(e.id)):(t.add(e.id),n.delete(e.id)),Vr({hidden:[...t],shown:[...n]})},Ur=(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=(Br?.order??[]).filter(e=>!f.has(e));Vr({order:[...p,...d]})},Wr=(e,t)=>{(t===`start`||t===`center`||t===`end`)&&Vr({align:{...Br?.align,[e]:t}})},Gr=(e,t)=>{let n={...Br?.slots,[e]:t};Vr({slots:n})},Kr=(e,t)=>{let n={...Br?.labels},r=t.trim().slice(0,60);r?n[e]=r:delete n[e],Vr({labels:n})},qr=e=>Q({uiLayout:Fi(Br,e)}),Jr=()=>Q({uiLayout:Ii()}),Yr=e=>{Nt(null),kr(`uninstall`,e)},Xr=(e,t)=>{kr(`update`,e,t)},Zr=e=>{kr(`install`,e.id,e.source)},Qr=e=>{$({type:`plugin_catalog_remove`,id:e})},$r=()=>{let e=Vt.trim();e&&($({type:`plugin_catalog_add`,entry:{source:e,...Ut.trim()?{id:Ut.trim()}:{},...Gt.trim()?{name:Gt.trim()}:{},...qt.trim()?{description:qt.trim()}:{},...Yt.trim()?{icon:Yt.trim()}:{}}}),Ht(``),Wt(``),Kt(``),Jt(``),Zt(``),$t(!1))},ei=e=>{let t=e.trim();if(!t)return;let n=St();fn(n),mn(t),$({type:`plugin_catalog_sync`,requestId:n,source:t,...sn?{install:!0}:{},...ln?{replace:!0}:{}})},[ti,ri]=(0,m.useState)(``);(0,m.useEffect)(()=>{let e=Vt.trim();if(!e){ri(``);return}let t=setTimeout(()=>{let t=St();ri(t),$({type:`plugin_install_inspect`,requestId:t,source:e,...Ut.trim()?{explicitId:Ut.trim()}:{}})},500);return()=>clearTimeout(t)},[Vt,Ut]);let ii=e.installInspect,ai=ii&&ii.requestId===ti&&ii.source===Vt.trim()?ii:null,oi=e.catalogSync&&e.catalogSync.requestId===dn?e.catalogSync:null;(0,m.useEffect)(()=>{oi?.ok&&pn&&gn(ey(pn))},[oi?.requestId,oi?.ok]);let si=e=>{let t=new Set(g.reviewSkills.filter(e=>!e.enabled).map(e=>e.name));t.has(e.name)?t.delete(e.name):t.add(e.name),Q({reviewDisabledSkills:[...t]})},ci=()=>Q({promptTemplate:D}),li=e=>{Q({promptOverrides:{[e]:k[e]??``}})},ui=e=>{ee.current===e&&(ee.current=null),ne(null),A(t=>{let n={...t};return delete n[e],n}),Q({promptOverrides:{[e]:``}})},pi=e=>B(t=>({...t,[e]:!t[e]})),mi=(e,t)=>{A(n=>({...n,[e]:t})),ne(e)},hi=()=>{j.current=!1,ee.current=null,O(qv),A({}),Q({promptTemplate:qv,promptOverrides:{}})},gi=e=>{O(t=>t.trim()?`${t}\n\n{{${e}}}`:`{{${e}}}`)},_i=D.trim()&&D.trim()!==qv||Object.values(k).some(e=>e.trim());return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:i,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":l(`close`),onClick:i,children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(U,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:l(`settingsTitle`)}),(0,X.jsx)(Zc,{text:l(`settingsDesc`)})]}),(0,X.jsxs)(`div`,{className:`settings-layout`,children:[(0,X.jsx)(`nav`,{className:`settings-rail`,"aria-label":l(`settingsTitle`),ref:E,children:er.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-tab":e.id,className:`settings-tab${x===e.id?` active`:``}`,"aria-current":x===e.id?`true`:void 0,title:e.hint??e.label,onClick:()=>S(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:T,children:[x===`prompt`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(M,{className:`set-section-icon`}),l(`settingsSystemPrompt`),(0,X.jsx)(Zc,{text:`${l(`promptComposeHint`)}\n${l(`promptComposeDesc`)}`})]}),(0,X.jsxs)(`div`,{className:`set-prompt-view-triggers`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":Ze,onClick:()=>Qe(e=>!e),children:[(0,X.jsx)(`span`,{children:l(`settingsViewPrompt`)}),nt>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:l(`settingsViewPromptTokens`,{n:nt.toLocaleString()})}),(0,X.jsx)(`span`,{children:Ze?`▴`:`▾`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":$e,onClick:()=>tt(e=>!e),children:[(0,X.jsx)(`span`,{children:l(`settingsViewToolsSchema`)}),it>0&&(0,X.jsx)(`span`,{className:`set-prompt-token-est`,children:l(`settingsViewPromptTokens`,{n:it.toLocaleString()})}),(0,X.jsx)(`span`,{children:$e?`▴`:`▾`})]}),at>0&&(0,X.jsx)(`span`,{className:`set-prompt-total-est`,children:l(`settingsPromptContextTotal`,{n:at.toLocaleString()})})]}),Ze&&(0,X.jsxs)(`div`,{className:`set-prompt-view`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:l(`settingsViewPrompt`)}),(0,X.jsx)(Zc,{text:l(`settingsViewPromptHint`)}),(0,X.jsx)(Ql,{text:g.effectiveSystemPrompt})]}),g.effectiveSystemPrompt?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:g.effectiveSystemPrompt}):(0,X.jsx)(`p`,{className:`set-empty`,children:l(`settingsViewPromptEmpty`)})]}),$e&&(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:l(`settingsViewToolsSchema`)}),(0,X.jsx)(Zc,{text:l(`settingsViewToolsSchemaHint`)}),(0,X.jsx)(Ql,{text:g.toolsSchema})]}),g.toolsSchema?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:g.toolsSchema}):(0,X.jsx)(`p`,{className:`set-empty`,children:l(`settingsViewToolsSchemaEmpty`)})]})}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`promptTemplateLabel`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:6,spellCheck:!1,placeholder:qv,value:D,onFocus:()=>j.current=!0,onBlur:()=>{j.current=!1,ci()},onChange:e=>O(e.target.value)}),(0,X.jsxs)(`div`,{className:`compose-toolbar`,children:[(0,X.jsx)(`span`,{className:`set-field-label set-muted`,children:l(`promptInsertTokens`)}),L.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`token-chip`,title:d(`promptTok_${e}_desc`),onClick:()=>gi(e),children:`{{${e}}}`},e))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`promptSourcesLabel`)}),L.map(e=>{let t=k[e]??``,n=g.promptSourceDefaults?.[e]??``,r=te===e,i=n.split(`
|
|
362
|
+
`).length>6||n.length>480;if(Kv(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:[d(`promptTok_${e}`),` `,(0,X.jsx)(Zc,{text:d(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,title:l(`promptReadonlyLockedHint`),onClick:()=>ui(e),children:l(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:l(`promptReadonlyBadge`)})]}),(0,X.jsx)(`div`,{className:`source-default readonly${r.trim()?``:` empty`}`,title:l(`promptReadonlyTitle`),children:r.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?re[e]?` expanded`:` clamped`:``}`,children:r}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),pi(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),pi(e))},children:re[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`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:[d(`promptTok_${e}`),` `,(0,X.jsx)(Zc,{text:d(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,onClick:()=>ui(e),children:l(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:l(`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(`
|
|
363
|
+
`).length)),autoFocus:r,placeholder:l(`promptOverridePlaceholder`),value:t,onFocus:t=>{ee.current=e,ne(e);let r=t.currentTarget;r.value&&r.value===n&&r.setSelectionRange(r.value.length,r.value.length)},onBlur:()=>{ee.current===e&&(ee.current=null);let t=k[e]??``;if(t.trim()&&t===n){ui(e);return}li(e),t.trim()||ne(null)},onChange:t=>A(n=>({...n,[e]:t.target.value}))}),(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:l(`promptSourceRefLabel`)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`source-default-toggle`,onClick:()=>pi(e),children:re[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}),n.trim()?(0,X.jsx)(`pre`,{className:`source-default-text${i?re[e]?` expanded`:` clamped`:``}`,children:n}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)}),!t.trim()&&n.trim()&&(0,X.jsx)(`button`,{type:`button`,className:`override-seed-btn`,title:l(`promptSourceSeedTip`),onClick:()=>mi(e,n),children:l(`promptSourceSeedButton`)})]})]}):(0,X.jsx)(`div`,{className:`source-default`,title:l(`promptSourceDefaultEditHint`),role:`button`,tabIndex:0,onClick:()=>mi(e,n),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),mi(e,n))},children:n.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?re[e]?` expanded`:` clamped`:``}`,children:n}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),pi(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),pi(e))},children:re[e]?l(`promptSourceCollapse`):l(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:l(`promptSourceDefaultEmpty`)})})]},e)}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-btn`,onClick:hi,disabled:!_i,children:l(`promptResetAll`)})})]})]}),x===`prompt`&&!b&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(je,{className:`set-section-icon`}),l(`scmCommitMsgSettingsTitle`),(0,X.jsx)(Zc,{text:l(`scmCommitMsgSettingsDesc`)})]}),(0,X.jsx)(sy,{mode:fe,onModeChange:pe,draft:le,onDraftChange:ue,defaultPrompt:g.scmCommitMsgDefaultPrompt,placeholder:l(`scmCommitMsgPromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({scmCommitMsgPromptMode:e,scmCommitMsgPrompt:t})},hint:l(`scmCommitMsgSettingsHint`),focusRef:me})]}),x===`prompt`&&!b&&(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`}),l(`planModePromptSettingsTitle`),(0,X.jsx)(Zc,{text:l(`planModePromptSettingsDesc`)})]}),(0,X.jsx)(sy,{mode:q,onModeChange:ve,draft:he,onDraftChange:ge,defaultPrompt:g.planModeDefaultPrompt,placeholder:l(`planModePromptPlaceholder`),rows:8,onCommit:(e,t)=>{Q({planModePromptMode:e,planModePrompt:t})},modeLabel:l(`planModePromptMode`),hint:l(`planModePromptSettingsHint`),focusRef:ye})]}),x===`scheduler`&&!b&&(0,X.jsx)(U_,{tasks:e.schedulerTasks,cwd:e.state?.cwd??``,models:g.subagentModels}),x===`prompt-history`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Ye,{className:`set-section-icon`}),l(`settingsPromptHistory`),(0,X.jsx)(Zc,{text:l(`settingsPromptHistoryDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:l(`promptHistoryCount`,{n:String(Tt)})})]}),Tt===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`promptHistoryEmpty`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:l(`promptHistoryCount`,{n:String(Tt)})}),(0,X.jsx)(oy,{label:l(`promptHistoryMax`),tip:l(`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(Ct.maxEntries),onChange:e=>{let t=Math.floor(Number(e.target.value)||0),n={...Ct,maxEntries:t};wt(n)},onBlur:()=>{let e={...Ct};(!Number.isFinite(e.maxEntries)||e.maxEntries<1)&&(e.maxEntries=1),e.maxEntries>500&&(e.maxEntries=500),e.maxEntries=Math.floor(e.maxEntries),wt(e),vh(e),kt()}})}),(0,X.jsx)(ny,{title:l(`promptHistoryCharLimit`),tip:l(`promptHistoryCharLimitHint`),enabled:Ct.charLimitEnabled,onToggle:()=>{let e={...Ct,charLimitEnabled:!Ct.charLimitEnabled};wt(e),vh(e),kt()}}),Ct.charLimitEnabled&&(0,X.jsx)(oy,{label:l(`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:l(`promptHistoryCharLimitPlaceholder`),value:String(Ct.charLimit),onChange:e=>{let t=Math.floor(Number(e.target.value)||0);wt({...Ct,charLimit:t})},onBlur:()=>{let e=Math.floor(Number(Ct.charLimit)||0);(!Number.isFinite(e)||e<100)&&(e=100),e>2e4&&(e=2e4);let t={...Ct,charLimit:e};wt(t),vh(t),kt()}})}),(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:12},children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${Dt?` confirm`:``}`,disabled:Tt===0,title:l(Tt===0?`promptHistoryEmpty`:`promptHistoryClear`),onClick:()=>{if(!Dt){Ot(!0);return}wh(),Ot(!1),kt()},children:[(0,X.jsx)(R,{}),` `,l(Dt?`promptHistoryClearConfirm`:`promptHistoryClear`)]}),Tt>0&&(0,X.jsx)(`span`,{className:`set-hint`,style:{marginLeft:8},children:l(`promptHistoryCount`,{n:String(Tt)})})]}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[(0,X.jsx)(mt,{style:{verticalAlign:`-2px`,marginRight:4}}),l(`settingsPromptHistoryDesc`)]})]}),x===`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`}),l(`settingsTools`)]}),Gn&&(0,X.jsxs)(`p`,{className:`set-catalog-hint warn`,children:[l(`toolsPresetBanner`,{name:qn,count:Yn+Xn}),` `,(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>$({type:`dsh_preset_default`,preset:`standard`}),children:l(`toolsBackToStandard`)})]}),(0,X.jsx)(ny,{title:l(`readDirEnabled`),tip:l(`readDirEnabledDesc`),enabled:g.readDirEnabled!==!1,onToggle:()=>Q({readDirEnabled:g.readDirEnabled===!1})}),(0,X.jsx)(ny,{title:l(`toolApprovalEnabled`),tip:l(`toolApprovalEnabledDesc`),enabled:g.toolApprovalEnabled!==!1,onToggle:()=>Q({toolApprovalEnabled:g.toolApprovalEnabled===!1}),action:b?void 0:(0,X.jsxs)(`button`,{type:`button`,className:`tpl-chip`,onClick:()=>S(`approval-rules`),title:l(`settingsApprovalRulesDesc`),children:[(0,X.jsx)(H,{}),` `,l(`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:[l(`dshPermDefault`),(0,X.jsx)(Zc,{text:l(`dshPermDefaultDesc`)})]}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:Qh.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:l($h(e))},e))})]}),_?.allowAll||(_?.categories.length??0)>0?(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolApprovalPolicyTitle`),(0,X.jsx)(Zc,{text:l(`toolApprovalPolicyHint`)})]}),_?.allowAll&&(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:l(`toolApprovalPolicyAllowAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,allowAll:!1}),children:l(`toolApprovalPolicyRevoke`)})]}),(_?.categories??[]).map(e=>(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsx)(`span`,{className:`set-hint`,children:u===`zh`?e.label:e.labelEn}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`set_approval_policy`,categories:(_?.categories??[]).filter(t=>t.id!==e.id).map(e=>e.id)}),children:l(`toolApprovalPolicyRevoke`)})]},e.id))]}):null,(0,X.jsx)(oy,{label:l(`toolWatchdogTimeout`),tip:l(`toolWatchdogTimeoutDesc`),htmlFor:`tool-watchdog-timeout`,children:(0,X.jsx)(`input`,{id:`tool-watchdog-timeout`,className:`set-input`,type:`number`,min:0,step:1,placeholder:l(`toolWatchdogOff`),value:Dn,onChange:e=>kn(e.target.value),onBlur:()=>{let e=Dn.trim(),t=e===``?20:Math.max(0,Math.floor(Number(e)||0));kn(String(t));let n=t*6e4;n!==g.toolWatchdogTimeoutMs&&Q({toolWatchdogTimeoutMs:n})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionCore`),(0,X.jsx)(Zc,{text:l(`toolsCoreHint`)})]}),xr.map(e=>{let t=Jn(e);return(0,X.jsx)(ny,{title:e,tip:hr[e],subtitle:t?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Hn.has(e),disabled:t,onToggle:()=>gr(e)},e)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:l(`toolsSectionTerminal`)}),rr.map(e=>{let t=Jn(e);return(0,X.jsx)(ny,{title:e,tip:l(`settingsTerminalToolsDesc`),subtitle:t?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Hn.has(e),disabled:t,onToggle:()=>gr(e)},e)}),(0,X.jsx)(ny,{title:l(`terminalBashTakeover`),tip:l(`terminalBashTakeoverDesc`),enabled:g.terminalBash,onToggle:()=>Q({terminalBash:!g.terminalBash})}),g.terminalBash&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oy,{label:l(`terminalBashIdleMs`),tip:l(`terminalBashIdleMsDesc`),htmlFor:`tb-idle-ms`,children:(0,X.jsx)(`input`,{id:`tb-idle-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:xn,onChange:e=>Sn(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(xn)||0));Sn(String(e)),e!==g.terminalBashIdleMs&&Q({terminalBashIdleMs:e})}})}),(0,X.jsx)(oy,{label:l(`terminalBashMaxForegroundMs`),tip:l(`terminalBashMaxForegroundMsDesc`),htmlFor:`tb-max-ms`,children:(0,X.jsx)(`input`,{id:`tb-max-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:Cn,onChange:e=>Tn(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(Cn)||0));Tn(String(e)),e!==g.terminalBashMaxForegroundMs&&Q({terminalBashMaxForegroundMs:e})}})})]}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionSubagent`),` `,(0,X.jsx)(Zc,{text:l(`toolsSubagentDepHint`)})]}),ir.map(e=>{let t=Jn(e);return(0,X.jsx)(ny,{title:e,tip:mr[e],subtitle:t?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Hn.has(e),disabled:t,onToggle:()=>gr(e)},e)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`settingsMarkers`),(0,X.jsx)(Zc,{text:`${l(`settingsMarkersDesc`)}\n${l(`markerRenameTip`)}`})]}),(0,X.jsx)(ny,{title:l(`markersEnabled`),tip:`${l(`markersEnabledDesc`)}\n${l(`markersOffHint`)}`,enabled:wr,onToggle:()=>Q({markersEnabled:!wr})}),wr&&(g.markers?.length??0)===0&&(0,X.jsxs)(`p`,{className:`set-empty`,children:[l(`loading`),`...`]}),wr&&g.markers&&g.markers.length>0&&g.markers.map(e=>(0,X.jsx)(ny,{title:e.name===`todo`?l(`markerGroupTodo`):e.name===`notify`?l(`markerGroupNotify`):e.name===`conv`?l(`markerGroupRename`):e.name,tip:e.guidance.join(`
|
|
364
|
+
`),enabled:e.enabled,onToggle:()=>Er(e.name)},e.name)),(0,X.jsx)(ny,{title:`todo_list`,tip:`${l(`todoListEnabledDesc`)}\n${l(`todoListOffHint`)}`,subtitle:Jn(`todo_list`)?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!Jn(`todo_list`)&&!Hn.has(`todo_list`),disabled:Jn(`todo_list`),onToggle:()=>gr(`todo_list`)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:l(`toolsSectionOther`)}),Xv.map(e=>{let t=Jn(e.name);return(0,X.jsx)(ny,{title:e.name,tip:`${d(e.descKey??e.name)}\n${d(e.offHintKey??e.name)}`,subtitle:t?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Hn.has(e.name),disabled:t,onToggle:()=>gr(e.name)},e.name)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`toolsSectionPlugin`),(0,X.jsx)(Zc,{text:l(`toolsPluginHint`)})]}),yr.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:e.plugins.length===0?l(`noUiPlugins`):l(`pluginToolsEmpty`)}):yr.map(e=>{let t=ur.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?` (${l(`pluginDisabledInPlugins`)})`:``]}),e.tools.map(e=>(0,X.jsx)(ny,{title:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name,tip:e.description?`${e.description}\n${l(`pluginToolOffHint`)}`:l(`pluginToolOffHint`),subtitle:t?l(`pluginToolsDisabledByPlugin`):Gn?l(`toolsBlockedByPreset`,{name:qn}):void 0,enabled:!t&&!Gn&&!_r.has(e.name),disabled:t||Gn,onToggle:()=>!t&&!Gn&&vr(e.name)},e.name))]},e.plugin.id)})]}),x===`question`&&(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`}),l(`settingsQuestionnaire`)]}),(0,X.jsx)(ny,{title:l(`questionnaireEnabled`),tip:`${l(`questionnaireEnabledDesc`)}\n${l(`questionnaireOffHint`)}`,enabled:g.questionnaireEnabled,onToggle:()=>Q({questionnaireEnabled:!g.questionnaireEnabled})})]}),x===`display`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(_e,{className:`set-section-icon`}),l(`settingsMessageDisplay`)]}),(0,X.jsx)(oy,{label:l(`softCapTokens`),tip:l(`softCapHint`),htmlFor:`soft-cap-max`,children:(0,X.jsx)(`input`,{id:`soft-cap-max`,className:`set-input`,type:`text`,placeholder:l(`softCapOff`),value:Mn,onChange:e=>Nn(e.target.value),onBlur:()=>{let e=$_(Mn);Nn(ev(e)),e!==(g.softCapTokens??0)&&Q({softCapTokens:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-section-title`,children:[l(`softCapByModel`),(0,X.jsx)(Zc,{text:l(`softCapByModelHint`)})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`softCapModelId`),value:Pn,maxLength:200,onChange:e=>Fn(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,placeholder:l(`softCapTokens`),value:In,onChange:e=>Ln(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&Pn.trim()&&$_(In)>0){let e=$_(In);Q({softCapByModel:{...g.softCapByModel,[Pn.trim()]:e}}),Fn(``),Ln(``)}}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Pn.trim()||$_(In)<=0,onClick:()=>{let e=Pn.trim(),t=$_(In);!e||t<=0||(Q({softCapByModel:{...g.softCapByModel,[e]:t}}),Fn(``),Ln(``))},children:[(0,X.jsx)(ce,{}),` `,l(`softCapAdd`)]})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Object.entries(g.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:ev(t),onBlur:t=>{let n=$_(t.target.value);t.target.value=ev(n);let r={...g.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:l(`softCapRemove`),onClick:()=>{let t={...g.softCapByModel};delete t[e],Q({softCapByModel:t})},children:[(0,X.jsx)(N,{}),` `,l(`softCapRemove`)]})]},e))}),(0,X.jsx)(oy,{label:l(`modelRetryAttempts`),tip:l(`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:An,onChange:e=>jn(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(0,Math.floor(Number(An)||0)));jn(String(e)),e!==g.retryMaxAttempts&&Q({retryMaxAttempts:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(ny,{title:l(`thinkingWrap`),tip:l(`thinkingWrapDesc`),enabled:g.thinkingWrap??!0,onToggle:()=>Q({thinkingWrap:!(g.thinkingWrap??!0)})}),(0,X.jsx)(ny,{title:l(`toolsWrap`),tip:l(`toolsWrapDesc`),enabled:g.toolsWrap??!0,onToggle:()=>Q({toolsWrap:!(g.toolsWrap??!0)})}),(0,X.jsx)(ny,{title:l(`toolImages`),tip:l(`toolImagesDesc`),enabled:g.toolImagesEnabled??!0,onToggle:()=>Q({toolImagesEnabled:!(g.toolImagesEnabled??!0)})}),(0,X.jsx)(ny,{title:l(`presentAutoOpen`),tip:l(`presentAutoOpenDesc`),enabled:ct,onToggle:()=>Wd(!ct)}),(0,X.jsx)(ny,{title:l(`parallelReminderEnabled`),tip:`${l(`parallelReminderEnabledDesc`)}\n${l(`parallelReminderOffHint`)}`,enabled:g.parallelReminderEnabled??!0,onToggle:()=>Q({parallelReminderEnabled:!(g.parallelReminderEnabled??!0)})}),(0,X.jsx)(ny,{title:l(`devNoCache`),tip:l(`devNoCacheDesc`),enabled:g.devNoCache??!0,onToggle:()=>Q({devNoCache:!(g.devNoCache??!0)})}),(0,X.jsx)(ny,{title:l(`autoReload`),tip:l(`autoReloadDesc`),enabled:g.autoReload??!0,onToggle:()=>Q({autoReload:!(g.autoReload??!0)})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsx)(ny,{title:l(`wideChat`),tip:l(`wideChatDesc`),enabled:ot,onToggle:()=>av({wide:!ot})}),(0,X.jsx)(ny,{title:l(`projectTitle`),tip:l(`projectTitleDesc`),enabled:lt,onToggle:()=>gv({projectName:!lt})}),(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:[l(`wallpaperTitle`),(0,X.jsx)(Zc,{text:l(`wallpaperDesc`)})]}),(0,X.jsxs)(`div`,{className:`wallpaper-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input wallpaper-url`,placeholder:l(`wallpaperUrlPh`),value:dt,maxLength:2e3,spellCheck:!1,onFocus:()=>{pt.current=!0},onChange:e=>ft(e.target.value),onBlur:()=>{if(pt.current=!1,!dt.trim()&&ut.url.startsWith(`data:`)){ft(``);return}let e=Dv(dt);ft(e),e!==ut.url&&Pv({...ut,url:e})},onKeyDown:e=>{e.key===`Enter`?e.target.blur():e.key===`Escape`&&(ft(ut.url.startsWith(`data:`)?``:ut.url),e.target.blur())}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:_t,onClick:()=>ht.current?.click(),children:[(0,X.jsx)(I,{}),` `,l(`wallpaperUpload`)]}),(0,X.jsx)(`input`,{ref:ht,type:`file`,accept:`image/*`,hidden:!0,onChange:xt})]}),yt&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`wallpaperUploadFailed`)}),(0,X.jsxs)(`div`,{className:`wallpaper-sliders`,children:[(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:l(`wallpaperDim`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:95,step:1,value:ut.dim,onChange:e=>Pv({...ut,dim:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[ut.dim,`%`]})]}),(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:l(`wallpaperBlur`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:24,step:1,value:ut.blur,onChange:e=>Pv({...ut,blur:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[ut.blur,`px`]})]})]})]}),ut.url&&(0,X.jsxs)(`div`,{className:`wallpaper-current`,children:[(0,X.jsx)(`img`,{className:`wallpaper-preview`,src:ut.url,alt:``}),(0,X.jsx)(`button`,{type:`button`,className:`wallpaper-clear`,onClick:()=>{ft(``),Pv({...ut,url:``})},children:l(`wallpaperClear`)})]})]})]}),x===`sound`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(P,{className:`set-section-icon`}),l(`settingsSoundVoice`)]}),(0,X.jsx)(En,{settings:a,onChange:o,onPreview:e=>Q_(e,a)}),(0,X.jsx)(On,{settings:s,onChange:c,onPreview:()=>Xt(l(`ttsPreviewLine`),{...s,enabled:!0})})]}),x===`quick`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(W,{className:`set-section-icon`}),l(`quickPhrases`),(0,X.jsx)(Zc,{text:l(`quickPhrasesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.quickPhrases.length})]}),(0,X.jsx)(ny,{title:l(`quickPhrasesEnabled`),tip:l(`quickPhrasesDesc`),enabled:g.quickPhrasesEnabled,onToggle:()=>Q({quickPhrasesEnabled:!g.quickPhrasesEnabled})}),!g.quickPhrasesEnabled&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`quickPhrasesOffHint`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`quickPhrasesPlaceholder`),value:_n,maxLength:200,onChange:e=>vn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_n.trim()&&(Q({quickPhrases:[...g.quickPhrases,_n.trim()]}),vn(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!_n.trim(),onClick:()=>{Q({quickPhrases:[...g.quickPhrases,_n.trim()]}),vn(``)},children:[(0,X.jsx)(ce,{}),` `,l(`quickPhrasesAdd`)]})]}),g.quickPhrases.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`quickPhrasesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.quickPhrases.map((e,t)=>(0,X.jsx)(`div`,{className:`set-row`,children:yn?.index===t?(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`input`,{className:`set-input`,autoFocus:!0,value:yn.value,maxLength:200,placeholder:l(`quickPhrasesEditPh`),onChange:e=>bn({index:t,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?or():e.key===`Escape`&&bn(null)},onBlur:or})}):(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:l(`quickPhrasesEdit`),onClick:()=>bn({index:t,value:e}),children:(0,X.jsx)(Le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`quickPhrasesMoveUp`),disabled:t===0,onClick:()=>{let e=[...g.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:l(`quickPhrasesMoveDown`),disabled:t===g.quickPhrases.length-1,onClick:()=>{let e=[...g.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:l(`quickPhrasesDelete`),onClick:()=>Q({quickPhrases:g.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:()=>{bn(null),Q({quickPhrases:Uv[u]??Uv.en})},children:l(`quickPhrasesReset`)})})]}),x===`skills`&&(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`}),l(`settingsSkills`),(0,X.jsx)(Zc,{text:`${l(`skillFullTextLabel`)}:${l(`skillFullTextDesc`)}`}),(0,X.jsx)(`span`,{className:`set-count`,children:g.skills.length})]}),!b&&Gn&&!Cr(Wn??void 0)&&(0,X.jsx)(`p`,{className:`set-catalog-hint warn`,children:l(`skillsHiddenByPreset`,{name:qn})}),g.skills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(b?`dshSkillsNote`:`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.skills.map(e=>(0,X.jsx)(ny,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>sr(e),action:(0,X.jsx)(`button`,{type:`button`,className:`tpl-chip${cr.has(e.name)?` on`:``}`,title:l(`skillFullTextDesc`),onClick:()=>lr(e.name),children:l(`skillFullTextShort`)})},e.name))})]}),x===`extensions`&&(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`}),l(`settingsExtensions`),(0,X.jsx)(`span`,{className:`set-count`,children:g.extensions.length})]}),g.extensions.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(b?`dshExtensionsNote`:`noExtensions`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.extensions.map(e=>{let t=e.id.startsWith(`npm:`)?e.id.slice(4):null;return(0,X.jsx)(ny,{title:e.name,subtitle:e.path,enabled:e.enabled,onToggle:()=>pr(e),action:t?At===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`uninstallConfirmHint`),onClick:()=>Or(t),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`uninstallHint`),onClick:()=>jt(e.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]}):void 0},e.id)})})]}),x===`layout`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(V,{className:`set-section-icon`}),l(`uiLayoutTitle`),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:Jr,children:l(`uiLayoutRestoreAll`)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:l(`uiLayoutHint`)}),(0,X.jsxs)(`label`,{className:`set-toggle`,title:`sideDockFloat`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Br?.sideDockFloat===!0,onChange:e=>Vr({sideDockFloat:e.target.checked})}),(0,X.jsx)(`span`,{children:l(`uiLayoutSideDockFloat`)})]}),Rn.length>0&&(0,X.jsxs)(`details`,{className:`set-ui-diag`,open:Rn.some(e=>e.level===`error`),children:[(0,X.jsxs)(`summary`,{children:[`⚠ `,l(`uiLayoutDiagTitle`,{n:Rn.length})]}),(0,X.jsx)(`ul`,{className:`set-ui-diag-list`,children:Rn.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:l(`uiLayoutDiagHint`)})]}),(0,X.jsx)(`input`,{className:`set-ui-filter`,value:Lr,placeholder:l(`uiLayoutSearch`),"aria-label":l(`uiLayoutSearch`),onChange:e=>Rr(e.target.value)}),Nr.map(({slot:e,labelKey:t})=>{let n=(zn[e]??[]).filter(e=>(b||e.id!==`host:composer-dsh-perm`&&e.id!==`host:composer-dsh-preset`&&e.id!==`host:goal-plan`)&&!fi.has(e.id)),r=Lr.trim().toLowerCase(),i=!r&&Pr.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=di.has(t.id);return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`label`,{className:`set-toggle`,title:o?l(`uiLayoutRequired`):t.id,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!t.hidden,disabled:o,onChange:()=>Hr(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:l(`uiLayoutArranged`)}),t.movedFrom&&(0,X.jsxs)(`span`,{className:`set-ui-source`,title:t.id,children:[l(`uiLayoutMovedFrom`),`: `,zr(t.movedFrom)]}),Ir.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:l(`uiLayoutPosition`),children:(0,X.jsxs)(`select`,{value:e,onChange:e=>Gr(t.id,e.target.value),"aria-label":l(`uiLayoutPosition`),children:[(0,X.jsx)(`option`,{value:`topbar.primary`,children:l(`uiLayoutPosTop`)}),(0,X.jsx)(`option`,{value:`bottombar`,children:l(`uiLayoutPosBottom`)}),(0,X.jsx)(`option`,{value:`sidebar.left`,children:l(`uiLayoutPosLeft`)}),(0,X.jsx)(`option`,{value:`sidebar.right`,children:l(`uiLayoutPosRight`)})]})}),Pr.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:l(`uiLayoutAlign`),children:(0,X.jsx)(`select`,{value:t.align,onChange:e=>Wr(t.id,e.target.value),"aria-label":l(`uiLayoutAlign`),children:Fr(e)?xg.map(e=>(0,X.jsx)(`option`,{value:e,children:Sg(l,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:Br?.labels?.[t.id]??``,placeholder:l(`uiLayoutRename`),title:l(`uiLayoutRename`),"aria-label":l(`uiLayoutRename`),onBlur:e=>{e.target.value!==(Br?.labels?.[t.id]??``)&&Kr(t.id,e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.target.blur()}},`${t.id}:${Br?.labels?.[t.id]??``}`),t.userOverrides.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>qr(t.id),children:l(`uiLayoutRestore`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<=0,onClick:()=>Ur(n,i,t.id,-1),children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||a<0||a>=i.length-1,onClick:()=>Ur(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:l(t)}),e===`topbar.primary`&&(0,X.jsxs)(`label`,{className:`set-toggle`,title:`topbarText`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Br?.topbarText!==!1,onChange:e=>Vr({topbarText:e.target.checked})}),(0,X.jsx)(`span`,{children:l(`uiLayoutTopbarText`)})]}),n.length===0?(0,X.jsx)(`div`,{className:`set-empty`,children:l(`uiLayoutEmpty`)}):i.map(t=>(0,X.jsxs)(m.Fragment,{children:[t.align&&(0,X.jsx)(`div`,{className:`set-ui-slot-title set-ui-seg`,children:Fr(e)?Sg(l,t.align):t.align}),t.items.map(e=>o(e,t.items))]},t.align??`all`))]},e)})]}),x===`plugins`&&!y&&(0,X.jsxs)(`div`,{className:`set-subtabs`,role:`tablist`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`market`,className:`set-subtab${C===`market`?` active`:``}`,onClick:()=>{w(`market`),T.current?.scrollTo({top:0})},children:[l(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":C===`installed`,className:`set-subtab${C===`installed`?` active`:``}`,onClick:()=>{w(`installed`),T.current?.scrollTo({top:0})},children:[(0,X.jsx)(st,{}),l(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(Qn||$n)&&(0,X.jsx)(`span`,{className:`update-dot`,style:{marginLeft:4}})]})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Me,{className:`set-section-icon`}),l(`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:l(`pluginGrantsHint`)}),e.pluginGrants.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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:l(`pluginGrantsRevoke`)})]},t))]},e.pluginId))})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Te,{className:`set-section-icon`}),l(`pluginPermsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:(e.pluginPermissions??[]).length})]}),(0,X.jsx)(`div`,{className:`set-note`,children:l(`pluginPermsHint`)}),(e.pluginPermissions??[]).length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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`?l(`pluginPermNet`):l(`pluginPermLlm`),e.session?` · ${l(`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:l(`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:l(`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??l(`pluginPermUnscoped`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:e.family}),children:l(`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}`))})]}),x===`plugins`&&y&&(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-note`,children:l(`updatesManaged`)})}),x===`plugins`&&!y&&C===`market`&&(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`}),l(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`div`,{className:`set-toolbar`,children:[(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginBuildHint`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:en,onChange:e=>tn(e.target.checked)}),l(`pluginBuildSource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogSyncHint`),onClick:()=>rn(e=>!e),children:[(0,X.jsx)(K,{}),l(`pluginCatalogSync`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogAddHint`),onClick:()=>$t(e=>!e),children:[(0,X.jsx)(ce,{}),l(`pluginCatalogAdd`)]})]}),nn&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`div`,{className:`set-note`,children:l(`pluginCatalogSyncHint`)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogSyncSource`),value:an,onChange:e=>on(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ei(an)}}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginCatalogSyncInstall`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:sn,onChange:e=>cn(e.target.checked)}),l(`pluginCatalogSyncInstall`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:l(`pluginCatalogSyncReplace`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:ln,onChange:e=>un(e.target.checked)}),l(`pluginCatalogSyncReplace`)]}),hn.length>0&&(0,X.jsxs)(`div`,{className:`set-catalog-recent`,children:[(0,X.jsx)(`span`,{className:`set-catalog-recent-label`,children:l(`pluginCatalogSyncRecent`)}),hn.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-catalog-recent-item`,title:e,onClick:()=>{on(e),ei(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:!an.trim(),onClick:()=>ei(an),children:l(`pluginCatalogSyncSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>rn(!1),children:l(`cancel`)})]}),oi&&(oi.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[(0,X.jsxs)(`span`,{children:[`✓ `,l(`pluginCatalogSyncOk`,{n:oi.entryCount??0}),oi.installed?` · ${l(`pluginCatalogSyncInstalled`,{ok:oi.installed.filter(e=>e.ok).length,fail:oi.installed.filter(e=>!e.ok).length})}`:null]}),oi.installed?.some(e=>!e.ok)&&(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:oi.installed.filter(e=>!e.ok).map(e=>`${e.id}:${e.error??`?`}`).join(`
|
|
365
|
+
`)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,oi.error||l(`pluginJobFailed`)]})}))]}),Qt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogSource`),value:Vt,onChange:e=>Ht(e.target.value)}),jr(ai),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogId`),value:Ut,onChange:e=>Wt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogName`),value:Gt,onChange:e=>Kt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`pluginCatalogIcon`),value:Yt,onChange:e=>Zt(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:l(`pluginCatalogDesc`),value:qt,onChange:e=>Jt(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!Vt.trim(),onClick:$r,children:l(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$t(!1),children:l(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(t=>{let n=dr.has(t.id),r=e.pluginUpdates?.[t.id],i=n&&r?.updatable===!0,a=!!(Ar(t.id)&&Ar(t.id)?.phase!==`done`),o=u!==`zh`&&t.nameEn?t.nameEn:t.name,s=u!==`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)(ni,{icon:t.icon,iconSvg:t.iconSvg}),` `,o]}),n&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:l(`pluginInstalled`)}),!t.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:l(`pluginCatalogCustom`)}),i&&(0,X.jsxs)(`span`,{className:`set-catalog-update-badge`,title:r?.latestVersion?`${r?.version??``} → v${r.latestVersion}`:r?.remoteSha??``,children:[l(`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}),Mr(t.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${i?` accent`:``}`,disabled:a,title:i&&r?.latestVersion?l(`pluginUpdateAvailableDetail`,{version:`v${r.latestVersion}`}):l(`pluginUpdateHint`),onClick:()=>Xr(t.id,t.source),children:[(0,X.jsx)(K,{className:a?`set-job-spin`:``}),l(a?`pluginJobRunning`:`pluginUpdate`)]}),Mt===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:a,title:l(`pluginUninstallHint`),onClick:()=>Yr(t.id),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:a,title:l(`pluginUninstallHint`),onClick:()=>Nt(t.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]})]}):(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginInstallHint`),disabled:a,onClick:()=>Zr(t),children:a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(K,{className:`set-job-spin`}),l(`pluginJobRunning`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ze,{}),l(`pluginInstall`)]})}),!t.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCatalogRemoveHint`),onClick:()=>Qr(t.id),children:(0,X.jsx)(N,{})})]})]},t.id)})})]}),x===`plugins`&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(st,{className:`set-section-icon`}),l(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginCheckUpdatesHint`),disabled:e.checkingPluginUpdates,onClick:()=>$({type:`check_plugin_updates`}),children:[(0,X.jsx)(K,{className:e.checkingPluginUpdates?`spin`:``}),e.checkingPluginUpdates?l(`checkingUpdate`):l(`pluginCheckUpdates`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(K,{}),l(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(ay,{plugins:e.plugins,disabledIds:ur}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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=!!(Ar(t.id)&&Ar(t.id)?.phase!==`done`);return(0,X.jsxs)(m.Fragment,{children:[(0,X.jsx)(ny,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(iy,{phase:Vv(t,ur.has(t.id)),label:d(ry(Vv(t,ur.has(t.id))))}),(0,X.jsx)(ni,{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:[l(`pluginUpdateAvailableBadge`),n?.latestVersion?` v${n.latestVersion}`:``]})]}),subtitle:(t.error?`${t.id} · ${t.error}`:t.source?`${t.id} · ${t.source}`:`${t.id} · ${l(`uiPluginNoSource`)}`)+(t.permissions?.length?` · ${l(`uiPluginPerms`)}: ${t.permissions.join(`, `)}`:``),enabled:!ur.has(t.id)&&!t.error,onToggle:()=>!t.error&&fr(t),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${r?` accent`:``}`,disabled:i,title:r&&n?.latestVersion?l(`pluginUpdateAvailableDetail`,{version:`v${n.latestVersion}`}):l(`pluginUpdateHint`),onClick:()=>Xr(t.id,t.source),children:[(0,X.jsx)(K,{className:i?`set-job-spin`:``}),l(i?`pluginJobRunning`:`pluginUpdate`)]}),Mt===t.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:i,title:l(`pluginUninstallHint`),onClick:()=>Yr(t.id),children:l(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,disabled:i,title:l(`pluginUninstallHint`),onClick:()=>Nt(t.id),children:[(0,X.jsx)(R,{}),l(`uninstallExt`)]})]})},t.id),Mr(t.id),t.agentTools&&t.agentTools.length>0&&!b&&(0,X.jsxs)(`div`,{className:`set-row`,title:l(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[l(`pluginToolsSection`),` (`,t.agentTools.length,`)`,t.agentTools.some(e=>_r.has(e.name))?` · ${l(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>S(`tools`),children:[l(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{It===t.id?Lt(null):(Lt(t.id),$(zs(t.id)))},children:[(0,X.jsx)(Pe,{}),l(`pluginLogTitle`),` (`,Ks(t.id).length,`) ·`,` `,It===t.id?l(`pluginLogHide`):l(`pluginLogShow`)]}),It===t.id&&(0,X.jsx)(cy,{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:()=>Ft(Pt===t.id?null:t.id),children:[(0,X.jsx)(gt,{}),l(`pluginDiagTitle`),` (`,t.diagnostics.length,`) ·`,` `,Pt===t.id?l(`pluginDiagHide`):l(`pluginDiagShow`)]}),Pt===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:l(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:t.domGranted?l(`pluginDomGranted`):l(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${t.domGranted?``:` confirm`}`,title:l(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:t.id,granted:!t.domGranted}),children:t.domGranted?l(`pluginDomRevoke`):l(`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:()=>zt(e=>({...e,[t.id]:!e[t.id]})),children:[(0,X.jsx)(V,{}),l(`pluginSettingsTitle`),` (`,t.settingsSchema.length,`) ·`,` `,Rt[t.id]?l(`pluginSettingsHide`):l(`pluginSettingsShow`)]}),Rt[t.id]&&(0,X.jsx)(L_,{plugin:t,models:g?.subagentModels??[]})]})]},t.id)})})]}),x===`plugins`&&b&&C===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(st,{className:`set-section-icon`}),l(`dshPatches`),(0,X.jsx)(Zc,{text:l(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:l(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(K,{}),l(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`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:[xf(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[l(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),x===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(M,{className:`set-section-icon`}),l(`settingsReview`),(0,X.jsx)(Zc,{text:l(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.reviewSkills.length})]}),(0,X.jsx)(ny,{title:l(`goalModeEnabled`),tip:`${l(`goalModeEnabledDesc`)}\n${l(`goalModeOffHint`)}`,enabled:g.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!g.goalModeEnabled})}),(0,X.jsx)(ny,{title:l(`delegateMode`),tip:`${l(`delegateModeDesc`)}\n${l(`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:l(`reviewPromptPlaceholder`),value:be,onFocus:()=>Se.current=!0,onBlur:()=>{Se.current=!1,Q({reviewPrompt:be})},onChange:e=>xe(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[l(`settingsReviewSkills`),b&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(Zc,{text:l(`dshReviewPromptNote`)})]})]}),g.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.reviewSkills.map(e=>(0,X.jsx)(ny,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>si(e)},`review-${e.name}`))})]}),x===`vision`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(Fe,{className:`set-section-icon`}),l(`settingsVisionBridge`)]}),(0,X.jsx)(ny,{title:l(`visionBridgeEnabled`),tip:`${l(`settingsVisionBridgeDesc`)}\n${l(`visionBridgeOffHint`)}`,enabled:g.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!g.visionBridgeEnabled})}),g.visionBridgeEnabled&&(0,X.jsx)(oy,{label:l(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:g.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:l(`visionBridgeAuto`)}),g.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),g.visionBridgeEnabled&&(0,X.jsx)(sy,{mode:ae,onModeChange:oe,draft:ie,onDraftChange:G,defaultPrompt:g.visionBridgeDefaultPrompt,placeholder:l(`visionBridgePromptPlaceholder`),rows:4,onCommit:(e,t)=>{Q({visionBridgePromptMode:e,visionBridgePrompt:t})},hint:g.visionModels.length===0?l(`visionBridgeNoModels`):l(`visionBridgeCurrent`,{model:g.visionBridgeModel??l(`visionBridgeAuto`)}),focusRef:se})]}),x===`presets`&&e.dshPresets&&e.dshPresets.presets.length>0&&(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`}),l(`dshPreset`),(0,X.jsx)(Zc,{text:l(`dshDefaultPresetDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPresets.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`dshDefaultPreset`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:Yh(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[Jh(e,u,l).name,e.trust===`user`?` · ${l(`dshPresetUser`)}`:``]},e.id))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Yh(e.dshPresets.presets).map(t=>{let n=Jh(t,u,l);return(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[n.name,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetUser`)}),t.id===e.dshPresets.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:l(`dshPresetBroken`)})]}),n.description&&!t.broken&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:n.description}),t.broken&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t.broken})]})},t.id)})}),(0,X.jsx)(`p`,{className:`set-hint`,children:l(`dshPresetUserNote`)})]}),x===`presets`&&e.dshPermission&&e.dshPermission.options.length>0&&(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`}),l(`dshPerm`),(0,X.jsx)(Zc,{text:l(`dshPermDefaultDesc`)})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`dshPermDefault`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:Qh.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:l($h(e))},e))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Qh.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(t=>(0,X.jsx)(`div`,{className:`set-row`,children:(0,X.jsxs)(`div`,{className:`set-row-info`,children:[(0,X.jsxs)(`div`,{className:`set-row-name`,children:[l($h(t)),t===e.dshPermission.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:l(`dshPresetDefaultTag`)})]}),(0,X.jsx)(`div`,{className:`set-row-desc`,children:l(eg(t))})]})},t))})]}),x===`presets`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(U,{className:`set-section-icon`}),l(`settingsPresets`),(0,X.jsx)(`span`,{className:`set-count`,children:g.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`presetNamePlaceholder`),value:Ce,onChange:e=>we(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Ce.trim()&&($({type:`save_preset`,name:Ce.trim()}),we(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Ce.trim(),onClick:()=>{$({type:`save_preset`,name:Ce.trim()}),we(``)},children:[(0,X.jsx)(ce,{}),` `,l(`saveAsPreset`)]})]}),g.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:g.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`?l(`promptModeReplace`):l(`promptModeAppend`),e.disabledSkills.length>0&&` · ${l(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${l(`settingsExtensions`)} ${e.disabledExtensions.length}`]})]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`apply_preset`,name:e.name}),children:l(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),x===`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`}),l(`settingsSubagentTemplates`),(0,X.jsx)(Zc,{text:l(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:l(`subagentTemplateNew`),onClick:()=>{Ee({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),ke(!0)},children:[(0,X.jsx)(ce,{}),` `,l(`subagentTemplateNew`)]})]}),(0,X.jsx)(oy,{label:l(`subagentDefaultModelLabel`),tip:l(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:g.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:l(`subagentFollowMain`)}),g.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),g.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:l(`subagentNoModels`)}),J&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>Ee(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":l(`close`),onClick:()=>Ee(null),children:(0,X.jsx)(N,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(F,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:Oe?l(`subagentTemplateNew`):`${l(`subagentTemplateEdit`)} · ${J.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:l(`tplNamePlaceholder`),value:J.name,onChange:e=>Ee({...J,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`tplDescriptionPlaceholder`),value:J.description,onChange:e=>Ee({...J,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:l(`tplDescriptionEnPlaceholder`),value:J.descriptionEn??``,onChange:e=>Ee({...J,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.promptMode,onChange:e=>Ee({...J,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:l(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:l(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:l(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.model??``,onChange:e=>Ee({...J,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:l(`subagentFollowMain`)}),g.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:[l(`tplThinkingLabel`),` `,(0,X.jsx)(Zc,{text:l(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:J.thinkingLevel??``,onChange:e=>Ee({...J,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:l(`tplThinkingFollowMain`)}),Vh.map(e=>(0,X.jsx)(`option`,{value:e,children:l(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${l(`tplSystemPromptLabel`)}${u===`zh`?`:`:`: `}${l(`tplSystemPromptPlaceholder`)}`,value:J.systemPrompt,onChange:e=>Ee({...J,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${l(`tplSystemPromptLabel`)}: ${l(`tplSystemPromptEnPlaceholder`)}`,value:J.systemPromptEn??``,onChange:e=>Ee({...J,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:[l(`tplSkillsLabel`),` · `,l(`tplWhitelistHint`)]})}),g.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:g.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${J.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:J.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;Ee({...J,enabledSkills:n?[...J.enabledSkills,e.name]:J.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:[l(`tplExtensionsLabel`),` · `,l(`tplWhitelistHint`)]})}),g.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:g.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${J.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:J.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;Ee({...J,enabledExtensions:n?[...J.enabledExtensions,e.id]:J.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:!J.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...J,name:J.name.trim()}}),Ee(null)},children:l(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>Ee(null),children:l(`tplCancel`)})]})]})}),g.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:l(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:g.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,g.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:l(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:l(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(u!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?l(`promptModeReplace`):l(`promptModeAppend`)}`,e.model?` · ${l(`tplModelLabel`)} ${e.model}`:` · ${l(`subagentFollowMain`)}`,e.thinkingLevel?` · ${l(`tplThinkingLabel`)} ${d(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${l(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${l(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${l(`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?l(`subagentTemplateDisable`):l(`subagentTemplateEnable`)} · ${l(`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:l(`subagentTemplateEdit`),onClick:()=>{Ee({...e}),ke(!1)},children:l(`subagentTemplateEdit`)}),Ae===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:l(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),Ne(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`tplDelete`),onClick:()=>Ne(e.name),children:(0,X.jsx)(R,{})})]})]},e.name))})]}),x===`approval-rules`&&!b&&(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`}),l(`settingsApprovalRules`),(0,X.jsx)(Zc,{text:l(`settingsApprovalRulesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:g.approvalRules?.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:l(`approvalRuleNew`),onClick:()=>{Ie({id:`custom.${St().slice(0,8)}`,enabled:!0,tools:[`bash`],field:`command`,match:`regex`,value:``,action:`ask`,label:``,labelEn:``,reason:``,reasonEn:``}),He(`bash`),Be(!0),Ge(null)},children:[(0,X.jsx)(ce,{}),` `,l(`approvalRuleNew`)]})]}),Y&&(0,X.jsxs)(`div`,{className:`rule-editor`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,style:{fontSize:13,marginBottom:4},children:Re?l(`approvalRuleNew`):`${l(`approvalRuleEdit`)} · ${Y.label}`}),(0,X.jsx)(oy,{label:l(`approvalRuleLabel`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.label,placeholder:`例如:拦截 Docker 危险操作`,onChange:e=>Ie({...Y,label:e.target.value})})}),(0,X.jsx)(oy,{label:l(`approvalRuleLabelEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.labelEn??``,placeholder:`e.g. Block dangerous Docker commands`,onChange:e=>Ie({...Y,labelEn:e.target.value})})}),(0,X.jsx)(oy,{label:l(`approvalRuleTools`),tip:l(`approvalRuleToolsTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Ve,placeholder:`bash, write, edit (或 * 通配)`,onChange:e=>{He(e.target.value);let t=e.target.value.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean);Ie({...Y,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)(oy,{label:l(`approvalRuleField`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.field,onChange:e=>Ie({...Y,field:e.target.value}),children:[(0,X.jsx)(`option`,{value:`command`,children:l(`approvalRuleFieldCommand`)}),(0,X.jsx)(`option`,{value:`path`,children:l(`approvalRuleFieldPath`)}),(0,X.jsx)(`option`,{value:`params`,children:l(`approvalRuleFieldParams`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(oy,{label:l(`approvalRuleMatch`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.match,onChange:e=>Ie({...Y,match:e.target.value}),children:[(0,X.jsx)(`option`,{value:`regex`,children:l(`approvalRuleMatchRegex`)}),(0,X.jsx)(`option`,{value:`glob`,children:l(`approvalRuleMatchGlob`)}),(0,X.jsx)(`option`,{value:`contains`,children:l(`approvalRuleMatchContains`)}),(0,X.jsx)(`option`,{value:`prefix`,children:l(`approvalRuleMatchPrefix`)}),(0,X.jsx)(`option`,{value:`outside_workspace`,children:l(`approvalRuleMatchOutsideWs`)})]})})}),(0,X.jsx)(`div`,{style:{flex:1,minWidth:160},children:(0,X.jsx)(oy,{label:`命中动作`,children:(0,X.jsxs)(`select`,{className:`set-select`,value:Y.action,onChange:e=>Ie({...Y,action:e.target.value}),children:[(0,X.jsx)(`option`,{value:`ask`,children:l(`approvalRuleActionAsk`)}),(0,X.jsx)(`option`,{value:`deny`,children:l(`approvalRuleActionDeny`)}),(0,X.jsx)(`option`,{value:`allow`,children:l(`approvalRuleActionAllow`)})]})})})]}),Y.match!==`outside_workspace`&&(0,X.jsx)(oy,{label:l(`approvalRuleValue`),tip:l(`approvalRuleValueTip`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.value,placeholder:`匹配表达式或关键字…`,onChange:e=>Ie({...Y,value:e.target.value})})}),(0,X.jsx)(oy,{label:l(`approvalRuleReason`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.reason??``,placeholder:`例如:检测到删除镜像或容器操作`,onChange:e=>Ie({...Y,reason:e.target.value})})}),(0,X.jsx)(oy,{label:l(`approvalRuleReasonEn`),children:(0,X.jsx)(`input`,{className:`set-input`,value:Y.reasonEn??``,placeholder:`e.g. Detected docker image/container removal`,onChange:e=>Ie({...Y,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:Y.enabled,onChange:e=>Ie({...Y,enabled:e.target.checked})}),l(`approvalRuleEnabled`)]})}),We&&(0,X.jsx)(`div`,{style:{color:`var(--red, #ef4444)`,fontSize:12},children:We}),(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`flex-end`,gap:8,marginTop:4},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Ie(null),Ge(null)},children:l(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{if(!Y.label.trim()){Ge(`请填写规则名称`);return}if(Y.match===`regex`)try{new RegExp(Y.value)}catch(e){Ge(`正则表达式非法:${e.message}`);return}$({type:`save_approval_rule`,rule:Y}),Ie(null),Ge(null)},children:l(`save`)})]})]}),(g.approvalRules??[]).length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:l(`approvalRuleEmpty`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:(g.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`?l(`approvalRuleActionDeny`):e.action===`allow`?l(`approvalRuleActionAllow`):l(`approvalRuleActionAsk`)}),(0,X.jsx)(`strong`,{style:{fontSize:13},children:u===`zh`?e.label:e.labelEn||e.label}),n&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:l(`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:u===`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?l(`settingsEnabled`):l(`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:l(`approvalRuleMoveUp`),onClick:()=>{let e=[...g.approvalRules??[]],n=e[t-1];e[t-1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(et,{})}),!n&&t<(g.approvalRules?.length??0)-1&&(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleMoveDown`),onClick:()=>{let e=[...g.approvalRules??[]],n=e[t+1];e[t+1]=e[t],e[t]=n,$({type:`save_approval_rules`,rules:e})},children:(0,X.jsx)(rt,{})}),n&&(Je===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`reset_builtin_approval_rule`,id:e.id}),Xe(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleReset`),onClick:()=>Xe(e.id),children:(0,X.jsx)(K,{})})),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:l(`approvalRuleEdit`),onClick:()=>{Ie({...e}),He(e.tools.join(`, `)),Be(!1),Ge(null)},children:(0,X.jsx)(Le,{})}),!n&&(Ke===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,onClick:()=>{$({type:`delete_approval_rule`,id:e.id}),qe(null)},children:l(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:l(`approvalRuleDelete`),onClick:()=>qe(e.id),children:(0,X.jsx)(R,{})}))]})]},e.id)})})]}),tr&&(0,X.jsx)(ol,{plugin:tr.plugin,epoch:e.pluginsEpoch,send:$,className:`set-plugin-page`})]})]}),(0,X.jsx)(`div`,{className:`modal-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:i,children:l(`close`)})})]})})}var fy=0,py=``;function my(){typeof document<`u`&&(fy===0&&(py=document.body.style.overflow,document.body.style.overflow=`hidden`),fy++)}function hy(){typeof document<`u`&&(fy=Math.max(0,fy-1),fy===0&&(document.body.style.overflow=py))}function gy({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(),h=(0,m.useRef)(t);if((0,m.useLayoutEffect)(()=>{h.current=t}),At(()=>l?(h.current(),!0):!1,e),(0,m.useEffect)(()=>{if(e&&f)return my(),()=>{hy()}},[e,f]),!e)return null;let g=e=>{e.target===e.currentTarget&&c&&h.current()},_=d??(typeof n==`string`?n:void 0);return(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop ${o}`.trim(),onClick:g,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:()=>h.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 _y(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 vy({servers:e,onClose:t}){let n=Z(),[r,i]=(0,m.useState)(new Set),a=e=>i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,m.useEffect)(()=>{$({type:`list_bg_servers`})},[]),(0,X.jsxs)(gy,{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)(we,{}),` `,n(`bgTasks`),e.length>0&&(0,X.jsx)(`em`,{className:`bg-task-count`,children:e.length})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:n(`close`),onClick:t,children:(0,X.jsx)(N,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(we,{}),(0,X.jsx)(`span`,{children:n(`bgTasksEmpty`)}),(0,X.jsx)(`small`,{children:n(`bgTasksDesc`)})]}):(0,X.jsx)(`ul`,{className:`bg-task-list`,children:e.map(e=>{let t=!!e.taskId,i=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:n(`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:[n(`bgTaskPid`),` `,e.pid]}),(0,X.jsxs)(`span`,{children:[n(`bgTaskSince`),` `,_y(e.since,n)]}),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 ${r.has(i)?`open`:``}`,title:`${n(`bgTaskCommand`)}: ${e.command}`,onClick:()=>a(i),children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`code`,{children:e.command})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stop`,title:n(`bgTaskStop`),onClick:()=>$(t?{type:`kill_background_server`,taskId:e.taskId}:{type:`kill_background_server`,port:e.port}),children:[(0,X.jsx)(ie,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStop`)})]})]},i)})}),(0,X.jsxs)(`div`,{className:`bg-task-foot`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:n(`bgTaskRefresh`),onClick:()=>$({type:`list_bg_servers`}),children:[(0,X.jsx)(K,{}),(0,X.jsx)(`span`,{children:n(`bgTaskRefresh`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn bg-task-stopall`,disabled:e.length===0,title:n(`bgTaskStopAll`),onClick:()=>$({type:`kill_background_servers`}),children:[(0,X.jsx)(ie,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStopAll`)})]})]})]})}function yy(){let e=Z(),t=Wf(),[n,r]=(0,m.useState)(!0),i=(0,m.useRef)(null);return(0,m.useEffect)(()=>{t&&r(!0)},[t]),At(()=>{t&&Hf()},!!t),(0,m.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(),Uf(n))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,n]),t?(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:Hf,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)(gt,{}),e(`rollbackSession`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:e(`cancel`),onClick:Hf,children:(0,X.jsx)(N,{})})]}),(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:Hf,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:()=>Uf(n),children:[(0,X.jsx)(it,{}),e(`confirm`)]})]})]})]})}),document.body):null}function by({approval:e}){let t=Z(),{locale:n}=wn(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(null);if((0,m.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,k.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)(gt,{}),t(`toolApprovalTitle`)]}),(0,X.jsx)(`code`,{className:`tool-info-name`,style:{fontWeight:700},children:e.toolName}),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)(N,{})})]}),(0,X.jsxs)(`div`,{className:`tool-info-body`,style:{padding:`16px 20px`},children:[(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]})]}),(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)(we,{}),t(`toolApprovalAllowCategory`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:t(`toolApprovalAllowConversationHint`),onClick:()=>s(`all`),children:[(0,X.jsx)(at,{}),t(`toolApprovalAllowConversation`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,style:{color:`var(--red, #ef4444)`},onClick:c,children:[(0,X.jsx)(N,{}),t(`toolApprovalDeny`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>s(),style:{fontWeight:500},children:[(0,X.jsx)(it,{}),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)(Le,{}),t(`toolApprovalEditAndRun`)]})]})]})]})}),document.body)}var xy={pending:`in_progress`,in_progress:`done`,done:`failed`,failed:`pending`};function Sy({plan:e}){let t=Z(),[n,r]=(0,m.useState)(!1),{copied:i,copy:a}=hl({duration:2e3}),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``);if(!e||!e.steps||e.steps.length===0)return null;let f=e.steps,p=f.filter(e=>e.status===`done`).length,h=f.length,g=Math.round(p/h*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(`
|
|
366
366
|
`);$({type:`plan_clean_handoff`,steps:f,prompt:`${t(`planCleanHandoffPrompt`)}\n\n${e}`})},x=async()=>{let e=[`# ${t(`planBoardTitle`)} (${p}/${h})`,``,...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(`
|
|
367
|
-
`))},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:yy[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)(at,{}),t(`planBoardCompleted`)]});case`in_progress`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ye,{}),t(`planBoardInProgress`)]});case`failed`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_t,{}),t(`planBoardFailed`)]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ze,{}),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)(Ce,{className:`plan-board-icon`}),(0,X.jsx)(`span`,{className:`plan-board-title`,children:t(`planBoardTitle`)}),(0,X.jsxs)(`span`,{className:`plan-board-count ${g===100?`plan-board-count-done`:``}`.trim(),children:[p,`/`,h]}),!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)(it,{style:{color:`var(--green, #22c55e)`}}):(0,X.jsx)(Ke,{})}),(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)(et,{}):(0,X.jsx)(rt,{})})]}),n&&(0,X.jsx)(`div`,{className:`plan-board-head-divider`,children:(0,X.jsx)(`div`,{className:`plan-board-head-divider-fill`,style:{width:`${g}%`,backgroundColor:g===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:`${g}%`,backgroundColor:g===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)(N,{}),` `,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)(it,{}),` `,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)(Re,{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)(le,{}),` `,t(`planBoardAddStep`)]})]})]})}var xy=3,Sy=200;function Cy(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wy(e){return typeof e==`string`&&e.trim()||void 0}function Ty(e,t){let n=[];for(let r of e){let e=Dy(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function Ey(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 Dy(e,t=0){if(t>6||!Cy(e))return`any`;if(wy(e.$ref))return`ref`;let n=wy(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:Dy(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 Ty(r,t+1)}return Cy(e.properties)?`object`:Cy(e.additionalProperties)?`record<${Dy(e.additionalProperties,t+1)}>`:`any`}function Oy(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=Ey(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 ky(e,t={}){let n=t.maxDepth??xy,r=t.maxRows??Sy,i=e;if(!Cy(i))return[];let a=i.properties;if(!Cy(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=Cy(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:Dy(e,i),required:a.has(s),depth:i},f=wy(e.description);f&&(d.description=f);let p=Oy(e);if(p&&(d.hint=p),o.push(d),i+1<n&&Cy(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 Ay(){let e=Z(),t=oo();return At(()=>{no()},!!t),t?(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:no,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)(q,{}),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:no,children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(jy,{info:t})})]})}),document.body):null}function jy({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?[]:ky(e.parameters),r=e.parameters===void 0?``:Ny(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)(My,{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)(Ql,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function My({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 Ny(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function Py(e,t){return e.toLowerCase().includes(t)}function Fy({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=wn(),u=l===`en`?`Plugins`:`插件`,d=ha(`cwd`),f=(0,m.useRef)(null),[p,h]=(0,m.useState)(``),g=(0,m.useDeferredValue)(p),[_,v]=(0,m.useState)(0),y=(0,m.useRef)(0),b=(0,m.useRef)(null),[x,S]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=p.trim();if(t){let e=zh();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,m.useState)(!1);(0,m.useEffect)(()=>{b.current&&clearTimeout(b.current);let e=g.trim();if(!e){w(!1),S(null);return}return b.current=setTimeout(()=>{let t=zh();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)}},[g]),(0,m.useEffect)(()=>{n&&n.reqId===y.current&&S(n)},[n]);let T=g.trim().toLowerCase(),E=(0,m.useMemo)(()=>!T||!r||r.reqId!==y.current||!r.ok?[]:r.results,[r,T]),D=(0,m.useMemo)(()=>T?t.filter(e=>Py(e.path,T)).slice(0,10):[],[t,T]),O=(0,m.useMemo)(()=>!T||!x||!x.ok?[]:x.results,[x,T]);(0,m.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,m.useState)([]);(0,m.useEffect)(()=>{if(!e)return;let t=g.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 Wo==`function`&&(r=Wo())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=Yo(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,g]);let ee=(0,m.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,m.useEffect)(()=>{v(0)},[g]);let M=(0,m.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=g.trim();if(t){let e=zh();y.current=e,w(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}}else e.kind===`plugin`?Mo(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,g]);(0,m.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 P=E.length+D.length+O.length+A.length,F=(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})]}),I=-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)(W,{}),(0,X.jsx)(`input`,{ref:f,type:`text`,value:p,placeholder:c(`gsPlaceholder`),onChange:e=>h(e.target.value)}),(0,X.jsx)(`button`,{type:`button`,className:`gs-close`,title:c(`close`),onClick:i,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!T&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),T&&P===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:[F(c(`gsSessions`),E.length,(0,X.jsx)(ve,{})),E.map(e=>{I++;let t=I,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(),er({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:[F(c(`gsProjects`),D.length,(0,X.jsx)(Me,{})),D.map(e=>{I++;let t=I,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:[F(c(`gsFiles`),O.length,(0,X.jsx)(Pe,{})),O.map(e=>{I++;let t=I;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:[F(u,A.length,(0,X.jsx)(fe,{})),A.map((e,t)=>{I++;let n=I;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 Iy({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(my,{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)(Lg,{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 Ly=5e3;function Ry({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(``),[C,w]=(0,m.useState)(!0),[T,E]=(0,m.useState)(!0),[D,O]=(0,m.useState)(!1),k=(0,m.useRef)(!1),[A,M]=(0,m.useState)(!0),[P,F]=(0,m.useState)(!1),[I,L]=(0,m.useState)(100),te=(0,m.useRef)(0),R=(0,m.useRef)(!1),z=(0,m.useRef)(null),[ne,re]=(0,m.useState)(!1),[B,ie]=(0,m.useState)(!1),V=(0,m.useRef)(!1),ae=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{z.current&&clearTimeout(z.current),ae.current&&clearTimeout(ae.current)},[]),(0,m.useEffect)(()=>{d(!0),l(null),p(null),b(!1),S(``),w(!0),E(!0),O(!1),k.current=!1,V.current=!1,re(!1),ie(!1),ae.current&&clearTimeout(ae.current),$({type:`read_file`,path:e.path})},[e.path]),(0,m.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1),V.current&&(V.current=!1,ae.current&&clearTimeout(ae.current),re(!1),ie(!1),b(!1),S(t.text),k.current&&(zy(e.name)&&w(!0),Vy(e.name)&&E(!0)),p(null)))},[t,y,e.path]),(0,m.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){pe();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(),ce())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,m.useEffect)(()=>{let e=()=>{R.current=!1,g(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let H=(0,m.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
|
|
368
|
-
`);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,Ly)},[c]),U=c?.lines??0,W=U>Ly,oe=(e,t)=>{if(t){let t=te.current>0?te.current:e;p({start:Math.min(t,e),end:Math.max(t,e)})}else te.current=e,p({start:e,end:e})},ce=()=>{H.length!==0&&(te.current=1,p({start:1,end:H.length}))},G=()=>{f&&(n(e.path,e.name,f.start,f.end),v(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>v(!1),1400))},le=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated&&!By(e.name),ue=()=>{V.current=!1,ae.current&&clearTimeout(ae.current),re(!1),ie(!1),S(c?.text??``),b(!1),k.current&&(zy(e.name)&&w(!0),Vy(e.name)&&E(!0))},de=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;ue();return}le&&c&&(k.current=zy(e.name)&&C||Vy(e.name)&&T,zy(e.name)&&w(!1),Vy(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,ie(!1),re(!0),ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{V.current=!1,re(!1),ie(!0)},5e3))},pe=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},me=e=>{L(Math.min(200,Math.max(50,e)))},he=f?f.end-f.start+1:0,_e=c?.binary??!1,ve=c?.truncated??!1,K=c?.kind??`text`,be=zy(e.name)||By(e.name),xe=Vy(e.name),Se=be&&C&&!y&&K===`text`&&!_e,Ce=xe&&T&&!y&&K===`text`&&!_e,Te={"host:fp-md":be&&K===`text`&&!_e&&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)(Fe,{}):(0,X.jsx)(Je,{})}):null,"host:fp-html":xe&&K===`text`&&!_e&&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)(Je,{}):(0,X.jsx)(Fe,{})}):null,"host:fp-edit":K===`text`&&!_e&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(ve?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!le&&!y,onClick:de,children:(0,X.jsx)(Le,{})}):null,"host:fp-wrap":K===`text`&&!_e&&!Se&&!Ce?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${A?`on`:``}`,"data-tip":s(A?`disableWrap`:`enableWrap`),onClick:()=>M(e=>!e),children:(0,X.jsx)(Ge,{})}):null,"host:fp-zoom":K===`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:I<=50,onClick:()=>me(I-10),children:(0,X.jsx)(j,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>L(100),children:[I,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:I>=200,onClick:()=>me(I+10),children:(0,X.jsx)(ee,{})})]}):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)(we,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${P?`on`:``}`,"data-tip":s(P?`exitFullscreen`:`fullscreen`),onClick:()=>F(e=>!e),children:P?(0,X.jsx)(ge,{}):(0,X.jsx)(ye,{})}),"host:fp-close":null},Ee=a===void 0?[`host:fp-md`,`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`),q=e=>sn(nn(`/api/file?clientId=${encodeURIComponent(uc())}&path=${encodeURIComponent(e)}`)),J=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return sn(nn(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(uc())}${D?`&allowJs=1`:``}`))};return(0,X.jsx)(`div`,{className:`fp-overlay ${P?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&pe()},children:(0,X.jsxs)(`div`,{className:`fp ${P?`fullscreen`:``}`,style:{"--fp-zoom":I/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,onDoubleClick:e=>{let t=e.target;t&&!t.closest(`button, a, input`)&&F(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&&K===`text`&&!_e&&s(`fileLines`,{n:U}),c&&` · ${xf(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:sm(Ee,Te,o)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),"aria-label":s(`close`),onClick:pe,children:(0,X.jsx)(N,{})})]}),ve&&K===`text`&&!_e&&(0,X.jsx)(`div`,{className:`fp-notice`,children:By(e.name)?s(`previewLinesTruncated`,{n:H.length}):s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&K===`none`&&!_e&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&K===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap clickable`,onClick:pe,title:s(`clickToCloseImage`),children:(0,X.jsx)(`img`,{className:`fp-media fp-media-clickable`,src:q(e.path),alt:e.name,onClick:pe,title:s(`clickToCloseImage`)})}),!u&&K===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:q(e.path),controls:!0,preload:`metadata`})}),!u&&Ce&&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:J(e.path),target:`_blank`,rel:`noopener noreferrer`,title:s(`openInNewTab`),children:[(0,X.jsx)(Ie,{}),(0,X.jsx)(`span`,{children:s(`openInNewTab`)})]})]}),(0,X.jsx)(`iframe`,{className:`fp-html-frame`,src:J(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&Se&&c&&(0,X.jsx)(`div`,{className:By(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,children:(0,X.jsx)(Ku,{text:c.text})})}),!u&&_e&&K!==`image`&&K!==`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&&K===`text`&&!_e&&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}),B&&(0,X.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:s(`saveResultUnknown`)})]}),!u&&!Se&&!Ce&&!y&&K===`text`&&!_e&&c&&H.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!Se&&!Ce&&!y&&K===`text`&&!_e&&H.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${h?`dragging`:``} ${A?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[H.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&&(oe(n,e.shiftKey),R.current=!0,g(!0))},onMouseEnter:()=>{R.current&&oe(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),W&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:Ly})})]}),(y||!Se&&!Ce&&K===`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:ne||x===(c?.text??``),onClick:fe,children:[(0,X.jsx)(se,{}),` `,s(`saveFile`)]})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:f?s(`selectedRange`,{n:he,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:H.length===0,onClick:ce,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||_e,onClick:G,children:[_?(0,X.jsx)(it,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function zy(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function By(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)}function Vy(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function Hy({file:e,plugin:t,declaration:n,epoch:r,send:i,onClose:a,onFallback:o}){let s=Z(),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(!1),p=(0,m.useRef)(o);p.current=o;let h=n.label??t.name;return(0,m.useEffect)(()=>{let r=c.current;if(!r)return;let a=!1,o;return u(null),f(!1),(async()=>{try{let s=await x_({plugin:t,declaration:n});if(a)return;if(!s)throw Error(`插件没有提供可用的文件查看器`);let c=`/plugins-api/${encodeURIComponent(t.id)}`,l={...Ls(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 sn(nn(`${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)(my,{className:`plugin-file-preview`,title:h,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`})]})})}function Uy(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 Wy=(0,m.lazy)(()=>ps(()=>import(`./TerminalPanel-C88r3r3Q.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function Gy({notice:e,onDismiss:t}){let n=Z(),{locale:r}=wn(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(a)return;let n=setTimeout(()=>t(e.id),e.level===`error`?12e3:7e3);return()=>clearTimeout(n)},[a,e.id,e.level,t]);let s=e.level===`error`?_t:e.level===`warning`?gt:q;return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${a?` paused`:``}`,role:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),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:()=>t(e.id),children:(0,X.jsx)(N,{})})]})}var Ky=[],qy=180,Jy=520,Yy=240,Xy=e=>`pi-web-ui:${e}-panel-width`;function Zy(e){try{let t=Number(localStorage.getItem(Xy(e)));return Number.isFinite(t)&&t>=qy&&t<=Jy?t:Yy}catch{return Yy}}var Qy=e=>`pi-web-ui:${e}-panel-collapsed`;function $y(e){try{return localStorage.getItem(Qy(e))===`1`}catch{return!1}}function eb({side:e,width:t,onResize:n}){let r=Z(),i=(0,m.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(Jy,Math.max(qy,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`);try{localStorage.setItem(Xy(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(Yy)})}function tb({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)(Qe,{}):(0,X.jsx)($e,{})})}var nb=`pi-web-ui:plugin-path-grants`,rb=e=>e?`${nb}:${e}`:nb;function ib(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function ab(e){try{let t=rb(e);if(localStorage.getItem(t)!==null)return ib(localStorage.getItem(t));if(!e)return[];let n=ib(localStorage.getItem(nb));return localStorage.setItem(t,JSON.stringify(n)),n}catch{return[]}}function ob(e,t){try{let n=[...new Set([...ab(t),e])];localStorage.setItem(rb(t),JSON.stringify(n))}catch{}}function sb(){let e=Z(),{locale:t}=wn(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=Tc(),s=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:Vv[t]??Vv.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=yv();(0,m.useEffect)(()=>{let t=l?fv(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,m.useState)([]);(0,m.useEffect)(()=>(Xn(e=>d(t=>eh(t,e))),()=>Xn(null)),[]);let[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(null),_=(0,m.useRef)(!1),v=(0,m.useRef)(null);(0,m.useEffect)(()=>{_.current=f!==null,v.current=h},[f,h]);let y=(0,m.useCallback)((e,t)=>{let n=b_(t);if(n){p(null),g({file:{path:e,name:t},plugin:n.plugin,declaration:n.declaration});return}g(null),p({path:e,name:t})},[]);(0,m.useEffect)(()=>(Ru({open:e=>y(e.path,e.name),isOpen:()=>_.current||v.current!==null}),()=>Ru(null)),[y]);let[b,x]=(0,m.useState)(!1);(0,m.useEffect)(()=>{let e=()=>x(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[S,C]=(0,m.useState)(`chat`),w=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(S.startsWith(`plugin:`)?`plugins`:S)?S:`chat`,T=(0,m.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),E=(0,m.useMemo)(()=>{let r=[],i=ji(bi(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,m.useMemo)(()=>E[`topbar.primary`].filter(e=>!e.hidden),[E]),O=(0,m.useMemo)(()=>[...E[`topbar.primary`].filter(e=>e.hidden),...E[`topbar.overflow`]],[E]),k=(0,m.useMemo)(()=>E[`leftpanel.sessions`].filter(e=>!e.hidden),[E]),A=(0,m.useMemo)(()=>E[`terminal.toolbar`].filter(e=>!e.hidden),[E]),j=(0,m.useMemo)(()=>E[`scm.toolbar`].filter(e=>!e.hidden),[E]),ee=(0,m.useMemo)(()=>E[`goalbar.actions`].filter(e=>!e.hidden),[E]),M=(0,m.useMemo)(()=>E[`chat.header`].filter(e=>!e.hidden),[E]),P=(0,m.useMemo)(()=>E[`chat.empty`].filter(e=>!e.hidden),[E]),F=(0,m.useMemo)(()=>E[`file.preview.toolbar`].filter(e=>!e.hidden),[E]),I=(0,m.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(n=>[n.id,qh(n,t,e).name])),[n.dshPresets,t]),L=(0,m.useMemo)(()=>E[`notice.actions`].filter(e=>!e.hidden),[E]),te=(0,m.useMemo)(()=>E[`sidebar.left`]??[],[E]),R=(0,m.useMemo)(()=>E[`sidebar.right`]??[],[E]),z=(0,m.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&&Bf({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&&Mo(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=W.current.plugins.find(t=>t.id===e);return t?Fs(t,W.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[ne,re]=(0,m.useState)([]);(0,m.useEffect)(()=>Os(re),[]);let[B,ie]=(0,m.useState)([]);(0,m.useEffect)(()=>Es(ie),[]);let[V,ae]=(0,m.useState)(null),H=V?E[`modal.dialog`].find(e=>e.id===V&&!e.hidden):void 0,U=(0,m.useMemo)(()=>{if(!H||H.kind!==`view`)return``;let e=H.view??``;return e.startsWith(`plugin:`)?e.slice(7):H.source.startsWith(`plugin:`)?H.source.slice(7):``},[H]);(0,m.useEffect)(()=>{if(!H||!U||ne.some(e=>e.info.id===U))return;let e=W.current.plugins.find(e=>e.id===U);e&&Fs(e,W.current.pluginsEpoch)},[H,U,ne,n.pluginsEpoch]),(0,m.useEffect)(()=>{mu(r),hu(T,n.pluginsEpoch),Su(T,n.pluginsEpoch),y_(T,n.pluginsEpoch),Is(T,n.pluginsEpoch)},[T,n.pluginsEpoch,r]);let W=(0,m.useRef)(n);W.current=n;let oe=(0,m.useRef)(C);oe.current=C;let se=(0,m.useRef)(E);se.current=E,(0,m.useEffect)(()=>(To(wo({send:r,isReady:()=>!!W.current.state,setView:e=>oe.current(e),getCwd:()=>W.current.state?.cwd??``,getWorkspaceRoots:()=>W.current.state?.workspaceRoots??[],listSessions:()=>{let e=W.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:()=>W.current.state?.conversationId??null,isConversationBlank:()=>(W.current.state?.messages.length??0)===0,listModels:()=>W.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=W.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>W.current.projects.map(e=>e.path),grantedPaths:ab,grantPath:ob,confirm:e=>new Promise(t=>{if(je.current){t(!1);return}let n={path:e.path,resolve:t};je.current=n,Ae(n)}),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=se.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(ae(t),!0)},closeModal:()=>ae(null),dialogConfirm:e=>new Promise(t=>{if(Y.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Y.current=n,Ne(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,Fe([]),Ne(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,Le(e.initial??``),Ne(n)}),notifyAction:e=>new Promise(t=>{try{let n=Be.current;Be.current=null,ze(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Be.current=r,ze(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=W.current.plugins.find(t=>t.id===e);return t?Fs(t,W.current.pluginsEpoch):Promise.resolve(!1)}})),()=>To(null)),[r]);let[ce,le]=(0,m.useState)(()=>Zy(`left`)),[ue,de]=(0,m.useState)(()=>Zy(`right`)),fe=(0,m.useCallback)(e=>le(e),[]),pe=(0,m.useCallback)(e=>de(e),[]),[me,he]=(0,m.useState)(()=>$y(`left`)),[ge,_e]=(0,m.useState)(()=>$y(`right`)),ve=(0,m.useCallback)(()=>{he(e=>{try{localStorage.setItem(Qy(`left`),e?`0`:`1`)}catch{}return!e})},[]),K=(0,m.useCallback)(()=>{_e(e=>{try{localStorage.setItem(Qy(`right`),e?`0`:`1`)}catch{}return!e})},[]),[ye,be]=(0,m.useState)(null),[xe,Se]=(0,m.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,m.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>Se(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[Ce,we]=(0,m.useState)(!1),[Te,Ee]=(0,m.useState)(!1),[q,J]=(0,m.useState)(!1),[De,Oe]=(0,m.useState)(),[ke,Ae]=(0,m.useState)(null),je=(0,m.useRef)(null),[Me,Ne]=(0,m.useState)(null),Y=(0,m.useRef)(null),[Pe,Fe]=(0,m.useState)([]),[Ie,Le]=(0,m.useState)(``),[Re,ze]=(0,m.useState)(null),Be=(0,m.useRef)(null),[Ve,He]=(0,m.useState)(()=>new Set),Ue=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),He(t=>new Set(t).add(e))},We=n.pathRequests.find(e=>!Ve.has(e.id))??null,[Ge,Ke]=(0,m.useState)(()=>new Set),qe=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),Ke(t=>new Set(t).add(e))},Je=n.permRequests.find(e=>!Ge.has(e.id))??null,Ye=cv(),[Xe,Ze]=(0,m.useState)(!1),[Qe,$e]=(0,m.useState)(!1),[et,tt]=(0,m.useState)(!1),[nt,rt]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!nt)return;let e=setTimeout(()=>rt(null),15e3);return()=>clearTimeout(e)},[nt]),(0,m.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=St();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,m.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),$e(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[it,at]=(0,m.useState)(W_),[ot,st]=(0,m.useState)(It),{themes:ct,theme:lt,switchTheme:ut,reloadThemes:dt}=Nu();Rv(),(0,m.useEffect)(()=>{try{typeof as==`function`&&as(lt??``)}catch{}},[lt]),(0,m.useEffect)(()=>{try{typeof os==`function`&&os(t)}catch{}},[t]),(0,m.useEffect)(()=>{try{typeof ss==`function`&&ss(w)}catch{}},[w]),(0,m.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof ts==`function`&&ts(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,m.useEffect)(()=>{if(!Me)return;let e=e=>{if(e.key!==`Escape`)return;let t=Y.current;Y.current=null,Ne(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)},[Me]),(0,m.useEffect)(()=>{if(!Re)return;let e=setTimeout(()=>{let e=Be.current;Be.current=null,ze(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Re]);let ft=(0,m.useRef)(null),pt=(0,m.useRef)(null),mt=(0,m.useRef)(n.state?.messages);mt.current=n.state?.messages;let ht=(0,m.useRef)(new Set),gt=(0,m.useRef)(new Set),_t=(0,m.useRef)(new Set),vt=(0,m.useRef)(0),yt=(0,m.useRef)(!1),bt=(0,m.useRef)(n.terminals);(0,m.useEffect)(()=>{G_(it)},[it]),(0,m.useEffect)(()=>{Lt(ot)},[ot]),(0,m.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,m.useEffect)(()=>{let t=n.state?.conversationId??null,r=Uy(ft.current,t,n.state?.isStreaming??!1,n.conversations,pt.current);if(ft.current=r.nextMap,pt.current=t,r.startCue&&X_(`start`,it),r.finishedConvs.length>0){X_(`done`,it);let t=r.finishedConvs.find(e=>e.isActive);if(t&&(Gr(e(`notifyDoneTitle`),e(`notifyDoneBody`)),ot.enabled&&!Mr(zr()))){if(ot.readReplies){let t=Vt(mt.current);t?Xt(t,ot):ot.announce&&Xt(e(`ttsAnnounceDone`),ot)}else ot.announce&&Xt(e(`ttsAnnounceDone`),ot)}for(let t of r.finishedConvs.filter(e=>!e.isActive)){let n=t.title?`${t.title}:${e(`notifyDoneBody`)}`:e(`notifyDoneBody`);Gr(e(`notifyDoneTitle`),n)}!t&&ot.enabled&&ot.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceDone`),ot)}},[n.state?.conversationId,n.state?.isStreaming,n.conversations,it,ot,e]),(0,m.useEffect)(()=>{let t=n.dialog?.id??null;if(t!==null&&!ht.current.has(t)){if(ht.current.add(t),ht.current.size>64){let e=ht.current.values().next().value;e!==void 0&&ht.current.delete(e)}X_(`question`,it),Gr(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),ot.enabled&&ot.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceQuestion`),ot)}},[n.dialog,it,ot,e]),(0,m.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null,i=!1;t!==null&&!gt.current.has(t)&&(gt.current.add(t),i=!0),r!==null&&!gt.current.has(r)&&(gt.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}`;gt.current.has(n)||(gt.current.add(n),e.questionId&>.current.add(e.questionId),t!==e.questionId&&(i=!0))}if(gt.current.size>64){let e=gt.current.values().next().value;e!==void 0&>.current.delete(e)}i&&(X_(`question`,it),Gr(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),ot.enabled&&ot.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceQuestion`),ot))},[n.question,n.remoteQuestion,n.conversations,it,ot,e]),(0,m.useEffect)(()=>{let t=n.approval,r=t?.id??null;if(r!==null&&!_t.current.has(r)){if(_t.current.add(r),_t.current.size>64){let e=_t.current.values().next().value;e!==void 0&&_t.current.delete(e)}X_(`approval`,it);let n=typeof t?.toolName==`string`?t.toolName:``;Gr(e(`notifyApprovalTitle`),n?e(`notifyApprovalBodyTool`,{tool:n}):e(`notifyApprovalBody`)),ot.enabled&&ot.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceApproval`),ot)}},[n.approval,it,ot,e]),(0,m.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==vt.current&&(vt.current=t.id,X_(`error`,it),Gr(e(`notifyErrorTitle`),e(`notifyErrorBody`)),ot.enabled&&ot.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceError`),ot))},[n.notices,it,ot,e]);let xt=(0,m.useRef)(new Set);(0,m.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||xt.current.has(t.id))continue;xt.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(nn(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 Ct=(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&&qn(`@${s} `)},wt=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&&Jn(`@${t}`)},Tt=(0,m.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&be(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&C(e=>e===`chat`?e:`chat`),r(e)),[r]),Et=(0,m.useRef)(new Set),Dt=n.activeConversationId||n.state?.conversationId||``;(0,m.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 Et.current)i.has(e)||Et.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===Dt){qg(t,{silent:!0});continue}n.questionId&&Et.current.has(n.questionId)||Kg({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&&Et.current.add(n.questionId)},onClick:()=>{Tt({type:`switch_conversation`,id:n.id}),qg(t,{silent:!0})}})}Jg(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===Dt:!1},{silent:!0})},[n.conversations,Dt,Tt,e]);let Ot=(0,m.useRef)(0),kt=(0,m.useRef)(0),At=(0,m.useCallback)(t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-kt.current>1e4&&(kt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++Ot.current}`;d(e=>[...e,{path:``,key:i,name:t.name,imageData:t.data,mimeType:t.mimeType}])},[n.state?.model,a,e]),jt=(0,m.useCallback)(async t=>{for(let n of t){let t=await hf(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}At(t)}},[At,a,e]),Mt=20971520,Nt=(0,m.useRef)(0),Pt=(0,m.useCallback)(async t=>{if(t.size>Mt){a(`warning`,e(`fileTooLarge`,{name:t.name,size:Mt/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-${++Nt.current}`;d(e=>[...e,{path:``,key:r,name:t.name,fileData:n,size:t.size,mimeType:t.type||void 0}])},[Mt,a,e]),Ft=(0,m.useCallback)(async e=>{for(let t of e)mf(t.type)?await jt([t]):await Pt(t)},[jt,Pt]),Rt=(0,m.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),zt=(0,m.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[Bt,Ht]=(0,m.useState)([]),Ut=(0,m.useRef)(0),Wt=(0,m.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),Ut.current+=1;let i=jl(t),a={text:i.text,seq:Ut.current};i.quotes.length&&d(e=>eh(e,i.quotes.map(e=>({path:``,name:``,mode:`quote`,quote:e,key:St()})))),Ht(e=>[...e.slice(-9),a])},[r]),Gt=(0,m.useCallback)(()=>Ee(!0),[]),Kt=(0,m.useCallback)(()=>d([]),[]);m_(n.state?.sessionId??``,Kt);let qt=(0,m.useCallback)(wt,[]),Jt=jt,Yt=Ft,Zt=(0,m.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),Qt=(0,m.useCallback)(e=>Ct(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines,e.silent??!1),[]),$t=n.state?.model,en=n.state?.thinkingLevel,tn=n.state?.availableThinkingLevels,rn=(0,m.useMemo)(()=>$t?{model:$t,thinkingLevel:en??`off`,availableThinkingLevels:tn??[]}:null,[$t,en,tn]),an=(0,m.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:St(),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,m.useEffect)(()=>{if(yt.current){if(w!==`terminal`||n.terminals.length!==0){yt.current=!1;return}an()&&(yt.current=!1)}},[n.terminals.length,an,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=>mf(e.type)),i=n.filter(e=>!mf(e.type));r.length>0&&jt(r),i.length>0&&Ft(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)(Ga,{chat:n,terminal:o,view:w,plugins:T,uiPrimary:D,uiOverflow:O,uiContextTopbar:E[`contextmenu.topbar`],onUiAction:z,onViewChange:e=>{yt.current=e===`terminal`&&n.terminals.length===0,yt.current&&an()&&(yt.current=!1),C(e),be(null)},onOpenPanel:be,onOpenSettings:()=>{Oe(void 0),J(!0)},onManagePlugins:()=>{Oe(`plugins`),J(!0)},onOpenBgTasks:()=>Ze(!0),onOpenGlobalSearch:()=>$e(!0),onOpenIconEdit:()=>tt(!0),sound:it,onSoundChange:at,onSoundPreview:e=>X_(e,it),themes:ct,theme:lt,onThemeChange:ut,reloadThemes:dt}),et&&(0,X.jsx)(p_,{slots:E,layout:n.settings?.uiLayout,exclude:fi,onClose:()=>tt(!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)(Gy,{notice:e,onDismiss:i},e.id)),Re&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Re.text}),Re.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Be.current;Be.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=Be.current;Be.current=null,ze(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(N,{})})]}),L.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:L.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=>z(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:()=>z(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)($p,{currentModelId:$t?`${$t.provider}/${$t.id}`:null,children:(0,X.jsxs)(`div`,{className:`layout`,style:{"--left-w":`${ce}px`,"--right-w":`${ue}px`},children:[ye&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>be(null)}),(0,X.jsx)(vg,{side:`left`,items:te,chat:n,view:w,onViewChange:e=>{yt.current=e===`terminal`&&n.terminals.length===0,yt.current&&an()&&(yt.current=!1),C(e),be(null)},onOpenPanel:be,onOpenSettings:e=>{Oe(e),J(!0)},onOpenBgTasks:()=>Ze(!0),onOpenGlobalSearch:()=>$e(!0),onUiAction:z,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>ut(lt===`light`?null:`light`),onSoundToggle:()=>at({...it,enabled:!it.enabled})}),(0,X.jsxs)(`div`,{className:`view-pane ${w===`chat`?``:`hidden`}`,children:[!xe&&me&&(0,X.jsx)(tb,{side:`left`,onClick:ve}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${ye===`left`?`open`:``}${xe?``:me?` hidden`:``}`,children:(0,X.jsx)(Lc,{collapsible:!xe,onToggleCollapse:ve,panelSend:Tt,active:!xe||ye===`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,onUiAction:z,presetNames:I})}),!xe&&(0,X.jsx)(eb,{side:`left`,width:ce,onResize:fe}),(0,X.jsxs)(`main`,{className:Ye?`main wide-chat`:`main`,children:[M.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:am(M,z)}),n.state?(0,X.jsxs)(X.Fragment,{children:[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:Dt}),children:[`💾 `,e(`saveEphemeral`)]})]}),(0,X.jsx)(Ym,{uiMessageActions:E[`message.actions`],uiContextMessage:E[`contextmenu.message`],uiContextToolCall:E[`contextmenu.toolcall`],uiChatEmpty:P,onUiAction:z,state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:Rt,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Gp(`${e.provider}/${e.id}`)}},onRemoveQueued:zt,onRecallQueued:Wt,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,jumpTarget:nt,onJumpDone:()=>rt(null)},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)(sg,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:ee,onUiAction:z})}),(0,X.jsx)(zg,{onAction:(e,t,n)=>z(e,n,t)}),n.dialog&&(0,X.jsx)(yg,{dialog:n.dialog}),Me&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":Me.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),Me.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:Me.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Y.current;Y.current=null,Ne(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),Me.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(Me.options??[]).map((e,t)=>{let n=Me.multi?Pe.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(Me.multi){Fe(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Y.current;Y.current=null,Ne(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)}),(Me.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),Me.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)=>Pe.includes(t)).map(e=>e.label);Y.current=null,Ne(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),Me.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,Ne(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,Ne(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),Me.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Ie,placeholder:Me.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>Le(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Y.current;Y.current=null,Ne(null);try{e?.resolve({ok:!0,value:Ie})}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,Ne(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,Ne(null);try{e?.resolve({ok:!0,value:Ie})}catch{}},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Sg,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||Dt))?.title}),n.remoteQuestion&&(0,X.jsx)(Sg,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(by,{plan:n.state?.plan}),(0,X.jsx)(og,{composerLeading:E[`composer.leading`],composerActions:E[`composer.actions`],onUiAction:z,streaming:n.state?.isStreaming??!1,planMode:n.state?.planMode??!1,messages:n.state?.messages??Ky,slashCommands:n.slashCommands,modelState:rn,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:qt,onAddImageFiles:Jt,onAddLocalFiles:Yt,onAddPathAttachment:Qt,fileSearch:n.fileSearch,onSearchFiles:Zt,onNotice:a,onManageModels:Gt,onSent:Kt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:Bt,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??``})]}),!xe&&(0,X.jsx)(eb,{side:`right`,width:ue,onResize:pe}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${ye===`right`?`open`:``}${xe?``:ge?` hidden`:``}`,children:(0,X.jsx)(Ol,{collapsible:!xe,onToggleCollapse:K,panelSend:Tt,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{be(null),Ct(e,t,n,r)},onPreview:(e,t)=>{be(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})}),!xe&&ge&&(0,X.jsx)(tb,{side:`right`,onClick:K})]}),(0,X.jsx)(`div`,{className:`view-pane ${w===`terminal`?``:`hidden`}`,children:(0,X.jsx)(m.Suspense,{fallback:null,children:(0,X.jsx)(Wy,{chat:n,terminal:o,uiTerminalToolbar:A,onUiAction:z})})}),(0,X.jsx)(`div`,{className:`view-pane ${w===`git`?``:`hidden`}`,children:(0,X.jsx)(Ig,{chat:n,terminal:o,active:w===`git`,onSwitchToTerminal:()=>C(`terminal`),uiScmToolbar:j,onUiAction:z})}),ne.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${w===t?``:`hidden`}`,children:(0,X.jsx)(Lg,{entry:e})},e.info.id)}),w.startsWith(`plugin:`)&&!ne.some(e=>`plugin:${e.info.id}`===w)&&(0,X.jsx)(Rg,{pluginId:w.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===w),epoch:n.pluginsEpoch,failed:B.includes(w.slice(7))}),(0,X.jsx)(vg,{side:`right`,items:R,chat:n,view:w,onViewChange:e=>{yt.current=e===`terminal`&&n.terminals.length===0,yt.current&&an()&&(yt.current=!1),C(e),be(null)},onOpenPanel:be,onOpenSettings:e=>{Oe(e),J(!0)},onOpenBgTasks:()=>Ze(!0),onOpenGlobalSearch:()=>$e(!0),onUiAction:z,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>ut(lt===`light`?null:`light`),onSoundToggle:()=>at({...it,enabled:!it.enabled})})]})}),(0,X.jsx)(hg,{chat:n,bottombarItems:E.bottombar,onUiAction:z,onOpenSettings:()=>{Oe(void 0),J(!0)},onViewChange:e=>{yt.current=e===`terminal`&&n.terminals.length===0,yt.current&&an()&&(yt.current=!1),C(e),be(null)},onOpenGlobalSearch:()=>$e(!0),onOpenBgTasks:()=>Ze(!0)}),f&&(0,X.jsx)(Ry,{file:f,content:n.fileContent,onAddLines:(e,t,n,r)=>Ct(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>Ct(e,t,n),onClose:()=>p(null),uiFilePreviewToolbar:F,onUiAction:z}),h&&(0,X.jsx)(Hy,{file:h.file,plugin:h.plugin,declaration:h.declaration,epoch:n.pluginsEpoch,send:r,onClose:()=>g(null),onFallback:()=>{g(null),p(h.file)}}),n.ready&&n.state&&n.state.piConfigured===!1&&!Ce&&!Te&&(0,X.jsx)(C_,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>we(!0)}),Te&&(0,X.jsx)(N_,{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:()=>Ee(!1)}),q&&(0,X.jsx)(ly,{chat:n,terminal:o,initialSection:De,onSwitchToTerminal:()=>C(`terminal`),onClose:()=>J(!1),sound:it,onSoundChange:at,tts:ot,onTtsChange:st}),Xe&&(0,X.jsx)(gy,{servers:n.bgServers,onClose:()=>Ze(!1)}),(0,X.jsx)(Ay,{}),(0,X.jsx)(_y,{}),(0,X.jsx)(vy,{approval:n.approval}),H&&(0,X.jsx)(Iy,{entry:H,pluginView:U?ne.find(e=>e.info.id===U):void 0,onUiAction:(e,t)=>{z(e,t),ae(null)},onClose:()=>ae(null)}),(0,X.jsx)(Fy,{open:Qe,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>$e(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];rt(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{y(e,t)}}),(Je||We||ke)&&(0,X.jsxs)(`div`,{className:`modal-backdrop perm-modal-backdrop`,children:[Je&&(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:()=>qe(Je.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[Je.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,Je.pluginId).replace(`{hosts}`,(Je.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,Je.pluginId).replace(`{models}`,(Je.models??[]).length>0?` ${(Je.models??[]).join(`, `)}`:``),Je.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Je.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>qe(Je.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>qe(Je.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>qe(Je.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),We&&(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:()=>Ue(We.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,We.pluginId).replace(`{path}`,We.path),We.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:We.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Ue(We.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>Ue(We.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),ke&&(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:()=>{je.current=null,ke.resolve(!1),Ae(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,ke.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{je.current=null,ke.resolve(!1),Ae(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{je.current=null,ke.resolve(!0),Ae(null)},children:e(`ok`)})]})]})]})]}),!q&&Object.values(n.pluginJobs??{}).some(e=>e.phase!==`done`)&&(0,X.jsxs)(`div`,{className:`active-plugin-jobs-bar`,onClick:()=>{Oe(`plugins`),J(!0)},title:e(`pluginJobRunning`),children:[(0,X.jsx)(G,{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})()]}),(0,X.jsx)(e_,{})]})}function cb(){typeof document<`u`&&(lb(ub()),fb())}function lb(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function ub(){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 db(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 fb(){let e=()=>{let e=document.querySelector(`.messages`);return e?(lb(db(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)}an(),ju(ku()),cb(),(0,A.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(m.StrictMode,{children:(0,X.jsx)(Cn,{children:(0,X.jsx)(sb,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=en();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,St as c,ue as d,le as f,N as g,R as h,Pu as i,Re as l,ne as m,am as n,wn as o,G as p,Ou as r,Z as s,sm as t,K as u};
|
|
367
|
+
`))},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:xy[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)(at,{}),t(`planBoardCompleted`)]});case`in_progress`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ye,{}),t(`planBoardInProgress`)]});case`failed`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(_t,{}),t(`planBoardFailed`)]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ze,{}),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)(Se,{className:`plan-board-icon`}),(0,X.jsx)(`span`,{className:`plan-board-title`,children:t(`planBoardTitle`)}),(0,X.jsxs)(`span`,{className:`plan-board-count ${g===100?`plan-board-count-done`:``}`.trim(),children:[p,`/`,h]}),!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)(it,{style:{color:`var(--green, #22c55e)`}}):(0,X.jsx)(Ke,{})}),(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)(et,{}):(0,X.jsx)(rt,{})})]}),n&&(0,X.jsx)(`div`,{className:`plan-board-head-divider`,children:(0,X.jsx)(`div`,{className:`plan-board-head-divider-fill`,style:{width:`${g}%`,backgroundColor:g===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:`${g}%`,backgroundColor:g===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)(N,{}),` `,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)(it,{}),` `,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)(Re,{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)(ce,{}),` `,t(`planBoardAddStep`)]})]})]})}var Cy=3,wy=200;function Ty(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ey(e){return typeof e==`string`&&e.trim()||void 0}function Dy(e,t){let n=[];for(let r of e){let e=ky(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function Oy(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 ky(e,t=0){if(t>6||!Ty(e))return`any`;if(Ey(e.$ref))return`ref`;let n=Ey(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:ky(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 Dy(r,t+1)}return Ty(e.properties)?`object`:Ty(e.additionalProperties)?`record<${ky(e.additionalProperties,t+1)}>`:`any`}function Ay(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=Oy(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 jy(e,t={}){let n=t.maxDepth??Cy,r=t.maxRows??wy,i=e;if(!Ty(i))return[];let a=i.properties;if(!Ty(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=Ty(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:ky(e,i),required:a.has(s),depth:i},f=Ey(e.description);f&&(d.description=f);let p=Ay(e);if(p&&(d.hint=p),o.push(d),i+1<n&&Ty(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 My(){let e=Z(),t=oo();return At(()=>{no()},!!t),t?(0,k.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:no,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)(J,{}),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:no,children:(0,X.jsx)(N,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(Ny,{info:t})})]})}),document.body):null}function Ny({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?[]:jy(e.parameters),r=e.parameters===void 0?``:Fy(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)(Py,{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)(Ql,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function Py({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 Fy(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function Iy(e,t){return e.toLowerCase().includes(t)}function Ly({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=wn(),u=l===`en`?`Plugins`:`插件`,d=ha(`cwd`),f=(0,m.useRef)(null),[p,h]=(0,m.useState)(``),g=(0,m.useDeferredValue)(p),[_,v]=(0,m.useState)(0),y=(0,m.useRef)(0),b=(0,m.useRef)(null),[x,S]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=p.trim();if(t){let e=Bh();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,m.useState)(!1);(0,m.useEffect)(()=>{b.current&&clearTimeout(b.current);let e=g.trim();if(!e){w(!1),S(null);return}return b.current=setTimeout(()=>{let t=Bh();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)}},[g]),(0,m.useEffect)(()=>{n&&n.reqId===y.current&&S(n)},[n]);let T=g.trim().toLowerCase(),E=(0,m.useMemo)(()=>!T||!r||r.reqId!==y.current||!r.ok?[]:r.results,[r,T]),D=(0,m.useMemo)(()=>T?t.filter(e=>Iy(e.path,T)).slice(0,10):[],[t,T]),O=(0,m.useMemo)(()=>!T||!x||!x.ok?[]:x.results,[x,T]);(0,m.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,m.useState)([]);(0,m.useEffect)(()=>{if(!e)return;let t=g.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 Wo==`function`&&(r=Wo())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=Yo(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,g]);let ee=(0,m.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,m.useEffect)(()=>{v(0)},[g]);let M=(0,m.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=g.trim();if(t){let e=Bh();y.current=e,w(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}}else e.kind===`plugin`?Mo(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,g]);(0,m.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 P=E.length+D.length+O.length+A.length,F=(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})]}),I=-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)(G,{}),(0,X.jsx)(`input`,{ref:f,type:`text`,value:p,placeholder:c(`gsPlaceholder`),onChange:e=>h(e.target.value)}),(0,X.jsx)(`button`,{type:`button`,className:`gs-close`,title:c(`close`),onClick:i,children:(0,X.jsx)(N,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!T&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),T&&P===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:[F(c(`gsSessions`),E.length,(0,X.jsx)(_e,{})),E.map(e=>{I++;let t=I,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(),er({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:[F(c(`gsProjects`),D.length,(0,X.jsx)(Me,{})),D.map(e=>{I++;let t=I,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:[F(c(`gsFiles`),O.length,(0,X.jsx)(Pe,{})),O.map(e=>{I++;let t=I;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:[F(u,A.length,(0,X.jsx)(de,{})),A.map((e,t)=>{I++;let n=I;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 Ry({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(gy,{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)(Yg,{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 zy=5e3;function By({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(``),[C,w]=(0,m.useState)(!0),[T,E]=(0,m.useState)(!0),[D,O]=(0,m.useState)(!1),k=(0,m.useRef)(!1),[A,M]=(0,m.useState)(!0),[P,F]=(0,m.useState)(!1),[I,L]=(0,m.useState)(100),te=(0,m.useRef)(0),R=(0,m.useRef)(!1),z=(0,m.useRef)(null),[ne,re]=(0,m.useState)(!1),[B,ie]=(0,m.useState)(!1),V=(0,m.useRef)(!1),H=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>{z.current&&clearTimeout(z.current),H.current&&clearTimeout(H.current)},[]),(0,m.useEffect)(()=>{d(!0),l(null),p(null),b(!1),S(``),w(!0),E(!0),O(!1),k.current=!1,V.current=!1,re(!1),ie(!1),H.current&&clearTimeout(H.current),$({type:`read_file`,path:e.path})},[e.path]),(0,m.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1),V.current&&(V.current=!1,H.current&&clearTimeout(H.current),re(!1),ie(!1),b(!1),S(t.text),k.current&&(Vy(e.name)&&w(!0),Uy(e.name)&&E(!0)),p(null)))},[t,y,e.path]),(0,m.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){fe();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&y){e.preventDefault(),de();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(),se())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,m.useEffect)(()=>{let e=()=>{R.current=!1,g(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let U=(0,m.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
|
|
368
|
+
`);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,zy)},[c]),W=c?.lines??0,G=W>zy,ae=(e,t)=>{if(t){let t=te.current>0?te.current:e;p({start:Math.min(t,e),end:Math.max(t,e)})}else te.current=e,p({start:e,end:e})},se=()=>{U.length!==0&&(te.current=1,p({start:1,end:U.length}))},K=()=>{f&&(n(e.path,e.name,f.start,f.end),v(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>v(!1),1400))},ce=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated&&!Hy(e.name),le=()=>{V.current=!1,H.current&&clearTimeout(H.current),re(!1),ie(!1),S(c?.text??``),b(!1),k.current&&(Vy(e.name)&&w(!0),Uy(e.name)&&E(!0))},ue=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;le();return}ce&&c&&(k.current=Vy(e.name)&&C||Uy(e.name)&&T,Vy(e.name)&&w(!1),Uy(e.name)&&E(!1),p(null),S(c.text),b(!0))},de=()=>{y&&c&&ce&&$({type:`write_file`,path:e.path,text:x})&&(V.current=!0,ie(!1),re(!0),H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{V.current=!1,re(!1),ie(!0)},5e3))},fe=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},pe=e=>{L(Math.min(200,Math.max(50,e)))},me=f?f.end-f.start+1:0,ge=c?.binary??!1,_e=c?.truncated??!1,q=c?.kind??`text`,ye=Vy(e.name)||Hy(e.name),be=Uy(e.name),xe=ye&&C&&!y&&q===`text`&&!ge,Se=be&&T&&!y&&q===`text`&&!ge,we={"host:fp-md":ye&&q===`text`&&!ge&&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)(Fe,{}):(0,X.jsx)(Je,{})}):null,"host:fp-html":be&&q===`text`&&!ge&&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)(Je,{}):(0,X.jsx)(Fe,{})}):null,"host:fp-edit":q===`text`&&!ge&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(_e?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!ce&&!y,onClick:ue,children:(0,X.jsx)(Le,{})}):null,"host:fp-wrap":q===`text`&&!ge&&!xe&&!Se?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${A?`on`:``}`,"data-tip":s(A?`disableWrap`:`enableWrap`),onClick:()=>M(e=>!e),children:(0,X.jsx)(Ge,{})}):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:I<=50,onClick:()=>pe(I-10),children:(0,X.jsx)(j,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>L(100),children:[I,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:I>=200,onClick:()=>pe(I+10),children:(0,X.jsx)(ee,{})})]}):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)(Ce,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${P?`on`:``}`,"data-tip":s(P?`exitFullscreen`:`fullscreen`),onClick:()=>F(e=>!e),children:P?(0,X.jsx)(he,{}):(0,X.jsx)(ve,{})}),"host:fp-close":null},Te=a===void 0?[`host:fp-md`,`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`),J=e=>sn(nn(`/api/file?clientId=${encodeURIComponent(uc())}&path=${encodeURIComponent(e)}`)),Ee=e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return sn(nn(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(uc())}${D?`&allowJs=1`:``}`))};return(0,X.jsx)(`div`,{className:`fp-overlay ${P?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&fe()},children:(0,X.jsxs)(`div`,{className:`fp ${P?`fullscreen`:``}`,style:{"--fp-zoom":I/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,onDoubleClick:e=>{let t=e.target;t&&!t.closest(`button, a, input`)&&F(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`&&!ge&&s(`fileLines`,{n:W}),c&&` · ${Sf(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:cm(Te,we,o)}),(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),"aria-label":s(`close`),onClick:fe,children:(0,X.jsx)(N,{})})]}),_e&&q===`text`&&!ge&&(0,X.jsx)(`div`,{className:`fp-notice`,children:Hy(e.name)?s(`previewLinesTruncated`,{n:U.length}):s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&q===`none`&&!ge&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&q===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap clickable`,onClick:fe,title:s(`clickToCloseImage`),children:(0,X.jsx)(`img`,{className:`fp-media fp-media-clickable`,src:J(e.path),alt:e.name,onClick:fe,title:s(`clickToCloseImage`)})}),!u&&q===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:J(e.path),controls:!0,preload:`metadata`})}),!u&&Se&&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:Ee(e.path),target:`_blank`,rel:`noopener noreferrer`,title:s(`openInNewTab`),children:[(0,X.jsx)(Ie,{}),(0,X.jsx)(`span`,{children:s(`openInNewTab`)})]})]}),(0,X.jsx)(`iframe`,{className:`fp-html-frame`,src:Ee(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&xe&&c&&(0,X.jsx)(`div`,{className:Hy(e.name)?`fp-markdown msg-text fp-office`:`fp-markdown msg-text`,children:(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,children:(0,X.jsx)(Ku,{text:c.text})})}),!u&&ge&&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`&&!ge&&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}),B&&(0,X.jsx)(`div`,{className:`fp-notice`,role:`alert`,children:s(`saveResultUnknown`)})]}),!u&&!xe&&!Se&&!y&&q===`text`&&!ge&&c&&U.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!xe&&!Se&&!y&&q===`text`&&!ge&&U.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${h?`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&&(ae(n,e.shiftKey),R.current=!0,g(!0))},onMouseEnter:()=>{R.current&&ae(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),G&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:zy})})]}),(y||!xe&&!Se&&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:ue,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:ne||x===(c?.text??``),onClick:de,children:[(0,X.jsx)(oe,{}),` `,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:se,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||ge,onClick:K,children:[_?(0,X.jsx)(it,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function Vy(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function Hy(e){let t=e.toLowerCase();return t.endsWith(`.docx`)||t.endsWith(`.xlsx`)||t.endsWith(`.xlsm`)}function Uy(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function Wy({file:e,plugin:t,declaration:n,epoch:r,send:i,onClose:a,onFallback:o}){let s=Z(),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(!1),p=(0,m.useRef)(o);p.current=o;let h=n.label??t.name;return(0,m.useEffect)(()=>{let r=c.current;if(!r)return;let a=!1,o;return u(null),f(!1),(async()=>{try{let s=await C_({plugin:t,declaration:n});if(a)return;if(!s)throw Error(`插件没有提供可用的文件查看器`);let c=`/plugins-api/${encodeURIComponent(t.id)}`,l={...Ls(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 sn(nn(`${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)(gy,{className:`plugin-file-preview`,title:h,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 Gy=.4,Ky=1.05;function qy(e){return Math.min(300,e*.86)}function Jy(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Yy(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Xy(e,t){return e===`left`?t:-t}function Zy(e,t){return Math.max(-e,Math.min(0,-e+t))}function Qy(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function $y(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Qy(r*Ky,n,t)>=Gy}var eb=new Set([`auto`,`scroll`,`overlay`]);function tb(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&eb.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function nb(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function rb(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,m.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=Jy(r.clientX,window.innerWidth,n);i&&!tb(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=Yy(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=qy(window.innerWidth),h=m*Ky;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=Xy(r,d);let b=Zy(h,f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Qy(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?$y({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(nb(),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 ib(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 ab=(0,m.lazy)(()=>ps(()=>import(`./TerminalPanel-NerrJlTS.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function ob({notice:e,onDismiss:t}){let n=Z(),{locale:r}=wn(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(a)return;let n=setTimeout(()=>t(e.id),e.level===`error`?12e3:7e3);return()=>clearTimeout(n)},[a,e.id,e.level,t]);let s=e.level===`error`?_t:e.level===`warning`?gt:J;return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${a?` paused`:``}`,role:`status`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),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:()=>t(e.id),children:(0,X.jsx)(N,{})})]})}var sb=[],cb=180,lb=520,ub=240,db=e=>`pi-web-ui:${e}-panel-width`;function fb(e){try{let t=Number(localStorage.getItem(db(e)));return Number.isFinite(t)&&t>=cb&&t<=lb?t:ub}catch{return ub}}var pb=e=>`pi-web-ui:${e}-panel-collapsed`;function mb(e){try{return localStorage.getItem(pb(e))===`1`}catch{return!1}}function hb({side:e,width:t,onResize:n}){let r=Z(),i=(0,m.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(lb,Math.max(cb,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`);try{localStorage.setItem(db(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(ub)})}function gb({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)(Qe,{}):(0,X.jsx)($e,{})})}var _b=`pi-web-ui:plugin-path-grants`,vb=e=>e?`${_b}:${e}`:_b;function yb(e){if(e===null)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function bb(e){try{let t=vb(e);if(localStorage.getItem(t)!==null)return yb(localStorage.getItem(t));if(!e)return[];let n=yb(localStorage.getItem(_b));return localStorage.setItem(t,JSON.stringify(n)),n}catch{return[]}}function xb(e,t){try{let n=[...new Set([...bb(t),e])];localStorage.setItem(vb(t),JSON.stringify(n))}catch{}}function Sb(){let e=Z(),{locale:t}=wn(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=Tc(),s=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:Uv[t]??Uv.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=xv();(0,m.useEffect)(()=>{let t=l?mv(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,m.useState)([]);(0,m.useEffect)(()=>(Xn(e=>d(t=>th(t,e))),()=>Xn(null)),[]);let[f,p]=(0,m.useState)(null),[h,g]=(0,m.useState)(null),_=(0,m.useRef)(!1),v=(0,m.useRef)(null);(0,m.useEffect)(()=>{_.current=f!==null,v.current=h},[f,h]);let y=(0,m.useCallback)((e,t)=>{let n=S_(t);if(n){p(null),g({file:{path:e,name:t},plugin:n.plugin,declaration:n.declaration});return}g(null),p({path:e,name:t})},[]);(0,m.useEffect)(()=>(Ru({open:e=>y(e.path,e.name),isOpen:()=>_.current||v.current!==null}),()=>Ru(null)),[y]);let[b,x]=(0,m.useState)(!1);(0,m.useEffect)(()=>{let e=()=>x(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[S,C]=(0,m.useState)(`chat`),w=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(S.startsWith(`plugin:`)?`plugins`:S)?S:`chat`,T=(0,m.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),E=(0,m.useMemo)(()=>{let r=[],i=ji(bi(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,m.useMemo)(()=>E[`topbar.primary`].filter(e=>!e.hidden),[E]),O=(0,m.useMemo)(()=>[...E[`topbar.primary`].filter(e=>e.hidden),...E[`topbar.overflow`]],[E]),k=(0,m.useMemo)(()=>E[`leftpanel.sessions`].filter(e=>!e.hidden),[E]),A=(0,m.useMemo)(()=>E[`terminal.toolbar`].filter(e=>!e.hidden),[E]),j=(0,m.useMemo)(()=>E[`scm.toolbar`].filter(e=>!e.hidden),[E]),ee=(0,m.useMemo)(()=>E[`goalbar.actions`].filter(e=>!e.hidden),[E]),M=(0,m.useMemo)(()=>E[`chat.header`].filter(e=>!e.hidden),[E]),P=(0,m.useMemo)(()=>E[`chat.empty`].filter(e=>!e.hidden),[E]),F=(0,m.useMemo)(()=>E[`file.preview.toolbar`].filter(e=>!e.hidden),[E]),I=(0,m.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(n=>[n.id,Jh(n,t,e).name])),[n.dshPresets,t]),L=(0,m.useMemo)(()=>E[`notice.actions`].filter(e=>!e.hidden),[E]),te=(0,m.useMemo)(()=>E[`sidebar.left`]??[],[E]),R=(0,m.useMemo)(()=>E[`sidebar.right`]??[],[E]),z=(0,m.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&&Vf({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&&Mo(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?Fs(t,G.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[ne,re]=(0,m.useState)([]);(0,m.useEffect)(()=>Os(re),[]);let[B,ie]=(0,m.useState)([]);(0,m.useEffect)(()=>Es(ie),[]);let[V,H]=(0,m.useState)(null),U=V?E[`modal.dialog`].find(e=>e.id===V&&!e.hidden):void 0,W=(0,m.useMemo)(()=>{if(!U||U.kind!==`view`)return``;let e=U.view??``;return e.startsWith(`plugin:`)?e.slice(7):U.source.startsWith(`plugin:`)?U.source.slice(7):``},[U]);(0,m.useEffect)(()=>{if(!U||!W||ne.some(e=>e.info.id===W))return;let e=G.current.plugins.find(e=>e.id===W);e&&Fs(e,G.current.pluginsEpoch)},[U,W,ne,n.pluginsEpoch]),(0,m.useEffect)(()=>{mu(r),hu(T,n.pluginsEpoch),Su(T,n.pluginsEpoch),x_(T,n.pluginsEpoch),Is(T,n.pluginsEpoch)},[T,n.pluginsEpoch,r]);let G=(0,m.useRef)(n);G.current=n;let ae=(0,m.useRef)(C);ae.current=C;let oe=(0,m.useRef)(E);oe.current=E,(0,m.useEffect)(()=>(To(wo({send:r,isReady:()=>!!G.current.state,setView:e=>ae.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:bb,grantPath:xb,confirm:e=>new Promise(t=>{if(Me.current){t(!1);return}let n={path:e.path,resolve:t};Me.current=n,je(n)}),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=oe.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(H(t),!0)},closeModal:()=>H(null),dialogConfirm:e=>new Promise(t=>{if(Pe.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Pe.current=n,Y(n)}),select:e=>new Promise(t=>{if(Pe.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Pe.current=n,Ie([]),Y(n)}),input:e=>new Promise(t=>{if(Pe.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};Pe.current=n,Re(e.initial??``),Y(n)}),notifyAction:e=>new Promise(t=>{try{let n=Ve.current;Ve.current=null,Be(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Ve.current=r,Be(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=G.current.plugins.find(t=>t.id===e);return t?Fs(t,G.current.pluginsEpoch):Promise.resolve(!1)}})),()=>To(null)),[r]);let[se,ce]=(0,m.useState)(()=>fb(`left`)),[le,ue]=(0,m.useState)(()=>fb(`right`)),de=(0,m.useCallback)(e=>ce(e),[]),fe=(0,m.useCallback)(e=>ue(e),[]),[pe,me]=(0,m.useState)(()=>mb(`left`)),[he,ge]=(0,m.useState)(()=>mb(`right`)),_e=(0,m.useCallback)(()=>{me(e=>{try{localStorage.setItem(pb(`left`),e?`0`:`1`)}catch{}return!e})},[]),q=(0,m.useCallback)(()=>{ge(e=>{try{localStorage.setItem(pb(`right`),e?`0`:`1`)}catch{}return!e})},[]),[ve,ye]=(0,m.useState)(null),be=(0,m.useRef)(null),[xe,Se]=(0,m.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,m.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>Se(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),rb({enabled:xe&&w===`chat`,open:ve,onOpenChange:ye,container:be,backdropSelector:`.drawer-backdrop.persistent`});let[Ce,we]=(0,m.useState)(!1),[Te,J]=(0,m.useState)(!1),[Ee,De]=(0,m.useState)(!1),[Oe,ke]=(0,m.useState)(),[Ae,je]=(0,m.useState)(null),Me=(0,m.useRef)(null),[Ne,Y]=(0,m.useState)(null),Pe=(0,m.useRef)(null),[Fe,Ie]=(0,m.useState)([]),[Le,Re]=(0,m.useState)(``),[ze,Be]=(0,m.useState)(null),Ve=(0,m.useRef)(null),[He,Ue]=(0,m.useState)(()=>new Set),We=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),Ue(t=>new Set(t).add(e))},Ge=n.pathRequests.find(e=>!He.has(e.id))??null,[Ke,qe]=(0,m.useState)(()=>new Set),Je=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),qe(t=>new Set(t).add(e))},Ye=n.permRequests.find(e=>!Ke.has(e.id))??null,Xe=uv(),[Ze,Qe]=(0,m.useState)(!1),[$e,et]=(0,m.useState)(!1),[tt,nt]=(0,m.useState)(!1),[rt,it]=(0,m.useState)(null);(0,m.useEffect)(()=>{if(!rt)return;let e=setTimeout(()=>it(null),15e3);return()=>clearTimeout(e)},[rt]),(0,m.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=St();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,m.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),et(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[at,ot]=(0,m.useState)(K_),[st,ct]=(0,m.useState)(It),{themes:lt,theme:ut,switchTheme:dt,reloadThemes:ft}=Nu();Bv(),(0,m.useEffect)(()=>{try{typeof as==`function`&&as(ut??``)}catch{}},[ut]),(0,m.useEffect)(()=>{try{typeof os==`function`&&os(t)}catch{}},[t]),(0,m.useEffect)(()=>{try{typeof ss==`function`&&ss(w)}catch{}},[w]),(0,m.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof ts==`function`&&ts(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,m.useEffect)(()=>{if(!Ne)return;let e=e=>{if(e.key!==`Escape`)return;let t=Pe.current;Pe.current=null,Y(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)},[Ne]),(0,m.useEffect)(()=>{if(!ze)return;let e=setTimeout(()=>{let e=Ve.current;Ve.current=null,Be(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[ze]);let pt=(0,m.useRef)(null),mt=(0,m.useRef)(null),ht=(0,m.useRef)(n.state?.messages);ht.current=n.state?.messages;let gt=(0,m.useRef)(new Set),_t=(0,m.useRef)(new Set),vt=(0,m.useRef)(new Set),yt=(0,m.useRef)(0),bt=(0,m.useRef)(!1),xt=(0,m.useRef)(n.terminals);(0,m.useEffect)(()=>{q_(at)},[at]),(0,m.useEffect)(()=>{Lt(st)},[st]),(0,m.useEffect)(()=>{let e=xt.current;xt.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,m.useEffect)(()=>{let t=n.state?.conversationId??null,r=ib(pt.current,t,n.state?.isStreaming??!1,n.conversations,mt.current);if(pt.current=r.nextMap,mt.current=t,r.startCue&&Q_(`start`,at),r.finishedConvs.length>0){Q_(`done`,at);let t=r.finishedConvs.find(e=>e.isActive);if(t&&(Gr(e(`notifyDoneTitle`),e(`notifyDoneBody`)),st.enabled&&!Mr(zr()))){if(st.readReplies){let t=Vt(ht.current);t?Xt(t,st):st.announce&&Xt(e(`ttsAnnounceDone`),st)}else st.announce&&Xt(e(`ttsAnnounceDone`),st)}for(let t of r.finishedConvs.filter(e=>!e.isActive)){let n=t.title?`${t.title}:${e(`notifyDoneBody`)}`:e(`notifyDoneBody`);Gr(e(`notifyDoneTitle`),n)}!t&&st.enabled&&st.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceDone`),st)}},[n.state?.conversationId,n.state?.isStreaming,n.conversations,at,st,e]),(0,m.useEffect)(()=>{let t=n.dialog?.id??null;if(t!==null&&!gt.current.has(t)){if(gt.current.add(t),gt.current.size>64){let e=gt.current.values().next().value;e!==void 0&>.current.delete(e)}Q_(`question`,at),Gr(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),st.enabled&&st.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceQuestion`),st)}},[n.dialog,at,st,e]),(0,m.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null,i=!1;t!==null&&!_t.current.has(t)&&(_t.current.add(t),i=!0),r!==null&&!_t.current.has(r)&&(_t.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}`;_t.current.has(n)||(_t.current.add(n),e.questionId&&_t.current.add(e.questionId),t!==e.questionId&&(i=!0))}if(_t.current.size>64){let e=_t.current.values().next().value;e!==void 0&&_t.current.delete(e)}i&&(Q_(`question`,at),Gr(e(`notifyQuestionTitle`),e(`notifyQuestionBody`)),st.enabled&&st.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceQuestion`),st))},[n.question,n.remoteQuestion,n.conversations,at,st,e]),(0,m.useEffect)(()=>{let t=n.approval,r=t?.id??null;if(r!==null&&!vt.current.has(r)){if(vt.current.add(r),vt.current.size>64){let e=vt.current.values().next().value;e!==void 0&&vt.current.delete(e)}Q_(`approval`,at);let n=typeof t?.toolName==`string`?t.toolName:``;Gr(e(`notifyApprovalTitle`),n?e(`notifyApprovalBodyTool`,{tool:n}):e(`notifyApprovalBody`)),st.enabled&&st.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceApproval`),st)}},[n.approval,at,st,e]),(0,m.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==yt.current&&(yt.current=t.id,Q_(`error`,at),Gr(e(`notifyErrorTitle`),e(`notifyErrorBody`)),st.enabled&&st.announce&&!Mr(zr())&&Xt(e(`ttsAnnounceError`),st))},[n.notices,at,st,e]);let Ct=(0,m.useRef)(new Set);(0,m.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||Ct.current.has(t.id))continue;Ct.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(nn(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 wt=(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&&qn(`@${s} `)},Tt=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&&Jn(`@${t}`)},Et=(0,m.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&ye(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&C(e=>e===`chat`?e:`chat`),r(e)),[r]),Dt=(0,m.useRef)(new Set),Ot=n.activeConversationId||n.state?.conversationId||``;(0,m.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 Dt.current)i.has(e)||Dt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===Ot){a_(t,{silent:!0});continue}n.questionId&&Dt.current.has(n.questionId)||i_({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&&Dt.current.add(n.questionId)},onClick:()=>{Et({type:`switch_conversation`,id:n.id}),a_(t,{silent:!0})}})}o_(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===Ot:!1},{silent:!0})},[n.conversations,Ot,Et,e]);let kt=(0,m.useRef)(0),At=(0,m.useRef)(0),jt=(0,m.useCallback)(t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-At.current>1e4&&(At.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++kt.current}`;d(e=>[...e,{path:``,key:i,name:t.name,imageData:t.data,mimeType:t.mimeType}])},[n.state?.model,a,e]),Mt=(0,m.useCallback)(async t=>{for(let n of t){let t=await gf(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}jt(t)}},[jt,a,e]),Nt=20971520,Pt=(0,m.useRef)(0),Ft=(0,m.useCallback)(async t=>{if(t.size>Nt){a(`warning`,e(`fileTooLarge`,{name:t.name,size:Nt/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-${++Pt.current}`;d(e=>[...e,{path:``,key:r,name:t.name,fileData:n,size:t.size,mimeType:t.type||void 0}])},[Nt,a,e]),Rt=(0,m.useCallback)(async e=>{for(let t of e)hf(t.type)?await Mt([t]):await Ft(t)},[Mt,Ft]),zt=(0,m.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),Bt=(0,m.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[Ht,Ut]=(0,m.useState)([]),Wt=(0,m.useRef)(0),Gt=(0,m.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),Wt.current+=1;let i=jl(t),a={text:i.text,seq:Wt.current};i.quotes.length&&d(e=>th(e,i.quotes.map(e=>({path:``,name:``,mode:`quote`,quote:e,key:St()})))),Ut(e=>[...e.slice(-9),a])},[r]),Kt=(0,m.useCallback)(()=>J(!0),[]),qt=(0,m.useCallback)(()=>d([]),[]);g_(n.state?.sessionId??``,qt);let Jt=(0,m.useCallback)(Tt,[]),Yt=Mt,Zt=Rt,Qt=(0,m.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),$t=(0,m.useCallback)(e=>wt(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines,e.silent??!1),[]),en=n.state?.model,tn=n.state?.thinkingLevel,rn=n.state?.availableThinkingLevels,an=(0,m.useMemo)(()=>en?{model:en,thinkingLevel:tn??`off`,availableThinkingLevels:rn??[]}:null,[en,tn,rn]),on=(0,m.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:St(),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,m.useEffect)(()=>{if(bt.current){if(w!==`terminal`||n.terminals.length!==0){bt.current=!1;return}on()&&(bt.current=!1)}},[n.terminals.length,on,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=>hf(e.type)),i=n.filter(e=>!hf(e.type));r.length>0&&Mt(r),i.length>0&&Rt(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)(Ga,{chat:n,terminal:o,view:w,plugins:T,uiPrimary:D,uiOverflow:O,uiContextTopbar:E[`contextmenu.topbar`],onUiAction:z,onViewChange:e=>{bt.current=e===`terminal`&&n.terminals.length===0,bt.current&&on()&&(bt.current=!1),C(e),ye(null)},onOpenPanel:ye,onOpenSettings:()=>{ke(void 0),De(!0)},onManagePlugins:()=>{ke(`plugins`),De(!0)},onOpenBgTasks:()=>Qe(!0),onOpenGlobalSearch:()=>et(!0),onOpenIconEdit:()=>nt(!0),sound:at,onSoundChange:ot,onSoundPreview:e=>Q_(e,at),themes:lt,theme:ut,onThemeChange:dt,reloadThemes:ft}),tt&&(0,X.jsx)(h_,{slots:E,layout:n.settings?.uiLayout,exclude:fi,onClose:()=>nt(!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)(ob,{notice:e,onDismiss:i},e.id)),ze&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:ze.text}),ze.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Ve.current;Ve.current=null,Be(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=Ve.current;Ve.current=null,Be(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(N,{})})]}),L.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:L.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=>z(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:()=>z(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(em,{currentModelId:en?`${en.provider}/${en.id}`:null,children:(0,X.jsxs)(`div`,{ref:be,className:`layout`,style:{"--left-w":`${se}px`,"--right-w":`${le}px`},children:[xe?(0,X.jsx)(`div`,{className:`drawer-backdrop persistent${ve?` on`:``}`,onClick:()=>ye(null)}):ve&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>ye(null)}),(0,X.jsx)(Ag,{side:`left`,items:te,chat:n,view:w,onViewChange:e=>{bt.current=e===`terminal`&&n.terminals.length===0,bt.current&&on()&&(bt.current=!1),C(e),ye(null)},onOpenPanel:ye,onOpenSettings:e=>{ke(e),De(!0)},onOpenBgTasks:()=>Qe(!0),onOpenGlobalSearch:()=>et(!0),onUiAction:z,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>dt(ut===`light`?null:`light`),onSoundToggle:()=>ot({...at,enabled:!at.enabled})}),(0,X.jsxs)(`div`,{className:`view-pane ${w===`chat`?``:`hidden`}`,children:[!xe&&pe&&(0,X.jsx)(gb,{side:`left`,onClick:_e}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${ve===`left`?`open`:``}${xe?``:pe?` hidden`:``}`,children:(0,X.jsx)(Lc,{collapsible:!xe,onToggleCollapse:_e,panelSend:Et,active:!xe||ve===`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,onUiAction:z,presetNames:I})}),!xe&&(0,X.jsx)(hb,{side:`left`,width:se,onResize:de}),(0,X.jsxs)(`main`,{className:Xe?`main wide-chat`:`main`,children:[M.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:om(M,z)}),n.state?(0,X.jsxs)(X.Fragment,{children:[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:Ot}),children:[`💾 `,e(`saveEphemeral`)]})]}),(0,X.jsx)(Xm,{uiMessageActions:E[`message.actions`],uiContextMessage:E[`contextmenu.message`],uiContextToolCall:E[`contextmenu.toolcall`],uiChatEmpty:P,onUiAction:z,state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:zt,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Kp(`${e.provider}/${e.id}`)}},onRemoveQueued:Bt,onRecallQueued:Gt,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,jumpTarget:rt,onJumpDone:()=>it(null)},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)(cg,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:ee,onUiAction:z})}),(0,X.jsx)(Zg,{onAction:(e,t,n)=>z(e,n,t)}),n.dialog&&(0,X.jsx)(jg,{dialog:n.dialog}),Ne&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":Ne.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),Ne.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:Ne.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Pe.current;Pe.current=null,Y(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),Ne.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(Ne.options??[]).map((e,t)=>{let n=Ne.multi?Fe.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(Ne.multi){Ie(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Pe.current;Pe.current=null,Y(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)}),(Ne.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),Ne.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Pe.current,t=(e?.options??[]).filter((e,t)=>Fe.includes(t)).map(e=>e.label);Pe.current=null,Y(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),Ne.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=Pe.current;Pe.current=null,Y(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Pe.current;Pe.current=null,Y(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),Ne.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Le,placeholder:Ne.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>Re(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Pe.current;Pe.current=null,Y(null);try{e?.resolve({ok:!0,value:Le})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Pe.current;Pe.current=null,Y(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Pe.current;Pe.current=null,Y(null);try{e?.resolve({ok:!0,value:Le})}catch{}},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Pg,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||Ot))?.title}),n.remoteQuestion&&(0,X.jsx)(Pg,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(Sy,{plan:n.activeConversationId&&n.state?.conversationId!==n.activeConversationId?null:n.state?.plan}),(0,X.jsx)(sg,{composerLeading:E[`composer.leading`],composerActions:E[`composer.actions`],onUiAction:z,streaming:n.state?.isStreaming??!1,planMode:n.state?.planMode??!1,messages:n.state?.messages??sb,slashCommands:n.slashCommands,modelState:an,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:Jt,onAddImageFiles:Yt,onAddLocalFiles:Zt,onAddPathAttachment:$t,fileSearch:n.fileSearch,onSearchFiles:Qt,onNotice:a,onManageModels:Kt,onSent:qt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:Ht,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??``})]}),!xe&&(0,X.jsx)(hb,{side:`right`,width:le,onResize:fe}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${ve===`right`?`open`:``}${xe?``:he?` hidden`:``}`,children:(0,X.jsx)(Ol,{collapsible:!xe,onToggleCollapse:q,panelSend:Et,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{ye(null),wt(e,t,n,r)},onPreview:(e,t)=>{ye(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})}),!xe&&he&&(0,X.jsx)(gb,{side:`right`,onClick:q})]}),(0,X.jsx)(`div`,{className:`view-pane ${w===`terminal`?``:`hidden`}`,children:(0,X.jsx)(m.Suspense,{fallback:null,children:(0,X.jsx)(ab,{chat:n,terminal:o,uiTerminalToolbar:A,onUiAction:z})})}),(0,X.jsx)(`div`,{className:`view-pane ${w===`git`?``:`hidden`}`,children:(0,X.jsx)(Jg,{chat:n,terminal:o,active:w===`git`,onSwitchToTerminal:()=>C(`terminal`),uiScmToolbar:j,onUiAction:z})}),ne.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${w===t?``:`hidden`}`,children:(0,X.jsx)(Yg,{entry:e})},e.info.id)}),w.startsWith(`plugin:`)&&!ne.some(e=>`plugin:${e.info.id}`===w)&&(0,X.jsx)(Xg,{pluginId:w.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===w),epoch:n.pluginsEpoch,failed:B.includes(w.slice(7))}),(0,X.jsx)(Ag,{side:`right`,items:R,chat:n,view:w,onViewChange:e=>{bt.current=e===`terminal`&&n.terminals.length===0,bt.current&&on()&&(bt.current=!1),C(e),ye(null)},onOpenPanel:ye,onOpenSettings:e=>{ke(e),De(!0)},onOpenBgTasks:()=>Qe(!0),onOpenGlobalSearch:()=>et(!0),onUiAction:z,uiContextTopbar:E[`contextmenu.topbar`],onThemeToggle:()=>dt(ut===`light`?null:`light`),onSoundToggle:()=>ot({...at,enabled:!at.enabled})})]})}),(0,X.jsx)(gg,{chat:n,bottombarItems:E.bottombar,onUiAction:z,onOpenSettings:()=>{ke(void 0),De(!0)},onViewChange:e=>{bt.current=e===`terminal`&&n.terminals.length===0,bt.current&&on()&&(bt.current=!1),C(e),ye(null)},onOpenGlobalSearch:()=>et(!0),onOpenBgTasks:()=>Qe(!0)}),f&&(0,X.jsx)(By,{file:f,content:n.fileContent,onAddLines:(e,t,n,r)=>wt(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>wt(e,t,n),onClose:()=>p(null),uiFilePreviewToolbar:F,onUiAction:z}),h&&(0,X.jsx)(Wy,{file:h.file,plugin:h.plugin,declaration:h.declaration,epoch:n.pluginsEpoch,send:r,onClose:()=>g(null),onFallback:()=>{g(null),p(h.file)}}),n.ready&&n.state&&n.state.piConfigured===!1&&!Ce&&!Te&&(0,X.jsx)(T_,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>we(!0)}),Te&&(0,X.jsx)(F_,{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:()=>J(!1)}),Ee&&(0,X.jsx)(dy,{chat:n,terminal:o,initialSection:Oe,onSwitchToTerminal:()=>C(`terminal`),onClose:()=>De(!1),sound:at,onSoundChange:ot,tts:st,onTtsChange:ct}),Ze&&(0,X.jsx)(vy,{servers:n.bgServers,onClose:()=>Qe(!1)}),(0,X.jsx)(My,{}),(0,X.jsx)(yy,{}),(0,X.jsx)(by,{approval:n.approval}),U&&(0,X.jsx)(Ry,{entry:U,pluginView:W?ne.find(e=>e.info.id===W):void 0,onUiAction:(e,t)=>{z(e,t),H(null)},onClose:()=>H(null)}),(0,X.jsx)(Ly,{open:$e,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>et(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];it(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{y(e,t)}}),(Ye||Ge||Ae)&&(0,X.jsxs)(`div`,{className:`modal-backdrop perm-modal-backdrop`,children:[Ye&&(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:()=>Je(Ye.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[Ye.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,Ye.pluginId).replace(`{hosts}`,(Ye.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,Ye.pluginId).replace(`{models}`,(Ye.models??[]).length>0?` ${(Ye.models??[]).join(`, `)}`:``),Ye.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Ye.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Je(Ye.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Je(Ye.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>Je(Ye.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),Ge&&(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:()=>We(Ge.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,Ge.pluginId).replace(`{path}`,Ge.path),Ge.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Ge.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>We(Ge.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>We(Ge.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),Ae&&(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:()=>{Me.current=null,Ae.resolve(!1),je(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,Ae.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{Me.current=null,Ae.resolve(!1),je(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{Me.current=null,Ae.resolve(!0),je(null)},children:e(`ok`)})]})]})]})]}),!Ee&&Object.values(n.pluginJobs??{}).some(e=>e.phase!==`done`)&&(0,X.jsxs)(`div`,{className:`active-plugin-jobs-bar`,onClick:()=>{ke(`plugins`),De(!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})()]}),(0,X.jsx)(f_,{})]})}function Cb(){typeof document<`u`&&(wb(Tb()),Db())}function wb(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function Tb(){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 Eb(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 Db(){let e=()=>{let e=document.querySelector(`.messages`);return e?(wb(Eb(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)}an(),ju(ku()),Cb(),(0,A.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(m.StrictMode,{children:(0,X.jsx)(Cn,{children:(0,X.jsx)(Sb,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=en();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,St as c,le as d,ce as f,N as g,R as h,Pu as i,Re as l,ne as m,om as n,wn as o,K as p,Ou as r,Z as s,cm as t,q as u};
|