pi-web-ui 0.80.2 → 0.81.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.
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-CeruoZjh.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 jl,s as wn,h as Sa,w as Wt,b as Ll,c as Rl,d as mr,o as ea,z as pr,e as Dl,g as Pl,p as Vt,v as Ol,i as hr,k as qa,M as Ml,l as Bl,m as Fl,n as fr,q as gr}from"./markdown-D3PKeHAZ.js";import{r as br}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={},$a;function Hl(){if($a)return Ws;$a=1;var e=br();return Ws.createRoot=e.createRoot,Ws.hydrateRoot=e.hydrateRoot,Ws}var Ul=Hl();const ql="modulepreload",$l=function(e){return"/"+e},Wa={},Wl=function(t,n,i){let a=Promise.resolve();if(n&&n.length>0){let l=function(E){return Promise.all(E.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),m=u?.nonce||u?.getAttribute("nonce");a=l(n.map(E=>{if(E=$l(E),E in Wa)return;Wa[E]=!0;const h=E.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${E}"]${g}`))return;const w=document.createElement("link");if(w.rel=h?"stylesheet":ql,h||(w.as="script"),w.crossOrigin="",w.href=E,m&&w.setAttribute("nonce",m),document.head.appendChild(w),h)return new Promise((k,_)=>{w.addEventListener("load",k),w.addEventListener("error",()=>_(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 Er={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ka=Kt.createContext&&Kt.createContext(Er),Kl=["attr","size","title"];function Yl(e,t){if(e==null)return{};var n,i,a=Gl(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 Gl(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 on(){return on=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},on.apply(null,arguments)}function Ya(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 ln(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ya(Object(n),!0).forEach(function(i){Vl(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ya(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Vl(e,t,n){return(t=zl(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function zl(e){var t=Ql(e,"string");return typeof t=="symbol"?t:t+""}function Ql(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 Tr(e){return e&&e.map((t,n)=>Kt.createElement(t.tag,ln({key:n},t.attr),Tr(t.child)))}function be(e){return t=>Kt.createElement(Xl,on({attr:ln({},e.attr)},t),Tr(e.child))}function Xl(e){var t=n=>{var i=e.attr,a=e.size,o=e.title,l=Yl(e,Kl),u=a||n.size||"1em",m;return n.className&&(m=n.className),e.className&&(m=(m?m+" ":"")+e.className),Kt.createElement("svg",on({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,i,l,{className:m,style:ln(ln({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 Ka!==void 0?Kt.createElement(Ka.Consumer,null,n=>t(n)):t(Er)}function Jl(e){return be({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 Zl(e){return be({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 be({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 be({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 xr(e){return be({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 Ga(e){return be({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 yr(e){return be({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 ec(e){return be({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 be({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 Va(e){return be({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 An(e){return be({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 za(e){return be({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 tc(e){return be({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 cn(e){return be({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 sc(e){return be({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 un(e){return be({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 ta(e){return be({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 dn(e){return be({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 nc(e){return be({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 Nr(e){return be({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 be({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 be({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 G0(e){return be({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 ac(e){return be({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 Bn(e){return be({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 ic(e){return be({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 rc(e){return be({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 oc(e){return be({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 be({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 lc(e){return be({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 cc(e){return be({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 uc(e){return be({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 dc(e){return be({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 mc(e){return be({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 pc(e){return be({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 sa(e){return be({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 be({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 hc(e){return be({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 fc(e){return be({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 Qa(e){return be({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 gc(e){return be({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 kr(e){return be({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 Xa(e){return be({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 be({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 be({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 bc(e){return be({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 vr(e){return be({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 pn(e){return be({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 hn(e){return be({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 fn(e){return be({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 be({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 be({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 Ec(e){return be({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 St(e){return be({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 Ja(e){return be({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 na(e){return be({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 Za(e){return be({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 Cr(e){return be({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 _r(e){return be({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 In(e){return be({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 be({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 be({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 be({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 be({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 Fn(e){return be({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 Tc(e){return be({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 xc(e){return be({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 aa(e){return be({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 yc(e){return be({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 Sr(e){return be({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 wr(e){return be({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 Nc(e){return be({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 kc(e){return be({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 vc(e){return e.map(t=>t.kind==="package"?`pi update npm:${t.name}`:`npm i -g ${t.name}@latest`).join("; ")}function wt(){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:m,menuStyle:E}){const h=c.useRef(null);return c.useEffect(()=>{if(!t)return;const g=k=>{h.current&&!h.current.contains(k.target)&&n(!1)},w=k=>{k.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",w)}},[t,n]),s.jsxs("div",{className:`dropdown ${a} ${o?"fit":""} ${l==="up"?"dd-up":""}`,ref:h,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:m,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 Hn=null;function Cc(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 Ar(){return Hn===null&&(Hn=Cc()),Hn}function _c(e,t){return t==="/"?e:t+e.replace(/^\/+/,"")}function tt(e){return _c(e,Ar())}const Ir="pi-web-ui:token";function Sc(){try{const e=new URL(window.location.href),t=e.searchParams.get("token");t&&(localStorage.setItem(Ir,t.trim()),e.searchParams.delete("token"),window.history.replaceState(null,"",e.toString()))}catch{}}function wc(){try{return localStorage.getItem(Ir)??""}catch{return""}}function vt(e){const t=wc();return t?`${e}${e.includes("?")?"&":"?"}token=${encodeURIComponent(t)}`:e}const Ac=["zh","en","de","es","fr","it","ja","ko","pt","ru"];function ia(e,t,n,i=Ac){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 m=u.split("-")[0];if(m&&i.includes(m))return m}const o=(n??"").trim().toLowerCase();return o&&i.includes(o)?o:"en"}const ra="pi-web-ui:lang",Ic={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} 字符已省略]…
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-GQZf9XvH.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 Fl,s as In,h as Ia,w as Wt,b as Hl,c as Ul,d as xr,o as na,z as yr,e as $l,g as ql,p as Vt,v as Wl,i as Nr,k as Ka,M as Kl,l as Yl,m as Gl,n as kr,q as vr}from"./markdown-D3PKeHAZ.js";import{r as Cr}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={},Ya;function Vl(){if(Ya)return Ws;Ya=1;var e=Cr();return Ws.createRoot=e.createRoot,Ws.hydrateRoot=e.hydrateRoot,Ws}var zl=Vl();const Ql="modulepreload",Xl=function(e){return"/"+e},Ga={},Jl=function(t,n,i){let a=Promise.resolve();if(n&&n.length>0){let l=function(T){return Promise.all(T.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),m=u?.nonce||u?.getAttribute("nonce");a=l(n.map(T=>{if(T=Xl(T),T in Ga)return;Ga[T]=!0;const h=T.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${T}"]${g}`))return;const A=document.createElement("link");if(A.rel=h?"stylesheet":Ql,h||(A.as="script"),A.crossOrigin="",A.href=T,m&&A.setAttribute("nonce",m),document.head.appendChild(A),h)return new Promise((N,v)=>{A.addEventListener("load",N),A.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${T}`)))})}))}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 _r={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Va=Kt.createContext&&Kt.createContext(_r),Zl=["attr","size","title"];function ec(e,t){if(e==null)return{};var n,i,a=tc(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 tc(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 on(){return on=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},on.apply(null,arguments)}function za(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 ln(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?za(Object(n),!0).forEach(function(i){sc(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):za(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function sc(e,t,n){return(t=nc(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nc(e){var t=ac(e,"string");return typeof t=="symbol"?t:t+""}function ac(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 Sr(e){return e&&e.map((t,n)=>Kt.createElement(t.tag,ln({key:n},t.attr),Sr(t.child)))}function ge(e){return t=>Kt.createElement(ic,on({attr:ln({},e.attr)},t),Sr(e.child))}function ic(e){var t=n=>{var i=e.attr,a=e.size,o=e.title,l=ec(e,Zl),u=a||n.size||"1em",m;return n.className&&(m=n.className),e.className&&(m=(m?m+" ":"")+e.className),Kt.createElement("svg",on({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,i,l,{className:m,style:ln(ln({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 Va!==void 0?Kt.createElement(Va.Consumer,null,n=>t(n)):t(_r)}function rc(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 oc(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 wr(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 Qa(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 Ar(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 lc(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 Xa(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 jn(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 Ja(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 cc(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 cn(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 uc(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 un(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 aa(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 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:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},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:"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 Ir(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 ug(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 mc(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 Hn(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 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:"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 hc(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 fc(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 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:"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 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:"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 Ec(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 Tc(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 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:"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 yc(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 ia(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 Nc(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 kc(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 Za(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 vc(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 jr(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 ei(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 Cc(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 Lr(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 pn(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 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:"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 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:"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 _c(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 St(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 ti(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 ra(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 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:"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 Rr(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 Dr(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 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:"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 Un(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 Sc(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 wc(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 oa(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 Ac(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 Pr(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 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:"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 Ic(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 jc(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 Lc(e){return e.map(t=>t.kind==="package"?`pi update npm:${t.name}`:`npm i -g ${t.name}@latest`).join("; ")}function wt(){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:m,menuStyle:T}){const h=c.useRef(null);return c.useEffect(()=>{if(!t)return;const g=N=>{h.current&&!h.current.contains(N.target)&&n(!1)},A=N=>{N.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",A),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",A)}},[t,n]),s.jsxs("div",{className:`dropdown ${a} ${o?"fit":""} ${l==="up"?"dd-up":""}`,ref:h,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:m,style:T,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 $n=null;function Rc(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 Mr(){return $n===null&&($n=Rc()),$n}function Dc(e,t){return t==="/"?e:t+e.replace(/^\/+/,"")}function tt(e){return Dc(e,Mr())}const Br="pi-web-ui:token";function Pc(){try{const e=new URL(window.location.href),t=e.searchParams.get("token");t&&(localStorage.setItem(Br,t.trim()),e.searchParams.delete("token"),window.history.replaceState(null,"",e.toString()))}catch{}}function Oc(){try{return localStorage.getItem(Br)??""}catch{return""}}function vt(e){const t=Oc();return t?`${e}${e.includes("?")?"&":"?"}token=${encodeURIComponent(t)}`:e}const Mc=["zh","en","de","es","fr","it","ja","ko","pt","ru"];function la(e,t,n,i=Mc){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 m=u.split("-")[0];if(m&&i.includes(m))return m}const o=(n??"").trim().toLowerCase();return o&&i.includes(o)?o:"en"}const ca="pi-web-ui:lang",Bc={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
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
4
 
5
5
  1. 项目类型、技术栈与目录结构
@@ -150,7 +150,7 @@ import{R as Kt,a as c,j as s,f as jl,s as wn,h as Sa,w as Wt,b as Ll,c as Rl,d a
150
150
  2. 用最小实现让测试通过
151
151
  3. 重构并保持测试通过
152
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:"已关闭:模型不能再向你弹出问卷/提问对话框",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:"模型(空 = 跟随主对话)",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:"上下文"},jc={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]…
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:"已关闭:模型不能再向你弹出问卷/提问对话框",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:"模型(空 = 跟随主对话)",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:"上下文"},Fc={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
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
155
 
156
156
  1. Project type, tech stack and directory layout
@@ -301,47 +301,47 @@ Keep going until the plan holds up.`,"tpl.sk.tdd":"Test-driven","tpl.sk.tdd.desc
301
301
  2. Make them pass with the minimal implementation
302
302
  3. Refactor while keeping tests green
303
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",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). 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), 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)",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"},Lc=[{code:"zh",nativeName:"中文"},{code:"en",nativeName:"English"}],vs={};function Rc(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 Dc(e){delete vs[e]}function Pc(e){return e==="zh"?"中文":e.toUpperCase()}function Oc(e){return e==="zh"?"zh-CN":e==="pt"?"pt-BR":e}async function ei(e){const t=await fetch(vt(tt(e)));if(!t.ok)throw new Error(`HTTP ${t.status} for ${e}`);return await t.json()}const jr=c.createContext(null);function Lr(){try{return localStorage.getItem(ra)}catch{return null}}function Mc(){return ia(Lr(),typeof navigator<"u"?navigator.languages:[],null)}function Bc({children:e}){const[t,n]=c.useState(Mc),[i,a]=c.useState(0),o=c.useRef(t);o.current=t;const l=c.useCallback(g=>{n(g);try{localStorage.setItem(ra,g)}catch{}try{window.dispatchEvent(new CustomEvent("pi-web-ui:locale",{detail:g}))}catch{}},[]),u=c.useCallback(async()=>{let g,w=null;try{const k=await ei("/api/locales");g=k.packs??[],w=k.defaultLocale??null}catch{return null}return await Promise.all(g.filter(k=>k.installed).map(async k=>{try{const _=await ei(`/api/locales/${k.code}`);Rc({code:_.code||k.code,nativeName:_.nativeName||k.nativeName,strings:_.strings})}catch{}})),a(k=>k+1),w},[]);c.useEffect(()=>{u().then(g=>{if(!Lr()?.trim()){const k=ia(null,typeof navigator<"u"?navigator.languages:[],g);k!==o.current&&(o.current=k,n(k))}const w=o.current;if(w!=="zh"&&w!=="en"&&!vs[w]){const k=ia(null,typeof navigator<"u"?navigator.languages:[],g,["zh","en"]);o.current=k,n(k);try{localStorage.setItem(ra,k)}catch{}}})},[u]);const m=c.useMemo(()=>[...Lc,...Object.values(vs).map(g=>({code:g.code,nativeName:g.nativeName}))],[i]),E=c.useCallback((g,w)=>{let k=vs[t]?.strings[g]??(t==="zh"?Ic[g]:jc[g]);if(w)for(const[_,M]of Object.entries(w))k=k.replaceAll(`{${_}}`,String(M));return k},[t,i]);c.useEffect(()=>{document.documentElement.lang=Oc(t)},[t]);const h=c.useMemo(()=>({locale:t,setLocale:l,t:E,packs:m,reloadPacks:u}),[t,l,E,m,u]);return s.jsx(jr.Provider,{value:h,children:e})}function Ht(){const e=c.useContext(jr);if(!e)throw new Error("useI18n must be used within LanguageProvider");return e}function Pe(){return Ht().t}const Fc=[{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 ti({settings:e,onChange:t,onPreview:n}){const i=Pe(),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(xr,{className:"sound-icon"}),s.jsx("span",{children:i("enableSound")})]}),s.jsx("input",{type:"checkbox",checked:e.enabled,onChange:o=>a({enabled:o.target.checked})})]}),Fc.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:m=>{m.preventDefault(),n(o)},children:i("preview")}),s.jsx("input",{type:"checkbox",checked:e[o],disabled:!e.enabled,onChange:m=>a({[o]:m.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 Rr="pi-web-notify",Un={enabled:!1};function Dr(){try{const e=localStorage.getItem(Rr);if(!e)return{...Un};const t=JSON.parse(e);return{enabled:typeof t.enabled=="boolean"?t.enabled:Un.enabled}}catch{return{...Un}}}function si(e){try{localStorage.setItem(Rr,JSON.stringify(e))}catch{}}function Ms(){return typeof window<"u"&&"Notification"in window}function Hc(){return Ms()?null:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported"}const Uc=12e4;function qc(e){const{screenX:t,screenY:n,outerWidth:i,outerHeight:a}=e;return Number.isFinite(t)&&ni(t)||Number.isFinite(n)&&ni(n)?!0:i>0&&i<=400&&a>0&&a<=40}function ni(e){return e<=-1e4}function $c(e){return!(e.visibility!=="visible"||e.minimized||!e.hasFocus||e.windows&&e.idleMs>Uc)}let Pr=Date.now(),ai=!1;function ii(){Pr=Date.now()}function Wc(){return Math.max(0,Date.now()-Pr)}function Kc(){if(ai||typeof window>"u")return;ai=!0;const e={passive:!0,capture:!0};for(const t of["pointerdown","pointermove","keydown","wheel","touchstart","focus","scroll"])window.addEventListener(t,ii,e);typeof document<"u"&&document.addEventListener("visibilitychange",ii,e)}function Or(){return typeof navigator>"u"?!1:/windows/i.test(navigator.userAgent??"")}function Yc(){return Kc(),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:qc({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Wc(),windows:Or()}}function ri(){return Ms()?Notification.permission:"denied"}async function Gc(){if(!Ms())return"denied";try{return await Notification.requestPermission()}catch{return"denied"}}function oi(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function Vc(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 zc(e,t,n=!1){if(!Ms())return{path:"none",error:"unsupported"};if(Notification.permission!=="granted")return{path:"none",error:`permission: ${Notification.permission}`};const i=Vc(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=oi(o)}try{return new Notification(e,i),{path:"page",error:a}}catch(o){return{path:"none",error:`${a}; page: ${oi(o)}`}}}async function Ks(e,t){Ms()&&($c(Yc())||Dr().enabled&&await zc(e,t))}const Qc=!1;function li(){const e=Pe(),[t,n]=c.useState(Dr),[i,a]=c.useState(()=>ri()),[o,l]=c.useState(null),u=Hc(),m=u!==null,E=Or();c.useEffect(()=>{const g=()=>a(ri());return window.addEventListener("focus",g),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",g)}},[]);const h=async g=>{const w={...t,enabled:g};if(n(w),si(w),g){const k=await Gc();if(a(k),k!=="granted"){const _={...w,enabled:!1};n(_),si(_)}}};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${m?" disabled":""}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(xc,{className:"sound-icon"}),s.jsx("span",{children:e("notifyEnable")})]}),s.jsx("input",{type:"checkbox",checked:t.enabled&&!m,disabled:m,onChange:g=>h(g.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")}),!m&&i==="denied"&&s.jsx("div",{className:"sound-hint",children:e("notifyDenied")}),!m&&E&&s.jsx("div",{className:"sound-hint",children:e("notifyWindowsHint")}),Qc]})}const Xc={engine:"pi",managed:!1,status:"connecting",ready:!1,cwd:""};let as=Xc;const oa=new Set;function Jc(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,i)=>n===t[i])}function Zc(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&&Jc(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function ci(e){const t={...as,...e};if(!Zc(as,t)){as=t;for(const n of oa)n()}}function Mr(e){return oa.add(e),()=>{oa.delete(e)}}function ui(){return as}function wa(){return c.useSyncExternalStore(Mr,ui,ui)}function Ct(e){return c.useSyncExternalStore(Mr,()=>as[e],()=>as[e])}function Br(){return Ct("engine")==="dsh"}function Fr(){return Ct("managed")}function eu(){return Ct("service")}let la=null;function tu(e){la=e}const ae=e=>la?la(e):!1;function su({onClose:e}){const t=Pe(),{locale:n,setLocale:i,reloadPacks:a}=Ht(),[o,l]=c.useState(null),[u,m]=c.useState(""),[E,h]=c.useState("");async function g(){try{const _=await fetch(vt(tt("/api/locales")));if(!_.ok)throw new Error(`HTTP ${_.status}`);const M=await _.json();l(M.packs??[]),m("")}catch(_){m(t("localeListFailed",{error:_ instanceof Error?_.message:String(_)}))}}c.useEffect(()=>{g()},[]);async function w(_){h(_),m("");try{const M=await fetch(vt(tt(`/api/locales/${_}/install`)),{method:"POST"});if(!M.ok){let $=`HTTP ${M.status}`;try{$=(await M.json()).error??$}catch{}throw new Error($)}await a(),await g()}catch(M){m(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{h("")}}async function k(_){h(_),m("");try{const M=await fetch(vt(tt(`/api/locales/${_}`)),{method:"DELETE"});if(!M.ok)throw new Error(`HTTP ${M.status}`);Dc(_),n===_&&i("zh"),await a(),await g()}catch(M){m(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{h("")}}return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"bg-task-modal",onClick:_=>_.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(kr,{})," ",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(_=>{const M=E===_.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:_.nativeName}),_.installed&&_.version&&s.jsxs("span",{className:"bg-task-name",children:["v",_.version]})]}),s.jsxs("div",{className:"bg-task-line2",children:[s.jsx("span",{children:_.code}),_.installed?s.jsxs("span",{children:[t("localeInstalled")," · ",t("localeRemoveHint")]}):s.jsx("span",{children:t("localeGetMore")})]})]}),_.installed?s.jsxs("button",{type:"button",className:"btn bg-task-stop",disabled:M,title:t("localeRemove"),onClick:()=>void k(_.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(_.code),children:[s.jsx(Yt,{}),s.jsx("span",{children:t(M?"localeDownloading":"localeInstall")})]})]},_.code)})}),s.jsx("div",{className:"bg-task-foot",children:s.jsxs("button",{type:"button",className:"btn",title:t("bgTaskRefresh"),onClick:()=>void g(),children:[s.jsx(kt,{}),s.jsx("span",{children:t("bgTaskRefresh")})]})})]})})}function nu({chat:e,terminal:t,view:n,plugins:i,onViewChange:a,onOpenPanel:o,onOpenSettings:l,onOpenBgTasks:u,onOpenGlobalSearch:m,sound:E,onSoundChange:h,onSoundPreview:g,themes:w,theme:k,onThemeChange:_}){const{locale:M,setLocale:$,t:S,packs:I}=Ht(),{appVersion:j}=wa(),H=Fr(),ee=eu(),[J,ue]=c.useState(!1);c.useEffect(()=>{J&&e.status==="open"&&ue(!1)},[J,e.status]);const[pe,G]=c.useState(!1),[Y,ge]=c.useState(!1),[O,R]=c.useState(!1),[x,D]=c.useState(!1),[U,C]=c.useState(!1),[Z,X]=c.useState(!1),ve=e.ready?S("connected"):e.status==="closed"?S("reconnecting"):S("connecting"),N=e.ready?"ok":"busy",z=()=>{if(!e.ready)return;const F=S("updateTabTitle"),Le={name:F,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},Oe=e.terminals.find(P=>P.title===F);Oe?(t.restart(Oe.id),ae({type:"run_command",terminalId:Oe.id,conversationId:Oe.conversationId,command:Le,cols:80,rows:24})):t.create({id:wt(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:F,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Le}),D(!1),C(!1),a("terminal")},de=(F,Le)=>{if(!e.ready||F.length===0)return;const Oe={name:Le,command:vc(F),cwd:"${pwd}"},P=e.terminals.find(ye=>ye.title===Le);P?(t.restart(P.id),ae({type:"run_command",terminalId:P.id,conversationId:P.conversationId,command:Oe,cols:80,rows:24})):t.create({id:wt(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:Le,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Oe}),D(!1),C(!1),a("terminal")},re=F=>!e.tabs||F==="chat"||e.tabs.includes(F),ke=e.updatesAll??[],oe=ke.filter(F=>!F.upToDate&&!F.error).length,he=ke.filter(F=>!F.upToDate&&!F.error&&F.kind!=="webui"),W=()=>s.jsxs("div",{className:"dd-updates-all",children:[s.jsx("div",{className:"dd-header",children:S("updatesAllTitle")}),e.updatesAll===null?s.jsx("div",{className:"dd-note",children:S("checkingUpdate")}):ke.length===0?s.jsx("div",{className:"dd-note",children:S("updatesAllUpToDate")}):s.jsx("ul",{className:"dd-all-list",children:ke.map(F=>s.jsxs("li",{className:`dd-all-item${F.error?" err":F.upToDate?"":" warn"}`,children:[s.jsx("span",{className:"dd-all-name",title:F.name,children:F.name}),s.jsx("span",{className:"dd-all-kind",children:F.kind==="webui"?S("kindWebUi"):F.kind==="pi-core"?S("kindPiCore"):S("kindPackage")}),s.jsx("span",{className:"dd-all-vers",children:F.error?S("updateCheckFailed"):F.upToDate?`v${F.current}`:s.jsxs(s.Fragment,{children:["v",F.current," → v",F.latest]})}),F.kind!=="webui"&&!F.upToDate&&!F.error&&s.jsx("button",{type:"button",className:"dd-update-btn",onClick:()=>de([F],S("updatePkgTabTitle",{name:F.name})),children:S("updateBtn")})]},`${F.kind}:${F.name}`))}),s.jsxs("div",{className:"dd-actions",children:[he.length>0&&s.jsx("button",{type:"button",className:"dd-refresh accent",style:{flex:1},onClick:()=>de(he,S("updateAllTabTitle")),children:S("updateAllBtn")}),s.jsx("button",{type:"button",className:"dd-refresh",style:he.length>0?{flex:1}:void 0,onClick:()=>ae({type:"check_updates_all",force:!0}),children:S("updatesAllRefresh")})]})]}),ce=()=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"dd-update",children:[s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:S("currentVersion")}),s.jsxs("b",{children:["v",e.update?.current??"…"]})]}),s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:S("latestVersion")}),s.jsx("b",{children:e.update===null?S("checkingUpdate"):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:S("checkingUpdate")})]}),e.update&&e.update.upToDate&&s.jsx("div",{className:"dd-note ok",children:S("upToDate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note warn",children:S("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:S("updateJustPublished",{version:e.update.latest??""})}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note",children:S("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?S("checkingUpdate"):S("checkUpdate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("button",{type:"button",className:"dd-refresh accent",onClick:z,children:S("updateNow")}),ee&&s.jsx("button",{type:"button",className:"dd-refresh accent",disabled:J,title:S("restartServiceTip",{name:ee.name}),onClick:()=>{J||(ue(!0),ae({type:"restart_service"}))},children:S(J?"restartingService":"restartService")})]})]});return s.jsxs("header",{className:"topbar",children:[s.jsxs("div",{className:"brand",children:[s.jsx("button",{type:"button",className:"panel-toggle",title:S("openHistory"),onClick:()=>o("left"),children:s.jsx(lc,{})}),s.jsx("span",{className:"brand-logo",children:"π"}),s.jsx("span",{className:"brand-name",children:"pi-web-ui"}),s.jsx("span",{className:`conn-dot ${N}`,title:ve}),s.jsx("span",{className:"conn-label",children:ve})]}),s.jsxs("div",{className:"topbar-actions",children:[s.jsxs("div",{className:"view-switch",role:"tablist","aria-label":S("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:S("chat")})]}),re("terminal")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":n==="terminal",className:n==="terminal"?"active":"",onClick:()=>a("terminal"),children:[s.jsx(An,{}),s.jsx("span",{children:S("terminal")})]}),re("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:S("scmTab")})]}),(re("plugins")?i:[]).filter(F=>F.view!==!1).map(F=>{const Le=F.error?`${F.name}: ${F.error}`:F.description?`${F.name} — ${F.description}`:F.name;return s.jsxs("button",{type:"button",role:"tab","aria-selected":n===`plugin:${F.id}`,className:`plugin-tab${n===`plugin:${F.id}`?" active":""}${F.error?" broken":""}`,title:Le,onClick:()=>a(`plugin:${F.id}`),children:[F.icon?s.jsx("span",{"aria-hidden":!0,children:F.icon}):null,s.jsx("span",{children:F.name})]},F.id)})]}),s.jsxs("div",{className:"topbar-desktop",children:[re("search")&&s.jsxs("button",{type:"button",className:"chip",title:S("searchGlobalTip"),onClick:m,children:[s.jsx(dn,{}),s.jsx("span",{className:"chip-sub",children:S("searchGlobal")})]}),re("tasks")&&s.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":S("bgTasksTip"),onClick:u,children:[s.jsx(mn,{}),s.jsx("span",{className:"chip-sub",children:S("bgTasks")}),e.bgServers.length>0&&s.jsx("span",{className:"bg-task-badge",children:e.bgServers.length})]}),re("settings")&&s.jsxs("button",{type:"button",className:"chip",title:S("settingsTitle"),onClick:l,children:[s.jsx(un,{}),s.jsx("span",{className:"chip-sub",children:S("settings")})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(xr,{}),s.jsx("span",{className:"chip-sub",children:S("sound")})]}),open:pe,onOpenChange:G,children:[s.jsx(ti,{settings:E,onChange:h,onPreview:g}),s.jsx(li,{})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(kr,{}),s.jsx("span",{className:"chip-sub",children:Pc(M)})]}),open:Y,onOpenChange:ge,children:[s.jsx("div",{className:"dd-header",children:S("language")}),I.map(F=>s.jsx(it,{active:M===F.code,onClick:()=>{$(F.code),ge(!1)},children:F.nativeName},F.code)),s.jsxs(it,{onClick:()=>{ge(!1),X(!0)},children:[s.jsx(Yt,{})," ",S("localeGetMore")]})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(tc,{}),s.jsx("span",{className:"chip-sub",children:S("theme")})]}),open:O,onOpenChange:R,children:[s.jsx("div",{className:"dd-header",children:S("theme")}),s.jsx(it,{active:k===null,onClick:()=>{_(null),R(!1)},children:S("themeDefault")}),w.map(F=>s.jsx(it,{active:k===F.id,onClick:()=>{_(F.id),R(!1)},children:M==="zh"?F.name:F.nameEn??F.name},F.id))]}),H?s.jsxs("span",{className:"chip",title:S("updatesManaged"),children:[s.jsx(Yt,{}),s.jsxs("span",{className:"chip-sub",children:["v",j??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:S("updateAvailable",{version:e.update.latest??""})}),oe>0&&s.jsx("span",{className:"update-badge",children:S("updatesAllBadge",{n:oe})})]}),open:x,onOpenChange:F=>{D(F),F&&(ae({type:"check_update"}),ae({type:"check_updates_all"}))},fit:!0,children:[s.jsx("div",{className:"dd-header",children:S("update")}),ce(),W()]}),s.jsx("a",{className:"chip github",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",title:S("githubRepo"),children:s.jsx(Xa,{})})]}),s.jsxs("button",{type:"button",className:"chip newchat","data-tip":S("newChatTip"),onClick:()=>ae({type:"new_chat"}),children:[s.jsx(dt,{}),s.jsx("span",{children:S("newChat")})]}),s.jsx("div",{className:"topbar-more",children:s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(ic,{}),s.jsx("span",{className:"chip-sub",children:S("more")}),!H&&e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot"})]}),open:U,onOpenChange:F=>{C(F),F&&!H&&(ae({type:"check_update"}),ae({type:"check_updates_all"}))},children:[s.jsx("div",{className:"dd-header",children:S("sound")}),s.jsx("div",{className:"dd-header",children:S("settings")}),s.jsxs(it,{onClick:()=>{C(!1),l()},children:[s.jsx(un,{})," ",S("settingsTitle")]}),s.jsxs(it,{onClick:()=>{C(!1),m()},children:[s.jsx(dn,{})," ",S("searchGlobal")]}),s.jsxs(it,{onClick:()=>{C(!1),u()},children:[s.jsx(mn,{})," ",S("bgTasks"),e.bgServers.length>0&&s.jsx("em",{className:"bg-task-badge",children:e.bgServers.length})]}),s.jsx(ti,{settings:E,onChange:h,onPreview:g}),s.jsx(li,{}),s.jsx("div",{className:"dd-header",children:S("language")}),I.map(F=>s.jsx(it,{active:M===F.code,onClick:()=>$(F.code),children:F.nativeName},F.code)),s.jsx("div",{className:"dd-header",children:S("theme")}),s.jsx(it,{active:k===null,onClick:()=>{_(null),C(!1)},children:S("themeDefault")}),w.map(F=>s.jsx(it,{active:k===F.id,onClick:()=>{_(F.id),C(!1)},children:M==="zh"?F.name:F.nameEn??F.name},F.id)),s.jsx("div",{className:"dd-header",children:S("update")}),ce(),W(),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(Xa,{})," ",S("githubRepo")]})]})})]}),s.jsx("button",{type:"button",className:"panel-toggle",title:S("openFiles"),onClick:()=>o("right"),children:s.jsx(Bt,{})}),Z&&s.jsx(su,{onClose:()=>X(!1)})]})}function Hr(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 Ur(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 m=e.minAbovePx+e.minBelowPx||1,E=t*e.minAbovePx/m;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 di(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 au(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 iu="pi-web-ui:lp-collapse-projects",ru="pi-web-ui:lp-collapse-convs",ou="pi-web-ui:lp-collapse-sessions";function qn(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 qr="pi-web-ui:lp-sizes",gn={projects:1,convs:1,sessions:1},lu=32,mi=72;function cu(){try{return Hr(localStorage.getItem(qr),gn)}catch{return{...gn}}}const uu=c.memo(function({sessionFile:t,conversations:n,sessions:i,projects:a,activeConversationId:o,panelSend:l,active:u,collapsible:m,onToggleCollapse:E}){const h=Pe(),g=t,w=Ct("ready"),k=Ct("status"),_=Ct("cwd"),M=_,[$,S]=c.useState(null),[I,j]=c.useState(null),[H,ee]=c.useState(""),[J,ue]=qn(iu,!1),[pe,G]=qn(ru,!1),[Y,ge]=qn(ou,!1),[O,R]=c.useState(null),[x,D]=c.useState(null),U=c.useCallback(()=>{D(null),R(null)},[]),C=c.useCallback((P,ye)=>{P.preventDefault(),P.stopPropagation(),R({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=fe=>{fe.target?.closest(".ctx-menu")||U()},ye=fe=>{fe.key==="Escape"&&U()};return window.addEventListener("mousedown",P,!0),window.addEventListener("keydown",ye),window.addEventListener("blur",U),()=>{window.removeEventListener("mousedown",P,!0),window.removeEventListener("keydown",ye),window.removeEventListener("blur",U)}},[O,U]);const Z=c.useCallback((P,ye)=>{if(!ye)return P.filter(Ne=>Ne.isSubagent&&!Ne.isStreaming&&Ne.id!==o).length;const fe=new Map(P.map(Ne=>[Ne.id,Ne])),Te=Ne=>{if(Ne.id===ye)return(fe.get(ye)?.isSubagent??!1)&&!Ne.isStreaming&&Ne.id!==o;let Se=Ne;const Ce=new Set;for(;Se?.parentId;){if(Se.parentId===ye)return!0;if(Ce.has(Se.parentId)||(Ce.add(Se.parentId),Se=fe.get(Se.parentId),!Se))return!1}return!1};return P.filter(Ne=>Ne.isSubagent&&!Ne.isStreaming&&Ne.id!==o&&Te(Ne)).length},[o]),X=c.useCallback((P,ye)=>{if(!ye)return P.filter(Ne=>Ne.isSubagent).length;const fe=new Map(P.map(Ne=>[Ne.id,Ne])),Te=Ne=>{if(Ne.id===ye)return fe.get(ye)?.isSubagent??!1;let Se=Ne;const Ce=new Set;for(;Se?.parentId;){if(Se.parentId===ye)return!0;if(Ce.has(Se.parentId)||(Ce.add(Se.parentId),Se=fe.get(Se.parentId),!Se))return!1}return!1};return P.filter(Ne=>Ne.isSubagent&&Te(Ne)).length},[]),ve=c.useCallback((P,ye)=>{if(!ye)return 0;const fe=new Map(P.map(Ne=>[Ne.id,Ne])),Te=Ne=>{let Se=Ne;const Ce=new Set;for(;Se?.parentId;){if(Se.parentId===ye)return!0;if(Ce.has(Se.parentId)||(Ce.add(Se.parentId),Se=fe.get(Se.parentId),!Se))return!1}return!1};return P.filter(Ne=>Ne.isSubagent&&Ne.isStreaming&&Te(Ne)).length},[]),N=c.useRef(null),[z,de]=c.useState(()=>cu());c.useEffect(()=>{try{localStorage.setItem(qr,JSON.stringify(z))}catch{}},[z]);const re=c.useCallback((P,ye)=>fe=>{fe.preventDefault();const Te=fe.currentTarget,Ne=fe.clientY,Se={...z},Ce=N.current;if(!Ce)return;const T=[{key:"projects",visible:a.length>0,collapsed:J},{key:"convs",visible:n.length>0,collapsed:pe},{key:"sessions",visible:!0,collapsed:Y}].filter(v=>v.visible),le=T.filter(v=>v.collapsed).length,Ee=T.filter(v=>!v.collapsed).map(v=>v.key).reduce((v,te)=>v+(Se[te]??1),0)||1,Re=Math.max(120,Ce.clientHeight-le*lu);Te.classList.add("dragging"),document.body.classList.add("lp-resizing");const y=v=>{const{above:te,below:me}=Ur({start:{above:Se[P]??1,below:Se[ye]??1},deltaPx:v.clientY-Ne,availablePx:Re,totalWeight:Ee,minAbovePx:mi,minBelowPx:mi});de(je=>({...je,[P]:te,[ye]:me}))},ie=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",ie),Te.classList.remove("dragging"),document.body.classList.remove("lp-resizing")};window.addEventListener("pointermove",y),window.addEventListener("pointerup",ie)},[z,a.length,n.length,J,pe,Y]);c.useEffect(()=>{!u||!w||k!=="open"||_&&(l({type:"list_sessions"}),l({type:"list_projects"}))},[u,w,k,_,l]);const ke=P=>{const ye=P.name||P.firstMessage.trim();return ye.length>0?ye:h("emptyChat")},oe=P=>P.split(/[\\/]/).pop()||P,he=(P,ye,fe,Te,Ne)=>{const Se=$===P;return s.jsx("button",{type:"button",className:`lp-del ${Se?"confirm":""}`,title:Se?fe:ye,onClick:Ce=>{Ce.stopPropagation(),Se?(S(null),Te()):S(P)},children:Se?s.jsx(Tt,{}):Ne??s.jsx(et,{})})},W=(P,ye,fe,Te)=>s.jsxs("button",{type:"button",className:"lp-section-title panel-section-title",onClick:fe,title:h(ye?"expandSection":"collapseSection"),children:[s.jsxs("span",{className:"lp-section-title-text",children:[P,Te!==void 0?` (${Te})`:""]}),s.jsx("span",{className:"lp-section-chevron",children:ye?s.jsx(Ft,{}):s.jsx(In,{})})]}),F=[{key:"projects",visible:a.length>0,collapsed:J},{key:"convs",visible:n.length>0,collapsed:pe},{key:"sessions",visible:!0,collapsed:Y}].filter(P=>P.visible).filter(P=>!P.collapsed),Le=F.reduce((P,ye)=>P+(z[ye.key]??1),0)||1,Oe=P=>F.length<=1?1:(z[P]??1)/Le*F.length;return s.jsxs("aside",{ref:N,className:"panel panel-left lp-panel",children:[m&&E&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:h("collapsePanel"),onClick:E,children:s.jsx(_r,{})}),a.length>0&&s.jsxs("div",{className:`lp-section panel-projects ${J?"collapsed":""}`,style:J?void 0:{flex:`${Oe("projects")} 1 0px`},children:[W(h("recentProjects"),J,ue,a.length),!J&&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:()=>S(fe=>fe===`proj:${P.path}`?null:fe),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:oe(P.path)}),s.jsx("span",{className:"project-path",children:P.path})]}),s.jsx("span",{className:"project-time",children:di(P.lastUsed)})]}),he(`proj:${P.path}`,h("deleteProject"),h("deleteProjectConfirm"),()=>l({type:"remove_project",path:P.path}))]},P.path)})})]}),a.length>0&&!J&&(n.length>0?!pe:!Y)&&s.jsx("div",{className:"lp-sash",onPointerDown:re("projects",n.length>0?"convs":"sessions"),onDoubleClick:()=>de({...gn}),title:h("dragToResize")}),n.length>0&&s.jsxs("div",{className:`lp-section lp-section-convs panel-convs ${pe?"collapsed":""}`,style:pe?void 0:{flex:`${Oe("convs")} 1 0px`},onContextMenu:P=>C(P),children:[W(h("runningConversations"),pe,G,n.length),!pe&&s.jsx("div",{className:"lp-section-body convs-scroll",children:au(n,_).map(P=>s.jsxs("div",{className:"panel-conv-group",children:[!P.isCurrent&&s.jsx("div",{className:"panel-conv-group-title",title:P.cwd,children:oe(P.cwd)}),(()=>{const ye=new Map(P.convs.map(T=>[T.id,T])),fe=new Map,Te=[];for(const T of P.convs)if(T.parentId&&ye.has(T.parentId)){const le=fe.get(T.parentId)??[];le.push(T),fe.set(T.parentId,le)}else Te.push(T);const Ne=[],Se=new Set,Ce=(T,le)=>{if(!Se.has(T.id)){Se.add(T.id),Ne.push({c:T,depth:le});for(const se of fe.get(T.id)??[])Ce(se,le+1)}};for(const T of Te)Ce(T,0);for(const T of P.convs)Ce(T,0);return Ne.map(({c:T,depth:le})=>{const se=o===T.id;return s.jsxs("div",{className:`lp-row${le>0?" lp-sub":""}`,style:le>0?{marginLeft:le*18}:void 0,onMouseLeave:()=>S(Ee=>Ee===`conv:${T.id}`?null:Ee),onContextMenu:Ee=>C(Ee,T.id),children:[s.jsxs("button",{type:"button",className:`session-item ${se?"active":""}`,title:`${T.title}${P.isCurrent?"":` — ${P.cwd}`}`,onClick:()=>{se||l({type:"switch_conversation",id:T.id})},children:[s.jsx(rs,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[I===`conv:${T.id}`?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:H,placeholder:h("renameSessionPlaceholder"),onClick:Ee=>Ee.stopPropagation(),onChange:Ee=>ee(Ee.target.value),onKeyDown:Ee=>{if(Ee.stopPropagation(),Ee.key==="Enter"&&!Ee.nativeEvent.isComposing){const Re=H.trim();Re&&l({type:"rename_conversation",id:T.id,name:Re}),j(null)}else Ee.key==="Escape"&&j(null)},onBlur:()=>j(null)}):s.jsxs("span",{className:"session-title",children:[T.isSubagent&&s.jsx("span",{className:"subagent-badge",children:h("subagentBadge")}),T.title,T.error&&s.jsx("span",{className:"conv-error-badge",title:h("convErrorBadge",{error:T.error})})]}),I===`conv:${T.id}`?null:s.jsx("span",{className:"session-sub",children:se?h("current"):h("messageCount",{n:T.messageCount})})]}),T.isStreaming&&s.jsx("span",{className:"conv-streaming",title:h("streaming")})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:h("renameSession"),onClick:Ee=>{Ee.stopPropagation(),S(null),ee(T.title),j(`conv:${T.id}`)},children:s.jsx(fn,{})}),(()=>{const Ee=`conv:${T.id}`,Re=$===Ee,y=Z(n,T.id),ie=ve(n,T.id),v=X(n,T.id);return v===0&&!T.isStreaming?he(Ee,h("dismissConversation"),h("dismissConversationConfirm"),()=>l({type:"dismiss_conversation",id:T.id}),s.jsx(Ke,{})):v===0?he(Ee,h("dismissConversation"),h("dismissStreamingConfirm"),()=>l({type:"dismiss_conversation",id:T.id,force:!0}),s.jsx(Ke,{})):Re?s.jsxs("span",{className:"lp-del-group",children:[y>0&&s.jsx("button",{type:"button",className:"lp-del-opt",title:h("dismissFinishedSubagentsScoped",{n:y}),onClick:te=>{te.stopPropagation(),S(null),l({type:"dismiss_finished_subagents",parentId:T.id})},children:h("dismissFinishedOnly",{n:y})}),s.jsx("button",{type:"button",className:"lp-del-opt danger",title:h("forceDismissTitle",{n:v,m:ie}),onClick:te=>{te.stopPropagation(),S(null),l({type:"dismiss_conversation",id:T.id,force:!0})},children:h("dismissForceAll",{n:v})})]}):s.jsx("button",{type:"button",className:"lp-del",title:h("dismissConversation"),onClick:te=>{te.stopPropagation(),S(Ee)},children:s.jsx(Ke,{})})})(),T.isStreaming&&s.jsx("span",{className:"lp-row-stalled",title:h("streaming"),style:{position:"absolute",right:28,top:"50%",transform:"translateY(-50%)"}})]},T.id)})})()]},P.cwd))})]}),n.length>0&&!pe&&!Y&&s.jsx("div",{className:"lp-sash",onPointerDown:re("convs","sessions"),onDoubleClick:()=>de({...gn}),title:h("dragToResize")}),s.jsxs("div",{className:`lp-section lp-section-sessions panel-sessions ${Y?"collapsed":""}`,style:Y?void 0:{flex:`${Oe("sessions")} 1 0px`},children:[W(h("historySessions"),Y,ge,i.length),!Y&&s.jsxs("div",{className:"lp-section-body sessions-scroll",children:[i.length===0&&s.jsx("div",{className:"panel-empty",children:h("noHistory")}),i.map(P=>{const ye=g===P.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>S(fe=>fe===`sess:${P.path}`?null:fe),children:[s.jsxs("button",{type:"button",className:`session-item ${ye?"active":""}`,title:P.path,onClick:()=>{I||ye||l({type:"switch_session",path:P.path})},children:[s.jsx(rs,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[I===P.path?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:H,placeholder:h("renameSessionPlaceholder"),onClick:fe=>fe.stopPropagation(),onChange:fe=>ee(fe.target.value),onKeyDown:fe=>{if(fe.stopPropagation(),fe.key==="Enter"&&!fe.nativeEvent.isComposing){const Te=H.trim();Te&&l({type:"rename_session",path:P.path,name:Te}),j(null)}else fe.key==="Escape"&&j(null)},onBlur:()=>j(null)}):s.jsx("span",{className:"session-title",children:ke(P)}),I===P.path?null:s.jsxs("span",{className:"session-sub",children:[ye?h("current"):h("messageCount",{n:P.messageCount}),P.source==="tui"&&s.jsx("span",{className:"session-src",title:h("tuiTip"),children:"TUI"})]})]}),s.jsx("span",{className:"session-time",children:di(P.modified)})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:h("renameSession"),onClick:fe=>{fe.stopPropagation(),S(null),ee(P.name??""),j(P.path)},children:s.jsx(fn,{})}),he(`sess:${P.path}`,h("deleteSession"),h("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:Z(n,O.scopeId)===0?h("noFinishedSubagents"):void 0,disabled:Z(n,O.scopeId)===0,onClick:()=>{O.scopeId?l({type:"dismiss_finished_subagents",parentId:O.scopeId}):l({type:"dismiss_finished_subagents"}),U()},children:[s.jsx(Ke,{}),s.jsx("span",{children:Z(n,O.scopeId)===0?h("noFinishedSubagents"):O.scopeId?h("dismissFinishedSubagentsScoped",{n:Z(n,O.scopeId)}):h("dismissFinishedSubagents",{n:Z(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?h("forceDismissConfirm"):h("forceDismissConversation"),onClick:()=>{const P=O.scopeId;x===P?(l({type:"dismiss_conversation",id:P,force:!0}),D(null),U()):D(P)},children:[s.jsx(Ke,{}),s.jsx("span",{children:x===O.scopeId?h("forceDismissConfirm"):h("forceDismissConversation")})]})]})]})});function du(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,m=u&&u.id===t.messageId?u:{id:t.messageId,content:[]},E=[...m.content],h=n.type==="thinking_delta"?"thinking":"text",g=n.contentIndex??E.length-1;return g>=0&&g<E.length&&E[g].type===h?E[g]=h==="thinking"?{type:"thinking",thinking:(E[g].thinking??"")+l}:{type:"text",text:(E[g].text??"")+l}:E.push(h==="thinking"?{type:"thinking",thinking:l}:{type:"text",text:l}),{...e,stats:o,streamingMessage:{...m,id:t.messageId,content:E}}}function mu(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 ca="pi-web-ui:plugin-data";function pu(e,t){window.dispatchEvent(new CustomEvent(ca,{detail:{pluginId:e,payload:t}}))}function hu(e){const t=n=>{const i=n.detail;e(i.pluginId,i.payload)};return window.addEventListener(ca,t),()=>window.removeEventListener(ca,t)}const ss=new Map,ua=new Set,Zt=new Set;let pi=-1;function $r(){return[...ss.values()]}function fu(){const e=$r();for(const t of ua)t(e)}function gu(e){return ua.add(e),e($r()),()=>ua.delete(e)}async function bu(e,t){t!==pi&&(pi=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)}})),fu()}function Eu(e,t){return{pluginId:e,send:n=>t({type:"plugin_message",pluginId:e,payload:n}),onData:n=>hu((i,a)=>{i===e&&n(a)})}}const Tu=15,xu="pi-web-ui:lang";function hi(){try{return(localStorage.getItem(xu)??"").trim()}catch{return""}}const fi="pi-web-ui:locale",$n=2e5,yu=2e5,Nu="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 vu(){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 h of u)try{h.write(o)}catch{}return}const m=t.get(l)??"",E=m.length+o.length>yu?o:m+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 m=t.get(l);if(m){try{o.write(m)}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 gi(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 bi(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 Cu(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!==Tu};case"snapshot":return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:gi(e.liveOutputs,t.state),toolStatuses:bi(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:gi(e.liveOutputs,a),toolStatuses:bi(e.toolStatuses,a)}}case"tool_delta":{const i=(e.liveOutputs.get(t.toolCallId)?.text??"")+t.delta,a=i.length>$n?`…[${Nu}:${i.length-$n}]…
305
- `+i.slice(i.length-$n):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:du(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 Ei="pi-web-client-id";let Wn=null;function bn(){if(Wn)return Wn;let e=null;try{e=sessionStorage.getItem(Ei),e||(e=wt(),sessionStorage.setItem(Ei,e))}catch{e=e??wt()}return Wn=e,e}const Wr="pi-web-last-cwd";function _u(){try{return localStorage.getItem(Wr)}catch{return null}}function Su(e){try{localStorage.setItem(Wr,e)}catch{}}function wu(){const e=location.protocol==="https:"?"wss:":"ws:";return vt(`${e}//${location.host}${tt("/ws")}`)}function Au(){const[e,t]=c.useReducer(Cu,{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(vu()),a=c.useRef(0),o=c.useRef(null),l=c.useRef(!0),u=c.useRef(0),m=c.useRef(0),E=c.useRef(new Map),h=c.useRef(null),g=c.useRef(!1),w=c.useRef(null),k=c.useRef(new Set),_=c.useRef("live"),M=()=>{h.current||(h.current=setTimeout(()=>{h.current=null;const O=n.current;O&&O.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"get_state"}))},300))},$=(O,R)=>{const x=E.current,D=x.get(O);if(D!==void 0&&R!==D+1){const U=ge.current.chat,C=U.activeConversationId||U.state?.conversationId;O===C&&M()}x.set(O,R)},S=c.useCallback((O,R)=>{const x=++m.current;t({type:"notice",notice:{id:x,level:O,text:R}})},[]),I=c.useCallback(O=>{const R=n.current;if(R&&R.readyState===WebSocket.OPEN){if(O.type==="check_updates_all"&&O.force===!0&&t({type:"updates_check_started"}),R.send(JSON.stringify(O)),O.type==="question_answer"){if(k.current.add(O.id),k.current.size>64){const x=k.current.values().next().value;x!==void 0&&k.current.delete(x)}_.current="live",t({type:"question",question:null})}return!0}return!1},[]),j=c.useCallback(O=>{const R=mu({current:ge.current.chat.question,source:_.current,snapshot:O,answered:k.current});R.changed&&(_.current=R.source,t({type:"question",question:R.question}))},[]);tu(I);const H=c.useCallback(()=>{if(!l.current)return;t({type:"status",status:"connecting"});const O=new WebSocket(wu());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:bn(),locale:hi()})))},O.onmessage=R=>{if(n.current!==O)return;u.current=Date.now();let x;try{x=JSON.parse(R.data)}catch{return}switch(x.type){case"ready":ci({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}),j(x.state.pendingQuestion);break;case"snapshot_delta":{const D=ge.current.chat.state;(!D||D.conversationId!==x.conversationId||D.rev!==x.baseRev)&&M(),t({type:"snapshot_delta",msg:x}),j(x.state.pendingQuestion);break}case"tool_delta":$(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":{$(x.conversationId,x.seq),t({type:"message_delta",msg:x});break}case"notice":{const D=++m.current;t({type:"notice",notice:{id:D,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":_.current="live",t({type:"question",question:{id:x.id,...x.deadline!==void 0?{deadline:x.deadline}:{},questions:x.questions}});break;case"terminal_output":i.current.write(x.conversationId??ge.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 R=Math.min(1e3*2**a.current,1e4);a.current+=1,o.current=setTimeout(()=>{o.current=null,H()},R)},O.onerror=()=>{}},[]);c.useEffect(()=>{const O=R=>{const x=R.detail??hi();x&&I({type:"set_locale",locale:x})};return window.addEventListener(fi,O),()=>window.removeEventListener(fi,O)},[I]),c.useEffect(()=>{l.current=!0,H();const O=setInterval(()=>{if(!l.current)return;const R=n.current;R&&R.readyState===WebSocket.OPEN&&Date.now()-u.current>3e4&&R.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(!g.current){g.current=!0;const R=_u();if(R&&R!==O){I({type:"set_cwd",path:R});return}}w.current!==O&&(w.current=O,Su(O))}},[e.state?.cwd,I]),c.useEffect(()=>{ci({ready:e.ready,status:e.status,cwd:e.state?.cwd??""})},[e.ready,e.status,e.state?.cwd]);const ee=c.useCallback(O=>t({type:"dismiss_notice",id:O}),[]),J=c.useCallback(O=>t({type:"terminal_add",meta:O}),[]),ue=c.useCallback(O=>t({type:"terminal_remove",id:O}),[]),pe=c.useCallback(O=>t({type:"terminal_restart",terminalId:O}),[]),G=c.useCallback(O=>t({type:"terminal_active",id:O}),[]),Y=c.useCallback((O,R,x)=>i.current.register(O,R,x),[]),ge=c.useRef({chat:e,send:I,pushNotice:S,dismissNotice:ee,terminal:{create:J,close:ue,register:Y,restart:pe,select:G}});return ge.current={chat:e,send:I,pushNotice:S,dismissNotice:ee,terminal:{create:J,close:ue,register:Y,restart:pe,select:G}},ge.current}const Iu=200*1024*1024,ju=/windows/i.test(navigator.userAgent),Lu=/[<>:"/\\|?*\u0000-\u001f]/g,Ru=/[. ]+$/,Du=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Pu(e){const t=e.replace(Lu,"_").replace(Ru,"");return t?Du.test(t)?`_${t}`:t:"_"}function Ti(e,t=!0){const n=new URLSearchParams({clientId:bn(),path:e,...t?{download:"1"}:{}});return vt(tt(`/api/file?${n}`))}const Kr="FILE_NOT_FOUND";async function Ou(e,t){const n=ju?Pu(t):t;try{const i=await fetch(Ti(e));if(!i.ok)return{ok:!1,cancelled:!1,error:await i.text().catch(()=>"")||(i.status===404?Kr:`HTTP ${i.status}`)};if(Number(i.headers.get("content-length")??"0")>Iu)return window.location.assign(Ti(e)),{ok:!0};const o=await i.blob();return window.showSaveFilePicker&&window.isSecureContext?Mu(o,n):da(o,n)}catch(i){return{ok:!1,cancelled:!1,error:i instanceof Error?i.message:String(i)}}}async function Mu(e,t){let n;const i=window.showSaveFilePicker;if(!i)return da(e,t);try{n=await i({suggestedName:t})}catch(a){return a instanceof DOMException&&a.name==="AbortError"?{ok:!1,cancelled:!0}:da(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 da(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",xi="pi-web-ui:rp-sizes",Kn={files:4,widgets:1},yi=120,Ni=56,Bu=c.memo(function({files:t,fileChanged:n,widgets:i,panelSend:a,onAttach:o,onPreview:l,onNotice:u,collapsible:m,onToggleCollapse:E}){const h=Pe(),g=Ct("cwd"),[w,k]=c.useState(""),[_,M]=c.useState(null),[$,S]=c.useState(!1),I=c.useRef(null),j=c.useRef(null),[H,ee]=c.useState(()=>{try{return Hr(localStorage.getItem(xi),Kn)}catch{return{...Kn}}});c.useEffect(()=>{try{localStorage.setItem(xi,JSON.stringify(H))}catch{}},[H]);const J=i.some(T=>T.lines.length>0),ue=c.useCallback(T=>{T.preventDefault();const le=I.current;if(!le)return;const se=T.currentTarget,Ee=T.clientY,Re={above:H.files,below:H.widgets},y=Math.max(120,le.clientHeight-(j.current?.offsetHeight??32));se.classList.add("dragging"),document.body.classList.add("rp-resizing");const ie=te=>{const{above:me,below:je}=Ur({start:Re,deltaPx:te.clientY-Ee,availablePx:y,totalWeight:Re.above+Re.below,minAbovePx:yi,minBelowPx:Ni});ee({files:me,widgets:je})},v=()=>{window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",v),se.classList.remove("dragging"),document.body.classList.remove("rp-resizing")};window.addEventListener("pointermove",ie),window.addEventListener("pointerup",v)},[H.files,H.widgets]),[pe,G]=c.useState(null),Y=c.useRef(""),ge=c.useRef(null),O=c.useRef(null),[R,x]=c.useState(null),D=c.useRef(null);c.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]);const U=c.useCallback(T=>{x(T),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>x(null),1200)},[]),C=T=>{try{const le=document.createElement("textarea");le.value=T,le.style.position="fixed",le.style.opacity="0",document.body.appendChild(le),le.select();const se=document.execCommand("copy");return document.body.removeChild(le),se}catch{return!1}},Z=c.useCallback((T,le)=>{if(!T)return;const se=()=>U(le),Ee=()=>u("error",h("slashCopyFailed")),Re=navigator;Re.clipboard?.writeText?Re.clipboard.writeText(T).then(se,()=>{C(T)?se():Ee()}):C(T)?se():Ee()},[U,u,h]),X=c.useCallback(T=>{if(!T)return g;if(/^[A-Za-z]:$/.test(T))return`${T}/`;if(T.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(T))return T;const le=g.replace(/\\/g,"/").replace(/\/+$/,"");return le?`${le}/${T}`:T},[g]),ve=c.useCallback(T=>!T||T===fs?null:T.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(T)?T:`${g.replace(/\\/g,"/").replace(/\/+$/,"")}/${T}`,[g]),N=c.useCallback((T,le,se)=>{T.preventDefault(),Y.current=le,ge.current=se??null,G({x:Math.min(T.clientX,window.innerWidth-220),y:Math.min(T.clientY,window.innerHeight-90)})},[]),z=c.useCallback(()=>G(null),[]);c.useEffect(()=>{if(!pe)return;const T=Ee=>{Ee.target?.closest(".ctx-menu")||z()},le=Ee=>{Ee.key==="Escape"&&z()};window.addEventListener("mousedown",T,!0),window.addEventListener("keydown",le);const se=()=>z();return window.addEventListener("blur",se),()=>{window.removeEventListener("mousedown",T,!0),window.removeEventListener("keydown",le),window.removeEventListener("blur",se)}},[pe,z]);const de=c.useCallback(()=>{const T=ge.current;z(),T&&a({type:"set_cwd",path:T.path})},[z,a]),re=c.useCallback(()=>{z(),O.current&&(O.current.value=""),O.current?.click()},[z]),ke=c.useCallback((T,le)=>{for(const se of le){const Ee=new FileReader;Ee.onload=()=>{const Re=Ee.result,y=Re.slice(Re.indexOf(",")+1);y&&a({type:"upload_file",dirPath:T,name:se.name,data:y})},Ee.readAsDataURL(se)}},[a]),oe=c.useCallback(T=>{ke(Y.current,Array.from(T.target.files??[]))},[ke]),he=c.useRef(null),W=T=>Array.from(T.dataTransfer?.types??[]).includes("Files"),ce=c.useCallback(()=>{he.current?.querySelectorAll(".file-item.drop-target").forEach(T=>T.classList.remove("drop-target")),he.current?.classList.remove("drop-root")},[]),F=c.useCallback(T=>{if(ce(),T==null)return;const le=he.current?.querySelector(`.file-item[data-path="${CSS.escape(T)}"]`);le?le.classList.add("drop-target"):he.current?.classList.add("drop-root")},[ce]),Le=T=>{const le=T instanceof Element?T.closest(".file-item"):null;return le?.dataset.type==="dir"?le.dataset.path??w:w},Oe=c.useCallback(()=>{const T=document.querySelector(".app");T&&T.dispatchEvent(new DragEvent("dragleave",{bubbles:!0}))},[]),P=1e4,ye=c.useRef(0),fe=c.useRef(void 0),Te=c.useCallback((T,le)=>{const se=++ye.current;k(T),le?.silent||S(!0),a({type:"list_files",path:T===""?void 0:T})||ye.current===se&&S(!1)},[a]);c.useEffect(()=>{t&&t.path===w&&S(!1)},[t,w]),c.useEffect(()=>{if(g!==fe.current){fe.current=g,Te("",{silent:!0});return}const T=setInterval(()=>{document.visibilityState!=="hidden"&&Te(w,{silent:!0})},P);return()=>clearInterval(T)},[g,w,Te]),c.useEffect(()=>{n&&n.path===w&&Te(w,{silent:!0})},[n,w,Te]);const Ne=T=>Te(T),Se=()=>{t?.parent!==null&&t?.parent!==void 0&&Te(t.parent)},Ce=(()=>{if(w===""||w===fs)return[];const T=w.split("/").filter(le=>!!le&&le!==fs);return w.startsWith("/")?T.map((le,se)=>({label:se===0?"/":T[se],path:"/"+T.slice(0,se+1).join("/")})):T.map((le,se)=>({label:T[se],path:T.slice(0,se+1).join("/")}))})();return s.jsxs("aside",{className:"panel panel-right",ref:I,children:[m&&E&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:h("collapsePanel"),onClick:E,children:s.jsx(Cr,{})}),s.jsxs("div",{className:"panel-crumbs",ref:j,children:[s.jsx("button",{type:"button",className:`crumb ${w===""?"active":""}`,onClick:()=>Te(""),children:h("rootDir")}),s.jsx("button",{type:"button",className:`crumb ${w===fs?"active":""}`,title:h("computer"),onClick:()=>Te(fs),children:"💻"}),Ce.map(T=>s.jsxs("span",{className:"crumb-seg",children:[s.jsx(zt,{}),s.jsx("button",{type:"button",className:`crumb ${T.path===w?"active":""}`,onClick:()=>Te(T.path),children:T.label})]},T.path))]}),s.jsxs("div",{ref:he,className:"panel-body",style:J?{flexGrow:H.files,minHeight:yi}:void 0,onContextMenu:T=>N(T,w),onDragOver:T=>{W(T)&&(T.preventDefault(),T.stopPropagation(),T.dataTransfer.dropEffect="copy",Oe(),F(Le(T.target)))},onDragLeave:T=>{T.relatedTarget&&T.currentTarget.contains(T.relatedTarget)||ce()},onDrop:T=>{if(ce(),!W(T))return;T.preventDefault(),T.stopPropagation(),Oe();const le=Array.from(T.dataTransfer?.files??[]);if(le.length===0){u("warning",h("foldersNotSupported"));return}ke(Le(T.target),le)},onDragEnd:ce,children:[s.jsx("input",{ref:O,type:"file",multiple:!0,hidden:!0,onChange:oe}),$&&s.jsx("div",{className:"panel-empty",children:h("loading")}),!$&&t&&t.path===w&&s.jsxs(s.Fragment,{children:[t.parent!=null&&s.jsxs("button",{type:"button",className:"file-item dir",onClick:Se,children:[s.jsx(Bt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:".."})]}),t.entries.map(T=>T.type==="dir"?s.jsxs("div",{className:"file-item dir","data-type":"dir","data-path":T.path,onContextMenu:le=>{le.stopPropagation();const se=ve(T.path);N(le,T.path,se?{path:se,name:T.name}:null)},children:[s.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>Ne(T.path),children:[s.jsx(Bt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:T.name})]}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":h("linkFolderTip"),"aria-label":h("linkFolderTip"),onClick:()=>o(T.path,T.name,"reference",!0),children:s.jsx(sa,{})}),s.jsx("button",{type:"button",className:`file-attach copy${R===`name:${T.path}`?" copied":""}`,"data-tip":h("copyName"),"aria-label":h("copyName"),onClick:()=>Z(T.name,`name:${T.path}`),children:R===`name:${T.path}`?s.jsx(Tt,{}):s.jsx(St,{})}),s.jsx("button",{type:"button",className:`file-attach copy${R===`path:${T.path}`?" copied":""}`,"data-tip":h("copyPath"),"aria-label":h("copyPath"),onClick:()=>Z(X(T.path),`path:${T.path}`),children:R===`path:${T.path}`?s.jsx(Tt,{}):s.jsx(Za,{})})]},T.path):s.jsxs("div",{className:"file-item file","data-type":"file","data-path":T.path,onContextMenu:le=>{le.stopPropagation(),N(le,w)},children:[s.jsxs("button",{type:"button",className:"file-name",title:`${T.path} — ${h("previewFile")}`,onClick:()=>l(T.path,T.name),children:[s.jsx(bc,{className:"file-icon"}),s.jsx("span",{className:"file-name-text",children:T.name})]}),s.jsx("button",{type:"button",className:"file-attach download","data-tip":h("downloadFile"),onClick:()=>{Ou(T.path,T.name).then(le=>{le.ok||le.cancelled||u("error",h("downloadFailed",{error:le.error===Kr?h("fileNotFoundShort"):le.error}))})},children:s.jsx(Yt,{})}),s.jsx("button",{type:"button",className:"file-attach inline","data-tip":h("attachInlineTip"),onClick:()=>o(T.path,T.name,"inline"),children:s.jsx(dt,{})}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":h("referenceTip"),"aria-label":h("referenceTip"),onClick:()=>o(T.path,T.name,"reference"),children:s.jsx(sa,{})}),s.jsx("button",{type:"button",className:`file-attach copy${R===`name:${T.path}`?" copied":""}`,"data-tip":h("copyName"),"aria-label":h("copyName"),onClick:()=>Z(T.name,`name:${T.path}`),children:R===`name:${T.path}`?s.jsx(Tt,{}):s.jsx(St,{})}),s.jsx("button",{type:"button",className:`file-attach copy${R===`path:${T.path}`?" copied":""}`,"data-tip":h("copyPath"),"aria-label":h("copyPath"),onClick:()=>Z(X(T.path),`path:${T.path}`),children:R===`path:${T.path}`?s.jsx(Tt,{}):s.jsx(Za,{})})]},T.path)),t.truncated&&s.jsx("div",{className:"panel-empty files-truncated",children:h("filesTruncated")})]}),!$&&!t&&s.jsx("div",{className:"panel-empty",children:h("noFiles")})]}),J&&s.jsx("div",{className:"rp-sash",onPointerDown:ue,onDoubleClick:()=>ee({...Kn}),title:h("dragToResize")}),J&&s.jsx("div",{className:"panel-widgets",style:{flexGrow:H.widgets,minHeight:Ni},children:i.filter(T=>T.lines.length>0).map(T=>s.jsxs("div",{className:"widget",children:[s.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:h("widgetExpand"),onClick:()=>M(T.key),children:[s.jsx("span",{children:T.key}),s.jsx(uc,{})]}),s.jsx("pre",{className:"widget-lines",children:T.lines.join(`
306
- `)})]},T.key))}),_&&(()=>{const T=i.find(le=>le.key===_);return T?s.jsx("div",{className:"modal-backdrop",onClick:()=>M(null),children:s.jsxs("div",{className:"widget-expand",onClick:le=>le.stopPropagation(),children:[s.jsxs("div",{className:"widget-expand-head",children:[s.jsx("span",{className:"widget-expand-title",children:T.key}),s.jsx("button",{type:"button",className:"btn",title:h("close"),onClick:()=>M(null),children:s.jsx(Ke,{})})]}),s.jsx("pre",{className:"widget-expand-lines",children:T.lines.join(`
307
- `)})]})}):null})(),pe&&s.jsxs("div",{className:"ctx-menu",style:{left:pe.x,top:pe.y},onContextMenu:T=>{T.preventDefault(),T.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",onClick:re,children:[s.jsx(yr,{}),Y.current===w?h("uploadToCurrentDir"):h("uploadToFolder")]}),ge.current&&s.jsxs("button",{type:"button",className:"ctx-item",onClick:de,children:[s.jsx(Bt,{}),h("openAsProject")]})]})]})});var Yr=br();function Fu(e){jl(e,[/\r?\n|\r/g,Hu])}function Hu(){return{type:"break"}}function Uu(){return function(e){Fu(e)}}function qu(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 m=ki(t,n[l-1]);u=m===-1?t.length+1:m+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],m=ki(t,u),E=m===-1?t.length+1:m+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 ki(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 Gr={}.hasOwnProperty,$u=Object.prototype;function Wu(e,t){const n=t||{};return Aa({file:n.file||void 0,location:!1,schema:n.space==="svg"?wn:Sa,verbose:n.verbose||!1},e)}function Aa(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:Vr(e,t.childNodes),data:{quirksMode:a}},e.file&&e.location){const o=String(e.file),l=qu(o),u=l.toPoint(0),m=l.toPoint(o.length);n.position={start:u,end:m}}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=Ku(e,t),n}}function Vr(e,t){let n=-1;const i=[];for(;++n<t.length;){const a=Aa(e,t[n]);i.push(a)}return i}function Ku(e,t){const n=e.schema;e.schema=t.namespaceURI===Wt.svg?wn:Sa;let i=-1;const a={};for(;++i<t.attrs.length;){const u=t.attrs[i],m=(u.prefix?u.prefix+":":"")+u.name;Gr.call($u,m)||(a[m]=u.value)}const l=(e.schema.space==="svg"?Ll:Rl)(t.tagName,a,Vr(e,t.childNodes));if(Xs(e,t,l),l.tagName==="template"){const u=t,m=u.sourceCodeLocation,E=m&&m.startTag&&ns(m.startTag),h=m&&m.endTag&&ns(m.endTag),g=Aa(e,u.content);E&&h&&e.file&&(g.position={start:E.end,end:h.start}),l.content=g}return e.schema=n,l}function Xs(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const i=Yu(e,n,t.sourceCodeLocation);i&&(e.location=!0,n.position=i)}}function Yu(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)Gr.call(n.attrs,l)&&(o[mr(e.schema,l).property]=ns(n.attrs[l]));ea(n.startTag);const u=ns(n.startTag),m=n.endTag?ns(n.endTag):void 0,E={opening:u};m&&(E.closing=m),E.properties=o,t.data={position:E}}}return i}function ns(e){const t=vi({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=vi({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function vi(e){return e.line&&e.column?e:void 0}const Gu={},Vu={}.hasOwnProperty,zr=pr("type",{handlers:{root:Qu,element:td,text:Zu,comment:ed,doctype:Ju}});function zu(e,t){const i=(t||Gu).space;return zr(e,i==="svg"?wn:Sa)}function Qu(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=Ia(e.children,n,t),us(e,n),n}function Xu(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=Ia(e.children,n,t),us(e,n),n}function Ju(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return us(e,t),t}function Zu(e){const t={nodeName:"#text",value:e.value,parentNode:null};return us(e,t),t}function ed(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return us(e,t),t}function td(e,t){const n=t;let i=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=wn);const a=[];let o;if(e.properties){for(o in e.properties)if(o!=="children"&&Vu.call(e.properties,o)){const m=sd(i,o,e.properties[o]);m&&a.push(m)}}const l=i.space,u={nodeName:e.tagName,tagName:e.tagName,attrs:a,namespaceURI:Wt[l],childNodes:[],parentNode:null};return u.childNodes=Ia(e.children,u,i),us(e,u),e.tagName==="template"&&e.content&&(u.content=Xu(e.content,i)),u}function sd(e,t,n){const i=mr(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?Dl(n):Pl(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 Ia(e,t,n){let i=-1;const a=[];if(e)for(;++i<e.length;){const o=zr(e[i],n);o.parentNode=t,a.push(o)}return a}function us(e,t){const n=e.position;n&&n.start&&n.end&&(ea(typeof n.start.offset=="number"),ea(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 nd=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],ad=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]),$e="�";var p;(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"})(p||(p={}));const at={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function Qr(e){return e>=55296&&e<=57343}function id(e){return e>=56320&&e<=57343}function rd(e,t){return(e-55296)*1024+9216+t}function Xr(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function Jr(e){return e>=64976&&e<=65007||ad.has(e)}var B;(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"})(B||(B={}));const od=65536;class ld{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=od,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(id(n))return this.pos++,this._addGap(),rd(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,p.EOF;return this._err(B.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,p.EOF;const i=this.html.charCodeAt(n);return i===p.CARRIAGE_RETURN?p.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,p.EOF;let t=this.html.charCodeAt(this.pos);return t===p.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,p.LINE_FEED):t===p.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,Qr(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===p.LINE_FEED||t===p.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){Xr(t)?this._err(B.controlCharacterInInputStream):Jr(t)&&this._err(B.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var Be;(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"})(Be||(Be={}));function Zr(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 cd=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୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢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;怳Ādp໩໮uct;戏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ǣጓ\0጖y;䐎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Ā;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀ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Ā;e᜚᜜lƀ;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\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩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ↄⅪ←ٖ↛ǰ↉\0↎proø₞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;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\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\0⹻m;櫳;櫽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))),ud=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 dd(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=ud.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 md=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 ma(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 hd(e){return e>=Je.UPPER_A&&e<=Je.UPPER_Z||e>=Je.LOWER_A&&e<=Je.LOWER_Z||ma(e)}function fd(e){return e===Je.EQUALS||hd(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 gd{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)|md)===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(ma(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(ma(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(dd(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=bd(i,a,this.treeIndex+Math.max(1,o),l),this.treeIndex<0)return this.result===0||this.decodeMode===Nt.Attribute&&(o===0||fd(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 bd(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 m=i-o;return m<0||m>=a?-1:e[n+m]-1}let l=n,u=l+a-1;for(;l<=u;){const m=l+u>>>1,E=e[m];if(E<i)l=m+1;else if(E>i)u=m-1;else return e[m+a]}return-1}var Q;(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/"})(Q||(Q={}));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 A;(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"})(A||(A={}));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 Ed=new Map([[A.A,r.A],[A.ADDRESS,r.ADDRESS],[A.ANNOTATION_XML,r.ANNOTATION_XML],[A.APPLET,r.APPLET],[A.AREA,r.AREA],[A.ARTICLE,r.ARTICLE],[A.ASIDE,r.ASIDE],[A.B,r.B],[A.BASE,r.BASE],[A.BASEFONT,r.BASEFONT],[A.BGSOUND,r.BGSOUND],[A.BIG,r.BIG],[A.BLOCKQUOTE,r.BLOCKQUOTE],[A.BODY,r.BODY],[A.BR,r.BR],[A.BUTTON,r.BUTTON],[A.CAPTION,r.CAPTION],[A.CENTER,r.CENTER],[A.CODE,r.CODE],[A.COL,r.COL],[A.COLGROUP,r.COLGROUP],[A.DD,r.DD],[A.DESC,r.DESC],[A.DETAILS,r.DETAILS],[A.DIALOG,r.DIALOG],[A.DIR,r.DIR],[A.DIV,r.DIV],[A.DL,r.DL],[A.DT,r.DT],[A.EM,r.EM],[A.EMBED,r.EMBED],[A.FIELDSET,r.FIELDSET],[A.FIGCAPTION,r.FIGCAPTION],[A.FIGURE,r.FIGURE],[A.FONT,r.FONT],[A.FOOTER,r.FOOTER],[A.FOREIGN_OBJECT,r.FOREIGN_OBJECT],[A.FORM,r.FORM],[A.FRAME,r.FRAME],[A.FRAMESET,r.FRAMESET],[A.H1,r.H1],[A.H2,r.H2],[A.H3,r.H3],[A.H4,r.H4],[A.H5,r.H5],[A.H6,r.H6],[A.HEAD,r.HEAD],[A.HEADER,r.HEADER],[A.HGROUP,r.HGROUP],[A.HR,r.HR],[A.HTML,r.HTML],[A.I,r.I],[A.IMG,r.IMG],[A.IMAGE,r.IMAGE],[A.INPUT,r.INPUT],[A.IFRAME,r.IFRAME],[A.KEYGEN,r.KEYGEN],[A.LABEL,r.LABEL],[A.LI,r.LI],[A.LINK,r.LINK],[A.LISTING,r.LISTING],[A.MAIN,r.MAIN],[A.MALIGNMARK,r.MALIGNMARK],[A.MARQUEE,r.MARQUEE],[A.MATH,r.MATH],[A.MENU,r.MENU],[A.META,r.META],[A.MGLYPH,r.MGLYPH],[A.MI,r.MI],[A.MO,r.MO],[A.MN,r.MN],[A.MS,r.MS],[A.MTEXT,r.MTEXT],[A.NAV,r.NAV],[A.NOBR,r.NOBR],[A.NOFRAMES,r.NOFRAMES],[A.NOEMBED,r.NOEMBED],[A.NOSCRIPT,r.NOSCRIPT],[A.OBJECT,r.OBJECT],[A.OL,r.OL],[A.OPTGROUP,r.OPTGROUP],[A.OPTION,r.OPTION],[A.P,r.P],[A.PARAM,r.PARAM],[A.PLAINTEXT,r.PLAINTEXT],[A.PRE,r.PRE],[A.RB,r.RB],[A.RP,r.RP],[A.RT,r.RT],[A.RTC,r.RTC],[A.RUBY,r.RUBY],[A.S,r.S],[A.SCRIPT,r.SCRIPT],[A.SEARCH,r.SEARCH],[A.SECTION,r.SECTION],[A.SELECT,r.SELECT],[A.SOURCE,r.SOURCE],[A.SMALL,r.SMALL],[A.SPAN,r.SPAN],[A.STRIKE,r.STRIKE],[A.STRONG,r.STRONG],[A.STYLE,r.STYLE],[A.SUB,r.SUB],[A.SUMMARY,r.SUMMARY],[A.SUP,r.SUP],[A.TABLE,r.TABLE],[A.TBODY,r.TBODY],[A.TEMPLATE,r.TEMPLATE],[A.TEXTAREA,r.TEXTAREA],[A.TFOOT,r.TFOOT],[A.TD,r.TD],[A.TH,r.TH],[A.THEAD,r.THEAD],[A.TITLE,r.TITLE],[A.TR,r.TR],[A.TRACK,r.TRACK],[A.TT,r.TT],[A.U,r.U],[A.UL,r.UL],[A.SVG,r.SVG],[A.VAR,r.VAR],[A.WBR,r.WBR],[A.XMP,r.XMP]]);function ds(e){var t;return(t=Ed.get(e))!==null&&t!==void 0?t:r.UNKNOWN}const ne=r,Td={[Q.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]),[Q.MATHML]:new Set([ne.MI,ne.MO,ne.MN,ne.MS,ne.MTEXT,ne.ANNOTATION_XML]),[Q.SVG]:new Set([ne.TITLE,ne.FOREIGN_OBJECT,ne.DESC]),[Q.XLINK]:new Set,[Q.XML]:new Set,[Q.XMLNS]:new Set},pa=new Set([ne.H1,ne.H2,ne.H3,ne.H4,ne.H5,ne.H6]);A.STYLE,A.SCRIPT,A.XMP,A.IFRAME,A.NOEMBED,A.NOFRAMES,A.PLAINTEXT;var f;(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"})(f||(f={}));const Ye={DATA:f.DATA,RCDATA:f.RCDATA,RAWTEXT:f.RAWTEXT,SCRIPT_DATA:f.SCRIPT_DATA,PLAINTEXT:f.PLAINTEXT,CDATA_SECTION:f.CDATA_SECTION};function xd(e){return e>=p.DIGIT_0&&e<=p.DIGIT_9}function ks(e){return e>=p.LATIN_CAPITAL_A&&e<=p.LATIN_CAPITAL_Z}function yd(e){return e>=p.LATIN_SMALL_A&&e<=p.LATIN_SMALL_Z}function Rt(e){return yd(e)||ks(e)}function Ci(e){return Rt(e)||xd(e)}function Ys(e){return e+32}function eo(e){return e===p.SPACE||e===p.LINE_FEED||e===p.TABULATION||e===p.FORM_FEED}function _i(e){return eo(e)||e===p.SOLIDUS||e===p.GREATER_THAN_SIGN}function Nd(e){return e===p.NULL?B.nullCharacterReference:e>1114111?B.characterReferenceOutsideUnicodeRange:Qr(e)?B.surrogateCharacterReference:Jr(e)?B.noncharacterCharacterReference:Xr(e)||e===p.CARRIAGE_RETURN?B.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=f.DATA,this.returnState=f.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new ld(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new gd(cd,(i,a)=>{this.preprocessor.pos=this.entityStartPos+a-1,this._flushCodePointConsumedAsCharacterReference(i)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(B.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:i=>{this._err(B.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+i)},validateNumericCharacterReference:i=>{const a=Nd(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:Be.START_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Be.END_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:Be.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:Be.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(Zr(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(B.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===Be.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(B.endTagWithAttributes),t.selfClosing&&this._err(B.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 Be.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case Be.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case Be.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:Be.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=eo(t)?Be.WHITESPACE_CHARACTER:t===p.NULL?Be.NULL_CHARACTER:Be.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(Be.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=f.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Nt.Attribute:Nt.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===f.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===f.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===f.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case f.DATA:{this._stateData(t);break}case f.RCDATA:{this._stateRcdata(t);break}case f.RAWTEXT:{this._stateRawtext(t);break}case f.SCRIPT_DATA:{this._stateScriptData(t);break}case f.PLAINTEXT:{this._statePlaintext(t);break}case f.TAG_OPEN:{this._stateTagOpen(t);break}case f.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case f.TAG_NAME:{this._stateTagName(t);break}case f.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case f.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case f.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case f.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case f.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case f.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case f.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case f.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case f.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case f.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case f.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case f.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case f.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case f.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case f.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case f.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case f.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case f.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case f.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case f.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case f.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case f.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case f.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case f.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case f.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case f.BOGUS_COMMENT:{this._stateBogusComment(t);break}case f.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case f.COMMENT_START:{this._stateCommentStart(t);break}case f.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case f.COMMENT:{this._stateComment(t);break}case f.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case f.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case f.COMMENT_END:{this._stateCommentEnd(t);break}case f.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case f.DOCTYPE:{this._stateDoctype(t);break}case f.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case f.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case f.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case f.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case f.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case f.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case f.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case f.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case f.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case f.CDATA_SECTION:{this._stateCdataSection(t);break}case f.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case f.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case f.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case f.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case p.LESS_THAN_SIGN:{this.state=f.TAG_OPEN;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(B.unexpectedNullCharacter),this._emitCodePoint(t);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case p.AMPERSAND:{this._startCharacterReference();break}case p.LESS_THAN_SIGN:{this.state=f.RCDATA_LESS_THAN_SIGN;break}case p.NULL:{this._err(B.unexpectedNullCharacter),this._emitChars($e);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case p.LESS_THAN_SIGN:{this.state=f.RAWTEXT_LESS_THAN_SIGN;break}case p.NULL:{this._err(B.unexpectedNullCharacter),this._emitChars($e);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_LESS_THAN_SIGN;break}case p.NULL:{this._err(B.unexpectedNullCharacter),this._emitChars($e);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case p.NULL:{this._err(B.unexpectedNullCharacter),this._emitChars($e);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(Rt(t))this._createStartTagToken(),this.state=f.TAG_NAME,this._stateTagName(t);else switch(t){case p.EXCLAMATION_MARK:{this.state=f.MARKUP_DECLARATION_OPEN;break}case p.SOLIDUS:{this.state=f.END_TAG_OPEN;break}case p.QUESTION_MARK:{this._err(B.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t);break}case p.EOF:{this._err(B.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(B.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=f.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(Rt(t))this._createEndTagToken(),this.state=f.TAG_NAME,this._stateTagName(t);else switch(t){case p.GREATER_THAN_SIGN:{this._err(B.missingEndTagName),this.state=f.DATA;break}case p.EOF:{this._err(B.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(B.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BEFORE_ATTRIBUTE_NAME;break}case p.SOLIDUS:{this.state=f.SELF_CLOSING_START_TAG;break}case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentTagToken();break}case p.NULL:{this._err(B.unexpectedNullCharacter),n.tagName+=$e;break}case p.EOF:{this._err(B.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(ks(t)?Ys(t):t)}}_stateRcdataLessThanSign(t){t===p.SOLIDUS?this.state=f.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=f.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){Rt(t)?(this.state=f.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=f.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 p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=f.BEFORE_ATTRIBUTE_NAME,!1;case p.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=f.SELF_CLOSING_START_TAG,!1;case p.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=f.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===p.SOLIDUS?this.state=f.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){Rt(t)?(this.state=f.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case p.SOLIDUS:{this.state=f.SCRIPT_DATA_END_TAG_OPEN;break}case p.EXCLAMATION_MARK:{this.state=f.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=f.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){Rt(t)?(this.state=f.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===p.HYPHEN_MINUS?(this.state=f.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===p.HYPHEN_MINUS?(this.state=f.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.NULL:{this._err(B.unexpectedNullCharacter),this._emitChars($e);break}case p.EOF:{this._err(B.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.NULL:{this._err(B.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_ESCAPED,this._emitChars($e);break}case p.EOF:{this._err(B.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case p.HYPHEN_MINUS:{this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.GREATER_THAN_SIGN:{this.state=f.SCRIPT_DATA,this._emitChars(">");break}case p.NULL:{this._err(B.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_ESCAPED,this._emitChars($e);break}case p.EOF:{this._err(B.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===p.SOLIDUS?this.state=f.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Rt(t)?(this._emitChars("<"),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){Rt(t)?(this.state=f.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(at.SCRIPT,!1)&&_i(this.preprocessor.peek(at.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<at.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.NULL:{this._err(B.unexpectedNullCharacter),this._emitChars($e);break}case p.EOF:{this._err(B.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.NULL:{this._err(B.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars($e);break}case p.EOF:{this._err(B.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case p.HYPHEN_MINUS:{this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.GREATER_THAN_SIGN:{this.state=f.SCRIPT_DATA,this._emitChars(">");break}case p.NULL:{this._err(B.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars($e);break}case p.EOF:{this._err(B.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===p.SOLIDUS?(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(at.SCRIPT,!1)&&_i(this.preprocessor.peek(at.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<at.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=f.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.SOLIDUS:case p.GREATER_THAN_SIGN:case p.EOF:{this.state=f.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case p.EQUALS_SIGN:{this._err(B.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=f.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=f.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:case p.SOLIDUS:case p.GREATER_THAN_SIGN:case p.EOF:{this._leaveAttrName(),this.state=f.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case p.EQUALS_SIGN:{this._leaveAttrName(),this.state=f.BEFORE_ATTRIBUTE_VALUE;break}case p.QUOTATION_MARK:case p.APOSTROPHE:case p.LESS_THAN_SIGN:{this._err(B.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case p.NULL:{this._err(B.unexpectedNullCharacter),this.currentAttr.name+=$e;break}default:this.currentAttr.name+=String.fromCodePoint(ks(t)?Ys(t):t)}}_stateAfterAttributeName(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.SOLIDUS:{this.state=f.SELF_CLOSING_START_TAG;break}case p.EQUALS_SIGN:{this.state=f.BEFORE_ATTRIBUTE_VALUE;break}case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(B.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=f.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.QUOTATION_MARK:{this.state=f.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this.state=f.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(B.missingAttributeValue),this.state=f.DATA,this.emitCurrentTagToken();break}default:this.state=f.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case p.QUOTATION_MARK:{this.state=f.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(B.unexpectedNullCharacter),this.currentAttr.value+=$e;break}case p.EOF:{this._err(B.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case p.APOSTROPHE:{this.state=f.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(B.unexpectedNullCharacter),this.currentAttr.value+=$e;break}case p.EOF:{this._err(B.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this._leaveAttrValue(),this.state=f.BEFORE_ATTRIBUTE_NAME;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=f.DATA,this.emitCurrentTagToken();break}case p.NULL:{this._err(B.unexpectedNullCharacter),this.currentAttr.value+=$e;break}case p.QUOTATION_MARK:case p.APOSTROPHE:case p.LESS_THAN_SIGN:case p.EQUALS_SIGN:case p.GRAVE_ACCENT:{this._err(B.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case p.EOF:{this._err(B.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this._leaveAttrValue(),this.state=f.BEFORE_ATTRIBUTE_NAME;break}case p.SOLIDUS:{this._leaveAttrValue(),this.state=f.SELF_CLOSING_START_TAG;break}case p.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=f.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(B.eofInTag),this._emitEOFToken();break}default:this._err(B.missingWhitespaceBetweenAttributes),this.state=f.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case p.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=f.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(B.eofInTag),this._emitEOFToken();break}default:this._err(B.unexpectedSolidusInTag),this.state=f.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentComment(n);break}case p.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case p.NULL:{this._err(B.unexpectedNullCharacter),n.data+=$e;break}default:n.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(at.DASH_DASH,!0)?(this._createCommentToken(at.DASH_DASH.length+1),this.state=f.COMMENT_START):this._consumeSequenceIfMatch(at.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(at.DOCTYPE.length+1),this.state=f.DOCTYPE):this._consumeSequenceIfMatch(at.CDATA_START,!0)?this.inForeignNode?this.state=f.CDATA_SECTION:(this._err(B.cdataInHtmlContent),this._createCommentToken(at.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=f.BOGUS_COMMENT):this._ensureHibernation()||(this._err(B.incorrectlyOpenedComment),this._createCommentToken(2),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.COMMENT_START_DASH;break}case p.GREATER_THAN_SIGN:{this._err(B.abruptClosingOfEmptyComment),this.state=f.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=f.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=f.COMMENT_END;break}case p.GREATER_THAN_SIGN:{this._err(B.abruptClosingOfEmptyComment),this.state=f.DATA,this.emitCurrentComment(n);break}case p.EOF:{this._err(B.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=f.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=f.COMMENT_END_DASH;break}case p.LESS_THAN_SIGN:{n.data+="<",this.state=f.COMMENT_LESS_THAN_SIGN;break}case p.NULL:{this._err(B.unexpectedNullCharacter),n.data+=$e;break}case p.EOF:{this._err(B.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case p.EXCLAMATION_MARK:{n.data+="!",this.state=f.COMMENT_LESS_THAN_SIGN_BANG;break}case p.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=f.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===p.HYPHEN_MINUS?this.state=f.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=f.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===p.HYPHEN_MINUS?this.state=f.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=f.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==p.GREATER_THAN_SIGN&&t!==p.EOF&&this._err(B.nestedComment),this.state=f.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=f.COMMENT_END;break}case p.EOF:{this._err(B.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=f.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentComment(n);break}case p.EXCLAMATION_MARK:{this.state=f.COMMENT_END_BANG;break}case p.HYPHEN_MINUS:{n.data+="-";break}case p.EOF:{this._err(B.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=f.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{n.data+="--!",this.state=f.COMMENT_END_DASH;break}case p.GREATER_THAN_SIGN:{this._err(B.incorrectlyClosedComment),this.state=f.DATA,this.emitCurrentComment(n);break}case p.EOF:{this._err(B.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=f.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this.state=f.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case p.EOF:{this._err(B.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(B.missingWhitespaceBeforeDoctypeName),this.state=f.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(ks(t))this._createDoctypeToken(String.fromCharCode(Ys(t))),this.state=f.DOCTYPE_NAME;else switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.NULL:{this._err(B.unexpectedNullCharacter),this._createDoctypeToken($e),this.state=f.DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this._err(B.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(B.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=f.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.AFTER_DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.NULL:{this._err(B.unexpectedNullCharacter),n.name+=$e;break}case p.EOF:{this._err(B.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 p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(B.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(at.PUBLIC,!1)?this.state=f.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(at.SYSTEM,!1)?this.state=f.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(B.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.QUOTATION_MARK:{this._err(B.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(B.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(B.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(B.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(B.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.QUOTATION_MARK:{n.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(B.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(B.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(B.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case p.QUOTATION_MARK:{this.state=f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.NULL:{this._err(B.unexpectedNullCharacter),n.publicId+=$e;break}case p.GREATER_THAN_SIGN:{this._err(B.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(B.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 p.APOSTROPHE:{this.state=f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.NULL:{this._err(B.unexpectedNullCharacter),n.publicId+=$e;break}case p.GREATER_THAN_SIGN:{this._err(B.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(B.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 p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.QUOTATION_MARK:{this._err(B.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(B.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.EOF:{this._err(B.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(B.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.QUOTATION_MARK:{n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.EOF:{this._err(B.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(B.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.QUOTATION_MARK:{this._err(B.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(B.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(B.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(B.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(B.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.QUOTATION_MARK:{n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(B.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(B.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(B.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case p.QUOTATION_MARK:{this.state=f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.NULL:{this._err(B.unexpectedNullCharacter),n.systemId+=$e;break}case p.GREATER_THAN_SIGN:{this._err(B.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(B.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 p.APOSTROPHE:{this.state=f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.NULL:{this._err(B.unexpectedNullCharacter),n.systemId+=$e;break}case p.GREATER_THAN_SIGN:{this._err(B.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(B.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 p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(B.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(B.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.NULL:{this._err(B.unexpectedNullCharacter);break}case p.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case p.RIGHT_SQUARE_BRACKET:{this.state=f.CDATA_SECTION_BRACKET;break}case p.EOF:{this._err(B.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===p.RIGHT_SQUARE_BRACKET?this.state=f.CDATA_SECTION_END:(this._emitChars("]"),this.state=f.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case p.GREATER_THAN_SIGN:{this.state=f.DATA;break}case p.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=f.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(p.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&Ci(this.preprocessor.peek(1))?f.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){Ci(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===p.SEMICOLON&&this._err(B.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const to=new Set([r.DD,r.DT,r.LI,r.OPTGROUP,r.OPTION,r.P,r.RB,r.RP,r.RT,r.RTC]),Si=new Set([...to,r.CAPTION,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]),En=new Set([r.APPLET,r.CAPTION,r.HTML,r.MARQUEE,r.OBJECT,r.TABLE,r.TD,r.TEMPLATE,r.TH]),vd=new Set([...En,r.OL,r.UL]),Cd=new Set([...En,r.BUTTON]),wi=new Set([r.ANNOTATION_XML,r.MI,r.MN,r.MO,r.MS,r.MTEXT]),Ai=new Set([r.DESC,r.FOREIGN_OBJECT,r.TITLE]),_d=new Set([r.TR,r.TEMPLATE,r.HTML]),Sd=new Set([r.TBODY,r.TFOOT,r.THEAD,r.TEMPLATE,r.HTML]),wd=new Set([r.TABLE,r.TEMPLATE,r.HTML]),Ad=new Set([r.TD,r.TH]);class Id{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)===Q.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])!==Q.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(pa,Q.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Ad,Q.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(wd,Q.HTML)}clearBackToTableBodyContext(){this.clearBackTo(Sd,Q.HTML)}clearBackToTableRowContext(){this.clearBackTo(_d,Q.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 Q.HTML:{if(a===t)return!0;if(n.has(a))return!1;break}case Q.SVG:{if(Ai.has(a))return!1;break}case Q.MATHML:{if(wi.has(a))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,En)}hasInListItemScope(t){return this.hasInDynamicScope(t,vd)}hasInButtonScope(t){return this.hasInDynamicScope(t,Cd)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case Q.HTML:{if(pa.has(n))return!0;if(En.has(n))return!1;break}case Q.SVG:{if(Ai.has(n))return!1;break}case Q.MATHML:{if(wi.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===Q.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])===Q.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])===Q.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&&to.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&Si.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&Si.has(this.currentTagId);)this.pop()}}const Yn=3;var Et;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Et||(Et={}));const Ii={type:Et.Marker};class jd{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 m=this.entries[u];if(m.type===Et.Marker)break;const{element:E}=m;if(this.treeAdapter.getTagName(E)===o&&this.treeAdapter.getNamespaceURI(E)===l){const h=this.treeAdapter.getAttrList(E);h.length===a&&i.push({idx:u,attrs:h})}}return i}_ensureNoahArkCondition(t){if(this.entries.length<Yn)return;const n=this.treeAdapter.getAttrList(t),i=this._getNoahArkConditionCandidates(t,n);if(i.length<Yn)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(m=>a.get(m.name)===m.value)&&(o+=1,o>=Yn&&this.entries.splice(u.idx,1))}}insertMarker(){this.entries.unshift(Ii)}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(Ii);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}}},so="html",Ld="about:legacy-compat",Rd="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",no=["+//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//"],Dd=[...no,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],Pd=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),ao=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],Od=[...ao,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function ji(e,t){return t.some(n=>e.startsWith(n))}function Md(e){return e.name===so&&e.publicId===null&&(e.systemId===null||e.systemId===Ld)}function Bd(e){if(e.name!==so)return ut.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===Rd)return ut.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),Pd.has(n))return ut.QUIRKS;let i=t===null?Dd:no;if(ji(n,i))return ut.QUIRKS;if(i=t===null?ao:Od,ji(n,i))return ut.LIMITED_QUIRKS}return ut.NO_QUIRKS}const Li={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},Fd="definitionurl",Hd="definitionURL",Ud=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])),qd=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:Q.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:Q.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:Q.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:Q.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:Q.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:Q.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:Q.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:Q.XML}],["xml:space",{prefix:"xml",name:"space",namespace:Q.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:Q.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:Q.XMLNS}]]),$d=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])),Wd=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 Kd(e){const t=e.tagID;return t===r.FONT&&e.attrs.some(({name:i})=>i===Gt.COLOR||i===Gt.SIZE||i===Gt.FACE)||Wd.has(t)}function io(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===Fd){e.attrs[t].name=Hd;break}}function ro(e){for(let t=0;t<e.attrs.length;t++){const n=Ud.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function ja(e){for(let t=0;t<e.attrs.length;t++){const n=qd.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 Yd(e){const t=$d.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=ds(e.tagName))}function Gd(e,t){return t===Q.MATHML&&(e===r.MI||e===r.MO||e===r.MN||e===r.MS||e===r.MTEXT)}function Vd(e,t,n){if(t===Q.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===Li.TEXT_HTML||a===Li.APPLICATION_XML}}return t===Q.SVG&&(e===r.FOREIGN_OBJECT||e===r.DESC||e===r.TITLE)}function zd(e,t,n,i){return(!i||i===Q.HTML)&&Vd(e,t,n)||(!i||i===Q.MATHML)&&Gd(e,t)}const Qd="hidden",Xd=8,Jd=3;var b;(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"})(b||(b={}));const Zd={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},oo=new Set([r.TABLE,r.TBODY,r.TFOOT,r.THEAD,r.TR]),Ri={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Dt,onParseError:null};class Di{constructor(t,n,i=null,a=null){this.fragmentContext=i,this.scriptHandler=a,this.currentToken=null,this.stopped=!1,this.insertionMode=b.INITIAL,this.originalInsertionMode=b.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={...Ri,...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 jd(this.treeAdapter),this.fragmentContextID=i?ds(this.treeAdapter.getTagName(i)):r.UNKNOWN,this._setContextModes(i??this.document,this.fragmentContextID),this.openElements=new Id(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={...Ri,...n};t??(t=i.treeAdapter.createElement(A.TEMPLATE,Q.HTML,[]));const a=i.treeAdapter.createElement("documentmock",Q.HTML,[]),o=new this(i,a,t);return o.fragmentContextID===r.TEMPLATE&&o.tmplInsertionModeStack.unshift(b.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:Zd,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)===Q.HTML;this.currentNotInHTML=!i,this.tokenizer.inForeignNode=!i&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,Q.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=b.TEXT}switchToPlaintextParsing(){this.insertionMode=b.TEXT,this.originalInsertionMode=b.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)===A.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==Q.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,Q.HTML,[]);this._attachElementToTree(i,null),this.openElements.push(i,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,Q.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(A.HTML,Q.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:m,endCol:E,endOffset:h}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(l,{endLine:m,endCol:E,endOffset:h})}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===Be.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)===A.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===Q.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===r.MGLYPH||t.tagID===r.MALIGNMARK)&&i!==void 0&&!this._isIntegrationPoint(i,n,Q.HTML)}_processToken(t){switch(t.type){case Be.CHARACTER:{this.onCharacter(t);break}case Be.NULL_CHARACTER:{this.onNullCharacter(t);break}case Be.COMMENT:{this.onComment(t);break}case Be.DOCTYPE:{this.onDoctype(t);break}case Be.START_TAG:{this._processStartTag(t);break}case Be.END_TAG:{this.onEndTag(t);break}case Be.EOF:{this.onEof(t);break}case Be.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,i){const a=this.treeAdapter.getNamespaceURI(n),o=this.treeAdapter.getAttrList(n);return zd(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=b.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=b.IN_ROW;return}case r.TBODY:case r.THEAD:case r.TFOOT:{this.insertionMode=b.IN_TABLE_BODY;return}case r.CAPTION:{this.insertionMode=b.IN_CAPTION;return}case r.COLGROUP:{this.insertionMode=b.IN_COLUMN_GROUP;return}case r.TABLE:{this.insertionMode=b.IN_TABLE;return}case r.BODY:{this.insertionMode=b.IN_BODY;return}case r.FRAMESET:{this.insertionMode=b.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?b.AFTER_HEAD:b.BEFORE_HEAD;return}case r.TD:case r.TH:{if(t>0){this.insertionMode=b.IN_CELL;return}break}case r.HEAD:{if(t>0){this.insertionMode=b.IN_HEAD;return}break}}this.insertionMode=b.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=b.IN_SELECT_IN_TABLE;return}}this.insertionMode=b.IN_SELECT}_isElementCausesFosterParenting(t){return oo.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)===Q.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 Td[i].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Ap(this,t);return}switch(this.insertionMode){case b.INITIAL:{gs(this,t);break}case b.BEFORE_HTML:{Cs(this,t);break}case b.BEFORE_HEAD:{_s(this,t);break}case b.IN_HEAD:{Ss(this,t);break}case b.IN_HEAD_NO_SCRIPT:{ws(this,t);break}case b.AFTER_HEAD:{As(this,t);break}case b.IN_BODY:case b.IN_CAPTION:case b.IN_CELL:case b.IN_TEMPLATE:{co(this,t);break}case b.TEXT:case b.IN_SELECT:case b.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case b.IN_TABLE:case b.IN_TABLE_BODY:case b.IN_ROW:{Gn(this,t);break}case b.IN_TABLE_TEXT:{go(this,t);break}case b.IN_COLUMN_GROUP:{Tn(this,t);break}case b.AFTER_BODY:{xn(this,t);break}case b.AFTER_AFTER_BODY:{Js(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){wp(this,t);return}switch(this.insertionMode){case b.INITIAL:{gs(this,t);break}case b.BEFORE_HTML:{Cs(this,t);break}case b.BEFORE_HEAD:{_s(this,t);break}case b.IN_HEAD:{Ss(this,t);break}case b.IN_HEAD_NO_SCRIPT:{ws(this,t);break}case b.AFTER_HEAD:{As(this,t);break}case b.TEXT:{this._insertCharacters(t);break}case b.IN_TABLE:case b.IN_TABLE_BODY:case b.IN_ROW:{Gn(this,t);break}case b.IN_COLUMN_GROUP:{Tn(this,t);break}case b.AFTER_BODY:{xn(this,t);break}case b.AFTER_AFTER_BODY:{Js(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){ha(this,t);return}switch(this.insertionMode){case b.INITIAL:case b.BEFORE_HTML:case b.BEFORE_HEAD:case b.IN_HEAD:case b.IN_HEAD_NO_SCRIPT:case b.AFTER_HEAD:case b.IN_BODY:case b.IN_TABLE:case b.IN_CAPTION:case b.IN_COLUMN_GROUP:case b.IN_TABLE_BODY:case b.IN_ROW:case b.IN_CELL:case b.IN_SELECT:case b.IN_SELECT_IN_TABLE:case b.IN_TEMPLATE:case b.IN_FRAMESET:case b.AFTER_FRAMESET:{ha(this,t);break}case b.IN_TABLE_TEXT:{bs(this,t);break}case b.AFTER_BODY:{rm(this,t);break}case b.AFTER_AFTER_BODY:case b.AFTER_AFTER_FRAMESET:{om(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case b.INITIAL:{lm(this,t);break}case b.BEFORE_HEAD:case b.IN_HEAD:case b.IN_HEAD_NO_SCRIPT:case b.AFTER_HEAD:{this._err(t,B.misplacedDoctype);break}case b.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,B.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?Ip(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case b.INITIAL:{gs(this,t);break}case b.BEFORE_HTML:{cm(this,t);break}case b.BEFORE_HEAD:{dm(this,t);break}case b.IN_HEAD:{ht(this,t);break}case b.IN_HEAD_NO_SCRIPT:{hm(this,t);break}case b.AFTER_HEAD:{gm(this,t);break}case b.IN_BODY:{Ze(this,t);break}case b.IN_TABLE:{os(this,t);break}case b.IN_TABLE_TEXT:{bs(this,t);break}case b.IN_CAPTION:{mp(this,t);break}case b.IN_COLUMN_GROUP:{Da(this,t);break}case b.IN_TABLE_BODY:{Rn(this,t);break}case b.IN_ROW:{Dn(this,t);break}case b.IN_CELL:{fp(this,t);break}case b.IN_SELECT:{To(this,t);break}case b.IN_SELECT_IN_TABLE:{bp(this,t);break}case b.IN_TEMPLATE:{Tp(this,t);break}case b.AFTER_BODY:{yp(this,t);break}case b.IN_FRAMESET:{Np(this,t);break}case b.AFTER_FRAMESET:{vp(this,t);break}case b.AFTER_AFTER_BODY:{_p(this,t);break}case b.AFTER_AFTER_FRAMESET:{Sp(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?jp(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case b.INITIAL:{gs(this,t);break}case b.BEFORE_HTML:{um(this,t);break}case b.BEFORE_HEAD:{mm(this,t);break}case b.IN_HEAD:{pm(this,t);break}case b.IN_HEAD_NO_SCRIPT:{fm(this,t);break}case b.AFTER_HEAD:{bm(this,t);break}case b.IN_BODY:{Ln(this,t);break}case b.TEXT:{sp(this,t);break}case b.IN_TABLE:{Ps(this,t);break}case b.IN_TABLE_TEXT:{bs(this,t);break}case b.IN_CAPTION:{pp(this,t);break}case b.IN_COLUMN_GROUP:{hp(this,t);break}case b.IN_TABLE_BODY:{fa(this,t);break}case b.IN_ROW:{Eo(this,t);break}case b.IN_CELL:{gp(this,t);break}case b.IN_SELECT:{xo(this,t);break}case b.IN_SELECT_IN_TABLE:{Ep(this,t);break}case b.IN_TEMPLATE:{xp(this,t);break}case b.AFTER_BODY:{No(this,t);break}case b.IN_FRAMESET:{kp(this,t);break}case b.AFTER_FRAMESET:{Cp(this,t);break}case b.AFTER_AFTER_BODY:{Js(this,t);break}}}onEof(t){switch(this.insertionMode){case b.INITIAL:{gs(this,t);break}case b.BEFORE_HTML:{Cs(this,t);break}case b.BEFORE_HEAD:{_s(this,t);break}case b.IN_HEAD:{Ss(this,t);break}case b.IN_HEAD_NO_SCRIPT:{ws(this,t);break}case b.AFTER_HEAD:{As(this,t);break}case b.IN_BODY:case b.IN_TABLE:case b.IN_CAPTION:case b.IN_COLUMN_GROUP:case b.IN_TABLE_BODY:case b.IN_ROW:case b.IN_CELL:case b.IN_SELECT:case b.IN_SELECT_IN_TABLE:{ho(this,t);break}case b.TEXT:{np(this,t);break}case b.IN_TABLE_TEXT:{bs(this,t);break}case b.IN_TEMPLATE:{yo(this,t);break}case b.AFTER_BODY:case b.IN_FRAMESET:case b.AFTER_FRAMESET:case b.AFTER_AFTER_BODY:case b.AFTER_AFTER_FRAMESET:{Ra(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===p.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 b.IN_HEAD:case b.IN_HEAD_NO_SCRIPT:case b.AFTER_HEAD:case b.TEXT:case b.IN_COLUMN_GROUP:case b.IN_SELECT:case b.IN_SELECT_IN_TABLE:case b.IN_FRAMESET:case b.AFTER_FRAMESET:{this._insertCharacters(t);break}case b.IN_BODY:case b.IN_CAPTION:case b.IN_CELL:case b.IN_TEMPLATE:case b.AFTER_BODY:case b.AFTER_AFTER_BODY:case b.AFTER_AFTER_FRAMESET:{lo(this,t);break}case b.IN_TABLE:case b.IN_TABLE_BODY:case b.IN_ROW:{Gn(this,t);break}case b.IN_TABLE_TEXT:{fo(this,t);break}}}}function em(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):po(e,t),n}function tm(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 sm(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),m=u&&o>=Jd;!u||m?(m&&e.activeFormattingElements.removeEntry(u),e.openElements.remove(l)):(l=nm(e,u),i===t&&(e.activeFormattingElements.bookmark=u),e.treeAdapter.detachNode(i),e.treeAdapter.appendChild(l,i),i=l)}return i}function nm(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 am(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===Q.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function im(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 La(e,t){for(let n=0;n<Xd;n++){const i=em(e,t);if(!i)break;const a=tm(e,i);if(!a)break;e.activeFormattingElements.bookmark=i;const o=sm(e,a,i.element),l=e.openElements.getCommonAncestor(i.element);e.treeAdapter.detachNode(o),l&&am(e,l,o),im(e,a,i)}}function ha(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function rm(e,t){e._appendCommentNode(t,e.openElements.items[0])}function om(e,t){e._appendCommentNode(t,e.document)}function Ra(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 lm(e,t){e._setDocumentType(t);const n=t.forceQuirks?ut.QUIRKS:Bd(t);Md(t)||e._err(t,B.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=b.BEFORE_HTML}function gs(e,t){e._err(t,B.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,ut.QUIRKS),e.insertionMode=b.BEFORE_HTML,e._processToken(t)}function cm(e,t){t.tagID===r.HTML?(e._insertElement(t,Q.HTML),e.insertionMode=b.BEFORE_HEAD):Cs(e,t)}function um(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=b.BEFORE_HEAD,e._processToken(t)}function dm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.HEAD:{e._insertElement(t,Q.HTML),e.headElement=e.openElements.current,e.insertionMode=b.IN_HEAD;break}default:_s(e,t)}}function mm(e,t){const n=t.tagID;n===r.HEAD||n===r.BODY||n===r.HTML||n===r.BR?_s(e,t):e._err(t,B.endTagWithoutMatchingOpenElement)}function _s(e,t){e._insertFakeElement(A.HEAD,r.HEAD),e.headElement=e.openElements.current,e.insertionMode=b.IN_HEAD,e._processToken(t)}function ht(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,Q.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,Q.HTML),e.insertionMode=b.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=b.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(b.IN_TEMPLATE);break}case r.HEAD:{e._err(t,B.misplacedStartTagForHeadElement);break}default:Ss(e,t)}}function pm(e,t){switch(t.tagID){case r.HEAD:{e.openElements.pop(),e.insertionMode=b.AFTER_HEAD;break}case r.BODY:case r.BR:case r.HTML:{Ss(e,t);break}case r.TEMPLATE:{Qt(e,t);break}default:e._err(t,B.endTagWithoutMatchingOpenElement)}}function Qt(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==r.TEMPLATE&&e._err(t,B.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,B.endTagWithoutMatchingOpenElement)}function Ss(e,t){e.openElements.pop(),e.insertionMode=b.AFTER_HEAD,e._processToken(t)}function hm(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:{ht(e,t);break}case r.NOSCRIPT:{e._err(t,B.nestedNoscriptInHead);break}default:ws(e,t)}}function fm(e,t){switch(t.tagID){case r.NOSCRIPT:{e.openElements.pop(),e.insertionMode=b.IN_HEAD;break}case r.BR:{ws(e,t);break}default:e._err(t,B.endTagWithoutMatchingOpenElement)}}function ws(e,t){const n=t.type===Be.EOF?B.openElementsLeftAfterEof:B.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=b.IN_HEAD,e._processToken(t)}function gm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BODY:{e._insertElement(t,Q.HTML),e.framesetOk=!1,e.insertionMode=b.IN_BODY;break}case r.FRAMESET:{e._insertElement(t,Q.HTML),e.insertionMode=b.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,B.abandonedHeadElementChild),e.openElements.push(e.headElement,r.HEAD),ht(e,t),e.openElements.remove(e.headElement);break}case r.HEAD:{e._err(t,B.misplacedStartTagForHeadElement);break}default:As(e,t)}}function bm(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,B.endTagWithoutMatchingOpenElement)}}function As(e,t){e._insertFakeElement(A.BODY,r.BODY),e.insertionMode=b.IN_BODY,jn(e,t)}function jn(e,t){switch(t.type){case Be.CHARACTER:{co(e,t);break}case Be.WHITESPACE_CHARACTER:{lo(e,t);break}case Be.COMMENT:{ha(e,t);break}case Be.START_TAG:{Ze(e,t);break}case Be.END_TAG:{Ln(e,t);break}case Be.EOF:{ho(e,t);break}}}function lo(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function co(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function Em(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function Tm(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function xm(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Q.HTML),e.insertionMode=b.IN_FRAMESET)}function ym(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Q.HTML)}function Nm(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&pa.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Q.HTML)}function km(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Q.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function vm(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Q.HTML),n||(e.formElement=e.openElements.current))}function Cm(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,Q.HTML)}function _m(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Q.HTML),e.tokenizer.state=Ye.PLAINTEXT}function Sm(e,t){e.openElements.hasInScope(r.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,Q.HTML),e.framesetOk=!1}function wm(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(A.A);n&&(La(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,Q.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Am(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Q.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Im(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(r.NOBR)&&(La(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Q.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function jm(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Q.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function Lm(e,t){e.treeAdapter.getDocumentMode(e.document)!==ut.QUIRKS&&e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Q.HTML),e.framesetOk=!1,e.insertionMode=b.IN_TABLE}function uo(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Q.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function mo(e){const t=Zr(e,Gt.TYPE);return t!=null&&t.toLowerCase()===Qd}function Rm(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Q.HTML),mo(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function Dm(e,t){e._appendElement(t,Q.HTML),t.ackSelfClosing=!0}function Pm(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._appendElement(t,Q.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Om(e,t){t.tagName=A.IMG,t.tagID=r.IMG,uo(e,t)}function Mm(e,t){e._insertElement(t,Q.HTML),e.skipNextNewLine=!0,e.tokenizer.state=Ye.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=b.TEXT}function Bm(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Ye.RAWTEXT)}function Fm(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Ye.RAWTEXT)}function Pi(e,t){e._switchToTextParsing(t,Ye.RAWTEXT)}function Hm(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Q.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===b.IN_TABLE||e.insertionMode===b.IN_CAPTION||e.insertionMode===b.IN_TABLE_BODY||e.insertionMode===b.IN_ROW||e.insertionMode===b.IN_CELL?b.IN_SELECT_IN_TABLE:b.IN_SELECT}function Um(e,t){e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Q.HTML)}function qm(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Q.HTML)}function $m(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(r.RTC),e._insertElement(t,Q.HTML)}function Wm(e,t){e._reconstructActiveFormattingElements(),io(t),ja(t),t.selfClosing?e._appendElement(t,Q.MATHML):e._insertElement(t,Q.MATHML),t.ackSelfClosing=!0}function Km(e,t){e._reconstructActiveFormattingElements(),ro(t),ja(t),t.selfClosing?e._appendElement(t,Q.SVG):e._insertElement(t,Q.SVG),t.ackSelfClosing=!0}function Oi(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Q.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:{Am(e,t);break}case r.A:{wm(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Nm(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:{ym(e,t);break}case r.LI:case r.DD:case r.DT:{Cm(e,t);break}case r.BR:case r.IMG:case r.WBR:case r.AREA:case r.EMBED:case r.KEYGEN:{uo(e,t);break}case r.HR:{Pm(e,t);break}case r.RB:case r.RTC:{qm(e,t);break}case r.RT:case r.RP:{$m(e,t);break}case r.PRE:case r.LISTING:{km(e,t);break}case r.XMP:{Bm(e,t);break}case r.SVG:{Km(e,t);break}case r.HTML:{Em(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:{ht(e,t);break}case r.BODY:{Tm(e,t);break}case r.FORM:{vm(e,t);break}case r.NOBR:{Im(e,t);break}case r.MATH:{Wm(e,t);break}case r.TABLE:{Lm(e,t);break}case r.INPUT:{Rm(e,t);break}case r.PARAM:case r.TRACK:case r.SOURCE:{Dm(e,t);break}case r.IMAGE:{Om(e,t);break}case r.BUTTON:{Sm(e,t);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{jm(e,t);break}case r.IFRAME:{Fm(e,t);break}case r.SELECT:{Hm(e,t);break}case r.OPTION:case r.OPTGROUP:{Um(e,t);break}case r.NOEMBED:case r.NOFRAMES:{Pi(e,t);break}case r.FRAMESET:{xm(e,t);break}case r.TEXTAREA:{Mm(e,t);break}case r.NOSCRIPT:{e.options.scriptingEnabled?Pi(e,t):Oi(e,t);break}case r.PLAINTEXT:{_m(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:Oi(e,t)}}function Ym(e,t){if(e.openElements.hasInScope(r.BODY)&&(e.insertionMode=b.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function Gm(e,t){e.openElements.hasInScope(r.BODY)&&(e.insertionMode=b.AFTER_BODY,No(e,t))}function Vm(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function zm(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 Qm(e){e.openElements.hasInButtonScope(r.P)||e._insertFakeElement(A.P,r.P),e._closePElement()}function Xm(e){e.openElements.hasInListItemScope(r.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(r.LI),e.openElements.popUntilTagNamePopped(r.LI))}function Jm(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function Zm(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function ep(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function tp(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(A.BR,r.BR),e.openElements.pop(),e.framesetOk=!1}function po(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 Ln(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:{La(e,t);break}case r.P:{Qm(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:{Vm(e,t);break}case r.LI:{Xm(e);break}case r.DD:case r.DT:{Jm(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Zm(e);break}case r.BR:{tp(e);break}case r.BODY:{Ym(e,t);break}case r.HTML:{Gm(e,t);break}case r.FORM:{zm(e);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{ep(e,t);break}case r.TEMPLATE:{Qt(e,t);break}default:po(e,t)}}function ho(e,t){e.tmplInsertionModeStack.length>0?yo(e,t):Ra(e,t)}function sp(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 np(e,t){e._err(t,B.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Gn(e,t){if(e.openElements.currentTagId!==void 0&&oo.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=b.IN_TABLE_TEXT,t.type){case Be.CHARACTER:{go(e,t);break}case Be.WHITESPACE_CHARACTER:{fo(e,t);break}}else Bs(e,t)}function ap(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Q.HTML),e.insertionMode=b.IN_CAPTION}function ip(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Q.HTML),e.insertionMode=b.IN_COLUMN_GROUP}function rp(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(A.COLGROUP,r.COLGROUP),e.insertionMode=b.IN_COLUMN_GROUP,Da(e,t)}function op(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Q.HTML),e.insertionMode=b.IN_TABLE_BODY}function lp(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(A.TBODY,r.TBODY),e.insertionMode=b.IN_TABLE_BODY,Rn(e,t)}function cp(e,t){e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function up(e,t){mo(t)?e._appendElement(t,Q.HTML):Bs(e,t),t.ackSelfClosing=!0}function dp(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,Q.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:{lp(e,t);break}case r.STYLE:case r.SCRIPT:case r.TEMPLATE:{ht(e,t);break}case r.COL:{rp(e,t);break}case r.FORM:{dp(e,t);break}case r.TABLE:{cp(e,t);break}case r.TBODY:case r.TFOOT:case r.THEAD:{op(e,t);break}case r.INPUT:{up(e,t);break}case r.CAPTION:{ap(e,t);break}case r.COLGROUP:{ip(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,jn(e,t),e.fosterParentingEnabled=n}function fo(e,t){e.pendingCharacterTokens.push(t)}function go(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 bo=new Set([r.CAPTION,r.COL,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]);function mp(e,t){const n=t.tagID;bo.has(n)?e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=b.IN_TABLE,os(e,t)):Ze(e,t)}function pp(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=b.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:Ln(e,t)}}function Da(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.COL:{e._appendElement(t,Q.HTML),t.ackSelfClosing=!0;break}case r.TEMPLATE:{ht(e,t);break}default:Tn(e,t)}}function hp(e,t){switch(t.tagID){case r.COLGROUP:{e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=b.IN_TABLE);break}case r.TEMPLATE:{Qt(e,t);break}case r.COL:break;default:Tn(e,t)}}function Tn(e,t){e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=b.IN_TABLE,e._processToken(t))}function Rn(e,t){switch(t.tagID){case r.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,Q.HTML),e.insertionMode=b.IN_ROW;break}case r.TH:case r.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(A.TR,r.TR),e.insertionMode=b.IN_ROW,Dn(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=b.IN_TABLE,os(e,t));break}default:os(e,t)}}function fa(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=b.IN_TABLE);break}case r.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=b.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 Dn(e,t){switch(t.tagID){case r.TH:case r.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,Q.HTML),e.insertionMode=b.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=b.IN_TABLE_BODY,Rn(e,t));break}default:os(e,t)}}function Eo(e,t){switch(t.tagID){case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=b.IN_TABLE_BODY);break}case r.TABLE:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=b.IN_TABLE_BODY,fa(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=b.IN_TABLE_BODY,fa(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 fp(e,t){const n=t.tagID;bo.has(n)?(e.openElements.hasInTableScope(r.TD)||e.openElements.hasInTableScope(r.TH))&&(e._closeTableCell(),Dn(e,t)):Ze(e,t)}function gp(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=b.IN_ROW);break}case r.TABLE:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),Eo(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:break;default:Ln(e,t)}}function To(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,Q.HTML);break}case r.OPTGROUP:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._insertElement(t,Q.HTML);break}case r.HR:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._appendElement(t,Q.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:{ht(e,t);break}}}function xo(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 bp(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)):To(e,t)}function Ep(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)):xo(e,t)}function Tp(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:{ht(e,t);break}case r.CAPTION:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.tmplInsertionModeStack[0]=b.IN_TABLE,e.insertionMode=b.IN_TABLE,os(e,t);break}case r.COL:{e.tmplInsertionModeStack[0]=b.IN_COLUMN_GROUP,e.insertionMode=b.IN_COLUMN_GROUP,Da(e,t);break}case r.TR:{e.tmplInsertionModeStack[0]=b.IN_TABLE_BODY,e.insertionMode=b.IN_TABLE_BODY,Rn(e,t);break}case r.TD:case r.TH:{e.tmplInsertionModeStack[0]=b.IN_ROW,e.insertionMode=b.IN_ROW,Dn(e,t);break}default:e.tmplInsertionModeStack[0]=b.IN_BODY,e.insertionMode=b.IN_BODY,Ze(e,t)}}function xp(e,t){t.tagID===r.TEMPLATE&&Qt(e,t)}function yo(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):Ra(e,t)}function yp(e,t){t.tagID===r.HTML?Ze(e,t):xn(e,t)}function No(e,t){var n;if(t.tagID===r.HTML){if(e.fragmentContext||(e.insertionMode=b.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 xn(e,t)}function xn(e,t){e.insertionMode=b.IN_BODY,jn(e,t)}function Np(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.FRAMESET:{e._insertElement(t,Q.HTML);break}case r.FRAME:{e._appendElement(t,Q.HTML),t.ackSelfClosing=!0;break}case r.NOFRAMES:{ht(e,t);break}}}function kp(e,t){t.tagID===r.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==r.FRAMESET&&(e.insertionMode=b.AFTER_FRAMESET))}function vp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{ht(e,t);break}}}function Cp(e,t){t.tagID===r.HTML&&(e.insertionMode=b.AFTER_AFTER_FRAMESET)}function _p(e,t){t.tagID===r.HTML?Ze(e,t):Js(e,t)}function Js(e,t){e.insertionMode=b.IN_BODY,jn(e,t)}function Sp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{ht(e,t);break}}}function wp(e,t){t.chars=$e,e._insertCharacters(t)}function Ap(e,t){e._insertCharacters(t),e.framesetOk=!1}function ko(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==Q.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function Ip(e,t){if(Kd(t))ko(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),i=e.treeAdapter.getNamespaceURI(n);i===Q.MATHML?io(t):i===Q.SVG&&(Yd(t),ro(t)),ja(t),t.selfClosing?e._appendElement(t,i):e._insertElement(t,i),t.ackSelfClosing=!0}}function jp(e,t){if(t.tagID===r.P||t.tagID===r.BR){ko(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)===Q.HTML){e._endTagOutsideForeignContent(t);break}const a=e.treeAdapter.getTagName(i);if(a.toLowerCase()===t.tagName){t.tagName=a,e.openElements.shortenToLength(n);break}}}A.AREA,A.BASE,A.BASEFONT,A.BGSOUND,A.BR,A.COL,A.EMBED,A.FRAME,A.HR,A.IMG,A.INPUT,A.KEYGEN,A.LINK,A.META,A.PARAM,A.SOURCE,A.TRACK,A.WBR;const Lp=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,Rp=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),Mi={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function vo(e,t){const n=$p(e),i=pr("type",{handlers:{root:Dp,element:Pp,text:Op,comment:_o,doctype:Mp,raw:Fp},unknown:Hp}),a={parser:n?new Di(Mi):Di.getFragmentParser(void 0,Mi),handle(u){i(u,a)},stitches:!1,options:t||{}};i(e,a),ms(a,Vt());const o=n?a.parser.document:a.parser.getFragment(),l=Wu(o,{file:a.options.file});return a.stitches&&Ol(l,"comment",function(u,m,E){const h=u;if(h.value.stitch&&E&&m!==void 0){const g=E.children;return g[m]=h.value.stitch,m}}),l.type==="root"&&l.children.length===1&&l.children[0].type===e.type?l.children[0]:l}function Co(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function Dp(e,t){Co(e.children,t)}function Pp(e,t){Up(e,t),Co(e.children,t),qp(e,t)}function Op(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:Be.CHARACTER,chars:e.value,location:Fs(e)};ms(t,Vt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function Mp(e,t){const n={type:Be.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Fs(e)};ms(t,Vt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function Bp(e,t){t.stitches=!0;const n=Wp(e);if("children"in e&&"children"in n){const i=vo({type:"root",children:e.children},t.options);n.children=i.children}_o({type:"comment",value:{stitch:n}},t)}function _o(e,t){const n=e.value,i={type:Be.COMMENT,data:n,location:Fs(e)};ms(t,Vt(e)),t.parser.currentToken=i,t.parser._processToken(t.parser.currentToken)}function Fp(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,So(t,Vt(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(Lp,"&lt;$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 Hp(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))Bp(n,t);else{let i="";throw Rp.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 ms(e,t){So(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 So(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 Up(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===Ye.PLAINTEXT)return;ms(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=zu({...e,children:[]},{space:a===Wt.svg?"svg":"html"}),l={type:Be.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 qp(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&nd.includes(n)||t.parser.tokenizer.state===Ye.PLAINTEXT)return;ms(t,hr(e));const i={type:Be.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 $p(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=hr(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 Wp(e){return"children"in e?qa({...e,children:[]}):qa(e)}function Kp(e){return function(t,n){return vo(t,{...e,file:n})}}const yn=c.memo(function({text:t}){const n=Pe(),[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(St,{})}):null});function Yp(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(m=>[c.createElement(a.type,l,...m)])}return[[i]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function ga(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(ga).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return ga(t?.children)}return""}function Gp(e){const t=Array.isArray(e)?e[0]:e;return!t||typeof t!="object"||!("props"in t)?null:t}function Vp(e){const n=Gp(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 Bi="pi-web-ui:plugin-data";let Is=new Map,js=new Map,is=new Set,ba=-1,wo=0;const Ea=new Set;function zp(){wo++;for(const e of Ea)e()}function Qp(e){return Ea.add(e),()=>{Ea.delete(e)}}function Fi(){return wo}let Ao=null;function Xp(e){Ao=e}function Jp(e,t){t!==ba&&(ba=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,zp()}}async function Zp(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=${ba}`))).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=>{Ao?.({type:"plugin_message",pluginId:i.pluginId,payload:o})},onData:o=>{const l=u=>{const m=u.detail;m.pluginId===i.pluginId&&o(m.payload)};return window.addEventListener(Bi,l),()=>window.removeEventListener(Bi,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 eh(e){return Is.has(e)}const Ta="pi-web-ui:theme",Io="dark",Hi="theme-stylesheet",Mt="pi-web-ui:theme-change";function jo(){try{const e=localStorage.getItem(Ta);if(e&&e!==Io)return e}catch{}return null}function th(e){try{e?localStorage.setItem(Ta,e):localStorage.removeItem(Ta)}catch{}}function Lo(e){let t=document.getElementById(Hi);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Mt));return}t||(t=document.createElement("link"),t.id=Hi,t.rel="stylesheet",document.head.appendChild(t)),t.href=tt(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Mt))}async function sh(){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 nh(){const[e,t]=c.useState([]),[n,i]=c.useState(()=>jo());return c.useEffect(()=>{let o=!1;return sh().then(l=>{o||t(l)}),()=>{o=!0}},[]),c.useEffect(()=>{Lo(n),th(n)},[n]),{themes:e,theme:n,switchTheme:o=>i(o===Io?null:o)}}function V0(){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 ah({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 m=()=>{const E=++a.current,h=i.current;h&&(h.dispatchEvent(new CustomEvent(Mt)),o.current.set(h,E))};return window.addEventListener(Mt,m),()=>window.removeEventListener(Mt,m)},[]),c.useEffect(()=>{let m=!1;const E=a.current;return u(null),Zp(e,t).then(h=>{m||(h&&o.current.set(h,E),u(h))}),()=>{m=!0}},[e,t]),c.useEffect(()=>{i.current=l;const m=n.current;return m&&(m.replaceChildren(),l&&(m.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(yn,{text:t}),s.jsx("pre",{children:s.jsx("code",{children:t})})]})}const ih=[fr,gr],rh=[fr,Uu,gr],Ui=[[Bl,{strict:!1,throwOnError:!1}],[Fl,{detect:!0,ignoreMissing:!0}]];function Pa({text:e,rawHtml:t=!1,hardBreaks:n=!1}){const i=t?[Kp,...Ui]:Ui;return s.jsx(Ml,{remarkPlugins:n?rh:ih,rehypePlugins:i,components:{pre:oh},children:e})}const rt=c.memo(function({text:t,rawHtml:n=!1,hardBreaks:i=!1}){return s.jsx("div",{className:"md",children:s.jsx(Pa,{text:t,rawHtml:n,hardBreaks:i})})});function oh({children:e,...t}){c.useSyncExternalStore(Qp,Fi,Fi);const n=Vp(e);return n&&eh(n)?s.jsx(ah,{lang:n,code:ga(e)}):s.jsx(lh,{children:e,...t})}function lh({children:e,...t}){const n=e&&typeof e=="object"&&"props"in e?e.props?.children:e,i=Yp(n),a=i.length>1,o=a?`${String(i.length).length+1}ch`:void 0;return s.jsxs("div",{className:"codeblock",children:[s.jsx(yn,{text:xa(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 xa(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(xa).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return xa(t?.children)}return""}const ch=/^\s{0,3}(`{3,}|~{3,})/,uh=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Vn(e){return e.trim()===""}function qi(e){const t=ch.exec(e);return t?t[1]:null}function dh(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 m=qi(l);m&&m[0]===a[0]&&m.length>=a.length&&(a=null),i.push(l);continue}const u=qi(l);if(u&&!Vn(l)){a=u,i.push(l);continue}if(Vn(l)){let m=o;for(;m<t.length&&Vn(t[m]);)m++;if(!(m<t.length&&uh.test(t[m]))&&i.length>0){n.push(i.join(`
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",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). 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), 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)",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"},Hc=[{code:"zh",nativeName:"中文"},{code:"en",nativeName:"English"}],vs={};function Uc(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 $c(e){delete vs[e]}function qc(e){return e==="zh"?"中文":e.toUpperCase()}function Wc(e){return e==="zh"?"zh-CN":e==="pt"?"pt-BR":e}async function ni(e){const t=await fetch(vt(tt(e)));if(!t.ok)throw new Error(`HTTP ${t.status} for ${e}`);return await t.json()}const Fr=c.createContext(null);function Hr(){try{return localStorage.getItem(ca)}catch{return null}}function Kc(){return la(Hr(),typeof navigator<"u"?navigator.languages:[],null)}function Yc({children:e}){const[t,n]=c.useState(Kc),[i,a]=c.useState(0),o=c.useRef(t);o.current=t;const l=c.useCallback(g=>{n(g);try{localStorage.setItem(ca,g)}catch{}try{window.dispatchEvent(new CustomEvent("pi-web-ui:locale",{detail:g}))}catch{}},[]),u=c.useCallback(async()=>{let g,A=null;try{const N=await ni("/api/locales");g=N.packs??[],A=N.defaultLocale??null}catch{return null}return await Promise.all(g.filter(N=>N.installed).map(async N=>{try{const v=await ni(`/api/locales/${N.code}`);Uc({code:v.code||N.code,nativeName:v.nativeName||N.nativeName,strings:v.strings})}catch{}})),a(N=>N+1),A},[]);c.useEffect(()=>{u().then(g=>{if(!Hr()?.trim()){const N=la(null,typeof navigator<"u"?navigator.languages:[],g);N!==o.current&&(o.current=N,n(N))}const A=o.current;if(A!=="zh"&&A!=="en"&&!vs[A]){const N=la(null,typeof navigator<"u"?navigator.languages:[],g,["zh","en"]);o.current=N,n(N);try{localStorage.setItem(ca,N)}catch{}}})},[u]);const m=c.useMemo(()=>[...Hc,...Object.values(vs).map(g=>({code:g.code,nativeName:g.nativeName}))],[i]),T=c.useCallback((g,A)=>{let N=vs[t]?.strings[g]??(t==="zh"?Bc[g]:Fc[g]);if(A)for(const[v,B]of Object.entries(A))N=N.replaceAll(`{${v}}`,String(B));return N},[t,i]);c.useEffect(()=>{document.documentElement.lang=Wc(t)},[t]);const h=c.useMemo(()=>({locale:t,setLocale:l,t:T,packs:m,reloadPacks:u}),[t,l,T,m,u]);return s.jsx(Fr.Provider,{value:h,children:e})}function Ht(){const e=c.useContext(Fr);if(!e)throw new Error("useI18n must be used within LanguageProvider");return e}function Re(){return Ht().t}const Gc=[{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 ai({settings:e,onChange:t,onPreview:n}){const i=Re(),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(wr,{className:"sound-icon"}),s.jsx("span",{children:i("enableSound")})]}),s.jsx("input",{type:"checkbox",checked:e.enabled,onChange:o=>a({enabled:o.target.checked})})]}),Gc.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:m=>{m.preventDefault(),n(o)},children:i("preview")}),s.jsx("input",{type:"checkbox",checked:e[o],disabled:!e.enabled,onChange:m=>a({[o]:m.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 Ur="pi-web-notify",qn={enabled:!1};function $r(){try{const e=localStorage.getItem(Ur);if(!e)return{...qn};const t=JSON.parse(e);return{enabled:typeof t.enabled=="boolean"?t.enabled:qn.enabled}}catch{return{...qn}}}function ii(e){try{localStorage.setItem(Ur,JSON.stringify(e))}catch{}}function Ms(){return typeof window<"u"&&"Notification"in window}function Vc(){return Ms()?null:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported"}const zc=12e4;function Qc(e){const{screenX:t,screenY:n,outerWidth:i,outerHeight:a}=e;return Number.isFinite(t)&&ri(t)||Number.isFinite(n)&&ri(n)?!0:i>0&&i<=400&&a>0&&a<=40}function ri(e){return e<=-1e4}function Xc(e){return!(e.visibility!=="visible"||e.minimized||!e.hasFocus||e.windows&&e.idleMs>zc)}let qr=Date.now(),oi=!1;function li(){qr=Date.now()}function Jc(){return Math.max(0,Date.now()-qr)}function Zc(){if(oi||typeof window>"u")return;oi=!0;const e={passive:!0,capture:!0};for(const t of["pointerdown","pointermove","keydown","wheel","touchstart","focus","scroll"])window.addEventListener(t,li,e);typeof document<"u"&&document.addEventListener("visibilitychange",li,e)}function Wr(){return typeof navigator>"u"?!1:/windows/i.test(navigator.userAgent??"")}function eu(){return Zc(),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:Qc({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:Jc(),windows:Wr()}}function ci(){return Ms()?Notification.permission:"denied"}async function tu(){if(!Ms())return"denied";try{return await Notification.requestPermission()}catch{return"denied"}}function ui(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function su(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 nu(e,t,n=!1){if(!Ms())return{path:"none",error:"unsupported"};if(Notification.permission!=="granted")return{path:"none",error:`permission: ${Notification.permission}`};const i=su(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=ui(o)}try{return new Notification(e,i),{path:"page",error:a}}catch(o){return{path:"none",error:`${a}; page: ${ui(o)}`}}}async function Ks(e,t){Ms()&&(Xc(eu())||$r().enabled&&await nu(e,t))}const au=!1;function di(){const e=Re(),[t,n]=c.useState($r),[i,a]=c.useState(()=>ci()),[o,l]=c.useState(null),u=Vc(),m=u!==null,T=Wr();c.useEffect(()=>{const g=()=>a(ci());return window.addEventListener("focus",g),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",g)}},[]);const h=async g=>{const A={...t,enabled:g};if(n(A),ii(A),g){const N=await tu();if(a(N),N!=="granted"){const v={...A,enabled:!1};n(v),ii(v)}}};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${m?" disabled":""}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(wc,{className:"sound-icon"}),s.jsx("span",{children:e("notifyEnable")})]}),s.jsx("input",{type:"checkbox",checked:t.enabled&&!m,disabled:m,onChange:g=>h(g.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")}),!m&&i==="denied"&&s.jsx("div",{className:"sound-hint",children:e("notifyDenied")}),!m&&T&&s.jsx("div",{className:"sound-hint",children:e("notifyWindowsHint")}),au]})}const iu={engine:"pi",managed:!1,status:"connecting",ready:!1,cwd:""};let as=iu;const ua=new Set;function ru(e,t){return e===t?!0:!e||!t||e.length!==t.length?!1:e.every((n,i)=>n===t[i])}function ou(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&&ru(e.tabs,t.tabs)&&e.service?.name===t.service?.name&&e.service?.supervisor===t.service?.supervisor}function mi(e){const t={...as,...e};if(!ou(as,t)){as=t;for(const n of ua)n()}}function Kr(e){return ua.add(e),()=>{ua.delete(e)}}function pi(){return as}function ja(){return c.useSyncExternalStore(Kr,pi,pi)}function Ct(e){return c.useSyncExternalStore(Kr,()=>as[e],()=>as[e])}function Yr(){return Ct("engine")==="dsh"}function Gr(){return Ct("managed")}function lu(){return Ct("service")}let da=null;function cu(e){da=e}const ae=e=>da?da(e):!1;function uu({onClose:e}){const t=Re(),{locale:n,setLocale:i,reloadPacks:a}=Ht(),[o,l]=c.useState(null),[u,m]=c.useState(""),[T,h]=c.useState("");async function g(){try{const v=await fetch(vt(tt("/api/locales")));if(!v.ok)throw new Error(`HTTP ${v.status}`);const B=await v.json();l(B.packs??[]),m("")}catch(v){m(t("localeListFailed",{error:v instanceof Error?v.message:String(v)}))}}c.useEffect(()=>{g()},[]);async function A(v){h(v),m("");try{const B=await fetch(vt(tt(`/api/locales/${v}/install`)),{method:"POST"});if(!B.ok){let W=`HTTP ${B.status}`;try{W=(await B.json()).error??W}catch{}throw new Error(W)}await a(),await g()}catch(B){m(t("localeInstallFailed",{error:B instanceof Error?B.message:String(B)}))}finally{h("")}}async function N(v){h(v),m("");try{const B=await fetch(vt(tt(`/api/locales/${v}`)),{method:"DELETE"});if(!B.ok)throw new Error(`HTTP ${B.status}`);$c(v),n===v&&i("zh"),await a(),await g()}catch(B){m(t("localeInstallFailed",{error:B instanceof Error?B.message:String(B)}))}finally{h("")}}return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"bg-task-modal",onClick:v=>v.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(jr,{})," ",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(v=>{const B=T===v.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:v.nativeName}),v.installed&&v.version&&s.jsxs("span",{className:"bg-task-name",children:["v",v.version]})]}),s.jsxs("div",{className:"bg-task-line2",children:[s.jsx("span",{children:v.code}),v.installed?s.jsxs("span",{children:[t("localeInstalled")," · ",t("localeRemoveHint")]}):s.jsx("span",{children:t("localeGetMore")})]})]}),v.installed?s.jsxs("button",{type:"button",className:"btn bg-task-stop",disabled:B,title:t("localeRemove"),onClick:()=>void N(v.code),children:[s.jsx(et,{}),s.jsx("span",{children:t(B?"localeRemoving":"localeRemove")})]}):s.jsxs("button",{type:"button",className:"btn",disabled:B,title:t("localeInstall"),onClick:()=>void A(v.code),children:[s.jsx(Yt,{}),s.jsx("span",{children:t(B?"localeDownloading":"localeInstall")})]})]},v.code)})}),s.jsx("div",{className:"bg-task-foot",children:s.jsxs("button",{type:"button",className:"btn",title:t("bgTaskRefresh"),onClick:()=>void g(),children:[s.jsx(kt,{}),s.jsx("span",{children:t("bgTaskRefresh")})]})})]})})}function du({chat:e,terminal:t,view:n,plugins:i,onViewChange:a,onOpenPanel:o,onOpenSettings:l,onOpenBgTasks:u,onOpenGlobalSearch:m,sound:T,onSoundChange:h,onSoundPreview:g,themes:A,theme:N,onThemeChange:v}){const{locale:B,setLocale:W,t:_,packs:j}=Ht(),{appVersion:L}=ja(),U=Gr(),te=lu(),[ee,le]=c.useState(!1);c.useEffect(()=>{ee&&e.status==="open"&&le(!1)},[ee,e.status]);const[me,Q]=c.useState(!1),[G,ce]=c.useState(!1),[O,M]=c.useState(!1),[y,D]=c.useState(!1),[q,C]=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 H=_("updateTabTitle"),Ie={name:H,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},je=e.terminals.find(P=>P.title===H);je?(t.restart(je.id),ae({type:"run_command",terminalId:je.id,conversationId:je.conversationId,command:Ie,cols:80,rows:24})):t.create({id:wt(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:H,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Ie}),D(!1),C(!1),a("terminal")},re=(H,Ie)=>{if(!e.ready||H.length===0)return;const je={name:Ie,command:Lc(H),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:je,cols:80,rows:24})):t.create({id:wt(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:Ie,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:je}),D(!1),C(!1),a("terminal")},de=H=>!e.tabs||H==="chat"||e.tabs.includes(H),Se=e.updatesAll??[],ie=Se.filter(H=>!H.upToDate&&!H.error).length,pe=Se.filter(H=>!H.upToDate&&!H.error&&H.kind!=="webui"),J=()=>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")}):Se.length===0?s.jsx("div",{className:"dd-note",children:_("updatesAllUpToDate")}):s.jsx("ul",{className:"dd-all-list",children:Se.map(H=>s.jsxs("li",{className:`dd-all-item${H.error?" err":H.upToDate?"":" warn"}`,children:[s.jsx("span",{className:"dd-all-name",title:H.name,children:H.name}),s.jsx("span",{className:"dd-all-kind",children:H.kind==="webui"?_("kindWebUi"):H.kind==="pi-core"?_("kindPiCore"):_("kindPackage")}),s.jsx("span",{className:"dd-all-vers",children:H.error?_("updateCheckFailed"):H.upToDate?`v${H.current}`:s.jsxs(s.Fragment,{children:["v",H.current," → v",H.latest]})}),H.kind!=="webui"&&!H.upToDate&&!H.error&&s.jsx("button",{type:"button",className:"dd-update-btn",onClick:()=>re([H],_("updatePkgTabTitle",{name:H.name})),children:_("updateBtn")})]},`${H.kind}:${H.name}`))}),s.jsxs("div",{className:"dd-actions",children:[pe.length>0&&s.jsx("button",{type:"button",className:"dd-refresh accent",style:{flex:1},onClick:()=>re(pe,_("updateAllTabTitle")),children:_("updateAllBtn")}),s.jsx("button",{type:"button",className:"dd-refresh",style:pe.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:[s.jsx("button",{type:"button",className:"panel-toggle",title:_("openHistory"),onClick:()=>o("left"),children:s.jsx(gc,{})}),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(jn,{}),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(H=>H.view!==!1).map(H=>{const Ie=H.error?`${H.name}: ${H.error}`:H.description?`${H.name} — ${H.description}`:H.name;return s.jsxs("button",{type:"button",role:"tab","aria-selected":n===`plugin:${H.id}`,className:`plugin-tab${n===`plugin:${H.id}`?" active":""}${H.error?" broken":""}`,title:Ie,onClick:()=>a(`plugin:${H.id}`),children:[H.icon?s.jsx("span",{"aria-hidden":!0,children:H.icon}):null,s.jsx("span",{children:H.name})]},H.id)})]}),s.jsxs("div",{className:"topbar-desktop",children:[de("search")&&s.jsxs("button",{type:"button",className:"chip",title:_("searchGlobalTip"),onClick:m,children:[s.jsx(dn,{}),s.jsx("span",{className:"chip-sub",children:_("searchGlobal")})]}),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(un,{}),s.jsx("span",{className:"chip-sub",children:_("settings")})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(wr,{}),s.jsx("span",{className:"chip-sub",children:_("sound")})]}),open:me,onOpenChange:Q,children:[s.jsx(ai,{settings:T,onChange:h,onPreview:g}),s.jsx(di,{})]}),s.jsxs(Pt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(jr,{}),s.jsx("span",{className:"chip-sub",children:qc(B)})]}),open:G,onOpenChange:ce,children:[s.jsx("div",{className:"dd-header",children:_("language")}),j.map(H=>s.jsx(it,{active:B===H.code,onClick:()=>{W(H.code),ce(!1)},children:H.nativeName},H.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(cc,{}),s.jsx("span",{className:"chip-sub",children:_("theme")})]}),open:O,onOpenChange:M,children:[s.jsx("div",{className:"dd-header",children:_("theme")}),s.jsx(it,{active:N===null,onClick:()=>{v(null),M(!1)},children:_("themeDefault")}),A.map(H=>s.jsx(it,{active:N===H.id,onClick:()=>{v(H.id),M(!1)},children:B==="zh"?H.name:H.nameEn??H.name},H.id))]}),U?s.jsxs("span",{className:"chip",title:_("updatesManaged"),children:[s.jsx(Yt,{}),s.jsxs("span",{className:"chip-sub",children:["v",L??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:y,onOpenChange:H=>{D(H),H&&(ae({type:"check_update"}),ae({type:"check_updates_all"}))},fit:!0,children:[s.jsx("div",{className:"dd-header",children:_("update")}),oe(),J()]}),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(ei,{})})]}),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(pc,{}),s.jsx("span",{className:"chip-sub",children:_("more")}),!U&&e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot"})]}),open:q,onOpenChange:H=>{C(H),H&&!U&&(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:()=>{C(!1),l()},children:[s.jsx(un,{})," ",_("settingsTitle")]}),s.jsxs(it,{onClick:()=>{C(!1),m()},children:[s.jsx(dn,{})," ",_("searchGlobal")]}),s.jsxs(it,{onClick:()=>{C(!1),u()},children:[s.jsx(mn,{})," ",_("bgTasks"),e.bgServers.length>0&&s.jsx("em",{className:"bg-task-badge",children:e.bgServers.length})]}),s.jsx(ai,{settings:T,onChange:h,onPreview:g}),s.jsx(di,{}),s.jsx("div",{className:"dd-header",children:_("language")}),j.map(H=>s.jsx(it,{active:B===H.code,onClick:()=>W(H.code),children:H.nativeName},H.code)),s.jsx("div",{className:"dd-header",children:_("theme")}),s.jsx(it,{active:N===null,onClick:()=>{v(null),C(!1)},children:_("themeDefault")}),A.map(H=>s.jsx(it,{active:N===H.id,onClick:()=>{v(H.id),C(!1)},children:B==="zh"?H.name:H.nameEn??H.name},H.id)),s.jsx("div",{className:"dd-header",children:_("update")}),oe(),J(),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(ei,{})," ",_("githubRepo")]})]})})]}),s.jsx("button",{type:"button",className:"panel-toggle",title:_("openFiles"),onClick:()=>o("right"),children:s.jsx(Bt,{})}),se&&s.jsx(uu,{onClose:()=>K(!1)})]})}function Vr(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 m=e.minAbovePx+e.minBelowPx||1,T=t*e.minAbovePx/m;return{above:T,below:t-T}}const u=Math.min(t-l,Math.max(o,e.start.above+e.deltaPx/a));return{above:u,below:t-u}}function hi(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 mu(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 pu="pi-web-ui:lp-collapse-projects",hu="pi-web-ui:lp-collapse-convs",fu="pi-web-ui:lp-collapse-sessions";function Wn(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 Qr="pi-web-ui:lp-sizes",gn={projects:1,convs:1,sessions:1},gu=32,fi=72;function bu(){try{return Vr(localStorage.getItem(Qr),gn)}catch{return{...gn}}}const Eu=c.memo(function({sessionFile:t,conversations:n,sessions:i,projects:a,activeConversationId:o,panelSend:l,active:u,collapsible:m,onToggleCollapse:T}){const h=Re(),g=t,A=Ct("ready"),N=Ct("status"),v=Ct("cwd"),B=v,[W,_]=c.useState(null),[j,L]=c.useState(null),[U,te]=c.useState(""),[ee,le]=Wn(pu,!1),[me,Q]=Wn(hu,!1),[G,ce]=Wn(fu,!1),[O,M]=c.useState(null),[y,D]=c.useState(null),q=c.useCallback(()=>{D(null),M(null)},[]),C=c.useCallback((P,ye)=>{P.preventDefault(),P.stopPropagation(),M({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")||q()},ye=he=>{he.key==="Escape"&&q()};return window.addEventListener("mousedown",P,!0),window.addEventListener("keydown",ye),window.addEventListener("blur",q),()=>{window.removeEventListener("mousedown",P,!0),window.removeEventListener("keydown",ye),window.removeEventListener("blur",q)}},[O,q]);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(()=>bu());c.useEffect(()=>{try{localStorage.setItem(Qr,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 x=[{key:"projects",visible:a.length>0,collapsed:ee},{key:"convs",visible:n.length>0,collapsed:me},{key:"sessions",visible:!0,collapsed:G}].filter(w=>w.visible),b=x.filter(w=>w.collapsed).length,z=x.filter(w=>!w.collapsed).map(w=>w.key).reduce((w,fe)=>w+(Ce[fe]??1),0)||1,ue=Math.max(120,ke.clientHeight-b*gu);be.classList.add("dragging"),document.body.classList.add("lp-resizing");const Ne=w=>{const{above:fe,below:Ae}=zr({start:{above:Ce[P]??1,below:Ce[ye]??1},deltaPx:w.clientY-Te,availablePx:ue,totalWeight:z,minAbovePx:fi,minBelowPx:fi});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,me,G]);c.useEffect(()=>{!u||!A||N!=="open"||v&&(l({type:"list_sessions"}),l({type:"list_projects"}))},[u,A,N,v,l]);const Se=P=>{const ye=P.name||P.firstMessage.trim();return ye.length>0?ye:h("emptyChat")},ie=P=>P.split(/[\\/]/).pop()||P,pe=(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,{})})},J=(P,ye,he,be)=>s.jsxs("button",{type:"button",className:"lp-section-title panel-section-title",onClick:he,title:h(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(Ln,{})})]}),H=[{key:"projects",visible:a.length>0,collapsed:ee},{key:"convs",visible:n.length>0,collapsed:me},{key:"sessions",visible:!0,collapsed:G}].filter(P=>P.visible).filter(P=>!P.collapsed),Ie=H.reduce((P,ye)=>P+(Y[ye.key]??1),0)||1,je=P=>H.length<=1?1:(Y[P]??1)/Ie*H.length;return s.jsxs("aside",{ref:k,className:"panel panel-left lp-panel",children:[m&&T&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:h("collapsePanel"),onClick:T,children:s.jsx(Dr,{})}),a.length>0&&s.jsxs("div",{className:`lp-section panel-projects ${ee?"collapsed":""}`,style:ee?void 0:{flex:`${je("projects")} 1 0px`},children:[J(h("recentProjects"),ee,le,a.length),!ee&&s.jsx("div",{className:"lp-section-body projects-scroll",children:a.map(P=>{const ye=B===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:hi(P.lastUsed)})]}),pe(`proj:${P.path}`,h("deleteProject"),h("deleteProjectConfirm"),()=>l({type:"remove_project",path:P.path}))]},P.path)})})]}),a.length>0&&!ee&&(n.length>0?!me:!G)&&s.jsx("div",{className:"lp-sash",onPointerDown:de("projects",n.length>0?"convs":"sessions"),onDoubleClick:()=>re({...gn}),title:h("dragToResize")}),n.length>0&&s.jsxs("div",{className:`lp-section lp-section-convs panel-convs ${me?"collapsed":""}`,style:me?void 0:{flex:`${je("convs")} 1 0px`},onContextMenu:P=>C(P),children:[J(h("runningConversations"),me,Q,n.length),!me&&s.jsx("div",{className:"lp-section-body convs-scroll",children:mu(n,v).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(x=>[x.id,x])),he=new Map,be=[];for(const x of P.convs)if(x.parentId&&ye.has(x.parentId)){const b=he.get(x.parentId)??[];b.push(x),he.set(x.parentId,b)}else be.push(x);const Te=[],Ce=new Set,ke=(x,b)=>{if(!Ce.has(x.id)){Ce.add(x.id),Te.push({c:x,depth:b});for(const S of he.get(x.id)??[])ke(S,b+1)}};for(const x of be)ke(x,0);for(const x of P.convs)ke(x,0);return Te.map(({c:x,depth:b})=>{const S=o===x.id;return s.jsxs("div",{className:`lp-row${b>0?" lp-sub":""}`,style:b>0?{marginLeft:b*18}:void 0,onMouseLeave:()=>_(z=>z===`conv:${x.id}`?null:z),onContextMenu:z=>C(z,x.id),children:[s.jsxs("button",{type:"button",className:`session-item ${S?"active":""}`,title:`${x.title}${P.isCurrent?"":` — ${P.cwd}`}`,onClick:()=>{S||l({type:"switch_conversation",id:x.id})},children:[s.jsx(rs,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[j===`conv:${x.id}`?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:U,placeholder:h("renameSessionPlaceholder"),onClick:z=>z.stopPropagation(),onChange:z=>te(z.target.value),onKeyDown:z=>{if(z.stopPropagation(),z.key==="Enter"&&!z.nativeEvent.isComposing){const ue=U.trim();ue&&l({type:"rename_conversation",id:x.id,name:ue}),L(null)}else z.key==="Escape"&&L(null)},onBlur:()=>L(null)}):s.jsxs("span",{className:"session-title",children:[x.isSubagent&&s.jsx("span",{className:"subagent-badge",children:h("subagentBadge")}),x.title,x.error&&s.jsx("span",{className:"conv-error-badge",title:h("convErrorBadge",{error:x.error})})]}),j===`conv:${x.id}`?null:s.jsx("span",{className:"session-sub",children:S?h("current"):h("messageCount",{n:x.messageCount})})]}),x.isStreaming&&s.jsx("span",{className:"conv-streaming",title:h("streaming")})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:h("renameSession"),onClick:z=>{z.stopPropagation(),_(null),te(x.title),L(`conv:${x.id}`)},children:s.jsx(fn,{})}),(()=>{const z=`conv:${x.id}`,ue=W===z,Ne=se(n,x.id),De=xe(n,x.id),w=K(n,x.id);return w===0&&!x.isStreaming?pe(z,h("dismissConversation"),h("dismissConversationConfirm"),()=>l({type:"dismiss_conversation",id:x.id}),s.jsx(Ke,{})):w===0?pe(z,h("dismissConversation"),h("dismissStreamingConfirm"),()=>l({type:"dismiss_conversation",id:x.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:h("dismissFinishedSubagentsScoped",{n:Ne}),onClick:fe=>{fe.stopPropagation(),_(null),l({type:"dismiss_finished_subagents",parentId:x.id})},children:h("dismissFinishedOnly",{n:Ne})}),s.jsx("button",{type:"button",className:"lp-del-opt danger",title:h("forceDismissTitle",{n:w,m:De}),onClick:fe=>{fe.stopPropagation(),_(null),l({type:"dismiss_conversation",id:x.id,force:!0})},children:h("dismissForceAll",{n:w})})]}):s.jsx("button",{type:"button",className:"lp-del",title:h("dismissConversation"),onClick:fe=>{fe.stopPropagation(),_(z)},children:s.jsx(Ke,{})})})(),x.isStreaming&&s.jsx("span",{className:"lp-row-stalled",title:h("streaming"),style:{position:"absolute",right:28,top:"50%",transform:"translateY(-50%)"}})]},x.id)})})()]},P.cwd))})]}),n.length>0&&!me&&!G&&s.jsx("div",{className:"lp-sash",onPointerDown:de("convs","sessions"),onDoubleClick:()=>re({...gn}),title:h("dragToResize")}),s.jsxs("div",{className:`lp-section lp-section-sessions panel-sessions ${G?"collapsed":""}`,style:G?void 0:{flex:`${je("sessions")} 1 0px`},children:[J(h("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:h("noHistory")}),i.map(P=>{const ye=g===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:()=>{j||ye||l({type:"switch_session",path:P.path})},children:[s.jsx(rs,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[j===P.path?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:U,placeholder:h("renameSessionPlaceholder"),onClick:he=>he.stopPropagation(),onChange:he=>te(he.target.value),onKeyDown:he=>{if(he.stopPropagation(),he.key==="Enter"&&!he.nativeEvent.isComposing){const be=U.trim();be&&l({type:"rename_session",path:P.path,name:be}),L(null)}else he.key==="Escape"&&L(null)},onBlur:()=>L(null)}):s.jsx("span",{className:"session-title",children:Se(P)}),j===P.path?null:s.jsxs("span",{className:"session-sub",children:[ye?h("current"):h("messageCount",{n:P.messageCount}),P.source==="tui"&&s.jsx("span",{className:"session-src",title:h("tuiTip"),children:"TUI"})]})]}),s.jsx("span",{className:"session-time",children:hi(P.modified)})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:h("renameSession"),onClick:he=>{he.stopPropagation(),_(null),te(P.name??""),L(P.path)},children:s.jsx(fn,{})}),pe(`sess:${P.path}`,h("deleteSession"),h("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?h("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"}),q()},children:[s.jsx(Ke,{}),s.jsx("span",{children:se(n,O.scopeId)===0?h("noFinishedSubagents"):O.scopeId?h("dismissFinishedSubagentsScoped",{n:se(n,O.scopeId)}):h("dismissFinishedSubagents",{n:se(n,O.scopeId)})})]}),O.scopeId&&s.jsxs("button",{type:"button",className:y===O.scopeId?"ctx-item danger armed":"ctx-item danger",title:y===O.scopeId?h("forceDismissConfirm"):h("forceDismissConversation"),onClick:()=>{const P=O.scopeId;y===P?(l({type:"dismiss_conversation",id:P,force:!0}),D(null),q()):D(P)},children:[s.jsx(Ke,{}),s.jsx("span",{children:y===O.scopeId?h("forceDismissConfirm"):h("forceDismissConversation")})]})]})]})});function Tu(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,m=u&&u.id===t.messageId?u:{id:t.messageId,content:[]},T=[...m.content],h=n.type==="thinking_delta"?"thinking":"text",g=n.contentIndex??T.length-1;return g>=0&&g<T.length&&T[g].type===h?T[g]=h==="thinking"?{type:"thinking",thinking:(T[g].thinking??"")+l}:{type:"text",text:(T[g].text??"")+l}:T.push(h==="thinking"?{type:"thinking",thinking:l}:{type:"text",text:l}),{...e,stats:o,streamingMessage:{...m,id:t.messageId,content:T}}}function xu(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 ma="pi-web-ui:plugin-data";function yu(e,t){window.dispatchEvent(new CustomEvent(ma,{detail:{pluginId:e,payload:t}}))}function Nu(e){const t=n=>{const i=n.detail;e(i.pluginId,i.payload)};return window.addEventListener(ma,t),()=>window.removeEventListener(ma,t)}const ss=new Map,pa=new Set,Zt=new Set;let gi=-1;function Xr(){return[...ss.values()]}function ku(){const e=Xr();for(const t of pa)t(e)}function vu(e){return pa.add(e),e(Xr()),()=>pa.delete(e)}async function Cu(e,t){t!==gi&&(gi=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)}})),ku()}function _u(e,t){return{pluginId:e,send:n=>t({type:"plugin_message",pluginId:e,payload:n}),onData:n=>Nu((i,a)=>{i===e&&n(a)})}}const Su=15,wu="pi-web-ui:lang";function bi(){try{return(localStorage.getItem(wu)??"").trim()}catch{return""}}const Ei="pi-web-ui:locale",Kn=2e5,Au=2e5,Iu="LIVE_OMIT",ju={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 Lu(){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 h of u)try{h.write(o)}catch{}return}const m=t.get(l)??"",T=m.length+o.length>Au?o:m+o;t.set(l,T)},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 m=t.get(l);if(m){try{o.write(m)}catch{}t.delete(l)}return()=>{const T=e.get(l);T&&(T.delete(o),T.size===0&&e.delete(l)),t.delete(l)}},clear(){e.clear(),t.clear()}}}function Ti(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 xi(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 Ru(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!==Su};case"snapshot":return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:Ti(e.liveOutputs,t.state),toolStatuses:xi(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:Ti(e.liveOutputs,a),toolStatuses:xi(e.toolStatuses,a)}}case"tool_delta":{const i=(e.liveOutputs.get(t.toolCallId)?.text??"")+t.delta,a=i.length>Kn?`…[${Iu}:${i.length-Kn}]…
305
+ `+i.slice(i.length-Kn):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:Tu(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 yi="pi-web-client-id";let Yn=null;function bn(){if(Yn)return Yn;let e=null;try{e=sessionStorage.getItem(yi),e||(e=wt(),sessionStorage.setItem(yi,e))}catch{e=e??wt()}return Yn=e,e}const Jr="pi-web-last-cwd";function Du(){try{return localStorage.getItem(Jr)}catch{return null}}function Pu(e){try{localStorage.setItem(Jr,e)}catch{}}function Ou(){const e=location.protocol==="https:"?"wss:":"ws:";return vt(`${e}//${location.host}${tt("/ws")}`)}function Mu(){const[e,t]=c.useReducer(Ru,{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:ju,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(Lu()),a=c.useRef(0),o=c.useRef(null),l=c.useRef(!0),u=c.useRef(0),m=c.useRef(0),T=c.useRef(new Map),h=c.useRef(null),g=c.useRef(!1),A=c.useRef(null),N=c.useRef(new Set),v=c.useRef("live"),B=()=>{h.current||(h.current=setTimeout(()=>{h.current=null;const O=n.current;O&&O.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"get_state"}))},300))},W=(O,M)=>{const y=T.current,D=y.get(O);if(D!==void 0&&M!==D+1){const q=ce.current.chat,C=q.activeConversationId||q.state?.conversationId;O===C&&B()}y.set(O,M)},_=c.useCallback((O,M)=>{const y=++m.current;t({type:"notice",notice:{id:y,level:O,text:M}})},[]),j=c.useCallback(O=>{const M=n.current;if(M&&M.readyState===WebSocket.OPEN){if(O.type==="check_updates_all"&&O.force===!0&&t({type:"updates_check_started"}),M.send(JSON.stringify(O)),O.type==="question_answer"){if(N.current.add(O.id),N.current.size>64){const y=N.current.values().next().value;y!==void 0&&N.current.delete(y)}v.current="live",t({type:"question",question:null})}return!0}return!1},[]),L=c.useCallback(O=>{const M=xu({current:ce.current.chat.question,source:v.current,snapshot:O,answered:N.current});M.changed&&(v.current=M.source,t({type:"question",question:M.question}))},[]);cu(j);const U=c.useCallback(()=>{if(!l.current)return;t({type:"status",status:"connecting"});const O=new WebSocket(Ou());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:bn(),locale:bi()})))},O.onmessage=M=>{if(n.current!==O)return;u.current=Date.now();let y;try{y=JSON.parse(M.data)}catch{return}switch(y.type){case"ready":mi({engine:y.engine??"pi",managed:!!y.managed,tabs:y.tabs,appVersion:y.appVersion,serverVersion:y.serverVersion,service:y.service}),t({type:"ready",serverVersion:y.serverVersion,protocolVersion:y.protocolVersion,engine:y.engine,appVersion:y.appVersion,managed:y.managed,tabs:y.tabs,service:y.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"})),y.managed||(O.send(JSON.stringify({type:"check_update"})),O.send(JSON.stringify({type:"check_updates_all"})));break;case"snapshot":T.current=new Map,t({type:"snapshot",state:y.state}),L(y.state.pendingQuestion);break;case"snapshot_delta":{const D=ce.current.chat.state;(!D||D.conversationId!==y.conversationId||D.rev!==y.baseRev)&&B(),t({type:"snapshot_delta",msg:y}),L(y.state.pendingQuestion);break}case"tool_delta":W(y.conversationId,y.seq),t({type:"tool_delta",toolCallId:y.toolCallId,toolName:y.toolName,delta:y.delta});break;case"tool_status":t({type:"tool_status",status:y});break;case"message_delta":{W(y.conversationId,y.seq),t({type:"message_delta",msg:y});break}case"notice":{const D=++m.current;t({type:"notice",notice:{id:D,level:y.level,text:y.text,textEn:y.textEn}});break}case"sessions":t({type:"sessions",sessions:y.sessions});break;case"conversations":t({type:"conversations",conversations:y.conversations,activeId:y.activeId});break;case"projects":t({type:"projects",projects:y.projects});break;case"files":t({type:"files",files:y});break;case"file_changed":t({type:"file_changed",path:y.path});break;case"file_content":t({type:"file_content",content:y});break;case"models":t({type:"models",models:y.models,loading:!1});break;case"models_config":t({type:"models_config",providers:y.providers});break;case"providers_status":t({type:"providers_status",providers:y.providers});break;case"provider_keys":t({type:"provider_keys",keys:y.keys});break;case"fetch_models_result":t({type:"fetch_models_result",result:{reqId:y.reqId,ok:y.ok,models:y.models,error:y.error}});break;case"refresh_provider_result":t({type:"refresh_provider_result",result:{reqId:y.reqId,ok:y.ok,added:y.added,total:y.total,error:y.error}});break;case"clone_provider_result":t({type:"clone_provider_result",result:{reqId:y.reqId,ok:y.ok,config:y.config,configs:y.configs,error:y.error}});break;case"scm_data":t({type:"scm_data",data:y});break;case"search_files_result":t({type:"file_search_result",result:{reqId:y.reqId,ok:y.ok,results:y.results,truncated:y.truncated}});break;case"session_search_results":t({type:"session_search_result",result:{reqId:y.reqId,ok:y.ok,results:y.results}});break;case"scm_changed":t({type:"scm_changed"});break;case"install_result":t({type:"install_result",result:y});break;case"path_completions":t({type:"path_completions",completions:y.completions});break;case"update_status":t({type:"update_status",status:y});break;case"update_status_all":t({type:"update_status_all",items:y.items});break;case"widgets":t({type:"widgets",widgets:y.widgets});break;case"statuses":t({type:"statuses",statuses:y.statuses});break;case"dialog":t({type:"dialog",dialog:{id:y.id,kind:y.kind,title:y.title,args:y.args}});break;case"dialog_closed":t({type:"dialog",dialog:null});break;case"question_pending":v.current="live",t({type:"question",question:{id:y.id,...y.deadline!==void 0?{deadline:y.deadline}:{},questions:y.questions}});break;case"terminal_output":i.current.write(y.conversationId??ce.current.chat.activeConversationId,y.terminalId,y.data);break;case"terminal_exit":t({type:"terminal_exit",conversationId:y.conversationId,terminalId:y.terminalId,exitCode:y.exitCode});break;case"terminal_list":t({type:"terminal_list",conversationId:y.conversationId,terminals:y.terminals});break;case"commands":t({type:"commands",commands:y.commands,path:y.path});break;case"slash_commands":t({type:"slash_commands",commands:y.commands});break;case"goal_status":t({type:"goal_status",status:y.status});break;case"settings_state":t({type:"settings",settings:y.settings});break;case"bg_servers":t({type:"bg_servers",servers:y.servers});break;case"plugins":t({type:"plugins",plugins:y.plugins,epoch:y.epoch});break;case"plugin_catalog":t({type:"plugin_catalog",entries:y.entries,epoch:y.epoch});break;case"dsh_patches":t({type:"dsh_patches",patchDir:y.patchDir,files:y.files});break;case"plugin_data":yu(y.pluginId,y.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 M=Math.min(1e3*2**a.current,1e4);a.current+=1,o.current=setTimeout(()=>{o.current=null,U()},M)},O.onerror=()=>{}},[]);c.useEffect(()=>{const O=M=>{const y=M.detail??bi();y&&j({type:"set_locale",locale:y})};return window.addEventListener(Ei,O),()=>window.removeEventListener(Ei,O)},[j]),c.useEffect(()=>{l.current=!0,U();const O=setInterval(()=>{if(!l.current)return;const M=n.current;M&&M.readyState===WebSocket.OPEN&&Date.now()-u.current>3e4&&M.close()},5e3);return()=>{l.current=!1,clearInterval(O),o.current&&(clearTimeout(o.current),o.current=null),n.current?.close(),n.current=null}},[U]),c.useEffect(()=>{const O=e.state?.cwd;if(O){if(!g.current){g.current=!0;const M=Du();if(M&&M!==O){j({type:"set_cwd",path:M});return}}A.current!==O&&(A.current=O,Pu(O))}},[e.state?.cwd,j]),c.useEffect(()=>{mi({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}),[]),me=c.useCallback(O=>t({type:"terminal_restart",terminalId:O}),[]),Q=c.useCallback(O=>t({type:"terminal_active",id:O}),[]),G=c.useCallback((O,M,y)=>i.current.register(O,M,y),[]),ce=c.useRef({chat:e,send:j,pushNotice:_,dismissNotice:te,terminal:{create:ee,close:le,register:G,restart:me,select:Q}});return ce.current={chat:e,send:j,pushNotice:_,dismissNotice:te,terminal:{create:ee,close:le,register:G,restart:me,select:Q}},ce.current}const Bu=200*1024*1024,Fu=/windows/i.test(navigator.userAgent),Hu=/[<>:"/\\|?*\u0000-\u001f]/g,Uu=/[. ]+$/,$u=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function qu(e){const t=e.replace(Hu,"_").replace(Uu,"");return t?$u.test(t)?`_${t}`:t:"_"}function Ni(e,t=!0){const n=new URLSearchParams({clientId:bn(),path:e,...t?{download:"1"}:{}});return vt(tt(`/api/file?${n}`))}const Zr="FILE_NOT_FOUND";async function Wu(e,t){const n=Fu?qu(t):t;try{const i=await fetch(Ni(e));if(!i.ok)return{ok:!1,cancelled:!1,error:await i.text().catch(()=>"")||(i.status===404?Zr:`HTTP ${i.status}`)};if(Number(i.headers.get("content-length")??"0")>Bu)return window.location.assign(Ni(e)),{ok:!0};const o=await i.blob();return window.showSaveFilePicker&&window.isSecureContext?Ku(o,n):ha(o,n)}catch(i){return{ok:!1,cancelled:!1,error:i instanceof Error?i.message:String(i)}}}async function Ku(e,t){let n;const i=window.showSaveFilePicker;if(!i)return ha(e,t);try{n=await i({suggestedName:t})}catch(a){return a instanceof DOMException&&a.name==="AbortError"?{ok:!1,cancelled:!0}:ha(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 ha(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",ki="pi-web-ui:rp-sizes",Gn={files:4,widgets:1},vi=120,Ci=56,Yu=c.memo(function({files:t,fileChanged:n,widgets:i,panelSend:a,onAttach:o,onPreview:l,onNotice:u,collapsible:m,onToggleCollapse:T}){const h=Re(),g=Ct("cwd"),[A,N]=c.useState(""),[v,B]=c.useState(null),[W,_]=c.useState(!1),j=c.useRef(null),L=c.useRef(null),[U,te]=c.useState(()=>{try{return Vr(localStorage.getItem(ki),Gn)}catch{return{...Gn}}});c.useEffect(()=>{try{localStorage.setItem(ki,JSON.stringify(U))}catch{}},[U]);const ee=i.some(x=>x.lines.length>0),le=c.useCallback(x=>{x.preventDefault();const b=j.current;if(!b)return;const S=x.currentTarget,z=x.clientY,ue={above:U.files,below:U.widgets},Ne=Math.max(120,b.clientHeight-(L.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:vi,minBelowPx:Ci});te({files:Ae,widgets:Fe})},w=()=>{window.removeEventListener("pointermove",De),window.removeEventListener("pointerup",w),S.classList.remove("dragging"),document.body.classList.remove("rp-resizing")};window.addEventListener("pointermove",De),window.addEventListener("pointerup",w)},[U.files,U.widgets]),[me,Q]=c.useState(null),G=c.useRef(""),ce=c.useRef(null),O=c.useRef(null),[M,y]=c.useState(null),D=c.useRef(null);c.useEffect(()=>()=>{D.current&&clearTimeout(D.current)},[]);const q=c.useCallback(x=>{y(x),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>y(null),1200)},[]),C=x=>{try{const b=document.createElement("textarea");b.value=x,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((x,b)=>{if(!x)return;const S=()=>q(b),z=()=>u("error",h("slashCopyFailed")),ue=navigator;ue.clipboard?.writeText?ue.clipboard.writeText(x).then(S,()=>{C(x)?S():z()}):C(x)?S():z()},[q,u,h]),K=c.useCallback(x=>{if(!x)return g;if(/^[A-Za-z]:$/.test(x))return`${x}/`;if(x.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(x))return x;const b=g.replace(/\\/g,"/").replace(/\/+$/,"");return b?`${b}/${x}`:x},[g]),xe=c.useCallback(x=>!x||x===fs?null:x.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(x)?x:`${g.replace(/\\/g,"/").replace(/\/+$/,"")}/${x}`,[g]),k=c.useCallback((x,b,S)=>{x.preventDefault(),G.current=b,ce.current=S??null,Q({x:Math.min(x.clientX,window.innerWidth-220),y:Math.min(x.clientY,window.innerHeight-90)})},[]),Y=c.useCallback(()=>Q(null),[]);c.useEffect(()=>{if(!me)return;const x=z=>{z.target?.closest(".ctx-menu")||Y()},b=z=>{z.key==="Escape"&&Y()};window.addEventListener("mousedown",x,!0),window.addEventListener("keydown",b);const S=()=>Y();return window.addEventListener("blur",S),()=>{window.removeEventListener("mousedown",x,!0),window.removeEventListener("keydown",b),window.removeEventListener("blur",S)}},[me,Y]);const re=c.useCallback(()=>{const x=ce.current;Y(),x&&a({type:"set_cwd",path:x.path})},[Y,a]),de=c.useCallback(()=>{Y(),O.current&&(O.current.value=""),O.current?.click()},[Y]),Se=c.useCallback((x,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:x,name:S.name,data:Ne})},z.readAsDataURL(S)}},[a]),ie=c.useCallback(x=>{Se(G.current,Array.from(x.target.files??[]))},[Se]),pe=c.useRef(null),J=x=>Array.from(x.dataTransfer?.types??[]).includes("Files"),oe=c.useCallback(()=>{pe.current?.querySelectorAll(".file-item.drop-target").forEach(x=>x.classList.remove("drop-target")),pe.current?.classList.remove("drop-root")},[]),H=c.useCallback(x=>{if(oe(),x==null)return;const b=pe.current?.querySelector(`.file-item[data-path="${CSS.escape(x)}"]`);b?b.classList.add("drop-target"):pe.current?.classList.add("drop-root")},[oe]),Ie=x=>{const b=x instanceof Element?x.closest(".file-item"):null;return b?.dataset.type==="dir"?b.dataset.path??A:A},je=c.useCallback(()=>{const x=document.querySelector(".app");x&&x.dispatchEvent(new DragEvent("dragleave",{bubbles:!0}))},[]),P=1e4,ye=c.useRef(0),he=c.useRef(void 0),be=c.useCallback((x,b)=>{const S=++ye.current;N(x),b?.silent||_(!0),a({type:"list_files",path:x===""?void 0:x})||ye.current===S&&_(!1)},[a]);c.useEffect(()=>{t&&t.path===A&&_(!1)},[t,A]),c.useEffect(()=>{if(g!==he.current){he.current=g,be("",{silent:!0});return}const x=setInterval(()=>{document.visibilityState!=="hidden"&&be(A,{silent:!0})},P);return()=>clearInterval(x)},[g,A,be]),c.useEffect(()=>{n&&n.path===A&&be(A,{silent:!0})},[n,A,be]);const Te=x=>be(x),Ce=()=>{t?.parent!==null&&t?.parent!==void 0&&be(t.parent)},ke=(()=>{if(A===""||A===fs)return[];const x=A.split("/").filter(b=>!!b&&b!==fs);return A.startsWith("/")?x.map((b,S)=>({label:S===0?"/":x[S],path:"/"+x.slice(0,S+1).join("/")})):x.map((b,S)=>({label:x[S],path:x.slice(0,S+1).join("/")}))})();return s.jsxs("aside",{className:"panel panel-right",ref:j,children:[m&&T&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:h("collapsePanel"),onClick:T,children:s.jsx(Rr,{})}),s.jsxs("div",{className:"panel-crumbs",ref:L,children:[s.jsx("button",{type:"button",className:`crumb ${A===""?"active":""}`,onClick:()=>be(""),children:h("rootDir")}),s.jsx("button",{type:"button",className:`crumb ${A===fs?"active":""}`,title:h("computer"),onClick:()=>be(fs),children:"💻"}),ke.map(x=>s.jsxs("span",{className:"crumb-seg",children:[s.jsx(zt,{}),s.jsx("button",{type:"button",className:`crumb ${x.path===A?"active":""}`,onClick:()=>be(x.path),children:x.label})]},x.path))]}),s.jsxs("div",{ref:pe,className:"panel-body",style:ee?{flexGrow:U.files,minHeight:vi}:void 0,onContextMenu:x=>k(x,A),onDragOver:x=>{J(x)&&(x.preventDefault(),x.stopPropagation(),x.dataTransfer.dropEffect="copy",je(),H(Ie(x.target)))},onDragLeave:x=>{x.relatedTarget&&x.currentTarget.contains(x.relatedTarget)||oe()},onDrop:x=>{if(oe(),!J(x))return;x.preventDefault(),x.stopPropagation(),je();const b=Array.from(x.dataTransfer?.files??[]);if(b.length===0){u("warning",h("foldersNotSupported"));return}Se(Ie(x.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:h("loading")}),!W&&t&&t.path===A&&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(x=>x.type==="dir"?s.jsxs("div",{className:"file-item dir","data-type":"dir","data-path":x.path,onContextMenu:b=>{b.stopPropagation();const S=xe(x.path);k(b,x.path,S?{path:S,name:x.name}:null)},children:[s.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>Te(x.path),children:[s.jsx(Bt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:x.name})]}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":h("linkFolderTip"),"aria-label":h("linkFolderTip"),onClick:()=>o(x.path,x.name,"reference",!0),children:s.jsx(ia,{})}),s.jsx("button",{type:"button",className:`file-attach copy${M===`name:${x.path}`?" copied":""}`,"data-tip":h("copyName"),"aria-label":h("copyName"),onClick:()=>se(x.name,`name:${x.path}`),children:M===`name:${x.path}`?s.jsx(Tt,{}):s.jsx(St,{})}),s.jsx("button",{type:"button",className:`file-attach copy${M===`path:${x.path}`?" copied":""}`,"data-tip":h("copyPath"),"aria-label":h("copyPath"),onClick:()=>se(K(x.path),`path:${x.path}`),children:M===`path:${x.path}`?s.jsx(Tt,{}):s.jsx(si,{})})]},x.path):s.jsxs("div",{className:"file-item file","data-type":"file","data-path":x.path,onContextMenu:b=>{b.stopPropagation(),k(b,A)},children:[s.jsxs("button",{type:"button",className:"file-name",title:`${x.path} — ${h("previewFile")}`,onClick:()=>l(x.path,x.name),children:[s.jsx(Cc,{className:"file-icon"}),s.jsx("span",{className:"file-name-text",children:x.name})]}),s.jsx("button",{type:"button",className:"file-attach download","data-tip":h("downloadFile"),onClick:()=>{Wu(x.path,x.name).then(b=>{b.ok||b.cancelled||u("error",h("downloadFailed",{error:b.error===Zr?h("fileNotFoundShort"):b.error}))})},children:s.jsx(Yt,{})}),s.jsx("button",{type:"button",className:"file-attach inline","data-tip":h("attachInlineTip"),onClick:()=>o(x.path,x.name,"inline"),children:s.jsx(dt,{})}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":h("referenceTip"),"aria-label":h("referenceTip"),onClick:()=>o(x.path,x.name,"reference"),children:s.jsx(ia,{})}),s.jsx("button",{type:"button",className:`file-attach copy${M===`name:${x.path}`?" copied":""}`,"data-tip":h("copyName"),"aria-label":h("copyName"),onClick:()=>se(x.name,`name:${x.path}`),children:M===`name:${x.path}`?s.jsx(Tt,{}):s.jsx(St,{})}),s.jsx("button",{type:"button",className:`file-attach copy${M===`path:${x.path}`?" copied":""}`,"data-tip":h("copyPath"),"aria-label":h("copyPath"),onClick:()=>se(K(x.path),`path:${x.path}`),children:M===`path:${x.path}`?s.jsx(Tt,{}):s.jsx(si,{})})]},x.path)),t.truncated&&s.jsx("div",{className:"panel-empty files-truncated",children:h("filesTruncated")})]}),!W&&!t&&s.jsx("div",{className:"panel-empty",children:h("noFiles")})]}),ee&&s.jsx("div",{className:"rp-sash",onPointerDown:le,onDoubleClick:()=>te({...Gn}),title:h("dragToResize")}),ee&&s.jsx("div",{className:"panel-widgets",style:{flexGrow:U.widgets,minHeight:Ci},children:i.filter(x=>x.lines.length>0).map(x=>s.jsxs("div",{className:"widget",children:[s.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:h("widgetExpand"),onClick:()=>B(x.key),children:[s.jsx("span",{children:x.key}),s.jsx(Ec,{})]}),s.jsx("pre",{className:"widget-lines",children:x.lines.join(`
306
+ `)})]},x.key))}),v&&(()=>{const x=i.find(b=>b.key===v);return x?s.jsx("div",{className:"modal-backdrop",onClick:()=>B(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:x.key}),s.jsx("button",{type:"button",className:"btn",title:h("close"),onClick:()=>B(null),children:s.jsx(Ke,{})})]}),s.jsx("pre",{className:"widget-expand-lines",children:x.lines.join(`
307
+ `)})]})}):null})(),me&&s.jsxs("div",{className:"ctx-menu",style:{left:me.x,top:me.y},onContextMenu:x=>{x.preventDefault(),x.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",onClick:de,children:[s.jsx(Ar,{}),G.current===A?h("uploadToCurrentDir"):h("uploadToFolder")]}),ce.current&&s.jsxs("button",{type:"button",className:"ctx-item",onClick:re,children:[s.jsx(Bt,{}),h("openAsProject")]})]})]})});var eo=Cr();function Gu(e){Fl(e,[/\r?\n|\r/g,Vu])}function Vu(){return{type:"break"}}function zu(){return function(e){Gu(e)}}function Qu(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 m=_i(t,n[l-1]);u=m===-1?t.length+1:m+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],m=_i(t,u),T=m===-1?t.length+1:m+1;if(u===T)break;n.push(T)}const l=(o.line>1?n[o.line-2]:0)+o.column-1;if(l<n[o.line-1])return l}}}function _i(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 to={}.hasOwnProperty,Xu=Object.prototype;function Ju(e,t){const n=t||{};return La({file:n.file||void 0,location:!1,schema:n.space==="svg"?In:Ia,verbose:n.verbose||!1},e)}function La(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:so(e,t.childNodes),data:{quirksMode:a}},e.file&&e.location){const o=String(e.file),l=Qu(o),u=l.toPoint(0),m=l.toPoint(o.length);n.position={start:u,end:m}}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=Zu(e,t),n}}function so(e,t){let n=-1;const i=[];for(;++n<t.length;){const a=La(e,t[n]);i.push(a)}return i}function Zu(e,t){const n=e.schema;e.schema=t.namespaceURI===Wt.svg?In:Ia;let i=-1;const a={};for(;++i<t.attrs.length;){const u=t.attrs[i],m=(u.prefix?u.prefix+":":"")+u.name;to.call(Xu,m)||(a[m]=u.value)}const l=(e.schema.space==="svg"?Hl:Ul)(t.tagName,a,so(e,t.childNodes));if(Xs(e,t,l),l.tagName==="template"){const u=t,m=u.sourceCodeLocation,T=m&&m.startTag&&ns(m.startTag),h=m&&m.endTag&&ns(m.endTag),g=La(e,u.content);T&&h&&e.file&&(g.position={start:T.end,end:h.start}),l.content=g}return e.schema=n,l}function Xs(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const i=ed(e,n,t.sourceCodeLocation);i&&(e.location=!0,n.position=i)}}function ed(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)to.call(n.attrs,l)&&(o[xr(e.schema,l).property]=ns(n.attrs[l]));na(n.startTag);const u=ns(n.startTag),m=n.endTag?ns(n.endTag):void 0,T={opening:u};m&&(T.closing=m),T.properties=o,t.data={position:T}}}return i}function ns(e){const t=Si({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=Si({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function Si(e){return e.line&&e.column?e:void 0}const td={},sd={}.hasOwnProperty,no=yr("type",{handlers:{root:ad,element:cd,text:od,comment:ld,doctype:rd}});function nd(e,t){const i=(t||td).space;return no(e,i==="svg"?In:Ia)}function ad(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=Ra(e.children,n,t),us(e,n),n}function id(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=Ra(e.children,n,t),us(e,n),n}function rd(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return us(e,t),t}function od(e){const t={nodeName:"#text",value:e.value,parentNode:null};return us(e,t),t}function ld(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return us(e,t),t}function cd(e,t){const n=t;let i=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=In);const a=[];let o;if(e.properties){for(o in e.properties)if(o!=="children"&&sd.call(e.properties,o)){const m=ud(i,o,e.properties[o]);m&&a.push(m)}}const l=i.space,u={nodeName:e.tagName,tagName:e.tagName,attrs:a,namespaceURI:Wt[l],childNodes:[],parentNode:null};return u.childNodes=Ra(e.children,u,i),us(e,u),e.tagName==="template"&&e.content&&(u.content=id(e.content,i)),u}function ud(e,t,n){const i=xr(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?$l(n):ql(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 Ra(e,t,n){let i=-1;const a=[];if(e)for(;++i<e.length;){const o=no(e[i],n);o.parentNode=t,a.push(o)}return a}function us(e,t){const n=e.position;n&&n.start&&n.end&&(na(typeof n.start.offset=="number"),na(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 dd=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],md=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 p;(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"})(p||(p={}));const at={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function ao(e){return e>=55296&&e<=57343}function pd(e){return e>=56320&&e<=57343}function hd(e,t){return(e-55296)*1024+9216+t}function io(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function ro(e){return e>=64976&&e<=65007||md.has(e)}var F;(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"})(F||(F={}));const fd=65536;class gd{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=fd,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(pd(n))return this.pos++,this._addGap(),hd(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,p.EOF;return this._err(F.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,p.EOF;const i=this.html.charCodeAt(n);return i===p.CARRIAGE_RETURN?p.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,p.EOF;let t=this.html.charCodeAt(this.pos);return t===p.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,p.LINE_FEED):t===p.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,ao(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===p.LINE_FEED||t===p.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){io(t)?this._err(F.controlCharacterInInputStream):ro(t)&&this._err(F.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 oo(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 bd=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୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢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;怳Ādp໩໮uct;戏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ǣጓ\0጖y;䐎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Ā;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀ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Ā;e᜚᜜lƀ;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\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩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ↄⅪ←ٖ↛ǰ↉\0↎proø₞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;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\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\0⹻m;櫳;櫽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))),Ed=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 Td(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=Ed.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 xd=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 fa(e){return e>=Je.ZERO&&e<=Je.NINE}function yd(e){return e>=Je.UPPER_A&&e<=Je.UPPER_F||e>=Je.LOWER_A&&e<=Je.LOWER_F}function Nd(e){return e>=Je.UPPER_A&&e<=Je.UPPER_Z||e>=Je.LOWER_A&&e<=Je.LOWER_Z||fa(e)}function kd(e){return e===Je.EQUALS||Nd(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 vd{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)|xd)===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(fa(a)||yd(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(fa(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(Td(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=Cd(i,a,this.treeIndex+Math.max(1,o),l),this.treeIndex<0)return this.result===0||this.decodeMode===Nt.Attribute&&(o===0||kd(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 Cd(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 m=i-o;return m<0||m>=a?-1:e[n+m]-1}let l=n,u=l+a-1;for(;l<=u;){const m=l+u>>>1,T=e[m];if(T<i)l=m+1;else if(T>i)u=m-1;else return e[m+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 I;(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"})(I||(I={}));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 _d=new Map([[I.A,r.A],[I.ADDRESS,r.ADDRESS],[I.ANNOTATION_XML,r.ANNOTATION_XML],[I.APPLET,r.APPLET],[I.AREA,r.AREA],[I.ARTICLE,r.ARTICLE],[I.ASIDE,r.ASIDE],[I.B,r.B],[I.BASE,r.BASE],[I.BASEFONT,r.BASEFONT],[I.BGSOUND,r.BGSOUND],[I.BIG,r.BIG],[I.BLOCKQUOTE,r.BLOCKQUOTE],[I.BODY,r.BODY],[I.BR,r.BR],[I.BUTTON,r.BUTTON],[I.CAPTION,r.CAPTION],[I.CENTER,r.CENTER],[I.CODE,r.CODE],[I.COL,r.COL],[I.COLGROUP,r.COLGROUP],[I.DD,r.DD],[I.DESC,r.DESC],[I.DETAILS,r.DETAILS],[I.DIALOG,r.DIALOG],[I.DIR,r.DIR],[I.DIV,r.DIV],[I.DL,r.DL],[I.DT,r.DT],[I.EM,r.EM],[I.EMBED,r.EMBED],[I.FIELDSET,r.FIELDSET],[I.FIGCAPTION,r.FIGCAPTION],[I.FIGURE,r.FIGURE],[I.FONT,r.FONT],[I.FOOTER,r.FOOTER],[I.FOREIGN_OBJECT,r.FOREIGN_OBJECT],[I.FORM,r.FORM],[I.FRAME,r.FRAME],[I.FRAMESET,r.FRAMESET],[I.H1,r.H1],[I.H2,r.H2],[I.H3,r.H3],[I.H4,r.H4],[I.H5,r.H5],[I.H6,r.H6],[I.HEAD,r.HEAD],[I.HEADER,r.HEADER],[I.HGROUP,r.HGROUP],[I.HR,r.HR],[I.HTML,r.HTML],[I.I,r.I],[I.IMG,r.IMG],[I.IMAGE,r.IMAGE],[I.INPUT,r.INPUT],[I.IFRAME,r.IFRAME],[I.KEYGEN,r.KEYGEN],[I.LABEL,r.LABEL],[I.LI,r.LI],[I.LINK,r.LINK],[I.LISTING,r.LISTING],[I.MAIN,r.MAIN],[I.MALIGNMARK,r.MALIGNMARK],[I.MARQUEE,r.MARQUEE],[I.MATH,r.MATH],[I.MENU,r.MENU],[I.META,r.META],[I.MGLYPH,r.MGLYPH],[I.MI,r.MI],[I.MO,r.MO],[I.MN,r.MN],[I.MS,r.MS],[I.MTEXT,r.MTEXT],[I.NAV,r.NAV],[I.NOBR,r.NOBR],[I.NOFRAMES,r.NOFRAMES],[I.NOEMBED,r.NOEMBED],[I.NOSCRIPT,r.NOSCRIPT],[I.OBJECT,r.OBJECT],[I.OL,r.OL],[I.OPTGROUP,r.OPTGROUP],[I.OPTION,r.OPTION],[I.P,r.P],[I.PARAM,r.PARAM],[I.PLAINTEXT,r.PLAINTEXT],[I.PRE,r.PRE],[I.RB,r.RB],[I.RP,r.RP],[I.RT,r.RT],[I.RTC,r.RTC],[I.RUBY,r.RUBY],[I.S,r.S],[I.SCRIPT,r.SCRIPT],[I.SEARCH,r.SEARCH],[I.SECTION,r.SECTION],[I.SELECT,r.SELECT],[I.SOURCE,r.SOURCE],[I.SMALL,r.SMALL],[I.SPAN,r.SPAN],[I.STRIKE,r.STRIKE],[I.STRONG,r.STRONG],[I.STYLE,r.STYLE],[I.SUB,r.SUB],[I.SUMMARY,r.SUMMARY],[I.SUP,r.SUP],[I.TABLE,r.TABLE],[I.TBODY,r.TBODY],[I.TEMPLATE,r.TEMPLATE],[I.TEXTAREA,r.TEXTAREA],[I.TFOOT,r.TFOOT],[I.TD,r.TD],[I.TH,r.TH],[I.THEAD,r.THEAD],[I.TITLE,r.TITLE],[I.TR,r.TR],[I.TRACK,r.TRACK],[I.TT,r.TT],[I.U,r.U],[I.UL,r.UL],[I.SVG,r.SVG],[I.VAR,r.VAR],[I.WBR,r.WBR],[I.XMP,r.XMP]]);function ds(e){var t;return(t=_d.get(e))!==null&&t!==void 0?t:r.UNKNOWN}const ne=r,Sd={[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},ga=new Set([ne.H1,ne.H2,ne.H3,ne.H4,ne.H5,ne.H6]);I.STYLE,I.SCRIPT,I.XMP,I.IFRAME,I.NOEMBED,I.NOFRAMES,I.PLAINTEXT;var f;(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"})(f||(f={}));const Ye={DATA:f.DATA,RCDATA:f.RCDATA,RAWTEXT:f.RAWTEXT,SCRIPT_DATA:f.SCRIPT_DATA,PLAINTEXT:f.PLAINTEXT,CDATA_SECTION:f.CDATA_SECTION};function wd(e){return e>=p.DIGIT_0&&e<=p.DIGIT_9}function ks(e){return e>=p.LATIN_CAPITAL_A&&e<=p.LATIN_CAPITAL_Z}function Ad(e){return e>=p.LATIN_SMALL_A&&e<=p.LATIN_SMALL_Z}function Rt(e){return Ad(e)||ks(e)}function wi(e){return Rt(e)||wd(e)}function Ys(e){return e+32}function lo(e){return e===p.SPACE||e===p.LINE_FEED||e===p.TABULATION||e===p.FORM_FEED}function Ai(e){return lo(e)||e===p.SOLIDUS||e===p.GREATER_THAN_SIGN}function Id(e){return e===p.NULL?F.nullCharacterReference:e>1114111?F.characterReferenceOutsideUnicodeRange:ao(e)?F.surrogateCharacterReference:ro(e)?F.noncharacterCharacterReference:io(e)||e===p.CARRIAGE_RETURN?F.controlCharacterReference:null}class jd{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=f.DATA,this.returnState=f.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new gd(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new vd(bd,(i,a)=>{this.preprocessor.pos=this.entityStartPos+a-1,this._flushCodePointConsumedAsCharacterReference(i)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(F.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:i=>{this._err(F.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+i)},validateNumericCharacterReference:i=>{const a=Id(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(oo(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(F.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(F.endTagWithAttributes),t.selfClosing&&this._err(F.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=lo(t)?Oe.WHITESPACE_CHARACTER:t===p.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=f.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Nt.Attribute:Nt.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===f.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===f.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===f.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case f.DATA:{this._stateData(t);break}case f.RCDATA:{this._stateRcdata(t);break}case f.RAWTEXT:{this._stateRawtext(t);break}case f.SCRIPT_DATA:{this._stateScriptData(t);break}case f.PLAINTEXT:{this._statePlaintext(t);break}case f.TAG_OPEN:{this._stateTagOpen(t);break}case f.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case f.TAG_NAME:{this._stateTagName(t);break}case f.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case f.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case f.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case f.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case f.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case f.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case f.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case f.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case f.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case f.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case f.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case f.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case f.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case f.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case f.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case f.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case f.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case f.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case f.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case f.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case f.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case f.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case f.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case f.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case f.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case f.BOGUS_COMMENT:{this._stateBogusComment(t);break}case f.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case f.COMMENT_START:{this._stateCommentStart(t);break}case f.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case f.COMMENT:{this._stateComment(t);break}case f.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case f.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case f.COMMENT_END:{this._stateCommentEnd(t);break}case f.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case f.DOCTYPE:{this._stateDoctype(t);break}case f.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case f.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case f.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case f.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case f.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case f.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case f.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case f.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case f.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case f.CDATA_SECTION:{this._stateCdataSection(t);break}case f.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case f.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case f.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case f.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case p.LESS_THAN_SIGN:{this.state=f.TAG_OPEN;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(F.unexpectedNullCharacter),this._emitCodePoint(t);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case p.AMPERSAND:{this._startCharacterReference();break}case p.LESS_THAN_SIGN:{this.state=f.RCDATA_LESS_THAN_SIGN;break}case p.NULL:{this._err(F.unexpectedNullCharacter),this._emitChars(qe);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case p.LESS_THAN_SIGN:{this.state=f.RAWTEXT_LESS_THAN_SIGN;break}case p.NULL:{this._err(F.unexpectedNullCharacter),this._emitChars(qe);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_LESS_THAN_SIGN;break}case p.NULL:{this._err(F.unexpectedNullCharacter),this._emitChars(qe);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case p.NULL:{this._err(F.unexpectedNullCharacter),this._emitChars(qe);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(Rt(t))this._createStartTagToken(),this.state=f.TAG_NAME,this._stateTagName(t);else switch(t){case p.EXCLAMATION_MARK:{this.state=f.MARKUP_DECLARATION_OPEN;break}case p.SOLIDUS:{this.state=f.END_TAG_OPEN;break}case p.QUESTION_MARK:{this._err(F.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t);break}case p.EOF:{this._err(F.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(F.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=f.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(Rt(t))this._createEndTagToken(),this.state=f.TAG_NAME,this._stateTagName(t);else switch(t){case p.GREATER_THAN_SIGN:{this._err(F.missingEndTagName),this.state=f.DATA;break}case p.EOF:{this._err(F.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(F.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BEFORE_ATTRIBUTE_NAME;break}case p.SOLIDUS:{this.state=f.SELF_CLOSING_START_TAG;break}case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentTagToken();break}case p.NULL:{this._err(F.unexpectedNullCharacter),n.tagName+=qe;break}case p.EOF:{this._err(F.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(ks(t)?Ys(t):t)}}_stateRcdataLessThanSign(t){t===p.SOLIDUS?this.state=f.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=f.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){Rt(t)?(this.state=f.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=f.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 p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=f.BEFORE_ATTRIBUTE_NAME,!1;case p.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=f.SELF_CLOSING_START_TAG,!1;case p.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=f.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===p.SOLIDUS?this.state=f.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){Rt(t)?(this.state=f.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case p.SOLIDUS:{this.state=f.SCRIPT_DATA_END_TAG_OPEN;break}case p.EXCLAMATION_MARK:{this.state=f.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=f.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){Rt(t)?(this.state=f.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===p.HYPHEN_MINUS?(this.state=f.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===p.HYPHEN_MINUS?(this.state=f.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.NULL:{this._err(F.unexpectedNullCharacter),this._emitChars(qe);break}case p.EOF:{this._err(F.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.NULL:{this._err(F.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_ESCAPED,this._emitChars(qe);break}case p.EOF:{this._err(F.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case p.HYPHEN_MINUS:{this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.GREATER_THAN_SIGN:{this.state=f.SCRIPT_DATA,this._emitChars(">");break}case p.NULL:{this._err(F.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_ESCAPED,this._emitChars(qe);break}case p.EOF:{this._err(F.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===p.SOLIDUS?this.state=f.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:Rt(t)?(this._emitChars("<"),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){Rt(t)?(this.state=f.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(at.SCRIPT,!1)&&Ai(this.preprocessor.peek(at.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<at.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.NULL:{this._err(F.unexpectedNullCharacter),this._emitChars(qe);break}case p.EOF:{this._err(F.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.NULL:{this._err(F.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(qe);break}case p.EOF:{this._err(F.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case p.HYPHEN_MINUS:{this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.GREATER_THAN_SIGN:{this.state=f.SCRIPT_DATA,this._emitChars(">");break}case p.NULL:{this._err(F.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(qe);break}case p.EOF:{this._err(F.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===p.SOLIDUS?(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(at.SCRIPT,!1)&&Ai(this.preprocessor.peek(at.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<at.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=f.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.SOLIDUS:case p.GREATER_THAN_SIGN:case p.EOF:{this.state=f.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case p.EQUALS_SIGN:{this._err(F.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=f.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=f.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:case p.SOLIDUS:case p.GREATER_THAN_SIGN:case p.EOF:{this._leaveAttrName(),this.state=f.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case p.EQUALS_SIGN:{this._leaveAttrName(),this.state=f.BEFORE_ATTRIBUTE_VALUE;break}case p.QUOTATION_MARK:case p.APOSTROPHE:case p.LESS_THAN_SIGN:{this._err(F.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case p.NULL:{this._err(F.unexpectedNullCharacter),this.currentAttr.name+=qe;break}default:this.currentAttr.name+=String.fromCodePoint(ks(t)?Ys(t):t)}}_stateAfterAttributeName(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.SOLIDUS:{this.state=f.SELF_CLOSING_START_TAG;break}case p.EQUALS_SIGN:{this.state=f.BEFORE_ATTRIBUTE_VALUE;break}case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(F.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=f.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.QUOTATION_MARK:{this.state=f.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this.state=f.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(F.missingAttributeValue),this.state=f.DATA,this.emitCurrentTagToken();break}default:this.state=f.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case p.QUOTATION_MARK:{this.state=f.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(F.unexpectedNullCharacter),this.currentAttr.value+=qe;break}case p.EOF:{this._err(F.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case p.APOSTROPHE:{this.state=f.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(F.unexpectedNullCharacter),this.currentAttr.value+=qe;break}case p.EOF:{this._err(F.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this._leaveAttrValue(),this.state=f.BEFORE_ATTRIBUTE_NAME;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=f.DATA,this.emitCurrentTagToken();break}case p.NULL:{this._err(F.unexpectedNullCharacter),this.currentAttr.value+=qe;break}case p.QUOTATION_MARK:case p.APOSTROPHE:case p.LESS_THAN_SIGN:case p.EQUALS_SIGN:case p.GRAVE_ACCENT:{this._err(F.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case p.EOF:{this._err(F.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this._leaveAttrValue(),this.state=f.BEFORE_ATTRIBUTE_NAME;break}case p.SOLIDUS:{this._leaveAttrValue(),this.state=f.SELF_CLOSING_START_TAG;break}case p.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=f.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(F.eofInTag),this._emitEOFToken();break}default:this._err(F.missingWhitespaceBetweenAttributes),this.state=f.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case p.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=f.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(F.eofInTag),this._emitEOFToken();break}default:this._err(F.unexpectedSolidusInTag),this.state=f.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentComment(n);break}case p.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case p.NULL:{this._err(F.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=f.COMMENT_START):this._consumeSequenceIfMatch(at.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(at.DOCTYPE.length+1),this.state=f.DOCTYPE):this._consumeSequenceIfMatch(at.CDATA_START,!0)?this.inForeignNode?this.state=f.CDATA_SECTION:(this._err(F.cdataInHtmlContent),this._createCommentToken(at.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=f.BOGUS_COMMENT):this._ensureHibernation()||(this._err(F.incorrectlyOpenedComment),this._createCommentToken(2),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case p.HYPHEN_MINUS:{this.state=f.COMMENT_START_DASH;break}case p.GREATER_THAN_SIGN:{this._err(F.abruptClosingOfEmptyComment),this.state=f.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=f.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=f.COMMENT_END;break}case p.GREATER_THAN_SIGN:{this._err(F.abruptClosingOfEmptyComment),this.state=f.DATA,this.emitCurrentComment(n);break}case p.EOF:{this._err(F.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=f.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=f.COMMENT_END_DASH;break}case p.LESS_THAN_SIGN:{n.data+="<",this.state=f.COMMENT_LESS_THAN_SIGN;break}case p.NULL:{this._err(F.unexpectedNullCharacter),n.data+=qe;break}case p.EOF:{this._err(F.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const n=this.currentToken;switch(t){case p.EXCLAMATION_MARK:{n.data+="!",this.state=f.COMMENT_LESS_THAN_SIGN_BANG;break}case p.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=f.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===p.HYPHEN_MINUS?this.state=f.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=f.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===p.HYPHEN_MINUS?this.state=f.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=f.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==p.GREATER_THAN_SIGN&&t!==p.EOF&&this._err(F.nestedComment),this.state=f.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=f.COMMENT_END;break}case p.EOF:{this._err(F.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=f.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentComment(n);break}case p.EXCLAMATION_MARK:{this.state=f.COMMENT_END_BANG;break}case p.HYPHEN_MINUS:{n.data+="-";break}case p.EOF:{this._err(F.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=f.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{n.data+="--!",this.state=f.COMMENT_END_DASH;break}case p.GREATER_THAN_SIGN:{this._err(F.incorrectlyClosedComment),this.state=f.DATA,this.emitCurrentComment(n);break}case p.EOF:{this._err(F.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=f.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this.state=f.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case p.EOF:{this._err(F.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(F.missingWhitespaceBeforeDoctypeName),this.state=f.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(ks(t))this._createDoctypeToken(String.fromCharCode(Ys(t))),this.state=f.DOCTYPE_NAME;else switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.NULL:{this._err(F.unexpectedNullCharacter),this._createDoctypeToken(qe),this.state=f.DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this._err(F.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(F.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=f.DOCTYPE_NAME}}_stateDoctypeName(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.AFTER_DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.NULL:{this._err(F.unexpectedNullCharacter),n.name+=qe;break}case p.EOF:{this._err(F.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 p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(F.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(at.PUBLIC,!1)?this.state=f.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(at.SYSTEM,!1)?this.state=f.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(F.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.QUOTATION_MARK:{this._err(F.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(F.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(F.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(F.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(F.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.QUOTATION_MARK:{n.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(F.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(F.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(F.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case p.QUOTATION_MARK:{this.state=f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.NULL:{this._err(F.unexpectedNullCharacter),n.publicId+=qe;break}case p.GREATER_THAN_SIGN:{this._err(F.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(F.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 p.APOSTROPHE:{this.state=f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.NULL:{this._err(F.unexpectedNullCharacter),n.publicId+=qe;break}case p.GREATER_THAN_SIGN:{this._err(F.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(F.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 p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case p.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.QUOTATION_MARK:{this._err(F.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(F.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.EOF:{this._err(F.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(F.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.QUOTATION_MARK:{n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.EOF:{this._err(F.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(F.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.QUOTATION_MARK:{this._err(F.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(F.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(F.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(F.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(F.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const n=this.currentToken;switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.QUOTATION_MARK:{n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(F.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(F.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(F.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case p.QUOTATION_MARK:{this.state=f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.NULL:{this._err(F.unexpectedNullCharacter),n.systemId+=qe;break}case p.GREATER_THAN_SIGN:{this._err(F.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(F.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 p.APOSTROPHE:{this.state=f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.NULL:{this._err(F.unexpectedNullCharacter),n.systemId+=qe;break}case p.GREATER_THAN_SIGN:{this._err(F.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(F.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 p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:break;case p.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.EOF:{this._err(F.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(F.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=f.DATA;break}case p.NULL:{this._err(F.unexpectedNullCharacter);break}case p.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case p.RIGHT_SQUARE_BRACKET:{this.state=f.CDATA_SECTION_BRACKET;break}case p.EOF:{this._err(F.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===p.RIGHT_SQUARE_BRACKET?this.state=f.CDATA_SECTION_END:(this._emitChars("]"),this.state=f.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case p.GREATER_THAN_SIGN:{this.state=f.DATA;break}case p.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=f.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(p.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&wi(this.preprocessor.peek(1))?f.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){wi(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===p.SEMICOLON&&this._err(F.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const co=new Set([r.DD,r.DT,r.LI,r.OPTGROUP,r.OPTION,r.P,r.RB,r.RP,r.RT,r.RTC]),Ii=new Set([...co,r.CAPTION,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]),En=new Set([r.APPLET,r.CAPTION,r.HTML,r.MARQUEE,r.OBJECT,r.TABLE,r.TD,r.TEMPLATE,r.TH]),Ld=new Set([...En,r.OL,r.UL]),Rd=new Set([...En,r.BUTTON]),ji=new Set([r.ANNOTATION_XML,r.MI,r.MN,r.MO,r.MS,r.MTEXT]),Li=new Set([r.DESC,r.FOREIGN_OBJECT,r.TITLE]),Dd=new Set([r.TR,r.TEMPLATE,r.HTML]),Pd=new Set([r.TBODY,r.TFOOT,r.THEAD,r.TEMPLATE,r.HTML]),Od=new Set([r.TABLE,r.TEMPLATE,r.HTML]),Md=new Set([r.TD,r.TH]);class Bd{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(ga,Z.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Md,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(Od,Z.HTML)}clearBackToTableBodyContext(){this.clearBackTo(Pd,Z.HTML)}clearBackToTableRowContext(){this.clearBackTo(Dd,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(Li.has(a))return!1;break}case Z.MATHML:{if(ji.has(a))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,En)}hasInListItemScope(t){return this.hasInDynamicScope(t,Ld)}hasInButtonScope(t){return this.hasInDynamicScope(t,Rd)}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(ga.has(n))return!0;if(En.has(n))return!1;break}case Z.SVG:{if(Li.has(n))return!1;break}case Z.MATHML:{if(ji.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&&co.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&Ii.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&Ii.has(this.currentTagId);)this.pop()}}const Vn=3;var Et;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Et||(Et={}));const Ri={type:Et.Marker};class Fd{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 m=this.entries[u];if(m.type===Et.Marker)break;const{element:T}=m;if(this.treeAdapter.getTagName(T)===o&&this.treeAdapter.getNamespaceURI(T)===l){const h=this.treeAdapter.getAttrList(T);h.length===a&&i.push({idx:u,attrs:h})}}return i}_ensureNoahArkCondition(t){if(this.entries.length<Vn)return;const n=this.treeAdapter.getAttrList(t),i=this._getNoahArkConditionCandidates(t,n);if(i.length<Vn)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(m=>a.get(m.name)===m.value)&&(o+=1,o>=Vn&&this.entries.splice(u.idx,1))}}insertMarker(){this.entries.unshift(Ri)}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(Ri);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}}},uo="html",Hd="about:legacy-compat",Ud="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",mo=["+//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//"],$d=[...mo,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],qd=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),po=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],Wd=[...po,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function Di(e,t){return t.some(n=>e.startsWith(n))}function Kd(e){return e.name===uo&&e.publicId===null&&(e.systemId===null||e.systemId===Hd)}function Yd(e){if(e.name!==uo)return ut.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===Ud)return ut.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),qd.has(n))return ut.QUIRKS;let i=t===null?$d:mo;if(Di(n,i))return ut.QUIRKS;if(i=t===null?po:Wd,Di(n,i))return ut.LIMITED_QUIRKS}return ut.NO_QUIRKS}const Pi={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},Gd="definitionurl",Vd="definitionURL",zd=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])),Qd=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}]]),Xd=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])),Jd=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 Zd(e){const t=e.tagID;return t===r.FONT&&e.attrs.some(({name:i})=>i===Gt.COLOR||i===Gt.SIZE||i===Gt.FACE)||Jd.has(t)}function ho(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===Gd){e.attrs[t].name=Vd;break}}function fo(e){for(let t=0;t<e.attrs.length;t++){const n=zd.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function Da(e){for(let t=0;t<e.attrs.length;t++){const n=Qd.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 em(e){const t=Xd.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=ds(e.tagName))}function tm(e,t){return t===Z.MATHML&&(e===r.MI||e===r.MO||e===r.MN||e===r.MS||e===r.MTEXT)}function sm(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===Pi.TEXT_HTML||a===Pi.APPLICATION_XML}}return t===Z.SVG&&(e===r.FOREIGN_OBJECT||e===r.DESC||e===r.TITLE)}function nm(e,t,n,i){return(!i||i===Z.HTML)&&sm(e,t,n)||(!i||i===Z.MATHML)&&tm(e,t)}const am="hidden",im=8,rm=3;var E;(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"})(E||(E={}));const om={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},go=new Set([r.TABLE,r.TBODY,r.TFOOT,r.THEAD,r.TR]),Oi={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Dt,onParseError:null};class Mi{constructor(t,n,i=null,a=null){this.fragmentContext=i,this.scriptHandler=a,this.currentToken=null,this.stopped=!1,this.insertionMode=E.INITIAL,this.originalInsertionMode=E.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={...Oi,...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 jd(this.options,this),this.activeFormattingElements=new Fd(this.treeAdapter),this.fragmentContextID=i?ds(this.treeAdapter.getTagName(i)):r.UNKNOWN,this._setContextModes(i??this.document,this.fragmentContextID),this.openElements=new Bd(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={...Oi,...n};t??(t=i.treeAdapter.createElement(I.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(E.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:om,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=E.TEXT}switchToPlaintextParsing(){this.insertionMode=E.TEXT,this.originalInsertionMode=E.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)===I.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(I.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:m,endCol:T,endOffset:h}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(l,{endLine:m,endCol:T,endOffset:h})}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)===I.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 nm(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=E.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=E.IN_ROW;return}case r.TBODY:case r.THEAD:case r.TFOOT:{this.insertionMode=E.IN_TABLE_BODY;return}case r.CAPTION:{this.insertionMode=E.IN_CAPTION;return}case r.COLGROUP:{this.insertionMode=E.IN_COLUMN_GROUP;return}case r.TABLE:{this.insertionMode=E.IN_TABLE;return}case r.BODY:{this.insertionMode=E.IN_BODY;return}case r.FRAMESET:{this.insertionMode=E.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?E.AFTER_HEAD:E.BEFORE_HEAD;return}case r.TD:case r.TH:{if(t>0){this.insertionMode=E.IN_CELL;return}break}case r.HEAD:{if(t>0){this.insertionMode=E.IN_HEAD;return}break}}this.insertionMode=E.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=E.IN_SELECT_IN_TABLE;return}}this.insertionMode=E.IN_SELECT}_isElementCausesFosterParenting(t){return go.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 Sd[i].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Mp(this,t);return}switch(this.insertionMode){case E.INITIAL:{gs(this,t);break}case E.BEFORE_HTML:{Cs(this,t);break}case E.BEFORE_HEAD:{_s(this,t);break}case E.IN_HEAD:{Ss(this,t);break}case E.IN_HEAD_NO_SCRIPT:{ws(this,t);break}case E.AFTER_HEAD:{As(this,t);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:{Eo(this,t);break}case E.TEXT:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{zn(this,t);break}case E.IN_TABLE_TEXT:{vo(this,t);break}case E.IN_COLUMN_GROUP:{Tn(this,t);break}case E.AFTER_BODY:{xn(this,t);break}case E.AFTER_AFTER_BODY:{Js(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Op(this,t);return}switch(this.insertionMode){case E.INITIAL:{gs(this,t);break}case E.BEFORE_HTML:{Cs(this,t);break}case E.BEFORE_HEAD:{_s(this,t);break}case E.IN_HEAD:{Ss(this,t);break}case E.IN_HEAD_NO_SCRIPT:{ws(this,t);break}case E.AFTER_HEAD:{As(this,t);break}case E.TEXT:{this._insertCharacters(t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{zn(this,t);break}case E.IN_COLUMN_GROUP:{Tn(this,t);break}case E.AFTER_BODY:{xn(this,t);break}case E.AFTER_AFTER_BODY:{Js(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){ba(this,t);return}switch(this.insertionMode){case E.INITIAL:case E.BEFORE_HTML:case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_TEMPLATE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{ba(this,t);break}case E.IN_TABLE_TEXT:{bs(this,t);break}case E.AFTER_BODY:{hm(this,t);break}case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{fm(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case E.INITIAL:{gm(this,t);break}case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:{this._err(t,F.misplacedDoctype);break}case E.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,F.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?Bp(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case E.INITIAL:{gs(this,t);break}case E.BEFORE_HTML:{bm(this,t);break}case E.BEFORE_HEAD:{Tm(this,t);break}case E.IN_HEAD:{ht(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Nm(this,t);break}case E.AFTER_HEAD:{vm(this,t);break}case E.IN_BODY:{Ze(this,t);break}case E.IN_TABLE:{os(this,t);break}case E.IN_TABLE_TEXT:{bs(this,t);break}case E.IN_CAPTION:{xp(this,t);break}case E.IN_COLUMN_GROUP:{Ma(this,t);break}case E.IN_TABLE_BODY:{Pn(this,t);break}case E.IN_ROW:{On(this,t);break}case E.IN_CELL:{kp(this,t);break}case E.IN_SELECT:{So(this,t);break}case E.IN_SELECT_IN_TABLE:{Cp(this,t);break}case E.IN_TEMPLATE:{Sp(this,t);break}case E.AFTER_BODY:{Ap(this,t);break}case E.IN_FRAMESET:{Ip(this,t);break}case E.AFTER_FRAMESET:{Lp(this,t);break}case E.AFTER_AFTER_BODY:{Dp(this,t);break}case E.AFTER_AFTER_FRAMESET:{Pp(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?Fp(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case E.INITIAL:{gs(this,t);break}case E.BEFORE_HTML:{Em(this,t);break}case E.BEFORE_HEAD:{xm(this,t);break}case E.IN_HEAD:{ym(this,t);break}case E.IN_HEAD_NO_SCRIPT:{km(this,t);break}case E.AFTER_HEAD:{Cm(this,t);break}case E.IN_BODY:{Dn(this,t);break}case E.TEXT:{up(this,t);break}case E.IN_TABLE:{Ps(this,t);break}case E.IN_TABLE_TEXT:{bs(this,t);break}case E.IN_CAPTION:{yp(this,t);break}case E.IN_COLUMN_GROUP:{Np(this,t);break}case E.IN_TABLE_BODY:{Ea(this,t);break}case E.IN_ROW:{_o(this,t);break}case E.IN_CELL:{vp(this,t);break}case E.IN_SELECT:{wo(this,t);break}case E.IN_SELECT_IN_TABLE:{_p(this,t);break}case E.IN_TEMPLATE:{wp(this,t);break}case E.AFTER_BODY:{Io(this,t);break}case E.IN_FRAMESET:{jp(this,t);break}case E.AFTER_FRAMESET:{Rp(this,t);break}case E.AFTER_AFTER_BODY:{Js(this,t);break}}}onEof(t){switch(this.insertionMode){case E.INITIAL:{gs(this,t);break}case E.BEFORE_HTML:{Cs(this,t);break}case E.BEFORE_HEAD:{_s(this,t);break}case E.IN_HEAD:{Ss(this,t);break}case E.IN_HEAD_NO_SCRIPT:{ws(this,t);break}case E.AFTER_HEAD:{As(this,t);break}case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{No(this,t);break}case E.TEXT:{dp(this,t);break}case E.IN_TABLE_TEXT:{bs(this,t);break}case E.IN_TEMPLATE:{Ao(this,t);break}case E.AFTER_BODY:case E.IN_FRAMESET:case E.AFTER_FRAMESET:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{Oa(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===p.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 E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.TEXT:case E.IN_COLUMN_GROUP:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{this._insertCharacters(t);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:case E.AFTER_BODY:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{bo(this,t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{zn(this,t);break}case E.IN_TABLE_TEXT:{ko(this,t);break}}}}function lm(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):yo(e,t),n}function cm(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 um(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),m=u&&o>=rm;!u||m?(m&&e.activeFormattingElements.removeEntry(u),e.openElements.remove(l)):(l=dm(e,u),i===t&&(e.activeFormattingElements.bookmark=u),e.treeAdapter.detachNode(i),e.treeAdapter.appendChild(l,i),i=l)}return i}function dm(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 mm(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 pm(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 Pa(e,t){for(let n=0;n<im;n++){const i=lm(e,t);if(!i)break;const a=cm(e,i);if(!a)break;e.activeFormattingElements.bookmark=i;const o=um(e,a,i.element),l=e.openElements.getCommonAncestor(i.element);e.treeAdapter.detachNode(o),l&&mm(e,l,o),pm(e,a,i)}}function ba(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function hm(e,t){e._appendCommentNode(t,e.openElements.items[0])}function fm(e,t){e._appendCommentNode(t,e.document)}function Oa(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 gm(e,t){e._setDocumentType(t);const n=t.forceQuirks?ut.QUIRKS:Yd(t);Kd(t)||e._err(t,F.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=E.BEFORE_HTML}function gs(e,t){e._err(t,F.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,ut.QUIRKS),e.insertionMode=E.BEFORE_HTML,e._processToken(t)}function bm(e,t){t.tagID===r.HTML?(e._insertElement(t,Z.HTML),e.insertionMode=E.BEFORE_HEAD):Cs(e,t)}function Em(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=E.BEFORE_HEAD,e._processToken(t)}function Tm(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=E.IN_HEAD;break}default:_s(e,t)}}function xm(e,t){const n=t.tagID;n===r.HEAD||n===r.BODY||n===r.HTML||n===r.BR?_s(e,t):e._err(t,F.endTagWithoutMatchingOpenElement)}function _s(e,t){e._insertFakeElement(I.HEAD,r.HEAD),e.headElement=e.openElements.current,e.insertionMode=E.IN_HEAD,e._processToken(t)}function ht(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=E.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=E.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(E.IN_TEMPLATE);break}case r.HEAD:{e._err(t,F.misplacedStartTagForHeadElement);break}default:Ss(e,t)}}function ym(e,t){switch(t.tagID){case r.HEAD:{e.openElements.pop(),e.insertionMode=E.AFTER_HEAD;break}case r.BODY:case r.BR:case r.HTML:{Ss(e,t);break}case r.TEMPLATE:{Qt(e,t);break}default:e._err(t,F.endTagWithoutMatchingOpenElement)}}function Qt(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==r.TEMPLATE&&e._err(t,F.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,F.endTagWithoutMatchingOpenElement)}function Ss(e,t){e.openElements.pop(),e.insertionMode=E.AFTER_HEAD,e._processToken(t)}function Nm(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:{ht(e,t);break}case r.NOSCRIPT:{e._err(t,F.nestedNoscriptInHead);break}default:ws(e,t)}}function km(e,t){switch(t.tagID){case r.NOSCRIPT:{e.openElements.pop(),e.insertionMode=E.IN_HEAD;break}case r.BR:{ws(e,t);break}default:e._err(t,F.endTagWithoutMatchingOpenElement)}}function ws(e,t){const n=t.type===Oe.EOF?F.openElementsLeftAfterEof:F.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=E.IN_HEAD,e._processToken(t)}function vm(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=E.IN_BODY;break}case r.FRAMESET:{e._insertElement(t,Z.HTML),e.insertionMode=E.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,F.abandonedHeadElementChild),e.openElements.push(e.headElement,r.HEAD),ht(e,t),e.openElements.remove(e.headElement);break}case r.HEAD:{e._err(t,F.misplacedStartTagForHeadElement);break}default:As(e,t)}}function Cm(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,F.endTagWithoutMatchingOpenElement)}}function As(e,t){e._insertFakeElement(I.BODY,r.BODY),e.insertionMode=E.IN_BODY,Rn(e,t)}function Rn(e,t){switch(t.type){case Oe.CHARACTER:{Eo(e,t);break}case Oe.WHITESPACE_CHARACTER:{bo(e,t);break}case Oe.COMMENT:{ba(e,t);break}case Oe.START_TAG:{Ze(e,t);break}case Oe.END_TAG:{Dn(e,t);break}case Oe.EOF:{No(e,t);break}}}function bo(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Eo(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function _m(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function Sm(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function wm(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,Z.HTML),e.insertionMode=E.IN_FRAMESET)}function Am(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML)}function Im(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&ga.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,Z.HTML)}function jm(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function Lm(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 Rm(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 Dm(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,Z.HTML),e.tokenizer.state=Ye.PLAINTEXT}function Pm(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 Om(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(I.A);n&&(Pa(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 Mm(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Bm(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(r.NOBR)&&(Pa(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,Z.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Fm(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function Hm(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=E.IN_TABLE}function To(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Z.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function xo(e){const t=oo(e,Gt.TYPE);return t!=null&&t.toLowerCase()===am}function Um(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,Z.HTML),xo(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function $m(e,t){e._appendElement(t,Z.HTML),t.ackSelfClosing=!0}function qm(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._appendElement(t,Z.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Wm(e,t){t.tagName=I.IMG,t.tagID=r.IMG,To(e,t)}function Km(e,t){e._insertElement(t,Z.HTML),e.skipNextNewLine=!0,e.tokenizer.state=Ye.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=E.TEXT}function Ym(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Ye.RAWTEXT)}function Gm(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Ye.RAWTEXT)}function Bi(e,t){e._switchToTextParsing(t,Ye.RAWTEXT)}function Vm(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===E.IN_TABLE||e.insertionMode===E.IN_CAPTION||e.insertionMode===E.IN_TABLE_BODY||e.insertionMode===E.IN_ROW||e.insertionMode===E.IN_CELL?E.IN_SELECT_IN_TABLE:E.IN_SELECT}function zm(e,t){e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,Z.HTML)}function Qm(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,Z.HTML)}function Xm(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(r.RTC),e._insertElement(t,Z.HTML)}function Jm(e,t){e._reconstructActiveFormattingElements(),ho(t),Da(t),t.selfClosing?e._appendElement(t,Z.MATHML):e._insertElement(t,Z.MATHML),t.ackSelfClosing=!0}function Zm(e,t){e._reconstructActiveFormattingElements(),fo(t),Da(t),t.selfClosing?e._appendElement(t,Z.SVG):e._insertElement(t,Z.SVG),t.ackSelfClosing=!0}function Fi(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:{Mm(e,t);break}case r.A:{Om(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Im(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:{Am(e,t);break}case r.LI:case r.DD:case r.DT:{Rm(e,t);break}case r.BR:case r.IMG:case r.WBR:case r.AREA:case r.EMBED:case r.KEYGEN:{To(e,t);break}case r.HR:{qm(e,t);break}case r.RB:case r.RTC:{Qm(e,t);break}case r.RT:case r.RP:{Xm(e,t);break}case r.PRE:case r.LISTING:{jm(e,t);break}case r.XMP:{Ym(e,t);break}case r.SVG:{Zm(e,t);break}case r.HTML:{_m(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:{ht(e,t);break}case r.BODY:{Sm(e,t);break}case r.FORM:{Lm(e,t);break}case r.NOBR:{Bm(e,t);break}case r.MATH:{Jm(e,t);break}case r.TABLE:{Hm(e,t);break}case r.INPUT:{Um(e,t);break}case r.PARAM:case r.TRACK:case r.SOURCE:{$m(e,t);break}case r.IMAGE:{Wm(e,t);break}case r.BUTTON:{Pm(e,t);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{Fm(e,t);break}case r.IFRAME:{Gm(e,t);break}case r.SELECT:{Vm(e,t);break}case r.OPTION:case r.OPTGROUP:{zm(e,t);break}case r.NOEMBED:case r.NOFRAMES:{Bi(e,t);break}case r.FRAMESET:{wm(e,t);break}case r.TEXTAREA:{Km(e,t);break}case r.NOSCRIPT:{e.options.scriptingEnabled?Bi(e,t):Fi(e,t);break}case r.PLAINTEXT:{Dm(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:Fi(e,t)}}function ep(e,t){if(e.openElements.hasInScope(r.BODY)&&(e.insertionMode=E.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function tp(e,t){e.openElements.hasInScope(r.BODY)&&(e.insertionMode=E.AFTER_BODY,Io(e,t))}function sp(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function np(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 ap(e){e.openElements.hasInButtonScope(r.P)||e._insertFakeElement(I.P,r.P),e._closePElement()}function ip(e){e.openElements.hasInListItemScope(r.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(r.LI),e.openElements.popUntilTagNamePopped(r.LI))}function rp(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function op(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function lp(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function cp(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(I.BR,r.BR),e.openElements.pop(),e.framesetOk=!1}function yo(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 Dn(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:{Pa(e,t);break}case r.P:{ap(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:{sp(e,t);break}case r.LI:{ip(e);break}case r.DD:case r.DT:{rp(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{op(e);break}case r.BR:{cp(e);break}case r.BODY:{ep(e,t);break}case r.HTML:{tp(e,t);break}case r.FORM:{np(e);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{lp(e,t);break}case r.TEMPLATE:{Qt(e,t);break}default:yo(e,t)}}function No(e,t){e.tmplInsertionModeStack.length>0?Ao(e,t):Oa(e,t)}function up(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 dp(e,t){e._err(t,F.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function zn(e,t){if(e.openElements.currentTagId!==void 0&&go.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=E.IN_TABLE_TEXT,t.type){case Oe.CHARACTER:{vo(e,t);break}case Oe.WHITESPACE_CHARACTER:{ko(e,t);break}}else Bs(e,t)}function mp(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,Z.HTML),e.insertionMode=E.IN_CAPTION}function pp(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Z.HTML),e.insertionMode=E.IN_COLUMN_GROUP}function hp(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(I.COLGROUP,r.COLGROUP),e.insertionMode=E.IN_COLUMN_GROUP,Ma(e,t)}function fp(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,Z.HTML),e.insertionMode=E.IN_TABLE_BODY}function gp(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(I.TBODY,r.TBODY),e.insertionMode=E.IN_TABLE_BODY,Pn(e,t)}function bp(e,t){e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function Ep(e,t){xo(t)?e._appendElement(t,Z.HTML):Bs(e,t),t.ackSelfClosing=!0}function Tp(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:{gp(e,t);break}case r.STYLE:case r.SCRIPT:case r.TEMPLATE:{ht(e,t);break}case r.COL:{hp(e,t);break}case r.FORM:{Tp(e,t);break}case r.TABLE:{bp(e,t);break}case r.TBODY:case r.TFOOT:case r.THEAD:{fp(e,t);break}case r.INPUT:{Ep(e,t);break}case r.CAPTION:{mp(e,t);break}case r.COLGROUP:{pp(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,Rn(e,t),e.fosterParentingEnabled=n}function ko(e,t){e.pendingCharacterTokens.push(t)}function vo(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 Co=new Set([r.CAPTION,r.COL,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]);function xp(e,t){const n=t.tagID;Co.has(n)?e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_TABLE,os(e,t)):Ze(e,t)}function yp(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=E.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:Dn(e,t)}}function Ma(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:{ht(e,t);break}default:Tn(e,t)}}function Np(e,t){switch(t.tagID){case r.COLGROUP:{e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=E.IN_TABLE);break}case r.TEMPLATE:{Qt(e,t);break}case r.COL:break;default:Tn(e,t)}}function Tn(e,t){e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=E.IN_TABLE,e._processToken(t))}function Pn(e,t){switch(t.tagID){case r.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,Z.HTML),e.insertionMode=E.IN_ROW;break}case r.TH:case r.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(I.TR,r.TR),e.insertionMode=E.IN_ROW,On(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=E.IN_TABLE,os(e,t));break}default:os(e,t)}}function Ea(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=E.IN_TABLE);break}case r.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.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 On(e,t){switch(t.tagID){case r.TH:case r.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,Z.HTML),e.insertionMode=E.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=E.IN_TABLE_BODY,Pn(e,t));break}default:os(e,t)}}function _o(e,t){switch(t.tagID){case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY);break}case r.TABLE:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Ea(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=E.IN_TABLE_BODY,Ea(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 kp(e,t){const n=t.tagID;Co.has(n)?(e.openElements.hasInTableScope(r.TD)||e.openElements.hasInTableScope(r.TH))&&(e._closeTableCell(),On(e,t)):Ze(e,t)}function vp(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=E.IN_ROW);break}case r.TABLE:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),_o(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:break;default:Dn(e,t)}}function So(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:{ht(e,t);break}}}function wo(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 Cp(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)):So(e,t)}function _p(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)):wo(e,t)}function Sp(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:{ht(e,t);break}case r.CAPTION:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.tmplInsertionModeStack[0]=E.IN_TABLE,e.insertionMode=E.IN_TABLE,os(e,t);break}case r.COL:{e.tmplInsertionModeStack[0]=E.IN_COLUMN_GROUP,e.insertionMode=E.IN_COLUMN_GROUP,Ma(e,t);break}case r.TR:{e.tmplInsertionModeStack[0]=E.IN_TABLE_BODY,e.insertionMode=E.IN_TABLE_BODY,Pn(e,t);break}case r.TD:case r.TH:{e.tmplInsertionModeStack[0]=E.IN_ROW,e.insertionMode=E.IN_ROW,On(e,t);break}default:e.tmplInsertionModeStack[0]=E.IN_BODY,e.insertionMode=E.IN_BODY,Ze(e,t)}}function wp(e,t){t.tagID===r.TEMPLATE&&Qt(e,t)}function Ao(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):Oa(e,t)}function Ap(e,t){t.tagID===r.HTML?Ze(e,t):xn(e,t)}function Io(e,t){var n;if(t.tagID===r.HTML){if(e.fragmentContext||(e.insertionMode=E.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 xn(e,t)}function xn(e,t){e.insertionMode=E.IN_BODY,Rn(e,t)}function Ip(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:{ht(e,t);break}}}function jp(e,t){t.tagID===r.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==r.FRAMESET&&(e.insertionMode=E.AFTER_FRAMESET))}function Lp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{ht(e,t);break}}}function Rp(e,t){t.tagID===r.HTML&&(e.insertionMode=E.AFTER_AFTER_FRAMESET)}function Dp(e,t){t.tagID===r.HTML?Ze(e,t):Js(e,t)}function Js(e,t){e.insertionMode=E.IN_BODY,Rn(e,t)}function Pp(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{ht(e,t);break}}}function Op(e,t){t.chars=qe,e._insertCharacters(t)}function Mp(e,t){e._insertCharacters(t),e.framesetOk=!1}function jo(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 Bp(e,t){if(Zd(t))jo(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),i=e.treeAdapter.getNamespaceURI(n);i===Z.MATHML?ho(t):i===Z.SVG&&(em(t),fo(t)),Da(t),t.selfClosing?e._appendElement(t,i):e._insertElement(t,i),t.ackSelfClosing=!0}}function Fp(e,t){if(t.tagID===r.P||t.tagID===r.BR){jo(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}}}I.AREA,I.BASE,I.BASEFONT,I.BGSOUND,I.BR,I.COL,I.EMBED,I.FRAME,I.HR,I.IMG,I.INPUT,I.KEYGEN,I.LINK,I.META,I.PARAM,I.SOURCE,I.TRACK,I.WBR;const Hp=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,Up=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),Hi={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function Lo(e,t){const n=Xp(e),i=yr("type",{handlers:{root:$p,element:qp,text:Wp,comment:Do,doctype:Kp,raw:Gp},unknown:Vp}),a={parser:n?new Mi(Hi):Mi.getFragmentParser(void 0,Hi),handle(u){i(u,a)},stitches:!1,options:t||{}};i(e,a),ms(a,Vt());const o=n?a.parser.document:a.parser.getFragment(),l=Ju(o,{file:a.options.file});return a.stitches&&Wl(l,"comment",function(u,m,T){const h=u;if(h.value.stitch&&T&&m!==void 0){const g=T.children;return g[m]=h.value.stitch,m}}),l.type==="root"&&l.children.length===1&&l.children[0].type===e.type?l.children[0]:l}function Ro(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function $p(e,t){Ro(e.children,t)}function qp(e,t){zp(e,t),Ro(e.children,t),Qp(e,t)}function Wp(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:Oe.CHARACTER,chars:e.value,location:Fs(e)};ms(t,Vt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function Kp(e,t){const n={type:Oe.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Fs(e)};ms(t,Vt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function Yp(e,t){t.stitches=!0;const n=Jp(e);if("children"in e&&"children"in n){const i=Lo({type:"root",children:e.children},t.options);n.children=i.children}Do({type:"comment",value:{stitch:n}},t)}function Do(e,t){const n=e.value,i={type:Oe.COMMENT,data:n,location:Fs(e)};ms(t,Vt(e)),t.parser.currentToken=i,t.parser._processToken(t.parser.currentToken)}function Gp(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,Po(t,Vt(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(Hp,"&lt;$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 Vp(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))Yp(n,t);else{let i="";throw Up.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 ms(e,t){Po(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 Po(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 zp(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===Ye.PLAINTEXT)return;ms(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=nd({...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 Qp(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&dd.includes(n)||t.parser.tokenizer.state===Ye.PLAINTEXT)return;ms(t,Nr(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 Xp(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=Nr(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 Jp(e){return"children"in e?Ka({...e,children:[]}):Ka(e)}function Zp(e){return function(t,n){return Lo(t,{...e,file:n})}}const yn=c.memo(function({text:t}){const n=Re(),[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(St,{})}):null});function eh(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(m=>[c.createElement(a.type,l,...m)])}return[[i]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function Ta(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Ta).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return Ta(t?.children)}return""}function th(e){const t=Array.isArray(e)?e[0]:e;return!t||typeof t!="object"||!("props"in t)?null:t}function sh(e){const n=th(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 Ui="pi-web-ui:plugin-data";let Is=new Map,js=new Map,is=new Set,xa=-1,Oo=0;const ya=new Set;function nh(){Oo++;for(const e of ya)e()}function ah(e){return ya.add(e),()=>{ya.delete(e)}}function $i(){return Oo}let Mo=null;function ih(e){Mo=e}function rh(e,t){t!==xa&&(xa=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,nh()}}async function oh(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=${xa}`))).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=>{Mo?.({type:"plugin_message",pluginId:i.pluginId,payload:o})},onData:o=>{const l=u=>{const m=u.detail;m.pluginId===i.pluginId&&o(m.payload)};return window.addEventListener(Ui,l),()=>window.removeEventListener(Ui,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 lh(e){return Is.has(e)}const Na="pi-web-ui:theme",Bo="dark",qi="theme-stylesheet",Mt="pi-web-ui:theme-change";function Fo(){try{const e=localStorage.getItem(Na);if(e&&e!==Bo)return e}catch{}return null}function ch(e){try{e?localStorage.setItem(Na,e):localStorage.removeItem(Na)}catch{}}function Ho(e){let t=document.getElementById(qi);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Mt));return}t||(t=document.createElement("link"),t.id=qi,t.rel="stylesheet",document.head.appendChild(t)),t.href=tt(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Mt))}async function uh(){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 dh(){const[e,t]=c.useState([]),[n,i]=c.useState(()=>Fo());return c.useEffect(()=>{let o=!1;return uh().then(l=>{o||t(l)}),()=>{o=!0}},[]),c.useEffect(()=>{Ho(n),ch(n)},[n]),{themes:e,theme:n,switchTheme:o=>i(o===Bo?null:o)}}function dg(){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 mh({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 m=()=>{const T=++a.current,h=i.current;h&&(h.dispatchEvent(new CustomEvent(Mt)),o.current.set(h,T))};return window.addEventListener(Mt,m),()=>window.removeEventListener(Mt,m)},[]),c.useEffect(()=>{let m=!1;const T=a.current;return u(null),oh(e,t).then(h=>{m||(h&&o.current.set(h,T),u(h))}),()=>{m=!0}},[e,t]),c.useEffect(()=>{i.current=l;const m=n.current;return m&&(m.replaceChildren(),l&&(m.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(yn,{text:t}),s.jsx("pre",{children:s.jsx("code",{children:t})})]})}const ph=[kr,vr],hh=[kr,zu,vr],Wi=[[Yl,{strict:!1,throwOnError:!1}],[Gl,{detect:!0,ignoreMissing:!0}]];function Ba({text:e,rawHtml:t=!1,hardBreaks:n=!1}){const i=t?[Zp,...Wi]:Wi;return s.jsx(Kl,{remarkPlugins:n?hh:ph,rehypePlugins:i,components:{pre:fh},children:e})}const rt=c.memo(function({text:t,rawHtml:n=!1,hardBreaks:i=!1}){return s.jsx("div",{className:"md",children:s.jsx(Ba,{text:t,rawHtml:n,hardBreaks:i})})});function fh({children:e,...t}){c.useSyncExternalStore(ah,$i,$i);const n=sh(e);return n&&lh(n)?s.jsx(mh,{lang:n,code:Ta(e)}):s.jsx(gh,{children:e,...t})}function gh({children:e,...t}){const n=e&&typeof e=="object"&&"props"in e?e.props?.children:e,i=eh(n),a=i.length>1,o=a?`${String(i.length).length+1}ch`:void 0;return s.jsxs("div",{className:"codeblock",children:[s.jsx(yn,{text:ka(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 ka(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(ka).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return ka(t?.children)}return""}const bh=/^\s{0,3}(`{3,}|~{3,})/,Eh=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Qn(e){return e.trim()===""}function Ki(e){const t=bh.exec(e);return t?t[1]:null}function Th(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 m=Ki(l);m&&m[0]===a[0]&&m.length>=a.length&&(a=null),i.push(l);continue}const u=Ki(l);if(u&&!Qn(l)){a=u,i.push(l);continue}if(Qn(l)){let m=o;for(;m<t.length&&Qn(t[m]);)m++;if(!(m<t.length&&Eh.test(t[m]))&&i.length>0){n.push(i.join(`
311
311
  `)),i=[];continue}i.push(l);continue}i.push(l)}return{frozen:n,active:i.join(`
312
- `),inFence:a!==null}}const mh=c.memo(function({text:t}){return s.jsx(Pa,{text:t})}),$i=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>=$i){u();return}return o.current=setTimeout(u,$i-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(Pa,{text:n})}const hh=c.memo(function({text:t}){const{frozen:n,active:i,inFence:a}=c.useMemo(()=>dh(t),[t]);return s.jsxs("div",{className:"md",children:[n.map((o,l)=>s.jsx(mh,{text:o},l)),i.length>0&&s.jsx(ph,{text:i,inFence:a},n.length)]})});function fh({thinking:e,streaming:t,wrap:n=!0,forceOpen:i=!1}){const a=Pe(),[o,l]=c.useState(null),u=o??n,m=u||i,E=t?e.trimEnd().slice(-80):e.split(`
313
- `)[0].slice(0,80),[h,g]=c.useState(!1),w=()=>{navigator.clipboard.writeText(e),g(!0),window.setTimeout(()=>g(!1),1200)};return s.jsxs("div",{className:`thinking ${m?"open":""} ${t?"live":""}`,children:[s.jsxs("div",{className:"chead thinking-head",role:"button",tabIndex:0,"aria-expanded":m,title:a(m?"collapseMsg":"expandMsg"),onClick:()=>l(!u),onKeyDown:k=>{k.target===k.currentTarget&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),l(!u))},children:[s.jsx("button",{type:"button",className:"chead-toggle thinking-toggle",title:a(m?"collapseMsg":"expandMsg"),"aria-label":a(m?"collapseMsg":"expandMsg"),"aria-expanded":m,onClick:k=>{k.stopPropagation(),l(!u)},children:m?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&&m?s.jsxs("span",{className:"thinking-live-label",children:[a("thinkingNow"),s.jsx("span",{className:"dots"})]}):m?a("thinking"):a("thinkingPreview",{preview:E})}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy thinking-copy",title:a(h?"copied":"copyMessage"),"aria-label":a("copyMessage"),onClick:k=>{k.stopPropagation(),w()},children:h?s.jsx(cs,{}):s.jsx(St,{})})]}),m&&s.jsx("div",{className:"thinking-body",children:e})]})}const Nn=256*1024,kn=300,gh=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,bh=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,Eh=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,Th=1e9;function xh(e){if(!e)return{};const t=e.length>Nn?e.slice(0,Nn):e;return{path:Ch(t),timeout:_h(t),command:Sh(e),agent:yh(t)}}function yh(e){const t=bh.exec(e);if(!t)return;const n=t[1].replace(/[\u0000-\u001f\u007f]/g,"").trim();if(n)return n.length>kn?`${n.slice(0,kn)}…`:n}const Nh=["task","expected_outcome","required_tools","must_do","must_not_do","context"];function kh(e){if(!e||e.length>Nn)return{};try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n=t,i={};for(const a of[...Nh,"agent","model"])typeof n[a]=="string"&&n[a].trim()&&(i[a]=n[a]);return i}catch{return{}}}function vh(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 Ch(e){const t=gh.exec(e);if(!t)return;const i=wh(t[2]).replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim();if(i)return i.length>kn?`${i.slice(0,kn-1)}…`:i}function _h(e){const t=Eh.exec(e);if(!t)return;const n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>Th)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 Sh(e){if(!(e.length>Nn))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 wh(e){try{const t=JSON.parse(`"${e}"`);return typeof t=="string"?t:e}catch{return e}}const Ah={bash:"$",delegate_task:"◈",read:"📄",write:"✍️",edit:"✏️",edit_soft:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function Ih(e){return Ah[e]??"🛠"}const jh=c.memo(function({block:t,view:n,onKillBash:i,wrap:a=!0,forceOpen:o=!1}){const l=Pe(),[u,m]=c.useState(null),E=u??a,h=E||o,[g,w]=c.useState(!1),k=!n.result&&n.streaming&&!n.status,_=t.name==="bash"&&k,M=n.result!==void 0,$=!n.result&&!!n.status,S=n.result?.isError??n.status?.isError??!1,I=n.result?n.result.content.map(U=>U.type==="text"?U.text:"").join(""):n.liveOutput??"",j=I.replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(U,C)=>l("liveOutputOmitted",{n:C})),H=t.name==="delegate_task",ee=H?kh(t.argumentsText):{},J=H&&n.result&&typeof n.result.details=="object"&&n.result.details!==null?n.result.details.convId:void 0,ue=typeof J=="string"&&J?J:/sa-[0-9a-f]{8}/.exec(I)?.[0],pe=S?"err":M?"ok":k||$?"run":"idle";let G=l(S?"error":M?"done":k?"running":$?"toolDoneWaitingModel":"toolQueued");const Y=$&&n.status?.durationMs!==void 0?Ph(n.status.durationMs):"";$&&Y&&(G=`${G} · ${Y}`);const ge=$&&n.status?.exitCode!==void 0?`exit ${n.status.exitCode}`:"",O=xh(t.argumentsText),R=t.name==="bash"?O.command:void 0,x=!h&&R?Dh(R):void 0,D=()=>{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":h,title:l(h?"collapseMsg":"expandMsg"),onClick:()=>m(!E),onKeyDown:U=>{U.target===U.currentTarget&&(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),m(!E))},children:[s.jsx("button",{type:"button",className:"chead-toggle toolcall-toggle",title:l(h?"collapseMsg":"expandMsg"),"aria-label":l(h?"collapseMsg":"expandMsg"),"aria-expanded":h,onClick:U=>{U.stopPropagation(),m(!E)},children:h?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon toolcall-icon",children:Ih(t.name)}),s.jsx("span",{className:"chead-title toolcall-name",children:t.name}),s.jsx("span",{className:"toolcall-status",title:ge?`${G} · ${ge}`:G,"aria-label":ge?`${G} · ${ge}`:G,children:S?s.jsx(Ke,{}):M?s.jsx(Tt,{}):k?s.jsx(mc,{}):$?s.jsx(na,{}):s.jsx(rc,{})}),x&&s.jsxs("span",{className:"toolcall-cmd",title:R,children:["$ ",x]}),O.path&&s.jsx("span",{className:"toolcall-path",title:O.path,children:vh(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"}),_&&i&&s.jsxs("button",{type:"button",className:"toolcall-kill",title:l("stopBashTip"),onClick:U=>{U.stopPropagation(),i?.()},children:[s.jsx(cn,{}),s.jsx("span",{children:l("stopBash")})]}),H&&M&&ue&&s.jsxs("button",{type:"button",className:"toolcall-open",title:l("delegateOpenSubagent"),onClick:U=>{U.stopPropagation(),window.dispatchEvent(new CustomEvent("pi-web-ui:switch-conversation",{detail:ue}))},children:[s.jsx(yc,{}),s.jsx("span",{children:l("delegateOpenSubagent")})]}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy",title:l("copyArgs"),onClick:U=>{U.stopPropagation(),D()},children:g?s.jsx(cs,{}):s.jsx(St,{})})]}),h&&s.jsxs("div",{className:"toolcall-body",children:[H?s.jsx(Rh,{args:ee}):t.argumentsText&&s.jsx("div",{className:"toolcall-args",children:R?s.jsx(Lh,{command:R}):s.jsx("pre",{children:t.argumentsText})}),j.length>0&&s.jsxs("div",{className:"toolcall-output",children:[s.jsxs("div",{className:"toolcall-output-label",children:[l(S?"errorOutput":"output"),(k||$)&&s.jsx("span",{className:"cursor"})]}),s.jsx("pre",{children:j})]}),k&&j.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",l("waitingOutput")]}),$&&j.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",l("waitingModel")]})]})]})});function Lh({command:e}){return s.jsxs("div",{className:"termline",children:[s.jsx(An,{className:"termline-icon"}),s.jsx("code",{children:e})]})}function Rh({args:e}){const t=Pe(),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 Dh(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 Ph(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 Oh=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function Oa(e){const t=e.match(Oh);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}const Mh=1568,Bh=2*1024*1024;function _t(e){return e.startsWith("image/")&&e!=="image/svg+xml"&&e!=="image/svg"}async function Ma(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,Mh/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,m]of o){const E=document.createElement("canvas");E.width=i,E.height=a;const h=E.getContext("2d");if(!h)continue;u!=="image/png"&&(h.fillStyle="#ffffff",h.fillRect(0,0,i,a)),h.drawImage(t,0,0,i,a);const g=E.toDataURL(u,m),w=g.match(/^data:([^;]+);base64,/),k=w?w[1]:u,_=g.replace(/^data:[^;]*;base64,/,""),M=Math.floor(_.length*3/4);if(l={data:_,mimeType:k,name:e.name,size:M},M<=Bh)return l}return l}finally{t.close()}}const Fh=20*1024*1024;function ls(e){return e.type==="text"&&typeof e.text=="string"?e:null}function Ro(e){return e.type==="thinking"&&typeof e.thinking=="string"?e:null}function Do(e){return e.type==="toolCall"&&typeof e.id=="string"&&typeof e.name=="string"?e:null}function Po(e){return e.type==="image"&&typeof e.dataUrl=="string"?e:null}function Oo(e){return e.type==="bash"&&typeof e.command=="string"?e:null}function Hh(e){return e.imageData?"image":e.uploadPath?"upload":e.fileData?"file":"path"}function Uh(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==="reference"?t("refOnly",{path:n}):t("attachContent",{path:n})}const Wi=c.memo(function({message:t,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onEdit:u,onKillBash:m,onRetry:E,onCollapse:h,questionAttachments:g,qnIndex:w,qnActive:k,onJump:_,thinkingWrap:M,toolsWrap:$,searchActive:S,autoExpand:I}){const j=Pe(),[H,ee]=c.useState(!1),[J,ue]=c.useState(""),[pe,G]=c.useState([]),[Y,ge]=c.useState(!1),[O,R]=c.useState(null),x=W=>{R(W),window.setTimeout(()=>R(ce=>ce===W?null:ce),4e3)};if(t.role==="toolResult")return null;if(t.role==="compactionSummary")return s.jsx(Wh,{message:t,forceOpen:S,autoExpand:I});const D=t.role==="custom"&&t.customType==="file",U=t.content.map(W=>ls(W)?.text??"").filter(Boolean).join(`
315
- `),C=t.role==="user"?Oa(U):null,Z=C?C.userMessage??`skill:${C.name}`:U.split(`
316
- `).join(" ").trim(),X=o&&l&&t.content.length===0,ve=t.role==="user"&&!o&&!X&&!!u,N=async W=>{const ce=[];for(const F of W){if(!_t(F.type))continue;const Le=await Ma(F);Le&&ce.push({path:"",imageData:Le.data,mimeType:Le.mimeType,name:Le.name})}ce.length>0&&G(F=>[...F,...ce])},z=async W=>{if(W.size>Fh){x(j("fileTooLarge",{name:W.name,size:20}));return}let ce;try{ce=(await new Promise((Le,Oe)=>{const P=new FileReader;P.onload=()=>Le(P.result),P.onerror=()=>Oe(P.error??new Error("read failed")),P.readAsDataURL(W)})).replace(/^data:[^;]*;base64,/,"")}catch{x(j("fileLoadFailed",{name:W.name}));return}G(F=>[...F,{path:"",fileData:ce,name:W.name,size:W.size,mimeType:W.type||void 0}])},de=async W=>{const ce=[];for(const F of W)_t(F.type)?ce.push(F):z(F);ce.length>0&&await N(ce)},re=()=>{ue(C?`/skill:${C.name}${C.userMessage?` ${C.userMessage}`:""}`:t.content.map(W=>ls(W)?.text??"").filter(Boolean).join(`
317
- `)),G(g??[]),ee(!0)},ke=()=>{const W=J.trim();W&&(u?.(t.id,W,pe.length>0?pe:void 0),ee(!1))},oe=t.role==="custom"&&(t.customType==="goal-review"||t.customType==="goal-wizard"),he=t.role==="custom"&&t.customType==="goal-wizard";return s.jsxs("div",{className:`msg msg-${t.role}${oe?" 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"?he?j("goalWizardCard"):oe?j("goalBarTitle"):t.customType==="file"?j("attachment"):`${j("plugin")} · ${t.customType??j("unknown")}`:Mo(t.role,j)}),t.model&&s.jsx("span",{className:"msg-model",children:t.model}),t.timestamp&&s.jsx("span",{className:"msg-time",children:Bo(t.timestamp)}),h&&s.jsxs("button",{type:"button",className:"msg-collapse-btn",title:j("collapseMsg"),onClick:()=>h(t.id),children:[s.jsx(In,{})," ",j("collapseMsg")]}),w!==void 0&&_&&s.jsxs("button",{type:"button",className:`qn-tag ${k?"active":""}`,title:`${w+1}. ${Z}`,"aria-label":`${w+1}. ${Z}`,onClick:()=>_(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${Y?" drag-over":""}`,onDragOver:W=>{W.preventDefault(),W.stopPropagation(),ge(!0)},onDragLeave:W=>{W.currentTarget.contains(W.relatedTarget)||ge(!1)},onDrop:W=>{W.preventDefault(),W.stopPropagation(),ge(!1),de(Array.from(W.dataTransfer?.files??[]))},children:[pe.length>0&&s.jsx("div",{className:"msg-editor-images",children:pe.map((W,ce)=>{const F=Hh(W);return s.jsxs("span",{className:`msg-editor-img ${F==="image"?"":"file-chip"}`,title:Uh(W,j),children:[F==="image"?s.jsx("img",{src:`data:${W.mimeType??"image/png"};base64,${W.imageData}`,alt:W.name}):s.jsxs("span",{className:"msg-editor-file",children:[s.jsx("span",{className:"msg-editor-file-icon",children:F==="path"?W.mode==="reference"?"🔗":"📎":"📄"}),s.jsx("span",{className:"msg-editor-file-name",children:W.name??W.path?.split("/").pop()})]}),s.jsx("button",{type:"button",className:"msg-editor-img-remove",title:j("removeAttachment"),onClick:()=>G(Le=>Le.filter((Oe,P)=>P!==ce)),children:s.jsx(Ke,{})})]},`${W.name??W.path??"att"}-${ce}`)})}),O&&s.jsx("div",{className:"msg-editor-notice",children:O}),s.jsx("textarea",{className:"msg-editor-input",value:J,autoFocus:!0,placeholder:j("editPlaceholder"),rows:Math.max(2,Math.min(10,J.split(`
318
- `).length+1)),onChange:W=>ue(W.target.value),onPaste:W=>{const ce=[];for(const F of W.clipboardData?.items??[])if(F.kind==="file"&&_t(F.type)){const Le=F.getAsFile();Le&&ce.push(Le)}ce.length!==0&&(W.preventDefault(),N(ce))},onKeyDown:W=>{W.key==="Enter"&&(W.metaKey||W.ctrlKey)?(W.preventDefault(),ke()):W.key==="Escape"&&ee(!1)}}),s.jsxs("div",{className:"msg-editor-actions",children:[s.jsxs("span",{className:"msg-editor-hint",children:[s.jsx(fc,{})," ",j("editAttachmentHint")]}),s.jsx("button",{type:"button",className:"chip",onClick:()=>ee(!1),children:j("cancel")}),s.jsxs("button",{type:"button",className:"chip primary",disabled:!J.trim(),title:j("reaskFromHere"),onClick:ke,children:[s.jsx(hn,{})," ",j("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:j("retryLastTip"),onClick:E,children:[s.jsx(kt,{})," ",j("retryNow")]})]}),D?s.jsx(qh,{message:t,forceOpen:S}):C?s.jsxs(s.Fragment,{children:[s.jsx(Kh,{block:C,forceOpen:S}),C.userMessage&&s.jsx("div",{className:"msg-text",children:s.jsx(rt,{text:C.userMessage,hardBreaks:!0})}),t.content.map((W,ce)=>W.type==="text"?null:s.jsx(Yi,{block:W,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onKillBash:m,toolsWrap:$,thinkingWrap:M,searchActive:S,role:t.role},`${t.id}-${ce}`))]}):t.content.map((W,ce)=>s.jsx(Yi,{block:W,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onKillBash:m,toolsWrap:$,thinkingWrap:M,searchActive:S,role:t.role},`${t.id}-${ce}`)),X&&s.jsxs("div",{className:"thinking-wait",children:[j("thinkingWait"),s.jsx("span",{className:"dot"})]}),o&&l&&!X&&s.jsx("span",{className:"stream-cursor"})]})}),ve&&!H&&s.jsx("div",{className:"msg-actions",children:s.jsxs("button",{type:"button",className:"msg-action",title:j("editReaskTip"),onClick:re,children:[s.jsx(hn,{})," ",j("editReask")]})})]})});function qh({message:e,forceOpen:t=!1}){const n=Pe(),[i,a]=c.useState(!1),[o,l]=c.useState(!1),u=i||t,m=e.details??{},E=m.name??m.path??n("attachment"),h=m.type==="folder",g=m.mode==="reference",w=m.mode==="bridged",k=e.content.filter(I=>I.type==="text").map(I=>I.text).join(`
319
- `),_=$h(k),M=e.content.find(I=>I.type==="image"),$=_.split(`
320
- `).length,S=!g&&_.length>0;return s.jsxs("div",{className:`attachcard ${g?"reference":""}`,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(j=>t?!0:!j))},children:[!g&&s.jsx("span",{className:"chead-toggle",children:u?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon attachcard-icon",children:h?"📁":"📎"}),s.jsx("span",{className:"chead-title attachcard-name",children:E}),m.path&&s.jsx("span",{className:"attachcard-path",children:m.path}),s.jsx("span",{className:`attachcard-mode ${m.mode==="lines"?"lines":g?"ref":w?"bridged":"inline"}`,children:g?h?n("folderRefShort"):`${n("refOnlyShort")} · ${Ki(m.size)}`:w?n("bridgedVision"):M?n("image"):m.mode==="lines"?n("inlineLinesRange",{start:m.startLine??1,end:m.endLine??m.lines??1}):n("inlineLines",{n:m.lines??$})}),S&&s.jsx("button",{type:"button",className:"chead-copy",title:n(o?"copied":"copyMessage"),"aria-label":n("copyMessage"),onClick:I=>{I.stopPropagation(),navigator.clipboard.writeText(_),l(!0),window.setTimeout(()=>l(!1),1200)},children:o?s.jsx(cs,{}):s.jsx(St,{})})]}),!g&&u&&(w?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"attachcard-bridgenote",children:n("bridgedVisionDetail")}),M?.dataUrl&&s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:M.dataUrl,alt:E})}),_&&s.jsx("pre",{className:"attachcard-content",children:_})]}):M?.dataUrl?s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:M.dataUrl,alt:E})}):s.jsx("pre",{className:"attachcard-content",children:_})),g&&s.jsx("div",{className:"attachcard-refnote",children:h?n("folderNotExpanded"):n("fileNotExpanded",{size:Ki(m.size)})})]})}function Ki(e){return e===void 0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function $h(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 Wh({message:e,forceOpen:t=!1,autoExpand:n=!1}){const i=Pe(),[a,o]=c.useState(!1),[l,u]=c.useState(!1),[m,E]=c.useState(n);n!==m&&(E(n),n&&o(!0));const h=a||t,g=e.content.map(k=>ls(k)?.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:Bo(e.timestamp)})]}),s.jsxs("div",{className:`compaction-card${a?" expanded":""}`,children:[s.jsxs("div",{className:"chead compaction-head",role:"button",tabIndex:0,"aria-expanded":h,title:i(h?"collapseMsg":"expandMsg"),onClick:()=>o(k=>t?!0:!k),onKeyDown:k=>{k.target===k.currentTarget&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o(_=>t?!0:!_))},children:[s.jsx("span",{className:"chead-toggle",children:h?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon compaction-icon",children:s.jsx(wr,{})}),s.jsx("span",{className:"chead-title compaction-title",children:w?i("compactionFrom",{tokens:w}):i("role.compaction")}),g&&s.jsx("button",{type:"button",className:"chead-copy",title:i(l?"copied":"copyMessage"),"aria-label":i("copyMessage"),onClick:k=>{k.stopPropagation(),navigator.clipboard.writeText(g),u(!0),window.setTimeout(()=>u(!1),1200)},children:l?s.jsx(cs,{}):s.jsx(St,{})})]}),h&&s.jsxs("div",{className:"compaction-body",children:[s.jsx(rt,{text:g}),s.jsx("div",{className:"compaction-hint",children:i("compactionKeptHint")})]})]})]})}function Kh({block:e,forceOpen:t=!1}){const n=Pe(),[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(m=>t?!0:!m),onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.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(Tc,{})}),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:m=>{m.stopPropagation(),navigator.clipboard.writeText(e.content),l(!0),window.setTimeout(()=>l(!1),1200)},children:o?s.jsx(cs,{}):s.jsx(St,{})})]}),u&&s.jsx("div",{className:"skillcard-body",children:s.jsx(rt,{text:e.content})})]})}function Yi({block:e,toolResults:t,liveOutputs:n,toolStatuses:i,streaming:a,isLast:o,onKillBash:l,thinkingWrap:u,toolsWrap:m,searchActive:E,role:h}){const g=Pe(),[w,k]=c.useState(!1),_=ls(e);if(_){const j=a&&o,H=h==="assistant"||h==="user",ee=H&&!_.text.includes(`
322
- `)&&!_.truncated,J=h==="user"?s.jsx(rt,{text:_.text,hardBreaks:!0}):j?s.jsx(hh,{text:_.text}):s.jsx(rt,{text:_.text});return s.jsxs("div",{className:`msg-text${ee?" single":""}`,children:[ee?s.jsx("div",{className:"msg-text-main",children:J}):s.jsxs(s.Fragment,{children:[J,_.truncated&&s.jsx("div",{className:"trunc-note",children:g("truncated")})]}),H?s.jsx("button",{type:"button",className:"msg-text-copy",title:g(w?"copied":"copyMessage"),"aria-label":g("copyMessage"),onClick:()=>{navigator.clipboard.writeText(_.text),k(!0),window.setTimeout(()=>k(!1),1200)},children:w?s.jsx(cs,{}):s.jsx(St,{})}):null]})}const M=Ro(e);if(M)return s.jsx(fh,{thinking:M.thinking,streaming:a&&o,wrap:u,forceOpen:E});const $=Do(e);if($){const j=t.get($.id),H=n.get($.id),ee={result:j,liveOutput:H?.text,streaming:a,status:i.get($.id)};return s.jsx(jh,{block:$,view:ee,onKillBash:l,wrap:m,forceOpen:E})}const S=Po(e);if(S&&S.dataUrl)return s.jsx("div",{className:"msg-image",children:s.jsx("img",{src:S.dataUrl,alt:"attachment"})});const I=Oo(e);return I?s.jsxs("div",{className:"bashblock",children:[s.jsxs("div",{className:"bashblock-command",children:[s.jsx("span",{className:"bashblock-prompt",children:"$"}),s.jsx("code",{children:I.command}),I.exitCode!==void 0&&s.jsx("span",{className:`bashblock-exit ${I.exitCode===0?"ok":"err"}`,children:g("exitCode",{code:I.exitCode})}),I.cancelled&&s.jsx("span",{className:"bashblock-exit err",children:g("cancelled")})]}),I.output&&s.jsx("pre",{className:"bashblock-output",children:I.output}),I.truncated&&s.jsx("div",{className:"trunc-note",children:g("outputTruncated")})]}):null}function Mo(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 Bo(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`${n}:${i}`}function Gi(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 Yh(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=[];Gi(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(!Gi(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.path&&l.mode){const u=l.mode==="inline"||l.mode==="lines"?l.mode:"reference",m={path:l.path,mode:u};l.mode==="lines"&&typeof l.startLine=="number"&&typeof l.endLine=="number"&&(m.lines={start:l.startLine,end:l.endLine}),a.push(m)}}}a.length>0&&t.set(i.id,a)}return t}const Gh=c.memo(function({message:t,onExpand:n}){const i=Pe();let a="";for(const g of t.content){const w=ls(g);if(w&&w.text.trim()){const k=Oa(w.text);k?a=`skill:${k.name}`+(k.userMessage?` · ${k.userMessage.replace(/\s+/g," ").trim()}`:""):a=w.text.replace(/\s+/g," ").trim();break}}if(!a&&t.role==="custom"&&t.customType==="file"){const g=t.details??{};a=g.name??g.path??""}a.length>90&&(a=`${a.slice(0,90)}…`);let l=0,u=0,m=0,E=0;for(const g of t.content)Ro(g)?l++:Do(g)?u++:Oo(g)?m++:Po(g)&&E++;const h=[];return l&&h.push(`${i("thinking")} ${l}`),u&&h.push(`${i("toolCalls")} ${u}`),m&&h.push(`${i("bashRuns")} ${m}`),E&&h.push(`${i("images")} ${E}`),s.jsxs("div",{role:"button",tabIndex:0,className:"msg-collapsed","data-msg-id":t.id,title:`${i("expandMsg")} · ${a||h.join(" · ")||t.role}`,onClick:()=>n(t.id),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),n(t.id))},children:[s.jsx("span",{className:`msg-collapsed-role role-${t.role}`,children:t.role==="custom"&&t.customType==="file"?i("attachment"):Mo(t.role,i)}),s.jsxs("span",{className:"msg-collapsed-body",children:[a&&s.jsx("span",{className:"msg-collapsed-preview",children:a}),h.length>0&&s.jsx("span",{className:"msg-collapsed-chips",children:h.map((g,w)=>s.jsx("span",{className:"msg-collapsed-chip",children:g},w))})]}),t.timestamp?s.jsx("span",{className:"msg-collapsed-time",children:Vh(t.timestamp)}):null,s.jsxs("span",{className:"msg-collapsed-action",children:[s.jsx(zt,{})," ",i("expandMsg")]})]})});function Vh(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`${n}:${i}`}const zh=c.memo(function({id:t,show:n,height:i,containerRef:a,onMeasured:o,lazyRef:l,children:u}){const m=c.useRef(null),E=c.useRef(null);return c.useLayoutEffect(()=>{const h=E.current;if(E.current=n,!n||h!==!1)return;const g=m.current,w=a.current;if(!g||!w)return;const k=g.offsetHeight;o?.(t,k);const _=k-i;if(_!==0){const M=g.parentElement;M&&M.getBoundingClientRect().bottom<=w.getBoundingClientRect().top&&(w.scrollTop+=_)}},[n]),n?s.jsx("div",{ref:l,"data-lazy-id":t,children:s.jsx("div",{ref:m,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 Qh(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 Xh(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 Jh(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)??Fo(l.role,l.customType)}return i}function Fo(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 Zh=["text","thinking","argumentsText","output","command"];function ef(e){let t=0;for(const n of e.content){n.type==="image"&&(t+=1);for(const i of Zh){const a=n[i];typeof a=="string"&&(t+=a.length)}}return t}function tf(e,t,n,i){const a=n.get(e);return a&&a.len===t?a.h:i}function sf(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 nf(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=sf(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 af(e,t){let n=0,i=e.indexOf(t);for(;i!==-1;)n++,i=e.indexOf(t,i+t.length);return n}function rf(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=af(nf(l,i).toLowerCase(),o);u>0&&a.set(l.id,u)}return a}function of(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 m=document.createRange();m.setStart(o,u),m.setEnd(o,u+i.length),n.push(m),u=l.indexOf(i,u+i.length)}}return n}function lf(e,t,n,i,a){const o=rf(n,i,t,a),l=new Map;for(const m of of(e,t)){const E=m.startContainer.parentElement?.closest("[data-msg-id]");if(!E?.dataset.msgId)continue;const h=l.get(E.dataset.msgId);h?h.push(m):l.set(E.dataset.msgId,[m])}const u=[];for(const m of n){const E=l.get(m.id);if(E)for(let g=0;g<E.length;g++)u.push({kind:"dom",range:E[g],msgId:m.id,k:g});const h=o.get(m.id);if(h)for(let g=0;g<h;g++)u.push({kind:"folded",msgId:m.id,k:g})}return u}function zn(e,t){return e.findIndex(n=>n.msgId===t.msgId&&n.k===t.k)}function pt(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 cf(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 uf(e,t){const n=t.startContainer.parentElement;for(const u of cf(n,e)){const m=t.getBoundingClientRect(),E=u.getBoundingClientRect();if(m.height<=0||m.width<=0)return;m.top>=E.top+4&&m.bottom<=E.bottom-4||(u.scrollTop+=m.top-E.top-(u.clientHeight-m.height)/2),m.left>=E.left+4&&m.right<=E.right-4||(u.scrollLeft+=m.left-E.left-(u.clientWidth-m.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 df({containerRef:e,messages:t,collapsedIds:n,toolResults:i,onExpand:a,onProgrammaticScroll:o,open:l,onClose:u}){const m=Pe(),E=c.useRef(null),[h,g]=c.useState(""),[w,k]=c.useState(null),[_,M]=c.useState(0),[,$]=c.useState(0),S=c.useDeferredValue(h),I=l?S.trim():"",j=c.useRef(null);j.current=w;const H=c.useRef([]),ee=c.useRef({key:null}),J=c.useRef("");c.useEffect(()=>{l&&(k(null),requestAnimationFrame(()=>E.current?.select()))},[l]),c.useEffect(()=>{if(!l)return;const G=Y=>{Y.key==="Escape"&&(Y.preventDefault(),Y.stopPropagation(),u())};return window.addEventListener("keydown",G,!0),()=>window.removeEventListener("keydown",G,!0)},[l,u]),c.useEffect(()=>(l||(pt("msg-search",[]),pt("msg-search-active",[])),()=>{pt("msg-search",[]),pt("msg-search-active",[])}),[l]),c.useLayoutEffect(()=>{const G=()=>{M(0),k(null),$(0),H.current=[],pt("msg-search",[]),pt("msg-search-active",[]),ee.current={key:null},J.current=""};if(!l||!I){G();return}const Y=e.current;if(!Y)return;let ge=!1,O=0;return O=requestAnimationFrame(()=>{if(ge)return;const R=lf(Y,I,t,n,i);H.current=R;const x=R.length;if(M(x),x===0){k(null),$(0),pt("msg-search",[]),pt("msg-search-active",[]),ee.current={key:null},J.current=I;return}const D=j.current;let U;if(D){if(U=zn(R,D),U===-1){const N=[];for(let z=0;z<R.length;z++)R[z].msgId===D.msgId&&N.push(z);if(N.length>0){const z=Math.min(D.k,N.length-1);U=N[z]}else U=0}}else U=0;U<0&&(U=0),U>=x&&(U=x-1),(!D||D.msgId!==R[U].msgId||D.k!==R[U].k)&&k({msgId:R[U].msgId,k:R[U].k}),$(U);const C=R[U],Z=ee.current,X=Z.key?.msgId!==C.msgId||Z.key?.k!==C.k||Z.kind==="folded"&&C.kind==="dom"||I!==J.current;ee.current={key:{msgId:C.msgId,k:C.k},kind:C.kind},J.current=I;const ve=R.filter(N=>N.kind==="dom").map(N=>N.range);if(pt("msg-search",ve),C.kind==="folded"){pt("msg-search-active",[]),X&&a(C.msgId);return}pt("msg-search-active",[C.range]),X&&(o?.(),uf(Y,C.range))}),()=>{ge=!0,cancelAnimationFrame(O)}},[l,I,t,e,w,n,i,a,o]);const ue=c.useCallback(G=>{const Y=H.current,ge=Y.length;if(ge===0)return;const O=j.current,R=O?zn(Y,O):0,x=Y[(R+G+ge)%ge];k(x.kind==="dom"||x.kind==="folded"?{msgId:x.msgId,k:x.k}:null)},[]);if(!l)return null;const pe=w?(()=>{const G=zn(H.current,w);return G===-1?0:G})():0;return s.jsxs("div",{className:"search-bar",role:"search",children:[s.jsx("input",{ref:E,className:"search-input",type:"text",value:h,placeholder:m("searchPlaceholder"),onChange:G=>{g(G.target.value)},onKeyDown:G=>{G.key==="Enter"&&(G.preventDefault(),ue(G.shiftKey?-1:1))}}),s.jsx("span",{className:`search-count ${_===0?"empty":""}`,children:_===0?m("searchNoResults"):`${Math.min(pe+1,_)}/${_}`}),s.jsx("button",{type:"button",className:"search-btn",title:m("searchPrev"),disabled:_===0,onClick:()=>ue(-1),children:s.jsx(In,{})}),s.jsx("button",{type:"button",className:"search-btn",title:m("searchNext"),disabled:_===0,onClick:()=>ue(1),children:s.jsx(Ft,{})}),s.jsx("button",{type:"button",className:"search-btn",title:m("searchClose"),onClick:u,children:s.jsx(Ke,{})})]})}function mf(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 Ho="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 hf(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function ff(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 Uo(){try{const e=localStorage.getItem(Ho);return e?pf(JSON.parse(e)):{}}catch{return{}}}function gf(e){try{localStorage.setItem(Ho,JSON.stringify(e))}catch{}}function vn(e){const t=hf(Uo(),e);return gf(t),t}const qo=[{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"}],$o="pi-web-ui:prompt-templates";function bf(){try{const e=localStorage.getItem($o);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 Vi(e){return qo.some(t=>t.id===e)}function Gs(e){return typeof e.title=="string"}const Wo=c.createContext(null);function Ko(){const e=c.useContext(Wo);if(!e)throw new Error("useTemplates must be used within TemplateProvider");return e}function Ef({children:e,currentModelId:t}){const n=Pe(),[i,a]=c.useState(bf),[o,l]=c.useState(!1),[u,m]=c.useState(null),[E,h]=c.useState(!1),[g,w]=c.useState(!1),[k,_]=c.useState(!1);c.useEffect(()=>{try{localStorage.setItem($o,JSON.stringify(i))}catch{}},[i]);const M=c.useMemo(()=>{const R=new Map,x=new Set;for(const C of i)C.hidden?x.add(C.id):(Gs(C)&&!Vi(C.id)||Gs(C))&&R.set(C.id,C);const D=qo.filter(C=>!x.has(C.id)).map(C=>{const Z=R.get(C.id);return{id:C.id,icon:Z?.icon??C.icon,title:Z?.title??n(C.titleKey),desc:Z?.desc??n(C.descKey),prompt:Z?.prompt??n(C.promptKey),builtin:!0}}),U=i.filter(C=>Gs(C)&&!Vi(C.id)).map(C=>({id:C.id,icon:C.icon??"📌",title:C.title??"",desc:C.desc??"",prompt:C.prompt??""}));return[...D,...U]},[i,n]),$=c.useCallback(()=>l(!0),[]),S=c.useCallback(R=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:R}))},[]),I=c.useCallback((R,x=!1)=>{_(x),R?(h(!1),m({...R})):(h(!0),m({id:wt(),icon:"📌",title:"",desc:"",prompt:""}))},[]),j=c.useCallback(()=>{l(!1),m(null),_(!1)},[]),H=c.useCallback(()=>{g?(a([]),w(!1)):(w(!0),setTimeout(()=>w(!1),5e3))},[g]),ee=c.useCallback(R=>{l(!1),S(R.prompt)},[S]),J=c.useCallback(R=>{l(!1),I(R,!0)},[I]),ue=c.useCallback(()=>{l(!1),I(void 0,!0)},[I]),pe=c.useCallback(R=>{a(x=>{const D=x.findIndex(U=>U.id===R.id);if(D>=0){const U=[...x];return U[D]=R,U}return[...x,R]}),m(null),k&&(l(!0),_(!1))},[k]),G=c.useCallback(R=>{a(x=>R.builtin?[...x.filter(U=>U.id!==R.id),{id:R.id,hidden:!0}]:x.filter(D=>D.id!==R.id)),m(null),k&&(l(!0),_(!1))},[k]),Y=c.useCallback(R=>{a(x=>x.filter(D=>D.id!==R.id||D.hidden)),m(null),k&&(l(!0),_(!1))},[k]),ge=c.useMemo(()=>({templates:M,fill:S,openPicker:$,openEdit:I,resetConfirm:g,toggleReset:H}),[M,S,$,I,g,H]),O=u?i.some(R=>R.id===u.id&&!R.hidden&&Gs(R)):!1;return s.jsxs(Wo.Provider,{value:ge,children:[e,o&&s.jsx(xf,{templates:M,resetConfirm:g,onFill:ee,onEditTpl:J,onNew:ue,onResetToggle:H,onClose:j}),u&&s.jsx(yf,{editing:u,isNew:E,hasOverride:O,onDraft:m,onSave:pe,onRestore:()=>Y(u),onRemove:()=>G(u),onFill:()=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:u.prompt})),j()},onSend:()=>{const R=u.prompt.trim();R&&ae({type:"prompt",text:R,queue:!1})&&(t&&vn(t),j())},onClose:j})]})}function Tf(){const e=Pe(),{templates:t,fill:n,openEdit:i,toggleReset:a,resetConfirm:o}=Ko();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(Yo,{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(Nr,{}),e(o?"tpl.resetConfirm":"tpl.reset")]})})]})}function Yo({tpl:e,title:t,onFill:n,onEdit:i,editTitle:a}){const o=Pe();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(fn,{})})]})}function xf({templates:e,resetConfirm:t,onFill:n,onEditTpl:i,onNew:a,onResetToggle:o,onClose:l}){const u=Pe();return c.useEffect(()=>{const m=E=>{E.key==="Escape"&&l()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l]),s.jsx("div",{className:"modal-backdrop",onClick:l,children:s.jsxs("div",{className:"modal template-picker",onClick:m=>m.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(m=>s.jsx(Yo,{tpl:m,title:u("tpl.clickCard"),onFill:()=>n(m),onEdit:()=>i(m),editTitle:u("tpl.editTpl")},m.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(Nr,{}),u(t?"tpl.resetConfirm":"tpl.reset")]})})]})})}function yf({editing:e,isNew:t,hasOverride:n,onDraft:i,onSave:a,onRestore:o,onRemove:l,onFill:u,onSend:m,onClose:E}){const h=Pe(),g=c.useRef(null);c.useEffect(()=>{const _=M=>{M.key==="Escape"&&E()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[E]),c.useEffect(()=>{const _=g.current;if(!_)return;_.style.height="auto";const M=_.scrollHeight>300;_.style.height=`${Math.min(_.scrollHeight,300)}px`,_.style.overflowY=M?"auto":"hidden"},[e.prompt]);const w=()=>{const _=e.title.trim(),M=e.prompt.trim();if(!_||!M){i({...e,error:h("tpl.required")});return}a({id:e.id,icon:e.icon.trim()||"📌",title:_,desc:e.desc.trim(),prompt:M})},k=!!e.builtin&&!t;return s.jsx("div",{className:"modal-backdrop",onClick:E,children:s.jsxs("div",{className:"modal template-modal",onClick:_=>_.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:h(k?"tpl.builtin":"tpl.custom")}),s.jsx("span",{className:"template-modal-title",children:h(t?"tpl.newTitle":"tpl.editTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:h("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:h("tpl.fieldIcon")}),s.jsx("input",{className:"template-field-input icon",value:e.icon,maxLength:4,onChange:_=>i({...e,icon:_.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:h("tpl.fieldTitle")}),s.jsx("input",{className:"template-field-input",value:e.title,placeholder:h("tpl.fieldTitlePh"),onChange:_=>i({...e,title:_.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:h("tpl.fieldDesc")}),s.jsx("input",{className:"template-field-input",value:e.desc,placeholder:h("tpl.fieldDescPh"),onChange:_=>i({...e,desc:_.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:h("tpl.fieldPrompt")}),s.jsx("textarea",{ref:g,className:"template-field-prompt",value:e.prompt,placeholder:h("tpl.fieldPromptPh"),onChange:_=>i({...e,prompt:_.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&&k&&n&&s.jsx("button",{type:"button",className:"btn template-btn ghost",title:h("tpl.restoreTip"),onClick:o,children:h("tpl.restore")}),!t&&k&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:h("tpl.removeTip"),onClick:l,children:[s.jsx(et,{})," ",h("tpl.remove")]}),!t&&!k&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:h("tpl.deleteTip"),onClick:l,children:[s.jsx(et,{})," ",h("tpl.delete")]})]}),s.jsxs("div",{className:"template-modal-actions-right",children:[s.jsx("button",{type:"button",className:"btn template-btn",onClick:w,children:h("tpl.save")}),s.jsx("button",{type:"button",className:"btn template-btn fill",onClick:u,title:h("tpl.fillTip"),children:h("tpl.fill")}),s.jsxs("button",{type:"button",className:"btn template-btn send",onClick:m,title:h("tpl.sendTip"),children:[s.jsx(ta,{})," ",h("tpl.sendNow")]})]})]})]})})}const zi=new Map,Nf=15,Qi=30,Qn=250,Xi=1200,kf=1600;function Ji({kind:e,text:t,onRemoveQueued:n,onRecallQueued:i}){const a=Pe();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 vf({compaction:e}){const t=Pe(),[,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 Zi(e){return e.content.some(t=>t.type==="toolCall")}function Cf({state:e,liveOutputs:t,toolStatuses:n,onEdit:i,onKillBash:a,onRetry:o,onRemoveQueued:l,onRecallQueued:u,thinkingWrap:m,toolsWrap:E,jumpTarget:h,onJumpDone:g}){const w=Pe(),k=c.useRef(null),[_,M]=c.useState(!0),$=c.useRef(!0),S=c.useRef(0),I=c.useRef(0),j=c.useRef(!1),H=c.useRef(0),[ee,J]=c.useState(()=>new Set),[ue,pe]=c.useState(!1),G=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,Y=c.useMemo(()=>{const L=new Map;for(const K of e.messages)K.role==="toolResult"&&K.toolCallId&&L.set(K.toolCallId,K);return L},[e.messages]),ge=c.useMemo(()=>Yh(e.messages),[e.messages]),O=G.length>0?G[G.length-1].id:null,R=e.messages.length>Qi?Math.max(0,e.messages.length-Nf):0,x=c.useMemo(()=>{const L=new Set;for(let K=0;K<R;K++){const Ae=e.messages[K];Ae.role!=="toolResult"&&(ee.has(Ae.id)||L.add(Ae.id))}return L},[e.messages,R,ee]),[D,U]=c.useState(()=>new Set),[C,Z]=c.useState(()=>new Set),X=c.useRef(new Map),ve=c.useRef(new Map),N=c.useRef(new Map),z=c.useRef(0),de=c.useMemo(()=>{const L=new Map;for(const K of e.messages)L.set(K.id,ef(K));return L},[e.messages]),re=c.useRef(de);re.current=de;const ke=c.useRef(D);ke.current=D;const oe=e.messages.length>Qi&&!ue,he=c.useRef(oe);he.current=oe;const W=Jh(e.messages,X.current,kf),ce=c.useRef(W);ce.current=W;const F=c.useCallback(()=>{const L=k.current;if(!L)return;if(!he.current){U(He=>He.size?new Set:He);return}const K=L.getBoundingClientRect(),Ae={top:K.top-Xi,bottom:K.bottom+Xi},we=[];for(const[He,ot]of N.current){const yt=ot.getBoundingClientRect();we.push({id:He,top:yt.top,bottom:yt.bottom}),ke.current.has(He)||P(He,yt.bottom-yt.top,re.current.get(He))}const Me=Qh(we,Ae,ce.current,ke.current);for(const He of Me.hide){const ot=N.current.get(He);ot&&P(He,ot.offsetHeight,re.current.get(He))}U(He=>Xh(He,Me))},[]),Le=c.useCallback(()=>{z.current||(z.current=requestAnimationFrame(()=>{z.current=0,F()}))},[F]);c.useLayoutEffect(()=>{F()},[F]);const Oe=c.useRef(ue);c.useLayoutEffect(()=>{Oe.current&&!ue&&F(),Oe.current=ue},[ue,F]);const P=c.useCallback((L,K,Ae)=>{Ae!==void 0&&(ve.current.set(L,{h:K,len:Ae}),X.current.set(L,K))},[]),ye=c.useCallback((L,K)=>{P(L,K,re.current.get(L))},[P]),fe=c.useCallback(L=>{L&&N.current.set(L.dataset.lazyId??"",L)},[]);c.useEffect(()=>{const L=new Set(e.messages.map(K=>K.id));for(const K of N.current.keys())L.has(K)||(N.current.delete(K),X.current.delete(K),ve.current.delete(K));U(K=>{let Ae=!1;const we=new Set;for(const Me of K)L.has(Me)?we.add(Me):Ae=!0;return Ae?we:K})},[e.messages,ee]),c.useEffect(()=>()=>cancelAnimationFrame(z.current),[]);const Te=c.useMemo(()=>{const L=[];for(const K of e.messages){if(K.role!=="user")continue;const Ae=K.content.map(He=>ls(He)?.text??"").filter(Boolean).join(" "),we=Oa(Ae),Me=we?we.userMessage??`skill:${we.name}`:Ae.trim();Me&&L.push({id:K.id,text:Me})}return L},[e.messages]),Ne=c.useMemo(()=>{const L=new Map;return Te.forEach((K,Ae)=>L.set(K.id,Ae)),L},[Te]),[Se,Ce]=c.useState(-1),T=c.useRef(-1),le=c.useRef(Te);c.useEffect(()=>{le.current=Te},[Te]);const se=c.useCallback(()=>{const L=k.current,K=le.current;if(!L||K.length===0)return;const Ae=L.getBoundingClientRect().top,we=140;let Me=-1;for(let He=0;He<K.length;He++){const ot=L.querySelector(`[data-msg-id="${K[He].id}"]`);if(ot)if(ot.getBoundingClientRect().top<=Ae+we)Me=He;else break}Me!==T.current&&(T.current=Me,Ce(Me))},[]);c.useEffect(()=>{se()},[Te,se]);const Ee=c.useCallback(L=>{J(K=>K.has(L)?K:new Set(K).add(L))},[]);c.useEffect(()=>{const L=K=>{if(!(K.ctrlKey||K.metaKey)||K.key.toLowerCase()!=="f")return;const Ae=K.target;Ae&&(Ae.tagName==="INPUT"||Ae.tagName==="TEXTAREA"||Ae.isContentEditable)||(K.preventDefault(),pe(!0))};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[]);const Re=c.useCallback(L=>{J(K=>{if(!K.has(L))return K;const Ae=new Set(K);return Ae.delete(L),Ae})},[]),y=c.useCallback(L=>{const K=e.messages.findIndex(we=>we.id===L);Yr.flushSync(()=>{K>=0&&K<R&&!ee.has(L)&&Ee(L),Z(we=>we.has(L)?we:new Set(we).add(L))});const Ae=le.current.findIndex(we=>we.id===L);T.current=Ae,Ce(Ae),requestAnimationFrame(()=>{const we=k.current?.querySelector(`[data-msg-id="${L}"]`);we&&(k.current?.querySelectorAll(".msg-flash").forEach(Me=>Me.classList.remove("msg-flash")),we.scrollIntoView({block:"start"}),we.classList.remove("msg-flash"),we.offsetWidth,we.classList.add("msg-flash"),we!==k.current?.lastElementChild&&(j.current=!0))})},[e.messages,R,ee,Ee]),[ie,v]=c.useState(null),te=c.useRef(null),me=c.useRef(null);c.useEffect(()=>{const L=te.current;if(!L||L.convId!==e.conversationId){te.current={convId:e.conversationId,ids:new Set(e.messages.filter(K=>K.role==="compactionSummary").map(K=>K.id))},me.current=null,v(null);return}for(const K of e.messages)if(K.role==="compactionSummary"&&!L.ids.has(K.id)){L.ids.add(K.id),v(K.id);break}},[e.messages,e.conversationId]),c.useEffect(()=>{!ie||me.current===ie||(me.current=ie,y(ie))},[ie,y]);const je=c.useMemo(()=>h?e.messages.find(L=>L.role===h.role&&L.timestamp===h.timestamp)?.id??null:null,[e.messages,h]);c.useEffect(()=>{if(h){if(je){y(je),g?.();return}e.sessionFile===h.path&&e.messages.length>0&&g?.()}},[je,y,g,h,e.sessionFile,e.messages.length]);const Ie=c.useCallback(()=>{const L=k.current;if(!L)return;const K=L.scrollTop-S.current,Ae=L.scrollHeight-I.current;S.current=L.scrollTop,I.current=L.scrollHeight;const we=L.scrollHeight-L.scrollTop-L.clientHeight<80,Me=Date.now()<H.current,He=mf({dSt:K,dSh:Ae,escaped:j.current,graceActive:Me,stuck:$.current});He.reassert&&(H.current=Date.now()+Qn,L.scrollTop=L.scrollHeight),He.flipEscape&&(j.current=!0),we&&K>=0&&(j.current=!1),Me||(K<0?$.current=we&&!j.current:we&&($.current=!0)),M($.current),se(),Le()},[se,Le]),Ge=c.useRef(!1);c.useEffect(()=>{const L=Ge.current;if(Ge.current=!!e.isStreaming,L&&!e.isStreaming&&!j.current){const K=()=>{const we=k.current;we&&!j.current&&(we.scrollTop=we.scrollHeight,$.current=!0,M(!0))};requestAnimationFrame(()=>requestAnimationFrame(K));const Ae=setTimeout(K,180);return()=>clearTimeout(Ae)}},[e.isStreaming]),c.useEffect(()=>{const L=k.current;L&&$.current&&(L.scrollTop=L.scrollHeight)},[G,e.isStreaming,t]);const Xt=e.queue.steering.join("\0")+""+e.queue.followUp.join("\0");c.useEffect(()=>{const L=k.current;L&&$.current&&(L.scrollTop=L.scrollHeight)},[Xt]),c.useEffect(()=>{const L=k.current;if(!L||typeof ResizeObserver>"u")return;let K=L.clientHeight;const Ae=new ResizeObserver(()=>{const we=L.clientHeight,Me=we-K;K=we,Me>0&&(L.scrollTop=Math.min(L.scrollTop,L.scrollHeight-L.clientHeight))});return Ae.observe(L),()=>Ae.disconnect()},[]),c.useEffect(()=>{const L=k.current;if(!L||typeof MutationObserver>"u")return;let K=!1;const Ae=new MutationObserver(()=>{K||(K=!0,requestAnimationFrame(()=>{K=!1;const we=k.current;we&&$.current&&!j.current&&(we.scrollTop=we.scrollHeight,M(!0))}))});return Ae.observe(L,{childList:!0,subtree:!0,characterData:!0}),()=>Ae.disconnect()},[]);const At=c.useCallback(()=>{if(!k.current)return;$.current=!0,j.current=!1,M(!0),H.current=Date.now()+Qn;const K=()=>{const Ae=k.current;!Ae||!$.current||j.current||(H.current=Date.now()+Qn,Ae.scrollTop=Ae.scrollHeight)};K(),requestAnimationFrame(()=>requestAnimationFrame(K)),setTimeout(K,120),setTimeout(K,300),setTimeout(K,600)},[]),Ut=c.useRef(null);c.useEffect(()=>{const L=Ut.current,K=k.current;if(!L||!K)return;const Ae=we=>{we.preventDefault();const Me=L.querySelector(".qn-list");if(Me&&Me.contains(we.target)&&Me.scrollHeight>Me.clientHeight){Me.scrollTop+=we.deltaY;return}K.scrollTop+=we.deltaY};return L.addEventListener("wheel",Ae,{passive:!1}),()=>L.removeEventListener("wheel",Ae)},[]);const[mt,qt]=c.useState(0);c.useEffect(()=>{const L=()=>{qt(k.current?.clientHeight??0),Le()};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[Le]);const xt=Te.length,$t=c.useMemo(()=>xt===0?27:Math.max(4,Math.min(27,Math.floor(((mt||600)-16)/xt)-3)),[xt,mt]),It=$t<20;return s.jsxs("div",{className:"messages-wrap",children:[s.jsxs("div",{className:`messages${ue||_?"":" anchor-live"}`,ref:k,onScroll:Ie,children:[e.messages.length===0&&!e.streamingMessage&&s.jsx("div",{className:"empty-state",children:s.jsx(Tf,{})}),e.messages.map((L,K)=>{const Ae=K<R,we=Ae&&ee.has(L.id);if(Ae&&!we)return L.role==="toolResult"?null:s.jsx(Gh,{message:L,onExpand:Ee},L.id);const Me=L.role==="user"?Ne.get(L.id):void 0,He=!oe||W.has(L.id)||C.has(L.id)||!D.has(L.id);return s.jsx(zh,{id:L.id,show:He,height:tf(L.id,de.get(L.id)??-1,ve.current,Fo(L.role,L.customType)),containerRef:k,onMeasured:ye,lazyRef:fe,children:s.jsx(Wi,{message:L,qnIndex:Me,qnActive:Me!==void 0?Me===Se:void 0,onJump:y,toolResults:Y,liveOutputs:Zi(L)?t:zi,toolStatuses:n,streaming:e.isStreaming,onKillBash:a,onRetry:L.id===O?o:void 0,toolsWrap:E,thinkingWrap:m,isLast:L.id===O,onEdit:i,questionAttachments:ge.get(L.id),onCollapse:we?Re:void 0,searchActive:ue,autoExpand:L.id===ie},L.id)},L.id)}),e.streamingMessage&&s.jsx(Wi,{message:e.streamingMessage,toolResults:Y,liveOutputs:Zi(e.streamingMessage)?t:zi,toolStatuses:n,streaming:!0,isLast:!0,onEdit:i,onKillBash:a,toolsWrap:E,thinkingWrap:m,searchActive:ue},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(vf,{compaction:e.compaction}),e.isStreaming&&G.length===0&&s.jsx("div",{className:"streaming-wait",children:w("waitingResponse")}),e.queue.steering.map((L,K)=>s.jsx(Ji,{kind:"steer",text:L,onRemoveQueued:l,onRecallQueued:u},`q-steer-${K}`)),e.queue.followUp.map((L,K)=>s.jsx(Ji,{kind:"followUp",text:L,onRemoveQueued:l,onRecallQueued:u},`q-fu-${K}`))]}),!_&&s.jsxs("button",{type:"button",className:"scroll-bottom",onClick:At,children:[s.jsx(Sr,{})," ",w("backToBottom")]}),s.jsx(df,{containerRef:k,messages:G,collapsedIds:x,toolResults:Y,onExpand:Ee,onProgrammaticScroll:()=>{j.current=!0,$.current=!1,M(!1)},open:ue,onClose:()=>pe(!1)}),Te.length>0&&s.jsxs("div",{className:`qn-rail ${It?"many":""}`,ref:Ut,"aria-label":w("questionNavTitle"),style:{"--rail-gap":`${$t}px`},children:[Te.map((L,K)=>s.jsx("button",{type:"button",className:`qn-bar ${K===Se?"active":""}`,"aria-label":`${K+1}. ${L.text}`,onClick:()=>y(L.id),children:s.jsxs("span",{className:"qn-bar-text",children:[K+1,". ",L.text]})},L.id)),It&&s.jsx("div",{className:"qn-list",children:Te.map((L,K)=>s.jsxs("button",{type:"button",className:`qn-list-item ${K===Se?"active":""}`,"aria-label":`${K+1}. ${L.text}`,onClick:()=>y(L.id),children:[s.jsx("span",{className:"qn-list-idx",children:K+1}),s.jsx("span",{className:"qn-list-text",children:L.text})]},L.id))})]})]})}function _f(e,t){return t?e.trim()?`${e.replace(/\s+$/,"")}
325
- ${t}`:t:e}const Ba="pi-web-ui:prompt-history",Sf=100,Go="pi-web-ui:prompt-history-settings",ya={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function Vo(e){const t=ya;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 zo(){try{const e=localStorage.getItem(Go);return e?Vo(JSON.parse(e)):{...ya}}catch{return{...ya}}}function Xn(e){const t=Vo(e);try{localStorage.setItem(Go,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)),Qo(n)}catch{}}function wf(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 Af(e,t,n=Sf){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(Ba);return e?wf(JSON.parse(e)):[]}catch{return[]}}function Qo(e){let t=e;for(;t;)try{localStorage.setItem(Ba,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 er(e){let t=e.trim();if(!t)return;const n=zo();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));const i=Os(),a=Af(i,t,n.maxEntries);a!==i&&Qo(a)}function If(){try{localStorage.removeItem(Ba)}catch{}}function jf(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 Lf(){return typeof window>"u"||typeof navigator>"u"||typeof window.matchMedia!="function"?!1:jf({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}const Rf=["off","minimal","low","medium","high","xhigh","max"],Df=c.memo(function({state:t,models:n,modelsLoading:i,onManageModels:a,providerKeys:o,compact:l=!1}){const u=Pe(),m=t?.model,E=m?`${m.provider}/${m.id}`:null,[h,g]=c.useState(!1),[w,k]=c.useState(!1),[_,M]=c.useState(""),[$,S]=c.useState(null),[I,j]=c.useState({}),H=c.useRef(null),ee=c.useRef(null),[J,ue]=c.useState(null);c.useEffect(()=>{if(!h){ue(null);return}if(n.length===0)return;const C=requestAnimationFrame(()=>{const Z=ee.current;Z&&ue(Z.offsetWidth)});return()=>cancelAnimationFrame(C)},[h,n.length]),c.useEffect(()=>{h&&j(Uo())},[h]),c.useEffect(()=>{h||(M(""),S(null))},[h]);const pe=c.useMemo(()=>{const C=new Map;for(const X of n)C.set(X.provider,(C.get(X.provider)??0)+1);const Z=[];for(const[X,ve]of[...C.entries()].sort((N,z)=>N[0].localeCompare(z[0]))){const N=o[X];if(N&&N.length>1)for(const z of N)Z.push({provider:X,keyName:z.name,count:ve});else Z.push({provider:X,keyName:null,count:ve})}return Z},[n,o]),G=c.useMemo(()=>ff(n,I),[n,I]),Y=c.useMemo(()=>{let C=G;$&&(C=C.filter(X=>X.provider===$.provider));const Z=_.trim().toLowerCase();return Z?C.filter(X=>X.name.toLowerCase().includes(Z)||X.provider.toLowerCase().includes(Z)||X.id.toLowerCase().includes(Z)):C},[G,_,$]),ge=c.useMemo(()=>{const C=[];for(const Z of Y){const X=o[Z.provider];if(!X||X.length<=1){C.push({model:Z,key:null});continue}let ve=X.find(N=>N.active)??X[0];if($?.provider===Z.provider&&$.keyName){const N=X.find(z=>z.name===$.keyName);N&&(ve=N)}C.push({model:Z,key:ve})}return C},[Y,o,$]),[O,R]=c.useState(!1),x=t?.availableThinkingLevels&&t.availableThinkingLevels.length>0?new Set(t.availableThinkingLevels):null,D=Rf.map(C=>({value:C,label:u(`thinking.${C}`),supported:x?x.has(C):!0})),U=C=>D.find(Z=>Z.value===C)?.label??C;return c.useEffect(()=>{h&&n.length===0&&!O&&!i&&(R(!0),ae({type:"list_models"}))},[h,n.length,O,i]),c.useEffect(()=>{n.length>0&&R(!1)},[n.length]),c.useEffect(()=>{if(!h)return;H.current?.querySelector(".dd-item.active")?.scrollIntoView({block:"nearest"})},[h,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:m?m.name:u("selectModel")}),!l&&m?.vision&&s.jsx("span",{className:"chip-vision",title:u("vision"),children:"🖼"}),!l&&m&&s.jsx("span",{className:"chip-sub",children:m.provider})]}),open:h,onOpenChange:g,menuClassName:"dd-menu-model",menuRef:ee,menuStyle:J!=null?{width:J}:void 0,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("availableModels")}),s.jsxs("div",{className:"dd-search-row",children:[s.jsx(dn,{}),s.jsx("input",{className:"dd-search",type:"text",placeholder:u("searchModels"),value:_,onChange:C=>M(C.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 ${$===null?"active":""}`,onClick:()=>S(null),children:s.jsx("span",{children:u("allProviders")})}),pe.map(C=>{const Z=$?.provider===C.provider&&$?.keyName===C.keyName;return s.jsxs("button",{type:"button",className:`dd-provider-item ${Z?"active":""}`,onClick:()=>S(Z?null:{provider:C.provider,keyName:C.keyName}),title:C.keyName?`${C.provider} · ${C.keyName}`:`${C.provider} · ${C.count}`,children:[s.jsxs("span",{className:"dd-provider-txt",children:[s.jsx("span",{className:"dd-provider-name",children:C.provider}),C.keyName&&s.jsx("span",{className:"dd-provider-key",children:C.keyName})]}),s.jsx("span",{className:"dd-provider-count",children:C.count})]},C.keyName?`${C.provider}::${C.keyName}`:C.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")}),Y.length===0&&n.length>0&&s.jsx("div",{className:"dd-loading",children:u("noModelMatches")}),ge.map(C=>{const Z=C.model,X=E===Z.id&&(!C.key||C.key.active);return s.jsx(it,{active:X,onClick:()=>{C.key&&!C.key.active&&ae({type:"activate_provider_key",provider:Z.provider,keyName:C.key.name}),E!==Z.id&&ae({type:"set_model",modelId:Z.id}),g(!1)},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:Z.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:Z.provider}),s.jsx("span",{className:"dd-model-id",children:Z.id.split("/").slice(1).join("/")}),C.key&&s.jsxs("span",{className:`dd-model-key ${C.key.active?"active":""}`,children:[C.key.active?"●":"○"," ",C.key.name]}),(I[Z.id]??0)>0&&s.jsx("span",{className:"dd-model-usage",children:u("modelUsedCount",{n:I[Z.id]})}),(Z.reasoning||Z.vision)&&s.jsxs("span",{className:"dd-model-badges",children:[Z.reasoning&&s.jsx("span",{className:"dd-model-badge",children:u("reasoning")}),Z.vision&&s.jsx("span",{className:"dd-model-badge",children:u("vision")})]})]})]})},C.key?`${Z.id}::${C.key.name}`:Z.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:()=>{g(!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?U(t.thinkingLevel):"—"})})]}),open:w,onOpenChange:k,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("thinkingLevel")}),D.map(C=>s.jsx(it,{active:t?.thinkingLevel===C.value,disabled:!C.supported,title:C.supported?void 0:u("thinkingUnsupported"),onClick:()=>{t?.thinkingLevel!==C.value&&ae({type:"set_thinking",level:C.value}),k(!1)},children:C.label},C.value))]})]})}),tr=Lf(),Pf=c.memo(function({streaming:t,messages:n,slashCommands:i,modelState:a,models:o,modelsLoading:l,attachments:u,onRemoveAttachment:m,onAddImageFiles:E,onAddLocalFiles:h,onNotice:g,onSent:w,onManageModels:k,providerKeys:_,quickPhrases:M,quickPhrasesEnabled:$,recallDrafts:S}){const I=Pe(),j=Ct("ready"),H=Br(),{locale:ee}=Ht(),{openPicker:J}=Ko(),ue=y=>ee!=="zh"&&y.descriptionEn?y.descriptionEn:y.description??"",pe=y=>ee!=="zh"&&y.argumentHintEn?y.argumentHintEn:y.argumentHint??"",[G,Y]=c.useState(""),[ge,O]=c.useState(!1),[R,x]=c.useState(null),[D,U]=c.useState(0),[C,Z]=c.useState(!1),[X,ve]=c.useState(void 0),N=c.useRef(null),z=c.useRef(null),de=c.useRef(null),re=c.useRef(-1),ke=c.useRef(""),oe=c.useRef(0);c.useEffect(()=>{if(!S||S.length===0)return;const y=S.filter(ie=>ie.text&&ie.seq>oe.current);y.length!==0&&(oe.current=y[y.length-1].seq,Y(ie=>y.reduce((v,te)=>_f(v,te.text),ie)),re.current=-1,ke.current="",requestAnimationFrame(()=>{const ie=N.current;ie&&(ie.focus(),ie.selectionStart=ie.selectionEnd=ie.value.length)}))},[S]);const he={builtin:I("slashBuiltin"),extension:I("slashExtension"),prompt:I("slashPrompt"),skill:I("slashSkill"),plugin:I("slashPlugin")},W=y=>{const ie=y.match(/^\/([^\s]*)$/);if(ie&&j){const v=ie[1].toLowerCase(),te=i.filter(me=>me.name.toLowerCase().startsWith(v));x(te.length>0?te:null),U(0)}else x(null)};c.useEffect(()=>{de.current?.querySelector(".slash-item.active")?.scrollIntoView({block:"nearest"})},[D,R]);const ce=y=>{const ie=R??[],v=y??ie[D%Math.max(ie.length,1)];if(!v){x(null);return}const te=G.match(/^\/([^\s]*)([\s\S]*)$/),me=te?te[2]:"";Y(`/${v.name} ${me}`),x(null),N.current?.focus()},F=async()=>{const v=[...n].reverse().find(te=>te.role==="assistant"&&te.content.some(me=>me.type==="text"&&me.text))?.content.filter(te=>te.type==="text").map(te=>te.text).join(`
326
- `);if(!v){g("warning",I("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(v),g("info",I("slashCopied"))}catch{g("error",I("slashCopyFailed"))}},Le=y=>{if(!y||y.length===0){g("warning",I("foldersNotSupported"));return}const ie=Array.from(y).filter(me=>_t(me.type)),v=Array.from(y).filter(me=>!_t(me.type)),te=P();ie.length>0&&te?g("warning",te):ie.length>0&&E(ie),v.length>0&&h(v)},Oe=y=>{const ie=y.clipboardData?.items;if(!ie)return;const v=[];for(const me of ie)if(me.kind==="file"&&_t(me.type)){const je=me.getAsFile();je&&v.push(je)}if(v.length===0)return;y.preventDefault();const te=P();if(te){g("warning",te);return}E(v)},P=()=>{const y=a?.model;if(!y?.id)return null;const ie=o.find(v=>v.id===y.id);return ie&&ie.vision===!1?I("modelNoVision",{name:ie.name}):null},ye=j,fe=c.useRef(G);c.useEffect(()=>{fe.current=G},[G]),c.useEffect(()=>{W(fe.current)},[i]),c.useEffect(()=>{const y=ie=>{const v=ie.detail;Y(v),N.current?.focus()};return window.addEventListener("pi-web:fill",y),()=>window.removeEventListener("pi-web:fill",y)},[]),c.useEffect(()=>{if(!C)return;const y=ie=>{ie.key==="Escape"&&Z(!1)};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[C]);const Te=c.useRef(null);c.useEffect(()=>{const y=N.current,ie=Te.current;if(!y||!ie)return;const v=y.closest("main")?.querySelector(".messages"),te=ie.getBoundingClientRect().height,me=v?.scrollTop??0;y.style.height="auto";const je=y.scrollHeight>220;if(y.style.height=`${Math.min(y.scrollHeight,220)}px`,y.style.overflowY=je?"auto":"hidden",v){const Ie=ie.getBoundingClientRect().height-te;v.scrollTop=me+Ie}},[G]);const Ne=y=>y.selectionStart!==y.selectionEnd?!1:!y.value.slice(0,y.selectionStart).includes(`
327
- `),Se=y=>y.selectionStart!==y.selectionEnd?!1:!y.value.slice(y.selectionStart).includes(`
328
- `),Ce=()=>u.map(y=>y.imageData?{path:"",imageData:y.imageData,mimeType:y.mimeType,name:y.name}:y.fileData?{path:"",fileData:y.fileData,mimeType:y.mimeType,name:y.name,size:y.size}:{path:y.path,mode:y.mode,...y.lines?{lines:y.lines}:{}}),T=(y=!1)=>{const ie=G.trim(),v=u.some(te=>te.imageData||te.fileData);if(!(!ye||!ie&&!v)){if(ie==="/help"){const te=N.current?.closest(".inputbox")?.getBoundingClientRect();ve(te?.width),Z(!0),Y(""),N.current?.focus();return}if(ie==="/copy"){Y(""),N.current?.focus(),F();return}if(ae({type:"prompt",text:ie,queue:y,attachments:Ce()})){ie&&er(ie),re.current=-1,ke.current="",Y(""),w();const te=a?.model;te&&vn(`${te.provider}/${te.id}`),N.current?.focus()}}},le=y=>{const ie=y.trim();if(!(!ye||!ie)&&ae({type:"prompt",text:ie,attachments:Ce()})){ie&&er(ie),re.current=-1,ke.current="",w();const v=a?.model;v&&vn(`${v.provider}/${v.id}`),tr||N.current?.focus()}},se=y=>{if(!y.nativeEvent.isComposing){if(R&&R.length>0)switch(y.key){case"ArrowDown":y.preventDefault(),U(ie=>(ie+1)%R.length);return;case"ArrowUp":y.preventDefault(),U(ie=>(ie-1+R.length)%R.length);return;case"Tab":case"Enter":y.preventDefault(),ce();return;case"Escape":y.preventDefault(),x(null);return}if(y.key==="ArrowUp"||y.key==="ArrowDown"){if(y.ctrlKey||y.metaKey||y.altKey)return;const ie=N.current;if(!ie)return;const v=y.key==="ArrowUp";if(v&&!Ne(ie)||!v&&!Se(ie)||!v&&re.current===-1)return;const te=Os();if(te.length===0)return;if(y.preventDefault(),v){if(re.current===-1){ke.current=G;const me=te.length-1;re.current=me;const je=te[me];Y(je),W(je),requestAnimationFrame(()=>{const Ie=N.current;Ie&&(Ie.selectionStart=Ie.selectionEnd=je.length)})}else if(re.current>0){const me=re.current-1;re.current=me;const je=te[me];Y(je),W(je),requestAnimationFrame(()=>{const Ie=N.current;Ie&&(Ie.selectionStart=Ie.selectionEnd=je.length)})}}else{const me=re.current+1;if(me<te.length){re.current=me;const je=te[me];Y(je),W(je),requestAnimationFrame(()=>{const Ie=N.current;Ie&&(Ie.selectionStart=Ie.selectionEnd=je.length)})}else{re.current=-1;const je=ke.current;Y(je),W(je),requestAnimationFrame(()=>{const Ie=N.current;Ie&&(Ie.selectionStart=Ie.selectionEnd=je.length)})}}return}if(y.key==="Escape"&&re.current!==-1){y.preventDefault();const ie=ke.current;re.current=-1,Y(ie),W(ie),requestAnimationFrame(()=>{const v=N.current;v&&(v.selectionStart=v.selectionEnd=ie.length)});return}if(y.key==="Enter"){if(tr&&!y.shiftKey&&!(y.ctrlKey||y.metaKey))return;y.shiftKey||(y.preventDefault(),T())}}},Ee=ye&&(G.trim()!==""||u.some(y=>y.imageData||y.fileData)),Re=()=>s.jsx("div",{className:"inputbox-actions",children:t?Ee?s.jsxs("div",{className:`split-send${H?" single":""}`,children:[s.jsx("button",{type:"button",className:"split-queue",title:I("supplementTip"),"aria-label":I("queueFollowTag"),onClick:()=>T(!0),children:s.jsx(pc,{})}),!H&&s.jsx("button",{type:"button",className:"split-steer",title:I("steerTip"),"aria-label":I("queueSteerTag"),onClick:()=>T(),children:s.jsx(aa,{})})]}):s.jsx("button",{type:"button",className:"btn stop",title:I("stopAgent"),onClick:()=>ae({type:"abort"}),children:s.jsx(cn,{})}):s.jsx("button",{type:"button",className:"btn send",title:I("sendTip"),disabled:!Ee,onClick:()=>T(),children:s.jsx(aa,{})})});return s.jsxs("div",{ref:Te,className:`inputbar${ge?" drop-active":""}`,onDragOver:y=>{y.preventDefault(),y.stopPropagation(),O(!0)},onDragLeave:y=>{y.currentTarget.contains(y.relatedTarget)||O(!1)},onDrop:y=>{y.preventDefault(),y.stopPropagation(),O(!1),Le(y.dataTransfer?.files??null)},children:[ge&&s.jsx("div",{className:"drop-overlay",children:s.jsxs("span",{children:["📎 ",I("dropHereToAttach")]})}),u.length>0&&s.jsxs("div",{className:"attach-row",children:[u.map(y=>s.jsxs("span",{className:`attach-chip ${y.imageData?"image":y.fileData?"file":y.mode}`,title:y.imageData?I("attachImage",{name:y.name}):y.fileData?I("attachFile",{name:y.name}):y.isDir?I("folderRef",{path:y.path}):y.mode==="reference"?I("refOnly",{path:y.path}):y.mode==="lines"&&y.lines?I("attachLines",{path:y.path,start:y.lines.start,end:y.lines.end}):I("attachContent",{path:y.path}),children:[y.imageData?"🖼":y.fileData?"📄":y.isDir?"📁":y.mode==="reference"?"🔗":"📎"," ",y.name,y.mode==="lines"&&y.lines&&s.jsxs("span",{className:"attach-range",children:["L",y.lines.start,"-",y.lines.end]}),s.jsx("button",{type:"button",className:"attach-remove",title:I("removeAttachment"),onClick:()=>m(y.key??y.path),children:"×"})]},y.key??`${y.path}|${y.mode}|${y.lines?`${y.lines.start}-${y.lines.end}`:""}`)),s.jsx("span",{className:"attach-hint",children:I("attachHint")})]}),R&&R.length>0&&s.jsxs("div",{className:"slash-menu",role:"listbox",ref:de,"aria-label":I("slashCommands"),children:[s.jsxs("div",{className:"slash-menu-hint",children:[s.jsx("span",{children:I("slashMenuHint")}),s.jsx("span",{className:"slash-menu-close",onClick:()=>x(null),children:"Esc"})]}),R.map((y,ie)=>s.jsxs("button",{type:"button",className:`slash-item${ie===D?" active":""}`,onMouseEnter:()=>U(ie),onClick:()=>ce(y),children:[s.jsxs("span",{className:"slash-name",children:["/",y.name]}),s.jsx("span",{className:`slash-source ${y.source}`,children:he[y.source]}),s.jsxs("span",{className:"slash-desc",children:[ue(y),y.argumentHint&&s.jsx("span",{className:"slash-hint",children:pe(y)})]})]},y.name))]}),C&&s.jsx("div",{className:"modal-backdrop",onClick:()=>Z(!1),children:s.jsxs("div",{className:"slash-help",style:X?{width:X}:void 0,onClick:y=>y.stopPropagation(),children:[s.jsxs("div",{className:"slash-help-head",children:[s.jsxs("span",{children:["⚡ ",I("slashHelpTitle")]}),s.jsx("button",{type:"button",className:"btn",onClick:()=>Z(!1),children:I("close")})]}),s.jsx("div",{className:"slash-help-body",children:i.length===0?s.jsx("div",{className:"slash-help-empty",children:I("slashLoading")}):i.map(y=>s.jsxs("div",{className:"slash-help-row",children:[s.jsxs("span",{className:"slash-help-cmd",children:["/",y.name]}),s.jsx("span",{className:`slash-source ${y.source}`,children:he[y.source]}),s.jsxs("span",{className:"slash-help-desc",children:[ue(y),y.argumentHint&&s.jsx("span",{className:"slash-hint",children:pe(y)})]})]},y.name))})]})}),$&&M.length>0&&s.jsx("div",{className:"quick-row","aria-label":I("quickPhrases"),children:M.map(y=>s.jsx("button",{type:"button",className:"quick-chip",title:I("quickPhrasesTip",{text:y}),disabled:!ye,onClick:()=>le(y),children:y},y))}),s.jsxs("div",{className:"inputbox",children:[s.jsx("input",{ref:z,type:"file",multiple:!0,hidden:!0,onChange:y=>{Le(y.target.files),y.target.value=""}}),s.jsx("textarea",{ref:N,value:G,rows:1,placeholder:I(ye?t?H?"placeholderStreamingQueued":"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!ye,onChange:y=>{re.current=-1,Y(y.target.value),W(y.target.value)},onKeyDown:se,onPaste:Oe}),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:I("uploadFile"),disabled:!ye,onClick:()=>z.current?.click(),children:s.jsx(ac,{})}),s.jsx("button",{type:"button",className:"btn tpl-open",title:I("tpl.openPicker"),onClick:J,children:s.jsx(gc,{})}),s.jsx(Df,{state:a,models:o,modelsLoading:l,onManageModels:k,providerKeys:_,compact:!0})]}),s.jsx("div",{className:"composer-tools-right",children:Re()})]})]})]})}),Of=c.memo(function({goal:t,models:n,modelsLoading:i,activeConversationId:a}){const o=Pe(),{locale:l}=Ht(),u=l!=="zh"&&t.statusEn?t.statusEn:t.status||"",m=l!=="zh"&&t.wizard?.statusEn?t.wizard.statusEn:t.wizard?.status||"",E=Br(),h=!t.conversationId||t.conversationId===a,g=t.goal!==null&&h,[w,k]=c.useState(""),[_,M]=c.useState(t.reviewModel??""),[$,S]=c.useState(t.maxRounds),[I,j]=c.useState(t.locked),[H,ee]=c.useState(!1),[J,ue]=c.useState(!1),[pe,G]=c.useState(!0);c.useEffect(()=>{M(t.reviewModel??""),S(t.maxRounds||0),j(t.locked)},[t.goal,t.reviewModel,t.maxRounds,t.locked]),c.useEffect(()=>{H&&n.length===0&&!J&&!i&&(ue(!0),ae({type:"list_models"}))},[H,n.length,J,i]),c.useEffect(()=>{n.length>0&&ue(!1)},[n.length]);const Y=()=>_?n.find(x=>x.id===_)?.name??_:o("goalBarUseMainModel"),ge=()=>{const x=w.trim();x&&(ae({type:"set_goal",goal:x,..._?{reviewModel:_}:{},maxRounds:$,locked:I}),k(""),G(!1))},O=()=>{const x=w.trim();x&&(ae({type:"start_goal_wizard",text:x,..._?{wizardModel:_}:{},maxRounds:$,locked:I}),k(""),G(!1))},R=(t.wizard?.active??!1)&&h;return R?s.jsx("div",{className:`goalbar goalbar-active ${R?"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:m||o("goalBarReviewing")}),s.jsx("button",{type:"button",className:"goalbar-x",title:o("goalBarClear"),onClick:()=>{ae({type:"clear_goal"}),G(!0)},children:s.jsx(Ke,{})})]})}):g?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"}),G(!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:()=>G(!1),children:[s.jsx(za,{})," ",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(za,{})}),s.jsx("input",{className:"goalbar-input",value:w,placeholder:o("goalBarPlaceholder"),onChange:x=>k(x.target.value),onKeyDown:x=>{x.key==="Enter"&&ge()}}),s.jsx("button",{type:"button",className:"goalbar-btn",disabled:!w.trim(),onClick:ge,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(I?"goalBarLocked":"goalBarUnlocked"),onClick:()=>j(x=>(ae({type:"set_goal_prefs",locked:!x}),!x)),children:I?s.jsx(dc,{}):s.jsx(ec,{})}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o("goalBarClear"),onClick:()=>G(!0),children:s.jsx(In,{})})]}),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:Y()})]}),open:H,onOpenChange:ee,direction:"up",children:[s.jsx("div",{className:"dd-header",children:o("goalBarReviewModel")}),(J||i)&&s.jsx("div",{className:"dd-loading",children:o("loading")}),n.length===0&&!J&&!i&&s.jsx("div",{className:"dd-loading",children:o("noModels")}),s.jsx(it,{active:_==="",onClick:()=>{M(""),ee(!1),ae({type:"set_goal_prefs",reviewModel:""})},children:o("goalBarUseMainModel")}),n.map(x=>s.jsx(it,{active:_===x.id,onClick:()=>{M(x.id),ee(!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:$,placeholder:o("goalBarUnlimitedShort"),onChange:x=>{const D=parseInt(x.target.value,10);if(Number.isNaN(D)||D<0){S(0);return}S(D)},onBlur:()=>ae({type:"set_goal_prefs",maxRounds:$}),onKeyDown:x=>{x.key==="Enter"&&(ae({type:"set_goal_prefs",maxRounds:$}),x.target.blur())}})]}),s.jsx("span",{className:"goalbar-lock-hint",children:o(I?"goalBarLocked":"goalBarUnlocked")})]})]})});function Mf(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 Xo=2e3;function Bf(e,t,n=Xo){return e.filter(i=>t-i.t<=n)}function Ff(e,t=Xo){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 sr(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 Hf(e){let t=0;for(const n of e)n.type==="text"&&typeof n.text=="string"&&n.text?t+=sr(n.text):n.type==="thinking"&&typeof n.thinking=="string"&&n.thinking&&(t+=sr(n.thinking));return t}const bt="@root";function Uf({chat:e}){const t=Pe(),{engine:n}=wa(),i=e.state,[a,o]=c.useState(!1),[l,u]=c.useState(""),[m,E]=c.useState(""),[h,g]=c.useState(!1),[w,k]=c.useState(""),[_,M]=c.useState(-1),$=c.useRef(null),S=c.useRef(null),I=e.pathCompletions.filter(oe=>oe.type==="dir"),j=oe=>oe.endsWith("/")?oe:oe+"/",H=oe=>{let he=oe.endsWith("/")&&oe!=="/"?oe.slice(0,-1):oe;if(he===bt||he==="/")return null;const W=he.lastIndexOf("/");if(W<0)return/^[A-Za-z]:$/.test(he)?bt:null;if(W===0)return"/";const ce=he.slice(0,W);return/^[A-Za-z]:$/.test(ce)?ce+"/":ce};c.useEffect(()=>{if(!a)return;const oe=setTimeout(()=>{ae({type:"complete_path",path:j(l)})},60);return()=>clearTimeout(oe)},[l,a]),c.useEffect(()=>{if(!a||m===l)return;const oe=setTimeout(()=>{ae({type:"complete_path",path:m})},150);return()=>clearTimeout(oe)},[m,l,a]);const ee=c.useRef([]),J=i?.isStreaming??!1,ue=i?.streamingMessage?Hf(i.streamingMessage.content):0;if(c.useEffect(()=>{if(!J){ee.current=[];return}const oe=Date.now(),he=ee.current,W=he[he.length-1];W&&oe-W.t<250||(ee.current=Bf([...he,{t:oe,out:ue}],oe))},[J,ue]),!i)return null;const pe=i.stats,G=Mf(pe.tokens),Y=G.hitRate*100,ge=G.totalInput===0?"":G.hitRate>=.7?"ok":G.hitRate>=.4?"mid":"warn",O=G.totalInput>0?`${Y.toFixed(1)}%`:"—",R=J?Ff(ee.current):0,x=e.ready?"ok":"busy",D=e.ready?t("connected"):t("connecting"),U=pe.contextUsage,C=U.tokens!==null&&U.percent!==null?`${U.estimated?"~":""}${es(U.tokens)} / ${es(U.contextWindow)}`:"—",Z=U.percent??null,X=Z===null?"":Z>=80?"warn":Z>=50?"mid":"ok",ve=i.queue.steering.length+i.queue.followUp.length,N=()=>{const oe=i.cwd.replace(/\\/g,"/");E(oe),u(oe),g(!1),k(""),o(!0)},z=oe=>{const he=oe.trim();he!==bt&&(he&&he!==i.cwd&&ae({type:"set_cwd",path:he}),o(!1))},de=()=>{const oe=w.trim();oe&&(ae({type:"make_dir",path:`${j(l)}${oe}`}),setTimeout(()=>{ae({type:"complete_path",path:j(l)})},80),k(""),g(!1))},re=oe=>{if(oe.key==="Escape")oe.stopPropagation(),o(!1);else if(oe.key==="Enter"&&!oe.nativeEvent.isComposing)z(m);else if(oe.key==="Tab"){if(I.length===0)return;oe.preventDefault();const he=_>=0?(_+1)%I.length:0;M(he),E(I[he].path),u(I[he].path)}},ke=H(l);return s.jsxs("footer",{className:"statusbar",children:[s.jsx("span",{className:`status-dot ${x}`,title:D}),s.jsx("span",{className:"status-item",children:D}),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 ${X}`,children:Z!==null&&s.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min(Z,100)}%`}})}),C]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:t("cumulativeCost"),children:["$",qf(pe.cost)]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item status-cache",title:t("cacheHitTip",{read:es(G.read),write:es(G.write),miss:es(G.miss),input:es(G.totalInput)}),children:[t("cacheHit"),s.jsx("b",{className:`cache-pct ${ge}`,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(oe=>oe.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"),ve>0&&s.jsxs("span",{className:"status-queue",children:["⏳ ",ve," ",t("queued")]})]}),s.jsxs("span",{className:"status-item status-rate",title:t("rateTip"),children:[s.jsx("span",{className:"working-spin rate-spin"}),R>0?`${Math.round(R)}${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:!ke,title:t("cwdGoUp"),onClick:()=>{ke&&(u(ke),E(ke),M(-1))},children:["↑ ",t("cwdGoUp")]})]}),s.jsxs("div",{className:"cwd-picker-row",children:[s.jsx("input",{ref:$,className:"status-cwd-input cwd-picker-input",value:m,placeholder:t("enterPath"),spellCheck:!1,onChange:oe=>{E(oe.target.value),M(-1)},onKeyDown:re}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",title:t("cwdPickCurrent"),disabled:l===bt,onClick:()=>z(l),children:t("cwdPickCurrent")})]}),s.jsxs("div",{className:"cwd-list",children:[I.length===0&&s.jsx("div",{className:"cwd-empty",children:t("cwdEmpty")}),I.map(oe=>s.jsxs("div",{className:"cwd-item",children:[s.jsxs("button",{type:"button",className:"cwd-enter",title:`${t("cwdEnter")} ${oe.path}`,onClick:()=>{u(oe.path),E(oe.path),M(-1)},children:[s.jsx(Bt,{}),s.jsx("span",{className:"cwd-name",children:oe.name})]}),s.jsx("button",{type:"button",className:"cwd-choose-btn",title:t("cwdChoose"),onClick:()=>z(oe.path),children:t("cwdChoose")})]},oe.path))]}),s.jsx("div",{className:"cwd-picker-foot",children:h?s.jsxs("div",{className:"cwd-newrow",children:[s.jsx("input",{ref:S,value:w,autoFocus:!0,spellCheck:!1,placeholder:t("cwdNewName"),onChange:oe=>k(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&!oe.nativeEvent.isComposing?(oe.preventDefault(),de()):oe.key==="Escape"&&(oe.stopPropagation(),g(!1),k(""))}}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",onClick:de,children:t("cwdCreate")}),s.jsx("button",{type:"button",className:"cwd-choose-btn",onClick:()=>{g(!1),k("")},children:t("cwdCancel")})]}):s.jsxs("button",{type:"button",className:"cwd-newbtn",onClick:()=>g(!0),children:["+ ",t("cwdNewFolder")]})})]})]}):s.jsxs("button",{type:"button",className:"status-item status-cwd",title:t("cwdTip",{path:i.cwd}),onClick:N,children:["📁 ",i.cwd]})]})}function es(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(e)}function qf(e){return e<=0?"0":e<1e-4?"<0.0001":e.toFixed(4).replace(/\.?0+$/,"")}function $f({dialog:e}){const t=Pe(),[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=h=>{h.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]:[],m=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,h)=>s.jsx("button",{type:"button",className:`dialog-option ${h===a?"sel":""}`,onMouseEnter:()=>o(h),onClick:()=>l(E),children:s.jsx(rt,{text:E,rawHtml:!0})},h)),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:m,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:m||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 Wf({question:e}){const t=Pe(),[n,i]=c.useState({}),[a,o]=c.useState({}),[l,u]=c.useState(0),[m,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 j=setInterval(()=>{E(H=>{const ee=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return ee<=0&&H>0&&ae({type:"question_answer",id:e.id,answers:[],cancelled:!0}),ee})},1e3);return()=>clearInterval(j)},[e.id,e.deadline]),c.useEffect(()=>{const j=H=>{H.key==="Escape"&&k()};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[e.id]);const h=e.questions.length,g=e.questions[l];if(!g)return null;const w=j=>{const H=e.questions.map(ee=>{const J=j[ee.id]??[],ue=(a[ee.id]??"").trim();return{id:ee.id,selected:J,...ue?{custom:ue}:{}}});ae({type:"question_answer",id:e.id,answers:H})},k=()=>{ae({type:"question_answer",id:e.id,answers:[],cancelled:!0})},_=(j,H)=>{i(ee=>{const J=ee[j]??[];return{...ee,[j]:J.includes(H)?J.filter(ue=>ue!==H):[...J,H]}})},M=(j,H,ee)=>{if(ee){_(j,H);return}const J={...n,[j]:[H]};i(J),l===h-1?w(J):u(l+1)},$=()=>{l===h-1?w(n):u(l+1)},S=j=>(e.questions.find(ee=>ee.id===j)?.options?.length??0)===0?!0:(n[j]?.length??0)>0||(a[j]??"").trim()!=="",I=(g.options??[]).filter(j=>(n[g.id]??[]).includes(j.label)&&j.preview).map(j=>j.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")}),h>1&&s.jsx("span",{className:"question-progress",children:t("questionStep",{cur:l+1,total:h})}),m>=0&&s.jsx("span",{className:"question-timer",children:m>0?t("questionTimeout",{s:m}):t("questionTimeoutExpired")}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:t("cancel"),onClick:k,children:"✕"})]}),s.jsxs("div",{className:"set-section",children:[s.jsx("div",{className:"set-section-title",children:g.header??`${t("modelQuestion")} ${l+1}`}),s.jsx("div",{className:"question-head",children:s.jsx(rt,{text:g.question,rawHtml:!0})}),g.detail&&s.jsx("div",{className:"set-hint",children:s.jsx(rt,{text:g.detail,rawHtml:!0})}),(g.options?.length??0)>0&&s.jsx("div",{className:"set-list",children:g.options.map(j=>{const H=(n[g.id]??[]).includes(j.label);return s.jsxs("button",{type:"button",className:`set-row question-option${H?" active":""}`,onClick:()=>M(g.id,j.label,!!g.multiSelect),children:[s.jsxs("div",{className:"set-row-name",children:[s.jsx("span",{className:"question-mark",children:g.multiSelect?H?"☑ ":"☐ ":H?"● ":"○ "}),s.jsx(rt,{text:j.label,rawHtml:!0})]}),j.description&&s.jsx("div",{className:"set-row-desc",children:s.jsx(rt,{text:j.description,rawHtml:!0})})]},j.label)})}),I.length>0&&s.jsxs("div",{className:"question-preview",children:[s.jsx("div",{className:"question-preview-label",children:t("optionPreview")}),I.map((j,H)=>s.jsx("div",{className:"question-preview-body",children:s.jsx(rt,{text:j,rawHtml:!0})},H))]}),s.jsx("input",{className:"set-prompt-input question-custom",placeholder:t("modelQuestionCustom"),value:a[g.id]??"",onChange:j=>o(H=>({...H,[g.id]:j.target.value})),onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),S(g.id)&&$())}})]},g.id),s.jsxs("div",{className:"dialog-nav",children:[s.jsx("button",{type:"button",className:"dialog-dismiss-inline",onClick:k,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:!S(g.id),onClick:$,children:l===h-1?t("modelQuestionSubmit"):t("next")})]})]})]})}const nr=e=>`'${e.replace(/'/g,"'\\''")}'`;function Kf(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 Yf({chat:e,terminal:t,active:n,onSwitchToTerminal:i}){const a=Pe(),[o,l]=c.useState(null),[u,m]=c.useState([]),[E,h]=c.useState(""),[g,w]=c.useState(new Map),[k,_]=c.useState("changes"),[M,$]=c.useState([]),[S,I]=c.useState(null),[j,H]=c.useState(""),[ee,J]=c.useState(!1),[ue,pe]=c.useState(null),[G,Y]=c.useState(null),[ge,O]=c.useState(!1),[R,x]=c.useState(!1),[D,U]=c.useState(!1),[C,Z]=c.useState(null),[X,ve]=c.useState(!1),[N,z]=c.useState(""),de=c.useRef(0),re=c.useRef(-1),ke=c.useRef(-1),oe=c.useRef(-1),he=c.useRef(-1),W=c.useRef(void 0),ce=c.useRef(null),F=c.useRef([]),Le=c.useCallback(v=>{if(v.reqId===re.current){if(re.current=-1,x(!1),Z(null),!v.ok){Z(v.error??a("scmQueryFailedShort"));return}if(v.notRepo){ve(!0),l(null),m([]),w(new Map),$([]),I(null),H(""),Y(null);return}ve(!1);const te={branch:v.branch??"",detached:!!v.detached,upstream:v.upstream??null,ahead:v.ahead??0,behind:v.behind??0,upstreamGone:!!v.upstreamGone,files:(v.files??[]).map(Ie=>({...Ie}))},me=(v.branches??[]).map(Ie=>({...Ie})),je=new Map;for(const[Ie,Ge]of Object.entries(v.stats??{}))je.set(Ie,{add:Ge[0],del:Ge[1]});l(te),m(me),w(je),h(Ie=>te.detached?Ie||"":te.branch&&me.some(Ge=>Ge.name===te.branch)?te.branch:Ie&&me.some(Ge=>Ge.name===Ie)?Ie:me[0]?.name??""),Y(Ie=>Ie&&!te.files.some(Ge=>Ge.path===Ie.file.path)?null:Ie)}else if(v.reqId===ke.current){if(ke.current=-1,O(!1),!v.ok){Z(v.error??a("scmQueryFailedShort"));return}const te=ce.current;if(!te)return;Y({file:te,staged:v.stagedText??"",worktree:v.worktreeText??"",untracked:!1})}else if(v.reqId===he.current){if(he.current=-1,U(!1),!v.ok){Z(v.error??a("scmQueryFailedShort"));return}$((v.history??[]).map(te=>({...te})))}else if(v.reqId===oe.current){if(oe.current=-1,J(!1),!v.ok){Z(v.error??a("scmQueryFailedShort"));return}H(v.text??"")}},[]);c.useEffect(()=>{const v=e.scmData;v&&v.type==="scm_data"&&Le(v)},[e.scmData,Le]);const Oe=c.useCallback((v,te)=>{if(!e.ready||e.status!=="open")return!1;const me=++de.current;return ae({...v,reqId:me})?(te.current=me,!0):(de.current-=1,!1)},[e.ready,e.status]),P=c.useCallback((v=!1,te=!1)=>{!e.ready||e.status!=="open"||e.state?.cwd&&(W.current!==void 0&&W.current!==e.state.cwd&&(l(null),m([]),w(new Map),$([]),U(!1),he.current=-1,I(null),H(""),Y(null),pe(null)),W.current=e.state.cwd,Z(null),Oe({type:"scm_status"},re)&&(te||x(!0)))},[e.ready,e.state?.cwd,e.status,Oe]),ye=c.useCallback(v=>{if(pe(v),I(null),ce.current=v,v.x==="?"&&v.y==="?"){Y({file:v,staged:"",worktree:"",untracked:!0});return}O(!0),Z(null),Oe({type:"scm_filediff",path:v.path},ke)||O(!1)},[Oe]),fe=c.useCallback(v=>{I(v),pe(null),Y(null),H(""),J(!0),Z(null),Oe({type:"scm_commit",hash:v.hash},oe)||J(!1)},[Oe]),Te=c.useCallback((v,te)=>{if(!e.ready)return;const me={name:v,command:te,cwd:"${pwd}"};let je;const Ie=e.terminals.find(Ge=>Ge.title===v);Ie?(t.restart(Ie.id),ae({type:"run_command",terminalId:Ie.id,conversationId:Ie.conversationId,command:me,cols:80,rows:24}),je=Ie.id):(je=wt(),t.create({id:je,conversationId:e.activeConversationId||e.state?.conversationId||"",title:v,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:me})),t.select(je),i()},[e.ready,e.state?.cwd,e.terminals,i,t]),Ne=c.useCallback(()=>{const v=N.trim();if(!v||X)return;const te=v.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");Te("git commit",`git commit -m "${te}"`),z("")},[N,X,Te]),Se=c.useCallback(()=>{const v=N.trim();if(!v||X)return;const te=v.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");Te("git commit",`git add -A && git commit -m "${te}"`),z("")},[N,X,Te]),Ce=c.useCallback(v=>{X||Te("git add",`git add -- ${nr(v.path)}`)},[X,Te]),T=c.useCallback(v=>{X||Te("git reset",`git reset HEAD -- ${nr(v.path)}`)},[X,Te]),le=c.useCallback(()=>{if(!E||X)return;const v=u.find(te=>te.name===E);if(v?.remote&&typeof v.remote=="string"){const te=E.slice(v.remote.length+1);Te("git checkout",`git checkout -b ${te} ${E} || git checkout ${E}`)}else Te("git checkout",`git checkout ${E}`)},[E,u,X,Te]),se=c.useCallback(()=>Te("git push","git push"),[Te]),Ee=c.useCallback(()=>Te("git pull","git pull"),[Te]),Re=c.useCallback(()=>{Oe({type:"scm_history"},he)||(he.current=-1)},[Oe]);c.useEffect(()=>{n&&P()},[n,P]),c.useEffect(()=>{k==="history"&&o&&Re()},[k,o,Re]),c.useEffect(()=>{e.scmDirty>0&&n&&P(!1,!0)},[e.scmDirty]),c.useEffect(()=>{if(!n||!e.ready||e.status!=="open")return;const v=setInterval(()=>{document.visibilityState!=="hidden"&&P(!1,!0)},3e4);return()=>clearInterval(v)},[n,e.ready,e.status,P]),c.useEffect(()=>{const v=F.current;if(F.current=e.terminals,!n)return;e.terminals.some(me=>me.running!==!1?!1:v.find(Ie=>Ie.id===me.id)?.running===!0&&me.title.startsWith("git "))&&e.ready&&e.status==="open"&&(P(!1,!0),k==="history"&&o&&Re())},[e.terminals,n,e.ready,e.status,P,k,o,Re]);const y={staged:a("scmStaged"),unstaged:a("scmUnstaged"),untracked:a("scmUntracked"),both:a("scmStagedUnstaged")},ie=v=>{const te=v.split(`
329
- `);return s.jsx("pre",{className:"scm-diff-pre",children:te.map((me,je)=>{let Ie="";return me.startsWith("diff --git")||me.startsWith("index ")||me.startsWith("new file")||me.startsWith("deleted file")||me.startsWith("old mode")||me.startsWith("new mode")||me.startsWith("similarity index")||me.startsWith("rename ")||me.startsWith("copy ")||me.startsWith("Binary files")||me.startsWith("---")||me.startsWith("+++")?Ie="hdr":me.startsWith("@@")?Ie="hunk":me.startsWith("+")?Ie="add":me.startsWith("-")&&(Ie="del"),s.jsx("div",{className:`scm-diff-line ${Ie}`,children:me||" "},je)})})};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":k==="changes",className:k==="changes"?"active":"",onClick:()=>{_("changes"),Z(null)},children:a("scmChanges")}),s.jsx("button",{type:"button",role:"tab","aria-selected":k==="history",className:k==="history"?"active":"",onClick:()=>{_("history"),Z(null)},children:a("scmHistory")})]}),s.jsx("button",{type:"button",className:"panel-refresh",title:a("scmRefreshTip"),disabled:R,onClick:()=>P(!0),children:s.jsx(kt,{className:R?"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:X||u.length===0,title:a("scmSwitchBranch"),onChange:v=>h(v.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:a("scmSelectBranch")}),u.filter(v=>!v.remote).map(v=>s.jsx("option",{value:v.name,children:v.current?`* ${v.name}`:v.name},v.name)),u.some(v=>v.remote)&&s.jsx("optgroup",{label:a("scmRemoteBranches"),children:u.filter(v=>v.remote).map(v=>s.jsx("option",{value:v.name,children:v.name},v.name))})]}),s.jsxs("button",{type:"button",className:"btn",disabled:!E||E===o?.branch||X,title:a("scmSwitchBranchTip",{branch:E}),onClick:le,children:[s.jsx(Qs,{}),a("scmSwitch")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!o||o.detached||X,title:a("scmPushTip"),onClick:se,children:[s.jsx(aa,{}),a("scmPush")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!o||o.detached||X,title:a("scmPullTip"),onClick:Ee,children:[s.jsx(Sr,{}),a("scmPull")]}),s.jsx("input",{className:"scm-commit-input",value:N,placeholder:a("scmCommitPlaceholder"),disabled:X,onChange:v=>z(v.target.value),onKeyDown:v=>{v.key==="Enter"&&!v.nativeEvent.isComposing&&Ne()}}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!N.trim()||X,title:a("scmCommitTip"),onClick:Ne,children:[s.jsx(Tt,{}),a("scmCommit")]}),s.jsx("button",{type:"button",className:"btn",disabled:!N.trim()||X,title:a("scmCommitAllTip"),onClick:Se,children:a("scmCommitAll")})]})]}),s.jsxs("div",{className:"scm-body",children:[k==="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:X?s.jsx("div",{className:"scm-empty",children:a("scmNotGitRepo")}):!o||D?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(v=>s.jsxs("button",{type:"button",className:`scm-commit ${S?.hash===v.hash?"active":""}`,onClick:()=>fe(v),title:v.hash,children:[s.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:v.graph||"* "}),s.jsxs("span",{className:"scm-commit-info",children:[s.jsx("span",{className:"scm-commit-subject",children:v.subject}),s.jsxs("span",{className:"scm-commit-meta",children:[v.shortHash," · ",v.author," · ",v.date]}),v.decorations&&s.jsx("span",{className:"scm-commit-refs",children:v.decorations})]})]},v.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:X?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(v=>{const te=Kf(v),me=g.get(v.path);return s.jsxs("div",{className:`scm-file ${ue?.path===v.path?"active":""}`,title:y[te],onClick:()=>ye(v),children:[s.jsx("span",{className:`scm-file-xy ${te==="untracked"?"q":"x"}`,children:v.x!==" "?v.x:" "}),s.jsx("span",{className:`scm-file-xy ${te==="untracked"?"q":"y"}`,children:v.y!==" "?v.y:" "}),s.jsx("span",{className:"scm-file-path",children:v.path}),me&&(me.add>0||me.del>0)&&s.jsxs("span",{className:"scm-file-stat",children:[me.add>0&&s.jsxs("span",{className:"add",children:["+",me.add]}),me.del>0&&s.jsxs("span",{className:"del",children:["-",me.del]})]}),s.jsxs("span",{className:"scm-file-actions",children:[(v.y!==" "||te==="untracked")&&s.jsx("button",{type:"button",className:"scm-act",title:a("scmStageTip",{path:v.path}),onClick:je=>{je.stopPropagation(),Ce(v)},children:"+"}),te==="staged"||te==="both"?s.jsx("button",{type:"button",className:"scm-act",title:a("scmUnstageTip",{path:v.path}),onClick:je=>{je.stopPropagation(),T(v)},children:"−"}):null]})]},v.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:k==="history"?S?`${S.shortHash} ${S.subject}`:a("scmCommitDetail"):ue?ue.path:a("scmDiff")}),(k==="history"?ee:ge)&&s.jsx("span",{className:"scm-diff-loading",children:a("scmLoading")})]}),s.jsx("div",{className:"scm-diff-body",children:k==="history"?s.jsxs(s.Fragment,{children:[C&&s.jsx("div",{className:"scm-error",children:C}),!S&&!C&&s.jsx("div",{className:"scm-empty",children:a("scmSelectCommitHint")}),S&&ee&&!C&&s.jsx("div",{className:"scm-empty",children:a("scmLoading")}),S&&!ee&&!C&&j?ie(j):null]}):s.jsxs(s.Fragment,{children:[C&&s.jsx("div",{className:"scm-error",children:C}),!ue&&!C&&s.jsx("div",{className:"scm-empty",children:a("scmSelectFileHint")}),ue&&!G&&!C&&s.jsx("div",{className:"scm-empty",children:a("scmLoading")}),ue&&G&&G.untracked&&s.jsx("div",{className:"scm-empty",children:a("scmUntrackedNote")}),ue&&G&&!G.untracked&&s.jsxs(s.Fragment,{children:[G.staged&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:a("scmStaged")}),ie(G.staged)]}),G.worktree&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:a("scmUnstaged")}),ie(G.worktree)]}),!G.staged&&!G.worktree&&s.jsx("div",{className:"scm-empty",children:a("scmNoDiff")})]})]})})]})]}),s.jsxs("div",{className:"scm-hint",children:[s.jsx(An,{}),s.jsx("span",{children:a("scmRunsInTerminal")}),s.jsx("button",{type:"button",className:"scm-goto-term",onClick:i,children:a("scmViewTerminal")})]})]})}function Gf({entry:e}){const t=c.useRef(null),n=Pe();return c.useEffect(()=>{const i=t.current;if(!i)return;let a;try{a=e.module.mount(i,Eu(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 ar="__piWebUiHost",Vf=1,zf=e=>new Promise(t=>setTimeout(t,e));function Qf(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 zf(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 m=e.getConversationId();e.send({type:"new_chat"}),await i(()=>e.getConversationId()!==m||e.isConversationBlank())}e.send({type:"prompt",text:o})};return{version:Vf,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)}}}function ir(e){try{const t=window;e?t[ar]=e:delete t[ar]}catch{}}function Xf({piConfigured:e,piAgentInstalled:t,providers:n,installResult:i,onClose:a}){const o=Pe(),l=Fr(),[u,m]=c.useState(!1),[E,h]=c.useState(""),[g,w]=c.useState(""),[k,_]=c.useState(!1);c.useEffect(()=>{ae({type:"list_providers"})},[]),c.useEffect(()=>{e&&a()},[e,a]),c.useEffect(()=>{i&&m(!1)},[i]),c.useEffect(()=>{!E&&n.length>0&&h(n.find(H=>!H.configured)?.id??n[0].id)},[n,E]);const M=()=>{u||(m(!0),ae({type:"install_pi_agent"}))},$=()=>{!g.trim()||k||(_(!0),ae({type:"set_provider_api_key",provider:E.trim(),apiKey:g.trim()}),setTimeout(()=>_(!1),3e3))},S=()=>{ae({type:"get_state"}),ae({type:"list_providers"})},I=n.find(H=>H.id===E),j=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")}),j?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=>h(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))]}),I?.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:g,onChange:H=>w(H.target.value),placeholder:"sk-…"})]}),s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:!g.trim()||k||!E,onClick:$,children:o(k?"saving":"saveAndStart")}),s.jsxs("button",{type:"button",className:"btn",onClick:S,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 Jf=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],Fa=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),Zf=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[Fa()]});function Jn(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:[Fa()]).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 e0({providers:e,providerStatus:t,providerKeys:n,fetchModelsResult:i,cloneProviderResult:a,onClose:o}){const l=Pe(),[u,m]=c.useState(null),[E,h]=c.useState({}),[g,w]=c.useState({}),[k,_]=c.useState(null),[M,$]=c.useState(!1),[S,I]=c.useState(0),[j,H]=c.useState(null),ee=c.useRef(0),[J,ue]=c.useState(null),[pe,G]=c.useState(""),[Y,ge]=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 N=u.baseUrl.trim();if(!N){H({ok:!1,text:l("fetchModelsNeedBaseUrl")});return}if(M)return;$(!0),H(null);const z=S+1;I(z),ae({type:"fetch_models",reqId:z,baseUrl:N,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader,api:u.api})};c.useEffect(()=>{if(!(!i||i.reqId===ee.current))if(ee.current=i.reqId,$(!1),i.ok&&i.models?.length){const N=i.models;m(z=>{if(!z)return z;const de=z.models.map(he=>{if(!he.id.trim())return he;const W=N.find(F=>F.id===he.id.trim());if(!W)return he;const ce={...he};return!ce.name&&W.name&&(ce.name=W.name),!ce.contextWindow&&W.contextWindow&&(ce.contextWindow=String(W.contextWindow)),!ce.maxTokens&&W.maxTokens&&(ce.maxTokens=String(W.maxTokens)),ce.input==="text"&&W.input?.includes("image")&&(ce.input="text-image"),!ce.reasoning&&W.reasoning&&(ce.reasoning=!0),ce}),re=new Set(de.map(he=>he.id.trim()).filter(Boolean)),ke=N.filter(he=>!re.has(he.id)).map(he=>({id:he.id,name:he.name??"",reasoning:he.reasoning??!1,input:he.input?.includes("image")?"text-image":"text",contextWindow:he.contextWindow?String(he.contextWindow):"",maxTokens:he.maxTokens?String(he.maxTokens):""})),oe=[...de,...ke];return oe.some(he=>he.id.trim())?{...z,models:oe.filter(he=>he.id.trim())}:z}),H({ok:!0,text:l("fetchModelsOk",{n:N.length})})}else H({ok:!1,text:i.error||l("fetchModelsEmpty")})},[i]);const R=N=>{const z=(E[N.id]??"").trim();!z||k||(_(N.id),ae({type:"add_provider_key",provider:N.id,apiKey:z,name:(g[N.id]??"").trim()||void 0}),setTimeout(()=>{_(null),h(de=>({...de,[N.id]:""})),w(de=>({...de,[N.id]:""})),ae({type:"list_providers"}),ae({type:"list_provider_keys"})},1500))},x=(N,z)=>{ae({type:"activate_provider_key",provider:N,keyName:z}),ae({type:"list_provider_keys"})},D=(N,z)=>{window.confirm(l("removeKeyConfirm"))&&(ae({type:"remove_provider_key",provider:N,keyName:z}),ae({type:"list_provider_keys"}))},U=()=>{if(!Y)return;const N=Y.providerId.trim();if(!N||!Y.apiKey.trim())return;const z=Y.models.filter(re=>re.id.trim()).map(re=>({id:re.id.trim(),name:re.name.trim()||void 0,reasoning:re.reasoning||void 0,input:re.input==="text-image"?["text","image"]:void 0,contextWindow:re.contextWindow?Number(re.contextWindow):void 0,maxTokens:re.maxTokens?Number(re.maxTokens):void 0})),de={providerId:N,name:Y.name.trim()||void 0,api:Y.api.trim()||void 0,baseUrl:Y.baseUrl.trim()||void 0,apiKey:Y.apiKey.trim()||void 0,authHeader:Y.authHeader||void 0,models:z};ae({type:"save_model_config",providerId:N,config:de}),ge(null),o()},C=()=>{if(!u)return;const N=u.providerId.trim(),z=u.models.filter(re=>re.id.trim()).map(re=>({id:re.id.trim(),name:re.name.trim()||void 0,reasoning:re.reasoning||void 0,input:re.input==="text-image"?["text","image"]:void 0,contextWindow:re.contextWindow?Number(re.contextWindow):void 0,maxTokens:re.maxTokens?Number(re.maxTokens):void 0})),de={providerId:N,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:z};ae({type:"save_model_config",providerId:N,config:de}),o()};c.useEffect(()=>{if(a&&a.ok){const N=a.configs;if(N&&N.length>1){ue(N.map(z=>Jn({...z,apiKey:""}))),G("");return}if(a.config){ge(Jn({...a.config,apiKey:""}));return}}},[a]);const Z=N=>{window.confirm(l("clearKeyConfirm",{id:N}))&&ae({type:"clear_provider_api_key",provider:N})},X=N=>{window.confirm(l("deleteProviderConfirm",{id:N.providerId,n:N.models.length}))&&ae({type:"delete_model_config",providerId:N.providerId})},ve=(N,z)=>{u&&m({...u,models:u.models.map((de,re)=>re===N?{...de,...z}:de)})};return s.jsx("div",{className:"modal-backdrop",onClick:o,children:s.jsxs("div",{className:"modal model-modal",onClick:N=>N.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:Y?l("addKey"):J?l("batchCreateProviders",{n:J.length}):l(u?"editProvider":"manageModelsTitle")})}),Y?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:Y.api,baseUrl:Y.baseUrl||l("noBaseUrlShort"),n:Y.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:Y.providerId,onChange:N=>ge({...Y,providerId:N.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:Y.apiKey,onChange:N=>ge({...Y,apiKey:N.target.value}),placeholder:l("secondKeyPlaceholder")})]})]}),s.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:8},children:[Y.models.slice(0,5).map(N=>N.id).join(", "),Y.models.length>5?` … +${Y.models.length-5}`:""]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>ge(null),children:l("cancel")}),s.jsx("button",{type:"button",className:"btn",onClick:()=>{const N=Y;ge(null),m(N)},children:l("advancedEdit")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!Y.providerId.trim()||!Y.apiKey.trim(),onClick:U,children:l("save")})]})]}):J?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:J.map(N=>N.api).join("、"),n:J.length})}),s.jsxs("label",{className:"field",style:{marginBottom:16},children:[s.jsx("span",{className:"field-label",children:l("batchKeyLabel",{n:J.length})}),s.jsx("input",{type:"password",value:pe,onChange:N=>G(N.target.value),placeholder:l("secondKeyPlaceholder")})]}),s.jsx("div",{className:"provider-list",style:{marginBottom:16},children:J.map((N,z)=>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:N.providerId}),s.jsx("span",{style:{opacity:.7},children:N.api})]}),s.jsxs("div",{className:"provider-sub",style:{fontSize:12,opacity:.7},children:[N.baseUrl||l("noBaseUrlShort")," · ",l("modelsCountShort",{n:N.models.length}),N.models.slice(0,3).map(de=>de.id).join(", "),N.models.length>3?` … +${N.models.length-3}`:""]}),s.jsx("input",{type:"text",value:N.providerId,onChange:de=>ue(re=>re.map((ke,oe)=>oe===z?{...ke,providerId:de.target.value}:ke)),placeholder:l("providerIdPlaceholder"),style:{fontSize:12}}),s.jsx("input",{type:"text",value:N.baseUrl,onChange:de=>ue(re=>re.map((ke,oe)=>oe===z?{...ke,baseUrl:de.target.value}:ke)),placeholder:l("baseUrlExamplePh"),style:{fontSize:12}})]},z))})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>ue(null),children:l("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!pe.trim(),onClick:()=>{for(const N of J){const z=N.providerId.trim();if(!z)continue;const de=N.models.filter(ke=>ke.id.trim()).map(ke=>({id:ke.id.trim(),name:ke.name.trim()||void 0,reasoning:ke.reasoning||void 0,input:ke.input==="text-image"?["text","image"]:void 0,contextWindow:ke.contextWindow?Number(ke.contextWindow):void 0,maxTokens:ke.maxTokens?Number(ke.maxTokens):void 0})),re={providerId:z,name:N.name.trim()||void 0,api:N.api.trim()||void 0,baseUrl:N.baseUrl.trim()||void 0,apiKey:pe.trim()||void 0,authHeader:N.authHeader||void 0,models:de};ae({type:"save_model_config",providerId:z,config:re})}ue(null),o()},children:l("saveAllBatch",{n:J.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(N=>N.providerId===u.providerId),onChange:N=>m({...u,providerId:N.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:N=>m({...u,name:N.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:N=>m({...u,api:N.target.value}),children:Jf.map(N=>s.jsx("option",{value:N,children:N},N))})]}),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:N=>m({...u,baseUrl:N.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:N=>m({...u,apiKey:N.target.value}),placeholder:l("apiKeyHint")})]}),s.jsxs("label",{className:"field check",children:[s.jsx("input",{type:"checkbox",checked:u.authHeader,onChange:N=>m({...u,authHeader:N.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:[j&&s.jsx("span",{className:`fetch-msg ${j.ok?"ok":"err"}`,title:j.text,children:j.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((N,z)=>s.jsxs("div",{className:"model-row",children:[s.jsx("input",{type:"text",value:N.id,onChange:de=>ve(z,{id:de.target.value}),placeholder:l("modelIdReq")}),s.jsx("input",{type:"text",value:N.name,onChange:de=>ve(z,{name:de.target.value}),placeholder:l("displayName")}),s.jsxs("select",{value:N.input,onChange:de=>ve(z,{input:de.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:N.reasoning,onChange:de=>ve(z,{reasoning:de.target.checked})}),s.jsx("span",{children:l("reasoning")})]}),s.jsx("input",{type:"number",value:N.contextWindow,onChange:de=>ve(z,{contextWindow:de.target.value}),placeholder:l("contextWindow"),title:"contextWindow"}),s.jsx("input",{type:"number",value:N.maxTokens,onChange:de=>ve(z,{maxTokens:de.target.value}),placeholder:l("maxOutput"),title:"maxTokens"}),s.jsx("button",{type:"button",className:"iconbtn danger",title:l("removeModel"),onClick:()=>m({...u,models:u.models.filter((de,re)=>re!==z)}),children:s.jsx(et,{})})]},z)),s.jsxs("button",{type:"button",className:"btn",onClick:()=>m({...u,models:[...u.models,Fa()]}),children:[s.jsx(dt,{})," ",l("addModel")]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>m(null),children:l("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!u.providerId.trim()||!u.models.some(N=>N.id.trim()),onClick:C,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(N=>{const z=n[N.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:N.name}),s.jsxs("span",{className:"provider-sub",children:[N.id,N.configured&&s.jsx("span",{className:"auth-badge",children:l("configuredBadge")}),N.source&&!N.configured&&s.jsx("span",{className:"auth-badge dim",children:N.source})]})]}),N.source==="stored"&&s.jsxs("button",{type:"button",className:"btn sm danger",title:l("clearKeyTitle"),onClick:()=>Z(N.id),children:[s.jsx(et,{})," ",l("clearKey")]})]}),s.jsxs("div",{className:"provider-keys",children:[z.length===0&&s.jsx("div",{className:"provider-key-empty",children:l("noKeyYet")}),z.map(de=>s.jsxs("div",{className:`provider-key-item ${de.active?"active":""}`,children:[s.jsx("span",{className:"provider-key-dot",children:de.active?"●":"○"}),s.jsx("span",{className:"provider-key-label",children:de.name}),!de.active&&s.jsx("button",{type:"button",className:"iconbtn",title:l("activateKey"),onClick:()=>x(N.id,de.name),children:s.jsx(Tt,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:l("removeKey"),onClick:()=>D(N.id,de.name),children:s.jsx(et,{})})]},de.name)),s.jsxs("div",{className:"provider-add-key",children:[s.jsx("input",{type:"text",className:"key-input key-input-name",placeholder:l("keyNamePh"),value:g[N.id]??"",onChange:de=>w(re=>({...re,[N.id]:de.target.value}))}),s.jsx("input",{type:"password",className:"key-input key-input-value",placeholder:l("addKeyPlaceholder"),value:E[N.id]??"",onChange:de=>h(re=>({...re,[N.id]:de.target.value}))}),s.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(E[N.id]??"").trim()||k===N.id,onClick:()=>R(N),children:[s.jsx(dt,{})," ",k===N.id?l("savingKey"):l("addKey")]})]})]})]},N.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(N=>s.jsxs("div",{className:"provider-row",children:[s.jsxs("div",{className:"provider-info",children:[s.jsx("span",{className:"provider-name",children:N.providerId}),s.jsxs("span",{className:"provider-sub",children:[N.api??"—",N.baseUrl?` · ${N.baseUrl}`:"",N.models.length>0&&` · ${l("modelsCount",{n:N.models.length})}`]})]}),s.jsxs("div",{className:"provider-actions",children:[s.jsx("button",{type:"button",className:"iconbtn",title:l("edit"),onClick:()=>m(Jn(N)),children:s.jsx(fn,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:l("delete"),onClick:()=>X(N),children:s.jsx(et,{})})]})]},N.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:()=>m(Zf()),children:[s.jsx(dt,{})," ",l("addProvider")]})]})]})]})})}function ze({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))},m=()=>a(!1);return c.useEffect(()=>{if(!i)return;const E=n.current,h=t.current;if(!E||!h)return;const g=E.getBoundingClientRect(),w=h.getBoundingClientRect();let k=w.left-8,_=w.bottom+8;k+g.width>window.innerWidth-8&&(k=Math.max(8,w.right+8-g.width)),_+g.height>window.innerHeight-8&&(_=Math.max(8,w.top-8-g.height)),l(M=>M.left===k&&M.top===_?M:{left:k,top:_})},[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:m,onFocus:u,onBlur:m,onKeyDown:E=>{E.key==="Escape"&&E.target.blur()},children:["?",i&&Yr.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 t0({plugin:e}){const t=Pe(),n=e.settingsSchema??[],[i,a]=c.useState(()=>({...e.settingsValues})),[o,l]=c.useState(!1);if(n.length===0)return null;const u=(g,w)=>a(k=>({...k,[g]:w})),m=n.some(g=>i[g.key]!==e.settingsValues?.[g.key]),E=()=>{l(!0),ae({type:"plugin_settings",pluginId:e.id,values:i}),setTimeout(()=>l(!1),800)},h=()=>a({...e.settingsValues});return s.jsxs("div",{className:"plugin-settings-form",children:[s.jsx("div",{className:"plugin-settings-fields",children:n.map(g=>s.jsxs("label",{className:"plugin-settings-field",title:g.hint,children:[s.jsx("span",{className:"plugin-settings-label",children:g.label}),g.type==="boolean"?s.jsx("input",{type:"checkbox",checked:!!i[g.key],onChange:w=>u(g.key,w.target.checked)}):g.type==="select"?s.jsx("select",{value:String(i[g.key]??""),onChange:w=>u(g.key,w.target.value),children:(g.options??[]).map(w=>s.jsx("option",{value:w,children:w},w))}):s.jsx("input",{type:g.type==="password"?"password":g.type==="number"?"number":"text",value:String(i[g.key]??""),min:g.min,max:g.max,onChange:w=>u(g.key,g.type==="number"?Number(w.target.value):w.target.value)})]},g.key))}),s.jsxs("div",{className:"plugin-settings-actions",children:[s.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!m||o,onClick:E,children:t(o?"pluginSettingsSaving":"pluginSettingsSave")}),s.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:h,children:t("pluginSettingsReset")})]})]})}const Jo="pi-web-ui:wide-chat",Cn={wide:!1};function Zo(e){if(!e||typeof e!="object")return{...Cn};const t=e;return{wide:typeof t.wide=="boolean"?t.wide:Cn.wide}}function s0(){try{const e=localStorage.getItem(Jo);return e?Zo(JSON.parse(e)):{...Cn}}catch{return{...Cn}}}function n0(e){const t=Zo(e);try{localStorage.setItem(Jo,JSON.stringify(t))}catch{}Zs=t;for(const n of Na)n()}let Zs=null;const Na=new Set;function a0(e){return Na.add(e),()=>{Na.delete(e)}}function i0(){return Zs||(Zs=s0()),Zs.wide}function el(){return c.useSyncExternalStore(a0,i0)}const tl="pi-web-ui:project-title",_n={projectName:!0};function sl(e){if(!e||typeof e!="object")return{..._n};const t=e;return{projectName:typeof t.projectName=="boolean"?t.projectName:_n.projectName}}function r0(e){return e?e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"":""}function o0(){try{const e=localStorage.getItem(tl);return e?sl(JSON.parse(e)):{..._n}}catch{return{..._n}}}function l0(e){const t=sl(e);try{localStorage.setItem(tl,JSON.stringify(t))}catch{}en=t;for(const n of ka)n()}let en=null;const ka=new Set;function c0(e){return ka.add(e),()=>{ka.delete(e)}}function u0(){return en||(en=o0()),en.projectName}function nl(){return c.useSyncExternalStore(c0,u0)}const al="pi-web-ui:wallpaper",d0="has-wallpaper",Ls={url:"",dim:78,blur:0},m0=2e3,p0=28e5;function va(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.toLowerCase().startsWith("data:image/")?p0:m0;return t.length>n?"":/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith("/")&&!t.startsWith("//")?t:""}const rr=(e,t,n,i)=>typeof e!="number"||!Number.isFinite(e)?i:Math.min(n,Math.max(t,Math.round(e)));function il(e){if(!e||typeof e!="object")return{...Ls};const t=e;return{url:va(t.url),dim:rr(t.dim,0,95,Ls.dim),blur:rr(t.blur,0,24,Ls.blur)}}function rl(){try{const e=localStorage.getItem(al);return e?il(JSON.parse(e)):{...Ls}}catch{return{...Ls}}}function h0(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/[\r\n]/g,"")}async function f0(e){const t=await Ma(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function tn(){const e=Rs??rl(),t=document.documentElement;e.url?(t.style.setProperty("--bg-image",`url("${h0(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(d0,e.url!==""||n!==""&&n!=="none")}function Es(e){const t=il(e);Rs=t;try{localStorage.setItem(al,JSON.stringify(t))}catch{}for(const n of Ca)n();tn()}let Rs=null;const Ca=new Set;function g0(e){return Ca.add(e),()=>{Ca.delete(e)}}function b0(){return Rs||(Rs=rl()),Rs}function ol(){return c.useSyncExternalStore(g0,b0)}function E0(){const e=ol();c.useEffect(()=>{tn()},[e]),c.useEffect(()=>{const t=()=>tn();return window.addEventListener(Mt,t),tn(),()=>window.removeEventListener(Mt,t)},[])}const Sn={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"]},ll=["soul","tools","guidelines","pi_docs","append","persona","terminal","markers","context","skills","cwd"],T0=["tools","pi_docs","persona","terminal","markers","context","skills","cwd"];function cl(e){return T0.includes(e)}const Vs=ll.map(e=>`{{${e}}}`).join(`
330
-
331
- `),ul=["terminal_create","terminal_list","terminal_close","terminal_input","terminal_key","terminal_read","terminal_wait"],dl=["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",x0=[...ul.map(e=>({name:e,group:"terminal",defaultOn:!1,dshVisible:!0})),...dl.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}];new Set(x0.map(e=>e.name));function y0(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function or(e){return e==="append"?0:cl(e)?2:1}function We({title:e,subtitle:t,tip:n,enabled:i,onToggle:a,action:o}){const l=Pe();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(ze,{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 N0({chat:e,terminal:t,onSwitchToTerminal:n,onClose:i}){const a=Pe(),{locale:o}=Ht(),l=d=>a(d),u=e.settings,{engine:m,managed:E}=wa(),h=m==="dsh",[g,w]=c.useState("prompt"),k=c.useRef(null);c.useEffect(()=>{k.current?.scrollTo({top:0})},[g]),c.useEffect(()=>{g==="plugins"&&h&&ae({type:"dsh_patches_list"})},[g,h]);const[_,M]=c.useState(""),[$,S]=c.useState({}),I=c.useRef(!1),j=c.useRef(null),H=[...ll].sort((d,V)=>or(d)-or(V)),[ee,J]=c.useState(null),[ue,pe]=c.useState({}),[G,Y]=c.useState(""),[ge,O]=c.useState("append"),R=c.useRef(!1),[x,D]=c.useState(""),U=c.useRef(!1),[C,Z]=c.useState(""),[X,ve]=c.useState(null),[N,z]=c.useState(null),[de,re]=c.useState(!1),[ke,oe]=c.useState(!1),he=el(),W=nl(),ce=ol(),[F,Le]=c.useState(ce.url),Oe=c.useRef(!1),P=c.useRef(null),[ye,fe]=c.useState(!1),[Te,Ne]=c.useState(!1);c.useEffect(()=>{Oe.current||Le(ce.url.startsWith("data:")?"":ce.url)},[ce.url]);const Se=async d=>{const V=d.target.files?.[0];if(d.target.value="",!!V){fe(!0),Ne(!1);try{const _e=await f0(V),Qe=_e?va(_e):"";if(!Qe){Ne(!0);return}Le(""),Es({...ce,url:Qe})}finally{fe(!1)}}},[Ce,T]=c.useState(()=>zo()),[le,se]=c.useState(()=>{try{return Os().length}catch{return 0}}),[Ee,Re]=c.useState(!1),y=()=>{try{se(Os().length)}catch{se(0)}};c.useEffect(()=>{g==="prompt-history"&&y()},[g]),c.useEffect(()=>{if(!Ee)return;const d=window.setTimeout(()=>Re(!1),3e3);return()=>window.clearTimeout(d)},[Ee]);const[ie,v]=c.useState(null),[te,me]=c.useState(null),[je,Ie]=c.useState(""),[Ge,Xt]=c.useState(""),[At,Ut]=c.useState(""),[mt,qt]=c.useState(""),[xt,$t]=c.useState(""),[It,L]=c.useState(!1),[K,Ae]=c.useState(""),[we,Me]=c.useState(null);c.useEffect(()=>{u&&(I.current||M(u.promptTemplate??""),S(d=>{const V={};for(const[_e,Qe]of Object.entries(u.promptOverrides??{}))V[_e]=Qe??"";return j.current&&(V[j.current]=d[j.current]??""),V}),O(u.visionBridgePromptMode),!R.current&&(Y(ge==="append"||u.visionBridgePrompt?u.visionBridgePrompt:u.visionBridgeDefaultPrompt||""),U.current||D(u.reviewPrompt)))},[u,ge]);const[He,ot]=c.useState(String(u?.terminalBashIdleMs??15e3));c.useEffect(()=>{ot(String(u?.terminalBashIdleMs??15e3))},[u?.terminalBashIdleMs]);const[yt,ps]=c.useState(String(u?.retryMaxAttempts??6));if(c.useEffect(()=>{ps(String(u?.retryMaxAttempts??6))},[u?.retryMaxAttempts]),!u)return null;const ft=new Set(u.disabledAgentTools??[]),Pn=ft.size,jt=[{id:"prompt",icon:s.jsx(vr,{}),label:a("settingsSystemPrompt")},{id:"prompt-history",icon:s.jsx(na,{}),label:a("settingsPromptHistory"),count:le},...h?[{id:"question",icon:s.jsx(Qa,{}),label:a("settingsQuestionnaire")}]:[{id:"tools",icon:s.jsx(Va,{}),label:a("settingsTools"),count:Pn+(u.disabledMarkers?.length??0)||void 0}],{id:"display",icon:s.jsx(rs,{}),label:a("settingsMessageDisplay")},{id:"quick",icon:s.jsx(ta,{}),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(Bn,{}),label:a("settingsExtensions"),count:u.extensions.length},{id:"plugins",icon:s.jsx(Fn,{}),label:a("settingsUiPlugins"),count:e.plugins.length},{id:"review",icon:s.jsx(zs,{}),label:a("settingsReview"),count:u.reviewSkills.length},...h?[]:[{id:"vision",icon:s.jsx(pn,{}),label:a("settingsVisionBridge")}],{id:"presets",icon:s.jsx(sc,{}),label:a("settingsPresets"),count:u.presets.length},...h?[]:[{id:"subagent-templates",icon:s.jsx(Ga,{}),label:a("settingsSubagentTemplates"),count:u.subagentTemplates.length}]],Hs=new Set(u.disabledSkills),Us=new Set(u.disabledExtensions),Fe=d=>ae({type:"set_settings",...d}),Jt=()=>{if(!we||!u)return;const d=we.value.trim(),V=we.index;if(Me(null),!d||d===u.quickPhrases[V])return;const _e=[...u.quickPhrases];_e[V]=d,Fe({quickPhrases:_e})},q=d=>{const V=new Set(Hs);V.has(d.name)?V.delete(d.name):V.add(d.name),Fe({disabledSkills:[...V]})},xe=new Set(u.skillsFullText??[]),De=d=>{const V=new Set(xe);V.has(d)?V.delete(d):V.add(d),Fe({skillsFullText:[...V]})},Ue=new Set(u.disabledPlugins??[]),Ve=new Set(e.plugins.map(d=>d.id)),Lt=d=>{const V=new Set(Ue);V.has(d.id)?V.delete(d.id):V.add(d.id),Fe({disabledPlugins:[...V]})},st=d=>{const V=new Set(Us);V.has(d.id)?V.delete(d.id):V.add(d.id),Fe({disabledExtensions:[...V]})},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")},gt=d=>{const V=new Set(ft);V.has(d)?V.delete(d):V.add(d),Fe({disabledAgentTools:[...V]})},qs=u.markersEnabled??!0,Tl=new Set(u.disabledMarkers??[]),xl=d=>{const V=new Set(Tl);!V.has(d)?V.add(d):V.delete(d),Fe({disabledMarkers:[...V]})},$s=(d,V)=>{const _e={name:d,command:V,cwd:"${pwd}"};let Qe;const ct=e.terminals.find(qe=>qe.title===d);ct?(t.restart(ct.id),ae({type:"run_command",terminalId:ct.id,conversationId:ct.conversationId,command:_e,cols:80,rows:24}),Qe=ct.id):(Qe=wt(),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:_e})),t.select(Qe),n(),i()},yl=d=>{v(null),$s(`${a("uninstallTitle")} ${d}`,`pi remove npm:${d}`)},Ha=d=>{me(null),$s(`${a("uninstallTitle")} ${d}`,`pi-web-ui uninstall ${d}`)},Ua=(d,V)=>{$s(`${a("pluginUpdate")} ${d}`,`pi-web-ui install ${V} --name ${d} --force`)},Nl=d=>{$s(`${a("pluginInstall")} ${d.id}`,`pi-web-ui install ${d.source} --name ${d.id}`)},kl=d=>{ae({type:"plugin_catalog_remove",id:d})},vl=()=>{const d=je.trim();d&&(ae({type:"plugin_catalog_add",entry:{source:d,...Ge.trim()?{id:Ge.trim()}:{},...At.trim()?{name:At.trim()}:{},...mt.trim()?{description:mt.trim()}:{},...xt.trim()?{icon:xt.trim()}:{}}}),Ie(""),Xt(""),Ut(""),qt(""),$t(""),L(!1))},Cl=d=>{const V=new Set(u.reviewSkills.filter(_e=>!_e.enabled).map(_e=>_e.name));V.has(d.name)?V.delete(d.name):V.add(d.name),Fe({reviewDisabledSkills:[...V]})},_l=()=>Fe({promptTemplate:_}),Sl=d=>{Fe({promptOverrides:{[d]:$[d]??""}})},On=d=>{j.current===d&&(j.current=null),J(null),S(V=>{const _e={...V};return delete _e[d],_e}),Fe({promptOverrides:{[d]:""}})},hs=d=>pe(V=>({...V,[d]:!V[d]})),Mn=(d,V)=>{S(_e=>({..._e,[d]:V})),J(d)},wl=()=>{I.current=!1,j.current=null,M(Vs),S({}),Fe({promptTemplate:Vs,promptOverrides:{}})},Al=d=>{M(V=>V.trim()?`${V}
332
-
333
- {{${d}}}`:`{{${d}}}`)},Il=_.trim()&&_.trim()!==Vs||Object.values($).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(un,{className:"modal-head-icon"}),s.jsx("h2",{children:a("settingsTitle")}),s.jsx(ze,{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${g===d.id?" active":""}`,"aria-current":g===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:k,children:[g==="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(ze,{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:_,onFocus:()=>I.current=!0,onBlur:()=>{I.current=!1,_l()},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:()=>Al(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 V=$[d]??"",_e=u.promptSourceDefaults?.[d]??"",Qe=ee===d,ct=_e.split(`
335
- `).length>6||_e.length>480;if(cl(d)){const qe=V.trim()?V:_e;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(ze,{text:l(`promptTok_${d}_desc`)})]}),V.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",title:a("promptReadonlyLockedHint"),onClick:()=>On(d),children:a("promptResetSource")}):s.jsx("span",{className:"set-muted",children:a("promptReadonlyBadge")})]}),s.jsx("div",{className:`source-default readonly${qe.trim()?"":" empty"}`,title:a("promptReadonlyTitle"),children:qe.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ct?ue[d]?" expanded":" clamped":""}`,children:qe}),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:ue[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(ze,{text:l(`promptTok_${d}_desc`)})]}),V.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",onClick:()=>On(d),children:a("promptResetSource")}):s.jsx("span",{className:"set-muted",children:a("promptAutoBadge")})]}),V.trim()||Qe?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"set-prompt-input override-input",rows:Math.min(10,Math.max(1,V.split(`
336
- `).length)),autoFocus:Qe,placeholder:a("promptOverridePlaceholder"),value:V,onFocus:qe=>{j.current=d,J(d);const nt=qe.currentTarget;nt.value&&nt.value===_e&&nt.setSelectionRange(nt.value.length,nt.value.length)},onBlur:()=>{j.current===d&&(j.current=null);const qe=$[d]??"";if(qe.trim()&&qe===_e){On(d);return}Sl(d),qe.trim()||J(null)},onChange:qe=>S(nt=>({...nt,[d]:qe.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:ue[d]?a("promptSourceCollapse"):a("promptSourceExpand")})]}),_e.trim()?s.jsx("pre",{className:`source-default-text${ct?ue[d]?" expanded":" clamped":""}`,children:_e}):s.jsx("span",{className:"source-default-empty",children:a("promptSourceDefaultEmpty")}),!V.trim()&&_e.trim()&&s.jsx("button",{type:"button",className:"override-seed-btn",title:a("promptSourceSeedTip"),onClick:()=>Mn(d,_e),children:a("promptSourceSeedButton")})]})]}):s.jsx("div",{className:"source-default",title:a("promptSourceDefaultEditHint"),role:"button",tabIndex:0,onClick:()=>Mn(d,_e),onKeyDown:qe=>{(qe.key==="Enter"||qe.key===" ")&&(qe.preventDefault(),Mn(d,_e))},children:_e.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ct?ue[d]?" expanded":" clamped":""}`,children:_e}),ct&&s.jsx("span",{className:"source-default-toggle",role:"button",tabIndex:0,onClick:qe=>{qe.stopPropagation(),hs(d)},onKeyDown:qe=>{(qe.key==="Enter"||qe.key===" ")&&(qe.preventDefault(),qe.stopPropagation(),hs(d))},children:ue[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:wl,disabled:!Il,children:a("promptResetAll")})})]}),s.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":de,onClick:()=>re(d=>!d),children:[a("settingsViewPrompt")," ",de?"▴":"▾"]}),de&&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(ze,{text:a("settingsViewPromptHint")}),s.jsx(yn,{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":ke,onClick:()=>oe(d=>!d),children:[a("settingsViewToolsSchema")," ",ke?"▴":"▾"]}),ke&&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(ze,{text:a("settingsViewToolsSchemaHint")}),s.jsx(yn,{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")})]})})]}),g==="prompt-history"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(na,{className:"set-section-icon"}),a("settingsPromptHistory"),s.jsx(ze,{text:a("settingsPromptHistoryDesc")}),s.jsx("span",{className:"set-count",children:a("promptHistoryCount",{n:String(le)})})]}),le===0?s.jsx("p",{className:"set-empty",children:a("promptHistoryEmpty")}):s.jsx("p",{className:"set-hint",children:a("promptHistoryCount",{n:String(le)})}),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(Ce.maxEntries),onChange:d=>{const V=Math.floor(Number(d.target.value)||0),_e={...Ce,maxEntries:V};T(_e)},onBlur:()=>{const d={...Ce};(!Number.isFinite(d.maxEntries)||d.maxEntries<1)&&(d.maxEntries=1),d.maxEntries>500&&(d.maxEntries=500),d.maxEntries=Math.floor(d.maxEntries),T(d),Xn(d),y()}}),s.jsx(ze,{text:a("promptHistoryMaxHint")})]})]}),s.jsx(We,{title:a("promptHistoryCharLimit"),tip:a("promptHistoryCharLimitHint"),enabled:Ce.charLimitEnabled,onToggle:()=>{const d={...Ce,charLimitEnabled:!Ce.charLimitEnabled};T(d),Xn(d),y()}}),Ce.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(Ce.charLimit),onChange:d=>{const V=Math.floor(Number(d.target.value)||0);T({...Ce,charLimit:V})},onBlur:()=>{let d=Math.floor(Number(Ce.charLimit)||0);(!Number.isFinite(d)||d<100)&&(d=100),d>2e4&&(d=2e4);const V={...Ce,charLimit:d};T(V),Xn(V),y()}})]}),s.jsxs("div",{className:"set-field",style:{marginTop:12},children:[s.jsxs("button",{type:"button",className:`set-uninstall${Ee?" confirm":""}`,disabled:le===0,title:a(le===0?"promptHistoryEmpty":"promptHistoryClear"),onClick:()=>{if(!Ee){Re(!0);return}If(),Re(!1),y()},children:[s.jsx(et,{})," ",a(Ee?"promptHistoryClearConfirm":"promptHistoryClear")]}),le>0&&s.jsx("span",{className:"set-hint",style:{marginLeft:8},children:a("promptHistoryCount",{n:String(le)})})]}),s.jsxs("p",{className:"set-hint",children:[s.jsx(wr,{style:{verticalAlign:"-2px",marginRight:4}}),a("settingsPromptHistoryDesc")]})]}),g==="tools"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Va,{className:"set-section-icon"}),a("settingsTools")]}),s.jsx("div",{className:"set-field-label",children:a("toolsSectionTerminal")}),ul.map(d=>s.jsx(We,{title:d,tip:a("settingsTerminalToolsDesc"),enabled:!ft.has(d),onToggle:()=>gt(d)},d)),s.jsx(We,{title:a("terminalBashTakeover"),tip:a("terminalBashTakeoverDesc"),enabled:u.terminalBash,onToggle:()=>Fe({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&&Fe({terminalBashIdleMs:d})}})]}),s.jsx("div",{className:"set-field-label",children:a("toolsSectionSubagent")}),s.jsx("div",{className:"set-row-desc",children:a("toolsSubagentDepHint")}),dl.map(d=>s.jsx(We,{title:d,tip:lt[d],enabled:!ft.has(d),onToggle:()=>gt(d)},d)),s.jsxs("div",{className:"set-field-label",children:[a("settingsMarkers"),s.jsx(ze,{text:`${a("settingsMarkersDesc")}
312
+ `),inFence:a!==null}}const xh=c.memo(function({text:t}){return s.jsx(Ba,{text:t})}),Yi=200;function yh({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>=Yi){u();return}return o.current=setTimeout(u,Yi-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(Ba,{text:n})}const Nh=c.memo(function({text:t}){const{frozen:n,active:i,inFence:a}=c.useMemo(()=>Th(t),[t]);return s.jsxs("div",{className:"md",children:[n.map((o,l)=>s.jsx(xh,{text:o},l)),i.length>0&&s.jsx(yh,{text:i,inFence:a},n.length)]})});function kh({thinking:e,streaming:t,wrap:n=!0,forceOpen:i=!1}){const a=Re(),[o,l]=c.useState(null),u=o??n,m=u||i,T=t?e.trimEnd().slice(-80):e.split(`
313
+ `)[0].slice(0,80),[h,g]=c.useState(!1),A=()=>{navigator.clipboard.writeText(e),g(!0),window.setTimeout(()=>g(!1),1200)};return s.jsxs("div",{className:`thinking ${m?"open":""} ${t?"live":""}`,children:[s.jsxs("div",{className:"chead thinking-head",role:"button",tabIndex:0,"aria-expanded":m,title:a(m?"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(m?"collapseMsg":"expandMsg"),"aria-label":a(m?"collapseMsg":"expandMsg"),"aria-expanded":m,onClick:N=>{N.stopPropagation(),l(!u)},children:m?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&&m?s.jsxs("span",{className:"thinking-live-label",children:[a("thinkingNow"),s.jsx("span",{className:"dots"})]}):m?a("thinking"):a("thinkingPreview",{preview:T})}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy thinking-copy",title:a(h?"copied":"copyMessage"),"aria-label":a("copyMessage"),onClick:N=>{N.stopPropagation(),A()},children:h?s.jsx(cs,{}):s.jsx(St,{})})]}),m&&s.jsx("div",{className:"thinking-body",children:e})]})}const Nn=256*1024,kn=300,vh=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,Ch=/"agent"\s*:\s*"((?:[^"\\\n]|\\.){0,200})"/,_h=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,Sh=1e9;function wh(e){if(!e)return{};const t=e.length>Nn?e.slice(0,Nn):e;return{path:Rh(t),timeout:Dh(t),command:Ph(e),agent:Ah(t)}}function Ah(e){const t=Ch.exec(e);if(!t)return;const n=t[1].replace(/[\u0000-\u001f\u007f]/g,"").trim();if(n)return n.length>kn?`${n.slice(0,kn)}…`:n}const Ih=["task","expected_outcome","required_tools","must_do","must_not_do","context"];function jh(e){if(!e||e.length>Nn)return{};try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};const n=t,i={};for(const a of[...Ih,"agent","model"])typeof n[a]=="string"&&n[a].trim()&&(i[a]=n[a]);return i}catch{return{}}}function Lh(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 Rh(e){const t=vh.exec(e);if(!t)return;const i=Oh(t[2]).replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim();if(i)return i.length>kn?`${i.slice(0,kn-1)}…`:i}function Dh(e){const t=_h.exec(e);if(!t)return;const n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>Sh)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 Ph(e){if(!(e.length>Nn))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 Oh(e){try{const t=JSON.parse(`"${e}"`);return typeof t=="string"?t:e}catch{return e}}const Mh={bash:"$",delegate_task:"◈",read:"📄",write:"✍️",edit:"✏️",edit_soft:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function Bh(e){return Mh[e]??"🛠"}const Fh=c.memo(function({block:t,view:n,onKillBash:i,wrap:a=!0,forceOpen:o=!1}){const l=Re(),[u,m]=c.useState(null),T=u??a,h=T||o,[g,A]=c.useState(!1),N=!n.result&&n.streaming&&!n.status,v=t.name==="bash"&&N,B=n.result!==void 0,W=!n.result&&!!n.status,_=n.result?.isError??n.status?.isError??!1,j=n.result?n.result.content.map(q=>q.type==="text"?q.text:"").join(""):n.liveOutput??"",L=j.replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(q,C)=>l("liveOutputOmitted",{n:C})),U=t.name==="delegate_task",te=U?jh(t.argumentsText):{},ee=U&&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(j)?.[0],me=_?"err":B?"ok":N||W?"run":"idle";let Q=l(_?"error":B?"done":N?"running":W?"toolDoneWaitingModel":"toolQueued");const G=W&&n.status?.durationMs!==void 0?qh(n.status.durationMs):"";W&&G&&(Q=`${Q} · ${G}`);const ce=W&&n.status?.exitCode!==void 0?`exit ${n.status.exitCode}`:"",O=wh(t.argumentsText),M=t.name==="bash"?O.command:void 0,y=!h&&M?$h(M):void 0,D=()=>{t.argumentsText&&(navigator.clipboard.writeText(t.argumentsText),A(!0),setTimeout(()=>A(!1),1200))};return s.jsxs("div",{className:`toolcall ${me}`,children:[s.jsxs("div",{className:"chead toolcall-head",role:"button",tabIndex:0,"aria-expanded":h,title:l(h?"collapseMsg":"expandMsg"),onClick:()=>m(!T),onKeyDown:q=>{q.target===q.currentTarget&&(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),m(!T))},children:[s.jsx("button",{type:"button",className:"chead-toggle toolcall-toggle",title:l(h?"collapseMsg":"expandMsg"),"aria-label":l(h?"collapseMsg":"expandMsg"),"aria-expanded":h,onClick:q=>{q.stopPropagation(),m(!T)},children:h?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon toolcall-icon",children:Bh(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,{}):B?s.jsx(Tt,{}):N?s.jsx(xc,{}):W?s.jsx(ra,{}):s.jsx(hc,{})}),y&&s.jsxs("span",{className:"toolcall-cmd",title:M,children:["$ ",y]}),O.path&&s.jsx("span",{className:"toolcall-path",title:O.path,children:Lh(O.path)}),O.timeout&&s.jsxs("span",{className:"toolcall-timeout",children:["⏱ ",O.timeout]}),U&&O.agent&&s.jsxs("span",{className:"toolcall-agent",title:O.agent,children:["◈ ",O.agent]}),s.jsx("span",{className:"toolcall-spacer"}),v&&i&&s.jsxs("button",{type:"button",className:"toolcall-kill",title:l("stopBashTip"),onClick:q=>{q.stopPropagation(),i?.()},children:[s.jsx(cn,{}),s.jsx("span",{children:l("stopBash")})]}),U&&B&&le&&s.jsxs("button",{type:"button",className:"toolcall-open",title:l("delegateOpenSubagent"),onClick:q=>{q.stopPropagation(),window.dispatchEvent(new CustomEvent("pi-web-ui:switch-conversation",{detail:le}))},children:[s.jsx(Ac,{}),s.jsx("span",{children:l("delegateOpenSubagent")})]}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy",title:l("copyArgs"),onClick:q=>{q.stopPropagation(),D()},children:g?s.jsx(cs,{}):s.jsx(St,{})})]}),h&&s.jsxs("div",{className:"toolcall-body",children:[U?s.jsx(Uh,{args:te}):t.argumentsText&&s.jsx("div",{className:"toolcall-args",children:M?s.jsx(Hh,{command:M}):s.jsx("pre",{children:t.argumentsText})}),L.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:L})]}),N&&L.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",l("waitingOutput")]}),W&&L.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",l("waitingModel")]})]})]})});function Hh({command:e}){return s.jsxs("div",{className:"termline",children:[s.jsx(jn,{className:"termline-icon"}),s.jsx("code",{children:e})]})}function Uh({args:e}){const t=Re(),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 $h(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 qh(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 Wh=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function Fa(e){const t=e.match(Wh);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}const Kh=1568,Yh=2*1024*1024;function _t(e){return e.startsWith("image/")&&e!=="image/svg+xml"&&e!=="image/svg"}async function Ha(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,Kh/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,m]of o){const T=document.createElement("canvas");T.width=i,T.height=a;const h=T.getContext("2d");if(!h)continue;u!=="image/png"&&(h.fillStyle="#ffffff",h.fillRect(0,0,i,a)),h.drawImage(t,0,0,i,a);const g=T.toDataURL(u,m),A=g.match(/^data:([^;]+);base64,/),N=A?A[1]:u,v=g.replace(/^data:[^;]*;base64,/,""),B=Math.floor(v.length*3/4);if(l={data:v,mimeType:N,name:e.name,size:B},B<=Yh)return l}return l}finally{t.close()}}const Gh=20*1024*1024;function ls(e){return e.type==="text"&&typeof e.text=="string"?e:null}function Uo(e){return e.type==="thinking"&&typeof e.thinking=="string"?e:null}function $o(e){return e.type==="toolCall"&&typeof e.id=="string"&&typeof e.name=="string"?e:null}function qo(e){return e.type==="image"&&typeof e.dataUrl=="string"?e:null}function Wo(e){return e.type==="bash"&&typeof e.command=="string"?e:null}function Vh(e){return e.imageData?"image":e.uploadPath?"upload":e.fileData?"file":"path"}function zh(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==="reference"?t("refOnly",{path:n}):t("attachContent",{path:n})}const Gi=c.memo(function({message:t,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onEdit:u,onKillBash:m,onRetry:T,onCollapse:h,questionAttachments:g,qnIndex:A,qnActive:N,onJump:v,thinkingWrap:B,toolsWrap:W,searchActive:_,autoExpand:j}){const L=Re(),[U,te]=c.useState(!1),[ee,le]=c.useState(""),[me,Q]=c.useState([]),[G,ce]=c.useState(!1),[O,M]=c.useState(null),y=J=>{M(J),window.setTimeout(()=>M(oe=>oe===J?null:oe),4e3)};if(t.role==="toolResult")return null;if(t.role==="compactionSummary")return s.jsx(Jh,{message:t,forceOpen:_,autoExpand:j});const D=t.role==="custom"&&t.customType==="file",q=t.content.map(J=>ls(J)?.text??"").filter(Boolean).join(`
315
+ `),C=t.role==="user"?Fa(q):null,se=C?C.userMessage??`skill:${C.name}`:q.split(`
316
+ `).join(" ").trim(),K=o&&l&&t.content.length===0,xe=t.role==="user"&&!o&&!K&&!!u,k=async J=>{const oe=[];for(const H of J){if(!_t(H.type))continue;const Ie=await Ha(H);Ie&&oe.push({path:"",imageData:Ie.data,mimeType:Ie.mimeType,name:Ie.name})}oe.length>0&&Q(H=>[...H,...oe])},Y=async J=>{if(J.size>Gh){y(L("fileTooLarge",{name:J.name,size:20}));return}let oe;try{oe=(await new Promise((Ie,je)=>{const P=new FileReader;P.onload=()=>Ie(P.result),P.onerror=()=>je(P.error??new Error("read failed")),P.readAsDataURL(J)})).replace(/^data:[^;]*;base64,/,"")}catch{y(L("fileLoadFailed",{name:J.name}));return}Q(H=>[...H,{path:"",fileData:oe,name:J.name,size:J.size,mimeType:J.type||void 0}])},re=async J=>{const oe=[];for(const H of J)_t(H.type)?oe.push(H):Y(H);oe.length>0&&await k(oe)},de=()=>{le(C?`/skill:${C.name}${C.userMessage?` ${C.userMessage}`:""}`:t.content.map(J=>ls(J)?.text??"").filter(Boolean).join(`
317
+ `)),Q(g??[]),te(!0)},Se=()=>{const J=ee.trim();J&&(u?.(t.id,J,me.length>0?me:void 0),te(!1))},ie=t.role==="custom"&&(t.customType==="goal-review"||t.customType==="goal-wizard"),pe=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"?pe?L("goalWizardCard"):ie?L("goalBarTitle"):t.customType==="file"?L("attachment"):`${L("plugin")} · ${t.customType??L("unknown")}`:Ko(t.role,L)}),t.model&&s.jsx("span",{className:"msg-model",children:t.model}),t.timestamp&&s.jsx("span",{className:"msg-time",children:Yo(t.timestamp)}),h&&s.jsxs("button",{type:"button",className:"msg-collapse-btn",title:L("collapseMsg"),onClick:()=>h(t.id),children:[s.jsx(Ln,{})," ",L("collapseMsg")]}),A!==void 0&&v&&s.jsxs("button",{type:"button",className:`qn-tag ${N?"active":""}`,title:`${A+1}. ${se}`,"aria-label":`${A+1}. ${se}`,onClick:()=>v(t.id),children:[s.jsx("span",{className:"qn-tag-bar"}),s.jsx("span",{className:"qn-tag-idx",children:A+1})]})]}),s.jsx("div",{className:"msg-body",children:U?s.jsxs("div",{className:`msg-editor${G?" drag-over":""}`,onDragOver:J=>{J.preventDefault(),J.stopPropagation(),ce(!0)},onDragLeave:J=>{J.currentTarget.contains(J.relatedTarget)||ce(!1)},onDrop:J=>{J.preventDefault(),J.stopPropagation(),ce(!1),re(Array.from(J.dataTransfer?.files??[]))},children:[me.length>0&&s.jsx("div",{className:"msg-editor-images",children:me.map((J,oe)=>{const H=Vh(J);return s.jsxs("span",{className:`msg-editor-img ${H==="image"?"":"file-chip"}`,title:zh(J,L),children:[H==="image"?s.jsx("img",{src:`data:${J.mimeType??"image/png"};base64,${J.imageData}`,alt:J.name}):s.jsxs("span",{className:"msg-editor-file",children:[s.jsx("span",{className:"msg-editor-file-icon",children:H==="path"?J.mode==="reference"?"🔗":"📎":"📄"}),s.jsx("span",{className:"msg-editor-file-name",children:J.name??J.path?.split("/").pop()})]}),s.jsx("button",{type:"button",className:"msg-editor-img-remove",title:L("removeAttachment"),onClick:()=>Q(Ie=>Ie.filter((je,P)=>P!==oe)),children:s.jsx(Ke,{})})]},`${J.name??J.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:L("editPlaceholder"),rows:Math.max(2,Math.min(10,ee.split(`
318
+ `).length+1)),onChange:J=>le(J.target.value),onPaste:J=>{const oe=[];for(const H of J.clipboardData?.items??[])if(H.kind==="file"&&_t(H.type)){const Ie=H.getAsFile();Ie&&oe.push(Ie)}oe.length!==0&&(J.preventDefault(),k(oe))},onKeyDown:J=>{J.key==="Enter"&&(J.metaKey||J.ctrlKey)?(J.preventDefault(),Se()):J.key==="Escape"&&te(!1)}}),s.jsxs("div",{className:"msg-editor-actions",children:[s.jsxs("span",{className:"msg-editor-hint",children:[s.jsx(kc,{})," ",L("editAttachmentHint")]}),s.jsx("button",{type:"button",className:"chip",onClick:()=>te(!1),children:L("cancel")}),s.jsxs("button",{type:"button",className:"chip primary",disabled:!ee.trim(),title:L("reaskFromHere"),onClick:Se,children:[s.jsx(hn,{})," ",L("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&&T&&s.jsxs("button",{type:"button",className:"msg-retry-btn",title:L("retryLastTip"),onClick:T,children:[s.jsx(kt,{})," ",L("retryNow")]})]}),D?s.jsx(Qh,{message:t,forceOpen:_}):C?s.jsxs(s.Fragment,{children:[s.jsx(Zh,{block:C,forceOpen:_}),C.userMessage&&s.jsx("div",{className:"msg-text",children:s.jsx(rt,{text:C.userMessage,hardBreaks:!0})}),t.content.map((J,oe)=>J.type==="text"?null:s.jsx(zi,{block:J,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onKillBash:m,toolsWrap:W,thinkingWrap:B,searchActive:_,role:t.role},`${t.id}-${oe}`))]}):t.content.map((J,oe)=>s.jsx(zi,{block:J,toolResults:n,liveOutputs:i,toolStatuses:a,streaming:o,isLast:l,onKillBash:m,toolsWrap:W,thinkingWrap:B,searchActive:_,role:t.role},`${t.id}-${oe}`)),K&&s.jsxs("div",{className:"thinking-wait",children:[L("thinkingWait"),s.jsx("span",{className:"dot"})]}),o&&l&&!K&&s.jsx("span",{className:"stream-cursor"})]})}),xe&&!U&&s.jsx("div",{className:"msg-actions",children:s.jsxs("button",{type:"button",className:"msg-action",title:L("editReaskTip"),onClick:de,children:[s.jsx(hn,{})," ",L("editReask")]})})]})});function Qh({message:e,forceOpen:t=!1}){const n=Re(),[i,a]=c.useState(!1),[o,l]=c.useState(!1),u=i||t,m=e.details??{},T=m.name??m.path??n("attachment"),h=m.type==="folder",g=m.mode==="reference",A=m.mode==="bridged",N=e.content.filter(j=>j.type==="text").map(j=>j.text).join(`
319
+ `),v=Xh(N),B=e.content.find(j=>j.type==="image"),W=v.split(`
320
+ `).length,_=!g&&v.length>0;return s.jsxs("div",{className:`attachcard ${g?"reference":""}`,children:[s.jsxs("div",{className:"chead attachcard-head",role:"button",tabIndex:0,"aria-expanded":u,title:n(u?"collapseMsg":"expandMsg"),onClick:()=>a(j=>t?!0:!j),onKeyDown:j=>{j.target===j.currentTarget&&(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),a(L=>t?!0:!L))},children:[!g&&s.jsx("span",{className:"chead-toggle",children:u?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon attachcard-icon",children:h?"📁":"📎"}),s.jsx("span",{className:"chead-title attachcard-name",children:T}),m.path&&s.jsx("span",{className:"attachcard-path",children:m.path}),s.jsx("span",{className:`attachcard-mode ${m.mode==="lines"?"lines":g?"ref":A?"bridged":"inline"}`,children:g?h?n("folderRefShort"):`${n("refOnlyShort")} · ${Vi(m.size)}`:A?n("bridgedVision"):B?n("image"):m.mode==="lines"?n("inlineLinesRange",{start:m.startLine??1,end:m.endLine??m.lines??1}):n("inlineLines",{n:m.lines??W})}),_&&s.jsx("button",{type:"button",className:"chead-copy",title:n(o?"copied":"copyMessage"),"aria-label":n("copyMessage"),onClick:j=>{j.stopPropagation(),navigator.clipboard.writeText(v),l(!0),window.setTimeout(()=>l(!1),1200)},children:o?s.jsx(cs,{}):s.jsx(St,{})})]}),!g&&u&&(A?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"attachcard-bridgenote",children:n("bridgedVisionDetail")}),B?.dataUrl&&s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:B.dataUrl,alt:T})}),v&&s.jsx("pre",{className:"attachcard-content",children:v})]}):B?.dataUrl?s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:B.dataUrl,alt:T})}):s.jsx("pre",{className:"attachcard-content",children:v})),g&&s.jsx("div",{className:"attachcard-refnote",children:h?n("folderNotExpanded"):n("fileNotExpanded",{size:Vi(m.size)})})]})}function Vi(e){return e===void 0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function Xh(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 Jh({message:e,forceOpen:t=!1,autoExpand:n=!1}){const i=Re(),[a,o]=c.useState(!1),[l,u]=c.useState(!1),[m,T]=c.useState(n);n!==m&&(T(n),n&&o(!0));const h=a||t,g=e.content.map(N=>ls(N)?.text??"").filter(Boolean).join(`
321
+ `),A=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:Yo(e.timestamp)})]}),s.jsxs("div",{className:`compaction-card${a?" expanded":""}`,children:[s.jsxs("div",{className:"chead compaction-head",role:"button",tabIndex:0,"aria-expanded":h,title:i(h?"collapseMsg":"expandMsg"),onClick:()=>o(N=>t?!0:!N),onKeyDown:N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),o(v=>t?!0:!v))},children:[s.jsx("span",{className:"chead-toggle",children:h?s.jsx(Ft,{}):s.jsx(zt,{})}),s.jsx("span",{className:"chead-icon compaction-icon",children:s.jsx(Or,{})}),s.jsx("span",{className:"chead-title compaction-title",children:A?i("compactionFrom",{tokens:A}):i("role.compaction")}),g&&s.jsx("button",{type:"button",className:"chead-copy",title:i(l?"copied":"copyMessage"),"aria-label":i("copyMessage"),onClick:N=>{N.stopPropagation(),navigator.clipboard.writeText(g),u(!0),window.setTimeout(()=>u(!1),1200)},children:l?s.jsx(cs,{}):s.jsx(St,{})})]}),h&&s.jsxs("div",{className:"compaction-body",children:[s.jsx(rt,{text:g}),s.jsx("div",{className:"compaction-hint",children:i("compactionKeptHint")})]})]})]})}function Zh({block:e,forceOpen:t=!1}){const n=Re(),[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(m=>t?!0:!m),onKeyDown:m=>{m.target===m.currentTarget&&(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a(T=>t?!0:!T))},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(Sc,{})}),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:m=>{m.stopPropagation(),navigator.clipboard.writeText(e.content),l(!0),window.setTimeout(()=>l(!1),1200)},children:o?s.jsx(cs,{}):s.jsx(St,{})})]}),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:m,searchActive:T,role:h}){const g=Re(),[A,N]=c.useState(!1),v=ls(e);if(v){const L=a&&o,U=h==="assistant"||h==="user",te=U&&!v.text.includes(`
322
+ `)&&!v.truncated,ee=h==="user"?s.jsx(rt,{text:v.text,hardBreaks:!0}):L?s.jsx(Nh,{text:v.text}):s.jsx(rt,{text:v.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,v.truncated&&s.jsx("div",{className:"trunc-note",children:g("truncated")})]}),U?s.jsx("button",{type:"button",className:"msg-text-copy",title:g(A?"copied":"copyMessage"),"aria-label":g("copyMessage"),onClick:()=>{navigator.clipboard.writeText(v.text),N(!0),window.setTimeout(()=>N(!1),1200)},children:A?s.jsx(cs,{}):s.jsx(St,{})}):null]})}const B=Uo(e);if(B)return s.jsx(kh,{thinking:B.thinking,streaming:a&&o,wrap:u,forceOpen:T});const W=$o(e);if(W){const L=t.get(W.id),U=n.get(W.id),te={result:L,liveOutput:U?.text,streaming:a,status:i.get(W.id)};return s.jsx(Fh,{block:W,view:te,onKillBash:l,wrap:m,forceOpen:T})}const _=qo(e);if(_&&_.dataUrl)return s.jsx("div",{className:"msg-image",children:s.jsx("img",{src:_.dataUrl,alt:"attachment"})});const j=Wo(e);return j?s.jsxs("div",{className:"bashblock",children:[s.jsxs("div",{className:"bashblock-command",children:[s.jsx("span",{className:"bashblock-prompt",children:"$"}),s.jsx("code",{children:j.command}),j.exitCode!==void 0&&s.jsx("span",{className:`bashblock-exit ${j.exitCode===0?"ok":"err"}`,children:g("exitCode",{code:j.exitCode})}),j.cancelled&&s.jsx("span",{className:"bashblock-exit err",children:g("cancelled")})]}),j.output&&s.jsx("pre",{className:"bashblock-output",children:j.output}),j.truncated&&s.jsx("div",{className:"trunc-note",children:g("outputTruncated")})]}):null}function Ko(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 Yo(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`${n}:${i}`}function Qi(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 ef(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=[];Qi(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(!Qi(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.path&&l.mode){const u=l.mode==="inline"||l.mode==="lines"?l.mode:"reference",m={path:l.path,mode:u};l.mode==="lines"&&typeof l.startLine=="number"&&typeof l.endLine=="number"&&(m.lines={start:l.startLine,end:l.endLine}),a.push(m)}}}a.length>0&&t.set(i.id,a)}return t}const tf=c.memo(function({message:t,onExpand:n}){const i=Re();let a="";for(const g of t.content){const A=ls(g);if(A&&A.text.trim()){const N=Fa(A.text);N?a=`skill:${N.name}`+(N.userMessage?` · ${N.userMessage.replace(/\s+/g," ").trim()}`:""):a=A.text.replace(/\s+/g," ").trim();break}}if(!a&&t.role==="custom"&&t.customType==="file"){const g=t.details??{};a=g.name??g.path??""}a.length>90&&(a=`${a.slice(0,90)}…`);let l=0,u=0,m=0,T=0;for(const g of t.content)Uo(g)?l++:$o(g)?u++:Wo(g)?m++:qo(g)&&T++;const h=[];return l&&h.push(`${i("thinking")} ${l}`),u&&h.push(`${i("toolCalls")} ${u}`),m&&h.push(`${i("bashRuns")} ${m}`),T&&h.push(`${i("images")} ${T}`),s.jsxs("div",{role:"button",tabIndex:0,className:"msg-collapsed","data-msg-id":t.id,title:`${i("expandMsg")} · ${a||h.join(" · ")||t.role}`,onClick:()=>n(t.id),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),n(t.id))},children:[s.jsx("span",{className:`msg-collapsed-role role-${t.role}`,children:t.role==="custom"&&t.customType==="file"?i("attachment"):Ko(t.role,i)}),s.jsxs("span",{className:"msg-collapsed-body",children:[a&&s.jsx("span",{className:"msg-collapsed-preview",children:a}),h.length>0&&s.jsx("span",{className:"msg-collapsed-chips",children:h.map((g,A)=>s.jsx("span",{className:"msg-collapsed-chip",children:g},A))})]}),t.timestamp?s.jsx("span",{className:"msg-collapsed-time",children:sf(t.timestamp)}):null,s.jsxs("span",{className:"msg-collapsed-action",children:[s.jsx(zt,{})," ",i("expandMsg")]})]})});function sf(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`${n}:${i}`}const nf=c.memo(function({id:t,show:n,height:i,containerRef:a,onMeasured:o,lazyRef:l,children:u}){const m=c.useRef(null),T=c.useRef(null);return c.useLayoutEffect(()=>{const h=T.current;if(T.current=n,!n||h!==!1)return;const g=m.current,A=a.current;if(!g||!A)return;const N=g.offsetHeight;o?.(t,N);const v=N-i;if(v!==0){const B=g.parentElement;B&&B.getBoundingClientRect().bottom<=A.getBoundingClientRect().top&&(A.scrollTop+=v)}},[n]),n?s.jsx("div",{ref:l,"data-lazy-id":t,children:s.jsx("div",{ref:m,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 af(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 rf(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 of(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)??Go(l.role,l.customType)}return i}function Go(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 lf=["text","thinking","argumentsText","output","command"];function cf(e){let t=0;for(const n of e.content){n.type==="image"&&(t+=1);for(const i of lf){const a=n[i];typeof a=="string"&&(t+=a.length)}}return t}function uf(e,t,n,i){const a=n.get(e);return a&&a.len===t?a.h:i}function df(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 mf(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=df(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 pf(e,t){let n=0,i=e.indexOf(t);for(;i!==-1;)n++,i=e.indexOf(t,i+t.length);return n}function hf(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=pf(mf(l,i).toLowerCase(),o);u>0&&a.set(l.id,u)}return a}function ff(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 m=document.createRange();m.setStart(o,u),m.setEnd(o,u+i.length),n.push(m),u=l.indexOf(i,u+i.length)}}return n}function gf(e,t,n,i,a){const o=hf(n,i,t,a),l=new Map;for(const m of ff(e,t)){const T=m.startContainer.parentElement?.closest("[data-msg-id]");if(!T?.dataset.msgId)continue;const h=l.get(T.dataset.msgId);h?h.push(m):l.set(T.dataset.msgId,[m])}const u=[];for(const m of n){const T=l.get(m.id);if(T)for(let g=0;g<T.length;g++)u.push({kind:"dom",range:T[g],msgId:m.id,k:g});const h=o.get(m.id);if(h)for(let g=0;g<h;g++)u.push({kind:"folded",msgId:m.id,k:g})}return u}function Xn(e,t){return e.findIndex(n=>n.msgId===t.msgId&&n.k===t.k)}function pt(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 bf(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 Ef(e,t){const n=t.startContainer.parentElement;for(const u of bf(n,e)){const m=t.getBoundingClientRect(),T=u.getBoundingClientRect();if(m.height<=0||m.width<=0)return;m.top>=T.top+4&&m.bottom<=T.bottom-4||(u.scrollTop+=m.top-T.top-(u.clientHeight-m.height)/2),m.left>=T.left+4&&m.right<=T.right-4||(u.scrollLeft+=m.left-T.left-(u.clientWidth-m.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 Tf({containerRef:e,messages:t,collapsedIds:n,toolResults:i,onExpand:a,onProgrammaticScroll:o,open:l,onClose:u}){const m=Re(),T=c.useRef(null),[h,g]=c.useState(""),[A,N]=c.useState(null),[v,B]=c.useState(0),[,W]=c.useState(0),_=c.useDeferredValue(h),j=l?_.trim():"",L=c.useRef(null);L.current=A;const U=c.useRef([]),te=c.useRef({key:null}),ee=c.useRef("");c.useEffect(()=>{l&&(N(null),requestAnimationFrame(()=>T.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||(pt("msg-search",[]),pt("msg-search-active",[])),()=>{pt("msg-search",[]),pt("msg-search-active",[])}),[l]),c.useLayoutEffect(()=>{const Q=()=>{B(0),N(null),W(0),U.current=[],pt("msg-search",[]),pt("msg-search-active",[]),te.current={key:null},ee.current=""};if(!l||!j){Q();return}const G=e.current;if(!G)return;let ce=!1,O=0;return O=requestAnimationFrame(()=>{if(ce)return;const M=gf(G,j,t,n,i);U.current=M;const y=M.length;if(B(y),y===0){N(null),W(0),pt("msg-search",[]),pt("msg-search-active",[]),te.current={key:null},ee.current=j;return}const D=L.current;let q;if(D){if(q=Xn(M,D),q===-1){const k=[];for(let Y=0;Y<M.length;Y++)M[Y].msgId===D.msgId&&k.push(Y);if(k.length>0){const Y=Math.min(D.k,k.length-1);q=k[Y]}else q=0}}else q=0;q<0&&(q=0),q>=y&&(q=y-1),(!D||D.msgId!==M[q].msgId||D.k!==M[q].k)&&N({msgId:M[q].msgId,k:M[q].k}),W(q);const C=M[q],se=te.current,K=se.key?.msgId!==C.msgId||se.key?.k!==C.k||se.kind==="folded"&&C.kind==="dom"||j!==ee.current;te.current={key:{msgId:C.msgId,k:C.k},kind:C.kind},ee.current=j;const xe=M.filter(k=>k.kind==="dom").map(k=>k.range);if(pt("msg-search",xe),C.kind==="folded"){pt("msg-search-active",[]),K&&a(C.msgId);return}pt("msg-search-active",[C.range]),K&&(o?.(),Ef(G,C.range))}),()=>{ce=!0,cancelAnimationFrame(O)}},[l,j,t,e,A,n,i,a,o]);const le=c.useCallback(Q=>{const G=U.current,ce=G.length;if(ce===0)return;const O=L.current,M=O?Xn(G,O):0,y=G[(M+Q+ce)%ce];N(y.kind==="dom"||y.kind==="folded"?{msgId:y.msgId,k:y.k}:null)},[]);if(!l)return null;const me=A?(()=>{const Q=Xn(U.current,A);return Q===-1?0:Q})():0;return s.jsxs("div",{className:"search-bar",role:"search",children:[s.jsx("input",{ref:T,className:"search-input",type:"text",value:h,placeholder:m("searchPlaceholder"),onChange:Q=>{g(Q.target.value)},onKeyDown:Q=>{Q.key==="Enter"&&(Q.preventDefault(),le(Q.shiftKey?-1:1))}}),s.jsx("span",{className:`search-count ${v===0?"empty":""}`,children:v===0?m("searchNoResults"):`${Math.min(me+1,v)}/${v}`}),s.jsx("button",{type:"button",className:"search-btn",title:m("searchPrev"),disabled:v===0,onClick:()=>le(-1),children:s.jsx(Ln,{})}),s.jsx("button",{type:"button",className:"search-btn",title:m("searchNext"),disabled:v===0,onClick:()=>le(1),children:s.jsx(Ft,{})}),s.jsx("button",{type:"button",className:"search-btn",title:m("searchClose"),onClick:u,children:s.jsx(Ke,{})})]})}function xf(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 Vo="pi-web-model-usage";function yf(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 Nf(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function kf(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(Vo);return e?yf(JSON.parse(e)):{}}catch{return{}}}function vf(e){try{localStorage.setItem(Vo,JSON.stringify(e))}catch{}}function vn(e){const t=Nf(zo(),e);return vf(t),t}const Qo=[{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"}],Xo="pi-web-ui:prompt-templates";function Cf(){try{const e=localStorage.getItem(Xo);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 Xi(e){return Qo.some(t=>t.id===e)}function Gs(e){return typeof e.title=="string"}const Jo=c.createContext(null);function Zo(){const e=c.useContext(Jo);if(!e)throw new Error("useTemplates must be used within TemplateProvider");return e}function _f({children:e,currentModelId:t}){const n=Re(),[i,a]=c.useState(Cf),[o,l]=c.useState(!1),[u,m]=c.useState(null),[T,h]=c.useState(!1),[g,A]=c.useState(!1),[N,v]=c.useState(!1);c.useEffect(()=>{try{localStorage.setItem(Xo,JSON.stringify(i))}catch{}},[i]);const B=c.useMemo(()=>{const M=new Map,y=new Set;for(const C of i)C.hidden?y.add(C.id):(Gs(C)&&!Xi(C.id)||Gs(C))&&M.set(C.id,C);const D=Qo.filter(C=>!y.has(C.id)).map(C=>{const se=M.get(C.id);return{id:C.id,icon:se?.icon??C.icon,title:se?.title??n(C.titleKey),desc:se?.desc??n(C.descKey),prompt:se?.prompt??n(C.promptKey),builtin:!0}}),q=i.filter(C=>Gs(C)&&!Xi(C.id)).map(C=>({id:C.id,icon:C.icon??"📌",title:C.title??"",desc:C.desc??"",prompt:C.prompt??""}));return[...D,...q]},[i,n]),W=c.useCallback(()=>l(!0),[]),_=c.useCallback(M=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:M}))},[]),j=c.useCallback((M,y=!1)=>{v(y),M?(h(!1),m({...M})):(h(!0),m({id:wt(),icon:"📌",title:"",desc:"",prompt:""}))},[]),L=c.useCallback(()=>{l(!1),m(null),v(!1)},[]),U=c.useCallback(()=>{g?(a([]),A(!1)):(A(!0),setTimeout(()=>A(!1),5e3))},[g]),te=c.useCallback(M=>{l(!1),_(M.prompt)},[_]),ee=c.useCallback(M=>{l(!1),j(M,!0)},[j]),le=c.useCallback(()=>{l(!1),j(void 0,!0)},[j]),me=c.useCallback(M=>{a(y=>{const D=y.findIndex(q=>q.id===M.id);if(D>=0){const q=[...y];return q[D]=M,q}return[...y,M]}),m(null),N&&(l(!0),v(!1))},[N]),Q=c.useCallback(M=>{a(y=>M.builtin?[...y.filter(q=>q.id!==M.id),{id:M.id,hidden:!0}]:y.filter(D=>D.id!==M.id)),m(null),N&&(l(!0),v(!1))},[N]),G=c.useCallback(M=>{a(y=>y.filter(D=>D.id!==M.id||D.hidden)),m(null),N&&(l(!0),v(!1))},[N]),ce=c.useMemo(()=>({templates:B,fill:_,openPicker:W,openEdit:j,resetConfirm:g,toggleReset:U}),[B,_,W,j,g,U]),O=u?i.some(M=>M.id===u.id&&!M.hidden&&Gs(M)):!1;return s.jsxs(Jo.Provider,{value:ce,children:[e,o&&s.jsx(wf,{templates:B,resetConfirm:g,onFill:te,onEditTpl:ee,onNew:le,onResetToggle:U,onClose:L}),u&&s.jsx(Af,{editing:u,isNew:T,hasOverride:O,onDraft:m,onSave:me,onRestore:()=>G(u),onRemove:()=>Q(u),onFill:()=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:u.prompt})),L()},onSend:()=>{const M=u.prompt.trim();M&&ae({type:"prompt",text:M,queue:!1})&&(t&&vn(t),L())},onClose:L})]})}function Sf(){const e=Re(),{templates:t,fill:n,openEdit:i,toggleReset:a,resetConfirm:o}=Zo();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(el,{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(Ir,{}),e(o?"tpl.resetConfirm":"tpl.reset")]})})]})}function el({tpl:e,title:t,onFill:n,onEdit:i,editTitle:a}){const o=Re();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(fn,{})})]})}function wf({templates:e,resetConfirm:t,onFill:n,onEditTpl:i,onNew:a,onResetToggle:o,onClose:l}){const u=Re();return c.useEffect(()=>{const m=T=>{T.key==="Escape"&&l()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[l]),s.jsx("div",{className:"modal-backdrop",onClick:l,children:s.jsxs("div",{className:"modal template-picker",onClick:m=>m.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(m=>s.jsx(el,{tpl:m,title:u("tpl.clickCard"),onFill:()=>n(m),onEdit:()=>i(m),editTitle:u("tpl.editTpl")},m.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(Ir,{}),u(t?"tpl.resetConfirm":"tpl.reset")]})})]})})}function Af({editing:e,isNew:t,hasOverride:n,onDraft:i,onSave:a,onRestore:o,onRemove:l,onFill:u,onSend:m,onClose:T}){const h=Re(),g=c.useRef(null);c.useEffect(()=>{const v=B=>{B.key==="Escape"&&T()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[T]),c.useEffect(()=>{const v=g.current;if(!v)return;v.style.height="auto";const B=v.scrollHeight>300;v.style.height=`${Math.min(v.scrollHeight,300)}px`,v.style.overflowY=B?"auto":"hidden"},[e.prompt]);const A=()=>{const v=e.title.trim(),B=e.prompt.trim();if(!v||!B){i({...e,error:h("tpl.required")});return}a({id:e.id,icon:e.icon.trim()||"📌",title:v,desc:e.desc.trim(),prompt:B})},N=!!e.builtin&&!t;return s.jsx("div",{className:"modal-backdrop",onClick:T,children:s.jsxs("div",{className:"modal template-modal",onClick:v=>v.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:h(N?"tpl.builtin":"tpl.custom")}),s.jsx("span",{className:"template-modal-title",children:h(t?"tpl.newTitle":"tpl.editTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:h("close"),onClick:T,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:h("tpl.fieldIcon")}),s.jsx("input",{className:"template-field-input icon",value:e.icon,maxLength:4,onChange:v=>i({...e,icon:v.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:h("tpl.fieldTitle")}),s.jsx("input",{className:"template-field-input",value:e.title,placeholder:h("tpl.fieldTitlePh"),onChange:v=>i({...e,title:v.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:h("tpl.fieldDesc")}),s.jsx("input",{className:"template-field-input",value:e.desc,placeholder:h("tpl.fieldDescPh"),onChange:v=>i({...e,desc:v.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:h("tpl.fieldPrompt")}),s.jsx("textarea",{ref:g,className:"template-field-prompt",value:e.prompt,placeholder:h("tpl.fieldPromptPh"),onChange:v=>i({...e,prompt:v.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:h("tpl.restoreTip"),onClick:o,children:h("tpl.restore")}),!t&&N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:h("tpl.removeTip"),onClick:l,children:[s.jsx(et,{})," ",h("tpl.remove")]}),!t&&!N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:h("tpl.deleteTip"),onClick:l,children:[s.jsx(et,{})," ",h("tpl.delete")]})]}),s.jsxs("div",{className:"template-modal-actions-right",children:[s.jsx("button",{type:"button",className:"btn template-btn",onClick:A,children:h("tpl.save")}),s.jsx("button",{type:"button",className:"btn template-btn fill",onClick:u,title:h("tpl.fillTip"),children:h("tpl.fill")}),s.jsxs("button",{type:"button",className:"btn template-btn send",onClick:m,title:h("tpl.sendTip"),children:[s.jsx(aa,{})," ",h("tpl.sendNow")]})]})]})]})})}const Ji=new Map,If=15,Zi=30,Jn=250,er=1200,jf=1600;function tr({kind:e,text:t,onRemoveQueued:n,onRecallQueued:i}){const a=Re();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 Lf({compaction:e}){const t=Re(),[,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 sr(e){return e.content.some(t=>t.type==="toolCall")}function Rf({state:e,liveOutputs:t,toolStatuses:n,onEdit:i,onKillBash:a,onRetry:o,onRemoveQueued:l,onRecallQueued:u,thinkingWrap:m,toolsWrap:T,jumpTarget:h,onJumpDone:g}){const A=Re(),N=c.useRef(null),[v,B]=c.useState(!0),W=c.useRef(!0),_=c.useRef(0),j=c.useRef(0),L=c.useRef(!1),U=c.useRef(0),[te,ee]=c.useState(()=>new Set),[le,me]=c.useState(!1),Q=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,G=c.useMemo(()=>{const R=new Map;for(const V of e.messages)V.role==="toolResult"&&V.toolCallId&&R.set(V.toolCallId,V);return R},[e.messages]),ce=c.useMemo(()=>ef(e.messages),[e.messages]),O=Q.length>0?Q[Q.length-1].id:null,M=e.messages.length>Zi?Math.max(0,e.messages.length-If):0,y=c.useMemo(()=>{const R=new Set;for(let V=0;V<M;V++){const we=e.messages[V];we.role!=="toolResult"&&(te.has(we.id)||R.add(we.id))}return R},[e.messages,M,te]),[D,q]=c.useState(()=>new Set),[C,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 R=new Map;for(const V of e.messages)R.set(V.id,cf(V));return R},[e.messages]),de=c.useRef(re);de.current=re;const Se=c.useRef(D);Se.current=D;const ie=e.messages.length>Zi&&!le,pe=c.useRef(ie);pe.current=ie;const J=of(e.messages,K.current,jf),oe=c.useRef(J);oe.current=J;const H=c.useCallback(()=>{const R=N.current;if(!R)return;if(!pe.current){q(He=>He.size?new Set:He);return}const V=R.getBoundingClientRect(),we={top:V.top-er,bottom:V.bottom+er},_e=[];for(const[He,ot]of k.current){const yt=ot.getBoundingClientRect();_e.push({id:He,top:yt.top,bottom:yt.bottom}),Se.current.has(He)||P(He,yt.bottom-yt.top,de.current.get(He))}const Pe=af(_e,we,oe.current,Se.current);for(const He of Pe.hide){const ot=k.current.get(He);ot&&P(He,ot.offsetHeight,de.current.get(He))}q(He=>rf(He,Pe))},[]),Ie=c.useCallback(()=>{Y.current||(Y.current=requestAnimationFrame(()=>{Y.current=0,H()}))},[H]);c.useLayoutEffect(()=>{H()},[H]);const je=c.useRef(le);c.useLayoutEffect(()=>{je.current&&!le&&H(),je.current=le},[le,H]);const P=c.useCallback((R,V,we)=>{we!==void 0&&(xe.current.set(R,{h:V,len:we}),K.current.set(R,V))},[]),ye=c.useCallback((R,V)=>{P(R,V,de.current.get(R))},[P]),he=c.useCallback(R=>{R&&k.current.set(R.dataset.lazyId??"",R)},[]);c.useEffect(()=>{const R=new Set(e.messages.map(V=>V.id));for(const V of k.current.keys())R.has(V)||(k.current.delete(V),K.current.delete(V),xe.current.delete(V));q(V=>{let we=!1;const _e=new Set;for(const Pe of V)R.has(Pe)?_e.add(Pe):we=!0;return we?_e:V})},[e.messages,te]),c.useEffect(()=>()=>cancelAnimationFrame(Y.current),[]);const be=c.useMemo(()=>{const R=[];for(const V of e.messages){if(V.role!=="user")continue;const we=V.content.map(He=>ls(He)?.text??"").filter(Boolean).join(" "),_e=Fa(we),Pe=_e?_e.userMessage??`skill:${_e.name}`:we.trim();Pe&&R.push({id:V.id,text:Pe})}return R},[e.messages]),Te=c.useMemo(()=>{const R=new Map;return be.forEach((V,we)=>R.set(V.id,we)),R},[be]),[Ce,ke]=c.useState(-1),x=c.useRef(-1),b=c.useRef(be);c.useEffect(()=>{b.current=be},[be]);const S=c.useCallback(()=>{const R=N.current,V=b.current;if(!R||V.length===0)return;const we=R.getBoundingClientRect().top,_e=140;let Pe=-1;for(let He=0;He<V.length;He++){const ot=R.querySelector(`[data-msg-id="${V[He].id}"]`);if(ot)if(ot.getBoundingClientRect().top<=we+_e)Pe=He;else break}Pe!==x.current&&(x.current=Pe,ke(Pe))},[]);c.useEffect(()=>{S()},[be,S]);const z=c.useCallback(R=>{ee(V=>V.has(R)?V:new Set(V).add(R))},[]);c.useEffect(()=>{const R=V=>{if(!(V.ctrlKey||V.metaKey)||V.key.toLowerCase()!=="f")return;const we=V.target;we&&(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable)||(V.preventDefault(),me(!0))};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[]);const ue=c.useCallback(R=>{ee(V=>{if(!V.has(R))return V;const we=new Set(V);return we.delete(R),we})},[]),Ne=c.useCallback(R=>{const V=e.messages.findIndex(_e=>_e.id===R);eo.flushSync(()=>{V>=0&&V<M&&!te.has(R)&&z(R),se(_e=>_e.has(R)?_e:new Set(_e).add(R))});const we=b.current.findIndex(_e=>_e.id===R);x.current=we,ke(we),requestAnimationFrame(()=>{const _e=N.current?.querySelector(`[data-msg-id="${R}"]`);_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&&(L.current=!0))})},[e.messages,M,te,z]),[De,w]=c.useState(null),fe=c.useRef(null),Ae=c.useRef(null);c.useEffect(()=>{const R=fe.current;if(!R||R.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,w(null);return}for(const V of e.messages)if(V.role==="compactionSummary"&&!R.ids.has(V.id)){R.ids.add(V.id),w(V.id);break}},[e.messages,e.conversationId]),c.useEffect(()=>{!De||Ae.current===De||(Ae.current=De,Ne(De))},[De,Ne]);const Fe=c.useMemo(()=>h?e.messages.find(R=>R.role===h.role&&R.timestamp===h.timestamp)?.id??null:null,[e.messages,h]);c.useEffect(()=>{if(h){if(Fe){Ne(Fe),g?.();return}e.sessionFile===h.path&&e.messages.length>0&&g?.()}},[Fe,Ne,g,h,e.sessionFile,e.messages.length]);const Me=c.useCallback(()=>{const R=N.current;if(!R)return;const V=R.scrollTop-_.current,we=R.scrollHeight-j.current;_.current=R.scrollTop,j.current=R.scrollHeight;const _e=R.scrollHeight-R.scrollTop-R.clientHeight<80,Pe=Date.now()<U.current,He=xf({dSt:V,dSh:we,escaped:L.current,graceActive:Pe,stuck:W.current});He.reassert&&(U.current=Date.now()+Jn,R.scrollTop=R.scrollHeight),He.flipEscape&&(L.current=!0),_e&&V>=0&&(L.current=!1),Pe||(V<0?W.current=_e&&!L.current:_e&&(W.current=!0)),B(W.current),S(),Ie()},[S,Ie]),Ge=c.useRef(!1);c.useEffect(()=>{const R=Ge.current;if(Ge.current=!!e.isStreaming,R&&!e.isStreaming&&!L.current){const V=()=>{const _e=N.current;_e&&!L.current&&(_e.scrollTop=_e.scrollHeight,W.current=!0,B(!0))};requestAnimationFrame(()=>requestAnimationFrame(V));const we=setTimeout(V,180);return()=>clearTimeout(we)}},[e.isStreaming]),c.useEffect(()=>{const R=N.current;R&&W.current&&(R.scrollTop=R.scrollHeight)},[Q,e.isStreaming,t]);const Xt=e.queue.steering.join("\0")+""+e.queue.followUp.join("\0");c.useEffect(()=>{const R=N.current;R&&W.current&&(R.scrollTop=R.scrollHeight)},[Xt]),c.useEffect(()=>{const R=N.current;if(!R||typeof ResizeObserver>"u")return;let V=R.clientHeight;const we=new ResizeObserver(()=>{const _e=R.clientHeight,Pe=_e-V;V=_e,Pe>0&&(R.scrollTop=Math.min(R.scrollTop,R.scrollHeight-R.clientHeight))});return we.observe(R),()=>we.disconnect()},[]),c.useEffect(()=>{const R=N.current;if(!R||typeof MutationObserver>"u")return;let V=!1;const we=new MutationObserver(()=>{V||(V=!0,requestAnimationFrame(()=>{V=!1;const _e=N.current;_e&&W.current&&!L.current&&(_e.scrollTop=_e.scrollHeight,B(!0))}))});return we.observe(R,{childList:!0,subtree:!0,characterData:!0}),()=>we.disconnect()},[]);const At=c.useCallback(()=>{if(!N.current)return;W.current=!0,L.current=!1,B(!0),U.current=Date.now()+Jn;const V=()=>{const we=N.current;!we||!W.current||L.current||(U.current=Date.now()+Jn,we.scrollTop=we.scrollHeight)};V(),requestAnimationFrame(()=>requestAnimationFrame(V)),setTimeout(V,120),setTimeout(V,300),setTimeout(V,600)},[]),Ut=c.useRef(null);c.useEffect(()=>{const R=Ut.current,V=N.current;if(!R||!V)return;const we=_e=>{_e.preventDefault();const Pe=R.querySelector(".qn-list");if(Pe&&Pe.contains(_e.target)&&Pe.scrollHeight>Pe.clientHeight){Pe.scrollTop+=_e.deltaY;return}V.scrollTop+=_e.deltaY};return R.addEventListener("wheel",we,{passive:!1}),()=>R.removeEventListener("wheel",we)},[]);const[mt,$t]=c.useState(0);c.useEffect(()=>{const R=()=>{$t(N.current?.clientHeight??0),Ie()};return R(),window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[Ie]);const xt=be.length,qt=c.useMemo(()=>xt===0?27:Math.max(4,Math.min(27,Math.floor(((mt||600)-16)/xt)-3)),[xt,mt]),It=qt<20;return s.jsxs("div",{className:"messages-wrap",children:[s.jsxs("div",{className:`messages${le||v?"":" anchor-live"}`,ref:N,onScroll:Me,children:[e.messages.length===0&&!e.streamingMessage&&s.jsx("div",{className:"empty-state",children:s.jsx(Sf,{})}),e.messages.map((R,V)=>{const we=V<M,_e=we&&te.has(R.id);if(we&&!_e)return R.role==="toolResult"?null:s.jsx(tf,{message:R,onExpand:z},R.id);const Pe=R.role==="user"?Te.get(R.id):void 0,He=!ie||J.has(R.id)||C.has(R.id)||!D.has(R.id);return s.jsx(nf,{id:R.id,show:He,height:uf(R.id,re.get(R.id)??-1,xe.current,Go(R.role,R.customType)),containerRef:N,onMeasured:ye,lazyRef:he,children:s.jsx(Gi,{message:R,qnIndex:Pe,qnActive:Pe!==void 0?Pe===Ce:void 0,onJump:Ne,toolResults:G,liveOutputs:sr(R)?t:Ji,toolStatuses:n,streaming:e.isStreaming,onKillBash:a,onRetry:R.id===O?o:void 0,toolsWrap:T,thinkingWrap:m,isLast:R.id===O,onEdit:i,questionAttachments:ce.get(R.id),onCollapse:_e?ue:void 0,searchActive:le,autoExpand:R.id===De},R.id)},R.id)}),e.streamingMessage&&s.jsx(Gi,{message:e.streamingMessage,toolResults:G,liveOutputs:sr(e.streamingMessage)?t:Ji,toolStatuses:n,streaming:!0,isLast:!0,onEdit:i,onKillBash:a,toolsWrap:T,thinkingWrap:m,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?A("retryingApi",{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):A("retryingApiSoon",{error:e.retry.errorMessage})})]}),e.compaction&&s.jsx(Lf,{compaction:e.compaction}),e.isStreaming&&Q.length===0&&s.jsx("div",{className:"streaming-wait",children:A("waitingResponse")}),e.queue.steering.map((R,V)=>s.jsx(tr,{kind:"steer",text:R,onRemoveQueued:l,onRecallQueued:u},`q-steer-${V}`)),e.queue.followUp.map((R,V)=>s.jsx(tr,{kind:"followUp",text:R,onRemoveQueued:l,onRecallQueued:u},`q-fu-${V}`))]}),!v&&s.jsxs("button",{type:"button",className:"scroll-bottom",onClick:At,children:[s.jsx(Pr,{})," ",A("backToBottom")]}),s.jsx(Tf,{containerRef:N,messages:Q,collapsedIds:y,toolResults:G,onExpand:z,onProgrammaticScroll:()=>{L.current=!0,W.current=!1,B(!1)},open:le,onClose:()=>me(!1)}),be.length>0&&s.jsxs("div",{className:`qn-rail ${It?"many":""}`,ref:Ut,"aria-label":A("questionNavTitle"),style:{"--rail-gap":`${qt}px`},children:[be.map((R,V)=>s.jsx("button",{type:"button",className:`qn-bar ${V===Ce?"active":""}`,"aria-label":`${V+1}. ${R.text}`,onClick:()=>Ne(R.id),children:s.jsxs("span",{className:"qn-bar-text",children:[V+1,". ",R.text]})},R.id)),It&&s.jsx("div",{className:"qn-list",children:be.map((R,V)=>s.jsxs("button",{type:"button",className:`qn-list-item ${V===Ce?"active":""}`,"aria-label":`${V+1}. ${R.text}`,onClick:()=>Ne(R.id),children:[s.jsx("span",{className:"qn-list-idx",children:V+1}),s.jsx("span",{className:"qn-list-text",children:R.text})]},R.id))})]})]})}function nr(e,t){return t?e.trim()?`${e.replace(/\s+$/,"")}
325
+ ${t}`:t:e}function ar(e){return e.key?`key:${e.key}`:e.path?`${e.path}|${e.mode}|${e.lines?`${e.lines.start}-${e.lines.end}`:""}`:null}function Df(e,t){if(t.length===0)return e;if(e.length===0)return[...t];const n=new Set(e.map(ar).filter(a=>a!==null)),i=[...e];for(const a of t){const o=ar(a);if(o!==null){if(n.has(o))continue;n.add(o)}i.push(a)}return i}let Cn=null,_n=null;function ir(e){Cn=e}function rr(e){_n=e}function Pf(){return!!(Cn||_n)}function Of(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&&!Cn||a&&!_n?!1:(a&&_n?.(n),i&&Cn?.(t),!0)}const Mf=1,Bf="";function Ff(e,t,n=Mf){return{first:e<=n,last:Math.abs(t-e)<=n}}function Hf(e,t){return{first:!e.slice(0,t).includes(`
326
+ `),last:!e.slice(t).includes(`
327
+ `)}}let Zn=null;function Uf(){if(Zn?.isConnected)return Zn;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),Zn=e,e}function $f(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 or(e,t){e.textContent=t;const n=document.createElement("span");return n.textContent=Bf,e.appendChild(n),n.offsetTop}function qf(e){const t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};const i=Hf(t,n);if(!i.first&&!i.last||typeof document>"u"||typeof getComputedStyle!="function")return i;const a=Uf();if($f(e,a)<=0)return i;const o=or(a,t.slice(0,n)),l=or(a,t),u=a.offsetHeight>0;return a.textContent="",!u&&t!==""?i:Ff(o,l)}const Ua="pi-web-ui:prompt-history",Wf=100,tl="pi-web-ui:prompt-history-settings",va={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function sl(e){const t=va;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 nl(){try{const e=localStorage.getItem(tl);return e?sl(JSON.parse(e)):{...va}}catch{return{...va}}}function ea(e){const t=sl(e);try{localStorage.setItem(tl,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)),al(n)}catch{}}function Kf(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 Yf(e,t,n=Wf){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(Ua);return e?Kf(JSON.parse(e)):[]}catch{return[]}}function al(e){let t=e;for(;t;)try{localStorage.setItem(Ua,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 lr(e){let t=e.trim();if(!t)return;const n=nl();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));const i=Os(),a=Yf(i,t,n.maxEntries);a!==i&&al(a)}function Gf(){try{localStorage.removeItem(Ua)}catch{}}function Vf(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 zf(){return typeof window>"u"||typeof navigator>"u"||typeof window.matchMedia!="function"?!1:Vf({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}const Qf=["off","minimal","low","medium","high","xhigh","max"],Xf=c.memo(function({state:t,models:n,modelsLoading:i,onManageModels:a,providerKeys:o,compact:l=!1}){const u=Re(),m=t?.model,T=m?`${m.provider}/${m.id}`:null,[h,g]=c.useState(!1),[A,N]=c.useState(!1),[v,B]=c.useState(""),[W,_]=c.useState(null),[j,L]=c.useState({}),U=c.useRef(null),te=c.useRef(null),[ee,le]=c.useState(null);c.useEffect(()=>{if(!h){le(null);return}if(n.length===0)return;const C=requestAnimationFrame(()=>{const se=te.current;se&&le(se.offsetWidth)});return()=>cancelAnimationFrame(C)},[h,n.length]),c.useEffect(()=>{h&&L(zo())},[h]),c.useEffect(()=>{h||(B(""),_(null))},[h]);const me=c.useMemo(()=>{const C=new Map;for(const K of n)C.set(K.provider,(C.get(K.provider)??0)+1);const se=[];for(const[K,xe]of[...C.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(()=>kf(n,j),[n,j]),G=c.useMemo(()=>{let C=Q;W&&(C=C.filter(K=>K.provider===W.provider));const se=v.trim().toLowerCase();return se?C.filter(K=>K.name.toLowerCase().includes(se)||K.provider.toLowerCase().includes(se)||K.id.toLowerCase().includes(se)):C},[Q,v,W]),ce=c.useMemo(()=>{const C=[];for(const se of G){const K=o[se.provider];if(!K||K.length<=1){C.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)}C.push({model:se,key:xe})}return C},[G,o,W]),[O,M]=c.useState(!1),y=t?.availableThinkingLevels&&t.availableThinkingLevels.length>0?new Set(t.availableThinkingLevels):null,D=Qf.map(C=>({value:C,label:u(`thinking.${C}`),supported:y?y.has(C):!0})),q=C=>D.find(se=>se.value===C)?.label??C;return c.useEffect(()=>{h&&n.length===0&&!O&&!i&&(M(!0),ae({type:"list_models"}))},[h,n.length,O,i]),c.useEffect(()=>{n.length>0&&M(!1)},[n.length]),c.useEffect(()=>{if(!h)return;U.current?.querySelector(".dd-item.active")?.scrollIntoView({block:"nearest"})},[h,T,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:m?m.name:u("selectModel")}),!l&&m?.vision&&s.jsx("span",{className:"chip-vision",title:u("vision"),children:"🖼"}),!l&&m&&s.jsx("span",{className:"chip-sub",children:m.provider})]}),open:h,onOpenChange:g,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(dn,{}),s.jsx("input",{className:"dd-search",type:"text",placeholder:u("searchModels"),value:v,onChange:C=>B(C.target.value)})]}),s.jsxs("div",{className:"dd-model-body",children:[me.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")})}),me.map(C=>{const se=W?.provider===C.provider&&W?.keyName===C.keyName;return s.jsxs("button",{type:"button",className:`dd-provider-item ${se?"active":""}`,onClick:()=>_(se?null:{provider:C.provider,keyName:C.keyName}),title:C.keyName?`${C.provider} · ${C.keyName}`:`${C.provider} · ${C.count}`,children:[s.jsxs("span",{className:"dd-provider-txt",children:[s.jsx("span",{className:"dd-provider-name",children:C.provider}),C.keyName&&s.jsx("span",{className:"dd-provider-key",children:C.keyName})]}),s.jsx("span",{className:"dd-provider-count",children:C.count})]},C.keyName?`${C.provider}::${C.keyName}`:C.provider)})]}),s.jsxs("div",{className:"dd-model-scroll",ref:U,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(C=>{const se=C.model,K=T===se.id&&(!C.key||C.key.active);return s.jsx(it,{active:K,onClick:()=>{C.key&&!C.key.active&&ae({type:"activate_provider_key",provider:se.provider,keyName:C.key.name}),T!==se.id&&ae({type:"set_model",modelId:se.id}),g(!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("/")}),C.key&&s.jsxs("span",{className:`dd-model-key ${C.key.active?"active":""}`,children:[C.key.active?"●":"○"," ",C.key.name]}),(j[se.id]??0)>0&&s.jsx("span",{className:"dd-model-usage",children:u("modelUsedCount",{n:j[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")})]})]})]})},C.key?`${se.id}::${C.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:()=>{g(!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?q(t.thinkingLevel):"—"})})]}),open:A,onOpenChange:N,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("thinkingLevel")}),D.map(C=>s.jsx(it,{active:t?.thinkingLevel===C.value,disabled:!C.supported,title:C.supported?void 0:u("thinkingUnsupported"),onClick:()=>{t?.thinkingLevel!==C.value&&ae({type:"set_thinking",level:C.value}),N(!1)},children:C.label},C.value))]})]})}),cr=zf(),Jf=c.memo(function({streaming:t,messages:n,slashCommands:i,modelState:a,models:o,modelsLoading:l,attachments:u,onRemoveAttachment:m,onAddImageFiles:T,onAddLocalFiles:h,onNotice:g,onSent:A,onManageModels:N,providerKeys:v,quickPhrases:B,quickPhrasesEnabled:W,recallDrafts:_}){const j=Re(),L=Ct("ready"),U=Yr(),{locale:te}=Ht(),{openPicker:ee}=Zo(),le=b=>te!=="zh"&&b.descriptionEn?b.descriptionEn:b.description??"",me=b=>te!=="zh"&&b.argumentHintEn?b.argumentHintEn:b.argumentHint??"",[Q,G]=c.useState(""),[ce,O]=c.useState(null),[M,y]=c.useState(0),[D,q]=c.useState(!1),[C,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)=>nr(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(()=>(ir(b=>{G(S=>nr(S,b)),Y.current=-1,re.current="",requestAnimationFrame(()=>{const S=K.current;S&&(S.focus(),S.selectionStart=S.selectionEnd=S.value.length)})}),()=>ir(null)),[]);const Se={builtin:j("slashBuiltin"),extension:j("slashExtension"),prompt:j("slashPrompt"),skill:j("slashSkill"),plugin:j("slashPlugin")},ie=b=>{const S=b.match(/^\/([^\s]*)$/);if(S&&L){const z=S[1].toLowerCase(),ue=i.filter(Ne=>Ne.name.toLowerCase().startsWith(z));O(ue.length>0?ue:null),y(0)}else O(null)};c.useEffect(()=>{k.current?.querySelector(".slash-item.active")?.scrollIntoView({block:"nearest"})},[M,ce]);const pe=b=>{const S=ce??[],z=b??S[M%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()},J=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){g("warning",j("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(z),g("info",j("slashCopied"))}catch{g("error",j("slashCopyFailed"))}},oe=b=>{if(!b||b.length===0){g("warning",j("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?g("warning",ue):S.length>0&&T(S),z.length>0&&h(z)},H=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){g("warning",ue);return}T(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?j("modelNoVision",{name:S.name}):null},je=L,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(!D)return;const b=S=>{S.key==="Escape"&&q(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[D]);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 w=S.getBoundingClientRect().height-ue;z.scrollTop=Ne+w}},[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}:{}}),be=(b=!1)=>{const S=Q.trim(),z=u.some(ue=>ue.imageData||ue.fileData);if(!(!je||!S&&!z)){if(S==="/help"){const ue=K.current?.closest(".inputbox")?.getBoundingClientRect();se(ue?.width),q(!0),G(""),K.current?.focus();return}if(S==="/copy"){G(""),K.current?.focus(),J();return}if(ae({type:"prompt",text:S,queue:b,attachments:he()})){S&&lr(S),Y.current=-1,re.current="",G(""),A();const ue=a?.model;ue&&vn(`${ue.provider}/${ue.id}`),K.current?.focus()}}},Te=b=>{const S=b.trim();if(!(!je||!S)&&ae({type:"prompt",text:S,attachments:he()})){S&&lr(S),Y.current=-1,re.current="",A();const z=a?.model;z&&vn(`${z.provider}/${z.id}`),cr||K.current?.focus()}},Ce=b=>{if(!b.nativeEvent.isComposing){if(ce&&ce.length>0)switch(b.key){case"ArrowDown":b.preventDefault(),y(S=>(S+1)%ce.length);return;case"ArrowUp":b.preventDefault(),y(S=>(S-1+ce.length)%ce.length);return;case"Tab":case"Enter":b.preventDefault(),pe();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=qf(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 w=Ne[De];G(w),ie(w),requestAnimationFrame(()=>{const fe=K.current;fe&&(fe.selectionStart=fe.selectionEnd=w.length)})}else if(Y.current>0){const De=Y.current-1;Y.current=De;const w=Ne[De];G(w),ie(w),requestAnimationFrame(()=>{const fe=K.current;fe&&(fe.selectionStart=fe.selectionEnd=w.length)})}}else{const De=Y.current+1;if(De<Ne.length){Y.current=De;const w=Ne[De];G(w),ie(w),requestAnimationFrame(()=>{const fe=K.current;fe&&(fe.selectionStart=fe.selectionEnd=w.length)})}else{Y.current=-1;const w=re.current;G(w),ie(w),requestAnimationFrame(()=>{const fe=K.current;fe&&(fe.selectionStart=fe.selectionEnd=w.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(cr&&!b.shiftKey&&!(b.ctrlKey||b.metaKey))return;b.shiftKey||(b.preventDefault(),be())}}},ke=je&&(Q.trim()!==""||u.some(b=>b.imageData||b.fileData)),x=()=>s.jsx("div",{className:"inputbox-actions",children:t?ke?s.jsxs("div",{className:`split-send${U?" single":""}`,children:[s.jsx("button",{type:"button",className:"split-queue",title:j("supplementTip"),"aria-label":j("queueFollowTag"),onClick:()=>be(!0),children:s.jsx(yc,{})}),!U&&s.jsx("button",{type:"button",className:"split-steer",title:j("steerTip"),"aria-label":j("queueSteerTag"),onClick:()=>be(),children:s.jsx(oa,{})})]}):s.jsx("button",{type:"button",className:"btn stop",title:j("stopAgent"),onClick:()=>ae({type:"abort"}),children:s.jsx(cn,{})}):s.jsx("button",{type:"button",className:"btn send",title:j("sendTip"),disabled:!ke,onClick:()=>be(),children:s.jsx(oa,{})})});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?j("attachImage",{name:b.name}):b.fileData?j("attachFile",{name:b.name}):b.isDir?j("folderRef",{path:b.path}):b.mode==="reference"?j("refOnly",{path:b.path}):b.mode==="lines"&&b.lines?j("attachLines",{path:b.path,start:b.lines.start,end:b.lines.end}):j("attachContent",{path:b.path}),children:[b.imageData?"🖼":b.fileData?"📄":b.isDir?"📁":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:j("removeAttachment"),onClick:()=>m(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:j("attachHint")})]}),ce&&ce.length>0&&s.jsxs("div",{className:"slash-menu",role:"listbox",ref:k,"aria-label":j("slashCommands"),children:[s.jsxs("div",{className:"slash-menu-hint",children:[s.jsx("span",{children:j("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===M?" active":""}`,onMouseEnter:()=>y(S),onClick:()=>pe(b),children:[s.jsxs("span",{className:"slash-name",children:["/",b.name]}),s.jsx("span",{className:`slash-source ${b.source}`,children:Se[b.source]}),s.jsxs("span",{className:"slash-desc",children:[le(b),b.argumentHint&&s.jsx("span",{className:"slash-hint",children:me(b)})]})]},b.name))]}),D&&s.jsx("div",{className:"modal-backdrop",onClick:()=>q(!1),children:s.jsxs("div",{className:"slash-help",style:C?{width:C}:void 0,onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"slash-help-head",children:[s.jsxs("span",{children:["⚡ ",j("slashHelpTitle")]}),s.jsx("button",{type:"button",className:"btn",onClick:()=>q(!1),children:j("close")})]}),s.jsx("div",{className:"slash-help-body",children:i.length===0?s.jsx("div",{className:"slash-help-empty",children:j("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:Se[b.source]}),s.jsxs("span",{className:"slash-help-desc",children:[le(b),b.argumentHint&&s.jsx("span",{className:"slash-hint",children:me(b)})]})]},b.name))})]})}),W&&B.length>0&&s.jsx("div",{className:"quick-row","aria-label":j("quickPhrases"),children:B.map(b=>s.jsx("button",{type:"button",className:"quick-chip",title:j("quickPhrasesTip",{text:b}),disabled:!je,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:j(je?t?U?"placeholderStreamingQueued":"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!je,onChange:b=>{Y.current=-1,G(b.target.value),ie(b.target.value)},onKeyDown:Ce,onPaste:H}),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:j("uploadFile"),disabled:!je,onClick:()=>xe.current?.click(),children:s.jsx(mc,{})}),s.jsx("button",{type:"button",className:"btn tpl-open",title:j("tpl.openPicker"),onClick:ee,children:s.jsx(vc,{})}),s.jsx(Xf,{state:a,models:o,modelsLoading:l,onManageModels:N,providerKeys:v,compact:!0})]}),s.jsx("div",{className:"composer-tools-right",children:x()})]})]})]})}),Zf=c.memo(function({goal:t,models:n,modelsLoading:i,activeConversationId:a}){const o=Re(),{locale:l}=Ht(),u=l!=="zh"&&t.statusEn?t.statusEn:t.status||"",m=l!=="zh"&&t.wizard?.statusEn?t.wizard.statusEn:t.wizard?.status||"",T=Yr(),h=!t.conversationId||t.conversationId===a,g=t.goal!==null&&h,[A,N]=c.useState(""),[v,B]=c.useState(t.reviewModel??""),[W,_]=c.useState(t.maxRounds),[j,L]=c.useState(t.locked),[U,te]=c.useState(!1),[ee,le]=c.useState(!1),[me,Q]=c.useState(!0);c.useEffect(()=>{B(t.reviewModel??""),_(t.maxRounds||0),L(t.locked)},[t.goal,t.reviewModel,t.maxRounds,t.locked]),c.useEffect(()=>{U&&n.length===0&&!ee&&!i&&(le(!0),ae({type:"list_models"}))},[U,n.length,ee,i]),c.useEffect(()=>{n.length>0&&le(!1)},[n.length]);const G=()=>v?n.find(y=>y.id===v)?.name??v:o("goalBarUseMainModel"),ce=()=>{const y=A.trim();y&&(ae({type:"set_goal",goal:y,...v?{reviewModel:v}:{},maxRounds:W,locked:j}),N(""),Q(!1))},O=()=>{const y=A.trim();y&&(ae({type:"start_goal_wizard",text:y,...v?{wizardModel:v}:{},maxRounds:W,locked:j}),N(""),Q(!1))},M=(t.wizard?.active??!1)&&h;return M?s.jsx("div",{className:`goalbar goalbar-active ${M?"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:m||o("goalBarReviewing")}),s.jsx("button",{type:"button",className:"goalbar-x",title:o("goalBarClear"),onClick:()=>{ae({type:"clear_goal"}),Q(!0)},children:s.jsx(Ke,{})})]})}):g?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,{})})]})}):me?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(Ja,{})," ",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(Ja,{})}),s.jsx("input",{className:"goalbar-input",value:A,placeholder:o("goalBarPlaceholder"),onChange:y=>N(y.target.value),onKeyDown:y=>{y.key==="Enter"&&ce()}}),s.jsx("button",{type:"button",className:"goalbar-btn",disabled:!A.trim(),onClick:ce,children:o("goalBarSet")}),s.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!A.trim(),title:o("goalWizardTip"),onClick:O,children:["🔍 ",o("goalWizardBtn")]}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o(j?"goalBarLocked":"goalBarUnlocked"),onClick:()=>L(y=>(ae({type:"set_goal_prefs",locked:!y}),!y)),children:j?s.jsx(Tc,{}):s.jsx(lc,{})}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o("goalBarClear"),onClick:()=>Q(!0),children:s.jsx(Ln,{})})]}),s.jsxs("div",{className:"goalbar-opts",children:[T?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:U,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:v==="",onClick:()=>{B(""),te(!1),ae({type:"set_goal_prefs",reviewModel:""})},children:o("goalBarUseMainModel")}),n.map(y=>s.jsx(it,{active:v===y.id,onClick:()=>{B(y.id),te(!1),ae({type:"set_goal_prefs",reviewModel:y.id})},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:y.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:y.provider}),s.jsx("span",{className:"dd-model-id",children:y.id.split("/").slice(1).join("/")})]})]})},y.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:y=>{const D=parseInt(y.target.value,10);if(Number.isNaN(D)||D<0){_(0);return}_(D)},onBlur:()=>ae({type:"set_goal_prefs",maxRounds:W}),onKeyDown:y=>{y.key==="Enter"&&(ae({type:"set_goal_prefs",maxRounds:W}),y.target.blur())}})]}),s.jsx("span",{className:"goalbar-lock-hint",children:o(j?"goalBarLocked":"goalBarUnlocked")})]})]})});function e0(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 il=2e3;function t0(e,t,n=il){return e.filter(i=>t-i.t<=n)}function s0(e,t=il){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 ur(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 n0(e){let t=0;for(const n of e)n.type==="text"&&typeof n.text=="string"&&n.text?t+=ur(n.text):n.type==="thinking"&&typeof n.thinking=="string"&&n.thinking&&(t+=ur(n.thinking));return t}const bt="@root";function a0({chat:e}){const t=Re(),{engine:n}=ja(),i=e.state,[a,o]=c.useState(!1),[l,u]=c.useState(""),[m,T]=c.useState(""),[h,g]=c.useState(!1),[A,N]=c.useState(""),[v,B]=c.useState(-1),W=c.useRef(null),_=c.useRef(null),j=e.pathCompletions.filter(ie=>ie.type==="dir"),L=ie=>ie.endsWith("/")?ie:ie+"/",U=ie=>{let pe=ie.endsWith("/")&&ie!=="/"?ie.slice(0,-1):ie;if(pe===bt||pe==="/")return null;const J=pe.lastIndexOf("/");if(J<0)return/^[A-Za-z]:$/.test(pe)?bt:null;if(J===0)return"/";const oe=pe.slice(0,J);return/^[A-Za-z]:$/.test(oe)?oe+"/":oe};c.useEffect(()=>{if(!a)return;const ie=setTimeout(()=>{ae({type:"complete_path",path:L(l)})},60);return()=>clearTimeout(ie)},[l,a]),c.useEffect(()=>{if(!a||m===l)return;const ie=setTimeout(()=>{ae({type:"complete_path",path:m})},150);return()=>clearTimeout(ie)},[m,l,a]);const te=c.useRef([]),ee=i?.isStreaming??!1,le=i?.streamingMessage?n0(i.streamingMessage.content):0;if(c.useEffect(()=>{if(!ee){te.current=[];return}const ie=Date.now(),pe=te.current,J=pe[pe.length-1];J&&ie-J.t<250||(te.current=t0([...pe,{t:ie,out:le}],ie))},[ee,le]),!i)return null;const me=i.stats,Q=e0(me.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)}%`:"—",M=ee?s0(te.current):0,y=e.ready?"ok":"busy",D=e.ready?t("connected"):t("connecting"),q=me.contextUsage,C=q.tokens!==null&&q.percent!==null?`${q.estimated?"~":""}${es(q.tokens)} / ${es(q.contextWindow)}`:"—",se=q.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,"/");T(ie),u(ie),g(!1),N(""),o(!0)},Y=ie=>{const pe=ie.trim();pe!==bt&&(pe&&pe!==i.cwd&&ae({type:"set_cwd",path:pe}),o(!1))},re=()=>{const ie=A.trim();ie&&(ae({type:"make_dir",path:`${L(l)}${ie}`}),setTimeout(()=>{ae({type:"complete_path",path:L(l)})},80),N(""),g(!1))},de=ie=>{if(ie.key==="Escape")ie.stopPropagation(),o(!1);else if(ie.key==="Enter"&&!ie.nativeEvent.isComposing)Y(m);else if(ie.key==="Tab"){if(j.length===0)return;ie.preventDefault();const pe=v>=0?(v+1)%j.length:0;B(pe),T(j[pe].path),u(j[pe].path)}},Se=U(l);return s.jsxs("footer",{className:"statusbar",children:[s.jsx("span",{className:`status-dot ${y}`,title:D}),s.jsx("span",{className:"status-item",children:D}),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)}%`}})}),C]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:t("cumulativeCost"),children:["$",i0(me.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")," ",me.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"}),M>0?`${Math.round(M)}${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),T(bt),B(-1)},children:"💻"}),s.jsxs("button",{type:"button",className:"cwd-up",disabled:!Se,title:t("cwdGoUp"),onClick:()=>{Se&&(u(Se),T(Se),B(-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:m,placeholder:t("enterPath"),spellCheck:!1,onChange:ie=>{T(ie.target.value),B(-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:[j.length===0&&s.jsx("div",{className:"cwd-empty",children:t("cwdEmpty")}),j.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),T(ie.path),B(-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:h?s.jsxs("div",{className:"cwd-newrow",children:[s.jsx("input",{ref:_,value:A,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(),g(!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:()=>{g(!1),N("")},children:t("cwdCancel")})]}):s.jsxs("button",{type:"button",className:"cwd-newbtn",onClick:()=>g(!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 i0(e){return e<=0?"0":e<1e-4?"<0.0001":e.toFixed(4).replace(/\.?0+$/,"")}function r0({dialog:e}){const t=Re(),[n,i]=c.useState(""),[a,o]=c.useState(0),l=T=>{ae({type:"dialog_response",id:e.id,value:T})};c.useEffect(()=>{i(""),o(0);const T=h=>{h.key==="Escape"&&l(null)};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[e.id]);const u=Array.isArray(e.args[0])?e.args[0]:[],m=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((T,h)=>s.jsx("button",{type:"button",className:`dialog-option ${h===a?"sel":""}`,onMouseEnter:()=>o(h),onClick:()=>l(T),children:s.jsx(rt,{text:T,rawHtml:!0})},h)),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:m,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:m||t("inputPlaceholder"),autoFocus:!0,onChange:T=>i(T.target.value),onKeyDown:T=>{T.key==="Enter"&&!T.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 o0({question:e}){const t=Re(),[n,i]=c.useState({}),[a,o]=c.useState({}),[l,u]=c.useState(0),[m,T]=c.useState(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);c.useEffect(()=>{i({}),o({}),u(0),T(e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1)},[e.id,e.deadline]),c.useEffect(()=>{if(!e.deadline)return;const L=setInterval(()=>{T(U=>{const te=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return te<=0&&U>0&&ae({type:"question_answer",id:e.id,answers:[],cancelled:!0}),te})},1e3);return()=>clearInterval(L)},[e.id,e.deadline]),c.useEffect(()=>{const L=U=>{U.key==="Escape"&&N()};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[e.id]);const h=e.questions.length,g=e.questions[l];if(!g)return null;const A=L=>{const U=e.questions.map(te=>{const ee=L[te.id]??[],le=(a[te.id]??"").trim();return{id:te.id,selected:ee,...le?{custom:le}:{}}});ae({type:"question_answer",id:e.id,answers:U})},N=()=>{ae({type:"question_answer",id:e.id,answers:[],cancelled:!0})},v=(L,U)=>{i(te=>{const ee=te[L]??[];return{...te,[L]:ee.includes(U)?ee.filter(le=>le!==U):[...ee,U]}})},B=(L,U,te)=>{if(te){v(L,U);return}const ee={...n,[L]:[U]};i(ee),l===h-1?A(ee):u(l+1)},W=()=>{l===h-1?A(n):u(l+1)},_=L=>(e.questions.find(te=>te.id===L)?.options?.length??0)===0?!0:(n[L]?.length??0)>0||(a[L]??"").trim()!=="",j=(g.options??[]).filter(L=>(n[g.id]??[]).includes(L.label)&&L.preview).map(L=>L.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")}),h>1&&s.jsx("span",{className:"question-progress",children:t("questionStep",{cur:l+1,total:h})}),m>=0&&s.jsx("span",{className:"question-timer",children:m>0?t("questionTimeout",{s:m}):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:g.header??`${t("modelQuestion")} ${l+1}`}),s.jsx("div",{className:"question-head",children:s.jsx(rt,{text:g.question,rawHtml:!0})}),g.detail&&s.jsx("div",{className:"set-hint",children:s.jsx(rt,{text:g.detail,rawHtml:!0})}),(g.options?.length??0)>0&&s.jsx("div",{className:"set-list",children:g.options.map(L=>{const U=(n[g.id]??[]).includes(L.label);return s.jsxs("button",{type:"button",className:`set-row question-option${U?" active":""}`,onClick:()=>B(g.id,L.label,!!g.multiSelect),children:[s.jsxs("div",{className:"set-row-name",children:[s.jsx("span",{className:"question-mark",children:g.multiSelect?U?"☑ ":"☐ ":U?"● ":"○ "}),s.jsx(rt,{text:L.label,rawHtml:!0})]}),L.description&&s.jsx("div",{className:"set-row-desc",children:s.jsx(rt,{text:L.description,rawHtml:!0})})]},L.label)})}),j.length>0&&s.jsxs("div",{className:"question-preview",children:[s.jsx("div",{className:"question-preview-label",children:t("optionPreview")}),j.map((L,U)=>s.jsx("div",{className:"question-preview-body",children:s.jsx(rt,{text:L,rawHtml:!0})},U))]}),s.jsx("input",{className:"set-prompt-input question-custom",placeholder:t("modelQuestionCustom"),value:a[g.id]??"",onChange:L=>o(U=>({...U,[g.id]:L.target.value})),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),_(g.id)&&W())}})]},g.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:!_(g.id),onClick:W,children:l===h-1?t("modelQuestionSubmit"):t("next")})]})]})]})}const dr=e=>`'${e.replace(/'/g,"'\\''")}'`;function l0(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 c0({chat:e,terminal:t,active:n,onSwitchToTerminal:i}){const a=Re(),[o,l]=c.useState(null),[u,m]=c.useState([]),[T,h]=c.useState(""),[g,A]=c.useState(new Map),[N,v]=c.useState("changes"),[B,W]=c.useState([]),[_,j]=c.useState(null),[L,U]=c.useState(""),[te,ee]=c.useState(!1),[le,me]=c.useState(null),[Q,G]=c.useState(null),[ce,O]=c.useState(!1),[M,y]=c.useState(!1),[D,q]=c.useState(!1),[C,se]=c.useState(null),[K,xe]=c.useState(!1),[k,Y]=c.useState(""),re=c.useRef(0),de=c.useRef(-1),Se=c.useRef(-1),ie=c.useRef(-1),pe=c.useRef(-1),J=c.useRef(void 0),oe=c.useRef(null),H=c.useRef([]),Ie=c.useCallback(w=>{if(w.reqId===de.current){if(de.current=-1,y(!1),se(null),!w.ok){se(w.error??a("scmQueryFailedShort"));return}if(w.notRepo){xe(!0),l(null),m([]),A(new Map),W([]),j(null),U(""),G(null);return}xe(!1);const fe={branch:w.branch??"",detached:!!w.detached,upstream:w.upstream??null,ahead:w.ahead??0,behind:w.behind??0,upstreamGone:!!w.upstreamGone,files:(w.files??[]).map(Me=>({...Me}))},Ae=(w.branches??[]).map(Me=>({...Me})),Fe=new Map;for(const[Me,Ge]of Object.entries(w.stats??{}))Fe.set(Me,{add:Ge[0],del:Ge[1]});l(fe),m(Ae),A(Fe),h(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(w.reqId===Se.current){if(Se.current=-1,O(!1),!w.ok){se(w.error??a("scmQueryFailedShort"));return}const fe=oe.current;if(!fe)return;G({file:fe,staged:w.stagedText??"",worktree:w.worktreeText??"",untracked:!1})}else if(w.reqId===pe.current){if(pe.current=-1,q(!1),!w.ok){se(w.error??a("scmQueryFailedShort"));return}W((w.history??[]).map(fe=>({...fe})))}else if(w.reqId===ie.current){if(ie.current=-1,ee(!1),!w.ok){se(w.error??a("scmQueryFailedShort"));return}U(w.text??"")}},[]);c.useEffect(()=>{const w=e.scmData;w&&w.type==="scm_data"&&Ie(w)},[e.scmData,Ie]);const je=c.useCallback((w,fe)=>{if(!e.ready||e.status!=="open")return!1;const Ae=++re.current;return ae({...w,reqId:Ae})?(fe.current=Ae,!0):(re.current-=1,!1)},[e.ready,e.status]),P=c.useCallback((w=!1,fe=!1)=>{!e.ready||e.status!=="open"||e.state?.cwd&&(J.current!==void 0&&J.current!==e.state.cwd&&(l(null),m([]),A(new Map),W([]),q(!1),pe.current=-1,j(null),U(""),G(null),me(null)),J.current=e.state.cwd,se(null),je({type:"scm_status"},de)&&(fe||y(!0)))},[e.ready,e.state?.cwd,e.status,je]),ye=c.useCallback(w=>{if(me(w),j(null),oe.current=w,w.x==="?"&&w.y==="?"){G({file:w,staged:"",worktree:"",untracked:!0});return}O(!0),se(null),je({type:"scm_filediff",path:w.path},Se)||O(!1)},[je]),he=c.useCallback(w=>{j(w),me(null),G(null),U(""),ee(!0),se(null),je({type:"scm_commit",hash:w.hash},ie)||ee(!1)},[je]),be=c.useCallback((w,fe)=>{if(!e.ready)return;const Ae={name:w,command:fe,cwd:"${pwd}"};let Fe;const Me=e.terminals.find(Ge=>Ge.title===w);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=wt(),t.create({id:Fe,conversationId:e.activeConversationId||e.state?.conversationId||"",title:w,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 w=k.trim();if(!w||K)return;const fe=w.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");be("git commit",`git commit -m "${fe}"`),Y("")},[k,K,be]),Ce=c.useCallback(()=>{const w=k.trim();if(!w||K)return;const fe=w.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(w=>{K||be("git add",`git add -- ${dr(w.path)}`)},[K,be]),x=c.useCallback(w=>{K||be("git reset",`git reset HEAD -- ${dr(w.path)}`)},[K,be]),b=c.useCallback(()=>{if(!T||K)return;const w=u.find(fe=>fe.name===T);if(w?.remote&&typeof w.remote=="string"){const fe=T.slice(w.remote.length+1);be("git checkout",`git checkout -b ${fe} ${T} || git checkout ${T}`)}else be("git checkout",`git checkout ${T}`)},[T,u,K,be]),S=c.useCallback(()=>be("git push","git push"),[be]),z=c.useCallback(()=>be("git pull","git pull"),[be]),ue=c.useCallback(()=>{je({type:"scm_history"},pe)||(pe.current=-1)},[je]);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 w=setInterval(()=>{document.visibilityState!=="hidden"&&P(!1,!0)},3e4);return()=>clearInterval(w)},[n,e.ready,e.status,P]),c.useEffect(()=>{const w=H.current;if(H.current=e.terminals,!n)return;e.terminals.some(Ae=>Ae.running!==!1?!1:w.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=w=>{const fe=w.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:()=>{v("changes"),se(null)},children:a("scmChanges")}),s.jsx("button",{type:"button",role:"tab","aria-selected":N==="history",className:N==="history"?"active":"",onClick:()=>{v("history"),se(null)},children:a("scmHistory")})]}),s.jsx("button",{type:"button",className:"panel-refresh",title:a("scmRefreshTip"),disabled:M,onClick:()=>P(!0),children:s.jsx(kt,{className:M?"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:T,disabled:K||u.length===0,title:a("scmSwitchBranch"),onChange:w=>h(w.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:a("scmSelectBranch")}),u.filter(w=>!w.remote).map(w=>s.jsx("option",{value:w.name,children:w.current?`* ${w.name}`:w.name},w.name)),u.some(w=>w.remote)&&s.jsx("optgroup",{label:a("scmRemoteBranches"),children:u.filter(w=>w.remote).map(w=>s.jsx("option",{value:w.name,children:w.name},w.name))})]}),s.jsxs("button",{type:"button",className:"btn",disabled:!T||T===o?.branch||K,title:a("scmSwitchBranchTip",{branch:T}),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(oa,{}),a("scmPush")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!o||o.detached||K,title:a("scmPullTip"),onClick:z,children:[s.jsx(Pr,{}),a("scmPull")]}),s.jsx("input",{className:"scm-commit-input",value:k,placeholder:a("scmCommitPlaceholder"),disabled:K,onChange:w=>Y(w.target.value),onKeyDown:w=>{w.key==="Enter"&&!w.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")}),B.length>0&&s.jsx("span",{className:"scm-files-count",children:B.length})]}),s.jsx("div",{className:"scm-history-list",children:K?s.jsx("div",{className:"scm-empty",children:a("scmNotGitRepo")}):!o||D?s.jsx("div",{className:"scm-empty",children:e.status==="open"?a("scmLoading"):a("scmConnecting")}):B.length===0?s.jsx("div",{className:"scm-empty",children:a("scmNoHistory")}):B.map(w=>s.jsxs("button",{type:"button",className:`scm-commit ${_?.hash===w.hash?"active":""}`,onClick:()=>he(w),title:w.hash,children:[s.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:w.graph||"* "}),s.jsxs("span",{className:"scm-commit-info",children:[s.jsx("span",{className:"scm-commit-subject",children:w.subject}),s.jsxs("span",{className:"scm-commit-meta",children:[w.shortHash," · ",w.author," · ",w.date]}),w.decorations&&s.jsx("span",{className:"scm-commit-refs",children:w.decorations})]})]},w.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(w=>{const fe=l0(w),Ae=g.get(w.path);return s.jsxs("div",{className:`scm-file ${le?.path===w.path?"active":""}`,title:Ne[fe],onClick:()=>ye(w),children:[s.jsx("span",{className:`scm-file-xy ${fe==="untracked"?"q":"x"}`,children:w.x!==" "?w.x:" "}),s.jsx("span",{className:`scm-file-xy ${fe==="untracked"?"q":"y"}`,children:w.y!==" "?w.y:" "}),s.jsx("span",{className:"scm-file-path",children:w.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:[(w.y!==" "||fe==="untracked")&&s.jsx("button",{type:"button",className:"scm-act",title:a("scmStageTip",{path:w.path}),onClick:Fe=>{Fe.stopPropagation(),ke(w)},children:"+"}),fe==="staged"||fe==="both"?s.jsx("button",{type:"button",className:"scm-act",title:a("scmUnstageTip",{path:w.path}),onClick:Fe=>{Fe.stopPropagation(),x(w)},children:"−"}):null]})]},w.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:[C&&s.jsx("div",{className:"scm-error",children:C}),!_&&!C&&s.jsx("div",{className:"scm-empty",children:a("scmSelectCommitHint")}),_&&te&&!C&&s.jsx("div",{className:"scm-empty",children:a("scmLoading")}),_&&!te&&!C&&L?De(L):null]}):s.jsxs(s.Fragment,{children:[C&&s.jsx("div",{className:"scm-error",children:C}),!le&&!C&&s.jsx("div",{className:"scm-empty",children:a("scmSelectFileHint")}),le&&!Q&&!C&&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(jn,{}),s.jsx("span",{children:a("scmRunsInTerminal")}),s.jsx("button",{type:"button",className:"scm-goto-term",onClick:i,children:a("scmViewTerminal")})]})]})}function u0({entry:e}){const t=c.useRef(null),n=Re();return c.useEffect(()=>{const i=t.current;if(!i)return;let a;try{a=e.module.mount(i,_u(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 mr="__piWebUiHost",d0=2,m0=e=>new Promise(t=>setTimeout(t,e));function p0(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 m0(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 m=e.getConversationId();e.send({type:"new_chat"}),await i(()=>e.getConversationId()!==m||e.isConversationBlank())}e.send({type:"prompt",text:o})};return{version:d0,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 Pf()?Of({text:typeof o?.text=="string"?o.text:void 0,attachments:Array.isArray(o?.attachments)?o.attachments:void 0}):!1}}}function pr(e){try{const t=window;e?t[mr]=e:delete t[mr]}catch{}}function h0({piConfigured:e,piAgentInstalled:t,providers:n,installResult:i,onClose:a}){const o=Re(),l=Gr(),[u,m]=c.useState(!1),[T,h]=c.useState(""),[g,A]=c.useState(""),[N,v]=c.useState(!1);c.useEffect(()=>{ae({type:"list_providers"})},[]),c.useEffect(()=>{e&&a()},[e,a]),c.useEffect(()=>{i&&m(!1)},[i]),c.useEffect(()=>{!T&&n.length>0&&h(n.find(U=>!U.configured)?.id??n[0].id)},[n,T]);const B=()=>{u||(m(!0),ae({type:"install_pi_agent"}))},W=()=>{!g.trim()||N||(v(!0),ae({type:"set_provider_api_key",provider:T.trim(),apiKey:g.trim()}),setTimeout(()=>v(!1),3e3))},_=()=>{ae({type:"get_state"}),ae({type:"list_providers"})},j=n.find(U=>U.id===T),L=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")}),L?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:B,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:T,onChange:U=>h(U.target.value),children:[n.length===0&&s.jsx("option",{value:"",children:o("loading")}),n.map(U=>s.jsxs("option",{value:U.id,children:[U.name,"(",U.id,")",U.configured?` · ${o("configured")}`:""]},U.id))]}),j?.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:g,onChange:U=>A(U.target.value),placeholder:"sk-…"})]}),s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:!g.trim()||N||!T,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:B,children:o(u?"installing":"autoInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:a,children:o("skip")})]})]})})}const f0=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],$a=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),g0=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[$a()]});function ta(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:[$a()]).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 b0({providers:e,providerStatus:t,providerKeys:n,fetchModelsResult:i,cloneProviderResult:a,onClose:o}){const l=Re(),[u,m]=c.useState(null),[T,h]=c.useState({}),[g,A]=c.useState({}),[N,v]=c.useState(null),[B,W]=c.useState(!1),[_,j]=c.useState(0),[L,U]=c.useState(null),te=c.useRef(0),[ee,le]=c.useState(null),[me,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){U({ok:!1,text:l("fetchModelsNeedBaseUrl")});return}if(B)return;W(!0),U(null);const Y=_+1;j(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;m(Y=>{if(!Y)return Y;const re=Y.models.map(pe=>{if(!pe.id.trim())return pe;const J=k.find(H=>H.id===pe.id.trim());if(!J)return pe;const oe={...pe};return!oe.name&&J.name&&(oe.name=J.name),!oe.contextWindow&&J.contextWindow&&(oe.contextWindow=String(J.contextWindow)),!oe.maxTokens&&J.maxTokens&&(oe.maxTokens=String(J.maxTokens)),oe.input==="text"&&J.input?.includes("image")&&(oe.input="text-image"),!oe.reasoning&&J.reasoning&&(oe.reasoning=!0),oe}),de=new Set(re.map(pe=>pe.id.trim()).filter(Boolean)),Se=k.filter(pe=>!de.has(pe.id)).map(pe=>({id:pe.id,name:pe.name??"",reasoning:pe.reasoning??!1,input:pe.input?.includes("image")?"text-image":"text",contextWindow:pe.contextWindow?String(pe.contextWindow):"",maxTokens:pe.maxTokens?String(pe.maxTokens):""})),ie=[...re,...Se];return ie.some(pe=>pe.id.trim())?{...Y,models:ie.filter(pe=>pe.id.trim())}:Y}),U({ok:!0,text:l("fetchModelsOk",{n:k.length})})}else U({ok:!1,text:i.error||l("fetchModelsEmpty")})},[i]);const M=k=>{const Y=(T[k.id]??"").trim();!Y||N||(v(k.id),ae({type:"add_provider_key",provider:k.id,apiKey:Y,name:(g[k.id]??"").trim()||void 0}),setTimeout(()=>{v(null),h(re=>({...re,[k.id]:""})),A(re=>({...re,[k.id]:""})),ae({type:"list_providers"}),ae({type:"list_provider_keys"})},1500))},y=(k,Y)=>{ae({type:"activate_provider_key",provider:k,keyName:Y}),ae({type:"list_provider_keys"})},D=(k,Y)=>{window.confirm(l("removeKeyConfirm"))&&(ae({type:"remove_provider_key",provider:k,keyName:Y}),ae({type:"list_provider_keys"}))},q=()=>{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()},C=()=>{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=>ta({...Y,apiKey:""}))),Q("");return}if(a.config){ce(ta({...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&&m({...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),m(k)},children:l("advancedEdit")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!G.providerId.trim()||!G.apiKey.trim(),onClick:q,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:me,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((Se,ie)=>ie===Y?{...Se,providerId:re.target.value}:Se)),placeholder:l("providerIdPlaceholder"),style:{fontSize:12}}),s.jsx("input",{type:"text",value:k.baseUrl,onChange:re=>le(de=>de.map((Se,ie)=>ie===Y?{...Se,baseUrl:re.target.value}:Se)),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:!me.trim(),onClick:()=>{for(const k of ee){const Y=k.providerId.trim();if(!Y)continue;const re=k.models.filter(Se=>Se.id.trim()).map(Se=>({id:Se.id.trim(),name:Se.name.trim()||void 0,reasoning:Se.reasoning||void 0,input:Se.input==="text-image"?["text","image"]:void 0,contextWindow:Se.contextWindow?Number(Se.contextWindow):void 0,maxTokens:Se.maxTokens?Number(Se.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:me.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=>m({...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=>m({...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=>m({...u,api:k.target.value}),children:f0.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=>m({...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=>m({...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=>m({...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:[L&&s.jsx("span",{className:`fetch-msg ${L.ok?"ok":"err"}`,title:L.text,children:L.text}),s.jsxs("button",{type:"button",className:"btn sm",disabled:B||!u.baseUrl.trim(),title:l("fetchModelsHint"),onClick:O,children:[s.jsx(Yt,{})," ",l(B?"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:()=>m({...u,models:u.models.filter((re,de)=>de!==Y)}),children:s.jsx(et,{})})]},Y)),s.jsxs("button",{type:"button",className:"btn",onClick:()=>m({...u,models:[...u.models,$a()]}),children:[s.jsx(dt,{})," ",l("addModel")]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>m(null),children:l("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!u.providerId.trim()||!u.models.some(k=>k.id.trim()),onClick:C,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:()=>y(k.id,re.name),children:s.jsx(Tt,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:l("removeKey"),onClick:()=>D(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:g[k.id]??"",onChange:re=>A(de=>({...de,[k.id]:re.target.value}))}),s.jsx("input",{type:"password",className:"key-input key-input-value",placeholder:l("addKeyPlaceholder"),value:T[k.id]??"",onChange:re=>h(de=>({...de,[k.id]:re.target.value}))}),s.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(T[k.id]??"").trim()||N===k.id,onClick:()=>M(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:()=>m(ta(k)),children:s.jsx(fn,{})}),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:()=>m(g0()),children:[s.jsx(dt,{})," ",l("addProvider")]})]})]})]})})}function ze({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 T=t.current?.getBoundingClientRect();T&&(l({left:Math.max(8,T.left-8),top:T.bottom+8}),a(!0))},m=()=>a(!1);return c.useEffect(()=>{if(!i)return;const T=n.current,h=t.current;if(!T||!h)return;const g=T.getBoundingClientRect(),A=h.getBoundingClientRect();let N=A.left-8,v=A.bottom+8;N+g.width>window.innerWidth-8&&(N=Math.max(8,A.right+8-g.width)),v+g.height>window.innerHeight-8&&(v=Math.max(8,A.top-8-g.height)),l(B=>B.left===N&&B.top===v?B:{left:N,top:v})},[i,e]),c.useEffect(()=>{if(!i)return;const T=()=>a(!1);return window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[i]),s.jsxs("span",{ref:t,className:"set-tip",tabIndex:0,"aria-label":e,onMouseEnter:u,onMouseLeave:m,onFocus:u,onBlur:m,onKeyDown:T=>{T.key==="Escape"&&T.target.blur()},children:["?",i&&eo.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 E0({plugin:e}){const t=Re(),n=e.settingsSchema??[],[i,a]=c.useState(()=>({...e.settingsValues})),[o,l]=c.useState(!1);if(n.length===0)return null;const u=(g,A)=>a(N=>({...N,[g]:A})),m=n.some(g=>i[g.key]!==e.settingsValues?.[g.key]),T=()=>{l(!0),ae({type:"plugin_settings",pluginId:e.id,values:i}),setTimeout(()=>l(!1),800)},h=()=>a({...e.settingsValues});return s.jsxs("div",{className:"plugin-settings-form",children:[s.jsx("div",{className:"plugin-settings-fields",children:n.map(g=>s.jsxs("label",{className:"plugin-settings-field",title:g.hint,children:[s.jsx("span",{className:"plugin-settings-label",children:g.label}),g.type==="boolean"?s.jsx("input",{type:"checkbox",checked:!!i[g.key],onChange:A=>u(g.key,A.target.checked)}):g.type==="select"?s.jsx("select",{value:String(i[g.key]??""),onChange:A=>u(g.key,A.target.value),children:(g.options??[]).map(A=>s.jsx("option",{value:A,children:A},A))}):s.jsx("input",{type:g.type==="password"?"password":g.type==="number"?"number":"text",value:String(i[g.key]??""),min:g.min,max:g.max,onChange:A=>u(g.key,g.type==="number"?Number(A.target.value):A.target.value)})]},g.key))}),s.jsxs("div",{className:"plugin-settings-actions",children:[s.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!m||o,onClick:T,children:t(o?"pluginSettingsSaving":"pluginSettingsSave")}),s.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:h,children:t("pluginSettingsReset")})]})]})}const rl="pi-web-ui:wide-chat",Sn={wide:!1};function ol(e){if(!e||typeof e!="object")return{...Sn};const t=e;return{wide:typeof t.wide=="boolean"?t.wide:Sn.wide}}function T0(){try{const e=localStorage.getItem(rl);return e?ol(JSON.parse(e)):{...Sn}}catch{return{...Sn}}}function x0(e){const t=ol(e);try{localStorage.setItem(rl,JSON.stringify(t))}catch{}Zs=t;for(const n of Ca)n()}let Zs=null;const Ca=new Set;function y0(e){return Ca.add(e),()=>{Ca.delete(e)}}function N0(){return Zs||(Zs=T0()),Zs.wide}function ll(){return c.useSyncExternalStore(y0,N0)}const cl="pi-web-ui:project-title",wn={projectName:!0};function ul(e){if(!e||typeof e!="object")return{...wn};const t=e;return{projectName:typeof t.projectName=="boolean"?t.projectName:wn.projectName}}function k0(e){return e?e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"":""}function v0(){try{const e=localStorage.getItem(cl);return e?ul(JSON.parse(e)):{...wn}}catch{return{...wn}}}function C0(e){const t=ul(e);try{localStorage.setItem(cl,JSON.stringify(t))}catch{}en=t;for(const n of _a)n()}let en=null;const _a=new Set;function _0(e){return _a.add(e),()=>{_a.delete(e)}}function S0(){return en||(en=v0()),en.projectName}function dl(){return c.useSyncExternalStore(_0,S0)}const ml="pi-web-ui:wallpaper",w0="has-wallpaper",Ls={url:"",dim:78,blur:0},A0=2e3,I0=28e5;function Sa(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.toLowerCase().startsWith("data:image/")?I0:A0;return t.length>n?"":/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith("/")&&!t.startsWith("//")?t:""}const hr=(e,t,n,i)=>typeof e!="number"||!Number.isFinite(e)?i:Math.min(n,Math.max(t,Math.round(e)));function pl(e){if(!e||typeof e!="object")return{...Ls};const t=e;return{url:Sa(t.url),dim:hr(t.dim,0,95,Ls.dim),blur:hr(t.blur,0,24,Ls.blur)}}function hl(){try{const e=localStorage.getItem(ml);return e?pl(JSON.parse(e)):{...Ls}}catch{return{...Ls}}}function j0(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/[\r\n]/g,"")}async function L0(e){const t=await Ha(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function tn(){const e=Rs??hl(),t=document.documentElement;e.url?(t.style.setProperty("--bg-image",`url("${j0(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(w0,e.url!==""||n!==""&&n!=="none")}function Es(e){const t=pl(e);Rs=t;try{localStorage.setItem(ml,JSON.stringify(t))}catch{}for(const n of wa)n();tn()}let Rs=null;const wa=new Set;function R0(e){return wa.add(e),()=>{wa.delete(e)}}function D0(){return Rs||(Rs=hl()),Rs}function fl(){return c.useSyncExternalStore(R0,D0)}function P0(){const e=fl();c.useEffect(()=>{tn()},[e]),c.useEffect(()=>{const t=()=>tn();return window.addEventListener(Mt,t),tn(),()=>window.removeEventListener(Mt,t)},[])}const An={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"]},gl=["soul","tools","guidelines","pi_docs","append","persona","terminal","markers","context","skills","cwd"],O0=["tools","pi_docs","persona","terminal","markers","context","skills","cwd"];function bl(e){return O0.includes(e)}const Vs=gl.map(e=>`{{${e}}}`).join(`
330
+
331
+ `),El=["terminal_create","terminal_list","terminal_close","terminal_input","terminal_key","terminal_read","terminal_wait"],Tl=["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",M0=[...El.map(e=>({name:e,group:"terminal",defaultOn:!1,dshVisible:!0})),...Tl.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}];new Set(M0.map(e=>e.name));function B0(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function fr(e){return e==="append"?0:bl(e)?2:1}function We({title:e,subtitle:t,tip:n,enabled:i,onToggle:a,action:o}){const l=Re();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(ze,{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 F0({chat:e,terminal:t,onSwitchToTerminal:n,onClose:i}){const a=Re(),{locale:o}=Ht(),l=d=>a(d),u=e.settings,{engine:m,managed:T}=ja(),h=m==="dsh",[g,A]=c.useState("prompt"),N=c.useRef(null);c.useEffect(()=>{N.current?.scrollTo({top:0})},[g]),c.useEffect(()=>{g==="plugins"&&h&&ae({type:"dsh_patches_list"})},[g,h]);const[v,B]=c.useState(""),[W,_]=c.useState({}),j=c.useRef(!1),L=c.useRef(null),U=[...gl].sort((d,X)=>fr(d)-fr(X)),[te,ee]=c.useState(null),[le,me]=c.useState({}),[Q,G]=c.useState(""),[ce,O]=c.useState("append"),M=c.useRef(!1),[y,D]=c.useState(""),q=c.useRef(!1),[C,se]=c.useState(""),[K,xe]=c.useState(null),[k,Y]=c.useState(null),[re,de]=c.useState(!1),[Se,ie]=c.useState(!1),pe=ll(),J=dl(),oe=fl(),[H,Ie]=c.useState(oe.url),je=c.useRef(!1),P=c.useRef(null),[ye,he]=c.useState(!1),[be,Te]=c.useState(!1);c.useEffect(()=>{je.current||Ie(oe.url.startsWith("data:")?"":oe.url)},[oe.url]);const Ce=async d=>{const X=d.target.files?.[0];if(d.target.value="",!!X){he(!0),Te(!1);try{const ve=await L0(X),Qe=ve?Sa(ve):"";if(!Qe){Te(!0);return}Ie(""),Es({...oe,url:Qe})}finally{he(!1)}}},[ke,x]=c.useState(()=>nl()),[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(()=>{g==="prompt-history"&&Ne()},[g]),c.useEffect(()=>{if(!z)return;const d=window.setTimeout(()=>ue(!1),3e3);return()=>window.clearTimeout(d)},[z]);const[De,w]=c.useState(null),[fe,Ae]=c.useState(null),[Fe,Me]=c.useState(""),[Ge,Xt]=c.useState(""),[At,Ut]=c.useState(""),[mt,$t]=c.useState(""),[xt,qt]=c.useState(""),[It,R]=c.useState(!1),[V,we]=c.useState(""),[_e,Pe]=c.useState(null);c.useEffect(()=>{u&&(j.current||B(u.promptTemplate??""),_(d=>{const X={};for(const[ve,Qe]of Object.entries(u.promptOverrides??{}))X[ve]=Qe??"";return L.current&&(X[L.current]=d[L.current]??""),X}),O(u.visionBridgePromptMode),!M.current&&(G(ce==="append"||u.visionBridgePrompt?u.visionBridgePrompt:u.visionBridgeDefaultPrompt||""),q.current||D(u.reviewPrompt)))},[u,ce]);const[He,ot]=c.useState(String(u?.terminalBashIdleMs??15e3));c.useEffect(()=>{ot(String(u?.terminalBashIdleMs??15e3))},[u?.terminalBashIdleMs]);const[yt,ps]=c.useState(String(u?.retryMaxAttempts??6));if(c.useEffect(()=>{ps(String(u?.retryMaxAttempts??6))},[u?.retryMaxAttempts]),!u)return null;const ft=new Set(u.disabledAgentTools??[]),Mn=ft.size,jt=[{id:"prompt",icon:s.jsx(Lr,{}),label:a("settingsSystemPrompt")},{id:"prompt-history",icon:s.jsx(ra,{}),label:a("settingsPromptHistory"),count:b},...h?[{id:"question",icon:s.jsx(Za,{}),label:a("settingsQuestionnaire")}]:[{id:"tools",icon:s.jsx(Xa,{}),label:a("settingsTools"),count:Mn+(u.disabledMarkers?.length??0)||void 0}],{id:"display",icon:s.jsx(rs,{}),label:a("settingsMessageDisplay")},{id:"quick",icon:s.jsx(aa,{}),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(Hn,{}),label:a("settingsExtensions"),count:u.extensions.length},{id:"plugins",icon:s.jsx(Un,{}),label:a("settingsUiPlugins"),count:e.plugins.length},{id:"review",icon:s.jsx(zs,{}),label:a("settingsReview"),count:u.reviewSkills.length},...h?[]:[{id:"vision",icon:s.jsx(pn,{}),label:a("settingsVisionBridge")}],{id:"presets",icon:s.jsx(uc,{}),label:a("settingsPresets"),count:u.presets.length},...h?[]:[{id:"subagent-templates",icon:s.jsx(Qa,{}),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(),X=_e.index;if(Pe(null),!d||d===u.quickPhrases[X])return;const ve=[...u.quickPhrases];ve[X]=d,Be({quickPhrases:ve})},$=d=>{const X=new Set(Hs);X.has(d.name)?X.delete(d.name):X.add(d.name),Be({disabledSkills:[...X]})},Ee=new Set(u.skillsFullText??[]),Le=d=>{const X=new Set(Ee);X.has(d)?X.delete(d):X.add(d),Be({skillsFullText:[...X]})},Ue=new Set(u.disabledPlugins??[]),Ve=new Set(e.plugins.map(d=>d.id)),Lt=d=>{const X=new Set(Ue);X.has(d.id)?X.delete(d.id):X.add(d.id),Be({disabledPlugins:[...X]})},st=d=>{const X=new Set(Us);X.has(d.id)?X.delete(d.id):X.add(d.id),Be({disabledExtensions:[...X]})},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")},gt=d=>{const X=new Set(ft);X.has(d)?X.delete(d):X.add(d),Be({disabledAgentTools:[...X]})},$s=u.markersEnabled??!0,Sl=new Set(u.disabledMarkers??[]),wl=d=>{const X=new Set(Sl);!X.has(d)?X.add(d):X.delete(d),Be({disabledMarkers:[...X]})},qs=(d,X)=>{const ve={name:d,command:X,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=wt(),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()},Al=d=>{w(null),qs(`${a("uninstallTitle")} ${d}`,`pi remove npm:${d}`)},qa=d=>{Ae(null),qs(`${a("uninstallTitle")} ${d}`,`pi-web-ui uninstall ${d}`)},Wa=(d,X)=>{qs(`${a("pluginUpdate")} ${d}`,`pi-web-ui install ${X} --name ${d} --force`)},Il=d=>{qs(`${a("pluginInstall")} ${d.id}`,`pi-web-ui install ${d.source} --name ${d.id}`)},jl=d=>{ae({type:"plugin_catalog_remove",id:d})},Ll=()=>{const d=Fe.trim();d&&(ae({type:"plugin_catalog_add",entry:{source:d,...Ge.trim()?{id:Ge.trim()}:{},...At.trim()?{name:At.trim()}:{},...mt.trim()?{description:mt.trim()}:{},...xt.trim()?{icon:xt.trim()}:{}}}),Me(""),Xt(""),Ut(""),$t(""),qt(""),R(!1))},Rl=d=>{const X=new Set(u.reviewSkills.filter(ve=>!ve.enabled).map(ve=>ve.name));X.has(d.name)?X.delete(d.name):X.add(d.name),Be({reviewDisabledSkills:[...X]})},Dl=()=>Be({promptTemplate:v}),Pl=d=>{Be({promptOverrides:{[d]:W[d]??""}})},Bn=d=>{L.current===d&&(L.current=null),ee(null),_(X=>{const ve={...X};return delete ve[d],ve}),Be({promptOverrides:{[d]:""}})},hs=d=>me(X=>({...X,[d]:!X[d]})),Fn=(d,X)=>{_(ve=>({...ve,[d]:X})),ee(d)},Ol=()=>{j.current=!1,L.current=null,B(Vs),_({}),Be({promptTemplate:Vs,promptOverrides:{}})},Ml=d=>{B(X=>X.trim()?`${X}
332
+
333
+ {{${d}}}`:`{{${d}}}`)},Bl=v.trim()&&v.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(un,{className:"modal-head-icon"}),s.jsx("h2",{children:a("settingsTitle")}),s.jsx(ze,{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${g===d.id?" active":""}`,"aria-current":g===d.id?"true":void 0,title:d.label,onClick:()=>A(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:[g==="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(ze,{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:v,onFocus:()=>j.current=!0,onBlur:()=>{j.current=!1,Dl()},onChange:d=>B(d.target.value)}),s.jsxs("div",{className:"compose-toolbar",children:[s.jsx("span",{className:"set-field-label set-muted",children:a("promptInsertTokens")}),U.map(d=>s.jsx("button",{type:"button",className:"token-chip",title:l(`promptTok_${d}_desc`),onClick:()=>Ml(d),children:`{{${d}}}`},d))]})]}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",children:a("promptSourcesLabel")}),U.map(d=>{const X=W[d]??"",ve=u.promptSourceDefaults?.[d]??"",Qe=te===d,ct=ve.split(`
335
+ `).length>6||ve.length>480;if(bl(d)){const $e=X.trim()?X: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(ze,{text:l(`promptTok_${d}_desc`)})]}),X.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",title:a("promptReadonlyLockedHint"),onClick:()=>Bn(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(ze,{text:l(`promptTok_${d}_desc`)})]}),X.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",onClick:()=>Bn(d),children:a("promptResetSource")}):s.jsx("span",{className:"set-muted",children:a("promptAutoBadge")})]}),X.trim()||Qe?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"set-prompt-input override-input",rows:Math.min(10,Math.max(1,X.split(`
336
+ `).length)),autoFocus:Qe,placeholder:a("promptOverridePlaceholder"),value:X,onFocus:$e=>{L.current=d,ee(d);const nt=$e.currentTarget;nt.value&&nt.value===ve&&nt.setSelectionRange(nt.value.length,nt.value.length)},onBlur:()=>{L.current===d&&(L.current=null);const $e=W[d]??"";if($e.trim()&&$e===ve){Bn(d);return}Pl(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")}),!X.trim()&&ve.trim()&&s.jsx("button",{type:"button",className:"override-seed-btn",title:a("promptSourceSeedTip"),onClick:()=>Fn(d,ve),children:a("promptSourceSeedButton")})]})]}):s.jsx("div",{className:"source-default",title:a("promptSourceDefaultEditHint"),role:"button",tabIndex:0,onClick:()=>Fn(d,ve),onKeyDown:$e=>{($e.key==="Enter"||$e.key===" ")&&($e.preventDefault(),Fn(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:Ol,disabled:!Bl,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(ze,{text:a("settingsViewPromptHint")}),s.jsx(yn,{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":Se,onClick:()=>ie(d=>!d),children:[a("settingsViewToolsSchema")," ",Se?"▴":"▾"]}),Se&&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(ze,{text:a("settingsViewToolsSchemaHint")}),s.jsx(yn,{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")})]})})]}),g==="prompt-history"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(ra,{className:"set-section-icon"}),a("settingsPromptHistory"),s.jsx(ze,{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 X=Math.floor(Number(d.target.value)||0),ve={...ke,maxEntries:X};x(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),x(d),ea(d),Ne()}}),s.jsx(ze,{text:a("promptHistoryMaxHint")})]})]}),s.jsx(We,{title:a("promptHistoryCharLimit"),tip:a("promptHistoryCharLimitHint"),enabled:ke.charLimitEnabled,onToggle:()=>{const d={...ke,charLimitEnabled:!ke.charLimitEnabled};x(d),ea(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 X=Math.floor(Number(d.target.value)||0);x({...ke,charLimit:X})},onBlur:()=>{let d=Math.floor(Number(ke.charLimit)||0);(!Number.isFinite(d)||d<100)&&(d=100),d>2e4&&(d=2e4);const X={...ke,charLimit:d};x(X),ea(X),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}Gf(),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(Or,{style:{verticalAlign:"-2px",marginRight:4}}),a("settingsPromptHistoryDesc")]})]}),g==="tools"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Xa,{className:"set-section-icon"}),a("settingsTools")]}),s.jsx("div",{className:"set-field-label",children:a("toolsSectionTerminal")}),El.map(d=>s.jsx(We,{title:d,tip:a("settingsTerminalToolsDesc"),enabled:!ft.has(d),onToggle:()=>gt(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")}),Tl.map(d=>s.jsx(We,{title:d,tip:lt[d],enabled:!ft.has(d),onToggle:()=>gt(d)},d)),s.jsxs("div",{className:"set-field-label",children:[a("settingsMarkers"),s.jsx(ze,{text:`${a("settingsMarkersDesc")}
337
337
  ${a("markerRenameTip")}`})]}),s.jsx(We,{title:a("markersEnabled"),tip:`${a("markersEnabledDesc")}
338
- ${a("markersOffHint")}`,enabled:qs,onToggle:()=>Fe({markersEnabled:!qs})}),qs&&(u.markers?.length??0)===0&&s.jsxs("p",{className:"set-empty",children:[a("loading"),"..."]}),qs&&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:()=>xl(d.name)},d.name)),s.jsx(We,{title:rn,tip:`${a("todoListEnabledDesc")}
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:()=>wl(d.name)},d.name)),s.jsx(We,{title:rn,tip:`${a("todoListEnabledDesc")}
340
340
  ${a("todoListOffHint")}`,enabled:!ft.has(rn),onToggle:()=>gt(rn)}),s.jsx("div",{className:"set-field-label",children:a("toolsSectionOther")}),s.jsx(We,{title:sn,tip:`${a("editSoftEnabledDesc")}
341
341
  ${a("editSoftOffHint")}`,enabled:!ft.has(sn),onToggle:()=>gt(sn)}),s.jsx(We,{title:nn,tip:`${a("delegateTaskEnabledDesc")}
342
342
  ${a("delegateTaskOffHint")}`,enabled:!ft.has(nn),onToggle:()=>gt(nn)}),s.jsx(We,{title:an,tip:`${a("questionnaireEnabledDesc")}
343
- ${a("questionnaireOffHint")}`,enabled:!ft.has(an),onToggle:()=>gt(an)})]}),g==="question"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Qa,{className:"set-section-icon"}),a("settingsQuestionnaire")]}),s.jsx(We,{title:a("questionnaireEnabled"),tip:`${a("questionnaireEnabledDesc")}
344
- ${a("questionnaireOffHint")}`,enabled:u.questionnaireEnabled,onToggle:()=>Fe({questionnaireEnabled:!u.questionnaireEnabled})})]}),g==="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(ze,{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=>ps(d.target.value),onBlur:()=>{const d=Math.min(100,Math.max(0,Math.floor(Number(yt)||0)));ps(String(d)),d!==u.retryMaxAttempts&&Fe({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:()=>Fe({thinkingWrap:!(u.thinkingWrap??!0)})}),s.jsx(We,{title:a("toolsWrap"),tip:a("toolsWrapDesc"),enabled:u.toolsWrap??!0,onToggle:()=>Fe({toolsWrap:!(u.toolsWrap??!0)})}),s.jsx("hr",{className:"set-sep"}),s.jsx(We,{title:a("wideChat"),tip:a("wideChatDesc"),enabled:he,onToggle:()=>n0({wide:!he})}),s.jsx(We,{title:a("projectTitle"),tip:a("projectTitleDesc"),enabled:W,onToggle:()=>l0({projectName:!W})}),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(ze,{text:a("wallpaperDesc")})]}),s.jsxs("div",{className:"wallpaper-url-row",children:[s.jsx("input",{className:"set-input wallpaper-url",placeholder:a("wallpaperUrlPh"),value:F,maxLength:2e3,spellCheck:!1,onFocus:()=>{Oe.current=!0},onChange:d=>Le(d.target.value),onBlur:()=>{if(Oe.current=!1,!F.trim()&&ce.url.startsWith("data:")){Le("");return}const d=va(F);Le(d),d!==ce.url&&Es({...ce,url:d})},onKeyDown:d=>{d.key==="Enter"?d.target.blur():d.key==="Escape"&&(Le(ce.url.startsWith("data:")?"":ce.url),d.target.blur())}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:ye,onClick:()=>P.current?.click(),children:[s.jsx(yr,{})," ",a("wallpaperUpload")]}),s.jsx("input",{ref:P,type:"file",accept:"image/*",hidden:!0,onChange:Se})]}),Te&&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:ce.dim,onChange:d=>Es({...ce,dim:Number(d.target.value)})}),s.jsxs("output",{children:[ce.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:ce.blur,onChange:d=>Es({...ce,blur:Number(d.target.value)})}),s.jsxs("output",{children:[ce.blur,"px"]})]})]})]}),ce.url&&s.jsxs("div",{className:"wallpaper-current",children:[s.jsx("img",{className:"wallpaper-preview",src:ce.url,alt:""}),s.jsx("button",{type:"button",className:"wallpaper-clear",onClick:()=>{Le(""),Es({...ce,url:""})},children:a("wallpaperClear")})]})]})]}),g==="quick"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(ta,{className:"set-section-icon"}),a("quickPhrases"),s.jsx(ze,{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:()=>Fe({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:K,maxLength:200,onChange:d=>Ae(d.target.value),onKeyDown:d=>{d.key==="Enter"&&K.trim()&&(Fe({quickPhrases:[...u.quickPhrases,K.trim()]}),Ae(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!K.trim(),onClick:()=>{Fe({quickPhrases:[...u.quickPhrases,K.trim()]}),Ae("")},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,V)=>s.jsx("div",{className:"set-row",children:we?.index===V?s.jsx("div",{className:"set-row-info",children:s.jsx("input",{className:"set-input",autoFocus:!0,value:we.value,maxLength:200,placeholder:a("quickPhrasesEditPh"),onChange:_e=>Me({index:V,value:_e.target.value}),onKeyDown:_e=>{_e.key==="Enter"?Jt():_e.key==="Escape"&&Me(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:()=>Me({index:V,value:d}),children:s.jsx(hn,{})}),s.jsx("button",{type:"button",className:"set-icon-btn",title:a("quickPhrasesMoveUp"),disabled:V===0,onClick:()=>{const _e=[...u.quickPhrases];[_e[V-1],_e[V]]=[_e[V],_e[V-1]],Fe({quickPhrases:_e})},children:"↑"}),s.jsx("button",{type:"button",className:"set-icon-btn",title:a("quickPhrasesMoveDown"),disabled:V===u.quickPhrases.length-1,onClick:()=>{const _e=[...u.quickPhrases];[_e[V],_e[V+1]]=[_e[V+1],_e[V]],Fe({quickPhrases:_e})},children:"↓"}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:a("quickPhrasesDelete"),onClick:()=>Fe({quickPhrases:u.quickPhrases.filter((_e,Qe)=>Qe!==V)}),children:s.jsx(et,{})})]})]})},`${V}:${d}`))}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{Me(null),Fe({quickPhrases:Sn[o]??Sn.en})},children:a("quickPhrasesReset")})})]}),g==="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(ze,{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(h?"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${xe.has(d.name)?" on":""}`,title:a("skillFullTextDesc"),onClick:()=>De(d.name),children:a("skillFullTextShort")})},d.name))})]}),g==="extensions"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Bn,{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(h?"dshExtensionsNote":"noExtensions")}):s.jsx("div",{className:"set-list",children:u.extensions.map(d=>{const V=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:V?ie===d.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("uninstallConfirmHint"),onClick:()=>yl(V),children:a("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("uninstallHint"),onClick:()=>v(d.id),children:[s.jsx(et,{}),a("uninstallExt")]}):void 0},d.id)})})]}),g==="plugins"&&E&&s.jsx("div",{className:"set-section",children:s.jsx("div",{className:"set-note",children:a("updatesManaged")})}),g==="plugins"&&!E&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Bn,{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:je,onChange:d=>Ie(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=>$t(d.target.value)}),s.jsx("textarea",{className:"set-input",rows:2,placeholder:a("pluginCatalogDesc"),value:mt,onChange:d=>qt(d.target.value)}),s.jsxs("div",{className:"set-catalog-add-actions",children:[s.jsx("button",{type:"button",className:"set-uninstall confirm",disabled:!je.trim(),onClick:vl,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 V=Ve.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]}),V&&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:[V?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginUpdateHint"),onClick:()=>Ua(d.id,d.source),children:[s.jsx(kt,{}),a("pluginUpdate")]}),te===d.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("pluginUninstallHint"),onClick:()=>Ha(d.id),children:a("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginUninstallHint"),onClick:()=>me(d.id),children:[s.jsx(et,{}),a("uninstallExt")]})]}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginInstallHint"),onClick:()=>Nl(d),children:[s.jsx(Yt,{}),a("pluginInstall")]}),!d.builtin&&s.jsx("button",{type:"button",className:"set-uninstall",title:a("pluginCatalogRemoveHint"),onClick:()=>kl(d.id),children:s.jsx(Ke,{})})]})]},d.id)})})]}),g==="plugins"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Fn,{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:()=>Ua(d.id,d.source),children:[s.jsx(kt,{}),a("pluginUpdate")]}),te===d.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("pluginUninstallHint"),onClick:()=>Ha(d.id),children:a("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginUninstallHint"),onClick:()=>me(d.id),children:[s.jsx(et,{}),a("uninstallExt")]})]})},d.id),d.settingsSchema&&d.settingsSchema.length>0&&s.jsx(t0,{plugin:d})]}))})]}),g==="plugins"&&h&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Fn,{className:"set-section-icon"}),a("dshPatches"),s.jsx(ze,{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:[y0(d.size)," · ",new Date(d.mtimeMs).toLocaleString()]})]})},d.name))}),s.jsxs("p",{className:"set-hint",children:[a("dshPatchesPath")," ",e.dshPatches?.patchDir??""]})]}),g==="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(ze,{text:a("settingsReviewDesc")}),s.jsx("span",{className:"set-count",children:u.reviewSkills.length})]}),s.jsx(We,{title:a("goalModeEnabled"),tip:`${a("goalModeEnabledDesc")}
345
- ${a("goalModeOffHint")}`,enabled:u.goalModeEnabled,onToggle:()=>Fe({goalModeEnabled:!u.goalModeEnabled})}),s.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:a("reviewPromptPlaceholder"),value:x,onFocus:()=>U.current=!0,onBlur:()=>{U.current=!1,Fe({reviewPrompt:x})},onChange:d=>D(d.target.value)}),s.jsxs("div",{className:"set-field-label",children:[a("settingsReviewSkills"),h&&s.jsxs(s.Fragment,{children:[" ",s.jsx(ze,{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:()=>Cl(d)},`review-${d.name}`))})]}),g==="vision"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(pn,{className:"set-section-icon"}),a("settingsVisionBridge")]}),s.jsx(We,{title:a("visionBridgeEnabled"),tip:`${a("settingsVisionBridgeDesc")}
346
- ${a("visionBridgeOffHint")}`,enabled:u.visionBridgeEnabled,onToggle:()=>Fe({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=>Fe({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:ge,onChange:d=>{const V=d.target.value;O(V),Fe({visionBridgePromptMode:V})},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:G,onFocus:()=>R.current=!0,onBlur:()=>{R.current=!1;const d=ge==="replace"&&u.visionBridgeDefaultPrompt&&G===u.visionBridgeDefaultPrompt?"":G;Fe({visionBridgePromptMode:ge,visionBridgePrompt:d})},onChange:d=>Y(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")})}))]}),g==="presets"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(un,{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:C,onChange:d=>Z(d.target.value),onKeyDown:d=>{d.key==="Enter"&&C.trim()&&(ae({type:"save_preset",name:C.trim()}),Z(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!C.trim(),onClick:()=>{ae({type:"save_preset",name:C.trim()}),Z("")},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))})]}),g==="subagent-templates"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Ga,{className:"set-section-icon"}),a("settingsSubagentTemplates"),s.jsx(ze,{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:()=>ve({name:"",description:"",promptMode:"replace",systemPrompt:"",enabledSkills:[],enabledExtensions:[],model:"",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(ze,{text:a("subagentDefaultModelHint")})]}),s.jsxs("select",{className:"set-select",value:u.subagentDefaultModel??"",onChange:d=>Fe({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")}),X&&s.jsxs("div",{className:"tpl-editor",children:[s.jsxs("div",{className:"tpl-fields",children:[s.jsx("input",{className:"set-input",placeholder:a("tplNamePlaceholder"),value:X.name,onChange:d=>ve({...X,name:d.target.value})}),s.jsx("input",{className:"set-input",placeholder:a("tplDescriptionPlaceholder"),value:X.description,onChange:d=>ve({...X,description:d.target.value})}),s.jsx("input",{className:"set-input",placeholder:a("tplDescriptionEnPlaceholder"),value:X.descriptionEn??"",onChange:d=>ve({...X,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:X.promptMode,onChange:d=>ve({...X,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:X.model??"",onChange:d=>ve({...X,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.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${a("tplSystemPromptLabel")}${o==="zh"?":":": "}${a("tplSystemPromptPlaceholder")}`,value:X.systemPrompt,onChange:d=>ve({...X,systemPrompt:d.target.value})}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${a("tplSystemPromptLabel")}: ${a("tplSystemPromptEnPlaceholder")}`,value:X.systemPromptEn??"",onChange:d=>ve({...X,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${X.enabledSkills.includes(d.name)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:X.enabledSkills.includes(d.name),onChange:V=>{const _e=V.target.checked;ve({...X,enabledSkills:_e?[...X.enabledSkills,d.name]:X.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${X.enabledExtensions.includes(d.id)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:X.enabledExtensions.includes(d.id),onChange:V=>{const _e=V.target.checked;ve({...X,enabledExtensions:_e?[...X.enabledExtensions,d.id]:X.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:!X.name.trim(),onClick:()=>{ae({type:"save_subagent_template",template:{...X,name:X.name.trim()}}),ve(null)},children:a("tplSave")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>ve(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.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:()=>ve({...d}),children:a("subagentTemplateEdit")}),N===d.name?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("uninstallConfirmHint"),onClick:()=>{ae({type:"delete_subagent_template",name:d.name}),z(null)},children:a("uninstallConfirm")}):s.jsx("button",{type:"button",className:"set-icon-btn danger",title:a("tplDelete"),onClick:()=>z(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 k0(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 v0({servers:e,onClose:t}){const n=Pe(),[i,a]=c.useState(new Set),o=l=>a(u=>{const m=new Set(u);return m.has(l)?m.delete(l):m.add(l),m});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,m=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")," ",k0(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(m)?"open":""}`,title:`${n("bgTaskCommand")}: ${l.command}`,onClick:()=>o(m),children:[s.jsx(An,{}),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(cn,{}),s.jsx("span",{children:n("bgTaskStop")})]})]},m)})}),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(cn,{}),s.jsx("span",{children:n("bgTaskStopAll")})]})]})]})})}function C0(e,t){return e.toLowerCase().includes(t)}function _0({open:e,projects:t,fileSearch:n,sessionSearch:i,onClose:a,onSwitchSession:o,onSwitchProject:l,onPreviewFile:u}){const m=Pe(),E=Ct("cwd"),h=c.useRef(null),[g,w]=c.useState(""),k=c.useDeferredValue(g),[_,M]=c.useState(0),$=c.useRef(1),S=c.useRef(0),I=c.useRef(null);c.useEffect(()=>{if(!e)return;ae({type:"list_sessions"}),ae({type:"list_projects"});const D=g.trim();if(D){const U=++$.current;S.current=U,H(!0),ae({type:"search_files",reqId:U,query:D}),ae({type:"search_sessions",reqId:U,query:D})}requestAnimationFrame(()=>h.current?.select())},[e]);const[j,H]=c.useState(!1);c.useEffect(()=>{I.current&&clearTimeout(I.current);const D=k.trim();if(!D){H(!1);return}return I.current=setTimeout(()=>{const U=++$.current;S.current=U,H(!0),ae({type:"search_files",reqId:U,query:D}),ae({type:"search_sessions",reqId:U,query:D})},300),()=>{I.current&&clearTimeout(I.current)}},[k]);const ee=k.trim().toLowerCase(),J=c.useMemo(()=>!ee||!i||i.reqId!==S.current||!i.ok?[]:i.results,[i,ee]),ue=c.useMemo(()=>ee?t.filter(D=>C0(D.path,ee)).slice(0,10):[],[t,ee]),pe=c.useMemo(()=>!ee||!n||n.reqId!==S.current||!n.ok?[]:n.results,[n,ee]);c.useEffect(()=>{n&&n.reqId===S.current&&i&&i.reqId===S.current&&S.current!==0&&H(!1)},[n,i]);const G=!!n&&n.ok&&n.truncated,Y=c.useMemo(()=>[...J.map(D=>({kind:"session",path:D.path,anchors:D.anchors})),...ue.map(D=>({kind:"project",path:D.path})),...pe.filter(D=>D.type==="file").map(D=>({kind:"file",path:D.path,name:D.name}))],[J,ue,pe]);c.useEffect(()=>{M(0)},[k]);const ge=c.useCallback(D=>{if(D)if(D.kind==="session")o(D.path,D.anchors),a();else if(D.kind==="project"){l(D.path),ae({type:"list_sessions"}),ae({type:"list_projects"});const U=k.trim();if(U){const C=++$.current;S.current=C,H(!0),ae({type:"search_files",reqId:C,query:U}),ae({type:"search_sessions",reqId:C,query:U})}}else u(D.path,D.name)},[o,l,u,k]);c.useEffect(()=>{if(!e)return;const D=U=>{U.key==="Escape"?(U.preventDefault(),U.stopPropagation(),a()):U.key==="ArrowDown"?(U.preventDefault(),M(C=>Math.min(C+1,Y.length-1))):U.key==="ArrowUp"?(U.preventDefault(),M(C=>Math.max(C-1,0))):U.key==="Enter"&&(U.preventDefault(),ge(Y[_]))};return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[Y,_,ge,a,e]);const O=J.length+ue.length+pe.length,R=(D,U,C)=>s.jsxs("div",{className:"gs-section-head",children:[C,s.jsx("span",{children:D}),s.jsx("em",{children:U})]});let x=-1;return e?s.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:a,children:s.jsxs("div",{className:"gs-modal",onClick:D=>D.stopPropagation(),children:[s.jsxs("div",{className:"gs-input-row",children:[s.jsx(dn,{}),s.jsx("input",{ref:h,type:"text",value:g,placeholder:m("gsPlaceholder"),onChange:D=>w(D.target.value)}),s.jsx("button",{type:"button",className:"gs-close",title:m("close"),onClick:a,children:s.jsx(Ke,{})})]}),s.jsxs("div",{className:"gs-results",children:[!ee&&s.jsx("div",{className:"gs-empty",children:m("gsHint")}),ee&&O===0&&!G&&s.jsx("div",{className:"gs-empty",children:m(j?"gsSearching":"gsNoResults")}),J.length>0&&s.jsxs("div",{className:"gs-section",children:[R(m("gsSessions"),J.length,s.jsx(rs,{})),J.map(D=>{x++;const U=x;return s.jsxs("button",{type:"button",className:U===_?"gs-item active":"gs-item",onMouseEnter:()=>M(U),onClick:()=>ge({kind:"session",path:D.path,anchors:D.anchors}),children:[s.jsxs("span",{className:"gs-item-title",children:[D.name||D.path.split(/[\\/]/).pop(),s.jsx("em",{className:"gs-item-meta",children:D.messageCount})]}),s.jsx("span",{className:"gs-item-sub",children:D.firstMessage})]},D.path)})]}),ue.length>0&&s.jsxs("div",{className:"gs-section",children:[R(m("gsProjects"),ue.length,s.jsx(Bt,{})),ue.map(D=>{x++;const U=x,C=E&&D.path===E;return s.jsxs("button",{type:"button",className:U===_?"gs-item active":"gs-item",onMouseEnter:()=>M(U),onClick:()=>ge({kind:"project",path:D.path}),children:[s.jsxs("span",{className:"gs-item-title",children:[D.path.split(/[\\/]/).pop(),C&&s.jsx("em",{className:"gs-item-meta",children:m("gsCurrentProject")})]}),s.jsx("span",{className:"gs-item-sub",children:D.path})]},D.path)})]}),(pe.length>0||ee&&G)&&s.jsxs("div",{className:"gs-section",children:[R(m("gsFiles"),pe.length,s.jsx(vr,{})),pe.map(D=>{x++;const U=x;return s.jsxs("button",{type:"button",className:U===_?"gs-item active":"gs-item",disabled:D.type==="dir",title:D.type==="dir"?void 0:m("gsOpenPreview"),onMouseEnter:()=>M(U),onClick:()=>{D.type==="file"&&ge({kind:"file",path:D.path,name:D.name})},children:[s.jsx("span",{className:"gs-item-title",children:D.name}),s.jsx("span",{className:"gs-item-sub",children:D.path})]},`${D.type}:${D.path}`)}),G&&s.jsx("div",{className:"gs-truncated",children:m("gsTruncated")})]})]}),s.jsxs("div",{className:"gs-foot",children:[s.jsxs("span",{children:["↑↓ ",m("gsNavigate")]}),s.jsxs("span",{children:["Enter ",m("gsOpen")]}),s.jsxs("span",{children:["Esc ",m("gsCloseHint")]})]})]})}):null}const Zn=5e3;function S0({file:e,content:t,onAddLines:n,onAttach:i,onClose:a}){const o=Pe(),[l,u]=c.useState(null),[m,E]=c.useState(!1),[h,g]=c.useState(null),[w,k]=c.useState(!1),[_,M]=c.useState(!1),[$,S]=c.useState(!1),[I,j]=c.useState(""),[H,ee]=c.useState(!0),[J,ue]=c.useState(!0),[pe,G]=c.useState(!1),Y=c.useRef(!1),[ge,O]=c.useState(!0),[R,x]=c.useState(!1),[D,U]=c.useState(100),C=c.useRef(0),Z=c.useRef(!1),X=c.useRef(null);c.useEffect(()=>{E(!0),u(null),g(null),S(!1),j(""),ee(!0),ue(!0),G(!1),Y.current=!1,ae({type:"read_file",path:e.path})},[e.path]),c.useEffect(()=>{t&&t.path===e.path&&(u(t),$||j(t.text),E(!1))},[t,$,e.path]),c.useEffect(()=>{const se=Ee=>{if(Ee.key==="Escape"){F();return}if((Ee.ctrlKey||Ee.metaKey)&&Ee.key.toLowerCase()==="s"&&$){Ee.preventDefault(),ce();return}const Re=Ee.target,y=Re&&(Re.tagName==="INPUT"||Re.tagName==="TEXTAREA"||Re.isContentEditable);(Ee.ctrlKey||Ee.metaKey)&&Ee.key.toLowerCase()==="a"&&!y&&(Ee.preventDefault(),re())};return document.addEventListener("keydown",se),()=>document.removeEventListener("keydown",se)},[a,l,$,I]),c.useEffect(()=>{const se=()=>{Z.current=!1,k(!1)};return window.addEventListener("mouseup",se),()=>window.removeEventListener("mouseup",se)},[]);const ve=c.useMemo(()=>{if(!l)return[];const se=l.text.split(`
347
- `);return se.length>0&&se[se.length-1]===""&&se.pop(),se.slice(0,Zn)},[l]),N=l?.lines??0,z=N>Zn,de=(se,Ee)=>{if(Ee){const Re=C.current>0?C.current:se;g({start:Math.min(Re,se),end:Math.max(Re,se)})}else C.current=se,g({start:se,end:se})},re=()=>{ve.length!==0&&(C.current=1,g({start:1,end:ve.length}))},ke=()=>{h&&(n(e.path,e.name,h.start,h.end),M(!0),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>M(!1),1400))},oe=l!==null&&l.kind==="text"&&!l.binary&&!l.truncated,he=()=>{j(l?.text??""),S(!1),Y.current&&(Ts(e.name)&&ee(!0),xs(e.name)&&ue(!0))},W=()=>{if($){if(I!==(l?.text??"")&&!window.confirm(o("discardFileChanges")))return;he();return}!oe||!l||(Y.current=Ts(e.name)&&H||xs(e.name)&&J,Ts(e.name)&&ee(!1),xs(e.name)&&ue(!1),g(null),j(l.text),S(!0))},ce=()=>{!$||!l||!oe||ae({type:"write_file",path:e.path,text:I})&&(S(!1),Y.current&&(Ts(e.name)&&ee(!0),xs(e.name)&&ue(!0)),g(null))},F=()=>{$&&I!==(l?.text??"")&&!window.confirm(o("discardFileChanges"))||a()},Le=se=>{U(Math.min(200,Math.max(50,se)))},Oe=h?h.end-h.start+1:0,P=l?.binary??!1,ye=l?.truncated??!1,fe=l?.kind??"text",Te=Ts(e.name),Ne=xs(e.name),Se=Te&&H&&!$&&fe==="text"&&!P,Ce=Ne&&J&&!$&&fe==="text"&&!P,T=se=>vt(tt(`/api/file?clientId=${encodeURIComponent(bn())}&path=${encodeURIComponent(se)}`)),le=se=>{const Ee=se.split("/").map(ie=>encodeURIComponent(ie)).join("/"),y=/^[A-Za-z]:([\\/]|$)/.test(se)||se.startsWith("/")?`/api/preview/__abs__/${Ee}`:`/api/preview/${Ee}`;return vt(tt(`${y}?clientId=${encodeURIComponent(bn())}${pe?"&allowJs=1":""}`))};return s.jsx("div",{className:`fp-overlay ${R?"fullscreen":""}`,onMouseDown:se=>{se.target===se.currentTarget&&F()},children:s.jsxs("div",{className:`fp ${R?"fullscreen":""}`,style:{"--fp-zoom":D/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&&fe==="text"&&!P&&o("fileLines",{n:N}),l&&` · ${w0(l.size)}`]}),s.jsxs("span",{className:"fp-head-actions",children:[Te&&fe==="text"&&!P&&l&&s.jsx("button",{type:"button",className:`fp-attach markdown ${H?"on":""}`,"data-tip":o(H?"showMarkdownSource":"showMarkdownPreview"),disabled:$,onClick:()=>ee(se=>!se),children:H?s.jsx(pn,{}):s.jsx(Ja,{})}),Ne&&fe==="text"&&!P&&l&&s.jsx("button",{type:"button",className:`fp-attach html ${J?"on":""}`,"data-tip":o(J?"showHtmlSource":"showHtmlPreview"),disabled:$,onClick:()=>ue(se=>!se),children:J?s.jsx(Ja,{}):s.jsx(pn,{})}),fe==="text"&&!P&&l&&s.jsx("button",{type:"button",className:`fp-attach edit ${$?"on":""}`,"data-tip":o(ye?"fileEditTruncated":$?"exitEditFile":"editFile"),disabled:!oe&&!$,onClick:W,children:s.jsx(hn,{})}),fe==="text"&&!P&&!Se&&!Ce&&s.jsx("button",{type:"button",className:`fp-attach wrap ${ge?"on":""}`,"data-tip":o(ge?"disableWrap":"enableWrap"),onClick:()=>O(se=>!se),children:s.jsx(Ec,{})}),fe==="text"&&l&&s.jsxs("span",{className:"fp-zoom",children:[s.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":o("zoomOut"),disabled:D<=50,onClick:()=>Le(D-10),children:s.jsx(Jl,{})}),s.jsxs("button",{type:"button",className:"fp-zoom-val",title:o("resetZoom"),onClick:()=>U(100),children:[D,"%"]}),s.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":o("zoomIn"),disabled:D>=200,onClick:()=>Le(D+10),children:s.jsx(Zl,{})})]}),fe!=="video"&&fe!=="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(sa,{})}),s.jsx("button",{type:"button",className:`fp-attach full ${R?"on":""}`,"data-tip":o(R?"exitFullscreen":"fullscreen"),onClick:()=>x(se=>!se),children:R?s.jsx(oc,{}):s.jsx(cc,{})}),s.jsx("button",{type:"button",className:"fp-close",title:o("close"),onClick:F,children:s.jsx(Ke,{})})]})]}),ye&&fe==="text"&&!P&&s.jsx("div",{className:"fp-notice",children:o("previewTruncated")}),m&&!l&&s.jsx("div",{className:"fp-empty",children:o("loading")}),!m&&fe==="none"&&!P&&s.jsx("div",{className:"fp-empty",children:o("previewNotSupported")}),!m&&fe==="image"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("img",{className:"fp-media",src:T(e.path),alt:e.name})}),!m&&fe==="video"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("video",{className:"fp-media",src:T(e.path),controls:!0,preload:"metadata"})}),!m&&Ce&&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:()=>G(se=>!se),children:o(pe?"htmlDisableJs":"htmlEnableJs")})]}),s.jsx("iframe",{className:"fp-html-frame",src:le(e.path),title:e.name,sandbox:pe?"allow-scripts":"",referrerPolicy:"no-referrer"},pe?"js":"nojs")]}),!m&&Se&&l&&s.jsx("div",{className:"fp-markdown msg-text",children:s.jsx("div",{className:"fp-markdown-zoom",children:s.jsx(rt,{text:l.text})})}),!m&&P&&fe!=="image"&&fe!=="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})]}),!m&&$&&fe==="text"&&!P&&l&&s.jsx("textarea",{className:`fp-editor ${ge?"":"no-wrap"}`,value:I,onChange:se=>j(se.target.value),wrap:ge?"soft":"off",spellCheck:!1,autoFocus:!0}),!m&&!Se&&!Ce&&!$&&fe==="text"&&!P&&l&&ve.length===0&&s.jsx("div",{className:"fp-empty",children:o("emptyFile")}),!m&&!Se&&!Ce&&!$&&fe==="text"&&!P&&ve.length>0&&s.jsxs("div",{className:`fp-code ${w?"dragging":""} ${ge?"":"no-wrap"}`,onMouseDown:se=>{se.button===0&&se.preventDefault()},children:[ve.map((se,Ee)=>{const Re=Ee+1,y=h!==null&&Re>=h.start&&Re<=h.end;return s.jsxs("div",{className:`fp-line ${y?"sel":""}`,onMouseDown:ie=>{ie.button===0&&(de(Re,ie.shiftKey),Z.current=!0,k(!0))},onMouseEnter:()=>{Z.current&&de(Re,!0)},children:[s.jsx("span",{className:"fp-num",children:Re}),s.jsx("span",{className:"fp-code-text",children:se})]},Re)}),z&&s.jsx("div",{className:"fp-lines-note",children:o("previewLinesTruncated",{n:Zn})})]}),s.jsx("div",{className:"fp-foot",children:$?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:W,children:o("cancel")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:I===(l?.text??""),onClick:ce,children:[s.jsx(nc,{})," ",o("saveFile")]})]})]}):!Se&&!Ce&&fe==="text"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:h?o("selectedRange",{n:Oe,start:h.start,end:h.end}):o("selectLinesHint")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",disabled:ve.length===0,onClick:re,children:o("selectAll")}),s.jsx("button",{type:"button",className:"btn",disabled:!h,onClick:()=>g(null),children:o("clearSelection")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!h||P,onClick:ke,children:[_?s.jsx(Tt,{}):null,o(_?"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 w0(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}const ml="pi-web-sounds",ys={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function pl(){try{const e=localStorage.getItem(ml);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 A0(e){try{localStorage.setItem(ml,JSON.stringify(e))}catch{}}let Ns=null;function I0(){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 j0=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],L0=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],R0=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],D0=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],P0={question:j0,done:L0,start:R0,error:D0};function O0(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=pl()){if(!t.enabled||!t[e])return;const n=I0();if(!n)return;const i=Math.max(0,Math.min(1,t.volume/100));for(const a of P0[e])O0(n,a,i)}const M0=c.lazy(()=>Wl(()=>import("./TerminalPanel-CeruoZjh.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.TerminalPanel})));function B0({notice:e,onDismiss:t}){const n=Pe(),{locale:i}=Ht(),a=i!=="zh"&&e.textEn?e.textEn:e.text,[o,l]=c.useState(!1);c.useEffect(()=>{if(o)return;const m=setTimeout(()=>t(e.id),e.level==="error"?12e3:7e3);return()=>clearTimeout(m)},[o,e.id,e.level,t]);const u=e.level==="error"?kc:e.level==="warning"?Nc:hc;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 F0=[],hl=180,fl=520,gl=240,bl=e=>`pi-web-ui:${e}-panel-width`;function lr(e){const t=Number(localStorage.getItem(bl(e)));return Number.isFinite(t)&&t>=hl&&t<=fl?t:gl}const _a=e=>`pi-web-ui:${e}-panel-collapsed`;function cr(e){return localStorage.getItem(_a(e))==="1"}function ur({side:e,width:t,onResize:n}){const i=Pe(),a=c.useCallback(o=>{o.preventDefault();const l=o.clientX,u=t;let m=u;const E=g=>{const w=e==="left"?g.clientX-l:l-g.clientX;m=Math.min(fl,Math.max(hl,Math.round(u+w))),n(m)},h=()=>{window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",h),document.body.classList.remove("panel-resizing"),localStorage.setItem(bl(e),String(m))};window.addEventListener("pointermove",E),window.addEventListener("pointerup",h),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(gl)})}function dr({side:e,onClick:t}){const n=Pe();return s.jsx("button",{type:"button",className:`panel-rail panel-rail-${e}`,title:n("expandPanel"),onClick:t,children:e==="left"?s.jsx(Cr,{}):s.jsx(_r,{})})}function H0(){const e=Pe(),{locale:t}=Ht(),{chat:n,send:i,dismissNotice:a,pushNotice:o,terminal:l}=Au(),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:Sn[t]??Sn.en,quickPhrasesSeeded:!0}))},[n.ready,n.settings,i,t]);const m=n.state?.cwd??"",E=nl();c.useEffect(()=>{const q=E?r0(m):"";document.title=q?`${q} — pi-web-ui`:e("docTitle")},[m,E,e]);const[h,g]=c.useState([]),[w,k]=c.useState(null),[_,M]=c.useState(!1),[$,S]=c.useState("chat"),I=q=>!n.tabs||q==="chat"||n.tabs.includes(q),j=$.startsWith("plugin:")?"plugins":$,H=I(j)?$:"chat",ee=c.useMemo(()=>n.plugins.filter(q=>!n.settings?.disabledPlugins?.includes(q.id)),[n.plugins,n.settings?.disabledPlugins]),[J,ue]=c.useState([]);c.useEffect(()=>gu(ue),[]),c.useEffect(()=>{Xp(i),Jp(ee,n.pluginsEpoch),bu(ee,n.pluginsEpoch)},[ee,n.pluginsEpoch,i]);const pe=c.useRef(n);pe.current=n;const G=c.useRef(S);G.current=S,c.useEffect(()=>(ir(Qf({send:i,isReady:()=>!!pe.current.state,setView:q=>G.current(q),getCwd:()=>pe.current.state?.cwd??"",getConversationId:()=>pe.current.state?.conversationId??null,isConversationBlank:()=>(pe.current.state?.messages.length??0)===0})),()=>ir(null)),[i]);const[Y,ge]=c.useState(()=>lr("left")),[O,R]=c.useState(()=>lr("right")),x=c.useCallback(q=>ge(q),[]),D=c.useCallback(q=>R(q),[]),[U,C]=c.useState(()=>cr("left")),[Z,X]=c.useState(()=>cr("right")),ve=c.useCallback(()=>{C(q=>(localStorage.setItem(_a("left"),q?"0":"1"),!q))},[]),N=c.useCallback(()=>{X(q=>(localStorage.setItem(_a("right"),q?"0":"1"),!q))},[]),[z,de]=c.useState(null),[re,ke]=c.useState(()=>window.matchMedia("(max-width: 768px)").matches);c.useEffect(()=>{const q=window.matchMedia("(max-width: 768px)"),xe=De=>ke(De.matches);return q.addEventListener("change",xe),()=>q.removeEventListener("change",xe)},[]);const[oe,he]=c.useState(!1),[W,ce]=c.useState(!1),[F,Le]=c.useState(!1),Oe=el(),[P,ye]=c.useState(!1),[fe,Te]=c.useState(!1),[Ne,Se]=c.useState(null);c.useEffect(()=>{if(!Ne)return;const q=setTimeout(()=>Se(null),15e3);return()=>clearTimeout(q)},[Ne]),c.useEffect(()=>{const q=De=>{const Ue=De.detail,Ve=Ue?.title||e("pluginCommandFallback"),Lt=Ue?.command;if(!Lt||!n.ready)return;const st={name:Ve,command:Lt,cwd:"${pwd}"},lt=n.terminals.find(gt=>gt.title===Ve);if(lt)l.restart(lt.id),i({type:"run_command",terminalId:lt.id,conversationId:lt.conversationId,command:st,cols:80,rows:24});else{const gt=wt();l.create({id:gt,conversationId:n.activeConversationId||n.state?.conversationId||"",title:Ve,cwd:n.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:st})}S("terminal")};window.addEventListener("pi-web-ui:plugin-run-command",q);const xe=De=>{const Ue=De.detail;typeof Ue=="string"&&Ue&&i({type:"switch_conversation",id:Ue})};return window.addEventListener("pi-web-ui:switch-conversation",xe),()=>{window.removeEventListener("pi-web-ui:plugin-run-command",q),window.removeEventListener("pi-web-ui:switch-conversation",xe)}},[n,l,i]),c.useEffect(()=>{const q=xe=>{!(xe.ctrlKey||xe.metaKey)||xe.key.toLowerCase()!=="k"||(xe.preventDefault(),Te(De=>!De))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const[Ce,T]=c.useState(pl),{themes:le,theme:se,switchTheme:Ee}=nh();E0();const Re=c.useRef(null),y=c.useRef(null),ie=c.useRef(null),v=c.useRef(0),te=c.useRef(!1),me=c.useRef(n.terminals);c.useEffect(()=>{A0(Ce)},[Ce]),c.useEffect(()=>{const q=me.current;me.current=n.terminals;for(const xe of n.terminals){const De=xe.command?.command??"";!q.find(Ve=>Ve.id===xe.id)?.running||xe.running||(De.startsWith("pi remove ")?i({type:"extensions_reload"}):De.startsWith("pi-web-ui install ")||De.startsWith("pi-web-ui uninstall ")?i({type:"plugins_reload"}):De.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,xe=Re.current;Re.current=q,xe!==null&&(!xe&&q?ts("start",Ce):xe&&!q&&(ts("done",Ce),Ks(e("notifyDoneTitle"),e("notifyDoneBody"))))},[n.state?.isStreaming,Ce]),c.useEffect(()=>{const q=n.dialog?.id??null;q!==null&&q!==y.current&&(ts("question",Ce),Ks(e("notifyQuestionTitle"),e("notifyQuestionBody"))),y.current=q},[n.dialog,Ce]),c.useEffect(()=>{const q=n.question?.id??null;q!==null&&q!==ie.current&&(ts("question",Ce),Ks(e("notifyQuestionTitle"),e("notifyQuestionBody"))),ie.current=q},[n.question,Ce]),c.useEffect(()=>{const q=[...n.notices].reverse().find(xe=>xe.level==="error");q&&q.id!==v.current&&(v.current=q.id,ts("error",Ce),Ks(e("notifyErrorTitle"),e("notifyErrorBody")))},[n.notices,Ce]);const je=(q,xe,De,Ue=!1,Ve)=>{const Lt=`${q}|${De}|${Ve?`${Ve.start}-${Ve.end}`:""}`;g(st=>st.some(lt=>`${lt.path}|${lt.mode}|${lt.lines?`${lt.lines.start}-${lt.lines.end}`:""}`===Lt)?st:[...st,{path:q,name:xe,mode:De,isDir:Ue,...Ve?{lines:Ve}:{}}])},Ie=q=>g(xe=>xe.filter(De=>De.key?De.key!==q:De.path!==q)),Ge=c.useCallback(q=>(!q.type.startsWith("list_")&&!q.type.startsWith("get_")&&de(null),i(q)),[i]),Xt=c.useRef(0),At=c.useRef(0),Ut=q=>{const xe=Date.now();n.state?.model&&!n.state.model.vision&&xe-At.current>1e4&&(At.current=xe,o("warning",e("imageNotSupported")));const De=`paste-${++Xt.current}`;g(Ue=>[...Ue,{path:"",key:De,name:q.name,mode:"inline",imageData:q.data,mimeType:q.mimeType}])},mt=async q=>{for(const xe of q){const De=await Ma(xe);if(!De){o("error",e("imageLoadFailed",{name:xe.name}));continue}Ut(De)}},qt=20*1024*1024,xt=c.useRef(0),$t=async q=>{if(q.size>qt){o("warning",e("fileTooLarge",{name:q.name,size:qt/1024/1024}));return}let xe;try{xe=(await new Promise((Ve,Lt)=>{const st=new FileReader;st.onload=()=>Ve(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 De=`upload-${++xt.current}`;g(Ue=>[...Ue,{path:"",key:De,name:q.name,mode:"inline",fileData:xe,size:q.size,mimeType:q.type||void 0}])},It=async q=>{for(const xe of q)_t(xe.type)?await mt([xe]):await $t(xe)},L=c.useCallback((q,xe,De)=>{i({type:"edit_message",messageId:q,text:xe,attachments:De})},[i]),K=c.useCallback((q,xe)=>{i({type:"queue_remove",kind:q,text:xe})},[i]),[Ae,we]=c.useState([]),Me=c.useRef(0),He=c.useCallback((q,xe)=>{i({type:"queue_remove",kind:q,text:xe}),Me.current+=1;const De={text:xe,seq:Me.current};we(Ue=>[...Ue.slice(-9),De])},[i]),ot=c.useCallback(()=>ce(!0),[]),yt=c.useCallback(()=>g([]),[]),ps=c.useCallback(Ie,[]),ft=c.useCallback(mt,[mt]),Pn=c.useCallback(It,[It]),jt=n.state?.model,Hs=n.state?.thinkingLevel,Us=n.state?.availableThinkingLevels,Fe=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:wt(),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(te.current){if(H!=="terminal"||n.terminals.length!==0){te.current=!1;return}Jt()&&(te.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 xe=Array.from(q.dataTransfer?.files??[]);if(xe.length===0){o("warning",e("foldersNotSupported"));return}const De=xe.filter(Ve=>_t(Ve.type)),Ue=xe.filter(Ve=>!_t(Ve.type));De.length>0&&mt(De),Ue.length>0&&It(Ue)},children:[_&&s.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:s.jsxs("span",{children:["📎 ",e("dropHereToAttach")]})}),s.jsx(nu,{chat:n,terminal:l,view:H,plugins:ee,onViewChange:q=>{te.current=q==="terminal"&&n.terminals.length===0,te.current&&Jt()&&(te.current=!1),S(q),de(null)},onOpenPanel:de,onOpenSettings:()=>Le(!0),onOpenBgTasks:()=>ye(!0),onOpenGlobalSearch:()=>Te(!0),sound:Ce,onSoundChange:T,onSoundPreview:q=>ts(q,Ce),themes:le,theme:se,onThemeChange:Ee}),n.protocolMismatch&&s.jsxs("div",{className:"protocol-banner",children:["⚠ ",e("protocolMismatch")]}),s.jsx("div",{className:"notices",children:n.notices.map(q=>s.jsx(B0,{notice:q,onDismiss:a},q.id))}),s.jsx(Ef,{currentModelId:jt?`${jt.provider}/${jt.id}`:null,children:s.jsxs("div",{className:"layout",style:{"--left-w":`${Y}px`,"--right-w":`${O}px`},children:[z&&s.jsx("div",{className:"drawer-backdrop",onClick:()=>de(null)}),s.jsxs("div",{className:`view-pane ${H==="chat"?"":"hidden"}`,children:[!re&&U&&s.jsx(dr,{side:"left",onClick:ve}),s.jsx("div",{className:`panel-drawer drawer-left ${z==="left"?"open":""}${re?"":U?" hidden":""}`,children:s.jsx(uu,{collapsible:!re,onToggleCollapse:ve,panelSend:Ge,active:!re||z==="left",sessionFile:n.state?.sessionFile??null,conversations:n.conversations,sessions:n.sessions,projects:n.projects,activeConversationId:n.activeConversationId})}),!re&&s.jsx(ur,{side:"left",width:Y,onResize:x}),s.jsxs("main",{className:Oe?"main wide-chat":"main",children:[n.state?s.jsx(Cf,{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&&vn(`${q.provider}/${q.id}`)}},onRemoveQueued:K,onRecallQueued:He,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,jumpTarget:Ne,onJumpDone:()=>Se(null)},n.state.conversationId??"boot"):s.jsx("div",{className:"boot-wait",children:n.ready?e("loadingSession"):e("connectingServer")}),n.settings?.goalModeEnabled!==!1&&s.jsx(Of,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId}),n.dialog&&s.jsx($f,{dialog:n.dialog}),n.question&&s.jsx(Wf,{question:n.question}),s.jsx(Pf,{streaming:n.state?.isStreaming??!1,messages:n.state?.messages??F0,slashCommands:n.slashCommands,modelState:Fe,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,attachments:h,onRemoveAttachment:ps,onAddImageFiles:ft,onAddLocalFiles:Pn,onNotice:o,onManageModels:ot,onSent:yt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:Ae})]}),!re&&s.jsx(ur,{side:"right",width:O,onResize:D}),s.jsx("div",{className:`panel-drawer drawer-right ${z==="right"?"open":""}${re?"":Z?" hidden":""}`,children:s.jsx(Bu,{collapsible:!re,onToggleCollapse:N,panelSend:Ge,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:(q,xe,De,Ue)=>{de(null),je(q,xe,De,Ue)},onPreview:(q,xe)=>{de(null),k({path:q,name:xe})},onNotice:(q,xe)=>o(q,xe)})}),!re&&Z&&s.jsx(dr,{side:"right",onClick:N})]}),s.jsx("div",{className:`view-pane ${H==="terminal"?"":"hidden"}`,children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(M0,{chat:n,terminal:l})})}),s.jsx("div",{className:`view-pane ${H==="git"?"":"hidden"}`,children:s.jsx(Yf,{chat:n,terminal:l,active:H==="git",onSwitchToTerminal:()=>S("terminal")})}),J.map(q=>{const xe=`plugin:${q.info.id}`;return s.jsx("div",{className:`view-pane ${H===xe?"":"hidden"}`,children:s.jsx(Gf,{entry:q})},q.info.id)})]})}),s.jsx(Uf,{chat:n}),w&&s.jsx(S0,{file:w,content:n.fileContent,onAddLines:(q,xe,De,Ue)=>je(q,xe,"lines",!1,{start:De,end:Ue}),onAttach:(q,xe,De)=>je(q,xe,De),onClose:()=>k(null)}),n.ready&&n.state&&n.state.piConfigured===!1&&!oe&&!W&&s.jsx(Xf,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,installResult:n.installResult,onClose:()=>he(!0)}),W&&s.jsx(e0,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,fetchModelsResult:n.fetchModelsResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>ce(!1)}),F&&s.jsx(N0,{chat:n,terminal:l,onSwitchToTerminal:()=>S("terminal"),onClose:()=>Le(!1)}),P&&s.jsx(v0,{servers:n.bgServers,onClose:()=>ye(!1)}),s.jsx(_0,{open:fe,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>Te(!1),onSwitchSession:(q,xe)=>{i({type:"switch_session",path:q});const De=xe&&xe[0];Se(De?{path:q,role:De.role,timestamp:De.timestamp}:null)},onSwitchProject:q=>{i({type:"set_cwd",path:q})},onPreviewFile:(q,xe)=>{k({path:q,name:xe})}})]})}function U0(){typeof document>"u"||(El(q0()),W0())}function El(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty("--msgs-gutter",`${Math.round(e*100)/100}px`)}function q0(){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 $0(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 W0(){const e=()=>{const i=document.querySelector(".messages");return i?(El($0(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)}Sc();Lo(jo());U0();Ul.createRoot(document.getElementById("root")).render(s.jsx(c.StrictMode,{children:s.jsx(Bc,{children:s.jsx(H0,{})})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=Ar();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,V0 as b,Pe as c,dt as d,G0 as e,fn as f,et as g,lc as h,An as i,Ke as j,wt as r,Ht as u};
343
+ ${a("questionnaireOffHint")}`,enabled:!ft.has(an),onToggle:()=>gt(an)})]}),g==="question"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Za,{className:"set-section-icon"}),a("settingsQuestionnaire")]}),s.jsx(We,{title:a("questionnaireEnabled"),tip:`${a("questionnaireEnabledDesc")}
344
+ ${a("questionnaireOffHint")}`,enabled:u.questionnaireEnabled,onToggle:()=>Be({questionnaireEnabled:!u.questionnaireEnabled})})]}),g==="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(ze,{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=>ps(d.target.value),onBlur:()=>{const d=Math.min(100,Math.max(0,Math.floor(Number(yt)||0)));ps(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:pe,onToggle:()=>x0({wide:!pe})}),s.jsx(We,{title:a("projectTitle"),tip:a("projectTitleDesc"),enabled:J,onToggle:()=>C0({projectName:!J})}),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(ze,{text:a("wallpaperDesc")})]}),s.jsxs("div",{className:"wallpaper-url-row",children:[s.jsx("input",{className:"set-input wallpaper-url",placeholder:a("wallpaperUrlPh"),value:H,maxLength:2e3,spellCheck:!1,onFocus:()=>{je.current=!0},onChange:d=>Ie(d.target.value),onBlur:()=>{if(je.current=!1,!H.trim()&&oe.url.startsWith("data:")){Ie("");return}const d=Sa(H);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(Ar,{})," ",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")})]})]})]}),g==="quick"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(aa,{className:"set-section-icon"}),a("quickPhrases"),s.jsx(ze,{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=>we(d.target.value),onKeyDown:d=>{d.key==="Enter"&&V.trim()&&(Be({quickPhrases:[...u.quickPhrases,V.trim()]}),we(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!V.trim(),onClick:()=>{Be({quickPhrases:[...u.quickPhrases,V.trim()]}),we("")},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,X)=>s.jsx("div",{className:"set-row",children:_e?.index===X?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:X,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:X,value:d}),children:s.jsx(hn,{})}),s.jsx("button",{type:"button",className:"set-icon-btn",title:a("quickPhrasesMoveUp"),disabled:X===0,onClick:()=>{const ve=[...u.quickPhrases];[ve[X-1],ve[X]]=[ve[X],ve[X-1]],Be({quickPhrases:ve})},children:"↑"}),s.jsx("button",{type:"button",className:"set-icon-btn",title:a("quickPhrasesMoveDown"),disabled:X===u.quickPhrases.length-1,onClick:()=>{const ve=[...u.quickPhrases];[ve[X],ve[X+1]]=[ve[X+1],ve[X]],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!==X)}),children:s.jsx(et,{})})]})]})},`${X}:${d}`))}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{Pe(null),Be({quickPhrases:An[o]??An.en})},children:a("quickPhrasesReset")})})]}),g==="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(ze,{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(h?"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:()=>$(d),action:s.jsx("button",{type:"button",className:`tpl-chip${Ee.has(d.name)?" on":""}`,title:a("skillFullTextDesc"),onClick:()=>Le(d.name),children:a("skillFullTextShort")})},d.name))})]}),g==="extensions"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Hn,{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(h?"dshExtensionsNote":"noExtensions")}):s.jsx("div",{className:"set-list",children:u.extensions.map(d=>{const X=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:X?De===d.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:a("uninstallConfirmHint"),onClick:()=>Al(X),children:a("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:a("uninstallHint"),onClick:()=>w(d.id),children:[s.jsx(et,{}),a("uninstallExt")]}):void 0},d.id)})})]}),g==="plugins"&&T&&s.jsx("div",{className:"set-section",children:s.jsx("div",{className:"set-note",children:a("updatesManaged")})}),g==="plugins"&&!T&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Hn,{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:()=>R(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:mt,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:Ll,children:a("pluginCatalogAddSubmit")}),s.jsx("button",{type:"button",className:"set-uninstall",onClick:()=>R(!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 X=Ve.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]}),X&&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:[X?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"set-uninstall",title:a("pluginUpdateHint"),onClick:()=>Wa(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:()=>qa(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:()=>Il(d),children:[s.jsx(Yt,{}),a("pluginInstall")]}),!d.builtin&&s.jsx("button",{type:"button",className:"set-uninstall",title:a("pluginCatalogRemoveHint"),onClick:()=>jl(d.id),children:s.jsx(Ke,{})})]})]},d.id)})})]}),g==="plugins"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Un,{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:()=>Wa(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:()=>qa(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(E0,{plugin:d})]}))})]}),g==="plugins"&&h&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Un,{className:"set-section-icon"}),a("dshPatches"),s.jsx(ze,{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:[B0(d.size)," · ",new Date(d.mtimeMs).toLocaleString()]})]})},d.name))}),s.jsxs("p",{className:"set-hint",children:[a("dshPatchesPath")," ",e.dshPatches?.patchDir??""]})]}),g==="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(ze,{text:a("settingsReviewDesc")}),s.jsx("span",{className:"set-count",children:u.reviewSkills.length})]}),s.jsx(We,{title:a("goalModeEnabled"),tip:`${a("goalModeEnabledDesc")}
345
+ ${a("goalModeOffHint")}`,enabled:u.goalModeEnabled,onToggle:()=>Be({goalModeEnabled:!u.goalModeEnabled})}),s.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:a("reviewPromptPlaceholder"),value:y,onFocus:()=>q.current=!0,onBlur:()=>{q.current=!1,Be({reviewPrompt:y})},onChange:d=>D(d.target.value)}),s.jsxs("div",{className:"set-field-label",children:[a("settingsReviewSkills"),h&&s.jsxs(s.Fragment,{children:[" ",s.jsx(ze,{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:()=>Rl(d)},`review-${d.name}`))})]}),g==="vision"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(pn,{className:"set-section-icon"}),a("settingsVisionBridge")]}),s.jsx(We,{title:a("visionBridgeEnabled"),tip:`${a("settingsVisionBridgeDesc")}
346
+ ${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 X=d.target.value;O(X),Be({visionBridgePromptMode:X})},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:()=>M.current=!0,onBlur:()=>{M.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")})}))]}),g==="presets"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(un,{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:C,onChange:d=>se(d.target.value),onKeyDown:d=>{d.key==="Enter"&&C.trim()&&(ae({type:"save_preset",name:C.trim()}),se(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!C.trim(),onClick:()=>{ae({type:"save_preset",name:C.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))})]}),g==="subagent-templates"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Qa,{className:"set-section-icon"}),a("settingsSubagentTemplates"),s.jsx(ze,{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:"",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(ze,{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.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:X=>{const ve=X.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:X=>{const ve=X.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.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 H0(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 U0({servers:e,onClose:t}){const n=Re(),[i,a]=c.useState(new Set),o=l=>a(u=>{const m=new Set(u);return m.has(l)?m.delete(l):m.add(l),m});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,m=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")," ",H0(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(m)?"open":""}`,title:`${n("bgTaskCommand")}: ${l.command}`,onClick:()=>o(m),children:[s.jsx(jn,{}),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(cn,{}),s.jsx("span",{children:n("bgTaskStop")})]})]},m)})}),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(cn,{}),s.jsx("span",{children:n("bgTaskStopAll")})]})]})]})})}function $0(e,t){return e.toLowerCase().includes(t)}function q0({open:e,projects:t,fileSearch:n,sessionSearch:i,onClose:a,onSwitchSession:o,onSwitchProject:l,onPreviewFile:u}){const m=Re(),T=Ct("cwd"),h=c.useRef(null),[g,A]=c.useState(""),N=c.useDeferredValue(g),[v,B]=c.useState(0),W=c.useRef(1),_=c.useRef(0),j=c.useRef(null);c.useEffect(()=>{if(!e)return;ae({type:"list_sessions"}),ae({type:"list_projects"});const D=g.trim();if(D){const q=++W.current;_.current=q,U(!0),ae({type:"search_files",reqId:q,query:D}),ae({type:"search_sessions",reqId:q,query:D})}requestAnimationFrame(()=>h.current?.select())},[e]);const[L,U]=c.useState(!1);c.useEffect(()=>{j.current&&clearTimeout(j.current);const D=N.trim();if(!D){U(!1);return}return j.current=setTimeout(()=>{const q=++W.current;_.current=q,U(!0),ae({type:"search_files",reqId:q,query:D}),ae({type:"search_sessions",reqId:q,query:D})},300),()=>{j.current&&clearTimeout(j.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(D=>$0(D.path,te)).slice(0,10):[],[t,te]),me=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&&U(!1)},[n,i]);const Q=!!n&&n.ok&&n.truncated,G=c.useMemo(()=>[...ee.map(D=>({kind:"session",path:D.path,anchors:D.anchors})),...le.map(D=>({kind:"project",path:D.path})),...me.filter(D=>D.type==="file").map(D=>({kind:"file",path:D.path,name:D.name}))],[ee,le,me]);c.useEffect(()=>{B(0)},[N]);const ce=c.useCallback(D=>{if(D)if(D.kind==="session")o(D.path,D.anchors),a();else if(D.kind==="project"){l(D.path),ae({type:"list_sessions"}),ae({type:"list_projects"});const q=N.trim();if(q){const C=++W.current;_.current=C,U(!0),ae({type:"search_files",reqId:C,query:q}),ae({type:"search_sessions",reqId:C,query:q})}}else u(D.path,D.name)},[o,l,u,N]);c.useEffect(()=>{if(!e)return;const D=q=>{q.key==="Escape"?(q.preventDefault(),q.stopPropagation(),a()):q.key==="ArrowDown"?(q.preventDefault(),B(C=>Math.min(C+1,G.length-1))):q.key==="ArrowUp"?(q.preventDefault(),B(C=>Math.max(C-1,0))):q.key==="Enter"&&(q.preventDefault(),ce(G[v]))};return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[G,v,ce,a,e]);const O=ee.length+le.length+me.length,M=(D,q,C)=>s.jsxs("div",{className:"gs-section-head",children:[C,s.jsx("span",{children:D}),s.jsx("em",{children:q})]});let y=-1;return e?s.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:a,children:s.jsxs("div",{className:"gs-modal",onClick:D=>D.stopPropagation(),children:[s.jsxs("div",{className:"gs-input-row",children:[s.jsx(dn,{}),s.jsx("input",{ref:h,type:"text",value:g,placeholder:m("gsPlaceholder"),onChange:D=>A(D.target.value)}),s.jsx("button",{type:"button",className:"gs-close",title:m("close"),onClick:a,children:s.jsx(Ke,{})})]}),s.jsxs("div",{className:"gs-results",children:[!te&&s.jsx("div",{className:"gs-empty",children:m("gsHint")}),te&&O===0&&!Q&&s.jsx("div",{className:"gs-empty",children:m(L?"gsSearching":"gsNoResults")}),ee.length>0&&s.jsxs("div",{className:"gs-section",children:[M(m("gsSessions"),ee.length,s.jsx(rs,{})),ee.map(D=>{y++;const q=y;return s.jsxs("button",{type:"button",className:q===v?"gs-item active":"gs-item",onMouseEnter:()=>B(q),onClick:()=>ce({kind:"session",path:D.path,anchors:D.anchors}),children:[s.jsxs("span",{className:"gs-item-title",children:[D.name||D.path.split(/[\\/]/).pop(),s.jsx("em",{className:"gs-item-meta",children:D.messageCount})]}),s.jsx("span",{className:"gs-item-sub",children:D.firstMessage})]},D.path)})]}),le.length>0&&s.jsxs("div",{className:"gs-section",children:[M(m("gsProjects"),le.length,s.jsx(Bt,{})),le.map(D=>{y++;const q=y,C=T&&D.path===T;return s.jsxs("button",{type:"button",className:q===v?"gs-item active":"gs-item",onMouseEnter:()=>B(q),onClick:()=>ce({kind:"project",path:D.path}),children:[s.jsxs("span",{className:"gs-item-title",children:[D.path.split(/[\\/]/).pop(),C&&s.jsx("em",{className:"gs-item-meta",children:m("gsCurrentProject")})]}),s.jsx("span",{className:"gs-item-sub",children:D.path})]},D.path)})]}),(me.length>0||te&&Q)&&s.jsxs("div",{className:"gs-section",children:[M(m("gsFiles"),me.length,s.jsx(Lr,{})),me.map(D=>{y++;const q=y;return s.jsxs("button",{type:"button",className:q===v?"gs-item active":"gs-item",disabled:D.type==="dir",title:D.type==="dir"?void 0:m("gsOpenPreview"),onMouseEnter:()=>B(q),onClick:()=>{D.type==="file"&&ce({kind:"file",path:D.path,name:D.name})},children:[s.jsx("span",{className:"gs-item-title",children:D.name}),s.jsx("span",{className:"gs-item-sub",children:D.path})]},`${D.type}:${D.path}`)}),Q&&s.jsx("div",{className:"gs-truncated",children:m("gsTruncated")})]})]}),s.jsxs("div",{className:"gs-foot",children:[s.jsxs("span",{children:["↑↓ ",m("gsNavigate")]}),s.jsxs("span",{children:["Enter ",m("gsOpen")]}),s.jsxs("span",{children:["Esc ",m("gsCloseHint")]})]})]})}):null}const sa=5e3;function W0({file:e,content:t,onAddLines:n,onAttach:i,onClose:a}){const o=Re(),[l,u]=c.useState(null),[m,T]=c.useState(!1),[h,g]=c.useState(null),[A,N]=c.useState(!1),[v,B]=c.useState(!1),[W,_]=c.useState(!1),[j,L]=c.useState(""),[U,te]=c.useState(!0),[ee,le]=c.useState(!0),[me,Q]=c.useState(!1),G=c.useRef(!1),[ce,O]=c.useState(!0),[M,y]=c.useState(!1),[D,q]=c.useState(100),C=c.useRef(0),se=c.useRef(!1),K=c.useRef(null);c.useEffect(()=>{T(!0),u(null),g(null),_(!1),L(""),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||L(t.text),T(!1))},[t,W,e.path]),c.useEffect(()=>{const S=z=>{if(z.key==="Escape"){H();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,j]),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(`
347
+ `);return S.length>0&&S[S.length-1]===""&&S.pop(),S.slice(0,sa)},[l]),k=l?.lines??0,Y=k>sa,re=(S,z)=>{if(z){const ue=C.current>0?C.current:S;g({start:Math.min(ue,S),end:Math.max(ue,S)})}else C.current=S,g({start:S,end:S})},de=()=>{xe.length!==0&&(C.current=1,g({start:1,end:xe.length}))},Se=()=>{h&&(n(e.path,e.name,h.start,h.end),B(!0),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>B(!1),1400))},ie=l!==null&&l.kind==="text"&&!l.binary&&!l.truncated,pe=()=>{L(l?.text??""),_(!1),G.current&&(Ts(e.name)&&te(!0),xs(e.name)&&le(!0))},J=()=>{if(W){if(j!==(l?.text??"")&&!window.confirm(o("discardFileChanges")))return;pe();return}!ie||!l||(G.current=Ts(e.name)&&U||xs(e.name)&&ee,Ts(e.name)&&te(!1),xs(e.name)&&le(!1),g(null),L(l.text),_(!0))},oe=()=>{!W||!l||!ie||ae({type:"write_file",path:e.path,text:j})&&(_(!1),G.current&&(Ts(e.name)&&te(!0),xs(e.name)&&le(!0)),g(null))},H=()=>{W&&j!==(l?.text??"")&&!window.confirm(o("discardFileChanges"))||a()},Ie=S=>{q(Math.min(200,Math.max(50,S)))},je=h?h.end-h.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&&U&&!W&&he==="text"&&!P,ke=Te&&ee&&!W&&he==="text"&&!P,x=S=>vt(tt(`/api/file?clientId=${encodeURIComponent(bn())}&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(bn())}${me?"&allowJs=1":""}`))};return s.jsx("div",{className:`fp-overlay ${M?"fullscreen":""}`,onMouseDown:S=>{S.target===S.currentTarget&&H()},children:s.jsxs("div",{className:`fp ${M?"fullscreen":""}`,style:{"--fp-zoom":D/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&&` · ${K0(l.size)}`]}),s.jsxs("span",{className:"fp-head-actions",children:[be&&he==="text"&&!P&&l&&s.jsx("button",{type:"button",className:`fp-attach markdown ${U?"on":""}`,"data-tip":o(U?"showMarkdownSource":"showMarkdownPreview"),disabled:W,onClick:()=>te(S=>!S),children:U?s.jsx(pn,{}):s.jsx(ti,{})}),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(ti,{}):s.jsx(pn,{})}),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:J,children:s.jsx(hn,{})}),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(_c,{})}),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:D<=50,onClick:()=>Ie(D-10),children:s.jsx(rc,{})}),s.jsxs("button",{type:"button",className:"fp-zoom-val",title:o("resetZoom"),onClick:()=>q(100),children:[D,"%"]}),s.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":o("zoomIn"),disabled:D>=200,onClick:()=>Ie(D+10),children:s.jsx(oc,{})})]}),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(ia,{})}),s.jsx("button",{type:"button",className:`fp-attach full ${M?"on":""}`,"data-tip":o(M?"exitFullscreen":"fullscreen"),onClick:()=>y(S=>!S),children:M?s.jsx(fc,{}):s.jsx(bc,{})}),s.jsx("button",{type:"button",className:"fp-close",title:o("close"),onClick:H,children:s.jsx(Ke,{})})]})]}),ye&&he==="text"&&!P&&s.jsx("div",{className:"fp-notice",children:o("previewTruncated")}),m&&!l&&s.jsx("div",{className:"fp-empty",children:o("loading")}),!m&&he==="none"&&!P&&s.jsx("div",{className:"fp-empty",children:o("previewNotSupported")}),!m&&he==="image"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("img",{className:"fp-media",src:x(e.path),alt:e.name})}),!m&&he==="video"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("video",{className:"fp-media",src:x(e.path),controls:!0,preload:"metadata"})}),!m&&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(me?"htmlJsOnTip":"htmlJsOffTip"),children:o(me?"htmlJsOn":"htmlJsOff")}),s.jsx("button",{type:"button",className:`fp-html-js ${me?"on":""}`,"data-tip":o(me?"htmlDisableJs":"htmlEnableJs"),onClick:()=>Q(S=>!S),children:o(me?"htmlDisableJs":"htmlEnableJs")})]}),s.jsx("iframe",{className:"fp-html-frame",src:b(e.path),title:e.name,sandbox:me?"allow-scripts":"",referrerPolicy:"no-referrer"},me?"js":"nojs")]}),!m&&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})})}),!m&&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})]}),!m&&W&&he==="text"&&!P&&l&&s.jsx("textarea",{className:`fp-editor ${ce?"":"no-wrap"}`,value:j,onChange:S=>L(S.target.value),wrap:ce?"soft":"off",spellCheck:!1,autoFocus:!0}),!m&&!Ce&&!ke&&!W&&he==="text"&&!P&&l&&xe.length===0&&s.jsx("div",{className:"fp-empty",children:o("emptyFile")}),!m&&!Ce&&!ke&&!W&&he==="text"&&!P&&xe.length>0&&s.jsxs("div",{className:`fp-code ${A?"dragging":""} ${ce?"":"no-wrap"}`,onMouseDown:S=>{S.button===0&&S.preventDefault()},children:[xe.map((S,z)=>{const ue=z+1,Ne=h!==null&&ue>=h.start&&ue<=h.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:sa})})]}),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:J,children:o("cancel")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:j===(l?.text??""),onClick:oe,children:[s.jsx(dc,{})," ",o("saveFile")]})]})]}):!Ce&&!ke&&he==="text"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:h?o("selectedRange",{n:je,start:h.start,end:h.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:!h,onClick:()=>g(null),children:o("clearSelection")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!h||P,onClick:Se,children:[v?s.jsx(Tt,{}):null,o(v?"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 K0(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}const xl="pi-web-sounds",ys={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function yl(){try{const e=localStorage.getItem(xl);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 Y0(e){try{localStorage.setItem(xl,JSON.stringify(e))}catch{}}let Ns=null;function G0(){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 V0=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],z0=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],Q0=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],X0=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],J0={question:V0,done:z0,start:Q0,error:X0};function Z0(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=yl()){if(!t.enabled||!t[e])return;const n=G0();if(!n)return;const i=Math.max(0,Math.min(1,t.volume/100));for(const a of J0[e])Z0(n,a,i)}const eg=c.lazy(()=>Jl(()=>import("./TerminalPanel-GQZf9XvH.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.TerminalPanel})));function tg({notice:e,onDismiss:t}){const n=Re(),{locale:i}=Ht(),a=i!=="zh"&&e.textEn?e.textEn:e.text,[o,l]=c.useState(!1);c.useEffect(()=>{if(o)return;const m=setTimeout(()=>t(e.id),e.level==="error"?12e3:7e3);return()=>clearTimeout(m)},[o,e.id,e.level,t]);const u=e.level==="error"?jc:e.level==="warning"?Ic:Nc;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 sg=[],Nl=180,kl=520,vl=240,Cl=e=>`pi-web-ui:${e}-panel-width`;function gr(e){const t=Number(localStorage.getItem(Cl(e)));return Number.isFinite(t)&&t>=Nl&&t<=kl?t:vl}const Aa=e=>`pi-web-ui:${e}-panel-collapsed`;function br(e){return localStorage.getItem(Aa(e))==="1"}function Er({side:e,width:t,onResize:n}){const i=Re(),a=c.useCallback(o=>{o.preventDefault();const l=o.clientX,u=t;let m=u;const T=g=>{const A=e==="left"?g.clientX-l:l-g.clientX;m=Math.min(kl,Math.max(Nl,Math.round(u+A))),n(m)},h=()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",h),document.body.classList.remove("panel-resizing"),localStorage.setItem(Cl(e),String(m))};window.addEventListener("pointermove",T),window.addEventListener("pointerup",h),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(vl)})}function Tr({side:e,onClick:t}){const n=Re();return s.jsx("button",{type:"button",className:`panel-rail panel-rail-${e}`,title:n("expandPanel"),onClick:t,children:e==="left"?s.jsx(Rr,{}):s.jsx(Dr,{})})}function ng(){const e=Re(),{locale:t}=Ht(),{chat:n,send:i,dismissNotice:a,pushNotice:o,terminal:l}=Mu(),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:An[t]??An.en,quickPhrasesSeeded:!0}))},[n.ready,n.settings,i,t]);const m=n.state?.cwd??"",T=dl();c.useEffect(()=>{const $=T?k0(m):"";document.title=$?`${$} — pi-web-ui`:e("docTitle")},[m,T,e]);const[h,g]=c.useState([]);c.useEffect(()=>(rr($=>g(Ee=>Df(Ee,$))),()=>rr(null)),[]);const[A,N]=c.useState(null),[v,B]=c.useState(!1);c.useEffect(()=>{const $=()=>B(!1);return window.addEventListener("drop",$,!0),()=>window.removeEventListener("drop",$,!0)},[]);const[W,_]=c.useState("chat"),j=$=>!n.tabs||$==="chat"||n.tabs.includes($),L=W.startsWith("plugin:")?"plugins":W,U=j(L)?W:"chat",te=c.useMemo(()=>n.plugins.filter($=>!n.settings?.disabledPlugins?.includes($.id)),[n.plugins,n.settings?.disabledPlugins]),[ee,le]=c.useState([]);c.useEffect(()=>vu(le),[]),c.useEffect(()=>{ih(i),rh(te,n.pluginsEpoch),Cu(te,n.pluginsEpoch)},[te,n.pluginsEpoch,i]);const me=c.useRef(n);me.current=n;const Q=c.useRef(_);Q.current=_,c.useEffect(()=>(pr(p0({send:i,isReady:()=>!!me.current.state,setView:$=>Q.current($),getCwd:()=>me.current.state?.cwd??"",getConversationId:()=>me.current.state?.conversationId??null,isConversationBlank:()=>(me.current.state?.messages.length??0)===0})),()=>pr(null)),[i]);const[G,ce]=c.useState(()=>gr("left")),[O,M]=c.useState(()=>gr("right")),y=c.useCallback($=>ce($),[]),D=c.useCallback($=>M($),[]),[q,C]=c.useState(()=>br("left")),[se,K]=c.useState(()=>br("right")),xe=c.useCallback(()=>{C($=>(localStorage.setItem(Aa("left"),$?"0":"1"),!$))},[]),k=c.useCallback(()=>{K($=>(localStorage.setItem(Aa("right"),$?"0":"1"),!$))},[]),[Y,re]=c.useState(null),[de,Se]=c.useState(()=>window.matchMedia("(max-width: 768px)").matches);c.useEffect(()=>{const $=window.matchMedia("(max-width: 768px)"),Ee=Le=>Se(Le.matches);return $.addEventListener("change",Ee),()=>$.removeEventListener("change",Ee)},[]);const[ie,pe]=c.useState(!1),[J,oe]=c.useState(!1),[H,Ie]=c.useState(!1),je=ll(),[P,ye]=c.useState(!1),[he,be]=c.useState(!1),[Te,Ce]=c.useState(null);c.useEffect(()=>{if(!Te)return;const $=setTimeout(()=>Ce(null),15e3);return()=>clearTimeout($)},[Te]),c.useEffect(()=>{const $=Le=>{const Ue=Le.detail,Ve=Ue?.title||e("pluginCommandFallback"),Lt=Ue?.command;if(!Lt||!n.ready)return;const st={name:Ve,command:Lt,cwd:"${pwd}"},lt=n.terminals.find(gt=>gt.title===Ve);if(lt)l.restart(lt.id),i({type:"run_command",terminalId:lt.id,conversationId:lt.conversationId,command:st,cols:80,rows:24});else{const gt=wt();l.create({id:gt,conversationId:n.activeConversationId||n.state?.conversationId||"",title:Ve,cwd:n.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:st})}_("terminal")};window.addEventListener("pi-web-ui:plugin-run-command",$);const Ee=Le=>{const Ue=Le.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",$),window.removeEventListener("pi-web-ui:switch-conversation",Ee)}},[n,l,i]),c.useEffect(()=>{const $=Ee=>{!(Ee.ctrlKey||Ee.metaKey)||Ee.key.toLowerCase()!=="k"||(Ee.preventDefault(),be(Le=>!Le))};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[]);const[ke,x]=c.useState(yl),{themes:b,theme:S,switchTheme:z}=dh();P0();const ue=c.useRef(null),Ne=c.useRef(null),De=c.useRef(null),w=c.useRef(0),fe=c.useRef(!1),Ae=c.useRef(n.terminals);c.useEffect(()=>{Y0(ke)},[ke]),c.useEffect(()=>{const $=Ae.current;Ae.current=n.terminals;for(const Ee of n.terminals){const Le=Ee.command?.command??"";!$.find(Ve=>Ve.id===Ee.id)?.running||Ee.running||(Le.startsWith("pi remove ")?i({type:"extensions_reload"}):Le.startsWith("pi-web-ui install ")||Le.startsWith("pi-web-ui uninstall ")?i({type:"plugins_reload"}):Le.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 $=n.state?.isStreaming??!1,Ee=ue.current;ue.current=$,Ee!==null&&(!Ee&&$?ts("start",ke):Ee&&!$&&(ts("done",ke),Ks(e("notifyDoneTitle"),e("notifyDoneBody"))))},[n.state?.isStreaming,ke]),c.useEffect(()=>{const $=n.dialog?.id??null;$!==null&&$!==Ne.current&&(ts("question",ke),Ks(e("notifyQuestionTitle"),e("notifyQuestionBody"))),Ne.current=$},[n.dialog,ke]),c.useEffect(()=>{const $=n.question?.id??null;$!==null&&$!==De.current&&(ts("question",ke),Ks(e("notifyQuestionTitle"),e("notifyQuestionBody"))),De.current=$},[n.question,ke]),c.useEffect(()=>{const $=[...n.notices].reverse().find(Ee=>Ee.level==="error");$&&$.id!==w.current&&(w.current=$.id,ts("error",ke),Ks(e("notifyErrorTitle"),e("notifyErrorBody")))},[n.notices,ke]);const Fe=($,Ee,Le,Ue=!1,Ve)=>{const Lt=`${$}|${Le}|${Ve?`${Ve.start}-${Ve.end}`:""}`;g(st=>st.some(lt=>`${lt.path}|${lt.mode}|${lt.lines?`${lt.lines.start}-${lt.lines.end}`:""}`===Lt)?st:[...st,{path:$,name:Ee,mode:Le,isDir:Ue,...Ve?{lines:Ve}:{}}])},Me=$=>g(Ee=>Ee.filter(Le=>Le.key?Le.key!==$:Le.path!==$)),Ge=c.useCallback($=>(!$.type.startsWith("list_")&&!$.type.startsWith("get_")&&re(null),i($)),[i]),Xt=c.useRef(0),At=c.useRef(0),Ut=$=>{const Ee=Date.now();n.state?.model&&!n.state.model.vision&&Ee-At.current>1e4&&(At.current=Ee,o("warning",e("imageNotSupported")));const Le=`paste-${++Xt.current}`;g(Ue=>[...Ue,{path:"",key:Le,name:$.name,mode:"inline",imageData:$.data,mimeType:$.mimeType}])},mt=async $=>{for(const Ee of $){const Le=await Ha(Ee);if(!Le){o("error",e("imageLoadFailed",{name:Ee.name}));continue}Ut(Le)}},$t=20*1024*1024,xt=c.useRef(0),qt=async $=>{if($.size>$t){o("warning",e("fileTooLarge",{name:$.name,size:$t/1024/1024}));return}let Ee;try{Ee=(await new Promise((Ve,Lt)=>{const st=new FileReader;st.onload=()=>Ve(st.result),st.onerror=()=>Lt(st.error??new Error("read failed")),st.readAsDataURL($)})).replace(/^data:[^;]*;base64,/,"")}catch{o("error",e("fileLoadFailed",{name:$.name}));return}const Le=`upload-${++xt.current}`;g(Ue=>[...Ue,{path:"",key:Le,name:$.name,mode:"inline",fileData:Ee,size:$.size,mimeType:$.type||void 0}])},It=async $=>{for(const Ee of $)_t(Ee.type)?await mt([Ee]):await qt(Ee)},R=c.useCallback(($,Ee,Le)=>{i({type:"edit_message",messageId:$,text:Ee,attachments:Le})},[i]),V=c.useCallback(($,Ee)=>{i({type:"queue_remove",kind:$,text:Ee})},[i]),[we,_e]=c.useState([]),Pe=c.useRef(0),He=c.useCallback(($,Ee)=>{i({type:"queue_remove",kind:$,text:Ee}),Pe.current+=1;const Le={text:Ee,seq:Pe.current};_e(Ue=>[...Ue.slice(-9),Le])},[i]),ot=c.useCallback(()=>oe(!0),[]),yt=c.useCallback(()=>g([]),[]),ps=c.useCallback(Me,[]),ft=c.useCallback(mt,[mt]),Mn=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:wt(),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(U!=="terminal"||n.terminals.length!==0){fe.current=!1;return}Jt()&&(fe.current=!1)}},[n.terminals.length,Jt,U]),s.jsxs("div",{className:"app",onDragOver:$=>{Array.from($.dataTransfer?.types??[]).includes("Files")&&($.preventDefault(),B(!0))},onDragLeave:$=>{$.currentTarget.contains($.relatedTarget)||B(!1)},onDrop:$=>{if(B(!1),!Array.from($.dataTransfer?.types??[]).includes("Files"))return;$.preventDefault();const Ee=Array.from($.dataTransfer?.files??[]);if(Ee.length===0){o("warning",e("foldersNotSupported"));return}const Le=Ee.filter(Ve=>_t(Ve.type)),Ue=Ee.filter(Ve=>!_t(Ve.type));Le.length>0&&mt(Le),Ue.length>0&&It(Ue)},children:[v&&s.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:s.jsxs("span",{children:["📎 ",e("dropHereToAttach")]})}),s.jsx(du,{chat:n,terminal:l,view:U,plugins:te,onViewChange:$=>{fe.current=$==="terminal"&&n.terminals.length===0,fe.current&&Jt()&&(fe.current=!1),_($),re(null)},onOpenPanel:re,onOpenSettings:()=>Ie(!0),onOpenBgTasks:()=>ye(!0),onOpenGlobalSearch:()=>be(!0),sound:ke,onSoundChange:x,onSoundPreview:$=>ts($,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($=>s.jsx(tg,{notice:$,onDismiss:a},$.id))}),s.jsx(_f,{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 ${U==="chat"?"":"hidden"}`,children:[!de&&q&&s.jsx(Tr,{side:"left",onClick:xe}),s.jsx("div",{className:`panel-drawer drawer-left ${Y==="left"?"open":""}${de?"":q?" hidden":""}`,children:s.jsx(Eu,{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(Er,{side:"left",width:G,onResize:y}),s.jsxs("main",{className:je?"main wide-chat":"main",children:[n.state?s.jsx(Rf,{state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:R,onKillBash:()=>i({type:"abort_bash"}),onRetry:()=>{if(i({type:"retry_last"})){const $=n.state?.model;$&&vn(`${$.provider}/${$.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(Zf,{goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId}),n.dialog&&s.jsx(r0,{dialog:n.dialog}),n.question&&s.jsx(o0,{question:n.question}),s.jsx(Jf,{streaming:n.state?.isStreaming??!1,messages:n.state?.messages??sg,slashCommands:n.slashCommands,modelState:Be,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,attachments:h,onRemoveAttachment:ps,onAddImageFiles:ft,onAddLocalFiles:Mn,onNotice:o,onManageModels:ot,onSent:yt,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0,recallDrafts:we})]}),!de&&s.jsx(Er,{side:"right",width:O,onResize:D}),s.jsx("div",{className:`panel-drawer drawer-right ${Y==="right"?"open":""}${de?"":se?" hidden":""}`,children:s.jsx(Yu,{collapsible:!de,onToggleCollapse:k,panelSend:Ge,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,onAttach:($,Ee,Le,Ue)=>{re(null),Fe($,Ee,Le,Ue)},onPreview:($,Ee)=>{re(null),N({path:$,name:Ee})},onNotice:($,Ee)=>o($,Ee)})}),!de&&se&&s.jsx(Tr,{side:"right",onClick:k})]}),s.jsx("div",{className:`view-pane ${U==="terminal"?"":"hidden"}`,children:s.jsx(c.Suspense,{fallback:null,children:s.jsx(eg,{chat:n,terminal:l})})}),s.jsx("div",{className:`view-pane ${U==="git"?"":"hidden"}`,children:s.jsx(c0,{chat:n,terminal:l,active:U==="git",onSwitchToTerminal:()=>_("terminal")})}),ee.map($=>{const Ee=`plugin:${$.info.id}`;return s.jsx("div",{className:`view-pane ${U===Ee?"":"hidden"}`,children:s.jsx(u0,{entry:$})},$.info.id)})]})}),s.jsx(a0,{chat:n}),A&&s.jsx(W0,{file:A,content:n.fileContent,onAddLines:($,Ee,Le,Ue)=>Fe($,Ee,"lines",!1,{start:Le,end:Ue}),onAttach:($,Ee,Le)=>Fe($,Ee,Le),onClose:()=>N(null)}),n.ready&&n.state&&n.state.piConfigured===!1&&!ie&&!J&&s.jsx(h0,{piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,providers:n.providers,installResult:n.installResult,onClose:()=>pe(!0)}),J&&s.jsx(b0,{providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,fetchModelsResult:n.fetchModelsResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>oe(!1)}),H&&s.jsx(F0,{chat:n,terminal:l,onSwitchToTerminal:()=>_("terminal"),onClose:()=>Ie(!1)}),P&&s.jsx(U0,{servers:n.bgServers,onClose:()=>ye(!1)}),s.jsx(q0,{open:he,projects:n.projects,fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>be(!1),onSwitchSession:($,Ee)=>{i({type:"switch_session",path:$});const Le=Ee&&Ee[0];Ce(Le?{path:$,role:Le.role,timestamp:Le.timestamp}:null)},onSwitchProject:$=>{i({type:"set_cwd",path:$})},onPreviewFile:($,Ee)=>{N({path:$,name:Ee})}})]})}function ag(){typeof document>"u"||(_l(ig()),og())}function _l(e){!Number.isFinite(e)||e<0||document.documentElement.style.setProperty("--msgs-gutter",`${Math.round(e*100)/100}px`)}function ig(){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 rg(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 og(){const e=()=>{const i=document.querySelector(".messages");return i?(_l(rg(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)}Pc();Ho(Fo());ag();zl.createRoot(document.getElementById("root")).render(s.jsx(c.StrictMode,{children:s.jsx(Yc,{children:s.jsx(ng,{})})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=Mr();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,dg as b,Re as c,dt as d,ug as e,fn as f,et as g,gc as h,jn as i,Ke as j,wt as r,Ht as u};