pi-web-ui 0.75.0 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/package.json +1 -1
- package/web/dist/assets/{TerminalPanel-CX6GKT5R.js → TerminalPanel-CKvAH2c_.js} +1 -1
- package/web/dist/assets/{index-B-YjvCxZ.js → index-BBvR_HDI.js} +35 -35
- package/web/dist/assets/{index-d1VZAfby.css → index-ChcqaOWi.css} +1 -1
- package/web/dist/index.html +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-
|
|
2
|
-
import{R as Ft,a as l,j as s,f as Vo,b as la,p as ka,c as Ca,n as va,h as cn,s as ws,o as Dn,z as $i,d as Qo,e as Xo,g as qt,v as Jo,i as Wi,k as _a,M as Zo,l as el,m as Ki}from"./markdown-Cpo0pNcR.js";import{r as Yi}from"./react-CtudoG1_.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var Ps={},Sa;function tl(){if(Sa)return Ps;Sa=1;var e=Yi();return Ps.createRoot=e.createRoot,Ps.hydrateRoot=e.hydrateRoot,Ps}var sl=tl();const nl="modulepreload",al=function(e){return"/"+e},Aa={},il=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let c=function(f){return Promise.all(f.map(b=>Promise.resolve(b).then(E=>({status:"fulfilled",value:E}),E=>({status:"rejected",reason:E}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),u=d?.nonce||d?.getAttribute("nonce");o=c(n.map(f=>{if(f=al(f),f in Aa)return;Aa[f]=!0;const b=f.endsWith(".css"),E=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${E}`))return;const y=document.createElement("link");if(y.rel=b?"stylesheet":nl,b||(y.as="script"),y.crossOrigin="",y.href=f,u&&y.setAttribute("nonce",u),document.head.appendChild(y),b)return new Promise((N,S)=>{y.addEventListener("load",N),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&i(d.reason);return t().catch(i)})};var Gi={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},wa=Ft.createContext&&Ft.createContext(Gi),rl=["attr","size","title"];function ol(e,t){if(e==null)return{};var n,a,o=ll(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function ll(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Ys.apply(null,arguments)}function Ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function Gs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ia(Object(n),!0).forEach(function(a){cl(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ia(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function cl(e,t,n){return(t=ul(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ul(e){var t=dl(e,"string");return typeof t=="symbol"?t:t+""}function dl(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function zi(e){return e&&e.map((t,n)=>Ft.createElement(t.tag,Gs({key:n},t.attr),zi(t.child)))}function fe(e){return t=>Ft.createElement(ml,Ys({attr:Gs({},e.attr)},t),zi(e.child))}function ml(e){var t=n=>{var a=e.attr,o=e.size,i=e.title,c=ol(e,rl),d=o||n.size||"1em",u;return n.className&&(u=n.className),e.className&&(u=(u?u+" ":"")+e.className),Ft.createElement("svg",Ys({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,c,{className:u,style:Gs(Gs({color:e.color||n.color},n.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),i&&Ft.createElement("title",null,i),e.children)};return wa!==void 0?Ft.createElement(wa.Consumer,null,n=>t(n)):t(Gi)}function pl(e){return fe({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 hl(e){return fe({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 Fs(e){return fe({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 $e(e){return fe({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 Vi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"},child:[]},{tag:"path",attr:{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"},child:[]}]})(e)}function ja(e){return fe({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 Qi(e){return fe({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 fl(e){return fe({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 fe({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 Zt(e){return fe({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 La(e){return fe({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 Ra(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"},child:[]},{tag:"line",attr:{x1:"7",y1:"7",x2:"7.01",y2:"7"},child:[]}]})(e)}function gl(e){return fe({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 zs(e){return fe({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 bl(e){return fe({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 Vs(e){return fe({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 Qs(e){return fe({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 Xs(e){return fe({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 El(e){return fe({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 Xi(e){return fe({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 fe({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 fe({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 Wf(e){return fe({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 Tl(e){return fe({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 En(e){return fe({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 xl(e){return fe({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 yl(e){return fe({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 Nl(e){return fe({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 es(e){return fe({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 kl(e){return fe({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 Cl(e){return fe({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 vl(e){return fe({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 _l(e){return fe({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 Sl(e){return fe({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 On(e){return fe({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 Js(e){return fe({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 Al(e){return fe({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 wl(e){return fe({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 Pa(e){return fe({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 Il(e){return fe({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 Ji(e){return fe({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 Da(e){return fe({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 Hs(e){return fe({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 Pt(e){return fe({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 jl(e){return fe({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 Zi(e){return fe({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 Mn(e){return fe({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 Xt(e){return fe({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 Zs(e){return fe({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 Ht(e){return fe({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 _s(e){return fe({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 Ll(e){return fe({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 vt(e){return fe({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 Rl(e){return fe({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 Bn(e){return fe({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 Oa(e){return fe({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 er(e){return fe({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 tr(e){return fe({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 un(e){return fe({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 $t(e){return fe({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 Ot(e){return fe({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 fe({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 ns(e){return fe({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 Tn(e){return fe({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 Pl(e){return fe({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 Dl(e){return fe({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 sr(e){return fe({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 nr(e){return fe({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 ar(e){return fe({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 Ol(e){return fe({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 Ml(e){return fe({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 Bl(e){return e.map(t=>t.kind==="package"?`pi update npm:${t.name}`:`npm i -g ${t.name}@latest`).join("; ")}function _t(){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 jt({trigger:e,open:t,onOpenChange:n,children:a,align:o="right",fit:i=!1,direction:c="down",menuClassName:d,menuRef:u,menuStyle:f}){const b=l.useRef(null);return l.useEffect(()=>{if(!t)return;const E=N=>{b.current&&!b.current.contains(N.target)&&n(!1)},y=N=>{N.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",E),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",y)}},[t,n]),s.jsxs("div",{className:`dropdown ${o} ${i?"fit":""} ${c==="up"?"dd-up":""}`,ref:b,children:[s.jsxs("button",{type:"button",className:"chip",onClick:()=>n(!t),"aria-expanded":t,children:[e,s.jsx(Ot,{className:`dd-caret ${t?"up":""}`})]}),t&&s.jsx("div",{className:`dd-menu ${d??""}`,ref:u,style:f,children:a})]})}function nt({active:e,disabled:t=!1,title:n,onClick:a,children:o}){return s.jsx("button",{type:"button",className:`dd-item ${e?"active":""}`,disabled:t,title:n,onClick:a,children:o})}let xn=null;function Fl(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 ir(){return xn===null&&(xn=Fl()),xn}function Hl(e,t){return t==="/"?e:t+e.replace(/^\/+/,"")}function at(e){return Hl(e,ir())}const rr="pi-web-ui:token";function Ul(){try{const e=new URL(window.location.href),t=e.searchParams.get("token");t&&(localStorage.setItem(rr,t.trim()),e.searchParams.delete("token"),window.history.replaceState(null,"",e.toString()))}catch{}}function ql(){try{return localStorage.getItem(rr)??""}catch{return""}}function Dt(e){const t=ql();return t?`${e}${e.includes("?")?"&":"?"}token=${encodeURIComponent(t)}`:e}const $l=["zh","en","de","es","fr","it","ja","ko","pt","ru"];function Fn(e,t,n,a=$l){const o=(e??"").trim();if(o)return o;for(const c of t??[]){const d=String(c??"").trim().toLowerCase().replace(/_/g,"-");if(!d)continue;if(a.includes(d))return d;const u=d.split("-")[0];if(u&&a.includes(u))return u}const i=(n??"").trim().toLowerCase();return i&&a.includes(i)?i:"en"}const Hn="pi-web-ui:lang",Wl={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:"智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送",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 回答完全结束后才发送(不打断)",queueSteerTag:"插队",queueFollowTag:"排队",queueRemoveTip:"移除此排队消息",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:"更新全部组件",computer:"此电脑",rootDir:"根目录",noFiles:"暂无文件",filesTruncated:"目录过大,列表已截断,仅显示前 2000 项",linkFolderTip:"链接文件夹路径到对话",attachInlineTip:"附加内容到对话",referenceTip:"仅引用路径(AI 按需读取)",previewFile:"预览",downloadFile:"下载文件",copyName:"复制名称",copyPath:"复制路径",downloadFailed:"下载失败:{error}",fileNotFoundShort:"文件不存在",pluginMountFailed:"插件 {name} 挂载失败",liveOutputOmitted:`…[前 {n} 字符已省略]…
|
|
3
|
-
`,uploadToFolder:"上传文件到此文件夹",uploadToCurrentDir:"上传文件到当前目录",openAsProject:"以项目打开",protocolMismatch:"页面版本与服务器不一致(应用刚更新过),请刷新页面以恢复全部功能。",selectLinesHint:"点击选择行;拖拽或 Shift+点击选择范围",enableWrap:"开启自动换行",disableWrap:"关闭自动换行",selectedRange:"已选 {n} 行(第 {start}-{end} 行)",fileLines:"{n} 行",selectAll:"全选",clearSelection:"清除",addToChat:"添加到对话",addedToChat:"已添加",previewTruncated:"⚠ 文件过大,仅预览前 512KB",previewLinesTruncated:"… 文件行数过多,仅显示前 {n} 行",binaryFile:"🔣 二进制文件,已显示前 4KB 十六进制",binaryHexTruncated:"(文件更大,可下载完整文件)",previewNotSupported:"该类型文件不支持预览(仅图片 / 视频 / 文本)",emptyFile:"(空文件)",editFile:"编辑文件",exitEditFile:"退出编辑",saveFile:"保存文件",discardFileChanges:"放弃未保存的修改?",fileSaved:"已保存",fileEditTruncated:"文件过大,预览不完整,无法编辑",showMarkdownSource:"显示 Markdown 原文",showMarkdownPreview:"显示 Markdown 预览",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:"
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-CKvAH2c_.js","assets/markdown-Cpo0pNcR.js","assets/xterm-B96xOxS9.js","assets/react-CtudoG1_.js","assets/TerminalPanel-DOrYoP_4.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{R as Ft,a as l,j as s,f as tl,b as la,p as ka,c as va,n as Ca,h as un,s as ws,o as Dn,z as Gi,d as sl,e as nl,g as qt,v as al,i as zi,k as _a,M as il,l as rl,m as Vi}from"./markdown-Cpo0pNcR.js";import{r as Qi}from"./react-CtudoG1_.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var Ds={},Sa;function ol(){if(Sa)return Ds;Sa=1;var e=Qi();return Ds.createRoot=e.createRoot,Ds.hydrateRoot=e.hydrateRoot,Ds}var ll=ol();const cl="modulepreload",ul=function(e){return"/"+e},Aa={},dl=function(t,n,a){let o=Promise.resolve();if(n&&n.length>0){let c=function(f){return Promise.all(f.map(E=>Promise.resolve(E).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),u=d?.nonce||d?.getAttribute("nonce");o=c(n.map(f=>{if(f=ul(f),f in Aa)return;Aa[f]=!0;const E=f.endsWith(".css"),g=E?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${g}`))return;const y=document.createElement("link");if(y.rel=E?"stylesheet":cl,E||(y.as="script"),y.crossOrigin="",y.href=f,u&&y.setAttribute("nonce",u),document.head.appendChild(y),E)return new Promise((N,S)=>{y.addEventListener("load",N),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${f}`)))})}))}function i(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return o.then(c=>{for(const d of c||[])d.status==="rejected"&&i(d.reason);return t().catch(i)})};var Xi={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},wa=Ft.createContext&&Ft.createContext(Xi),ml=["attr","size","title"];function pl(e,t){if(e==null)return{};var n,a,o=hl(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function hl(e,t){if(e==null)return{};var n={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;n[a]=e[a]}return n}function Gs(){return Gs=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Gs.apply(null,arguments)}function Ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,a)}return n}function zs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ia(Object(n),!0).forEach(function(a){fl(e,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ia(Object(n)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(n,a))})}return e}function fl(e,t,n){return(t=gl(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gl(e){var t=bl(e,"string");return typeof t=="symbol"?t:t+""}function bl(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var a=n.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ji(e){return e&&e.map((t,n)=>Ft.createElement(t.tag,zs({key:n},t.attr),Ji(t.child)))}function fe(e){return t=>Ft.createElement(El,Gs({attr:zs({},e.attr)},t),Ji(e.child))}function El(e){var t=n=>{var a=e.attr,o=e.size,i=e.title,c=pl(e,ml),d=o||n.size||"1em",u;return n.className&&(u=n.className),e.className&&(u=(u?u+" ":"")+e.className),Ft.createElement("svg",Gs({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,a,c,{className:u,style:zs(zs({color:e.color||n.color},n.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),i&&Ft.createElement("title",null,i),e.children)};return wa!==void 0?Ft.createElement(wa.Consumer,null,n=>t(n)):t(Xi)}function Tl(e){return fe({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 xl(e){return fe({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 Hs(e){return fe({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 $e(e){return fe({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 Zi(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"},child:[]},{tag:"path",attr:{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"},child:[]}]})(e)}function ja(e){return fe({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 er(e){return fe({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 yl(e){return fe({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 fe({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 Zt(e){return fe({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 La(e){return fe({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 Ra(e){return fe({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"},child:[]},{tag:"line",attr:{x1:"7",y1:"7",x2:"7.01",y2:"7"},child:[]}]})(e)}function Nl(e){return fe({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 Vs(e){return fe({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 kl(e){return fe({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 Qs(e){return fe({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 Xs(e){return fe({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 Js(e){return fe({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 vl(e){return fe({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 tr(e){return fe({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 fe({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 fe({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 n0(e){return fe({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 Cl(e){return fe({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 En(e){return fe({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 _l(e){return fe({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 Sl(e){return fe({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 Al(e){return fe({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 es(e){return fe({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 wl(e){return fe({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 Il(e){return fe({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 jl(e){return fe({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 Ll(e){return fe({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 Rl(e){return fe({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 On(e){return fe({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 Zs(e){return fe({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 Pl(e){return fe({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 Dl(e){return fe({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 Pa(e){return fe({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 Ol(e){return fe({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 sr(e){return fe({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 Da(e){return fe({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 Us(e){return fe({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 Pt(e){return fe({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 Ml(e){return fe({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 nr(e){return fe({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 Mn(e){return fe({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 Xt(e){return fe({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 en(e){return fe({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 Ht(e){return fe({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 _s(e){return fe({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 Bl(e){return fe({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 Ct(e){return fe({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 Fl(e){return fe({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 Bn(e){return fe({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 Oa(e){return fe({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 ar(e){return fe({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 ir(e){return fe({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 dn(e){return fe({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 $t(e){return fe({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 Ot(e){return fe({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 fe({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 ns(e){return fe({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 Tn(e){return fe({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 Hl(e){return fe({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 Ul(e){return fe({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 rr(e){return fe({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 or(e){return fe({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 lr(e){return fe({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 ql(e){return fe({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 $l(e){return fe({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 Wl(e){return e.map(t=>t.kind==="package"?`pi update npm:${t.name}`:`npm i -g ${t.name}@latest`).join("; ")}function _t(){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 jt({trigger:e,open:t,onOpenChange:n,children:a,align:o="right",fit:i=!1,direction:c="down",menuClassName:d,menuRef:u,menuStyle:f}){const E=l.useRef(null);return l.useEffect(()=>{if(!t)return;const g=N=>{E.current&&!E.current.contains(N.target)&&n(!1)},y=N=>{N.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[t,n]),s.jsxs("div",{className:`dropdown ${o} ${i?"fit":""} ${c==="up"?"dd-up":""}`,ref:E,children:[s.jsxs("button",{type:"button",className:"chip",onClick:()=>n(!t),"aria-expanded":t,children:[e,s.jsx(Ot,{className:`dd-caret ${t?"up":""}`})]}),t&&s.jsx("div",{className:`dd-menu ${d??""}`,ref:u,style:f,children:a})]})}function nt({active:e,disabled:t=!1,title:n,onClick:a,children:o}){return s.jsx("button",{type:"button",className:`dd-item ${e?"active":""}`,disabled:t,title:n,onClick:a,children:o})}let xn=null;function Kl(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 cr(){return xn===null&&(xn=Kl()),xn}function Yl(e,t){return t==="/"?e:t+e.replace(/^\/+/,"")}function at(e){return Yl(e,cr())}const ur="pi-web-ui:token";function Gl(){try{const e=new URL(window.location.href),t=e.searchParams.get("token");t&&(localStorage.setItem(ur,t.trim()),e.searchParams.delete("token"),window.history.replaceState(null,"",e.toString()))}catch{}}function zl(){try{return localStorage.getItem(ur)??""}catch{return""}}function Dt(e){const t=zl();return t?`${e}${e.includes("?")?"&":"?"}token=${encodeURIComponent(t)}`:e}const Vl=["zh","en","de","es","fr","it","ja","ko","pt","ru"];function Fn(e,t,n,a=Vl){const o=(e??"").trim();if(o)return o;for(const c of t??[]){const d=String(c??"").trim().toLowerCase().replace(/_/g,"-");if(!d)continue;if(a.includes(d))return d;const u=d.split("-")[0];if(u&&a.includes(u))return u}const i=(n??"").trim().toLowerCase();return i&&a.includes(i)?i:"en"}const Hn="pi-web-ui:lang",Ql={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:"智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送",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 回答完全结束后才发送(不打断)",queueSteerTag:"插队",queueFollowTag:"排队",queueRemoveTip:"移除此排队消息",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:"更新全部组件",computer:"此电脑",rootDir:"根目录",noFiles:"暂无文件",filesTruncated:"目录过大,列表已截断,仅显示前 2000 项",linkFolderTip:"链接文件夹路径到对话",attachInlineTip:"附加内容到对话",referenceTip:"仅引用路径(AI 按需读取)",previewFile:"预览",downloadFile:"下载文件",copyName:"复制名称",copyPath:"复制路径",downloadFailed:"下载失败:{error}",fileNotFoundShort:"文件不存在",pluginMountFailed:"插件 {name} 挂载失败",liveOutputOmitted:`…[前 {n} 字符已省略]…
|
|
3
|
+
`,uploadToFolder:"上传文件到此文件夹",uploadToCurrentDir:"上传文件到当前目录",openAsProject:"以项目打开",protocolMismatch:"页面版本与服务器不一致(应用刚更新过),请刷新页面以恢复全部功能。",selectLinesHint:"点击选择行;拖拽或 Shift+点击选择范围",enableWrap:"开启自动换行",disableWrap:"关闭自动换行",selectedRange:"已选 {n} 行(第 {start}-{end} 行)",fileLines:"{n} 行",selectAll:"全选",clearSelection:"清除",addToChat:"添加到对话",addedToChat:"已添加",previewTruncated:"⚠ 文件过大,仅预览前 512KB",previewLinesTruncated:"… 文件行数过多,仅显示前 {n} 行",binaryFile:"🔣 二进制文件,已显示前 4KB 十六进制",binaryHexTruncated:"(文件更大,可下载完整文件)",previewNotSupported:"该类型文件不支持预览(仅图片 / 视频 / 文本)",emptyFile:"(空文件)",editFile:"编辑文件",exitEditFile:"退出编辑",saveFile:"保存文件",discardFileChanges:"放弃未保存的修改?",fileSaved:"已保存",fileEditTruncated:"文件过大,预览不完整,无法编辑",showMarkdownSource:"显示 Markdown 原文",showMarkdownPreview:"显示 Markdown 预览",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. 项目类型、技术栈与目录结构
|
|
6
6
|
2. 构建 / 测试 / 运行 / 格式化的具体命令
|
|
@@ -150,8 +150,8 @@ import{R as Ft,a as l,j as s,f as Vo,b as la,p as ka,c as Ca,n as va,h as cn,s 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:"已关闭:模型不能再向你弹出问卷/提问对话框",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:"图片读取失败或过大,请换一张试试"},Kl={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",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)",queueSteerTag:"Steer",queueFollowTag:"Queued",queueRemoveTip:"Remove this queued message",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",computer:"This PC",rootDir:"Root",noFiles:"No files",filesTruncated:"Directory too large — list truncated (first 2000 shown)",linkFolderTip:"Link folder path to chat",attachInlineTip:"Attach content to chat",referenceTip:"Reference path only (AI reads on demand)",previewFile:"Preview",downloadFile:"Download file",copyName:"Copy name",copyPath:"Copy path",downloadFailed:"Download failed: {error}",fileNotFoundShort:"File not found",pluginMountFailed:"Plugin {name} failed to mount",liveOutputOmitted:`…[{n} chars omitted above]…
|
|
154
|
-
`,uploadToFolder:"Upload files to this folder",uploadToCurrentDir:"Upload files to current directory",openAsProject:"Open as project",protocolMismatch:"Page version differs from the server (the app was just updated). Refresh the page to restore full functionality.",selectLinesHint:"Click a line to select; drag or Shift+click for a range",enableWrap:"Enable line wrap",disableWrap:"Disable line wrap",selectedRange:"Selected {n} lines (lines {start}-{end})",fileLines:"{n} lines",selectAll:"Select all",clearSelection:"Clear",addToChat:"Add to chat",addedToChat:"Added",previewTruncated:"⚠ File too large — previewing the first 512KB",previewLinesTruncated:"… too many lines — showing the first {n}",binaryFile:"🔣 Binary file — first 4KB shown as hex",binaryHexTruncated:" (file larger — download for the full file)",previewNotSupported:"This file type can't be previewed (only images / videos / text)",emptyFile:"(empty file)",editFile:"Edit file",exitEditFile:"Exit editing",saveFile:"Save file",discardFileChanges:"Discard unsaved changes?",fileSaved:"Saved",fileEditTruncated:"The preview is incomplete, so this file can't be edited",showMarkdownSource:"Show Markdown source",showMarkdownPreview:"Show Markdown preview",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).",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.",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:
|
|
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:"已关闭:模型不能再向你弹出问卷/提问对话框",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:"图片读取失败或过大,请换一张试试"},Xl={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",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)",queueSteerTag:"Steer",queueFollowTag:"Queued",queueRemoveTip:"Remove this queued message",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",computer:"This PC",rootDir:"Root",noFiles:"No files",filesTruncated:"Directory too large — list truncated (first 2000 shown)",linkFolderTip:"Link folder path to chat",attachInlineTip:"Attach content to chat",referenceTip:"Reference path only (AI reads on demand)",previewFile:"Preview",downloadFile:"Download file",copyName:"Copy name",copyPath:"Copy path",downloadFailed:"Download failed: {error}",fileNotFoundShort:"File not found",pluginMountFailed:"Plugin {name} failed to mount",liveOutputOmitted:`…[{n} chars omitted above]…
|
|
154
|
+
`,uploadToFolder:"Upload files to this folder",uploadToCurrentDir:"Upload files to current directory",openAsProject:"Open as project",protocolMismatch:"Page version differs from the server (the app was just updated). Refresh the page to restore full functionality.",selectLinesHint:"Click a line to select; drag or Shift+click for a range",enableWrap:"Enable line wrap",disableWrap:"Disable line wrap",selectedRange:"Selected {n} lines (lines {start}-{end})",fileLines:"{n} lines",selectAll:"Select all",clearSelection:"Clear",addToChat:"Add to chat",addedToChat:"Added",previewTruncated:"⚠ File too large — previewing the first 512KB",previewLinesTruncated:"… too many lines — showing the first {n}",binaryFile:"🔣 Binary file — first 4KB shown as hex",binaryHexTruncated:" (file larger — download for the full file)",previewNotSupported:"This file type can't be previewed (only images / videos / text)",emptyFile:"(empty file)",editFile:"Edit file",exitEditFile:"Exit editing",saveFile:"Save file",discardFileChanges:"Discard unsaved changes?",fileSaved:"Saved",fileEditTruncated:"The preview is incomplete, so this file can't be edited",showMarkdownSource:"Show Markdown source",showMarkdownPreview:"Show Markdown preview",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
|
|
157
157
|
2. Concrete commands for build / test / run / format
|
|
@@ -301,35 +301,35 @@ 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",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"},Yl=[{code:"zh",nativeName:"中文"},{code:"en",nativeName:"English"}],gs={};function Gl(e){return!e||typeof e.code!="string"||!e.code||e.code==="zh"||e.code==="en"||!e.strings||typeof e.strings!="object"?!1:(gs[e.code]=e,!0)}function zl(e){delete gs[e]}function Vl(e){return e==="zh"?"中文":e.toUpperCase()}function Ql(e){return e==="zh"?"zh-CN":e==="pt"?"pt-BR":e}async function Ma(e){const t=await fetch(Dt(at(e)));if(!t.ok)throw new Error(`HTTP ${t.status} for ${e}`);return await t.json()}const or=l.createContext(null);function lr(){try{return localStorage.getItem(Hn)}catch{return null}}function Xl(){return Fn(lr(),typeof navigator<"u"?navigator.languages:[],null)}function Jl({children:e}){const[t,n]=l.useState(Xl),[a,o]=l.useState(0),i=l.useRef(t);i.current=t;const c=l.useCallback(E=>{n(E);try{localStorage.setItem(Hn,E)}catch{}try{window.dispatchEvent(new CustomEvent("pi-web-ui:locale",{detail:E}))}catch{}},[]),d=l.useCallback(async()=>{let E,y=null;try{const N=await Ma("/api/locales");E=N.packs??[],y=N.defaultLocale??null}catch{return null}return await Promise.all(E.filter(N=>N.installed).map(async N=>{try{const S=await Ma(`/api/locales/${N.code}`);Gl({code:S.code||N.code,nativeName:S.nativeName||N.nativeName,strings:S.strings})}catch{}})),o(N=>N+1),y},[]);l.useEffect(()=>{d().then(E=>{if(!lr()?.trim()){const N=Fn(null,typeof navigator<"u"?navigator.languages:[],E);N!==i.current&&(i.current=N,n(N))}const y=i.current;if(y!=="zh"&&y!=="en"&&!gs[y]){const N=Fn(null,typeof navigator<"u"?navigator.languages:[],E,["zh","en"]);i.current=N,n(N);try{localStorage.setItem(Hn,N)}catch{}}})},[d]);const u=l.useMemo(()=>[...Yl,...Object.values(gs).map(E=>({code:E.code,nativeName:E.nativeName}))],[a]),f=l.useCallback((E,y)=>{let N=gs[t]?.strings[E]??(t==="zh"?Wl[E]:Kl[E]);if(y)for(const[S,M]of Object.entries(y))N=N.replaceAll(`{${S}}`,String(M));return N},[t,a]);l.useEffect(()=>{document.documentElement.lang=Ql(t)},[t]);const b=l.useMemo(()=>({locale:t,setLocale:c,t:f,packs:u,reloadPacks:d}),[t,c,f,u,d]);return s.jsx(or.Provider,{value:b,children:e})}function Mt(){const e=l.useContext(or);if(!e)throw new Error("useI18n must be used within LanguageProvider");return e}function Le(){return Mt().t}const Zl=[{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 Ba({settings:e,onChange:t,onPreview:n}){const a=Le(),o=i=>t({...e,...i});return s.jsxs("div",{className:"sound-menu",children:[s.jsx("div",{className:"dd-header",children:a("soundHeader")}),s.jsxs("label",{className:"sound-row sound-master",children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(Vi,{className:"sound-icon"}),s.jsx("span",{children:a("enableSound")})]}),s.jsx("input",{type:"checkbox",checked:e.enabled,onChange:i=>o({enabled:i.target.checked})})]}),Zl.map(({kind:i,labelKey:c,descKey:d})=>s.jsxs("label",{className:`sound-row ${e.enabled?"":"disabled"}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx("span",{className:"sound-name",children:a(c)}),s.jsx("span",{className:"sound-desc",children:a(d)})]}),s.jsxs("span",{className:"sound-right",children:[s.jsx("button",{type:"button",className:"sound-preview",title:a("preview"),disabled:!e.enabled,onClick:u=>{u.preventDefault(),n(i)},children:a("preview")}),s.jsx("input",{type:"checkbox",checked:e[i],disabled:!e.enabled,onChange:u=>o({[i]:u.target.checked})})]})]},i)),s.jsxs("div",{className:`sound-volume ${e.enabled?"":"disabled"}`,children:[s.jsx("span",{className:"sound-name",children:a("volume")}),s.jsx("input",{type:"range",min:0,max:100,step:5,value:e.volume,disabled:!e.enabled,onChange:i=>o({volume:Number(i.target.value)})}),s.jsxs("span",{className:"sound-vol-num",children:[e.volume,"%"]})]})]})}const cr="pi-web-notify",yn={enabled:!1};function ur(){try{const e=localStorage.getItem(cr);if(!e)return{...yn};const t=JSON.parse(e);return{enabled:typeof t.enabled=="boolean"?t.enabled:yn.enabled}}catch{return{...yn}}}function Fa(e){try{localStorage.setItem(cr,JSON.stringify(e))}catch{}}function dn(){return typeof window<"u"&&"Notification"in window}function ec(){return dn()?null:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported"}function tc(e,t){return e&&t==="visible"}function sc(){return typeof navigator>"u"?!1:/windows/i.test(navigator.userAgent??"")}function Ha(){return dn()?Notification.permission:"denied"}async function nc(){if(!dn())return"denied";try{return await Notification.requestPermission()}catch{return"denied"}}async function Ds(e,t){if(!dn()||tc(document.hasFocus(),document.visibilityState)||!ur().enabled||Notification.permission!=="granted")return;const n={body:t,icon:at("/icons/icon-192.png"),badge:at("/icons/icon-192.png"),tag:"pi-web-ui",data:{url:typeof location<"u"?location.href:at("/")}};try{const a=await navigator.serviceWorker?.getRegistration();a&&typeof a.showNotification=="function"?a.showNotification(e,n):new Notification(e,n)}catch{}}function Ua(){const e=Le(),[t,n]=l.useState(ur),[a,o]=l.useState(()=>Ha()),i=ec(),c=i!==null,d=sc();l.useEffect(()=>{const f=()=>o(Ha());return window.addEventListener("focus",f),document.addEventListener("visibilitychange",f),()=>{window.removeEventListener("focus",f),document.removeEventListener("visibilitychange",f)}},[]);const u=async f=>{const b={...t,enabled:f};if(n(b),Fa(b),f){const E=await nc();if(o(E),E!=="granted"){const y={...b,enabled:!1};n(y),Fa(y)}}};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${c?" disabled":""}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(Dl,{className:"sound-icon"}),s.jsx("span",{children:e("notifyEnable")})]}),s.jsx("input",{type:"checkbox",checked:t.enabled&&!c,disabled:c,onChange:f=>u(f.target.checked)})]}),s.jsx("div",{className:"sound-hint",children:e("notifyEnableDesc")}),i==="insecure"&&s.jsx("div",{className:"sound-hint",children:e("notifyInsecure")}),i==="unsupported"&&s.jsx("div",{className:"sound-hint",children:e("notifyUnsupported")}),!c&&a==="denied"&&s.jsx("div",{className:"sound-hint",children:e("notifyDenied")}),!c&&d&&s.jsx("div",{className:"sound-hint",children:e("notifyWindowsHint")})]})}function ac({onClose:e}){const t=Le(),{locale:n,setLocale:a,reloadPacks:o}=Mt(),[i,c]=l.useState(null),[d,u]=l.useState(""),[f,b]=l.useState("");async function E(){try{const S=await fetch(Dt(at("/api/locales")));if(!S.ok)throw new Error(`HTTP ${S.status}`);const M=await S.json();c(M.packs??[]),u("")}catch(S){u(t("localeListFailed",{error:S instanceof Error?S.message:String(S)}))}}l.useEffect(()=>{E()},[]);async function y(S){b(S),u("");try{const M=await fetch(Dt(at(`/api/locales/${S}/install`)),{method:"POST"});if(!M.ok){let z=`HTTP ${M.status}`;try{z=(await M.json()).error??z}catch{}throw new Error(z)}await o(),await E()}catch(M){u(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{b("")}}async function N(S){b(S),u("");try{const M=await fetch(Dt(at(`/api/locales/${S}`)),{method:"DELETE"});if(!M.ok)throw new Error(`HTTP ${M.status}`);zl(S),n===S&&a("zh"),await o(),await E()}catch(M){u(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{b("")}}return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"bg-task-modal",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(Ji,{})," ",t("localePacks")]}),s.jsx("button",{type:"button",className:"btn",title:t("close"),onClick:e,children:s.jsx($e,{})})]}),d&&s.jsx("div",{className:"bg-task-empty",children:d}),i===null&&!d?s.jsx("div",{className:"bg-task-empty",children:t("loading")}):s.jsx("ul",{className:"bg-task-list",children:(i??[]).map(S=>{const M=f===S.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:S.nativeName}),S.installed&&S.version&&s.jsxs("span",{className:"bg-task-name",children:["v",S.version]})]}),s.jsxs("div",{className:"bg-task-line2",children:[s.jsx("span",{children:S.code}),S.installed?s.jsxs("span",{children:[t("localeInstalled")," · ",t("localeRemoveHint")]}):s.jsx("span",{children:t("localeGetMore")})]})]}),S.installed?s.jsxs("button",{type:"button",className:"btn bg-task-stop",disabled:M,title:t("localeRemove"),onClick:()=>void N(S.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 y(S.code),children:[s.jsx(Ht,{}),s.jsx("span",{children:t(M?"localeDownloading":"localeInstall")})]})]},S.code)})}),s.jsx("div",{className:"bg-task-foot",children:s.jsxs("button",{type:"button",className:"btn",title:t("bgTaskRefresh"),onClick:()=>void E(),children:[s.jsx(kt,{}),s.jsx("span",{children:t("bgTaskRefresh")})]})})]})})}function ic({chat:e,send:t,terminal:n,view:a,plugins:o,onViewChange:i,onOpenPanel:c,onOpenSettings:d,onOpenBgTasks:u,onOpenGlobalSearch:f,sound:b,onSoundChange:E,onSoundPreview:y,themes:N,theme:S,onThemeChange:M}){const{locale:z,setLocale:$,t:v,packs:P}=Mt(),[B,H]=l.useState(!1),[Q,re]=l.useState(!1),[K,j]=l.useState(!1),[X,k]=l.useState(!1),[Z,Y]=l.useState(!1),[me,de]=l.useState(!1),w=e.ready?v("connected"):e.status==="closed"?v("reconnecting"):v("connecting"),I=e.ready?"ok":"busy",L=()=>{if(!e.ready)return;const _=v("updateTabTitle"),he={name:_,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},F=e.terminals.find(pe=>pe.title===_);F?(n.restart(F.id),t({type:"run_command",terminalId:F.id,conversationId:F.conversationId,command:he,cols:80,rows:24})):n.create({id:_t(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:_,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:he}),k(!1),Y(!1),i("terminal")},oe=(_,he)=>{if(!e.ready||_.length===0)return;const F={name:he,command:Bl(_),cwd:"${pwd}"},pe=e.terminals.find(Ee=>Ee.title===he);pe?(n.restart(pe.id),t({type:"run_command",terminalId:pe.id,conversationId:pe.conversationId,command:F,cols:80,rows:24})):n.create({id:_t(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:he,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:F}),k(!1),Y(!1),i("terminal")},se=_=>!e.tabs||_==="chat"||e.tabs.includes(_),ye=e.updatesAll??[],C=ye.filter(_=>!_.upToDate&&!_.error).length,ee=ye.filter(_=>!_.upToDate&&!_.error&&_.kind!=="webui"),ce=()=>s.jsxs("div",{className:"dd-updates-all",children:[s.jsx("div",{className:"dd-header",children:v("updatesAllTitle")}),e.updatesAll===null?s.jsx("div",{className:"dd-note",children:v("checkingUpdate")}):ye.length===0?s.jsx("div",{className:"dd-note",children:v("updatesAllUpToDate")}):s.jsx("ul",{className:"dd-all-list",children:ye.map(_=>s.jsxs("li",{className:`dd-all-item${_.error?" err":_.upToDate?"":" warn"}`,children:[s.jsx("span",{className:"dd-all-name",title:_.name,children:_.name}),s.jsx("span",{className:"dd-all-kind",children:_.kind==="webui"?v("kindWebUi"):_.kind==="pi-core"?v("kindPiCore"):v("kindPackage")}),s.jsx("span",{className:"dd-all-vers",children:_.error?v("updateCheckFailed"):_.upToDate?`v${_.current}`:s.jsxs(s.Fragment,{children:["v",_.current," → v",_.latest]})}),_.kind!=="webui"&&!_.upToDate&&!_.error&&s.jsx("button",{type:"button",className:"dd-update-btn",onClick:()=>oe([_],v("updatePkgTabTitle",{name:_.name})),children:v("updateBtn")})]},`${_.kind}:${_.name}`))}),s.jsxs("div",{className:"dd-actions",children:[ee.length>0&&s.jsx("button",{type:"button",className:"dd-refresh accent",style:{flex:1},onClick:()=>oe(ee,v("updateAllTabTitle")),children:v("updateAllBtn")}),s.jsx("button",{type:"button",className:"dd-refresh",style:ee.length>0?{flex:1}:void 0,onClick:()=>t({type:"check_updates_all",force:!0}),children:v("updatesAllRefresh")})]})]}),ae=()=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"dd-update",children:[s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:v("currentVersion")}),s.jsxs("b",{children:["v",e.update?.current??"…"]})]}),s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:v("latestVersion")}),s.jsx("b",{children:e.update===null?v("checkingUpdate"):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:v("checkingUpdate")})]}),e.update&&e.update.upToDate&&s.jsx("div",{className:"dd-note ok",children:v("upToDate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note warn",children:v("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:v("updateJustPublished",{version:e.update.latest??""})}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note",children:v("updateTerminalHint")})]}),s.jsxs("div",{className:"dd-actions",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>t({type:"check_update"}),children:e.update===null?v("checkingUpdate"):v("checkUpdate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("button",{type:"button",className:"dd-refresh accent",onClick:L,children:v("updateNow")})]})]});return s.jsxs("header",{className:"topbar",children:[s.jsxs("div",{className:"brand",children:[s.jsx("button",{type:"button",className:"panel-toggle",title:v("openHistory"),onClick:()=>c("left"),children:s.jsx(kl,{})}),s.jsx("span",{className:"brand-logo",children:"π"}),s.jsx("span",{className:"brand-name",children:"pi-web-ui"}),s.jsx("span",{className:`conn-dot ${I}`,title:w}),s.jsx("span",{className:"conn-label",children:w})]}),s.jsxs("div",{className:"topbar-actions",children:[s.jsxs("div",{className:"view-switch",role:"tablist","aria-label":v("viewSwitch"),children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="chat",className:a==="chat"?"active":"",onClick:()=>i("chat"),children:[s.jsx(es,{}),s.jsx("span",{children:v("chat")})]}),se("terminal")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="terminal",className:a==="terminal"?"active":"",onClick:()=>i("terminal"),children:[s.jsx(Zt,{}),s.jsx("span",{children:v("terminal")})]}),se("git")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="git",className:a==="git"?"active":"",onClick:()=>i("git"),children:[s.jsx(Hs,{}),s.jsx("span",{children:v("scmTab")})]}),(se("plugins")?o:[]).filter(_=>_.view!==!1).map(_=>{const he=_.error?`${_.name}: ${_.error}`:_.description?`${_.name} — ${_.description}`:_.name;return s.jsxs("button",{type:"button",role:"tab","aria-selected":a===`plugin:${_.id}`,className:`plugin-tab${a===`plugin:${_.id}`?" active":""}${_.error?" broken":""}`,title:he,onClick:()=>i(`plugin:${_.id}`),children:[_.icon?s.jsx("span",{"aria-hidden":!0,children:_.icon}):null,s.jsx("span",{children:_.name})]},_.id)})]}),s.jsxs("div",{className:"topbar-desktop",children:[se("search")&&s.jsxs("button",{type:"button",className:"chip",title:v("searchGlobalTip"),onClick:f,children:[s.jsx(Xs,{}),s.jsx("span",{className:"chip-sub",children:v("searchGlobal")})]}),se("tasks")&&s.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":v("bgTasksTip"),onClick:u,children:[s.jsx(Js,{}),s.jsx("span",{className:"chip-sub",children:v("bgTasks")}),e.bgServers.length>0&&s.jsx("span",{className:"bg-task-badge",children:e.bgServers.length})]}),se("settings")&&s.jsxs("button",{type:"button",className:"chip",title:v("settingsTitle"),onClick:d,children:[s.jsx(Vs,{}),s.jsx("span",{className:"chip-sub",children:v("settings")})]}),s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Vi,{}),s.jsx("span",{className:"chip-sub",children:v("sound")})]}),open:B,onOpenChange:H,children:[s.jsx(Ba,{settings:b,onChange:E,onPreview:y}),s.jsx(Ua,{})]}),s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Ji,{}),s.jsx("span",{className:"chip-sub",children:Vl(z)})]}),open:Q,onOpenChange:re,children:[s.jsx("div",{className:"dd-header",children:v("language")}),P.map(_=>s.jsx(nt,{active:z===_.code,onClick:()=>{$(_.code),re(!1)},children:_.nativeName},_.code)),s.jsxs(nt,{onClick:()=>{re(!1),de(!0)},children:[s.jsx(Ht,{})," ",v("localeGetMore")]})]}),s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(gl,{}),s.jsx("span",{className:"chip-sub",children:v("theme")})]}),open:K,onOpenChange:j,children:[s.jsx("div",{className:"dd-header",children:v("theme")}),s.jsx(nt,{active:S===null,onClick:()=>{M(null),j(!1)},children:v("themeDefault")}),N.map(_=>s.jsx(nt,{active:S===_.id,onClick:()=>{M(_.id),j(!1)},children:z==="zh"?_.name:_.nameEn??_.name},_.id))]}),e.managed?s.jsxs("span",{className:"chip",title:v("updatesManaged"),children:[s.jsx(Ht,{}),s.jsxs("span",{className:"chip-sub",children:["v",e.appVersion??e.update?.current??"…"]})]}):s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Ht,{}),s.jsxs("span",{className:"chip-sub",children:["v",e.update?.current??"…"]}),e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot",title:v("updateAvailable",{version:e.update.latest??""})}),C>0&&s.jsx("span",{className:"update-badge",children:v("updatesAllBadge",{n:C})})]}),open:X,onOpenChange:_=>{k(_),_&&(t({type:"check_update"}),t({type:"check_updates_all"}))},fit:!0,children:[s.jsx("div",{className:"dd-header",children:v("update")}),ae(),ce()]}),s.jsx("a",{className:"chip github",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",title:v("githubRepo"),children:s.jsx(Da,{})})]}),s.jsxs("button",{type:"button",className:"chip newchat","data-tip":v("newChatTip"),onClick:()=>t({type:"new_chat"}),children:[s.jsx(dt,{}),s.jsx("span",{children:v("newChat")})]}),s.jsx("div",{className:"topbar-more",children:s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(xl,{}),s.jsx("span",{className:"chip-sub",children:v("more")}),!e.managed&&e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot"})]}),open:Z,onOpenChange:_=>{Y(_),_&&!e.managed&&(t({type:"check_update"}),t({type:"check_updates_all"}))},children:[s.jsx("div",{className:"dd-header",children:v("sound")}),s.jsx("div",{className:"dd-header",children:v("settings")}),s.jsxs(nt,{onClick:()=>{Y(!1),d()},children:[s.jsx(Vs,{})," ",v("settingsTitle")]}),s.jsxs(nt,{onClick:()=>{Y(!1),f()},children:[s.jsx(Xs,{})," ",v("searchGlobal")]}),s.jsxs(nt,{onClick:()=>{Y(!1),u()},children:[s.jsx(Js,{})," ",v("bgTasks"),e.bgServers.length>0&&s.jsx("em",{className:"bg-task-badge",children:e.bgServers.length})]}),s.jsx(Ba,{settings:b,onChange:E,onPreview:y}),s.jsx(Ua,{}),s.jsx("div",{className:"dd-header",children:v("language")}),P.map(_=>s.jsx(nt,{active:z===_.code,onClick:()=>$(_.code),children:_.nativeName},_.code)),s.jsx("div",{className:"dd-header",children:v("theme")}),s.jsx(nt,{active:S===null,onClick:()=>{M(null),Y(!1)},children:v("themeDefault")}),N.map(_=>s.jsx(nt,{active:S===_.id,onClick:()=>{M(_.id),Y(!1)},children:z==="zh"?_.name:_.nameEn??_.name},_.id)),s.jsx("div",{className:"dd-header",children:v("update")}),ae(),ce(),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(Da,{})," ",v("githubRepo")]})]})})]}),s.jsx("button",{type:"button",className:"panel-toggle",title:v("openFiles"),onClick:()=>c("right"),children:s.jsx(Pt,{})}),me&&s.jsx(ac,{onClose:()=>de(!1)})]})}function dr(e,t){const n={...t};if(!e)return n;try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a))for(const o of Object.keys(t)){const i=a[o];typeof i=="number"&&Number.isFinite(i)&&i>0&&(n[o]=i)}}catch{}return n}function mr(e){const t=e.start.above+e.start.below,n=Math.max(1,e.availablePx),a=e.totalWeight>0?e.totalWeight:1,o=n/a,i=e.minAbovePx/o,c=e.minBelowPx/o;if(i+c>=t){const u=e.minAbovePx+e.minBelowPx||1,f=t*e.minAbovePx/u;return{above:f,below:t-f}}const d=Math.min(t-c,Math.max(i,e.start.above+e.deltaPx/o));return{above:d,below:t-d}}function qa(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 rc(e,t){const n=new Map(e.map(i=>[i.id,i])),a=new Map;for(const i of e){const c=i.parentId?n.get(i.parentId)?.cwd??i.cwd:i.cwd,d=a.get(c)??[];d.push(i),a.set(c,d)}const o=[...a.entries()].map(([i,c])=>({cwd:i,isCurrent:i===t,convs:c}));return o.sort((i,c)=>i.isCurrent?-1:c.isCurrent?1:i.cwd<c.cwd?-1:i.cwd>c.cwd?1:0),o}const oc="pi-web-ui:lp-collapse-projects",lc="pi-web-ui:lp-collapse-convs",cc="pi-web-ui:lp-collapse-sessions";function Nn(e,t=!1){const[n,a]=l.useState(()=>{try{const i=localStorage.getItem(e);if(i==="1")return!0;if(i==="0")return!1}catch{}return t}),o=l.useCallback(()=>{a(i=>{const c=!i;try{localStorage.setItem(e,c?"1":"0")}catch{}return c})},[e]);return[n,o]}const pr="pi-web-ui:lp-sizes",en={projects:1,convs:1,sessions:1},uc=32,$a=72;function dc(){try{return dr(localStorage.getItem(pr),en)}catch{return{...en}}}const mc=l.memo(function({ready:t,status:n,cwd:a,sessionFile:o,conversations:i,sessions:c,projects:d,activeConversationId:u,send:f,active:b,collapsible:E,onToggleCollapse:y}){const N=Le(),S=o,M=a,[z,$]=l.useState(null),[v,P]=l.useState(null),[B,H]=l.useState(""),[Q,re]=Nn(oc,!1),[K,j]=Nn(lc,!1),[X,k]=Nn(cc,!1),[Z,Y]=l.useState(null),[me,de]=l.useState(null),w=l.useCallback(()=>{de(null),Y(null)},[]),I=l.useCallback((U,ge)=>{U.preventDefault(),U.stopPropagation(),Y({x:Math.min(U.clientX,window.innerWidth-260),y:Math.min(U.clientY,window.innerHeight-120),scopeId:ge})},[]);l.useEffect(()=>{if(!Z)return;const U=ue=>{ue.target?.closest(".ctx-menu")||w()},ge=ue=>{ue.key==="Escape"&&w()};return window.addEventListener("mousedown",U,!0),window.addEventListener("keydown",ge),window.addEventListener("blur",w),()=>{window.removeEventListener("mousedown",U,!0),window.removeEventListener("keydown",ge),window.removeEventListener("blur",w)}},[Z,w]);const L=l.useCallback((U,ge)=>{if(!ge)return U.filter(G=>G.isSubagent&&!G.isStreaming&&G.id!==u).length;const ue=new Map(U.map(G=>[G.id,G])),ie=G=>{if(G.id===ge)return(ue.get(ge)?.isSubagent??!1)&&!G.isStreaming&&G.id!==u;let Te=G;const Re=new Set;for(;Te?.parentId;){if(Te.parentId===ge)return!0;if(Re.has(Te.parentId)||(Re.add(Te.parentId),Te=ue.get(Te.parentId),!Te))return!1}return!1};return U.filter(G=>G.isSubagent&&!G.isStreaming&&G.id!==u&&ie(G)).length},[u]),oe=l.useCallback((U,ge)=>{if(!ge)return U.filter(G=>G.isSubagent).length;const ue=new Map(U.map(G=>[G.id,G])),ie=G=>{if(G.id===ge)return ue.get(ge)?.isSubagent??!1;let Te=G;const Re=new Set;for(;Te?.parentId;){if(Te.parentId===ge)return!0;if(Re.has(Te.parentId)||(Re.add(Te.parentId),Te=ue.get(Te.parentId),!Te))return!1}return!1};return U.filter(G=>G.isSubagent&&ie(G)).length},[]),se=l.useCallback((U,ge)=>{if(!ge)return 0;const ue=new Map(U.map(G=>[G.id,G])),ie=G=>{let Te=G;const Re=new Set;for(;Te?.parentId;){if(Te.parentId===ge)return!0;if(Re.has(Te.parentId)||(Re.add(Te.parentId),Te=ue.get(Te.parentId),!Te))return!1}return!1};return U.filter(G=>G.isSubagent&&G.isStreaming&&ie(G)).length},[]),ye=l.useRef(null),[C,ee]=l.useState(()=>dc());l.useEffect(()=>{try{localStorage.setItem(pr,JSON.stringify(C))}catch{}},[C]);const ce=l.useCallback((U,ge)=>ue=>{ue.preventDefault();const ie=ue.currentTarget,G=ue.clientY,Te={...C},Re=ye.current;if(!Re)return;const x=[{key:"projects",visible:d.length>0,collapsed:Q},{key:"convs",visible:i.length>0,collapsed:K},{key:"sessions",visible:!0,collapsed:X}].filter(Ae=>Ae.visible),g=x.filter(Ae=>Ae.collapsed).length,le=x.filter(Ae=>!Ae.collapsed).map(Ae=>Ae.key).reduce((Ae,D)=>Ae+(Te[D]??1),0)||1,be=Math.max(120,Re.clientHeight-g*uc);ie.classList.add("dragging"),document.body.classList.add("lp-resizing");const ke=Ae=>{const{above:D,below:we}=mr({start:{above:Te[U]??1,below:Te[ge]??1},deltaPx:Ae.clientY-G,availablePx:be,totalWeight:le,minAbovePx:$a,minBelowPx:$a});ee(Ce=>({...Ce,[U]:D,[ge]:we}))},Ie=()=>{window.removeEventListener("pointermove",ke),window.removeEventListener("pointerup",Ie),ie.classList.remove("dragging"),document.body.classList.remove("lp-resizing")};window.addEventListener("pointermove",ke),window.addEventListener("pointerup",Ie)},[C,d.length,i.length,Q,K,X]);l.useEffect(()=>{!b||!t||n!=="open"||a&&(f({type:"list_sessions"}),f({type:"list_projects"}))},[b,t,n,a,f]);const ae=U=>{const ge=U.name||U.firstMessage.trim();return ge.length>0?ge:N("emptyChat")},_=U=>U.split(/[\\/]/).pop()||U,he=(U,ge,ue,ie,G)=>{const Te=z===U;return s.jsx("button",{type:"button",className:`lp-del ${Te?"confirm":""}`,title:Te?ue:ge,onClick:Re=>{Re.stopPropagation(),Te?($(null),ie()):$(U)},children:Te?s.jsx(Tt,{}):G??s.jsx(et,{})})},F=(U,ge,ue,ie)=>s.jsxs("button",{type:"button",className:"lp-section-title panel-section-title",onClick:ue,title:N(ge?"expandSection":"collapseSection"),children:[s.jsxs("span",{className:"lp-section-title-text",children:[U,ie!==void 0?` (${ie})`:""]}),s.jsx("span",{className:"lp-section-chevron",children:ge?s.jsx(Ot,{}):s.jsx(un,{})})]}),Ee=[{key:"projects",visible:d.length>0,collapsed:Q},{key:"convs",visible:i.length>0,collapsed:K},{key:"sessions",visible:!0,collapsed:X}].filter(U=>U.visible).filter(U=>!U.collapsed),Oe=Ee.reduce((U,ge)=>U+(C[ge.key]??1),0)||1,Se=U=>Ee.length<=1?1:(C[U]??1)/Oe*Ee.length;return s.jsxs("aside",{ref:ye,className:"panel panel-left lp-panel",children:[E&&y&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:N("collapsePanel"),onClick:y,children:s.jsx(tr,{})}),d.length>0&&s.jsxs("div",{className:`lp-section panel-projects ${Q?"collapsed":""}`,style:Q?void 0:{flex:`${Se("projects")} 1 0px`},children:[F(N("recentProjects"),Q,re,d.length),!Q&&s.jsx("div",{className:"lp-section-body projects-scroll",children:d.map(U=>{const ge=M===U.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>$(ue=>ue===`proj:${U.path}`?null:ue),children:[s.jsxs("button",{type:"button",className:`project-item ${ge?"active":""}`,title:U.path,onClick:()=>{ge||f({type:"set_cwd",path:U.path})},children:[s.jsx(Pt,{className:"project-icon"}),s.jsxs("span",{className:"project-info",children:[s.jsx("span",{className:"project-name",children:_(U.path)}),s.jsx("span",{className:"project-path",children:U.path})]}),s.jsx("span",{className:"project-time",children:qa(U.lastUsed)})]}),he(`proj:${U.path}`,N("deleteProject"),N("deleteProjectConfirm"),()=>f({type:"remove_project",path:U.path}))]},U.path)})})]}),d.length>0&&!Q&&(i.length>0?!K:!X)&&s.jsx("div",{className:"lp-sash",onPointerDown:ce("projects",i.length>0?"convs":"sessions"),onDoubleClick:()=>ee({...en}),title:N("dragToResize")}),i.length>0&&s.jsxs("div",{className:`lp-section lp-section-convs panel-convs ${K?"collapsed":""}`,style:K?void 0:{flex:`${Se("convs")} 1 0px`},onContextMenu:U=>I(U),children:[F(N("runningConversations"),K,j,i.length),!K&&s.jsx("div",{className:"lp-section-body convs-scroll",children:rc(i,a).map(U=>s.jsxs("div",{className:"panel-conv-group",children:[!U.isCurrent&&s.jsx("div",{className:"panel-conv-group-title",title:U.cwd,children:_(U.cwd)}),(()=>{const ge=new Map(U.convs.map(x=>[x.id,x])),ue=new Map,ie=[];for(const x of U.convs)if(x.parentId&&ge.has(x.parentId)){const g=ue.get(x.parentId)??[];g.push(x),ue.set(x.parentId,g)}else ie.push(x);const G=[],Te=new Set,Re=(x,g)=>{if(!Te.has(x.id)){Te.add(x.id),G.push({c:x,depth:g});for(const J of ue.get(x.id)??[])Re(J,g+1)}};for(const x of ie)Re(x,0);for(const x of U.convs)Re(x,0);return G.map(({c:x,depth:g})=>{const J=u===x.id;return s.jsxs("div",{className:`lp-row${g>0?" lp-sub":""}`,style:g>0?{marginLeft:g*18}:void 0,onMouseLeave:()=>$(le=>le===`conv:${x.id}`?null:le),onContextMenu:le=>I(le,x.id),children:[s.jsxs("button",{type:"button",className:`session-item ${J?"active":""}`,title:`${x.title}${U.isCurrent?"":` — ${U.cwd}`}`,onClick:()=>{J||f({type:"switch_conversation",id:x.id})},children:[s.jsx(es,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[v===`conv:${x.id}`?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:B,placeholder:N("renameSessionPlaceholder"),onClick:le=>le.stopPropagation(),onChange:le=>H(le.target.value),onKeyDown:le=>{if(le.stopPropagation(),le.key==="Enter"&&!le.nativeEvent.isComposing){const be=B.trim();be&&f({type:"rename_conversation",id:x.id,name:be}),P(null)}else le.key==="Escape"&&P(null)},onBlur:()=>P(null)}):s.jsxs("span",{className:"session-title",children:[x.isSubagent&&s.jsx("span",{className:"subagent-badge",children:N("subagentBadge")}),x.title,x.error&&s.jsx("span",{className:"conv-error-badge",title:N("convErrorBadge",{error:x.error})})]}),v===`conv:${x.id}`?null:s.jsx("span",{className:"session-sub",children:J?N("current"):N("messageCount",{n:x.messageCount})})]}),x.isStreaming&&s.jsx("span",{className:"conv-streaming",title:N("streaming")})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:N("renameSession"),onClick:le=>{le.stopPropagation(),$(null),H(x.title),P(`conv:${x.id}`)},children:s.jsx(Zs,{})}),(()=>{const le=`conv:${x.id}`,be=z===le,ke=L(i,x.id),Ie=se(i,x.id),Ae=oe(i,x.id);return Ae===0&&!x.isStreaming?he(le,N("dismissConversation"),N("dismissConversationConfirm"),()=>f({type:"dismiss_conversation",id:x.id}),s.jsx($e,{})):Ae===0?he(le,N("dismissConversation"),N("dismissStreamingConfirm"),()=>f({type:"dismiss_conversation",id:x.id,force:!0}),s.jsx($e,{})):be?s.jsxs("span",{className:"lp-del-group",children:[ke>0&&s.jsx("button",{type:"button",className:"lp-del-opt",title:N("dismissFinishedSubagentsScoped",{n:ke}),onClick:D=>{D.stopPropagation(),$(null),f({type:"dismiss_finished_subagents",parentId:x.id})},children:N("dismissFinishedOnly",{n:ke})}),s.jsx("button",{type:"button",className:"lp-del-opt danger",title:N("forceDismissTitle",{n:Ae,m:Ie}),onClick:D=>{D.stopPropagation(),$(null),f({type:"dismiss_conversation",id:x.id,force:!0})},children:N("dismissForceAll",{n:Ae})})]}):s.jsx("button",{type:"button",className:"lp-del",title:N("dismissConversation"),onClick:D=>{D.stopPropagation(),$(le)},children:s.jsx($e,{})})})(),x.isStreaming&&s.jsx("span",{className:"lp-row-stalled",title:N("streaming"),style:{position:"absolute",right:28,top:"50%",transform:"translateY(-50%)"}})]},x.id)})})()]},U.cwd))})]}),i.length>0&&!K&&!X&&s.jsx("div",{className:"lp-sash",onPointerDown:ce("convs","sessions"),onDoubleClick:()=>ee({...en}),title:N("dragToResize")}),s.jsxs("div",{className:`lp-section lp-section-sessions panel-sessions ${X?"collapsed":""}`,style:X?void 0:{flex:`${Se("sessions")} 1 0px`},children:[F(N("historySessions"),X,k,c.length),!X&&s.jsxs("div",{className:"lp-section-body sessions-scroll",children:[c.length===0&&s.jsx("div",{className:"panel-empty",children:N("noHistory")}),c.map(U=>{const ge=S===U.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>$(ue=>ue===`sess:${U.path}`?null:ue),children:[s.jsxs("button",{type:"button",className:`session-item ${ge?"active":""}`,title:U.path,onClick:()=>{v||ge||f({type:"switch_session",path:U.path})},children:[s.jsx(es,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[v===U.path?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:B,placeholder:N("renameSessionPlaceholder"),onClick:ue=>ue.stopPropagation(),onChange:ue=>H(ue.target.value),onKeyDown:ue=>{if(ue.stopPropagation(),ue.key==="Enter"&&!ue.nativeEvent.isComposing){const ie=B.trim();ie&&f({type:"rename_session",path:U.path,name:ie}),P(null)}else ue.key==="Escape"&&P(null)},onBlur:()=>P(null)}):s.jsx("span",{className:"session-title",children:ae(U)}),v===U.path?null:s.jsxs("span",{className:"session-sub",children:[ge?N("current"):N("messageCount",{n:U.messageCount}),U.source==="tui"&&s.jsx("span",{className:"session-src",title:N("tuiTip"),children:"TUI"})]})]}),s.jsx("span",{className:"session-time",children:qa(U.modified)})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:N("renameSession"),onClick:ue=>{ue.stopPropagation(),$(null),H(U.name??""),P(U.path)},children:s.jsx(Zs,{})}),he(`sess:${U.path}`,N("deleteSession"),N("deleteSessionConfirm"),()=>f({type:"delete_session",path:U.path}))]},U.path)})]})]}),Z&&s.jsxs("div",{className:"ctx-menu",style:{left:Z.x,top:Z.y},onContextMenu:U=>{U.preventDefault(),U.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",title:L(i,Z.scopeId)===0?N("noFinishedSubagents"):void 0,disabled:L(i,Z.scopeId)===0,onClick:()=>{Z.scopeId?f({type:"dismiss_finished_subagents",parentId:Z.scopeId}):f({type:"dismiss_finished_subagents"}),w()},children:[s.jsx($e,{}),s.jsx("span",{children:L(i,Z.scopeId)===0?N("noFinishedSubagents"):Z.scopeId?N("dismissFinishedSubagentsScoped",{n:L(i,Z.scopeId)}):N("dismissFinishedSubagents",{n:L(i,Z.scopeId)})})]}),Z.scopeId&&s.jsxs("button",{type:"button",className:me===Z.scopeId?"ctx-item danger armed":"ctx-item danger",title:me===Z.scopeId?N("forceDismissConfirm"):N("forceDismissConversation"),onClick:()=>{const U=Z.scopeId;me===U?(f({type:"dismiss_conversation",id:U,force:!0}),de(null),w()):de(U)},children:[s.jsx($e,{}),s.jsx("span",{children:me===Z.scopeId?N("forceDismissConfirm"):N("forceDismissConversation")})]})]})]})});function pc(e,t){const n=t.assistantMessageEvent,a=e.stats.tokens,o=t.usage!==null?{...a,...t.usage}:a,i=o===a?e.stats:{...e.stats,tokens:o};if(n.type!=="text_delta"&&n.type!=="thinking_delta")return i===e.stats?e:{...e,stats:i};const c=n.delta??"";if(!c)return i===e.stats?e:{...e,stats:i};const d=e.streamingMessage??null,u=d&&d.id===t.messageId?d:{id:t.messageId,content:[]},f=[...u.content],b=n.type==="thinking_delta"?"thinking":"text",E=n.contentIndex??f.length-1;return E>=0&&E<f.length&&f[E].type===b?f[E]=b==="thinking"?{type:"thinking",thinking:(f[E].thinking??"")+c}:{type:"text",text:(f[E].text??"")+c}:f.push(b==="thinking"?{type:"thinking",thinking:c}:{type:"text",text:c}),{...e,stats:i,streamingMessage:{...u,id:t.messageId,content:f}}}const Un="pi-web-ui:plugin-data";function hc(e,t){window.dispatchEvent(new CustomEvent(Un,{detail:{pluginId:e,payload:t}}))}function fc(e){const t=n=>{const a=n.detail;e(a.pluginId,a.payload)};return window.addEventListener(Un,t),()=>window.removeEventListener(Un,t)}const Vt=new Map,qn=new Set,Yt=new Set;let Wa=-1;function hr(){return[...Vt.values()]}function gc(){const e=hr();for(const t of qn)t(e)}function bc(e){return qn.add(e),e(hr()),()=>qn.delete(e)}async function Ec(e,t){t!==Wa&&(Wa=t,Vt.clear(),Yt.clear());const n=new Set(e.map(a=>a.id));for(const a of[...Vt.keys()])n.has(a)||Vt.delete(a);for(const a of[...Yt])n.has(a)||Yt.delete(a);await Promise.all(e.filter(a=>a.hasClient&&a.view!==!1&&!a.error&&!Vt.has(a.id)&&!Yt.has(a.id)).map(async a=>{try{const i=(await import(at(`/plugins/${encodeURIComponent(a.id)}/client/entry.mjs?e=${t}`))).default;i&&typeof i.mount=="function"?Vt.set(a.id,{info:a,module:i}):(Yt.add(a.id),console.error(`[plugin:${a.id}] entry.mjs 缺少 default.mount`))}catch(o){Yt.add(a.id),console.error(`[plugin:${a.id}] 客户端加载失败:`,o)}})),gc()}function Tc(e,t){return{pluginId:e,send:n=>t({type:"plugin_message",pluginId:e,payload:n}),onData:n=>fc((a,o)=>{a===e&&n(o)})}}const xc=15,yc="pi-web-ui:lang";function Ka(){try{return(localStorage.getItem(yc)??"").trim()}catch{return""}}const Ya="pi-web-ui:locale",kn=2e5,Nc=2e5,kc="LIVE_OMIT",Cc={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 vc(){const e=new Map,t=new Map,n=(a,o)=>`${a}:${o}`;return{write(a,o,i){const c=n(a,o),d=e.get(c);if(d&&d.size>0){for(const b of d)try{b.write(i)}catch{}return}const u=t.get(c)??"",f=u.length+i.length>Nc?i:u+i;t.set(c,f)},register(a,o,i){const c=n(a,o);let d=e.get(c);d||(d=new Set,e.set(c,d)),d.add(i);const u=t.get(c);if(u){try{i.write(u)}catch{}t.delete(c)}return()=>{const f=e.get(c);f&&(f.delete(i),f.size===0&&e.delete(c)),t.delete(c)}},clear(){e.clear(),t.clear()}}}function Ga(e,t){const n=new Set;for(const o of t.messages)o.role==="toolResult"&&o.toolCallId&&n.add(o.toolCallId),o.role==="bashExecution"&&n.add(`bash-${o.id}`);let a=!1;for(const o of e.keys())n.has(o)&&(e.delete(o),a=!0);return a?new Map(e):e}function za(e,t){if(e.size===0)return e;const n=new Set;for(const o of t.messages)o.role==="toolResult"&&o.toolCallId&&n.add(o.toolCallId);let a=!1;for(const o of e.keys())n.has(o)&&(e.delete(o),a=!0);return a?new Map(e):e}function _c(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!==xc};case"snapshot":return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:Ga(e.liveOutputs,t.state),toolStatuses:za(e.toolStatuses,t.state)};case"snapshot_delta":{const n=e.state,a=t.msg;if(!n||n.conversationId!==a.conversationId||n.rev!==a.baseRev)return e;const o={...n,...a.state,messages:a.appended.length>0?[...n.messages,...a.appended]:n.messages};return{...e,ready:!0,state:o,activeConversationId:o.conversationId,liveOutputs:Ga(e.liveOutputs,o),toolStatuses:za(e.toolStatuses,o)}}case"tool_delta":{const a=(e.liveOutputs.get(t.toolCallId)?.text??"")+t.delta,o=a.length>kn?`…[${kc}:${a.length-kn}]…
|
|
305
|
-
`+a.slice(a.length-kn):a,i=new Map(e.liveOutputs);return i.set(t.toolCallId,{toolName:t.toolName,text:o}),{...e,liveOutputs:i}}case"message_delta":{const n=e.state;return!n||n.conversationId!==t.msg.conversationId?e:{...e,state:pc(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 Va="pi-web-client-id";let Cn=null;function ca(){if(Cn)return Cn;let e=null;try{e=sessionStorage.getItem(Va),e||(e=_t(),sessionStorage.setItem(Va,e))}catch{e=e??_t()}return Cn=e,e}const fr="pi-web-last-cwd";function Sc(){try{return localStorage.getItem(fr)}catch{return null}}function Ac(e){try{localStorage.setItem(fr,e)}catch{}}function wc(){const e=location.protocol==="https:"?"wss:":"ws:";return Dt(`${e}//${location.host}${at("/ws")}`)}function Ic(){const[e,t]=l.useReducer(_c,{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:Cc,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=l.useRef(null),a=l.useRef(vc()),o=l.useRef(0),i=l.useRef(null),c=l.useRef(!0),d=l.useRef(0),u=l.useRef(0),f=l.useRef(new Map),b=l.useRef(null),E=l.useRef(!1),y=l.useRef(null),N=()=>{b.current||(b.current=setTimeout(()=>{b.current=null;const j=n.current;j&&j.readyState===WebSocket.OPEN&&j.send(JSON.stringify({type:"get_state"}))},300))},S=(j,X)=>{const k=f.current,Z=k.get(j);if(Z!==void 0&&X!==Z+1){const Y=K.current.chat,me=Y.activeConversationId||Y.state?.conversationId;j===me&&N()}k.set(j,X)},M=l.useCallback((j,X)=>{const k=++u.current;t({type:"notice",notice:{id:k,level:j,text:X}})},[]),z=l.useCallback(j=>{const X=n.current;return X&&X.readyState===WebSocket.OPEN?(j.type==="check_updates_all"&&j.force===!0&&t({type:"updates_check_started"}),X.send(JSON.stringify(j)),j.type==="question_answer"&&t({type:"question",question:null}),!0):!1},[]),$=l.useCallback(()=>{if(!c.current)return;t({type:"status",status:"connecting"});const j=new WebSocket(wc());n.current=j,j.onopen=()=>{n.current===j&&(t({type:"status",status:"open"}),o.current=0,d.current=Date.now(),j.send(JSON.stringify({type:"hello",clientId:ca(),locale:Ka()})))},j.onmessage=X=>{if(n.current!==j)return;d.current=Date.now();let k;try{k=JSON.parse(X.data)}catch{return}switch(k.type){case"ready":t({type:"ready",serverVersion:k.serverVersion,protocolVersion:k.protocolVersion,engine:k.engine,appVersion:k.appVersion,managed:k.managed,tabs:k.tabs}),j.send(JSON.stringify({type:"get_state"})),j.send(JSON.stringify({type:"list_files"})),j.send(JSON.stringify({type:"list_models"})),j.send(JSON.stringify({type:"list_commands"})),j.send(JSON.stringify({type:"get_commands"})),k.managed||(j.send(JSON.stringify({type:"check_update"})),j.send(JSON.stringify({type:"check_updates_all"})));break;case"snapshot":f.current=new Map,t({type:"snapshot",state:k.state});break;case"snapshot_delta":{const Z=K.current.chat.state;(!Z||Z.conversationId!==k.conversationId||Z.rev!==k.baseRev)&&N(),t({type:"snapshot_delta",msg:k});break}case"tool_delta":S(k.conversationId,k.seq),t({type:"tool_delta",toolCallId:k.toolCallId,toolName:k.toolName,delta:k.delta});break;case"tool_status":t({type:"tool_status",status:k});break;case"message_delta":{S(k.conversationId,k.seq),t({type:"message_delta",msg:k});break}case"notice":{const Z=++u.current;t({type:"notice",notice:{id:Z,level:k.level,text:k.text,textEn:k.textEn}});break}case"sessions":t({type:"sessions",sessions:k.sessions});break;case"conversations":t({type:"conversations",conversations:k.conversations,activeId:k.activeId});break;case"projects":t({type:"projects",projects:k.projects});break;case"files":t({type:"files",files:k});break;case"file_changed":t({type:"file_changed",path:k.path});break;case"file_content":t({type:"file_content",content:k});break;case"models":t({type:"models",models:k.models,loading:!1});break;case"models_config":t({type:"models_config",providers:k.providers});break;case"providers_status":t({type:"providers_status",providers:k.providers});break;case"provider_keys":t({type:"provider_keys",keys:k.keys});break;case"fetch_models_result":t({type:"fetch_models_result",result:{reqId:k.reqId,ok:k.ok,models:k.models,error:k.error}});break;case"refresh_provider_result":t({type:"refresh_provider_result",result:{reqId:k.reqId,ok:k.ok,added:k.added,total:k.total,error:k.error}});break;case"clone_provider_result":t({type:"clone_provider_result",result:{reqId:k.reqId,ok:k.ok,config:k.config,configs:k.configs,error:k.error}});break;case"scm_data":t({type:"scm_data",data:k});break;case"search_files_result":t({type:"file_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results,truncated:k.truncated}});break;case"session_search_results":t({type:"session_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results}});break;case"scm_changed":t({type:"scm_changed"});break;case"install_result":t({type:"install_result",result:k});break;case"path_completions":t({type:"path_completions",completions:k.completions});break;case"update_status":t({type:"update_status",status:k});break;case"update_status_all":t({type:"update_status_all",items:k.items});break;case"widgets":t({type:"widgets",widgets:k.widgets});break;case"statuses":t({type:"statuses",statuses:k.statuses});break;case"dialog":t({type:"dialog",dialog:{id:k.id,kind:k.kind,title:k.title,args:k.args}});break;case"dialog_closed":t({type:"dialog",dialog:null});break;case"question_pending":t({type:"question",question:{id:k.id,questions:k.questions}});break;case"terminal_output":a.current.write(k.conversationId??K.current.chat.activeConversationId,k.terminalId,k.data);break;case"terminal_exit":t({type:"terminal_exit",conversationId:k.conversationId,terminalId:k.terminalId,exitCode:k.exitCode});break;case"terminal_list":t({type:"terminal_list",conversationId:k.conversationId,terminals:k.terminals});break;case"commands":t({type:"commands",commands:k.commands,path:k.path});break;case"slash_commands":t({type:"slash_commands",commands:k.commands});break;case"goal_status":t({type:"goal_status",status:k.status});break;case"settings_state":t({type:"settings",settings:k.settings});break;case"bg_servers":t({type:"bg_servers",servers:k.servers});break;case"plugins":t({type:"plugins",plugins:k.plugins,epoch:k.epoch});break;case"plugin_catalog":t({type:"plugin_catalog",entries:k.entries,epoch:k.epoch});break;case"dsh_patches":t({type:"dsh_patches",patchDir:k.patchDir,files:k.files});break;case"plugin_data":hc(k.pluginId,k.payload);break}},j.onclose=()=>{if(n.current===j&&(n.current=null),a.current.clear(),!c.current||n.current&&n.current!==j)return;t({type:"status",status:"closed"});const X=Math.min(1e3*2**o.current,1e4);o.current+=1,i.current=setTimeout(()=>{i.current=null,$()},X)},j.onerror=()=>{}},[]);l.useEffect(()=>{const j=X=>{const k=X.detail??Ka();k&&z({type:"set_locale",locale:k})};return window.addEventListener(Ya,j),()=>window.removeEventListener(Ya,j)},[z]),l.useEffect(()=>{c.current=!0,$();const j=setInterval(()=>{if(!c.current)return;const X=n.current;X&&X.readyState===WebSocket.OPEN&&Date.now()-d.current>3e4&&X.close()},5e3);return()=>{c.current=!1,clearInterval(j),i.current&&(clearTimeout(i.current),i.current=null),n.current?.close(),n.current=null}},[$]),l.useEffect(()=>{const j=e.state?.cwd;if(j){if(!E.current){E.current=!0;const X=Sc();if(X&&X!==j){z({type:"set_cwd",path:X});return}}y.current!==j&&(y.current=j,Ac(j))}},[e.state?.cwd,z]);const v=l.useCallback(j=>t({type:"dismiss_notice",id:j}),[]),P=l.useCallback(j=>t({type:"terminal_add",meta:j}),[]),B=l.useCallback(j=>t({type:"terminal_remove",id:j}),[]),H=l.useCallback(j=>t({type:"terminal_restart",terminalId:j}),[]),Q=l.useCallback(j=>t({type:"terminal_active",id:j}),[]),re=l.useCallback((j,X,k)=>a.current.register(j,X,k),[]),K=l.useRef({chat:e,send:z,pushNotice:M,dismissNotice:v,terminal:{create:P,close:B,register:re,restart:H,select:Q}});return K.current={chat:e,send:z,pushNotice:M,dismissNotice:v,terminal:{create:P,close:B,register:re,restart:H,select:Q}},K.current}const jc=200*1024*1024,Lc=/windows/i.test(navigator.userAgent),Rc=/[<>:"/\\|?*\u0000-\u001f]/g,Pc=/[. ]+$/,Dc=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Oc(e){const t=e.replace(Rc,"_").replace(Pc,"");return t?Dc.test(t)?`_${t}`:t:"_"}function Qa(e,t=!0){const n=new URLSearchParams({clientId:ca(),path:e,...t?{download:"1"}:{}});return Dt(at(`/api/file?${n}`))}const gr="FILE_NOT_FOUND";async function Mc(e,t){const n=Lc?Oc(t):t;try{const a=await fetch(Qa(e));if(!a.ok)return{ok:!1,cancelled:!1,error:await a.text().catch(()=>"")||(a.status===404?gr:`HTTP ${a.status}`)};if(Number(a.headers.get("content-length")??"0")>jc)return window.location.assign(Qa(e)),{ok:!0};const i=await a.blob();return window.showSaveFilePicker&&window.isSecureContext?Bc(i,n):$n(i,n)}catch(a){return{ok:!1,cancelled:!1,error:a instanceof Error?a.message:String(a)}}}async function Bc(e,t){let n;const a=window.showSaveFilePicker;if(!a)return $n(e,t);try{n=await a({suggestedName:t})}catch(o){return o instanceof DOMException&&o.name==="AbortError"?{ok:!1,cancelled:!0}:$n(e,t)}try{const o=await n.createWritable();return await o.write(e),await o.close(),{ok:!0}}catch(o){return{ok:!1,cancelled:!1,error:o instanceof Error?o.message:String(o)}}}function $n(e,t){const n=URL.createObjectURL(e),a=document.createElement("a");return a.href=n,a.download=t,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}const cs="@root",Xa="pi-web-ui:rp-sizes",vn={files:4,widgets:1},Ja=120,Za=56,Fc=l.memo(function({files:t,fileChanged:n,widgets:a,cwd:o,send:i,onAttach:c,onPreview:d,onNotice:u,collapsible:f,onToggleCollapse:b}){const E=Le(),[y,N]=l.useState(""),[S,M]=l.useState(null),[z,$]=l.useState(!1),v=l.useRef(null),P=l.useRef(null),[B,H]=l.useState(()=>{try{return dr(localStorage.getItem(Xa),vn)}catch{return{...vn}}});l.useEffect(()=>{try{localStorage.setItem(Xa,JSON.stringify(B))}catch{}},[B]);const Q=a.some(x=>x.lines.length>0),re=l.useCallback(x=>{x.preventDefault();const g=v.current;if(!g)return;const J=x.currentTarget,le=x.clientY,be={above:B.files,below:B.widgets},ke=Math.max(120,g.clientHeight-(P.current?.offsetHeight??32));J.classList.add("dragging"),document.body.classList.add("rp-resizing");const Ie=D=>{const{above:we,below:Ce}=mr({start:be,deltaPx:D.clientY-le,availablePx:ke,totalWeight:be.above+be.below,minAbovePx:Ja,minBelowPx:Za});H({files:we,widgets:Ce})},Ae=()=>{window.removeEventListener("pointermove",Ie),window.removeEventListener("pointerup",Ae),J.classList.remove("dragging"),document.body.classList.remove("rp-resizing")};window.addEventListener("pointermove",Ie),window.addEventListener("pointerup",Ae)},[B.files,B.widgets]),[K,j]=l.useState(null),X=l.useRef(""),k=l.useRef(null),Z=l.useRef(null),[Y,me]=l.useState(null),de=l.useRef(null);l.useEffect(()=>()=>{de.current&&clearTimeout(de.current)},[]);const w=l.useCallback(x=>{me(x),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>me(null),1200)},[]),I=x=>{try{const g=document.createElement("textarea");g.value=x,g.style.position="fixed",g.style.opacity="0",document.body.appendChild(g),g.select();const J=document.execCommand("copy");return document.body.removeChild(g),J}catch{return!1}},L=l.useCallback((x,g)=>{if(!x)return;const J=()=>w(g),le=()=>u("error",E("slashCopyFailed")),be=navigator;be.clipboard?.writeText?be.clipboard.writeText(x).then(J,()=>{I(x)?J():le()}):I(x)?J():le()},[w,u,E]),oe=l.useCallback(x=>{if(!x)return o;if(/^[A-Za-z]:$/.test(x))return`${x}/`;if(x.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(x))return x;const g=o.replace(/\\/g,"/").replace(/\/+$/,"");return g?`${g}/${x}`:x},[o]),se=l.useCallback(x=>!x||x===cs?null:x.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(x)?x:`${o.replace(/\\/g,"/").replace(/\/+$/,"")}/${x}`,[o]),ye=l.useCallback((x,g,J)=>{x.preventDefault(),X.current=g,k.current=J??null,j({x:Math.min(x.clientX,window.innerWidth-220),y:Math.min(x.clientY,window.innerHeight-90)})},[]),C=l.useCallback(()=>j(null),[]);l.useEffect(()=>{if(!K)return;const x=le=>{le.target?.closest(".ctx-menu")||C()},g=le=>{le.key==="Escape"&&C()};window.addEventListener("mousedown",x,!0),window.addEventListener("keydown",g);const J=()=>C();return window.addEventListener("blur",J),()=>{window.removeEventListener("mousedown",x,!0),window.removeEventListener("keydown",g),window.removeEventListener("blur",J)}},[K,C]);const ee=l.useCallback(()=>{const x=k.current;C(),x&&i({type:"set_cwd",path:x.path})},[C,i]),ce=l.useCallback(()=>{C(),Z.current&&(Z.current.value=""),Z.current?.click()},[C]),ae=l.useCallback((x,g)=>{for(const J of g){const le=new FileReader;le.onload=()=>{const be=le.result,ke=be.slice(be.indexOf(",")+1);ke&&i({type:"upload_file",dirPath:x,name:J.name,data:ke})},le.readAsDataURL(J)}},[i]),_=l.useCallback(x=>{ae(X.current,Array.from(x.target.files??[]))},[ae]),he=l.useRef(null),F=x=>Array.from(x.dataTransfer?.types??[]).includes("Files"),pe=l.useCallback(()=>{he.current?.querySelectorAll(".file-item.drop-target").forEach(x=>x.classList.remove("drop-target")),he.current?.classList.remove("drop-root")},[]),Ee=l.useCallback(x=>{if(pe(),x==null)return;const g=he.current?.querySelector(`.file-item[data-path="${CSS.escape(x)}"]`);g?g.classList.add("drop-target"):he.current?.classList.add("drop-root")},[pe]),Oe=x=>{const g=x instanceof Element?x.closest(".file-item"):null;return g?.dataset.type==="dir"?g.dataset.path??y:y},Se=l.useCallback(()=>{const x=document.querySelector(".app");x&&x.dispatchEvent(new DragEvent("dragleave",{bubbles:!0}))},[]),U=1e4,ge=l.useRef(0),ue=l.useRef(void 0),ie=l.useCallback((x,g)=>{const J=++ge.current;N(x),g?.silent||$(!0),i({type:"list_files",path:x===""?void 0:x})||ge.current===J&&$(!1)},[i]);l.useEffect(()=>{t&&t.path===y&&$(!1)},[t,y]),l.useEffect(()=>{if(o!==ue.current){ue.current=o,ie("",{silent:!0});return}const x=setInterval(()=>{document.visibilityState!=="hidden"&&ie(y,{silent:!0})},U);return()=>clearInterval(x)},[o,y,ie]),l.useEffect(()=>{n&&n.path===y&&ie(y,{silent:!0})},[n,y,ie]);const G=x=>ie(x),Te=()=>{t?.parent!==null&&t?.parent!==void 0&&ie(t.parent)},Re=(()=>{if(y===""||y===cs)return[];const x=y.split("/").filter(g=>!!g&&g!==cs);return y.startsWith("/")?x.map((g,J)=>({label:J===0?"/":x[J],path:"/"+x.slice(0,J+1).join("/")})):x.map((g,J)=>({label:x[J],path:x.slice(0,J+1).join("/")}))})();return s.jsxs("aside",{className:"panel panel-right",ref:v,children:[f&&b&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:E("collapsePanel"),onClick:b,children:s.jsx(er,{})}),s.jsxs("div",{className:"panel-crumbs",ref:P,children:[s.jsx("button",{type:"button",className:`crumb ${y===""?"active":""}`,onClick:()=>ie(""),children:E("rootDir")}),s.jsx("button",{type:"button",className:`crumb ${y===cs?"active":""}`,title:E("computer"),onClick:()=>ie(cs),children:"💻"}),Re.map(x=>s.jsxs("span",{className:"crumb-seg",children:[s.jsx($t,{}),s.jsx("button",{type:"button",className:`crumb ${x.path===y?"active":""}`,onClick:()=>ie(x.path),children:x.label})]},x.path))]}),s.jsxs("div",{ref:he,className:"panel-body",style:Q?{flexGrow:B.files,minHeight:Ja}:void 0,onContextMenu:x=>ye(x,y),onDragOver:x=>{F(x)&&(x.preventDefault(),x.stopPropagation(),x.dataTransfer.dropEffect="copy",Se(),Ee(Oe(x.target)))},onDragLeave:x=>{x.relatedTarget&&x.currentTarget.contains(x.relatedTarget)||pe()},onDrop:x=>{if(pe(),!F(x))return;x.preventDefault(),x.stopPropagation(),Se();const g=Array.from(x.dataTransfer?.files??[]);if(g.length===0){u("warning",E("foldersNotSupported"));return}ae(Oe(x.target),g)},onDragEnd:pe,children:[s.jsx("input",{ref:Z,type:"file",multiple:!0,hidden:!0,onChange:_}),z&&s.jsx("div",{className:"panel-empty",children:E("loading")}),!z&&t&&t.path===y&&s.jsxs(s.Fragment,{children:[t.parent!=null&&s.jsxs("button",{type:"button",className:"file-item dir",onClick:Te,children:[s.jsx(Pt,{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:g=>{g.stopPropagation();const J=se(x.path);ye(g,x.path,J?{path:J,name:x.name}:null)},children:[s.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>G(x.path),children:[s.jsx(Pt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:x.name})]}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":E("linkFolderTip"),"aria-label":E("linkFolderTip"),onClick:()=>c(x.path,x.name,"reference",!0),children:s.jsx(On,{})}),s.jsx("button",{type:"button",className:`file-attach copy${Y===`name:${x.path}`?" copied":""}`,"data-tip":E("copyName"),"aria-label":E("copyName"),onClick:()=>L(x.name,`name:${x.path}`),children:Y===`name:${x.path}`?s.jsx(Tt,{}):s.jsx(vt,{})}),s.jsx("button",{type:"button",className:`file-attach copy${Y===`path:${x.path}`?" copied":""}`,"data-tip":E("copyPath"),"aria-label":E("copyPath"),onClick:()=>L(oe(x.path),`path:${x.path}`),children:Y===`path:${x.path}`?s.jsx(Tt,{}):s.jsx(Oa,{})})]},x.path):s.jsxs("div",{className:"file-item file","data-type":"file","data-path":x.path,onContextMenu:g=>{g.stopPropagation(),ye(g,y)},children:[s.jsxs("button",{type:"button",className:"file-name",title:`${x.path} — ${E("previewFile")}`,onClick:()=>d(x.path,x.name),children:[s.jsx(jl,{className:"file-icon"}),s.jsx("span",{className:"file-name-text",children:x.name})]}),s.jsx("button",{type:"button",className:"file-attach download","data-tip":E("downloadFile"),onClick:()=>{Mc(x.path,x.name).then(g=>{g.ok||g.cancelled||u("error",E("downloadFailed",{error:g.error===gr?E("fileNotFoundShort"):g.error}))})},children:s.jsx(Ht,{})}),s.jsx("button",{type:"button",className:"file-attach inline","data-tip":E("attachInlineTip"),onClick:()=>c(x.path,x.name,"inline"),children:s.jsx(dt,{})}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":E("referenceTip"),"aria-label":E("referenceTip"),onClick:()=>c(x.path,x.name,"reference"),children:s.jsx(On,{})}),s.jsx("button",{type:"button",className:`file-attach copy${Y===`name:${x.path}`?" copied":""}`,"data-tip":E("copyName"),"aria-label":E("copyName"),onClick:()=>L(x.name,`name:${x.path}`),children:Y===`name:${x.path}`?s.jsx(Tt,{}):s.jsx(vt,{})}),s.jsx("button",{type:"button",className:`file-attach copy${Y===`path:${x.path}`?" copied":""}`,"data-tip":E("copyPath"),"aria-label":E("copyPath"),onClick:()=>L(oe(x.path),`path:${x.path}`),children:Y===`path:${x.path}`?s.jsx(Tt,{}):s.jsx(Oa,{})})]},x.path)),t.truncated&&s.jsx("div",{className:"panel-empty files-truncated",children:E("filesTruncated")})]}),!z&&!t&&s.jsx("div",{className:"panel-empty",children:E("noFiles")})]}),Q&&s.jsx("div",{className:"rp-sash",onPointerDown:re,onDoubleClick:()=>H({...vn}),title:E("dragToResize")}),Q&&s.jsx("div",{className:"panel-widgets",style:{flexGrow:B.widgets,minHeight:Za},children:a.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:E("widgetExpand"),onClick:()=>M(x.key),children:[s.jsx("span",{children:x.key}),s.jsx(vl,{})]}),s.jsx("pre",{className:"widget-lines",children:x.lines.join(`
|
|
306
|
-
`)})]},x.key))}),S&&(()=>{const x=a.find(
|
|
307
|
-
`)})]})}):null})(),K&&s.jsxs("div",{className:"ctx-menu",style:{left:K.x,top:K.y},onContextMenu:x=>{x.preventDefault(),x.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",onClick:ce,children:[s.jsx(
|
|
308
|
-
`,t);return a===-1?n:n===-1||n+1===a?a:n<a?n:a}const Bt={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},Er={}.hasOwnProperty,Zc=Object.prototype;function eu(e,t){const n=t||{};return ua({file:n.file||void 0,location:!1,schema:n.space==="svg"?ws:cn,verbose:n.verbose||!1},e)}function ua(e,t){let n;switch(t.nodeName){case"#comment":{const a=t;return n={type:"comment",value:a.data},Us(e,a,n),n}case"#document":case"#document-fragment":{const a=t,o="mode"in a?a.mode==="quirks"||a.mode==="limited-quirks":!1;if(n={type:"root",children:Tr(e,t.childNodes),data:{quirksMode:o}},e.file&&e.location){const i=String(e.file),c=Jc(i),d=c.toPoint(0),u=c.toPoint(i.length);n.position={start:d,end:u}}return n}case"#documentType":{const a=t;return n={type:"doctype"},Us(e,a,n),n}case"#text":{const a=t;return n={type:"text",value:a.value},Us(e,a,n),n}default:return n=tu(e,t),n}}function Tr(e,t){let n=-1;const a=[];for(;++n<t.length;){const o=ua(e,t[n]);a.push(o)}return a}function tu(e,t){const n=e.schema;e.schema=t.namespaceURI===Bt.svg?ws:cn;let a=-1;const o={};for(;++a<t.attrs.length;){const d=t.attrs[a],u=(d.prefix?d.prefix+":":"")+d.name;Er.call(Zc,u)||(o[u]=d.value)}const c=(e.schema.space==="svg"?Xc:Qc)(t.tagName,o,Tr(e,t.childNodes));if(Us(e,t,c),c.tagName==="template"){const d=t,u=d.sourceCodeLocation,f=u&&u.startTag&&Qt(u.startTag),b=u&&u.endTag&&Qt(u.endTag),E=ua(e,d.content);f&&b&&e.file&&(E.position={start:f.end,end:b.start}),c.content=E}return e.schema=n,c}function Us(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const a=su(e,n,t.sourceCodeLocation);a&&(e.location=!0,n.position=a)}}function su(e,t,n){const a=Qt(n);if(t.type==="element"){const o=t.children[t.children.length-1];if(a&&!n.endTag&&o&&o.position&&o.position.end&&(a.end=Object.assign({},o.position.end)),e.verbose){const i={};let c;if(n.attrs)for(c in n.attrs)Er.call(n.attrs,c)&&(i[la(e.schema,c).property]=Qt(n.attrs[c]));Dn(n.startTag);const d=Qt(n.startTag),u=n.endTag?Qt(n.endTag):void 0,f={opening:d};u&&(f.closing=u),f.properties=i,t.data={position:f}}}return a}function Qt(e){const t=ni({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=ni({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function ni(e){return e.line&&e.column?e:void 0}const nu={},au={}.hasOwnProperty,xr=$i("type",{handlers:{root:ru,element:du,text:cu,comment:uu,doctype:lu}});function iu(e,t){const a=(t||nu).space;return xr(e,a==="svg"?ws:cn)}function ru(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=da(e.children,n,t),as(e,n),n}function ou(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=da(e.children,n,t),as(e,n),n}function lu(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return as(e,t),t}function cu(e){const t={nodeName:"#text",value:e.value,parentNode:null};return as(e,t),t}function uu(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return as(e,t),t}function du(e,t){const n=t;let a=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(a=ws);const o=[];let i;if(e.properties){for(i in e.properties)if(i!=="children"&&au.call(e.properties,i)){const u=mu(a,i,e.properties[i]);u&&o.push(u)}}const c=a.space,d={nodeName:e.tagName,tagName:e.tagName,attrs:o,namespaceURI:Bt[c],childNodes:[],parentNode:null};return d.childNodes=da(e.children,d,a),as(e,d),e.tagName==="template"&&e.content&&(d.content=ou(e.content,a)),d}function mu(e,t,n){const a=la(e,t);if(n===!1||n===null||n===void 0||typeof n=="number"&&Number.isNaN(n)||!n&&a.boolean)return;Array.isArray(n)&&(n=a.commaSeparated?Qo(n):Xo(n));const o={name:a.attribute,value:n===!0?"":String(n)};if(a.space&&a.space!=="html"&&a.space!=="svg"){const i=o.name.indexOf(":");i<0?o.prefix="":(o.name=o.name.slice(i+1),o.prefix=a.attribute.slice(0,i)),o.namespace=Bt[a.space]}return o}function da(e,t,n){let a=-1;const o=[];if(e)for(;++a<e.length;){const i=xr(e[a],n);i.parentNode=t,o.push(i)}return o}function as(e,t){const n=e.position;n&&n.start&&n.end&&(Dn(typeof n.start.offset=="number"),Dn(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 pu=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],hu=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]),Ue="�";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 st={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function yr(e){return e>=55296&&e<=57343}function fu(e){return e>=56320&&e<=57343}function gu(e,t){return(e-55296)*1024+9216+t}function Nr(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function kr(e){return e>=64976&&e<=65007||hu.has(e)}var O;(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"})(O||(O={}));const bu=65536;class Eu{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=bu,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:a,col:o,offset:i}=this,c=o+n,d=i+n;return{code:t,startLine:a,endLine:a,startCol:c,endCol:c,startOffset:d,endOffset:d}}_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(fu(n))return this.pos++,this._addGap(),gu(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,p.EOF;return this._err(O.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 a=0;a<t.length;a++)if((this.html.charCodeAt(this.pos+a)|32)!==t.charCodeAt(a))return!1;return!0}peek(t){const n=this.pos+t;if(n>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,p.EOF;const a=this.html.charCodeAt(n);return a===p.CARRIAGE_RETURN?p.LINE_FEED:a}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,yr(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){Nr(t)?this._err(O.controlCharacterInInputStream):kr(t)&&this._err(O.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var Pe;(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"})(Pe||(Pe={}));function Cr(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 Tu=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏઑඡ༉༦ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲϏϢϸontourIntegraìȹoɴ\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲy;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱còJTabcdfgorstרׯؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ߂ߐĀiyޱrc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣসে্ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४ĀnrࢃgleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpwਖਛgȀLRlr৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼અઋp;椅y;䐜Ādl੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑඞcy;䐊cute;䅃ƀaeyહાron;䅇dil;䅅;䐝ƀgswે૰ativeƀMTV૨ediumSpace;怋hiĀcn૦ëeryThiîtedĀGLଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷreak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater;EFGLSTஶஷ扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨setĀ;Eೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂෛ෧ขภยา฿ไlig;䅒cute耻Ó䃓Āiyීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲcr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬืde耻Õ䃕es;樷ml耻Ö䃖erĀBP๋Āar๐๓r;怾acĀek๚;揞et;掴arenthesis;揜ҀacfhilorsງຊຏຒດຝະrtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ檻cedesȀ;EST່້扺qual;檯lantEqual;扼ilde;找me;怳Ādpuct;戏ortionĀ;aȥl;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL憒ar;懥eftArrow;懄eiling;按oǵ\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄቕቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHcቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗ĀeiቻDzኀ\0ኇefore;戴a;䎘ĀcnኘkSpace;쀀 Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtèa;䎖r;愨pf;愤cr;쀀𝒵ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒;Eaeiopᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;eᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;eᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰᝃᝈ០៦ᠹᡐᜍ᥈ᥰot;櫭ĀcrᛶkȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀakoᠦᠵĀcn៲ᠣkƀlst֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ;敛;敘;攘;攔;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģbar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;elƀ;bhᥨᥩᥫ䁜;槅sub;柈ŬᥴlĀ;e怢t»pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭒\0᯽\0ᰌƀcprᦲute;䄇̀;abcdsᦿᧀᧄ᧕᧙戩nd;橄rcup;橉Āau᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r;Ecefms᩠ᩢᩫ᪤᪪旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ\0\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»eóɍǧ\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯delprvw᭠᭬᭷ᮂᮬᯔarrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;pᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰻᰿ᱝᱩᱵᲞᲬᲷᴍᵻᶑᶫᶻ᷆᷍ròar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂᳖᳜᳠mƀ;oș᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄĀDoḆᴴoôĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»ṺƀaeiἒἚls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧\0耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₥₰₴⃰℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽ƀ;qsؾٌlanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqrⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0proør;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼ròòΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonóquigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roøurĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨íistĀ;sடr;쀀𝔫ȀEest⩦⩹⩼ƀ;qs⩭ƀ;qs⩴lanôií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast⭕⭚⭟lleìl;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖchimpqu⮽⯍⯙⬄⯤⯯Ȁ;cerല⯆ഷ⯉uå;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭ååഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñĀ;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;cⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācrir;榿;쀀𝔬ͯ\0\0\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕⶥⶨrò᪀Āirⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔǒr;榷rp;榹;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ\0\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ脀¶;l䂶leìЃɩ\0\0m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳ᤈ⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t⾴ïrel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⋢⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔ABHabcdefhilmnoprstuxけさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstwガクシスゼゾダッデナp;極Ā;fゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ìâヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘rrowĀ;tㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowóarpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓ròaòՑ;怏oustĀ;a㈞掱che»mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì耻䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;qኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫwar;椪lig耻ß䃟㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rëƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproøim»ኬsðኞĀas㚺㚮ðrn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈadempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xôheadĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roðtré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜtré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),xu=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 yu(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=xu.get(e))!==null&&t!==void 0?t:e}var Qe;(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"})(Qe||(Qe={}));const Nu=32;var Lt;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Lt||(Lt={}));function Kn(e){return e>=Qe.ZERO&&e<=Qe.NINE}function ku(e){return e>=Qe.UPPER_A&&e<=Qe.UPPER_F||e>=Qe.LOWER_A&&e<=Qe.LOWER_F}function Cu(e){return e>=Qe.UPPER_A&&e<=Qe.UPPER_Z||e>=Qe.LOWER_A&&e<=Qe.LOWER_Z||Kn(e)}function vu(e){return e===Qe.EQUALS||Cu(e)}var Ve;(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"})(Ve||(Ve={}));var Nt;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Nt||(Nt={}));class _u{constructor(t,n,a){this.decodeTree=t,this.emitCodePoint=n,this.errors=a,this.state=Ve.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Nt.Strict}startEntity(t){this.decodeMode=t,this.state=Ve.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case Ve.EntityStart:return t.charCodeAt(n)===Qe.NUM?(this.state=Ve.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=Ve.NamedEntity,this.stateNamedEntity(t,n));case Ve.NumericStart:return this.stateNumericStart(t,n);case Ve.NumericDecimal:return this.stateNumericDecimal(t,n);case Ve.NumericHex:return this.stateNumericHex(t,n);case Ve.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|Nu)===Qe.LOWER_X?(this.state=Ve.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=Ve.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,a,o){if(n!==a){const i=a-n;this.result=this.result*Math.pow(o,i)+Number.parseInt(t.substr(n,i),o),this.consumed+=i}}stateNumericHex(t,n){const a=n;for(;n<t.length;){const o=t.charCodeAt(n);if(Kn(o)||ku(o))n+=1;else return this.addToNumericResult(t,a,n,16),this.emitNumericEntity(o,3)}return this.addToNumericResult(t,a,n,16),-1}stateNumericDecimal(t,n){const a=n;for(;n<t.length;){const o=t.charCodeAt(n);if(Kn(o))n+=1;else return this.addToNumericResult(t,a,n,10),this.emitNumericEntity(o,2)}return this.addToNumericResult(t,a,n,10),-1}emitNumericEntity(t,n){var a;if(this.consumed<=n)return(a=this.errors)===null||a===void 0||a.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===Qe.SEMI)this.consumed+=1;else if(this.decodeMode===Nt.Strict)return 0;return this.emitCodePoint(yu(this.result),this.consumed),this.errors&&(t!==Qe.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,n){const{decodeTree:a}=this;let o=a[this.treeIndex],i=(o&Lt.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const c=t.charCodeAt(n);if(this.treeIndex=Su(a,o,this.treeIndex+Math.max(1,i),c),this.treeIndex<0)return this.result===0||this.decodeMode===Nt.Attribute&&(i===0||vu(c))?0:this.emitNotTerminatedNamedEntity();if(o=a[this.treeIndex],i=(o&Lt.VALUE_LENGTH)>>14,i!==0){if(c===Qe.SEMI)return this.emitNamedEntityData(this.treeIndex,i,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:a}=this,o=(a[n]&Lt.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,o,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,a){const{decodeTree:o}=this;return this.emitCodePoint(n===1?o[t]&~Lt.VALUE_LENGTH:o[t+1],a),n===3&&this.emitCodePoint(o[t+2],a),a}end(){var t;switch(this.state){case Ve.NamedEntity:return this.result!==0&&(this.decodeMode!==Nt.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Ve.NumericDecimal:return this.emitNumericEntity(0,2);case Ve.NumericHex:return this.emitNumericEntity(0,3);case Ve.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Ve.EntityStart:return 0}}}function Su(e,t,n,a){const o=(t&Lt.BRANCH_LENGTH)>>7,i=t&Lt.JUMP_TABLE;if(o===0)return i!==0&&a===i?n:-1;if(i){const u=a-i;return u<0||u>=o?-1:e[n+u]-1}let c=n,d=c+o-1;for(;c<=d;){const u=c+d>>>1,f=e[u];if(f<a)c=u+1;else if(f>a)d=u-1;else return e[u+o]}return-1}var V;(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/"})(V||(V={}));var Ut;(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"})(Ut||(Ut={}));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 Au=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 is(e){var t;return(t=Au.get(e))!==null&&t!==void 0?t:r.UNKNOWN}const te=r,wu={[V.HTML]:new Set([te.ADDRESS,te.APPLET,te.AREA,te.ARTICLE,te.ASIDE,te.BASE,te.BASEFONT,te.BGSOUND,te.BLOCKQUOTE,te.BODY,te.BR,te.BUTTON,te.CAPTION,te.CENTER,te.COL,te.COLGROUP,te.DD,te.DETAILS,te.DIR,te.DIV,te.DL,te.DT,te.EMBED,te.FIELDSET,te.FIGCAPTION,te.FIGURE,te.FOOTER,te.FORM,te.FRAME,te.FRAMESET,te.H1,te.H2,te.H3,te.H4,te.H5,te.H6,te.HEAD,te.HEADER,te.HGROUP,te.HR,te.HTML,te.IFRAME,te.IMG,te.INPUT,te.LI,te.LINK,te.LISTING,te.MAIN,te.MARQUEE,te.MENU,te.META,te.NAV,te.NOEMBED,te.NOFRAMES,te.NOSCRIPT,te.OBJECT,te.OL,te.P,te.PARAM,te.PLAINTEXT,te.PRE,te.SCRIPT,te.SECTION,te.SELECT,te.SOURCE,te.STYLE,te.SUMMARY,te.TABLE,te.TBODY,te.TD,te.TEMPLATE,te.TEXTAREA,te.TFOOT,te.TH,te.THEAD,te.TITLE,te.TR,te.TRACK,te.UL,te.WBR,te.XMP]),[V.MATHML]:new Set([te.MI,te.MO,te.MN,te.MS,te.MTEXT,te.ANNOTATION_XML]),[V.SVG]:new Set([te.TITLE,te.FOREIGN_OBJECT,te.DESC]),[V.XLINK]:new Set,[V.XML]:new Set,[V.XMLNS]:new Set},Yn=new Set([te.H1,te.H2,te.H3,te.H4,te.H5,te.H6]);A.STYLE,A.SCRIPT,A.XMP,A.IFRAME,A.NOEMBED,A.NOFRAMES,A.PLAINTEXT;var h;(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"})(h||(h={}));const We={DATA:h.DATA,RCDATA:h.RCDATA,RAWTEXT:h.RAWTEXT,SCRIPT_DATA:h.SCRIPT_DATA,PLAINTEXT:h.PLAINTEXT,CDATA_SECTION:h.CDATA_SECTION};function Iu(e){return e>=p.DIGIT_0&&e<=p.DIGIT_9}function fs(e){return e>=p.LATIN_CAPITAL_A&&e<=p.LATIN_CAPITAL_Z}function ju(e){return e>=p.LATIN_SMALL_A&&e<=p.LATIN_SMALL_Z}function wt(e){return ju(e)||fs(e)}function ai(e){return wt(e)||Iu(e)}function Os(e){return e+32}function vr(e){return e===p.SPACE||e===p.LINE_FEED||e===p.TABULATION||e===p.FORM_FEED}function ii(e){return vr(e)||e===p.SOLIDUS||e===p.GREATER_THAN_SIGN}function Lu(e){return e===p.NULL?O.nullCharacterReference:e>1114111?O.characterReferenceOutsideUnicodeRange:yr(e)?O.surrogateCharacterReference:kr(e)?O.noncharacterCharacterReference:Nr(e)||e===p.CARRIAGE_RETURN?O.controlCharacterReference:null}class Ru{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=h.DATA,this.returnState=h.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new Eu(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new _u(Tu,(a,o)=>{this.preprocessor.pos=this.entityStartPos+o-1,this._flushCodePointConsumedAsCharacterReference(a)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(O.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:a=>{this._err(O.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+a)},validateNumericCharacterReference:a=>{const o=Lu(a);o&&this._err(o,1)}}:void 0)}_err(t,n=0){var a,o;(o=(a=this.handler).onParseError)===null||o===void 0||o.call(a,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,a){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||a?.()}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:Pe.START_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Pe.END_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:Pe.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:Pe.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 a=this.currentToken;if(Cr(a,this.currentAttr.name)===null){if(a.attrs.push(this.currentAttr),a.location&&this.currentLocation){const o=(t=(n=a.location).attrs)!==null&&t!==void 0?t:n.attrs=Object.create(null);o[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(O.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=is(t.tagName),t.type===Pe.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(O.endTagWithAttributes),t.selfClosing&&this._err(O.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 Pe.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case Pe.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case Pe.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:Pe.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=vr(t)?Pe.WHITESPACE_CHARACTER:t===p.NULL?Pe.NULL_CHARACTER:Pe.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(Pe.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=h.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Nt.Attribute:Nt.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===h.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===h.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===h.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case h.DATA:{this._stateData(t);break}case h.RCDATA:{this._stateRcdata(t);break}case h.RAWTEXT:{this._stateRawtext(t);break}case h.SCRIPT_DATA:{this._stateScriptData(t);break}case h.PLAINTEXT:{this._statePlaintext(t);break}case h.TAG_OPEN:{this._stateTagOpen(t);break}case h.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case h.TAG_NAME:{this._stateTagName(t);break}case h.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case h.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case h.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case h.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case h.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case h.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case h.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case h.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case h.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case h.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case h.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case h.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case h.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case h.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case h.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case h.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case h.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case h.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case h.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case h.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case h.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case h.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case h.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case h.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case h.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case h.BOGUS_COMMENT:{this._stateBogusComment(t);break}case h.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case h.COMMENT_START:{this._stateCommentStart(t);break}case h.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case h.COMMENT:{this._stateComment(t);break}case h.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case h.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case h.COMMENT_END:{this._stateCommentEnd(t);break}case h.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case h.DOCTYPE:{this._stateDoctype(t);break}case h.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case h.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case h.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case h.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case h.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case h.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case h.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case h.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case h.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case h.CDATA_SECTION:{this._stateCdataSection(t);break}case h.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case h.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case h.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case h.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case p.LESS_THAN_SIGN:{this.state=h.TAG_OPEN;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(O.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=h.RCDATA_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case p.LESS_THAN_SIGN:{this.state=h.RAWTEXT_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(wt(t))this._createStartTagToken(),this.state=h.TAG_NAME,this._stateTagName(t);else switch(t){case p.EXCLAMATION_MARK:{this.state=h.MARKUP_DECLARATION_OPEN;break}case p.SOLIDUS:{this.state=h.END_TAG_OPEN;break}case p.QUESTION_MARK:{this._err(O.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=h.BOGUS_COMMENT,this._stateBogusComment(t);break}case p.EOF:{this._err(O.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(O.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=h.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(wt(t))this._createEndTagToken(),this.state=h.TAG_NAME,this._stateTagName(t);else switch(t){case p.GREATER_THAN_SIGN:{this._err(O.missingEndTagName),this.state=h.DATA;break}case p.EOF:{this._err(O.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(O.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=h.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=h.BEFORE_ATTRIBUTE_NAME;break}case p.SOLIDUS:{this.state=h.SELF_CLOSING_START_TAG;break}case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentTagToken();break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.tagName+=Ue;break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(fs(t)?Os(t):t)}}_stateRcdataLessThanSign(t){t===p.SOLIDUS?this.state=h.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=h.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){wt(t)?(this.state=h.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=h.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=h.BEFORE_ATTRIBUTE_NAME,!1;case p.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=h.SELF_CLOSING_START_TAG,!1;case p.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=h.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===p.SOLIDUS?this.state=h.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){wt(t)?(this.state=h.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case p.SOLIDUS:{this.state=h.SCRIPT_DATA_END_TAG_OPEN;break}case p.EXCLAMATION_MARK:{this.state=h.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=h.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){wt(t)?(this.state=h.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===p.HYPHEN_MINUS?(this.state=h.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===p.HYPHEN_MINUS?(this.state=h.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_ESCAPED,this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case p.HYPHEN_MINUS:{this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.GREATER_THAN_SIGN:{this.state=h.SCRIPT_DATA,this._emitChars(">");break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_ESCAPED,this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===p.SOLIDUS?this.state=h.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:wt(t)?(this._emitChars("<"),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){wt(t)?(this.state=h.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(st.SCRIPT,!1)&&ii(this.preprocessor.peek(st.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<st.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.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=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.GREATER_THAN_SIGN:{this.state=h.SCRIPT_DATA,this._emitChars(">");break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===p.SOLIDUS?(this.state=h.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(st.SCRIPT,!1)&&ii(this.preprocessor.peek(st.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<st.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=h.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=h.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=h.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case p.EQUALS_SIGN:{this._err(O.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=h.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=h.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=h.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case p.EQUALS_SIGN:{this._leaveAttrName(),this.state=h.BEFORE_ATTRIBUTE_VALUE;break}case p.QUOTATION_MARK:case p.APOSTROPHE:case p.LESS_THAN_SIGN:{this._err(O.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.name+=Ue;break}default:this.currentAttr.name+=String.fromCodePoint(fs(t)?Os(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=h.SELF_CLOSING_START_TAG;break}case p.EQUALS_SIGN:{this.state=h.BEFORE_ATTRIBUTE_VALUE;break}case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=h.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=h.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this.state=h.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingAttributeValue),this.state=h.DATA,this.emitCurrentTagToken();break}default:this.state=h.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case p.QUOTATION_MARK:{this.state=h.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=Ue;break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case p.APOSTROPHE:{this.state=h.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=Ue;break}case p.EOF:{this._err(O.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=h.BEFORE_ATTRIBUTE_NAME;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=h.DATA,this.emitCurrentTagToken();break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=Ue;break}case p.QUOTATION_MARK:case p.APOSTROPHE:case p.LESS_THAN_SIGN:case p.EQUALS_SIGN:case p.GRAVE_ACCENT:{this._err(O.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case p.EOF:{this._err(O.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=h.BEFORE_ATTRIBUTE_NAME;break}case p.SOLIDUS:{this._leaveAttrValue(),this.state=h.SELF_CLOSING_START_TAG;break}case p.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=h.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._err(O.missingWhitespaceBetweenAttributes),this.state=h.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case p.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=h.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._err(O.unexpectedSolidusInTag),this.state=h.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentComment(n);break}case p.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.data+=Ue;break}default:n.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(st.DASH_DASH,!0)?(this._createCommentToken(st.DASH_DASH.length+1),this.state=h.COMMENT_START):this._consumeSequenceIfMatch(st.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(st.DOCTYPE.length+1),this.state=h.DOCTYPE):this._consumeSequenceIfMatch(st.CDATA_START,!0)?this.inForeignNode?this.state=h.CDATA_SECTION:(this._err(O.cdataInHtmlContent),this._createCommentToken(st.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=h.BOGUS_COMMENT):this._ensureHibernation()||(this._err(O.incorrectlyOpenedComment),this._createCommentToken(2),this.state=h.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.COMMENT_START_DASH;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptClosingOfEmptyComment),this.state=h.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=h.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=h.COMMENT_END;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptClosingOfEmptyComment),this.state=h.DATA,this.emitCurrentComment(n);break}case p.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=h.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=h.COMMENT_END_DASH;break}case p.LESS_THAN_SIGN:{n.data+="<",this.state=h.COMMENT_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.data+=Ue;break}case p.EOF:{this._err(O.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=h.COMMENT_LESS_THAN_SIGN_BANG;break}case p.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=h.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===p.HYPHEN_MINUS?this.state=h.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=h.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===p.HYPHEN_MINUS?this.state=h.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=h.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==p.GREATER_THAN_SIGN&&t!==p.EOF&&this._err(O.nestedComment),this.state=h.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=h.COMMENT_END;break}case p.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=h.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentComment(n);break}case p.EXCLAMATION_MARK:{this.state=h.COMMENT_END_BANG;break}case p.HYPHEN_MINUS:{n.data+="-";break}case p.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=h.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{n.data+="--!",this.state=h.COMMENT_END_DASH;break}case p.GREATER_THAN_SIGN:{this._err(O.incorrectlyClosedComment),this.state=h.DATA,this.emitCurrentComment(n);break}case p.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=h.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=h.BEFORE_DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this.state=h.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case p.EOF:{this._err(O.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingWhitespaceBeforeDoctypeName),this.state=h.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(fs(t))this._createDoctypeToken(String.fromCharCode(Os(t))),this.state=h.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(O.unexpectedNullCharacter),this._createDoctypeToken(Ue),this.state=h.DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.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=h.AFTER_DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.name+=Ue;break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(fs(t)?Os(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=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(st.PUBLIC,!1)?this.state=h.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(st.SYSTEM,!1)?this.state=h.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(O.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=h.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=h.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.QUOTATION_MARK:{this._err(O.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(O.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.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=h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case p.QUOTATION_MARK:{this.state=h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.publicId+=Ue;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.publicId+=Ue;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.QUOTATION_MARK:{this._err(O.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(O.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.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=h.DATA;break}case p.QUOTATION_MARK:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.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=h.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.QUOTATION_MARK:{this._err(O.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(O.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.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=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case p.QUOTATION_MARK:{this.state=h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.systemId+=Ue;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.systemId+=Ue;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.DATA;break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.NULL:{this._err(O.unexpectedNullCharacter);break}case p.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case p.RIGHT_SQUARE_BRACKET:{this.state=h.CDATA_SECTION_BRACKET;break}case p.EOF:{this._err(O.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===p.RIGHT_SQUARE_BRACKET?this.state=h.CDATA_SECTION_END:(this._emitChars("]"),this.state=h.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case p.GREATER_THAN_SIGN:{this.state=h.DATA;break}case p.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=h.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()&&ai(this.preprocessor.peek(1))?h.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){ai(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===p.SEMICOLON&&this._err(O.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const _r=new Set([r.DD,r.DT,r.LI,r.OPTGROUP,r.OPTION,r.P,r.RB,r.RP,r.RT,r.RTC]),ri=new Set([..._r,r.CAPTION,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]),tn=new Set([r.APPLET,r.CAPTION,r.HTML,r.MARQUEE,r.OBJECT,r.TABLE,r.TD,r.TEMPLATE,r.TH]),Pu=new Set([...tn,r.OL,r.UL]),Du=new Set([...tn,r.BUTTON]),oi=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]),Ou=new Set([r.TR,r.TEMPLATE,r.HTML]),Mu=new Set([r.TBODY,r.TFOOT,r.THEAD,r.TEMPLATE,r.HTML]),Bu=new Set([r.TABLE,r.TEMPLATE,r.HTML]),Fu=new Set([r.TD,r.TH]);class Hu{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,n,a){this.treeAdapter=n,this.handler=a,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)===V.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 a=this._indexOf(t);this.items[a]=n,a===this.stackTop&&(this.current=n)}insertAfter(t,n,a){const o=this._indexOf(t)+1;this.items.splice(o,0,n),this.tagIDs.splice(o,0,a),this.stackTop++,o===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,o===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])!==V.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 a=this._indexOfTagNames(t,n);this.shortenToLength(Math.max(a,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(Yn,V.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Fu,V.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,n){for(let a=this.stackTop;a>=0;a--)if(t.has(this.tagIDs[a])&&this.treeAdapter.getNamespaceURI(this.items[a])===n)return a;return-1}clearBackTo(t,n){const a=this._indexOfTagNames(t,n);this.shortenToLength(a+1)}clearBackToTableContext(){this.clearBackTo(Bu,V.HTML)}clearBackToTableBodyContext(){this.clearBackTo(Mu,V.HTML)}clearBackToTableRowContext(){this.clearBackTo(Ou,V.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 a=this.stackTop;a>=0;a--){const o=this.tagIDs[a];switch(this.treeAdapter.getNamespaceURI(this.items[a])){case V.HTML:{if(o===t)return!0;if(n.has(o))return!1;break}case V.SVG:{if(li.has(o))return!1;break}case V.MATHML:{if(oi.has(o))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,tn)}hasInListItemScope(t){return this.hasInDynamicScope(t,Pu)}hasInButtonScope(t){return this.hasInDynamicScope(t,Du)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case V.HTML:{if(Yn.has(n))return!0;if(tn.has(n))return!1;break}case V.SVG:{if(li.has(n))return!1;break}case V.MATHML:{if(oi.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===V.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])===V.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])===V.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&&_r.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&ri.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&ri.has(this.currentTagId);)this.pop()}}const _n=3;var Et;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Et||(Et={}));const ci={type:Et.Marker};class Uu{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const a=[],o=n.length,i=this.treeAdapter.getTagName(t),c=this.treeAdapter.getNamespaceURI(t);for(let d=0;d<this.entries.length;d++){const u=this.entries[d];if(u.type===Et.Marker)break;const{element:f}=u;if(this.treeAdapter.getTagName(f)===i&&this.treeAdapter.getNamespaceURI(f)===c){const b=this.treeAdapter.getAttrList(f);b.length===o&&a.push({idx:d,attrs:b})}}return a}_ensureNoahArkCondition(t){if(this.entries.length<_n)return;const n=this.treeAdapter.getAttrList(t),a=this._getNoahArkConditionCandidates(t,n);if(a.length<_n)return;const o=new Map(n.map(c=>[c.name,c.value]));let i=0;for(let c=0;c<a.length;c++){const d=a[c];d.attrs.every(u=>o.get(u.name)===u.value)&&(i+=1,i>=_n&&this.entries.splice(d.idx,1))}}insertMarker(){this.entries.unshift(ci)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:Et.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const a=this.entries.indexOf(this.bookmark);this.entries.splice(a,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(ci);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(a=>a.type===Et.Marker||this.treeAdapter.getTagName(a.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 It={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 a=e.childNodes.indexOf(n);e.childNodes.splice(a,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,a){const o=e.childNodes.find(i=>i.nodeName==="#documentType");if(o)o.name=t,o.publicId=n,o.systemId=a;else{const i={nodeName:"#documentType",name:t,publicId:n,systemId:a,parentNode:null};It.appendChild(e,i)}},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(It.isTextNode(n)){n.value+=t;return}}It.appendChild(e,It.createTextNode(t))},insertTextBefore(e,t,n){const a=e.childNodes[e.childNodes.indexOf(n)-1];a&&It.isTextNode(a)?a.value+=t:It.insertBefore(e,It.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(a=>a.name));for(let a=0;a<t.length;a++)n.has(t[a].name)||e.attrs.push(t[a])},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}}},Sr="html",qu="about:legacy-compat",$u="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",Ar=["+//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//"],Wu=[...Ar,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],Ku=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),wr=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],Yu=[...wr,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function ui(e,t){return t.some(n=>e.startsWith(n))}function Gu(e){return e.name===Sr&&e.publicId===null&&(e.systemId===null||e.systemId===qu)}function zu(e){if(e.name!==Sr)return ut.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===$u)return ut.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),Ku.has(n))return ut.QUIRKS;let a=t===null?Wu:Ar;if(ui(n,a))return ut.QUIRKS;if(a=t===null?wr:Yu,ui(n,a))return ut.LIMITED_QUIRKS}return ut.NO_QUIRKS}const di={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},Vu="definitionurl",Qu="definitionURL",Xu=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])),Ju=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:V.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:V.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:V.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:V.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:V.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:V.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:V.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:V.XML}],["xml:space",{prefix:"xml",name:"space",namespace:V.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:V.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:V.XMLNS}]]),Zu=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])),ed=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 td(e){const t=e.tagID;return t===r.FONT&&e.attrs.some(({name:a})=>a===Ut.COLOR||a===Ut.SIZE||a===Ut.FACE)||ed.has(t)}function Ir(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===Vu){e.attrs[t].name=Qu;break}}function jr(e){for(let t=0;t<e.attrs.length;t++){const n=Xu.get(e.attrs[t].name);n!=null&&(e.attrs[t].name=n)}}function ma(e){for(let t=0;t<e.attrs.length;t++){const n=Ju.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 sd(e){const t=Zu.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=is(e.tagName))}function nd(e,t){return t===V.MATHML&&(e===r.MI||e===r.MO||e===r.MN||e===r.MS||e===r.MTEXT)}function ad(e,t,n){if(t===V.MATHML&&e===r.ANNOTATION_XML){for(let a=0;a<n.length;a++)if(n[a].name===Ut.ENCODING){const o=n[a].value.toLowerCase();return o===di.TEXT_HTML||o===di.APPLICATION_XML}}return t===V.SVG&&(e===r.FOREIGN_OBJECT||e===r.DESC||e===r.TITLE)}function id(e,t,n,a){return(!a||a===V.HTML)&&ad(e,t,n)||(!a||a===V.MATHML)&&nd(e,t)}const rd="hidden",od=8,ld=3;var T;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(T||(T={}));const cd={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},Lr=new Set([r.TABLE,r.TBODY,r.TFOOT,r.THEAD,r.TR]),mi={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:It,onParseError:null};class pi{constructor(t,n,a=null,o=null){this.fragmentContext=a,this.scriptHandler=o,this.currentToken=null,this.stopped=!1,this.insertionMode=T.INITIAL,this.originalInsertionMode=T.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...mi,...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 Ru(this.options,this),this.activeFormattingElements=new Uu(this.treeAdapter),this.fragmentContextID=a?is(this.treeAdapter.getTagName(a)):r.UNKNOWN,this._setContextModes(a??this.document,this.fragmentContextID),this.openElements=new Hu(this.document,this.treeAdapter,this)}static parse(t,n){const a=new this(n);return a.tokenizer.write(t,!0),a.document}static getFragmentParser(t,n){const a={...mi,...n};t??(t=a.treeAdapter.createElement(A.TEMPLATE,V.HTML,[]));const o=a.treeAdapter.createElement("documentmock",V.HTML,[]),i=new this(a,o,t);return i.fragmentContextID===r.TEMPLATE&&i.tmplInsertionModeStack.unshift(T.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),n=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,n),n}_err(t,n,a){var o;if(!this.onParseError)return;const i=(o=t.location)!==null&&o!==void 0?o:cd,c={code:n,startLine:i.startLine,startCol:i.startCol,startOffset:i.startOffset,endLine:a?i.startLine:i.endLine,endCol:a?i.startCol:i.endCol,endOffset:a?i.startOffset:i.endOffset};this.onParseError(c)}onItemPush(t,n,a){var o,i;(i=(o=this.treeAdapter).onItemPush)===null||i===void 0||i.call(o,t),a&&this.openElements.stackTop>0&&this._setContextModes(t,n)}onItemPop(t,n){var a,o;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(o=(a=this.treeAdapter).onItemPop)===null||o===void 0||o.call(a,t,this.openElements.current),n){let i,c;this.openElements.stackTop===0&&this.fragmentContext?(i=this.fragmentContext,c=this.fragmentContextID):{current:i,currentTagId:c}=this.openElements,this._setContextModes(i,c)}}_setContextModes(t,n){const a=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===V.HTML;this.currentNotInHTML=!a,this.tokenizer.inForeignNode=!a&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,V.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=T.TEXT}switchToPlaintextParsing(){this.insertionMode=T.TEXT,this.originalInsertionMode=T.IN_BODY,this.tokenizer.state=We.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)!==V.HTML))switch(this.fragmentContextID){case r.TITLE:case r.TEXTAREA:{this.tokenizer.state=We.RCDATA;break}case r.STYLE:case r.XMP:case r.IFRAME:case r.NOEMBED:case r.NOFRAMES:case r.NOSCRIPT:{this.tokenizer.state=We.RAWTEXT;break}case r.SCRIPT:{this.tokenizer.state=We.SCRIPT_DATA;break}case r.PLAINTEXT:{this.tokenizer.state=We.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",a=t.publicId||"",o=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,a,o),t.location){const c=this.treeAdapter.getChildNodes(this.document).find(d=>this.treeAdapter.isDocumentTypeNode(d));c&&this.treeAdapter.setNodeSourceCodeLocation(c,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const a=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,a)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const a=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(a??this.document,t)}}_appendElement(t,n){const a=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(a,t.location)}_insertElement(t,n){const a=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(a,t.location),this.openElements.push(a,t.tagID)}_insertFakeElement(t,n){const a=this.treeAdapter.createElement(t,V.HTML,[]);this._attachElementToTree(a,null),this.openElements.push(a,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,V.HTML,t.attrs),a=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,a),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(A.HTML,V.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 a=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,a),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}_insertCharacters(t){let n,a;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:a}=this._findFosterParentingLocation(),a?this.treeAdapter.insertTextBefore(n,t.chars,a):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const o=this.treeAdapter.getChildNodes(n),i=a?o.lastIndexOf(a):o.length,c=o[i-1];if(this.treeAdapter.getNodeSourceCodeLocation(c)){const{endLine:u,endCol:f,endOffset:b}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(c,{endLine:u,endCol:f,endOffset:b})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(c,t.location)}_adoptNodes(t,n){for(let a=this.treeAdapter.getFirstChild(t);a;a=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(a),this.treeAdapter.appendChild(n,a)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const a=n.location,o=this.treeAdapter.getTagName(t),i=n.type===Pe.END_TAG&&o===n.tagName?{endTag:{...a},endLine:a.endLine,endCol:a.endCol,endOffset:a.endOffset}:{endLine:a.startLine,endCol:a.startCol,endOffset:a.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,i)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,a;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,a=this.fragmentContextID):{current:n,currentTagId:a}=this.openElements,t.tagID===r.SVG&&this.treeAdapter.getTagName(n)===A.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===V.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===r.MGLYPH||t.tagID===r.MALIGNMARK)&&a!==void 0&&!this._isIntegrationPoint(a,n,V.HTML)}_processToken(t){switch(t.type){case Pe.CHARACTER:{this.onCharacter(t);break}case Pe.NULL_CHARACTER:{this.onNullCharacter(t);break}case Pe.COMMENT:{this.onComment(t);break}case Pe.DOCTYPE:{this.onDoctype(t);break}case Pe.START_TAG:{this._processStartTag(t);break}case Pe.END_TAG:{this.onEndTag(t);break}case Pe.EOF:{this.onEof(t);break}case Pe.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,a){const o=this.treeAdapter.getNamespaceURI(n),i=this.treeAdapter.getAttrList(n);return id(t,o,i,a)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(o=>o.type===Et.Marker||this.openElements.contains(o.element)),a=n===-1?t-1:n-1;for(let o=a;o>=0;o--){const i=this.activeFormattingElements.entries[o];this._insertElement(i.token,this.treeAdapter.getNamespaceURI(i.element)),i.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=T.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(r.P),this.openElements.popUntilTagNamePopped(r.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case r.TR:{this.insertionMode=T.IN_ROW;return}case r.TBODY:case r.THEAD:case r.TFOOT:{this.insertionMode=T.IN_TABLE_BODY;return}case r.CAPTION:{this.insertionMode=T.IN_CAPTION;return}case r.COLGROUP:{this.insertionMode=T.IN_COLUMN_GROUP;return}case r.TABLE:{this.insertionMode=T.IN_TABLE;return}case r.BODY:{this.insertionMode=T.IN_BODY;return}case r.FRAMESET:{this.insertionMode=T.IN_FRAMESET;return}case r.SELECT:{this._resetInsertionModeForSelect(t);return}case r.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case r.HTML:{this.insertionMode=this.headElement?T.AFTER_HEAD:T.BEFORE_HEAD;return}case r.TD:case r.TH:{if(t>0){this.insertionMode=T.IN_CELL;return}break}case r.HEAD:{if(t>0){this.insertionMode=T.IN_HEAD;return}break}}this.insertionMode=T.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const a=this.openElements.tagIDs[n];if(a===r.TEMPLATE)break;if(a===r.TABLE){this.insertionMode=T.IN_SELECT_IN_TABLE;return}}this.insertionMode=T.IN_SELECT}_isElementCausesFosterParenting(t){return Lr.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)===V.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case r.TABLE:{const a=this.treeAdapter.getParentNode(n);return a?{parent:a,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 a=this.treeAdapter.getNamespaceURI(t);return wu[a].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Fm(this,t);return}switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{bs(this,t);break}case T.BEFORE_HEAD:{Es(this,t);break}case T.IN_HEAD:{Ts(this,t);break}case T.IN_HEAD_NO_SCRIPT:{xs(this,t);break}case T.AFTER_HEAD:{ys(this,t);break}case T.IN_BODY:case T.IN_CAPTION:case T.IN_CELL:case T.IN_TEMPLATE:{Pr(this,t);break}case T.TEXT:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Sn(this,t);break}case T.IN_TABLE_TEXT:{Hr(this,t);break}case T.IN_COLUMN_GROUP:{sn(this,t);break}case T.AFTER_BODY:{nn(this,t);break}case T.AFTER_AFTER_BODY:{qs(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Bm(this,t);return}switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{bs(this,t);break}case T.BEFORE_HEAD:{Es(this,t);break}case T.IN_HEAD:{Ts(this,t);break}case T.IN_HEAD_NO_SCRIPT:{xs(this,t);break}case T.AFTER_HEAD:{ys(this,t);break}case T.TEXT:{this._insertCharacters(t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Sn(this,t);break}case T.IN_COLUMN_GROUP:{sn(this,t);break}case T.AFTER_BODY:{nn(this,t);break}case T.AFTER_AFTER_BODY:{qs(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){Gn(this,t);return}switch(this.insertionMode){case T.INITIAL:case T.BEFORE_HTML:case T.BEFORE_HEAD:case T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:case T.IN_BODY:case T.IN_TABLE:case T.IN_CAPTION:case T.IN_COLUMN_GROUP:case T.IN_TABLE_BODY:case T.IN_ROW:case T.IN_CELL:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:case T.IN_TEMPLATE:case T.IN_FRAMESET:case T.AFTER_FRAMESET:{Gn(this,t);break}case T.IN_TABLE_TEXT:{ds(this,t);break}case T.AFTER_BODY:{gd(this,t);break}case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{bd(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case T.INITIAL:{Ed(this,t);break}case T.BEFORE_HEAD:case T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:{this._err(t,O.misplacedDoctype);break}case T.IN_TABLE_TEXT:{ds(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,O.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?Hm(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{Td(this,t);break}case T.BEFORE_HEAD:{yd(this,t);break}case T.IN_HEAD:{gt(this,t);break}case T.IN_HEAD_NO_SCRIPT:{Cd(this,t);break}case T.AFTER_HEAD:{_d(this,t);break}case T.IN_BODY:{Ze(this,t);break}case T.IN_TABLE:{ts(this,t);break}case T.IN_TABLE_TEXT:{ds(this,t);break}case T.IN_CAPTION:{Nm(this,t);break}case T.IN_COLUMN_GROUP:{fa(this,t);break}case T.IN_TABLE_BODY:{hn(this,t);break}case T.IN_ROW:{fn(this,t);break}case T.IN_CELL:{vm(this,t);break}case T.IN_SELECT:{$r(this,t);break}case T.IN_SELECT_IN_TABLE:{Sm(this,t);break}case T.IN_TEMPLATE:{wm(this,t);break}case T.AFTER_BODY:{jm(this,t);break}case T.IN_FRAMESET:{Lm(this,t);break}case T.AFTER_FRAMESET:{Pm(this,t);break}case T.AFTER_AFTER_BODY:{Om(this,t);break}case T.AFTER_AFTER_FRAMESET:{Mm(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?Um(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{xd(this,t);break}case T.BEFORE_HEAD:{Nd(this,t);break}case T.IN_HEAD:{kd(this,t);break}case T.IN_HEAD_NO_SCRIPT:{vd(this,t);break}case T.AFTER_HEAD:{Sd(this,t);break}case T.IN_BODY:{pn(this,t);break}case T.TEXT:{mm(this,t);break}case T.IN_TABLE:{Ss(this,t);break}case T.IN_TABLE_TEXT:{ds(this,t);break}case T.IN_CAPTION:{km(this,t);break}case T.IN_COLUMN_GROUP:{Cm(this,t);break}case T.IN_TABLE_BODY:{zn(this,t);break}case T.IN_ROW:{qr(this,t);break}case T.IN_CELL:{_m(this,t);break}case T.IN_SELECT:{Wr(this,t);break}case T.IN_SELECT_IN_TABLE:{Am(this,t);break}case T.IN_TEMPLATE:{Im(this,t);break}case T.AFTER_BODY:{Yr(this,t);break}case T.IN_FRAMESET:{Rm(this,t);break}case T.AFTER_FRAMESET:{Dm(this,t);break}case T.AFTER_AFTER_BODY:{qs(this,t);break}}}onEof(t){switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{bs(this,t);break}case T.BEFORE_HEAD:{Es(this,t);break}case T.IN_HEAD:{Ts(this,t);break}case T.IN_HEAD_NO_SCRIPT:{xs(this,t);break}case T.AFTER_HEAD:{ys(this,t);break}case T.IN_BODY:case T.IN_TABLE:case T.IN_CAPTION:case T.IN_COLUMN_GROUP:case T.IN_TABLE_BODY:case T.IN_ROW:case T.IN_CELL:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:{Br(this,t);break}case T.TEXT:{pm(this,t);break}case T.IN_TABLE_TEXT:{ds(this,t);break}case T.IN_TEMPLATE:{Kr(this,t);break}case T.AFTER_BODY:case T.IN_FRAMESET:case T.AFTER_FRAMESET:case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{ha(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 T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:case T.TEXT:case T.IN_COLUMN_GROUP:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:case T.IN_FRAMESET:case T.AFTER_FRAMESET:{this._insertCharacters(t);break}case T.IN_BODY:case T.IN_CAPTION:case T.IN_CELL:case T.IN_TEMPLATE:case T.AFTER_BODY:case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{Rr(this,t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Sn(this,t);break}case T.IN_TABLE_TEXT:{Fr(this,t);break}}}}function ud(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):Mr(e,t),n}function dd(e,t){let n=null,a=e.openElements.stackTop;for(;a>=0;a--){const o=e.openElements.items[a];if(o===t.element)break;e._isSpecialElement(o,e.openElements.tagIDs[a])&&(n=o)}return n||(e.openElements.shortenToLength(Math.max(a,0)),e.activeFormattingElements.removeEntry(t)),n}function md(e,t,n){let a=t,o=e.openElements.getCommonAncestor(t);for(let i=0,c=o;c!==n;i++,c=o){o=e.openElements.getCommonAncestor(c);const d=e.activeFormattingElements.getElementEntry(c),u=d&&i>=ld;!d||u?(u&&e.activeFormattingElements.removeEntry(d),e.openElements.remove(c)):(c=pd(e,d),a===t&&(e.activeFormattingElements.bookmark=d),e.treeAdapter.detachNode(a),e.treeAdapter.appendChild(c,a),a=c)}return a}function pd(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),a=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,a),t.element=a,a}function hd(e,t,n){const a=e.treeAdapter.getTagName(t),o=is(a);if(e._isElementCausesFosterParenting(o))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);o===r.TEMPLATE&&i===V.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function fd(e,t,n){const a=e.treeAdapter.getNamespaceURI(n.element),{token:o}=n,i=e.treeAdapter.createElement(o.tagName,a,o.attrs);e._adoptNodes(t,i),e.treeAdapter.appendChild(t,i),e.activeFormattingElements.insertElementAfterBookmark(i,o),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,i,o.tagID)}function pa(e,t){for(let n=0;n<od;n++){const a=ud(e,t);if(!a)break;const o=dd(e,a);if(!o)break;e.activeFormattingElements.bookmark=a;const i=md(e,o,a.element),c=e.openElements.getCommonAncestor(a.element);e.treeAdapter.detachNode(i),c&&hd(e,c,i),fd(e,o,a)}}function Gn(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function gd(e,t){e._appendCommentNode(t,e.openElements.items[0])}function bd(e,t){e._appendCommentNode(t,e.document)}function ha(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let a=e.openElements.stackTop;a>=n;a--)e._setEndLocation(e.openElements.items[a],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const a=e.openElements.items[0],o=e.treeAdapter.getNodeSourceCodeLocation(a);if(o&&!o.endTag&&(e._setEndLocation(a,t),e.openElements.stackTop>=1)){const i=e.openElements.items[1],c=e.treeAdapter.getNodeSourceCodeLocation(i);c&&!c.endTag&&e._setEndLocation(i,t)}}}}function Ed(e,t){e._setDocumentType(t);const n=t.forceQuirks?ut.QUIRKS:zu(t);Gu(t)||e._err(t,O.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=T.BEFORE_HTML}function us(e,t){e._err(t,O.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,ut.QUIRKS),e.insertionMode=T.BEFORE_HTML,e._processToken(t)}function Td(e,t){t.tagID===r.HTML?(e._insertElement(t,V.HTML),e.insertionMode=T.BEFORE_HEAD):bs(e,t)}function xd(e,t){const n=t.tagID;(n===r.HTML||n===r.HEAD||n===r.BODY||n===r.BR)&&bs(e,t)}function bs(e,t){e._insertFakeRootElement(),e.insertionMode=T.BEFORE_HEAD,e._processToken(t)}function yd(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.HEAD:{e._insertElement(t,V.HTML),e.headElement=e.openElements.current,e.insertionMode=T.IN_HEAD;break}default:Es(e,t)}}function Nd(e,t){const n=t.tagID;n===r.HEAD||n===r.BODY||n===r.HTML||n===r.BR?Es(e,t):e._err(t,O.endTagWithoutMatchingOpenElement)}function Es(e,t){e._insertFakeElement(A.HEAD,r.HEAD),e.headElement=e.openElements.current,e.insertionMode=T.IN_HEAD,e._processToken(t)}function gt(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:{e._appendElement(t,V.HTML),t.ackSelfClosing=!0;break}case r.TITLE:{e._switchToTextParsing(t,We.RCDATA);break}case r.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,We.RAWTEXT):(e._insertElement(t,V.HTML),e.insertionMode=T.IN_HEAD_NO_SCRIPT);break}case r.NOFRAMES:case r.STYLE:{e._switchToTextParsing(t,We.RAWTEXT);break}case r.SCRIPT:{e._switchToTextParsing(t,We.SCRIPT_DATA);break}case r.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=T.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(T.IN_TEMPLATE);break}case r.HEAD:{e._err(t,O.misplacedStartTagForHeadElement);break}default:Ts(e,t)}}function kd(e,t){switch(t.tagID){case r.HEAD:{e.openElements.pop(),e.insertionMode=T.AFTER_HEAD;break}case r.BODY:case r.BR:case r.HTML:{Ts(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function Wt(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==r.TEMPLATE&&e._err(t,O.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,O.endTagWithoutMatchingOpenElement)}function Ts(e,t){e.openElements.pop(),e.insertionMode=T.AFTER_HEAD,e._processToken(t)}function Cd(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BASEFONT:case r.BGSOUND:case r.HEAD:case r.LINK:case r.META:case r.NOFRAMES:case r.STYLE:{gt(e,t);break}case r.NOSCRIPT:{e._err(t,O.nestedNoscriptInHead);break}default:xs(e,t)}}function vd(e,t){switch(t.tagID){case r.NOSCRIPT:{e.openElements.pop(),e.insertionMode=T.IN_HEAD;break}case r.BR:{xs(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function xs(e,t){const n=t.type===Pe.EOF?O.openElementsLeftAfterEof:O.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=T.IN_HEAD,e._processToken(t)}function _d(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BODY:{e._insertElement(t,V.HTML),e.framesetOk=!1,e.insertionMode=T.IN_BODY;break}case r.FRAMESET:{e._insertElement(t,V.HTML),e.insertionMode=T.IN_FRAMESET;break}case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:case r.NOFRAMES:case r.SCRIPT:case r.STYLE:case r.TEMPLATE:case r.TITLE:{e._err(t,O.abandonedHeadElementChild),e.openElements.push(e.headElement,r.HEAD),gt(e,t),e.openElements.remove(e.headElement);break}case r.HEAD:{e._err(t,O.misplacedStartTagForHeadElement);break}default:ys(e,t)}}function Sd(e,t){switch(t.tagID){case r.BODY:case r.HTML:case r.BR:{ys(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function ys(e,t){e._insertFakeElement(A.BODY,r.BODY),e.insertionMode=T.IN_BODY,mn(e,t)}function mn(e,t){switch(t.type){case Pe.CHARACTER:{Pr(e,t);break}case Pe.WHITESPACE_CHARACTER:{Rr(e,t);break}case Pe.COMMENT:{Gn(e,t);break}case Pe.START_TAG:{Ze(e,t);break}case Pe.END_TAG:{pn(e,t);break}case Pe.EOF:{Br(e,t);break}}}function Rr(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Pr(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function Ad(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function wd(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function Id(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_FRAMESET)}function jd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML)}function Ld(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Yn.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,V.HTML)}function Rd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function Pd(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML),n||(e.formElement=e.openElements.current))}function Dd(e,t){e.framesetOk=!1;const n=t.tagID;for(let a=e.openElements.stackTop;a>=0;a--){const o=e.openElements.tagIDs[a];if(n===r.LI&&o===r.LI||(n===r.DD||n===r.DT)&&(o===r.DD||o===r.DT)){e.openElements.generateImpliedEndTagsWithExclusion(o),e.openElements.popUntilTagNamePopped(o);break}if(o!==r.ADDRESS&&o!==r.DIV&&o!==r.P&&e._isSpecialElement(e.openElements.items[a],o))break}e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML)}function Od(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML),e.tokenizer.state=We.PLAINTEXT}function Md(e,t){e.openElements.hasInScope(r.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.framesetOk=!1}function Bd(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(A.A);n&&(pa(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Fd(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Hd(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(r.NOBR)&&(pa(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,V.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Ud(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function qd(e,t){e.treeAdapter.getDocumentMode(e.document)!==ut.QUIRKS&&e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML),e.framesetOk=!1,e.insertionMode=T.IN_TABLE}function Dr(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,V.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Or(e){const t=Cr(e,Ut.TYPE);return t!=null&&t.toLowerCase()===rd}function $d(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,V.HTML),Or(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function Wd(e,t){e._appendElement(t,V.HTML),t.ackSelfClosing=!0}function Kd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._appendElement(t,V.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Yd(e,t){t.tagName=A.IMG,t.tagID=r.IMG,Dr(e,t)}function Gd(e,t){e._insertElement(t,V.HTML),e.skipNextNewLine=!0,e.tokenizer.state=We.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=T.TEXT}function zd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,We.RAWTEXT)}function Vd(e,t){e.framesetOk=!1,e._switchToTextParsing(t,We.RAWTEXT)}function hi(e,t){e._switchToTextParsing(t,We.RAWTEXT)}function Qd(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===T.IN_TABLE||e.insertionMode===T.IN_CAPTION||e.insertionMode===T.IN_TABLE_BODY||e.insertionMode===T.IN_ROW||e.insertionMode===T.IN_CELL?T.IN_SELECT_IN_TABLE:T.IN_SELECT}function Xd(e,t){e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML)}function Jd(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,V.HTML)}function Zd(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(r.RTC),e._insertElement(t,V.HTML)}function em(e,t){e._reconstructActiveFormattingElements(),Ir(t),ma(t),t.selfClosing?e._appendElement(t,V.MATHML):e._insertElement(t,V.MATHML),t.ackSelfClosing=!0}function tm(e,t){e._reconstructActiveFormattingElements(),jr(t),ma(t),t.selfClosing?e._appendElement(t,V.SVG):e._insertElement(t,V.SVG),t.ackSelfClosing=!0}function fi(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,V.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:{Fd(e,t);break}case r.A:{Bd(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Ld(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:{jd(e,t);break}case r.LI:case r.DD:case r.DT:{Dd(e,t);break}case r.BR:case r.IMG:case r.WBR:case r.AREA:case r.EMBED:case r.KEYGEN:{Dr(e,t);break}case r.HR:{Kd(e,t);break}case r.RB:case r.RTC:{Jd(e,t);break}case r.RT:case r.RP:{Zd(e,t);break}case r.PRE:case r.LISTING:{Rd(e,t);break}case r.XMP:{zd(e,t);break}case r.SVG:{tm(e,t);break}case r.HTML:{Ad(e,t);break}case r.BASE:case r.LINK:case r.META:case r.STYLE:case r.TITLE:case r.SCRIPT:case r.BGSOUND:case r.BASEFONT:case r.TEMPLATE:{gt(e,t);break}case r.BODY:{wd(e,t);break}case r.FORM:{Pd(e,t);break}case r.NOBR:{Hd(e,t);break}case r.MATH:{em(e,t);break}case r.TABLE:{qd(e,t);break}case r.INPUT:{$d(e,t);break}case r.PARAM:case r.TRACK:case r.SOURCE:{Wd(e,t);break}case r.IMAGE:{Yd(e,t);break}case r.BUTTON:{Md(e,t);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{Ud(e,t);break}case r.IFRAME:{Vd(e,t);break}case r.SELECT:{Qd(e,t);break}case r.OPTION:case r.OPTGROUP:{Xd(e,t);break}case r.NOEMBED:case r.NOFRAMES:{hi(e,t);break}case r.FRAMESET:{Id(e,t);break}case r.TEXTAREA:{Gd(e,t);break}case r.NOSCRIPT:{e.options.scriptingEnabled?hi(e,t):fi(e,t);break}case r.PLAINTEXT:{Od(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 sm(e,t){if(e.openElements.hasInScope(r.BODY)&&(e.insertionMode=T.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function nm(e,t){e.openElements.hasInScope(r.BODY)&&(e.insertionMode=T.AFTER_BODY,Yr(e,t))}function am(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function im(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 rm(e){e.openElements.hasInButtonScope(r.P)||e._insertFakeElement(A.P,r.P),e._closePElement()}function om(e){e.openElements.hasInListItemScope(r.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(r.LI),e.openElements.popUntilTagNamePopped(r.LI))}function lm(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function cm(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function um(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function dm(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(A.BR,r.BR),e.openElements.pop(),e.framesetOk=!1}function Mr(e,t){const n=t.tagName,a=t.tagID;for(let o=e.openElements.stackTop;o>0;o--){const i=e.openElements.items[o],c=e.openElements.tagIDs[o];if(a===c&&(a!==r.UNKNOWN||e.treeAdapter.getTagName(i)===n)){e.openElements.generateImpliedEndTagsWithExclusion(a),e.openElements.stackTop>=o&&e.openElements.shortenToLength(o);break}if(e._isSpecialElement(i,c))break}}function pn(e,t){switch(t.tagID){case r.A:case r.B:case r.I:case r.S:case r.U:case r.EM:case r.TT:case r.BIG:case r.CODE:case r.FONT:case r.NOBR:case r.SMALL:case r.STRIKE:case r.STRONG:{pa(e,t);break}case r.P:{rm(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:{am(e,t);break}case r.LI:{om(e);break}case r.DD:case r.DT:{lm(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{cm(e);break}case r.BR:{dm(e);break}case r.BODY:{sm(e,t);break}case r.HTML:{nm(e,t);break}case r.FORM:{im(e);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{um(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:Mr(e,t)}}function Br(e,t){e.tmplInsertionModeStack.length>0?Kr(e,t):ha(e,t)}function mm(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 pm(e,t){e._err(t,O.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Sn(e,t){if(e.openElements.currentTagId!==void 0&&Lr.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=T.IN_TABLE_TEXT,t.type){case Pe.CHARACTER:{Hr(e,t);break}case Pe.WHITESPACE_CHARACTER:{Fr(e,t);break}}else Is(e,t)}function hm(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_CAPTION}function fm(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_COLUMN_GROUP}function gm(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(A.COLGROUP,r.COLGROUP),e.insertionMode=T.IN_COLUMN_GROUP,fa(e,t)}function bm(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_TABLE_BODY}function Em(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(A.TBODY,r.TBODY),e.insertionMode=T.IN_TABLE_BODY,hn(e,t)}function Tm(e,t){e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function xm(e,t){Or(t)?e._appendElement(t,V.HTML):Is(e,t),t.ackSelfClosing=!0}function ym(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,V.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function ts(e,t){switch(t.tagID){case r.TD:case r.TH:case r.TR:{Em(e,t);break}case r.STYLE:case r.SCRIPT:case r.TEMPLATE:{gt(e,t);break}case r.COL:{gm(e,t);break}case r.FORM:{ym(e,t);break}case r.TABLE:{Tm(e,t);break}case r.TBODY:case r.TFOOT:case r.THEAD:{bm(e,t);break}case r.INPUT:{xm(e,t);break}case r.CAPTION:{hm(e,t);break}case r.COLGROUP:{fm(e,t);break}default:Is(e,t)}}function Ss(e,t){switch(t.tagID){case r.TABLE:{e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode());break}case r.TEMPLATE:{Wt(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:Is(e,t)}}function Is(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,mn(e,t),e.fosterParentingEnabled=n}function Fr(e,t){e.pendingCharacterTokens.push(t)}function Hr(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function ds(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)Is(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const Ur=new Set([r.CAPTION,r.COL,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]);function Nm(e,t){const n=t.tagID;Ur.has(n)?e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_TABLE,ts(e,t)):Ze(e,t)}function km(e,t){const n=t.tagID;switch(n){case r.CAPTION:case r.TABLE:{e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_TABLE,n===r.TABLE&&Ss(e,t));break}case r.BODY:case r.COL:case r.COLGROUP:case r.HTML:case r.TBODY:case r.TD:case r.TFOOT:case r.TH:case r.THEAD:case r.TR:break;default:pn(e,t)}}function fa(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.COL:{e._appendElement(t,V.HTML),t.ackSelfClosing=!0;break}case r.TEMPLATE:{gt(e,t);break}default:sn(e,t)}}function Cm(e,t){switch(t.tagID){case r.COLGROUP:{e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=T.IN_TABLE);break}case r.TEMPLATE:{Wt(e,t);break}case r.COL:break;default:sn(e,t)}}function sn(e,t){e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=T.IN_TABLE,e._processToken(t))}function hn(e,t){switch(t.tagID){case r.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_ROW;break}case r.TH:case r.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(A.TR,r.TR),e.insertionMode=T.IN_ROW,fn(e,t);break}case r.CAPTION:case r.COL:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE,ts(e,t));break}default:ts(e,t)}}function zn(e,t){const n=t.tagID;switch(t.tagID){case r.TBODY:case r.TFOOT:case r.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE);break}case r.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE,Ss(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:Ss(e,t)}}function fn(e,t){switch(t.tagID){case r.TH:case r.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_CELL,e.activeFormattingElements.insertMarker();break}case r.CAPTION:case r.COL:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,hn(e,t));break}default:ts(e,t)}}function qr(e,t){switch(t.tagID){case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY);break}case r.TABLE:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,zn(e,t));break}case r.TBODY:case r.TFOOT:case r.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(r.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,zn(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:Ss(e,t)}}function vm(e,t){const n=t.tagID;Ur.has(n)?(e.openElements.hasInTableScope(r.TD)||e.openElements.hasInTableScope(r.TH))&&(e._closeTableCell(),fn(e,t)):Ze(e,t)}function _m(e,t){const n=t.tagID;switch(n){case r.TD:case r.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_ROW);break}case r.TABLE:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),qr(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:break;default:pn(e,t)}}function $r(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,V.HTML);break}case r.OPTGROUP:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._insertElement(t,V.HTML);break}case r.HR:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._appendElement(t,V.HTML),t.ackSelfClosing=!0;break}case r.INPUT:case r.KEYGEN:case r.TEXTAREA:case r.SELECT:{e.openElements.hasInSelectScope(r.SELECT)&&(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),t.tagID!==r.SELECT&&e._processStartTag(t));break}case r.SCRIPT:case r.TEMPLATE:{gt(e,t);break}}}function Wr(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:{Wt(e,t);break}}}function Sm(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)):$r(e,t)}function Am(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)):Wr(e,t)}function wm(e,t){switch(t.tagID){case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:case r.NOFRAMES:case r.SCRIPT:case r.STYLE:case r.TEMPLATE:case r.TITLE:{gt(e,t);break}case r.CAPTION:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.tmplInsertionModeStack[0]=T.IN_TABLE,e.insertionMode=T.IN_TABLE,ts(e,t);break}case r.COL:{e.tmplInsertionModeStack[0]=T.IN_COLUMN_GROUP,e.insertionMode=T.IN_COLUMN_GROUP,fa(e,t);break}case r.TR:{e.tmplInsertionModeStack[0]=T.IN_TABLE_BODY,e.insertionMode=T.IN_TABLE_BODY,hn(e,t);break}case r.TD:case r.TH:{e.tmplInsertionModeStack[0]=T.IN_ROW,e.insertionMode=T.IN_ROW,fn(e,t);break}default:e.tmplInsertionModeStack[0]=T.IN_BODY,e.insertionMode=T.IN_BODY,Ze(e,t)}}function Im(e,t){t.tagID===r.TEMPLATE&&Wt(e,t)}function Kr(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):ha(e,t)}function jm(e,t){t.tagID===r.HTML?Ze(e,t):nn(e,t)}function Yr(e,t){var n;if(t.tagID===r.HTML){if(e.fragmentContext||(e.insertionMode=T.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===r.HTML){e._setEndLocation(e.openElements.items[0],t);const a=e.openElements.items[1];a&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(a))===null||n===void 0)&&n.endTag)&&e._setEndLocation(a,t)}}else nn(e,t)}function nn(e,t){e.insertionMode=T.IN_BODY,mn(e,t)}function Lm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.FRAMESET:{e._insertElement(t,V.HTML);break}case r.FRAME:{e._appendElement(t,V.HTML),t.ackSelfClosing=!0;break}case r.NOFRAMES:{gt(e,t);break}}}function Rm(e,t){t.tagID===r.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==r.FRAMESET&&(e.insertionMode=T.AFTER_FRAMESET))}function Pm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{gt(e,t);break}}}function Dm(e,t){t.tagID===r.HTML&&(e.insertionMode=T.AFTER_AFTER_FRAMESET)}function Om(e,t){t.tagID===r.HTML?Ze(e,t):qs(e,t)}function qs(e,t){e.insertionMode=T.IN_BODY,mn(e,t)}function Mm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{gt(e,t);break}}}function Bm(e,t){t.chars=Ue,e._insertCharacters(t)}function Fm(e,t){e._insertCharacters(t),e.framesetOk=!1}function Gr(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==V.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function Hm(e,t){if(td(t))Gr(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),a=e.treeAdapter.getNamespaceURI(n);a===V.MATHML?Ir(t):a===V.SVG&&(sd(t),jr(t)),ma(t),t.selfClosing?e._appendElement(t,a):e._insertElement(t,a),t.ackSelfClosing=!0}}function Um(e,t){if(t.tagID===r.P||t.tagID===r.BR){Gr(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const a=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(a)===V.HTML){e._endTagOutsideForeignContent(t);break}const o=e.treeAdapter.getTagName(a);if(o.toLowerCase()===t.tagName){t.tagName=o,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 qm=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,$m=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),gi={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function zr(e,t){const n=Zm(e),a=$i("type",{handlers:{root:Wm,element:Km,text:Ym,comment:Qr,doctype:Gm,raw:Vm},unknown:Qm}),o={parser:n?new pi(gi):pi.getFragmentParser(void 0,gi),handle(d){a(d,o)},stitches:!1,options:t||{}};a(e,o),rs(o,qt());const i=n?o.parser.document:o.parser.getFragment(),c=eu(i,{file:o.options.file});return o.stitches&&Jo(c,"comment",function(d,u,f){const b=d;if(b.value.stitch&&f&&u!==void 0){const E=f.children;return E[u]=b.value.stitch,u}}),c.type==="root"&&c.children.length===1&&c.children[0].type===e.type?c.children[0]:c}function Vr(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function Wm(e,t){Vr(e.children,t)}function Km(e,t){Xm(e,t),Vr(e.children,t),Jm(e,t)}function Ym(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:Pe.CHARACTER,chars:e.value,location:js(e)};rs(t,qt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function Gm(e,t){const n={type:Pe.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:js(e)};rs(t,qt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function zm(e,t){t.stitches=!0;const n=ep(e);if("children"in e&&"children"in n){const a=zr({type:"root",children:e.children},t.options);n.children=a.children}Qr({type:"comment",value:{stitch:n}},t)}function Qr(e,t){const n=e.value,a={type:Pe.COMMENT,data:n,location:js(e)};rs(t,qt(e)),t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken)}function Vm(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,Xr(t,qt(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(qm,"<$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 Qm(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))zm(n,t);else{let a="";throw $m.has(n.type)&&(a=". 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"+a)}}function rs(e,t){Xr(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=We.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 Xr(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 Xm(e,t){const n=e.tagName.toLowerCase();if(t.parser.tokenizer.state===We.PLAINTEXT)return;rs(t,qt(e));const a=t.parser.openElements.current;let o="namespaceURI"in a?a.namespaceURI:Bt.html;o===Bt.html&&n==="svg"&&(o=Bt.svg);const i=iu({...e,children:[]},{space:o===Bt.svg?"svg":"html"}),c={type:Pe.START_TAG,tagName:n,tagID:is(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in i?i.attrs:[],location:js(e)};t.parser.currentToken=c,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function Jm(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&pu.includes(n)||t.parser.tokenizer.state===We.PLAINTEXT)return;rs(t,Wi(e));const a={type:Pe.END_TAG,tagName:n,tagID:is(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:js(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===We.RCDATA||t.parser.tokenizer.state===We.RAWTEXT||t.parser.tokenizer.state===We.SCRIPT_DATA)&&(t.parser.tokenizer.state=We.DATA)}function Zm(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function js(e){const t=qt(e)||{line:void 0,column:void 0,offset:void 0},n=Wi(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 ep(e){return"children"in e?_a({...e,children:[]}):_a(e)}function tp(e){return function(t,n){return zr(t,{...e,file:n})}}const an=l.memo(function({text:t}){const n=Le(),[a,o]=l.useState(!1);return t?s.jsx("button",{type:"button",className:"copy-btn",title:n("copy"),onClick:()=>{navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1200)})},children:a?s.jsx(Tt,{}):s.jsx(vt,{})}):null});function sp(e){const t=a=>{if(typeof a=="string"||typeof a=="number"){const o=String(a);return o===""?[[]]:o.split(`
|
|
309
|
-
`).map(i=>i===""?[]:[i])}if(Array.isArray(a)){let o=[];for(const i of a){const c=t(i);if(o.length===0)o=c;else{const d=c[0]??[];o[o.length-1].push(...d),o.push(...c.slice(1))}}return o}if(a&&typeof a=="object"&&"props"in a){const o=a,i=o.props?.children,c={...o.props,children:void 0},d=i==null?[]:t(i);return d.length===0?[[l.createElement(o.type,c)]]:d.map(u=>[l.createElement(o.type,c,...u)])}return[[a]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function Vn(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Vn).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return Vn(t?.children)}return""}function
|
|
310
|
-
`),n=[];let a=[],o=null;for(let i=0;i<t.length;i++){const c=t[i];if(o!==null){const u=
|
|
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",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"},Jl=[{code:"zh",nativeName:"中文"},{code:"en",nativeName:"English"}],gs={};function Zl(e){return!e||typeof e.code!="string"||!e.code||e.code==="zh"||e.code==="en"||!e.strings||typeof e.strings!="object"?!1:(gs[e.code]=e,!0)}function ec(e){delete gs[e]}function tc(e){return e==="zh"?"中文":e.toUpperCase()}function sc(e){return e==="zh"?"zh-CN":e==="pt"?"pt-BR":e}async function Ma(e){const t=await fetch(Dt(at(e)));if(!t.ok)throw new Error(`HTTP ${t.status} for ${e}`);return await t.json()}const dr=l.createContext(null);function mr(){try{return localStorage.getItem(Hn)}catch{return null}}function nc(){return Fn(mr(),typeof navigator<"u"?navigator.languages:[],null)}function ac({children:e}){const[t,n]=l.useState(nc),[a,o]=l.useState(0),i=l.useRef(t);i.current=t;const c=l.useCallback(g=>{n(g);try{localStorage.setItem(Hn,g)}catch{}try{window.dispatchEvent(new CustomEvent("pi-web-ui:locale",{detail:g}))}catch{}},[]),d=l.useCallback(async()=>{let g,y=null;try{const N=await Ma("/api/locales");g=N.packs??[],y=N.defaultLocale??null}catch{return null}return await Promise.all(g.filter(N=>N.installed).map(async N=>{try{const S=await Ma(`/api/locales/${N.code}`);Zl({code:S.code||N.code,nativeName:S.nativeName||N.nativeName,strings:S.strings})}catch{}})),o(N=>N+1),y},[]);l.useEffect(()=>{d().then(g=>{if(!mr()?.trim()){const N=Fn(null,typeof navigator<"u"?navigator.languages:[],g);N!==i.current&&(i.current=N,n(N))}const y=i.current;if(y!=="zh"&&y!=="en"&&!gs[y]){const N=Fn(null,typeof navigator<"u"?navigator.languages:[],g,["zh","en"]);i.current=N,n(N);try{localStorage.setItem(Hn,N)}catch{}}})},[d]);const u=l.useMemo(()=>[...Jl,...Object.values(gs).map(g=>({code:g.code,nativeName:g.nativeName}))],[a]),f=l.useCallback((g,y)=>{let N=gs[t]?.strings[g]??(t==="zh"?Ql[g]:Xl[g]);if(y)for(const[S,M]of Object.entries(y))N=N.replaceAll(`{${S}}`,String(M));return N},[t,a]);l.useEffect(()=>{document.documentElement.lang=sc(t)},[t]);const E=l.useMemo(()=>({locale:t,setLocale:c,t:f,packs:u,reloadPacks:d}),[t,c,f,u,d]);return s.jsx(dr.Provider,{value:E,children:e})}function Mt(){const e=l.useContext(dr);if(!e)throw new Error("useI18n must be used within LanguageProvider");return e}function Le(){return Mt().t}const ic=[{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 Ba({settings:e,onChange:t,onPreview:n}){const a=Le(),o=i=>t({...e,...i});return s.jsxs("div",{className:"sound-menu",children:[s.jsx("div",{className:"dd-header",children:a("soundHeader")}),s.jsxs("label",{className:"sound-row sound-master",children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(Zi,{className:"sound-icon"}),s.jsx("span",{children:a("enableSound")})]}),s.jsx("input",{type:"checkbox",checked:e.enabled,onChange:i=>o({enabled:i.target.checked})})]}),ic.map(({kind:i,labelKey:c,descKey:d})=>s.jsxs("label",{className:`sound-row ${e.enabled?"":"disabled"}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx("span",{className:"sound-name",children:a(c)}),s.jsx("span",{className:"sound-desc",children:a(d)})]}),s.jsxs("span",{className:"sound-right",children:[s.jsx("button",{type:"button",className:"sound-preview",title:a("preview"),disabled:!e.enabled,onClick:u=>{u.preventDefault(),n(i)},children:a("preview")}),s.jsx("input",{type:"checkbox",checked:e[i],disabled:!e.enabled,onChange:u=>o({[i]:u.target.checked})})]})]},i)),s.jsxs("div",{className:`sound-volume ${e.enabled?"":"disabled"}`,children:[s.jsx("span",{className:"sound-name",children:a("volume")}),s.jsx("input",{type:"range",min:0,max:100,step:5,value:e.volume,disabled:!e.enabled,onChange:i=>o({volume:Number(i.target.value)})}),s.jsxs("span",{className:"sound-vol-num",children:[e.volume,"%"]})]})]})}const pr="pi-web-notify",yn={enabled:!1};function hr(){try{const e=localStorage.getItem(pr);if(!e)return{...yn};const t=JSON.parse(e);return{enabled:typeof t.enabled=="boolean"?t.enabled:yn.enabled}}catch{return{...yn}}}function Fa(e){try{localStorage.setItem(pr,JSON.stringify(e))}catch{}}function Is(){return typeof window<"u"&&"Notification"in window}function rc(){return Is()?null:typeof window<"u"&&window.isSecureContext===!1?"insecure":"unsupported"}const oc=12e4;function lc(e){const{screenX:t,screenY:n,outerWidth:a,outerHeight:o}=e;return Number.isFinite(t)&&Ha(t)||Number.isFinite(n)&&Ha(n)?!0:a>0&&a<=400&&o>0&&o<=40}function Ha(e){return e<=-1e4}function cc(e){return!(e.visibility!=="visible"||e.minimized||!e.hasFocus||e.windows&&e.idleMs>oc)}let fr=Date.now(),Ua=!1;function qa(){fr=Date.now()}function uc(){return Math.max(0,Date.now()-fr)}function dc(){if(Ua||typeof window>"u")return;Ua=!0;const e={passive:!0,capture:!0};for(const t of["pointerdown","pointermove","keydown","wheel","touchstart","focus","scroll"])window.addEventListener(t,qa,e);typeof document<"u"&&document.addEventListener("visibilitychange",qa,e)}function gr(){return typeof navigator>"u"?!1:/windows/i.test(navigator.userAgent??"")}function mc(){return dc(),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:lc({screenX:window.screenX,screenY:window.screenY,outerWidth:window.outerWidth,outerHeight:window.outerHeight}),idleMs:uc(),windows:gr()}}function $a(){return Is()?Notification.permission:"denied"}async function pc(){if(!Is())return"denied";try{return await Notification.requestPermission()}catch{return"denied"}}function Wa(e){return e instanceof Error?`${e.name}: ${e.message}`:String(e)}function hc(e,t=!1){return{body:e,requireInteraction:t,icon:at("/icons/icon-192.png"),badge:at("/icons/icon-192.png"),data:{url:typeof location<"u"?location.href:at("/")}}}async function fc(e,t,n=!1){if(!Is())return{path:"none",error:"unsupported"};if(Notification.permission!=="granted")return{path:"none",error:`permission: ${Notification.permission}`};const a=hc(t,n);let o;try{const i=await navigator.serviceWorker?.getRegistration();if(i?.active&&typeof i.showNotification=="function")return await i.showNotification(e,a),{path:"sw"};o=i?"service worker not active":"no service worker registration"}catch(i){o=Wa(i)}try{return new Notification(e,a),{path:"page",error:o}}catch(i){return{path:"none",error:`${o}; page: ${Wa(i)}`}}}async function Os(e,t){Is()&&(cc(mc())||hr().enabled&&await fc(e,t))}const gc=!1;function Ka(){const e=Le(),[t,n]=l.useState(hr),[a,o]=l.useState(()=>$a()),[i,c]=l.useState(null),d=rc(),u=d!==null,f=gr();l.useEffect(()=>{const g=()=>o($a());return window.addEventListener("focus",g),document.addEventListener("visibilitychange",g),()=>{window.removeEventListener("focus",g),document.removeEventListener("visibilitychange",g)}},[]);const E=async g=>{const y={...t,enabled:g};if(n(y),Fa(y),g){const N=await pc();if(o(N),N!=="granted"){const S={...y,enabled:!1};n(S),Fa(S)}}};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${u?" disabled":""}`,children:[s.jsxs("span",{className:"sound-label",children:[s.jsx(Ul,{className:"sound-icon"}),s.jsx("span",{children:e("notifyEnable")})]}),s.jsx("input",{type:"checkbox",checked:t.enabled&&!u,disabled:u,onChange:g=>E(g.target.checked)})]}),s.jsx("div",{className:"sound-hint",children:e("notifyEnableDesc")}),d==="insecure"&&s.jsx("div",{className:"sound-hint",children:e("notifyInsecure")}),d==="unsupported"&&s.jsx("div",{className:"sound-hint",children:e("notifyUnsupported")}),!u&&a==="denied"&&s.jsx("div",{className:"sound-hint",children:e("notifyDenied")}),!u&&f&&s.jsx("div",{className:"sound-hint",children:e("notifyWindowsHint")}),gc]})}function bc({onClose:e}){const t=Le(),{locale:n,setLocale:a,reloadPacks:o}=Mt(),[i,c]=l.useState(null),[d,u]=l.useState(""),[f,E]=l.useState("");async function g(){try{const S=await fetch(Dt(at("/api/locales")));if(!S.ok)throw new Error(`HTTP ${S.status}`);const M=await S.json();c(M.packs??[]),u("")}catch(S){u(t("localeListFailed",{error:S instanceof Error?S.message:String(S)}))}}l.useEffect(()=>{g()},[]);async function y(S){E(S),u("");try{const M=await fetch(Dt(at(`/api/locales/${S}/install`)),{method:"POST"});if(!M.ok){let z=`HTTP ${M.status}`;try{z=(await M.json()).error??z}catch{}throw new Error(z)}await o(),await g()}catch(M){u(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{E("")}}async function N(S){E(S),u("");try{const M=await fetch(Dt(at(`/api/locales/${S}`)),{method:"DELETE"});if(!M.ok)throw new Error(`HTTP ${M.status}`);ec(S),n===S&&a("zh"),await o(),await g()}catch(M){u(t("localeInstallFailed",{error:M instanceof Error?M.message:String(M)}))}finally{E("")}}return s.jsx("div",{className:"modal-backdrop",onClick:e,children:s.jsxs("div",{className:"bg-task-modal",onClick:S=>S.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(sr,{})," ",t("localePacks")]}),s.jsx("button",{type:"button",className:"btn",title:t("close"),onClick:e,children:s.jsx($e,{})})]}),d&&s.jsx("div",{className:"bg-task-empty",children:d}),i===null&&!d?s.jsx("div",{className:"bg-task-empty",children:t("loading")}):s.jsx("ul",{className:"bg-task-list",children:(i??[]).map(S=>{const M=f===S.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:S.nativeName}),S.installed&&S.version&&s.jsxs("span",{className:"bg-task-name",children:["v",S.version]})]}),s.jsxs("div",{className:"bg-task-line2",children:[s.jsx("span",{children:S.code}),S.installed?s.jsxs("span",{children:[t("localeInstalled")," · ",t("localeRemoveHint")]}):s.jsx("span",{children:t("localeGetMore")})]})]}),S.installed?s.jsxs("button",{type:"button",className:"btn bg-task-stop",disabled:M,title:t("localeRemove"),onClick:()=>void N(S.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 y(S.code),children:[s.jsx(Ht,{}),s.jsx("span",{children:t(M?"localeDownloading":"localeInstall")})]})]},S.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 Ec({chat:e,send:t,terminal:n,view:a,plugins:o,onViewChange:i,onOpenPanel:c,onOpenSettings:d,onOpenBgTasks:u,onOpenGlobalSearch:f,sound:E,onSoundChange:g,onSoundPreview:y,themes:N,theme:S,onThemeChange:M}){const{locale:z,setLocale:$,t:C,packs:P}=Mt(),[B,H]=l.useState(!1),[Q,re]=l.useState(!1),[K,j]=l.useState(!1),[X,k]=l.useState(!1),[Z,Y]=l.useState(!1),[me,de]=l.useState(!1),w=e.ready?C("connected"):e.status==="closed"?C("reconnecting"):C("connecting"),I=e.ready?"ok":"busy",L=()=>{if(!e.ready)return;const _=C("updateTabTitle"),he={name:_,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},F=e.terminals.find(pe=>pe.title===_);F?(n.restart(F.id),t({type:"run_command",terminalId:F.id,conversationId:F.conversationId,command:he,cols:80,rows:24})):n.create({id:_t(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:_,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:he}),k(!1),Y(!1),i("terminal")},oe=(_,he)=>{if(!e.ready||_.length===0)return;const F={name:he,command:Wl(_),cwd:"${pwd}"},pe=e.terminals.find(Ee=>Ee.title===he);pe?(n.restart(pe.id),t({type:"run_command",terminalId:pe.id,conversationId:pe.conversationId,command:F,cols:80,rows:24})):n.create({id:_t(),conversationId:e.activeConversationId||e.state?.conversationId||"",title:he,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:F}),k(!1),Y(!1),i("terminal")},se=_=>!e.tabs||_==="chat"||e.tabs.includes(_),ye=e.updatesAll??[],v=ye.filter(_=>!_.upToDate&&!_.error).length,ee=ye.filter(_=>!_.upToDate&&!_.error&&_.kind!=="webui"),ce=()=>s.jsxs("div",{className:"dd-updates-all",children:[s.jsx("div",{className:"dd-header",children:C("updatesAllTitle")}),e.updatesAll===null?s.jsx("div",{className:"dd-note",children:C("checkingUpdate")}):ye.length===0?s.jsx("div",{className:"dd-note",children:C("updatesAllUpToDate")}):s.jsx("ul",{className:"dd-all-list",children:ye.map(_=>s.jsxs("li",{className:`dd-all-item${_.error?" err":_.upToDate?"":" warn"}`,children:[s.jsx("span",{className:"dd-all-name",title:_.name,children:_.name}),s.jsx("span",{className:"dd-all-kind",children:_.kind==="webui"?C("kindWebUi"):_.kind==="pi-core"?C("kindPiCore"):C("kindPackage")}),s.jsx("span",{className:"dd-all-vers",children:_.error?C("updateCheckFailed"):_.upToDate?`v${_.current}`:s.jsxs(s.Fragment,{children:["v",_.current," → v",_.latest]})}),_.kind!=="webui"&&!_.upToDate&&!_.error&&s.jsx("button",{type:"button",className:"dd-update-btn",onClick:()=>oe([_],C("updatePkgTabTitle",{name:_.name})),children:C("updateBtn")})]},`${_.kind}:${_.name}`))}),s.jsxs("div",{className:"dd-actions",children:[ee.length>0&&s.jsx("button",{type:"button",className:"dd-refresh accent",style:{flex:1},onClick:()=>oe(ee,C("updateAllTabTitle")),children:C("updateAllBtn")}),s.jsx("button",{type:"button",className:"dd-refresh",style:ee.length>0?{flex:1}:void 0,onClick:()=>t({type:"check_updates_all",force:!0}),children:C("updatesAllRefresh")})]})]}),ae=()=>s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"dd-update",children:[s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:C("currentVersion")}),s.jsxs("b",{children:["v",e.update?.current??"…"]})]}),s.jsxs("div",{className:"dd-row",children:[s.jsx("span",{children:C("latestVersion")}),s.jsx("b",{children:e.update===null?C("checkingUpdate"):e.update.error?e.update.error:e.update.latest?`v${e.update.latest}`:C("checkingUpdate")})]}),e.update&&e.update.upToDate&&s.jsx("div",{className:"dd-note ok",children:C("upToDate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note warn",children:C("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:C("updateJustPublished",{version:e.update.latest??""})}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("div",{className:"dd-note",children:C("updateTerminalHint")})]}),s.jsxs("div",{className:"dd-actions",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>t({type:"check_update"}),children:e.update===null?C("checkingUpdate"):C("checkUpdate")}),e.update&&!e.update.upToDate&&e.update.latest&&s.jsx("button",{type:"button",className:"dd-refresh accent",onClick:L,children:C("updateNow")})]})]});return s.jsxs("header",{className:"topbar",children:[s.jsxs("div",{className:"brand",children:[s.jsx("button",{type:"button",className:"panel-toggle",title:C("openHistory"),onClick:()=>c("left"),children:s.jsx(wl,{})}),s.jsx("span",{className:"brand-logo",children:"π"}),s.jsx("span",{className:"brand-name",children:"pi-web-ui"}),s.jsx("span",{className:`conn-dot ${I}`,title:w}),s.jsx("span",{className:"conn-label",children:w})]}),s.jsxs("div",{className:"topbar-actions",children:[s.jsxs("div",{className:"view-switch",role:"tablist","aria-label":C("viewSwitch"),children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="chat",className:a==="chat"?"active":"",onClick:()=>i("chat"),children:[s.jsx(es,{}),s.jsx("span",{children:C("chat")})]}),se("terminal")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="terminal",className:a==="terminal"?"active":"",onClick:()=>i("terminal"),children:[s.jsx(Zt,{}),s.jsx("span",{children:C("terminal")})]}),se("git")&&s.jsxs("button",{type:"button",role:"tab","aria-selected":a==="git",className:a==="git"?"active":"",onClick:()=>i("git"),children:[s.jsx(Us,{}),s.jsx("span",{children:C("scmTab")})]}),(se("plugins")?o:[]).filter(_=>_.view!==!1).map(_=>{const he=_.error?`${_.name}: ${_.error}`:_.description?`${_.name} — ${_.description}`:_.name;return s.jsxs("button",{type:"button",role:"tab","aria-selected":a===`plugin:${_.id}`,className:`plugin-tab${a===`plugin:${_.id}`?" active":""}${_.error?" broken":""}`,title:he,onClick:()=>i(`plugin:${_.id}`),children:[_.icon?s.jsx("span",{"aria-hidden":!0,children:_.icon}):null,s.jsx("span",{children:_.name})]},_.id)})]}),s.jsxs("div",{className:"topbar-desktop",children:[se("search")&&s.jsxs("button",{type:"button",className:"chip",title:C("searchGlobalTip"),onClick:f,children:[s.jsx(Js,{}),s.jsx("span",{className:"chip-sub",children:C("searchGlobal")})]}),se("tasks")&&s.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":C("bgTasksTip"),onClick:u,children:[s.jsx(Zs,{}),s.jsx("span",{className:"chip-sub",children:C("bgTasks")}),e.bgServers.length>0&&s.jsx("span",{className:"bg-task-badge",children:e.bgServers.length})]}),se("settings")&&s.jsxs("button",{type:"button",className:"chip",title:C("settingsTitle"),onClick:d,children:[s.jsx(Qs,{}),s.jsx("span",{className:"chip-sub",children:C("settings")})]}),s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Zi,{}),s.jsx("span",{className:"chip-sub",children:C("sound")})]}),open:B,onOpenChange:H,children:[s.jsx(Ba,{settings:E,onChange:g,onPreview:y}),s.jsx(Ka,{})]}),s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(sr,{}),s.jsx("span",{className:"chip-sub",children:tc(z)})]}),open:Q,onOpenChange:re,children:[s.jsx("div",{className:"dd-header",children:C("language")}),P.map(_=>s.jsx(nt,{active:z===_.code,onClick:()=>{$(_.code),re(!1)},children:_.nativeName},_.code)),s.jsxs(nt,{onClick:()=>{re(!1),de(!0)},children:[s.jsx(Ht,{})," ",C("localeGetMore")]})]}),s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Nl,{}),s.jsx("span",{className:"chip-sub",children:C("theme")})]}),open:K,onOpenChange:j,children:[s.jsx("div",{className:"dd-header",children:C("theme")}),s.jsx(nt,{active:S===null,onClick:()=>{M(null),j(!1)},children:C("themeDefault")}),N.map(_=>s.jsx(nt,{active:S===_.id,onClick:()=>{M(_.id),j(!1)},children:z==="zh"?_.name:_.nameEn??_.name},_.id))]}),e.managed?s.jsxs("span",{className:"chip",title:C("updatesManaged"),children:[s.jsx(Ht,{}),s.jsxs("span",{className:"chip-sub",children:["v",e.appVersion??e.update?.current??"…"]})]}):s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Ht,{}),s.jsxs("span",{className:"chip-sub",children:["v",e.update?.current??"…"]}),e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot",title:C("updateAvailable",{version:e.update.latest??""})}),v>0&&s.jsx("span",{className:"update-badge",children:C("updatesAllBadge",{n:v})})]}),open:X,onOpenChange:_=>{k(_),_&&(t({type:"check_update"}),t({type:"check_updates_all"}))},fit:!0,children:[s.jsx("div",{className:"dd-header",children:C("update")}),ae(),ce()]}),s.jsx("a",{className:"chip github",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",title:C("githubRepo"),children:s.jsx(Da,{})})]}),s.jsxs("button",{type:"button",className:"chip newchat","data-tip":C("newChatTip"),onClick:()=>t({type:"new_chat"}),children:[s.jsx(dt,{}),s.jsx("span",{children:C("newChat")})]}),s.jsx("div",{className:"topbar-more",children:s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(_l,{}),s.jsx("span",{className:"chip-sub",children:C("more")}),!e.managed&&e.update&&!e.update.upToDate&&s.jsx("span",{className:"update-dot"})]}),open:Z,onOpenChange:_=>{Y(_),_&&!e.managed&&(t({type:"check_update"}),t({type:"check_updates_all"}))},children:[s.jsx("div",{className:"dd-header",children:C("sound")}),s.jsx("div",{className:"dd-header",children:C("settings")}),s.jsxs(nt,{onClick:()=>{Y(!1),d()},children:[s.jsx(Qs,{})," ",C("settingsTitle")]}),s.jsxs(nt,{onClick:()=>{Y(!1),f()},children:[s.jsx(Js,{})," ",C("searchGlobal")]}),s.jsxs(nt,{onClick:()=>{Y(!1),u()},children:[s.jsx(Zs,{})," ",C("bgTasks"),e.bgServers.length>0&&s.jsx("em",{className:"bg-task-badge",children:e.bgServers.length})]}),s.jsx(Ba,{settings:E,onChange:g,onPreview:y}),s.jsx(Ka,{}),s.jsx("div",{className:"dd-header",children:C("language")}),P.map(_=>s.jsx(nt,{active:z===_.code,onClick:()=>$(_.code),children:_.nativeName},_.code)),s.jsx("div",{className:"dd-header",children:C("theme")}),s.jsx(nt,{active:S===null,onClick:()=>{M(null),Y(!1)},children:C("themeDefault")}),N.map(_=>s.jsx(nt,{active:S===_.id,onClick:()=>{M(_.id),Y(!1)},children:z==="zh"?_.name:_.nameEn??_.name},_.id)),s.jsx("div",{className:"dd-header",children:C("update")}),ae(),ce(),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(Da,{})," ",C("githubRepo")]})]})})]}),s.jsx("button",{type:"button",className:"panel-toggle",title:C("openFiles"),onClick:()=>c("right"),children:s.jsx(Pt,{})}),me&&s.jsx(bc,{onClose:()=>de(!1)})]})}function br(e,t){const n={...t};if(!e)return n;try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a))for(const o of Object.keys(t)){const i=a[o];typeof i=="number"&&Number.isFinite(i)&&i>0&&(n[o]=i)}}catch{}return n}function Er(e){const t=e.start.above+e.start.below,n=Math.max(1,e.availablePx),a=e.totalWeight>0?e.totalWeight:1,o=n/a,i=e.minAbovePx/o,c=e.minBelowPx/o;if(i+c>=t){const u=e.minAbovePx+e.minBelowPx||1,f=t*e.minAbovePx/u;return{above:f,below:t-f}}const d=Math.min(t-c,Math.max(i,e.start.above+e.deltaPx/o));return{above:d,below:t-d}}function Ya(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 Tc(e,t){const n=new Map(e.map(i=>[i.id,i])),a=new Map;for(const i of e){const c=i.parentId?n.get(i.parentId)?.cwd??i.cwd:i.cwd,d=a.get(c)??[];d.push(i),a.set(c,d)}const o=[...a.entries()].map(([i,c])=>({cwd:i,isCurrent:i===t,convs:c}));return o.sort((i,c)=>i.isCurrent?-1:c.isCurrent?1:i.cwd<c.cwd?-1:i.cwd>c.cwd?1:0),o}const xc="pi-web-ui:lp-collapse-projects",yc="pi-web-ui:lp-collapse-convs",Nc="pi-web-ui:lp-collapse-sessions";function Nn(e,t=!1){const[n,a]=l.useState(()=>{try{const i=localStorage.getItem(e);if(i==="1")return!0;if(i==="0")return!1}catch{}return t}),o=l.useCallback(()=>{a(i=>{const c=!i;try{localStorage.setItem(e,c?"1":"0")}catch{}return c})},[e]);return[n,o]}const Tr="pi-web-ui:lp-sizes",tn={projects:1,convs:1,sessions:1},kc=32,Ga=72;function vc(){try{return br(localStorage.getItem(Tr),tn)}catch{return{...tn}}}const Cc=l.memo(function({ready:t,status:n,cwd:a,sessionFile:o,conversations:i,sessions:c,projects:d,activeConversationId:u,send:f,active:E,collapsible:g,onToggleCollapse:y}){const N=Le(),S=o,M=a,[z,$]=l.useState(null),[C,P]=l.useState(null),[B,H]=l.useState(""),[Q,re]=Nn(xc,!1),[K,j]=Nn(yc,!1),[X,k]=Nn(Nc,!1),[Z,Y]=l.useState(null),[me,de]=l.useState(null),w=l.useCallback(()=>{de(null),Y(null)},[]),I=l.useCallback((U,ge)=>{U.preventDefault(),U.stopPropagation(),Y({x:Math.min(U.clientX,window.innerWidth-260),y:Math.min(U.clientY,window.innerHeight-120),scopeId:ge})},[]);l.useEffect(()=>{if(!Z)return;const U=ue=>{ue.target?.closest(".ctx-menu")||w()},ge=ue=>{ue.key==="Escape"&&w()};return window.addEventListener("mousedown",U,!0),window.addEventListener("keydown",ge),window.addEventListener("blur",w),()=>{window.removeEventListener("mousedown",U,!0),window.removeEventListener("keydown",ge),window.removeEventListener("blur",w)}},[Z,w]);const L=l.useCallback((U,ge)=>{if(!ge)return U.filter(G=>G.isSubagent&&!G.isStreaming&&G.id!==u).length;const ue=new Map(U.map(G=>[G.id,G])),ie=G=>{if(G.id===ge)return(ue.get(ge)?.isSubagent??!1)&&!G.isStreaming&&G.id!==u;let Te=G;const Re=new Set;for(;Te?.parentId;){if(Te.parentId===ge)return!0;if(Re.has(Te.parentId)||(Re.add(Te.parentId),Te=ue.get(Te.parentId),!Te))return!1}return!1};return U.filter(G=>G.isSubagent&&!G.isStreaming&&G.id!==u&&ie(G)).length},[u]),oe=l.useCallback((U,ge)=>{if(!ge)return U.filter(G=>G.isSubagent).length;const ue=new Map(U.map(G=>[G.id,G])),ie=G=>{if(G.id===ge)return ue.get(ge)?.isSubagent??!1;let Te=G;const Re=new Set;for(;Te?.parentId;){if(Te.parentId===ge)return!0;if(Re.has(Te.parentId)||(Re.add(Te.parentId),Te=ue.get(Te.parentId),!Te))return!1}return!1};return U.filter(G=>G.isSubagent&&ie(G)).length},[]),se=l.useCallback((U,ge)=>{if(!ge)return 0;const ue=new Map(U.map(G=>[G.id,G])),ie=G=>{let Te=G;const Re=new Set;for(;Te?.parentId;){if(Te.parentId===ge)return!0;if(Re.has(Te.parentId)||(Re.add(Te.parentId),Te=ue.get(Te.parentId),!Te))return!1}return!1};return U.filter(G=>G.isSubagent&&G.isStreaming&&ie(G)).length},[]),ye=l.useRef(null),[v,ee]=l.useState(()=>vc());l.useEffect(()=>{try{localStorage.setItem(Tr,JSON.stringify(v))}catch{}},[v]);const ce=l.useCallback((U,ge)=>ue=>{ue.preventDefault();const ie=ue.currentTarget,G=ue.clientY,Te={...v},Re=ye.current;if(!Re)return;const x=[{key:"projects",visible:d.length>0,collapsed:Q},{key:"convs",visible:i.length>0,collapsed:K},{key:"sessions",visible:!0,collapsed:X}].filter(Ae=>Ae.visible),b=x.filter(Ae=>Ae.collapsed).length,le=x.filter(Ae=>!Ae.collapsed).map(Ae=>Ae.key).reduce((Ae,D)=>Ae+(Te[D]??1),0)||1,be=Math.max(120,Re.clientHeight-b*kc);ie.classList.add("dragging"),document.body.classList.add("lp-resizing");const ke=Ae=>{const{above:D,below:we}=Er({start:{above:Te[U]??1,below:Te[ge]??1},deltaPx:Ae.clientY-G,availablePx:be,totalWeight:le,minAbovePx:Ga,minBelowPx:Ga});ee(ve=>({...ve,[U]:D,[ge]:we}))},Ie=()=>{window.removeEventListener("pointermove",ke),window.removeEventListener("pointerup",Ie),ie.classList.remove("dragging"),document.body.classList.remove("lp-resizing")};window.addEventListener("pointermove",ke),window.addEventListener("pointerup",Ie)},[v,d.length,i.length,Q,K,X]);l.useEffect(()=>{!E||!t||n!=="open"||a&&(f({type:"list_sessions"}),f({type:"list_projects"}))},[E,t,n,a,f]);const ae=U=>{const ge=U.name||U.firstMessage.trim();return ge.length>0?ge:N("emptyChat")},_=U=>U.split(/[\\/]/).pop()||U,he=(U,ge,ue,ie,G)=>{const Te=z===U;return s.jsx("button",{type:"button",className:`lp-del ${Te?"confirm":""}`,title:Te?ue:ge,onClick:Re=>{Re.stopPropagation(),Te?($(null),ie()):$(U)},children:Te?s.jsx(Tt,{}):G??s.jsx(et,{})})},F=(U,ge,ue,ie)=>s.jsxs("button",{type:"button",className:"lp-section-title panel-section-title",onClick:ue,title:N(ge?"expandSection":"collapseSection"),children:[s.jsxs("span",{className:"lp-section-title-text",children:[U,ie!==void 0?` (${ie})`:""]}),s.jsx("span",{className:"lp-section-chevron",children:ge?s.jsx(Ot,{}):s.jsx(dn,{})})]}),Ee=[{key:"projects",visible:d.length>0,collapsed:Q},{key:"convs",visible:i.length>0,collapsed:K},{key:"sessions",visible:!0,collapsed:X}].filter(U=>U.visible).filter(U=>!U.collapsed),Oe=Ee.reduce((U,ge)=>U+(v[ge.key]??1),0)||1,Se=U=>Ee.length<=1?1:(v[U]??1)/Oe*Ee.length;return s.jsxs("aside",{ref:ye,className:"panel panel-left lp-panel",children:[g&&y&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:N("collapsePanel"),onClick:y,children:s.jsx(ir,{})}),d.length>0&&s.jsxs("div",{className:`lp-section panel-projects ${Q?"collapsed":""}`,style:Q?void 0:{flex:`${Se("projects")} 1 0px`},children:[F(N("recentProjects"),Q,re,d.length),!Q&&s.jsx("div",{className:"lp-section-body projects-scroll",children:d.map(U=>{const ge=M===U.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>$(ue=>ue===`proj:${U.path}`?null:ue),children:[s.jsxs("button",{type:"button",className:`project-item ${ge?"active":""}`,title:U.path,onClick:()=>{ge||f({type:"set_cwd",path:U.path})},children:[s.jsx(Pt,{className:"project-icon"}),s.jsxs("span",{className:"project-info",children:[s.jsx("span",{className:"project-name",children:_(U.path)}),s.jsx("span",{className:"project-path",children:U.path})]}),s.jsx("span",{className:"project-time",children:Ya(U.lastUsed)})]}),he(`proj:${U.path}`,N("deleteProject"),N("deleteProjectConfirm"),()=>f({type:"remove_project",path:U.path}))]},U.path)})})]}),d.length>0&&!Q&&(i.length>0?!K:!X)&&s.jsx("div",{className:"lp-sash",onPointerDown:ce("projects",i.length>0?"convs":"sessions"),onDoubleClick:()=>ee({...tn}),title:N("dragToResize")}),i.length>0&&s.jsxs("div",{className:`lp-section lp-section-convs panel-convs ${K?"collapsed":""}`,style:K?void 0:{flex:`${Se("convs")} 1 0px`},onContextMenu:U=>I(U),children:[F(N("runningConversations"),K,j,i.length),!K&&s.jsx("div",{className:"lp-section-body convs-scroll",children:Tc(i,a).map(U=>s.jsxs("div",{className:"panel-conv-group",children:[!U.isCurrent&&s.jsx("div",{className:"panel-conv-group-title",title:U.cwd,children:_(U.cwd)}),(()=>{const ge=new Map(U.convs.map(x=>[x.id,x])),ue=new Map,ie=[];for(const x of U.convs)if(x.parentId&&ge.has(x.parentId)){const b=ue.get(x.parentId)??[];b.push(x),ue.set(x.parentId,b)}else ie.push(x);const G=[],Te=new Set,Re=(x,b)=>{if(!Te.has(x.id)){Te.add(x.id),G.push({c:x,depth:b});for(const J of ue.get(x.id)??[])Re(J,b+1)}};for(const x of ie)Re(x,0);for(const x of U.convs)Re(x,0);return G.map(({c:x,depth:b})=>{const J=u===x.id;return s.jsxs("div",{className:`lp-row${b>0?" lp-sub":""}`,style:b>0?{marginLeft:b*18}:void 0,onMouseLeave:()=>$(le=>le===`conv:${x.id}`?null:le),onContextMenu:le=>I(le,x.id),children:[s.jsxs("button",{type:"button",className:`session-item ${J?"active":""}`,title:`${x.title}${U.isCurrent?"":` — ${U.cwd}`}`,onClick:()=>{J||f({type:"switch_conversation",id:x.id})},children:[s.jsx(es,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[C===`conv:${x.id}`?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:B,placeholder:N("renameSessionPlaceholder"),onClick:le=>le.stopPropagation(),onChange:le=>H(le.target.value),onKeyDown:le=>{if(le.stopPropagation(),le.key==="Enter"&&!le.nativeEvent.isComposing){const be=B.trim();be&&f({type:"rename_conversation",id:x.id,name:be}),P(null)}else le.key==="Escape"&&P(null)},onBlur:()=>P(null)}):s.jsxs("span",{className:"session-title",children:[x.isSubagent&&s.jsx("span",{className:"subagent-badge",children:N("subagentBadge")}),x.title,x.error&&s.jsx("span",{className:"conv-error-badge",title:N("convErrorBadge",{error:x.error})})]}),C===`conv:${x.id}`?null:s.jsx("span",{className:"session-sub",children:J?N("current"):N("messageCount",{n:x.messageCount})})]}),x.isStreaming&&s.jsx("span",{className:"conv-streaming",title:N("streaming")})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:N("renameSession"),onClick:le=>{le.stopPropagation(),$(null),H(x.title),P(`conv:${x.id}`)},children:s.jsx(en,{})}),(()=>{const le=`conv:${x.id}`,be=z===le,ke=L(i,x.id),Ie=se(i,x.id),Ae=oe(i,x.id);return Ae===0&&!x.isStreaming?he(le,N("dismissConversation"),N("dismissConversationConfirm"),()=>f({type:"dismiss_conversation",id:x.id}),s.jsx($e,{})):Ae===0?he(le,N("dismissConversation"),N("dismissStreamingConfirm"),()=>f({type:"dismiss_conversation",id:x.id,force:!0}),s.jsx($e,{})):be?s.jsxs("span",{className:"lp-del-group",children:[ke>0&&s.jsx("button",{type:"button",className:"lp-del-opt",title:N("dismissFinishedSubagentsScoped",{n:ke}),onClick:D=>{D.stopPropagation(),$(null),f({type:"dismiss_finished_subagents",parentId:x.id})},children:N("dismissFinishedOnly",{n:ke})}),s.jsx("button",{type:"button",className:"lp-del-opt danger",title:N("forceDismissTitle",{n:Ae,m:Ie}),onClick:D=>{D.stopPropagation(),$(null),f({type:"dismiss_conversation",id:x.id,force:!0})},children:N("dismissForceAll",{n:Ae})})]}):s.jsx("button",{type:"button",className:"lp-del",title:N("dismissConversation"),onClick:D=>{D.stopPropagation(),$(le)},children:s.jsx($e,{})})})(),x.isStreaming&&s.jsx("span",{className:"lp-row-stalled",title:N("streaming"),style:{position:"absolute",right:28,top:"50%",transform:"translateY(-50%)"}})]},x.id)})})()]},U.cwd))})]}),i.length>0&&!K&&!X&&s.jsx("div",{className:"lp-sash",onPointerDown:ce("convs","sessions"),onDoubleClick:()=>ee({...tn}),title:N("dragToResize")}),s.jsxs("div",{className:`lp-section lp-section-sessions panel-sessions ${X?"collapsed":""}`,style:X?void 0:{flex:`${Se("sessions")} 1 0px`},children:[F(N("historySessions"),X,k,c.length),!X&&s.jsxs("div",{className:"lp-section-body sessions-scroll",children:[c.length===0&&s.jsx("div",{className:"panel-empty",children:N("noHistory")}),c.map(U=>{const ge=S===U.path;return s.jsxs("div",{className:"lp-row",onMouseLeave:()=>$(ue=>ue===`sess:${U.path}`?null:ue),children:[s.jsxs("button",{type:"button",className:`session-item ${ge?"active":""}`,title:U.path,onClick:()=>{C||ge||f({type:"switch_session",path:U.path})},children:[s.jsx(es,{className:"session-icon"}),s.jsxs("span",{className:"session-info",children:[C===U.path?s.jsx("input",{autoFocus:!0,className:"session-rename-input",value:B,placeholder:N("renameSessionPlaceholder"),onClick:ue=>ue.stopPropagation(),onChange:ue=>H(ue.target.value),onKeyDown:ue=>{if(ue.stopPropagation(),ue.key==="Enter"&&!ue.nativeEvent.isComposing){const ie=B.trim();ie&&f({type:"rename_session",path:U.path,name:ie}),P(null)}else ue.key==="Escape"&&P(null)},onBlur:()=>P(null)}):s.jsx("span",{className:"session-title",children:ae(U)}),C===U.path?null:s.jsxs("span",{className:"session-sub",children:[ge?N("current"):N("messageCount",{n:U.messageCount}),U.source==="tui"&&s.jsx("span",{className:"session-src",title:N("tuiTip"),children:"TUI"})]})]}),s.jsx("span",{className:"session-time",children:Ya(U.modified)})]}),s.jsx("button",{type:"button",className:"lp-del lp-rename",title:N("renameSession"),onClick:ue=>{ue.stopPropagation(),$(null),H(U.name??""),P(U.path)},children:s.jsx(en,{})}),he(`sess:${U.path}`,N("deleteSession"),N("deleteSessionConfirm"),()=>f({type:"delete_session",path:U.path}))]},U.path)})]})]}),Z&&s.jsxs("div",{className:"ctx-menu",style:{left:Z.x,top:Z.y},onContextMenu:U=>{U.preventDefault(),U.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",title:L(i,Z.scopeId)===0?N("noFinishedSubagents"):void 0,disabled:L(i,Z.scopeId)===0,onClick:()=>{Z.scopeId?f({type:"dismiss_finished_subagents",parentId:Z.scopeId}):f({type:"dismiss_finished_subagents"}),w()},children:[s.jsx($e,{}),s.jsx("span",{children:L(i,Z.scopeId)===0?N("noFinishedSubagents"):Z.scopeId?N("dismissFinishedSubagentsScoped",{n:L(i,Z.scopeId)}):N("dismissFinishedSubagents",{n:L(i,Z.scopeId)})})]}),Z.scopeId&&s.jsxs("button",{type:"button",className:me===Z.scopeId?"ctx-item danger armed":"ctx-item danger",title:me===Z.scopeId?N("forceDismissConfirm"):N("forceDismissConversation"),onClick:()=>{const U=Z.scopeId;me===U?(f({type:"dismiss_conversation",id:U,force:!0}),de(null),w()):de(U)},children:[s.jsx($e,{}),s.jsx("span",{children:me===Z.scopeId?N("forceDismissConfirm"):N("forceDismissConversation")})]})]})]})});function _c(e,t){const n=t.assistantMessageEvent,a=e.stats.tokens,o=t.usage!==null?{...a,...t.usage}:a,i=o===a?e.stats:{...e.stats,tokens:o};if(n.type!=="text_delta"&&n.type!=="thinking_delta")return i===e.stats?e:{...e,stats:i};const c=n.delta??"";if(!c)return i===e.stats?e:{...e,stats:i};const d=e.streamingMessage??null,u=d&&d.id===t.messageId?d:{id:t.messageId,content:[]},f=[...u.content],E=n.type==="thinking_delta"?"thinking":"text",g=n.contentIndex??f.length-1;return g>=0&&g<f.length&&f[g].type===E?f[g]=E==="thinking"?{type:"thinking",thinking:(f[g].thinking??"")+c}:{type:"text",text:(f[g].text??"")+c}:f.push(E==="thinking"?{type:"thinking",thinking:c}:{type:"text",text:c}),{...e,stats:i,streamingMessage:{...u,id:t.messageId,content:f}}}const Un="pi-web-ui:plugin-data";function Sc(e,t){window.dispatchEvent(new CustomEvent(Un,{detail:{pluginId:e,payload:t}}))}function Ac(e){const t=n=>{const a=n.detail;e(a.pluginId,a.payload)};return window.addEventListener(Un,t),()=>window.removeEventListener(Un,t)}const Vt=new Map,qn=new Set,Yt=new Set;let za=-1;function xr(){return[...Vt.values()]}function wc(){const e=xr();for(const t of qn)t(e)}function Ic(e){return qn.add(e),e(xr()),()=>qn.delete(e)}async function jc(e,t){t!==za&&(za=t,Vt.clear(),Yt.clear());const n=new Set(e.map(a=>a.id));for(const a of[...Vt.keys()])n.has(a)||Vt.delete(a);for(const a of[...Yt])n.has(a)||Yt.delete(a);await Promise.all(e.filter(a=>a.hasClient&&a.view!==!1&&!a.error&&!Vt.has(a.id)&&!Yt.has(a.id)).map(async a=>{try{const i=(await import(at(`/plugins/${encodeURIComponent(a.id)}/client/entry.mjs?e=${t}`))).default;i&&typeof i.mount=="function"?Vt.set(a.id,{info:a,module:i}):(Yt.add(a.id),console.error(`[plugin:${a.id}] entry.mjs 缺少 default.mount`))}catch(o){Yt.add(a.id),console.error(`[plugin:${a.id}] 客户端加载失败:`,o)}})),wc()}function Lc(e,t){return{pluginId:e,send:n=>t({type:"plugin_message",pluginId:e,payload:n}),onData:n=>Ac((a,o)=>{a===e&&n(o)})}}const Rc=15,Pc="pi-web-ui:lang";function Va(){try{return(localStorage.getItem(Pc)??"").trim()}catch{return""}}const Qa="pi-web-ui:locale",kn=2e5,Dc=2e5,Oc="LIVE_OMIT",Mc={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 Bc(){const e=new Map,t=new Map,n=(a,o)=>`${a}:${o}`;return{write(a,o,i){const c=n(a,o),d=e.get(c);if(d&&d.size>0){for(const E of d)try{E.write(i)}catch{}return}const u=t.get(c)??"",f=u.length+i.length>Dc?i:u+i;t.set(c,f)},register(a,o,i){const c=n(a,o);let d=e.get(c);d||(d=new Set,e.set(c,d)),d.add(i);const u=t.get(c);if(u){try{i.write(u)}catch{}t.delete(c)}return()=>{const f=e.get(c);f&&(f.delete(i),f.size===0&&e.delete(c)),t.delete(c)}},clear(){e.clear(),t.clear()}}}function Xa(e,t){const n=new Set;for(const o of t.messages)o.role==="toolResult"&&o.toolCallId&&n.add(o.toolCallId),o.role==="bashExecution"&&n.add(`bash-${o.id}`);let a=!1;for(const o of e.keys())n.has(o)&&(e.delete(o),a=!0);return a?new Map(e):e}function Ja(e,t){if(e.size===0)return e;const n=new Set;for(const o of t.messages)o.role==="toolResult"&&o.toolCallId&&n.add(o.toolCallId);let a=!1;for(const o of e.keys())n.has(o)&&(e.delete(o),a=!0);return a?new Map(e):e}function Fc(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!==Rc};case"snapshot":return{...e,ready:!0,state:t.state,activeConversationId:t.state.conversationId,liveOutputs:Xa(e.liveOutputs,t.state),toolStatuses:Ja(e.toolStatuses,t.state)};case"snapshot_delta":{const n=e.state,a=t.msg;if(!n||n.conversationId!==a.conversationId||n.rev!==a.baseRev)return e;const o={...n,...a.state,messages:a.appended.length>0?[...n.messages,...a.appended]:n.messages};return{...e,ready:!0,state:o,activeConversationId:o.conversationId,liveOutputs:Xa(e.liveOutputs,o),toolStatuses:Ja(e.toolStatuses,o)}}case"tool_delta":{const a=(e.liveOutputs.get(t.toolCallId)?.text??"")+t.delta,o=a.length>kn?`…[${Oc}:${a.length-kn}]…
|
|
305
|
+
`+a.slice(a.length-kn):a,i=new Map(e.liveOutputs);return i.set(t.toolCallId,{toolName:t.toolName,text:o}),{...e,liveOutputs:i}}case"message_delta":{const n=e.state;return!n||n.conversationId!==t.msg.conversationId?e:{...e,state:_c(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 Za="pi-web-client-id";let vn=null;function ca(){if(vn)return vn;let e=null;try{e=sessionStorage.getItem(Za),e||(e=_t(),sessionStorage.setItem(Za,e))}catch{e=e??_t()}return vn=e,e}const yr="pi-web-last-cwd";function Hc(){try{return localStorage.getItem(yr)}catch{return null}}function Uc(e){try{localStorage.setItem(yr,e)}catch{}}function qc(){const e=location.protocol==="https:"?"wss:":"ws:";return Dt(`${e}//${location.host}${at("/ws")}`)}function $c(){const[e,t]=l.useReducer(Fc,{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:Mc,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=l.useRef(null),a=l.useRef(Bc()),o=l.useRef(0),i=l.useRef(null),c=l.useRef(!0),d=l.useRef(0),u=l.useRef(0),f=l.useRef(new Map),E=l.useRef(null),g=l.useRef(!1),y=l.useRef(null),N=()=>{E.current||(E.current=setTimeout(()=>{E.current=null;const j=n.current;j&&j.readyState===WebSocket.OPEN&&j.send(JSON.stringify({type:"get_state"}))},300))},S=(j,X)=>{const k=f.current,Z=k.get(j);if(Z!==void 0&&X!==Z+1){const Y=K.current.chat,me=Y.activeConversationId||Y.state?.conversationId;j===me&&N()}k.set(j,X)},M=l.useCallback((j,X)=>{const k=++u.current;t({type:"notice",notice:{id:k,level:j,text:X}})},[]),z=l.useCallback(j=>{const X=n.current;return X&&X.readyState===WebSocket.OPEN?(j.type==="check_updates_all"&&j.force===!0&&t({type:"updates_check_started"}),X.send(JSON.stringify(j)),j.type==="question_answer"&&t({type:"question",question:null}),!0):!1},[]),$=l.useCallback(()=>{if(!c.current)return;t({type:"status",status:"connecting"});const j=new WebSocket(qc());n.current=j,j.onopen=()=>{n.current===j&&(t({type:"status",status:"open"}),o.current=0,d.current=Date.now(),j.send(JSON.stringify({type:"hello",clientId:ca(),locale:Va()})))},j.onmessage=X=>{if(n.current!==j)return;d.current=Date.now();let k;try{k=JSON.parse(X.data)}catch{return}switch(k.type){case"ready":t({type:"ready",serverVersion:k.serverVersion,protocolVersion:k.protocolVersion,engine:k.engine,appVersion:k.appVersion,managed:k.managed,tabs:k.tabs}),j.send(JSON.stringify({type:"get_state"})),j.send(JSON.stringify({type:"list_files"})),j.send(JSON.stringify({type:"list_models"})),j.send(JSON.stringify({type:"list_commands"})),j.send(JSON.stringify({type:"get_commands"})),k.managed||(j.send(JSON.stringify({type:"check_update"})),j.send(JSON.stringify({type:"check_updates_all"})));break;case"snapshot":f.current=new Map,t({type:"snapshot",state:k.state});break;case"snapshot_delta":{const Z=K.current.chat.state;(!Z||Z.conversationId!==k.conversationId||Z.rev!==k.baseRev)&&N(),t({type:"snapshot_delta",msg:k});break}case"tool_delta":S(k.conversationId,k.seq),t({type:"tool_delta",toolCallId:k.toolCallId,toolName:k.toolName,delta:k.delta});break;case"tool_status":t({type:"tool_status",status:k});break;case"message_delta":{S(k.conversationId,k.seq),t({type:"message_delta",msg:k});break}case"notice":{const Z=++u.current;t({type:"notice",notice:{id:Z,level:k.level,text:k.text,textEn:k.textEn}});break}case"sessions":t({type:"sessions",sessions:k.sessions});break;case"conversations":t({type:"conversations",conversations:k.conversations,activeId:k.activeId});break;case"projects":t({type:"projects",projects:k.projects});break;case"files":t({type:"files",files:k});break;case"file_changed":t({type:"file_changed",path:k.path});break;case"file_content":t({type:"file_content",content:k});break;case"models":t({type:"models",models:k.models,loading:!1});break;case"models_config":t({type:"models_config",providers:k.providers});break;case"providers_status":t({type:"providers_status",providers:k.providers});break;case"provider_keys":t({type:"provider_keys",keys:k.keys});break;case"fetch_models_result":t({type:"fetch_models_result",result:{reqId:k.reqId,ok:k.ok,models:k.models,error:k.error}});break;case"refresh_provider_result":t({type:"refresh_provider_result",result:{reqId:k.reqId,ok:k.ok,added:k.added,total:k.total,error:k.error}});break;case"clone_provider_result":t({type:"clone_provider_result",result:{reqId:k.reqId,ok:k.ok,config:k.config,configs:k.configs,error:k.error}});break;case"scm_data":t({type:"scm_data",data:k});break;case"search_files_result":t({type:"file_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results,truncated:k.truncated}});break;case"session_search_results":t({type:"session_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results}});break;case"scm_changed":t({type:"scm_changed"});break;case"install_result":t({type:"install_result",result:k});break;case"path_completions":t({type:"path_completions",completions:k.completions});break;case"update_status":t({type:"update_status",status:k});break;case"update_status_all":t({type:"update_status_all",items:k.items});break;case"widgets":t({type:"widgets",widgets:k.widgets});break;case"statuses":t({type:"statuses",statuses:k.statuses});break;case"dialog":t({type:"dialog",dialog:{id:k.id,kind:k.kind,title:k.title,args:k.args}});break;case"dialog_closed":t({type:"dialog",dialog:null});break;case"question_pending":t({type:"question",question:{id:k.id,questions:k.questions}});break;case"terminal_output":a.current.write(k.conversationId??K.current.chat.activeConversationId,k.terminalId,k.data);break;case"terminal_exit":t({type:"terminal_exit",conversationId:k.conversationId,terminalId:k.terminalId,exitCode:k.exitCode});break;case"terminal_list":t({type:"terminal_list",conversationId:k.conversationId,terminals:k.terminals});break;case"commands":t({type:"commands",commands:k.commands,path:k.path});break;case"slash_commands":t({type:"slash_commands",commands:k.commands});break;case"goal_status":t({type:"goal_status",status:k.status});break;case"settings_state":t({type:"settings",settings:k.settings});break;case"bg_servers":t({type:"bg_servers",servers:k.servers});break;case"plugins":t({type:"plugins",plugins:k.plugins,epoch:k.epoch});break;case"plugin_catalog":t({type:"plugin_catalog",entries:k.entries,epoch:k.epoch});break;case"dsh_patches":t({type:"dsh_patches",patchDir:k.patchDir,files:k.files});break;case"plugin_data":Sc(k.pluginId,k.payload);break}},j.onclose=()=>{if(n.current===j&&(n.current=null),a.current.clear(),!c.current||n.current&&n.current!==j)return;t({type:"status",status:"closed"});const X=Math.min(1e3*2**o.current,1e4);o.current+=1,i.current=setTimeout(()=>{i.current=null,$()},X)},j.onerror=()=>{}},[]);l.useEffect(()=>{const j=X=>{const k=X.detail??Va();k&&z({type:"set_locale",locale:k})};return window.addEventListener(Qa,j),()=>window.removeEventListener(Qa,j)},[z]),l.useEffect(()=>{c.current=!0,$();const j=setInterval(()=>{if(!c.current)return;const X=n.current;X&&X.readyState===WebSocket.OPEN&&Date.now()-d.current>3e4&&X.close()},5e3);return()=>{c.current=!1,clearInterval(j),i.current&&(clearTimeout(i.current),i.current=null),n.current?.close(),n.current=null}},[$]),l.useEffect(()=>{const j=e.state?.cwd;if(j){if(!g.current){g.current=!0;const X=Hc();if(X&&X!==j){z({type:"set_cwd",path:X});return}}y.current!==j&&(y.current=j,Uc(j))}},[e.state?.cwd,z]);const C=l.useCallback(j=>t({type:"dismiss_notice",id:j}),[]),P=l.useCallback(j=>t({type:"terminal_add",meta:j}),[]),B=l.useCallback(j=>t({type:"terminal_remove",id:j}),[]),H=l.useCallback(j=>t({type:"terminal_restart",terminalId:j}),[]),Q=l.useCallback(j=>t({type:"terminal_active",id:j}),[]),re=l.useCallback((j,X,k)=>a.current.register(j,X,k),[]),K=l.useRef({chat:e,send:z,pushNotice:M,dismissNotice:C,terminal:{create:P,close:B,register:re,restart:H,select:Q}});return K.current={chat:e,send:z,pushNotice:M,dismissNotice:C,terminal:{create:P,close:B,register:re,restart:H,select:Q}},K.current}const Wc=200*1024*1024,Kc=/windows/i.test(navigator.userAgent),Yc=/[<>:"/\\|?*\u0000-\u001f]/g,Gc=/[. ]+$/,zc=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Vc(e){const t=e.replace(Yc,"_").replace(Gc,"");return t?zc.test(t)?`_${t}`:t:"_"}function ei(e,t=!0){const n=new URLSearchParams({clientId:ca(),path:e,...t?{download:"1"}:{}});return Dt(at(`/api/file?${n}`))}const Nr="FILE_NOT_FOUND";async function Qc(e,t){const n=Kc?Vc(t):t;try{const a=await fetch(ei(e));if(!a.ok)return{ok:!1,cancelled:!1,error:await a.text().catch(()=>"")||(a.status===404?Nr:`HTTP ${a.status}`)};if(Number(a.headers.get("content-length")??"0")>Wc)return window.location.assign(ei(e)),{ok:!0};const i=await a.blob();return window.showSaveFilePicker&&window.isSecureContext?Xc(i,n):$n(i,n)}catch(a){return{ok:!1,cancelled:!1,error:a instanceof Error?a.message:String(a)}}}async function Xc(e,t){let n;const a=window.showSaveFilePicker;if(!a)return $n(e,t);try{n=await a({suggestedName:t})}catch(o){return o instanceof DOMException&&o.name==="AbortError"?{ok:!1,cancelled:!0}:$n(e,t)}try{const o=await n.createWritable();return await o.write(e),await o.close(),{ok:!0}}catch(o){return{ok:!1,cancelled:!1,error:o instanceof Error?o.message:String(o)}}}function $n(e,t){const n=URL.createObjectURL(e),a=document.createElement("a");return a.href=n,a.download=t,document.body.appendChild(a),a.click(),a.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}const cs="@root",ti="pi-web-ui:rp-sizes",Cn={files:4,widgets:1},si=120,ni=56,Jc=l.memo(function({files:t,fileChanged:n,widgets:a,cwd:o,send:i,onAttach:c,onPreview:d,onNotice:u,collapsible:f,onToggleCollapse:E}){const g=Le(),[y,N]=l.useState(""),[S,M]=l.useState(null),[z,$]=l.useState(!1),C=l.useRef(null),P=l.useRef(null),[B,H]=l.useState(()=>{try{return br(localStorage.getItem(ti),Cn)}catch{return{...Cn}}});l.useEffect(()=>{try{localStorage.setItem(ti,JSON.stringify(B))}catch{}},[B]);const Q=a.some(x=>x.lines.length>0),re=l.useCallback(x=>{x.preventDefault();const b=C.current;if(!b)return;const J=x.currentTarget,le=x.clientY,be={above:B.files,below:B.widgets},ke=Math.max(120,b.clientHeight-(P.current?.offsetHeight??32));J.classList.add("dragging"),document.body.classList.add("rp-resizing");const Ie=D=>{const{above:we,below:ve}=Er({start:be,deltaPx:D.clientY-le,availablePx:ke,totalWeight:be.above+be.below,minAbovePx:si,minBelowPx:ni});H({files:we,widgets:ve})},Ae=()=>{window.removeEventListener("pointermove",Ie),window.removeEventListener("pointerup",Ae),J.classList.remove("dragging"),document.body.classList.remove("rp-resizing")};window.addEventListener("pointermove",Ie),window.addEventListener("pointerup",Ae)},[B.files,B.widgets]),[K,j]=l.useState(null),X=l.useRef(""),k=l.useRef(null),Z=l.useRef(null),[Y,me]=l.useState(null),de=l.useRef(null);l.useEffect(()=>()=>{de.current&&clearTimeout(de.current)},[]);const w=l.useCallback(x=>{me(x),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>me(null),1200)},[]),I=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 J=document.execCommand("copy");return document.body.removeChild(b),J}catch{return!1}},L=l.useCallback((x,b)=>{if(!x)return;const J=()=>w(b),le=()=>u("error",g("slashCopyFailed")),be=navigator;be.clipboard?.writeText?be.clipboard.writeText(x).then(J,()=>{I(x)?J():le()}):I(x)?J():le()},[w,u,g]),oe=l.useCallback(x=>{if(!x)return o;if(/^[A-Za-z]:$/.test(x))return`${x}/`;if(x.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(x))return x;const b=o.replace(/\\/g,"/").replace(/\/+$/,"");return b?`${b}/${x}`:x},[o]),se=l.useCallback(x=>!x||x===cs?null:x.startsWith("/")||/^[A-Za-z]:([/]|$)/.test(x)?x:`${o.replace(/\\/g,"/").replace(/\/+$/,"")}/${x}`,[o]),ye=l.useCallback((x,b,J)=>{x.preventDefault(),X.current=b,k.current=J??null,j({x:Math.min(x.clientX,window.innerWidth-220),y:Math.min(x.clientY,window.innerHeight-90)})},[]),v=l.useCallback(()=>j(null),[]);l.useEffect(()=>{if(!K)return;const x=le=>{le.target?.closest(".ctx-menu")||v()},b=le=>{le.key==="Escape"&&v()};window.addEventListener("mousedown",x,!0),window.addEventListener("keydown",b);const J=()=>v();return window.addEventListener("blur",J),()=>{window.removeEventListener("mousedown",x,!0),window.removeEventListener("keydown",b),window.removeEventListener("blur",J)}},[K,v]);const ee=l.useCallback(()=>{const x=k.current;v(),x&&i({type:"set_cwd",path:x.path})},[v,i]),ce=l.useCallback(()=>{v(),Z.current&&(Z.current.value=""),Z.current?.click()},[v]),ae=l.useCallback((x,b)=>{for(const J of b){const le=new FileReader;le.onload=()=>{const be=le.result,ke=be.slice(be.indexOf(",")+1);ke&&i({type:"upload_file",dirPath:x,name:J.name,data:ke})},le.readAsDataURL(J)}},[i]),_=l.useCallback(x=>{ae(X.current,Array.from(x.target.files??[]))},[ae]),he=l.useRef(null),F=x=>Array.from(x.dataTransfer?.types??[]).includes("Files"),pe=l.useCallback(()=>{he.current?.querySelectorAll(".file-item.drop-target").forEach(x=>x.classList.remove("drop-target")),he.current?.classList.remove("drop-root")},[]),Ee=l.useCallback(x=>{if(pe(),x==null)return;const b=he.current?.querySelector(`.file-item[data-path="${CSS.escape(x)}"]`);b?b.classList.add("drop-target"):he.current?.classList.add("drop-root")},[pe]),Oe=x=>{const b=x instanceof Element?x.closest(".file-item"):null;return b?.dataset.type==="dir"?b.dataset.path??y:y},Se=l.useCallback(()=>{const x=document.querySelector(".app");x&&x.dispatchEvent(new DragEvent("dragleave",{bubbles:!0}))},[]),U=1e4,ge=l.useRef(0),ue=l.useRef(void 0),ie=l.useCallback((x,b)=>{const J=++ge.current;N(x),b?.silent||$(!0),i({type:"list_files",path:x===""?void 0:x})||ge.current===J&&$(!1)},[i]);l.useEffect(()=>{t&&t.path===y&&$(!1)},[t,y]),l.useEffect(()=>{if(o!==ue.current){ue.current=o,ie("",{silent:!0});return}const x=setInterval(()=>{document.visibilityState!=="hidden"&&ie(y,{silent:!0})},U);return()=>clearInterval(x)},[o,y,ie]),l.useEffect(()=>{n&&n.path===y&&ie(y,{silent:!0})},[n,y,ie]);const G=x=>ie(x),Te=()=>{t?.parent!==null&&t?.parent!==void 0&&ie(t.parent)},Re=(()=>{if(y===""||y===cs)return[];const x=y.split("/").filter(b=>!!b&&b!==cs);return y.startsWith("/")?x.map((b,J)=>({label:J===0?"/":x[J],path:"/"+x.slice(0,J+1).join("/")})):x.map((b,J)=>({label:x[J],path:x.slice(0,J+1).join("/")}))})();return s.jsxs("aside",{className:"panel panel-right",ref:C,children:[f&&E&&s.jsx("button",{type:"button",className:"panel-collapse-btn",title:g("collapsePanel"),onClick:E,children:s.jsx(ar,{})}),s.jsxs("div",{className:"panel-crumbs",ref:P,children:[s.jsx("button",{type:"button",className:`crumb ${y===""?"active":""}`,onClick:()=>ie(""),children:g("rootDir")}),s.jsx("button",{type:"button",className:`crumb ${y===cs?"active":""}`,title:g("computer"),onClick:()=>ie(cs),children:"💻"}),Re.map(x=>s.jsxs("span",{className:"crumb-seg",children:[s.jsx($t,{}),s.jsx("button",{type:"button",className:`crumb ${x.path===y?"active":""}`,onClick:()=>ie(x.path),children:x.label})]},x.path))]}),s.jsxs("div",{ref:he,className:"panel-body",style:Q?{flexGrow:B.files,minHeight:si}:void 0,onContextMenu:x=>ye(x,y),onDragOver:x=>{F(x)&&(x.preventDefault(),x.stopPropagation(),x.dataTransfer.dropEffect="copy",Se(),Ee(Oe(x.target)))},onDragLeave:x=>{x.relatedTarget&&x.currentTarget.contains(x.relatedTarget)||pe()},onDrop:x=>{if(pe(),!F(x))return;x.preventDefault(),x.stopPropagation(),Se();const b=Array.from(x.dataTransfer?.files??[]);if(b.length===0){u("warning",g("foldersNotSupported"));return}ae(Oe(x.target),b)},onDragEnd:pe,children:[s.jsx("input",{ref:Z,type:"file",multiple:!0,hidden:!0,onChange:_}),z&&s.jsx("div",{className:"panel-empty",children:g("loading")}),!z&&t&&t.path===y&&s.jsxs(s.Fragment,{children:[t.parent!=null&&s.jsxs("button",{type:"button",className:"file-item dir",onClick:Te,children:[s.jsx(Pt,{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 J=se(x.path);ye(b,x.path,J?{path:J,name:x.name}:null)},children:[s.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>G(x.path),children:[s.jsx(Pt,{className:"file-icon"}),s.jsx("span",{className:"file-name",children:x.name})]}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":g("linkFolderTip"),"aria-label":g("linkFolderTip"),onClick:()=>c(x.path,x.name,"reference",!0),children:s.jsx(On,{})}),s.jsx("button",{type:"button",className:`file-attach copy${Y===`name:${x.path}`?" copied":""}`,"data-tip":g("copyName"),"aria-label":g("copyName"),onClick:()=>L(x.name,`name:${x.path}`),children:Y===`name:${x.path}`?s.jsx(Tt,{}):s.jsx(Ct,{})}),s.jsx("button",{type:"button",className:`file-attach copy${Y===`path:${x.path}`?" copied":""}`,"data-tip":g("copyPath"),"aria-label":g("copyPath"),onClick:()=>L(oe(x.path),`path:${x.path}`),children:Y===`path:${x.path}`?s.jsx(Tt,{}):s.jsx(Oa,{})})]},x.path):s.jsxs("div",{className:"file-item file","data-type":"file","data-path":x.path,onContextMenu:b=>{b.stopPropagation(),ye(b,y)},children:[s.jsxs("button",{type:"button",className:"file-name",title:`${x.path} — ${g("previewFile")}`,onClick:()=>d(x.path,x.name),children:[s.jsx(Ml,{className:"file-icon"}),s.jsx("span",{className:"file-name-text",children:x.name})]}),s.jsx("button",{type:"button",className:"file-attach download","data-tip":g("downloadFile"),onClick:()=>{Qc(x.path,x.name).then(b=>{b.ok||b.cancelled||u("error",g("downloadFailed",{error:b.error===Nr?g("fileNotFoundShort"):b.error}))})},children:s.jsx(Ht,{})}),s.jsx("button",{type:"button",className:"file-attach inline","data-tip":g("attachInlineTip"),onClick:()=>c(x.path,x.name,"inline"),children:s.jsx(dt,{})}),s.jsx("button",{type:"button",className:"file-attach ref","data-tip":g("referenceTip"),"aria-label":g("referenceTip"),onClick:()=>c(x.path,x.name,"reference"),children:s.jsx(On,{})}),s.jsx("button",{type:"button",className:`file-attach copy${Y===`name:${x.path}`?" copied":""}`,"data-tip":g("copyName"),"aria-label":g("copyName"),onClick:()=>L(x.name,`name:${x.path}`),children:Y===`name:${x.path}`?s.jsx(Tt,{}):s.jsx(Ct,{})}),s.jsx("button",{type:"button",className:`file-attach copy${Y===`path:${x.path}`?" copied":""}`,"data-tip":g("copyPath"),"aria-label":g("copyPath"),onClick:()=>L(oe(x.path),`path:${x.path}`),children:Y===`path:${x.path}`?s.jsx(Tt,{}):s.jsx(Oa,{})})]},x.path)),t.truncated&&s.jsx("div",{className:"panel-empty files-truncated",children:g("filesTruncated")})]}),!z&&!t&&s.jsx("div",{className:"panel-empty",children:g("noFiles")})]}),Q&&s.jsx("div",{className:"rp-sash",onPointerDown:re,onDoubleClick:()=>H({...Cn}),title:g("dragToResize")}),Q&&s.jsx("div",{className:"panel-widgets",style:{flexGrow:B.widgets,minHeight:ni},children:a.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:g("widgetExpand"),onClick:()=>M(x.key),children:[s.jsx("span",{children:x.key}),s.jsx(jl,{})]}),s.jsx("pre",{className:"widget-lines",children:x.lines.join(`
|
|
306
|
+
`)})]},x.key))}),S&&(()=>{const x=a.find(b=>b.key===S);return x?s.jsx("div",{className:"modal-backdrop",onClick:()=>M(null),children:s.jsxs("div",{className:"widget-expand",onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"widget-expand-head",children:[s.jsx("span",{className:"widget-expand-title",children:x.key}),s.jsx("button",{type:"button",className:"btn",title:g("close"),onClick:()=>M(null),children:s.jsx($e,{})})]}),s.jsx("pre",{className:"widget-expand-lines",children:x.lines.join(`
|
|
307
|
+
`)})]})}):null})(),K&&s.jsxs("div",{className:"ctx-menu",style:{left:K.x,top:K.y},onContextMenu:x=>{x.preventDefault(),x.stopPropagation()},children:[s.jsxs("button",{type:"button",className:"ctx-item",onClick:ce,children:[s.jsx(er,{}),X.current===y?g("uploadToCurrentDir"):g("uploadToFolder")]}),k.current&&s.jsxs("button",{type:"button",className:"ctx-item",onClick:ee,children:[s.jsx(Pt,{}),g("openAsProject")]})]})]})});var Zc=Qi();function eu(e){tl(e,[/\r?\n|\r/g,tu])}function tu(){return{type:"break"}}function su(){return function(e){eu(e)}}const ai=/[#.]/g;function nu(e,t){const n=e||"",a={};let o=0,i,c;for(;o<n.length;){ai.lastIndex=o;const d=ai.exec(n),u=n.slice(o,d?d.index:n.length);u&&(i?i==="#"?a.id=u:Array.isArray(a.className)?a.className.push(u):a.className=[u]:c=u,o+=u.length),d&&(i=d[0],o++)}return{type:"element",tagName:c||t||"div",properties:a,children:[]}}function kr(e,t,n){const a=n?ou(n):void 0;function o(i,c,...d){let u;if(i==null){u={type:"root",children:[]};const f=c;d.unshift(f)}else{u=nu(i,t);const f=u.tagName.toLowerCase(),E=a?a.get(f):void 0;if(u.tagName=E||f,au(c))d.unshift(c);else for(const[g,y]of Object.entries(c))iu(e,u.properties,g,y)}for(const f of d)Wn(u.children,f);return u.type==="element"&&u.tagName==="template"&&(u.content={type:"root",children:u.children},u.children=[]),u}return o}function au(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,n=Object.keys(e);for(const a of n){const o=t[a];if(o&&typeof o=="object"){if(!Array.isArray(o))return!0;const i=o;for(const c of i)if(typeof c!="number"&&typeof c!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function iu(e,t,n,a){const o=la(e,n);let i;if(a!=null){if(typeof a=="number"){if(Number.isNaN(a))return;i=a}else typeof a=="boolean"?i=a:typeof a=="string"?o.spaceSeparated?i=ka(a):o.commaSeparated?i=va(a):o.commaOrSpaceSeparated?i=ka(va(a).join(" ")):i=ii(o,o.property,a):Array.isArray(a)?i=[...a]:i=o.property==="style"?ru(a):String(a);if(Array.isArray(i)){const c=[];for(const d of i)c.push(ii(o,o.property,d));i=c}o.property==="className"&&Array.isArray(t.className)&&(i=t.className.concat(i)),t[o.property]=i}}function Wn(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const n of t)Wn(e,n);else if(typeof t=="object"&&"type"in t)t.type==="root"?Wn(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function ii(e,t,n){if(typeof n=="string"){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===""||Ca(n)===Ca(t)))return!0}return n}function ru(e){const t=[];for(const[n,a]of Object.entries(e))t.push([n,a].join(": "));return t.join("; ")}function ou(e){const t=new Map;for(const n of e)t.set(n.toLowerCase(),n);return t}const lu=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],cu=kr(un,"div"),uu=kr(ws,"g",lu);function du(e){const t=String(e),n=[];return{toOffset:o,toPoint:a};function a(i){if(typeof i=="number"&&i>-1&&i<=t.length){let c=0;for(;;){let d=n[c];if(d===void 0){const u=ri(t,n[c-1]);d=u===-1?t.length+1:u+1,n[c]=d}if(d>i)return{line:c+1,column:i-(c>0?n[c-1]:0)+1,offset:i};c++}}}function o(i){if(i&&typeof i.line=="number"&&typeof i.column=="number"&&!Number.isNaN(i.line)&&!Number.isNaN(i.column)){for(;n.length<i.line;){const d=n[n.length-1],u=ri(t,d),f=u===-1?t.length+1:u+1;if(d===f)break;n.push(f)}const c=(i.line>1?n[i.line-2]:0)+i.column-1;if(c<n[i.line-1])return c}}}function ri(e,t){const n=e.indexOf("\r",t),a=e.indexOf(`
|
|
308
|
+
`,t);return a===-1?n:n===-1||n+1===a?a:n<a?n:a}const Bt={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},vr={}.hasOwnProperty,mu=Object.prototype;function pu(e,t){const n=t||{};return ua({file:n.file||void 0,location:!1,schema:n.space==="svg"?ws:un,verbose:n.verbose||!1},e)}function ua(e,t){let n;switch(t.nodeName){case"#comment":{const a=t;return n={type:"comment",value:a.data},qs(e,a,n),n}case"#document":case"#document-fragment":{const a=t,o="mode"in a?a.mode==="quirks"||a.mode==="limited-quirks":!1;if(n={type:"root",children:Cr(e,t.childNodes),data:{quirksMode:o}},e.file&&e.location){const i=String(e.file),c=du(i),d=c.toPoint(0),u=c.toPoint(i.length);n.position={start:d,end:u}}return n}case"#documentType":{const a=t;return n={type:"doctype"},qs(e,a,n),n}case"#text":{const a=t;return n={type:"text",value:a.value},qs(e,a,n),n}default:return n=hu(e,t),n}}function Cr(e,t){let n=-1;const a=[];for(;++n<t.length;){const o=ua(e,t[n]);a.push(o)}return a}function hu(e,t){const n=e.schema;e.schema=t.namespaceURI===Bt.svg?ws:un;let a=-1;const o={};for(;++a<t.attrs.length;){const d=t.attrs[a],u=(d.prefix?d.prefix+":":"")+d.name;vr.call(mu,u)||(o[u]=d.value)}const c=(e.schema.space==="svg"?uu:cu)(t.tagName,o,Cr(e,t.childNodes));if(qs(e,t,c),c.tagName==="template"){const d=t,u=d.sourceCodeLocation,f=u&&u.startTag&&Qt(u.startTag),E=u&&u.endTag&&Qt(u.endTag),g=ua(e,d.content);f&&E&&e.file&&(g.position={start:f.end,end:E.start}),c.content=g}return e.schema=n,c}function qs(e,t,n){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const a=fu(e,n,t.sourceCodeLocation);a&&(e.location=!0,n.position=a)}}function fu(e,t,n){const a=Qt(n);if(t.type==="element"){const o=t.children[t.children.length-1];if(a&&!n.endTag&&o&&o.position&&o.position.end&&(a.end=Object.assign({},o.position.end)),e.verbose){const i={};let c;if(n.attrs)for(c in n.attrs)vr.call(n.attrs,c)&&(i[la(e.schema,c).property]=Qt(n.attrs[c]));Dn(n.startTag);const d=Qt(n.startTag),u=n.endTag?Qt(n.endTag):void 0,f={opening:d};u&&(f.closing=u),f.properties=i,t.data={position:f}}}return a}function Qt(e){const t=oi({line:e.startLine,column:e.startCol,offset:e.startOffset}),n=oi({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||n?{start:t,end:n}:void 0}function oi(e){return e.line&&e.column?e:void 0}const gu={},bu={}.hasOwnProperty,_r=Gi("type",{handlers:{root:Tu,element:vu,text:Nu,comment:ku,doctype:yu}});function Eu(e,t){const a=(t||gu).space;return _r(e,a==="svg"?ws:un)}function Tu(e,t){const n={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return n.childNodes=da(e.children,n,t),as(e,n),n}function xu(e,t){const n={nodeName:"#document-fragment",childNodes:[]};return n.childNodes=da(e.children,n,t),as(e,n),n}function yu(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return as(e,t),t}function Nu(e){const t={nodeName:"#text",value:e.value,parentNode:null};return as(e,t),t}function ku(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return as(e,t),t}function vu(e,t){const n=t;let a=n;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(a=ws);const o=[];let i;if(e.properties){for(i in e.properties)if(i!=="children"&&bu.call(e.properties,i)){const u=Cu(a,i,e.properties[i]);u&&o.push(u)}}const c=a.space,d={nodeName:e.tagName,tagName:e.tagName,attrs:o,namespaceURI:Bt[c],childNodes:[],parentNode:null};return d.childNodes=da(e.children,d,a),as(e,d),e.tagName==="template"&&e.content&&(d.content=xu(e.content,a)),d}function Cu(e,t,n){const a=la(e,t);if(n===!1||n===null||n===void 0||typeof n=="number"&&Number.isNaN(n)||!n&&a.boolean)return;Array.isArray(n)&&(n=a.commaSeparated?sl(n):nl(n));const o={name:a.attribute,value:n===!0?"":String(n)};if(a.space&&a.space!=="html"&&a.space!=="svg"){const i=o.name.indexOf(":");i<0?o.prefix="":(o.name=o.name.slice(i+1),o.prefix=a.attribute.slice(0,i)),o.namespace=Bt[a.space]}return o}function da(e,t,n){let a=-1;const o=[];if(e)for(;++a<e.length;){const i=_r(e[a],n);i.parentNode=t,o.push(i)}return o}function as(e,t){const n=e.position;n&&n.start&&n.end&&(Dn(typeof n.start.offset=="number"),Dn(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 _u=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],Su=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]),Ue="�";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 st={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function Sr(e){return e>=55296&&e<=57343}function Au(e){return e>=56320&&e<=57343}function wu(e,t){return(e-55296)*1024+9216+t}function Ar(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function wr(e){return e>=64976&&e<=65007||Su.has(e)}var O;(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"})(O||(O={}));const Iu=65536;class ju{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=Iu,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:a,col:o,offset:i}=this,c=o+n,d=i+n;return{code:t,startLine:a,endLine:a,startCol:c,endCol:c,startOffset:d,endOffset:d}}_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(Au(n))return this.pos++,this._addGap(),wu(t,n)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,p.EOF;return this._err(O.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 a=0;a<t.length;a++)if((this.html.charCodeAt(this.pos+a)|32)!==t.charCodeAt(a))return!1;return!0}peek(t){const n=this.pos+t;if(n>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,p.EOF;const a=this.html.charCodeAt(n);return a===p.CARRIAGE_RETURN?p.LINE_FEED:a}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,Sr(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){Ar(t)?this._err(O.controlCharacterInInputStream):wr(t)&&this._err(O.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var Pe;(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"})(Pe||(Pe={}));function Ir(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 Lu=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏઑඡ༉༦ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲϏϢϸontourIntegraìȹoɴ\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲy;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱còJTabcdfgorstרׯؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ߂ߐĀiyޱrc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣসে্ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४ĀnrࢃgleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpwਖਛgȀLRlr৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼અઋp;椅y;䐜Ādl੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑඞcy;䐊cute;䅃ƀaeyહાron;䅇dil;䅅;䐝ƀgswે૰ativeƀMTV૨ediumSpace;怋hiĀcn૦ëeryThiîtedĀGLଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷreak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater;EFGLSTஶஷ扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨setĀ;Eೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂෛ෧ขภยา฿ไlig;䅒cute耻Ó䃓Āiyීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲcr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬืde耻Õ䃕es;樷ml耻Ö䃖erĀBP๋Āar๐๓r;怾acĀek๚;揞et;掴arenthesis;揜ҀacfhilorsງຊຏຒດຝະrtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ檻cedesȀ;EST່້扺qual;檯lantEqual;扼ilde;找me;怳Ādpuct;戏ortionĀ;aȥl;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL憒ar;懥eftArrow;懄eiling;按oǵ\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄቕቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHcቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗ĀeiቻDzኀ\0ኇefore;戴a;䎘ĀcnኘkSpace;쀀 Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtèa;䎖r;愨pf;愤cr;쀀𝒵ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒;Eaeiopᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;eᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;eᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰᝃᝈ០៦ᠹᡐᜍ᥈ᥰot;櫭ĀcrᛶkȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀakoᠦᠵĀcn៲ᠣkƀlst֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ;敛;敘;攘;攔;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģbar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;elƀ;bhᥨᥩᥫ䁜;槅sub;柈ŬᥴlĀ;e怢t»pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭒\0᯽\0ᰌƀcprᦲute;䄇̀;abcdsᦿᧀᧄ᧕᧙戩nd;橄rcup;橉Āau᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r;Ecefms᩠ᩢᩫ᪤᪪旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ\0\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»eóɍǧ\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯delprvw᭠᭬᭷ᮂᮬᯔarrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;pᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰻᰿ᱝᱩᱵᲞᲬᲷᴍᵻᶑᶫᶻ᷆᷍ròar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂᳖᳜᳠mƀ;oș᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄĀDoḆᴴoôĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»ṺƀaeiἒἚls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧\0耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₥₰₴⃰℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽ƀ;qsؾٌlanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqrⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0proør;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼ròòΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonóquigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roøurĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨íistĀ;sடr;쀀𝔫ȀEest⩦⩹⩼ƀ;qs⩭ƀ;qs⩴lanôií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast⭕⭚⭟lleìl;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖchimpqu⮽⯍⯙⬄⯤⯯Ȁ;cerല⯆ഷ⯉uå;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭ååഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñĀ;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;cⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācrir;榿;쀀𝔬ͯ\0\0\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕⶥⶨrò᪀Āirⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔǒr;榷rp;榹;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ\0\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ脀¶;l䂶leìЃɩ\0\0m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳ᤈ⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t⾴ïrel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⋢⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔ABHabcdefhilmnoprstuxけさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstwガクシスゼゾダッデナp;極Ā;fゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ìâヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘rrowĀ;tㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowóarpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓ròaòՑ;怏oustĀ;a㈞掱che»mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì耻䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;qኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫwar;椪lig耻ß䃟㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rëƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproøim»ኬsðኞĀas㚺㚮ðrn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈadempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xôheadĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roðtré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜtré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),Ru=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 Pu(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=Ru.get(e))!==null&&t!==void 0?t:e}var Qe;(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"})(Qe||(Qe={}));const Du=32;var Lt;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(Lt||(Lt={}));function Kn(e){return e>=Qe.ZERO&&e<=Qe.NINE}function Ou(e){return e>=Qe.UPPER_A&&e<=Qe.UPPER_F||e>=Qe.LOWER_A&&e<=Qe.LOWER_F}function Mu(e){return e>=Qe.UPPER_A&&e<=Qe.UPPER_Z||e>=Qe.LOWER_A&&e<=Qe.LOWER_Z||Kn(e)}function Bu(e){return e===Qe.EQUALS||Mu(e)}var Ve;(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"})(Ve||(Ve={}));var Nt;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Nt||(Nt={}));class Fu{constructor(t,n,a){this.decodeTree=t,this.emitCodePoint=n,this.errors=a,this.state=Ve.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Nt.Strict}startEntity(t){this.decodeMode=t,this.state=Ve.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,n){switch(this.state){case Ve.EntityStart:return t.charCodeAt(n)===Qe.NUM?(this.state=Ve.NumericStart,this.consumed+=1,this.stateNumericStart(t,n+1)):(this.state=Ve.NamedEntity,this.stateNamedEntity(t,n));case Ve.NumericStart:return this.stateNumericStart(t,n);case Ve.NumericDecimal:return this.stateNumericDecimal(t,n);case Ve.NumericHex:return this.stateNumericHex(t,n);case Ve.NamedEntity:return this.stateNamedEntity(t,n)}}stateNumericStart(t,n){return n>=t.length?-1:(t.charCodeAt(n)|Du)===Qe.LOWER_X?(this.state=Ve.NumericHex,this.consumed+=1,this.stateNumericHex(t,n+1)):(this.state=Ve.NumericDecimal,this.stateNumericDecimal(t,n))}addToNumericResult(t,n,a,o){if(n!==a){const i=a-n;this.result=this.result*Math.pow(o,i)+Number.parseInt(t.substr(n,i),o),this.consumed+=i}}stateNumericHex(t,n){const a=n;for(;n<t.length;){const o=t.charCodeAt(n);if(Kn(o)||Ou(o))n+=1;else return this.addToNumericResult(t,a,n,16),this.emitNumericEntity(o,3)}return this.addToNumericResult(t,a,n,16),-1}stateNumericDecimal(t,n){const a=n;for(;n<t.length;){const o=t.charCodeAt(n);if(Kn(o))n+=1;else return this.addToNumericResult(t,a,n,10),this.emitNumericEntity(o,2)}return this.addToNumericResult(t,a,n,10),-1}emitNumericEntity(t,n){var a;if(this.consumed<=n)return(a=this.errors)===null||a===void 0||a.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===Qe.SEMI)this.consumed+=1;else if(this.decodeMode===Nt.Strict)return 0;return this.emitCodePoint(Pu(this.result),this.consumed),this.errors&&(t!==Qe.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,n){const{decodeTree:a}=this;let o=a[this.treeIndex],i=(o&Lt.VALUE_LENGTH)>>14;for(;n<t.length;n++,this.excess++){const c=t.charCodeAt(n);if(this.treeIndex=Hu(a,o,this.treeIndex+Math.max(1,i),c),this.treeIndex<0)return this.result===0||this.decodeMode===Nt.Attribute&&(i===0||Bu(c))?0:this.emitNotTerminatedNamedEntity();if(o=a[this.treeIndex],i=(o&Lt.VALUE_LENGTH)>>14,i!==0){if(c===Qe.SEMI)return this.emitNamedEntityData(this.treeIndex,i,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:a}=this,o=(a[n]&Lt.VALUE_LENGTH)>>14;return this.emitNamedEntityData(n,o,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,n,a){const{decodeTree:o}=this;return this.emitCodePoint(n===1?o[t]&~Lt.VALUE_LENGTH:o[t+1],a),n===3&&this.emitCodePoint(o[t+2],a),a}end(){var t;switch(this.state){case Ve.NamedEntity:return this.result!==0&&(this.decodeMode!==Nt.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case Ve.NumericDecimal:return this.emitNumericEntity(0,2);case Ve.NumericHex:return this.emitNumericEntity(0,3);case Ve.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case Ve.EntityStart:return 0}}}function Hu(e,t,n,a){const o=(t&Lt.BRANCH_LENGTH)>>7,i=t&Lt.JUMP_TABLE;if(o===0)return i!==0&&a===i?n:-1;if(i){const u=a-i;return u<0||u>=o?-1:e[n+u]-1}let c=n,d=c+o-1;for(;c<=d;){const u=c+d>>>1,f=e[u];if(f<a)c=u+1;else if(f>a)d=u-1;else return e[u+o]}return-1}var V;(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/"})(V||(V={}));var Ut;(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"})(Ut||(Ut={}));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 Uu=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 is(e){var t;return(t=Uu.get(e))!==null&&t!==void 0?t:r.UNKNOWN}const te=r,qu={[V.HTML]:new Set([te.ADDRESS,te.APPLET,te.AREA,te.ARTICLE,te.ASIDE,te.BASE,te.BASEFONT,te.BGSOUND,te.BLOCKQUOTE,te.BODY,te.BR,te.BUTTON,te.CAPTION,te.CENTER,te.COL,te.COLGROUP,te.DD,te.DETAILS,te.DIR,te.DIV,te.DL,te.DT,te.EMBED,te.FIELDSET,te.FIGCAPTION,te.FIGURE,te.FOOTER,te.FORM,te.FRAME,te.FRAMESET,te.H1,te.H2,te.H3,te.H4,te.H5,te.H6,te.HEAD,te.HEADER,te.HGROUP,te.HR,te.HTML,te.IFRAME,te.IMG,te.INPUT,te.LI,te.LINK,te.LISTING,te.MAIN,te.MARQUEE,te.MENU,te.META,te.NAV,te.NOEMBED,te.NOFRAMES,te.NOSCRIPT,te.OBJECT,te.OL,te.P,te.PARAM,te.PLAINTEXT,te.PRE,te.SCRIPT,te.SECTION,te.SELECT,te.SOURCE,te.STYLE,te.SUMMARY,te.TABLE,te.TBODY,te.TD,te.TEMPLATE,te.TEXTAREA,te.TFOOT,te.TH,te.THEAD,te.TITLE,te.TR,te.TRACK,te.UL,te.WBR,te.XMP]),[V.MATHML]:new Set([te.MI,te.MO,te.MN,te.MS,te.MTEXT,te.ANNOTATION_XML]),[V.SVG]:new Set([te.TITLE,te.FOREIGN_OBJECT,te.DESC]),[V.XLINK]:new Set,[V.XML]:new Set,[V.XMLNS]:new Set},Yn=new Set([te.H1,te.H2,te.H3,te.H4,te.H5,te.H6]);A.STYLE,A.SCRIPT,A.XMP,A.IFRAME,A.NOEMBED,A.NOFRAMES,A.PLAINTEXT;var h;(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"})(h||(h={}));const We={DATA:h.DATA,RCDATA:h.RCDATA,RAWTEXT:h.RAWTEXT,SCRIPT_DATA:h.SCRIPT_DATA,PLAINTEXT:h.PLAINTEXT,CDATA_SECTION:h.CDATA_SECTION};function $u(e){return e>=p.DIGIT_0&&e<=p.DIGIT_9}function fs(e){return e>=p.LATIN_CAPITAL_A&&e<=p.LATIN_CAPITAL_Z}function Wu(e){return e>=p.LATIN_SMALL_A&&e<=p.LATIN_SMALL_Z}function wt(e){return Wu(e)||fs(e)}function li(e){return wt(e)||$u(e)}function Ms(e){return e+32}function jr(e){return e===p.SPACE||e===p.LINE_FEED||e===p.TABULATION||e===p.FORM_FEED}function ci(e){return jr(e)||e===p.SOLIDUS||e===p.GREATER_THAN_SIGN}function Ku(e){return e===p.NULL?O.nullCharacterReference:e>1114111?O.characterReferenceOutsideUnicodeRange:Sr(e)?O.surrogateCharacterReference:wr(e)?O.noncharacterCharacterReference:Ar(e)||e===p.CARRIAGE_RETURN?O.controlCharacterReference:null}class Yu{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=h.DATA,this.returnState=h.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new ju(n),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new Fu(Lu,(a,o)=>{this.preprocessor.pos=this.entityStartPos+o-1,this._flushCodePointConsumedAsCharacterReference(a)},n.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(O.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:a=>{this._err(O.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+a)},validateNumericCharacterReference:a=>{const o=Ku(a);o&&this._err(o,1)}}:void 0)}_err(t,n=0){var a,o;(o=(a=this.handler).onParseError)===null||o===void 0||o.call(a,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,a){this.active=!0,this.preprocessor.write(t,n),this._runParsingLoop(),this.paused||a?.()}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:Pe.START_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:Pe.END_TAG,tagName:"",tagID:r.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:Pe.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:Pe.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 a=this.currentToken;if(Ir(a,this.currentAttr.name)===null){if(a.attrs.push(this.currentAttr),a.location&&this.currentLocation){const o=(t=(n=a.location).attrs)!==null&&t!==void 0?t:n.attrs=Object.create(null);o[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(O.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=is(t.tagName),t.type===Pe.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(O.endTagWithAttributes),t.selfClosing&&this._err(O.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 Pe.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case Pe.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case Pe.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:Pe.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=jr(t)?Pe.WHITESPACE_CHARACTER:t===p.NULL?Pe.NULL_CHARACTER:Pe.CHARACTER;this._appendCharToCurrentCharacterToken(n,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(Pe.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=h.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Nt.Attribute:Nt.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===h.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===h.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===h.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case h.DATA:{this._stateData(t);break}case h.RCDATA:{this._stateRcdata(t);break}case h.RAWTEXT:{this._stateRawtext(t);break}case h.SCRIPT_DATA:{this._stateScriptData(t);break}case h.PLAINTEXT:{this._statePlaintext(t);break}case h.TAG_OPEN:{this._stateTagOpen(t);break}case h.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case h.TAG_NAME:{this._stateTagName(t);break}case h.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case h.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case h.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case h.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case h.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case h.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case h.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case h.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case h.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case h.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case h.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case h.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case h.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case h.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case h.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case h.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case h.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case h.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case h.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case h.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case h.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case h.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case h.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case h.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case h.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case h.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case h.BOGUS_COMMENT:{this._stateBogusComment(t);break}case h.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case h.COMMENT_START:{this._stateCommentStart(t);break}case h.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case h.COMMENT:{this._stateComment(t);break}case h.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case h.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case h.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case h.COMMENT_END:{this._stateCommentEnd(t);break}case h.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case h.DOCTYPE:{this._stateDoctype(t);break}case h.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case h.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case h.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case h.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case h.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case h.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case h.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case h.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case h.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case h.CDATA_SECTION:{this._stateCdataSection(t);break}case h.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case h.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case h.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case h.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case p.LESS_THAN_SIGN:{this.state=h.TAG_OPEN;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(O.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=h.RCDATA_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case p.LESS_THAN_SIGN:{this.state=h.RAWTEXT_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(wt(t))this._createStartTagToken(),this.state=h.TAG_NAME,this._stateTagName(t);else switch(t){case p.EXCLAMATION_MARK:{this.state=h.MARKUP_DECLARATION_OPEN;break}case p.SOLIDUS:{this.state=h.END_TAG_OPEN;break}case p.QUESTION_MARK:{this._err(O.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=h.BOGUS_COMMENT,this._stateBogusComment(t);break}case p.EOF:{this._err(O.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(O.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=h.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(wt(t))this._createEndTagToken(),this.state=h.TAG_NAME,this._stateTagName(t);else switch(t){case p.GREATER_THAN_SIGN:{this._err(O.missingEndTagName),this.state=h.DATA;break}case p.EOF:{this._err(O.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(O.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=h.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=h.BEFORE_ATTRIBUTE_NAME;break}case p.SOLIDUS:{this.state=h.SELF_CLOSING_START_TAG;break}case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentTagToken();break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.tagName+=Ue;break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:n.tagName+=String.fromCodePoint(fs(t)?Ms(t):t)}}_stateRcdataLessThanSign(t){t===p.SOLIDUS?this.state=h.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=h.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){wt(t)?(this.state=h.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=h.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=h.BEFORE_ATTRIBUTE_NAME,!1;case p.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=h.SELF_CLOSING_START_TAG,!1;case p.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=h.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===p.SOLIDUS?this.state=h.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){wt(t)?(this.state=h.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case p.SOLIDUS:{this.state=h.SCRIPT_DATA_END_TAG_OPEN;break}case p.EXCLAMATION_MARK:{this.state=h.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=h.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){wt(t)?(this.state=h.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===p.HYPHEN_MINUS?(this.state=h.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===p.HYPHEN_MINUS?(this.state=h.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=h.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_ESCAPED,this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case p.HYPHEN_MINUS:{this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case p.GREATER_THAN_SIGN:{this.state=h.SCRIPT_DATA,this._emitChars(">");break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_ESCAPED,this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===p.SOLIDUS?this.state=h.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:wt(t)?(this._emitChars("<"),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){wt(t)?(this.state=h.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(st.SCRIPT,!1)&&ci(this.preprocessor.peek(st.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<st.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=h.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.NULL:{this._err(O.unexpectedNullCharacter),this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case p.LESS_THAN_SIGN:{this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.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=h.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case p.GREATER_THAN_SIGN:{this.state=h.SCRIPT_DATA,this._emitChars(">");break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Ue);break}case p.EOF:{this._err(O.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===p.SOLIDUS?(this.state=h.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=h.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(st.SCRIPT,!1)&&ci(this.preprocessor.peek(st.SCRIPT.length))){this._emitCodePoint(t);for(let n=0;n<st.SCRIPT.length;n++)this._emitCodePoint(this._consume());this.state=h.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=h.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=h.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case p.EQUALS_SIGN:{this._err(O.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=h.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=h.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=h.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case p.EQUALS_SIGN:{this._leaveAttrName(),this.state=h.BEFORE_ATTRIBUTE_VALUE;break}case p.QUOTATION_MARK:case p.APOSTROPHE:case p.LESS_THAN_SIGN:{this._err(O.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.name+=Ue;break}default:this.currentAttr.name+=String.fromCodePoint(fs(t)?Ms(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=h.SELF_CLOSING_START_TAG;break}case p.EQUALS_SIGN:{this.state=h.BEFORE_ATTRIBUTE_VALUE;break}case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=h.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=h.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this.state=h.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingAttributeValue),this.state=h.DATA,this.emitCurrentTagToken();break}default:this.state=h.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case p.QUOTATION_MARK:{this.state=h.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=Ue;break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case p.APOSTROPHE:{this.state=h.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=Ue;break}case p.EOF:{this._err(O.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=h.BEFORE_ATTRIBUTE_NAME;break}case p.AMPERSAND:{this._startCharacterReference();break}case p.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=h.DATA,this.emitCurrentTagToken();break}case p.NULL:{this._err(O.unexpectedNullCharacter),this.currentAttr.value+=Ue;break}case p.QUOTATION_MARK:case p.APOSTROPHE:case p.LESS_THAN_SIGN:case p.EQUALS_SIGN:case p.GRAVE_ACCENT:{this._err(O.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case p.EOF:{this._err(O.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=h.BEFORE_ATTRIBUTE_NAME;break}case p.SOLIDUS:{this._leaveAttrValue(),this.state=h.SELF_CLOSING_START_TAG;break}case p.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=h.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._err(O.missingWhitespaceBetweenAttributes),this.state=h.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case p.GREATER_THAN_SIGN:{const n=this.currentToken;n.selfClosing=!0,this.state=h.DATA,this.emitCurrentTagToken();break}case p.EOF:{this._err(O.eofInTag),this._emitEOFToken();break}default:this._err(O.unexpectedSolidusInTag),this.state=h.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentComment(n);break}case p.EOF:{this.emitCurrentComment(n),this._emitEOFToken();break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.data+=Ue;break}default:n.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(st.DASH_DASH,!0)?(this._createCommentToken(st.DASH_DASH.length+1),this.state=h.COMMENT_START):this._consumeSequenceIfMatch(st.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(st.DOCTYPE.length+1),this.state=h.DOCTYPE):this._consumeSequenceIfMatch(st.CDATA_START,!0)?this.inForeignNode?this.state=h.CDATA_SECTION:(this._err(O.cdataInHtmlContent),this._createCommentToken(st.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=h.BOGUS_COMMENT):this._ensureHibernation()||(this._err(O.incorrectlyOpenedComment),this._createCommentToken(2),this.state=h.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case p.HYPHEN_MINUS:{this.state=h.COMMENT_START_DASH;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptClosingOfEmptyComment),this.state=h.DATA;const n=this.currentToken;this.emitCurrentComment(n);break}default:this.state=h.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=h.COMMENT_END;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptClosingOfEmptyComment),this.state=h.DATA,this.emitCurrentComment(n);break}case p.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=h.COMMENT,this._stateComment(t)}}_stateComment(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=h.COMMENT_END_DASH;break}case p.LESS_THAN_SIGN:{n.data+="<",this.state=h.COMMENT_LESS_THAN_SIGN;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.data+=Ue;break}case p.EOF:{this._err(O.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=h.COMMENT_LESS_THAN_SIGN_BANG;break}case p.LESS_THAN_SIGN:{n.data+="<";break}default:this.state=h.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===p.HYPHEN_MINUS?this.state=h.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=h.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===p.HYPHEN_MINUS?this.state=h.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=h.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==p.GREATER_THAN_SIGN&&t!==p.EOF&&this._err(O.nestedComment),this.state=h.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{this.state=h.COMMENT_END;break}case p.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="-",this.state=h.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentComment(n);break}case p.EXCLAMATION_MARK:{this.state=h.COMMENT_END_BANG;break}case p.HYPHEN_MINUS:{n.data+="-";break}case p.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--",this.state=h.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const n=this.currentToken;switch(t){case p.HYPHEN_MINUS:{n.data+="--!",this.state=h.COMMENT_END_DASH;break}case p.GREATER_THAN_SIGN:{this._err(O.incorrectlyClosedComment),this.state=h.DATA,this.emitCurrentComment(n);break}case p.EOF:{this._err(O.eofInComment),this.emitCurrentComment(n),this._emitEOFToken();break}default:n.data+="--!",this.state=h.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case p.SPACE:case p.LINE_FEED:case p.TABULATION:case p.FORM_FEED:{this.state=h.BEFORE_DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this.state=h.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case p.EOF:{this._err(O.eofInDoctype),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingWhitespaceBeforeDoctypeName),this.state=h.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(fs(t))this._createDoctypeToken(String.fromCharCode(Ms(t))),this.state=h.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(O.unexpectedNullCharacter),this._createDoctypeToken(Ue),this.state=h.DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypeName),this._createDoctypeToken(null);const n=this.currentToken;n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.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=h.AFTER_DOCTYPE_NAME;break}case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.name+=Ue;break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:n.name+=String.fromCodePoint(fs(t)?Ms(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=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(st.PUBLIC,!1)?this.state=h.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(st.SYSTEM,!1)?this.state=h.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(O.invalidCharacterSequenceAfterDoctypeName),n.forceQuirks=!0,this.state=h.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=h.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.QUOTATION_MARK:{this._err(O.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(O.missingWhitespaceAfterDoctypePublicKeyword),n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.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=h.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.publicId="",this.state=h.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypePublicIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case p.QUOTATION_MARK:{this.state=h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.publicId+=Ue;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.publicId+=Ue;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptDoctypePublicIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case p.GREATER_THAN_SIGN:{this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.QUOTATION_MARK:{this._err(O.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(O.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.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=h.DATA;break}case p.QUOTATION_MARK:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.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=h.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.QUOTATION_MARK:{this._err(O.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{this._err(O.missingWhitespaceAfterDoctypeSystemKeyword),n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.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=h.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case p.APOSTROPHE:{n.systemId="",this.state=h.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case p.GREATER_THAN_SIGN:{this._err(O.missingDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.DATA,this.emitCurrentDoctype(n);break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.missingQuoteBeforeDoctypeSystemIdentifier),n.forceQuirks=!0,this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const n=this.currentToken;switch(t){case p.QUOTATION_MARK:{this.state=h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.systemId+=Ue;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case p.NULL:{this._err(O.unexpectedNullCharacter),n.systemId+=Ue;break}case p.GREATER_THAN_SIGN:{this._err(O.abruptDoctypeSystemIdentifier),n.forceQuirks=!0,this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.EOF:{this._err(O.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=h.DATA;break}case p.EOF:{this._err(O.eofInDoctype),n.forceQuirks=!0,this.emitCurrentDoctype(n),this._emitEOFToken();break}default:this._err(O.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=h.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const n=this.currentToken;switch(t){case p.GREATER_THAN_SIGN:{this.emitCurrentDoctype(n),this.state=h.DATA;break}case p.NULL:{this._err(O.unexpectedNullCharacter);break}case p.EOF:{this.emitCurrentDoctype(n),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case p.RIGHT_SQUARE_BRACKET:{this.state=h.CDATA_SECTION_BRACKET;break}case p.EOF:{this._err(O.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===p.RIGHT_SQUARE_BRACKET?this.state=h.CDATA_SECTION_END:(this._emitChars("]"),this.state=h.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case p.GREATER_THAN_SIGN:{this.state=h.DATA;break}case p.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=h.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()&&li(this.preprocessor.peek(1))?h.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){li(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===p.SEMICOLON&&this._err(O.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const Lr=new Set([r.DD,r.DT,r.LI,r.OPTGROUP,r.OPTION,r.P,r.RB,r.RP,r.RT,r.RTC]),ui=new Set([...Lr,r.CAPTION,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]),sn=new Set([r.APPLET,r.CAPTION,r.HTML,r.MARQUEE,r.OBJECT,r.TABLE,r.TD,r.TEMPLATE,r.TH]),Gu=new Set([...sn,r.OL,r.UL]),zu=new Set([...sn,r.BUTTON]),di=new Set([r.ANNOTATION_XML,r.MI,r.MN,r.MO,r.MS,r.MTEXT]),mi=new Set([r.DESC,r.FOREIGN_OBJECT,r.TITLE]),Vu=new Set([r.TR,r.TEMPLATE,r.HTML]),Qu=new Set([r.TBODY,r.TFOOT,r.THEAD,r.TEMPLATE,r.HTML]),Xu=new Set([r.TABLE,r.TEMPLATE,r.HTML]),Ju=new Set([r.TD,r.TH]);class Zu{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,n,a){this.treeAdapter=n,this.handler=a,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)===V.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 a=this._indexOf(t);this.items[a]=n,a===this.stackTop&&(this.current=n)}insertAfter(t,n,a){const o=this._indexOf(t)+1;this.items.splice(o,0,n),this.tagIDs.splice(o,0,a),this.stackTop++,o===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,o===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])!==V.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 a=this._indexOfTagNames(t,n);this.shortenToLength(Math.max(a,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(Yn,V.HTML)}popUntilTableCellPopped(){this.popUntilPopped(Ju,V.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,n){for(let a=this.stackTop;a>=0;a--)if(t.has(this.tagIDs[a])&&this.treeAdapter.getNamespaceURI(this.items[a])===n)return a;return-1}clearBackTo(t,n){const a=this._indexOfTagNames(t,n);this.shortenToLength(a+1)}clearBackToTableContext(){this.clearBackTo(Xu,V.HTML)}clearBackToTableBodyContext(){this.clearBackTo(Qu,V.HTML)}clearBackToTableRowContext(){this.clearBackTo(Vu,V.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 a=this.stackTop;a>=0;a--){const o=this.tagIDs[a];switch(this.treeAdapter.getNamespaceURI(this.items[a])){case V.HTML:{if(o===t)return!0;if(n.has(o))return!1;break}case V.SVG:{if(mi.has(o))return!1;break}case V.MATHML:{if(di.has(o))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,sn)}hasInListItemScope(t){return this.hasInDynamicScope(t,Gu)}hasInButtonScope(t){return this.hasInDynamicScope(t,zu)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const n=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case V.HTML:{if(Yn.has(n))return!0;if(sn.has(n))return!1;break}case V.SVG:{if(mi.has(n))return!1;break}case V.MATHML:{if(di.has(n))return!1;break}}}return!0}hasInTableScope(t){for(let n=this.stackTop;n>=0;n--)if(this.treeAdapter.getNamespaceURI(this.items[n])===V.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])===V.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])===V.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&&Lr.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&ui.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&ui.has(this.currentTagId);)this.pop()}}const _n=3;var Et;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Et||(Et={}));const pi={type:Et.Marker};class ed{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,n){const a=[],o=n.length,i=this.treeAdapter.getTagName(t),c=this.treeAdapter.getNamespaceURI(t);for(let d=0;d<this.entries.length;d++){const u=this.entries[d];if(u.type===Et.Marker)break;const{element:f}=u;if(this.treeAdapter.getTagName(f)===i&&this.treeAdapter.getNamespaceURI(f)===c){const E=this.treeAdapter.getAttrList(f);E.length===o&&a.push({idx:d,attrs:E})}}return a}_ensureNoahArkCondition(t){if(this.entries.length<_n)return;const n=this.treeAdapter.getAttrList(t),a=this._getNoahArkConditionCandidates(t,n);if(a.length<_n)return;const o=new Map(n.map(c=>[c.name,c.value]));let i=0;for(let c=0;c<a.length;c++){const d=a[c];d.attrs.every(u=>o.get(u.name)===u.value)&&(i+=1,i>=_n&&this.entries.splice(d.idx,1))}}insertMarker(){this.entries.unshift(pi)}pushElement(t,n){this._ensureNoahArkCondition(t),this.entries.unshift({type:Et.Element,element:t,token:n})}insertElementAfterBookmark(t,n){const a=this.entries.indexOf(this.bookmark);this.entries.splice(a,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(pi);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const n=this.entries.find(a=>a.type===Et.Marker||this.treeAdapter.getTagName(a.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 It={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 a=e.childNodes.indexOf(n);e.childNodes.splice(a,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,n,a){const o=e.childNodes.find(i=>i.nodeName==="#documentType");if(o)o.name=t,o.publicId=n,o.systemId=a;else{const i={nodeName:"#documentType",name:t,publicId:n,systemId:a,parentNode:null};It.appendChild(e,i)}},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(It.isTextNode(n)){n.value+=t;return}}It.appendChild(e,It.createTextNode(t))},insertTextBefore(e,t,n){const a=e.childNodes[e.childNodes.indexOf(n)-1];a&&It.isTextNode(a)?a.value+=t:It.insertBefore(e,It.createTextNode(t),n)},adoptAttributes(e,t){const n=new Set(e.attrs.map(a=>a.name));for(let a=0;a<t.length;a++)n.has(t[a].name)||e.attrs.push(t[a])},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}}},Rr="html",td="about:legacy-compat",sd="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",Pr=["+//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//"],nd=[...Pr,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],ad=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),Dr=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],id=[...Dr,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function hi(e,t){return t.some(n=>e.startsWith(n))}function rd(e){return e.name===Rr&&e.publicId===null&&(e.systemId===null||e.systemId===td)}function od(e){if(e.name!==Rr)return ut.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===sd)return ut.QUIRKS;let{publicId:n}=e;if(n!==null){if(n=n.toLowerCase(),ad.has(n))return ut.QUIRKS;let a=t===null?nd:Pr;if(hi(n,a))return ut.QUIRKS;if(a=t===null?Dr:id,hi(n,a))return ut.LIMITED_QUIRKS}return ut.NO_QUIRKS}const fi={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},ld="definitionurl",cd="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])),dd=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:V.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:V.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:V.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:V.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:V.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:V.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:V.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:V.XML}],["xml:space",{prefix:"xml",name:"space",namespace:V.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:V.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:V.XMLNS}]]),md=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])),pd=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 hd(e){const t=e.tagID;return t===r.FONT&&e.attrs.some(({name:a})=>a===Ut.COLOR||a===Ut.SIZE||a===Ut.FACE)||pd.has(t)}function Or(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===ld){e.attrs[t].name=cd;break}}function Mr(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 ma(e){for(let t=0;t<e.attrs.length;t++){const n=dd.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 fd(e){const t=md.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=is(e.tagName))}function gd(e,t){return t===V.MATHML&&(e===r.MI||e===r.MO||e===r.MN||e===r.MS||e===r.MTEXT)}function bd(e,t,n){if(t===V.MATHML&&e===r.ANNOTATION_XML){for(let a=0;a<n.length;a++)if(n[a].name===Ut.ENCODING){const o=n[a].value.toLowerCase();return o===fi.TEXT_HTML||o===fi.APPLICATION_XML}}return t===V.SVG&&(e===r.FOREIGN_OBJECT||e===r.DESC||e===r.TITLE)}function Ed(e,t,n,a){return(!a||a===V.HTML)&&bd(e,t,n)||(!a||a===V.MATHML)&&gd(e,t)}const Td="hidden",xd=8,yd=3;var T;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(T||(T={}));const Nd={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},Br=new Set([r.TABLE,r.TBODY,r.TFOOT,r.THEAD,r.TR]),gi={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:It,onParseError:null};class bi{constructor(t,n,a=null,o=null){this.fragmentContext=a,this.scriptHandler=o,this.currentToken=null,this.stopped=!1,this.insertionMode=T.INITIAL,this.originalInsertionMode=T.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...gi,...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 Yu(this.options,this),this.activeFormattingElements=new ed(this.treeAdapter),this.fragmentContextID=a?is(this.treeAdapter.getTagName(a)):r.UNKNOWN,this._setContextModes(a??this.document,this.fragmentContextID),this.openElements=new Zu(this.document,this.treeAdapter,this)}static parse(t,n){const a=new this(n);return a.tokenizer.write(t,!0),a.document}static getFragmentParser(t,n){const a={...gi,...n};t??(t=a.treeAdapter.createElement(A.TEMPLATE,V.HTML,[]));const o=a.treeAdapter.createElement("documentmock",V.HTML,[]),i=new this(a,o,t);return i.fragmentContextID===r.TEMPLATE&&i.tmplInsertionModeStack.unshift(T.IN_TEMPLATE),i._initTokenizerForFragmentParsing(),i._insertFakeRootElement(),i._resetInsertionMode(),i._findFormInFragmentContext(),i}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),n=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,n),n}_err(t,n,a){var o;if(!this.onParseError)return;const i=(o=t.location)!==null&&o!==void 0?o:Nd,c={code:n,startLine:i.startLine,startCol:i.startCol,startOffset:i.startOffset,endLine:a?i.startLine:i.endLine,endCol:a?i.startCol:i.endCol,endOffset:a?i.startOffset:i.endOffset};this.onParseError(c)}onItemPush(t,n,a){var o,i;(i=(o=this.treeAdapter).onItemPush)===null||i===void 0||i.call(o,t),a&&this.openElements.stackTop>0&&this._setContextModes(t,n)}onItemPop(t,n){var a,o;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(o=(a=this.treeAdapter).onItemPop)===null||o===void 0||o.call(a,t,this.openElements.current),n){let i,c;this.openElements.stackTop===0&&this.fragmentContext?(i=this.fragmentContext,c=this.fragmentContextID):{current:i,currentTagId:c}=this.openElements,this._setContextModes(i,c)}}_setContextModes(t,n){const a=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===V.HTML;this.currentNotInHTML=!a,this.tokenizer.inForeignNode=!a&&t!==void 0&&n!==void 0&&!this._isIntegrationPoint(n,t)}_switchToTextParsing(t,n){this._insertElement(t,V.HTML),this.tokenizer.state=n,this.originalInsertionMode=this.insertionMode,this.insertionMode=T.TEXT}switchToPlaintextParsing(){this.insertionMode=T.TEXT,this.originalInsertionMode=T.IN_BODY,this.tokenizer.state=We.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)!==V.HTML))switch(this.fragmentContextID){case r.TITLE:case r.TEXTAREA:{this.tokenizer.state=We.RCDATA;break}case r.STYLE:case r.XMP:case r.IFRAME:case r.NOEMBED:case r.NOFRAMES:case r.NOSCRIPT:{this.tokenizer.state=We.RAWTEXT;break}case r.SCRIPT:{this.tokenizer.state=We.SCRIPT_DATA;break}case r.PLAINTEXT:{this.tokenizer.state=We.PLAINTEXT;break}}}_setDocumentType(t){const n=t.name||"",a=t.publicId||"",o=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,n,a,o),t.location){const c=this.treeAdapter.getChildNodes(this.document).find(d=>this.treeAdapter.isDocumentTypeNode(d));c&&this.treeAdapter.setNodeSourceCodeLocation(c,t.location)}}_attachElementToTree(t,n){if(this.options.sourceCodeLocationInfo){const a=n&&{...n,startTag:n};this.treeAdapter.setNodeSourceCodeLocation(t,a)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const a=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(a??this.document,t)}}_appendElement(t,n){const a=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(a,t.location)}_insertElement(t,n){const a=this.treeAdapter.createElement(t.tagName,n,t.attrs);this._attachElementToTree(a,t.location),this.openElements.push(a,t.tagID)}_insertFakeElement(t,n){const a=this.treeAdapter.createElement(t,V.HTML,[]);this._attachElementToTree(a,null),this.openElements.push(a,n)}_insertTemplate(t){const n=this.treeAdapter.createElement(t.tagName,V.HTML,t.attrs),a=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(n,a),this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(A.HTML,V.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 a=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(n,a),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(a,t.location)}_insertCharacters(t){let n,a;if(this._shouldFosterParentOnInsertion()?({parent:n,beforeElement:a}=this._findFosterParentingLocation(),a?this.treeAdapter.insertTextBefore(n,t.chars,a):this.treeAdapter.insertText(n,t.chars)):(n=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(n,t.chars)),!t.location)return;const o=this.treeAdapter.getChildNodes(n),i=a?o.lastIndexOf(a):o.length,c=o[i-1];if(this.treeAdapter.getNodeSourceCodeLocation(c)){const{endLine:u,endCol:f,endOffset:E}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(c,{endLine:u,endCol:f,endOffset:E})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(c,t.location)}_adoptNodes(t,n){for(let a=this.treeAdapter.getFirstChild(t);a;a=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(a),this.treeAdapter.appendChild(n,a)}_setEndLocation(t,n){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&n.location){const a=n.location,o=this.treeAdapter.getTagName(t),i=n.type===Pe.END_TAG&&o===n.tagName?{endTag:{...a},endLine:a.endLine,endCol:a.endCol,endOffset:a.endOffset}:{endLine:a.startLine,endCol:a.startCol,endOffset:a.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,i)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let n,a;return this.openElements.stackTop===0&&this.fragmentContext?(n=this.fragmentContext,a=this.fragmentContextID):{current:n,currentTagId:a}=this.openElements,t.tagID===r.SVG&&this.treeAdapter.getTagName(n)===A.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(n)===V.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===r.MGLYPH||t.tagID===r.MALIGNMARK)&&a!==void 0&&!this._isIntegrationPoint(a,n,V.HTML)}_processToken(t){switch(t.type){case Pe.CHARACTER:{this.onCharacter(t);break}case Pe.NULL_CHARACTER:{this.onNullCharacter(t);break}case Pe.COMMENT:{this.onComment(t);break}case Pe.DOCTYPE:{this.onDoctype(t);break}case Pe.START_TAG:{this._processStartTag(t);break}case Pe.END_TAG:{this.onEndTag(t);break}case Pe.EOF:{this.onEof(t);break}case Pe.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,n,a){const o=this.treeAdapter.getNamespaceURI(n),i=this.treeAdapter.getAttrList(n);return Ed(t,o,i,a)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const n=this.activeFormattingElements.entries.findIndex(o=>o.type===Et.Marker||this.openElements.contains(o.element)),a=n===-1?t-1:n-1;for(let o=a;o>=0;o--){const i=this.activeFormattingElements.entries[o];this._insertElement(i.token,this.treeAdapter.getNamespaceURI(i.element)),i.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=T.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(r.P),this.openElements.popUntilTagNamePopped(r.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case r.TR:{this.insertionMode=T.IN_ROW;return}case r.TBODY:case r.THEAD:case r.TFOOT:{this.insertionMode=T.IN_TABLE_BODY;return}case r.CAPTION:{this.insertionMode=T.IN_CAPTION;return}case r.COLGROUP:{this.insertionMode=T.IN_COLUMN_GROUP;return}case r.TABLE:{this.insertionMode=T.IN_TABLE;return}case r.BODY:{this.insertionMode=T.IN_BODY;return}case r.FRAMESET:{this.insertionMode=T.IN_FRAMESET;return}case r.SELECT:{this._resetInsertionModeForSelect(t);return}case r.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case r.HTML:{this.insertionMode=this.headElement?T.AFTER_HEAD:T.BEFORE_HEAD;return}case r.TD:case r.TH:{if(t>0){this.insertionMode=T.IN_CELL;return}break}case r.HEAD:{if(t>0){this.insertionMode=T.IN_HEAD;return}break}}this.insertionMode=T.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let n=t-1;n>0;n--){const a=this.openElements.tagIDs[n];if(a===r.TEMPLATE)break;if(a===r.TABLE){this.insertionMode=T.IN_SELECT_IN_TABLE;return}}this.insertionMode=T.IN_SELECT}_isElementCausesFosterParenting(t){return Br.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)===V.HTML)return{parent:this.treeAdapter.getTemplateContent(n),beforeElement:null};break}case r.TABLE:{const a=this.treeAdapter.getParentNode(n);return a?{parent:a,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 a=this.treeAdapter.getNamespaceURI(t);return qu[a].has(n)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Jm(this,t);return}switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{bs(this,t);break}case T.BEFORE_HEAD:{Es(this,t);break}case T.IN_HEAD:{Ts(this,t);break}case T.IN_HEAD_NO_SCRIPT:{xs(this,t);break}case T.AFTER_HEAD:{ys(this,t);break}case T.IN_BODY:case T.IN_CAPTION:case T.IN_CELL:case T.IN_TEMPLATE:{Hr(this,t);break}case T.TEXT:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Sn(this,t);break}case T.IN_TABLE_TEXT:{Yr(this,t);break}case T.IN_COLUMN_GROUP:{nn(this,t);break}case T.AFTER_BODY:{an(this,t);break}case T.AFTER_AFTER_BODY:{$s(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){Xm(this,t);return}switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{bs(this,t);break}case T.BEFORE_HEAD:{Es(this,t);break}case T.IN_HEAD:{Ts(this,t);break}case T.IN_HEAD_NO_SCRIPT:{xs(this,t);break}case T.AFTER_HEAD:{ys(this,t);break}case T.TEXT:{this._insertCharacters(t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Sn(this,t);break}case T.IN_COLUMN_GROUP:{nn(this,t);break}case T.AFTER_BODY:{an(this,t);break}case T.AFTER_AFTER_BODY:{$s(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){Gn(this,t);return}switch(this.insertionMode){case T.INITIAL:case T.BEFORE_HTML:case T.BEFORE_HEAD:case T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:case T.IN_BODY:case T.IN_TABLE:case T.IN_CAPTION:case T.IN_COLUMN_GROUP:case T.IN_TABLE_BODY:case T.IN_ROW:case T.IN_CELL:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:case T.IN_TEMPLATE:case T.IN_FRAMESET:case T.AFTER_FRAMESET:{Gn(this,t);break}case T.IN_TABLE_TEXT:{ds(this,t);break}case T.AFTER_BODY:{wd(this,t);break}case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{Id(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case T.INITIAL:{jd(this,t);break}case T.BEFORE_HEAD:case T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:{this._err(t,O.misplacedDoctype);break}case T.IN_TABLE_TEXT:{ds(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,O.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?Zm(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{Ld(this,t);break}case T.BEFORE_HEAD:{Pd(this,t);break}case T.IN_HEAD:{gt(this,t);break}case T.IN_HEAD_NO_SCRIPT:{Md(this,t);break}case T.AFTER_HEAD:{Fd(this,t);break}case T.IN_BODY:{Ze(this,t);break}case T.IN_TABLE:{ts(this,t);break}case T.IN_TABLE_TEXT:{ds(this,t);break}case T.IN_CAPTION:{Dm(this,t);break}case T.IN_COLUMN_GROUP:{fa(this,t);break}case T.IN_TABLE_BODY:{hn(this,t);break}case T.IN_ROW:{fn(this,t);break}case T.IN_CELL:{Bm(this,t);break}case T.IN_SELECT:{Vr(this,t);break}case T.IN_SELECT_IN_TABLE:{Hm(this,t);break}case T.IN_TEMPLATE:{qm(this,t);break}case T.AFTER_BODY:{Wm(this,t);break}case T.IN_FRAMESET:{Km(this,t);break}case T.AFTER_FRAMESET:{Gm(this,t);break}case T.AFTER_AFTER_BODY:{Vm(this,t);break}case T.AFTER_AFTER_FRAMESET:{Qm(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?ep(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{Rd(this,t);break}case T.BEFORE_HEAD:{Dd(this,t);break}case T.IN_HEAD:{Od(this,t);break}case T.IN_HEAD_NO_SCRIPT:{Bd(this,t);break}case T.AFTER_HEAD:{Hd(this,t);break}case T.IN_BODY:{pn(this,t);break}case T.TEXT:{Cm(this,t);break}case T.IN_TABLE:{Ss(this,t);break}case T.IN_TABLE_TEXT:{ds(this,t);break}case T.IN_CAPTION:{Om(this,t);break}case T.IN_COLUMN_GROUP:{Mm(this,t);break}case T.IN_TABLE_BODY:{zn(this,t);break}case T.IN_ROW:{zr(this,t);break}case T.IN_CELL:{Fm(this,t);break}case T.IN_SELECT:{Qr(this,t);break}case T.IN_SELECT_IN_TABLE:{Um(this,t);break}case T.IN_TEMPLATE:{$m(this,t);break}case T.AFTER_BODY:{Jr(this,t);break}case T.IN_FRAMESET:{Ym(this,t);break}case T.AFTER_FRAMESET:{zm(this,t);break}case T.AFTER_AFTER_BODY:{$s(this,t);break}}}onEof(t){switch(this.insertionMode){case T.INITIAL:{us(this,t);break}case T.BEFORE_HTML:{bs(this,t);break}case T.BEFORE_HEAD:{Es(this,t);break}case T.IN_HEAD:{Ts(this,t);break}case T.IN_HEAD_NO_SCRIPT:{xs(this,t);break}case T.AFTER_HEAD:{ys(this,t);break}case T.IN_BODY:case T.IN_TABLE:case T.IN_CAPTION:case T.IN_COLUMN_GROUP:case T.IN_TABLE_BODY:case T.IN_ROW:case T.IN_CELL:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:{Wr(this,t);break}case T.TEXT:{_m(this,t);break}case T.IN_TABLE_TEXT:{ds(this,t);break}case T.IN_TEMPLATE:{Xr(this,t);break}case T.AFTER_BODY:case T.IN_FRAMESET:case T.AFTER_FRAMESET:case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{ha(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 T.IN_HEAD:case T.IN_HEAD_NO_SCRIPT:case T.AFTER_HEAD:case T.TEXT:case T.IN_COLUMN_GROUP:case T.IN_SELECT:case T.IN_SELECT_IN_TABLE:case T.IN_FRAMESET:case T.AFTER_FRAMESET:{this._insertCharacters(t);break}case T.IN_BODY:case T.IN_CAPTION:case T.IN_CELL:case T.IN_TEMPLATE:case T.AFTER_BODY:case T.AFTER_AFTER_BODY:case T.AFTER_AFTER_FRAMESET:{Fr(this,t);break}case T.IN_TABLE:case T.IN_TABLE_BODY:case T.IN_ROW:{Sn(this,t);break}case T.IN_TABLE_TEXT:{Kr(this,t);break}}}}function kd(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):$r(e,t),n}function vd(e,t){let n=null,a=e.openElements.stackTop;for(;a>=0;a--){const o=e.openElements.items[a];if(o===t.element)break;e._isSpecialElement(o,e.openElements.tagIDs[a])&&(n=o)}return n||(e.openElements.shortenToLength(Math.max(a,0)),e.activeFormattingElements.removeEntry(t)),n}function Cd(e,t,n){let a=t,o=e.openElements.getCommonAncestor(t);for(let i=0,c=o;c!==n;i++,c=o){o=e.openElements.getCommonAncestor(c);const d=e.activeFormattingElements.getElementEntry(c),u=d&&i>=yd;!d||u?(u&&e.activeFormattingElements.removeEntry(d),e.openElements.remove(c)):(c=_d(e,d),a===t&&(e.activeFormattingElements.bookmark=d),e.treeAdapter.detachNode(a),e.treeAdapter.appendChild(c,a),a=c)}return a}function _d(e,t){const n=e.treeAdapter.getNamespaceURI(t.element),a=e.treeAdapter.createElement(t.token.tagName,n,t.token.attrs);return e.openElements.replace(t.element,a),t.element=a,a}function Sd(e,t,n){const a=e.treeAdapter.getTagName(t),o=is(a);if(e._isElementCausesFosterParenting(o))e._fosterParentElement(n);else{const i=e.treeAdapter.getNamespaceURI(t);o===r.TEMPLATE&&i===V.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,n)}}function Ad(e,t,n){const a=e.treeAdapter.getNamespaceURI(n.element),{token:o}=n,i=e.treeAdapter.createElement(o.tagName,a,o.attrs);e._adoptNodes(t,i),e.treeAdapter.appendChild(t,i),e.activeFormattingElements.insertElementAfterBookmark(i,o),e.activeFormattingElements.removeEntry(n),e.openElements.remove(n.element),e.openElements.insertAfter(t,i,o.tagID)}function pa(e,t){for(let n=0;n<xd;n++){const a=kd(e,t);if(!a)break;const o=vd(e,a);if(!o)break;e.activeFormattingElements.bookmark=a;const i=Cd(e,o,a.element),c=e.openElements.getCommonAncestor(a.element);e.treeAdapter.detachNode(i),c&&Sd(e,c,i),Ad(e,o,a)}}function Gn(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function wd(e,t){e._appendCommentNode(t,e.openElements.items[0])}function Id(e,t){e._appendCommentNode(t,e.document)}function ha(e,t){if(e.stopped=!0,t.location){const n=e.fragmentContext?0:2;for(let a=e.openElements.stackTop;a>=n;a--)e._setEndLocation(e.openElements.items[a],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const a=e.openElements.items[0],o=e.treeAdapter.getNodeSourceCodeLocation(a);if(o&&!o.endTag&&(e._setEndLocation(a,t),e.openElements.stackTop>=1)){const i=e.openElements.items[1],c=e.treeAdapter.getNodeSourceCodeLocation(i);c&&!c.endTag&&e._setEndLocation(i,t)}}}}function jd(e,t){e._setDocumentType(t);const n=t.forceQuirks?ut.QUIRKS:od(t);rd(t)||e._err(t,O.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,n),e.insertionMode=T.BEFORE_HTML}function us(e,t){e._err(t,O.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,ut.QUIRKS),e.insertionMode=T.BEFORE_HTML,e._processToken(t)}function Ld(e,t){t.tagID===r.HTML?(e._insertElement(t,V.HTML),e.insertionMode=T.BEFORE_HEAD):bs(e,t)}function Rd(e,t){const n=t.tagID;(n===r.HTML||n===r.HEAD||n===r.BODY||n===r.BR)&&bs(e,t)}function bs(e,t){e._insertFakeRootElement(),e.insertionMode=T.BEFORE_HEAD,e._processToken(t)}function Pd(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.HEAD:{e._insertElement(t,V.HTML),e.headElement=e.openElements.current,e.insertionMode=T.IN_HEAD;break}default:Es(e,t)}}function Dd(e,t){const n=t.tagID;n===r.HEAD||n===r.BODY||n===r.HTML||n===r.BR?Es(e,t):e._err(t,O.endTagWithoutMatchingOpenElement)}function Es(e,t){e._insertFakeElement(A.HEAD,r.HEAD),e.headElement=e.openElements.current,e.insertionMode=T.IN_HEAD,e._processToken(t)}function gt(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:{e._appendElement(t,V.HTML),t.ackSelfClosing=!0;break}case r.TITLE:{e._switchToTextParsing(t,We.RCDATA);break}case r.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,We.RAWTEXT):(e._insertElement(t,V.HTML),e.insertionMode=T.IN_HEAD_NO_SCRIPT);break}case r.NOFRAMES:case r.STYLE:{e._switchToTextParsing(t,We.RAWTEXT);break}case r.SCRIPT:{e._switchToTextParsing(t,We.SCRIPT_DATA);break}case r.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=T.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(T.IN_TEMPLATE);break}case r.HEAD:{e._err(t,O.misplacedStartTagForHeadElement);break}default:Ts(e,t)}}function Od(e,t){switch(t.tagID){case r.HEAD:{e.openElements.pop(),e.insertionMode=T.AFTER_HEAD;break}case r.BODY:case r.BR:case r.HTML:{Ts(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function Wt(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==r.TEMPLATE&&e._err(t,O.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,O.endTagWithoutMatchingOpenElement)}function Ts(e,t){e.openElements.pop(),e.insertionMode=T.AFTER_HEAD,e._processToken(t)}function Md(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BASEFONT:case r.BGSOUND:case r.HEAD:case r.LINK:case r.META:case r.NOFRAMES:case r.STYLE:{gt(e,t);break}case r.NOSCRIPT:{e._err(t,O.nestedNoscriptInHead);break}default:xs(e,t)}}function Bd(e,t){switch(t.tagID){case r.NOSCRIPT:{e.openElements.pop(),e.insertionMode=T.IN_HEAD;break}case r.BR:{xs(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function xs(e,t){const n=t.type===Pe.EOF?O.openElementsLeftAfterEof:O.disallowedContentInNoscriptInHead;e._err(t,n),e.openElements.pop(),e.insertionMode=T.IN_HEAD,e._processToken(t)}function Fd(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.BODY:{e._insertElement(t,V.HTML),e.framesetOk=!1,e.insertionMode=T.IN_BODY;break}case r.FRAMESET:{e._insertElement(t,V.HTML),e.insertionMode=T.IN_FRAMESET;break}case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:case r.NOFRAMES:case r.SCRIPT:case r.STYLE:case r.TEMPLATE:case r.TITLE:{e._err(t,O.abandonedHeadElementChild),e.openElements.push(e.headElement,r.HEAD),gt(e,t),e.openElements.remove(e.headElement);break}case r.HEAD:{e._err(t,O.misplacedStartTagForHeadElement);break}default:ys(e,t)}}function Hd(e,t){switch(t.tagID){case r.BODY:case r.HTML:case r.BR:{ys(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:e._err(t,O.endTagWithoutMatchingOpenElement)}}function ys(e,t){e._insertFakeElement(A.BODY,r.BODY),e.insertionMode=T.IN_BODY,mn(e,t)}function mn(e,t){switch(t.type){case Pe.CHARACTER:{Hr(e,t);break}case Pe.WHITESPACE_CHARACTER:{Fr(e,t);break}case Pe.COMMENT:{Gn(e,t);break}case Pe.START_TAG:{Ze(e,t);break}case Pe.END_TAG:{pn(e,t);break}case Pe.EOF:{Wr(e,t);break}}}function Fr(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Hr(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function Ud(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function qd(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(n,t.attrs))}function $d(e,t){const n=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&n&&(e.treeAdapter.detachNode(n),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_FRAMESET)}function Wd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML)}function Kd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Yn.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,V.HTML)}function Yd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function Gd(e,t){const n=e.openElements.tmplCount>0;(!e.formElement||n)&&(e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML),n||(e.formElement=e.openElements.current))}function zd(e,t){e.framesetOk=!1;const n=t.tagID;for(let a=e.openElements.stackTop;a>=0;a--){const o=e.openElements.tagIDs[a];if(n===r.LI&&o===r.LI||(n===r.DD||n===r.DT)&&(o===r.DD||o===r.DT)){e.openElements.generateImpliedEndTagsWithExclusion(o),e.openElements.popUntilTagNamePopped(o);break}if(o!==r.ADDRESS&&o!==r.DIV&&o!==r.P&&e._isSpecialElement(e.openElements.items[a],o))break}e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML)}function Vd(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML),e.tokenizer.state=We.PLAINTEXT}function Qd(e,t){e.openElements.hasInScope(r.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.framesetOk=!1}function Xd(e,t){const n=e.activeFormattingElements.getElementEntryInScopeWithTagName(A.A);n&&(pa(e,t),e.openElements.remove(n.element),e.activeFormattingElements.removeEntry(n)),e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Jd(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function Zd(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(r.NOBR)&&(pa(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,V.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function em(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function tm(e,t){e.treeAdapter.getDocumentMode(e.document)!==ut.QUIRKS&&e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._insertElement(t,V.HTML),e.framesetOk=!1,e.insertionMode=T.IN_TABLE}function Ur(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,V.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function qr(e){const t=Ir(e,Ut.TYPE);return t!=null&&t.toLowerCase()===Td}function sm(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,V.HTML),qr(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function nm(e,t){e._appendElement(t,V.HTML),t.ackSelfClosing=!0}function am(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._appendElement(t,V.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function im(e,t){t.tagName=A.IMG,t.tagID=r.IMG,Ur(e,t)}function rm(e,t){e._insertElement(t,V.HTML),e.skipNextNewLine=!0,e.tokenizer.state=We.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=T.TEXT}function om(e,t){e.openElements.hasInButtonScope(r.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,We.RAWTEXT)}function lm(e,t){e.framesetOk=!1,e._switchToTextParsing(t,We.RAWTEXT)}function Ei(e,t){e._switchToTextParsing(t,We.RAWTEXT)}function cm(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===T.IN_TABLE||e.insertionMode===T.IN_CAPTION||e.insertionMode===T.IN_TABLE_BODY||e.insertionMode===T.IN_ROW||e.insertionMode===T.IN_CELL?T.IN_SELECT_IN_TABLE:T.IN_SELECT}function um(e,t){e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,V.HTML)}function dm(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,V.HTML)}function mm(e,t){e.openElements.hasInScope(r.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(r.RTC),e._insertElement(t,V.HTML)}function pm(e,t){e._reconstructActiveFormattingElements(),Or(t),ma(t),t.selfClosing?e._appendElement(t,V.MATHML):e._insertElement(t,V.MATHML),t.ackSelfClosing=!0}function hm(e,t){e._reconstructActiveFormattingElements(),Mr(t),ma(t),t.selfClosing?e._appendElement(t,V.SVG):e._insertElement(t,V.SVG),t.ackSelfClosing=!0}function Ti(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,V.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:{Jd(e,t);break}case r.A:{Xd(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Kd(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:{Wd(e,t);break}case r.LI:case r.DD:case r.DT:{zd(e,t);break}case r.BR:case r.IMG:case r.WBR:case r.AREA:case r.EMBED:case r.KEYGEN:{Ur(e,t);break}case r.HR:{am(e,t);break}case r.RB:case r.RTC:{dm(e,t);break}case r.RT:case r.RP:{mm(e,t);break}case r.PRE:case r.LISTING:{Yd(e,t);break}case r.XMP:{om(e,t);break}case r.SVG:{hm(e,t);break}case r.HTML:{Ud(e,t);break}case r.BASE:case r.LINK:case r.META:case r.STYLE:case r.TITLE:case r.SCRIPT:case r.BGSOUND:case r.BASEFONT:case r.TEMPLATE:{gt(e,t);break}case r.BODY:{qd(e,t);break}case r.FORM:{Gd(e,t);break}case r.NOBR:{Zd(e,t);break}case r.MATH:{pm(e,t);break}case r.TABLE:{tm(e,t);break}case r.INPUT:{sm(e,t);break}case r.PARAM:case r.TRACK:case r.SOURCE:{nm(e,t);break}case r.IMAGE:{im(e,t);break}case r.BUTTON:{Qd(e,t);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{em(e,t);break}case r.IFRAME:{lm(e,t);break}case r.SELECT:{cm(e,t);break}case r.OPTION:case r.OPTGROUP:{um(e,t);break}case r.NOEMBED:case r.NOFRAMES:{Ei(e,t);break}case r.FRAMESET:{$d(e,t);break}case r.TEXTAREA:{rm(e,t);break}case r.NOSCRIPT:{e.options.scriptingEnabled?Ei(e,t):Ti(e,t);break}case r.PLAINTEXT:{Vd(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:Ti(e,t)}}function fm(e,t){if(e.openElements.hasInScope(r.BODY)&&(e.insertionMode=T.AFTER_BODY,e.options.sourceCodeLocationInfo)){const n=e.openElements.tryPeekProperlyNestedBodyElement();n&&e._setEndLocation(n,t)}}function gm(e,t){e.openElements.hasInScope(r.BODY)&&(e.insertionMode=T.AFTER_BODY,Jr(e,t))}function bm(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n))}function Em(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 Tm(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 ym(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.popUntilTagNamePopped(n))}function Nm(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function km(e,t){const n=t.tagID;e.openElements.hasInScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker())}function vm(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(A.BR,r.BR),e.openElements.pop(),e.framesetOk=!1}function $r(e,t){const n=t.tagName,a=t.tagID;for(let o=e.openElements.stackTop;o>0;o--){const i=e.openElements.items[o],c=e.openElements.tagIDs[o];if(a===c&&(a!==r.UNKNOWN||e.treeAdapter.getTagName(i)===n)){e.openElements.generateImpliedEndTagsWithExclusion(a),e.openElements.stackTop>=o&&e.openElements.shortenToLength(o);break}if(e._isSpecialElement(i,c))break}}function pn(e,t){switch(t.tagID){case r.A:case r.B:case r.I:case r.S:case r.U:case r.EM:case r.TT:case r.BIG:case r.CODE:case r.FONT:case r.NOBR:case r.SMALL:case r.STRIKE:case r.STRONG:{pa(e,t);break}case r.P:{Tm(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:{bm(e,t);break}case r.LI:{xm(e);break}case r.DD:case r.DT:{ym(e,t);break}case r.H1:case r.H2:case r.H3:case r.H4:case r.H5:case r.H6:{Nm(e);break}case r.BR:{vm(e);break}case r.BODY:{fm(e,t);break}case r.HTML:{gm(e,t);break}case r.FORM:{Em(e);break}case r.APPLET:case r.OBJECT:case r.MARQUEE:{km(e,t);break}case r.TEMPLATE:{Wt(e,t);break}default:$r(e,t)}}function Wr(e,t){e.tmplInsertionModeStack.length>0?Xr(e,t):ha(e,t)}function Cm(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 _m(e,t){e._err(t,O.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Sn(e,t){if(e.openElements.currentTagId!==void 0&&Br.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=T.IN_TABLE_TEXT,t.type){case Pe.CHARACTER:{Yr(e,t);break}case Pe.WHITESPACE_CHARACTER:{Kr(e,t);break}}else js(e,t)}function Sm(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_CAPTION}function Am(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_COLUMN_GROUP}function wm(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(A.COLGROUP,r.COLGROUP),e.insertionMode=T.IN_COLUMN_GROUP,fa(e,t)}function Im(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_TABLE_BODY}function jm(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(A.TBODY,r.TBODY),e.insertionMode=T.IN_TABLE_BODY,hn(e,t)}function Lm(e,t){e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function Rm(e,t){qr(t)?e._appendElement(t,V.HTML):js(e,t),t.ackSelfClosing=!0}function Pm(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,V.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function ts(e,t){switch(t.tagID){case r.TD:case r.TH:case r.TR:{jm(e,t);break}case r.STYLE:case r.SCRIPT:case r.TEMPLATE:{gt(e,t);break}case r.COL:{wm(e,t);break}case r.FORM:{Pm(e,t);break}case r.TABLE:{Lm(e,t);break}case r.TBODY:case r.TFOOT:case r.THEAD:{Im(e,t);break}case r.INPUT:{Rm(e,t);break}case r.CAPTION:{Sm(e,t);break}case r.COLGROUP:{Am(e,t);break}default:js(e,t)}}function Ss(e,t){switch(t.tagID){case r.TABLE:{e.openElements.hasInTableScope(r.TABLE)&&(e.openElements.popUntilTagNamePopped(r.TABLE),e._resetInsertionMode());break}case r.TEMPLATE:{Wt(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:js(e,t)}}function js(e,t){const n=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,mn(e,t),e.fosterParentingEnabled=n}function Kr(e,t){e.pendingCharacterTokens.push(t)}function Yr(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function ds(e,t){let n=0;if(e.hasNonWhitespacePendingCharacterToken)for(;n<e.pendingCharacterTokens.length;n++)js(e,e.pendingCharacterTokens[n]);else for(;n<e.pendingCharacterTokens.length;n++)e._insertCharacters(e.pendingCharacterTokens[n]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const Gr=new Set([r.CAPTION,r.COL,r.COLGROUP,r.TBODY,r.TD,r.TFOOT,r.TH,r.THEAD,r.TR]);function Dm(e,t){const n=t.tagID;Gr.has(n)?e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_TABLE,ts(e,t)):Ze(e,t)}function Om(e,t){const n=t.tagID;switch(n){case r.CAPTION:case r.TABLE:{e.openElements.hasInTableScope(r.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(r.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_TABLE,n===r.TABLE&&Ss(e,t));break}case r.BODY:case r.COL:case r.COLGROUP:case r.HTML:case r.TBODY:case r.TD:case r.TFOOT:case r.TH:case r.THEAD:case r.TR:break;default:pn(e,t)}}function fa(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.COL:{e._appendElement(t,V.HTML),t.ackSelfClosing=!0;break}case r.TEMPLATE:{gt(e,t);break}default:nn(e,t)}}function Mm(e,t){switch(t.tagID){case r.COLGROUP:{e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=T.IN_TABLE);break}case r.TEMPLATE:{Wt(e,t);break}case r.COL:break;default:nn(e,t)}}function nn(e,t){e.openElements.currentTagId===r.COLGROUP&&(e.openElements.pop(),e.insertionMode=T.IN_TABLE,e._processToken(t))}function hn(e,t){switch(t.tagID){case r.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_ROW;break}case r.TH:case r.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(A.TR,r.TR),e.insertionMode=T.IN_ROW,fn(e,t);break}case r.CAPTION:case r.COL:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE,ts(e,t));break}default:ts(e,t)}}function zn(e,t){const n=t.tagID;switch(t.tagID){case r.TBODY:case r.TFOOT:case r.THEAD:{e.openElements.hasInTableScope(n)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE);break}case r.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE,Ss(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:Ss(e,t)}}function fn(e,t){switch(t.tagID){case r.TH:case r.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,V.HTML),e.insertionMode=T.IN_CELL,e.activeFormattingElements.insertMarker();break}case r.CAPTION:case r.COL:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,hn(e,t));break}default:ts(e,t)}}function zr(e,t){switch(t.tagID){case r.TR:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY);break}case r.TABLE:{e.openElements.hasInTableScope(r.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,zn(e,t));break}case r.TBODY:case r.TFOOT:case r.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(r.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=T.IN_TABLE_BODY,zn(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:Ss(e,t)}}function Bm(e,t){const n=t.tagID;Gr.has(n)?(e.openElements.hasInTableScope(r.TD)||e.openElements.hasInTableScope(r.TH))&&(e._closeTableCell(),fn(e,t)):Ze(e,t)}function Fm(e,t){const n=t.tagID;switch(n){case r.TD:case r.TH:{e.openElements.hasInTableScope(n)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(n),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=T.IN_ROW);break}case r.TABLE:case r.TBODY:case r.TFOOT:case r.THEAD:case r.TR:{e.openElements.hasInTableScope(n)&&(e._closeTableCell(),zr(e,t));break}case r.BODY:case r.CAPTION:case r.COL:case r.COLGROUP:case r.HTML:break;default:pn(e,t)}}function Vr(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,V.HTML);break}case r.OPTGROUP:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._insertElement(t,V.HTML);break}case r.HR:{e.openElements.currentTagId===r.OPTION&&e.openElements.pop(),e.openElements.currentTagId===r.OPTGROUP&&e.openElements.pop(),e._appendElement(t,V.HTML),t.ackSelfClosing=!0;break}case r.INPUT:case r.KEYGEN:case r.TEXTAREA:case r.SELECT:{e.openElements.hasInSelectScope(r.SELECT)&&(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),t.tagID!==r.SELECT&&e._processStartTag(t));break}case r.SCRIPT:case r.TEMPLATE:{gt(e,t);break}}}function Qr(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:{Wt(e,t);break}}}function Hm(e,t){const n=t.tagID;n===r.CAPTION||n===r.TABLE||n===r.TBODY||n===r.TFOOT||n===r.THEAD||n===r.TR||n===r.TD||n===r.TH?(e.openElements.popUntilTagNamePopped(r.SELECT),e._resetInsertionMode(),e._processStartTag(t)):Vr(e,t)}function Um(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)):Qr(e,t)}function qm(e,t){switch(t.tagID){case r.BASE:case r.BASEFONT:case r.BGSOUND:case r.LINK:case r.META:case r.NOFRAMES:case r.SCRIPT:case r.STYLE:case r.TEMPLATE:case r.TITLE:{gt(e,t);break}case r.CAPTION:case r.COLGROUP:case r.TBODY:case r.TFOOT:case r.THEAD:{e.tmplInsertionModeStack[0]=T.IN_TABLE,e.insertionMode=T.IN_TABLE,ts(e,t);break}case r.COL:{e.tmplInsertionModeStack[0]=T.IN_COLUMN_GROUP,e.insertionMode=T.IN_COLUMN_GROUP,fa(e,t);break}case r.TR:{e.tmplInsertionModeStack[0]=T.IN_TABLE_BODY,e.insertionMode=T.IN_TABLE_BODY,hn(e,t);break}case r.TD:case r.TH:{e.tmplInsertionModeStack[0]=T.IN_ROW,e.insertionMode=T.IN_ROW,fn(e,t);break}default:e.tmplInsertionModeStack[0]=T.IN_BODY,e.insertionMode=T.IN_BODY,Ze(e,t)}}function $m(e,t){t.tagID===r.TEMPLATE&&Wt(e,t)}function Xr(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(r.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):ha(e,t)}function Wm(e,t){t.tagID===r.HTML?Ze(e,t):an(e,t)}function Jr(e,t){var n;if(t.tagID===r.HTML){if(e.fragmentContext||(e.insertionMode=T.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===r.HTML){e._setEndLocation(e.openElements.items[0],t);const a=e.openElements.items[1];a&&!(!((n=e.treeAdapter.getNodeSourceCodeLocation(a))===null||n===void 0)&&n.endTag)&&e._setEndLocation(a,t)}}else an(e,t)}function an(e,t){e.insertionMode=T.IN_BODY,mn(e,t)}function Km(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.FRAMESET:{e._insertElement(t,V.HTML);break}case r.FRAME:{e._appendElement(t,V.HTML),t.ackSelfClosing=!0;break}case r.NOFRAMES:{gt(e,t);break}}}function Ym(e,t){t.tagID===r.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==r.FRAMESET&&(e.insertionMode=T.AFTER_FRAMESET))}function Gm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{gt(e,t);break}}}function zm(e,t){t.tagID===r.HTML&&(e.insertionMode=T.AFTER_AFTER_FRAMESET)}function Vm(e,t){t.tagID===r.HTML?Ze(e,t):$s(e,t)}function $s(e,t){e.insertionMode=T.IN_BODY,mn(e,t)}function Qm(e,t){switch(t.tagID){case r.HTML:{Ze(e,t);break}case r.NOFRAMES:{gt(e,t);break}}}function Xm(e,t){t.chars=Ue,e._insertCharacters(t)}function Jm(e,t){e._insertCharacters(t),e.framesetOk=!1}function Zr(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==V.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function Zm(e,t){if(hd(t))Zr(e),e._startTagOutsideForeignContent(t);else{const n=e._getAdjustedCurrentElement(),a=e.treeAdapter.getNamespaceURI(n);a===V.MATHML?Or(t):a===V.SVG&&(fd(t),Mr(t)),ma(t),t.selfClosing?e._appendElement(t,a):e._insertElement(t,a),t.ackSelfClosing=!0}}function ep(e,t){if(t.tagID===r.P||t.tagID===r.BR){Zr(e),e._endTagOutsideForeignContent(t);return}for(let n=e.openElements.stackTop;n>0;n--){const a=e.openElements.items[n];if(e.treeAdapter.getNamespaceURI(a)===V.HTML){e._endTagOutsideForeignContent(t);break}const o=e.treeAdapter.getTagName(a);if(o.toLowerCase()===t.tagName){t.tagName=o,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 tp=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,sp=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),xi={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function eo(e,t){const n=mp(e),a=Gi("type",{handlers:{root:np,element:ap,text:ip,comment:so,doctype:rp,raw:lp},unknown:cp}),o={parser:n?new bi(xi):bi.getFragmentParser(void 0,xi),handle(d){a(d,o)},stitches:!1,options:t||{}};a(e,o),rs(o,qt());const i=n?o.parser.document:o.parser.getFragment(),c=pu(i,{file:o.options.file});return o.stitches&&al(c,"comment",function(d,u,f){const E=d;if(E.value.stitch&&f&&u!==void 0){const g=f.children;return g[u]=E.value.stitch,u}}),c.type==="root"&&c.children.length===1&&c.children[0].type===e.type?c.children[0]:c}function to(e,t){let n=-1;if(e)for(;++n<e.length;)t.handle(e[n])}function np(e,t){to(e.children,t)}function ap(e,t){up(e,t),to(e.children,t),dp(e,t)}function ip(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const n={type:Pe.CHARACTER,chars:e.value,location:Ls(e)};rs(t,qt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function rp(e,t){const n={type:Pe.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Ls(e)};rs(t,qt(e)),t.parser.currentToken=n,t.parser._processToken(t.parser.currentToken)}function op(e,t){t.stitches=!0;const n=pp(e);if("children"in e&&"children"in n){const a=eo({type:"root",children:e.children},t.options);n.children=a.children}so({type:"comment",value:{stitch:n}},t)}function so(e,t){const n=e.value,a={type:Pe.COMMENT,data:n,location:Ls(e)};rs(t,qt(e)),t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken)}function lp(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,no(t,qt(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(tp,"<$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 cp(e,t){const n=e;if(t.options.passThrough&&t.options.passThrough.includes(n.type))op(n,t);else{let a="";throw sp.has(n.type)&&(a=". 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"+a)}}function rs(e,t){no(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=We.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 no(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===We.PLAINTEXT)return;rs(t,qt(e));const a=t.parser.openElements.current;let o="namespaceURI"in a?a.namespaceURI:Bt.html;o===Bt.html&&n==="svg"&&(o=Bt.svg);const i=Eu({...e,children:[]},{space:o===Bt.svg?"svg":"html"}),c={type:Pe.START_TAG,tagName:n,tagID:is(n),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in i?i.attrs:[],location:Ls(e)};t.parser.currentToken=c,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=n}function dp(e,t){const n=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&_u.includes(n)||t.parser.tokenizer.state===We.PLAINTEXT)return;rs(t,zi(e));const a={type:Pe.END_TAG,tagName:n,tagID:is(n),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:Ls(e)};t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken),n===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===We.RCDATA||t.parser.tokenizer.state===We.RAWTEXT||t.parser.tokenizer.state===We.SCRIPT_DATA)&&(t.parser.tokenizer.state=We.DATA)}function mp(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function Ls(e){const t=qt(e)||{line:void 0,column:void 0,offset:void 0},n=zi(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 pp(e){return"children"in e?_a({...e,children:[]}):_a(e)}function hp(e){return function(t,n){return eo(t,{...e,file:n})}}const rn=l.memo(function({text:t}){const n=Le(),[a,o]=l.useState(!1);return t?s.jsx("button",{type:"button",className:"copy-btn",title:n("copy"),onClick:()=>{navigator.clipboard.writeText(t).then(()=>{o(!0),setTimeout(()=>o(!1),1200)})},children:a?s.jsx(Tt,{}):s.jsx(Ct,{})}):null});function fp(e){const t=a=>{if(typeof a=="string"||typeof a=="number"){const o=String(a);return o===""?[[]]:o.split(`
|
|
309
|
+
`).map(i=>i===""?[]:[i])}if(Array.isArray(a)){let o=[];for(const i of a){const c=t(i);if(o.length===0)o=c;else{const d=c[0]??[];o[o.length-1].push(...d),o.push(...c.slice(1))}}return o}if(a&&typeof a=="object"&&"props"in a){const o=a,i=o.props?.children,c={...o.props,children:void 0},d=i==null?[]:t(i);return d.length===0?[[l.createElement(o.type,c)]]:d.map(u=>[l.createElement(o.type,c,...u)])}return[[a]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function Vn(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Vn).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return Vn(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 bp(e){const n=gp(e)?.props?.className;if(typeof n!="string")return null;const a=n.match(/(?:^|\s)language-([A-Za-z0-9_+\-]+)(?:\s|$)/);return a?a[1]:null}const yi="pi-web-ui:plugin-data";let Ns=new Map,ks=new Map,Jt=new Set,Qn=-1,ao=0;const Xn=new Set;function Ep(){ao++;for(const e of Xn)e()}function Tp(e){return Xn.add(e),()=>{Xn.delete(e)}}function Ni(){return ao}let io=null;function xp(e){io=e}function yp(e,t){t!==Qn&&(Qn=t,ks.clear(),Jt.clear());const n=new Map;for(const o of e)if(!(o.error||!o.renderers))for(const i of o.renderers)n.has(i)||n.set(i,o.id);let a=n.size!==Ns.size;if(!a){for(const[o,i]of n)if(Ns.get(o)!==i){a=!0;break}}if(a){for(const o of ks.keys())n.has(o)||ks.delete(o);for(const o of Jt)n.has(o)||Jt.delete(o);Ns=n,Ep()}}async function Np(e,t){const n=Ns.get(e);if(!n)return null;let a=ks.get(e);if(!a&&!Jt.has(e))try{const c=(await import(at(`/plugins/${encodeURIComponent(n)}/client/entry.mjs?e=${Qn}`))).default?.renderers?.[e];typeof c=="function"?(a={pluginId:n,renderer:c},ks.set(e,a)):(Jt.add(e),console.error(`[plugin:${n}] entry.mjs 未提供 renderers["${e}"]`))}catch(i){Jt.add(e),console.error(`[plugin:${n}] renderer 加载失败(${e}):`,i)}if(!a)return null;const o={pluginId:a.pluginId,send:i=>{io?.({type:"plugin_message",pluginId:a.pluginId,payload:i})},onData:i=>{const c=d=>{const u=d.detail;u.pluginId===a.pluginId&&i(u.payload)};return window.addEventListener(yi,c),()=>window.removeEventListener(yi,c)}};try{const i=await a.renderer(t,o);return i instanceof HTMLElement?i:null}catch(i){return console.error(`[plugin:${a.pluginId}] renderer("${e}") 执行失败:`,i),null}}function kp(e){return Ns.has(e)}const Jn="pi-web-ui:theme",ro="dark",ki="theme-stylesheet",Rt="pi-web-ui:theme-change";function oo(){try{const e=localStorage.getItem(Jn);if(e&&e!==ro)return e}catch{}return null}function vp(e){try{e?localStorage.setItem(Jn,e):localStorage.removeItem(Jn)}catch{}}function lo(e){let t=document.getElementById(ki);if(!e){t?.remove(),window.dispatchEvent(new CustomEvent(Rt));return}t||(t=document.createElement("link"),t.id=ki,t.rel="stylesheet",document.head.appendChild(t)),t.href=at(`/themes/${encodeURIComponent(e)}.css`),t.onload=()=>window.dispatchEvent(new CustomEvent(Rt))}async function Cp(){try{const e=await fetch(Dt(at("/api/themes")));if(!e.ok)return[];const t=await e.json();return Array.isArray(t.themes)?t.themes:[]}catch{return[]}}function _p(){const[e,t]=l.useState([]),[n,a]=l.useState(()=>oo());return l.useEffect(()=>{let i=!1;return Cp().then(c=>{i||t(c)}),()=>{i=!0}},[]),l.useEffect(()=>{lo(n),vp(n)},[n]),{themes:e,theme:n,switchTheme:i=>a(i===ro?null:i)}}function a0(){const e=getComputedStyle(document.documentElement),t=(n,a)=>e.getPropertyValue(n).trim()||a;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 Sp({lang:e,code:t}){const n=l.useRef(null),a=l.useRef(null),o=l.useRef(0),i=l.useRef(new WeakMap),[c,d]=l.useState(null);return l.useEffect(()=>{const u=()=>{const f=++o.current,E=a.current;E&&(E.dispatchEvent(new CustomEvent(Rt)),i.current.set(E,f))};return window.addEventListener(Rt,u),()=>window.removeEventListener(Rt,u)},[]),l.useEffect(()=>{let u=!1;const f=o.current;return d(null),Np(e,t).then(E=>{u||(E&&i.current.set(E,f),d(E))}),()=>{u=!0}},[e,t]),l.useEffect(()=>{a.current=c;const u=n.current;return u&&(u.replaceChildren(),c&&(u.appendChild(c),(i.current.get(c)??o.current)<o.current&&(c.dispatchEvent(new CustomEvent(Rt)),i.current.set(c,o.current)))),()=>{a.current===c&&(a.current=null)}},[c]),c?s.jsx("div",{className:"plugin-fence",ref:n}):s.jsxs("div",{className:"codeblock",children:[s.jsx(rn,{text:t}),s.jsx("pre",{children:s.jsx("code",{children:t})})]})}const Ap=[Vi],wp=[Vi,su],vi=[[rl,{detect:!0,ignoreMissing:!0}]];function ga({text:e,rawHtml:t=!1,hardBreaks:n=!1}){const a=t?[hp,...vi]:vi;return s.jsx(il,{remarkPlugins:n?wp:Ap,rehypePlugins:a,components:{pre:Ip},children:e})}const ot=l.memo(function({text:t,rawHtml:n=!1,hardBreaks:a=!1}){return s.jsx("div",{className:"md",children:s.jsx(ga,{text:t,rawHtml:n,hardBreaks:a})})});function Ip({children:e,...t}){l.useSyncExternalStore(Tp,Ni,Ni);const n=bp(e);return n&&kp(n)?s.jsx(Sp,{lang:n,code:Vn(e)}):s.jsx(jp,{children:e,...t})}function jp({children:e,...t}){const n=e&&typeof e=="object"&&"props"in e?e.props?.children:e,a=fp(n),o=a.length>1,i=o?`${String(a.length).length+1}ch`:void 0;return s.jsxs("div",{className:"codeblock",children:[s.jsx(rn,{text:Zn(e)}),s.jsx("pre",{...t,children:a.map((c,d)=>s.jsxs("div",{className:"code-line",children:[o&&s.jsx("span",{className:"code-num",style:i?{width:i}:void 0,children:d+1}),s.jsx("code",{className:"code-line-body hljs",children:c})]},d))})]})}function Zn(e){if(typeof e=="string")return e;if(Array.isArray(e))return e.map(Zn).join("");if(e&&typeof e=="object"&&"props"in e){const t=e.props;return Zn(t?.children)}return""}const Lp=/^\s{0,3}(`{3,}|~{3,})/,Rp=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function An(e){return e.trim()===""}function Ci(e){const t=Lp.exec(e);return t?t[1]:null}function Pp(e){const t=e.split(`
|
|
310
|
+
`),n=[];let a=[],o=null;for(let i=0;i<t.length;i++){const c=t[i];if(o!==null){const u=Ci(c);u&&u[0]===o[0]&&u.length>=o.length&&(o=null),a.push(c);continue}const d=Ci(c);if(d&&!An(c)){o=d,a.push(c);continue}if(An(c)){let u=i;for(;u<t.length&&An(t[u]);)u++;if(!(u<t.length&&Rp.test(t[u]))&&a.length>0){n.push(a.join(`
|
|
311
311
|
`)),a=[];continue}a.push(c);continue}a.push(c)}return{frozen:n,active:a.join(`
|
|
312
|
-
`),inFence:o!==null}}const
|
|
313
|
-
`)[0].slice(0,80),[
|
|
312
|
+
`),inFence:o!==null}}const Dp=l.memo(function({text:t}){return s.jsx(ga,{text:t})}),_i=200;function Op({text:e,inFence:t}){const[n,a]=l.useState(e),o=l.useRef(0),i=l.useRef(null);return l.useEffect(()=>{if(t)return;const c=Date.now()-o.current,d=()=>{o.current=Date.now(),a(e)};if(c>=_i){d();return}return i.current=setTimeout(d,_i-c),()=>{i.current&&clearTimeout(i.current)}},[e,t]),t?s.jsx("div",{className:"codeblock",children:s.jsx("pre",{children:s.jsx("code",{children:e})})}):s.jsx(ga,{text:n})}const Mp=l.memo(function({text:t}){const{frozen:n,active:a,inFence:o}=l.useMemo(()=>Pp(t),[t]);return s.jsxs("div",{className:"md",children:[n.map((i,c)=>s.jsx(Dp,{text:i},c)),a.length>0&&s.jsx(Op,{text:a,inFence:o},n.length)]})});function Bp({thinking:e,streaming:t,wrap:n=!0,forceOpen:a=!1}){const o=Le(),[i,c]=l.useState(null),d=i??n,u=d||a,f=t?e.trimEnd().slice(-80):e.split(`
|
|
313
|
+
`)[0].slice(0,80),[E,g]=l.useState(!1),y=()=>{navigator.clipboard.writeText(e),g(!0),window.setTimeout(()=>g(!1),1200)};return s.jsxs("div",{className:`thinking ${u?"open":""} ${t?"live":""}`,children:[s.jsxs("div",{className:"chead thinking-head",role:"button",tabIndex:0,"aria-expanded":u,title:o(u?"collapseMsg":"expandMsg"),onClick:()=>c(!d),onKeyDown:N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),c(!d))},children:[s.jsx("button",{type:"button",className:"chead-toggle thinking-toggle",title:o(u?"collapseMsg":"expandMsg"),"aria-label":o(u?"collapseMsg":"expandMsg"),"aria-expanded":u,onClick:N=>{N.stopPropagation(),c(!d)},children:u?s.jsx(Ot,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon thinking-icon",children:s.jsx(_s,{})}),s.jsx("span",{className:"chead-title thinking-label",children:t&&u?s.jsxs("span",{className:"thinking-live-label",children:[o("thinkingNow"),s.jsx("span",{className:"dots"})]}):u?o("thinking"):o("thinkingPreview",{preview:f})}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy thinking-copy",title:o(E?"copied":"copyMessage"),"aria-label":o("copyMessage"),onClick:N=>{N.stopPropagation(),y()},children:E?s.jsx(ns,{}):s.jsx(Ct,{})})]}),u&&s.jsx("div",{className:"thinking-body",children:e})]})}const ea=256*1024,Si=300,Fp=/"(path|file_path|filePath|filename|file)"\s*:\s*"((?:[^"\\\n]|\\.){0,4000})"/,Hp=/"(timeout|timeoutSeconds|timeout_seconds|timeoutSec|timeoutMs|timeout_ms|timeoutMilliseconds)"\s*:\s*(-?\d+(?:\.\d+)?)(?![0-9eE.])/,Up=1e9;function qp(e){if(!e)return{};const t=e.length>ea?e.slice(0,ea):e;return{path:Wp(t),timeout:Kp(t),command:Yp(e)}}function $p(e,t=56){if(e.length<=t)return e;const n=e.split(/[\\/]+/).filter(Boolean),a=n[n.length-1];if(!a||n.length<=1)return`…${e.slice(-(t-1))}`;let o=a;for(let i=n.length-2;i>=0;i--){const c=`${n[i]}/${o}`;if(c.length+2>t)break;o=c}return`…/${o}`}function Wp(e){const t=Fp.exec(e);if(!t)return;const a=Gp(t[2]).replace(/[\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim();if(a)return a.length>Si?`${a.slice(0,Si-1)}…`:a}function Kp(e){const t=Hp.exec(e);if(!t)return;const n=Number(t[2]);if(!Number.isFinite(n)||n<=0||n>Up)return;const a=t[1].toLowerCase();return!a.endsWith("ms")&&!a.endsWith("milliseconds")?`${n}s`:n<1e3?`${n}ms`:`${Math.round(n/100)/10}s`}function Yp(e){if(!(e.length>ea))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 Gp(e){try{const t=JSON.parse(`"${e}"`);return typeof t=="string"?t:e}catch{return e}}const zp={bash:"$",read:"📄",write:"✍️",edit:"✏️",edit_soft:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function Vp(e){return zp[e]??"🛠"}const Qp=l.memo(function({block:t,view:n,onKillBash:a,wrap:o=!0,forceOpen:i=!1}){const c=Le(),[d,u]=l.useState(null),f=d??o,E=f||i,[g,y]=l.useState(!1),N=!n.result&&n.streaming&&!n.status,S=t.name==="bash"&&N,M=n.result!==void 0,z=!n.result&&!!n.status,$=n.result?.isError??n.status?.isError??!1,P=(n.result?n.result.content.map(k=>k.type==="text"?k.text:"").join(""):n.liveOutput??"").replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(k,Z)=>c("liveOutputOmitted",{n:Z})),B=$?"err":M?"ok":N||z?"run":"idle";let H=c($?"error":M?"done":N?"running":z?"toolDoneWaitingModel":"toolQueued");const Q=z&&n.status?.durationMs!==void 0?Jp(n.status.durationMs):"";z&&Q&&(H=`${H} · ${Q}`);const re=z&&n.status?.exitCode!==void 0?`exit ${n.status.exitCode}`:"",K=qp(t.argumentsText),j=t.name==="bash"?K.command:void 0,X=()=>{t.argumentsText&&(navigator.clipboard.writeText(t.argumentsText),y(!0),setTimeout(()=>y(!1),1200))};return s.jsxs("div",{className:`toolcall ${B}`,children:[s.jsxs("div",{className:"chead toolcall-head",role:"button",tabIndex:0,"aria-expanded":E,title:c(E?"collapseMsg":"expandMsg"),onClick:()=>u(!f),onKeyDown:k=>{k.target===k.currentTarget&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),u(!f))},children:[s.jsx("button",{type:"button",className:"chead-toggle toolcall-toggle",title:c(E?"collapseMsg":"expandMsg"),"aria-label":c(E?"collapseMsg":"expandMsg"),"aria-expanded":E,onClick:k=>{k.stopPropagation(),u(!f)},children:E?s.jsx(Ot,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon toolcall-icon",children:Vp(t.name)}),s.jsx("span",{className:"chead-title toolcall-name",children:t.name}),s.jsx("span",{className:"toolcall-status",title:re?`${H} · ${re}`:H,"aria-label":re?`${H} · ${re}`:H,children:$?s.jsx($e,{}):M?s.jsx(Tt,{}):N?s.jsx(Rl,{}):z?s.jsx(Bn,{}):s.jsx(Sl,{})}),K.path&&s.jsx("span",{className:"toolcall-path",title:K.path,children:$p(K.path)}),K.timeout&&s.jsxs("span",{className:"toolcall-timeout",children:["⏱ ",K.timeout]}),s.jsx("span",{className:"toolcall-spacer"}),S&&a&&s.jsxs("button",{type:"button",className:"toolcall-kill",title:c("stopBashTip"),onClick:k=>{k.stopPropagation(),a?.()},children:[s.jsx(Vs,{}),s.jsx("span",{children:c("stopBash")})]}),s.jsx("button",{type:"button",className:"chead-copy toolcall-copy",title:c("copyArgs"),onClick:k=>{k.stopPropagation(),X()},children:g?s.jsx(ns,{}):s.jsx(Ct,{})})]}),E&&s.jsxs("div",{className:"toolcall-body",children:[t.argumentsText&&s.jsx("div",{className:"toolcall-args",children:j?s.jsx(Xp,{command:j}):s.jsx("pre",{children:t.argumentsText})}),P.length>0&&s.jsxs("div",{className:"toolcall-output",children:[s.jsxs("div",{className:"toolcall-output-label",children:[c($?"errorOutput":"output"),(N||z)&&s.jsx("span",{className:"cursor"})]}),s.jsx("pre",{children:P})]}),N&&P.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",c("waitingOutput")]}),z&&P.length===0&&s.jsxs("div",{className:"toolcall-waiting",children:[s.jsx("span",{className:"cursor"})," ",c("waitingModel")]})]})]})});function Xp({command:e}){return s.jsxs("div",{className:"termline",children:[s.jsx(Zt,{className:"termline-icon"}),s.jsx("code",{children:e})]})}function Jp(e){if(e===void 0)return"";const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),a=Math.round(t%60);return`${n}m ${String(a).padStart(2,"0")}s`}const Zp=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function ba(e){const t=e.match(Zp);return t?{name:t[1],location:t[2],content:t[3],userMessage:t[4]?.trim()||void 0}:null}const eh=1568,th=2*1024*1024;function vt(e){return e.startsWith("image/")&&e!=="image/svg+xml"&&e!=="image/svg"}async function Ea(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,eh/Math.max(t.width,t.height)),a=Math.max(1,Math.round(t.width*n)),o=Math.max(1,Math.round(t.height*n)),i=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 c=null;for(const[d,u]of i){const f=document.createElement("canvas");f.width=a,f.height=o;const E=f.getContext("2d");if(!E)continue;d!=="image/png"&&(E.fillStyle="#ffffff",E.fillRect(0,0,a,o)),E.drawImage(t,0,0,a,o);const g=f.toDataURL(d,u),y=g.match(/^data:([^;]+);base64,/),N=y?y[1]:d,S=g.replace(/^data:[^;]*;base64,/,""),M=Math.floor(S.length*3/4);if(c={data:S,mimeType:N,name:e.name,size:M},M<=th)return c}return c}finally{t.close()}}const sh=20*1024*1024;function ss(e){return e.type==="text"&&typeof e.text=="string"?e:null}function co(e){return e.type==="thinking"&&typeof e.thinking=="string"?e:null}function uo(e){return e.type==="toolCall"&&typeof e.id=="string"&&typeof e.name=="string"?e:null}function mo(e){return e.type==="image"&&typeof e.dataUrl=="string"?e:null}function po(e){return e.type==="bash"&&typeof e.command=="string"?e:null}function nh(e){return e.imageData?"image":e.uploadPath?"upload":e.fileData?"file":"path"}function ah(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 Ai=l.memo(function({message:t,toolResults:n,liveOutputs:a,toolStatuses:o,streaming:i,isLast:c,onEdit:d,onKillBash:u,onRetry:f,onCollapse:E,questionAttachments:g,qnIndex:y,qnActive:N,onJump:S,thinkingWrap:M,toolsWrap:z,searchActive:$,autoExpand:C}){const P=Le(),[B,H]=l.useState(!1),[Q,re]=l.useState(""),[K,j]=l.useState([]),[X,k]=l.useState(!1),[Z,Y]=l.useState(null),me=F=>{Y(F),window.setTimeout(()=>Y(pe=>pe===F?null:pe),4e3)};if(t.role==="toolResult")return null;if(t.role==="compactionSummary")return s.jsx(oh,{message:t,forceOpen:$,autoExpand:C});const de=t.role==="custom"&&t.customType==="file",w=t.content.map(F=>ss(F)?.text??"").filter(Boolean).join(`
|
|
314
314
|
`),I=t.role==="user"?ba(w):null,L=I?I.userMessage??`skill:${I.name}`:w.split(`
|
|
315
|
-
`).join(" ").trim(),oe=i&&c&&t.content.length===0,se=t.role==="user"&&!i&&!oe&&!!d,ye=async F=>{const pe=[];for(const Ee of F){if(!
|
|
316
|
-
`)),j(
|
|
317
|
-
`).length+1)),onChange:F=>re(F.target.value),onPaste:F=>{const pe=[];for(const Ee of F.clipboardData?.items??[])if(Ee.kind==="file"&&
|
|
318
|
-
`),S=
|
|
319
|
-
`).length,$=!
|
|
320
|
-
`),y=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:a("role.compaction")}),e.timestamp&&s.jsx("span",{className:"msg-time",children:
|
|
321
|
-
`)&&!S.truncated,Q=
|
|
322
|
-
`)}function
|
|
323
|
-
`)}function lh(e,t){let n=0,a=e.indexOf(t);for(;a!==-1;)n++,a=e.indexOf(t,a+t.length);return n}function ch(e,t,n,a){const o=new Map,i=n.toLowerCase();if(!i)return o;for(const c of e){if(!t.has(c.id))continue;const d=lh(oh(c,a).toLowerCase(),i);d>0&&o.set(c.id,d)}return o}function uh(e,t){const n=[],a=t.toLowerCase();if(!a)return n;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(i){const c=i.parentElement;return!c||c.closest(".search-bar")||c.closest(".msg-collapsed")?NodeFilter.FILTER_REJECT:(i.textContent??"").toLowerCase().includes(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let i=o.nextNode();i;i=o.nextNode()){const c=(i.textContent??"").toLowerCase();if(!i.parentElement?.closest("[data-msg-id]"))continue;let d=c.indexOf(a);for(;d!==-1;){const u=document.createRange();u.setStart(i,d),u.setEnd(i,d+a.length),n.push(u),d=c.indexOf(a,d+a.length)}}return n}function dh(e,t,n,a,o){const i=ch(n,a,t,o),c=new Map;for(const u of uh(e,t)){const f=u.startContainer.parentElement?.closest("[data-msg-id]");if(!f?.dataset.msgId)continue;const b=c.get(f.dataset.msgId);b?b.push(u):c.set(f.dataset.msgId,[u])}const d=[];for(const u of n){const f=c.get(u.id);if(f)for(let E=0;E<f.length;E++)d.push({kind:"dom",range:f[E],msgId:u.id,k:E});const b=i.get(u.id);if(b)for(let E=0;E<b;E++)d.push({kind:"folded",msgId:u.id,k:E})}return d}function wn(e,t){return e.findIndex(n=>n.msgId===t.msgId&&n.k===t.k)}function ht(e,t){const n=CSS;if(!n.highlights)return;if(t.length===0){n.highlights.delete(e);return}const a=window.Highlight;a&&n.highlights.set(e,new a(...t))}function mh(e,t){const n=[];let a=e;for(;a&&a!==t;){const o=getComputedStyle(a);/(auto|scroll|hidden)/.test(o.overflowY+o.overflowX)&&(a.scrollHeight>a.clientHeight||a.scrollWidth>a.clientWidth)&&n.push(a),a=a.parentElement}return n}function ph(e,t){const n=t.startContainer.parentElement;for(const d of mh(n,e)){const u=t.getBoundingClientRect(),f=d.getBoundingClientRect();if(u.height<=0||u.width<=0)return;u.top>=f.top+4&&u.bottom<=f.bottom-4||(d.scrollTop+=u.top-f.top-(d.clientHeight-u.height)/2),u.left>=f.left+4&&u.right<=f.right-4||(d.scrollLeft+=u.left-f.left-(d.clientWidth-u.width)/2)}const a=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(a.height<=0||a.width<=0)return;const i=a.top>=o.top+6&&a.bottom<=o.bottom-6,c=a.left>=o.left+6&&a.right<=o.right-6;i&&c||(i||(e.scrollTop+=a.top-o.top-(o.height-a.height)/2),c||(e.scrollLeft+=a.left-o.left-(o.width-a.width)/2))}function hh({containerRef:e,messages:t,collapsedIds:n,toolResults:a,onExpand:o,onProgrammaticScroll:i,open:c,onClose:d}){const u=Le(),f=l.useRef(null),[b,E]=l.useState(""),[y,N]=l.useState(null),[S,M]=l.useState(0),[,z]=l.useState(0),$=l.useDeferredValue(b),v=c?$.trim():"",P=l.useRef(null);P.current=y;const B=l.useRef([]),H=l.useRef({key:null}),Q=l.useRef("");l.useEffect(()=>{c&&(N(null),requestAnimationFrame(()=>f.current?.select()))},[c]),l.useEffect(()=>{if(!c)return;const j=X=>{X.key==="Escape"&&(X.preventDefault(),X.stopPropagation(),d())};return window.addEventListener("keydown",j,!0),()=>window.removeEventListener("keydown",j,!0)},[c,d]),l.useEffect(()=>(c||(ht("msg-search",[]),ht("msg-search-active",[])),()=>{ht("msg-search",[]),ht("msg-search-active",[])}),[c]),l.useLayoutEffect(()=>{const j=()=>{M(0),N(null),z(0),B.current=[],ht("msg-search",[]),ht("msg-search-active",[]),H.current={key:null},Q.current=""};if(!c||!v){j();return}const X=e.current;if(!X)return;let k=!1,Z=0;return Z=requestAnimationFrame(()=>{if(k)return;const Y=dh(X,v,t,n,a);B.current=Y;const me=Y.length;if(M(me),me===0){N(null),z(0),ht("msg-search",[]),ht("msg-search-active",[]),H.current={key:null},Q.current=v;return}const de=P.current;let w;if(de){if(w=wn(Y,de),w===-1){const ye=[];for(let C=0;C<Y.length;C++)Y[C].msgId===de.msgId&&ye.push(C);if(ye.length>0){const C=Math.min(de.k,ye.length-1);w=ye[C]}else w=0}}else w=0;w<0&&(w=0),w>=me&&(w=me-1),(!de||de.msgId!==Y[w].msgId||de.k!==Y[w].k)&&N({msgId:Y[w].msgId,k:Y[w].k}),z(w);const I=Y[w],L=H.current,oe=L.key?.msgId!==I.msgId||L.key?.k!==I.k||L.kind==="folded"&&I.kind==="dom"||v!==Q.current;H.current={key:{msgId:I.msgId,k:I.k},kind:I.kind},Q.current=v;const se=Y.filter(ye=>ye.kind==="dom").map(ye=>ye.range);if(ht("msg-search",se),I.kind==="folded"){ht("msg-search-active",[]),oe&&o(I.msgId);return}ht("msg-search-active",[I.range]),oe&&(i?.(),ph(X,I.range))}),()=>{k=!0,cancelAnimationFrame(Z)}},[c,v,t,e,y,n,a,o,i]);const re=l.useCallback(j=>{const X=B.current,k=X.length;if(k===0)return;const Z=P.current,Y=Z?wn(X,Z):0,me=X[(Y+j+k)%k];N(me.kind==="dom"||me.kind==="folded"?{msgId:me.msgId,k:me.k}:null)},[]);if(!c)return null;const K=y?(()=>{const j=wn(B.current,y);return j===-1?0:j})():0;return s.jsxs("div",{className:"search-bar",role:"search",children:[s.jsx("input",{ref:f,className:"search-input",type:"text",value:b,placeholder:u("searchPlaceholder"),onChange:j=>{E(j.target.value)},onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),re(j.shiftKey?-1:1))}}),s.jsx("span",{className:`search-count ${S===0?"empty":""}`,children:S===0?u("searchNoResults"):`${Math.min(K+1,S)}/${S}`}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchPrev"),disabled:S===0,onClick:()=>re(-1),children:s.jsx(un,{})}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchNext"),disabled:S===0,onClick:()=>re(1),children:s.jsx(Ot,{})}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchClose"),onClick:d,children:s.jsx($e,{})})]})}function fh(e){const{dSt:t,dSh:n,escaped:a,graceActive:o,stuck:i}=e;return o?{flipEscape:!1,reassert:!1}:t>=-4||t<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:i&&!a}:{flipEscape:!0,reassert:!1}}const uo=[{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"}],mo="pi-web-ui:prompt-templates";function gh(){try{const e=localStorage.getItem(mo);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 Ai(e){return uo.some(t=>t.id===e)}function Ms(e){return typeof e.title=="string"}const po=l.createContext(null);function ho(){const e=l.useContext(po);if(!e)throw new Error("useTemplates must be used within TemplateProvider");return e}function bh({send:e,children:t}){const n=Le(),[a,o]=l.useState(gh),[i,c]=l.useState(!1),[d,u]=l.useState(null),[f,b]=l.useState(!1),[E,y]=l.useState(!1),[N,S]=l.useState(!1);l.useEffect(()=>{try{localStorage.setItem(mo,JSON.stringify(a))}catch{}},[a]);const M=l.useMemo(()=>{const Y=new Map,me=new Set;for(const I of a)I.hidden?me.add(I.id):(Ms(I)&&!Ai(I.id)||Ms(I))&&Y.set(I.id,I);const de=uo.filter(I=>!me.has(I.id)).map(I=>{const L=Y.get(I.id);return{id:I.id,icon:L?.icon??I.icon,title:L?.title??n(I.titleKey),desc:L?.desc??n(I.descKey),prompt:L?.prompt??n(I.promptKey),builtin:!0}}),w=a.filter(I=>Ms(I)&&!Ai(I.id)).map(I=>({id:I.id,icon:I.icon??"📌",title:I.title??"",desc:I.desc??"",prompt:I.prompt??""}));return[...de,...w]},[a,n]),z=l.useCallback(()=>c(!0),[]),$=l.useCallback(Y=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:Y}))},[]),v=l.useCallback((Y,me=!1)=>{S(me),Y?(b(!1),u({...Y})):(b(!0),u({id:_t(),icon:"📌",title:"",desc:"",prompt:""}))},[]),P=l.useCallback(()=>{c(!1),u(null),S(!1)},[]),B=l.useCallback(()=>{E?(o([]),y(!1)):(y(!0),setTimeout(()=>y(!1),5e3))},[E]),H=l.useCallback(Y=>{c(!1),$(Y.prompt)},[$]),Q=l.useCallback(Y=>{c(!1),v(Y,!0)},[v]),re=l.useCallback(()=>{c(!1),v(void 0,!0)},[v]),K=l.useCallback(Y=>{o(me=>{const de=me.findIndex(w=>w.id===Y.id);if(de>=0){const w=[...me];return w[de]=Y,w}return[...me,Y]}),u(null),N&&(c(!0),S(!1))},[N]),j=l.useCallback(Y=>{o(me=>Y.builtin?[...me.filter(w=>w.id!==Y.id),{id:Y.id,hidden:!0}]:me.filter(de=>de.id!==Y.id)),u(null),N&&(c(!0),S(!1))},[N]),X=l.useCallback(Y=>{o(me=>me.filter(de=>de.id!==Y.id||de.hidden)),u(null),N&&(c(!0),S(!1))},[N]),k=l.useMemo(()=>({templates:M,fill:$,openPicker:z,openEdit:v,resetConfirm:E,toggleReset:B}),[M,$,z,v,E,B]),Z=d?a.some(Y=>Y.id===d.id&&!Y.hidden&&Ms(Y)):!1;return s.jsxs(po.Provider,{value:k,children:[t,i&&s.jsx(Th,{templates:M,resetConfirm:E,onFill:H,onEditTpl:Q,onNew:re,onResetToggle:B,onClose:P}),d&&s.jsx(xh,{editing:d,isNew:f,hasOverride:Z,onDraft:u,onSave:K,onRestore:()=>X(d),onRemove:()=>j(d),onFill:()=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:d.prompt})),P()},onSend:()=>{const Y=d.prompt.trim();Y&&e({type:"prompt",text:Y,queue:!1})&&P()},onClose:P})]})}function Eh(){const e=Le(),{templates:t,fill:n,openEdit:a,toggleReset:o,resetConfirm:i}=ho();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(c=>s.jsx(fo,{tpl:c,title:e("tpl.clickCard"),onFill:()=>n(c.prompt),onEdit:()=>a(c),editTitle:e("tpl.editTpl")},c.id)),s.jsxs("button",{type:"button",className:"empty-template add",onClick:()=>a(),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:o,children:[s.jsx(Xi,{}),e(i?"tpl.resetConfirm":"tpl.reset")]})})]})}function fo({tpl:e,title:t,onFill:n,onEdit:a,editTitle:o}){const i=Le();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:o??i("tpl.editTpl"),onClick:c=>{c.stopPropagation(),a()},children:s.jsx(Zs,{})})]})}function Th({templates:e,resetConfirm:t,onFill:n,onEditTpl:a,onNew:o,onResetToggle:i,onClose:c}){const d=Le();return l.useEffect(()=>{const u=f=>{f.key==="Escape"&&c()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[c]),s.jsx("div",{className:"modal-backdrop",onClick:c,children:s.jsxs("div",{className:"modal template-picker",onClick:u=>u.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:d("tpl.pickerTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:d("close"),onClick:c,children:s.jsx($e,{})})]}),s.jsx("div",{className:"template-picker-hint",children:d("tpl.pickerHint")})]}),s.jsx("div",{className:"template-picker-scroll",children:s.jsxs("div",{className:"template-picker-grid",children:[e.map(u=>s.jsx(fo,{tpl:u,title:d("tpl.clickCard"),onFill:()=>n(u),onEdit:()=>a(u),editTitle:d("tpl.editTpl")},u.id)),s.jsxs("button",{type:"button",className:"empty-template add",onClick:o,title:d("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:d("tpl.add")}),s.jsx("span",{className:"empty-template-desc",children:d("tpl.addDesc")})]})]})]})}),s.jsx("div",{className:"template-picker-foot",children:s.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:i,children:[s.jsx(Xi,{}),d(t?"tpl.resetConfirm":"tpl.reset")]})})]})})}function xh({editing:e,isNew:t,hasOverride:n,onDraft:a,onSave:o,onRestore:i,onRemove:c,onFill:d,onSend:u,onClose:f}){const b=Le(),E=l.useRef(null);l.useEffect(()=>{const S=M=>{M.key==="Escape"&&f()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[f]),l.useEffect(()=>{const S=E.current;if(!S)return;S.style.height="auto";const M=S.scrollHeight>300;S.style.height=`${Math.min(S.scrollHeight,300)}px`,S.style.overflowY=M?"auto":"hidden"},[e.prompt]);const y=()=>{const S=e.title.trim(),M=e.prompt.trim();if(!S||!M){a({...e,error:b("tpl.required")});return}o({id:e.id,icon:e.icon.trim()||"📌",title:S,desc:e.desc.trim(),prompt:M})},N=!!e.builtin&&!t;return s.jsx("div",{className:"modal-backdrop",onClick:f,children:s.jsxs("div",{className:"modal template-modal",onClick:S=>S.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:b(N?"tpl.builtin":"tpl.custom")}),s.jsx("span",{className:"template-modal-title",children:b(t?"tpl.newTitle":"tpl.editTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:b("close"),onClick:f,children:s.jsx($e,{})})]}),s.jsxs("div",{className:"template-modal-body",children:[s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:b("tpl.fieldIcon")}),s.jsx("input",{className:"template-field-input icon",value:e.icon,maxLength:4,onChange:S=>a({...e,icon:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:b("tpl.fieldTitle")}),s.jsx("input",{className:"template-field-input",value:e.title,placeholder:b("tpl.fieldTitlePh"),onChange:S=>a({...e,title:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:b("tpl.fieldDesc")}),s.jsx("input",{className:"template-field-input",value:e.desc,placeholder:b("tpl.fieldDescPh"),onChange:S=>a({...e,desc:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:b("tpl.fieldPrompt")}),s.jsx("textarea",{ref:E,className:"template-field-prompt",value:e.prompt,placeholder:b("tpl.fieldPromptPh"),onChange:S=>a({...e,prompt:S.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:b("tpl.restoreTip"),onClick:i,children:b("tpl.restore")}),!t&&N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:b("tpl.removeTip"),onClick:c,children:[s.jsx(et,{})," ",b("tpl.remove")]}),!t&&!N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:b("tpl.deleteTip"),onClick:c,children:[s.jsx(et,{})," ",b("tpl.delete")]})]}),s.jsxs("div",{className:"template-modal-actions-right",children:[s.jsx("button",{type:"button",className:"btn template-btn",onClick:y,children:b("tpl.save")}),s.jsx("button",{type:"button",className:"btn template-btn fill",onClick:d,title:b("tpl.fillTip"),children:b("tpl.fill")}),s.jsxs("button",{type:"button",className:"btn template-btn send",onClick:u,title:b("tpl.sendTip"),children:[s.jsx(Qs,{})," ",b("tpl.sendNow")]})]})]})]})})}const wi=new Map,yh=15,Ii=30,In=250,ji=1200,Nh=1600;function kh({compaction:e}){const t=Le(),[,n]=l.useState(0);l.useEffect(()=>{const i=setInterval(()=>n(c=>c+1),1e3);return()=>clearInterval(i)},[]);const a=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3)),o=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")," · ",a,"s"]}),s.jsx("span",{className:"compact-reason",children:o})]})}function Li(e){return e.content.some(t=>t.type==="toolCall")}function Ch({state:e,liveOutputs:t,toolStatuses:n,onEdit:a,onKillBash:o,onRetry:i,onRemoveQueued:c,thinkingWrap:d,toolsWrap:u,jumpTarget:f,onJumpDone:b}){const E=Le(),y=l.useRef(null),[N,S]=l.useState(!0),M=l.useRef(!0),z=l.useRef(0),$=l.useRef(0),v=l.useRef(!1),P=l.useRef(0),[B,H]=l.useState(()=>new Set),[Q,re]=l.useState(!1),K=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,j=l.useMemo(()=>{const R=new Map;for(const W of e.messages)W.role==="toolResult"&&W.toolCallId&&R.set(W.toolCallId,W);return R},[e.messages]),X=l.useMemo(()=>Qp(e.messages),[e.messages]),k=K.length>0?K[K.length-1].id:null,Z=e.messages.length>Ii?Math.max(0,e.messages.length-yh):0,Y=l.useMemo(()=>{const R=new Set;for(let W=0;W<Z;W++){const _e=e.messages[W];_e.role!=="toolResult"&&(B.has(_e.id)||R.add(_e.id))}return R},[e.messages,Z,B]),[me,de]=l.useState(()=>new Set),[w,I]=l.useState(()=>new Set),L=l.useRef(new Map),oe=l.useRef(new Map),se=l.useRef(new Map),ye=l.useRef(0),C=l.useMemo(()=>{const R=new Map;for(const W of e.messages)R.set(W.id,ah(W));return R},[e.messages]),ee=l.useRef(C);ee.current=C;const ce=l.useRef(me);ce.current=me;const ae=e.messages.length>Ii&&!Q,_=l.useRef(ae);_.current=ae;const he=sh(e.messages,L.current,Nh),F=l.useRef(he);F.current=he;const pe=l.useCallback(()=>{const R=y.current;if(!R)return;if(!_.current){de(Fe=>Fe.size?new Set:Fe);return}const W=R.getBoundingClientRect(),_e={top:W.top-ji,bottom:W.bottom+ji},ve=[];for(const[Fe,it]of se.current){const yt=it.getBoundingClientRect();ve.push({id:Fe,top:yt.top,bottom:yt.bottom}),ce.current.has(Fe)||Se(Fe,yt.bottom-yt.top,ee.current.get(Fe))}const Be=eh(ve,_e,F.current,ce.current);for(const Fe of Be.hide){const it=se.current.get(Fe);it&&Se(Fe,it.offsetHeight,ee.current.get(Fe))}de(Fe=>th(Fe,Be))},[]),Ee=l.useCallback(()=>{ye.current||(ye.current=requestAnimationFrame(()=>{ye.current=0,pe()}))},[pe]);l.useLayoutEffect(()=>{pe()},[pe]);const Oe=l.useRef(Q);l.useLayoutEffect(()=>{Oe.current&&!Q&&pe(),Oe.current=Q},[Q,pe]);const Se=l.useCallback((R,W,_e)=>{_e!==void 0&&(oe.current.set(R,{h:W,len:_e}),L.current.set(R,W))},[]),U=l.useCallback((R,W)=>{Se(R,W,ee.current.get(R))},[Se]),ge=l.useCallback(R=>{R&&se.current.set(R.dataset.lazyId??"",R)},[]);l.useEffect(()=>{const R=new Set(e.messages.map(W=>W.id));for(const W of se.current.keys())R.has(W)||(se.current.delete(W),L.current.delete(W),oe.current.delete(W));de(W=>{let _e=!1;const ve=new Set;for(const Be of W)R.has(Be)?ve.add(Be):_e=!0;return _e?ve:W})},[e.messages,B]),l.useEffect(()=>()=>cancelAnimationFrame(ye.current),[]);const ue=l.useMemo(()=>{const R=[];for(const W of e.messages){if(W.role!=="user")continue;const _e=W.content.map(Fe=>ss(Fe)?.text??"").filter(Boolean).join(" "),ve=ba(_e),Be=ve?ve.userMessage??`skill:${ve.name}`:_e.trim();Be&&R.push({id:W.id,text:Be})}return R},[e.messages]),ie=l.useMemo(()=>{const R=new Map;return ue.forEach((W,_e)=>R.set(W.id,_e)),R},[ue]),[G,Te]=l.useState(-1),Re=l.useRef(-1),x=l.useRef(ue);l.useEffect(()=>{x.current=ue},[ue]);const g=l.useCallback(()=>{const R=y.current,W=x.current;if(!R||W.length===0)return;const _e=R.getBoundingClientRect().top,ve=140;let Be=-1;for(let Fe=0;Fe<W.length;Fe++){const it=R.querySelector(`[data-msg-id="${W[Fe].id}"]`);if(it)if(it.getBoundingClientRect().top<=_e+ve)Be=Fe;else break}Be!==Re.current&&(Re.current=Be,Te(Be))},[]);l.useEffect(()=>{g()},[ue,g]);const J=l.useCallback(R=>{H(W=>W.has(R)?W:new Set(W).add(R))},[]);l.useEffect(()=>{const R=W=>{if(!(W.ctrlKey||W.metaKey)||W.key.toLowerCase()!=="f")return;const _e=W.target;_e&&(_e.tagName==="INPUT"||_e.tagName==="TEXTAREA"||_e.isContentEditable)||(W.preventDefault(),re(!0))};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[]);const le=l.useCallback(R=>{H(W=>{if(!W.has(R))return W;const _e=new Set(W);return _e.delete(R),_e})},[]),be=l.useCallback(R=>{const W=e.messages.findIndex(ve=>ve.id===R);Hc.flushSync(()=>{W>=0&&W<Z&&!B.has(R)&&J(R),I(ve=>ve.has(R)?ve:new Set(ve).add(R))});const _e=x.current.findIndex(ve=>ve.id===R);Re.current=_e,Te(_e),requestAnimationFrame(()=>{const ve=y.current?.querySelector(`[data-msg-id="${R}"]`);ve&&(y.current?.querySelectorAll(".msg-flash").forEach(Be=>Be.classList.remove("msg-flash")),ve.scrollIntoView({block:"start"}),ve.classList.remove("msg-flash"),ve.offsetWidth,ve.classList.add("msg-flash"),ve!==y.current?.lastElementChild&&(v.current=!0))})},[e.messages,Z,B,J]),[ke,Ie]=l.useState(null),Ae=l.useRef(null),D=l.useRef(null);l.useEffect(()=>{const R=Ae.current;if(!R||R.convId!==e.conversationId){Ae.current={convId:e.conversationId,ids:new Set(e.messages.filter(W=>W.role==="compactionSummary").map(W=>W.id))},D.current=null,Ie(null);return}for(const W of e.messages)if(W.role==="compactionSummary"&&!R.ids.has(W.id)){R.ids.add(W.id),Ie(W.id);break}},[e.messages,e.conversationId]),l.useEffect(()=>{!ke||D.current===ke||(D.current=ke,be(ke))},[ke,be]);const we=l.useMemo(()=>f?e.messages.find(R=>R.role===f.role&&R.timestamp===f.timestamp)?.id??null:null,[e.messages,f]);l.useEffect(()=>{if(f){if(we){be(we),b?.();return}e.sessionFile===f.path&&e.messages.length>0&&b?.()}},[we,be,b,f,e.sessionFile,e.messages.length]);const Ce=l.useCallback(()=>{const R=y.current;if(!R)return;const W=R.scrollTop-z.current,_e=R.scrollHeight-$.current;z.current=R.scrollTop,$.current=R.scrollHeight;const ve=R.scrollHeight-R.scrollTop-R.clientHeight<80,Be=Date.now()<P.current,Fe=fh({dSt:W,dSh:_e,escaped:v.current,graceActive:Be,stuck:M.current});Fe.reassert&&(P.current=Date.now()+In,R.scrollTop=R.scrollHeight),Fe.flipEscape&&(v.current=!0),ve&&W>=0&&(v.current=!1),Be||(W<0?M.current=ve&&!v.current:ve&&(M.current=!0)),S(M.current),g(),Ee()},[g,Ee]),qe=l.useRef(!1);l.useEffect(()=>{const R=qe.current;if(qe.current=!!e.isStreaming,R&&!e.isStreaming&&!v.current){const W=()=>{const ve=y.current;ve&&!v.current&&(ve.scrollTop=ve.scrollHeight,M.current=!0,S(!0))};requestAnimationFrame(()=>requestAnimationFrame(W));const _e=setTimeout(W,180);return()=>clearTimeout(_e)}},[e.isStreaming]),l.useEffect(()=>{const R=y.current;R&&M.current&&(R.scrollTop=R.scrollHeight)},[K,e.isStreaming,t]);const De=e.queue.steering.join("\0")+""+e.queue.followUp.join("\0");l.useEffect(()=>{const R=y.current;R&&M.current&&(R.scrollTop=R.scrollHeight)},[De]),l.useEffect(()=>{const R=y.current;if(!R||typeof ResizeObserver>"u")return;const W=new ResizeObserver(()=>{M.current&&!v.current&&(R.scrollTop=R.scrollHeight,S(!0))});return W.observe(R),()=>W.disconnect()},[]),l.useEffect(()=>{const R=y.current;if(!R||typeof MutationObserver>"u")return;let W=!1;const _e=new MutationObserver(()=>{W||(W=!0,requestAnimationFrame(()=>{W=!1;const ve=y.current;ve&&M.current&&!v.current&&(ve.scrollTop=ve.scrollHeight,S(!0))}))});return _e.observe(R,{childList:!0,subtree:!0,characterData:!0}),()=>_e.disconnect()},[]);const Xe=l.useCallback(()=>{if(!y.current)return;M.current=!0,v.current=!1,S(!0),P.current=Date.now()+In;const W=()=>{const _e=y.current;!_e||!M.current||v.current||(P.current=Date.now()+In,_e.scrollTop=_e.scrollHeight)};W(),requestAnimationFrame(()=>requestAnimationFrame(W)),setTimeout(W,120),setTimeout(W,300),setTimeout(W,600)},[]),mt=l.useRef(null);l.useEffect(()=>{const R=mt.current,W=y.current;if(!R||!W)return;const _e=ve=>{ve.preventDefault();const Be=R.querySelector(".qn-list");if(Be&&Be.contains(ve.target)&&Be.scrollHeight>Be.clientHeight){Be.scrollTop+=ve.deltaY;return}W.scrollTop+=ve.deltaY};return R.addEventListener("wheel",_e,{passive:!1}),()=>R.removeEventListener("wheel",_e)},[]);const[St,os]=l.useState(0);l.useEffect(()=>{const R=()=>{os(y.current?.clientHeight??0),Ee()};return R(),window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[Ee]);const xt=ue.length,lt=l.useMemo(()=>xt===0?27:Math.max(4,Math.min(27,Math.floor(((St||600)-16)/xt)-3)),[xt,St]),At=lt<20;return s.jsxs("div",{className:"messages-wrap",children:[s.jsxs("div",{className:`messages${Q||N?"":" anchor-live"}`,ref:y,onScroll:Ce,children:[e.messages.length===0&&!e.streamingMessage&&s.jsx("div",{className:"empty-state",children:s.jsx(Eh,{})}),e.messages.map((R,W)=>{const _e=W<Z,ve=_e&&B.has(R.id);if(_e&&!ve)return R.role==="toolResult"?null:s.jsx(Xp,{message:R,onExpand:J},R.id);const Be=R.role==="user"?ie.get(R.id):void 0,Fe=!ae||he.has(R.id)||w.has(R.id)||!me.has(R.id);return s.jsx(Zp,{id:R.id,show:Fe,height:ih(R.id,C.get(R.id)??-1,oe.current,co(R.role,R.customType)),containerRef:y,onMeasured:U,lazyRef:ge,children:s.jsx(Ci,{message:R,qnIndex:Be,qnActive:Be!==void 0?Be===G:void 0,onJump:be,toolResults:j,liveOutputs:Li(R)?t:wi,toolStatuses:n,streaming:e.isStreaming,onKillBash:o,onRetry:R.id===k?i:void 0,toolsWrap:u,thinkingWrap:d,isLast:R.id===k,onEdit:a,questionAttachments:X.get(R.id),onCollapse:ve?le:void 0,searchActive:Q,autoExpand:R.id===ke},R.id)},R.id)}),e.streamingMessage&&s.jsx(Ci,{message:e.streamingMessage,toolResults:j,liveOutputs:Li(e.streamingMessage)?t:wi,toolStatuses:n,streaming:!0,isLast:!0,onEdit:a,onKillBash:o,toolsWrap:u,thinkingWrap:d,searchActive:Q},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?E("retryingApi",{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):E("retryingApiSoon",{error:e.retry.errorMessage})})]}),e.compaction&&s.jsx(kh,{compaction:e.compaction}),e.isStreaming&&K.length===0&&s.jsx("div",{className:"streaming-wait",children:E("waitingResponse")}),e.queue.steering.map((R,W)=>s.jsx("div",{className:"queued-msg",children:s.jsxs("div",{className:"queued-bubble",children:[s.jsx("span",{className:"queued-tag steer",children:E("queueSteerTag")}),s.jsx("div",{className:"queued-text",children:R}),c&&s.jsx("button",{type:"button",className:"queued-remove",title:E("queueRemoveTip"),onClick:()=>c("steer",R),children:"✕"})]})},`q-steer-${W}`)),e.queue.followUp.map((R,W)=>s.jsx("div",{className:"queued-msg",children:s.jsxs("div",{className:"queued-bubble",children:[s.jsx("span",{className:"queued-tag follow",children:E("queueFollowTag")}),s.jsx("div",{className:"queued-text",children:R}),c&&s.jsx("button",{type:"button",className:"queued-remove",title:E("queueRemoveTip"),onClick:()=>c("followUp",R),children:"✕"})]})},`q-fu-${W}`))]}),!N&&s.jsxs("button",{type:"button",className:"scroll-bottom",onClick:Xe,children:[s.jsx(nr,{})," ",E("backToBottom")]}),s.jsx(hh,{containerRef:y,messages:K,collapsedIds:Y,toolResults:j,onExpand:J,onProgrammaticScroll:()=>{v.current=!0,M.current=!1,S(!1)},open:Q,onClose:()=>re(!1)}),ue.length>0&&s.jsxs("div",{className:`qn-rail ${At?"many":""}`,ref:mt,"aria-label":E("questionNavTitle"),style:{"--rail-gap":`${lt}px`},children:[ue.map((R,W)=>s.jsx("button",{type:"button",className:`qn-bar ${W===G?"active":""}`,"aria-label":`${W+1}. ${R.text}`,onClick:()=>be(R.id),children:s.jsxs("span",{className:"qn-bar-text",children:[W+1,". ",R.text]})},R.id)),At&&s.jsx("div",{className:"qn-list",children:ue.map((R,W)=>s.jsxs("button",{type:"button",className:`qn-list-item ${W===G?"active":""}`,"aria-label":`${W+1}. ${R.text}`,onClick:()=>be(R.id),children:[s.jsx("span",{className:"qn-list-idx",children:W+1}),s.jsx("span",{className:"qn-list-text",children:R.text})]},R.id))})]})]})}const go="pi-web-model-usage";function vh(e){if(!e||typeof e!="object")return{};const t={};for(const[n,a]of Object.entries(e)){const o=typeof a=="number"?Math.floor(a):0;Number.isFinite(o)&&o>0&&(t[n]=o)}return t}function _h(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Sh(e,t){const n=t;return e.map((a,o)=>({m:a,i:o,count:n[a.id]??0})).sort((a,o)=>o.count-a.count||a.i-o.i).map(a=>a.m)}function bo(){try{const e=localStorage.getItem(go);return e?vh(JSON.parse(e)):{}}catch{return{}}}function Ah(e){try{localStorage.setItem(go,JSON.stringify(e))}catch{}}function Ri(e){const t=_h(bo(),e);return Ah(t),t}const Ta="pi-web-ui:prompt-history",wh=100,Eo="pi-web-ui:prompt-history-settings",ta={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function To(e){const t=ta;if(!e||typeof e!="object")return{...t};const n=e;let a=typeof n.maxEntries=="number"?Math.floor(n.maxEntries):t.maxEntries;(!Number.isFinite(a)||a<1)&&(a=1),a>500&&(a=500);let o=typeof n.charLimit=="number"?Math.floor(n.charLimit):t.charLimit;(!Number.isFinite(o)||o<100)&&(o=100),o>2e4&&(o=2e4);const i=typeof n.charLimitEnabled=="boolean"?n.charLimitEnabled:t.charLimitEnabled;return{maxEntries:a,charLimitEnabled:i,charLimit:o}}function xo(){try{const e=localStorage.getItem(Eo);return e?To(JSON.parse(e)):{...ta}}catch{return{...ta}}}function jn(e){const t=To(e);try{localStorage.setItem(Eo,JSON.stringify(t))}catch{}try{let n=As();t.charLimitEnabled&&(n=n.map(a=>a.length>t.charLimit?a.slice(0,t.charLimit):a)),n.length>t.maxEntries&&(n=n.slice(n.length-t.maxEntries)),yo(n)}catch{}}function Ih(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="string")continue;const a=n.trim();a&&t.push(a)}return t}function jh(e,t,n=wh){const a=t.trim();if(!a||e.length>0&&e[e.length-1]===a)return e;const o=[...e,a];return o.length>n?o.slice(o.length-n):o}function As(){try{const e=localStorage.getItem(Ta);return e?Ih(JSON.parse(e)):[]}catch{return[]}}function yo(e){let t=e;for(;t;)try{localStorage.setItem(Ta,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 Pi(e){let t=e.trim();if(!t)return;const n=xo();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));const a=As(),o=jh(a,t,n.maxEntries);o!==a&&yo(o)}function Lh(){try{localStorage.removeItem(Ta)}catch{}}function Rh(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 Ph(){return typeof window>"u"||typeof navigator>"u"||typeof window.matchMedia!="function"?!1:Rh({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}const Dh=["off","minimal","low","medium","high","xhigh","max"],Oh=l.memo(function({state:t,models:n,modelsLoading:a,send:o,onManageModels:i,providerKeys:c,compact:d=!1}){const u=Le(),f=t?.model,b=f?`${f.provider}/${f.id}`:null,[E,y]=l.useState(!1),[N,S]=l.useState(!1),[M,z]=l.useState(""),[$,v]=l.useState(null),[P,B]=l.useState({}),H=l.useRef(null),Q=l.useRef(null),[re,K]=l.useState(null);l.useEffect(()=>{if(!E){K(null);return}if(n.length===0)return;const L=requestAnimationFrame(()=>{const oe=Q.current;oe&&K(oe.offsetWidth)});return()=>cancelAnimationFrame(L)},[E,n.length]),l.useEffect(()=>{E&&B(bo())},[E]),l.useEffect(()=>{E||(z(""),v(null))},[E]);const j=l.useMemo(()=>{const L=new Map;for(const se of n)L.set(se.provider,(L.get(se.provider)??0)+1);const oe=[];for(const[se,ye]of[...L.entries()].sort((C,ee)=>C[0].localeCompare(ee[0]))){const C=c[se];if(C&&C.length>1)for(const ee of C)oe.push({provider:se,keyName:ee.name,count:ye});else oe.push({provider:se,keyName:null,count:ye})}return oe},[n,c]),X=l.useMemo(()=>Sh(n,P),[n,P]),k=l.useMemo(()=>{let L=X;$&&(L=L.filter(se=>se.provider===$.provider));const oe=M.trim().toLowerCase();return oe?L.filter(se=>se.name.toLowerCase().includes(oe)||se.provider.toLowerCase().includes(oe)||se.id.toLowerCase().includes(oe)):L},[X,M,$]),Z=l.useMemo(()=>{const L=[];for(const oe of k){const se=c[oe.provider];if(!se||se.length<=1){L.push({model:oe,key:null});continue}let ye=se.find(C=>C.active)??se[0];if($?.provider===oe.provider&&$.keyName){const C=se.find(ee=>ee.name===$.keyName);C&&(ye=C)}L.push({model:oe,key:ye})}return L},[k,c,$]),[Y,me]=l.useState(!1),de=t?.availableThinkingLevels&&t.availableThinkingLevels.length>0?new Set(t.availableThinkingLevels):null,w=Dh.map(L=>({value:L,label:u(`thinking.${L}`),supported:de?de.has(L):!0})),I=L=>w.find(oe=>oe.value===L)?.label??L;return l.useEffect(()=>{E&&n.length===0&&!Y&&!a&&(me(!0),o({type:"list_models"}))},[E,n.length,Y,a,o]),l.useEffect(()=>{n.length>0&&me(!1)},[n.length]),l.useEffect(()=>{if(!E)return;H.current?.querySelector(".dd-item.active")?.scrollIntoView({block:"nearest"})},[E,b,n.length]),s.jsxs(s.Fragment,{children:[s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(_s,{}),s.jsx("span",{className:"chip-model",children:f?f.name:u("selectModel")}),!d&&f?.vision&&s.jsx("span",{className:"chip-vision",title:u("vision"),children:"🖼"}),!d&&f&&s.jsx("span",{className:"chip-sub",children:f.provider})]}),open:E,onOpenChange:y,menuClassName:"dd-menu-model",menuRef:Q,menuStyle:re!=null?{width:re}:void 0,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("availableModels")}),s.jsxs("div",{className:"dd-search-row",children:[s.jsx(Xs,{}),s.jsx("input",{className:"dd-search",type:"text",placeholder:u("searchModels"),value:M,onChange:L=>z(L.target.value)})]}),s.jsxs("div",{className:"dd-model-body",children:[j.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:()=>v(null),children:s.jsx("span",{children:u("allProviders")})}),j.map(L=>{const oe=$?.provider===L.provider&&$?.keyName===L.keyName;return s.jsxs("button",{type:"button",className:`dd-provider-item ${oe?"active":""}`,onClick:()=>v(oe?null:{provider:L.provider,keyName:L.keyName}),title:L.keyName?`${L.provider} · ${L.keyName}`:`${L.provider} · ${L.count}`,children:[s.jsxs("span",{className:"dd-provider-txt",children:[s.jsx("span",{className:"dd-provider-name",children:L.provider}),L.keyName&&s.jsx("span",{className:"dd-provider-key",children:L.keyName})]}),s.jsx("span",{className:"dd-provider-count",children:L.count})]},L.keyName?`${L.provider}::${L.keyName}`:L.provider)})]}),s.jsxs("div",{className:"dd-model-scroll",ref:H,children:[(Y||a)&&s.jsx("div",{className:"dd-loading",children:u("loading")}),n.length===0&&!Y&&!a&&s.jsx("div",{className:"dd-loading",children:u("noModels")}),k.length===0&&n.length>0&&s.jsx("div",{className:"dd-loading",children:u("noModelMatches")}),Z.map(L=>{const oe=L.model,se=b===oe.id&&(!L.key||L.key.active);return s.jsx(nt,{active:se,onClick:()=>{L.key&&!L.key.active&&o({type:"activate_provider_key",provider:oe.provider,keyName:L.key.name}),b!==oe.id&&o({type:"set_model",modelId:oe.id}),y(!1)},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:oe.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:oe.provider}),s.jsx("span",{className:"dd-model-id",children:oe.id.split("/").slice(1).join("/")}),L.key&&s.jsxs("span",{className:`dd-model-key ${L.key.active?"active":""}`,children:[L.key.active?"●":"○"," ",L.key.name]}),(P[oe.id]??0)>0&&s.jsx("span",{className:"dd-model-usage",children:u("modelUsedCount",{n:P[oe.id]})}),(oe.reasoning||oe.vision)&&s.jsxs("span",{className:"dd-model-badges",children:[oe.reasoning&&s.jsx("span",{className:"dd-model-badge",children:u("reasoning")}),oe.vision&&s.jsx("span",{className:"dd-model-badge",children:u("vision")})]})]})]})},L.key?`${oe.id}::${L.key.name}`:oe.id)})]})]}),s.jsxs("div",{className:"dd-footer",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>o({type:"list_models"}),children:u("refreshModels")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{y(!1),i()},children:u("manageModels")})]})]}),s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Fs,{}),s.jsx("span",{className:"chip-sub",children:u("thinkingChip",{level:t?I(t.thinkingLevel):"—"})})]}),open:N,onOpenChange:S,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("thinkingLevel")}),w.map(L=>s.jsx(nt,{active:t?.thinkingLevel===L.value,disabled:!L.supported,title:L.supported?void 0:u("thinkingUnsupported"),onClick:()=>{t?.thinkingLevel!==L.value&&o({type:"set_thinking",level:L.value}),S(!1)},children:L.label},L.value))]})]})}),Di=Ph(),Mh=l.memo(function({ready:t,streaming:n,messages:a,slashCommands:o,modelState:i,models:c,modelsLoading:d,send:u,attachments:f,onRemoveAttachment:b,onAddImageFiles:E,onAddLocalFiles:y,onNotice:N,onSent:S,onManageModels:M,providerKeys:z,quickPhrases:$,quickPhrasesEnabled:v}){const P=Le(),{locale:B}=Mt(),{openPicker:H}=ho(),Q=g=>B!=="zh"&&g.descriptionEn?g.descriptionEn:g.description??"",re=g=>B!=="zh"&&g.argumentHintEn?g.argumentHintEn:g.argumentHint??"",[K,j]=l.useState(""),[X,k]=l.useState(!1),[Z,Y]=l.useState(null),[me,de]=l.useState(0),[w,I]=l.useState(!1),[L,oe]=l.useState(void 0),se=l.useRef(null),ye=l.useRef(null),C=l.useRef(null),ee=l.useRef(-1),ce=l.useRef(""),ae={builtin:P("slashBuiltin"),extension:P("slashExtension"),prompt:P("slashPrompt"),skill:P("slashSkill"),plugin:P("slashPlugin")},_=g=>{const J=g.match(/^\/([^\s]*)$/);if(J&&t){const le=J[1].toLowerCase(),be=o.filter(ke=>ke.name.toLowerCase().startsWith(le));Y(be.length>0?be:null),de(0)}else Y(null)};l.useEffect(()=>{C.current?.querySelector(".slash-item.active")?.scrollIntoView({block:"nearest"})},[me,Z]);const he=g=>{const J=Z??[],le=g??J[me%Math.max(J.length,1)];if(!le){Y(null);return}const be=K.match(/^\/([^\s]*)([\s\S]*)$/),ke=be?be[2]:"";j(`/${le.name} ${ke}`),Y(null),se.current?.focus()},F=async()=>{const le=[...a].reverse().find(be=>be.role==="assistant"&&be.content.some(ke=>ke.type==="text"&&ke.text))?.content.filter(be=>be.type==="text").map(be=>be.text).join(`
|
|
324
|
-
`);if(!le){N("warning",P("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(le),N("info",P("slashCopied"))}catch{N("error",P("slashCopyFailed"))}},pe=
|
|
325
|
-
`),ue=
|
|
326
|
-
`),ie=()=>f.map(g=>g.imageData?{path:"",imageData:g.imageData,mimeType:g.mimeType,name:g.name}:g.fileData?{path:"",fileData:g.fileData,mimeType:g.mimeType,name:g.name,size:g.size}:{path:g.path,mode:g.mode,...g.lines?{lines:g.lines}:{}}),G=(g=!1)=>{const J=K.trim(),le=f.some(be=>be.imageData||be.fileData);if(!(!Se||!J&&!le)){if(J==="/help"){const be=se.current?.closest(".inputbox")?.getBoundingClientRect();oe(be?.width),I(!0),j(""),se.current?.focus();return}if(J==="/copy"){j(""),se.current?.focus(),F();return}if(u({type:"prompt",text:J,queue:g,attachments:ie()})){J&&Pi(J),ee.current=-1,ce.current="",j(""),S();const be=i?.model;be&&Ri(`${be.provider}/${be.id}`),se.current?.focus()}}},Te=g=>{const J=g.trim();if(!(!Se||!J)&&u({type:"prompt",text:J,attachments:ie()})){J&&Pi(J),ee.current=-1,ce.current="",S();const le=i?.model;le&&Ri(`${le.provider}/${le.id}`),Di||se.current?.focus()}},Re=g=>{if(!g.nativeEvent.isComposing){if(Z&&Z.length>0)switch(g.key){case"ArrowDown":g.preventDefault(),de(J=>(J+1)%Z.length);return;case"ArrowUp":g.preventDefault(),de(J=>(J-1+Z.length)%Z.length);return;case"Tab":case"Enter":g.preventDefault(),he();return;case"Escape":g.preventDefault(),Y(null);return}if(g.key==="ArrowUp"||g.key==="ArrowDown"){if(g.ctrlKey||g.metaKey||g.altKey)return;const J=se.current;if(!J)return;const le=g.key==="ArrowUp";if(le&&!ge(J)||!le&&!ue(J)||!le&&ee.current===-1)return;const be=As();if(be.length===0)return;if(g.preventDefault(),le){if(ee.current===-1){ce.current=K;const ke=be.length-1;ee.current=ke;const Ie=be[ke];j(Ie),_(Ie),requestAnimationFrame(()=>{const Ae=se.current;Ae&&(Ae.selectionStart=Ae.selectionEnd=Ie.length)})}else if(ee.current>0){const ke=ee.current-1;ee.current=ke;const Ie=be[ke];j(Ie),_(Ie),requestAnimationFrame(()=>{const Ae=se.current;Ae&&(Ae.selectionStart=Ae.selectionEnd=Ie.length)})}}else{const ke=ee.current+1;if(ke<be.length){ee.current=ke;const Ie=be[ke];j(Ie),_(Ie),requestAnimationFrame(()=>{const Ae=se.current;Ae&&(Ae.selectionStart=Ae.selectionEnd=Ie.length)})}else{ee.current=-1;const Ie=ce.current;j(Ie),_(Ie),requestAnimationFrame(()=>{const Ae=se.current;Ae&&(Ae.selectionStart=Ae.selectionEnd=Ie.length)})}}return}if(g.key==="Escape"&&ee.current!==-1){g.preventDefault();const J=ce.current;ee.current=-1,j(J),_(J),requestAnimationFrame(()=>{const le=se.current;le&&(le.selectionStart=le.selectionEnd=J.length)});return}if(g.key==="Enter"){if(Di&&!g.shiftKey&&!(g.ctrlKey||g.metaKey))return;g.shiftKey||(g.preventDefault(),G())}}},x=()=>s.jsx("div",{className:"inputbox-actions",children:n?s.jsxs(s.Fragment,{children:[K.trim()!==""&&s.jsxs("button",{type:"button",className:"btn supplement",title:P("supplementTip"),onClick:()=>G(!0),children:[s.jsx(Qs,{})," ",P("supplement")]}),s.jsx("button",{type:"button",className:"btn stop",title:P("stopAgent"),onClick:()=>u({type:"abort"}),children:s.jsx(zs,{})})]}):s.jsx("button",{type:"button",className:"btn send",title:P("sendTip"),disabled:!Se||!K.trim()&&!f.some(g=>g.imageData||g.fileData),onClick:()=>G(),children:s.jsx(sr,{})})});return s.jsxs("div",{className:`inputbar${X?" drop-active":""}`,onDragOver:g=>{g.preventDefault(),g.stopPropagation(),k(!0)},onDragLeave:g=>{g.currentTarget.contains(g.relatedTarget)||k(!1)},onDrop:g=>{g.preventDefault(),g.stopPropagation(),k(!1),pe(g.dataTransfer?.files??null)},children:[X&&s.jsx("div",{className:"drop-overlay",children:s.jsxs("span",{children:["📎 ",P("dropHereToAttach")]})}),f.length>0&&s.jsxs("div",{className:"attach-row",children:[f.map(g=>s.jsxs("span",{className:`attach-chip ${g.imageData?"image":g.fileData?"file":g.mode}`,title:g.imageData?P("attachImage",{name:g.name}):g.fileData?P("attachFile",{name:g.name}):g.isDir?P("folderRef",{path:g.path}):g.mode==="reference"?P("refOnly",{path:g.path}):g.mode==="lines"&&g.lines?P("attachLines",{path:g.path,start:g.lines.start,end:g.lines.end}):P("attachContent",{path:g.path}),children:[g.imageData?"🖼":g.fileData?"📄":g.isDir?"📁":g.mode==="reference"?"🔗":"📎"," ",g.name,g.mode==="lines"&&g.lines&&s.jsxs("span",{className:"attach-range",children:["L",g.lines.start,"-",g.lines.end]}),s.jsx("button",{type:"button",className:"attach-remove",title:P("removeAttachment"),onClick:()=>b(g.key??g.path),children:"×"})]},g.key??`${g.path}|${g.mode}|${g.lines?`${g.lines.start}-${g.lines.end}`:""}`)),s.jsx("span",{className:"attach-hint",children:P("attachHint")})]}),Z&&Z.length>0&&s.jsxs("div",{className:"slash-menu",role:"listbox",ref:C,"aria-label":P("slashCommands"),children:[s.jsxs("div",{className:"slash-menu-hint",children:[s.jsx("span",{children:P("slashMenuHint")}),s.jsx("span",{className:"slash-menu-close",onClick:()=>Y(null),children:"Esc"})]}),Z.map((g,J)=>s.jsxs("button",{type:"button",className:`slash-item${J===me?" active":""}`,onMouseEnter:()=>de(J),onClick:()=>he(g),children:[s.jsxs("span",{className:"slash-name",children:["/",g.name]}),s.jsx("span",{className:`slash-source ${g.source}`,children:ae[g.source]}),s.jsxs("span",{className:"slash-desc",children:[Q(g),g.argumentHint&&s.jsx("span",{className:"slash-hint",children:re(g)})]})]},g.name))]}),w&&s.jsx("div",{className:"modal-backdrop",onClick:()=>I(!1),children:s.jsxs("div",{className:"slash-help",style:L?{width:L}:void 0,onClick:g=>g.stopPropagation(),children:[s.jsxs("div",{className:"slash-help-head",children:[s.jsxs("span",{children:["⚡ ",P("slashHelpTitle")]}),s.jsx("button",{type:"button",className:"btn",onClick:()=>I(!1),children:P("close")})]}),s.jsx("div",{className:"slash-help-body",children:o.length===0?s.jsx("div",{className:"slash-help-empty",children:P("slashLoading")}):o.map(g=>s.jsxs("div",{className:"slash-help-row",children:[s.jsxs("span",{className:"slash-help-cmd",children:["/",g.name]}),s.jsx("span",{className:`slash-source ${g.source}`,children:ae[g.source]}),s.jsxs("span",{className:"slash-help-desc",children:[Q(g),g.argumentHint&&s.jsx("span",{className:"slash-hint",children:re(g)})]})]},g.name))})]})}),v&&$.length>0&&s.jsx("div",{className:"quick-row","aria-label":P("quickPhrases"),children:$.map(g=>s.jsx("button",{type:"button",className:"quick-chip",title:P("quickPhrasesTip",{text:g}),disabled:!Se,onClick:()=>Te(g),children:g},g))}),s.jsxs("div",{className:"inputbox",children:[s.jsx("input",{ref:ye,type:"file",multiple:!0,hidden:!0,onChange:g=>{pe(g.target.files),g.target.value=""}}),s.jsx("textarea",{ref:se,value:K,rows:1,placeholder:P(Se?n?"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!Se,onChange:g=>{ee.current=-1,j(g.target.value),_(g.target.value)},onKeyDown:Re,onPaste:Ee}),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:P("uploadFile"),disabled:!Se,onClick:()=>ye.current?.click(),children:s.jsx(Tl,{})}),s.jsx("button",{type:"button",className:"btn tpl-open",title:P("tpl.openPicker"),onClick:H,children:s.jsx(Il,{})}),s.jsx(Oh,{state:i,models:c,modelsLoading:d,send:u,onManageModels:M,providerKeys:z,compact:!0})]}),s.jsx("div",{className:"composer-tools-right",children:x()})]})]})]})}),Bh=l.memo(function({goal:t,models:n,modelsLoading:a,activeConversationId:o,engine:i,send:c}){const d=Le(),{locale:u}=Mt(),f=u!=="zh"&&t.statusEn?t.statusEn:t.status||"",b=u!=="zh"&&t.wizard?.statusEn?t.wizard.statusEn:t.wizard?.status||"",E=i==="dsh",y=!t.conversationId||t.conversationId===o,N=t.goal!==null&&y,[S,M]=l.useState(""),[z,$]=l.useState(t.reviewModel??""),[v,P]=l.useState(t.maxRounds),[B,H]=l.useState(t.locked),[Q,re]=l.useState(!1),[K,j]=l.useState(!1),[X,k]=l.useState(!0);l.useEffect(()=>{$(t.reviewModel??""),P(t.maxRounds||0),H(t.locked)},[t.goal,t.reviewModel,t.maxRounds,t.locked]),l.useEffect(()=>{Q&&n.length===0&&!K&&!a&&(j(!0),c({type:"list_models"}))},[Q,n.length,K,a,c]),l.useEffect(()=>{n.length>0&&j(!1)},[n.length]);const Z=()=>z?n.find(w=>w.id===z)?.name??z:d("goalBarUseMainModel"),Y=()=>{const w=S.trim();w&&(c({type:"set_goal",goal:w,...z?{reviewModel:z}:{},maxRounds:v,locked:B}),M(""),k(!1))},me=()=>{const w=S.trim();w&&(c({type:"start_goal_wizard",text:w,...z?{wizardModel:z}:{},maxRounds:v,locked:B}),M(""),k(!1))},de=(t.wizard?.active??!1)&&y;return de?s.jsx("div",{className:`goalbar goalbar-active ${de?"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:[d("goalWizardRunning"),": ",t.wizard?.draft]}),s.jsxs("span",{className:"goalbar-chip reviewing",children:[d("goalBarRound",{n:(t.wizard?.step??0)+1})," / ",t.wizard?.maxSteps??6]}),s.jsx("span",{className:"goalbar-detail",children:b||d("goalBarReviewing")}),s.jsx("button",{type:"button",className:"goalbar-x",title:d("goalBarClear"),onClick:()=>{c({type:"clear_goal"}),k(!0)},children:s.jsx($e,{})})]})}):N?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:[d("goalBarReviewing")," ",d("goalBarRound",{n:t.round})]}):s.jsx("span",{className:`goalbar-chip ${t.verdict==="pass"?"pass":t.verdict==="fail"?"fail":""}`,children:t.verdict==="pass"?d("goalBarPassed"):t.verdict==="fail"?d("goalBarFailed"):`${d("goalBarRound",{n:t.round||1})} · ${t.locked?d("goalBarLocked"):d("goalBarUnlocked")}`}),s.jsx("span",{className:"goalbar-detail",children:f}),s.jsx("button",{type:"button",className:"goalbar-x",title:d("goalBarClear"),disabled:t.reviewing,onClick:()=>{c({type:"clear_goal"}),k(!0)},children:s.jsx($e,{})})]})}):X?s.jsx("div",{className:"goalbar goalbar-collapsed",children:s.jsxs("button",{type:"button",className:"goalbar-hint",title:d("goalBarPlaceholder"),onClick:()=>k(!1),children:[s.jsx(La,{})," ",s.jsx("span",{children:d("goalBarTitle")})]})}):s.jsxs("div",{className:"goalbar",children:[s.jsxs("div",{className:"goalbar-row",children:[s.jsx("span",{className:"goalbar-icon",children:s.jsx(La,{})}),s.jsx("input",{className:"goalbar-input",value:S,placeholder:d("goalBarPlaceholder"),onChange:w=>M(w.target.value),onKeyDown:w=>{w.key==="Enter"&&Y()}}),s.jsx("button",{type:"button",className:"goalbar-btn",disabled:!S.trim(),onClick:Y,children:d("goalBarSet")}),s.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!S.trim(),title:d("goalWizardTip"),onClick:me,children:["🔍 ",d("goalWizardBtn")]}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:d(B?"goalBarLocked":"goalBarUnlocked"),onClick:()=>H(w=>(c({type:"set_goal_prefs",locked:!w}),!w)),children:B?s.jsx(_l,{}):s.jsx(fl,{})}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:d("goalBarClear"),onClick:()=>k(!0),children:s.jsx(un,{})})]}),s.jsxs("div",{className:"goalbar-opts",children:[E?s.jsx("p",{className:"goalbar-dsh-note",children:d("dshNoReviewModel")}):s.jsxs(jt,{trigger:s.jsxs("span",{className:"goalbar-opt",children:[d("goalBarReviewModel"),": ",s.jsx("b",{children:Z()})]}),open:Q,onOpenChange:re,direction:"up",children:[s.jsx("div",{className:"dd-header",children:d("goalBarReviewModel")}),(K||a)&&s.jsx("div",{className:"dd-loading",children:d("loading")}),n.length===0&&!K&&!a&&s.jsx("div",{className:"dd-loading",children:d("noModels")}),s.jsx(nt,{active:z==="",onClick:()=>{$(""),re(!1),c({type:"set_goal_prefs",reviewModel:""})},children:d("goalBarUseMainModel")}),n.map(w=>s.jsx(nt,{active:z===w.id,onClick:()=>{$(w.id),re(!1),c({type:"set_goal_prefs",reviewModel:w.id})},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:w.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:w.provider}),s.jsx("span",{className:"dd-model-id",children:w.id.split("/").slice(1).join("/")})]})]})},w.id)),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>c({type:"list_models"}),children:d("refreshModels")})]}),s.jsxs("label",{className:"goalbar-round",title:d("goalBarMaxRoundsTip"),children:[s.jsx("span",{children:d("goalBarMaxRounds")}),s.jsx("input",{type:"number",min:0,step:1,value:v,placeholder:d("goalBarUnlimitedShort"),onChange:w=>{const I=parseInt(w.target.value,10);if(Number.isNaN(I)||I<0){P(0);return}P(I)},onBlur:()=>c({type:"set_goal_prefs",maxRounds:v}),onKeyDown:w=>{w.key==="Enter"&&(c({type:"set_goal_prefs",maxRounds:v}),w.target.blur())}})]}),s.jsx("span",{className:"goalbar-lock-hint",children:d(B?"goalBarLocked":"goalBarUnlocked")})]})]})});function Fh(e){const t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),a=Math.max(0,e.cacheWrite??0),o=t+n+a;return{totalInput:o,miss:t,read:n,write:a,hitRate:o>0?Math.min(n/o,1):0,writeRate:o>0?Math.min(a/o,1):0}}const No=2e3;function Hh(e,t,n=No){return e.filter(a=>t-a.t<=n)}function Uh(e,t=No){if(e.length<2)return 0;const n=e[e.length-1],a=e.find(i=>i.t>=n.t-t)??e[0],o=(n.t-a.t)/1e3;return o<=0?0:Math.max(0,(n.out-a.out)/o)}function Oi(e){if(!e)return 0;let t=0;for(let a=0;a<e.length;a++){const o=e.charCodeAt(a);(o>=12352&&o<=12543||o>=13312&&o<=19903||o>=19968&&o<=40959||o>=63744&&o<=64255||o>=65280&&o<=65519||o===12288)&&t++}const n=e.length-t;return Math.round(t+n/4)}function qh(e){let t=0;for(const n of e)n.type==="text"&&typeof n.text=="string"&&n.text?t+=Oi(n.text):n.type==="thinking"&&typeof n.thinking=="string"&&n.thinking&&(t+=Oi(n.thinking));return t}const bt="@root";function $h({chat:e,send:t}){const n=Le(),a=e.state,[o,i]=l.useState(!1),[c,d]=l.useState(""),[u,f]=l.useState(""),[b,E]=l.useState(!1),[y,N]=l.useState(""),[S,M]=l.useState(-1),z=l.useRef(null),$=l.useRef(null),v=e.pathCompletions.filter(_=>_.type==="dir"),P=_=>_.endsWith("/")?_:_+"/",B=_=>{let he=_.endsWith("/")&&_!=="/"?_.slice(0,-1):_;if(he===bt||he==="/")return null;const F=he.lastIndexOf("/");if(F<0)return/^[A-Za-z]:$/.test(he)?bt:null;if(F===0)return"/";const pe=he.slice(0,F);return/^[A-Za-z]:$/.test(pe)?pe+"/":pe};l.useEffect(()=>{if(!o)return;const _=setTimeout(()=>{t({type:"complete_path",path:P(c)})},60);return()=>clearTimeout(_)},[c,o,t]),l.useEffect(()=>{if(!o||u===c)return;const _=setTimeout(()=>{t({type:"complete_path",path:u})},150);return()=>clearTimeout(_)},[u,c,o,t]);const H=l.useRef([]),Q=a?.isStreaming??!1,re=a?.streamingMessage?qh(a.streamingMessage.content):0;if(l.useEffect(()=>{if(!Q){H.current=[];return}const _=Date.now(),he=H.current,F=he[he.length-1];F&&_-F.t<250||(H.current=Hh([...he,{t:_,out:re}],_))},[Q,re]),!a)return null;const K=a.stats,j=Fh(K.tokens),X=j.hitRate*100,k=j.totalInput===0?"":j.hitRate>=.7?"ok":j.hitRate>=.4?"mid":"warn",Z=j.totalInput>0?`${X.toFixed(1)}%`:"—",Y=Q?Uh(H.current):0,me=e.ready?"ok":"busy",de=e.ready?n("connected"):n("connecting"),w=K.contextUsage,I=w.tokens!==null&&w.percent!==null?`${w.estimated?"~":""}${Gt(w.tokens)} / ${Gt(w.contextWindow)}`:"—",L=w.percent??null,oe=L===null?"":L>=80?"warn":L>=50?"mid":"ok",se=a.queue.steering.length+a.queue.followUp.length,ye=()=>{const _=a.cwd.replace(/\\/g,"/");f(_),d(_),E(!1),N(""),i(!0)},C=_=>{const he=_.trim();he!==bt&&(he&&he!==a.cwd&&t({type:"set_cwd",path:he}),i(!1))},ee=()=>{const _=y.trim();_&&(t({type:"make_dir",path:`${P(c)}${_}`}),setTimeout(()=>{t({type:"complete_path",path:P(c)})},80),N(""),E(!1))},ce=_=>{if(_.key==="Escape")_.stopPropagation(),i(!1);else if(_.key==="Enter"&&!_.nativeEvent.isComposing)C(u);else if(_.key==="Tab"){if(v.length===0)return;_.preventDefault();const he=S>=0?(S+1)%v.length:0;M(he),f(v[he].path),d(v[he].path)}},ae=B(c);return s.jsxs("footer",{className:"statusbar",children:[s.jsx("span",{className:`status-dot ${me}`,title:de}),s.jsx("span",{className:"status-item",children:de}),s.jsx("span",{className:"status-sep",children:"·"}),e.engine&&e.engine!=="pi"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`status-item engine-badge engine-${e.engine}`,title:`${n("engineBadge")}: ${e.engine}`,children:e.engine==="dsh"?"DSH":e.engine}),s.jsx("span",{className:"status-sep",children:"·"})]}),s.jsxs("span",{className:"status-item status-ctx",title:n("contextUsage"),children:[s.jsx("span",{className:"ctx-label",children:n("context")}),s.jsx("span",{className:`ctx-bar ${oe}`,children:L!==null&&s.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min(L,100)}%`}})}),I]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:n("cumulativeCost"),children:["$",Wh(K.cost)]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item status-cache",title:n("cacheHitTip",{read:Gt(j.read),write:Gt(j.write),miss:Gt(j.miss),input:Gt(j.totalInput)}),children:[n("cacheHit"),s.jsx("b",{className:`cache-pct ${k}`,children:Z})]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:n("sessionMessages"),children:[n("messages")," ",K.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:n("pluginStatus"),children:e.statuses.map(_=>_.text).join(" · ")})]}),a.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"}),n("working"),se>0&&s.jsxs("span",{className:"status-queue",children:["⏳ ",se," ",n("queued")]})]}),s.jsxs("span",{className:"status-item status-rate",title:n("rateTip"),children:[s.jsx("span",{className:"working-spin rate-spin"}),Y>0?`${Math.round(Y)}${n("tps")}`:"…"]})]}),o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"status-cwd-backdrop",onClick:()=>i(!1)}),s.jsxs("div",{className:"cwd-picker",children:[s.jsxs("div",{className:"cwd-picker-head",children:[s.jsxs("span",{className:"cwd-picker-title",title:c===bt?n("computer"):c,children:[c===bt?"💻":s.jsx(Pt,{}),s.jsx("span",{children:c===bt?n("computer"):c})]}),s.jsx("button",{type:"button",className:"cwd-up",disabled:c===bt,title:n("computer"),onClick:()=>{d(bt),f(bt),M(-1)},children:"💻"}),s.jsxs("button",{type:"button",className:"cwd-up",disabled:!ae,title:n("cwdGoUp"),onClick:()=>{ae&&(d(ae),f(ae),M(-1))},children:["↑ ",n("cwdGoUp")]})]}),s.jsxs("div",{className:"cwd-picker-row",children:[s.jsx("input",{ref:z,className:"status-cwd-input cwd-picker-input",value:u,placeholder:n("enterPath"),spellCheck:!1,onChange:_=>{f(_.target.value),M(-1)},onKeyDown:ce}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",title:n("cwdPickCurrent"),disabled:c===bt,onClick:()=>C(c),children:n("cwdPickCurrent")})]}),s.jsxs("div",{className:"cwd-list",children:[v.length===0&&s.jsx("div",{className:"cwd-empty",children:n("cwdEmpty")}),v.map(_=>s.jsxs("div",{className:"cwd-item",children:[s.jsxs("button",{type:"button",className:"cwd-enter",title:`${n("cwdEnter")} ${_.path}`,onClick:()=>{d(_.path),f(_.path),M(-1)},children:[s.jsx(Pt,{}),s.jsx("span",{className:"cwd-name",children:_.name})]}),s.jsx("button",{type:"button",className:"cwd-choose-btn",title:n("cwdChoose"),onClick:()=>C(_.path),children:n("cwdChoose")})]},_.path))]}),s.jsx("div",{className:"cwd-picker-foot",children:b?s.jsxs("div",{className:"cwd-newrow",children:[s.jsx("input",{ref:$,value:y,autoFocus:!0,spellCheck:!1,placeholder:n("cwdNewName"),onChange:_=>N(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing?(_.preventDefault(),ee()):_.key==="Escape"&&(_.stopPropagation(),E(!1),N(""))}}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",onClick:ee,children:n("cwdCreate")}),s.jsx("button",{type:"button",className:"cwd-choose-btn",onClick:()=>{E(!1),N("")},children:n("cwdCancel")})]}):s.jsxs("button",{type:"button",className:"cwd-newbtn",onClick:()=>E(!0),children:["+ ",n("cwdNewFolder")]})})]})]}):s.jsxs("button",{type:"button",className:"status-item status-cwd",title:n("cwdTip",{path:a.cwd}),onClick:ye,children:["📁 ",a.cwd]})]})}function Gt(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(e)}function Wh(e){return e<=0?"0":e<1e-4?"<0.0001":e.toFixed(4).replace(/\.?0+$/,"")}function Kh({dialog:e,send:t}){const n=Le(),[a,o]=l.useState(""),[i,c]=l.useState(0),d=b=>{t({type:"dialog_response",id:e.id,value:b})};l.useEffect(()=>{o(""),c(0);const b=E=>{E.key==="Escape"&&d(null)};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e.id]);const u=Array.isArray(e.args[0])?e.args[0]:[],f=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:n("pluginRequest")}),e.title&&e.title!==n("pluginRequest")&&s.jsx("span",{className:"dialog-title",children:e.title}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:()=>d(null),children:"✕"})]}),e.kind==="select"&&s.jsxs("div",{className:"dialog-options",children:[u.map((b,E)=>s.jsx("button",{type:"button",className:`dialog-option ${E===i?"sel":""}`,onMouseEnter:()=>c(E),onClick:()=>d(b),children:s.jsx(ot,{text:b,rawHtml:!0})},E)),u.length===0&&s.jsx("div",{className:"dialog-hint",children:n("noOptions")})]}),e.kind==="confirm"&&s.jsxs("div",{className:"dialog-body",children:[s.jsx(ot,{text:f,rawHtml:!0}),s.jsxs("div",{className:"dialog-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>d(!1),children:n("cancel")}),s.jsx("button",{type:"button",className:"btn primary",onClick:()=>d(!0),children:n("ok")})]})]}),e.kind==="input"&&s.jsxs("div",{className:"dialog-body",children:[s.jsx("input",{className:"dialog-input",value:a,placeholder:f||n("inputPlaceholder"),autoFocus:!0,onChange:b=>o(b.target.value),onKeyDown:b=>{b.key==="Enter"&&!b.nativeEvent.isComposing&&d(a)}}),s.jsxs("div",{className:"dialog-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>d(null),children:n("cancel")}),s.jsx("button",{type:"button",className:"btn primary",onClick:()=>d(a),children:n("ok")})]})]})]})}function Yh({question:e,send:t}){const n=Le(),[a,o]=l.useState({}),[i,c]=l.useState({}),[d,u]=l.useState(0),[f,b]=l.useState(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);l.useEffect(()=>{o({}),c({}),u(0),b(e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1)},[e.id,e.deadline]),l.useEffect(()=>{if(!e.deadline)return;const B=setInterval(()=>{b(H=>{const Q=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return Q<=0&&H>0&&t({type:"question_answer",id:e.id,answers:[],cancelled:!0}),Q})},1e3);return()=>clearInterval(B)},[e.id,e.deadline]),l.useEffect(()=>{const B=H=>{H.key==="Escape"&&S()};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[e.id]);const E=e.questions.length,y=e.questions[d];if(!y)return null;const N=B=>{const H=e.questions.map(Q=>{const re=B[Q.id]??[],K=(i[Q.id]??"").trim();return{id:Q.id,selected:re,...K?{custom:K}:{}}});t({type:"question_answer",id:e.id,answers:H})},S=()=>{t({type:"question_answer",id:e.id,answers:[],cancelled:!0})},M=(B,H)=>{o(Q=>{const re=Q[B]??[];return{...Q,[B]:re.includes(H)?re.filter(K=>K!==H):[...re,H]}})},z=(B,H,Q)=>{if(Q){M(B,H);return}const re={...a,[B]:[H]};o(re),d===E-1?N(re):u(d+1)},$=()=>{d===E-1?N(a):u(d+1)},v=B=>(e.questions.find(Q=>Q.id===B)?.options?.length??0)===0?!0:(a[B]?.length??0)>0||(i[B]??"").trim()!=="",P=(y.options??[]).filter(B=>(a[y.id]??[]).includes(B.label)&&B.preview).map(B=>B.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:n("modelQuestion")}),E>1&&s.jsx("span",{className:"question-progress",children:n("questionStep",{cur:d+1,total:E})}),f>=0&&s.jsx("span",{className:"question-timer",children:f>0?n("questionTimeout",{s:f}):n("questionTimeoutExpired")}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:S,children:"✕"})]}),s.jsxs("div",{className:"set-section",children:[s.jsx("div",{className:"set-section-title",children:y.header??`${n("modelQuestion")} ${d+1}`}),s.jsx("div",{className:"question-head",children:s.jsx(ot,{text:y.question,rawHtml:!0})}),y.detail&&s.jsx("div",{className:"set-hint",children:s.jsx(ot,{text:y.detail,rawHtml:!0})}),(y.options?.length??0)>0&&s.jsx("div",{className:"set-list",children:y.options.map(B=>{const H=(a[y.id]??[]).includes(B.label);return s.jsxs("button",{type:"button",className:`set-row question-option${H?" active":""}`,onClick:()=>z(y.id,B.label,!!y.multiSelect),children:[s.jsxs("div",{className:"set-row-name",children:[s.jsx("span",{className:"question-mark",children:y.multiSelect?H?"☑ ":"☐ ":H?"● ":"○ "}),s.jsx(ot,{text:B.label,rawHtml:!0})]}),B.description&&s.jsx("div",{className:"set-row-desc",children:s.jsx(ot,{text:B.description,rawHtml:!0})})]},B.label)})}),P.length>0&&s.jsxs("div",{className:"question-preview",children:[s.jsx("div",{className:"question-preview-label",children:n("optionPreview")}),P.map((B,H)=>s.jsx("div",{className:"question-preview-body",children:s.jsx(ot,{text:B,rawHtml:!0})},H))]}),s.jsx("input",{className:"set-prompt-input question-custom",placeholder:n("modelQuestionCustom"),value:i[y.id]??"",onChange:B=>c(H=>({...H,[y.id]:B.target.value})),onKeyDown:B=>{B.key==="Enter"&&(B.preventDefault(),v(y.id)&&$())}})]},y.id),s.jsxs("div",{className:"dialog-nav",children:[s.jsx("button",{type:"button",className:"dialog-dismiss-inline",onClick:S,children:n("cancel")}),s.jsxs("div",{className:"dialog-nav-right",children:[s.jsx("button",{type:"button",className:"dialog-prev",disabled:d===0,onClick:()=>u(d-1),children:n("previous")}),s.jsx("button",{type:"button",className:"dialog-submit",disabled:!v(y.id),onClick:$,children:d===E-1?n("modelQuestionSubmit"):n("next")})]})]})]})}const Mi=e=>`'${e.replace(/'/g,"'\\''")}'`;function Gh(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 zh({chat:e,send:t,terminal:n,active:a,onSwitchToTerminal:o}){const i=Le(),[c,d]=l.useState(null),[u,f]=l.useState([]),[b,E]=l.useState(""),[y,N]=l.useState(new Map),[S,M]=l.useState("changes"),[z,$]=l.useState([]),[v,P]=l.useState(null),[B,H]=l.useState(""),[Q,re]=l.useState(!1),[K,j]=l.useState(null),[X,k]=l.useState(null),[Z,Y]=l.useState(!1),[me,de]=l.useState(!1),[w,I]=l.useState(!1),[L,oe]=l.useState(null),[se,ye]=l.useState(!1),[C,ee]=l.useState(""),ce=l.useRef(0),ae=l.useRef(-1),_=l.useRef(-1),he=l.useRef(-1),F=l.useRef(-1),pe=l.useRef(void 0),Ee=l.useRef(null),Oe=l.useRef([]),Se=l.useCallback(D=>{if(D.reqId===ae.current){if(ae.current=-1,de(!1),oe(null),!D.ok){oe(D.error??i("scmQueryFailedShort"));return}if(D.notRepo){ye(!0),d(null),f([]),N(new Map),$([]),P(null),H(""),k(null);return}ye(!1);const we={branch:D.branch??"",detached:!!D.detached,upstream:D.upstream??null,ahead:D.ahead??0,behind:D.behind??0,upstreamGone:!!D.upstreamGone,files:(D.files??[]).map(De=>({...De}))},Ce=(D.branches??[]).map(De=>({...De})),qe=new Map;for(const[De,Xe]of Object.entries(D.stats??{}))qe.set(De,{add:Xe[0],del:Xe[1]});d(we),f(Ce),N(qe),E(De=>we.detached?De||"":we.branch&&Ce.some(Xe=>Xe.name===we.branch)?we.branch:De&&Ce.some(Xe=>Xe.name===De)?De:Ce[0]?.name??""),k(De=>De&&!we.files.some(Xe=>Xe.path===De.file.path)?null:De)}else if(D.reqId===_.current){if(_.current=-1,Y(!1),!D.ok){oe(D.error??i("scmQueryFailedShort"));return}const we=Ee.current;if(!we)return;k({file:we,staged:D.stagedText??"",worktree:D.worktreeText??"",untracked:!1})}else if(D.reqId===F.current){if(F.current=-1,I(!1),!D.ok){oe(D.error??i("scmQueryFailedShort"));return}$((D.history??[]).map(we=>({...we})))}else if(D.reqId===he.current){if(he.current=-1,re(!1),!D.ok){oe(D.error??i("scmQueryFailedShort"));return}H(D.text??"")}},[]);l.useEffect(()=>{const D=e.scmData;D&&D.type==="scm_data"&&Se(D)},[e.scmData,Se]);const U=l.useCallback((D,we)=>{if(!e.ready||e.status!=="open")return!1;const Ce=++ce.current;return t({...D,reqId:Ce})?(we.current=Ce,!0):(ce.current-=1,!1)},[e.ready,e.status,t]),ge=l.useCallback((D=!1,we=!1)=>{!e.ready||e.status!=="open"||e.state?.cwd&&(pe.current!==void 0&&pe.current!==e.state.cwd&&(d(null),f([]),N(new Map),$([]),I(!1),F.current=-1,P(null),H(""),k(null),j(null)),pe.current=e.state.cwd,oe(null),U({type:"scm_status"},ae)&&(we||de(!0)))},[e.ready,e.state?.cwd,e.status,U]),ue=l.useCallback(D=>{if(j(D),P(null),Ee.current=D,D.x==="?"&&D.y==="?"){k({file:D,staged:"",worktree:"",untracked:!0});return}Y(!0),oe(null),U({type:"scm_filediff",path:D.path},_)||Y(!1)},[U]),ie=l.useCallback(D=>{P(D),j(null),k(null),H(""),re(!0),oe(null),U({type:"scm_commit",hash:D.hash},he)||re(!1)},[U]),G=l.useCallback((D,we)=>{if(!e.ready)return;const Ce={name:D,command:we,cwd:"${pwd}"};let qe;const De=e.terminals.find(Xe=>Xe.title===D);De?(n.restart(De.id),t({type:"run_command",terminalId:De.id,conversationId:De.conversationId,command:Ce,cols:80,rows:24}),qe=De.id):(qe=_t(),n.create({id:qe,conversationId:e.activeConversationId||e.state?.conversationId||"",title:D,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Ce})),n.select(qe),o()},[e.ready,e.state?.cwd,e.terminals,o,t,n]),Te=l.useCallback(()=>{const D=C.trim();if(!D||se)return;const we=D.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");G("git commit",`git commit -m "${we}"`),ee("")},[C,se,G]),Re=l.useCallback(()=>{const D=C.trim();if(!D||se)return;const we=D.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");G("git commit",`git add -A && git commit -m "${we}"`),ee("")},[C,se,G]),x=l.useCallback(D=>{se||G("git add",`git add -- ${Mi(D.path)}`)},[se,G]),g=l.useCallback(D=>{se||G("git reset",`git reset HEAD -- ${Mi(D.path)}`)},[se,G]),J=l.useCallback(()=>{if(!b||se)return;const D=u.find(we=>we.name===b);if(D?.remote&&typeof D.remote=="string"){const we=b.slice(D.remote.length+1);G("git checkout",`git checkout -b ${we} ${b} || git checkout ${b}`)}else G("git checkout",`git checkout ${b}`)},[b,u,se,G]),le=l.useCallback(()=>G("git push","git push"),[G]),be=l.useCallback(()=>G("git pull","git pull"),[G]),ke=l.useCallback(()=>{U({type:"scm_history"},F)||(F.current=-1)},[U]);l.useEffect(()=>{a&&ge()},[a,ge]),l.useEffect(()=>{S==="history"&&c&&ke()},[S,c,ke]),l.useEffect(()=>{e.scmDirty>0&&a&&ge(!1,!0)},[e.scmDirty]),l.useEffect(()=>{if(!a||!e.ready||e.status!=="open")return;const D=setInterval(()=>{document.visibilityState!=="hidden"&&ge(!1,!0)},3e4);return()=>clearInterval(D)},[a,e.ready,e.status,ge]),l.useEffect(()=>{const D=Oe.current;if(Oe.current=e.terminals,!a)return;e.terminals.some(Ce=>Ce.running!==!1?!1:D.find(De=>De.id===Ce.id)?.running===!0&&Ce.title.startsWith("git "))&&e.ready&&e.status==="open"&&(ge(!1,!0),S==="history"&&c&&ke())},[e.terminals,a,e.ready,e.status,ge,S,c,ke]);const Ie={staged:i("scmStaged"),unstaged:i("scmUnstaged"),untracked:i("scmUntracked"),both:i("scmStagedUnstaged")},Ae=D=>{const we=D.split(`
|
|
327
|
-
`);return s.jsx("pre",{className:"scm-diff-pre",children:we.map((Ce,qe)=>{let De="";return Ce.startsWith("diff --git")||Ce.startsWith("index ")||Ce.startsWith("new file")||Ce.startsWith("deleted file")||Ce.startsWith("old mode")||Ce.startsWith("new mode")||Ce.startsWith("similarity index")||Ce.startsWith("rename ")||Ce.startsWith("copy ")||Ce.startsWith("Binary files")||Ce.startsWith("---")||Ce.startsWith("+++")?De="hdr":Ce.startsWith("@@")?De="hunk":Ce.startsWith("+")?De="add":Ce.startsWith("-")&&(De="del"),s.jsx("div",{className:`scm-diff-line ${De}`,children:Ce||" "},qe)})})};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(Hs,{}),i("scmTitle")]}),s.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[s.jsx("button",{type:"button",role:"tab","aria-selected":S==="changes",className:S==="changes"?"active":"",onClick:()=>{M("changes"),oe(null)},children:i("scmChanges")}),s.jsx("button",{type:"button",role:"tab","aria-selected":S==="history",className:S==="history"?"active":"",onClick:()=>{M("history"),oe(null)},children:i("scmHistory")})]}),s.jsx("button",{type:"button",className:"panel-refresh",title:i("scmRefreshTip"),disabled:me,onClick:()=>ge(!0),children:s.jsx(kt,{className:me?"scm-spin":""})})]}),s.jsxs("div",{className:"scm-row",children:[s.jsxs("span",{className:"scm-branch-current",title:i("scmCurrentBranch"),children:[s.jsx(Hs,{}),c?c.detached?i("scmDetached"):c.branch:"…",c?.upstream&&s.jsx("span",{className:"scm-upstream",children:c.upstreamGone?i("scmUpstreamGone"):c.ahead>0||c.behind>0?i("scmAheadBehind",{ahead:c.ahead,behind:c.behind}):c.upstream})]}),s.jsxs("select",{className:"scm-select",value:b,disabled:se||u.length===0,title:i("scmSwitchBranch"),onChange:D=>E(D.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:i("scmSelectBranch")}),u.filter(D=>!D.remote).map(D=>s.jsx("option",{value:D.name,children:D.current?`* ${D.name}`:D.name},D.name)),u.some(D=>D.remote)&&s.jsx("optgroup",{label:i("scmRemoteBranches"),children:u.filter(D=>D.remote).map(D=>s.jsx("option",{value:D.name,children:D.name},D.name))})]}),s.jsxs("button",{type:"button",className:"btn",disabled:!b||b===c?.branch||se,title:i("scmSwitchBranchTip",{branch:b}),onClick:J,children:[s.jsx(Hs,{}),i("scmSwitch")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!c||c.detached||se,title:i("scmPushTip"),onClick:le,children:[s.jsx(sr,{}),i("scmPush")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!c||c.detached||se,title:i("scmPullTip"),onClick:be,children:[s.jsx(nr,{}),i("scmPull")]}),s.jsx("input",{className:"scm-commit-input",value:C,placeholder:i("scmCommitPlaceholder"),disabled:se,onChange:D=>ee(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.nativeEvent.isComposing&&Te()}}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!C.trim()||se,title:i("scmCommitTip"),onClick:Te,children:[s.jsx(Tt,{}),i("scmCommit")]}),s.jsx("button",{type:"button",className:"btn",disabled:!C.trim()||se,title:i("scmCommitAllTip"),onClick:Re,children:i("scmCommitAll")})]})]}),s.jsxs("div",{className:"scm-body",children:[S==="history"?s.jsxs("div",{className:"scm-history",children:[s.jsxs("div",{className:"scm-files-header",children:[s.jsx("span",{children:i("scmHistory")}),z.length>0&&s.jsx("span",{className:"scm-files-count",children:z.length})]}),s.jsx("div",{className:"scm-history-list",children:se?s.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):!c||w?s.jsx("div",{className:"scm-empty",children:e.status==="open"?i("scmLoading"):i("scmConnecting")}):z.length===0?s.jsx("div",{className:"scm-empty",children:i("scmNoHistory")}):z.map(D=>s.jsxs("button",{type:"button",className:`scm-commit ${v?.hash===D.hash?"active":""}`,onClick:()=>ie(D),title:D.hash,children:[s.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:D.graph||"* "}),s.jsxs("span",{className:"scm-commit-info",children:[s.jsx("span",{className:"scm-commit-subject",children:D.subject}),s.jsxs("span",{className:"scm-commit-meta",children:[D.shortHash," · ",D.author," · ",D.date]}),D.decorations&&s.jsx("span",{className:"scm-commit-refs",children:D.decorations})]})]},D.hash))})]}):s.jsxs("div",{className:"scm-files",children:[s.jsxs("div",{className:"scm-files-header",children:[s.jsx("span",{children:i("scmChanges")}),c&&c.files.length>0&&s.jsx("span",{className:"scm-files-count",children:c.files.length})]}),s.jsx("div",{className:"scm-files-list",children:se?s.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):c?c.files.length===0?s.jsx("div",{className:"scm-empty",children:i("scmNoChanges")}):c.files.map(D=>{const we=Gh(D),Ce=y.get(D.path);return s.jsxs("div",{className:`scm-file ${K?.path===D.path?"active":""}`,title:Ie[we],onClick:()=>ue(D),children:[s.jsx("span",{className:`scm-file-xy ${we==="untracked"?"q":"x"}`,children:D.x!==" "?D.x:" "}),s.jsx("span",{className:`scm-file-xy ${we==="untracked"?"q":"y"}`,children:D.y!==" "?D.y:" "}),s.jsx("span",{className:"scm-file-path",children:D.path}),Ce&&(Ce.add>0||Ce.del>0)&&s.jsxs("span",{className:"scm-file-stat",children:[Ce.add>0&&s.jsxs("span",{className:"add",children:["+",Ce.add]}),Ce.del>0&&s.jsxs("span",{className:"del",children:["-",Ce.del]})]}),s.jsxs("span",{className:"scm-file-actions",children:[(D.y!==" "||we==="untracked")&&s.jsx("button",{type:"button",className:"scm-act",title:i("scmStageTip",{path:D.path}),onClick:qe=>{qe.stopPropagation(),x(D)},children:"+"}),we==="staged"||we==="both"?s.jsx("button",{type:"button",className:"scm-act",title:i("scmUnstageTip",{path:D.path}),onClick:qe=>{qe.stopPropagation(),g(D)},children:"−"}):null]})]},D.path)}):s.jsx("div",{className:"scm-empty",children:e.status==="open"?i("scmLoading"):i("scmConnecting")})})]}),s.jsxs("div",{className:"scm-diff",children:[s.jsxs("div",{className:"scm-diff-header",children:[s.jsx("span",{children:S==="history"?v?`${v.shortHash} ${v.subject}`:i("scmCommitDetail"):K?K.path:i("scmDiff")}),(S==="history"?Q:Z)&&s.jsx("span",{className:"scm-diff-loading",children:i("scmLoading")})]}),s.jsx("div",{className:"scm-diff-body",children:S==="history"?s.jsxs(s.Fragment,{children:[L&&s.jsx("div",{className:"scm-error",children:L}),!v&&!L&&s.jsx("div",{className:"scm-empty",children:i("scmSelectCommitHint")}),v&&Q&&!L&&s.jsx("div",{className:"scm-empty",children:i("scmLoading")}),v&&!Q&&!L&&B?Ae(B):null]}):s.jsxs(s.Fragment,{children:[L&&s.jsx("div",{className:"scm-error",children:L}),!K&&!L&&s.jsx("div",{className:"scm-empty",children:i("scmSelectFileHint")}),K&&!X&&!L&&s.jsx("div",{className:"scm-empty",children:i("scmLoading")}),K&&X&&X.untracked&&s.jsx("div",{className:"scm-empty",children:i("scmUntrackedNote")}),K&&X&&!X.untracked&&s.jsxs(s.Fragment,{children:[X.staged&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:i("scmStaged")}),Ae(X.staged)]}),X.worktree&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:i("scmUnstaged")}),Ae(X.worktree)]}),!X.staged&&!X.worktree&&s.jsx("div",{className:"scm-empty",children:i("scmNoDiff")})]})]})})]})]}),s.jsxs("div",{className:"scm-hint",children:[s.jsx(Zt,{}),s.jsx("span",{children:i("scmRunsInTerminal")}),s.jsx("button",{type:"button",className:"scm-goto-term",onClick:o,children:i("scmViewTerminal")})]})]})}function Vh({entry:e,send:t}){const n=l.useRef(null),a=Le();return l.useEffect(()=>{const o=n.current;if(!o)return;let i;try{i=e.module.mount(o,Tc(e.info.id,c=>t(c)))}catch(c){console.error(`[plugin:${e.info.id}] mount failed:`,c),o.textContent=a("pluginMountFailed",{name:e.info.name})}return()=>{if(typeof i=="function")try{i()}catch(c){console.error(`[plugin:${e.info.id}] cleanup failed:`,c)}o.textContent=""}},[e,t]),s.jsx("div",{className:"plugin-view",ref:n})}function Qh({send:e,piConfigured:t,piAgentInstalled:n,managed:a,providers:o,installResult:i,onClose:c}){const d=Le(),[u,f]=l.useState(!1),[b,E]=l.useState(""),[y,N]=l.useState(""),[S,M]=l.useState(!1);l.useEffect(()=>{e({type:"list_providers"})},[e]),l.useEffect(()=>{t&&c()},[t,c]),l.useEffect(()=>{i&&f(!1)},[i]),l.useEffect(()=>{!b&&o.length>0&&E(o.find(H=>!H.configured)?.id??o[0].id)},[o,b]);const z=()=>{u||(f(!0),e({type:"install_pi_agent"}))},$=()=>{!y.trim()||S||(M(!0),e({type:"set_provider_api_key",provider:b.trim(),apiKey:y.trim()}),setTimeout(()=>M(!1),3e3))},v=()=>{e({type:"get_state"}),e({type:"list_providers"})},P=o.find(H=>H.id===b),B=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":d("close"),onClick:c,children:s.jsx($e,{})}),s.jsxs("div",{className:"modal-head",children:[s.jsx(_s,{className:"modal-head-icon"}),s.jsx("h2",{children:d("setupTitle")})]}),s.jsx("p",{className:"modal-desc",children:d("setupDesc")}),B?s.jsxs("div",{className:"setup-failed",children:[s.jsx("div",{className:"setup-done",children:d("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:z,children:d("retryInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]})]}):n||i?.ok?s.jsxs("div",{className:"setup-key-form",children:[s.jsx("div",{className:"setup-done",children:i?.ok?d("installDone"):d("cliReadyHint")}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("provider")}),s.jsxs("select",{value:b,onChange:H=>E(H.target.value),children:[o.length===0&&s.jsx("option",{value:"",children:d("loading")}),o.map(H=>s.jsxs("option",{value:H.id,children:[H.name,"(",H.id,")",H.configured?` · ${d("configured")}`:""]},H.id))]}),P?.configured&&s.jsx("div",{className:"field-hint",children:d("providerKeyReady")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKey")}),s.jsx("input",{type:"password",value:y,onChange:H=>N(H.target.value),placeholder:"sk-…"})]}),s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:!y.trim()||S||!b,onClick:$,children:d(S?"saving":"saveAndStart")}),s.jsxs("button",{type:"button",className:"btn",onClick:v,children:[s.jsx(kt,{})," ",d("recheck")]})]})]}):a?s.jsxs("div",{className:"setup-actions",children:[s.jsx("div",{className:"setup-done",children:d("updatesManaged")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]}):s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:u,onClick:z,children:d(u?"installing":"autoInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]})]})})}const Xh=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],xa=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),Jh=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[xa()]});function Ln(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:[xa()]).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 Zh({send:e,providers:t,providerStatus:n,providerKeys:a,fetchModelsResult:o,cloneProviderResult:i,onClose:c}){const d=Le(),[u,f]=l.useState(null),[b,E]=l.useState({}),[y,N]=l.useState({}),[S,M]=l.useState(null),[z,$]=l.useState(!1),[v,P]=l.useState(0),[B,H]=l.useState(null),Q=l.useRef(0),[re,K]=l.useState(null),[j,X]=l.useState(""),[k,Z]=l.useState(null);l.useEffect(()=>{e({type:"list_models_config"}),e({type:"list_providers"}),e({type:"list_provider_keys"})},[e]);const Y=()=>{if(!u)return;const C=u.baseUrl.trim();if(!C){H({ok:!1,text:d("fetchModelsNeedBaseUrl")});return}if(z)return;$(!0),H(null);const ee=v+1;P(ee),e({type:"fetch_models",reqId:ee,baseUrl:C,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader,api:u.api})};l.useEffect(()=>{if(!(!o||o.reqId===Q.current))if(Q.current=o.reqId,$(!1),o.ok&&o.models?.length){const C=o.models;f(ee=>{if(!ee)return ee;const ce=ee.models.map(F=>{if(!F.id.trim())return F;const pe=C.find(Oe=>Oe.id===F.id.trim());if(!pe)return F;const Ee={...F};return!Ee.name&&pe.name&&(Ee.name=pe.name),!Ee.contextWindow&&pe.contextWindow&&(Ee.contextWindow=String(pe.contextWindow)),!Ee.maxTokens&&pe.maxTokens&&(Ee.maxTokens=String(pe.maxTokens)),Ee.input==="text"&&pe.input?.includes("image")&&(Ee.input="text-image"),!Ee.reasoning&&pe.reasoning&&(Ee.reasoning=!0),Ee}),ae=new Set(ce.map(F=>F.id.trim()).filter(Boolean)),_=C.filter(F=>!ae.has(F.id)).map(F=>({id:F.id,name:F.name??"",reasoning:F.reasoning??!1,input:F.input?.includes("image")?"text-image":"text",contextWindow:F.contextWindow?String(F.contextWindow):"",maxTokens:F.maxTokens?String(F.maxTokens):""})),he=[...ce,..._];return he.some(F=>F.id.trim())?{...ee,models:he.filter(F=>F.id.trim())}:ee}),H({ok:!0,text:d("fetchModelsOk",{n:C.length})})}else H({ok:!1,text:o.error||d("fetchModelsEmpty")})},[o]);const me=C=>{const ee=(b[C.id]??"").trim();!ee||S||(M(C.id),e({type:"add_provider_key",provider:C.id,apiKey:ee,name:(y[C.id]??"").trim()||void 0}),setTimeout(()=>{M(null),E(ce=>({...ce,[C.id]:""})),N(ce=>({...ce,[C.id]:""})),e({type:"list_providers"}),e({type:"list_provider_keys"})},1500))},de=(C,ee)=>{e({type:"activate_provider_key",provider:C,keyName:ee}),e({type:"list_provider_keys"})},w=(C,ee)=>{window.confirm(d("removeKeyConfirm"))&&(e({type:"remove_provider_key",provider:C,keyName:ee}),e({type:"list_provider_keys"}))},I=()=>{if(!k)return;const C=k.providerId.trim();if(!C||!k.apiKey.trim())return;const ee=k.models.filter(ae=>ae.id.trim()).map(ae=>({id:ae.id.trim(),name:ae.name.trim()||void 0,reasoning:ae.reasoning||void 0,input:ae.input==="text-image"?["text","image"]:void 0,contextWindow:ae.contextWindow?Number(ae.contextWindow):void 0,maxTokens:ae.maxTokens?Number(ae.maxTokens):void 0})),ce={providerId:C,name:k.name.trim()||void 0,api:k.api.trim()||void 0,baseUrl:k.baseUrl.trim()||void 0,apiKey:k.apiKey.trim()||void 0,authHeader:k.authHeader||void 0,models:ee};e({type:"save_model_config",providerId:C,config:ce}),Z(null),c()},L=()=>{if(!u)return;const C=u.providerId.trim(),ee=u.models.filter(ae=>ae.id.trim()).map(ae=>({id:ae.id.trim(),name:ae.name.trim()||void 0,reasoning:ae.reasoning||void 0,input:ae.input==="text-image"?["text","image"]:void 0,contextWindow:ae.contextWindow?Number(ae.contextWindow):void 0,maxTokens:ae.maxTokens?Number(ae.maxTokens):void 0})),ce={providerId:C,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:ee};e({type:"save_model_config",providerId:C,config:ce}),c()};l.useEffect(()=>{if(i&&i.ok){const C=i.configs;if(C&&C.length>1){K(C.map(ee=>Ln({...ee,apiKey:""}))),X("");return}if(i.config){Z(Ln({...i.config,apiKey:""}));return}}},[i]);const oe=C=>{window.confirm(d("clearKeyConfirm",{id:C}))&&e({type:"clear_provider_api_key",provider:C})},se=C=>{window.confirm(d("deleteProviderConfirm",{id:C.providerId,n:C.models.length}))&&e({type:"delete_model_config",providerId:C.providerId})},ye=(C,ee)=>{u&&f({...u,models:u.models.map((ce,ae)=>ae===C?{...ce,...ee}:ce)})};return s.jsx("div",{className:"modal-backdrop",onClick:c,children:s.jsxs("div",{className:"modal model-modal",onClick:C=>C.stopPropagation(),children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":d("close"),onClick:c,children:s.jsx($e,{})}),s.jsx("div",{className:"modal-head",children:s.jsx("h2",{children:k?d("addKey"):re?d("batchCreateProviders",{n:re.length}):d(u?"editProvider":"manageModelsTitle")})}),k?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:d("secondKeyTitle",{api:k.api,baseUrl:k.baseUrl||d("noBaseUrlShort"),n:k.models.length})}),s.jsxs("div",{className:"form-grid",children:[s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:[d("providerNameLabel")," ",s.jsx("em",{children:d("providerNameHint")})]}),s.jsx("input",{type:"text",value:k.providerId,onChange:C=>Z({...k,providerId:C.target.value}),placeholder:"opencode-2"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKeyLabel")}),s.jsx("input",{type:"password",value:k.apiKey,onChange:C=>Z({...k,apiKey:C.target.value}),placeholder:d("secondKeyPlaceholder")})]})]}),s.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:8},children:[k.models.slice(0,5).map(C=>C.id).join(", "),k.models.length>5?` … +${k.models.length-5}`:""]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>Z(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn",onClick:()=>{const C=k;Z(null),f(C)},children:d("advancedEdit")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!k.providerId.trim()||!k.apiKey.trim(),onClick:I,children:d("save")})]})]}):re?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:d("batchDesc",{apis:re.map(C=>C.api).join("、"),n:re.length})}),s.jsxs("label",{className:"field",style:{marginBottom:16},children:[s.jsx("span",{className:"field-label",children:d("batchKeyLabel",{n:re.length})}),s.jsx("input",{type:"password",value:j,onChange:C=>X(C.target.value),placeholder:d("secondKeyPlaceholder")})]}),s.jsx("div",{className:"provider-list",style:{marginBottom:16},children:re.map((C,ee)=>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:C.providerId}),s.jsx("span",{style:{opacity:.7},children:C.api})]}),s.jsxs("div",{className:"provider-sub",style:{fontSize:12,opacity:.7},children:[C.baseUrl||d("noBaseUrlShort")," · ",d("modelsCountShort",{n:C.models.length}),C.models.slice(0,3).map(ce=>ce.id).join(", "),C.models.length>3?` … +${C.models.length-3}`:""]}),s.jsx("input",{type:"text",value:C.providerId,onChange:ce=>K(ae=>ae.map((_,he)=>he===ee?{..._,providerId:ce.target.value}:_)),placeholder:d("providerIdPlaceholder"),style:{fontSize:12}}),s.jsx("input",{type:"text",value:C.baseUrl,onChange:ce=>K(ae=>ae.map((_,he)=>he===ee?{..._,baseUrl:ce.target.value}:_)),placeholder:d("baseUrlExamplePh"),style:{fontSize:12}})]},ee))})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>K(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!j.trim(),onClick:()=>{for(const C of re){const ee=C.providerId.trim();if(!ee)continue;const ce=C.models.filter(_=>_.id.trim()).map(_=>({id:_.id.trim(),name:_.name.trim()||void 0,reasoning:_.reasoning||void 0,input:_.input==="text-image"?["text","image"]:void 0,contextWindow:_.contextWindow?Number(_.contextWindow):void 0,maxTokens:_.maxTokens?Number(_.maxTokens):void 0})),ae={providerId:ee,name:C.name.trim()||void 0,api:C.api.trim()||void 0,baseUrl:C.baseUrl.trim()||void 0,apiKey:j.trim()||void 0,authHeader:C.authHeader||void 0,models:ce};e({type:"save_model_config",providerId:ee,config:ae})}K(null),c()},children:d("saveAllBatch",{n:re.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:[d("providerId")," ",s.jsx("em",{children:d("providerIdHint")})]}),s.jsx("input",{type:"text",value:u.providerId,disabled:t.some(C=>C.providerId===u.providerId),onChange:C=>f({...u,providerId:C.target.value}),placeholder:"my-proxy"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("displayName")}),s.jsx("input",{type:"text",value:u.name,onChange:C=>f({...u,name:C.target.value}),placeholder:d("displayNamePh")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiType")}),s.jsx("select",{value:u.api,onChange:C=>f({...u,api:C.target.value}),children:Xh.map(C=>s.jsx("option",{value:C,children:C},C))})]}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:["baseUrl ",s.jsx("em",{children:d("baseUrlHint")})]}),s.jsx("input",{type:"text",value:u.baseUrl,onChange:C=>f({...u,baseUrl:C.target.value}),placeholder:"http://localhost:11434/v1"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKey")}),s.jsx("input",{type:"password",value:u.apiKey,onChange:C=>f({...u,apiKey:C.target.value}),placeholder:d("apiKeyHint")})]}),s.jsxs("label",{className:"field check",children:[s.jsx("input",{type:"checkbox",checked:u.authHeader,onChange:C=>f({...u,authHeader:C.target.checked})}),s.jsx("span",{children:d("authHeader")})]})]}),s.jsxs("div",{className:"model-section-head",children:[s.jsx("span",{className:"form-section-title",children:d("modelsTitle")}),s.jsxs("span",{className:"model-section-actions",children:[B&&s.jsx("span",{className:`fetch-msg ${B.ok?"ok":"err"}`,title:B.text,children:B.text}),s.jsxs("button",{type:"button",className:"btn sm",disabled:z||!u.baseUrl.trim(),title:d("fetchModelsHint"),onClick:Y,children:[s.jsx(Ht,{})," ",d(z?"fetchingModels":"fetchModels")]})]})]}),u.models.map((C,ee)=>s.jsxs("div",{className:"model-row",children:[s.jsx("input",{type:"text",value:C.id,onChange:ce=>ye(ee,{id:ce.target.value}),placeholder:d("modelIdReq")}),s.jsx("input",{type:"text",value:C.name,onChange:ce=>ye(ee,{name:ce.target.value}),placeholder:d("displayName")}),s.jsxs("select",{value:C.input,onChange:ce=>ye(ee,{input:ce.target.value}),children:[s.jsx("option",{value:"text",children:d("text")}),s.jsx("option",{value:"text-image",children:d("textImage")})]}),s.jsxs("label",{className:"check",children:[s.jsx("input",{type:"checkbox",checked:C.reasoning,onChange:ce=>ye(ee,{reasoning:ce.target.checked})}),s.jsx("span",{children:d("reasoning")})]}),s.jsx("input",{type:"number",value:C.contextWindow,onChange:ce=>ye(ee,{contextWindow:ce.target.value}),placeholder:d("contextWindow"),title:"contextWindow"}),s.jsx("input",{type:"number",value:C.maxTokens,onChange:ce=>ye(ee,{maxTokens:ce.target.value}),placeholder:d("maxOutput"),title:"maxTokens"}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("removeModel"),onClick:()=>f({...u,models:u.models.filter((ce,ae)=>ae!==ee)}),children:s.jsx(et,{})})]},ee)),s.jsxs("button",{type:"button",className:"btn",onClick:()=>f({...u,models:[...u.models,xa()]}),children:[s.jsx(dt,{})," ",d("addModel")]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>f(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!u.providerId.trim()||!u.models.some(C=>C.id.trim()),onClick:L,children:d("save")})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-fixed-hint",children:s.jsxs("div",{className:"form-section-title",children:[d("builtinProviders")," ",s.jsx("em",{className:"section-hint",children:d("hintKeyOnly")})]})}),s.jsxs("div",{className:"model-modal-body",children:[s.jsxs("div",{className:"provider-list",children:[n.length===0&&s.jsx("div",{className:"dd-loading",children:d("loading")}),n.map(C=>{const ee=a[C.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:C.name}),s.jsxs("span",{className:"provider-sub",children:[C.id,C.configured&&s.jsx("span",{className:"auth-badge",children:d("configuredBadge")}),C.source&&!C.configured&&s.jsx("span",{className:"auth-badge dim",children:C.source})]})]}),C.source==="stored"&&s.jsxs("button",{type:"button",className:"btn sm danger",title:d("clearKeyTitle"),onClick:()=>oe(C.id),children:[s.jsx(et,{})," ",d("clearKey")]})]}),s.jsxs("div",{className:"provider-keys",children:[ee.length===0&&s.jsx("div",{className:"provider-key-empty",children:d("noKeyYet")}),ee.map(ce=>s.jsxs("div",{className:`provider-key-item ${ce.active?"active":""}`,children:[s.jsx("span",{className:"provider-key-dot",children:ce.active?"●":"○"}),s.jsx("span",{className:"provider-key-label",children:ce.name}),!ce.active&&s.jsx("button",{type:"button",className:"iconbtn",title:d("activateKey"),onClick:()=>de(C.id,ce.name),children:s.jsx(Tt,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("removeKey"),onClick:()=>w(C.id,ce.name),children:s.jsx(et,{})})]},ce.name)),s.jsxs("div",{className:"provider-add-key",children:[s.jsx("input",{type:"text",className:"key-input key-input-name",placeholder:d("keyNamePh"),value:y[C.id]??"",onChange:ce=>N(ae=>({...ae,[C.id]:ce.target.value}))}),s.jsx("input",{type:"password",className:"key-input key-input-value",placeholder:d("addKeyPlaceholder"),value:b[C.id]??"",onChange:ce=>E(ae=>({...ae,[C.id]:ce.target.value}))}),s.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(b[C.id]??"").trim()||S===C.id,onClick:()=>me(C),children:[s.jsx(dt,{})," ",S===C.id?d("savingKey"):d("addKey")]})]})]})]},C.id)})]}),s.jsx("div",{className:"form-section-title",children:d("customProviders")}),s.jsx("p",{className:"modal-desc",children:d("customDesc")}),s.jsx("p",{className:"modal-desc",children:d("reloadModelsHint")}),t.length===0&&s.jsx("div",{className:"dd-loading",children:d("noCustomProviders")}),s.jsx("div",{className:"provider-list",children:t.map(C=>s.jsxs("div",{className:"provider-row",children:[s.jsxs("div",{className:"provider-info",children:[s.jsx("span",{className:"provider-name",children:C.providerId}),s.jsxs("span",{className:"provider-sub",children:[C.api??"—",C.baseUrl?` · ${C.baseUrl}`:"",C.models.length>0&&` · ${d("modelsCount",{n:C.models.length})}`]})]}),s.jsxs("div",{className:"provider-actions",children:[s.jsx("button",{type:"button",className:"iconbtn",title:d("edit"),onClick:()=>f(Ln(C)),children:s.jsx(Zs,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("delete"),onClick:()=>se(C),children:s.jsx(et,{})})]})]},C.providerId))})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsxs("button",{type:"button",className:"btn",onClick:()=>e({type:"reload_models_config"}),children:[s.jsx(kt,{})," ",d("reloadModelsConfig")]}),s.jsxs("button",{type:"button",className:"btn primary",onClick:()=>f(Jh()),children:[s.jsx(dt,{})," ",d("addProvider")]})]})]})]})})}function ef({plugin:e,send:t}){const n=Le(),a=e.settingsSchema??[],[o,i]=l.useState(()=>({...e.settingsValues})),[c,d]=l.useState(!1);if(a.length===0)return null;const u=(y,N)=>i(S=>({...S,[y]:N})),f=a.some(y=>o[y.key]!==e.settingsValues?.[y.key]),b=()=>{d(!0),t({type:"plugin_settings",pluginId:e.id,values:o}),setTimeout(()=>d(!1),800)},E=()=>i({...e.settingsValues});return s.jsxs("div",{className:"plugin-settings-form",children:[s.jsx("div",{className:"plugin-settings-fields",children:a.map(y=>s.jsxs("label",{className:"plugin-settings-field",title:y.hint,children:[s.jsx("span",{className:"plugin-settings-label",children:y.label}),y.type==="boolean"?s.jsx("input",{type:"checkbox",checked:!!o[y.key],onChange:N=>u(y.key,N.target.checked)}):y.type==="select"?s.jsx("select",{value:String(o[y.key]??""),onChange:N=>u(y.key,N.target.value),children:(y.options??[]).map(N=>s.jsx("option",{value:N,children:N},N))}):s.jsx("input",{type:y.type==="password"?"password":y.type==="number"?"number":"text",value:String(o[y.key]??""),min:y.min,max:y.max,onChange:N=>u(y.key,y.type==="number"?Number(N.target.value):N.target.value)})]},y.key))}),s.jsxs("div",{className:"plugin-settings-actions",children:[s.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!f||c,onClick:b,children:n(c?"pluginSettingsSaving":"pluginSettingsSave")}),s.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:E,children:n("pluginSettingsReset")})]})]})}const ko="pi-web-ui:wide-chat",rn={wide:!1};function Co(e){if(!e||typeof e!="object")return{...rn};const t=e;return{wide:typeof t.wide=="boolean"?t.wide:rn.wide}}function tf(){try{const e=localStorage.getItem(ko);return e?Co(JSON.parse(e)):{...rn}}catch{return{...rn}}}function sf(e){const t=Co(e);try{localStorage.setItem(ko,JSON.stringify(t))}catch{}$s=t;for(const n of sa)n()}let $s=null;const sa=new Set;function nf(e){return sa.add(e),()=>{sa.delete(e)}}function af(){return $s||($s=tf()),$s.wide}function vo(){return l.useSyncExternalStore(nf,af)}const _o="pi-web-ui:project-title",on={projectName:!0};function So(e){if(!e||typeof e!="object")return{...on};const t=e;return{projectName:typeof t.projectName=="boolean"?t.projectName:on.projectName}}function rf(e){return e?e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"":""}function of(){try{const e=localStorage.getItem(_o);return e?So(JSON.parse(e)):{...on}}catch{return{...on}}}function lf(e){const t=So(e);try{localStorage.setItem(_o,JSON.stringify(t))}catch{}Ws=t;for(const n of na)n()}let Ws=null;const na=new Set;function cf(e){return na.add(e),()=>{na.delete(e)}}function uf(){return Ws||(Ws=of()),Ws.projectName}function Ao(){return l.useSyncExternalStore(cf,uf)}const wo="pi-web-ui:wallpaper",df="has-wallpaper",Cs={url:"",dim:78,blur:0},mf=2e3,pf=28e5;function aa(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.toLowerCase().startsWith("data:image/")?pf:mf;return t.length>n?"":/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith("/")&&!t.startsWith("//")?t:""}const Bi=(e,t,n,a)=>typeof e!="number"||!Number.isFinite(e)?a:Math.min(n,Math.max(t,Math.round(e)));function Io(e){if(!e||typeof e!="object")return{...Cs};const t=e;return{url:aa(t.url),dim:Bi(t.dim,0,95,Cs.dim),blur:Bi(t.blur,0,24,Cs.blur)}}function jo(){try{const e=localStorage.getItem(wo);return e?Io(JSON.parse(e)):{...Cs}}catch{return{...Cs}}}function hf(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/[\r\n]/g,"")}async function ff(e){const t=await Ea(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function Ks(){const e=vs??jo(),t=document.documentElement;e.url?(t.style.setProperty("--bg-image",`url("${hf(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(df,e.url!==""||n!==""&&n!=="none")}function ms(e){const t=Io(e);vs=t;try{localStorage.setItem(wo,JSON.stringify(t))}catch{}for(const n of ia)n();Ks()}let vs=null;const ia=new Set;function gf(e){return ia.add(e),()=>{ia.delete(e)}}function bf(){return vs||(vs=jo()),vs}function Lo(){return l.useSyncExternalStore(gf,bf)}function Ef(){const e=Lo();l.useEffect(()=>{Ks()},[e]),l.useEffect(()=>{const t=()=>Ks();return window.addEventListener(Rt,t),Ks(),()=>window.removeEventListener(Rt,t)},[])}const ln={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"]},ra=["soul","tools","guidelines","pi_docs","append","persona","terminal","markers","context","skills","cwd"],Tf=["tools","pi_docs","persona","terminal","markers","context","skills","cwd"];function xf(e){return Tf.includes(e)}const Bs=ra.map(e=>`{{${e}}}`).join(`
|
|
328
|
-
|
|
329
|
-
`);function
|
|
330
|
-
|
|
331
|
-
{{${m}}}`:`{{${m}}}`)},
|
|
332
|
-
`).length>6||Ne.length>480;if(
|
|
333
|
-
`).length)),autoFocus:Ge,placeholder:i("promptOverridePlaceholder"),value:ne,onFocus:He=>{v.current=m,B(m);const tt=He.currentTarget;tt.value&&tt.value===Ne&&tt.setSelectionRange(tt.value.length,tt.value.length)},onBlur:()=>{v.current===m&&(v.current=null);const He=M[m]??"";if(He.trim()&&He===Ne){gn(m);return}Ko(m),He.trim()||B(null)},onChange:He=>z(tt=>({...tt,[m]:He.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:i("promptSourceRefLabel")}),ct&&s.jsx("button",{type:"button",className:"source-default-toggle",onClick:()=>ls(m),children:H[m]?i("promptSourceCollapse"):i("promptSourceExpand")})]}),Ne.trim()?s.jsx("pre",{className:`source-default-text${ct?H[m]?" expanded":" clamped":""}`,children:Ne}):s.jsx("span",{className:"source-default-empty",children:i("promptSourceDefaultEmpty")}),!ne.trim()&&Ne.trim()&&s.jsx("button",{type:"button",className:"override-seed-btn",title:i("promptSourceSeedTip"),onClick:()=>bn(m,Ne),children:i("promptSourceSeedButton")})]})]}):s.jsx("div",{className:"source-default",title:i("promptSourceDefaultEditHint"),role:"button",tabIndex:0,onClick:()=>bn(m,Ne),onKeyDown:He=>{(He.key==="Enter"||He.key===" ")&&(He.preventDefault(),bn(m,Ne))},children:Ne.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ct?H[m]?" expanded":" clamped":""}`,children:Ne}),ct&&s.jsx("span",{className:"source-default-toggle",role:"button",tabIndex:0,onClick:He=>{He.stopPropagation(),ls(m)},onKeyDown:He=>{(He.key==="Enter"||He.key===" ")&&(He.preventDefault(),He.stopPropagation(),ls(m))},children:H[m]?i("promptSourceCollapse"):i("promptSourceExpand")})]}):s.jsx("span",{className:"source-default-empty",children:i("promptSourceDefaultEmpty")})})]},m)}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"set-btn",onClick:Yo,disabled:!zo,children:i("promptResetAll")})})]}),s.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":ye,onClick:()=>C(m=>!m),children:[i("settingsViewPrompt")," ",ye?"▴":"▾"]}),ye&&s.jsxs("div",{className:"set-prompt-view",children:[s.jsxs("div",{className:"set-prompt-view-head",children:[s.jsx("span",{children:i("settingsViewPromptHint")}),s.jsx(an,{text:u.effectiveSystemPrompt})]}),u.effectiveSystemPrompt?s.jsx("pre",{className:"set-prompt-view-text",children:u.effectiveSystemPrompt}):s.jsx("p",{className:"set-empty",children:i("settingsViewPromptEmpty")}),s.jsxs("div",{className:"set-prompt-tools",children:[s.jsxs("div",{className:"set-prompt-view-head",children:[s.jsx("span",{children:i("settingsViewToolsSchema")}),s.jsx(an,{text:u.toolsSchema})]}),s.jsx("p",{className:"set-hint",children:i("settingsViewToolsSchemaHint")}),u.toolsSchema?s.jsx("pre",{className:"set-prompt-view-text",children:u.toolsSchema}):s.jsx("p",{className:"set-empty",children:i("settingsViewToolsSchemaEmpty")})]})]})]}),b==="prompt-history"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Bn,{className:"set-section-icon"}),i("settingsPromptHistory"),s.jsx(ft,{text:i("settingsPromptHistoryDesc")}),s.jsx("span",{className:"set-count",children:i("promptHistoryCount",{n:String(G)})})]}),G===0?s.jsx("p",{className:"set-empty",children:i("promptHistoryEmpty")}):s.jsx("p",{className:"set-hint",children:i("promptHistoryCount",{n:String(G)})}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"ph-max",children:i("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(ue.maxEntries),onChange:m=>{const ne=Math.floor(Number(m.target.value)||0),Ne={...ue,maxEntries:ne};ie(Ne)},onBlur:()=>{const m={...ue};(!Number.isFinite(m.maxEntries)||m.maxEntries<1)&&(m.maxEntries=1),m.maxEntries>500&&(m.maxEntries=500),m.maxEntries=Math.floor(m.maxEntries),ie(m),jn(m),g()}}),s.jsx(ft,{text:i("promptHistoryMaxHint")})]})]}),s.jsx(ze,{title:i("promptHistoryCharLimit"),tip:i("promptHistoryCharLimitHint"),enabled:ue.charLimitEnabled,onToggle:()=>{const m={...ue,charLimitEnabled:!ue.charLimitEnabled};ie(m),jn(m),g()}}),ue.charLimitEnabled&&s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"ph-char-limit",children:i("promptHistoryCharLimit")}),s.jsx("input",{id:"ph-char-limit",className:"set-input",type:"number",min:100,max:2e4,step:100,placeholder:i("promptHistoryCharLimitPlaceholder"),value:String(ue.charLimit),onChange:m=>{const ne=Math.floor(Number(m.target.value)||0);ie({...ue,charLimit:ne})},onBlur:()=>{let m=Math.floor(Number(ue.charLimit)||0);(!Number.isFinite(m)||m<100)&&(m=100),m>2e4&&(m=2e4);const ne={...ue,charLimit:m};ie(ne),jn(ne),g()}})]}),s.jsxs("div",{className:"set-field",style:{marginTop:12},children:[s.jsxs("button",{type:"button",className:`set-uninstall${Re?" confirm":""}`,disabled:G===0,title:i(G===0?"promptHistoryEmpty":"promptHistoryClear"),onClick:()=>{if(!Re){x(!0);return}Lh(),x(!1),g()},children:[s.jsx(et,{})," ",i(Re?"promptHistoryClearConfirm":"promptHistoryClear")]}),G>0&&s.jsx("span",{className:"set-hint",style:{marginLeft:8},children:i("promptHistoryCount",{n:String(G)})})]}),s.jsxs("p",{className:"set-hint",children:[s.jsx(ar,{style:{verticalAlign:"-2px",marginRight:4}}),i("settingsPromptHistoryDesc")]})]}),b==="terminal"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Zt,{className:"set-section-icon"}),i("settingsTerminalTools")]}),s.jsx(ze,{title:i("terminalToolsEnabled"),tip:i("settingsTerminalToolsDesc"),enabled:u.terminalToolsEnabled,onToggle:()=>Me({terminalToolsEnabled:!u.terminalToolsEnabled})}),!u.terminalToolsEnabled&&s.jsx("p",{className:"set-hint",children:i("terminalToolsOffHint")}),s.jsx(ze,{title:i("terminalBashTakeover"),tip:i("terminalBashTakeoverDesc"),enabled:u.terminalBash,onToggle:()=>Me({terminalBash:!u.terminalBash})}),u.terminalBash&&s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"tb-idle-ms",children:i("terminalBashIdleMs")}),s.jsx("input",{id:"tb-idle-ms",className:"set-input",type:"number",min:0,step:1e3,value:_e,onChange:m=>ve(m.target.value),onBlur:()=>{const m=Math.max(0,Math.floor(Number(_e)||0));ve(String(m)),m!==u.terminalBashIdleMs&&Me({terminalBashIdleMs:m})}})]})]}),b==="edit"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Xt,{className:"set-section-icon"}),i("settingsEditTools")]}),s.jsx(ze,{title:i("editSoftEnabled"),tip:i("editSoftEnabledDesc"),enabled:u.editSoftEnabled,onToggle:()=>Me({editSoftEnabled:!u.editSoftEnabled})}),!u.editSoftEnabled&&s.jsx("p",{className:"set-hint",children:i("editSoftOffHint")})]}),b==="question"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Pa,{className:"set-section-icon"}),i("settingsQuestionnaire")]}),s.jsx(ze,{title:i("questionnaireEnabled"),tip:i("questionnaireEnabledDesc"),enabled:u.questionnaireEnabled,onToggle:()=>Me({questionnaireEnabled:!u.questionnaireEnabled})}),!u.questionnaireEnabled&&s.jsx("p",{className:"set-hint",children:i("questionnaireOffHint")})]}),b==="display"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(es,{className:"set-section-icon"}),i("settingsMessageDisplay")]}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"model-retry-max",children:i("modelRetryAttempts")}),s.jsx("input",{id:"model-retry-max",className:"set-input",type:"number",min:0,max:100,step:1,value:Be,onChange:m=>Fe(m.target.value),onBlur:()=>{const m=Math.min(100,Math.max(0,Math.floor(Number(Be)||0)));Fe(String(m)),m!==u.retryMaxAttempts&&Me({retryMaxAttempts:m})},onKeyDown:m=>{m.key==="Enter"&&m.target.blur()}}),s.jsx("p",{className:"set-hint",children:i("modelRetryHint")})]}),s.jsx("hr",{className:"set-sep"}),s.jsx(ze,{title:i("thinkingWrap"),tip:i("thinkingWrapDesc"),enabled:u.thinkingWrap??!0,onToggle:()=>Me({thinkingWrap:!(u.thinkingWrap??!0)})}),s.jsx(ze,{title:i("toolsWrap"),tip:i("toolsWrapDesc"),enabled:u.toolsWrap??!0,onToggle:()=>Me({toolsWrap:!(u.toolsWrap??!0)})}),s.jsx("hr",{className:"set-sep"}),s.jsx(ze,{title:i("wideChat"),tip:i("wideChatDesc"),enabled:ee,onToggle:()=>sf({wide:!ee})}),s.jsx(ze,{title:i("projectTitle"),tip:i("projectTitleDesc"),enabled:ce,onToggle:()=>lf({projectName:!ce})}),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:[i("wallpaperTitle"),s.jsx(ft,{text:i("wallpaperDesc")})]}),s.jsxs("div",{className:"wallpaper-url-row",children:[s.jsx("input",{className:"set-input wallpaper-url",placeholder:i("wallpaperUrlPh"),value:_,maxLength:2e3,spellCheck:!1,onFocus:()=>{F.current=!0},onChange:m=>he(m.target.value),onBlur:()=>{if(F.current=!1,!_.trim()&&ae.url.startsWith("data:")){he("");return}const m=aa(_);he(m),m!==ae.url&&ms({...ae,url:m})},onKeyDown:m=>{m.key==="Enter"?m.target.blur():m.key==="Escape"&&(he(ae.url.startsWith("data:")?"":ae.url),m.target.blur())}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:Ee,onClick:()=>pe.current?.click(),children:[s.jsx(Qi,{})," ",i("wallpaperUpload")]}),s.jsx("input",{ref:pe,type:"file",accept:"image/*",hidden:!0,onChange:ge})]}),Se&&s.jsx("p",{className:"set-hint",children:i("wallpaperUploadFailed")}),s.jsxs("div",{className:"wallpaper-sliders",children:[s.jsxs("label",{className:"wallpaper-slider",children:[s.jsx("span",{children:i("wallpaperDim")}),s.jsx("input",{type:"range",min:0,max:95,step:1,value:ae.dim,onChange:m=>ms({...ae,dim:Number(m.target.value)})}),s.jsxs("output",{children:[ae.dim,"%"]})]}),s.jsxs("label",{className:"wallpaper-slider",children:[s.jsx("span",{children:i("wallpaperBlur")}),s.jsx("input",{type:"range",min:0,max:24,step:1,value:ae.blur,onChange:m=>ms({...ae,blur:Number(m.target.value)})}),s.jsxs("output",{children:[ae.blur,"px"]})]})]})]}),ae.url&&s.jsxs("div",{className:"wallpaper-current",children:[s.jsx("img",{className:"wallpaper-preview",src:ae.url,alt:""}),s.jsx("button",{type:"button",className:"wallpaper-clear",onClick:()=>{he(""),ms({...ae,url:""})},children:i("wallpaperClear")})]})]})]}),b==="quick"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Qs,{className:"set-section-icon"}),i("quickPhrases"),s.jsx(ft,{text:i("quickPhrasesDesc")}),s.jsx("span",{className:"set-count",children:u.quickPhrases.length})]}),s.jsx(ze,{title:i("quickPhrasesEnabled"),tip:i("quickPhrasesDesc"),enabled:u.quickPhrasesEnabled,onToggle:()=>Me({quickPhrasesEnabled:!u.quickPhrasesEnabled})}),!u.quickPhrasesEnabled&&s.jsx("p",{className:"set-hint",children:i("quickPhrasesOffHint")}),s.jsxs("div",{className:"set-preset-save",children:[s.jsx("input",{className:"set-input",placeholder:i("quickPhrasesPlaceholder"),value:lt,maxLength:200,onChange:m=>At(m.target.value),onKeyDown:m=>{m.key==="Enter"&<.trim()&&(Me({quickPhrases:[...u.quickPhrases,lt.trim()]}),At(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!lt.trim(),onClick:()=>{Me({quickPhrases:[...u.quickPhrases,lt.trim()]}),At("")},children:[s.jsx(dt,{})," ",i("quickPhrasesAdd")]})]}),u.quickPhrases.length===0?s.jsx("p",{className:"set-empty",children:i("quickPhrasesEmpty")}):s.jsx("div",{className:"set-list",children:u.quickPhrases.map((m,ne)=>s.jsx("div",{className:"set-row",children:R?.index===ne?s.jsx("div",{className:"set-row-info",children:s.jsx("input",{className:"set-input",autoFocus:!0,value:R.value,maxLength:200,placeholder:i("quickPhrasesEditPh"),onChange:Ne=>W({index:ne,value:Ne.target.value}),onKeyDown:Ne=>{Ne.key==="Enter"?Kt():Ne.key==="Escape"&&W(null)},onBlur:Kt})}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"set-row-info",children:s.jsx("div",{className:"set-row-name",title:m,children:m})}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesEdit"),onClick:()=>W({index:ne,value:m}),children:s.jsx(Xt,{})}),s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesMoveUp"),disabled:ne===0,onClick:()=>{const Ne=[...u.quickPhrases];[Ne[ne-1],Ne[ne]]=[Ne[ne],Ne[ne-1]],Me({quickPhrases:Ne})},children:"↑"}),s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesMoveDown"),disabled:ne===u.quickPhrases.length-1,onClick:()=>{const Ne=[...u.quickPhrases];[Ne[ne],Ne[ne+1]]=[Ne[ne+1],Ne[ne]],Me({quickPhrases:Ne})},children:"↓"}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("quickPhrasesDelete"),onClick:()=>Me({quickPhrases:u.quickPhrases.filter((Ne,Ge)=>Ge!==ne)}),children:s.jsx(et,{})})]})]})},`${ne}:${m}`))}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{W(null),Me({quickPhrases:ln[c]??ln.en})},children:i("quickPhrasesReset")})})]}),b==="markers"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Ra,{className:"set-section-icon"}),i("settingsMarkers"),s.jsx(ft,{text:i("settingsMarkersDesc")}),s.jsx("span",{className:"set-count",children:u.markers?.length??0})]}),s.jsx(ze,{title:i("markersEnabled"),tip:i("markersEnabledDesc"),enabled:rt,onToggle:()=>Me({markersEnabled:!rt})}),!rt&&s.jsx("p",{className:"set-hint",children:i("markersOffHint")}),rt&&(u.markers?.length??0)===0&&s.jsxs("p",{className:"set-empty",children:[i("loading"),"..."]}),rt&&u.markers&&u.markers.length>0&&s.jsx("div",{className:"set-list",children:u.markers.map(m=>s.jsx(ze,{title:m.name==="todo"?i("markerGroupTodo"):m.name==="notify"?i("markerGroupNotify"):m.name==="conv"?i("markerGroupRename"):m.name,subtitle:(m.guidance[0]??"").slice(0,120),tip:m.guidance.join(`
|
|
334
|
-
`),enabled:m.enabled,onToggle:()=>pt(m.name)},m.name))}),rt&&s.jsx("p",{className:"set-hint",children:i("markerRenameTip")})]}),b==="skills"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(_s,{className:"set-section-icon"}),i("settingsSkills"),s.jsx("span",{className:"set-count",children:u.skills.length})]}),u.skills.length===0?s.jsx("p",{className:"set-empty",children:i(f?"dshSkillsNote":"noSkills")}):s.jsx("div",{className:"set-list",children:u.skills.map(m=>s.jsx(ze,{title:m.name,subtitle:m.description,enabled:m.enabled,onToggle:()=>q(m)},m.name))})]}),b==="extensions"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(En,{className:"set-section-icon"}),i("settingsExtensions"),s.jsx("span",{className:"set-count",children:u.extensions.length})]}),u.extensions.length===0?s.jsx("p",{className:"set-empty",children:i(f?"dshExtensionsNote":"noExtensions")}):s.jsx("div",{className:"set-list",children:u.extensions.map(m=>{const ne=m.id.startsWith("npm:")?m.id.slice(4):null;return s.jsx(ze,{title:m.name,subtitle:m.path,enabled:m.enabled,onToggle:()=>Ye(m),action:ne?J===m.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>Fo(ne),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("uninstallHint"),onClick:()=>le(m.id),children:[s.jsx(et,{}),i("uninstallExt")]}):void 0},m.id)})})]}),b==="plugins"&&e.managed&&s.jsx("div",{className:"set-section",children:s.jsx("div",{className:"set-note",children:i("updatesManaged")})}),b==="plugins"&&!e.managed&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(En,{className:"set-section-icon"}),i("pluginMarket"),s.jsx("span",{className:"set-count",children:e.pluginCatalog.length}),s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginCatalogAddHint"),onClick:()=>xt(m=>!m),children:[s.jsx(dt,{}),i("pluginCatalogAdd")]})]}),os&&s.jsxs("div",{className:"set-catalog-add",children:[s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogSource"),value:Ie,onChange:m=>Ae(m.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogId"),value:D,onChange:m=>we(m.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogName"),value:Ce,onChange:m=>qe(m.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogIcon"),value:mt,onChange:m=>St(m.target.value)}),s.jsx("textarea",{className:"set-input",rows:2,placeholder:i("pluginCatalogDesc"),value:De,onChange:m=>Xe(m.target.value)}),s.jsxs("div",{className:"set-catalog-add-actions",children:[s.jsx("button",{type:"button",className:"set-uninstall confirm",disabled:!Ie.trim(),onClick:qo,children:i("pluginCatalogAddSubmit")}),s.jsx("button",{type:"button",className:"set-uninstall",onClick:()=>xt(!1),children:i("cancel")})]})]}),e.pluginCatalog.length===0?s.jsx("p",{className:"set-empty",children:i("noPluginCatalog")}):s.jsx("div",{className:"set-list",children:e.pluginCatalog.map(m=>{const ne=je.has(m.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:[m.icon?`${m.icon} `:"",m.name]}),ne&&s.jsx("span",{className:"set-catalog-installed",children:i("pluginInstalled")}),!m.builtin&&s.jsx("span",{className:"set-catalog-custom",children:i("pluginCatalogCustom")})]}),m.description&&s.jsx("div",{className:"set-catalog-desc",children:m.description}),s.jsx("div",{className:"set-catalog-source",children:m.source})]}),s.jsxs("div",{className:"set-row-actions",children:[ne?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>Na(m.id,m.source),children:[s.jsx(kt,{}),i("pluginUpdate")]}),be===m.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>ya(m.id),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>ke(m.id),children:[s.jsx(et,{}),i("uninstallExt")]})]}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginInstallHint"),onClick:()=>Ho(m),children:[s.jsx(Ht,{}),i("pluginInstall")]}),!m.builtin&&s.jsx("button",{type:"button",className:"set-uninstall",title:i("pluginCatalogRemoveHint"),onClick:()=>Uo(m.id),children:s.jsx($e,{})})]})]},m.id)})})]}),b==="plugins"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Tn,{className:"set-section-icon"}),i("settingsUiPlugins"),s.jsx("span",{className:"set-count",children:e.plugins.length})]}),e.plugins.length===0?s.jsx("p",{className:"set-empty",children:i("noUiPlugins")}):s.jsx("div",{className:"set-list",children:e.plugins.map(m=>s.jsxs(s.Fragment,{children:[s.jsx(ze,{title:`${m.icon?`${m.icon} `:""}${m.name}`,subtitle:(m.error?`${m.id} · ${m.error}`:m.source?`${m.id} · ${m.source}`:`${m.id} · ${i("uiPluginNoSource")}`)+(m.permissions?.length?` · ${i("uiPluginPerms")}: ${m.permissions.join(", ")}`:""),enabled:!xe.has(m.id)&&!m.error,onToggle:()=>!m.error&&Ke(m),action:s.jsxs("div",{className:"set-row-actions",children:[m.source&&s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>Na(m.id,m.source),children:[s.jsx(kt,{}),i("pluginUpdate")]}),be===m.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>ya(m.id),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>ke(m.id),children:[s.jsx(et,{}),i("uninstallExt")]})]})},m.id),m.settingsSchema&&m.settingsSchema.length>0&&s.jsx(ef,{plugin:m,send:t})]}))})]}),b==="plugins"&&e.engine==="dsh"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Tn,{className:"set-section-icon"}),i("dshPatches"),s.jsx(ft,{text:i("dshPatchesDesc")}),s.jsx("span",{className:"set-count",children:e.dshPatches?.files.length??0}),s.jsxs("button",{type:"button",className:"set-uninstall",title:i("dshPatchesRescanHint"),onClick:()=>t({type:"dsh_patches_rescan"}),children:[s.jsx(kt,{}),i("dshPatchesRescan")]})]}),(e.dshPatches?.files.length??0)===0?s.jsx("p",{className:"set-empty",children:i("dshPatchesEmpty")}):s.jsx("div",{className:"set-list",children:e.dshPatches.files.map(m=>s.jsx("div",{className:"set-row",children:s.jsxs("div",{className:"set-row-info",children:[s.jsx("div",{className:"set-row-name",children:m.name}),s.jsxs("div",{className:"set-row-desc",children:[yf(m.size)," · ",new Date(m.mtimeMs).toLocaleString()]})]})},m.name))}),s.jsxs("p",{className:"set-hint",children:[i("dshPatchesPath")," ",e.dshPatches?.patchDir??""]})]}),b==="review"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Fs,{className:"set-section-icon"}),i("settingsReview"),s.jsx(ft,{text:i("settingsReviewDesc")}),s.jsx("span",{className:"set-count",children:u.reviewSkills.length})]}),s.jsx(ze,{title:i("goalModeEnabled"),tip:i("goalModeEnabledDesc"),enabled:u.goalModeEnabled,onToggle:()=>Me({goalModeEnabled:!u.goalModeEnabled})}),!u.goalModeEnabled&&s.jsx("p",{className:"set-hint",children:i("goalModeOffHint")}),f&&s.jsx("p",{className:"set-hint",children:i("dshReviewPromptNote")}),s.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:i("reviewPromptPlaceholder"),value:Z,onFocus:()=>me.current=!0,onBlur:()=>{me.current=!1,Me({reviewPrompt:Z})},onChange:m=>Y(m.target.value)}),s.jsx("div",{className:"set-field-label",children:i("settingsReviewSkills")}),u.reviewSkills.length===0?s.jsx("p",{className:"set-empty",children:i("noSkills")}):s.jsx("div",{className:"set-list",children:u.reviewSkills.map(m=>s.jsx(ze,{title:m.name,subtitle:m.description,enabled:m.enabled,onToggle:()=>$o(m)},`review-${m.name}`))})]}),b==="vision"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Mn,{className:"set-section-icon"}),i("settingsVisionBridge")]}),s.jsx(ze,{title:i("visionBridgeEnabled"),tip:i("settingsVisionBridgeDesc"),enabled:u.visionBridgeEnabled,onToggle:()=>Me({visionBridgeEnabled:!u.visionBridgeEnabled})}),!u.visionBridgeEnabled&&s.jsx("p",{className:"set-hint",children:i("visionBridgeOffHint")}),u.visionBridgeEnabled&&s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("visionBridgeModel")}),s.jsxs("select",{className:"set-select",value:u.visionBridgeModel??"",onChange:m=>Me({visionBridgeModel:m.target.value||null}),children:[s.jsx("option",{value:"",children:i("visionBridgeAuto")}),u.visionModels.map(m=>s.jsx("option",{value:`${m.provider}/${m.id}`,children:m.label},`${m.provider}/${m.id}`))]})]}),u.visionBridgeEnabled&&s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("visionBridgePromptMode")}),s.jsxs("select",{className:"set-select",value:j,onChange:m=>{const ne=m.target.value;X(ne),Me({visionBridgePromptMode:ne})},children:[s.jsx("option",{value:"append",children:i("promptModeAppend")}),s.jsx("option",{value:"replace",children:i("promptModeReplace")})]})]}),u.visionBridgeEnabled&&s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:i("visionBridgePromptPlaceholder"),value:re,onFocus:()=>k.current=!0,onBlur:()=>{k.current=!1;const m=j==="replace"&&u.visionBridgeDefaultPrompt&&re===u.visionBridgeDefaultPrompt?"":re;Me({visionBridgePromptMode:j,visionBridgePrompt:m})},onChange:m=>K(m.target.value)}),u.visionBridgeEnabled&&(u.visionModels.length===0?s.jsx("p",{className:"set-hint",children:i("visionBridgeNoModels")}):s.jsx("p",{className:"set-hint",children:i("visionBridgeCurrent",{model:u.visionBridgeModel??i("visionBridgeAuto")})}))]}),b==="presets"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Vs,{className:"set-section-icon"}),i("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:i("presetNamePlaceholder"),value:de,onChange:m=>w(m.target.value),onKeyDown:m=>{m.key==="Enter"&&de.trim()&&(t({type:"save_preset",name:de.trim()}),w(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!de.trim(),onClick:()=>{t({type:"save_preset",name:de.trim()}),w("")},children:[s.jsx(dt,{})," ",i("saveAsPreset")]})]}),u.presets.length===0?s.jsx("p",{className:"set-empty",children:i("noPresets")}):s.jsx("div",{className:"set-list",children:u.presets.map(m=>s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsx("div",{className:"set-row-name",children:m.name}),s.jsxs("div",{className:"set-row-desc",children:[m.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend"),m.disabledSkills.length>0&&` · ${i("settingsSkills")} ${m.disabledSkills.length}`,m.disabledExtensions.length>0&&` · ${i("settingsExtensions")} ${m.disabledExtensions.length}`]})]}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>t({type:"apply_preset",name:m.name}),children:i("applyPreset")}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("deletePreset"),onClick:()=>t({type:"delete_preset",name:m.name}),children:s.jsx(et,{})})]})]},m.name))})]}),b==="subagent-templates"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(ja,{className:"set-section-icon"}),i("settingsSubagentTemplates"),s.jsx(ft,{text:i("settingsSubagentTemplatesDesc")}),s.jsx("span",{className:"set-count",children:u.subagentTemplates.length}),s.jsxs("button",{type:"button",className:"set-save-btn",title:i("subagentTemplateNew"),onClick:()=>L({name:"",description:"",promptMode:"replace",systemPrompt:"",enabledSkills:[],enabledExtensions:[],model:"",enabled:!0}),children:[s.jsx(dt,{})," ",i("subagentTemplateNew")]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("subagentDefaultModelLabel")}),s.jsxs("select",{className:"set-select",value:u.subagentDefaultModel??"",onChange:m=>Me({subagentDefaultModel:m.target.value||null}),children:[s.jsx("option",{value:"",children:i("subagentFollowMain")}),u.subagentModels.map(m=>s.jsx("option",{value:`${m.provider}/${m.id}`,children:m.label},`${m.provider}/${m.id}`))]})]}),u.subagentModels.length===0?s.jsx("p",{className:"set-hint",children:i("subagentNoModels")}):s.jsx("p",{className:"set-hint",children:i("subagentDefaultModelHint")}),I&&s.jsxs("div",{className:"tpl-editor",children:[s.jsxs("div",{className:"tpl-fields",children:[s.jsx("input",{className:"set-input",placeholder:i("tplNamePlaceholder"),value:I.name,onChange:m=>L({...I,name:m.target.value})}),s.jsx("input",{className:"set-input",placeholder:i("tplDescriptionPlaceholder"),value:I.description,onChange:m=>L({...I,description:m.target.value})}),s.jsx("input",{className:"set-input",placeholder:i("tplDescriptionEnPlaceholder"),value:I.descriptionEn??"",onChange:m=>L({...I,descriptionEn:m.target.value})})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("tplPromptModeLabel")}),s.jsxs("select",{className:"set-select",value:I.promptMode,onChange:m=>L({...I,promptMode:m.target.value}),children:[s.jsx("option",{value:"replace",children:i("promptModeReplace")}),s.jsx("option",{value:"append",children:i("promptModeAppend")})]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("tplModelLabel")}),s.jsxs("select",{className:"set-select",value:I.model??"",onChange:m=>L({...I,model:m.target.value}),children:[s.jsx("option",{value:"",children:i("subagentFollowMain")}),u.subagentModels.map(m=>s.jsx("option",{value:`${m.provider}/${m.id}`,children:m.label},`${m.provider}/${m.id}`))]})]}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${i("tplSystemPromptLabel")}${c==="zh"?":":": "}${i("tplSystemPromptPlaceholder")}`,value:I.systemPrompt,onChange:m=>L({...I,systemPrompt:m.target.value})}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${i("tplSystemPromptLabel")}: ${i("tplSystemPromptEnPlaceholder")}`,value:I.systemPromptEn??"",onChange:m=>L({...I,systemPromptEn:m.target.value})}),s.jsxs("div",{className:"tpl-pick-block",children:[s.jsx("div",{className:"tpl-pick-head",children:s.jsxs("span",{children:[i("tplSkillsLabel")," · ",i("tplWhitelistHint")]})}),u.skills.length===0?s.jsx("p",{className:"set-hint",children:i("noSkills")}):s.jsx("div",{className:"tpl-pick",children:u.skills.map(m=>s.jsxs("label",{className:`tpl-chip${I.enabledSkills.includes(m.name)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:I.enabledSkills.includes(m.name),onChange:ne=>{const Ne=ne.target.checked;L({...I,enabledSkills:Ne?[...I.enabledSkills,m.name]:I.enabledSkills.filter(Ge=>Ge!==m.name)})}}),m.name]},m.name))})]}),s.jsxs("div",{className:"tpl-pick-block",children:[s.jsx("div",{className:"tpl-pick-head",children:s.jsxs("span",{children:[i("tplExtensionsLabel")," · ",i("tplWhitelistHint")]})}),u.extensions.length===0?s.jsx("p",{className:"set-hint",children:i("noExtensions")}):s.jsx("div",{className:"tpl-pick",children:u.extensions.map(m=>s.jsxs("label",{className:`tpl-chip${I.enabledExtensions.includes(m.id)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:I.enabledExtensions.includes(m.id),onChange:ne=>{const Ne=ne.target.checked;L({...I,enabledExtensions:Ne?[...I.enabledExtensions,m.id]:I.enabledExtensions.filter(Ge=>Ge!==m.id)})}}),m.name]},m.id))})]}),s.jsxs("div",{className:"tpl-actions",children:[s.jsx("button",{type:"button",className:"set-save-btn",disabled:!I.name.trim(),onClick:()=>{t({type:"save_subagent_template",template:{...I,name:I.name.trim()}}),L(null)},children:i("tplSave")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>L(null),children:i("tplCancel")})]})]}),u.subagentTemplates.length===0?s.jsx("p",{className:"set-empty",children:i("noSubagentTemplates")}):s.jsx("div",{className:"set-list",children:u.subagentTemplates.map(m=>s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsxs("div",{className:"set-row-name",children:[m.name,u.subagentDefaultTemplates.includes(m.name)&&s.jsx("span",{className:"tpl-badge default",children:i("tplDefaultBadge")}),!m.enabled&&s.jsx("span",{className:"tpl-badge",children:i("subagentTemplateClosed")})]}),s.jsxs("div",{className:"set-row-desc",children:[(c!=="zh"&&m.descriptionEn?m.descriptionEn:m.description)||`${m.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend")}`,m.model?` · ${i("tplModelLabel")} ${m.model}`:` · ${i("subagentFollowMain")}`,m.enabledSkills.length>0&&` · ${i("tplSkillsLabel")} ${m.enabledSkills.length}`,m.enabledExtensions.length>0&&` · ${i("tplExtensionsLabel")} ${m.enabledExtensions.length}`,!m.description&&m.enabledSkills.length===0&&m.enabledExtensions.length===0&&` · ${i("tplInherit")}`]})]}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:`set-switch${m.enabled?" on":""}`,role:"switch","aria-checked":m.enabled,title:`${m.enabled?i("subagentTemplateDisable"):i("subagentTemplateEnable")} · ${i("subagentTemplateOffHint")}`,onClick:()=>t({type:"save_subagent_template",template:{...m,enabled:!m.enabled}}),children:s.jsx("span",{className:"set-switch-knob"})}),s.jsx("button",{type:"button",className:"dd-refresh",title:i("subagentTemplateEdit"),onClick:()=>L({...m}),children:i("subagentTemplateEdit")}),oe===m.name?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>{t({type:"delete_subagent_template",name:m.name}),se(null)},children:i("uninstallConfirm")}):s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("tplDelete"),onClick:()=>se(m.name),children:s.jsx(et,{})})]})]},m.name))})]})]})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:o,children:i("close")})})]})})}function kf(e,t){const n=Math.max(0,Date.now()-e),a=Math.floor(n/6e4);if(a<1)return t("bgTaskJustNow");if(a<60)return t("bgTaskMinutes",{n:a});const o=Math.floor(a/60);return o<24?t("bgTaskHours",{n:o}):t("bgTaskDays",{n:Math.floor(o/24)})}function Cf({servers:e,send:t,onClose:n}){const a=Le(),[o,i]=l.useState(new Set),c=d=>i(u=>{const f=new Set(u);return f.has(d)?f.delete(d):f.add(d),f});return l.useEffect(()=>{t({type:"list_bg_servers"})},[]),s.jsx("div",{className:"modal-backdrop",onClick:n,children:s.jsxs("div",{className:"bg-task-modal",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(Js,{})," ",a("bgTasks"),e.length>0&&s.jsx("em",{className:"bg-task-count",children:e.length})]}),s.jsx("button",{type:"button",className:"btn",title:a("close"),onClick:n,children:s.jsx($e,{})})]}),e.length===0?s.jsxs("div",{className:"bg-task-empty",children:[s.jsx(Js,{}),s.jsx("span",{children:a("bgTasksEmpty")}),s.jsx("small",{children:a("bgTasksDesc")})]}):s.jsx("ul",{className:"bg-task-list",children:e.map(d=>{const u=!!d.taskId,f=d.taskId??String(d.port);return s.jsxs("li",{className:"bg-task-item",children:[s.jsx("span",{className:"bg-task-icon",title:u?d.plugin:a("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:d.taskId,children:["🧩 ",d.plugin]}):s.jsxs("span",{className:"bg-task-port",children:[":",d.port]}),d.name&&s.jsx("span",{className:"bg-task-name",children:d.name})]}),s.jsxs("div",{className:"bg-task-line2",children:[!u&&s.jsxs("span",{children:[a("bgTaskPid")," ",d.pid]}),s.jsxs("span",{children:[a("bgTaskSince")," ",kf(d.since,a)]}),u&&d.status&&s.jsx("span",{className:"bg-task-status",children:d.status})]}),d.command&&s.jsxs("button",{type:"button",className:`bg-task-cmd ${o.has(f)?"open":""}`,title:`${a("bgTaskCommand")}: ${d.command}`,onClick:()=>c(f),children:[s.jsx(Zt,{}),s.jsx("code",{children:d.command})]})]}),s.jsxs("button",{type:"button",className:"btn bg-task-stop",title:a("bgTaskStop"),onClick:()=>t(u?{type:"kill_background_server",taskId:d.taskId}:{type:"kill_background_server",port:d.port}),children:[s.jsx(zs,{}),s.jsx("span",{children:a("bgTaskStop")})]})]},f)})}),s.jsxs("div",{className:"bg-task-foot",children:[s.jsxs("button",{type:"button",className:"btn",title:a("bgTaskRefresh"),onClick:()=>t({type:"list_bg_servers"}),children:[s.jsx(kt,{}),s.jsx("span",{children:a("bgTaskRefresh")})]}),s.jsxs("button",{type:"button",className:"btn bg-task-stopall",disabled:e.length===0,title:a("bgTaskStopAll"),onClick:()=>t({type:"kill_background_servers"}),children:[s.jsx(zs,{}),s.jsx("span",{children:a("bgTaskStopAll")})]})]})]})})}function vf(e,t){return e.toLowerCase().includes(t)}function _f({open:e,send:t,projects:n,cwd:a,fileSearch:o,sessionSearch:i,onClose:c,onSwitchSession:d,onSwitchProject:u,onPreviewFile:f}){const b=Le(),E=l.useRef(null),[y,N]=l.useState(""),S=l.useDeferredValue(y),[M,z]=l.useState(0),$=l.useRef(1),v=l.useRef(0),P=l.useRef(null);l.useEffect(()=>{if(!e)return;t({type:"list_sessions"}),t({type:"list_projects"});const w=y.trim();if(w){const I=++$.current;v.current=I,H(!0),t({type:"search_files",reqId:I,query:w}),t({type:"search_sessions",reqId:I,query:w})}requestAnimationFrame(()=>E.current?.select())},[e]);const[B,H]=l.useState(!1);l.useEffect(()=>{P.current&&clearTimeout(P.current);const w=S.trim();if(!w){H(!1);return}return P.current=setTimeout(()=>{const I=++$.current;v.current=I,H(!0),t({type:"search_files",reqId:I,query:w}),t({type:"search_sessions",reqId:I,query:w})},300),()=>{P.current&&clearTimeout(P.current)}},[S]);const Q=S.trim().toLowerCase(),re=l.useMemo(()=>!Q||!i||i.reqId!==v.current||!i.ok?[]:i.results,[i,Q]),K=l.useMemo(()=>Q?n.filter(w=>vf(w.path,Q)).slice(0,10):[],[n,Q]),j=l.useMemo(()=>!Q||!o||o.reqId!==v.current||!o.ok?[]:o.results,[o,Q]);l.useEffect(()=>{o&&o.reqId===v.current&&i&&i.reqId===v.current&&v.current!==0&&H(!1)},[o,i]);const X=!!o&&o.ok&&o.truncated,k=l.useMemo(()=>[...re.map(w=>({kind:"session",path:w.path,anchors:w.anchors})),...K.map(w=>({kind:"project",path:w.path})),...j.filter(w=>w.type==="file").map(w=>({kind:"file",path:w.path,name:w.name}))],[re,K,j]);l.useEffect(()=>{z(0)},[S]);const Z=l.useCallback(w=>{if(w)if(w.kind==="session")d(w.path,w.anchors),c();else if(w.kind==="project"){u(w.path),t({type:"list_sessions"}),t({type:"list_projects"});const I=S.trim();if(I){const L=++$.current;v.current=L,H(!0),t({type:"search_files",reqId:L,query:I}),t({type:"search_sessions",reqId:L,query:I})}}else f(w.path,w.name)},[d,u,f,t,S]);l.useEffect(()=>{if(!e)return;const w=I=>{I.key==="Escape"?(I.preventDefault(),I.stopPropagation(),c()):I.key==="ArrowDown"?(I.preventDefault(),z(L=>Math.min(L+1,k.length-1))):I.key==="ArrowUp"?(I.preventDefault(),z(L=>Math.max(L-1,0))):I.key==="Enter"&&(I.preventDefault(),Z(k[M]))};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[k,M,Z,c,e]);const Y=re.length+K.length+j.length,me=(w,I,L)=>s.jsxs("div",{className:"gs-section-head",children:[L,s.jsx("span",{children:w}),s.jsx("em",{children:I})]});let de=-1;return e?s.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:c,children:s.jsxs("div",{className:"gs-modal",onClick:w=>w.stopPropagation(),children:[s.jsxs("div",{className:"gs-input-row",children:[s.jsx(Xs,{}),s.jsx("input",{ref:E,type:"text",value:y,placeholder:b("gsPlaceholder"),onChange:w=>N(w.target.value)}),s.jsx("button",{type:"button",className:"gs-close",title:b("close"),onClick:c,children:s.jsx($e,{})})]}),s.jsxs("div",{className:"gs-results",children:[!Q&&s.jsx("div",{className:"gs-empty",children:b("gsHint")}),Q&&Y===0&&!X&&s.jsx("div",{className:"gs-empty",children:b(B?"gsSearching":"gsNoResults")}),re.length>0&&s.jsxs("div",{className:"gs-section",children:[me(b("gsSessions"),re.length,s.jsx(es,{})),re.map(w=>{de++;const I=de;return s.jsxs("button",{type:"button",className:I===M?"gs-item active":"gs-item",onMouseEnter:()=>z(I),onClick:()=>Z({kind:"session",path:w.path,anchors:w.anchors}),children:[s.jsxs("span",{className:"gs-item-title",children:[w.name||w.path.split(/[\\/]/).pop(),s.jsx("em",{className:"gs-item-meta",children:w.messageCount})]}),s.jsx("span",{className:"gs-item-sub",children:w.firstMessage})]},w.path)})]}),K.length>0&&s.jsxs("div",{className:"gs-section",children:[me(b("gsProjects"),K.length,s.jsx(Pt,{})),K.map(w=>{de++;const I=de,L=a&&w.path===a;return s.jsxs("button",{type:"button",className:I===M?"gs-item active":"gs-item",onMouseEnter:()=>z(I),onClick:()=>Z({kind:"project",path:w.path}),children:[s.jsxs("span",{className:"gs-item-title",children:[w.path.split(/[\\/]/).pop(),L&&s.jsx("em",{className:"gs-item-meta",children:b("gsCurrentProject")})]}),s.jsx("span",{className:"gs-item-sub",children:w.path})]},w.path)})]}),(j.length>0||Q&&X)&&s.jsxs("div",{className:"gs-section",children:[me(b("gsFiles"),j.length,s.jsx(Zi,{})),j.map(w=>{de++;const I=de;return s.jsxs("button",{type:"button",className:I===M?"gs-item active":"gs-item",disabled:w.type==="dir",title:w.type==="dir"?void 0:b("gsOpenPreview"),onMouseEnter:()=>z(I),onClick:()=>{w.type==="file"&&Z({kind:"file",path:w.path,name:w.name})},children:[s.jsx("span",{className:"gs-item-title",children:w.name}),s.jsx("span",{className:"gs-item-sub",children:w.path})]},`${w.type}:${w.path}`)}),X&&s.jsx("div",{className:"gs-truncated",children:b("gsTruncated")})]})]}),s.jsxs("div",{className:"gs-foot",children:[s.jsxs("span",{children:["↑↓ ",b("gsNavigate")]}),s.jsxs("span",{children:["Enter ",b("gsOpen")]}),s.jsxs("span",{children:["Esc ",b("gsCloseHint")]})]})]})}):null}const Rn=5e3;function Sf({file:e,content:t,send:n,onAddLines:a,onAttach:o,onClose:i}){const c=Le(),[d,u]=l.useState(null),[f,b]=l.useState(!1),[E,y]=l.useState(null),[N,S]=l.useState(!1),[M,z]=l.useState(!1),[$,v]=l.useState(!1),[P,B]=l.useState(""),[H,Q]=l.useState(!0),re=l.useRef(!1),[K,j]=l.useState(!0),[X,k]=l.useState(!1),[Z,Y]=l.useState(100),me=l.useRef(0),de=l.useRef(!1),w=l.useRef(null);l.useEffect(()=>{b(!0),u(null),y(null),v(!1),B(""),Q(!0),re.current=!1,n({type:"read_file",path:e.path})},[e.path,n]),l.useEffect(()=>{t&&t.path===e.path&&(u(t),$||B(t.text),b(!1))},[t,$,e.path]),l.useEffect(()=>{const ie=G=>{if(G.key==="Escape"){he();return}if((G.ctrlKey||G.metaKey)&&G.key.toLowerCase()==="s"&&$){G.preventDefault(),_();return}const Te=G.target,Re=Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.isContentEditable);(G.ctrlKey||G.metaKey)&&G.key.toLowerCase()==="a"&&!Re&&(G.preventDefault(),ye())};return document.addEventListener("keydown",ie),()=>document.removeEventListener("keydown",ie)},[i,d,$,P]),l.useEffect(()=>{const ie=()=>{de.current=!1,S(!1)};return window.addEventListener("mouseup",ie),()=>window.removeEventListener("mouseup",ie)},[]);const I=l.useMemo(()=>{if(!d)return[];const ie=d.text.split(`
|
|
335
|
-
`);return ie.length>0&&ie[ie.length-1]===""&&ie.pop(),ie.slice(0,Rn)},[d]),L=d?.lines??0,oe=L>Rn,se=(ie,G)=>{if(G){const Te=me.current>0?me.current:ie;y({start:Math.min(Te,ie),end:Math.max(Te,ie)})}else me.current=ie,y({start:ie,end:ie})},ye=()=>{I.length!==0&&(me.current=1,y({start:1,end:I.length}))},C=()=>{E&&(a(e.path,e.name,E.start,E.end),z(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>z(!1),1400))},ee=d!==null&&d.kind==="text"&&!d.binary&&!d.truncated,ce=()=>{B(d?.text??""),v(!1),re.current&&Q(!0)},ae=()=>{if($){if(P!==(d?.text??"")&&!window.confirm(c("discardFileChanges")))return;ce();return}!ee||!d||(re.current=Pn(e.name)&&H,Pn(e.name)&&Q(!1),y(null),B(d.text),v(!0))},_=()=>{!$||!d||!ee||n({type:"write_file",path:e.path,text:P})&&(v(!1),re.current&&Q(!0),y(null))},he=()=>{$&&P!==(d?.text??"")&&!window.confirm(c("discardFileChanges"))||i()},F=ie=>{Y(Math.min(200,Math.max(50,ie)))},pe=E?E.end-E.start+1:0,Ee=d?.binary??!1,Oe=d?.truncated??!1,Se=d?.kind??"text",U=Pn(e.name),ge=U&&H&&!$&&Se==="text"&&!Ee,ue=ie=>Dt(at(`/api/file?clientId=${encodeURIComponent(ca())}&path=${encodeURIComponent(ie)}`));return s.jsx("div",{className:`fp-overlay ${X?"fullscreen":""}`,onMouseDown:ie=>{ie.target===ie.currentTarget&&he()},children:s.jsxs("div",{className:`fp ${X?"fullscreen":""}`,style:{"--fp-zoom":Z/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:[d&&Se==="text"&&!Ee&&c("fileLines",{n:L}),d&&` · ${Af(d.size)}`]}),s.jsxs("span",{className:"fp-head-actions",children:[U&&Se==="text"&&!Ee&&d&&s.jsx("button",{type:"button",className:`fp-attach markdown ${H?"on":""}`,"data-tip":c(H?"showMarkdownSource":"showMarkdownPreview"),disabled:$,onClick:()=>Q(ie=>!ie),children:H?s.jsx(Mn,{}):s.jsx(Rl,{})}),Se==="text"&&!Ee&&d&&s.jsx("button",{type:"button",className:`fp-attach edit ${$?"on":""}`,"data-tip":c(Oe?"fileEditTruncated":$?"exitEditFile":"editFile"),disabled:!ee&&!$,onClick:ae,children:s.jsx(Xt,{})}),Se==="text"&&!Ee&&!ge&&s.jsx("button",{type:"button",className:`fp-attach wrap ${K?"on":""}`,"data-tip":c(K?"disableWrap":"enableWrap"),onClick:()=>j(ie=>!ie),children:s.jsx(Ll,{})}),Se==="text"&&d&&s.jsxs("span",{className:"fp-zoom",children:[s.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":c("zoomOut"),disabled:Z<=50,onClick:()=>F(Z-10),children:s.jsx(pl,{})}),s.jsxs("button",{type:"button",className:"fp-zoom-val",title:c("resetZoom"),onClick:()=>Y(100),children:[Z,"%"]}),s.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":c("zoomIn"),disabled:Z>=200,onClick:()=>F(Z+10),children:s.jsx(hl,{})})]}),Se!=="video"&&Se!=="none"&&s.jsx("button",{type:"button",className:"fp-attach inline","data-tip":c("attachInlineTip"),onClick:()=>o(e.path,e.name,"inline"),children:s.jsx(dt,{})}),s.jsx("button",{type:"button",className:"fp-attach ref","data-tip":c("referenceTip"),onClick:()=>o(e.path,e.name,"reference"),children:s.jsx(On,{})}),s.jsx("button",{type:"button",className:`fp-attach full ${X?"on":""}`,"data-tip":c(X?"exitFullscreen":"fullscreen"),onClick:()=>k(ie=>!ie),children:X?s.jsx(Nl,{}):s.jsx(Cl,{})}),s.jsx("button",{type:"button",className:"fp-close",title:c("close"),onClick:he,children:s.jsx($e,{})})]})]}),Oe&&Se==="text"&&!Ee&&s.jsx("div",{className:"fp-notice",children:c("previewTruncated")}),f&&!d&&s.jsx("div",{className:"fp-empty",children:c("loading")}),!f&&Se==="none"&&!Ee&&s.jsx("div",{className:"fp-empty",children:c("previewNotSupported")}),!f&&Se==="image"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("img",{className:"fp-media",src:ue(e.path),alt:e.name})}),!f&&Se==="video"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("video",{className:"fp-media",src:ue(e.path),controls:!0,preload:"metadata"})}),!f&&ge&&d&&s.jsx("div",{className:"fp-markdown msg-text",children:s.jsx("div",{className:"fp-markdown-zoom",children:s.jsx(ot,{text:d.text})})}),!f&&Ee&&Se!=="image"&&Se!=="video"&&d&&s.jsxs("div",{className:"fp-hex-wrap",children:[s.jsxs("div",{className:"fp-notice",children:[c("binaryFile"),d.truncated&&c("binaryHexTruncated")]}),s.jsx("pre",{className:"fp-hex",children:d.text})]}),!f&&$&&Se==="text"&&!Ee&&d&&s.jsx("textarea",{className:`fp-editor ${K?"":"no-wrap"}`,value:P,onChange:ie=>B(ie.target.value),wrap:K?"soft":"off",spellCheck:!1,autoFocus:!0}),!f&&!ge&&!$&&Se==="text"&&!Ee&&d&&I.length===0&&s.jsx("div",{className:"fp-empty",children:c("emptyFile")}),!f&&!ge&&!$&&Se==="text"&&!Ee&&I.length>0&&s.jsxs("div",{className:`fp-code ${N?"dragging":""} ${K?"":"no-wrap"}`,onMouseDown:ie=>{ie.button===0&&ie.preventDefault()},children:[I.map((ie,G)=>{const Te=G+1,Re=E!==null&&Te>=E.start&&Te<=E.end;return s.jsxs("div",{className:`fp-line ${Re?"sel":""}`,onMouseDown:x=>{x.button===0&&(se(Te,x.shiftKey),de.current=!0,S(!0))},onMouseEnter:()=>{de.current&&se(Te,!0)},children:[s.jsx("span",{className:"fp-num",children:Te}),s.jsx("span",{className:"fp-code-text",children:ie})]},Te)}),oe&&s.jsx("div",{className:"fp-lines-note",children:c("previewLinesTruncated",{n:Rn})})]}),s.jsx("div",{className:"fp-foot",children:$?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:c("editFile")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:ae,children:c("cancel")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:P===(d?.text??""),onClick:_,children:[s.jsx(El,{})," ",c("saveFile")]})]})]}):!ge&&Se==="text"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:E?c("selectedRange",{n:pe,start:E.start,end:E.end}):c("selectLinesHint")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",disabled:I.length===0,onClick:ye,children:c("selectAll")}),s.jsx("button",{type:"button",className:"btn",disabled:!E,onClick:()=>y(null),children:c("clearSelection")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!E||Ee,onClick:C,children:[M?s.jsx(Tt,{}):null,c(M?"addedToChat":"addToChat")]})]})]})})]})})}function Pn(e){const t=e.toLowerCase();return t.endsWith(".md")||t.endsWith(".markdown")}function Af(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}const Ro="pi-web-sounds",ps={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function Po(){try{const e=localStorage.getItem(Ro);if(!e)return{...ps};const t=JSON.parse(e),n={...ps,...t};for(const a of["enabled","question","done","start","error"])typeof n[a]!="boolean"&&(n[a]=ps[a]);return typeof n.volume!="number"||!Number.isFinite(n.volume)?n.volume=ps.volume:n.volume=Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...ps}}}function wf(e){try{localStorage.setItem(Ro,JSON.stringify(e))}catch{}}let hs=null;function If(){try{if(!hs){const e=window.AudioContext??window.webkitAudioContext;if(!e)return null;hs=new e}return hs.state==="suspended"&&hs.resume(),hs}catch{return null}}const jf=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],Lf=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],Rf=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],Pf=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],Df={question:jf,done:Lf,start:Rf,error:Pf};function Of(e,t,n){const a=e.createOscillator(),o=e.createGain();a.type=t.type,a.frequency.value=t.freq;const i=e.currentTime+t.start,c=Math.max(1e-4,t.peak*n);o.gain.setValueAtTime(1e-4,i),o.gain.exponentialRampToValueAtTime(c,i+.012),o.gain.exponentialRampToValueAtTime(1e-4,i+t.dur),a.connect(o),o.connect(e.destination),a.start(i),a.stop(i+t.dur+.05)}function zt(e,t=Po()){if(!t.enabled||!t[e])return;const n=If();if(!n)return;const a=Math.max(0,Math.min(1,t.volume/100));for(const o of Df[e])Of(n,o,a)}const Mf=l.lazy(()=>il(()=>import("./TerminalPanel-CX6GKT5R.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.TerminalPanel})));function Bf({notice:e,onDismiss:t}){const n=Le(),{locale:a}=Mt(),o=a!=="zh"&&e.textEn?e.textEn:e.text,[i,c]=l.useState(!1);l.useEffect(()=>{if(i)return;const u=setTimeout(()=>t(e.id),e.level==="error"?12e3:7e3);return()=>clearTimeout(u)},[i,e.id,e.level,t]);const d=e.level==="error"?Ml:e.level==="warning"?Ol:Al;return s.jsxs("div",{className:`notice notice-${e.level}${i?" paused":""}`,role:"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[s.jsx(d,{className:"notice-icon"}),s.jsx("span",{className:"notice-text",children:o}),s.jsx("button",{type:"button",className:"notice-close",title:n("close"),onClick:()=>t(e.id),children:s.jsx($e,{})})]})}const Ff=[],Do=180,Oo=520,Mo=240,Bo=e=>`pi-web-ui:${e}-panel-width`;function Fi(e){const t=Number(localStorage.getItem(Bo(e)));return Number.isFinite(t)&&t>=Do&&t<=Oo?t:Mo}const oa=e=>`pi-web-ui:${e}-panel-collapsed`;function Hi(e){return localStorage.getItem(oa(e))==="1"}function Ui({side:e,width:t,onResize:n}){const a=Le(),o=l.useCallback(i=>{i.preventDefault();const c=i.clientX,d=t;let u=d;const f=E=>{const y=e==="left"?E.clientX-c:c-E.clientX;u=Math.min(Oo,Math.max(Do,Math.round(d+y))),n(u)},b=()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",b),document.body.classList.remove("panel-resizing"),localStorage.setItem(Bo(e),String(u))};window.addEventListener("pointermove",f),window.addEventListener("pointerup",b),document.body.classList.add("panel-resizing")},[e,t,n]);return s.jsx("div",{className:`resize-handle resize-${e}`,title:a("dragToResize"),onPointerDown:o,onDoubleClick:()=>n(Mo)})}function qi({side:e,onClick:t}){const n=Le();return s.jsx("button",{type:"button",className:`panel-rail panel-rail-${e}`,title:n("expandPanel"),onClick:t,children:e==="left"?s.jsx(er,{}):s.jsx(tr,{})})}function Hf(){const e=Le(),{locale:t}=Mt(),{chat:n,send:a,dismissNotice:o,pushNotice:i,terminal:c}=Ic(),d=l.useRef(!1);l.useEffect(()=>{!n.ready||!n.settings||d.current||n.settings.quickPhrasesSeeded||(d.current=!0,n.settings.quickPhrases.length===0&&a({type:"set_settings",quickPhrases:ln[t]??ln.en,quickPhrasesSeeded:!0}))},[n.ready,n.settings,a,t]);const u=n.state?.cwd??"",f=Ao();l.useEffect(()=>{const q=f?rf(u):"";document.title=q?`${q} — pi-web-ui`:e("docTitle")},[u,f,e]);const[b,E]=l.useState([]),[y,N]=l.useState(null),[S,M]=l.useState(!1),[z,$]=l.useState("chat"),v=q=>!n.tabs||q==="chat"||n.tabs.includes(q),P=z.startsWith("plugin:")?"plugins":z,B=v(P)?z:"chat",H=l.useMemo(()=>n.plugins.filter(q=>!n.settings?.disabledPlugins?.includes(q.id)),[n.plugins,n.settings?.disabledPlugins]),[Q,re]=l.useState([]);l.useEffect(()=>bc(re),[]),l.useEffect(()=>{op(a),lp(H,n.pluginsEpoch),Ec(H,n.pluginsEpoch)},[H,n.pluginsEpoch,a]);const[K,j]=l.useState(()=>Fi("left")),[X,k]=l.useState(()=>Fi("right")),Z=l.useCallback(q=>j(q),[]),Y=l.useCallback(q=>k(q),[]),[me,de]=l.useState(()=>Hi("left")),[w,I]=l.useState(()=>Hi("right")),L=l.useCallback(()=>{de(q=>(localStorage.setItem(oa("left"),q?"0":"1"),!q))},[]),oe=l.useCallback(()=>{I(q=>(localStorage.setItem(oa("right"),q?"0":"1"),!q))},[]),[se,ye]=l.useState(null),[C,ee]=l.useState(()=>window.matchMedia("(max-width: 768px)").matches);l.useEffect(()=>{const q=window.matchMedia("(max-width: 768px)"),xe=je=>ee(je.matches);return q.addEventListener("change",xe),()=>q.removeEventListener("change",xe)},[]);const[ce,ae]=l.useState(!1),[_,he]=l.useState(!1),[F,pe]=l.useState(!1),Ee=vo(),[Oe,Se]=l.useState(!1),[U,ge]=l.useState(!1),[ue,ie]=l.useState(null);l.useEffect(()=>{if(!ue)return;const q=setTimeout(()=>ie(null),15e3);return()=>clearTimeout(q)},[ue]),l.useEffect(()=>{const q=xe=>{const je=xe.detail,Ke=je?.title||e("pluginCommandFallback"),Ye=je?.command;if(!Ye||!n.ready)return;const rt={name:Ke,command:Ye,cwd:"${pwd}"},Je=n.terminals.find(pt=>pt.title===Ke);if(Je)c.restart(Je.id),a({type:"run_command",terminalId:Je.id,conversationId:Je.conversationId,command:rt,cols:80,rows:24});else{const pt=_t();c.create({id:pt,conversationId:n.activeConversationId||n.state?.conversationId||"",title:Ke,cwd:n.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:rt})}$("terminal")};return window.addEventListener("pi-web-ui:plugin-run-command",q),()=>window.removeEventListener("pi-web-ui:plugin-run-command",q)},[n,c,a]),l.useEffect(()=>{const q=xe=>{!(xe.ctrlKey||xe.metaKey)||xe.key.toLowerCase()!=="k"||(xe.preventDefault(),ge(je=>!je))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const[G,Te]=l.useState(Po),{themes:Re,theme:x,switchTheme:g}=pp();Ef();const J=l.useRef(null),le=l.useRef(null),be=l.useRef(null),ke=l.useRef(0),Ie=l.useRef(!1),Ae=l.useRef(n.terminals);l.useEffect(()=>{wf(G)},[G]),l.useEffect(()=>{const q=Ae.current;Ae.current=n.terminals;for(const xe of n.terminals){const je=xe.command?.command??"";!q.find(Ye=>Ye.id===xe.id)?.running||xe.running||(je.startsWith("pi remove ")?a({type:"extensions_reload"}):je.startsWith("pi-web-ui install ")||je.startsWith("pi-web-ui uninstall ")?a({type:"plugins_reload"}):je.startsWith("npm i -g ")&&(a({type:"extensions_reload"}),a({type:"plugins_reload"}),a({type:"check_updates_all",force:!0})))}},[n.terminals,a]),l.useEffect(()=>{const q=n.state?.isStreaming??!1,xe=J.current;J.current=q,xe!==null&&(!xe&&q?zt("start",G):xe&&!q&&(zt("done",G),Ds(e("notifyDoneTitle"),e("notifyDoneBody"))))},[n.state?.isStreaming,G]),l.useEffect(()=>{const q=n.dialog?.id??null;q!==null&&q!==le.current&&(zt("question",G),Ds(e("notifyQuestionTitle"),e("notifyQuestionBody"))),le.current=q},[n.dialog,G]),l.useEffect(()=>{const q=n.question?.id??null;q!==null&&q!==be.current&&(zt("question",G),Ds(e("notifyQuestionTitle"),e("notifyQuestionBody"))),be.current=q},[n.question,G]),l.useEffect(()=>{const q=[...n.notices].reverse().find(xe=>xe.level==="error");q&&q.id!==ke.current&&(ke.current=q.id,zt("error",G),Ds(e("notifyErrorTitle"),e("notifyErrorBody")))},[n.notices,G]);const D=(q,xe,je,Ke=!1,Ye)=>{const rt=`${q}|${je}|${Ye?`${Ye.start}-${Ye.end}`:""}`;E(Je=>Je.some(pt=>`${pt.path}|${pt.mode}|${pt.lines?`${pt.lines.start}-${pt.lines.end}`:""}`===rt)?Je:[...Je,{path:q,name:xe,mode:je,isDir:Ke,...Ye?{lines:Ye}:{}}])},we=q=>E(xe=>xe.filter(je=>je.key?je.key!==q:je.path!==q)),Ce=l.useCallback(q=>(!q.type.startsWith("list_")&&!q.type.startsWith("get_")&&ye(null),a(q)),[a]),qe=l.useRef(0),De=l.useRef(0),Xe=q=>{const xe=Date.now();n.state?.model&&!n.state.model.vision&&xe-De.current>1e4&&(De.current=xe,i("warning",e("imageNotSupported")));const je=`paste-${++qe.current}`;E(Ke=>[...Ke,{path:"",key:je,name:q.name,mode:"inline",imageData:q.data,mimeType:q.mimeType}])},mt=async q=>{for(const xe of q){const je=await Ea(xe);if(!je){i("error",e("imageLoadFailed",{name:xe.name}));continue}Xe(je)}},St=20*1024*1024,os=l.useRef(0),xt=async q=>{if(q.size>St){i("warning",e("fileTooLarge",{name:q.name,size:St/1024/1024}));return}let xe;try{xe=(await new Promise((Ye,rt)=>{const Je=new FileReader;Je.onload=()=>Ye(Je.result),Je.onerror=()=>rt(Je.error??new Error("read failed")),Je.readAsDataURL(q)})).replace(/^data:[^;]*;base64,/,"")}catch{i("error",e("fileLoadFailed",{name:q.name}));return}const je=`upload-${++os.current}`;E(Ke=>[...Ke,{path:"",key:je,name:q.name,mode:"inline",fileData:xe,size:q.size,mimeType:q.type||void 0}])},lt=async q=>{for(const xe of q)Ct(xe.type)?await mt([xe]):await xt(xe)},At=l.useCallback((q,xe,je)=>{a({type:"edit_message",messageId:q,text:xe,attachments:je})},[a]),R=l.useCallback((q,xe)=>{a({type:"queue_remove",kind:q,text:xe})},[a]),W=l.useCallback(()=>he(!0),[]),_e=l.useCallback(()=>E([]),[]),ve=l.useCallback(we,[]),Be=l.useCallback(mt,[mt]),Fe=l.useCallback(lt,[lt]),it=n.state?.model,yt=n.state?.thinkingLevel,Ls=n.state?.availableThinkingLevels,Me=l.useMemo(()=>it?{model:it,thinkingLevel:yt??"off",availableThinkingLevels:Ls??[]}:null,[it,yt,Ls]),Kt=l.useCallback(()=>!n.ready||n.terminals.length!==0?!1:(c.create({id:_t(),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,c]);return l.useEffect(()=>{if(Ie.current){if(B!=="terminal"||n.terminals.length!==0){Ie.current=!1;return}Kt()&&(Ie.current=!1)}},[n.terminals.length,Kt,B]),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){i("warning",e("foldersNotSupported"));return}const je=xe.filter(Ye=>Ct(Ye.type)),Ke=xe.filter(Ye=>!Ct(Ye.type));je.length>0&&mt(je),Ke.length>0&<(Ke)},children:[S&&s.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:s.jsxs("span",{children:["📎 ",e("dropHereToAttach")]})}),s.jsx(ic,{chat:n,send:a,terminal:c,view:B,plugins:H,onViewChange:q=>{Ie.current=q==="terminal"&&n.terminals.length===0,Ie.current&&Kt()&&(Ie.current=!1),$(q),ye(null)},onOpenPanel:ye,onOpenSettings:()=>pe(!0),onOpenBgTasks:()=>Se(!0),onOpenGlobalSearch:()=>ge(!0),sound:G,onSoundChange:Te,onSoundPreview:q=>zt(q,G),themes:Re,theme:x,onThemeChange:g}),n.protocolMismatch&&s.jsxs("div",{className:"protocol-banner",children:["⚠ ",e("protocolMismatch")]}),s.jsx("div",{className:"notices",children:n.notices.map(q=>s.jsx(Bf,{notice:q,onDismiss:o},q.id))}),s.jsx(bh,{send:a,children:s.jsxs("div",{className:"layout",style:{"--left-w":`${K}px`,"--right-w":`${X}px`},children:[se&&s.jsx("div",{className:"drawer-backdrop",onClick:()=>ye(null)}),s.jsxs("div",{className:`view-pane ${B==="chat"?"":"hidden"}`,children:[!C&&me&&s.jsx(qi,{side:"left",onClick:L}),s.jsx("div",{className:`panel-drawer drawer-left ${se==="left"?"open":""}${C?"":me?" hidden":""}`,children:s.jsx(mc,{collapsible:!C,onToggleCollapse:L,send:Ce,active:!C||se==="left",ready:n.ready,status:n.status,cwd:n.state?.cwd??"",sessionFile:n.state?.sessionFile??null,conversations:n.conversations,sessions:n.sessions,projects:n.projects,activeConversationId:n.activeConversationId})}),!C&&s.jsx(Ui,{side:"left",width:K,onResize:Z}),s.jsxs("main",{className:Ee?"main wide-chat":"main",children:[n.state?s.jsx(Ch,{state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:At,onKillBash:()=>a({type:"abort_bash"}),onRetry:()=>a({type:"retry_last"}),onRemoveQueued:R,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,jumpTarget:ue,onJumpDone:()=>ie(null)},n.state.conversationId??"boot"):s.jsx("div",{className:"boot-wait",children:n.ready?e("loadingSession"):e("connectingServer")}),n.settings?.goalModeEnabled!==!1&&s.jsx(Bh,{send:a,goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,engine:n.engine}),n.dialog&&s.jsx(Kh,{dialog:n.dialog,send:a}),n.question&&s.jsx(Yh,{question:n.question,send:a}),s.jsx(Mh,{send:a,ready:n.ready,streaming:n.state?.isStreaming??!1,messages:n.state?.messages??Ff,slashCommands:n.slashCommands,modelState:Me,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,attachments:b,onRemoveAttachment:ve,onAddImageFiles:Be,onAddLocalFiles:Fe,onNotice:i,onManageModels:W,onSent:_e,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0})]}),!C&&s.jsx(Ui,{side:"right",width:X,onResize:Y}),s.jsx("div",{className:`panel-drawer drawer-right ${se==="right"?"open":""}${C?"":w?" hidden":""}`,children:s.jsx(Fc,{collapsible:!C,onToggleCollapse:oe,send:Ce,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,cwd:n.state?.cwd??"",onAttach:(q,xe,je,Ke)=>{ye(null),D(q,xe,je,Ke)},onPreview:(q,xe)=>{ye(null),N({path:q,name:xe})},onNotice:(q,xe)=>i(q,xe)})}),!C&&w&&s.jsx(qi,{side:"right",onClick:oe})]}),s.jsx("div",{className:`view-pane ${B==="terminal"?"":"hidden"}`,children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Mf,{chat:n,send:a,terminal:c})})}),s.jsx("div",{className:`view-pane ${B==="git"?"":"hidden"}`,children:s.jsx(zh,{chat:n,send:a,terminal:c,active:B==="git",onSwitchToTerminal:()=>$("terminal")})}),Q.map(q=>{const xe=`plugin:${q.info.id}`;return s.jsx("div",{className:`view-pane ${B===xe?"":"hidden"}`,children:s.jsx(Vh,{entry:q,send:a})},q.info.id)})]})}),s.jsx($h,{chat:n,send:a}),y&&s.jsx(Sf,{file:y,content:n.fileContent,send:a,onAddLines:(q,xe,je,Ke)=>D(q,xe,"lines",!1,{start:je,end:Ke}),onAttach:(q,xe,je)=>D(q,xe,je),onClose:()=>N(null)}),n.ready&&n.state&&n.state.piConfigured===!1&&!ce&&!_&&s.jsx(Qh,{send:a,piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,managed:n.managed,providers:n.providers,installResult:n.installResult,onClose:()=>ae(!0)}),_&&s.jsx(Zh,{send:a,providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,fetchModelsResult:n.fetchModelsResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>he(!1)}),F&&s.jsx(Nf,{chat:n,send:a,terminal:c,onSwitchToTerminal:()=>$("terminal"),onClose:()=>pe(!1)}),Oe&&s.jsx(Cf,{servers:n.bgServers,send:a,onClose:()=>Se(!1)}),s.jsx(_f,{open:U,send:a,projects:n.projects,cwd:n.state?.cwd??"",fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>ge(!1),onSwitchSession:(q,xe)=>{a({type:"switch_session",path:q});const je=xe&&xe[0];ie(je?{path:q,role:je.role,timestamp:je.timestamp}:null)},onSwitchProject:q=>{a({type:"set_cwd",path:q})},onPreviewFile:(q,xe)=>{N({path:q,name:xe})}})]})}function Uf(){if(typeof document>"u")return;const e=document.documentElement,t=document.createElement("div");t.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(t);const n=(t.offsetWidth-t.clientWidth)/2;document.body.removeChild(t),e.style.setProperty("--msgs-gutter",`${n}px`)}Ul();so(to());Uf();sl.createRoot(document.getElementById("root")).render(s.jsx(l.StrictMode,{children:s.jsx(Jl,{children:s.jsx(Hf,{})})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=ir();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(t=>{console.warn("Service worker registration failed:",t)})});export{kt as F,Rt as T,Le as a,Kf as b,dt as c,Wf as d,Zs as e,et as f,kl as g,Zt as h,$e as i,_t as r,Mt as u};
|
|
315
|
+
`).join(" ").trim(),oe=i&&c&&t.content.length===0,se=t.role==="user"&&!i&&!oe&&!!d,ye=async F=>{const pe=[];for(const Ee of F){if(!vt(Ee.type))continue;const Oe=await Ea(Ee);Oe&&pe.push({path:"",imageData:Oe.data,mimeType:Oe.mimeType,name:Oe.name})}pe.length>0&&j(Ee=>[...Ee,...pe])},v=async F=>{if(F.size>sh){me(P("fileTooLarge",{name:F.name,size:20}));return}let pe;try{pe=(await new Promise((Oe,Se)=>{const U=new FileReader;U.onload=()=>Oe(U.result),U.onerror=()=>Se(U.error??new Error("read failed")),U.readAsDataURL(F)})).replace(/^data:[^;]*;base64,/,"")}catch{me(P("fileLoadFailed",{name:F.name}));return}j(Ee=>[...Ee,{path:"",fileData:pe,name:F.name,size:F.size,mimeType:F.type||void 0}])},ee=async F=>{const pe=[];for(const Ee of F)vt(Ee.type)?pe.push(Ee):v(Ee);pe.length>0&&await ye(pe)},ce=()=>{re(I?`/skill:${I.name}${I.userMessage?` ${I.userMessage}`:""}`:t.content.map(F=>ss(F)?.text??"").filter(Boolean).join(`
|
|
316
|
+
`)),j(g??[]),H(!0)},ae=()=>{const F=Q.trim();F&&(d?.(t.id,F,K.length>0?K:void 0),H(!1))},_=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}${_?" 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?P("goalWizardCard"):_?P("goalBarTitle"):t.customType==="file"?P("attachment"):`${P("plugin")} · ${t.customType??P("unknown")}`:ho(t.role,P)}),t.model&&s.jsx("span",{className:"msg-model",children:t.model}),t.timestamp&&s.jsx("span",{className:"msg-time",children:fo(t.timestamp)}),E&&s.jsxs("button",{type:"button",className:"msg-collapse-btn",title:P("collapseMsg"),onClick:()=>E(t.id),children:[s.jsx(dn,{})," ",P("collapseMsg")]}),y!==void 0&&S&&s.jsxs("button",{type:"button",className:`qn-tag ${N?"active":""}`,title:`${y+1}. ${L}`,"aria-label":`${y+1}. ${L}`,onClick:()=>S(t.id),children:[s.jsx("span",{className:"qn-tag-bar"}),s.jsx("span",{className:"qn-tag-idx",children:y+1})]})]}),s.jsx("div",{className:"msg-body",children:B?s.jsxs("div",{className:`msg-editor${X?" drag-over":""}`,onDragOver:F=>{F.preventDefault(),F.stopPropagation(),k(!0)},onDragLeave:F=>{F.currentTarget.contains(F.relatedTarget)||k(!1)},onDrop:F=>{F.preventDefault(),F.stopPropagation(),k(!1),ee(Array.from(F.dataTransfer?.files??[]))},children:[K.length>0&&s.jsx("div",{className:"msg-editor-images",children:K.map((F,pe)=>{const Ee=nh(F);return s.jsxs("span",{className:`msg-editor-img ${Ee==="image"?"":"file-chip"}`,title:ah(F,P),children:[Ee==="image"?s.jsx("img",{src:`data:${F.mimeType??"image/png"};base64,${F.imageData}`,alt:F.name}):s.jsxs("span",{className:"msg-editor-file",children:[s.jsx("span",{className:"msg-editor-file-icon",children:Ee==="path"?F.mode==="reference"?"🔗":"📎":"📄"}),s.jsx("span",{className:"msg-editor-file-name",children:F.name??F.path?.split("/").pop()})]}),s.jsx("button",{type:"button",className:"msg-editor-img-remove",title:P("removeAttachment"),onClick:()=>j(Oe=>Oe.filter((Se,U)=>U!==pe)),children:s.jsx($e,{})})]},`${F.name??F.path??"att"}-${pe}`)})}),Z&&s.jsx("div",{className:"msg-editor-notice",children:Z}),s.jsx("textarea",{className:"msg-editor-input",value:Q,autoFocus:!0,placeholder:P("editPlaceholder"),rows:Math.max(2,Math.min(10,Q.split(`
|
|
317
|
+
`).length+1)),onChange:F=>re(F.target.value),onPaste:F=>{const pe=[];for(const Ee of F.clipboardData?.items??[])if(Ee.kind==="file"&&vt(Ee.type)){const Oe=Ee.getAsFile();Oe&&pe.push(Oe)}pe.length!==0&&(F.preventDefault(),ye(pe))},onKeyDown:F=>{F.key==="Enter"&&(F.metaKey||F.ctrlKey)?(F.preventDefault(),ae()):F.key==="Escape"&&H(!1)}}),s.jsxs("div",{className:"msg-editor-actions",children:[s.jsxs("span",{className:"msg-editor-hint",children:[s.jsx(Dl,{})," ",P("editAttachmentHint")]}),s.jsx("button",{type:"button",className:"chip",onClick:()=>H(!1),children:P("cancel")}),s.jsxs("button",{type:"button",className:"chip primary",disabled:!Q.trim(),title:P("reaskFromHere"),onClick:ae,children:[s.jsx(Xt,{})," ",P("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}),c&&!i&&f&&s.jsxs("button",{type:"button",className:"msg-retry-btn",title:P("retryLastTip"),onClick:f,children:[s.jsx(kt,{})," ",P("retryNow")]})]}),de?s.jsx(ih,{message:t,forceOpen:$}):I?s.jsxs(s.Fragment,{children:[s.jsx(lh,{block:I,forceOpen:$}),I.userMessage&&s.jsx("div",{className:"msg-text",children:s.jsx(ot,{text:I.userMessage,hardBreaks:!0})}),t.content.map((F,pe)=>F.type==="text"?null:s.jsx(Ii,{block:F,toolResults:n,liveOutputs:a,toolStatuses:o,streaming:i,isLast:c,onKillBash:u,toolsWrap:z,thinkingWrap:M,searchActive:$,role:t.role},`${t.id}-${pe}`))]}):t.content.map((F,pe)=>s.jsx(Ii,{block:F,toolResults:n,liveOutputs:a,toolStatuses:o,streaming:i,isLast:c,onKillBash:u,toolsWrap:z,thinkingWrap:M,searchActive:$,role:t.role},`${t.id}-${pe}`)),oe&&s.jsxs("div",{className:"thinking-wait",children:[P("thinkingWait"),s.jsx("span",{className:"dot"})]}),i&&c&&!oe&&s.jsx("span",{className:"stream-cursor"})]})}),se&&!B&&s.jsx("div",{className:"msg-actions",children:s.jsxs("button",{type:"button",className:"msg-action",title:P("editReaskTip"),onClick:ce,children:[s.jsx(Xt,{})," ",P("editReask")]})})]})});function ih({message:e,forceOpen:t=!1}){const n=Le(),[a,o]=l.useState(!1),[i,c]=l.useState(!1),d=a||t,u=e.details??{},f=u.name??u.path??n("attachment"),E=u.type==="folder",g=u.mode==="reference",y=u.mode==="bridged",N=e.content.filter(C=>C.type==="text").map(C=>C.text).join(`
|
|
318
|
+
`),S=rh(N),M=e.content.find(C=>C.type==="image"),z=S.split(`
|
|
319
|
+
`).length,$=!g&&S.length>0;return s.jsxs("div",{className:`attachcard ${g?"reference":""}`,children:[s.jsxs("div",{className:"chead attachcard-head",role:"button",tabIndex:0,"aria-expanded":d,title:n(d?"collapseMsg":"expandMsg"),onClick:()=>o(C=>t?!0:!C),onKeyDown:C=>{C.target===C.currentTarget&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),o(P=>t?!0:!P))},children:[!g&&s.jsx("span",{className:"chead-toggle",children:d?s.jsx(Ot,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon attachcard-icon",children:E?"📁":"📎"}),s.jsx("span",{className:"chead-title attachcard-name",children:f}),u.path&&s.jsx("span",{className:"attachcard-path",children:u.path}),s.jsx("span",{className:`attachcard-mode ${u.mode==="lines"?"lines":g?"ref":y?"bridged":"inline"}`,children:g?E?n("folderRefShort"):`${n("refOnlyShort")} · ${wi(u.size)}`:y?n("bridgedVision"):M?n("image"):u.mode==="lines"?n("inlineLinesRange",{start:u.startLine??1,end:u.endLine??u.lines??1}):n("inlineLines",{n:u.lines??z})}),$&&s.jsx("button",{type:"button",className:"chead-copy",title:n(i?"copied":"copyMessage"),"aria-label":n("copyMessage"),onClick:C=>{C.stopPropagation(),navigator.clipboard.writeText(S),c(!0),window.setTimeout(()=>c(!1),1200)},children:i?s.jsx(ns,{}):s.jsx(Ct,{})})]}),!g&&d&&(y?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:f})}),S&&s.jsx("pre",{className:"attachcard-content",children:S})]}):M?.dataUrl?s.jsx("div",{className:"attachcard-image",children:s.jsx("img",{src:M.dataUrl,alt:f})}):s.jsx("pre",{className:"attachcard-content",children:S})),g&&s.jsx("div",{className:"attachcard-refnote",children:E?n("folderNotExpanded"):n("fileNotExpanded",{size:wi(u.size)})})]})}function wi(e){return e===void 0?"":e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function rh(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 oh({message:e,forceOpen:t=!1,autoExpand:n=!1}){const a=Le(),[o,i]=l.useState(!1),[c,d]=l.useState(!1),[u,f]=l.useState(n);n!==u&&(f(n),n&&i(!0));const E=o||t,g=e.content.map(N=>ss(N)?.text??"").filter(Boolean).join(`
|
|
320
|
+
`),y=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:a("role.compaction")}),e.timestamp&&s.jsx("span",{className:"msg-time",children:fo(e.timestamp)})]}),s.jsxs("div",{className:`compaction-card${o?" expanded":""}`,children:[s.jsxs("div",{className:"chead compaction-head",role:"button",tabIndex:0,"aria-expanded":E,title:a(E?"collapseMsg":"expandMsg"),onClick:()=>i(N=>t?!0:!N),onKeyDown:N=>{N.target===N.currentTarget&&(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),i(S=>t?!0:!S))},children:[s.jsx("span",{className:"chead-toggle",children:E?s.jsx(Ot,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon compaction-icon",children:s.jsx(lr,{})}),s.jsx("span",{className:"chead-title compaction-title",children:y?a("compactionFrom",{tokens:y}):a("role.compaction")}),g&&s.jsx("button",{type:"button",className:"chead-copy",title:a(c?"copied":"copyMessage"),"aria-label":a("copyMessage"),onClick:N=>{N.stopPropagation(),navigator.clipboard.writeText(g),d(!0),window.setTimeout(()=>d(!1),1200)},children:c?s.jsx(ns,{}):s.jsx(Ct,{})})]}),E&&s.jsxs("div",{className:"compaction-body",children:[s.jsx(ot,{text:g}),s.jsx("div",{className:"compaction-hint",children:a("compactionKeptHint")})]})]})]})}function lh({block:e,forceOpen:t=!1}){const n=Le(),[a,o]=l.useState(!1),[i,c]=l.useState(!1),d=a||t;return s.jsxs("div",{className:`skillcard${a?" expanded":""}`,children:[s.jsxs("div",{className:"chead skillcard-head",role:"button",tabIndex:0,"aria-expanded":d,title:e.location,onClick:()=>o(u=>t?!0:!u),onKeyDown:u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),o(f=>t?!0:!f))},children:[s.jsx("span",{className:"chead-toggle",children:d?s.jsx(Ot,{}):s.jsx($t,{})}),s.jsx("span",{className:"chead-icon skillcard-icon",children:s.jsx(Hl,{})}),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(i?"copied":"copyMessage"),"aria-label":n("copyMessage"),onClick:u=>{u.stopPropagation(),navigator.clipboard.writeText(e.content),c(!0),window.setTimeout(()=>c(!1),1200)},children:i?s.jsx(ns,{}):s.jsx(Ct,{})})]}),d&&s.jsx("div",{className:"skillcard-body",children:s.jsx(ot,{text:e.content})})]})}function Ii({block:e,toolResults:t,liveOutputs:n,toolStatuses:a,streaming:o,isLast:i,onKillBash:c,thinkingWrap:d,toolsWrap:u,searchActive:f,role:E}){const g=Le(),[y,N]=l.useState(!1),S=ss(e);if(S){const P=o&&i,B=E==="assistant"||E==="user",H=B&&!S.text.includes(`
|
|
321
|
+
`)&&!S.truncated,Q=E==="user"?s.jsx(ot,{text:S.text,hardBreaks:!0}):P?s.jsx(Mp,{text:S.text}):s.jsx(ot,{text:S.text});return s.jsxs("div",{className:`msg-text${H?" single":""}`,children:[H?s.jsx("div",{className:"msg-text-main",children:Q}):s.jsxs(s.Fragment,{children:[Q,S.truncated&&s.jsx("div",{className:"trunc-note",children:g("truncated")})]}),B?s.jsx("button",{type:"button",className:"msg-text-copy",title:g(y?"copied":"copyMessage"),"aria-label":g("copyMessage"),onClick:()=>{navigator.clipboard.writeText(S.text),N(!0),window.setTimeout(()=>N(!1),1200)},children:y?s.jsx(ns,{}):s.jsx(Ct,{})}):null]})}const M=co(e);if(M)return s.jsx(Bp,{thinking:M.thinking,streaming:o&&i,wrap:d,forceOpen:f});const z=uo(e);if(z){const P=t.get(z.id),B=n.get(z.id),H={result:P,liveOutput:B?.text,streaming:o,status:a.get(z.id)};return s.jsx(Qp,{block:z,view:H,onKillBash:c,wrap:u,forceOpen:f})}const $=mo(e);if($&&$.dataUrl)return s.jsx("div",{className:"msg-image",children:s.jsx("img",{src:$.dataUrl,alt:"attachment"})});const C=po(e);return C?s.jsxs("div",{className:"bashblock",children:[s.jsxs("div",{className:"bashblock-command",children:[s.jsx("span",{className:"bashblock-prompt",children:"$"}),s.jsx("code",{children:C.command}),C.exitCode!==void 0&&s.jsx("span",{className:`bashblock-exit ${C.exitCode===0?"ok":"err"}`,children:g("exitCode",{code:C.exitCode})}),C.cancelled&&s.jsx("span",{className:"bashblock-exit err",children:g("cancelled")})]}),C.output&&s.jsx("pre",{className:"bashblock-output",children:C.output}),C.truncated&&s.jsx("div",{className:"trunc-note",children:g("outputTruncated")})]}):null}function ho(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 fo(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return`${n}:${a}`}function ji(e,t,n){let a=!1;for(const o of t){const i=o;if(i.type!=="image"||typeof i.dataUrl!="string"||!i.dataUrl.startsWith("data:"))continue;const c=i.dataUrl.match(/^data:([^;]*);base64,(.+)$/);c&&(a=!0,e.push({path:"",imageData:c[2],mimeType:c[1]||"image/png",name:n??`image.${(c[1]||"image/png").split("/")[1]??"png"}`}))}return a}function ch(e){const t=new Map;for(let n=0;n<e.length;n++){const a=e[n];if(a.role!=="user"||!a.id)continue;const o=[];ji(o,a.content);for(let i=n+1;i<e.length&&e[i].role==="custom"&&e[i].customType==="file";i++){const c=e[i].details??{};if(!ji(o,e[i].content,c.name)){if(c.upload&&c.path){o.push({path:"",uploadPath:c.path,name:c.name??c.path,size:c.size});continue}if(c.path&&c.mode){const d=c.mode==="inline"||c.mode==="lines"?c.mode:"reference",u={path:c.path,mode:d};c.mode==="lines"&&typeof c.startLine=="number"&&typeof c.endLine=="number"&&(u.lines={start:c.startLine,end:c.endLine}),o.push(u)}}}o.length>0&&t.set(a.id,o)}return t}const uh=l.memo(function({message:t,onExpand:n}){const a=Le();let o="";for(const g of t.content){const y=ss(g);if(y&&y.text.trim()){const N=ba(y.text);N?o=`skill:${N.name}`+(N.userMessage?` · ${N.userMessage.replace(/\s+/g," ").trim()}`:""):o=y.text.replace(/\s+/g," ").trim();break}}if(!o&&t.role==="custom"&&t.customType==="file"){const g=t.details??{};o=g.name??g.path??""}o.length>90&&(o=`${o.slice(0,90)}…`);let c=0,d=0,u=0,f=0;for(const g of t.content)co(g)?c++:uo(g)?d++:po(g)?u++:mo(g)&&f++;const E=[];return c&&E.push(`${a("thinking")} ${c}`),d&&E.push(`${a("toolCalls")} ${d}`),u&&E.push(`${a("bashRuns")} ${u}`),f&&E.push(`${a("images")} ${f}`),s.jsxs("div",{role:"button",tabIndex:0,className:"msg-collapsed","data-msg-id":t.id,title:`${a("expandMsg")} · ${o||E.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"?a("attachment"):ho(t.role,a)}),s.jsxs("span",{className:"msg-collapsed-body",children:[o&&s.jsx("span",{className:"msg-collapsed-preview",children:o}),E.length>0&&s.jsx("span",{className:"msg-collapsed-chips",children:E.map((g,y)=>s.jsx("span",{className:"msg-collapsed-chip",children:g},y))})]}),t.timestamp?s.jsx("span",{className:"msg-collapsed-time",children:dh(t.timestamp)}):null,s.jsxs("span",{className:"msg-collapsed-action",children:[s.jsx($t,{})," ",a("expandMsg")]})]})});function dh(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return`${n}:${a}`}const mh=l.memo(function({id:t,show:n,height:a,containerRef:o,onMeasured:i,lazyRef:c,children:d}){const u=l.useRef(null),f=l.useRef(null);return l.useLayoutEffect(()=>{const E=f.current;if(f.current=n,!n||E!==!1)return;const g=u.current,y=o.current;if(!g||!y)return;const N=g.offsetHeight;i?.(t,N);const S=N-a;if(S!==0){const M=g.parentElement;M&&M.getBoundingClientRect().bottom<=y.getBoundingClientRect().top&&(y.scrollTop+=S)}},[n]),n?s.jsx("div",{ref:c,"data-lazy-id":t,children:s.jsx("div",{ref:u,children:d})}):s.jsx("div",{ref:c,className:"msg-lazy-ph","data-msg-id":t,"data-lazy-id":t,style:{height:a},"aria-hidden":"true"})});function ph(e,t,n,a){const o=[],i=[];let c=0;for(const d of e){if(n.has(d.id))continue;d.top<t.bottom&&d.bottom>t.top?a.has(d.id)&&o.push(d.id):a.has(d.id)||(i.push(d.id),d.bottom<=t.top&&(c+=d.bottom-d.top))}return{show:o,hide:i,shrinkAbove:c}}function hh(e,t){if(t.show.length===0&&t.hide.length===0)return e;const n=new Set(e);for(const a of t.show)n.delete(a);for(const a of t.hide)n.add(a);return n}function fh(e,t,n){const a=new Set;let o=0;for(let i=e.length-1;i>=0&&!(i<e.length-1&&o>=n);i--){const c=e[i];a.add(c.id),o+=t.get(c.id)??go(c.role,c.customType)}return a}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 gh=["text","thinking","argumentsText","output","command"];function bh(e){let t=0;for(const n of e.content){n.type==="image"&&(t+=1);for(const a of gh){const o=n[a];typeof o=="string"&&(t+=o.length)}}return t}function Eh(e,t,n,a){const o=n.get(e);return o&&o.len===t?o.h:a}function Th(e){const t=[];for(const n of e.content)n.type==="text"&&typeof n.text=="string"&&t.push(n.text);return t.join(`
|
|
322
|
+
`)}function xh(e,t){const n=[];for(const a of e.content)if(a.type==="text"&&typeof a.text=="string")n.push(a.text);else if(a.type==="thinking"&&typeof a.thinking=="string")n.push(a.thinking);else if(a.type==="toolCall"){if(typeof a.name=="string"&&n.push(a.name),typeof a.argumentsText=="string"&&n.push(a.argumentsText),typeof a.id=="string"){const o=t.get(a.id);if(o){const i=Th(o);i&&n.push(i)}}}else a.type==="bash"&&(typeof a.command=="string"&&n.push(a.command),typeof a.output=="string"&&n.push(a.output));return n.join(`
|
|
323
|
+
`)}function yh(e,t){let n=0,a=e.indexOf(t);for(;a!==-1;)n++,a=e.indexOf(t,a+t.length);return n}function Nh(e,t,n,a){const o=new Map,i=n.toLowerCase();if(!i)return o;for(const c of e){if(!t.has(c.id))continue;const d=yh(xh(c,a).toLowerCase(),i);d>0&&o.set(c.id,d)}return o}function kh(e,t){const n=[],a=t.toLowerCase();if(!a)return n;const o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(i){const c=i.parentElement;return!c||c.closest(".search-bar")||c.closest(".msg-collapsed")?NodeFilter.FILTER_REJECT:(i.textContent??"").toLowerCase().includes(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let i=o.nextNode();i;i=o.nextNode()){const c=(i.textContent??"").toLowerCase();if(!i.parentElement?.closest("[data-msg-id]"))continue;let d=c.indexOf(a);for(;d!==-1;){const u=document.createRange();u.setStart(i,d),u.setEnd(i,d+a.length),n.push(u),d=c.indexOf(a,d+a.length)}}return n}function vh(e,t,n,a,o){const i=Nh(n,a,t,o),c=new Map;for(const u of kh(e,t)){const f=u.startContainer.parentElement?.closest("[data-msg-id]");if(!f?.dataset.msgId)continue;const E=c.get(f.dataset.msgId);E?E.push(u):c.set(f.dataset.msgId,[u])}const d=[];for(const u of n){const f=c.get(u.id);if(f)for(let g=0;g<f.length;g++)d.push({kind:"dom",range:f[g],msgId:u.id,k:g});const E=i.get(u.id);if(E)for(let g=0;g<E;g++)d.push({kind:"folded",msgId:u.id,k:g})}return d}function wn(e,t){return e.findIndex(n=>n.msgId===t.msgId&&n.k===t.k)}function ht(e,t){const n=CSS;if(!n.highlights)return;if(t.length===0){n.highlights.delete(e);return}const a=window.Highlight;a&&n.highlights.set(e,new a(...t))}function Ch(e,t){const n=[];let a=e;for(;a&&a!==t;){const o=getComputedStyle(a);/(auto|scroll|hidden)/.test(o.overflowY+o.overflowX)&&(a.scrollHeight>a.clientHeight||a.scrollWidth>a.clientWidth)&&n.push(a),a=a.parentElement}return n}function _h(e,t){const n=t.startContainer.parentElement;for(const d of Ch(n,e)){const u=t.getBoundingClientRect(),f=d.getBoundingClientRect();if(u.height<=0||u.width<=0)return;u.top>=f.top+4&&u.bottom<=f.bottom-4||(d.scrollTop+=u.top-f.top-(d.clientHeight-u.height)/2),u.left>=f.left+4&&u.right<=f.right-4||(d.scrollLeft+=u.left-f.left-(d.clientWidth-u.width)/2)}const a=t.getBoundingClientRect(),o=e.getBoundingClientRect();if(a.height<=0||a.width<=0)return;const i=a.top>=o.top+6&&a.bottom<=o.bottom-6,c=a.left>=o.left+6&&a.right<=o.right-6;i&&c||(i||(e.scrollTop+=a.top-o.top-(o.height-a.height)/2),c||(e.scrollLeft+=a.left-o.left-(o.width-a.width)/2))}function Sh({containerRef:e,messages:t,collapsedIds:n,toolResults:a,onExpand:o,onProgrammaticScroll:i,open:c,onClose:d}){const u=Le(),f=l.useRef(null),[E,g]=l.useState(""),[y,N]=l.useState(null),[S,M]=l.useState(0),[,z]=l.useState(0),$=l.useDeferredValue(E),C=c?$.trim():"",P=l.useRef(null);P.current=y;const B=l.useRef([]),H=l.useRef({key:null}),Q=l.useRef("");l.useEffect(()=>{c&&(N(null),requestAnimationFrame(()=>f.current?.select()))},[c]),l.useEffect(()=>{if(!c)return;const j=X=>{X.key==="Escape"&&(X.preventDefault(),X.stopPropagation(),d())};return window.addEventListener("keydown",j,!0),()=>window.removeEventListener("keydown",j,!0)},[c,d]),l.useEffect(()=>(c||(ht("msg-search",[]),ht("msg-search-active",[])),()=>{ht("msg-search",[]),ht("msg-search-active",[])}),[c]),l.useLayoutEffect(()=>{const j=()=>{M(0),N(null),z(0),B.current=[],ht("msg-search",[]),ht("msg-search-active",[]),H.current={key:null},Q.current=""};if(!c||!C){j();return}const X=e.current;if(!X)return;let k=!1,Z=0;return Z=requestAnimationFrame(()=>{if(k)return;const Y=vh(X,C,t,n,a);B.current=Y;const me=Y.length;if(M(me),me===0){N(null),z(0),ht("msg-search",[]),ht("msg-search-active",[]),H.current={key:null},Q.current=C;return}const de=P.current;let w;if(de){if(w=wn(Y,de),w===-1){const ye=[];for(let v=0;v<Y.length;v++)Y[v].msgId===de.msgId&&ye.push(v);if(ye.length>0){const v=Math.min(de.k,ye.length-1);w=ye[v]}else w=0}}else w=0;w<0&&(w=0),w>=me&&(w=me-1),(!de||de.msgId!==Y[w].msgId||de.k!==Y[w].k)&&N({msgId:Y[w].msgId,k:Y[w].k}),z(w);const I=Y[w],L=H.current,oe=L.key?.msgId!==I.msgId||L.key?.k!==I.k||L.kind==="folded"&&I.kind==="dom"||C!==Q.current;H.current={key:{msgId:I.msgId,k:I.k},kind:I.kind},Q.current=C;const se=Y.filter(ye=>ye.kind==="dom").map(ye=>ye.range);if(ht("msg-search",se),I.kind==="folded"){ht("msg-search-active",[]),oe&&o(I.msgId);return}ht("msg-search-active",[I.range]),oe&&(i?.(),_h(X,I.range))}),()=>{k=!0,cancelAnimationFrame(Z)}},[c,C,t,e,y,n,a,o,i]);const re=l.useCallback(j=>{const X=B.current,k=X.length;if(k===0)return;const Z=P.current,Y=Z?wn(X,Z):0,me=X[(Y+j+k)%k];N(me.kind==="dom"||me.kind==="folded"?{msgId:me.msgId,k:me.k}:null)},[]);if(!c)return null;const K=y?(()=>{const j=wn(B.current,y);return j===-1?0:j})():0;return s.jsxs("div",{className:"search-bar",role:"search",children:[s.jsx("input",{ref:f,className:"search-input",type:"text",value:E,placeholder:u("searchPlaceholder"),onChange:j=>{g(j.target.value)},onKeyDown:j=>{j.key==="Enter"&&(j.preventDefault(),re(j.shiftKey?-1:1))}}),s.jsx("span",{className:`search-count ${S===0?"empty":""}`,children:S===0?u("searchNoResults"):`${Math.min(K+1,S)}/${S}`}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchPrev"),disabled:S===0,onClick:()=>re(-1),children:s.jsx(dn,{})}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchNext"),disabled:S===0,onClick:()=>re(1),children:s.jsx(Ot,{})}),s.jsx("button",{type:"button",className:"search-btn",title:u("searchClose"),onClick:d,children:s.jsx($e,{})})]})}function Ah(e){const{dSt:t,dSh:n,escaped:a,graceActive:o,stuck:i}=e;return o?{flipEscape:!1,reassert:!1}:t>=-4||t<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:i&&!a}:{flipEscape:!0,reassert:!1}}const bo=[{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"}],Eo="pi-web-ui:prompt-templates";function wh(){try{const e=localStorage.getItem(Eo);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 Li(e){return bo.some(t=>t.id===e)}function Bs(e){return typeof e.title=="string"}const To=l.createContext(null);function xo(){const e=l.useContext(To);if(!e)throw new Error("useTemplates must be used within TemplateProvider");return e}function Ih({send:e,children:t}){const n=Le(),[a,o]=l.useState(wh),[i,c]=l.useState(!1),[d,u]=l.useState(null),[f,E]=l.useState(!1),[g,y]=l.useState(!1),[N,S]=l.useState(!1);l.useEffect(()=>{try{localStorage.setItem(Eo,JSON.stringify(a))}catch{}},[a]);const M=l.useMemo(()=>{const Y=new Map,me=new Set;for(const I of a)I.hidden?me.add(I.id):(Bs(I)&&!Li(I.id)||Bs(I))&&Y.set(I.id,I);const de=bo.filter(I=>!me.has(I.id)).map(I=>{const L=Y.get(I.id);return{id:I.id,icon:L?.icon??I.icon,title:L?.title??n(I.titleKey),desc:L?.desc??n(I.descKey),prompt:L?.prompt??n(I.promptKey),builtin:!0}}),w=a.filter(I=>Bs(I)&&!Li(I.id)).map(I=>({id:I.id,icon:I.icon??"📌",title:I.title??"",desc:I.desc??"",prompt:I.prompt??""}));return[...de,...w]},[a,n]),z=l.useCallback(()=>c(!0),[]),$=l.useCallback(Y=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:Y}))},[]),C=l.useCallback((Y,me=!1)=>{S(me),Y?(E(!1),u({...Y})):(E(!0),u({id:_t(),icon:"📌",title:"",desc:"",prompt:""}))},[]),P=l.useCallback(()=>{c(!1),u(null),S(!1)},[]),B=l.useCallback(()=>{g?(o([]),y(!1)):(y(!0),setTimeout(()=>y(!1),5e3))},[g]),H=l.useCallback(Y=>{c(!1),$(Y.prompt)},[$]),Q=l.useCallback(Y=>{c(!1),C(Y,!0)},[C]),re=l.useCallback(()=>{c(!1),C(void 0,!0)},[C]),K=l.useCallback(Y=>{o(me=>{const de=me.findIndex(w=>w.id===Y.id);if(de>=0){const w=[...me];return w[de]=Y,w}return[...me,Y]}),u(null),N&&(c(!0),S(!1))},[N]),j=l.useCallback(Y=>{o(me=>Y.builtin?[...me.filter(w=>w.id!==Y.id),{id:Y.id,hidden:!0}]:me.filter(de=>de.id!==Y.id)),u(null),N&&(c(!0),S(!1))},[N]),X=l.useCallback(Y=>{o(me=>me.filter(de=>de.id!==Y.id||de.hidden)),u(null),N&&(c(!0),S(!1))},[N]),k=l.useMemo(()=>({templates:M,fill:$,openPicker:z,openEdit:C,resetConfirm:g,toggleReset:B}),[M,$,z,C,g,B]),Z=d?a.some(Y=>Y.id===d.id&&!Y.hidden&&Bs(Y)):!1;return s.jsxs(To.Provider,{value:k,children:[t,i&&s.jsx(Lh,{templates:M,resetConfirm:g,onFill:H,onEditTpl:Q,onNew:re,onResetToggle:B,onClose:P}),d&&s.jsx(Rh,{editing:d,isNew:f,hasOverride:Z,onDraft:u,onSave:K,onRestore:()=>X(d),onRemove:()=>j(d),onFill:()=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:d.prompt})),P()},onSend:()=>{const Y=d.prompt.trim();Y&&e({type:"prompt",text:Y,queue:!1})&&P()},onClose:P})]})}function jh(){const e=Le(),{templates:t,fill:n,openEdit:a,toggleReset:o,resetConfirm:i}=xo();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(c=>s.jsx(yo,{tpl:c,title:e("tpl.clickCard"),onFill:()=>n(c.prompt),onEdit:()=>a(c),editTitle:e("tpl.editTpl")},c.id)),s.jsxs("button",{type:"button",className:"empty-template add",onClick:()=>a(),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:o,children:[s.jsx(tr,{}),e(i?"tpl.resetConfirm":"tpl.reset")]})})]})}function yo({tpl:e,title:t,onFill:n,onEdit:a,editTitle:o}){const i=Le();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:o??i("tpl.editTpl"),onClick:c=>{c.stopPropagation(),a()},children:s.jsx(en,{})})]})}function Lh({templates:e,resetConfirm:t,onFill:n,onEditTpl:a,onNew:o,onResetToggle:i,onClose:c}){const d=Le();return l.useEffect(()=>{const u=f=>{f.key==="Escape"&&c()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[c]),s.jsx("div",{className:"modal-backdrop",onClick:c,children:s.jsxs("div",{className:"modal template-picker",onClick:u=>u.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:d("tpl.pickerTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:d("close"),onClick:c,children:s.jsx($e,{})})]}),s.jsx("div",{className:"template-picker-hint",children:d("tpl.pickerHint")})]}),s.jsx("div",{className:"template-picker-scroll",children:s.jsxs("div",{className:"template-picker-grid",children:[e.map(u=>s.jsx(yo,{tpl:u,title:d("tpl.clickCard"),onFill:()=>n(u),onEdit:()=>a(u),editTitle:d("tpl.editTpl")},u.id)),s.jsxs("button",{type:"button",className:"empty-template add",onClick:o,title:d("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:d("tpl.add")}),s.jsx("span",{className:"empty-template-desc",children:d("tpl.addDesc")})]})]})]})}),s.jsx("div",{className:"template-picker-foot",children:s.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:i,children:[s.jsx(tr,{}),d(t?"tpl.resetConfirm":"tpl.reset")]})})]})})}function Rh({editing:e,isNew:t,hasOverride:n,onDraft:a,onSave:o,onRestore:i,onRemove:c,onFill:d,onSend:u,onClose:f}){const E=Le(),g=l.useRef(null);l.useEffect(()=>{const S=M=>{M.key==="Escape"&&f()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[f]),l.useEffect(()=>{const S=g.current;if(!S)return;S.style.height="auto";const M=S.scrollHeight>300;S.style.height=`${Math.min(S.scrollHeight,300)}px`,S.style.overflowY=M?"auto":"hidden"},[e.prompt]);const y=()=>{const S=e.title.trim(),M=e.prompt.trim();if(!S||!M){a({...e,error:E("tpl.required")});return}o({id:e.id,icon:e.icon.trim()||"📌",title:S,desc:e.desc.trim(),prompt:M})},N=!!e.builtin&&!t;return s.jsx("div",{className:"modal-backdrop",onClick:f,children:s.jsxs("div",{className:"modal template-modal",onClick:S=>S.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:E(N?"tpl.builtin":"tpl.custom")}),s.jsx("span",{className:"template-modal-title",children:E(t?"tpl.newTitle":"tpl.editTitle")}),s.jsx("button",{type:"button",className:"btn template-modal-close",title:E("close"),onClick:f,children:s.jsx($e,{})})]}),s.jsxs("div",{className:"template-modal-body",children:[s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:E("tpl.fieldIcon")}),s.jsx("input",{className:"template-field-input icon",value:e.icon,maxLength:4,onChange:S=>a({...e,icon:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:E("tpl.fieldTitle")}),s.jsx("input",{className:"template-field-input",value:e.title,placeholder:E("tpl.fieldTitlePh"),onChange:S=>a({...e,title:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:E("tpl.fieldDesc")}),s.jsx("input",{className:"template-field-input",value:e.desc,placeholder:E("tpl.fieldDescPh"),onChange:S=>a({...e,desc:S.target.value})})]}),s.jsxs("label",{className:"template-field",children:[s.jsx("span",{className:"template-field-label",children:E("tpl.fieldPrompt")}),s.jsx("textarea",{ref:g,className:"template-field-prompt",value:e.prompt,placeholder:E("tpl.fieldPromptPh"),onChange:S=>a({...e,prompt:S.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:E("tpl.restoreTip"),onClick:i,children:E("tpl.restore")}),!t&&N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:E("tpl.removeTip"),onClick:c,children:[s.jsx(et,{})," ",E("tpl.remove")]}),!t&&!N&&s.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:E("tpl.deleteTip"),onClick:c,children:[s.jsx(et,{})," ",E("tpl.delete")]})]}),s.jsxs("div",{className:"template-modal-actions-right",children:[s.jsx("button",{type:"button",className:"btn template-btn",onClick:y,children:E("tpl.save")}),s.jsx("button",{type:"button",className:"btn template-btn fill",onClick:d,title:E("tpl.fillTip"),children:E("tpl.fill")}),s.jsxs("button",{type:"button",className:"btn template-btn send",onClick:u,title:E("tpl.sendTip"),children:[s.jsx(Xs,{})," ",E("tpl.sendNow")]})]})]})]})})}const Ri=new Map,Ph=15,Pi=30,In=250,Di=1200,Dh=1600;function Oh({compaction:e}){const t=Le(),[,n]=l.useState(0);l.useEffect(()=>{const i=setInterval(()=>n(c=>c+1),1e3);return()=>clearInterval(i)},[]);const a=Math.max(0,Math.floor((Date.now()-e.startedAt)/1e3)),o=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")," · ",a,"s"]}),s.jsx("span",{className:"compact-reason",children:o})]})}function Oi(e){return e.content.some(t=>t.type==="toolCall")}function Mh({state:e,liveOutputs:t,toolStatuses:n,onEdit:a,onKillBash:o,onRetry:i,onRemoveQueued:c,thinkingWrap:d,toolsWrap:u,jumpTarget:f,onJumpDone:E}){const g=Le(),y=l.useRef(null),[N,S]=l.useState(!0),M=l.useRef(!0),z=l.useRef(0),$=l.useRef(0),C=l.useRef(!1),P=l.useRef(0),[B,H]=l.useState(()=>new Set),[Q,re]=l.useState(!1),K=e.streamingMessage?[...e.messages,e.streamingMessage]:e.messages,j=l.useMemo(()=>{const R=new Map;for(const W of e.messages)W.role==="toolResult"&&W.toolCallId&&R.set(W.toolCallId,W);return R},[e.messages]),X=l.useMemo(()=>ch(e.messages),[e.messages]),k=K.length>0?K[K.length-1].id:null,Z=e.messages.length>Pi?Math.max(0,e.messages.length-Ph):0,Y=l.useMemo(()=>{const R=new Set;for(let W=0;W<Z;W++){const _e=e.messages[W];_e.role!=="toolResult"&&(B.has(_e.id)||R.add(_e.id))}return R},[e.messages,Z,B]),[me,de]=l.useState(()=>new Set),[w,I]=l.useState(()=>new Set),L=l.useRef(new Map),oe=l.useRef(new Map),se=l.useRef(new Map),ye=l.useRef(0),v=l.useMemo(()=>{const R=new Map;for(const W of e.messages)R.set(W.id,bh(W));return R},[e.messages]),ee=l.useRef(v);ee.current=v;const ce=l.useRef(me);ce.current=me;const ae=e.messages.length>Pi&&!Q,_=l.useRef(ae);_.current=ae;const he=fh(e.messages,L.current,Dh),F=l.useRef(he);F.current=he;const pe=l.useCallback(()=>{const R=y.current;if(!R)return;if(!_.current){de(Fe=>Fe.size?new Set:Fe);return}const W=R.getBoundingClientRect(),_e={top:W.top-Di,bottom:W.bottom+Di},Ce=[];for(const[Fe,it]of se.current){const yt=it.getBoundingClientRect();Ce.push({id:Fe,top:yt.top,bottom:yt.bottom}),ce.current.has(Fe)||Se(Fe,yt.bottom-yt.top,ee.current.get(Fe))}const Be=ph(Ce,_e,F.current,ce.current);for(const Fe of Be.hide){const it=se.current.get(Fe);it&&Se(Fe,it.offsetHeight,ee.current.get(Fe))}de(Fe=>hh(Fe,Be))},[]),Ee=l.useCallback(()=>{ye.current||(ye.current=requestAnimationFrame(()=>{ye.current=0,pe()}))},[pe]);l.useLayoutEffect(()=>{pe()},[pe]);const Oe=l.useRef(Q);l.useLayoutEffect(()=>{Oe.current&&!Q&&pe(),Oe.current=Q},[Q,pe]);const Se=l.useCallback((R,W,_e)=>{_e!==void 0&&(oe.current.set(R,{h:W,len:_e}),L.current.set(R,W))},[]),U=l.useCallback((R,W)=>{Se(R,W,ee.current.get(R))},[Se]),ge=l.useCallback(R=>{R&&se.current.set(R.dataset.lazyId??"",R)},[]);l.useEffect(()=>{const R=new Set(e.messages.map(W=>W.id));for(const W of se.current.keys())R.has(W)||(se.current.delete(W),L.current.delete(W),oe.current.delete(W));de(W=>{let _e=!1;const Ce=new Set;for(const Be of W)R.has(Be)?Ce.add(Be):_e=!0;return _e?Ce:W})},[e.messages,B]),l.useEffect(()=>()=>cancelAnimationFrame(ye.current),[]);const ue=l.useMemo(()=>{const R=[];for(const W of e.messages){if(W.role!=="user")continue;const _e=W.content.map(Fe=>ss(Fe)?.text??"").filter(Boolean).join(" "),Ce=ba(_e),Be=Ce?Ce.userMessage??`skill:${Ce.name}`:_e.trim();Be&&R.push({id:W.id,text:Be})}return R},[e.messages]),ie=l.useMemo(()=>{const R=new Map;return ue.forEach((W,_e)=>R.set(W.id,_e)),R},[ue]),[G,Te]=l.useState(-1),Re=l.useRef(-1),x=l.useRef(ue);l.useEffect(()=>{x.current=ue},[ue]);const b=l.useCallback(()=>{const R=y.current,W=x.current;if(!R||W.length===0)return;const _e=R.getBoundingClientRect().top,Ce=140;let Be=-1;for(let Fe=0;Fe<W.length;Fe++){const it=R.querySelector(`[data-msg-id="${W[Fe].id}"]`);if(it)if(it.getBoundingClientRect().top<=_e+Ce)Be=Fe;else break}Be!==Re.current&&(Re.current=Be,Te(Be))},[]);l.useEffect(()=>{b()},[ue,b]);const J=l.useCallback(R=>{H(W=>W.has(R)?W:new Set(W).add(R))},[]);l.useEffect(()=>{const R=W=>{if(!(W.ctrlKey||W.metaKey)||W.key.toLowerCase()!=="f")return;const _e=W.target;_e&&(_e.tagName==="INPUT"||_e.tagName==="TEXTAREA"||_e.isContentEditable)||(W.preventDefault(),re(!0))};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[]);const le=l.useCallback(R=>{H(W=>{if(!W.has(R))return W;const _e=new Set(W);return _e.delete(R),_e})},[]),be=l.useCallback(R=>{const W=e.messages.findIndex(Ce=>Ce.id===R);Zc.flushSync(()=>{W>=0&&W<Z&&!B.has(R)&&J(R),I(Ce=>Ce.has(R)?Ce:new Set(Ce).add(R))});const _e=x.current.findIndex(Ce=>Ce.id===R);Re.current=_e,Te(_e),requestAnimationFrame(()=>{const Ce=y.current?.querySelector(`[data-msg-id="${R}"]`);Ce&&(y.current?.querySelectorAll(".msg-flash").forEach(Be=>Be.classList.remove("msg-flash")),Ce.scrollIntoView({block:"start"}),Ce.classList.remove("msg-flash"),Ce.offsetWidth,Ce.classList.add("msg-flash"),Ce!==y.current?.lastElementChild&&(C.current=!0))})},[e.messages,Z,B,J]),[ke,Ie]=l.useState(null),Ae=l.useRef(null),D=l.useRef(null);l.useEffect(()=>{const R=Ae.current;if(!R||R.convId!==e.conversationId){Ae.current={convId:e.conversationId,ids:new Set(e.messages.filter(W=>W.role==="compactionSummary").map(W=>W.id))},D.current=null,Ie(null);return}for(const W of e.messages)if(W.role==="compactionSummary"&&!R.ids.has(W.id)){R.ids.add(W.id),Ie(W.id);break}},[e.messages,e.conversationId]),l.useEffect(()=>{!ke||D.current===ke||(D.current=ke,be(ke))},[ke,be]);const we=l.useMemo(()=>f?e.messages.find(R=>R.role===f.role&&R.timestamp===f.timestamp)?.id??null:null,[e.messages,f]);l.useEffect(()=>{if(f){if(we){be(we),E?.();return}e.sessionFile===f.path&&e.messages.length>0&&E?.()}},[we,be,E,f,e.sessionFile,e.messages.length]);const ve=l.useCallback(()=>{const R=y.current;if(!R)return;const W=R.scrollTop-z.current,_e=R.scrollHeight-$.current;z.current=R.scrollTop,$.current=R.scrollHeight;const Ce=R.scrollHeight-R.scrollTop-R.clientHeight<80,Be=Date.now()<P.current,Fe=Ah({dSt:W,dSh:_e,escaped:C.current,graceActive:Be,stuck:M.current});Fe.reassert&&(P.current=Date.now()+In,R.scrollTop=R.scrollHeight),Fe.flipEscape&&(C.current=!0),Ce&&W>=0&&(C.current=!1),Be||(W<0?M.current=Ce&&!C.current:Ce&&(M.current=!0)),S(M.current),b(),Ee()},[b,Ee]),qe=l.useRef(!1);l.useEffect(()=>{const R=qe.current;if(qe.current=!!e.isStreaming,R&&!e.isStreaming&&!C.current){const W=()=>{const Ce=y.current;Ce&&!C.current&&(Ce.scrollTop=Ce.scrollHeight,M.current=!0,S(!0))};requestAnimationFrame(()=>requestAnimationFrame(W));const _e=setTimeout(W,180);return()=>clearTimeout(_e)}},[e.isStreaming]),l.useEffect(()=>{const R=y.current;R&&M.current&&(R.scrollTop=R.scrollHeight)},[K,e.isStreaming,t]);const De=e.queue.steering.join("\0")+""+e.queue.followUp.join("\0");l.useEffect(()=>{const R=y.current;R&&M.current&&(R.scrollTop=R.scrollHeight)},[De]),l.useEffect(()=>{const R=y.current;if(!R||typeof ResizeObserver>"u")return;const W=new ResizeObserver(()=>{M.current&&!C.current&&(R.scrollTop=R.scrollHeight,S(!0))});return W.observe(R),()=>W.disconnect()},[]),l.useEffect(()=>{const R=y.current;if(!R||typeof MutationObserver>"u")return;let W=!1;const _e=new MutationObserver(()=>{W||(W=!0,requestAnimationFrame(()=>{W=!1;const Ce=y.current;Ce&&M.current&&!C.current&&(Ce.scrollTop=Ce.scrollHeight,S(!0))}))});return _e.observe(R,{childList:!0,subtree:!0,characterData:!0}),()=>_e.disconnect()},[]);const Xe=l.useCallback(()=>{if(!y.current)return;M.current=!0,C.current=!1,S(!0),P.current=Date.now()+In;const W=()=>{const _e=y.current;!_e||!M.current||C.current||(P.current=Date.now()+In,_e.scrollTop=_e.scrollHeight)};W(),requestAnimationFrame(()=>requestAnimationFrame(W)),setTimeout(W,120),setTimeout(W,300),setTimeout(W,600)},[]),mt=l.useRef(null);l.useEffect(()=>{const R=mt.current,W=y.current;if(!R||!W)return;const _e=Ce=>{Ce.preventDefault();const Be=R.querySelector(".qn-list");if(Be&&Be.contains(Ce.target)&&Be.scrollHeight>Be.clientHeight){Be.scrollTop+=Ce.deltaY;return}W.scrollTop+=Ce.deltaY};return R.addEventListener("wheel",_e,{passive:!1}),()=>R.removeEventListener("wheel",_e)},[]);const[St,os]=l.useState(0);l.useEffect(()=>{const R=()=>{os(y.current?.clientHeight??0),Ee()};return R(),window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)},[Ee]);const xt=ue.length,lt=l.useMemo(()=>xt===0?27:Math.max(4,Math.min(27,Math.floor(((St||600)-16)/xt)-3)),[xt,St]),At=lt<20;return s.jsxs("div",{className:"messages-wrap",children:[s.jsxs("div",{className:`messages${Q||N?"":" anchor-live"}`,ref:y,onScroll:ve,children:[e.messages.length===0&&!e.streamingMessage&&s.jsx("div",{className:"empty-state",children:s.jsx(jh,{})}),e.messages.map((R,W)=>{const _e=W<Z,Ce=_e&&B.has(R.id);if(_e&&!Ce)return R.role==="toolResult"?null:s.jsx(uh,{message:R,onExpand:J},R.id);const Be=R.role==="user"?ie.get(R.id):void 0,Fe=!ae||he.has(R.id)||w.has(R.id)||!me.has(R.id);return s.jsx(mh,{id:R.id,show:Fe,height:Eh(R.id,v.get(R.id)??-1,oe.current,go(R.role,R.customType)),containerRef:y,onMeasured:U,lazyRef:ge,children:s.jsx(Ai,{message:R,qnIndex:Be,qnActive:Be!==void 0?Be===G:void 0,onJump:be,toolResults:j,liveOutputs:Oi(R)?t:Ri,toolStatuses:n,streaming:e.isStreaming,onKillBash:o,onRetry:R.id===k?i:void 0,toolsWrap:u,thinkingWrap:d,isLast:R.id===k,onEdit:a,questionAttachments:X.get(R.id),onCollapse:Ce?le:void 0,searchActive:Q,autoExpand:R.id===ke},R.id)},R.id)}),e.streamingMessage&&s.jsx(Ai,{message:e.streamingMessage,toolResults:j,liveOutputs:Oi(e.streamingMessage)?t:Ri,toolStatuses:n,streaming:!0,isLast:!0,onEdit:a,onKillBash:o,toolsWrap:u,thinkingWrap:d,searchActive:Q},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?g("retryingApi",{attempt:Math.max(1,e.retry.attempt),max:e.retry.maxAttempts,error:e.retry.errorMessage}):g("retryingApiSoon",{error:e.retry.errorMessage})})]}),e.compaction&&s.jsx(Oh,{compaction:e.compaction}),e.isStreaming&&K.length===0&&s.jsx("div",{className:"streaming-wait",children:g("waitingResponse")}),e.queue.steering.map((R,W)=>s.jsx("div",{className:"queued-msg",children:s.jsxs("div",{className:"queued-bubble",children:[s.jsx("span",{className:"queued-tag steer",children:g("queueSteerTag")}),s.jsx("div",{className:"queued-text",children:R}),c&&s.jsx("button",{type:"button",className:"queued-remove",title:g("queueRemoveTip"),onClick:()=>c("steer",R),children:"✕"})]})},`q-steer-${W}`)),e.queue.followUp.map((R,W)=>s.jsx("div",{className:"queued-msg",children:s.jsxs("div",{className:"queued-bubble",children:[s.jsx("span",{className:"queued-tag follow",children:g("queueFollowTag")}),s.jsx("div",{className:"queued-text",children:R}),c&&s.jsx("button",{type:"button",className:"queued-remove",title:g("queueRemoveTip"),onClick:()=>c("followUp",R),children:"✕"})]})},`q-fu-${W}`))]}),!N&&s.jsxs("button",{type:"button",className:"scroll-bottom",onClick:Xe,children:[s.jsx(or,{})," ",g("backToBottom")]}),s.jsx(Sh,{containerRef:y,messages:K,collapsedIds:Y,toolResults:j,onExpand:J,onProgrammaticScroll:()=>{C.current=!0,M.current=!1,S(!1)},open:Q,onClose:()=>re(!1)}),ue.length>0&&s.jsxs("div",{className:`qn-rail ${At?"many":""}`,ref:mt,"aria-label":g("questionNavTitle"),style:{"--rail-gap":`${lt}px`},children:[ue.map((R,W)=>s.jsx("button",{type:"button",className:`qn-bar ${W===G?"active":""}`,"aria-label":`${W+1}. ${R.text}`,onClick:()=>be(R.id),children:s.jsxs("span",{className:"qn-bar-text",children:[W+1,". ",R.text]})},R.id)),At&&s.jsx("div",{className:"qn-list",children:ue.map((R,W)=>s.jsxs("button",{type:"button",className:`qn-list-item ${W===G?"active":""}`,"aria-label":`${W+1}. ${R.text}`,onClick:()=>be(R.id),children:[s.jsx("span",{className:"qn-list-idx",children:W+1}),s.jsx("span",{className:"qn-list-text",children:R.text})]},R.id))})]})]})}const No="pi-web-model-usage";function Bh(e){if(!e||typeof e!="object")return{};const t={};for(const[n,a]of Object.entries(e)){const o=typeof a=="number"?Math.floor(a):0;Number.isFinite(o)&&o>0&&(t[n]=o)}return t}function Fh(e,t){return t?{...e,[t]:(e[t]??0)+1}:e}function Hh(e,t){const n=t;return e.map((a,o)=>({m:a,i:o,count:n[a.id]??0})).sort((a,o)=>o.count-a.count||a.i-o.i).map(a=>a.m)}function ko(){try{const e=localStorage.getItem(No);return e?Bh(JSON.parse(e)):{}}catch{return{}}}function Uh(e){try{localStorage.setItem(No,JSON.stringify(e))}catch{}}function Mi(e){const t=Fh(ko(),e);return Uh(t),t}const Ta="pi-web-ui:prompt-history",qh=100,vo="pi-web-ui:prompt-history-settings",ta={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function Co(e){const t=ta;if(!e||typeof e!="object")return{...t};const n=e;let a=typeof n.maxEntries=="number"?Math.floor(n.maxEntries):t.maxEntries;(!Number.isFinite(a)||a<1)&&(a=1),a>500&&(a=500);let o=typeof n.charLimit=="number"?Math.floor(n.charLimit):t.charLimit;(!Number.isFinite(o)||o<100)&&(o=100),o>2e4&&(o=2e4);const i=typeof n.charLimitEnabled=="boolean"?n.charLimitEnabled:t.charLimitEnabled;return{maxEntries:a,charLimitEnabled:i,charLimit:o}}function _o(){try{const e=localStorage.getItem(vo);return e?Co(JSON.parse(e)):{...ta}}catch{return{...ta}}}function jn(e){const t=Co(e);try{localStorage.setItem(vo,JSON.stringify(t))}catch{}try{let n=As();t.charLimitEnabled&&(n=n.map(a=>a.length>t.charLimit?a.slice(0,t.charLimit):a)),n.length>t.maxEntries&&(n=n.slice(n.length-t.maxEntries)),So(n)}catch{}}function $h(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="string")continue;const a=n.trim();a&&t.push(a)}return t}function Wh(e,t,n=qh){const a=t.trim();if(!a||e.length>0&&e[e.length-1]===a)return e;const o=[...e,a];return o.length>n?o.slice(o.length-n):o}function As(){try{const e=localStorage.getItem(Ta);return e?$h(JSON.parse(e)):[]}catch{return[]}}function So(e){let t=e;for(;t;)try{localStorage.setItem(Ta,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 Bi(e){let t=e.trim();if(!t)return;const n=_o();n.charLimitEnabled&&t.length>n.charLimit&&(t=t.slice(0,n.charLimit));const a=As(),o=Wh(a,t,n.maxEntries);o!==a&&So(o)}function Kh(){try{localStorage.removeItem(Ta)}catch{}}function Yh(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 Gh(){return typeof window>"u"||typeof navigator>"u"||typeof window.matchMedia!="function"?!1:Yh({query:e=>window.matchMedia(e).matches,userAgent:navigator.userAgent,maxTouchPoints:navigator.maxTouchPoints})}const zh=["off","minimal","low","medium","high","xhigh","max"],Vh=l.memo(function({state:t,models:n,modelsLoading:a,send:o,onManageModels:i,providerKeys:c,compact:d=!1}){const u=Le(),f=t?.model,E=f?`${f.provider}/${f.id}`:null,[g,y]=l.useState(!1),[N,S]=l.useState(!1),[M,z]=l.useState(""),[$,C]=l.useState(null),[P,B]=l.useState({}),H=l.useRef(null),Q=l.useRef(null),[re,K]=l.useState(null);l.useEffect(()=>{if(!g){K(null);return}if(n.length===0)return;const L=requestAnimationFrame(()=>{const oe=Q.current;oe&&K(oe.offsetWidth)});return()=>cancelAnimationFrame(L)},[g,n.length]),l.useEffect(()=>{g&&B(ko())},[g]),l.useEffect(()=>{g||(z(""),C(null))},[g]);const j=l.useMemo(()=>{const L=new Map;for(const se of n)L.set(se.provider,(L.get(se.provider)??0)+1);const oe=[];for(const[se,ye]of[...L.entries()].sort((v,ee)=>v[0].localeCompare(ee[0]))){const v=c[se];if(v&&v.length>1)for(const ee of v)oe.push({provider:se,keyName:ee.name,count:ye});else oe.push({provider:se,keyName:null,count:ye})}return oe},[n,c]),X=l.useMemo(()=>Hh(n,P),[n,P]),k=l.useMemo(()=>{let L=X;$&&(L=L.filter(se=>se.provider===$.provider));const oe=M.trim().toLowerCase();return oe?L.filter(se=>se.name.toLowerCase().includes(oe)||se.provider.toLowerCase().includes(oe)||se.id.toLowerCase().includes(oe)):L},[X,M,$]),Z=l.useMemo(()=>{const L=[];for(const oe of k){const se=c[oe.provider];if(!se||se.length<=1){L.push({model:oe,key:null});continue}let ye=se.find(v=>v.active)??se[0];if($?.provider===oe.provider&&$.keyName){const v=se.find(ee=>ee.name===$.keyName);v&&(ye=v)}L.push({model:oe,key:ye})}return L},[k,c,$]),[Y,me]=l.useState(!1),de=t?.availableThinkingLevels&&t.availableThinkingLevels.length>0?new Set(t.availableThinkingLevels):null,w=zh.map(L=>({value:L,label:u(`thinking.${L}`),supported:de?de.has(L):!0})),I=L=>w.find(oe=>oe.value===L)?.label??L;return l.useEffect(()=>{g&&n.length===0&&!Y&&!a&&(me(!0),o({type:"list_models"}))},[g,n.length,Y,a,o]),l.useEffect(()=>{n.length>0&&me(!1)},[n.length]),l.useEffect(()=>{if(!g)return;H.current?.querySelector(".dd-item.active")?.scrollIntoView({block:"nearest"})},[g,E,n.length]),s.jsxs(s.Fragment,{children:[s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(_s,{}),s.jsx("span",{className:"chip-model",children:f?f.name:u("selectModel")}),!d&&f?.vision&&s.jsx("span",{className:"chip-vision",title:u("vision"),children:"🖼"}),!d&&f&&s.jsx("span",{className:"chip-sub",children:f.provider})]}),open:g,onOpenChange:y,menuClassName:"dd-menu-model",menuRef:Q,menuStyle:re!=null?{width:re}:void 0,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("availableModels")}),s.jsxs("div",{className:"dd-search-row",children:[s.jsx(Js,{}),s.jsx("input",{className:"dd-search",type:"text",placeholder:u("searchModels"),value:M,onChange:L=>z(L.target.value)})]}),s.jsxs("div",{className:"dd-model-body",children:[j.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:()=>C(null),children:s.jsx("span",{children:u("allProviders")})}),j.map(L=>{const oe=$?.provider===L.provider&&$?.keyName===L.keyName;return s.jsxs("button",{type:"button",className:`dd-provider-item ${oe?"active":""}`,onClick:()=>C(oe?null:{provider:L.provider,keyName:L.keyName}),title:L.keyName?`${L.provider} · ${L.keyName}`:`${L.provider} · ${L.count}`,children:[s.jsxs("span",{className:"dd-provider-txt",children:[s.jsx("span",{className:"dd-provider-name",children:L.provider}),L.keyName&&s.jsx("span",{className:"dd-provider-key",children:L.keyName})]}),s.jsx("span",{className:"dd-provider-count",children:L.count})]},L.keyName?`${L.provider}::${L.keyName}`:L.provider)})]}),s.jsxs("div",{className:"dd-model-scroll",ref:H,children:[(Y||a)&&s.jsx("div",{className:"dd-loading",children:u("loading")}),n.length===0&&!Y&&!a&&s.jsx("div",{className:"dd-loading",children:u("noModels")}),k.length===0&&n.length>0&&s.jsx("div",{className:"dd-loading",children:u("noModelMatches")}),Z.map(L=>{const oe=L.model,se=E===oe.id&&(!L.key||L.key.active);return s.jsx(nt,{active:se,onClick:()=>{L.key&&!L.key.active&&o({type:"activate_provider_key",provider:oe.provider,keyName:L.key.name}),E!==oe.id&&o({type:"set_model",modelId:oe.id}),y(!1)},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:oe.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:oe.provider}),s.jsx("span",{className:"dd-model-id",children:oe.id.split("/").slice(1).join("/")}),L.key&&s.jsxs("span",{className:`dd-model-key ${L.key.active?"active":""}`,children:[L.key.active?"●":"○"," ",L.key.name]}),(P[oe.id]??0)>0&&s.jsx("span",{className:"dd-model-usage",children:u("modelUsedCount",{n:P[oe.id]})}),(oe.reasoning||oe.vision)&&s.jsxs("span",{className:"dd-model-badges",children:[oe.reasoning&&s.jsx("span",{className:"dd-model-badge",children:u("reasoning")}),oe.vision&&s.jsx("span",{className:"dd-model-badge",children:u("vision")})]})]})]})},L.key?`${oe.id}::${L.key.name}`:oe.id)})]})]}),s.jsxs("div",{className:"dd-footer",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>o({type:"list_models"}),children:u("refreshModels")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{y(!1),i()},children:u("manageModels")})]})]}),s.jsxs(jt,{trigger:s.jsxs(s.Fragment,{children:[s.jsx(Hs,{}),s.jsx("span",{className:"chip-sub",children:u("thinkingChip",{level:t?I(t.thinkingLevel):"—"})})]}),open:N,onOpenChange:S,direction:"up",children:[s.jsx("div",{className:"dd-header",children:u("thinkingLevel")}),w.map(L=>s.jsx(nt,{active:t?.thinkingLevel===L.value,disabled:!L.supported,title:L.supported?void 0:u("thinkingUnsupported"),onClick:()=>{t?.thinkingLevel!==L.value&&o({type:"set_thinking",level:L.value}),S(!1)},children:L.label},L.value))]})]})}),Fi=Gh(),Qh=l.memo(function({ready:t,streaming:n,messages:a,slashCommands:o,modelState:i,models:c,modelsLoading:d,send:u,attachments:f,onRemoveAttachment:E,onAddImageFiles:g,onAddLocalFiles:y,onNotice:N,onSent:S,onManageModels:M,providerKeys:z,quickPhrases:$,quickPhrasesEnabled:C}){const P=Le(),{locale:B}=Mt(),{openPicker:H}=xo(),Q=b=>B!=="zh"&&b.descriptionEn?b.descriptionEn:b.description??"",re=b=>B!=="zh"&&b.argumentHintEn?b.argumentHintEn:b.argumentHint??"",[K,j]=l.useState(""),[X,k]=l.useState(!1),[Z,Y]=l.useState(null),[me,de]=l.useState(0),[w,I]=l.useState(!1),[L,oe]=l.useState(void 0),se=l.useRef(null),ye=l.useRef(null),v=l.useRef(null),ee=l.useRef(-1),ce=l.useRef(""),ae={builtin:P("slashBuiltin"),extension:P("slashExtension"),prompt:P("slashPrompt"),skill:P("slashSkill"),plugin:P("slashPlugin")},_=b=>{const J=b.match(/^\/([^\s]*)$/);if(J&&t){const le=J[1].toLowerCase(),be=o.filter(ke=>ke.name.toLowerCase().startsWith(le));Y(be.length>0?be:null),de(0)}else Y(null)};l.useEffect(()=>{v.current?.querySelector(".slash-item.active")?.scrollIntoView({block:"nearest"})},[me,Z]);const he=b=>{const J=Z??[],le=b??J[me%Math.max(J.length,1)];if(!le){Y(null);return}const be=K.match(/^\/([^\s]*)([\s\S]*)$/),ke=be?be[2]:"";j(`/${le.name} ${ke}`),Y(null),se.current?.focus()},F=async()=>{const le=[...a].reverse().find(be=>be.role==="assistant"&&be.content.some(ke=>ke.type==="text"&&ke.text))?.content.filter(be=>be.type==="text").map(be=>be.text).join(`
|
|
324
|
+
`);if(!le){N("warning",P("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(le),N("info",P("slashCopied"))}catch{N("error",P("slashCopyFailed"))}},pe=b=>{if(!b||b.length===0){N("warning",P("foldersNotSupported"));return}const J=Array.from(b).filter(ke=>vt(ke.type)),le=Array.from(b).filter(ke=>!vt(ke.type)),be=Oe();J.length>0&&be?N("warning",be):J.length>0&&g(J),le.length>0&&y(le)},Ee=b=>{const J=b.clipboardData?.items;if(!J)return;const le=[];for(const ke of J)if(ke.kind==="file"&&vt(ke.type)){const Ie=ke.getAsFile();Ie&&le.push(Ie)}if(le.length===0)return;b.preventDefault();const be=Oe();if(be){N("warning",be);return}g(le)},Oe=()=>{const b=i?.model;if(!b?.id)return null;const J=c.find(le=>le.id===b.id);return J&&J.vision===!1?P("modelNoVision",{name:J.name}):null},Se=t,U=l.useRef(K);l.useEffect(()=>{U.current=K},[K]),l.useEffect(()=>{_(U.current)},[o]),l.useEffect(()=>{const b=J=>{const le=J.detail;j(le),se.current?.focus()};return window.addEventListener("pi-web:fill",b),()=>window.removeEventListener("pi-web:fill",b)},[]),l.useEffect(()=>{if(!w)return;const b=J=>{J.key==="Escape"&&I(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[w]),l.useEffect(()=>{const b=se.current;if(!b)return;b.style.height="auto";const J=b.scrollHeight>220;b.style.height=`${Math.min(b.scrollHeight,220)}px`,b.style.overflowY=J?"auto":"hidden"},[K]);const ge=b=>b.selectionStart!==b.selectionEnd?!1:!b.value.slice(0,b.selectionStart).includes(`
|
|
325
|
+
`),ue=b=>b.selectionStart!==b.selectionEnd?!1:!b.value.slice(b.selectionStart).includes(`
|
|
326
|
+
`),ie=()=>f.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}:{}}),G=(b=!1)=>{const J=K.trim(),le=f.some(be=>be.imageData||be.fileData);if(!(!Se||!J&&!le)){if(J==="/help"){const be=se.current?.closest(".inputbox")?.getBoundingClientRect();oe(be?.width),I(!0),j(""),se.current?.focus();return}if(J==="/copy"){j(""),se.current?.focus(),F();return}if(u({type:"prompt",text:J,queue:b,attachments:ie()})){J&&Bi(J),ee.current=-1,ce.current="",j(""),S();const be=i?.model;be&&Mi(`${be.provider}/${be.id}`),se.current?.focus()}}},Te=b=>{const J=b.trim();if(!(!Se||!J)&&u({type:"prompt",text:J,attachments:ie()})){J&&Bi(J),ee.current=-1,ce.current="",S();const le=i?.model;le&&Mi(`${le.provider}/${le.id}`),Fi||se.current?.focus()}},Re=b=>{if(!b.nativeEvent.isComposing){if(Z&&Z.length>0)switch(b.key){case"ArrowDown":b.preventDefault(),de(J=>(J+1)%Z.length);return;case"ArrowUp":b.preventDefault(),de(J=>(J-1+Z.length)%Z.length);return;case"Tab":case"Enter":b.preventDefault(),he();return;case"Escape":b.preventDefault(),Y(null);return}if(b.key==="ArrowUp"||b.key==="ArrowDown"){if(b.ctrlKey||b.metaKey||b.altKey)return;const J=se.current;if(!J)return;const le=b.key==="ArrowUp";if(le&&!ge(J)||!le&&!ue(J)||!le&&ee.current===-1)return;const be=As();if(be.length===0)return;if(b.preventDefault(),le){if(ee.current===-1){ce.current=K;const ke=be.length-1;ee.current=ke;const Ie=be[ke];j(Ie),_(Ie),requestAnimationFrame(()=>{const Ae=se.current;Ae&&(Ae.selectionStart=Ae.selectionEnd=Ie.length)})}else if(ee.current>0){const ke=ee.current-1;ee.current=ke;const Ie=be[ke];j(Ie),_(Ie),requestAnimationFrame(()=>{const Ae=se.current;Ae&&(Ae.selectionStart=Ae.selectionEnd=Ie.length)})}}else{const ke=ee.current+1;if(ke<be.length){ee.current=ke;const Ie=be[ke];j(Ie),_(Ie),requestAnimationFrame(()=>{const Ae=se.current;Ae&&(Ae.selectionStart=Ae.selectionEnd=Ie.length)})}else{ee.current=-1;const Ie=ce.current;j(Ie),_(Ie),requestAnimationFrame(()=>{const Ae=se.current;Ae&&(Ae.selectionStart=Ae.selectionEnd=Ie.length)})}}return}if(b.key==="Escape"&&ee.current!==-1){b.preventDefault();const J=ce.current;ee.current=-1,j(J),_(J),requestAnimationFrame(()=>{const le=se.current;le&&(le.selectionStart=le.selectionEnd=J.length)});return}if(b.key==="Enter"){if(Fi&&!b.shiftKey&&!(b.ctrlKey||b.metaKey))return;b.shiftKey||(b.preventDefault(),G())}}},x=()=>s.jsx("div",{className:"inputbox-actions",children:n?s.jsxs(s.Fragment,{children:[K.trim()!==""&&s.jsxs("button",{type:"button",className:"btn supplement",title:P("supplementTip"),onClick:()=>G(!0),children:[s.jsx(Xs,{})," ",P("supplement")]}),s.jsx("button",{type:"button",className:"btn stop",title:P("stopAgent"),onClick:()=>u({type:"abort"}),children:s.jsx(Vs,{})})]}):s.jsx("button",{type:"button",className:"btn send",title:P("sendTip"),disabled:!Se||!K.trim()&&!f.some(b=>b.imageData||b.fileData),onClick:()=>G(),children:s.jsx(rr,{})})});return s.jsxs("div",{className:`inputbar${X?" drop-active":""}`,onDragOver:b=>{b.preventDefault(),b.stopPropagation(),k(!0)},onDragLeave:b=>{b.currentTarget.contains(b.relatedTarget)||k(!1)},onDrop:b=>{b.preventDefault(),b.stopPropagation(),k(!1),pe(b.dataTransfer?.files??null)},children:[X&&s.jsx("div",{className:"drop-overlay",children:s.jsxs("span",{children:["📎 ",P("dropHereToAttach")]})}),f.length>0&&s.jsxs("div",{className:"attach-row",children:[f.map(b=>s.jsxs("span",{className:`attach-chip ${b.imageData?"image":b.fileData?"file":b.mode}`,title:b.imageData?P("attachImage",{name:b.name}):b.fileData?P("attachFile",{name:b.name}):b.isDir?P("folderRef",{path:b.path}):b.mode==="reference"?P("refOnly",{path:b.path}):b.mode==="lines"&&b.lines?P("attachLines",{path:b.path,start:b.lines.start,end:b.lines.end}):P("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:P("removeAttachment"),onClick:()=>E(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:P("attachHint")})]}),Z&&Z.length>0&&s.jsxs("div",{className:"slash-menu",role:"listbox",ref:v,"aria-label":P("slashCommands"),children:[s.jsxs("div",{className:"slash-menu-hint",children:[s.jsx("span",{children:P("slashMenuHint")}),s.jsx("span",{className:"slash-menu-close",onClick:()=>Y(null),children:"Esc"})]}),Z.map((b,J)=>s.jsxs("button",{type:"button",className:`slash-item${J===me?" active":""}`,onMouseEnter:()=>de(J),onClick:()=>he(b),children:[s.jsxs("span",{className:"slash-name",children:["/",b.name]}),s.jsx("span",{className:`slash-source ${b.source}`,children:ae[b.source]}),s.jsxs("span",{className:"slash-desc",children:[Q(b),b.argumentHint&&s.jsx("span",{className:"slash-hint",children:re(b)})]})]},b.name))]}),w&&s.jsx("div",{className:"modal-backdrop",onClick:()=>I(!1),children:s.jsxs("div",{className:"slash-help",style:L?{width:L}:void 0,onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"slash-help-head",children:[s.jsxs("span",{children:["⚡ ",P("slashHelpTitle")]}),s.jsx("button",{type:"button",className:"btn",onClick:()=>I(!1),children:P("close")})]}),s.jsx("div",{className:"slash-help-body",children:o.length===0?s.jsx("div",{className:"slash-help-empty",children:P("slashLoading")}):o.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:ae[b.source]}),s.jsxs("span",{className:"slash-help-desc",children:[Q(b),b.argumentHint&&s.jsx("span",{className:"slash-hint",children:re(b)})]})]},b.name))})]})}),C&&$.length>0&&s.jsx("div",{className:"quick-row","aria-label":P("quickPhrases"),children:$.map(b=>s.jsx("button",{type:"button",className:"quick-chip",title:P("quickPhrasesTip",{text:b}),disabled:!Se,onClick:()=>Te(b),children:b},b))}),s.jsxs("div",{className:"inputbox",children:[s.jsx("input",{ref:ye,type:"file",multiple:!0,hidden:!0,onChange:b=>{pe(b.target.files),b.target.value=""}}),s.jsx("textarea",{ref:se,value:K,rows:1,placeholder:P(Se?n?"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!Se,onChange:b=>{ee.current=-1,j(b.target.value),_(b.target.value)},onKeyDown:Re,onPaste:Ee}),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:P("uploadFile"),disabled:!Se,onClick:()=>ye.current?.click(),children:s.jsx(Cl,{})}),s.jsx("button",{type:"button",className:"btn tpl-open",title:P("tpl.openPicker"),onClick:H,children:s.jsx(Ol,{})}),s.jsx(Vh,{state:i,models:c,modelsLoading:d,send:u,onManageModels:M,providerKeys:z,compact:!0})]}),s.jsx("div",{className:"composer-tools-right",children:x()})]})]})]})}),Xh=l.memo(function({goal:t,models:n,modelsLoading:a,activeConversationId:o,engine:i,send:c}){const d=Le(),{locale:u}=Mt(),f=u!=="zh"&&t.statusEn?t.statusEn:t.status||"",E=u!=="zh"&&t.wizard?.statusEn?t.wizard.statusEn:t.wizard?.status||"",g=i==="dsh",y=!t.conversationId||t.conversationId===o,N=t.goal!==null&&y,[S,M]=l.useState(""),[z,$]=l.useState(t.reviewModel??""),[C,P]=l.useState(t.maxRounds),[B,H]=l.useState(t.locked),[Q,re]=l.useState(!1),[K,j]=l.useState(!1),[X,k]=l.useState(!0);l.useEffect(()=>{$(t.reviewModel??""),P(t.maxRounds||0),H(t.locked)},[t.goal,t.reviewModel,t.maxRounds,t.locked]),l.useEffect(()=>{Q&&n.length===0&&!K&&!a&&(j(!0),c({type:"list_models"}))},[Q,n.length,K,a,c]),l.useEffect(()=>{n.length>0&&j(!1)},[n.length]);const Z=()=>z?n.find(w=>w.id===z)?.name??z:d("goalBarUseMainModel"),Y=()=>{const w=S.trim();w&&(c({type:"set_goal",goal:w,...z?{reviewModel:z}:{},maxRounds:C,locked:B}),M(""),k(!1))},me=()=>{const w=S.trim();w&&(c({type:"start_goal_wizard",text:w,...z?{wizardModel:z}:{},maxRounds:C,locked:B}),M(""),k(!1))},de=(t.wizard?.active??!1)&&y;return de?s.jsx("div",{className:`goalbar goalbar-active ${de?"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:[d("goalWizardRunning"),": ",t.wizard?.draft]}),s.jsxs("span",{className:"goalbar-chip reviewing",children:[d("goalBarRound",{n:(t.wizard?.step??0)+1})," / ",t.wizard?.maxSteps??6]}),s.jsx("span",{className:"goalbar-detail",children:E||d("goalBarReviewing")}),s.jsx("button",{type:"button",className:"goalbar-x",title:d("goalBarClear"),onClick:()=>{c({type:"clear_goal"}),k(!0)},children:s.jsx($e,{})})]})}):N?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:[d("goalBarReviewing")," ",d("goalBarRound",{n:t.round})]}):s.jsx("span",{className:`goalbar-chip ${t.verdict==="pass"?"pass":t.verdict==="fail"?"fail":""}`,children:t.verdict==="pass"?d("goalBarPassed"):t.verdict==="fail"?d("goalBarFailed"):`${d("goalBarRound",{n:t.round||1})} · ${t.locked?d("goalBarLocked"):d("goalBarUnlocked")}`}),s.jsx("span",{className:"goalbar-detail",children:f}),s.jsx("button",{type:"button",className:"goalbar-x",title:d("goalBarClear"),disabled:t.reviewing,onClick:()=>{c({type:"clear_goal"}),k(!0)},children:s.jsx($e,{})})]})}):X?s.jsx("div",{className:"goalbar goalbar-collapsed",children:s.jsxs("button",{type:"button",className:"goalbar-hint",title:d("goalBarPlaceholder"),onClick:()=>k(!1),children:[s.jsx(La,{})," ",s.jsx("span",{children:d("goalBarTitle")})]})}):s.jsxs("div",{className:"goalbar",children:[s.jsxs("div",{className:"goalbar-row",children:[s.jsx("span",{className:"goalbar-icon",children:s.jsx(La,{})}),s.jsx("input",{className:"goalbar-input",value:S,placeholder:d("goalBarPlaceholder"),onChange:w=>M(w.target.value),onKeyDown:w=>{w.key==="Enter"&&Y()}}),s.jsx("button",{type:"button",className:"goalbar-btn",disabled:!S.trim(),onClick:Y,children:d("goalBarSet")}),s.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!S.trim(),title:d("goalWizardTip"),onClick:me,children:["🔍 ",d("goalWizardBtn")]}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:d(B?"goalBarLocked":"goalBarUnlocked"),onClick:()=>H(w=>(c({type:"set_goal_prefs",locked:!w}),!w)),children:B?s.jsx(Ll,{}):s.jsx(yl,{})}),s.jsx("button",{type:"button",className:"goalbar-icon-btn",title:d("goalBarClear"),onClick:()=>k(!0),children:s.jsx(dn,{})})]}),s.jsxs("div",{className:"goalbar-opts",children:[g?s.jsx("p",{className:"goalbar-dsh-note",children:d("dshNoReviewModel")}):s.jsxs(jt,{trigger:s.jsxs("span",{className:"goalbar-opt",children:[d("goalBarReviewModel"),": ",s.jsx("b",{children:Z()})]}),open:Q,onOpenChange:re,direction:"up",children:[s.jsx("div",{className:"dd-header",children:d("goalBarReviewModel")}),(K||a)&&s.jsx("div",{className:"dd-loading",children:d("loading")}),n.length===0&&!K&&!a&&s.jsx("div",{className:"dd-loading",children:d("noModels")}),s.jsx(nt,{active:z==="",onClick:()=>{$(""),re(!1),c({type:"set_goal_prefs",reviewModel:""})},children:d("goalBarUseMainModel")}),n.map(w=>s.jsx(nt,{active:z===w.id,onClick:()=>{$(w.id),re(!1),c({type:"set_goal_prefs",reviewModel:w.id})},children:s.jsxs("span",{className:"dd-model-cell",children:[s.jsx("span",{className:"dd-model-name",children:w.name}),s.jsxs("span",{className:"dd-model-meta",children:[s.jsx("span",{className:"dd-model-provider",children:w.provider}),s.jsx("span",{className:"dd-model-id",children:w.id.split("/").slice(1).join("/")})]})]})},w.id)),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>c({type:"list_models"}),children:d("refreshModels")})]}),s.jsxs("label",{className:"goalbar-round",title:d("goalBarMaxRoundsTip"),children:[s.jsx("span",{children:d("goalBarMaxRounds")}),s.jsx("input",{type:"number",min:0,step:1,value:C,placeholder:d("goalBarUnlimitedShort"),onChange:w=>{const I=parseInt(w.target.value,10);if(Number.isNaN(I)||I<0){P(0);return}P(I)},onBlur:()=>c({type:"set_goal_prefs",maxRounds:C}),onKeyDown:w=>{w.key==="Enter"&&(c({type:"set_goal_prefs",maxRounds:C}),w.target.blur())}})]}),s.jsx("span",{className:"goalbar-lock-hint",children:d(B?"goalBarLocked":"goalBarUnlocked")})]})]})});function Jh(e){const t=Math.max(0,e.input??0),n=Math.max(0,e.cacheRead??0),a=Math.max(0,e.cacheWrite??0),o=t+n+a;return{totalInput:o,miss:t,read:n,write:a,hitRate:o>0?Math.min(n/o,1):0,writeRate:o>0?Math.min(a/o,1):0}}const Ao=2e3;function Zh(e,t,n=Ao){return e.filter(a=>t-a.t<=n)}function ef(e,t=Ao){if(e.length<2)return 0;const n=e[e.length-1],a=e.find(i=>i.t>=n.t-t)??e[0],o=(n.t-a.t)/1e3;return o<=0?0:Math.max(0,(n.out-a.out)/o)}function Hi(e){if(!e)return 0;let t=0;for(let a=0;a<e.length;a++){const o=e.charCodeAt(a);(o>=12352&&o<=12543||o>=13312&&o<=19903||o>=19968&&o<=40959||o>=63744&&o<=64255||o>=65280&&o<=65519||o===12288)&&t++}const n=e.length-t;return Math.round(t+n/4)}function tf(e){let t=0;for(const n of e)n.type==="text"&&typeof n.text=="string"&&n.text?t+=Hi(n.text):n.type==="thinking"&&typeof n.thinking=="string"&&n.thinking&&(t+=Hi(n.thinking));return t}const bt="@root";function sf({chat:e,send:t}){const n=Le(),a=e.state,[o,i]=l.useState(!1),[c,d]=l.useState(""),[u,f]=l.useState(""),[E,g]=l.useState(!1),[y,N]=l.useState(""),[S,M]=l.useState(-1),z=l.useRef(null),$=l.useRef(null),C=e.pathCompletions.filter(_=>_.type==="dir"),P=_=>_.endsWith("/")?_:_+"/",B=_=>{let he=_.endsWith("/")&&_!=="/"?_.slice(0,-1):_;if(he===bt||he==="/")return null;const F=he.lastIndexOf("/");if(F<0)return/^[A-Za-z]:$/.test(he)?bt:null;if(F===0)return"/";const pe=he.slice(0,F);return/^[A-Za-z]:$/.test(pe)?pe+"/":pe};l.useEffect(()=>{if(!o)return;const _=setTimeout(()=>{t({type:"complete_path",path:P(c)})},60);return()=>clearTimeout(_)},[c,o,t]),l.useEffect(()=>{if(!o||u===c)return;const _=setTimeout(()=>{t({type:"complete_path",path:u})},150);return()=>clearTimeout(_)},[u,c,o,t]);const H=l.useRef([]),Q=a?.isStreaming??!1,re=a?.streamingMessage?tf(a.streamingMessage.content):0;if(l.useEffect(()=>{if(!Q){H.current=[];return}const _=Date.now(),he=H.current,F=he[he.length-1];F&&_-F.t<250||(H.current=Zh([...he,{t:_,out:re}],_))},[Q,re]),!a)return null;const K=a.stats,j=Jh(K.tokens),X=j.hitRate*100,k=j.totalInput===0?"":j.hitRate>=.7?"ok":j.hitRate>=.4?"mid":"warn",Z=j.totalInput>0?`${X.toFixed(1)}%`:"—",Y=Q?ef(H.current):0,me=e.ready?"ok":"busy",de=e.ready?n("connected"):n("connecting"),w=K.contextUsage,I=w.tokens!==null&&w.percent!==null?`${w.estimated?"~":""}${Gt(w.tokens)} / ${Gt(w.contextWindow)}`:"—",L=w.percent??null,oe=L===null?"":L>=80?"warn":L>=50?"mid":"ok",se=a.queue.steering.length+a.queue.followUp.length,ye=()=>{const _=a.cwd.replace(/\\/g,"/");f(_),d(_),g(!1),N(""),i(!0)},v=_=>{const he=_.trim();he!==bt&&(he&&he!==a.cwd&&t({type:"set_cwd",path:he}),i(!1))},ee=()=>{const _=y.trim();_&&(t({type:"make_dir",path:`${P(c)}${_}`}),setTimeout(()=>{t({type:"complete_path",path:P(c)})},80),N(""),g(!1))},ce=_=>{if(_.key==="Escape")_.stopPropagation(),i(!1);else if(_.key==="Enter"&&!_.nativeEvent.isComposing)v(u);else if(_.key==="Tab"){if(C.length===0)return;_.preventDefault();const he=S>=0?(S+1)%C.length:0;M(he),f(C[he].path),d(C[he].path)}},ae=B(c);return s.jsxs("footer",{className:"statusbar",children:[s.jsx("span",{className:`status-dot ${me}`,title:de}),s.jsx("span",{className:"status-item",children:de}),s.jsx("span",{className:"status-sep",children:"·"}),e.engine&&e.engine!=="pi"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`status-item engine-badge engine-${e.engine}`,title:`${n("engineBadge")}: ${e.engine}`,children:e.engine==="dsh"?"DSH":e.engine}),s.jsx("span",{className:"status-sep",children:"·"})]}),s.jsxs("span",{className:"status-item status-ctx",title:n("contextUsage"),children:[s.jsx("span",{className:"ctx-label",children:n("context")}),s.jsx("span",{className:`ctx-bar ${oe}`,children:L!==null&&s.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min(L,100)}%`}})}),I]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:n("cumulativeCost"),children:["$",nf(K.cost)]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item status-cache",title:n("cacheHitTip",{read:Gt(j.read),write:Gt(j.write),miss:Gt(j.miss),input:Gt(j.totalInput)}),children:[n("cacheHit"),s.jsx("b",{className:`cache-pct ${k}`,children:Z})]}),s.jsx("span",{className:"status-sep",children:"·"}),s.jsxs("span",{className:"status-item",title:n("sessionMessages"),children:[n("messages")," ",K.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:n("pluginStatus"),children:e.statuses.map(_=>_.text).join(" · ")})]}),a.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"}),n("working"),se>0&&s.jsxs("span",{className:"status-queue",children:["⏳ ",se," ",n("queued")]})]}),s.jsxs("span",{className:"status-item status-rate",title:n("rateTip"),children:[s.jsx("span",{className:"working-spin rate-spin"}),Y>0?`${Math.round(Y)}${n("tps")}`:"…"]})]}),o?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"status-cwd-backdrop",onClick:()=>i(!1)}),s.jsxs("div",{className:"cwd-picker",children:[s.jsxs("div",{className:"cwd-picker-head",children:[s.jsxs("span",{className:"cwd-picker-title",title:c===bt?n("computer"):c,children:[c===bt?"💻":s.jsx(Pt,{}),s.jsx("span",{children:c===bt?n("computer"):c})]}),s.jsx("button",{type:"button",className:"cwd-up",disabled:c===bt,title:n("computer"),onClick:()=>{d(bt),f(bt),M(-1)},children:"💻"}),s.jsxs("button",{type:"button",className:"cwd-up",disabled:!ae,title:n("cwdGoUp"),onClick:()=>{ae&&(d(ae),f(ae),M(-1))},children:["↑ ",n("cwdGoUp")]})]}),s.jsxs("div",{className:"cwd-picker-row",children:[s.jsx("input",{ref:z,className:"status-cwd-input cwd-picker-input",value:u,placeholder:n("enterPath"),spellCheck:!1,onChange:_=>{f(_.target.value),M(-1)},onKeyDown:ce}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",title:n("cwdPickCurrent"),disabled:c===bt,onClick:()=>v(c),children:n("cwdPickCurrent")})]}),s.jsxs("div",{className:"cwd-list",children:[C.length===0&&s.jsx("div",{className:"cwd-empty",children:n("cwdEmpty")}),C.map(_=>s.jsxs("div",{className:"cwd-item",children:[s.jsxs("button",{type:"button",className:"cwd-enter",title:`${n("cwdEnter")} ${_.path}`,onClick:()=>{d(_.path),f(_.path),M(-1)},children:[s.jsx(Pt,{}),s.jsx("span",{className:"cwd-name",children:_.name})]}),s.jsx("button",{type:"button",className:"cwd-choose-btn",title:n("cwdChoose"),onClick:()=>v(_.path),children:n("cwdChoose")})]},_.path))]}),s.jsx("div",{className:"cwd-picker-foot",children:E?s.jsxs("div",{className:"cwd-newrow",children:[s.jsx("input",{ref:$,value:y,autoFocus:!0,spellCheck:!1,placeholder:n("cwdNewName"),onChange:_=>N(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing?(_.preventDefault(),ee()):_.key==="Escape"&&(_.stopPropagation(),g(!1),N(""))}}),s.jsx("button",{type:"button",className:"cwd-choose-btn primary",onClick:ee,children:n("cwdCreate")}),s.jsx("button",{type:"button",className:"cwd-choose-btn",onClick:()=>{g(!1),N("")},children:n("cwdCancel")})]}):s.jsxs("button",{type:"button",className:"cwd-newbtn",onClick:()=>g(!0),children:["+ ",n("cwdNewFolder")]})})]})]}):s.jsxs("button",{type:"button",className:"status-item status-cwd",title:n("cwdTip",{path:a.cwd}),onClick:ye,children:["📁 ",a.cwd]})]})}function Gt(e){return e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(e)}function nf(e){return e<=0?"0":e<1e-4?"<0.0001":e.toFixed(4).replace(/\.?0+$/,"")}function af({dialog:e,send:t}){const n=Le(),[a,o]=l.useState(""),[i,c]=l.useState(0),d=E=>{t({type:"dialog_response",id:e.id,value:E})};l.useEffect(()=>{o(""),c(0);const E=g=>{g.key==="Escape"&&d(null)};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[e.id]);const u=Array.isArray(e.args[0])?e.args[0]:[],f=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:n("pluginRequest")}),e.title&&e.title!==n("pluginRequest")&&s.jsx("span",{className:"dialog-title",children:e.title}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:()=>d(null),children:"✕"})]}),e.kind==="select"&&s.jsxs("div",{className:"dialog-options",children:[u.map((E,g)=>s.jsx("button",{type:"button",className:`dialog-option ${g===i?"sel":""}`,onMouseEnter:()=>c(g),onClick:()=>d(E),children:s.jsx(ot,{text:E,rawHtml:!0})},g)),u.length===0&&s.jsx("div",{className:"dialog-hint",children:n("noOptions")})]}),e.kind==="confirm"&&s.jsxs("div",{className:"dialog-body",children:[s.jsx(ot,{text:f,rawHtml:!0}),s.jsxs("div",{className:"dialog-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>d(!1),children:n("cancel")}),s.jsx("button",{type:"button",className:"btn primary",onClick:()=>d(!0),children:n("ok")})]})]}),e.kind==="input"&&s.jsxs("div",{className:"dialog-body",children:[s.jsx("input",{className:"dialog-input",value:a,placeholder:f||n("inputPlaceholder"),autoFocus:!0,onChange:E=>o(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.nativeEvent.isComposing&&d(a)}}),s.jsxs("div",{className:"dialog-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>d(null),children:n("cancel")}),s.jsx("button",{type:"button",className:"btn primary",onClick:()=>d(a),children:n("ok")})]})]})]})}function rf({question:e,send:t}){const n=Le(),[a,o]=l.useState({}),[i,c]=l.useState({}),[d,u]=l.useState(0),[f,E]=l.useState(()=>e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1);l.useEffect(()=>{o({}),c({}),u(0),E(e.deadline?Math.max(0,Math.ceil((e.deadline-Date.now())/1e3)):-1)},[e.id,e.deadline]),l.useEffect(()=>{if(!e.deadline)return;const B=setInterval(()=>{E(H=>{const Q=Math.max(0,Math.ceil((e.deadline-Date.now())/1e3));return Q<=0&&H>0&&t({type:"question_answer",id:e.id,answers:[],cancelled:!0}),Q})},1e3);return()=>clearInterval(B)},[e.id,e.deadline]),l.useEffect(()=>{const B=H=>{H.key==="Escape"&&S()};return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[e.id]);const g=e.questions.length,y=e.questions[d];if(!y)return null;const N=B=>{const H=e.questions.map(Q=>{const re=B[Q.id]??[],K=(i[Q.id]??"").trim();return{id:Q.id,selected:re,...K?{custom:K}:{}}});t({type:"question_answer",id:e.id,answers:H})},S=()=>{t({type:"question_answer",id:e.id,answers:[],cancelled:!0})},M=(B,H)=>{o(Q=>{const re=Q[B]??[];return{...Q,[B]:re.includes(H)?re.filter(K=>K!==H):[...re,H]}})},z=(B,H,Q)=>{if(Q){M(B,H);return}const re={...a,[B]:[H]};o(re),d===g-1?N(re):u(d+1)},$=()=>{d===g-1?N(a):u(d+1)},C=B=>(e.questions.find(Q=>Q.id===B)?.options?.length??0)===0?!0:(a[B]?.length??0)>0||(i[B]??"").trim()!=="",P=(y.options??[]).filter(B=>(a[y.id]??[]).includes(B.label)&&B.preview).map(B=>B.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:n("modelQuestion")}),g>1&&s.jsx("span",{className:"question-progress",children:n("questionStep",{cur:d+1,total:g})}),f>=0&&s.jsx("span",{className:"question-timer",children:f>0?n("questionTimeout",{s:f}):n("questionTimeoutExpired")}),s.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:S,children:"✕"})]}),s.jsxs("div",{className:"set-section",children:[s.jsx("div",{className:"set-section-title",children:y.header??`${n("modelQuestion")} ${d+1}`}),s.jsx("div",{className:"question-head",children:s.jsx(ot,{text:y.question,rawHtml:!0})}),y.detail&&s.jsx("div",{className:"set-hint",children:s.jsx(ot,{text:y.detail,rawHtml:!0})}),(y.options?.length??0)>0&&s.jsx("div",{className:"set-list",children:y.options.map(B=>{const H=(a[y.id]??[]).includes(B.label);return s.jsxs("button",{type:"button",className:`set-row question-option${H?" active":""}`,onClick:()=>z(y.id,B.label,!!y.multiSelect),children:[s.jsxs("div",{className:"set-row-name",children:[s.jsx("span",{className:"question-mark",children:y.multiSelect?H?"☑ ":"☐ ":H?"● ":"○ "}),s.jsx(ot,{text:B.label,rawHtml:!0})]}),B.description&&s.jsx("div",{className:"set-row-desc",children:s.jsx(ot,{text:B.description,rawHtml:!0})})]},B.label)})}),P.length>0&&s.jsxs("div",{className:"question-preview",children:[s.jsx("div",{className:"question-preview-label",children:n("optionPreview")}),P.map((B,H)=>s.jsx("div",{className:"question-preview-body",children:s.jsx(ot,{text:B,rawHtml:!0})},H))]}),s.jsx("input",{className:"set-prompt-input question-custom",placeholder:n("modelQuestionCustom"),value:i[y.id]??"",onChange:B=>c(H=>({...H,[y.id]:B.target.value})),onKeyDown:B=>{B.key==="Enter"&&(B.preventDefault(),C(y.id)&&$())}})]},y.id),s.jsxs("div",{className:"dialog-nav",children:[s.jsx("button",{type:"button",className:"dialog-dismiss-inline",onClick:S,children:n("cancel")}),s.jsxs("div",{className:"dialog-nav-right",children:[s.jsx("button",{type:"button",className:"dialog-prev",disabled:d===0,onClick:()=>u(d-1),children:n("previous")}),s.jsx("button",{type:"button",className:"dialog-submit",disabled:!C(y.id),onClick:$,children:d===g-1?n("modelQuestionSubmit"):n("next")})]})]})]})}const Ui=e=>`'${e.replace(/'/g,"'\\''")}'`;function of(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 lf({chat:e,send:t,terminal:n,active:a,onSwitchToTerminal:o}){const i=Le(),[c,d]=l.useState(null),[u,f]=l.useState([]),[E,g]=l.useState(""),[y,N]=l.useState(new Map),[S,M]=l.useState("changes"),[z,$]=l.useState([]),[C,P]=l.useState(null),[B,H]=l.useState(""),[Q,re]=l.useState(!1),[K,j]=l.useState(null),[X,k]=l.useState(null),[Z,Y]=l.useState(!1),[me,de]=l.useState(!1),[w,I]=l.useState(!1),[L,oe]=l.useState(null),[se,ye]=l.useState(!1),[v,ee]=l.useState(""),ce=l.useRef(0),ae=l.useRef(-1),_=l.useRef(-1),he=l.useRef(-1),F=l.useRef(-1),pe=l.useRef(void 0),Ee=l.useRef(null),Oe=l.useRef([]),Se=l.useCallback(D=>{if(D.reqId===ae.current){if(ae.current=-1,de(!1),oe(null),!D.ok){oe(D.error??i("scmQueryFailedShort"));return}if(D.notRepo){ye(!0),d(null),f([]),N(new Map),$([]),P(null),H(""),k(null);return}ye(!1);const we={branch:D.branch??"",detached:!!D.detached,upstream:D.upstream??null,ahead:D.ahead??0,behind:D.behind??0,upstreamGone:!!D.upstreamGone,files:(D.files??[]).map(De=>({...De}))},ve=(D.branches??[]).map(De=>({...De})),qe=new Map;for(const[De,Xe]of Object.entries(D.stats??{}))qe.set(De,{add:Xe[0],del:Xe[1]});d(we),f(ve),N(qe),g(De=>we.detached?De||"":we.branch&&ve.some(Xe=>Xe.name===we.branch)?we.branch:De&&ve.some(Xe=>Xe.name===De)?De:ve[0]?.name??""),k(De=>De&&!we.files.some(Xe=>Xe.path===De.file.path)?null:De)}else if(D.reqId===_.current){if(_.current=-1,Y(!1),!D.ok){oe(D.error??i("scmQueryFailedShort"));return}const we=Ee.current;if(!we)return;k({file:we,staged:D.stagedText??"",worktree:D.worktreeText??"",untracked:!1})}else if(D.reqId===F.current){if(F.current=-1,I(!1),!D.ok){oe(D.error??i("scmQueryFailedShort"));return}$((D.history??[]).map(we=>({...we})))}else if(D.reqId===he.current){if(he.current=-1,re(!1),!D.ok){oe(D.error??i("scmQueryFailedShort"));return}H(D.text??"")}},[]);l.useEffect(()=>{const D=e.scmData;D&&D.type==="scm_data"&&Se(D)},[e.scmData,Se]);const U=l.useCallback((D,we)=>{if(!e.ready||e.status!=="open")return!1;const ve=++ce.current;return t({...D,reqId:ve})?(we.current=ve,!0):(ce.current-=1,!1)},[e.ready,e.status,t]),ge=l.useCallback((D=!1,we=!1)=>{!e.ready||e.status!=="open"||e.state?.cwd&&(pe.current!==void 0&&pe.current!==e.state.cwd&&(d(null),f([]),N(new Map),$([]),I(!1),F.current=-1,P(null),H(""),k(null),j(null)),pe.current=e.state.cwd,oe(null),U({type:"scm_status"},ae)&&(we||de(!0)))},[e.ready,e.state?.cwd,e.status,U]),ue=l.useCallback(D=>{if(j(D),P(null),Ee.current=D,D.x==="?"&&D.y==="?"){k({file:D,staged:"",worktree:"",untracked:!0});return}Y(!0),oe(null),U({type:"scm_filediff",path:D.path},_)||Y(!1)},[U]),ie=l.useCallback(D=>{P(D),j(null),k(null),H(""),re(!0),oe(null),U({type:"scm_commit",hash:D.hash},he)||re(!1)},[U]),G=l.useCallback((D,we)=>{if(!e.ready)return;const ve={name:D,command:we,cwd:"${pwd}"};let qe;const De=e.terminals.find(Xe=>Xe.title===D);De?(n.restart(De.id),t({type:"run_command",terminalId:De.id,conversationId:De.conversationId,command:ve,cols:80,rows:24}),qe=De.id):(qe=_t(),n.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})),n.select(qe),o()},[e.ready,e.state?.cwd,e.terminals,o,t,n]),Te=l.useCallback(()=>{const D=v.trim();if(!D||se)return;const we=D.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");G("git commit",`git commit -m "${we}"`),ee("")},[v,se,G]),Re=l.useCallback(()=>{const D=v.trim();if(!D||se)return;const we=D.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");G("git commit",`git add -A && git commit -m "${we}"`),ee("")},[v,se,G]),x=l.useCallback(D=>{se||G("git add",`git add -- ${Ui(D.path)}`)},[se,G]),b=l.useCallback(D=>{se||G("git reset",`git reset HEAD -- ${Ui(D.path)}`)},[se,G]),J=l.useCallback(()=>{if(!E||se)return;const D=u.find(we=>we.name===E);if(D?.remote&&typeof D.remote=="string"){const we=E.slice(D.remote.length+1);G("git checkout",`git checkout -b ${we} ${E} || git checkout ${E}`)}else G("git checkout",`git checkout ${E}`)},[E,u,se,G]),le=l.useCallback(()=>G("git push","git push"),[G]),be=l.useCallback(()=>G("git pull","git pull"),[G]),ke=l.useCallback(()=>{U({type:"scm_history"},F)||(F.current=-1)},[U]);l.useEffect(()=>{a&&ge()},[a,ge]),l.useEffect(()=>{S==="history"&&c&&ke()},[S,c,ke]),l.useEffect(()=>{e.scmDirty>0&&a&&ge(!1,!0)},[e.scmDirty]),l.useEffect(()=>{if(!a||!e.ready||e.status!=="open")return;const D=setInterval(()=>{document.visibilityState!=="hidden"&&ge(!1,!0)},3e4);return()=>clearInterval(D)},[a,e.ready,e.status,ge]),l.useEffect(()=>{const D=Oe.current;if(Oe.current=e.terminals,!a)return;e.terminals.some(ve=>ve.running!==!1?!1:D.find(De=>De.id===ve.id)?.running===!0&&ve.title.startsWith("git "))&&e.ready&&e.status==="open"&&(ge(!1,!0),S==="history"&&c&&ke())},[e.terminals,a,e.ready,e.status,ge,S,c,ke]);const Ie={staged:i("scmStaged"),unstaged:i("scmUnstaged"),untracked:i("scmUntracked"),both:i("scmStagedUnstaged")},Ae=D=>{const we=D.split(`
|
|
327
|
+
`);return s.jsx("pre",{className:"scm-diff-pre",children:we.map((ve,qe)=>{let De="";return ve.startsWith("diff --git")||ve.startsWith("index ")||ve.startsWith("new file")||ve.startsWith("deleted file")||ve.startsWith("old mode")||ve.startsWith("new mode")||ve.startsWith("similarity index")||ve.startsWith("rename ")||ve.startsWith("copy ")||ve.startsWith("Binary files")||ve.startsWith("---")||ve.startsWith("+++")?De="hdr":ve.startsWith("@@")?De="hunk":ve.startsWith("+")?De="add":ve.startsWith("-")&&(De="del"),s.jsx("div",{className:`scm-diff-line ${De}`,children:ve||" "},qe)})})};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(Us,{}),i("scmTitle")]}),s.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[s.jsx("button",{type:"button",role:"tab","aria-selected":S==="changes",className:S==="changes"?"active":"",onClick:()=>{M("changes"),oe(null)},children:i("scmChanges")}),s.jsx("button",{type:"button",role:"tab","aria-selected":S==="history",className:S==="history"?"active":"",onClick:()=>{M("history"),oe(null)},children:i("scmHistory")})]}),s.jsx("button",{type:"button",className:"panel-refresh",title:i("scmRefreshTip"),disabled:me,onClick:()=>ge(!0),children:s.jsx(kt,{className:me?"scm-spin":""})})]}),s.jsxs("div",{className:"scm-row",children:[s.jsxs("span",{className:"scm-branch-current",title:i("scmCurrentBranch"),children:[s.jsx(Us,{}),c?c.detached?i("scmDetached"):c.branch:"…",c?.upstream&&s.jsx("span",{className:"scm-upstream",children:c.upstreamGone?i("scmUpstreamGone"):c.ahead>0||c.behind>0?i("scmAheadBehind",{ahead:c.ahead,behind:c.behind}):c.upstream})]}),s.jsxs("select",{className:"scm-select",value:E,disabled:se||u.length===0,title:i("scmSwitchBranch"),onChange:D=>g(D.target.value),children:[s.jsx("option",{value:"",disabled:!0,children:i("scmSelectBranch")}),u.filter(D=>!D.remote).map(D=>s.jsx("option",{value:D.name,children:D.current?`* ${D.name}`:D.name},D.name)),u.some(D=>D.remote)&&s.jsx("optgroup",{label:i("scmRemoteBranches"),children:u.filter(D=>D.remote).map(D=>s.jsx("option",{value:D.name,children:D.name},D.name))})]}),s.jsxs("button",{type:"button",className:"btn",disabled:!E||E===c?.branch||se,title:i("scmSwitchBranchTip",{branch:E}),onClick:J,children:[s.jsx(Us,{}),i("scmSwitch")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!c||c.detached||se,title:i("scmPushTip"),onClick:le,children:[s.jsx(rr,{}),i("scmPush")]}),s.jsxs("button",{type:"button",className:"btn",disabled:!c||c.detached||se,title:i("scmPullTip"),onClick:be,children:[s.jsx(or,{}),i("scmPull")]}),s.jsx("input",{className:"scm-commit-input",value:v,placeholder:i("scmCommitPlaceholder"),disabled:se,onChange:D=>ee(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.nativeEvent.isComposing&&Te()}}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!v.trim()||se,title:i("scmCommitTip"),onClick:Te,children:[s.jsx(Tt,{}),i("scmCommit")]}),s.jsx("button",{type:"button",className:"btn",disabled:!v.trim()||se,title:i("scmCommitAllTip"),onClick:Re,children:i("scmCommitAll")})]})]}),s.jsxs("div",{className:"scm-body",children:[S==="history"?s.jsxs("div",{className:"scm-history",children:[s.jsxs("div",{className:"scm-files-header",children:[s.jsx("span",{children:i("scmHistory")}),z.length>0&&s.jsx("span",{className:"scm-files-count",children:z.length})]}),s.jsx("div",{className:"scm-history-list",children:se?s.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):!c||w?s.jsx("div",{className:"scm-empty",children:e.status==="open"?i("scmLoading"):i("scmConnecting")}):z.length===0?s.jsx("div",{className:"scm-empty",children:i("scmNoHistory")}):z.map(D=>s.jsxs("button",{type:"button",className:`scm-commit ${C?.hash===D.hash?"active":""}`,onClick:()=>ie(D),title:D.hash,children:[s.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:D.graph||"* "}),s.jsxs("span",{className:"scm-commit-info",children:[s.jsx("span",{className:"scm-commit-subject",children:D.subject}),s.jsxs("span",{className:"scm-commit-meta",children:[D.shortHash," · ",D.author," · ",D.date]}),D.decorations&&s.jsx("span",{className:"scm-commit-refs",children:D.decorations})]})]},D.hash))})]}):s.jsxs("div",{className:"scm-files",children:[s.jsxs("div",{className:"scm-files-header",children:[s.jsx("span",{children:i("scmChanges")}),c&&c.files.length>0&&s.jsx("span",{className:"scm-files-count",children:c.files.length})]}),s.jsx("div",{className:"scm-files-list",children:se?s.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):c?c.files.length===0?s.jsx("div",{className:"scm-empty",children:i("scmNoChanges")}):c.files.map(D=>{const we=of(D),ve=y.get(D.path);return s.jsxs("div",{className:`scm-file ${K?.path===D.path?"active":""}`,title:Ie[we],onClick:()=>ue(D),children:[s.jsx("span",{className:`scm-file-xy ${we==="untracked"?"q":"x"}`,children:D.x!==" "?D.x:" "}),s.jsx("span",{className:`scm-file-xy ${we==="untracked"?"q":"y"}`,children:D.y!==" "?D.y:" "}),s.jsx("span",{className:"scm-file-path",children:D.path}),ve&&(ve.add>0||ve.del>0)&&s.jsxs("span",{className:"scm-file-stat",children:[ve.add>0&&s.jsxs("span",{className:"add",children:["+",ve.add]}),ve.del>0&&s.jsxs("span",{className:"del",children:["-",ve.del]})]}),s.jsxs("span",{className:"scm-file-actions",children:[(D.y!==" "||we==="untracked")&&s.jsx("button",{type:"button",className:"scm-act",title:i("scmStageTip",{path:D.path}),onClick:qe=>{qe.stopPropagation(),x(D)},children:"+"}),we==="staged"||we==="both"?s.jsx("button",{type:"button",className:"scm-act",title:i("scmUnstageTip",{path:D.path}),onClick:qe=>{qe.stopPropagation(),b(D)},children:"−"}):null]})]},D.path)}):s.jsx("div",{className:"scm-empty",children:e.status==="open"?i("scmLoading"):i("scmConnecting")})})]}),s.jsxs("div",{className:"scm-diff",children:[s.jsxs("div",{className:"scm-diff-header",children:[s.jsx("span",{children:S==="history"?C?`${C.shortHash} ${C.subject}`:i("scmCommitDetail"):K?K.path:i("scmDiff")}),(S==="history"?Q:Z)&&s.jsx("span",{className:"scm-diff-loading",children:i("scmLoading")})]}),s.jsx("div",{className:"scm-diff-body",children:S==="history"?s.jsxs(s.Fragment,{children:[L&&s.jsx("div",{className:"scm-error",children:L}),!C&&!L&&s.jsx("div",{className:"scm-empty",children:i("scmSelectCommitHint")}),C&&Q&&!L&&s.jsx("div",{className:"scm-empty",children:i("scmLoading")}),C&&!Q&&!L&&B?Ae(B):null]}):s.jsxs(s.Fragment,{children:[L&&s.jsx("div",{className:"scm-error",children:L}),!K&&!L&&s.jsx("div",{className:"scm-empty",children:i("scmSelectFileHint")}),K&&!X&&!L&&s.jsx("div",{className:"scm-empty",children:i("scmLoading")}),K&&X&&X.untracked&&s.jsx("div",{className:"scm-empty",children:i("scmUntrackedNote")}),K&&X&&!X.untracked&&s.jsxs(s.Fragment,{children:[X.staged&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:i("scmStaged")}),Ae(X.staged)]}),X.worktree&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"scm-diff-section",children:i("scmUnstaged")}),Ae(X.worktree)]}),!X.staged&&!X.worktree&&s.jsx("div",{className:"scm-empty",children:i("scmNoDiff")})]})]})})]})]}),s.jsxs("div",{className:"scm-hint",children:[s.jsx(Zt,{}),s.jsx("span",{children:i("scmRunsInTerminal")}),s.jsx("button",{type:"button",className:"scm-goto-term",onClick:o,children:i("scmViewTerminal")})]})]})}function cf({entry:e,send:t}){const n=l.useRef(null),a=Le();return l.useEffect(()=>{const o=n.current;if(!o)return;let i;try{i=e.module.mount(o,Lc(e.info.id,c=>t(c)))}catch(c){console.error(`[plugin:${e.info.id}] mount failed:`,c),o.textContent=a("pluginMountFailed",{name:e.info.name})}return()=>{if(typeof i=="function")try{i()}catch(c){console.error(`[plugin:${e.info.id}] cleanup failed:`,c)}o.textContent=""}},[e,t]),s.jsx("div",{className:"plugin-view",ref:n})}function uf({send:e,piConfigured:t,piAgentInstalled:n,managed:a,providers:o,installResult:i,onClose:c}){const d=Le(),[u,f]=l.useState(!1),[E,g]=l.useState(""),[y,N]=l.useState(""),[S,M]=l.useState(!1);l.useEffect(()=>{e({type:"list_providers"})},[e]),l.useEffect(()=>{t&&c()},[t,c]),l.useEffect(()=>{i&&f(!1)},[i]),l.useEffect(()=>{!E&&o.length>0&&g(o.find(H=>!H.configured)?.id??o[0].id)},[o,E]);const z=()=>{u||(f(!0),e({type:"install_pi_agent"}))},$=()=>{!y.trim()||S||(M(!0),e({type:"set_provider_api_key",provider:E.trim(),apiKey:y.trim()}),setTimeout(()=>M(!1),3e3))},C=()=>{e({type:"get_state"}),e({type:"list_providers"})},P=o.find(H=>H.id===E),B=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":d("close"),onClick:c,children:s.jsx($e,{})}),s.jsxs("div",{className:"modal-head",children:[s.jsx(_s,{className:"modal-head-icon"}),s.jsx("h2",{children:d("setupTitle")})]}),s.jsx("p",{className:"modal-desc",children:d("setupDesc")}),B?s.jsxs("div",{className:"setup-failed",children:[s.jsx("div",{className:"setup-done",children:d("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:z,children:d("retryInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]})]}):n||i?.ok?s.jsxs("div",{className:"setup-key-form",children:[s.jsx("div",{className:"setup-done",children:i?.ok?d("installDone"):d("cliReadyHint")}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("provider")}),s.jsxs("select",{value:E,onChange:H=>g(H.target.value),children:[o.length===0&&s.jsx("option",{value:"",children:d("loading")}),o.map(H=>s.jsxs("option",{value:H.id,children:[H.name,"(",H.id,")",H.configured?` · ${d("configured")}`:""]},H.id))]}),P?.configured&&s.jsx("div",{className:"field-hint",children:d("providerKeyReady")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKey")}),s.jsx("input",{type:"password",value:y,onChange:H=>N(H.target.value),placeholder:"sk-…"})]}),s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:!y.trim()||S||!E,onClick:$,children:d(S?"saving":"saveAndStart")}),s.jsxs("button",{type:"button",className:"btn",onClick:C,children:[s.jsx(kt,{})," ",d("recheck")]})]})]}):a?s.jsxs("div",{className:"setup-actions",children:[s.jsx("div",{className:"setup-done",children:d("updatesManaged")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]}):s.jsxs("div",{className:"setup-actions",children:[s.jsx("button",{type:"button",className:"btn primary",disabled:u,onClick:z,children:d(u?"installing":"autoInstall")}),s.jsx("button",{type:"button",className:"btn",onClick:c,children:d("skip")})]})]})})}const df=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],xa=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),mf=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[xa()]});function Ln(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:[xa()]).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 pf({send:e,providers:t,providerStatus:n,providerKeys:a,fetchModelsResult:o,cloneProviderResult:i,onClose:c}){const d=Le(),[u,f]=l.useState(null),[E,g]=l.useState({}),[y,N]=l.useState({}),[S,M]=l.useState(null),[z,$]=l.useState(!1),[C,P]=l.useState(0),[B,H]=l.useState(null),Q=l.useRef(0),[re,K]=l.useState(null),[j,X]=l.useState(""),[k,Z]=l.useState(null);l.useEffect(()=>{e({type:"list_models_config"}),e({type:"list_providers"}),e({type:"list_provider_keys"})},[e]);const Y=()=>{if(!u)return;const v=u.baseUrl.trim();if(!v){H({ok:!1,text:d("fetchModelsNeedBaseUrl")});return}if(z)return;$(!0),H(null);const ee=C+1;P(ee),e({type:"fetch_models",reqId:ee,baseUrl:v,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader,api:u.api})};l.useEffect(()=>{if(!(!o||o.reqId===Q.current))if(Q.current=o.reqId,$(!1),o.ok&&o.models?.length){const v=o.models;f(ee=>{if(!ee)return ee;const ce=ee.models.map(F=>{if(!F.id.trim())return F;const pe=v.find(Oe=>Oe.id===F.id.trim());if(!pe)return F;const Ee={...F};return!Ee.name&&pe.name&&(Ee.name=pe.name),!Ee.contextWindow&&pe.contextWindow&&(Ee.contextWindow=String(pe.contextWindow)),!Ee.maxTokens&&pe.maxTokens&&(Ee.maxTokens=String(pe.maxTokens)),Ee.input==="text"&&pe.input?.includes("image")&&(Ee.input="text-image"),!Ee.reasoning&&pe.reasoning&&(Ee.reasoning=!0),Ee}),ae=new Set(ce.map(F=>F.id.trim()).filter(Boolean)),_=v.filter(F=>!ae.has(F.id)).map(F=>({id:F.id,name:F.name??"",reasoning:F.reasoning??!1,input:F.input?.includes("image")?"text-image":"text",contextWindow:F.contextWindow?String(F.contextWindow):"",maxTokens:F.maxTokens?String(F.maxTokens):""})),he=[...ce,..._];return he.some(F=>F.id.trim())?{...ee,models:he.filter(F=>F.id.trim())}:ee}),H({ok:!0,text:d("fetchModelsOk",{n:v.length})})}else H({ok:!1,text:o.error||d("fetchModelsEmpty")})},[o]);const me=v=>{const ee=(E[v.id]??"").trim();!ee||S||(M(v.id),e({type:"add_provider_key",provider:v.id,apiKey:ee,name:(y[v.id]??"").trim()||void 0}),setTimeout(()=>{M(null),g(ce=>({...ce,[v.id]:""})),N(ce=>({...ce,[v.id]:""})),e({type:"list_providers"}),e({type:"list_provider_keys"})},1500))},de=(v,ee)=>{e({type:"activate_provider_key",provider:v,keyName:ee}),e({type:"list_provider_keys"})},w=(v,ee)=>{window.confirm(d("removeKeyConfirm"))&&(e({type:"remove_provider_key",provider:v,keyName:ee}),e({type:"list_provider_keys"}))},I=()=>{if(!k)return;const v=k.providerId.trim();if(!v||!k.apiKey.trim())return;const ee=k.models.filter(ae=>ae.id.trim()).map(ae=>({id:ae.id.trim(),name:ae.name.trim()||void 0,reasoning:ae.reasoning||void 0,input:ae.input==="text-image"?["text","image"]:void 0,contextWindow:ae.contextWindow?Number(ae.contextWindow):void 0,maxTokens:ae.maxTokens?Number(ae.maxTokens):void 0})),ce={providerId:v,name:k.name.trim()||void 0,api:k.api.trim()||void 0,baseUrl:k.baseUrl.trim()||void 0,apiKey:k.apiKey.trim()||void 0,authHeader:k.authHeader||void 0,models:ee};e({type:"save_model_config",providerId:v,config:ce}),Z(null),c()},L=()=>{if(!u)return;const v=u.providerId.trim(),ee=u.models.filter(ae=>ae.id.trim()).map(ae=>({id:ae.id.trim(),name:ae.name.trim()||void 0,reasoning:ae.reasoning||void 0,input:ae.input==="text-image"?["text","image"]:void 0,contextWindow:ae.contextWindow?Number(ae.contextWindow):void 0,maxTokens:ae.maxTokens?Number(ae.maxTokens):void 0})),ce={providerId:v,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:ee};e({type:"save_model_config",providerId:v,config:ce}),c()};l.useEffect(()=>{if(i&&i.ok){const v=i.configs;if(v&&v.length>1){K(v.map(ee=>Ln({...ee,apiKey:""}))),X("");return}if(i.config){Z(Ln({...i.config,apiKey:""}));return}}},[i]);const oe=v=>{window.confirm(d("clearKeyConfirm",{id:v}))&&e({type:"clear_provider_api_key",provider:v})},se=v=>{window.confirm(d("deleteProviderConfirm",{id:v.providerId,n:v.models.length}))&&e({type:"delete_model_config",providerId:v.providerId})},ye=(v,ee)=>{u&&f({...u,models:u.models.map((ce,ae)=>ae===v?{...ce,...ee}:ce)})};return s.jsx("div",{className:"modal-backdrop",onClick:c,children:s.jsxs("div",{className:"modal model-modal",onClick:v=>v.stopPropagation(),children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":d("close"),onClick:c,children:s.jsx($e,{})}),s.jsx("div",{className:"modal-head",children:s.jsx("h2",{children:k?d("addKey"):re?d("batchCreateProviders",{n:re.length}):d(u?"editProvider":"manageModelsTitle")})}),k?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:d("secondKeyTitle",{api:k.api,baseUrl:k.baseUrl||d("noBaseUrlShort"),n:k.models.length})}),s.jsxs("div",{className:"form-grid",children:[s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:[d("providerNameLabel")," ",s.jsx("em",{children:d("providerNameHint")})]}),s.jsx("input",{type:"text",value:k.providerId,onChange:v=>Z({...k,providerId:v.target.value}),placeholder:"opencode-2"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKeyLabel")}),s.jsx("input",{type:"password",value:k.apiKey,onChange:v=>Z({...k,apiKey:v.target.value}),placeholder:d("secondKeyPlaceholder")})]})]}),s.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:8},children:[k.models.slice(0,5).map(v=>v.id).join(", "),k.models.length>5?` … +${k.models.length-5}`:""]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>Z(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn",onClick:()=>{const v=k;Z(null),f(v)},children:d("advancedEdit")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!k.providerId.trim()||!k.apiKey.trim(),onClick:I,children:d("save")})]})]}):re?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:d("batchDesc",{apis:re.map(v=>v.api).join("、"),n:re.length})}),s.jsxs("label",{className:"field",style:{marginBottom:16},children:[s.jsx("span",{className:"field-label",children:d("batchKeyLabel",{n:re.length})}),s.jsx("input",{type:"password",value:j,onChange:v=>X(v.target.value),placeholder:d("secondKeyPlaceholder")})]}),s.jsx("div",{className:"provider-list",style:{marginBottom:16},children:re.map((v,ee)=>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:v.providerId}),s.jsx("span",{style:{opacity:.7},children:v.api})]}),s.jsxs("div",{className:"provider-sub",style:{fontSize:12,opacity:.7},children:[v.baseUrl||d("noBaseUrlShort")," · ",d("modelsCountShort",{n:v.models.length}),v.models.slice(0,3).map(ce=>ce.id).join(", "),v.models.length>3?` … +${v.models.length-3}`:""]}),s.jsx("input",{type:"text",value:v.providerId,onChange:ce=>K(ae=>ae.map((_,he)=>he===ee?{..._,providerId:ce.target.value}:_)),placeholder:d("providerIdPlaceholder"),style:{fontSize:12}}),s.jsx("input",{type:"text",value:v.baseUrl,onChange:ce=>K(ae=>ae.map((_,he)=>he===ee?{..._,baseUrl:ce.target.value}:_)),placeholder:d("baseUrlExamplePh"),style:{fontSize:12}})]},ee))})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>K(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!j.trim(),onClick:()=>{for(const v of re){const ee=v.providerId.trim();if(!ee)continue;const ce=v.models.filter(_=>_.id.trim()).map(_=>({id:_.id.trim(),name:_.name.trim()||void 0,reasoning:_.reasoning||void 0,input:_.input==="text-image"?["text","image"]:void 0,contextWindow:_.contextWindow?Number(_.contextWindow):void 0,maxTokens:_.maxTokens?Number(_.maxTokens):void 0})),ae={providerId:ee,name:v.name.trim()||void 0,api:v.api.trim()||void 0,baseUrl:v.baseUrl.trim()||void 0,apiKey:j.trim()||void 0,authHeader:v.authHeader||void 0,models:ce};e({type:"save_model_config",providerId:ee,config:ae})}K(null),c()},children:d("saveAllBatch",{n:re.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:[d("providerId")," ",s.jsx("em",{children:d("providerIdHint")})]}),s.jsx("input",{type:"text",value:u.providerId,disabled:t.some(v=>v.providerId===u.providerId),onChange:v=>f({...u,providerId:v.target.value}),placeholder:"my-proxy"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("displayName")}),s.jsx("input",{type:"text",value:u.name,onChange:v=>f({...u,name:v.target.value}),placeholder:d("displayNamePh")})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiType")}),s.jsx("select",{value:u.api,onChange:v=>f({...u,api:v.target.value}),children:df.map(v=>s.jsx("option",{value:v,children:v},v))})]}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{className:"field-label",children:["baseUrl ",s.jsx("em",{children:d("baseUrlHint")})]}),s.jsx("input",{type:"text",value:u.baseUrl,onChange:v=>f({...u,baseUrl:v.target.value}),placeholder:"http://localhost:11434/v1"})]}),s.jsxs("label",{className:"field",children:[s.jsx("span",{className:"field-label",children:d("apiKey")}),s.jsx("input",{type:"password",value:u.apiKey,onChange:v=>f({...u,apiKey:v.target.value}),placeholder:d("apiKeyHint")})]}),s.jsxs("label",{className:"field check",children:[s.jsx("input",{type:"checkbox",checked:u.authHeader,onChange:v=>f({...u,authHeader:v.target.checked})}),s.jsx("span",{children:d("authHeader")})]})]}),s.jsxs("div",{className:"model-section-head",children:[s.jsx("span",{className:"form-section-title",children:d("modelsTitle")}),s.jsxs("span",{className:"model-section-actions",children:[B&&s.jsx("span",{className:`fetch-msg ${B.ok?"ok":"err"}`,title:B.text,children:B.text}),s.jsxs("button",{type:"button",className:"btn sm",disabled:z||!u.baseUrl.trim(),title:d("fetchModelsHint"),onClick:Y,children:[s.jsx(Ht,{})," ",d(z?"fetchingModels":"fetchModels")]})]})]}),u.models.map((v,ee)=>s.jsxs("div",{className:"model-row",children:[s.jsx("input",{type:"text",value:v.id,onChange:ce=>ye(ee,{id:ce.target.value}),placeholder:d("modelIdReq")}),s.jsx("input",{type:"text",value:v.name,onChange:ce=>ye(ee,{name:ce.target.value}),placeholder:d("displayName")}),s.jsxs("select",{value:v.input,onChange:ce=>ye(ee,{input:ce.target.value}),children:[s.jsx("option",{value:"text",children:d("text")}),s.jsx("option",{value:"text-image",children:d("textImage")})]}),s.jsxs("label",{className:"check",children:[s.jsx("input",{type:"checkbox",checked:v.reasoning,onChange:ce=>ye(ee,{reasoning:ce.target.checked})}),s.jsx("span",{children:d("reasoning")})]}),s.jsx("input",{type:"number",value:v.contextWindow,onChange:ce=>ye(ee,{contextWindow:ce.target.value}),placeholder:d("contextWindow"),title:"contextWindow"}),s.jsx("input",{type:"number",value:v.maxTokens,onChange:ce=>ye(ee,{maxTokens:ce.target.value}),placeholder:d("maxOutput"),title:"maxTokens"}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("removeModel"),onClick:()=>f({...u,models:u.models.filter((ce,ae)=>ae!==ee)}),children:s.jsx(et,{})})]},ee)),s.jsxs("button",{type:"button",className:"btn",onClick:()=>f({...u,models:[...u.models,xa()]}),children:[s.jsx(dt,{})," ",d("addModel")]})]})}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:()=>f(null),children:d("cancel")}),s.jsx("button",{type:"button",className:"btn primary",disabled:!u.providerId.trim()||!u.models.some(v=>v.id.trim()),onClick:L,children:d("save")})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"model-modal-fixed-hint",children:s.jsxs("div",{className:"form-section-title",children:[d("builtinProviders")," ",s.jsx("em",{className:"section-hint",children:d("hintKeyOnly")})]})}),s.jsxs("div",{className:"model-modal-body",children:[s.jsxs("div",{className:"provider-list",children:[n.length===0&&s.jsx("div",{className:"dd-loading",children:d("loading")}),n.map(v=>{const ee=a[v.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:v.name}),s.jsxs("span",{className:"provider-sub",children:[v.id,v.configured&&s.jsx("span",{className:"auth-badge",children:d("configuredBadge")}),v.source&&!v.configured&&s.jsx("span",{className:"auth-badge dim",children:v.source})]})]}),v.source==="stored"&&s.jsxs("button",{type:"button",className:"btn sm danger",title:d("clearKeyTitle"),onClick:()=>oe(v.id),children:[s.jsx(et,{})," ",d("clearKey")]})]}),s.jsxs("div",{className:"provider-keys",children:[ee.length===0&&s.jsx("div",{className:"provider-key-empty",children:d("noKeyYet")}),ee.map(ce=>s.jsxs("div",{className:`provider-key-item ${ce.active?"active":""}`,children:[s.jsx("span",{className:"provider-key-dot",children:ce.active?"●":"○"}),s.jsx("span",{className:"provider-key-label",children:ce.name}),!ce.active&&s.jsx("button",{type:"button",className:"iconbtn",title:d("activateKey"),onClick:()=>de(v.id,ce.name),children:s.jsx(Tt,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("removeKey"),onClick:()=>w(v.id,ce.name),children:s.jsx(et,{})})]},ce.name)),s.jsxs("div",{className:"provider-add-key",children:[s.jsx("input",{type:"text",className:"key-input key-input-name",placeholder:d("keyNamePh"),value:y[v.id]??"",onChange:ce=>N(ae=>({...ae,[v.id]:ce.target.value}))}),s.jsx("input",{type:"password",className:"key-input key-input-value",placeholder:d("addKeyPlaceholder"),value:E[v.id]??"",onChange:ce=>g(ae=>({...ae,[v.id]:ce.target.value}))}),s.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(E[v.id]??"").trim()||S===v.id,onClick:()=>me(v),children:[s.jsx(dt,{})," ",S===v.id?d("savingKey"):d("addKey")]})]})]})]},v.id)})]}),s.jsx("div",{className:"form-section-title",children:d("customProviders")}),s.jsx("p",{className:"modal-desc",children:d("customDesc")}),s.jsx("p",{className:"modal-desc",children:d("reloadModelsHint")}),t.length===0&&s.jsx("div",{className:"dd-loading",children:d("noCustomProviders")}),s.jsx("div",{className:"provider-list",children:t.map(v=>s.jsxs("div",{className:"provider-row",children:[s.jsxs("div",{className:"provider-info",children:[s.jsx("span",{className:"provider-name",children:v.providerId}),s.jsxs("span",{className:"provider-sub",children:[v.api??"—",v.baseUrl?` · ${v.baseUrl}`:"",v.models.length>0&&` · ${d("modelsCount",{n:v.models.length})}`]})]}),s.jsxs("div",{className:"provider-actions",children:[s.jsx("button",{type:"button",className:"iconbtn",title:d("edit"),onClick:()=>f(Ln(v)),children:s.jsx(en,{})}),s.jsx("button",{type:"button",className:"iconbtn danger",title:d("delete"),onClick:()=>se(v),children:s.jsx(et,{})})]})]},v.providerId))})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsxs("button",{type:"button",className:"btn",onClick:()=>e({type:"reload_models_config"}),children:[s.jsx(kt,{})," ",d("reloadModelsConfig")]}),s.jsxs("button",{type:"button",className:"btn primary",onClick:()=>f(mf()),children:[s.jsx(dt,{})," ",d("addProvider")]})]})]})]})})}function hf({plugin:e,send:t}){const n=Le(),a=e.settingsSchema??[],[o,i]=l.useState(()=>({...e.settingsValues})),[c,d]=l.useState(!1);if(a.length===0)return null;const u=(y,N)=>i(S=>({...S,[y]:N})),f=a.some(y=>o[y.key]!==e.settingsValues?.[y.key]),E=()=>{d(!0),t({type:"plugin_settings",pluginId:e.id,values:o}),setTimeout(()=>d(!1),800)},g=()=>i({...e.settingsValues});return s.jsxs("div",{className:"plugin-settings-form",children:[s.jsx("div",{className:"plugin-settings-fields",children:a.map(y=>s.jsxs("label",{className:"plugin-settings-field",title:y.hint,children:[s.jsx("span",{className:"plugin-settings-label",children:y.label}),y.type==="boolean"?s.jsx("input",{type:"checkbox",checked:!!o[y.key],onChange:N=>u(y.key,N.target.checked)}):y.type==="select"?s.jsx("select",{value:String(o[y.key]??""),onChange:N=>u(y.key,N.target.value),children:(y.options??[]).map(N=>s.jsx("option",{value:N,children:N},N))}):s.jsx("input",{type:y.type==="password"?"password":y.type==="number"?"number":"text",value:String(o[y.key]??""),min:y.min,max:y.max,onChange:N=>u(y.key,y.type==="number"?Number(N.target.value):N.target.value)})]},y.key))}),s.jsxs("div",{className:"plugin-settings-actions",children:[s.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!f||c,onClick:E,children:n(c?"pluginSettingsSaving":"pluginSettingsSave")}),s.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:g,children:n("pluginSettingsReset")})]})]})}const wo="pi-web-ui:wide-chat",on={wide:!1};function Io(e){if(!e||typeof e!="object")return{...on};const t=e;return{wide:typeof t.wide=="boolean"?t.wide:on.wide}}function ff(){try{const e=localStorage.getItem(wo);return e?Io(JSON.parse(e)):{...on}}catch{return{...on}}}function gf(e){const t=Io(e);try{localStorage.setItem(wo,JSON.stringify(t))}catch{}Ws=t;for(const n of sa)n()}let Ws=null;const sa=new Set;function bf(e){return sa.add(e),()=>{sa.delete(e)}}function Ef(){return Ws||(Ws=ff()),Ws.wide}function jo(){return l.useSyncExternalStore(bf,Ef)}const Lo="pi-web-ui:project-title",ln={projectName:!0};function Ro(e){if(!e||typeof e!="object")return{...ln};const t=e;return{projectName:typeof t.projectName=="boolean"?t.projectName:ln.projectName}}function Tf(e){return e?e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"":""}function xf(){try{const e=localStorage.getItem(Lo);return e?Ro(JSON.parse(e)):{...ln}}catch{return{...ln}}}function yf(e){const t=Ro(e);try{localStorage.setItem(Lo,JSON.stringify(t))}catch{}Ks=t;for(const n of na)n()}let Ks=null;const na=new Set;function Nf(e){return na.add(e),()=>{na.delete(e)}}function kf(){return Ks||(Ks=xf()),Ks.projectName}function Po(){return l.useSyncExternalStore(Nf,kf)}const Do="pi-web-ui:wallpaper",vf="has-wallpaper",vs={url:"",dim:78,blur:0},Cf=2e3,_f=28e5;function aa(e){if(typeof e!="string")return"";const t=e.trim();if(!t)return"";const n=t.toLowerCase().startsWith("data:image/")?_f:Cf;return t.length>n?"":/^https?:\/\//i.test(t)||/^blob:/i.test(t)||/^data:image\//i.test(t)||t.startsWith("/")&&!t.startsWith("//")?t:""}const qi=(e,t,n,a)=>typeof e!="number"||!Number.isFinite(e)?a:Math.min(n,Math.max(t,Math.round(e)));function Oo(e){if(!e||typeof e!="object")return{...vs};const t=e;return{url:aa(t.url),dim:qi(t.dim,0,95,vs.dim),blur:qi(t.blur,0,24,vs.blur)}}function Mo(){try{const e=localStorage.getItem(Do);return e?Oo(JSON.parse(e)):{...vs}}catch{return{...vs}}}function Sf(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/[\r\n]/g,"")}async function Af(e){const t=await Ea(e);return t?`data:${t.mimeType};base64,${t.data}`:null}function Ys(){const e=Cs??Mo(),t=document.documentElement;e.url?(t.style.setProperty("--bg-image",`url("${Sf(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(vf,e.url!==""||n!==""&&n!=="none")}function ms(e){const t=Oo(e);Cs=t;try{localStorage.setItem(Do,JSON.stringify(t))}catch{}for(const n of ia)n();Ys()}let Cs=null;const ia=new Set;function wf(e){return ia.add(e),()=>{ia.delete(e)}}function If(){return Cs||(Cs=Mo()),Cs}function Bo(){return l.useSyncExternalStore(wf,If)}function jf(){const e=Bo();l.useEffect(()=>{Ys()},[e]),l.useEffect(()=>{const t=()=>Ys();return window.addEventListener(Rt,t),Ys(),()=>window.removeEventListener(Rt,t)},[])}const cn={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"]},ra=["soul","tools","guidelines","pi_docs","append","persona","terminal","markers","context","skills","cwd"],Lf=["tools","pi_docs","persona","terminal","markers","context","skills","cwd"];function Rf(e){return Lf.includes(e)}const Fs=ra.map(e=>`{{${e}}}`).join(`
|
|
328
|
+
|
|
329
|
+
`);function Pf(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ft({text:e}){const t=l.useRef(null),[n,a]=l.useState(!1),o=()=>{const i=t.current?.getBoundingClientRect();i&&a(window.innerWidth-i.right<340)};return s.jsxs("span",{ref:t,className:`set-tip${n?" flip":""}`,tabIndex:0,"aria-label":e,onMouseEnter:o,onFocus:o,children:["?",s.jsx("span",{className:"set-tip-bubble",role:"tooltip",children:e})]})}function ze({title:e,subtitle:t,tip:n,enabled:a,onToggle:o,action:i}){const c=Le();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(ft,{text:n})]}),t&&s.jsx("div",{className:"set-row-desc",children:t})]}),i,s.jsx("button",{type:"button",className:`set-switch ${a?"on":""}`,role:"switch","aria-checked":a,title:c(a?"settingsEnabled":"settingsDisabled"),onClick:o,children:s.jsx("span",{className:"set-switch-knob"})})]})}function Df({chat:e,send:t,terminal:n,onSwitchToTerminal:a,onClose:o}){const i=Le(),{locale:c}=Mt(),d=m=>i(m),u=e.settings,f=e.engine==="dsh",[E,g]=l.useState("prompt"),y=l.useRef(null);l.useEffect(()=>{y.current?.scrollTo({top:0})},[E]),l.useEffect(()=>{E==="plugins"&&e.engine==="dsh"&&t({type:"dsh_patches_list"})},[E,e.engine,t]);const[N,S]=l.useState(""),[M,z]=l.useState({}),$=l.useRef(!1),C=l.useRef(null),[P,B]=l.useState(null),[H,Q]=l.useState({}),[re,K]=l.useState(""),[j,X]=l.useState("append"),k=l.useRef(!1),[Z,Y]=l.useState(""),me=l.useRef(!1),[de,w]=l.useState(""),[I,L]=l.useState(null),[oe,se]=l.useState(null),[ye,v]=l.useState(!1),ee=jo(),ce=Po(),ae=Bo(),[_,he]=l.useState(ae.url),F=l.useRef(!1),pe=l.useRef(null),[Ee,Oe]=l.useState(!1),[Se,U]=l.useState(!1);l.useEffect(()=>{F.current||he(ae.url.startsWith("data:")?"":ae.url)},[ae.url]);const ge=async m=>{const ne=m.target.files?.[0];if(m.target.value="",!!ne){Oe(!0),U(!1);try{const Ne=await Af(ne),Ge=Ne?aa(Ne):"";if(!Ge){U(!0);return}he(""),ms({...ae,url:Ge})}finally{Oe(!1)}}},[ue,ie]=l.useState(()=>_o()),[G,Te]=l.useState(()=>{try{return As().length}catch{return 0}}),[Re,x]=l.useState(!1),b=()=>{try{Te(As().length)}catch{Te(0)}};l.useEffect(()=>{E==="prompt-history"&&b()},[E]),l.useEffect(()=>{if(!Re)return;const m=window.setTimeout(()=>x(!1),3e3);return()=>window.clearTimeout(m)},[Re]);const[J,le]=l.useState(null),[be,ke]=l.useState(null),[Ie,Ae]=l.useState(""),[D,we]=l.useState(""),[ve,qe]=l.useState(""),[De,Xe]=l.useState(""),[mt,St]=l.useState(""),[os,xt]=l.useState(!1),[lt,At]=l.useState(""),[R,W]=l.useState(null);l.useEffect(()=>{u&&($.current||S(u.promptTemplate??""),z(m=>{const ne={};for(const[Ne,Ge]of Object.entries(u.promptOverrides??{}))ne[Ne]=Ge??"";return C.current&&(ne[C.current]=m[C.current]??""),ne}),X(u.visionBridgePromptMode),!k.current&&(K(j==="append"||u.visionBridgePrompt?u.visionBridgePrompt:u.visionBridgeDefaultPrompt||""),me.current||Y(u.reviewPrompt)))},[u,j]);const[_e,Ce]=l.useState(String(u?.terminalBashIdleMs??15e3));l.useEffect(()=>{Ce(String(u?.terminalBashIdleMs??15e3))},[u?.terminalBashIdleMs]);const[Be,Fe]=l.useState(String(u?.retryMaxAttempts??6));if(l.useEffect(()=>{Fe(String(u?.retryMaxAttempts??6))},[u?.retryMaxAttempts]),!u)return null;const it=[{id:"prompt",icon:s.jsx(nr,{}),label:i("settingsSystemPrompt")},{id:"prompt-history",icon:s.jsx(Bn,{}),label:i("settingsPromptHistory"),count:G},{id:"terminal",icon:s.jsx(Zt,{}),label:i("settingsTerminalTools")},{id:"question",icon:s.jsx(Pa,{}),label:i("settingsQuestionnaire")},...f?[]:[{id:"edit",icon:s.jsx(Xt,{}),label:i("settingsEditTools")}],{id:"display",icon:s.jsx(es,{}),label:i("settingsMessageDisplay")},{id:"quick",icon:s.jsx(Xs,{}),label:i("quickPhrases"),count:u.quickPhrases.length},{id:"markers",icon:s.jsx(Ra,{}),label:i("settingsMarkers"),count:u.markers?.length??0},{id:"skills",icon:s.jsx(_s,{}),label:i("settingsSkills"),count:u.skills.length},{id:"extensions",icon:s.jsx(En,{}),label:i("settingsExtensions"),count:u.extensions.length},{id:"plugins",icon:s.jsx(Tn,{}),label:i("settingsUiPlugins"),count:e.plugins.length},{id:"review",icon:s.jsx(Hs,{}),label:i("settingsReview"),count:u.reviewSkills.length},...f?[]:[{id:"vision",icon:s.jsx(Mn,{}),label:i("settingsVisionBridge")}],{id:"presets",icon:s.jsx(kl,{}),label:i("settingsPresets"),count:u.presets.length},...f?[]:[{id:"subagent-templates",icon:s.jsx(ja,{}),label:i("settingsSubagentTemplates"),count:u.subagentTemplates.length}]],yt=new Set(u.disabledSkills),Rs=new Set(u.disabledExtensions),Me=m=>t({type:"set_settings",...m}),Kt=()=>{if(!R||!u)return;const m=R.value.trim(),ne=R.index;if(W(null),!m||m===u.quickPhrases[ne])return;const Ne=[...u.quickPhrases];Ne[ne]=m,Me({quickPhrases:Ne})},q=m=>{const ne=new Set(yt);ne.has(m.name)?ne.delete(m.name):ne.add(m.name),Me({disabledSkills:[...ne]})},xe=new Set(u.disabledPlugins??[]),je=new Set(e.plugins.map(m=>m.id)),Ke=m=>{const ne=new Set(xe);ne.has(m.id)?ne.delete(m.id):ne.add(m.id),Me({disabledPlugins:[...ne]})},Ye=m=>{const ne=new Set(Rs);ne.has(m.id)?ne.delete(m.id):ne.add(m.id),Me({disabledExtensions:[...ne]})},rt=u.markersEnabled??!0,Je=new Set(u.disabledMarkers??[]),pt=m=>{const ne=new Set(Je);!ne.has(m)?ne.add(m):ne.delete(m),Me({disabledMarkers:[...ne]})},Ps=(m,ne)=>{const Ne={name:m,command:ne,cwd:"${pwd}"};let Ge;const ct=e.terminals.find(He=>He.title===m);ct?(n.restart(ct.id),t({type:"run_command",terminalId:ct.id,conversationId:ct.conversationId,command:Ne,cols:80,rows:24}),Ge=ct.id):(Ge=_t(),n.create({id:Ge,conversationId:e.activeConversationId||e.state?.conversationId||"",title:m,cwd:e.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:Ne})),n.select(Ge),a(),o()},Ko=m=>{le(null),Ps(`${i("uninstallTitle")} ${m}`,`pi remove npm:${m}`)},ya=m=>{ke(null),Ps(`${i("uninstallTitle")} ${m}`,`pi-web-ui uninstall ${m}`)},Na=(m,ne)=>{Ps(`${i("pluginUpdate")} ${m}`,`pi-web-ui install ${ne} --name ${m} --force`)},Yo=m=>{Ps(`${i("pluginInstall")} ${m.id}`,`pi-web-ui install ${m.source} --name ${m.id}`)},Go=m=>{t({type:"plugin_catalog_remove",id:m})},zo=()=>{const m=Ie.trim();m&&(t({type:"plugin_catalog_add",entry:{source:m,...D.trim()?{id:D.trim()}:{},...ve.trim()?{name:ve.trim()}:{},...De.trim()?{description:De.trim()}:{},...mt.trim()?{icon:mt.trim()}:{}}}),Ae(""),we(""),qe(""),Xe(""),St(""),xt(!1))},Vo=m=>{const ne=new Set(u.reviewSkills.filter(Ne=>!Ne.enabled).map(Ne=>Ne.name));ne.has(m.name)?ne.delete(m.name):ne.add(m.name),Me({reviewDisabledSkills:[...ne]})},Qo=()=>Me({promptTemplate:N}),Xo=m=>{Me({promptOverrides:{[m]:M[m]??""}})},gn=m=>{C.current===m&&(C.current=null),B(null),z(ne=>{const Ne={...ne};return delete Ne[m],Ne}),Me({promptOverrides:{[m]:""}})},ls=m=>Q(ne=>({...ne,[m]:!ne[m]})),bn=(m,ne)=>{z(Ne=>({...Ne,[m]:ne})),B(m)},Jo=()=>{$.current=!1,C.current=null,S(Fs),z({}),Me({promptTemplate:Fs,promptOverrides:{}})},Zo=m=>{S(ne=>ne.trim()?`${ne}
|
|
330
|
+
|
|
331
|
+
{{${m}}}`:`{{${m}}}`)},el=N.trim()&&N.trim()!==Fs||Object.values(M).some(m=>m.trim());return s.jsx("div",{className:"modal-backdrop",onClick:o,children:s.jsxs("div",{className:"modal settings-modal",onClick:m=>m.stopPropagation(),children:[s.jsx("button",{type:"button",className:"modal-close","aria-label":i("close"),onClick:o,children:s.jsx($e,{})}),s.jsxs("div",{className:"modal-head",children:[s.jsx(Qs,{className:"modal-head-icon"}),s.jsx("h2",{children:i("settingsTitle")}),s.jsx(ft,{text:i("settingsDesc")})]}),s.jsxs("div",{className:"settings-layout",children:[s.jsx("nav",{className:"settings-rail","aria-label":i("settingsTitle"),children:it.map(m=>s.jsxs("button",{type:"button",className:`settings-tab${E===m.id?" active":""}`,"aria-current":E===m.id?"true":void 0,title:m.label,onClick:()=>g(m.id),children:[s.jsx("span",{className:"settings-tab-icon",children:m.icon}),s.jsx("span",{className:"settings-tab-label",children:m.label}),m.count!==void 0&&s.jsx("span",{className:"set-count",children:m.count})]},m.id))}),s.jsxs("div",{className:"modal-body",ref:y,children:[E==="prompt"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Hs,{className:"set-section-icon"}),i("settingsSystemPrompt"),s.jsx(ft,{text:i("promptComposeHint")})]}),s.jsx("p",{className:"set-hint",children:i("promptComposeDesc")}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",children:i("promptTemplateLabel")}),s.jsx("textarea",{className:"set-prompt-input",rows:8,spellCheck:!1,placeholder:Fs,value:N,onFocus:()=>$.current=!0,onBlur:()=>{$.current=!1,Qo()},onChange:m=>S(m.target.value)}),s.jsxs("div",{className:"compose-toolbar",children:[s.jsx("span",{className:"set-field-label set-muted",children:i("promptInsertTokens")}),ra.map(m=>s.jsx("button",{type:"button",className:"token-chip",title:d(`promptTok_${m}_desc`),onClick:()=>Zo(m),children:`{{${m}}}`},m))]})]}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",children:i("promptSourcesLabel")}),ra.map(m=>{const ne=M[m]??"",Ne=u.promptSourceDefaults?.[m]??"",Ge=P===m,ct=Ne.split(`
|
|
332
|
+
`).length>6||Ne.length>480;if(Rf(m)){const He=ne.trim()?ne:Ne;return s.jsxs("div",{className:"override-row readonly",children:[s.jsxs("div",{className:"override-row-head",children:[`{{${m}}}`,s.jsxs("span",{className:"set-muted",children:[d(`promptTok_${m}`)," — ",d(`promptTok_${m}_desc`)]}),ne.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",title:i("promptReadonlyLockedHint"),onClick:()=>gn(m),children:i("promptResetSource")}):s.jsx("span",{className:"set-muted",children:i("promptReadonlyBadge")})]}),s.jsx("div",{className:`source-default readonly${He.trim()?"":" empty"}`,title:i("promptReadonlyTitle"),children:He.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ct?H[m]?" expanded":" clamped":""}`,children:He}),ct&&s.jsx("span",{className:"source-default-toggle",role:"button",tabIndex:0,onClick:tt=>{tt.stopPropagation(),ls(m)},onKeyDown:tt=>{(tt.key==="Enter"||tt.key===" ")&&(tt.preventDefault(),tt.stopPropagation(),ls(m))},children:H[m]?i("promptSourceCollapse"):i("promptSourceExpand")})]}):s.jsx("span",{className:"source-default-empty",children:i("promptSourceDefaultEmpty")})})]},m)}return s.jsxs("div",{className:"override-row",children:[s.jsxs("div",{className:"override-row-head",children:[`{{${m}}}`,s.jsxs("span",{className:"set-muted",children:[d(`promptTok_${m}`)," — ",d(`promptTok_${m}_desc`)]}),ne.trim()?s.jsx("button",{type:"button",className:"set-btn-mini",onClick:()=>gn(m),children:i("promptResetSource")}):s.jsx("span",{className:"set-muted",children:i("promptAutoBadge")})]}),ne.trim()||Ge?s.jsxs(s.Fragment,{children:[s.jsx("textarea",{className:"set-prompt-input override-input",rows:Math.min(10,Math.max(1,ne.split(`
|
|
333
|
+
`).length)),autoFocus:Ge,placeholder:i("promptOverridePlaceholder"),value:ne,onFocus:He=>{C.current=m,B(m);const tt=He.currentTarget;tt.value&&tt.value===Ne&&tt.setSelectionRange(tt.value.length,tt.value.length)},onBlur:()=>{C.current===m&&(C.current=null);const He=M[m]??"";if(He.trim()&&He===Ne){gn(m);return}Xo(m),He.trim()||B(null)},onChange:He=>z(tt=>({...tt,[m]:He.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:i("promptSourceRefLabel")}),ct&&s.jsx("button",{type:"button",className:"source-default-toggle",onClick:()=>ls(m),children:H[m]?i("promptSourceCollapse"):i("promptSourceExpand")})]}),Ne.trim()?s.jsx("pre",{className:`source-default-text${ct?H[m]?" expanded":" clamped":""}`,children:Ne}):s.jsx("span",{className:"source-default-empty",children:i("promptSourceDefaultEmpty")}),!ne.trim()&&Ne.trim()&&s.jsx("button",{type:"button",className:"override-seed-btn",title:i("promptSourceSeedTip"),onClick:()=>bn(m,Ne),children:i("promptSourceSeedButton")})]})]}):s.jsx("div",{className:"source-default",title:i("promptSourceDefaultEditHint"),role:"button",tabIndex:0,onClick:()=>bn(m,Ne),onKeyDown:He=>{(He.key==="Enter"||He.key===" ")&&(He.preventDefault(),bn(m,Ne))},children:Ne.trim()?s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:`source-default-text${ct?H[m]?" expanded":" clamped":""}`,children:Ne}),ct&&s.jsx("span",{className:"source-default-toggle",role:"button",tabIndex:0,onClick:He=>{He.stopPropagation(),ls(m)},onKeyDown:He=>{(He.key==="Enter"||He.key===" ")&&(He.preventDefault(),He.stopPropagation(),ls(m))},children:H[m]?i("promptSourceCollapse"):i("promptSourceExpand")})]}):s.jsx("span",{className:"source-default-empty",children:i("promptSourceDefaultEmpty")})})]},m)}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"set-btn",onClick:Jo,disabled:!el,children:i("promptResetAll")})})]}),s.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":ye,onClick:()=>v(m=>!m),children:[i("settingsViewPrompt")," ",ye?"▴":"▾"]}),ye&&s.jsxs("div",{className:"set-prompt-view",children:[s.jsxs("div",{className:"set-prompt-view-head",children:[s.jsx("span",{children:i("settingsViewPromptHint")}),s.jsx(rn,{text:u.effectiveSystemPrompt})]}),u.effectiveSystemPrompt?s.jsx("pre",{className:"set-prompt-view-text",children:u.effectiveSystemPrompt}):s.jsx("p",{className:"set-empty",children:i("settingsViewPromptEmpty")}),s.jsxs("div",{className:"set-prompt-tools",children:[s.jsxs("div",{className:"set-prompt-view-head",children:[s.jsx("span",{children:i("settingsViewToolsSchema")}),s.jsx(rn,{text:u.toolsSchema})]}),s.jsx("p",{className:"set-hint",children:i("settingsViewToolsSchemaHint")}),u.toolsSchema?s.jsx("pre",{className:"set-prompt-view-text",children:u.toolsSchema}):s.jsx("p",{className:"set-empty",children:i("settingsViewToolsSchemaEmpty")})]})]})]}),E==="prompt-history"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Bn,{className:"set-section-icon"}),i("settingsPromptHistory"),s.jsx(ft,{text:i("settingsPromptHistoryDesc")}),s.jsx("span",{className:"set-count",children:i("promptHistoryCount",{n:String(G)})})]}),G===0?s.jsx("p",{className:"set-empty",children:i("promptHistoryEmpty")}):s.jsx("p",{className:"set-hint",children:i("promptHistoryCount",{n:String(G)})}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"ph-max",children:i("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(ue.maxEntries),onChange:m=>{const ne=Math.floor(Number(m.target.value)||0),Ne={...ue,maxEntries:ne};ie(Ne)},onBlur:()=>{const m={...ue};(!Number.isFinite(m.maxEntries)||m.maxEntries<1)&&(m.maxEntries=1),m.maxEntries>500&&(m.maxEntries=500),m.maxEntries=Math.floor(m.maxEntries),ie(m),jn(m),b()}}),s.jsx(ft,{text:i("promptHistoryMaxHint")})]})]}),s.jsx(ze,{title:i("promptHistoryCharLimit"),tip:i("promptHistoryCharLimitHint"),enabled:ue.charLimitEnabled,onToggle:()=>{const m={...ue,charLimitEnabled:!ue.charLimitEnabled};ie(m),jn(m),b()}}),ue.charLimitEnabled&&s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"ph-char-limit",children:i("promptHistoryCharLimit")}),s.jsx("input",{id:"ph-char-limit",className:"set-input",type:"number",min:100,max:2e4,step:100,placeholder:i("promptHistoryCharLimitPlaceholder"),value:String(ue.charLimit),onChange:m=>{const ne=Math.floor(Number(m.target.value)||0);ie({...ue,charLimit:ne})},onBlur:()=>{let m=Math.floor(Number(ue.charLimit)||0);(!Number.isFinite(m)||m<100)&&(m=100),m>2e4&&(m=2e4);const ne={...ue,charLimit:m};ie(ne),jn(ne),b()}})]}),s.jsxs("div",{className:"set-field",style:{marginTop:12},children:[s.jsxs("button",{type:"button",className:`set-uninstall${Re?" confirm":""}`,disabled:G===0,title:i(G===0?"promptHistoryEmpty":"promptHistoryClear"),onClick:()=>{if(!Re){x(!0);return}Kh(),x(!1),b()},children:[s.jsx(et,{})," ",i(Re?"promptHistoryClearConfirm":"promptHistoryClear")]}),G>0&&s.jsx("span",{className:"set-hint",style:{marginLeft:8},children:i("promptHistoryCount",{n:String(G)})})]}),s.jsxs("p",{className:"set-hint",children:[s.jsx(lr,{style:{verticalAlign:"-2px",marginRight:4}}),i("settingsPromptHistoryDesc")]})]}),E==="terminal"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Zt,{className:"set-section-icon"}),i("settingsTerminalTools")]}),s.jsx(ze,{title:i("terminalToolsEnabled"),tip:i("settingsTerminalToolsDesc"),enabled:u.terminalToolsEnabled,onToggle:()=>Me({terminalToolsEnabled:!u.terminalToolsEnabled})}),!u.terminalToolsEnabled&&s.jsx("p",{className:"set-hint",children:i("terminalToolsOffHint")}),s.jsx(ze,{title:i("terminalBashTakeover"),tip:i("terminalBashTakeoverDesc"),enabled:u.terminalBash,onToggle:()=>Me({terminalBash:!u.terminalBash})}),u.terminalBash&&s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"tb-idle-ms",children:i("terminalBashIdleMs")}),s.jsx("input",{id:"tb-idle-ms",className:"set-input",type:"number",min:0,step:1e3,value:_e,onChange:m=>Ce(m.target.value),onBlur:()=>{const m=Math.max(0,Math.floor(Number(_e)||0));Ce(String(m)),m!==u.terminalBashIdleMs&&Me({terminalBashIdleMs:m})}})]})]}),E==="edit"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Xt,{className:"set-section-icon"}),i("settingsEditTools")]}),s.jsx(ze,{title:i("editSoftEnabled"),tip:i("editSoftEnabledDesc"),enabled:u.editSoftEnabled,onToggle:()=>Me({editSoftEnabled:!u.editSoftEnabled})}),!u.editSoftEnabled&&s.jsx("p",{className:"set-hint",children:i("editSoftOffHint")})]}),E==="question"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Pa,{className:"set-section-icon"}),i("settingsQuestionnaire")]}),s.jsx(ze,{title:i("questionnaireEnabled"),tip:i("questionnaireEnabledDesc"),enabled:u.questionnaireEnabled,onToggle:()=>Me({questionnaireEnabled:!u.questionnaireEnabled})}),!u.questionnaireEnabled&&s.jsx("p",{className:"set-hint",children:i("questionnaireOffHint")})]}),E==="display"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(es,{className:"set-section-icon"}),i("settingsMessageDisplay")]}),s.jsxs("div",{className:"set-field",children:[s.jsx("label",{className:"set-field-label",htmlFor:"model-retry-max",children:i("modelRetryAttempts")}),s.jsx("input",{id:"model-retry-max",className:"set-input",type:"number",min:0,max:100,step:1,value:Be,onChange:m=>Fe(m.target.value),onBlur:()=>{const m=Math.min(100,Math.max(0,Math.floor(Number(Be)||0)));Fe(String(m)),m!==u.retryMaxAttempts&&Me({retryMaxAttempts:m})},onKeyDown:m=>{m.key==="Enter"&&m.target.blur()}}),s.jsx("p",{className:"set-hint",children:i("modelRetryHint")})]}),s.jsx("hr",{className:"set-sep"}),s.jsx(ze,{title:i("thinkingWrap"),tip:i("thinkingWrapDesc"),enabled:u.thinkingWrap??!0,onToggle:()=>Me({thinkingWrap:!(u.thinkingWrap??!0)})}),s.jsx(ze,{title:i("toolsWrap"),tip:i("toolsWrapDesc"),enabled:u.toolsWrap??!0,onToggle:()=>Me({toolsWrap:!(u.toolsWrap??!0)})}),s.jsx("hr",{className:"set-sep"}),s.jsx(ze,{title:i("wideChat"),tip:i("wideChatDesc"),enabled:ee,onToggle:()=>gf({wide:!ee})}),s.jsx(ze,{title:i("projectTitle"),tip:i("projectTitleDesc"),enabled:ce,onToggle:()=>yf({projectName:!ce})}),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:[i("wallpaperTitle"),s.jsx(ft,{text:i("wallpaperDesc")})]}),s.jsxs("div",{className:"wallpaper-url-row",children:[s.jsx("input",{className:"set-input wallpaper-url",placeholder:i("wallpaperUrlPh"),value:_,maxLength:2e3,spellCheck:!1,onFocus:()=>{F.current=!0},onChange:m=>he(m.target.value),onBlur:()=>{if(F.current=!1,!_.trim()&&ae.url.startsWith("data:")){he("");return}const m=aa(_);he(m),m!==ae.url&&ms({...ae,url:m})},onKeyDown:m=>{m.key==="Enter"?m.target.blur():m.key==="Escape"&&(he(ae.url.startsWith("data:")?"":ae.url),m.target.blur())}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:Ee,onClick:()=>pe.current?.click(),children:[s.jsx(er,{})," ",i("wallpaperUpload")]}),s.jsx("input",{ref:pe,type:"file",accept:"image/*",hidden:!0,onChange:ge})]}),Se&&s.jsx("p",{className:"set-hint",children:i("wallpaperUploadFailed")}),s.jsxs("div",{className:"wallpaper-sliders",children:[s.jsxs("label",{className:"wallpaper-slider",children:[s.jsx("span",{children:i("wallpaperDim")}),s.jsx("input",{type:"range",min:0,max:95,step:1,value:ae.dim,onChange:m=>ms({...ae,dim:Number(m.target.value)})}),s.jsxs("output",{children:[ae.dim,"%"]})]}),s.jsxs("label",{className:"wallpaper-slider",children:[s.jsx("span",{children:i("wallpaperBlur")}),s.jsx("input",{type:"range",min:0,max:24,step:1,value:ae.blur,onChange:m=>ms({...ae,blur:Number(m.target.value)})}),s.jsxs("output",{children:[ae.blur,"px"]})]})]})]}),ae.url&&s.jsxs("div",{className:"wallpaper-current",children:[s.jsx("img",{className:"wallpaper-preview",src:ae.url,alt:""}),s.jsx("button",{type:"button",className:"wallpaper-clear",onClick:()=>{he(""),ms({...ae,url:""})},children:i("wallpaperClear")})]})]})]}),E==="quick"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Xs,{className:"set-section-icon"}),i("quickPhrases"),s.jsx(ft,{text:i("quickPhrasesDesc")}),s.jsx("span",{className:"set-count",children:u.quickPhrases.length})]}),s.jsx(ze,{title:i("quickPhrasesEnabled"),tip:i("quickPhrasesDesc"),enabled:u.quickPhrasesEnabled,onToggle:()=>Me({quickPhrasesEnabled:!u.quickPhrasesEnabled})}),!u.quickPhrasesEnabled&&s.jsx("p",{className:"set-hint",children:i("quickPhrasesOffHint")}),s.jsxs("div",{className:"set-preset-save",children:[s.jsx("input",{className:"set-input",placeholder:i("quickPhrasesPlaceholder"),value:lt,maxLength:200,onChange:m=>At(m.target.value),onKeyDown:m=>{m.key==="Enter"&<.trim()&&(Me({quickPhrases:[...u.quickPhrases,lt.trim()]}),At(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!lt.trim(),onClick:()=>{Me({quickPhrases:[...u.quickPhrases,lt.trim()]}),At("")},children:[s.jsx(dt,{})," ",i("quickPhrasesAdd")]})]}),u.quickPhrases.length===0?s.jsx("p",{className:"set-empty",children:i("quickPhrasesEmpty")}):s.jsx("div",{className:"set-list",children:u.quickPhrases.map((m,ne)=>s.jsx("div",{className:"set-row",children:R?.index===ne?s.jsx("div",{className:"set-row-info",children:s.jsx("input",{className:"set-input",autoFocus:!0,value:R.value,maxLength:200,placeholder:i("quickPhrasesEditPh"),onChange:Ne=>W({index:ne,value:Ne.target.value}),onKeyDown:Ne=>{Ne.key==="Enter"?Kt():Ne.key==="Escape"&&W(null)},onBlur:Kt})}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"set-row-info",children:s.jsx("div",{className:"set-row-name",title:m,children:m})}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesEdit"),onClick:()=>W({index:ne,value:m}),children:s.jsx(Xt,{})}),s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesMoveUp"),disabled:ne===0,onClick:()=>{const Ne=[...u.quickPhrases];[Ne[ne-1],Ne[ne]]=[Ne[ne],Ne[ne-1]],Me({quickPhrases:Ne})},children:"↑"}),s.jsx("button",{type:"button",className:"set-icon-btn",title:i("quickPhrasesMoveDown"),disabled:ne===u.quickPhrases.length-1,onClick:()=>{const Ne=[...u.quickPhrases];[Ne[ne],Ne[ne+1]]=[Ne[ne+1],Ne[ne]],Me({quickPhrases:Ne})},children:"↓"}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("quickPhrasesDelete"),onClick:()=>Me({quickPhrases:u.quickPhrases.filter((Ne,Ge)=>Ge!==ne)}),children:s.jsx(et,{})})]})]})},`${ne}:${m}`))}),s.jsx("div",{className:"compose-toolbar",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{W(null),Me({quickPhrases:cn[c]??cn.en})},children:i("quickPhrasesReset")})})]}),E==="markers"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Ra,{className:"set-section-icon"}),i("settingsMarkers"),s.jsx(ft,{text:i("settingsMarkersDesc")}),s.jsx("span",{className:"set-count",children:u.markers?.length??0})]}),s.jsx(ze,{title:i("markersEnabled"),tip:i("markersEnabledDesc"),enabled:rt,onToggle:()=>Me({markersEnabled:!rt})}),!rt&&s.jsx("p",{className:"set-hint",children:i("markersOffHint")}),rt&&(u.markers?.length??0)===0&&s.jsxs("p",{className:"set-empty",children:[i("loading"),"..."]}),rt&&u.markers&&u.markers.length>0&&s.jsx("div",{className:"set-list",children:u.markers.map(m=>s.jsx(ze,{title:m.name==="todo"?i("markerGroupTodo"):m.name==="notify"?i("markerGroupNotify"):m.name==="conv"?i("markerGroupRename"):m.name,subtitle:(m.guidance[0]??"").slice(0,120),tip:m.guidance.join(`
|
|
334
|
+
`),enabled:m.enabled,onToggle:()=>pt(m.name)},m.name))}),rt&&s.jsx("p",{className:"set-hint",children:i("markerRenameTip")})]}),E==="skills"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(_s,{className:"set-section-icon"}),i("settingsSkills"),s.jsx("span",{className:"set-count",children:u.skills.length})]}),u.skills.length===0?s.jsx("p",{className:"set-empty",children:i(f?"dshSkillsNote":"noSkills")}):s.jsx("div",{className:"set-list",children:u.skills.map(m=>s.jsx(ze,{title:m.name,subtitle:m.description,enabled:m.enabled,onToggle:()=>q(m)},m.name))})]}),E==="extensions"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(En,{className:"set-section-icon"}),i("settingsExtensions"),s.jsx("span",{className:"set-count",children:u.extensions.length})]}),u.extensions.length===0?s.jsx("p",{className:"set-empty",children:i(f?"dshExtensionsNote":"noExtensions")}):s.jsx("div",{className:"set-list",children:u.extensions.map(m=>{const ne=m.id.startsWith("npm:")?m.id.slice(4):null;return s.jsx(ze,{title:m.name,subtitle:m.path,enabled:m.enabled,onToggle:()=>Ye(m),action:ne?J===m.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>Ko(ne),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("uninstallHint"),onClick:()=>le(m.id),children:[s.jsx(et,{}),i("uninstallExt")]}):void 0},m.id)})})]}),E==="plugins"&&e.managed&&s.jsx("div",{className:"set-section",children:s.jsx("div",{className:"set-note",children:i("updatesManaged")})}),E==="plugins"&&!e.managed&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(En,{className:"set-section-icon"}),i("pluginMarket"),s.jsx("span",{className:"set-count",children:e.pluginCatalog.length}),s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginCatalogAddHint"),onClick:()=>xt(m=>!m),children:[s.jsx(dt,{}),i("pluginCatalogAdd")]})]}),os&&s.jsxs("div",{className:"set-catalog-add",children:[s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogSource"),value:Ie,onChange:m=>Ae(m.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogId"),value:D,onChange:m=>we(m.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogName"),value:ve,onChange:m=>qe(m.target.value)}),s.jsx("input",{className:"set-input",placeholder:i("pluginCatalogIcon"),value:mt,onChange:m=>St(m.target.value)}),s.jsx("textarea",{className:"set-input",rows:2,placeholder:i("pluginCatalogDesc"),value:De,onChange:m=>Xe(m.target.value)}),s.jsxs("div",{className:"set-catalog-add-actions",children:[s.jsx("button",{type:"button",className:"set-uninstall confirm",disabled:!Ie.trim(),onClick:zo,children:i("pluginCatalogAddSubmit")}),s.jsx("button",{type:"button",className:"set-uninstall",onClick:()=>xt(!1),children:i("cancel")})]})]}),e.pluginCatalog.length===0?s.jsx("p",{className:"set-empty",children:i("noPluginCatalog")}):s.jsx("div",{className:"set-list",children:e.pluginCatalog.map(m=>{const ne=je.has(m.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:[m.icon?`${m.icon} `:"",m.name]}),ne&&s.jsx("span",{className:"set-catalog-installed",children:i("pluginInstalled")}),!m.builtin&&s.jsx("span",{className:"set-catalog-custom",children:i("pluginCatalogCustom")})]}),m.description&&s.jsx("div",{className:"set-catalog-desc",children:m.description}),s.jsx("div",{className:"set-catalog-source",children:m.source})]}),s.jsxs("div",{className:"set-row-actions",children:[ne?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>Na(m.id,m.source),children:[s.jsx(kt,{}),i("pluginUpdate")]}),be===m.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>ya(m.id),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>ke(m.id),children:[s.jsx(et,{}),i("uninstallExt")]})]}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginInstallHint"),onClick:()=>Yo(m),children:[s.jsx(Ht,{}),i("pluginInstall")]}),!m.builtin&&s.jsx("button",{type:"button",className:"set-uninstall",title:i("pluginCatalogRemoveHint"),onClick:()=>Go(m.id),children:s.jsx($e,{})})]})]},m.id)})})]}),E==="plugins"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Tn,{className:"set-section-icon"}),i("settingsUiPlugins"),s.jsx("span",{className:"set-count",children:e.plugins.length})]}),e.plugins.length===0?s.jsx("p",{className:"set-empty",children:i("noUiPlugins")}):s.jsx("div",{className:"set-list",children:e.plugins.map(m=>s.jsxs(s.Fragment,{children:[s.jsx(ze,{title:`${m.icon?`${m.icon} `:""}${m.name}`,subtitle:(m.error?`${m.id} · ${m.error}`:m.source?`${m.id} · ${m.source}`:`${m.id} · ${i("uiPluginNoSource")}`)+(m.permissions?.length?` · ${i("uiPluginPerms")}: ${m.permissions.join(", ")}`:""),enabled:!xe.has(m.id)&&!m.error,onToggle:()=>!m.error&&Ke(m),action:s.jsxs("div",{className:"set-row-actions",children:[m.source&&s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>Na(m.id,m.source),children:[s.jsx(kt,{}),i("pluginUpdate")]}),be===m.id?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>ya(m.id),children:i("uninstallConfirm")}):s.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>ke(m.id),children:[s.jsx(et,{}),i("uninstallExt")]})]})},m.id),m.settingsSchema&&m.settingsSchema.length>0&&s.jsx(hf,{plugin:m,send:t})]}))})]}),E==="plugins"&&e.engine==="dsh"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Tn,{className:"set-section-icon"}),i("dshPatches"),s.jsx(ft,{text:i("dshPatchesDesc")}),s.jsx("span",{className:"set-count",children:e.dshPatches?.files.length??0}),s.jsxs("button",{type:"button",className:"set-uninstall",title:i("dshPatchesRescanHint"),onClick:()=>t({type:"dsh_patches_rescan"}),children:[s.jsx(kt,{}),i("dshPatchesRescan")]})]}),(e.dshPatches?.files.length??0)===0?s.jsx("p",{className:"set-empty",children:i("dshPatchesEmpty")}):s.jsx("div",{className:"set-list",children:e.dshPatches.files.map(m=>s.jsx("div",{className:"set-row",children:s.jsxs("div",{className:"set-row-info",children:[s.jsx("div",{className:"set-row-name",children:m.name}),s.jsxs("div",{className:"set-row-desc",children:[Pf(m.size)," · ",new Date(m.mtimeMs).toLocaleString()]})]})},m.name))}),s.jsxs("p",{className:"set-hint",children:[i("dshPatchesPath")," ",e.dshPatches?.patchDir??""]})]}),E==="review"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Hs,{className:"set-section-icon"}),i("settingsReview"),s.jsx(ft,{text:i("settingsReviewDesc")}),s.jsx("span",{className:"set-count",children:u.reviewSkills.length})]}),s.jsx(ze,{title:i("goalModeEnabled"),tip:i("goalModeEnabledDesc"),enabled:u.goalModeEnabled,onToggle:()=>Me({goalModeEnabled:!u.goalModeEnabled})}),!u.goalModeEnabled&&s.jsx("p",{className:"set-hint",children:i("goalModeOffHint")}),f&&s.jsx("p",{className:"set-hint",children:i("dshReviewPromptNote")}),s.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:i("reviewPromptPlaceholder"),value:Z,onFocus:()=>me.current=!0,onBlur:()=>{me.current=!1,Me({reviewPrompt:Z})},onChange:m=>Y(m.target.value)}),s.jsx("div",{className:"set-field-label",children:i("settingsReviewSkills")}),u.reviewSkills.length===0?s.jsx("p",{className:"set-empty",children:i("noSkills")}):s.jsx("div",{className:"set-list",children:u.reviewSkills.map(m=>s.jsx(ze,{title:m.name,subtitle:m.description,enabled:m.enabled,onToggle:()=>Vo(m)},`review-${m.name}`))})]}),E==="vision"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Mn,{className:"set-section-icon"}),i("settingsVisionBridge")]}),s.jsx(ze,{title:i("visionBridgeEnabled"),tip:i("settingsVisionBridgeDesc"),enabled:u.visionBridgeEnabled,onToggle:()=>Me({visionBridgeEnabled:!u.visionBridgeEnabled})}),!u.visionBridgeEnabled&&s.jsx("p",{className:"set-hint",children:i("visionBridgeOffHint")}),u.visionBridgeEnabled&&s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("visionBridgeModel")}),s.jsxs("select",{className:"set-select",value:u.visionBridgeModel??"",onChange:m=>Me({visionBridgeModel:m.target.value||null}),children:[s.jsx("option",{value:"",children:i("visionBridgeAuto")}),u.visionModels.map(m=>s.jsx("option",{value:`${m.provider}/${m.id}`,children:m.label},`${m.provider}/${m.id}`))]})]}),u.visionBridgeEnabled&&s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("visionBridgePromptMode")}),s.jsxs("select",{className:"set-select",value:j,onChange:m=>{const ne=m.target.value;X(ne),Me({visionBridgePromptMode:ne})},children:[s.jsx("option",{value:"append",children:i("promptModeAppend")}),s.jsx("option",{value:"replace",children:i("promptModeReplace")})]})]}),u.visionBridgeEnabled&&s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:i("visionBridgePromptPlaceholder"),value:re,onFocus:()=>k.current=!0,onBlur:()=>{k.current=!1;const m=j==="replace"&&u.visionBridgeDefaultPrompt&&re===u.visionBridgeDefaultPrompt?"":re;Me({visionBridgePromptMode:j,visionBridgePrompt:m})},onChange:m=>K(m.target.value)}),u.visionBridgeEnabled&&(u.visionModels.length===0?s.jsx("p",{className:"set-hint",children:i("visionBridgeNoModels")}):s.jsx("p",{className:"set-hint",children:i("visionBridgeCurrent",{model:u.visionBridgeModel??i("visionBridgeAuto")})}))]}),E==="presets"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(Qs,{className:"set-section-icon"}),i("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:i("presetNamePlaceholder"),value:de,onChange:m=>w(m.target.value),onKeyDown:m=>{m.key==="Enter"&&de.trim()&&(t({type:"save_preset",name:de.trim()}),w(""))}}),s.jsxs("button",{type:"button",className:"set-save-btn",disabled:!de.trim(),onClick:()=>{t({type:"save_preset",name:de.trim()}),w("")},children:[s.jsx(dt,{})," ",i("saveAsPreset")]})]}),u.presets.length===0?s.jsx("p",{className:"set-empty",children:i("noPresets")}):s.jsx("div",{className:"set-list",children:u.presets.map(m=>s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsx("div",{className:"set-row-name",children:m.name}),s.jsxs("div",{className:"set-row-desc",children:[m.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend"),m.disabledSkills.length>0&&` · ${i("settingsSkills")} ${m.disabledSkills.length}`,m.disabledExtensions.length>0&&` · ${i("settingsExtensions")} ${m.disabledExtensions.length}`]})]}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>t({type:"apply_preset",name:m.name}),children:i("applyPreset")}),s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("deletePreset"),onClick:()=>t({type:"delete_preset",name:m.name}),children:s.jsx(et,{})})]})]},m.name))})]}),E==="subagent-templates"&&s.jsxs("div",{className:"set-section",children:[s.jsxs("div",{className:"set-section-title",children:[s.jsx(ja,{className:"set-section-icon"}),i("settingsSubagentTemplates"),s.jsx(ft,{text:i("settingsSubagentTemplatesDesc")}),s.jsx("span",{className:"set-count",children:u.subagentTemplates.length}),s.jsxs("button",{type:"button",className:"set-save-btn",title:i("subagentTemplateNew"),onClick:()=>L({name:"",description:"",promptMode:"replace",systemPrompt:"",enabledSkills:[],enabledExtensions:[],model:"",enabled:!0}),children:[s.jsx(dt,{})," ",i("subagentTemplateNew")]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("subagentDefaultModelLabel")}),s.jsxs("select",{className:"set-select",value:u.subagentDefaultModel??"",onChange:m=>Me({subagentDefaultModel:m.target.value||null}),children:[s.jsx("option",{value:"",children:i("subagentFollowMain")}),u.subagentModels.map(m=>s.jsx("option",{value:`${m.provider}/${m.id}`,children:m.label},`${m.provider}/${m.id}`))]})]}),u.subagentModels.length===0?s.jsx("p",{className:"set-hint",children:i("subagentNoModels")}):s.jsx("p",{className:"set-hint",children:i("subagentDefaultModelHint")}),I&&s.jsxs("div",{className:"tpl-editor",children:[s.jsxs("div",{className:"tpl-fields",children:[s.jsx("input",{className:"set-input",placeholder:i("tplNamePlaceholder"),value:I.name,onChange:m=>L({...I,name:m.target.value})}),s.jsx("input",{className:"set-input",placeholder:i("tplDescriptionPlaceholder"),value:I.description,onChange:m=>L({...I,description:m.target.value})}),s.jsx("input",{className:"set-input",placeholder:i("tplDescriptionEnPlaceholder"),value:I.descriptionEn??"",onChange:m=>L({...I,descriptionEn:m.target.value})})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("tplPromptModeLabel")}),s.jsxs("select",{className:"set-select",value:I.promptMode,onChange:m=>L({...I,promptMode:m.target.value}),children:[s.jsx("option",{value:"replace",children:i("promptModeReplace")}),s.jsx("option",{value:"append",children:i("promptModeAppend")})]})]}),s.jsxs("div",{className:"set-mode-row",children:[s.jsx("label",{className:"set-field-label",children:i("tplModelLabel")}),s.jsxs("select",{className:"set-select",value:I.model??"",onChange:m=>L({...I,model:m.target.value}),children:[s.jsx("option",{value:"",children:i("subagentFollowMain")}),u.subagentModels.map(m=>s.jsx("option",{value:`${m.provider}/${m.id}`,children:m.label},`${m.provider}/${m.id}`))]})]}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${i("tplSystemPromptLabel")}${c==="zh"?":":": "}${i("tplSystemPromptPlaceholder")}`,value:I.systemPrompt,onChange:m=>L({...I,systemPrompt:m.target.value})}),s.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${i("tplSystemPromptLabel")}: ${i("tplSystemPromptEnPlaceholder")}`,value:I.systemPromptEn??"",onChange:m=>L({...I,systemPromptEn:m.target.value})}),s.jsxs("div",{className:"tpl-pick-block",children:[s.jsx("div",{className:"tpl-pick-head",children:s.jsxs("span",{children:[i("tplSkillsLabel")," · ",i("tplWhitelistHint")]})}),u.skills.length===0?s.jsx("p",{className:"set-hint",children:i("noSkills")}):s.jsx("div",{className:"tpl-pick",children:u.skills.map(m=>s.jsxs("label",{className:`tpl-chip${I.enabledSkills.includes(m.name)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:I.enabledSkills.includes(m.name),onChange:ne=>{const Ne=ne.target.checked;L({...I,enabledSkills:Ne?[...I.enabledSkills,m.name]:I.enabledSkills.filter(Ge=>Ge!==m.name)})}}),m.name]},m.name))})]}),s.jsxs("div",{className:"tpl-pick-block",children:[s.jsx("div",{className:"tpl-pick-head",children:s.jsxs("span",{children:[i("tplExtensionsLabel")," · ",i("tplWhitelistHint")]})}),u.extensions.length===0?s.jsx("p",{className:"set-hint",children:i("noExtensions")}):s.jsx("div",{className:"tpl-pick",children:u.extensions.map(m=>s.jsxs("label",{className:`tpl-chip${I.enabledExtensions.includes(m.id)?" on":""}`,children:[s.jsx("input",{type:"checkbox",checked:I.enabledExtensions.includes(m.id),onChange:ne=>{const Ne=ne.target.checked;L({...I,enabledExtensions:Ne?[...I.enabledExtensions,m.id]:I.enabledExtensions.filter(Ge=>Ge!==m.id)})}}),m.name]},m.id))})]}),s.jsxs("div",{className:"tpl-actions",children:[s.jsx("button",{type:"button",className:"set-save-btn",disabled:!I.name.trim(),onClick:()=>{t({type:"save_subagent_template",template:{...I,name:I.name.trim()}}),L(null)},children:i("tplSave")}),s.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>L(null),children:i("tplCancel")})]})]}),u.subagentTemplates.length===0?s.jsx("p",{className:"set-empty",children:i("noSubagentTemplates")}):s.jsx("div",{className:"set-list",children:u.subagentTemplates.map(m=>s.jsxs("div",{className:"set-row",children:[s.jsxs("div",{className:"set-row-info",children:[s.jsxs("div",{className:"set-row-name",children:[m.name,u.subagentDefaultTemplates.includes(m.name)&&s.jsx("span",{className:"tpl-badge default",children:i("tplDefaultBadge")}),!m.enabled&&s.jsx("span",{className:"tpl-badge",children:i("subagentTemplateClosed")})]}),s.jsxs("div",{className:"set-row-desc",children:[(c!=="zh"&&m.descriptionEn?m.descriptionEn:m.description)||`${m.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend")}`,m.model?` · ${i("tplModelLabel")} ${m.model}`:` · ${i("subagentFollowMain")}`,m.enabledSkills.length>0&&` · ${i("tplSkillsLabel")} ${m.enabledSkills.length}`,m.enabledExtensions.length>0&&` · ${i("tplExtensionsLabel")} ${m.enabledExtensions.length}`,!m.description&&m.enabledSkills.length===0&&m.enabledExtensions.length===0&&` · ${i("tplInherit")}`]})]}),s.jsxs("div",{className:"set-row-actions",children:[s.jsx("button",{type:"button",className:`set-switch${m.enabled?" on":""}`,role:"switch","aria-checked":m.enabled,title:`${m.enabled?i("subagentTemplateDisable"):i("subagentTemplateEnable")} · ${i("subagentTemplateOffHint")}`,onClick:()=>t({type:"save_subagent_template",template:{...m,enabled:!m.enabled}}),children:s.jsx("span",{className:"set-switch-knob"})}),s.jsx("button",{type:"button",className:"dd-refresh",title:i("subagentTemplateEdit"),onClick:()=>L({...m}),children:i("subagentTemplateEdit")}),oe===m.name?s.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>{t({type:"delete_subagent_template",name:m.name}),se(null)},children:i("uninstallConfirm")}):s.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("tplDelete"),onClick:()=>se(m.name),children:s.jsx(et,{})})]})]},m.name))})]})]})]}),s.jsx("div",{className:"modal-actions",children:s.jsx("button",{type:"button",className:"dd-refresh",onClick:o,children:i("close")})})]})})}function Of(e,t){const n=Math.max(0,Date.now()-e),a=Math.floor(n/6e4);if(a<1)return t("bgTaskJustNow");if(a<60)return t("bgTaskMinutes",{n:a});const o=Math.floor(a/60);return o<24?t("bgTaskHours",{n:o}):t("bgTaskDays",{n:Math.floor(o/24)})}function Mf({servers:e,send:t,onClose:n}){const a=Le(),[o,i]=l.useState(new Set),c=d=>i(u=>{const f=new Set(u);return f.has(d)?f.delete(d):f.add(d),f});return l.useEffect(()=>{t({type:"list_bg_servers"})},[]),s.jsx("div",{className:"modal-backdrop",onClick:n,children:s.jsxs("div",{className:"bg-task-modal",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"bg-task-head",children:[s.jsxs("span",{className:"bg-task-title",children:[s.jsx(Zs,{})," ",a("bgTasks"),e.length>0&&s.jsx("em",{className:"bg-task-count",children:e.length})]}),s.jsx("button",{type:"button",className:"btn",title:a("close"),onClick:n,children:s.jsx($e,{})})]}),e.length===0?s.jsxs("div",{className:"bg-task-empty",children:[s.jsx(Zs,{}),s.jsx("span",{children:a("bgTasksEmpty")}),s.jsx("small",{children:a("bgTasksDesc")})]}):s.jsx("ul",{className:"bg-task-list",children:e.map(d=>{const u=!!d.taskId,f=d.taskId??String(d.port);return s.jsxs("li",{className:"bg-task-item",children:[s.jsx("span",{className:"bg-task-icon",title:u?d.plugin:a("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:d.taskId,children:["🧩 ",d.plugin]}):s.jsxs("span",{className:"bg-task-port",children:[":",d.port]}),d.name&&s.jsx("span",{className:"bg-task-name",children:d.name})]}),s.jsxs("div",{className:"bg-task-line2",children:[!u&&s.jsxs("span",{children:[a("bgTaskPid")," ",d.pid]}),s.jsxs("span",{children:[a("bgTaskSince")," ",Of(d.since,a)]}),u&&d.status&&s.jsx("span",{className:"bg-task-status",children:d.status})]}),d.command&&s.jsxs("button",{type:"button",className:`bg-task-cmd ${o.has(f)?"open":""}`,title:`${a("bgTaskCommand")}: ${d.command}`,onClick:()=>c(f),children:[s.jsx(Zt,{}),s.jsx("code",{children:d.command})]})]}),s.jsxs("button",{type:"button",className:"btn bg-task-stop",title:a("bgTaskStop"),onClick:()=>t(u?{type:"kill_background_server",taskId:d.taskId}:{type:"kill_background_server",port:d.port}),children:[s.jsx(Vs,{}),s.jsx("span",{children:a("bgTaskStop")})]})]},f)})}),s.jsxs("div",{className:"bg-task-foot",children:[s.jsxs("button",{type:"button",className:"btn",title:a("bgTaskRefresh"),onClick:()=>t({type:"list_bg_servers"}),children:[s.jsx(kt,{}),s.jsx("span",{children:a("bgTaskRefresh")})]}),s.jsxs("button",{type:"button",className:"btn bg-task-stopall",disabled:e.length===0,title:a("bgTaskStopAll"),onClick:()=>t({type:"kill_background_servers"}),children:[s.jsx(Vs,{}),s.jsx("span",{children:a("bgTaskStopAll")})]})]})]})})}function Bf(e,t){return e.toLowerCase().includes(t)}function Ff({open:e,send:t,projects:n,cwd:a,fileSearch:o,sessionSearch:i,onClose:c,onSwitchSession:d,onSwitchProject:u,onPreviewFile:f}){const E=Le(),g=l.useRef(null),[y,N]=l.useState(""),S=l.useDeferredValue(y),[M,z]=l.useState(0),$=l.useRef(1),C=l.useRef(0),P=l.useRef(null);l.useEffect(()=>{if(!e)return;t({type:"list_sessions"}),t({type:"list_projects"});const w=y.trim();if(w){const I=++$.current;C.current=I,H(!0),t({type:"search_files",reqId:I,query:w}),t({type:"search_sessions",reqId:I,query:w})}requestAnimationFrame(()=>g.current?.select())},[e]);const[B,H]=l.useState(!1);l.useEffect(()=>{P.current&&clearTimeout(P.current);const w=S.trim();if(!w){H(!1);return}return P.current=setTimeout(()=>{const I=++$.current;C.current=I,H(!0),t({type:"search_files",reqId:I,query:w}),t({type:"search_sessions",reqId:I,query:w})},300),()=>{P.current&&clearTimeout(P.current)}},[S]);const Q=S.trim().toLowerCase(),re=l.useMemo(()=>!Q||!i||i.reqId!==C.current||!i.ok?[]:i.results,[i,Q]),K=l.useMemo(()=>Q?n.filter(w=>Bf(w.path,Q)).slice(0,10):[],[n,Q]),j=l.useMemo(()=>!Q||!o||o.reqId!==C.current||!o.ok?[]:o.results,[o,Q]);l.useEffect(()=>{o&&o.reqId===C.current&&i&&i.reqId===C.current&&C.current!==0&&H(!1)},[o,i]);const X=!!o&&o.ok&&o.truncated,k=l.useMemo(()=>[...re.map(w=>({kind:"session",path:w.path,anchors:w.anchors})),...K.map(w=>({kind:"project",path:w.path})),...j.filter(w=>w.type==="file").map(w=>({kind:"file",path:w.path,name:w.name}))],[re,K,j]);l.useEffect(()=>{z(0)},[S]);const Z=l.useCallback(w=>{if(w)if(w.kind==="session")d(w.path,w.anchors),c();else if(w.kind==="project"){u(w.path),t({type:"list_sessions"}),t({type:"list_projects"});const I=S.trim();if(I){const L=++$.current;C.current=L,H(!0),t({type:"search_files",reqId:L,query:I}),t({type:"search_sessions",reqId:L,query:I})}}else f(w.path,w.name)},[d,u,f,t,S]);l.useEffect(()=>{if(!e)return;const w=I=>{I.key==="Escape"?(I.preventDefault(),I.stopPropagation(),c()):I.key==="ArrowDown"?(I.preventDefault(),z(L=>Math.min(L+1,k.length-1))):I.key==="ArrowUp"?(I.preventDefault(),z(L=>Math.max(L-1,0))):I.key==="Enter"&&(I.preventDefault(),Z(k[M]))};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[k,M,Z,c,e]);const Y=re.length+K.length+j.length,me=(w,I,L)=>s.jsxs("div",{className:"gs-section-head",children:[L,s.jsx("span",{children:w}),s.jsx("em",{children:I})]});let de=-1;return e?s.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:c,children:s.jsxs("div",{className:"gs-modal",onClick:w=>w.stopPropagation(),children:[s.jsxs("div",{className:"gs-input-row",children:[s.jsx(Js,{}),s.jsx("input",{ref:g,type:"text",value:y,placeholder:E("gsPlaceholder"),onChange:w=>N(w.target.value)}),s.jsx("button",{type:"button",className:"gs-close",title:E("close"),onClick:c,children:s.jsx($e,{})})]}),s.jsxs("div",{className:"gs-results",children:[!Q&&s.jsx("div",{className:"gs-empty",children:E("gsHint")}),Q&&Y===0&&!X&&s.jsx("div",{className:"gs-empty",children:E(B?"gsSearching":"gsNoResults")}),re.length>0&&s.jsxs("div",{className:"gs-section",children:[me(E("gsSessions"),re.length,s.jsx(es,{})),re.map(w=>{de++;const I=de;return s.jsxs("button",{type:"button",className:I===M?"gs-item active":"gs-item",onMouseEnter:()=>z(I),onClick:()=>Z({kind:"session",path:w.path,anchors:w.anchors}),children:[s.jsxs("span",{className:"gs-item-title",children:[w.name||w.path.split(/[\\/]/).pop(),s.jsx("em",{className:"gs-item-meta",children:w.messageCount})]}),s.jsx("span",{className:"gs-item-sub",children:w.firstMessage})]},w.path)})]}),K.length>0&&s.jsxs("div",{className:"gs-section",children:[me(E("gsProjects"),K.length,s.jsx(Pt,{})),K.map(w=>{de++;const I=de,L=a&&w.path===a;return s.jsxs("button",{type:"button",className:I===M?"gs-item active":"gs-item",onMouseEnter:()=>z(I),onClick:()=>Z({kind:"project",path:w.path}),children:[s.jsxs("span",{className:"gs-item-title",children:[w.path.split(/[\\/]/).pop(),L&&s.jsx("em",{className:"gs-item-meta",children:E("gsCurrentProject")})]}),s.jsx("span",{className:"gs-item-sub",children:w.path})]},w.path)})]}),(j.length>0||Q&&X)&&s.jsxs("div",{className:"gs-section",children:[me(E("gsFiles"),j.length,s.jsx(nr,{})),j.map(w=>{de++;const I=de;return s.jsxs("button",{type:"button",className:I===M?"gs-item active":"gs-item",disabled:w.type==="dir",title:w.type==="dir"?void 0:E("gsOpenPreview"),onMouseEnter:()=>z(I),onClick:()=>{w.type==="file"&&Z({kind:"file",path:w.path,name:w.name})},children:[s.jsx("span",{className:"gs-item-title",children:w.name}),s.jsx("span",{className:"gs-item-sub",children:w.path})]},`${w.type}:${w.path}`)}),X&&s.jsx("div",{className:"gs-truncated",children:E("gsTruncated")})]})]}),s.jsxs("div",{className:"gs-foot",children:[s.jsxs("span",{children:["↑↓ ",E("gsNavigate")]}),s.jsxs("span",{children:["Enter ",E("gsOpen")]}),s.jsxs("span",{children:["Esc ",E("gsCloseHint")]})]})]})}):null}const Rn=5e3;function Hf({file:e,content:t,send:n,onAddLines:a,onAttach:o,onClose:i}){const c=Le(),[d,u]=l.useState(null),[f,E]=l.useState(!1),[g,y]=l.useState(null),[N,S]=l.useState(!1),[M,z]=l.useState(!1),[$,C]=l.useState(!1),[P,B]=l.useState(""),[H,Q]=l.useState(!0),re=l.useRef(!1),[K,j]=l.useState(!0),[X,k]=l.useState(!1),[Z,Y]=l.useState(100),me=l.useRef(0),de=l.useRef(!1),w=l.useRef(null);l.useEffect(()=>{E(!0),u(null),y(null),C(!1),B(""),Q(!0),re.current=!1,n({type:"read_file",path:e.path})},[e.path,n]),l.useEffect(()=>{t&&t.path===e.path&&(u(t),$||B(t.text),E(!1))},[t,$,e.path]),l.useEffect(()=>{const ie=G=>{if(G.key==="Escape"){he();return}if((G.ctrlKey||G.metaKey)&&G.key.toLowerCase()==="s"&&$){G.preventDefault(),_();return}const Te=G.target,Re=Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.isContentEditable);(G.ctrlKey||G.metaKey)&&G.key.toLowerCase()==="a"&&!Re&&(G.preventDefault(),ye())};return document.addEventListener("keydown",ie),()=>document.removeEventListener("keydown",ie)},[i,d,$,P]),l.useEffect(()=>{const ie=()=>{de.current=!1,S(!1)};return window.addEventListener("mouseup",ie),()=>window.removeEventListener("mouseup",ie)},[]);const I=l.useMemo(()=>{if(!d)return[];const ie=d.text.split(`
|
|
335
|
+
`);return ie.length>0&&ie[ie.length-1]===""&&ie.pop(),ie.slice(0,Rn)},[d]),L=d?.lines??0,oe=L>Rn,se=(ie,G)=>{if(G){const Te=me.current>0?me.current:ie;y({start:Math.min(Te,ie),end:Math.max(Te,ie)})}else me.current=ie,y({start:ie,end:ie})},ye=()=>{I.length!==0&&(me.current=1,y({start:1,end:I.length}))},v=()=>{g&&(a(e.path,e.name,g.start,g.end),z(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>z(!1),1400))},ee=d!==null&&d.kind==="text"&&!d.binary&&!d.truncated,ce=()=>{B(d?.text??""),C(!1),re.current&&Q(!0)},ae=()=>{if($){if(P!==(d?.text??"")&&!window.confirm(c("discardFileChanges")))return;ce();return}!ee||!d||(re.current=Pn(e.name)&&H,Pn(e.name)&&Q(!1),y(null),B(d.text),C(!0))},_=()=>{!$||!d||!ee||n({type:"write_file",path:e.path,text:P})&&(C(!1),re.current&&Q(!0),y(null))},he=()=>{$&&P!==(d?.text??"")&&!window.confirm(c("discardFileChanges"))||i()},F=ie=>{Y(Math.min(200,Math.max(50,ie)))},pe=g?g.end-g.start+1:0,Ee=d?.binary??!1,Oe=d?.truncated??!1,Se=d?.kind??"text",U=Pn(e.name),ge=U&&H&&!$&&Se==="text"&&!Ee,ue=ie=>Dt(at(`/api/file?clientId=${encodeURIComponent(ca())}&path=${encodeURIComponent(ie)}`));return s.jsx("div",{className:`fp-overlay ${X?"fullscreen":""}`,onMouseDown:ie=>{ie.target===ie.currentTarget&&he()},children:s.jsxs("div",{className:`fp ${X?"fullscreen":""}`,style:{"--fp-zoom":Z/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:[d&&Se==="text"&&!Ee&&c("fileLines",{n:L}),d&&` · ${Uf(d.size)}`]}),s.jsxs("span",{className:"fp-head-actions",children:[U&&Se==="text"&&!Ee&&d&&s.jsx("button",{type:"button",className:`fp-attach markdown ${H?"on":""}`,"data-tip":c(H?"showMarkdownSource":"showMarkdownPreview"),disabled:$,onClick:()=>Q(ie=>!ie),children:H?s.jsx(Mn,{}):s.jsx(Fl,{})}),Se==="text"&&!Ee&&d&&s.jsx("button",{type:"button",className:`fp-attach edit ${$?"on":""}`,"data-tip":c(Oe?"fileEditTruncated":$?"exitEditFile":"editFile"),disabled:!ee&&!$,onClick:ae,children:s.jsx(Xt,{})}),Se==="text"&&!Ee&&!ge&&s.jsx("button",{type:"button",className:`fp-attach wrap ${K?"on":""}`,"data-tip":c(K?"disableWrap":"enableWrap"),onClick:()=>j(ie=>!ie),children:s.jsx(Bl,{})}),Se==="text"&&d&&s.jsxs("span",{className:"fp-zoom",children:[s.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":c("zoomOut"),disabled:Z<=50,onClick:()=>F(Z-10),children:s.jsx(Tl,{})}),s.jsxs("button",{type:"button",className:"fp-zoom-val",title:c("resetZoom"),onClick:()=>Y(100),children:[Z,"%"]}),s.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":c("zoomIn"),disabled:Z>=200,onClick:()=>F(Z+10),children:s.jsx(xl,{})})]}),Se!=="video"&&Se!=="none"&&s.jsx("button",{type:"button",className:"fp-attach inline","data-tip":c("attachInlineTip"),onClick:()=>o(e.path,e.name,"inline"),children:s.jsx(dt,{})}),s.jsx("button",{type:"button",className:"fp-attach ref","data-tip":c("referenceTip"),onClick:()=>o(e.path,e.name,"reference"),children:s.jsx(On,{})}),s.jsx("button",{type:"button",className:`fp-attach full ${X?"on":""}`,"data-tip":c(X?"exitFullscreen":"fullscreen"),onClick:()=>k(ie=>!ie),children:X?s.jsx(Al,{}):s.jsx(Il,{})}),s.jsx("button",{type:"button",className:"fp-close",title:c("close"),onClick:he,children:s.jsx($e,{})})]})]}),Oe&&Se==="text"&&!Ee&&s.jsx("div",{className:"fp-notice",children:c("previewTruncated")}),f&&!d&&s.jsx("div",{className:"fp-empty",children:c("loading")}),!f&&Se==="none"&&!Ee&&s.jsx("div",{className:"fp-empty",children:c("previewNotSupported")}),!f&&Se==="image"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("img",{className:"fp-media",src:ue(e.path),alt:e.name})}),!f&&Se==="video"&&s.jsx("div",{className:"fp-media-wrap",children:s.jsx("video",{className:"fp-media",src:ue(e.path),controls:!0,preload:"metadata"})}),!f&&ge&&d&&s.jsx("div",{className:"fp-markdown msg-text",children:s.jsx("div",{className:"fp-markdown-zoom",children:s.jsx(ot,{text:d.text})})}),!f&&Ee&&Se!=="image"&&Se!=="video"&&d&&s.jsxs("div",{className:"fp-hex-wrap",children:[s.jsxs("div",{className:"fp-notice",children:[c("binaryFile"),d.truncated&&c("binaryHexTruncated")]}),s.jsx("pre",{className:"fp-hex",children:d.text})]}),!f&&$&&Se==="text"&&!Ee&&d&&s.jsx("textarea",{className:`fp-editor ${K?"":"no-wrap"}`,value:P,onChange:ie=>B(ie.target.value),wrap:K?"soft":"off",spellCheck:!1,autoFocus:!0}),!f&&!ge&&!$&&Se==="text"&&!Ee&&d&&I.length===0&&s.jsx("div",{className:"fp-empty",children:c("emptyFile")}),!f&&!ge&&!$&&Se==="text"&&!Ee&&I.length>0&&s.jsxs("div",{className:`fp-code ${N?"dragging":""} ${K?"":"no-wrap"}`,onMouseDown:ie=>{ie.button===0&&ie.preventDefault()},children:[I.map((ie,G)=>{const Te=G+1,Re=g!==null&&Te>=g.start&&Te<=g.end;return s.jsxs("div",{className:`fp-line ${Re?"sel":""}`,onMouseDown:x=>{x.button===0&&(se(Te,x.shiftKey),de.current=!0,S(!0))},onMouseEnter:()=>{de.current&&se(Te,!0)},children:[s.jsx("span",{className:"fp-num",children:Te}),s.jsx("span",{className:"fp-code-text",children:ie})]},Te)}),oe&&s.jsx("div",{className:"fp-lines-note",children:c("previewLinesTruncated",{n:Rn})})]}),s.jsx("div",{className:"fp-foot",children:$?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:c("editFile")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",onClick:ae,children:c("cancel")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:P===(d?.text??""),onClick:_,children:[s.jsx(vl,{})," ",c("saveFile")]})]})]}):!ge&&Se==="text"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"fp-hint",children:g?c("selectedRange",{n:pe,start:g.start,end:g.end}):c("selectLinesHint")}),s.jsxs("div",{className:"fp-actions",children:[s.jsx("button",{type:"button",className:"btn",disabled:I.length===0,onClick:ye,children:c("selectAll")}),s.jsx("button",{type:"button",className:"btn",disabled:!g,onClick:()=>y(null),children:c("clearSelection")}),s.jsxs("button",{type:"button",className:"btn primary",disabled:!g||Ee,onClick:v,children:[M?s.jsx(Tt,{}):null,c(M?"addedToChat":"addToChat")]})]})]})})]})})}function Pn(e){const t=e.toLowerCase();return t.endsWith(".md")||t.endsWith(".markdown")}function Uf(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}const Fo="pi-web-sounds",ps={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function Ho(){try{const e=localStorage.getItem(Fo);if(!e)return{...ps};const t=JSON.parse(e),n={...ps,...t};for(const a of["enabled","question","done","start","error"])typeof n[a]!="boolean"&&(n[a]=ps[a]);return typeof n.volume!="number"||!Number.isFinite(n.volume)?n.volume=ps.volume:n.volume=Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...ps}}}function qf(e){try{localStorage.setItem(Fo,JSON.stringify(e))}catch{}}let hs=null;function $f(){try{if(!hs){const e=window.AudioContext??window.webkitAudioContext;if(!e)return null;hs=new e}return hs.state==="suspended"&&hs.resume(),hs}catch{return null}}const Wf=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],Kf=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],Yf=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],Gf=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],zf={question:Wf,done:Kf,start:Yf,error:Gf};function Vf(e,t,n){const a=e.createOscillator(),o=e.createGain();a.type=t.type,a.frequency.value=t.freq;const i=e.currentTime+t.start,c=Math.max(1e-4,t.peak*n);o.gain.setValueAtTime(1e-4,i),o.gain.exponentialRampToValueAtTime(c,i+.012),o.gain.exponentialRampToValueAtTime(1e-4,i+t.dur),a.connect(o),o.connect(e.destination),a.start(i),a.stop(i+t.dur+.05)}function zt(e,t=Ho()){if(!t.enabled||!t[e])return;const n=$f();if(!n)return;const a=Math.max(0,Math.min(1,t.volume/100));for(const o of zf[e])Vf(n,o,a)}const Qf=l.lazy(()=>dl(()=>import("./TerminalPanel-CKvAH2c_.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.TerminalPanel})));function Xf({notice:e,onDismiss:t}){const n=Le(),{locale:a}=Mt(),o=a!=="zh"&&e.textEn?e.textEn:e.text,[i,c]=l.useState(!1);l.useEffect(()=>{if(i)return;const u=setTimeout(()=>t(e.id),e.level==="error"?12e3:7e3);return()=>clearTimeout(u)},[i,e.id,e.level,t]);const d=e.level==="error"?$l:e.level==="warning"?ql:Pl;return s.jsxs("div",{className:`notice notice-${e.level}${i?" paused":""}`,role:"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[s.jsx(d,{className:"notice-icon"}),s.jsx("span",{className:"notice-text",children:o}),s.jsx("button",{type:"button",className:"notice-close",title:n("close"),onClick:()=>t(e.id),children:s.jsx($e,{})})]})}const Jf=[],Uo=180,qo=520,$o=240,Wo=e=>`pi-web-ui:${e}-panel-width`;function $i(e){const t=Number(localStorage.getItem(Wo(e)));return Number.isFinite(t)&&t>=Uo&&t<=qo?t:$o}const oa=e=>`pi-web-ui:${e}-panel-collapsed`;function Wi(e){return localStorage.getItem(oa(e))==="1"}function Ki({side:e,width:t,onResize:n}){const a=Le(),o=l.useCallback(i=>{i.preventDefault();const c=i.clientX,d=t;let u=d;const f=g=>{const y=e==="left"?g.clientX-c:c-g.clientX;u=Math.min(qo,Math.max(Uo,Math.round(d+y))),n(u)},E=()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",E),document.body.classList.remove("panel-resizing"),localStorage.setItem(Wo(e),String(u))};window.addEventListener("pointermove",f),window.addEventListener("pointerup",E),document.body.classList.add("panel-resizing")},[e,t,n]);return s.jsx("div",{className:`resize-handle resize-${e}`,title:a("dragToResize"),onPointerDown:o,onDoubleClick:()=>n($o)})}function Yi({side:e,onClick:t}){const n=Le();return s.jsx("button",{type:"button",className:`panel-rail panel-rail-${e}`,title:n("expandPanel"),onClick:t,children:e==="left"?s.jsx(ar,{}):s.jsx(ir,{})})}function Zf(){const e=Le(),{locale:t}=Mt(),{chat:n,send:a,dismissNotice:o,pushNotice:i,terminal:c}=$c(),d=l.useRef(!1);l.useEffect(()=>{!n.ready||!n.settings||d.current||n.settings.quickPhrasesSeeded||(d.current=!0,n.settings.quickPhrases.length===0&&a({type:"set_settings",quickPhrases:cn[t]??cn.en,quickPhrasesSeeded:!0}))},[n.ready,n.settings,a,t]);const u=n.state?.cwd??"",f=Po();l.useEffect(()=>{const q=f?Tf(u):"";document.title=q?`${q} — pi-web-ui`:e("docTitle")},[u,f,e]);const[E,g]=l.useState([]),[y,N]=l.useState(null),[S,M]=l.useState(!1),[z,$]=l.useState("chat"),C=q=>!n.tabs||q==="chat"||n.tabs.includes(q),P=z.startsWith("plugin:")?"plugins":z,B=C(P)?z:"chat",H=l.useMemo(()=>n.plugins.filter(q=>!n.settings?.disabledPlugins?.includes(q.id)),[n.plugins,n.settings?.disabledPlugins]),[Q,re]=l.useState([]);l.useEffect(()=>Ic(re),[]),l.useEffect(()=>{xp(a),yp(H,n.pluginsEpoch),jc(H,n.pluginsEpoch)},[H,n.pluginsEpoch,a]);const[K,j]=l.useState(()=>$i("left")),[X,k]=l.useState(()=>$i("right")),Z=l.useCallback(q=>j(q),[]),Y=l.useCallback(q=>k(q),[]),[me,de]=l.useState(()=>Wi("left")),[w,I]=l.useState(()=>Wi("right")),L=l.useCallback(()=>{de(q=>(localStorage.setItem(oa("left"),q?"0":"1"),!q))},[]),oe=l.useCallback(()=>{I(q=>(localStorage.setItem(oa("right"),q?"0":"1"),!q))},[]),[se,ye]=l.useState(null),[v,ee]=l.useState(()=>window.matchMedia("(max-width: 768px)").matches);l.useEffect(()=>{const q=window.matchMedia("(max-width: 768px)"),xe=je=>ee(je.matches);return q.addEventListener("change",xe),()=>q.removeEventListener("change",xe)},[]);const[ce,ae]=l.useState(!1),[_,he]=l.useState(!1),[F,pe]=l.useState(!1),Ee=jo(),[Oe,Se]=l.useState(!1),[U,ge]=l.useState(!1),[ue,ie]=l.useState(null);l.useEffect(()=>{if(!ue)return;const q=setTimeout(()=>ie(null),15e3);return()=>clearTimeout(q)},[ue]),l.useEffect(()=>{const q=xe=>{const je=xe.detail,Ke=je?.title||e("pluginCommandFallback"),Ye=je?.command;if(!Ye||!n.ready)return;const rt={name:Ke,command:Ye,cwd:"${pwd}"},Je=n.terminals.find(pt=>pt.title===Ke);if(Je)c.restart(Je.id),a({type:"run_command",terminalId:Je.id,conversationId:Je.conversationId,command:rt,cols:80,rows:24});else{const pt=_t();c.create({id:pt,conversationId:n.activeConversationId||n.state?.conversationId||"",title:Ke,cwd:n.state?.cwd??"",cols:80,rows:24,running:!0,exitCode:null,command:rt})}$("terminal")};return window.addEventListener("pi-web-ui:plugin-run-command",q),()=>window.removeEventListener("pi-web-ui:plugin-run-command",q)},[n,c,a]),l.useEffect(()=>{const q=xe=>{!(xe.ctrlKey||xe.metaKey)||xe.key.toLowerCase()!=="k"||(xe.preventDefault(),ge(je=>!je))};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const[G,Te]=l.useState(Ho),{themes:Re,theme:x,switchTheme:b}=_p();jf();const J=l.useRef(null),le=l.useRef(null),be=l.useRef(null),ke=l.useRef(0),Ie=l.useRef(!1),Ae=l.useRef(n.terminals);l.useEffect(()=>{qf(G)},[G]),l.useEffect(()=>{const q=Ae.current;Ae.current=n.terminals;for(const xe of n.terminals){const je=xe.command?.command??"";!q.find(Ye=>Ye.id===xe.id)?.running||xe.running||(je.startsWith("pi remove ")?a({type:"extensions_reload"}):je.startsWith("pi-web-ui install ")||je.startsWith("pi-web-ui uninstall ")?a({type:"plugins_reload"}):je.startsWith("npm i -g ")&&(a({type:"extensions_reload"}),a({type:"plugins_reload"}),a({type:"check_updates_all",force:!0})))}},[n.terminals,a]),l.useEffect(()=>{const q=n.state?.isStreaming??!1,xe=J.current;J.current=q,xe!==null&&(!xe&&q?zt("start",G):xe&&!q&&(zt("done",G),Os(e("notifyDoneTitle"),e("notifyDoneBody"))))},[n.state?.isStreaming,G]),l.useEffect(()=>{const q=n.dialog?.id??null;q!==null&&q!==le.current&&(zt("question",G),Os(e("notifyQuestionTitle"),e("notifyQuestionBody"))),le.current=q},[n.dialog,G]),l.useEffect(()=>{const q=n.question?.id??null;q!==null&&q!==be.current&&(zt("question",G),Os(e("notifyQuestionTitle"),e("notifyQuestionBody"))),be.current=q},[n.question,G]),l.useEffect(()=>{const q=[...n.notices].reverse().find(xe=>xe.level==="error");q&&q.id!==ke.current&&(ke.current=q.id,zt("error",G),Os(e("notifyErrorTitle"),e("notifyErrorBody")))},[n.notices,G]);const D=(q,xe,je,Ke=!1,Ye)=>{const rt=`${q}|${je}|${Ye?`${Ye.start}-${Ye.end}`:""}`;g(Je=>Je.some(pt=>`${pt.path}|${pt.mode}|${pt.lines?`${pt.lines.start}-${pt.lines.end}`:""}`===rt)?Je:[...Je,{path:q,name:xe,mode:je,isDir:Ke,...Ye?{lines:Ye}:{}}])},we=q=>g(xe=>xe.filter(je=>je.key?je.key!==q:je.path!==q)),ve=l.useCallback(q=>(!q.type.startsWith("list_")&&!q.type.startsWith("get_")&&ye(null),a(q)),[a]),qe=l.useRef(0),De=l.useRef(0),Xe=q=>{const xe=Date.now();n.state?.model&&!n.state.model.vision&&xe-De.current>1e4&&(De.current=xe,i("warning",e("imageNotSupported")));const je=`paste-${++qe.current}`;g(Ke=>[...Ke,{path:"",key:je,name:q.name,mode:"inline",imageData:q.data,mimeType:q.mimeType}])},mt=async q=>{for(const xe of q){const je=await Ea(xe);if(!je){i("error",e("imageLoadFailed",{name:xe.name}));continue}Xe(je)}},St=20*1024*1024,os=l.useRef(0),xt=async q=>{if(q.size>St){i("warning",e("fileTooLarge",{name:q.name,size:St/1024/1024}));return}let xe;try{xe=(await new Promise((Ye,rt)=>{const Je=new FileReader;Je.onload=()=>Ye(Je.result),Je.onerror=()=>rt(Je.error??new Error("read failed")),Je.readAsDataURL(q)})).replace(/^data:[^;]*;base64,/,"")}catch{i("error",e("fileLoadFailed",{name:q.name}));return}const je=`upload-${++os.current}`;g(Ke=>[...Ke,{path:"",key:je,name:q.name,mode:"inline",fileData:xe,size:q.size,mimeType:q.type||void 0}])},lt=async q=>{for(const xe of q)vt(xe.type)?await mt([xe]):await xt(xe)},At=l.useCallback((q,xe,je)=>{a({type:"edit_message",messageId:q,text:xe,attachments:je})},[a]),R=l.useCallback((q,xe)=>{a({type:"queue_remove",kind:q,text:xe})},[a]),W=l.useCallback(()=>he(!0),[]),_e=l.useCallback(()=>g([]),[]),Ce=l.useCallback(we,[]),Be=l.useCallback(mt,[mt]),Fe=l.useCallback(lt,[lt]),it=n.state?.model,yt=n.state?.thinkingLevel,Rs=n.state?.availableThinkingLevels,Me=l.useMemo(()=>it?{model:it,thinkingLevel:yt??"off",availableThinkingLevels:Rs??[]}:null,[it,yt,Rs]),Kt=l.useCallback(()=>!n.ready||n.terminals.length!==0?!1:(c.create({id:_t(),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,c]);return l.useEffect(()=>{if(Ie.current){if(B!=="terminal"||n.terminals.length!==0){Ie.current=!1;return}Kt()&&(Ie.current=!1)}},[n.terminals.length,Kt,B]),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){i("warning",e("foldersNotSupported"));return}const je=xe.filter(Ye=>vt(Ye.type)),Ke=xe.filter(Ye=>!vt(Ye.type));je.length>0&&mt(je),Ke.length>0&<(Ke)},children:[S&&s.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:s.jsxs("span",{children:["📎 ",e("dropHereToAttach")]})}),s.jsx(Ec,{chat:n,send:a,terminal:c,view:B,plugins:H,onViewChange:q=>{Ie.current=q==="terminal"&&n.terminals.length===0,Ie.current&&Kt()&&(Ie.current=!1),$(q),ye(null)},onOpenPanel:ye,onOpenSettings:()=>pe(!0),onOpenBgTasks:()=>Se(!0),onOpenGlobalSearch:()=>ge(!0),sound:G,onSoundChange:Te,onSoundPreview:q=>zt(q,G),themes:Re,theme:x,onThemeChange:b}),n.protocolMismatch&&s.jsxs("div",{className:"protocol-banner",children:["⚠ ",e("protocolMismatch")]}),s.jsx("div",{className:"notices",children:n.notices.map(q=>s.jsx(Xf,{notice:q,onDismiss:o},q.id))}),s.jsx(Ih,{send:a,children:s.jsxs("div",{className:"layout",style:{"--left-w":`${K}px`,"--right-w":`${X}px`},children:[se&&s.jsx("div",{className:"drawer-backdrop",onClick:()=>ye(null)}),s.jsxs("div",{className:`view-pane ${B==="chat"?"":"hidden"}`,children:[!v&&me&&s.jsx(Yi,{side:"left",onClick:L}),s.jsx("div",{className:`panel-drawer drawer-left ${se==="left"?"open":""}${v?"":me?" hidden":""}`,children:s.jsx(Cc,{collapsible:!v,onToggleCollapse:L,send:ve,active:!v||se==="left",ready:n.ready,status:n.status,cwd:n.state?.cwd??"",sessionFile:n.state?.sessionFile??null,conversations:n.conversations,sessions:n.sessions,projects:n.projects,activeConversationId:n.activeConversationId})}),!v&&s.jsx(Ki,{side:"left",width:K,onResize:Z}),s.jsxs("main",{className:Ee?"main wide-chat":"main",children:[n.state?s.jsx(Mh,{state:n.state,liveOutputs:n.liveOutputs,toolStatuses:n.toolStatuses,onEdit:At,onKillBash:()=>a({type:"abort_bash"}),onRetry:()=>a({type:"retry_last"}),onRemoveQueued:R,thinkingWrap:n.settings?.thinkingWrap??!0,toolsWrap:n.settings?.toolsWrap??!0,jumpTarget:ue,onJumpDone:()=>ie(null)},n.state.conversationId??"boot"):s.jsx("div",{className:"boot-wait",children:n.ready?e("loadingSession"):e("connectingServer")}),n.settings?.goalModeEnabled!==!1&&s.jsx(Xh,{send:a,goal:n.goal,models:n.models,modelsLoading:n.modelsLoading,activeConversationId:n.activeConversationId,engine:n.engine}),n.dialog&&s.jsx(af,{dialog:n.dialog,send:a}),n.question&&s.jsx(rf,{question:n.question,send:a}),s.jsx(Qh,{send:a,ready:n.ready,streaming:n.state?.isStreaming??!1,messages:n.state?.messages??Jf,slashCommands:n.slashCommands,modelState:Me,models:n.models,modelsLoading:n.modelsLoading,providerKeys:n.providerKeys,attachments:E,onRemoveAttachment:Ce,onAddImageFiles:Be,onAddLocalFiles:Fe,onNotice:i,onManageModels:W,onSent:_e,quickPhrases:n.settings?.quickPhrases??[],quickPhrasesEnabled:n.settings?.quickPhrasesEnabled??!0})]}),!v&&s.jsx(Ki,{side:"right",width:X,onResize:Y}),s.jsx("div",{className:`panel-drawer drawer-right ${se==="right"?"open":""}${v?"":w?" hidden":""}`,children:s.jsx(Jc,{collapsible:!v,onToggleCollapse:oe,send:ve,files:n.files,fileChanged:n.fileChanged,widgets:n.widgets,cwd:n.state?.cwd??"",onAttach:(q,xe,je,Ke)=>{ye(null),D(q,xe,je,Ke)},onPreview:(q,xe)=>{ye(null),N({path:q,name:xe})},onNotice:(q,xe)=>i(q,xe)})}),!v&&w&&s.jsx(Yi,{side:"right",onClick:oe})]}),s.jsx("div",{className:`view-pane ${B==="terminal"?"":"hidden"}`,children:s.jsx(l.Suspense,{fallback:null,children:s.jsx(Qf,{chat:n,send:a,terminal:c})})}),s.jsx("div",{className:`view-pane ${B==="git"?"":"hidden"}`,children:s.jsx(lf,{chat:n,send:a,terminal:c,active:B==="git",onSwitchToTerminal:()=>$("terminal")})}),Q.map(q=>{const xe=`plugin:${q.info.id}`;return s.jsx("div",{className:`view-pane ${B===xe?"":"hidden"}`,children:s.jsx(cf,{entry:q,send:a})},q.info.id)})]})}),s.jsx(sf,{chat:n,send:a}),y&&s.jsx(Hf,{file:y,content:n.fileContent,send:a,onAddLines:(q,xe,je,Ke)=>D(q,xe,"lines",!1,{start:je,end:Ke}),onAttach:(q,xe,je)=>D(q,xe,je),onClose:()=>N(null)}),n.ready&&n.state&&n.state.piConfigured===!1&&!ce&&!_&&s.jsx(uf,{send:a,piConfigured:n.state.piConfigured,piAgentInstalled:n.state.piAgentInstalled,managed:n.managed,providers:n.providers,installResult:n.installResult,onClose:()=>ae(!0)}),_&&s.jsx(pf,{send:a,providers:n.modelsConfig,providerStatus:n.providers,providerKeys:n.providerKeys,fetchModelsResult:n.fetchModelsResult,cloneProviderResult:n.cloneProviderResult,onClose:()=>he(!1)}),F&&s.jsx(Df,{chat:n,send:a,terminal:c,onSwitchToTerminal:()=>$("terminal"),onClose:()=>pe(!1)}),Oe&&s.jsx(Mf,{servers:n.bgServers,send:a,onClose:()=>Se(!1)}),s.jsx(Ff,{open:U,send:a,projects:n.projects,cwd:n.state?.cwd??"",fileSearch:n.fileSearch,sessionSearch:n.sessionSearch,onClose:()=>ge(!1),onSwitchSession:(q,xe)=>{a({type:"switch_session",path:q});const je=xe&&xe[0];ie(je?{path:q,role:je.role,timestamp:je.timestamp}:null)},onSwitchProject:q=>{a({type:"set_cwd",path:q})},onPreviewFile:(q,xe)=>{N({path:q,name:xe})}})]})}function e0(){if(typeof document>"u")return;const e=document.documentElement,t=document.createElement("div");t.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(t);const n=(t.offsetWidth-t.clientWidth)/2;document.body.removeChild(t),e.style.setProperty("--msgs-gutter",`${n}px`)}Gl();lo(oo());e0();ll.createRoot(document.getElementById("root")).render(s.jsx(l.StrictMode,{children:s.jsx(ac,{children:s.jsx(Zf,{})})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{const e=cr();navigator.serviceWorker.register(`${e}sw.js`,{scope:e}).catch(t=>{console.warn("Service worker registration failed:",t)})});export{kt as F,Rt as T,Le as a,a0 as b,dt as c,n0 as d,en as e,et as f,wl as g,Zt as h,$e as i,_t as r,Mt as u};
|