pi-web-ui 0.80.2 → 0.83.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 +167 -2
- package/README.md +112 -97
- package/README.zh-CN.md +86 -66
- package/dist/server/agent-service.js +385 -13
- package/dist/server/attachments.js +36 -0
- package/dist/server/index.js +5 -0
- package/dist/server/mcp-bridge.js +132 -23
- package/dist/server/plugins.js +23 -2
- package/dist/server/subagent-templates.js +30 -2
- package/dist/server/subagents.js +25 -15
- package/dist/server/tool-manager.js +7 -1
- package/dist/server/webui-context.js +28 -4
- package/package.json +4 -2
- package/plugins/catalog.json +9 -0
- package/themes/cyberpunk.css +1 -0
- package/themes/dazzle.css +1 -0
- package/themes/md-preview.css +1 -0
- package/themes/mist.css +1 -0
- package/themes/paper.css +1 -0
- package/themes/sakura.css +1 -0
- package/themes/white.css +1 -0
- package/web/dist/assets/{TerminalPanel-CeruoZjh.js → TerminalPanel-BF99sld0.js} +1 -1
- package/web/dist/assets/index-B1XPfcM0.css +10 -0
- package/web/dist/assets/index-D__1RagK.js +348 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BduNm7_u.css +0 -10
- package/web/dist/assets/index-DtBJSe33.js +0 -347
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-BF99sld0.js","assets/markdown-D3PKeHAZ.js","assets/xterm-B96xOxS9.js","assets/react-w24rH0km.js","assets/TerminalPanel-DOrYoP_4.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{R as Kt,a as c,j as s,f as Kl,s as jn,h as La,w as Wt,b as Yl,c as Gl,d as Nr,o as aa,z as kr,e as Vl,g as zl,p as Vt,v as Ql,i as vr,k as Ga,M as Xl,l as Jl,m as Zl,n as Cr,q as _r}from"./markdown-D3PKeHAZ.js";import{r as wr}from"./react-w24rH0km.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(a){if(a.ep)return;a.ep=!0;const o=n(a);fetch(a.href,o)}})();var Ws={},Va;function ec(){if(Va)return Ws;Va=1;var e=wr();return Ws.createRoot=e.createRoot,Ws.hydrateRoot=e.hydrateRoot,Ws}var tc=ec();const sc="modulepreload",nc=function(e){return"/"+e},za={},ac=function(t,n,i){let a=Promise.resolve();if(n&&n.length>0){let l=function(E){return Promise.all(E.map(m=>Promise.resolve(m).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),p=u?.nonce||u?.getAttribute("nonce");a=l(n.map(E=>{if(E=nc(E),E in za)return;za[E]=!0;const m=E.endsWith(".css"),f=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${E}"]${f}`))return;const w=document.createElement("link");if(w.rel=m?"stylesheet":sc,m||(w.as="script"),w.crossOrigin="",w.href=E,p&&w.setAttribute("nonce",p),document.head.appendChild(w),m)return new Promise((N,C)=>{w.addEventListener("load",N),w.addEventListener("error",()=>C(new Error(`Unable to preload CSS for ${E}`)))})}))}function o(l){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=l,window.dispatchEvent(u),!u.defaultPrevented)throw l}return a.then(l=>{for(const u of l||[])u.status==="rejected"&&o(u.reason);return t().catch(o)})};var Sr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Qa=Kt.createContext&&Kt.createContext(Sr),ic=["attr","size","title"];function rc(e,t){if(e==null)return{};var n,i,a=oc(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}function oc(e,t){if(e==null)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;n[i]=e[i]}return n}function ln(){return ln=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ln.apply(null,arguments)}function Xa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,i)}return n}function cn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Xa(Object(n),!0).forEach(function(i){lc(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xa(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function lc(e,t,n){return(t=cc(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cc(e){var t=uc(e,"string");return typeof t=="symbol"?t:t+""}function uc(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ar(e){return e&&e.map((t,n)=>Kt.createElement(t.tag,cn({key:n},t.attr),Ar(t.child)))}function ge(e){return t=>Kt.createElement(dc,ln({attr:cn({},e.attr)},t),Ar(e.child))}function dc(e){var t=n=>{var i=e.attr,a=e.size,o=e.title,l=rc(e,ic),u=a||n.size||"1em",p;return n.className&&(p=n.className),e.className&&(p=(p?p+" ":"")+e.className),Kt.createElement("svg",ln({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,i,l,{className:p,style:cn(cn({color:e.color||n.color},n.style),e.style),height:u,width:u,xmlns:"http://www.w3.org/2000/svg"}),o&&Kt.createElement("title",null,o),e.children)};return Qa!==void 0?Kt.createElement(Qa.Consumer,null,n=>t(n)):t(Sr)}function pc(e){return ge({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 mc(e){return ge({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 zs(e){return ge({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 Ke(e){return ge({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 Ir(e){return ge({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 Ja(e){return ge({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 jr(e){return ge({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 hc(e){return ge({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 et(e){return ge({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 Za(e){return ge({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 Ln(e){return ge({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 ei(e){return ge({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 fc(e){return ge({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 un(e){return ge({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 gc(e){return ge({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 dn(e){return ge({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 ia(e){return ge({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 pn(e){return ge({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 bc(e){return ge({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 Lr(e){return ge({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 kt(e){return ge({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 dt(e){return ge({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 yg(e){return ge({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 Ec(e){return ge({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 Un(e){return ge({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 Tc(e){return ge({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"19",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"5",cy:"12",r:"1"},child:[]}]})(e)}function ra(e){return ge({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 xc(e){return ge({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 yc(e){return ge({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 rs(e){return ge({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 Nc(e){return ge({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 kc(e){return ge({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 vc(e){return ge({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 Cc(e){return ge({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 _c(e){return ge({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 wc(e){return ge({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 oa(e){return ge({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 mn(e){return ge({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 Sc(e){return ge({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 Ac(e){return ge({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 ti(e){return ge({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 Ic(e){return ge({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 Rr(e){return ge({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 si(e){return ge({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 Qs(e){return ge({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 Bt(e){return ge({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 jc(e){return ge({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 Dr(e){return ge({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 hn(e){return ge({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 fn(e){return ge({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 gn(e){return ge({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 Yt(e){return ge({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 Ds(e){return ge({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 Lc(e){return ge({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 wt(e){return ge({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 ni(e){return ge({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 la(e){return ge({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 ai(e){return ge({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 Pr(e){return ge({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 Or(e){return ge({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 Rn(e){return ge({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 zt(e){return ge({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 Ft(e){return ge({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 Tt(e){return ge({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 cs(e){return ge({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 $n(e){return ge({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 Rc(e){return ge({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 Dc(e){return ge({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 ca(e){return ge({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 Pc(e){return ge({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 Mr(e){return ge({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 Br(e){return ge({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 Oc(e){return ge({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 Mc(e){return ge({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 Bc(e){return e.map(t=>t.kind==="package"?`pi update npm:${t.name}`:`npm i -g ${t.name}@latest`).join("; ")}function St(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=new Uint8Array(16);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(e);else for(let n=0;n<16;n++)e[n]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(n=>n.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 Pt({trigger:e,open:t,onOpenChange:n,children:i,align:a="right",fit:o=!1,direction:l="down",menuClassName:u,menuRef:p,menuStyle:E}){const m=c.useRef(null);return c.useEffect(()=>{if(!t)return;const f=N=>{m.current&&!m.current.contains(N.target)&&n(!1)},w=N=>{N.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",f),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",w)}},[t,n]),s.jsxs("div",{className:`dropdown ${a} ${o?"fit":""} ${l==="up"?"dd-up":""}`,ref:m,children:[s.jsxs("button",{type:"button",className:"chip",onClick:()=>n(!t),"aria-expanded":t,children:[e,s.jsx(Ft,{className:`dd-caret ${t?"up":""}`})]}),t&&s.jsx("div",{className:`dd-menu ${u??""}`,ref:p,style:E,children:i})]})}function it({active:e,disabled:t=!1,title:n,onClick:i,children:a}){return s.jsx("button",{type:"button",className:`dd-item ${e?"active":""}`,disabled:t,title:n,onClick:i,children:a})}let qn=null;function Fc(e){if(e===void 0){const n=globalThis.document;if(n&&typeof n.baseURI=="string"&&n.baseURI)try{e=new URL(n.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 Fr(){return qn===null&&(qn=Fc()),qn}function Hc(e,t){return t==="/"?e:t+e.replace(/^\/+/,"")}function tt(e){return Hc(e,Fr())}const Hr="pi-web-ui:token";function Uc(){try{const e=new URL(window.location.href),t=e.searchParams.get("token");t&&(localStorage.setItem(Hr,t.trim()),e.searchParams.delete("token"),window.history.replaceState(null,"",e.toString()))}catch{}}function $c(){try{return localStorage.getItem(Hr)??""}catch{return""}}function vt(e){const t=$c();return t?`${e}${e.includes("?")?"&":"?"}token=${encodeURIComponent(t)}`:e}const qc=["zh","en","de","es","fr","it","ja","ko","pt","ru"];function ua(e,t,n,i=qc){const a=(e??"").trim();if(a)return a;for(const l of t??[]){const u=String(l??"").trim().toLowerCase().replace(/_/g,"-");if(!u)continue;if(i.includes(u))return u;const p=u.split("-")[0];if(p&&i.includes(p))return p}const o=(n??"").trim().toLowerCase();return o&&i.includes(o)?o:"en"}const da="pi-web-ui:lang",Wc={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:"管理模型",thinkingLevel:"思考强度",thinking:"思考",thinkingChip:"思考:{level}",sound:"声音",theme:"主题",themeDefault:"深色(默认)",newChat:"新对话",more:"更多",newChatTip:"新建对话(每个浏览器独立保存会话)","thinking.off":"关闭","thinking.minimal":"极简","thinking.low":"低","thinking.medium":"中","thinking.high":"高","thinking.xhigh":"极高","thinking.max":"最大",thinkingUnsupported:"当前模型不支持该级别,已按模型能力就近生效",context:"上下文",contextUsage:"上下文用量",cumulativeCost:"累计成本",sessionMessages:"会话消息数",messages:"消息",pluginStatus:"插件状态",engineBadge:"引擎",working:"工作中",queued:"排队",enterPath:"输入路径,Enter 切换",cwdTip:"工作目录:{path}(点击切换)",cwdGoUp:"上级目录",cwdPickCurrent:"选择当前目录",cwdChoose:"选择",cwdEnter:"进入",cwdEmpty:"(空目录)",cwdNewFolder:"新建文件夹",cwdNewName:"文件夹名称",cwdCreate:"创建",cwdCancel:"取消",cacheHit:"缓存命中",cacheHitTip:"缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)",tps:"t/s",rateTip:"实时生成速率(估算)",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)",quickPhrases:"快捷短语",quickPhrasesDesc:"输入框上方的一排常用短语按钮,点击即发送(会带上当前已选的文件附件,不清空输入框草稿)",quickPhrasesEnabled:"启用快捷短语",quickPhrasesOffHint:"已关闭:输入框上方不再显示快捷短语按钮(已配置的短语保留,可随时重新启用)",quickPhrasesPlaceholder:"输入常用短语…(Enter 添加)",quickPhrasesAdd:"添加",quickPhrasesEmpty:"还没有快捷短语,在下面添加第一条",quickPhrasesTip:"点击发送:{text}",quickPhrasesMoveUp:"上移",quickPhrasesMoveDown:"下移",quickPhrasesDelete:"删除该短语",quickPhrasesEdit:"编辑该短语",quickPhrasesEditPh:"修改短语…(Enter 保存,Esc 取消)",quickPhrasesReset:"恢复默认短语",slashCommands:"命令",slashMenuHint:"↑↓ 选择 · Enter/Tab 补全",slashHelpTitle:"pi 命令",slashHelpHint:"输入 / 随时打开命令列表",slashLoading:"命令列表加载中…(连接服务器后可用)",slashBuiltin:"内置",slashExtension:"扩展",slashPrompt:"模板",slashSkill:"技能",slashPlugin:"插件",slashCopied:"已复制上一条助手回复",slashCopyFailed:"复制失败,请手动复制",slashCopyEmpty:"还没有可复制的助手回复",recentProjects:"最近项目",runningConversations:"运行的对话",subagentBadge:"子代理",convErrorBadge:"子代理运行报错:{error}",subagentTitle:"子代理 · {title}",historySessions:"历史对话",openHistory:"历史对话",openFiles:"文件列表",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:"强行关闭对话(含全部子代理)",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)。",updatesAllTitle:"全部组件更新",updatesAllBadge:"{n} 个更新",updatesAllUpToDate:"全部组件均为最新",kindWebUi:"Web 界面",kindPiCore:"核心",kindPackage:"组件",updatesAllRefresh:"重新检查全部",updateCheckFailed:"检查失败",updateBtn:"更新",updateAllBtn:"全部更新",updatePkgTabTitle:"更新 {name}",updateAllTabTitle:"更新全部组件",restartService:"重启服务",restartingService:"重启中…",restartServiceTip:"重启 pi-web-ui 服务({name}):本实例由系统服务托管(launchd/systemd/Windows watchdog),进程退出后会被自动拉起,本页会自动重连;更新完成后用它生效",computer:"此电脑",rootDir:"根目录",noFiles:"暂无文件",filesTruncated:"目录过大,列表已截断,仅显示前 2000 项",linkFolderTip:"链接文件夹路径到对话",attachInlineTip:"附加内容到对话",referenceTip:"仅引用路径(AI 按需读取)",previewFile:"预览",downloadFile:"下载文件",copyName:"复制名称",copyPath:"复制路径",downloadFailed:"下载失败:{error}",fileNotFoundShort:"文件不存在",pluginMountFailed:"插件 {name} 挂载失败",liveOutputOmitted:`…[前 {n} 字符已省略]…
|
|
3
|
+
`,uploadToFolder:"上传文件到此文件夹",uploadToCurrentDir:"上传文件到当前目录",openAsProject:"以项目打开",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 则失败即停。修改即时生效,无需重载。",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":`请先扫描这个仓库,建立「其他工作流都能用」的基础上下文,输出一份简明报告:
|
|
4
|
+
|
|
5
|
+
1. 项目类型、技术栈与目录结构
|
|
6
|
+
2. 构建 / 测试 / 运行 / 格式化的具体命令
|
|
7
|
+
3. 代码约定与命名规范
|
|
8
|
+
4. 任务 / issue 的存放位置与格式
|
|
9
|
+
5. 目前已知的坑或遗留问题
|
|
10
|
+
|
|
11
|
+
先只报告,不修改任何文件。`,"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":`请把我们在对话中已经达成的共识,整理成一份结构化的规格说明书:
|
|
12
|
+
|
|
13
|
+
1. 背景与目标
|
|
14
|
+
2. 明确的目标与非目标
|
|
15
|
+
3. 用户与使用场景
|
|
16
|
+
4. 边界条件与失败场景
|
|
17
|
+
5. 验收标准(怎样算完成)
|
|
18
|
+
6. 接口 / 数据结构概要
|
|
19
|
+
|
|
20
|
+
先输出规格让我评审,确认后再继续。`,"tpl.sk.totickets":"拆工单","tpl.sk.totickets.desc":"把规格拆成可构建的小任务","tpl.sk.totickets.prompt":`请把这份规格说明拆成一组小工单,供逐个构建:
|
|
21
|
+
|
|
22
|
+
1. 每个工单足够小、可独立验收
|
|
23
|
+
2. 标注依赖顺序(哪些必须先做)
|
|
24
|
+
3. 每个工单含:做什么、验收标准、涉及文件
|
|
25
|
+
4. 识别出可并行的工单
|
|
26
|
+
|
|
27
|
+
先输出工单列表,我确认顺序后再执行。`,"tpl.sk.implement":"规格落地","tpl.sk.implement.desc":"按规格测试优先实现","tpl.sk.implement.prompt":`请按这份规格说明实现,测试优先:
|
|
28
|
+
|
|
29
|
+
1. 先为每个工单写会失败的测试(覆盖正常、边界、错误分支)
|
|
30
|
+
2. 用最小实现让测试通过
|
|
31
|
+
3. 重构并保持测试通过
|
|
32
|
+
4. 逐工单推进,每完成一个简要汇报
|
|
33
|
+
|
|
34
|
+
最后对照验收标准逐条确认。`,"tpl.sk.codeview":"代码审查","tpl.sk.codeview.desc":"对照规格与标准审查 diff","tpl.sk.codeview.prompt":`请审查最近改动的 diff:
|
|
35
|
+
|
|
36
|
+
1. 对照规格说明,实现是否完全覆盖、有无偏差
|
|
37
|
+
2. 正确性:边界、空值、并发与时序
|
|
38
|
+
3. 安全:输入校验、注入、敏感信息
|
|
39
|
+
4. 性能与可读性:是否遵循项目约定
|
|
40
|
+
5. 测试:关键路径是否有覆盖
|
|
41
|
+
|
|
42
|
+
按严重程度分级列出问题,每条给出具体修改建议。`,"tpl.sk.wayfinder":"大任务地图","tpl.sk.wayfinder.desc":"把大工程画成决策地图","tpl.sk.wayfinder.prompt":`这是一个大型任务。请先把它画成一张「决策地图」:
|
|
43
|
+
|
|
44
|
+
1. 拆出所有需要做出的决策点及其依赖关系
|
|
45
|
+
2. 为每个决策点列出选项、权衡与你的推荐
|
|
46
|
+
3. 标注哪些可以并行推进、哪些必须串行
|
|
47
|
+
4. 输出一份路径规划,我逐项确认后再动手。`,"tpl.sk.prototype":"快速原型","tpl.sk.prototype.desc":"用一次性代码验证设计假设","tpl.sk.prototype.prompt":`请针对这个设计问题写一个最小原型来验证假设:
|
|
48
|
+
|
|
49
|
+
1. 只验证关键假设,不做完整实现
|
|
50
|
+
2. 用最简单的方式(可硬编码、可牺牲边界情况)
|
|
51
|
+
3. 运行并告诉我结论:假设成立吗?有哪些权衡?
|
|
52
|
+
4. 验证完的原型可以删除,或等确认后再正式实现。`,"tpl.sk.research":"有据调研","tpl.sk.research.desc":"读一手来源给出带引用的答案","tpl.sk.research.prompt":`请调研这个问题,优先读一手来源(官方文档 / 源码 / 规范):
|
|
53
|
+
|
|
54
|
+
1. 给出带来源链接的答案
|
|
55
|
+
2. 明确区分:事实、合理推断、仍不确定
|
|
56
|
+
3. 列出主要选项及其权衡
|
|
57
|
+
4. 避免用二手内容拼凑,找不到就直接说没找到。`,"tpl.sk.arch":"架构体检","tpl.sk.arch.desc":"找出值得重构的模块(报告)","tpl.sk.arch.prompt":`对整个代码库做一次架构体检:
|
|
58
|
+
|
|
59
|
+
1. 找出「深模块被破坏」的迹象:过长的函数与类、明显的重复、命名混乱、隐藏的耦合
|
|
60
|
+
2. 按严重程度与影响范围分级,输出一份可视化改进报告
|
|
61
|
+
3. 对每一项给出最小可行的重构方案与理由
|
|
62
|
+
4. 先报告再动手,重构前确认范围。`,"tpl.sk.debug":"系统化排错","tpl.sk.debug.desc":"从可复现的失败开始诊断","tpl.sk.debug.prompt":`请系统化诊断这个 bug:
|
|
63
|
+
|
|
64
|
+
1. 先复现,给出可复现的步骤或输入(没有就先造最小复现)
|
|
65
|
+
2. 二分或排除法缩小范围到具体模块
|
|
66
|
+
3. 提出假设,用日志 / 断言 / 最小样例验证,不凭感觉改
|
|
67
|
+
4. 定位根因后解释,再做最小修复
|
|
68
|
+
5. 补回归测试防止复发。`,"tpl.sk.merge":"解决合并冲突","tpl.sk.merge.desc":"逐个 hunk 完成合并/变基","tpl.sk.merge.prompt":`请帮我解决这个合并 / 变基冲突:
|
|
69
|
+
|
|
70
|
+
1. 逐个冲突 hunk 处理,先读懂双方各自的意图
|
|
71
|
+
2. 选择或合并出保留正确语义的代码,不盲目取一边
|
|
72
|
+
3. 处理完运行测试与构建确认没问题
|
|
73
|
+
4. 最后总结每处冲突的取舍原因。`,"tpl.sk.triage":"工单分流","tpl.sk.triage.desc":"把原始 issue 整理成可领取的工作","tpl.sk.triage.prompt":`请把这些原始 issue / 反馈整理成可执行的工作项:
|
|
74
|
+
|
|
75
|
+
1. 去重、合并相关的条目
|
|
76
|
+
2. 分类(bug / 功能 / 改进 / 问题)
|
|
77
|
+
3. 按影响与紧急度标优先级
|
|
78
|
+
4. 每个工作项补上:复现信息或期望、验收标准
|
|
79
|
+
|
|
80
|
+
输出整理后的清单。`,"tpl.sk.wizard":"设置向导","tpl.sk.wizard.desc":"生成引导人类完成设置的脚本","tpl.sk.wizard.prompt":`请为一个需要手动操作的设置流程生成一个引导向导(脚本或文档):
|
|
81
|
+
|
|
82
|
+
1. 一步步引导,每步说明为什么
|
|
83
|
+
2. 每步带校验,输错给出可操作的提示
|
|
84
|
+
3. 支持撤销 / 回退到上一步
|
|
85
|
+
4. 结束时做一次自检并给出验证方法。`,"tpl.sk.grillme":"需求拷问","tpl.sk.grillme.desc":"动手前盘问对齐想法","tpl.sk.grillme.prompt":`开始之前,请不遗余力地盘问我这个想法的每一个方面,直到我们达成共识(一次只问一个问题,每个问题先给推荐答案):
|
|
86
|
+
|
|
87
|
+
1. 目标与非目标
|
|
88
|
+
2. 用户与场景
|
|
89
|
+
3. 边界与失败模式
|
|
90
|
+
4. 约束与依赖
|
|
91
|
+
5. 验收标准
|
|
92
|
+
|
|
93
|
+
达成共识后再给实现计划,等确认再写代码。`,"tpl.sk.handoff":"交接","tpl.sk.handoff.desc":"把长会话写成交接文档","tpl.sk.handoff.prompt":`请把当前会话整理成一份交接文档,让另一个 agent / 同事能无缝继续:
|
|
94
|
+
|
|
95
|
+
1. 背景与目标
|
|
96
|
+
2. 已完成的工作与关键决策(附原因)
|
|
97
|
+
3. 未完成项与下一步
|
|
98
|
+
4. 已知风险与待确认问题
|
|
99
|
+
5. 如何验证当前状态(命令等)
|
|
100
|
+
|
|
101
|
+
输出为结构化文档。`,"tpl.sk.questionnaire":"转问卷","tpl.sk.questionnaire.desc":"把开放问题变成可填问卷","tpl.sk.questionnaire.prompt":`请把需要别人提供的信息整理成一份可填写的问卷:
|
|
102
|
+
|
|
103
|
+
1. 每个问题说明背景和用途
|
|
104
|
+
2. 标注必填 / 选填
|
|
105
|
+
3. 给出示例答案降低理解成本
|
|
106
|
+
4. 分组排序,先简单后复杂
|
|
107
|
+
|
|
108
|
+
输出一份文档,对方可以照着填。`,"tpl.sk.teach":"持续学习","tpl.sk.teach.desc":"跨多次会话循序渐进学习","tpl.sk.teach.prompt":`请按循序渐进的方式教我:
|
|
109
|
+
|
|
110
|
+
1. 先定学习路径和目标
|
|
111
|
+
2. 一次只讲一小节,讲完给个小练习
|
|
112
|
+
3. 基于上一节的内容递进,主动提问确认理解
|
|
113
|
+
4. 每节结束总结要点
|
|
114
|
+
|
|
115
|
+
适合跨多次会话推进。`,"tpl.sk.ww":"说人话","tpl.sk.ww.desc":"用大白话重讲刚才的解释","tpl.sk.ww.prompt":`请把刚才的解释用最简单的语言重新讲一遍:
|
|
116
|
+
|
|
117
|
+
1. 避免术语,必须用时先给一句话定义
|
|
118
|
+
2. 用类比或具体例子说明
|
|
119
|
+
3. 明确指出哪部分仍是猜测 / 不确定
|
|
120
|
+
4. 用最短的话说完核心意思。`,"tpl.sk.wfa":"写给 agent 的文档","tpl.sk.wfa.desc":"按 agent 易读的原则写文档","tpl.sk.wfa.prompt":`请按「写给 agent 阅读」的原则写这份文档 / 说明:
|
|
121
|
+
|
|
122
|
+
1. 目标与使用场景写在最前
|
|
123
|
+
2. 指令具体、可验证,避免歧义和空话
|
|
124
|
+
3. 给正反例帮助理解
|
|
125
|
+
4. 结构化:标题、步骤、清单
|
|
126
|
+
5. 标注哪些是硬性要求、哪些是可选。`,"tpl.sk.codesign":"深模块设计","tpl.sk.codesign.desc":"用深模块原则审查与设计","tpl.sk.codesign.prompt":`请用「深模块」设计原则审查 / 设计:
|
|
127
|
+
|
|
128
|
+
1. 识别模块对外暴露的接口是否比内部实现更简单
|
|
129
|
+
2. 找出把复杂度泄漏到外部的模块
|
|
130
|
+
3. 给出每个模块的职责边界与改进方案
|
|
131
|
+
4. 平衡内聚与复用,避免过度抽象
|
|
132
|
+
|
|
133
|
+
输出审查结论与重构建议。`,"tpl.sk.domain":"领域建模","tpl.sk.domain.desc":"打磨项目用词并写下来","tpl.sk.domain.prompt":`请帮我梳理这个项目的领域语言:
|
|
134
|
+
|
|
135
|
+
1. 找出核心术语及当前叫法
|
|
136
|
+
2. 识别同词异义 / 异词同义造成的混乱
|
|
137
|
+
3. 统一推荐用词,写进术语表
|
|
138
|
+
4. 说明每个术语的边界(不是什么)
|
|
139
|
+
|
|
140
|
+
输出一份领域术语表。`,"tpl.sk.grilling":"拷问流程","tpl.sk.grilling.desc":"用拷问压测一个计划","tpl.sk.grilling.prompt":`请对下面这个计划做压力测试(拷问):
|
|
141
|
+
|
|
142
|
+
1. 逐项检查假设:如果它是错的会怎样?
|
|
143
|
+
2. 找漏洞:边界、失败模式、依赖、时序
|
|
144
|
+
3. 质疑决策:为什么这样?有没有更简单的路?
|
|
145
|
+
4. 每次只提出一个最尖锐的问题,等我回答
|
|
146
|
+
|
|
147
|
+
直到这个计划经得起推敲。`,"tpl.sk.tdd":"测试驱动","tpl.sk.tdd.desc":"红-绿-重构的规则","tpl.sk.tdd.prompt":`请用 TDD(红-绿-重构)完成:
|
|
148
|
+
|
|
149
|
+
1. 先写会失败的测试,覆盖正常路径、边界与错误分支
|
|
150
|
+
2. 用最小实现让测试通过
|
|
151
|
+
3. 重构并保持测试通过
|
|
152
|
+
|
|
153
|
+
避免三种反模式:与实现耦合的测试、空洞断言(永远为真)、横向切片(只测表面)。每步汇报并运行测试。`,error:"出错",done:"完成",running:"执行中…",toolQueued:"排队中",copyArgs:"复制参数",copyMessage:"复制消息",copied:"已复制",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:"输入提交信息…",scmChanges:"更改",scmHistory:"提交树",scmCommitDetail:"提交详情",scmSelectCommitHint:"点击左侧提交查看详情",scmNoHistory:"暂无提交记录",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 密钥",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(手工或脚本)?点下面的「重新加载配置」从磁盘重读,无需重启服务。",modelsCount:"{n} 个模型",addProvider:"新增服务商",providerId:"服务商 ID",providerIdHint:"(必填,如 ollama / my-proxy)",displayName:"显示名",displayNamePh:"我的代理",apiType:"API 类型",baseUrlHint:"(OpenAI 兼容端点)",apiKeyHint:"sk-…(可留空,用 auth.json 的密钥)",authHeader:"自动添加 Authorization 请求头",modelsTitle:"模型",modelIdReq:"模型 ID(必填)",text:"文本",textImage:"文本+图片",contextWindow:"上下文",maxOutput:"最大输出",removeModel:"移除模型",addModel:"添加模型",deleteProviderConfirm:"删除服务商 {id} 及其 {n} 个模型?",fetchModels:"自动获取模型列表",fetchModelsHint:"从 baseUrl 的 /models 接口自动拉取模型 ID(服务端请求,不受 CORS 限制)",fetchingModels:"获取中…",fetchModelsOk:"已获取 {n} 个模型",fetchModelsEmpty:"接口未返回任何模型",fetchModelsErr:"获取失败:{msg}",fetchModelsNeedBaseUrl:"请先填写 baseUrl 再获取",goalBarTitle:"目标",goalBarPlaceholder:"设定一个目标,agent 完成后自动审查…",goalBarSet:"开始",goalBarClear:"取消",goalBarLocked:"锁定:应用到后续所有回合",goalBarUnlocked:"仅本回合(改完自动清除)",goalBarReviewModel:"审查模型",goalBarUseMainModel:"使用主模型",goalBarMaxRounds:"最大轮数",goalBarMaxRoundsTip:"最大审查重改轮数;0 或不填 = 不限(持续改到通过)",goalBarUnlimitedShort:"不限",goalBarReviewing:"审查中…",goalBarRound:"第 {n} 轮",goalBarActive:"目标生效中",goalBarPassed:"已通过",goalBarFailed:"未通过",goalBarStatusPending:"等待生成…",goalWizardBtn:"AI 提炼",goalWizardTip:"让 AI 通过问卷调研细化需求,收敛为目标",goalWizardRunning:"目标调研中",goalWizardAnswer:"回答",goalWizardCard:"目标调研",settings:"设置",settingsTitle:"设置",settingsDesc:"修改立即生效:系统提示词、技能与插件开关会重建当前会话;审查提示词与审查技能只影响后续目标审查(回复进行中则主会话变更自动延迟)。",settingsSystemPrompt:"系统提示词",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:"已关闭:模型不能再向你弹出问卷/提问对话框",browserPageEnabledDesc:"让模型操作浏览器里被授权的页面(page-picker 扩展的 browser_page 工具:读内容 / 点击 / 输入 / 滚动 / 跳转,eval 另有单独开关)。需要先在扩展选项页授权目标页面。",browserPageOffHint:"已关闭:模型不能再点你的页面、也不能在页面里执行脚本",browserControl:"浏览器操作",browserControlTip:"让 AI 操作你在浏览器里授权的页面(读内容 / 点按钮 / 填表单 / 滚动),需要 page-picker 扩展;授权与开关都在扩展设置页里。",browserControlChecking:"正在查询扩展状态…",browserControlOffline:"还没连上浏览器扩展:装好(或启用)page-picker 扩展,在本页点一次扩展图标绑定地址,然后刷新本页。",browserControlEmpty:"扩展已就绪,但还没授权任何页面 —— 点下面的「打开扩展设置页」,在那里授权一个页面。",browserControlDisabled:"「允许 AI 操作页面」总开关是关的 —— 在扩展设置页打开它。",browserControlPages:"已授权的页面",browserControlPageOpen:"开着",browserControlPageClosed:"没打开",browserControlExamples:"可以这样让它干活",browserControlExample1:"「把那个页面上的订单读出来,按金额排序」",browserControlExample2:"「在搜索框输入 张三,点查询,等结果出来告诉我第一条」",browserControlOpenOptions:"打开扩展设置页",browserControlRefresh:"刷新状态",browserControlCite:"引用到对话",browserControlCiteTip:"把 {name} 作为网页引用放进输入框(不自动发送,你补一句话再发)",browserControlCiteNote:"点「引用到对话」会把网页引用放进输入框:模型据此知道操作哪个页面,不必再手打网址。",browserControlCited:"已引用到输入框 —— 补一句话再发",browserControlCiteFailed:"输入框还没准备好,稍后再试",browserControlOpenPanel:"打开面板(状态 / 授权管理)",browserControlSingleTip:"点击把 {name} 引用到对话;右侧 ▾ 打开面板",attachPage:"网页引用:{name}(AI 已获授权操作这个页面)",attachPageShort:"网页",settingsTools:"工具",toolsSectionTerminal:"持久终端",toolsSectionSubagent:"子代理",toolsSectionOther:"其他工具",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:"开启:工具调用始终完整展开显示参数和输出;关闭:默认折叠,点击展开",wideChat:"宽屏聊天列",wideChatDesc:"开启:中央列铺满宽度(超宽屏有用);关闭:保持 860px 上限",projectTitle:"标题显示项目名",projectTitleDesc:"开启:浏览器标签页标题为「项目目录名 — pi-web-ui」,切项目即时更新(多标签页开多个项目时好区分);关闭:固定显示应用名",terminalBashTakeover:"终端接管 bash",terminalBashTakeoverDesc:"此开关决定 bash 是否覆盖为终端版:关 = 原生 SDK bash(纯进程、不开终端);开 = 跑进可见终端,且 persist 参数在本开关的基础上决定一次性(false,命令跑完进程退出、输出留档)还是持久(true,shell 状态跨调用保留、静默自动转后台并通知 AI)",terminalBashIdleMs:"静默转后台阈值(毫秒)",terminalBashIdleMsDesc:"持久终端模式下,命令连续无输出达到该时长即不再阻塞等待,转入后台继续运行并通知 AI;0 = 一直等到命令结束(默认 15000)",visionBridgePromptPlaceholder:"输入自定义转写提示词…(留空 = 使用内置默认提示词,失焦后自动应用)",visionBridgePromptAppendHint:"追加模式:自定义内容拼接到内置转写提示词末尾(推荐,保留默认的逐字转写约束)。",visionBridgePromptReplaceHint:"替换模式:完全用自定义内容替换内置转写提示词。切换后输入框会显示内置默认提示词,可直接修改;不改动失焦则仍使用默认。",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:"在可见终端执行 pi-web-ui uninstall 卸载此插件(再次点击确认),完成后自动刷新列表",settingsExtensions:"插件",settingsUiPlugins:"界面插件",noUiPlugins:"未安装界面组件(<dataDir>/plugins/)",dshPatches:"DSH 用户补丁",dshPatchesDesc:"启动时按文件名序加载的 Cordis patch(<dataDir>/dsh-patches/*.yml)。新增/修改后点「重扫」重启运行时生效;失败的文件会被跳过并打印到运行时 stderr。",dshPatchesRescan:"重扫",dshPatchesRescanHint:"重新扫描补丁目录并重启 DSH 运行时使新补丁生效",dshPatchesEmpty:"未放置补丁文件",dshPatchesPath:"补丁目录:",uiPluginNoSource:"手工安装,无来源信息,无法在线更新",uiPluginPerms:"能力声明",pluginSettingsSave:"保存插件设置",pluginSettingsSaving:"保存中…",pluginSettingsReset:"恢复默认",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:"删除模板",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:"上下文"},Kc={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",thinkingLevel:"Thinking level",thinking:"Thinking",thinkingChip:"Thinking: {level}",sound:"Sound",theme:"Theme",themeDefault:"Dark (default)",newChat:"New chat",more:"More",newChatTip:"New chat (sessions are saved per browser)","thinking.off":"Off","thinking.minimal":"Minimal","thinking.low":"Low","thinking.medium":"Medium","thinking.high":"High","thinking.xhigh":"Extra high","thinking.max":"Max",thinkingUnsupported:"Not supported by this model — snapped to the nearest supported level",context:"Context",contextUsage:"Context usage",cumulativeCost:"Cumulative cost",sessionMessages:"Session messages",messages:"messages",pluginStatus:"Plugin status",engineBadge:"Engine",working:"Working",queued:"queued",enterPath:"Type a path, Enter to switch",cwdTip:"Working directory: {path} (click to switch)",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)",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)",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}",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",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",subagentBadge:"Subagent",convErrorBadge:"Subagent failed: {error}",subagentTitle:"Subagent · {title}",historySessions:"History",openHistory:"History",openFiles:"Files",streaming:"Streaming…",noHistory:"No previous chats",current:"Current",messageCount:"{n} messages",tuiTip:"Chat in the pi terminal (TUI)",deleteProject:"Remove from recent projects",deleteProjectConfirm:"Confirm remove",deleteSession:"Delete this chat transcript permanently",deleteSessionConfirm:"Confirm delete",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)",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).",updatesAllTitle:"Component updates",updatesAllBadge:"{n} updates",updatesAllUpToDate:"All components up to date",kindWebUi:"Web UI",kindPiCore:"Core",kindPackage:"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",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",liveOutputOmitted:`…[{n} chars omitted above]…
|
|
154
|
+
`,uploadToFolder:"Upload files to this folder",uploadToCurrentDir:"Upload files to current directory",openAsProject:"Open as project",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.",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:
|
|
155
|
+
|
|
156
|
+
1. Project type, tech stack and directory layout
|
|
157
|
+
2. Concrete commands for build / test / run / format
|
|
158
|
+
3. Code conventions and naming rules
|
|
159
|
+
4. Where tasks / issues live and their format
|
|
160
|
+
5. Known pitfalls or leftover issues
|
|
161
|
+
|
|
162
|
+
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:
|
|
163
|
+
|
|
164
|
+
1. Background and goals
|
|
165
|
+
2. Explicit goals and non-goals
|
|
166
|
+
3. Users and usage scenarios
|
|
167
|
+
4. Edge cases and failure modes
|
|
168
|
+
5. Acceptance criteria (what counts as done)
|
|
169
|
+
6. Interface / data-shape overview
|
|
170
|
+
|
|
171
|
+
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:
|
|
172
|
+
|
|
173
|
+
1. Each ticket small enough to be independently accepted
|
|
174
|
+
2. Annotate dependency order (what must come first)
|
|
175
|
+
3. Each ticket has: what to do, acceptance criteria, files involved
|
|
176
|
+
4. Flag which tickets can run in parallel
|
|
177
|
+
|
|
178
|
+
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:
|
|
179
|
+
|
|
180
|
+
1. Write failing tests for each ticket first (happy path, edges, error branches)
|
|
181
|
+
2. Make them pass with the minimal implementation
|
|
182
|
+
3. Refactor while keeping tests green
|
|
183
|
+
4. Proceed ticket by ticket, reporting briefly after each
|
|
184
|
+
|
|
185
|
+
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:
|
|
186
|
+
|
|
187
|
+
1. Against the spec: is the implementation complete and faithful?
|
|
188
|
+
2. Correctness: edges, nulls, concurrency and timing
|
|
189
|
+
3. Security: input validation, injection, sensitive data
|
|
190
|
+
4. Performance & readability: does it follow project conventions?
|
|
191
|
+
5. Tests: are critical paths covered?
|
|
192
|
+
|
|
193
|
+
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:
|
|
194
|
+
|
|
195
|
+
1. List every decision point and its dependencies
|
|
196
|
+
2. For each decision give options, trade-offs and your recommendation
|
|
197
|
+
3. Mark what can run in parallel vs. what must be sequential
|
|
198
|
+
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:
|
|
199
|
+
|
|
200
|
+
1. Validate only the key assumption, not the full implementation
|
|
201
|
+
2. Use the simplest means (hard-coding and skipped edge cases are fine)
|
|
202
|
+
3. Run it and tell me the verdict: does the assumption hold? trade-offs?
|
|
203
|
+
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):
|
|
204
|
+
|
|
205
|
+
1. Give an answer with source links
|
|
206
|
+
2. Distinguish facts, reasonable inference, and what's still uncertain
|
|
207
|
+
3. List the main options and their trade-offs
|
|
208
|
+
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:
|
|
209
|
+
|
|
210
|
+
1. Find signs of broken deep modules: oversized functions/classes, duplication, poor naming, hidden coupling
|
|
211
|
+
2. Prioritize improvements by severity and blast radius; produce a visual report
|
|
212
|
+
3. For each item give the minimal viable refactor with rationale
|
|
213
|
+
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:
|
|
214
|
+
|
|
215
|
+
1. Reproduce it first (build a minimal repro if none exists)
|
|
216
|
+
2. Narrow to a specific module via bisection or elimination
|
|
217
|
+
3. Form hypotheses and verify with logs / assertions / a minimal sample — no guessing
|
|
218
|
+
4. Once the root cause is found, explain it, then make the minimal fix
|
|
219
|
+
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:
|
|
220
|
+
|
|
221
|
+
1. Handle each conflict hunk, reading both sides' intent first
|
|
222
|
+
2. Choose or merge to keep correct semantics — don't blindly pick one side
|
|
223
|
+
3. Run tests and build afterwards to confirm
|
|
224
|
+
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:
|
|
225
|
+
|
|
226
|
+
1. Deduplicate and merge related entries
|
|
227
|
+
2. Categorize (bug / feature / improvement / question)
|
|
228
|
+
3. Prioritize by impact and urgency
|
|
229
|
+
4. For each item add: repro info or expectation, acceptance criteria
|
|
230
|
+
|
|
231
|
+
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:
|
|
232
|
+
|
|
233
|
+
1. Guide step by step, explaining why at each step
|
|
234
|
+
2. Validate each step; on wrong input give actionable hints
|
|
235
|
+
3. Support undo / going back a step
|
|
236
|
+
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):
|
|
237
|
+
|
|
238
|
+
1. Goals and non-goals
|
|
239
|
+
2. Users and scenarios
|
|
240
|
+
3. Edge cases and failure modes
|
|
241
|
+
4. Constraints and dependencies
|
|
242
|
+
5. Acceptance criteria
|
|
243
|
+
|
|
244
|
+
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:
|
|
245
|
+
|
|
246
|
+
1. Background and goals
|
|
247
|
+
2. Work done and key decisions (with reasons)
|
|
248
|
+
3. Outstanding items and next steps
|
|
249
|
+
4. Known risks and open questions
|
|
250
|
+
5. How to verify current state (commands, etc.)
|
|
251
|
+
|
|
252
|
+
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:
|
|
253
|
+
|
|
254
|
+
1. Explain the background and purpose of each question
|
|
255
|
+
2. Mark required / optional
|
|
256
|
+
3. Give example answers to lower friction
|
|
257
|
+
4. Group and order: easy first, hard later
|
|
258
|
+
|
|
259
|
+
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:
|
|
260
|
+
|
|
261
|
+
1. First set a learning path and goal
|
|
262
|
+
2. Teach one small section at a time, then a quick exercise
|
|
263
|
+
3. Build on the previous section and ask questions to confirm understanding
|
|
264
|
+
4. Summarize key points at the end of each section
|
|
265
|
+
|
|
266
|
+
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:
|
|
267
|
+
|
|
268
|
+
1. Avoid jargon; define any term you must use in one sentence
|
|
269
|
+
2. Use an analogy or concrete example
|
|
270
|
+
3. Be clear about what is still guesswork / uncertain
|
|
271
|
+
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:
|
|
272
|
+
|
|
273
|
+
1. Put the goal and usage up front
|
|
274
|
+
2. Make instructions concrete and verifiable — no vagueness
|
|
275
|
+
3. Give positive and negative examples
|
|
276
|
+
4. Structure with headings, steps and checklists
|
|
277
|
+
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:
|
|
278
|
+
|
|
279
|
+
1. Check whether each module's public interface is simpler than its implementation
|
|
280
|
+
2. Find modules that leak complexity outward
|
|
281
|
+
3. Give responsibility boundaries and improvement plans
|
|
282
|
+
4. Balance cohesion and reuse without over-abstracting
|
|
283
|
+
|
|
284
|
+
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:
|
|
285
|
+
|
|
286
|
+
1. Find the core terms and their current spellings
|
|
287
|
+
2. Spot confusion from same-word-different-meaning / different-word-same-meaning
|
|
288
|
+
3. Recommend one canonical term each, into a glossary
|
|
289
|
+
4. State each term's boundary (what it is not)
|
|
290
|
+
|
|
291
|
+
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:
|
|
292
|
+
|
|
293
|
+
1. Check each assumption: what if it's wrong?
|
|
294
|
+
2. Hunt for holes: edges, failure modes, dependencies, timing
|
|
295
|
+
3. Challenge decisions: why this way? is there a simpler path?
|
|
296
|
+
4. Ask one sharp question at a time and wait for my answer
|
|
297
|
+
|
|
298
|
+
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):
|
|
299
|
+
|
|
300
|
+
1. First write failing tests covering the happy path, edge cases and error branches
|
|
301
|
+
2. Make them pass with the minimal implementation
|
|
302
|
+
3. Refactor while keeping tests green
|
|
303
|
+
|
|
304
|
+
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",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…",scmChanges:"Changes",scmHistory:"Commit tree",scmCommitDetail:"Commit details",scmSelectCommitHint:"Click a commit on the left to view its details",scmNoHistory:"No commits yet",scmNoChanges:"Working tree clean — no changes",scmNotGitRepo:"Current directory is not a Git repository",scmLoading:"Querying…",scmConnecting:"Waiting for connection…",scmDiff:"Diff",scmSelectFileHint:"Click a file on the left to view its diff",scmNoDiff:"(no diff)",scmStaged:"Staged",scmUnstaged:"Unstaged",scmStagedUnstaged:"Staged + unstaged",scmUntracked:"Untracked",scmUntrackedNote:"Untracked file — 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",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.",modelsCount:"{n} models",addProvider:"Add provider",providerId:"Provider ID",providerIdHint:"(required, e.g. ollama / my-proxy)",displayName:"Display name",displayNamePh:"My proxy",apiType:"API type",baseUrlHint:"(OpenAI-compatible endpoint)",apiKeyHint:"sk-… (optional — uses the auth.json key)",authHeader:"Auto-add Authorization header",modelsTitle:"Models",modelIdReq:"Model ID (required)",text:"Text",textImage:"Text+image",contextWindow:"Context",maxOutput:"Max output",removeModel:"Remove model",addModel:"Add model",deleteProviderConfirm:"Delete provider {id} and its {n} models?",fetchModels:"Fetch model list",fetchModelsHint:"Pull model IDs from the baseUrl /models endpoint (server-side, no CORS)",fetchingModels:"Fetching…",fetchModelsOk:"Fetched {n} models",fetchModelsEmpty:"The endpoint returned no models",fetchModelsErr:"Fetch failed: {msg}",fetchModelsNeedBaseUrl:"Enter a baseUrl first",goalBarTitle:"Goal",goalBarPlaceholder:"Set a goal; the agent's output is auto-reviewed…",goalBarSet:"Start",goalBarClear:"Cancel",goalBarLocked:"Locked: applies to every later turn",goalBarUnlocked:"This turn only (cleared afterwards)",goalBarReviewModel:"Review model",goalBarUseMainModel:"Use the main model",goalBarMaxRounds:"Max rounds",goalBarMaxRoundsTip:"Max review-revision rounds; 0 or empty = unlimited (keep revising until it passes)",goalBarUnlimitedShort:"Unlimited",goalBarReviewing:"Reviewing…",goalBarRound:"Round {n}",goalBarActive:"Goal active",goalBarPassed:"Passed",goalBarFailed:"Failed",goalBarStatusPending:"Waiting to generate…",goalWizardBtn:"AI Scrape",goalWizardTip:"Let AI refine the requirement into a goal via a Q&A survey",goalWizardRunning:"Scoping the goal",goalWizardAnswer:"Answer",goalWizardCard:"Goal survey",settings:"Settings",settingsTitle:"Settings",settingsDesc:"Changes apply immediately: system prompt, skill and extension toggles rebuild the current session; review instructions and review skills affect later goal reviews (main-session changes are deferred while streaming).",settingsSystemPrompt:"System prompt",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",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",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.",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",attachPage:"Page reference: {name} (the AI is granted access to this page)",attachPageShort:"page",settingsTools:"Tools",toolsSectionTerminal:"Persistent terminal",toolsSectionSubagent:"Subagents",toolsSectionOther:"Other tools",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",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)",visionBridgePromptPlaceholder:"Type a custom transcription prompt… (empty = built-in default, applied on blur)",visionBridgePromptAppendHint:"Append mode: custom text is appended after the built-in transcription prompt (recommended — keeps the verbatim-transcription contract).",visionBridgePromptReplaceHint:"Replace mode: custom text replaces the built-in transcription prompt entirely. After switching, the editor shows the built-in default prompt ready to edit; blurring without changes keeps the default.",uninstallExt:"Uninstall",uninstallConfirm:"Confirm?",uninstallConfirmHint:"Click again to confirm — runs pi remove in the terminal",uninstallHint:"Runs pi remove in a visible terminal, then refreshes the list automatically",uninstallTitle:"Uninstall",pluginUpdate:"Update",pluginUpdateHint:"Re-installs from the recorded source (--force, keeps config.json), then refreshes the plugin list automatically",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:"Install straight from the source into UI plugins (runs in a visible terminal)",pluginCatalogRemoveHint:"Remove this custom plugin from the list",pluginUninstallHint:"Runs pi-web-ui uninstall in a visible terminal (click again to confirm), then refreshes the list automatically",settingsExtensions:"Extensions",settingsUiPlugins:"UI plugins",noUiPlugins:"No UI plugins installed (<dataDir>/plugins/)",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: ",uiPluginNoSource:"Installed manually — no recorded source, online update unavailable",uiPluginPerms:"Permissions",pluginSettingsSave:"Save plugin settings",pluginSettingsSaving:"Saving…",pluginSettingsReset:"Reset defaults",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",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"},Yc=[{code:"zh",nativeName:"中文"},{code:"en",nativeName:"English"}],vs={};function Gc(e){return!e||typeof e.code!="string"||!e.code||e.code==="zh"||e.code==="en"||!e.strings||typeof e.strings!="object"?!1:(vs[e.code]=e,!0)}function Vc(e){delete vs[e]}function zc(e){return e==="zh"?"中文":e.toUpperCase()}function Qc(e){return e==="zh"?"zh-CN":e==="pt"?"pt-BR":e}async function ii(e){const t=await fetch(vt(tt(e)));if(!t.ok)throw new Error(`HTTP ${t.status} for ${e}`);return await t.json()}const Ur=c.createContext(null);function $r(){try{return localStorage.getItem(da)}catch{return null}}function Xc(){return ua($r(),typeof navigator<"u"?navigator.languages:[],null)}function Jc({children:e}){const[t,n]=c.useState(Xc),[i,a]=c.useState(0),o=c.useRef(t);o.current=t;const l=c.useCallback(f=>{n(f);try{localStorage.setItem(da,f)}catch{}try{window.dispatchEvent(new CustomEvent("pi-web-ui:locale",{detail:f}))}catch{}},[]),u=c.useCallback(async()=>{let f,w=null;try{const N=await ii("/api/locales");f=N.packs??[],w=N.defaultLocale??null}catch{return null}return await Promise.all(f.filter(N=>N.installed).map(async N=>{try{const C=await ii(`/api/locales/${N.code}`);Gc({code:C.code||N.code,nativeName:C.nativeName||N.nativeName,strings:C.strings})}catch{}})),a(N=>N+1),w},[]);c.useEffect(()=>{u().then(f=>{if(!$r()?.trim()){const N=ua(null,typeof navigator<"u"?navigator.languages:[],f);N!==o.current&&(o.current=N,n(N))}const w=o.current;if(w!=="zh"&&w!=="en"&&!vs[w]){const N=ua(null,typeof navigator<"u"?navigator.languages:[],f,["zh","en"]);o.current=N,n(N);try{localStorage.setItem(da,N)}catch{}}})},[u]);const p=c.useMemo(()=>[...Yc,...Object.values(vs).map(f=>({code:f.code,nativeName:f.nativeName}))],[i]),E=c.useCallback((f,w)=>{let N=vs[t]?.strings[f]??(t==="zh"?Wc[f]:Kc[f]);if(w)for(const[C,M]of Object.entries(w))N=N.replaceAll(`{${C}}`,String(M));return N},[t,i]);c.useEffect(()=>{document.documentElement.lang=Qc(t)},[t]);const m=c.useMemo(()=>({locale:t,setLocale:l,t:E,packs:p,reloadPacks:u}),[t,l,E,p,u]);return s.jsx(Ur.Provider,{value:m,children:e})}function Ht(){const e=c.useContext(Ur);if(!e)throw new Error("useI18n must be used within LanguageProvider");return e}function je(){return Ht().t}const Zc=[{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 ri({settings:e,onChange:t,onPreview:n}){const i=je(),a=o=>t({...e,...o});return s.jsxs("div",{className:"sound-menu",children:[s.jsx("div",{className:"dd-header",children:i("soundHeader")}),s.jsxs("label",{className:"sound-row sound-master",children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(Ir,{className:"sound-icon"}),s.jsx("span",{children:i("enableSound")})]}),s.jsx("input",{type:"checkbox",checked:e.enabled,onChange:o=>a({enabled:o.target.checked})})]}),Zc.map(({kind:o,labelKey:l,descKey:u})=>s.jsxs("label",{className:`sound-row ${e.enabled?"":"disabled"}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx("span",{className:"sound-name",children:i(l)}),s.jsx("span",{className:"sound-desc",children:i(u)})]}),s.jsxs("span",{className:"sound-right",children:[s.jsx("button",{type:"button",className:"sound-preview",title:i("preview"),disabled:!e.enabled,onClick:p=>{p.preventDefault(),n(o)},children:i("preview")}),s.jsx("input",{type:"checkbox",checked:e[o],disabled:!e.enabled,onChange:p=>a({[o]:p.target.checked})})]})]},o)),s.jsxs("div",{className:`sound-volume ${e.enabled?"":"disabled"}`,children:[s.jsx("span",{className:"sound-name",children:i("volume")}),s.jsx("input",{type:"range",min:0,max:100,step:5,value:e.volume,disabled:!e.enabled,onChange:o=>a({volume:Number(o.target.value)})}),s.jsxs("span",{className:"sound-vol-num",children:[e.volume,"%"]})]})]})}const qr=()=>window.__piWebUiHost?.pageCall?.bind(window.__piWebUiHost);async function eu(){const e=qr();if(!e)return{available:!1,pages:[],error:"宿主页面桥不可用:这个 pi-web-ui 页面还没装上扩展桥(装/启用 page-picker 后刷新本页)"};try{const t=await e({op:"status",timeoutMs:5e3});if(!t.ok)return{available:!1,pages:[],error:t.error??"扩展没有返回状态"};const n=t.result??{};return{available:n.installed===!0,aiControl:n.aiControl===!0,allowEval:n.allowEval===!0,pages:Array.isArray(n.pages)?n.pages:[]}}catch(t){return{available:!1,pages:[],error:t instanceof Error?t.message:String(t)}}}function tu(e){return e.length===1?e[0]:null}function su(e){return{path:e.origin,name:e.title?.trim()||e.origin,mode:"page",key:`page:${e.origin}`}}async function nu(){const e=qr();if(!e)return!1;try{return(await e({op:"openOptions",timeoutMs:5e3})).ok===!0}catch{return!1}}function au(e=45e3){const[t,n]=c.useState(null),i=c.useRef(!0),a=c.useCallback(async o=>{const l=await eu();i.current&&(n(l),o&&!l.available&&setTimeout(()=>{i.current&&a(!1)},1500))},[]);return c.useEffect(()=>{i.current=!0,a(!0);const o=setInterval(()=>void a(!1),Math.max(5e3,e));return()=>{i.current=!1,clearInterval(o)}},[a,e]),{status:t,refresh:()=>void a(!0)}}let bn=null,En=null;function oi(e){bn=e}function li(e){En=e}function iu(){return!!(bn||En)}function Wr(e){const t=typeof e?.text=="string"?e.text:"",n=Array.isArray(e?.attachments)?e.attachments:[],i=t.trim()!=="",a=n.length>0;return!i&&!a||i&&!bn||a&&!En?!1:(a&&En?.(n),i&&bn?.(t),!0)}function ru(){const e=je(),{status:t,refresh:n}=au(),[i,a]=c.useState(!1),[o,l]=c.useState(null),u=c.useRef(null),p=t?.pages??[],E=t?.available===!0&&(p.length===0||t.aiControl===!1),m=tu(p),f=C=>{l(C),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>l(null),2600)},w=C=>{const M=Wr({attachments:[su(C)]});f(e(M?"browserControlCited":"browserControlCiteFailed"))},N=()=>{a(!0),n()};return s.jsxs("span",{className:"bc-anchor",children:[m?s.jsxs("span",{className:"browser-control-split",children:[s.jsxs("button",{type:"button",className:`chip browser-control single${E?" attention":""}`,title:e("browserControlSingleTip",{name:m.title||m.origin}),onClick:()=>w(m),children:[s.jsx(ra,{size:14,"aria-hidden":!0}),s.jsx("span",{className:"bc-chip-label",children:m.title||m.origin})]}),s.jsx("button",{type:"button",className:"chip browser-control caret",title:e("browserControlOpenPanel"),"aria-label":e("browserControlOpenPanel"),onClick:N,children:"▾"})]}):s.jsxs("button",{type:"button",className:`chip browser-control${E?" attention":""}`,title:t?.error??e(E?"browserControlEmpty":"browserControlTip"),onClick:N,children:[s.jsx(ra,{size:14,"aria-hidden":!0}),s.jsxs("span",{children:[e("browserControl"),p.length>0?` · ${p.length}`:""]})]}),o&&s.jsx("span",{className:"bc-flash",children:o}),i&&s.jsx(ou,{status:t,onRefresh:n,onCite:w,onClose:()=>a(!1)})]})}function ou({status:e,onRefresh:t,onCite:n,onClose:i}){const a=je(),[o,l]=c.useState(!1),u=e?.pages??[],p=async()=>{l(!0);try{await nu()||t()}finally{l(!1)}};return s.jsx("div",{className:"modal-backdrop",onClick:i,children:s.jsxs("div",{className:"modal browser-control-modal",onClick:E=>E.stopPropagation(),children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":a("close"),onClick:i,children:"✕"}),s.jsxs("div",{className:"modal-head",children:[s.jsx(ra,{size:16,"aria-hidden":!0}),s.jsx("h2",{children:a("browserControl")})]}),s.jsx("div",{className:"modal-desc",children:a("browserControlTip")}),e===null&&s.jsx("div",{className:"bc-note",children:a("browserControlChecking")}),e?.available===!1&&s.jsx("div",{className:"bc-note warn",children:a("browserControlOffline")}),e?.available===!0&&e.aiControl===!1&&s.jsx("div",{className:"bc-note warn",children:a("browserControlDisabled")}),e?.available===!0&&u.length===0&&s.jsx("div",{className:"bc-note warn",children:a("browserControlEmpty")}),u.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"bc-section",children:a("browserControlPages")}),s.jsx("ul",{className:"bc-pages",children:u.map(E=>s.jsxs("li",{children:[s.jsx("span",{className:"bc-title",title:E.title,children:E.title}),s.jsx("span",{className:"bc-origin",title:E.origin,children:E.origin}),s.jsx("span",{className:`bc-open${E.open?" on":""}`,children:E.open?a("browserControlPageOpen"):a("browserControlPageClosed")}),s.jsx("button",{type:"button",className:"bc-cite",title:a("browserControlCiteTip",{name:E.title||E.origin}),onClick:()=>n(E),children:a("browserControlCite")})]},E.origin))}),s.jsx("div",{className:"bc-note",children:a("browserControlCiteNote")})]}),s.jsx("div",{className:"bc-section",children:a("browserControlExamples")}),s.jsxs("ul",{className:"bc-examples",children:[s.jsx("li",{children:a("browserControlExample1")}),s.jsx("li",{children:a("browserControlExample2")})]}),s.jsxs("div",{className:"bc-actions",children:[s.jsx("button",{type:"button",className:"primary",disabled:o,onClick:()=>void p(),children:a("browserControlOpenOptions")}),s.jsx("button",{type:"button",onClick:t,children:a("browserControlRefresh")})]})]})})}const Kr="pi-web-notify",Wn={enabled:!1};function Yr(){try{const e=localStorage.getItem(Kr);if(!e)return{...Wn};const t=JSON.parse(e);return{enabled:typeof t.enabled=="boolean"?t.enabled:Wn.enabled}}catch{return{...Wn}}}function ci(e){try{localStorage.setItem(Kr,JSON.stringify(e))}catch{}}function Ms(){return typeof window<"u"&&"Notification"in window}function lu(){return Ms()?null:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported"}const cu=12e4;function uu(e){const{screenX:t,screenY:n,outerWidth:i,outerHeight:a}=e;return Number.isFinite(t)&&ui(t)||Number.isFinite(n)&&ui(n)?!0:i>0&&i<=400&&a>0&&a<=40}function ui(e){return e<=-1e4}function du(e){return!(e.visibility!=="visible"||e.minimized||!e.hasFocus||e.windows&&e.idleMs>cu)}let Gr=Date.now(),di=!1;function pi(){Gr=Date.now()}function pu(){return Math.max(0,Date.now()-Gr)}function mu(){if(di||typeof window>"u")return;di=!0;const e={passive:!0,capture:!0};for(const t of["pointerdown","pointermove","keydown","wheel","touchstart","focus","scroll"])window.addEventListener(t,pi,e);typeof document<"u"&&document.addEventListener("visibilitychange",pi,e)}function Vr(){return typeof navigator>"u"?!1:/windows/i.test(navigator.userAgent??"")}function hu(){return mu(),typeof window>"u"||typeof document>"u"?{hasFocus:!0,visibility:"visible",minimized:!1,idleMs:0,windows:!1}:{hasFocus:typeof document.hasFocus=="function"?document.hasFocus():!0,visibility:document.visibilityState??"",minimized:uu({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:pu(),windows:Vr()}}function mi(){return Ms()?Notification.permission:"denied"}async function fu(){if(!Ms())return"denied";try{return await Notification.requestPermission()}catch{return"denied"}}function hi(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function gu(e,t=!1){return{body:e,requireInteraction:t,icon:tt("/icons/icon-192.png"),badge:tt("/icons/icon-192.png"),data:{url:typeof location<"u"?location.href:tt("/")}}}async function bu(e,t,n=!1){if(!Ms())return{path:"none",error:"unsupported"};if(Notification.permission!=="granted")return{path:"none",error:`permission: ${Notification.permission}`};const i=gu(t,n);let a;try{const o=await navigator.serviceWorker?.getRegistration();if(o?.active&&typeof o.showNotification=="function")return await o.showNotification(e,i),{path:"sw"};a=o?"service worker not active":"no service worker registration"}catch(o){a=hi(o)}try{return new Notification(e,i),{path:"page",error:a}}catch(o){return{path:"none",error:`${a}; page: ${hi(o)}`}}}async function Ks(e,t){Ms()&&(du(hu())||Yr().enabled&&await bu(e,t))}const Eu=!1;function fi(){const e=je(),[t,n]=c.useState(Yr),[i,a]=c.useState(()=>mi()),[o,l]=c.useState(null),u=lu(),p=u!==null,E=Vr();c.useEffect(()=>{const f=()=>a(mi());return window.addEventListener("focus",f),document.addEventListener("visibilitychange",f),()=>{window.removeEventListener("focus",f),document.removeEventListener("visibilitychange",f)}},[]);const m=async f=>{const w={...t,enabled:f};if(n(w),ci(w),f){const N=await fu();if(a(N),N!=="granted"){const C={...w,enabled:!1};n(C),ci(C)}}};return s.jsxs("div",{className:"sound-menu notify-menu",children:[s.jsx("div",{className:"dd-header",children:e("notifyHeader")}),s.jsxs("label",{className:`sound-row sound-master${p?" disabled":""}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(Dc,{className:"sound-icon"}),s.jsx("span",{children:e("notifyEnable")})]}),s.jsx("input",{type:"checkbox",checked:t.enabled&&!p,disabled:p,onChange:f=>m(f.target.checked)})]}),s.jsx("div",{className:"sound-hint",children:e("notifyEnableDesc")}),u==="insecure"&&s.jsx("div",{className:"sound-hint",children:e("notifyInsecure")}),u==="unsupported"&&s.jsx("div",{className:"sound-hint",children:e("notifyUnsupported")}),!p&&i==="denied"&&s.jsx("div",{className:"sound-hint",children:e("notifyDenied")}),!p&&E&&s.jsx("div",{className:"sound-hint",children:e("notifyWindowsHint")}),Eu]})}const Tu={engine:"pi",managed:!1,status:"connecting",ready:!1,cwd:""};let as=Tu;const pa=new Set;function xu(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,i)=>n===t[i])}function yu(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&&xu(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function gi(e){const t={...as,...e};if(!yu(as,t)){as=t;for(const n of pa)n()}}function zr(e){return pa.add(e),()=>{pa.delete(e)}}function bi(){return as}function Ra(){return c.useSyncExternalStore(zr,bi,bi)}function Ct(e){return c.useSyncExternalStore(zr,()=>as[e],()=>as[e])}function Qr(){return Ct("engine")==="dsh"}function Xr(){return Ct("managed")}function Nu(){return Ct("service")}let ma=null;function ku(e){ma=e}const ae=e=>ma?ma(e):!1;function vu({onClose:e}){const t=je(),{locale:n,setLocale:i,reloadPacks:a}=Ht(),[o,l]=c.useState(null),[u,p]=c.useState(""),[E,m]=c.useState("");async function f(){try{const C=await fetch(vt(tt("/api/locales")));if(!C.ok)throw new Error(`HTTP ${C.status}`);const M=await C.json();l(M.packs??[]),p("")}catch(C){p(t("localeListFailed",{error:C instanceof Error?C.message:String(C)}))}}c.useEffect(()=>{f()},[]);async function w(C){m(C),p("");try{const M=await fetch(vt(tt(`/api/locales/${C}/install`)),{method:"POST"});if(!M.ok){let W=`HTTP ${M.status}`;try{W=(await M.json()).error??W}catch{}throw new Error(W)}await a(),await f()}catch(M){p(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{m("")}}async function N(C){m(C),p("");try{const M=await fetch(vt(tt(`/api/locales/${C}`)),{method:"DELETE"});if(!M.ok)throw new Error(`HTTP ${M.status}`);Vc(C),n===C&&i("zh"),await a(),await f()}catch(M){p(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{m("")}}return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"bg-task-modal",onClick:C=>C.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(Rr,{})," ",t("localePacks")]}),s.jsx("button",{type:"button",className:"btn",title:t("close"),onClick:e,children:s.jsx(Ke,{})})]}),u&&s.jsx("div",{className:"bg-task-empty",children:u}),o===null&&!u?s.jsx("div",{className:"bg-task-empty",children:t("loading")}):s.jsx("ul",{className:"bg-task-list",children:(o??[]).map(C=>{const M=E===C.code;return s.jsxs("li",{className:"bg-task-item",children:[s.jsxs("div",{className:"bg-task-info",children:[s.jsxs("div",{className:"bg-task-line1",children:[s.jsx("span",{className:"bg-task-port",children:C.nativeName}),C.installed&&C.version&&s.jsxs("span",{className:"bg-task-name",children:["v",C.version]})]}),s.jsxs("div",{className:"bg-task-line2",children:[s.jsx("span",{children:C.code}),C.installed?s.jsxs("span",{children:[t("localeInstalled")," · ",t("localeRemoveHint")]}):s.jsx("span",{children:t("localeGetMore")})]})]}),C.installed?s.jsxs("button",{type:"button",className:"btn bg-task-stop",disabled:M,title:t("localeRemove"),onClick:()=>void N(C.code),children:[s.jsx(et,{}),s.jsx("span",{children:t(M?"localeRemoving":"localeRemove")})]}):s.jsxs("button",{type:"button",className:"btn",disabled:M,title:t("localeInstall"),onClick:()=>void w(C.code),children:[s.jsx(Yt,{}),s.jsx("span",{children:t(M?"localeDownloading":"localeInstall")})]})]},C.code)})}),s.jsx("div",{className:"bg-task-foot",children:s.jsxs("button",{type:"button",className:"btn",title:t("bgTaskRefresh"),onClick:()=>void f(),children:[s.jsx(kt,{}),s.jsx("span",{children:t("bgTaskRefresh")})]})})]})})}function Cu({chat:e,terminal:t,view:n,plugins:i,onViewChange:a,onOpenPanel:o,onOpenSettings:l,onOpenBgTasks:u,onOpenGlobalSearch:p,sound:E,onSoundChange:m,onSoundPreview:f,themes:w,theme:N,onThemeChange:C}){const{locale:M,setLocale:W,t:_,packs:D}=Ht(),{appVersion:I}=Ra(),H=Xr(),te=Nu(),[ee,le]=c.useState(!1);c.useEffect(()=>{ee&&e.status==="open"&&le(!1)},[ee,e.status]);const[pe,Q]=c.useState(!1),[G,ce]=c.useState(!1),[O,B]=c.useState(!1),[x,R]=c.useState(!1),[F,v]=c.useState(!1),[se,K]=c.useState(!1),xe=e.ready?_("connected"):e.status==="closed"?_("reconnecting"):_("connecting"),k=e.ready?"ok":"busy",Y=()=>{if(!e.ready)return;const $=_("updateTabTitle"),Ie={name:$,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},Le=e.terminals.find(P=>P.title===$);Le?(t.restart(Le.id),ae({type:"run_command",terminalId:Le.id,conversationId:Le.conversationId,command:Ie,cols:80,rows:24})):t.create({id:St(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:$,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Ie}),R(!1),v(!1),a("terminal")},re=($,Ie)=>{if(!e.ready||$.length===0)return;const Le={name:Ie,command:Bc($),cwd:"${pwd}"},P=e.terminals.find(ye=>ye.title===Ie);P?(t.restart(P.id),ae({type:"run_command",terminalId:P.id,conversationId:P.conversationId,command:Le,cols:80,rows:24})):t.create({id:St(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:Ie,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Le}),R(!1),v(!1),a("terminal")},de=$=>!e.tabs||$==="chat"||e.tabs.includes($),we=e.updatesAll??[],ie=we.filter($=>!$.upToDate&&!$.error).length,me=we.filter($=>!$.upToDate&&!$.error&&$.kind!=="webui"),X=()=>s.jsxs("div",{className:"dd-updates-all",children:[s.jsx("div",{className:"dd-header",children:_("updatesAllTitle")}),e.updatesAll===null?s.jsx("div",{className:"dd-note",children:_("checkingUpdate")}):we.length===0?s.jsx("div",{className:"dd-note",children:_("updatesAllUpToDate")}):s.jsx("ul",{className:"dd-all-list",children:we.map($=>s.jsxs("li",{className:`dd-all-item${$.error?" err":$.upToDate?"":" warn"}`,children:[s.jsx("span",{className:"dd-all-name",title:$.name,children:$.name}),s.jsx("span",{className:"dd-all-kind",children:$.kind==="webui"?_("kindWebUi"):$.kind==="pi-core"?_("kindPiCore"):_("kindPackage")}),s.jsx("span",{className:"dd-all-vers",children:$.error?_("updateCheckFailed"):$.upToDate?`v${$.current}`:s.jsxs(s.Fragment,{children:["v",$.current," → v",$.latest]})}),$.kind!=="webui"&&!$.upToDate&&!$.error&&s.jsx("button",{type:"button",className:"dd-update-btn",onClick:()=>re([$],_("updatePkgTabTitle",{name:$.name})),children:_("updateBtn")})]},`${$.kind}:${$.name}`))}),s.jsxs("div",{className:"dd-actions",children:[me.length>0&&s.jsx("button",{type:"button",className:"dd-refresh accent",style:{flex:1},onClick:()=>re(me,_("updateAllTabTitle")),children:_("updateAllBtn")}),s.jsx("button",{type:"button",className:"dd-refresh",style:me.length>0?{flex:1}:void 0,onClick:()=>ae({type:"check_updates_all",force:!0}),children:_("updatesAllRefresh")})]})]}),oe=()=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"dd-update",children:[s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:_("currentVersion")}),s.jsxs("b",{children:["v",e.update?.current??"…"]})]}),s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:_("latestVersion")}),s.jsx("b",{children:e.update===null?_("checkingUpdate"):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:_("checkingUpdate")})]}),e.update&&e.update.upToDate&&s.jsx("div",{className:"dd-note ok",children:_("upToDate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note warn",children:_("updateAvailable",{version:e.update.latest})}),e.update?.latestPublishedAt&&Date.now()-new Date(e.update.latestPublishedAt).getTime()<30*6e4&&s.jsx("div",{className:"dd-note warn",children:_("updateJustPublished",{version:e.update.latest??""})}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note",children:_("updateTerminalHint")})]}),s.jsxs("div",{className:"dd-actions",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>ae({type:"check_update"}),children:e.update===null?_("checkingUpdate"):_("checkUpdate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("button",{type:"button",className:"dd-refresh accent",onClick:Y,children:_("updateNow")}),te&&s.jsx("button",{type:"button",className:"dd-refresh accent",disabled:ee,title:_("restartServiceTip",{name:te.name}),onClick:()=>{ee||(le(!0),ae({type:"restart_service"}))},children:_(ee?"restartingService":"restartService")})]})]});return s.jsxs("header",{className:"topbar",children:[s.jsxs("div",{className:"brand",children:[n==="chat"&&s.jsx("button",{type:"button",className:"panel-toggle",title:_("openHistory"),onClick:()=>o("left"),children:s.jsx(Nc,{})}),s.jsx("span",{className:"brand-logo",children:"π"}),s.jsx("span",{className:"brand-name",children:"pi-web-ui"}),s.jsx("span",{className:`conn-dot ${k}`,title:xe}),s.jsx("span",{className:"conn-label",children:xe})]}),s.jsxs("div",{className:"topbar-actions",children:[s.jsxs("div",{className:"view-switch",role:"tablist","aria-label":_("viewSwitch"),children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":n==="chat",className:n==="chat"?"active":"",onClick:()=>a("chat"),children:[s.jsx(rs,{}),s.jsx("span",{children:_("chat")})]}),de("terminal")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":n==="terminal",className:n==="terminal"?"active":"",onClick:()=>a("terminal"),children:[s.jsx(Ln,{}),s.jsx("span",{children:_("terminal")})]}),de("git")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":n==="git",className:n==="git"?"active":"",onClick:()=>a("git"),children:[s.jsx(Qs,{}),s.jsx("span",{children:_("scmTab")})]}),(de("plugins")?i:[]).filter($=>$.view!==!1).map($=>{const Ie=$.error?`${$.name}: ${$.error}`:$.description?`${$.name} — ${$.description}`:$.name;return s.jsxs("button",{type:"button",role:"tab","aria-selected":n===`plugin:${$.id}`,className:`plugin-tab${n===`plugin:${$.id}`?" active":""}${$.error?" broken":""}`,title:Ie,onClick:()=>a(`plugin:${$.id}`),children:[$.icon?s.jsx("span",{"aria-hidden":!0,children:$.icon}):null,s.jsx("span",{children:$.name})]},$.id)})]}),s.jsxs("div",{className:"topbar-desktop",children:[de("search")&&s.jsxs("button",{type:"button",className:"chip",title:_("searchGlobalTip"),onClick:p,children:[s.jsx(pn,{}),s.jsx("span",{className:"chip-sub",children:_("searchGlobal")})]}),s.jsx(ru,{}),de("tasks")&&s.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":_("bgTasksTip"),onClick:u,children:[s.jsx(mn,{}),s.jsx("span",{className:"chip-sub",children:_("bgTasks")}),e.bgServers.length>0&&s.jsx("span",{className:"bg-task-badge",children:e.bgServers.length})]}),de("settings")&&s.jsxs("button",{type:"button",className:"chip",title:_("settingsTitle"),onClick:l,children:[s.jsx(dn,{}),s.jsx("span",{className:"chip-sub",children:_("settings")})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Ir,{}),s.jsx("span",{className:"chip-sub",children:_("sound")})]}),open:pe,onOpenChange:Q,children:[s.jsx(ri,{settings:E,onChange:m,onPreview:f}),s.jsx(fi,{})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Rr,{}),s.jsx("span",{className:"chip-sub",children:zc(M)})]}),open:G,onOpenChange:ce,children:[s.jsx("div",{className:"dd-header",children:_("language")}),D.map($=>s.jsx(it,{active:M===$.code,onClick:()=>{W($.code),ce(!1)},children:$.nativeName},$.code)),s.jsxs(it,{onClick:()=>{ce(!1),K(!0)},children:[s.jsx(Yt,{})," ",_("localeGetMore")]})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(fc,{}),s.jsx("span",{className:"chip-sub",children:_("theme")})]}),open:O,onOpenChange:B,children:[s.jsx("div",{className:"dd-header",children:_("theme")}),s.jsx(it,{active:N===null,onClick:()=>{C(null),B(!1)},children:_("themeDefault")}),w.map($=>s.jsx(it,{active:N===$.id,onClick:()=>{C($.id),B(!1)},children:M==="zh"?$.name:$.nameEn??$.name},$.id))]}),H?s.jsxs("span",{className:"chip",title:_("updatesManaged"),children:[s.jsx(Yt,{}),s.jsxs("span",{className:"chip-sub",children:["v",I??e.update?.current??"…"]})]}):s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Yt,{}),s.jsxs("span",{className:"chip-sub",children:["v",e.update?.current??"…"]}),e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot",title:_("updateAvailable",{version:e.update.latest??""})}),ie>0&&s.jsx("span",{className:"update-badge",children:_("updatesAllBadge",{n:ie})})]}),open:x,onOpenChange:$=>{R($),$&&(ae({type:"check_update"}),ae({type:"check_updates_all"}))},fit:!0,children:[s.jsx("div",{className:"dd-header",children:_("update")}),oe(),X()]}),s.jsx("a",{className:"chip github",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",title:_("githubRepo"),children:s.jsx(si,{})})]}),s.jsxs("button",{type:"button",className:"chip newchat","data-tip":_("newChatTip"),onClick:()=>ae({type:"new_chat"}),children:[s.jsx(dt,{}),s.jsx("span",{children:_("newChat")})]}),s.jsx("div",{className:"topbar-more",children:s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Tc,{}),s.jsx("span",{className:"chip-sub",children:_("more")}),!H&&e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot"})]}),open:F,onOpenChange:$=>{v($),$&&!H&&(ae({type:"check_update"}),ae({type:"check_updates_all"}))},children:[s.jsx("div",{className:"dd-header",children:_("sound")}),s.jsx("div",{className:"dd-header",children:_("settings")}),s.jsxs(it,{onClick:()=>{v(!1),l()},children:[s.jsx(dn,{})," ",_("settingsTitle")]}),s.jsxs(it,{onClick:()=>{v(!1),p()},children:[s.jsx(pn,{})," ",_("searchGlobal")]}),s.jsxs(it,{onClick:()=>{v(!1),u()},children:[s.jsx(mn,{})," ",_("bgTasks"),e.bgServers.length>0&&s.jsx("em",{className:"bg-task-badge",children:e.bgServers.length})]}),s.jsx(ri,{settings:E,onChange:m,onPreview:f}),s.jsx(fi,{}),s.jsx("div",{className:"dd-header",children:_("language")}),D.map($=>s.jsx(it,{active:M===$.code,onClick:()=>W($.code),children:$.nativeName},$.code)),s.jsx("div",{className:"dd-header",children:_("theme")}),s.jsx(it,{active:N===null,onClick:()=>{C(null),v(!1)},children:_("themeDefault")}),w.map($=>s.jsx(it,{active:N===$.id,onClick:()=>{C($.id),v(!1)},children:M==="zh"?$.name:$.nameEn??$.name},$.id)),s.jsx("div",{className:"dd-header",children:_("update")}),oe(),X(),s.jsxs("a",{className:"dd-refresh dd-more-link",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",children:[s.jsx(si,{})," ",_("githubRepo")]})]})})]}),n==="chat"&&s.jsx("button",{type:"button",className:"panel-toggle",title:_("openFiles"),onClick:()=>o("right"),children:s.jsx(Bt,{})}),se&&s.jsx(vu,{onClose:()=>K(!1)})]})}function Jr(e,t){const n={...t};if(!e)return n;try{const i=JSON.parse(e);if(i&&typeof i=="object"&&!Array.isArray(i))for(const a of Object.keys(t)){const o=i[a];typeof o=="number"&&Number.isFinite(o)&&o>0&&(n[a]=o)}}catch{}return n}function Zr(e){const t=e.start.above+e.start.below,n=Math.max(1,e.availablePx),i=e.totalWeight>0?e.totalWeight:1,a=n/i,o=e.minAbovePx/a,l=e.minBelowPx/a;if(o+l>=t){const p=e.minAbovePx+e.minBelowPx||1,E=t*e.minAbovePx/p;return{above:E,below:t-E}}const u=Math.min(t-l,Math.max(o,e.start.above+e.deltaPx/a));return{above:u,below:t-u}}function Ei(e){const 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 _u(e,t){const n=new Map(e.map(o=>[o.id,o])),i=new Map;for(const o of e){const l=o.parentId?n.get(o.parentId)?.cwd??o.cwd:o.cwd,u=i.get(l)??[];u.push(o),i.set(l,u)}const a=[...i.entries()].map(([o,l])=>({cwd:o,isCurrent:o===t,convs:l}));return a.sort((o,l)=>o.isCurrent?-1:l.isCurrent?1:o.cwd<l.cwd?-1:o.cwd>l.cwd?1:0),a}const wu="pi-web-ui:lp-collapse-projects",Su="pi-web-ui:lp-collapse-convs",Au="pi-web-ui:lp-collapse-sessions";function Kn(e,t=!1){const[n,i]=c.useState(()=>{try{const o=localStorage.getItem(e);if(o==="1")return!0;if(o==="0")return!1}catch{}return t}),a=c.useCallback(()=>{i(o=>{const l=!o;try{localStorage.setItem(e,l?"1":"0")}catch{}return l})},[e]);return[n,a]}const eo="pi-web-ui:lp-sizes",Tn={projects:1,convs:1,sessions:1},Iu=32,Ti=72;function ju(){try{return Jr(localStorage.getItem(eo),Tn)}catch{return{...Tn}}}const Lu=c.memo(function({sessionFile:t,conversations:n,sessions:i,projects:a,activeConversationId:o,panelSend:l,active:u,collapsible:p,onToggleCollapse:E}){const m=je(),f=t,w=Ct("ready"),N=Ct("status"),C=Ct("cwd"),M=C,[W,_]=c.useState(null),[D,I]=c.useState(null),[H,te]=c.useState(""),[ee,le]=Kn(wu,!1),[pe,Q]=Kn(Su,!1),[G,ce]=Kn(Au,!1),[O,B]=c.useState(null),[x,R]=c.useState(null),F=c.useCallback(()=>{R(null),B(null)},[]),v=c.useCallback((P,ye)=>{P.preventDefault(),P.stopPropagation(),B({x:Math.min(P.clientX,window.innerWidth-260),y:Math.min(P.clientY,window.innerHeight-120),scopeId:ye})},[]);c.useEffect(()=>{if(!O)return;const P=he=>{he.target?.closest(".ctx-menu")||F()},ye=he=>{he.key==="Escape"&&F()};return window.addEventListener("mousedown",P,!0),window.addEventListener("keydown",ye),window.addEventListener("blur",F),()=>{window.removeEventListener("mousedown",P,!0),window.removeEventListener("keydown",ye),window.removeEventListener("blur",F)}},[O,F]);const se=c.useCallback((P,ye)=>{if(!ye)return P.filter(Te=>Te.isSubagent&&!Te.isStreaming&&Te.id!==o).length;const he=new Map(P.map(Te=>[Te.id,Te])),be=Te=>{if(Te.id===ye)return(he.get(ye)?.isSubagent??!1)&&!Te.isStreaming&&Te.id!==o;let Ce=Te;const ke=new Set;for(;Ce?.parentId;){if(Ce.parentId===ye)return!0;if(ke.has(Ce.parentId)||(ke.add(Ce.parentId),Ce=he.get(Ce.parentId),!Ce))return!1}return!1};return P.filter(Te=>Te.isSubagent&&!Te.isStreaming&&Te.id!==o&&be(Te)).length},[o]),K=c.useCallback((P,ye)=>{if(!ye)return P.filter(Te=>Te.isSubagent).length;const he=new Map(P.map(Te=>[Te.id,Te])),be=Te=>{if(Te.id===ye)return he.get(ye)?.isSubagent??!1;let Ce=Te;const ke=new Set;for(;Ce?.parentId;){if(Ce.parentId===ye)return!0;if(ke.has(Ce.parentId)||(ke.add(Ce.parentId),Ce=he.get(Ce.parentId),!Ce))return!1}return!1};return P.filter(Te=>Te.isSubagent&&be(Te)).length},[]),xe=c.useCallback((P,ye)=>{if(!ye)return 0;const he=new Map(P.map(Te=>[Te.id,Te])),be=Te=>{let Ce=Te;const ke=new Set;for(;Ce?.parentId;){if(Ce.parentId===ye)return!0;if(ke.has(Ce.parentId)||(ke.add(Ce.parentId),Ce=he.get(Ce.parentId),!Ce))return!1}return!1};return P.filter(Te=>Te.isSubagent&&Te.isStreaming&&be(Te)).length},[]),k=c.useRef(null),[Y,re]=c.useState(()=>ju());c.useEffect(()=>{try{localStorage.setItem(eo,JSON.stringify(Y))}catch{}},[Y]);const de=c.useCallback((P,ye)=>he=>{he.preventDefault();const be=he.currentTarget,Te=he.clientY,Ce={...Y},ke=k.current;if(!ke)return;const y=[{key:"projects",visible:a.length>0,collapsed:ee},{key:"convs",visible:n.length>0,collapsed:pe},{key:"sessions",visible:!0,collapsed:G}].filter(A=>A.visible),b=y.filter(A=>A.collapsed).length,z=y.filter(A=>!A.collapsed).map(A=>A.key).reduce((A,fe)=>A+(Ce[fe]??1),0)||1,ue=Math.max(120,ke.clientHeight-b*Iu);be.classList.add("dragging"),document.body.classList.add("lp-resizing");const Ne=A=>{const{above:fe,below:Ae}=Zr({start:{above:Ce[P]??1,below:Ce[ye]??1},deltaPx:A.clientY-Te,availablePx:ue,totalWeight:z,minAbovePx:Ti,minBelowPx:Ti});re(Fe=>({...Fe,[P]:fe,[ye]:Ae}))},De=()=>{window.removeEventListener("pointermove",Ne),window.removeEventListener("pointerup",De),be.classList.remove("dragging"),document.body.classList.remove("lp-resizing")};window.addEventListener("pointermove",Ne),window.addEventListener("pointerup",De)},[Y,a.length,n.length,ee,pe,G]);c.useEffect(()=>{!u||!w||N!=="open"||C&&(l({type:"list_sessions"}),l({type:"list_projects"}))},[u,w,N,C,l]);const we=P=>{const ye=P.name||P.firstMessage.trim();return ye.length>0?ye:m("emptyChat")},ie=P=>P.split(/[\\/]/).pop()||P,me=(P,ye,he,be,Te)=>{const Ce=W===P;return s.jsx("button",{type:"button",className:`lp-del ${Ce?"confirm":""}`,title:Ce?he:ye,onClick:ke=>{ke.stopPropagation(),Ce?(_(null),be()):_(P)},children:Ce?s.jsx(Tt,{}):Te??s.jsx(et,{})})},X=(P,ye,he,be)=>s.jsxs("button",{type:"button",className:"lp-section-title panel-section-title",onClick:he,title:m(ye?"expandSection":"collapseSection"),children:[s.jsxs("span",{className:"lp-section-title-text",children:[P,be!==void 0?` (${be})`:""]}),s.jsx("span",{className:"lp-section-chevron",children:ye?s.jsx(Ft,{}):s.jsx(Rn,{})})]}),$=[{key:"projects",visible:a.length>0,collapsed:ee},{key:"convs",visible:n.length>0,collapsed:pe},{key:"sessions",visible:!0,collapsed:G}].filter(P=>P.visible).filter(P=>!P.collapsed),Ie=$.reduce((P,ye)=>P+(Y[ye.key]??1),0)||1,Le=P=>$.length<=1?1:(Y[P]??1)/Ie*$.length;return s.jsxs("aside",{ref:k,className:"panel panel-left lp-panel",children:[p&&E&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:m("collapsePanel"),onClick:E,children:s.jsx(Or,{})}),a.length>0&&s.jsxs("div",{className:`lp-section panel-projects ${ee?"collapsed":""}`,style:ee?void 0:{flex:`${Le("projects")} 1 0px`},children:[X(m("recentProjects"),ee,le,a.length),!ee&&s.jsx("div",{className:"lp-section-body projects-scroll",children:a.map(P=>{const ye=M===P.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>_(he=>he===`proj:${P.path}`?null:he),children:[s.jsxs("button",{type:"button",className:`project-item ${ye?"active":""}`,title:P.path,onClick:()=>{ye||l({type:"set_cwd",path:P.path})},children:[s.jsx(Bt,{className:"project-icon"}),s.jsxs("span",{className:"project-info",children:[s.jsx("span",{className:"project-name",children:ie(P.path)}),s.jsx("span",{className:"project-path",children:P.path})]}),s.jsx("span",{className:"project-time",children:Ei(P.lastUsed)})]}),me(`proj:${P.path}`,m("deleteProject"),m("deleteProjectConfirm"),()=>l({type:"remove_project",path:P.path}))]},P.path)})})]}),a.length>0&&!ee&&(n.length>0?!pe:!G)&&s.jsx("div",{className:"lp-sash",onPointerDown:de("projects",n.length>0?"convs":"sessions"),onDoubleClick:()=>re({...Tn}),title:m("dragToResize")}),n.length>0&&s.jsxs("div",{className:`lp-section lp-section-convs panel-convs ${pe?"collapsed":""}`,style:pe?void 0:{flex:`${Le("convs")} 1 0px`},onContextMenu:P=>v(P),children:[X(m("runningConversations"),pe,Q,n.length),!pe&&s.jsx("div",{className:"lp-section-body convs-scroll",children:_u(n,C).map(P=>s.jsxs("div",{className:"panel-conv-group",children:[!P.isCurrent&&s.jsx("div",{className:"panel-conv-group-title",title:P.cwd,children:ie(P.cwd)}),(()=>{const ye=new Map(P.convs.map(y=>[y.id,y])),he=new Map,be=[];for(const y of P.convs)if(y.parentId&&ye.has(y.parentId)){const b=he.get(y.parentId)??[];b.push(y),he.set(y.parentId,b)}else be.push(y);const Te=[],Ce=new Set,ke=(y,b)=>{if(!Ce.has(y.id)){Ce.add(y.id),Te.push({c:y,depth:b});for(const S of he.get(y.id)??[])ke(S,b+1)}};for(const y of be)ke(y,0);for(const y of P.convs)ke(y,0);return Te.map(({c:y,depth:b})=>{const S=o===y.id;return s.jsxs("div",{className:`lp-row${b>0?" lp-sub":""}`,style:b>0?{marginLeft:b*18}:void 0,onMouseLeave:()=>_(z=>z===`conv:${y.id}`?null:z),onContextMenu:z=>v(z,y.id),children:[s.jsxs("button",{type:"button",className:`session-item ${S?"active":""}`,title:`${y.title}${P.isCurrent?"":` — ${P.cwd}`}`,onClick:()=>{S||l({type:"switch_conversation",id:y.id})},children:[s.jsx(rs,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[D===`conv:${y.id}`?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:H,placeholder:m("renameSessionPlaceholder"),onClick:z=>z.stopPropagation(),onChange:z=>te(z.target.value),onKeyDown:z=>{if(z.stopPropagation(),z.key==="Enter"&&!z.nativeEvent.isComposing){const ue=H.trim();ue&&l({type:"rename_conversation",id:y.id,name:ue}),I(null)}else z.key==="Escape"&&I(null)},onBlur:()=>I(null)}):s.jsxs("span",{className:"session-title",children:[y.isSubagent&&s.jsx("span",{className:"subagent-badge",children:m("subagentBadge")}),y.title,y.error&&s.jsx("span",{className:"conv-error-badge",title:m("convErrorBadge",{error:y.error})})]}),D===`conv:${y.id}`?null:s.jsx("span",{className:"session-sub",children:S?m("current"):m("messageCount",{n:y.messageCount})})]}),y.isStreaming&&s.jsx("span",{className:"conv-streaming",title:m("streaming")})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:m("renameSession"),onClick:z=>{z.stopPropagation(),_(null),te(y.title),I(`conv:${y.id}`)},children:s.jsx(gn,{})}),(()=>{const z=`conv:${y.id}`,ue=W===z,Ne=se(n,y.id),De=xe(n,y.id),A=K(n,y.id);return A===0&&!y.isStreaming?me(z,m("dismissConversation"),m("dismissConversationConfirm"),()=>l({type:"dismiss_conversation",id:y.id}),s.jsx(Ke,{})):A===0?me(z,m("dismissConversation"),m("dismissStreamingConfirm"),()=>l({type:"dismiss_conversation",id:y.id,force:!0}),s.jsx(Ke,{})):ue?s.jsxs("span",{className:"lp-del-group",children:[Ne>0&&s.jsx("button",{type:"button",className:"lp-del-opt",title:m("dismissFinishedSubagentsScoped",{n:Ne}),onClick:fe=>{fe.stopPropagation(),_(null),l({type:"dismiss_finished_subagents",parentId:y.id})},children:m("dismissFinishedOnly",{n:Ne})}),s.jsx("button",{type:"button",className:"lp-del-opt danger",title:m("forceDismissTitle",{n:A,m:De}),onClick:fe=>{fe.stopPropagation(),_(null),l({type:"dismiss_conversation",id:y.id,force:!0})},children:m("dismissForceAll",{n:A})})]}):s.jsx("button",{type:"button",className:"lp-del",title:m("dismissConversation"),onClick:fe=>{fe.stopPropagation(),_(z)},children:s.jsx(Ke,{})})})(),y.isStreaming&&s.jsx("span",{className:"lp-row-stalled",title:m("streaming"),style:{position:"absolute",right:28,top:"50%",transform:"translateY(-50%)"}})]},y.id)})})()]},P.cwd))})]}),n.length>0&&!pe&&!G&&s.jsx("div",{className:"lp-sash",onPointerDown:de("convs","sessions"),onDoubleClick:()=>re({...Tn}),title:m("dragToResize")}),s.jsxs("div",{className:`lp-section lp-section-sessions panel-sessions ${G?"collapsed":""}`,style:G?void 0:{flex:`${Le("sessions")} 1 0px`},children:[X(m("historySessions"),G,ce,i.length),!G&&s.jsxs("div",{className:"lp-section-body sessions-scroll",children:[i.length===0&&s.jsx("div",{className:"panel-empty",children:m("noHistory")}),i.map(P=>{const ye=f===P.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>_(he=>he===`sess:${P.path}`?null:he),children:[s.jsxs("button",{type:"button",className:`session-item ${ye?"active":""}`,title:P.path,onClick:()=>{D||ye||l({type:"switch_session",path:P.path})},children:[s.jsx(rs,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[D===P.path?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:H,placeholder:m("renameSessionPlaceholder"),onClick:he=>he.stopPropagation(),onChange:he=>te(he.target.value),onKeyDown:he=>{if(he.stopPropagation(),he.key==="Enter"&&!he.nativeEvent.isComposing){const be=H.trim();be&&l({type:"rename_session",path:P.path,name:be}),I(null)}else he.key==="Escape"&&I(null)},onBlur:()=>I(null)}):s.jsx("span",{className:"session-title",children:we(P)}),D===P.path?null:s.jsxs("span",{className:"session-sub",children:[ye?m("current"):m("messageCount",{n:P.messageCount}),P.source==="tui"&&s.jsx("span",{className:"session-src",title:m("tuiTip"),children:"TUI"})]})]}),s.jsx("span",{className:"session-time",children:Ei(P.modified)})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:m("renameSession"),onClick:he=>{he.stopPropagation(),_(null),te(P.name??""),I(P.path)},children:s.jsx(gn,{})}),me(`sess:${P.path}`,m("deleteSession"),m("deleteSessionConfirm"),()=>l({type:"delete_session",path:P.path}))]},P.path)})]})]}),O&&s.jsxs("div",{className:"ctx-menu",style:{left:O.x,top:O.y},onContextMenu:P=>{P.preventDefault(),P.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",title:se(n,O.scopeId)===0?m("noFinishedSubagents"):void 0,disabled:se(n,O.scopeId)===0,onClick:()=>{O.scopeId?l({type:"dismiss_finished_subagents",parentId:O.scopeId}):l({type:"dismiss_finished_subagents"}),F()},children:[s.jsx(Ke,{}),s.jsx("span",{children:se(n,O.scopeId)===0?m("noFinishedSubagents"):O.scopeId?m("dismissFinishedSubagentsScoped",{n:se(n,O.scopeId)}):m("dismissFinishedSubagents",{n:se(n,O.scopeId)})})]}),O.scopeId&&s.jsxs("button",{type:"button",className:x===O.scopeId?"ctx-item danger armed":"ctx-item danger",title:x===O.scopeId?m("forceDismissConfirm"):m("forceDismissConversation"),onClick:()=>{const P=O.scopeId;x===P?(l({type:"dismiss_conversation",id:P,force:!0}),R(null),F()):R(P)},children:[s.jsx(Ke,{}),s.jsx("span",{children:x===O.scopeId?m("forceDismissConfirm"):m("forceDismissConversation")})]})]})]})});function Ru(e,t){const n=t.assistantMessageEvent,i=e.stats.tokens,a=t.usage!==null?{...i,...t.usage}:i,o=a===i?e.stats:{...e.stats,tokens:a};if(n.type!=="text_delta"&&n.type!=="thinking_delta")return o===e.stats?e:{...e,stats:o};const l=n.delta??"";if(!l)return o===e.stats?e:{...e,stats:o};const u=e.streamingMessage??null,p=u&&u.id===t.messageId?u:{id:t.messageId,content:[]},E=[...p.content],m=n.type==="thinking_delta"?"thinking":"text",f=n.contentIndex??E.length-1;return f>=0&&f<E.length&&E[f].type===m?E[f]=m==="thinking"?{type:"thinking",thinking:(E[f].thinking??"")+l}:{type:"text",text:(E[f].text??"")+l}:E.push(m==="thinking"?{type:"thinking",thinking:l}:{type:"text",text:l}),{...e,stats:o,streamingMessage:{...p,id:t.messageId,content:E}}}function Du(e){const{current:t,source:n,snapshot:i,answered:a}=e;return i&&i.id&&!a.has(i.id)?t?.id===i.id?{changed:!1,question:t,source:n}:{changed:!0,question:i,source:"snapshot"}:!i&&t&&n==="snapshot"?{changed:!0,question:null,source:"live"}:{changed:!1,question:t,source:n}}const ha="pi-web-ui:plugin-data";function Pu(e,t){window.dispatchEvent(new CustomEvent(ha,{detail:{pluginId:e,payload:t}}))}function Ou(e){const t=n=>{const i=n.detail;e(i.pluginId,i.payload)};return window.addEventListener(ha,t),()=>window.removeEventListener(ha,t)}const ss=new Map,fa=new Set,Zt=new Set;let xi=-1;function to(){return[...ss.values()]}function Mu(){const e=to();for(const t of fa)t(e)}function Bu(e){return fa.add(e),e(to()),()=>fa.delete(e)}async function Fu(e,t){t!==xi&&(xi=t,ss.clear(),Zt.clear());const n=new Set(e.map(i=>i.id));for(const i of[...ss.keys()])n.has(i)||ss.delete(i);for(const i of[...Zt])n.has(i)||Zt.delete(i);await Promise.all(e.filter(i=>i.hasClient&&i.view!==!1&&!i.error&&!ss.has(i.id)&&!Zt.has(i.id)).map(async i=>{try{const o=(await import(tt(`/plugins/${encodeURIComponent(i.id)}/client/entry.mjs?e=${t}`))).default;o&&typeof o.mount=="function"?ss.set(i.id,{info:i,module:o}):(Zt.add(i.id),console.error(`[plugin:${i.id}] entry.mjs 缺少 default.mount`))}catch(a){Zt.add(i.id),console.error(`[plugin:${i.id}] 客户端加载失败:`,a)}})),Mu()}function Hu(e,t){return{pluginId:e,send:n=>t({type:"plugin_message",pluginId:e,payload:n}),onData:n=>Ou((i,a)=>{i===e&&n(a)})}}const Uu=15,$u="pi-web-ui:lang";function yi(){try{return(localStorage.getItem($u)??"").trim()}catch{return""}}const Ni="pi-web-ui:locale",Yn=2e5,qu=2e5,Wu="LIVE_OMIT",Ku={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 Yu(){const e=new Map,t=new Map,n=(i,a)=>`${i}:${a}`;return{write(i,a,o){const l=n(i,a),u=e.get(l);if(u&&u.size>0){for(const m of u)try{m.write(o)}catch{}return}const p=t.get(l)??"",E=p.length+o.length>qu?o:p+o;t.set(l,E)},register(i,a,o){const l=n(i,a);let u=e.get(l);u||(u=new Set,e.set(l,u)),u.add(o);const p=t.get(l);if(p){try{o.write(p)}catch{}t.delete(l)}return()=>{const E=e.get(l);E&&(E.delete(o),E.size===0&&e.delete(l)),t.delete(l)}},clear(){e.clear(),t.clear()}}}function ki(e,t){const n=new Set;for(const a of t.messages)a.role==="toolResult"&&a.toolCallId&&n.add(a.toolCallId),a.role==="bashExecution"&&n.add(`bash-${a.id}`);let i=!1;for(const a of e.keys())n.has(a)&&(e.delete(a),i=!0);return i?new Map(e):e}function vi(e,t){if(e.size===0)return e;const n=new Set;for(const a of t.messages)a.role==="toolResult"&&a.toolCallId&&n.add(a.toolCallId);let i=!1;for(const a of e.keys())n.has(a)&&(e.delete(a),i=!0);return i?new Map(e):e}function Gu(e,t){switch(t.type){case"status":return{...e,status:t.status,ready:t.status==="open"?e.ready:!1,terminals:t.status==="closed"?[]:e.terminals};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!==Uu};case"snapshot":return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:ki(e.liveOutputs,t.state),toolStatuses:vi(e.toolStatuses,t.state)};case"snapshot_delta":{const n=e.state,i=t.msg;if(!n||n.conversationId!==i.conversationId||n.rev!==i.baseRev)return e;const a={...n,...i.state,messages:i.appended.length>0?[...n.messages,...i.appended]:n.messages};return{...e,ready:!0,state:a,activeConversationId:a.conversationId,liveOutputs:ki(e.liveOutputs,a),toolStatuses:vi(e.toolStatuses,a)}}case"tool_delta":{const i=(e.liveOutputs.get(t.toolCallId)?.text??"")+t.delta,a=i.length>Yn?`…[${Wu}:${i.length-Yn}]…
|
|
305
|
+
`+i.slice(i.length-Yn):i,o=new Map(e.liveOutputs);return o.set(t.toolCallId,{toolName:t.toolName,text:a}),{...e,liveOutputs:o}}case"message_delta":{const n=e.state;return!n||n.conversationId!==t.msg.conversationId?e:{...e,state:Ru(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(n=>n.id!==t.id)};case"sessions":return{...e,sessions:t.sessions};case"conversations":return{...e,conversations:t.conversations,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"fetch_models_result":return{...e,fetchModelsResult:t.result};case"refresh_provider_result":return{...e,refreshProviderResult: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"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"plugins":return{...e,plugins:t.plugins,pluginsEpoch:t.epoch};case"plugin_catalog":return{...e,pluginCatalog:t.entries,pluginCatalogEpoch:t.epoch};case"dsh_patches":return{...e,dshPatches:{patchDir:t.patchDir,files:t.files}};case"terminal_add":return{...e,terminals:[...e.terminals,t.meta]};case"terminal_remove":return{...e,terminals:e.terminals.filter(n=>n.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(n=>n.id===t.terminalId?{...n,running:!1,exitCode:t.exitCode}:n)};case"terminal_restart":return{...e,terminals:e.terminals.map(n=>n.id===t.terminalId?{...n,running:!0,exitCode:null}:n)};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}}const Ci="pi-web-client-id";let Gn=null;function xn(){if(Gn)return Gn;let e=null;try{e=sessionStorage.getItem(Ci),e||(e=St(),sessionStorage.setItem(Ci,e))}catch{e=e??St()}return Gn=e,e}const so="pi-web-last-cwd";function Vu(){try{return localStorage.getItem(so)}catch{return null}}function zu(e){try{localStorage.setItem(so,e)}catch{}}function Qu(){const e=location.protocol==="https:"?"wss:":"ws:";return vt(`${e}//${location.host}${tt("/ws")}`)}function Xu(){const[e,t]=c.useReducer(Gu,{status:"connecting",ready:!1,state:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:[],conversations:[],activeConversationId:"",projects:[],files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},installResult:null,pathCompletions:[],update:null,updatesAll:null,widgets:[],statuses:[],dialog:null,question:null,commands:[],commandsPath:"",slashCommands:[],terminals:[],terminalActiveId:null,goal:Ku,bgServers:[],settings:null,fetchModelsResult:null,refreshProviderResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,pluginCatalog:[],pluginCatalogEpoch:0,dshPatches:null,protocolMismatch:!1}),n=c.useRef(null),i=c.useRef(Yu()),a=c.useRef(0),o=c.useRef(null),l=c.useRef(!0),u=c.useRef(0),p=c.useRef(0),E=c.useRef(new Map),m=c.useRef(null),f=c.useRef(!1),w=c.useRef(null),N=c.useRef(new Set),C=c.useRef("live"),M=()=>{m.current||(m.current=setTimeout(()=>{m.current=null;const O=n.current;O&&O.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"get_state"}))},300))},W=(O,B)=>{const x=E.current,R=x.get(O);if(R!==void 0&&B!==R+1){const F=ce.current.chat,v=F.activeConversationId||F.state?.conversationId;O===v&&M()}x.set(O,B)},_=c.useCallback((O,B)=>{const x=++p.current;t({type:"notice",notice:{id:x,level:O,text:B}})},[]),D=c.useCallback(O=>{const B=n.current;if(B&&B.readyState===WebSocket.OPEN){if(O.type==="check_updates_all"&&O.force===!0&&t({type:"updates_check_started"}),B.send(JSON.stringify(O)),O.type==="question_answer"){if(N.current.add(O.id),N.current.size>64){const x=N.current.values().next().value;x!==void 0&&N.current.delete(x)}C.current="live",t({type:"question",question:null})}return!0}return!1},[]),I=c.useCallback(O=>{const B=Du({current:ce.current.chat.question,source:C.current,snapshot:O,answered:N.current});B.changed&&(C.current=B.source,t({type:"question",question:B.question}))},[]);ku(D);const H=c.useCallback(()=>{if(!l.current)return;t({type:"status",status:"connecting"});const O=new WebSocket(Qu());n.current=O,O.onopen=()=>{n.current===O&&(t({type:"status",status:"open"}),a.current=0,u.current=Date.now(),O.send(JSON.stringify({type:"hello",clientId:xn(),locale:yi()})))},O.onmessage=B=>{if(n.current!==O)return;u.current=Date.now();let x;try{x=JSON.parse(B.data)}catch{return}switch(x.type){case"ready":gi({engine:x.engine??"pi",managed:!!x.managed,tabs:x.tabs,appVersion:x.appVersion,serverVersion:x.serverVersion,service:x.service}),t({type:"ready",serverVersion:x.serverVersion,protocolVersion:x.protocolVersion,engine:x.engine,appVersion:x.appVersion,managed:x.managed,tabs:x.tabs,service:x.service}),O.send(JSON.stringify({type:"get_state"})),O.send(JSON.stringify({type:"list_files"})),O.send(JSON.stringify({type:"list_models"})),O.send(JSON.stringify({type:"list_commands"})),O.send(JSON.stringify({type:"get_commands"})),x.managed||(O.send(JSON.stringify({type:"check_update"})),O.send(JSON.stringify({type:"check_updates_all"})));break;case"snapshot":E.current=new Map,t({type:"snapshot",state:x.state}),I(x.state.pendingQuestion);break;case"snapshot_delta":{const R=ce.current.chat.state;(!R||R.conversationId!==x.conversationId||R.rev!==x.baseRev)&&M(),t({type:"snapshot_delta",msg:x}),I(x.state.pendingQuestion);break}case"tool_delta":W(x.conversationId,x.seq),t({type:"tool_delta",toolCallId:x.toolCallId,toolName:x.toolName,delta:x.delta});break;case"tool_status":t({type:"tool_status",status:x});break;case"message_delta":{W(x.conversationId,x.seq),t({type:"message_delta",msg:x});break}case"notice":{const R=++p.current;t({type:"notice",notice:{id:R,level:x.level,text:x.text,textEn:x.textEn}});break}case"sessions":t({type:"sessions",sessions:x.sessions});break;case"conversations":t({type:"conversations",conversations:x.conversations,activeId:x.activeId});break;case"projects":t({type:"projects",projects:x.projects});break;case"files":t({type:"files",files:x});break;case"file_changed":t({type:"file_changed",path:x.path});break;case"file_content":t({type:"file_content",content:x});break;case"models":t({type:"models",models:x.models,loading:!1});break;case"models_config":t({type:"models_config",providers:x.providers});break;case"providers_status":t({type:"providers_status",providers:x.providers});break;case"provider_keys":t({type:"provider_keys",keys:x.keys});break;case"fetch_models_result":t({type:"fetch_models_result",result:{reqId:x.reqId,ok:x.ok,models:x.models,error:x.error}});break;case"refresh_provider_result":t({type:"refresh_provider_result",result:{reqId:x.reqId,ok:x.ok,added:x.added,total:x.total,error:x.error}});break;case"clone_provider_result":t({type:"clone_provider_result",result:{reqId:x.reqId,ok:x.ok,config:x.config,configs:x.configs,error:x.error}});break;case"scm_data":t({type:"scm_data",data:x});break;case"search_files_result":t({type:"file_search_result",result:{reqId:x.reqId,ok:x.ok,results:x.results,truncated:x.truncated}});break;case"session_search_results":t({type:"session_search_result",result:{reqId:x.reqId,ok:x.ok,results:x.results}});break;case"scm_changed":t({type:"scm_changed"});break;case"install_result":t({type:"install_result",result:x});break;case"path_completions":t({type:"path_completions",completions:x.completions});break;case"update_status":t({type:"update_status",status:x});break;case"update_status_all":t({type:"update_status_all",items:x.items});break;case"widgets":t({type:"widgets",widgets:x.widgets});break;case"statuses":t({type:"statuses",statuses:x.statuses});break;case"dialog":t({type:"dialog",dialog:{id:x.id,kind:x.kind,title:x.title,args:x.args}});break;case"dialog_closed":t({type:"dialog",dialog:null});break;case"question_pending":C.current="live",t({type:"question",question:{id:x.id,...x.deadline!==void 0?{deadline:x.deadline}:{},questions:x.questions}});break;case"page_request":{(async()=>{const R=window.__piWebUiHost;let F;if(!R?.pageCall)F={ok:!1,error:"宿主页面桥不可用(页面版本过旧?)—— 刷新本页后再试"};else try{F=await R.pageCall({op:x.op,...x.args===void 0?{}:{args:x.args},...x.target?{target:x.target}:{},timeoutMs:x.timeoutMs})}catch(v){F={ok:!1,error:v instanceof Error?v.message:String(v)}}D({type:"page_response",id:x.id,ok:F.ok===!0,...F.ok===!0?F.result===void 0?{}:{result:F.result}:{error:F.error??"页面操作失败"}})})();break}case"terminal_output":i.current.write(x.conversationId??ce.current.chat.activeConversationId,x.terminalId,x.data);break;case"terminal_exit":t({type:"terminal_exit",conversationId:x.conversationId,terminalId:x.terminalId,exitCode:x.exitCode});break;case"terminal_list":t({type:"terminal_list",conversationId:x.conversationId,terminals:x.terminals});break;case"commands":t({type:"commands",commands:x.commands,path:x.path});break;case"slash_commands":t({type:"slash_commands",commands:x.commands});break;case"goal_status":t({type:"goal_status",status:x.status});break;case"settings_state":t({type:"settings",settings:x.settings});break;case"bg_servers":t({type:"bg_servers",servers:x.servers});break;case"plugins":t({type:"plugins",plugins:x.plugins,epoch:x.epoch});break;case"plugin_catalog":t({type:"plugin_catalog",entries:x.entries,epoch:x.epoch});break;case"dsh_patches":t({type:"dsh_patches",patchDir:x.patchDir,files:x.files});break;case"plugin_data":Pu(x.pluginId,x.payload);break}},O.onclose=()=>{if(n.current===O&&(n.current=null),i.current.clear(),!l.current||n.current&&n.current!==O)return;t({type:"status",status:"closed"});const B=Math.min(1e3*2**a.current,1e4);a.current+=1,o.current=setTimeout(()=>{o.current=null,H()},B)},O.onerror=()=>{}},[]);c.useEffect(()=>{const O=B=>{const x=B.detail??yi();x&&D({type:"set_locale",locale:x})};return window.addEventListener(Ni,O),()=>window.removeEventListener(Ni,O)},[D]),c.useEffect(()=>{l.current=!0,H();const O=setInterval(()=>{if(!l.current)return;const B=n.current;B&&B.readyState===WebSocket.OPEN&&Date.now()-u.current>3e4&&B.close()},5e3);return()=>{l.current=!1,clearInterval(O),o.current&&(clearTimeout(o.current),o.current=null),n.current?.close(),n.current=null}},[H]),c.useEffect(()=>{const O=e.state?.cwd;if(O){if(!f.current){f.current=!0;const B=Vu();if(B&&B!==O){D({type:"set_cwd",path:B});return}}w.current!==O&&(w.current=O,zu(O))}},[e.state?.cwd,D]),c.useEffect(()=>{gi({ready:e.ready,status:e.status,cwd:e.state?.cwd??""})},[e.ready,e.status,e.state?.cwd]);const te=c.useCallback(O=>t({type:"dismiss_notice",id:O}),[]),ee=c.useCallback(O=>t({type:"terminal_add",meta:O}),[]),le=c.useCallback(O=>t({type:"terminal_remove",id:O}),[]),pe=c.useCallback(O=>t({type:"terminal_restart",terminalId:O}),[]),Q=c.useCallback(O=>t({type:"terminal_active",id:O}),[]),G=c.useCallback((O,B,x)=>i.current.register(O,B,x),[]),ce=c.useRef({chat:e,send:D,pushNotice:_,dismissNotice:te,terminal:{create:ee,close:le,register:G,restart:pe,select:Q}});return ce.current={chat:e,send:D,pushNotice:_,dismissNotice:te,terminal:{create:ee,close:le,register:G,restart:pe,select:Q}},ce.current}const Ju=200*1024*1024,Zu=/windows/i.test(navigator.userAgent),ed=/[<>:"/\\|?*\u0000-\u001f]/g,td=/[. ]+$/,sd=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function nd(e){const t=e.replace(ed,"_").replace(td,"");return t?sd.test(t)?`_${t}`:t:"_"}function _i(e,t=!0){const n=new URLSearchParams({clientId:xn(),path:e,...t?{download:"1"}:{}});return vt(tt(`/api/file?${n}`))}const no="FILE_NOT_FOUND";async function ad(e,t){const n=Zu?nd(t):t;try{const i=await fetch(_i(e));if(!i.ok)return{ok:!1,cancelled:!1,error:await i.text().catch(()=>"")||(i.status===404?no:`HTTP ${i.status}`)};if(Number(i.headers.get("content-length")??"0")>Ju)return window.location.assign(_i(e)),{ok:!0};const o=await i.blob();return window.showSaveFilePicker&&window.isSecureContext?id(o,n):ga(o,n)}catch(i){return{ok:!1,cancelled:!1,error:i instanceof Error?i.message:String(i)}}}async function id(e,t){let n;const i=window.showSaveFilePicker;if(!i)return ga(e,t);try{n=await i({suggestedName:t})}catch(a){return a instanceof DOMException&&a.name==="AbortError"?{ok:!1,cancelled:!0}:ga(e,t)}try{const a=await n.createWritable();return await a.write(e),await a.close(),{ok:!0}}catch(a){return{ok:!1,cancelled:!1,error:a instanceof Error?a.message:String(a)}}}function ga(e,t){const n=URL.createObjectURL(e),i=document.createElement("a");return i.href=n,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}const fs="@root",wi="pi-web-ui:rp-sizes",Vn={files:4,widgets:1},Si=120,Ai=56,rd=c.memo(function({files:t,fileChanged:n,widgets:i,panelSend:a,onAttach:o,onPreview:l,onNotice:u,collapsible:p,onToggleCollapse:E}){const m=je(),f=Ct("cwd"),[w,N]=c.useState(""),[C,M]=c.useState(null),[W,_]=c.useState(!1),D=c.useRef(null),I=c.useRef(null),[H,te]=c.useState(()=>{try{return Jr(localStorage.getItem(wi),Vn)}catch{return{...Vn}}});c.useEffect(()=>{try{localStorage.setItem(wi,JSON.stringify(H))}catch{}},[H]);const ee=i.some(y=>y.lines.length>0),le=c.useCallback(y=>{y.preventDefault();const b=D.current;if(!b)return;const S=y.currentTarget,z=y.clientY,ue={above:H.files,below:H.widgets},Ne=Math.max(120,b.clientHeight-(I.current?.offsetHeight??32));S.classList.add("dragging"),document.body.classList.add("rp-resizing");const De=fe=>{const{above:Ae,below:Fe}=Zr({start:ue,deltaPx:fe.clientY-z,availablePx:Ne,totalWeight:ue.above+ue.below,minAbovePx:Si,minBelowPx:Ai});te({files:Ae,widgets:Fe})},A=()=>{window.removeEventListener("pointermove",De),window.removeEventListener("pointerup",A),S.classList.remove("dragging"),document.body.classList.remove("rp-resizing")};window.addEventListener("pointermove",De),window.addEventListener("pointerup",A)},[H.files,H.widgets]),[pe,Q]=c.useState(null),G=c.useRef(""),ce=c.useRef(null),O=c.useRef(null),[B,x]=c.useState(null),R=c.useRef(null);c.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]);const F=c.useCallback(y=>{x(y),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>x(null),1200)},[]),v=y=>{try{const b=document.createElement("textarea");b.value=y,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select();const S=document.execCommand("copy");return document.body.removeChild(b),S}catch{return!1}},se=c.useCallback((y,b)=>{if(!y)return;const S=()=>F(b),z=()=>u("error",m("slashCopyFailed")),ue=navigator;ue.clipboard?.writeText?ue.clipboard.writeText(y).then(S,()=>{v(y)?S():z()}):v(y)?S():z()},[F,u,m]),K=c.useCallback(y=>{if(!y)return f;if(/^[A-Za-z]:$/.test(y))return`${y}/`;if(y.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(y))return y;const b=f.replace(/\\/g,"/").replace(/\/+$/,"");return b?`${b}/${y}`:y},[f]),xe=c.useCallback(y=>!y||y===fs?null:y.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(y)?y:`${f.replace(/\\/g,"/").replace(/\/+$/,"")}/${y}`,[f]),k=c.useCallback((y,b,S)=>{y.preventDefault(),G.current=b,ce.current=S??null,Q({x:Math.min(y.clientX,window.innerWidth-220),y:Math.min(y.clientY,window.innerHeight-90)})},[]),Y=c.useCallback(()=>Q(null),[]);c.useEffect(()=>{if(!pe)return;const y=z=>{z.target?.closest(".ctx-menu")||Y()},b=z=>{z.key==="Escape"&&Y()};window.addEventListener("mousedown",y,!0),window.addEventListener("keydown",b);const S=()=>Y();return window.addEventListener("blur",S),()=>{window.removeEventListener("mousedown",y,!0),window.removeEventListener("keydown",b),window.removeEventListener("blur",S)}},[pe,Y]);const re=c.useCallback(()=>{const y=ce.current;Y(),y&&a({type:"set_cwd",path:y.path})},[Y,a]),de=c.useCallback(()=>{Y(),O.current&&(O.current.value=""),O.current?.click()},[Y]),we=c.useCallback((y,b)=>{for(const S of b){const z=new FileReader;z.onload=()=>{const ue=z.result,Ne=ue.slice(ue.indexOf(",")+1);Ne&&a({type:"upload_file",dirPath:y,name:S.name,data:Ne})},z.readAsDataURL(S)}},[a]),ie=c.useCallback(y=>{we(G.current,Array.from(y.target.files??[]))},[we]),me=c.useRef(null),X=y=>Array.from(y.dataTransfer?.types??[]).includes("Files"),oe=c.useCallback(()=>{me.current?.querySelectorAll(".file-item.drop-target").forEach(y=>y.classList.remove("drop-target")),me.current?.classList.remove("drop-root")},[]),$=c.useCallback(y=>{if(oe(),y==null)return;const b=me.current?.querySelector(`.file-item[data-path="${CSS.escape(y)}"]`);b?b.classList.add("drop-target"):me.current?.classList.add("drop-root")},[oe]),Ie=y=>{const b=y instanceof Element?y.closest(".file-item"):null;return b?.dataset.type==="dir"?b.dataset.path??w:w},Le=c.useCallback(()=>{const y=document.querySelector(".app");y&&y.dispatchEvent(new DragEvent("dragleave",{bubbles:!0}))},[]),P=1e4,ye=c.useRef(0),he=c.useRef(void 0),be=c.useCallback((y,b)=>{const S=++ye.current;N(y),b?.silent||_(!0),a({type:"list_files",path:y===""?void 0:y})||ye.current===S&&_(!1)},[a]);c.useEffect(()=>{t&&t.path===w&&_(!1)},[t,w]),c.useEffect(()=>{if(f!==he.current){he.current=f,be("",{silent:!0});return}const y=setInterval(()=>{document.visibilityState!=="hidden"&&be(w,{silent:!0})},P);return()=>clearInterval(y)},[f,w,be]),c.useEffect(()=>{n&&n.path===w&&be(w,{silent:!0})},[n,w,be]);const Te=y=>be(y),Ce=()=>{t?.parent!==null&&t?.parent!==void 0&&be(t.parent)},ke=(()=>{if(w===""||w===fs)return[];const y=w.split("/").filter(b=>!!b&&b!==fs);return w.startsWith("/")?y.map((b,S)=>({label:S===0?"/":y[S],path:"/"+y.slice(0,S+1).join("/")})):y.map((b,S)=>({label:y[S],path:y.slice(0,S+1).join("/")}))})();return s.jsxs("aside",{className:"panel panel-right",ref:D,children:[p&&E&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:m("collapsePanel"),onClick:E,children:s.jsx(Pr,{})}),s.jsxs("div",{className:"panel-crumbs",ref:I,children:[s.jsx("button",{type:"button",className:`crumb ${w===""?"active":""}`,onClick:()=>be(""),children:m("rootDir")}),s.jsx("button",{type:"button",className:`crumb ${w===fs?"active":""}`,title:m("computer"),onClick:()=>be(fs),children:"💻"}),ke.map(y=>s.jsxs("span",{className:"crumb-seg",children:[s.jsx(zt,{}),s.jsx("button",{type:"button",className:`crumb ${y.path===w?"active":""}`,onClick:()=>be(y.path),children:y.label})]},y.path))]}),s.jsxs("div",{ref:me,className:"panel-body",style:ee?{flexGrow:H.files,minHeight:Si}:void 0,onContextMenu:y=>k(y,w),onDragOver:y=>{X(y)&&(y.preventDefault(),y.stopPropagation(),y.dataTransfer.dropEffect="copy",Le(),$(Ie(y.target)))},onDragLeave:y=>{y.relatedTarget&&y.currentTarget.contains(y.relatedTarget)||oe()},onDrop:y=>{if(oe(),!X(y))return;y.preventDefault(),y.stopPropagation(),Le();const b=Array.from(y.dataTransfer?.files??[]);if(b.length===0){u("warning",m("foldersNotSupported"));return}we(Ie(y.target),b)},onDragEnd:oe,children:[s.jsx("input",{ref:O,type:"file",multiple:!0,hidden:!0,onChange:ie}),W&&s.jsx("div",{className:"panel-empty",children:m("loading")}),!W&&t&&t.path===w&&s.jsxs(s.Fragment,{children:[t.parent!=null&&s.jsxs("button",{type:"button",className:"file-item dir",onClick:Ce,children:[s.jsx(Bt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:".."})]}),t.entries.map(y=>y.type==="dir"?s.jsxs("div",{className:"file-item dir","data-type":"dir","data-path":y.path,onContextMenu:b=>{b.stopPropagation();const S=xe(y.path);k(b,y.path,S?{path:S,name:y.name}:null)},children:[s.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>Te(y.path),children:[s.jsx(Bt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:y.name})]}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":m("linkFolderTip"),"aria-label":m("linkFolderTip"),onClick:()=>o(y.path,y.name,"reference",!0),children:s.jsx(oa,{})}),s.jsx("button",{type:"button",className:`file-attach copy${B===`name:${y.path}`?" copied":""}`,"data-tip":m("copyName"),"aria-label":m("copyName"),onClick:()=>se(y.name,`name:${y.path}`),children:B===`name:${y.path}`?s.jsx(Tt,{}):s.jsx(wt,{})}),s.jsx("button",{type:"button",className:`file-attach copy${B===`path:${y.path}`?" copied":""}`,"data-tip":m("copyPath"),"aria-label":m("copyPath"),onClick:()=>se(K(y.path),`path:${y.path}`),children:B===`path:${y.path}`?s.jsx(Tt,{}):s.jsx(ai,{})})]},y.path):s.jsxs("div",{className:"file-item file","data-type":"file","data-path":y.path,onContextMenu:b=>{b.stopPropagation(),k(b,w)},children:[s.jsxs("button",{type:"button",className:"file-name",title:`${y.path} — ${m("previewFile")}`,onClick:()=>l(y.path,y.name),children:[s.jsx(jc,{className:"file-icon"}),s.jsx("span",{className:"file-name-text",children:y.name})]}),s.jsx("button",{type:"button",className:"file-attach download","data-tip":m("downloadFile"),onClick:()=>{ad(y.path,y.name).then(b=>{b.ok||b.cancelled||u("error",m("downloadFailed",{error:b.error===no?m("fileNotFoundShort"):b.error}))})},children:s.jsx(Yt,{})}),s.jsx("button",{type:"button",className:"file-attach inline","data-tip":m("attachInlineTip"),onClick:()=>o(y.path,y.name,"inline"),children:s.jsx(dt,{})}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":m("referenceTip"),"aria-label":m("referenceTip"),onClick:()=>o(y.path,y.name,"reference"),children:s.jsx(oa,{})}),s.jsx("button",{type:"button",className:`file-attach copy${B===`name:${y.path}`?" copied":""}`,"data-tip":m("copyName"),"aria-label":m("copyName"),onClick:()=>se(y.name,`name:${y.path}`),children:B===`name:${y.path}`?s.jsx(Tt,{}):s.jsx(wt,{})}),s.jsx("button",{type:"button",className:`file-attach copy${B===`path:${y.path}`?" copied":""}`,"data-tip":m("copyPath"),"aria-label":m("copyPath"),onClick:()=>se(K(y.path),`path:${y.path}`),children:B===`path:${y.path}`?s.jsx(Tt,{}):s.jsx(ai,{})})]},y.path)),t.truncated&&s.jsx("div",{className:"panel-empty files-truncated",children:m("filesTruncated")})]}),!W&&!t&&s.jsx("div",{className:"panel-empty",children:m("noFiles")})]}),ee&&s.jsx("div",{className:"rp-sash",onPointerDown:le,onDoubleClick:()=>te({...Vn}),title:m("dragToResize")}),ee&&s.jsx("div",{className:"panel-widgets",style:{flexGrow:H.widgets,minHeight:Ai},children:i.filter(y=>y.lines.length>0).map(y=>s.jsxs("div",{className:"widget",children:[s.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:m("widgetExpand"),onClick:()=>M(y.key),children:[s.jsx("span",{children:y.key}),s.jsx(vc,{})]}),s.jsx("pre",{className:"widget-lines",children:y.lines.join(`
|
|
306
|
+
`)})]},y.key))}),C&&(()=>{const y=i.find(b=>b.key===C);return y?s.jsx("div",{className:"modal-backdrop",onClick:()=>M(null),children:s.jsxs("div",{className:"widget-expand",onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"widget-expand-head",children:[s.jsx("span",{className:"widget-expand-title",children:y.key}),s.jsx("button",{type:"button",className:"btn",title:m("close"),onClick:()=>M(null),children:s.jsx(Ke,{})})]}),s.jsx("pre",{className:"widget-expand-lines",children:y.lines.join(`
|
|
307
|
+
`)})]})}):null})(),pe&&s.jsxs("div",{className:"ctx-menu",style:{left:pe.x,top:pe.y},onContextMenu:y=>{y.preventDefault(),y.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",onClick:de,children:[s.jsx(jr,{}),G.current===w?m("uploadToCurrentDir"):m("uploadToFolder")]}),ce.current&&s.jsxs("button",{type:"button",className:"ctx-item",onClick:re,children:[s.jsx(Bt,{}),m("openAsProject")]})]})]})});var ao=wr();function od(e){Kl(e,[/\r?\n|\r/g,ld])}function ld(){return{type:"break"}}function cd(){return function(e){od(e)}}function ud(e){const t=String(e),n=[];return{toOffset:a,toPoint:i};function i(o){if(typeof o=="number"&&o>-1&&o<=t.length){let l=0;for(;;){let u=n[l];if(u===void 0){const p=Ii(t,n[l-1]);u=p===-1?t.length+1:p+1,n[l]=u}if(u>o)return{line:l+1,column:o-(l>0?n[l-1]:0)+1,offset:o};l++}}}function a(o){if(o&&typeof o.line=="number"&&typeof o.column=="number"&&!Number.isNaN(o.line)&&!Number.isNaN(o.column)){for(;n.length<o.line;){const u=n[n.length-1],p=Ii(t,u),E=p===-1?t.length+1:p+1;if(u===E)break;n.push(E)}const l=(o.line>1?n[o.line-2]:0)+o.column-1;if(l<n[o.line-1])return l}}}function Ii(e,t){const n=e.indexOf("\r",t),i=e.indexOf(`
|
|
308
|
+
`,t);return i===-1?n:n===-1||n+1===i?i:n<i?n:i}const io={}.hasOwnProperty,dd=Object.prototype;function pd(e,t){const n=t||{};return Da({file:n.file||void 0,location:!1,schema:n.space==="svg"?jn:La,verbose:n.verbose||!1},e)}function Da(e,t){let n;switch(t.nodeName){case"#comment":{const i=t;return n={type:"comment",value:i.data},Xs(e,i,n),n}case"#document":case"#document-fragment":{const i=t,a="mode"in i?i.mode==="quirks"||i.mode==="limited-quirks":!1;if(n={type:"root",children:ro(e,t.childNodes),data:{quirksMode:a}},e.file&&e.location){const o=String(e.file),l=ud(o),u=l.toPoint(0),p=l.toPoint(o.length);n.position={start:u,end:p}}return n}case"#documentType":{const i=t;return n={type:"doctype"},Xs(e,i,n),n}case"#text":{const i=t;return n={type:"text",value:i.value},Xs(e,i,n),n}default:return n=md(e,t),n}}function ro(e,t){let n=-1;const i=[];for(;++n<t.length;){const a=Da(e,t[n]);i.push(a)}return i}function md(e,t){const n=e.schema;e.schema=t.namespaceURI===Wt.svg?jn:La;let i=-1;const a={};for(;++i<t.attrs.length;){const u=t.attrs[i],p=(u.prefix?u.prefix+":":"")+u.name;io.call(dd,p)||(a[p]=u.value)}const l=(e.schema.space==="svg"?Yl:Gl)(t.tagName,a,ro(e,t.childNodes));if(Xs(e,t,l),l.tagName==="template"){const u=t,p=u.sourceCodeLocation,E=p&&p.startTag&&ns(p.startTag),m=p&&p.endTag&&ns(p.endTag),f=Da(e,u.content);E&&m&&e.file&&(f.position={start:E.end,end:m.start}),l.content=f}return e.schema=n,l}function Xs(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const i=hd(e,n,t.sourceCodeLocation);i&&(e.location=!0,n.position=i)}}function hd(e,t,n){const i=ns(n);if(t.type==="element"){const a=t.children[t.children.length-1];if(i&&!n.endTag&&a&&a.position&&a.position.end&&(i.end=Object.assign({},a.position.end)),e.verbose){const o={};let l;if(n.attrs)for(l in n.attrs)io.call(n.attrs,l)&&(o[Nr(e.schema,l).property]=ns(n.attrs[l]));aa(n.startTag);const u=ns(n.startTag),p=n.endTag?ns(n.endTag):void 0,E={opening:u};p&&(E.closing=p),E.properties=o,t.data={position:E}}}return i}function ns(e){const t=ji({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=ji({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function ji(e){return e.line&&e.column?e:void 0}const fd={},gd={}.hasOwnProperty,oo=kr("type",{handlers:{root:Ed,element:kd,text:yd,comment:Nd,doctype:xd}});function bd(e,t){const i=(t||fd).space;return oo(e,i==="svg"?jn:La)}function Ed(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=Pa(e.children,n,t),us(e,n),n}function Td(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=Pa(e.children,n,t),us(e,n),n}function xd(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return us(e,t),t}function yd(e){const t={nodeName:"#text",value:e.value,parentNode:null};return us(e,t),t}function Nd(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return us(e,t),t}function kd(e,t){const n=t;let i=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=jn);const a=[];let o;if(e.properties){for(o in e.properties)if(o!=="children"&&gd.call(e.properties,o)){const p=vd(i,o,e.properties[o]);p&&a.push(p)}}const l=i.space,u={nodeName:e.tagName,tagName:e.tagName,attrs:a,namespaceURI:Wt[l],childNodes:[],parentNode:null};return u.childNodes=Pa(e.children,u,i),us(e,u),e.tagName==="template"&&e.content&&(u.content=Td(e.content,i)),u}function vd(e,t,n){const i=Nr(e,t);if(n===!1||n===null||n===void 0||typeof n=="number"&&Number.isNaN(n)||!n&&i.boolean)return;Array.isArray(n)&&(n=i.commaSeparated?Vl(n):zl(n));const a={name:i.attribute,value:n===!0?"":String(n)};if(i.space&&i.space!=="html"&&i.space!=="svg"){const o=a.name.indexOf(":");o<0?a.prefix="":(a.name=a.name.slice(o+1),a.prefix=i.attribute.slice(0,o)),a.namespace=Wt[i.space]}return a}function Pa(e,t,n){let i=-1;const a=[];if(e)for(;++i<e.length;){const o=oo(e[i],n);o.parentNode=t,a.push(o)}return a}function us(e,t){const n=e.position;n&&n.start&&n.end&&(aa(typeof n.start.offset=="number"),aa(typeof n.end.offset=="number"),t.sourceCodeLocation={startLine:n.start.line,startCol:n.start.column,startOffset:n.start.offset,endLine:n.end.line,endCol:n.end.column,endOffset:n.end.offset})}const Cd=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],_d=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),qe="�";var h;(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(h||(h={}));const at={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function lo(e){return e>=55296&&e<=57343}function wd(e){return e>=56320&&e<=57343}function Sd(e,t){return(e-55296)*1024+9216+t}function co(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function uo(e){return e>=64976&&e<=65007||_d.has(e)}var U;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(U||(U={}));const Ad=65536;class Id{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=Ad,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,n){const{line:i,col:a,offset:o}=this,l=a+n,u=o+n;return{code:t,startLine:i,endLine:i,startCol:l,endCol:l,startOffset:u,endOffset:u}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const n=this.html.charCodeAt(this.pos+1);if(wd(n))return this.pos++,this._addGap(),Sd(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,h.EOF;return this._err(U.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,n){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=n}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,n){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(n)return this.html.startsWith(t,this.pos);for(let i=0;i<t.length;i++)if((this.html.charCodeAt(this.pos+i)|32)!==t.charCodeAt(i))return!1;return!0}peek(t){const n=this.pos+t;if(n>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,h.EOF;const i=this.html.charCodeAt(n);return i===h.CARRIAGE_RETURN?h.LINE_FEED:i}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,h.EOF;let t=this.html.charCodeAt(this.pos);return t===h.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,h.LINE_FEED):t===h.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,lo(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===h.LINE_FEED||t===h.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){co(t)?this._err(U.controlCharacterInInputStream):uo(t)&&this._err(U.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var Oe;(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})(Oe||(Oe={}));function po(e,t){for(let n=e.attrs.length-1;n>=0;n--)if(e.attrs[n].name===t)return e.attrs[n].value;return null}const jd=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏઑඡ༉༦ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲϏϢϸontourIntegraìȹoɴ\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲy;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱còJTabcdfgorstרׯؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ߂ߐĀiyޱrc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣসে্ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४ĀnrࢃgleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpwਖਛgȀLRlr৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼અઋp;椅y;䐜Ādl੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑඞcy;䐊cute;䅃ƀaeyહાron;䅇dil;䅅;䐝ƀgswે૰ativeƀMTV૨ediumSpace;怋hiĀcn૦ëeryThiîtedĀGLଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷreak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater;EFGLSTஶஷ扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨setĀ;Eೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂෛ෧ขภยา฿ไlig;䅒cute耻Ó䃓Āiyීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲcr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬืde耻Õ䃕es;樷ml耻Ö䃖erĀBP๋Āar๐๓r;怾acĀek๚;揞et;掴arenthesis;揜ҀacfhilorsງຊຏຒດຝະrtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ檻cedesȀ;EST່້扺qual;檯lantEqual;扼ilde;找me;怳Ādpuct;戏ortionĀ;aȥl;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL憒ar;懥eftArrow;懄eiling;按oǵ\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄቕቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHcቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗ĀeiቻDzኀ\0ኇefore;戴a;䎘ĀcnኘkSpace;쀀 Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtèa;䎖r;愨pf;愤cr;쀀𝒵ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒;Eaeiopᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;eᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;eᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰᝃᝈ០៦ᠹᡐᜍ᥈ᥰot;櫭ĀcrᛶkȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀakoᠦᠵĀcn៲ᠣkƀlst֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ;敛;敘;攘;攔;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģbar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;elƀ;bhᥨᥩᥫ䁜;槅sub;柈ŬᥴlĀ;e怢t»pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭒\0᯽\0ᰌƀcprᦲute;䄇̀;abcdsᦿᧀᧄ᧕᧙戩nd;橄rcup;橉Āau᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r;Ecefms᩠ᩢᩫ᪤᪪旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ\0\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»eóɍǧ\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯delprvw᭠᭬᭷ᮂᮬᯔarrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;pᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰻᰿ᱝᱩᱵᲞᲬᲷᴍᵻᶑᶫᶻ᷆᷍ròar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂᳖᳜᳠mƀ;oș᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄĀDoḆᴴoôĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»ṺƀaeiἒἚls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧\0耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₥₰₴⃰℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽ƀ;qsؾٌlanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqrⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0proør;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼ròòΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonóquigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roøurĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨íistĀ;sடr;쀀𝔫ȀEest⩦⩹⩼ƀ;qs⩭ƀ;qs⩴lanôií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast⭕⭚⭟lleìl;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖchimpqu⮽⯍⯙⬄⯤⯯Ȁ;cerല⯆ഷ⯉uå;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭ååഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñĀ;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;cⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācrir;榿;쀀𝔬ͯ\0\0\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕⶥⶨrò᪀Āirⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔǒr;榷rp;榹;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ\0\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ脀¶;l䂶leìЃɩ\0\0m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳ᤈ⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t⾴ïrel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⋢⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔ABHabcdefhilmnoprstuxけさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstwガクシスゼゾダッデナp;極Ā;fゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ìâヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘rrowĀ;tㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowóarpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓ròaòՑ;怏oustĀ;a㈞掱che»mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì耻䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;qኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫwar;椪lig耻ß䃟㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rëƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproøim»ኬsðኞĀas㚺㚮ðrn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈadempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xôheadĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roðtré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜtré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),Ld=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]);function Rd(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=Ld.get(e))!==null&&t!==void 0?t:e}var Je;(function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"})(Je||(Je={}));const Dd=32;var Ot;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Ot||(Ot={}));function ba(e){return e>=Je.ZERO&&e<=Je.NINE}function Pd(e){return e>=Je.UPPER_A&&e<=Je.UPPER_F||e>=Je.LOWER_A&&e<=Je.LOWER_F}function Od(e){return e>=Je.UPPER_A&&e<=Je.UPPER_Z||e>=Je.LOWER_A&&e<=Je.LOWER_Z||ba(e)}function Md(e){return e===Je.EQUALS||Od(e)}var Xe;(function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"})(Xe||(Xe={}));var Nt;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Nt||(Nt={}));class Bd{constructor(t,n,i){this.decodeTree=t,this.emitCodePoint=n,this.errors=i,this.state=Xe.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Nt.Strict}startEntity(t){this.decodeMode=t,this.state=Xe.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case Xe.EntityStart:return t.charCodeAt(n)===Je.NUM?(this.state=Xe.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=Xe.NamedEntity,this.stateNamedEntity(t,n));case Xe.NumericStart:return this.stateNumericStart(t,n);case Xe.NumericDecimal:return this.stateNumericDecimal(t,n);case Xe.NumericHex:return this.stateNumericHex(t,n);case Xe.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|Dd)===Je.LOWER_X?(this.state=Xe.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=Xe.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,i,a){if(n!==i){const o=i-n;this.result=this.result*Math.pow(a,o)+Number.parseInt(t.substr(n,o),a),this.consumed+=o}}stateNumericHex(t,n){const i=n;for(;n<t.length;){const a=t.charCodeAt(n);if(ba(a)||Pd(a))n+=1;else return this.addToNumericResult(t,i,n,16),this.emitNumericEntity(a,3)}return this.addToNumericResult(t,i,n,16),-1}stateNumericDecimal(t,n){const i=n;for(;n<t.length;){const a=t.charCodeAt(n);if(ba(a))n+=1;else return this.addToNumericResult(t,i,n,10),this.emitNumericEntity(a,2)}return this.addToNumericResult(t,i,n,10),-1}emitNumericEntity(t,n){var i;if(this.consumed<=n)return(i=this.errors)===null||i===void 0||i.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===Je.SEMI)this.consumed+=1;else if(this.decodeMode===Nt.Strict)return 0;return this.emitCodePoint(Rd(this.result),this.consumed),this.errors&&(t!==Je.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,n){const{decodeTree:i}=this;let a=i[this.treeIndex],o=(a&Ot.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const l=t.charCodeAt(n);if(this.treeIndex=Fd(i,a,this.treeIndex+Math.max(1,o),l),this.treeIndex<0)return this.result===0||this.decodeMode===Nt.Attribute&&(o===0||Md(l))?0:this.emitNotTerminatedNamedEntity();if(a=i[this.treeIndex],o=(a&Ot.VALUE_LENGTH)>>14,o!==0){if(l===Je.SEMI)return this.emitNamedEntityData(this.treeIndex,o,this.consumed+this.excess);this.decodeMode!==Nt.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;const{result:n,decodeTree:i}=this,a=(i[n]&Ot.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,a,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,i){const{decodeTree:a}=this;return this.emitCodePoint(n===1?a[t]&~Ot.VALUE_LENGTH:a[t+1],i),n===3&&this.emitCodePoint(a[t+2],i),i}end(){var t;switch(this.state){case Xe.NamedEntity:return this.result!==0&&(this.decodeMode!==Nt.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Xe.NumericDecimal:return this.emitNumericEntity(0,2);case Xe.NumericHex:return this.emitNumericEntity(0,3);case Xe.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Xe.EntityStart:return 0}}}function Fd(e,t,n,i){const a=(t&Ot.BRANCH_LENGTH)>>7,o=t&Ot.JUMP_TABLE;if(a===0)return o!==0&&i===o?n:-1;if(o){const p=i-o;return p<0||p>=a?-1:e[n+p]-1}let l=n,u=l+a-1;for(;l<=u;){const p=l+u>>>1,E=e[p];if(E<i)l=p+1;else if(E>i)u=p-1;else return e[p+a]}return-1}var Z;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(Z||(Z={}));var Gt;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(Gt||(Gt={}));var ut;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(ut||(ut={}));var j;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(j||(j={}));var r;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(r||(r={}));const Hd=new Map([[j.A,r.A],[j.ADDRESS,r.ADDRESS],[j.ANNOTATION_XML,r.ANNOTATION_XML],[j.APPLET,r.APPLET],[j.AREA,r.AREA],[j.ARTICLE,r.ARTICLE],[j.ASIDE,r.ASIDE],[j.B,r.B],[j.BASE,r.BASE],[j.BASEFONT,r.BASEFONT],[j.BGSOUND,r.BGSOUND],[j.BIG,r.BIG],[j.BLOCKQUOTE,r.BLOCKQUOTE],[j.BODY,r.BODY],[j.BR,r.BR],[j.BUTTON,r.BUTTON],[j.CAPTION,r.CAPTION],[j.CENTER,r.CENTER],[j.CODE,r.CODE],[j.COL,r.COL],[j.COLGROUP,r.COLGROUP],[j.DD,r.DD],[j.DESC,r.DESC],[j.DETAILS,r.DETAILS],[j.DIALOG,r.DIALOG],[j.DIR,r.DIR],[j.DIV,r.DIV],[j.DL,r.DL],[j.DT,r.DT],[j.EM,r.EM],[j.EMBED,r.EMBED],[j.FIELDSET,r.FIELDSET],[j.FIGCAPTION,r.FIGCAPTION],[j.FIGURE,r.FIGURE],[j.FONT,r.FONT],[j.FOOTER,r.FOOTER],[j.FOREIGN_OBJECT,r.FOREIGN_OBJECT],[j.FORM,r.FORM],[j.FRAME,r.FRAME],[j.FRAMESET,r.FRAMESET],[j.H1,r.H1],[j.H2,r.H2],[j.H3,r.H3],[j.H4,r.H4],[j.H5,r.H5],[j.H6,r.H6],[j.HEAD,r.HEAD],[j.HEADER,r.HEADER],[j.HGROUP,r.HGROUP],[j.HR,r.HR],[j.HTML,r.HTML],[j.I,r.I],[j.IMG,r.IMG],[j.IMAGE,r.IMAGE],[j.INPUT,r.INPUT],[j.IFRAME,r.IFRAME],[j.KEYGEN,r.KEYGEN],[j.LABEL,r.LABEL],[j.LI,r.LI],[j.LINK,r.LINK],[j.LISTING,r.LISTING],[j.MAIN,r.MAIN],[j.MALIGNMARK,r.MALIGNMARK],[j.MARQUEE,r.MARQUEE],[j.MATH,r.MATH],[j.MENU,r.MENU],[j.META,r.META],[j.MGLYPH,r.MGLYPH],[j.MI,r.MI],[j.MO,r.MO],[j.MN,r.MN],[j.MS,r.MS],[j.MTEXT,r.MTEXT],[j.NAV,r.NAV],[j.NOBR,r.NOBR],[j.NOFRAMES,r.NOFRAMES],[j.NOEMBED,r.NOEMBED],[j.NOSCRIPT,r.NOSCRIPT],[j.OBJECT,r.OBJECT],[j.OL,r.OL],[j.OPTGROUP,r.OPTGROUP],[j.OPTION,r.OPTION],[j.P,r.P],[j.PARAM,r.PARAM],[j.PLAINTEXT,r.PLAINTEXT],[j.PRE,r.PRE],[j.RB,r.RB],[j.RP,r.RP],[j.RT,r.RT],[j.RTC,r.RTC],[j.RUBY,r.RUBY],[j.S,r.S],[j.SCRIPT,r.SCRIPT],[j.SEARCH,r.SEARCH],[j.SECTION,r.SECTION],[j.SELECT,r.SELECT],[j.SOURCE,r.SOURCE],[j.SMALL,r.SMALL],[j.SPAN,r.SPAN],[j.STRIKE,r.STRIKE],[j.STRONG,r.STRONG],[j.STYLE,r.STYLE],[j.SUB,r.SUB],[j.SUMMARY,r.SUMMARY],[j.SUP,r.SUP],[j.TABLE,r.TABLE],[j.TBODY,r.TBODY],[j.TEMPLATE,r.TEMPLATE],[j.TEXTAREA,r.TEXTAREA],[j.TFOOT,r.TFOOT],[j.TD,r.TD],[j.TH,r.TH],[j.THEAD,r.THEAD],[j.TITLE,r.TITLE],[j.TR,r.TR],[j.TRACK,r.TRACK],[j.TT,r.TT],[j.U,r.U],[j.UL,r.UL],[j.SVG,r.SVG],[j.VAR,r.VAR],[j.WBR,r.WBR],[j.XMP,r.XMP]]);function ds(e){var t;return(t=Hd.get(e))!==null&&t!==void 0?t:r.UNKNOWN}const ne=r,Ud={[Z.HTML]:new Set([ne.ADDRESS,ne.APPLET,ne.AREA,ne.ARTICLE,ne.ASIDE,ne.BASE,ne.BASEFONT,ne.BGSOUND,ne.BLOCKQUOTE,ne.BODY,ne.BR,ne.BUTTON,ne.CAPTION,ne.CENTER,ne.COL,ne.COLGROUP,ne.DD,ne.DETAILS,ne.DIR,ne.DIV,ne.DL,ne.DT,ne.EMBED,ne.FIELDSET,ne.FIGCAPTION,ne.FIGURE,ne.FOOTER,ne.FORM,ne.FRAME,ne.FRAMESET,ne.H1,ne.H2,ne.H3,ne.H4,ne.H5,ne.H6,ne.HEAD,ne.HEADER,ne.HGROUP,ne.HR,ne.HTML,ne.IFRAME,ne.IMG,ne.INPUT,ne.LI,ne.LINK,ne.LISTING,ne.MAIN,ne.MARQUEE,ne.MENU,ne.META,ne.NAV,ne.NOEMBED,ne.NOFRAMES,ne.NOSCRIPT,ne.OBJECT,ne.OL,ne.P,ne.PARAM,ne.PLAINTEXT,ne.PRE,ne.SCRIPT,ne.SECTION,ne.SELECT,ne.SOURCE,ne.STYLE,ne.SUMMARY,ne.TABLE,ne.TBODY,ne.TD,ne.TEMPLATE,ne.TEXTAREA,ne.TFOOT,ne.TH,ne.THEAD,ne.TITLE,ne.TR,ne.TRACK,ne.UL,ne.WBR,ne.XMP]),[Z.MATHML]:new Set([ne.MI,ne.MO,ne.MN,ne.MS,ne.MTEXT,ne.ANNOTATION_XML]),[Z.SVG]:new Set([ne.TITLE,ne.FOREIGN_OBJECT,ne.DESC]),[Z.XLINK]:new Set,[Z.XML]:new Set,[Z.XMLNS]:new Set},Ea=new Set([ne.H1,ne.H2,ne.H3,ne.H4,ne.H5,ne.H6]);j.STYLE,j.SCRIPT,j.XMP,j.IFRAME,j.NOEMBED,j.NOFRAMES,j.PLAINTEXT;var g;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(g||(g={}));const Ye={DATA:g.DATA,RCDATA:g.RCDATA,RAWTEXT:g.RAWTEXT,SCRIPT_DATA:g.SCRIPT_DATA,PLAINTEXT:g.PLAINTEXT,CDATA_SECTION:g.CDATA_SECTION};function $d(e){return e>=h.DIGIT_0&&e<=h.DIGIT_9}function ks(e){return e>=h.LATIN_CAPITAL_A&&e<=h.LATIN_CAPITAL_Z}function qd(e){return e>=h.LATIN_SMALL_A&&e<=h.LATIN_SMALL_Z}function Rt(e){return qd(e)||ks(e)}function Li(e){return Rt(e)||$d(e)}function Ys(e){return e+32}function mo(e){return e===h.SPACE||e===h.LINE_FEED||e===h.TABULATION||e===h.FORM_FEED}function Ri(e){return mo(e)||e===h.SOLIDUS||e===h.GREATER_THAN_SIGN}function Wd(e){return e===h.NULL?U.nullCharacterReference:e>1114111?U.characterReferenceOutsideUnicodeRange:lo(e)?U.surrogateCharacterReference:uo(e)?U.noncharacterCharacterReference:co(e)||e===h.CARRIAGE_RETURN?U.controlCharacterReference:null}class Kd{constructor(t,n){this.options=t,this.handler=n,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=g.DATA,this.returnState=g.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new Id(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new Bd(jd,(i,a)=>{this.preprocessor.pos=this.entityStartPos+a-1,this._flushCodePointConsumedAsCharacterReference(i)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(U.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:i=>{this._err(U.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+i)},validateNumericCharacterReference:i=>{const a=Wd(i);a&&this._err(a,1)}}:void 0)}_err(t,n=0){var i,a;(a=(i=this.handler).onParseError)===null||a===void 0||a.call(i,this.preprocessor.getError(t,n))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t?.())}write(t,n,i){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||i?.()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let n=0;n<t;n++)this.preprocessor.advance()}_consumeSequenceIfMatch(t,n){return this.preprocessor.startsWith(t,n)?(this._advanceBy(t.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:Oe.START_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Oe.END_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:Oe.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:Oe.DOCTYPE,name:t,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(t,n){this.currentCharacterToken={type:t,chars:n,location:this.currentLocation}}_createAttr(t){this.currentAttr={name:t,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var t,n;const i=this.currentToken;if(po(i,this.currentAttr.name)===null){if(i.attrs.push(this.currentAttr),i.location&&this.currentLocation){const a=(t=(n=i.location).attrs)!==null&&t!==void 0?t:n.attrs=Object.create(null);a[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(U.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(t){this._emitCurrentCharacterToken(t.location),this.currentToken=null,t.location&&(t.location.endLine=this.preprocessor.line,t.location.endCol=this.preprocessor.col+1,t.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const t=this.currentToken;this.prepareToken(t),t.tagID=ds(t.tagName),t.type===Oe.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(U.endTagWithAttributes),t.selfClosing&&this._err(U.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case Oe.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case Oe.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case Oe.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:Oe.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,n){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=n;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,n)}_emitCodePoint(t){const n=mo(t)?Oe.WHITESPACE_CHARACTER:t===h.NULL?Oe.NULL_CHARACTER:Oe.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(Oe.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=g.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Nt.Attribute:Nt.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===g.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===g.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===g.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case g.DATA:{this._stateData(t);break}case g.RCDATA:{this._stateRcdata(t);break}case g.RAWTEXT:{this._stateRawtext(t);break}case g.SCRIPT_DATA:{this._stateScriptData(t);break}case g.PLAINTEXT:{this._statePlaintext(t);break}case g.TAG_OPEN:{this._stateTagOpen(t);break}case g.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case g.TAG_NAME:{this._stateTagName(t);break}case g.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case g.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case g.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case g.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case g.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case g.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case g.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case g.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case g.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case g.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case g.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case g.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case g.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case g.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case g.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case g.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case g.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case g.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case g.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case g.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case g.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case g.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case g.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case g.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case g.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case g.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case g.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case g.BOGUS_COMMENT:{this._stateBogusComment(t);break}case g.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case g.COMMENT_START:{this._stateCommentStart(t);break}case g.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case g.COMMENT:{this._stateComment(t);break}case g.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case g.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case g.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case g.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case g.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case g.COMMENT_END:{this._stateCommentEnd(t);break}case g.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case g.DOCTYPE:{this._stateDoctype(t);break}case g.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case g.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case g.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case g.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case g.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case g.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case g.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case g.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case g.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case g.CDATA_SECTION:{this._stateCdataSection(t);break}case g.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case g.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case g.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case g.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case h.LESS_THAN_SIGN:{this.state=g.TAG_OPEN;break}case h.AMPERSAND:{this._startCharacterReference();break}case h.NULL:{this._err(U.unexpectedNullCharacter),this._emitCodePoint(t);break}case h.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case h.AMPERSAND:{this._startCharacterReference();break}case h.LESS_THAN_SIGN:{this.state=g.RCDATA_LESS_THAN_SIGN;break}case h.NULL:{this._err(U.unexpectedNullCharacter),this._emitChars(qe);break}case h.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case h.LESS_THAN_SIGN:{this.state=g.RAWTEXT_LESS_THAN_SIGN;break}case h.NULL:{this._err(U.unexpectedNullCharacter),this._emitChars(qe);break}case h.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case h.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_LESS_THAN_SIGN;break}case h.NULL:{this._err(U.unexpectedNullCharacter),this._emitChars(qe);break}case h.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case h.NULL:{this._err(U.unexpectedNullCharacter),this._emitChars(qe);break}case h.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(Rt(t))this._createStartTagToken(),this.state=g.TAG_NAME,this._stateTagName(t);else switch(t){case h.EXCLAMATION_MARK:{this.state=g.MARKUP_DECLARATION_OPEN;break}case h.SOLIDUS:{this.state=g.END_TAG_OPEN;break}case h.QUESTION_MARK:{this._err(U.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=g.BOGUS_COMMENT,this._stateBogusComment(t);break}case h.EOF:{this._err(U.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(U.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=g.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(Rt(t))this._createEndTagToken(),this.state=g.TAG_NAME,this._stateTagName(t);else switch(t){case h.GREATER_THAN_SIGN:{this._err(U.missingEndTagName),this.state=g.DATA;break}case h.EOF:{this._err(U.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(U.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=g.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:{this.state=g.BEFORE_ATTRIBUTE_NAME;break}case h.SOLIDUS:{this.state=g.SELF_CLOSING_START_TAG;break}case h.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentTagToken();break}case h.NULL:{this._err(U.unexpectedNullCharacter),n.tagName+=qe;break}case h.EOF:{this._err(U.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(ks(t)?Ys(t):t)}}_stateRcdataLessThanSign(t){t===h.SOLIDUS?this.state=g.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=g.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){Rt(t)?(this.state=g.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=g.RCDATA,this._stateRcdata(t))}handleSpecialEndTag(t){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const n=this.currentToken;switch(n.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=g.BEFORE_ATTRIBUTE_NAME,!1;case h.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=g.SELF_CLOSING_START_TAG,!1;case h.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=g.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=g.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===h.SOLIDUS?this.state=g.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=g.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){Rt(t)?(this.state=g.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=g.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=g.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case h.SOLIDUS:{this.state=g.SCRIPT_DATA_END_TAG_OPEN;break}case h.EXCLAMATION_MARK:{this.state=g.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=g.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){Rt(t)?(this.state=g.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=g.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=g.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===h.HYPHEN_MINUS?(this.state=g.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=g.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===h.HYPHEN_MINUS?(this.state=g.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=g.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case h.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case h.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case h.NULL:{this._err(U.unexpectedNullCharacter),this._emitChars(qe);break}case h.EOF:{this._err(U.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case h.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case h.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case h.NULL:{this._err(U.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_ESCAPED,this._emitChars(qe);break}case h.EOF:{this._err(U.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case h.HYPHEN_MINUS:{this._emitChars("-");break}case h.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case h.GREATER_THAN_SIGN:{this.state=g.SCRIPT_DATA,this._emitChars(">");break}case h.NULL:{this._err(U.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_ESCAPED,this._emitChars(qe);break}case h.EOF:{this._err(U.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===h.SOLIDUS?this.state=g.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Rt(t)?(this._emitChars("<"),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){Rt(t)?(this.state=g.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(at.SCRIPT,!1)&&Ri(this.preprocessor.peek(at.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<at.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=g.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case h.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case h.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case h.NULL:{this._err(U.unexpectedNullCharacter),this._emitChars(qe);break}case h.EOF:{this._err(U.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case h.HYPHEN_MINUS:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case h.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case h.NULL:{this._err(U.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(qe);break}case h.EOF:{this._err(U.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case h.HYPHEN_MINUS:{this._emitChars("-");break}case h.LESS_THAN_SIGN:{this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case h.GREATER_THAN_SIGN:{this.state=g.SCRIPT_DATA,this._emitChars(">");break}case h.NULL:{this._err(U.unexpectedNullCharacter),this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(qe);break}case h.EOF:{this._err(U.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===h.SOLIDUS?(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(at.SCRIPT,!1)&&Ri(this.preprocessor.peek(at.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<at.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=g.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=g.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.SOLIDUS:case h.GREATER_THAN_SIGN:case h.EOF:{this.state=g.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case h.EQUALS_SIGN:{this._err(U.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=g.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=g.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:case h.SOLIDUS:case h.GREATER_THAN_SIGN:case h.EOF:{this._leaveAttrName(),this.state=g.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case h.EQUALS_SIGN:{this._leaveAttrName(),this.state=g.BEFORE_ATTRIBUTE_VALUE;break}case h.QUOTATION_MARK:case h.APOSTROPHE:case h.LESS_THAN_SIGN:{this._err(U.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case h.NULL:{this._err(U.unexpectedNullCharacter),this.currentAttr.name+=qe;break}default:this.currentAttr.name+=String.fromCodePoint(ks(t)?Ys(t):t)}}_stateAfterAttributeName(t){switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.SOLIDUS:{this.state=g.SELF_CLOSING_START_TAG;break}case h.EQUALS_SIGN:{this.state=g.BEFORE_ATTRIBUTE_VALUE;break}case h.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentTagToken();break}case h.EOF:{this._err(U.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=g.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.QUOTATION_MARK:{this.state=g.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case h.APOSTROPHE:{this.state=g.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case h.GREATER_THAN_SIGN:{this._err(U.missingAttributeValue),this.state=g.DATA,this.emitCurrentTagToken();break}default:this.state=g.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case h.QUOTATION_MARK:{this.state=g.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case h.AMPERSAND:{this._startCharacterReference();break}case h.NULL:{this._err(U.unexpectedNullCharacter),this.currentAttr.value+=qe;break}case h.EOF:{this._err(U.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case h.APOSTROPHE:{this.state=g.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case h.AMPERSAND:{this._startCharacterReference();break}case h.NULL:{this._err(U.unexpectedNullCharacter),this.currentAttr.value+=qe;break}case h.EOF:{this._err(U.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:{this._leaveAttrValue(),this.state=g.BEFORE_ATTRIBUTE_NAME;break}case h.AMPERSAND:{this._startCharacterReference();break}case h.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=g.DATA,this.emitCurrentTagToken();break}case h.NULL:{this._err(U.unexpectedNullCharacter),this.currentAttr.value+=qe;break}case h.QUOTATION_MARK:case h.APOSTROPHE:case h.LESS_THAN_SIGN:case h.EQUALS_SIGN:case h.GRAVE_ACCENT:{this._err(U.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case h.EOF:{this._err(U.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:{this._leaveAttrValue(),this.state=g.BEFORE_ATTRIBUTE_NAME;break}case h.SOLIDUS:{this._leaveAttrValue(),this.state=g.SELF_CLOSING_START_TAG;break}case h.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=g.DATA,this.emitCurrentTagToken();break}case h.EOF:{this._err(U.eofInTag),this._emitEOFToken();break}default:this._err(U.missingWhitespaceBetweenAttributes),this.state=g.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case h.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=g.DATA,this.emitCurrentTagToken();break}case h.EOF:{this._err(U.eofInTag),this._emitEOFToken();break}default:this._err(U.unexpectedSolidusInTag),this.state=g.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case h.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentComment(n);break}case h.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case h.NULL:{this._err(U.unexpectedNullCharacter),n.data+=qe;break}default:n.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(at.DASH_DASH,!0)?(this._createCommentToken(at.DASH_DASH.length+1),this.state=g.COMMENT_START):this._consumeSequenceIfMatch(at.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(at.DOCTYPE.length+1),this.state=g.DOCTYPE):this._consumeSequenceIfMatch(at.CDATA_START,!0)?this.inForeignNode?this.state=g.CDATA_SECTION:(this._err(U.cdataInHtmlContent),this._createCommentToken(at.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=g.BOGUS_COMMENT):this._ensureHibernation()||(this._err(U.incorrectlyOpenedComment),this._createCommentToken(2),this.state=g.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case h.HYPHEN_MINUS:{this.state=g.COMMENT_START_DASH;break}case h.GREATER_THAN_SIGN:{this._err(U.abruptClosingOfEmptyComment),this.state=g.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=g.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case h.HYPHEN_MINUS:{this.state=g.COMMENT_END;break}case h.GREATER_THAN_SIGN:{this._err(U.abruptClosingOfEmptyComment),this.state=g.DATA,this.emitCurrentComment(n);break}case h.EOF:{this._err(U.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=g.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case h.HYPHEN_MINUS:{this.state=g.COMMENT_END_DASH;break}case h.LESS_THAN_SIGN:{n.data+="<",this.state=g.COMMENT_LESS_THAN_SIGN;break}case h.NULL:{this._err(U.unexpectedNullCharacter),n.data+=qe;break}case h.EOF:{this._err(U.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case h.EXCLAMATION_MARK:{n.data+="!",this.state=g.COMMENT_LESS_THAN_SIGN_BANG;break}case h.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=g.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===h.HYPHEN_MINUS?this.state=g.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=g.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===h.HYPHEN_MINUS?this.state=g.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=g.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==h.GREATER_THAN_SIGN&&t!==h.EOF&&this._err(U.nestedComment),this.state=g.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case h.HYPHEN_MINUS:{this.state=g.COMMENT_END;break}case h.EOF:{this._err(U.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=g.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case h.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentComment(n);break}case h.EXCLAMATION_MARK:{this.state=g.COMMENT_END_BANG;break}case h.HYPHEN_MINUS:{n.data+="-";break}case h.EOF:{this._err(U.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=g.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case h.HYPHEN_MINUS:{n.data+="--!",this.state=g.COMMENT_END_DASH;break}case h.GREATER_THAN_SIGN:{this._err(U.incorrectlyClosedComment),this.state=g.DATA,this.emitCurrentComment(n);break}case h.EOF:{this._err(U.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=g.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_NAME;break}case h.GREATER_THAN_SIGN:{this.state=g.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case h.EOF:{this._err(U.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(U.missingWhitespaceBeforeDoctypeName),this.state=g.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(ks(t))this._createDoctypeToken(String.fromCharCode(Ys(t))),this.state=g.DOCTYPE_NAME;else switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.NULL:{this._err(U.unexpectedNullCharacter),this._createDoctypeToken(qe),this.state=g.DOCTYPE_NAME;break}case h.GREATER_THAN_SIGN:{this._err(U.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=g.DATA;break}case h.EOF:{this._err(U.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(t)),this.state=g.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:{this.state=g.AFTER_DOCTYPE_NAME;break}case h.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(n);break}case h.NULL:{this._err(U.unexpectedNullCharacter),n.name+=qe;break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(ks(t)?Ys(t):t)}}_stateAfterDoctypeName(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(n);break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(at.PUBLIC,!1)?this.state=g.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(at.SYSTEM,!1)?this.state=g.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(U.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case h.QUOTATION_MARK:{this._err(U.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case h.APOSTROPHE:{this._err(U.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case h.GREATER_THAN_SIGN:{this._err(U.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(n);break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(U.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.QUOTATION_MARK:{n.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case h.APOSTROPHE:{n.publicId="",this.state=g.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case h.GREATER_THAN_SIGN:{this._err(U.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(n);break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(U.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case h.QUOTATION_MARK:{this.state=g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case h.NULL:{this._err(U.unexpectedNullCharacter),n.publicId+=qe;break}case h.GREATER_THAN_SIGN:{this._err(U.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=g.DATA;break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateDoctypePublicIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case h.APOSTROPHE:{this.state=g.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case h.NULL:{this._err(U.unexpectedNullCharacter),n.publicId+=qe;break}case h.GREATER_THAN_SIGN:{this._err(U.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=g.DATA;break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.publicId+=String.fromCodePoint(t)}}_stateAfterDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:{this.state=g.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case h.GREATER_THAN_SIGN:{this.state=g.DATA,this.emitCurrentDoctype(n);break}case h.QUOTATION_MARK:{this._err(U.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case h.APOSTROPHE:{this._err(U.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(U.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=g.DATA;break}case h.QUOTATION_MARK:{n.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case h.APOSTROPHE:{n.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(U.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:{this.state=g.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case h.QUOTATION_MARK:{this._err(U.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case h.APOSTROPHE:{this._err(U.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case h.GREATER_THAN_SIGN:{this._err(U.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(n);break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(U.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.QUOTATION_MARK:{n.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case h.APOSTROPHE:{n.systemId="",this.state=g.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case h.GREATER_THAN_SIGN:{this._err(U.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=g.DATA,this.emitCurrentDoctype(n);break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(U.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case h.QUOTATION_MARK:{this.state=g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case h.NULL:{this._err(U.unexpectedNullCharacter),n.systemId+=qe;break}case h.GREATER_THAN_SIGN:{this._err(U.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=g.DATA;break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateDoctypeSystemIdentifierSingleQuoted(t){const n=this.currentToken;switch(t){case h.APOSTROPHE:{this.state=g.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case h.NULL:{this._err(U.unexpectedNullCharacter),n.systemId+=qe;break}case h.GREATER_THAN_SIGN:{this._err(U.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=g.DATA;break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.systemId+=String.fromCodePoint(t)}}_stateAfterDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case h.SPACE:case h.LINE_FEED:case h.TABULATION:case h.FORM_FEED:break;case h.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=g.DATA;break}case h.EOF:{this._err(U.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(U.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=g.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case h.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=g.DATA;break}case h.NULL:{this._err(U.unexpectedNullCharacter);break}case h.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case h.RIGHT_SQUARE_BRACKET:{this.state=g.CDATA_SECTION_BRACKET;break}case h.EOF:{this._err(U.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===h.RIGHT_SQUARE_BRACKET?this.state=g.CDATA_SECTION_END:(this._emitChars("]"),this.state=g.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case h.GREATER_THAN_SIGN:{this.state=g.DATA;break}case h.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=g.CDATA_SECTION,this._stateCdataSection(t)}}_stateCharacterReference(){let t=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(t<0)if(this.preprocessor.lastChunkWritten)t=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}t===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(h.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&Li(this.preprocessor.peek(1))?g.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){Li(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===h.SEMICOLON&&this._err(U.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const ho=new Set([r.DD,r.DT,r.LI,r.OPTGROUP,r.OPTION,r.P,r.RB,r.RP,r.RT,r.RTC]),Di=new Set([...ho,r.CAPTION,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]),yn=new Set([r.APPLET,r.CAPTION,r.HTML,r.MARQUEE,r.OBJECT,r.TABLE,r.TD,r.TEMPLATE,r.TH]),Yd=new Set([...yn,r.OL,r.UL]),Gd=new Set([...yn,r.BUTTON]),Pi=new Set([r.ANNOTATION_XML,r.MI,r.MN,r.MO,r.MS,r.MTEXT]),Oi=new Set([r.DESC,r.FOREIGN_OBJECT,r.TITLE]),Vd=new Set([r.TR,r.TEMPLATE,r.HTML]),zd=new Set([r.TBODY,r.TFOOT,r.THEAD,r.TEMPLATE,r.HTML]),Qd=new Set([r.TABLE,r.TEMPLATE,r.HTML]),Xd=new Set([r.TD,r.TH]);class Jd{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,n,i){this.treeAdapter=n,this.handler=i,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=r.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===r.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===Z.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(t,n){this.stackTop++,this.items[this.stackTop]=t,this.current=t,this.tagIDs[this.stackTop]=n,this.currentTagId=n,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(t,n,!0)}pop(){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,n){const i=this._indexOf(t);this.items[i]=n,i===this.stackTop&&(this.current=n)}insertAfter(t,n,i){const a=this._indexOf(t)+1;this.items.splice(a,0,n),this.tagIDs.splice(a,0,i),this.stackTop++,a===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,a===this.stackTop)}popUntilTagNamePopped(t){let n=this.stackTop+1;do n=this.tagIDs.lastIndexOf(t,n-1);while(n>0&&this.treeAdapter.getNamespaceURI(this.items[n])!==Z.HTML);this.shortenToLength(Math.max(n,0))}shortenToLength(t){for(;this.stackTop>=t;){const n=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(n,this.stackTop<t)}}popUntilElementPopped(t){const n=this._indexOf(t);this.shortenToLength(Math.max(n,0))}popUntilPopped(t,n){const i=this._indexOfTagNames(t,n);this.shortenToLength(Math.max(i,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(Ea,Z.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Xd,Z.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,n){for(let i=this.stackTop;i>=0;i--)if(t.has(this.tagIDs[i])&&this.treeAdapter.getNamespaceURI(this.items[i])===n)return i;return-1}clearBackTo(t,n){const i=this._indexOfTagNames(t,n);this.shortenToLength(i+1)}clearBackToTableContext(){this.clearBackTo(Qd,Z.HTML)}clearBackToTableBodyContext(){this.clearBackTo(zd,Z.HTML)}clearBackToTableRowContext(){this.clearBackTo(Vd,Z.HTML)}remove(t){const n=this._indexOf(t);n>=0&&(n===this.stackTop?this.pop():(this.items.splice(n,1),this.tagIDs.splice(n,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===r.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const n=this._indexOf(t)-1;return n>=0?this.items[n]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===r.HTML}hasInDynamicScope(t,n){for(let i=this.stackTop;i>=0;i--){const a=this.tagIDs[i];switch(this.treeAdapter.getNamespaceURI(this.items[i])){case Z.HTML:{if(a===t)return!0;if(n.has(a))return!1;break}case Z.SVG:{if(Oi.has(a))return!1;break}case Z.MATHML:{if(Pi.has(a))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,yn)}hasInListItemScope(t){return this.hasInDynamicScope(t,Yd)}hasInButtonScope(t){return this.hasInDynamicScope(t,Gd)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case Z.HTML:{if(Ea.has(n))return!0;if(yn.has(n))return!1;break}case Z.SVG:{if(Oi.has(n))return!1;break}case Z.MATHML:{if(Pi.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===Z.HTML)switch(this.tagIDs[n]){case t:return!0;case r.TABLE:case r.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===Z.HTML)switch(this.tagIDs[t]){case r.TBODY:case r.THEAD:case r.TFOOT:return!0;case r.TABLE:case r.HTML:return!1}return!0}hasInSelectScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===Z.HTML)switch(this.tagIDs[n]){case t:return!0;case r.OPTION:case r.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&ho.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&Di.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&Di.has(this.currentTagId);)this.pop()}}const zn=3;var Et;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Et||(Et={}));const Mi={type:Et.Marker};class Zd{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const i=[],a=n.length,o=this.treeAdapter.getTagName(t),l=this.treeAdapter.getNamespaceURI(t);for(let u=0;u<this.entries.length;u++){const p=this.entries[u];if(p.type===Et.Marker)break;const{element:E}=p;if(this.treeAdapter.getTagName(E)===o&&this.treeAdapter.getNamespaceURI(E)===l){const m=this.treeAdapter.getAttrList(E);m.length===a&&i.push({idx:u,attrs:m})}}return i}_ensureNoahArkCondition(t){if(this.entries.length<zn)return;const n=this.treeAdapter.getAttrList(t),i=this._getNoahArkConditionCandidates(t,n);if(i.length<zn)return;const a=new Map(n.map(l=>[l.name,l.value]));let o=0;for(let l=0;l<i.length;l++){const u=i[l];u.attrs.every(p=>a.get(p.name)===p.value)&&(o+=1,o>=zn&&this.entries.splice(u.idx,1))}}insertMarker(){this.entries.unshift(Mi)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:Et.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const i=this.entries.indexOf(this.bookmark);this.entries.splice(i,0,{type:Et.Element,element:t,token:n})}removeEntry(t){const n=this.entries.indexOf(t);n!==-1&&this.entries.splice(n,1)}clearToLastMarker(){const t=this.entries.indexOf(Mi);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(i=>i.type===Et.Marker||this.treeAdapter.getTagName(i.element)===t);return n&&n.type===Et.Element?n:null}getElementEntry(t){return this.entries.find(n=>n.type===Et.Element&&n.element===t)}}const Dt={createDocument(){return{nodeName:"#document",mode:ut.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,n){return{nodeName:e,tagName:e,attrs:n,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,n){const i=e.childNodes.indexOf(n);e.childNodes.splice(i,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,i){const a=e.childNodes.find(o=>o.nodeName==="#documentType");if(a)a.name=t,a.publicId=n,a.systemId=i;else{const o={nodeName:"#documentType",name:t,publicId:n,systemId:i,parentNode:null};Dt.appendChild(e,o)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const n=e.childNodes[e.childNodes.length-1];if(Dt.isTextNode(n)){n.value+=t;return}}Dt.appendChild(e,Dt.createTextNode(t))},insertTextBefore(e,t,n){const i=e.childNodes[e.childNodes.indexOf(n)-1];i&&Dt.isTextNode(i)?i.value+=t:Dt.insertBefore(e,Dt.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(i=>i.name));for(let i=0;i<t.length;i++)n.has(t[i].name)||e.attrs.push(t[i])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},fo="html",ep="about:legacy-compat",tp="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",go=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],sp=[...go,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],np=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),bo=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],ap=[...bo,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function Bi(e,t){return t.some(n=>e.startsWith(n))}function ip(e){return e.name===fo&&e.publicId===null&&(e.systemId===null||e.systemId===ep)}function rp(e){if(e.name!==fo)return ut.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===tp)return ut.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),np.has(n))return ut.QUIRKS;let i=t===null?sp:go;if(Bi(n,i))return ut.QUIRKS;if(i=t===null?bo:ap,Bi(n,i))return ut.LIMITED_QUIRKS}return ut.NO_QUIRKS}const Fi={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},op="definitionurl",lp="definitionURL",cp=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),up=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Z.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Z.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Z.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Z.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Z.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Z.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Z.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:Z.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Z.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Z.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Z.XMLNS}]]),dp=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),pp=new Set([r.B,r.BIG,r.BLOCKQUOTE,r.BODY,r.BR,r.CENTER,r.CODE,r.DD,r.DIV,r.DL,r.DT,r.EM,r.EMBED,r.H1,r.H2,r.H3,r.H4,r.H5,r.H6,r.HEAD,r.HR,r.I,r.IMG,r.LI,r.LISTING,r.MENU,r.META,r.NOBR,r.OL,r.P,r.PRE,r.RUBY,r.S,r.SMALL,r.SPAN,r.STRONG,r.STRIKE,r.SUB,r.SUP,r.TABLE,r.TT,r.U,r.UL,r.VAR]);function mp(e){const t=e.tagID;return t===r.FONT&&e.attrs.some(({name:i})=>i===Gt.COLOR||i===Gt.SIZE||i===Gt.FACE)||pp.has(t)}function Eo(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===op){e.attrs[t].name=lp;break}}function To(e){for(let t=0;t<e.attrs.length;t++){const n=cp.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function Oa(e){for(let t=0;t<e.attrs.length;t++){const n=up.get(e.attrs[t].name);n&&(e.attrs[t].prefix=n.prefix,e.attrs[t].name=n.name,e.attrs[t].namespace=n.namespace)}}function hp(e){const t=dp.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=ds(e.tagName))}function fp(e,t){return t===Z.MATHML&&(e===r.MI||e===r.MO||e===r.MN||e===r.MS||e===r.MTEXT)}function gp(e,t,n){if(t===Z.MATHML&&e===r.ANNOTATION_XML){for(let i=0;i<n.length;i++)if(n[i].name===Gt.ENCODING){const a=n[i].value.toLowerCase();return a===Fi.TEXT_HTML||a===Fi.APPLICATION_XML}}return t===Z.SVG&&(e===r.FOREIGN_OBJECT||e===r.DESC||e===r.TITLE)}function bp(e,t,n,i){return(!i||i===Z.HTML)&&gp(e,t,n)||(!i||i===Z.MATHML)&&fp(e,t)}const Ep="hidden",Tp=8,xp=3;var T;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(T||(T={}));const yp={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},xo=new Set([r.TABLE,r.TBODY,r.TFOOT,r.THEAD,r.TR]),Hi={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Dt,onParseError:null};class Ui{constructor(t,n,i=null,a=null){this.fragmentContext=i,this.scriptHandler=a,this.currentToken=null,this.stopped=!1,this.insertionMode=T.INITIAL,this.originalInsertionMode=T.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...Hi,...t},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=n??this.treeAdapter.createDocument(),this.tokenizer=new Kd(this.options,this),this.activeFormattingElements=new Zd(this.treeAdapter),this.fragmentContextID=i?ds(this.treeAdapter.getTagName(i)):r.UNKNOWN,this._setContextModes(i??this.document,this.fragmentContextID),this.openElements=new Jd(this.document,this.treeAdapter,this)}static parse(t,n){const i=new this(n);return i.tokenizer.write(t,!0),i.document}static getFragmentParser(t,n){const i={...Hi,...n};t??(t=i.treeAdapter.createElement(j.TEMPLATE,Z.HTML,[]));const a=i.treeAdapter.createElement("documentmock",Z.HTML,[]),o=new this(i,a,t);return o.fragmentContextID===r.TEMPLATE&&o.tmplInsertionModeStack.unshift(T.IN_TEMPLATE),o._initTokenizerForFragmentParsing(),o._insertFakeRootElement(),o._resetInsertionMode(),o._findFormInFragmentContext(),o}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),n=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,n),n}_err(t,n,i){var a;if(!this.onParseError)return;const o=(a=t.location)!==null&&a!==void 0?a:yp,l={code:n,startLine:o.startLine,startCol:o.startCol,startOffset:o.startOffset,endLine:i?o.startLine:o.endLine,endCol:i?o.startCol:o.endCol,endOffset:i?o.startOffset:o.endOffset};this.onParseError(l)}onItemPush(t,n,i){var a,o;(o=(a=this.treeAdapter).onItemPush)===null||o===void 0||o.call(a,t),i&&this.openElements.stackTop>0&&this._setContextModes(t,n)}onItemPop(t,n){var i,a;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(a=(i=this.treeAdapter).onItemPop)===null||a===void 0||a.call(i,t,this.openElements.current),n){let o,l;this.openElements.stackTop===0&&this.fragmentContext?(o=this.fragmentContext,l=this.fragmentContextID):{current:o,currentTagId:l}=this.openElements,this._setContextModes(o,l)}}_setContextModes(t,n){const i=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===Z.HTML;this.currentNotInHTML=!i,this.tokenizer.inForeignNode=!i&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,Z.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=T.TEXT}switchToPlaintextParsing(){this.insertionMode=T.TEXT,this.originalInsertionMode=T.IN_BODY,this.tokenizer.state=Ye.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===j.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==Z.HTML))switch(this.fragmentContextID){case r.TITLE:case r.TEXTAREA:{this.tokenizer.state=Ye.RCDATA;break}case r.STYLE:case r.XMP:case r.IFRAME:case r.NOEMBED:case r.NOFRAMES:case r.NOSCRIPT:{this.tokenizer.state=Ye.RAWTEXT;break}case r.SCRIPT:{this.tokenizer.state=Ye.SCRIPT_DATA;break}case r.PLAINTEXT:{this.tokenizer.state=Ye.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",i=t.publicId||"",a=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,i,a),t.location){const l=this.treeAdapter.getChildNodes(this.document).find(u=>this.treeAdapter.isDocumentTypeNode(u));l&&this.treeAdapter.setNodeSourceCodeLocation(l,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const i=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,i)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const i=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(i??this.document,t)}}_appendElement(t,n){const i=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(i,t.location)}_insertElement(t,n){const i=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(i,t.location),this.openElements.push(i,t.tagID)}_insertFakeElement(t,n){const i=this.treeAdapter.createElement(t,Z.HTML,[]);this._attachElementToTree(i,null),this.openElements.push(i,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,Z.HTML,t.attrs),i=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,i),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(j.HTML,Z.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,r.HTML)}_appendCommentNode(t,n){const i=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,i),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(i,t.location)}_insertCharacters(t){let n,i;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:i}=this._findFosterParentingLocation(),i?this.treeAdapter.insertTextBefore(n,t.chars,i):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const a=this.treeAdapter.getChildNodes(n),o=i?a.lastIndexOf(i):a.length,l=a[o-1];if(this.treeAdapter.getNodeSourceCodeLocation(l)){const{endLine:p,endCol:E,endOffset:m}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(l,{endLine:p,endCol:E,endOffset:m})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(l,t.location)}_adoptNodes(t,n){for(let i=this.treeAdapter.getFirstChild(t);i;i=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(i),this.treeAdapter.appendChild(n,i)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const i=n.location,a=this.treeAdapter.getTagName(t),o=n.type===Oe.END_TAG&&a===n.tagName?{endTag:{...i},endLine:i.endLine,endCol:i.endCol,endOffset:i.endOffset}:{endLine:i.startLine,endCol:i.startCol,endOffset:i.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,o)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,i;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,i=this.fragmentContextID):{current:n,currentTagId:i}=this.openElements,t.tagID===r.SVG&&this.treeAdapter.getTagName(n)===j.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===Z.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===r.MGLYPH||t.tagID===r.MALIGNMARK)&&i!==void 0&&!this._isIntegrationPoint(i,n,Z.HTML)}_processToken(t){switch(t.type){case Oe.CHARACTER:{this.onCharacter(t);break}case Oe.NULL_CHARACTER:{this.onNullCharacter(t);break}case Oe.COMMENT:{this.onComment(t);break}case Oe.DOCTYPE:{this.onDoctype(t);break}case Oe.START_TAG:{this._processStartTag(t);break}case Oe.END_TAG:{this.onEndTag(t);break}case Oe.EOF:{this.onEof(t);break}case Oe.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,i){const a=this.treeAdapter.getNamespaceURI(n),o=this.treeAdapter.getAttrList(n);return bp(t,a,o,i)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(a=>a.type===Et.Marker||this.openElements.contains(a.element)),i=n===-1?t-1:n-1;for(let a=i;a>=0;a--){const o=this.activeFormattingElements.entries[a];this._insertElement(o.token,this.treeAdapter.getNamespaceURI(o.element)),o.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=T.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(r.P),this.openElements.popUntilTagNamePopped(r.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case r.TR:{this.insertionMode=T.IN_ROW;return}case r.TBODY:case r.THEAD:case r.TFOOT:{this.insertionMode=T.IN_TABLE_BODY;return}case r.CAPTION:{this.insertionMode=T.IN_CAPTION;return}case r.COLGROUP:{this.insertionMode=T.IN_COLUMN_GROUP;return}case r.TABLE:{this.insertionMode=T.IN_TABLE;return}case r.BODY:{this.insertionMode=T.IN_BODY;return}case r.FRAMESET:{this.insertionMode=T.IN_FRAMESET;return}case r.SELECT:{this._resetInsertionModeForSelect(t);return}case r.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case r.HTML:{this.insertionMode=this.headElement?T.AFTER_HEAD:T.BEFORE_HEAD;return}case r.TD:case r.TH:{if(t>0){this.insertionMode=T.IN_CELL;return}break}case r.HEAD:{if(t>0){this.insertionMode=T.IN_HEAD;return}break}}this.insertionMode=T.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const i=this.openElements.tagIDs[n];if(i===r.TEMPLATE)break;if(i===r.TABLE){this.insertionMode=T.IN_SELECT_IN_TABLE;return}}this.insertionMode=T.IN_SELECT}_isElementCausesFosterParenting(t){return xo.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this.openElements.currentTagId!==void 0&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const n=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case r.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(n)===Z.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case r.TABLE:{const i=this.treeAdapter.getParentNode(n);return i?{parent:i,beforeElement:n}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const n=this._findFosterParentingLocation();n.beforeElement?this.treeAdapter.insertBefore(n.parent,t,n.beforeElement):this.treeAdapter.appendChild(n.parent,t)}_isSpecialElement(t,n){const i=this.treeAdapter.getNamespaceURI(t);return Ud[i].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Xm(this,t);return}switch(this.insertionMode){case T.INITIAL:{gs(this,t);break}case T.BEFORE_HTML:{Cs(this,t);break}case T.BEFORE_HEAD:{_s(this,t);break}case T.IN_HEAD:{ws(this,t);break}case T.IN_HEAD_NO_SCRIPT:{Ss(this,t);break}case T.AFTER_HEAD:{As(this,t);break}case T.IN_BODY:case T.IN_CAPTION:case T.IN_CELL:case T.IN_TEMPLATE:{No(this,t);break}case T.TEXT:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Qn(this,t);break}case T.IN_TABLE_TEXT:{So(this,t);break}case T.IN_COLUMN_GROUP:{Nn(this,t);break}case T.AFTER_BODY:{kn(this,t);break}case T.AFTER_AFTER_BODY:{Js(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Qm(this,t);return}switch(this.insertionMode){case T.INITIAL:{gs(this,t);break}case T.BEFORE_HTML:{Cs(this,t);break}case T.BEFORE_HEAD:{_s(this,t);break}case T.IN_HEAD:{ws(this,t);break}case T.IN_HEAD_NO_SCRIPT:{Ss(this,t);break}case T.AFTER_HEAD:{As(this,t);break}case T.TEXT:{this._insertCharacters(t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Qn(this,t);break}case T.IN_COLUMN_GROUP:{Nn(this,t);break}case T.AFTER_BODY:{kn(this,t);break}case T.AFTER_AFTER_BODY:{Js(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){Ta(this,t);return}switch(this.insertionMode){case T.INITIAL:case T.BEFORE_HTML:case T.BEFORE_HEAD:case T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:case T.IN_BODY:case T.IN_TABLE:case T.IN_CAPTION:case T.IN_COLUMN_GROUP:case T.IN_TABLE_BODY:case T.IN_ROW:case T.IN_CELL:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:case T.IN_TEMPLATE:case T.IN_FRAMESET:case T.AFTER_FRAMESET:{Ta(this,t);break}case T.IN_TABLE_TEXT:{bs(this,t);break}case T.AFTER_BODY:{Sp(this,t);break}case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{Ap(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case T.INITIAL:{Ip(this,t);break}case T.BEFORE_HEAD:case T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:{this._err(t,U.misplacedDoctype);break}case T.IN_TABLE_TEXT:{bs(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,U.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?Jm(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case T.INITIAL:{gs(this,t);break}case T.BEFORE_HTML:{jp(this,t);break}case T.BEFORE_HEAD:{Rp(this,t);break}case T.IN_HEAD:{gt(this,t);break}case T.IN_HEAD_NO_SCRIPT:{Op(this,t);break}case T.AFTER_HEAD:{Bp(this,t);break}case T.IN_BODY:{Ze(this,t);break}case T.IN_TABLE:{os(this,t);break}case T.IN_TABLE_TEXT:{bs(this,t);break}case T.IN_CAPTION:{Dm(this,t);break}case T.IN_COLUMN_GROUP:{Fa(this,t);break}case T.IN_TABLE_BODY:{On(this,t);break}case T.IN_ROW:{Mn(this,t);break}case T.IN_CELL:{Mm(this,t);break}case T.IN_SELECT:{jo(this,t);break}case T.IN_SELECT_IN_TABLE:{Fm(this,t);break}case T.IN_TEMPLATE:{Um(this,t);break}case T.AFTER_BODY:{qm(this,t);break}case T.IN_FRAMESET:{Wm(this,t);break}case T.AFTER_FRAMESET:{Ym(this,t);break}case T.AFTER_AFTER_BODY:{Vm(this,t);break}case T.AFTER_AFTER_FRAMESET:{zm(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?Zm(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case T.INITIAL:{gs(this,t);break}case T.BEFORE_HTML:{Lp(this,t);break}case T.BEFORE_HEAD:{Dp(this,t);break}case T.IN_HEAD:{Pp(this,t);break}case T.IN_HEAD_NO_SCRIPT:{Mp(this,t);break}case T.AFTER_HEAD:{Fp(this,t);break}case T.IN_BODY:{Pn(this,t);break}case T.TEXT:{vm(this,t);break}case T.IN_TABLE:{Ps(this,t);break}case T.IN_TABLE_TEXT:{bs(this,t);break}case T.IN_CAPTION:{Pm(this,t);break}case T.IN_COLUMN_GROUP:{Om(this,t);break}case T.IN_TABLE_BODY:{xa(this,t);break}case T.IN_ROW:{Io(this,t);break}case T.IN_CELL:{Bm(this,t);break}case T.IN_SELECT:{Lo(this,t);break}case T.IN_SELECT_IN_TABLE:{Hm(this,t);break}case T.IN_TEMPLATE:{$m(this,t);break}case T.AFTER_BODY:{Do(this,t);break}case T.IN_FRAMESET:{Km(this,t);break}case T.AFTER_FRAMESET:{Gm(this,t);break}case T.AFTER_AFTER_BODY:{Js(this,t);break}}}onEof(t){switch(this.insertionMode){case T.INITIAL:{gs(this,t);break}case T.BEFORE_HTML:{Cs(this,t);break}case T.BEFORE_HEAD:{_s(this,t);break}case T.IN_HEAD:{ws(this,t);break}case T.IN_HEAD_NO_SCRIPT:{Ss(this,t);break}case T.AFTER_HEAD:{As(this,t);break}case T.IN_BODY:case T.IN_TABLE:case T.IN_CAPTION:case T.IN_COLUMN_GROUP:case T.IN_TABLE_BODY:case T.IN_ROW:case T.IN_CELL:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:{_o(this,t);break}case T.TEXT:{Cm(this,t);break}case T.IN_TABLE_TEXT:{bs(this,t);break}case T.IN_TEMPLATE:{Ro(this,t);break}case T.AFTER_BODY:case T.IN_FRAMESET:case T.AFTER_FRAMESET:case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{Ba(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===h.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:case T.TEXT:case T.IN_COLUMN_GROUP:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:case T.IN_FRAMESET:case T.AFTER_FRAMESET:{this._insertCharacters(t);break}case T.IN_BODY:case T.IN_CAPTION:case T.IN_CELL:case T.IN_TEMPLATE:case T.AFTER_BODY:case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{yo(this,t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Qn(this,t);break}case T.IN_TABLE_TEXT:{wo(this,t);break}}}}function Np(e,t){let n=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return n?e.openElements.contains(n.element)?e.openElements.hasInScope(t.tagID)||(n=null):(e.activeFormattingElements.removeEntry(n),n=null):Co(e,t),n}function kp(e,t){let n=null,i=e.openElements.stackTop;for(;i>=0;i--){const a=e.openElements.items[i];if(a===t.element)break;e._isSpecialElement(a,e.openElements.tagIDs[i])&&(n=a)}return n||(e.openElements.shortenToLength(Math.max(i,0)),e.activeFormattingElements.removeEntry(t)),n}function vp(e,t,n){let i=t,a=e.openElements.getCommonAncestor(t);for(let o=0,l=a;l!==n;o++,l=a){a=e.openElements.getCommonAncestor(l);const u=e.activeFormattingElements.getElementEntry(l),p=u&&o>=xp;!u||p?(p&&e.activeFormattingElements.removeEntry(u),e.openElements.remove(l)):(l=Cp(e,u),i===t&&(e.activeFormattingElements.bookmark=u),e.treeAdapter.detachNode(i),e.treeAdapter.appendChild(l,i),i=l)}return i}function Cp(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),i=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,i),t.element=i,i}function _p(e,t,n){const i=e.treeAdapter.getTagName(t),a=ds(i);if(e._isElementCausesFosterParenting(a))e._fosterParentElement(n);else{const o=e.treeAdapter.getNamespaceURI(t);a===r.TEMPLATE&&o===Z.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function wp(e,t,n){const i=e.treeAdapter.getNamespaceURI(n.element),{token:a}=n,o=e.treeAdapter.createElement(a.tagName,i,a.attrs);e._adoptNodes(t,o),e.treeAdapter.appendChild(t,o),e.activeFormattingElements.insertElementAfterBookmark(o,a),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,o,a.tagID)}function Ma(e,t){for(let n=0;n<Tp;n++){const i=Np(e,t);if(!i)break;const a=kp(e,i);if(!a)break;e.activeFormattingElements.bookmark=i;const o=vp(e,a,i.element),l=e.openElements.getCommonAncestor(i.element);e.treeAdapter.detachNode(o),l&&_p(e,l,o),wp(e,a,i)}}function Ta(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function Sp(e,t){e._appendCommentNode(t,e.openElements.items[0])}function Ap(e,t){e._appendCommentNode(t,e.document)}function Ba(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let i=e.openElements.stackTop;i>=n;i--)e._setEndLocation(e.openElements.items[i],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const i=e.openElements.items[0],a=e.treeAdapter.getNodeSourceCodeLocation(i);if(a&&!a.endTag&&(e._setEndLocation(i,t),e.openElements.stackTop>=1)){const o=e.openElements.items[1],l=e.treeAdapter.getNodeSourceCodeLocation(o);l&&!l.endTag&&e._setEndLocation(o,t)}}}}function Ip(e,t){e._setDocumentType(t);const n=t.forceQuirks?ut.QUIRKS:rp(t);ip(t)||e._err(t,U.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=T.BEFORE_HTML}function gs(e,t){e._err(t,U.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,ut.QUIRKS),e.insertionMode=T.BEFORE_HTML,e._processToken(t)}function jp(e,t){t.tagID===r.HTML?(e._insertElement(t,Z.HTML),e.insertionMode=T.BEFORE_HEAD):Cs(e,t)}function Lp(e,t){const n=t.tagID;(n===r.HTML||n===r.HEAD||n===r.BODY||n===r.BR)&&Cs(e,t)}function Cs(e,t){e._insertFakeRootElement(),e.insertionMode=T.BEFORE_HEAD,e._processToken(t)}function Rp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.HEAD:{e._insertElement(t,Z.HTML),e.headElement=e.openElements.current,e.insertionMode=T.IN_HEAD;break}default:_s(e,t)}}function Dp(e,t){const n=t.tagID;n===r.HEAD||n===r.BODY||n===r.HTML||n===r.BR?_s(e,t):e._err(t,U.endTagWithoutMatchingOpenElement)}function _s(e,t){e._insertFakeElement(j.HEAD,r.HEAD),e.headElement=e.openElements.current,e.insertionMode=T.IN_HEAD,e._processToken(t)}function gt(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:{e._appendElement(t,Z.HTML),t.ackSelfClosing=!0;break}case r.TITLE:{e._switchToTextParsing(t,Ye.RCDATA);break}case r.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,Ye.RAWTEXT):(e._insertElement(t,Z.HTML),e.insertionMode=T.IN_HEAD_NO_SCRIPT);break}case r.NOFRAMES:case r.STYLE:{e._switchToTextParsing(t,Ye.RAWTEXT);break}case r.SCRIPT:{e._switchToTextParsing(t,Ye.SCRIPT_DATA);break}case r.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=T.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(T.IN_TEMPLATE);break}case r.HEAD:{e._err(t,U.misplacedStartTagForHeadElement);break}default:ws(e,t)}}function Pp(e,t){switch(t.tagID){case r.HEAD:{e.openElements.pop(),e.insertionMode=T.AFTER_HEAD;break}case r.BODY:case r.BR:case r.HTML:{ws(e,t);break}case r.TEMPLATE:{Qt(e,t);break}default:e._err(t,U.endTagWithoutMatchingOpenElement)}}function Qt(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==r.TEMPLATE&&e._err(t,U.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,U.endTagWithoutMatchingOpenElement)}function ws(e,t){e.openElements.pop(),e.insertionMode=T.AFTER_HEAD,e._processToken(t)}function Op(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BASEFONT:case r.BGSOUND:case r.HEAD:case r.LINK:case r.META:case r.NOFRAMES:case r.STYLE:{gt(e,t);break}case r.NOSCRIPT:{e._err(t,U.nestedNoscriptInHead);break}default:Ss(e,t)}}function Mp(e,t){switch(t.tagID){case r.NOSCRIPT:{e.openElements.pop(),e.insertionMode=T.IN_HEAD;break}case r.BR:{Ss(e,t);break}default:e._err(t,U.endTagWithoutMatchingOpenElement)}}function Ss(e,t){const n=t.type===Oe.EOF?U.openElementsLeftAfterEof:U.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=T.IN_HEAD,e._processToken(t)}function Bp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BODY:{e._insertElement(t,Z.HTML),e.framesetOk=!1,e.insertionMode=T.IN_BODY;break}case r.FRAMESET:{e._insertElement(t,Z.HTML),e.insertionMode=T.IN_FRAMESET;break}case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:case r.NOFRAMES:case r.SCRIPT:case r.STYLE:case r.TEMPLATE:case r.TITLE:{e._err(t,U.abandonedHeadElementChild),e.openElements.push(e.headElement,r.HEAD),gt(e,t),e.openElements.remove(e.headElement);break}case r.HEAD:{e._err(t,U.misplacedStartTagForHeadElement);break}default:As(e,t)}}function Fp(e,t){switch(t.tagID){case r.BODY:case r.HTML:case r.BR:{As(e,t);break}case r.TEMPLATE:{Qt(e,t);break}default:e._err(t,U.endTagWithoutMatchingOpenElement)}}function As(e,t){e._insertFakeElement(j.BODY,r.BODY),e.insertionMode=T.IN_BODY,Dn(e,t)}function Dn(e,t){switch(t.type){case Oe.CHARACTER:{No(e,t);break}case Oe.WHITESPACE_CHARACTER:{yo(e,t);break}case Oe.COMMENT:{Ta(e,t);break}case Oe.START_TAG:{Ze(e,t);break}case Oe.END_TAG:{Pn(e,t);break}case Oe.EOF:{_o(e,t);break}}}function yo(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function No(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function Hp(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function Up(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function $p(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Z.HTML),e.insertionMode=T.IN_FRAMESET)}function qp(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML)}function Wp(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Ea.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Z.HTML)}function Kp(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function Yp(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML),n||(e.formElement=e.openElements.current))}function Gp(e,t){e.framesetOk=!1;const n=t.tagID;for(let i=e.openElements.stackTop;i>=0;i--){const a=e.openElements.tagIDs[i];if(n===r.LI&&a===r.LI||(n===r.DD||n===r.DT)&&(a===r.DD||a===r.DT)){e.openElements.generateImpliedEndTagsWithExclusion(a),e.openElements.popUntilTagNamePopped(a);break}if(a!==r.ADDRESS&&a!==r.DIV&&a!==r.P&&e._isSpecialElement(e.openElements.items[i],a))break}e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML)}function Vp(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML),e.tokenizer.state=Ye.PLAINTEXT}function zp(e,t){e.openElements.hasInScope(r.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML),e.framesetOk=!1}function Qp(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(j.A);n&&(Ma(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Xp(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Jp(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(r.NOBR)&&(Ma(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Z.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Zp(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function em(e,t){e.treeAdapter.getDocumentMode(e.document)!==ut.QUIRKS&&e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML),e.framesetOk=!1,e.insertionMode=T.IN_TABLE}function ko(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Z.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function vo(e){const t=po(e,Gt.TYPE);return t!=null&&t.toLowerCase()===Ep}function tm(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Z.HTML),vo(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function sm(e,t){e._appendElement(t,Z.HTML),t.ackSelfClosing=!0}function nm(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._appendElement(t,Z.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function am(e,t){t.tagName=j.IMG,t.tagID=r.IMG,ko(e,t)}function im(e,t){e._insertElement(t,Z.HTML),e.skipNextNewLine=!0,e.tokenizer.state=Ye.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=T.TEXT}function rm(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Ye.RAWTEXT)}function om(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Ye.RAWTEXT)}function $i(e,t){e._switchToTextParsing(t,Ye.RAWTEXT)}function lm(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===T.IN_TABLE||e.insertionMode===T.IN_CAPTION||e.insertionMode===T.IN_TABLE_BODY||e.insertionMode===T.IN_ROW||e.insertionMode===T.IN_CELL?T.IN_SELECT_IN_TABLE:T.IN_SELECT}function cm(e,t){e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML)}function um(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Z.HTML)}function dm(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(r.RTC),e._insertElement(t,Z.HTML)}function pm(e,t){e._reconstructActiveFormattingElements(),Eo(t),Oa(t),t.selfClosing?e._appendElement(t,Z.MATHML):e._insertElement(t,Z.MATHML),t.ackSelfClosing=!0}function mm(e,t){e._reconstructActiveFormattingElements(),To(t),Oa(t),t.selfClosing?e._appendElement(t,Z.SVG):e._insertElement(t,Z.SVG),t.ackSelfClosing=!0}function qi(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML)}function Ze(e,t){switch(t.tagID){case r.I:case r.S:case r.B:case r.U:case r.EM:case r.TT:case r.BIG:case r.CODE:case r.FONT:case r.SMALL:case r.STRIKE:case r.STRONG:{Xp(e,t);break}case r.A:{Qp(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Wp(e,t);break}case r.P:case r.DL:case r.OL:case r.UL:case r.DIV:case r.DIR:case r.NAV:case r.MAIN:case r.MENU:case r.ASIDE:case r.CENTER:case r.FIGURE:case r.FOOTER:case r.HEADER:case r.HGROUP:case r.DIALOG:case r.DETAILS:case r.ADDRESS:case r.ARTICLE:case r.SEARCH:case r.SECTION:case r.SUMMARY:case r.FIELDSET:case r.BLOCKQUOTE:case r.FIGCAPTION:{qp(e,t);break}case r.LI:case r.DD:case r.DT:{Gp(e,t);break}case r.BR:case r.IMG:case r.WBR:case r.AREA:case r.EMBED:case r.KEYGEN:{ko(e,t);break}case r.HR:{nm(e,t);break}case r.RB:case r.RTC:{um(e,t);break}case r.RT:case r.RP:{dm(e,t);break}case r.PRE:case r.LISTING:{Kp(e,t);break}case r.XMP:{rm(e,t);break}case r.SVG:{mm(e,t);break}case r.HTML:{Hp(e,t);break}case r.BASE:case r.LINK:case r.META:case r.STYLE:case r.TITLE:case r.SCRIPT:case r.BGSOUND:case r.BASEFONT:case r.TEMPLATE:{gt(e,t);break}case r.BODY:{Up(e,t);break}case r.FORM:{Yp(e,t);break}case r.NOBR:{Jp(e,t);break}case r.MATH:{pm(e,t);break}case r.TABLE:{em(e,t);break}case r.INPUT:{tm(e,t);break}case r.PARAM:case r.TRACK:case r.SOURCE:{sm(e,t);break}case r.IMAGE:{am(e,t);break}case r.BUTTON:{zp(e,t);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{Zp(e,t);break}case r.IFRAME:{om(e,t);break}case r.SELECT:{lm(e,t);break}case r.OPTION:case r.OPTGROUP:{cm(e,t);break}case r.NOEMBED:case r.NOFRAMES:{$i(e,t);break}case r.FRAMESET:{$p(e,t);break}case r.TEXTAREA:{im(e,t);break}case r.NOSCRIPT:{e.options.scriptingEnabled?$i(e,t):qi(e,t);break}case r.PLAINTEXT:{Vp(e,t);break}case r.COL:case r.TH:case r.TD:case r.TR:case r.HEAD:case r.FRAME:case r.TBODY:case r.TFOOT:case r.THEAD:case r.CAPTION:case r.COLGROUP:break;default:qi(e,t)}}function hm(e,t){if(e.openElements.hasInScope(r.BODY)&&(e.insertionMode=T.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function fm(e,t){e.openElements.hasInScope(r.BODY)&&(e.insertionMode=T.AFTER_BODY,Do(e,t))}function gm(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function bm(e){const t=e.openElements.tmplCount>0,{formElement:n}=e;t||(e.formElement=null),(n||t)&&e.openElements.hasInScope(r.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(r.FORM):n&&e.openElements.remove(n))}function Em(e){e.openElements.hasInButtonScope(r.P)||e._insertFakeElement(j.P,r.P),e._closePElement()}function Tm(e){e.openElements.hasInListItemScope(r.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(r.LI),e.openElements.popUntilTagNamePopped(r.LI))}function xm(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function ym(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function Nm(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function km(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(j.BR,r.BR),e.openElements.pop(),e.framesetOk=!1}function Co(e,t){const n=t.tagName,i=t.tagID;for(let a=e.openElements.stackTop;a>0;a--){const o=e.openElements.items[a],l=e.openElements.tagIDs[a];if(i===l&&(i!==r.UNKNOWN||e.treeAdapter.getTagName(o)===n)){e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.stackTop>=a&&e.openElements.shortenToLength(a);break}if(e._isSpecialElement(o,l))break}}function Pn(e,t){switch(t.tagID){case r.A:case r.B:case r.I:case r.S:case r.U:case r.EM:case r.TT:case r.BIG:case r.CODE:case r.FONT:case r.NOBR:case r.SMALL:case r.STRIKE:case r.STRONG:{Ma(e,t);break}case r.P:{Em(e);break}case r.DL:case r.UL:case r.OL:case r.DIR:case r.DIV:case r.NAV:case r.PRE:case r.MAIN:case r.MENU:case r.ASIDE:case r.BUTTON:case r.CENTER:case r.FIGURE:case r.FOOTER:case r.HEADER:case r.HGROUP:case r.DIALOG:case r.ADDRESS:case r.ARTICLE:case r.DETAILS:case r.SEARCH:case r.SECTION:case r.SUMMARY:case r.LISTING:case r.FIELDSET:case r.BLOCKQUOTE:case r.FIGCAPTION:{gm(e,t);break}case r.LI:{Tm(e);break}case r.DD:case r.DT:{xm(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{ym(e);break}case r.BR:{km(e);break}case r.BODY:{hm(e,t);break}case r.HTML:{fm(e,t);break}case r.FORM:{bm(e);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{Nm(e,t);break}case r.TEMPLATE:{Qt(e,t);break}default:Co(e,t)}}function _o(e,t){e.tmplInsertionModeStack.length>0?Ro(e,t):Ba(e,t)}function vm(e,t){var n;t.tagID===r.SCRIPT&&((n=e.scriptHandler)===null||n===void 0||n.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function Cm(e,t){e._err(t,U.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Qn(e,t){if(e.openElements.currentTagId!==void 0&&xo.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=T.IN_TABLE_TEXT,t.type){case Oe.CHARACTER:{So(e,t);break}case Oe.WHITESPACE_CHARACTER:{wo(e,t);break}}else Bs(e,t)}function _m(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Z.HTML),e.insertionMode=T.IN_CAPTION}function wm(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Z.HTML),e.insertionMode=T.IN_COLUMN_GROUP}function Sm(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(j.COLGROUP,r.COLGROUP),e.insertionMode=T.IN_COLUMN_GROUP,Fa(e,t)}function Am(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Z.HTML),e.insertionMode=T.IN_TABLE_BODY}function Im(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(j.TBODY,r.TBODY),e.insertionMode=T.IN_TABLE_BODY,On(e,t)}function jm(e,t){e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function Lm(e,t){vo(t)?e._appendElement(t,Z.HTML):Bs(e,t),t.ackSelfClosing=!0}function Rm(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,Z.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function os(e,t){switch(t.tagID){case r.TD:case r.TH:case r.TR:{Im(e,t);break}case r.STYLE:case r.SCRIPT:case r.TEMPLATE:{gt(e,t);break}case r.COL:{Sm(e,t);break}case r.FORM:{Rm(e,t);break}case r.TABLE:{jm(e,t);break}case r.TBODY:case r.TFOOT:case r.THEAD:{Am(e,t);break}case r.INPUT:{Lm(e,t);break}case r.CAPTION:{_m(e,t);break}case r.COLGROUP:{wm(e,t);break}default:Bs(e,t)}}function Ps(e,t){switch(t.tagID){case r.TABLE:{e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode());break}case r.TEMPLATE:{Qt(e,t);break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:case r.TBODY:case r.TD:case r.TFOOT:case r.TH:case r.THEAD:case r.TR:break;default:Bs(e,t)}}function Bs(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,Dn(e,t),e.fosterParentingEnabled=n}function wo(e,t){e.pendingCharacterTokens.push(t)}function So(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function bs(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)Bs(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const Ao=new Set([r.CAPTION,r.COL,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]);function Dm(e,t){const n=t.tagID;Ao.has(n)?e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_TABLE,os(e,t)):Ze(e,t)}function Pm(e,t){const n=t.tagID;switch(n){case r.CAPTION:case r.TABLE:{e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_TABLE,n===r.TABLE&&Ps(e,t));break}case r.BODY:case r.COL:case r.COLGROUP:case r.HTML:case r.TBODY:case r.TD:case r.TFOOT:case r.TH:case r.THEAD:case r.TR:break;default:Pn(e,t)}}function Fa(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.COL:{e._appendElement(t,Z.HTML),t.ackSelfClosing=!0;break}case r.TEMPLATE:{gt(e,t);break}default:Nn(e,t)}}function Om(e,t){switch(t.tagID){case r.COLGROUP:{e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=T.IN_TABLE);break}case r.TEMPLATE:{Qt(e,t);break}case r.COL:break;default:Nn(e,t)}}function Nn(e,t){e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=T.IN_TABLE,e._processToken(t))}function On(e,t){switch(t.tagID){case r.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,Z.HTML),e.insertionMode=T.IN_ROW;break}case r.TH:case r.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(j.TR,r.TR),e.insertionMode=T.IN_ROW,Mn(e,t);break}case r.CAPTION:case r.COL:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE,os(e,t));break}default:os(e,t)}}function xa(e,t){const n=t.tagID;switch(t.tagID){case r.TBODY:case r.TFOOT:case r.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE);break}case r.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE,Ps(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:case r.TD:case r.TH:case r.TR:break;default:Ps(e,t)}}function Mn(e,t){switch(t.tagID){case r.TH:case r.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,Z.HTML),e.insertionMode=T.IN_CELL,e.activeFormattingElements.insertMarker();break}case r.CAPTION:case r.COL:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,On(e,t));break}default:os(e,t)}}function Io(e,t){switch(t.tagID){case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY);break}case r.TABLE:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,xa(e,t));break}case r.TBODY:case r.TFOOT:case r.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(r.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,xa(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:case r.TD:case r.TH:break;default:Ps(e,t)}}function Mm(e,t){const n=t.tagID;Ao.has(n)?(e.openElements.hasInTableScope(r.TD)||e.openElements.hasInTableScope(r.TH))&&(e._closeTableCell(),Mn(e,t)):Ze(e,t)}function Bm(e,t){const n=t.tagID;switch(n){case r.TD:case r.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_ROW);break}case r.TABLE:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),Io(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:break;default:Pn(e,t)}}function jo(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.OPTION:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e._insertElement(t,Z.HTML);break}case r.OPTGROUP:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._insertElement(t,Z.HTML);break}case r.HR:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._appendElement(t,Z.HTML),t.ackSelfClosing=!0;break}case r.INPUT:case r.KEYGEN:case r.TEXTAREA:case r.SELECT:{e.openElements.hasInSelectScope(r.SELECT)&&(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),t.tagID!==r.SELECT&&e._processStartTag(t));break}case r.SCRIPT:case r.TEMPLATE:{gt(e,t);break}}}function Lo(e,t){switch(t.tagID){case r.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===r.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===r.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop();break}case r.OPTION:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop();break}case r.SELECT:{e.openElements.hasInSelectScope(r.SELECT)&&(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode());break}case r.TEMPLATE:{Qt(e,t);break}}}function Fm(e,t){const n=t.tagID;n===r.CAPTION||n===r.TABLE||n===r.TBODY||n===r.TFOOT||n===r.THEAD||n===r.TR||n===r.TD||n===r.TH?(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),e._processStartTag(t)):jo(e,t)}function Hm(e,t){const n=t.tagID;n===r.CAPTION||n===r.TABLE||n===r.TBODY||n===r.TFOOT||n===r.THEAD||n===r.TR||n===r.TD||n===r.TH?e.openElements.hasInTableScope(n)&&(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Lo(e,t)}function Um(e,t){switch(t.tagID){case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:case r.NOFRAMES:case r.SCRIPT:case r.STYLE:case r.TEMPLATE:case r.TITLE:{gt(e,t);break}case r.CAPTION:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.tmplInsertionModeStack[0]=T.IN_TABLE,e.insertionMode=T.IN_TABLE,os(e,t);break}case r.COL:{e.tmplInsertionModeStack[0]=T.IN_COLUMN_GROUP,e.insertionMode=T.IN_COLUMN_GROUP,Fa(e,t);break}case r.TR:{e.tmplInsertionModeStack[0]=T.IN_TABLE_BODY,e.insertionMode=T.IN_TABLE_BODY,On(e,t);break}case r.TD:case r.TH:{e.tmplInsertionModeStack[0]=T.IN_ROW,e.insertionMode=T.IN_ROW,Mn(e,t);break}default:e.tmplInsertionModeStack[0]=T.IN_BODY,e.insertionMode=T.IN_BODY,Ze(e,t)}}function $m(e,t){t.tagID===r.TEMPLATE&&Qt(e,t)}function Ro(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):Ba(e,t)}function qm(e,t){t.tagID===r.HTML?Ze(e,t):kn(e,t)}function Do(e,t){var n;if(t.tagID===r.HTML){if(e.fragmentContext||(e.insertionMode=T.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===r.HTML){e._setEndLocation(e.openElements.items[0],t);const i=e.openElements.items[1];i&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(i))===null||n===void 0)&&n.endTag)&&e._setEndLocation(i,t)}}else kn(e,t)}function kn(e,t){e.insertionMode=T.IN_BODY,Dn(e,t)}function Wm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.FRAMESET:{e._insertElement(t,Z.HTML);break}case r.FRAME:{e._appendElement(t,Z.HTML),t.ackSelfClosing=!0;break}case r.NOFRAMES:{gt(e,t);break}}}function Km(e,t){t.tagID===r.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==r.FRAMESET&&(e.insertionMode=T.AFTER_FRAMESET))}function Ym(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{gt(e,t);break}}}function Gm(e,t){t.tagID===r.HTML&&(e.insertionMode=T.AFTER_AFTER_FRAMESET)}function Vm(e,t){t.tagID===r.HTML?Ze(e,t):Js(e,t)}function Js(e,t){e.insertionMode=T.IN_BODY,Dn(e,t)}function zm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{gt(e,t);break}}}function Qm(e,t){t.chars=qe,e._insertCharacters(t)}function Xm(e,t){e._insertCharacters(t),e.framesetOk=!1}function Po(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Z.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function Jm(e,t){if(mp(t))Po(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),i=e.treeAdapter.getNamespaceURI(n);i===Z.MATHML?Eo(t):i===Z.SVG&&(hp(t),To(t)),Oa(t),t.selfClosing?e._appendElement(t,i):e._insertElement(t,i),t.ackSelfClosing=!0}}function Zm(e,t){if(t.tagID===r.P||t.tagID===r.BR){Po(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const i=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(i)===Z.HTML){e._endTagOutsideForeignContent(t);break}const a=e.treeAdapter.getTagName(i);if(a.toLowerCase()===t.tagName){t.tagName=a,e.openElements.shortenToLength(n);break}}}j.AREA,j.BASE,j.BASEFONT,j.BGSOUND,j.BR,j.COL,j.EMBED,j.FRAME,j.HR,j.IMG,j.INPUT,j.KEYGEN,j.LINK,j.META,j.PARAM,j.SOURCE,j.TRACK,j.WBR;const eh=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,th=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),Wi={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function Oo(e,t){const n=dh(e),i=kr("type",{handlers:{root:sh,element:nh,text:ah,comment:Bo,doctype:ih,raw:oh},unknown:lh}),a={parser:n?new Ui(Wi):Ui.getFragmentParser(void 0,Wi),handle(u){i(u,a)},stitches:!1,options:t||{}};i(e,a),ps(a,Vt());const o=n?a.parser.document:a.parser.getFragment(),l=pd(o,{file:a.options.file});return a.stitches&&Ql(l,"comment",function(u,p,E){const m=u;if(m.value.stitch&&E&&p!==void 0){const f=E.children;return f[p]=m.value.stitch,p}}),l.type==="root"&&l.children.length===1&&l.children[0].type===e.type?l.children[0]:l}function Mo(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function sh(e,t){Mo(e.children,t)}function nh(e,t){ch(e,t),Mo(e.children,t),uh(e,t)}function ah(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:Oe.CHARACTER,chars:e.value,location:Fs(e)};ps(t,Vt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function ih(e,t){const n={type:Oe.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Fs(e)};ps(t,Vt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function rh(e,t){t.stitches=!0;const n=ph(e);if("children"in e&&"children"in n){const i=Oo({type:"root",children:e.children},t.options);n.children=i.children}Bo({type:"comment",value:{stitch:n}},t)}function Bo(e,t){const n=e.value,i={type:Oe.COMMENT,data:n,location:Fs(e)};ps(t,Vt(e)),t.parser.currentToken=i,t.parser._processToken(t.parser.currentToken)}function oh(e,t){if(t.parser.tokenizer.preprocessor.html="",t.parser.tokenizer.preprocessor.pos=-1,t.parser.tokenizer.preprocessor.lastGapPos=-2,t.parser.tokenizer.preprocessor.gapStack=[],t.parser.tokenizer.preprocessor.skipNextNewLine=!1,t.parser.tokenizer.preprocessor.lastChunkWritten=!1,t.parser.tokenizer.preprocessor.endOfChunkHit=!1,t.parser.tokenizer.preprocessor.isEol=!1,Fo(t,Vt(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(eh,"<$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;const n=t.parser.tokenizer._consume();t.parser.tokenizer._callState(n)}}function lh(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))rh(n,t);else{let i="";throw th.has(n.type)&&(i=". It looks like you are using MDX nodes with `hast-util-raw` (or `rehype-raw`). If you use this because you are using remark or rehype plugins that inject `'html'` nodes, then please raise an issue with that plugin, as its a bad and slow idea. If you use this because you are using markdown syntax, then you have to configure this utility (or plugin) to pass through these nodes (see `passThrough` in docs), but you can also migrate to use the MDX syntax"),new Error("Cannot compile `"+n.type+"` node"+i)}}function ps(e,t){Fo(e,t);const n=e.parser.tokenizer.currentCharacterToken;n&&n.location&&(n.location.endLine=e.parser.tokenizer.preprocessor.line,n.location.endCol=e.parser.tokenizer.preprocessor.col+1,n.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=n,e.parser._processToken(e.parser.currentToken)),e.parser.tokenizer.paused=!1,e.parser.tokenizer.inLoop=!1,e.parser.tokenizer.active=!1,e.parser.tokenizer.returnState=Ye.DATA,e.parser.tokenizer.charRefCode=-1,e.parser.tokenizer.consumedAfterSnapshot=-1,e.parser.tokenizer.currentLocation=null,e.parser.tokenizer.currentCharacterToken=null,e.parser.tokenizer.currentToken=null,e.parser.tokenizer.currentAttr={name:"",value:""}}function Fo(e,t){if(t&&t.offset!==void 0){const n={startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:-1,endCol:-1,endOffset:-1};e.parser.tokenizer.preprocessor.lineStartPos=-t.column+1,e.parser.tokenizer.preprocessor.droppedBufferSize=t.offset,e.parser.tokenizer.preprocessor.line=t.line,e.parser.tokenizer.currentLocation=n}}function ch(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===Ye.PLAINTEXT)return;ps(t,Vt(e));const i=t.parser.openElements.current;let a="namespaceURI"in i?i.namespaceURI:Wt.html;a===Wt.html&&n==="svg"&&(a=Wt.svg);const o=bd({...e,children:[]},{space:a===Wt.svg?"svg":"html"}),l={type:Oe.START_TAG,tagName:n,tagID:ds(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in o?o.attrs:[],location:Fs(e)};t.parser.currentToken=l,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function uh(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&Cd.includes(n)||t.parser.tokenizer.state===Ye.PLAINTEXT)return;ps(t,vr(e));const i={type:Oe.END_TAG,tagName:n,tagID:ds(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:Fs(e)};t.parser.currentToken=i,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===Ye.RCDATA||t.parser.tokenizer.state===Ye.RAWTEXT||t.parser.tokenizer.state===Ye.SCRIPT_DATA)&&(t.parser.tokenizer.state=Ye.DATA)}function dh(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function Fs(e){const t=Vt(e)||{line:void 0,column:void 0,offset:void 0},n=vr(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:n.line,endCol:n.column,endOffset:n.offset}}function ph(e){return"children"in e?Ga({...e,children:[]}):Ga(e)}function mh(e){return function(t,n){return Oo(t,{...e,file:n})}}const vn=c.memo(function({text:t}){const n=je(),[i,a]=c.useState(!1);return t?s.jsx("button",{type:"button",className:"copy-btn",title:n("copy"),onClick:()=>{navigator.clipboard.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),1200)})},children:i?s.jsx(Tt,{}):s.jsx(wt,{})}):null});function hh(e){const t=i=>{if(typeof i=="string"||typeof i=="number"){const a=String(i);return a===""?[[]]:a.split(`
|
|
309
|
+
`).map(o=>o===""?[]:[o])}if(Array.isArray(i)){let a=[];for(const o of i){const l=t(o);if(a.length===0)a=l;else{const u=l[0]??[];a[a.length-1].push(...u),a.push(...l.slice(1))}}return a}if(i&&typeof i=="object"&&"props"in i){const a=i,o=a.props?.children,l={...a.props,children:void 0},u=o==null?[]:t(o);return u.length===0?[[c.createElement(a.type,l)]]:u.map(p=>[c.createElement(a.type,l,...p)])}return[[i]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function ya(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(ya).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return ya(t?.children)}return""}function fh(e){const t=Array.isArray(e)?e[0]:e;return!t||typeof t!="object"||!("props"in t)?null:t}function gh(e){const n=fh(e)?.props?.className;if(typeof n!="string")return null;const i=n.match(/(?:^|\s)language-([A-Za-z0-9_+\-]+)(?:\s|$)/);return i?i[1]:null}const Ki="pi-web-ui:plugin-data";let Is=new Map,js=new Map,is=new Set,Na=-1,Ho=0;const ka=new Set;function bh(){Ho++;for(const e of ka)e()}function Eh(e){return ka.add(e),()=>{ka.delete(e)}}function Yi(){return Ho}let Uo=null;function Th(e){Uo=e}function xh(e,t){t!==Na&&(Na=t,js.clear(),is.clear());const n=new Map;for(const a of e)if(!(a.error||!a.renderers))for(const o of a.renderers)n.has(o)||n.set(o,a.id);let i=n.size!==Is.size;if(!i){for(const[a,o]of n)if(Is.get(a)!==o){i=!0;break}}if(i){for(const a of js.keys())n.has(a)||js.delete(a);for(const a of is)n.has(a)||is.delete(a);Is=n,bh()}}async function yh(e,t){const n=Is.get(e);if(!n)return null;let i=js.get(e);if(!i&&!is.has(e))try{const l=(await import(tt(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${Na}`))).default?.renderers?.[e];typeof l=="function"?(i={pluginId:n,renderer:l},js.set(e,i)):(is.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(o){is.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,o)}if(!i)return null;const a={pluginId:i.pluginId,send:o=>{Uo?.({type:"plugin_message",pluginId:i.pluginId,payload:o})},onData:o=>{const l=u=>{const p=u.detail;p.pluginId===i.pluginId&&o(p.payload)};return window.addEventListener(Ki,l),()=>window.removeEventListener(Ki,l)}};try{const o=await i.renderer(t,a);return o instanceof HTMLElement?o:null}catch(o){return console.error(`[plugin:${i.pluginId}] renderer("${e}") 执行失败:`,o),null}}function Nh(e){return Is.has(e)}const va="pi-web-ui:theme",$o="dark",Gi="theme-stylesheet",Mt="pi-web-ui:theme-change";function qo(){try{const e=localStorage.getItem(va);if(e&&e!==$o)return e}catch{}return null}function kh(e){try{e?localStorage.setItem(va,e):localStorage.removeItem(va)}catch{}}function Wo(e){let t=document.getElementById(Gi);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Mt));return}t||(t=document.createElement("link"),t.id=Gi,t.rel="stylesheet",document.head.appendChild(t)),t.href=tt(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Mt))}async function vh(){try{const e=await fetch(vt(tt("/api/themes")));if(!e.ok)return[];const t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function Ch(){const[e,t]=c.useState([]),[n,i]=c.useState(()=>qo());return c.useEffect(()=>{let o=!1;return vh().then(l=>{o||t(l)}),()=>{o=!0}},[]),c.useEffect(()=>{Wo(n),kh(n)},[n]),{themes:e,theme:n,switchTheme:o=>i(o===$o?null:o)}}function Ng(){const e=getComputedStyle(document.documentElement),t=(n,i)=>e.getPropertyValue(n).trim()||i;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 _h({lang:e,code:t}){const n=c.useRef(null),i=c.useRef(null),a=c.useRef(0),o=c.useRef(new WeakMap),[l,u]=c.useState(null);return c.useEffect(()=>{const p=()=>{const E=++a.current,m=i.current;m&&(m.dispatchEvent(new CustomEvent(Mt)),o.current.set(m,E))};return window.addEventListener(Mt,p),()=>window.removeEventListener(Mt,p)},[]),c.useEffect(()=>{let p=!1;const E=a.current;return u(null),yh(e,t).then(m=>{p||(m&&o.current.set(m,E),u(m))}),()=>{p=!0}},[e,t]),c.useEffect(()=>{i.current=l;const p=n.current;return p&&(p.replaceChildren(),l&&(p.appendChild(l),(o.current.get(l)??a.current)<a.current&&(l.dispatchEvent(new CustomEvent(Mt)),o.current.set(l,a.current)))),()=>{i.current===l&&(i.current=null)}},[l]),l?s.jsx("div",{className:"plugin-fence",ref:n}):s.jsxs("div",{className:"codeblock",children:[s.jsx(vn,{text:t}),s.jsx("pre",{children:s.jsx("code",{children:t})})]})}const wh=[Cr,_r],Sh=[Cr,cd,_r],Vi=[[Jl,{strict:!1,throwOnError:!1}],[Zl,{detect:!0,ignoreMissing:!0}]];function Ha({text:e,rawHtml:t=!1,hardBreaks:n=!1}){const i=t?[mh,...Vi]:Vi;return s.jsx(Xl,{remarkPlugins:n?Sh:wh,rehypePlugins:i,components:{pre:Ah},children:e})}const rt=c.memo(function({text:t,rawHtml:n=!1,hardBreaks:i=!1}){return s.jsx("div",{className:"md",children:s.jsx(Ha,{text:t,rawHtml:n,hardBreaks:i})})});function Ah({children:e,...t}){c.useSyncExternalStore(Eh,Yi,Yi);const n=gh(e);return n&&Nh(n)?s.jsx(_h,{lang:n,code:ya(e)}):s.jsx(Ih,{children:e,...t})}function Ih({children:e,...t}){const n=e&&typeof e=="object"&&"props"in e?e.props?.children:e,i=hh(n),a=i.length>1,o=a?`${String(i.length).length+1}ch`:void 0;return s.jsxs("div",{className:"codeblock",children:[s.jsx(vn,{text:Ca(e)}),s.jsx("pre",{...t,children:i.map((l,u)=>s.jsxs("div",{className:"code-line",children:[a&&s.jsx("span",{className:"code-num",style:o?{width:o}:void 0,children:u+1}),s.jsx("code",{className:"code-line-body hljs",children:l})]},u))})]})}function Ca(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Ca).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return Ca(t?.children)}return""}const jh=/^\s{0,3}(`{3,}|~{3,})/,Lh=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Xn(e){return e.trim()===""}function zi(e){const t=jh.exec(e);return t?t[1]:null}function Rh(e){const t=e.split(`
|
|
310
|
+
`),n=[];let i=[],a=null;for(let o=0;o<t.length;o++){const l=t[o];if(a!==null){const p=zi(l);p&&p[0]===a[0]&&p.length>=a.length&&(a=null),i.push(l);continue}const u=zi(l);if(u&&!Xn(l)){a=u,i.push(l);continue}if(Xn(l)){let p=o;for(;p<t.length&&Xn(t[p]);)p++;if(!(p<t.length&&Lh.test(t[p]))&&i.length>0){n.push(i.join(`
|
|
311
|
+
`)),i=[];continue}i.push(l);continue}i.push(l)}return{frozen:n,active:i.join(`
|
|
312
|
+
`),inFence:a!==null}}const Dh=c.memo(function({text:t}){return s.jsx(Ha,{text:t})}),Qi=200;function Ph({text:e,inFence:t}){const[n,i]=c.useState(e),a=c.useRef(0),o=c.useRef(null);return c.useEffect(()=>{if(t)return;const l=Date.now()-a.current,u=()=>{a.current=Date.now(),i(e)};if(l>=Qi){u();return}return o.current=setTimeout(u,Qi-l),()=>{o.current&&clearTimeout(o.current)}},[e,t]),t?s.jsx("div",{className:"codeblock",children:s.jsx("pre",{children:s.jsx("code",{children:e})})}):s.jsx(Ha,{text:n})}const Oh=c.memo(function({text:t}){const{frozen:n,active:i,inFence:a}=c.useMemo(()=>Rh(t),[t]);return s.jsxs("div",{className:"md",children:[n.map((o,l)=>s.jsx(Dh,{text:o},l)),i.length>0&&s.jsx(Ph,{text:i,inFence:a},n.length)]})});function Mh({thinking:e,streaming:t,wrap:n=!0,forceOpen:i=!1}){const a=je(),[o,l]=c.useState(null),u=o??n,p=u||i,E=t?e.trimEnd().slice(-80):e.split(`
|
|
313
|
+
`)[0].slice(0,80),[m,f]=c.useState(!1),w=()=>{navigator.clipboard.writeText(e),f(!0),window.setTimeout(()=>f(!1),1200)};return s.jsxs("div",{className:`thinking ${p?"open":""} ${t?"live":""}`,children:[s.jsxs("div",{className:"chead thinking-head",role:"button",tabIndex:0,"aria-expanded":p,title:a(p?"collapseMsg":"expandMsg"),onClick:()=>l(!u),onKeyDown:N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),l(!u))},children:[s.jsx("button",{type:"button",className:"chead-toggle thinking-toggle",title:a(p?"collapseMsg":"expandMsg"),"aria-label":a(p?"collapseMsg":"expandMsg"),"aria-expanded":p,onClick:N=>{N.stopPropagation(),l(!u)},children:p?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon thinking-icon",children:s.jsx(Ds,{})}),s.jsx("span",{className:"chead-title thinking-label",children:t&&p?s.jsxs("span",{className:"thinking-live-label",children:[a("thinkingNow"),s.jsx("span",{className:"dots"})]}):p?a("thinking"):a("thinkingPreview",{preview:E})}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy thinking-copy",title:a(m?"copied":"copyMessage"),"aria-label":a("copyMessage"),onClick:N=>{N.stopPropagation(),w()},children:m?s.jsx(cs,{}):s.jsx(wt,{})})]}),p&&s.jsx("div",{className:"thinking-body",children:e})]})}const Cn=256*1024,_n=300,Bh=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,Fh=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,Hh=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,Uh=1e9;function $h(e){if(!e)return{};const t=e.length>Cn?e.slice(0,Cn):e;return{path:Gh(t),timeout:Vh(t),command:zh(e),agent:qh(t)}}function qh(e){const t=Fh.exec(e);if(!t)return;const n=t[1].replace(/[\u0000-\u001f\u007f]/g,"").trim();if(n)return n.length>_n?`${n.slice(0,_n)}…`:n}const Wh=["task","expected_outcome","required_tools","must_do","must_not_do","context"];function Kh(e){if(!e||e.length>Cn)return{};try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n=t,i={};for(const a of[...Wh,"agent","model"])typeof n[a]=="string"&&n[a].trim()&&(i[a]=n[a]);return i}catch{return{}}}function Yh(e,t=56){if(e.length<=t)return e;const n=e.split(/[\\/]+/).filter(Boolean),i=n[n.length-1];if(!i||n.length<=1)return`…${e.slice(-(t-1))}`;let a=i;for(let o=n.length-2;o>=0;o--){const l=`${n[o]}/${a}`;if(l.length+2>t)break;a=l}return`…/${a}`}function Gh(e){const t=Bh.exec(e);if(!t)return;const i=Qh(t[2]).replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim();if(i)return i.length>_n?`${i.slice(0,_n-1)}…`:i}function Vh(e){const t=Hh.exec(e);if(!t)return;const n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>Uh)return;const i=t[1].toLowerCase();return!i.endsWith("ms")&&!i.endsWith("milliseconds")?`${n}s`:n<1e3?`${n}ms`:`${Math.round(n/100)/10}s`}function zh(e){if(!(e.length>Cn))try{const 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 Qh(e){try{const t=JSON.parse(`"${e}"`);return typeof t=="string"?t:e}catch{return e}}const Xh={bash:"$",delegate_task:"◈",read:"📄",write:"✍️",edit:"✏️",edit_soft:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function Jh(e){return Xh[e]??"🛠"}const Zh=c.memo(function({block:t,view:n,onKillBash:i,wrap:a=!0,forceOpen:o=!1}){const l=je(),[u,p]=c.useState(null),E=u??a,m=E||o,[f,w]=c.useState(!1),N=!n.result&&n.streaming&&!n.status,C=t.name==="bash"&&N,M=n.result!==void 0,W=!n.result&&!!n.status,_=n.result?.isError??n.status?.isError??!1,D=n.result?n.result.content.map(F=>F.type==="text"?F.text:"").join(""):n.liveOutput??"",I=D.replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(F,v)=>l("liveOutputOmitted",{n:v})),H=t.name==="delegate_task",te=H?Kh(t.argumentsText):{},ee=H&&n.result&&typeof n.result.details=="object"&&n.result.details!==null?n.result.details.convId:void 0,le=typeof ee=="string"&&ee?ee:/sa-[0-9a-f]{8}/.exec(D)?.[0],pe=_?"err":M?"ok":N||W?"run":"idle";let Q=l(_?"error":M?"done":N?"running":W?"toolDoneWaitingModel":"toolQueued");const G=W&&n.status?.durationMs!==void 0?nf(n.status.durationMs):"";W&&G&&(Q=`${Q} · ${G}`);const ce=W&&n.status?.exitCode!==void 0?`exit ${n.status.exitCode}`:"",O=$h(t.argumentsText),B=t.name==="bash"?O.command:void 0,x=!m&&B?sf(B):void 0,R=()=>{t.argumentsText&&(navigator.clipboard.writeText(t.argumentsText),w(!0),setTimeout(()=>w(!1),1200))};return s.jsxs("div",{className:`toolcall ${pe}`,children:[s.jsxs("div",{className:"chead toolcall-head",role:"button",tabIndex:0,"aria-expanded":m,title:l(m?"collapseMsg":"expandMsg"),onClick:()=>p(!E),onKeyDown:F=>{F.target===F.currentTarget&&(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),p(!E))},children:[s.jsx("button",{type:"button",className:"chead-toggle toolcall-toggle",title:l(m?"collapseMsg":"expandMsg"),"aria-label":l(m?"collapseMsg":"expandMsg"),"aria-expanded":m,onClick:F=>{F.stopPropagation(),p(!E)},children:m?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon toolcall-icon",children:Jh(t.name)}),s.jsx("span",{className:"chead-title toolcall-name",children:t.name}),s.jsx("span",{className:"toolcall-status",title:ce?`${Q} · ${ce}`:Q,"aria-label":ce?`${Q} · ${ce}`:Q,children:_?s.jsx(Ke,{}):M?s.jsx(Tt,{}):N?s.jsx(_c,{}):W?s.jsx(la,{}):s.jsx(xc,{})}),x&&s.jsxs("span",{className:"toolcall-cmd",title:B,children:["$ ",x]}),O.path&&s.jsx("span",{className:"toolcall-path",title:O.path,children:Yh(O.path)}),O.timeout&&s.jsxs("span",{className:"toolcall-timeout",children:["⏱ ",O.timeout]}),H&&O.agent&&s.jsxs("span",{className:"toolcall-agent",title:O.agent,children:["◈ ",O.agent]}),s.jsx("span",{className:"toolcall-spacer"}),C&&i&&s.jsxs("button",{type:"button",className:"toolcall-kill",title:l("stopBashTip"),onClick:F=>{F.stopPropagation(),i?.()},children:[s.jsx(un,{}),s.jsx("span",{children:l("stopBash")})]}),H&&M&&le&&s.jsxs("button",{type:"button",className:"toolcall-open",title:l("delegateOpenSubagent"),onClick:F=>{F.stopPropagation(),window.dispatchEvent(new CustomEvent("pi-web-ui:switch-conversation",{detail:le}))},children:[s.jsx(Pc,{}),s.jsx("span",{children:l("delegateOpenSubagent")})]}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy",title:l("copyArgs"),onClick:F=>{F.stopPropagation(),R()},children:f?s.jsx(cs,{}):s.jsx(wt,{})})]}),m&&s.jsxs("div",{className:"toolcall-body",children:[H?s.jsx(tf,{args:te}):t.argumentsText&&s.jsx("div",{className:"toolcall-args",children:B?s.jsx(ef,{command:B}):s.jsx("pre",{children:t.argumentsText})}),I.length>0&&s.jsxs("div",{className:"toolcall-output",children:[s.jsxs("div",{className:"toolcall-output-label",children:[l(_?"errorOutput":"output"),(N||W)&&s.jsx("span",{className:"cursor"})]}),s.jsx("pre",{children:I})]}),N&&I.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",l("waitingOutput")]}),W&&I.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",l("waitingModel")]})]})]})});function ef({command:e}){return s.jsxs("div",{className:"termline",children:[s.jsx(Ln,{className:"termline-icon"}),s.jsx("code",{children:e})]})}function tf({args:e}){const t=je(),i=[{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:a})=>e[a]?.trim());return i.length===0?null:s.jsx("div",{className:"delegate-brief",children:i.map(({field:a,label:o})=>s.jsxs("div",{className:"delegate-sec",children:[s.jsx("div",{className:"delegate-sec-label",children:o}),s.jsx("div",{className:"delegate-sec-text",children:e[a]})]},a))})}function sf(e){const t=e.split(`
|
|
314
|
+
`),n=t[0].replace(/\s+/g," ").trim();if(!n)return;const i=t.length-1,a=n.length>80?`${n.slice(0,80)}…`:n;return i>0?`${a} +${i}`:a}function nf(e){if(e===void 0)return"";const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),i=Math.round(t%60);return`${n}m ${String(i).padStart(2,"0")}s`}const af=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function Ua(e){const t=e.match(af);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}const rf=1568,of=2*1024*1024;function _t(e){return e.startsWith("image/")&&e!=="image/svg+xml"&&e!=="image/svg"}async function $a(e){if(!e.type.startsWith("image/"))return null;let t;try{t=await createImageBitmap(e,{imageOrientation:"from-image"})}catch{return null}try{const n=Math.min(1,rf/Math.max(t.width,t.height)),i=Math.max(1,Math.round(t.width*n)),a=Math.max(1,Math.round(t.height*n)),o=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]];let l=null;for(const[u,p]of o){const E=document.createElement("canvas");E.width=i,E.height=a;const m=E.getContext("2d");if(!m)continue;u!=="image/png"&&(m.fillStyle="#ffffff",m.fillRect(0,0,i,a)),m.drawImage(t,0,0,i,a);const f=E.toDataURL(u,p),w=f.match(/^data:([^;]+);base64,/),N=w?w[1]:u,C=f.replace(/^data:[^;]*;base64,/,""),M=Math.floor(C.length*3/4);if(l={data:C,mimeType:N,name:e.name,size:M},M<=of)return l}return l}finally{t.close()}}const lf=20*1024*1024;function ls(e){return e.type==="text"&&typeof e.text=="string"?e:null}function Ko(e){return e.type==="thinking"&&typeof e.thinking=="string"?e:null}function Yo(e){return e.type==="toolCall"&&typeof e.id=="string"&&typeof e.name=="string"?e:null}function Go(e){return e.type==="image"&&typeof e.dataUrl=="string"?e:null}function Vo(e){return e.type==="bash"&&typeof e.command=="string"?e:null}function cf(e){return e.imageData?"image":e.uploadPath?"upload":e.fileData?"file":"path"}function uf(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"});const 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==="reference"?t("refOnly",{path:n}):t("attachContent",{path:n})}const Xi=c.memo(function({message:t,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onEdit:u,onKillBash:p,onRetry:E,onCollapse:m,questionAttachments:f,qnIndex:w,qnActive:N,onJump:C,thinkingWrap:M,toolsWrap:W,searchActive:_,autoExpand:D}){const I=je(),[H,te]=c.useState(!1),[ee,le]=c.useState(""),[pe,Q]=c.useState([]),[G,ce]=c.useState(!1),[O,B]=c.useState(null),x=X=>{B(X),window.setTimeout(()=>B(oe=>oe===X?null:oe),4e3)};if(t.role==="toolResult")return null;if(t.role==="compactionSummary")return s.jsx(mf,{message:t,forceOpen:_,autoExpand:D});const R=t.role==="custom"&&t.customType==="file",F=t.content.map(X=>ls(X)?.text??"").filter(Boolean).join(`
|
|
315
|
+
`),v=t.role==="user"?Ua(F):null,se=v?v.userMessage??`skill:${v.name}`:F.split(`
|
|
316
|
+
`).join(" ").trim(),K=o&&l&&t.content.length===0,xe=t.role==="user"&&!o&&!K&&!!u,k=async X=>{const oe=[];for(const $ of X){if(!_t($.type))continue;const Ie=await $a($);Ie&&oe.push({path:"",imageData:Ie.data,mimeType:Ie.mimeType,name:Ie.name})}oe.length>0&&Q($=>[...$,...oe])},Y=async X=>{if(X.size>lf){x(I("fileTooLarge",{name:X.name,size:20}));return}let oe;try{oe=(await new Promise((Ie,Le)=>{const P=new FileReader;P.onload=()=>Ie(P.result),P.onerror=()=>Le(P.error??new Error("read failed")),P.readAsDataURL(X)})).replace(/^data:[^;]*;base64,/,"")}catch{x(I("fileLoadFailed",{name:X.name}));return}Q($=>[...$,{path:"",fileData:oe,name:X.name,size:X.size,mimeType:X.type||void 0}])},re=async X=>{const oe=[];for(const $ of X)_t($.type)?oe.push($):Y($);oe.length>0&&await k(oe)},de=()=>{le(v?`/skill:${v.name}${v.userMessage?` ${v.userMessage}`:""}`:t.content.map(X=>ls(X)?.text??"").filter(Boolean).join(`
|
|
317
|
+
`)),Q(f??[]),te(!0)},we=()=>{const X=ee.trim();X&&(u?.(t.id,X,pe.length>0?pe:void 0),te(!1))},ie=t.role==="custom"&&(t.customType==="goal-review"||t.customType==="goal-wizard"),me=t.role==="custom"&&t.customType==="goal-wizard";return s.jsxs("div",{className:`msg msg-${t.role}${ie?" msg-goal-review":""}`,"data-role":t.role,"data-msg-id":t.id,children:[s.jsxs("div",{className:"msg-meta",children:[s.jsx("span",{className:"msg-role",children:t.role==="custom"?me?I("goalWizardCard"):ie?I("goalBarTitle"):t.customType==="file"?I("attachment"):`${I("plugin")} · ${t.customType??I("unknown")}`:zo(t.role,I)}),t.model&&s.jsx("span",{className:"msg-model",children:t.model}),t.timestamp&&s.jsx("span",{className:"msg-time",children:Qo(t.timestamp)}),m&&s.jsxs("button",{type:"button",className:"msg-collapse-btn",title:I("collapseMsg"),onClick:()=>m(t.id),children:[s.jsx(Rn,{})," ",I("collapseMsg")]}),w!==void 0&&C&&s.jsxs("button",{type:"button",className:`qn-tag ${N?"active":""}`,title:`${w+1}. ${se}`,"aria-label":`${w+1}. ${se}`,onClick:()=>C(t.id),children:[s.jsx("span",{className:"qn-tag-bar"}),s.jsx("span",{className:"qn-tag-idx",children:w+1})]})]}),s.jsx("div",{className:"msg-body",children:H?s.jsxs("div",{className:`msg-editor${G?" drag-over":""}`,onDragOver:X=>{X.preventDefault(),X.stopPropagation(),ce(!0)},onDragLeave:X=>{X.currentTarget.contains(X.relatedTarget)||ce(!1)},onDrop:X=>{X.preventDefault(),X.stopPropagation(),ce(!1),re(Array.from(X.dataTransfer?.files??[]))},children:[pe.length>0&&s.jsx("div",{className:"msg-editor-images",children:pe.map((X,oe)=>{const $=cf(X);return s.jsxs("span",{className:`msg-editor-img ${$==="image"?"":"file-chip"}`,title:uf(X,I),children:[$==="image"?s.jsx("img",{src:`data:${X.mimeType??"image/png"};base64,${X.imageData}`,alt:X.name}):s.jsxs("span",{className:"msg-editor-file",children:[s.jsx("span",{className:"msg-editor-file-icon",children:$==="path"?X.mode==="page"?"🌐":X.mode==="reference"?"🔗":"📎":"📄"}),s.jsx("span",{className:"msg-editor-file-name",children:X.name??X.path?.split("/").pop()})]}),s.jsx("button",{type:"button",className:"msg-editor-img-remove",title:I("removeAttachment"),onClick:()=>Q(Ie=>Ie.filter((Le,P)=>P!==oe)),children:s.jsx(Ke,{})})]},`${X.name??X.path??"att"}-${oe}`)})}),O&&s.jsx("div",{className:"msg-editor-notice",children:O}),s.jsx("textarea",{className:"msg-editor-input",value:ee,autoFocus:!0,placeholder:I("editPlaceholder"),rows:Math.max(2,Math.min(10,ee.split(`
|
|
318
|
+
`).length+1)),onChange:X=>le(X.target.value),onPaste:X=>{const oe=[];for(const $ of X.clipboardData?.items??[])if($.kind==="file"&&_t($.type)){const Ie=$.getAsFile();Ie&&oe.push(Ie)}oe.length!==0&&(X.preventDefault(),k(oe))},onKeyDown:X=>{X.key==="Enter"&&(X.metaKey||X.ctrlKey)?(X.preventDefault(),we()):X.key==="Escape"&&te(!1)}}),s.jsxs("div",{className:"msg-editor-actions",children:[s.jsxs("span",{className:"msg-editor-hint",children:[s.jsx(Ac,{})," ",I("editAttachmentHint")]}),s.jsx("button",{type:"button",className:"chip",onClick:()=>te(!1),children:I("cancel")}),s.jsxs("button",{type:"button",className:"chip primary",disabled:!ee.trim(),title:I("reaskFromHere"),onClick:we,children:[s.jsx(fn,{})," ",I("reaskFromHere")]})]})]}):s.jsxs(s.Fragment,{children:[t.errorMessage&&s.jsxs("div",{className:"msg-error",children:[s.jsx("span",{className:"msg-error-text",children:t.errorMessage}),l&&!o&&E&&s.jsxs("button",{type:"button",className:"msg-retry-btn",title:I("retryLastTip"),onClick:E,children:[s.jsx(kt,{})," ",I("retryNow")]})]}),R?s.jsx(df,{message:t,forceOpen:_}):v?s.jsxs(s.Fragment,{children:[s.jsx(hf,{block:v,forceOpen:_}),v.userMessage&&s.jsx("div",{className:"msg-text",children:s.jsx(rt,{text:v.userMessage,hardBreaks:!0})}),t.content.map((X,oe)=>X.type==="text"?null:s.jsx(Zi,{block:X,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onKillBash:p,toolsWrap:W,thinkingWrap:M,searchActive:_,role:t.role},`${t.id}-${oe}`))]}):t.content.map((X,oe)=>s.jsx(Zi,{block:X,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onKillBash:p,toolsWrap:W,thinkingWrap:M,searchActive:_,role:t.role},`${t.id}-${oe}`)),K&&s.jsxs("div",{className:"thinking-wait",children:[I("thinkingWait"),s.jsx("span",{className:"dot"})]}),o&&l&&!K&&s.jsx("span",{className:"stream-cursor"})]})}),xe&&!H&&s.jsx("div",{className:"msg-actions",children:s.jsxs("button",{type:"button",className:"msg-action",title:I("editReaskTip"),onClick:de,children:[s.jsx(fn,{})," ",I("editReask")]})})]})});function df({message:e,forceOpen:t=!1}){const n=je(),[i,a]=c.useState(!1),[o,l]=c.useState(!1),u=i||t,p=e.details??{},E=p.name??p.path??n("attachment"),m=p.type==="folder",f=p.mode==="reference",w=p.mode==="bridged",N=p.mode==="page",C=e.content.filter(I=>I.type==="text").map(I=>I.text).join(`
|
|
319
|
+
`),M=pf(C),W=e.content.find(I=>I.type==="image"),_=M.split(`
|
|
320
|
+
`).length,D=!f&&!N&&M.length>0;return s.jsxs("div",{className:`attachcard ${f?"reference":""}${N?" page":""}`,children:[s.jsxs("div",{className:"chead attachcard-head",role:"button",tabIndex:0,"aria-expanded":u,title:n(u?"collapseMsg":"expandMsg"),onClick:()=>a(I=>t?!0:!I),onKeyDown:I=>{I.target===I.currentTarget&&(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),a(H=>t?!0:!H))},children:[!f&&!N&&s.jsx("span",{className:"chead-toggle",children:u?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon attachcard-icon",children:m?"📁":N?"🌐":"📎"}),s.jsx("span",{className:"chead-title attachcard-name",children:E}),p.path&&(N?s.jsx("a",{className:"attachcard-path attachcard-link",href:p.path,target:"_blank",rel:"noreferrer",children:p.path}):s.jsx("span",{className:"attachcard-path",children:p.path})),s.jsx("span",{className:`attachcard-mode ${p.mode==="lines"?"lines":f?"ref":N?"page":w?"bridged":"inline"}`,children:N?n("attachPageShort"):f?m?n("folderRefShort"):`${n("refOnlyShort")} · ${Ji(p.size)}`:w?n("bridgedVision"):W?n("image"):p.mode==="lines"?n("inlineLinesRange",{start:p.startLine??1,end:p.endLine??p.lines??1}):n("inlineLines",{n:p.lines??_})}),D&&s.jsx("button",{type:"button",className:"chead-copy",title:n(o?"copied":"copyMessage"),"aria-label":n("copyMessage"),onClick:I=>{I.stopPropagation(),navigator.clipboard.writeText(M),l(!0),window.setTimeout(()=>l(!1),1200)},children:o?s.jsx(cs,{}):s.jsx(wt,{})})]}),!f&&u&&(w?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"attachcard-bridgenote",children:n("bridgedVisionDetail")}),W?.dataUrl&&s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:W.dataUrl,alt:E})}),M&&s.jsx("pre",{className:"attachcard-content",children:M})]}):W?.dataUrl?s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:W.dataUrl,alt:E})}):s.jsx("pre",{className:"attachcard-content",children:M})),f&&s.jsx("div",{className:"attachcard-refnote",children:m?n("folderNotExpanded"):n("fileNotExpanded",{size:Ji(p.size)})})]})}function Ji(e){return e===void 0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function pf(e){const t=e.match(/^\s*<file path="[^"]*"(?:\s+lines="[^"]*")?>\s*```\s*\n?([\s\S]*?)\n?```\s*<\/file>\s*$/);if(t)return t[1].trim();const n=e.match(/^\s*<vision-bridge>\s*([\s\S]*?)\s*<\/vision-bridge>\s*$/);return n?n[1].trim():e.trim()}function mf({message:e,forceOpen:t=!1,autoExpand:n=!1}){const i=je(),[a,o]=c.useState(!1),[l,u]=c.useState(!1),[p,E]=c.useState(n);n!==p&&(E(n),n&&o(!0));const m=a||t,f=e.content.map(N=>ls(N)?.text??"").filter(Boolean).join(`
|
|
321
|
+
`),w=typeof e.tokensBefore=="number"?e.tokensBefore.toLocaleString():null;return s.jsxs("div",{className:"msg msg-compactionSummary","data-role":e.role,"data-msg-id":e.id,children:[s.jsxs("div",{className:"msg-meta",children:[s.jsx("span",{className:"msg-role",children:i("role.compaction")}),e.timestamp&&s.jsx("span",{className:"msg-time",children:Qo(e.timestamp)})]}),s.jsxs("div",{className:`compaction-card${a?" expanded":""}`,children:[s.jsxs("div",{className:"chead compaction-head",role:"button",tabIndex:0,"aria-expanded":m,title:i(m?"collapseMsg":"expandMsg"),onClick:()=>o(N=>t?!0:!N),onKeyDown:N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),o(C=>t?!0:!C))},children:[s.jsx("span",{className:"chead-toggle",children:m?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon compaction-icon",children:s.jsx(Br,{})}),s.jsx("span",{className:"chead-title compaction-title",children:w?i("compactionFrom",{tokens:w}):i("role.compaction")}),f&&s.jsx("button",{type:"button",className:"chead-copy",title:i(l?"copied":"copyMessage"),"aria-label":i("copyMessage"),onClick:N=>{N.stopPropagation(),navigator.clipboard.writeText(f),u(!0),window.setTimeout(()=>u(!1),1200)},children:l?s.jsx(cs,{}):s.jsx(wt,{})})]}),m&&s.jsxs("div",{className:"compaction-body",children:[s.jsx(rt,{text:f}),s.jsx("div",{className:"compaction-hint",children:i("compactionKeptHint")})]})]})]})}function hf({block:e,forceOpen:t=!1}){const n=je(),[i,a]=c.useState(!1),[o,l]=c.useState(!1),u=i||t;return s.jsxs("div",{className:`skillcard${i?" expanded":""}`,children:[s.jsxs("div",{className:"chead skillcard-head",role:"button",tabIndex:0,"aria-expanded":u,title:e.location,onClick:()=>a(p=>t?!0:!p),onKeyDown:p=>{p.target===p.currentTarget&&(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),a(E=>t?!0:!E))},children:[s.jsx("span",{className:"chead-toggle",children:u?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon skillcard-icon",children:s.jsx(Rc,{})}),s.jsx("span",{className:"chead-title skillcard-name",children:e.name}),s.jsx("span",{className:"skillcard-path",children:e.location}),s.jsx("button",{type:"button",className:"chead-copy",title:n(o?"copied":"copyMessage"),"aria-label":n("copyMessage"),onClick:p=>{p.stopPropagation(),navigator.clipboard.writeText(e.content),l(!0),window.setTimeout(()=>l(!1),1200)},children:o?s.jsx(cs,{}):s.jsx(wt,{})})]}),u&&s.jsx("div",{className:"skillcard-body",children:s.jsx(rt,{text:e.content})})]})}function Zi({block:e,toolResults:t,liveOutputs:n,toolStatuses:i,streaming:a,isLast:o,onKillBash:l,thinkingWrap:u,toolsWrap:p,searchActive:E,role:m}){const f=je(),[w,N]=c.useState(!1),C=ls(e);if(C){const I=a&&o,H=m==="assistant"||m==="user",te=H&&!C.text.includes(`
|
|
322
|
+
`)&&!C.truncated,ee=m==="user"?s.jsx(rt,{text:C.text,hardBreaks:!0}):I?s.jsx(Oh,{text:C.text}):s.jsx(rt,{text:C.text});return s.jsxs("div",{className:`msg-text${te?" single":""}`,children:[te?s.jsx("div",{className:"msg-text-main",children:ee}):s.jsxs(s.Fragment,{children:[ee,C.truncated&&s.jsx("div",{className:"trunc-note",children:f("truncated")})]}),H?s.jsx("button",{type:"button",className:"msg-text-copy",title:f(w?"copied":"copyMessage"),"aria-label":f("copyMessage"),onClick:()=>{navigator.clipboard.writeText(C.text),N(!0),window.setTimeout(()=>N(!1),1200)},children:w?s.jsx(cs,{}):s.jsx(wt,{})}):null]})}const M=Ko(e);if(M)return s.jsx(Mh,{thinking:M.thinking,streaming:a&&o,wrap:u,forceOpen:E});const W=Yo(e);if(W){const I=t.get(W.id),H=n.get(W.id),te={result:I,liveOutput:H?.text,streaming:a,status:i.get(W.id)};return s.jsx(Zh,{block:W,view:te,onKillBash:l,wrap:p,forceOpen:E})}const _=Go(e);if(_&&_.dataUrl)return s.jsx("div",{className:"msg-image",children:s.jsx("img",{src:_.dataUrl,alt:"attachment"})});const D=Vo(e);return D?s.jsxs("div",{className:"bashblock",children:[s.jsxs("div",{className:"bashblock-command",children:[s.jsx("span",{className:"bashblock-prompt",children:"$"}),s.jsx("code",{children:D.command}),D.exitCode!==void 0&&s.jsx("span",{className:`bashblock-exit ${D.exitCode===0?"ok":"err"}`,children:f("exitCode",{code:D.exitCode})}),D.cancelled&&s.jsx("span",{className:"bashblock-exit err",children:f("cancelled")})]}),D.output&&s.jsx("pre",{className:"bashblock-output",children:D.output}),D.truncated&&s.jsx("div",{className:"trunc-note",children:f("outputTruncated")})]}):null}function zo(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 Qo(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`${n}:${i}`}function er(e,t,n){let i=!1;for(const a of t){const o=a;if(o.type!=="image"||typeof o.dataUrl!="string"||!o.dataUrl.startsWith("data:"))continue;const l=o.dataUrl.match(/^data:([^;]*);base64,(.+)$/);l&&(i=!0,e.push({path:"",imageData:l[2],mimeType:l[1]||"image/png",name:n??`image.${(l[1]||"image/png").split("/")[1]??"png"}`}))}return i}function ff(e){const t=new Map;for(let n=0;n<e.length;n++){const i=e[n];if(i.role!=="user"||!i.id)continue;const a=[];er(a,i.content);for(let o=n+1;o<e.length&&e[o].role==="custom"&&e[o].customType==="file";o++){const l=e[o].details??{};if(!er(a,e[o].content,l.name)){if(l.upload&&l.path){a.push({path:"",uploadPath:l.path,name:l.name??l.path,size:l.size});continue}if(l.mode==="page"&&l.path){a.push({path:l.path,mode:"page",name:l.name??l.path});continue}if(l.path&&l.mode){const u=l.mode==="inline"||l.mode==="lines"?l.mode:"reference",p={path:l.path,mode:u};l.mode==="lines"&&typeof l.startLine=="number"&&typeof l.endLine=="number"&&(p.lines={start:l.startLine,end:l.endLine}),a.push(p)}}}a.length>0&&t.set(i.id,a)}return t}const gf=c.memo(function({message:t,onExpand:n}){const i=je();let a="";for(const f of t.content){const w=ls(f);if(w&&w.text.trim()){const N=Ua(w.text);N?a=`skill:${N.name}`+(N.userMessage?` · ${N.userMessage.replace(/\s+/g," ").trim()}`:""):a=w.text.replace(/\s+/g," ").trim();break}}if(!a&&t.role==="custom"&&t.customType==="file"){const f=t.details??{};a=f.name??f.path??""}a.length>90&&(a=`${a.slice(0,90)}…`);let l=0,u=0,p=0,E=0;for(const f of t.content)Ko(f)?l++:Yo(f)?u++:Vo(f)?p++:Go(f)&&E++;const m=[];return l&&m.push(`${i("thinking")} ${l}`),u&&m.push(`${i("toolCalls")} ${u}`),p&&m.push(`${i("bashRuns")} ${p}`),E&&m.push(`${i("images")} ${E}`),s.jsxs("div",{role:"button",tabIndex:0,className:"msg-collapsed","data-msg-id":t.id,title:`${i("expandMsg")} · ${a||m.join(" · ")||t.role}`,onClick:()=>n(t.id),onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),n(t.id))},children:[s.jsx("span",{className:`msg-collapsed-role role-${t.role}`,children:t.role==="custom"&&t.customType==="file"?i("attachment"):zo(t.role,i)}),s.jsxs("span",{className:"msg-collapsed-body",children:[a&&s.jsx("span",{className:"msg-collapsed-preview",children:a}),m.length>0&&s.jsx("span",{className:"msg-collapsed-chips",children:m.map((f,w)=>s.jsx("span",{className:"msg-collapsed-chip",children:f},w))})]}),t.timestamp?s.jsx("span",{className:"msg-collapsed-time",children:bf(t.timestamp)}):null,s.jsxs("span",{className:"msg-collapsed-action",children:[s.jsx(zt,{})," ",i("expandMsg")]})]})});function bf(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`${n}:${i}`}const Ef=c.memo(function({id:t,show:n,height:i,containerRef:a,onMeasured:o,lazyRef:l,children:u}){const p=c.useRef(null),E=c.useRef(null);return c.useLayoutEffect(()=>{const m=E.current;if(E.current=n,!n||m!==!1)return;const f=p.current,w=a.current;if(!f||!w)return;const N=f.offsetHeight;o?.(t,N);const C=N-i;if(C!==0){const M=f.parentElement;M&&M.getBoundingClientRect().bottom<=w.getBoundingClientRect().top&&(w.scrollTop+=C)}},[n]),n?s.jsx("div",{ref:l,"data-lazy-id":t,children:s.jsx("div",{ref:p,children:u})}):s.jsx("div",{ref:l,className:"msg-lazy-ph","data-msg-id":t,"data-lazy-id":t,style:{height:i},"aria-hidden":"true"})});function Tf(e,t,n,i){const a=[],o=[];let l=0;for(const u of e){if(n.has(u.id))continue;u.top<t.bottom&&u.bottom>t.top?i.has(u.id)&&a.push(u.id):i.has(u.id)||(o.push(u.id),u.bottom<=t.top&&(l+=u.bottom-u.top))}return{show:a,hide:o,shrinkAbove:l}}function xf(e,t){if(t.show.length===0&&t.hide.length===0)return e;const n=new Set(e);for(const i of t.show)n.delete(i);for(const i of t.hide)n.add(i);return n}function yf(e,t,n){const i=new Set;let a=0;for(let o=e.length-1;o>=0&&!(o<e.length-1&&a>=n);o--){const l=e[o];i.add(l.id),a+=t.get(l.id)??Xo(l.role,l.customType)}return i}function Xo(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}}const Nf=["text","thinking","argumentsText","output","command"];function kf(e){let t=0;for(const n of e.content){n.type==="image"&&(t+=1);for(const i of Nf){const a=n[i];typeof a=="string"&&(t+=a.length)}}return t}function vf(e,t,n,i){const a=n.get(e);return a&&a.len===t?a.h:i}function Cf(e){const t=[];for(const n of e.content)n.type==="text"&&typeof n.text=="string"&&t.push(n.text);return t.join(`
|
|
323
|
+
`)}function _f(e,t){const n=[];for(const i of e.content)if(i.type==="text"&&typeof i.text=="string")n.push(i.text);else if(i.type==="thinking"&&typeof i.thinking=="string")n.push(i.thinking);else if(i.type==="toolCall"){if(typeof i.name=="string"&&n.push(i.name),typeof i.argumentsText=="string"&&n.push(i.argumentsText),typeof i.id=="string"){const a=t.get(i.id);if(a){const o=Cf(a);o&&n.push(o)}}}else i.type==="bash"&&(typeof i.command=="string"&&n.push(i.command),typeof i.output=="string"&&n.push(i.output));return n.join(`
|
|
324
|
+
`)}function wf(e,t){let n=0,i=e.indexOf(t);for(;i!==-1;)n++,i=e.indexOf(t,i+t.length);return n}function Sf(e,t,n,i){const a=new Map,o=n.toLowerCase();if(!o)return a;for(const l of e){if(!t.has(l.id))continue;const u=wf(_f(l,i).toLowerCase(),o);u>0&&a.set(l.id,u)}return a}function Af(e,t){const n=[],i=t.toLowerCase();if(!i)return n;const a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(o){const l=o.parentElement;return!l||l.closest(".search-bar")||l.closest(".msg-collapsed")?NodeFilter.FILTER_REJECT:(o.textContent??"").toLowerCase().includes(i)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let o=a.nextNode();o;o=a.nextNode()){const l=(o.textContent??"").toLowerCase();if(!o.parentElement?.closest("[data-msg-id]"))continue;let u=l.indexOf(i);for(;u!==-1;){const p=document.createRange();p.setStart(o,u),p.setEnd(o,u+i.length),n.push(p),u=l.indexOf(i,u+i.length)}}return n}function If(e,t,n,i,a){const o=Sf(n,i,t,a),l=new Map;for(const p of Af(e,t)){const E=p.startContainer.parentElement?.closest("[data-msg-id]");if(!E?.dataset.msgId)continue;const m=l.get(E.dataset.msgId);m?m.push(p):l.set(E.dataset.msgId,[p])}const u=[];for(const p of n){const E=l.get(p.id);if(E)for(let f=0;f<E.length;f++)u.push({kind:"dom",range:E[f],msgId:p.id,k:f});const m=o.get(p.id);if(m)for(let f=0;f<m;f++)u.push({kind:"folded",msgId:p.id,k:f})}return u}function Jn(e,t){return e.findIndex(n=>n.msgId===t.msgId&&n.k===t.k)}function ft(e,t){const n=CSS;if(!n.highlights)return;if(t.length===0){n.highlights.delete(e);return}const i=window.Highlight;i&&n.highlights.set(e,new i(...t))}function jf(e,t){const n=[];let i=e;for(;i&&i!==t;){const a=getComputedStyle(i);/(auto|scroll|hidden)/.test(a.overflowY+a.overflowX)&&(i.scrollHeight>i.clientHeight||i.scrollWidth>i.clientWidth)&&n.push(i),i=i.parentElement}return n}function Lf(e,t){const n=t.startContainer.parentElement;for(const u of jf(n,e)){const p=t.getBoundingClientRect(),E=u.getBoundingClientRect();if(p.height<=0||p.width<=0)return;p.top>=E.top+4&&p.bottom<=E.bottom-4||(u.scrollTop+=p.top-E.top-(u.clientHeight-p.height)/2),p.left>=E.left+4&&p.right<=E.right-4||(u.scrollLeft+=p.left-E.left-(u.clientWidth-p.width)/2)}const i=t.getBoundingClientRect(),a=e.getBoundingClientRect();if(i.height<=0||i.width<=0)return;const o=i.top>=a.top+6&&i.bottom<=a.bottom-6,l=i.left>=a.left+6&&i.right<=a.right-6;o&&l||(o||(e.scrollTop+=i.top-a.top-(a.height-i.height)/2),l||(e.scrollLeft+=i.left-a.left-(a.width-i.width)/2))}function Rf({containerRef:e,messages:t,collapsedIds:n,toolResults:i,onExpand:a,onProgrammaticScroll:o,open:l,onClose:u}){const p=je(),E=c.useRef(null),[m,f]=c.useState(""),[w,N]=c.useState(null),[C,M]=c.useState(0),[,W]=c.useState(0),_=c.useDeferredValue(m),D=l?_.trim():"",I=c.useRef(null);I.current=w;const H=c.useRef([]),te=c.useRef({key:null}),ee=c.useRef("");c.useEffect(()=>{l&&(N(null),requestAnimationFrame(()=>E.current?.select()))},[l]),c.useEffect(()=>{if(!l)return;const Q=G=>{G.key==="Escape"&&(G.preventDefault(),G.stopPropagation(),u())};return window.addEventListener("keydown",Q,!0),()=>window.removeEventListener("keydown",Q,!0)},[l,u]),c.useEffect(()=>(l||(ft("msg-search",[]),ft("msg-search-active",[])),()=>{ft("msg-search",[]),ft("msg-search-active",[])}),[l]),c.useLayoutEffect(()=>{const Q=()=>{M(0),N(null),W(0),H.current=[],ft("msg-search",[]),ft("msg-search-active",[]),te.current={key:null},ee.current=""};if(!l||!D){Q();return}const G=e.current;if(!G)return;let ce=!1,O=0;return O=requestAnimationFrame(()=>{if(ce)return;const B=If(G,D,t,n,i);H.current=B;const x=B.length;if(M(x),x===0){N(null),W(0),ft("msg-search",[]),ft("msg-search-active",[]),te.current={key:null},ee.current=D;return}const R=I.current;let F;if(R){if(F=Jn(B,R),F===-1){const k=[];for(let Y=0;Y<B.length;Y++)B[Y].msgId===R.msgId&&k.push(Y);if(k.length>0){const Y=Math.min(R.k,k.length-1);F=k[Y]}else F=0}}else F=0;F<0&&(F=0),F>=x&&(F=x-1),(!R||R.msgId!==B[F].msgId||R.k!==B[F].k)&&N({msgId:B[F].msgId,k:B[F].k}),W(F);const v=B[F],se=te.current,K=se.key?.msgId!==v.msgId||se.key?.k!==v.k||se.kind==="folded"&&v.kind==="dom"||D!==ee.current;te.current={key:{msgId:v.msgId,k:v.k},kind:v.kind},ee.current=D;const xe=B.filter(k=>k.kind==="dom").map(k=>k.range);if(ft("msg-search",xe),v.kind==="folded"){ft("msg-search-active",[]),K&&a(v.msgId);return}ft("msg-search-active",[v.range]),K&&(o?.(),Lf(G,v.range))}),()=>{ce=!0,cancelAnimationFrame(O)}},[l,D,t,e,w,n,i,a,o]);const le=c.useCallback(Q=>{const G=H.current,ce=G.length;if(ce===0)return;const O=I.current,B=O?Jn(G,O):0,x=G[(B+Q+ce)%ce];N(x.kind==="dom"||x.kind==="folded"?{msgId:x.msgId,k:x.k}:null)},[]);if(!l)return null;const pe=w?(()=>{const Q=Jn(H.current,w);return Q===-1?0:Q})():0;return s.jsxs("div",{className:"search-bar",role:"search",children:[s.jsx("input",{ref:E,className:"search-input",type:"text",value:m,placeholder:p("searchPlaceholder"),onChange:Q=>{f(Q.target.value)},onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),le(Q.shiftKey?-1:1))}}),s.jsx("span",{className:`search-count ${C===0?"empty":""}`,children:C===0?p("searchNoResults"):`${Math.min(pe+1,C)}/${C}`}),s.jsx("button",{type:"button",className:"search-btn",title:p("searchPrev"),disabled:C===0,onClick:()=>le(-1),children:s.jsx(Rn,{})}),s.jsx("button",{type:"button",className:"search-btn",title:p("searchNext"),disabled:C===0,onClick:()=>le(1),children:s.jsx(Ft,{})}),s.jsx("button",{type:"button",className:"search-btn",title:p("searchClose"),onClick:u,children:s.jsx(Ke,{})})]})}function Df(e){const{dSt:t,dSh:n,escaped:i,graceActive:a,stuck:o}=e;return a?{flipEscape:!1,reassert:!1}:t>=-4||t<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:o&&!i}:{flipEscape:!0,reassert:!1}}const Jo="pi-web-model-usage";function Pf(e){if(!e||typeof e!="object")return{};const t={};for(const[n,i]of Object.entries(e)){const a=typeof i=="number"?Math.floor(i):0;Number.isFinite(a)&&a>0&&(t[n]=a)}return t}function Of(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Mf(e,t){const n=t;return e.map((i,a)=>({m:i,i:a,count:n[i.id]??0})).sort((i,a)=>a.count-i.count||i.i-a.i).map(i=>i.m)}function Zo(){try{const e=localStorage.getItem(Jo);return e?Pf(JSON.parse(e)):{}}catch{return{}}}function Bf(e){try{localStorage.setItem(Jo,JSON.stringify(e))}catch{}}function wn(e){const t=Of(Zo(),e);return Bf(t),t}const el=[{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"}],tl="pi-web-ui:prompt-templates";function Ff(){try{const e=localStorage.getItem(tl);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}catch{return[]}}function tr(e){return el.some(t=>t.id===e)}function Gs(e){return typeof e.title=="string"}const sl=c.createContext(null);function nl(){const e=c.useContext(sl);if(!e)throw new Error("useTemplates must be used within TemplateProvider");return e}function Hf({children:e,currentModelId:t}){const n=je(),[i,a]=c.useState(Ff),[o,l]=c.useState(!1),[u,p]=c.useState(null),[E,m]=c.useState(!1),[f,w]=c.useState(!1),[N,C]=c.useState(!1);c.useEffect(()=>{try{localStorage.setItem(tl,JSON.stringify(i))}catch{}},[i]);const M=c.useMemo(()=>{const B=new Map,x=new Set;for(const v of i)v.hidden?x.add(v.id):(Gs(v)&&!tr(v.id)||Gs(v))&&B.set(v.id,v);const R=el.filter(v=>!x.has(v.id)).map(v=>{const se=B.get(v.id);return{id:v.id,icon:se?.icon??v.icon,title:se?.title??n(v.titleKey),desc:se?.desc??n(v.descKey),prompt:se?.prompt??n(v.promptKey),builtin:!0}}),F=i.filter(v=>Gs(v)&&!tr(v.id)).map(v=>({id:v.id,icon:v.icon??"📌",title:v.title??"",desc:v.desc??"",prompt:v.prompt??""}));return[...R,...F]},[i,n]),W=c.useCallback(()=>l(!0),[]),_=c.useCallback(B=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:B}))},[]),D=c.useCallback((B,x=!1)=>{C(x),B?(m(!1),p({...B})):(m(!0),p({id:St(),icon:"📌",title:"",desc:"",prompt:""}))},[]),I=c.useCallback(()=>{l(!1),p(null),C(!1)},[]),H=c.useCallback(()=>{f?(a([]),w(!1)):(w(!0),setTimeout(()=>w(!1),5e3))},[f]),te=c.useCallback(B=>{l(!1),_(B.prompt)},[_]),ee=c.useCallback(B=>{l(!1),D(B,!0)},[D]),le=c.useCallback(()=>{l(!1),D(void 0,!0)},[D]),pe=c.useCallback(B=>{a(x=>{const R=x.findIndex(F=>F.id===B.id);if(R>=0){const F=[...x];return F[R]=B,F}return[...x,B]}),p(null),N&&(l(!0),C(!1))},[N]),Q=c.useCallback(B=>{a(x=>B.builtin?[...x.filter(F=>F.id!==B.id),{id:B.id,hidden:!0}]:x.filter(R=>R.id!==B.id)),p(null),N&&(l(!0),C(!1))},[N]),G=c.useCallback(B=>{a(x=>x.filter(R=>R.id!==B.id||R.hidden)),p(null),N&&(l(!0),C(!1))},[N]),ce=c.useMemo(()=>({templates:M,fill:_,openPicker:W,openEdit:D,resetConfirm:f,toggleReset:H}),[M,_,W,D,f,H]),O=u?i.some(B=>B.id===u.id&&!B.hidden&&Gs(B)):!1;return s.jsxs(sl.Provider,{value:ce,children:[e,o&&s.jsx($f,{templates:M,resetConfirm:f,onFill:te,onEditTpl:ee,onNew:le,onResetToggle:H,onClose:I}),u&&s.jsx(qf,{editing:u,isNew:E,hasOverride:O,onDraft:p,onSave:pe,onRestore:()=>G(u),onRemove:()=>Q(u),onFill:()=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:u.prompt})),I()},onSend:()=>{const B=u.prompt.trim();B&&ae({type:"prompt",text:B,queue:!1})&&(t&&wn(t),I())},onClose:I})]})}function Uf(){const e=je(),{templates:t,fill:n,openEdit:i,toggleReset:a,resetConfirm:o}=nl();return s.jsxs("div",{className:"empty-templates",children:[s.jsxs("div",{className:"empty-templates-head",children:[s.jsx("span",{className:"empty-templates-title",children:e("tpl.title")}),s.jsx("span",{className:"empty-templates-hint",children:e("tpl.hint")})]}),s.jsxs("div",{className:"empty-templates-grid",children:[t.map(l=>s.jsx(al,{tpl:l,title:e("tpl.clickCard"),onFill:()=>n(l.prompt),onEdit:()=>i(l),editTitle:e("tpl.editTpl")},l.id)),s.jsxs("button",{type:"button",className:"empty-template add",onClick:()=>i(),title:e("tpl.add"),children:[s.jsx("span",{className:"empty-template-icon",children:s.jsx(dt,{})}),s.jsxs("span",{className:"empty-template-main",children:[s.jsx("span",{className:"empty-template-title",children:e("tpl.add")}),s.jsx("span",{className:"empty-template-desc",children:e("tpl.addDesc")})]})]})]}),s.jsx("div",{className:"empty-templates-foot",children:s.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:a,children:[s.jsx(Lr,{}),e(o?"tpl.resetConfirm":"tpl.reset")]})})]})}function al({tpl:e,title:t,onFill:n,onEdit:i,editTitle:a}){const o=je();return s.jsxs("button",{type:"button",className:"empty-template",title:t,onClick:n,children:[s.jsx("span",{className:"empty-template-icon",children:e.icon}),s.jsxs("span",{className:"empty-template-main",children:[s.jsx("span",{className:"empty-template-title",children:e.title}),s.jsx("span",{className:"empty-template-desc",children:e.desc})]}),s.jsx("span",{className:"template-card-ops",role:"button",title:a??o("tpl.editTpl"),onClick:l=>{l.stopPropagation(),i()},children:s.jsx(gn,{})})]})}function $f({templates:e,resetConfirm:t,onFill:n,onEditTpl:i,onNew:a,onResetToggle:o,onClose:l}){const u=je();return c.useEffect(()=>{const p=E=>{E.key==="Escape"&&l()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[l]),s.jsx("div",{className:"modal-backdrop",onClick:l,children:s.jsxs("div",{className:"modal template-picker",onClick:p=>p.stopPropagation(),children:[s.jsxs("div",{className:"template-picker-top",children:[s.jsxs("div",{className:"template-picker-head",children:[s.jsx("span",{className:"template-picker-title",children:u("tpl.pickerTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:u("close"),onClick:l,children:s.jsx(Ke,{})})]}),s.jsx("div",{className:"template-picker-hint",children:u("tpl.pickerHint")})]}),s.jsx("div",{className:"template-picker-scroll",children:s.jsxs("div",{className:"template-picker-grid",children:[e.map(p=>s.jsx(al,{tpl:p,title:u("tpl.clickCard"),onFill:()=>n(p),onEdit:()=>i(p),editTitle:u("tpl.editTpl")},p.id)),s.jsxs("button",{type:"button",className:"empty-template add",onClick:a,title:u("tpl.add"),children:[s.jsx("span",{className:"empty-template-icon",children:s.jsx(dt,{})}),s.jsxs("span",{className:"empty-template-main",children:[s.jsx("span",{className:"empty-template-title",children:u("tpl.add")}),s.jsx("span",{className:"empty-template-desc",children:u("tpl.addDesc")})]})]})]})}),s.jsx("div",{className:"template-picker-foot",children:s.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:o,children:[s.jsx(Lr,{}),u(t?"tpl.resetConfirm":"tpl.reset")]})})]})})}function qf({editing:e,isNew:t,hasOverride:n,onDraft:i,onSave:a,onRestore:o,onRemove:l,onFill:u,onSend:p,onClose:E}){const m=je(),f=c.useRef(null);c.useEffect(()=>{const C=M=>{M.key==="Escape"&&E()};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[E]),c.useEffect(()=>{const C=f.current;if(!C)return;C.style.height="auto";const M=C.scrollHeight>300;C.style.height=`${Math.min(C.scrollHeight,300)}px`,C.style.overflowY=M?"auto":"hidden"},[e.prompt]);const w=()=>{const C=e.title.trim(),M=e.prompt.trim();if(!C||!M){i({...e,error:m("tpl.required")});return}a({id:e.id,icon:e.icon.trim()||"📌",title:C,desc:e.desc.trim(),prompt:M})},N=!!e.builtin&&!t;return s.jsx("div",{className:"modal-backdrop",onClick:E,children:s.jsxs("div",{className:"modal template-modal",onClick:C=>C.stopPropagation(),children:[s.jsxs("div",{className:"template-modal-head",children:[s.jsx("span",{className:"template-modal-icon",children:e.icon}),s.jsx("span",{className:"template-modal-badge",children:m(N?"tpl.builtin":"tpl.custom")}),s.jsx("span",{className:"template-modal-title",children:m(t?"tpl.newTitle":"tpl.editTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:m("close"),onClick:E,children:s.jsx(Ke,{})})]}),s.jsxs("div",{className:"template-modal-body",children:[s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:m("tpl.fieldIcon")}),s.jsx("input",{className:"template-field-input icon",value:e.icon,maxLength:4,onChange:C=>i({...e,icon:C.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:m("tpl.fieldTitle")}),s.jsx("input",{className:"template-field-input",value:e.title,placeholder:m("tpl.fieldTitlePh"),onChange:C=>i({...e,title:C.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:m("tpl.fieldDesc")}),s.jsx("input",{className:"template-field-input",value:e.desc,placeholder:m("tpl.fieldDescPh"),onChange:C=>i({...e,desc:C.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:m("tpl.fieldPrompt")}),s.jsx("textarea",{ref:f,className:"template-field-prompt",value:e.prompt,placeholder:m("tpl.fieldPromptPh"),onChange:C=>i({...e,prompt:C.target.value})})]})]}),e.error&&s.jsx("div",{className:"template-error",children:e.error}),s.jsxs("div",{className:"template-modal-actions",children:[s.jsxs("div",{className:"template-modal-actions-left",children:[!t&&N&&n&&s.jsx("button",{type:"button",className:"btn template-btn ghost",title:m("tpl.restoreTip"),onClick:o,children:m("tpl.restore")}),!t&&N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:m("tpl.removeTip"),onClick:l,children:[s.jsx(et,{})," ",m("tpl.remove")]}),!t&&!N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:m("tpl.deleteTip"),onClick:l,children:[s.jsx(et,{})," ",m("tpl.delete")]})]}),s.jsxs("div",{className:"template-modal-actions-right",children:[s.jsx("button",{type:"button",className:"btn template-btn",onClick:w,children:m("tpl.save")}),s.jsx("button",{type:"button",className:"btn template-btn fill",onClick:u,title:m("tpl.fillTip"),children:m("tpl.fill")}),s.jsxs("button",{type:"button",className:"btn template-btn send",onClick:p,title:m("tpl.sendTip"),children:[s.jsx(ia,{})," ",m("tpl.sendNow")]})]})]})]})})}const sr=new Map,Wf=15,nr=30,Zn=250,ar=1200,Kf=1600;function ir({kind:e,text:t,onRemoveQueued:n,onRecallQueued:i}){const a=je();return s.jsxs("div",{className:"msg msg-user msg-queued","data-role":"user",children:[s.jsxs("div",{className:"msg-meta",children:[s.jsx("span",{className:"msg-role",children:a("role.user")}),s.jsx("span",{className:`queued-tag ${e==="steer"?"steer":"follow"}`,children:a(e==="steer"?"queueSteerTag":"queueFollowTag")}),s.jsxs("div",{className:"msg-queued-actions",children:[i&&s.jsx("button",{type:"button",className:"msg-queued-recall",title:a("queueRecallTip"),"aria-label":a("queueRecallTip"),onClick:()=>i(e,t),children:"↩"}),n&&s.jsx("button",{type:"button",className:"msg-queued-remove",title:a("queueRemoveTip"),"aria-label":a("queueRemoveTip"),onClick:()=>n(e,t),children:"✕"})]})]}),s.jsx("div",{className:"msg-body",children:s.jsx("div",{className:"msg-text",children:s.jsx(rt,{text:t,hardBreaks:!0})})})]})}function Yf({compaction:e}){const t=je(),[,n]=c.useState(0);c.useEffect(()=>{const o=setInterval(()=>n(l=>l+1),1e3);return()=>clearInterval(o)},[]);const i=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3)),a=e.reason==="manual"?t("compactingReasonManual"):e.reason==="overflow"?t("compactingReasonOverflow"):t("compactingReasonThreshold");return s.jsxs("div",{className:"compact-notice",role:"status",children:[s.jsx("span",{className:"compact-pulse"}),s.jsxs("span",{className:"compact-text",children:[t("compactingContext")," · ",i,"s"]}),s.jsx("span",{className:"compact-reason",children:a})]})}function rr(e){return e.content.some(t=>t.type==="toolCall")}function Gf({state:e,liveOutputs:t,toolStatuses:n,onEdit:i,onKillBash:a,onRetry:o,onRemoveQueued:l,onRecallQueued:u,thinkingWrap:p,toolsWrap:E,jumpTarget:m,onJumpDone:f}){const w=je(),N=c.useRef(null),[C,M]=c.useState(!0),W=c.useRef(!0),_=c.useRef(0),D=c.useRef(0),I=c.useRef(!1),H=c.useRef(0),[te,ee]=c.useState(()=>new Set),[le,pe]=c.useState(!1),Q=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,G=c.useMemo(()=>{const L=new Map;for(const V of e.messages)V.role==="toolResult"&&V.toolCallId&&L.set(V.toolCallId,V);return L},[e.messages]),ce=c.useMemo(()=>ff(e.messages),[e.messages]),O=Q.length>0?Q[Q.length-1].id:null,B=e.messages.length>nr?Math.max(0,e.messages.length-Wf):0,x=c.useMemo(()=>{const L=new Set;for(let V=0;V<B;V++){const Se=e.messages[V];Se.role!=="toolResult"&&(te.has(Se.id)||L.add(Se.id))}return L},[e.messages,B,te]),[R,F]=c.useState(()=>new Set),[v,se]=c.useState(()=>new Set),K=c.useRef(new Map),xe=c.useRef(new Map),k=c.useRef(new Map),Y=c.useRef(0),re=c.useMemo(()=>{const L=new Map;for(const V of e.messages)L.set(V.id,kf(V));return L},[e.messages]),de=c.useRef(re);de.current=re;const we=c.useRef(R);we.current=R;const ie=e.messages.length>nr&&!le,me=c.useRef(ie);me.current=ie;const X=yf(e.messages,K.current,Kf),oe=c.useRef(X);oe.current=X;const $=c.useCallback(()=>{const L=N.current;if(!L)return;if(!me.current){F(He=>He.size?new Set:He);return}const V=L.getBoundingClientRect(),Se={top:V.top-ar,bottom:V.bottom+ar},_e=[];for(const[He,ot]of k.current){const yt=ot.getBoundingClientRect();_e.push({id:He,top:yt.top,bottom:yt.bottom}),we.current.has(He)||P(He,yt.bottom-yt.top,de.current.get(He))}const Pe=Tf(_e,Se,oe.current,we.current);for(const He of Pe.hide){const ot=k.current.get(He);ot&&P(He,ot.offsetHeight,de.current.get(He))}F(He=>xf(He,Pe))},[]),Ie=c.useCallback(()=>{Y.current||(Y.current=requestAnimationFrame(()=>{Y.current=0,$()}))},[$]);c.useLayoutEffect(()=>{$()},[$]);const Le=c.useRef(le);c.useLayoutEffect(()=>{Le.current&&!le&&$(),Le.current=le},[le,$]);const P=c.useCallback((L,V,Se)=>{Se!==void 0&&(xe.current.set(L,{h:V,len:Se}),K.current.set(L,V))},[]),ye=c.useCallback((L,V)=>{P(L,V,de.current.get(L))},[P]),he=c.useCallback(L=>{L&&k.current.set(L.dataset.lazyId??"",L)},[]);c.useEffect(()=>{const L=new Set(e.messages.map(V=>V.id));for(const V of k.current.keys())L.has(V)||(k.current.delete(V),K.current.delete(V),xe.current.delete(V));F(V=>{let Se=!1;const _e=new Set;for(const Pe of V)L.has(Pe)?_e.add(Pe):Se=!0;return Se?_e:V})},[e.messages,te]),c.useEffect(()=>()=>cancelAnimationFrame(Y.current),[]);const be=c.useMemo(()=>{const L=[];for(const V of e.messages){if(V.role!=="user")continue;const Se=V.content.map(He=>ls(He)?.text??"").filter(Boolean).join(" "),_e=Ua(Se),Pe=_e?_e.userMessage??`skill:${_e.name}`:Se.trim();Pe&&L.push({id:V.id,text:Pe})}return L},[e.messages]),Te=c.useMemo(()=>{const L=new Map;return be.forEach((V,Se)=>L.set(V.id,Se)),L},[be]),[Ce,ke]=c.useState(-1),y=c.useRef(-1),b=c.useRef(be);c.useEffect(()=>{b.current=be},[be]);const S=c.useCallback(()=>{const L=N.current,V=b.current;if(!L||V.length===0)return;const Se=L.getBoundingClientRect().top,_e=140;let Pe=-1;for(let He=0;He<V.length;He++){const ot=L.querySelector(`[data-msg-id="${V[He].id}"]`);if(ot)if(ot.getBoundingClientRect().top<=Se+_e)Pe=He;else break}Pe!==y.current&&(y.current=Pe,ke(Pe))},[]);c.useEffect(()=>{S()},[be,S]);const z=c.useCallback(L=>{ee(V=>V.has(L)?V:new Set(V).add(L))},[]);c.useEffect(()=>{const L=V=>{if(!(V.ctrlKey||V.metaKey)||V.key.toLowerCase()!=="f")return;const Se=V.target;Se&&(Se.tagName==="INPUT"||Se.tagName==="TEXTAREA"||Se.isContentEditable)||(V.preventDefault(),pe(!0))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const ue=c.useCallback(L=>{ee(V=>{if(!V.has(L))return V;const Se=new Set(V);return Se.delete(L),Se})},[]),Ne=c.useCallback(L=>{const V=e.messages.findIndex(_e=>_e.id===L);ao.flushSync(()=>{V>=0&&V<B&&!te.has(L)&&z(L),se(_e=>_e.has(L)?_e:new Set(_e).add(L))});const Se=b.current.findIndex(_e=>_e.id===L);y.current=Se,ke(Se),requestAnimationFrame(()=>{const _e=N.current?.querySelector(`[data-msg-id="${L}"]`);_e&&(N.current?.querySelectorAll(".msg-flash").forEach(Pe=>Pe.classList.remove("msg-flash")),_e.scrollIntoView({block:"start"}),_e.classList.remove("msg-flash"),_e.offsetWidth,_e.classList.add("msg-flash"),_e!==N.current?.lastElementChild&&(I.current=!0))})},[e.messages,B,te,z]),[De,A]=c.useState(null),fe=c.useRef(null),Ae=c.useRef(null);c.useEffect(()=>{const L=fe.current;if(!L||L.convId!==e.conversationId){fe.current={convId:e.conversationId,ids:new Set(e.messages.filter(V=>V.role==="compactionSummary").map(V=>V.id))},Ae.current=null,A(null);return}for(const V of e.messages)if(V.role==="compactionSummary"&&!L.ids.has(V.id)){L.ids.add(V.id),A(V.id);break}},[e.messages,e.conversationId]),c.useEffect(()=>{!De||Ae.current===De||(Ae.current=De,Ne(De))},[De,Ne]);const Fe=c.useMemo(()=>m?e.messages.find(L=>L.role===m.role&&L.timestamp===m.timestamp)?.id??null:null,[e.messages,m]);c.useEffect(()=>{if(m){if(Fe){Ne(Fe),f?.();return}e.sessionFile===m.path&&e.messages.length>0&&f?.()}},[Fe,Ne,f,m,e.sessionFile,e.messages.length]);const Me=c.useCallback(()=>{const L=N.current;if(!L)return;const V=L.scrollTop-_.current,Se=L.scrollHeight-D.current;_.current=L.scrollTop,D.current=L.scrollHeight;const _e=L.scrollHeight-L.scrollTop-L.clientHeight<80,Pe=Date.now()<H.current,He=Df({dSt:V,dSh:Se,escaped:I.current,graceActive:Pe,stuck:W.current});He.reassert&&(H.current=Date.now()+Zn,L.scrollTop=L.scrollHeight),He.flipEscape&&(I.current=!0),_e&&V>=0&&(I.current=!1),Pe||(V<0?W.current=_e&&!I.current:_e&&(W.current=!0)),M(W.current),S(),Ie()},[S,Ie]),Ge=c.useRef(!1);c.useEffect(()=>{const L=Ge.current;if(Ge.current=!!e.isStreaming,L&&!e.isStreaming&&!I.current){const V=()=>{const _e=N.current;_e&&!I.current&&(_e.scrollTop=_e.scrollHeight,W.current=!0,M(!0))};requestAnimationFrame(()=>requestAnimationFrame(V));const Se=setTimeout(V,180);return()=>clearTimeout(Se)}},[e.isStreaming]),c.useEffect(()=>{const L=N.current;L&&W.current&&(L.scrollTop=L.scrollHeight)},[Q,e.isStreaming,t]);const Xt=e.queue.steering.join("\0")+""+e.queue.followUp.join("\0");c.useEffect(()=>{const L=N.current;L&&W.current&&(L.scrollTop=L.scrollHeight)},[Xt]),c.useEffect(()=>{const L=N.current;if(!L||typeof ResizeObserver>"u")return;let V=L.clientHeight;const Se=new ResizeObserver(()=>{const _e=L.clientHeight,Pe=_e-V;V=_e,Pe>0&&(L.scrollTop=Math.min(L.scrollTop,L.scrollHeight-L.clientHeight))});return Se.observe(L),()=>Se.disconnect()},[]),c.useEffect(()=>{const L=N.current;if(!L||typeof MutationObserver>"u")return;let V=!1;const Se=new MutationObserver(()=>{V||(V=!0,requestAnimationFrame(()=>{V=!1;const _e=N.current;_e&&W.current&&!I.current&&(_e.scrollTop=_e.scrollHeight,M(!0))}))});return Se.observe(L,{childList:!0,subtree:!0,characterData:!0}),()=>Se.disconnect()},[]);const At=c.useCallback(()=>{if(!N.current)return;W.current=!0,I.current=!1,M(!0),H.current=Date.now()+Zn;const V=()=>{const Se=N.current;!Se||!W.current||I.current||(H.current=Date.now()+Zn,Se.scrollTop=Se.scrollHeight)};V(),requestAnimationFrame(()=>requestAnimationFrame(V)),setTimeout(V,120),setTimeout(V,300),setTimeout(V,600)},[]),Ut=c.useRef(null);c.useEffect(()=>{const L=Ut.current,V=N.current;if(!L||!V)return;const Se=_e=>{_e.preventDefault();const Pe=L.querySelector(".qn-list");if(Pe&&Pe.contains(_e.target)&&Pe.scrollHeight>Pe.clientHeight){Pe.scrollTop+=_e.deltaY;return}V.scrollTop+=_e.deltaY};return L.addEventListener("wheel",Se,{passive:!1}),()=>L.removeEventListener("wheel",Se)},[]);const[pt,$t]=c.useState(0);c.useEffect(()=>{const L=()=>{$t(N.current?.clientHeight??0),Ie()};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[Ie]);const xt=be.length,qt=c.useMemo(()=>xt===0?27:Math.max(4,Math.min(27,Math.floor(((pt||600)-16)/xt)-3)),[xt,pt]),It=qt<20;return s.jsxs("div",{className:"messages-wrap",children:[s.jsxs("div",{className:`messages${le||C?"":" anchor-live"}`,ref:N,onScroll:Me,children:[e.messages.length===0&&!e.streamingMessage&&s.jsx("div",{className:"empty-state",children:s.jsx(Uf,{})}),e.messages.map((L,V)=>{const Se=V<B,_e=Se&&te.has(L.id);if(Se&&!_e)return L.role==="toolResult"?null:s.jsx(gf,{message:L,onExpand:z},L.id);const Pe=L.role==="user"?Te.get(L.id):void 0,He=!ie||X.has(L.id)||v.has(L.id)||!R.has(L.id);return s.jsx(Ef,{id:L.id,show:He,height:vf(L.id,re.get(L.id)??-1,xe.current,Xo(L.role,L.customType)),containerRef:N,onMeasured:ye,lazyRef:he,children:s.jsx(Xi,{message:L,qnIndex:Pe,qnActive:Pe!==void 0?Pe===Ce:void 0,onJump:Ne,toolResults:G,liveOutputs:rr(L)?t:sr,toolStatuses:n,streaming:e.isStreaming,onKillBash:a,onRetry:L.id===O?o:void 0,toolsWrap:E,thinkingWrap:p,isLast:L.id===O,onEdit:i,questionAttachments:ce.get(L.id),onCollapse:_e?ue:void 0,searchActive:le,autoExpand:L.id===De},L.id)},L.id)}),e.streamingMessage&&s.jsx(Xi,{message:e.streamingMessage,toolResults:G,liveOutputs:rr(e.streamingMessage)?t:sr,toolStatuses:n,streaming:!0,isLast:!0,onEdit:i,onKillBash:a,toolsWrap:E,thinkingWrap:p,searchActive:le},e.streamingMessage.id),e.retry&&e.isStreaming&&s.jsxs("div",{className:"retry-notice",role:"status",title:e.retry.errorMessage||void 0,children:[s.jsx("span",{className:"retry-pulse"}),s.jsx("span",{className:"retry-text",children:e.retry.maxAttempts>0?w("retryingApi",{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):w("retryingApiSoon",{error:e.retry.errorMessage})})]}),e.compaction&&s.jsx(Yf,{compaction:e.compaction}),e.isStreaming&&Q.length===0&&s.jsx("div",{className:"streaming-wait",children:w("waitingResponse")}),e.queue.steering.map((L,V)=>s.jsx(ir,{kind:"steer",text:L,onRemoveQueued:l,onRecallQueued:u},`q-steer-${V}`)),e.queue.followUp.map((L,V)=>s.jsx(ir,{kind:"followUp",text:L,onRemoveQueued:l,onRecallQueued:u},`q-fu-${V}`))]}),!C&&s.jsxs("button",{type:"button",className:"scroll-bottom",onClick:At,children:[s.jsx(Mr,{})," ",w("backToBottom")]}),s.jsx(Rf,{containerRef:N,messages:Q,collapsedIds:x,toolResults:G,onExpand:z,onProgrammaticScroll:()=>{I.current=!0,W.current=!1,M(!1)},open:le,onClose:()=>pe(!1)}),be.length>0&&s.jsxs("div",{className:`qn-rail ${It?"many":""}`,ref:Ut,"aria-label":w("questionNavTitle"),style:{"--rail-gap":`${qt}px`},children:[be.map((L,V)=>s.jsx("button",{type:"button",className:`qn-bar ${V===Ce?"active":""}`,"aria-label":`${V+1}. ${L.text}`,onClick:()=>Ne(L.id),children:s.jsxs("span",{className:"qn-bar-text",children:[V+1,". ",L.text]})},L.id)),It&&s.jsx("div",{className:"qn-list",children:be.map((L,V)=>s.jsxs("button",{type:"button",className:`qn-list-item ${V===Ce?"active":""}`,"aria-label":`${V+1}. ${L.text}`,onClick:()=>Ne(L.id),children:[s.jsx("span",{className:"qn-list-idx",children:V+1}),s.jsx("span",{className:"qn-list-text",children:L.text})]},L.id))})]})]})}function or(e,t){return t?e.trim()?`${e.replace(/\s+$/,"")}
|
|
325
|
+
${t}`:t:e}function lr(e){return e.key?`key:${e.key}`:e.path?`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:""}`:null}function Vf(e,t){if(t.length===0)return e;if(e.length===0)return[...t];const n=new Set(e.map(lr).filter(a=>a!==null)),i=[...e];for(const a of t){const o=lr(a);if(o!==null){if(n.has(o))continue;n.add(o)}i.push(a)}return i}const zf=1,Qf="";function Xf(e,t,n=zf){return{first:e<=n,last:Math.abs(t-e)<=n}}function Jf(e,t){return{first:!e.slice(0,t).includes(`
|
|
326
|
+
`),last:!e.slice(t).includes(`
|
|
327
|
+
`)}}let ea=null;function Zf(){if(ea?.isConnected)return ea;const e=document.createElement("div");e.setAttribute("aria-hidden","true"),e.setAttribute("data-caret-mirror","");const 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="content-box",t.overflow="visible",document.body.appendChild(e),ea=e,e}function e0(e,t){const n=getComputedStyle(e),i=t.style;i.fontFamily=n.fontFamily,i.fontSize=n.fontSize,i.fontStyle=n.fontStyle,i.fontWeight=n.fontWeight,i.fontVariant=n.fontVariant,i.fontStretch=n.fontStretch,i.lineHeight=n.lineHeight,i.letterSpacing=n.letterSpacing,i.wordSpacing=n.wordSpacing,i.textTransform=n.textTransform,i.textIndent=n.textIndent,i.tabSize=n.tabSize,i.whiteSpace=n.whiteSpace||"pre-wrap",i.overflowWrap=n.overflowWrap||"break-word",i.wordBreak=n.wordBreak||"normal",i.direction=n.direction,i.writingMode=n.writingMode;const a=e.clientWidth-(parseFloat(n.paddingLeft)||0)-(parseFloat(n.paddingRight)||0);return a>0?(i.width=`${a}px`,a):0}function cr(e,t){e.textContent=t;const n=document.createElement("span");return n.textContent=Qf,e.appendChild(n),n.offsetTop}function t0(e){const t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};const i=Jf(t,n);if(!i.first&&!i.last||typeof document>"u"||typeof getComputedStyle!="function")return i;const a=Zf();if(e0(e,a)<=0)return i;const o=cr(a,t.slice(0,n)),l=cr(a,t),u=a.offsetHeight>0;return a.textContent="",!u&&t!==""?i:Xf(o,l)}const qa="pi-web-ui:prompt-history",s0=100,il="pi-web-ui:prompt-history-settings",_a={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function rl(e){const t=_a;if(!e||typeof e!="object")return{...t};const n=e;let i=typeof n.maxEntries=="number"?Math.floor(n.maxEntries):t.maxEntries;(!Number.isFinite(i)||i<1)&&(i=1),i>500&&(i=500);let a=typeof n.charLimit=="number"?Math.floor(n.charLimit):t.charLimit;(!Number.isFinite(a)||a<100)&&(a=100),a>2e4&&(a=2e4);const o=typeof n.charLimitEnabled=="boolean"?n.charLimitEnabled:t.charLimitEnabled;return{maxEntries:i,charLimitEnabled:o,charLimit:a}}function ol(){try{const e=localStorage.getItem(il);return e?rl(JSON.parse(e)):{..._a}}catch{return{..._a}}}function ta(e){const t=rl(e);try{localStorage.setItem(il,JSON.stringify(t))}catch{}try{let n=Os();t.charLimitEnabled&&(n=n.map(i=>i.length>t.charLimit?i.slice(0,t.charLimit):i)),n.length>t.maxEntries&&(n=n.slice(n.length-t.maxEntries)),ll(n)}catch{}}function n0(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="string")continue;const i=n.trim();i&&t.push(i)}return t}function a0(e,t,n=s0){const i=t.trim();if(!i||e.length>0&&e[e.length-1]===i)return e;const a=[...e,i];return a.length>n?a.slice(a.length-n):a}function Os(){try{const e=localStorage.getItem(qa);return e?n0(JSON.parse(e)):[]}catch{return[]}}function ll(e){let t=e;for(;t;)try{localStorage.setItem(qa,JSON.stringify(t));return}catch(n){if(!(n instanceof DOMException&&(n.name==="QuotaExceededError"||n.code===22))||t.length<=1)return;t=t.slice(Math.ceil(t.length/2))}}function ur(e){let t=e.trim();if(!t)return;const n=ol();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));const i=Os(),a=a0(i,t,n.maxEntries);a!==i&&ll(a)}function i0(){try{localStorage.removeItem(qa)}catch{}}function r0(e){const t=e.query;if(!t||!t("(pointer: coarse)")||!t("(hover: none)"))return!1;const 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 o0(){return typeof window>"u"||typeof navigator>"u"||typeof window.matchMedia!="function"?!1:r0({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}const cl=["off","minimal","low","medium","high","xhigh","max"],l0=c.memo(function({state:t,models:n,modelsLoading:i,onManageModels:a,providerKeys:o,compact:l=!1}){const u=je(),p=t?.model,E=p?`${p.provider}/${p.id}`:null,[m,f]=c.useState(!1),[w,N]=c.useState(!1),[C,M]=c.useState(""),[W,_]=c.useState(null),[D,I]=c.useState({}),H=c.useRef(null),te=c.useRef(null),[ee,le]=c.useState(null);c.useEffect(()=>{if(!m){le(null);return}if(n.length===0)return;const v=requestAnimationFrame(()=>{const se=te.current;se&&le(se.offsetWidth)});return()=>cancelAnimationFrame(v)},[m,n.length]),c.useEffect(()=>{m&&I(Zo())},[m]),c.useEffect(()=>{m||(M(""),_(null))},[m]);const pe=c.useMemo(()=>{const v=new Map;for(const K of n)v.set(K.provider,(v.get(K.provider)??0)+1);const se=[];for(const[K,xe]of[...v.entries()].sort((k,Y)=>k[0].localeCompare(Y[0]))){const k=o[K];if(k&&k.length>1)for(const Y of k)se.push({provider:K,keyName:Y.name,count:xe});else se.push({provider:K,keyName:null,count:xe})}return se},[n,o]),Q=c.useMemo(()=>Mf(n,D),[n,D]),G=c.useMemo(()=>{let v=Q;W&&(v=v.filter(K=>K.provider===W.provider));const se=C.trim().toLowerCase();return se?v.filter(K=>K.name.toLowerCase().includes(se)||K.provider.toLowerCase().includes(se)||K.id.toLowerCase().includes(se)):v},[Q,C,W]),ce=c.useMemo(()=>{const v=[];for(const se of G){const K=o[se.provider];if(!K||K.length<=1){v.push({model:se,key:null});continue}let xe=K.find(k=>k.active)??K[0];if(W?.provider===se.provider&&W.keyName){const k=K.find(Y=>Y.name===W.keyName);k&&(xe=k)}v.push({model:se,key:xe})}return v},[G,o,W]),[O,B]=c.useState(!1),x=t?.availableThinkingLevels&&t.availableThinkingLevels.length>0?new Set(t.availableThinkingLevels):null,R=cl.map(v=>({value:v,label:u(`thinking.${v}`),supported:x?x.has(v):!0})),F=v=>R.find(se=>se.value===v)?.label??v;return c.useEffect(()=>{m&&n.length===0&&!O&&!i&&(B(!0),ae({type:"list_models"}))},[m,n.length,O,i]),c.useEffect(()=>{n.length>0&&B(!1)},[n.length]),c.useEffect(()=>{if(!m)return;H.current?.querySelector(".dd-item.active")?.scrollIntoView({block:"nearest"})},[m,E,n.length]),s.jsxs(s.Fragment,{children:[s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Ds,{}),s.jsx("span",{className:"chip-model",children:p?p.name:u("selectModel")}),!l&&p?.vision&&s.jsx("span",{className:"chip-vision",title:u("vision"),children:"🖼"}),!l&&p&&s.jsx("span",{className:"chip-sub",children:p.provider})]}),open:m,onOpenChange:f,menuClassName:"dd-menu-model",menuRef:te,menuStyle:ee!=null?{width:ee}:void 0,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("availableModels")}),s.jsxs("div",{className:"dd-search-row",children:[s.jsx(pn,{}),s.jsx("input",{className:"dd-search",type:"text",placeholder:u("searchModels"),value:C,onChange:v=>M(v.target.value)})]}),s.jsxs("div",{className:"dd-model-body",children:[pe.length>1&&s.jsxs("div",{className:"dd-provider-col",children:[s.jsx("div",{className:"dd-provider-head",children:u("providers")}),s.jsx("button",{type:"button",className:`dd-provider-item ${W===null?"active":""}`,onClick:()=>_(null),children:s.jsx("span",{children:u("allProviders")})}),pe.map(v=>{const se=W?.provider===v.provider&&W?.keyName===v.keyName;return s.jsxs("button",{type:"button",className:`dd-provider-item ${se?"active":""}`,onClick:()=>_(se?null:{provider:v.provider,keyName:v.keyName}),title:v.keyName?`${v.provider} · ${v.keyName}`:`${v.provider} · ${v.count}`,children:[s.jsxs("span",{className:"dd-provider-txt",children:[s.jsx("span",{className:"dd-provider-name",children:v.provider}),v.keyName&&s.jsx("span",{className:"dd-provider-key",children:v.keyName})]}),s.jsx("span",{className:"dd-provider-count",children:v.count})]},v.keyName?`${v.provider}::${v.keyName}`:v.provider)})]}),s.jsxs("div",{className:"dd-model-scroll",ref:H,children:[(O||i)&&s.jsx("div",{className:"dd-loading",children:u("loading")}),n.length===0&&!O&&!i&&s.jsx("div",{className:"dd-loading",children:u("noModels")}),G.length===0&&n.length>0&&s.jsx("div",{className:"dd-loading",children:u("noModelMatches")}),ce.map(v=>{const se=v.model,K=E===se.id&&(!v.key||v.key.active);return s.jsx(it,{active:K,onClick:()=>{v.key&&!v.key.active&&ae({type:"activate_provider_key",provider:se.provider,keyName:v.key.name}),E!==se.id&&ae({type:"set_model",modelId:se.id}),f(!1)},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:se.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:se.provider}),s.jsx("span",{className:"dd-model-id",children:se.id.split("/").slice(1).join("/")}),v.key&&s.jsxs("span",{className:`dd-model-key ${v.key.active?"active":""}`,children:[v.key.active?"●":"○"," ",v.key.name]}),(D[se.id]??0)>0&&s.jsx("span",{className:"dd-model-usage",children:u("modelUsedCount",{n:D[se.id]})}),(se.reasoning||se.vision)&&s.jsxs("span",{className:"dd-model-badges",children:[se.reasoning&&s.jsx("span",{className:"dd-model-badge",children:u("reasoning")}),se.vision&&s.jsx("span",{className:"dd-model-badge",children:u("vision")})]})]})]})},v.key?`${se.id}::${v.key.name}`:se.id)})]})]}),s.jsxs("div",{className:"dd-footer",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>ae({type:"list_models"}),children:u("refreshModels")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{f(!1),a()},children:u("manageModels")})]})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(zs,{}),s.jsx("span",{className:"chip-sub",children:u("thinkingChip",{level:t?F(t.thinkingLevel):"—"})})]}),open:w,onOpenChange:N,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("thinkingLevel")}),R.map(v=>s.jsx(it,{active:t?.thinkingLevel===v.value,disabled:!v.supported,title:v.supported?void 0:u("thinkingUnsupported"),onClick:()=>{t?.thinkingLevel!==v.value&&ae({type:"set_thinking",level:v.value}),N(!1)},children:v.label},v.value))]})]})}),dr=o0(),c0=c.memo(function({streaming:t,messages:n,slashCommands:i,modelState:a,models:o,modelsLoading:l,attachments:u,onRemoveAttachment:p,onAddImageFiles:E,onAddLocalFiles:m,onNotice:f,onSent:w,onManageModels:N,providerKeys:C,quickPhrases:M,quickPhrasesEnabled:W,recallDrafts:_}){const D=je(),I=Ct("ready"),H=Qr(),{locale:te}=Ht(),{openPicker:ee}=nl(),le=b=>te!=="zh"&&b.descriptionEn?b.descriptionEn:b.description??"",pe=b=>te!=="zh"&&b.argumentHintEn?b.argumentHintEn:b.argumentHint??"",[Q,G]=c.useState(""),[ce,O]=c.useState(null),[B,x]=c.useState(0),[R,F]=c.useState(!1),[v,se]=c.useState(void 0),K=c.useRef(null),xe=c.useRef(null),k=c.useRef(null),Y=c.useRef(-1),re=c.useRef(""),de=c.useRef(0);c.useEffect(()=>{if(!_||_.length===0)return;const b=_.filter(S=>S.text&&S.seq>de.current);b.length!==0&&(de.current=b[b.length-1].seq,G(S=>b.reduce((z,ue)=>or(z,ue.text),S)),Y.current=-1,re.current="",requestAnimationFrame(()=>{const S=K.current;S&&(S.focus(),S.selectionStart=S.selectionEnd=S.value.length)}))},[_]),c.useEffect(()=>(oi(b=>{G(S=>or(S,b)),Y.current=-1,re.current="",requestAnimationFrame(()=>{const S=K.current;S&&(S.focus(),S.selectionStart=S.selectionEnd=S.value.length)})}),()=>oi(null)),[]);const we={builtin:D("slashBuiltin"),extension:D("slashExtension"),prompt:D("slashPrompt"),skill:D("slashSkill"),plugin:D("slashPlugin")},ie=b=>{const S=b.match(/^\/([^\s]*)$/);if(S&&I){const z=S[1].toLowerCase(),ue=i.filter(Ne=>Ne.name.toLowerCase().startsWith(z));O(ue.length>0?ue:null),x(0)}else O(null)};c.useEffect(()=>{k.current?.querySelector(".slash-item.active")?.scrollIntoView({block:"nearest"})},[B,ce]);const me=b=>{const S=ce??[],z=b??S[B%Math.max(S.length,1)];if(!z){O(null);return}const ue=Q.match(/^\/([^\s]*)([\s\S]*)$/),Ne=ue?ue[2]:"";G(`/${z.name} ${Ne}`),O(null),K.current?.focus()},X=async()=>{const z=[...n].reverse().find(ue=>ue.role==="assistant"&&ue.content.some(Ne=>Ne.type==="text"&&Ne.text))?.content.filter(ue=>ue.type==="text").map(ue=>ue.text).join(`
|
|
328
|
+
`);if(!z){f("warning",D("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(z),f("info",D("slashCopied"))}catch{f("error",D("slashCopyFailed"))}},oe=b=>{if(!b||b.length===0){f("warning",D("foldersNotSupported"));return}const S=Array.from(b).filter(Ne=>_t(Ne.type)),z=Array.from(b).filter(Ne=>!_t(Ne.type)),ue=Ie();S.length>0&&ue?f("warning",ue):S.length>0&&E(S),z.length>0&&m(z)},$=b=>{const S=b.clipboardData?.items;if(!S)return;const z=[];for(const Ne of S)if(Ne.kind==="file"&&_t(Ne.type)){const De=Ne.getAsFile();De&&z.push(De)}if(z.length===0)return;b.preventDefault();const ue=Ie();if(ue){f("warning",ue);return}E(z)},Ie=()=>{const b=a?.model;if(!b?.id)return null;const S=o.find(z=>z.id===b.id);return S&&S.vision===!1?D("modelNoVision",{name:S.name}):null},Le=I,P=c.useRef(Q);c.useEffect(()=>{P.current=Q},[Q]),c.useEffect(()=>{ie(P.current)},[i]),c.useEffect(()=>{const b=S=>{const z=S.detail;G(z),K.current?.focus()};return window.addEventListener("pi-web:fill",b),()=>window.removeEventListener("pi-web:fill",b)},[]),c.useEffect(()=>{if(!R)return;const b=S=>{S.key==="Escape"&&F(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[R]);const ye=c.useRef(null);c.useEffect(()=>{const b=K.current,S=ye.current;if(!b||!S)return;const z=b.closest("main")?.querySelector(".messages"),ue=S.getBoundingClientRect().height,Ne=z?.scrollTop??0;b.style.height="auto";const De=b.scrollHeight>220;if(b.style.height=`${Math.min(b.scrollHeight,220)}px`,b.style.overflowY=De?"auto":"hidden",z){const A=S.getBoundingClientRect().height-ue;z.scrollTop=Ne+A}},[Q]);const he=()=>u.map(b=>b.imageData?{path:"",imageData:b.imageData,mimeType:b.mimeType,name:b.name}:b.fileData?{path:"",fileData:b.fileData,mimeType:b.mimeType,name:b.name,size:b.size}:{path:b.path,mode:b.mode,...b.lines?{lines:b.lines}:{},...b.mode==="page"?{name:b.name}:{}}),be=(b=!1)=>{const S=Q.trim(),z=u.some(ue=>ue.imageData||ue.fileData);if(!(!Le||!S&&!z)){if(S==="/help"){const ue=K.current?.closest(".inputbox")?.getBoundingClientRect();se(ue?.width),F(!0),G(""),K.current?.focus();return}if(S==="/copy"){G(""),K.current?.focus(),X();return}if(ae({type:"prompt",text:S,queue:b,attachments:he()})){S&&ur(S),Y.current=-1,re.current="",G(""),w();const ue=a?.model;ue&&wn(`${ue.provider}/${ue.id}`),K.current?.focus()}}},Te=b=>{const S=b.trim();if(!(!Le||!S)&&ae({type:"prompt",text:S,attachments:he()})){S&&ur(S),Y.current=-1,re.current="",w();const z=a?.model;z&&wn(`${z.provider}/${z.id}`),dr||K.current?.focus()}},Ce=b=>{if(!b.nativeEvent.isComposing){if(ce&&ce.length>0)switch(b.key){case"ArrowDown":b.preventDefault(),x(S=>(S+1)%ce.length);return;case"ArrowUp":b.preventDefault(),x(S=>(S-1+ce.length)%ce.length);return;case"Tab":case"Enter":b.preventDefault(),me();return;case"Escape":b.preventDefault(),O(null);return}if(b.key==="ArrowUp"||b.key==="ArrowDown"){if(b.ctrlKey||b.metaKey||b.altKey)return;const S=K.current;if(!S)return;const z=b.key==="ArrowUp",ue=t0(S);if(z&&!ue.first||!z&&!ue.last||!z&&Y.current===-1)return;const Ne=Os();if(Ne.length===0)return;if(b.preventDefault(),z){if(Y.current===-1){re.current=Q;const De=Ne.length-1;Y.current=De;const A=Ne[De];G(A),ie(A),requestAnimationFrame(()=>{const fe=K.current;fe&&(fe.selectionStart=fe.selectionEnd=A.length)})}else if(Y.current>0){const De=Y.current-1;Y.current=De;const A=Ne[De];G(A),ie(A),requestAnimationFrame(()=>{const fe=K.current;fe&&(fe.selectionStart=fe.selectionEnd=A.length)})}}else{const De=Y.current+1;if(De<Ne.length){Y.current=De;const A=Ne[De];G(A),ie(A),requestAnimationFrame(()=>{const fe=K.current;fe&&(fe.selectionStart=fe.selectionEnd=A.length)})}else{Y.current=-1;const A=re.current;G(A),ie(A),requestAnimationFrame(()=>{const fe=K.current;fe&&(fe.selectionStart=fe.selectionEnd=A.length)})}}return}if(b.key==="Escape"&&Y.current!==-1){b.preventDefault();const S=re.current;Y.current=-1,G(S),ie(S),requestAnimationFrame(()=>{const z=K.current;z&&(z.selectionStart=z.selectionEnd=S.length)});return}if(b.key==="Enter"){if(dr&&!b.shiftKey&&!(b.ctrlKey||b.metaKey))return;b.shiftKey||(b.preventDefault(),be())}}},ke=Le&&(Q.trim()!==""||u.some(b=>b.imageData||b.fileData)),y=()=>s.jsx("div",{className:"inputbox-actions",children:t?ke?s.jsxs("div",{className:`split-send${H?" single":""}`,children:[s.jsx("button",{type:"button",className:"split-queue",title:D("supplementTip"),"aria-label":D("queueFollowTag"),onClick:()=>be(!0),children:s.jsx(wc,{})}),!H&&s.jsx("button",{type:"button",className:"split-steer",title:D("steerTip"),"aria-label":D("queueSteerTag"),onClick:()=>be(),children:s.jsx(ca,{})})]}):s.jsx("button",{type:"button",className:"btn stop",title:D("stopAgent"),onClick:()=>ae({type:"abort"}),children:s.jsx(un,{})}):s.jsx("button",{type:"button",className:"btn send",title:D("sendTip"),disabled:!ke,onClick:()=>be(),children:s.jsx(ca,{})})});return s.jsxs("div",{ref:ye,className:"inputbar",onDragOver:b=>{b.preventDefault()},onDrop:b=>{b.preventDefault(),b.stopPropagation(),oe(b.dataTransfer?.files??null)},children:[u.length>0&&s.jsxs("div",{className:"attach-row",children:[u.map(b=>s.jsxs("span",{className:`attach-chip ${b.imageData?"image":b.fileData?"file":b.mode}`,title:b.imageData?D("attachImage",{name:b.name}):b.fileData?D("attachFile",{name:b.name}):b.isDir?D("folderRef",{path:b.path}):b.mode==="page"?D("attachPage",{name:b.name}):b.mode==="reference"?D("refOnly",{path:b.path}):b.mode==="lines"&&b.lines?D("attachLines",{path:b.path,start:b.lines.start,end:b.lines.end}):D("attachContent",{path:b.path}),children:[b.imageData?"🖼":b.fileData?"📄":b.isDir?"📁":b.mode==="page"?"🌐":b.mode==="reference"?"🔗":"📎",b.name,b.mode==="lines"&&b.lines&&s.jsxs("span",{className:"attach-range",children:["L",b.lines.start,"-",b.lines.end]}),s.jsx("button",{type:"button",className:"attach-remove",title:D("removeAttachment"),onClick:()=>p(b.key??b.path),children:"×"})]},b.key??`${b.path}|${b.mode}|${b.lines?`${b.lines.start}-${b.lines.end}`:""}`)),s.jsx("span",{className:"attach-hint",children:D("attachHint")})]}),ce&&ce.length>0&&s.jsxs("div",{className:"slash-menu",role:"listbox",ref:k,"aria-label":D("slashCommands"),children:[s.jsxs("div",{className:"slash-menu-hint",children:[s.jsx("span",{children:D("slashMenuHint")}),s.jsx("span",{className:"slash-menu-close",onClick:()=>O(null),children:"Esc"})]}),ce.map((b,S)=>s.jsxs("button",{type:"button",className:`slash-item${S===B?" active":""}`,onMouseEnter:()=>x(S),onClick:()=>me(b),children:[s.jsxs("span",{className:"slash-name",children:["/",b.name]}),s.jsx("span",{className:`slash-source ${b.source}`,children:we[b.source]}),s.jsxs("span",{className:"slash-desc",children:[le(b),b.argumentHint&&s.jsx("span",{className:"slash-hint",children:pe(b)})]})]},b.name))]}),R&&s.jsx("div",{className:"modal-backdrop",onClick:()=>F(!1),children:s.jsxs("div",{className:"slash-help",style:v?{width:v}:void 0,onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"slash-help-head",children:[s.jsxs("span",{children:["⚡ ",D("slashHelpTitle")]}),s.jsx("button",{type:"button",className:"btn",onClick:()=>F(!1),children:D("close")})]}),s.jsx("div",{className:"slash-help-body",children:i.length===0?s.jsx("div",{className:"slash-help-empty",children:D("slashLoading")}):i.map(b=>s.jsxs("div",{className:"slash-help-row",children:[s.jsxs("span",{className:"slash-help-cmd",children:["/",b.name]}),s.jsx("span",{className:`slash-source ${b.source}`,children:we[b.source]}),s.jsxs("span",{className:"slash-help-desc",children:[le(b),b.argumentHint&&s.jsx("span",{className:"slash-hint",children:pe(b)})]})]},b.name))})]})}),W&&M.length>0&&s.jsx("div",{className:"quick-row","aria-label":D("quickPhrases"),children:M.map(b=>s.jsx("button",{type:"button",className:"quick-chip",title:D("quickPhrasesTip",{text:b}),disabled:!Le,onClick:()=>Te(b),children:b},b))}),s.jsxs("div",{className:"inputbox",children:[s.jsx("input",{ref:xe,type:"file",multiple:!0,hidden:!0,onChange:b=>{oe(b.target.files),b.target.value=""}}),s.jsx("textarea",{ref:K,value:Q,rows:1,placeholder:D(Le?t?H?"placeholderStreamingQueued":"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!Le,onChange:b=>{Y.current=-1,G(b.target.value),ie(b.target.value)},onKeyDown:Ce,onPaste:$}),s.jsxs("div",{className:"composer-tools",children:[s.jsxs("div",{className:"composer-tools-left",children:[s.jsx("button",{type:"button",className:"btn attach-img",title:D("uploadFile"),disabled:!Le,onClick:()=>xe.current?.click(),children:s.jsx(Ec,{})}),s.jsx("button",{type:"button",className:"btn tpl-open",title:D("tpl.openPicker"),onClick:ee,children:s.jsx(Ic,{})}),s.jsx(l0,{state:a,models:o,modelsLoading:l,onManageModels:N,providerKeys:C,compact:!0})]}),s.jsx("div",{className:"composer-tools-right",children:y()})]})]})]})}),u0=c.memo(function({goal:t,models:n,modelsLoading:i,activeConversationId:a}){const o=je(),{locale:l}=Ht(),u=l!=="zh"&&t.statusEn?t.statusEn:t.status||"",p=l!=="zh"&&t.wizard?.statusEn?t.wizard.statusEn:t.wizard?.status||"",E=Qr(),m=!t.conversationId||t.conversationId===a,f=t.goal!==null&&m,[w,N]=c.useState(""),[C,M]=c.useState(t.reviewModel??""),[W,_]=c.useState(t.maxRounds),[D,I]=c.useState(t.locked),[H,te]=c.useState(!1),[ee,le]=c.useState(!1),[pe,Q]=c.useState(!0);c.useEffect(()=>{M(t.reviewModel??""),_(t.maxRounds||0),I(t.locked)},[t.goal,t.reviewModel,t.maxRounds,t.locked]),c.useEffect(()=>{H&&n.length===0&&!ee&&!i&&(le(!0),ae({type:"list_models"}))},[H,n.length,ee,i]),c.useEffect(()=>{n.length>0&&le(!1)},[n.length]);const G=()=>C?n.find(x=>x.id===C)?.name??C:o("goalBarUseMainModel"),ce=()=>{const x=w.trim();x&&(ae({type:"set_goal",goal:x,...C?{reviewModel:C}:{},maxRounds:W,locked:D}),N(""),Q(!1))},O=()=>{const x=w.trim();x&&(ae({type:"start_goal_wizard",text:x,...C?{wizardModel:C}:{},maxRounds:W,locked:D}),N(""),Q(!1))},B=(t.wizard?.active??!1)&&m;return B?s.jsx("div",{className:`goalbar goalbar-active ${B?"wizard":""}`,children:s.jsxs("div",{className:"goalbar-active-row",children:[s.jsx("span",{className:"goalbar-icon",children:s.jsx("span",{className:"goalbar-spin",children:"🔍"})}),s.jsxs("span",{className:"goalbar-text",title:t.wizard?.draft??"",children:[o("goalWizardRunning"),": ",t.wizard?.draft]}),s.jsxs("span",{className:"goalbar-chip reviewing",children:[o("goalBarRound",{n:(t.wizard?.step??0)+1})," / ",t.wizard?.maxSteps??6]}),s.jsx("span",{className:"goalbar-detail",children:p||o("goalBarReviewing")}),s.jsx("button",{type:"button",className:"goalbar-x",title:o("goalBarClear"),onClick:()=>{ae({type:"clear_goal"}),Q(!0)},children:s.jsx(Ke,{})})]})}):f?s.jsx("div",{className:`goalbar goalbar-active ${t.reviewing?"reviewing":""}`,children:s.jsxs("div",{className:"goalbar-active-row",children:[s.jsx("span",{className:"goalbar-icon",children:t.reviewing?s.jsx("span",{className:"goalbar-spin",children:"◌"}):"🎯"}),s.jsx("span",{className:"goalbar-text",title:t.goal??"",children:t.goal}),t.reviewing?s.jsxs("span",{className:"goalbar-chip reviewing",children:[o("goalBarReviewing")," ",o("goalBarRound",{n:t.round})]}):s.jsx("span",{className:`goalbar-chip ${t.verdict==="pass"?"pass":t.verdict==="fail"?"fail":""}`,children:t.verdict==="pass"?o("goalBarPassed"):t.verdict==="fail"?o("goalBarFailed"):`${o("goalBarRound",{n:t.round||1})} · ${t.locked?o("goalBarLocked"):o("goalBarUnlocked")}`}),s.jsx("span",{className:"goalbar-detail",children:u}),s.jsx("button",{type:"button",className:"goalbar-x",title:o("goalBarClear"),disabled:t.reviewing,onClick:()=>{ae({type:"clear_goal"}),Q(!0)},children:s.jsx(Ke,{})})]})}):pe?s.jsx("div",{className:"goalbar goalbar-collapsed",children:s.jsxs("button",{type:"button",className:"goalbar-hint",title:o("goalBarPlaceholder"),onClick:()=>Q(!1),children:[s.jsx(ei,{})," ",s.jsx("span",{children:o("goalBarTitle")})]})}):s.jsxs("div",{className:"goalbar",children:[s.jsxs("div",{className:"goalbar-row",children:[s.jsx("span",{className:"goalbar-icon",children:s.jsx(ei,{})}),s.jsx("input",{className:"goalbar-input",value:w,placeholder:o("goalBarPlaceholder"),onChange:x=>N(x.target.value),onKeyDown:x=>{x.key==="Enter"&&ce()}}),s.jsx("button",{type:"button",className:"goalbar-btn",disabled:!w.trim(),onClick:ce,children:o("goalBarSet")}),s.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!w.trim(),title:o("goalWizardTip"),onClick:O,children:["🔍 ",o("goalWizardBtn")]}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o(D?"goalBarLocked":"goalBarUnlocked"),onClick:()=>I(x=>(ae({type:"set_goal_prefs",locked:!x}),!x)),children:D?s.jsx(Cc,{}):s.jsx(hc,{})}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o("goalBarClear"),onClick:()=>Q(!0),children:s.jsx(Rn,{})})]}),s.jsxs("div",{className:"goalbar-opts",children:[E?s.jsx("p",{className:"goalbar-dsh-note",children:o("dshNoReviewModel")}):s.jsxs(Pt,{trigger:s.jsxs("span",{className:"goalbar-opt",children:[o("goalBarReviewModel"),": ",s.jsx("b",{children:G()})]}),open:H,onOpenChange:te,direction:"up",children:[s.jsx("div",{className:"dd-header",children:o("goalBarReviewModel")}),(ee||i)&&s.jsx("div",{className:"dd-loading",children:o("loading")}),n.length===0&&!ee&&!i&&s.jsx("div",{className:"dd-loading",children:o("noModels")}),s.jsx(it,{active:C==="",onClick:()=>{M(""),te(!1),ae({type:"set_goal_prefs",reviewModel:""})},children:o("goalBarUseMainModel")}),n.map(x=>s.jsx(it,{active:C===x.id,onClick:()=>{M(x.id),te(!1),ae({type:"set_goal_prefs",reviewModel:x.id})},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:x.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:x.provider}),s.jsx("span",{className:"dd-model-id",children:x.id.split("/").slice(1).join("/")})]})]})},x.id)),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>ae({type:"list_models"}),children:o("refreshModels")})]}),s.jsxs("label",{className:"goalbar-round",title:o("goalBarMaxRoundsTip"),children:[s.jsx("span",{children:o("goalBarMaxRounds")}),s.jsx("input",{type:"number",min:0,step:1,value:W,placeholder:o("goalBarUnlimitedShort"),onChange:x=>{const R=parseInt(x.target.value,10);if(Number.isNaN(R)||R<0){_(0);return}_(R)},onBlur:()=>ae({type:"set_goal_prefs",maxRounds:W}),onKeyDown:x=>{x.key==="Enter"&&(ae({type:"set_goal_prefs",maxRounds:W}),x.target.blur())}})]}),s.jsx("span",{className:"goalbar-lock-hint",children:o(D?"goalBarLocked":"goalBarUnlocked")})]})]})});function d0(e){const t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),i=Math.max(0,e.cacheWrite??0),a=t+n+i;return{totalInput:a,miss:t,read:n,write:i,hitRate:a>0?Math.min(n/a,1):0,writeRate:a>0?Math.min(i/a,1):0}}const ul=2e3;function p0(e,t,n=ul){return e.filter(i=>t-i.t<=n)}function m0(e,t=ul){if(e.length<2)return 0;const n=e[e.length-1],i=e.find(o=>o.t>=n.t-t)??e[0],a=(n.t-i.t)/1e3;return a<=0?0:Math.max(0,(n.out-i.out)/a)}function pr(e){if(!e)return 0;let t=0;for(let i=0;i<e.length;i++){const a=e.charCodeAt(i);(a>=12352&&a<=12543||a>=13312&&a<=19903||a>=19968&&a<=40959||a>=63744&&a<=64255||a>=65280&&a<=65519||a===12288)&&t++}const n=e.length-t;return Math.round(t+n/4)}function h0(e){let t=0;for(const n of e)n.type==="text"&&typeof n.text=="string"&&n.text?t+=pr(n.text):n.type==="thinking"&&typeof n.thinking=="string"&&n.thinking&&(t+=pr(n.thinking));return t}const bt="@root";function f0({chat:e}){const t=je(),{engine:n}=Ra(),i=e.state,[a,o]=c.useState(!1),[l,u]=c.useState(""),[p,E]=c.useState(""),[m,f]=c.useState(!1),[w,N]=c.useState(""),[C,M]=c.useState(-1),W=c.useRef(null),_=c.useRef(null),D=e.pathCompletions.filter(ie=>ie.type==="dir"),I=ie=>ie.endsWith("/")?ie:ie+"/",H=ie=>{let me=ie.endsWith("/")&&ie!=="/"?ie.slice(0,-1):ie;if(me===bt||me==="/")return null;const X=me.lastIndexOf("/");if(X<0)return/^[A-Za-z]:$/.test(me)?bt:null;if(X===0)return"/";const oe=me.slice(0,X);return/^[A-Za-z]:$/.test(oe)?oe+"/":oe};c.useEffect(()=>{if(!a)return;const ie=setTimeout(()=>{ae({type:"complete_path",path:I(l)})},60);return()=>clearTimeout(ie)},[l,a]),c.useEffect(()=>{if(!a||p===l)return;const ie=setTimeout(()=>{ae({type:"complete_path",path:p})},150);return()=>clearTimeout(ie)},[p,l,a]);const te=c.useRef([]),ee=i?.isStreaming??!1,le=i?.streamingMessage?h0(i.streamingMessage.content):0;if(c.useEffect(()=>{if(!ee){te.current=[];return}const ie=Date.now(),me=te.current,X=me[me.length-1];X&&ie-X.t<250||(te.current=p0([...me,{t:ie,out:le}],ie))},[ee,le]),!i)return null;const pe=i.stats,Q=d0(pe.tokens),G=Q.hitRate*100,ce=Q.totalInput===0?"":Q.hitRate>=.7?"ok":Q.hitRate>=.4?"mid":"warn",O=Q.totalInput>0?`${G.toFixed(1)}%`:"—",B=ee?m0(te.current):0,x=e.ready?"ok":"busy",R=e.ready?t("connected"):t("connecting"),F=pe.contextUsage,v=F.tokens!==null&&F.percent!==null?`${F.estimated?"~":""}${es(F.tokens)} / ${es(F.contextWindow)}`:"—",se=F.percent??null,K=se===null?"":se>=80?"warn":se>=50?"mid":"ok",xe=i.queue.steering.length+i.queue.followUp.length,k=()=>{const ie=i.cwd.replace(/\\/g,"/");E(ie),u(ie),f(!1),N(""),o(!0)},Y=ie=>{const me=ie.trim();me!==bt&&(me&&me!==i.cwd&&ae({type:"set_cwd",path:me}),o(!1))},re=()=>{const ie=w.trim();ie&&(ae({type:"make_dir",path:`${I(l)}${ie}`}),setTimeout(()=>{ae({type:"complete_path",path:I(l)})},80),N(""),f(!1))},de=ie=>{if(ie.key==="Escape")ie.stopPropagation(),o(!1);else if(ie.key==="Enter"&&!ie.nativeEvent.isComposing)Y(p);else if(ie.key==="Tab"){if(D.length===0)return;ie.preventDefault();const me=C>=0?(C+1)%D.length:0;M(me),E(D[me].path),u(D[me].path)}},we=H(l);return s.jsxs("footer",{className:"statusbar",children:[s.jsx("span",{className:`status-dot ${x}`,title:R}),s.jsx("span",{className:"status-item",children:R}),s.jsx("span",{className:"status-sep",children:"·"}),n!=="pi"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`status-item engine-badge engine-${n}`,title:`${t("engineBadge")}: ${n}`,children:n==="dsh"?"DSH":n}),s.jsx("span",{className:"status-sep",children:"·"})]}),s.jsxs("span",{className:"status-item status-ctx",title:t("contextUsage"),children:[s.jsx("span",{className:"ctx-label",children:t("context")}),s.jsx("span",{className:`ctx-bar ${K}`,children:se!==null&&s.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min(se,100)}%`}})}),v]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:t("cumulativeCost"),children:["$",g0(pe.cost)]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item status-cache",title:t("cacheHitTip",{read:es(Q.read),write:es(Q.write),miss:es(Q.miss),input:es(Q.totalInput)}),children:[t("cacheHit"),s.jsx("b",{className:`cache-pct ${ce}`,children:O})]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:t("sessionMessages"),children:[t("messages")," ",pe.totalMessages]}),e.statuses.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"status-sep",children:"·"}),s.jsx("span",{className:"status-item ext-status",title:t("pluginStatus"),children:e.statuses.map(ie=>ie.text).join(" · ")})]}),i.isStreaming&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item working",children:[s.jsx("span",{className:"working-spin"}),t("working"),xe>0&&s.jsxs("span",{className:"status-queue",children:["⏳ ",xe," ",t("queued")]})]}),s.jsxs("span",{className:"status-item status-rate",title:t("rateTip"),children:[s.jsx("span",{className:"working-spin rate-spin"}),B>0?`${Math.round(B)}${t("tps")}`:"…"]})]}),a?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"status-cwd-backdrop",onClick:()=>o(!1)}),s.jsxs("div",{className:"cwd-picker",children:[s.jsxs("div",{className:"cwd-picker-head",children:[s.jsxs("span",{className:"cwd-picker-title",title:l===bt?t("computer"):l,children:[l===bt?"💻":s.jsx(Bt,{}),s.jsx("span",{children:l===bt?t("computer"):l})]}),s.jsx("button",{type:"button",className:"cwd-up",disabled:l===bt,title:t("computer"),onClick:()=>{u(bt),E(bt),M(-1)},children:"💻"}),s.jsxs("button",{type:"button",className:"cwd-up",disabled:!we,title:t("cwdGoUp"),onClick:()=>{we&&(u(we),E(we),M(-1))},children:["↑ ",t("cwdGoUp")]})]}),s.jsxs("div",{className:"cwd-picker-row",children:[s.jsx("input",{ref:W,className:"status-cwd-input cwd-picker-input",value:p,placeholder:t("enterPath"),spellCheck:!1,onChange:ie=>{E(ie.target.value),M(-1)},onKeyDown:de}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",title:t("cwdPickCurrent"),disabled:l===bt,onClick:()=>Y(l),children:t("cwdPickCurrent")})]}),s.jsxs("div",{className:"cwd-list",children:[D.length===0&&s.jsx("div",{className:"cwd-empty",children:t("cwdEmpty")}),D.map(ie=>s.jsxs("div",{className:"cwd-item",children:[s.jsxs("button",{type:"button",className:"cwd-enter",title:`${t("cwdEnter")} ${ie.path}`,onClick:()=>{u(ie.path),E(ie.path),M(-1)},children:[s.jsx(Bt,{}),s.jsx("span",{className:"cwd-name",children:ie.name})]}),s.jsx("button",{type:"button",className:"cwd-choose-btn",title:t("cwdChoose"),onClick:()=>Y(ie.path),children:t("cwdChoose")})]},ie.path))]}),s.jsx("div",{className:"cwd-picker-foot",children:m?s.jsxs("div",{className:"cwd-newrow",children:[s.jsx("input",{ref:_,value:w,autoFocus:!0,spellCheck:!1,placeholder:t("cwdNewName"),onChange:ie=>N(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&!ie.nativeEvent.isComposing?(ie.preventDefault(),re()):ie.key==="Escape"&&(ie.stopPropagation(),f(!1),N(""))}}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",onClick:re,children:t("cwdCreate")}),s.jsx("button",{type:"button",className:"cwd-choose-btn",onClick:()=>{f(!1),N("")},children:t("cwdCancel")})]}):s.jsxs("button",{type:"button",className:"cwd-newbtn",onClick:()=>f(!0),children:["+ ",t("cwdNewFolder")]})})]})]}):s.jsxs("button",{type:"button",className:"status-item status-cwd",title:t("cwdTip",{path:i.cwd}),onClick:k,children:["📁 ",i.cwd]})]})}function es(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(e)}function g0(e){return e<=0?"0":e<1e-4?"<0.0001":e.toFixed(4).replace(/\.?0+$/,"")}function b0({dialog:e}){const t=je(),[n,i]=c.useState(""),[a,o]=c.useState(0),l=E=>{ae({type:"dialog_response",id:e.id,value:E})};c.useEffect(()=>{i(""),o(0);const E=m=>{m.key==="Escape"&&l(null)};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[e.id]);const u=Array.isArray(e.args[0])?e.args[0]:[],p=typeof e.args[0]=="string"?e.args[0]:"";return s.jsxs("div",{className:"dialog-inline","data-dialog-kind":e.kind,children:[s.jsxs("div",{className:"dialog-head",children:[s.jsx("span",{className:"dialog-badge",children:t("pluginRequest")}),e.title&&e.title!==t("pluginRequest")&&s.jsx("span",{className:"dialog-title",children:e.title}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:t("cancel"),onClick:()=>l(null),children:"✕"})]}),e.kind==="select"&&s.jsxs("div",{className:"dialog-options",children:[u.map((E,m)=>s.jsx("button",{type:"button",className:`dialog-option ${m===a?"sel":""}`,onMouseEnter:()=>o(m),onClick:()=>l(E),children:s.jsx(rt,{text:E,rawHtml:!0})},m)),u.length===0&&s.jsx("div",{className:"dialog-hint",children:t("noOptions")})]}),e.kind==="confirm"&&s.jsxs("div",{className:"dialog-body",children:[s.jsx(rt,{text:p,rawHtml:!0}),s.jsxs("div",{className:"dialog-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>l(!1),children:t("cancel")}),s.jsx("button",{type:"button",className:"btn primary",onClick:()=>l(!0),children:t("ok")})]})]}),e.kind==="input"&&s.jsxs("div",{className:"dialog-body",children:[s.jsx("input",{className:"dialog-input",value:n,placeholder:p||t("inputPlaceholder"),autoFocus:!0,onChange:E=>i(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.nativeEvent.isComposing&&l(n)}}),s.jsxs("div",{className:"dialog-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>l(null),children:t("cancel")}),s.jsx("button",{type:"button",className:"btn primary",onClick:()=>l(n),children:t("ok")})]})]})]})}function E0({question:e}){const t=je(),[n,i]=c.useState({}),[a,o]=c.useState({}),[l,u]=c.useState(0),[p,E]=c.useState(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);c.useEffect(()=>{i({}),o({}),u(0),E(e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1)},[e.id,e.deadline]),c.useEffect(()=>{if(!e.deadline)return;const I=setInterval(()=>{E(H=>{const te=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return te<=0&&H>0&&ae({type:"question_answer",id:e.id,answers:[],cancelled:!0}),te})},1e3);return()=>clearInterval(I)},[e.id,e.deadline]),c.useEffect(()=>{const I=H=>{H.key==="Escape"&&N()};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[e.id]);const m=e.questions.length,f=e.questions[l];if(!f)return null;const w=I=>{const H=e.questions.map(te=>{const ee=I[te.id]??[],le=(a[te.id]??"").trim();return{id:te.id,selected:ee,...le?{custom:le}:{}}});ae({type:"question_answer",id:e.id,answers:H})},N=()=>{ae({type:"question_answer",id:e.id,answers:[],cancelled:!0})},C=(I,H)=>{i(te=>{const ee=te[I]??[];return{...te,[I]:ee.includes(H)?ee.filter(le=>le!==H):[...ee,H]}})},M=(I,H,te)=>{if(te){C(I,H);return}const ee={...n,[I]:[H]};i(ee),l===m-1?w(ee):u(l+1)},W=()=>{l===m-1?w(n):u(l+1)},_=I=>(e.questions.find(te=>te.id===I)?.options?.length??0)===0?!0:(n[I]?.length??0)>0||(a[I]??"").trim()!=="",D=(f.options??[]).filter(I=>(n[f.id]??[]).includes(I.label)&&I.preview).map(I=>I.preview);return s.jsxs("div",{className:"dialog-inline","data-dialog-kind":"select",children:[s.jsxs("div",{className:"dialog-head",children:[s.jsx("span",{className:"dialog-badge",children:t("modelQuestion")}),m>1&&s.jsx("span",{className:"question-progress",children:t("questionStep",{cur:l+1,total:m})}),p>=0&&s.jsx("span",{className:"question-timer",children:p>0?t("questionTimeout",{s:p}):t("questionTimeoutExpired")}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:t("cancel"),onClick:N,children:"✕"})]}),s.jsxs("div",{className:"set-section",children:[s.jsx("div",{className:"set-section-title",children:f.header??`${t("modelQuestion")} ${l+1}`}),s.jsx("div",{className:"question-head",children:s.jsx(rt,{text:f.question,rawHtml:!0})}),f.detail&&s.jsx("div",{className:"set-hint",children:s.jsx(rt,{text:f.detail,rawHtml:!0})}),(f.options?.length??0)>0&&s.jsx("div",{className:"set-list",children:f.options.map(I=>{const H=(n[f.id]??[]).includes(I.label);return s.jsxs("button",{type:"button",className:`set-row question-option${H?" active":""}`,onClick:()=>M(f.id,I.label,!!f.multiSelect),children:[s.jsxs("div",{className:"set-row-name",children:[s.jsx("span",{className:"question-mark",children:f.multiSelect?H?"☑ ":"☐ ":H?"● ":"○ "}),s.jsx(rt,{text:I.label,rawHtml:!0})]}),I.description&&s.jsx("div",{className:"set-row-desc",children:s.jsx(rt,{text:I.description,rawHtml:!0})})]},I.label)})}),D.length>0&&s.jsxs("div",{className:"question-preview",children:[s.jsx("div",{className:"question-preview-label",children:t("optionPreview")}),D.map((I,H)=>s.jsx("div",{className:"question-preview-body",children:s.jsx(rt,{text:I,rawHtml:!0})},H))]}),s.jsx("input",{className:"set-prompt-input question-custom",placeholder:t("modelQuestionCustom"),value:a[f.id]??"",onChange:I=>o(H=>({...H,[f.id]:I.target.value})),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),_(f.id)&&W())}})]},f.id),s.jsxs("div",{className:"dialog-nav",children:[s.jsx("button",{type:"button",className:"dialog-dismiss-inline",onClick:N,children:t("cancel")}),s.jsxs("div",{className:"dialog-nav-right",children:[s.jsx("button",{type:"button",className:"dialog-prev",disabled:l===0,onClick:()=>u(l-1),children:t("previous")}),s.jsx("button",{type:"button",className:"dialog-submit",disabled:!_(f.id),onClick:W,children:l===m-1?t("modelQuestionSubmit"):t("next")})]})]})]})}const mr=e=>`'${e.replace(/'/g,"'\\''")}'`;function T0(e){if(e.x==="?"&&e.y==="?")return"untracked";const t=e.x!==" "&&e.x!=="?",n=e.y!==" "&&e.y!=="?";return t&&n?"both":t?"staged":"unstaged"}function x0({chat:e,terminal:t,active:n,onSwitchToTerminal:i}){const a=je(),[o,l]=c.useState(null),[u,p]=c.useState([]),[E,m]=c.useState(""),[f,w]=c.useState(new Map),[N,C]=c.useState("changes"),[M,W]=c.useState([]),[_,D]=c.useState(null),[I,H]=c.useState(""),[te,ee]=c.useState(!1),[le,pe]=c.useState(null),[Q,G]=c.useState(null),[ce,O]=c.useState(!1),[B,x]=c.useState(!1),[R,F]=c.useState(!1),[v,se]=c.useState(null),[K,xe]=c.useState(!1),[k,Y]=c.useState(""),re=c.useRef(0),de=c.useRef(-1),we=c.useRef(-1),ie=c.useRef(-1),me=c.useRef(-1),X=c.useRef(void 0),oe=c.useRef(null),$=c.useRef([]),Ie=c.useCallback(A=>{if(A.reqId===de.current){if(de.current=-1,x(!1),se(null),!A.ok){se(A.error??a("scmQueryFailedShort"));return}if(A.notRepo){xe(!0),l(null),p([]),w(new Map),W([]),D(null),H(""),G(null);return}xe(!1);const fe={branch:A.branch??"",detached:!!A.detached,upstream:A.upstream??null,ahead:A.ahead??0,behind:A.behind??0,upstreamGone:!!A.upstreamGone,files:(A.files??[]).map(Me=>({...Me}))},Ae=(A.branches??[]).map(Me=>({...Me})),Fe=new Map;for(const[Me,Ge]of Object.entries(A.stats??{}))Fe.set(Me,{add:Ge[0],del:Ge[1]});l(fe),p(Ae),w(Fe),m(Me=>fe.detached?Me||"":fe.branch&&Ae.some(Ge=>Ge.name===fe.branch)?fe.branch:Me&&Ae.some(Ge=>Ge.name===Me)?Me:Ae[0]?.name??""),G(Me=>Me&&!fe.files.some(Ge=>Ge.path===Me.file.path)?null:Me)}else if(A.reqId===we.current){if(we.current=-1,O(!1),!A.ok){se(A.error??a("scmQueryFailedShort"));return}const fe=oe.current;if(!fe)return;G({file:fe,staged:A.stagedText??"",worktree:A.worktreeText??"",untracked:!1})}else if(A.reqId===me.current){if(me.current=-1,F(!1),!A.ok){se(A.error??a("scmQueryFailedShort"));return}W((A.history??[]).map(fe=>({...fe})))}else if(A.reqId===ie.current){if(ie.current=-1,ee(!1),!A.ok){se(A.error??a("scmQueryFailedShort"));return}H(A.text??"")}},[]);c.useEffect(()=>{const A=e.scmData;A&&A.type==="scm_data"&&Ie(A)},[e.scmData,Ie]);const Le=c.useCallback((A,fe)=>{if(!e.ready||e.status!=="open")return!1;const Ae=++re.current;return ae({...A,reqId:Ae})?(fe.current=Ae,!0):(re.current-=1,!1)},[e.ready,e.status]),P=c.useCallback((A=!1,fe=!1)=>{!e.ready||e.status!=="open"||e.state?.cwd&&(X.current!==void 0&&X.current!==e.state.cwd&&(l(null),p([]),w(new Map),W([]),F(!1),me.current=-1,D(null),H(""),G(null),pe(null)),X.current=e.state.cwd,se(null),Le({type:"scm_status"},de)&&(fe||x(!0)))},[e.ready,e.state?.cwd,e.status,Le]),ye=c.useCallback(A=>{if(pe(A),D(null),oe.current=A,A.x==="?"&&A.y==="?"){G({file:A,staged:"",worktree:"",untracked:!0});return}O(!0),se(null),Le({type:"scm_filediff",path:A.path},we)||O(!1)},[Le]),he=c.useCallback(A=>{D(A),pe(null),G(null),H(""),ee(!0),se(null),Le({type:"scm_commit",hash:A.hash},ie)||ee(!1)},[Le]),be=c.useCallback((A,fe)=>{if(!e.ready)return;const Ae={name:A,command:fe,cwd:"${pwd}"};let Fe;const Me=e.terminals.find(Ge=>Ge.title===A);Me?(t.restart(Me.id),ae({type:"run_command",terminalId:Me.id,conversationId:Me.conversationId,command:Ae,cols:80,rows:24}),Fe=Me.id):(Fe=St(),t.create({id:Fe,conversationId:e.activeConversationId||e.state?.conversationId||"",title:A,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Ae})),t.select(Fe),i()},[e.ready,e.state?.cwd,e.terminals,i,t]),Te=c.useCallback(()=>{const A=k.trim();if(!A||K)return;const fe=A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");be("git commit",`git commit -m "${fe}"`),Y("")},[k,K,be]),Ce=c.useCallback(()=>{const A=k.trim();if(!A||K)return;const fe=A.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");be("git commit",`git add -A && git commit -m "${fe}"`),Y("")},[k,K,be]),ke=c.useCallback(A=>{K||be("git add",`git add -- ${mr(A.path)}`)},[K,be]),y=c.useCallback(A=>{K||be("git reset",`git reset HEAD -- ${mr(A.path)}`)},[K,be]),b=c.useCallback(()=>{if(!E||K)return;const A=u.find(fe=>fe.name===E);if(A?.remote&&typeof A.remote=="string"){const fe=E.slice(A.remote.length+1);be("git checkout",`git checkout -b ${fe} ${E} || git checkout ${E}`)}else be("git checkout",`git checkout ${E}`)},[E,u,K,be]),S=c.useCallback(()=>be("git push","git push"),[be]),z=c.useCallback(()=>be("git pull","git pull"),[be]),ue=c.useCallback(()=>{Le({type:"scm_history"},me)||(me.current=-1)},[Le]);c.useEffect(()=>{n&&P()},[n,P]),c.useEffect(()=>{N==="history"&&o&&ue()},[N,o,ue]),c.useEffect(()=>{e.scmDirty>0&&n&&P(!1,!0)},[e.scmDirty]),c.useEffect(()=>{if(!n||!e.ready||e.status!=="open")return;const A=setInterval(()=>{document.visibilityState!=="hidden"&&P(!1,!0)},3e4);return()=>clearInterval(A)},[n,e.ready,e.status,P]),c.useEffect(()=>{const A=$.current;if($.current=e.terminals,!n)return;e.terminals.some(Ae=>Ae.running!==!1?!1:A.find(Me=>Me.id===Ae.id)?.running===!0&&Ae.title.startsWith("git "))&&e.ready&&e.status==="open"&&(P(!1,!0),N==="history"&&o&&ue())},[e.terminals,n,e.ready,e.status,P,N,o,ue]);const Ne={staged:a("scmStaged"),unstaged:a("scmUnstaged"),untracked:a("scmUntracked"),both:a("scmStagedUnstaged")},De=A=>{const fe=A.split(`
|
|
329
|
+
`);return s.jsx("pre",{className:"scm-diff-pre",children:fe.map((Ae,Fe)=>{let Me="";return Ae.startsWith("diff --git")||Ae.startsWith("index ")||Ae.startsWith("new file")||Ae.startsWith("deleted file")||Ae.startsWith("old mode")||Ae.startsWith("new mode")||Ae.startsWith("similarity index")||Ae.startsWith("rename ")||Ae.startsWith("copy ")||Ae.startsWith("Binary files")||Ae.startsWith("---")||Ae.startsWith("+++")?Me="hdr":Ae.startsWith("@@")?Me="hunk":Ae.startsWith("+")?Me="add":Ae.startsWith("-")&&(Me="del"),s.jsx("div",{className:`scm-diff-line ${Me}`,children:Ae||" "},Fe)})})};return s.jsxs("div",{className:"scm-view",children:[s.jsxs("div",{className:"scm-header",children:[s.jsxs("div",{className:"scm-title-row",children:[s.jsxs("span",{className:"scm-title",children:[s.jsx(Qs,{}),a("scmTitle")]}),s.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[s.jsx("button",{type:"button",role:"tab","aria-selected":N==="changes",className:N==="changes"?"active":"",onClick:()=>{C("changes"),se(null)},children:a("scmChanges")}),s.jsx("button",{type:"button",role:"tab","aria-selected":N==="history",className:N==="history"?"active":"",onClick:()=>{C("history"),se(null)},children:a("scmHistory")})]}),s.jsx("button",{type:"button",className:"panel-refresh",title:a("scmRefreshTip"),disabled:B,onClick:()=>P(!0),children:s.jsx(kt,{className:B?"scm-spin":""})})]}),s.jsxs("div",{className:"scm-row",children:[s.jsxs("span",{className:"scm-branch-current",title:a("scmCurrentBranch"),children:[s.jsx(Qs,{}),o?o.detached?a("scmDetached"):o.branch:"…",o?.upstream&&s.jsx("span",{className:"scm-upstream",children:o.upstreamGone?a("scmUpstreamGone"):o.ahead>0||o.behind>0?a("scmAheadBehind",{ahead:o.ahead,behind:o.behind}):o.upstream})]}),s.jsxs("select",{className:"scm-select",value:E,disabled:K||u.length===0,title:a("scmSwitchBranch"),onChange:A=>m(A.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:a("scmSelectBranch")}),u.filter(A=>!A.remote).map(A=>s.jsx("option",{value:A.name,children:A.current?`* ${A.name}`:A.name},A.name)),u.some(A=>A.remote)&&s.jsx("optgroup",{label:a("scmRemoteBranches"),children:u.filter(A=>A.remote).map(A=>s.jsx("option",{value:A.name,children:A.name},A.name))})]}),s.jsxs("button",{type:"button",className:"btn",disabled:!E||E===o?.branch||K,title:a("scmSwitchBranchTip",{branch:E}),onClick:b,children:[s.jsx(Qs,{}),a("scmSwitch")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!o||o.detached||K,title:a("scmPushTip"),onClick:S,children:[s.jsx(ca,{}),a("scmPush")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!o||o.detached||K,title:a("scmPullTip"),onClick:z,children:[s.jsx(Mr,{}),a("scmPull")]}),s.jsx("input",{className:"scm-commit-input",value:k,placeholder:a("scmCommitPlaceholder"),disabled:K,onChange:A=>Y(A.target.value),onKeyDown:A=>{A.key==="Enter"&&!A.nativeEvent.isComposing&&Te()}}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!k.trim()||K,title:a("scmCommitTip"),onClick:Te,children:[s.jsx(Tt,{}),a("scmCommit")]}),s.jsx("button",{type:"button",className:"btn",disabled:!k.trim()||K,title:a("scmCommitAllTip"),onClick:Ce,children:a("scmCommitAll")})]})]}),s.jsxs("div",{className:"scm-body",children:[N==="history"?s.jsxs("div",{className:"scm-history",children:[s.jsxs("div",{className:"scm-files-header",children:[s.jsx("span",{children:a("scmHistory")}),M.length>0&&s.jsx("span",{className:"scm-files-count",children:M.length})]}),s.jsx("div",{className:"scm-history-list",children:K?s.jsx("div",{className:"scm-empty",children:a("scmNotGitRepo")}):!o||R?s.jsx("div",{className:"scm-empty",children:e.status==="open"?a("scmLoading"):a("scmConnecting")}):M.length===0?s.jsx("div",{className:"scm-empty",children:a("scmNoHistory")}):M.map(A=>s.jsxs("button",{type:"button",className:`scm-commit ${_?.hash===A.hash?"active":""}`,onClick:()=>he(A),title:A.hash,children:[s.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:A.graph||"* "}),s.jsxs("span",{className:"scm-commit-info",children:[s.jsx("span",{className:"scm-commit-subject",children:A.subject}),s.jsxs("span",{className:"scm-commit-meta",children:[A.shortHash," · ",A.author," · ",A.date]}),A.decorations&&s.jsx("span",{className:"scm-commit-refs",children:A.decorations})]})]},A.hash))})]}):s.jsxs("div",{className:"scm-files",children:[s.jsxs("div",{className:"scm-files-header",children:[s.jsx("span",{children:a("scmChanges")}),o&&o.files.length>0&&s.jsx("span",{className:"scm-files-count",children:o.files.length})]}),s.jsx("div",{className:"scm-files-list",children:K?s.jsx("div",{className:"scm-empty",children:a("scmNotGitRepo")}):o?o.files.length===0?s.jsx("div",{className:"scm-empty",children:a("scmNoChanges")}):o.files.map(A=>{const fe=T0(A),Ae=f.get(A.path);return s.jsxs("div",{className:`scm-file ${le?.path===A.path?"active":""}`,title:Ne[fe],onClick:()=>ye(A),children:[s.jsx("span",{className:`scm-file-xy ${fe==="untracked"?"q":"x"}`,children:A.x!==" "?A.x:" "}),s.jsx("span",{className:`scm-file-xy ${fe==="untracked"?"q":"y"}`,children:A.y!==" "?A.y:" "}),s.jsx("span",{className:"scm-file-path",children:A.path}),Ae&&(Ae.add>0||Ae.del>0)&&s.jsxs("span",{className:"scm-file-stat",children:[Ae.add>0&&s.jsxs("span",{className:"add",children:["+",Ae.add]}),Ae.del>0&&s.jsxs("span",{className:"del",children:["-",Ae.del]})]}),s.jsxs("span",{className:"scm-file-actions",children:[(A.y!==" "||fe==="untracked")&&s.jsx("button",{type:"button",className:"scm-act",title:a("scmStageTip",{path:A.path}),onClick:Fe=>{Fe.stopPropagation(),ke(A)},children:"+"}),fe==="staged"||fe==="both"?s.jsx("button",{type:"button",className:"scm-act",title:a("scmUnstageTip",{path:A.path}),onClick:Fe=>{Fe.stopPropagation(),y(A)},children:"−"}):null]})]},A.path)}):s.jsx("div",{className:"scm-empty",children:e.status==="open"?a("scmLoading"):a("scmConnecting")})})]}),s.jsxs("div",{className:"scm-diff",children:[s.jsxs("div",{className:"scm-diff-header",children:[s.jsx("span",{children:N==="history"?_?`${_.shortHash} ${_.subject}`:a("scmCommitDetail"):le?le.path:a("scmDiff")}),(N==="history"?te:ce)&&s.jsx("span",{className:"scm-diff-loading",children:a("scmLoading")})]}),s.jsx("div",{className:"scm-diff-body",children:N==="history"?s.jsxs(s.Fragment,{children:[v&&s.jsx("div",{className:"scm-error",children:v}),!_&&!v&&s.jsx("div",{className:"scm-empty",children:a("scmSelectCommitHint")}),_&&te&&!v&&s.jsx("div",{className:"scm-empty",children:a("scmLoading")}),_&&!te&&!v&&I?De(I):null]}):s.jsxs(s.Fragment,{children:[v&&s.jsx("div",{className:"scm-error",children:v}),!le&&!v&&s.jsx("div",{className:"scm-empty",children:a("scmSelectFileHint")}),le&&!Q&&!v&&s.jsx("div",{className:"scm-empty",children:a("scmLoading")}),le&&Q&&Q.untracked&&s.jsx("div",{className:"scm-empty",children:a("scmUntrackedNote")}),le&&Q&&!Q.untracked&&s.jsxs(s.Fragment,{children:[Q.staged&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:a("scmStaged")}),De(Q.staged)]}),Q.worktree&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:a("scmUnstaged")}),De(Q.worktree)]}),!Q.staged&&!Q.worktree&&s.jsx("div",{className:"scm-empty",children:a("scmNoDiff")})]})]})})]})]}),s.jsxs("div",{className:"scm-hint",children:[s.jsx(Ln,{}),s.jsx("span",{children:a("scmRunsInTerminal")}),s.jsx("button",{type:"button",className:"scm-goto-term",onClick:i,children:a("scmViewTerminal")})]})]})}function y0({entry:e}){const t=c.useRef(null),n=je();return c.useEffect(()=>{const i=t.current;if(!i)return;let a;try{a=e.module.mount(i,Hu(e.info.id,o=>ae(o)))}catch(o){console.error(`[plugin:${e.info.id}] mount failed:`,o),i.textContent=n("pluginMountFailed",{name:e.info.name})}return()=>{if(typeof a=="function")try{a()}catch(o){console.error(`[plugin:${e.info.id}] cleanup failed:`,o)}i.textContent=""}},[e]),s.jsx("div",{className:"plugin-view",ref:t})}const hr="__piWebUiHost",N0=3,dl=e=>new Promise(t=>setTimeout(t,e));async function k0(e=3e3){const t=Date.now()+e;for(;;){const n=window.__piBridge;if(n&&typeof n.call=="function")return n;if(Date.now()>=t)return null;await dl(100)}}function v0(e){const t=Math.max(1,Number(e.pollMs??100)),n=Math.max(t,Number(e.timeoutMs??8e3)),i=async o=>{const l=Date.now()+n;for(;;){if(o())return!0;if(Date.now()>=l)return o();await dl(t)}},a=async(o,l)=>{const u=String(l.cwd??"").trim();if(u&&e.getCwd()!==u&&(e.send({type:"set_cwd",path:u}),await i(()=>e.getCwd()===u)),l.newChat!==!1){const p=e.getConversationId();e.send({type:"new_chat"}),await i(()=>e.getConversationId()!==p||e.isConversationBlank())}e.send({type:"prompt",text:o})};return{version:N0,setView(o){const l=String(o??"").trim();l&&e.setView(l)},startChat(o){const l=String(o?.prompt??"").trim();return!l||!e.isReady()?!1:(a(l,o??{}).catch(()=>{}),!0)},compose(o){return iu()?Wr({text:typeof o?.text=="string"?o.text:void 0,attachments:Array.isArray(o?.attachments)?o.attachments:void 0}):!1},async pageCall(o){const l=String(o?.op??"").trim();if(!l)return{ok:!1,error:"pageCall 需要一个动作名(op)"};const u=await k0(e.bridgeWaitMs??3e3);if(!u)return{ok:!1,error:"浏览器扩展的页面桥没就绪:确认已安装并启用 page-picker 扩展、本页地址已绑定,然后刷新本页"};try{const p=await u.call({op:l,...o.args===void 0?{}:{args:o.args},...o.target?{to:o.target}:{},...o.timeoutMs?{timeoutMs:o.timeoutMs}:{}});return p===void 0?{ok:!0}:{ok:!0,result:p}}catch(p){return{ok:!1,error:p instanceof Error?p.message:String(p)}}}}}function fr(e){try{const t=window;e?t[hr]=e:delete t[hr]}catch{}}function C0({piConfigured:e,piAgentInstalled:t,providers:n,installResult:i,onClose:a}){const o=je(),l=Xr(),[u,p]=c.useState(!1),[E,m]=c.useState(""),[f,w]=c.useState(""),[N,C]=c.useState(!1);c.useEffect(()=>{ae({type:"list_providers"})},[]),c.useEffect(()=>{e&&a()},[e,a]),c.useEffect(()=>{i&&p(!1)},[i]),c.useEffect(()=>{!E&&n.length>0&&m(n.find(H=>!H.configured)?.id??n[0].id)},[n,E]);const M=()=>{u||(p(!0),ae({type:"install_pi_agent"}))},W=()=>{!f.trim()||N||(C(!0),ae({type:"set_provider_api_key",provider:E.trim(),apiKey:f.trim()}),setTimeout(()=>C(!1),3e3))},_=()=>{ae({type:"get_state"}),ae({type:"list_providers"})},D=n.find(H=>H.id===E),I=i!==null&&!i.ok;return s.jsx("div",{className:"modal-backdrop",children:s.jsxs("div",{className:"modal setup-modal",children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":o("close"),onClick:a,children:s.jsx(Ke,{})}),s.jsxs("div",{className:"modal-head",children:[s.jsx(Ds,{className:"modal-head-icon"}),s.jsx("h2",{children:o("setupTitle")})]}),s.jsx("p",{className:"modal-desc",children:o("setupDesc")}),I?s.jsxs("div",{className:"setup-failed",children:[s.jsx("div",{className:"setup-done",children:o("installFailed")}),s.jsx("pre",{className:"setup-detail",children:i.detail}),s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:u,onClick:M,children:o("retryInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:a,children:o("skip")})]})]}):t||i?.ok?s.jsxs("div",{className:"setup-key-form",children:[s.jsx("div",{className:"setup-done",children:i?.ok?o("installDone"):o("cliReadyHint")}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:o("provider")}),s.jsxs("select",{value:E,onChange:H=>m(H.target.value),children:[n.length===0&&s.jsx("option",{value:"",children:o("loading")}),n.map(H=>s.jsxs("option",{value:H.id,children:[H.name,"(",H.id,")",H.configured?` · ${o("configured")}`:""]},H.id))]}),D?.configured&&s.jsx("div",{className:"field-hint",children:o("providerKeyReady")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:o("apiKey")}),s.jsx("input",{type:"password",value:f,onChange:H=>w(H.target.value),placeholder:"sk-…"})]}),s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:!f.trim()||N||!E,onClick:W,children:o(N?"saving":"saveAndStart")}),s.jsxs("button",{type:"button",className:"btn",onClick:_,children:[s.jsx(kt,{})," ",o("recheck")]})]})]}):l?s.jsxs("div",{className:"setup-actions",children:[s.jsx("div",{className:"setup-done",children:o("updatesManaged")}),s.jsx("button",{type:"button",className:"btn",onClick:a,children:o("skip")})]}):s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:u,onClick:M,children:o(u?"installing":"autoInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:a,children:o("skip")})]})]})})}const _0=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],Wa=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),w0=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[Wa()]});function sa(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:[Wa()]).map(t=>({id:t.id,name:t.name??"",reasoning:t.reasoning??!1,input:t.input?.includes("image")?"text-image":"text",contextWindow:t.contextWindow?String(t.contextWindow):"",maxTokens:t.maxTokens?String(t.maxTokens):""}))}}function S0({providers:e,providerStatus:t,providerKeys:n,fetchModelsResult:i,cloneProviderResult:a,onClose:o}){const l=je(),[u,p]=c.useState(null),[E,m]=c.useState({}),[f,w]=c.useState({}),[N,C]=c.useState(null),[M,W]=c.useState(!1),[_,D]=c.useState(0),[I,H]=c.useState(null),te=c.useRef(0),[ee,le]=c.useState(null),[pe,Q]=c.useState(""),[G,ce]=c.useState(null);c.useEffect(()=>{ae({type:"list_models_config"}),ae({type:"list_providers"}),ae({type:"list_provider_keys"})},[]);const O=()=>{if(!u)return;const k=u.baseUrl.trim();if(!k){H({ok:!1,text:l("fetchModelsNeedBaseUrl")});return}if(M)return;W(!0),H(null);const Y=_+1;D(Y),ae({type:"fetch_models",reqId:Y,baseUrl:k,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader,api:u.api})};c.useEffect(()=>{if(!(!i||i.reqId===te.current))if(te.current=i.reqId,W(!1),i.ok&&i.models?.length){const k=i.models;p(Y=>{if(!Y)return Y;const re=Y.models.map(me=>{if(!me.id.trim())return me;const X=k.find($=>$.id===me.id.trim());if(!X)return me;const oe={...me};return!oe.name&&X.name&&(oe.name=X.name),!oe.contextWindow&&X.contextWindow&&(oe.contextWindow=String(X.contextWindow)),!oe.maxTokens&&X.maxTokens&&(oe.maxTokens=String(X.maxTokens)),oe.input==="text"&&X.input?.includes("image")&&(oe.input="text-image"),!oe.reasoning&&X.reasoning&&(oe.reasoning=!0),oe}),de=new Set(re.map(me=>me.id.trim()).filter(Boolean)),we=k.filter(me=>!de.has(me.id)).map(me=>({id:me.id,name:me.name??"",reasoning:me.reasoning??!1,input:me.input?.includes("image")?"text-image":"text",contextWindow:me.contextWindow?String(me.contextWindow):"",maxTokens:me.maxTokens?String(me.maxTokens):""})),ie=[...re,...we];return ie.some(me=>me.id.trim())?{...Y,models:ie.filter(me=>me.id.trim())}:Y}),H({ok:!0,text:l("fetchModelsOk",{n:k.length})})}else H({ok:!1,text:i.error||l("fetchModelsEmpty")})},[i]);const B=k=>{const Y=(E[k.id]??"").trim();!Y||N||(C(k.id),ae({type:"add_provider_key",provider:k.id,apiKey:Y,name:(f[k.id]??"").trim()||void 0}),setTimeout(()=>{C(null),m(re=>({...re,[k.id]:""})),w(re=>({...re,[k.id]:""})),ae({type:"list_providers"}),ae({type:"list_provider_keys"})},1500))},x=(k,Y)=>{ae({type:"activate_provider_key",provider:k,keyName:Y}),ae({type:"list_provider_keys"})},R=(k,Y)=>{window.confirm(l("removeKeyConfirm"))&&(ae({type:"remove_provider_key",provider:k,keyName:Y}),ae({type:"list_provider_keys"}))},F=()=>{if(!G)return;const k=G.providerId.trim();if(!k||!G.apiKey.trim())return;const Y=G.models.filter(de=>de.id.trim()).map(de=>({id:de.id.trim(),name:de.name.trim()||void 0,reasoning:de.reasoning||void 0,input:de.input==="text-image"?["text","image"]:void 0,contextWindow:de.contextWindow?Number(de.contextWindow):void 0,maxTokens:de.maxTokens?Number(de.maxTokens):void 0})),re={providerId:k,name:G.name.trim()||void 0,api:G.api.trim()||void 0,baseUrl:G.baseUrl.trim()||void 0,apiKey:G.apiKey.trim()||void 0,authHeader:G.authHeader||void 0,models:Y};ae({type:"save_model_config",providerId:k,config:re}),ce(null),o()},v=()=>{if(!u)return;const k=u.providerId.trim(),Y=u.models.filter(de=>de.id.trim()).map(de=>({id:de.id.trim(),name:de.name.trim()||void 0,reasoning:de.reasoning||void 0,input:de.input==="text-image"?["text","image"]:void 0,contextWindow:de.contextWindow?Number(de.contextWindow):void 0,maxTokens:de.maxTokens?Number(de.maxTokens):void 0})),re={providerId:k,name:u.name.trim()||void 0,api:u.api.trim()||void 0,baseUrl:u.baseUrl.trim()||void 0,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader||void 0,models:Y};ae({type:"save_model_config",providerId:k,config:re}),o()};c.useEffect(()=>{if(a&&a.ok){const k=a.configs;if(k&&k.length>1){le(k.map(Y=>sa({...Y,apiKey:""}))),Q("");return}if(a.config){ce(sa({...a.config,apiKey:""}));return}}},[a]);const se=k=>{window.confirm(l("clearKeyConfirm",{id:k}))&&ae({type:"clear_provider_api_key",provider:k})},K=k=>{window.confirm(l("deleteProviderConfirm",{id:k.providerId,n:k.models.length}))&&ae({type:"delete_model_config",providerId:k.providerId})},xe=(k,Y)=>{u&&p({...u,models:u.models.map((re,de)=>de===k?{...re,...Y}:re)})};return s.jsx("div",{className:"modal-backdrop",onClick:o,children:s.jsxs("div",{className:"modal model-modal",onClick:k=>k.stopPropagation(),children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":l("close"),onClick:o,children:s.jsx(Ke,{})}),s.jsx("div",{className:"modal-head",children:s.jsx("h2",{children:G?l("addKey"):ee?l("batchCreateProviders",{n:ee.length}):l(u?"editProvider":"manageModelsTitle")})}),G?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-body",children:s.jsxs("div",{className:"provider-form",children:[s.jsx("p",{className:"modal-desc",style:{marginBottom:12},children:l("secondKeyTitle",{api:G.api,baseUrl:G.baseUrl||l("noBaseUrlShort"),n:G.models.length})}),s.jsxs("div",{className:"form-grid",children:[s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:[l("providerNameLabel")," ",s.jsx("em",{children:l("providerNameHint")})]}),s.jsx("input",{type:"text",value:G.providerId,onChange:k=>ce({...G,providerId:k.target.value}),placeholder:"opencode-2"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:l("apiKeyLabel")}),s.jsx("input",{type:"password",value:G.apiKey,onChange:k=>ce({...G,apiKey:k.target.value}),placeholder:l("secondKeyPlaceholder")})]})]}),s.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:8},children:[G.models.slice(0,5).map(k=>k.id).join(", "),G.models.length>5?` … +${G.models.length-5}`:""]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>ce(null),children:l("cancel")}),s.jsx("button",{type:"button",className:"btn",onClick:()=>{const k=G;ce(null),p(k)},children:l("advancedEdit")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!G.providerId.trim()||!G.apiKey.trim(),onClick:F,children:l("save")})]})]}):ee?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-body",children:s.jsxs("div",{className:"provider-form",children:[s.jsx("p",{className:"modal-desc",style:{marginBottom:12},children:l("batchDesc",{apis:ee.map(k=>k.api).join("、"),n:ee.length})}),s.jsxs("label",{className:"field",style:{marginBottom:16},children:[s.jsx("span",{className:"field-label",children:l("batchKeyLabel",{n:ee.length})}),s.jsx("input",{type:"password",value:pe,onChange:k=>Q(k.target.value),placeholder:l("secondKeyPlaceholder")})]}),s.jsx("div",{className:"provider-list",style:{marginBottom:16},children:ee.map((k,Y)=>s.jsxs("div",{className:"provider-row",style:{flexDirection:"column",alignItems:"stretch",gap:6},children:[s.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:13},children:[s.jsx("strong",{children:k.providerId}),s.jsx("span",{style:{opacity:.7},children:k.api})]}),s.jsxs("div",{className:"provider-sub",style:{fontSize:12,opacity:.7},children:[k.baseUrl||l("noBaseUrlShort")," · ",l("modelsCountShort",{n:k.models.length}),k.models.slice(0,3).map(re=>re.id).join(", "),k.models.length>3?` … +${k.models.length-3}`:""]}),s.jsx("input",{type:"text",value:k.providerId,onChange:re=>le(de=>de.map((we,ie)=>ie===Y?{...we,providerId:re.target.value}:we)),placeholder:l("providerIdPlaceholder"),style:{fontSize:12}}),s.jsx("input",{type:"text",value:k.baseUrl,onChange:re=>le(de=>de.map((we,ie)=>ie===Y?{...we,baseUrl:re.target.value}:we)),placeholder:l("baseUrlExamplePh"),style:{fontSize:12}})]},Y))})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>le(null),children:l("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!pe.trim(),onClick:()=>{for(const k of ee){const Y=k.providerId.trim();if(!Y)continue;const re=k.models.filter(we=>we.id.trim()).map(we=>({id:we.id.trim(),name:we.name.trim()||void 0,reasoning:we.reasoning||void 0,input:we.input==="text-image"?["text","image"]:void 0,contextWindow:we.contextWindow?Number(we.contextWindow):void 0,maxTokens:we.maxTokens?Number(we.maxTokens):void 0})),de={providerId:Y,name:k.name.trim()||void 0,api:k.api.trim()||void 0,baseUrl:k.baseUrl.trim()||void 0,apiKey:pe.trim()||void 0,authHeader:k.authHeader||void 0,models:re};ae({type:"save_model_config",providerId:Y,config:de})}le(null),o()},children:l("saveAllBatch",{n:ee.length})})]})]}):u?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-body",children:s.jsxs("div",{className:"provider-form",children:[s.jsxs("div",{className:"form-grid",children:[s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:[l("providerId")," ",s.jsx("em",{children:l("providerIdHint")})]}),s.jsx("input",{type:"text",value:u.providerId,disabled:e.some(k=>k.providerId===u.providerId),onChange:k=>p({...u,providerId:k.target.value}),placeholder:"my-proxy"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:l("displayName")}),s.jsx("input",{type:"text",value:u.name,onChange:k=>p({...u,name:k.target.value}),placeholder:l("displayNamePh")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:l("apiType")}),s.jsx("select",{value:u.api,onChange:k=>p({...u,api:k.target.value}),children:_0.map(k=>s.jsx("option",{value:k,children:k},k))})]}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:["baseUrl ",s.jsx("em",{children:l("baseUrlHint")})]}),s.jsx("input",{type:"text",value:u.baseUrl,onChange:k=>p({...u,baseUrl:k.target.value}),placeholder:"http://localhost:11434/v1"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:l("apiKey")}),s.jsx("input",{type:"password",value:u.apiKey,onChange:k=>p({...u,apiKey:k.target.value}),placeholder:l("apiKeyHint")})]}),s.jsxs("label",{className:"field check",children:[s.jsx("input",{type:"checkbox",checked:u.authHeader,onChange:k=>p({...u,authHeader:k.target.checked})}),s.jsx("span",{children:l("authHeader")})]})]}),s.jsxs("div",{className:"model-section-head",children:[s.jsx("span",{className:"form-section-title",children:l("modelsTitle")}),s.jsxs("span",{className:"model-section-actions",children:[I&&s.jsx("span",{className:`fetch-msg ${I.ok?"ok":"err"}`,title:I.text,children:I.text}),s.jsxs("button",{type:"button",className:"btn sm",disabled:M||!u.baseUrl.trim(),title:l("fetchModelsHint"),onClick:O,children:[s.jsx(Yt,{})," ",l(M?"fetchingModels":"fetchModels")]})]})]}),u.models.map((k,Y)=>s.jsxs("div",{className:"model-row",children:[s.jsx("input",{type:"text",value:k.id,onChange:re=>xe(Y,{id:re.target.value}),placeholder:l("modelIdReq")}),s.jsx("input",{type:"text",value:k.name,onChange:re=>xe(Y,{name:re.target.value}),placeholder:l("displayName")}),s.jsxs("select",{value:k.input,onChange:re=>xe(Y,{input:re.target.value}),children:[s.jsx("option",{value:"text",children:l("text")}),s.jsx("option",{value:"text-image",children:l("textImage")})]}),s.jsxs("label",{className:"check",children:[s.jsx("input",{type:"checkbox",checked:k.reasoning,onChange:re=>xe(Y,{reasoning:re.target.checked})}),s.jsx("span",{children:l("reasoning")})]}),s.jsx("input",{type:"number",value:k.contextWindow,onChange:re=>xe(Y,{contextWindow:re.target.value}),placeholder:l("contextWindow"),title:"contextWindow"}),s.jsx("input",{type:"number",value:k.maxTokens,onChange:re=>xe(Y,{maxTokens:re.target.value}),placeholder:l("maxOutput"),title:"maxTokens"}),s.jsx("button",{type:"button",className:"iconbtn danger",title:l("removeModel"),onClick:()=>p({...u,models:u.models.filter((re,de)=>de!==Y)}),children:s.jsx(et,{})})]},Y)),s.jsxs("button",{type:"button",className:"btn",onClick:()=>p({...u,models:[...u.models,Wa()]}),children:[s.jsx(dt,{})," ",l("addModel")]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>p(null),children:l("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!u.providerId.trim()||!u.models.some(k=>k.id.trim()),onClick:v,children:l("save")})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-fixed-hint",children:s.jsxs("div",{className:"form-section-title",children:[l("builtinProviders")," ",s.jsx("em",{className:"section-hint",children:l("hintKeyOnly")})]})}),s.jsxs("div",{className:"model-modal-body",children:[s.jsxs("div",{className:"provider-list",children:[t.length===0&&s.jsx("div",{className:"dd-loading",children:l("loading")}),t.map(k=>{const Y=n[k.id]??[];return s.jsxs("div",{className:"provider-row provider-key-row",children:[s.jsxs("div",{className:"provider-key-head",children:[s.jsxs("div",{className:"provider-info",children:[s.jsx("span",{className:"provider-name",children:k.name}),s.jsxs("span",{className:"provider-sub",children:[k.id,k.configured&&s.jsx("span",{className:"auth-badge",children:l("configuredBadge")}),k.source&&!k.configured&&s.jsx("span",{className:"auth-badge dim",children:k.source})]})]}),k.source==="stored"&&s.jsxs("button",{type:"button",className:"btn sm danger",title:l("clearKeyTitle"),onClick:()=>se(k.id),children:[s.jsx(et,{})," ",l("clearKey")]})]}),s.jsxs("div",{className:"provider-keys",children:[Y.length===0&&s.jsx("div",{className:"provider-key-empty",children:l("noKeyYet")}),Y.map(re=>s.jsxs("div",{className:`provider-key-item ${re.active?"active":""}`,children:[s.jsx("span",{className:"provider-key-dot",children:re.active?"●":"○"}),s.jsx("span",{className:"provider-key-label",children:re.name}),!re.active&&s.jsx("button",{type:"button",className:"iconbtn",title:l("activateKey"),onClick:()=>x(k.id,re.name),children:s.jsx(Tt,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:l("removeKey"),onClick:()=>R(k.id,re.name),children:s.jsx(et,{})})]},re.name)),s.jsxs("div",{className:"provider-add-key",children:[s.jsx("input",{type:"text",className:"key-input key-input-name",placeholder:l("keyNamePh"),value:f[k.id]??"",onChange:re=>w(de=>({...de,[k.id]:re.target.value}))}),s.jsx("input",{type:"password",className:"key-input key-input-value",placeholder:l("addKeyPlaceholder"),value:E[k.id]??"",onChange:re=>m(de=>({...de,[k.id]:re.target.value}))}),s.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(E[k.id]??"").trim()||N===k.id,onClick:()=>B(k),children:[s.jsx(dt,{})," ",N===k.id?l("savingKey"):l("addKey")]})]})]})]},k.id)})]}),s.jsx("div",{className:"form-section-title",children:l("customProviders")}),s.jsx("p",{className:"modal-desc",children:l("customDesc")}),s.jsx("p",{className:"modal-desc",children:l("reloadModelsHint")}),e.length===0&&s.jsx("div",{className:"dd-loading",children:l("noCustomProviders")}),s.jsx("div",{className:"provider-list",children:e.map(k=>s.jsxs("div",{className:"provider-row",children:[s.jsxs("div",{className:"provider-info",children:[s.jsx("span",{className:"provider-name",children:k.providerId}),s.jsxs("span",{className:"provider-sub",children:[k.api??"—",k.baseUrl?` · ${k.baseUrl}`:"",k.models.length>0&&` · ${l("modelsCount",{n:k.models.length})}`]})]}),s.jsxs("div",{className:"provider-actions",children:[s.jsx("button",{type:"button",className:"iconbtn",title:l("edit"),onClick:()=>p(sa(k)),children:s.jsx(gn,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:l("delete"),onClick:()=>K(k),children:s.jsx(et,{})})]})]},k.providerId))})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsxs("button",{type:"button",className:"btn",onClick:()=>ae({type:"reload_models_config"}),children:[s.jsx(kt,{})," ",l("reloadModelsConfig")]}),s.jsxs("button",{type:"button",className:"btn primary",onClick:()=>p(w0()),children:[s.jsx(dt,{})," ",l("addProvider")]})]})]})]})})}function Ve({text:e}){const t=c.useRef(null),n=c.useRef(null),[i,a]=c.useState(!1),[o,l]=c.useState({left:0,top:0}),u=()=>{const E=t.current?.getBoundingClientRect();E&&(l({left:Math.max(8,E.left-8),top:E.bottom+8}),a(!0))},p=()=>a(!1);return c.useEffect(()=>{if(!i)return;const E=n.current,m=t.current;if(!E||!m)return;const f=E.getBoundingClientRect(),w=m.getBoundingClientRect();let N=w.left-8,C=w.bottom+8;N+f.width>window.innerWidth-8&&(N=Math.max(8,w.right+8-f.width)),C+f.height>window.innerHeight-8&&(C=Math.max(8,w.top-8-f.height)),l(M=>M.left===N&&M.top===C?M:{left:N,top:C})},[i,e]),c.useEffect(()=>{if(!i)return;const E=()=>a(!1);return window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[i]),s.jsxs("span",{ref:t,className:"set-tip",tabIndex:0,"aria-label":e,onMouseEnter:u,onMouseLeave:p,onFocus:u,onBlur:p,onKeyDown:E=>{E.key==="Escape"&&E.target.blur()},children:["?",i&&ao.createPortal(s.jsx("span",{ref:n,className:"set-tip-bubble open",role:"tooltip",style:{position:"fixed",left:o.left,top:o.top},children:e}),document.body)]})}function A0({plugin:e}){const t=je(),n=e.settingsSchema??[],[i,a]=c.useState(()=>({...e.settingsValues})),[o,l]=c.useState(!1);if(n.length===0)return null;const u=(f,w)=>a(N=>({...N,[f]:w})),p=n.some(f=>i[f.key]!==e.settingsValues?.[f.key]),E=()=>{l(!0),ae({type:"plugin_settings",pluginId:e.id,values:i}),setTimeout(()=>l(!1),800)},m=()=>a({...e.settingsValues});return s.jsxs("div",{className:"plugin-settings-form",children:[s.jsx("div",{className:"plugin-settings-fields",children:n.map(f=>s.jsxs("label",{className:"plugin-settings-field",title:f.hint,children:[s.jsx("span",{className:"plugin-settings-label",children:f.label}),f.type==="boolean"?s.jsx("input",{type:"checkbox",checked:!!i[f.key],onChange:w=>u(f.key,w.target.checked)}):f.type==="select"?s.jsx("select",{value:String(i[f.key]??""),onChange:w=>u(f.key,w.target.value),children:(f.options??[]).map(w=>s.jsx("option",{value:w,children:w},w))}):s.jsx("input",{type:f.type==="password"?"password":f.type==="number"?"number":"text",value:String(i[f.key]??""),min:f.min,max:f.max,onChange:w=>u(f.key,f.type==="number"?Number(w.target.value):w.target.value)})]},f.key))}),s.jsxs("div",{className:"plugin-settings-actions",children:[s.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!p||o,onClick:E,children:t(o?"pluginSettingsSaving":"pluginSettingsSave")}),s.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:m,children:t("pluginSettingsReset")})]})]})}const pl="pi-web-ui:wide-chat",Sn={wide:!1};function ml(e){if(!e||typeof e!="object")return{...Sn};const t=e;return{wide:typeof t.wide=="boolean"?t.wide:Sn.wide}}function I0(){try{const e=localStorage.getItem(pl);return e?ml(JSON.parse(e)):{...Sn}}catch{return{...Sn}}}function j0(e){const t=ml(e);try{localStorage.setItem(pl,JSON.stringify(t))}catch{}Zs=t;for(const n of wa)n()}let Zs=null;const wa=new Set;function L0(e){return wa.add(e),()=>{wa.delete(e)}}function R0(){return Zs||(Zs=I0()),Zs.wide}function hl(){return c.useSyncExternalStore(L0,R0)}const fl="pi-web-ui:project-title",An={projectName:!0};function gl(e){if(!e||typeof e!="object")return{...An};const t=e;return{projectName:typeof t.projectName=="boolean"?t.projectName:An.projectName}}function D0(e){return e?e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"":""}function P0(){try{const e=localStorage.getItem(fl);return e?gl(JSON.parse(e)):{...An}}catch{return{...An}}}function O0(e){const t=gl(e);try{localStorage.setItem(fl,JSON.stringify(t))}catch{}en=t;for(const n of Sa)n()}let en=null;const Sa=new Set;function M0(e){return Sa.add(e),()=>{Sa.delete(e)}}function B0(){return en||(en=P0()),en.projectName}function bl(){return c.useSyncExternalStore(M0,B0)}const El="pi-web-ui:wallpaper",F0="has-wallpaper",Ls={url:"",dim:78,blur:0},H0=2e3,U0=28e5;function Aa(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.toLowerCase().startsWith("data:image/")?U0:H0;return t.length>n?"":/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith("/")&&!t.startsWith("//")?t:""}const gr=(e,t,n,i)=>typeof e!="number"||!Number.isFinite(e)?i:Math.min(n,Math.max(t,Math.round(e)));function Tl(e){if(!e||typeof e!="object")return{...Ls};const t=e;return{url:Aa(t.url),dim:gr(t.dim,0,95,Ls.dim),blur:gr(t.blur,0,24,Ls.blur)}}function xl(){try{const e=localStorage.getItem(El);return e?Tl(JSON.parse(e)):{...Ls}}catch{return{...Ls}}}function $0(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/[\r\n]/g,"")}async function q0(e){const t=await $a(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function tn(){const e=Rs??xl(),t=document.documentElement;e.url?(t.style.setProperty("--bg-image",`url("${$0(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"));const n=getComputedStyle(t).getPropertyValue("--bg-image").trim();document.body.classList.toggle(F0,e.url!==""||n!==""&&n!=="none")}function Es(e){const t=Tl(e);Rs=t;try{localStorage.setItem(El,JSON.stringify(t))}catch{}for(const n of Ia)n();tn()}let Rs=null;const Ia=new Set;function W0(e){return Ia.add(e),()=>{Ia.delete(e)}}function K0(){return Rs||(Rs=xl()),Rs}function yl(){return c.useSyncExternalStore(W0,K0)}function Y0(){const e=yl();c.useEffect(()=>{tn()},[e]),c.useEffect(()=>{const t=()=>tn();return window.addEventListener(Mt,t),tn(),()=>window.removeEventListener(Mt,t)},[])}const In={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"]},Nl=["soul","tools","guidelines","pi_docs","append","persona","terminal","markers","context","skills","cwd"],G0=["tools","pi_docs","persona","terminal","markers","context","skills","cwd"];function kl(e){return G0.includes(e)}const Vs=Nl.map(e=>`{{${e}}}`).join(`
|
|
330
|
+
|
|
331
|
+
`),vl=["terminal_create","terminal_list","terminal_close","terminal_input","terminal_key","terminal_read","terminal_wait"],Cl=["subagent_spawn","subagent_get_result","subagent_steer","subagent_list","subagent_stop","subagent_wait_all","subagent_templates"],sn="edit_soft",nn="delegate_task",an="ask_user_question",rn="todo_list",on="browser_page",V0=[...vl.map(e=>({name:e,group:"terminal",defaultOn:!1,dshVisible:!0})),...Cl.map(e=>({name:e,group:"subagent",defaultOn:!0,dshVisible:!1})),{name:sn,group:"other",defaultOn:!1,dshVisible:!1},{name:nn,group:"other",defaultOn:!0,dshVisible:!1},{name:an,group:"other",defaultOn:!0,dshVisible:!0},{name:rn,group:"other",defaultOn:!0,dshVisible:!0},{name:on,group:"other",defaultOn:!0,dshVisible:!1}];new Set(V0.map(e=>e.name));function z0(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function br(e){return e==="append"?0:kl(e)?2:1}function We({title:e,subtitle:t,tip:n,enabled:i,onToggle:a,action:o}){const l=je();return s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsxs("div",{className:"set-row-name",children:[e,n&&s.jsx(Ve,{text:n})]}),t&&s.jsx("div",{className:"set-row-desc",children:t})]}),o,s.jsx("button",{type:"button",className:`set-switch ${i?"on":""}`,role:"switch","aria-checked":i,title:l(i?"settingsEnabled":"settingsDisabled"),onClick:a,children:s.jsx("span",{className:"set-switch-knob"})})]})}function Q0({chat:e,terminal:t,onSwitchToTerminal:n,onClose:i}){const a=je(),{locale:o}=Ht(),l=d=>a(d),u=e.settings,{engine:p,managed:E}=Ra(),m=p==="dsh",[f,w]=c.useState("prompt"),N=c.useRef(null);c.useEffect(()=>{N.current?.scrollTo({top:0})},[f]),c.useEffect(()=>{f==="plugins"&&m&&ae({type:"dsh_patches_list"})},[f,m]);const[C,M]=c.useState(""),[W,_]=c.useState({}),D=c.useRef(!1),I=c.useRef(null),H=[...Nl].sort((d,J)=>br(d)-br(J)),[te,ee]=c.useState(null),[le,pe]=c.useState({}),[Q,G]=c.useState(""),[ce,O]=c.useState("append"),B=c.useRef(!1),[x,R]=c.useState(""),F=c.useRef(!1),[v,se]=c.useState(""),[K,xe]=c.useState(null),[k,Y]=c.useState(null),[re,de]=c.useState(!1),[we,ie]=c.useState(!1),me=hl(),X=bl(),oe=yl(),[$,Ie]=c.useState(oe.url),Le=c.useRef(!1),P=c.useRef(null),[ye,he]=c.useState(!1),[be,Te]=c.useState(!1);c.useEffect(()=>{Le.current||Ie(oe.url.startsWith("data:")?"":oe.url)},[oe.url]);const Ce=async d=>{const J=d.target.files?.[0];if(d.target.value="",!!J){he(!0),Te(!1);try{const ve=await q0(J),Qe=ve?Aa(ve):"";if(!Qe){Te(!0);return}Ie(""),Es({...oe,url:Qe})}finally{he(!1)}}},[ke,y]=c.useState(()=>ol()),[b,S]=c.useState(()=>{try{return Os().length}catch{return 0}}),[z,ue]=c.useState(!1),Ne=()=>{try{S(Os().length)}catch{S(0)}};c.useEffect(()=>{f==="prompt-history"&&Ne()},[f]),c.useEffect(()=>{if(!z)return;const d=window.setTimeout(()=>ue(!1),3e3);return()=>window.clearTimeout(d)},[z]);const[De,A]=c.useState(null),[fe,Ae]=c.useState(null),[Fe,Me]=c.useState(""),[Ge,Xt]=c.useState(""),[At,Ut]=c.useState(""),[pt,$t]=c.useState(""),[xt,qt]=c.useState(""),[It,L]=c.useState(!1),[V,Se]=c.useState(""),[_e,Pe]=c.useState(null);c.useEffect(()=>{u&&(D.current||M(u.promptTemplate??""),_(d=>{const J={};for(const[ve,Qe]of Object.entries(u.promptOverrides??{}))J[ve]=Qe??"";return I.current&&(J[I.current]=d[I.current]??""),J}),O(u.visionBridgePromptMode),!B.current&&(G(ce==="append"||u.visionBridgePrompt?u.visionBridgePrompt:u.visionBridgeDefaultPrompt||""),F.current||R(u.reviewPrompt)))},[u,ce]);const[He,ot]=c.useState(String(u?.terminalBashIdleMs??15e3));c.useEffect(()=>{ot(String(u?.terminalBashIdleMs??15e3))},[u?.terminalBashIdleMs]);const[yt,ms]=c.useState(String(u?.retryMaxAttempts??6));if(c.useEffect(()=>{ms(String(u?.retryMaxAttempts??6))},[u?.retryMaxAttempts]),!u)return null;const mt=new Set(u.disabledAgentTools??[]),Bn=mt.size,jt=[{id:"prompt",icon:s.jsx(Dr,{}),label:a("settingsSystemPrompt")},{id:"prompt-history",icon:s.jsx(la,{}),label:a("settingsPromptHistory"),count:b},...m?[{id:"question",icon:s.jsx(ti,{}),label:a("settingsQuestionnaire")}]:[{id:"tools",icon:s.jsx(Za,{}),label:a("settingsTools"),count:Bn+(u.disabledMarkers?.length??0)||void 0}],{id:"display",icon:s.jsx(rs,{}),label:a("settingsMessageDisplay")},{id:"quick",icon:s.jsx(ia,{}),label:a("quickPhrases"),count:u.quickPhrases.length},{id:"skills",icon:s.jsx(Ds,{}),label:a("settingsSkills"),count:u.skills.length},{id:"extensions",icon:s.jsx(Un,{}),label:a("settingsExtensions"),count:u.extensions.length},{id:"plugins",icon:s.jsx($n,{}),label:a("settingsUiPlugins"),count:e.plugins.length},{id:"review",icon:s.jsx(zs,{}),label:a("settingsReview"),count:u.reviewSkills.length},...m?[]:[{id:"vision",icon:s.jsx(hn,{}),label:a("settingsVisionBridge")}],{id:"presets",icon:s.jsx(gc,{}),label:a("settingsPresets"),count:u.presets.length},...m?[]:[{id:"subagent-templates",icon:s.jsx(Ja,{}),label:a("settingsSubagentTemplates"),count:u.subagentTemplates.length}]],Hs=new Set(u.disabledSkills),Us=new Set(u.disabledExtensions),Be=d=>ae({type:"set_settings",...d}),Jt=()=>{if(!_e||!u)return;const d=_e.value.trim(),J=_e.index;if(Pe(null),!d||d===u.quickPhrases[J])return;const ve=[...u.quickPhrases];ve[J]=d,Be({quickPhrases:ve})},q=d=>{const J=new Set(Hs);J.has(d.name)?J.delete(d.name):J.add(d.name),Be({disabledSkills:[...J]})},Ee=new Set(u.skillsFullText??[]),Re=d=>{const J=new Set(Ee);J.has(d)?J.delete(d):J.add(d),Be({skillsFullText:[...J]})},Ue=new Set(u.disabledPlugins??[]),ze=new Set(e.plugins.map(d=>d.id)),Lt=d=>{const J=new Set(Ue);J.has(d.id)?J.delete(d.id):J.add(d.id),Be({disabledPlugins:[...J]})},st=d=>{const J=new Set(Us);J.has(d.id)?J.delete(d.id):J.add(d.id),Be({disabledExtensions:[...J]})},lt={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")},ht=d=>{const J=new Set(mt);J.has(d)?J.delete(d):J.add(d),Be({disabledAgentTools:[...J]})},$s=u.markersEnabled??!0,Rl=new Set(u.disabledMarkers??[]),Dl=d=>{const J=new Set(Rl);!J.has(d)?J.add(d):J.delete(d),Be({disabledMarkers:[...J]})},qs=(d,J)=>{const ve={name:d,command:J,cwd:"${pwd}"};let Qe;const ct=e.terminals.find($e=>$e.title===d);ct?(t.restart(ct.id),ae({type:"run_command",terminalId:ct.id,conversationId:ct.conversationId,command:ve,cols:80,rows:24}),Qe=ct.id):(Qe=St(),t.create({id:Qe,conversationId:e.activeConversationId||e.state?.conversationId||"",title:d,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:ve})),t.select(Qe),n(),i()},Pl=d=>{A(null),qs(`${a("uninstallTitle")} ${d}`,`pi remove npm:${d}`)},Ka=d=>{Ae(null),qs(`${a("uninstallTitle")} ${d}`,`pi-web-ui uninstall ${d}`)},Ya=(d,J)=>{qs(`${a("pluginUpdate")} ${d}`,`pi-web-ui install ${J} --name ${d} --force`)},Ol=d=>{qs(`${a("pluginInstall")} ${d.id}`,`pi-web-ui install ${d.source} --name ${d.id}`)},Ml=d=>{ae({type:"plugin_catalog_remove",id:d})},Bl=()=>{const d=Fe.trim();d&&(ae({type:"plugin_catalog_add",entry:{source:d,...Ge.trim()?{id:Ge.trim()}:{},...At.trim()?{name:At.trim()}:{},...pt.trim()?{description:pt.trim()}:{},...xt.trim()?{icon:xt.trim()}:{}}}),Me(""),Xt(""),Ut(""),$t(""),qt(""),L(!1))},Fl=d=>{const J=new Set(u.reviewSkills.filter(ve=>!ve.enabled).map(ve=>ve.name));J.has(d.name)?J.delete(d.name):J.add(d.name),Be({reviewDisabledSkills:[...J]})},Hl=()=>Be({promptTemplate:C}),Ul=d=>{Be({promptOverrides:{[d]:W[d]??""}})},Fn=d=>{I.current===d&&(I.current=null),ee(null),_(J=>{const ve={...J};return delete ve[d],ve}),Be({promptOverrides:{[d]:""}})},hs=d=>pe(J=>({...J,[d]:!J[d]})),Hn=(d,J)=>{_(ve=>({...ve,[d]:J})),ee(d)},$l=()=>{D.current=!1,I.current=null,M(Vs),_({}),Be({promptTemplate:Vs,promptOverrides:{}})},ql=d=>{M(J=>J.trim()?`${J}
|
|
332
|
+
|
|
333
|
+
{{${d}}}`:`{{${d}}}`)},Wl=C.trim()&&C.trim()!==Vs||Object.values(W).some(d=>d.trim());return s.jsx("div",{className:"modal-backdrop",onClick:i,children:s.jsxs("div",{className:"modal settings-modal",onClick:d=>d.stopPropagation(),children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":a("close"),onClick:i,children:s.jsx(Ke,{})}),s.jsxs("div",{className:"modal-head",children:[s.jsx(dn,{className:"modal-head-icon"}),s.jsx("h2",{children:a("settingsTitle")}),s.jsx(Ve,{text:a("settingsDesc")})]}),s.jsxs("div",{className:"settings-layout",children:[s.jsx("nav",{className:"settings-rail","aria-label":a("settingsTitle"),children:jt.map(d=>s.jsxs("button",{type:"button",className:`settings-tab${f===d.id?" active":""}`,"aria-current":f===d.id?"true":void 0,title:d.label,onClick:()=>w(d.id),children:[s.jsx("span",{className:"settings-tab-icon",children:d.icon}),s.jsx("span",{className:"settings-tab-label",children:d.label}),d.count!==void 0&&s.jsx("span",{className:"set-count",children:d.count})]},d.id))}),s.jsxs("div",{className:"modal-body",ref:N,children:[f==="prompt"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(zs,{className:"set-section-icon"}),a("settingsSystemPrompt"),s.jsx(Ve,{text:`${a("promptComposeHint")}
|
|
334
|
+
${a("promptComposeDesc")}`})]}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",children:a("promptTemplateLabel")}),s.jsx("textarea",{className:"set-prompt-input",rows:8,spellCheck:!1,placeholder:Vs,value:C,onFocus:()=>D.current=!0,onBlur:()=>{D.current=!1,Hl()},onChange:d=>M(d.target.value)}),s.jsxs("div",{className:"compose-toolbar",children:[s.jsx("span",{className:"set-field-label set-muted",children:a("promptInsertTokens")}),H.map(d=>s.jsx("button",{type:"button",className:"token-chip",title:l(`promptTok_${d}_desc`),onClick:()=>ql(d),children:`{{${d}}}`},d))]})]}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",children:a("promptSourcesLabel")}),H.map(d=>{const J=W[d]??"",ve=u.promptSourceDefaults?.[d]??"",Qe=te===d,ct=ve.split(`
|
|
335
|
+
`).length>6||ve.length>480;if(kl(d)){const $e=J.trim()?J:ve;return s.jsxs("div",{className:"override-row readonly",children:[s.jsxs("div",{className:"override-row-head",children:[`{{${d}}}`,s.jsxs("span",{className:"set-muted",children:[l(`promptTok_${d}`)," ",s.jsx(Ve,{text:l(`promptTok_${d}_desc`)})]}),J.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",title:a("promptReadonlyLockedHint"),onClick:()=>Fn(d),children:a("promptResetSource")}):s.jsx("span",{className:"set-muted",children:a("promptReadonlyBadge")})]}),s.jsx("div",{className:`source-default readonly${$e.trim()?"":" empty"}`,title:a("promptReadonlyTitle"),children:$e.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ct?le[d]?" expanded":" clamped":""}`,children:$e}),ct&&s.jsx("span",{className:"source-default-toggle",role:"button",tabIndex:0,onClick:nt=>{nt.stopPropagation(),hs(d)},onKeyDown:nt=>{(nt.key==="Enter"||nt.key===" ")&&(nt.preventDefault(),nt.stopPropagation(),hs(d))},children:le[d]?a("promptSourceCollapse"):a("promptSourceExpand")})]}):s.jsx("span",{className:"source-default-empty",children:a("promptSourceDefaultEmpty")})})]},d)}return s.jsxs("div",{className:"override-row",children:[s.jsxs("div",{className:"override-row-head",children:[`{{${d}}}`,s.jsxs("span",{className:"set-muted",children:[l(`promptTok_${d}`)," ",s.jsx(Ve,{text:l(`promptTok_${d}_desc`)})]}),J.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",onClick:()=>Fn(d),children:a("promptResetSource")}):s.jsx("span",{className:"set-muted",children:a("promptAutoBadge")})]}),J.trim()||Qe?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"set-prompt-input override-input",rows:Math.min(10,Math.max(1,J.split(`
|
|
336
|
+
`).length)),autoFocus:Qe,placeholder:a("promptOverridePlaceholder"),value:J,onFocus:$e=>{I.current=d,ee(d);const nt=$e.currentTarget;nt.value&&nt.value===ve&&nt.setSelectionRange(nt.value.length,nt.value.length)},onBlur:()=>{I.current===d&&(I.current=null);const $e=W[d]??"";if($e.trim()&&$e===ve){Fn(d);return}Ul(d),$e.trim()||ee(null)},onChange:$e=>_(nt=>({...nt,[d]:$e.target.value}))}),s.jsxs("div",{className:"override-edit-foot",children:[s.jsxs("div",{className:"override-edit-foot-head",children:[s.jsx("span",{className:"set-muted",children:a("promptSourceRefLabel")}),ct&&s.jsx("button",{type:"button",className:"source-default-toggle",onClick:()=>hs(d),children:le[d]?a("promptSourceCollapse"):a("promptSourceExpand")})]}),ve.trim()?s.jsx("pre",{className:`source-default-text${ct?le[d]?" expanded":" clamped":""}`,children:ve}):s.jsx("span",{className:"source-default-empty",children:a("promptSourceDefaultEmpty")}),!J.trim()&&ve.trim()&&s.jsx("button",{type:"button",className:"override-seed-btn",title:a("promptSourceSeedTip"),onClick:()=>Hn(d,ve),children:a("promptSourceSeedButton")})]})]}):s.jsx("div",{className:"source-default",title:a("promptSourceDefaultEditHint"),role:"button",tabIndex:0,onClick:()=>Hn(d,ve),onKeyDown:$e=>{($e.key==="Enter"||$e.key===" ")&&($e.preventDefault(),Hn(d,ve))},children:ve.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ct?le[d]?" expanded":" clamped":""}`,children:ve}),ct&&s.jsx("span",{className:"source-default-toggle",role:"button",tabIndex:0,onClick:$e=>{$e.stopPropagation(),hs(d)},onKeyDown:$e=>{($e.key==="Enter"||$e.key===" ")&&($e.preventDefault(),$e.stopPropagation(),hs(d))},children:le[d]?a("promptSourceCollapse"):a("promptSourceExpand")})]}):s.jsx("span",{className:"source-default-empty",children:a("promptSourceDefaultEmpty")})})]},d)}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"set-btn",onClick:$l,disabled:!Wl,children:a("promptResetAll")})})]}),s.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":re,onClick:()=>de(d=>!d),children:[a("settingsViewPrompt")," ",re?"▴":"▾"]}),re&&s.jsxs("div",{className:"set-prompt-view",children:[s.jsxs("div",{className:"set-prompt-view-head",children:[s.jsx("span",{children:a("settingsViewPrompt")}),s.jsx(Ve,{text:a("settingsViewPromptHint")}),s.jsx(vn,{text:u.effectiveSystemPrompt})]}),u.effectiveSystemPrompt?s.jsx("pre",{className:"set-prompt-view-text",children:u.effectiveSystemPrompt}):s.jsx("p",{className:"set-empty",children:a("settingsViewPromptEmpty")})]}),s.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":we,onClick:()=>ie(d=>!d),children:[a("settingsViewToolsSchema")," ",we?"▴":"▾"]}),we&&s.jsx("div",{className:"set-prompt-view",children:s.jsxs("div",{className:"set-prompt-tools",children:[s.jsxs("div",{className:"set-prompt-view-head",children:[s.jsx("span",{children:a("settingsViewToolsSchema")}),s.jsx(Ve,{text:a("settingsViewToolsSchemaHint")}),s.jsx(vn,{text:u.toolsSchema})]}),u.toolsSchema?s.jsx("pre",{className:"set-prompt-view-text",children:u.toolsSchema}):s.jsx("p",{className:"set-empty",children:a("settingsViewToolsSchemaEmpty")})]})})]}),f==="prompt-history"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(la,{className:"set-section-icon"}),a("settingsPromptHistory"),s.jsx(Ve,{text:a("settingsPromptHistoryDesc")}),s.jsx("span",{className:"set-count",children:a("promptHistoryCount",{n:String(b)})})]}),b===0?s.jsx("p",{className:"set-empty",children:a("promptHistoryEmpty")}):s.jsx("p",{className:"set-hint",children:a("promptHistoryCount",{n:String(b)})}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"ph-max",children:a("promptHistoryMax")}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("input",{id:"ph-max",className:"set-input",type:"number",min:1,max:500,step:1,value:String(ke.maxEntries),onChange:d=>{const J=Math.floor(Number(d.target.value)||0),ve={...ke,maxEntries:J};y(ve)},onBlur:()=>{const d={...ke};(!Number.isFinite(d.maxEntries)||d.maxEntries<1)&&(d.maxEntries=1),d.maxEntries>500&&(d.maxEntries=500),d.maxEntries=Math.floor(d.maxEntries),y(d),ta(d),Ne()}}),s.jsx(Ve,{text:a("promptHistoryMaxHint")})]})]}),s.jsx(We,{title:a("promptHistoryCharLimit"),tip:a("promptHistoryCharLimitHint"),enabled:ke.charLimitEnabled,onToggle:()=>{const d={...ke,charLimitEnabled:!ke.charLimitEnabled};y(d),ta(d),Ne()}}),ke.charLimitEnabled&&s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"ph-char-limit",children:a("promptHistoryCharLimit")}),s.jsx("input",{id:"ph-char-limit",className:"set-input",type:"number",min:100,max:2e4,step:100,placeholder:a("promptHistoryCharLimitPlaceholder"),value:String(ke.charLimit),onChange:d=>{const J=Math.floor(Number(d.target.value)||0);y({...ke,charLimit:J})},onBlur:()=>{let d=Math.floor(Number(ke.charLimit)||0);(!Number.isFinite(d)||d<100)&&(d=100),d>2e4&&(d=2e4);const J={...ke,charLimit:d};y(J),ta(J),Ne()}})]}),s.jsxs("div",{className:"set-field",style:{marginTop:12},children:[s.jsxs("button",{type:"button",className:`set-uninstall${z?" confirm":""}`,disabled:b===0,title:a(b===0?"promptHistoryEmpty":"promptHistoryClear"),onClick:()=>{if(!z){ue(!0);return}i0(),ue(!1),Ne()},children:[s.jsx(et,{})," ",a(z?"promptHistoryClearConfirm":"promptHistoryClear")]}),b>0&&s.jsx("span",{className:"set-hint",style:{marginLeft:8},children:a("promptHistoryCount",{n:String(b)})})]}),s.jsxs("p",{className:"set-hint",children:[s.jsx(Br,{style:{verticalAlign:"-2px",marginRight:4}}),a("settingsPromptHistoryDesc")]})]}),f==="tools"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Za,{className:"set-section-icon"}),a("settingsTools")]}),s.jsx("div",{className:"set-field-label",children:a("toolsSectionTerminal")}),vl.map(d=>s.jsx(We,{title:d,tip:a("settingsTerminalToolsDesc"),enabled:!mt.has(d),onToggle:()=>ht(d)},d)),s.jsx(We,{title:a("terminalBashTakeover"),tip:a("terminalBashTakeoverDesc"),enabled:u.terminalBash,onToggle:()=>Be({terminalBash:!u.terminalBash})}),u.terminalBash&&s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"tb-idle-ms",children:a("terminalBashIdleMs")}),s.jsx("input",{id:"tb-idle-ms",className:"set-input",type:"number",min:0,step:1e3,value:He,onChange:d=>ot(d.target.value),onBlur:()=>{const d=Math.max(0,Math.floor(Number(He)||0));ot(String(d)),d!==u.terminalBashIdleMs&&Be({terminalBashIdleMs:d})}})]}),s.jsx("div",{className:"set-field-label",children:a("toolsSectionSubagent")}),s.jsx("div",{className:"set-row-desc",children:a("toolsSubagentDepHint")}),Cl.map(d=>s.jsx(We,{title:d,tip:lt[d],enabled:!mt.has(d),onToggle:()=>ht(d)},d)),s.jsxs("div",{className:"set-field-label",children:[a("settingsMarkers"),s.jsx(Ve,{text:`${a("settingsMarkersDesc")}
|
|
337
|
+
${a("markerRenameTip")}`})]}),s.jsx(We,{title:a("markersEnabled"),tip:`${a("markersEnabledDesc")}
|
|
338
|
+
${a("markersOffHint")}`,enabled:$s,onToggle:()=>Be({markersEnabled:!$s})}),$s&&(u.markers?.length??0)===0&&s.jsxs("p",{className:"set-empty",children:[a("loading"),"..."]}),$s&&u.markers&&u.markers.length>0&&u.markers.map(d=>s.jsx(We,{title:d.name==="todo"?a("markerGroupTodo"):d.name==="notify"?a("markerGroupNotify"):d.name==="conv"?a("markerGroupRename"):d.name,tip:d.guidance.join(`
|
|
339
|
+
`),enabled:d.enabled,onToggle:()=>Dl(d.name)},d.name)),s.jsx(We,{title:rn,tip:`${a("todoListEnabledDesc")}
|
|
340
|
+
${a("todoListOffHint")}`,enabled:!mt.has(rn),onToggle:()=>ht(rn)}),s.jsx("div",{className:"set-field-label",children:a("toolsSectionOther")}),s.jsx(We,{title:sn,tip:`${a("editSoftEnabledDesc")}
|
|
341
|
+
${a("editSoftOffHint")}`,enabled:!mt.has(sn),onToggle:()=>ht(sn)}),s.jsx(We,{title:nn,tip:`${a("delegateTaskEnabledDesc")}
|
|
342
|
+
${a("delegateTaskOffHint")}`,enabled:!mt.has(nn),onToggle:()=>ht(nn)}),s.jsx(We,{title:an,tip:`${a("questionnaireEnabledDesc")}
|
|
343
|
+
${a("questionnaireOffHint")}`,enabled:!mt.has(an),onToggle:()=>ht(an)}),s.jsx(We,{title:on,tip:`${a("browserPageEnabledDesc")}
|
|
344
|
+
${a("browserPageOffHint")}`,enabled:!mt.has(on),onToggle:()=>ht(on)})]}),f==="question"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(ti,{className:"set-section-icon"}),a("settingsQuestionnaire")]}),s.jsx(We,{title:a("questionnaireEnabled"),tip:`${a("questionnaireEnabledDesc")}
|
|
345
|
+
${a("questionnaireOffHint")}`,enabled:u.questionnaireEnabled,onToggle:()=>Be({questionnaireEnabled:!u.questionnaireEnabled})})]}),f==="display"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(rs,{className:"set-section-icon"}),a("settingsMessageDisplay")]}),s.jsxs("div",{className:"set-field",children:[s.jsxs("label",{className:"set-field-label",htmlFor:"model-retry-max",children:[a("modelRetryAttempts")," ",s.jsx(Ve,{text:a("modelRetryHint")})]}),s.jsx("input",{id:"model-retry-max",className:"set-input",type:"number",min:0,max:100,step:1,value:yt,onChange:d=>ms(d.target.value),onBlur:()=>{const d=Math.min(100,Math.max(0,Math.floor(Number(yt)||0)));ms(String(d)),d!==u.retryMaxAttempts&&Be({retryMaxAttempts:d})},onKeyDown:d=>{d.key==="Enter"&&d.target.blur()}})]}),s.jsx("hr",{className:"set-sep"}),s.jsx(We,{title:a("thinkingWrap"),tip:a("thinkingWrapDesc"),enabled:u.thinkingWrap??!0,onToggle:()=>Be({thinkingWrap:!(u.thinkingWrap??!0)})}),s.jsx(We,{title:a("toolsWrap"),tip:a("toolsWrapDesc"),enabled:u.toolsWrap??!0,onToggle:()=>Be({toolsWrap:!(u.toolsWrap??!0)})}),s.jsx("hr",{className:"set-sep"}),s.jsx(We,{title:a("wideChat"),tip:a("wideChatDesc"),enabled:me,onToggle:()=>j0({wide:!me})}),s.jsx(We,{title:a("projectTitle"),tip:a("projectTitleDesc"),enabled:X,onToggle:()=>O0({projectName:!X})}),s.jsx("hr",{className:"set-sep"}),s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsxs("div",{className:"set-row-name",children:[a("wallpaperTitle"),s.jsx(Ve,{text:a("wallpaperDesc")})]}),s.jsxs("div",{className:"wallpaper-url-row",children:[s.jsx("input",{className:"set-input wallpaper-url",placeholder:a("wallpaperUrlPh"),value:$,maxLength:2e3,spellCheck:!1,onFocus:()=>{Le.current=!0},onChange:d=>Ie(d.target.value),onBlur:()=>{if(Le.current=!1,!$.trim()&&oe.url.startsWith("data:")){Ie("");return}const d=Aa($);Ie(d),d!==oe.url&&Es({...oe,url:d})},onKeyDown:d=>{d.key==="Enter"?d.target.blur():d.key==="Escape"&&(Ie(oe.url.startsWith("data:")?"":oe.url),d.target.blur())}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:ye,onClick:()=>P.current?.click(),children:[s.jsx(jr,{})," ",a("wallpaperUpload")]}),s.jsx("input",{ref:P,type:"file",accept:"image/*",hidden:!0,onChange:Ce})]}),be&&s.jsx("p",{className:"set-hint",children:a("wallpaperUploadFailed")}),s.jsxs("div",{className:"wallpaper-sliders",children:[s.jsxs("label",{className:"wallpaper-slider",children:[s.jsx("span",{children:a("wallpaperDim")}),s.jsx("input",{type:"range",min:0,max:95,step:1,value:oe.dim,onChange:d=>Es({...oe,dim:Number(d.target.value)})}),s.jsxs("output",{children:[oe.dim,"%"]})]}),s.jsxs("label",{className:"wallpaper-slider",children:[s.jsx("span",{children:a("wallpaperBlur")}),s.jsx("input",{type:"range",min:0,max:24,step:1,value:oe.blur,onChange:d=>Es({...oe,blur:Number(d.target.value)})}),s.jsxs("output",{children:[oe.blur,"px"]})]})]})]}),oe.url&&s.jsxs("div",{className:"wallpaper-current",children:[s.jsx("img",{className:"wallpaper-preview",src:oe.url,alt:""}),s.jsx("button",{type:"button",className:"wallpaper-clear",onClick:()=>{Ie(""),Es({...oe,url:""})},children:a("wallpaperClear")})]})]})]}),f==="quick"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(ia,{className:"set-section-icon"}),a("quickPhrases"),s.jsx(Ve,{text:a("quickPhrasesDesc")}),s.jsx("span",{className:"set-count",children:u.quickPhrases.length})]}),s.jsx(We,{title:a("quickPhrasesEnabled"),tip:a("quickPhrasesDesc"),enabled:u.quickPhrasesEnabled,onToggle:()=>Be({quickPhrasesEnabled:!u.quickPhrasesEnabled})}),!u.quickPhrasesEnabled&&s.jsx("p",{className:"set-hint",children:a("quickPhrasesOffHint")}),s.jsxs("div",{className:"set-preset-save",children:[s.jsx("input",{className:"set-input",placeholder:a("quickPhrasesPlaceholder"),value:V,maxLength:200,onChange:d=>Se(d.target.value),onKeyDown:d=>{d.key==="Enter"&&V.trim()&&(Be({quickPhrases:[...u.quickPhrases,V.trim()]}),Se(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!V.trim(),onClick:()=>{Be({quickPhrases:[...u.quickPhrases,V.trim()]}),Se("")},children:[s.jsx(dt,{})," ",a("quickPhrasesAdd")]})]}),u.quickPhrases.length===0?s.jsx("p",{className:"set-empty",children:a("quickPhrasesEmpty")}):s.jsx("div",{className:"set-list",children:u.quickPhrases.map((d,J)=>s.jsx("div",{className:"set-row",children:_e?.index===J?s.jsx("div",{className:"set-row-info",children:s.jsx("input",{className:"set-input",autoFocus:!0,value:_e.value,maxLength:200,placeholder:a("quickPhrasesEditPh"),onChange:ve=>Pe({index:J,value:ve.target.value}),onKeyDown:ve=>{ve.key==="Enter"?Jt():ve.key==="Escape"&&Pe(null)},onBlur:Jt})}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"set-row-info",children:s.jsx("div",{className:"set-row-name",title:d,children:d})}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:"set-icon-btn",title:a("quickPhrasesEdit"),onClick:()=>Pe({index:J,value:d}),children:s.jsx(fn,{})}),s.jsx("button",{type:"button",className:"set-icon-btn",title:a("quickPhrasesMoveUp"),disabled:J===0,onClick:()=>{const ve=[...u.quickPhrases];[ve[J-1],ve[J]]=[ve[J],ve[J-1]],Be({quickPhrases:ve})},children:"↑"}),s.jsx("button",{type:"button",className:"set-icon-btn",title:a("quickPhrasesMoveDown"),disabled:J===u.quickPhrases.length-1,onClick:()=>{const ve=[...u.quickPhrases];[ve[J],ve[J+1]]=[ve[J+1],ve[J]],Be({quickPhrases:ve})},children:"↓"}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:a("quickPhrasesDelete"),onClick:()=>Be({quickPhrases:u.quickPhrases.filter((ve,Qe)=>Qe!==J)}),children:s.jsx(et,{})})]})]})},`${J}:${d}`))}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{Pe(null),Be({quickPhrases:In[o]??In.en})},children:a("quickPhrasesReset")})})]}),f==="skills"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Ds,{className:"set-section-icon"}),a("settingsSkills"),s.jsx(Ve,{text:`${a("skillFullTextLabel")}:${a("skillFullTextDesc")}`}),s.jsx("span",{className:"set-count",children:u.skills.length})]}),u.skills.length===0?s.jsx("p",{className:"set-empty",children:a(m?"dshSkillsNote":"noSkills")}):s.jsx("div",{className:"set-list",children:u.skills.map(d=>s.jsx(We,{title:d.name,subtitle:d.description,enabled:d.enabled,onToggle:()=>q(d),action:s.jsx("button",{type:"button",className:`tpl-chip${Ee.has(d.name)?" on":""}`,title:a("skillFullTextDesc"),onClick:()=>Re(d.name),children:a("skillFullTextShort")})},d.name))})]}),f==="extensions"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Un,{className:"set-section-icon"}),a("settingsExtensions"),s.jsx("span",{className:"set-count",children:u.extensions.length})]}),u.extensions.length===0?s.jsx("p",{className:"set-empty",children:a(m?"dshExtensionsNote":"noExtensions")}):s.jsx("div",{className:"set-list",children:u.extensions.map(d=>{const J=d.id.startsWith("npm:")?d.id.slice(4):null;return s.jsx(We,{title:d.name,subtitle:d.path,enabled:d.enabled,onToggle:()=>st(d),action:J?De===d.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("uninstallConfirmHint"),onClick:()=>Pl(J),children:a("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("uninstallHint"),onClick:()=>A(d.id),children:[s.jsx(et,{}),a("uninstallExt")]}):void 0},d.id)})})]}),f==="plugins"&&E&&s.jsx("div",{className:"set-section",children:s.jsx("div",{className:"set-note",children:a("updatesManaged")})}),f==="plugins"&&!E&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Un,{className:"set-section-icon"}),a("pluginMarket"),s.jsx("span",{className:"set-count",children:e.pluginCatalog.length}),s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginCatalogAddHint"),onClick:()=>L(d=>!d),children:[s.jsx(dt,{}),a("pluginCatalogAdd")]})]}),It&&s.jsxs("div",{className:"set-catalog-add",children:[s.jsx("input",{className:"set-input",placeholder:a("pluginCatalogSource"),value:Fe,onChange:d=>Me(d.target.value)}),s.jsx("input",{className:"set-input",placeholder:a("pluginCatalogId"),value:Ge,onChange:d=>Xt(d.target.value)}),s.jsx("input",{className:"set-input",placeholder:a("pluginCatalogName"),value:At,onChange:d=>Ut(d.target.value)}),s.jsx("input",{className:"set-input",placeholder:a("pluginCatalogIcon"),value:xt,onChange:d=>qt(d.target.value)}),s.jsx("textarea",{className:"set-input",rows:2,placeholder:a("pluginCatalogDesc"),value:pt,onChange:d=>$t(d.target.value)}),s.jsxs("div",{className:"set-catalog-add-actions",children:[s.jsx("button",{type:"button",className:"set-uninstall confirm",disabled:!Fe.trim(),onClick:Bl,children:a("pluginCatalogAddSubmit")}),s.jsx("button",{type:"button",className:"set-uninstall",onClick:()=>L(!1),children:a("cancel")})]})]}),e.pluginCatalog.length===0?s.jsx("p",{className:"set-empty",children:a("noPluginCatalog")}):s.jsx("div",{className:"set-list",children:e.pluginCatalog.map(d=>{const J=ze.has(d.id);return s.jsxs("div",{className:"set-catalog-row",children:[s.jsxs("div",{className:"set-catalog-main",children:[s.jsxs("div",{className:"set-catalog-title",children:[s.jsxs("span",{children:[d.icon?`${d.icon} `:"",d.name]}),J&&s.jsx("span",{className:"set-catalog-installed",children:a("pluginInstalled")}),!d.builtin&&s.jsx("span",{className:"set-catalog-custom",children:a("pluginCatalogCustom")})]}),d.description&&s.jsx("div",{className:"set-catalog-desc",children:d.description}),s.jsx("div",{className:"set-catalog-source",children:d.source})]}),s.jsxs("div",{className:"set-row-actions",children:[J?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginUpdateHint"),onClick:()=>Ya(d.id,d.source),children:[s.jsx(kt,{}),a("pluginUpdate")]}),fe===d.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("pluginUninstallHint"),onClick:()=>Ka(d.id),children:a("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginUninstallHint"),onClick:()=>Ae(d.id),children:[s.jsx(et,{}),a("uninstallExt")]})]}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginInstallHint"),onClick:()=>Ol(d),children:[s.jsx(Yt,{}),a("pluginInstall")]}),!d.builtin&&s.jsx("button",{type:"button",className:"set-uninstall",title:a("pluginCatalogRemoveHint"),onClick:()=>Ml(d.id),children:s.jsx(Ke,{})})]})]},d.id)})})]}),f==="plugins"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx($n,{className:"set-section-icon"}),a("settingsUiPlugins"),s.jsx("span",{className:"set-count",children:e.plugins.length})]}),e.plugins.length===0?s.jsx("p",{className:"set-empty",children:a("noUiPlugins")}):s.jsx("div",{className:"set-list",children:e.plugins.map(d=>s.jsxs(s.Fragment,{children:[s.jsx(We,{title:`${d.icon?`${d.icon} `:""}${d.name}`,subtitle:(d.error?`${d.id} · ${d.error}`:d.source?`${d.id} · ${d.source}`:`${d.id} · ${a("uiPluginNoSource")}`)+(d.permissions?.length?` · ${a("uiPluginPerms")}: ${d.permissions.join(", ")}`:""),enabled:!Ue.has(d.id)&&!d.error,onToggle:()=>!d.error&&Lt(d),action:s.jsxs("div",{className:"set-row-actions",children:[d.source&&s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginUpdateHint"),onClick:()=>Ya(d.id,d.source),children:[s.jsx(kt,{}),a("pluginUpdate")]}),fe===d.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("pluginUninstallHint"),onClick:()=>Ka(d.id),children:a("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginUninstallHint"),onClick:()=>Ae(d.id),children:[s.jsx(et,{}),a("uninstallExt")]})]})},d.id),d.settingsSchema&&d.settingsSchema.length>0&&s.jsx(A0,{plugin:d})]}))})]}),f==="plugins"&&m&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx($n,{className:"set-section-icon"}),a("dshPatches"),s.jsx(Ve,{text:a("dshPatchesDesc")}),s.jsx("span",{className:"set-count",children:e.dshPatches?.files.length??0}),s.jsxs("button",{type:"button",className:"set-uninstall",title:a("dshPatchesRescanHint"),onClick:()=>ae({type:"dsh_patches_rescan"}),children:[s.jsx(kt,{}),a("dshPatchesRescan")]})]}),(e.dshPatches?.files.length??0)===0?s.jsx("p",{className:"set-empty",children:a("dshPatchesEmpty")}):s.jsx("div",{className:"set-list",children:e.dshPatches.files.map(d=>s.jsx("div",{className:"set-row",children:s.jsxs("div",{className:"set-row-info",children:[s.jsx("div",{className:"set-row-name",children:d.name}),s.jsxs("div",{className:"set-row-desc",children:[z0(d.size)," · ",new Date(d.mtimeMs).toLocaleString()]})]})},d.name))}),s.jsxs("p",{className:"set-hint",children:[a("dshPatchesPath")," ",e.dshPatches?.patchDir??""]})]}),f==="review"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(zs,{className:"set-section-icon"}),a("settingsReview"),s.jsx(Ve,{text:a("settingsReviewDesc")}),s.jsx("span",{className:"set-count",children:u.reviewSkills.length})]}),s.jsx(We,{title:a("goalModeEnabled"),tip:`${a("goalModeEnabledDesc")}
|
|
346
|
+
${a("goalModeOffHint")}`,enabled:u.goalModeEnabled,onToggle:()=>Be({goalModeEnabled:!u.goalModeEnabled})}),s.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:a("reviewPromptPlaceholder"),value:x,onFocus:()=>F.current=!0,onBlur:()=>{F.current=!1,Be({reviewPrompt:x})},onChange:d=>R(d.target.value)}),s.jsxs("div",{className:"set-field-label",children:[a("settingsReviewSkills"),m&&s.jsxs(s.Fragment,{children:[" ",s.jsx(Ve,{text:a("dshReviewPromptNote")})]})]}),u.reviewSkills.length===0?s.jsx("p",{className:"set-empty",children:a("noSkills")}):s.jsx("div",{className:"set-list",children:u.reviewSkills.map(d=>s.jsx(We,{title:d.name,subtitle:d.description,enabled:d.enabled,onToggle:()=>Fl(d)},`review-${d.name}`))})]}),f==="vision"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(hn,{className:"set-section-icon"}),a("settingsVisionBridge")]}),s.jsx(We,{title:a("visionBridgeEnabled"),tip:`${a("settingsVisionBridgeDesc")}
|
|
347
|
+
${a("visionBridgeOffHint")}`,enabled:u.visionBridgeEnabled,onToggle:()=>Be({visionBridgeEnabled:!u.visionBridgeEnabled})}),u.visionBridgeEnabled&&s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:a("visionBridgeModel")}),s.jsxs("select",{className:"set-select",value:u.visionBridgeModel??"",onChange:d=>Be({visionBridgeModel:d.target.value||null}),children:[s.jsx("option",{value:"",children:a("visionBridgeAuto")}),u.visionModels.map(d=>s.jsx("option",{value:`${d.provider}/${d.id}`,children:d.label},`${d.provider}/${d.id}`))]})]}),u.visionBridgeEnabled&&s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:a("visionBridgePromptMode")}),s.jsxs("select",{className:"set-select",value:ce,onChange:d=>{const J=d.target.value;O(J),Be({visionBridgePromptMode:J})},children:[s.jsx("option",{value:"append",children:a("promptModeAppend")}),s.jsx("option",{value:"replace",children:a("promptModeReplace")})]})]}),u.visionBridgeEnabled&&s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:a("visionBridgePromptPlaceholder"),value:Q,onFocus:()=>B.current=!0,onBlur:()=>{B.current=!1;const d=ce==="replace"&&u.visionBridgeDefaultPrompt&&Q===u.visionBridgeDefaultPrompt?"":Q;Be({visionBridgePromptMode:ce,visionBridgePrompt:d})},onChange:d=>G(d.target.value)}),u.visionBridgeEnabled&&(u.visionModels.length===0?s.jsx("p",{className:"set-hint",children:a("visionBridgeNoModels")}):s.jsx("p",{className:"set-hint",children:a("visionBridgeCurrent",{model:u.visionBridgeModel??a("visionBridgeAuto")})}))]}),f==="presets"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(dn,{className:"set-section-icon"}),a("settingsPresets"),s.jsx("span",{className:"set-count",children:u.presets.length})]}),s.jsxs("div",{className:"set-preset-save",children:[s.jsx("input",{className:"set-input",placeholder:a("presetNamePlaceholder"),value:v,onChange:d=>se(d.target.value),onKeyDown:d=>{d.key==="Enter"&&v.trim()&&(ae({type:"save_preset",name:v.trim()}),se(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!v.trim(),onClick:()=>{ae({type:"save_preset",name:v.trim()}),se("")},children:[s.jsx(dt,{})," ",a("saveAsPreset")]})]}),u.presets.length===0?s.jsx("p",{className:"set-empty",children:a("noPresets")}):s.jsx("div",{className:"set-list",children:u.presets.map(d=>s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsx("div",{className:"set-row-name",children:d.name}),s.jsxs("div",{className:"set-row-desc",children:[d.promptMode==="replace"?a("promptModeReplace"):a("promptModeAppend"),d.disabledSkills.length>0&&` · ${a("settingsSkills")} ${d.disabledSkills.length}`,d.disabledExtensions.length>0&&` · ${a("settingsExtensions")} ${d.disabledExtensions.length}`]})]}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>ae({type:"apply_preset",name:d.name}),children:a("applyPreset")}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:a("deletePreset"),onClick:()=>ae({type:"delete_preset",name:d.name}),children:s.jsx(et,{})})]})]},d.name))})]}),f==="subagent-templates"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Ja,{className:"set-section-icon"}),a("settingsSubagentTemplates"),s.jsx(Ve,{text:a("settingsSubagentTemplatesDesc")}),s.jsx("span",{className:"set-count",children:u.subagentTemplates.length}),s.jsxs("button",{type:"button",className:"set-save-btn",title:a("subagentTemplateNew"),onClick:()=>xe({name:"",description:"",promptMode:"replace",systemPrompt:"",enabledSkills:[],enabledExtensions:[],model:"",thinkingLevel:"",enabled:!0}),children:[s.jsx(dt,{})," ",a("subagentTemplateNew")]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsxs("label",{className:"set-field-label",children:[a("subagentDefaultModelLabel")," ",s.jsx(Ve,{text:a("subagentDefaultModelHint")})]}),s.jsxs("select",{className:"set-select",value:u.subagentDefaultModel??"",onChange:d=>Be({subagentDefaultModel:d.target.value||null}),children:[s.jsx("option",{value:"",children:a("subagentFollowMain")}),u.subagentModels.map(d=>s.jsx("option",{value:`${d.provider}/${d.id}`,children:d.label},`${d.provider}/${d.id}`))]})]}),u.subagentModels.length===0&&s.jsx("p",{className:"set-hint",children:a("subagentNoModels")}),K&&s.jsxs("div",{className:"tpl-editor",children:[s.jsxs("div",{className:"tpl-fields",children:[s.jsx("input",{className:"set-input",placeholder:a("tplNamePlaceholder"),value:K.name,onChange:d=>xe({...K,name:d.target.value})}),s.jsx("input",{className:"set-input",placeholder:a("tplDescriptionPlaceholder"),value:K.description,onChange:d=>xe({...K,description:d.target.value})}),s.jsx("input",{className:"set-input",placeholder:a("tplDescriptionEnPlaceholder"),value:K.descriptionEn??"",onChange:d=>xe({...K,descriptionEn:d.target.value})})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:a("tplPromptModeLabel")}),s.jsxs("select",{className:"set-select",value:K.promptMode,onChange:d=>xe({...K,promptMode:d.target.value}),children:[s.jsx("option",{value:"replace",children:a("promptModeReplace")}),s.jsx("option",{value:"append",children:a("promptModeAppend")})]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:a("tplModelLabel")}),s.jsxs("select",{className:"set-select",value:K.model??"",onChange:d=>xe({...K,model:d.target.value}),children:[s.jsx("option",{value:"",children:a("subagentFollowMain")}),u.subagentModels.map(d=>s.jsx("option",{value:`${d.provider}/${d.id}`,children:d.label},`${d.provider}/${d.id}`))]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsxs("label",{className:"set-field-label",children:[a("tplThinkingLabel")," ",s.jsx(Ve,{text:a("tplThinkingHint")})]}),s.jsxs("select",{className:"set-select",value:K.thinkingLevel??"",onChange:d=>xe({...K,thinkingLevel:d.target.value}),children:[s.jsx("option",{value:"",children:a("tplThinkingFollowMain")}),cl.map(d=>s.jsx("option",{value:d,children:a(`thinking.${d}`)},d))]})]}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${a("tplSystemPromptLabel")}${o==="zh"?":":": "}${a("tplSystemPromptPlaceholder")}`,value:K.systemPrompt,onChange:d=>xe({...K,systemPrompt:d.target.value})}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${a("tplSystemPromptLabel")}: ${a("tplSystemPromptEnPlaceholder")}`,value:K.systemPromptEn??"",onChange:d=>xe({...K,systemPromptEn:d.target.value})}),s.jsxs("div",{className:"tpl-pick-block",children:[s.jsx("div",{className:"tpl-pick-head",children:s.jsxs("span",{children:[a("tplSkillsLabel")," · ",a("tplWhitelistHint")]})}),u.skills.length===0?s.jsx("p",{className:"set-hint",children:a("noSkills")}):s.jsx("div",{className:"tpl-pick",children:u.skills.map(d=>s.jsxs("label",{className:`tpl-chip${K.enabledSkills.includes(d.name)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:K.enabledSkills.includes(d.name),onChange:J=>{const ve=J.target.checked;xe({...K,enabledSkills:ve?[...K.enabledSkills,d.name]:K.enabledSkills.filter(Qe=>Qe!==d.name)})}}),d.name]},d.name))})]}),s.jsxs("div",{className:"tpl-pick-block",children:[s.jsx("div",{className:"tpl-pick-head",children:s.jsxs("span",{children:[a("tplExtensionsLabel")," · ",a("tplWhitelistHint")]})}),u.extensions.length===0?s.jsx("p",{className:"set-hint",children:a("noExtensions")}):s.jsx("div",{className:"tpl-pick",children:u.extensions.map(d=>s.jsxs("label",{className:`tpl-chip${K.enabledExtensions.includes(d.id)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:K.enabledExtensions.includes(d.id),onChange:J=>{const ve=J.target.checked;xe({...K,enabledExtensions:ve?[...K.enabledExtensions,d.id]:K.enabledExtensions.filter(Qe=>Qe!==d.id)})}}),d.name]},d.id))})]}),s.jsxs("div",{className:"tpl-actions",children:[s.jsx("button",{type:"button",className:"set-save-btn",disabled:!K.name.trim(),onClick:()=>{ae({type:"save_subagent_template",template:{...K,name:K.name.trim()}}),xe(null)},children:a("tplSave")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>xe(null),children:a("tplCancel")})]})]}),u.subagentTemplates.length===0?s.jsx("p",{className:"set-empty",children:a("noSubagentTemplates")}):s.jsx("div",{className:"set-list",children:u.subagentTemplates.map(d=>s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsxs("div",{className:"set-row-name",children:[d.name,u.subagentDefaultTemplates.includes(d.name)&&s.jsx("span",{className:"tpl-badge default",children:a("tplDefaultBadge")}),!d.enabled&&s.jsx("span",{className:"tpl-badge",children:a("subagentTemplateClosed")})]}),s.jsxs("div",{className:"set-row-desc",children:[(o!=="zh"&&d.descriptionEn?d.descriptionEn:d.description)||`${d.promptMode==="replace"?a("promptModeReplace"):a("promptModeAppend")}`,d.model?` · ${a("tplModelLabel")} ${d.model}`:` · ${a("subagentFollowMain")}`,d.thinkingLevel?` · ${a("tplThinkingLabel")} ${l(`thinking.${d.thinkingLevel}`)}`:"",d.enabledSkills.length>0&&` · ${a("tplSkillsLabel")} ${d.enabledSkills.length}`,d.enabledExtensions.length>0&&` · ${a("tplExtensionsLabel")} ${d.enabledExtensions.length}`,!d.description&&d.enabledSkills.length===0&&d.enabledExtensions.length===0&&` · ${a("tplInherit")}`]})]}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:`set-switch${d.enabled?" on":""}`,role:"switch","aria-checked":d.enabled,title:`${d.enabled?a("subagentTemplateDisable"):a("subagentTemplateEnable")} · ${a("subagentTemplateOffHint")}`,onClick:()=>ae({type:"save_subagent_template",template:{...d,enabled:!d.enabled}}),children:s.jsx("span",{className:"set-switch-knob"})}),s.jsx("button",{type:"button",className:"dd-refresh",title:a("subagentTemplateEdit"),onClick:()=>xe({...d}),children:a("subagentTemplateEdit")}),k===d.name?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("uninstallConfirmHint"),onClick:()=>{ae({type:"delete_subagent_template",name:d.name}),Y(null)},children:a("uninstallConfirm")}):s.jsx("button",{type:"button",className:"set-icon-btn danger",title:a("tplDelete"),onClick:()=>Y(d.name),children:s.jsx(et,{})})]})]},d.name))})]})]})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:i,children:a("close")})})]})})}function X0(e,t){const n=Math.max(0,Date.now()-e),i=Math.floor(n/6e4);if(i<1)return t("bgTaskJustNow");if(i<60)return t("bgTaskMinutes",{n:i});const a=Math.floor(i/60);return a<24?t("bgTaskHours",{n:a}):t("bgTaskDays",{n:Math.floor(a/24)})}function J0({servers:e,onClose:t}){const n=je(),[i,a]=c.useState(new Set),o=l=>a(u=>{const p=new Set(u);return p.has(l)?p.delete(l):p.add(l),p});return c.useEffect(()=>{ae({type:"list_bg_servers"})},[]),s.jsx("div",{className:"modal-backdrop",onClick:t,children:s.jsxs("div",{className:"bg-task-modal",onClick:l=>l.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(mn,{})," ",n("bgTasks"),e.length>0&&s.jsx("em",{className:"bg-task-count",children:e.length})]}),s.jsx("button",{type:"button",className:"btn",title:n("close"),onClick:t,children:s.jsx(Ke,{})})]}),e.length===0?s.jsxs("div",{className:"bg-task-empty",children:[s.jsx(mn,{}),s.jsx("span",{children:n("bgTasksEmpty")}),s.jsx("small",{children:n("bgTasksDesc")})]}):s.jsx("ul",{className:"bg-task-list",children:e.map(l=>{const u=!!l.taskId,p=l.taskId??String(l.port);return s.jsxs("li",{className:"bg-task-item",children:[s.jsx("span",{className:"bg-task-icon",title:u?l.plugin:n("bgTaskPort")}),s.jsxs("div",{className:"bg-task-info",children:[s.jsxs("div",{className:"bg-task-line1",children:[u?s.jsxs("span",{className:"bg-task-port",title:l.taskId,children:["🧩 ",l.plugin]}):s.jsxs("span",{className:"bg-task-port",children:[":",l.port]}),l.name&&s.jsx("span",{className:"bg-task-name",children:l.name})]}),s.jsxs("div",{className:"bg-task-line2",children:[!u&&s.jsxs("span",{children:[n("bgTaskPid")," ",l.pid]}),s.jsxs("span",{children:[n("bgTaskSince")," ",X0(l.since,n)]}),u&&l.status&&s.jsx("span",{className:"bg-task-status",children:l.status})]}),l.command&&s.jsxs("button",{type:"button",className:`bg-task-cmd ${i.has(p)?"open":""}`,title:`${n("bgTaskCommand")}: ${l.command}`,onClick:()=>o(p),children:[s.jsx(Ln,{}),s.jsx("code",{children:l.command})]})]}),s.jsxs("button",{type:"button",className:"btn bg-task-stop",title:n("bgTaskStop"),onClick:()=>ae(u?{type:"kill_background_server",taskId:l.taskId}:{type:"kill_background_server",port:l.port}),children:[s.jsx(un,{}),s.jsx("span",{children:n("bgTaskStop")})]})]},p)})}),s.jsxs("div",{className:"bg-task-foot",children:[s.jsxs("button",{type:"button",className:"btn",title:n("bgTaskRefresh"),onClick:()=>ae({type:"list_bg_servers"}),children:[s.jsx(kt,{}),s.jsx("span",{children:n("bgTaskRefresh")})]}),s.jsxs("button",{type:"button",className:"btn bg-task-stopall",disabled:e.length===0,title:n("bgTaskStopAll"),onClick:()=>ae({type:"kill_background_servers"}),children:[s.jsx(un,{}),s.jsx("span",{children:n("bgTaskStopAll")})]})]})]})})}function Z0(e,t){return e.toLowerCase().includes(t)}function eg({open:e,projects:t,fileSearch:n,sessionSearch:i,onClose:a,onSwitchSession:o,onSwitchProject:l,onPreviewFile:u}){const p=je(),E=Ct("cwd"),m=c.useRef(null),[f,w]=c.useState(""),N=c.useDeferredValue(f),[C,M]=c.useState(0),W=c.useRef(1),_=c.useRef(0),D=c.useRef(null);c.useEffect(()=>{if(!e)return;ae({type:"list_sessions"}),ae({type:"list_projects"});const R=f.trim();if(R){const F=++W.current;_.current=F,H(!0),ae({type:"search_files",reqId:F,query:R}),ae({type:"search_sessions",reqId:F,query:R})}requestAnimationFrame(()=>m.current?.select())},[e]);const[I,H]=c.useState(!1);c.useEffect(()=>{D.current&&clearTimeout(D.current);const R=N.trim();if(!R){H(!1);return}return D.current=setTimeout(()=>{const F=++W.current;_.current=F,H(!0),ae({type:"search_files",reqId:F,query:R}),ae({type:"search_sessions",reqId:F,query:R})},300),()=>{D.current&&clearTimeout(D.current)}},[N]);const te=N.trim().toLowerCase(),ee=c.useMemo(()=>!te||!i||i.reqId!==_.current||!i.ok?[]:i.results,[i,te]),le=c.useMemo(()=>te?t.filter(R=>Z0(R.path,te)).slice(0,10):[],[t,te]),pe=c.useMemo(()=>!te||!n||n.reqId!==_.current||!n.ok?[]:n.results,[n,te]);c.useEffect(()=>{n&&n.reqId===_.current&&i&&i.reqId===_.current&&_.current!==0&&H(!1)},[n,i]);const Q=!!n&&n.ok&&n.truncated,G=c.useMemo(()=>[...ee.map(R=>({kind:"session",path:R.path,anchors:R.anchors})),...le.map(R=>({kind:"project",path:R.path})),...pe.filter(R=>R.type==="file").map(R=>({kind:"file",path:R.path,name:R.name}))],[ee,le,pe]);c.useEffect(()=>{M(0)},[N]);const ce=c.useCallback(R=>{if(R)if(R.kind==="session")o(R.path,R.anchors),a();else if(R.kind==="project"){l(R.path),ae({type:"list_sessions"}),ae({type:"list_projects"});const F=N.trim();if(F){const v=++W.current;_.current=v,H(!0),ae({type:"search_files",reqId:v,query:F}),ae({type:"search_sessions",reqId:v,query:F})}}else u(R.path,R.name)},[o,l,u,N]);c.useEffect(()=>{if(!e)return;const R=F=>{F.key==="Escape"?(F.preventDefault(),F.stopPropagation(),a()):F.key==="ArrowDown"?(F.preventDefault(),M(v=>Math.min(v+1,G.length-1))):F.key==="ArrowUp"?(F.preventDefault(),M(v=>Math.max(v-1,0))):F.key==="Enter"&&(F.preventDefault(),ce(G[C]))};return window.addEventListener("keydown",R,!0),()=>window.removeEventListener("keydown",R,!0)},[G,C,ce,a,e]);const O=ee.length+le.length+pe.length,B=(R,F,v)=>s.jsxs("div",{className:"gs-section-head",children:[v,s.jsx("span",{children:R}),s.jsx("em",{children:F})]});let x=-1;return e?s.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:a,children:s.jsxs("div",{className:"gs-modal",onClick:R=>R.stopPropagation(),children:[s.jsxs("div",{className:"gs-input-row",children:[s.jsx(pn,{}),s.jsx("input",{ref:m,type:"text",value:f,placeholder:p("gsPlaceholder"),onChange:R=>w(R.target.value)}),s.jsx("button",{type:"button",className:"gs-close",title:p("close"),onClick:a,children:s.jsx(Ke,{})})]}),s.jsxs("div",{className:"gs-results",children:[!te&&s.jsx("div",{className:"gs-empty",children:p("gsHint")}),te&&O===0&&!Q&&s.jsx("div",{className:"gs-empty",children:p(I?"gsSearching":"gsNoResults")}),ee.length>0&&s.jsxs("div",{className:"gs-section",children:[B(p("gsSessions"),ee.length,s.jsx(rs,{})),ee.map(R=>{x++;const F=x;return s.jsxs("button",{type:"button",className:F===C?"gs-item active":"gs-item",onMouseEnter:()=>M(F),onClick:()=>ce({kind:"session",path:R.path,anchors:R.anchors}),children:[s.jsxs("span",{className:"gs-item-title",children:[R.name||R.path.split(/[\\/]/).pop(),s.jsx("em",{className:"gs-item-meta",children:R.messageCount})]}),s.jsx("span",{className:"gs-item-sub",children:R.firstMessage})]},R.path)})]}),le.length>0&&s.jsxs("div",{className:"gs-section",children:[B(p("gsProjects"),le.length,s.jsx(Bt,{})),le.map(R=>{x++;const F=x,v=E&&R.path===E;return s.jsxs("button",{type:"button",className:F===C?"gs-item active":"gs-item",onMouseEnter:()=>M(F),onClick:()=>ce({kind:"project",path:R.path}),children:[s.jsxs("span",{className:"gs-item-title",children:[R.path.split(/[\\/]/).pop(),v&&s.jsx("em",{className:"gs-item-meta",children:p("gsCurrentProject")})]}),s.jsx("span",{className:"gs-item-sub",children:R.path})]},R.path)})]}),(pe.length>0||te&&Q)&&s.jsxs("div",{className:"gs-section",children:[B(p("gsFiles"),pe.length,s.jsx(Dr,{})),pe.map(R=>{x++;const F=x;return s.jsxs("button",{type:"button",className:F===C?"gs-item active":"gs-item",disabled:R.type==="dir",title:R.type==="dir"?void 0:p("gsOpenPreview"),onMouseEnter:()=>M(F),onClick:()=>{R.type==="file"&&ce({kind:"file",path:R.path,name:R.name})},children:[s.jsx("span",{className:"gs-item-title",children:R.name}),s.jsx("span",{className:"gs-item-sub",children:R.path})]},`${R.type}:${R.path}`)}),Q&&s.jsx("div",{className:"gs-truncated",children:p("gsTruncated")})]})]}),s.jsxs("div",{className:"gs-foot",children:[s.jsxs("span",{children:["↑↓ ",p("gsNavigate")]}),s.jsxs("span",{children:["Enter ",p("gsOpen")]}),s.jsxs("span",{children:["Esc ",p("gsCloseHint")]})]})]})}):null}const na=5e3;function tg({file:e,content:t,onAddLines:n,onAttach:i,onClose:a}){const o=je(),[l,u]=c.useState(null),[p,E]=c.useState(!1),[m,f]=c.useState(null),[w,N]=c.useState(!1),[C,M]=c.useState(!1),[W,_]=c.useState(!1),[D,I]=c.useState(""),[H,te]=c.useState(!0),[ee,le]=c.useState(!0),[pe,Q]=c.useState(!1),G=c.useRef(!1),[ce,O]=c.useState(!0),[B,x]=c.useState(!1),[R,F]=c.useState(100),v=c.useRef(0),se=c.useRef(!1),K=c.useRef(null);c.useEffect(()=>{E(!0),u(null),f(null),_(!1),I(""),te(!0),le(!0),Q(!1),G.current=!1,ae({type:"read_file",path:e.path})},[e.path]),c.useEffect(()=>{t&&t.path===e.path&&(u(t),W||I(t.text),E(!1))},[t,W,e.path]),c.useEffect(()=>{const S=z=>{if(z.key==="Escape"){$();return}if((z.ctrlKey||z.metaKey)&&z.key.toLowerCase()==="s"&&W){z.preventDefault(),oe();return}const ue=z.target,Ne=ue&&(ue.tagName==="INPUT"||ue.tagName==="TEXTAREA"||ue.isContentEditable);(z.ctrlKey||z.metaKey)&&z.key.toLowerCase()==="a"&&!Ne&&(z.preventDefault(),de())};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[a,l,W,D]),c.useEffect(()=>{const S=()=>{se.current=!1,N(!1)};return window.addEventListener("mouseup",S),()=>window.removeEventListener("mouseup",S)},[]);const xe=c.useMemo(()=>{if(!l)return[];const S=l.text.split(`
|
|
348
|
+
`);return S.length>0&&S[S.length-1]===""&&S.pop(),S.slice(0,na)},[l]),k=l?.lines??0,Y=k>na,re=(S,z)=>{if(z){const ue=v.current>0?v.current:S;f({start:Math.min(ue,S),end:Math.max(ue,S)})}else v.current=S,f({start:S,end:S})},de=()=>{xe.length!==0&&(v.current=1,f({start:1,end:xe.length}))},we=()=>{m&&(n(e.path,e.name,m.start,m.end),M(!0),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>M(!1),1400))},ie=l!==null&&l.kind==="text"&&!l.binary&&!l.truncated,me=()=>{I(l?.text??""),_(!1),G.current&&(Ts(e.name)&&te(!0),xs(e.name)&&le(!0))},X=()=>{if(W){if(D!==(l?.text??"")&&!window.confirm(o("discardFileChanges")))return;me();return}!ie||!l||(G.current=Ts(e.name)&&H||xs(e.name)&&ee,Ts(e.name)&&te(!1),xs(e.name)&&le(!1),f(null),I(l.text),_(!0))},oe=()=>{!W||!l||!ie||ae({type:"write_file",path:e.path,text:D})&&(_(!1),G.current&&(Ts(e.name)&&te(!0),xs(e.name)&&le(!0)),f(null))},$=()=>{W&&D!==(l?.text??"")&&!window.confirm(o("discardFileChanges"))||a()},Ie=S=>{F(Math.min(200,Math.max(50,S)))},Le=m?m.end-m.start+1:0,P=l?.binary??!1,ye=l?.truncated??!1,he=l?.kind??"text",be=Ts(e.name),Te=xs(e.name),Ce=be&&H&&!W&&he==="text"&&!P,ke=Te&&ee&&!W&&he==="text"&&!P,y=S=>vt(tt(`/api/file?clientId=${encodeURIComponent(xn())}&path=${encodeURIComponent(S)}`)),b=S=>{const z=S.split("/").map(De=>encodeURIComponent(De)).join("/"),Ne=/^[A-Za-z]:([\\/]|$)/.test(S)||S.startsWith("/")?`/api/preview/__abs__/${z}`:`/api/preview/${z}`;return vt(tt(`${Ne}?clientId=${encodeURIComponent(xn())}${pe?"&allowJs=1":""}`))};return s.jsx("div",{className:`fp-overlay ${B?"fullscreen":""}`,onMouseDown:S=>{S.target===S.currentTarget&&$()},children:s.jsxs("div",{className:`fp ${B?"fullscreen":""}`,style:{"--fp-zoom":R/100},children:[s.jsxs("div",{className:"fp-head",children:[s.jsx("span",{className:"fp-name",title:e.path,children:e.name}),s.jsx("span",{className:"fp-path",children:e.path}),s.jsxs("span",{className:"fp-meta",children:[l&&he==="text"&&!P&&o("fileLines",{n:k}),l&&` · ${sg(l.size)}`]}),s.jsxs("span",{className:"fp-head-actions",children:[be&&he==="text"&&!P&&l&&s.jsx("button",{type:"button",className:`fp-attach markdown ${H?"on":""}`,"data-tip":o(H?"showMarkdownSource":"showMarkdownPreview"),disabled:W,onClick:()=>te(S=>!S),children:H?s.jsx(hn,{}):s.jsx(ni,{})}),Te&&he==="text"&&!P&&l&&s.jsx("button",{type:"button",className:`fp-attach html ${ee?"on":""}`,"data-tip":o(ee?"showHtmlSource":"showHtmlPreview"),disabled:W,onClick:()=>le(S=>!S),children:ee?s.jsx(ni,{}):s.jsx(hn,{})}),he==="text"&&!P&&l&&s.jsx("button",{type:"button",className:`fp-attach edit ${W?"on":""}`,"data-tip":o(ye?"fileEditTruncated":W?"exitEditFile":"editFile"),disabled:!ie&&!W,onClick:X,children:s.jsx(fn,{})}),he==="text"&&!P&&!Ce&&!ke&&s.jsx("button",{type:"button",className:`fp-attach wrap ${ce?"on":""}`,"data-tip":o(ce?"disableWrap":"enableWrap"),onClick:()=>O(S=>!S),children:s.jsx(Lc,{})}),he==="text"&&l&&s.jsxs("span",{className:"fp-zoom",children:[s.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":o("zoomOut"),disabled:R<=50,onClick:()=>Ie(R-10),children:s.jsx(pc,{})}),s.jsxs("button",{type:"button",className:"fp-zoom-val",title:o("resetZoom"),onClick:()=>F(100),children:[R,"%"]}),s.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":o("zoomIn"),disabled:R>=200,onClick:()=>Ie(R+10),children:s.jsx(mc,{})})]}),he!=="video"&&he!=="none"&&s.jsx("button",{type:"button",className:"fp-attach inline","data-tip":o("attachInlineTip"),onClick:()=>i(e.path,e.name,"inline"),children:s.jsx(dt,{})}),s.jsx("button",{type:"button",className:"fp-attach ref","data-tip":o("referenceTip"),onClick:()=>i(e.path,e.name,"reference"),children:s.jsx(oa,{})}),s.jsx("button",{type:"button",className:`fp-attach full ${B?"on":""}`,"data-tip":o(B?"exitFullscreen":"fullscreen"),onClick:()=>x(S=>!S),children:B?s.jsx(yc,{}):s.jsx(kc,{})}),s.jsx("button",{type:"button",className:"fp-close",title:o("close"),onClick:$,children:s.jsx(Ke,{})})]})]}),ye&&he==="text"&&!P&&s.jsx("div",{className:"fp-notice",children:o("previewTruncated")}),p&&!l&&s.jsx("div",{className:"fp-empty",children:o("loading")}),!p&&he==="none"&&!P&&s.jsx("div",{className:"fp-empty",children:o("previewNotSupported")}),!p&&he==="image"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("img",{className:"fp-media",src:y(e.path),alt:e.name})}),!p&&he==="video"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("video",{className:"fp-media",src:y(e.path),controls:!0,preload:"metadata"})}),!p&&ke&&l&&s.jsxs("div",{className:"fp-html",children:[s.jsxs("div",{className:"fp-html-bar",children:[s.jsx("span",{className:"fp-html-hint",title:o(pe?"htmlJsOnTip":"htmlJsOffTip"),children:o(pe?"htmlJsOn":"htmlJsOff")}),s.jsx("button",{type:"button",className:`fp-html-js ${pe?"on":""}`,"data-tip":o(pe?"htmlDisableJs":"htmlEnableJs"),onClick:()=>Q(S=>!S),children:o(pe?"htmlDisableJs":"htmlEnableJs")})]}),s.jsx("iframe",{className:"fp-html-frame",src:b(e.path),title:e.name,sandbox:pe?"allow-scripts":"",referrerPolicy:"no-referrer"},pe?"js":"nojs")]}),!p&&Ce&&l&&s.jsx("div",{className:"fp-markdown msg-text",children:s.jsx("div",{className:"fp-markdown-zoom",children:s.jsx(rt,{text:l.text})})}),!p&&P&&he!=="image"&&he!=="video"&&l&&s.jsxs("div",{className:"fp-hex-wrap",children:[s.jsxs("div",{className:"fp-notice",children:[o("binaryFile"),l.truncated&&o("binaryHexTruncated")]}),s.jsx("pre",{className:"fp-hex",children:l.text})]}),!p&&W&&he==="text"&&!P&&l&&s.jsx("textarea",{className:`fp-editor ${ce?"":"no-wrap"}`,value:D,onChange:S=>I(S.target.value),wrap:ce?"soft":"off",spellCheck:!1,autoFocus:!0}),!p&&!Ce&&!ke&&!W&&he==="text"&&!P&&l&&xe.length===0&&s.jsx("div",{className:"fp-empty",children:o("emptyFile")}),!p&&!Ce&&!ke&&!W&&he==="text"&&!P&&xe.length>0&&s.jsxs("div",{className:`fp-code ${w?"dragging":""} ${ce?"":"no-wrap"}`,onMouseDown:S=>{S.button===0&&S.preventDefault()},children:[xe.map((S,z)=>{const ue=z+1,Ne=m!==null&&ue>=m.start&&ue<=m.end;return s.jsxs("div",{className:`fp-line ${Ne?"sel":""}`,onMouseDown:De=>{De.button===0&&(re(ue,De.shiftKey),se.current=!0,N(!0))},onMouseEnter:()=>{se.current&&re(ue,!0)},children:[s.jsx("span",{className:"fp-num",children:ue}),s.jsx("span",{className:"fp-code-text",children:S})]},ue)}),Y&&s.jsx("div",{className:"fp-lines-note",children:o("previewLinesTruncated",{n:na})})]}),s.jsx("div",{className:"fp-foot",children:W?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:o("editFile")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:X,children:o("cancel")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:D===(l?.text??""),onClick:oe,children:[s.jsx(bc,{})," ",o("saveFile")]})]})]}):!Ce&&!ke&&he==="text"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:m?o("selectedRange",{n:Le,start:m.start,end:m.end}):o("selectLinesHint")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",disabled:xe.length===0,onClick:de,children:o("selectAll")}),s.jsx("button",{type:"button",className:"btn",disabled:!m,onClick:()=>f(null),children:o("clearSelection")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!m||P,onClick:we,children:[C?s.jsx(Tt,{}):null,o(C?"addedToChat":"addToChat")]})]})]})})]})})}function Ts(e){const t=e.toLowerCase();return t.endsWith(".md")||t.endsWith(".markdown")}function xs(e){const t=e.toLowerCase();return t.endsWith(".html")||t.endsWith(".htm")||t.endsWith(".xhtml")}function sg(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}const _l="pi-web-sounds",ys={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function wl(){try{const e=localStorage.getItem(_l);if(!e)return{...ys};const t=JSON.parse(e),n={...ys,...t};for(const i of["enabled","question","done","start","error"])typeof n[i]!="boolean"&&(n[i]=ys[i]);return typeof n.volume!="number"||!Number.isFinite(n.volume)?n.volume=ys.volume:n.volume=Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...ys}}}function ng(e){try{localStorage.setItem(_l,JSON.stringify(e))}catch{}}let Ns=null;function ag(){try{if(!Ns){const e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Ns=new e}return Ns.state==="suspended"&&Ns.resume(),Ns}catch{return null}}const ig=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],rg=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],og=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],lg=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],cg={question:ig,done:rg,start:og,error:lg};function ug(e,t,n){const i=e.createOscillator(),a=e.createGain();i.type=t.type,i.frequency.value=t.freq;const o=e.currentTime+t.start,l=Math.max(1e-4,t.peak*n);a.gain.setValueAtTime(1e-4,o),a.gain.exponentialRampToValueAtTime(l,o+.012),a.gain.exponentialRampToValueAtTime(1e-4,o+t.dur),i.connect(a),a.connect(e.destination),i.start(o),i.stop(o+t.dur+.05)}function ts(e,t=wl()){if(!t.enabled||!t[e])return;const n=ag();if(!n)return;const i=Math.max(0,Math.min(1,t.volume/100));for(const a of cg[e])ug(n,a,i)}const dg=c.lazy(()=>ac(()=>import("./TerminalPanel-BF99sld0.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.TerminalPanel})));function pg({notice:e,onDismiss:t}){const n=je(),{locale:i}=Ht(),a=i!=="zh"&&e.textEn?e.textEn:e.text,[o,l]=c.useState(!1);c.useEffect(()=>{if(o)return;const p=setTimeout(()=>t(e.id),e.level==="error"?12e3:7e3);return()=>clearTimeout(p)},[o,e.id,e.level,t]);const u=e.level==="error"?Mc:e.level==="warning"?Oc:Sc;return s.jsxs("div",{className:`notice notice-${e.level}${o?" paused":""}`,role:"status",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[s.jsx(u,{className:"notice-icon"}),s.jsx("span",{className:"notice-text",children:a}),s.jsx("button",{type:"button",className:"notice-close",title:n("close"),onClick:()=>t(e.id),children:s.jsx(Ke,{})})]})}const mg=[],Sl=180,Al=520,Il=240,jl=e=>`pi-web-ui:${e}-panel-width`;function Er(e){const t=Number(localStorage.getItem(jl(e)));return Number.isFinite(t)&&t>=Sl&&t<=Al?t:Il}const ja=e=>`pi-web-ui:${e}-panel-collapsed`;function Tr(e){return localStorage.getItem(ja(e))==="1"}function xr({side:e,width:t,onResize:n}){const i=je(),a=c.useCallback(o=>{o.preventDefault();const l=o.clientX,u=t;let p=u;const E=f=>{const w=e==="left"?f.clientX-l:l-f.clientX;p=Math.min(Al,Math.max(Sl,Math.round(u+w))),n(p)},m=()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",m),document.body.classList.remove("panel-resizing"),localStorage.setItem(jl(e),String(p))};window.addEventListener("pointermove",E),window.addEventListener("pointerup",m),document.body.classList.add("panel-resizing")},[e,t,n]);return s.jsx("div",{className:`resize-handle resize-${e}`,title:i("dragToResize"),onPointerDown:a,onDoubleClick:()=>n(Il)})}function yr({side:e,onClick:t}){const n=je();return s.jsx("button",{type:"button",className:`panel-rail panel-rail-${e}`,title:n("expandPanel"),onClick:t,children:e==="left"?s.jsx(Pr,{}):s.jsx(Or,{})})}function hg(){const e=je(),{locale:t}=Ht(),{chat:n,send:i,dismissNotice:a,pushNotice:o,terminal:l}=Xu(),u=c.useRef(!1);c.useEffect(()=>{!n.ready||!n.settings||u.current||n.settings.quickPhrasesSeeded||(u.current=!0,n.settings.quickPhrases.length===0&&i({type:"set_settings",quickPhrases:In[t]??In.en,quickPhrasesSeeded:!0}))},[n.ready,n.settings,i,t]);const p=n.state?.cwd??"",E=bl();c.useEffect(()=>{const q=E?D0(p):"";document.title=q?`${q} — pi-web-ui`:e("docTitle")},[p,E,e]);const[m,f]=c.useState([]);c.useEffect(()=>(li(q=>f(Ee=>Vf(Ee,q))),()=>li(null)),[]);const[w,N]=c.useState(null),[C,M]=c.useState(!1);c.useEffect(()=>{const q=()=>M(!1);return window.addEventListener("drop",q,!0),()=>window.removeEventListener("drop",q,!0)},[]);const[W,_]=c.useState("chat"),D=q=>!n.tabs||q==="chat"||n.tabs.includes(q),I=W.startsWith("plugin:")?"plugins":W,H=D(I)?W:"chat",te=c.useMemo(()=>n.plugins.filter(q=>!n.settings?.disabledPlugins?.includes(q.id)),[n.plugins,n.settings?.disabledPlugins]),[ee,le]=c.useState([]);c.useEffect(()=>Bu(le),[]),c.useEffect(()=>{Th(i),xh(te,n.pluginsEpoch),Fu(te,n.pluginsEpoch)},[te,n.pluginsEpoch,i]);const pe=c.useRef(n);pe.current=n;const Q=c.useRef(_);Q.current=_,c.useEffect(()=>(fr(v0({send:i,isReady:()=>!!pe.current.state,setView:q=>Q.current(q),getCwd:()=>pe.current.state?.cwd??"",getConversationId:()=>pe.current.state?.conversationId??null,isConversationBlank:()=>(pe.current.state?.messages.length??0)===0})),()=>fr(null)),[i]);const[G,ce]=c.useState(()=>Er("left")),[O,B]=c.useState(()=>Er("right")),x=c.useCallback(q=>ce(q),[]),R=c.useCallback(q=>B(q),[]),[F,v]=c.useState(()=>Tr("left")),[se,K]=c.useState(()=>Tr("right")),xe=c.useCallback(()=>{v(q=>(localStorage.setItem(ja("left"),q?"0":"1"),!q))},[]),k=c.useCallback(()=>{K(q=>(localStorage.setItem(ja("right"),q?"0":"1"),!q))},[]),[Y,re]=c.useState(null),[de,we]=c.useState(()=>window.matchMedia("(max-width: 768px)").matches);c.useEffect(()=>{const q=window.matchMedia("(max-width: 768px)"),Ee=Re=>we(Re.matches);return q.addEventListener("change",Ee),()=>q.removeEventListener("change",Ee)},[]);const[ie,me]=c.useState(!1),[X,oe]=c.useState(!1),[$,Ie]=c.useState(!1),Le=hl(),[P,ye]=c.useState(!1),[he,be]=c.useState(!1),[Te,Ce]=c.useState(null);c.useEffect(()=>{if(!Te)return;const q=setTimeout(()=>Ce(null),15e3);return()=>clearTimeout(q)},[Te]),c.useEffect(()=>{const q=Re=>{const Ue=Re.detail,ze=Ue?.title||e("pluginCommandFallback"),Lt=Ue?.command;if(!Lt||!n.ready)return;const st={name:ze,command:Lt,cwd:"${pwd}"},lt=n.terminals.find(ht=>ht.title===ze);if(lt)l.restart(lt.id),i({type:"run_command",terminalId:lt.id,conversationId:lt.conversationId,command:st,cols:80,rows:24});else{const ht=St();l.create({id:ht,conversationId:n.activeConversationId||n.state?.conversationId||"",title:ze,cwd:n.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:st})}_("terminal")};window.addEventListener("pi-web-ui:plugin-run-command",q);const Ee=Re=>{const Ue=Re.detail;typeof Ue=="string"&&Ue&&i({type:"switch_conversation",id:Ue})};return window.addEventListener("pi-web-ui:switch-conversation",Ee),()=>{window.removeEventListener("pi-web-ui:plugin-run-command",q),window.removeEventListener("pi-web-ui:switch-conversation",Ee)}},[n,l,i]),c.useEffect(()=>{const q=Ee=>{!(Ee.ctrlKey||Ee.metaKey)||Ee.key.toLowerCase()!=="k"||(Ee.preventDefault(),be(Re=>!Re))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const[ke,y]=c.useState(wl),{themes:b,theme:S,switchTheme:z}=Ch();Y0();const ue=c.useRef(null),Ne=c.useRef(null),De=c.useRef(null),A=c.useRef(0),fe=c.useRef(!1),Ae=c.useRef(n.terminals);c.useEffect(()=>{ng(ke)},[ke]),c.useEffect(()=>{const q=Ae.current;Ae.current=n.terminals;for(const Ee of n.terminals){const Re=Ee.command?.command??"";!q.find(ze=>ze.id===Ee.id)?.running||Ee.running||(Re.startsWith("pi remove ")?i({type:"extensions_reload"}):Re.startsWith("pi-web-ui install ")||Re.startsWith("pi-web-ui uninstall ")?i({type:"plugins_reload"}):Re.startsWith("npm i -g ")&&(i({type:"extensions_reload"}),i({type:"plugins_reload"}),i({type:"check_updates_all",force:!0})))}},[n.terminals,i]),c.useEffect(()=>{const q=n.state?.isStreaming??!1,Ee=ue.current;ue.current=q,Ee!==null&&(!Ee&&q?ts("start",ke):Ee&&!q&&(ts("done",ke),Ks(e("notifyDoneTitle"),e("notifyDoneBody"))))},[n.state?.isStreaming,ke]),c.useEffect(()=>{const q=n.dialog?.id??null;q!==null&&q!==Ne.current&&(ts("question",ke),Ks(e("notifyQuestionTitle"),e("notifyQuestionBody"))),Ne.current=q},[n.dialog,ke]),c.useEffect(()=>{const q=n.question?.id??null;q!==null&&q!==De.current&&(ts("question",ke),Ks(e("notifyQuestionTitle"),e("notifyQuestionBody"))),De.current=q},[n.question,ke]),c.useEffect(()=>{const q=[...n.notices].reverse().find(Ee=>Ee.level==="error");q&&q.id!==A.current&&(A.current=q.id,ts("error",ke),Ks(e("notifyErrorTitle"),e("notifyErrorBody")))},[n.notices,ke]);const Fe=(q,Ee,Re,Ue=!1,ze)=>{const Lt=`${q}|${Re}|${ze?`${ze.start}-${ze.end}`:""}`;f(st=>st.some(lt=>`${lt.path}|${lt.mode}|${lt.lines?`${lt.lines.start}-${lt.lines.end}`:""}`===Lt)?st:[...st,{path:q,name:Ee,mode:Re,isDir:Ue,...ze?{lines:ze}:{}}])},Me=q=>f(Ee=>Ee.filter(Re=>Re.key?Re.key!==q:Re.path!==q)),Ge=c.useCallback(q=>(!q.type.startsWith("list_")&&!q.type.startsWith("get_")&&re(null),i(q)),[i]),Xt=c.useRef(0),At=c.useRef(0),Ut=q=>{const Ee=Date.now();n.state?.model&&!n.state.model.vision&&Ee-At.current>1e4&&(At.current=Ee,o("warning",e("imageNotSupported")));const Re=`paste-${++Xt.current}`;f(Ue=>[...Ue,{path:"",key:Re,name:q.name,mode:"inline",imageData:q.data,mimeType:q.mimeType}])},pt=async q=>{for(const Ee of q){const Re=await $a(Ee);if(!Re){o("error",e("imageLoadFailed",{name:Ee.name}));continue}Ut(Re)}},$t=20*1024*1024,xt=c.useRef(0),qt=async q=>{if(q.size>$t){o("warning",e("fileTooLarge",{name:q.name,size:$t/1024/1024}));return}let Ee;try{Ee=(await new Promise((ze,Lt)=>{const st=new FileReader;st.onload=()=>ze(st.result),st.onerror=()=>Lt(st.error??new Error("read failed")),st.readAsDataURL(q)})).replace(/^data:[^;]*;base64,/,"")}catch{o("error",e("fileLoadFailed",{name:q.name}));return}const Re=`upload-${++xt.current}`;f(Ue=>[...Ue,{path:"",key:Re,name:q.name,mode:"inline",fileData:Ee,size:q.size,mimeType:q.type||void 0}])},It=async q=>{for(const Ee of q)_t(Ee.type)?await pt([Ee]):await qt(Ee)},L=c.useCallback((q,Ee,Re)=>{i({type:"edit_message",messageId:q,text:Ee,attachments:Re})},[i]),V=c.useCallback((q,Ee)=>{i({type:"queue_remove",kind:q,text:Ee})},[i]),[Se,_e]=c.useState([]),Pe=c.useRef(0),He=c.useCallback((q,Ee)=>{i({type:"queue_remove",kind:q,text:Ee}),Pe.current+=1;const Re={text:Ee,seq:Pe.current};_e(Ue=>[...Ue.slice(-9),Re])},[i]),ot=c.useCallback(()=>oe(!0),[]),yt=c.useCallback(()=>f([]),[]),ms=c.useCallback(Me,[]),mt=c.useCallback(pt,[pt]),Bn=c.useCallback(It,[It]),jt=n.state?.model,Hs=n.state?.thinkingLevel,Us=n.state?.availableThinkingLevels,Be=c.useMemo(()=>jt?{model:jt,thinkingLevel:Hs??"off",availableThinkingLevels:Us??[]}:null,[jt,Hs,Us]),Jt=c.useCallback(()=>!n.ready||n.terminals.length!==0?!1:(l.create({id:St(),conversationId:n.activeConversationId||n.state?.conversationId||"",title:e("terminalTitle",{n:1}),cwd:n.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null}),!0),[n.ready,n.state?.cwd,n.terminals.length,e,l]);return c.useEffect(()=>{if(fe.current){if(H!=="terminal"||n.terminals.length!==0){fe.current=!1;return}Jt()&&(fe.current=!1)}},[n.terminals.length,Jt,H]),s.jsxs("div",{className:"app",onDragOver:q=>{Array.from(q.dataTransfer?.types??[]).includes("Files")&&(q.preventDefault(),M(!0))},onDragLeave:q=>{q.currentTarget.contains(q.relatedTarget)||M(!1)},onDrop:q=>{if(M(!1),!Array.from(q.dataTransfer?.types??[]).includes("Files"))return;q.preventDefault();const Ee=Array.from(q.dataTransfer?.files??[]);if(Ee.length===0){o("warning",e("foldersNotSupported"));return}const Re=Ee.filter(ze=>_t(ze.type)),Ue=Ee.filter(ze=>!_t(ze.type));Re.length>0&&pt(Re),Ue.length>0&&It(Ue)},children:[C&&s.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:s.jsxs("span",{children:["📎 ",e("dropHereToAttach")]})}),s.jsx(Cu,{chat:n,terminal:l,view:H,plugins:te,onViewChange:q=>{fe.current=q==="terminal"&&n.terminals.length===0,fe.current&&Jt()&&(fe.current=!1),_(q),re(null)},onOpenPanel:re,onOpenSettings:()=>Ie(!0),onOpenBgTasks:()=>ye(!0),onOpenGlobalSearch:()=>be(!0),sound:ke,onSoundChange:y,onSoundPreview:q=>ts(q,ke),themes:b,theme:S,onThemeChange:z}),n.protocolMismatch&&s.jsxs("div",{className:"protocol-banner",children:["⚠ ",e("protocolMismatch")]}),s.jsx("div",{className:"notices",children:n.notices.map(q=>s.jsx(pg,{notice:q,onDismiss:a},q.id))}),s.jsx(Hf,{currentModelId:jt?`${jt.provider}/${jt.id}`:null,children:s.jsxs("div",{className:"layout",style:{"--left-w":`${G}px`,"--right-w":`${O}px`},children:[Y&&s.jsx("div",{className:"drawer-backdrop",onClick:()=>re(null)}),s.jsxs("div",{className:`view-pane ${H==="chat"?"":"hidden"}`,children:[!de&&F&&s.jsx(yr,{side:"left",onClick:xe}),s.jsx("div",{className:`panel-drawer drawer-left ${Y==="left"?"open":""}${de?"":F?" hidden":""}`,children:s.jsx(Lu,{collapsible:!de,onToggleCollapse:xe,panelSend:Ge,active:!de||Y==="left",sessionFile:n.state?.sessionFile??null,conversations:n.conversations,sessions:n.sessions,projects:n.projects,activeConversationId:n.activeConversationId})}),!de&&s.jsx(xr,{side:"left",width:G,onResize:x}),s.jsxs("main",{className:Le?"main wide-chat":"main",children:[n.state?s.jsx(Gf,{state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:L,onKillBash:()=>i({type:"abort_bash"}),onRetry:()=>{if(i({type:"retry_last"})){const q=n.state?.model;q&&wn(`${q.provider}/${q.id}`)}},onRemoveQueued:V,onRecallQueued:He,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,jumpTarget:Te,onJumpDone:()=>Ce(null)},n.state.conversationId??"boot"):s.jsx("div",{className:"boot-wait",children:n.ready?e("loadingSession"):e("connectingServer")}),n.settings?.goalModeEnabled!==!1&&s.jsx(u0,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId}),n.dialog&&s.jsx(b0,{dialog:n.dialog}),n.question&&s.jsx(E0,{question:n.question}),s.jsx(c0,{streaming:n.state?.isStreaming??!1,messages:n.state?.messages??mg,slashCommands:n.slashCommands,modelState:Be,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,attachments:m,onRemoveAttachment:ms,onAddImageFiles:mt,onAddLocalFiles:Bn,onNotice:o,onManageModels:ot,onSent:yt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:Se})]}),!de&&s.jsx(xr,{side:"right",width:O,onResize:R}),s.jsx("div",{className:`panel-drawer drawer-right ${Y==="right"?"open":""}${de?"":se?" hidden":""}`,children:s.jsx(rd,{collapsible:!de,onToggleCollapse:k,panelSend:Ge,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(q,Ee,Re,Ue)=>{re(null),Fe(q,Ee,Re,Ue)},onPreview:(q,Ee)=>{re(null),N({path:q,name:Ee})},onNotice:(q,Ee)=>o(q,Ee)})}),!de&&se&&s.jsx(yr,{side:"right",onClick:k})]}),s.jsx("div",{className:`view-pane ${H==="terminal"?"":"hidden"}`,children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(dg,{chat:n,terminal:l})})}),s.jsx("div",{className:`view-pane ${H==="git"?"":"hidden"}`,children:s.jsx(x0,{chat:n,terminal:l,active:H==="git",onSwitchToTerminal:()=>_("terminal")})}),ee.map(q=>{const Ee=`plugin:${q.info.id}`;return s.jsx("div",{className:`view-pane ${H===Ee?"":"hidden"}`,children:s.jsx(y0,{entry:q})},q.info.id)})]})}),s.jsx(f0,{chat:n}),w&&s.jsx(tg,{file:w,content:n.fileContent,onAddLines:(q,Ee,Re,Ue)=>Fe(q,Ee,"lines",!1,{start:Re,end:Ue}),onAttach:(q,Ee,Re)=>Fe(q,Ee,Re),onClose:()=>N(null)}),n.ready&&n.state&&n.state.piConfigured===!1&&!ie&&!X&&s.jsx(C0,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,installResult:n.installResult,onClose:()=>me(!0)}),X&&s.jsx(S0,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,fetchModelsResult:n.fetchModelsResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>oe(!1)}),$&&s.jsx(Q0,{chat:n,terminal:l,onSwitchToTerminal:()=>_("terminal"),onClose:()=>Ie(!1)}),P&&s.jsx(J0,{servers:n.bgServers,onClose:()=>ye(!1)}),s.jsx(eg,{open:he,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>be(!1),onSwitchSession:(q,Ee)=>{i({type:"switch_session",path:q});const Re=Ee&&Ee[0];Ce(Re?{path:q,role:Re.role,timestamp:Re.timestamp}:null)},onSwitchProject:q=>{i({type:"set_cwd",path:q})},onPreviewFile:(q,Ee)=>{N({path:q,name:Ee})}})]})}function fg(){typeof document>"u"||(Ll(gg()),Eg())}function Ll(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty("--msgs-gutter",`${Math.round(e*100)/100}px`)}function gg(){const 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);const t=(e.offsetWidth-e.clientWidth)/2;return e.remove(),t}function bg(e){const t=document.createElement("div");t.style.cssText="width:0;height:0;pointer-events:none;",e.appendChild(t);const n=getComputedStyle(e),i=e.getBoundingClientRect(),a=t.getBoundingClientRect(),o=Number.parseFloat(n.borderLeftWidth)||0,l=Number.parseFloat(n.paddingLeft)||0,u=a.left-(i.left+o+l);return t.remove(),u}function Eg(){const e=()=>{const i=document.querySelector(".messages");return i?(Ll(bg(i)),!0):!1};let t=0;if(window.addEventListener("resize",()=>{t||(t=window.requestAnimationFrame(()=>{t=0,e()}))}),e())return;const n=new MutationObserver(()=>{e()&&n.disconnect()});n.observe(document.documentElement,{childList:!0,subtree:!0}),window.setTimeout(()=>n.disconnect(),6e4)}Uc();Wo(qo());fg();tc.createRoot(document.getElementById("root")).render(s.jsx(c.StrictMode,{children:s.jsx(Jc,{children:s.jsx(hg,{})})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=Fr();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(t=>{console.warn("Service worker registration failed:",t)})});export{kt as F,Mt as T,ae as a,Ng as b,je as c,dt as d,yg as e,gn as f,et as g,Nc as h,Ln as i,Ke as j,St as r,Ht as u};
|