pi-web-ui 0.94.1 → 0.95.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 +49 -1
- package/README.md +5 -6
- package/README.zh-CN.md +4 -5
- package/bin/pi-web-ui.mjs +751 -206
- package/dist/server/agent-service.js +1869 -85
- package/dist/server/approval-rules.js +550 -0
- package/dist/server/attachment-store.js +112 -0
- package/dist/server/attachments.js +62 -171
- package/dist/server/client-state.js +4 -0
- package/dist/server/compact-context-tool.js +125 -0
- package/dist/server/context-budget.js +317 -0
- package/dist/server/dangling-tools.js +162 -0
- package/dist/server/dsh/dsh-agent-service.js +50 -60
- package/dist/server/edit-soft-tool.js +70 -5
- package/dist/server/eval-tool.js +535 -0
- package/dist/server/files-service.js +35 -7
- package/dist/server/goal-service.js +240 -68
- package/dist/server/hashline-engine.js +665 -0
- package/dist/server/host-metrics.js +26 -2
- package/dist/server/index.js +157 -9
- package/dist/server/lsp-tool.js +679 -0
- package/dist/server/model-admin.js +20 -0
- package/dist/server/office-parse.js +309 -0
- package/dist/server/patch-tool.js +91 -0
- package/dist/server/plan-manager.js +104 -0
- package/dist/server/plugin-api-catalog.js +296 -0
- package/dist/server/plugin-install-spec.js +196 -0
- package/dist/server/plugin-installer.js +73 -0
- package/dist/server/plugin-manifest-validate.js +305 -0
- package/dist/server/plugin-project.js +47 -11
- package/dist/server/plugin-tool-guard.js +120 -0
- package/dist/server/plugins.js +745 -161
- package/dist/server/process-utils.js +12 -6
- package/dist/server/scheduler-tasks.js +6 -0
- package/dist/server/serialize.js +13 -3
- package/dist/server/settings-service.js +108 -1
- package/dist/server/subagents.js +41 -0
- package/dist/server/terminals.js +69 -14
- package/dist/server/tool-approval.js +84 -0
- package/dist/server/tool-manager.js +214 -6
- package/dist/server/workspace-snapshot.js +113 -0
- package/package.json +2 -2
- package/plugin-sdk/README.md +25 -0
- package/plugin-sdk/index.d.ts +31 -38
- package/plugin-sdk/index.mjs +35 -19
- package/plugins/catalog.json +20 -0
- package/themes/ayu-light.css +6 -6
- package/themes/catppuccin-latte.css +6 -6
- package/themes/claude-code-dark.css +144 -0
- package/themes/codex.css +6 -6
- package/themes/everforest-light.css +6 -6
- package/themes/geist.css +6 -6
- package/themes/gruvbox-light.css +6 -6
- package/themes/kanagawa-lotus.css +6 -6
- package/themes/rose-pine-dawn.css +6 -6
- package/themes/solarized-light.css +6 -6
- package/themes/vs-code-dark.css +146 -0
- package/web/dist/assets/{TerminalPanel-MVoxpJOA.js → TerminalPanel-DlGBF2MD.js} +1 -1
- package/web/dist/assets/index-BXnCQL9p.js +364 -0
- package/web/dist/assets/index-RpIGFyi_.css +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-B3S9MxnN.css +0 -1
- package/web/dist/assets/index-DVLrHI2E.js +0 -364
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-MVoxpJOA.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,i as o,n as s,o as c,r as l,s as u,t as d}from"./markdown-eUQn_o9D.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 f=e(t(),1),p={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},m=f.createContext&&f.createContext(p),h=[`attr`,`size`,`title`];function g(e,t){if(e==null)return{};var n,r,i=_(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 _(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 v(){return v=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},v.apply(null,arguments)}function y(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 b(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?y(Object(n),!0).forEach(function(t){x(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function x(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e){var t=C(e,`string`);return typeof t==`symbol`?t:t+``}function C(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 w(e){return e&&e.map((e,t)=>f.createElement(e.tag,b({key:t},e.attr),w(e.child)))}function T(e){return t=>f.createElement(E,v({attr:b({},e.attr)},t),w(e.child))}function E(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=g(e,h),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,v({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:b(b({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return m===void 0?t(p):f.createElement(m.Consumer,null,e=>t(e))}var D=r(),O=n();function k(e){return T({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 A(e){return T({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 j(e){return T({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 M(e){return T({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 N(e){return T({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 P(e){return T({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 F(e){return T({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`17 8 12 3 7 8`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`3`,x2:`12`,y2:`15`},child:[]}]})(e)}function I(e){return T({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 L(e){return T({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`3 6 5 6 21 6`},child:[]},{tag:`path`,attr:{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`11`,x2:`10`,y2:`17`},child:[]},{tag:`line`,attr:{x1:`14`,y1:`11`,x2:`14`,y2:`17`},child:[]}]})(e)}function R(e){return T({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 ee(e){return T({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 te(e){return T({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 ne(e){return T({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 z(e){return T({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 B(e){return T({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 V(e){return T({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 re(e){return T({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 ie(e){return T({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 H(e){return T({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 U(e){return T({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 ae(e){return T({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 oe(e){return T({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 se(e){return T({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 ce(e){return T({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 le(e){return T({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 ue(e){return T({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 de(e){return T({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 fe(e){return T({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 pe(e){return T({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 W(e){return T({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 me(e){return T({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 G(e){return T({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 he(e){return T({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 ge(e){return T({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 _e(e){return T({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 ve(e){return T({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 ye(e){return T({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 K(e){return T({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 be(e){return T({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 xe(e){return T({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 Se(e){return T({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 Ce(e){return T({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 q(e){return T({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 we(e){return T({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 Te(e){return T({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 J(e){return T({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 Ee(e){return T({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 De(e){return T({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 Y(e){return T({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 Oe(e){return T({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 ke(e){return T({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 Ae(e){return T({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 je(e){return T({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 Me(e){return T({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 Ne(e){return T({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 Pe(e){return T({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 Fe(e){return T({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 Ie(e){return T({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 Le(e){return T({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 Re(e){return T({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 ze(e){return T({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 Be(e){return T({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 Ve(e){return T({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 He(e){return T({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 Ue(e){return T({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 We(e){return T({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 Ge(e){return T({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 Ke(e){return T({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 qe(e){return T({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 Je(e){return T({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 Ye(e){return T({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 Xe(e){return T({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 Ze(e){return T({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 Qe(e){return T({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 $e(e){return T({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 et(e){return T({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 tt(e){return T({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 nt(e){return T({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 rt(e){return T({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 it(e){return e.map(e=>e.kind===`package`?`pi update npm:${e.name}`:e.kind===`git-extension`?`pi update ${at(e.source??e.name)}`:`npm i -g ${e.name}@latest`).join(`; `)}function at(e){return e.startsWith(`git:`)?e:`git:${e}`}function ot(){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 st(e,t,n={}){let{enabled:r=!0,ignore:i}=n,a=(0,f.useRef)(t);(0,f.useLayoutEffect)(()=>{a.current=t}),(0,f.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 ct=[],lt=!1;function ut(e){if(e.key===`Escape`&&ct.length!==0)for(let t=ct.length-1;t>=0;t--){let n=ct[t];if(n()!==!1){e.preventDefault(),e.stopPropagation();break}}}function dt(){!lt&&typeof document<`u`&&(document.addEventListener(`keydown`,ut,!0),lt=!0)}function ft(){lt&&ct.length===0&&typeof document<`u`&&(document.removeEventListener(`keydown`,ut,!0),lt=!1)}function pt(e){return ct.push(e),dt(),()=>{let t=ct.lastIndexOf(e);t>=0&&ct.splice(t,1),ft()}}function mt(e,t=!0){let n=(0,f.useRef)(e);(0,f.useLayoutEffect)(()=>{n.current=e}),(0,f.useEffect)(()=>{if(t)return pt(()=>n.current())},[t])}var X=i();function ht({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 gt({trigger:e,open:t,onOpenChange:n,children:r,align:i=`right`,fit:a=!1,direction:o=`down`,tip:s,menuClassName:c,menuRef:l,menuStyle:u}){let d=(0,f.useRef)(null),p=(0,f.useRef)(null),[m,h]=(0,f.useState)(0),g=e=>{p.current=e,typeof l==`function`?l(e):l&&`current`in l&&(l.current=e)},_=()=>{let e=d.current,t=p.current;if(!e||!t)return;if(window.innerWidth<=768){m!==0&&h(0);return}let n=t.getBoundingClientRect(),r=e.getBoundingClientRect();if(r.width===0&&r.height===0||n.width===0){m!==0&&h(0);return}let a=n.width,o=ht({align:i,triggerLeft:r.left,triggerRight:r.right,menuWidth:a,viewportWidth:window.innerWidth,margin:8});o!==m&&h(o)};return(0,f.useLayoutEffect)(()=>{t?_():m!==0&&h(0)}),(0,f.useEffect)(()=>{if(t)return window.addEventListener(`resize`,_),()=>window.removeEventListener(`resize`,_)},[t,m]),st(d,()=>n(!1),{enabled:t}),mt(()=>n(!1),t),(0,X.jsxs)(`div`,{className:`dropdown ${i} ${a?`fit`:``} ${o===`up`?`dd-up`:``}`,ref:d,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chip`,onClick:()=>n(!t),"aria-expanded":t,"data-tip":s,children:[e,(0,X.jsx)(Ge,{className:`dd-caret ${t?`up`:``}`})]}),t&&(0,X.jsx)(`div`,{className:`dd-menu ${c??``}`,ref:g,style:m===0?u:{...u,transform:u?.transform?`${u.transform} translateX(${m}px)`:`translateX(${m}px)`},children:r})]})}function _t({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 vt=null;function yt(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 bt(){return vt===null&&(vt=yt()),vt}function xt(e,t){return t===`/`?e:t+e.replace(/^\/+/,``)}function St(e){return xt(e,bt())}var Ct=`pi-web-ui:token`;function wt(){try{let e=new URL(window.location.href),t=e.searchParams.get(`token`);t&&(localStorage.setItem(Ct,t.trim()),e.searchParams.delete(`token`),window.history.replaceState(null,``,e.toString()))}catch{}}function Tt(){try{return localStorage.getItem(Ct)??``}catch{return``}}function Et(e){let t=Tt();return t?`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(t)}`:e}var Dt=[`zh`,`en`,`de`,`es`,`fr`,`it`,`ja`,`ko`,`pt`,`ru`];function Ot(e,t,n,r=Dt){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 kt=`pi-web-ui:lang`,At={docTitle:`pi-web-ui — pi 编码智能体`,cancel:`取消`,ok:`确定`,save:`保存`,close:`关闭`,widgetExpand:`点击放大查看完整输出`,collapsePanel:`收起面板`,expandPanel:`展开面板`,dragToResize:`拖拽调整宽度 · 双击复位`,loading:`加载中…`,connected:`已连接`,connecting:`连接中…`,reconnecting:`重连中…`,language:`语言`,langZh:`中文`,langEn:`English`,langIt:`Italiano`,langJa:`日语`,langKo:`韩语`,langFr:`法语`,langDe:`德语`,langEs:`西班牙语`,langRu:`俄语`,langPt:`葡萄牙语`,githubRepo:`GitHub 仓库(xing-shuyin/pi-web-ui)`,copy:`复制`,viewSwitch:`视图切换`,chat:`对话`,terminal:`终端`,selectModel:`选择模型`,availableModels:`可用模型`,allProviders:`全部`,providers:`服务商`,noModels:`暂无可用模型(请先配置 API 密钥)`,reasoning:`推理`,vision:`识图`,refreshModels:`刷新模型列表(保留手填,合并新增)`,manageModels:`⚙ 管理模型(新增 / 修改)`,manageModelsTitle:`管理模型`,setGlobalDefault:`☆ 设为全局默认(新项目自动使用)`,clearGlobalDefault:`★ 取消全局默认`,globalDefaultBadge:`全局默认`,thinkingLevel:`思考强度`,thinking:`思考`,thinkingChip:`思考:{level}`,sound:`声音`,theme:`主题`,themeDefault:`深色(默认)`,themeGroupClassics:`现代经典`,themeGroupBuiltin:`原始预设`,themeLight:`浅色`,themeDark:`深色`,newChat:`新对话`,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)和随机存取内存(RAM)使用率`,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 命令`,slashHelpHint:`输入 / 随时打开命令列表`,slashLoading:`命令列表加载中…(连接服务器后可用)`,slashBuiltin:`内置`,slashExtension:`扩展`,slashPrompt:`模板`,slashSkill:`技能`,slashPlugin:`插件`,slashCopied:`已复制上一条助手回复`,slashCopyFailed:`复制失败,请手动复制`,slashCopyEmpty:`还没有可复制的助手回复`,recentProjects:`最近项目`,runningConversations:`运行的对话`,elsewhereBadge:`另一处`,elsewhereTip:`在其他标签页 / 设备上打开的对话(运行中或已结束未关闭,右键可过户到本页查看)`,takeoverConversation:`过户到当前页面`,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:`输入新名称…`,renameSessionConfirm:`重命名`,dismissConversation:`从运行列表移出(历史记录保留)`,dismissConversationConfirm:`确认移出`,dismissFinishedSubagents:`关闭已结束的子代理({n} 个)`,dismissFinishedSubagentsScoped:`关闭该对话下已结束的子代理(含嵌套,{n} 个)`,dismissConversationWithSubagents:`同时关闭已结束的子代理({n} 个)?请确认其结果已不再需要,再点一次确认`,dismissConversationWithSubagentsMixed:`同时关闭已结束的子代理({n} 个)?运行中的 {m} 个不受影响、父对话暂留;请确认已结束的已不再需要,再点一次确认`,dismissStreamingConfirm:`仍在运行,确认强行关闭?(运行将被中止)`,dismissFinishedOnly:`仅关已结束({n})`,dismissForceAll:`强行全关(含子代理 {n})`,forceDismissTitle:`强行关闭本对话及全部 {n} 个子代理(运行中的 {m} 个将被中止)`,forceDismissConversation:`强行关闭对话(含全部子代理)`,persistSubagent:`固化为普通对话`,forceDismissConfirm:`确认强行关闭?未结束的运行将被中止,再点一次`,noFinishedSubagents:`没有可关闭的已结束子代理`,collapseSection:`折叠`,expandSection:`展开`,emptyChat:`空对话`,editReask:`编辑重问`,editReaskTip:`修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)`,reaskFromHere:`从此处重新提问`,editPlaceholder:`修改问题内容…`,editHint:`⌘/Ctrl+Enter 提交 · Esc 取消`,editAttachmentHint:`原附件已保留,可粘贴/拖入新图片或文件 · ⌘/Ctrl+Enter 提交 · Esc 取消`,expandMsg:`展开`,collapseMsg:`收起`,toolCalls:`工具调用`,bashRuns:`终端运行`,images:`图片`,update:`更新`,updateTip:`检查并更新 pi-web-ui`,currentVersion:`当前版本`,latestVersion:`最新版本`,checkingUpdate:`检查中…`,checkUpdate:`检查更新`,upToDate:`已是最新版本`,updateAvailable:`发现新版本 v{version}`,updateJustPublished:`v{version} 刚刚发布,npm 缓存可能尚未同步——若未检测到新版本,请稍后重新检查`,updateNow:`在终端中更新`,updateTabTitle:`更新 pi-web-ui`,updateTerminalHint:`点击后会在可见终端中运行 npm i -g pi-web-ui@latest;完成后重启服务生效(pi-web-ui server restart)。`,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 组件`,updatesAllRefresh:`重新检查全部`,updateCheckFailed:`检查失败`,updateBtn:`更新`,updateAllBtn:`全部更新`,updatePkgTabTitle:`更新 {name}`,updateAllTabTitle:`更新全部组件`,restartService:`重启服务`,restartingService:`重启中…`,restartServiceTip:`重启 pi-web-ui 服务({name}):本实例由系统服务托管(launchd/systemd/Windows watchdog),进程退出后会被自动拉起,本页会自动重连;更新完成后用它生效`,computer:`此电脑`,rootDir:`根目录`,homeDir:`用户目录`,desktopDir:`桌面`,filesHelp:`浏览:点文件夹进入、点文件预览,「..」返回上级;「根目录」回当前项目根,「此电脑」浏览全盘换盘符,「🏠」直达用户目录,「🖥️」直达桌面。
|
|
3
|
-
文件操作:右键可新建文件/文件夹、重命名、复制/剪切/粘贴、创建副本、删除、上传文件;文件可下载,行尾按钮可复制名称/路径。
|
|
4
|
-
切换项目:文件夹右键「以项目打开」,或点右下角 📁 路径按钮输入/选择目录。
|
|
5
|
-
发给 AI:行尾按钮附加内容或仅引用路径,也可把文件拖进输入框。`,workspaceRoots:`工作区根`,workspaceRootsHint:`文件树可切换到这些根;插件读写这些目录不必再单独授权。`,addWorkspaceRoot:`添加为工作区根`,addWorkspaceRootHint:`把当前目录加成工作区根(右栏文件树可切换浏览;插件读写该目录不再单独授权)`,removeWorkspaceRoot:`移除工作区根`,noFiles:`暂无文件`,filesTruncated:`目录过大,列表已截断,仅显示前 2000 项`,linkFolderTip:`链接文件夹路径到对话`,attachInlineTip:`附加内容到对话`,referenceTip:`仅引用路径(AI 按需读取)`,previewFile:`预览`,downloadFile:`下载文件`,copyName:`复制名称`,copyPath:`复制路径`,downloadFailed:`下载失败:{error}`,fileNotFoundShort:`文件不存在`,pluginMountFailed:`插件 {name} 挂载失败`,pluginViewLoading:`插件视图加载中…`,pluginViewLoadFailed:`插件视图加载失败`,pluginViewLoadFailedHint:`按 F12 打开 console 查看 plugin 开头的报错,或检查服务端日志;也可以在设置 → 插件里重装该插件。`,pluginViewRetry:`重试加载`,liveOutputOmitted:`…[前 {n} 字符已省略]…
|
|
6
|
-
`,uploadToFolder:`上传文件到此文件夹`,fileCompress:`压缩`,fileExtract:`解压`,fileCompressDownload:`压缩并下载`,fileUploadFolder:`上传文件夹`,fileChooseFolder:`选择文件夹`,fileExtractDestination:`解压到(已有目录,留空为工作区)`,fileConflictPolicy:`遇到已有文件`,fileConflictSkip:`跳过(默认)`,fileConflictOverwrite:`覆盖文件(不替换目录)`,fileConflictError:`停止,不写入任何文件`,fileArchiveLimits:`ZIP / TAR / TAR.GZ / TGZ / GZ;最多 20,000 项、解压后 1 GiB。不接受链接或特殊文件。`,fileFolderUploadHint:`保留所选文件夹名称和层级,逐个上传(单文件最多 32 MiB)。已有文件不会被覆盖,失败时已上传的文件会保留。支持 File System Access 的浏览器还会上传空目录,其他浏览器仅上传文件及其父目录。`,fileTransferBusy:`正在处理,请勿关闭…`,fileTransferFailed:`操作未完成:{error}`,uploadToCurrentDir:`上传文件到当前目录`,openAsProject:`以项目打开`,fileOpenPreview:`打开预览`,fileEnterDir:`进入目录`,fileReveal:`在资源管理器中显示`,fileOpenDefault:`用默认应用打开`,fileNewFile:`新建文件`,fileNewDir:`新建文件夹`,fileRename:`重命名`,fileNamePlaceholder:`文件名`,fileDuplicate:`创建副本`,fileCut:`剪切`,fileCopyEntry:`复制`,filePaste:`粘贴`,fileDelete:`删除`,fileDeleteConfirm:`确认删除 {name}?`,fileCopyRelPath:`复制相对路径`,fileRefresh:`刷新列表`,protocolMismatch:`页面版本与服务器不一致(应用刚更新过),请刷新页面以恢复全部功能。`,selectLinesHint:`点击选择行;拖拽或 Shift+点击选择范围`,enableWrap:`开启自动换行`,disableWrap:`关闭自动换行`,selectedRange:`已选 {n} 行(第 {start}-{end} 行)`,fileLines:`{n} 行`,selectAll:`全选`,clearSelection:`清除`,addToChat:`添加到对话`,addedToChat:`已添加`,previewTruncated:`⚠ 文件过大,仅预览前 512KB`,previewLinesTruncated:`… 文件行数过多,仅显示前 {n} 行`,binaryFile:`🔣 二进制文件,已显示前 4KB 十六进制`,binaryHexTruncated:`(文件更大,可下载完整文件)`,previewNotSupported:`该类型文件不支持预览(仅图片 / 视频 / 文本)`,emptyFile:`(空文件)`,editFile:`编辑文件`,exitEditFile:`退出编辑`,saveFile:`保存文件`,discardFileChanges:`放弃未保存的修改?`,fileSaved:`已保存`,fileEditTruncated:`文件过大,预览不完整,无法编辑`,showMarkdownSource:`显示 Markdown 原文`,showMarkdownPreview:`显示 Markdown 预览`,showHtmlSource:`显示 HTML 源码`,showHtmlPreview:`显示 HTML 预览`,htmlJsOff:`🛡 脚本已禁用(静态预览)`,htmlJsOffTip:`当前是纯静态渲染:页面里的 JavaScript 不会执行。只对你信任的文件开启脚本。`,htmlJsOn:`⚠ 脚本已启用`,htmlJsOnTip:`页面里的 JavaScript 正在运行。它仍碰不到本应用(无同源、无表单、无顶层跳转),但可能产生网络请求或挖矿等行为,仅用于你信任的文件。`,htmlEnableJs:`启用脚本`,htmlDisableJs:`禁用脚本`,fullscreen:`全屏`,exitFullscreen:`退出全屏`,zoomIn:`放大字号`,zoomOut:`缩小字号`,resetZoom:`重置缩放`,pluginRequest:`插件请求`,modelQuestion:`模型提问`,modelQuestionCustom:`补充回答(可选)`,modelQuestionSubmit:`提交回答`,next:`下一步`,previous:`上一步`,questionStep:`第 {cur} / {total} 题`,optionPreview:`选项预览`,noOptions:`(无选项)`,inputPlaceholder:`输入内容`,questionTimeout:`⏳ 剩余 {s} 秒,超时将自动取消`,questionTimeoutExpired:`提问已超时,正在恢复对话…`,modelNoVision:`当前模型 {name} 不支持图片,请切换到 DeepSeek V4 Flash Vision (exp)`,dshSkillsNote:`DSH 引擎使用运行时内置技能(dsh-skill),暂不支持在设置面板启停`,dshExtensionsNote:`DSH 引擎无 pi 扩展体系,能力由运行时内置(MCP/subagent/goal/plan/skill 等)`,dshReviewPromptNote:`DSH 无独立审查会话:此指令将随目标轮次附加到系统提示词,供模型在目标轮次中遵守`,dshVisionHiddenNote:`DSH 引擎直接支持图片输入(仅 DeepSeek V4 Flash Vision (exp) 模型),无需视觉桥转写`,dshNoReviewModel:`DSH 无独立审查模型:目标由模型自判定完成/受阻,轮次上限即自动迭代次数`,soundHeader:`声音提示`,enableSound:`启用声音`,preview:`试听`,volume:`音量`,notifyHeader:`桌面通知`,notifyEnable:`启用桌面通知(PWA)`,notifyEnableDesc:`会话完成或需要你输入时提醒你(需授权;仅当页面不在你眼前时触发:切到其他应用、最小化窗口或后台标签页;Windows 上窗口最小化后系统给的状态信号是错的,因此 2 分钟没操作页面也照常提醒——宁可多提醒一次也不静默)。`,notifyDenied:`通知权限已被拒绝 —— 请在浏览器站点设置里为本站点开启通知(Windows 还要在「设置 → 系统 → 通知」里允许浏览器/应用,并关闭专注助手)。`,notifyUnsupported:`此浏览器不支持通知。`,notifyInsecure:`当前地址不是安全上下文(非 localhost 的 http 访问),浏览器不提供通知接口 —— 请改用 127.0.0.1 或 HTTPS 打开,或将本机地址加入浏览器白名单。`,notifyWindowsHint:`Windows 额外一层系统开关:请允许浏览器(或已安装的 pi-web-ui 应用)在「设置 → 系统 → 通知」里推送,并关闭专注助手/勿扰;关窗后进程结束也不会再提醒。`,notifyTest:`发送测试通知`,notifyTestBody:`能看到这条系统通知,就说明浏览器和 Windows 都放行了。`,notifyTestSent:`已发送(通道:{path})`,notifyTestFailed:`发送失败:{error}`,notifyTestState:`系统状态:焦点 {focus} · 可见性 {visibility} · 最小化 {minimized} · 空闲 {idle}s`,notifyTestHeld:`浏览器已受理(通知中心里现有 {count} 条):屏幕上没弹横幅的话,是 Windows/Edge 的横幅开关或静默设置把它压住了。`,notifyTestDropped:`浏览器没有保留这条通知 → Edge 自己把它丢了(站点通知被静默/阻止,或被系统策略丢弃)。`,notifyTestGateSuppressed:`当前判定:会被吞掉(系统认为你正看着这个页面)。`,notifyTestGateOpen:`当前判定:会正常提醒(系统认为你没在看)。`,notifyDoneTitle:`任务完成`,notifyDoneBody:`会话已完成,等待你的输入。`,notifyQuestionTitle:`需要你回答`,notifyQuestionBody:`pi 正在等你回答一个问题。`,notifyErrorTitle:`出错了`,notifyErrorBody:`一个会话报告了错误。`,"sound.question":`问卷弹出`,"sound.question.desc":`ask_user_question 出现时`,"sound.done":`回复结束`,"sound.done.desc":`智能体完成一轮回答时`,"sound.start":`回复开始`,"sound.start.desc":`智能体开始新一轮时`,"sound.error":`出错`,"sound.error.desc":`出现错误提示时`,setupTitle:`未检测到 pi agent 配置`,setupDesc:`pi-web-ui 需要 pi 的配置目录(~/.pi/agent)和至少一个 API 密钥才能运行智能体。pi 内置了 openai、anthropic、deepseek 等服务商——选一个填密钥即可,全程无需打开终端。`,installFailed:`✖ pi agent 安装失败:`,retryInstall:`重试安装`,skip:`跳过`,installDone:`✅ pi agent CLI 已安装。选择服务商并填入 API 密钥即可开始对话:`,cliReadyHint:`✅ 本地已检测到 pi agent,选择服务商并填入 API 密钥即可开始对话:`,provider:`服务商`,configured:`已配置`,providerKeyReady:`该服务商已配置密钥,可直接使用或更换新密钥。`,apiKey:`API 密钥`,saving:`保存中…`,saveAndStart:`保存并开始使用`,recheck:`重新检测`,installing:`正在安装 pi agent CLI…`,autoInstall:`自动安装 pi agent`,attachment:`附件`,plugin:`插件`,unknown:`未知`,thinkingWait:`正在思考`,exitCode:`退出码 {code}`,cancelled:`已取消`,truncated:`… 内容过长,当前视图已截断`,outputTruncated:`… 输出过长,当前视图已截断`,refOnlyShort:`仅引用`,folderRefShort:`文件夹 · 仅引用`,inlineLines:`内联 · {n} 行`,inlineLinesRange:`行 {start}-{end}`,image:`🖼 图片`,bridgedVision:`👁 已转写`,bridgedVisionDetail:`图片已由视觉桥转写(当前模型不支持识图)`,folderNotExpanded:`文件夹,未展开内容 —— 智能体会按需浏览目录`,fileNotExpanded:`文件较大({size}),未展开内容 —— 智能体会按需读取`,"role.user":`你`,"role.assistant":`pi`,"role.tool":`工具`,"role.bash":`终端`,"role.branch":`分支摘要`,"role.compaction":`上下文已压缩`,directory:`目录`,waitingResponse:`正在等待模型响应…`,retryingApi:`大模型 API 出错,正在自动重试({attempt}/{max}):{error}`,retryingApiSoon:`大模型 API 出错,正在自动重试:{error}`,modelRetryAttempts:`模型报错自动重试次数`,modelRetryHint:`大模型 API 调用出错时自动重试的次数。次数用完后本轮停止并标红,可点「重试」手动再试;设为 0 则失败即停。修改即时生效,无需重载。`,softCapTokens:`压缩阈值(tokens)`,softCapHint:`会话上下文达到此 tokens 数即自动触发压缩,而不是堆到模型物理上限。防阶梯计费翻倍(如 Grok 超 200K 涨价)与长上下文降智。支持输入 300k、1M、300000;空 = 关闭。按模型覆盖优先于全局。修改即时生效,无需重载。`,softCapOff:`关闭(堆到上限才压,支持 300k / 1M 等)`,softCapByModel:`按模型覆盖`,softCapByModelHint:`针对特定模型(provider/id,如 xai/grok-4)单独设阈值,优先于上面的全局值。`,softCapModelId:`模型 provider/id`,softCapAdd:`添加`,softCapRemove:`删除`,softCapMarker:`压缩阈值`,retryNow:`重试`,retryLastTip:`手动重试上次失败的模型请求`,compactingContext:`正在压缩上下文,摘要生成中…`,compactingReasonManual:`手动触发`,compactingReasonThreshold:`上下文达到阈值,自动触发`,compactingReasonOverflow:`上下文溢出,自动触发`,compactionFrom:`从 {tokens} tokens 压缩`,compactionKeptHint:`此前历史已折叠为该摘要,上下文中仅保留最近消息`,backToBottom:`回到底部`,questionNavTitle:`问题列表`,searchPlaceholder:`在对话中搜索…`,searchNoResults:`无结果`,searchModels:`搜索模型…`,noModelMatches:`无匹配模型`,modelUsedCount:`已用 {n} 次`,searchGlobal:`搜索`,searchGlobalTip:`全局搜索:对话 / 项目 / 文件(Ctrl+K)`,gsPlaceholder:`搜索项目、历史对话、工作区文件…`,gsHint:`输入关键词:搜索历史对话全文(含 AI 回复)、最近项目与当前项目的文件名`,gsSessions:`对话`,gsProjects:`项目`,gsFiles:`文件`,gsNoResults:`无匹配结果`,gsSearching:`正在搜索…`,gsTruncated:`匹配过多,仅显示部分结果`,gsCurrentProject:`当前`,gsOpenPreview:`打开文件预览`,gsNavigate:`选择`,gsOpen:`打开`,gsCloseHint:`关闭`,bgTaskCommand:`命令行`,searchPrev:`上一个(Shift+Enter)`,searchNext:`下一个(Enter)`,searchClose:`关闭(Esc)`,questionNavTip:`本对话的全部问题,悬浮展开,点击跳转`,"tpl.title":`提示词模板`,"tpl.hint":`点击卡片直接填入输入框,✏️ 可编辑或删除 · 也能新增自己的模板`,"tpl.clickCard":`点击填入输入框`,"tpl.editTpl":`编辑 / 删除模板`,"tpl.openPicker":`提示词模板(常用提示词,随时取用)`,"tpl.pickerTitle":`提示词模板`,"tpl.pickerHint":`点击卡片直接填入输入框,✏️ 可编辑或删除 · 也能新增自己的模板`,"tpl.add":`新建模板`,"tpl.addDesc":`把常用工作流存成模板`,"tpl.reset":`恢复默认模板`,"tpl.resetConfirm":`确认恢复默认?`,"tpl.builtin":`内置`,"tpl.custom":`自定义`,"tpl.newTitle":`新建提示词模板`,"tpl.editTitle":`编辑提示词模板`,"tpl.fieldIcon":`图标`,"tpl.fieldTitle":`标题`,"tpl.fieldTitlePh":`卡片上显示的短标题`,"tpl.fieldDesc":`说明`,"tpl.fieldDescPh":`一句话说明,显示在卡片上`,"tpl.fieldPrompt":`提示词`,"tpl.fieldPromptPh":`完整提示词 —— 发送给智能体的内容`,"tpl.required":`标题和提示词不能为空`,"tpl.save":`保存修改`,"tpl.fill":`填入输入框`,"tpl.fillTip":`填入输入框,可再编辑后发送`,"tpl.sendNow":`直接发送`,"tpl.sendTip":`立即作为新对话发送`,"tpl.delete":`删除`,"tpl.deleteTip":`删除这个自定义模板`,"tpl.remove":`移出模板库`,"tpl.removeTip":`把内置模板移出模板库,可在底部「恢复默认模板」找回`,"tpl.restore":`恢复默认`,"tpl.restoreTip":`撤掉你的修改,恢复内置默认`,"tpl.sk.setup":`仓库初始化`,"tpl.sk.setup.desc":`让仓库了解它的构建与约定`,"tpl.sk.setup.prompt":`请先扫描这个仓库,建立「其他工作流都能用」的基础上下文,输出一份简明报告:
|
|
7
|
-
|
|
8
|
-
1. 项目类型、技术栈与目录结构
|
|
9
|
-
2. 构建 / 测试 / 运行 / 格式化的具体命令
|
|
10
|
-
3. 代码约定与命名规范
|
|
11
|
-
4. 任务 / issue 的存放位置与格式
|
|
12
|
-
5. 目前已知的坑或遗留问题
|
|
13
|
-
|
|
14
|
-
先只报告,不修改任何文件。`,"tpl.sk.ask":`技能导航`,"tpl.sk.ask.desc":`告诉我该用哪个流程`,"tpl.sk.ask.prompt":`我先描述当前要解决的情况,你先判断最适合的工作流(需求澄清 / 拆解计划 / 测试驱动 / 排错 / 架构 / 审查 / 交接等),说明为什么推荐它、会怎么做,等我确认后按它执行。`,"tpl.sk.grilldocs":`需求拷问·落档`,"tpl.sk.grilldocs.desc":`边盘问需求边记录决策`,"tpl.sk.grilldocs.prompt":`动手前,请用拷问的方式向我盘问这个计划(一次一个问题),直到达成共识。同时把过程中的关键术语和已定决策记录下来(例如写入 CONTEXT.md 或 ADR 文件),让后续所有工作都基于同一套「共享语言」。每个问题先给出你的推荐答案。`,"tpl.sk.tospec":`转规格说明`,"tpl.sk.tospec.desc":`把讨论结果整理成规格书`,"tpl.sk.tospec.prompt":`请把我们在对话中已经达成的共识,整理成一份结构化的规格说明书:
|
|
15
|
-
|
|
16
|
-
1. 背景与目标
|
|
17
|
-
2. 明确的目标与非目标
|
|
18
|
-
3. 用户与使用场景
|
|
19
|
-
4. 边界条件与失败场景
|
|
20
|
-
5. 验收标准(怎样算完成)
|
|
21
|
-
6. 接口 / 数据结构概要
|
|
22
|
-
|
|
23
|
-
先输出规格让我评审,确认后再继续。`,"tpl.sk.totickets":`拆工单`,"tpl.sk.totickets.desc":`把规格拆成可构建的小任务`,"tpl.sk.totickets.prompt":`请把这份规格说明拆成一组小工单,供逐个构建:
|
|
24
|
-
|
|
25
|
-
1. 每个工单足够小、可独立验收
|
|
26
|
-
2. 标注依赖顺序(哪些必须先做)
|
|
27
|
-
3. 每个工单含:做什么、验收标准、涉及文件
|
|
28
|
-
4. 识别出可并行的工单
|
|
29
|
-
|
|
30
|
-
先输出工单列表,我确认顺序后再执行。`,"tpl.sk.implement":`规格落地`,"tpl.sk.implement.desc":`按规格测试优先实现`,"tpl.sk.implement.prompt":`请按这份规格说明实现,测试优先:
|
|
31
|
-
|
|
32
|
-
1. 先为每个工单写会失败的测试(覆盖正常、边界、错误分支)
|
|
33
|
-
2. 用最小实现让测试通过
|
|
34
|
-
3. 重构并保持测试通过
|
|
35
|
-
4. 逐工单推进,每完成一个简要汇报
|
|
36
|
-
|
|
37
|
-
最后对照验收标准逐条确认。`,"tpl.sk.codeview":`代码审查`,"tpl.sk.codeview.desc":`对照规格与标准审查 diff`,"tpl.sk.codeview.prompt":`请审查最近改动的 diff:
|
|
38
|
-
|
|
39
|
-
1. 对照规格说明,实现是否完全覆盖、有无偏差
|
|
40
|
-
2. 正确性:边界、空值、并发与时序
|
|
41
|
-
3. 安全:输入校验、注入、敏感信息
|
|
42
|
-
4. 性能与可读性:是否遵循项目约定
|
|
43
|
-
5. 测试:关键路径是否有覆盖
|
|
44
|
-
|
|
45
|
-
按严重程度分级列出问题,每条给出具体修改建议。`,"tpl.sk.wayfinder":`大任务地图`,"tpl.sk.wayfinder.desc":`把大工程画成决策地图`,"tpl.sk.wayfinder.prompt":`这是一个大型任务。请先把它画成一张「决策地图」:
|
|
46
|
-
|
|
47
|
-
1. 拆出所有需要做出的决策点及其依赖关系
|
|
48
|
-
2. 为每个决策点列出选项、权衡与你的推荐
|
|
49
|
-
3. 标注哪些可以并行推进、哪些必须串行
|
|
50
|
-
4. 输出一份路径规划,我逐项确认后再动手。`,"tpl.sk.prototype":`快速原型`,"tpl.sk.prototype.desc":`用一次性代码验证设计假设`,"tpl.sk.prototype.prompt":`请针对这个设计问题写一个最小原型来验证假设:
|
|
51
|
-
|
|
52
|
-
1. 只验证关键假设,不做完整实现
|
|
53
|
-
2. 用最简单的方式(可硬编码、可牺牲边界情况)
|
|
54
|
-
3. 运行并告诉我结论:假设成立吗?有哪些权衡?
|
|
55
|
-
4. 验证完的原型可以删除,或等确认后再正式实现。`,"tpl.sk.research":`有据调研`,"tpl.sk.research.desc":`读一手来源给出带引用的答案`,"tpl.sk.research.prompt":`请调研这个问题,优先读一手来源(官方文档 / 源码 / 规范):
|
|
56
|
-
|
|
57
|
-
1. 给出带来源链接的答案
|
|
58
|
-
2. 明确区分:事实、合理推断、仍不确定
|
|
59
|
-
3. 列出主要选项及其权衡
|
|
60
|
-
4. 避免用二手内容拼凑,找不到就直接说没找到。`,"tpl.sk.arch":`架构体检`,"tpl.sk.arch.desc":`找出值得重构的模块(报告)`,"tpl.sk.arch.prompt":`对整个代码库做一次架构体检:
|
|
61
|
-
|
|
62
|
-
1. 找出「深模块被破坏」的迹象:过长的函数与类、明显的重复、命名混乱、隐藏的耦合
|
|
63
|
-
2. 按严重程度与影响范围分级,输出一份可视化改进报告
|
|
64
|
-
3. 对每一项给出最小可行的重构方案与理由
|
|
65
|
-
4. 先报告再动手,重构前确认范围。`,"tpl.sk.debug":`系统化排错`,"tpl.sk.debug.desc":`从可复现的失败开始诊断`,"tpl.sk.debug.prompt":`请系统化诊断这个 bug:
|
|
66
|
-
|
|
67
|
-
1. 先复现,给出可复现的步骤或输入(没有就先造最小复现)
|
|
68
|
-
2. 二分或排除法缩小范围到具体模块
|
|
69
|
-
3. 提出假设,用日志 / 断言 / 最小样例验证,不凭感觉改
|
|
70
|
-
4. 定位根因后解释,再做最小修复
|
|
71
|
-
5. 补回归测试防止复发。`,"tpl.sk.merge":`解决合并冲突`,"tpl.sk.merge.desc":`逐个 hunk 完成合并/变基`,"tpl.sk.merge.prompt":`请帮我解决这个合并 / 变基冲突:
|
|
72
|
-
|
|
73
|
-
1. 逐个冲突 hunk 处理,先读懂双方各自的意图
|
|
74
|
-
2. 选择或合并出保留正确语义的代码,不盲目取一边
|
|
75
|
-
3. 处理完运行测试与构建确认没问题
|
|
76
|
-
4. 最后总结每处冲突的取舍原因。`,"tpl.sk.triage":`工单分流`,"tpl.sk.triage.desc":`把原始 issue 整理成可领取的工作`,"tpl.sk.triage.prompt":`请把这些原始 issue / 反馈整理成可执行的工作项:
|
|
77
|
-
|
|
78
|
-
1. 去重、合并相关的条目
|
|
79
|
-
2. 分类(bug / 功能 / 改进 / 问题)
|
|
80
|
-
3. 按影响与紧急度标优先级
|
|
81
|
-
4. 每个工作项补上:复现信息或期望、验收标准
|
|
82
|
-
|
|
83
|
-
输出整理后的清单。`,"tpl.sk.wizard":`设置向导`,"tpl.sk.wizard.desc":`生成引导人类完成设置的脚本`,"tpl.sk.wizard.prompt":`请为一个需要手动操作的设置流程生成一个引导向导(脚本或文档):
|
|
84
|
-
|
|
85
|
-
1. 一步步引导,每步说明为什么
|
|
86
|
-
2. 每步带校验,输错给出可操作的提示
|
|
87
|
-
3. 支持撤销 / 回退到上一步
|
|
88
|
-
4. 结束时做一次自检并给出验证方法。`,"tpl.sk.grillme":`需求拷问`,"tpl.sk.grillme.desc":`动手前盘问对齐想法`,"tpl.sk.grillme.prompt":`开始之前,请不遗余力地盘问我这个想法的每一个方面,直到我们达成共识(一次只问一个问题,每个问题先给推荐答案):
|
|
89
|
-
|
|
90
|
-
1. 目标与非目标
|
|
91
|
-
2. 用户与场景
|
|
92
|
-
3. 边界与失败模式
|
|
93
|
-
4. 约束与依赖
|
|
94
|
-
5. 验收标准
|
|
95
|
-
|
|
96
|
-
达成共识后再给实现计划,等确认再写代码。`,"tpl.sk.handoff":`交接`,"tpl.sk.handoff.desc":`把长会话写成交接文档`,"tpl.sk.handoff.prompt":`请把当前会话整理成一份交接文档,让另一个 agent / 同事能无缝继续:
|
|
97
|
-
|
|
98
|
-
1. 背景与目标
|
|
99
|
-
2. 已完成的工作与关键决策(附原因)
|
|
100
|
-
3. 未完成项与下一步
|
|
101
|
-
4. 已知风险与待确认问题
|
|
102
|
-
5. 如何验证当前状态(命令等)
|
|
103
|
-
|
|
104
|
-
输出为结构化文档。`,"tpl.sk.questionnaire":`转问卷`,"tpl.sk.questionnaire.desc":`把开放问题变成可填问卷`,"tpl.sk.questionnaire.prompt":`请把需要别人提供的信息整理成一份可填写的问卷:
|
|
105
|
-
|
|
106
|
-
1. 每个问题说明背景和用途
|
|
107
|
-
2. 标注必填 / 选填
|
|
108
|
-
3. 给出示例答案降低理解成本
|
|
109
|
-
4. 分组排序,先简单后复杂
|
|
110
|
-
|
|
111
|
-
输出一份文档,对方可以照着填。`,"tpl.sk.teach":`持续学习`,"tpl.sk.teach.desc":`跨多次会话循序渐进学习`,"tpl.sk.teach.prompt":`请按循序渐进的方式教我:
|
|
112
|
-
|
|
113
|
-
1. 先定学习路径和目标
|
|
114
|
-
2. 一次只讲一小节,讲完给个小练习
|
|
115
|
-
3. 基于上一节的内容递进,主动提问确认理解
|
|
116
|
-
4. 每节结束总结要点
|
|
117
|
-
|
|
118
|
-
适合跨多次会话推进。`,"tpl.sk.ww":`说人话`,"tpl.sk.ww.desc":`用大白话重讲刚才的解释`,"tpl.sk.ww.prompt":`请把刚才的解释用最简单的语言重新讲一遍:
|
|
119
|
-
|
|
120
|
-
1. 避免术语,必须用时先给一句话定义
|
|
121
|
-
2. 用类比或具体例子说明
|
|
122
|
-
3. 明确指出哪部分仍是猜测 / 不确定
|
|
123
|
-
4. 用最短的话说完核心意思。`,"tpl.sk.wfa":`写给 agent 的文档`,"tpl.sk.wfa.desc":`按 agent 易读的原则写文档`,"tpl.sk.wfa.prompt":`请按「写给 agent 阅读」的原则写这份文档 / 说明:
|
|
124
|
-
|
|
125
|
-
1. 目标与使用场景写在最前
|
|
126
|
-
2. 指令具体、可验证,避免歧义和空话
|
|
127
|
-
3. 给正反例帮助理解
|
|
128
|
-
4. 结构化:标题、步骤、清单
|
|
129
|
-
5. 标注哪些是硬性要求、哪些是可选。`,"tpl.sk.codesign":`深模块设计`,"tpl.sk.codesign.desc":`用深模块原则审查与设计`,"tpl.sk.codesign.prompt":`请用「深模块」设计原则审查 / 设计:
|
|
130
|
-
|
|
131
|
-
1. 识别模块对外暴露的接口是否比内部实现更简单
|
|
132
|
-
2. 找出把复杂度泄漏到外部的模块
|
|
133
|
-
3. 给出每个模块的职责边界与改进方案
|
|
134
|
-
4. 平衡内聚与复用,避免过度抽象
|
|
135
|
-
|
|
136
|
-
输出审查结论与重构建议。`,"tpl.sk.domain":`领域建模`,"tpl.sk.domain.desc":`打磨项目用词并写下来`,"tpl.sk.domain.prompt":`请帮我梳理这个项目的领域语言:
|
|
137
|
-
|
|
138
|
-
1. 找出核心术语及当前叫法
|
|
139
|
-
2. 识别同词异义 / 异词同义造成的混乱
|
|
140
|
-
3. 统一推荐用词,写进术语表
|
|
141
|
-
4. 说明每个术语的边界(不是什么)
|
|
142
|
-
|
|
143
|
-
输出一份领域术语表。`,"tpl.sk.grilling":`拷问流程`,"tpl.sk.grilling.desc":`用拷问压测一个计划`,"tpl.sk.grilling.prompt":`请对下面这个计划做压力测试(拷问):
|
|
144
|
-
|
|
145
|
-
1. 逐项检查假设:如果它是错的会怎样?
|
|
146
|
-
2. 找漏洞:边界、失败模式、依赖、时序
|
|
147
|
-
3. 质疑决策:为什么这样?有没有更简单的路?
|
|
148
|
-
4. 每次只提出一个最尖锐的问题,等我回答
|
|
149
|
-
|
|
150
|
-
直到这个计划经得起推敲。`,"tpl.sk.tdd":`测试驱动`,"tpl.sk.tdd.desc":`红-绿-重构的规则`,"tpl.sk.tdd.prompt":`请用 TDD(红-绿-重构)完成:
|
|
151
|
-
|
|
152
|
-
1. 先写会失败的测试,覆盖正常路径、边界与错误分支
|
|
153
|
-
2. 用最小实现让测试通过
|
|
154
|
-
3. 重构并保持测试通过
|
|
155
|
-
|
|
156
|
-
避免三种反模式:与实现耦合的测试、空洞断言(永远为真)、横向切片(只测表面)。每步汇报并运行测试。`,error:`出错`,done:`完成`,running:`执行中…`,toolQueued:`排队中`,copyArgs:`复制参数`,copyMessage:`复制消息`,copied:`已复制`,copyText:`复制纯文本`,copyMarkdown:`复制 Markdown`,copyImage:`复制为图片`,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:`未跟踪文件:需先用 + 暂存,或使用“全部提交”才会包含`,scmQueryFailed:`Git 查询失败:{error}`,scmQueryFailedShort:`查询失败`,pluginCommandFallback:`插件命令`,scmTooManyFailures:`Git 查询连续失败,请点击刷新重试`,scmRunsInTerminal:`提交 / 切换分支 / 推送 / 拉取在终端中执行`,scmViewTerminal:`去终端`,editProvider:`编辑服务商`,builtinProviders:`内置服务商`,hintKeyOnly:`只需填入 API 密钥`,providerAuthHint:`选择服务商支持的登录方式`,oauthLogin:`使用 {name} 登录`,oauthLogout:`退出登录`,oauthConnected:`已通过 {name} 登录`,oauthDeviceCode:`设备验证码`,oauthOpenVerification:`打开验证页面`,oauthContinue:`继续`,configuredBadge:`✓ 已配置`,keyReady:`密钥已就绪`,replaceKey:`更换密钥`,replaceKeyTitle:`替换已保存的密钥`,clearKey:`清空`,clearKeyTitle:`清除该服务商保存在 auth.json 的密钥,回到未配置状态(环境变量来源的无法在此清除)`,clearKeyConfirm:`清空 {id} 已保存的密钥?其模型将从列表消失,直到重新配置。`,cloneProvider:`添加密钥`,cloning:`添加中`,cloneProviderTitle:`为该供应商添加第二把密钥(自动复制 baseUrl 与模型列表,可改名后保存)`,pasteKey:`粘贴 API 密钥…`,savingKey:`保存中`,saveKey:`保存密钥`,addKey:`添加密钥`,addKeyPlaceholder:`粘贴密钥值…`,keyNamePh:`名称(可留空,如 备用)`,providerIdPlaceholder:`供应商 ID`,baseUrlExamplePh:`baseUrl 链接,如 https://api.opencode.ai/zen/v1 或 http://127.0.0.1:4096`,saveAllBatch:`一键保存全部({n})`,netDisconnected:`网络连接已断开,请重连后重试`,advancedEdit:`高级编辑`,batchCreateProviders:`批量创建供应商({n}个接口)`,secondKeyTitle:`为 {api} · {baseUrl} · {n} 个模型添加第二把密钥,只需指定新供应商名字和密钥即可。`,noBaseUrlShort:`(无 baseUrl)`,providerNameLabel:`供应商名字`,providerNameHint:`(新 ID,如 opencode-2)`,apiKeyLabel:`API 密钥`,secondKeyPlaceholder:`sk-… 第二把 key`,batchDesc:`该供应商含多种接口({apis}),已按接口拆分为 {n} 个自定义供应商,分别保存后才能让所有模型(如 muse-spark)都可用。统一填入第二把 API 密钥后一键保存。`,batchKeyLabel:`统一 API 密钥(将应用到全部 {n} 个供应商)`,modelsCountShort:`{n} 个模型:`,noKeyYet:`尚无密钥,添加一把即可用`,activateKey:`设为当前`,removeKey:`移除`,removeKeyConfirm:`确定移除该密钥?移除后需重新配置才能使用。`,customProviders:`自定义服务商`,customDesc:`用于 Ollama / vLLM / 兼容 OpenAI 的代理等,写入 pi 的 models.json,保存后热重载、立即生效。`,noCustomProviders:`还没有自定义服务商`,reloadModelsConfig:`重新加载配置`,reloadModelsHint:`直接改过 models.json(手工或脚本)?点下面的「重新加载配置」从磁盘重读,无需重启服务。`,refreshBuiltinCatalog:`强制刷新官方目录`,refreshBuiltinHint:`内置供应商(opencode 等)的模型来自 pi 官方目录,本地缓存 4 小时。官方已上新但下拉里没有时,点这里绕过缓存直拉最新(约半分钟)。`,refreshBuiltinBusy:`正在拉取官方目录…`,refreshBuiltinOk:`官方目录已更新,模型下拉已刷新`,refreshBuiltinFail:`强制刷新失败,稍后重试`,appendModel:`加模型`,appendModelTitle:`官方目录还没有的新模型(如刚发布的 Union 模型),先手工加到该供应商下即刻可用;官方收录后强制刷新时会自动转用官方配置`,appendModelIdPh:`模型 ID,如 union-alpha-free`,appendModelNamePh:`显示名(可选)`,appendModelAdd:`添加`,appendModelBusy:`添加中…`,appendModelCancel:`取消`,appendModelOk:`已添加,模型下拉已更新`,appendModelFail:`添加失败`,appendModelApiTitle:`接口类型:留空则从同供应商现有模型自动继承`,appendModelApiAuto:`接口:自动继承`,appendModelBaseUrlPh:`接口地址(可选,默认继承,如 https://opencode.ai/zen/go)`,modelsCount:`{n} 个模型`,addProvider:`新增服务商`,providerId:`服务商 ID`,providerIdHint:`(必填,如 ollama / my-proxy)`,displayName:`显示名`,displayNamePh:`我的代理`,apiType:`API 类型`,baseUrlHint:`(OpenAI 兼容端点)`,apiKeyHint:`sk-…(可留空,用 auth.json 的密钥)`,authHeader:`自动添加 Authorization 请求头`,modelsTitle:`模型`,modelIdReq:`模型 ID(必填)`,text:`文本`,textImage:`文本+图片`,contextWindow:`上下文`,maxOutput:`最大输出`,removeModel:`移除模型`,addModel:`添加模型`,deleteProviderConfirm:`删除服务商 {id} 及其 {n} 个模型?`,fetchModels:`自动获取模型列表`,fetchModelsHint:`从 baseUrl 的 /models 接口自动拉取模型 ID(服务端请求,不受 CORS 限制)`,fetchingModels:`获取中…`,fetchModelsOk:`已获取 {n} 个模型`,fetchModelsEmpty:`接口未返回任何模型`,fetchModelsErr:`获取失败:{msg}`,fetchModelsNeedBaseUrl:`请先填写 baseUrl 再获取`,antigravityTemplateTitle:`快捷模板`,antigravityTemplateDesc:`本地 Antigravity-Manager 反代(8045 端口):点一下填好接口,只需粘贴 API Key,再点「自动获取模型列表」。`,antigravityFillOpenAI:`填入 Antigravity(OpenAI 通道)`,antigravityFillAnthropic:`填入 Antigravity(Anthropic 通道)`,enrichModels:`补参数`,enrichModelsHint:`按模型 id 查 OpenRouter / models.dev 目录补上下文、输出上限、识图与推理(只填空,不覆盖手填)`,enrichHintPh:`选填依据,每行一条:模型 id = 目录 id 或模型页 URL(如 claude-sonnet-4-5-thinking = anthropic/claude-sonnet-4-5),留空自动匹配`,enrichingModels:`补参中…`,enrichModelsCancel:`取消`,enrichModelsAbort:`中断补参数`,enrichCancelling:`正在取消…`,enrichModelsCancelled:`已取消补参数`,enrichModelsOk:`已补 {n} 个,未匹配 {m} 个`,enrichModelsErr:`补参数失败:{msg}`,enrichModelsNeedIds:`先填写至少一个模型 ID`,goalBarTitle:`目标`,goalBarPlaceholder:`设定一个目标,agent 完成后自动审查…`,goalBarSet:`开始`,goalBarClear:`取消`,goalBarLocked:`锁定:应用到后续所有回合`,goalBarUnlocked:`仅本回合(改完自动清除)`,goalBarReviewModel:`审查模型`,goalBarUseMainModel:`使用主模型`,goalBarMaxRounds:`最大轮数`,goalBarMaxRoundsTip:`最大审查重改轮数;0 或不填 = 不限(持续改到通过)`,goalBarUnlimitedShort:`不限`,goalBarReviewing:`审查中…`,goalBarRound:`第 {n} 轮`,goalBarActive:`目标生效中`,goalBarPassed:`已通过`,goalBarFailed:`未通过`,goalBarStatusPending:`等待生成…`,goalWizardBtn:`AI 提炼`,goalWizardTip:`让 AI 通过问卷调研细化需求,收敛为目标`,goalWizardRunning:`目标调研中`,goalWizardAnswer:`回答`,goalWizardCard:`目标调研`,settings:`设置`,settingsTitle:`设置`,settingsDesc:`修改立即生效:系统提示词、技能与插件开关会重建当前会话;审查提示词与审查技能只影响后续目标审查(回复进行中则主会话变更自动延迟)。`,settingsSystemPrompt:`系统提示词`,settingsPromptHistory:`输入历史`,settingsPromptHistoryDesc:`用 ↑↓ 在输入框循环历史提问,全局跨对话共享(localStorage)`,promptHistoryMax:`最大条数`,promptHistoryMaxHint:`超过上限时最旧的自动丢弃,可设 1–500`,promptHistoryCharLimit:`限制单条字数`,promptHistoryCharLimitHint:`开启后超长输入截断后保存,避免大段粘贴占满存储`,promptHistoryCharLimitPlaceholder:`最大字数(100–20000)`,promptHistoryClear:`清空历史`,promptHistoryClearConfirm:`确认清空?`,promptHistoryCleared:`已清空输入历史`,promptHistoryCount:`当前 {n} 条`,promptHistoryEmpty:`暂无历史记录,上/下键暂无可循环内容`,settingsPromptMode:`模式`,promptModeAppend:`追加`,promptModeReplace:`替换`,promptAppendHint:`追加模式:自定义内容拼接到默认系统提示词末尾(推荐,保留默认行为约束)。`,promptReplaceHint:`替换模式:只替换内置模板的「灵魂提示词」(人物设定段,如 “You are an expert coding assistant…”);工具列表、Guidelines、文档指引、项目上下文、技能段等自动拼装段仍由系统每次重新生成,不会被替换。切换后输入框显示原本的灵魂提示词,可直接修改;留空则使用内置默认。`,promptPlaceholder:`输入自定义系统提示词…(失焦后自动应用)`,promptComposeHint:`模板里的 {{token}} 在每次对话时展开为对应「来源」的提示词;未覆盖的来源用自动内容(工具列表/项目上下文/技能等永远用最新数据生成)。`,promptComposeDesc:`组合模板:{{token}} 自由排序/删改/穿插自己的话;空 = 默认模板。下面每个来源可单独覆盖(留空 = 自动内容),也可逐块恢复默认。`,promptTemplateLabel:`组合模板`,promptSourcesLabel:`各来源(可单独覆盖)`,promptInsertTokens:`插入段落:`,promptResetAll:`恢复默认模板并清空所有覆盖`,promptResetSource:`恢复默认`,promptAutoBadge:`自动`,promptOverridePlaceholder:`输入覆盖内容(留空 = 用自动内容)…`,promptSourceDefaultEmpty:`(该来源当前无自动内容)`,promptReadonlyBadge:`系统自动生成(只读)`,promptReadonlyLockedBadge:`自定义覆盖(只读·锁定)`,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:`查看当前完整提示词`,settingsViewPromptHint:`当前会话实际生效的完整系统提示词(含自定义追加/替换内容、项目上下文、技能说明与工具引导),只读。`,settingsViewPromptEmpty:`会话尚未就绪,暂无系统提示词。`,settingsViewToolsSchema:`工具 schema`,settingsViewToolsSchemaHint:`发给模型的 function-calling 工具定义(name / description / parameters),与系统提示词正文拼成完整初始上下文,只读。`,settingsViewToolsSchemaEmpty:`会话尚未就绪,暂无工具 schema。`,settingsSkills:`技能`,settingsReview:`目标审查`,settingsReviewDesc:`为独立的目标审查会话配置额外提示词和技能;不会改变主会话设置。`,settingsReviewSkills:`审查可用技能`,reviewPromptPlaceholder:`输入审查自定义提示词…(失焦后自动应用)`,reviewPromptHint:`这些内容会追加到审查任务中;审查仍会强制要求输出 pass/fail JSON。技能开关仅对审查生效。`,goalModeEnabled:`启用目标模式`,goalModeEnabledDesc:`目标条 / 目标调研向导 / 审查循环的总开关(默认开)。关闭后目标条隐藏,无法设置目标、启动调研或触发审查。`,goalModeOffHint:`目标模式已关闭:目标条已隐藏,已有的目标将不再触发审查。`,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 字;在回复第一条消息末尾根据情况重命名)`,settingsTerminalTools:`终端工具`,terminalToolsEnabled:`启用持久终端工具`,settingsTerminalToolsDesc:`让 AI 在交互式程序(REPL/vim)、长驻服务、需要持续观察输出或你要求在可见终端操作时,使用内置终端;普通命令仍走一次性 bash 工具`,terminalToolsOffHint:`已关闭:AI 无法使用 terminal_* 工具,也不会收到相关使用引导`,settingsEditTools:`编辑工具`,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:`工具`,toolsSectionTerminal:`持久终端`,toolsSectionSubagent:`子代理`,toolsSectionOther:`其他工具`,toolsSectionPlugin:`插件工具`,toolsPluginHint:`插件经 registerAgentTool 注册的 AI 工具:关掉即从会话里移除,AI 调不动;重开立即加回,无需 reload。禁掉的条目会保留,插件重装后仍保持关闭。`,pluginToolsSection:`注册的 AI 工具`,pluginToolsEmpty:`已安装的插件都没有注册 AI 工具`,pluginToolOffHint:`已关闭:AI 无法调用该工具(重开立即恢复,无需 reload)`,toolsSubagentDepHint:`逐个开关:关闭 subagent_spawn 后其余(等待/查询/改向/停止)无会话可管,只会返回空列表或“未找到”;delegate_task 走 spawn 通道,spawn 关了它也派不出去。`,delegateTaskEnabledDesc:`把定义清楚的任务派给 specialist 子代理模板:六段派单(TASK/EXPECTED OUTCOME/REQUIRED TOOLS/MUST DO/MUST NOT DO/CONTEXT)在服务端校验,缺段或含糊直接报错打回。执行体复用子代理 spawn 通道。`,delegateTaskOffHint:`已关闭:AI 无法使用 delegate_task 派单(可用 subagent_spawn 自由派单,不带六段校验)`,todoListEnabledDesc:`只读查询当前任务列表,删除项需显式传参;写操作不走工具,直接写内联标记。`,todoListOffHint:`已关闭:AI 不能再调查询工具(内联标记的写入不受影响)`,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)`,readDirEnabled:`read 读目录`,readDirEnabledDesc:`开启:read 工具传目录路径时列出目录条目(一行一项、目录带 / 后缀,此时 limit 是条目上限);关闭:目录参数原样交给内置 read(报 EISDIR,看目录得用 bash 的 ls)。DSH 引擎没有该覆盖,仅 pi 引擎生效`,toolWatchdogTimeout:`工具看门狗超时(分钟)`,toolWatchdogTimeoutDesc:`单个工具调用的最长执行时长(默认 20 分钟,0 = 禁用看门狗)。超时自动终止以防挂死;若工具调用显式指定了更长超时(如 bash timeout),看门狗将自动顺延`,toolWatchdogOff:`0 = 禁用`,visionBridgePromptPlaceholder:`输入自定义转写提示词…(留空 = 使用内置默认提示词,失焦后自动应用)`,visionBridgePromptAppendHint:`追加模式:自定义内容拼接到内置转写提示词末尾(推荐,保留默认的逐字转写约束)。`,visionBridgePromptReplaceHint:`替换模式:完全用自定义内容替换内置转写提示词。切换后输入框会显示内置默认提示词,可直接修改;不改动失焦则仍使用默认。`,scmCommitMsgSettingsTitle:`AI 提交信息(源代码管理)`,scmCommitMsgSettingsDesc:`源代码管理面板「AI 生成」按钮的提示词:模型按仓库近期提交的语言与风格,把当前改动提炼成一行提交信息并填入提交输入框`,scmCommitMsgPromptPlaceholder:`输入自定义提示词…(留空 = 使用内置默认提示词,失焦后自动应用)`,scmCommitMsgSettingsHint:`追加模式把自定义内容拼在内置提示词末尾;替换模式完全使用自定义内容(切换后输入框会显示内置默认,可直接修改,不改动失焦则仍使用默认)`,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:`添加到列表`,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:`插件可以调整这里的条目(包括宿主内置入口);你随时能改回来:取消勾选=隐藏,↑/↓ 调顺序,改过的条目会显示「恢复」。隐藏的条目仍能在顶栏溢出菜单里点到。`,pluginTopbarMore:`更多插件按钮`,pluginMenuTitle:`插件`,pluginMenuPin:`钉到顶栏`,pluginMenuUnpin:`取消钉住`,pluginMenuReorder:`调整插件顺序`,pluginMenuReorderHint:`拖动排序;聚焦后可用上下方向键`,pluginMenuManage:`管理插件`,pluginMenuEmpty:`未安装界面插件(<dataDir>/plugins/)`,pluginMenuNoView:`无独立界面`,uiLayoutTopbar:`顶栏`,uiLayoutRequired:`此入口固定显示,不能隐藏`,uiLayoutTopbarText:`显示按钮文字`,uiLayoutTopbarOverflow:`顶栏溢出菜单`,uiLayoutBottombar:`底栏`,uiLayoutComposerLeading:`输入框前置区(上传按钮左侧)`,uiLayoutComposer:`输入框动作`,uiLayoutMessage:`消息工具条`,uiLayoutRightPanel:`右侧面板`,uiLayoutSettingsPages:`设置页`,uiLayoutModal:`弹窗`,uiLayoutContextTopbar:`顶栏右键菜单`,uiLayoutContextMessage:`消息右键菜单`,uiLayoutContextSession:`会话右键菜单`,uiLayoutContextFile:`文件右键菜单`,uiLayoutContextToolcall:`工具卡右键菜单`,uiLayoutLeftSessions:`左栏会话行`,uiLayoutChatHeader:`对话头部条`,uiLayoutChatEmpty:`空对话占位区`,uiLayoutFilePreview:`文件预览工具条`,uiLayoutTerminal:`终端工具条`,uiLayoutScm:`SCM 工具条`,uiLayoutGoalbar:`目标条动作`,uiLayoutNotice:`通知条动作`,uiLayoutSearch:`搜索条目…`,uiLayoutMovedFrom:`移自`,uiLayoutAlign:`对齐`,uiLayoutRename:`改名`,uiLayoutRestore:`恢复`,uiLayoutRestoreAll:`全部恢复默认`,uiLayoutArranged:`插件调整过`,uiLayoutEmpty:`(无)`,pluginGrantsTitle:`已授权目录`,pluginGrantsHint:`插件要访问工作区之外的目录时必须先经你确认(确认过的会记在这里,可随时撤销)。`,pluginGrantsEmpty:`还没有插件获得过工作区外的目录授权`,pluginGrantsRevoke:`撤销`,pluginGrantRequestTitle:`插件请求访问目录`,pluginGrantRequestBody:`{plugin} 想访问下面这个目录:
|
|
157
|
-
|
|
158
|
-
{path}`,pluginGrantAllow:`允许`,pluginGrantDeny:`拒绝`,pluginPermTitle:`插件请求能力授权`,pluginPermBodyNet:`{plugin} 想访问下面这些网络主机(不再改配置重装):
|
|
159
|
-
|
|
160
|
-
{hosts}`,pluginPermBodyLlm:`{plugin} 想调用模型{models}(花你的模型额度)`,pluginPermOnce:`仅本次允许`,pluginPermAlways:`记住并允许`,pluginPermsTitle:`已授权能力`,pluginPermsHint:`插件运行时申请的能力范围(网络主机 / 模型作用域),可逐条撤销。仅本次的授权重启即失。`,pluginPermsEmpty:`还没有动态授权`,pluginPermSession:`仅本次`,pluginPermNet:`网络`,pluginPermLlm:`模型`,pluginPermUnscoped:`不限范围`,pluginUiNoHandler:`插件没有接管这个动作(可能版本不匹配)`,pluginSessionGrantTitle:`插件请求打开一个项目会话`,pluginSessionGrantBody:`插件想在下面这个目录里打开一个新会话(工作区会切过去):
|
|
161
|
-
|
|
162
|
-
{path}
|
|
163
|
-
|
|
164
|
-
只在你确认后打开。`,settingsExtensions:`插件`,settingsUiPlugins:`界面插件`,pluginListTab:`插件列表`,noUiPlugins:`未安装界面组件(<dataDir>/plugins/)`,pluginPhaseActive:`运行中`,pluginPhaseDisabled:`已禁用`,pluginPhaseFailed:`失败`,pluginPhaseIdle:`纯前端`,pluginRescan:`重新扫描`,pluginRescanHint:`重新扫描插件目录(新增/修复后生效;失败记录清空重记)`,dshPatches:`DSH 用户补丁`,dshPatchesDesc:`启动时按文件名序加载的 Cordis patch(<dataDir>/dsh-patches/*.yml)。新增/修改后点「重扫」重启运行时生效;失败的文件会被跳过并打印到运行时 stderr。`,dshPatchesRescan:`重扫`,dshPatchesRescanHint:`重新扫描补丁目录并重启 DSH 运行时使新补丁生效`,dshPatchesEmpty:`未放置补丁文件`,dshPatchesPath:`补丁目录:`,dshPreset:`Agent 预设`,dshPresetNewChat:`以此预设开新对话`,dshPresetLocked:`已锁定`,dshPresetBlankOnly:`首轮发言后锁定,空白会话可切换`,dshPresetBroken:`(不可用)`,dshPresetUser:`自建`,dshPresetDefaultTag:`默认`,dshPresetCurrent:`当前`,dshPresetMinimalNote:`极简模式:仅持久 shell;宿主插件工具与问卷不可用`,dshDefaultPreset:`默认预设`,dshDefaultPresetDesc:`新对话使用的预设;空白会话可随时切换,首轮发言后锁定`,dshPresetUserNote:`自建预设来自用户预设目录(与 shell 同等信任);用裸包名的自建组合在此无法挂载(已知限制)`,dshPerm:`权限`,dshPermReadOnly:`仅可查看`,dshPermReadOnlyDesc:`只能读文件、跑只读命令;写操作一律拒绝,不弹确认`,dshPermWorkspaceWrite:`工作区内修改`,dshPermWorkspaceWriteDesc:`工作区内读写,不弹确认;超出范围的操作直接拒绝`,dshPermFullAccess:`完全权限`,dshPermFullAccessDesc:`关闭沙箱,整机任意读写;只给信任的任务`,dshPermFullAccessTag:`高危`,dshPermCustom:`自定义`,dshPermConfirmFull:`再点一次确认开启完全权限`,dshPermDefault:`新会话默认权限`,dshPermDefaultDesc:`新对话的初始权限;当前对话可随时热切换,无需重启`,uiPluginNoSource:`手工安装,无来源信息,无法在线更新`,uiPluginPerms:`能力声明`,pluginDiagTitle:`诊断信息`,pluginDiagShow:`诊断`,pluginDiagHide:`收起`,pluginLogTitle:`运行日志`,pluginLogShow:`日志`,pluginLogHide:`收起`,pluginLogLevel:`级别`,pluginLogAll:`全部`,pluginLogEmpty:`暂无日志`,pluginLogClear:`清空`,pluginDomNeed:`⚠ 请求完全 DOM 访问`,pluginDomDesc:`该插件可直接读写页面 DOM(绕过界面布局限制)。只给可信来源的插件授权;授权后其界面代码可碰顶栏/输入框/任意页面元素。`,pluginDomGrant:`授权 DOM 访问`,pluginDomRevoke:`撤销 DOM 访问`,pluginDomGranted:`已授权完全 DOM 访问`,pluginSettingsTitle:`插件配置`,pluginSettingsShow:`配置`,pluginSettingsHide:`收起`,pluginSettingsSave:`保存插件设置`,pluginSettingsSaving:`保存中…`,pluginSettingsReset:`恢复默认`,pluginSettingsInherit:`跟随全局默认`,pluginSecretSet:`已设置(加密保存,留空不改)`,pluginSecretUnset:`未设置(加密保存)`,settingsPresets:`预设`,settingsSubagentTemplates:`子代理模板`,settingsSubagentTemplatesDesc:`配置子代理预设(角色系统提示词 + 技能/扩展白名单 + 可选模型与思考强度)。AI 派生子代理时可选用模板(subagent_spawn 的 template 参数),也可不传按默认运行;停用的模板保留在面板但对 AI 不可见。`,noSubagentTemplates:`还没有子代理模板。AI 派生子代理时可选用模板(角色提示词 + 技能/扩展白名单 + 可选模型与思考强度),也可以不传 template 按默认配置运行。`,subagentTemplateNew:`新建模板`,subagentTemplateEdit:`编辑`,subagentTemplateClosed:`已停用`,tplDefaultBadge:`默认`,subagentTemplateOffHint:`关闭的模板保留在面板、可随时重新启用,但 AI 工具查询不到、不能选择`,subagentTemplateEnable:`启用`,subagentTemplateDisable:`停用`,subagentDefaultModelLabel:`子代理默认模型`,subagentFollowMain:`跟随主对话当前模型`,subagentDefaultModelHint:`所有子代理的兜底模型(模板里指定的模型和 subagent_spawn 的 model 参数优先级更高);不改主对话模型。`,subagentNoModels:`暂无可用的模型(需要先配置服务商 API Key)——子代理将跟随主对话模型。`,tplNamePlaceholder:`模板名(AI 用 subagent_spawn 的 template 参数引用)…`,tplDescriptionPlaceholder:`简介(AI 据此判断适用场景)…`,tplDescriptionEnPlaceholder:`英文简介(英文 UI 时 AI 看这个,留空则用中文简介)…`,tplPromptModeLabel:`系统提示词模式`,tplModelLabel:`模型(空 = 跟随主对话)`,tplThinkingLabel:`思考强度`,tplThinkingFollowMain:`跟随主对话当前思考强度`,tplThinkingHint:`空 = 跟随主对话当前思考强度(与不指定模型时的「跟随主对话」同语义);模型不支持所选档位时自动收敛到最接近的可用档位。`,tplSystemPromptLabel:`系统提示词`,tplSystemPromptPlaceholder:`模板角色系统提示词…(append 模式可留空)`,tplSystemPromptEnPlaceholder:`英文系统提示词…(英文 UI 时生效,留空则用中文)`,tplWhitelistHint:`白名单:勾选 = 子代理只启用这些;全部不勾 = 跟随主会话设置`,tplSkillsLabel:`技能白名单`,tplExtensionsLabel:`扩展白名单`,tplSave:`保存模板`,tplCancel:`取消编辑`,tplDelete:`删除模板`,settingsScheduler:`定时任务`,schedulerDesc:`到点自动让 Agent 干活(依赖巡检、跑测试、生成早报……):无头伪客户端执行,无浏览器也能跑;跑完推送通知,历史可查。`,schedulerEmpty:`还没有定时任务。点右上角「新建任务」安排第一个:每天 9 点巡检、每小时跑一次测试都可以。`,schedulerNew:`新建任务`,schedulerEdit:`编辑`,schedulerDelete:`删除`,schedulerRunNow:`立即运行`,schedulerRunning:`执行中…`,schedulerEnable:`启用`,schedulerDisable:`停用`,schedulerEnabled:`已启用`,schedulerDisabled:`已停用`,schedulerNameLabel:`任务名称`,schedulerNamePlaceholder:`如:每日依赖与代码健康检查…`,schedulerDescPlaceholder:`说明(可选):这个任务是干什么的…`,schedulerCwdLabel:`执行目标项目`,schedulerCwdPlaceholder:`/绝对/路径/到/项目…`,schedulerUseCurrentCwd:`用当前项目`,schedulerKindLabel:`调度周期`,schedulerKindCron:`Cron 表达式`,schedulerKindInterval:`固定间隔`,schedulerCronPlaceholder:`如 0 9 * * *(每天 9:00)`,schedulerPresetDaily:`每天 9:00`,schedulerPresetHourly:`每小时整点`,schedulerPresetHalfHour:`每 30 分钟`,schedulerPresetWorkday:`工作日 9:00`,schedulerPresetMonday:`每周一 9:00`,schedulerPresetCustom:`自定义…`,schedulerIntervalMinutes:`间隔(分钟,最少 1 分钟)`,schedulerPromptLabel:`触发指令`,schedulerPromptPlaceholder:`给 Agent 的具体任务,如:审计依赖并报告可升级项…`,schedulerModelLabel:`模型(空 = 跟随默认)`,schedulerThinkingLabel:`思考强度(空 = 跟随默认)`,schedulerCatchUp:`服务重启后补跑漏掉的一次`,schedulerCatchUpHint:`勾选后,服务停机期间错过的触发会在下次启动时补跑一次;不勾选则跳过。`,schedulerNextFire:`下次`,schedulerLastRun:`上次`,schedulerNeverRun:`从未运行`,schedulerHistory:`历史`,schedulerManualBadge:`手动`,schedulerRunOk:`成功`,schedulerRunFail:`失败`,schedulerConfirmDelete:`确定删除定时任务「{name}」吗?历史记录一并清除。`,schedulerSave:`保存任务`,schedulerCancelEdit:`取消编辑`,tplInherit:`跟随主会话`,settingsEnabled:`已启用`,settingsDisabled:`已禁用`,presetNamePlaceholder:`预设名称…`,saveAsPreset:`保存为预设`,applyPreset:`应用`,deletePreset:`删除预设`,noSkills:`暂无技能`,noExtensions:`暂无插件`,noPresets:`暂无预设(先调整上面的设置,再保存为预设组合)`,loadingSession:`正在加载会话…`,connectingServer:`正在连接 pi-web-ui 服务器…`,localePacks:`语言包`,localeGetMore:`获取更多语言`,localeInstalled:`已安装`,localeInstall:`下载`,localeRemove:`移除`,localeDownloading:`下载中…`,localeRemoving:`移除中…`,localeInstallFailed:`下载失败:{error}`,localeListFailed:`获取语言包列表失败:{error}`,localeRemoveHint:`移除后随时可重新下载`,wallpaperTitle:`聊天背景图`,wallpaperDesc:`给整个窗口加一张背景图(左右面板、顶栏、底栏也会透出):主题自带的图会自动生效,在此填地址则优先用你的;用压暗与模糊保证文字清晰。`,wallpaperUrlPh:`图片地址(https://…,留空关闭)`,wallpaperDim:`压暗`,wallpaperBlur:`模糊`,wallpaperClear:`清除`,wallpaperUpload:`上传图片`,wallpaperUploadFailed:`图片读取失败或过大,请换一张试试`,skillFullTextLabel:`技能全文注入`,skillFullTextDesc:`把技能文件正文直接展开进系统提示词(单文件 8KB、总量 32KB 封顶),否则只列名录由模型按需读取`,skillFullTextShort:`全文`,delegateOpenSubagent:`查看子代理`,delegateSecTask:`任务`,delegateSecExpected:`期望产出`,delegateSecTools:`可用工具`,delegateSecMustDo:`必须做`,delegateSecMustNotDo:`禁止做`,delegateSecContext:`上下文`,copyConversationId:`复制对话 ID`,copyConversationPath:`复制会话文件路径`,quoteConversation:`引用到输入框(AI 可读)`,quoteConversationShort:`引用`,attachConversation:`对话引用:{name}(AI 经 conversation_read 按需读取)`,attachConversationShort:`对话`,presentOpenLocal:`本地打开`,presentMissing:`文件不存在或不可读(可能已被移动、删除或超出工作区)`,presentEmpty:`没有可展示的文件`,presentAutoOpen:`自动打开 AI 展示的预览`,presentAutoOpenDesc:`AI 用 present_files 展示文件、并标了「先看这个」时,自动弹出文件预览窗口;关闭(默认)则只在卡片里显示,点一下再看。`,presentFilesEnabledDesc:`让 AI 把产物(截图 / 图表 / 视频 / 报告 / 日志)作为预览卡片推到对话里:图片、视频、音频直接在消息里显示/播放,文本给开头摘录 + 一键开预览弹窗,每条都带「本地打开 / 在文件夹中显示 / 下载 / 复制路径」。自动弹预览窗的开关在「对话」页。`,presentFilesOffHint:`已关闭:AI 只能用文字告诉你文件路径,没有卡片,也没有本地打开按钮`,skillEnabledDesc:`技能正文按名加载(技能名录仍注入系统提示词):真要用到某个技能时才取全文,不再让模型拼路径去 read。`,skillOffHint:`已关闭:AI 不能按名取技能全文(提示词里的技能名录不受影响)`,claimFilesEnabledDesc:`声明你要改哪些文件,让同项目的并行对话绕行(纯建议,不拦编辑):开着 AI 才知道能认领,先到先得,过期自动释放。`,claimFilesOffHint:`已关闭:AI 不能再认领文件(并行触碰提醒照常工作,只是少了事前意图这一路)`,toolInfoMenuLabel:`显示工具详细信息`,toolInfoTitle:`工具详细信息`,toolInfoLoading:`正在读取工具定义…`,toolInfoUnsupported:`当前引擎不支持查看工具定义`,toolInfoMissing:`未找到这个工具的定义(可能来自已卸载的插件或旧版本)`,toolInfoActive:`已启用`,toolInfoInactive:`已停用`,toolInfoSource:`来源`,toolInfoDescription:`说明`,toolInfoNoDescription:`这个工具没有提供说明`,toolInfoPromptSnippet:`提示词摘要`,toolInfoGuidelines:`提示词要点`,toolInfoParams:`参数`,toolInfoParamsNone:`这个工具没有参数`,toolInfoSchemaDropped:`参数 schema 太大,已省略(见下方原始 JSON)`,toolInfoRawSchema:`原始 JSON Schema`,toolInfoRequired:`必填`,toolInfoFootnote:`这是工具的定义说明,不含本次调用的参数与结果。`},jt={docTitle:`pi-web-ui — pi coding agent`,cancel:`Cancel`,ok:`OK`,save:`Save`,close:`Close`,widgetExpand:`Click to view full output`,collapsePanel:`Collapse panel`,expandPanel:`Expand panel`,dragToResize:`Drag to resize · double-click to reset`,loading:`Loading…`,connected:`Connected`,connecting:`Connecting…`,reconnecting:`Reconnecting…`,language:`Language`,langZh:`中文`,langEn:`English`,langIt:`Italiano`,langJa:`日本語`,langKo:`한국어`,langFr:`Français`,langDe:`Deutsch`,langEs:`Español`,langRu:`Русский`,langPt:`Português`,githubRepo:`GitHub repository (xing-shuyin/pi-web-ui)`,copy:`Copy`,viewSwitch:`Switch view`,chat:`Chat`,terminal:`Terminal`,selectModel:`Select model`,availableModels:`Available models`,allProviders:`All`,providers:`Providers`,noModels:`No models available (configure an API key first)`,reasoning:`reasoning`,vision:`vision`,refreshModels:`Refresh model list (keeps manual rows, merges new ones)`,manageModels:`⚙ Manage models (add / edit)`,manageModelsTitle:`Manage models`,setGlobalDefault:`☆ Set as global default (new projects follow it)`,clearGlobalDefault:`★ Clear global default`,globalDefaultBadge:`Global default`,thinkingLevel:`Thinking level`,thinking:`Thinking`,thinkingChip:`Thinking: {level}`,sound:`Sound`,theme:`Theme`,themeDefault:`Dark (default)`,themeGroupClassics:`Classics`,themeGroupBuiltin:`Original`,themeLight:`Light`,themeDark:`Dark`,newChat:`New chat`,more:`More`,brand:`Brand`,newChatTip:`New chat (sessions are saved per browser)`,"thinking.off":`Off`,"thinking.minimal":`Minimal`,"thinking.low":`Low`,"thinking.medium":`Medium`,"thinking.high":`High`,"thinking.xhigh":`Extra high`,"thinking.max":`Max`,thinkingUnsupported:`Not supported by this model — snapped to the nearest supported level`,context:`Context`,contextUsage:`Context usage`,cumulativeCost:`Cumulative cost`,sessionMessages:`Session messages`,messages:`messages`,pluginStatus:`Plugin status`,engineBadge:`Engine`,working:`Working`,queued:`queued`,enterPath:`Type a path, Enter to switch`,cwdTip:`Working directory: {path} (click to switch)`,manageProjects:`Manage projects and working directories`,projectPickerTitle:`Choose a working directory`,newProject:`New project`,projectName:`Project name`,createAndOpenProject:`Create and open`,invalidProjectName:`Enter a project name without path separators`,cwdGoUp:`Up one level`,cwdPickCurrent:`Select this folder`,cwdChoose:`Select`,cwdEnter:`Enter`,cwdEmpty:`(empty)`,cwdNewFolder:`New folder`,cwdNewName:`Folder name`,cwdCreate:`Create`,cwdCancel:`Cancel`,cacheHit:`Cache hit`,cacheHitTip:`read {read} · write {write} · miss {miss} (of {input} input tokens)`,tps:`t/s`,rateTip:`Live generation rate (estimated)`,hostResources:`Host resources`,hostProcessor:`CPU`,hostMemory:`RAM`,hostResourcesTip:`Host running pi-web-ui · Central processing unit (CPU) and random-access memory (RAM) usage`,folderRef:`Folder reference: {path}`,refOnly:`Reference only: {path}`,attachContent:`Attached content: {path}`,attachLines:`Attached selected lines: {path} (lines {start}-{end})`,attachImage:`Image: {name}`,attachFile:`File: {name}`,removeAttachment:`Remove attachment`,attachHint:`Will be sent with the next message`,uploadFile:`Add files (images / text / any file — or drag in / paste a screenshot)`,dropHereToAttach:`Release to attach file`,imageNotSupported:`The current model doesn't support vision — images will be transcribed by the vision bridge (may be ignored if no vision model is configured)`,imageLoadFailed:`Couldn't read image: {name}`,fileLoadFailed:`Couldn't read file: {name}`,fileTooLarge:`File too large, skipped (> {size}MB): {name}`,foldersNotSupported:`Folders can't be dropped directly — expand and pick files instead`,placeholderStreaming:`The agent is working… press Enter to steer, or click Queue to send after the reply finishes`,placeholderStreamingQueued:`The agent is working… press Enter or click Queue — delivered after the reply finishes (this engine cannot steer)`,placeholderIdle:`Message pi — Enter to send, / for commands`,placeholderConnecting:`Connecting to server…`,stopAgent:`Stop agent`,stop:`Stop`,bgTasks:`Background tasks`,bgTasksTip:`Servers the AI started in the background (npm run dev & etc.) — stop them individually or all at once; they survive the conversation`,bgTasksEmpty:`No background tasks`,bgTasksDesc:`Processes the AI started that are still listening (detected by port)`,bgTaskPort:`Port`,bgTaskPid:`PID`,bgTaskSince:`Started`,bgTaskStop:`Stop`,bgTaskStopAll:`Stop all`,bgTaskRefresh:`Refresh`,bgTaskJustNow:`just now`,bgTaskMinutes:`{n} min ago`,bgTaskHours:`{n} hr ago`,bgTaskDays:`{n} days ago`,stopBash:`Stop`,stopBashTip:`Stop the running bash command (conversation continues)`,supplement:`Queue`,supplementTip:`Add to queue: sent only after the whole run finishes (no interruption)`,steerTip:`Steer: send right away — the current turn responds immediately (Enter)`,queueSteerTag:`Steer`,queueFollowTag:`Queued`,queueRemoveTip:`Remove this queued message`,queueRecallTip:`Recall into the input box for editing`,sendTip:`Send (Enter)`,composerResize:`Drag to resize the input height (double-click to reset)`,quickPhrases:`Quick phrases`,quickPhrasesDesc:`A row of frequently-used phrase buttons above the input box — click to send (current file attachments are included, the input draft is kept)`,quickPhrasesEnabled:`Enable quick phrases`,quickPhrasesOffHint:`Off: the phrase buttons above the input box are hidden (saved phrases are kept and can be re-enabled anytime)`,quickPhrasesPlaceholder:`Type a frequently-used phrase… (Enter to add)`,quickPhrasesAdd:`Add`,quickPhrasesEmpty:`No quick phrases yet — add your first one below`,quickPhrasesTip:`Click to send: {text}`,quickPhrasesSendTip:`Left-click to steer, right-click to queue`,quickPhrasesMoveUp:`Move up`,quickPhrasesMoveDown:`Move down`,quickPhrasesDelete:`Delete this phrase`,quickPhrasesEdit:`Edit this phrase`,quickPhrasesEditPh:`Edit phrase… (Enter to save, Esc to cancel)`,quickPhrasesReset:`Reset to defaults`,slashCommands:`Commands`,slashMenuHint:`↑↓ select · Enter/Tab complete`,atMentions:`Mentions`,atMenuHint:`↑↓ select · Enter/Tab insert`,slashHelpTitle:`pi commands`,slashHelpHint:`Type / anytime to open the command list`,slashLoading:`Loading commands… (available once connected)`,slashBuiltin:`Builtin`,slashExtension:`Extension`,slashPrompt:`Template`,slashSkill:`Skill`,slashPlugin:`Plugin`,slashCopied:`Copied the last assistant reply`,slashCopyFailed:`Copy failed — please copy manually`,slashCopyEmpty:`No assistant reply to copy yet`,recentProjects:`Recent projects`,runningConversations:`Running chats`,elsewhereBadge:`Elsewhere`,elsewhereTip:`Conversation open in another tab / device (running, or finished but still held there; right-click to take over and view it here)`,takeoverConversation:`Take over to this page`,takeoverHasQuestion:`Has a pending question — click to answer it here`,waitingQuestionBadge:`Waiting on your answer — click to view`,subagentBadge:`Subagent`,convErrorBadge:`Subagent failed: {error}`,subagentTitle:`Subagent · {title}`,historySessions:`History`,openHistory:`History`,openFiles:`Files`,openProject:`Open project`,streaming:`Streaming…`,noHistory:`No previous chats`,current:`Current`,messageCount:`{n} messages`,tuiTip:`Chat in the pi terminal (TUI)`,deleteProject:`Remove from recent projects`,deleteProjectConfirm:`Confirm remove`,deleteSession:`Delete this chat transcript permanently`,deleteSessionConfirm:`Confirm delete`,renameSession:`Rename this chat`,renameSessionPlaceholder:`Type a new name…`,renameSessionConfirm:`Rename`,dismissConversation:`Dismiss from running (keep in history)`,dismissConversationConfirm:`Confirm dismiss`,dismissFinishedSubagents:`Dismiss finished subagents ({n})`,dismissFinishedSubagentsScoped:`Dismiss finished subagents under this chat, incl. nested ({n})`,dismissConversationWithSubagents:`Also dismiss finished subagents ({n})? Make sure their results are no longer needed — click again to confirm`,dismissConversationWithSubagentsMixed:`Also dismiss finished subagents ({n})? {m} running one(s) stay, parent stays; make sure the finished ones are no longer needed — click again to confirm`,dismissStreamingConfirm:`Still running — confirm force-dismiss? (The run will be aborted)`,dismissFinishedOnly:`Dismiss finished only ({n})`,dismissForceAll:`Force-dismiss all (incl. {n} subagent(s))`,forceDismissTitle:`Force-dismiss this conversation and all {n} subagent(s) ({m} running will be aborted)`,forceDismissConversation:`Force-dismiss conversation (incl. all subagents)`,persistSubagent:`Convert to Regular Conversation`,forceDismissConfirm:`Confirm force-dismiss? Unfinished runs will be aborted — click again`,noFinishedSubagents:`No finished subagents to dismiss`,collapseSection:`Collapse`,expandSection:`Expand`,emptyChat:`Empty chat`,editReask:`Edit & re-ask`,editReaskTip:`Edit this question and re-ask from here (forks a new conversation; the original is kept)`,reaskFromHere:`Re-ask from here`,editPlaceholder:`Edit the question…`,editHint:`⌘/Ctrl+Enter to submit · Esc to cancel`,editAttachmentHint:`Original attachments kept — paste/drop images or files · ⌘/Ctrl+Enter to submit · Esc to cancel`,expandMsg:`Expand`,collapseMsg:`Collapse`,toolCalls:`tool calls`,bashRuns:`bash runs`,images:`images`,update:`Update`,updateTip:`Check & update pi-web-ui`,currentVersion:`Current version`,latestVersion:`Latest version`,checkingUpdate:`Checking…`,checkUpdate:`Check for updates`,upToDate:`You're up to date`,updateAvailable:`New version v{version} available`,updateJustPublished:`v{version} was just published — npm cache may lag; if the new version isn't detected yet, re-check in a moment`,updateNow:`Update in terminal`,updateTabTitle:`Update pi-web-ui`,updateTerminalHint:`Clicking runs npm i -g pi-web-ui@latest in a visible terminal; restart the service afterwards to take effect (pi-web-ui server restart).`,updateDesktopNote:`The desktop app doesn't use the global npm install: its server ships inside the app bundle, so the terminal command above does nothing for it. Use the in-app update below, or grab a new installer from the downloads page.`,updateDesktopCheck:`Check for desktop updates`,updateDesktopChecking:`Checking for desktop updates…`,updateDesktopAvailable:`New desktop release v{version} available`,updateDesktopDownload:`Download update`,updateDesktopDownloading:`Downloading {n}%`,updateDesktopDownloaded:`Download ready — install & restart to apply`,updateDesktopInstall:`Install & restart`,updateDesktopManual:`Manual install from downloads page`,updateDesktopError:`Desktop update failed: {error}`,updateDesktopNoBridge:`This desktop shell predates the built-in updater — grab a new installer from the downloads page.`,updatesAllTitle:`Component updates`,updatesAllBadge:`{n} updates`,updatesAllUpToDate:`All components up to date`,kindWebUi:`Web UI`,kindPiCore:`Core`,kindPackage:`Package`,kindGitExtension:`Git package`,updatesAllRefresh:`Re-check all`,updateCheckFailed:`Check failed`,updateBtn:`Update`,updateAllBtn:`Update all`,updatePkgTabTitle:`Update {name}`,updateAllTabTitle:`Update all components`,restartService:`Restart service`,restartingService:`Restarting…`,restartServiceTip:`Restart the pi-web-ui service ({name}): this instance is supervised (launchd/systemd/Windows watchdog), so it comes back automatically and the page reconnects — run it after an update`,computer:`This PC`,rootDir:`Root`,homeDir:`Home directory`,desktopDir:`Desktop`,filesHelp:`Navigate: click a folder to enter, a file to preview, '..' to go up; Root returns to the current project, This PC browses all drives, 🏠 jumps to your home directory, 🖥️ to the desktop.
|
|
165
|
-
Manage: right-click for new file/folder, rename, copy/cut/paste, duplicate, delete, upload; files can be downloaded, row buttons copy name/path.
|
|
166
|
-
Switch projects: right-click a folder → Open as project, or click the bottom-right 📁 path button to type/pick a directory.
|
|
167
|
-
Send to AI: row buttons attach content or reference a path, or drag files into the input.`,workspaceRoots:`Workspace roots`,workspaceRootsHint:`Roots the file tree can switch to; plugins may read and write them without a separate prompt.`,addWorkspaceRoot:`Add as workspace root`,addWorkspaceRootHint:`Add the current directory as a workspace root (switchable in the file tree; plugins may read/write it without a separate prompt)`,removeWorkspaceRoot:`Remove workspace root`,noFiles:`No files`,filesTruncated:`Directory too large — list truncated (first 2000 shown)`,linkFolderTip:`Link folder path to chat`,attachInlineTip:`Attach content to chat`,referenceTip:`Reference path only (AI reads on demand)`,previewFile:`Preview`,downloadFile:`Download file`,copyName:`Copy name`,copyPath:`Copy path`,downloadFailed:`Download failed: {error}`,fileNotFoundShort:`File not found`,pluginMountFailed:`Plugin {name} failed to mount`,pluginViewLoading:`Loading plugin view…`,pluginViewLoadFailed:`Plugin view failed to load`,pluginViewLoadFailedHint:`Open console (F12) for the plugin error, or check the server log; you can also reinstall the plugin in Settings → Plugins.`,pluginViewRetry:`Retry`,liveOutputOmitted:`…[{n} chars omitted above]…
|
|
168
|
-
`,uploadToFolder:`Upload files to this folder`,fileCompress:`Compress`,fileExtract:`Extract`,fileCompressDownload:`Compress and download`,fileUploadFolder:`Upload folder`,fileChooseFolder:`Choose folder`,fileExtractDestination:`Extract to (existing directory; empty means workspace)`,fileConflictPolicy:`Existing files`,fileConflictSkip:`Skip (default)`,fileConflictOverwrite:`Overwrite files (never replace directories)`,fileConflictError:`Stop without writing any files`,fileArchiveLimits:`ZIP / TAR / TAR.GZ / TGZ / GZ; up to 20,000 entries and 1 GiB expanded. Links and special files are rejected.`,fileFolderUploadHint:`Keeps the selected folder name and hierarchy, uploading one file at a time (32 MiB per file). Existing files are never overwritten; completed uploads remain after a failure. File System Access browsers also preserve empty directories; other browsers upload files and their parent folders.`,fileTransferBusy:`Working, please keep this dialog open…`,fileTransferFailed:`Operation incomplete: {error}`,uploadToCurrentDir:`Upload files to current directory`,openAsProject:`Open as project`,fileOpenPreview:`Open preview`,fileEnterDir:`Open folder`,fileReveal:`Reveal in File Explorer`,fileOpenDefault:`Open with Default App`,fileNewFile:`New file`,fileNewDir:`New folder`,fileRename:`Rename`,fileNamePlaceholder:`File name`,fileDuplicate:`Duplicate`,fileCut:`Cut`,fileCopyEntry:`Copy`,filePaste:`Paste`,fileDelete:`Delete`,fileDeleteConfirm:`Delete {name}?`,fileCopyRelPath:`Copy relative path`,fileRefresh:`Refresh`,protocolMismatch:`Page version differs from the server (the app was just updated). Refresh the page to restore full functionality.`,selectLinesHint:`Click a line to select; drag or Shift+click for a range`,enableWrap:`Enable line wrap`,disableWrap:`Disable line wrap`,selectedRange:`Selected {n} lines (lines {start}-{end})`,fileLines:`{n} lines`,selectAll:`Select all`,clearSelection:`Clear`,addToChat:`Add to chat`,addedToChat:`Added`,previewTruncated:`⚠ File too large — previewing the first 512KB`,previewLinesTruncated:`… too many lines — showing the first {n}`,binaryFile:`🔣 Binary file — first 4KB shown as hex`,binaryHexTruncated:` (file larger — download for the full file)`,previewNotSupported:`This file type can't be previewed (only images / videos / text)`,emptyFile:`(empty file)`,editFile:`Edit file`,exitEditFile:`Exit editing`,saveFile:`Save file`,discardFileChanges:`Discard unsaved changes?`,fileSaved:`Saved`,fileEditTruncated:`The preview is incomplete, so this file can't be edited`,showMarkdownSource:`Show Markdown source`,showMarkdownPreview:`Show Markdown preview`,showHtmlSource:`Show HTML source`,showHtmlPreview:`Show HTML preview`,htmlJsOff:`🛡 Scripts disabled (static preview)`,htmlJsOffTip:`Pure static render: JavaScript in the page will not run. Only enable scripts for files you trust.`,htmlJsOn:`⚠ Scripts enabled`,htmlJsOnTip:`JavaScript in the page is running. It still cannot reach this app (no same-origin, no forms, no top navigation), but it may make network requests or mine crypto — only for files you trust.`,htmlEnableJs:`Enable scripts`,htmlDisableJs:`Disable scripts`,fullscreen:`Fullscreen`,exitFullscreen:`Exit fullscreen`,zoomIn:`Increase font size`,zoomOut:`Decrease font size`,resetZoom:`Reset zoom`,pluginRequest:`Plugin request`,modelQuestion:`Model question`,modelQuestionCustom:`Custom answer (optional)`,modelQuestionSubmit:`Submit answer`,next:`Next`,previous:`Previous`,questionStep:`Q {cur} / {total}`,optionPreview:`Option preview`,questionTimeout:`⏳ {s}s left — auto-cancels on timeout`,questionTimeoutExpired:`Question timed out, resuming conversation…`,modelNoVision:`Current model {name} doesn't support images — switch to DeepSeek V4 Flash Vision (exp)`,dshSkillsNote:`DSH uses runtime-built-in skills (dsh-skill); toggling is not supported in settings yet`,dshExtensionsNote:`DSH has no pi extension system; capabilities are runtime-built-in (MCP/subagent/goal/plan/skill…)`,dshReviewPromptNote:`DSH has no separate reviewer: this text is appended to the system prompt for goal rounds`,dshVisionHiddenNote:`DSH supports real image input (DeepSeek V4 Flash Vision (exp) only) — no vision bridge needed`,dshNoReviewModel:`DSH has no separate reviewer model — the model self-certifies goal completion; max rounds = auto-iteration count`,noOptions:`(no options)`,inputPlaceholder:`Enter content`,soundHeader:`Sound notifications`,enableSound:`Enable sound`,preview:`Preview`,volume:`Volume`,notifyHeader:`Desktop notifications`,notifyEnable:`Enable desktop notifications`,notifyEnableDesc:`Ping you when a session finishes or needs your input. Requires permission; fires only while the page is out of sight (another app, a minimised window or a background tab). On Windows it also fires once you have been idle on the page for two minutes — the platform's presence signals are wrong there, and a redundant toast beats a silent one.`,notifyDenied:`Notification permission was blocked — allow notifications for this site in browser settings (on Windows also allow the browser/app under Settings → System → Notifications and turn Focus assist off).`,notifyUnsupported:`Notifications are not supported by this browser.`,notifyInsecure:`This address is not a secure context (plain http on a non-localhost host), so the browser withholds the notification API — open the app via 127.0.0.1 or HTTPS.`,notifyWindowsHint:`Windows adds an OS-level gate: allow the browser (or the installed pi-web-ui app) under Settings → System → Notifications and turn off Focus assist, otherwise toasts stay silent; closing the window also ends the process, so nothing can be delivered after that.`,notifyTest:`Send test notification`,notifyTestBody:`If you can see this OS notification, both the browser and Windows are letting notifications through.`,notifyTestSent:`Sent (path: {path})`,notifyTestFailed:`Delivery failed: {error}`,notifyTestState:`Platform state: focus {focus} · visibility {visibility} · minimised {minimized} · idle {idle}s`,notifyTestHeld:`The browser accepted it ({count} in your notification centre): if no banner popped up, Windows/Edge banner or quiet-notification settings are suppressing it.`,notifyTestDropped:`The browser did not keep this notification → Edge dropped it (site notifications muted/blocked).`,notifyTestGateSuppressed:`Current decision: would be swallowed (the platform thinks you are watching this page).`,notifyTestGateOpen:`Current decision: would be delivered (the platform thinks you are away).`,notifyDoneTitle:`Task finished`,notifyDoneBody:`The session finished and is ready for your input.`,notifyQuestionTitle:`Needs your input`,notifyQuestionBody:`pi is waiting for your answer to a question.`,notifyErrorTitle:`Something went wrong`,notifyErrorBody:`A session reported an error.`,"sound.question":`Question popup`,"sound.question.desc":`When ask_user_question appears`,"sound.done":`Reply finished`,"sound.done.desc":`When the agent finishes a turn`,"sound.start":`Reply started`,"sound.start.desc":`When the agent starts a new turn`,"sound.error":`Error`,"sound.error.desc":`When an error notice appears`,setupTitle:`pi agent config not detected`,setupDesc:`pi-web-ui needs pi's config directory (~/.pi/agent) and at least one API key to run the agent. pi has built-in providers such as openai, anthropic, and deepseek — just pick one and enter a key, no terminal needed.`,installFailed:`✖ pi agent installation failed:`,retryInstall:`Retry install`,skip:`Skip`,installDone:`✅ pi agent CLI installed. Pick a provider and enter an API key to start chatting:`,cliReadyHint:`✅ pi agent CLI already installed locally. Pick a provider and enter an API key to start chatting:`,provider:`Provider`,configured:`configured`,providerKeyReady:`This provider already has a key — use it or replace it.`,apiKey:`API key`,saving:`Saving…`,saveAndStart:`Save and start using`,recheck:`Recheck`,installing:`Installing pi agent CLI…`,autoInstall:`Auto-install pi agent`,attachment:`Attachment`,plugin:`plugin`,unknown:`unknown`,thinkingWait:`Thinking`,exitCode:`Exit code {code}`,cancelled:`Cancelled`,truncated:`… content too long, truncated in this view`,outputTruncated:`… output too long, truncated in this view`,refOnlyShort:`Reference only`,folderRefShort:`Folder · reference only`,inlineLines:`Inline · {n} lines`,inlineLinesRange:`Lines {start}-{end}`,image:`🖼 Image`,bridgedVision:`👁 Transcribed`,bridgedVisionDetail:`Image transcribed by the vision bridge (current model can't see images)`,folderNotExpanded:`Folder — content not expanded, the agent will browse it as needed`,fileNotExpanded:`Large file ({size}) — content not expanded, the agent will read it as needed`,"role.user":`You`,"role.assistant":`pi`,"role.tool":`Tool`,"role.bash":`Terminal`,"role.branch":`Branch summary`,"role.compaction":`Context compacted`,directory:`Directory`,waitingResponse:`Waiting for model response…`,retryingApi:`Model API error, auto-retrying ({attempt}/{max}): {error}`,retryingApiSoon:`Model API error, auto-retrying: {error}`,modelRetryAttempts:`Auto-retry attempts on model errors`,modelRetryHint:`How many times a failed model API call is retried automatically. When the budget runs out the turn stops with a red error and you can retry manually; 0 stops at the first failure. Applies immediately, no reload needed.`,softCapTokens:`Compression threshold (tokens)`,softCapHint:`Auto-compact the session once context reaches this many tokens instead of piling up to the model's physical limit. Guards against tiered-billing surprises (e.g. Grok price jump past 200K) and long-context degradation. Supports 300k, 1M, 300000; empty = off. Per-model overrides win over the global value. Applies immediately, no reload needed.`,softCapOff:`Off (compact at limit, supports 300k / 1M)`,softCapByModel:`Per-model overrides`,softCapByModelHint:`Threshold per model (provider/id, e.g. xai/grok-4); wins over the global value above.`,softCapModelId:`Model provider/id`,softCapAdd:`Add`,softCapRemove:`Remove`,softCapMarker:`soft cap`,retryNow:`Retry`,retryLastTip:`Manually retry the last failed model request`,compactingContext:`Compacting context, generating summary…`,compactingReasonManual:`Triggered manually`,compactingReasonThreshold:`Auto-triggered by context threshold`,compactingReasonOverflow:`Auto-triggered by context overflow`,compactionFrom:`Compacted from {tokens} tokens`,compactionKeptHint:`Earlier history is folded into this summary; only recent messages stay in context`,backToBottom:`Back to bottom`,questionNavTitle:`Questions`,searchPlaceholder:`Search in conversation…`,searchNoResults:`No results`,searchModels:`Filter models…`,noModelMatches:`No matching models`,modelUsedCount:`used {n}×`,searchGlobal:`Search`,searchGlobalTip:`Global search: sessions / projects / files (Ctrl+K)`,gsPlaceholder:`Search projects, past conversations, workspace files…`,gsHint:`Type to search full conversation text (AI replies included), recent projects and file names in the current workspace at once`,gsSessions:`Conversations`,gsProjects:`Projects`,gsFiles:`Files`,gsNoResults:`No matches`,gsSearching:`Searching…`,gsTruncated:`Too many matches — showing a subset`,gsCurrentProject:`current`,gsOpenPreview:`Open file preview`,gsNavigate:`select`,gsOpen:`open`,gsCloseHint:`close`,bgTaskCommand:`Command`,searchPrev:`Previous (Shift+Enter)`,searchNext:`Next (Enter)`,searchClose:`Close (Esc)`,questionNavTip:`All questions in this conversation — hover to expand, click to jump`,"tpl.title":`Prompt templates`,"tpl.hint":`Click a card to fill the input; ✏️ to edit or delete; add your own too`,"tpl.clickCard":`Click to fill the input`,"tpl.editTpl":`Edit / delete template`,"tpl.openPicker":`Prompt templates (reusable prompts, anytime)`,"tpl.pickerTitle":`Prompt templates`,"tpl.pickerHint":`Click a card to fill the input; ✏️ to edit or delete; add your own too`,"tpl.add":`New template`,"tpl.addDesc":`Save a workflow you use often`,"tpl.reset":`Restore defaults`,"tpl.resetConfirm":`Restore defaults?`,"tpl.builtin":`Built-in`,"tpl.custom":`Custom`,"tpl.newTitle":`New prompt template`,"tpl.editTitle":`Edit prompt template`,"tpl.fieldIcon":`Icon`,"tpl.fieldTitle":`Title`,"tpl.fieldTitlePh":`Short title shown on the card`,"tpl.fieldDesc":`Description`,"tpl.fieldDescPh":`One-liner shown on the card`,"tpl.fieldPrompt":`Prompt`,"tpl.fieldPromptPh":`The full prompt sent to the agent`,"tpl.required":`Title and prompt are required`,"tpl.save":`Save`,"tpl.fill":`Fill input`,"tpl.fillTip":`Fill the input so you can tweak it before sending`,"tpl.sendNow":`Send now`,"tpl.sendTip":`Send immediately as a new conversation`,"tpl.delete":`Delete`,"tpl.deleteTip":`Delete this custom template`,"tpl.remove":`Remove from library`,"tpl.removeTip":`Remove this built-in template; restore later via “Restore defaults”`,"tpl.restore":`Restore default`,"tpl.restoreTip":`Discard your edits and restore the built-in default`,"tpl.sk.setup":`Repo setup`,"tpl.sk.setup.desc":`Give the repo a baseline that other workflows can use`,"tpl.sk.setup.prompt":`Scan this repository and build the baseline context other workflows rely on, then report concisely:
|
|
169
|
-
|
|
170
|
-
1. Project type, tech stack and directory layout
|
|
171
|
-
2. Concrete commands for build / test / run / format
|
|
172
|
-
3. Code conventions and naming rules
|
|
173
|
-
4. Where tasks / issues live and their format
|
|
174
|
-
5. Known pitfalls or leftover issues
|
|
175
|
-
|
|
176
|
-
Report only — do not modify any files.`,"tpl.sk.ask":`Skill navigator`,"tpl.sk.ask.desc":`Tell me which workflow to use`,"tpl.sk.ask.prompt":`I'll describe the situation I'm in; you decide the best workflow (clarify requirements / plan & execute / TDD / debugging / architecture / review / handoff, etc.), explain why you recommend it and how you'd run it, then execute it after I confirm.`,"tpl.sk.grilldocs":`Grill & record`,"tpl.sk.grilldocs.desc":`Interview the plan and record decisions`,"tpl.sk.grilldocs.prompt":`Before starting, grill me about this plan (one question at a time) until we reach shared understanding. Record key terms and settled decisions as you go (e.g. into CONTEXT.md or an ADR file) so all later work shares one vocabulary. Give your recommended answer with each question.`,"tpl.sk.tospec":`To spec`,"tpl.sk.tospec.desc":`Turn the agreed discussion into a written spec`,"tpl.sk.tospec.prompt":`Turn the consensus we reached into a structured specification:
|
|
177
|
-
|
|
178
|
-
1. Background and goals
|
|
179
|
-
2. Explicit goals and non-goals
|
|
180
|
-
3. Users and usage scenarios
|
|
181
|
-
4. Edge cases and failure modes
|
|
182
|
-
5. Acceptance criteria (what counts as done)
|
|
183
|
-
6. Interface / data-shape overview
|
|
184
|
-
|
|
185
|
-
Output the spec for my review first, then continue only after I confirm.`,"tpl.sk.totickets":`To tickets`,"tpl.sk.totickets.desc":`Split the spec into small buildable tickets`,"tpl.sk.totickets.prompt":`Split this spec into a set of small tickets an agent can build one by one:
|
|
186
|
-
|
|
187
|
-
1. Each ticket small enough to be independently accepted
|
|
188
|
-
2. Annotate dependency order (what must come first)
|
|
189
|
-
3. Each ticket has: what to do, acceptance criteria, files involved
|
|
190
|
-
4. Flag which tickets can run in parallel
|
|
191
|
-
|
|
192
|
-
Output the ticket list; I'll confirm the order before you execute.`,"tpl.sk.implement":`Implement spec`,"tpl.sk.implement.desc":`Build the finished spec, test-first`,"tpl.sk.implement.prompt":`Implement per this spec, test-first:
|
|
193
|
-
|
|
194
|
-
1. Write failing tests for each ticket first (happy path, edges, error branches)
|
|
195
|
-
2. Make them pass with the minimal implementation
|
|
196
|
-
3. Refactor while keeping tests green
|
|
197
|
-
4. Proceed ticket by ticket, reporting briefly after each
|
|
198
|
-
|
|
199
|
-
Finally check every acceptance criterion explicitly.`,"tpl.sk.codeview":`Code review`,"tpl.sk.codeview.desc":`Review the diff against the spec and your standards`,"tpl.sk.codeview.prompt":`Review the recently changed diff:
|
|
200
|
-
|
|
201
|
-
1. Against the spec: is the implementation complete and faithful?
|
|
202
|
-
2. Correctness: edges, nulls, concurrency and timing
|
|
203
|
-
3. Security: input validation, injection, sensitive data
|
|
204
|
-
4. Performance & readability: does it follow project conventions?
|
|
205
|
-
5. Tests: are critical paths covered?
|
|
206
|
-
|
|
207
|
-
List issues by severity, each with a concrete suggestion.`,"tpl.sk.wayfinder":`Wayfinder`,"tpl.sk.wayfinder.desc":`Chart a large effort as a map of decisions`,"tpl.sk.wayfinder.prompt":`This is a large task. First chart it as a decision map:
|
|
208
|
-
|
|
209
|
-
1. List every decision point and its dependencies
|
|
210
|
-
2. For each decision give options, trade-offs and your recommendation
|
|
211
|
-
3. Mark what can run in parallel vs. what must be sequential
|
|
212
|
-
4. Output a path plan; I'll confirm each item before you start.`,"tpl.sk.prototype":`Prototype`,"tpl.sk.prototype.desc":`Answer a design question with throwaway code`,"tpl.sk.prototype.prompt":`Write a minimal prototype to validate the design assumption:
|
|
213
|
-
|
|
214
|
-
1. Validate only the key assumption, not the full implementation
|
|
215
|
-
2. Use the simplest means (hard-coding and skipped edge cases are fine)
|
|
216
|
-
3. Run it and tell me the verdict: does the assumption hold? trade-offs?
|
|
217
|
-
4. The prototype can be deleted, or made production-ready only after I confirm.`,"tpl.sk.research":`Research`,"tpl.sk.research.desc":`Get a cited answer from primary sources`,"tpl.sk.research.prompt":`Research this question, preferring primary sources (official docs / source / specs):
|
|
218
|
-
|
|
219
|
-
1. Give an answer with source links
|
|
220
|
-
2. Distinguish facts, reasonable inference, and what's still uncertain
|
|
221
|
-
3. List the main options and their trade-offs
|
|
222
|
-
4. Don't stitch together secondary content; say so if you can't find it.`,"tpl.sk.arch":`Architecture review`,"tpl.sk.arch.desc":`Find the modules worth refactoring (report)`,"tpl.sk.arch.prompt":`Do an architecture review of the whole codebase:
|
|
223
|
-
|
|
224
|
-
1. Find signs of broken deep modules: oversized functions/classes, duplication, poor naming, hidden coupling
|
|
225
|
-
2. Prioritize improvements by severity and blast radius; produce a visual report
|
|
226
|
-
3. For each item give the minimal viable refactor with rationale
|
|
227
|
-
4. Report before changing anything; confirm scope before refactoring.`,"tpl.sk.debug":`Diagnose bugs`,"tpl.sk.debug.desc":`Diagnose from a repro that fails`,"tpl.sk.debug.prompt":`Diagnose this bug systematically:
|
|
228
|
-
|
|
229
|
-
1. Reproduce it first (build a minimal repro if none exists)
|
|
230
|
-
2. Narrow to a specific module via bisection or elimination
|
|
231
|
-
3. Form hypotheses and verify with logs / assertions / a minimal sample — no guessing
|
|
232
|
-
4. Once the root cause is found, explain it, then make the minimal fix
|
|
233
|
-
5. Add a regression test to prevent recurrence.`,"tpl.sk.merge":`Resolve merge conflicts`,"tpl.sk.merge.desc":`Finish a merge or rebase conflict hunk by hunk`,"tpl.sk.merge.prompt":`Help me resolve this merge / rebase conflict:
|
|
234
|
-
|
|
235
|
-
1. Handle each conflict hunk, reading both sides' intent first
|
|
236
|
-
2. Choose or merge to keep correct semantics — don't blindly pick one side
|
|
237
|
-
3. Run tests and build afterwards to confirm
|
|
238
|
-
4. Finally summarize the rationale for each resolution.`,"tpl.sk.triage":`Triage`,"tpl.sk.triage.desc":`Sort raw issues into work someone can pick up`,"tpl.sk.triage.prompt":`Turn these raw issues / feedback into actionable work items:
|
|
239
|
-
|
|
240
|
-
1. Deduplicate and merge related entries
|
|
241
|
-
2. Categorize (bug / feature / improvement / question)
|
|
242
|
-
3. Prioritize by impact and urgency
|
|
243
|
-
4. For each item add: repro info or expectation, acceptance criteria
|
|
244
|
-
|
|
245
|
-
Output the cleaned list.`,"tpl.sk.wizard":`Setup wizard`,"tpl.sk.wizard.desc":`Generate a script that walks a human through setup`,"tpl.sk.wizard.prompt":`Create a guided wizard (script or doc) for a manual setup flow:
|
|
246
|
-
|
|
247
|
-
1. Guide step by step, explaining why at each step
|
|
248
|
-
2. Validate each step; on wrong input give actionable hints
|
|
249
|
-
3. Support undo / going back a step
|
|
250
|
-
4. End with a self-check and how to verify.`,"tpl.sk.grillme":`Grill me`,"tpl.sk.grillme.desc":`Align on an idea before committing`,"tpl.sk.grillme.prompt":`Before starting, interview me relentlessly about every aspect of this idea until we reach shared understanding (one question at a time, each with your recommended answer):
|
|
251
|
-
|
|
252
|
-
1. Goals and non-goals
|
|
253
|
-
2. Users and scenarios
|
|
254
|
-
3. Edge cases and failure modes
|
|
255
|
-
4. Constraints and dependencies
|
|
256
|
-
5. Acceptance criteria
|
|
257
|
-
|
|
258
|
-
Then give an implementation plan and wait for my confirmation before writing code.`,"tpl.sk.handoff":`Handoff`,"tpl.sk.handoff.desc":`Write up a long session so another agent can continue`,"tpl.sk.handoff.prompt":`Turn this session into a handoff doc so another agent / teammate can continue seamlessly:
|
|
259
|
-
|
|
260
|
-
1. Background and goals
|
|
261
|
-
2. Work done and key decisions (with reasons)
|
|
262
|
-
3. Outstanding items and next steps
|
|
263
|
-
4. Known risks and open questions
|
|
264
|
-
5. How to verify current state (commands, etc.)
|
|
265
|
-
|
|
266
|
-
Output as a structured document.`,"tpl.sk.questionnaire":`To questionnaire`,"tpl.sk.questionnaire.desc":`Turn open questions into a doc someone fills in`,"tpl.sk.questionnaire.prompt":`Turn the info you need from someone into a fillable questionnaire:
|
|
267
|
-
|
|
268
|
-
1. Explain the background and purpose of each question
|
|
269
|
-
2. Mark required / optional
|
|
270
|
-
3. Give example answers to lower friction
|
|
271
|
-
4. Group and order: easy first, hard later
|
|
272
|
-
|
|
273
|
-
Output a doc they can fill in directly.`,"tpl.sk.teach":`Teach`,"tpl.sk.teach.desc":`Learn a topic across sessions that build on each other`,"tpl.sk.teach.prompt":`Teach me this topic incrementally:
|
|
274
|
-
|
|
275
|
-
1. First set a learning path and goal
|
|
276
|
-
2. Teach one small section at a time, then a quick exercise
|
|
277
|
-
3. Build on the previous section and ask questions to confirm understanding
|
|
278
|
-
4. Summarize key points at the end of each section
|
|
279
|
-
|
|
280
|
-
Works well across multiple sessions.`,"tpl.sk.ww":`Wait, what?`,"tpl.sk.ww.desc":`Say the last explanation again in plain English`,"tpl.sk.ww.prompt":`Re-explain what you just said in the simplest terms:
|
|
281
|
-
|
|
282
|
-
1. Avoid jargon; define any term you must use in one sentence
|
|
283
|
-
2. Use an analogy or concrete example
|
|
284
|
-
3. Be clear about what is still guesswork / uncertain
|
|
285
|
-
4. Keep the core point as short as possible.`,"tpl.sk.wfa":`Writing for agents`,"tpl.sk.wfa.desc":`Write docs that follow agent-friendly principles`,"tpl.sk.wfa.prompt":`Write this doc / explanation following “written for agents to read” principles:
|
|
286
|
-
|
|
287
|
-
1. Put the goal and usage up front
|
|
288
|
-
2. Make instructions concrete and verifiable — no vagueness
|
|
289
|
-
3. Give positive and negative examples
|
|
290
|
-
4. Structure with headings, steps and checklists
|
|
291
|
-
5. Mark what's required vs. optional.`,"tpl.sk.codesign":`Deep-module design`,"tpl.sk.codesign.desc":`Review & design with deep-module principles`,"tpl.sk.codesign.prompt":`Review / design using the “deep module” principle:
|
|
292
|
-
|
|
293
|
-
1. Check whether each module's public interface is simpler than its implementation
|
|
294
|
-
2. Find modules that leak complexity outward
|
|
295
|
-
3. Give responsibility boundaries and improvement plans
|
|
296
|
-
4. Balance cohesion and reuse without over-abstracting
|
|
297
|
-
|
|
298
|
-
Output the review conclusions and refactor suggestions.`,"tpl.sk.domain":`Domain modeling`,"tpl.sk.domain.desc":`Sharpen the words a project uses and write them down`,"tpl.sk.domain.prompt":`Help me clean up this project's domain language:
|
|
299
|
-
|
|
300
|
-
1. Find the core terms and their current spellings
|
|
301
|
-
2. Spot confusion from same-word-different-meaning / different-word-same-meaning
|
|
302
|
-
3. Recommend one canonical term each, into a glossary
|
|
303
|
-
4. State each term's boundary (what it is not)
|
|
304
|
-
|
|
305
|
-
Output a domain glossary.`,"tpl.sk.grilling":`Grilling`,"tpl.sk.grilling.desc":`Stress-test a plan with an interview`,"tpl.sk.grilling.prompt":`Stress-test this plan with an interview:
|
|
306
|
-
|
|
307
|
-
1. Check each assumption: what if it's wrong?
|
|
308
|
-
2. Hunt for holes: edges, failure modes, dependencies, timing
|
|
309
|
-
3. Challenge decisions: why this way? is there a simpler path?
|
|
310
|
-
4. Ask one sharp question at a time and wait for my answer
|
|
311
|
-
|
|
312
|
-
Keep going until the plan holds up.`,"tpl.sk.tdd":`Test-driven`,"tpl.sk.tdd.desc":`The rules of the red-green-refactor loop`,"tpl.sk.tdd.prompt":`Implement using TDD (red-green-refactor):
|
|
313
|
-
|
|
314
|
-
1. First write failing tests covering the happy path, edge cases and error branches
|
|
315
|
-
2. Make them pass with the minimal implementation
|
|
316
|
-
3. Refactor while keeping tests green
|
|
317
|
-
|
|
318
|
-
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`,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)`,scmQueryFailed:`Git query failed: {error}`,scmQueryFailedShort:`Query failed`,pluginCommandFallback:`Plugin command`,scmTooManyFailures:`Git queries keep failing — click refresh to retry`,scmRunsInTerminal:`Commit / branch switch / push / pull run in the terminal`,scmViewTerminal:`Open terminal`,editProvider:`Edit provider`,builtinProviders:`Built-in providers`,hintKeyOnly:`Just enter an API key`,providerAuthHint:`Choose a supported sign-in method`,oauthLogin:`Sign in with {name}`,oauthLogout:`Sign out`,oauthConnected:`Signed in with {name}`,oauthDeviceCode:`Device code`,oauthOpenVerification:`Open verification page`,oauthContinue:`Continue`,configuredBadge:`✓ Configured`,keyReady:`Key ready`,replaceKey:`Replace key`,replaceKeyTitle:`Replace the saved key`,clearKey:`Clear`,clearKeyTitle:`Remove this provider's key stored in auth.json; it returns to unconfigured (env-var sourced keys can't be cleared here)`,clearKeyConfirm:`Clear the stored key for {id}? Its models will leave the list until you configure it again.`,cloneProvider:`Add key`,cloning:`Adding`,cloneProviderTitle:`Add a second API key for this provider (baseUrl and model list are copied automatically)`,pasteKey:`Paste API key…`,savingKey:`Saving`,saveKey:`Save key`,addKey:`Add key`,addKeyPlaceholder:`Paste the key value…`,keyNamePh:`Name (optional, e.g. backup)`,providerIdPlaceholder:`Provider ID`,baseUrlExamplePh:`baseUrl, e.g. https://api.opencode.ai/zen/v1 or http://127.0.0.1:4096`,saveAllBatch:`Save all ({n})`,netDisconnected:`Network disconnected — reconnect and retry`,advancedEdit:`Advanced edit`,batchCreateProviders:`Batch-create providers ({n} APIs)`,secondKeyTitle:`Add a second key for {api} · {baseUrl} · {n} models — just name the new provider and enter the key.`,noBaseUrlShort:`(no baseUrl)`,providerNameLabel:`Provider name`,providerNameHint:`(new ID, e.g. opencode-2)`,apiKeyLabel:`API key`,secondKeyPlaceholder:`sk-… second key`,batchDesc:`This provider has multiple APIs ({apis}); it was split into {n} custom providers. Save each so all models (e.g. muse-spark) work. Enter one shared second key to save all at once.`,batchKeyLabel:`Shared API key (applies to all {n} providers)`,modelsCountShort:`{n} models: `,noKeyYet:`No key yet — add one to use this provider`,activateKey:`Set active`,removeKey:`Remove`,removeKeyConfirm:`Remove this key? It must be re-configured to be used again.`,customProviders:`Custom providers`,customDesc:`For Ollama / vLLM / OpenAI-compatible proxies, etc. Written to pi's models.json — hot-reloaded immediately.`,noCustomProviders:`No custom providers yet`,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.`,refreshBuiltinCatalog:`Force-refresh official catalogs`,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`,appendModelTitle:`A new model not yet in the official catalog (e.g. a freshly released Union model) — add it to this provider to use it right away; once the official catalog lists it, a force-refresh graduates the row to the official config automatically`,appendModelIdPh:`Model ID, e.g. union-alpha-free`,appendModelNamePh:`Display name (optional)`,appendModelAdd:`Add`,appendModelBusy:`Adding…`,appendModelCancel:`Cancel`,appendModelOk:`Added, model picker updated`,appendModelFail:`Failed to add`,appendModelApiTitle:`API type: leave blank to inherit from the provider's existing models`,appendModelApiAuto:`API: auto-inherit`,appendModelBaseUrlPh:`Base URL (optional, inherited by default, e.g. https://opencode.ai/zen/go)`,modelsCount:`{n} models`,addProvider:`Add provider`,providerId:`Provider ID`,providerIdHint:`(required, e.g. ollama / my-proxy)`,displayName:`Display name`,displayNamePh:`My proxy`,apiType:`API type`,baseUrlHint:`(OpenAI-compatible endpoint)`,apiKeyHint:`sk-… (optional — uses the auth.json key)`,authHeader:`Auto-add Authorization header`,modelsTitle:`Models`,modelIdReq:`Model ID (required)`,text:`Text`,textImage:`Text+image`,contextWindow:`Context`,maxOutput:`Max output`,removeModel:`Remove model`,addModel:`Add model`,deleteProviderConfirm:`Delete provider {id} and its {n} models?`,fetchModels:`Fetch model list`,fetchModelsHint:`Pull model IDs from the baseUrl /models endpoint (server-side, no CORS)`,fetchingModels:`Fetching…`,fetchModelsOk:`Fetched {n} models`,fetchModelsEmpty:`The endpoint returned no models`,fetchModelsErr:`Fetch failed: {msg}`,fetchModelsNeedBaseUrl:`Enter a baseUrl first`,antigravityTemplateTitle:`Quick templates`,antigravityTemplateDesc:`Local Antigravity-Manager proxy (port 8045): fills in the endpoint — just paste your API key, then hit Fetch model list.`,antigravityFillOpenAI:`Fill Antigravity (OpenAI)`,antigravityFillAnthropic:`Fill Antigravity (Anthropic)`,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)`,enrichHintPh:`Optional evidence, one per line: model id = catalog id or model page URL (e.g. claude-sonnet-4-5-thinking = anthropic/claude-sonnet-4-5); blank = auto-match`,enrichingModels:`Enriching…`,enrichModelsCancel:`Cancel`,enrichModelsAbort:`Abort enrichment`,enrichCancelling:`Cancelling…`,enrichModelsCancelled:`Model enrichment cancelled`,enrichModelsOk:`Enriched {n}, unmatched {m}`,enrichModelsErr:`Enrich failed: {msg}`,enrichModelsNeedIds:`Enter at least one model id`,goalBarTitle:`Goal`,goalBarPlaceholder:`Set a goal; the agent's output is auto-reviewed…`,goalBarSet:`Start`,goalBarClear:`Cancel`,goalBarLocked:`Locked: applies to every later turn`,goalBarUnlocked:`This turn only (cleared afterwards)`,goalBarReviewModel:`Review model`,goalBarUseMainModel:`Use the main model`,goalBarMaxRounds:`Max rounds`,goalBarMaxRoundsTip:`Max review-revision rounds; 0 or empty = unlimited (keep revising until it passes)`,goalBarUnlimitedShort:`Unlimited`,goalBarReviewing:`Reviewing…`,goalBarRound:`Round {n}`,goalBarActive:`Goal active`,goalBarPassed:`Passed`,goalBarFailed:`Failed`,goalBarStatusPending:`Waiting to generate…`,goalWizardBtn:`AI Scrape`,goalWizardTip:`Let AI refine the requirement into a goal via a Q&A survey`,goalWizardRunning:`Scoping the goal`,goalWizardAnswer:`Answer`,goalWizardCard:`Goal survey`,settings:`Settings`,settingsTitle:`Settings`,settingsDesc:`Changes apply immediately: system prompt, skill and extension toggles rebuild the current session; review instructions and review skills affect later goal reviews (main-session changes are deferred while streaming).`,settingsSystemPrompt:`System prompt`,settingsPromptHistory:`Input history`,settingsPromptHistoryDesc:`Cycle previous prompts with ↑/↓ in the input — global across conversations (localStorage)`,promptHistoryMax:`Max entries`,promptHistoryMaxHint:`Oldest entries are dropped when exceeded (1–500)`,promptHistoryCharLimit:`Limit characters per entry`,promptHistoryCharLimitHint:`When enabled, overlong prompts are truncated before saving`,promptHistoryCharLimitPlaceholder:`Max chars (100–20000)`,promptHistoryClear:`Clear history`,promptHistoryClearConfirm:`Confirm clear?`,promptHistoryCleared:`Input history cleared`,promptHistoryCount:`{n} entries`,promptHistoryEmpty:`No history yet — ↑/↓ has nothing to cycle`,settingsPromptMode:`Mode`,promptModeAppend:`Append`,promptModeReplace:`Replace`,promptAppendHint:`Append mode: your text is appended to the end of the default system prompt (recommended — keeps the default behavior constraints).`,promptReplaceHint:`Replace mode: only the built-in template's persona (soul) paragraph is replaced (e.g. "You are an expert coding assistant…"). The tools list, guidelines, docs pointers, project context and skills are auto-assembled on every run and are never replaced. After switching, the editor shows the built-in soul paragraph; leaving it empty keeps the built-in default.`,promptPlaceholder:`Type a custom system prompt… (applied on blur)`,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)`,promptReadonlyLockedBadge:`Custom override (read-only/locked)`,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`,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:`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.`,settingsSkills:`Skills`,settingsReview:`Goal review`,settingsReviewDesc:`Configure extra instructions and skills for the isolated goal-review session; the main session is unaffected.`,settingsReviewSkills:`Skills available to review`,reviewPromptPlaceholder:`Type custom review instructions… (applied on blur)`,reviewPromptHint:`These instructions are added to the review task; pass/fail JSON output is still enforced. Skill toggles apply only to review.`,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.`,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)`,settingsTerminalTools:`Terminal tools`,terminalToolsEnabled:`Enable persistent terminal tools`,settingsTerminalToolsDesc:`Let the AI use the built-in terminal for interactive programs (REPLs/vim), long-running servers, continuous output watching, or when you ask it to work in the visible terminal; ordinary commands still go through the one-shot bash tool`,terminalToolsOffHint:`Disabled: the AI has no terminal_* tools and receives no usage guidance`,settingsEditTools:`Edit tools`,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 张三 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`,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)`,toolsSubagentDepHint:`Toggled individually: with subagent_spawn off, the rest (wait/get/steer/stop) have no sessions to manage and only return empty lists or “not found”; delegate_task rides the spawn channel, so it cannot dispatch with spawn off.`,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_spawn 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)`,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)`,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)`,visionBridgePromptAppendHint:`Append mode: custom text is appended after the built-in transcription prompt (recommended — keeps the verbatim-transcription contract).`,visionBridgePromptReplaceHint:`Replace mode: custom text replaces the built-in transcription prompt entirely. After switching, the editor shows the built-in default prompt ready to edit; blurring without changes keeps the default.`,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)`,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`,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.`,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`,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`,uiLayoutSearch:`Filter entries…`,uiLayoutMovedFrom:`moved from`,uiLayoutAlign:`Align`,uiLayoutRename:`Rename`,uiLayoutRestore:`Restore`,uiLayoutRestoreAll:`Restore all`,uiLayoutArranged:`Changed by a plugin`,uiLayoutEmpty:`(none)`,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
|
-
|
|
320
|
-
{path}`,pluginGrantAllow:`Allow`,pluginGrantDeny:`Deny`,pluginPermTitle:`A plugin requests capability access`,pluginPermBodyNet:`{plugin} wants to reach these network hosts (no reinstall needed):
|
|
321
|
-
|
|
322
|
-
{hosts}`,pluginPermBodyLlm:`{plugin} wants to call a model{models} (spends your model quota)`,pluginPermOnce:`Allow once`,pluginPermAlways:`Remember & allow`,pluginPermsTitle:`Granted capabilities`,pluginPermsHint:`Runtime capability scopes granted to plugins (network hosts / model scope). Revoke per item; session-only grants expire on restart.`,pluginPermsEmpty:`No dynamic grants yet`,pluginPermSession:`Session only`,pluginPermNet:`Network`,pluginPermLlm:`Model`,pluginPermUnscoped:`Unscoped`,pluginUiNoHandler:`The plugin does not handle this action (version mismatch?)`,pluginSessionGrantTitle:`A plugin wants to open a project session`,pluginSessionGrantBody:`The plugin wants to open a new session in this directory (the workspace will switch):
|
|
323
|
-
|
|
324
|
-
{path}
|
|
325
|
-
|
|
326
|
-
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`,dshPresetCurrent:`current`,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)`,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`,schedulerNameLabel:`Task name`,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)`,schedulerPromptLabel:`Prompt`,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 the settings above, then 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`,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)`,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.`},Mt=[{code:`zh`,nativeName:`中文`},{code:`en`,nativeName:`English`}],Nt={};function Pt(e){return!e||typeof e.code!=`string`||!e.code||e.code===`zh`||e.code===`en`||!e.strings||typeof e.strings!=`object`?!1:(Nt[e.code]=e,!0)}function Ft(e){delete Nt[e]}function It(e){return e===`zh`?`中文`:e.toUpperCase()}function Lt(e){return e===`zh`?`zh-CN`:e===`pt`?`pt-BR`:e}async function Rt(e){let t=await fetch(Et(St(e)));if(!t.ok)throw Error(`HTTP ${t.status} for ${e}`);return await t.json()}var zt=(0,f.createContext)(null);function Bt(){try{return localStorage.getItem(kt)}catch{return null}}function Vt(){return Ot(Bt(),typeof navigator<`u`?navigator.languages:[],null)}function Ht({children:e}){let[t,n]=(0,f.useState)(Vt),[r,i]=(0,f.useState)(0),a=(0,f.useRef)(t);a.current=t;let o=(0,f.useCallback)(e=>{n(e);try{localStorage.setItem(kt,e)}catch{}try{window.dispatchEvent(new CustomEvent(`pi-web-ui:locale`,{detail:e}))}catch{}},[]),s=(0,f.useCallback)(async()=>{let e,t=null;try{let n=await Rt(`/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 Rt(`/api/locales/${e.code}`);return Pt({code:t.code||e.code,nativeName:t.nativeName||e.nativeName,strings:t.strings}),!0}catch{return!1}})),i(e=>e+1),t},[]);(0,f.useEffect)(()=>{s().then(e=>{if(!Bt()?.trim()){let t=Ot(null,typeof navigator<`u`?navigator.languages:[],e);t!==a.current&&(a.current=t,n(t))}let t=a.current;if(t!==`zh`&&t!==`en`&&!Nt[t]){let t=Ot(null,typeof navigator<`u`?navigator.languages:[],e,[`zh`,`en`]);a.current=t,n(t);try{localStorage.setItem(kt,t)}catch{}}})},[s]);let c=(0,f.useMemo)(()=>[...Mt,...Object.values(Nt).map(e=>({code:e.code,nativeName:e.nativeName}))],[r]),l=(0,f.useCallback)((e,n)=>{let r=Nt[t]?.strings[e]??(t===`zh`?At[e]:jt[e]);if(n)for(let[e,t]of Object.entries(n))r=r.replaceAll(`{${e}}`,String(t));return r},[t,r]);(0,f.useEffect)(()=>{document.documentElement.lang=Lt(t)},[t]);let u=(0,f.useMemo)(()=>({locale:t,setLocale:o,t:l,packs:c,reloadPacks:s}),[t,o,l,c,s]);return(0,X.jsx)(zt.Provider,{value:u,children:e})}function Ut(){let e=(0,f.useContext)(zt);if(!e)throw Error(`useI18n must be used within LanguageProvider`);return e}function Z(){return Ut().t}var Wt=[{kind:`question`,labelKey:`sound.question`,descKey:`sound.question.desc`},{kind:`done`,labelKey:`sound.done`,descKey:`sound.done.desc`},{kind:`start`,labelKey:`sound.start`,descKey:`sound.start.desc`},{kind:`error`,labelKey:`sound.error`,descKey:`sound.error.desc`}];function Gt({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)(N,{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})})]}),Wt.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 Kt(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 qt=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost),Jt=null,Yt=0;function Xt(){return Jt?.available===!0?Jt.pages??[]:[]}function Zt(){Date.now()-Yt<5e3||Qt().catch(()=>{})}async function Qt(){if(Kt())return{available:!1,pages:[],desktop:!0,error:`桌面版不支持浏览器操作:窗口里没有 Chrome 扩展运行时,请改用系统浏览器打开同一个地址(网页版)`};let e=qt();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&&(Jt=r,Yt=Date.now()),r}catch(e){return{available:!1,pages:[],error:e instanceof Error?e.message:String(e)}}}function $t(e){return e.length===1?e[0]:null}function en(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:`page`,key:`page:${e.origin}`}}async function tn(){let e=qt();if(!e)return!1;try{return(await e({op:`openOptions`,timeoutMs:5e3})).ok===!0}catch{return!1}}function nn(e=45e3){let[t,n]=(0,f.useState)(null),r=(0,f.useRef)(!0),i=(0,f.useCallback)(async e=>{let t=await Qt();r.current&&(n(t),e&&!t.available&&setTimeout(()=>{r.current&&i(!1)},1500))},[]);return(0,f.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 rn=null,an=null,on=null;function sn(e){rn=e}function cn(e){an=e}function ln(e){on=e}function un(){return on?(on(),!0):!1}function Q(){return!!(rn||an)}function dn(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&&!rn||i&&!an?!1:(i&&an?.(n),r&&rn?.(t),!0)}function fn(){let e=Z(),{status:t,refresh:n}=nn(),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(null),s=(0,f.useRef)(null),c=t?.pages??[],l=t?.available===!0&&(c.length===0||t.aiControl===!1),u=$t(c),d=e=>{o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>o(null),2600)},p=t=>{let n=dn({attachments:[en(t)]});d(e(n?`browserControlCited`:`browserControlCiteFailed`))},m=()=>{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:()=>p(u),children:[(0,X.jsx)(de,{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:m,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:m,children:[(0,X.jsx)(de,{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)(pn,{status:t,onRefresh:n,onCite:p,onClose:()=>i(!1)})]})}function pn({status:e,onRefresh:t,onCite:n,onClose:r}){let i=Z(),[a,o]=(0,f.useState)(!1),s=e?.pages??[],c=async()=>{o(!0);try{await tn()||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)(de,{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 mn=[`terminal_create`,`terminal_list`,`terminal_close`,`terminal_input`,`terminal_key`,`terminal_read`,`terminal_wait`],hn=[`subagent_spawn`,`subagent_get_result`,`subagent_steer`,`subagent_list`,`subagent_stop`,`subagent_wait_all`,`subagent_templates`],gn=`edit_soft`,_n=`delegate_task`,vn=`ask_user_question`,yn=`todo_list`,bn=`browser_page`,xn=`conversation_read`,Sn=`skill`,Cn=`schedule_task`,wn=`schedule_list`,Tn=`schedule_cancel`,En=`present_files`,Dn=`claim_files`,On=[...mn.map(e=>({name:e,group:`terminal`,defaultOn:!1,dshVisible:!0})),...hn.map(e=>({name:e,group:`subagent`,defaultOn:!0,dshVisible:!1})),{name:gn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`editSoftEnabledDesc`,offHintKey:`editSoftOffHint`},{name:_n,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`delegateTaskEnabledDesc`,offHintKey:`delegateTaskOffHint`},{name:vn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`questionnaireEnabledDesc`,offHintKey:`questionnaireOffHint`},{name:bn,group:`other`,defaultOn:!1,dshVisible:!1,descKey:`browserPageEnabledDesc`,offHintKey:`browserPageOffHint`},{name:xn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`conversationReadEnabledDesc`,offHintKey:`conversationReadOffHint`},{name:Dn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`claimFilesEnabledDesc`,offHintKey:`claimFilesOffHint`},{name:En,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`presentFilesEnabledDesc`,offHintKey:`presentFilesOffHint`},{name:Sn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`skillEnabledDesc`,offHintKey:`skillOffHint`},{name:Cn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:wn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:Tn,group:`other`,defaultOn:!0,dshVisible:!1,descKey:`scheduleTaskEnabledDesc`,offHintKey:`scheduleTaskOffHint`},{name:yn,group:`other`,defaultOn:!0,dshVisible:!0,descKey:`todoListEnabledDesc`,offHintKey:`todoListOffHint`}];new Set(On.map(e=>e.name));var kn=`pi-web-notify`,An={enabled:!1};function jn(){try{let e=localStorage.getItem(kn);if(!e)return{...An};let t=JSON.parse(e);return{enabled:typeof t.enabled==`boolean`?t.enabled:An.enabled}}catch{return{...An}}}function Mn(e){try{localStorage.setItem(kn,JSON.stringify(e))}catch{}}function Nn(){return typeof window<`u`&&`Notification`in window}function Pn(){return Nn()?null:typeof window<`u`&&window.isSecureContext===!1?`insecure`:`unsupported`}function Fn(e){let{screenX:t,screenY:n,outerWidth:r,outerHeight:i}=e;return Number.isFinite(t)&&In(t)||Number.isFinite(n)&&In(n)?!0:r>0&&r<=400&&i>0&&i<=40}function In(e){return e<=-1e4}function Ln(e){return!(e.visibility!==`visible`||e.minimized||!e.hasFocus||e.windows&&e.idleMs>12e4)}var Rn=Date.now(),zn=!1;function Bn(){Rn=Date.now()}function Vn(){return Math.max(0,Date.now()-Rn)}function Hn(){if(zn||typeof window>`u`)return;zn=!0;let e={passive:!0,capture:!0};for(let t of[`pointerdown`,`pointermove`,`keydown`,`wheel`,`touchstart`,`focus`,`scroll`])window.addEventListener(t,Bn,e);typeof document<`u`&&document.addEventListener(`visibilitychange`,Bn,e)}function Un(){return typeof navigator>`u`?!1:/windows/i.test(navigator.userAgent??``)}function Wn(){return Hn(),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:Fn({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Vn(),windows:Un()}}function Gn(){return Nn()?Notification.permission:`denied`}async function Kn(){if(!Nn())return`denied`;try{return await Notification.requestPermission()}catch{return`denied`}}function qn(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Jn(e,t=!1){return{body:e,requireInteraction:t,icon:St(`/icons/icon-192.png`),badge:St(`/icons/icon-192.png`),data:{url:typeof location<`u`?location.href:St(`/`)}}}async function Yn(e,t,n=!1){if(!Nn())return{path:`none`,error:`unsupported`};if(Notification.permission!==`granted`)return{path:`none`,error:`permission: ${Notification.permission}`};let r=Jn(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=qn(e)}try{return new Notification(e,r),{path:`page`,error:i}}catch(e){return{path:`none`,error:`${i}; page: ${qn(e)}`}}}async function Xn(e,t){Nn()&&(Ln(Wn())||jn().enabled&&await Yn(e,t))}var Zn=!1;function Qn(){let e=Z(),[t,n]=(0,f.useState)(jn),[r,i]=(0,f.useState)(()=>Gn()),[a,o]=(0,f.useState)(null),s=Pn(),c=s!==null,l=Un();(0,f.useEffect)(()=>{let e=()=>i(Gn());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),Mn(r),e){let e=await Kn();if(i(e),e!==`granted`){let e={...r,enabled:!1};n(e),Mn(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)(Ze,{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`)}),Zn]})}var $n=new Set([`svg`,`g`,`path`,`circle`,`rect`,`line`,`polyline`,`polygon`,`ellipse`,`use`,`defs`,`clipPath`,`linearGradient`,`radialGradient`,`stop`]),er=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(`.`)),tr=new Set([`script`,`style`,`title`,`desc`,`foreignobject`]),nr=new Set([...$n].map(e=>e.toLowerCase())),rr=new Set([...er].map(e=>e.toLowerCase()));function ir(e){return nr.has(e.toLowerCase())}function ar(e){return rr.has(e.toLowerCase())}function or(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(!ir(e)){tr.has(e)?t.remove():(i(t),t.replaceWith(...t.childNodes));continue}for(let e of[...t.attributes]){let n=e.name.toLowerCase();(!ar(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();(!ar(t)||/^on/i.test(t))&&r.removeAttribute(e.name)}return i(r),new XMLSerializer().serializeToString(r)}function sr({icon:e,iconSvg:t,className:n}){let r=or(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 cr=[`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`],lr=[{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: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: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-edit-reask`,slot:`message.actions`,labelKey:`editReask`,icon:`edit`,kind:`action`,order:10},{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: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-inline`,slot:`file.preview.toolbar`,labelKey:`attachInlineTip`,icon:`plus`,kind:`action`,order:60},{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-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-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:lp-projects`,slot:`leftpanel.sessions`,labelKey:`recentProjects`,icon:`folder`,kind:`action`,order:10},{id:`host:lp-running`,slot:`leftpanel.sessions`,labelKey:`runningConversations`,icon:`activity`,kind:`action`,order:20},{id:`host:lp-history`,slot:`leftpanel.sessions`,labelKey:`historySessions`,icon:`clock`,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-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-inline`,slot:`contextmenu.file`,labelKey:`attachInlineTip`,icon:`plus`,kind:`action`,context:`file`,order:31,group:`chat`},{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:tool-info`,slot:`contextmenu.toolcall`,labelKey:`toolInfoMenuLabel`,icon:`info`,kind:`action`,context:`toolcall`,order:10}],ur=new Set([`host:lp-projects`,`host:lp-running`,`host:lp-history`]),dr=`__view`,fr=new Set([`host:settings`]);function pr(e){return`${e}:${dr}`}function mr(e){return e.source.startsWith(`plugin:`)?e.id===pr(e.source.slice(7)):!1}function hr(e,t,n){let r=pr(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 gr(e,t){let n=t.map(pr),r=new Set(n),i=(e?.order??[]).filter(e=>!r.has(e));return{...e,order:[...i,...n]}}var _r=`host:brand`,vr=[`host:brand-logo`,`host:brand-name`];function yr(e){if(!((e.hidden??[]).some(e=>vr.includes(e))||(e.shown??[]).some(e=>vr.includes(e))||(e.order??[]).some(e=>vr.includes(e))||vr.some(t=>e.align?.[t]!==void 0)||vr.some(t=>e.groups?.[t]!==void 0)||vr.some(t=>e.labels?.[t]!==void 0)))return e;let t=e=>{if(!e)return;let t=[];for(let n of e){let e=vr.includes(n)?_r: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))vr.includes(t)||(n[t]=r);if(n[`host:brand`]===void 0){let r=t?e[vr[0]]??e[vr[1]]:e[vr[1]]??e[vr[0]];r!==void 0&&(n[_r]=r)}return n},r=e=>{if(!e)return;let t={};for(let[n,r]of Object.entries(e))vr.includes(n)||(t[n]=r);if(t[`host:brand`]===void 0){let n=e[vr[0]]??e[vr[1]];n!==void 0&&(t[_r]=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)}:{}}}function br(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:dr,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 xr(e){return typeof e==`string`&&cr.includes(e)}function Sr(e,t){return t?e.label:e.labelEn??e.label}function Cr(e,t){return t?e.hint??e.hintEn:e.hintEn??e.hint}function wr(e,t,n,r,i){let a=`${e}#${r.id}`,o=Tr(a,t,n,r.children,i),s=Cr(r,i),c=Er(r.options,i);return{id:a,slot:t,source:n,label:Sr(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 Tr(e,t,n,r,i){return r?.length?r.map((r,a)=>({entry:wr(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 Er(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 Dr(e){if(e===void 0)return;let t=Number(e);return Number.isFinite(t)?Math.min(100,Math.max(0,t)):0}function Or(e,t,n,r,i,a){let o=Tr(e,t,n,r.children,i),s=Cr(r,i),c=Dr(r.progress),l=Er(r.options,i);return{id:e,slot:t,source:n,label:Sr(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 kr(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 Ar(e){let t=e.filter(e=>mr(e));if(t.length===0)return e;let n=e.filter(e=>!mr(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 jr(e,t){let n=t.locale===`zh`,r=new Set(t.disabledPlugins??[]),i=yr(t.layout??{}),a=new Map,o=0;for(let e of lr)a.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:o++});for(let t of e){if(t.error||r.has(t.id))continue;let e=`plugin:${t.id}`;for(let r of t.ui?.items??[]){if(!xr(r.slot))continue;let i=`${t.id}:${r.id}`,s=a.get(i);a.set(i,Or(i,r.slot,e,r,n,s?.seq??o++))}}for(let t of e)if(!(t.error||r.has(t.id)))for(let e of t.ui?.arrange??[])Nr(a,e,t.id);let s=new Map,c=(e,t)=>{let n=s.get(e)??[];n.includes(t)||n.push(t),s.set(e,n)};for(let e of i.hidden??[]){let t=a.get(e);t&&(t.hidden=!0,c(e,`hidden`))}for(let e of i.shown??[]){let t=a.get(e);t&&(t.hidden=!1,c(e,`hidden`))}for(let[e,t]of Object.entries(i.groups??{})){let n=a.get(e);n&&(n.group=t,c(e,`group`))}for(let[e,t]of Object.entries(i.align??{})){let n=a.get(e);!n||t!==`start`&&t!==`center`&&t!==`end`||(n.align=t,c(e,`align`))}for(let[e,t]of Object.entries(i.labels??{})){let n=a.get(e);n&&(n.label=t,c(e,`label`))}for(let e of fr){let t=a.get(e);t&&(t.slot=`topbar.primary`,t.hidden=!1)}let l=new Map;(i.order??[]).forEach((e,t)=>{a.has(e)&&(l.has(e)||l.set(e,t),c(e,`order`))});let u=new Map;for(let e of cr)u.set(e,[]);for(let e of a.values())u.get(e.slot)?.push(e);let d={};for(let e of cr){let t=kr(u.get(e)??[],l);d[e]=(e===`topbar.primary`?Ar(t):t).map(e=>Mr(e,s.get(e.id)??[]))}return d}function Mr(e,t){let n={...e,userOverrides:t};return delete n.seq,n}function Nr(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&&xr(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 Pr(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 Fr(e,t){let n=e??{},r={},i=t===`host:brand`?[t,...vr]:[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=Lr(n.groups,t),l=Lr(n.labels,t),u=Lr(n.align,t);if(t===`host:brand`)for(let e of vr)c=Lr(c,e),l=Lr(l,e),u=Lr(u,e);return c&&(r.groups=c),l&&(r.labels=l),u&&(r.align=u),n.topbarText!==void 0&&(r.topbarText=n.topbarText),r}function Ir(){return{}}function Lr(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 Rr=new Set([`host:files`]);function zr(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 Br(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 Vr=null,Hr=new Set;function Ur(){for(let e of Hr)e()}function Wr(e){Vr={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}:{}},Ur()}function Gr(){Vr!==null&&(Vr=null,Ur())}function Kr(e){return Hr.add(e),()=>{Hr.delete(e)}}function qr(){return Vr}function Jr(){return(0,f.useSyncExternalStore)(Kr,qr,qr)}function Yr(e){return Number.isFinite(e)?e:0}function Xr(e,t,n,r,i,a){let o=Math.max(0,Yr(n)),s=Math.max(0,Yr(r)),c=Math.max(8,Yr(i)-o-8),l=Math.max(8,Yr(a)-s-8);return{x:Math.min(Math.max(8,Yr(e)),c),y:Math.min(Math.max(8,Yr(t)),l)}}function Zr(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 Qr(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 $r(e,t){return!e||Qr(e.when,t)}function ei(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 ti(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 ni(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 ri(e,t){return!e||e.kind===`divider`||e.hidden===!0?!1:!$r(e,t)}function ii(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,ri(e[o],r))return o;return-1}var ai={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:`〜`};function oi(e){let t=(e??``).trim();return t?ai[t.toLowerCase()]||(/[^\p{L}\p{N}\s]/u.test(t)&&t.length<=4?t:``):``}var si={engine:`pi`,managed:!1,status:`connecting`,ready:!1,cwd:``,workspaceRoots:[],homeDir:``,desktopDir:``},ci=new Set;function li(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n])}function ui(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&&li(e.workspaceRoots,t.workspaceRoots)&&e.homeDir===t.homeDir&&e.desktopDir===t.desktopDir&&li(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function di(e){let t={...si,...e};if(!ui(si,t)){si=t;for(let e of ci)e()}}function fi(e){return ci.add(e),()=>{ci.delete(e)}}function pi(){return si}function mi(){return(0,f.useSyncExternalStore)(fi,pi,pi)}function hi(e){return(0,f.useSyncExternalStore)(fi,()=>si[e],()=>si[e])}function gi(){return hi(`engine`)===`dsh`}function _i(){return hi(`managed`)}function vi(){return hi(`service`)}var yi=null;function bi(e){yi=e}var $=e=>yi?yi(e):!1,xi=`@root`,Si=e=>e.endsWith(`/`)?e:e+`/`;function Ci(e,t){let n=t.trim(),r=e.replace(/\\/g,`/`);return r.endsWith(`/`)?r+n:(/^[A-Za-z]:$/.test(r),r+`/`+n)}function wi(e){let t=e.trim();return!(!t||t===`.`||t===`..`||t.includes(`/`)||t.includes(`\\`))}var Ti=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)?xi:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};function Ei({open:e,currentCwd:t,pathCompletions:n,workspaceRoots:r,onClose:i,onSelectDirectory:a,onCreateProject:o}){let s=Z(),[c,l]=(0,f.useState)(``),[u,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(null),[y,b]=(0,f.useState)(-1),x=(0,f.useRef)(null),S=(0,f.useRef)(null),C=n.filter(e=>e.type===`dir`);if((0,f.useEffect)(()=>{if(e){let e=(t||``).replace(/\\/g,`/`);l(e),d(e),m(!1),g(``),v(null),b(-1)}},[e,t]),(0,f.useEffect)(()=>{if(e){let e=requestAnimationFrame(()=>{x.current?.focus()});return()=>cancelAnimationFrame(e)}},[e]),(0,f.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(p?(m(!1),g(``),v(null)):i())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,p,i]),(0,f.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{$({type:`complete_path`,path:Si(c)})},60);return()=>clearTimeout(t)},[c,e]),(0,f.useEffect)(()=>{if(!e||u===c)return;let t=setTimeout(()=>{$({type:`complete_path`,path:u})},150);return()=>clearTimeout(t)},[u,c,e]),!e)return null;let w=e=>{let t=e.trim();t&&t!==`@root`&&(a(t),i())},T=()=>{let e=h.trim();if(!wi(e)){v(s(`invalidProjectName`));return}o(Ci(c,e)),m(!1),g(``),v(null),i()},E=e=>{if(e.key===`Escape`)e.stopPropagation(),p?(m(!1),g(``),v(null)):i();else if(e.key===`Enter`&&!e.nativeEvent.isComposing)w(u);else if(e.key===`Tab`){if(C.length===0)return;e.preventDefault();let t=y>=0?(y+1)%C.length:0;b(t),d(C[t].path),l(C[t].path)}},D=Ti(c),O=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},k=O(c),A=!!c&&c!==`@root`&&k!==O(t)&&!r.some(e=>O(e)===k);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop project-picker-backdrop`,onClick:i}),(0,X.jsxs)(`div`,{className:`cwd-picker project-picker`,role:`dialog`,"aria-label":s(`projectPickerTitle`),children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:c===`@root`?s(`computer`):c,children:[c===`@root`?`💻`:(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{children:c===`@root`?s(`computer`):c})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:c===xi,title:s(`computer`),onClick:()=>{l(xi),d(xi),b(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!D,title:s(`cwdGoUp`),onClick:()=>{D&&(l(D),d(D),b(-1))},children:[`↑ `,s(`cwdGoUp`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!A,title:s(`addWorkspaceRootHint`),onClick:()=>{A&&$({type:`set_workspace_roots`,roots:[...r,c]})},children:[`+ `,s(`addWorkspaceRoot`)]})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:x,className:`status-cwd-input cwd-picker-input`,value:u,placeholder:s(`enterPath`),spellCheck:!1,onChange:e=>{d(e.target.value),b(-1)},onKeyDown:E}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:s(`cwdPickCurrent`),disabled:c===xi,onClick:()=>w(c),children:s(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[C.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:s(`cwdEmpty`)}),C.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${s(`cwdEnter`)} ${e.path}`,onClick:()=>{l(e.path),d(e.path),b(-1)},children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:s(`cwdChoose`),onClick:()=>w(e.path),children:s(`cwdChoose`)})]},e.path))]}),(0,X.jsxs)(`div`,{className:`cwd-picker-foot`,children:[p?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:S,value:h,autoFocus:!0,spellCheck:!1,placeholder:s(`projectName`),onChange:e=>{g(e.target.value),_&&v(null)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),T()):e.key===`Escape`&&(e.stopPropagation(),m(!1),g(``),v(null))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:T,children:s(`createAndOpenProject`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{m(!1),g(``),v(null)},children:s(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>m(!0),children:[`+ `,s(`newProject`)]}),_&&(0,X.jsx)(`div`,{className:`project-picker-error`,style:{color:`var(--red)`,fontSize:`11px`,marginTop:`4px`},children:_})]})]})]})}function Di(e){return T({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 Oi(e){return T({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 ki(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 Ai(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,f.useRef)(null),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(i);(0,f.useLayoutEffect)(()=>{m.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=ki(i,{width:n.width,height:n.height},{width:window.innerWidth,height:window.innerHeight},{align:o,side:s,gap:c,margin:l});p(e=>e?.x===a.x&&e?.y===a.y?e:a)};return(0,f.useLayoutEffect)(()=>{t?_():p(null)},[t,n,r,o,s,c,l]),mt(()=>{m.current()},t),(0,f.useEffect)(()=>{if(!t)return;let e=e=>e instanceof Node&&!!(u.current?.contains(e)||g()?.contains(e)||a?.(e)),n=t=>{e(t.target)||m.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 ji({anchorRect:e,anchorEl:t,plugins:n,pinnedIds:r,orderedPluginIds:i,onTogglePin:a,onReorder:o,onOpenView:s,onManagePlugins:c,onClose:l}){let{t:u}=Ut(),{panelRef:d,style:p,measure:m}=Ai({anchor:e,anchorEl:t,onClose:l}),[,h]=(0,f.useState)(null),g=(0,f.useRef)(null),[_,v]=(0,f.useState)(null),y=(0,f.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,f.useLayoutEffect)(()=>{m()},[y,m]);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,D.createPortal)((0,X.jsxs)(`div`,{ref:d,className:`pm-panel`,role:`menu`,"aria-label":u(`pluginMenuTitle`),style:p,children:[(0,X.jsxs)(`div`,{className:`pm-head`,"aria-hidden":`true`,children:[(0,X.jsx)(Ye,{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)(G,{"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)(sr,{icon:o,iconSvg:e.iconSvg,className:`pm-icon`}):(0,X.jsx)(Ye,{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)(Oi,{"aria-hidden":!0}):(0,X.jsx)(Di,{"aria-hidden":!0})})]},e.id)})}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`pm-manage`,onClick:()=>{l(),c()},children:[(0,X.jsx)(re,{"aria-hidden":!0}),(0,X.jsx)(`span`,{children:u(`pluginMenuManage`)})]})]}),document.body)}function Mi({onClose:e}){let t=Z(),{locale:n,setLocale:r,reloadPacks:i}=Ut(),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(``),[l,u]=(0,f.useState)(``);async function d(){try{let e=await fetch(Et(St(`/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,f.useEffect)(()=>{d()},[]);async function p(e){u(e),c(``);try{let t=await fetch(Et(St(`/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 m(e){u(e),c(``);try{let t=await fetch(Et(St(`/api/locales/${e}`)),{method:`DELETE`});if(!t.ok)throw Error(`HTTP ${t.status}`);Ft(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)(Te,{}),` `,t(`localePacks`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,title:t(`close`),onClick:e,children:(0,X.jsx)(M,{})})]}),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 m(e.code),children:[(0,X.jsx)(L,{}),(0,X.jsx)(`span`,{children:t(n?`localeRemoving`:`localeRemove`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:n,title:t(`localeInstall`),onClick:()=>void p(e.code),children:[(0,X.jsx)(Pe,{}),(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)(oe,{}),(0,X.jsx)(`span`,{children:t(`bgTaskRefresh`)})]})})]})})}var Ni=`xing-shuyin/pi-web-ui`,Pi={state:`idle`,version:null,percent:0,message:null};function Fi(e){return typeof e==`number`&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Ii(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:Fi(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 Li(e){if(!Kt(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 Ri(e){return e instanceof Error?e.message:String(e)}function zi(e){let t=(e??``).trim().replace(/^v/,``);return t?`https://github.com/${Ni}/releases/tag/v${t}`:`https://github.com/${Ni}/releases/latest`}function Bi(){let[e]=(0,f.useState)(()=>Li()),[t,n]=(0,f.useState)(Pi);(0,f.useEffect)(()=>{if(e)return e.onEvent(e=>n(t=>Ii(t,e)))},[e]);let r=(0,f.useCallback)(()=>{e&&(n(e=>({...e,state:`checking`,message:null})),e.check().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)}))))},[e]),i=(0,f.useCallback)(()=>{e&&(n(e=>({...e,state:`downloading`,message:null})),e.download().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)}))))},[e]),a=(0,f.useCallback)(()=>{e&&e.quitAndInstall().catch(e=>n(t=>({...t,state:`error`,message:Ri(e)})))},[e]);return{...t,bridge:e,check:r,download:i,quitAndInstall:a}}function Vi({anchorRef:e,open:t,onClose:n,children:r}){let{panelRef:i,style:a,measure:o}=Ai({open:t,anchor:e,onClose:n});return(0,f.useLayoutEffect)(()=>{t&&o()},[t,r,o]),t?(0,D.createPortal)((0,X.jsx)(`div`,{ref:i,className:`plugin-topbar-menu portal`,role:`menu`,style:a,children:r}),document.body):null}function Hi(){let[e,t]=(0,f.useState)(()=>typeof window<`u`&&window.matchMedia!==void 0&&window.matchMedia(`(max-width: 768px)`).matches);return(0,f.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 Ui({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:p,onOpenGlobalSearch:m,sound:h,onSoundChange:g,onSoundPreview:_,themes:v,theme:y,onThemeChange:b,reloadThemes:x}){let{locale:S,setLocale:C,t:w,packs:T}=Ut(),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(!1),[A,j]=(0,f.useState)(null),M=hi(`cwd`),P=hi(`workspaceRoots`),F=(0,f.useRef)(null),I=t=>!e.tabs||t===`chat`||e.tabs.includes(t),L=[...a??[]].filter(e=>(e.source!==`host`||e.id!==`host:brand`)&&!mr(e)),R=new Set([...i??[],...a??[]].filter(e=>mr(e)&&!e.hidden).map(e=>e.source.slice(7))),te=new Map((e.settings?.uiLayout?.order??[]).map((e,t)=>[e,t])),z=r.map((e,t)=>({id:e.id,index:t})).sort((e,t)=>(te.get(`${e.id}:__view`)??1e6+e.index)-(te.get(`${t.id}:__view`)??1e6+t.index)).map(e=>e.id),B=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:files`].map(e=>({id:e,entry:null})):i.map(e=>({id:e.id,entry:e})),V=(I(`plugins`)?r:[]).filter(e=>e.view!==!1&&e.error&&!B.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:[]})),ie=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`}),un(),!0;case`host:open-project`:return k(!0),!0;case`host:search`:return m(),!0;case`host:tasks`:return p(),!0;case`host:settings`:return u(),!0;case`host:plugins`:return j(F.current?{rect:F.current.getBoundingClientRect(),el:F.current}:null),!0;default:return!1}},U=(e,t,n)=>{e.preventDefault(),Wr({x:e.clientX,y:e.clientY,slot:`contextmenu.topbar`,target:{id:t,label:n},entries:o??[]})},{appVersion:ae}=mi(),oe=_i(),ce=vi(),[le,ue]=(0,f.useState)(!1);(0,f.useEffect)(()=>{le&&e.status===`open`&&ue(!1)},[le,e.status]);let[de,fe]=(0,f.useState)(!1),[pe,W]=(0,f.useState)(!1),[he,ge]=(0,f.useState)(!1),[_e,ve]=(0,f.useState)(!1),ye=Kt(),K=Bi(),[xe,Se]=(0,f.useState)(!1),Ce=()=>{if(!e.ready)return;let n=w(`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:ot(),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`)},q=(n,r)=>{if(!e.ready||n.length===0)return;let i={name:r,command:it(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:ot(),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`)},we=e.updatesAll??[],Oe=we.filter(e=>!e.upToDate&&!e.error).length,ke=we.filter(e=>!e.upToDate&&!e.error&&e.kind!==`webui`),Ae=e=>e.kind===`git-extension`&&e.source?e.source:e.name,je=e=>e.kind===`git-extension`&&e.source&&e.source!==e.name?`${e.source} (${e.name})`:e.name,Me=e=>{let t=e.replace(/ \([0-9a-f]{7}\)$/,``);return/^[0-9a-f]{7}$/.test(t)?``:t},Ne=(e,t)=>{if(!t)return Me(e);let n=Me(e),r=Me(t);return n===r?n:`${n} → ${r}`},Fe=()=>(0,X.jsxs)(`div`,{className:`dd-updates-all`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`updatesAllTitle`)}),e.updatesAll===null?(0,X.jsx)(`div`,{className:`dd-note`,children:w(`checkingUpdate`)}):we.length===0?(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updatesAllUpToDate`)}):(0,X.jsx)(`ul`,{className:`dd-all-list`,children:we.map(e=>(0,X.jsxs)(`li`,{className:`dd-all-item${e.error?` err`:e.upToDate?``:` warn`}`,children:[e.kind!==`webui`&&!e.upToDate&&!e.error&&(0,X.jsx)(`button`,{type:`button`,className:`dd-update-btn`,onClick:()=>q([e],w(`updatePkgTabTitle`,{name:e.name})),children:w(`updateBtn`)}),(0,X.jsx)(`span`,{className:`dd-all-name`,title:je(e),children:Ae(e)}),(0,X.jsxs)(`span`,{className:`dd-all-meta`,children:[(0,X.jsx)(`span`,{className:`dd-all-kind`,children:e.kind===`webui`?w(`kindWebUi`):e.kind===`pi-core`?w(`kindPiCore`):e.kind===`git-extension`?w(`kindGitExtension`):w(`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?w(`updateCheckFailed`):e.kind===`git-extension`?e.upToDate?Me(e.current):Ne(e.current,e.latest):e.upToDate?`v${e.current}`:(0,X.jsxs)(X.Fragment,{children:[`v`,e.current,` → v`,e.latest]})})]})]},`${e.kind}:${e.name}`))}),(0,X.jsxs)(`div`,{className:`dd-actions`,children:[ke.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,style:{flex:1},onClick:()=>q(ke,w(`updateAllTabTitle`)),children:w(`updateAllBtn`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,style:ke.length>0?{flex:1}:void 0,onClick:()=>$({type:`check_updates_all`,force:!0}),children:w(`updatesAllRefresh`)})]})]}),Ie=()=>{let t=zi(e.update?.latest??K.version),n=(0,X.jsx)(`a`,{className:`dd-refresh dd-more-link`,href:t,target:`_blank`,rel:`noreferrer noopener`,children:w(`updateDesktopManual`)});if(!K.bridge)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopNoBridge`)}),n]});switch(K.state){case`checking`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateDesktopChecking`)}),n]});case`available`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopAvailable`,{version:K.version??e.update?.latest??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.download(),children:w(`updateDesktopDownload`)}),n]});case`downloading`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateDesktopDownloading`,{n:K.percent})}),n]});case`downloaded`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`updateDesktopDownloaded`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.quitAndInstall(),children:w(`updateDesktopInstall`)}),n]});case`up-to-date`:return(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`upToDate`)});case`error`:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`updateDesktopError`,{error:K.message??``})}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>K.check(),children:w(`updateDesktopCheck`)}),n]});default:return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:()=>K.check(),children:w(`updateDesktopCheck`)}),n]})}},Le=()=>(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:w(`currentVersion`)}),(0,X.jsxs)(`b`,{children:[`v`,e.update?.current??`…`]})]}),(0,X.jsxs)(`div`,{className:`dd-row`,children:[(0,X.jsx)(`span`,{children:w(`latestVersion`)}),(0,X.jsx)(`b`,{children:e.update===null?w(`checkingUpdate`):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:w(`checkingUpdate`)})]}),e.update&&e.update.upToDate&&(0,X.jsx)(`div`,{className:`dd-note ok`,children:w(`upToDate`)}),e.update&&!e.update.upToDate&&e.update.latest&&(0,X.jsx)(`div`,{className:`dd-note warn`,children:w(`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:w(`updateJustPublished`,{version:e.update.latest??``})}),e.update&&!e.update.upToDate&&e.update.latest&&!ye&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`updateTerminalHint`)}),e.update&&!e.update.upToDate&&e.update.latest&&ye&&(0,X.jsx)(`div`,{className:`dd-note`,children:w(`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?w(`checkingUpdate`):w(`checkUpdate`)}),e.update&&!e.update.upToDate&&e.update.latest&&!ye&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,onClick:Ce,children:w(`updateNow`)}),e.update&&!e.update.upToDate&&e.update.latest&&ye&&Ie(),ce&&(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh accent`,disabled:le,title:w(`restartServiceTip`,{name:ce.name}),onClick:()=>{le||(ue(!0),$({type:`restart_service`}))},children:w(le?`restartingService`:`restartService`)})]})]}),Re=Hi(),ze={"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":w(`openProject`),onClick:()=>k(!0),children:[(0,X.jsx)(Y,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`openProject`)})]}),"host:history":n===`chat`&&I(`history`)?(0,X.jsx)(`button`,{type:`button`,className:`panel-toggle`,"data-tip":w(`openHistory`),"aria-label":w(`openHistory`),onClick:()=>l(`left`),children:(0,X.jsx)(G,{})}):null,"host:files":n===`chat`&&I(`files`)?(0,X.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"data-tip":w(`openFiles`),"aria-label":w(`openFiles`),onClick:()=>l(`right`),children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{children:w(`openFiles`)})]}):null,"host:new-chat":I(`new-chat`)?(0,X.jsxs)(`button`,{type:`button`,className:`chip newchat`,"data-tip":w(`newChatTip`),onClick:()=>{c(`chat`),$({type:`new_chat`}),un()},children:[(0,X.jsx)(se,{}),(0,X.jsx)(`span`,{children:w(`newChat`)})]}):null,"host:chat":(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`chat`,className:`tb-tab${n===`chat`?` active`:``}`,"data-tip":w(`chat`),onClick:()=>c(`chat`),children:[(0,X.jsx)(me,{}),(0,X.jsx)(`span`,{children:w(`chat`)})]}),"host:terminal":I(`terminal`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`terminal`,className:`tb-tab${n===`terminal`?` active`:``}`,"data-tip":w(`terminal`),onClick:()=>c(`terminal`),children:[(0,X.jsx)(ee,{}),(0,X.jsx)(`span`,{children:w(`terminal`)})]}):null,"host:git":I(`git`)?(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":n===`git`,className:`tb-tab${n===`git`?` active`:``}`,"data-tip":w(`scmTab`),onClick:()=>c(`git`),children:[(0,X.jsx)(Ee,{}),(0,X.jsx)(`span`,{children:w(`scmTab`)})]}):null,"host:plugins":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":w(`pluginMenuTitle`),"aria-haspopup":`menu`,"aria-expanded":A!==null,onClick:e=>{let t=e.currentTarget;j(e=>e?.el===t?null:{rect:t.getBoundingClientRect(),el:t})},children:[(0,X.jsx)(Ye,{"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`pluginMenuTitle`)})]}),"host:search":(0,X.jsxs)(`button`,{type:`button`,className:`chip`,"data-tip":w(`searchGlobalTip`),onClick:m,children:[(0,X.jsx)(H,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`searchGlobal`)})]}),"host:browser":e.settings?.disabledAgentTools?.includes(`browser_page`)??!1?null:(0,X.jsx)(fn,{}),"host:tasks":(0,X.jsxs)(`button`,{type:`button`,className:`chip bg-task-chip`,"data-tip":w(`bgTasksTip`),onClick:p,children:[(0,X.jsx)(be,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`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":w(`settingsTitle`),onClick:u,children:[(0,X.jsx)(re,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`settings`)})]}),"host:sound":(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`sound`)})]}),tip:w(`sound`),open:de,onOpenChange:fe,children:[(0,X.jsx)(Gt,{settings:h,onChange:g,onPreview:_}),(0,X.jsx)(Qn,{})]}),"host:language":(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Te,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:It(S)})]}),tip:w(`language`),open:pe,onOpenChange:W,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`language`)}),T.map(e=>(0,X.jsx)(_t,{active:S===e.code,onClick:()=>{C(e.code),W(!1)},children:e.nativeName},e.code)),(0,X.jsxs)(_t,{onClick:()=>{W(!1),Se(!0)},children:[(0,X.jsx)(Pe,{}),` `,w(`localeGetMore`)]})]}),"host:theme":(0,X.jsx)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ne,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:w(`theme`)})]}),tip:w(`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=S===`zh`?e.name:e.nameEn??e.name,n=e.scheme===`light`?w(`themeLight`):e.scheme===`dark`?w(`themeDark`):``;return n?S===`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:w(`themeGroupClassics`)}),e.map(e=>(0,X.jsx)(_t,{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?w(`themeGroupBuiltin`):w(`theme`)}),(0,X.jsx)(_t,{active:y===null,onClick:()=>{b(null),ge(!1)},children:w(`themeDefault`)}),t.map(e=>(0,X.jsx)(_t,{active:y===e.id,onClick:()=>{b(e.id),ge(!1)},children:n(e)},e.id))]})})()}),"host:update":oe?(0,X.jsxs)(`span`,{className:`chip`,"data-tip":w(`updatesManaged`),children:[(0,X.jsx)(Pe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,children:[`v`,ae??e.update?.current??`…`]})]}):(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pe,{}),(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:w(`updateAvailable`,{version:e.update.latest??``})}),Oe>0&&(0,X.jsx)(`span`,{className:`update-badge`,children:w(`updatesAllBadge`,{n:Oe})})]}),tip:w(`update`),open:_e,onOpenChange:e=>{ve(e),e&&($({type:`check_update`}),$({type:`check_updates_all`}))},fit:!0,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:w(`update`)}),Le(),Fe()]}),"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":w(`githubRepo`),children:(0,X.jsx)(J,{})})},Be=new Set([`host:search`,`host:tasks`,`host:settings`,`host:plugins`]),Ve=new Set([`host:sound`,`host:language`,`host:theme`,`host:update`,`host:browser`]),He=e=>Be.has(e)&&!I(e.slice(5)),Ue=e=>{if(e.kind===`view`){if(!I(`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)(sr,{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)(sr,{icon:e.icon,iconSvg:e.iconSvg}),(0,X.jsx)(`span`,{children:e.label})]},e.id)},We=[];for(let e of B){if(e.entry?.hidden||He(e.id))continue;let t=e.id.startsWith(`host:`)?ze[e.id]??null:e.entry?Ue(e.entry):null;t&&We.push({id:e.id,entry:e.entry,node:t})}for(let e of V){let t=Ue(e);t&&We.push({id:e.id,entry:e,node:t})}let Ge=e=>e.entry?.align??`start`,[Ke,qe]=(0,f.useState)(()=>new Set),Je=(0,f.useRef)(null),Xe=(0,f.useRef)(new Map),Ze=We.filter(e=>!Ke.has(e.id)),Qe=Re?Ze.filter(e=>Rr.has(e.id)):[],$e=Re?Ze.filter(e=>!Rr.has(e.id)):Ze,et=Re?We.filter(e=>!Rr.has(e.id)):We,tt=[...et.filter(e=>Ge(e)===`start`),...et.filter(e=>Ge(e)===`center`),...et.filter(e=>Ge(e)===`end`)],nt=tt.filter(e=>!Ke.has(e.id)),rt=()=>{let e=Je.current;if(!e||typeof ResizeObserver>`u`)return;let t=Array.from(e.children).filter(e=>!e.classList.contains(`tb-spacer`));t.length===nt.length&&nt.forEach((e,n)=>Xe.current.set(e.id,t[n].offsetWidth));let n=Number.parseFloat(getComputedStyle(e).columnGap)||0,r=Br(tt.map(e=>({id:e.id,width:e.entry?Xe.current.get(e.id)??0:0})),e.clientWidth,n,0,fr);qe(e=>e.size===r.size&&[...r].every(t=>e.has(t))?e:r)},at=`${Ze.map(e=>`${e.id}:${e.entry?.label??``}`).join(`|`)}|${n}|${(e.tabs??[]).join(`,`)}|${Re?`m`:`d`}`;(0,f.useLayoutEffect)(rt,[at]),(0,f.useEffect)(()=>{let e=Je.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>rt());return t.observe(e),()=>t.disconnect()},[at]);let st=$e.filter(e=>Ge(e)===`start`),ct=$e.filter(e=>Ge(e)===`center`),lt=$e.filter(e=>Ge(e)===`end`),ut=We.filter(e=>Ke.has(e.id)&&e.entry).map(e=>e.entry),dt=new Map;[...i??[],...a??[]].forEach((e,t)=>{dt.has(e.id)||dt.set(e.id,t)});let ft=zr([...L,...ut],e=>dt.get(e)??999999),pt=e.settings?.uiLayout?.topbarText===!1;return(0,X.jsxs)(`header`,{className:`topbar${pt?` no-labels`:``}`,"data-pi-anchor":`topbar`,children:[(0,X.jsxs)(`div`,{className:`topbar-flow`,ref:Je,role:`toolbar`,"aria-label":w(`viewSwitch`),children:[st.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),(ct.length>0||lt.length>0)&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),ct.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),lt.length>0&&(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),lt.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id))]}),ft.length>0&&(0,X.jsxs)(`div`,{className:`plugin-topbar-more`,children:[(0,X.jsx)(`button`,{ref:F,type:`button`,className:`plugin-topbar-item`,"aria-haspopup":`menu`,"aria-expanded":E,"data-tip":w(`pluginTopbarMore`),onClick:()=>D(e=>!e),children:`⋯`}),(0,X.jsx)(Vi,{anchorRef:F,open:E,onClose:()=>D(!1),children:ft.map(e=>{let t=e.source===`host`&&Ve.has(e.id)?ze[e.id]:void 0;if(t!==void 0)return(0,X.jsx)(f.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:w(`githubRepo`),onClick:()=>D(!1),children:[(0,X.jsx)(J,{}),(0,X.jsx)(`span`,{children:`GitHub`})]},e.id);if(e.source===`host`){let t=ze[e.id];if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>D(!1),children:t},e.id)}else{let t=Ue(e);if(t)return(0,X.jsx)(`div`,{className:`plugin-topbar-menu-keep`,onClick:()=>D(!1),children:t},e.id)}return e.kind===`select`&&e.options?.length?(0,X.jsxs)(`label`,{className:`plugin-topbar-overflow-select`,title:e.hint??e.label,children:[(0,X.jsxs)(`span`,{children:[e.icon&&!/[a-z]/i.test(e.icon)?`${e.icon} `:``,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=>{D(!1),ie(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`,title:e.hint??e.label,onClick:()=>{D(!1),ie(e)||s?.(e)},children:[e.icon&&!/[a-z]/i.test(e.icon)?`${e.icon} `:``,e.label]},e.id)})})]}),Qe.map(e=>(0,X.jsx)(f.Fragment,{children:e.node},e.id)),xe&&(0,X.jsx)(Mi,{onClose:()=>Se(!1)}),A&&(0,X.jsx)(ji,{anchorRect:A.rect,anchorEl:A.el,plugins:r,pinnedIds:R,orderedPluginIds:z,onTogglePin:(t,n)=>$({type:`set_settings`,uiLayout:hr(e.settings?.uiLayout,t,n)}),onReorder:t=>$({type:`set_settings`,uiLayout:gr(e.settings?.uiLayout,t)}),onOpenView:e=>{j(null),c(`plugin:${e}`)},onManagePlugins:d,onClose:()=>j(null)}),O&&(0,X.jsx)(Ei,{open:!0,currentCwd:M,pathCompletions:e.pathCompletions??[],workspaceRoots:P,onClose:()=>k(!1),onSelectDirectory:e=>$({type:`set_cwd`,path:e}),onCreateProject:e=>$({type:`make_dir`,path:e,setAsCwd:!0})})]})}function Wi(e,t){let n={...t};if(!e)return n;try{let r=JSON.parse(e);if(r&&typeof r==`object`&&!Array.isArray(r))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 Gi(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 Ki(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 qi(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 Ji(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 Yi=`pi-web-ui:lp-collapse-projects`,Xi=`pi-web-ui:lp-collapse-convs`,Zi=`pi-web-ui:lp-collapse-sessions`;function Qi(e,t=!1){let[n,r]=(0,f.useState)(()=>{try{let t=localStorage.getItem(e);if(t===`1`)return!0;if(t===`0`)return!1}catch{}return t});return[n,(0,f.useCallback)(()=>{r(t=>{let n=!t;try{localStorage.setItem(e,n?`1`:`0`)}catch{}return n})},[e])]}var $i=`pi-web-ui:lp-sizes`,ea={projects:1,convs:1,sessions:1},ta=32,na=72;function ra(){try{return Wi(localStorage.getItem($i),ea)}catch{return{...ea}}}var ia=(0,f.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:p,onUiAction:m,presetNames:h}){let g=Z(),_=e,v=hi(`ready`),y=hi(`status`),b=hi(`cwd`),x=hi(`workspaceRoots`),S=b,[C,w]=(0,f.useState)(!1),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(``),[j,N]=Qi(Yi,!1),[P,F]=Qi(Xi,!1),[I,R]=Qi(Zi,!1),ee=(0,f.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]),te=(0,f.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},[]),ne=(0,f.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},[]),z=(0,f.useRef)(null),B=(0,f.useRef)(null),V=(0,f.useRef)(()=>{}),re=ti(d??[]).length>0,ie=(0,f.useCallback)((e,n,r)=>{z.current={x:e,y:n,target:r};let i=r.kind===`running`?r.id:void 0,a=r.kind===`elsewhere`,o=i??(a&&r.id||void 0),s=ee(t,i),c=s===0?g(`noFinishedSubagents`):g(i?`dismissFinishedSubagentsScoped`:`dismissFinishedSubagents`,{n:s}),l=!!i&&B.current===i;Wr({x:e,y:n,slot:`contextmenu.session`,target:r,entries:(d??[]).map(e=>{if(e.source!==`host`)return e;if(e.id===`host:conv-rename`)return r.kind===`running`||r.kind===`history`?e:{...e,hidden:!0};if(e.id===`host:conv-takeover`)return a&&o&&r.owner?e:{...e,hidden:!0};if(a&&(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:c,...s===0?{when:[...e.when??[],`disabled`]}:{}};if(e.id===`host:conv-force-dismiss`)return i?{...e,...l?{label:g(`forceDismissConfirm`)}:{}}:{...e,hidden:!0};if(e.id===`host:conv-persist`){if(!i)return{...e,hidden:!0};let n=t.find(e=>e.id===i);return n&&(n.isSubagent||!n.sessionFile)?e:{...e,hidden:!0}}return e.id===`host:conv-copy-id`?o?e:{...e,hidden:!0}:e.id===`host:conv-copy-path`?r.kind===`history`?e:i?t.some(e=>e.id===i&&e.sessionFile)?e:{...e,when:[...e.when??[],`disabled`]}:{...e,hidden:!0}:e.id===`host:conv-quote`?o||r.kind===`history`?e:{...e,hidden:!0}:e}),onHostAction:(e,t)=>V.current(e,t)})},[d,t,ee,g]);V.current=(0,f.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=z.current;if(!i||!e)return;if(B.current!==i)return B.current=i,ie(e.x,e.y,e.target),!0;B.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-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?dn({attachments:[{path:``,key:`conv||${n.id}`,name:n.label||n.id,mode:`conversation`,sessionPath:n.id}]}):a&&dn({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);A(e?.title??n.label??``),O(`conv:${i}`)}else if(n.kind===`history`&&n.id){let e=r.find(e=>e.path===n.id);A(e?.name??n.label??``),O(n.id)}return}},[o,ie,t,r]);let H=()=>{let e=(p??[]).filter(e=>!ur.has(e.id));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(),m?.(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(),m?.(e)},children:e.icon?(0,X.jsx)(`span`,{"aria-hidden":!0,children:e.icon}):(0,X.jsx)(`span`,{children:r})},n)})})},U=(0,f.useCallback)((e,t)=>{Ji(e.target)||re&&(e.preventDefault(),e.stopPropagation(),B.current=null,ie(e.clientX,e.clientY,t))},[re,ie]),ae=(0,f.useRef)(null),[oe,ce]=(0,f.useState)(()=>ra());(0,f.useEffect)(()=>{try{localStorage.setItem($i,JSON.stringify(oe))}catch{}},[oe]);let le=[...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,...e.owner&&e.convId?{owner:e.owner,convId:e.convId}:{},...e.hasQuestion?{hasQuestion:!0}:{}}))],ue=(0,f.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:j},{key:`convs`,visible:le.length>0,collapsed:P},{key:`sessions`,visible:!0,collapsed:I}].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*ta);r.classList.add(`dragging`),document.body.classList.add(`lp-resizing`);let f=n=>{let{above:r,below:i}=Gi({start:{above:o[e]??1,below:o[t]??1},deltaPx:n.clientY-a,availablePx:d,totalWeight:u,minAbovePx:na,minBelowPx:na});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)},[oe,i.length,le.length,j,P,I]);(0,f.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,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)(Ke,{}):i??(0,X.jsx)(L,{})})},W=(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)(Ge,{}):(0,X.jsx)(Ue,{})})]}),i?(0,X.jsx)(`div`,{className:`lp-section-actions`,children:i}):null]}),G=[{key:`projects`,visible:i.length>0,collapsed:j},{key:`convs`,visible:le.length>0,collapsed:P},{key:`sessions`,visible:!0,collapsed:I}].filter(e=>e.visible).filter(e=>!e.collapsed),he=G.reduce((e,t)=>e+(oe[t.key]??1),0)||1,ge=e=>G.length<=1?1:(oe[e]??1)/he*G.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)(He,{})}),(0,X.jsxs)(`div`,{className:`lp-section panel-projects ${j||i.length===0?`collapsed`:``}`,style:i.length>0&&!j?{flex:`${ge(`projects`)} 1 0px`}:void 0,children:[W(g(`recentProjects`),j,N,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)(Y,{})})),i.length>0&&!j&&(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)(De,{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:qi(e.lastUsed)})]}),pe(`proj:${e.path}`,g(`deleteProject`),g(`deleteProjectConfirm`),()=>o({type:`remove_project`,path:e.path}))]},e.path)})})]}),i.length>0&&!j&&(le.length>0?!P:!I)&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`projects`,le.length>0?`convs`:`sessions`),onDoubleClick:()=>ce({...ea}),title:g(`dragToResize`)}),le.length>0&&(0,X.jsxs)(`div`,{className:`lp-section lp-section-convs panel-convs ${P?`collapsed`:``}`,style:P?void 0:{flex:`${ge(`convs`)} 1 0px`},onContextMenu:e=>U(e,{id:``,kind:`section`,label:g(`runningConversations`)}),children:[W(g(`runningConversations`),P,F,le.length),!P&&(0,X.jsx)(`div`,{className:`lp-section-body convs-scroll`,children:Ki(le,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)return(0,X.jsx)(`div`,{className:`lp-row`,onContextMenu:e=>U(e,{id:n.convId??n.id,kind:`elsewhere`,label:n.title,...n.owner?{owner:n.owner}:{}}),children:(0,X.jsxs)(`div`,{className:`session-item elsewhere-item`,title:`${g(`elsewhereTip`)}\n${n.cwd}`,children:[(0,X.jsx)(me,{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(`elsewhereBadge`)}),n.hasQuestion&&n.owner&&n.convId&&(0,X.jsx)(`span`,{className:`question-badge clickable`,title:g(`takeoverHasQuestion`),onClick:e=>{e.stopPropagation(),o({type:`peek_elsewhere_question`,owner:n.owner,id:n.convId})},children:`?`}),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`)})]})},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=>U(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)(me,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[D===`conv:${n.id}`?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:k,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>A(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Enter`&&!e.nativeEvent.isComposing){let e=k.trim();e&&o({type:`rename_conversation`,id:n.id,name:e}),O(null)}else e.key===`Escape`&&O(null)},onBlur:()=>O(null)}):(0,X.jsxs)(`span`,{className:`session-title`,children:[n.isSubagent&&(0,X.jsx)(`span`,{className:`subagent-badge`,children:g(`subagentBadge`)}),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:`?`})]}),D===`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),A(n.title),O(`conv:${n.id}`)},children:(0,X.jsx)(Ne,{})}),(()=>{let e=`conv:${n.id}`,r=T===e,i=ee(t,n.id),a=ne(t,n.id),s=te(t,n.id);return s===0&&!n.isStreaming?pe(e,g(`dismissConversation`),g(`dismissConversationConfirm`),()=>o({type:`dismiss_conversation`,id:n.id}),(0,X.jsx)(M,{})):s===0?pe(e,g(`dismissConversation`),g(`dismissStreamingConfirm`),()=>o({type:`dismiss_conversation`,id:n.id,force:!0}),(0,X.jsx)(M,{})):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)(M,{})})})(),H(),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))})]}),le.length>0&&!P&&!I&&(0,X.jsx)(`div`,{className:`lp-sash`,onPointerDown:ue(`convs`,`sessions`),onDoubleClick:()=>ce({...ea}),title:g(`dragToResize`)}),(0,X.jsxs)(`div`,{className:`lp-section lp-section-sessions panel-sessions ${I?`collapsed`:``}`,style:I?void 0:{flex:`${ge(`sessions`)} 1 0px`},children:[W(g(`historySessions`),I,R,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`}),un()},children:(0,X.jsx)(se,{})})),!I&&(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=>U(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:()=>{D||t||o({type:`switch_session`,path:e.path})},children:[(0,X.jsx)(me,{className:`session-icon`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[D===e.path?(0,X.jsx)(`input`,{autoFocus:!0,className:`session-rename-input`,value:k,placeholder:g(`renameSessionPlaceholder`),onClick:e=>e.stopPropagation(),onChange:e=>A(e.target.value),onKeyDown:t=>{if(t.stopPropagation(),t.key===`Enter`&&!t.nativeEvent.isComposing){let t=k.trim();t&&o({type:`rename_session`,path:e.path,name:t}),O(null)}else t.key===`Escape`&&O(null)},onBlur:()=>O(null)}):(0,X.jsx)(`span`,{className:`session-title`,children:de(e)}),D===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:qi(e.modified)})]}),(0,X.jsx)(`button`,{type:`button`,className:`lp-del lp-rename`,title:g(`renameSession`),onClick:t=>{t.stopPropagation(),E(null),A(e.name??``),O(e.path)},children:(0,X.jsx)(Ne,{})}),pe(`sess:${e.path}`,g(`deleteSession`),g(`deleteSessionConfirm`),()=>o({type:`delete_session`,path:e.path})),H()]},e.path)})]})]}),(0,X.jsx)(Ei,{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})})]})});function aa(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 oa(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 sa(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 ca=null,la=new Set;function ua(){for(let e of la)e()}function da(e){let t=(e??``).trim();t&&(ca={name:t,status:`loading`},ua(),$({type:`get_tool_info`,name:t}))}function fa(){ca!==null&&(ca=null,ua())}function pa(e){ca!==null&&ca.name===e.name&&(ca=sa(e),ua())}function ma(e){return la.add(e),()=>{la.delete(e)}}function ha(){return ca}function ga(){return(0,f.useSyncExternalStore)(ma,ha,ha)}var _a=`__piWebUiHost`,va=e=>new Promise(t=>setTimeout(t,e));async function ya(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 va(100)}}function ba(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 va(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();return r&&!a(r)?!1:(s(n,t??{prompt:n}).catch(()=>{}),!0)},models:{list:()=>i(),active:()=>e.getCurrentModelId?.()??null,onChange:e=>Ja(e)},compose(e){return Q()?dn({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=Array.isArray(t?.folders)?t.folders.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],i=Array.isArray(t?.roots)?t.roots.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()):[],s=String(t?.cwd??``).trim(),c=[...new Set([...n,...i])],l=s||c[0]||``;if(!l)return{ok:!1,error:`openSession 需要 cwd / folders / roots(绝对路径)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let u=c.filter(e=>e!==l).slice(0,7),d=new Set([...e.listProjects?.()??[],...e.grantedPaths?.()??[]]);for(let t of[l,...u])if(!d.has(t)){if(!(e.confirm&&await e.confirm({path:t}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${t}`};e.grantPath?.(t)}if(e.getCwd()!==l&&(e.send({type:`set_cwd`,path:l}),!await r(()=>e.getCwd()===l)))return{ok:!1,error:`切换工作目录失败或超时:${l}`};(u.length>0||e.getWorkspaceRoots().length>0)&&e.send({type:`set_workspace_roots`,roots:u});let f=e.getConversationId()??void 0;if(t?.newChat!==!1){let t=f;e.send({type:`new_chat`}),await r(()=>e.getConversationId()!==t||e.isConversationBlank()),f=e.getConversationId()??void 0}let p=String(t?.model??``).trim();if(p){if(!a(p))return{ok:!1,error:`未知模型:${p}(先调 models.list() 取可用列表)`};await o(p),f=e.getConversationId()??f}let m=String(t?.prompt??``).trim();return m&&e.send({type:`prompt`,text:m}),{ok:!0,...f?{sessionId:f}:{}}},sessions:{list:()=>e.listSessions(),async open(t){let n=String(t??``).trim();if(!n)return{ok:!1,error:`sessions.open 需要一个会话 id(先调 list)`};if(!e.isReady())return{ok:!1,error:`尚未连接到服务器(还没有快照)`};let i=e.listSessions().find(e=>e.id===n);if(!i)return{ok:!1,error:`找不到会话:${n}`};if(i.cwd&&i.cwd!==e.getCwd()){if(!new Set([...e.listProjects?.()??[],...e.grantedPaths?.()??[]]).has(i.cwd)){if(!(e.confirm&&await e.confirm({path:i.cwd}).catch(()=>!1)))return{ok:!1,error:`用户拒绝了该目录的访问:${i.cwd}`};e.grantPath?.(i.cwd)}if(e.send({type:`set_cwd`,path:i.cwd}),!await r(()=>e.getCwd()===i.cwd))return{ok:!1,error:`切换工作目录失败或超时:${i.cwd}`}}let a=e.getConversationId();return i.kind===`running`?e.send({type:`switch_conversation`,id:i.id}):e.send({type:`switch_session`,path:i.id}),await r(()=>e.getConversationId()!==a)?{ok:!0,sessionId:e.getConversationId()??void 0}:{ok:!1,error:`切换会话超时:${i.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=ot();return new Promise(t=>{let a=setTimeout(()=>{no.delete(i),t({ok:!1,error:`目录同步超时(服务端未在等待窗口内回执)`})},Math.max(1e3,Number(e.catalogTimeoutMs??18e4)));no.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 Ta(Ca,String(e??``).trim(),t)},onTopbarAction(e,t){return Ta(Ca,String(e??``).trim(),t)},async pageCall(t){let n=String(t?.op??``).trim();if(!n)return{ok:!1,error:`pageCall 需要一个动作名(op)`};if(Kt())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 ya(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(Da,{detail:{text:n}}))}catch{}return null},shortcuts:{register:(e,t)=>Fa(String(e??``),t)},searchProviders:{register:e=>La(e),list:()=>Ra()},composerProviders:{register:e=>Ba(e),list:()=>Va()},onTheme:e=>Xa(e),onLocale:e=>Za(e),onViewChange:e=>Qa(e)}}function xa(e){try{let t=window;e?t[_a]=e:delete t[_a]}catch{}}var Sa=new Map,Ca=null;async function wa(e,t){let n=Ca;Ca=e;try{return await t()}finally{Ca=n}}function Ta(e,t,n){if(!t||typeof n!=`function`)return()=>{};let r=e?`${e}:${t}`:t,i=Sa.get(r);i||(i=new Set,Sa.set(r,i));let a=i;return a.add(n),()=>{a.delete(n),a.size===0&&Sa.delete(r)}}async function Ea(e,t,n,r){let i=i=>{let a=Sa.get(i);if(!a||a.size===0)return!1;for(let i of[...a])try{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 Da=`pi-web-ui:toast`,Oa=new Map,ka=!1;function Aa(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 ja(){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 Ma(e){try{if(ja())return;let t=`${e.ctrlKey?`ctrl+`:``}${e.shiftKey?`shift+`:``}${e.altKey?`alt+`:``}${e.metaKey?`meta+`:``}${(e.key??``).toLowerCase()}`,n=Oa.get(t);if(!n||n.size===0)return;for(let e of[...n])try{e()}catch(e){console.error(`[plugin-host] 快捷键处理器抛错:`,e)}}catch{}}function Na(){if(!ka)try{if(typeof window>`u`||typeof window.addEventListener!=`function`)return;window.addEventListener(`keydown`,Ma),ka=!0}catch{}}function Pa(){if(!(Oa.size>0||!ka))try{window.removeEventListener(`keydown`,Ma)}catch{}finally{ka=!1}}function Fa(e,t){if(typeof t!=`function`)return()=>{};let n=Aa(e);if(!n)return()=>{};let r=Oa.get(n.combo);r||(r=new Set,Oa.set(n.combo,r));let i=r;return i.add(t),Na(),()=>{i.delete(t),i.size===0&&Oa.delete(n.combo),Pa()}}var Ia=new Map;function La(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 Ia.set(t,n),()=>{Ia.get(t)===n&&Ia.delete(t)}}function Ra(){return[...Ia.values()].map(e=>({id:e.id,label:e.label}))}var za=new Map;function Ba(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 za.set(t,n),()=>{za.get(t)===n&&za.delete(t)}}function Va(){return[...za.values()].map(e=>({id:e.id,label:e.label}))}function Ha(e){return za.get(String(e??``))}function Ua(e){return Ia.get(String(e??``))}var Wa=new Set,Ga=new Set,Ka=new Set,qa=new Set;function Ja(e){return qa.add(e),()=>{qa.delete(e)}}function Ya(e){for(let t of[...qa])try{t(e)}catch(e){console.error(`[plugin-host] onModelChange 处理器抛错:`,e)}}function Xa(e){return typeof e==`function`?(Wa.add(e),()=>{Wa.delete(e)}):()=>{}}function Za(e){return typeof e==`function`?(Ga.add(e),()=>{Ga.delete(e)}):()=>{}}function Qa(e){return typeof e==`function`?(Ka.add(e),()=>{Ka.delete(e)}):()=>{}}function $a(e){let t=String(e??``);for(let e of[...Wa])try{e(t)}catch(e){console.error(`[plugin-host] onTheme 处理器抛错:`,e)}}function eo(e){let t=String(e??``);for(let e of[...Ga])try{e(t)}catch(e){console.error(`[plugin-host] onLocale 处理器抛错:`,e)}}function to(e){let t=String(e??``);for(let e of[...Ka])try{e(t)}catch(e){console.error(`[plugin-host] onViewChange 处理器抛错:`,e)}}var no=new Map;function ro(e){let t=no.get(e.requestId);if(t){if(no.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 io=`modulepreload`,ao=function(e){return`/`+e},oo={},so=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=ao(t,n),t=s(t),t in oo)return;oo[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`:io,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)})},co=`pi-web-ui:plugin-data`;function lo(e,t){window.dispatchEvent(new CustomEvent(co,{detail:{pluginId:e,payload:t}}))}function uo(e){let t=t=>{let n=t.detail;e(n.pluginId,n.payload)};return window.addEventListener(co,t),()=>window.removeEventListener(co,t)}var fo=new Map,po=new Set,mo=new Set,ho=new Set,go=new Set,_o=-1;function vo(){return[...fo.values()]}function yo(){let e=vo();for(let t of mo)t(e)}function bo(){let e=[...ho];for(let t of go)t(e)}function xo(e){return go.add(e),e([...ho]),()=>go.delete(e)}async function So(e,t){ho.delete(e.id),wo.set(e.id,(wo.get(e.id)??0)+1),bo();let n=await Oo(e,t);return yo(),n}function Co(e){return mo.add(e),e(vo()),()=>mo.delete(e)}var wo=new Map;function To(e,t){let n=wo.get(e)??0;return St(`/plugins/${encodeURIComponent(e)}/client/entry.mjs?e=${t}${n>0?`&r=${n}`:``}`)}function Eo(e){let t=Promise.resolve();return(n,r)=>{let i=t.then(()=>wa(n,()=>e(r)));return t=i.then(()=>void 0,()=>void 0),i}}var Do=Eo(e=>so(()=>import(e),[]));async function Oo(e,t){try{let n=(await Do(e.id,To(e.id,t))).default;return n&&typeof n.mount==`function`?(fo.set(e.id,{info:e,module:n}),!0):e.preload?(po.add(e.id),!0):(ho.add(e.id),bo(),console.error(`[plugin:${e.id}] entry.mjs 缺少 default.mount`),!1)}catch(t){return ho.add(e.id),bo(),console.error(`[plugin:${e.id}] 客户端加载失败:`,t),!1}}async function ko(e,t){if(fo.has(e.id)||po.has(e.id))return!0;if(ho.has(e.id)||!e.hasClient)return!1;let n=await Oo(e,t);return yo(),n}async function Ao(e,t){t!==_o&&(_o=t,fo.clear(),po.clear(),ho.clear(),wo.clear(),bo());let n=new Set(e.map(e=>e.id));for(let e of[...fo.keys()])n.has(e)||fo.delete(e);for(let e of[...po])n.has(e)||po.delete(e);for(let e of[...ho])n.has(e)||ho.delete(e);bo(),await Promise.all(e.filter(e=>e.hasClient&&(e.view!==!1||e.preload)&&!e.error&&!fo.has(e.id)&&!po.has(e.id)&&!ho.has(e.id)).map(e=>Oo(e,t))),yo()}function jo(e,t){return{pluginId:e,send:n=>t({type:`plugin_message`,pluginId:e,payload:n}),onData:t=>uo((n,r)=>{n===e&&t(r)})}}var Mo=[`debug`,`info`,`warn`,`error`];function No(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`get`}}}function Po(e){return{type:`plugin_message`,pluginId:e,payload:{__host:`logs`,op:`clear`}}}function Fo(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`&&Mo.includes(String(e.level)))}var Io=new Map,Lo=new Set;function Ro(){for(let e of[...Lo])try{e()}catch{}}function zo(e){return Lo.add(e),()=>Lo.delete(e)}function Bo(e){return(Io.get(e)??[]).map(e=>({...e}))}function Vo(e,t){return Fo(t)?(Io.set(e,t.logs.map(e=>({ts:e.ts,level:e.level,text:e.text}))),Ro(),!0):!1}function Ho(){return{flows:[],results:{}}}function Uo(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 Wo(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:Uo(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:Uo(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 Go=`pi-web-ui:lang`;function Ko(){try{return(localStorage.getItem(Go)??``).trim()}catch{return``}}var qo=`pi-web-ui:locale`,Jo=2e5,Yo=2e5,Xo=`LIVE_OMIT`,Zo={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 Qo(){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>Yo?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 $o(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 es(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 ts(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`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!==19};case`snapshot`:return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:$o(e.liveOutputs,t.state),toolStatuses:es(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,activeConversationId:i.conversationId,liveOutputs:$o(e.liveOutputs,i),toolStatuses:es(e.toolStatuses,i)}}case`tool_delta`:{let n=(e.liveOutputs.get(t.toolCallId)?.text??``)+t.delta,r=n.length>Jo?`…[${Xo}:${n.length-Jo}]…\n`+n.slice(n.length-Jo):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:aa(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{...e,sessions:t.sessions};case`conversations`:return{...e,conversations:t.conversations,elsewhere:t.elsewhere??[],activeConversationId:t.activeId};case`projects`:return{...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=Wo({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`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};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`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_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 n=e.pluginJobs[t.job.jobId],r=t.line?[...n?.lines??[],t.line].slice(-40):n?.lines??[],i={...n,...t.job,lines:r,startedAt:n?.startedAt??Date.now()};return{...e,pluginJobs:{...e.pluginJobs,[t.job.jobId]:i}}}case`plugin_catalog_sync_result`:return{...e,catalogSync:{...t.result,receivedAt:Date.now()}};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 ns=`pi-web-client-id`,rs=null;function is(){if(rs)return rs;let e=null;try{e=sessionStorage.getItem(ns),e||(e=ot(),sessionStorage.setItem(ns,e))}catch{e??=ot()}return rs=e,e}var as=`pi-web-last-cwd`;function os(){try{return localStorage.getItem(as)}catch{return null}}function ss(e){try{localStorage.setItem(as,e)}catch{}}function cs(){return Et(`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}${St(`/ws`)}`)}function ls(){let[e,t]=(0,f.useReducer)(ts,{status:`connecting`,ready:!1,state:null,hostMetrics:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:[],conversations:[],elsewhere:[],activeConversationId:``,projects:[],files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},defaultModel:null,providerOAuthFlows:[],providerOAuthResults:Ho().results,installResult:null,pathCompletions:[],update:null,updatesAll:null,widgets:[],statuses:[],dialog:null,question:null,remoteQuestion:null,commands:[],commandsPath:``,slashCommands:[],terminals:[],terminalActiveId:null,goal:Zo,bgServers:[],schedulerTasks:[],settings:null,fetchModelsResult:null,enrichModelsResult:null,enrichModelsProgress:null,refreshProviderResult:null,refreshBuiltinResult:null,appendBuiltinResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginCatalog:[],pluginCatalogEpoch:0,pluginJobs:{},catalogSync:null,pluginGrants:[],pluginPermissions:[],pathRequests:[],permRequests:[],dshPatches:null,dshPresets:null,dshPermission:null,protocolMismatch:!1}),n=(0,f.useRef)(null),r=(0,f.useRef)(Qo()),i=(0,f.useRef)(0),a=(0,f.useRef)(null),o=(0,f.useRef)(!0),s=(0,f.useRef)(0),c=(0,f.useRef)(0),l=(0,f.useRef)(new Map),u=(0,f.useRef)(null),d=(0,f.useRef)(!1),p=(0,f.useRef)(null),m=(0,f.useRef)(new Set),h=(0,f.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,f.useCallback)((e,n)=>{let r=++c.current;t({type:`notice`,notice:{id:r,level:e,text:n}})},[]),y=(0,f.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`}),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(m.current.add(e.id),m.current.size>64){let e=m.current.values().next().value;e!==void 0&&m.current.delete(e)}h.current=`live`,t({type:`question`,question:null})}}return!0}return!1},[]),b=(0,f.useCallback)((e,n)=>{let r=oa({current:O.current.chat.question,source:h.current,snapshot:e,answered:m.current,activeConversationId:n});r.changed&&(h.current=r.source,t({type:`question`,question:r.question}))},[]);bi(y);let x=(0,f.useCallback)(()=>{if(!o.current)return;t({type:`status`,status:`connecting`});let e=new WebSocket(cs());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:is(),locale:Ko()})))},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!==`20260922T01193`){let e=`pi-web-ui-reloaded-${a.buildId}`;if(!sessionStorage.getItem(e)){sessionStorage.setItem(e,`1`),location.reload();return}}di({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}),m.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`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`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`:pa(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});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`question_retracted`:{let e=O.current.chat.question;if(e&&e.id===a.id){if(m.current.add(a.id),m.current.size>64){let e=m.current.values().next().value;e!==void 0&&m.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`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_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_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_catalog_sync_result`:ro(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`:Vo(a.pluginId,a.payload)||lo(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,f.useEffect)(()=>{let e=e=>{let t=e.detail??Ko();t&&y({type:`set_locale`,locale:t})};return window.addEventListener(qo,e),()=>window.removeEventListener(qo,e)},[y]),(0,f.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,f.useEffect)(()=>{let t=e.state?.cwd;if(t){if(!d.current){d.current=!0;let e=os();if(e&&e!==t){y({type:`set_cwd`,path:e});return}}p.current!==t&&(p.current=t,ss(t))}},[e.state?.cwd,y]),(0,f.useEffect)(()=>{di({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,f.useCallback)(e=>t({type:`dismiss_notice`,id:e}),[]),C=(0,f.useCallback)(e=>t({type:`terminal_add`,meta:e}),[]),w=(0,f.useCallback)(e=>t({type:`terminal_remove`,id:e}),[]),T=(0,f.useCallback)(e=>t({type:`terminal_restart`,terminalId:e}),[]),E=(0,f.useCallback)(e=>t({type:`terminal_active`,id:e}),[]),D=(0,f.useCallback)((e,t,n)=>r.current.register(e,t,n),[]),O=(0,f.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}var us=209715200,ds=/windows/i.test(navigator.userAgent),fs=/[<>:"/\\|?*\u0000-\u001f]/g,ps=/[. ]+$/,ms=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function hs(e){let t=e.replace(fs,`_`).replace(ps,``);return t?ms.test(t)?`_${t}`:t:`_`}function gs(e,t=!0){return Et(St(`/api/file?${new URLSearchParams({clientId:is(),path:e,...t?{download:`1`}:{}})}`))}async function _s(e,t){let n=ds?hs(t):t;try{let t=await fetch(gs(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`)>us)return window.location.assign(gs(e)),{ok:!0};let r=await t.blob();return window.showSaveFilePicker&&window.isSecureContext?ys(r,n):bs(r,n)}catch(e){return{ok:!1,cancelled:!1,error:e instanceof Error?e.message:String(e)}}}async function vs(e,t){let n=ds?hs(t):t;return window.showSaveFilePicker&&window.isSecureContext?ys(e,n):bs(e,n)}async function ys(e,t){let n,r=window.showSaveFilePicker;if(!r)return bs(e,t);try{n=await r({suggestedName:t})}catch(n){return n instanceof DOMException&&n.name===`AbortError`?{ok:!1,cancelled:!0}:bs(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 bs(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 xs(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 Ss(){return typeof window<`u`&&window.matchMedia?.(`(hover: hover) and (pointer: fine)`)?.matches===!0}function Cs({text:e}){let t=(0,f.useRef)(null),n=(0,f.useRef)(null),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.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,f.useEffect)(()=>{if(!r)return;let e=n.current,i=t.current;if(!e||!i)return;let a=e.getBoundingClientRect(),s=xs(i.getBoundingClientRect(),a,{width:window.innerWidth,height:window.innerHeight});o(e=>e.left===s.left&&e.top===s.top?e:s)},[r,e]),(0,f.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=xs(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,D.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 ws=e=>/\.(zip|tar|tar\.gz|tgz|gz)$/i.test(e);function Ts(e,t={}){let n={archive:St(`/api/file-transfer/archive`),upload:St(`/api/file-transfer/upload`)},r=new URL(Et(`${n[e]}?${new URLSearchParams({clientId:is(),...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 Es(e,t,n){let r=await fetch(Ts(`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 vs(await r.blob(),i);if(!a.ok&&!a.cancelled)throw Error(a.error)}}async function Ds(){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 Os(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=Ts(`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 ks({request:e,onClose:t,onComplete:n}){let r=Z(),[i,a]=(0,f.useState)(e.dir),[o,s]=(0,f.useState)(`skip`),[c,l]=(0,f.useState)([]),[u,d]=(0,f.useState)(0),p=(0,f.useRef)(null),[m,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(``),v=(0,f.useRef)(null);(0,f.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 Ds();e?l(e):p.current?.click()}catch(e){e instanceof DOMException&&e.name===`AbortError`||_(String(e))}}async function x(){d(0),h(!0),_(``);try{e.action===`upload`?await Os(e.dir,c,d):await Es(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,D.createPortal)((0,X.jsx)(`dialog`,{ref:v,className:`file-transfer-dialog`,"aria-labelledby":`file-transfer-title`,onCancel:e=>{e.preventDefault(),m||t()},children:(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),x()},children:[(0,X.jsx)(`h3`,{id:`file-transfer-title`,children:y}),(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:m,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`label`,{children:[r(`fileConflictPolicy`),(0,X.jsxs)(`select`,{value:o,disabled:m,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:m,onClick:()=>void b(),children:r(`fileChooseFolder`)}),(0,X.jsx)(`input`,{type:`file`,"aria-label":y,multiple:!0,hidden:!0,disabled:m,ref:e=>{p.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:m,onClick:t,children:r(`cancel`)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:m||e.action===`upload`&&c.length===0,children:m?r(`fileTransferBusy`):y})]})]})}),document.body)}function As(e){return e instanceof Error?e.message:String(e)}function js(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 Ms({plugin:e,epoch:t,send:n,className:r}){let i=(0,f.useRef)(null),{locale:a}=Ut(),o=Z(),[s,c]=(0,f.useState)(null),l=(0,f.useRef)(n);(0,f.useEffect)(()=>{l.current=n},[n]),(0,f.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 ko(e,t),r)return;let i=await wa(e.id,()=>so(()=>import(To(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,jo(e.id,e=>l.current(e)))}catch(t){if(r)return;console.error(`[plugin:${e.id}] 页面${o?`挂载`:`加载`}失败:`,t),c({kind:o?`mount`:`load`,detail:As(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:js(s,e.name,a,o)})]})}function Ns(e){return`pi-web-ui:${e}:tab`}function Ps(e,t){try{let n=localStorage.getItem(Ns(e));return n&&t.some(e=>e.id===n)?n:null}catch{return null}}function Fs(e,t){try{localStorage.setItem(Ns(e),t)}catch{}}function Is(e){return e.length>0&&!/[a-z]/i.test(e)}function Ls(e){if(e.label)return e.label;let t=e.pluginPage;return t?.entry.label||t?.plugin.name||e.id}function Rs({storageKey:e,tabs:t,epoch:n,send:r,extra:i,className:a}){let o=(0,f.useId)(),[s,c]=(0,f.useState)(()=>Ps(e,t)??t[0]?.id??``),l=(0,f.useRef)([]),u=(0,f.useRef)(``),d=t.findIndex(e=>e.id===s),p=d>=0?t[d]:t[0],m=p?t.indexOf(p):-1;(0,f.useEffect)(()=>{if(!p)return;s!==p.id&&c(p.id);let t=`${e}:${p.id}`;u.current!==t&&(u.current=t,Fs(e,p.id))},[p,s,e]);let h=t=>{c(t.id),u.current=`${e}:${t.id}`,Fs(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(!p)return null;let _=`${o}-panel-${m}`,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===m;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,id:`${o}-tab-${t}`,className:n?`slot-tab active`:`slot-tab`,title:e.hint??Ls(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)(sr,{iconSvg:e.iconSvg,className:`slot-tab-icon`}):e.icon&&Is(e.icon)?(0,X.jsx)(`span`,{className:`slot-tab-icon`,children:e.icon}):null,(0,X.jsx)(`span`,{className:`slot-tab-label`,children:Ls(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-${m}`,children:p.pluginPage?(0,X.jsx)(Ms,{plugin:p.pluginPage.plugin,epoch:n,send:r}):p.element??null})]})}var zs=`@root`,Bs=`pi-web-ui:rp-sizes`,Vs={files:4,widgets:1},Hs=120,Us=56;function Ws(e,t){return t?Math.max(0,t.getBoundingClientRect().top-e.getBoundingClientRect().top):32}var Gs=`files`,Ks=[],qs=()=>{};function Js(e){let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,n=t.lastIndexOf(`/`);return n<0?``:n===0?`/`:t.slice(0,n)}function Ys(e){return e===zs||e===`/`||/^[A-Za-z]:$/.test(e)}function Xs(e){return e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)}var Zs=(0,f.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:p,send:m}){let h=Z(),g=d??Ks,_=hi(`cwd`),v=hi(`workspaceRoots`),y=hi(`homeDir`),b=hi(`desktopDir`),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(!1),D=(0,f.useRef)(null),O=(0,f.useRef)(null),[k,A]=(0,f.useState)(()=>{try{return Wi(localStorage.getItem(Bs),Vs)}catch{return{...Vs}}});(0,f.useEffect)(()=>{try{localStorage.setItem(Bs,JSON.stringify(k))}catch{}},[k]);let j=n.some(e=>e.lines.length>0),N=(0,f.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-Ws(t,O.current));n.classList.add(`dragging`),document.body.classList.add(`rp-resizing`);let o=e=>{let{above:t,below:n}=Gi({start:i,deltaPx:e.clientY-r,availablePx:a,totalWeight:i.above+i.below,minAbovePx:Hs,minBelowPx:Us});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]),P=(0,f.useRef)(null),F=(0,f.useRef)(0),I=(0,f.useCallback)(e=>{P.current=e,e&&(e.scrollTop=F.current)},[]),[L,R]=(0,f.useState)(null),ee=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>{ee.current&&clearTimeout(ee.current)},[]);let te=(0,f.useCallback)(e=>{R(e),ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>R(null),1200)},[]),ne=e=>{try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}},z=(0,f.useCallback)((e,t)=>{if(!e)return;let n=()=>te(t),r=()=>o(`error`,h(`slashCopyFailed`)),i=navigator;i.clipboard?.writeText?i.clipboard.writeText(e).then(n,()=>{ne(e)?n():r()}):ne(e)?n():r()},[te,o,h]),B=(0,f.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},[_]),V=(0,f.useCallback)(e=>!e||e===zs?null:e.startsWith(`/`)||/^[A-Za-z]:([/]|$)/.test(e)?e:`${_.replace(/\\/g,`/`).replace(/\/+$/,``)}/${e}`,[_]),re=104857600,ie=(0,f.useCallback)((e,t)=>{for(let n of t){if(n.size>re){o(`warning`,h(`fileTooLarge`,{name:n.name,size:re/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]),H=(0,f.useRef)(null),[U,ae]=(0,f.useState)(null),oe=(0,f.useRef)(null),ce=(0,f.useCallback)(()=>{let e=H.current?.project;e&&r({type:`set_cwd`,path:e.path})},[r]),le=(0,f.useCallback)(()=>{oe.current&&(oe.current.value=``),oe.current?.click()},[]),[ue,de]=(0,f.useState)(null),[fe,pe]=(0,f.useState)(null),[W,me]=(0,f.useState)(``),[G,he]=(0,f.useState)(null),[_e,ve]=(0,f.useState)(``),ye=(0,f.useCallback)((e,t)=>{_s(e,t).then(e=>{e.ok||e.cancelled||o(`error`,h(`downloadFailed`,{error:e.error===`FILE_NOT_FOUND`?h(`fileNotFoundShort`):e.error}))})},[o,h]),be=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&(he(null),me(e.label),pe(e.id))},[]),xe=(0,f.useCallback)(()=>{if(!fe)return;let e=W.trim();pe(null),e&&r({type:`file_rename`,path:fe,newName:e})},[fe,W,r]),Se=(0,f.useCallback)(e=>{let t=H.current?.dir??x;pe(null),ve(``),he({dir:t,kind:e})},[x]),Ce=(0,f.useCallback)(()=>{if(!G)return;let e=_e.trim();he(null),e&&r({type:`file_create`,dir:G.dir,name:e,kind:G.kind})},[G,_e,r]),q=(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}),we=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&window.confirm(h(`fileDeleteConfirm`,{name:e.label}))&&(ue?.src===e.id&&de(null),fe===e.id&&pe(null),r({type:`file_delete`,path:e.id}))},[r,h,ue,fe]),Te=(0,f.useCallback)(()=>{let e=H.current?.target;e&&e.kind!==`list`&&!Ys(e.id)&&r({type:`file_copy`,src:e.id,destDir:Js(e.id)})},[r]),J=(0,f.useCallback)(e=>{let t=H.current?.target;t&&t.kind!==`list`&&!Ys(t.id)&&de({src:t.id,cut:e})},[]),Ee=(0,f.useCallback)(()=>{if(!ue)return;let e=H.current?.dir??x;ue.cut?(r({type:`file_copy`,src:ue.src,destDir:e,move:!0}),de(null)):r({type:`file_copy`,src:ue.src,destDir:e})},[ue,r,x]),Y=(0,f.useCallback)(()=>{r({type:`list_files`,path:x===``?void 0:x})},[r,x]),[ke,Ae]=(0,f.useState)(!1);(0,f.useEffect)(()=>{if(!ke)return;let e=e=>{e.target?.closest(`.root-picker`)||Ae(!1)},t=e=>{e.key===`Escape`&&Ae(!1)};return window.addEventListener(`mousedown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e,!0),window.removeEventListener(`keydown`,t)}},[ke]);let je=(0,f.useCallback)(e=>{r({type:`set_workspace_roots`,roots:e})},[r]),Me=(0,f.useCallback)(()=>{let e=H.current?.target;if(!e||e.kind!==`dir`)return;let t=V(e.id);t&&!v.includes(t)&&je([...v,t])},[v,V,je]),Ne=(0,f.useCallback)(e=>{ie(H.current?.dir??x,Array.from(e.target.files??[]))},[ie,x]),Fe=(0,f.useCallback)(e=>{let t=H.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`;ae({action:n,path:B(t.id),dir:B(n===`upload`?H.current?.dir??x:Js(t.id))});break}case`host:file-open-project`:ce();break;case`host:file-upload`:le();break;case`host:file-add-root`:Me();break;case`host:file-open`:t?.kind===`file`&&a(t.id,t.label);break;case`host:file-enter`:t?.kind===`dir`&&Ze(t.id);break;case`host:file-download`:t?.kind===`file`&&ye(t.id,t.label);break;case`host:file-reveal`:t&&t.kind!==`list`&&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-inline`:t?.kind===`file`&&i(t.id,t.label,`inline`);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`:Se(`file`);break;case`host:file-new-dir`:Se(`dir`);break;case`host:file-paste`:Ee();break;case`host:file-rename`:be();break;case`host:file-duplicate`:Te();break;case`host:file-cut`:J(!0);break;case`host:file-copy`:J(!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(B(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`:Y();break;case`host:file-delete`:we()}},[ce,x,le,Me,a,i,z,B,ye,Se,Ee,be,Te,J,Y,we]),Ie=(0,f.useCallback)((e,t)=>{let n=t.kind===`dir`?V(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&&Ys(t.id),l=!s&&Xs(t.id),d=x===zs,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&&ws(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-inline`:case`host:file-attach-ref`:return a?e:{...e,hidden:!0};case`host:file-reveal`:return s?{...e,hidden:!0}:e;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&&ue?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}});ti(f).length!==0&&(e.preventDefault(),e.stopPropagation(),H.current=r,Wr({x:e.clientX,y:e.clientY,slot:`contextmenu.file`,target:t,entries:f,onHostAction:Fe}))},[u,x,V,h,Fe,_,v,ue]),Re=e=>Array.from(e.dataTransfer?.types??[]).includes(`Files`),ze=(0,f.useCallback)(()=>{P.current?.querySelectorAll(`.file-item.drop-target`).forEach(e=>e.classList.remove(`drop-target`)),P.current?.classList.remove(`drop-root`)},[]),He=(0,f.useCallback)(e=>{if(ze(),e==null)return;let t=P.current?.querySelector(`.file-item[data-path="${CSS.escape(e)}"]`);t?t.classList.add(`drop-target`):P.current?.classList.add(`drop-root`)},[ze]),Ue=e=>{let t=e instanceof Element?e.closest(`.file-item`):null;return t?.dataset.type===`dir`?t.dataset.path??x:x},Ge=(0,f.useCallback)(()=>{let e=document.querySelector(`.app`);e&&e.dispatchEvent(new DragEvent(`dragleave`,{bubbles:!0}))},[]),qe=(0,f.useRef)(0),Je=(0,f.useRef)(void 0),Ye=(0,f.useCallback)((e,t)=>{let n=++qe.current;S(e),t?.silent||E(!0),r({type:`list_files`,path:e===``?void 0:e})||qe.current===n&&E(!1)},[r]),Xe=(0,f.useCallback)(e=>{let t=v.filter(t=>t!==e);je(t),(x===e||x.startsWith(`${e}/`))&&Ye(``)},[v,je,x,Ye]);(0,f.useEffect)(()=>{e&&e.path===x&&E(!1)},[e,x]),(0,f.useEffect)(()=>{if(_!==Je.current){Je.current=_,Ye(``,{silent:!0});return}let e=setInterval(()=>{document.visibilityState!==`hidden`&&Ye(x,{silent:!0})},1e4);return()=>clearInterval(e)},[_,x,Ye]),(0,f.useEffect)(()=>{t&&t.path===x&&Ye(x,{silent:!0})},[t,x,Ye]);let Ze=e=>Ye(e),Qe=()=>{e?.parent!==null&&e?.parent!==void 0&&Ye(e.parent)},$e=(()=>{if(x===``||x===zs)return[];let e=x.split(`/`).filter(e=>!!e&&e!==zs);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(`/`)}))})(),et=[];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&&et.push({id:e.id,label:e.label,icon:e.icon,...e.iconSvg?{iconSvg:e.iconSvg}:{},hint:e.hint,pluginPage:{plugin:t,entry:e}})}let tt=(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)(Ve,{})}),(0,X.jsx)(`div`,{ref:O,style:{display:`flex`,flexDirection:`column`,flex:j?`${k.files} 1 0`:`1 1 0`,minHeight:j?Hs:0},children:(0,X.jsx)(Rs,{storageKey:`rightpanel`,epoch:p??0,send:m??qs,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===Gs?`host:right-files`:e)??1e9;return[...e].sort((e,t)=>r(e.id)-r(t.id))})([...tt?[]:[{id:Gs,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:()=>Ye(``),children:h(`rootDir`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===zs?`active`:``}`,title:h(`computer`),onClick:()=>Ye(zs),children:`💻`}),y!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===y||x.startsWith(`${y}/`)?`active`:``}`,title:h(`homeDir`),onClick:()=>Ye(y),children:`🏠`}),b!==``&&(0,X.jsx)(`button`,{type:`button`,className:`crumb ${x===b||x.startsWith(`${b}/`)?`active`:``}`,title:h(`desktopDir`),onClick:()=>Ye(b),children:`🖥️`}),(0,X.jsx)(Cs,{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":ke,title:h(`workspaceRoots`),onClick:()=>Ae(e=>!e),children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{className:`root-picker-label`,children:h(`workspaceRoots`)}),(0,X.jsx)(`span`,{className:`set-count`,children:v.length+1}),`▾`]}),ke&&(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:()=>{Ae(!1),Ye(``)},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:()=>{Ae(!1),Ye(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:()=>Xe(e),children:(0,X.jsx)(M,{})})]},e)),(0,X.jsx)(`div`,{className:`root-picker-hint`,children:h(`workspaceRootsHint`)})]})]}),$e.map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(We,{}),(0,X.jsx)(`button`,{type:`button`,className:`crumb ${e.path===x?`active`:``}`,onClick:()=>Ye(e.path),children:e.label})]},e.path))]}),(0,X.jsxs)(`div`,{ref:I,className:`panel-body`,onScroll:e=>{F.current=e.currentTarget.scrollTop},onContextMenu:e=>Ie(e,{id:x,kind:`list`,label:x===``?h(`rootDir`):x===zs?h(`computer`):x}),onDragOver:e=>{Re(e)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=`copy`,Ge(),He(Ue(e.target)))},onDragLeave:e=>{e.relatedTarget&&e.currentTarget.contains(e.relatedTarget)||ze()},onDrop:e=>{if(ze(),!Re(e))return;e.preventDefault(),e.stopPropagation(),Ge();let t=Array.from(e.dataTransfer?.files??[]);if(t.length===0){o(`warning`,h(`foldersNotSupported`));return}ie(Ue(e.target),t)},onDragEnd:ze,children:[(0,X.jsx)(`input`,{ref:oe,type:`file`,multiple:!0,hidden:!0,onChange:Ne}),U&&(0,X.jsx)(ks,{request:U,onClose:()=>ae(null),onComplete:Y}),G&&(0,X.jsxs)(`div`,{className:`file-item dir`,children:[G.kind===`dir`?(0,X.jsx)(De,{className:`file-icon`}):(0,X.jsx)(Oe,{className:`file-icon`}),q(_e,ve,Ce,()=>he(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:Qe,children:[(0,X.jsx)(De,{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${ue?.cut&&ue.src===e.path?` cut`:``}`,"data-type":`dir`,"data-path":e.path,onContextMenu:t=>Ie(t,{id:e.path,kind:`dir`,label:e.name}),children:[fe===e.path?q(W,me,xe,()=>pe(null)):(0,X.jsxs)(`button`,{type:`button`,className:`file-dir-main`,onClick:()=>Ze(e.path),children:[(0,X.jsx)(De,{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)(K,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:L===`name:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(B(e.path),`path:${e.path}`),children:L===`path:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Be,{})})]},e.path):(0,X.jsxs)(`div`,{className:`file-item file${ue?.cut&&ue.src===e.path?` cut`:``}`,"data-type":`file`,"data-path":e.path,onContextMenu:t=>Ie(t,{id:e.path,kind:`file`,label:e.name}),children:[fe===e.path?q(W,me,xe,()=>pe(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)(Oe,{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:()=>ye(e.path,e.name),children:(0,X.jsx)(Pe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach inline`,"data-tip":h(`attachInlineTip`),onClick:()=>i(e.path,e.name,`inline`),children:(0,X.jsx)(se,{})}),(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)(K,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`name:${e.path}`?` copied`:``}`,"data-tip":h(`copyName`),"aria-label":h(`copyName`),onClick:()=>z(e.name,`name:${e.path}`),children:L===`name:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Le,{})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${L===`path:${e.path}`?` copied`:``}`,"data-tip":h(`copyPath`),"aria-label":h(`copyPath`),onClick:()=>z(B(e.path),`path:${e.path}`),children:L===`path:${e.path}`?(0,X.jsx)(Ke,{}):(0,X.jsx)(Be,{})})]},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`)})]})]})}],...et])})}),j&&(0,X.jsx)(`div`,{className:`rp-sash`,onPointerDown:N,onDoubleClick:()=>A({...Vs}),title:h(`dragToResize`)}),j&&(0,X.jsx)(`div`,{className:`panel-widgets`,style:{flexGrow:k.widgets,minHeight:Us},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)(ge,{})]}),(0,X.jsx)(`pre`,{className:`widget-lines`,children:e.lines.join(`
|
|
327
|
-
`)})]},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)(M,{})})]}),(0,X.jsx)(`pre`,{className:`widget-expand-lines`,children:e.lines.join(`
|
|
328
|
-
`)})]})}):null})()]})});function Qs(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}}function $s(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,[i,a]=(0,f.useState)(!1),o=(0,f.useRef)(null),s=(0,f.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),c=(0,f.useCallback)(()=>{s(),a(!1)},[s]);return(0,f.useEffect)(()=>()=>{s()},[s]),{copied:i,copy:(0,f.useCallback)(async e=>{let i=!1;try{typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`?(await navigator.clipboard.writeText(e),i=!0):i=Qs(e)}catch(t){i=Qs(e),!i&&r&&r(t)}return i&&(a(!0),s(),o.current=setTimeout(()=>{a(!1),o.current=null},t),n?.(e)),i},[t,n,r,s]),reset:c}}var ec=(0,f.memo)(function({text:e}){let t=Z(),{copied:n,copy:r}=$s({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)(Ke,{}):(0,X.jsx)(Le,{})}):null});function tc(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
329
|
-
`).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,f.createElement)(n.type,i)]]:a.map(e=>[(0,f.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function nc(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(nc).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return nc(t?.children)}return``}function rc(e){let t=Array.isArray(e)?e[0]:e;return!t||typeof t!=`object`||!(`props`in t)?null:t}function ic(e){let t=rc(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 ac=`pi-web-ui:plugin-data`,oc=new Map,sc=new Map,cc=new Set,lc=-1,uc=0,dc=new Set;function fc(){uc++;for(let e of dc)e()}function pc(e){return dc.add(e),()=>{dc.delete(e)}}function mc(){return uc}var hc=null;function gc(e){hc=e}function _c(e,t){t!==lc&&(lc=t,sc.clear(),cc.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!==oc.size;if(!r){for(let[e,t]of n)if(oc.get(e)!==t){r=!0;break}}if(r){for(let e of sc.keys())n.has(e)||sc.delete(e);for(let e of cc)n.has(e)||cc.delete(e);oc=n,fc()}}async function vc(e,t){let n=oc.get(e);if(!n)return null;let r=sc.get(e);if(!r&&!cc.has(e))try{let t=(await so(()=>import(St(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${lc}`)),[])).default?.renderers?.[e];typeof t==`function`?(r={pluginId:n,renderer:t},sc.set(e,r)):(cc.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(t){cc.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,t)}if(!r)return null;let i={pluginId:r.pluginId,send:e=>{hc?.({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(ac,t),()=>window.removeEventListener(ac,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 yc(e){return oc.has(e)}var bc=new Map,xc=new Map,Sc=new Set,Cc=-1;function wc(e,t){t!==Cc&&(Cc=t,xc.clear(),Sc.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[...bc.keys()])n.has(e)||bc.delete(e);for(let[e,t]of n)bc.set(e,t);for(let e of xc.keys())n.has(e)||xc.delete(e);for(let e of Sc)n.has(e)||Sc.delete(e)}function Tc(e){return bc.has(e)}async function Ec(e){let t=bc.get(e);if(!t)return null;let n=xc.get(e);if(!n&&!Sc.has(e))try{let r=(await so(()=>import(St(`/plugins/${encodeURIComponent(t)}/client/entry.mjs?e=${Cc}`)),[])).default?.messageWidgets?.[e];typeof r==`function`?(n={pluginId:t,renderer:r},xc.set(e,n)):(Sc.add(e),console.error(`[plugin:${t}] entry.mjs 未提供 messageWidgets["${e}"]`))}catch(n){Sc.add(e),console.error(`[plugin:${t}] messageWidget 加载失败(${e}):`,n)}return n?.renderer??null}var Dc=`pi-web-ui:theme`,Oc=`dark`,kc=`theme-stylesheet`,Ac=`pi-web-ui:theme-change`;function jc(){try{let e=localStorage.getItem(Dc);if(e&&e!==Oc)return e}catch{}return null}function Mc(e){try{e?localStorage.setItem(Dc,e):localStorage.removeItem(Dc)}catch{}}function Nc(e){let t=document.getElementById(kc);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Ac));return}t||(t=document.createElement(`link`),t.id=kc,t.rel=`stylesheet`,document.head.appendChild(t)),t.href=St(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Ac))}async function Pc(){try{let e=await fetch(Et(St(`/api/themes`)));if(!e.ok)return[];let t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function Fc(){let[e,t]=(0,f.useState)([]),[n,r]=(0,f.useState)(()=>jc());(0,f.useEffect)(()=>{let e=!1;return Pc().then(n=>{e||t(n)}),()=>{e=!0}},[]);let i=(0,f.useCallback)(()=>{Pc().then(t)},[]);return(0,f.useEffect)(()=>{Nc(n),Mc(n)},[n]),{themes:e,theme:n,switchTheme:e=>r(e===Oc?null:e),reloadThemes:i}}function Ic(){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 Lc({lang:e,code:t}){let n=(0,f.useRef)(null),r=(0,f.useRef)(null),i=(0,f.useRef)(0),a=(0,f.useRef)(new WeakMap),[o,s]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let e=()=>{let e=++i.current,t=r.current;t&&(t.dispatchEvent(new CustomEvent(Ac)),a.current.set(t,e))};return window.addEventListener(Ac,e),()=>window.removeEventListener(Ac,e)},[]),(0,f.useEffect)(()=>{let n=!1,r=i.current;return s(null),vc(e,t).then(e=>{n||(e&&a.current.set(e,r),s(e))}),()=>{n=!0}},[e,t]),(0,f.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(Ac)),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)(ec,{text:t}),(0,X.jsx)(`pre`,{children:(0,X.jsx)(`code`,{children:t})})]})}var Rc=[c,o],zc=[c,a,o],Bc=[[s,{strict:!1,throwOnError:!1}],[l,{detect:!0,ignoreMissing:!0}]];function Vc({text:e,rawHtml:t=!1,hardBreaks:n=!1}){let r=t?[d,...Bc]:Bc;return(0,X.jsx)(u,{remarkPlugins:n?zc:Rc,rehypePlugins:r,components:{pre:Wc,a:Uc},children:e})}var Hc=(0,f.memo)(function({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(Vc,{text:e,rawHtml:t,hardBreaks:n})})});function Uc({href:e,children:t,...n}){let r=String(e??``);return/^(https?:|mailto:|tel:)/i.test(r)?(0,X.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer noopener`,...n,children:t}):(0,X.jsx)(`a`,{href:e,...n,children:t})}function Wc({children:e,...t}){(0,f.useSyncExternalStore)(pc,mc,mc);let n=ic(e);return n&&yc(n)?(0,X.jsx)(Lc,{lang:n,code:nc(e)}):(0,X.jsx)(Gc,{children:e,...t})}function Gc({children:e,...t}){let n=tc(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)(ec,{text:Kc(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 Kc(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Kc).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Kc(t?.children)}return``}function qc({type:e,code:t,children:n}){let r=(0,f.useRef)(null),[i,a]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=!1;if(a(null),Tc(e))return Ec(e).then(async r=>{if(!n&&r)try{let i=await r(t,{pluginId:bc.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,f.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 Jc=/^\s{0,3}(`{3,}|~{3,})/,Yc=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Xc(e){return e.trim()===``}function Zc(e){let t=Jc.exec(e);return t?t[1]:null}function Qc(e){let t=e.split(`
|
|
330
|
-
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=Zc(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=Zc(a);if(o&&!Xc(a)){i=o,r.push(a);continue}if(Xc(a)){let i=e;for(;i<t.length&&Xc(t[i]);)i++;if(!(i<t.length&&Yc.test(t[i]))&&r.length>0){n.push(r.join(`
|
|
331
|
-
`)),r=[];continue}r.push(a);continue}r.push(a)}return{frozen:n,active:r.join(`
|
|
332
|
-
`),inFence:i!==null}}var $c=(0,f.memo)(function({text:e}){return(0,X.jsx)(Vc,{text:e})}),el=200;function tl({text:e,inFence:t}){let[n,r]=(0,f.useState)(e),i=(0,f.useRef)(0),a=(0,f.useRef)(null);return(0,f.useEffect)(()=>{if(t)return;let n=Date.now()-i.current,o=()=>{i.current=Date.now(),r(e)};if(n>=el){o();return}return a.current=setTimeout(o,el-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)(Vc,{text:n})}var nl=(0,f.memo)(function({text:e}){let{frozen:t,active:n,inFence:r}=(0,f.useMemo)(()=>Qc(e),[e]);return(0,X.jsxs)(`div`,{className:`md`,children:[t.map((e,t)=>(0,X.jsx)($c,{text:e},t)),n.length>0&&(0,X.jsx)(tl,{text:n,inFence:r},t.length)]})});function rl(e,t){return t?e.trimEnd().slice(-80):e.split(`
|
|
333
|
-
`)[0].slice(0,80)}function il({thinking:e,streaming:t,wrap:n=!0,forceOpen:r=!1}){let i=Z(),[a,o]=(0,f.useState)(null),s=a??n,c=s||r,l=rl(e,t),[u,d]=(0,f.useState)(!1),p=()=>{navigator.clipboard.writeText(e),d(!0),window.setTimeout(()=>d(!1),1200)};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)(Ge,{}):(0,X.jsx)(We,{})}),(0,X.jsx)(`span`,{className:`chead-icon thinking-icon`,children:(0,X.jsx)(Fe,{})}),(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`,title:i(u?`copied`:`copyMessage`),"aria-label":i(`copyMessage`),onClick:e=>{e.stopPropagation(),p()},children:u?(0,X.jsx)(qe,{}):(0,X.jsx)(Le,{})})]}),c&&(0,X.jsx)(`div`,{className:`thinking-body`,children:e})]})}var al=262144,ol=300,sl=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,cl=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,ll=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,ul=1e9;function dl(e){if(!e)return{};let t=e.length>al?e.slice(0,al):e;return{path:gl(t),timeout:_l(t),command:vl(e),agent:fl(t)}}function fl(e){let t=cl.exec(e);if(!t)return;let n=t[1].replace(/[\u0000-\u001f\u007f]/g,``).trim();if(n)return n.length>ol?`${n.slice(0,ol)}…`:n}var pl=[`task`,`expected_outcome`,`required_tools`,`must_do`,`must_not_do`,`context`];function ml(e){if(!e||e.length>al)return{};try{let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n=t,r={};for(let e of[...pl,`agent`,`model`])typeof n[e]==`string`&&n[e].trim()&&(r[e]=n[e]);return r}catch{return{}}}function hl(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 gl(e){let t=sl.exec(e);if(!t)return;let n=yl(t[2]).replace(/[\u0000-\u001f\u007f]/g,` `).replace(/\s+/g,` `).trim();if(n)return n.length>ol?`${n.slice(0,299)}…`:n}function _l(e){let t=ll.exec(e);if(!t)return;let n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>ul)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 vl(e){if(!(e.length>al))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 yl(e){try{let t=JSON.parse(`"${e}"`);return typeof t==`string`?t:e}catch{return e}}var bl=new Set([`image`,`video`,`audio`,`markdown`,`html`,`pdf`,`text`,`binary`,`dir`,`missing`]);function xl(e){let t=String(e??``).trim().replace(/\\/g,`/`);return t.length>1?t.replace(/\/+$/,``):t}function Sl(e){let t=xl(e).split(`/`);return(t[t.length-1]??``)||String(e??``)}function Cl(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function wl(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Tl(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Cl(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=Cl(e),n=t?wl(t.path):void 0;if(!n)continue;let r={path:n},a=wl(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=wl(n.title);o&&(a.title=o);let s=wl(n.note);return s&&(a.note=s),a}function El(e,t){let n=Cl(t),r=Array.isArray(n?.items)?n.items.map(Cl):[],i=new Map;for(let e of r){if(!e)continue;let t=xl(String(e.path??e.abs??``));t&&!i.has(t)&&i.set(t,e)}return e.items.map((e,t)=>{let n=i.get(xl(e.path))??r[t]??null,a=wl(n?.kind),o={path:e.path,target:wl(n?.abs)??e.path,name:Sl(wl(n?.name)??e.path),kind:a&&bl.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=wl(n?.excerpt);return s&&(o.excerpt=s),n?.excerptTruncated===!0&&(o.excerptTruncated=!0),o})}function Dl(e,t){return wl(Cl(t)?.title)??e.title}function Ol(e,t){return wl(Cl(t)?.note)??e.note}function kl(e){return e===`image`||e===`video`||e===`audio`?e:null}function Al(e){return e!==`dir`&&e!==`missing`}function jl(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 Ml(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 Nl(e){return e.find(e=>e.focus&&Al(e.kind))}function Pl(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 Fl=null,Il=null;function Ll(e){Fl=e?.open??null,Il=e?.isOpen??null}function Rl(){return Il?Il():!1}function zl(e){return!Fl||!e?.path?!1:(Fl(e),!0)}var Bl=`pi-web-ui:present-auto-open`,Vl=`pi-web-ui:present-auto-opened`;function Hl(){try{return localStorage.getItem(Bl)===`1`}catch{return!1}}function Ul(e){try{localStorage.setItem(Bl,e?`1`:`0`)}catch{}ql=e,Gl()}var Wl=new Set;function Gl(){for(let e of Wl)e()}function Kl(e){return Wl.add(e),()=>{Wl.delete(e)}}var ql=null;function Jl(){return ql===null&&(ql=Hl()),ql}function Yl(){return(0,f.useSyncExternalStore)(Kl,Jl)}function Xl(){try{let e=sessionStorage.getItem(Vl);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Zl(e){if(!e)return!1;let t=Xl();if(t.includes(e))return!1;let n=[...t,e].slice(-200);try{sessionStorage.setItem(Vl,JSON.stringify(n))}catch{}return!0}function Ql(e,t,n=Date.now()){return Pl({enabled:Hl(),seen:!1,timestamp:t,now:n,maxAgeMs:3e4})?Zl(e):!1}var $l=(0,f.memo)(function({args:e,details:t,toolCallId:n,resultTimestamp:r}){let i=Z(),a=Yl(),o=(0,f.useMemo)(()=>El(e,t),[e,t]),s=Dl(e,t),c=Ol(e,t),l=(0,f.useMemo)(()=>Nl(o),[o]);return(0,f.useEffect)(()=>{a&&l&&n&&(Rl()||Ql(n,r)&&zl({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)(Hc,{text:c,rawHtml:!0})}),(0,X.jsx)(`div`,{className:`present-items`,children:o.map(e=>(0,X.jsx)(tu,{item:e},`${e.target}\u0000${e.path}`))})]})});function eu(e){return typeof e.mtime==`number`?`${e.path}\n${new Date(e.mtime).toLocaleString()}`:e.path}function tu({item:e}){let t=Z(),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),[o,s]=(0,f.useState)(``),c=i?null:kl(e.kind),l=Ml(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:jl(e.kind)}),(0,X.jsx)(`span`,{className:`present-item-name`,title:eu(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:[Al(e.kind)&&(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`previewFile`),"aria-label":t(`previewFile`),onClick:()=>zl(d),children:(0,X.jsx)(Ae,{})}),(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)(je,{}),(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)(De,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn`,title:t(`downloadFile`),"aria-label":t(`downloadFile`),onClick:()=>{s(``),_s(e.target,e.name).then(e=>{e.ok||e.cancelled||s(e.error===`FILE_NOT_FOUND`?t(`fileNotFoundShort`):e.error)})},children:(0,X.jsx)(Pe,{})}),(0,X.jsx)(`button`,{type:`button`,className:`present-btn${n?` on`:``}`,title:t(`copyPath`),"aria-label":t(`copyPath`),onClick:()=>{navigator.clipboard.writeText(e.path),r(!0),window.setTimeout(()=>r(!1),1200)},children:(0,X.jsx)(Le,{})})]})]}),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:()=>zl(d),children:(0,X.jsx)(`img`,{src:gs(e.target,!1),alt:e.name,loading:`lazy`,onError:()=>a(!0)})}),c===`video`&&(0,X.jsx)(`video`,{className:`present-media-video`,src:gs(e.target,!1),controls:!0,preload:`metadata`,onError:()=>a(!0)}),c===`audio`&&(0,X.jsx)(`audio`,{className:`present-media-audio`,src:gs(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 nu={bash:`$`,delegate_task:`◈`,read:`📄`,write:`✍️`,edit:`✏️`,edit_soft:`✏️`,grep:`🔍`,find:`🧭`,ls:`📂`,[En]:`🖼`};function ru(e){return nu[e]??`🛠`}var iu=(0,f.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,f.useState)(null),d=e.name===En,p=l??(d?!0:r),m=p||a,[h,g]=(0,f.useState)(!1),_=!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,f.useMemo)(()=>i?(t.result?.content??[]).filter(e=>e.type===`image`&&typeof e.dataUrl==`string`&&e.dataUrl.startsWith(`data:`)):[],[i,t.result]),[T,E]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!T)return;let e=e=>{e.key===`Escape`&&E(null)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[T]);let O=e.name===`delegate_task`,k=O?ml(e.argumentsText):{},A=(0,f.useMemo)(()=>d?Tl(e.argumentsText):null,[d,e.argumentsText]),j=O&&t.result&&typeof t.result.details==`object`&&t.result.details!==null?t.result.details.convId:void 0,N=typeof j==`string`&&j?j:/sa-[0-9a-f]{8}/.exec(S)?.[0],P=(0,f.useRef)(void 0);t.status?.durationMs!==void 0&&(P.current=t.status.durationMs);let F=t.result?.durationMs;typeof F==`number`&&(P.current=F);let I=typeof F==`number`?F:t.status?.durationMs??P.current,L=x?`err`:y?`ok`:_||b?`run`:`idle`,R=c(x?`error`:y?`done`:_?`running`:b?`toolDoneWaitingModel`:`toolQueued`),ee=(b||y)&&I!==void 0?cu(I):``;(b||y)&&ee&&(R=`${R} · ${ee}`);let te=b&&t.status?.exitCode!==void 0?`exit ${t.status.exitCode}`:``,ne=dl(e.argumentsText),B=e.name===`bash`?ne.command:void 0,V=!m&&B?su(B):void 0,re=()=>{e.argumentsText&&(navigator.clipboard.writeText(e.argumentsText),g(!0),setTimeout(()=>g(!1),1200))},ie=(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":m,title:c(m?`collapseMsg`:`expandMsg`),onClick:()=>u(!p),onContextMenu:t=>{if(!ie)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(),Wr({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`){da(e.name);return}s?.(t)}}))},onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(!p))},children:[(0,X.jsx)(`button`,{type:`button`,className:`chead-toggle toolcall-toggle`,title:c(m?`collapseMsg`:`expandMsg`),"aria-label":c(m?`collapseMsg`:`expandMsg`),"aria-expanded":m,onClick:e=>{e.stopPropagation(),u(!p)},children:m?(0,X.jsx)(Ge,{}):(0,X.jsx)(We,{})}),(0,X.jsx)(`span`,{className:`chead-icon toolcall-icon`,children:ru(e.name)}),(0,X.jsx)(`span`,{className:`chead-title toolcall-name`,children:e.name}),(0,X.jsx)(`span`,{className:`toolcall-status`,title:te?`${R} · ${te}`:R,"aria-label":te?`${R} · ${te}`:R,children:x?(0,X.jsx)(M,{}):y?(0,X.jsx)(Ke,{}):_?(0,X.jsx)(ve,{}):b?(0,X.jsx)(ze,{}):(0,X.jsx)(fe,{})}),ee&&(0,X.jsx)(`span`,{className:`toolcall-duration toolcall-timeout`,style:{marginLeft:-2,fontFamily:`var(--mono)`},title:te?`${R} · ${te}`:R,children:ee}),V&&(0,X.jsxs)(`span`,{className:`toolcall-cmd`,title:B,children:[`$ `,V]}),ne.path&&(0,X.jsx)(`span`,{className:`toolcall-path`,title:ne.path,children:hl(ne.path)}),ne.timeout&&(0,X.jsxs)(`span`,{className:`toolcall-timeout`,children:[`⏱ `,ne.timeout]}),O&&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)(z,{}),(0,X.jsx)(`span`,{children:c(`stopBash`)})]}),O&&y&&N&&(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:N}))},children:[(0,X.jsx)($e,{}),(0,X.jsx)(`span`,{children:c(`delegateOpenSubagent`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`chead-copy toolcall-copy`,title:c(`copyArgs`),onClick:e=>{e.stopPropagation(),re()},children:h?(0,X.jsx)(qe,{}):(0,X.jsx)(Le,{})})]}),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,D.createPortal)((0,X.jsx)(`div`,{className:`img-lightbox`,role:`dialog`,"aria-label":c(`toolImageZoom`),onClick:()=>E(null),children:(0,X.jsx)(`img`,{src:T,alt:`tool result preview`})}),document.body),m&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[d&&A?(0,X.jsx)($l,{args:A,details:t.result?.details,toolCallId:t.result?.toolCallId??e.id,resultTimestamp:t.result?.timestamp}):O?(0,X.jsx)(ou,{args:k}):e.argumentsText&&(0,X.jsx)(`div`,{className:`toolcall-args`,children:B?(0,X.jsx)(au,{command:B}):(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 au({command:e}){return(0,X.jsxs)(`div`,{className:`termline`,children:[(0,X.jsx)(ee,{className:`termline-icon`}),(0,X.jsx)(`code`,{children:e})]})}function ou({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 su(e){let t=e.split(`
|
|
334
|
-
`),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 cu(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 lu=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function uu(e){let t=e.match(lu);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}var du=1568,fu=2097152;function pu(e){return e.startsWith(`image/`)&&e!==`image/svg+xml`&&e!==`image/svg`}async function mu(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,du/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<=fu)return o}return o}finally{t.close()}}function hu(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 gu(e){return hu(e).join(`
|
|
335
|
-
|
|
336
|
-
`)}function _u(e){return vu(gu(e))}function vu(e){let t=e.split(`
|
|
337
|
-
`),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(`
|
|
338
|
-
`).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(`
|
|
339
|
-
`).map(e=>e.replace(/[ \t]+/g,` `).replace(/^\s+|\s+$/g,``)).join(`
|
|
340
|
-
`).replace(/\n{3,}/g,`
|
|
341
|
-
|
|
342
|
-
`).trim()}var yu={open:!1,triggerId:``,selectedIds:[],includeTools:!1,includeThinking:!1},bu=yu,xu=[],Su=new Set;function Cu(){for(let e of Su)e()}function wu(e){return(e.role===`user`||e.role===`assistant`)&&gu(e.content).length>0}function Tu(e,t=xu){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 Eu(e){if(xu=e,bu.open){let e=Tu(bu.selectedIds,xu);e.join(`\0`)!==bu.selectedIds.join(`\0`)&&(bu={...bu,selectedIds:e},Cu())}}function Du(){return bu}function Ou(e){return Su.add(e),()=>{Su.delete(e)}}function ku(){return(0,f.useSyncExternalStore)(Ou,Du,Du)}function Au(){bu.open&&(bu=yu,Cu())}function ju(e){let t=xu.find(t=>t.id===e);if(t&&wu(t)){if(bu.open){bu={...bu,selectedIds:Tu([...bu.selectedIds,e])},Cu();return}bu={open:!0,triggerId:e,selectedIds:[e],includeTools:!1,includeThinking:!1},Cu()}}function Mu(e){bu.open&&(bu={...bu,includeTools:e.includeTools??bu.includeTools,includeThinking:e.includeThinking??bu.includeThinking},Cu())}function Nu(e){if(!bu.open||!xu.filter(wu).map(e=>e.id).includes(e))return;let t=bu.selectedIds.includes(e)?bu.selectedIds.filter(t=>t!==e):Tu([...bu.selectedIds,e]);bu={...bu,selectedIds:t},Cu()}var Pu=20971520;function Fu(e){return e.type===`text`&&typeof e.text==`string`?e:null}function Iu(e){return e.type===`thinking`&&typeof e.thinking==`string`?e:null}function Lu(e){return e.type===`toolCall`&&typeof e.id==`string`&&typeof e.name==`string`?e:null}function Ru(e){return e.type===`image`&&typeof e.dataUrl==`string`?e:null}function zu(e){return e.type===`bash`&&typeof e.command==`string`?e:null}function Bu(e){return e.imageData?`image`:e.uploadPath?`upload`:e.fileData?`file`:`path`}function Vu(e,t){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 Hu={edit:(0,X.jsx)(Me,{}),copy:(0,X.jsx)(Le,{}),text:(0,X.jsx)(ke,{}),markdown:(0,X.jsx)(Re,{}),image:(0,X.jsx)(Ce,{}),x:(0,X.jsx)(M,{})};function Uu(e){let t=(e??``).trim();return t?Hu[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)(j,{})):(0,X.jsx)(j,{})}function Wu(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t)}…`:n}var Gu=(0,f.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:p,onJump:m,thinkingWrap:h,toolsWrap:g,toolImages:_,searchActive:v,autoExpand:y,uiMessageActions:b,uiContextMessage:x,uiContextToolCall:S,onUiAction:C}){let w=Z(),[T,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(``),[k,A]=(0,f.useState)([]),[j,N]=(0,f.useState)(!1),[P,F]=(0,f.useState)(null),I=e=>{F(e),window.setTimeout(()=>F(t=>t===e?null:t),4e3)};if(e.role===`toolResult`)return null;if(e.role===`compactionSummary`)return(0,X.jsx)(Yu,{message:e,forceOpen:v,autoExpand:y});let L=e.role===`custom`&&e.customType===`file`,R=e.content.map(e=>Fu(e)?.text??``).filter(Boolean).join(`
|
|
343
|
-
`),ee=e.role===`user`?uu(R):null,te=ee?ee.userMessage??`skill:${ee.name}`:R.split(`
|
|
344
|
-
`).join(` `).trim(),ne=i&&a&&e.content.length===0,z=e.role===`user`&&!i&&!ne&&!!o,B=async e=>{let t=[];for(let n of e){if(!pu(n.type))continue;let e=await mu(n);e&&t.push({path:``,imageData:e.data,mimeType:e.mimeType,name:e.name})}t.length>0&&A(e=>[...e,...t])},V=async e=>{if(e.size>Pu){I(w(`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{I(w(`fileLoadFailed`,{name:e.name}));return}A(n=>[...n,{path:``,fileData:t,name:e.name,size:e.size,mimeType:e.type||void 0}])},re=async e=>{let t=[];for(let n of e)pu(n.type)?t.push(n):V(n);t.length>0&&await B(t)},ie=()=>{O(ee?`/skill:${ee.name}${ee.userMessage?` ${ee.userMessage}`:``}`:e.content.map(e=>Fu(e)?.text??``).filter(Boolean).join(`
|
|
345
|
-
`)),A(u??[]),E(!0)},H=()=>{let t=D.trim();t&&(o?.(e.id,t,k.length>0?k:void 0),E(!1))},U=!b||b.some(e=>e?.id===`host:msg-copy`&&e.hidden!==!0),ae=(0,f.useRef)(null),[se,ce]=(0,f.useState)(null),le=ku(),ue=(0,f.useRef)(0),de=gu(e.content),fe=(e.role===`assistant`||e.role===`user`)&&de.length>0&&!i,pe=async t=>{try{if(t===`host:msg-copy-text`)await navigator.clipboard.writeText(_u(e.content));else if(t===`host:msg-copy-markdown`)await navigator.clipboard.writeText(de);else{ju(e.id);return}window.clearTimeout(ue.current),ce({id:t,ok:!0}),ue.current=window.setTimeout(()=>ce(null),1600)}catch{window.clearTimeout(ue.current),ce({id:t,ok:!1}),ue.current=window.setTimeout(()=>ce(null),1600)}},W=Wu(_u(e.content),40)||Qu(e.role,w),me=(x??[]).some(e=>e&&e.hidden!==!0&&e.kind!==`divider`),G=t=>{if(!me)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(),Wr({x:t.clientX,y:t.clientY,slot:`contextmenu.message`,target:{id:e.id,kind:`message`,label:W},entries:x??[]}))},he=e=>fe?[{id:`host:msg-copy-text`,label:w(`copyText`),icon:`text`},{id:`host:msg-copy-markdown`,label:w(`copyMarkdown`),icon:`markdown`},{id:`host:msg-copy-image`,label:w(`copyImage`),icon:`image`}].map(t=>{let n=se?.id===t.id,r=n&&se.ok;return(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:r?w(`copied`):n?w(`copyFailed`):t.label,"aria-label":t.label,onClick:()=>void pe(t.id),children:[r?(0,X.jsx)(qe,{}):Uu(t.icon),` `,t.label]},`${e}${t.id}`)}):[],ge=()=>{if(!b){let e=he(`fb:`);return!z&&e.length===0?null:(0,X.jsxs)(`div`,{className:`msg-actions`,children:[z&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`editReaskTip`),onClick:ie,children:[(0,X.jsx)(Me,{}),` `,w(`editReask`)]}),e]})}let e=[];return b.forEach((t,n)=>{if(!t||t.hidden===!0||t.id===`host:msg-copy`)return;let r=`${t.id}#${n}`,i=t.label||t.id;if(t.id===`host:msg-copy-text`||t.id===`host:msg-copy-markdown`||t.id===`host:msg-copy-image`){if(!fe)return;let n=se?.id===t.id,a=n&&se.ok;e.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:a?w(`copied`):n?w(`copyFailed`):i,"aria-label":i,onClick:()=>void pe(t.id),children:[a?(0,X.jsx)(qe,{}):Uu(t.icon),` `,i]},r));return}if(t.id===`host:msg-edit-reask`){if(!z)return;e.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:w(`editReaskTip`),onClick:ie,children:[Uu(t.icon),` `,i]},r));return}if(t.kind===`divider`){e.push((0,X.jsx)(`span`,{className:`msg-action-divider`,"aria-hidden":`true`},r));return}if(t.kind===`badge`){e.push((0,X.jsx)(`span`,{className:`msg-action-badge`,title:i,children:t.badge??i},r));return}if(t.kind===`select`&&t.options?.length){e.push((0,X.jsx)(`select`,{className:`msg-action msg-action-select`,title:i,"aria-label":i,value:t.options.some(e=>e.value===t.value)?t.value:t.options[0].value,onChange:e=>C?.(t,e.target.value),children:t.options.map(e=>(0,X.jsx)(`option`,{value:e.value,children:e.label},e.value))},r));return}e.push((0,X.jsxs)(`button`,{type:`button`,className:`msg-action`,title:i,"aria-label":i,onClick:()=>C?.(t),children:[Uu(t.icon),` `,i,t.badge?(0,X.jsx)(`span`,{className:`msg-action-count`,children:t.badge}):null]},r))}),e.length===0?null:(0,X.jsx)(`div`,{className:`msg-actions`,children:e})},_e=e.role===`custom`&&(e.customType===`goal-review`||e.customType===`goal-wizard`),ve=e.role===`custom`&&e.customType===`goal-wizard`,ye=e.role===`custom`&&!!e.customType&&e.customType!==`file`&&!_e&&Tc(e.customType),K=ye?JSON.stringify({customType:e.customType,details:e.details??{}}):``,be=le.open&&le.selectedIds.includes(e.id),xe=le.open&&fe,Se=be&&le.includeThinking,q=be&&le.includeTools;return(0,X.jsxs)(`div`,{ref:ae,className:`msg msg-${e.role}${_e?` msg-goal-review`:``}${be?` msg-export-selected`:``}`,"data-role":e.role,"data-msg-id":e.id,onContextMenu:G,children:[xe&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:be,title:w(`copyImage`),"aria-label":w(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>Nu(e.id)}),(0,X.jsxs)(`div`,{className:`msg-meta`,children:[l&&(0,X.jsxs)(`button`,{type:`button`,className:`msg-collapse-btn`,title:w(`collapseMsg`),onClick:()=>l(e.id),children:[(0,X.jsx)(Ue,{}),` `,w(`collapseMsg`)]}),(0,X.jsx)(`span`,{className:`msg-role`,children:e.role===`custom`?ve?w(`goalWizardCard`):_e?w(`goalBarTitle`):e.customType===`file`?w(`attachment`):`${w(`plugin`)} · ${e.customType??w(`unknown`)}`:Qu(e.role,w)}),e.model&&(0,X.jsx)(`span`,{className:`msg-model`,children:e.model}),e.timestamp&&(0,X.jsx)(`span`,{className:`msg-time`,children:$u(e.timestamp)}),d!==void 0&&m&&(0,X.jsxs)(`button`,{type:`button`,className:`qn-tag ${p?`active`:``}`,title:`${d+1}. ${te}`,"aria-label":`${d+1}. ${te}`,onClick:()=>m(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:T?(0,X.jsxs)(`div`,{className:`msg-editor${j?` drag-over`:``}`,onDragOver:e=>{e.preventDefault(),e.stopPropagation(),N(!0)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||N(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),N(!1),re(Array.from(e.dataTransfer?.files??[]))},children:[k.length>0&&(0,X.jsx)(`div`,{className:`msg-editor-images`,children:k.map((e,t)=>{let n=Bu(e);return(0,X.jsxs)(`span`,{className:`msg-editor-img ${n===`image`?``:`file-chip`}`,title:Vu(e,w),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:w(`removeAttachment`),onClick:()=>A(e=>e.filter((e,n)=>n!==t)),children:(0,X.jsx)(M,{})})]},`${e.name??e.path??`att`}-${t}`)})}),P&&(0,X.jsx)(`div`,{className:`msg-editor-notice`,children:P}),(0,X.jsx)(`textarea`,{className:`msg-editor-input`,value:D,autoFocus:!0,placeholder:w(`editPlaceholder`),rows:Math.max(2,Math.min(10,D.split(`
|
|
346
|
-
`).length+1)),onChange:e=>O(e.target.value),onPaste:e=>{let t=[];for(let n of e.clipboardData?.items??[])if(n.kind===`file`&&pu(n.type)){let e=n.getAsFile();e&&t.push(e)}t.length!==0&&(e.preventDefault(),B(t))},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)?(e.preventDefault(),H()):e.key===`Escape`&&E(!1)}}),(0,X.jsxs)(`div`,{className:`msg-editor-actions`,children:[(0,X.jsxs)(`span`,{className:`msg-editor-hint`,children:[(0,X.jsx)(Ce,{}),` `,w(`editAttachmentHint`)]}),(0,X.jsx)(`button`,{type:`button`,className:`chip`,onClick:()=>E(!1),children:w(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip primary`,disabled:!D.trim(),title:w(`reaskFromHere`),onClick:H,children:[(0,X.jsx)(Me,{}),` `,w(`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:w(`retryLastTip`),onClick:c,children:[(0,X.jsx)(oe,{}),` `,w(`retryNow`)]})]}),L?(0,X.jsx)(Ku,{message:e,forceOpen:v}):ee?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Xu,{block:ee,forceOpen:v}),ee.userMessage&&(0,X.jsx)(`div`,{className:`msg-text`,children:(0,X.jsx)(Hc,{text:ee.userMessage,hardBreaks:!0})}),e.content.map((o,c)=>o.type===`text`?null:(0,X.jsx)(Zu,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Se,forceTools:q,role:e.role,showCopy:U,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))]}):ye?(0,X.jsx)(qc,{type:e.customType??``,code:K,children:e.content.map((o,c)=>(0,X.jsx)(Zu,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Se,forceTools:q,role:e.role,showCopy:U,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`))}):e.content.map((o,c)=>(0,X.jsx)(Zu,{block:o,toolResults:t,liveOutputs:n,toolStatuses:r,streaming:i,isLast:a,onKillBash:s,toolsWrap:g,toolImages:_,thinkingWrap:h,searchActive:v,forceThinking:Se,forceTools:q,role:e.role,showCopy:U,uiContextToolCall:S,onUiAction:C},`${e.id}-${c}`)),ne&&(0,X.jsxs)(`div`,{className:`thinking-wait`,children:[w(`thinkingWait`),(0,X.jsx)(`span`,{className:`dot`})]}),i&&a&&!ne&&(0,X.jsx)(`span`,{className:`stream-cursor`})]})}),!T&&ge()]})});function Ku({message:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(!1),s=r||t,c=e.details??{},l=c.name??c.path??n(`attachment`),u=c.type===`folder`,d=c.mode===`reference`,p=c.mode===`bridged`,m=c.mode===`page`,h=c.mode===`conversation`,g=Ju(e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
347
|
-
`)),_=e.content.find(e=>e.type===`image`),v=g.split(`
|
|
348
|
-
`).length,y=!d&&!m&&!h&&g.length>0;return(0,X.jsxs)(`div`,{className:`attachcard ${d?`reference`:``}${m?` page`:``}${h?` conversation`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead attachcard-head`,role:`button`,tabIndex:0,"aria-expanded":s,title:n(s?`collapseMsg`:`expandMsg`),onClick:()=>i(e=>t?!0:!e),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i(e=>t?!0:!e))},children:[!d&&!m&&!h&&(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(Ge,{}):(0,X.jsx)(We,{})}),(0,X.jsx)(`span`,{className:`chead-icon attachcard-icon`,children:u?`📁`:m?`🌐`:h?`💬`:`📎`}),(0,X.jsx)(`span`,{className:`chead-title attachcard-name`,children:l}),c.path&&(m?(0,X.jsx)(`a`,{className:`attachcard-path attachcard-link`,href:c.path,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`:m?`page`:h?`conversation`:p?`bridged`:`inline`}`,children:m?n(`attachPageShort`):h?n(`attachConversationShort`):d?u?n(`folderRefShort`):`${n(`refOnlyShort`)} · ${qu(c.size)}`:p?n(`bridgedVision`):_?n(`image`):c.mode===`lines`?n(`inlineLinesRange`,{start:c.startLine??1,end:c.endLine??c.lines??1}):n(`inlineLines`,{n:c.lines??v})}),y&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:n(a?`copied`:`copyMessage`),"aria-label":n(`copyMessage`),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(g),o(!0),window.setTimeout(()=>o(!1),1200)},children:a?(0,X.jsx)(qe,{}):(0,X.jsx)(Le,{})})]}),!d&&s&&(p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`attachcard-bridgenote`,children:n(`bridgedVisionDetail`)}),_?.dataUrl&&(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:_.dataUrl,alt:l})}),g&&(0,X.jsx)(`pre`,{className:`attachcard-content`,children:g})]}):_?.dataUrl?(0,X.jsx)(`div`,{className:`attachcard-image`,children:(0,X.jsx)(`img`,{src:_.dataUrl,alt:l})}):(0,X.jsx)(`pre`,{className:`attachcard-content`,children:g})),d&&(0,X.jsx)(`div`,{className:`attachcard-refnote`,children:u?n(`folderNotExpanded`):n(`fileNotExpanded`,{size:qu(c.size)})})]})}function qu(e){return e===void 0?``:e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function Ju(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 Yu({message:e,forceOpen:t=!1,autoExpand:n=!1}){let r=Z(),[i,a]=(0,f.useState)(!1),[o,s]=(0,f.useState)(!1),[c,l]=(0,f.useState)(n);n!==c&&(l(n),n&&a(!0));let u=i||t,d=e.content.map(e=>Fu(e)?.text??``).filter(Boolean).join(`
|
|
349
|
-
`),p=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:$u(e.timestamp)})]}),(0,X.jsxs)(`div`,{className:`compaction-card${i?` expanded`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead compaction-head`,role:`button`,tabIndex:0,"aria-expanded":u,title:r(u?`collapseMsg`:`expandMsg`),onClick:()=>a(e=>t?!0:!e),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a(e=>t?!0:!e))},children:[(0,X.jsx)(`span`,{className:`chead-toggle`,children:u?(0,X.jsx)(Ge,{}):(0,X.jsx)(We,{})}),(0,X.jsx)(`span`,{className:`chead-icon compaction-icon`,children:(0,X.jsx)(tt,{})}),(0,X.jsx)(`span`,{className:`chead-title compaction-title`,children:p?r(`compactionFrom`,{tokens:p}):r(`role.compaction`)}),d&&(0,X.jsx)(`button`,{type:`button`,className:`chead-copy`,title:r(o?`copied`:`copyMessage`),"aria-label":r(`copyMessage`),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(d),s(!0),window.setTimeout(()=>s(!1),1200)},children:o?(0,X.jsx)(qe,{}):(0,X.jsx)(Le,{})})]}),u&&(0,X.jsxs)(`div`,{className:`compaction-body`,children:[(0,X.jsx)(Hc,{text:d}),(0,X.jsx)(`div`,{className:`compaction-hint`,children:r(`compactionKeptHint`)})]})]})]})}function Xu({block:e,forceOpen:t=!1}){let n=Z(),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(!1),s=r||t;return(0,X.jsxs)(`div`,{className:`skillcard${r?` expanded`:``}`,children:[(0,X.jsxs)(`div`,{className:`chead skillcard-head`,role:`button`,tabIndex:0,"aria-expanded":s,title:e.location,onClick:()=>i(e=>t?!0:!e),onKeyDown:e=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i(e=>t?!0:!e))},children:[(0,X.jsx)(`span`,{className:`chead-toggle`,children:s?(0,X.jsx)(Ge,{}):(0,X.jsx)(We,{})}),(0,X.jsx)(`span`,{className:`chead-icon skillcard-icon`,children:(0,X.jsx)(Xe,{})}),(0,X.jsx)(`span`,{className:`chead-title skillcard-name`,children:e.name}),(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(),navigator.clipboard.writeText(e.content),o(!0),window.setTimeout(()=>o(!1),1200)},children:a?(0,X.jsx)(qe,{}):(0,X.jsx)(Le,{})})]}),s&&(0,X.jsx)(`div`,{className:`skillcard-body`,children:(0,X.jsx)(Hc,{text:e.content})})]})}function Zu({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:p,role:m,showCopy:h,uiContextToolCall:g,onUiAction:_}){let v=Z(),[y,b]=(0,f.useState)(!1),x=Fu(e);if(x){let e=i&&a,t=(m===`assistant`||m===`user`)&&h!==!1,n=t&&!x.text.includes(`
|
|
350
|
-
`)&&!x.truncated,r=m===`user`?(0,X.jsx)(Hc,{text:x.text,hardBreaks:!0}):e?(0,X.jsx)(nl,{text:x.text}):(0,X.jsx)(Hc,{text:x.text});return(0,X.jsxs)(`div`,{className:`msg-text${n?` single`:``}`,children:[n?(0,X.jsx)(`div`,{className:`msg-text-main`,children:r}):(0,X.jsxs)(X.Fragment,{children:[r,x.truncated&&(0,X.jsx)(`div`,{className:`trunc-note`,children:v(`truncated`)})]}),t?(0,X.jsx)(`button`,{type:`button`,className:`msg-text-copy`,title:v(y?`copied`:`copyMessage`),"aria-label":v(`copyMessage`),onClick:()=>{navigator.clipboard.writeText(x.text),b(!0),window.setTimeout(()=>b(!1),1200)},children:y?(0,X.jsx)(qe,{}):(0,X.jsx)(Le,{})}):null]})}let S=Iu(e);if(S)return(0,X.jsx)(il,{thinking:S.thinking,streaming:i&&a,wrap:s,forceOpen:u||d});let C=Lu(e);if(C){let e={result:t.get(C.id),liveOutput:n.get(C.id)?.text,streaming:i,status:r.get(C.id)};return(0,X.jsx)(iu,{block:C,view:e,onKillBash:o,wrap:c,showImages:l??!0,forceOpen:u||p,uiContextToolCall:g,onUiAction:_})}let w=Ru(e);if(w&&w.dataUrl)return(0,X.jsx)(`div`,{className:`msg-image`,children:(0,X.jsx)(`img`,{src:w.dataUrl,alt:`attachment`})});let T=zu(e);return T?(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:T.command}),T.exitCode!==void 0&&(0,X.jsx)(`span`,{className:`bashblock-exit ${T.exitCode===0?`ok`:`err`}`,children:v(`exitCode`,{code:T.exitCode})}),T.cancelled&&(0,X.jsx)(`span`,{className:`bashblock-exit err`,children:v(`cancelled`)})]}),T.output&&(0,X.jsx)(`pre`,{className:`bashblock-output`,children:T.output}),T.truncated&&(0,X.jsx)(`div`,{className:`trunc-note`,children:v(`outputTruncated`)})]}):null}function Qu(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 $u(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function ed(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 td(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=[];ed(i,r.content);for(let t=n+1;t<e.length&&e[t].role===`custom`&&e[t].customType===`file`;t++){let n=e[t].details??{};if(!ed(i,e[t].content,n.name)){if(n.upload&&n.path){i.push({path:``,uploadPath:n.path,name:n.name??n.path,size:n.size});continue}if(n.mode===`page`&&n.path){i.push({path:n.path,mode:`page`,name:n.name??n.path});continue}if(n.mode===`conversation`){let e=n,t=typeof e.conversationId==`string`&&e.conversationId?e.conversationId:void 0,r=typeof e.sessionPath==`string`&&e.sessionPath?e.sessionPath:void 0;(t||r)&&i.push({path:``,mode:`conversation`,name:n.name??t??r,...t?{conversationId:t}:{},...r?{sessionPath:r}:{}});continue}if(n.path&&n.mode){let e=n.mode===`inline`||n.mode===`lines`?n.mode:`reference`,t={path:n.path,mode:e};n.mode===`lines`&&typeof n.startLine==`number`&&typeof n.endLine==`number`&&(t.lines={start:n.startLine,end:n.endLine}),i.push(t)}}}i.length>0&&t.set(r.id,i)}return t}var nd=(0,f.memo)(function({message:e,onExpand:t}){let n=Z(),r=ku(),i=wu(e),a=r.open&&r.selectedIds.includes(e.id),o=r.open&&i,s=``;for(let t of e.content){let e=Fu(t);if(e&&e.text.trim()){let t=uu(e.text);s=t?`skill:${t.name}`+(t.userMessage?` · ${t.userMessage.replace(/\s+/g,` `).trim()}`:``):e.text.replace(/\s+/g,` `).trim();break}}if(!s&&e.role===`custom`&&e.customType===`file`){let t=e.details??{};s=t.name??t.path??``}s.length>90&&(s=`${s.slice(0,90)}…`);let c=0,l=0,u=0,d=0;for(let t of e.content)Iu(t)?c++:Lu(t)?l++:zu(t)?u++:Ru(t)&&d++;let f=[];return c&&f.push(`${n(`thinking`)} ${c}`),l&&f.push(`${n(`toolCalls`)} ${l}`),u&&f.push(`${n(`bashRuns`)} ${u}`),d&&f.push(`${n(`images`)} ${d}`),(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,className:`msg-collapsed${a?` msg-export-selected`:``}`,"data-msg-id":e.id,title:`${n(`expandMsg`)} · ${s||f.join(` · `)||e.role}`,onClick:()=>t(e.id),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.id))},children:[o&&(0,X.jsx)(`input`,{type:`checkbox`,className:`msg-export-check`,checked:a,title:n(`copyImage`),"aria-label":n(`copyImage`),onClick:e=>e.stopPropagation(),onChange:()=>Nu(e.id)}),(0,X.jsx)(`span`,{className:`msg-collapsed-role role-${e.role}`,children:e.role===`custom`&&e.customType===`file`?n(`attachment`):Qu(e.role,n)}),(0,X.jsxs)(`span`,{className:`msg-collapsed-body`,children:[s&&(0,X.jsx)(`span`,{className:`msg-collapsed-preview`,children:s}),f.length>0&&(0,X.jsx)(`span`,{className:`msg-collapsed-chips`,children:f.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:rd(e.timestamp)}):null,(0,X.jsx)(`span`,{className:`msg-collapsed-action`,children:n(`expandMsg`)})]})});function rd(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}var id=(0,f.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,f.useRef)(null),c=(0,f.useRef)(null);return(0,f.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 ad(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 od(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 sd(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)??cd(n.role,n.customType)}return r}function cd(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 ld=[`text`,`thinking`,`argumentsText`,`output`,`command`];function ud(e){let t=0;for(let n of e.content){n.type===`image`&&(t+=1);for(let e of ld){let r=n[e];typeof r==`string`&&(t+=r.length)}}return t}function dd(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function fd(e){let t=[];for(let n of e.content)n.type===`text`&&typeof n.text==`string`&&t.push(n.text);return t.join(`
|
|
351
|
-
`)}function pd(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=fd(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(`
|
|
352
|
-
`)}function md(e,t){let n=0,r=e.indexOf(t);for(;r!==-1;)n++,r=e.indexOf(t,r+t.length);return n}function hd(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=md(pd(n,r).toLowerCase(),a);e>0&&i.set(n.id,e)}return i}function gd(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 _d(e,t,n,r,i){let a=hd(n,r,t,i),o=new Map;for(let n of gd(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 vd(e,t){return e.findIndex(e=>e.msgId===t.msgId&&e.k===t.k)}function yd(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 bd(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 xd(e,t){let n=t.startContainer.parentElement;for(let r of bd(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 Sd({containerRef:e,messages:t,collapsedIds:n,toolResults:r,onExpand:i,onProgrammaticScroll:a,open:o,onClose:s}){let c=Z(),l=(0,f.useRef)(null),[u,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(null),[h,g]=(0,f.useState)(0),[,_]=(0,f.useState)(0),v=(0,f.useDeferredValue)(u),y=o?v.trim():``,b=(0,f.useRef)(null);b.current=p;let x=(0,f.useRef)([]),S=(0,f.useRef)({key:null}),C=(0,f.useRef)(``);(0,f.useEffect)(()=>{o&&(m(null),requestAnimationFrame(()=>l.current?.select()))},[o]),(0,f.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,f.useEffect)(()=>(o||(yd(`msg-search`,[]),yd(`msg-search-active`,[])),()=>{yd(`msg-search`,[]),yd(`msg-search-active`,[])}),[o]),(0,f.useLayoutEffect)(()=>{let s=()=>{g(0),m(null),_(0),x.current=[],yd(`msg-search`,[]),yd(`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=_d(c,y,t,n,r);x.current=e;let o=e.length;if(g(o),o===0){m(null),_(0),yd(`msg-search`,[]),yd(`msg-search-active`,[]),S.current={key:null},C.current=y;return}let s=b.current,u;if(s){if(u=vd(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)&&m({msgId:e[u].msgId,k:e[u].k}),_(u);let d=e[u],f=S.current,p=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,yd(`msg-search`,e.filter(e=>e.kind===`dom`).map(e=>e.range)),d.kind===`folded`){yd(`msg-search-active`,[]),p&&i(d.msgId);return}yd(`msg-search-active`,[d.range]),p&&(a?.(),xd(c,d.range))}),()=>{l=!0,cancelAnimationFrame(u)}},[o,y,t,e,p,n,r,i,a]);let w=(0,f.useCallback)(e=>{let t=x.current,n=t.length;if(n===0)return;let r=b.current,i=t[((r?vd(t,r):0)+e+n)%n];m(i.kind===`dom`||i.kind===`folded`?{msgId:i.msgId,k:i.k}:null)},[]);if(!o)return null;let T=p?(()=>{let e=vd(x.current,p);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)(Ue,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchNext`),disabled:h===0,onClick:()=>w(1),children:(0,X.jsx)(Ge,{})}),(0,X.jsx)(`button`,{type:`button`,className:`search-btn`,title:c(`searchClose`),onClick:s,children:(0,X.jsx)(M,{})})]})}function Cd(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 wd=`pi-web-model-usage`;function Td(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 Ed(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Dd(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 Od(){try{let e=localStorage.getItem(wd);return e?Td(JSON.parse(e)):{}}catch{return{}}}function kd(e){try{localStorage.setItem(wd,JSON.stringify(e))}catch{}}function Ad(e){let t=Ed(Od(),e);return kd(t),t}var jd=[{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`}],Md=`pi-web-ui:prompt-templates`;function Nd(){try{let e=localStorage.getItem(Md);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 Pd(e){return jd.some(t=>t.id===e)}function Fd(e){return typeof e.title==`string`}var Id=(0,f.createContext)(null);function Ld(){let e=(0,f.useContext)(Id);if(!e)throw Error(`useTemplates must be used within TemplateProvider`);return e}function Rd({children:e,currentModelId:t}){let n=Z(),[r,i]=(0,f.useState)(Nd),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(null),[l,u]=(0,f.useState)(!1),[d,p]=(0,f.useState)(!1),[m,h]=(0,f.useState)(!1);(0,f.useEffect)(()=>{try{localStorage.setItem(Md,JSON.stringify(r))}catch{}},[r]);let g=(0,f.useMemo)(()=>{let e=new Map,t=new Set;for(let n of r)n.hidden?t.add(n.id):(Fd(n)&&!Pd(n.id)||Fd(n))&&e.set(n.id,n);let i=jd.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=>Fd(e)&&!Pd(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,f.useCallback)(()=>o(!0),[]),v=(0,f.useCallback)(e=>{window.dispatchEvent(new CustomEvent(`pi-web:fill`,{detail:e}))},[]),y=(0,f.useCallback)((e,t=!1)=>{h(t),e?(u(!1),c({...e})):(u(!0),c({id:ot(),icon:`📌`,title:``,desc:``,prompt:``}))},[]),b=(0,f.useCallback)(()=>{o(!1),c(null),h(!1)},[]),x=(0,f.useCallback)(()=>{d?(i([]),p(!1)):(p(!0),setTimeout(()=>p(!1),5e3))},[d]),S=(0,f.useCallback)(e=>{o(!1),v(e.prompt)},[v]),C=(0,f.useCallback)(e=>{o(!1),y(e,!0)},[y]),w=(0,f.useCallback)(()=>{o(!1),y(void 0,!0)},[y]),T=(0,f.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),m&&(o(!0),h(!1))},[m]),E=(0,f.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),m&&(o(!0),h(!1))},[m]),D=(0,f.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e.id||t.hidden)),c(null),m&&(o(!0),h(!1))},[m]),O=(0,f.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&&Fd(e)):!1;return(0,X.jsxs)(Id.Provider,{value:O,children:[e,a&&(0,X.jsx)(Vd,{templates:g,resetConfirm:d,onFill:S,onEditTpl:C,onNew:w,onResetToggle:x,onClose:b}),s&&(0,X.jsx)(Hd,{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&&Ad(t),b())},onClose:b})]})}function zd(){let e=Z(),{templates:t,fill:n,openEdit:r,toggleReset:i,resetConfirm:a}=Ld();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)(Bd,{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)(se,{})}),(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)(ae,{}),e(a?`tpl.resetConfirm`:`tpl.reset`)]})})]})}function Bd({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)(Ne,{})})]})}function Vd({templates:e,resetConfirm:t,onFill:n,onEditTpl:r,onNew:i,onResetToggle:a,onClose:o}){let s=Z();return(0,f.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)(M,{})})]}),(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)(Bd,{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)(se,{})}),(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)(ae,{}),s(t?`tpl.resetConfirm`:`tpl.reset`)]})})]})})}function Hd({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,f.useRef)(null);(0,f.useEffect)(()=>{let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l]),(0,f.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 p=()=>{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})},m=!!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(m?`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)(M,{})})]}),(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&&m&&n&&(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn ghost`,title:u(`tpl.restoreTip`),onClick:a,children:u(`tpl.restore`)}),!t&&m&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.removeTip`),onClick:o,children:[(0,X.jsx)(L,{}),` `,u(`tpl.remove`)]}),!t&&!m&&(0,X.jsxs)(`button`,{type:`button`,className:`btn template-btn ghost danger`,title:u(`tpl.deleteTip`),onClick:o,children:[(0,X.jsx)(L,{}),` `,u(`tpl.delete`)]})]}),(0,X.jsxs)(`div`,{className:`template-modal-actions-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn template-btn`,onClick:p,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)(ie,{}),` `,u(`tpl.sendNow`)]})]})]})]})})}function Ud(e,t){return!e||e.length===0?null:(0,X.jsx)(`span`,{className:`slot-toolbar`,children:e.map((e,n)=>Wd(e,n,t))})}function Wd(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 Gd(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)=>Wd(e,t,n))},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)(f.Fragment,{children:i},e.id))}else i.push(e)}),o(`tail`),a?(0,X.jsx)(X.Fragment,{children:r}):null}var Kd=`#ffffff`,qd=`#1e1e1e`,Jd=`.msg-actions, .msg-text-copy, .chead-copy, .stream-cursor, .msg-editor, .msg-collapse-btn, .msg-export-check, .toolcall-kill, .toolcall-open`;function Yd(e,t=800,n=2){let r=Math.max(e,t,1);return r*n<=16384?n:+(r<=16384)}function Xd(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=Qd(t.trim())}else if(r.includes(`,`)){let e=r.split(`,`).map(e=>e.trim());e.length===4&&(a=Qd(e.pop())),i=e}else i=r.split(/\s+/).filter(Boolean),i.length===4&&(a=Qd(i.pop()));if(i.length!==3)return null;let o=Zd(i[0]),s=Zd(i[1]),c=Zd(i[2]);return[o,s,c,a].some(e=>Number.isNaN(e))?null:{r:o,g:s,b:c,a}}function Zd(e){return e.endsWith(`%`)?Math.round($d(Number.parseFloat(e),0,100)*2.55):Math.round($d(Number.parseFloat(e),0,255))}function Qd(e){return e.endsWith(`%`)?$d(Number.parseFloat(e)/100,0,1):$d(Number.parseFloat(e),0,1)}function $d(e,t,n){return Math.min(n,Math.max(t,e))}function ef(e){let t=$d(Math.round(e.r),0,255),n=$d(Math.round(e.g),0,255),r=$d(Math.round(e.b),0,255);return e.a<.996?`rgba(${t}, ${n}, ${r}, ${Math.round($d(e.a,0,1)*1e3)/1e3})`:`rgb(${t}, ${n}, ${r})`}function tf(e,t){let n=$d(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 nf(e,t){let n=Xd(t)??{r:255,g:255,b:255,a:1},r=Xd(e);return!r||r.a<=.004?ef({...n,a:1}):ef(tf(r,{...n,a:1}))}function rf(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 af(e){return rf(e)>.45}function of(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 sf(){return getComputedStyle(document.documentElement).colorScheme.split(/\s+/).includes(`light`)?Kd:qd}function cf(e){let t=sf(),n=t;try{n=nf(of(`var(--bg)`),t)}catch{n=t}try{let e=nf(of(`var(--card-bg, var(--msgs-bg, var(--bg)))`),n),t=Xd(e);if(t&&rf(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=nf(e,n),r=Xd(e);if(r&&r.a>.04)return t}r=r.parentElement}return n}function lf(e){return e instanceof HTMLElement||e instanceof SVGElement?e.style:null}function uf(e,t){let n=Xd(e);return n?n.a<=.004?`transparent`:n.a>=.996?ef({...n,a:1}):ef(tf(n,{...Xd(t)??{r:255,g:255,b:255,a:1},a:1})):null}function df(e,t,n){let r=getComputedStyle(e),i=lf(t),a=n;if(i){let e=uf(r.backgroundColor,n);e===`transparent`?i.backgroundColor=`transparent`:e&&(i.backgroundColor=e,a=e);let t=uf(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=uf(r[e],a);t&&t!==`transparent`&&(i[e]=t)}let o=uf(r.fill,a);o&&o!==`transparent`&&r.fill!==`none`&&(i.fill=o);let s=uf(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++)df(o[e],s[e],a)}function ff(e){e.querySelectorAll(Jd).forEach(e=>e.remove())}function pf(e,t={}){t.includeThinking||e.querySelectorAll(`.thinking`).forEach(e=>e.remove()),t.includeTools||e.querySelectorAll(`.toolcall`).forEach(e=>e.remove())}function mf(e,t,n={}){let r=e.cloneNode(!0);return df(e,r,t),pf(r,n),ff(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 hf(e,t={}){let{toBlob:n}=await so(async()=>{let{toBlob:e}=await import(`./es-DIDZppIF.js`);return{toBlob:e}},[]),r=t.backgroundColor??cf(e),i=Xd(r),a=await n(e,{pixelRatio:t.pixelRatio??2,backgroundColor:r,cacheBust:!1,style:{colorScheme:i&&!af(i)?`dark`:`light`}});if(!a)throw Error(`toBlob returned null`);return a}function gf(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}function _f(e){return document.querySelector(`.msg[data-msg-id="${gf(e)}"]`)??document.querySelector(`[data-msg-id="${gf(e)}"]`)}function vf(){let e=Z(),t=ku(),[n,r]=(0,f.useState)(``),[i,a]=(0,f.useState)(!1),[o,s]=(0,f.useState)(!1),[c,l]=(0,f.useState)(`pi-web-ui`),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(``),y=(0,f.useRef)(null),b=(0,f.useRef)(null),x=(0,f.useRef)(`#ffffff`);if((0,f.useEffect)(()=>{t.open&&(d(!1),g(!1),v(``))},[t.open]),(0,f.useEffect)(()=>{if(!t.open)return;let e=e=>{e.key===`Escape`&&Au()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t.open]),(0,f.useLayoutEffect)(()=>{if(!t.open)return;let e=!1,n=0;m(!0);let r=()=>{if(e||!b.current)return;let i=[],a=!1;for(let e of t.selectedIds){let t=_f(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=cf(s??void 0);x.current=c;let l=document.createDocumentFragment();for(let e of i)l.appendChild(mf(e,c,{includeThinking:t.includeThinking,includeTools:t.includeTools}));b.current.replaceChildren(l);let u=y.current;if(u){u.style.backgroundColor=c;let e=Xd(c);if(u.style.colorScheme=e&&!af(e)?`dark`:`light`,s){let e=getComputedStyle(s).color;e&&(u.style.color=e)}}m(!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=Yd(n.scrollHeight,n.scrollWidth);if(t===0){v(e(`exportTooLong`));return}let r=await hf(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:()=>Au(),children:(0,X.jsx)(M,{})})]}),(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=>Mu({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=>Mu({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||p||t.selectedIds.length===0,title:e(`copyImageBtn`),children:[u||p?(0,X.jsx)(ve,{className:`saveimg-spin`}):h?(0,X.jsx)(qe,{}):(0,X.jsx)(Le,{}),(0,X.jsx)(`span`,{children:e(u||p?`savingImage`:h?`copied`:`copyImageBtn`)})]})]})]}),_?(0,X.jsx)(`div`,{className:`saveimg-error`,children:_}):null]})]})}var yf=new Map,bf=15,xf=30,Sf=250,Cf=1200,wf=1600;function Tf({kind:e,text:t,index:n,onRemoveQueued:r,onRecallQueued:i}){let a=Z();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.jsx)(`div`,{className:`msg-text`,children:(0,X.jsx)(Hc,{text:t,hardBreaks:!0})})})]})}function Ef({compaction:e}){let t=Z(),[,n]=(0,f.useState)(0);(0,f.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 Df(e){return e.content.some(e=>e.type===`toolCall`)}function Of({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:p,uiMessageActions:m,uiContextMessage:h,uiContextToolCall:g,uiChatEmpty:_,onUiAction:v}){let y=Z(),b=ku(),x=(0,f.useRef)(null),[S,C]=(0,f.useState)(!0),w=(0,f.useRef)(!0),T=(0,f.useRef)(0),E=(0,f.useRef)(0),O=(0,f.useRef)(!1),k=(0,f.useRef)(0),[A,j]=(0,f.useState)(()=>new Set),[M,N]=(0,f.useState)(!1),P=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,F=(0,f.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,f.useMemo)(()=>td(e.messages),[e.messages]),L=P.length>0?P[P.length-1].id:null,R=e.messages.length>xf?Math.max(0,e.messages.length-bf):0,ee=(0,f.useMemo)(()=>{let t=new Set;for(let n=0;n<R;n++){let r=e.messages[n];r.role!==`toolResult`&&(A.has(r.id)||t.add(r.id))}return t},[e.messages,R,A]),[te,ne]=(0,f.useState)(()=>new Set),[z,B]=(0,f.useState)(()=>new Set),V=(0,f.useRef)(new Map),re=(0,f.useRef)(new Map),ie=(0,f.useRef)(new Map),H=(0,f.useRef)(0),U=(0,f.useMemo)(()=>{let t=new Map;for(let n of e.messages)t.set(n.id,ud(n));return t},[e.messages]),ae=(0,f.useRef)(U);ae.current=U;let oe=(0,f.useRef)(te);oe.current=te;let se=e.messages.length>xf&&!M,ce=(0,f.useRef)(se);ce.current=se;let le=sd(e.messages,V.current,wf),ue=(0,f.useRef)(le);ue.current=le;let de=(0,f.useCallback)(()=>{let e=x.current;if(!e)return;if(!ce.current){ne(e=>e.size?new Set:e);return}let t=e.getBoundingClientRect(),n={top:t.top-Cf,bottom:t.bottom+Cf},r=[];for(let[e,t]of ie.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),oe.current.has(e)||W(e,n.bottom-n.top,ae.current.get(e))}let i=ad(r,n,ue.current,oe.current);for(let e of i.hide){let t=ie.current.get(e);t&&W(e,t.offsetHeight,ae.current.get(e))}ne(e=>od(e,i))},[]),fe=(0,f.useCallback)(()=>{H.current||=requestAnimationFrame(()=>{H.current=0,de()})},[de]);(0,f.useLayoutEffect)(()=>{de()},[de]);let pe=(0,f.useRef)(M);(0,f.useLayoutEffect)(()=>{pe.current&&!M&&de(),pe.current=M},[M,de]);let W=(0,f.useCallback)((e,t,n)=>{n!==void 0&&(re.current.set(e,{h:t,len:n}),V.current.set(e,t))},[]),me=(0,f.useCallback)((e,t)=>{W(e,t,ae.current.get(e))},[W]),G=(0,f.useCallback)(e=>{e&&ie.current.set(e.dataset.lazyId??``,e)},[]);(0,f.useEffect)(()=>{let t=new Set(e.messages.map(e=>e.id));for(let e of ie.current.keys())t.has(e)||(ie.current.delete(e),V.current.delete(e),re.current.delete(e));ne(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,A]),(0,f.useEffect)(()=>()=>cancelAnimationFrame(H.current),[]);let he=(0,f.useMemo)(()=>{let t=[];for(let n of e.messages){if(n.role!==`user`)continue;let e=n.content.map(e=>Fu(e)?.text??``).filter(Boolean).join(` `),r=uu(e),i=r?r.userMessage??`skill:${r.name}`:e.trim();i&&t.push({id:n.id,text:i})}return t},[e.messages]),ge=(0,f.useMemo)(()=>{let e=new Map;return he.forEach((t,n)=>e.set(t.id,n)),e},[he]),[_e,ve]=(0,f.useState)(-1),ye=(0,f.useRef)(-1),K=(0,f.useRef)(he);(0,f.useEffect)(()=>{K.current=he},[he]);let be=(0,f.useCallback)(()=>{let e=x.current,t=K.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,f.useEffect)(()=>{be()},[he,be]);let xe=(0,f.useCallback)(e=>{j(t=>t.has(e)?t:new Set(t).add(e))},[]);(0,f.useLayoutEffect)(()=>{Eu(e.messages.filter(wu).map(e=>({id:e.id,role:e.role,content:e.content})))},[e.messages]),(0,f.useEffect)(()=>{if(b.open){for(let e of b.selectedIds)xe(e);B(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,xe]),(0,f.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 Se=(0,f.useCallback)(e=>{j(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),Ce=(0,f.useCallback)(t=>{let n=e.messages.findIndex(e=>e.id===t);(0,D.flushSync)(()=>{n>=0&&n<R&&!A.has(t)&&xe(t),B(e=>e.has(t)?e:new Set(e).add(t))});let r=K.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&&(O.current=!0))})},[e.messages,R,A,xe]),[q,we]=(0,f.useState)(null),Te=(0,f.useRef)(null),J=(0,f.useRef)(null);(0,f.useEffect)(()=>{let t=Te.current;if(!t||t.convId!==e.conversationId){Te.current={convId:e.conversationId,ids:new Set(e.messages.filter(e=>e.role===`compactionSummary`).map(e=>e.id))},J.current=null,we(null);return}for(let n of e.messages)if(n.role===`compactionSummary`&&!t.ids.has(n.id)){t.ids.add(n.id),we(n.id);break}},[e.messages,e.conversationId]),(0,f.useEffect)(()=>{q&&J.current!==q&&(J.current=q,Ce(q))},[q,Ce]);let Ee=(0,f.useMemo)(()=>d?e.messages.find(e=>e.role===d.role&&e.timestamp===d.timestamp)?.id??null:null,[e.messages,d]);(0,f.useEffect)(()=>{if(d){if(Ee){Ce(Ee),p?.();return}e.sessionFile===d.path&&e.messages.length>0&&p?.()}},[Ee,Ce,p,d,e.sessionFile,e.messages.length]);let De=(0,f.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()<k.current,a=Cd({dSt:t,dSh:n,escaped:O.current,graceActive:i,stuck:w.current});a.reassert&&(k.current=Date.now()+Sf,e.scrollTop=e.scrollHeight),a.flipEscape&&(O.current=!0),r&&t>=0&&(O.current=!1),i||(t<0?w.current=r&&!O.current:r&&(w.current=!0)),C(w.current),be(),fe()},[be,fe]),Y=(0,f.useRef)(!1);(0,f.useEffect)(()=>{let t=Y.current;if(Y.current=!!e.isStreaming,t&&!e.isStreaming&&!O.current){let e=()=>{let e=x.current;e&&!O.current&&(e.scrollTop=e.scrollHeight,w.current=!0,C(!0))};requestAnimationFrame(()=>requestAnimationFrame(e));let t=setTimeout(e,180);return()=>clearTimeout(t)}},[e.isStreaming]),(0,f.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[P,e.isStreaming,t]);let Oe=e.queue.steering.join(`\0`)+``+e.queue.followUp.join(`\0`);(0,f.useEffect)(()=>{let e=x.current;e&&w.current&&(e.scrollTop=e.scrollHeight)},[Oe]),(0,f.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,f.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&&!O.current&&(e.scrollTop=e.scrollHeight,C(!0))}))});return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>n.disconnect()},[]);let ke=(0,f.useCallback)(()=>{if(!x.current)return;w.current=!0,O.current=!1,C(!0),k.current=Date.now()+Sf;let e=()=>{let e=x.current;e&&w.current&&!O.current&&(k.current=Date.now()+Sf,e.scrollTop=e.scrollHeight)};e(),requestAnimationFrame(()=>requestAnimationFrame(e)),setTimeout(e,120),setTimeout(e,300),setTimeout(e,600)},[]),Ae=(0,f.useRef)(null);(0,f.useEffect)(()=>{let e=Ae.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[je,Me]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=()=>{Me(x.current?.clientHeight??0),fe()};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[fe]);let Ne=he.length,Pe=(0,f.useMemo)(()=>Ne===0?27:Math.max(4,Math.min(27,Math.floor(((je||600)-16)/Ne)-3)),[Ne,je]),Fe=Pe<20;return(0,X.jsxs)(`div`,{className:`messages-wrap${b.open?` messages-exporting`:``}`,children:[(0,X.jsxs)(`div`,{className:`messages${M||S?``:` anchor-live`}`,ref:x,onScroll:De,children:[e.messages.length===0&&!e.streamingMessage&&(0,X.jsxs)(`div`,{className:`empty-state`,children:[(0,X.jsx)(zd,{}),_&&_.length>0&&(0,X.jsx)(`div`,{className:`chat-empty-slots`,children:Ud(_,v)})]}),e.messages.map((o,s)=>{let d=s<R,f=d&&A.has(o.id);if(d&&!f)return o.role===`toolResult`?null:(0,X.jsx)(nd,{message:o,onExpand:xe},o.id);let p=o.role===`user`?ge.get(o.id):void 0,_=!se||le.has(o.id)||z.has(o.id)||!te.has(o.id);return(0,X.jsx)(id,{id:o.id,show:_,height:dd(o.id,U.get(o.id)??-1,re.current,cd(o.role,o.customType)),containerRef:x,onMeasured:me,lazyRef:G,children:(0,X.jsx)(Gu,{uiMessageActions:m,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:o,qnIndex:p,qnActive:p===void 0?void 0:p===_e,onJump:Ce,toolResults:F,liveOutputs:Df(o)?t:yf,toolStatuses:n,streaming:e.isStreaming,onKillBash:i,onRetry:o.id===L?a:void 0,toolsWrap:l,toolImages:u,thinkingWrap:c,isLast:o.id===L,onEdit:r,questionAttachments:I.get(o.id),onCollapse:f?Se:void 0,searchActive:M,autoExpand:o.id===q},o.id)},o.id)}),e.streamingMessage&&(0,X.jsx)(Gu,{uiMessageActions:m,uiContextMessage:h,uiContextToolCall:g,onUiAction:v,message:e.streamingMessage,toolResults:F,liveOutputs:Df(e.streamingMessage)?t:yf,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)(Ef,{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)(Tf,{kind:`steer`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-steer-${t}`)),e.queue.followUp.map((e,t)=>(0,X.jsx)(Tf,{kind:`followUp`,text:e,index:t,onRemoveQueued:o,onRecallQueued:s},`q-fu-${t}`))]}),!S&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:ke,children:[(0,X.jsx)(et,{}),` `,y(`backToBottom`)]}),(0,X.jsx)(Sd,{containerRef:x,messages:P,collapsedIds:ee,toolResults:F,onExpand:xe,onProgrammaticScroll:()=>{O.current=!0,w.current=!1,C(!1)},open:M,onClose:()=>N(!1)}),he.length>0&&(0,X.jsxs)(`div`,{className:`qn-rail ${Fe?`many`:``}`,ref:Ae,"aria-label":y(`questionNavTitle`),style:{"--rail-gap":`${Pe}px`},children:[he.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,className:`qn-bar ${t===_e?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Ce(e.id),children:(0,X.jsxs)(`span`,{className:`qn-bar-text`,children:[t+1,`. `,e.text]})},e.id)),Fe&&(0,X.jsx)(`div`,{className:`qn-list`,children:he.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`qn-list-item ${t===_e?`active`:``}`,"aria-label":`${t+1}. ${e.text}`,onClick:()=>Ce(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)(vf,{})]})}function kf(e,t){return t?e.trim()?`${e.replace(/\s+$/,``)}\n${t}`:t:e}function Af(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 jf(e){return 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 Mf(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=new Set(e.map(jf).filter(e=>e!==null)),r=[...e];for(let e of t){let t=jf(e);if(t!==null){if(n.has(t))continue;n.add(t)}r.push(e)}return r}function Nf(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Pf=``;function Ff(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function If(e,t){return{first:!e.slice(0,t).includes(`
|
|
353
|
-
`),last:!e.slice(t).includes(`
|
|
354
|
-
`)}}var Lf=null;function Rf(){if(Lf?.isConnected)return Lf;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),Lf=e,e}function zf(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 Bf(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=Pf,e.appendChild(n),n.offsetTop}function Vf(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=If(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=Rf();if(zf(e,i)<=0)return r;let a=Bf(i,t.slice(0,n)),o=Bf(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:Ff(a,o,Nf(e))}var Hf=`pi-web-ui:prompt-history`,Uf=`pi-web-ui:prompt-history-settings`,Wf={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function Gf(e){let t=Wf;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 Kf(){try{let e=localStorage.getItem(Uf);return e?Gf(JSON.parse(e)):{...Wf}}catch{return{...Wf}}}function qf(e){let t=Gf(e);try{localStorage.setItem(Uf,JSON.stringify(t))}catch{}try{let e=Xf();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)),Zf(e)}catch{}}function Jf(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 Yf(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 Xf(){try{let e=localStorage.getItem(Hf);return e?Jf(JSON.parse(e)):[]}catch{return[]}}function Zf(e){let t=e;for(;t;)try{localStorage.setItem(Hf,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 Qf(e){let t=e.trim();if(!t)return;let n=Kf();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));let r=Xf(),i=Yf(r,t,n.maxEntries);i!==r&&Zf(i)}function $f(){try{localStorage.removeItem(Hf)}catch{}}function ep(e,t){let n=e.toLowerCase();return t===`skill`&&n.startsWith(`skill:`)?[n,n.slice(6)]:[n]}function tp(e,t){let n=t.toLowerCase();return n?e.filter(e=>ep(e.name,e.source).some(e=>e.startsWith(n))):[...e]}var np=new Set([`p`,`page`,`pages`,`web`,`网页`,`页面`]);function rp(e,t,n,r=10){if(!Array.isArray(t))return[];let i=String(n??``).toLowerCase(),a=i===``||np.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 ip(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.name,attachments:[{path:t.path,name:t.name,mode:`reference`,...t.type===`dir`?{isDir:!0}:{}}]})}return r}function ap(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 op(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function sp(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||!op(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 cp(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 lp(){return typeof window>`u`||typeof navigator>`u`||typeof window.matchMedia!=`function`?!1:cp({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}var up=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],dp=(0,f.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,p]=(0,f.useState)(!1),[m,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(``),[v,y]=(0,f.useState)(null),[b,x]=(0,f.useState)({}),S=(0,f.useRef)(null),C=(0,f.useRef)(null),[w,T]=(0,f.useState)(null);(0,f.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,f.useEffect)(()=>{d&&x(Od())},[d]),(0,f.useEffect)(()=>{d||(_(``),y(null))},[d]);let E=(0,f.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,f.useMemo)(()=>Dd(t,b),[t,b]),O=(0,f.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,f.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,M]=(0,f.useState)(!1),N=e?.availableThinkingLevels&&e.availableThinkingLevels.length>0?new Set(e.availableThinkingLevels):null,P=up.map(e=>({value:e,label:c(`thinking.${e}`),supported:!N||N.has(e)})),F=e=>P.find(t=>t.value===e)?.label??e;(0,f.useEffect)(()=>{d&&t.length===0&&!A&&!n&&(M(!0),$({type:`list_models`}))},[d,t.length,A,n]),(0,f.useEffect)(()=>{t.length>0&&M(!1)},[t.length]),(0,f.useEffect)(()=>{d&&(S.current?.querySelector(`.dd-item.active`))?.scrollIntoView({block:`nearest`})},[d,u,t.length]);let I=(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fe,{}),(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:p,align:`left`,menuClassName:`dd-menu-model`,menuRef:C,menuStyle:w==null?void 0:{width:w},direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`availableModels`)}),(0,X.jsxs)(`div`,{className:`dd-search-row`,children:[(0,X.jsx)(H,{}),(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);return(0,X.jsx)(_t,{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}),p(!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||a!==void 0&&a===t.id)&&(0,X.jsxs)(`span`,{className:`dd-model-badges`,children:[a!==void 0&&a===t.id&&(0,X.jsx)(`span`,{className:`dd-model-badge`,title:c(`globalDefaultBadge`),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`)})]})]})]})},e.key?`${t.id}::${e.key.name}`:t.id)})]})]}),(0,X.jsxs)(`div`,{className:`dd-footer`,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:()=>{p(!1),r()},children:c(`manageModels`)}),a!==void 0&&(u!==null&&u===a?(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>$({type:`clear_default_model`}),children:c(`clearGlobalDefault`)}):(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,disabled:u===null,onClick:()=>{u!==null&&$({type:`set_default_model`,modelId:u})},children:c(`setGlobalDefault`)}))]})]}),L=(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(j,{}),(0,X.jsx)(`span`,{className:`chip-sub`,children:c(`thinkingChip`,{level:e?F(e.thinkingLevel):`—`})})]}),open:m,onOpenChange:h,align:`left`,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:c(`thinkingLevel`)}),P.map(t=>(0,X.jsx)(_t,{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))]});return s===`model`?I:s===`thinking`?L:(0,X.jsxs)(X.Fragment,{children:[I,L]})}),fp=[`standard`,`ptc`,`minimal`,`cordis`];function pp(e){return[...e].sort((e,t)=>{let n=Number.isSafeInteger(e.order)?e.order:fp.indexOf(e.id),r=Number.isSafeInteger(t.order)?t.order:fp.indexOf(t.id),i=n>=0?n:1e3,a=r>=0?r:1e3;return i===a?e.id.localeCompare(t.id):i-a})}var mp=(0,f.memo)(function({preset:e,presets:t,defaultPreset:n,blank:r,conversationId:i,compact:a=!1}){let o=Z(),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(e?.id??n);if((0,f.useEffect)(()=>{u(e?.id??n)},[i,e?.id,n]),t.length===0)return null;let d=e?.locked||!r,p=pp(t),m=p.find(t=>t.id===e?.id),h=p.find(e=>e.id===l)??m,g=t=>{u(t),c(!1),r&&t!==e?.id&&$({type:`dsh_preset_select`,preset:t})};if(a){let t=m?.description??m?.id??o(`dshPreset`);return(0,X.jsx)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fe,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:d?`${t}(${o(`dshPresetLocked`)})`:t,children:[m?.name??m?.id??e?.name??o(`dshPreset`),d&&(0,X.jsx)(_e,{style:{marginLeft:3}})]})]}),open:s&&!d,onOpenChange:c,direction:`up`,align:`left`,children:p.map(t=>(0,X.jsxs)(_t,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??t.description??t.id,onClick:()=>g(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[t.name??t.id,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`)})]}),t.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:t.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)(Fe,{}),o(`dshPreset`)]}),(0,X.jsx)(gt,{trigger:(0,X.jsxs)(`span`,{title:m?.description??m?.id??``,children:[m?.name??m?.id??e?.name??`…`,d&&(0,X.jsxs)(`span`,{className:`dsh-preset-lock`,title:o(`dshPresetBlankOnly`),children:[(0,X.jsx)(_e,{}),` `,o(`dshPresetLocked`)]})]}),open:s&&!d,onOpenChange:c,children:p.map(t=>(0,X.jsxs)(_t,{active:t.id===e?.id,disabled:!!t.broken,title:t.broken??t.description??t.id,onClick:()=>g(t.id),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[t.name??t.id,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`)})]}),t.description&&!t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-desc`,children:t.description})]},t.id))}),!d&&(0,X.jsx)(`span`,{className:`dsh-preset-hint`,title:o(`dshPresetBlankOnly`),children:o(`dshPresetBlankOnly`)}),h?.id===`minimal`&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:o(`dshPresetMinimalNote`)}),(0,X.jsxs)(`button`,{type:`button`,className:`chip`,title:o(`dshPresetNewChat`),onClick:()=>{$({type:`new_chat`,preset:h?.id??l}),un()},children:[(0,X.jsx)(se,{}),` `,o(`dshPresetNewChat`)]})]})}),hp=[`read-only`,`workspace-write-never`,`danger-full-access`],gp=[`read-only`,`workspace-write-never`,`danger-full-access`];function _p(e){return e===`read-only`?`dshPermReadOnly`:e===`danger-full-access`?`dshPermFullAccess`:`dshPermWorkspaceWrite`}function vp(e){return e===`read-only`?`dshPermReadOnlyDesc`:e===`danger-full-access`?`dshPermFullAccessDesc`:`dshPermWorkspaceWriteDesc`}var yp=(0,f.memo)(function({current:e,options:t,defaultPreset:n,conversationId:r,compact:i=!1}){let a=Z(),[o,s]=(0,f.useState)(!1),[c,l]=(0,f.useState)(!1);(0,f.useEffect)(()=>{l(!1),s(!1)},[r]);let u=hp.filter(e=>t.some(t=>t.value===e));if(u.length===0)return null;let d=e??n,p=!!e&&!u.includes(e),m=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 r=a(p?`dshPermCustom`:_p(d)),i=p?e??r:a(vp(d));return(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(V,{}),(0,X.jsxs)(`span`,{className:`chip-sub`,title:i,children:[r,d===`danger-full-access`&&(0,X.jsx)(nt,{style:{marginLeft:3}})]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},direction:`up`,align:`left`,children:[u.map(e=>{let r=t.find(t=>t.value===e);return(0,X.jsxs)(_t,{active:e===d,title:r?.description??a(vp(e)),onClick:()=>m(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(_p(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(vp(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)(V,{}),a(`dshPerm`)]}),(0,X.jsx)(gt,{trigger:(0,X.jsxs)(`span`,{title:p?e:a(vp(d)),children:[a(p?`dshPermCustom`:_p(d)),d===`danger-full-access`&&(0,X.jsxs)(`span`,{className:`dd-preset-tag warn`,children:[(0,X.jsx)(nt,{}),` `,a(`dshPermFullAccessTag`)]})]}),open:o,onOpenChange:e=>{s(e),e||l(!1)},children:u.map(e=>{let r=t.find(t=>t.value===e);return(0,X.jsxs)(_t,{active:e===d,title:r?.description??a(vp(e)),onClick:()=>m(e),children:[(0,X.jsxs)(`span`,{className:`dd-preset-name`,children:[a(_p(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(vp(e))})]},e)})}),c&&(0,X.jsx)(`span`,{className:`dsh-preset-hint warn`,children:a(`dshPermConfirmFull`)})]})}),bp=lp(),xp=40,Sp=220,Cp=720,wp=`pi-web-ui:composer-height`,Tp=(0,f.memo)(function({streaming:e,messages:t,slashCommands:n,modelState:r,models:i,modelsLoading:a,attachments:o,onRemoveAttachment:s,onAddImageFiles:c,onAddLocalFiles:l,onAddPathAttachment:u,fileSearch:d,onSearchFiles:p,onNotice:m,onSent:h,onManageModels:g,providerKeys:_,defaultModel:v,quickPhrases:y,quickPhrasesEnabled:b,recallDrafts:x,composerLeading:S,composerActions:C,onUiAction:w,dshPermCurrent:T,dshPermOptions:E,dshPermDefault:D,dshPreset:O,dshPresets:k,dshPresetDefault:A,dshBlank:j,conversationId:M,sessionDraft:N,sessionId:P}){let F=Z(),I=hi(`ready`),L=gi(),{locale:R}=Ut(),{openPicker:ee}=Ld(),te=e=>R!==`zh`&&e.descriptionEn?e.descriptionEn:e.description??``,ne=e=>R!==`zh`&&e.argumentHintEn?e.argumentHintEn:e.argumentHint??``,[B,V]=(0,f.useState)(``),[re,ie]=(0,f.useState)(()=>{try{let e=Number(localStorage.getItem(wp));if(Number.isFinite(e)&&e>=xp&&e<=Cp)return e}catch{}return null}),H=(0,f.useRef)(null),[U,ae]=(0,f.useState)(null),[oe,se]=(0,f.useState)(0),ce=(0,f.useRef)(0),ue=(0,f.useRef)(0),de=(0,f.useRef)(new Map),fe=(0,f.useRef)(``),[pe,me]=(0,f.useState)(!1),[G,he]=(0,f.useState)(void 0),ge=(0,f.useRef)(null),_e=(0,f.useRef)(null),ve=(0,f.useRef)(null),K=(0,f.useRef)(-1),be=(0,f.useRef)(``),xe=(0,f.useRef)(0);(0,f.useEffect)(()=>{if(!x||x.length===0)return;let e=x.filter(e=>e.text&&e.seq>xe.current);e.length!==0&&(xe.current=e[e.length-1].seq,V(t=>e.reduce((e,t)=>kf(e,t.text),t)),K.current=-1,be.current=``,requestAnimationFrame(()=>{let e=ge.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)}))},[x]),(0,f.useEffect)(()=>(sn(e=>{V(t=>kf(t,e)),K.current=-1,be.current=``,requestAnimationFrame(()=>{let e=ge.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=e.value.length)})}),()=>sn(null)),[]),(0,f.useEffect)(()=>(ln(()=>{bp||requestAnimationFrame(()=>{ge.current?.focus()})}),()=>ln(null)),[]);let Se=2e4,Ce=!L&&P?`${M??``}${P}`:null,q=Ce&&P?`pi-web-ui:composer-draft:${P}`:null,Te=(0,f.useRef)(``),J=(0,f.useRef)(0),Ee=(0,f.useRef)(!1),De=(0,f.useRef)(0),Y=(0,f.useRef)(null),Oe=(0,f.useRef)(null),ke=(0,f.useRef)(0),Ae=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}},je=(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})},Me=()=>{Y.current&&=(clearTimeout(Y.current),null),Ee.current&&Ce&&q&&P&&Xe&&je(P,q,Te.current,J.current)},Ne=e=>{if(Te.current=e,Ee.current=!0,J.current=Date.now(),q){let t=e.slice(0,Se);try{t.trim()?localStorage.setItem(q,JSON.stringify({text:t,ts:J.current})):localStorage.removeItem(q)}catch{}}if(Ce&&P&&Xe){Y.current&&clearTimeout(Y.current);let e=P,t=q,n=J.current,r=Ce;Y.current=setTimeout(()=>{Y.current=null,r===Oe.current&&t&&je(e,t,Te.current,n)},2e3)}},Pe=(e,t)=>{K.current=-1,V(e),Le(e,t),Ne(e)};(0,f.useEffect)(()=>{let e=Ce,t=P,n=q;return()=>{Y.current&&=(clearTimeout(Y.current),null),Ee.current&&e&&t&&n&&Te.current.trim()&&je(t,n,Te.current,J.current)}},[Ce]),(0,f.useEffect)(()=>{Oe.current=Ce,Ee.current=!1,De.current=0,Te.current=``,J.current=0,V(``),ae(null),K.current=-1},[Ce]);let Fe=(0,f.useRef)(null);(0,f.useEffect)(()=>{let e=t.length===0,n=Fe.current!==Ce;Fe.current=Ce,I&&e&&(!bp||n)&&requestAnimationFrame(()=>{ge.current?.focus()})},[Ce,t.length,I]),(0,f.useEffect)(()=>{if(!Ce||!q||Ee.current||Te.current!==``)return;let e=Af(N&&N.text?{text:N.text.slice(0,Se),ts:N.ts}:null,Ae(q),De.current);e&&(De.current=e.ts,Te.current=e.text,J.current=e.ts,V(e.text),Le(e.text,null))});let Ie={builtin:F(`slashBuiltin`),extension:F(`slashExtension`),prompt:F(`slashPrompt`),skill:F(`slashSkill`),plugin:F(`slashPlugin`)},Le=(e,t)=>{fe.current=e;let r=e.match(/^\/([^\s]*)$/);if(r&&I){let e=tp(n,r[1].toLowerCase());ae(e.length>0?{kind:`slash`,items:e}:null),se(0);return}if(t===null||!I){ae(null);return}let i=sp(e,t);if(!i){ae(null);return}let a=[];try{a=Va()}catch{a=[]}let o=++ce.current,s=e,c=i.start,l=i.query,u=a.map(e=>({id:e.id,label:e.label,run:()=>{let t;try{t=Ha(e.id)?.search}catch{t=void 0}return typeof t==`function`?t(l):Promise.resolve([])}}));if(l&&typeof p==`function`&&u.push({id:`host:files`,label:F(`openFiles`),run:()=>Re(l)}),Zt(),u.push({id:`host:pages`,label:F(`browserControl`),run:()=>Promise.resolve(rp(F(`browserControl`),Xt(),l))}),u.length===0){ae(null);return}Promise.allSettled(u.map(e=>Promise.race([e.run(),new Promise((e,t)=>setTimeout(()=>t(Error(`at-mention timeout`)),2e3))]))).then(e=>{if(ce.current!==o||fe.current!==s)return;let t=[],n=[];e.forEach((e,r)=>{e.status!==`fulfilled`||t.length+n.length>=30||(u[r].id===`host:pages`&&Array.isArray(e.value)?t.push(...e.value):u[r].id===`host:files`?n.push(...ip(u[r].label,e.value)):n.push(...ap(u[r].id,u[r].label,e.value)))});let r=[...t,...n].slice(0,30);ae(r.length>0?{kind:`at`,start:c,items:r}:null),se(0)})},Re=e=>{if(typeof p!=`function`)return Promise.resolve([]);let t=++ue.current;return new Promise(n=>{de.current.set(t,n);try{p(t,e)}catch{de.current.delete(t),n([]);return}setTimeout(()=>{de.current.get(t)===n&&(de.current.delete(t),n([]))},3e3)})};(0,f.useEffect)(()=>{if(!d||!d.ok)return;let e=de.current.get(d.reqId);e&&(de.current.delete(d.reqId),e(d.results??[]))},[d]);let ze=e=>Le(e,null);(0,f.useEffect)(()=>{(ve.current?.querySelector(`.slash-item.active`))?.scrollIntoView({block:`nearest`})},[oe,U]);let Be=e=>{let t=U?.kind===`slash`?U.items:[],n=e??t[oe%Math.max(t.length,1)];if(!n){ae(null);return}let r=B.match(/^\/([^\s]*)([\s\S]*)$/),i=r?r[2]:``,a=`/${n.name} ${i}`;fe.current=a,V(a),ae(null),ge.current?.focus()},Ve=(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){ae(null);return}let o=ge.current,s=o?o.selectionStart??B.length:B.length,c=`${i.text??i.title} `,l=`${B.slice(0,a)}${c}${B.slice(s)}`;fe.current=l,V(l),ae(null);for(let e of i.attachments??[])try{u?.({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}:{}})}catch{}requestAnimationFrame(()=>{let e=ge.current;e&&(e.focus(),e.selectionStart=e.selectionEnd=a+c.length)})},He=()=>U?.kind===`slash`?U.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===oe?` active`:``}`,onMouseEnter:()=>se(t),onClick:()=>We(e),children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`/`,e.name]}),(0,X.jsx)(`span`,{className:`slash-source ${e.source}`,children:Ie[e.source]}),(0,X.jsxs)(`span`,{className:`slash-desc`,children:[te(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:ne(e)})]})]},e.name)):null,Ue=()=>U?.kind===`at`?U.items.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,className:`slash-item${t===oe?` active`:``}`,onMouseEnter:()=>se(t),onClick:()=>We(e),title:e.hint??e.title,children:[(0,X.jsxs)(`span`,{className:`slash-name`,children:[`@`,e.title]}),(0,X.jsx)(`span`,{className:`slash-source plugin`,children:e.providerLabel}),e.hint&&(0,X.jsx)(`span`,{className:`slash-desc`,children:e.hint})]},`${e.providerId}:${e.title}:${t}`)):null,We=e=>{U&&(U.kind===`slash`?Be(e):Ve(e,U.start))},Ge=async()=>{let e=[...t].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(`
|
|
355
|
-
`);if(!e){m(`warning`,F(`slashCopyEmpty`));return}try{await navigator.clipboard.writeText(e),m(`info`,F(`slashCopied`))}catch{m(`error`,F(`slashCopyFailed`))}},Ke=e=>{if(!e||e.length===0){m(`warning`,F(`foldersNotSupported`));return}let t=Array.from(e).filter(e=>pu(e.type)),n=Array.from(e).filter(e=>!pu(e.type)),r=Ye();t.length>0&&r?m(`warning`,r):t.length>0&&c(t),n.length>0&&l(n)},qe=e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t)if(e.kind===`file`&&pu(e.type)){let t=e.getAsFile();t&&n.push(t)}if(n.length===0)return;e.preventDefault();let r=Ye();if(r){m(`warning`,r);return}c(n)},Ye=()=>{let e=r?.model;if(!e?.id)return null;let t=i.find(t=>t.id===e.id);return t&&t.vision===!1?F(`modelNoVision`,{name:t.name}):null},Xe=I,Ze=(0,f.useRef)(B);(0,f.useEffect)(()=>{Ze.current=B},[B]),(0,f.useEffect)(()=>{ze(Ze.current)},[n]),(0,f.useEffect)(()=>{let e=e=>{let t=e.detail;V(t),ge.current?.focus()};return window.addEventListener(`pi-web:fill`,e),()=>window.removeEventListener(`pi-web:fill`,e)},[]),(0,f.useEffect)(()=>{if(!pe)return;let e=e=>{e.key===`Escape`&&me(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[pe]);let $e=(0,f.useRef)(null);(0,f.useEffect)(()=>{let e=ge.current,t=$e.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=re==null?Sp:Cp;e.style.maxHeight=`${a}px`;let o=Math.min(Math.max(e.scrollHeight,re??0),a);e.style.height=`${o}px`,e.style.overflowY=e.scrollHeight>o?`auto`:`hidden`,n&&(n.scrollTop=i+(t.getBoundingClientRect().height-r))},[B,re]);let et=()=>o.map(e=>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}:{}}:{}}),tt=(e=!1)=>{let t=B.trim(),n=o.some(e=>e.imageData||e.fileData||e.mode===`conversation`);if(t||n){if(!Xe){m(`error`,F(`netDisconnected`));return}if(t===`/help`){let e=ge.current?.closest(`.inputbox`)?.getBoundingClientRect();he(e?.width),me(!0),V(``),ge.current?.focus();return}if(t===`/copy`){V(``),ge.current?.focus(),Ge();return}if($({type:`prompt`,text:t,queue:e,attachments:et()})){if(t&&Qf(t),K.current=-1,be.current=``,V(``),q)try{localStorage.removeItem(q)}catch{}Y.current&&=(clearTimeout(Y.current),null),Ee.current=!1,De.current=Date.now(),Te.current=``,J.current=0,h();let e=r?.model;e&&Ad(`${e.provider}/${e.id}`),ge.current?.focus()}else m(`error`,F(`netDisconnected`))}},nt=(e,t=!1)=>{let n=e.trim();if(n){if(!Xe){m(`error`,F(`netDisconnected`));return}if($({type:`prompt`,text:n,queue:t,attachments:et()})){n&&Qf(n),K.current=-1,be.current=``,Me(),h();let e=r?.model;e&&Ad(`${e.provider}/${e.id}`),bp||ge.current?.focus()}else m(`error`,F(`netDisconnected`))}},rt=e=>{if(!(e.nativeEvent.isComposing||e.keyCode===229||Date.now()-ke.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(),We();return;case`Escape`:e.preventDefault(),ae(null);return}}if(e.key===`ArrowUp`||e.key===`ArrowDown`){if(e.ctrlKey||e.metaKey||e.altKey)return;let t=ge.current;if(!t)return;let n=e.key===`ArrowUp`,r=Vf(t);if(n&&!r.first||!n&&!r.last||!n&&K.current===-1)return;let i=Xf();if(i.length===0)return;if(e.preventDefault(),n){if(K.current===-1){be.current=B;let e=i.length-1;K.current=e;let t=i[e];V(t),ze(t),requestAnimationFrame(()=>{let e=ge.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];V(t),ze(t),requestAnimationFrame(()=>{let e=ge.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];V(t),ze(t),requestAnimationFrame(()=>{let e=ge.current;e&&(e.selectionStart=e.selectionEnd=t.length)})}else{K.current=-1;let e=be.current;V(e),ze(e),requestAnimationFrame(()=>{let t=ge.current;t&&(t.selectionStart=t.selectionEnd=e.length)})}}return}if(e.key===`Escape`&&K.current!==-1){e.preventDefault();let t=be.current;K.current=-1,V(t),ze(t),requestAnimationFrame(()=>{let e=ge.current;e&&(e.selectionStart=e.selectionEnd=t.length)});return}if(e.key===`Enter`){if(bp&&!e.shiftKey&&!(e.ctrlKey||e.metaKey))return;e.shiftKey||(e.preventDefault(),tt())}}},it=Xe&&(B.trim()!==``||o.some(e=>e.imageData||e.fileData||e.mode===`conversation`)),at=(0,f.useMemo)(()=>Pr((C??[]).filter(e=>e.source!==`host`&&!e.hidden)),[C]),ot=(0,f.useMemo)(()=>(S??[]).filter(e=>e.source!==`host`&&!e.hidden),[S]),st=C!==void 0,ct=(0,f.useMemo)(()=>Pr((C??[]).filter(e=>!e.hidden)),[C]),lt=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=>w?.(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)(W,{}):e.icon===`camera`?(0,X.jsx)(Je,{}):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:()=>w?.(e),children:t},e.id)},ut=()=>(0,X.jsx)(`div`,{className:`inputbox-actions`,children:e?it?(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:()=>tt(!0),children:(0,X.jsx)(ye,{})}),!L&&(0,X.jsx)(`button`,{type:`button`,className:`split-steer`,title:F(`steerTip`),"aria-label":F(`queueSteerTag`),onClick:()=>tt(),children:(0,X.jsx)(Qe,{})})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn stop`,title:F(`stopAgent`),onClick:()=>$({type:`abort`}),children:(0,X.jsx)(z,{})}):(0,X.jsx)(`button`,{type:`button`,className:`btn send`,title:F(`sendTip`),disabled:!it,onClick:()=>tt(),children:(0,X.jsx)(Qe,{})})}),dt={"host:composer-upload":(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:F(`uploadFile`),disabled:!Xe,onClick:()=>_e.current?.click(),children:(0,X.jsx)(le,{})}),"host:composer-templates":(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:F(`tpl.openPicker`),onClick:ee,children:(0,X.jsx)(we,{})}),"host:composer-model":(0,X.jsx)(dp,{only:`model`,state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,defaultModel:v,compact:!0}),"host:composer-thinking":(0,X.jsx)(dp,{only:`thinking`,state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,compact:!0}),"host:composer-dsh-perm":E&&E.length>0&&D!==void 0?(0,X.jsx)(yp,{compact:!0,current:T??null,options:E,defaultPreset:D,conversationId:M??``}):null,"host:composer-dsh-preset":k&&k.length>0&&A!==void 0?(0,X.jsx)(mp,{compact:!0,preset:O??null,presets:k,defaultPreset:A,blank:j??!1,conversationId:M??``}):null,"host:composer-send":ut()},ft=e=>e.source===`host`?(0,X.jsx)(f.Fragment,{children:dt[e.id]??null},e.id):lt(e);return(0,X.jsxs)(`div`,{ref:$e,className:`inputbar`,onDragOver:e=>{e.preventDefault()},onDrop:e=>{e.preventDefault(),e.stopPropagation(),Ke(e.dataTransfer?.files??null)},children:[o.length>0&&(0,X.jsxs)(`div`,{className:`attach-row`,children:[o.map(e=>(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:()=>s(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:()=>ae(null),children:`Esc`})]}),U.kind===`slash`?He():Ue()]}),pe&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>me(!1),children:(0,X.jsxs)(`div`,{className:`slash-help`,style:G?{width:G}: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:()=>me(!1),children:F(`close`)})]}),(0,X.jsx)(`div`,{className:`slash-help-body`,children:n.length===0?(0,X.jsx)(`div`,{className:`slash-help-empty`,children:F(`slashLoading`)}):n.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:Ie[e.source]}),(0,X.jsxs)(`span`,{className:`slash-help-desc`,children:[te(e),e.argumentHint&&(0,X.jsx)(`span`,{className:`slash-hint`,children:ne(e)})]})]},e.name))})]})}),b&&y.length>0&&(0,X.jsx)(`div`,{className:`quick-row`,"aria-label":F(`quickPhrases`),children:y.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`quick-chip`,title:`${F(`quickPhrasesTip`,{text:e})}(${F(`quickPhrasesSendTip`)})`,disabled:!Xe,onClick:()=>nt(e),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),nt(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(re??Sp),"aria-valuemin":xp,"aria-valuemax":Cp,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId);let t=ge.current?.getBoundingClientRect().height;H.current={startY:e.clientY,startH:typeof t==`number`&&Number.isFinite(t)?t:re??Sp,next:null}},onPointerMove:e=>{let t=H.current;if(!t)return;let n=Math.min(Cp,Math.max(xp,t.startH+(t.startY-e.clientY)));t.next=n,ie(n)},onPointerUp:()=>{let e=H.current?.next;if(H.current=null,e!=null)try{localStorage.setItem(wp,String(Math.round(e)))}catch{}},onPointerCancel:()=>{H.current=null},onDoubleClick:()=>{ie(null);try{localStorage.removeItem(wp)}catch{}}}),(0,X.jsx)(`input`,{ref:_e,type:`file`,multiple:!0,hidden:!0,onChange:e=>{Ke(e.target.files),e.target.value=``}}),(0,X.jsx)(`textarea`,{ref:ge,value:B,rows:1,placeholder:F(Xe?e?L?`placeholderStreamingQueued`:`placeholderStreaming`:`placeholderIdle`:`placeholderConnecting`),disabled:!Xe,onChange:e=>{Pe(e.target.value,e.target.selectionStart??e.target.value.length)},onCompositionEnd:()=>{ke.current=Date.now()},onBlur:Me,onKeyDown:rt,onPaste:qe}),(0,X.jsx)(`div`,{className:`composer-tools`,children:st?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[ot.map(lt),ct.start.map(ft)]}),ct.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:ct.center.map(ft)}),(0,X.jsx)(`div`,{className:`composer-tools-right`,children:ct.end.map(ft)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`composer-tools-left`,children:[ot.map(lt),(0,X.jsx)(`button`,{type:`button`,className:`btn attach-img`,title:F(`uploadFile`),disabled:!Xe,onClick:()=>_e.current?.click(),children:(0,X.jsx)(le,{})}),at.start.map(lt),(0,X.jsx)(`button`,{type:`button`,className:`btn tpl-open`,title:F(`tpl.openPicker`),onClick:ee,children:(0,X.jsx)(we,{})}),(0,X.jsx)(dp,{state:r,models:i,modelsLoading:a,onManageModels:g,providerKeys:_,defaultModel:v,compact:!0}),E&&E.length>0&&D!==void 0&&(0,X.jsx)(yp,{compact:!0,current:T??null,options:E,defaultPreset:D,conversationId:M??``}),k&&k.length>0&&A!==void 0&&(0,X.jsx)(mp,{compact:!0,preset:O??null,presets:k,defaultPreset:A,blank:j??!1,conversationId:M??``})]}),at.center.length>0&&(0,X.jsx)(`div`,{className:`composer-tools-center`,children:at.center.map(lt)}),(0,X.jsxs)(`div`,{className:`composer-tools-right`,children:[at.end.map(lt),ut()]})]})})]})]})}),Ep=(0,f.memo)(function({goal:e,models:t,modelsLoading:n,activeConversationId:r,uiGoalbarActions:i,onUiAction:a}){let o=Z(),{locale:s}=Ut(),c=s!==`zh`&&e.statusEn?e.statusEn:e.status||``,l=s!==`zh`&&e.wizard?.statusEn?e.wizard.statusEn:e.wizard?.status||``,u=gi(),d=!e.conversationId||e.conversationId===r,p=e.goal!==null&&d,[m,h]=(0,f.useState)(``),[g,_]=(0,f.useState)(e.reviewModel??``),[v,y]=(0,f.useState)(e.maxRounds),[b,x]=(0,f.useState)(e.locked),[S,C]=(0,f.useState)(!1),[w,T]=(0,f.useState)(!1),[E,D]=(0,f.useState)(!0);(0,f.useEffect)(()=>{_(e.reviewModel??``),y(e.maxRounds||0),x(e.locked)},[e.goal,e.reviewModel,e.maxRounds,e.locked]),(0,f.useEffect)(()=>{S&&t.length===0&&!w&&!n&&(T(!0),$({type:`list_models`}))},[S,t.length,w,n]),(0,f.useEffect)(()=>{t.length>0&&T(!1)},[t.length]);let O=()=>g?t.find(e=>e.id===g)?.name??g:o(`goalBarUseMainModel`),k=()=>{let e=m.trim();e&&($({type:`set_goal`,goal:e,...g?{reviewModel:g}:{},maxRounds:v,locked:b}),h(``),D(!1))},A=()=>{let e=m.trim();e&&($({type:`start_goal_wizard`,text:e,...g?{wizardModel:g}:{},maxRounds:v,locked:b}),h(``),D(!1))},j=i===void 0?[`host:goal-pill`,`host:goal-set`,`host:goal-wizard`,`host:goal-lock`,`host:goal-collapse`,`host:goal-model`,`host:goal-rounds`,`host:goal-clear`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),N=e=>{let t=new Set(e);return j.filter(e=>t.has(e.id)||e.source!==`host`)},P={"host:goal-pill":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-hint`,title:o(`goalBarPlaceholder`),onClick:()=>D(!1),children:[(0,X.jsx)(te,{}),` `,(0,X.jsx)(`span`,{children:o(`goalBarTitle`)})]}),"host:goal-set":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-btn`,disabled:!m.trim(),onClick:k,children:o(`goalBarSet`)}),"host:goal-wizard":(0,X.jsxs)(`button`,{type:`button`,className:`goalbar-btn wizard`,disabled:!m.trim(),title:o(`goalWizardTip`),onClick:A,children:[`🔍 `,o(`goalWizardBtn`)]}),"host:goal-lock":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(b?`goalBarLocked`:`goalBarUnlocked`),onClick:()=>x(e=>($({type:`set_goal_prefs`,locked:!e}),!e)),children:b?(0,X.jsx)(_e,{}):(0,X.jsx)(I,{})}),"host:goal-collapse":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-icon-btn`,title:o(`goalBarClear`),onClick:()=>D(!0),children:(0,X.jsx)(Ue,{})}),"host:goal-model":u?(0,X.jsx)(`p`,{className:`goalbar-dsh-note`,children:o(`dshNoReviewModel`)}):(0,X.jsxs)(gt,{trigger:(0,X.jsxs)(`span`,{className:`goalbar-opt`,children:[o(`goalBarReviewModel`),`: `,(0,X.jsx)(`b`,{children:O()})]}),open:S,onOpenChange:C,direction:`up`,children:[(0,X.jsx)(`div`,{className:`dd-header`,children:o(`goalBarReviewModel`)}),(w||n)&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`loading`)}),t.length===0&&!w&&!n&&(0,X.jsx)(`div`,{className:`dd-loading`,children:o(`noModels`)}),(0,X.jsx)(_t,{active:g===``,onClick:()=>{_(``),C(!1),$({type:`set_goal_prefs`,reviewModel:``})},children:o(`goalBarUseMainModel`)}),t.map(e=>(0,X.jsx)(_t,{active:g===e.id,onClick:()=>{_(e.id),C(!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:v,placeholder:o(`goalBarUnlimitedShort`),onChange:e=>{let t=parseInt(e.target.value,10);if(Number.isNaN(t)||t<0){y(0);return}y(t)},onBlur:()=>$({type:`set_goal_prefs`,maxRounds:v}),onKeyDown:e=>{e.key===`Enter`&&($({type:`set_goal_prefs`,maxRounds:v}),e.target.blur())}})]})},F=(e.wizard?.active??!1)&&d;if(F)return(0,X.jsx)(`div`,{className:`goalbar goalbar-active ${F?`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`)}),Gd(N([`host:goal-clear`]),{...P,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),onClick:()=>{$({type:`clear_goal`}),D(!0)},children:(0,X.jsx)(M,{})})},a)]})});if(p)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:[o(`goalBarReviewing`),` `,o(`goalBarRound`,{n:e.round})]}):(0,X.jsx)(`span`,{className:`goalbar-chip ${e.verdict===`pass`?`pass`:e.verdict===`fail`?`fail`:``}`,children:e.verdict===`pass`?o(`goalBarPassed`):e.verdict===`fail`?o(`goalBarFailed`):`${o(`goalBarRound`,{n:e.round||1})} · ${e.locked?o(`goalBarLocked`):o(`goalBarUnlocked`)}`}),(0,X.jsx)(`span`,{className:`goalbar-detail`,children:c}),Gd(N([`host:goal-clear`]),{...P,"host:goal-clear":(0,X.jsx)(`button`,{type:`button`,className:`goalbar-x`,title:o(`goalBarClear`),disabled:e.reviewing,onClick:()=>{$({type:`clear_goal`}),D(!0)},children:(0,X.jsx)(M,{})})},a)]})});if(E){let e=Gd(N([`host:goal-pill`]),P,a);return e?(0,X.jsx)(`div`,{className:`goalbar 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)(te,{})}),(0,X.jsx)(`input`,{className:`goalbar-input`,value:m,placeholder:o(`goalBarPlaceholder`),onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&k()}}),Gd(N([`host:goal-set`,`host:goal-wizard`,`host:goal-lock`,`host:goal-collapse`]),P,a)]}),(0,X.jsxs)(`div`,{className:`goalbar-opts`,children:[N([`host:goal-model`,`host:goal-rounds`]).filter(e=>e.source===`host`).map(e=>(0,X.jsx)(f.Fragment,{children:P[e.id]},e.id)),(0,X.jsx)(`span`,{className:`goalbar-lock-hint`,children:o(b?`goalBarLocked`:`goalBarUnlocked`)})]})]})});function Dp(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 Op=2e3;function kp(e,t,n=Op){return e.filter(e=>t-e.t<=n)}function Ap(e,t=Op){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 jp(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 Mp(e){let t=0;for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text?t+=jp(n.text):n.type===`thinking`&&typeof n.thinking==`string`&&n.thinking&&(t+=jp(n.thinking));return t}var Np=`@root`,Pp=[{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:working`,align:`start`},{id:`host:host-metrics`,align:`end`},{id:`host:cwd`,align:`end`}];function Fp({chat:e,bottombarItems:t,onUiAction:n}){let r=Z(),{engine:i}=mi(),a=hi(`workspaceRoots`),o=e.state,[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(``),[v,y]=(0,f.useState)(-1),b=(0,f.useRef)(null),x=(0,f.useRef)(null),S=e.pathCompletions.filter(e=>e.type===`dir`),C=e=>e.endsWith(`/`)?e:e+`/`,w=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;if(t===Np||t===`/`)return null;let n=t.lastIndexOf(`/`);if(n<0)return/^[A-Za-z]:$/.test(t)?Np:null;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?r+`/`:r};(0,f.useEffect)(()=>{if(!s)return;let e=setTimeout(()=>{$({type:`complete_path`,path:C(l)})},60);return()=>clearTimeout(e)},[l,s]),(0,f.useEffect)(()=>{if(!s||d===l)return;let e=setTimeout(()=>{$({type:`complete_path`,path:d})},150);return()=>clearTimeout(e)},[d,l,s]);let T=(0,f.useRef)([]),E=o?.isStreaming??!1,D=o?.streamingMessage?Mp(o.streamingMessage.content):0;if((0,f.useEffect)(()=>{if(!E){T.current=[];return}let e=Date.now(),t=T.current,n=t[t.length-1];n&&e-n.t<250||(T.current=kp([...t,{t:e,out:D}],e))},[E,D]),!o)return null;let O=o.stats,k=Dp(O.tokens),A=k.hitRate*100,j=k.totalInput===0?``:k.hitRate>=.7?`ok`:k.hitRate>=.4?`mid`:`warn`,M=k.totalInput>0?`${A.toFixed(1)}%`:`—`,N=E?Ap(T.current):0,P=e.ready?`ok`:e.status===`closed`?`error`:`busy`,F=e.ready?r(`connected`):e.status===`closed`?r(`reconnecting`):r(`connecting`),I=O.contextUsage,L=I.softCap??null,R=L!==null&&L>0&&L<I.contextWindow,ee=R?L:I.contextWindow,te=I.tokens!==null&&ee>0?Math.min(100,Math.round(I.tokens/ee*100)):null,ne=I.tokens!==null&&te!==null?`${I.estimated?`~`:``}${Ip(I.tokens)} / ${Ip(ee)}`:`—`,z=te===null?``:te>=80?`warn`:te>=50?`mid`:`ok`,B=o.queue.steering.length+o.queue.followUp.length,V=()=>{let e=o.cwd.replace(/\\/g,`/`);p(e),u(e),h(!1),_(``),c(!0)},re=e=>{let t=e.trim();t!==Np&&(t&&t!==o.cwd&&$({type:`set_cwd`,path:t}),c(!1))},ie=()=>{let e=g.trim();e&&($({type:`make_dir`,path:`${C(l)}${e}`}),setTimeout(()=>{$({type:`complete_path`,path:C(l)})},80),_(``),h(!1))},H=e=>{if(e.key===`Escape`)e.stopPropagation(),c(!1);else if(e.key===`Enter`&&!e.nativeEvent.isComposing)re(d);else if(e.key===`Tab`){if(S.length===0)return;e.preventDefault();let t=v>=0?(v+1)%S.length:0;y(t),p(S[t].path),u(S[t].path)}},U=w(l),ae={"host:conn":(0,X.jsxs)(`span`,{className:`status-item status-conn ${P}`,title:F,children:[(0,X.jsx)(`span`,{className:`status-dot ${P}`}),(0,X.jsx)(`span`,{className:`status-conn-label`,children:F})]}),"host:engine":i===`pi`?null:(0,X.jsx)(`span`,{className:`status-item engine-badge engine-${i}`,title:`${r(`engineBadge`)}: ${i}`,children:i===`dsh`?`DSH`:i}),"host:ctx":(()=>{let e=R?`${r(`contextUsage`)}: ${Ip(I.tokens??0)} / ${Ip(L)} (${r(`softCapMarker`)}, max ${Ip(I.contextWindow)})`:L!==null&&L>0?`${r(`contextUsage`)} · ${r(`softCapMarker`)}: ${Ip(L)}`:r(`contextUsage`);return(0,X.jsxs)(`span`,{className:`status-item status-ctx`,title:e,children:[(0,X.jsx)(`span`,{className:`ctx-label`,children:r(`context`)}),(0,X.jsx)(`span`,{className:`ctx-bar ${z}`,children:te!==null&&(0,X.jsx)(`span`,{className:`ctx-bar-fill`,style:{width:`${Math.min(te,100)}%`}})}),ne]})})(),"host:cost":(0,X.jsxs)(`span`,{className:`status-item`,title:r(`cumulativeCost`),children:[`$`,Lp(O.cost)]}),"host:cache":(0,X.jsxs)(`span`,{className:`status-item status-cache`,title:r(`cacheHitTip`,{read:Ip(k.read),write:Ip(k.write),miss:Ip(k.miss),input:Ip(k.totalInput)}),children:[r(`cacheHit`),(0,X.jsx)(`b`,{className:`cache-pct ${j}`,children:M})]}),"host:msg-count":(0,X.jsxs)(`span`,{className:`status-item`,title:r(`sessionMessages`),children:[r(`messages`),` `,O.totalMessages]}),"host:plugin-status":e.statuses.length>0?(0,X.jsx)(`span`,{className:`status-item ext-status`,title:r(`pluginStatus`),children:e.statuses.map(e=>e.text).join(` · `)}):null,"host:working":o.isStreaming?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`status-item working`,children:[(0,X.jsx)(`span`,{className:`working-spin`}),r(`working`),B>0&&(0,X.jsxs)(`span`,{className:`status-queue`,children:[`⏳ `,B,` `,r(`queued`)]})]}),(0,X.jsxs)(`span`,{className:`status-item status-rate`,title:r(`rateTip`),children:[(0,X.jsx)(`span`,{className:`working-spin rate-spin`}),N>0?`${Math.round(N)}${r(`tps`)}`:`…`]})]}):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)}%`,i=Number.isFinite(t.memoryPercent)?`${Math.round(t.memoryPercent)}%`:`—`;return(0,X.jsxs)(`span`,{className:`status-item status-host-metrics`,title:`${r(`hostResourcesTip`)}\n${r(`hostProcessor`)}: ${n} · ${r(`hostMemory`)}: ${i}`,children:[r(`hostProcessor`),` `,n,` · `,r(`hostMemory`),` `,i]})})(),"host:cwd":s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`status-cwd-backdrop`,onClick:()=>c(!1)}),(0,X.jsxs)(`div`,{className:`cwd-picker`,children:[(0,X.jsxs)(`div`,{className:`cwd-picker-head`,children:[(0,X.jsxs)(`span`,{className:`cwd-picker-title`,title:l===Np?r(`computer`):l,children:[l===Np?`💻`:(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{children:l===Np?r(`computer`):l})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-up`,disabled:l===Np,title:r(`computer`),onClick:()=>{u(Np),p(Np),y(-1)},children:`💻`}),(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!U,title:r(`cwdGoUp`),onClick:()=>{U&&(u(U),p(U),y(-1))},children:[`↑ `,r(`cwdGoUp`)]}),(()=>{let e=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``);return/^[A-Za-z]:/.test(t)?t.toLowerCase():t},t=e(l),n=!!l&&l!==Np&&t!==e(o.cwd)&&!a.some(n=>e(n)===t);return(0,X.jsxs)(`button`,{type:`button`,className:`cwd-up`,disabled:!n,title:r(`addWorkspaceRootHint`),onClick:()=>{n&&$({type:`set_workspace_roots`,roots:[...a,l]})},children:[`+ `,r(`addWorkspaceRoot`)]})})()]}),(0,X.jsxs)(`div`,{className:`cwd-picker-row`,children:[(0,X.jsx)(`input`,{ref:b,className:`status-cwd-input cwd-picker-input`,value:d,placeholder:r(`enterPath`),spellCheck:!1,onChange:e=>{p(e.target.value),y(-1)},onKeyDown:H}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,title:r(`cwdPickCurrent`),disabled:l===Np,onClick:()=>re(l),children:r(`cwdPickCurrent`)})]}),(0,X.jsxs)(`div`,{className:`cwd-list`,children:[S.length===0&&(0,X.jsx)(`div`,{className:`cwd-empty`,children:r(`cwdEmpty`)}),S.map(e=>(0,X.jsxs)(`div`,{className:`cwd-item`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`cwd-enter`,title:`${r(`cwdEnter`)} ${e.path}`,onClick:()=>{u(e.path),p(e.path),y(-1)},children:[(0,X.jsx)(De,{}),(0,X.jsx)(`span`,{className:`cwd-name`,children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,title:r(`cwdChoose`),onClick:()=>re(e.path),children:r(`cwdChoose`)})]},e.path))]}),(0,X.jsx)(`div`,{className:`cwd-picker-foot`,children:m?(0,X.jsxs)(`div`,{className:`cwd-newrow`,children:[(0,X.jsx)(`input`,{ref:x,value:g,autoFocus:!0,spellCheck:!1,placeholder:r(`cwdNewName`),onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing?(e.preventDefault(),ie()):e.key===`Escape`&&(e.stopPropagation(),h(!1),_(``))}}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn primary`,onClick:ie,children:r(`cwdCreate`)}),(0,X.jsx)(`button`,{type:`button`,className:`cwd-choose-btn`,onClick:()=>{h(!1),_(``)},children:r(`cwdCancel`)})]}):(0,X.jsxs)(`button`,{type:`button`,className:`cwd-newbtn`,onClick:()=>h(!0),children:[`+ `,r(`cwdNewFolder`)]})})]})]}):(0,X.jsxs)(`button`,{type:`button`,className:`status-item status-cwd`,title:r(`cwdTip`,{path:o.cwd}),onClick:V,children:[`📁 `,o.cwd]})},oe=t?t.map(e=>({id:e.id,entry:e,fallbackAlign:`start`})):Pp.map(({id:e,align:t})=>({id:e,entry:null,fallbackAlign:t})),se=[],ce=[],le=[];for(let{id:e,entry:t,fallbackAlign:r}of oe){if(t?.hidden)continue;let i=null;if(e.startsWith(`host:`)?i=ae[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=t?.align??r;a===`end`?le.push({key:e,node:i}):a===`center`?ce.push({key:e,node:i}):se.push({key:e,node:i})}let ue=e=>e.map((e,t)=>(0,X.jsxs)(f.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:ue(se)}),ce.length>0&&(0,X.jsx)(`div`,{className:`statusbar-center`,children:ue(ce)}),(0,X.jsx)(`div`,{className:`statusbar-right`,children:ue(le)})]})}function Ip(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K`:String(e)}function Lp(e){return e<=0?`0`:e<1e-4?`<0.0001`:e.toFixed(4).replace(/\.?0+$/,``)}function Rp({dialog:e}){let t=Z(),[n,r]=(0,f.useState)(``),[i,a]=(0,f.useState)(0),o=t=>{$({type:`dialog_response`,id:e.id,value:t})};(0,f.useEffect)(()=>{r(``),a(0);let e=e=>{e.key===`Escape`&&o(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[e.id]);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)(Hc,{text:e,rawHtml:!0})},t)),s.length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:t(`noOptions`)})]}),e.kind===`confirm`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(Hc,{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 zp=150;function Bp({anchorRef:e,enabled:t=!0,className:n,children:r}){let i=(0,f.useRef)(null),a=(0,f.useRef)(null),[o,s]=(0,f.useState)(!1),[c,l]=(0,f.useState)({left:0,top:0}),u=(0,f.useCallback)(()=>{a.current!==null&&(clearTimeout(a.current),a.current=null)},[]),d=(0,f.useCallback)(()=>{u(),a.current=setTimeout(()=>s(!1),zp)},[u]);return(0,f.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,f.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,f.useLayoutEffect)(()=>{if(!o)return;let t=i.current,n=e.current;if(!t||!n)return;let r=xs(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,f.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,D.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 Vp({question:e,owner:t,conversationTitle:n}){let r=Z(),i=e.conversationTitle||n,[a,o]=(0,f.useState)({}),[s,c]=(0,f.useState)({}),[l,u]=(0,f.useState)(0),[d,p]=(0,f.useState)(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);(0,f.useEffect)(()=>{o({}),c({}),u(0),p(e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1)},[e.id,e.deadline]),(0,f.useEffect)(()=>{if(!e.deadline)return;let n=setInterval(()=>{p(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]),(0,f.useEffect)(()=>{let e=e=>{e.key===`Escape`&&_()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[e.id]);let m=e.questions.length,h=e.questions[l];if(!h)return null;let g=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}:{}})},_=()=>{$({type:`question_answer`,id:e.id,answers:[],cancelled:!0,...t?{owner:t}:{}})},v=(e,t)=>{o(n=>{let r=n[e]??[];return{...n,[e]:r.includes(t)?r.filter(e=>e!==t):[...r,t]}})},y=(e,t,n)=>{if(n){v(e,t);return}let r={...a,[e]:[t]};o(r),l===m-1?g(r):u(l+1)},b=()=>{l===m-1?g(a):u(l+1)},x=t=>(e.questions.find(e=>e.id===t)?.options?.length??0)===0||(a[t]?.length??0)>0||(s[t]??``).trim()!==``,S=(h.options??[]).filter(e=>(a[h.id]??[]).includes(e.label)&&e.preview).map(e=>e.preview);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}),m>1&&(0,X.jsx)(`span`,{className:`question-progress`,children:r(`questionStep`,{cur:l+1,total:m})}),d>=0&&(0,X.jsx)(`span`,{className:`question-timer`,children:d>0?r(`questionTimeout`,{s:d}):r(`questionTimeoutExpired`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:r(`cancel`),onClick:_,children:`✕`})]}),(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsx)(`div`,{className:`set-section-title`,children:h.header??`${r(`modelQuestion`)} ${l+1}`}),(0,X.jsx)(`div`,{className:`question-head`,children:(0,X.jsx)(Hc,{text:h.question,rawHtml:!0})}),h.detail&&(0,X.jsx)(`div`,{className:`set-hint`,children:(0,X.jsx)(Hc,{text:h.detail,rawHtml:!0})}),(h.options?.length??0)>0&&(0,X.jsx)(`div`,{className:`set-list`,children:h.options.map(e=>{let t=(a[h.id]??[]).includes(e.label);return(0,X.jsx)(Hp,{label:e.label,description:e.description,mark:h.multiSelect?t?`☑ `:`☐ `:t?`● `:`○ `,active:t,onPick:()=>y(h.id,e.label,!!h.multiSelect)},e.label)})}),S.length>0&&(0,X.jsxs)(`div`,{className:`question-preview`,children:[(0,X.jsx)(`div`,{className:`question-preview-label`,children:r(`optionPreview`)}),S.map((e,t)=>(0,X.jsx)(`div`,{className:`question-preview-body`,children:(0,X.jsx)(Hc,{text:e,rawHtml:!0})},t))]}),(0,X.jsx)(`input`,{className:`set-prompt-input question-custom`,placeholder:r(`modelQuestionCustom`),value:s[h.id]??``,onChange:e=>c(t=>({...t,[h.id]:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x(h.id)&&b())}})]},h.id),(0,X.jsxs)(`div`,{className:`dialog-nav`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss-inline`,onClick:_,children:r(`cancel`)}),(0,X.jsxs)(`div`,{className:`dialog-nav-right`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dialog-prev`,disabled:l===0,onClick:()=>u(l-1),children:r(`previous`)}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-submit`,disabled:!x(h.id),onClick:b,children:l===m-1?r(`modelQuestionSubmit`):r(`next`)})]})]})]})}function Hp({label:e,description:t,mark:n,active:r,onPick:i}){let a=(0,f.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)(Hc,{text:e,rawHtml:!0})]}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`set-row-desc`,children:(0,X.jsx)(Hc,{text:t,rawHtml:!0})}),(0,X.jsx)(Bp,{anchorRef:a,enabled:Ss(),className:`question-desc-tip`,children:(0,X.jsx)(Hc,{text:t,rawHtml:!0})})]})]})}var Up=e=>`'${e.replace(/'/g,`'\\''`)}'`,Wp=`pi-web-ui:scm-sidebar-width`;function Gp(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 Kp(e){return e===null||e.trim()===``?300:Gp(Number(e))}function qp(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 Jp(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>n.every(t=>qp(e,t)))}var Yp=`scm-commit-history`;function Xp(e=localStorage){try{let t=e.getItem(Yp);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>typeof e==`string`&&e.length>0):[]}catch{return[]}}function Zp(e,t=localStorage){let n=e.trim();if(!n)return Xp(t);let r=[n,...Xp(t).filter(e=>e!==n)].slice(0,20);try{t.setItem(Yp,JSON.stringify(r))}catch{}return r}var Qp={idx:-1,draft:``};function $p(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:Qp,text:t.draft}:{state:{idx:t.idx-1,draft:t.draft},text:e[t.idx-1]}}function em(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 tm({chat:e,terminal:t,active:n,onSwitchToTerminal:r,uiScmToolbar:i,onUiAction:a}){let o=Z(),[s,c]=(0,f.useState)(null),[l,u]=(0,f.useState)([]),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(new Map),[g,_]=(0,f.useState)(`changes`),[v,y]=(0,f.useState)([]),[b,x]=(0,f.useState)(null),[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(!1),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(!1),[M,N]=(0,f.useState)(!1),[P,F]=(0,f.useState)(!1),[I,L]=(0,f.useState)(null),[R,te]=(0,f.useState)(!1),[ne,z]=(0,f.useState)(!1),[B,V]=(0,f.useState)(null),[re,ie]=(0,f.useState)(()=>Kp(localStorage.getItem(Wp))),[H,U]=(0,f.useState)(``),[ae,se]=(0,f.useState)(``),[ce,le]=(0,f.useState)(()=>Xp()),ue=(0,f.useRef)(Qp),de=(0,f.useRef)(0),fe=(0,f.useRef)(-1),pe=(0,f.useRef)(-1),W=(0,f.useRef)(-1),me=(0,f.useRef)(-1),G=(0,f.useRef)(-1),he=(0,f.useRef)(void 0),ge=(0,f.useRef)(null),_e=(0,f.useRef)([]),ve=(0,f.useRef)(re);ve.current=re;let ye=(0,f.useRef)(null),K=(0,f.useCallback)(e=>{try{localStorage.setItem(Wp,String(e))}catch{}},[]),be=(0,f.useCallback)(e=>{e.preventDefault();let t=e.clientX,n=ve.current,r=ye.current?.getBoundingClientRect().width??0,i=n,a=e=>{i=Gp(n+(e.clientX-t),r),ie(i)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),document.body.classList.remove(`panel-resizing`),K(i)};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),document.body.classList.add(`panel-resizing`)},[K]),xe=(0,f.useCallback)(()=>{ie(300),K(300)},[K]),Se=(0,f.useCallback)(e=>{if(e.reqId===fe.current){if(fe.current=-1,N(!1),L(null),!e.ok){L(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),p(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===pe.current){if(pe.current=-1,j(!1),!e.ok){L(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===me.current){if(me.current=-1,F(!1),!e.ok){L(e.error??o(`scmQueryFailedShort`));return}y((e.history??[]).map(e=>({...e})))}else if(e.reqId===W.current){if(W.current=-1,T(!1),!e.ok){L(e.error??o(`scmQueryFailedShort`));return}C(e.text??``)}else if(e.reqId===G.current){if(G.current=-1,z(!1),!e.ok){V(e.error??o(`scmGenMsgFail`));return}V(null),U(e.text??``)}},[]);(0,f.useEffect)(()=>{let t=e.scmData;t&&t.type===`scm_data`&&Se(t)},[e.scmData,Se]);let Ce=(0,f.useCallback)((t,n)=>{if(!e.ready||e.status!==`open`)return!1;let r=++de.current;return $({...t,reqId:r})?(n.current=r,!0):(--de.current,!1)},[e.ready,e.status]),q=(0,f.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([]),se(``),F(!1),me.current=-1,x(null),C(``),k(null),D(null),V(null),z(!1),G.current=-1),he.current=e.state.cwd,L(null),Ce({type:`scm_status`},fe)&&(n||N(!0)))},[e.ready,e.state?.cwd,e.status,Ce]),we=(0,f.useCallback)(e=>{if(D(e),x(null),ge.current=e,e.x===`?`&&e.y===`?`){k({file:e,staged:``,worktree:``,untracked:!0});return}j(!0),L(null),Ce({type:`scm_filediff`,path:e.path},pe)||j(!1)},[Ce]),Te=(0,f.useCallback)(e=>{x(e),D(null),k(null),C(``),T(!0),L(null),Ce({type:`scm_commit`,hash:e.hash},W)||T(!1)},[Ce]),J=(0,f.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=ot(),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]),De=(0,f.useCallback)(()=>{let e=H.trim();if(!e||R)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);J(`git commit`,`git commit -m "${t}"`),le(Zp(e)),U(``),ue.current=Qp},[H,R,J]),Y=(0,f.useCallback)(()=>{let e=H.trim();if(!e||R)return;let t=e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/`/g,"\\`").replace(/\$/g,`\\$`);J(`git commit`,`git add -A && git commit -m "${t}"`),le(Zp(e)),U(``),ue.current=Qp},[H,R,J]),Oe=(0,f.useCallback)(e=>{R||J(`git add`,`git add -- ${Up(e.path)}`)},[R,J]),ke=(0,f.useCallback)(e=>{R||J(`git reset`,`git reset HEAD -- ${Up(e.path)}`)},[R,J]),Ae=(0,f.useCallback)(()=>{if(!d||R)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,R,J]),je=(0,f.useCallback)(()=>J(`git push`,`git push`),[J]),Me=(0,f.useCallback)(()=>J(`git pull`,`git pull`),[J]),Ne=(0,f.useCallback)(()=>{ne||R||!e.ready||e.status!==`open`||(V(null),Ce({type:`scm_commitmsg`},G)?z(!0):V(o(`scmGenMsgFail`)))},[ne,R,e.ready,e.status,Ce,o]),Pe=(0,f.useCallback)(()=>{Ce({type:`scm_history`},me)||(me.current=-1)},[Ce]);(0,f.useEffect)(()=>{n&&q()},[n,q]),(0,f.useEffect)(()=>{g===`history`&&s&&Pe()},[g,s,Pe]),(0,f.useEffect)(()=>{e.scmDirty>0&&n&&q(!1,!0)},[e.scmDirty]),(0,f.useEffect)(()=>{if(!n||!e.ready||e.status!==`open`)return;let t=setInterval(()=>{document.visibilityState!==`hidden`&&q(!1,!0)},3e4);return()=>clearInterval(t)},[n,e.ready,e.status,q]),(0,f.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`&&(q(!1,!0),g===`history`&&s&&Pe())},[e.terminals,n,e.ready,e.status,q,g,s,Pe]);let Ie={staged:o(`scmStaged`),unstaged:o(`scmUnstaged`),untracked:o(`scmUntracked`),both:o(`scmStagedUnstaged`)},Le=Jp(v,ae),Re=e=>{let t=e.split(`
|
|
356
|
-
`);return(0,X.jsx)(`pre`,{className:`scm-diff-pre`,children:t.map((e,t)=>{let n=``;return e.startsWith(`diff --git`)||e.startsWith(`index `)||e.startsWith(`new file`)||e.startsWith(`deleted file`)||e.startsWith(`old mode`)||e.startsWith(`new mode`)||e.startsWith(`similarity index`)||e.startsWith(`rename `)||e.startsWith(`copy `)||e.startsWith(`Binary files`)||e.startsWith(`---`)||e.startsWith(`+++`)?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,X.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})},ze=i===void 0?[`host:scm-changes`,`host:scm-history`,`host:scm-refresh`,`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`,`host:scm-term`].map(e=>({id:e,source:`host`})):i.filter(e=>!e.hidden),Be=[`host:scm-branch`,`host:scm-switch`,`host:scm-push`,`host:scm-pull`,`host:scm-input`,`host:scm-genmsg`,`host:scm-commit`,`host:scm-commit-all`],Ve=(e,t)=>{let n=new Set(e);return ze.filter(e=>n.has(e.id)||t&&e.source!==`host`)},He=e=>i===void 0||!i.some(t=>t.id===e&&t.hidden),Ue={"host:scm-changes":(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":g===`changes`,className:g===`changes`?`active`:``,onClick:()=>{_(`changes`),L(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`),L(null)},children:o(`scmHistory`)}),"host:scm-refresh":(0,X.jsx)(`button`,{type:`button`,className:`panel-refresh`,title:o(`scmRefreshTip`),disabled:M,onClick:()=>q(!0),children:(0,X.jsx)(oe,{className:M?`scm-spin`:``})}),"host:scm-branch":(0,X.jsxs)(`select`,{className:`scm-select`,value:d,disabled:R||l.length===0,title:o(`scmSwitchBranch`),onChange:e=>p(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||R,title:o(`scmSwitchBranchTip`,{branch:d}),onClick:Ae,children:[(0,X.jsx)(Ee,{}),o(`scmSwitch`)]}),"host:scm-push":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||R,title:o(`scmPushTip`),onClick:je,children:[(0,X.jsx)(Qe,{}),o(`scmPush`)]}),"host:scm-pull":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:!s||s.detached||R,title:o(`scmPullTip`),onClick:Me,children:[(0,X.jsx)(et,{}),o(`scmPull`)]}),"host:scm-input":(0,X.jsx)(`input`,{className:`scm-commit-input`,value:H,placeholder:o(`scmCommitPlaceholder`),disabled:R,title:ce.length>0?o(`scmCommitHistoryTip`):void 0,onChange:e=>{U(e.target.value),ue.current=Qp},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Enter`){De();return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){let t=$p(ce,ue.current,H,e.key===`ArrowUp`?`up`:`down`);t&&(e.preventDefault(),ue.current=t.state,U(t.text))}}}}),"host:scm-genmsg":(0,X.jsxs)(`button`,{type:`button`,className:`btn`,disabled:ne||R||!s||s.files.length===0,title:o(`scmGenMsgTip`),onClick:Ne,children:[(0,X.jsx)(Fe,{className:ne?`scm-spin`:``}),o(ne?`scmGenMsgRunning`:`scmGenMsg`)]}),"host:scm-commit":(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!H.trim()||R,title:o(`scmCommitTip`),onClick:De,children:[(0,X.jsx)(Ke,{}),o(`scmCommit`)]}),"host:scm-commit-all":(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!H.trim()||R,title:o(`scmCommitAllTip`),onClick:Y,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)(Ee,{}),o(`scmTitle`)]}),(0,X.jsx)(`div`,{className:`scm-view-tabs`,role:`tablist`,children:Gd(Ve([`host:scm-changes`,`host:scm-history`],!1),Ue,a)}),Gd(Ve([`host:scm-refresh`],!0),Ue,a)]}),(0,X.jsxs)(`div`,{className:`scm-row`,children:[(0,X.jsxs)(`span`,{className:`scm-branch-current`,title:o(`scmCurrentBranch`),children:[(0,X.jsx)(Ee,{}),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})]}),Gd(Ve(Be,!1),Ue,a)]}),B&&(0,X.jsx)(`div`,{className:`scm-gen-error`,role:`alert`,title:o(`close`),onClick:()=>V(null),children:B})]}),(0,X.jsxs)(`div`,{className:`scm-body`,ref:ye,style:{"--scm-sidebar-w":`${re}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:ae.trim()?`${Le.length}/${v.length}`:v.length})]}),v.length>0&&!R&&(0,X.jsx)(`input`,{className:`scm-history-filter`,value:ae,placeholder:o(`scmHistoryFilterPlaceholder`),title:o(`scmHistoryFilterTip`),onChange:e=>se(e.target.value)}),(0,X.jsx)(`div`,{className:`scm-history-list`,children:R?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNotGitRepo`)}):!s||P?(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`)}):Le.length===0?(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmHistoryFilterEmpty`)}):Le.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:R?(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=em(e),n=m.get(e.path);return(0,X.jsxs)(`div`,{className:`scm-file ${E?.path===e.path?`active`:``}`,title:Ie[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: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:[I&&(0,X.jsx)(`div`,{className:`scm-error`,children:I}),!b&&!I&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectCommitHint`)}),b&&w&&!I&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),b&&!w&&!I&&S?Re(S):null]}):(0,X.jsxs)(X.Fragment,{children:[I&&(0,X.jsx)(`div`,{className:`scm-error`,children:I}),!E&&!I&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmSelectFileHint`)}),E&&!O&&!I&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmLoading`)}),E&&O&&O.untracked&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmUntrackedNote`)}),E&&O&&!O.untracked&&(0,X.jsxs)(X.Fragment,{children:[O.staged&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmStaged`)}),Re(O.staged)]}),O.worktree&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`scm-diff-section`,children:o(`scmUnstaged`)}),Re(O.worktree)]}),!O.staged&&!O.worktree&&(0,X.jsx)(`div`,{className:`scm-empty`,children:o(`scmNoDiff`)})]})]})})]})]}),(0,X.jsxs)(`div`,{className:`scm-hint`,children:[(0,X.jsx)(ee,{}),(0,X.jsx)(`span`,{children:o(`scmRunsInTerminal`)}),He(`host:scm-term`)&&(0,X.jsx)(`button`,{type:`button`,className:`scm-goto-term`,onClick:r,children:o(`scmViewTerminal`)})]})]})}function nm({entry:e}){let t=(0,f.useRef)(null),n=Z();return(0,f.useEffect)(()=>{let r=t.current;if(!r)return;let i;try{i=e.module.mount(r,jo(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 rm({pluginId:e,info:t,epoch:n,failed:r}){let i=Z(),[a,o]=(0,f.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),So(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 im({onAction:e}){let t=Jr(),n=(0,f.useMemo)(()=>t?ti(t.entries):[],[t]),{items:r,selectParents:i}=(0,f.useMemo)(()=>ei(n),[n]),a=(0,f.useMemo)(()=>ni(r),[r]),o=(0,f.useMemo)(()=>t?Zr(t.slot,t.target):void 0,[t,t?.slot,t?.target.kind]),s=(0,f.useRef)(null),c=(0,f.useRef)(null),[l,u]=(0,f.useState)(null),[d,p]=(0,f.useState)(-1),[m,h]=(0,f.useState)(-1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(0),b=(0,f.useRef)(-1),x=e=>{b.current=e,p(e)},S=(0,f.useMemo)(()=>m>=0?ti(r[m]?.children??[]):[],[r,m]),C=(0,f.useMemo)(()=>ni(S),[S]),w=e=>{let n=r[e];if(t&&n&&!$r(n,o)){if(n.children?.length){h(e);return}T(n,t)||Gr()}},T=(t,n,r)=>t.source===`host`&&n.onHostAction?n.onHostAction(t,n.target)===!0:(e(t,n.target,r),!1),E=(0,f.useRef)(w);if((0,f.useLayoutEffect)(()=>{E.current=w}),(0,f.useEffect)(()=>{if(!t){b.current=-1,p(-1),h(-1);return}let e=ii(r,-1,1,o);b.current=e,p(e),h(-1),s.current?.focus()},[t,r,o]),(0,f.useLayoutEffect)(()=>{if(!t){u(null);return}let e=s.current;if(!e)return;let n=e.getBoundingClientRect();u(Xr(t.x,t.y,n.width,n.height,window.innerWidth,window.innerHeight))},[t,r]),(0,f.useLayoutEffect)(()=>{let e=c.current,t=s.current;if(m<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)},[m,r]),(0,f.useEffect)(()=>{if(!t)return;let e=e=>s.current&&e instanceof Node&&s.current.contains(e),n=t=>{e(t.target)||Gr()},r=t=>{e(t.target)||Gr()},i=()=>Gr();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,f.useEffect)(()=>{if(!t)return;let e=e=>{let t=ii(r,b.current,e,o);b.current=t,p(t)},n=t=>{switch(t.key){case`Escape`:t.preventDefault(),Gr();return;case`Tab`:Gr();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`:m>=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,m,o]),(0,f.useEffect)(()=>{d<0||s.current?.querySelector(`[data-ctx-active="true"]`)?.scrollIntoView?.({block:`nearest`})},[d]),!t)return null;let O=e=>{let n=i.get(e.id);if(n){if($r(n.parent,o))return;t&&!T(n.parent,t,n.value)&&Gr();return}$r(e,o)||T(e,t)||Gr()},k=(e,t,n)=>{let r=$r(e,o),i=!!e.children?.length,a=oi(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?m===t:void 0,"data-ctx-active":s?`true`:void 0,onMouseEnter:n?()=>{x(t),i&&!r&&h(t)}:void 0,onClick:()=>n?w(t):O(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&&m===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):k(e.entry,e.index,!1))}):null]},`${e.id}#${t}`)};return(0,D.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):k(e.entry,e.index,!0))}),document.body)}var am=0,om=[],sm=new Map,cm=new Set;function lm(){for(let e of cm)try{e()}catch{}}function um(e){let t=sm.get(e);t!==void 0&&(clearTimeout(t),sm.delete(e))}function dm(e){let t=e.id||`banner-${Date.now()}-${++am}`,n={...e,id:t,type:e.type||`info`,persistent:!!e.persistent,timeoutMs:e.timeoutMs??5e3,dismissible:e.dismissible!==!1};if(um(t),!n.persistent&&n.timeoutMs&&n.timeoutMs>0){let e=setTimeout(()=>{fm(t)},n.timeoutMs);sm.set(t,e)}let r=om.findIndex(e=>e.id===t);if(r>=0){let e=[...om];e[r]=n,om=e}else om=[...om,n];return lm(),t}function fm(e){um(e);let t=om.find(t=>t.id===e);if(t){om=om.filter(t=>t.id!==e);try{t.onClose?.()}catch{}lm()}}function pm(e){let t=om.filter(e);if(t.length!==0){for(let e of t){um(e.id);try{e.onClose?.()}catch{}}om=om.filter(t=>!e(t)),lm()}}function mm(){return om}function hm(e){return cm.add(e),()=>{cm.delete(e)}}function gm(){return(0,f.useSyncExternalStore)(hm,mm,mm)}function _m({type:e}){switch(e){case`question`:return(0,X.jsx)(q,{className:`banner-icon banner-icon-question`});case`warning`:return(0,X.jsx)(nt,{className:`banner-icon banner-icon-warning`});case`error`:return(0,X.jsx)(rt,{className:`banner-icon banner-icon-error`});case`success`:return(0,X.jsx)(qe,{className:`banner-icon banner-icon-success`});default:return(0,X.jsx)(Se,{className:`banner-icon banner-icon-info`})}}var vm=(0,f.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)(_m,{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(),fm(e.id)},"aria-label":`Close banner`,title:`关闭通知`,children:(0,X.jsx)(M,{})})]})}),ym=(0,f.memo)(function(){let e=gm();return e.length===0?null:(0,X.jsx)(`aside`,{className:`banner-container`,"aria-label":`Notifications`,children:e.map(e=>(0,X.jsx)(vm,{banner:e},e.id))})});function bm({provider:e,flow:t,result:n}){let r=Z(),i=t?.event,a=e.oauthName??e.name,[o,s]=(0,f.useState)(``);return(0,f.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 xm({piConfigured:e,piAgentInstalled:t,providers:n,providerOAuthFlows:r,providerOAuthResults:i,installResult:a,onClose:o}){let s=Z(),c=_i(),[l,u]=(0,f.useState)(!1),[d,p]=(0,f.useState)(``),[m,h]=(0,f.useState)(``),[g,_]=(0,f.useState)(!1);(0,f.useEffect)(()=>{$({type:`list_providers`}),$({type:`list_provider_oauth_flows`})},[]),(0,f.useEffect)(()=>{e&&o()},[e,o]),(0,f.useEffect)(()=>{a&&u(!1)},[a]),(0,f.useEffect)(()=>{!d&&n.length>0&&p(n.find(e=>!e.configured)?.id??n[0].id)},[n,d]);let v=()=>{l||(u(!0),$({type:`install_pi_agent`}))},y=()=>{m.trim()&&!g&&(_(!0),$({type:`set_provider_api_key`,provider:d.trim(),apiKey:m.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)(M,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(Fe,{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=>p(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)(bm,{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:m,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:!m.trim()||g||!d,onClick:y,children:s(g?`saving`:`saveAndStart`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:b,children:[(0,X.jsx)(oe,{}),` `,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 Sm=[`openai-completions`,`openai-responses`,`anthropic-messages`,`google-generative-ai`],Cm=()=>({id:``,name:``,reasoning:!1,input:`text`,contextWindow:``,maxTokens:``}),wm=()=>({providerId:``,name:``,api:`openai-completions`,baseUrl:``,apiKey:``,authHeader:!0,models:[Cm()]});function Tm(e){return{providerId:e.providerId,name:e.name??``,api:e.api??`openai-completions`,baseUrl:e.baseUrl??``,apiKey:e.apiKey??``,authHeader:e.authHeader??!1,models:(e.models.length?e.models:[Cm()]).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 Em(e){let t={};for(let n of e.split(`
|
|
357
|
-
`)){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 Dm({providers:e,providerStatus:t,providerKeys:n,providerOAuthFlows:r,providerOAuthResults:i,fetchModelsResult:a,enrichModelsResult:o,enrichModelsProgress:s,cloneProviderResult:c,refreshBuiltinResult:l,appendBuiltinResult:u,onClose:d}){let p=Z(),[m,h]=(0,f.useState)(null),[g,_]=(0,f.useState)({}),[v,y]=(0,f.useState)({}),[b,x]=(0,f.useState)(null),[S,C]=(0,f.useState)(!1),[w,T]=(0,f.useState)(0),[E,D]=(0,f.useState)(null),O=(0,f.useRef)(0),[k,A]=(0,f.useState)(!1),[j,N]=(0,f.useState)(!1),[P,F]=(0,f.useState)(0),[I,R]=(0,f.useState)(null),[ee,te]=(0,f.useState)([]),[ne,z]=(0,f.useState)(``),B=(0,f.useRef)(0),V=()=>{if(!m||k)return;let e=m.models.map(e=>e.id.trim()).filter(Boolean);if(e.length===0){R({ok:!1,text:p(`enrichModelsNeedIds`)});return}A(!0),N(!1),R(null),te([]);let t=P+1;F(t),$({type:`enrich_models`,reqId:t,ids:e,hints:Em(ne)})},re=()=>{k&&!j&&(N(!0),$({type:`abort_enrich_models`,reqId:P}))},ie=(e,t)=>{z(n=>`${n.trim()?`${n.trim()}\n`:``}${e} = ${t}`)},[H,U]=(0,f.useState)(!1),[ae,ce]=(0,f.useState)(0),[le,ue]=(0,f.useState)(null),de=(0,f.useRef)(0),[fe,pe]=(0,f.useState)(null),[W,me]=(0,f.useState)(``),[G,he]=(0,f.useState)(``),[ge,_e]=(0,f.useState)(``),[ve,ye]=(0,f.useState)(``),[K,be]=(0,f.useState)(!1),[xe,Se]=(0,f.useState)(0),[Ce,q]=(0,f.useState)(null),we=(0,f.useRef)(0),[Te,J]=(0,f.useState)(null),[Ee,De]=(0,f.useState)(``),[Y,Oe]=(0,f.useState)(null);(0,f.useEffect)(()=>{$({type:`list_models_config`}),$({type:`list_providers`}),$({type:`list_provider_keys`}),$({type:`list_provider_oauth_flows`})},[]);let ke=()=>{if(!m)return;let e=m.baseUrl.trim();if(!e){D({ok:!1,text:p(`fetchModelsNeedBaseUrl`)});return}if(S)return;C(!0),D(null);let t=w+1;T(t),$({type:`fetch_models`,reqId:t,baseUrl:e,apiKey:m.apiKey.trim()||void 0,authHeader:m.authHeader,api:m.api})};(0,f.useEffect)(()=>{if(a&&a.reqId!==O.current){if(O.current=a.reqId,C(!1),a.ok&&a.models?.length){let e=a.models;h(t=>{if(!t)return t;let n=t.models.map(t=>{if(!t.id.trim())return t;let n=e.find(e=>e.id===t.id.trim());if(!n)return t;let r={...t};return!r.name&&n.name&&(r.name=n.name),!r.contextWindow&&n.contextWindow&&(r.contextWindow=String(n.contextWindow)),!r.maxTokens&&n.maxTokens&&(r.maxTokens=String(n.maxTokens)),r.input===`text`&&n.input?.includes(`image`)&&(r.input=`text-image`),!r.reasoning&&n.reasoning&&(r.reasoning=!0),r}),r=new Set(n.map(e=>e.id.trim()).filter(Boolean)),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):``})),a=[...n,...i];return a.some(e=>e.id.trim())?{...t,models:a.filter(e=>e.id.trim())}:t}),D({ok:!0,text:p(`fetchModelsOk`,{n:e.length})})}else D({ok:!1,text:a.error||p(`fetchModelsEmpty`)})}},[a]),(0,f.useEffect)(()=>{if(o&&o.reqId!==B.current){if(B.current=o.reqId,A(!1),N(!1),o.ok&&o.results?.length){let e=o.results,t=new Map(e.map(e=>[e.id.trim(),e]));h(e=>e&&{...e,models:e.models.map(e=>{let n=e.id.trim(),r=n?t.get(n):void 0;if(!r||r.status!==`matched`)return e;let i={...e};return!i.name&&r.name&&(i.name=r.name),!i.contextWindow&&r.contextWindow&&(i.contextWindow=String(r.contextWindow)),!i.maxTokens&&r.maxTokens&&(i.maxTokens=String(r.maxTokens)),i.input===`text`&&r.input?.includes(`image`)&&(i.input=`text-image`),!i.reasoning&&r.reasoning&&(i.reasoning=!0),r.source&&(i.src=r.source),i})});let n=e.filter(e=>e.status===`matched`).length,r=e.filter(e=>e.status!==`matched`);R({ok:!0,text:p(`enrichModelsOk`,{n,m:r.length})}),te(r.map(e=>({id:e.id,suggestions:e.suggestions??[],note:e.note})))}else R({ok:!1,text:o.error||p(`enrichModelsErr`,{msg:``})})}},[o]);let Ae=()=>{if(H)return;U(!0),ue(null);let e=ae+1;ce(e),$({type:`refresh_builtin_models`,reqId:e})};(0,f.useEffect)(()=>{l&&l.reqId!==de.current&&(de.current=l.reqId,U(!1),ue(l.ok?{ok:!0,text:p(`refreshBuiltinOk`)}:{ok:!1,text:l.error||p(`refreshBuiltinFail`)}))},[l]);let je=e=>{let t=W.trim();if(!t||K)return;be(!0),q(null);let n=xe+1;Se(n),$({type:`append_builtin_model`,providerId:e,model:{id:t,...G.trim()?{name:G.trim()}:{},...ge?{api:ge}:{},...ve.trim()?{baseUrl:ve.trim()}:{}},reqId:n})};(0,f.useEffect)(()=>{u&&u.reqId!==we.current&&(we.current=u.reqId,be(!1),u.ok?(q({ok:!0,text:p(`appendModelOk`)}),me(``),he(``),_e(``),ye(``),pe(null),$({type:`list_models_config`})):q({ok:!1,text:u.error||p(`appendModelFail`)}))},[u]);let Me=e=>{let t=(g[e.id]??``).trim();t&&!b&&(x(e.id),$({type:`add_provider_key`,provider:e.id,apiKey:t,name:(v[e.id]??``).trim()||void 0}),setTimeout(()=>{x(null),_(t=>({...t,[e.id]:``})),y(t=>({...t,[e.id]:``})),$({type:`list_providers`}),$({type:`list_provider_keys`})},1500))},Fe=(e,t)=>{$({type:`activate_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`})},Ie=(e,t)=>{window.confirm(p(`removeKeyConfirm`))&&($({type:`remove_provider_key`,provider:e,keyName:t}),$({type:`list_provider_keys`}))},Le=t=>{h(n=>{if(!n)return n;let r=t===`openai`?`antigravity`:`antigravity-anthropic`,i=n.providerId.trim()||r;if(!n.providerId.trim()){let t=new Set(e.map(e=>e.providerId));for(let e=2;t.has(i);e++)i=`${r}-${e}`}return{...n,providerId:i,name:n.name.trim()||`Antigravity`,api:t===`openai`?`openai-completions`:`anthropic-messages`,baseUrl:t===`openai`?`http://127.0.0.1:8045/v1`:`http://127.0.0.1:8045`,authHeader:!0}}),D(null)},Re=()=>{if(!Y)return;let e=Y.providerId.trim();if(!e||!Y.apiKey.trim())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,apiKey:Y.apiKey.trim()||void 0,authHeader:Y.authHeader||void 0,models:t}}),Oe(null),d()},ze=()=>{if(!m)return;let e=m.providerId.trim(),t=m.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:m.name.trim()||void 0,api:m.api.trim()||void 0,baseUrl:m.baseUrl.trim()||void 0,apiKey:m.apiKey.trim()||void 0,authHeader:m.authHeader||void 0,models:t}}),d()};(0,f.useEffect)(()=>{if(c&&c.ok){let e=c.configs;if(e&&e.length>1){J(e.map(e=>Tm({...e,apiKey:``}))),De(``);return}if(c.config){Oe(Tm({...c.config,apiKey:``}));return}}},[c]);let Be=e=>{window.confirm(p(`clearKeyConfirm`,{id:e}))&&$({type:`clear_provider_api_key`,provider:e})},Ve=e=>{window.confirm(p(`deleteProviderConfirm`,{id:e.providerId,n:e.models.length}))&&$({type:`delete_model_config`,providerId:e.providerId})},He=(e,t)=>{m&&h({...m,models:m.models.map((n,r)=>r===e?{...n,...t}:n)})};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:d,children:(0,X.jsxs)(`div`,{className:`modal model-modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":p(`close`),onClick:d,children:(0,X.jsx)(M,{})}),(0,X.jsx)(`div`,{className:`modal-head`,children:(0,X.jsx)(`h2`,{children:Y?p(`addKey`):Te?p(`batchCreateProviders`,{n:Te.length}):p(m?`editProvider`:`manageModelsTitle`)})}),Y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`model-modal-body`,children:(0,X.jsxs)(`div`,{className:`provider-form`,children:[(0,X.jsx)(`p`,{className:`modal-desc`,style:{marginBottom:12},children:p(`secondKeyTitle`,{api:Y.api,baseUrl:Y.baseUrl||p(`noBaseUrlShort`),n:Y.models.length})}),(0,X.jsxs)(`div`,{className:`form-grid`,children:[(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[p(`providerNameLabel`),` `,(0,X.jsx)(`em`,{children:p(`providerNameHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:Y.providerId,onChange:e=>Oe({...Y,providerId:e.target.value}),placeholder:`opencode-2`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:p(`apiKeyLabel`)}),(0,X.jsx)(`input`,{type:`password`,value:Y.apiKey,onChange:e=>Oe({...Y,apiKey:e.target.value}),placeholder:p(`secondKeyPlaceholder`)})]})]}),(0,X.jsxs)(`div`,{style:{fontSize:12,opacity:.6,marginTop:8},children:[Y.models.slice(0,5).map(e=>e.id).join(`, `),Y.models.length>5?` … +${Y.models.length-5}`:``]})]})}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Oe(null),children:p(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Y;Oe(null),h(e)},children:p(`advancedEdit`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!Y.providerId.trim()||!Y.apiKey.trim(),onClick:Re,children:p(`save`)})]})]}):Te?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`model-modal-body`,children:(0,X.jsxs)(`div`,{className:`provider-form`,children:[(0,X.jsx)(`p`,{className:`modal-desc`,style:{marginBottom:12},children:p(`batchDesc`,{apis:Te.map(e=>e.api).join(`、`),n:Te.length})}),(0,X.jsxs)(`label`,{className:`field`,style:{marginBottom:16},children:[(0,X.jsx)(`span`,{className:`field-label`,children:p(`batchKeyLabel`,{n:Te.length})}),(0,X.jsx)(`input`,{type:`password`,value:Ee,onChange:e=>De(e.target.value),placeholder:p(`secondKeyPlaceholder`)})]}),(0,X.jsx)(`div`,{className:`provider-list`,style:{marginBottom:16},children:Te.map((e,t)=>(0,X.jsxs)(`div`,{className:`provider-row`,style:{flexDirection:`column`,alignItems:`stretch`,gap:6},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,fontSize:13},children:[(0,X.jsx)(`strong`,{children:e.providerId}),(0,X.jsx)(`span`,{style:{opacity:.7},children:e.api})]}),(0,X.jsxs)(`div`,{className:`provider-sub`,style:{fontSize:12,opacity:.7},children:[e.baseUrl||p(`noBaseUrlShort`),` · `,p(`modelsCountShort`,{n:e.models.length}),e.models.slice(0,3).map(e=>e.id).join(`, `),e.models.length>3?` … +${e.models.length-3}`:``]}),(0,X.jsx)(`input`,{type:`text`,value:e.providerId,onChange:e=>J(n=>n.map((n,r)=>r===t?{...n,providerId:e.target.value}:n)),placeholder:p(`providerIdPlaceholder`),style:{fontSize:12}}),(0,X.jsx)(`input`,{type:`text`,value:e.baseUrl,onChange:e=>J(n=>n.map((n,r)=>r===t?{...n,baseUrl:e.target.value}:n)),placeholder:p(`baseUrlExamplePh`),style:{fontSize:12}})]},t))})]})}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>J(null),children:p(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!Ee.trim(),onClick:()=>{for(let e of Te){let t=e.providerId.trim();if(!t)continue;let n=e.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:t,config:{providerId:t,name:e.name.trim()||void 0,api:e.api.trim()||void 0,baseUrl:e.baseUrl.trim()||void 0,apiKey:Ee.trim()||void 0,authHeader:e.authHeader||void 0,models:n}})}J(null),d()},children:p(`saveAllBatch`,{n:Te.length})})]})]}):m?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`model-modal-body`,children:(0,X.jsxs)(`div`,{className:`provider-form`,children:[(0,X.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:8,flexWrap:`wrap`,marginBottom:12},children:[(0,X.jsx)(`span`,{className:`field-label`,children:p(`antigravityTemplateTitle`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>Le(`openai`),children:p(`antigravityFillOpenAI`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>Le(`anthropic`),children:p(`antigravityFillAnthropic`)})]}),(0,X.jsx)(`p`,{className:`modal-desc`,style:{marginBottom:12},children:p(`antigravityTemplateDesc`)}),(0,X.jsxs)(`div`,{className:`form-grid`,children:[(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsxs)(`span`,{className:`field-label`,children:[p(`providerId`),` `,(0,X.jsx)(`em`,{children:p(`providerIdHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:m.providerId,disabled:e.some(e=>e.providerId===m.providerId),onChange:e=>h({...m,providerId:e.target.value}),placeholder:`my-proxy`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:p(`displayName`)}),(0,X.jsx)(`input`,{type:`text`,value:m.name,onChange:e=>h({...m,name:e.target.value}),placeholder:p(`displayNamePh`)})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:p(`apiType`)}),(0,X.jsx)(`select`,{value:m.api,onChange:e=>h({...m,api:e.target.value}),children:Sm.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:p(`baseUrlHint`)})]}),(0,X.jsx)(`input`,{type:`text`,value:m.baseUrl,onChange:e=>h({...m,baseUrl:e.target.value}),placeholder:`http://localhost:11434/v1`})]}),(0,X.jsxs)(`label`,{className:`field`,children:[(0,X.jsx)(`span`,{className:`field-label`,children:p(`apiKey`)}),(0,X.jsx)(`input`,{type:`password`,value:m.apiKey,onChange:e=>h({...m,apiKey:e.target.value}),placeholder:p(`apiKeyHint`)})]}),(0,X.jsxs)(`label`,{className:`field check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:m.authHeader,onChange:e=>h({...m,authHeader:e.target.checked})}),(0,X.jsx)(`span`,{children:p(`authHeader`)})]})]}),(0,X.jsxs)(`div`,{className:`model-section-head`,children:[(0,X.jsx)(`span`,{className:`form-section-title`,children:p(`modelsTitle`)}),(0,X.jsxs)(`span`,{className:`model-section-actions`,children:[E&&(0,X.jsx)(`span`,{className:`fetch-msg ${E.ok?`ok`:`err`}`,title:E.text,children:E.text}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:S||!m.baseUrl.trim(),title:p(`fetchModelsHint`),onClick:ke,children:[(0,X.jsx)(Pe,{}),` `,p(S?`fetchingModels`:`fetchModels`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:k,title:p(`enrichModelsHint`),onClick:V,children:[(0,X.jsx)(Pe,{}),` `,p(k?`enrichingModels`:`enrichModels`)]}),k&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,disabled:j,title:p(`enrichModelsAbort`),onClick:re,style:{color:`var(--red)`},children:[(0,X.jsx)(M,{}),` `,p(j?`enrichCancelling`:`enrichModelsCancel`)]})]})]}),k&&(0,X.jsxs)(`div`,{style:{marginBottom:8,fontSize:12,display:`flex`,alignItems:`center`,gap:8,background:`var(--bg-elev)`,padding:`4px 8px`,borderRadius:6,border:`1px solid var(--border-soft)`},children:[(0,X.jsx)(`span`,{className:`spinner sm`,style:{width:12,height:12}}),(0,X.jsx)(`span`,{style:{color:`var(--text-dim)`,flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:s?.reqId===P&&s?.message?s.message:p(`enrichingModels`)}),s?.reqId===P&&s.current!==void 0&&s.total!==void 0&&(0,X.jsxs)(`span`,{style:{color:`var(--accent)`,fontVariantNumeric:`tabular-nums`},children:[s.current,`/`,s.total,` (`,Math.round(s.current/s.total*100),`%)`]})]}),(0,X.jsx)(`div`,{style:{display:`flex`,gap:8,marginBottom:8},children:(0,X.jsx)(`textarea`,{value:ne,onChange:e=>z(e.target.value),placeholder:p(`enrichHintPh`),rows:2,style:{flex:1,fontSize:12,padding:`6px 8px`,borderRadius:8,background:`var(--bg-elev2)`,border:`1px solid var(--border-soft)`,color:`var(--text)`}})}),I&&(0,X.jsx)(`span`,{className:`fetch-msg ${I.ok?`ok`:`err`}`,title:I.text,style:{marginBottom:8,display:`inline-block`},children:I.text}),ee.length>0&&(0,X.jsx)(`div`,{style:{marginBottom:8,fontSize:12},children:ee.map(e=>(0,X.jsxs)(`div`,{style:{opacity:.85,marginBottom:4},children:[(0,X.jsxs)(`span`,{children:[e.id,`:`,e.note??``]}),e.suggestions.map(t=>(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,style:{marginLeft:6},onClick:()=>ie(e.id,t),children:t},t))]},e.id))}),m.models.map((e,t)=>(0,X.jsxs)(`div`,{className:`model-row`,children:[(0,X.jsx)(`input`,{type:`text`,value:e.id,onChange:e=>He(t,{id:e.target.value}),placeholder:p(`modelIdReq`)}),(0,X.jsx)(`input`,{type:`text`,value:e.name,onChange:e=>He(t,{name:e.target.value}),placeholder:p(`displayName`)}),(0,X.jsxs)(`select`,{value:e.input,onChange:e=>He(t,{input:e.target.value}),children:[(0,X.jsx)(`option`,{value:`text`,children:p(`text`)}),(0,X.jsx)(`option`,{value:`text-image`,children:p(`textImage`)})]}),(0,X.jsxs)(`label`,{className:`check`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:e.reasoning,onChange:e=>He(t,{reasoning:e.target.checked})}),(0,X.jsx)(`span`,{children:p(`reasoning`)})]}),(0,X.jsx)(`input`,{type:`number`,value:e.contextWindow,onChange:e=>He(t,{contextWindow:e.target.value}),placeholder:p(`contextWindow`),title:`contextWindow`}),(0,X.jsx)(`input`,{type:`number`,value:e.maxTokens,onChange:e=>He(t,{maxTokens:e.target.value}),placeholder:p(`maxOutput`),title:`maxTokens`}),e.src&&(0,X.jsx)(`span`,{style:{fontSize:11,opacity:.65,whiteSpace:`nowrap`},title:e.src,children:e.src}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:p(`removeModel`),onClick:()=>h({...m,models:m.models.filter((e,n)=>n!==t)}),children:(0,X.jsx)(L,{})})]},t)),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>h({...m,models:[...m.models,Cm()]}),children:[(0,X.jsx)(se,{}),` `,p(`addModel`)]})]})}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>h(null),children:p(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!m.providerId.trim()||!m.models.some(e=>e.id.trim()),onClick:ze,children:p(`save`)})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`model-modal-fixed-hint`,children:(0,X.jsxs)(`div`,{className:`form-section-title`,children:[p(`builtinProviders`),` `,(0,X.jsx)(`em`,{className:`section-hint`,children:p(`providerAuthHint`)})]})}),(0,X.jsxs)(`div`,{className:`model-modal-body`,children:[(0,X.jsxs)(`div`,{className:`provider-list`,children:[t.length===0&&(0,X.jsx)(`div`,{className:`dd-loading`,children:p(`loading`)}),t.map(e=>{let t=n[e.id]??[],a=r.find(t=>t.provider===e.id),o=i[e.id];return(0,X.jsxs)(`div`,{className:`provider-row provider-key-row`,children:[(0,X.jsxs)(`div`,{className:`provider-key-head`,children:[(0,X.jsxs)(`div`,{className:`provider-info`,children:[(0,X.jsx)(`span`,{className:`provider-name`,children:e.name}),(0,X.jsxs)(`span`,{className:`provider-sub`,children:[e.id,e.configured&&(0,X.jsx)(`span`,{className:`auth-badge`,children:p(`configuredBadge`)}),e.source&&!e.configured&&(0,X.jsx)(`span`,{className:`auth-badge dim`,children:e.source})]})]}),(0,X.jsxs)(`div`,{className:`provider-head-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn sm`,title:p(`appendModelTitle`),onClick:()=>{pe(fe===e.id?null:e.id),q(null)},children:[(0,X.jsx)(se,{}),` `,p(`appendModel`)]}),e.supportsApiKey&&e.source===`stored`&&!e.usingOAuth&&(0,X.jsxs)(`button`,{type:`button`,className:`btn sm danger`,title:p(`clearKeyTitle`),onClick:()=>Be(e.id),children:[(0,X.jsx)(L,{}),` `,p(`clearKey`)]})]})]}),fe===e.id&&(0,X.jsxs)(`div`,{className:`provider-add-key`,children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:p(`appendModelIdPh`),value:W,onChange:e=>me(e.target.value),onKeyDown:t=>{t.key===`Enter`&&je(e.id),t.key===`Escape`&&pe(null)},autoFocus:!0}),(0,X.jsx)(`input`,{type:`text`,className:`key-input key-input-name`,placeholder:p(`appendModelNamePh`),value:G,onChange:e=>he(e.target.value),onKeyDown:t=>{t.key===`Enter`&&je(e.id),t.key===`Escape`&&pe(null)}}),(0,X.jsxs)(`select`,{className:`key-input key-input-name`,title:p(`appendModelApiTitle`),value:ge,onChange:e=>_e(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:p(`appendModelApiAuto`)}),Sm.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))]}),(0,X.jsx)(`input`,{type:`text`,className:`key-input`,placeholder:p(`appendModelBaseUrlPh`),title:p(`appendModelBaseUrlPh`),value:ve,onChange:e=>ye(e.target.value),onKeyDown:t=>{t.key===`Enter`&&je(e.id),t.key===`Escape`&&pe(null)}}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!W.trim()||K,onClick:()=>je(e.id),children:[(0,X.jsx)(Ke,{}),` `,p(K?`appendModelBusy`:`appendModelAdd`)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>pe(null),children:p(`appendModelCancel`)}),Ce&&!Ce.ok&&(0,X.jsx)(`span`,{className:`fetch-msg err`,title:Ce.text,children:Ce.text})]}),e.supportsOAuth&&(0,X.jsx)(bm,{provider:e,flow:a,result:o}),e.supportsApiKey&&(0,X.jsxs)(`div`,{className:`provider-keys`,children:[t.length===0&&(0,X.jsx)(`div`,{className:`provider-key-empty`,children:p(`noKeyYet`)}),t.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:p(`activateKey`),onClick:()=>Fe(e.id,t.name),children:(0,X.jsx)(Ke,{})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:p(`removeKey`),onClick:()=>Ie(e.id,t.name),children:(0,X.jsx)(L,{})})]},t.name)),(0,X.jsxs)(`div`,{className:`provider-add-key`,children:[(0,X.jsx)(`input`,{type:`text`,className:`key-input key-input-name`,placeholder:p(`keyNamePh`),value:v[e.id]??``,onChange:t=>y(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsx)(`input`,{type:`password`,className:`key-input key-input-value`,placeholder:p(`addKeyPlaceholder`),value:g[e.id]??``,onChange:t=>_(n=>({...n,[e.id]:t.target.value}))}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary sm`,disabled:!(g[e.id]??``).trim()||b===e.id,onClick:()=>Me(e),children:[(0,X.jsx)(se,{}),` `,b===e.id?p(`savingKey`):p(`addKey`)]})]})]})]},e.id)})]}),(0,X.jsx)(`div`,{className:`form-section-title`,children:p(`customProviders`)}),(0,X.jsx)(`p`,{className:`modal-desc`,children:p(`customDesc`)}),(0,X.jsx)(`p`,{className:`modal-desc`,children:p(`reloadModelsHint`)}),e.length===0&&(0,X.jsx)(`div`,{className:`dd-loading`,children:p(`noCustomProviders`)}),(0,X.jsx)(`div`,{className:`provider-list`,children:e.map(e=>(0,X.jsxs)(`div`,{className:`provider-row`,children:[(0,X.jsxs)(`div`,{className:`provider-info`,children:[(0,X.jsx)(`span`,{className:`provider-name`,children:e.providerId}),(0,X.jsxs)(`span`,{className:`provider-sub`,children:[e.api??`—`,e.baseUrl?` · ${e.baseUrl}`:``,e.models.length>0&&` · ${p(`modelsCount`,{n:e.models.length})}`]})]}),(0,X.jsxs)(`div`,{className:`provider-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`iconbtn`,title:p(`edit`),onClick:()=>h(Tm(e)),children:(0,X.jsx)(Ne,{})}),(0,X.jsx)(`button`,{type:`button`,className:`iconbtn danger`,title:p(`delete`),onClick:()=>Ve(e),children:(0,X.jsx)(L,{})})]})]},e.providerId))})]}),(0,X.jsxs)(`div`,{className:`modal-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn`,onClick:()=>$({type:`reload_models_config`}),children:[(0,X.jsx)(oe,{}),` `,p(`reloadModelsConfig`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:p(`refreshBuiltinHint`),disabled:H,onClick:Ae,children:[(0,X.jsx)(Pe,{}),` `,p(H?`refreshBuiltinBusy`:`refreshBuiltinCatalog`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:()=>h(wm()),children:[(0,X.jsx)(se,{}),` `,p(`addProvider`)]})]}),le&&(0,X.jsx)(`p`,{className:`modal-desc`,children:(0,X.jsx)(`span`,{className:`fetch-msg ${le.ok?`ok`:`err`}`,title:le.text,children:le.text})})]})]})})}function Om(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 up)i(e);let a=typeof n==`string`?n:n==null?``:String(n);return a&&i(a),r}function km({plugin:e,models:t=[]}){let n=Z(),r=e.settingsSchema??[],[i,a]=(0,f.useState)(()=>{let t={...e.settingsValues};for(let e of r)e.type===`secret`&&(t[e.key]=``);return t}),[o,s]=(0,f.useState)(!1);if(r.length===0)return null;let c=(e,t)=>a(n=>({...n,[e]:t})),l=e=>Om(e,t,i[e.key]).map(r=>{if(r===``)return{value:``,label:n(`pluginSettingsInherit`)};if(e.optionsFrom===`thinkingLevels`&&up.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 Am=[{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 jm(e){return{id:``,name:``,description:``,cwd:e,kind:`cron`,cron:`0 9 * * *`,preset:`0 9 * * *`,intervalMinutes:`60`,prompt:``,model:``,thinkingLevel:``,catchUp:!1}}function Mm(e){let t=e.kind===`cron`&&Am.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 Nm(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=Am.find(t=>t.value===e.spec);return n?t(n.key):e.spec}function Pm(e){if(!e)return``;try{return new Date(e).toLocaleString()}catch{return String(e)}}function Fm({tasks:e,cwd:t,models:n}){let r=Z(),[i,a]=(0,f.useState)(null),[o,s]=(0,f.useState)(!1),[c,l]=(0,f.useState)(new Set);(0,f.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)(ze,{className:`set-section-icon`}),r(`settingsScheduler`),(0,X.jsx)(Cs,{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(jm(t)),s(!0)},children:[(0,X.jsx)(se,{}),` `,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:Nm(e,r)})]}),(0,X.jsxs)(`div`,{className:`scheduler-line2`,children:[(0,X.jsxs)(`span`,{children:[r(`schedulerNextFire`),`: `,e.nextFire?Pm(e.nextFire):`—`]}),(0,X.jsx)(`span`,{children:`·`}),(0,X.jsxs)(`span`,{children:[r(`schedulerLastRun`),`:`,` `,e.lastRun?(0,X.jsxs)(X.Fragment,{children:[Pm(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:[Pm(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)(ce,{}),` `,r(`schedulerRunNow`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerEdit`),onClick:()=>{a(Mm(e)),s(!1)},children:[(0,X.jsx)(Me,{}),` `,r(`schedulerEdit`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn`,title:r(`schedulerDelete`),onClick:()=>{window.confirm(r(`schedulerConfirmDelete`,{name:e.name}))&&$({type:`schedule_delete`,id:e.id})},children:[(0,X.jsx)(L,{}),` `,r(`schedulerDelete`)]})]})]},e.id))}),i&&(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:()=>a(null),children:(0,X.jsxs)(`div`,{className:`modal`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,className:`modal-close`,"aria-label":r(`close`),onClick:()=>a(null),children:(0,X.jsx)(M,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(ze,{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:[Am.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)(Cs,{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`)}),up.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)(Cs,{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`)})]})]})]})})]})}function Im(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 Lm(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 Rm=`pi-web-ui:wide-chat`,zm={wide:!1};function Bm(e){if(!e||typeof e!=`object`)return{...zm};let t=e;return{wide:typeof t.wide==`boolean`?t.wide:zm.wide}}function Vm(){try{let e=localStorage.getItem(Rm);return e?Bm(JSON.parse(e)):{...zm}}catch{return{...zm}}}function Hm(e){let t=Bm(e);try{localStorage.setItem(Rm,JSON.stringify(t))}catch{}Um=t;for(let e of Wm)e()}var Um=null,Wm=new Set;function Gm(e){return Wm.add(e),()=>{Wm.delete(e)}}function Km(){return Um||=Vm(),Um.wide}function qm(){return(0,f.useSyncExternalStore)(Gm,Km)}var Jm=`pi-web-ui:project-title`,Ym={projectName:!0};function Xm(e){if(!e||typeof e!=`object`)return{...Ym};let t=e;return{projectName:typeof t.projectName==`boolean`?t.projectName:Ym.projectName}}function Zm(e){return e?e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()??``:``}function Qm(){try{let e=localStorage.getItem(Jm);return e?Xm(JSON.parse(e)):{...Ym}}catch{return{...Ym}}}function $m(e){let t=Xm(e);try{localStorage.setItem(Jm,JSON.stringify(t))}catch{}eh=t;for(let e of th)e()}var eh=null,th=new Set;function nh(e){return th.add(e),()=>{th.delete(e)}}function rh(){return eh||=Qm(),eh.projectName}function ih(){return(0,f.useSyncExternalStore)(nh,rh)}var ah=`pi-web-ui:wallpaper`,oh=`has-wallpaper`,sh={url:``,dim:78,blur:0},ch=2e3,lh=28e5;function uh(e){if(typeof e!=`string`)return``;let t=e.trim();if(!t)return``;let n=t.toLowerCase().startsWith(`data:image/`)?lh:ch;return t.length>n?``:/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith(`/`)&&!t.startsWith(`//`)?t:``}var dh=(e,t,n,r)=>typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,Math.round(e)));function fh(e){if(!e||typeof e!=`object`)return{...sh};let t=e;return{url:uh(t.url),dim:dh(t.dim,0,95,sh.dim),blur:dh(t.blur,0,24,sh.blur)}}function ph(){try{let e=localStorage.getItem(ah);return e?fh(JSON.parse(e)):{...sh}}catch{return{...sh}}}function mh(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/[\r\n]/g,``)}async function hh(e){let t=await mu(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function gh(){let e=vh??ph(),t=document.documentElement;e.url?(t.style.setProperty(`--bg-image`,`url("${mh(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(oh,e.url!==``||n!==``&&n!==`none`)}function _h(e){let t=fh(e);vh=t;try{localStorage.setItem(ah,JSON.stringify(t))}catch{}for(let e of yh)e();gh()}var vh=null,yh=new Set;function bh(e){return yh.add(e),()=>{yh.delete(e)}}function xh(){return vh||=ph(),vh}function Sh(){return(0,f.useSyncExternalStore)(bh,xh)}function Ch(){let e=Sh();(0,f.useEffect)(()=>{gh()},[e]),(0,f.useEffect)(()=>{let e=()=>gh();return window.addEventListener(Ac,e),gh(),()=>window.removeEventListener(Ac,e)},[])}function wh(e,t){return e.error?`failed`:t?`disabled`:e.active===!0?`active`:`idle`}function Th(e,t){let n={active:0,disabled:0,failed:0,idle:0};for(let r of e)n[wh(r,t.has(r.id))]+=1;return n}var Eh={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`]},Dh=[`soul`,`tools`,`guidelines`,`pi_docs`,`append`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`],Oh=[`tools`,`pi_docs`,`persona`,`terminal`,`markers`,`context`,`skills`,`cwd`];function kh(e){return Oh.includes(e)}var Ah=Dh.map(e=>`{{${e}}}`).join(`
|
|
358
|
-
|
|
359
|
-
`),jh=On.filter(e=>e.group===`other`&&e.name!==`todo_list`),Mh=`pi-web-ui:catalog-sync-urls`,Nh=8;function Ph(){try{let e=localStorage.getItem(Mh);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`&&e.trim()!==``).slice(0,Nh):[]}catch{return[]}}function Fh(e){let t=e.trim();if(!t)return Ph();let n=[t,...Ph().filter(e=>e!==t)].slice(0,Nh);try{localStorage.setItem(Mh,JSON.stringify(n))}catch{}return n}function Ih(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Lh(e){return e===`append`?0:kh(e)?2:1}function Rh({title:e,subtitle:t,tip:n,enabled:r,onToggle:i,action:a}){let o=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)(Cs,{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,title:o(r?`settingsEnabled`:`settingsDisabled`),onClick:i,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})}function zh(e){return e===`active`?`pluginPhaseActive`:e===`disabled`?`pluginPhaseDisabled`:e===`failed`?`pluginPhaseFailed`:`pluginPhaseIdle`}function Bh({phase:e,label:t}){return(0,X.jsx)(`span`,{className:`inv-dot inv-dot-${e}`,title:t,"aria-label":t})}function Vh({plugins:e,disabledIds:t}){let n=Z(),r=Th(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)(Bh,{phase:e,label:i[e]}),r[e]]},e))})}function Hh({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)(Cs,{text:t})]}),r]})}function Uh({pluginId:e}){let t=Z(),[n,r]=(0,f.useState)(`all`),i=Bo(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`,...Mo].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:()=>$(Po(e)),children:[(0,X.jsx)(L,{}),t(`pluginLogClear`)]})]}),a.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:t(`pluginLogEmpty`)}):(0,X.jsx)(`ul`,{className:`set-diag-list set-log-list`,children:a.map((t,n)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`set-log-time`,children:new Date(t.ts).toLocaleTimeString()}),` `,(0,X.jsx)(`span`,{className:`set-log-level lv-${t.level}`,children:t.level.toUpperCase()}),` `,(0,X.jsx)(`span`,{className:`set-log-text`,children:t.text})]},`${e}-${t.ts}-${n}`))})]})}function Wh({chat:e,terminal:t,initialSection:n,onSwitchToTerminal:r,onClose:i}){let a=Z(),{locale:o}=Ut(),s=e=>a(e),c=e.settings,{engine:l,managed:u}=mi(),d=l===`dsh`,[p,m]=(0,f.useState)(n??`prompt`),[h,g]=(0,f.useState)(`market`),_=(0,f.useRef)(null);(0,f.useEffect)(()=>{_.current?.scrollTo({top:0})},[p]);let v=(0,f.useRef)(null);(0,f.useEffect)(()=>{v.current?.querySelector(`.settings-tab.active`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[p]),(0,f.useEffect)(()=>{p===`plugins`&&d&&$({type:`dsh_patches_list`})},[p,d]);let[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)({}),C=(0,f.useRef)(!1),w=(0,f.useRef)(null),T=[...Dh].sort((e,t)=>Lh(e)-Lh(t)),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)({}),[A,N]=(0,f.useState)(``),[I,ee]=(0,f.useState)(`append`),te=(0,f.useRef)(!1),[ne,z]=(0,f.useState)(``),[H,U]=(0,f.useState)(`append`),ae=(0,f.useRef)(!1),[ce,le]=(0,f.useState)(``),de=(0,f.useRef)(!1),[fe,pe]=(0,f.useState)(``),[W,G]=(0,f.useState)(null),[he,ge]=(0,f.useState)(!1),[_e,ve]=(0,f.useState)(null),[ye,K]=(0,f.useState)(!1),[be,Se]=(0,f.useState)(!1),Ce=qm(),we=Yl(),Te=ih(),J=Sh(),[Y,Oe]=(0,f.useState)(J.url),je=(0,f.useRef)(!1),Ne=(0,f.useRef)(null),[Ie,Le]=(0,f.useState)(!1),[Re,Be]=(0,f.useState)(!1);(0,f.useEffect)(()=>{je.current||Oe(J.url.startsWith(`data:`)?``:J.url)},[J.url]);let Ve=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t){Le(!0),Be(!1);try{let e=await hh(t),n=e?uh(e):``;if(!n){Be(!0);return}Oe(``),_h({...J,url:n})}finally{Le(!1)}}},[He,Ue]=(0,f.useState)(()=>Kf()),[We,Ge]=(0,f.useState)(()=>{try{return Xf().length}catch{return 0}}),[Ke,qe]=(0,f.useState)(!1),Je=()=>{try{Ge(Xf().length)}catch{Ge(0)}};(0,f.useEffect)(()=>{p===`prompt-history`&&Je()},[p]),(0,f.useEffect)(()=>{if(!Ke)return;let e=window.setTimeout(()=>qe(!1),3e3);return()=>window.clearTimeout(e)},[Ke]);let[Xe,Ze]=(0,f.useState)(null),[Qe,$e]=(0,f.useState)(null),[et,rt]=(0,f.useState)(null),[it,at]=(0,f.useState)(null),[st,ct]=(0,f.useState)({}),[,lt]=(0,f.useState)(0);(0,f.useEffect)(()=>zo(()=>lt(e=>e+1)),[]);let[ut,dt]=(0,f.useState)(``),[ft,pt]=(0,f.useState)(``),[mt,ht]=(0,f.useState)(``),[gt,_t]=(0,f.useState)(``),[vt,yt]=(0,f.useState)(``),[bt,xt]=(0,f.useState)(!1),[St,Ct]=(0,f.useState)(!1),[wt,Tt]=(0,f.useState)(!1),[Et,Dt]=(0,f.useState)(``),[Ot,kt]=(0,f.useState)(!1),[At,jt]=(0,f.useState)(!1),[Mt,Nt]=(0,f.useState)(null),[Pt,Ft]=(0,f.useState)(``),[It,Lt]=(0,f.useState)(()=>Ph()),[Rt,zt]=(0,f.useState)(``),[Bt,Vt]=(0,f.useState)(null);(0,f.useEffect)(()=>{c&&(C.current||b(c.promptTemplate??``),S(e=>{let t={};for(let[e,n]of Object.entries(c.promptOverrides??{}))t[e]=n??``;return w.current&&(t[w.current]=e[w.current]??``),t}),ee(c.visionBridgePromptMode),!te.current&&(N(I===`append`||c.visionBridgePrompt?c.visionBridgePrompt:c.visionBridgeDefaultPrompt||``),U(c.scmCommitMsgPromptMode),ae.current||z(c.scmCommitMsgPromptMode===`append`||c.scmCommitMsgPrompt?c.scmCommitMsgPrompt:c.scmCommitMsgDefaultPrompt||``),de.current||le(c.reviewPrompt)))},[c,I,H]);let[Ht,Wt]=(0,f.useState)(String(c?.terminalBashIdleMs??15e3));(0,f.useEffect)(()=>{Wt(String(c?.terminalBashIdleMs??15e3))},[c?.terminalBashIdleMs]);let[Gt,Kt]=(0,f.useState)(String(Math.round((c?.toolWatchdogTimeoutMs??12e5)/6e4)));(0,f.useEffect)(()=>{Kt(String(Math.round((c?.toolWatchdogTimeoutMs??12e5)/6e4)))},[c?.toolWatchdogTimeoutMs]);let[qt,Jt]=(0,f.useState)(String(c?.retryMaxAttempts??6));(0,f.useEffect)(()=>{Jt(String(c?.retryMaxAttempts??6))},[c?.retryMaxAttempts]);let[Yt,Xt]=(0,f.useState)(c?.softCapTokens&&c.softCapTokens>0?Lm(c.softCapTokens):``);(0,f.useEffect)(()=>{Xt(c?.softCapTokens&&c.softCapTokens>0?Lm(c.softCapTokens):``)},[c?.softCapTokens]);let[Zt,Qt]=(0,f.useState)(``),[$t,en]=(0,f.useState)(``),tn=jr(br(e.plugins),{locale:o,t:e=>a(e),disabledPlugins:e.settings?.disabledPlugins??[],layout:e.settings?.uiLayout}),nn=[];for(let t of tn[`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&&nn.push({entry:t,plugin:n})}let rn=e=>`plugin-page:${e}`;if((0,f.useEffect)(()=>{p.startsWith(`plugin-page:`)&&(nn.some(e=>rn(e.entry.id)===p)||m(`prompt`))},[p,nn]),!c)return null;let an=new Set(c.disabledAgentTools??[]),on=an.size,sn=[{id:`prompt`,icon:(0,X.jsx)(ke,{}),label:a(`settingsSystemPrompt`)},{id:`prompt-history`,icon:(0,X.jsx)(ze,{}),label:a(`settingsPromptHistory`),count:We},...d?[]:[{id:`scheduler`,icon:(0,X.jsx)(ze,{}),label:a(`settingsScheduler`),count:e.schedulerTasks.length||void 0}],...d?[{id:`question`,icon:(0,X.jsx)(q,{}),label:a(`settingsQuestionnaire`)}]:[{id:`tools`,icon:(0,X.jsx)(R,{}),label:a(`settingsTools`),count:on+(c.disabledMarkers?.length??0)||void 0}],{id:`display`,icon:(0,X.jsx)(me,{}),label:a(`settingsMessageDisplay`)},{id:`quick`,icon:(0,X.jsx)(ie,{}),label:a(`quickPhrases`),count:c.quickPhrases.length},{id:`skills`,icon:(0,X.jsx)(Fe,{}),label:a(`settingsSkills`),count:c.skills.length},{id:`extensions`,icon:(0,X.jsx)(ue,{}),label:a(`settingsExtensions`),count:c.extensions.length},{id:`plugins`,icon:(0,X.jsx)(Ye,{}),label:a(`settingsUiPlugins`),count:e.plugins.length},{id:`layout`,icon:(0,X.jsx)(B,{}),label:a(`uiLayoutTitle`)},{id:`review`,icon:(0,X.jsx)(j,{}),label:a(`settingsReview`),count:c.reviewSkills.length},...d?[]:[{id:`vision`,icon:(0,X.jsx)(Ae,{}),label:a(`settingsVisionBridge`)}],{id:`presets`,icon:(0,X.jsx)(B,{}),label:a(`settingsPresets`),count:c.presets.length},...d?[]:[{id:`subagent-templates`,icon:(0,X.jsx)(P,{}),label:a(`settingsSubagentTemplates`),count:c.subagentTemplates.length}],...nn.map(e=>({id:rn(e.entry.id),icon:e.entry.iconSvg?(0,X.jsx)(sr,{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)(Ye,{}),label:e.entry.label,pluginPage:{plugin:e.plugin,entry:e.entry}}))],cn=p.startsWith(`plugin-page:`)?nn.find(e=>rn(e.entry.id)===p)??null:null,ln=new Set(c.disabledSkills),un=new Set(c.disabledExtensions),Q=e=>$({type:`set_settings`,...e}),dn=()=>{if(!Bt||!c)return;let e=Bt.value.trim(),t=Bt.index;if(Vt(null),!e||e===c.quickPhrases[t])return;let n=[...c.quickPhrases];n[t]=e,Q({quickPhrases:n})},fn=e=>{let t=new Set(ln);t.has(e.name)?t.delete(e.name):t.add(e.name),Q({disabledSkills:[...t]})},pn=new Set(c.skillsFullText??[]),gn=e=>{let t=new Set(pn);t.has(e)?t.delete(e):t.add(e),Q({skillsFullText:[...t]})},_n=new Set(c.disabledPlugins??[]),vn=new Set(e.plugins.map(e=>e.id)),yn=e=>{let t=new Set(_n);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledPlugins:[...t]})},bn=e=>{let t=new Set(un);t.has(e.id)?t.delete(e.id):t.add(e.id),Q({disabledExtensions:[...t]})},xn={subagent_spawn:a(`toolDescSubagentSpawn`),subagent_get_result:a(`toolDescSubagentGetResult`),subagent_steer:a(`toolDescSubagentSteer`),subagent_list:a(`toolDescSubagentList`),subagent_stop:a(`toolDescSubagentStop`),subagent_wait_all:a(`toolDescSubagentWaitAll`),subagent_templates:a(`toolDescSubagentTemplates`)},Sn=e=>{let t=new Set(an);t.has(e)?t.delete(e):t.add(e),Q({disabledAgentTools:[...t]})},Cn=new Set(c.disabledPluginTools??[]),wn=e=>{let t=new Set(Cn);t.has(e)?t.delete(e):t.add(e),Q({disabledPluginTools:[...t]})},Tn=e.plugins.map(e=>({plugin:e,tools:[...e.agentTools??[]].sort((e,t)=>e.name.localeCompare(t.name))})).filter(e=>e.tools.length>0),En=c.markersEnabled??!0,Dn=new Set(c.disabledMarkers??[]),On=e=>{let t=new Set(Dn);t.has(e)?t.delete(e):t.add(e),Q({disabledMarkers:[...t]})},kn=(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=ot(),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()},An=e=>{Ze(null),kn(`${a(`uninstallTitle`)} ${e}`,`pi remove npm:${e}`)},jn=(e,t,n)=>{$({type:`plugin_job`,jobId:ot(),action:e,id:t,...n?{source:n}:{},...e!==`uninstall`&&St?{build:!0}:{}})},Mn=t=>{let n=null;for(let r of Object.values(e.pluginJobs??{}))r.pluginId===t&&(!n||r.startedAt>=n.startedAt)&&(n=r);return n},Nn=e=>{let t=Mn(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)(oe,{className:`set-job-spin`}),a(`pluginJobRunning`),(0,X.jsx)(`span`,{className:`set-catalog-job-line`,children:e})]})}return t.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[`✓ `,a(`pluginJobDone`)]}):(0,X.jsxs)(`div`,{className:`set-catalog-job error`,children:[(0,X.jsxs)(`span`,{children:[`✗ `,t.error||a(`pluginJobFailed`)]}),t.output?(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:t.output}):null]})},Pn=[{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`}],Fn=[`bottombar`,`composer.actions`,`topbar.primary`],[In,Ln]=(0,f.useState)(``),Rn=e=>{let t=Pn.find(t=>t.slot===e);return t?a(t.labelKey):e},zn=e.settings?.uiLayout,Bn=e=>Q({uiLayout:{...zn,...e}}),Vn=e=>{let t=new Set(zn?.hidden??[]),n=new Set(zn?.shown??[]);e.hidden?(t.delete(e.id),n.add(e.id)):(t.add(e.id),n.delete(e.id)),Bn({hidden:[...t],shown:[...n]})},Hn=(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=(zn?.order??[]).filter(e=>!f.has(e));Bn({order:[...p,...d]})},Un=(e,t)=>{(t===`start`||t===`center`||t===`end`)&&Bn({align:{...zn?.align,[e]:t}})},Wn=(e,t)=>{let n={...zn?.labels},r=t.trim().slice(0,60);r?n[e]=r:delete n[e],Bn({labels:n})},Gn=e=>Q({uiLayout:Fr(zn,e)}),Kn=()=>Q({uiLayout:Ir()}),qn=e=>{$e(null),jn(`uninstall`,e)},Jn=(e,t)=>{jn(`update`,e,t)},Yn=e=>{jn(`install`,e.id,e.source)},Xn=e=>{$({type:`plugin_catalog_remove`,id:e})},Zn=()=>{let e=ut.trim();e&&($({type:`plugin_catalog_add`,entry:{source:e,...ft.trim()?{id:ft.trim()}:{},...mt.trim()?{name:mt.trim()}:{},...gt.trim()?{description:gt.trim()}:{},...vt.trim()?{icon:vt.trim()}:{}}}),dt(``),pt(``),ht(``),_t(``),yt(``),xt(!1))},Qn=e=>{let t=e.trim();if(!t)return;let n=ot();Nt(n),Ft(t),$({type:`plugin_catalog_sync`,requestId:n,source:t,...Ot?{install:!0}:{},...At?{replace:!0}:{}})},$n=e.catalogSync&&e.catalogSync.requestId===Mt?e.catalogSync:null;(0,f.useEffect)(()=>{$n?.ok&&Pt&&Lt(Fh(Pt))},[$n?.requestId,$n?.ok]);let er=e=>{let t=new Set(c.reviewSkills.filter(e=>!e.enabled).map(e=>e.name));t.has(e.name)?t.delete(e.name):t.add(e.name),Q({reviewDisabledSkills:[...t]})},tr=()=>Q({promptTemplate:y}),nr=e=>{Q({promptOverrides:{[e]:x[e]??``}})},rr=e=>{w.current===e&&(w.current=null),D(null),S(t=>{let n={...t};return delete n[e],n}),Q({promptOverrides:{[e]:``}})},ir=e=>k(t=>({...t,[e]:!t[e]})),ar=(e,t)=>{S(n=>({...n,[e]:t})),D(e)},or=()=>{C.current=!1,w.current=null,b(Ah),S({}),Q({promptTemplate:Ah,promptOverrides:{}})},cr=e=>{b(t=>t.trim()?`${t}\n\n{{${e}}}`:`{{${e}}}`)},lr=y.trim()&&y.trim()!==Ah||Object.values(x).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":a(`close`),onClick:i,children:(0,X.jsx)(M,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(re,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:a(`settingsTitle`)}),(0,X.jsx)(Cs,{text:a(`settingsDesc`)})]}),(0,X.jsxs)(`div`,{className:`settings-layout`,children:[(0,X.jsx)(`nav`,{className:`settings-rail`,"aria-label":a(`settingsTitle`),ref:v,children:sn.map(e=>(0,X.jsxs)(`button`,{type:`button`,"data-tab":e.id,className:`settings-tab${p===e.id?` active`:``}`,"aria-current":p===e.id?`true`:void 0,title:e.hint??e.label,onClick:()=>m(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.id))}),(0,X.jsxs)(`div`,{className:`modal-body`,ref:_,children:[p===`prompt`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(j,{className:`set-section-icon`}),a(`settingsSystemPrompt`),(0,X.jsx)(Cs,{text:`${a(`promptComposeHint`)}\n${a(`promptComposeDesc`)}`})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`promptTemplateLabel`)}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:6,spellCheck:!1,placeholder:Ah,value:y,onFocus:()=>C.current=!0,onBlur:()=>{C.current=!1,tr()},onChange:e=>b(e.target.value)}),(0,X.jsxs)(`div`,{className:`compose-toolbar`,children:[(0,X.jsx)(`span`,{className:`set-field-label set-muted`,children:a(`promptInsertTokens`)}),T.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`token-chip`,title:s(`promptTok_${e}_desc`),onClick:()=>cr(e),children:`{{${e}}}`},e))]})]}),(0,X.jsxs)(`div`,{className:`set-field`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`promptSourcesLabel`)}),T.map(e=>{let t=x[e]??``,n=c.promptSourceDefaults?.[e]??``,r=E===e,i=n.split(`
|
|
360
|
-
`).length>6||n.length>480;if(kh(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:[s(`promptTok_${e}`),` `,(0,X.jsx)(Cs,{text:s(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,title:a(`promptReadonlyLockedHint`),onClick:()=>rr(e),children:a(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:a(`promptReadonlyBadge`)})]}),(0,X.jsx)(`div`,{className:`source-default readonly${r.trim()?``:` empty`}`,title:a(`promptReadonlyTitle`),children:r.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?O[e]?` expanded`:` clamped`:``}`,children:r}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ir(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ir(e))},children:O[e]?a(`promptSourceCollapse`):a(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:a(`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:[s(`promptTok_${e}`),` `,(0,X.jsx)(Cs,{text:s(`promptTok_${e}_desc`)})]}),t.trim()?(0,X.jsx)(`button`,{type:`button`,className:`set-btn-mini`,onClick:()=>rr(e),children:a(`promptResetSource`)}):(0,X.jsx)(`span`,{className:`set-muted`,children:a(`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(`
|
|
361
|
-
`).length)),autoFocus:r,placeholder:a(`promptOverridePlaceholder`),value:t,onFocus:t=>{w.current=e,D(e);let r=t.currentTarget;r.value&&r.value===n&&r.setSelectionRange(r.value.length,r.value.length)},onBlur:()=>{w.current===e&&(w.current=null);let t=x[e]??``;if(t.trim()&&t===n){rr(e);return}nr(e),t.trim()||D(null)},onChange:t=>S(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:a(`promptSourceRefLabel`)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`source-default-toggle`,onClick:()=>ir(e),children:O[e]?a(`promptSourceCollapse`):a(`promptSourceExpand`)})]}),n.trim()?(0,X.jsx)(`pre`,{className:`source-default-text${i?O[e]?` expanded`:` clamped`:``}`,children:n}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:a(`promptSourceDefaultEmpty`)}),!t.trim()&&n.trim()&&(0,X.jsx)(`button`,{type:`button`,className:`override-seed-btn`,title:a(`promptSourceSeedTip`),onClick:()=>ar(e,n),children:a(`promptSourceSeedButton`)})]})]}):(0,X.jsx)(`div`,{className:`source-default`,title:a(`promptSourceDefaultEditHint`),role:`button`,tabIndex:0,onClick:()=>ar(e,n),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),ar(e,n))},children:n.trim()?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`pre`,{className:`source-default-text${i?O[e]?` expanded`:` clamped`:``}`,children:n}),i&&(0,X.jsx)(`span`,{className:`source-default-toggle`,role:`button`,tabIndex:0,onClick:t=>{t.stopPropagation(),ir(e)},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),ir(e))},children:O[e]?a(`promptSourceCollapse`):a(`promptSourceExpand`)})]}):(0,X.jsx)(`span`,{className:`source-default-empty`,children:a(`promptSourceDefaultEmpty`)})})]},e)}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-btn`,onClick:or,disabled:!lr,children:a(`promptResetAll`)})})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":ye,onClick:()=>K(e=>!e),children:[a(`settingsViewPrompt`),` `,ye?`▴`:`▾`]}),ye&&(0,X.jsxs)(`div`,{className:`set-prompt-view`,children:[(0,X.jsxs)(`div`,{className:`set-prompt-view-head`,children:[(0,X.jsx)(`span`,{children:a(`settingsViewPrompt`)}),(0,X.jsx)(Cs,{text:a(`settingsViewPromptHint`)}),(0,X.jsx)(ec,{text:c.effectiveSystemPrompt})]}),c.effectiveSystemPrompt?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:c.effectiveSystemPrompt}):(0,X.jsx)(`p`,{className:`set-empty`,children:a(`settingsViewPromptEmpty`)})]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-view-prompt-btn`,"aria-expanded":be,onClick:()=>Se(e=>!e),children:[a(`settingsViewToolsSchema`),` `,be?`▴`:`▾`]}),be&&(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:a(`settingsViewToolsSchema`)}),(0,X.jsx)(Cs,{text:a(`settingsViewToolsSchemaHint`)}),(0,X.jsx)(ec,{text:c.toolsSchema})]}),c.toolsSchema?(0,X.jsx)(`pre`,{className:`set-prompt-view-text`,children:c.toolsSchema}):(0,X.jsx)(`p`,{className:`set-empty`,children:a(`settingsViewToolsSchemaEmpty`)})]})})]}),p===`prompt`&&!d&&(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`}),a(`scmCommitMsgSettingsTitle`),(0,X.jsx)(Cs,{text:a(`scmCommitMsgSettingsDesc`)})]}),(0,X.jsx)(Hh,{label:a(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:H,onChange:e=>{let t=e.target.value;U(t),Q({scmCommitMsgPromptMode:t})},children:[(0,X.jsx)(`option`,{value:`append`,children:a(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:a(`promptModeReplace`)})]})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:a(`scmCommitMsgPromptPlaceholder`),value:ne,onFocus:()=>ae.current=!0,onBlur:()=>{ae.current=!1;let e=H===`replace`&&c.scmCommitMsgDefaultPrompt&&ne===c.scmCommitMsgDefaultPrompt?``:ne;Q({scmCommitMsgPromptMode:H,scmCommitMsgPrompt:e})},onChange:e=>z(e.target.value)}),(0,X.jsx)(`p`,{className:`set-hint`,children:a(`scmCommitMsgSettingsHint`)})]}),p===`scheduler`&&!d&&(0,X.jsx)(Fm,{tasks:e.schedulerTasks,cwd:e.state?.cwd??``,models:c.subagentModels}),p===`prompt-history`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ze,{className:`set-section-icon`}),a(`settingsPromptHistory`),(0,X.jsx)(Cs,{text:a(`settingsPromptHistoryDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:a(`promptHistoryCount`,{n:String(We)})})]}),We===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`promptHistoryEmpty`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:a(`promptHistoryCount`,{n:String(We)})}),(0,X.jsx)(Hh,{label:a(`promptHistoryMax`),tip:a(`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(He.maxEntries),onChange:e=>{let t=Math.floor(Number(e.target.value)||0),n={...He,maxEntries:t};Ue(n)},onBlur:()=>{let e={...He};(!Number.isFinite(e.maxEntries)||e.maxEntries<1)&&(e.maxEntries=1),e.maxEntries>500&&(e.maxEntries=500),e.maxEntries=Math.floor(e.maxEntries),Ue(e),qf(e),Je()}})}),(0,X.jsx)(Rh,{title:a(`promptHistoryCharLimit`),tip:a(`promptHistoryCharLimitHint`),enabled:He.charLimitEnabled,onToggle:()=>{let e={...He,charLimitEnabled:!He.charLimitEnabled};Ue(e),qf(e),Je()}}),He.charLimitEnabled&&(0,X.jsx)(Hh,{label:a(`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:a(`promptHistoryCharLimitPlaceholder`),value:String(He.charLimit),onChange:e=>{let t=Math.floor(Number(e.target.value)||0);Ue({...He,charLimit:t})},onBlur:()=>{let e=Math.floor(Number(He.charLimit)||0);(!Number.isFinite(e)||e<100)&&(e=100),e>2e4&&(e=2e4);let t={...He,charLimit:e};Ue(t),qf(t),Je()}})}),(0,X.jsxs)(`div`,{className:`set-field`,style:{marginTop:12},children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall${Ke?` confirm`:``}`,disabled:We===0,title:a(We===0?`promptHistoryEmpty`:`promptHistoryClear`),onClick:()=>{if(!Ke){qe(!0);return}$f(),qe(!1),Je()},children:[(0,X.jsx)(L,{}),` `,a(Ke?`promptHistoryClearConfirm`:`promptHistoryClear`)]}),We>0&&(0,X.jsx)(`span`,{className:`set-hint`,style:{marginLeft:8},children:a(`promptHistoryCount`,{n:String(We)})})]}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[(0,X.jsx)(tt,{style:{verticalAlign:`-2px`,marginRight:4}}),a(`settingsPromptHistoryDesc`)]})]}),p===`tools`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(R,{className:`set-section-icon`}),a(`settingsTools`)]}),(0,X.jsx)(Rh,{title:a(`readDirEnabled`),tip:a(`readDirEnabledDesc`),enabled:c.readDirEnabled!==!1,onToggle:()=>Q({readDirEnabled:c.readDirEnabled===!1})}),(0,X.jsx)(Hh,{label:a(`toolWatchdogTimeout`),tip:a(`toolWatchdogTimeoutDesc`),htmlFor:`tool-watchdog-timeout`,children:(0,X.jsx)(`input`,{id:`tool-watchdog-timeout`,className:`set-input`,type:`number`,min:0,step:1,placeholder:a(`toolWatchdogOff`),value:Gt,onChange:e=>Kt(e.target.value),onBlur:()=>{let e=Gt.trim(),t=e===``?20:Math.max(0,Math.floor(Number(e)||0));Kt(String(t));let n=t*6e4;n!==c.toolWatchdogTimeoutMs&&Q({toolWatchdogTimeoutMs:n})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(`div`,{className:`set-field-label`,children:a(`toolsSectionTerminal`)}),mn.map(e=>(0,X.jsx)(Rh,{title:e,tip:a(`settingsTerminalToolsDesc`),enabled:!an.has(e),onToggle:()=>Sn(e)},e)),(0,X.jsx)(Rh,{title:a(`terminalBashTakeover`),tip:a(`terminalBashTakeoverDesc`),enabled:c.terminalBash,onToggle:()=>Q({terminalBash:!c.terminalBash})}),c.terminalBash&&(0,X.jsx)(Hh,{label:a(`terminalBashIdleMs`),htmlFor:`tb-idle-ms`,children:(0,X.jsx)(`input`,{id:`tb-idle-ms`,className:`set-input`,type:`number`,min:0,step:1e3,value:Ht,onChange:e=>Wt(e.target.value),onBlur:()=>{let e=Math.max(0,Math.floor(Number(Ht)||0));Wt(String(e)),e!==c.terminalBashIdleMs&&Q({terminalBashIdleMs:e})}})}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[a(`toolsSectionSubagent`),` `,(0,X.jsx)(Cs,{text:a(`toolsSubagentDepHint`)})]}),hn.map(e=>(0,X.jsx)(Rh,{title:e,tip:xn[e],enabled:!an.has(e),onToggle:()=>Sn(e)},e)),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[a(`settingsMarkers`),(0,X.jsx)(Cs,{text:`${a(`settingsMarkersDesc`)}\n${a(`markerRenameTip`)}`})]}),(0,X.jsx)(Rh,{title:a(`markersEnabled`),tip:`${a(`markersEnabledDesc`)}\n${a(`markersOffHint`)}`,enabled:En,onToggle:()=>Q({markersEnabled:!En})}),En&&(c.markers?.length??0)===0&&(0,X.jsxs)(`p`,{className:`set-empty`,children:[a(`loading`),`...`]}),En&&c.markers&&c.markers.length>0&&c.markers.map(e=>(0,X.jsx)(Rh,{title:e.name===`todo`?a(`markerGroupTodo`):e.name===`notify`?a(`markerGroupNotify`):e.name===`conv`?a(`markerGroupRename`):e.name,tip:e.guidance.join(`
|
|
362
|
-
`),enabled:e.enabled,onToggle:()=>On(e.name)},e.name)),(0,X.jsx)(Rh,{title:`todo_list`,tip:`${a(`todoListEnabledDesc`)}\n${a(`todoListOffHint`)}`,enabled:!an.has(`todo_list`),onToggle:()=>Sn(`todo_list`)}),(0,X.jsx)(`div`,{className:`set-field-label`,children:a(`toolsSectionOther`)}),jh.map(e=>(0,X.jsx)(Rh,{title:e.name,tip:`${s(e.descKey??e.name)}\n${s(e.offHintKey??e.name)}`,enabled:!an.has(e.name),onToggle:()=>Sn(e.name)},e.name)),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[a(`toolsSectionPlugin`),(0,X.jsx)(Cs,{text:a(`toolsPluginHint`)})]}),Tn.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:e.plugins.length===0?a(`noUiPlugins`):a(`pluginToolsEmpty`)}):Tn.map(e=>(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]}),e.tools.map(e=>(0,X.jsx)(Rh,{title:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name,tip:e.description?`${e.description}\n${a(`pluginToolOffHint`)}`:a(`pluginToolOffHint`),enabled:!Cn.has(e.name),onToggle:()=>wn(e.name)},e.name))]},e.plugin.id))]}),p===`question`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(q,{className:`set-section-icon`}),a(`settingsQuestionnaire`)]}),(0,X.jsx)(Rh,{title:a(`questionnaireEnabled`),tip:`${a(`questionnaireEnabledDesc`)}\n${a(`questionnaireOffHint`)}`,enabled:c.questionnaireEnabled,onToggle:()=>Q({questionnaireEnabled:!c.questionnaireEnabled})})]}),p===`display`&&(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`}),a(`settingsMessageDisplay`)]}),(0,X.jsx)(Hh,{label:a(`softCapTokens`),tip:a(`softCapHint`),htmlFor:`soft-cap-max`,children:(0,X.jsx)(`input`,{id:`soft-cap-max`,className:`set-input`,type:`text`,placeholder:a(`softCapOff`),value:Yt,onChange:e=>Xt(e.target.value),onBlur:()=>{let e=Im(Yt);Xt(Lm(e)),e!==(c.softCapTokens??0)&&Q({softCapTokens:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsxs)(`div`,{className:`set-section-title`,children:[a(`softCapByModel`),(0,X.jsx)(Cs,{text:a(`softCapByModelHint`)})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`softCapModelId`),value:Zt,maxLength:200,onChange:e=>Qt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,type:`text`,placeholder:a(`softCapTokens`),value:$t,onChange:e=>en(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&Zt.trim()&&Im($t)>0){let e=Im($t);Q({softCapByModel:{...c.softCapByModel,[Zt.trim()]:e}}),Qt(``),en(``)}}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Zt.trim()||Im($t)<=0,onClick:()=>{let e=Zt.trim(),t=Im($t);!e||t<=0||(Q({softCapByModel:{...c.softCapByModel,[e]:t}}),Qt(``),en(``))},children:[(0,X.jsx)(se,{}),` `,a(`softCapAdd`)]})]}),(0,X.jsx)(`div`,{className:`set-list`,children:Object.entries(c.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:Lm(t),onBlur:t=>{let n=Im(t.target.value);t.target.value=Lm(n);let r={...c.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:a(`softCapRemove`),onClick:()=>{let t={...c.softCapByModel};delete t[e],Q({softCapByModel:t})},children:[(0,X.jsx)(M,{}),` `,a(`softCapRemove`)]})]},e))}),(0,X.jsx)(Hh,{label:a(`modelRetryAttempts`),tip:a(`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:qt,onChange:e=>Jt(e.target.value),onBlur:()=>{let e=Math.min(100,Math.max(0,Math.floor(Number(qt)||0)));Jt(String(e)),e!==c.retryMaxAttempts&&Q({retryMaxAttempts:e})},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}),(0,X.jsx)(Rh,{title:a(`thinkingWrap`),tip:a(`thinkingWrapDesc`),enabled:c.thinkingWrap??!0,onToggle:()=>Q({thinkingWrap:!(c.thinkingWrap??!0)})}),(0,X.jsx)(Rh,{title:a(`toolsWrap`),tip:a(`toolsWrapDesc`),enabled:c.toolsWrap??!0,onToggle:()=>Q({toolsWrap:!(c.toolsWrap??!0)})}),(0,X.jsx)(Rh,{title:a(`toolImages`),tip:a(`toolImagesDesc`),enabled:c.toolImagesEnabled??!0,onToggle:()=>Q({toolImagesEnabled:!(c.toolImagesEnabled??!0)})}),(0,X.jsx)(Rh,{title:a(`presentAutoOpen`),tip:a(`presentAutoOpenDesc`),enabled:we,onToggle:()=>Ul(!we)}),(0,X.jsx)(Rh,{title:a(`parallelReminderEnabled`),tip:`${a(`parallelReminderEnabledDesc`)}\n${a(`parallelReminderOffHint`)}`,enabled:c.parallelReminderEnabled??!0,onToggle:()=>Q({parallelReminderEnabled:!(c.parallelReminderEnabled??!0)})}),(0,X.jsx)(Rh,{title:a(`devNoCache`),tip:a(`devNoCacheDesc`),enabled:c.devNoCache??!0,onToggle:()=>Q({devNoCache:!(c.devNoCache??!0)})}),(0,X.jsx)(Rh,{title:a(`autoReload`),tip:a(`autoReloadDesc`),enabled:c.autoReload??!0,onToggle:()=>Q({autoReload:!(c.autoReload??!0)})}),(0,X.jsx)(`hr`,{className:`set-sep`}),(0,X.jsx)(Rh,{title:a(`wideChat`),tip:a(`wideChatDesc`),enabled:Ce,onToggle:()=>Hm({wide:!Ce})}),(0,X.jsx)(Rh,{title:a(`projectTitle`),tip:a(`projectTitleDesc`),enabled:Te,onToggle:()=>$m({projectName:!Te})}),(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:[a(`wallpaperTitle`),(0,X.jsx)(Cs,{text:a(`wallpaperDesc`)})]}),(0,X.jsxs)(`div`,{className:`wallpaper-url-row`,children:[(0,X.jsx)(`input`,{className:`set-input wallpaper-url`,placeholder:a(`wallpaperUrlPh`),value:Y,maxLength:2e3,spellCheck:!1,onFocus:()=>{je.current=!0},onChange:e=>Oe(e.target.value),onBlur:()=>{if(je.current=!1,!Y.trim()&&J.url.startsWith(`data:`)){Oe(``);return}let e=uh(Y);Oe(e),e!==J.url&&_h({...J,url:e})},onKeyDown:e=>{e.key===`Enter`?e.target.blur():e.key===`Escape`&&(Oe(J.url.startsWith(`data:`)?``:J.url),e.target.blur())}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:Ie,onClick:()=>Ne.current?.click(),children:[(0,X.jsx)(F,{}),` `,a(`wallpaperUpload`)]}),(0,X.jsx)(`input`,{ref:Ne,type:`file`,accept:`image/*`,hidden:!0,onChange:Ve})]}),Re&&(0,X.jsx)(`p`,{className:`set-hint`,children:a(`wallpaperUploadFailed`)}),(0,X.jsxs)(`div`,{className:`wallpaper-sliders`,children:[(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:a(`wallpaperDim`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:95,step:1,value:J.dim,onChange:e=>_h({...J,dim:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[J.dim,`%`]})]}),(0,X.jsxs)(`label`,{className:`wallpaper-slider`,children:[(0,X.jsx)(`span`,{children:a(`wallpaperBlur`)}),(0,X.jsx)(`input`,{type:`range`,min:0,max:24,step:1,value:J.blur,onChange:e=>_h({...J,blur:Number(e.target.value)})}),(0,X.jsxs)(`output`,{children:[J.blur,`px`]})]})]})]}),J.url&&(0,X.jsxs)(`div`,{className:`wallpaper-current`,children:[(0,X.jsx)(`img`,{className:`wallpaper-preview`,src:J.url,alt:``}),(0,X.jsx)(`button`,{type:`button`,className:`wallpaper-clear`,onClick:()=>{Oe(``),_h({...J,url:``})},children:a(`wallpaperClear`)})]})]})]}),p===`quick`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(ie,{className:`set-section-icon`}),a(`quickPhrases`),(0,X.jsx)(Cs,{text:a(`quickPhrasesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:c.quickPhrases.length})]}),(0,X.jsx)(Rh,{title:a(`quickPhrasesEnabled`),tip:a(`quickPhrasesDesc`),enabled:c.quickPhrasesEnabled,onToggle:()=>Q({quickPhrasesEnabled:!c.quickPhrasesEnabled})}),!c.quickPhrasesEnabled&&(0,X.jsx)(`p`,{className:`set-hint`,children:a(`quickPhrasesOffHint`)}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`quickPhrasesPlaceholder`),value:Rt,maxLength:200,onChange:e=>zt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Rt.trim()&&(Q({quickPhrases:[...c.quickPhrases,Rt.trim()]}),zt(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!Rt.trim(),onClick:()=>{Q({quickPhrases:[...c.quickPhrases,Rt.trim()]}),zt(``)},children:[(0,X.jsx)(se,{}),` `,a(`quickPhrasesAdd`)]})]}),c.quickPhrases.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`quickPhrasesEmpty`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.quickPhrases.map((e,t)=>(0,X.jsx)(`div`,{className:`set-row`,children:Bt?.index===t?(0,X.jsx)(`div`,{className:`set-row-info`,children:(0,X.jsx)(`input`,{className:`set-input`,autoFocus:!0,value:Bt.value,maxLength:200,placeholder:a(`quickPhrasesEditPh`),onChange:e=>Vt({index:t,value:e.target.value}),onKeyDown:e=>{e.key===`Enter`?dn():e.key===`Escape`&&Vt(null)},onBlur:dn})}):(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:a(`quickPhrasesEdit`),onClick:()=>Vt({index:t,value:e}),children:(0,X.jsx)(Me,{})}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn`,title:a(`quickPhrasesMoveUp`),disabled:t===0,onClick:()=>{let e=[...c.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:a(`quickPhrasesMoveDown`),disabled:t===c.quickPhrases.length-1,onClick:()=>{let e=[...c.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:a(`quickPhrasesDelete`),onClick:()=>Q({quickPhrases:c.quickPhrases.filter((e,n)=>n!==t)}),children:(0,X.jsx)(L,{})})]})]})},`${t}:${e}`))}),(0,X.jsx)(`div`,{className:`compose-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>{Vt(null),Q({quickPhrases:Eh[o]??Eh.en})},children:a(`quickPhrasesReset`)})})]}),p===`skills`&&(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`}),a(`settingsSkills`),(0,X.jsx)(Cs,{text:`${a(`skillFullTextLabel`)}:${a(`skillFullTextDesc`)}`}),(0,X.jsx)(`span`,{className:`set-count`,children:c.skills.length})]}),c.skills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(d?`dshSkillsNote`:`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.skills.map(e=>(0,X.jsx)(Rh,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>fn(e),action:(0,X.jsx)(`button`,{type:`button`,className:`tpl-chip${pn.has(e.name)?` on`:``}`,title:a(`skillFullTextDesc`),onClick:()=>gn(e.name),children:a(`skillFullTextShort`)})},e.name))})]}),p===`extensions`&&(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`}),a(`settingsExtensions`),(0,X.jsx)(`span`,{className:`set-count`,children:c.extensions.length})]}),c.extensions.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(d?`dshExtensionsNote`:`noExtensions`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.extensions.map(e=>{let t=e.id.startsWith(`npm:`)?e.id.slice(4):null;return(0,X.jsx)(Rh,{title:e.name,subtitle:e.path,enabled:e.enabled,onToggle:()=>bn(e),action:t?Xe===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:a(`uninstallConfirmHint`),onClick:()=>An(t),children:a(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`uninstallHint`),onClick:()=>Ze(e.id),children:[(0,X.jsx)(L,{}),a(`uninstallExt`)]}):void 0},e.id)})})]}),p===`layout`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(B,{className:`set-section-icon`}),a(`uiLayoutTitle`),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:Kn,children:a(`uiLayoutRestoreAll`)})]}),(0,X.jsx)(`div`,{className:`set-note`,children:a(`uiLayoutHint`)}),(0,X.jsx)(`input`,{className:`set-ui-filter`,value:In,placeholder:a(`uiLayoutSearch`),"aria-label":a(`uiLayoutSearch`),onChange:e=>Ln(e.target.value)}),Pn.map(({slot:e,labelKey:t})=>{let n=(tn[e]??[]).filter(e=>d||e.id!==`host:composer-dsh-perm`&&e.id!==`host:composer-dsh-preset`),r=In.trim().toLowerCase(),i=!r&&Fn.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}],o=i.reduce((e,t)=>e+t.items.length,0);if(r&&o===0)return null;let s=(t,i)=>{let o=i.findIndex(e=>e.id===t.id),s=fr.has(t.id);return(0,X.jsxs)(`div`,{className:`set-row`,children:[(0,X.jsxs)(`label`,{className:`set-toggle`,title:s?a(`uiLayoutRequired`):t.id,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:!t.hidden,disabled:s,onChange:()=>Vn(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:a(`uiLayoutArranged`)}),t.movedFrom&&(0,X.jsxs)(`span`,{className:`set-ui-source`,title:t.id,children:[a(`uiLayoutMovedFrom`),`: `,Rn(t.movedFrom)]}),Fn.includes(e)&&(0,X.jsx)(`label`,{className:`set-ui-align`,title:a(`uiLayoutAlign`),children:(0,X.jsxs)(`select`,{value:t.align,onChange:e=>Un(t.id,e.target.value),"aria-label":a(`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:zn?.labels?.[t.id]??``,placeholder:a(`uiLayoutRename`),title:a(`uiLayoutRename`),"aria-label":a(`uiLayoutRename`),onBlur:e=>{e.target.value!==(zn?.labels?.[t.id]??``)&&Wn(t.id,e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&e.target.blur()}},`${t.id}:${zn?.labels?.[t.id]??``}`),t.userOverrides.length>0&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Gn(t.id),children:a(`uiLayoutRestore`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||o<=0,onClick:()=>Hn(n,i,t.id,-1),children:`↑`}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,disabled:!!r||o<0||o>=i.length-1,onClick:()=>Hn(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:a(t)}),e===`topbar.primary`&&(0,X.jsxs)(`label`,{className:`set-toggle`,title:`topbarText`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:zn?.topbarText!==!1,onChange:e=>Bn({topbarText:e.target.checked})}),(0,X.jsx)(`span`,{children:a(`uiLayoutTopbarText`)})]}),n.length===0?(0,X.jsx)(`div`,{className:`set-empty`,children:a(`uiLayoutEmpty`)}):i.map(e=>(0,X.jsxs)(f.Fragment,{children:[e.align&&(0,X.jsx)(`div`,{className:`set-ui-slot-title set-ui-seg`,children:e.align}),e.items.map(t=>s(t,e.items))]},e.align??`all`))]},e)})]}),p===`plugins`&&!u&&(0,X.jsxs)(`div`,{className:`set-subtabs`,role:`tablist`,children:[(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`market`,className:`set-subtab${h===`market`?` active`:``}`,onClick:()=>{g(`market`),_.current?.scrollTo({top:0})},children:[a(`pluginMarket`),(0,X.jsx)(`span`,{className:`set-count`,children:e.pluginCatalog.length})]}),(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":h===`installed`,className:`set-subtab${h===`installed`?` active`:``}`,onClick:()=>{g(`installed`),_.current?.scrollTo({top:0})},children:[a(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length})]})]}),p===`plugins`&&h===`installed`&&(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`}),a(`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:a(`pluginGrantsHint`)}),e.pluginGrants.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`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:a(`pluginGrantsRevoke`)})]},t))]},e.pluginId))})]}),p===`plugins`&&h===`installed`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(xe,{className:`set-section-icon`}),a(`pluginPermsTitle`),(0,X.jsx)(`span`,{className:`set-count`,children:(e.pluginPermissions??[]).length})]}),(0,X.jsx)(`div`,{className:`set-note`,children:a(`pluginPermsHint`)}),(e.pluginPermissions??[]).length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`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`?a(`pluginPermNet`):a(`pluginPermLlm`),e.session?` · ${a(`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:a(`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:a(`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??a(`pluginPermUnscoped`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>$({type:`plugin_permission_revoke`,pluginId:e.pluginId,family:e.family}),children:a(`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}`))})]}),p===`plugins`&&u&&(0,X.jsx)(`div`,{className:`set-section`,children:(0,X.jsx)(`div`,{className:`set-note`,children:a(`updatesManaged`)})}),p===`plugins`&&!u&&h===`market`&&(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`}),a(`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:a(`pluginBuildHint`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:St,onChange:e=>Ct(e.target.checked)}),a(`pluginBuildSource`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginCatalogSyncHint`),onClick:()=>Tt(e=>!e),children:[(0,X.jsx)(oe,{}),a(`pluginCatalogSync`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginCatalogAddHint`),onClick:()=>xt(e=>!e),children:[(0,X.jsx)(se,{}),a(`pluginCatalogAdd`)]})]}),wt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`div`,{className:`set-note`,children:a(`pluginCatalogSyncHint`)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogSyncSource`),value:Et,onChange:e=>Dt(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Qn(Et)}}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:a(`pluginCatalogSyncInstall`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:Ot,onChange:e=>kt(e.target.checked)}),a(`pluginCatalogSyncInstall`)]}),(0,X.jsxs)(`label`,{className:`set-catalog-build`,title:a(`pluginCatalogSyncReplace`),children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:At,onChange:e=>jt(e.target.checked)}),a(`pluginCatalogSyncReplace`)]}),It.length>0&&(0,X.jsxs)(`div`,{className:`set-catalog-recent`,children:[(0,X.jsx)(`span`,{className:`set-catalog-recent-label`,children:a(`pluginCatalogSyncRecent`)}),It.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`set-catalog-recent-item`,title:e,onClick:()=>{Dt(e),Qn(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:!Et.trim(),onClick:()=>Qn(Et),children:a(`pluginCatalogSyncSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>Tt(!1),children:a(`cancel`)})]}),$n&&($n.ok?(0,X.jsxs)(`div`,{className:`set-catalog-job ok`,children:[(0,X.jsxs)(`span`,{children:[`✓ `,a(`pluginCatalogSyncOk`,{n:$n.entryCount??0}),$n.installed?` · ${a(`pluginCatalogSyncInstalled`,{ok:$n.installed.filter(e=>e.ok).length,fail:$n.installed.filter(e=>!e.ok).length})}`:null]}),$n.installed?.some(e=>!e.ok)&&(0,X.jsx)(`pre`,{className:`set-catalog-job-out`,children:$n.installed.filter(e=>!e.ok).map(e=>`${e.id}:${e.error??`?`}`).join(`
|
|
363
|
-
`)})]}):(0,X.jsx)(`div`,{className:`set-catalog-job error`,children:(0,X.jsxs)(`span`,{children:[`✗ `,$n.error||a(`pluginJobFailed`)]})}))]}),bt&&(0,X.jsxs)(`div`,{className:`set-catalog-add`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogSource`),value:ut,onChange:e=>dt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogId`),value:ft,onChange:e=>pt(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogName`),value:mt,onChange:e=>ht(e.target.value)}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`pluginCatalogIcon`),value:vt,onChange:e=>yt(e.target.value)}),(0,X.jsx)(`textarea`,{className:`set-input`,rows:2,placeholder:a(`pluginCatalogDesc`),value:gt,onChange:e=>_t(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-catalog-add-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,disabled:!ut.trim(),onClick:Zn,children:a(`pluginCatalogAddSubmit`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>xt(!1),children:a(`cancel`)})]})]}),e.pluginCatalog.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noPluginCatalog`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.pluginCatalog.map(e=>{let t=vn.has(e.id);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)(sr,{icon:e.icon,iconSvg:e.iconSvg}),` `,e.name]}),t&&(0,X.jsx)(`span`,{className:`set-catalog-installed`,children:a(`pluginInstalled`)}),!e.builtin&&(0,X.jsx)(`span`,{className:`set-catalog-custom`,children:a(`pluginCatalogCustom`)})]}),e.description&&(0,X.jsx)(`div`,{className:`set-catalog-desc`,children:e.description}),(0,X.jsx)(`div`,{className:`set-catalog-source`,children:e.source}),Nn(e.id)]}),(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginUpdateHint`),onClick:()=>Jn(e.id,e.source),children:[(0,X.jsx)(oe,{}),a(`pluginUpdate`)]}),Qe===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:a(`pluginUninstallHint`),onClick:()=>qn(e.id),children:a(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginUninstallHint`),onClick:()=>$e(e.id),children:[(0,X.jsx)(L,{}),a(`uninstallExt`)]})]}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginInstallHint`),onClick:()=>Yn(e),children:[(0,X.jsx)(Pe,{}),a(`pluginInstall`)]}),!e.builtin&&(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginCatalogRemoveHint`),onClick:()=>Xn(e.id),children:(0,X.jsx)(M,{})})]})]},e.id)})})]}),p===`plugins`&&h===`installed`&&(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`}),a(`pluginListTab`),(0,X.jsx)(`span`,{className:`set-count`,children:e.plugins.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginRescanHint`),onClick:()=>$({type:`plugins_reload`}),children:[(0,X.jsx)(oe,{}),a(`pluginRescan`)]})]}),e.plugins.length>0&&(0,X.jsx)(Vh,{plugins:e.plugins,disabledIds:_n}),e.plugins.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noUiPlugins`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:e.plugins.map(e=>(0,X.jsxs)(f.Fragment,{children:[(0,X.jsx)(Rh,{title:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Bh,{phase:wh(e,_n.has(e.id)),label:s(zh(wh(e,_n.has(e.id))))}),(0,X.jsx)(sr,{icon:e.icon,iconSvg:e.iconSvg}),` `,e.name]}),subtitle:(e.error?`${e.id} · ${e.error}`:e.source?`${e.id} · ${e.source}`:`${e.id} · ${a(`uiPluginNoSource`)}`)+(e.permissions?.length?` · ${a(`uiPluginPerms`)}: ${e.permissions.join(`, `)}`:``),enabled:!_n.has(e.id)&&!e.error,onToggle:()=>!e.error&&yn(e),action:(0,X.jsxs)(`div`,{className:`set-row-actions`,children:[e.source&&(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginUpdateHint`),onClick:()=>Jn(e.id,e.source),children:[(0,X.jsx)(oe,{}),a(`pluginUpdate`)]}),Qe===e.id?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:a(`pluginUninstallHint`),onClick:()=>qn(e.id),children:a(`uninstallConfirm`)}):(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`pluginUninstallHint`),onClick:()=>$e(e.id),children:[(0,X.jsx)(L,{}),a(`uninstallExt`)]})]})},e.id),e.agentTools&&e.agentTools.length>0&&!d&&(0,X.jsxs)(`div`,{className:`set-row`,title:a(`pluginToolOffHint`),children:[(0,X.jsxs)(`span`,{className:`set-ui-source`,children:[a(`pluginToolsSection`),` (`,e.agentTools.length,`)`,e.agentTools.some(e=>Cn.has(e.name))?` · ${a(`settingsDisabled`)}`:``]}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,onClick:()=>m(`tools`),children:[a(`settingsTools`),` →`]})})]}),(0,X.jsxs)(`div`,{className:`set-row set-log-row`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`set-diag-toggle`,onClick:()=>{it===e.id?at(null):(at(e.id),$(No(e.id)))},children:[(0,X.jsx)(ke,{}),a(`pluginLogTitle`),` (`,Bo(e.id).length,`) ·`,` `,it===e.id?a(`pluginLogHide`):a(`pluginLogShow`)]}),it===e.id&&(0,X.jsx)(Uh,{pluginId:e.id})]}),e.diagnostics&&e.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:()=>rt(et===e.id?null:e.id),children:[(0,X.jsx)(nt,{}),a(`pluginDiagTitle`),` (`,e.diagnostics.length,`) ·`,` `,et===e.id?a(`pluginDiagHide`):a(`pluginDiagShow`)]}),et===e.id&&(0,X.jsx)(`ul`,{className:`set-diag-list`,children:e.diagnostics.map((t,n)=>(0,X.jsx)(`li`,{children:t},`${e.id}-${n}`))})]}),e.wantsDom&&(0,X.jsxs)(`div`,{className:`set-row`,title:a(`pluginDomDesc`),children:[(0,X.jsx)(`span`,{className:`set-ui-source`,children:e.domGranted?a(`pluginDomGranted`):a(`pluginDomNeed`)}),(0,X.jsx)(`div`,{className:`set-row-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall${e.domGranted?``:` confirm`}`,title:a(`pluginDomDesc`),onClick:()=>$({type:`plugin_dom_consent`,pluginId:e.id,granted:!e.domGranted}),children:e.domGranted?a(`pluginDomRevoke`):a(`pluginDomGrant`)})})]}),e.settingsSchema&&e.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:()=>ct(t=>({...t,[e.id]:!t[e.id]})),children:[(0,X.jsx)(B,{}),a(`pluginSettingsTitle`),` (`,e.settingsSchema.length,`) ·`,` `,st[e.id]?a(`pluginSettingsHide`):a(`pluginSettingsShow`)]}),st[e.id]&&(0,X.jsx)(km,{plugin:e,models:c?.subagentModels??[]})]})]},e.id))})]}),p===`plugins`&&d&&h===`installed`&&(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`}),a(`dshPatches`),(0,X.jsx)(Cs,{text:a(`dshPatchesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:e.dshPatches?.files.length??0}),(0,X.jsxs)(`button`,{type:`button`,className:`set-uninstall`,title:a(`dshPatchesRescanHint`),onClick:()=>$({type:`dsh_patches_rescan`}),children:[(0,X.jsx)(oe,{}),a(`dshPatchesRescan`)]})]}),(e.dshPatches?.files.length??0)===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`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:[Ih(e.size),` · `,new Date(e.mtimeMs).toLocaleString()]})]})},e.name))}),(0,X.jsxs)(`p`,{className:`set-hint`,children:[a(`dshPatchesPath`),` `,e.dshPatches?.patchDir??``]})]}),p===`review`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(j,{className:`set-section-icon`}),a(`settingsReview`),(0,X.jsx)(Cs,{text:a(`settingsReviewDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:c.reviewSkills.length})]}),(0,X.jsx)(Rh,{title:a(`goalModeEnabled`),tip:`${a(`goalModeEnabledDesc`)}\n${a(`goalModeOffHint`)}`,enabled:c.goalModeEnabled,onToggle:()=>Q({goalModeEnabled:!c.goalModeEnabled})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:5,placeholder:a(`reviewPromptPlaceholder`),value:ce,onFocus:()=>de.current=!0,onBlur:()=>{de.current=!1,Q({reviewPrompt:ce})},onChange:e=>le(e.target.value)}),(0,X.jsxs)(`div`,{className:`set-field-label`,children:[a(`settingsReviewSkills`),d&&(0,X.jsxs)(X.Fragment,{children:[` `,(0,X.jsx)(Cs,{text:a(`dshReviewPromptNote`)})]})]}),c.reviewSkills.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noSkills`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.reviewSkills.map(e=>(0,X.jsx)(Rh,{title:e.name,subtitle:e.description,enabled:e.enabled,onToggle:()=>er(e)},`review-${e.name}`))})]}),p===`vision`&&(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`}),a(`settingsVisionBridge`)]}),(0,X.jsx)(Rh,{title:a(`visionBridgeEnabled`),tip:`${a(`settingsVisionBridgeDesc`)}\n${a(`visionBridgeOffHint`)}`,enabled:c.visionBridgeEnabled,onToggle:()=>Q({visionBridgeEnabled:!c.visionBridgeEnabled})}),c.visionBridgeEnabled&&(0,X.jsx)(Hh,{label:a(`visionBridgeModel`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:c.visionBridgeModel??``,onChange:e=>Q({visionBridgeModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:a(`visionBridgeAuto`)}),c.visionModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),c.visionBridgeEnabled&&(0,X.jsx)(Hh,{label:a(`visionBridgePromptMode`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:I,onChange:e=>{let t=e.target.value;ee(t),Q({visionBridgePromptMode:t})},children:[(0,X.jsx)(`option`,{value:`append`,children:a(`promptModeAppend`)}),(0,X.jsx)(`option`,{value:`replace`,children:a(`promptModeReplace`)})]})}),c.visionBridgeEnabled&&(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:a(`visionBridgePromptPlaceholder`),value:A,onFocus:()=>te.current=!0,onBlur:()=>{te.current=!1;let e=I===`replace`&&c.visionBridgeDefaultPrompt&&A===c.visionBridgeDefaultPrompt?``:A;Q({visionBridgePromptMode:I,visionBridgePrompt:e})},onChange:e=>N(e.target.value)}),c.visionBridgeEnabled&&(c.visionModels.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:a(`visionBridgeNoModels`)}):(0,X.jsx)(`p`,{className:`set-hint`,children:a(`visionBridgeCurrent`,{model:c.visionBridgeModel??a(`visionBridgeAuto`)})}))]}),p===`presets`&&d&&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)(Fe,{className:`set-section-icon`}),a(`dshPreset`),(0,X.jsx)(Cs,{text:a(`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:a(`dshDefaultPreset`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPresets.defaultPreset,onChange:e=>$({type:`dsh_preset_default`,preset:e.target.value}),children:pp(e.dshPresets.presets).map(e=>(0,X.jsxs)(`option`,{value:e.id,disabled:!!e.broken,children:[e.name??e.id,e.trust===`user`?` · ${a(`dshPresetUser`)}`:``]},e.id))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:pp(e.dshPresets.presets).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:[t.name??t.id,t.trust===`user`&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetUser`)}),t.id===e.dshPresets.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)}),t.broken&&(0,X.jsx)(`span`,{className:`dd-preset-tag warn`,children:a(`dshPresetBroken`)})]}),t.description&&!t.broken&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t.description}),t.broken&&(0,X.jsx)(`div`,{className:`set-row-desc`,children:t.broken})]})},t.id))}),(0,X.jsx)(`p`,{className:`set-hint`,children:a(`dshPresetUserNote`)})]}),p===`presets`&&d&&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)(V,{className:`set-section-icon`}),a(`dshPerm`),(0,X.jsx)(Cs,{text:a(`dshPermDefaultDesc`)})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`dshPermDefault`)}),(0,X.jsx)(`select`,{className:`set-select`,value:e.dshPermission.defaultPreset,onChange:e=>$({type:`dsh_permission_default`,preset:e.target.value}),children:gp.filter(t=>e.dshPermission.options.some(e=>e.value===t)).map(e=>(0,X.jsx)(`option`,{value:e,children:a(_p(e))},e))})]}),(0,X.jsx)(`div`,{className:`set-list`,children:gp.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:[a(_p(t)),t===e.dshPermission.defaultPreset&&(0,X.jsx)(`span`,{className:`dd-preset-tag`,children:a(`dshPresetDefaultTag`)})]}),(0,X.jsx)(`div`,{className:`set-row-desc`,children:a(vp(t))})]})},t))})]}),p===`presets`&&(0,X.jsxs)(`div`,{className:`set-section`,children:[(0,X.jsxs)(`div`,{className:`set-section-title`,children:[(0,X.jsx)(re,{className:`set-section-icon`}),a(`settingsPresets`),(0,X.jsx)(`span`,{className:`set-count`,children:c.presets.length})]}),(0,X.jsxs)(`div`,{className:`set-preset-save`,children:[(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`presetNamePlaceholder`),value:fe,onChange:e=>pe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&fe.trim()&&($({type:`save_preset`,name:fe.trim()}),pe(``))}}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,disabled:!fe.trim(),onClick:()=>{$({type:`save_preset`,name:fe.trim()}),pe(``)},children:[(0,X.jsx)(se,{}),` `,a(`saveAsPreset`)]})]}),c.presets.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noPresets`)}):(0,X.jsx)(`div`,{className:`set-list`,children:c.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`?a(`promptModeReplace`):a(`promptModeAppend`),e.disabledSkills.length>0&&` · ${a(`settingsSkills`)} ${e.disabledSkills.length}`,e.disabledExtensions.length>0&&` · ${a(`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:a(`applyPreset`)}),(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:a(`deletePreset`),onClick:()=>$({type:`delete_preset`,name:e.name}),children:(0,X.jsx)(L,{})})]})]},e.name))})]}),p===`subagent-templates`&&(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`}),a(`settingsSubagentTemplates`),(0,X.jsx)(Cs,{text:a(`settingsSubagentTemplatesDesc`)}),(0,X.jsx)(`span`,{className:`set-count`,children:c.subagentTemplates.length}),(0,X.jsxs)(`button`,{type:`button`,className:`set-save-btn`,title:a(`subagentTemplateNew`),onClick:()=>{G({name:``,description:``,promptMode:`replace`,systemPrompt:``,enabledSkills:[],enabledExtensions:[],model:``,thinkingLevel:``,enabled:!0}),ge(!0)},children:[(0,X.jsx)(se,{}),` `,a(`subagentTemplateNew`)]})]}),(0,X.jsx)(Hh,{label:a(`subagentDefaultModelLabel`),tip:a(`subagentDefaultModelHint`),children:(0,X.jsxs)(`select`,{className:`set-select`,value:c.subagentDefaultModel??``,onChange:e=>Q({subagentDefaultModel:e.target.value||null}),children:[(0,X.jsx)(`option`,{value:``,children:a(`subagentFollowMain`)}),c.subagentModels.map(e=>(0,X.jsx)(`option`,{value:`${e.provider}/${e.id}`,children:e.label},`${e.provider}/${e.id}`))]})}),c.subagentModels.length===0&&(0,X.jsx)(`p`,{className:`set-hint`,children:a(`subagentNoModels`)}),W&&(0,X.jsx)(`div`,{className:`modal-backdrop tpl-modal-backdrop`,onClick:()=>G(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":a(`close`),onClick:()=>G(null),children:(0,X.jsx)(M,{})}),(0,X.jsxs)(`div`,{className:`modal-head`,children:[(0,X.jsx)(P,{className:`modal-head-icon`}),(0,X.jsx)(`h2`,{children:he?a(`subagentTemplateNew`):`${a(`subagentTemplateEdit`)} · ${W.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:a(`tplNamePlaceholder`),value:W.name,onChange:e=>G({...W,name:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`tplDescriptionPlaceholder`),value:W.description,onChange:e=>G({...W,description:e.target.value})}),(0,X.jsx)(`input`,{className:`set-input`,placeholder:a(`tplDescriptionEnPlaceholder`),value:W.descriptionEn??``,onChange:e=>G({...W,descriptionEn:e.target.value})})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`tplPromptModeLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:W.promptMode,onChange:e=>G({...W,promptMode:e.target.value}),children:[(0,X.jsx)(`option`,{value:`replace`,children:a(`promptModeReplace`)}),(0,X.jsx)(`option`,{value:`append`,children:a(`promptModeAppend`)})]})]}),(0,X.jsxs)(`div`,{className:`set-mode-row`,children:[(0,X.jsx)(`label`,{className:`set-field-label`,children:a(`tplModelLabel`)}),(0,X.jsxs)(`select`,{className:`set-select`,value:W.model??``,onChange:e=>G({...W,model:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:a(`subagentFollowMain`)}),c.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:[a(`tplThinkingLabel`),` `,(0,X.jsx)(Cs,{text:a(`tplThinkingHint`)})]}),(0,X.jsxs)(`select`,{className:`set-select`,value:W.thinkingLevel??``,onChange:e=>G({...W,thinkingLevel:e.target.value}),children:[(0,X.jsx)(`option`,{value:``,children:a(`tplThinkingFollowMain`)}),up.map(e=>(0,X.jsx)(`option`,{value:e,children:a(`thinking.${e}`)},e))]})]}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${a(`tplSystemPromptLabel`)}${o===`zh`?`:`:`: `}${a(`tplSystemPromptPlaceholder`)}`,value:W.systemPrompt,onChange:e=>G({...W,systemPrompt:e.target.value})}),(0,X.jsx)(`textarea`,{className:`set-prompt-input`,rows:4,placeholder:`${a(`tplSystemPromptLabel`)}: ${a(`tplSystemPromptEnPlaceholder`)}`,value:W.systemPromptEn??``,onChange:e=>G({...W,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:[a(`tplSkillsLabel`),` · `,a(`tplWhitelistHint`)]})}),c.skills.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:a(`noSkills`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:c.skills.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${W.enabledSkills.includes(e.name)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:W.enabledSkills.includes(e.name),onChange:t=>{let n=t.target.checked;G({...W,enabledSkills:n?[...W.enabledSkills,e.name]:W.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:[a(`tplExtensionsLabel`),` · `,a(`tplWhitelistHint`)]})}),c.extensions.length===0?(0,X.jsx)(`p`,{className:`set-hint`,children:a(`noExtensions`)}):(0,X.jsx)(`div`,{className:`tpl-pick`,children:c.extensions.map(e=>(0,X.jsxs)(`label`,{className:`tpl-chip${W.enabledExtensions.includes(e.id)?` on`:``}`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:W.enabledExtensions.includes(e.id),onChange:t=>{let n=t.target.checked;G({...W,enabledExtensions:n?[...W.enabledExtensions,e.id]:W.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:!W.name.trim(),onClick:()=>{$({type:`save_subagent_template`,template:{...W,name:W.name.trim()}}),G(null)},children:a(`tplSave`)}),(0,X.jsx)(`button`,{type:`button`,className:`dd-refresh`,onClick:()=>G(null),children:a(`tplCancel`)})]})]})}),c.subagentTemplates.length===0?(0,X.jsx)(`p`,{className:`set-empty`,children:a(`noSubagentTemplates`)}):(0,X.jsx)(`div`,{className:`set-list set-list-flat`,children:c.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,c.subagentDefaultTemplates.includes(e.name)&&(0,X.jsx)(`span`,{className:`tpl-badge default`,children:a(`tplDefaultBadge`)}),!e.enabled&&(0,X.jsx)(`span`,{className:`tpl-badge`,children:a(`subagentTemplateClosed`)})]}),(0,X.jsxs)(`div`,{className:`set-row-desc`,children:[(o!==`zh`&&e.descriptionEn?e.descriptionEn:e.description)||`${e.promptMode===`replace`?a(`promptModeReplace`):a(`promptModeAppend`)}`,e.model?` · ${a(`tplModelLabel`)} ${e.model}`:` · ${a(`subagentFollowMain`)}`,e.thinkingLevel?` · ${a(`tplThinkingLabel`)} ${s(`thinking.${e.thinkingLevel}`)}`:``,e.enabledSkills.length>0&&` · ${a(`tplSkillsLabel`)} ${e.enabledSkills.length}`,e.enabledExtensions.length>0&&` · ${a(`tplExtensionsLabel`)} ${e.enabledExtensions.length}`,!e.description&&e.enabledSkills.length===0&&e.enabledExtensions.length===0&&` · ${a(`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?a(`subagentTemplateDisable`):a(`subagentTemplateEnable`)} · ${a(`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:a(`subagentTemplateEdit`),onClick:()=>{G({...e}),ge(!1)},children:a(`subagentTemplateEdit`)}),_e===e.name?(0,X.jsx)(`button`,{type:`button`,className:`set-uninstall confirm`,title:a(`uninstallConfirmHint`),onClick:()=>{$({type:`delete_subagent_template`,name:e.name}),ve(null)},children:a(`uninstallConfirm`)}):(0,X.jsx)(`button`,{type:`button`,className:`set-icon-btn danger`,title:a(`tplDelete`),onClick:()=>ve(e.name),children:(0,X.jsx)(L,{})})]})]},e.name))})]}),cn&&(0,X.jsx)(Ms,{plugin:cn.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:a(`close`)})})]})})}var Gh=0,Kh=``;function qh(){typeof document<`u`&&(Gh===0&&(Kh=document.body.style.overflow,document.body.style.overflow=`hidden`),Gh++)}function Jh(){typeof document<`u`&&(Gh=Math.max(0,Gh-1),Gh===0&&(document.body.style.overflow=Kh))}function Yh({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:p=!0}){let m=Z(),h=(0,f.useRef)(t);if((0,f.useLayoutEffect)(()=>{h.current=t}),mt(()=>l?(h.current(),!0):!1,e),(0,f.useEffect)(()=>{if(e&&p)return qh(),()=>{Jh()}},[e,p]),!e)return null;let g=e=>{e.target===e.currentTarget&&c&&h.current()},_=d??(typeof n==`string`?n:void 0);return(0,D.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":m(`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 Xh(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 Zh({servers:e,onClose:t}){let n=Z(),[r,i]=(0,f.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,f.useEffect)(()=>{$({type:`list_bg_servers`})},[]),(0,X.jsxs)(Yh,{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)(be,{}),` `,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)(M,{})})]}),e.length===0?(0,X.jsxs)(`div`,{className:`bg-task-empty`,children:[(0,X.jsx)(be,{}),(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`),` `,Xh(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)(ee,{}),(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)(z,{}),(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)(oe,{}),(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)(z,{}),(0,X.jsx)(`span`,{children:n(`bgTaskStopAll`)})]})]})]})}var Qh=3,$h=200;function eg(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tg(e){return typeof e==`string`&&e.trim()||void 0}function ng(e,t){let n=[];for(let r of e){let e=ig(r,t);if(n.includes(e)||n.push(e),n.length>=4){n.push(`…`);break}}return n.join(` | `)||`any`}function rg(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 ig(e,t=0){if(t>6||!eg(e))return`any`;if(tg(e.$ref))return`ref`;let n=tg(e.type);if(n===`array`){let n=e.items;return`array<${n===void 0?`any`:ig(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 ng(r,t+1)}return eg(e.properties)?`object`:eg(e.additionalProperties)?`record<${ig(e.additionalProperties,t+1)}>`:`any`}function ag(e){let t=[],n=e.enum;if(Array.isArray(n)&&n.length>0){let e=rg(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 og(e,t={}){let n=t.maxDepth??Qh,r=t.maxRows??$h,i=e;if(!eg(i))return[];let a=i.properties;if(!eg(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=eg(l)?l:{},u=t?`${t}.${s}`:s,d={name:u,type:ig(e,i),required:a.has(s),depth:i},f=tg(e.description);f&&(d.description=f);let p=ag(e);if(p&&(d.hint=p),o.push(d),i+1<n&&eg(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 sg(){let e=Z(),t=ga();return(0,f.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&fa()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]),t?(0,D.createPortal)((0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:fa,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)(Se,{}),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:fa,children:(0,X.jsx)(M,{})})]}),(0,X.jsx)(`div`,{className:`tool-info-body`,children:(0,X.jsx)(cg,{info:t})})]})}),document.body):null}function cg({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?[]:og(e.parameters),r=e.parameters===void 0?``:ug(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)(lg,{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)(ec,{text:r})]}),(0,X.jsx)(`pre`,{children:r})]})]}),(0,X.jsx)(`div`,{className:`tool-info-foot`,children:t(`toolInfoFootnote`)})]})}function lg({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 ug(e){try{return JSON.stringify(e,null,2)??``}catch{return``}}function dg(e,t){return e.toLowerCase().includes(t)}function fg({open:e,projects:t,fileSearch:n,sessionSearch:r,onClose:i,onSwitchSession:a,onSwitchProject:o,onPreviewFile:s}){let c=Z(),{locale:l}=Ut(),u=l===`en`?`Plugins`:`插件`,d=hi(`cwd`),p=(0,f.useRef)(null),[m,h]=(0,f.useState)(``),g=(0,f.useDeferredValue)(m),[_,v]=(0,f.useState)(0),y=(0,f.useRef)(1),b=(0,f.useRef)(0),x=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(!e)return;$({type:`list_sessions`}),$({type:`list_projects`});let t=m.trim();if(t){let e=++y.current;b.current=e,C(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}requestAnimationFrame(()=>p.current?.select())},[e]);let[S,C]=(0,f.useState)(!1);(0,f.useEffect)(()=>{x.current&&clearTimeout(x.current);let e=g.trim();if(!e){C(!1);return}return x.current=setTimeout(()=>{let t=++y.current;b.current=t,C(!0),$({type:`search_files`,reqId:t,query:e}),$({type:`search_sessions`,reqId:t,query:e})},300),()=>{x.current&&clearTimeout(x.current)}},[g]);let w=g.trim().toLowerCase(),T=(0,f.useMemo)(()=>!w||!r||r.reqId!==b.current||!r.ok?[]:r.results,[r,w]),E=(0,f.useMemo)(()=>w?t.filter(e=>dg(e.path,w)).slice(0,10):[],[t,w]),D=(0,f.useMemo)(()=>!w||!n||n.reqId!==b.current||!n.ok?[]:n.results,[n,w]);(0,f.useEffect)(()=>{n&&n.reqId===b.current&&r&&r.reqId===b.current&&b.current!==0&&C(!1)},[n,r]);let O=!!n&&n.ok&&n.truncated,[k,A]=(0,f.useState)([]);(0,f.useEffect)(()=>{if(!e)return;let t=g.trim();if(!t){A([]);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 Ra==`function`&&(r=Ra())}catch{r=[]}let i=r.filter(e=>e&&typeof e.id==`string`).map(e=>{if(typeof e.search==`function`)return e;try{let t=Ua(e.id);return t&&typeof t.search==`function`?{...e,search:t.search}:null}catch{return null}}).filter(e=>!!e);if(i.length===0){A([]);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})}A(t.slice(0,20))}),()=>{n=!0}},[e,g]);let j=(0,f.useMemo)(()=>[...T.map(e=>({kind:`session`,path:e.path,anchors:e.anchors})),...E.map(e=>({kind:`project`,path:e.path})),...D.filter(e=>e.type===`file`).map(e=>({kind:`file`,path:e.path,name:e.name})),...k.map(e=>({kind:`plugin`,providerId:e.providerId,providerLabel:e.providerLabel,title:e.title,action:e.action}))],[T,E,D,k]);(0,f.useEffect)(()=>{v(0)},[g]);let N=(0,f.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=++y.current;b.current=e,C(!0),$({type:`search_files`,reqId:e,query:t}),$({type:`search_sessions`,reqId:e,query:t})}}else e.kind===`plugin`?Ea(e.providerId,e.action,e.action).catch(()=>{}):s(e.path,e.name)}},[a,o,s,g]);(0,f.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),i()):e.key===`ArrowDown`?(e.preventDefault(),v(e=>Math.min(e+1,j.length-1))):e.key===`ArrowUp`?(e.preventDefault(),v(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),N(j[_]))};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[j,_,N,i,e]);let P=T.length+E.length+D.length+k.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)(H,{}),(0,X.jsx)(`input`,{ref:p,type:`text`,value:m,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)(M,{})})]}),(0,X.jsxs)(`div`,{className:`gs-results`,children:[!w&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(`gsHint`)}),w&&P===0&&!O&&(0,X.jsx)(`div`,{className:`gs-empty`,children:c(S?`gsSearching`:`gsNoResults`)}),T.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[F(c(`gsSessions`),T.length,(0,X.jsx)(me,{})),T.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:()=>N({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(),dn({attachments:[{path:``,key:`conv||${e.path}`,name:n,mode:`conversation`,sessionPath:e.path}]})},children:[`💬 `,c(`quoteConversationShort`)]})]},e.path)})]}),E.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[F(c(`gsProjects`),E.length,(0,X.jsx)(De,{})),E.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:()=>N({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)})]}),(D.length>0||w&&O)&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[F(c(`gsFiles`),D.length,(0,X.jsx)(ke,{})),D.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`&&N({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}`)}),O&&(0,X.jsx)(`div`,{className:`gs-truncated`,children:c(`gsTruncated`)})]}),k.length>0&&(0,X.jsxs)(`div`,{className:`gs-section`,children:[F(u,k.length,(0,X.jsx)(ue,{})),k.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:()=>N({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 pg({entry:e,pluginView:t,onUiAction:n,onClose:r}){let i=Z(),a=e.label||e.id,o=e.kind===`view`;return(0,X.jsx)(Yh,{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)(nm,{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 mg=5e3;function hg({file:e,content:t,onAddLines:n,onAttach:r,onClose:i,uiFilePreviewToolbar:a,onUiAction:o}){let s=Z(),[c,l]=(0,f.useState)(null),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(null),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(!0),[T,E]=(0,f.useState)(!0),[D,O]=(0,f.useState)(!1),j=(0,f.useRef)(!1),[N,P]=(0,f.useState)(!0),[F,I]=(0,f.useState)(!1),[L,R]=(0,f.useState)(100),ee=(0,f.useRef)(0),te=(0,f.useRef)(!1),ne=(0,f.useRef)(null);(0,f.useEffect)(()=>{d(!0),l(null),m(null),b(!1),S(``),w(!0),E(!0),O(!1),j.current=!1,$({type:`read_file`,path:e.path})},[e.path]),(0,f.useEffect)(()=>{t&&t.path===e.path&&(l(t),y||S(t.text),d(!1))},[t,y,e.path]),(0,f.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){ue();return}if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&y){e.preventDefault(),le();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(),ie())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,c,y,x]),(0,f.useEffect)(()=>{let e=()=>{te.current=!1,g(!1)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[]);let z=(0,f.useMemo)(()=>{if(!c)return[];let e=c.text.split(`
|
|
364
|
-
`);return e.length>0&&e[e.length-1]===``&&e.pop(),e.slice(0,mg)},[c]),B=c?.lines??0,V=B>mg,re=(e,t)=>{if(t){let t=ee.current>0?ee.current:e;m({start:Math.min(t,e),end:Math.max(t,e)})}else ee.current=e,m({start:e,end:e})},ie=()=>{z.length!==0&&(ee.current=1,m({start:1,end:z.length}))},H=()=>{p&&(n(e.path,e.name,p.start,p.end),v(!0),ne.current&&clearTimeout(ne.current),ne.current=setTimeout(()=>v(!1),1400))},ae=c!==null&&c.kind===`text`&&!c.binary&&!c.truncated,oe=()=>{S(c?.text??``),b(!1),j.current&&(gg(e.name)&&w(!0),_g(e.name)&&E(!0))},ce=()=>{if(y){if(x!==(c?.text??``)&&!window.confirm(s(`discardFileChanges`)))return;oe();return}ae&&c&&(j.current=gg(e.name)&&C||_g(e.name)&&T,gg(e.name)&&w(!1),_g(e.name)&&E(!1),m(null),S(c.text),b(!0))},le=()=>{y&&c&&ae&&$({type:`write_file`,path:e.path,text:x})&&(b(!1),j.current&&(gg(e.name)&&w(!0),_g(e.name)&&E(!0)),m(null))},ue=()=>{(!y||x===(c?.text??``)||window.confirm(s(`discardFileChanges`)))&&i()},de=e=>{R(Math.min(200,Math.max(50,e)))},fe=p?p.end-p.start+1:0,W=c?.binary??!1,me=c?.truncated??!1,G=c?.kind??`text`,ge=gg(e.name),_e=_g(e.name),ve=ge&&C&&!y&&G===`text`&&!W,ye=_e&&T&&!y&&G===`text`&&!W,be={"host:fp-md":ge&&G===`text`&&!W&&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)(Ae,{}):(0,X.jsx)(Re,{})}):null,"host:fp-html":_e&&G===`text`&&!W&&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)(Re,{}):(0,X.jsx)(Ae,{})}):null,"host:fp-edit":G===`text`&&!W&&c?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach edit ${y?`on`:``}`,"data-tip":s(me?`fileEditTruncated`:y?`exitEditFile`:`editFile`),disabled:!ae&&!y,onClick:ce,children:(0,X.jsx)(Me,{})}):null,"host:fp-wrap":G===`text`&&!W&&!ve&&!ye?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach wrap ${N?`on`:``}`,"data-tip":s(N?`disableWrap`:`enableWrap`),onClick:()=>P(e=>!e),children:(0,X.jsx)(Ie,{})}):null,"host:fp-zoom":G===`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:L<=50,onClick:()=>de(L-10),children:(0,X.jsx)(k,{})}),(0,X.jsxs)(`button`,{type:`button`,className:`fp-zoom-val`,title:s(`resetZoom`),onClick:()=>R(100),children:[L,`%`]}),(0,X.jsx)(`button`,{type:`button`,className:`fp-attach zoom-in`,"data-tip":s(`zoomIn`),disabled:L>=200,onClick:()=>de(L+10),children:(0,X.jsx)(A,{})})]}):null,"host:fp-inline":G!==`video`&&G!==`none`?(0,X.jsx)(`button`,{type:`button`,className:`fp-attach inline`,"data-tip":s(`attachInlineTip`),onClick:()=>r(e.path,e.name,`inline`),children:(0,X.jsx)(se,{})}):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)(K,{})}),"host:fp-full":(0,X.jsx)(`button`,{type:`button`,className:`fp-attach full ${F?`on`:``}`,"data-tip":s(F?`exitFullscreen`:`fullscreen`),onClick:()=>I(e=>!e),children:F?(0,X.jsx)(pe,{}):(0,X.jsx)(he,{})}),"host:fp-close":(0,X.jsx)(`button`,{type:`button`,className:`fp-close`,title:s(`close`),onClick:ue,children:(0,X.jsx)(M,{})})},xe=a===void 0?[`host:fp-md`,`host:fp-html`,`host:fp-edit`,`host:fp-wrap`,`host:fp-zoom`,`host:fp-inline`,`host:fp-ref`,`host:fp-full`,`host:fp-close`].map(e=>({id:e,source:`host`})):a.filter(e=>!e.hidden),Se=e=>Et(St(`/api/file?clientId=${encodeURIComponent(is())}&path=${encodeURIComponent(e)}`));return(0,X.jsx)(`div`,{className:`fp-overlay ${F?`fullscreen`:``}`,onMouseDown:e=>{e.target===e.currentTarget&&ue()},children:(0,X.jsxs)(`div`,{className:`fp ${F?`fullscreen`:``}`,style:{"--fp-zoom":L/100},children:[(0,X.jsxs)(`div`,{className:`fp-head`,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&&G===`text`&&!W&&s(`fileLines`,{n:B}),c&&` · ${vg(c.size)}`]}),(0,X.jsx)(`span`,{className:`fp-head-actions`,children:Gd(xe,be,o)})]}),me&&G===`text`&&!W&&(0,X.jsx)(`div`,{className:`fp-notice`,children:s(`previewTruncated`)}),u&&!c&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`loading`)}),!u&&G===`none`&&!W&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`previewNotSupported`)}),!u&&G===`image`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`img`,{className:`fp-media`,src:Se(e.path),alt:e.name})}),!u&&G===`video`&&(0,X.jsx)(`div`,{className:`fp-media-wrap`,children:(0,X.jsx)(`video`,{className:`fp-media`,src:Se(e.path),controls:!0,preload:`metadata`})}),!u&&ye&&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.jsx)(`iframe`,{className:`fp-html-frame`,src:(e=>{let t=e.split(`/`).map(e=>encodeURIComponent(e)).join(`/`);return Et(St(`${/^[A-Za-z]:([\\/]|$)/.test(e)||e.startsWith(`/`)?`/api/preview/__abs__/${t}`:`/api/preview/${t}`}?clientId=${encodeURIComponent(is())}${D?`&allowJs=1`:``}`))})(e.path),title:e.name,sandbox:D?`allow-scripts`:``,referrerPolicy:`no-referrer`},D?`js`:`nojs`)]}),!u&&ve&&c&&(0,X.jsx)(`div`,{className:`fp-markdown msg-text`,children:(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,children:(0,X.jsx)(Hc,{text:c.text})})}),!u&&W&&G!==`image`&&G!==`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&&G===`text`&&!W&&c&&(0,X.jsx)(`textarea`,{className:`fp-editor ${N?``:`no-wrap`}`,value:x,onChange:e=>S(e.target.value),wrap:N?`soft`:`off`,spellCheck:!1,autoFocus:!0}),!u&&!ve&&!ye&&!y&&G===`text`&&!W&&c&&z.length===0&&(0,X.jsx)(`div`,{className:`fp-empty`,children:s(`emptyFile`)}),!u&&!ve&&!ye&&!y&&G===`text`&&!W&&z.length>0&&(0,X.jsxs)(`div`,{className:`fp-code ${h?`dragging`:``} ${N?``:`no-wrap`}`,onMouseDown:e=>{e.button===0&&e.preventDefault()},children:[z.map((e,t)=>{let n=t+1,r=p!==null&&n>=p.start&&n<=p.end;return(0,X.jsxs)(`div`,{className:`fp-line ${r?`sel`:``}`,onMouseDown:e=>{e.button===0&&(re(n,e.shiftKey),te.current=!0,g(!0))},onMouseEnter:()=>{te.current&&re(n,!0)},children:[(0,X.jsx)(`span`,{className:`fp-num`,children:n}),(0,X.jsx)(`span`,{className:`fp-code-text`,children:e})]},n)}),V&&(0,X.jsx)(`div`,{className:`fp-lines-note`,children:s(`previewLinesTruncated`,{n:mg})})]}),(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:ce,children:s(`cancel`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:x===(c?.text??``),onClick:le,children:[(0,X.jsx)(U,{}),` `,s(`saveFile`)]})]})]}):!ve&&!ye&&G===`text`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`fp-hint`,children:p?s(`selectedRange`,{n:fe,start:p.start,end:p.end}):s(`selectLinesHint`)}),(0,X.jsxs)(`div`,{className:`fp-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:z.length===0,onClick:ie,children:s(`selectAll`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:!p,onClick:()=>m(null),children:s(`clearSelection`)}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,disabled:!p||W,onClick:H,children:[_?(0,X.jsx)(Ke,{}):null,s(_?`addedToChat`:`addToChat`)]})]})]})})]})})}function gg(e){let t=e.toLowerCase();return t.endsWith(`.md`)||t.endsWith(`.markdown`)}function _g(e){let t=e.toLowerCase();return t.endsWith(`.html`)||t.endsWith(`.htm`)||t.endsWith(`.xhtml`)}function vg(e){return e>=1048576?`${(e/1048576).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}var yg=`pi-web-sounds`,bg={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function xg(){try{let e=localStorage.getItem(yg);if(!e)return{...bg};let t=JSON.parse(e),n={...bg,...t};for(let e of[`enabled`,`question`,`done`,`start`,`error`])typeof n[e]!=`boolean`&&(n[e]=bg[e]);return n.volume=typeof n.volume!=`number`||!Number.isFinite(n.volume)?bg.volume:Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...bg}}}function Sg(e){try{localStorage.setItem(yg,JSON.stringify(e))}catch{}}var Cg=null;function wg(){try{if(!Cg){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Cg=new e}return Cg.state===`suspended`&&Cg.resume(),Cg}catch{return null}}var Tg={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}]};function Eg(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 Dg(e,t=xg()){if(!t.enabled||!t[e])return;let n=wg();if(!n)return;let r=Math.max(0,Math.min(1,t.volume/100));for(let t of Tg[e])Eg(n,t,r)}var Og=(0,f.lazy)(()=>so(()=>import(`./TerminalPanel-MVoxpJOA.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4])));function kg({notice:e,onDismiss:t}){let n=Z(),{locale:r}=Ut(),i=r!==`zh`&&e.textEn?e.textEn:e.text,[a,o]=(0,f.useState)(!1);(0,f.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`?rt:e.level===`warning`?nt:Se;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)(M,{})})]})}var Ag=[],jg=180,Mg=520,Ng=240,Pg=e=>`pi-web-ui:${e}-panel-width`;function Fg(e){let t=Number(localStorage.getItem(Pg(e)));return Number.isFinite(t)&&t>=jg&&t<=Mg?t:Ng}var Ig=e=>`pi-web-ui:${e}-panel-collapsed`;function Lg(e){return localStorage.getItem(Ig(e))===`1`}function Rg({side:e,width:t,onResize:n}){let r=Z(),i=(0,f.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(Mg,Math.max(jg,Math.round(a+r))),n(o)},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),document.body.classList.remove(`panel-resizing`),localStorage.setItem(Pg(e),String(o))};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(Ng)})}function zg({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)(Ve,{}):(0,X.jsx)(He,{})})}var Bg=`pi-web-ui:plugin-path-grants`;function Vg(){try{let e=localStorage.getItem(Bg),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function Hg(e){try{let t=[...new Set([...Vg(),e])];localStorage.setItem(Bg,JSON.stringify(t))}catch{}}function Ug(){let e=Z(),{locale:t}=Ut(),{chat:n,send:r,dismissNotice:i,pushNotice:a,terminal:o}=ls(),s=(0,f.useRef)(!1);(0,f.useEffect)(()=>{n.ready&&n.settings&&(s.current||n.settings.quickPhrasesSeeded||(s.current=!0,n.settings.quickPhrases.length===0&&r({type:`set_settings`,quickPhrases:Eh[t]??Eh.en,quickPhrasesSeeded:!0})))},[n.ready,n.settings,r,t]);let c=n.state?.cwd??``,l=ih();(0,f.useEffect)(()=>{let t=l?Zm(c):``;document.title=t?`${t} — pi-web-ui`:e(`docTitle`)},[c,l,e]);let[u,d]=(0,f.useState)([]);(0,f.useEffect)(()=>(cn(e=>d(t=>Mf(t,e))),()=>cn(null)),[]);let[p,m]=(0,f.useState)(null),h=(0,f.useRef)(!1);(0,f.useEffect)(()=>{h.current=p!==null},[p]),(0,f.useEffect)(()=>(Ll({open:e=>m({path:e.path,name:e.name}),isOpen:()=>h.current}),()=>Ll(null)),[]);let[g,_]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=()=>_(!1);return window.addEventListener(`drop`,e,!0),()=>window.removeEventListener(`drop`,e,!0)},[]);let[v,y]=(0,f.useState)(`chat`),b=(e=>!n.tabs||e===`chat`||n.tabs.includes(e))(v.startsWith(`plugin:`)?`plugins`:v)?v:`chat`,x=(0,f.useMemo)(()=>n.plugins.filter(e=>!n.settings?.disabledPlugins?.includes(e.id)),[n.plugins,n.settings?.disabledPlugins]),S=(0,f.useMemo)(()=>jr(br(n.plugins),{locale:t,t:t=>e(t),disabledPlugins:n.settings?.disabledPlugins??[],layout:n.settings?.uiLayout}),[n.plugins,n.settings?.disabledPlugins,n.settings?.uiLayout,t,e]),C=(0,f.useMemo)(()=>S[`topbar.primary`].filter(e=>!e.hidden),[S]),w=(0,f.useMemo)(()=>[...S[`topbar.primary`].filter(e=>e.hidden),...S[`topbar.overflow`]],[S]),T=(0,f.useMemo)(()=>S[`leftpanel.sessions`].filter(e=>!e.hidden),[S]),E=(0,f.useMemo)(()=>S[`terminal.toolbar`].filter(e=>!e.hidden),[S]),D=(0,f.useMemo)(()=>S[`scm.toolbar`].filter(e=>!e.hidden),[S]),O=(0,f.useMemo)(()=>S[`goalbar.actions`].filter(e=>!e.hidden),[S]),k=(0,f.useMemo)(()=>S[`chat.header`].filter(e=>!e.hidden),[S]),A=(0,f.useMemo)(()=>S[`chat.empty`].filter(e=>!e.hidden),[S]),j=(0,f.useMemo)(()=>S[`file.preview.toolbar`].filter(e=>!e.hidden),[S]),N=(0,f.useMemo)(()=>Object.fromEntries((n.dshPresets?.presets??[]).map(e=>[e.id,e.name??e.id])),[n.dshPresets]),P=(0,f.useMemo)(()=>S[`notice.actions`].filter(e=>!e.hidden),[S]),F=(0,f.useCallback)((t,n,r)=>{let i=(t.action??``).trim();if(t.kind===`view`||(!i||i===`view`)&&t.source!==`host`){y(t.view??`plugin:${t.source.startsWith(`plugin:`)?t.source.slice(7):``}`);return}i&&Ea(t.source.startsWith(`plugin:`)?t.source.slice(7):``,i,t.id,{...n===void 0?{}:{value:n},...r===void 0?{}:{target:r},loadBundle:async e=>{let t=V.current.plugins.find(t=>t.id===e);return t?ko(t,V.current.pluginsEpoch):!1}}).then(t=>{t||a(`info`,e(`pluginUiNoHandler`))})},[e,a]),[I,L]=(0,f.useState)([]);(0,f.useEffect)(()=>Co(L),[]);let[R,ee]=(0,f.useState)([]);(0,f.useEffect)(()=>xo(ee),[]);let[te,ne]=(0,f.useState)(null),z=te?S[`modal.dialog`].find(e=>e.id===te&&!e.hidden):void 0,B=(0,f.useMemo)(()=>{if(!z||z.kind!==`view`)return``;let e=z.view??``;return e.startsWith(`plugin:`)?e.slice(7):z.source.startsWith(`plugin:`)?z.source.slice(7):``},[z]);(0,f.useEffect)(()=>{if(!z||!B||I.some(e=>e.info.id===B))return;let e=V.current.plugins.find(e=>e.id===B);e&&ko(e,V.current.pluginsEpoch)},[z,B,I,n.pluginsEpoch]),(0,f.useEffect)(()=>{gc(r),_c(x,n.pluginsEpoch),wc(x,n.pluginsEpoch),Ao(x,n.pluginsEpoch)},[x,n.pluginsEpoch,r]);let V=(0,f.useRef)(n);V.current=n;let re=(0,f.useRef)(y);re.current=y;let ie=(0,f.useRef)(S);ie.current=S,(0,f.useEffect)(()=>(xa(ba({send:r,isReady:()=>!!V.current.state,setView:e=>re.current(e),getCwd:()=>V.current.state?.cwd??``,getWorkspaceRoots:()=>V.current.state?.workspaceRoots??[],listSessions:()=>{let e=V.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:()=>V.current.state?.conversationId??null,isConversationBlank:()=>(V.current.state?.messages.length??0)===0,listModels:()=>V.current.models.map(e=>({id:e.id,provider:e.provider,name:e.name,vision:e.vision,reasoning:e.reasoning})),getCurrentModelId:()=>{let e=V.current.state?.model;return e?`${e.provider}/${e.id}`:null},listProjects:()=>V.current.projects.map(e=>e.path),grantedPaths:Vg,grantPath:Hg,confirm:e=>new Promise(t=>we({path:e.path,resolve:t})),openModal:e=>{let t=String(e??``).trim();if(!t)return!1;let n=ie.current[`modal.dialog`].find(e=>e.id===t);return!n||n.hidden?!1:(ne(t),!0)},closeModal:()=>ne(null),dialogConfirm:e=>new Promise(t=>{if(Ee.current){t(!1);return}let n={kind:`confirm`,title:e.title,resolve:t};Ee.current=n,J(n)}),select:e=>new Promise(t=>{if(Ee.current){t({ok:!1,error:`busy`});return}let n={kind:`select`,title:e.title,options:e.options,...e.multi?{multi:!0}:{},resolve:t};Ee.current=n,Y([]),J(n)}),input:e=>new Promise(t=>{if(Ee.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};Ee.current=n,ke(e.initial??``),J(n)}),notifyAction:e=>new Promise(t=>{try{let n=Me.current;Me.current=null,je(null);try{n?.resolve(null)}catch{}let r={text:e.text,actions:e.actions,resolve:t};Me.current=r,je(r)}catch{t(null)}}),loadPluginBundle:e=>{let t=V.current.plugins.find(t=>t.id===e);return t?ko(t,V.current.pluginsEpoch):Promise.resolve(!1)}})),()=>xa(null)),[r]);let[H,U]=(0,f.useState)(()=>Fg(`left`)),[ae,oe]=(0,f.useState)(()=>Fg(`right`)),se=(0,f.useCallback)(e=>U(e),[]),ce=(0,f.useCallback)(e=>oe(e),[]),[le,ue]=(0,f.useState)(()=>Lg(`left`)),[de,fe]=(0,f.useState)(()=>Lg(`right`)),pe=(0,f.useCallback)(()=>{ue(e=>(localStorage.setItem(Ig(`left`),e?`0`:`1`),!e))},[]),W=(0,f.useCallback)(()=>{fe(e=>(localStorage.setItem(Ig(`right`),e?`0`:`1`),!e))},[]),[me,G]=(0,f.useState)(null),[he,ge]=(0,f.useState)(()=>window.matchMedia(`(max-width: 768px)`).matches);(0,f.useEffect)(()=>{let e=window.matchMedia(`(max-width: 768px)`),t=e=>ge(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let[_e,ve]=(0,f.useState)(!1),[ye,K]=(0,f.useState)(!1),[be,xe]=(0,f.useState)(!1),[Se,Ce]=(0,f.useState)(),[q,we]=(0,f.useState)(null),[Te,J]=(0,f.useState)(null),Ee=(0,f.useRef)(null),[De,Y]=(0,f.useState)([]),[Oe,ke]=(0,f.useState)(``),[Ae,je]=(0,f.useState)(null),Me=(0,f.useRef)(null),[Ne,Pe]=(0,f.useState)(()=>new Set),Fe=(e,t)=>{r({type:`plugin_path_response`,id:e,ok:t}),Pe(t=>new Set(t).add(e))},Ie=n.pathRequests.find(e=>!Ne.has(e.id))??null,[Le,Re]=(0,f.useState)(()=>new Set),ze=(e,t,n=!1)=>{r({type:`plugin_permission_response`,id:e,ok:t,...n?{remember:!0}:{}}),Re(t=>new Set(t).add(e))},Be=n.permRequests.find(e=>!Le.has(e.id))??null,Ve=qm(),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(!1),[Ke,qe]=(0,f.useState)(null);(0,f.useEffect)(()=>{if(!Ke)return;let e=setTimeout(()=>qe(null),15e3);return()=>clearTimeout(e)},[Ke]),(0,f.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=ot();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})}y(`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,f.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`k`&&(e.preventDefault(),Ge(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let[Je,Ye]=(0,f.useState)(xg),{themes:Xe,theme:Ze,switchTheme:Qe,reloadThemes:$e}=Fc();Ch(),(0,f.useEffect)(()=>{try{typeof $a==`function`&&$a(Ze??``)}catch{}},[Ze]),(0,f.useEffect)(()=>{try{typeof eo==`function`&&eo(t)}catch{}},[t]),(0,f.useEffect)(()=>{try{typeof to==`function`&&to(b)}catch{}},[b]),(0,f.useEffect)(()=>{try{let e=n.state?.model,t=e?`${e.provider}/${e.id}`:null;typeof Ya==`function`&&Ya(t)}catch{}},[n.state?.model?.provider,n.state?.model?.id]),(0,f.useEffect)(()=>{if(!Te)return;let e=e=>{if(e.key!==`Escape`)return;let t=Ee.current;Ee.current=null,J(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)},[Te]),(0,f.useEffect)(()=>{if(!Ae)return;let e=setTimeout(()=>{let e=Me.current;Me.current=null,je(null);try{e?.resolve(null)}catch{}},8e3);return()=>clearTimeout(e)},[Ae]);let et=(0,f.useRef)(null),tt=(0,f.useRef)(null),nt=(0,f.useRef)(null),rt=(0,f.useRef)(null),it=(0,f.useRef)(new Set),at=(0,f.useRef)(0),st=(0,f.useRef)(!1),ct=(0,f.useRef)(n.terminals);(0,f.useEffect)(()=>{Sg(Je)},[Je]),(0,f.useEffect)(()=>{let e=ct.current;ct.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,f.useEffect)(()=>{let t=n.state?.isStreaming??!1,r=et.current;et.current=t,r!==null&&(!r&&t?Dg(`start`,Je):r&&!t&&(Dg(`done`,Je),Xn(e(`notifyDoneTitle`),e(`notifyDoneBody`))))},[n.state?.isStreaming,Je]),(0,f.useEffect)(()=>{let t=n.dialog?.id??null;t!==null&&t!==tt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),tt.current=t},[n.dialog,Je]),(0,f.useEffect)(()=>{let t=n.question?.id??null,r=n.remoteQuestion?`${n.remoteQuestion.owner}:${n.remoteQuestion.id}`:null;t!==null&&t!==nt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),r!==null&&r!==rt.current&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),nt.current=t,rt.current=r;let i=new Set(n.conversations.filter(e=>e.hasQuestion).map(e=>e.id));[...i].some(e=>!it.current.has(e))&&t===null&&(Dg(`question`,Je),Xn(e(`notifyQuestionTitle`),e(`notifyQuestionBody`))),it.current=i},[n.question,n.remoteQuestion,n.conversations,Je]),(0,f.useEffect)(()=>{let t=[...n.notices].reverse().find(e=>e.level===`error`);t&&t.id!==at.current&&(at.current=t.id,Dg(`error`,Je),Xn(e(`notifyErrorTitle`),e(`notifyErrorBody`)))},[n.notices,Je]);let lt=(0,f.useRef)(new Set);(0,f.useEffect)(()=>{let e=n.state?.messages??[];for(let t of e){if(t.toolName!==`live_preview`||lt.current.has(t.id))continue;lt.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{document.hasFocus()&&(n=window.open(St(e),`_blank`,`noopener`))}catch{n=null}n||a(`info`,e)}},[n.state?.messages,a]);let ut=(e,t,n,r=!1,i)=>{let a=`${e}|${n}|${i?`${i.start}-${i.end}`:``}`;d(o=>o.some(e=>`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:``}`===a)?o:[...o,{path:e,name:t,mode:n,isDir:r,...i?{lines:i}:{}}])},dt=e=>d(t=>t.filter(t=>t.key?t.key!==e:t.mode===`conversation`?`conv|${t.conversationId??``}|${t.sessionPath??``}`!==e:t.path!==e)),ft=(0,f.useCallback)(e=>(!e.type.startsWith(`list_`)&&!e.type.startsWith(`get_`)&&G(null),(e.type===`new_chat`||e.type===`switch_conversation`||e.type===`switch_session`)&&y(e=>e===`chat`?e:`chat`),r(e)),[r]),pt=(0,f.useRef)(new Set),mt=n.activeConversationId||n.state?.conversationId||``;(0,f.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 pt.current)i.has(e)||pt.current.delete(e);for(let n of t){let t=`question-${n.id}`;if(n.id===mt){fm(t);continue}n.questionId&&pt.current.has(n.questionId)||dm({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&&pt.current.add(n.questionId)},onClick:()=>{ft({type:`switch_conversation`,id:n.id}),fm(t),n.questionId&&pt.current.add(n.questionId)}})}pm(e=>{let t=e.data?.conversationId;return t?!r.has(t)||t===mt:!1})},[n.conversations,mt,ft,e]);let ht=(0,f.useRef)(0),gt=(0,f.useRef)(0),_t=t=>{let r=Date.now();n.state?.model&&!n.state.model.vision&&r-gt.current>1e4&&(gt.current=r,a(`warning`,e(`imageNotSupported`)));let i=`paste-${++ht.current}`;d(e=>[...e,{path:``,key:i,name:t.name,mode:`inline`,imageData:t.data,mimeType:t.mimeType}])},vt=async t=>{for(let n of t){let t=await mu(n);if(!t){a(`error`,e(`imageLoadFailed`,{name:n.name}));continue}_t(t)}},yt=20971520,bt=(0,f.useRef)(0),xt=async t=>{if(t.size>yt){a(`warning`,e(`fileTooLarge`,{name:t.name,size:yt/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-${++bt.current}`;d(e=>[...e,{path:``,key:r,name:t.name,mode:`inline`,fileData:n,size:t.size,mimeType:t.type||void 0}])},Ct=async e=>{for(let t of e)pu(t.type)?await vt([t]):await xt(t)},wt=(0,f.useCallback)((e,t,n)=>{r({type:`edit_message`,messageId:e,text:t,attachments:n})},[r]),Tt=(0,f.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n})},[r]),[Et,Dt]=(0,f.useState)([]),Ot=(0,f.useRef)(0),kt=(0,f.useCallback)((e,t,n)=>{r({type:`queue_remove`,kind:e,text:t,index:n}),Ot.current+=1;let i={text:t,seq:Ot.current};Dt(e=>[...e.slice(-9),i])},[r]),At=(0,f.useCallback)(()=>K(!0),[]),jt=(0,f.useCallback)(()=>d([]),[]),Mt=(0,f.useCallback)(dt,[]),Nt=(0,f.useCallback)(vt,[vt]),Pt=(0,f.useCallback)(Ct,[Ct]),Ft=(0,f.useCallback)((e,t)=>r({type:`search_files`,reqId:e,query:t}),[r]),It=(0,f.useCallback)(e=>ut(e.path,e.name,e.mode??`reference`,e.isDir??!1,e.lines),[]),Lt=n.state?.model,Rt=n.state?.thinkingLevel,zt=n.state?.availableThinkingLevels,Bt=(0,f.useMemo)(()=>Lt?{model:Lt,thinkingLevel:Rt??`off`,availableThinkingLevels:zt??[]}:null,[Lt,Rt,zt]),Vt=(0,f.useCallback)(()=>!n.ready||n.terminals.length!==0?!1:(o.create({id:ot(),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,f.useEffect)(()=>{if(st.current){if(b!==`terminal`||n.terminals.length!==0){st.current=!1;return}Vt()&&(st.current=!1)}},[n.terminals.length,Vt,b]),(0,X.jsxs)(`div`,{className:`app`,"data-pi-anchor":`app`,onDragOver:e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),_(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||_(!1)},onDrop:t=>{if(_(!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=>pu(e.type)),i=n.filter(e=>!pu(e.type));r.length>0&&vt(r),i.length>0&&Ct(i)},children:[g&&(0,X.jsx)(`div`,{className:`app-drop-overlay`,"aria-hidden":!0,children:(0,X.jsxs)(`span`,{children:[`📎 `,e(`dropHereToAttach`)]})}),(0,X.jsx)(Ui,{chat:n,terminal:o,view:b,plugins:x,uiPrimary:C,uiOverflow:w,uiContextTopbar:S[`contextmenu.topbar`],onUiAction:F,onViewChange:e=>{st.current=e===`terminal`&&n.terminals.length===0,st.current&&Vt()&&(st.current=!1),y(e),G(null)},onOpenPanel:G,onOpenSettings:()=>{Ce(void 0),xe(!0)},onManagePlugins:()=>{Ce(`plugins`),xe(!0)},onOpenBgTasks:()=>Ue(!0),onOpenGlobalSearch:()=>Ge(!0),sound:Je,onSoundChange:Ye,onSoundPreview:e=>Dg(e,Je),themes:Xe,theme:Ze,onThemeChange:Qe,reloadThemes:$e}),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)(kg,{notice:e,onDismiss:i},e.id)),Ae&&(0,X.jsxs)(`div`,{className:`notice notice-info`,role:`status`,children:[(0,X.jsx)(`span`,{className:`notice-text`,children:Ae.text}),Ae.actions.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let t=Me.current;Me.current=null,je(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=Me.current;Me.current=null,je(null);try{e?.resolve(null)}catch{}},children:(0,X.jsx)(M,{})})]}),P.length>0&&(0,X.jsx)(`div`,{className:`notice-actions`,role:`toolbar`,children:P.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=>F(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:()=>F(e),children:[e.icon?`${e.icon} `:``,e.badge??e.label]},e.id))})]}),(0,X.jsx)(Rd,{currentModelId:Lt?`${Lt.provider}/${Lt.id}`:null,children:(0,X.jsxs)(`div`,{className:`layout`,style:{"--left-w":`${H}px`,"--right-w":`${ae}px`},children:[me&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:()=>G(null)}),(0,X.jsxs)(`div`,{className:`view-pane ${b===`chat`?``:`hidden`}`,children:[!he&&le&&(0,X.jsx)(zg,{side:`left`,onClick:pe}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-left ${me===`left`?`open`:``}${he?``:le?` hidden`:``}`,children:(0,X.jsx)(ia,{collapsible:!he,onToggleCollapse:pe,panelSend:ft,active:!he||me===`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:S[`contextmenu.session`],uiLeftSessions:T,onUiAction:F,presetNames:N})}),!he&&(0,X.jsx)(Rg,{side:`left`,width:H,onResize:se}),(0,X.jsxs)(`main`,{className:Ve?`main wide-chat`:`main`,children:[k.length>0&&(0,X.jsx)(`div`,{className:`chat-header`,role:`toolbar`,children:Ud(k,F)}),n.state?(0,X.jsx)(Of,{uiMessageActions:S[`message.actions`],uiContextMessage:S[`contextmenu.message`],uiContextToolCall:S[`contextmenu.toolcall`],uiChatEmpty:A,onUiAction:F,state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:wt,onKillBash:()=>r({type:`abort_bash`}),onRetry:()=>{if(r({type:`retry_last`})){let e=n.state?.model;e&&Ad(`${e.provider}/${e.id}`)}},onRemoveQueued:Tt,onRecallQueued:kt,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,toolImages:n.settings?.toolImagesEnabled??!0,jumpTarget:Ke,onJumpDone:()=>qe(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)(Ep,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,uiGoalbarActions:O,onUiAction:F}),(0,X.jsx)(im,{onAction:(e,t,n)=>F(e,n,t)}),n.dialog&&(0,X.jsx)(Rp,{dialog:n.dialog}),Te&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"data-dialog-kind":Te.kind,children:[(0,X.jsxs)(`div`,{className:`dialog-head`,children:[(0,X.jsx)(`span`,{className:`dialog-badge`,children:e(`pluginRequest`)}),Te.title&&(0,X.jsx)(`span`,{className:`dialog-title`,children:Te.title}),(0,X.jsx)(`button`,{type:`button`,className:`dialog-dismiss`,title:e(`cancel`),onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.kind===`confirm`?e.resolve(!1):e?.resolve({ok:!1})}catch{}},children:`✕`})]}),Te.kind===`select`&&(0,X.jsxs)(`div`,{className:`dialog-options`,children:[(Te.options??[]).map((e,t)=>{let n=Te.multi?De.includes(t):!1;return(0,X.jsxs)(`button`,{type:`button`,className:`dialog-option ${n?`sel`:``}`,title:e.description,onClick:()=>{if(Te.multi){Y(e=>e.includes(t)?e.filter(e=>e!==t):[...e,t]);return}let n=Ee.current;Ee.current=null,J(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)}),(Te.options??[]).length===0&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:e(`noOptions`)}),Te.multi&&(0,X.jsx)(`div`,{className:`dialog-actions`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current,t=(e?.options??[]).filter((e,t)=>De.includes(t)).map(e=>e.label);Ee.current=null,J(null);try{e?.resolve({ok:!0,selected:t})}catch{}},children:e(`ok`)})})]}),Te.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=Ee.current;Ee.current=null,J(null);try{e?.resolve(!1)}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve(!0)}catch{}},children:e(`ok`)})]})}),Te.kind===`input`&&(0,X.jsxs)(`div`,{className:`dialog-body`,children:[(0,X.jsx)(`input`,{className:`dialog-input`,value:Oe,placeholder:Te.placeholder||e(`inputPlaceholder`),autoFocus:!0,onChange:e=>ke(e.target.value),onKeyDown:e=>{if(e.key===`Enter`&&!e.nativeEvent.isComposing){let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!0,value:Oe})}catch{}}}}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!1})}catch{}},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{let e=Ee.current;Ee.current=null,J(null);try{e?.resolve({ok:!0,value:Oe})}catch{}},children:e(`ok`)})]})]})]}),Be&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>ze(Be.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[Be.family===`net`?e(`pluginPermBodyNet`).replace(`{plugin}`,Be.pluginId).replace(`{hosts}`,(Be.hosts??[]).join(`, `)):e(`pluginPermBodyLlm`).replace(`{plugin}`,Be.pluginId).replace(`{models}`,(Be.models??[]).length>0?` ${(Be.models??[]).join(`, `)}`:``),Be.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Be.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ze(Be.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>ze(Be.id,!0),children:e(`pluginPermOnce`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>ze(Be.id,!0,!0),children:e(`pluginPermAlways`)})]})]})]}),Ie&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>Fe(Ie.id,!1),children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginGrantRequestBody`).replace(`{plugin}`,Ie.pluginId).replace(`{path}`,Ie.path),Ie.reason&&(0,X.jsx)(`div`,{className:`dialog-hint`,children:Ie.reason}),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>Fe(Ie.id,!1),children:e(`pluginGrantDeny`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>Fe(Ie.id,!0),children:e(`pluginGrantAllow`)})]})]})]}),q&&(0,X.jsxs)(`div`,{className:`dialog-inline`,"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:()=>{q.resolve(!1),we(null)},children:`✕`})]}),(0,X.jsxs)(`div`,{className:`dialog-body`,children:[e(`pluginSessionGrantBody`).replace(`{path}`,q.path),(0,X.jsxs)(`div`,{className:`dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{q.resolve(!1),we(null)},children:e(`cancel`)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:()=>{q.resolve(!0),we(null)},children:e(`ok`)})]})]})]}),n.question&&(0,X.jsx)(Vp,{question:n.question,conversationTitle:n.question.conversationTitle||n.conversations.find(e=>e.id===(n.question?.conversationId||mt))?.title}),n.remoteQuestion&&(0,X.jsx)(Vp,{question:n.remoteQuestion,owner:n.remoteQuestion.owner,conversationTitle:n.remoteQuestion.conversationTitle||n.conversations.find(e=>e.id===n.remoteQuestion?.convId)?.title}),(0,X.jsx)(Tp,{composerLeading:S[`composer.leading`],composerActions:S[`composer.actions`],onUiAction:F,streaming:n.state?.isStreaming??!1,messages:n.state?.messages??Ag,slashCommands:n.slashCommands,modelState:Bt,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,defaultModel:n.engine===`pi`?n.defaultModel:void 0,attachments:u,onRemoveAttachment:Mt,onAddImageFiles:Nt,onAddLocalFiles:Pt,onAddPathAttachment:It,fileSearch:n.fileSearch,onSearchFiles:Ft,onNotice:a,onManageModels:At,onSent:jt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:Et,dshPermCurrent:n.engine===`dsh`?n.state?.permission??null:void 0,dshPermOptions:n.engine===`dsh`?n.dshPermission?.options??void 0:void 0,dshPermDefault:n.engine===`dsh`?n.dshPermission?.defaultPreset:void 0,dshPreset:n.engine===`dsh`?n.state?.agentPreset??null:void 0,dshPresets:n.engine===`dsh`?n.dshPresets?.presets??void 0:void 0,dshPresetDefault:n.engine===`dsh`?n.dshPresets?.defaultPreset:void 0,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??``})]}),!he&&(0,X.jsx)(Rg,{side:`right`,width:ae,onResize:ce}),(0,X.jsx)(`div`,{className:`panel-drawer drawer-right ${me===`right`?`open`:``}${he?``:de?` hidden`:``}`,children:(0,X.jsx)(Zs,{collapsible:!he,onToggleCollapse:W,panelSend:ft,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(e,t,n,r)=>{G(null),ut(e,t,n,r)},onPreview:(e,t)=>{G(null),m({path:e,name:t})},onNotice:(e,t)=>a(e,t),uiRightPanelTabs:S[`rightpanel.tabs`],uiContextFile:S[`contextmenu.file`],plugins:x,pluginsEpoch:n.pluginsEpoch,send:r})}),!he&&de&&(0,X.jsx)(zg,{side:`right`,onClick:W})]}),(0,X.jsx)(`div`,{className:`view-pane ${b===`terminal`?``:`hidden`}`,children:(0,X.jsx)(f.Suspense,{fallback:null,children:(0,X.jsx)(Og,{chat:n,terminal:o,uiTerminalToolbar:E,onUiAction:F})})}),(0,X.jsx)(`div`,{className:`view-pane ${b===`git`?``:`hidden`}`,children:(0,X.jsx)(tm,{chat:n,terminal:o,active:b===`git`,onSwitchToTerminal:()=>y(`terminal`),uiScmToolbar:D,onUiAction:F})}),I.map(e=>{let t=`plugin:${e.info.id}`;return(0,X.jsx)(`div`,{className:`view-pane ${b===t?``:`hidden`}`,children:(0,X.jsx)(nm,{entry:e})},e.info.id)}),b.startsWith(`plugin:`)&&!I.some(e=>`plugin:${e.info.id}`===b)&&(0,X.jsx)(rm,{pluginId:b.slice(7),info:n.plugins.find(e=>`plugin:${e.id}`===b),epoch:n.pluginsEpoch,failed:R.includes(b.slice(7))})]})}),(0,X.jsx)(Fp,{chat:n,bottombarItems:S.bottombar,onUiAction:F}),p&&(0,X.jsx)(hg,{file:p,content:n.fileContent,onAddLines:(e,t,n,r)=>ut(e,t,`lines`,!1,{start:n,end:r}),onAttach:(e,t,n)=>ut(e,t,n),onClose:()=>m(null),uiFilePreviewToolbar:j,onUiAction:F}),n.ready&&n.state&&n.state.piConfigured===!1&&!_e&&!ye&&(0,X.jsx)(xm,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,installResult:n.installResult,onClose:()=>ve(!0)}),ye&&(0,X.jsx)(Dm,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,providerOAuthFlows:n.providerOAuthFlows,providerOAuthResults:n.providerOAuthResults,fetchModelsResult:n.fetchModelsResult,enrichModelsResult:n.enrichModelsResult,enrichModelsProgress:n.enrichModelsProgress,refreshBuiltinResult:n.refreshBuiltinResult,appendBuiltinResult:n.appendBuiltinResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>K(!1)}),be&&(0,X.jsx)(Wh,{chat:n,terminal:o,initialSection:Se,onSwitchToTerminal:()=>y(`terminal`),onClose:()=>xe(!1)}),He&&(0,X.jsx)(Zh,{servers:n.bgServers,onClose:()=>Ue(!1)}),(0,X.jsx)(sg,{}),z&&(0,X.jsx)(pg,{entry:z,pluginView:B?I.find(e=>e.info.id===B):void 0,onUiAction:(e,t)=>{F(e,t),ne(null)},onClose:()=>ne(null)}),(0,X.jsx)(fg,{open:We,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>Ge(!1),onSwitchSession:(e,t)=>{r({type:`switch_session`,path:e});let n=t&&t[0];qe(n?{path:e,role:n.role,timestamp:n.timestamp}:null)},onSwitchProject:e=>{r({type:`set_cwd`,path:e})},onPreviewFile:(e,t)=>{m({path:e,name:t})}}),(0,X.jsx)(ym,{})]})}function Wg(){typeof document<`u`&&(Gg(Kg()),Jg())}function Gg(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty(`--msgs-gutter`,`${Math.round(e*100)/100}px`)}function Kg(){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 qg(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 Jg(){let e=()=>{let e=document.querySelector(`.messages`);return e?(Gg(qg(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)}wt(),Nc(jc()),Wg(),(0,O.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(f.StrictMode,{children:(0,X.jsx)(Ht,{children:(0,X.jsx)(Ug,{})})})),`serviceWorker`in navigator&&window.addEventListener(`load`,()=>{let e=bt();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(e=>{console.warn(`Service worker registration failed:`,e)})});export{$ as a,ot as c,ce as d,se as f,M as g,L as h,Ic as i,Ne as l,ee as m,Ud as n,Ut as o,oe as p,Ac as r,Z as s,Gd as t,G as u};
|