fourth-spark 0.8.7 → 0.8.8

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.
@@ -427,7 +427,7 @@ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}
427
427
  *
428
428
  * This source code is licensed under the ISC license.
429
429
  * See the LICENSE file in the root directory of this source tree.
430
- */const _3=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Dh=Ae("zap",_3);function ZE(e){var t,a,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(a=ZE(e[t]))&&(s&&(s+=" "),s+=a)}else for(a in e)e[a]&&(s&&(s+=" "),s+=a);return s}function oe(){for(var e,t,a=0,s="",l=arguments.length;a<l;a++)(e=arguments[a])&&(t=ZE(e))&&(s&&(s+=" "),s+=t);return s}const ix=e=>{let t;const a=new Set,s=(h,x)=>{const b=typeof h=="function"?h(t):h;if(!Object.is(b,t)){const y=t;t=x??(typeof b!="object"||b===null)?b:Object.assign({},t,b),a.forEach(T=>T(t,y))}},l=()=>t,f={setState:s,getState:l,getInitialState:()=>m,subscribe:h=>(a.add(h),()=>a.delete(h))},m=t=e(s,l,f);return f},N3=(e=>e?ix(e):ix),S3=e=>e;function v3(e,t=S3){const a=Ku.useSyncExternalStore(e.subscribe,Ku.useCallback(()=>t(e.getState()),[e,t]),Ku.useCallback(()=>t(e.getInitialState()),[e,t]));return Ku.useDebugValue(a),a}const lx=e=>{const t=N3(e),a=s=>v3(t,s);return Object.assign(a,t),a},Wa=(e=>e?lx(e):lx),mm="fs-theme";function JE(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ox(e){return e==="system"?JE():e}function ux(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const Vm=Wa((e,t)=>({preference:localStorage.getItem(mm)??"system",resolved:ox(localStorage.getItem(mm)??"system"),setPreference(a){const s=ox(a);localStorage.setItem(mm,a),ux(a),e({preference:a,resolved:s})},cycle(){const a=["system","light","dark"],s=a[(a.indexOf(t().preference)+1)%a.length];t().setPreference(s)},init(){ux(t().preference);const a=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>{const{preference:l}=t();if(l==="system"){const u=JE();e({resolved:u})}};return a.addEventListener("change",s),()=>a.removeEventListener("change",s)}})),xc="fourth-spark-server-url";function ey(){if(typeof window>"u")return!1;const t=window.Capacitor;return typeof(t==null?void 0:t.isNativePlatform)=="function"&&t.isNativePlatform()}function ty(){return localStorage.getItem(xc)??""}function A3(e){const t=e.replace(/\/+$/,"");t?localStorage.setItem(xc,t):localStorage.removeItem(xc)}function Qm(){return localStorage.getItem(xc)??""}class Qa extends Error{constructor(a,s){super(a);rn(this,"status");this.name="ApiError",this.status=s}}async function Ne(e,t){let a;try{a=await fetch(ty()+e,{...t,headers:{Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers}})}catch(l){throw new Qa(l instanceof Error?l.message:"Network request failed",0)}if(!a.ok){const l=await a.text().catch(()=>"");throw new Qa(l.trim()||`${a.status} ${a.statusText}`,a.status)}if(a.status===204)return;const s=await a.text();if(s)return JSON.parse(s)}function yn(e,...t){if(Array.isArray(e))return e;if(e&&typeof e=="object"){const a=e;for(const s of[...t,"data","items"])if(Array.isArray(a[s]))return a[s]}return[]}async function C3(){return yn(await Ne("/api/repos"),"repos")}async function w3(e,t,a){return Ne("/api/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,localPath:a})})}async function k3(e){return Ne("/api/repos/resolve",{method:"POST",body:JSON.stringify({localPath:e})})}async function R3(e){await Ne(`/api/repos/${encodeURIComponent(e)}`,{method:"DELETE"})}async function O3(e){await Ne(`/api/repos/${encodeURIComponent(e)}/start`,{method:"POST"})}async function I3(e){await Ne(`/api/repos/${encodeURIComponent(e)}/stop`,{method:"POST"})}async function M3(e){return Ne(`/api/repos/${encodeURIComponent(e)}/branches`)}async function D3(e,t){return Ne(`/api/repos/${encodeURIComponent(e)}/checkout`,{method:"POST",body:JSON.stringify({branch:t})})}async function L3(e){return Ne(`/api/repos/${encodeURIComponent(e)}/pull`,{method:"POST"})}function Ke(e){return`/api/repos/${encodeURIComponent(e)}`}async function j3(e){return yn(await Ne(`${Ke(e)}/workspaces`),"workspaces")}async function B3(e,t){await Ne(`${Ke(e)}/workspaces/${encodeURIComponent(t)}`,{method:"DELETE"})}async function P3(e){return Ne(`${Ke(e)}/workspaces/cleanup`,{method:"POST"})}async function U3(e,t){await Ne(`/api/repos/${e}/worktree`,{method:"PATCH",body:JSON.stringify({enabled:t})})}async function H3(e){return yn(await Ne(`${Ke(e)}/sessions`),"sessions")}async function F3(e,t,a,s,l,u,d){return Ne(`${Ke(e)}/sessions`,{method:"POST",body:JSON.stringify({message:t,agent:a,model:s,variant:l,issueId:u,customAgentId:d})})}async function z3(e,t){return Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}`)}async function q3(e,t){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Y3(e,t,a,s,l){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/prompt`,{method:"POST",body:JSON.stringify({content:a,agent:s,model:l})})}async function $3(e,t){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/abort`,{method:"POST"})}async function G3(e,t,a){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/questions/reply`,{method:"POST",body:JSON.stringify({answers:a})})}async function K3(e,t){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/questions/reject`,{method:"POST"})}function V3(e){const t=e,a=t.info;if(a&&typeof a.id=="string"){const s=Array.isArray(t.parts)?t.parts:void 0;return{...a,...s?{parts:s}:{}}}return t}async function Q3(e,t){return yn(await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/messages`),"messages").map(V3)}async function X3(e,t){return yn(await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/todos`),"todos")}async function ny(e,t){return Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/status`)}async function cx(e,t){return Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`)}async function dx(e){return Ne(`${Ke(e)}/sessions/all-links`)}async function W3(e,t,a,s){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"POST",body:JSON.stringify({type:a,targetId:s})})}async function Z3(e,t,a,s){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"DELETE",body:JSON.stringify({type:a,targetId:s})})}async function J3(e){return yn(await Ne(`${Ke(e)}/agents`),"agents")}async function ay(){return yn(await Ne("/api/custom-agents"))}async function ry(e){return Ne("/api/custom-agents",{method:"POST",body:JSON.stringify(e)})}async function sy(e,t){return Ne(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function iy(e){await Ne(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"DELETE"})}async function fx(e){return Ne(`/api/custom-agents/${encodeURIComponent(e)}/export`)}async function eC(e){return Ne("/api/custom-agents/import",{method:"POST",body:JSON.stringify(e)})}async function tC(e){return yn(await Ne(`${Ke(e)}/custom-agents`))}async function nC(e,t){return Ne(`${Ke(e)}/custom-agents`,{method:"POST",body:JSON.stringify(t)})}async function Lh(e){return yn(await Ne(`${Ke(e)}/models`))}async function aC(){return yn(await Ne("/api/prompt-fragments"))}async function rC(e){return Ne("/api/prompt-fragments",{method:"POST",body:JSON.stringify(e)})}async function sC(e,t){return Ne(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function iC(e){await Ne(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"DELETE"})}async function mx(e){return yn(await Ne(`${Ke(e)}/tags`))}async function hx(e,t){return yn(await Ne(`${Ke(e)}/milestones`))}async function px(e,t="open"){return yn(await Ne(`${Ke(e)}/issues?state=${encodeURIComponent(t)}`),"issues")}async function lC(e,t="all"){return Ne(`${Ke(e)}/issues/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function oC(e,t,a){return Ne(`${Ke(e)}/issues`,{method:"POST",body:JSON.stringify({title:t,body:a})})}async function uC(e,t,a){await Ne(`${Ke(e)}/issues/${t}/children`,{method:"POST",body:JSON.stringify({childNumber:a})})}async function ly(e,t,a){return Ne(`${Ke(e)}/issues/${t}`,{method:"PATCH",body:JSON.stringify(a)})}async function gx(e,t){return yn(await Ne(`${Ke(e)}/issues/${t}/pulls`))}async function cC(e,t,a,s=!1){await Ne(`${Ke(e)}/issues/${t}/pulls/${a}/merge`,{method:"POST",body:JSON.stringify({closeIssue:s})})}async function bx(e,t="open"){return yn(await Ne(`${Ke(e)}/pulls?state=${encodeURIComponent(t)}`))}async function dC(e,t="all"){return Ne(`${Ke(e)}/pulls/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function fC(e,t){await Ne(`${Ke(e)}/pulls/${t}/merge`,{method:"POST"})}async function oy(e,t){return yn(await Ne(`${Ke(e)}/pulls/${t}/issues`))}async function mC(e,t,a){await Ne(`${Ke(e)}/pulls/${t}/issues`,{method:"POST",body:JSON.stringify({issueNumber:a})})}async function hC(e,t,a){await Ne(`${Ke(e)}/pulls/${t}/issues/${a}`,{method:"DELETE"})}async function pC(e,t){return Ne(`${Ke(e)}/pulls/${t}/comments`)}async function gC(e,t){return Ne(`${Ke(e)}/issues/${t}/comments`)}async function xx(e,t,a){return Ne(`${Ke(e)}/issues/${t}/comments`,{method:"POST",body:JSON.stringify({body:a})})}async function bC(e,t,a){return Ne(`${Ke(e)}/issues/${t}/polish`,{method:"POST",body:JSON.stringify({draft:a})})}async function Ex(e,t){return Ne(`${Ke(e)}/issues/${t}/draft`)}async function xC(e,t,a){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({title:a})})}async function EC(e,t,a){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({completedAt:a})})}async function yC(){return Ne("/api/agents-md")}async function TC(e){await Ne("/api/agents-md",{method:"PUT",body:JSON.stringify({content:e})})}async function _C(e){return Ne(`/api/repos/${encodeURIComponent(e)}/agents-md`)}async function NC(e,t){await Ne(`/api/repos/${encodeURIComponent(e)}/agents-md`,{method:"PUT",body:JSON.stringify({content:t})})}function SC(e){return`${ty()}${Ke(e)}/events`}async function vC(e){return Ne(`${Ke(e)}/sessions/status`)}async function Fc(){return Ne("/api/settings")}async function Xm(e,t){await Ne(`/api/settings/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({value:t})})}async function Wm(){return Ne("/api/cloud/status")}async function AC(){return Ne("/api/cloud/reload",{method:"POST"})}async function CC(e){try{return(await Ne("/api/cloud/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).connected}catch{return!1}}async function wC(){return yn(await Ne("/api/git-hosts"),"gitHosts")}async function kC(e,t,a,s="gitea"){return Ne("/api/git-hosts",{method:"POST",body:JSON.stringify({host:e,name:t,token:a,platform:s})})}async function RC(e){await Ne(`/api/git-hosts/${encodeURIComponent(e)}`,{method:"DELETE"})}async function uy(){return Ne("/api/usage")}async function cy(e){return Ne("/api/usage/switch",{method:"POST",body:JSON.stringify({accountId:e})})}async function OC(e,t="ios"){await Ne("/api/push/register",{method:"POST",body:JSON.stringify({token:e,platform:t})})}const as="fs-active-repo",Fe=Wa((e,t)=>({repos:[],activeRepoId:localStorage.getItem(as),loading:!1,loadError:null,loadRepos:async()=>{e({loading:!0,loadError:null});try{const a=await C3(),s=t().activeRepoId,l=s&&a.some(d=>d.id===s);e({repos:a,loading:!1,activeRepoId:l?s:a.length>0?a[0].id:null});const u=t().activeRepoId;u?localStorage.setItem(as,u):localStorage.removeItem(as)}catch(a){e({loading:!1,loadError:a instanceof Error?a.message:"Failed to load repos"})}},setActiveRepo:a=>{e({activeRepoId:a}),a?localStorage.setItem(as,a):localStorage.removeItem(as)},addRepo:async(a,s,l)=>{try{const u=await w3(a,s,l);return e(d=>({repos:[...d.repos,u],activeRepoId:u.id})),localStorage.setItem(as,u.id),u}catch(u){return e({loadError:u instanceof Error?u.message:"Failed to add repo"}),null}},removeRepo:async a=>{try{await R3(a)}catch{}e(s=>{const l=s.repos.filter(d=>d.id!==a),u=s.activeRepoId===a?l.length>0?l[0].id:null:s.activeRepoId;return u?localStorage.setItem(as,u):localStorage.removeItem(as),{repos:l,activeRepoId:u}})},updateRepoBranch:(a,s)=>{e(l=>({repos:l.repos.map(u=>u.id===a?{...u,branch:s}:u)}))}})),La=e=>{var t;return((t=e.repos.find(a=>a.id===e.activeRepoId))==null?void 0:t.name)??null},hm="fs-nav-collapsed",pm="fs-session-panel-collapsed",Ec=Wa(e=>({navCollapsed:localStorage.getItem(hm)==="true",sessionPanelCollapsed:localStorage.getItem(pm)==="true",toggleNav(){e(t=>{const a=!t.navCollapsed;return localStorage.setItem(hm,String(a)),{navCollapsed:a}})},toggleSessionPanel(){e(t=>{const a=!t.sessionPanelCollapsed;return localStorage.setItem(pm,String(a)),{sessionPanelCollapsed:a}})},setNavCollapsed(t){localStorage.setItem(hm,String(t)),e({navCollapsed:t})},setSessionPanelCollapsed(t){localStorage.setItem(pm,String(t)),e({sessionPanelCollapsed:t})}})),dy=[{segment:"repos",icon:$v,label:"仓库管理",global:!0},{segment:"run",icon:Uc,label:"运行面板",global:!1},{segment:"issues",icon:mo,label:"Issues",global:!1},{segment:"pulls",icon:ho,label:"PRs",global:!1},{segment:"settings",icon:o3,label:"设置",global:!0}];function fy(e,t,a){return t?`/${e}`:a?`/${encodeURIComponent(a)}/${e}`:`/${e}`}function IC({repoId:e,currentBranch:t}){const a=Fe(C=>C.updateRepoBranch),[s,l]=A.useState(!1),[u,d]=A.useState(null),[f,m]=A.useState(!1),[h,x]=A.useState(null),[b,y]=A.useState(null),T=A.useRef(null),N=A.useCallback(()=>{l(!1),y(null)},[]);A.useEffect(()=>{if(!s)return;const C=R=>{T.current&&!T.current.contains(R.target)&&N()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[s,N]);const v=async()=>{if(s){N();return}l(!0),m(!0),y(null);try{d(await M3(e))}catch{y("加载分支失败")}finally{m(!1)}},S=async C=>{if(!(C===t||h)){x(C),y(null);try{const R=await D3(e,C);a(e,R.branch),N()}catch(R){y(R instanceof Error?R.message:"切换失败")}finally{x(null)}}};return t?o.jsxs("div",{ref:T,className:"relative",children:[o.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 rounded-md bg-elevated px-2 py-1 text-xs text-fg-3 transition-colors hover:bg-blue-500/10 hover:text-blue-600",children:[o.jsx(Ys,{className:"h-3 w-3"}),t,o.jsx(Sr,{className:oe("h-3 w-3 transition-transform",s&&"rotate-180")})]}),s&&o.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1 w-56 overflow-hidden rounded-lg border border-line bg-surface shadow-lg",children:[f?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(Sa,{className:"h-4 w-4 animate-spin text-fg-4"})}):u?o.jsxs("div",{className:"max-h-64 overflow-y-auto py-1",children:[u.local.map(C=>o.jsxs("button",{type:"button",disabled:h!==null,onClick:()=>S(C),className:oe("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors",C===t?"font-medium text-blue-600":"text-fg-2 hover:bg-elevated"),children:[C===t?o.jsx(oa,{className:"h-3 w-3 shrink-0"}):h===C?o.jsx(Sa,{className:"h-3 w-3 shrink-0 animate-spin"}):o.jsx("span",{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"truncate",children:C})]},C)),u.remote.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mx-3 my-1 border-t border-line"}),o.jsx("div",{className:"px-3 py-1 text-[10px] font-medium uppercase tracking-wider text-fg-4",children:"Remote"}),u.remote.map(C=>o.jsxs("button",{type:"button",disabled:h!==null,onClick:()=>S(C),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[h===C?o.jsx(Sa,{className:"h-3 w-3 shrink-0 animate-spin"}):o.jsx("span",{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"truncate",children:C})]},`remote-${C}`))]})]}):null,b&&o.jsx("div",{className:"border-t border-line px-3 py-2 text-xs text-red-500",children:b})]})]}):null}function MC(){const[e,t]=A.useState(null);return A.useEffect(()=>{const a=()=>fetch("/api/health").then(u=>u.json()).then(u=>{u.latestVersion&&u.latestVersion!=="0.8.7"&&t(u.latestVersion)}).catch(()=>{});a();const s=setInterval(a,30*6e4),l=()=>a();return window.addEventListener("focus",l),()=>{clearInterval(s),window.removeEventListener("focus",l)}},[]),e}function DC(){const e=Aa(),t=ca(),a=Fe(b=>b.repos),s=Fe(b=>b.activeRepoId),l=Fe(b=>b.setActiveRepo),u=Vm(b=>b.preference),d=Vm(b=>b.cycle),f=u==="light"?f3:u==="dark"?QA:KA,m=a.find(b=>b.id===s),h=MC(),x=b=>{var N;if(!b)return;l(b);const y=a.find(v=>v.id===b);if(!y)return;const T=((N=t.pathname.match(/\/(run|issues|pulls)/))==null?void 0:N[1])??"run";e(`/${encodeURIComponent(y.name)}/${T}`)};return o.jsx("header",{className:"shrink-0 border-b border-line bg-surface pt-[var(--safe-top)]",children:o.jsxs("div",{className:"flex h-12 items-center justify-between px-4",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(Dh,{className:"h-5 w-5 text-blue-500"}),o.jsx("span",{className:"text-sm font-bold tracking-tight text-fg",children:"Fourth Spark"}),o.jsxs("span",{className:"rounded bg-elevated px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-fg-4",children:["v","0.8.7"]}),h&&o.jsxs("span",{className:"text-[10px] text-amber-500",children:["→ v",h," 可用,运行 ",o.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[a.length>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("select",{value:s??"",onChange:b=>x(b.target.value),className:"rounded-md border border-line bg-base px-2.5 py-1 text-xs text-fg-2 focus:border-blue-500 focus:outline-none",children:a.map(b=>o.jsx("option",{value:b.id,children:b.name},b.id))}),m&&s&&o.jsx(IC,{repoId:s,currentBranch:m.branch})]}),o.jsx("a",{href:"https://github.com/kinminghao/fourth-spark",target:"_blank",rel:"noopener noreferrer","aria-label":"GitHub",className:"flex h-8 w-8 items-center justify-center rounded-md text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:o.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}),o.jsx("button",{type:"button",onClick:d,"aria-label":`主题: ${u}`,className:"flex h-8 w-8 items-center justify-center rounded-md text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:o.jsx(f,{className:"h-4 w-4"})})]})]})})}function LC(){const e=Fe(La),t=Ec(s=>s.navCollapsed),a=Ec(s=>s.toggleNav);return o.jsxs("nav",{className:oe("hidden shrink-0 flex-col border-r border-line bg-surface py-2 transition-[width] duration-200 ease-in-out md:flex",t?"w-14":"w-48"),children:[o.jsx("div",{className:"flex flex-1 flex-col",children:dy.map(s=>o.jsxs(Rh,{to:fy(s.segment,s.global,e),title:t?s.label:void 0,className:({isActive:l})=>oe("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",l?"bg-blue-500/10 font-medium text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:[o.jsx(s.icon,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:oe("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:s.label})]},s.segment))}),o.jsx("button",{type:"button",onClick:a,title:t?"展开导航":"收起导航",className:"mx-2 flex items-center justify-center rounded-md py-2 text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:t?o.jsx(nA,{className:"h-4 w-4"}):o.jsx(eA,{className:"h-4 w-4"})})]})}function jC(){const e=Fe(La);return o.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-30 border-t border-line bg-surface pb-[var(--safe-bottom)] md:hidden",children:o.jsx("div",{className:"flex h-14 items-center justify-around",children:dy.filter(t=>t.segment!=="issues").map(t=>o.jsx(Rh,{to:fy(t.segment,t.global,e),"aria-label":t.label,className:({isActive:a})=>oe("flex h-10 w-10 items-center justify-center rounded-md transition-colors",a?"bg-blue-500/10 text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:o.jsx(t.icon,{className:"h-5 w-5 shrink-0"})},t.segment))})})}function BC(){return o.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-base text-fg",children:[o.jsx(DC,{}),o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsx(LC,{}),o.jsx("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden pb-[calc(3.5rem_+_var(--safe-bottom))] md:pb-0",children:o.jsx(YS,{})})]}),o.jsx(jC,{})]})}function PC({onClose:e}){const[t,a]=A.useState(""),[s,l]=A.useState(""),[u,d]=A.useState(""),[f,m]=A.useState(!1),[h,x]=A.useState(""),b=Fe(S=>S.addRepo),y=s.trim()!==""&&u.trim()!==""&&t.trim()!==""&&!f,T=async S=>{const C=S.trim();if(C){m(!0),x("");try{const R=await k3(C);R.name&&!s.trim()&&l(R.name),R.gitUrl&&!u.trim()&&d(R.gitUrl)}catch(R){const w=R instanceof Error?R.message:"无法解析路径";try{const D=JSON.parse(w);x(D.error??w)}catch{x(w)}}m(!1)}},N=A.useRef(T);N.current=T,A.useEffect(()=>{const S=t.trim();if(!S)return;const C=setTimeout(()=>{N.current(S)},500);return()=>clearTimeout(C)},[t]);const v=async()=>{if(!y)return;x(""),await b(s.trim(),u.trim(),t.trim())&&e()};return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:e,children:o.jsxs("div",{className:"w-full max-w-md rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:S=>S.stopPropagation(),children:[o.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[o.jsx("h2",{className:"text-base font-semibold text-fg",children:"添加仓库"}),o.jsx("button",{type:"button",onClick:e,className:"rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:o.jsx(gt,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{htmlFor:"m-path",className:"text-xs font-medium text-fg-3",children:"本地路径"}),o.jsx("input",{id:"m-path",value:t,onChange:S=>a(S.target.value),onBlur:S=>void T(S.target.value),placeholder:"/Users/you/code/repo",autoFocus:!0,className:"w-full rounded-lg border border-line bg-base px-3 py-2 font-mono text-sm text-fg placeholder:text-fg-5 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20"}),o.jsx("span",{className:"text-[11px] text-fg-5",children:f?"正在读取 Git 信息…":"输入路径后自动读取仓库信息"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{htmlFor:"m-name",className:"text-xs font-medium text-fg-3",children:"名称"}),o.jsx("input",{id:"m-name",value:s,onChange:S=>l(S.target.value),placeholder:"my-project",className:"w-full rounded-lg border border-line bg-base px-3 py-2 text-sm text-fg placeholder:text-fg-5 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{htmlFor:"m-git",className:"text-xs font-medium text-fg-3",children:"Git 远程地址"}),o.jsx("input",{id:"m-git",value:u,onChange:S=>d(S.target.value),placeholder:"https://github.com/org/repo.git",className:"w-full rounded-lg border border-line bg-base px-3 py-2 font-mono text-xs text-fg placeholder:text-fg-5 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20"})]}),h&&o.jsx("p",{className:"rounded-md bg-red-500/10 px-3 py-2 text-xs text-red-500",children:h}),o.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:e,className:"rounded-lg border border-line px-4 py-2 text-sm text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"取消"}),o.jsx("button",{type:"button",onClick:v,disabled:!y,className:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-500 disabled:cursor-not-allowed disabled:bg-fg-6 disabled:text-fg-4",children:"添加仓库"})]})]})]})})}function UC({repoId:e,repoName:t,onClose:a}){const[s,l]=A.useState(""),[u,d]=A.useState(""),[f,m]=A.useState(!0),[h,x]=A.useState(!1),[b,y]=A.useState(null);A.useEffect(()=>{_C(e).then(v=>{l(v.content),d(v.content),m(!1)}).catch(v=>{y(v instanceof Error?v.message:String(v)),m(!1)})},[e]);const T=async()=>{x(!0),y(null);try{await NC(e,s),d(s)}catch(v){y(v instanceof Error?v.message:String(v))}x(!1)},N=s!==u;return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:a,children:o.jsxs("div",{className:"flex w-full max-w-2xl flex-col rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("h2",{className:"text-base font-semibold text-fg",children:[t," — AGENTS.md"]}),o.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"仅对此仓库生效,修改后 opencode 热加载即时生效。"})]}),o.jsx("button",{type:"button",onClick:a,className:"shrink-0 rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:o.jsx(gt,{className:"h-4 w-4"})})]}),b&&o.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-lg bg-red-500/10 px-3 py-2 text-xs text-red-400",children:[o.jsx(Dn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"min-w-0 break-words",children:b})]}),f?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[o.jsx(Sa,{className:"h-5 w-5 fs-spin"}),o.jsx("p",{className:"text-xs",children:"加载中…"})]}):o.jsx("textarea",{value:s,onChange:v=>l(v.target.value),spellCheck:!1,className:"h-96 w-full resize-y rounded-lg border border-line bg-base px-4 py-3 font-mono text-sm leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20",placeholder:`# AGENTS.md
430
+ */const _3=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Dh=Ae("zap",_3);function ZE(e){var t,a,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var l=e.length;for(t=0;t<l;t++)e[t]&&(a=ZE(e[t]))&&(s&&(s+=" "),s+=a)}else for(a in e)e[a]&&(s&&(s+=" "),s+=a);return s}function oe(){for(var e,t,a=0,s="",l=arguments.length;a<l;a++)(e=arguments[a])&&(t=ZE(e))&&(s&&(s+=" "),s+=t);return s}const ix=e=>{let t;const a=new Set,s=(h,x)=>{const b=typeof h=="function"?h(t):h;if(!Object.is(b,t)){const y=t;t=x??(typeof b!="object"||b===null)?b:Object.assign({},t,b),a.forEach(T=>T(t,y))}},l=()=>t,f={setState:s,getState:l,getInitialState:()=>m,subscribe:h=>(a.add(h),()=>a.delete(h))},m=t=e(s,l,f);return f},N3=(e=>e?ix(e):ix),S3=e=>e;function v3(e,t=S3){const a=Ku.useSyncExternalStore(e.subscribe,Ku.useCallback(()=>t(e.getState()),[e,t]),Ku.useCallback(()=>t(e.getInitialState()),[e,t]));return Ku.useDebugValue(a),a}const lx=e=>{const t=N3(e),a=s=>v3(t,s);return Object.assign(a,t),a},Wa=(e=>e?lx(e):lx),mm="fs-theme";function JE(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function ox(e){return e==="system"?JE():e}function ux(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const Vm=Wa((e,t)=>({preference:localStorage.getItem(mm)??"system",resolved:ox(localStorage.getItem(mm)??"system"),setPreference(a){const s=ox(a);localStorage.setItem(mm,a),ux(a),e({preference:a,resolved:s})},cycle(){const a=["system","light","dark"],s=a[(a.indexOf(t().preference)+1)%a.length];t().setPreference(s)},init(){ux(t().preference);const a=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>{const{preference:l}=t();if(l==="system"){const u=JE();e({resolved:u})}};return a.addEventListener("change",s),()=>a.removeEventListener("change",s)}})),xc="fourth-spark-server-url";function ey(){if(typeof window>"u")return!1;const t=window.Capacitor;return typeof(t==null?void 0:t.isNativePlatform)=="function"&&t.isNativePlatform()}function ty(){return localStorage.getItem(xc)??""}function A3(e){const t=e.replace(/\/+$/,"");t?localStorage.setItem(xc,t):localStorage.removeItem(xc)}function Qm(){return localStorage.getItem(xc)??""}class Qa extends Error{constructor(a,s){super(a);rn(this,"status");this.name="ApiError",this.status=s}}async function Ne(e,t){let a;try{a=await fetch(ty()+e,{...t,headers:{Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers}})}catch(l){throw new Qa(l instanceof Error?l.message:"Network request failed",0)}if(!a.ok){const l=await a.text().catch(()=>"");throw new Qa(l.trim()||`${a.status} ${a.statusText}`,a.status)}if(a.status===204)return;const s=await a.text();if(s)return JSON.parse(s)}function yn(e,...t){if(Array.isArray(e))return e;if(e&&typeof e=="object"){const a=e;for(const s of[...t,"data","items"])if(Array.isArray(a[s]))return a[s]}return[]}async function C3(){return yn(await Ne("/api/repos"),"repos")}async function w3(e,t,a){return Ne("/api/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,localPath:a})})}async function k3(e){return Ne("/api/repos/resolve",{method:"POST",body:JSON.stringify({localPath:e})})}async function R3(e){await Ne(`/api/repos/${encodeURIComponent(e)}`,{method:"DELETE"})}async function O3(e){await Ne(`/api/repos/${encodeURIComponent(e)}/start`,{method:"POST"})}async function I3(e){await Ne(`/api/repos/${encodeURIComponent(e)}/stop`,{method:"POST"})}async function M3(e){return Ne(`/api/repos/${encodeURIComponent(e)}/branches`)}async function D3(e,t){return Ne(`/api/repos/${encodeURIComponent(e)}/checkout`,{method:"POST",body:JSON.stringify({branch:t})})}async function L3(e){return Ne(`/api/repos/${encodeURIComponent(e)}/pull`,{method:"POST"})}function Ke(e){return`/api/repos/${encodeURIComponent(e)}`}async function j3(e){return yn(await Ne(`${Ke(e)}/workspaces`),"workspaces")}async function B3(e,t){await Ne(`${Ke(e)}/workspaces/${encodeURIComponent(t)}`,{method:"DELETE"})}async function P3(e){return Ne(`${Ke(e)}/workspaces/cleanup`,{method:"POST"})}async function U3(e,t){await Ne(`/api/repos/${e}/worktree`,{method:"PATCH",body:JSON.stringify({enabled:t})})}async function H3(e){return yn(await Ne(`${Ke(e)}/sessions`),"sessions")}async function F3(e,t,a,s,l,u,d){return Ne(`${Ke(e)}/sessions`,{method:"POST",body:JSON.stringify({message:t,agent:a,model:s,variant:l,issueId:u,customAgentId:d})})}async function z3(e,t){return Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}`)}async function q3(e,t){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Y3(e,t,a,s,l){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/prompt`,{method:"POST",body:JSON.stringify({content:a,agent:s,model:l})})}async function $3(e,t){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/abort`,{method:"POST"})}async function G3(e,t,a){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/questions/reply`,{method:"POST",body:JSON.stringify({answers:a})})}async function K3(e,t){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/questions/reject`,{method:"POST"})}function V3(e){const t=e,a=t.info;if(a&&typeof a.id=="string"){const s=Array.isArray(t.parts)?t.parts:void 0;return{...a,...s?{parts:s}:{}}}return t}async function Q3(e,t){return yn(await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/messages`),"messages").map(V3)}async function X3(e,t){return yn(await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/todos`),"todos")}async function ny(e,t){return Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/status`)}async function cx(e,t){return Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`)}async function dx(e){return Ne(`${Ke(e)}/sessions/all-links`)}async function W3(e,t,a,s){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"POST",body:JSON.stringify({type:a,targetId:s})})}async function Z3(e,t,a,s){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"DELETE",body:JSON.stringify({type:a,targetId:s})})}async function J3(e){return yn(await Ne(`${Ke(e)}/agents`),"agents")}async function ay(){return yn(await Ne("/api/custom-agents"))}async function ry(e){return Ne("/api/custom-agents",{method:"POST",body:JSON.stringify(e)})}async function sy(e,t){return Ne(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function iy(e){await Ne(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"DELETE"})}async function fx(e){return Ne(`/api/custom-agents/${encodeURIComponent(e)}/export`)}async function eC(e){return Ne("/api/custom-agents/import",{method:"POST",body:JSON.stringify(e)})}async function tC(e){return yn(await Ne(`${Ke(e)}/custom-agents`))}async function nC(e,t){return Ne(`${Ke(e)}/custom-agents`,{method:"POST",body:JSON.stringify(t)})}async function Lh(e){return yn(await Ne(`${Ke(e)}/models`))}async function aC(){return yn(await Ne("/api/prompt-fragments"))}async function rC(e){return Ne("/api/prompt-fragments",{method:"POST",body:JSON.stringify(e)})}async function sC(e,t){return Ne(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function iC(e){await Ne(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"DELETE"})}async function mx(e){return yn(await Ne(`${Ke(e)}/tags`))}async function hx(e,t){return yn(await Ne(`${Ke(e)}/milestones`))}async function px(e,t="open"){return yn(await Ne(`${Ke(e)}/issues?state=${encodeURIComponent(t)}`),"issues")}async function lC(e,t="all"){return Ne(`${Ke(e)}/issues/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function oC(e,t,a){return Ne(`${Ke(e)}/issues`,{method:"POST",body:JSON.stringify({title:t,body:a})})}async function uC(e,t,a){await Ne(`${Ke(e)}/issues/${t}/children`,{method:"POST",body:JSON.stringify({childNumber:a})})}async function ly(e,t,a){return Ne(`${Ke(e)}/issues/${t}`,{method:"PATCH",body:JSON.stringify(a)})}async function gx(e,t){return yn(await Ne(`${Ke(e)}/issues/${t}/pulls`))}async function cC(e,t,a,s=!1){await Ne(`${Ke(e)}/issues/${t}/pulls/${a}/merge`,{method:"POST",body:JSON.stringify({closeIssue:s})})}async function bx(e,t="open"){return yn(await Ne(`${Ke(e)}/pulls?state=${encodeURIComponent(t)}`))}async function dC(e,t="all"){return Ne(`${Ke(e)}/pulls/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function fC(e,t){await Ne(`${Ke(e)}/pulls/${t}/merge`,{method:"POST"})}async function oy(e,t){return yn(await Ne(`${Ke(e)}/pulls/${t}/issues`))}async function mC(e,t,a){await Ne(`${Ke(e)}/pulls/${t}/issues`,{method:"POST",body:JSON.stringify({issueNumber:a})})}async function hC(e,t,a){await Ne(`${Ke(e)}/pulls/${t}/issues/${a}`,{method:"DELETE"})}async function pC(e,t){return Ne(`${Ke(e)}/pulls/${t}/comments`)}async function gC(e,t){return Ne(`${Ke(e)}/issues/${t}/comments`)}async function xx(e,t,a){return Ne(`${Ke(e)}/issues/${t}/comments`,{method:"POST",body:JSON.stringify({body:a})})}async function bC(e,t,a){return Ne(`${Ke(e)}/issues/${t}/polish`,{method:"POST",body:JSON.stringify({draft:a})})}async function Ex(e,t){return Ne(`${Ke(e)}/issues/${t}/draft`)}async function xC(e,t,a){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({title:a})})}async function EC(e,t,a){await Ne(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({completedAt:a})})}async function yC(){return Ne("/api/agents-md")}async function TC(e){await Ne("/api/agents-md",{method:"PUT",body:JSON.stringify({content:e})})}async function _C(e){return Ne(`/api/repos/${encodeURIComponent(e)}/agents-md`)}async function NC(e,t){await Ne(`/api/repos/${encodeURIComponent(e)}/agents-md`,{method:"PUT",body:JSON.stringify({content:t})})}function SC(e){return`${ty()}${Ke(e)}/events`}async function vC(e){return Ne(`${Ke(e)}/sessions/status`)}async function Fc(){return Ne("/api/settings")}async function Xm(e,t){await Ne(`/api/settings/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({value:t})})}async function Wm(){return Ne("/api/cloud/status")}async function AC(){return Ne("/api/cloud/reload",{method:"POST"})}async function CC(e){try{return(await Ne("/api/cloud/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).connected}catch{return!1}}async function wC(){return yn(await Ne("/api/git-hosts"),"gitHosts")}async function kC(e,t,a,s="gitea"){return Ne("/api/git-hosts",{method:"POST",body:JSON.stringify({host:e,name:t,token:a,platform:s})})}async function RC(e){await Ne(`/api/git-hosts/${encodeURIComponent(e)}`,{method:"DELETE"})}async function uy(){return Ne("/api/usage")}async function cy(e){return Ne("/api/usage/switch",{method:"POST",body:JSON.stringify({accountId:e})})}async function OC(e,t="ios"){await Ne("/api/push/register",{method:"POST",body:JSON.stringify({token:e,platform:t})})}const as="fs-active-repo",Fe=Wa((e,t)=>({repos:[],activeRepoId:localStorage.getItem(as),loading:!1,loadError:null,loadRepos:async()=>{e({loading:!0,loadError:null});try{const a=await C3(),s=t().activeRepoId,l=s&&a.some(d=>d.id===s);e({repos:a,loading:!1,activeRepoId:l?s:a.length>0?a[0].id:null});const u=t().activeRepoId;u?localStorage.setItem(as,u):localStorage.removeItem(as)}catch(a){e({loading:!1,loadError:a instanceof Error?a.message:"Failed to load repos"})}},setActiveRepo:a=>{e({activeRepoId:a}),a?localStorage.setItem(as,a):localStorage.removeItem(as)},addRepo:async(a,s,l)=>{try{const u=await w3(a,s,l);return e(d=>({repos:[...d.repos,u],activeRepoId:u.id})),localStorage.setItem(as,u.id),u}catch(u){return e({loadError:u instanceof Error?u.message:"Failed to add repo"}),null}},removeRepo:async a=>{try{await R3(a)}catch{}e(s=>{const l=s.repos.filter(d=>d.id!==a),u=s.activeRepoId===a?l.length>0?l[0].id:null:s.activeRepoId;return u?localStorage.setItem(as,u):localStorage.removeItem(as),{repos:l,activeRepoId:u}})},updateRepoBranch:(a,s)=>{e(l=>({repos:l.repos.map(u=>u.id===a?{...u,branch:s}:u)}))}})),La=e=>{var t;return((t=e.repos.find(a=>a.id===e.activeRepoId))==null?void 0:t.name)??null},hm="fs-nav-collapsed",pm="fs-session-panel-collapsed",Ec=Wa(e=>({navCollapsed:localStorage.getItem(hm)==="true",sessionPanelCollapsed:localStorage.getItem(pm)==="true",toggleNav(){e(t=>{const a=!t.navCollapsed;return localStorage.setItem(hm,String(a)),{navCollapsed:a}})},toggleSessionPanel(){e(t=>{const a=!t.sessionPanelCollapsed;return localStorage.setItem(pm,String(a)),{sessionPanelCollapsed:a}})},setNavCollapsed(t){localStorage.setItem(hm,String(t)),e({navCollapsed:t})},setSessionPanelCollapsed(t){localStorage.setItem(pm,String(t)),e({sessionPanelCollapsed:t})}})),dy=[{segment:"repos",icon:$v,label:"仓库管理",global:!0},{segment:"run",icon:Uc,label:"运行面板",global:!1},{segment:"issues",icon:mo,label:"Issues",global:!1},{segment:"pulls",icon:ho,label:"PRs",global:!1},{segment:"settings",icon:o3,label:"设置",global:!0}];function fy(e,t,a){return t?`/${e}`:a?`/${encodeURIComponent(a)}/${e}`:`/${e}`}function IC({repoId:e,currentBranch:t}){const a=Fe(C=>C.updateRepoBranch),[s,l]=A.useState(!1),[u,d]=A.useState(null),[f,m]=A.useState(!1),[h,x]=A.useState(null),[b,y]=A.useState(null),T=A.useRef(null),N=A.useCallback(()=>{l(!1),y(null)},[]);A.useEffect(()=>{if(!s)return;const C=R=>{T.current&&!T.current.contains(R.target)&&N()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[s,N]);const v=async()=>{if(s){N();return}l(!0),m(!0),y(null);try{d(await M3(e))}catch{y("加载分支失败")}finally{m(!1)}},S=async C=>{if(!(C===t||h)){x(C),y(null);try{const R=await D3(e,C);a(e,R.branch),N()}catch(R){y(R instanceof Error?R.message:"切换失败")}finally{x(null)}}};return t?o.jsxs("div",{ref:T,className:"relative",children:[o.jsxs("button",{type:"button",onClick:v,className:"flex items-center gap-1 rounded-md bg-elevated px-2 py-1 text-xs text-fg-3 transition-colors hover:bg-blue-500/10 hover:text-blue-600",children:[o.jsx(Ys,{className:"h-3 w-3"}),t,o.jsx(Sr,{className:oe("h-3 w-3 transition-transform",s&&"rotate-180")})]}),s&&o.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1 w-56 overflow-hidden rounded-lg border border-line bg-surface shadow-lg",children:[f?o.jsx("div",{className:"flex items-center justify-center py-4",children:o.jsx(Sa,{className:"h-4 w-4 animate-spin text-fg-4"})}):u?o.jsxs("div",{className:"max-h-64 overflow-y-auto py-1",children:[u.local.map(C=>o.jsxs("button",{type:"button",disabled:h!==null,onClick:()=>S(C),className:oe("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors",C===t?"font-medium text-blue-600":"text-fg-2 hover:bg-elevated"),children:[C===t?o.jsx(oa,{className:"h-3 w-3 shrink-0"}):h===C?o.jsx(Sa,{className:"h-3 w-3 shrink-0 animate-spin"}):o.jsx("span",{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"truncate",children:C})]},C)),u.remote.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mx-3 my-1 border-t border-line"}),o.jsx("div",{className:"px-3 py-1 text-[10px] font-medium uppercase tracking-wider text-fg-4",children:"Remote"}),u.remote.map(C=>o.jsxs("button",{type:"button",disabled:h!==null,onClick:()=>S(C),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[h===C?o.jsx(Sa,{className:"h-3 w-3 shrink-0 animate-spin"}):o.jsx("span",{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"truncate",children:C})]},`remote-${C}`))]})]}):null,b&&o.jsx("div",{className:"border-t border-line px-3 py-2 text-xs text-red-500",children:b})]})]}):null}function MC(){const[e,t]=A.useState(null);return A.useEffect(()=>{const a=()=>fetch("/api/health").then(u=>u.json()).then(u=>{u.latestVersion&&u.latestVersion!=="0.8.8"&&t(u.latestVersion)}).catch(()=>{});a();const s=setInterval(a,30*6e4),l=()=>a();return window.addEventListener("focus",l),()=>{clearInterval(s),window.removeEventListener("focus",l)}},[]),e}function DC(){const e=Aa(),t=ca(),a=Fe(b=>b.repos),s=Fe(b=>b.activeRepoId),l=Fe(b=>b.setActiveRepo),u=Vm(b=>b.preference),d=Vm(b=>b.cycle),f=u==="light"?f3:u==="dark"?QA:KA,m=a.find(b=>b.id===s),h=MC(),x=b=>{var N;if(!b)return;l(b);const y=a.find(v=>v.id===b);if(!y)return;const T=((N=t.pathname.match(/\/(run|issues|pulls)/))==null?void 0:N[1])??"run";e(`/${encodeURIComponent(y.name)}/${T}`)};return o.jsx("header",{className:"shrink-0 border-b border-line bg-surface pt-[var(--safe-top)]",children:o.jsxs("div",{className:"flex h-12 items-center justify-between px-4",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(Dh,{className:"h-5 w-5 text-blue-500"}),o.jsx("span",{className:"text-sm font-bold tracking-tight text-fg",children:"Fourth Spark"}),o.jsxs("span",{className:"rounded bg-elevated px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-fg-4",children:["v","0.8.8"]}),h&&o.jsxs("span",{className:"text-[10px] text-amber-500",children:["→ v",h," 可用,运行 ",o.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[a.length>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("select",{value:s??"",onChange:b=>x(b.target.value),className:"rounded-md border border-line bg-base px-2.5 py-1 text-xs text-fg-2 focus:border-blue-500 focus:outline-none",children:a.map(b=>o.jsx("option",{value:b.id,children:b.name},b.id))}),m&&s&&o.jsx(IC,{repoId:s,currentBranch:m.branch})]}),o.jsx("a",{href:"https://github.com/kinminghao/fourth-spark",target:"_blank",rel:"noopener noreferrer","aria-label":"GitHub",className:"flex h-8 w-8 items-center justify-center rounded-md text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:o.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:o.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}),o.jsx("button",{type:"button",onClick:d,"aria-label":`主题: ${u}`,className:"flex h-8 w-8 items-center justify-center rounded-md text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:o.jsx(f,{className:"h-4 w-4"})})]})]})})}function LC(){const e=Fe(La),t=Ec(s=>s.navCollapsed),a=Ec(s=>s.toggleNav);return o.jsxs("nav",{className:oe("hidden shrink-0 flex-col border-r border-line bg-surface py-2 transition-[width] duration-200 ease-in-out md:flex",t?"w-14":"w-48"),children:[o.jsx("div",{className:"flex flex-1 flex-col",children:dy.map(s=>o.jsxs(Rh,{to:fy(s.segment,s.global,e),title:t?s.label:void 0,className:({isActive:l})=>oe("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",l?"bg-blue-500/10 font-medium text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:[o.jsx(s.icon,{className:"h-4 w-4 shrink-0"}),o.jsx("span",{className:oe("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:s.label})]},s.segment))}),o.jsx("button",{type:"button",onClick:a,title:t?"展开导航":"收起导航",className:"mx-2 flex items-center justify-center rounded-md py-2 text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:t?o.jsx(nA,{className:"h-4 w-4"}):o.jsx(eA,{className:"h-4 w-4"})})]})}function jC(){const e=Fe(La);return o.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-30 border-t border-line bg-surface pb-[var(--safe-bottom)] md:hidden",children:o.jsx("div",{className:"flex h-14 items-center justify-around",children:dy.map(t=>o.jsx(Rh,{to:fy(t.segment,t.global,e),"aria-label":t.label,className:({isActive:a})=>oe("flex h-10 w-10 items-center justify-center rounded-md transition-colors",a?"bg-blue-500/10 text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:o.jsx(t.icon,{className:"h-5 w-5 shrink-0"})},t.segment))})})}function BC(){return o.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-base text-fg",children:[o.jsx(DC,{}),o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsx(LC,{}),o.jsx("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden pb-[calc(3.5rem_+_var(--safe-bottom))] md:pb-0",children:o.jsx(YS,{})})]}),o.jsx(jC,{})]})}function PC({onClose:e}){const[t,a]=A.useState(""),[s,l]=A.useState(""),[u,d]=A.useState(""),[f,m]=A.useState(!1),[h,x]=A.useState(""),b=Fe(S=>S.addRepo),y=s.trim()!==""&&u.trim()!==""&&t.trim()!==""&&!f,T=async S=>{const C=S.trim();if(C){m(!0),x("");try{const R=await k3(C);R.name&&!s.trim()&&l(R.name),R.gitUrl&&!u.trim()&&d(R.gitUrl)}catch(R){const w=R instanceof Error?R.message:"无法解析路径";try{const D=JSON.parse(w);x(D.error??w)}catch{x(w)}}m(!1)}},N=A.useRef(T);N.current=T,A.useEffect(()=>{const S=t.trim();if(!S)return;const C=setTimeout(()=>{N.current(S)},500);return()=>clearTimeout(C)},[t]);const v=async()=>{if(!y)return;x(""),await b(s.trim(),u.trim(),t.trim())&&e()};return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:e,children:o.jsxs("div",{className:"w-full max-w-md rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:S=>S.stopPropagation(),children:[o.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[o.jsx("h2",{className:"text-base font-semibold text-fg",children:"添加仓库"}),o.jsx("button",{type:"button",onClick:e,className:"rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:o.jsx(gt,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{htmlFor:"m-path",className:"text-xs font-medium text-fg-3",children:"本地路径"}),o.jsx("input",{id:"m-path",value:t,onChange:S=>a(S.target.value),onBlur:S=>void T(S.target.value),placeholder:"/Users/you/code/repo",autoFocus:!0,className:"w-full rounded-lg border border-line bg-base px-3 py-2 font-mono text-sm text-fg placeholder:text-fg-5 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20"}),o.jsx("span",{className:"text-[11px] text-fg-5",children:f?"正在读取 Git 信息…":"输入路径后自动读取仓库信息"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{htmlFor:"m-name",className:"text-xs font-medium text-fg-3",children:"名称"}),o.jsx("input",{id:"m-name",value:s,onChange:S=>l(S.target.value),placeholder:"my-project",className:"w-full rounded-lg border border-line bg-base px-3 py-2 text-sm text-fg placeholder:text-fg-5 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{htmlFor:"m-git",className:"text-xs font-medium text-fg-3",children:"Git 远程地址"}),o.jsx("input",{id:"m-git",value:u,onChange:S=>d(S.target.value),placeholder:"https://github.com/org/repo.git",className:"w-full rounded-lg border border-line bg-base px-3 py-2 font-mono text-xs text-fg placeholder:text-fg-5 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20"})]}),h&&o.jsx("p",{className:"rounded-md bg-red-500/10 px-3 py-2 text-xs text-red-500",children:h}),o.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:e,className:"rounded-lg border border-line px-4 py-2 text-sm text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"取消"}),o.jsx("button",{type:"button",onClick:v,disabled:!y,className:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-500 disabled:cursor-not-allowed disabled:bg-fg-6 disabled:text-fg-4",children:"添加仓库"})]})]})]})})}function UC({repoId:e,repoName:t,onClose:a}){const[s,l]=A.useState(""),[u,d]=A.useState(""),[f,m]=A.useState(!0),[h,x]=A.useState(!1),[b,y]=A.useState(null);A.useEffect(()=>{_C(e).then(v=>{l(v.content),d(v.content),m(!1)}).catch(v=>{y(v instanceof Error?v.message:String(v)),m(!1)})},[e]);const T=async()=>{x(!0),y(null);try{await NC(e,s),d(s)}catch(v){y(v instanceof Error?v.message:String(v))}x(!1)},N=s!==u;return o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:a,children:o.jsxs("div",{className:"flex w-full max-w-2xl flex-col rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsxs("h2",{className:"text-base font-semibold text-fg",children:[t," — AGENTS.md"]}),o.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"仅对此仓库生效,修改后 opencode 热加载即时生效。"})]}),o.jsx("button",{type:"button",onClick:a,className:"shrink-0 rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:o.jsx(gt,{className:"h-4 w-4"})})]}),b&&o.jsxs("div",{className:"mb-3 flex items-start gap-2 rounded-lg bg-red-500/10 px-3 py-2 text-xs text-red-400",children:[o.jsx(Dn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"min-w-0 break-words",children:b})]}),f?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[o.jsx(Sa,{className:"h-5 w-5 fs-spin"}),o.jsx("p",{className:"text-xs",children:"加载中…"})]}):o.jsx("textarea",{value:s,onChange:v=>l(v.target.value),spellCheck:!1,className:"h-96 w-full resize-y rounded-lg border border-line bg-base px-4 py-3 font-mono text-sm leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20",placeholder:`# AGENTS.md
431
431
 
432
432
  在此编写该仓库的 Agent 指令…`}),o.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:a,className:"rounded-lg border border-line px-4 py-2 text-sm text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"关闭"}),o.jsxs("button",{type:"button",onClick:()=>void T(),disabled:h||!N,className:"flex items-center gap-1.5 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-40",children:[o.jsx(Hc,{className:"h-3.5 w-3.5"}),h?"保存中…":"保存"]})]})]})})}const Zm=1024,Jm=Zm*1024,yx=Jm*1024;function Tx(e){return!e||e<=0?"0 B":e<Zm?`${e} B`:e<Jm?`${(e/Zm).toFixed(1)} KB`:e<yx?`${(e/Jm).toFixed(1)} MB`:`${(e/yx).toFixed(2)} GB`}const gm="ws/";function HC({repoId:e}){const[t,a]=A.useState(!1),[s,l]=A.useState(null),[u,d]=A.useState(!1),[f,m]=A.useState(null),[h,x]=A.useState(null),[b,y]=A.useState(!1),T=async()=>{d(!0),m(null);try{const R=await j3(e);l(R)}catch(R){m(R instanceof Qa?R.message:"加载失败")}d(!1)};A.useEffect(()=>{t&&s===null&&T()},[t]);const N=async R=>{x(R);try{await B3(e,R),await T()}catch(w){m(w instanceof Qa?w.message:"删除失败")}x(null)},v=async()=>{y(!0);try{await P3(e),await T()}catch(R){m(R instanceof Qa?R.message:"清理失败")}y(!1)},S=(s==null?void 0:s.length)??0,C=(s==null?void 0:s.reduce((R,w)=>R+(w.diskUsage||0),0))??0;return o.jsxs("div",{className:"mt-3 border-t border-line pt-3",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>a(R=>!R),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left text-xs font-medium text-fg-3 transition-colors hover:text-fg-2",children:[t?o.jsx(Zv,{className:"h-3 w-3 shrink-0"}):o.jsx(Sr,{className:"h-3 w-3 shrink-0"}),o.jsx(Ys,{className:"h-3 w-3 shrink-0 text-fg-5"}),o.jsx("span",{children:"工作空间"}),s!==null&&o.jsxs("span",{className:"text-fg-5",children:["(",S,") · ",Tx(C)]})]}),t&&S>0&&o.jsxs("button",{type:"button",onClick:()=>void v(),disabled:b,className:"flex h-6 shrink-0 items-center gap-1 rounded border border-line px-2 text-xs text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2 disabled:opacity-50",children:[b?o.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):null,"清理已合并"]})]}),t&&o.jsxs("div",{className:"mt-2",children:[f&&o.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 rounded border border-red-500/30 bg-red-500/5 px-2 py-1 text-xs text-red-600",children:[o.jsx("span",{className:"truncate",children:f}),o.jsx("button",{type:"button",onClick:()=>m(null),className:"shrink-0 rounded p-0.5 transition-colors hover:bg-red-500/10",children:o.jsx(gt,{className:"h-3 w-3"})})]}),u&&s===null?o.jsx("div",{className:"flex justify-center py-3",children:o.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-fg-5 border-t-transparent"})}):S===0?o.jsx("p",{className:"py-2 text-center text-xs text-fg-5",children:"暂无工作空间"}):o.jsx("ul",{className:"space-y-1",children:s==null?void 0:s.map(R=>{const w=R.branch.startsWith(gm),D=w?R.branch.slice(gm.length):R.branch,K=R.status==="active"?"bg-emerald-500/10 text-emerald-600":R.status==="idle"?"bg-amber-500/10 text-amber-600":"bg-fg-6/30 text-fg-4",L=R.status==="active"?"活跃":R.status==="idle"?"空闲":R.status==="merged"?"已合并":R.status==="stale"?"陈旧":R.status,M=R.status!=="active";return o.jsxs("li",{className:"flex items-center gap-2 rounded-md border border-line bg-elevated/40 px-2 py-1.5 text-xs",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[R.running&&R.port&&o.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",title:`运行中 :${R.port}`}),o.jsxs("span",{className:"min-w-0 truncate font-mono",children:[w&&o.jsx("span",{className:"text-fg-5",children:gm}),o.jsx("span",{className:"text-fg-2",children:D})]})]}),o.jsx("span",{className:oe("shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium",K),children:L}),o.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-fg-5",children:[o.jsx(RA,{className:"h-2.5 w-2.5"}),Tx(R.diskUsage)]}),o.jsx("button",{type:"button",onClick:()=>void N(R.id),disabled:!M||h===R.id,title:M?"删除工作空间":"活跃工作空间无法删除",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-fg-5 transition-colors hover:bg-red-500/10 hover:text-red-500 disabled:cursor-not-allowed disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-fg-5",children:h===R.id?o.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):o.jsx(zs,{className:"h-3 w-3"})})]},R.id)})})]})]})}function FC(){const e=Fe(w=>w.repos),t=Fe(w=>w.activeRepoId),a=Fe(w=>w.setActiveRepo),s=Fe(w=>w.removeRepo),l=Fe(w=>w.loadRepos),[u,d]=A.useState(!1),[f,m]=A.useState(null),[h,x]=A.useState(null),[b,y]=A.useState(null),[T,N]=A.useState(null),[v,S]=A.useState(null),C=async(w,D)=>{x(w);try{D?await I3(w):await O3(w),await l()}catch{}x(null)},R=async w=>{y(w),N(null);try{await L3(w),await l()}catch(D){let K="拉取失败";if(D instanceof Qa)try{K=JSON.parse(D.message).error??D.message}catch{K=D.message}N(K)}y(null)};return o.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[o.jsxs("div",{className:"mx-auto max-w-4xl",children:[o.jsxs("div",{className:"mb-6 flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("h1",{className:"text-lg font-semibold text-fg",children:"仓库管理"}),o.jsx("p",{className:"mt-0.5 text-sm text-fg-4",children:"管理代码仓库,每个仓库对应一个独立的 Agent 运行环境"})]}),o.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex shrink-0 items-center gap-1.5 rounded-lg bg-blue-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-500 md:px-4",children:[o.jsx(Xa,{className:"h-4 w-4"}),o.jsx("span",{className:"hidden md:inline",children:"添加仓库"})]})]}),T&&o.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 rounded-lg border border-red-500/30 bg-red-500/5 px-4 py-2.5 text-sm text-red-600",children:[o.jsx("span",{children:T}),o.jsx("button",{type:"button",onClick:()=>N(null),className:"shrink-0 rounded p-0.5 transition-colors hover:bg-red-500/10",children:o.jsx(gt,{className:"h-3.5 w-3.5"})})]}),e.length===0?o.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed border-line-hard py-16 text-center",children:[o.jsx("div",{className:"rounded-full bg-elevated p-3",children:o.jsx(Xa,{className:"h-6 w-6 text-fg-4"})}),o.jsx("p",{className:"text-sm font-medium text-fg-3",children:"暂无代码仓库"}),o.jsx("p",{className:"text-xs text-fg-5",children:"添加一个本地仓库开始使用"}),o.jsx("button",{type:"button",onClick:()=>d(!0),className:"mt-2 rounded-lg border border-line px-4 py-2 text-sm text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"添加仓库"})]}):o.jsx(o.Fragment,{children:o.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:e.map(w=>{const D=w.id===t;return o.jsxs("div",{className:oe("rounded-xl border p-4 transition-colors",D?"border-blue-500/40 bg-blue-500/5":"border-line"),children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>a(w.id),className:"flex min-w-0 items-center gap-2 text-left",children:[D?o.jsx(mo,{className:"h-4 w-4 shrink-0 text-blue-500"}):o.jsx(lA,{className:"h-4 w-4 shrink-0 text-fg-5"}),o.jsx("span",{className:oe("truncate font-medium",D?"text-fg":"text-fg-2"),children:w.name})]}),o.jsxs("span",{className:oe("inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium",w.running?"bg-emerald-500/10 text-emerald-600":"bg-fg-6/30 text-fg-4"),children:[o.jsx("span",{className:oe("h-1.5 w-1.5 rounded-full",w.running?"bg-emerald-500":"bg-fg-5")}),w.running?"运行中":"已停止"]})]}),o.jsxs("dl",{className:"mt-3 space-y-1 font-mono text-xs text-fg-4",children:[o.jsxs("div",{className:"flex gap-2",children:[o.jsx("dt",{className:"shrink-0 text-fg-5",children:"Git"}),o.jsx("dd",{className:"min-w-0 truncate",children:w.gitUrl})]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("dt",{className:"shrink-0 text-fg-5",children:"路径"}),o.jsxs("dd",{className:"flex min-w-0 items-center gap-1.5",children:[o.jsx("span",{className:"truncate",children:w.localPath}),o.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(w.localPath),title:"复制路径",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:o.jsx(hc,{className:"h-3 w-3"})})]})]}),w.running&&w.port&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("dt",{className:"shrink-0 text-fg-5",children:"直连"}),o.jsxs("dd",{className:"flex min-w-0 items-center gap-1.5",children:[o.jsxs("a",{href:`http://127.0.0.1:${w.port}`,target:"_blank",rel:"noopener noreferrer",className:"truncate text-blue-500 hover:underline",children:["127.0.0.1:",w.port]}),o.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(`http://127.0.0.1:${w.port}`),title:"复制链接",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:o.jsx(hc,{className:"h-3 w-3"})})]})]})]}),o.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:async()=>{await U3(w.id,!w.worktreeEnabled),l()},className:oe("flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border px-2.5 text-xs font-medium transition-colors",w.worktreeEnabled?"border-violet-500/30 text-violet-600 hover:bg-violet-500/10":"border-line text-fg-4 hover:bg-elevated hover:text-fg-2"),title:w.worktreeEnabled?"Worktree 已开启":"Worktree 已关闭",children:[o.jsx(Ys,{className:"h-3 w-3"}),"Worktree"]}),o.jsxs("button",{type:"button",onClick:()=>S({id:w.id,name:w.name}),className:"flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-line px-2.5 text-xs font-medium text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:[o.jsx(YE,{className:"h-3 w-3"}),"配置"]}),o.jsx("button",{type:"button",onClick:()=>void R(w.id),disabled:b===w.id,className:"flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-blue-500/30 px-2.5 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-500/10 disabled:opacity-50",children:b===w.id?o.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):o.jsxs(o.Fragment,{children:[o.jsx(Dv,{className:"h-3 w-3"}),"拉取"]})}),o.jsx("button",{type:"button",onClick:()=>void C(w.id,w.running),disabled:h===w.id,className:oe("flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md border text-xs font-medium transition-colors disabled:opacity-50",w.running?"border-amber-500/30 text-amber-600 hover:bg-amber-500/10":"border-emerald-500/30 text-emerald-600 hover:bg-emerald-500/10"),children:h===w.id?o.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):w.running?o.jsxs(o.Fragment,{children:[o.jsx(KE,{className:"h-3 w-3 fill-current"}),"停止"]}):o.jsxs(o.Fragment,{children:[o.jsx(Uc,{className:"h-3 w-3 fill-current"}),"启动"]})}),f===w.id?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>{s(w.id),m(null)},className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-red-500/30 text-red-500 transition-colors hover:bg-red-500/10",children:o.jsx(oa,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:()=>m(null),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line text-fg-4 transition-colors hover:bg-elevated",children:o.jsx(gt,{className:"h-3.5 w-3.5"})})]}):o.jsx("button",{type:"button",onClick:()=>m(w.id),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line text-fg-5 transition-colors hover:bg-red-500/10 hover:text-red-500",children:o.jsx(zs,{className:"h-3.5 w-3.5"})})]}),w.worktreeEnabled&&o.jsx(HC,{repoId:w.id})]},w.id)})})}),o.jsxs("p",{className:"mt-3 text-xs text-fg-5",children:[e.length," 个仓库"]})]}),u&&o.jsx(PC,{onClose:()=>d(!1)}),v&&o.jsx(UC,{repoId:v.id,repoName:v.name,onClose:()=>S(null)})]})}const zC=new Set(["tool","tool-use","tool_use","tool-call","tool_call","tool-result","tool_result"]),qC=new Set(["thinking","reasoning","reason"]),YC=new Set(["text","output_text","message"]);function jh(e){var a;const t=((a=e.type)==null?void 0:a.toLowerCase())??"";return zC.has(t)||e.toolName!=null||e.tool!=null?"tool":qC.has(t)?"thinking":YC.has(t)||e.content!=null||e.text!=null?"text":"other"}function yc(e){return e.content??e.text??""}function my(e){return e.toolName??e.tool??"tool"}function zc(e){var t;return e.input??((t=e.state)==null?void 0:t.input)}function Bh(e){var t;return e.output??((t=e.state)==null?void 0:t.output)}function Ph(e){var a,s,l;const t=(s=(a=e.state)==null?void 0:a.status)==null?void 0:s.toLowerCase();return t==="completed"||t==="done"||t==="success"?"completed":t==="error"||t==="failed"||((l=e.state)==null?void 0:l.error)!=null?"error":t==="pending"||t==="queued"?"pending":t==="running"||t==="in_progress"?"running":Bh(e)!=null?"completed":"running"}function _x(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Pi(e){const t=e==null?void 0:e.toLowerCase();return t==="in_progress"||t==="in-progress"||t==="active"?"in_progress":t==="completed"||t==="done"||t==="complete"?"completed":t==="cancelled"||t==="canceled"?"cancelled":"pending"}function $C(e){return e.filter(t=>Pi(t.status)==="completed").length}function po(e){const t=my(e).toLowerCase();return t==="question"||t==="mcp_question"}function GC(e){const t=zc(e);if(!t||typeof t!="object")return null;const a=t;return Array.isArray(a.questions)?a.questions:null}function Tc(e){if(!po(e))return!1;const t=Ph(e);return t==="pending"||t==="running"}const KC=/\bses_[a-zA-Z0-9]+/;function VC(e){var l;const t=zc(e);if(t&&typeof t=="object"){const u=t;if(typeof u.task_id=="string"&&u.task_id.startsWith("ses_"))return u.task_id}const a=(l=e.state)==null?void 0:l.metadata;if(a){const u=a.session_id??a.sessionId;if(typeof u=="string"&&u.startsWith("ses_"))return u}const s=Bh(e);if(typeof s=="string"){const u=KC.exec(s);if(u)return u[0]}if(s&&typeof s=="object"){const u=s,d=u.session_id??u.sessionId??u.task_id;if(typeof d=="string"&&d.startsWith("ses_"))return d}return null}const QC=["Sisyphus","Prometheus","Atlas"];function XC(e){const t=(e.name||e.id||"").toLowerCase();return QC.some(a=>t.startsWith(a.toLowerCase()))}const WC=Wa(e=>({agents:[],loaded:!1,loadAgents:async()=>{const t=Fe.getState().activeRepoId;if(!t){e({agents:[],loaded:!0});return}try{const a=await J3(t);e({agents:a.filter(XC),loaded:!0})}catch{e({loaded:!0})}}}));let ZC=0;const Yt=Wa(e=>({toasts:[],addToast:(t,a="info",s,l)=>{const u=(l==null?void 0:l.id)??`toast-${++ZC}-${Date.now()}`;e(d=>d.toasts.some(f=>f.id===u)?d:{toasts:[...d.toasts,{id:u,message:t,variant:a,sessionId:s,persistent:l==null?void 0:l.persistent}]}),l!=null&&l.persistent||setTimeout(()=>{e(d=>({toasts:d.toasts.filter(f=>f.id!==u)}))},4e3)},removeToast:t=>{e(a=>({toasts:a.toasts.filter(s=>s.id!==t)}))}}));function hy(e){return`question-${e}`}function bm(e,t){const a=t.find(l=>l.id===e),s=(a==null?void 0:a.title)||e.slice(-8);Yt.getState().addToast(`${s} — 等待回复`,"warning",e,{id:hy(e),persistent:!0})}function JC(e){var t;for(const a of e)if((t=a.parts)!=null&&t.some(s=>po(s)&&Tc(s)))return!0;return!1}const go=[],_c=[],Nx=[],Ds={};function Sx(e){return e.id??e.callID}function $n(){return Fe.getState().activeRepoId}const Ie=Wa((e,t)=>({sessions:[],activeSessionId:null,messages:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},sessionFilter:"all",loadingSessions:!1,loadError:null,sendError:null,setSessionFilter:a=>e({sessionFilter:a}),toggleSessionComplete:async a=>{const s=$n();if(!s)return;const l=t().sessions.find(d=>d.id===a);if(!l)return;const u=l.completedAt?null:Date.now();e(d=>({sessions:d.sessions.map(f=>f.id===a?{...f,completedAt:u??void 0}:f)}));try{await EC(s,a,u)}catch{await t().loadSessions()}},loadSessions:async()=>{const a=$n();if(!a){e({sessions:[],loadingSessions:!1});return}e({loadingSessions:!0,loadError:null});try{const[s,l]=await Promise.all([H3(a),dx(a).catch(()=>null)]),u={sessions:s,loadingSessions:!1};l&&(u.allSessionLinks=l),e(u)}catch(s){e({loadingSessions:!1,loadError:s instanceof Error?s.message:"Failed to load sessions"})}},createSession:async(a,s,l,u,d,f)=>{const m=$n();if(!m)return null;e({sendError:null});try{const h=await F3(m,a,s,l,u,d,f);return e(x=>({sessions:[h,...x.sessions.filter(b=>b.id!==h.id)],activeSessionId:h.id,messages:{...x.messages,[h.id]:[]}})),t().setSessionStatus(h.id,"busy"),h}catch(h){return e({sendError:h instanceof Error?h.message:"Failed to create session"}),null}},setActiveSession:async a=>{$n()&&(e({activeSessionId:a,sendError:null}),await t().refreshSessionData(a))},refreshSessionData:async a=>{const s=$n();if(!s)return;const[l,u,d,f,m]=await Promise.allSettled([Q3(s,a),X3(s,a),ny(s,a),z3(s,a),cx(s,a)]);e(h=>{const x={};if(l.status==="fulfilled"&&(x.messages={...h.messages,[a]:l.value}),u.status==="fulfilled"&&(x.todos={...h.todos,[a]:u.value}),d.status==="fulfilled"&&(x.sessionStatuses={...h.sessionStatuses,[a]:d.value.type}),f.status==="fulfilled"){const b=f.value;x.sessions=h.sessions.map(y=>y.id===a?{...y,...b}:y)}return m.status==="fulfilled"&&(x.sessionLinks={...h.sessionLinks,[a]:m.value}),x}),l.status==="fulfilled"&&JC(l.value)&&bm(a,t().sessions)},refreshSessionLinks:async a=>{const s=$n();if(s)try{const[l,u]=await Promise.all([cx(s,a),dx(s).catch(()=>null)]);e(d=>{const f={sessionLinks:{...d.sessionLinks,[a]:l}};return u&&(f.allSessionLinks=u),f})}catch{}},addLink:async(a,s,l)=>{const u=$n();if(!u)return!1;try{return await W3(u,a,s,l),await t().refreshSessionLinks(a),!0}catch{return!1}},removeLink:async(a,s,l)=>{const u=$n();if(!u)return!1;try{return await Z3(u,a,s,l),await t().refreshSessionLinks(a),!0}catch{return!1}},deleteSession:async a=>{const s=$n();if(s)try{await q3(s,a)}catch{}delete Ds[a],e(l=>{const{[a]:u,...d}=l.messages,{[a]:f,...m}=l.todos,{[a]:h,...x}=l.sessionStatuses,{[a]:b,...y}=l.errorReasons,{[a]:T,...N}=l.queuedMessageIds,{[a]:v,...S}=l.sessionLinks,{[a]:C,...R}=l.allSessionLinks;return{sessions:l.sessions.filter(w=>w.id!==a),messages:d,todos:m,sessionStatuses:x,errorReasons:y,queuedMessageIds:N,sessionLinks:S,allSessionLinks:R,activeSessionId:l.activeSessionId===a?null:l.activeSessionId}})},sendMessage:async(a,s)=>{const l=$n(),u=t().activeSessionId;if(!l||!u)return!1;const d=t().sessions.find(m=>m.id===u),f=t().sessionStatuses[u]==="busy";e({sendError:null}),f||t().setSessionStatus(u,"busy");try{const m=WC.getState(),h=d!=null&&d.agent&&m.loaded&&m.agents.some(x=>x.name===d.agent||x.id===d.agent)?d.agent:void 0;return await Y3(l,u,a,h,s),f&&(Ds[u]=(Ds[u]||0)+1),!0}catch(m){return e({sendError:m instanceof Error?m.message:"Failed to send message"}),f||t().setSessionStatus(u,"idle"),!1}},replyQuestion:async a=>{const s=$n(),l=t().activeSessionId;if(!(!s||!l))try{await G3(s,l,a)}catch(u){e({sendError:u instanceof Error?u.message:"Failed to reply to question"})}},rejectQuestion:async()=>{const a=$n(),s=t().activeSessionId;if(!(!a||!s))try{await K3(a,s)}catch{}},abortSession:async()=>{const a=$n(),s=t().activeSessionId;if(!(!a||!s)){try{await $3(a,s)}catch{}t().setSessionStatus(s,"idle")}},clearSessions:()=>{for(const a of Object.keys(Ds))delete Ds[a];e({sessions:[],activeSessionId:null,messages:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},loadError:null,sendError:null})},updateMessage:(a,s)=>{var l;e(u=>{const d=u.messages[a]??[],f=d.findIndex(x=>x.id===s.id);let m,h=u.queuedMessageIds;if(f>=0){const x={...d[f],...s};(!s.parts||s.parts.length===0)&&d[f].parts&&(x.parts=d[f].parts),m=[...d],m[f]=x}else{m=[...d,s];const x=Ds[a]||0;if(s.role==="user"&&x>0){const b=[...h[a]??[]];b.push(s.id),h={...h,[a]:b},Ds[a]=x-1}else if(s.role==="assistant"){const b=h[a];b&&b.length>0&&(h={...h,[a]:b.slice(1)})}}return{messages:{...u.messages,[a]:m},queuedMessageIds:h}}),(l=s.parts)!=null&&l.some(u=>po(u)&&Tc(u))&&bm(a,t().sessions)},updateMessagePart:(a,s,l)=>{e(u=>{const d=u.messages[a]??[],f=d.findIndex(N=>N.id===s),m=f>=0?d[f]:{id:s,role:"assistant"},h=m.parts?[...m.parts]:[],x=Sx(l),b=x!=null?h.findIndex(N=>Sx(N)===x):-1;b>=0?h[b]={...h[b],...l}:h.push(l);const y={...m,parts:h},T=f>=0?[...d]:[...d,y];return f>=0&&(T[f]=y),{messages:{...u.messages,[a]:T}}}),po(l)&&Tc(l)&&bm(a,t().sessions)},appendMessagePartDelta:(a,s,l,u)=>{e(d=>{const f=d.messages[a]??[],m=f.findIndex(N=>N.id===s),h=m>=0?f[m]:{id:s,role:"assistant"},x=h.parts?[...h.parts]:[],b=x.findIndex(N=>N.id===l);if(b>=0){const N=x[b],v=yc(N)+u;x[b]=N.content!=null?{...N,content:v}:{...N,text:v}}else x.push({id:l,type:"text",text:u});const y={...h,parts:x},T=m>=0?[...f]:[...f,y];return m>=0&&(T[m]=y),{messages:{...d.messages,[a]:T}}})},updateTodos:(a,s)=>{e(l=>({todos:{...l.todos,[a]:s}}))},updateSessionInfo:a=>{e(s=>s.sessions.some(u=>u.id===a.id)?{sessions:s.sessions.map(u=>u.id===a.id?{...u,...a}:u)}:{sessions:[a,...s.sessions]})},setSessionStatus:(a,s,l)=>{const u=t().sessionStatuses[a];if(u!==s){const d=t().sessions.find(m=>m.id===a),f=(d==null?void 0:d.title)||a.slice(-8);if(s==="idle"&&u!==void 0&&u!=="idle")Yt.getState().removeToast(hy(a)),Yt.getState().addToast(`${f} — 完成`,"success",a);else if(s==="busy"&&(u===void 0||u==="idle"))Yt.getState().addToast(`${f} — 开始运行`,"info",a);else if(s==="retry")Yt.getState().addToast(`${f} — 进入重试`,"warning",a);else if(s==="error"){const m=l?`${f} — 错误: ${l}`:`${f} — 发生错误`;Yt.getState().addToast(m,"error",a)}}e(d=>{const f=l?{...d.errorReasons,[a]:l}:s!=="error"?(()=>{const{[a]:m,...h}=d.errorReasons;return h})():d.errorReasons;return{sessionStatuses:{...d.sessionStatuses,[a]:s},errorReasons:f}})},bulkSetStatuses:a=>{e({sessionStatuses:{...t().sessionStatuses,...a}})},renameSession:async(a,s)=>{const l=$n();if(l){e(u=>({sessions:u.sessions.map(d=>d.id===a?{...d,title:s}:d)}));try{await xC(l,a,s)}catch{await t().loadSessions()}}}})),Ge=Wa((e,t)=>({issues:[],tags:[],tagFilterMode:new Map,milestones:[],selectedMilestoneId:null,loaded:!1,syncing:!1,selectedIssueId:null,previewIssueId:null,matchingParentId:null,matchingCandidateId:null,pendingDraft:null,clearIssues:()=>e({issues:[],tags:[],tagFilterMode:new Map,milestones:[],selectedMilestoneId:null,loaded:!1,selectedIssueId:null,previewIssueId:null,matchingParentId:null,matchingCandidateId:null,pendingDraft:null}),setSelectedIssue:a=>e({selectedIssueId:a}),setPreviewIssue:a=>e({previewIssueId:a}),setPendingDraft:a=>e({pendingDraft:a}),enterMatchMode:a=>e({matchingParentId:a,matchingCandidateId:null,previewIssueId:null}),exitMatchMode:()=>{const a=t().matchingParentId;e({matchingParentId:null,matchingCandidateId:null,previewIssueId:a})},setMatchCandidate:a=>e({matchingCandidateId:a}),linkChild:async(a,s)=>{var u;const l=Fe.getState().activeRepoId;if(!l)return!1;try{await uC(l,a,s);const d=(u=t().issues.find(f=>f.number===a))==null?void 0:u.id;return d&&e(f=>({issues:f.issues.map(m=>m.number===s?{...m,parentId:d}:m),matchingCandidateId:null})),!0}catch{return!1}},updateIssueState:async(a,s)=>{const l=Fe.getState().activeRepoId;if(!l)return!1;try{const u=await ly(l,a,{state:s});return e(d=>({issues:d.issues.map(f=>f.number===a?{...f,state:u.state}:f)})),!0}catch{return!1}},loadIssues:async()=>{const a=Fe.getState().activeRepoId;if(!a){e({issues:[],loaded:!0});return}try{const s=await px(a,"all");e({issues:s,loaded:!0})}catch{e({loaded:!0})}},syncIssues:async()=>{const a=Fe.getState().activeRepoId;if(a){e({syncing:!0});try{await lC(a);const[s,l,u]=await Promise.all([px(a,"all"),mx(a),hx(a)]);e({issues:s,tags:l,milestones:u,syncing:!1})}catch(s){e({syncing:!1});let l="同步 Issue 失败";if(s instanceof Qa)try{const u=JSON.parse(s.message);u.error&&(l=u.error)}catch{s.message&&(l=s.message)}Yt.getState().addToast(l,"error")}}},createIssue:async(a,s)=>{const l=Fe.getState().activeRepoId;if(!l)return null;try{const u=await oC(l,a,s);return e(d=>({issues:[u,...d.issues]})),u}catch{return null}},loadTags:async()=>{const a=Fe.getState().activeRepoId;if(!a){e({tags:[]});return}try{const s=await mx(a);e({tags:s})}catch{}},cycleTagFilter:a=>{e(s=>{const l=new Map(s.tagFilterMode),u=l.get(a);return u?u==="include"?l.set(a,"exclude"):l.delete(a):l.set(a,"include"),{tagFilterMode:l}})},clearTagFilter:()=>e({tagFilterMode:new Map}),loadMilestones:async()=>{const a=Fe.getState().activeRepoId;if(!a){e({milestones:[]});return}try{const s=await hx(a);e({milestones:s})}catch{}},setMilestoneFilter:a=>e({selectedMilestoneId:a})})),oc=Wa(e=>({drafts:{},setDraft:(t,a)=>e(s=>{if(!a.trim()){const{[t]:l,...u}=s.drafts;return{drafts:u}}return{drafts:{...s.drafts,[t]:a}}}),clearDraft:t=>e(a=>{const{[t]:s,...l}=a.drafts;return{drafts:l}})}));function vx(e){const t=[],a=String(e||"");let s=a.indexOf(","),l=0,u=!1;for(;!u;){s===-1&&(s=a.length,u=!0);const d=a.slice(l,s).trim();(d||!u)&&t.push(d),l=s+1,s=a.indexOf(",",l)}return t}function py(e,t){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const ew=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nw={};function Ax(e,t){return(nw.jsx?tw:ew).test(e)}const aw=/[ \t\n\f\r]/g;function rw(e){return typeof e=="object"?e.type==="text"?Cx(e.value):!1:Cx(e)}function Cx(e){return e.replace(aw,"")===""}class No{constructor(t,a,s){this.normal=a,this.property=t,s&&(this.space=s)}}No.prototype.normal={};No.prototype.property={};No.prototype.space=void 0;function gy(e,t){const a={},s={};for(const l of e)Object.assign(a,l.property),Object.assign(s,l.normal);return new No(a,s,t)}function bo(e){return e.toLowerCase()}class Qn{constructor(t,a){this.attribute=a,this.property=t}}Qn.prototype.attribute="";Qn.prototype.booleanish=!1;Qn.prototype.boolean=!1;Qn.prototype.commaOrSpaceSeparated=!1;Qn.prototype.commaSeparated=!1;Qn.prototype.defined=!1;Qn.prototype.mustUseProperty=!1;Qn.prototype.number=!1;Qn.prototype.overloadedBoolean=!1;Qn.prototype.property="";Qn.prototype.spaceSeparated=!1;Qn.prototype.space=void 0;let sw=0;const Ve=$s(),sn=$s(),eh=$s(),Ee=$s(),kt=$s(),Us=$s(),ia=$s();function $s(){return 2**++sw}const th=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ve,booleanish:sn,commaOrSpaceSeparated:ia,commaSeparated:Us,number:Ee,overloadedBoolean:eh,spaceSeparated:kt},Symbol.toStringTag,{value:"Module"})),xm=Object.keys(th);class Uh extends Qn{constructor(t,a,s,l){let u=-1;if(super(t,a),wx(this,"space",l),typeof s=="number")for(;++u<xm.length;){const d=xm[u];wx(this,xm[u],(s&th[d])===th[d])}}}Uh.prototype.defined=!0;function wx(e,t,a){a&&(e[t]=a)}function Gi(e){const t={},a={};for(const[s,l]of Object.entries(e.properties)){const u=new Uh(s,e.transform(e.attributes||{},s),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(u.mustUseProperty=!0),t[s]=u,a[bo(s)]=s,a[bo(u.attribute)]=s}return new No(t,a,e.space)}const by=Gi({properties:{ariaActiveDescendant:null,ariaAtomic:sn,ariaAutoComplete:null,ariaBusy:sn,ariaChecked:sn,ariaColCount:Ee,ariaColIndex:Ee,ariaColSpan:Ee,ariaControls:kt,ariaCurrent:null,ariaDescribedBy:kt,ariaDetails:null,ariaDisabled:sn,ariaDropEffect:kt,ariaErrorMessage:null,ariaExpanded:sn,ariaFlowTo:kt,ariaGrabbed:sn,ariaHasPopup:null,ariaHidden:sn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:kt,ariaLevel:Ee,ariaLive:null,ariaModal:sn,ariaMultiLine:sn,ariaMultiSelectable:sn,ariaOrientation:null,ariaOwns:kt,ariaPlaceholder:null,ariaPosInSet:Ee,ariaPressed:sn,ariaReadOnly:sn,ariaRelevant:null,ariaRequired:sn,ariaRoleDescription:kt,ariaRowCount:Ee,ariaRowIndex:Ee,ariaRowSpan:Ee,ariaSelected:sn,ariaSetSize:Ee,ariaSort:null,ariaValueMax:Ee,ariaValueMin:Ee,ariaValueNow:Ee,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function xy(e,t){return t in e?e[t]:t}function Ey(e,t){return xy(e,t.toLowerCase())}const iw=Gi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Us,acceptCharset:kt,accessKey:kt,action:null,allow:null,allowFullScreen:Ve,allowPaymentRequest:Ve,allowUserMedia:Ve,alpha:Ve,alt:null,as:null,async:Ve,autoCapitalize:null,autoComplete:kt,autoFocus:Ve,autoPlay:Ve,blocking:kt,capture:null,charSet:null,checked:Ve,cite:null,className:kt,closedBy:null,colorSpace:null,cols:Ee,colSpan:Ee,command:null,commandFor:null,content:null,contentEditable:sn,controls:Ve,controlsList:kt,coords:Ee|Us,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ve,defer:Ve,dir:null,dirName:null,disabled:Ve,download:eh,draggable:sn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ve,formTarget:null,headers:kt,height:Ee,hidden:eh,high:Ee,href:null,hrefLang:null,htmlFor:kt,httpEquiv:kt,id:null,imageSizes:null,imageSrcSet:null,inert:Ve,inputMode:null,integrity:null,is:null,isMap:Ve,itemId:null,itemProp:kt,itemRef:kt,itemScope:Ve,itemType:kt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ve,low:Ee,manifest:null,max:null,maxLength:Ee,media:null,method:null,min:null,minLength:Ee,multiple:Ve,muted:Ve,name:null,nonce:null,noModule:Ve,noValidate:Ve,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ve,optimum:Ee,pattern:null,ping:kt,placeholder:null,playsInline:Ve,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ve,referrerPolicy:null,rel:kt,required:Ve,reversed:Ve,rows:Ee,rowSpan:Ee,sandbox:kt,scope:null,scoped:Ve,seamless:Ve,selected:Ve,shadowRootClonable:Ve,shadowRootCustomElementRegistry:Ve,shadowRootDelegatesFocus:Ve,shadowRootMode:null,shadowRootSerializable:Ve,shape:null,size:Ee,sizes:null,slot:null,span:Ee,spellCheck:sn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ee,step:null,style:null,tabIndex:Ee,target:null,title:null,translate:null,type:null,typeMustMatch:Ve,useMap:null,value:sn,width:Ee,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:kt,axis:null,background:null,bgColor:null,border:Ee,borderColor:null,bottomMargin:Ee,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ve,declare:Ve,event:null,face:null,frame:null,frameBorder:null,hSpace:Ee,leftMargin:Ee,link:null,longDesc:null,lowSrc:null,marginHeight:Ee,marginWidth:Ee,noResize:Ve,noHref:Ve,noShade:Ve,noWrap:Ve,object:null,profile:null,prompt:null,rev:null,rightMargin:Ee,rules:null,scheme:null,scrolling:sn,standby:null,summary:null,text:null,topMargin:Ee,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ee,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ve,disablePictureInPicture:Ve,disableRemotePlayback:Ve,exportParts:Us,part:kt,prefix:null,property:null,results:Ee,security:null,unselectable:null},space:"html",transform:Ey}),lw=Gi({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ia,accentHeight:Ee,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ee,amplitude:Ee,arabicForm:null,ascent:Ee,attributeName:null,attributeType:null,azimuth:Ee,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ee,by:null,calcMode:null,capHeight:Ee,className:kt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ee,diffuseConstant:Ee,direction:null,display:null,dur:null,divisor:Ee,dominantBaseline:null,download:Ve,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ee,enableBackground:null,end:null,event:null,exponent:Ee,externalResourcesRequired:null,fill:null,fillOpacity:Ee,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Us,g2:Us,glyphName:Us,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ee,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ee,horizOriginX:Ee,horizOriginY:Ee,id:null,ideographic:Ee,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ee,k:Ee,k1:Ee,k2:Ee,k3:Ee,k4:Ee,kernelMatrix:ia,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ee,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ee,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ee,overlineThickness:Ee,paintOrder:null,panose1:null,path:null,pathLength:Ee,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:kt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ee,pointsAtY:Ee,pointsAtZ:Ee,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ia,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ia,rev:ia,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ia,requiredFeatures:ia,requiredFonts:ia,requiredFormats:ia,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ee,specularExponent:Ee,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ee,strikethroughThickness:Ee,string:null,stroke:null,strokeDashArray:ia,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ee,strokeOpacity:Ee,strokeWidth:null,style:null,surfaceScale:Ee,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ia,tabIndex:Ee,tableValues:null,target:null,targetX:Ee,targetY:Ee,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ia,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ee,underlineThickness:Ee,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ee,values:null,vAlphabetic:Ee,vMathematical:Ee,vectorEffect:null,vHanging:Ee,vIdeographic:Ee,version:null,vertAdvY:Ee,vertOriginX:Ee,vertOriginY:Ee,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ee,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:xy}),yy=Gi({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Ty=Gi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ey}),_y=Gi({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),ow={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},uw=/[A-Z]/g,kx=/-[a-z]/g,cw=/^data[-\w.:]+$/i;function qc(e,t){const a=bo(t);let s=t,l=Qn;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&cw.test(t)){if(t.charAt(4)==="-"){const u=t.slice(5).replace(kx,fw);s="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=t.slice(4);if(!kx.test(u)){let d=u.replace(uw,dw);d.charAt(0)!=="-"&&(d="-"+d),t="data"+d}}l=Uh}return new l(s,t)}function dw(e){return"-"+e.toLowerCase()}function fw(e){return e.charAt(1).toUpperCase()}const So=gy([by,iw,yy,Ty,_y],"html"),ds=gy([by,lw,yy,Ty,_y],"svg");function Rx(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Ny(e){return e.join(" ").trim()}var Ii={},Em,Ox;function mw(){if(Ox)return Em;Ox=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,a=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,l=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
433
433
  `,h="/",x="*",b="",y="comment",T="declaration";function N(S,C){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];C=C||{};var R=1,w=1;function D(le){var re=le.match(t);re&&(R+=re.length);var Q=le.lastIndexOf(m);w=~Q?le.length-Q:w+le.length}function K(){var le={line:R,column:w};return function(re){return re.position=new L(le),W(),re}}function L(le){this.start=le,this.end={line:R,column:w},this.source=C.source}L.prototype.content=S;function M(le){var re=new Error(C.source+":"+R+":"+w+": "+le);if(re.reason=le,re.filename=C.source,re.line=R,re.column=w,re.source=S,!C.silent)throw re}function V(le){var re=le.exec(S);if(re){var Q=re[0];return D(Q),S=S.slice(Q.length),re}}function W(){V(a)}function j(le){var re;for(le=le||[];re=U();)re!==!1&&le.push(re);return le}function U(){var le=K();if(!(h!=S.charAt(0)||x!=S.charAt(1))){for(var re=2;b!=S.charAt(re)&&(x!=S.charAt(re)||h!=S.charAt(re+1));)++re;if(re+=2,b===S.charAt(re-1))return M("End of comment missing");var Q=S.slice(2,re-2);return w+=2,D(Q),S=S.slice(re),w+=2,le({type:y,comment:Q})}}function J(){var le=K(),re=V(s);if(re){if(U(),!V(l))return M("property missing ':'");var Q=V(u),F=le({type:T,property:v(re[0].replace(e,b)),value:Q?v(Q[0].replace(e,b)):b});return V(d),F}}function se(){var le=[];j(le);for(var re;re=J();)re!==!1&&(le.push(re),j(le));return le}return W(),se()}function v(S){return S?S.replace(f,b):b}return Em=N,Em}var Ix;function hw(){if(Ix)return Ii;Ix=1;var e=Ii&&Ii.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.default=a;const t=e(mw());function a(s,l){let u=null;if(!s||typeof s!="string")return u;const d=(0,t.default)(s),f=typeof l=="function";return d.forEach(m=>{if(m.type!=="declaration")return;const{property:h,value:x}=m;f?l(h,x,m):x&&(u=u||{},u[h]=x)}),u}return Ii}var Kl={},Mx;function pw(){if(Mx)return Kl;Mx=1,Object.defineProperty(Kl,"__esModule",{value:!0}),Kl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,a=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,l=/^-(ms)-/,u=function(h){return!h||a.test(h)||e.test(h)},d=function(h,x){return x.toUpperCase()},f=function(h,x){return"".concat(x,"-")},m=function(h,x){return x===void 0&&(x={}),u(h)?h:(h=h.toLowerCase(),x.reactCompat?h=h.replace(l,f):h=h.replace(s,f),h.replace(t,d))};return Kl.camelCase=m,Kl}var Vl,Dx;function gw(){if(Dx)return Vl;Dx=1;var e=Vl&&Vl.__importDefault||function(l){return l&&l.__esModule?l:{default:l}},t=e(hw()),a=pw();function s(l,u){var d={};return!l||typeof l!="string"||(0,t.default)(l,function(f,m){f&&m&&(d[(0,a.camelCase)(f,u)]=m)}),d}return s.default=s,Vl=s,Vl}var bw=gw();const xw=Ic(bw),Yc=Sy("end"),Za=Sy("start");function Sy(e){return t;function t(a){const s=a&&a.position&&a.position[e]||{};if(typeof s.line=="number"&&s.line>0&&typeof s.column=="number"&&s.column>0)return{line:s.line,column:s.column,offset:typeof s.offset=="number"&&s.offset>-1?s.offset:void 0}}}function Ew(e){const t=Za(e),a=Yc(e);if(t&&a)return{start:t,end:a}}function no(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Lx(e.position):"start"in e||"end"in e?Lx(e):"line"in e||"column"in e?nh(e):""}function nh(e){return jx(e&&e.line)+":"+jx(e&&e.column)}function Lx(e){return nh(e&&e.start)+"-"+nh(e&&e.end)}function jx(e){return e&&typeof e=="number"?e:1}class An extends Error{constructor(t,a,s){super(),typeof a=="string"&&(s=a,a=void 0);let l="",u={},d=!1;if(a&&("line"in a&&"column"in a?u={place:a}:"start"in a&&"end"in a?u={place:a}:"type"in a?u={ancestors:[a],place:a.position}:u={...a}),typeof t=="string"?l=t:!u.cause&&t&&(d=!0,l=t.message,u.cause=t),!u.ruleId&&!u.source&&typeof s=="string"){const m=s.indexOf(":");m===-1?u.ruleId=s:(u.source=s.slice(0,m),u.ruleId=s.slice(m+1))}if(!u.place&&u.ancestors&&u.ancestors){const m=u.ancestors[u.ancestors.length-1];m&&(u.place=m.position)}const f=u.place&&"start"in u.place?u.place.start:u.place;this.ancestors=u.ancestors||void 0,this.cause=u.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=l,this.line=f?f.line:void 0,this.name=no(u.place)||"1:1",this.place=u.place||void 0,this.reason=this.message,this.ruleId=u.ruleId||void 0,this.source=u.source||void 0,this.stack=d&&u.cause&&typeof u.cause.stack=="string"?u.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}An.prototype.file="";An.prototype.name="";An.prototype.reason="";An.prototype.message="";An.prototype.stack="";An.prototype.column=void 0;An.prototype.line=void 0;An.prototype.ancestors=void 0;An.prototype.cause=void 0;An.prototype.fatal=void 0;An.prototype.place=void 0;An.prototype.ruleId=void 0;An.prototype.source=void 0;const Hh={}.hasOwnProperty,yw=new Map,Tw=/[A-Z]/g,_w=new Set(["table","tbody","thead","tfoot","tr"]),Nw=new Set(["td","th"]),vy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Sw(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=t.filePath||void 0;let s;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");s=Iw(a,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");s=Ow(a,t.jsx,t.jsxs)}const l={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:s,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?ds:So,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},u=Ay(l,e,void 0);return u&&typeof u!="string"?u:l.create(e,l.Fragment,{children:u||void 0},void 0)}function Ay(e,t,a){if(t.type==="element")return vw(e,t,a);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Aw(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return ww(e,t,a);if(t.type==="mdxjsEsm")return Cw(e,t);if(t.type==="root")return kw(e,t,a);if(t.type==="text")return Rw(e,t)}function vw(e,t,a){const s=e.schema;let l=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(l=ds,e.schema=l),e.ancestors.push(t);const u=wy(e,t.tagName,!1),d=Mw(e,t);let f=zh(e,t);return _w.has(t.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!rw(m):!0})),Cy(e,d,u,t),Fh(d,f),e.ancestors.pop(),e.schema=s,e.create(t,u,d,a)}function Aw(e,t){if(t.data&&t.data.estree&&e.evaluater){const s=t.data.estree.body[0];return s.type,e.evaluater.evaluateExpression(s.expression)}xo(e,t.position)}function Cw(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);xo(e,t.position)}function ww(e,t,a){const s=e.schema;let l=s;t.name==="svg"&&s.space==="html"&&(l=ds,e.schema=l),e.ancestors.push(t);const u=t.name===null?e.Fragment:wy(e,t.name,!0),d=Dw(e,t),f=zh(e,t);return Cy(e,d,u,t),Fh(d,f),e.ancestors.pop(),e.schema=s,e.create(t,u,d,a)}function kw(e,t,a){const s={};return Fh(s,zh(e,t)),e.create(t,e.Fragment,s,a)}function Rw(e,t){return t.value}function Cy(e,t,a,s){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(t.node=s)}function Fh(e,t){if(t.length>0){const a=t.length>1?t:t[0];a&&(e.children=a)}}function Ow(e,t,a){return s;function s(l,u,d,f){const h=Array.isArray(d.children)?a:t;return f?h(u,d,f):h(u,d)}}function Iw(e,t){return a;function a(s,l,u,d){const f=Array.isArray(u.children),m=Za(s);return t(l,u,d,f,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function Mw(e,t){const a={};let s,l;for(l in t.properties)if(l!=="children"&&Hh.call(t.properties,l)){const u=Lw(e,l,t.properties[l]);if(u){const[d,f]=u;e.tableCellAlignToStyle&&d==="align"&&typeof f=="string"&&Nw.has(t.tagName)?s=f:a[d]=f}}if(s){const u=a.style||(a.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=s}return a}function Dw(e,t){const a={};for(const s of t.attributes)if(s.type==="mdxJsxExpressionAttribute")if(s.data&&s.data.estree&&e.evaluater){const u=s.data.estree.body[0];u.type;const d=u.expression;d.type;const f=d.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else xo(e,t.position);else{const l=s.name;let u;if(s.value&&typeof s.value=="object")if(s.value.data&&s.value.data.estree&&e.evaluater){const f=s.value.data.estree.body[0];f.type,u=e.evaluater.evaluateExpression(f.expression)}else xo(e,t.position);else u=s.value===null?!0:s.value;a[l]=u}return a}function zh(e,t){const a=[];let s=-1;const l=e.passKeys?new Map:yw;for(;++s<t.children.length;){const u=t.children[s];let d;if(e.passKeys){const m=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(m){const h=l.get(m)||0;d=m+"-"+h,l.set(m,h+1)}}const f=Ay(e,u,d);f!==void 0&&a.push(f)}return a}function Lw(e,t,a){const s=qc(e.schema,t);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=s.commaSeparated?py(a):Ny(a)),s.property==="style"){let l=typeof a=="object"?a:jw(e,String(a));return e.stylePropertyNameCase==="css"&&(l=Bw(l)),["style",l]}return[e.elementAttributeNameCase==="react"&&s.space?ow[s.property]||s.property:s.attribute,a]}}function jw(e,t){try{return xw(t,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const s=a,l=new An("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:s,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw l.file=e.filePath||void 0,l.url=vy+"#cannot-parse-style-attribute",l}}function wy(e,t,a){let s;if(!a)s={type:"Literal",value:t};else if(t.includes(".")){const l=t.split(".");let u=-1,d;for(;++u<l.length;){const f=Ax(l[u])?{type:"Identifier",name:l[u]}:{type:"Literal",value:l[u]};d=d?{type:"MemberExpression",object:d,property:f,computed:!!(u&&f.type==="Literal"),optional:!1}:f}s=d}else s=Ax(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const l=s.value;return Hh.call(e.components,l)?e.components[l]:l}if(e.evaluater)return e.evaluater.evaluateExpression(s);xo(e)}function xo(e,t){const a=new An("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=vy+"#cannot-handle-mdx-estrees-without-createevaluater",a}function Bw(e){const t={};let a;for(a in e)Hh.call(e,a)&&(t[Pw(a)]=e[a]);return t}function Pw(e){let t=e.replace(Tw,Uw);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Uw(e){return"-"+e.toLowerCase()}const ym={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Hw={};function qh(e,t){const a=Hw,s=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,l=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return ky(e,s,l)}function ky(e,t,a){if(Fw(e)){if("value"in e)return e.type==="html"&&!a?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Bx(e.children,t,a)}return Array.isArray(e)?Bx(e,t,a):""}function Bx(e,t,a){const s=[];let l=-1;for(;++l<e.length;)s[l]=ky(e[l],t,a);return s.join("")}function Fw(e){return!!(e&&typeof e=="object")}const Px=document.createElement("i");function Yh(e){const t="&"+e+";";Px.innerHTML=t;const a=Px.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===t?!1:a}function la(e,t,a,s){const l=e.length;let u=0,d;if(t<0?t=-t>l?0:l+t:t=t>l?l:t,a=a>0?a:0,s.length<1e4)d=Array.from(s),d.unshift(t,a),e.splice(...d);else for(a&&e.splice(t,a);u<s.length;)d=s.slice(u,u+1e4),d.unshift(t,0),e.splice(...d),u+=1e4,t+=1e4}function _a(e,t){return e.length>0?(la(e,e.length,0,t),e):t}const Ux={}.hasOwnProperty;function Ry(e){const t={};let a=-1;for(;++a<e.length;)zw(t,e[a]);return t}function zw(e,t){let a;for(a in t){const l=(Ux.call(e,a)?e[a]:void 0)||(e[a]={}),u=t[a];let d;if(u)for(d in u){Ux.call(l,d)||(l[d]=[]);const f=u[d];qw(l[d],Array.isArray(f)?f:f?[f]:[])}}}function qw(e,t){let a=-1;const s=[];for(;++a<t.length;)(t[a].add==="after"?e:s).push(t[a]);la(e,0,0,s)}function Oy(e,t){const a=Number.parseInt(e,t);return a<9||a===11||a>13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function Ma(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Mn=fs(/[A-Za-z]/),vn=fs(/[\dA-Za-z]/),Yw=fs(/[#-'*+\--9=?A-Z^-~]/);function Nc(e){return e!==null&&(e<32||e===127)}const ah=fs(/\d/),$w=fs(/[\dA-Fa-f]/),Gw=fs(/[!-/:-@[-`{-~]/);function Ue(e){return e!==null&&e<-2}function Rt(e){return e!==null&&(e<0||e===32)}function rt(e){return e===-2||e===-1||e===32}const $c=fs(new RegExp("\\p{P}|\\p{S}","u")),qs=fs(/\s/);function fs(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function Ki(e){const t=[];let a=-1,s=0,l=0;for(;++a<e.length;){const u=e.charCodeAt(a);let d="";if(u===37&&vn(e.charCodeAt(a+1))&&vn(e.charCodeAt(a+2)))l=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(d=String.fromCharCode(u));else if(u>55295&&u<57344){const f=e.charCodeAt(a+1);u<56320&&f>56319&&f<57344?(d=String.fromCharCode(u,f),l=1):d="�"}else d=String.fromCharCode(u);d&&(t.push(e.slice(s,a),encodeURIComponent(d)),s=a+l+1,d=""),l&&(a+=l,l=0)}return t.join("")+e.slice(s)}function ct(e,t,a,s){const l=s?s-1:Number.POSITIVE_INFINITY;let u=0;return d;function d(m){return rt(m)?(e.enter(a),f(m)):t(m)}function f(m){return rt(m)&&u++<l?(e.consume(m),f):(e.exit(a),t(m))}}const Kw={tokenize:Vw};function Vw(e){const t=e.attempt(this.parser.constructs.contentInitial,s,l);let a;return t;function s(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),ct(e,t,"linePrefix")}function l(f){return e.enter("paragraph"),u(f)}function u(f){const m=e.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=m),a=m,d(f)}function d(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return Ue(f)?(e.consume(f),e.exit("chunkText"),u):(e.consume(f),d)}}const Qw={tokenize:Xw},Hx={tokenize:Ww};function Xw(e){const t=this,a=[];let s=0,l,u,d;return f;function f(w){if(s<a.length){const D=a[s];return t.containerState=D[1],e.attempt(D[0].continuation,m,h)(w)}return h(w)}function m(w){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,l&&R();const D=t.events.length;let K=D,L;for(;K--;)if(t.events[K][0]==="exit"&&t.events[K][1].type==="chunkFlow"){L=t.events[K][1].end;break}C(s);let M=D;for(;M<t.events.length;)t.events[M][1].end={...L},M++;return la(t.events,K+1,0,t.events.slice(D)),t.events.length=M,h(w)}return f(w)}function h(w){if(s===a.length){if(!l)return y(w);if(l.currentConstruct&&l.currentConstruct.concrete)return N(w);t.interrupt=!!(l.currentConstruct&&!l._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Hx,x,b)(w)}function x(w){return l&&R(),C(s),y(w)}function b(w){return t.parser.lazy[t.now().line]=s!==a.length,d=t.now().offset,N(w)}function y(w){return t.containerState={},e.attempt(Hx,T,N)(w)}function T(w){return s++,a.push([t.currentConstruct,t.containerState]),y(w)}function N(w){if(w===null){l&&R(),C(0),e.consume(w);return}return l=l||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:l,contentType:"flow",previous:u}),v(w)}function v(w){if(w===null){S(e.exit("chunkFlow"),!0),C(0),e.consume(w);return}return Ue(w)?(e.consume(w),S(e.exit("chunkFlow")),s=0,t.interrupt=void 0,f):(e.consume(w),v)}function S(w,D){const K=t.sliceStream(w);if(D&&K.push(null),w.previous=u,u&&(u.next=w),u=w,l.defineSkip(w.start),l.write(K),t.parser.lazy[w.start.line]){let L=l.events.length;for(;L--;)if(l.events[L][1].start.offset<d&&(!l.events[L][1].end||l.events[L][1].end.offset>d))return;const M=t.events.length;let V=M,W,j;for(;V--;)if(t.events[V][0]==="exit"&&t.events[V][1].type==="chunkFlow"){if(W){j=t.events[V][1].end;break}W=!0}for(C(s),L=M;L<t.events.length;)t.events[L][1].end={...j},L++;la(t.events,V+1,0,t.events.slice(M)),t.events.length=L}}function C(w){let D=a.length;for(;D-- >w;){const K=a[D];t.containerState=K[1],K[0].exit.call(t,e)}a.length=w}function R(){l.write([null]),u=void 0,l=void 0,t.containerState._closeFlow=void 0}}function Ww(e,t,a){return ct(e,e.attempt(this.parser.constructs.document,t,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ui(e){if(e===null||Rt(e)||qs(e))return 1;if($c(e))return 2}function Gc(e,t,a){const s=[];let l=-1;for(;++l<e.length;){const u=e[l].resolveAll;u&&!s.includes(u)&&(t=u(t,a),s.push(u))}return t}const rh={name:"attention",resolveAll:Zw,tokenize:Jw};function Zw(e,t){let a=-1,s,l,u,d,f,m,h,x;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(s=a;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[s][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;m=e[s][1].end.offset-e[s][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const b={...e[s][1].end},y={...e[a][1].start};Fx(b,-m),Fx(y,m),d={type:m>1?"strongSequence":"emphasisSequence",start:b,end:{...e[s][1].end}},f={type:m>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:y},u={type:m>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[a][1].start}},l={type:m>1?"strong":"emphasis",start:{...d.start},end:{...f.end}},e[s][1].end={...d.start},e[a][1].start={...f.end},h=[],e[s][1].end.offset-e[s][1].start.offset&&(h=_a(h,[["enter",e[s][1],t],["exit",e[s][1],t]])),h=_a(h,[["enter",l,t],["enter",d,t],["exit",d,t],["enter",u,t]]),h=_a(h,Gc(t.parser.constructs.insideSpan.null,e.slice(s+1,a),t)),h=_a(h,[["exit",u,t],["enter",f,t],["exit",f,t],["exit",l,t]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,h=_a(h,[["enter",e[a][1],t],["exit",e[a][1],t]])):x=0,la(e,s-1,a-s+3,h),a=s+h.length-x-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function Jw(e,t){const a=this.parser.constructs.attentionMarkers.null,s=this.previous,l=Ui(s);let u;return d;function d(m){return u=m,e.enter("attentionSequence"),f(m)}function f(m){if(m===u)return e.consume(m),f;const h=e.exit("attentionSequence"),x=Ui(m),b=!x||x===2&&l||a.includes(m),y=!l||l===2&&x||a.includes(s);return h._open=!!(u===42?b:b&&(l||!y)),h._close=!!(u===42?y:y&&(x||!b)),t(m)}}function Fx(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const e5={name:"autolink",tokenize:t5};function t5(e,t,a){let s=0;return l;function l(T){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(T),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),u}function u(T){return Mn(T)?(e.consume(T),d):T===64?a(T):h(T)}function d(T){return T===43||T===45||T===46||vn(T)?(s=1,f(T)):h(T)}function f(T){return T===58?(e.consume(T),s=0,m):(T===43||T===45||T===46||vn(T))&&s++<32?(e.consume(T),f):(s=0,h(T))}function m(T){return T===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(T),e.exit("autolinkMarker"),e.exit("autolink"),t):T===null||T===32||T===60||Nc(T)?a(T):(e.consume(T),m)}function h(T){return T===64?(e.consume(T),x):Yw(T)?(e.consume(T),h):a(T)}function x(T){return vn(T)?b(T):a(T)}function b(T){return T===46?(e.consume(T),s=0,x):T===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(T),e.exit("autolinkMarker"),e.exit("autolink"),t):y(T)}function y(T){if((T===45||vn(T))&&s++<63){const N=T===45?y:b;return e.consume(T),N}return a(T)}}const vo={partial:!0,tokenize:n5};function n5(e,t,a){return s;function s(u){return rt(u)?ct(e,l,"linePrefix")(u):l(u)}function l(u){return u===null||Ue(u)?t(u):a(u)}}const Iy={continuation:{tokenize:r5},exit:s5,name:"blockQuote",tokenize:a5};function a5(e,t,a){const s=this;return l;function l(d){if(d===62){const f=s.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(d),e.exit("blockQuoteMarker"),u}return a(d)}function u(d){return rt(d)?(e.enter("blockQuotePrefixWhitespace"),e.consume(d),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(d))}}function r5(e,t,a){const s=this;return l;function l(d){return rt(d)?ct(e,u,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d):u(d)}function u(d){return e.attempt(Iy,t,a)(d)}}function s5(e){e.exit("blockQuote")}const My={name:"characterEscape",tokenize:i5};function i5(e,t,a){return s;function s(u){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(u),e.exit("escapeMarker"),l}function l(u){return Gw(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):a(u)}}const Dy={name:"characterReference",tokenize:l5};function l5(e,t,a){const s=this;let l=0,u,d;return f;function f(b){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(b),e.exit("characterReferenceMarker"),m}function m(b){return b===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(b),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),u=31,d=vn,x(b))}function h(b){return b===88||b===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(b),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,d=$w,x):(e.enter("characterReferenceValue"),u=7,d=ah,x(b))}function x(b){if(b===59&&l){const y=e.exit("characterReferenceValue");return d===vn&&!Yh(s.sliceSerialize(y))?a(b):(e.enter("characterReferenceMarker"),e.consume(b),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return d(b)&&l++<u?(e.consume(b),x):a(b)}}const zx={partial:!0,tokenize:u5},qx={concrete:!0,name:"codeFenced",tokenize:o5};function o5(e,t,a){const s=this,l={partial:!0,tokenize:K};let u=0,d=0,f;return m;function m(L){return h(L)}function h(L){const M=s.events[s.events.length-1];return u=M&&M[1].type==="linePrefix"?M[2].sliceSerialize(M[1],!0).length:0,f=L,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),x(L)}function x(L){return L===f?(d++,e.consume(L),x):d<3?a(L):(e.exit("codeFencedFenceSequence"),rt(L)?ct(e,b,"whitespace")(L):b(L))}function b(L){return L===null||Ue(L)?(e.exit("codeFencedFence"),s.interrupt?t(L):e.check(zx,v,D)(L)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(L))}function y(L){return L===null||Ue(L)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),b(L)):rt(L)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ct(e,T,"whitespace")(L)):L===96&&L===f?a(L):(e.consume(L),y)}function T(L){return L===null||Ue(L)?b(L):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),N(L))}function N(L){return L===null||Ue(L)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),b(L)):L===96&&L===f?a(L):(e.consume(L),N)}function v(L){return e.attempt(l,D,S)(L)}function S(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),C}function C(L){return u>0&&rt(L)?ct(e,R,"linePrefix",u+1)(L):R(L)}function R(L){return L===null||Ue(L)?e.check(zx,v,D)(L):(e.enter("codeFlowValue"),w(L))}function w(L){return L===null||Ue(L)?(e.exit("codeFlowValue"),R(L)):(e.consume(L),w)}function D(L){return e.exit("codeFenced"),t(L)}function K(L,M,V){let W=0;return j;function j(re){return L.enter("lineEnding"),L.consume(re),L.exit("lineEnding"),U}function U(re){return L.enter("codeFencedFence"),rt(re)?ct(L,J,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(re):J(re)}function J(re){return re===f?(L.enter("codeFencedFenceSequence"),se(re)):V(re)}function se(re){return re===f?(W++,L.consume(re),se):W>=d?(L.exit("codeFencedFenceSequence"),rt(re)?ct(L,le,"whitespace")(re):le(re)):V(re)}function le(re){return re===null||Ue(re)?(L.exit("codeFencedFence"),M(re)):V(re)}}}function u5(e,t,a){const s=this;return l;function l(d){return d===null?a(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u)}function u(d){return s.parser.lazy[s.now().line]?a(d):t(d)}}const Tm={name:"codeIndented",tokenize:d5},c5={partial:!0,tokenize:f5};function d5(e,t,a){const s=this;return l;function l(h){return e.enter("codeIndented"),ct(e,u,"linePrefix",5)(h)}function u(h){const x=s.events[s.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(h):a(h)}function d(h){return h===null?m(h):Ue(h)?e.attempt(c5,d,m)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||Ue(h)?(e.exit("codeFlowValue"),d(h)):(e.consume(h),f)}function m(h){return e.exit("codeIndented"),t(h)}}function f5(e,t,a){const s=this;return l;function l(d){return s.parser.lazy[s.now().line]?a(d):Ue(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):ct(e,u,"linePrefix",5)(d)}function u(d){const f=s.events[s.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(d):Ue(d)?l(d):a(d)}}const m5={name:"codeText",previous:p5,resolve:h5,tokenize:g5};function h5(e){let t=e.length-4,a=3,s,l;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(s=a;++s<t;)if(e[s][1].type==="codeTextData"){e[a][1].type="codeTextPadding",e[t][1].type="codeTextPadding",a+=2,t-=2;break}}for(s=a-1,t++;++s<=t;)l===void 0?s!==t&&e[s][1].type!=="lineEnding"&&(l=s):(s===t||e[s][1].type==="lineEnding")&&(e[l][1].type="codeTextData",s!==l+2&&(e[l][1].end=e[s-1][1].end,e.splice(l+2,s-l-2),t-=s-l-2,s=l+2),l=void 0);return e}function p5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function g5(e,t,a){let s=0,l,u;return d;function d(b){return e.enter("codeText"),e.enter("codeTextSequence"),f(b)}function f(b){return b===96?(e.consume(b),s++,f):(e.exit("codeTextSequence"),m(b))}function m(b){return b===null?a(b):b===32?(e.enter("space"),e.consume(b),e.exit("space"),m):b===96?(u=e.enter("codeTextSequence"),l=0,x(b)):Ue(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),m):(e.enter("codeTextData"),h(b))}function h(b){return b===null||b===32||b===96||Ue(b)?(e.exit("codeTextData"),m(b)):(e.consume(b),h)}function x(b){return b===96?(e.consume(b),l++,x):l===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(b)):(u.type="codeTextData",h(b))}}class b5{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,a){const s=a??Number.POSITIVE_INFINITY;return s<this.left.length?this.left.slice(t,s):t>this.left.length?this.right.slice(this.right.length-s+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-s+this.left.length).reverse())}splice(t,a,s){const l=a||0;this.setCursor(Math.trunc(t));const u=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return s&&Ql(this.left,s),u.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ql(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ql(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const a=this.left.splice(t,Number.POSITIVE_INFINITY);Ql(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ql(this.left,a.reverse())}}}function Ql(e,t){let a=0;if(t.length<1e4)e.push(...t);else for(;a<t.length;)e.push(...t.slice(a,a+1e4)),a+=1e4}function Ly(e){const t={};let a=-1,s,l,u,d,f,m,h;const x=new b5(e);for(;++a<x.length;){for(;a in t;)a=t[a];if(s=x.get(a),a&&s[1].type==="chunkFlow"&&x.get(a-1)[1].type==="listItemPrefix"&&(m=s[1]._tokenizer.events,u=0,u<m.length&&m[u][1].type==="lineEndingBlank"&&(u+=2),u<m.length&&m[u][1].type==="content"))for(;++u<m.length&&m[u][1].type!=="content";)m[u][1].type==="chunkText"&&(m[u][1]._isInFirstContentOfListItem=!0,u++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,x5(x,a)),a=t[a],h=!0);else if(s[1]._container){for(u=a,l=void 0;u--;)if(d=x.get(u),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(l&&(x.get(l)[1].type="lineEndingBlank"),d[1].type="lineEnding",l=u);else if(!(d[1].type==="linePrefix"||d[1].type==="listItemIndent"))break;l&&(s[1].end={...x.get(l)[1].start},f=x.slice(l,a),f.unshift(s),x.splice(l,a-l+1,f))}}return la(e,0,Number.POSITIVE_INFINITY,x.slice(0)),!h}function x5(e,t){const a=e.get(t)[1],s=e.get(t)[2];let l=t-1;const u=[];let d=a._tokenizer;d||(d=s.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(d._contentTypeTextTrailing=!0));const f=d.events,m=[],h={};let x,b,y=-1,T=a,N=0,v=0;const S=[v];for(;T;){for(;e.get(++l)[1]!==T;);u.push(l),T._tokenizer||(x=s.sliceStream(T),T.next||x.push(null),b&&d.defineSkip(T.start),T._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(x),T._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),b=T,T=T.next}for(T=a;++y<f.length;)f[y][0]==="exit"&&f[y-1][0]==="enter"&&f[y][1].type===f[y-1][1].type&&f[y][1].start.line!==f[y][1].end.line&&(v=y+1,S.push(v),T._tokenizer=void 0,T.previous=void 0,T=T.next);for(d.events=[],T?(T._tokenizer=void 0,T.previous=void 0):S.pop(),y=S.length;y--;){const C=f.slice(S[y],S[y+1]),R=u.pop();m.push([R,R+C.length-1]),e.splice(R,2,C)}for(m.reverse(),y=-1;++y<m.length;)h[N+m[y][0]]=N+m[y][1],N+=m[y][1]-m[y][0]-1;return h}const E5={resolve:T5,tokenize:_5},y5={partial:!0,tokenize:N5};function T5(e){return Ly(e),e}function _5(e,t){let a;return s;function s(f){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),l(f)}function l(f){return f===null?u(f):Ue(f)?e.check(y5,d,u)(f):(e.consume(f),l)}function u(f){return e.exit("chunkContent"),e.exit("content"),t(f)}function d(f){return e.consume(f),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,l}}function N5(e,t,a){const s=this;return l;function l(d){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),ct(e,u,"linePrefix")}function u(d){if(d===null||Ue(d))return a(d);const f=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(d):e.interrupt(s.parser.constructs.flow,a,t)(d)}}function jy(e,t,a,s,l,u,d,f,m){const h=m||Number.POSITIVE_INFINITY;let x=0;return b;function b(C){return C===60?(e.enter(s),e.enter(l),e.enter(u),e.consume(C),e.exit(u),y):C===null||C===32||C===41||Nc(C)?a(C):(e.enter(s),e.enter(d),e.enter(f),e.enter("chunkString",{contentType:"string"}),v(C))}function y(C){return C===62?(e.enter(u),e.consume(C),e.exit(u),e.exit(l),e.exit(s),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),T(C))}function T(C){return C===62?(e.exit("chunkString"),e.exit(f),y(C)):C===null||C===60||Ue(C)?a(C):(e.consume(C),C===92?N:T)}function N(C){return C===60||C===62||C===92?(e.consume(C),T):T(C)}function v(C){return!x&&(C===null||C===41||Rt(C))?(e.exit("chunkString"),e.exit(f),e.exit(d),e.exit(s),t(C)):x<h&&C===40?(e.consume(C),x++,v):C===41?(e.consume(C),x--,v):C===null||C===32||C===40||Nc(C)?a(C):(e.consume(C),C===92?S:v)}function S(C){return C===40||C===41||C===92?(e.consume(C),v):v(C)}}function By(e,t,a,s,l,u){const d=this;let f=0,m;return h;function h(T){return e.enter(s),e.enter(l),e.consume(T),e.exit(l),e.enter(u),x}function x(T){return f>999||T===null||T===91||T===93&&!m||T===94&&!f&&"_hiddenFootnoteSupport"in d.parser.constructs?a(T):T===93?(e.exit(u),e.enter(l),e.consume(T),e.exit(l),e.exit(s),t):Ue(T)?(e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),b(T))}function b(T){return T===null||T===91||T===93||Ue(T)||f++>999?(e.exit("chunkString"),x(T)):(e.consume(T),m||(m=!rt(T)),T===92?y:b)}function y(T){return T===91||T===92||T===93?(e.consume(T),f++,b):b(T)}}function Py(e,t,a,s,l,u){let d;return f;function f(y){return y===34||y===39||y===40?(e.enter(s),e.enter(l),e.consume(y),e.exit(l),d=y===40?41:y,m):a(y)}function m(y){return y===d?(e.enter(l),e.consume(y),e.exit(l),e.exit(s),t):(e.enter(u),h(y))}function h(y){return y===d?(e.exit(u),m(d)):y===null?a(y):Ue(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),ct(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(y))}function x(y){return y===d||y===null||Ue(y)?(e.exit("chunkString"),h(y)):(e.consume(y),y===92?b:x)}function b(y){return y===d||y===92?(e.consume(y),x):x(y)}}function ao(e,t){let a;return s;function s(l){return Ue(l)?(e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),a=!0,s):rt(l)?ct(e,s,a?"linePrefix":"lineSuffix")(l):t(l)}}const S5={name:"definition",tokenize:A5},v5={partial:!0,tokenize:C5};function A5(e,t,a){const s=this;let l;return u;function u(T){return e.enter("definition"),d(T)}function d(T){return By.call(s,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(T)}function f(T){return l=Ma(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),T===58?(e.enter("definitionMarker"),e.consume(T),e.exit("definitionMarker"),m):a(T)}function m(T){return Rt(T)?ao(e,h)(T):h(T)}function h(T){return jy(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(T)}function x(T){return e.attempt(v5,b,b)(T)}function b(T){return rt(T)?ct(e,y,"whitespace")(T):y(T)}function y(T){return T===null||Ue(T)?(e.exit("definition"),s.parser.defined.push(l),t(T)):a(T)}}function C5(e,t,a){return s;function s(f){return Rt(f)?ao(e,l)(f):a(f)}function l(f){return Py(e,u,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function u(f){return rt(f)?ct(e,d,"whitespace")(f):d(f)}function d(f){return f===null||Ue(f)?t(f):a(f)}}const w5={name:"hardBreakEscape",tokenize:k5};function k5(e,t,a){return s;function s(u){return e.enter("hardBreakEscape"),e.consume(u),l}function l(u){return Ue(u)?(e.exit("hardBreakEscape"),t(u)):a(u)}}const R5={name:"headingAtx",resolve:O5,tokenize:I5};function O5(e,t){let a=e.length-2,s=3,l,u;return e[s][1].type==="whitespace"&&(s+=2),a-2>s&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(s===a-1||a-4>s&&e[a-2][1].type==="whitespace")&&(a-=s+1===a?2:4),a>s&&(l={type:"atxHeadingText",start:e[s][1].start,end:e[a][1].end},u={type:"chunkText",start:e[s][1].start,end:e[a][1].end,contentType:"text"},la(e,s,a-s+1,[["enter",l,t],["enter",u,t],["exit",u,t],["exit",l,t]])),e}function I5(e,t,a){let s=0;return l;function l(x){return e.enter("atxHeading"),u(x)}function u(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&s++<6?(e.consume(x),d):x===null||Rt(x)?(e.exit("atxHeadingSequence"),f(x)):a(x)}function f(x){return x===35?(e.enter("atxHeadingSequence"),m(x)):x===null||Ue(x)?(e.exit("atxHeading"),t(x)):rt(x)?ct(e,f,"whitespace")(x):(e.enter("atxHeadingText"),h(x))}function m(x){return x===35?(e.consume(x),m):(e.exit("atxHeadingSequence"),f(x))}function h(x){return x===null||x===35||Rt(x)?(e.exit("atxHeadingText"),f(x)):(e.consume(x),h)}}const M5=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Yx=["pre","script","style","textarea"],D5={concrete:!0,name:"htmlFlow",resolveTo:B5,tokenize:P5},L5={partial:!0,tokenize:H5},j5={partial:!0,tokenize:U5};function B5(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function P5(e,t,a){const s=this;let l,u,d,f,m;return h;function h(I){return x(I)}function x(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),b}function b(I){return I===33?(e.consume(I),y):I===47?(e.consume(I),u=!0,v):I===63?(e.consume(I),l=3,s.interrupt?t:P):Mn(I)?(e.consume(I),d=String.fromCharCode(I),S):a(I)}function y(I){return I===45?(e.consume(I),l=2,T):I===91?(e.consume(I),l=5,f=0,N):Mn(I)?(e.consume(I),l=4,s.interrupt?t:P):a(I)}function T(I){return I===45?(e.consume(I),s.interrupt?t:P):a(I)}function N(I){const Te="CDATA[";return I===Te.charCodeAt(f++)?(e.consume(I),f===Te.length?s.interrupt?t:J:N):a(I)}function v(I){return Mn(I)?(e.consume(I),d=String.fromCharCode(I),S):a(I)}function S(I){if(I===null||I===47||I===62||Rt(I)){const Te=I===47,ke=d.toLowerCase();return!Te&&!u&&Yx.includes(ke)?(l=1,s.interrupt?t(I):J(I)):M5.includes(d.toLowerCase())?(l=6,Te?(e.consume(I),C):s.interrupt?t(I):J(I)):(l=7,s.interrupt&&!s.parser.lazy[s.now().line]?a(I):u?R(I):w(I))}return I===45||vn(I)?(e.consume(I),d+=String.fromCharCode(I),S):a(I)}function C(I){return I===62?(e.consume(I),s.interrupt?t:J):a(I)}function R(I){return rt(I)?(e.consume(I),R):j(I)}function w(I){return I===47?(e.consume(I),j):I===58||I===95||Mn(I)?(e.consume(I),D):rt(I)?(e.consume(I),w):j(I)}function D(I){return I===45||I===46||I===58||I===95||vn(I)?(e.consume(I),D):K(I)}function K(I){return I===61?(e.consume(I),L):rt(I)?(e.consume(I),K):w(I)}function L(I){return I===null||I===60||I===61||I===62||I===96?a(I):I===34||I===39?(e.consume(I),m=I,M):rt(I)?(e.consume(I),L):V(I)}function M(I){return I===m?(e.consume(I),m=null,W):I===null||Ue(I)?a(I):(e.consume(I),M)}function V(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||Rt(I)?K(I):(e.consume(I),V)}function W(I){return I===47||I===62||rt(I)?w(I):a(I)}function j(I){return I===62?(e.consume(I),U):a(I)}function U(I){return I===null||Ue(I)?J(I):rt(I)?(e.consume(I),U):a(I)}function J(I){return I===45&&l===2?(e.consume(I),Q):I===60&&l===1?(e.consume(I),F):I===62&&l===4?(e.consume(I),q):I===63&&l===3?(e.consume(I),P):I===93&&l===5?(e.consume(I),Ce):Ue(I)&&(l===6||l===7)?(e.exit("htmlFlowData"),e.check(L5,ae,se)(I)):I===null||Ue(I)?(e.exit("htmlFlowData"),se(I)):(e.consume(I),J)}function se(I){return e.check(j5,le,ae)(I)}function le(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),re}function re(I){return I===null||Ue(I)?se(I):(e.enter("htmlFlowData"),J(I))}function Q(I){return I===45?(e.consume(I),P):J(I)}function F(I){return I===47?(e.consume(I),d="",fe):J(I)}function fe(I){if(I===62){const Te=d.toLowerCase();return Yx.includes(Te)?(e.consume(I),q):J(I)}return Mn(I)&&d.length<8?(e.consume(I),d+=String.fromCharCode(I),fe):J(I)}function Ce(I){return I===93?(e.consume(I),P):J(I)}function P(I){return I===62?(e.consume(I),q):I===45&&l===2?(e.consume(I),P):J(I)}function q(I){return I===null||Ue(I)?(e.exit("htmlFlowData"),ae(I)):(e.consume(I),q)}function ae(I){return e.exit("htmlFlow"),t(I)}}function U5(e,t,a){const s=this;return l;function l(d){return Ue(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),u):a(d)}function u(d){return s.parser.lazy[s.now().line]?a(d):t(d)}}function H5(e,t,a){return s;function s(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),e.attempt(vo,t,a)}}const F5={name:"htmlText",tokenize:z5};function z5(e,t,a){const s=this;let l,u,d;return f;function f(P){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(P),m}function m(P){return P===33?(e.consume(P),h):P===47?(e.consume(P),K):P===63?(e.consume(P),w):Mn(P)?(e.consume(P),V):a(P)}function h(P){return P===45?(e.consume(P),x):P===91?(e.consume(P),u=0,N):Mn(P)?(e.consume(P),R):a(P)}function x(P){return P===45?(e.consume(P),T):a(P)}function b(P){return P===null?a(P):P===45?(e.consume(P),y):Ue(P)?(d=b,F(P)):(e.consume(P),b)}function y(P){return P===45?(e.consume(P),T):b(P)}function T(P){return P===62?Q(P):P===45?y(P):b(P)}function N(P){const q="CDATA[";return P===q.charCodeAt(u++)?(e.consume(P),u===q.length?v:N):a(P)}function v(P){return P===null?a(P):P===93?(e.consume(P),S):Ue(P)?(d=v,F(P)):(e.consume(P),v)}function S(P){return P===93?(e.consume(P),C):v(P)}function C(P){return P===62?Q(P):P===93?(e.consume(P),C):v(P)}function R(P){return P===null||P===62?Q(P):Ue(P)?(d=R,F(P)):(e.consume(P),R)}function w(P){return P===null?a(P):P===63?(e.consume(P),D):Ue(P)?(d=w,F(P)):(e.consume(P),w)}function D(P){return P===62?Q(P):w(P)}function K(P){return Mn(P)?(e.consume(P),L):a(P)}function L(P){return P===45||vn(P)?(e.consume(P),L):M(P)}function M(P){return Ue(P)?(d=M,F(P)):rt(P)?(e.consume(P),M):Q(P)}function V(P){return P===45||vn(P)?(e.consume(P),V):P===47||P===62||Rt(P)?W(P):a(P)}function W(P){return P===47?(e.consume(P),Q):P===58||P===95||Mn(P)?(e.consume(P),j):Ue(P)?(d=W,F(P)):rt(P)?(e.consume(P),W):Q(P)}function j(P){return P===45||P===46||P===58||P===95||vn(P)?(e.consume(P),j):U(P)}function U(P){return P===61?(e.consume(P),J):Ue(P)?(d=U,F(P)):rt(P)?(e.consume(P),U):W(P)}function J(P){return P===null||P===60||P===61||P===62||P===96?a(P):P===34||P===39?(e.consume(P),l=P,se):Ue(P)?(d=J,F(P)):rt(P)?(e.consume(P),J):(e.consume(P),le)}function se(P){return P===l?(e.consume(P),l=void 0,re):P===null?a(P):Ue(P)?(d=se,F(P)):(e.consume(P),se)}function le(P){return P===null||P===34||P===39||P===60||P===61||P===96?a(P):P===47||P===62||Rt(P)?W(P):(e.consume(P),le)}function re(P){return P===47||P===62||Rt(P)?W(P):a(P)}function Q(P){return P===62?(e.consume(P),e.exit("htmlTextData"),e.exit("htmlText"),t):a(P)}function F(P){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),fe}function fe(P){return rt(P)?ct(e,Ce,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):Ce(P)}function Ce(P){return e.enter("htmlTextData"),d(P)}}const $h={name:"labelEnd",resolveAll:G5,resolveTo:K5,tokenize:V5},q5={tokenize:Q5},Y5={tokenize:X5},$5={tokenize:W5};function G5(e){let t=-1;const a=[];for(;++t<e.length;){const s=e[t][1];if(a.push(e[t]),s.type==="labelImage"||s.type==="labelLink"||s.type==="labelEnd"){const l=s.type==="labelImage"?4:2;s.type="data",t+=l}}return e.length!==a.length&&la(e,0,e.length,a),e}function K5(e,t){let a=e.length,s=0,l,u,d,f;for(;a--;)if(l=e[a][1],u){if(l.type==="link"||l.type==="labelLink"&&l._inactive)break;e[a][0]==="enter"&&l.type==="labelLink"&&(l._inactive=!0)}else if(d){if(e[a][0]==="enter"&&(l.type==="labelImage"||l.type==="labelLink")&&!l._balanced&&(u=a,l.type!=="labelLink")){s=2;break}}else l.type==="labelEnd"&&(d=a);const m={type:e[u][1].type==="labelLink"?"link":"image",start:{...e[u][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[u][1].start},end:{...e[d][1].end}},x={type:"labelText",start:{...e[u+s+2][1].end},end:{...e[d-2][1].start}};return f=[["enter",m,t],["enter",h,t]],f=_a(f,e.slice(u+1,u+s+3)),f=_a(f,[["enter",x,t]]),f=_a(f,Gc(t.parser.constructs.insideSpan.null,e.slice(u+s+4,d-3),t)),f=_a(f,[["exit",x,t],e[d-2],e[d-1],["exit",h,t]]),f=_a(f,e.slice(d+1)),f=_a(f,[["exit",m,t]]),la(e,u,e.length,f),e}function V5(e,t,a){const s=this;let l=s.events.length,u,d;for(;l--;)if((s.events[l][1].type==="labelImage"||s.events[l][1].type==="labelLink")&&!s.events[l][1]._balanced){u=s.events[l][1];break}return f;function f(y){return u?u._inactive?b(y):(d=s.parser.defined.includes(Ma(s.sliceSerialize({start:u.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(y),e.exit("labelMarker"),e.exit("labelEnd"),m):a(y)}function m(y){return y===40?e.attempt(q5,x,d?x:b)(y):y===91?e.attempt(Y5,x,d?h:b)(y):d?x(y):b(y)}function h(y){return e.attempt($5,x,b)(y)}function x(y){return t(y)}function b(y){return u._balanced=!0,a(y)}}function Q5(e,t,a){return s;function s(b){return e.enter("resource"),e.enter("resourceMarker"),e.consume(b),e.exit("resourceMarker"),l}function l(b){return Rt(b)?ao(e,u)(b):u(b)}function u(b){return b===41?x(b):jy(e,d,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function d(b){return Rt(b)?ao(e,m)(b):x(b)}function f(b){return a(b)}function m(b){return b===34||b===39||b===40?Py(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):x(b)}function h(b){return Rt(b)?ao(e,x)(b):x(b)}function x(b){return b===41?(e.enter("resourceMarker"),e.consume(b),e.exit("resourceMarker"),e.exit("resource"),t):a(b)}}function X5(e,t,a){const s=this;return l;function l(f){return By.call(s,e,u,d,"reference","referenceMarker","referenceString")(f)}function u(f){return s.parser.defined.includes(Ma(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(f):a(f)}function d(f){return a(f)}}function W5(e,t,a){return s;function s(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),l}function l(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),t):a(u)}}const Z5={name:"labelStartImage",resolveAll:$h.resolveAll,tokenize:J5};function J5(e,t,a){const s=this;return l;function l(f){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(f),e.exit("labelImageMarker"),u}function u(f){return f===91?(e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelImage"),d):a(f)}function d(f){return f===94&&"_hiddenFootnoteSupport"in s.parser.constructs?a(f):t(f)}}const ek={name:"labelStartLink",resolveAll:$h.resolveAll,tokenize:tk};function tk(e,t,a){const s=this;return l;function l(d){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelLink"),u}function u(d){return d===94&&"_hiddenFootnoteSupport"in s.parser.constructs?a(d):t(d)}}const _m={name:"lineEnding",tokenize:nk};function nk(e,t){return a;function a(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),ct(e,t,"linePrefix")}}const uc={name:"thematicBreak",tokenize:ak};function ak(e,t,a){let s=0,l;return u;function u(h){return e.enter("thematicBreak"),d(h)}function d(h){return l=h,f(h)}function f(h){return h===l?(e.enter("thematicBreakSequence"),m(h)):s>=3&&(h===null||Ue(h))?(e.exit("thematicBreak"),t(h)):a(h)}function m(h){return h===l?(e.consume(h),s++,m):(e.exit("thematicBreakSequence"),rt(h)?ct(e,f,"whitespace")(h):f(h))}}const Kn={continuation:{tokenize:lk},exit:uk,name:"list",tokenize:ik},rk={partial:!0,tokenize:ck},sk={partial:!0,tokenize:ok};function ik(e,t,a){const s=this,l=s.events[s.events.length-1];let u=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,d=0;return f;function f(T){const N=s.containerState.type||(T===42||T===43||T===45?"listUnordered":"listOrdered");if(N==="listUnordered"?!s.containerState.marker||T===s.containerState.marker:ah(T)){if(s.containerState.type||(s.containerState.type=N,e.enter(N,{_container:!0})),N==="listUnordered")return e.enter("listItemPrefix"),T===42||T===45?e.check(uc,a,h)(T):h(T);if(!s.interrupt||T===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(T)}return a(T)}function m(T){return ah(T)&&++d<10?(e.consume(T),m):(!s.interrupt||d<2)&&(s.containerState.marker?T===s.containerState.marker:T===41||T===46)?(e.exit("listItemValue"),h(T)):a(T)}function h(T){return e.enter("listItemMarker"),e.consume(T),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||T,e.check(vo,s.interrupt?a:x,e.attempt(rk,y,b))}function x(T){return s.containerState.initialBlankLine=!0,u++,y(T)}function b(T){return rt(T)?(e.enter("listItemPrefixWhitespace"),e.consume(T),e.exit("listItemPrefixWhitespace"),y):a(T)}function y(T){return s.containerState.size=u+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(T)}}function lk(e,t,a){const s=this;return s.containerState._closeFlow=void 0,e.check(vo,l,u);function l(f){return s.containerState.furtherBlankLines=s.containerState.furtherBlankLines||s.containerState.initialBlankLine,ct(e,t,"listItemIndent",s.containerState.size+1)(f)}function u(f){return s.containerState.furtherBlankLines||!rt(f)?(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,d(f)):(s.containerState.furtherBlankLines=void 0,s.containerState.initialBlankLine=void 0,e.attempt(sk,t,d)(f))}function d(f){return s.containerState._closeFlow=!0,s.interrupt=void 0,ct(e,e.attempt(Kn,t,a),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function ok(e,t,a){const s=this;return ct(e,l,"listItemIndent",s.containerState.size+1);function l(u){const d=s.events[s.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===s.containerState.size?t(u):a(u)}}function uk(e){e.exit(this.containerState.type)}function ck(e,t,a){const s=this;return ct(e,l,"listItemPrefixWhitespace",s.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(u){const d=s.events[s.events.length-1];return!rt(u)&&d&&d[1].type==="listItemPrefixWhitespace"?t(u):a(u)}}const $x={name:"setextUnderline",resolveTo:dk,tokenize:fk};function dk(e,t){let a=e.length,s,l,u;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){s=a;break}e[a][1].type==="paragraph"&&(l=a)}else e[a][1].type==="content"&&e.splice(a,1),!u&&e[a][1].type==="definition"&&(u=a);const d={type:"setextHeading",start:{...e[s][1].start},end:{...e[e.length-1][1].end}};return e[l][1].type="setextHeadingText",u?(e.splice(l,0,["enter",d,t]),e.splice(u+1,0,["exit",e[s][1],t]),e[s][1].end={...e[u][1].end}):e[s][1]=d,e.push(["exit",d,t]),e}function fk(e,t,a){const s=this;let l;return u;function u(h){let x=s.events.length,b;for(;x--;)if(s.events[x][1].type!=="lineEnding"&&s.events[x][1].type!=="linePrefix"&&s.events[x][1].type!=="content"){b=s.events[x][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||b)?(e.enter("setextHeadingLine"),l=h,d(h)):a(h)}function d(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===l?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),rt(h)?ct(e,m,"lineSuffix")(h):m(h))}function m(h){return h===null||Ue(h)?(e.exit("setextHeadingLine"),t(h)):a(h)}}const mk={tokenize:hk};function hk(e){const t=this,a=e.attempt(vo,s,e.attempt(this.parser.constructs.flowInitial,l,ct(e,e.attempt(this.parser.constructs.flow,l,e.attempt(E5,l)),"linePrefix")));return a;function s(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),t.currentConstruct=void 0,a}function l(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),t.currentConstruct=void 0,a}}const pk={resolveAll:Hy()},gk=Uy("string"),bk=Uy("text");function Uy(e){return{resolveAll:Hy(e==="text"?xk:void 0),tokenize:t};function t(a){const s=this,l=this.parser.constructs[e],u=a.attempt(l,d,f);return d;function d(x){return h(x)?u(x):f(x)}function f(x){if(x===null){a.consume(x);return}return a.enter("data"),a.consume(x),m}function m(x){return h(x)?(a.exit("data"),u(x)):(a.consume(x),m)}function h(x){if(x===null)return!0;const b=l[x];let y=-1;if(b)for(;++y<b.length;){const T=b[y];if(!T.previous||T.previous.call(s,s.previous))return!0}return!1}}}function Hy(e){return t;function t(a,s){let l=-1,u;for(;++l<=a.length;)u===void 0?a[l]&&a[l][1].type==="data"&&(u=l,l++):(!a[l]||a[l][1].type!=="data")&&(l!==u+2&&(a[u][1].end=a[l-1][1].end,a.splice(u+2,l-u-2),l=u+2),u=void 0);return e?e(a,s):a}}function xk(e,t){let a=0;for(;++a<=e.length;)if((a===e.length||e[a][1].type==="lineEnding")&&e[a-1][1].type==="data"){const s=e[a-1][1],l=t.sliceStream(s);let u=l.length,d=-1,f=0,m;for(;u--;){const h=l[u];if(typeof h=="string"){for(d=h.length;h.charCodeAt(d-1)===32;)f++,d--;if(d)break;d=-1}else if(h===-2)m=!0,f++;else if(h!==-1){u++;break}}if(t._contentTypeTextTrailing&&a===e.length&&(f=0),f){const h={type:a===e.length||m||f<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:u?d:s.start._bufferIndex+d,_index:s.start._index+u,line:s.end.line,column:s.end.column-f,offset:s.end.offset-f},end:{...s.end}};s.end={...h.start},s.start.offset===s.end.offset?Object.assign(s,h):(e.splice(a,0,["enter",h,t],["exit",h,t]),a+=2)}a++}return e}const Ek={42:Kn,43:Kn,45:Kn,48:Kn,49:Kn,50:Kn,51:Kn,52:Kn,53:Kn,54:Kn,55:Kn,56:Kn,57:Kn,62:Iy},yk={91:S5},Tk={[-2]:Tm,[-1]:Tm,32:Tm},_k={35:R5,42:uc,45:[$x,uc],60:D5,61:$x,95:uc,96:qx,126:qx},Nk={38:Dy,92:My},Sk={[-5]:_m,[-4]:_m,[-3]:_m,33:Z5,38:Dy,42:rh,60:[e5,F5],91:ek,92:[w5,My],93:$h,95:rh,96:m5},vk={null:[rh,pk]},Ak={null:[42,95]},Ck={null:[]},wk=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Ak,contentInitial:yk,disable:Ck,document:Ek,flow:_k,flowInitial:Tk,insideSpan:vk,string:Nk,text:Sk},Symbol.toStringTag,{value:"Module"}));function kk(e,t,a){let s={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const l={},u=[];let d=[],f=[];const m={attempt:M(K),check:M(L),consume:R,enter:w,exit:D,interrupt:M(L,{interrupt:!0})},h={code:null,containerState:{},defineSkip:v,events:[],now:N,parser:e,previous:null,sliceSerialize:y,sliceStream:T,write:b};let x=t.tokenize.call(h,m);return t.resolveAll&&u.push(t),h;function b(U){return d=_a(d,U),S(),d[d.length-1]!==null?[]:(V(t,0),h.events=Gc(u,h.events,h),h.events)}function y(U,J){return Ok(T(U),J)}function T(U){return Rk(d,U)}function N(){const{_bufferIndex:U,_index:J,line:se,column:le,offset:re}=s;return{_bufferIndex:U,_index:J,line:se,column:le,offset:re}}function v(U){l[U.line]=U.column,j()}function S(){let U;for(;s._index<d.length;){const J=d[s._index];if(typeof J=="string")for(U=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===U&&s._bufferIndex<J.length;)C(J.charCodeAt(s._bufferIndex));else C(J)}}function C(U){x=x(U)}function R(U){Ue(U)?(s.line++,s.column=1,s.offset+=U===-3?2:1,j()):U!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===d[s._index].length&&(s._bufferIndex=-1,s._index++)),h.previous=U}function w(U,J){const se=J||{};return se.type=U,se.start=N(),h.events.push(["enter",se,h]),f.push(se),se}function D(U){const J=f.pop();return J.end=N(),h.events.push(["exit",J,h]),J}function K(U,J){V(U,J.from)}function L(U,J){J.restore()}function M(U,J){return se;function se(le,re,Q){let F,fe,Ce,P;return Array.isArray(le)?ae(le):"tokenize"in le?ae([le]):q(le);function q(Re){return Ye;function Ye(dt){const ut=dt!==null&&Re[dt],Ft=dt!==null&&Re.null,Tn=[...Array.isArray(ut)?ut:ut?[ut]:[],...Array.isArray(Ft)?Ft:Ft?[Ft]:[]];return ae(Tn)(dt)}}function ae(Re){return F=Re,fe=0,Re.length===0?Q:I(Re[fe])}function I(Re){return Ye;function Ye(dt){return P=W(),Ce=Re,Re.partial||(h.currentConstruct=Re),Re.name&&h.parser.constructs.disable.null.includes(Re.name)?ke():Re.tokenize.call(J?Object.assign(Object.create(h),J):h,m,Te,ke)(dt)}}function Te(Re){return U(Ce,P),re}function ke(Re){return P.restore(),++fe<F.length?I(F[fe]):Q}}}function V(U,J){U.resolveAll&&!u.includes(U)&&u.push(U),U.resolve&&la(h.events,J,h.events.length-J,U.resolve(h.events.slice(J),h)),U.resolveTo&&(h.events=U.resolveTo(h.events,h))}function W(){const U=N(),J=h.previous,se=h.currentConstruct,le=h.events.length,re=Array.from(f);return{from:le,restore:Q};function Q(){s=U,h.previous=J,h.currentConstruct=se,h.events.length=le,f=re,j()}}function j(){s.line in l&&s.column<2&&(s.column=l[s.line],s.offset+=l[s.line]-1)}}function Rk(e,t){const a=t.start._index,s=t.start._bufferIndex,l=t.end._index,u=t.end._bufferIndex;let d;if(a===l)d=[e[a].slice(s,u)];else{if(d=e.slice(a,l),s>-1){const f=d[0];typeof f=="string"?d[0]=f.slice(s):d.shift()}u>0&&d.push(e[l].slice(0,u))}return d}function Ok(e,t){let a=-1;const s=[];let l;for(;++a<e.length;){const u=e[a];let d;if(typeof u=="string")d=u;else switch(u){case-5:{d="\r";break}case-4:{d=`
@@ -466,7 +466,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Kt=xe,xt=je),et===void
466
466
  `,1;if(tl>1e5&&tl>De.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Et+=Xe,Xe.length}const pn=Rn(xe);if(!pn)throw _t(Ct.replace("{}",xe)),new Error('Unknown language: "'+xe+'"');const jo=Wt(pn);let ni="",ze=xt||jo;const Bo={},Jt=new we.__emitter(we);el();let Et="",Ir=0,sr=0,tl=0,Mr=!1;try{if(pn.__emitTokens)pn.__emitTokens(je,Jt);else{for(ze.matcher.considerAll();;){tl++,Mr?Mr=!1:ze.matcher.considerAll(),ze.matcher.lastIndex=sr;const _e=ze.matcher.exec(je);if(!_e)break;const De=je.substring(sr,_e.index),Xe=ti(De,_e);sr=_e.index+Xe}ti(je.substring(sr))}return Jt.finalize(),ni=Jt.toHTML(),{language:xe,value:ni,relevance:Ir,illegal:!1,_emitter:Jt,_top:ze}}catch(_e){if(_e.message&&_e.message.includes("Illegal"))return{language:xe,value:kn(je),illegal:!0,relevance:0,_illegalBy:{message:_e.message,index:sr,context:je.slice(sr-100,sr+100),mode:_e.mode,resultSoFar:ni},_emitter:Jt};if(Mt)return{language:xe,value:kn(je),illegal:!1,relevance:0,errorRaised:_e,_emitter:Jt,_top:ze};throw _e}}function Xs(xe){const je={value:kn(xe),illegal:!1,relevance:0,_top:Me,_emitter:new we.__emitter(we)};return je._emitter.addText(xe),je}function Ws(xe,je){je=je||we.languages||Object.keys(me);const et=Xs(xe),xt=je.filter(Rn).filter(Rr).map(It=>nr(It,xe,!1));xt.unshift(et);const Kt=xt.sort((It,Zn)=>{if(It.relevance!==Zn.relevance)return Zn.relevance-It.relevance;if(It.language&&Zn.language){if(Rn(It.language).supersetOf===Zn.language)return 1;if(Rn(Zn.language).supersetOf===It.language)return-1}return 0}),[Nn,Wn]=Kt,Bn=Nn;return Bn.secondBest=Wn,Bn}function Ua(xe,je,et){const xt=je&&Se[je]||et;xe.classList.add("hljs"),xe.classList.add(`language-${xt}`)}function Gt(xe){let je=null;const et=$t(xe);if(qe(et))return;if(gs("before:highlightElement",{el:xe,language:et}),xe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",xe);return}if(xe.children.length>0&&(we.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(xe)),we.throwUnescapedHTML))throw new Pa("One of your code blocks includes unescaped HTML.",xe.innerHTML);je=xe;const xt=je.textContent,Kt=et?jt(xt,{language:et,ignoreIllegals:!0}):Ws(xt);xe.innerHTML=Kt.value,xe.dataset.highlighted="yes",Ua(xe,et,Kt.language),xe.result={language:Kt.language,re:Kt.relevance,relevance:Kt.relevance},Kt.secondBest&&(xe.secondBest={language:Kt.secondBest.language,relevance:Kt.secondBest.relevance}),gs("after:highlightElement",{el:xe,result:Kt,text:xt})}function _n(xe){we=Oo(we,xe)}const kr=()=>{Zs(),ce("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Wi(){Zs(),ce("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Io=!1;function Zs(){function xe(){Zs()}if(document.readyState==="loading"){Io||window.addEventListener("DOMContentLoaded",xe,!1),Io=!0;return}document.querySelectorAll(we.cssSelector).forEach(Gt)}function Mo(xe,je){let et=null;try{et=je($)}catch(xt){if(_t("Language definition for '{}' could not be registered.".replace("{}",xe)),Mt)_t(xt);else throw xt;et=Me}et.name||(et.name=xe),me[xe]=et,et.rawDefinition=je.bind(null,$),et.aliases&&ar(et.aliases,{languageName:xe})}function ps(xe){delete me[xe];for(const je of Object.keys(Se))Se[je]===xe&&delete Se[je]}function Zi(){return Object.keys(me)}function Rn(xe){return xe=(xe||"").toLowerCase(),me[xe]||me[Se[xe]]}function ar(xe,{languageName:je}){typeof xe=="string"&&(xe=[xe]),xe.forEach(et=>{Se[et.toLowerCase()]=je})}function Rr(xe){const je=Rn(xe);return je&&!je.disableAutodetect}function Or(xe){xe["before:highlightBlock"]&&!xe["before:highlightElement"]&&(xe["before:highlightElement"]=je=>{xe["before:highlightBlock"](Object.assign({block:je.el},je))}),xe["after:highlightBlock"]&&!xe["after:highlightElement"]&&(xe["after:highlightElement"]=je=>{xe["after:highlightBlock"](Object.assign({block:je.el},je))})}function Zt(xe){Or(xe),$e.push(xe)}function Do(xe){const je=$e.indexOf(xe);je!==-1&&$e.splice(je,1)}function gs(xe,je){const et=xe;$e.forEach(function(xt){xt[et]&&xt[et](je)})}function rr(xe){return ce("10.7.0","highlightBlock will be removed entirely in v12.0"),ce("10.7.0","Please use highlightElement now."),Gt(xe)}Object.assign($,{highlight:jt,highlightAuto:Ws,highlightAll:Zs,highlightElement:Gt,highlightBlock:rr,configure:_n,initHighlighting:kr,initHighlightingOnLoad:Wi,registerLanguage:Mo,unregisterLanguage:ps,listLanguages:Zi,getLanguage:Rn,registerAliases:ar,autoDetection:Rr,inherit:Oo,addPlugin:Zt,removePlugin:Do}),$.debugMode=function(){Mt=!1},$.safeMode=function(){Mt=!0},$.versionString=bt,$.regex={concat:v,lookahead:y,either:C,optional:N,anyNumberOfTimes:T};for(const xe in Ft)typeof Ft[xe]=="object"&&e(Ft[xe]);return Object.assign($,Ft),$},jn=hs({});return jn.newInstance=()=>hs({}),Bm=jn,jn.HighlightJS=jn,jn.default=jn,Bm}var bM=gM();const xM=Ic(bM),w1={},EM="hljs-";function yM(e){const t=xM.newInstance();return e&&u(e),{highlight:a,highlightAuto:s,listLanguages:l,register:u,registerAlias:d,registered:f};function a(m,h,x){const b=x||w1,y=typeof b.prefix=="string"?b.prefix:EM;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:TM,classPrefix:y});const T=t.highlight(h,{ignoreIllegals:!0,language:m});if(T.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:T.errorRaised});const N=T._emitter.root,v=N.data;return v.language=T.language,v.relevance=T.relevance,N}function s(m,h){const b=(h||w1).subset||l();let y=-1,T=0,N;for(;++y<b.length;){const v=b[y];if(!t.getLanguage(v))continue;const S=a(v,m,h);S.data&&S.data.relevance!==void 0&&S.data.relevance>T&&(T=S.data.relevance,N=S)}return N||{type:"root",children:[],data:{language:void 0,relevance:T}}}function l(){return t.listLanguages()}function u(m,h){if(typeof m=="string")t.registerLanguage(m,h);else{let x;for(x in m)Object.hasOwn(m,x)&&t.registerLanguage(x,m[x])}}function d(m,h){if(typeof m=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:m});else{let x;for(x in m)if(Object.hasOwn(m,x)){const b=m[x];t.registerAliases(typeof b=="string"?b:[...b],{languageName:x})}}}function f(m){return!!t.getLanguage(m)}}class TM{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const a=this.stack[this.stack.length-1],s=a.children[a.children.length-1];s&&s.type==="text"?s.value+=t:a.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,a){const s=this.stack[this.stack.length-1],l=t.root.children;a?s.children.push({type:"element",tagName:"span",properties:{className:[a]},children:l}):s.children.push(...l)}openNode(t){const a=this,s=t.split(".").map(function(d,f){return f?d+"_".repeat(f):a.options.classPrefix+d}),l=this.stack[this.stack.length-1],u={type:"element",tagName:"span",properties:{className:s},children:[]};l.children.push(u),this.stack.push(u)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const _M={};function NM(e){const t=e||_M,a=t.aliases,s=t.detect||!1,l=t.languages||pM,u=t.plainText,d=t.prefix,f=t.subset;let m="hljs";const h=yM(l);if(a&&h.registerAlias(a),d){const x=d.indexOf("-");m=x===-1?d:d.slice(0,x)}return function(x,b){Co(x,"element",function(y,T,N){if(y.tagName!=="code"||!N||N.type!=="element"||N.tagName!=="pre")return;const v=SM(y);if(v===!1||!v&&!s||v&&u&&u.includes(v))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(m)||y.properties.className.unshift(m);const S=zI(y,{whitespace:"pre"});let C;try{C=v?h.highlight(v,S,{prefix:d}):h.highlightAuto(S,{prefix:d,subset:f})}catch(R){const w=R;if(v&&/Unknown language/.test(w.message)){b.message("Cannot highlight as `"+v+"`, it’s not registered",{ancestors:[N,y],cause:w,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw w}!v&&C.data&&C.data.language&&y.properties.className.push("language-"+C.data.language),C.children.length>0&&(y.children=C.children)})}}function SM(e){const t=e.properties.className;let a=-1;if(!Array.isArray(t))return;let s;for(;++a<t.length;){const l=String(t[a]);if(l==="no-highlight"||l==="nohighlight")return!1;!s&&l.slice(0,5)==="lang-"&&(s=l.slice(5)),!s&&l.slice(0,9)==="language-"&&(s=l.slice(9))}return s}function vM({q:e,pending:t,selected:a,customText:s,onSelect:l,onCustomTextChange:u,onClearSelections:d,onSubmitCustom:f,isSingle:m}){const[h,x]=A.useState(!1),b=h||s.length>0;return o.jsxs("div",{className:"space-y-2",children:[e.header&&o.jsx("div",{className:"text-xs font-semibold text-fg-3",children:e.header}),o.jsx("p",{className:"text-sm text-fg-2",children:e.question}),e.options.length>0&&o.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.options.map(y=>{const T=!b&&((a==null?void 0:a.includes(y.label))??!1);return o.jsxs("button",{type:"button",disabled:!t,onClick:()=>{x(!1),u(""),l(y.label)},className:oe("rounded-md border px-3 py-1.5 text-left text-xs transition-colors",T?"border-emerald-500/60 bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/30":t?"border-blue-500/40 bg-blue-500/10 text-blue-300 hover:bg-blue-500/20":"border-line bg-surface/50 text-fg-5 cursor-default"),children:[T&&o.jsx(oa,{className:"mr-1 inline h-3 w-3"}),o.jsx("span",{className:"font-medium",children:y.label}),y.description&&o.jsx("span",{className:"ml-1.5 text-fg-5",children:y.description})]},y.label)}),t&&o.jsxs("button",{type:"button",onClick:()=>{b?(x(!1),u("")):(x(!0),d())},className:oe("rounded-md border px-3 py-1.5 text-left text-xs transition-colors",b?"border-emerald-500/60 bg-emerald-500/20 text-emerald-300 ring-1 ring-emerald-500/30":"border-dashed border-blue-500/40 text-blue-300 hover:bg-blue-500/10"),children:[b&&o.jsx(oa,{className:"mr-1 inline h-3 w-3"}),o.jsx("span",{className:"font-medium",children:"其他…"})]})]}),b&&t&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"text",value:s,onChange:y=>{u(y.target.value),y.target.value&&d()},onKeyDown:y=>{y.key==="Enter"&&s.trim()&&m&&f&&f()},placeholder:"输入自定义回复…",autoFocus:!0,className:"flex-1 rounded-md border border-blue-500/40 bg-blue-500/5 px-3 py-1.5 text-xs text-fg-1 placeholder:text-fg-5 outline-none focus:border-blue-500/60 focus:ring-1 focus:ring-blue-500/30"}),m&&o.jsx("button",{type:"button",disabled:!s.trim(),onClick:f,className:oe("flex items-center gap-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",s.trim()?"bg-emerald-600 text-white hover:bg-emerald-500":"bg-surface/50 text-fg-5 cursor-not-allowed"),children:o.jsx(bc,{className:"h-3 w-3"})})]})]})}function AM({part:e}){const t=GC(e),a=Ph(e),s=a==="pending"||a==="running",l=Ie(V=>V.activeSessionId),u=Ie(V=>V.replyQuestion),d=Ie(V=>V.rejectQuestion),[f,m]=A.useState(null),[h,x]=A.useState({}),[b,y]=A.useState({});if(!t||t.length===0)return null;const T=t.length===1,N=()=>{l&&Yt.getState().removeToast(`question-${l}`)},v=(V,W)=>{if(!f){if(y(j=>{const{[V]:U,...J}=j;return J}),T){m("answered"),N(),u([[W]]);return}x(j=>{const U=t[V],J=j[V]??[];if(U.multiple){const se=J.includes(W);return{...j,[V]:se?J.filter(le=>le!==W):[...J,W]}}return{...j,[V]:[W]}})}},S=(V,W)=>{y(j=>{if(W)return{...j,[V]:W};const{[V]:U,...J}=j;return J})},C=V=>{x(W=>{const{[V]:j,...U}=W;return U})},R=V=>{var j;const W=(j=b[V])==null?void 0:j.trim();f||!W||(m("answered"),N(),u([[W]]))},w=t.filter((V,W)=>{var j,U;return(((j=h[W])==null?void 0:j.length)??0)>0||(((U=b[W])==null?void 0:U.trim().length)??0)>0}).length,D=!T&&w===t.length,K=()=>{if(f||!D)return;m("answered"),N();const V=t.map((W,j)=>{var J;const U=(J=b[j])==null?void 0:J.trim();return U?[U]:h[j]??[]});u(V)},L=()=>{f||(m("dismissed"),N(),d())},M=s&&!f;return o.jsxs("div",{className:oe("my-1 overflow-hidden rounded-md border bg-term/70",M?"border-blue-500/40":"border-line"),children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 font-mono text-xs",children:[o.jsx(UA,{className:oe("h-3.5 w-3.5 shrink-0",M?"text-blue-400":"text-fg-4")}),o.jsx("span",{className:oe("font-medium",M?"text-blue-300":"text-fg-3"),children:f==="answered"?"已回复":f==="dismissed"?"已取消":M?"等待回复":"Question"}),!T&&M&&o.jsxs("span",{className:"text-fg-5",children:["(",w,"/",t.length,")"]}),M&&o.jsxs("button",{type:"button",onClick:L,className:"ml-auto flex items-center gap-1 rounded px-1.5 py-0.5 text-fg-5 transition-colors hover:bg-red-500/10 hover:text-red-400",children:[o.jsx(gt,{className:"h-3 w-3"}),o.jsx("span",{children:"取消"})]})]}),o.jsxs("div",{className:"border-t border-line px-4 py-3 space-y-3",children:[t.map((V,W)=>o.jsx(vM,{q:V,pending:M,selected:h[W],customText:b[W]??"",onSelect:j=>v(W,j),onCustomTextChange:j=>S(W,j),onClearSelections:()=>C(W),onSubmitCustom:T?()=>R(W):void 0,isSingle:T},W)),!T&&M&&o.jsx("div",{className:"flex justify-end pt-1",children:o.jsxs("button",{type:"button",disabled:!D,onClick:K,className:oe("flex items-center gap-1.5 rounded-md px-4 py-1.5 text-xs font-medium transition-colors",D?"bg-emerald-600 text-white hover:bg-emerald-500":"bg-surface/50 text-fg-5 cursor-not-allowed"),children:[o.jsx(bc,{className:"h-3 w-3"}),o.jsx("span",{children:"提交回答"})]})})]})]})}const Pm=2e3,CM={read:"Read",write:"Write",edit:"Edit",patch:"Patch",grep:"Grep",glob:"Glob",bash:"Bash",shell:"Bash",list:"List",ls:"List",webfetch:"Fetch",fetch:"Fetch",task:"Task",agent:"Task",todowrite:"Todo",write_todos:"Todo",question:"Question",mcp_question:"Question"},wM={running:{glyph:"◌",label:"running",color:"text-amber-400",accent:"border-amber-500/40",spin:!0},completed:{glyph:"✓",label:"done",color:"text-emerald-400",accent:"border-emerald-500/40",spin:!1},error:{glyph:"✗",label:"error",color:"text-red-400",accent:"border-red-500/40",spin:!1},pending:{glyph:"○",label:"queued",color:"text-fg-4",accent:"border-fg-6",spin:!1}};function a0(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Ka(e,t){if(!e)return null;for(const a of t){const s=e[a];if(typeof s=="string"&&s.trim())return s.trim()}return null}function kM(e,t){const a=e.toLowerCase(),s=CM[a]??e.charAt(0).toUpperCase()+e.slice(1),l=a0(t);switch(a){case"read":case"write":case"edit":case"patch":return{label:s,arg:Ka(l,["filePath","path","file"])};case"grep":{const u=Ka(l,["pattern","query"]);return{label:s,arg:u?`"${u}"`:null}}case"glob":return{label:s,arg:Ka(l,["pattern","query"])};case"bash":case"shell":{const u=Ka(l,["command","cmd","script"]);return{label:s,arg:u?u.split(`
467
467
  `)[0]:null}}case"webfetch":case"fetch":return{label:s,arg:Ka(l,["url"])};case"task":case"agent":return{label:s,arg:Ka(l,["description","prompt","title"])};default:return{label:s,arg:Ka(l,["filePath","path","pattern","query","command","url","description"])}}}function RM({oldStr:e,newStr:t}){const a=e.split(`
468
468
  `),s=t.split(`
469
- `);return o.jsxs("div",{className:"grid grid-cols-1 gap-px overflow-x-auto rounded text-xs md:grid-cols-2",children:[o.jsx("pre",{className:"min-w-0 whitespace-pre-wrap break-words p-1.5 fs-diff-del",children:a.map((l,u)=>o.jsxs("div",{children:[o.jsx("span",{className:"select-none text-red-400/70",children:"− "}),o.jsx("span",{className:"text-red-400",children:l})]},u))}),o.jsx("pre",{className:"min-w-0 whitespace-pre-wrap break-words p-1.5 fs-diff-add",children:s.map((l,u)=>o.jsxs("div",{children:[o.jsx("span",{className:"select-none text-emerald-400/70",children:"+ "}),o.jsx("span",{className:"text-emerald-400",children:l})]},u))})]})}const k1={completed:{glyph:"✓",color:"text-emerald-400"},in_progress:{glyph:"◌",color:"text-amber-400"},cancelled:{glyph:"✗",color:"text-fg-5"},pending:{glyph:"○",color:"text-fg-4"}};function qT({todos:e}){return o.jsx("ul",{className:"space-y-0.5 text-xs",children:e.map((t,a)=>{var f;const s=((f=t.status)==null?void 0:f.toLowerCase())??"pending",l=s==="in-progress"||s==="active"?"in_progress":s==="done"||s==="complete"?"completed":s==="canceled"?"cancelled":s,u=k1[l]??k1.pending,d=l==="completed"||l==="cancelled";return o.jsxs("li",{className:"flex items-start gap-1.5",children:[o.jsx("span",{className:oe("shrink-0 leading-5",u.color,l==="in_progress"&&"fs-spin"),children:u.glyph}),o.jsx("span",{className:oe("leading-5",d?"text-fg-5 line-through":"text-fg-2"),children:t.content}),t.priority&&o.jsx("span",{className:"ml-auto shrink-0 text-fg-5",children:t.priority})]},a)})})}const OM={"visual-engineering":"bg-purple-500/15 text-purple-400",quick:"bg-emerald-500/15 text-emerald-400",deep:"bg-blue-500/15 text-blue-400",ultrabrain:"bg-amber-500/15 text-amber-400",artistry:"bg-pink-500/15 text-pink-400",writing:"bg-cyan-500/15 text-cyan-400","unspecified-low":"bg-elevated text-fg-4","unspecified-high":"bg-elevated text-fg-3"},IM={explore:"bg-teal-500/15 text-teal-400",librarian:"bg-indigo-500/15 text-indigo-400",oracle:"bg-amber-500/15 text-amber-400",metis:"bg-rose-500/15 text-rose-400",momus:"bg-orange-500/15 text-orange-400"};function MM({record:e}){const[t,a]=A.useState(!1),s=typeof e.category=="string"?e.category:null,l=typeof e.subagent_type=="string"?e.subagent_type:null,u=Ka(e,["description","title"]),d=typeof e.prompt=="string"?e.prompt:null,f=Array.isArray(e.load_skills)?e.load_skills.filter(y=>typeof y=="string"):[],m=typeof e.run_in_background=="boolean"?e.run_in_background:!1,h=typeof e.task_id=="string"?e.task_id:null,x=s??l,b=(s&&OM[s])??(l&&IM[l])??"bg-elevated text-fg-3";return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[x&&o.jsx("span",{className:oe("rounded px-1.5 py-0.5 text-[10px] font-medium",b),children:x}),f.map(y=>o.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 text-[10px] text-fg-4",children:y},y)),m&&o.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 text-[10px] text-fg-5",children:"bg"}),h&&o.jsxs("span",{className:"rounded bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",title:h,children:["↩ ",h.slice(0,16),"…"]})]}),u&&o.jsx("p",{className:"text-xs text-fg-2",children:u}),d&&o.jsxs("div",{children:[o.jsxs("button",{type:"button",onClick:()=>a(y=>!y),className:"flex items-center gap-1 text-[10px] text-fg-4 transition-colors hover:text-fg-2",children:[o.jsx(Ih,{className:oe("h-3 w-3 transition-transform",t&&"rotate-90")}),"Prompt",o.jsxs("span",{className:"text-fg-5",children:["(",d.length," chars)"]})]}),t&&o.jsx("pre",{className:"mt-1 max-h-60 overflow-y-auto whitespace-pre-wrap break-words rounded bg-elevated/50 p-2 text-[11px] leading-relaxed text-fg-3",children:d})]})]})}function DM(e){const t=VC(e),a=Ie(m=>m.activeSessionId),s=Ie(m=>m.sessions);if(t)return t;if(!a)return null;const l=zc(e),u=a0(l),d=Ka(u,["description","title"]),f=s.filter(m=>m.parentID===a);if(f.length===0)return null;if(f.length===1)return f[0].id;if(d){const m=f.find(h=>h.title===d);if(m)return m.id}return null}function LM({part:e}){const t=DM(e),a=Ie(s=>s.setActiveSession);return t?o.jsxs("button",{type:"button",onClick:s=>{s.stopPropagation(),a(t)},className:"mt-2 flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1 font-mono text-xs text-blue-400 transition-colors hover:border-blue-500/50 hover:bg-blue-500/10",children:[o.jsxs("span",{className:"truncate text-fg-5",children:[t.slice(0,20),"…"]}),o.jsx(Pv,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"shrink-0",children:"查看子会话"})]}):null}function jM(e,t){const a=a0(t);if(!a)return null;const s=e.toLowerCase();if(s==="edit"||s==="patch"){const l=typeof a.oldString=="string"?a.oldString:"",u=typeof a.newString=="string"?a.newString:"";if(l||u)return o.jsx(RM,{oldStr:l,newStr:u})}if(s==="todowrite"||s==="write_todos"){const l=Array.isArray(a.todos)?a.todos:null;if(l&&l.length>0)return o.jsx(qT,{todos:l})}if(s==="bash"||s==="shell"){const l=Ka(a,["command","cmd","script"]);if(l)return o.jsxs("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-fg-2",children:[o.jsx("span",{className:"select-none text-emerald-400/70",children:"❯ "}),l]})}if(s==="task"||s==="agent")return o.jsx(MM,{record:a});if(s==="read")return null;if(s==="write"){const l=typeof a.content=="string"?a.content:null;if(l){const u=l.length>500?`${l.slice(0,500)}…`:l;return o.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-fg-2",children:u})}}return null}function BM(e,t){const a=e.toLowerCase();if(a==="todowrite"||a==="write_todos"){const s=Array.isArray(t)?t:null;if(s&&s.length>0)return o.jsx(qT,{todos:s})}return null}function PM({part:e}){const t=Ph(e),a=t==="running"||t==="pending",[s,l]=A.useState(a),[u,d]=A.useState(!1),f=A.useRef(a);A.useEffect(()=>{f.current!==a&&(l(a),f.current=a)},[a]);const m=my(e),h=m.toLowerCase(),x=h==="task"||h==="agent",b=zc(e),{label:y,arg:T}=kM(m,b),N=jM(m,b),v=N?null:_x(b),S=Bh(e),C=BM(m,S),R=C?"":_x(S),w=wM[t],D=R.length>Pm,K=u||!D?R:`${R.slice(0,Pm)}…`;return o.jsxs("div",{className:"my-1 overflow-hidden rounded-md border border-line bg-term/70",children:[o.jsxs("button",{type:"button",onClick:()=>l(L=>!L),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left font-mono text-xs transition-colors duration-150 hover:bg-surface/70",children:[o.jsx("span",{className:oe("shrink-0 leading-none",w.color),children:s?"▾":"▸"}),o.jsx("span",{className:"shrink-0 font-medium text-fg",children:y}),T&&o.jsx("span",{className:"truncate text-fg-3",children:T}),o.jsxs("span",{className:oe("ml-auto flex shrink-0 items-center gap-1.5 leading-none",w.color),children:[o.jsx("span",{className:oe(w.spin&&"fs-spin"),children:w.glyph}),o.jsx("span",{children:w.label})]})]}),s&&o.jsx("div",{className:"border-t border-line px-3 py-2",children:o.jsxs("div",{className:oe("ml-1 border-l-2 pl-3 font-mono text-xs",w.accent),children:[N&&o.jsx("section",{className:"mb-2",children:N}),v&&o.jsxs("section",{className:"mb-2",children:[o.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-fg-5",children:"input"}),o.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-fg-2",children:v})]}),x&&o.jsx(LM,{part:e}),C&&o.jsx("section",{children:C}),R&&o.jsxs("section",{children:[o.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-fg-5",children:"output"}),o.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-fg-2",children:K}),D&&o.jsx("button",{type:"button",onClick:()=>d(L=>!L),className:"mt-1 text-blue-400 transition-colors hover:text-blue-300",children:u?"show less":`show ${R.length-Pm} more chars`})]}),!N&&!v&&!C&&!R&&o.jsx("div",{className:"text-fg-5",children:"no parameters"})]})})]})}function UM({text:e}){const[t,a]=A.useState(!1);return o.jsxs("div",{className:"my-1",children:[o.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"flex items-center gap-1.5 font-mono text-xs text-fg-5 transition-colors hover:text-fg-3",children:[t?o.jsx(Sr,{className:"h-3 w-3 shrink-0"}):o.jsx(Ih,{className:"h-3 w-3 shrink-0"}),o.jsx(FE,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{children:"thinking"})]}),t&&o.jsx("div",{className:"ml-1.5 mt-1 whitespace-pre-wrap border-l border-line pl-3 text-xs italic leading-relaxed text-fg-4",children:e})]})}function HM(){const[e,t]=A.useState(0);return A.useEffect(()=>{const a=Date.now(),s=setInterval(()=>{t(Math.floor((Date.now()-a)/1e3))},1e3);return()=>clearInterval(s)},[]),o.jsxs("div",{className:"my-1 flex items-center gap-1.5 font-mono text-xs text-fg-5",children:[o.jsx(FE,{className:"h-3 w-3 shrink-0 animate-pulse"}),o.jsx("span",{children:"thinking"}),e>0&&o.jsxs("span",{className:"text-fg-6",children:[e,"s"]})]})}function FM({part:e,isStreaming:t}){switch(jh(e)){case"text":{const s=yc(e);return s.trim()?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[NM],components:{table:e0},children:s})}):null}case"thinking":{const s=yc(e);return s.trim()?o.jsx(UM,{text:s}):t?o.jsx(HM,{}):null}case"tool":return po(e)?o.jsx(AM,{part:e}):o.jsx(PM,{part:e});default:return null}}function zM({message:e,isStreaming:t,queued:a}){var x,b,y,T,N,v;const s=e.role==="user",l=e.parts??[],u=l.filter(S=>jh(S)!=="other");if(s){const S=l.map(yc).join("").trim(),C=(x=e.time)==null?void 0:x.created,R=C?new Date(C*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return o.jsxs("div",{className:"fs-fade-in rounded-r-md border-l-2 border-emerald-500/40 bg-emerald-500/[0.04] px-3 py-2 font-mono",children:[o.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[11px]",children:[o.jsx("span",{className:"font-medium text-emerald-400",children:"You"}),R&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsx("span",{className:"text-fg-5",children:R})]}),a&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-amber-500/30 px-1.5 py-0.5 text-xs text-amber-400",children:[o.jsx("span",{className:"leading-none",children:"○"}),o.jsx("span",{children:"queued"})]})]}),o.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[o.jsx("span",{className:"shrink-0 select-none text-emerald-400",children:"❯"}),o.jsx("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words text-fg",children:S||"…"})]})]})}const d=((b=e.info)==null?void 0:b.agent)??e.agent,f=((y=e.info)==null?void 0:y.modelID)??e.modelID,m=(T=e.info)==null?void 0:T.error,h=(N=e.info)==null?void 0:N.finish;return o.jsxs("div",{className:"fs-fade-in font-mono",children:[(d||f)&&o.jsxs("div",{className:"mb-1 flex items-center gap-2 text-xs",children:[d&&o.jsx("span",{className:"text-fg-3",children:d}),d&&f&&o.jsx("span",{className:"text-fg-6",children:"·"}),f&&o.jsx("span",{className:"text-fg-5",children:f})]}),m&&o.jsxs("div",{className:"my-1 flex items-start gap-2 rounded-md border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-400",children:[o.jsx(Dn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("span",{className:"font-semibold",children:m.name??"Error"}),((v=m.data)==null?void 0:v.message)&&o.jsx("p",{className:"mt-0.5 text-red-400/80",children:m.data.message}),h&&h!=="end"&&o.jsxs("p",{className:"mt-0.5 text-red-400/60",children:["finish: ",h]})]})]}),o.jsx("div",{className:"space-y-2 text-sm text-fg",children:u.length>0?u.map((S,C)=>o.jsx(FM,{part:S,isStreaming:t},S.id??S.callID??C)):!m&&o.jsx("span",{className:"text-fg-5",children:"…"})})]})}const qM={completed:{glyph:"■",color:"text-emerald-400"},in_progress:{glyph:"■",color:"text-amber-400"},cancelled:{glyph:"■",color:"text-fg-6"},pending:{glyph:"□",color:"text-fg-5"}};function YM(e){const t=e.find(s=>Pi(s.status)==="in_progress");if(t)return t.content;const a=e.find(s=>Pi(s.status)==="pending");return a?a.content:"all steps complete"}function $M({todos:e,onClick:t}){if(e.length===0)return null;const a=e.length,s=$C(e);return o.jsx("div",{className:"rounded-md border border-line bg-term/60 px-3 py-2",children:o.jsxs("button",{type:"button",onClick:t,className:"flex w-full items-center gap-2 text-left font-mono text-xs",children:[o.jsxs("span",{className:"shrink-0 tabular-nums text-fg-4",children:["[",s,"/",a,"]"]}),o.jsx("span",{className:"shrink-0 tracking-tight",children:e.map(l=>{const u=qM[Pi(l.status)];return o.jsx("span",{className:u.color,children:u.glyph},l.id)})}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-fg-2",children:YM(e)}),o.jsx("span",{className:"shrink-0 text-[10px] text-fg-5",children:"详情 →"})]})})}const GM=200;function KM(){return Ie(e=>{const t=e.activeSessionId;if(!t)return!1;const a=e.messages[t]??go;for(let s=a.length-1;s>=0;s--){const l=a[s].parts;if(l){for(const u of l)if(jh(u)==="tool"&&Tc(u))return!0}}return!1})}function VM(){const[e,t]=A.useState(""),[a,s]=A.useState(""),[l,u]=A.useState([]),d=A.useRef(null),f=Ie(D=>D.activeSessionId),m=Fe(D=>D.activeRepoId),h=Ie(D=>{const K=D.activeSessionId;return K?D.sessionStatuses[K]:void 0}),x=Ie(D=>D.sendMessage),b=oc(D=>D.setDraft),y=oc(D=>D.clearDraft),T=KM();A.useEffect(()=>{if(!m){u([]);return}let D=!1;return(async()=>{try{const[K,L]=await Promise.all([Fc(),Lh(m)]);if(D)return;const M=K.pinned_models,V=M?JSON.parse(M):[];u(V.length>0?L.filter(W=>V.includes(W.id)):[])}catch{D||u([])}})(),()=>{D=!0}},[m]);const N=h==="busy"&&!T,v=!f;A.useLayoutEffect(()=>{const D=d.current;D&&(D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,GM)}px`)},[e]),A.useEffect(()=>{t(f?oc.getState().drafts[f]??"":"")},[f]);const S=async()=>{const D=e.trim();if(!D||v)return;await x(D,a||void 0)&&(t(""),f&&y(f))},C=D=>{D.nativeEvent.isComposing||D.keyCode===229||D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),S())},R=f?T?"输入回复,或点击上方选项…":N?"输入消息将排队等待处理…":"enter a command…":"select or start a run",w=f?N?"text-amber-400 fs-blink":T?"text-blue-400":"text-emerald-400":"text-fg-6";return o.jsxs("div",{className:"border-t border-line bg-term px-4 py-4",children:[o.jsxs("div",{className:oe("mx-auto flex max-w-4xl items-start gap-2 rounded-lg border px-3 py-2 transition-colors duration-150",v?"border-line":"border-fg-5 focus-within:border-fg-4"),children:[o.jsx("span",{className:oe("select-none pt-px font-mono text-sm leading-6",w),children:"❯"}),o.jsx("textarea",{ref:d,rows:2,value:e,disabled:v,onChange:D=>{const K=D.target.value;t(K),f&&b(f,K)},onKeyDown:C,placeholder:R,className:"flex-1 resize-none bg-transparent font-mono text-sm leading-6 text-fg placeholder:text-fg-6 focus:outline-none disabled:cursor-not-allowed"}),o.jsx("button",{type:"button",onClick:S,disabled:v||e.trim().length===0,"aria-label":"Send message",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-emerald-600 text-white transition-colors duration-150 hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-fg-6/30 disabled:text-fg-5",children:o.jsx(HE,{className:"h-4 w-4",strokeWidth:2.5})})]}),o.jsxs("div",{className:"mx-auto mt-1.5 flex max-w-4xl items-center gap-3 pl-5",children:[o.jsx("span",{className:"font-mono text-[10px] text-fg-6",children:"⏎ to run · shift+⏎ for newline"}),l.length>0&&o.jsxs("select",{value:a,onChange:D=>s(D.target.value),className:"ml-auto max-w-[200px] truncate rounded border border-line bg-surface px-2 py-0.5 font-mono text-[11px] text-fg-4 focus:border-fg-5 focus:outline-none",children:[o.jsx("option",{value:"",children:"默认模型"}),l.map(D=>o.jsx("option",{value:D.id,children:D.name||D.id},D.id))]})]})]})}const R1={idle:{glyph:"●",label:"ready",color:"text-emerald-400",spin:!1},busy:{glyph:"◌",label:"running",color:"text-amber-400",spin:!0},retry:{glyph:"◌",label:"retrying",color:"text-amber-400",spin:!0},error:{glyph:"✗",label:"error",color:"text-red-400",spin:!1}};function QM({status:e,reason:t}){const a=R1[e??"idle"]??R1.idle;return o.jsxs("span",{className:oe("flex items-center gap-1.5 rounded border border-line px-2 py-0.5 font-mono text-xs",a.color),title:e==="error"&&t?t:void 0,children:[o.jsx("span",{className:oe("leading-none",a.spin&&"fs-spin"),children:a.glyph}),o.jsx("span",{children:a.label})]})}const XM={"claude-opus-4":1e6,"claude-sonnet-4":1e6,"claude-sonnet-5":1e6,"claude-opus-5":1e6,"claude-3-7-sonnet":2e5,"claude-3-5-sonnet":2e5,"claude-3-5-haiku":2e5,"claude-3-opus":2e5,"claude-3-sonnet":2e5,"claude-3-haiku":2e5},O1=1e6;function WM(e){if(!e)return O1;for(const[t,a]of Object.entries(XM))if(e.startsWith(t))return a;return O1}function I1(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ZM(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>0?`$${e.toFixed(4)}`:"$0"}function JM(e){for(let t=e.length-1;t>=0;t--){const a=e[t];if(a.role==="assistant"&&a.tokens){const s=a.tokens;if(s.cache&&(s.cache.read>0||s.cache.write>0)||s.input>0||s.output>0)return s}}return null}function eD({session:e,messages:t}){var m,h,x;const a=JM(t),s=(e==null?void 0:e.cost)??0;if(!a&&!s)return null;const l=a?a.input+(((m=a.cache)==null?void 0:m.read)??0)+(((h=a.cache)==null?void 0:h.write)??0):0,u=WM((x=e==null?void 0:e.model)==null?void 0:x.modelID),d=l>0?Math.min(Math.round(l/u*100),999):0,f=d>=80?"text-red-400":d>=50?"text-amber-400":"text-fg-5";return o.jsxs("div",{className:"flex items-center gap-2 font-mono text-[11px] text-fg-5",children:[l>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{title:"当前上下文 = cache_read + cache_write + input (最近一次请求)",children:I1(l)}),o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsxs("span",{className:f,title:`上下文占比 (${I1(u)} 窗口)`,children:[d,"%"]}),o.jsx("span",{className:"text-fg-6",children:"·"})]}),o.jsx("span",{title:"会话累计费用",children:ZM(s)})]})}const tD=144,nD=64;function YT({onToggleSidebar:e}){const[t,a]=A.useState(""),[s,l]=A.useState(""),[u,d]=A.useState(""),[f,m]=A.useState(""),[h,x]=A.useState(!1),b=A.useRef(null),y=A.useRef(null),T=Ie(U=>U.createSession),N=Ie(U=>U.sendError),v=Fe(U=>U.activeRepoId),S=ji(U=>U.agents),C=Ge(U=>U.issues),R=Ge(U=>U.selectedIssueId),w=Ge(U=>U.pendingDraft);A.useEffect(()=>{R&&(d(R),Ge.getState().setSelectedIssue(null))},[R]),A.useEffect(()=>{w&&(a(w),Ge.getState().setPendingDraft(null))},[w]),A.useLayoutEffect(()=>{const U=b.current;U&&(U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,tD)}px`)},[t]),A.useEffect(()=>{const U=J=>{y.current&&!y.current.contains(J.target)&&x(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]);const D=C.filter(U=>U.state==="open"),K=C.find(U=>U.id===u),L=f.trim().toLowerCase(),M=L?D.filter(U=>`#${U.number} ${U.title}`.toLowerCase().includes(L)):D,V=!!s||!!u,W=()=>{const U=t.trim();!v||!U&&!V||(a(""),T(U,void 0,void 0,void 0,u||void 0,s||void 0))},j=U=>{U.nativeEvent.isComposing||U.keyCode===229||U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),W())};return o.jsxs("div",{className:"relative flex flex-1 flex-col items-center justify-center bg-term",children:[o.jsx("button",{type:"button",onClick:e,"aria-label":"Open sidebar",className:"absolute left-3 top-3 rounded-lg p-2 text-fg-3 hover:bg-elevated md:hidden",children:o.jsx(Pc,{className:"h-5 w-5"})}),o.jsxs("div",{className:"w-full max-w-2xl px-6",children:[o.jsx("div",{className:"mb-8 text-center",children:o.jsxs("div",{className:"font-mono text-2xl text-fg-6",children:[o.jsx("span",{className:"text-emerald-500/60",children:"❯"}),o.jsx("span",{className:"fs-blink text-fg-4",children:" ▋"})]})}),o.jsxs("div",{className:"rounded-xl border border-line bg-base/80 shadow-sm transition-colors focus-within:border-fg-5",children:[o.jsxs("div",{className:"flex items-start gap-2 px-4 py-3",children:[o.jsx("span",{className:"select-none pt-px font-mono text-sm leading-6 text-emerald-400",children:"❯"}),o.jsx("textarea",{ref:b,rows:1,value:t,autoFocus:!0,disabled:!v,onChange:U=>a(U.target.value),onKeyDown:j,placeholder:v?"让 Agent 做什么?":"请先选择一个仓库",className:"flex-1 resize-none bg-transparent font-mono text-sm leading-6 text-fg placeholder:text-fg-6 focus:outline-none disabled:cursor-not-allowed"}),o.jsx("button",{type:"button",onClick:W,disabled:!v||!t.trim()&&!V,"aria-label":"Start run",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-emerald-600 text-white transition-colors duration-150 hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-fg-6/30 disabled:text-fg-5",children:o.jsx(HE,{className:"h-4 w-4",strokeWidth:2.5})})]}),o.jsxs("div",{className:"flex flex-col gap-2 border-t border-line/60 px-4 py-2 sm:flex-row sm:items-center sm:gap-3",children:[o.jsxs("label",{className:"flex items-center gap-1.5 font-mono text-[11px] text-fg-4",children:[o.jsx("span",{className:"shrink-0",children:"Agent"}),o.jsxs("select",{value:s,onChange:U=>l(U.target.value),className:"rounded border border-line bg-surface px-2 py-1 font-mono text-xs text-fg focus:border-fg-5 focus:outline-none",children:[o.jsx("option",{value:"",children:"默认"}),S.map(U=>o.jsx("option",{value:U.id,children:U.name},U.id))]})]}),C.length>0&&o.jsxs("div",{ref:y,className:"relative flex min-w-0 flex-1 items-center gap-1.5 font-mono text-[11px] text-fg-4",children:[o.jsx("span",{className:"shrink-0",children:"Issue"}),o.jsxs("button",{type:"button",onClick:()=>{x(U=>!U),m("")},className:"flex min-w-0 flex-1 items-center gap-1 truncate rounded border border-line bg-surface px-2 py-1 font-mono text-xs text-fg transition-colors hover:border-fg-5 focus:border-fg-5 focus:outline-none",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:K?`#${K.number} ${K.title}`:"无"}),o.jsx(Sr,{className:"h-3 w-3 shrink-0 text-fg-5"})]}),u&&o.jsx("button",{type:"button",onClick:()=>{d(""),m("")},className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})}),h&&o.jsxs("div",{className:"absolute left-0 top-full z-50 mt-1 w-full min-w-[280px] rounded-md border border-line bg-surface shadow-lg",children:[o.jsxs("div",{className:"flex items-center gap-1.5 border-b border-line px-2 py-1.5",children:[o.jsx(os,{className:"h-3 w-3 shrink-0 text-fg-5"}),o.jsx("input",{type:"text",value:f,onChange:U=>m(U.target.value),onKeyDown:U=>{U.key==="Escape"&&x(!1)},placeholder:"搜索 issue...",autoFocus:!0,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-fg placeholder:text-fg-6 focus:outline-none"})]}),o.jsxs("ul",{className:"max-h-48 overflow-y-auto py-1",children:[!L&&o.jsx("li",{children:o.jsx("button",{type:"button",onClick:()=>{d(""),x(!1)},className:oe("w-full px-2.5 py-1.5 text-left font-mono text-xs transition-colors hover:bg-elevated/60",u?"text-fg-4":"text-blue-400"),children:"无"})}),M.map(U=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>{d(U.id),m(""),x(!1)},className:oe("flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left transition-colors hover:bg-elevated/60",U.id===u?"bg-blue-500/10":""),children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium",U.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",U.number]}),o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:U.title})]})},U.id)),M.length===0&&o.jsx("li",{className:"px-2.5 py-3 text-center font-mono text-[10px] text-fg-5",children:"无匹配结果"})]})]})]})]})]}),o.jsx("div",{className:"mt-2 text-center font-mono text-[10px] text-fg-6",children:"⌘⏎ / ctrl+⏎ 开始运行"}),N&&o.jsx("div",{className:"mt-3 rounded-lg border border-red-500/20 bg-red-500/10 px-4 py-2 font-mono text-xs text-red-400",children:N})]})]})}function M1({body:e}){return e?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],components:{table:e0},children:e})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"没有描述内容"})}function D1({issue:e}){var t;return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",e.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",e.number," ",e.state]}),(t=e.labels)==null?void 0:t.map(a=>o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${a.color}20`,color:`#${a.color}`},children:a.name},a.id))]}),o.jsx("h2",{className:"mt-0.5 truncate text-sm font-medium text-fg",children:e.title})]})}function aD({onToggleSidebar:e}){const t=Ge(x=>x.matchingParentId),a=Ge(x=>x.matchingCandidateId),s=Ge(x=>x.issues.find(b=>b.id===t)),l=Ge(x=>x.issues.find(b=>b.id===a)),u=Ge(x=>x.exitMatchMode),d=Ge(x=>x.linkChild),[f,m]=A.useState(!1);if(!s)return null;const h=async()=>{l&&(m(!0),await d(s.number,l.number),m(!1))};return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-term",children:[o.jsxs("header",{className:"flex items-center gap-3 border-b border-line bg-base px-4 py-2.5",children:[o.jsx("button",{type:"button",onClick:e,"aria-label":"Open sidebar",className:"-ml-1 rounded-lg p-1.5 text-fg-3 hover:bg-elevated md:hidden",children:o.jsx(Pc,{className:"h-5 w-5"})}),o.jsx("span",{className:"text-xs font-medium text-fg-4",children:"匹配子任务"}),o.jsxs("span",{className:"font-mono text-xs text-fg-3",children:["父: #",s.number]}),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{type:"button",onClick:u,className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsx(gt,{className:"h-3.5 w-3.5"}),"退出匹配"]})]}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden border-b border-line md:border-b-0 md:border-r",children:[o.jsx("div",{className:"border-b border-line/60 px-4 py-2.5",children:o.jsx(D1,{issue:s})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:o.jsx(M1,{body:s.body})})]}),o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:l?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-b border-line/60 px-4 py-2.5",children:o.jsx(D1,{issue:l})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:o.jsx(M1,{body:l.body})})]}):o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"← 从左侧列表选择候选 Issue"})})})]}),l&&o.jsx("div",{className:"flex items-center justify-center gap-3 border-t border-line bg-base px-4 py-3",children:o.jsxs("button",{type:"button",onClick:()=>void h(),disabled:f,className:"flex items-center gap-1.5 rounded-md bg-blue-600 px-4 py-2 text-xs font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-50",children:[o.jsx(oa,{className:"h-3.5 w-3.5"}),f?"关联中…":`确认: 将 #${l.number} 设为 #${s.number} 的子任务`]})})]})}function rD({onToggleSidebar:e}){var l;const t=Ge(u=>u.previewIssueId),a=Ge(u=>u.issues.find(d=>d.id===t));if(!a)return o.jsx(YT,{onToggleSidebar:e});const s=()=>{Ge.getState().setSelectedIssue(a.id),Ge.getState().setPreviewIssue(null)};return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-term",children:[o.jsxs("header",{className:"flex items-center gap-3 border-b border-line bg-base px-4 py-2.5",children:[o.jsx("button",{type:"button",onClick:e,"aria-label":"Open sidebar",className:"-ml-1 rounded-lg p-1.5 text-fg-3 hover:bg-elevated md:hidden",children:o.jsx(Pc,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",a.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",a.number," ",a.state]}),(l=a.labels)==null?void 0:l.map(u=>o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${u.color}20`,color:`#${u.color}`},children:u.name},u.id))]}),o.jsx("h2",{className:"mt-0.5 truncate text-sm font-medium text-fg",children:a.title})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[a.htmlUrl&&o.jsxs("a",{href:a.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 font-mono text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsx(pc,{className:"h-3.5 w-3.5"}),"源站"]}),o.jsxs("button",{type:"button",onClick:()=>Ge.getState().enterMatchMode(a.id),className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 text-xs text-fg-3 transition-colors hover:border-blue-500/50 hover:text-blue-400",children:[o.jsx(Ys,{className:"h-3.5 w-3.5"}),"匹配子任务"]}),o.jsxs("button",{type:"button",onClick:s,className:"flex h-8 items-center gap-1.5 rounded-md bg-blue-600 px-3 text-xs font-medium text-white transition-colors hover:bg-blue-500",children:[o.jsx(Uc,{className:"h-3.5 w-3.5 fill-current"}),"开始处理"]})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsx("div",{className:"mx-auto max-w-4xl px-6 py-6",children:a.body?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],components:{table:e0},children:a.body})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"该 Issue 没有描述内容"})})})]})}function sD({onToggleSidebar:e,onToggleRightPanel:t,rightPanelOpen:a}){var L;const s=Aa(),l=Fe(La),u=Ie(M=>M.activeSessionId),d=Ge(M=>M.previewIssueId),f=Ie(M=>M.sessions.find(V=>V.id===M.activeSessionId)??null),m=Ie(M=>{const V=M.activeSessionId;return V?M.messages[V]??go:go}),h=Ie(M=>{const V=M.activeSessionId;return V?M.todos[V]??_c:_c}),x=Ie(M=>{const V=M.activeSessionId;return V?M.sessionStatuses[V]:void 0}),b=Ie(M=>{const V=M.activeSessionId;return V?M.queuedMessageIds[V]??Nx:Nx}),y=Ie(M=>{const V=M.activeSessionId;return V?M.errorReasons[V]:void 0}),T=Ie(M=>M.sendError),N=Ie(M=>M.abortSession),v=Ge(M=>f!=null&&f.issueId?M.issues.find(V=>V.id===f.issueId):void 0);A.useEffect(()=>{if(u)return Ac.activateSession(u),()=>Ac.deactivateSession(u)},[u]);const S=A.useRef(null),C=A.useRef(!0);A.useEffect(()=>{const M=S.current;M&&C.current&&(M.scrollTop=M.scrollHeight)},[m,h]),A.useEffect(()=>{C.current=!0},[u]),A.useEffect(()=>{if(x!=="busy"&&x!=="retry")return;const M=V=>{if(V.key!=="Escape"||V.defaultPrevented)return;const W=V.target;W instanceof HTMLInputElement||W instanceof HTMLTextAreaElement||W!=null&&W.isContentEditable||N()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[x,N]);const R=Ge(M=>M.matchingParentId);if(!u)return R?o.jsx(aD,{onToggleSidebar:e}):d?o.jsx(rD,{onToggleSidebar:e}):o.jsx(YT,{onToggleSidebar:e});const w=x==="busy",D=x==="retry",K=w||D;return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-term",children:[o.jsxs("header",{className:"flex items-center gap-3 border-b border-line bg-base px-4 py-2.5",children:[o.jsxs("div",{className:"flex items-center gap-1 md:hidden",children:[o.jsx("button",{type:"button",onClick:e,"aria-label":"Open sidebar",className:"-ml-1 rounded-lg p-1.5 text-fg-3 hover:bg-elevated",children:o.jsx(Pc,{className:"h-5 w-5"})}),o.jsx("button",{type:"button",onClick:()=>Ie.setState({activeSessionId:null}),"aria-label":"新建运行",title:"新建运行",className:"rounded-lg p-1.5 text-fg-3 hover:bg-elevated",children:o.jsx(Xa,{className:"h-5 w-5"})})]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[(f==null?void 0:f.parentID)&&o.jsxs("button",{type:"button",onClick:()=>void Ie.getState().setActiveSession(f.parentID),className:"mb-0.5 flex items-center gap-1 text-[11px] text-fg-4 transition-colors hover:text-blue-400",children:[o.jsx(jv,{className:"h-3 w-3"}),"返回父会话"]}),o.jsx("h2",{className:"truncate text-sm font-medium text-fg",children:((L=f==null?void 0:f.title)==null?void 0:L.trim())||"untitled run"}),(f==null?void 0:f.agent)&&o.jsx("p",{className:"truncate font-mono text-xs text-fg-4",children:f.agent}),o.jsx(eD,{session:f,messages:m})]}),v&&o.jsxs("button",{type:"button",onClick:()=>s(`/${encodeURIComponent(l)}/issues?issueId=${v.id}`),className:"flex items-center gap-1 rounded-md border border-line px-2 py-1 font-mono text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsxs("span",{className:oe("rounded px-1 py-0.5 text-[10px] font-semibold",v.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",v.number]}),o.jsx("span",{className:"hidden max-w-[120px] truncate sm:inline",children:v.title})]}),o.jsx(QM,{status:x,reason:y}),t&&o.jsx("button",{type:"button",onClick:t,"aria-label":a?"关闭侧边栏":"打开侧边栏",className:oe("hidden items-center justify-center rounded-md border border-line p-1.5 transition-colors md:flex",a?"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20":"text-fg-4 hover:bg-elevated hover:text-fg-2"),children:o.jsx($E,{className:"h-4 w-4"})}),K&&o.jsxs("button",{type:"button",onClick:()=>void N(),className:"flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1 font-mono text-xs text-fg-2 transition-colors hover:border-red-500/50 hover:text-red-400",children:[o.jsx(KE,{className:"h-3 w-3 fill-current"}),D?"stop retry":"stop"]})]}),o.jsx("div",{ref:S,onScroll:()=>{const M=S.current;M&&(C.current=M.scrollHeight-M.clientHeight-M.scrollTop<=nD)},className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-3 px-4 py-4",children:[m.length===0?o.jsxs("p",{className:"py-10 text-center font-mono text-xs text-fg-6",children:[o.jsx("span",{className:"text-emerald-500/60",children:"❯"})," waiting for input",o.jsx("span",{className:"fs-blink",children:" ▋"})]}):m.map((M,V)=>o.jsxs(A.Fragment,{children:[V>0&&M.role==="user"&&o.jsx("div",{className:"border-t border-line"}),o.jsx("div",{"data-message-id":M.id,children:o.jsx(zM,{message:M,isStreaming:w&&V===m.length-1,queued:b.includes(M.id)})})]},M.id)),h.length>0&&o.jsx($M,{todos:[...h],onClick:t})]})}),x==="error"&&y&&o.jsxs("div",{className:"flex items-center gap-2 border-t border-red-500/20 bg-red-500/10 px-4 py-2 font-mono text-xs text-red-400",children:[o.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"truncate",children:y})]}),T&&o.jsxs("div",{className:"flex items-center gap-2 border-t border-red-500/20 bg-red-500/10 px-4 py-2 font-mono text-xs text-red-400",children:[o.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"truncate",children:T})]}),o.jsx(VM,{})]})}const Vn=Wa((e,t)=>({pulls:[],loaded:!1,syncing:!1,selectedPrId:null,matchingPrId:null,matchingCandidateIssueId:null,clearPulls:()=>e({pulls:[],loaded:!1,selectedPrId:null,matchingPrId:null,matchingCandidateIssueId:null}),setSelectedPr:a=>e({selectedPrId:a}),enterMatchMode:a=>e({matchingPrId:a,matchingCandidateIssueId:null}),exitMatchMode:()=>{const a=t().matchingPrId;e({matchingPrId:null,matchingCandidateIssueId:null,selectedPrId:a})},setMatchCandidate:a=>e({matchingCandidateIssueId:a}),linkIssue:async(a,s)=>{const l=Fe.getState().activeRepoId;if(!l)return!1;try{return await mC(l,a,s),!0}catch{return!1}},unlinkIssue:async(a,s)=>{const l=Fe.getState().activeRepoId;if(!l)return!1;try{return await hC(l,a,s),!0}catch{return!1}},loadPulls:async()=>{const a=Fe.getState().activeRepoId;if(!a){e({pulls:[],loaded:!0});return}try{const s=await bx(a,"all");e({pulls:s,loaded:!0})}catch{e({loaded:!0})}},syncPulls:async()=>{const a=Fe.getState().activeRepoId;if(a){e({syncing:!0});try{await dC(a);const s=await bx(a,"all");e({pulls:s,syncing:!1})}catch(s){e({syncing:!1});let l="同步 PR 失败";if(s instanceof Qa)try{const u=JSON.parse(s.message);u.error&&(l=u.error)}catch{s.message&&(l=s.message)}Yt.getState().addToast(l,"error")}}}})),iD={completed:{glyph:"✓",color:"text-emerald-400",spin:!1},in_progress:{glyph:"◌",color:"text-amber-400",spin:!0},cancelled:{glyph:"✗",color:"text-fg-5",spin:!1},pending:{glyph:"○",color:"text-fg-4",spin:!1}};function lD(e){var l;const t=(l=e.time)==null?void 0:l.created;if(!t)return"";const a=t<1e12?t*1e3:t;return new Date(a).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}function oD(e){if(!e.parts)return"";for(const t of e.parts){const a=t.content??t.text;if(a)return a}return""}function uD({todos:e}){if(e.length===0)return o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"暂无待办项"})});const t=e.filter(a=>{const s=Pi(a.status);return s==="completed"||s==="cancelled"}).length;return o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[o.jsxs("div",{className:"mb-2 font-mono text-[10px] tabular-nums text-fg-5",children:["进度 ",t,"/",e.length]}),o.jsx("ul",{className:"space-y-1.5",children:e.map(a=>{const s=Pi(a.status),l=iD[s],u=s==="completed"||s==="cancelled";return o.jsxs("li",{className:"flex items-start gap-2 font-mono text-xs",children:[o.jsx("span",{className:oe("shrink-0 leading-5",l.color,l.spin&&"fs-spin"),children:l.glyph}),o.jsx("span",{className:oe("leading-5",u?"text-fg-5 line-through":"text-fg-2"),children:a.content})]},a.id)})})]})}function cD({messages:e,onScrollToMessage:t}){const a=e.filter(s=>s.role==="user");return a.length===0?o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"暂无输入记录"})}):o.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-2",children:o.jsx("ul",{className:"space-y-1",children:a.map((s,l)=>{const u=oD(s),d=lD(s);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(s.id),className:"group w-full rounded-md px-2 py-1.5 text-left transition-colors hover:bg-elevated/60",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"shrink-0 font-mono text-[10px] text-emerald-400/60",children:"❯"}),o.jsxs("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-fg-5",children:["#",l+1]}),d&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] text-fg-6",children:d})]}),u&&o.jsx("p",{className:"mt-0.5 line-clamp-2 pl-5 text-xs leading-relaxed text-fg-3 group-hover:text-fg-2",children:u})]})},s.id)})})})}function dD({linked:e,number:t,title:a,state:s,mergedAt:l,isPr:u,onToggle:d}){const f=u?s==="open"?"bg-emerald-500/15 text-emerald-400":l?"bg-purple-500/15 text-purple-400":"bg-red-500/15 text-red-400":s==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400";return o.jsx("li",{children:o.jsx("button",{type:"button",onClick:d,className:oe("flex w-full items-start gap-2 rounded-md px-2 py-2 text-left transition-colors",e?"border-l-2 border-emerald-500 bg-emerald-500/5":"border-l-2 border-transparent hover:bg-elevated/50"),children:o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-semibold",f),children:["#",t]}),o.jsx("span",{className:"min-w-0 truncate text-xs text-fg-2",children:a}),e&&o.jsx(Bc,{className:"ml-auto h-3 w-3 shrink-0 text-emerald-400"})]})})})}function fD({links:e,sessionId:t}){var L,M,V,W;const a=Aa(),s=Fe(La),[l,u]=A.useState(null),[d,f]=A.useState(""),m=A.useRef(null),h=Ge(j=>j.issues),x=Vn(j=>j.pulls),b=Ie(j=>j.addLink),y=Ie(j=>j.removeLink),T=new Set(((L=e==null?void 0:e.issues)==null?void 0:L.map(j=>j.id))??[]),N=new Set(((M=e==null?void 0:e.pullRequests)==null?void 0:M.map(j=>j.id))??[]);A.useEffect(()=>{var j;l&&((j=m.current)==null||j.focus())},[l]);const v=()=>{u(null),f("")},S=async(j,U,J)=>{t&&(J?await y(t,j,U):await b(t,j,U))},C=d.trim().toLowerCase(),R=C?h.filter(j=>`#${j.number} ${j.title}`.toLowerCase().includes(C)):h,w=C?x.filter(j=>`#${j.number} ${j.title} ${j.headBranch}`.toLowerCase().includes(C)):x,D=((V=e==null?void 0:e.issues)==null?void 0:V.length)??0,K=((W=e==null?void 0:e.pullRequests)==null?void 0:W.length)??0;if(l){const j=l==="issue",U=j?R:w,J=j?T:N;return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-line px-3 py-2",children:[o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-blue-400",children:j?"关联 Issue":"关联 PR"}),o.jsxs("button",{type:"button",onClick:v,className:"flex h-6 items-center gap-1 rounded-md px-2 text-xs text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:[o.jsx(gt,{className:"h-3.5 w-3.5"}),"完成"]})]}),o.jsx("div",{className:"border-b border-line px-3 py-2",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-line bg-base px-2 py-1",children:[o.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),o.jsx("input",{ref:m,type:"text",value:d,onChange:se=>f(se.target.value),placeholder:j?"搜索 issue...":"搜索 PR...",className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),d&&o.jsx("button",{type:"button",onClick:()=>f(""),className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:U.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:(j?h:x).length===0?j?"暂无 Issue,请先同步":"暂无 PR,请先同步":"无匹配结果"}):o.jsx("ul",{className:"space-y-0.5",children:U.map(se=>o.jsx(dD,{linked:J.has(se.id),number:se.number,title:se.title,state:se.state,mergedAt:j?void 0:se.mergedAt,isPr:!j,onToggle:()=>S(l,se.id,J.has(se.id))},se.id))})})]})}return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-1.5 border-b border-line px-3 py-2",children:[o.jsx("span",{className:"flex-1 font-mono text-[10px] text-fg-5",children:D+K>0?`${D+K} 项关联`:"暂无关联"}),o.jsxs("button",{type:"button",onClick:()=>u("issue"),className:"flex h-6 items-center gap-1 rounded-md border border-line px-1.5 text-fg-4 transition-colors hover:border-emerald-500/50 hover:text-emerald-400",children:[o.jsx(Xa,{className:"h-3 w-3"}),o.jsx("span",{className:"text-[10px] font-medium",children:"Issue"})]}),o.jsxs("button",{type:"button",onClick:()=>u("pr"),className:"flex h-6 items-center gap-1 rounded-md border border-line px-1.5 text-fg-4 transition-colors hover:border-blue-500/50 hover:text-blue-400",children:[o.jsx(Xa,{className:"h-3 w-3"}),o.jsx("span",{className:"text-[10px] font-medium",children:"PR"})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[D>0&&o.jsxs("div",{className:"mb-3",children:[o.jsxs("div",{className:"mb-1.5 font-mono text-[10px] font-medium uppercase tracking-wider text-fg-5",children:["Issues (",D,")"]}),o.jsx("ul",{className:"space-y-1",children:e.issues.map(j=>o.jsxs("li",{className:"group flex items-start gap-1",children:[o.jsxs("button",{type:"button",onClick:()=>a(`/${encodeURIComponent(s)}/issues?issueId=${encodeURIComponent(j.id)}`),className:"flex min-w-0 flex-1 items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-elevated/60",children:[o.jsxs("span",{className:oe("mt-0.5 shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-semibold",j.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",j.number]}),o.jsx("span",{className:"line-clamp-2 text-xs leading-5 text-fg-3 group-hover:text-fg-2",children:j.title})]}),o.jsx("button",{type:"button",onClick:()=>void S("issue",j.id,!0),className:"mt-1.5 hidden shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:bg-red-500/15 hover:text-red-400 group-hover:block",children:o.jsx(gt,{className:"h-3 w-3"})})]},j.id))})]}),K>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 font-mono text-[10px] font-medium uppercase tracking-wider text-fg-5",children:["Pull Requests (",K,")"]}),o.jsx("ul",{className:"space-y-1",children:e.pullRequests.map(j=>o.jsxs("li",{className:"group flex items-start gap-1",children:[o.jsxs("button",{type:"button",onClick:()=>a(`/${encodeURIComponent(s)}/pulls?prId=${encodeURIComponent(j.id)}`),className:"flex min-w-0 flex-1 items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-elevated/60",children:[o.jsxs("span",{className:oe("mt-0.5 shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-semibold",j.state==="open"?"bg-emerald-500/15 text-emerald-400":j.mergedAt?"bg-purple-500/15 text-purple-400":"bg-red-500/15 text-red-400"),children:["#",j.number]}),o.jsx("span",{className:"line-clamp-2 text-xs leading-5 text-fg-3 group-hover:text-fg-2",children:j.title})]}),o.jsx("button",{type:"button",onClick:()=>void S("pr",j.id,!0),className:"mt-1.5 hidden shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:bg-red-500/15 hover:text-red-400 group-hover:block",children:o.jsx(gt,{className:"h-3 w-3"})})]},j.id))})]}),D===0&&K===0&&o.jsx("div",{className:"flex flex-1 items-center justify-center py-10",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"点击上方按钮添加关联"})})]})]})}const mD={"visual-engineering":"bg-purple-500/15 text-purple-400",quick:"bg-emerald-500/15 text-emerald-400",deep:"bg-blue-500/15 text-blue-400",ultrabrain:"bg-amber-500/15 text-amber-400",artistry:"bg-pink-500/15 text-pink-400",writing:"bg-cyan-500/15 text-cyan-400",explore:"bg-teal-500/15 text-teal-400",librarian:"bg-indigo-500/15 text-indigo-400",oracle:"bg-amber-500/15 text-amber-400",metis:"bg-rose-500/15 text-rose-400",momus:"bg-orange-500/15 text-orange-400"};function hD(e){switch(e){case"idle":return"bg-emerald-500";case"busy":case"retry":return"bg-amber-500 animate-pulse";case"error":return"bg-red-500";default:return"bg-fg-5"}}function Um(e){var a;const t=(a=e.time)==null?void 0:a.created;if(t)return t<1e12?t*1e3:t;if(e.createdAt){const s=Date.parse(e.createdAt);if(!Number.isNaN(s))return s}return null}function pD(e){const t=Date.now()-e,a=Math.floor(t/1e3);if(a<60)return"just now";const s=Math.floor(a/60);if(s<60)return`${s}m ago`;const l=Math.floor(s/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function gD(){const e=Ie(m=>m.sessions),t=Ie(m=>m.activeSessionId),a=Ie(m=>m.sessionStatuses),s=Ie(m=>m.setActiveSession),l=e.find(m=>m.id===t),u=(l==null?void 0:l.parentID)??t,d=!!(l!=null&&l.parentID),f=e.filter(m=>m.parentID===u).sort((m,h)=>(Um(h)??0)-(Um(m)??0));return f.length===0?o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"暂无子任务"})}):o.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[d&&o.jsxs("div",{className:"mb-1.5 px-2 font-mono text-[10px] text-fg-5",children:["同级子任务 (",f.length,")"]}),o.jsx("ul",{className:"space-y-0.5",children:f.map(m=>{const h=m.id===t,x=a[m.id],b=Um(m),y=(m.agent&&mD[m.agent])??"bg-elevated text-fg-4",T=m.title||`${m.id.slice(0,9)}...`;return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>{h||s(m.id)},className:oe("group flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",h?"border-l-2 border-blue-500 bg-blue-500/5":"border-l-2 border-transparent hover:bg-elevated/60"),children:[o.jsx("span",{className:oe("mt-1 h-2 w-2 shrink-0 rounded-full",hD(x))}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[m.agent&&o.jsx("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium",y),children:m.agent}),b!=null&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-fg-6",children:pD(b)})]}),o.jsx("p",{className:oe("mt-0.5 line-clamp-2 text-xs leading-5",h?"text-fg-2":"text-fg-3 group-hover:text-fg-2"),children:T})]})]})},m.id)})})]})}function L1({todos:e,messages:t,sessionLinks:a,sessionId:s,onScrollToMessage:l}){var N,v;const[u,d]=A.useState("todo"),f=Ie(S=>S.sessions),m=Ie(S=>S.activeSessionId),h=t.filter(S=>S.role==="user").length,x=(((N=a==null?void 0:a.issues)==null?void 0:N.length)??0)+(((v=a==null?void 0:a.pullRequests)==null?void 0:v.length)??0),b=f.find(S=>S.id===m),y=(b==null?void 0:b.parentID)??m,T=f.filter(S=>S.parentID===y).length;return o.jsxs("div",{className:"flex h-full w-72 shrink-0 flex-col border-l border-line bg-surface",children:[o.jsxs("div",{className:"flex items-center border-b border-line",children:[o.jsxs("button",{type:"button",onClick:()=>d("todo"),className:oe("flex flex-1 items-center justify-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors",u==="todo"?"border-blue-500 text-blue-500":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(MA,{className:"h-3.5 w-3.5"}),"待办",e.length>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:e.length})]}),o.jsxs("button",{type:"button",onClick:()=>d("prompts"),className:oe("flex flex-1 items-center justify-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors",u==="prompts"?"border-blue-500 text-blue-500":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(qA,{className:"h-3.5 w-3.5"}),"输入",h>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:h})]}),o.jsxs("button",{type:"button",onClick:()=>d("links"),className:oe("flex flex-1 items-center justify-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors",u==="links"?"border-blue-500 text-blue-500":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(Bc,{className:"h-3.5 w-3.5"}),"关联",x>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:x})]}),o.jsxs("button",{type:"button",onClick:()=>d("subtasks"),className:oe("flex flex-1 items-center justify-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors",u==="subtasks"?"border-blue-500 text-blue-500":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(Ys,{className:"h-3.5 w-3.5"}),"子任务",T>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:T})]})]}),u==="todo"?o.jsx(uD,{todos:e}):u==="prompts"?o.jsx(cD,{messages:t,onScrollToMessage:l}):u==="links"?o.jsx(fD,{links:a,sessionId:s}):o.jsx(gD,{})]})}const j1=8;function bD(e,t){let a=e instanceof Element?e:null;for(;a&&a!==t;){if(a.scrollWidth>a.clientWidth){const s=getComputedStyle(a).overflowX;if(s==="auto"||s==="scroll")return!0}a=a.parentElement}return!1}function $T({onSwipeLeft:e,onSwipeRight:t,threshold:a=40,disabled:s=!1}={}){const l=A.useRef({x0:0,y0:0,dir:null,on:!1}),u=A.useRef(0),d=A.useCallback(h=>{if(s||bD(h.target,h.currentTarget))return;const x=h.touches[0];l.current={x0:x.clientX,y0:x.clientY,dir:null,on:!0},u.current=0},[s]),f=A.useCallback(h=>{const x=l.current;if(!x.on)return;const b=h.touches[0].clientX-x.x0,y=h.touches[0].clientY-x.y0;if(!x.dir){(Math.abs(b)>j1||Math.abs(y)>j1)&&(x.dir=Math.abs(b)>Math.abs(y)?"h":"v");return}if(x.dir==="v"){x.on=!1;return}u.current=b},[]),m=A.useCallback(()=>{const h=l.current;if(!h.on||h.dir!=="h"){h.on=!1;return}h.on=!1;const x=u.current;x>a?t==null||t():x<-a&&(e==null||e())},[a,e,t]);return{onTouchStart:d,onTouchMove:f,onTouchEnd:m}}function dh({side:e,open:t,onClose:a,children:s,width:l="w-80"}){const u=e==="left";return o.jsxs("div",{className:"md:hidden",children:[t&&o.jsx("div",{className:"fixed inset-0 z-40 bg-black/50",onClick:a,"aria-hidden":"true"}),o.jsx("div",{className:oe("fixed top-0 bottom-0 z-50 flex flex-col bg-surface pt-[var(--safe-top)] pb-[var(--safe-bottom)] shadow-xl transition-transform duration-200 ease-out",l,u?"left-0 border-r border-line":"right-0 border-l border-line",t?"translate-x-0":u?"-translate-x-full":"translate-x-full"),children:s})]})}function fh(e){var t,a;if(typeof((t=e.time)==null?void 0:t.updated)=="number")return e.time.updated;if(typeof((a=e.time)==null?void 0:a.created)=="number")return e.time.created;if(e.createdAt){const s=Date.parse(e.createdAt);return Number.isNaN(s)?0:s}return 0}function xD(e){const t=fh(e);if(!t)return"";const a=t<1e12?t*1e3:t,s=new Date(a);return s.toDateString()===new Date().toDateString()?s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function B1(e){navigator.clipboard?navigator.clipboard.writeText(e).catch(()=>P1(e)):P1(e)}function P1(e){const t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;opacity:0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function ED(e){switch(e){case"idle":return"bg-emerald-500";case"busy":case"retry":return"bg-amber-500 animate-pulse";case"error":return"bg-red-500";default:return"bg-fg-5"}}function yD({session:e,isActive:t,isConfirming:a,onSelect:s,onDelete:l,onConfirm:u,onCancelConfirm:d,onRename:f,onToggleComplete:m,status:h,issue:x,linkedItems:b}){var re,Q;const y=oc(F=>F.drafts[e.id]),T=!!e.completedAt,N=xD(e),[v,S]=A.useState(!1),[C,R]=A.useState(""),w=A.useRef(null),D=()=>{var F;R(((F=e.title)==null?void 0:F.trim())||""),S(!0),requestAnimationFrame(()=>{var fe;return(fe=w.current)==null?void 0:fe.focus()})},K=()=>{var fe;S(!1);const F=C.trim();F&&F!==(((fe=e.title)==null?void 0:fe.trim())||"")&&f(F)},[L,M]=A.useState(0),[V,W]=A.useState(!1),j=A.useRef({x0:0,y0:0,base:0,dir:null,on:!1}),U=F=>{const fe=F.touches[0];j.current={x0:fe.clientX,y0:fe.clientY,base:L,dir:null,on:!0},W(!1)},J=F=>{const fe=j.current;if(!fe.on)return;const Ce=F.touches[0].clientX-fe.x0,P=F.touches[0].clientY-fe.y0;if(!fe.dir){(Math.abs(Ce)>5||Math.abs(P)>5)&&(fe.dir=Math.abs(Ce)>Math.abs(P)?"h":"v");return}fe.dir!=="v"&&M(Math.max(-192,Math.min(0,fe.base+Ce)))},se=()=>{j.current.on=!1,W(!0),M(F=>F<-192/2?-192:0)},le=()=>{W(!0),M(0)};return o.jsxs("li",{className:"relative overflow-hidden rounded-md",children:[o.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex md:hidden",style:L<0?{zIndex:10}:void 0,children:a?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>{l(),le()},className:"flex w-12 items-center justify-center bg-red-500 text-white active:bg-red-600",children:o.jsx(oa,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{d(),le()},className:"flex w-12 items-center justify-center bg-neutral-500 text-white active:bg-neutral-600",children:o.jsx(gt,{className:"h-4 w-4"})})]}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>{m(),le()},className:oe("flex w-12 items-center justify-center text-white",T?"bg-neutral-500 active:bg-neutral-600":"bg-emerald-500 active:bg-emerald-600"),children:o.jsx(dm,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{D(),le()},className:"flex w-12 items-center justify-center bg-amber-500 text-white active:bg-amber-600",children:o.jsx(sx,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{var F;B1(JSON.stringify({id:e.id,name:((F=e.title)==null?void 0:F.trim())||""},null,2)),le()},className:"flex w-12 items-center justify-center bg-blue-500 text-white active:bg-blue-600",children:o.jsx(hc,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>u(),className:"flex w-12 items-center justify-center bg-red-500 text-white active:bg-red-600",children:o.jsx(zs,{className:"h-4 w-4"})})]})}),o.jsxs("div",{className:oe("group relative rounded-md border-l-2",t?"border-blue-500 bg-elevated":"border-transparent bg-surface hover:bg-elevated/50",V&&"transition-transform duration-200 ease-out"),style:{...L!==0?{transform:`translateX(${L}px)`}:{},...L===-192?{pointerEvents:"none"}:{}},onTouchStart:U,onTouchMove:J,onTouchEnd:se,children:[o.jsxs("button",{type:"button",onClick:()=>{v||(s(),le())},className:oe("block w-full px-2.5 py-2 text-left",T&&!t&&"opacity-50"),style:L===-192?{pointerEvents:"auto"}:void 0,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:oe("h-1.5 w-1.5 shrink-0 rounded-full",ED(h))}),o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:((re=e.agent)==null?void 0:re.trim())||"默认"}),T&&o.jsx(dm,{className:"h-3 w-3 shrink-0 text-emerald-400"}),N&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-fg-5",children:N})]}),v?o.jsx("input",{ref:w,type:"text",value:C,onChange:F=>R(F.target.value),onBlur:K,onKeyDown:F=>{F.key==="Enter"&&K(),F.key==="Escape"&&S(!1)},onClick:F=>F.stopPropagation(),className:"mt-0.5 w-full rounded border border-blue-500 bg-base pl-3.5 text-sm text-fg-2 outline-none"}):o.jsxs("div",{className:"mt-0.5 pl-3.5",onDoubleClick:F=>{F.stopPropagation(),D()},children:[(x||b)&&o.jsxs("div",{className:"mb-0.5 flex flex-wrap gap-1",children:[x&&o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium leading-none",x.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",x.number]}),b==null?void 0:b.map(F=>o.jsx("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium leading-none",F.type==="pr"?F.state==="open"?"bg-blue-500/15 text-blue-400":F.mergedAt?"bg-purple-500/15 text-purple-400":"bg-red-500/15 text-red-400":F.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:F.type==="pr"?`PR#${F.number}`:`#${F.number}`},`${F.type}-${F.number}`))]}),o.jsx("span",{className:"block truncate text-sm text-fg-2",children:((Q=e.title)==null?void 0:Q.trim())||"未命名运行"}),y&&o.jsxs("span",{className:"mt-0.5 block truncate text-xs text-amber-400/80",children:["✏️ ",y]})]})]}),a?o.jsxs("span",{className:"absolute right-1.5 top-1.5 hidden items-center gap-1 rounded bg-surface/90 px-0.5 md:flex",children:[o.jsx("button",{type:"button",onClick:l,className:"rounded p-1 text-red-400 hover:bg-red-500/10",children:o.jsx(oa,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:d,className:"rounded p-1 text-fg-3 hover:bg-elevated",children:o.jsx(gt,{className:"h-3.5 w-3.5"})})]}):o.jsxs("span",{className:"absolute right-1.5 top-1.5 hidden items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 md:flex",children:[o.jsx("button",{type:"button",onClick:m,title:T?"取消完成":"标记完成",className:oe("rounded p-1",T?"text-emerald-400 hover:text-emerald-300":"text-fg-5 hover:text-emerald-400"),children:o.jsx(dm,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:D,title:"重命名",className:"rounded p-1 text-fg-5 hover:text-fg-2",children:o.jsx(sx,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:()=>{var F;B1(JSON.stringify({id:e.id,name:((F=e.title)==null?void 0:F.trim())||""},null,2))},title:"复制 Session JSON",className:"rounded p-1 text-fg-5 hover:text-fg-2",children:o.jsx(hc,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:u,className:"rounded p-1 text-fg-5 hover:text-red-400",children:o.jsx(zs,{className:"h-3.5 w-3.5"})})]})]})]})}function U1({onClose:e}){const[t,a]=A.useState(null),s=Ie(R=>R.sessions),l=Ie(R=>R.activeSessionId),u=Ie(R=>R.sessionStatuses),d=Ie(R=>R.sessionFilter),f=Ie(R=>R.setSessionFilter),m=Ie(R=>R.setActiveSession),h=Ie(R=>R.deleteSession),x=Ie(R=>R.renameSession),b=Ie(R=>R.toggleSessionComplete),y=Fe(R=>R.activeRepoId),T=Ge(R=>R.issues),N=Ie(R=>R.allSessionLinks),v=[...s].filter(R=>R.parentID?!1:d==="active"?!R.completedAt:d==="completed"?!!R.completedAt:!0).sort((R,w)=>fh(w)-fh(R)),S=new Map(T.map(R=>[R.id,R])),C=R=>o.jsx("ul",{className:"space-y-0.5",children:R.map(w=>{const D=w.issueId?S.get(w.issueId):void 0,K=N[w.id],L=[];if(K){for(const M of K.issues)L.push({number:M.number,state:M.state,type:"issue"});for(const M of K.pullRequests)L.push({number:M.number,state:M.state,type:"pr",mergedAt:M.mergedAt})}return o.jsx(yD,{session:w,isActive:w.id===l,isConfirming:t===w.id,status:u[w.id],issue:D?{number:D.number,title:D.title,state:D.state}:void 0,linkedItems:L.length>0?L:void 0,onSelect:()=>{m(w.id),e==null||e()},onDelete:()=>{h(w.id),a(null)},onConfirm:()=>a(w.id),onCancelConfirm:()=>a(null),onRename:M=>void x(w.id,M),onToggleComplete:()=>void b(w.id)},w.id)})});return o.jsx("div",{className:"flex h-full w-80 shrink-0 flex-col border-r border-line bg-surface",children:o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-line px-3 py-3",children:[o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-fg-3",children:"运行记录"}),y&&o.jsx("button",{type:"button",onClick:()=>{Ie.setState({activeSessionId:null}),e==null||e()},title:"新建运行",className:"flex h-7 w-7 items-center justify-center rounded-md bg-blue-600 text-white transition-colors hover:bg-blue-500",children:o.jsx(Xa,{className:"h-4 w-4"})})]}),y&&o.jsx("div",{className:"flex gap-1 border-b border-line px-3 py-1.5",children:[["all","全部"],["active","进行中"],["completed","已完成"]].map(([R,w])=>o.jsx("button",{type:"button",onClick:()=>f(R),className:oe("rounded-md px-2 py-0.5 font-mono text-[11px] transition-colors",d===R?"bg-elevated text-fg-2":"text-fg-5 hover:text-fg-3"),children:w},R))}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:y?v.length===0?o.jsx("p",{className:"px-2 py-6 text-center font-mono text-xs text-fg-5",children:"暂无运行记录"}):o.jsx("div",{children:C(v)}):o.jsx("p",{className:"px-2 py-6 text-center font-mono text-xs text-fg-5",children:"请先选择一个仓库"})})]})})}function TD(){const[e,t]=A.useState(()=>typeof window<"u"&&window.matchMedia("(min-width: 1280px)").matches);return A.useEffect(()=>{const a=window.matchMedia("(min-width: 1280px)"),s=l=>t(l.matches);return a.addEventListener("change",s),()=>a.removeEventListener("change",s)},[]),e}function H1(e){const t=document.querySelector(`[data-message-id="${e}"]`);t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),t.classList.add("fs-highlight"),setTimeout(()=>t.classList.remove("fs-highlight"),2e3))}function _D(){const[e,t]=A.useState(!1),[a,s]=A.useState(!1),[l,u]=A.useState(!1),d=TD(),f=Ie(S=>S.activeSessionId),m=Ec(S=>S.sessionPanelCollapsed),h=Ec(S=>S.toggleSessionPanel),x=Ie(S=>{const C=S.activeSessionId;return C?S.todos[C]??_c:_c}),b=Ie(S=>{const C=S.activeSessionId;return C?S.messages[C]??go:go}),y=Ie(S=>{const C=S.activeSessionId;return C?S.sessionLinks[C]:void 0});A.useEffect(()=>{d&&f?u(!0):d||u(!1)},[d,f]);const T=l&&!!f,N=()=>{window.matchMedia("(max-width: 767px)").matches?s(S=>!S):u(S=>!S)},v=$T({onSwipeRight:()=>t(!0),onSwipeLeft:()=>s(!0),disabled:e||a});return o.jsxs("div",{className:"flex min-h-0 flex-1",...v,children:[o.jsxs("div",{className:"relative hidden shrink-0 md:flex",children:[o.jsx("div",{className:oe("overflow-hidden transition-[width] duration-200 ease-in-out",m?"w-0":"w-80"),children:o.jsx("div",{className:"h-full w-80",children:o.jsx(U1,{})})}),o.jsx("button",{type:"button",onClick:h,title:m?"展开运行记录":"收起运行记录",className:oe("absolute left-full top-1/2 z-20 flex h-14 w-4 -translate-y-1/2 items-center justify-center rounded-r-md border-y border-r border-line text-fg-5 transition-all duration-200 hover:bg-elevated hover:text-fg-3",m?"bg-surface opacity-80 hover:w-5 hover:opacity-100":"bg-surface/80 opacity-40 hover:opacity-100"),children:m?o.jsx(Ih,{className:"h-3 w-3"}):o.jsx(Oh,{className:"h-3 w-3"})})]}),o.jsx(dh,{side:"left",open:e,onClose:()=>t(!1),children:o.jsx(U1,{onClose:()=>t(!1)})}),o.jsx(dh,{side:"right",open:a,onClose:()=>s(!1),children:o.jsx(L1,{todos:x,messages:b,sessionLinks:y,sessionId:f,onScrollToMessage:S=>{s(!1),setTimeout(()=>H1(S),300)}})}),o.jsx("div",{className:"flex min-w-0 flex-1 flex-col",children:o.jsx(sD,{onToggleSidebar:()=>t(S=>!S),onToggleRightPanel:N,rightPanelOpen:T})}),T&&o.jsx("div",{className:"hidden shrink-0 md:flex",children:o.jsx(L1,{todos:x,messages:b,sessionLinks:y,sessionId:f,onScrollToMessage:H1})})]})}const F1=/[#.]/g;function ND(e,t){const a=e||"",s={};let l=0,u,d;for(;l<a.length;){F1.lastIndex=l;const f=F1.exec(a),m=a.slice(l,f?f.index:a.length);m&&(u?u==="#"?s.id=m:Array.isArray(s.className)?s.className.push(m):s.className=[m]:d=m,l+=m.length),f&&(u=f[0],l++)}return{type:"element",tagName:d||t||"div",properties:s,children:[]}}function GT(e,t,a){const s=a?CD(a):void 0;function l(u,d,...f){let m;if(u==null){m={type:"root",children:[]};const h=d;f.unshift(h)}else{m=ND(u,t);const h=m.tagName.toLowerCase(),x=s?s.get(h):void 0;if(m.tagName=x||h,SD(d))f.unshift(d);else for(const[b,y]of Object.entries(d))vD(e,m.properties,b,y)}for(const h of f)mh(m.children,h);return m.type==="element"&&m.tagName==="template"&&(m.content={type:"root",children:m.children},m.children=[]),m}return l}function SD(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,a=Object.keys(e);for(const s of a){const l=t[s];if(l&&typeof l=="object"){if(!Array.isArray(l))return!0;const u=l;for(const d of u)if(typeof d!="number"&&typeof d!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function vD(e,t,a,s){const l=qc(e,a);let u;if(s!=null){if(typeof s=="number"){if(Number.isNaN(s))return;u=s}else typeof s=="boolean"?u=s:typeof s=="string"?l.spaceSeparated?u=Rx(s):l.commaSeparated?u=vx(s):l.commaOrSpaceSeparated?u=Rx(vx(s).join(" ")):u=z1(l,l.property,s):Array.isArray(s)?u=[...s]:u=l.property==="style"?AD(s):String(s);if(Array.isArray(u)){const d=[];for(const f of u)d.push(z1(l,l.property,f));u=d}l.property==="className"&&Array.isArray(t.className)&&(u=t.className.concat(u)),t[l.property]=u}}function mh(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 a of t)mh(e,a);else if(typeof t=="object"&&"type"in t)t.type==="root"?mh(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function z1(e,t,a){if(typeof a=="string"){if(e.number&&a&&!Number.isNaN(Number(a)))return Number(a);if((e.boolean||e.overloadedBoolean)&&(a===""||bo(a)===bo(t)))return!0}return a}function AD(e){const t=[];for(const[a,s]of Object.entries(e))t.push([a,s].join(": "));return t.join("; ")}function CD(e){const t=new Map;for(const a of e)t.set(a.toLowerCase(),a);return t}const wD=["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"],kD=GT(So,"div"),RD=GT(ds,"g",wD);function OD(e){const t=String(e),a=[];return{toOffset:l,toPoint:s};function s(u){if(typeof u=="number"&&u>-1&&u<=t.length){let d=0;for(;;){let f=a[d];if(f===void 0){const m=q1(t,a[d-1]);f=m===-1?t.length+1:m+1,a[d]=f}if(f>u)return{line:d+1,column:u-(d>0?a[d-1]:0)+1,offset:u};d++}}}function l(u){if(u&&typeof u.line=="number"&&typeof u.column=="number"&&!Number.isNaN(u.line)&&!Number.isNaN(u.column)){for(;a.length<u.line;){const f=a[a.length-1],m=q1(t,f),h=m===-1?t.length+1:m+1;if(f===h)break;a.push(h)}const d=(u.line>1?a[u.line-2]:0)+u.column-1;if(d<a[u.line-1])return d}}}function q1(e,t){const a=e.indexOf("\r",t),s=e.indexOf(`
469
+ `);return o.jsxs("div",{className:"grid grid-cols-1 gap-px overflow-x-auto rounded text-xs md:grid-cols-2",children:[o.jsx("pre",{className:"min-w-0 whitespace-pre-wrap break-words p-1.5 fs-diff-del",children:a.map((l,u)=>o.jsxs("div",{children:[o.jsx("span",{className:"select-none text-red-400/70",children:"− "}),o.jsx("span",{className:"text-red-400",children:l})]},u))}),o.jsx("pre",{className:"min-w-0 whitespace-pre-wrap break-words p-1.5 fs-diff-add",children:s.map((l,u)=>o.jsxs("div",{children:[o.jsx("span",{className:"select-none text-emerald-400/70",children:"+ "}),o.jsx("span",{className:"text-emerald-400",children:l})]},u))})]})}const k1={completed:{glyph:"✓",color:"text-emerald-400"},in_progress:{glyph:"◌",color:"text-amber-400"},cancelled:{glyph:"✗",color:"text-fg-5"},pending:{glyph:"○",color:"text-fg-4"}};function qT({todos:e}){return o.jsx("ul",{className:"space-y-0.5 text-xs",children:e.map((t,a)=>{var f;const s=((f=t.status)==null?void 0:f.toLowerCase())??"pending",l=s==="in-progress"||s==="active"?"in_progress":s==="done"||s==="complete"?"completed":s==="canceled"?"cancelled":s,u=k1[l]??k1.pending,d=l==="completed"||l==="cancelled";return o.jsxs("li",{className:"flex items-start gap-1.5",children:[o.jsx("span",{className:oe("shrink-0 leading-5",u.color,l==="in_progress"&&"fs-spin"),children:u.glyph}),o.jsx("span",{className:oe("leading-5",d?"text-fg-5 line-through":"text-fg-2"),children:t.content}),t.priority&&o.jsx("span",{className:"ml-auto shrink-0 text-fg-5",children:t.priority})]},a)})})}const OM={"visual-engineering":"bg-purple-500/15 text-purple-400",quick:"bg-emerald-500/15 text-emerald-400",deep:"bg-blue-500/15 text-blue-400",ultrabrain:"bg-amber-500/15 text-amber-400",artistry:"bg-pink-500/15 text-pink-400",writing:"bg-cyan-500/15 text-cyan-400","unspecified-low":"bg-elevated text-fg-4","unspecified-high":"bg-elevated text-fg-3"},IM={explore:"bg-teal-500/15 text-teal-400",librarian:"bg-indigo-500/15 text-indigo-400",oracle:"bg-amber-500/15 text-amber-400",metis:"bg-rose-500/15 text-rose-400",momus:"bg-orange-500/15 text-orange-400"};function MM({record:e}){const[t,a]=A.useState(!1),s=typeof e.category=="string"?e.category:null,l=typeof e.subagent_type=="string"?e.subagent_type:null,u=Ka(e,["description","title"]),d=typeof e.prompt=="string"?e.prompt:null,f=Array.isArray(e.load_skills)?e.load_skills.filter(y=>typeof y=="string"):[],m=typeof e.run_in_background=="boolean"?e.run_in_background:!1,h=typeof e.task_id=="string"?e.task_id:null,x=s??l,b=(s&&OM[s])??(l&&IM[l])??"bg-elevated text-fg-3";return o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[x&&o.jsx("span",{className:oe("rounded px-1.5 py-0.5 text-[10px] font-medium",b),children:x}),f.map(y=>o.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 text-[10px] text-fg-4",children:y},y)),m&&o.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 text-[10px] text-fg-5",children:"bg"}),h&&o.jsxs("span",{className:"rounded bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",title:h,children:["↩ ",h.slice(0,16),"…"]})]}),u&&o.jsx("p",{className:"text-xs text-fg-2",children:u}),d&&o.jsxs("div",{children:[o.jsxs("button",{type:"button",onClick:()=>a(y=>!y),className:"flex items-center gap-1 text-[10px] text-fg-4 transition-colors hover:text-fg-2",children:[o.jsx(Ih,{className:oe("h-3 w-3 transition-transform",t&&"rotate-90")}),"Prompt",o.jsxs("span",{className:"text-fg-5",children:["(",d.length," chars)"]})]}),t&&o.jsx("pre",{className:"mt-1 max-h-60 overflow-y-auto whitespace-pre-wrap break-words rounded bg-elevated/50 p-2 text-[11px] leading-relaxed text-fg-3",children:d})]})]})}function DM(e){const t=VC(e),a=Ie(m=>m.activeSessionId),s=Ie(m=>m.sessions);if(t)return t;if(!a)return null;const l=zc(e),u=a0(l),d=Ka(u,["description","title"]),f=s.filter(m=>m.parentID===a);if(f.length===0)return null;if(f.length===1)return f[0].id;if(d){const m=f.find(h=>h.title===d);if(m)return m.id}return null}function LM({part:e}){const t=DM(e),a=Ie(s=>s.setActiveSession);return t?o.jsxs("button",{type:"button",onClick:s=>{s.stopPropagation(),a(t)},className:"mt-2 flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1 font-mono text-xs text-blue-400 transition-colors hover:border-blue-500/50 hover:bg-blue-500/10",children:[o.jsxs("span",{className:"truncate text-fg-5",children:[t.slice(0,20),"…"]}),o.jsx(Pv,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"shrink-0",children:"查看子会话"})]}):null}function jM(e,t){const a=a0(t);if(!a)return null;const s=e.toLowerCase();if(s==="edit"||s==="patch"){const l=typeof a.oldString=="string"?a.oldString:"",u=typeof a.newString=="string"?a.newString:"";if(l||u)return o.jsx(RM,{oldStr:l,newStr:u})}if(s==="todowrite"||s==="write_todos"){const l=Array.isArray(a.todos)?a.todos:null;if(l&&l.length>0)return o.jsx(qT,{todos:l})}if(s==="bash"||s==="shell"){const l=Ka(a,["command","cmd","script"]);if(l)return o.jsxs("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-fg-2",children:[o.jsx("span",{className:"select-none text-emerald-400/70",children:"❯ "}),l]})}if(s==="task"||s==="agent")return o.jsx(MM,{record:a});if(s==="read")return null;if(s==="write"){const l=typeof a.content=="string"?a.content:null;if(l){const u=l.length>500?`${l.slice(0,500)}…`:l;return o.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-fg-2",children:u})}}return null}function BM(e,t){const a=e.toLowerCase();if(a==="todowrite"||a==="write_todos"){const s=Array.isArray(t)?t:null;if(s&&s.length>0)return o.jsx(qT,{todos:s})}return null}function PM({part:e}){const t=Ph(e),a=t==="running"||t==="pending",[s,l]=A.useState(a),[u,d]=A.useState(!1),f=A.useRef(a);A.useEffect(()=>{f.current!==a&&(l(a),f.current=a)},[a]);const m=my(e),h=m.toLowerCase(),x=h==="task"||h==="agent",b=zc(e),{label:y,arg:T}=kM(m,b),N=jM(m,b),v=N?null:_x(b),S=Bh(e),C=BM(m,S),R=C?"":_x(S),w=wM[t],D=R.length>Pm,K=u||!D?R:`${R.slice(0,Pm)}…`;return o.jsxs("div",{className:"my-1 overflow-hidden rounded-md border border-line bg-term/70",children:[o.jsxs("button",{type:"button",onClick:()=>l(L=>!L),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left font-mono text-xs transition-colors duration-150 hover:bg-surface/70",children:[o.jsx("span",{className:oe("shrink-0 leading-none",w.color),children:s?"▾":"▸"}),o.jsx("span",{className:"shrink-0 font-medium text-fg",children:y}),T&&o.jsx("span",{className:"truncate text-fg-3",children:T}),o.jsxs("span",{className:oe("ml-auto flex shrink-0 items-center gap-1.5 leading-none",w.color),children:[o.jsx("span",{className:oe(w.spin&&"fs-spin"),children:w.glyph}),o.jsx("span",{children:w.label})]})]}),s&&o.jsx("div",{className:"border-t border-line px-3 py-2",children:o.jsxs("div",{className:oe("ml-1 border-l-2 pl-3 font-mono text-xs",w.accent),children:[N&&o.jsx("section",{className:"mb-2",children:N}),v&&o.jsxs("section",{className:"mb-2",children:[o.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-fg-5",children:"input"}),o.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-fg-2",children:v})]}),x&&o.jsx(LM,{part:e}),C&&o.jsx("section",{children:C}),R&&o.jsxs("section",{children:[o.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-fg-5",children:"output"}),o.jsx("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words text-fg-2",children:K}),D&&o.jsx("button",{type:"button",onClick:()=>d(L=>!L),className:"mt-1 text-blue-400 transition-colors hover:text-blue-300",children:u?"show less":`show ${R.length-Pm} more chars`})]}),!N&&!v&&!C&&!R&&o.jsx("div",{className:"text-fg-5",children:"no parameters"})]})})]})}function UM({text:e}){const[t,a]=A.useState(!1);return o.jsxs("div",{className:"my-1",children:[o.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"flex items-center gap-1.5 font-mono text-xs text-fg-5 transition-colors hover:text-fg-3",children:[t?o.jsx(Sr,{className:"h-3 w-3 shrink-0"}):o.jsx(Ih,{className:"h-3 w-3 shrink-0"}),o.jsx(FE,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{children:"thinking"})]}),t&&o.jsx("div",{className:"ml-1.5 mt-1 whitespace-pre-wrap border-l border-line pl-3 text-xs italic leading-relaxed text-fg-4",children:e})]})}function HM(){const[e,t]=A.useState(0);return A.useEffect(()=>{const a=Date.now(),s=setInterval(()=>{t(Math.floor((Date.now()-a)/1e3))},1e3);return()=>clearInterval(s)},[]),o.jsxs("div",{className:"my-1 flex items-center gap-1.5 font-mono text-xs text-fg-5",children:[o.jsx(FE,{className:"h-3 w-3 shrink-0 animate-pulse"}),o.jsx("span",{children:"thinking"}),e>0&&o.jsxs("span",{className:"text-fg-6",children:[e,"s"]})]})}function FM({part:e,isStreaming:t}){switch(jh(e)){case"text":{const s=yc(e);return s.trim()?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[NM],components:{table:e0},children:s})}):null}case"thinking":{const s=yc(e);return s.trim()?o.jsx(UM,{text:s}):t?o.jsx(HM,{}):null}case"tool":return po(e)?o.jsx(AM,{part:e}):o.jsx(PM,{part:e});default:return null}}function zM({message:e,isStreaming:t,queued:a}){var x,b,y,T,N,v;const s=e.role==="user",l=e.parts??[],u=l.filter(S=>jh(S)!=="other");if(s){const S=l.map(yc).join("").trim(),C=(x=e.time)==null?void 0:x.created,R=C?new Date(C*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return o.jsxs("div",{className:"fs-fade-in rounded-r-md border-l-2 border-emerald-500/40 bg-emerald-500/[0.04] px-3 py-2 font-mono",children:[o.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[11px]",children:[o.jsx("span",{className:"font-medium text-emerald-400",children:"You"}),R&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsx("span",{className:"text-fg-5",children:R})]}),a&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-amber-500/30 px-1.5 py-0.5 text-xs text-amber-400",children:[o.jsx("span",{className:"leading-none",children:"○"}),o.jsx("span",{children:"queued"})]})]}),o.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[o.jsx("span",{className:"shrink-0 select-none text-emerald-400",children:"❯"}),o.jsx("span",{className:"min-w-0 flex-1 whitespace-pre-wrap break-words text-fg",children:S||"…"})]})]})}const d=((b=e.info)==null?void 0:b.agent)??e.agent,f=((y=e.info)==null?void 0:y.modelID)??e.modelID,m=(T=e.info)==null?void 0:T.error,h=(N=e.info)==null?void 0:N.finish;return o.jsxs("div",{className:"fs-fade-in font-mono",children:[(d||f)&&o.jsxs("div",{className:"mb-1 flex items-center gap-2 text-xs",children:[d&&o.jsx("span",{className:"text-fg-3",children:d}),d&&f&&o.jsx("span",{className:"text-fg-6",children:"·"}),f&&o.jsx("span",{className:"text-fg-5",children:f})]}),m&&o.jsxs("div",{className:"my-1 flex items-start gap-2 rounded-md border border-red-500/20 bg-red-500/10 px-3 py-2 text-xs text-red-400",children:[o.jsx(Dn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("span",{className:"font-semibold",children:m.name??"Error"}),((v=m.data)==null?void 0:v.message)&&o.jsx("p",{className:"mt-0.5 text-red-400/80",children:m.data.message}),h&&h!=="end"&&o.jsxs("p",{className:"mt-0.5 text-red-400/60",children:["finish: ",h]})]})]}),o.jsx("div",{className:"space-y-2 text-sm text-fg",children:u.length>0?u.map((S,C)=>o.jsx(FM,{part:S,isStreaming:t},S.id??S.callID??C)):!m&&o.jsx("span",{className:"text-fg-5",children:"…"})})]})}const qM={completed:{glyph:"■",color:"text-emerald-400"},in_progress:{glyph:"■",color:"text-amber-400"},cancelled:{glyph:"■",color:"text-fg-6"},pending:{glyph:"□",color:"text-fg-5"}};function YM(e){const t=e.find(s=>Pi(s.status)==="in_progress");if(t)return t.content;const a=e.find(s=>Pi(s.status)==="pending");return a?a.content:"all steps complete"}function $M({todos:e,onClick:t}){if(e.length===0)return null;const a=e.length,s=$C(e);return o.jsx("div",{className:"rounded-md border border-line bg-term/60 px-3 py-2",children:o.jsxs("button",{type:"button",onClick:t,className:"flex w-full items-center gap-2 text-left font-mono text-xs",children:[o.jsxs("span",{className:"shrink-0 tabular-nums text-fg-4",children:["[",s,"/",a,"]"]}),o.jsx("span",{className:"shrink-0 tracking-tight",children:e.map(l=>{const u=qM[Pi(l.status)];return o.jsx("span",{className:u.color,children:u.glyph},l.id)})}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-fg-2",children:YM(e)}),o.jsx("span",{className:"shrink-0 text-[10px] text-fg-5",children:"详情 →"})]})})}const GM=200;function KM(){return Ie(e=>{const t=e.activeSessionId;if(!t)return!1;const a=e.messages[t]??go;for(let s=a.length-1;s>=0;s--){const l=a[s].parts;if(l){for(const u of l)if(jh(u)==="tool"&&Tc(u))return!0}}return!1})}function VM(){const[e,t]=A.useState(""),[a,s]=A.useState(""),[l,u]=A.useState([]),d=A.useRef(null),f=Ie(D=>D.activeSessionId),m=Fe(D=>D.activeRepoId),h=Ie(D=>{const K=D.activeSessionId;return K?D.sessionStatuses[K]:void 0}),x=Ie(D=>D.sendMessage),b=oc(D=>D.setDraft),y=oc(D=>D.clearDraft),T=KM();A.useEffect(()=>{if(!m){u([]);return}let D=!1;return(async()=>{try{const[K,L]=await Promise.all([Fc(),Lh(m)]);if(D)return;const M=K.pinned_models,V=M?JSON.parse(M):[];u(V.length>0?L.filter(W=>V.includes(W.id)):[])}catch{D||u([])}})(),()=>{D=!0}},[m]);const N=h==="busy"&&!T,v=!f;A.useLayoutEffect(()=>{const D=d.current;D&&(D.style.height="auto",D.style.height=`${Math.min(D.scrollHeight,GM)}px`)},[e]),A.useEffect(()=>{t(f?oc.getState().drafts[f]??"":"")},[f]);const S=async()=>{const D=e.trim();if(!D||v)return;await x(D,a||void 0)&&(t(""),f&&y(f))},C=D=>{D.nativeEvent.isComposing||D.keyCode===229||D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),S())},R=f?T?"输入回复,或点击上方选项…":N?"输入消息将排队等待处理…":"enter a command…":"select or start a run",w=f?N?"text-amber-400 fs-blink":T?"text-blue-400":"text-emerald-400":"text-fg-6";return o.jsxs("div",{className:"border-t border-line bg-term px-4 py-4",children:[o.jsxs("div",{className:oe("mx-auto flex max-w-4xl items-start gap-2 rounded-lg border px-3 py-2 transition-colors duration-150",v?"border-line":"border-fg-5 focus-within:border-fg-4"),children:[o.jsx("span",{className:oe("select-none pt-px font-mono text-sm leading-6",w),children:"❯"}),o.jsx("textarea",{ref:d,rows:2,value:e,disabled:v,onChange:D=>{const K=D.target.value;t(K),f&&b(f,K)},onKeyDown:C,placeholder:R,className:"flex-1 resize-none bg-transparent font-mono text-sm leading-6 text-fg placeholder:text-fg-6 focus:outline-none disabled:cursor-not-allowed"}),o.jsx("button",{type:"button",onClick:S,disabled:v||e.trim().length===0,"aria-label":"Send message",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-emerald-600 text-white transition-colors duration-150 hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-fg-6/30 disabled:text-fg-5",children:o.jsx(HE,{className:"h-4 w-4",strokeWidth:2.5})})]}),o.jsxs("div",{className:"mx-auto mt-1.5 flex max-w-4xl items-center gap-3 pl-5",children:[o.jsx("span",{className:"font-mono text-[10px] text-fg-6",children:"⏎ to run · shift+⏎ for newline"}),l.length>0&&o.jsxs("select",{value:a,onChange:D=>s(D.target.value),className:"ml-auto max-w-[200px] truncate rounded border border-line bg-surface px-2 py-0.5 font-mono text-[11px] text-fg-4 focus:border-fg-5 focus:outline-none",children:[o.jsx("option",{value:"",children:"默认模型"}),l.map(D=>o.jsx("option",{value:D.id,children:D.name||D.id},D.id))]})]})]})}const R1={idle:{glyph:"●",label:"ready",color:"text-emerald-400",spin:!1},busy:{glyph:"◌",label:"running",color:"text-amber-400",spin:!0},retry:{glyph:"◌",label:"retrying",color:"text-amber-400",spin:!0},error:{glyph:"✗",label:"error",color:"text-red-400",spin:!1}};function QM({status:e,reason:t}){const a=R1[e??"idle"]??R1.idle;return o.jsxs("span",{className:oe("flex items-center gap-1.5 rounded border border-line px-2 py-0.5 font-mono text-xs",a.color),title:e==="error"&&t?t:void 0,children:[o.jsx("span",{className:oe("leading-none",a.spin&&"fs-spin"),children:a.glyph}),o.jsx("span",{children:a.label})]})}const XM={"claude-opus-4":1e6,"claude-sonnet-4":1e6,"claude-sonnet-5":1e6,"claude-opus-5":1e6,"claude-3-7-sonnet":2e5,"claude-3-5-sonnet":2e5,"claude-3-5-haiku":2e5,"claude-3-opus":2e5,"claude-3-sonnet":2e5,"claude-3-haiku":2e5},O1=1e6;function WM(e){if(!e)return O1;for(const[t,a]of Object.entries(XM))if(e.startsWith(t))return a;return O1}function I1(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ZM(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>0?`$${e.toFixed(4)}`:"$0"}function JM(e){for(let t=e.length-1;t>=0;t--){const a=e[t];if(a.role==="assistant"&&a.tokens){const s=a.tokens;if(s.cache&&(s.cache.read>0||s.cache.write>0)||s.input>0||s.output>0)return s}}return null}function eD({session:e,messages:t}){var m,h,x;const a=JM(t),s=(e==null?void 0:e.cost)??0;if(!a&&!s)return null;const l=a?a.input+(((m=a.cache)==null?void 0:m.read)??0)+(((h=a.cache)==null?void 0:h.write)??0):0,u=WM((x=e==null?void 0:e.model)==null?void 0:x.modelID),d=l>0?Math.min(Math.round(l/u*100),999):0,f=d>=80?"text-red-400":d>=50?"text-amber-400":"text-fg-5";return o.jsxs("div",{className:"flex items-center gap-2 font-mono text-[11px] text-fg-5",children:[l>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{title:"当前上下文 = cache_read + cache_write + input (最近一次请求)",children:I1(l)}),o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsxs("span",{className:f,title:`上下文占比 (${I1(u)} 窗口)`,children:[d,"%"]}),o.jsx("span",{className:"text-fg-6",children:"·"})]}),o.jsx("span",{title:"会话累计费用",children:ZM(s)})]})}const tD=144,nD=64;function YT({onToggleSidebar:e}){const[t,a]=A.useState(""),[s,l]=A.useState(""),[u,d]=A.useState(""),[f,m]=A.useState(""),[h,x]=A.useState(!1),b=A.useRef(null),y=A.useRef(null),T=Ie(U=>U.createSession),N=Ie(U=>U.sendError),v=Fe(U=>U.activeRepoId),S=ji(U=>U.agents),C=Ge(U=>U.issues),R=Ge(U=>U.selectedIssueId),w=Ge(U=>U.pendingDraft);A.useEffect(()=>{R&&(d(R),Ge.getState().setSelectedIssue(null))},[R]),A.useEffect(()=>{w&&(a(w),Ge.getState().setPendingDraft(null))},[w]),A.useLayoutEffect(()=>{const U=b.current;U&&(U.style.height="auto",U.style.height=`${Math.min(U.scrollHeight,tD)}px`)},[t]),A.useEffect(()=>{const U=J=>{y.current&&!y.current.contains(J.target)&&x(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[]);const D=C.filter(U=>U.state==="open"),K=C.find(U=>U.id===u),L=f.trim().toLowerCase(),M=L?D.filter(U=>`#${U.number} ${U.title}`.toLowerCase().includes(L)):D,V=!!s||!!u,W=()=>{const U=t.trim();!v||!U&&!V||(a(""),T(U,void 0,void 0,void 0,u||void 0,s||void 0))},j=U=>{U.nativeEvent.isComposing||U.keyCode===229||U.key==="Enter"&&!U.shiftKey&&(U.preventDefault(),W())};return o.jsxs("div",{className:"relative flex flex-1 flex-col items-center justify-center bg-term",children:[o.jsx("button",{type:"button",onClick:e,"aria-label":"Open sidebar",className:"absolute left-3 top-3 rounded-lg p-2 text-fg-3 hover:bg-elevated md:hidden",children:o.jsx(Pc,{className:"h-5 w-5"})}),o.jsxs("div",{className:"w-full max-w-2xl px-6",children:[o.jsx("div",{className:"mb-8 text-center",children:o.jsxs("div",{className:"font-mono text-2xl text-fg-6",children:[o.jsx("span",{className:"text-emerald-500/60",children:"❯"}),o.jsx("span",{className:"fs-blink text-fg-4",children:" ▋"})]})}),o.jsxs("div",{className:"rounded-xl border border-line bg-base/80 shadow-sm transition-colors focus-within:border-fg-5",children:[o.jsxs("div",{className:"flex items-start gap-2 px-4 py-3",children:[o.jsx("span",{className:"select-none pt-px font-mono text-sm leading-6 text-emerald-400",children:"❯"}),o.jsx("textarea",{ref:b,rows:1,value:t,autoFocus:!0,disabled:!v,onChange:U=>a(U.target.value),onKeyDown:j,placeholder:v?"让 Agent 做什么?":"请先选择一个仓库",className:"flex-1 resize-none bg-transparent font-mono text-sm leading-6 text-fg placeholder:text-fg-6 focus:outline-none disabled:cursor-not-allowed"}),o.jsx("button",{type:"button",onClick:W,disabled:!v||!t.trim()&&!V,"aria-label":"Start run",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-emerald-600 text-white transition-colors duration-150 hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-fg-6/30 disabled:text-fg-5",children:o.jsx(HE,{className:"h-4 w-4",strokeWidth:2.5})})]}),o.jsxs("div",{className:"flex flex-col gap-2 border-t border-line/60 px-4 py-2 sm:flex-row sm:items-center sm:gap-3",children:[o.jsxs("label",{className:"flex items-center gap-1.5 font-mono text-[11px] text-fg-4",children:[o.jsx("span",{className:"shrink-0",children:"Agent"}),o.jsxs("select",{value:s,onChange:U=>l(U.target.value),className:"rounded border border-line bg-surface px-2 py-1 font-mono text-xs text-fg focus:border-fg-5 focus:outline-none",children:[o.jsx("option",{value:"",children:"默认"}),S.map(U=>o.jsx("option",{value:U.id,children:U.name},U.id))]})]}),C.length>0&&o.jsxs("div",{ref:y,className:"relative hidden min-w-0 flex-1 items-center gap-1.5 font-mono text-[11px] text-fg-4 sm:flex",children:[o.jsx("span",{className:"shrink-0",children:"Issue"}),o.jsxs("button",{type:"button",onClick:()=>{x(U=>!U),m("")},className:"flex min-w-0 flex-1 items-center gap-1 truncate rounded border border-line bg-surface px-2 py-1 font-mono text-xs text-fg transition-colors hover:border-fg-5 focus:border-fg-5 focus:outline-none",children:[o.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:K?`#${K.number} ${K.title}`:"无"}),o.jsx(Sr,{className:"h-3 w-3 shrink-0 text-fg-5"})]}),u&&o.jsx("button",{type:"button",onClick:()=>{d(""),m("")},className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})}),h&&o.jsxs("div",{className:"absolute left-0 top-full z-50 mt-1 w-full min-w-[280px] rounded-md border border-line bg-surface shadow-lg",children:[o.jsxs("div",{className:"flex items-center gap-1.5 border-b border-line px-2 py-1.5",children:[o.jsx(os,{className:"h-3 w-3 shrink-0 text-fg-5"}),o.jsx("input",{type:"text",value:f,onChange:U=>m(U.target.value),onKeyDown:U=>{U.key==="Escape"&&x(!1)},placeholder:"搜索 issue...",autoFocus:!0,className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-fg placeholder:text-fg-6 focus:outline-none"})]}),o.jsxs("ul",{className:"max-h-48 overflow-y-auto py-1",children:[!L&&o.jsx("li",{children:o.jsx("button",{type:"button",onClick:()=>{d(""),x(!1)},className:oe("w-full px-2.5 py-1.5 text-left font-mono text-xs transition-colors hover:bg-elevated/60",u?"text-fg-4":"text-blue-400"),children:"无"})}),M.map(U=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>{d(U.id),m(""),x(!1)},className:oe("flex w-full items-center gap-1.5 px-2.5 py-1.5 text-left transition-colors hover:bg-elevated/60",U.id===u?"bg-blue-500/10":""),children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium",U.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",U.number]}),o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:U.title})]})},U.id)),M.length===0&&o.jsx("li",{className:"px-2.5 py-3 text-center font-mono text-[10px] text-fg-5",children:"无匹配结果"})]})]})]})]})]}),o.jsx("div",{className:"mt-2 text-center font-mono text-[10px] text-fg-6",children:"⌘⏎ / ctrl+⏎ 开始运行"}),N&&o.jsx("div",{className:"mt-3 rounded-lg border border-red-500/20 bg-red-500/10 px-4 py-2 font-mono text-xs text-red-400",children:N})]})]})}function M1({body:e}){return e?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],components:{table:e0},children:e})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"没有描述内容"})}function D1({issue:e}){var t;return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",e.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",e.number," ",e.state]}),(t=e.labels)==null?void 0:t.map(a=>o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${a.color}20`,color:`#${a.color}`},children:a.name},a.id))]}),o.jsx("h2",{className:"mt-0.5 truncate text-sm font-medium text-fg",children:e.title})]})}function aD({onToggleSidebar:e}){const t=Ge(x=>x.matchingParentId),a=Ge(x=>x.matchingCandidateId),s=Ge(x=>x.issues.find(b=>b.id===t)),l=Ge(x=>x.issues.find(b=>b.id===a)),u=Ge(x=>x.exitMatchMode),d=Ge(x=>x.linkChild),[f,m]=A.useState(!1);if(!s)return null;const h=async()=>{l&&(m(!0),await d(s.number,l.number),m(!1))};return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-term",children:[o.jsxs("header",{className:"flex items-center gap-3 border-b border-line bg-base px-4 py-2.5",children:[o.jsx("button",{type:"button",onClick:e,"aria-label":"Open sidebar",className:"-ml-1 rounded-lg p-1.5 text-fg-3 hover:bg-elevated md:hidden",children:o.jsx(Pc,{className:"h-5 w-5"})}),o.jsx("span",{className:"text-xs font-medium text-fg-4",children:"匹配子任务"}),o.jsxs("span",{className:"font-mono text-xs text-fg-3",children:["父: #",s.number]}),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{type:"button",onClick:u,className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsx(gt,{className:"h-3.5 w-3.5"}),"退出匹配"]})]}),o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row",children:[o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden border-b border-line md:border-b-0 md:border-r",children:[o.jsx("div",{className:"border-b border-line/60 px-4 py-2.5",children:o.jsx(D1,{issue:s})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:o.jsx(M1,{body:s.body})})]}),o.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:l?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-b border-line/60 px-4 py-2.5",children:o.jsx(D1,{issue:l})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:o.jsx(M1,{body:l.body})})]}):o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"← 从左侧列表选择候选 Issue"})})})]}),l&&o.jsx("div",{className:"flex items-center justify-center gap-3 border-t border-line bg-base px-4 py-3",children:o.jsxs("button",{type:"button",onClick:()=>void h(),disabled:f,className:"flex items-center gap-1.5 rounded-md bg-blue-600 px-4 py-2 text-xs font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-50",children:[o.jsx(oa,{className:"h-3.5 w-3.5"}),f?"关联中…":`确认: 将 #${l.number} 设为 #${s.number} 的子任务`]})})]})}function rD({onToggleSidebar:e}){var l;const t=Ge(u=>u.previewIssueId),a=Ge(u=>u.issues.find(d=>d.id===t));if(!a)return o.jsx(YT,{onToggleSidebar:e});const s=()=>{Ge.getState().setSelectedIssue(a.id),Ge.getState().setPreviewIssue(null)};return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-term",children:[o.jsxs("header",{className:"flex items-center gap-3 border-b border-line bg-base px-4 py-2.5",children:[o.jsx("button",{type:"button",onClick:e,"aria-label":"Open sidebar",className:"-ml-1 rounded-lg p-1.5 text-fg-3 hover:bg-elevated md:hidden",children:o.jsx(Pc,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",a.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",a.number," ",a.state]}),(l=a.labels)==null?void 0:l.map(u=>o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${u.color}20`,color:`#${u.color}`},children:u.name},u.id))]}),o.jsx("h2",{className:"mt-0.5 truncate text-sm font-medium text-fg",children:a.title})]}),o.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[a.htmlUrl&&o.jsxs("a",{href:a.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 font-mono text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsx(pc,{className:"h-3.5 w-3.5"}),"源站"]}),o.jsxs("button",{type:"button",onClick:()=>Ge.getState().enterMatchMode(a.id),className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 text-xs text-fg-3 transition-colors hover:border-blue-500/50 hover:text-blue-400",children:[o.jsx(Ys,{className:"h-3.5 w-3.5"}),"匹配子任务"]}),o.jsxs("button",{type:"button",onClick:s,className:"flex h-8 items-center gap-1.5 rounded-md bg-blue-600 px-3 text-xs font-medium text-white transition-colors hover:bg-blue-500",children:[o.jsx(Uc,{className:"h-3.5 w-3.5 fill-current"}),"开始处理"]})]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsx("div",{className:"mx-auto max-w-4xl px-6 py-6",children:a.body?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],components:{table:e0},children:a.body})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"该 Issue 没有描述内容"})})})]})}function sD({onToggleSidebar:e,onToggleRightPanel:t,rightPanelOpen:a}){var L;const s=Aa(),l=Fe(La),u=Ie(M=>M.activeSessionId),d=Ge(M=>M.previewIssueId),f=Ie(M=>M.sessions.find(V=>V.id===M.activeSessionId)??null),m=Ie(M=>{const V=M.activeSessionId;return V?M.messages[V]??go:go}),h=Ie(M=>{const V=M.activeSessionId;return V?M.todos[V]??_c:_c}),x=Ie(M=>{const V=M.activeSessionId;return V?M.sessionStatuses[V]:void 0}),b=Ie(M=>{const V=M.activeSessionId;return V?M.queuedMessageIds[V]??Nx:Nx}),y=Ie(M=>{const V=M.activeSessionId;return V?M.errorReasons[V]:void 0}),T=Ie(M=>M.sendError),N=Ie(M=>M.abortSession),v=Ge(M=>f!=null&&f.issueId?M.issues.find(V=>V.id===f.issueId):void 0);A.useEffect(()=>{if(u)return Ac.activateSession(u),()=>Ac.deactivateSession(u)},[u]);const S=A.useRef(null),C=A.useRef(!0);A.useEffect(()=>{const M=S.current;M&&C.current&&(M.scrollTop=M.scrollHeight)},[m,h]),A.useEffect(()=>{C.current=!0},[u]),A.useEffect(()=>{if(x!=="busy"&&x!=="retry")return;const M=V=>{if(V.key!=="Escape"||V.defaultPrevented)return;const W=V.target;W instanceof HTMLInputElement||W instanceof HTMLTextAreaElement||W!=null&&W.isContentEditable||N()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[x,N]);const R=Ge(M=>M.matchingParentId);if(!u)return R?o.jsx(aD,{onToggleSidebar:e}):d?o.jsx(rD,{onToggleSidebar:e}):o.jsx(YT,{onToggleSidebar:e});const w=x==="busy",D=x==="retry",K=w||D;return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-term",children:[o.jsxs("header",{className:"flex items-center gap-3 border-b border-line bg-base px-4 py-2.5",children:[o.jsxs("div",{className:"flex items-center gap-1 md:hidden",children:[o.jsx("button",{type:"button",onClick:e,"aria-label":"Open sidebar",className:"-ml-1 rounded-lg p-1.5 text-fg-3 hover:bg-elevated",children:o.jsx(Pc,{className:"h-5 w-5"})}),o.jsx("button",{type:"button",onClick:()=>Ie.setState({activeSessionId:null}),"aria-label":"新建运行",title:"新建运行",className:"rounded-lg p-1.5 text-fg-3 hover:bg-elevated",children:o.jsx(Xa,{className:"h-5 w-5"})})]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[(f==null?void 0:f.parentID)&&o.jsxs("button",{type:"button",onClick:()=>void Ie.getState().setActiveSession(f.parentID),className:"mb-0.5 flex items-center gap-1 text-[11px] text-fg-4 transition-colors hover:text-blue-400",children:[o.jsx(jv,{className:"h-3 w-3"}),"返回父会话"]}),o.jsx("h2",{className:"truncate text-sm font-medium text-fg",children:((L=f==null?void 0:f.title)==null?void 0:L.trim())||"untitled run"}),(f==null?void 0:f.agent)&&o.jsx("p",{className:"truncate font-mono text-xs text-fg-4",children:f.agent}),o.jsx(eD,{session:f,messages:m})]}),v&&o.jsxs("button",{type:"button",onClick:()=>s(`/${encodeURIComponent(l)}/issues?issueId=${v.id}`),className:"flex items-center gap-1 rounded-md border border-line px-2 py-1 font-mono text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsxs("span",{className:oe("rounded px-1 py-0.5 text-[10px] font-semibold",v.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",v.number]}),o.jsx("span",{className:"hidden max-w-[120px] truncate sm:inline",children:v.title})]}),o.jsx(QM,{status:x,reason:y}),t&&o.jsx("button",{type:"button",onClick:t,"aria-label":a?"关闭侧边栏":"打开侧边栏",className:oe("hidden items-center justify-center rounded-md border border-line p-1.5 transition-colors md:flex",a?"bg-blue-500/10 text-blue-500 hover:bg-blue-500/20":"text-fg-4 hover:bg-elevated hover:text-fg-2"),children:o.jsx($E,{className:"h-4 w-4"})}),K&&o.jsxs("button",{type:"button",onClick:()=>void N(),className:"flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1 font-mono text-xs text-fg-2 transition-colors hover:border-red-500/50 hover:text-red-400",children:[o.jsx(KE,{className:"h-3 w-3 fill-current"}),D?"stop retry":"stop"]})]}),o.jsx("div",{ref:S,onScroll:()=>{const M=S.current;M&&(C.current=M.scrollHeight-M.clientHeight-M.scrollTop<=nD)},className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-3 px-4 py-4",children:[m.length===0?o.jsxs("p",{className:"py-10 text-center font-mono text-xs text-fg-6",children:[o.jsx("span",{className:"text-emerald-500/60",children:"❯"})," waiting for input",o.jsx("span",{className:"fs-blink",children:" ▋"})]}):m.map((M,V)=>o.jsxs(A.Fragment,{children:[V>0&&M.role==="user"&&o.jsx("div",{className:"border-t border-line"}),o.jsx("div",{"data-message-id":M.id,children:o.jsx(zM,{message:M,isStreaming:w&&V===m.length-1,queued:b.includes(M.id)})})]},M.id)),h.length>0&&o.jsx($M,{todos:[...h],onClick:t})]})}),x==="error"&&y&&o.jsxs("div",{className:"flex items-center gap-2 border-t border-red-500/20 bg-red-500/10 px-4 py-2 font-mono text-xs text-red-400",children:[o.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"truncate",children:y})]}),T&&o.jsxs("div",{className:"flex items-center gap-2 border-t border-red-500/20 bg-red-500/10 px-4 py-2 font-mono text-xs text-red-400",children:[o.jsx(Dn,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"truncate",children:T})]}),o.jsx(VM,{})]})}const Vn=Wa((e,t)=>({pulls:[],loaded:!1,syncing:!1,selectedPrId:null,matchingPrId:null,matchingCandidateIssueId:null,clearPulls:()=>e({pulls:[],loaded:!1,selectedPrId:null,matchingPrId:null,matchingCandidateIssueId:null}),setSelectedPr:a=>e({selectedPrId:a}),enterMatchMode:a=>e({matchingPrId:a,matchingCandidateIssueId:null}),exitMatchMode:()=>{const a=t().matchingPrId;e({matchingPrId:null,matchingCandidateIssueId:null,selectedPrId:a})},setMatchCandidate:a=>e({matchingCandidateIssueId:a}),linkIssue:async(a,s)=>{const l=Fe.getState().activeRepoId;if(!l)return!1;try{return await mC(l,a,s),!0}catch{return!1}},unlinkIssue:async(a,s)=>{const l=Fe.getState().activeRepoId;if(!l)return!1;try{return await hC(l,a,s),!0}catch{return!1}},loadPulls:async()=>{const a=Fe.getState().activeRepoId;if(!a){e({pulls:[],loaded:!0});return}try{const s=await bx(a,"all");e({pulls:s,loaded:!0})}catch{e({loaded:!0})}},syncPulls:async()=>{const a=Fe.getState().activeRepoId;if(a){e({syncing:!0});try{await dC(a);const s=await bx(a,"all");e({pulls:s,syncing:!1})}catch(s){e({syncing:!1});let l="同步 PR 失败";if(s instanceof Qa)try{const u=JSON.parse(s.message);u.error&&(l=u.error)}catch{s.message&&(l=s.message)}Yt.getState().addToast(l,"error")}}}})),iD={completed:{glyph:"✓",color:"text-emerald-400",spin:!1},in_progress:{glyph:"◌",color:"text-amber-400",spin:!0},cancelled:{glyph:"✗",color:"text-fg-5",spin:!1},pending:{glyph:"○",color:"text-fg-4",spin:!1}};function lD(e){var l;const t=(l=e.time)==null?void 0:l.created;if(!t)return"";const a=t<1e12?t*1e3:t;return new Date(a).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}function oD(e){if(!e.parts)return"";for(const t of e.parts){const a=t.content??t.text;if(a)return a}return""}function uD({todos:e}){if(e.length===0)return o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"暂无待办项"})});const t=e.filter(a=>{const s=Pi(a.status);return s==="completed"||s==="cancelled"}).length;return o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[o.jsxs("div",{className:"mb-2 font-mono text-[10px] tabular-nums text-fg-5",children:["进度 ",t,"/",e.length]}),o.jsx("ul",{className:"space-y-1.5",children:e.map(a=>{const s=Pi(a.status),l=iD[s],u=s==="completed"||s==="cancelled";return o.jsxs("li",{className:"flex items-start gap-2 font-mono text-xs",children:[o.jsx("span",{className:oe("shrink-0 leading-5",l.color,l.spin&&"fs-spin"),children:l.glyph}),o.jsx("span",{className:oe("leading-5",u?"text-fg-5 line-through":"text-fg-2"),children:a.content})]},a.id)})})]})}function cD({messages:e,onScrollToMessage:t}){const a=e.filter(s=>s.role==="user");return a.length===0?o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"暂无输入记录"})}):o.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-2",children:o.jsx("ul",{className:"space-y-1",children:a.map((s,l)=>{const u=oD(s),d=lD(s);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>t==null?void 0:t(s.id),className:"group w-full rounded-md px-2 py-1.5 text-left transition-colors hover:bg-elevated/60",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"shrink-0 font-mono text-[10px] text-emerald-400/60",children:"❯"}),o.jsxs("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-fg-5",children:["#",l+1]}),d&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] text-fg-6",children:d})]}),u&&o.jsx("p",{className:"mt-0.5 line-clamp-2 pl-5 text-xs leading-relaxed text-fg-3 group-hover:text-fg-2",children:u})]})},s.id)})})})}function dD({linked:e,number:t,title:a,state:s,mergedAt:l,isPr:u,onToggle:d}){const f=u?s==="open"?"bg-emerald-500/15 text-emerald-400":l?"bg-purple-500/15 text-purple-400":"bg-red-500/15 text-red-400":s==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400";return o.jsx("li",{children:o.jsx("button",{type:"button",onClick:d,className:oe("flex w-full items-start gap-2 rounded-md px-2 py-2 text-left transition-colors",e?"border-l-2 border-emerald-500 bg-emerald-500/5":"border-l-2 border-transparent hover:bg-elevated/50"),children:o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-semibold",f),children:["#",t]}),o.jsx("span",{className:"min-w-0 truncate text-xs text-fg-2",children:a}),e&&o.jsx(Bc,{className:"ml-auto h-3 w-3 shrink-0 text-emerald-400"})]})})})}function fD({links:e,sessionId:t}){var L,M,V,W;const a=Aa(),s=Fe(La),[l,u]=A.useState(null),[d,f]=A.useState(""),m=A.useRef(null),h=Ge(j=>j.issues),x=Vn(j=>j.pulls),b=Ie(j=>j.addLink),y=Ie(j=>j.removeLink),T=new Set(((L=e==null?void 0:e.issues)==null?void 0:L.map(j=>j.id))??[]),N=new Set(((M=e==null?void 0:e.pullRequests)==null?void 0:M.map(j=>j.id))??[]);A.useEffect(()=>{var j;l&&((j=m.current)==null||j.focus())},[l]);const v=()=>{u(null),f("")},S=async(j,U,J)=>{t&&(J?await y(t,j,U):await b(t,j,U))},C=d.trim().toLowerCase(),R=C?h.filter(j=>`#${j.number} ${j.title}`.toLowerCase().includes(C)):h,w=C?x.filter(j=>`#${j.number} ${j.title} ${j.headBranch}`.toLowerCase().includes(C)):x,D=((V=e==null?void 0:e.issues)==null?void 0:V.length)??0,K=((W=e==null?void 0:e.pullRequests)==null?void 0:W.length)??0;if(l){const j=l==="issue",U=j?R:w,J=j?T:N;return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-line px-3 py-2",children:[o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-blue-400",children:j?"关联 Issue":"关联 PR"}),o.jsxs("button",{type:"button",onClick:v,className:"flex h-6 items-center gap-1 rounded-md px-2 text-xs text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:[o.jsx(gt,{className:"h-3.5 w-3.5"}),"完成"]})]}),o.jsx("div",{className:"border-b border-line px-3 py-2",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-line bg-base px-2 py-1",children:[o.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),o.jsx("input",{ref:m,type:"text",value:d,onChange:se=>f(se.target.value),placeholder:j?"搜索 issue...":"搜索 PR...",className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),d&&o.jsx("button",{type:"button",onClick:()=>f(""),className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:U.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:(j?h:x).length===0?j?"暂无 Issue,请先同步":"暂无 PR,请先同步":"无匹配结果"}):o.jsx("ul",{className:"space-y-0.5",children:U.map(se=>o.jsx(dD,{linked:J.has(se.id),number:se.number,title:se.title,state:se.state,mergedAt:j?void 0:se.mergedAt,isPr:!j,onToggle:()=>S(l,se.id,J.has(se.id))},se.id))})})]})}return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-1.5 border-b border-line px-3 py-2",children:[o.jsx("span",{className:"flex-1 font-mono text-[10px] text-fg-5",children:D+K>0?`${D+K} 项关联`:"暂无关联"}),o.jsxs("button",{type:"button",onClick:()=>u("issue"),className:"flex h-6 items-center gap-1 rounded-md border border-line px-1.5 text-fg-4 transition-colors hover:border-emerald-500/50 hover:text-emerald-400",children:[o.jsx(Xa,{className:"h-3 w-3"}),o.jsx("span",{className:"text-[10px] font-medium",children:"Issue"})]}),o.jsxs("button",{type:"button",onClick:()=>u("pr"),className:"flex h-6 items-center gap-1 rounded-md border border-line px-1.5 text-fg-4 transition-colors hover:border-blue-500/50 hover:text-blue-400",children:[o.jsx(Xa,{className:"h-3 w-3"}),o.jsx("span",{className:"text-[10px] font-medium",children:"PR"})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[D>0&&o.jsxs("div",{className:"mb-3",children:[o.jsxs("div",{className:"mb-1.5 font-mono text-[10px] font-medium uppercase tracking-wider text-fg-5",children:["Issues (",D,")"]}),o.jsx("ul",{className:"space-y-1",children:e.issues.map(j=>o.jsxs("li",{className:"group flex items-start gap-1",children:[o.jsxs("button",{type:"button",onClick:()=>a(`/${encodeURIComponent(s)}/issues?issueId=${encodeURIComponent(j.id)}`),className:"flex min-w-0 flex-1 items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-elevated/60",children:[o.jsxs("span",{className:oe("mt-0.5 shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-semibold",j.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",j.number]}),o.jsx("span",{className:"line-clamp-2 text-xs leading-5 text-fg-3 group-hover:text-fg-2",children:j.title})]}),o.jsx("button",{type:"button",onClick:()=>void S("issue",j.id,!0),className:"mt-1.5 hidden shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:bg-red-500/15 hover:text-red-400 group-hover:block",children:o.jsx(gt,{className:"h-3 w-3"})})]},j.id))})]}),K>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1.5 font-mono text-[10px] font-medium uppercase tracking-wider text-fg-5",children:["Pull Requests (",K,")"]}),o.jsx("ul",{className:"space-y-1",children:e.pullRequests.map(j=>o.jsxs("li",{className:"group flex items-start gap-1",children:[o.jsxs("button",{type:"button",onClick:()=>a(`/${encodeURIComponent(s)}/pulls?prId=${encodeURIComponent(j.id)}`),className:"flex min-w-0 flex-1 items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-elevated/60",children:[o.jsxs("span",{className:oe("mt-0.5 shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-semibold",j.state==="open"?"bg-emerald-500/15 text-emerald-400":j.mergedAt?"bg-purple-500/15 text-purple-400":"bg-red-500/15 text-red-400"),children:["#",j.number]}),o.jsx("span",{className:"line-clamp-2 text-xs leading-5 text-fg-3 group-hover:text-fg-2",children:j.title})]}),o.jsx("button",{type:"button",onClick:()=>void S("pr",j.id,!0),className:"mt-1.5 hidden shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:bg-red-500/15 hover:text-red-400 group-hover:block",children:o.jsx(gt,{className:"h-3 w-3"})})]},j.id))})]}),D===0&&K===0&&o.jsx("div",{className:"flex flex-1 items-center justify-center py-10",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"点击上方按钮添加关联"})})]})]})}const mD={"visual-engineering":"bg-purple-500/15 text-purple-400",quick:"bg-emerald-500/15 text-emerald-400",deep:"bg-blue-500/15 text-blue-400",ultrabrain:"bg-amber-500/15 text-amber-400",artistry:"bg-pink-500/15 text-pink-400",writing:"bg-cyan-500/15 text-cyan-400",explore:"bg-teal-500/15 text-teal-400",librarian:"bg-indigo-500/15 text-indigo-400",oracle:"bg-amber-500/15 text-amber-400",metis:"bg-rose-500/15 text-rose-400",momus:"bg-orange-500/15 text-orange-400"};function hD(e){switch(e){case"idle":return"bg-emerald-500";case"busy":case"retry":return"bg-amber-500 animate-pulse";case"error":return"bg-red-500";default:return"bg-fg-5"}}function Um(e){var a;const t=(a=e.time)==null?void 0:a.created;if(t)return t<1e12?t*1e3:t;if(e.createdAt){const s=Date.parse(e.createdAt);if(!Number.isNaN(s))return s}return null}function pD(e){const t=Date.now()-e,a=Math.floor(t/1e3);if(a<60)return"just now";const s=Math.floor(a/60);if(s<60)return`${s}m ago`;const l=Math.floor(s/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function gD(){const e=Ie(m=>m.sessions),t=Ie(m=>m.activeSessionId),a=Ie(m=>m.sessionStatuses),s=Ie(m=>m.setActiveSession),l=e.find(m=>m.id===t),u=(l==null?void 0:l.parentID)??t,d=!!(l!=null&&l.parentID),f=e.filter(m=>m.parentID===u).sort((m,h)=>(Um(h)??0)-(Um(m)??0));return f.length===0?o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"暂无子任务"})}):o.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[d&&o.jsxs("div",{className:"mb-1.5 px-2 font-mono text-[10px] text-fg-5",children:["同级子任务 (",f.length,")"]}),o.jsx("ul",{className:"space-y-0.5",children:f.map(m=>{const h=m.id===t,x=a[m.id],b=Um(m),y=(m.agent&&mD[m.agent])??"bg-elevated text-fg-4",T=m.title||`${m.id.slice(0,9)}...`;return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>{h||s(m.id)},className:oe("group flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",h?"border-l-2 border-blue-500 bg-blue-500/5":"border-l-2 border-transparent hover:bg-elevated/60"),children:[o.jsx("span",{className:oe("mt-1 h-2 w-2 shrink-0 rounded-full",hD(x))}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[m.agent&&o.jsx("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium",y),children:m.agent}),b!=null&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-fg-6",children:pD(b)})]}),o.jsx("p",{className:oe("mt-0.5 line-clamp-2 text-xs leading-5",h?"text-fg-2":"text-fg-3 group-hover:text-fg-2"),children:T})]})]})},m.id)})})]})}function L1({todos:e,messages:t,sessionLinks:a,sessionId:s,onScrollToMessage:l}){var N,v;const[u,d]=A.useState("todo"),f=Ie(S=>S.sessions),m=Ie(S=>S.activeSessionId),h=t.filter(S=>S.role==="user").length,x=(((N=a==null?void 0:a.issues)==null?void 0:N.length)??0)+(((v=a==null?void 0:a.pullRequests)==null?void 0:v.length)??0),b=f.find(S=>S.id===m),y=(b==null?void 0:b.parentID)??m,T=f.filter(S=>S.parentID===y).length;return o.jsxs("div",{className:"flex h-full w-72 shrink-0 flex-col border-l border-line bg-surface",children:[o.jsxs("div",{className:"flex items-center border-b border-line",children:[o.jsxs("button",{type:"button",onClick:()=>d("todo"),className:oe("flex flex-1 items-center justify-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors",u==="todo"?"border-blue-500 text-blue-500":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(MA,{className:"h-3.5 w-3.5"}),"待办",e.length>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:e.length})]}),o.jsxs("button",{type:"button",onClick:()=>d("prompts"),className:oe("flex flex-1 items-center justify-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors",u==="prompts"?"border-blue-500 text-blue-500":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(qA,{className:"h-3.5 w-3.5"}),"输入",h>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:h})]}),o.jsxs("button",{type:"button",onClick:()=>d("links"),className:oe("flex flex-1 items-center justify-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors",u==="links"?"border-blue-500 text-blue-500":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(Bc,{className:"h-3.5 w-3.5"}),"关联",x>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:x})]}),o.jsxs("button",{type:"button",onClick:()=>d("subtasks"),className:oe("flex flex-1 items-center justify-center gap-1.5 border-b-2 px-3 py-2.5 text-xs font-medium transition-colors",u==="subtasks"?"border-blue-500 text-blue-500":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(Ys,{className:"h-3.5 w-3.5"}),"子任务",T>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:T})]})]}),u==="todo"?o.jsx(uD,{todos:e}):u==="prompts"?o.jsx(cD,{messages:t,onScrollToMessage:l}):u==="links"?o.jsx(fD,{links:a,sessionId:s}):o.jsx(gD,{})]})}const j1=8;function bD(e,t){let a=e instanceof Element?e:null;for(;a&&a!==t;){if(a.scrollWidth>a.clientWidth){const s=getComputedStyle(a).overflowX;if(s==="auto"||s==="scroll")return!0}a=a.parentElement}return!1}function $T({onSwipeLeft:e,onSwipeRight:t,threshold:a=40,disabled:s=!1}={}){const l=A.useRef({x0:0,y0:0,dir:null,on:!1}),u=A.useRef(0),d=A.useCallback(h=>{if(s||bD(h.target,h.currentTarget))return;const x=h.touches[0];l.current={x0:x.clientX,y0:x.clientY,dir:null,on:!0},u.current=0},[s]),f=A.useCallback(h=>{const x=l.current;if(!x.on)return;const b=h.touches[0].clientX-x.x0,y=h.touches[0].clientY-x.y0;if(!x.dir){(Math.abs(b)>j1||Math.abs(y)>j1)&&(x.dir=Math.abs(b)>Math.abs(y)?"h":"v");return}if(x.dir==="v"){x.on=!1;return}u.current=b},[]),m=A.useCallback(()=>{const h=l.current;if(!h.on||h.dir!=="h"){h.on=!1;return}h.on=!1;const x=u.current;x>a?t==null||t():x<-a&&(e==null||e())},[a,e,t]);return{onTouchStart:d,onTouchMove:f,onTouchEnd:m}}function dh({side:e,open:t,onClose:a,children:s,width:l="w-80"}){const u=e==="left";return o.jsxs("div",{className:"md:hidden",children:[t&&o.jsx("div",{className:"fixed inset-0 z-40 bg-black/50",onClick:a,"aria-hidden":"true"}),o.jsx("div",{className:oe("fixed top-0 bottom-0 z-50 flex flex-col bg-surface pt-[var(--safe-top)] pb-[var(--safe-bottom)] shadow-xl transition-transform duration-200 ease-out",l,u?"left-0 border-r border-line":"right-0 border-l border-line",t?"translate-x-0":u?"-translate-x-full":"translate-x-full"),children:s})]})}function fh(e){var t,a;if(typeof((t=e.time)==null?void 0:t.updated)=="number")return e.time.updated;if(typeof((a=e.time)==null?void 0:a.created)=="number")return e.time.created;if(e.createdAt){const s=Date.parse(e.createdAt);return Number.isNaN(s)?0:s}return 0}function xD(e){const t=fh(e);if(!t)return"";const a=t<1e12?t*1e3:t,s=new Date(a);return s.toDateString()===new Date().toDateString()?s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function B1(e){navigator.clipboard?navigator.clipboard.writeText(e).catch(()=>P1(e)):P1(e)}function P1(e){const t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;opacity:0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function ED(e){switch(e){case"idle":return"bg-emerald-500";case"busy":case"retry":return"bg-amber-500 animate-pulse";case"error":return"bg-red-500";default:return"bg-fg-5"}}function yD({session:e,isActive:t,isConfirming:a,onSelect:s,onDelete:l,onConfirm:u,onCancelConfirm:d,onRename:f,onToggleComplete:m,status:h,issue:x,linkedItems:b}){var re,Q;const y=oc(F=>F.drafts[e.id]),T=!!e.completedAt,N=xD(e),[v,S]=A.useState(!1),[C,R]=A.useState(""),w=A.useRef(null),D=()=>{var F;R(((F=e.title)==null?void 0:F.trim())||""),S(!0),requestAnimationFrame(()=>{var fe;return(fe=w.current)==null?void 0:fe.focus()})},K=()=>{var fe;S(!1);const F=C.trim();F&&F!==(((fe=e.title)==null?void 0:fe.trim())||"")&&f(F)},[L,M]=A.useState(0),[V,W]=A.useState(!1),j=A.useRef({x0:0,y0:0,base:0,dir:null,on:!1}),U=F=>{const fe=F.touches[0];j.current={x0:fe.clientX,y0:fe.clientY,base:L,dir:null,on:!0},W(!1)},J=F=>{const fe=j.current;if(!fe.on)return;const Ce=F.touches[0].clientX-fe.x0,P=F.touches[0].clientY-fe.y0;if(!fe.dir){(Math.abs(Ce)>5||Math.abs(P)>5)&&(fe.dir=Math.abs(Ce)>Math.abs(P)?"h":"v");return}fe.dir!=="v"&&M(Math.max(-192,Math.min(0,fe.base+Ce)))},se=()=>{j.current.on=!1,W(!0),M(F=>F<-192/2?-192:0)},le=()=>{W(!0),M(0)};return o.jsxs("li",{className:"relative overflow-hidden rounded-md",children:[o.jsx("div",{className:"absolute right-0 top-0 bottom-0 flex md:hidden",style:L<0?{zIndex:10}:void 0,children:a?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>{l(),le()},className:"flex w-12 items-center justify-center bg-red-500 text-white active:bg-red-600",children:o.jsx(oa,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{d(),le()},className:"flex w-12 items-center justify-center bg-neutral-500 text-white active:bg-neutral-600",children:o.jsx(gt,{className:"h-4 w-4"})})]}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>{m(),le()},className:oe("flex w-12 items-center justify-center text-white",T?"bg-neutral-500 active:bg-neutral-600":"bg-emerald-500 active:bg-emerald-600"),children:o.jsx(dm,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{D(),le()},className:"flex w-12 items-center justify-center bg-amber-500 text-white active:bg-amber-600",children:o.jsx(sx,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{var F;B1(JSON.stringify({id:e.id,name:((F=e.title)==null?void 0:F.trim())||""},null,2)),le()},className:"flex w-12 items-center justify-center bg-blue-500 text-white active:bg-blue-600",children:o.jsx(hc,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>u(),className:"flex w-12 items-center justify-center bg-red-500 text-white active:bg-red-600",children:o.jsx(zs,{className:"h-4 w-4"})})]})}),o.jsxs("div",{className:oe("group relative rounded-md border-l-2",t?"border-blue-500 bg-elevated":"border-transparent bg-surface hover:bg-elevated/50",V&&"transition-transform duration-200 ease-out"),style:{...L!==0?{transform:`translateX(${L}px)`}:{},...L===-192?{pointerEvents:"none"}:{}},onTouchStart:U,onTouchMove:J,onTouchEnd:se,children:[o.jsxs("button",{type:"button",onClick:()=>{v||(s(),le())},className:oe("block w-full px-2.5 py-2 text-left",T&&!t&&"opacity-50"),style:L===-192?{pointerEvents:"auto"}:void 0,children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:oe("h-1.5 w-1.5 shrink-0 rounded-full",ED(h))}),o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:((re=e.agent)==null?void 0:re.trim())||"默认"}),T&&o.jsx(dm,{className:"h-3 w-3 shrink-0 text-emerald-400"}),N&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-fg-5",children:N})]}),v?o.jsx("input",{ref:w,type:"text",value:C,onChange:F=>R(F.target.value),onBlur:K,onKeyDown:F=>{F.key==="Enter"&&K(),F.key==="Escape"&&S(!1)},onClick:F=>F.stopPropagation(),className:"mt-0.5 w-full rounded border border-blue-500 bg-base pl-3.5 text-sm text-fg-2 outline-none"}):o.jsxs("div",{className:"mt-0.5 pl-3.5",onDoubleClick:F=>{F.stopPropagation(),D()},children:[(x||b)&&o.jsxs("div",{className:"mb-0.5 flex flex-wrap gap-1",children:[x&&o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium leading-none",x.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",x.number]}),b==null?void 0:b.map(F=>o.jsx("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium leading-none",F.type==="pr"?F.state==="open"?"bg-blue-500/15 text-blue-400":F.mergedAt?"bg-purple-500/15 text-purple-400":"bg-red-500/15 text-red-400":F.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:F.type==="pr"?`PR#${F.number}`:`#${F.number}`},`${F.type}-${F.number}`))]}),o.jsx("span",{className:"block truncate text-sm text-fg-2",children:((Q=e.title)==null?void 0:Q.trim())||"未命名运行"}),y&&o.jsxs("span",{className:"mt-0.5 block truncate text-xs text-amber-400/80",children:["✏️ ",y]})]})]}),a?o.jsxs("span",{className:"absolute right-1.5 top-1.5 hidden items-center gap-1 rounded bg-surface/90 px-0.5 md:flex",children:[o.jsx("button",{type:"button",onClick:l,className:"rounded p-1 text-red-400 hover:bg-red-500/10",children:o.jsx(oa,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:d,className:"rounded p-1 text-fg-3 hover:bg-elevated",children:o.jsx(gt,{className:"h-3.5 w-3.5"})})]}):o.jsxs("span",{className:"absolute right-1.5 top-1.5 hidden items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 md:flex",children:[o.jsx("button",{type:"button",onClick:m,title:T?"取消完成":"标记完成",className:oe("rounded p-1",T?"text-emerald-400 hover:text-emerald-300":"text-fg-5 hover:text-emerald-400"),children:o.jsx(dm,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:D,title:"重命名",className:"rounded p-1 text-fg-5 hover:text-fg-2",children:o.jsx(sx,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:()=>{var F;B1(JSON.stringify({id:e.id,name:((F=e.title)==null?void 0:F.trim())||""},null,2))},title:"复制 Session JSON",className:"rounded p-1 text-fg-5 hover:text-fg-2",children:o.jsx(hc,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:u,className:"rounded p-1 text-fg-5 hover:text-red-400",children:o.jsx(zs,{className:"h-3.5 w-3.5"})})]})]})]})}function U1({onClose:e}){const[t,a]=A.useState(null),s=Ie(R=>R.sessions),l=Ie(R=>R.activeSessionId),u=Ie(R=>R.sessionStatuses),d=Ie(R=>R.sessionFilter),f=Ie(R=>R.setSessionFilter),m=Ie(R=>R.setActiveSession),h=Ie(R=>R.deleteSession),x=Ie(R=>R.renameSession),b=Ie(R=>R.toggleSessionComplete),y=Fe(R=>R.activeRepoId),T=Ge(R=>R.issues),N=Ie(R=>R.allSessionLinks),v=[...s].filter(R=>R.parentID?!1:d==="active"?!R.completedAt:d==="completed"?!!R.completedAt:!0).sort((R,w)=>fh(w)-fh(R)),S=new Map(T.map(R=>[R.id,R])),C=R=>o.jsx("ul",{className:"space-y-0.5",children:R.map(w=>{const D=w.issueId?S.get(w.issueId):void 0,K=N[w.id],L=[];if(K){for(const M of K.issues)L.push({number:M.number,state:M.state,type:"issue"});for(const M of K.pullRequests)L.push({number:M.number,state:M.state,type:"pr",mergedAt:M.mergedAt})}return o.jsx(yD,{session:w,isActive:w.id===l,isConfirming:t===w.id,status:u[w.id],issue:D?{number:D.number,title:D.title,state:D.state}:void 0,linkedItems:L.length>0?L:void 0,onSelect:()=>{m(w.id),e==null||e()},onDelete:()=>{h(w.id),a(null)},onConfirm:()=>a(w.id),onCancelConfirm:()=>a(null),onRename:M=>void x(w.id,M),onToggleComplete:()=>void b(w.id)},w.id)})});return o.jsx("div",{className:"flex h-full w-80 shrink-0 flex-col border-r border-line bg-surface",children:o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-line px-3 py-3",children:[o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-fg-3",children:"运行记录"}),y&&o.jsx("button",{type:"button",onClick:()=>{Ie.setState({activeSessionId:null}),e==null||e()},title:"新建运行",className:"flex h-7 w-7 items-center justify-center rounded-md bg-blue-600 text-white transition-colors hover:bg-blue-500",children:o.jsx(Xa,{className:"h-4 w-4"})})]}),y&&o.jsx("div",{className:"flex gap-1 border-b border-line px-3 py-1.5",children:[["all","全部"],["active","进行中"],["completed","已完成"]].map(([R,w])=>o.jsx("button",{type:"button",onClick:()=>f(R),className:oe("rounded-md px-2 py-0.5 font-mono text-[11px] transition-colors",d===R?"bg-elevated text-fg-2":"text-fg-5 hover:text-fg-3"),children:w},R))}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:y?v.length===0?o.jsx("p",{className:"px-2 py-6 text-center font-mono text-xs text-fg-5",children:"暂无运行记录"}):o.jsx("div",{children:C(v)}):o.jsx("p",{className:"px-2 py-6 text-center font-mono text-xs text-fg-5",children:"请先选择一个仓库"})})]})})}function TD(){const[e,t]=A.useState(()=>typeof window<"u"&&window.matchMedia("(min-width: 1280px)").matches);return A.useEffect(()=>{const a=window.matchMedia("(min-width: 1280px)"),s=l=>t(l.matches);return a.addEventListener("change",s),()=>a.removeEventListener("change",s)},[]),e}function H1(e){const t=document.querySelector(`[data-message-id="${e}"]`);t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),t.classList.add("fs-highlight"),setTimeout(()=>t.classList.remove("fs-highlight"),2e3))}function _D(){const[e,t]=A.useState(!1),[a,s]=A.useState(!1),[l,u]=A.useState(!1),d=TD(),f=Ie(S=>S.activeSessionId),m=Ec(S=>S.sessionPanelCollapsed),h=Ec(S=>S.toggleSessionPanel),x=Ie(S=>{const C=S.activeSessionId;return C?S.todos[C]??_c:_c}),b=Ie(S=>{const C=S.activeSessionId;return C?S.messages[C]??go:go}),y=Ie(S=>{const C=S.activeSessionId;return C?S.sessionLinks[C]:void 0});A.useEffect(()=>{d&&f?u(!0):d||u(!1)},[d,f]);const T=l&&!!f,N=()=>{window.matchMedia("(max-width: 767px)").matches?s(S=>!S):u(S=>!S)},v=$T({onSwipeRight:()=>t(!0),onSwipeLeft:()=>s(!0),disabled:e||a});return o.jsxs("div",{className:"flex min-h-0 flex-1",...v,children:[o.jsxs("div",{className:"relative hidden shrink-0 md:flex",children:[o.jsx("div",{className:oe("overflow-hidden transition-[width] duration-200 ease-in-out",m?"w-0":"w-80"),children:o.jsx("div",{className:"h-full w-80",children:o.jsx(U1,{})})}),o.jsx("button",{type:"button",onClick:h,title:m?"展开运行记录":"收起运行记录",className:oe("absolute left-full top-1/2 z-20 flex h-14 w-4 -translate-y-1/2 items-center justify-center rounded-r-md border-y border-r border-line text-fg-5 transition-all duration-200 hover:bg-elevated hover:text-fg-3",m?"bg-surface opacity-80 hover:w-5 hover:opacity-100":"bg-surface/80 opacity-40 hover:opacity-100"),children:m?o.jsx(Ih,{className:"h-3 w-3"}):o.jsx(Oh,{className:"h-3 w-3"})})]}),o.jsx(dh,{side:"left",open:e,onClose:()=>t(!1),children:o.jsx(U1,{onClose:()=>t(!1)})}),o.jsx(dh,{side:"right",open:a,onClose:()=>s(!1),children:o.jsx(L1,{todos:x,messages:b,sessionLinks:y,sessionId:f,onScrollToMessage:S=>{s(!1),setTimeout(()=>H1(S),300)}})}),o.jsx("div",{className:"flex min-w-0 flex-1 flex-col",children:o.jsx(sD,{onToggleSidebar:()=>t(S=>!S),onToggleRightPanel:N,rightPanelOpen:T})}),T&&o.jsx("div",{className:"hidden shrink-0 md:flex",children:o.jsx(L1,{todos:x,messages:b,sessionLinks:y,sessionId:f,onScrollToMessage:H1})})]})}const F1=/[#.]/g;function ND(e,t){const a=e||"",s={};let l=0,u,d;for(;l<a.length;){F1.lastIndex=l;const f=F1.exec(a),m=a.slice(l,f?f.index:a.length);m&&(u?u==="#"?s.id=m:Array.isArray(s.className)?s.className.push(m):s.className=[m]:d=m,l+=m.length),f&&(u=f[0],l++)}return{type:"element",tagName:d||t||"div",properties:s,children:[]}}function GT(e,t,a){const s=a?CD(a):void 0;function l(u,d,...f){let m;if(u==null){m={type:"root",children:[]};const h=d;f.unshift(h)}else{m=ND(u,t);const h=m.tagName.toLowerCase(),x=s?s.get(h):void 0;if(m.tagName=x||h,SD(d))f.unshift(d);else for(const[b,y]of Object.entries(d))vD(e,m.properties,b,y)}for(const h of f)mh(m.children,h);return m.type==="element"&&m.tagName==="template"&&(m.content={type:"root",children:m.children},m.children=[]),m}return l}function SD(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,a=Object.keys(e);for(const s of a){const l=t[s];if(l&&typeof l=="object"){if(!Array.isArray(l))return!0;const u=l;for(const d of u)if(typeof d!="number"&&typeof d!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function vD(e,t,a,s){const l=qc(e,a);let u;if(s!=null){if(typeof s=="number"){if(Number.isNaN(s))return;u=s}else typeof s=="boolean"?u=s:typeof s=="string"?l.spaceSeparated?u=Rx(s):l.commaSeparated?u=vx(s):l.commaOrSpaceSeparated?u=Rx(vx(s).join(" ")):u=z1(l,l.property,s):Array.isArray(s)?u=[...s]:u=l.property==="style"?AD(s):String(s);if(Array.isArray(u)){const d=[];for(const f of u)d.push(z1(l,l.property,f));u=d}l.property==="className"&&Array.isArray(t.className)&&(u=t.className.concat(u)),t[l.property]=u}}function mh(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 a of t)mh(e,a);else if(typeof t=="object"&&"type"in t)t.type==="root"?mh(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function z1(e,t,a){if(typeof a=="string"){if(e.number&&a&&!Number.isNaN(Number(a)))return Number(a);if((e.boolean||e.overloadedBoolean)&&(a===""||bo(a)===bo(t)))return!0}return a}function AD(e){const t=[];for(const[a,s]of Object.entries(e))t.push([a,s].join(": "));return t.join("; ")}function CD(e){const t=new Map;for(const a of e)t.set(a.toLowerCase(),a);return t}const wD=["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"],kD=GT(So,"div"),RD=GT(ds,"g",wD);function OD(e){const t=String(e),a=[];return{toOffset:l,toPoint:s};function s(u){if(typeof u=="number"&&u>-1&&u<=t.length){let d=0;for(;;){let f=a[d];if(f===void 0){const m=q1(t,a[d-1]);f=m===-1?t.length+1:m+1,a[d]=f}if(f>u)return{line:d+1,column:u-(d>0?a[d-1]:0)+1,offset:u};d++}}}function l(u){if(u&&typeof u.line=="number"&&typeof u.column=="number"&&!Number.isNaN(u.line)&&!Number.isNaN(u.column)){for(;a.length<u.line;){const f=a[a.length-1],m=q1(t,f),h=m===-1?t.length+1:m+1;if(f===h)break;a.push(h)}const d=(u.line>1?a[u.line-2]:0)+u.column-1;if(d<a[u.line-1])return d}}}function q1(e,t){const a=e.indexOf("\r",t),s=e.indexOf(`
470
470
  `,t);return s===-1?a:a===-1||a+1===s?s:a<s?a:s}const Ps={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/"},KT={}.hasOwnProperty,ID=Object.prototype;function MD(e,t){const a=t||{};return r0({file:a.file||void 0,location:!1,schema:a.space==="svg"?ds:So,verbose:a.verbose||!1},e)}function r0(e,t){let a;switch(t.nodeName){case"#comment":{const s=t;return a={type:"comment",value:s.data},cc(e,s,a),a}case"#document":case"#document-fragment":{const s=t,l="mode"in s?s.mode==="quirks"||s.mode==="limited-quirks":!1;if(a={type:"root",children:VT(e,t.childNodes),data:{quirksMode:l}},e.file&&e.location){const u=String(e.file),d=OD(u),f=d.toPoint(0),m=d.toPoint(u.length);a.position={start:f,end:m}}return a}case"#documentType":{const s=t;return a={type:"doctype"},cc(e,s,a),a}case"#text":{const s=t;return a={type:"text",value:s.value},cc(e,s,a),a}default:return a=DD(e,t),a}}function VT(e,t){let a=-1;const s=[];for(;++a<t.length;){const l=r0(e,t[a]);s.push(l)}return s}function DD(e,t){const a=e.schema;e.schema=t.namespaceURI===Ps.svg?ds:So;let s=-1;const l={};for(;++s<t.attrs.length;){const f=t.attrs[s],m=(f.prefix?f.prefix+":":"")+f.name;KT.call(ID,m)||(l[m]=f.value)}const d=(e.schema.space==="svg"?RD:kD)(t.tagName,l,VT(e,t.childNodes));if(cc(e,t,d),d.tagName==="template"){const f=t,m=f.sourceCodeLocation,h=m&&m.startTag&&Bi(m.startTag),x=m&&m.endTag&&Bi(m.endTag),b=r0(e,f.content);h&&x&&e.file&&(b.position={start:h.end,end:x.start}),d.content=b}return e.schema=a,d}function cc(e,t,a){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const s=LD(e,a,t.sourceCodeLocation);s&&(e.location=!0,a.position=s)}}function LD(e,t,a){const s=Bi(a);if(t.type==="element"){const l=t.children[t.children.length-1];if(s&&!a.endTag&&l&&l.position&&l.position.end&&(s.end=Object.assign({},l.position.end)),e.verbose){const u={};let d;if(a.attrs)for(d in a.attrs)KT.call(a.attrs,d)&&(u[qc(e.schema,d).property]=Bi(a.attrs[d]));a.startTag;const f=Bi(a.startTag),m=a.endTag?Bi(a.endTag):void 0,h={opening:f};m&&(h.closing=m),h.properties=u,t.data={position:h}}}return s}function Bi(e){const t=Y1({line:e.startLine,column:e.startCol,offset:e.startOffset}),a=Y1({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||a?{start:t,end:a}:void 0}function Y1(e){return e.line&&e.column?e:void 0}const jD={},BD={}.hasOwnProperty,QT=nT("type",{handlers:{root:UD,element:YD,text:zD,comment:qD,doctype:FD}});function PD(e,t){const s=(t||jD).space;return QT(e,s==="svg"?ds:So)}function UD(e,t){const a={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return a.childNodes=s0(e.children,a,t),Vi(e,a),a}function HD(e,t){const a={nodeName:"#document-fragment",childNodes:[]};return a.childNodes=s0(e.children,a,t),Vi(e,a),a}function FD(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return Vi(e,t),t}function zD(e){const t={nodeName:"#text",value:e.value,parentNode:null};return Vi(e,t),t}function qD(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return Vi(e,t),t}function YD(e,t){const a=t;let s=a;e.type==="element"&&e.tagName.toLowerCase()==="svg"&&a.space==="html"&&(s=ds);const l=[];let u;if(e.properties){for(u in e.properties)if(u!=="children"&&BD.call(e.properties,u)){const m=$D(s,u,e.properties[u]);m&&l.push(m)}}const d=s.space,f={nodeName:e.tagName,tagName:e.tagName,attrs:l,namespaceURI:Ps[d],childNodes:[],parentNode:null};return f.childNodes=s0(e.children,f,s),Vi(e,f),e.tagName==="template"&&e.content&&(f.content=HD(e.content,s)),f}function $D(e,t,a){const s=qc(e,t);if(a===!1||a===null||a===void 0||typeof a=="number"&&Number.isNaN(a)||!a&&s.boolean)return;Array.isArray(a)&&(a=s.commaSeparated?py(a):Ny(a));const l={name:s.attribute,value:a===!0?"":String(a)};if(s.space&&s.space!=="html"&&s.space!=="svg"){const u=l.name.indexOf(":");u<0?l.prefix="":(l.name=l.name.slice(u+1),l.prefix=s.attribute.slice(0,u)),l.namespace=Ps[s.space]}return l}function s0(e,t,a){let s=-1;const l=[];if(e)for(;++s<e.length;){const u=QT(e[s],a);u.parentNode=t,l.push(u)}return l}function Vi(e,t){const a=e.position;a&&a.start&&a.end&&(a.start.offset,a.end.offset,t.sourceCodeLocation={startLine:a.start.line,startCol:a.start.column,startOffset:a.start.offset,endLine:a.end.line,endCol:a.end.column,endOffset:a.end.offset})}const GD=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],KD=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]),Pt="�";var O;(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"})(O||(O={}));const Gn={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function XT(e){return e>=55296&&e<=57343}function VD(e){return e>=56320&&e<=57343}function QD(e,t){return(e-55296)*1024+9216+t}function WT(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function ZT(e){return e>=64976&&e<=65007||KD.has(e)}var ue;(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"})(ue||(ue={}));const XD=65536;class WD{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=XD,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,a){const{line:s,col:l,offset:u}=this,d=l+a,f=u+a;return{code:t,startLine:s,endLine:s,startCol:d,endCol:d,startOffset:f,endOffset:f}}_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 a=this.html.charCodeAt(this.pos+1);if(VD(a))return this.pos++,this._addGap(),QD(t,a)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,O.EOF;return this._err(ue.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,a){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=a}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,a){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(a)return this.html.startsWith(t,this.pos);for(let s=0;s<t.length;s++)if((this.html.charCodeAt(this.pos+s)|32)!==t.charCodeAt(s))return!1;return!0}peek(t){const a=this.pos+t;if(a>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,O.EOF;const s=this.html.charCodeAt(a);return s===O.CARRIAGE_RETURN?O.LINE_FEED:s}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,O.EOF;let t=this.html.charCodeAt(this.pos);return t===O.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,O.LINE_FEED):t===O.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,XT(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===O.LINE_FEED||t===O.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){WT(t)?this._err(ue.controlCharacterInInputStream):ZT(t)&&this._err(ue.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var tt;(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"})(tt||(tt={}));function JT(e,t){for(let a=e.attrs.length-1;a>=0;a--)if(e.attrs[a].name===t)return e.attrs[a].value;return null}const ZD=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),JD=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 eL(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=JD.get(e))!==null&&t!==void 0?t:e}var mn;(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"})(mn||(mn={}));const tL=32;var ls;(function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"})(ls||(ls={}));function hh(e){return e>=mn.ZERO&&e<=mn.NINE}function nL(e){return e>=mn.UPPER_A&&e<=mn.UPPER_F||e>=mn.LOWER_A&&e<=mn.LOWER_F}function aL(e){return e>=mn.UPPER_A&&e<=mn.UPPER_Z||e>=mn.LOWER_A&&e<=mn.LOWER_Z||hh(e)}function rL(e){return e===mn.EQUALS||aL(e)}var fn;(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"})(fn||(fn={}));var vr;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(vr||(vr={}));class sL{constructor(t,a,s){this.decodeTree=t,this.emitCodePoint=a,this.errors=s,this.state=fn.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=vr.Strict}startEntity(t){this.decodeMode=t,this.state=fn.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(t,a){switch(this.state){case fn.EntityStart:return t.charCodeAt(a)===mn.NUM?(this.state=fn.NumericStart,this.consumed+=1,this.stateNumericStart(t,a+1)):(this.state=fn.NamedEntity,this.stateNamedEntity(t,a));case fn.NumericStart:return this.stateNumericStart(t,a);case fn.NumericDecimal:return this.stateNumericDecimal(t,a);case fn.NumericHex:return this.stateNumericHex(t,a);case fn.NamedEntity:return this.stateNamedEntity(t,a)}}stateNumericStart(t,a){return a>=t.length?-1:(t.charCodeAt(a)|tL)===mn.LOWER_X?(this.state=fn.NumericHex,this.consumed+=1,this.stateNumericHex(t,a+1)):(this.state=fn.NumericDecimal,this.stateNumericDecimal(t,a))}addToNumericResult(t,a,s,l){if(a!==s){const u=s-a;this.result=this.result*Math.pow(l,u)+Number.parseInt(t.substr(a,u),l),this.consumed+=u}}stateNumericHex(t,a){const s=a;for(;a<t.length;){const l=t.charCodeAt(a);if(hh(l)||nL(l))a+=1;else return this.addToNumericResult(t,s,a,16),this.emitNumericEntity(l,3)}return this.addToNumericResult(t,s,a,16),-1}stateNumericDecimal(t,a){const s=a;for(;a<t.length;){const l=t.charCodeAt(a);if(hh(l))a+=1;else return this.addToNumericResult(t,s,a,10),this.emitNumericEntity(l,2)}return this.addToNumericResult(t,s,a,10),-1}emitNumericEntity(t,a){var s;if(this.consumed<=a)return(s=this.errors)===null||s===void 0||s.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(t===mn.SEMI)this.consumed+=1;else if(this.decodeMode===vr.Strict)return 0;return this.emitCodePoint(eL(this.result),this.consumed),this.errors&&(t!==mn.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(t,a){const{decodeTree:s}=this;let l=s[this.treeIndex],u=(l&ls.VALUE_LENGTH)>>14;for(;a<t.length;a++,this.excess++){const d=t.charCodeAt(a);if(this.treeIndex=iL(s,l,this.treeIndex+Math.max(1,u),d),this.treeIndex<0)return this.result===0||this.decodeMode===vr.Attribute&&(u===0||rL(d))?0:this.emitNotTerminatedNamedEntity();if(l=s[this.treeIndex],u=(l&ls.VALUE_LENGTH)>>14,u!==0){if(d===mn.SEMI)return this.emitNamedEntityData(this.treeIndex,u,this.consumed+this.excess);this.decodeMode!==vr.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var t;const{result:a,decodeTree:s}=this,l=(s[a]&ls.VALUE_LENGTH)>>14;return this.emitNamedEntityData(a,l,this.consumed),(t=this.errors)===null||t===void 0||t.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(t,a,s){const{decodeTree:l}=this;return this.emitCodePoint(a===1?l[t]&~ls.VALUE_LENGTH:l[t+1],s),a===3&&this.emitCodePoint(l[t+2],s),s}end(){var t;switch(this.state){case fn.NamedEntity:return this.result!==0&&(this.decodeMode!==vr.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case fn.NumericDecimal:return this.emitNumericEntity(0,2);case fn.NumericHex:return this.emitNumericEntity(0,3);case fn.NumericStart:return(t=this.errors)===null||t===void 0||t.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case fn.EntityStart:return 0}}}function iL(e,t,a,s){const l=(t&ls.BRANCH_LENGTH)>>7,u=t&ls.JUMP_TABLE;if(l===0)return u!==0&&s===u?a:-1;if(u){const m=s-u;return m<0||m>=l?-1:e[a+m]-1}let d=a,f=d+l-1;for(;d<=f;){const m=d+f>>>1,h=e[m];if(h<s)d=m+1;else if(h>s)f=m-1;else return e[m+l]}return-1}var ge;(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/"})(ge||(ge={}));var Hs;(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"})(Hs||(Hs={}));var Na;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(Na||(Na={}));var Z;(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"})(Z||(Z={}));var E;(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"})(E||(E={}));const lL=new Map([[Z.A,E.A],[Z.ADDRESS,E.ADDRESS],[Z.ANNOTATION_XML,E.ANNOTATION_XML],[Z.APPLET,E.APPLET],[Z.AREA,E.AREA],[Z.ARTICLE,E.ARTICLE],[Z.ASIDE,E.ASIDE],[Z.B,E.B],[Z.BASE,E.BASE],[Z.BASEFONT,E.BASEFONT],[Z.BGSOUND,E.BGSOUND],[Z.BIG,E.BIG],[Z.BLOCKQUOTE,E.BLOCKQUOTE],[Z.BODY,E.BODY],[Z.BR,E.BR],[Z.BUTTON,E.BUTTON],[Z.CAPTION,E.CAPTION],[Z.CENTER,E.CENTER],[Z.CODE,E.CODE],[Z.COL,E.COL],[Z.COLGROUP,E.COLGROUP],[Z.DD,E.DD],[Z.DESC,E.DESC],[Z.DETAILS,E.DETAILS],[Z.DIALOG,E.DIALOG],[Z.DIR,E.DIR],[Z.DIV,E.DIV],[Z.DL,E.DL],[Z.DT,E.DT],[Z.EM,E.EM],[Z.EMBED,E.EMBED],[Z.FIELDSET,E.FIELDSET],[Z.FIGCAPTION,E.FIGCAPTION],[Z.FIGURE,E.FIGURE],[Z.FONT,E.FONT],[Z.FOOTER,E.FOOTER],[Z.FOREIGN_OBJECT,E.FOREIGN_OBJECT],[Z.FORM,E.FORM],[Z.FRAME,E.FRAME],[Z.FRAMESET,E.FRAMESET],[Z.H1,E.H1],[Z.H2,E.H2],[Z.H3,E.H3],[Z.H4,E.H4],[Z.H5,E.H5],[Z.H6,E.H6],[Z.HEAD,E.HEAD],[Z.HEADER,E.HEADER],[Z.HGROUP,E.HGROUP],[Z.HR,E.HR],[Z.HTML,E.HTML],[Z.I,E.I],[Z.IMG,E.IMG],[Z.IMAGE,E.IMAGE],[Z.INPUT,E.INPUT],[Z.IFRAME,E.IFRAME],[Z.KEYGEN,E.KEYGEN],[Z.LABEL,E.LABEL],[Z.LI,E.LI],[Z.LINK,E.LINK],[Z.LISTING,E.LISTING],[Z.MAIN,E.MAIN],[Z.MALIGNMARK,E.MALIGNMARK],[Z.MARQUEE,E.MARQUEE],[Z.MATH,E.MATH],[Z.MENU,E.MENU],[Z.META,E.META],[Z.MGLYPH,E.MGLYPH],[Z.MI,E.MI],[Z.MO,E.MO],[Z.MN,E.MN],[Z.MS,E.MS],[Z.MTEXT,E.MTEXT],[Z.NAV,E.NAV],[Z.NOBR,E.NOBR],[Z.NOFRAMES,E.NOFRAMES],[Z.NOEMBED,E.NOEMBED],[Z.NOSCRIPT,E.NOSCRIPT],[Z.OBJECT,E.OBJECT],[Z.OL,E.OL],[Z.OPTGROUP,E.OPTGROUP],[Z.OPTION,E.OPTION],[Z.P,E.P],[Z.PARAM,E.PARAM],[Z.PLAINTEXT,E.PLAINTEXT],[Z.PRE,E.PRE],[Z.RB,E.RB],[Z.RP,E.RP],[Z.RT,E.RT],[Z.RTC,E.RTC],[Z.RUBY,E.RUBY],[Z.S,E.S],[Z.SCRIPT,E.SCRIPT],[Z.SEARCH,E.SEARCH],[Z.SECTION,E.SECTION],[Z.SELECT,E.SELECT],[Z.SOURCE,E.SOURCE],[Z.SMALL,E.SMALL],[Z.SPAN,E.SPAN],[Z.STRIKE,E.STRIKE],[Z.STRONG,E.STRONG],[Z.STYLE,E.STYLE],[Z.SUB,E.SUB],[Z.SUMMARY,E.SUMMARY],[Z.SUP,E.SUP],[Z.TABLE,E.TABLE],[Z.TBODY,E.TBODY],[Z.TEMPLATE,E.TEMPLATE],[Z.TEXTAREA,E.TEXTAREA],[Z.TFOOT,E.TFOOT],[Z.TD,E.TD],[Z.TH,E.TH],[Z.THEAD,E.THEAD],[Z.TITLE,E.TITLE],[Z.TR,E.TR],[Z.TRACK,E.TRACK],[Z.TT,E.TT],[Z.U,E.U],[Z.UL,E.UL],[Z.SVG,E.SVG],[Z.VAR,E.VAR],[Z.WBR,E.WBR],[Z.XMP,E.XMP]]);function Qi(e){var t;return(t=lL.get(e))!==null&&t!==void 0?t:E.UNKNOWN}const be=E,oL={[ge.HTML]:new Set([be.ADDRESS,be.APPLET,be.AREA,be.ARTICLE,be.ASIDE,be.BASE,be.BASEFONT,be.BGSOUND,be.BLOCKQUOTE,be.BODY,be.BR,be.BUTTON,be.CAPTION,be.CENTER,be.COL,be.COLGROUP,be.DD,be.DETAILS,be.DIR,be.DIV,be.DL,be.DT,be.EMBED,be.FIELDSET,be.FIGCAPTION,be.FIGURE,be.FOOTER,be.FORM,be.FRAME,be.FRAMESET,be.H1,be.H2,be.H3,be.H4,be.H5,be.H6,be.HEAD,be.HEADER,be.HGROUP,be.HR,be.HTML,be.IFRAME,be.IMG,be.INPUT,be.LI,be.LINK,be.LISTING,be.MAIN,be.MARQUEE,be.MENU,be.META,be.NAV,be.NOEMBED,be.NOFRAMES,be.NOSCRIPT,be.OBJECT,be.OL,be.P,be.PARAM,be.PLAINTEXT,be.PRE,be.SCRIPT,be.SECTION,be.SELECT,be.SOURCE,be.STYLE,be.SUMMARY,be.TABLE,be.TBODY,be.TD,be.TEMPLATE,be.TEXTAREA,be.TFOOT,be.TH,be.THEAD,be.TITLE,be.TR,be.TRACK,be.UL,be.WBR,be.XMP]),[ge.MATHML]:new Set([be.MI,be.MO,be.MN,be.MS,be.MTEXT,be.ANNOTATION_XML]),[ge.SVG]:new Set([be.TITLE,be.FOREIGN_OBJECT,be.DESC]),[ge.XLINK]:new Set,[ge.XML]:new Set,[ge.XMLNS]:new Set},ph=new Set([be.H1,be.H2,be.H3,be.H4,be.H5,be.H6]);Z.STYLE,Z.SCRIPT,Z.XMP,Z.IFRAME,Z.NOEMBED,Z.NOFRAMES,Z.PLAINTEXT;var B;(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"})(B||(B={}));const Xt={DATA:B.DATA,RCDATA:B.RCDATA,RAWTEXT:B.RAWTEXT,SCRIPT_DATA:B.SCRIPT_DATA,PLAINTEXT:B.PLAINTEXT,CDATA_SECTION:B.CDATA_SECTION};function uL(e){return e>=O.DIGIT_0&&e<=O.DIGIT_9}function to(e){return e>=O.LATIN_CAPITAL_A&&e<=O.LATIN_CAPITAL_Z}function cL(e){return e>=O.LATIN_SMALL_A&&e<=O.LATIN_SMALL_Z}function ss(e){return cL(e)||to(e)}function $1(e){return ss(e)||uL(e)}function rc(e){return e+32}function e_(e){return e===O.SPACE||e===O.LINE_FEED||e===O.TABULATION||e===O.FORM_FEED}function G1(e){return e_(e)||e===O.SOLIDUS||e===O.GREATER_THAN_SIGN}function dL(e){return e===O.NULL?ue.nullCharacterReference:e>1114111?ue.characterReferenceOutsideUnicodeRange:XT(e)?ue.surrogateCharacterReference:ZT(e)?ue.noncharacterCharacterReference:WT(e)||e===O.CARRIAGE_RETURN?ue.controlCharacterReference:null}class fL{constructor(t,a){this.options=t,this.handler=a,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=B.DATA,this.returnState=B.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new WD(a),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new sL(ZD,(s,l)=>{this.preprocessor.pos=this.entityStartPos+l-1,this._flushCodePointConsumedAsCharacterReference(s)},a.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(ue.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:s=>{this._err(ue.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+s)},validateNumericCharacterReference:s=>{const l=dL(s);l&&this._err(l,1)}}:void 0)}_err(t,a=0){var s,l;(l=(s=this.handler).onParseError)===null||l===void 0||l.call(s,this.preprocessor.getError(t,a))}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==null||t())}write(t,a,s){this.active=!0,this.preprocessor.write(t,a),this._runParsingLoop(),this.paused||s==null||s()}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 a=0;a<t;a++)this.preprocessor.advance()}_consumeSequenceIfMatch(t,a){return this.preprocessor.startsWith(t,a)?(this._advanceBy(t.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:tt.START_TAG,tagName:"",tagID:E.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:tt.END_TAG,tagName:"",tagID:E.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:tt.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:tt.DOCTYPE,name:t,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(t,a){this.currentCharacterToken={type:t,chars:a,location:this.currentLocation}}_createAttr(t){this.currentAttr={name:t,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var t,a;const s=this.currentToken;if(JT(s,this.currentAttr.name)===null){if(s.attrs.push(this.currentAttr),s.location&&this.currentLocation){const l=(t=(a=s.location).attrs)!==null&&t!==void 0?t:a.attrs=Object.create(null);l[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(ue.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=Qi(t.tagName),t.type===tt.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(ue.endTagWithAttributes),t.selfClosing&&this._err(ue.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 tt.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case tt.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case tt.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:tt.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,a){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=a;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,a)}_emitCodePoint(t){const a=e_(t)?tt.WHITESPACE_CHARACTER:t===O.NULL?tt.NULL_CHARACTER:tt.CHARACTER;this._appendCharToCurrentCharacterToken(a,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken(tt.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=B.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?vr.Attribute:vr.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===B.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===B.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===B.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case B.DATA:{this._stateData(t);break}case B.RCDATA:{this._stateRcdata(t);break}case B.RAWTEXT:{this._stateRawtext(t);break}case B.SCRIPT_DATA:{this._stateScriptData(t);break}case B.PLAINTEXT:{this._statePlaintext(t);break}case B.TAG_OPEN:{this._stateTagOpen(t);break}case B.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case B.TAG_NAME:{this._stateTagName(t);break}case B.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case B.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case B.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case B.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case B.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case B.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case B.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case B.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case B.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case B.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case B.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case B.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case B.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case B.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case B.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case B.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case B.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case B.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case B.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case B.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case B.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case B.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case B.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case B.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case B.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case B.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case B.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case B.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case B.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case B.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case B.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case B.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case B.BOGUS_COMMENT:{this._stateBogusComment(t);break}case B.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case B.COMMENT_START:{this._stateCommentStart(t);break}case B.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case B.COMMENT:{this._stateComment(t);break}case B.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case B.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case B.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case B.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case B.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case B.COMMENT_END:{this._stateCommentEnd(t);break}case B.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case B.DOCTYPE:{this._stateDoctype(t);break}case B.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case B.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case B.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case B.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case B.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case B.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case B.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case B.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case B.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case B.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case B.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case B.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case B.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case B.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case B.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case B.CDATA_SECTION:{this._stateCdataSection(t);break}case B.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case B.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case B.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case B.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case O.LESS_THAN_SIGN:{this.state=B.TAG_OPEN;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this._emitCodePoint(t);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case O.AMPERSAND:{this._startCharacterReference();break}case O.LESS_THAN_SIGN:{this.state=B.RCDATA_LESS_THAN_SIGN;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this._emitChars(Pt);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case O.LESS_THAN_SIGN:{this.state=B.RAWTEXT_LESS_THAN_SIGN;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this._emitChars(Pt);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case O.LESS_THAN_SIGN:{this.state=B.SCRIPT_DATA_LESS_THAN_SIGN;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this._emitChars(Pt);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case O.NULL:{this._err(ue.unexpectedNullCharacter),this._emitChars(Pt);break}case O.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(ss(t))this._createStartTagToken(),this.state=B.TAG_NAME,this._stateTagName(t);else switch(t){case O.EXCLAMATION_MARK:{this.state=B.MARKUP_DECLARATION_OPEN;break}case O.SOLIDUS:{this.state=B.END_TAG_OPEN;break}case O.QUESTION_MARK:{this._err(ue.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=B.BOGUS_COMMENT,this._stateBogusComment(t);break}case O.EOF:{this._err(ue.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(ue.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=B.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(ss(t))this._createEndTagToken(),this.state=B.TAG_NAME,this._stateTagName(t);else switch(t){case O.GREATER_THAN_SIGN:{this._err(ue.missingEndTagName),this.state=B.DATA;break}case O.EOF:{this._err(ue.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(ue.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=B.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=B.BEFORE_ATTRIBUTE_NAME;break}case O.SOLIDUS:{this.state=B.SELF_CLOSING_START_TAG;break}case O.GREATER_THAN_SIGN:{this.state=B.DATA,this.emitCurrentTagToken();break}case O.NULL:{this._err(ue.unexpectedNullCharacter),a.tagName+=Pt;break}case O.EOF:{this._err(ue.eofInTag),this._emitEOFToken();break}default:a.tagName+=String.fromCodePoint(to(t)?rc(t):t)}}_stateRcdataLessThanSign(t){t===O.SOLIDUS?this.state=B.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=B.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){ss(t)?(this.state=B.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=B.RCDATA,this._stateRcdata(t))}handleSpecialEndTag(t){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const a=this.currentToken;switch(a.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=B.BEFORE_ATTRIBUTE_NAME,!1;case O.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=B.SELF_CLOSING_START_TAG,!1;case O.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=B.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=B.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===O.SOLIDUS?this.state=B.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=B.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){ss(t)?(this.state=B.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=B.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=B.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case O.SOLIDUS:{this.state=B.SCRIPT_DATA_END_TAG_OPEN;break}case O.EXCLAMATION_MARK:{this.state=B.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=B.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){ss(t)?(this.state=B.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=B.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=B.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===O.HYPHEN_MINUS?(this.state=B.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=B.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===O.HYPHEN_MINUS?(this.state=B.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=B.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case O.HYPHEN_MINUS:{this.state=B.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=B.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this._emitChars(Pt);break}case O.EOF:{this._err(ue.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case O.HYPHEN_MINUS:{this.state=B.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=B.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this.state=B.SCRIPT_DATA_ESCAPED,this._emitChars(Pt);break}case O.EOF:{this._err(ue.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=B.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case O.HYPHEN_MINUS:{this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=B.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case O.GREATER_THAN_SIGN:{this.state=B.SCRIPT_DATA,this._emitChars(">");break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this.state=B.SCRIPT_DATA_ESCAPED,this._emitChars(Pt);break}case O.EOF:{this._err(ue.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=B.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===O.SOLIDUS?this.state=B.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:ss(t)?(this._emitChars("<"),this.state=B.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=B.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){ss(t)?(this.state=B.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=B.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=B.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Gn.SCRIPT,!1)&&G1(this.preprocessor.peek(Gn.SCRIPT.length))){this._emitCodePoint(t);for(let a=0;a<Gn.SCRIPT.length;a++)this._emitCodePoint(this._consume());this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=B.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case O.HYPHEN_MINUS:{this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this._emitChars(Pt);break}case O.EOF:{this._err(ue.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case O.HYPHEN_MINUS:{this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Pt);break}case O.EOF:{this._err(ue.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case O.HYPHEN_MINUS:{this._emitChars("-");break}case O.LESS_THAN_SIGN:{this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case O.GREATER_THAN_SIGN:{this.state=B.SCRIPT_DATA,this._emitChars(">");break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Pt);break}case O.EOF:{this._err(ue.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===O.SOLIDUS?(this.state=B.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Gn.SCRIPT,!1)&&G1(this.preprocessor.peek(Gn.SCRIPT.length))){this._emitCodePoint(t);for(let a=0;a<Gn.SCRIPT.length;a++)this._emitCodePoint(this._consume());this.state=B.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=B.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.SOLIDUS:case O.GREATER_THAN_SIGN:case O.EOF:{this.state=B.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case O.EQUALS_SIGN:{this._err(ue.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=B.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=B.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:case O.SOLIDUS:case O.GREATER_THAN_SIGN:case O.EOF:{this._leaveAttrName(),this.state=B.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case O.EQUALS_SIGN:{this._leaveAttrName(),this.state=B.BEFORE_ATTRIBUTE_VALUE;break}case O.QUOTATION_MARK:case O.APOSTROPHE:case O.LESS_THAN_SIGN:{this._err(ue.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this.currentAttr.name+=Pt;break}default:this.currentAttr.name+=String.fromCodePoint(to(t)?rc(t):t)}}_stateAfterAttributeName(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.SOLIDUS:{this.state=B.SELF_CLOSING_START_TAG;break}case O.EQUALS_SIGN:{this.state=B.BEFORE_ATTRIBUTE_VALUE;break}case O.GREATER_THAN_SIGN:{this.state=B.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(ue.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=B.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{this.state=B.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this.state=B.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(ue.missingAttributeValue),this.state=B.DATA,this.emitCurrentTagToken();break}default:this.state=B.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case O.QUOTATION_MARK:{this.state=B.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this.currentAttr.value+=Pt;break}case O.EOF:{this._err(ue.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case O.APOSTROPHE:{this.state=B.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this.currentAttr.value+=Pt;break}case O.EOF:{this._err(ue.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this._leaveAttrValue(),this.state=B.BEFORE_ATTRIBUTE_NAME;break}case O.AMPERSAND:{this._startCharacterReference();break}case O.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=B.DATA,this.emitCurrentTagToken();break}case O.NULL:{this._err(ue.unexpectedNullCharacter),this.currentAttr.value+=Pt;break}case O.QUOTATION_MARK:case O.APOSTROPHE:case O.LESS_THAN_SIGN:case O.EQUALS_SIGN:case O.GRAVE_ACCENT:{this._err(ue.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case O.EOF:{this._err(ue.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this._leaveAttrValue(),this.state=B.BEFORE_ATTRIBUTE_NAME;break}case O.SOLIDUS:{this._leaveAttrValue(),this.state=B.SELF_CLOSING_START_TAG;break}case O.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=B.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(ue.eofInTag),this._emitEOFToken();break}default:this._err(ue.missingWhitespaceBetweenAttributes),this.state=B.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case O.GREATER_THAN_SIGN:{const a=this.currentToken;a.selfClosing=!0,this.state=B.DATA,this.emitCurrentTagToken();break}case O.EOF:{this._err(ue.eofInTag),this._emitEOFToken();break}default:this._err(ue.unexpectedSolidusInTag),this.state=B.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const a=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.state=B.DATA,this.emitCurrentComment(a);break}case O.EOF:{this.emitCurrentComment(a),this._emitEOFToken();break}case O.NULL:{this._err(ue.unexpectedNullCharacter),a.data+=Pt;break}default:a.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(Gn.DASH_DASH,!0)?(this._createCommentToken(Gn.DASH_DASH.length+1),this.state=B.COMMENT_START):this._consumeSequenceIfMatch(Gn.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Gn.DOCTYPE.length+1),this.state=B.DOCTYPE):this._consumeSequenceIfMatch(Gn.CDATA_START,!0)?this.inForeignNode?this.state=B.CDATA_SECTION:(this._err(ue.cdataInHtmlContent),this._createCommentToken(Gn.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=B.BOGUS_COMMENT):this._ensureHibernation()||(this._err(ue.incorrectlyOpenedComment),this._createCommentToken(2),this.state=B.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case O.HYPHEN_MINUS:{this.state=B.COMMENT_START_DASH;break}case O.GREATER_THAN_SIGN:{this._err(ue.abruptClosingOfEmptyComment),this.state=B.DATA;const a=this.currentToken;this.emitCurrentComment(a);break}default:this.state=B.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const a=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=B.COMMENT_END;break}case O.GREATER_THAN_SIGN:{this._err(ue.abruptClosingOfEmptyComment),this.state=B.DATA,this.emitCurrentComment(a);break}case O.EOF:{this._err(ue.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="-",this.state=B.COMMENT,this._stateComment(t)}}_stateComment(t){const a=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=B.COMMENT_END_DASH;break}case O.LESS_THAN_SIGN:{a.data+="<",this.state=B.COMMENT_LESS_THAN_SIGN;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),a.data+=Pt;break}case O.EOF:{this._err(ue.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const a=this.currentToken;switch(t){case O.EXCLAMATION_MARK:{a.data+="!",this.state=B.COMMENT_LESS_THAN_SIGN_BANG;break}case O.LESS_THAN_SIGN:{a.data+="<";break}default:this.state=B.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===O.HYPHEN_MINUS?this.state=B.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=B.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===O.HYPHEN_MINUS?this.state=B.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=B.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==O.GREATER_THAN_SIGN&&t!==O.EOF&&this._err(ue.nestedComment),this.state=B.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const a=this.currentToken;switch(t){case O.HYPHEN_MINUS:{this.state=B.COMMENT_END;break}case O.EOF:{this._err(ue.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="-",this.state=B.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const a=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.state=B.DATA,this.emitCurrentComment(a);break}case O.EXCLAMATION_MARK:{this.state=B.COMMENT_END_BANG;break}case O.HYPHEN_MINUS:{a.data+="-";break}case O.EOF:{this._err(ue.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="--",this.state=B.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const a=this.currentToken;switch(t){case O.HYPHEN_MINUS:{a.data+="--!",this.state=B.COMMENT_END_DASH;break}case O.GREATER_THAN_SIGN:{this._err(ue.incorrectlyClosedComment),this.state=B.DATA,this.emitCurrentComment(a);break}case O.EOF:{this._err(ue.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="--!",this.state=B.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=B.BEFORE_DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this.state=B.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case O.EOF:{this._err(ue.eofInDoctype),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ue.missingWhitespaceBeforeDoctypeName),this.state=B.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(to(t))this._createDoctypeToken(String.fromCharCode(rc(t))),this.state=B.DOCTYPE_NAME;else switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.NULL:{this._err(ue.unexpectedNullCharacter),this._createDoctypeToken(Pt),this.state=B.DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this._err(ue.missingDoctypeName),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=B.DATA;break}case O.EOF:{this._err(ue.eofInDoctype),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(t)),this.state=B.DOCTYPE_NAME}}_stateDoctypeName(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=B.AFTER_DOCTYPE_NAME;break}case O.GREATER_THAN_SIGN:{this.state=B.DATA,this.emitCurrentDoctype(a);break}case O.NULL:{this._err(ue.unexpectedNullCharacter),a.name+=Pt;break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.name+=String.fromCodePoint(to(t)?rc(t):t)}}_stateAfterDoctypeName(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.state=B.DATA,this.emitCurrentDoctype(a);break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Gn.PUBLIC,!1)?this.state=B.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Gn.SYSTEM,!1)?this.state=B.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(ue.invalidCharacterSequenceAfterDoctypeName),a.forceQuirks=!0,this.state=B.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=B.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.QUOTATION_MARK:{this._err(ue.missingWhitespaceAfterDoctypePublicKeyword),a.publicId="",this.state=B.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(ue.missingWhitespaceAfterDoctypePublicKeyword),a.publicId="",this.state=B.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(ue.missingDoctypePublicIdentifier),a.forceQuirks=!0,this.state=B.DATA,this.emitCurrentDoctype(a);break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ue.missingQuoteBeforeDoctypePublicIdentifier),a.forceQuirks=!0,this.state=B.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{a.publicId="",this.state=B.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{a.publicId="",this.state=B.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(ue.missingDoctypePublicIdentifier),a.forceQuirks=!0,this.state=B.DATA,this.emitCurrentDoctype(a);break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ue.missingQuoteBeforeDoctypePublicIdentifier),a.forceQuirks=!0,this.state=B.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const a=this.currentToken;switch(t){case O.QUOTATION_MARK:{this.state=B.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),a.publicId+=Pt;break}case O.GREATER_THAN_SIGN:{this._err(ue.abruptDoctypePublicIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=B.DATA;break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.publicId+=String.fromCodePoint(t)}}_stateDoctypePublicIdentifierSingleQuoted(t){const a=this.currentToken;switch(t){case O.APOSTROPHE:{this.state=B.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),a.publicId+=Pt;break}case O.GREATER_THAN_SIGN:{this._err(ue.abruptDoctypePublicIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=B.DATA;break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.publicId+=String.fromCodePoint(t)}}_stateAfterDoctypePublicIdentifier(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=B.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case O.GREATER_THAN_SIGN:{this.state=B.DATA,this.emitCurrentDoctype(a);break}case O.QUOTATION_MARK:{this._err(ue.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),a.systemId="",this.state=B.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(ue.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),a.systemId="",this.state=B.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ue.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=B.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=B.DATA;break}case O.QUOTATION_MARK:{a.systemId="",this.state=B.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{a.systemId="",this.state=B.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ue.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=B.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:{this.state=B.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.QUOTATION_MARK:{this._err(ue.missingWhitespaceAfterDoctypeSystemKeyword),a.systemId="",this.state=B.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{this._err(ue.missingWhitespaceAfterDoctypeSystemKeyword),a.systemId="",this.state=B.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(ue.missingDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=B.DATA,this.emitCurrentDoctype(a);break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ue.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=B.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.QUOTATION_MARK:{a.systemId="",this.state=B.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case O.APOSTROPHE:{a.systemId="",this.state=B.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case O.GREATER_THAN_SIGN:{this._err(ue.missingDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=B.DATA,this.emitCurrentDoctype(a);break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ue.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=B.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const a=this.currentToken;switch(t){case O.QUOTATION_MARK:{this.state=B.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),a.systemId+=Pt;break}case O.GREATER_THAN_SIGN:{this._err(ue.abruptDoctypeSystemIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=B.DATA;break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.systemId+=String.fromCodePoint(t)}}_stateDoctypeSystemIdentifierSingleQuoted(t){const a=this.currentToken;switch(t){case O.APOSTROPHE:{this.state=B.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case O.NULL:{this._err(ue.unexpectedNullCharacter),a.systemId+=Pt;break}case O.GREATER_THAN_SIGN:{this._err(ue.abruptDoctypeSystemIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=B.DATA;break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.systemId+=String.fromCodePoint(t)}}_stateAfterDoctypeSystemIdentifier(t){const a=this.currentToken;switch(t){case O.SPACE:case O.LINE_FEED:case O.TABULATION:case O.FORM_FEED:break;case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=B.DATA;break}case O.EOF:{this._err(ue.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ue.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=B.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const a=this.currentToken;switch(t){case O.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=B.DATA;break}case O.NULL:{this._err(ue.unexpectedNullCharacter);break}case O.EOF:{this.emitCurrentDoctype(a),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case O.RIGHT_SQUARE_BRACKET:{this.state=B.CDATA_SECTION_BRACKET;break}case O.EOF:{this._err(ue.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===O.RIGHT_SQUARE_BRACKET?this.state=B.CDATA_SECTION_END:(this._emitChars("]"),this.state=B.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case O.GREATER_THAN_SIGN:{this.state=B.DATA;break}case O.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=B.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(O.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&$1(this.preprocessor.peek(1))?B.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){$1(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===O.SEMICOLON&&this._err(ue.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const t_=new Set([E.DD,E.DT,E.LI,E.OPTGROUP,E.OPTION,E.P,E.RB,E.RP,E.RT,E.RTC]),K1=new Set([...t_,E.CAPTION,E.COLGROUP,E.TBODY,E.TD,E.TFOOT,E.TH,E.THEAD,E.TR]),kc=new Set([E.APPLET,E.CAPTION,E.HTML,E.MARQUEE,E.OBJECT,E.TABLE,E.TD,E.TEMPLATE,E.TH]),mL=new Set([...kc,E.OL,E.UL]),hL=new Set([...kc,E.BUTTON]),V1=new Set([E.ANNOTATION_XML,E.MI,E.MN,E.MO,E.MS,E.MTEXT]),Q1=new Set([E.DESC,E.FOREIGN_OBJECT,E.TITLE]),pL=new Set([E.TR,E.TEMPLATE,E.HTML]),gL=new Set([E.TBODY,E.TFOOT,E.THEAD,E.TEMPLATE,E.HTML]),bL=new Set([E.TABLE,E.TEMPLATE,E.HTML]),xL=new Set([E.TD,E.TH]);class EL{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,a,s){this.treeAdapter=a,this.handler=s,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=E.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===E.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===ge.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(t,a){this.stackTop++,this.items[this.stackTop]=t,this.current=t,this.tagIDs[this.stackTop]=a,this.currentTagId=a,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(t,a,!0)}pop(){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,a){const s=this._indexOf(t);this.items[s]=a,s===this.stackTop&&(this.current=a)}insertAfter(t,a,s){const l=this._indexOf(t)+1;this.items.splice(l,0,a),this.tagIDs.splice(l,0,s),this.stackTop++,l===this.stackTop&&this._updateCurrentElement(),this.current&&this.currentTagId!==void 0&&this.handler.onItemPush(this.current,this.currentTagId,l===this.stackTop)}popUntilTagNamePopped(t){let a=this.stackTop+1;do a=this.tagIDs.lastIndexOf(t,a-1);while(a>0&&this.treeAdapter.getNamespaceURI(this.items[a])!==ge.HTML);this.shortenToLength(Math.max(a,0))}shortenToLength(t){for(;this.stackTop>=t;){const a=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(a,this.stackTop<t)}}popUntilElementPopped(t){const a=this._indexOf(t);this.shortenToLength(Math.max(a,0))}popUntilPopped(t,a){const s=this._indexOfTagNames(t,a);this.shortenToLength(Math.max(s,0))}popUntilNumberedHeaderPopped(){this.popUntilPopped(ph,ge.HTML)}popUntilTableCellPopped(){this.popUntilPopped(xL,ge.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,a){for(let s=this.stackTop;s>=0;s--)if(t.has(this.tagIDs[s])&&this.treeAdapter.getNamespaceURI(this.items[s])===a)return s;return-1}clearBackTo(t,a){const s=this._indexOfTagNames(t,a);this.shortenToLength(s+1)}clearBackToTableContext(){this.clearBackTo(bL,ge.HTML)}clearBackToTableBodyContext(){this.clearBackTo(gL,ge.HTML)}clearBackToTableRowContext(){this.clearBackTo(pL,ge.HTML)}remove(t){const a=this._indexOf(t);a>=0&&(a===this.stackTop?this.pop():(this.items.splice(a,1),this.tagIDs.splice(a,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===E.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const a=this._indexOf(t)-1;return a>=0?this.items[a]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===E.HTML}hasInDynamicScope(t,a){for(let s=this.stackTop;s>=0;s--){const l=this.tagIDs[s];switch(this.treeAdapter.getNamespaceURI(this.items[s])){case ge.HTML:{if(l===t)return!0;if(a.has(l))return!1;break}case ge.SVG:{if(Q1.has(l))return!1;break}case ge.MATHML:{if(V1.has(l))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,kc)}hasInListItemScope(t){return this.hasInDynamicScope(t,mL)}hasInButtonScope(t){return this.hasInDynamicScope(t,hL)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const a=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case ge.HTML:{if(ph.has(a))return!0;if(kc.has(a))return!1;break}case ge.SVG:{if(Q1.has(a))return!1;break}case ge.MATHML:{if(V1.has(a))return!1;break}}}return!0}hasInTableScope(t){for(let a=this.stackTop;a>=0;a--)if(this.treeAdapter.getNamespaceURI(this.items[a])===ge.HTML)switch(this.tagIDs[a]){case t:return!0;case E.TABLE:case E.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===ge.HTML)switch(this.tagIDs[t]){case E.TBODY:case E.THEAD:case E.TFOOT:return!0;case E.TABLE:case E.HTML:return!1}return!0}hasInSelectScope(t){for(let a=this.stackTop;a>=0;a--)if(this.treeAdapter.getNamespaceURI(this.items[a])===ge.HTML)switch(this.tagIDs[a]){case t:return!0;case E.OPTION:case E.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;this.currentTagId!==void 0&&t_.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&K1.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&K1.has(this.currentTagId);)this.pop()}}const Hm=3;var Va;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Va||(Va={}));const X1={type:Va.Marker};class yL{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,a){const s=[],l=a.length,u=this.treeAdapter.getTagName(t),d=this.treeAdapter.getNamespaceURI(t);for(let f=0;f<this.entries.length;f++){const m=this.entries[f];if(m.type===Va.Marker)break;const{element:h}=m;if(this.treeAdapter.getTagName(h)===u&&this.treeAdapter.getNamespaceURI(h)===d){const x=this.treeAdapter.getAttrList(h);x.length===l&&s.push({idx:f,attrs:x})}}return s}_ensureNoahArkCondition(t){if(this.entries.length<Hm)return;const a=this.treeAdapter.getAttrList(t),s=this._getNoahArkConditionCandidates(t,a);if(s.length<Hm)return;const l=new Map(a.map(d=>[d.name,d.value]));let u=0;for(let d=0;d<s.length;d++){const f=s[d];f.attrs.every(m=>l.get(m.name)===m.value)&&(u+=1,u>=Hm&&this.entries.splice(f.idx,1))}}insertMarker(){this.entries.unshift(X1)}pushElement(t,a){this._ensureNoahArkCondition(t),this.entries.unshift({type:Va.Element,element:t,token:a})}insertElementAfterBookmark(t,a){const s=this.entries.indexOf(this.bookmark);this.entries.splice(s,0,{type:Va.Element,element:t,token:a})}removeEntry(t){const a=this.entries.indexOf(t);a!==-1&&this.entries.splice(a,1)}clearToLastMarker(){const t=this.entries.indexOf(X1);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const a=this.entries.find(s=>s.type===Va.Marker||this.treeAdapter.getTagName(s.element)===t);return a&&a.type===Va.Element?a:null}getElementEntry(t){return this.entries.find(a=>a.type===Va.Element&&a.element===t)}}const is={createDocument(){return{nodeName:"#document",mode:Na.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,a){return{nodeName:e,tagName:e,attrs:a,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,a){const s=e.childNodes.indexOf(a);e.childNodes.splice(s,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,a,s){const l=e.childNodes.find(u=>u.nodeName==="#documentType");if(l)l.name=t,l.publicId=a,l.systemId=s;else{const u={nodeName:"#documentType",name:t,publicId:a,systemId:s,parentNode:null};is.appendChild(e,u)}},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 a=e.childNodes[e.childNodes.length-1];if(is.isTextNode(a)){a.value+=t;return}}is.appendChild(e,is.createTextNode(t))},insertTextBefore(e,t,a){const s=e.childNodes[e.childNodes.indexOf(a)-1];s&&is.isTextNode(s)?s.value+=t:is.insertBefore(e,is.createTextNode(t),a)},adoptAttributes(e,t){const a=new Set(e.attrs.map(s=>s.name));for(let s=0;s<t.length;s++)a.has(t[s].name)||e.attrs.push(t[s])},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}}},n_="html",TL="about:legacy-compat",_L="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",a_=["+//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//"],NL=[...a_,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],SL=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),r_=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],vL=[...r_,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function W1(e,t){return t.some(a=>e.startsWith(a))}function AL(e){return e.name===n_&&e.publicId===null&&(e.systemId===null||e.systemId===TL)}function CL(e){if(e.name!==n_)return Na.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===_L)return Na.QUIRKS;let{publicId:a}=e;if(a!==null){if(a=a.toLowerCase(),SL.has(a))return Na.QUIRKS;let s=t===null?NL:a_;if(W1(a,s))return Na.QUIRKS;if(s=t===null?r_:vL,W1(a,s))return Na.LIMITED_QUIRKS}return Na.NO_QUIRKS}const Z1={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},wL="definitionurl",kL="definitionURL",RL=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])),OL=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:ge.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:ge.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:ge.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:ge.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:ge.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:ge.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:ge.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:ge.XML}],["xml:space",{prefix:"xml",name:"space",namespace:ge.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:ge.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:ge.XMLNS}]]),IL=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])),ML=new Set([E.B,E.BIG,E.BLOCKQUOTE,E.BODY,E.BR,E.CENTER,E.CODE,E.DD,E.DIV,E.DL,E.DT,E.EM,E.EMBED,E.H1,E.H2,E.H3,E.H4,E.H5,E.H6,E.HEAD,E.HR,E.I,E.IMG,E.LI,E.LISTING,E.MENU,E.META,E.NOBR,E.OL,E.P,E.PRE,E.RUBY,E.S,E.SMALL,E.SPAN,E.STRONG,E.STRIKE,E.SUB,E.SUP,E.TABLE,E.TT,E.U,E.UL,E.VAR]);function DL(e){const t=e.tagID;return t===E.FONT&&e.attrs.some(({name:s})=>s===Hs.COLOR||s===Hs.SIZE||s===Hs.FACE)||ML.has(t)}function s_(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===wL){e.attrs[t].name=kL;break}}function i_(e){for(let t=0;t<e.attrs.length;t++){const a=RL.get(e.attrs[t].name);a!=null&&(e.attrs[t].name=a)}}function i0(e){for(let t=0;t<e.attrs.length;t++){const a=OL.get(e.attrs[t].name);a&&(e.attrs[t].prefix=a.prefix,e.attrs[t].name=a.name,e.attrs[t].namespace=a.namespace)}}function LL(e){const t=IL.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Qi(e.tagName))}function jL(e,t){return t===ge.MATHML&&(e===E.MI||e===E.MO||e===E.MN||e===E.MS||e===E.MTEXT)}function BL(e,t,a){if(t===ge.MATHML&&e===E.ANNOTATION_XML){for(let s=0;s<a.length;s++)if(a[s].name===Hs.ENCODING){const l=a[s].value.toLowerCase();return l===Z1.TEXT_HTML||l===Z1.APPLICATION_XML}}return t===ge.SVG&&(e===E.FOREIGN_OBJECT||e===E.DESC||e===E.TITLE)}function PL(e,t,a,s){return(!s||s===ge.HTML)&&BL(e,t,a)||(!s||s===ge.MATHML)&&jL(e,t)}const UL="hidden",HL=8,FL=3;var z;(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"})(z||(z={}));const zL={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},l_=new Set([E.TABLE,E.TBODY,E.TFOOT,E.THEAD,E.TR]),J1={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:is,onParseError:null};class eE{constructor(t,a,s=null,l=null){this.fragmentContext=s,this.scriptHandler=l,this.currentToken=null,this.stopped=!1,this.insertionMode=z.INITIAL,this.originalInsertionMode=z.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={...J1,...t},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=a??this.treeAdapter.createDocument(),this.tokenizer=new fL(this.options,this),this.activeFormattingElements=new yL(this.treeAdapter),this.fragmentContextID=s?Qi(this.treeAdapter.getTagName(s)):E.UNKNOWN,this._setContextModes(s??this.document,this.fragmentContextID),this.openElements=new EL(this.document,this.treeAdapter,this)}static parse(t,a){const s=new this(a);return s.tokenizer.write(t,!0),s.document}static getFragmentParser(t,a){const s={...J1,...a};t??(t=s.treeAdapter.createElement(Z.TEMPLATE,ge.HTML,[]));const l=s.treeAdapter.createElement("documentmock",ge.HTML,[]),u=new this(s,l,t);return u.fragmentContextID===E.TEMPLATE&&u.tmplInsertionModeStack.unshift(z.IN_TEMPLATE),u._initTokenizerForFragmentParsing(),u._insertFakeRootElement(),u._resetInsertionMode(),u._findFormInFragmentContext(),u}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),a=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,a),a}_err(t,a,s){var l;if(!this.onParseError)return;const u=(l=t.location)!==null&&l!==void 0?l:zL,d={code:a,startLine:u.startLine,startCol:u.startCol,startOffset:u.startOffset,endLine:s?u.startLine:u.endLine,endCol:s?u.startCol:u.endCol,endOffset:s?u.startOffset:u.endOffset};this.onParseError(d)}onItemPush(t,a,s){var l,u;(u=(l=this.treeAdapter).onItemPush)===null||u===void 0||u.call(l,t),s&&this.openElements.stackTop>0&&this._setContextModes(t,a)}onItemPop(t,a){var s,l;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(l=(s=this.treeAdapter).onItemPop)===null||l===void 0||l.call(s,t,this.openElements.current),a){let u,d;this.openElements.stackTop===0&&this.fragmentContext?(u=this.fragmentContext,d=this.fragmentContextID):{current:u,currentTagId:d}=this.openElements,this._setContextModes(u,d)}}_setContextModes(t,a){const s=t===this.document||t&&this.treeAdapter.getNamespaceURI(t)===ge.HTML;this.currentNotInHTML=!s,this.tokenizer.inForeignNode=!s&&t!==void 0&&a!==void 0&&!this._isIntegrationPoint(a,t)}_switchToTextParsing(t,a){this._insertElement(t,ge.HTML),this.tokenizer.state=a,this.originalInsertionMode=this.insertionMode,this.insertionMode=z.TEXT}switchToPlaintextParsing(){this.insertionMode=z.TEXT,this.originalInsertionMode=z.IN_BODY,this.tokenizer.state=Xt.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)===Z.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==ge.HTML))switch(this.fragmentContextID){case E.TITLE:case E.TEXTAREA:{this.tokenizer.state=Xt.RCDATA;break}case E.STYLE:case E.XMP:case E.IFRAME:case E.NOEMBED:case E.NOFRAMES:case E.NOSCRIPT:{this.tokenizer.state=Xt.RAWTEXT;break}case E.SCRIPT:{this.tokenizer.state=Xt.SCRIPT_DATA;break}case E.PLAINTEXT:{this.tokenizer.state=Xt.PLAINTEXT;break}}}_setDocumentType(t){const a=t.name||"",s=t.publicId||"",l=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,a,s,l),t.location){const d=this.treeAdapter.getChildNodes(this.document).find(f=>this.treeAdapter.isDocumentTypeNode(f));d&&this.treeAdapter.setNodeSourceCodeLocation(d,t.location)}}_attachElementToTree(t,a){if(this.options.sourceCodeLocationInfo){const s=a&&{...a,startTag:a};this.treeAdapter.setNodeSourceCodeLocation(t,s)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const s=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(s??this.document,t)}}_appendElement(t,a){const s=this.treeAdapter.createElement(t.tagName,a,t.attrs);this._attachElementToTree(s,t.location)}_insertElement(t,a){const s=this.treeAdapter.createElement(t.tagName,a,t.attrs);this._attachElementToTree(s,t.location),this.openElements.push(s,t.tagID)}_insertFakeElement(t,a){const s=this.treeAdapter.createElement(t,ge.HTML,[]);this._attachElementToTree(s,null),this.openElements.push(s,a)}_insertTemplate(t){const a=this.treeAdapter.createElement(t.tagName,ge.HTML,t.attrs),s=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(a,s),this._attachElementToTree(a,t.location),this.openElements.push(a,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(s,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(Z.HTML,ge.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,E.HTML)}_appendCommentNode(t,a){const s=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(a,s),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(s,t.location)}_insertCharacters(t){let a,s;if(this._shouldFosterParentOnInsertion()?({parent:a,beforeElement:s}=this._findFosterParentingLocation(),s?this.treeAdapter.insertTextBefore(a,t.chars,s):this.treeAdapter.insertText(a,t.chars)):(a=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(a,t.chars)),!t.location)return;const l=this.treeAdapter.getChildNodes(a),u=s?l.lastIndexOf(s):l.length,d=l[u-1];if(this.treeAdapter.getNodeSourceCodeLocation(d)){const{endLine:m,endCol:h,endOffset:x}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(d,{endLine:m,endCol:h,endOffset:x})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(d,t.location)}_adoptNodes(t,a){for(let s=this.treeAdapter.getFirstChild(t);s;s=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(s),this.treeAdapter.appendChild(a,s)}_setEndLocation(t,a){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&a.location){const s=a.location,l=this.treeAdapter.getTagName(t),u=a.type===tt.END_TAG&&l===a.tagName?{endTag:{...s},endLine:s.endLine,endCol:s.endCol,endOffset:s.endOffset}:{endLine:s.startLine,endCol:s.startCol,endOffset:s.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,u)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let a,s;return this.openElements.stackTop===0&&this.fragmentContext?(a=this.fragmentContext,s=this.fragmentContextID):{current:a,currentTagId:s}=this.openElements,t.tagID===E.SVG&&this.treeAdapter.getTagName(a)===Z.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(a)===ge.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===E.MGLYPH||t.tagID===E.MALIGNMARK)&&s!==void 0&&!this._isIntegrationPoint(s,a,ge.HTML)}_processToken(t){switch(t.type){case tt.CHARACTER:{this.onCharacter(t);break}case tt.NULL_CHARACTER:{this.onNullCharacter(t);break}case tt.COMMENT:{this.onComment(t);break}case tt.DOCTYPE:{this.onDoctype(t);break}case tt.START_TAG:{this._processStartTag(t);break}case tt.END_TAG:{this.onEndTag(t);break}case tt.EOF:{this.onEof(t);break}case tt.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,a,s){const l=this.treeAdapter.getNamespaceURI(a),u=this.treeAdapter.getAttrList(a);return PL(t,l,u,s)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const a=this.activeFormattingElements.entries.findIndex(l=>l.type===Va.Marker||this.openElements.contains(l.element)),s=a===-1?t-1:a-1;for(let l=s;l>=0;l--){const u=this.activeFormattingElements.entries[l];this._insertElement(u.token,this.treeAdapter.getNamespaceURI(u.element)),u.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=z.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(E.P),this.openElements.popUntilTagNamePopped(E.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case E.TR:{this.insertionMode=z.IN_ROW;return}case E.TBODY:case E.THEAD:case E.TFOOT:{this.insertionMode=z.IN_TABLE_BODY;return}case E.CAPTION:{this.insertionMode=z.IN_CAPTION;return}case E.COLGROUP:{this.insertionMode=z.IN_COLUMN_GROUP;return}case E.TABLE:{this.insertionMode=z.IN_TABLE;return}case E.BODY:{this.insertionMode=z.IN_BODY;return}case E.FRAMESET:{this.insertionMode=z.IN_FRAMESET;return}case E.SELECT:{this._resetInsertionModeForSelect(t);return}case E.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case E.HTML:{this.insertionMode=this.headElement?z.AFTER_HEAD:z.BEFORE_HEAD;return}case E.TD:case E.TH:{if(t>0){this.insertionMode=z.IN_CELL;return}break}case E.HEAD:{if(t>0){this.insertionMode=z.IN_HEAD;return}break}}this.insertionMode=z.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let a=t-1;a>0;a--){const s=this.openElements.tagIDs[a];if(s===E.TEMPLATE)break;if(s===E.TABLE){this.insertionMode=z.IN_SELECT_IN_TABLE;return}}this.insertionMode=z.IN_SELECT}_isElementCausesFosterParenting(t){return l_.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 a=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case E.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(a)===ge.HTML)return{parent:this.treeAdapter.getTemplateContent(a),beforeElement:null};break}case E.TABLE:{const s=this.treeAdapter.getParentNode(a);return s?{parent:s,beforeElement:a}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const a=this._findFosterParentingLocation();a.beforeElement?this.treeAdapter.insertBefore(a.parent,t,a.beforeElement):this.treeAdapter.appendChild(a.parent,t)}_isSpecialElement(t,a){const s=this.treeAdapter.getNamespaceURI(t);return oL[s].has(a)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){xj(this,t);return}switch(this.insertionMode){case z.INITIAL:{Zl(this,t);break}case z.BEFORE_HTML:{so(this,t);break}case z.BEFORE_HEAD:{io(this,t);break}case z.IN_HEAD:{lo(this,t);break}case z.IN_HEAD_NO_SCRIPT:{oo(this,t);break}case z.AFTER_HEAD:{uo(this,t);break}case z.IN_BODY:case z.IN_CAPTION:case z.IN_CELL:case z.IN_TEMPLATE:{u_(this,t);break}case z.TEXT:case z.IN_SELECT:case z.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case z.IN_TABLE:case z.IN_TABLE_BODY:case z.IN_ROW:{Fm(this,t);break}case z.IN_TABLE_TEXT:{p_(this,t);break}case z.IN_COLUMN_GROUP:{Rc(this,t);break}case z.AFTER_BODY:{Oc(this,t);break}case z.AFTER_AFTER_BODY:{dc(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){bj(this,t);return}switch(this.insertionMode){case z.INITIAL:{Zl(this,t);break}case z.BEFORE_HTML:{so(this,t);break}case z.BEFORE_HEAD:{io(this,t);break}case z.IN_HEAD:{lo(this,t);break}case z.IN_HEAD_NO_SCRIPT:{oo(this,t);break}case z.AFTER_HEAD:{uo(this,t);break}case z.TEXT:{this._insertCharacters(t);break}case z.IN_TABLE:case z.IN_TABLE_BODY:case z.IN_ROW:{Fm(this,t);break}case z.IN_COLUMN_GROUP:{Rc(this,t);break}case z.AFTER_BODY:{Oc(this,t);break}case z.AFTER_AFTER_BODY:{dc(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){gh(this,t);return}switch(this.insertionMode){case z.INITIAL:case z.BEFORE_HTML:case z.BEFORE_HEAD:case z.IN_HEAD:case z.IN_HEAD_NO_SCRIPT:case z.AFTER_HEAD:case z.IN_BODY:case z.IN_TABLE:case z.IN_CAPTION:case z.IN_COLUMN_GROUP:case z.IN_TABLE_BODY:case z.IN_ROW:case z.IN_CELL:case z.IN_SELECT:case z.IN_SELECT_IN_TABLE:case z.IN_TEMPLATE:case z.IN_FRAMESET:case z.AFTER_FRAMESET:{gh(this,t);break}case z.IN_TABLE_TEXT:{Jl(this,t);break}case z.AFTER_BODY:{QL(this,t);break}case z.AFTER_AFTER_BODY:case z.AFTER_AFTER_FRAMESET:{XL(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case z.INITIAL:{WL(this,t);break}case z.BEFORE_HEAD:case z.IN_HEAD:case z.IN_HEAD_NO_SCRIPT:case z.AFTER_HEAD:{this._err(t,ue.misplacedDoctype);break}case z.IN_TABLE_TEXT:{Jl(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,ue.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?Ej(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case z.INITIAL:{Zl(this,t);break}case z.BEFORE_HTML:{ZL(this,t);break}case z.BEFORE_HEAD:{e8(this,t);break}case z.IN_HEAD:{ja(this,t);break}case z.IN_HEAD_NO_SCRIPT:{a8(this,t);break}case z.AFTER_HEAD:{s8(this,t);break}case z.IN_BODY:{Cn(this,t);break}case z.IN_TABLE:{Fi(this,t);break}case z.IN_TABLE_TEXT:{Jl(this,t);break}case z.IN_CAPTION:{tj(this,t);break}case z.IN_COLUMN_GROUP:{u0(this,t);break}case z.IN_TABLE_BODY:{Wc(this,t);break}case z.IN_ROW:{Zc(this,t);break}case z.IN_CELL:{rj(this,t);break}case z.IN_SELECT:{x_(this,t);break}case z.IN_SELECT_IN_TABLE:{ij(this,t);break}case z.IN_TEMPLATE:{oj(this,t);break}case z.AFTER_BODY:{cj(this,t);break}case z.IN_FRAMESET:{dj(this,t);break}case z.AFTER_FRAMESET:{mj(this,t);break}case z.AFTER_AFTER_BODY:{pj(this,t);break}case z.AFTER_AFTER_FRAMESET:{gj(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?yj(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case z.INITIAL:{Zl(this,t);break}case z.BEFORE_HTML:{JL(this,t);break}case z.BEFORE_HEAD:{t8(this,t);break}case z.IN_HEAD:{n8(this,t);break}case z.IN_HEAD_NO_SCRIPT:{r8(this,t);break}case z.AFTER_HEAD:{i8(this,t);break}case z.IN_BODY:{Xc(this,t);break}case z.TEXT:{$8(this,t);break}case z.IN_TABLE:{yo(this,t);break}case z.IN_TABLE_TEXT:{Jl(this,t);break}case z.IN_CAPTION:{nj(this,t);break}case z.IN_COLUMN_GROUP:{aj(this,t);break}case z.IN_TABLE_BODY:{bh(this,t);break}case z.IN_ROW:{b_(this,t);break}case z.IN_CELL:{sj(this,t);break}case z.IN_SELECT:{E_(this,t);break}case z.IN_SELECT_IN_TABLE:{lj(this,t);break}case z.IN_TEMPLATE:{uj(this,t);break}case z.AFTER_BODY:{T_(this,t);break}case z.IN_FRAMESET:{fj(this,t);break}case z.AFTER_FRAMESET:{hj(this,t);break}case z.AFTER_AFTER_BODY:{dc(this,t);break}}}onEof(t){switch(this.insertionMode){case z.INITIAL:{Zl(this,t);break}case z.BEFORE_HTML:{so(this,t);break}case z.BEFORE_HEAD:{io(this,t);break}case z.IN_HEAD:{lo(this,t);break}case z.IN_HEAD_NO_SCRIPT:{oo(this,t);break}case z.AFTER_HEAD:{uo(this,t);break}case z.IN_BODY:case z.IN_TABLE:case z.IN_CAPTION:case z.IN_COLUMN_GROUP:case z.IN_TABLE_BODY:case z.IN_ROW:case z.IN_CELL:case z.IN_SELECT:case z.IN_SELECT_IN_TABLE:{m_(this,t);break}case z.TEXT:{G8(this,t);break}case z.IN_TABLE_TEXT:{Jl(this,t);break}case z.IN_TEMPLATE:{y_(this,t);break}case z.AFTER_BODY:case z.IN_FRAMESET:case z.AFTER_FRAMESET:case z.AFTER_AFTER_BODY:case z.AFTER_AFTER_FRAMESET:{o0(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===O.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 z.IN_HEAD:case z.IN_HEAD_NO_SCRIPT:case z.AFTER_HEAD:case z.TEXT:case z.IN_COLUMN_GROUP:case z.IN_SELECT:case z.IN_SELECT_IN_TABLE:case z.IN_FRAMESET:case z.AFTER_FRAMESET:{this._insertCharacters(t);break}case z.IN_BODY:case z.IN_CAPTION:case z.IN_CELL:case z.IN_TEMPLATE:case z.AFTER_BODY:case z.AFTER_AFTER_BODY:case z.AFTER_AFTER_FRAMESET:{o_(this,t);break}case z.IN_TABLE:case z.IN_TABLE_BODY:case z.IN_ROW:{Fm(this,t);break}case z.IN_TABLE_TEXT:{h_(this,t);break}}}}function qL(e,t){let a=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return a?e.openElements.contains(a.element)?e.openElements.hasInScope(t.tagID)||(a=null):(e.activeFormattingElements.removeEntry(a),a=null):f_(e,t),a}function YL(e,t){let a=null,s=e.openElements.stackTop;for(;s>=0;s--){const l=e.openElements.items[s];if(l===t.element)break;e._isSpecialElement(l,e.openElements.tagIDs[s])&&(a=l)}return a||(e.openElements.shortenToLength(Math.max(s,0)),e.activeFormattingElements.removeEntry(t)),a}function $L(e,t,a){let s=t,l=e.openElements.getCommonAncestor(t);for(let u=0,d=l;d!==a;u++,d=l){l=e.openElements.getCommonAncestor(d);const f=e.activeFormattingElements.getElementEntry(d),m=f&&u>=FL;!f||m?(m&&e.activeFormattingElements.removeEntry(f),e.openElements.remove(d)):(d=GL(e,f),s===t&&(e.activeFormattingElements.bookmark=f),e.treeAdapter.detachNode(s),e.treeAdapter.appendChild(d,s),s=d)}return s}function GL(e,t){const a=e.treeAdapter.getNamespaceURI(t.element),s=e.treeAdapter.createElement(t.token.tagName,a,t.token.attrs);return e.openElements.replace(t.element,s),t.element=s,s}function KL(e,t,a){const s=e.treeAdapter.getTagName(t),l=Qi(s);if(e._isElementCausesFosterParenting(l))e._fosterParentElement(a);else{const u=e.treeAdapter.getNamespaceURI(t);l===E.TEMPLATE&&u===ge.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,a)}}function VL(e,t,a){const s=e.treeAdapter.getNamespaceURI(a.element),{token:l}=a,u=e.treeAdapter.createElement(l.tagName,s,l.attrs);e._adoptNodes(t,u),e.treeAdapter.appendChild(t,u),e.activeFormattingElements.insertElementAfterBookmark(u,l),e.activeFormattingElements.removeEntry(a),e.openElements.remove(a.element),e.openElements.insertAfter(t,u,l.tagID)}function l0(e,t){for(let a=0;a<HL;a++){const s=qL(e,t);if(!s)break;const l=YL(e,s);if(!l)break;e.activeFormattingElements.bookmark=s;const u=$L(e,l,s.element),d=e.openElements.getCommonAncestor(s.element);e.treeAdapter.detachNode(u),d&&KL(e,d,u),VL(e,l,s)}}function gh(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function QL(e,t){e._appendCommentNode(t,e.openElements.items[0])}function XL(e,t){e._appendCommentNode(t,e.document)}function o0(e,t){if(e.stopped=!0,t.location){const a=e.fragmentContext?0:2;for(let s=e.openElements.stackTop;s>=a;s--)e._setEndLocation(e.openElements.items[s],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const s=e.openElements.items[0],l=e.treeAdapter.getNodeSourceCodeLocation(s);if(l&&!l.endTag&&(e._setEndLocation(s,t),e.openElements.stackTop>=1)){const u=e.openElements.items[1],d=e.treeAdapter.getNodeSourceCodeLocation(u);d&&!d.endTag&&e._setEndLocation(u,t)}}}}function WL(e,t){e._setDocumentType(t);const a=t.forceQuirks?Na.QUIRKS:CL(t);AL(t)||e._err(t,ue.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,a),e.insertionMode=z.BEFORE_HTML}function Zl(e,t){e._err(t,ue.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Na.QUIRKS),e.insertionMode=z.BEFORE_HTML,e._processToken(t)}function ZL(e,t){t.tagID===E.HTML?(e._insertElement(t,ge.HTML),e.insertionMode=z.BEFORE_HEAD):so(e,t)}function JL(e,t){const a=t.tagID;(a===E.HTML||a===E.HEAD||a===E.BODY||a===E.BR)&&so(e,t)}function so(e,t){e._insertFakeRootElement(),e.insertionMode=z.BEFORE_HEAD,e._processToken(t)}function e8(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.HEAD:{e._insertElement(t,ge.HTML),e.headElement=e.openElements.current,e.insertionMode=z.IN_HEAD;break}default:io(e,t)}}function t8(e,t){const a=t.tagID;a===E.HEAD||a===E.BODY||a===E.HTML||a===E.BR?io(e,t):e._err(t,ue.endTagWithoutMatchingOpenElement)}function io(e,t){e._insertFakeElement(Z.HEAD,E.HEAD),e.headElement=e.openElements.current,e.insertionMode=z.IN_HEAD,e._processToken(t)}function ja(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.BASE:case E.BASEFONT:case E.BGSOUND:case E.LINK:case E.META:{e._appendElement(t,ge.HTML),t.ackSelfClosing=!0;break}case E.TITLE:{e._switchToTextParsing(t,Xt.RCDATA);break}case E.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,Xt.RAWTEXT):(e._insertElement(t,ge.HTML),e.insertionMode=z.IN_HEAD_NO_SCRIPT);break}case E.NOFRAMES:case E.STYLE:{e._switchToTextParsing(t,Xt.RAWTEXT);break}case E.SCRIPT:{e._switchToTextParsing(t,Xt.SCRIPT_DATA);break}case E.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=z.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(z.IN_TEMPLATE);break}case E.HEAD:{e._err(t,ue.misplacedStartTagForHeadElement);break}default:lo(e,t)}}function n8(e,t){switch(t.tagID){case E.HEAD:{e.openElements.pop(),e.insertionMode=z.AFTER_HEAD;break}case E.BODY:case E.BR:case E.HTML:{lo(e,t);break}case E.TEMPLATE:{Vs(e,t);break}default:e._err(t,ue.endTagWithoutMatchingOpenElement)}}function Vs(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==E.TEMPLATE&&e._err(t,ue.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(E.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,ue.endTagWithoutMatchingOpenElement)}function lo(e,t){e.openElements.pop(),e.insertionMode=z.AFTER_HEAD,e._processToken(t)}function a8(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.BASEFONT:case E.BGSOUND:case E.HEAD:case E.LINK:case E.META:case E.NOFRAMES:case E.STYLE:{ja(e,t);break}case E.NOSCRIPT:{e._err(t,ue.nestedNoscriptInHead);break}default:oo(e,t)}}function r8(e,t){switch(t.tagID){case E.NOSCRIPT:{e.openElements.pop(),e.insertionMode=z.IN_HEAD;break}case E.BR:{oo(e,t);break}default:e._err(t,ue.endTagWithoutMatchingOpenElement)}}function oo(e,t){const a=t.type===tt.EOF?ue.openElementsLeftAfterEof:ue.disallowedContentInNoscriptInHead;e._err(t,a),e.openElements.pop(),e.insertionMode=z.IN_HEAD,e._processToken(t)}function s8(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.BODY:{e._insertElement(t,ge.HTML),e.framesetOk=!1,e.insertionMode=z.IN_BODY;break}case E.FRAMESET:{e._insertElement(t,ge.HTML),e.insertionMode=z.IN_FRAMESET;break}case E.BASE:case E.BASEFONT:case E.BGSOUND:case E.LINK:case E.META:case E.NOFRAMES:case E.SCRIPT:case E.STYLE:case E.TEMPLATE:case E.TITLE:{e._err(t,ue.abandonedHeadElementChild),e.openElements.push(e.headElement,E.HEAD),ja(e,t),e.openElements.remove(e.headElement);break}case E.HEAD:{e._err(t,ue.misplacedStartTagForHeadElement);break}default:uo(e,t)}}function i8(e,t){switch(t.tagID){case E.BODY:case E.HTML:case E.BR:{uo(e,t);break}case E.TEMPLATE:{Vs(e,t);break}default:e._err(t,ue.endTagWithoutMatchingOpenElement)}}function uo(e,t){e._insertFakeElement(Z.BODY,E.BODY),e.insertionMode=z.IN_BODY,Qc(e,t)}function Qc(e,t){switch(t.type){case tt.CHARACTER:{u_(e,t);break}case tt.WHITESPACE_CHARACTER:{o_(e,t);break}case tt.COMMENT:{gh(e,t);break}case tt.START_TAG:{Cn(e,t);break}case tt.END_TAG:{Xc(e,t);break}case tt.EOF:{m_(e,t);break}}}function o_(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function u_(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function l8(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function o8(e,t){const a=e.openElements.tryPeekProperlyNestedBodyElement();a&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(a,t.attrs))}function u8(e,t){const a=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&a&&(e.treeAdapter.detachNode(a),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_FRAMESET)}function c8(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML)}function d8(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&ph.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,ge.HTML)}function f8(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function m8(e,t){const a=e.openElements.tmplCount>0;(!e.formElement||a)&&(e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML),a||(e.formElement=e.openElements.current))}function h8(e,t){e.framesetOk=!1;const a=t.tagID;for(let s=e.openElements.stackTop;s>=0;s--){const l=e.openElements.tagIDs[s];if(a===E.LI&&l===E.LI||(a===E.DD||a===E.DT)&&(l===E.DD||l===E.DT)){e.openElements.generateImpliedEndTagsWithExclusion(l),e.openElements.popUntilTagNamePopped(l);break}if(l!==E.ADDRESS&&l!==E.DIV&&l!==E.P&&e._isSpecialElement(e.openElements.items[s],l))break}e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML)}function p8(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML),e.tokenizer.state=Xt.PLAINTEXT}function g8(e,t){e.openElements.hasInScope(E.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(E.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML),e.framesetOk=!1}function b8(e,t){const a=e.activeFormattingElements.getElementEntryInScopeWithTagName(Z.A);a&&(l0(e,t),e.openElements.remove(a.element),e.activeFormattingElements.removeEntry(a)),e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function x8(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function E8(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(E.NOBR)&&(l0(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,ge.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function y8(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function T8(e,t){e.treeAdapter.getDocumentMode(e.document)!==Na.QUIRKS&&e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML),e.framesetOk=!1,e.insertionMode=z.IN_TABLE}function c_(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,ge.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function d_(e){const t=JT(e,Hs.TYPE);return t!=null&&t.toLowerCase()===UL}function _8(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,ge.HTML),d_(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function N8(e,t){e._appendElement(t,ge.HTML),t.ackSelfClosing=!0}function S8(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._appendElement(t,ge.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function v8(e,t){t.tagName=Z.IMG,t.tagID=E.IMG,c_(e,t)}function A8(e,t){e._insertElement(t,ge.HTML),e.skipNextNewLine=!0,e.tokenizer.state=Xt.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=z.TEXT}function C8(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Xt.RAWTEXT)}function w8(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Xt.RAWTEXT)}function tE(e,t){e._switchToTextParsing(t,Xt.RAWTEXT)}function k8(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===z.IN_TABLE||e.insertionMode===z.IN_CAPTION||e.insertionMode===z.IN_TABLE_BODY||e.insertionMode===z.IN_ROW||e.insertionMode===z.IN_CELL?z.IN_SELECT_IN_TABLE:z.IN_SELECT}function R8(e,t){e.openElements.currentTagId===E.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML)}function O8(e,t){e.openElements.hasInScope(E.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,ge.HTML)}function I8(e,t){e.openElements.hasInScope(E.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(E.RTC),e._insertElement(t,ge.HTML)}function M8(e,t){e._reconstructActiveFormattingElements(),s_(t),i0(t),t.selfClosing?e._appendElement(t,ge.MATHML):e._insertElement(t,ge.MATHML),t.ackSelfClosing=!0}function D8(e,t){e._reconstructActiveFormattingElements(),i_(t),i0(t),t.selfClosing?e._appendElement(t,ge.SVG):e._insertElement(t,ge.SVG),t.ackSelfClosing=!0}function nE(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML)}function Cn(e,t){switch(t.tagID){case E.I:case E.S:case E.B:case E.U:case E.EM:case E.TT:case E.BIG:case E.CODE:case E.FONT:case E.SMALL:case E.STRIKE:case E.STRONG:{x8(e,t);break}case E.A:{b8(e,t);break}case E.H1:case E.H2:case E.H3:case E.H4:case E.H5:case E.H6:{d8(e,t);break}case E.P:case E.DL:case E.OL:case E.UL:case E.DIV:case E.DIR:case E.NAV:case E.MAIN:case E.MENU:case E.ASIDE:case E.CENTER:case E.FIGURE:case E.FOOTER:case E.HEADER:case E.HGROUP:case E.DIALOG:case E.DETAILS:case E.ADDRESS:case E.ARTICLE:case E.SEARCH:case E.SECTION:case E.SUMMARY:case E.FIELDSET:case E.BLOCKQUOTE:case E.FIGCAPTION:{c8(e,t);break}case E.LI:case E.DD:case E.DT:{h8(e,t);break}case E.BR:case E.IMG:case E.WBR:case E.AREA:case E.EMBED:case E.KEYGEN:{c_(e,t);break}case E.HR:{S8(e,t);break}case E.RB:case E.RTC:{O8(e,t);break}case E.RT:case E.RP:{I8(e,t);break}case E.PRE:case E.LISTING:{f8(e,t);break}case E.XMP:{C8(e,t);break}case E.SVG:{D8(e,t);break}case E.HTML:{l8(e,t);break}case E.BASE:case E.LINK:case E.META:case E.STYLE:case E.TITLE:case E.SCRIPT:case E.BGSOUND:case E.BASEFONT:case E.TEMPLATE:{ja(e,t);break}case E.BODY:{o8(e,t);break}case E.FORM:{m8(e,t);break}case E.NOBR:{E8(e,t);break}case E.MATH:{M8(e,t);break}case E.TABLE:{T8(e,t);break}case E.INPUT:{_8(e,t);break}case E.PARAM:case E.TRACK:case E.SOURCE:{N8(e,t);break}case E.IMAGE:{v8(e,t);break}case E.BUTTON:{g8(e,t);break}case E.APPLET:case E.OBJECT:case E.MARQUEE:{y8(e,t);break}case E.IFRAME:{w8(e,t);break}case E.SELECT:{k8(e,t);break}case E.OPTION:case E.OPTGROUP:{R8(e,t);break}case E.NOEMBED:case E.NOFRAMES:{tE(e,t);break}case E.FRAMESET:{u8(e,t);break}case E.TEXTAREA:{A8(e,t);break}case E.NOSCRIPT:{e.options.scriptingEnabled?tE(e,t):nE(e,t);break}case E.PLAINTEXT:{p8(e,t);break}case E.COL:case E.TH:case E.TD:case E.TR:case E.HEAD:case E.FRAME:case E.TBODY:case E.TFOOT:case E.THEAD:case E.CAPTION:case E.COLGROUP:break;default:nE(e,t)}}function L8(e,t){if(e.openElements.hasInScope(E.BODY)&&(e.insertionMode=z.AFTER_BODY,e.options.sourceCodeLocationInfo)){const a=e.openElements.tryPeekProperlyNestedBodyElement();a&&e._setEndLocation(a,t)}}function j8(e,t){e.openElements.hasInScope(E.BODY)&&(e.insertionMode=z.AFTER_BODY,T_(e,t))}function B8(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a))}function P8(e){const t=e.openElements.tmplCount>0,{formElement:a}=e;t||(e.formElement=null),(a||t)&&e.openElements.hasInScope(E.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(E.FORM):a&&e.openElements.remove(a))}function U8(e){e.openElements.hasInButtonScope(E.P)||e._insertFakeElement(Z.P,E.P),e._closePElement()}function H8(e){e.openElements.hasInListItemScope(E.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(E.LI),e.openElements.popUntilTagNamePopped(E.LI))}function F8(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTagsWithExclusion(a),e.openElements.popUntilTagNamePopped(a))}function z8(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function q8(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a),e.activeFormattingElements.clearToLastMarker())}function Y8(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(Z.BR,E.BR),e.openElements.pop(),e.framesetOk=!1}function f_(e,t){const a=t.tagName,s=t.tagID;for(let l=e.openElements.stackTop;l>0;l--){const u=e.openElements.items[l],d=e.openElements.tagIDs[l];if(s===d&&(s!==E.UNKNOWN||e.treeAdapter.getTagName(u)===a)){e.openElements.generateImpliedEndTagsWithExclusion(s),e.openElements.stackTop>=l&&e.openElements.shortenToLength(l);break}if(e._isSpecialElement(u,d))break}}function Xc(e,t){switch(t.tagID){case E.A:case E.B:case E.I:case E.S:case E.U:case E.EM:case E.TT:case E.BIG:case E.CODE:case E.FONT:case E.NOBR:case E.SMALL:case E.STRIKE:case E.STRONG:{l0(e,t);break}case E.P:{U8(e);break}case E.DL:case E.UL:case E.OL:case E.DIR:case E.DIV:case E.NAV:case E.PRE:case E.MAIN:case E.MENU:case E.ASIDE:case E.BUTTON:case E.CENTER:case E.FIGURE:case E.FOOTER:case E.HEADER:case E.HGROUP:case E.DIALOG:case E.ADDRESS:case E.ARTICLE:case E.DETAILS:case E.SEARCH:case E.SECTION:case E.SUMMARY:case E.LISTING:case E.FIELDSET:case E.BLOCKQUOTE:case E.FIGCAPTION:{B8(e,t);break}case E.LI:{H8(e);break}case E.DD:case E.DT:{F8(e,t);break}case E.H1:case E.H2:case E.H3:case E.H4:case E.H5:case E.H6:{z8(e);break}case E.BR:{Y8(e);break}case E.BODY:{L8(e,t);break}case E.HTML:{j8(e,t);break}case E.FORM:{P8(e);break}case E.APPLET:case E.OBJECT:case E.MARQUEE:{q8(e,t);break}case E.TEMPLATE:{Vs(e,t);break}default:f_(e,t)}}function m_(e,t){e.tmplInsertionModeStack.length>0?y_(e,t):o0(e,t)}function $8(e,t){var a;t.tagID===E.SCRIPT&&((a=e.scriptHandler)===null||a===void 0||a.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function G8(e,t){e._err(t,ue.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Fm(e,t){if(e.openElements.currentTagId!==void 0&&l_.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=z.IN_TABLE_TEXT,t.type){case tt.CHARACTER:{p_(e,t);break}case tt.WHITESPACE_CHARACTER:{h_(e,t);break}}else ko(e,t)}function K8(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_CAPTION}function V8(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_COLUMN_GROUP}function Q8(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Z.COLGROUP,E.COLGROUP),e.insertionMode=z.IN_COLUMN_GROUP,u0(e,t)}function X8(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_TABLE_BODY}function W8(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(Z.TBODY,E.TBODY),e.insertionMode=z.IN_TABLE_BODY,Wc(e,t)}function Z8(e,t){e.openElements.hasInTableScope(E.TABLE)&&(e.openElements.popUntilTagNamePopped(E.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function J8(e,t){d_(t)?e._appendElement(t,ge.HTML):ko(e,t),t.ackSelfClosing=!0}function ej(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,ge.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function Fi(e,t){switch(t.tagID){case E.TD:case E.TH:case E.TR:{W8(e,t);break}case E.STYLE:case E.SCRIPT:case E.TEMPLATE:{ja(e,t);break}case E.COL:{Q8(e,t);break}case E.FORM:{ej(e,t);break}case E.TABLE:{Z8(e,t);break}case E.TBODY:case E.TFOOT:case E.THEAD:{X8(e,t);break}case E.INPUT:{J8(e,t);break}case E.CAPTION:{K8(e,t);break}case E.COLGROUP:{V8(e,t);break}default:ko(e,t)}}function yo(e,t){switch(t.tagID){case E.TABLE:{e.openElements.hasInTableScope(E.TABLE)&&(e.openElements.popUntilTagNamePopped(E.TABLE),e._resetInsertionMode());break}case E.TEMPLATE:{Vs(e,t);break}case E.BODY:case E.CAPTION:case E.COL:case E.COLGROUP:case E.HTML:case E.TBODY:case E.TD:case E.TFOOT:case E.TH:case E.THEAD:case E.TR:break;default:ko(e,t)}}function ko(e,t){const a=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,Qc(e,t),e.fosterParentingEnabled=a}function h_(e,t){e.pendingCharacterTokens.push(t)}function p_(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function Jl(e,t){let a=0;if(e.hasNonWhitespacePendingCharacterToken)for(;a<e.pendingCharacterTokens.length;a++)ko(e,e.pendingCharacterTokens[a]);else for(;a<e.pendingCharacterTokens.length;a++)e._insertCharacters(e.pendingCharacterTokens[a]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const g_=new Set([E.CAPTION,E.COL,E.COLGROUP,E.TBODY,E.TD,E.TFOOT,E.TH,E.THEAD,E.TR]);function tj(e,t){const a=t.tagID;g_.has(a)?e.openElements.hasInTableScope(E.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(E.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=z.IN_TABLE,Fi(e,t)):Cn(e,t)}function nj(e,t){const a=t.tagID;switch(a){case E.CAPTION:case E.TABLE:{e.openElements.hasInTableScope(E.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(E.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=z.IN_TABLE,a===E.TABLE&&yo(e,t));break}case E.BODY:case E.COL:case E.COLGROUP:case E.HTML:case E.TBODY:case E.TD:case E.TFOOT:case E.TH:case E.THEAD:case E.TR:break;default:Xc(e,t)}}function u0(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.COL:{e._appendElement(t,ge.HTML),t.ackSelfClosing=!0;break}case E.TEMPLATE:{ja(e,t);break}default:Rc(e,t)}}function aj(e,t){switch(t.tagID){case E.COLGROUP:{e.openElements.currentTagId===E.COLGROUP&&(e.openElements.pop(),e.insertionMode=z.IN_TABLE);break}case E.TEMPLATE:{Vs(e,t);break}case E.COL:break;default:Rc(e,t)}}function Rc(e,t){e.openElements.currentTagId===E.COLGROUP&&(e.openElements.pop(),e.insertionMode=z.IN_TABLE,e._processToken(t))}function Wc(e,t){switch(t.tagID){case E.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_ROW;break}case E.TH:case E.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(Z.TR,E.TR),e.insertionMode=z.IN_ROW,Zc(e,t);break}case E.CAPTION:case E.COL:case E.COLGROUP:case E.TBODY:case E.TFOOT:case E.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=z.IN_TABLE,Fi(e,t));break}default:Fi(e,t)}}function bh(e,t){const a=t.tagID;switch(t.tagID){case E.TBODY:case E.TFOOT:case E.THEAD:{e.openElements.hasInTableScope(a)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=z.IN_TABLE);break}case E.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=z.IN_TABLE,yo(e,t));break}case E.BODY:case E.CAPTION:case E.COL:case E.COLGROUP:case E.HTML:case E.TD:case E.TH:case E.TR:break;default:yo(e,t)}}function Zc(e,t){switch(t.tagID){case E.TH:case E.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_CELL,e.activeFormattingElements.insertMarker();break}case E.CAPTION:case E.COL:case E.COLGROUP:case E.TBODY:case E.TFOOT:case E.THEAD:case E.TR:{e.openElements.hasInTableScope(E.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=z.IN_TABLE_BODY,Wc(e,t));break}default:Fi(e,t)}}function b_(e,t){switch(t.tagID){case E.TR:{e.openElements.hasInTableScope(E.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=z.IN_TABLE_BODY);break}case E.TABLE:{e.openElements.hasInTableScope(E.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=z.IN_TABLE_BODY,bh(e,t));break}case E.TBODY:case E.TFOOT:case E.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(E.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=z.IN_TABLE_BODY,bh(e,t));break}case E.BODY:case E.CAPTION:case E.COL:case E.COLGROUP:case E.HTML:case E.TD:case E.TH:break;default:yo(e,t)}}function rj(e,t){const a=t.tagID;g_.has(a)?(e.openElements.hasInTableScope(E.TD)||e.openElements.hasInTableScope(E.TH))&&(e._closeTableCell(),Zc(e,t)):Cn(e,t)}function sj(e,t){const a=t.tagID;switch(a){case E.TD:case E.TH:{e.openElements.hasInTableScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=z.IN_ROW);break}case E.TABLE:case E.TBODY:case E.TFOOT:case E.THEAD:case E.TR:{e.openElements.hasInTableScope(a)&&(e._closeTableCell(),b_(e,t));break}case E.BODY:case E.CAPTION:case E.COL:case E.COLGROUP:case E.HTML:break;default:Xc(e,t)}}function x_(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.OPTION:{e.openElements.currentTagId===E.OPTION&&e.openElements.pop(),e._insertElement(t,ge.HTML);break}case E.OPTGROUP:{e.openElements.currentTagId===E.OPTION&&e.openElements.pop(),e.openElements.currentTagId===E.OPTGROUP&&e.openElements.pop(),e._insertElement(t,ge.HTML);break}case E.HR:{e.openElements.currentTagId===E.OPTION&&e.openElements.pop(),e.openElements.currentTagId===E.OPTGROUP&&e.openElements.pop(),e._appendElement(t,ge.HTML),t.ackSelfClosing=!0;break}case E.INPUT:case E.KEYGEN:case E.TEXTAREA:case E.SELECT:{e.openElements.hasInSelectScope(E.SELECT)&&(e.openElements.popUntilTagNamePopped(E.SELECT),e._resetInsertionMode(),t.tagID!==E.SELECT&&e._processStartTag(t));break}case E.SCRIPT:case E.TEMPLATE:{ja(e,t);break}}}function E_(e,t){switch(t.tagID){case E.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===E.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===E.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===E.OPTGROUP&&e.openElements.pop();break}case E.OPTION:{e.openElements.currentTagId===E.OPTION&&e.openElements.pop();break}case E.SELECT:{e.openElements.hasInSelectScope(E.SELECT)&&(e.openElements.popUntilTagNamePopped(E.SELECT),e._resetInsertionMode());break}case E.TEMPLATE:{Vs(e,t);break}}}function ij(e,t){const a=t.tagID;a===E.CAPTION||a===E.TABLE||a===E.TBODY||a===E.TFOOT||a===E.THEAD||a===E.TR||a===E.TD||a===E.TH?(e.openElements.popUntilTagNamePopped(E.SELECT),e._resetInsertionMode(),e._processStartTag(t)):x_(e,t)}function lj(e,t){const a=t.tagID;a===E.CAPTION||a===E.TABLE||a===E.TBODY||a===E.TFOOT||a===E.THEAD||a===E.TR||a===E.TD||a===E.TH?e.openElements.hasInTableScope(a)&&(e.openElements.popUntilTagNamePopped(E.SELECT),e._resetInsertionMode(),e.onEndTag(t)):E_(e,t)}function oj(e,t){switch(t.tagID){case E.BASE:case E.BASEFONT:case E.BGSOUND:case E.LINK:case E.META:case E.NOFRAMES:case E.SCRIPT:case E.STYLE:case E.TEMPLATE:case E.TITLE:{ja(e,t);break}case E.CAPTION:case E.COLGROUP:case E.TBODY:case E.TFOOT:case E.THEAD:{e.tmplInsertionModeStack[0]=z.IN_TABLE,e.insertionMode=z.IN_TABLE,Fi(e,t);break}case E.COL:{e.tmplInsertionModeStack[0]=z.IN_COLUMN_GROUP,e.insertionMode=z.IN_COLUMN_GROUP,u0(e,t);break}case E.TR:{e.tmplInsertionModeStack[0]=z.IN_TABLE_BODY,e.insertionMode=z.IN_TABLE_BODY,Wc(e,t);break}case E.TD:case E.TH:{e.tmplInsertionModeStack[0]=z.IN_ROW,e.insertionMode=z.IN_ROW,Zc(e,t);break}default:e.tmplInsertionModeStack[0]=z.IN_BODY,e.insertionMode=z.IN_BODY,Cn(e,t)}}function uj(e,t){t.tagID===E.TEMPLATE&&Vs(e,t)}function y_(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(E.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):o0(e,t)}function cj(e,t){t.tagID===E.HTML?Cn(e,t):Oc(e,t)}function T_(e,t){var a;if(t.tagID===E.HTML){if(e.fragmentContext||(e.insertionMode=z.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===E.HTML){e._setEndLocation(e.openElements.items[0],t);const s=e.openElements.items[1];s&&!(!((a=e.treeAdapter.getNodeSourceCodeLocation(s))===null||a===void 0)&&a.endTag)&&e._setEndLocation(s,t)}}else Oc(e,t)}function Oc(e,t){e.insertionMode=z.IN_BODY,Qc(e,t)}function dj(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.FRAMESET:{e._insertElement(t,ge.HTML);break}case E.FRAME:{e._appendElement(t,ge.HTML),t.ackSelfClosing=!0;break}case E.NOFRAMES:{ja(e,t);break}}}function fj(e,t){t.tagID===E.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==E.FRAMESET&&(e.insertionMode=z.AFTER_FRAMESET))}function mj(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.NOFRAMES:{ja(e,t);break}}}function hj(e,t){t.tagID===E.HTML&&(e.insertionMode=z.AFTER_AFTER_FRAMESET)}function pj(e,t){t.tagID===E.HTML?Cn(e,t):dc(e,t)}function dc(e,t){e.insertionMode=z.IN_BODY,Qc(e,t)}function gj(e,t){switch(t.tagID){case E.HTML:{Cn(e,t);break}case E.NOFRAMES:{ja(e,t);break}}}function bj(e,t){t.chars=Pt,e._insertCharacters(t)}function xj(e,t){e._insertCharacters(t),e.framesetOk=!1}function __(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==ge.HTML&&e.openElements.currentTagId!==void 0&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function Ej(e,t){if(DL(t))__(e),e._startTagOutsideForeignContent(t);else{const a=e._getAdjustedCurrentElement(),s=e.treeAdapter.getNamespaceURI(a);s===ge.MATHML?s_(t):s===ge.SVG&&(LL(t),i_(t)),i0(t),t.selfClosing?e._appendElement(t,s):e._insertElement(t,s),t.ackSelfClosing=!0}}function yj(e,t){if(t.tagID===E.P||t.tagID===E.BR){__(e),e._endTagOutsideForeignContent(t);return}for(let a=e.openElements.stackTop;a>0;a--){const s=e.openElements.items[a];if(e.treeAdapter.getNamespaceURI(s)===ge.HTML){e._endTagOutsideForeignContent(t);break}const l=e.treeAdapter.getTagName(s);if(l.toLowerCase()===t.tagName){t.tagName=l,e.openElements.shortenToLength(a);break}}}Z.AREA,Z.BASE,Z.BASEFONT,Z.BGSOUND,Z.BR,Z.COL,Z.EMBED,Z.FRAME,Z.HR,Z.IMG,Z.INPUT,Z.KEYGEN,Z.LINK,Z.META,Z.PARAM,Z.SOURCE,Z.TRACK,Z.WBR;const Tj=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,_j=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),aE={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function N_(e,t){const a=Ij(e),s=nT("type",{handlers:{root:Nj,element:Sj,text:vj,comment:v_,doctype:Aj,raw:wj},unknown:kj}),l={parser:a?new eE(aE):eE.getFragmentParser(void 0,aE),handle(f){s(f,l)},stitches:!1,options:t||{}};s(e,l),Xi(l,Za());const u=a?l.parser.document:l.parser.getFragment(),d=MD(u,{file:l.options.file});return l.stitches&&Co(d,"comment",function(f,m,h){const x=f;if(x.value.stitch&&h&&m!==void 0){const b=h.children;return b[m]=x.value.stitch,m}}),d.type==="root"&&d.children.length===1&&d.children[0].type===e.type?d.children[0]:d}function S_(e,t){let a=-1;if(e)for(;++a<e.length;)t.handle(e[a])}function Nj(e,t){S_(e.children,t)}function Sj(e,t){Rj(e,t),S_(e.children,t),Oj(e,t)}function vj(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const a={type:tt.CHARACTER,chars:e.value,location:Ro(e)};Xi(t,Za(e)),t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken)}function Aj(e,t){const a={type:tt.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Ro(e)};Xi(t,Za(e)),t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken)}function Cj(e,t){t.stitches=!0;const a=Mj(e);if("children"in e&&"children"in a){const s=N_({type:"root",children:e.children},t.options);a.children=s.children}v_({type:"comment",value:{stitch:a}},t)}function v_(e,t){const a=e.value,s={type:tt.COMMENT,data:a,location:Ro(e)};Xi(t,Za(e)),t.parser.currentToken=s,t.parser._processToken(t.parser.currentToken)}function wj(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,A_(t,Za(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(Tj,"&lt;$1$2"):e.value,!1),t.parser.tokenizer._runParsingLoop(),t.parser.tokenizer.state===72||t.parser.tokenizer.state===78){t.parser.tokenizer.preprocessor.lastChunkWritten=!0;const a=t.parser.tokenizer._consume();t.parser.tokenizer._callState(a)}}function kj(e,t){const a=e;if(t.options.passThrough&&t.options.passThrough.includes(a.type))Cj(a,t);else{let s="";throw _j.has(a.type)&&(s=". 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 `"+a.type+"` node"+s)}}function Xi(e,t){A_(e,t);const a=e.parser.tokenizer.currentCharacterToken;a&&a.location&&(a.location.endLine=e.parser.tokenizer.preprocessor.line,a.location.endCol=e.parser.tokenizer.preprocessor.col+1,a.location.endOffset=e.parser.tokenizer.preprocessor.offset+1,e.parser.currentToken=a,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=Xt.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 A_(e,t){if(t&&t.offset!==void 0){const a={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=a}}function Rj(e,t){const a=e.tagName.toLowerCase();if(t.parser.tokenizer.state===Xt.PLAINTEXT)return;Xi(t,Za(e));const s=t.parser.openElements.current;let l="namespaceURI"in s?s.namespaceURI:Ps.html;l===Ps.html&&a==="svg"&&(l=Ps.svg);const u=PD({...e,children:[]},{space:l===Ps.svg?"svg":"html"}),d={type:tt.START_TAG,tagName:a,tagID:Qi(a),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in u?u.attrs:[],location:Ro(e)};t.parser.currentToken=d,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=a}function Oj(e,t){const a=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&GD.includes(a)||t.parser.tokenizer.state===Xt.PLAINTEXT)return;Xi(t,Yc(e));const s={type:tt.END_TAG,tagName:a,tagID:Qi(a),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:Ro(e)};t.parser.currentToken=s,t.parser._processToken(t.parser.currentToken),a===t.parser.tokenizer.lastStartTagName&&(t.parser.tokenizer.state===Xt.RCDATA||t.parser.tokenizer.state===Xt.RAWTEXT||t.parser.tokenizer.state===Xt.SCRIPT_DATA)&&(t.parser.tokenizer.state=Xt.DATA)}function Ij(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function Ro(e){const t=Za(e)||{line:void 0,column:void 0,offset:void 0},a=Yc(e)||{line:void 0,column:void 0,offset:void 0};return{startLine:t.line,startCol:t.column,startOffset:t.offset,endLine:a.line,endCol:a.column,endOffset:a.offset}}function Mj(e){return"children"in e?Hi({...e,children:[]}):Hi(e)}function co(e){return function(t,a){return N_(t,{...e,file:a})}}const rE=[{key:"open",label:"开放"},{key:"closed",label:"已关闭"},{key:"all",label:"全部"}];function Dj(e){const t=e<1e12?e*1e3:e,a=Date.now()-t;return a<6e4?"刚刚":a<36e5?`${Math.floor(a/6e4)}分钟前`:a<864e5?`${Math.floor(a/36e5)}小时前`:a<2592e6?`${Math.floor(a/864e5)}天前`:new Date(t).toLocaleDateString("zh-CN",{month:"short",day:"numeric"})}function sE({onDone:e}){const[t,a]=A.useState(""),[s,l]=A.useState(""),[u,d]=A.useState(!1),f=Ge(x=>x.createIssue),m=async()=>{!t.trim()||u||(d(!0),await f(t.trim(),s.trim()||void 0),d(!1),e())},h=x=>{(x.metaKey||x.ctrlKey)&&x.key==="Enter"&&(x.preventDefault(),m())};return o.jsxs("div",{className:"border-b border-line px-3 py-3",children:[o.jsx("input",{type:"text",value:t,onChange:x=>a(x.target.value),onKeyDown:h,placeholder:"Issue 标题",autoFocus:!0,className:"w-full rounded-md border border-line bg-base px-2.5 py-1.5 text-xs text-fg placeholder:text-fg-6 focus:border-fg-5 focus:outline-none"}),o.jsx("textarea",{value:s,onChange:x=>l(x.target.value),onKeyDown:h,placeholder:"描述(可选) ⌘⏎ 创建",rows:3,className:"mt-2 w-full resize-none rounded-md border border-line bg-base px-2.5 py-1.5 text-xs text-fg placeholder:text-fg-6 focus:border-fg-5 focus:outline-none"}),o.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:e,className:"rounded-md px-2.5 py-1 text-xs text-fg-4 transition-colors hover:text-fg-2",children:"取消"}),o.jsx("button",{type:"button",onClick:()=>void m(),disabled:!t.trim()||u,className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-40",children:"创建"})]})]})}function Lj({repoId:e,issueNumber:t,onPublished:a}){const s=Aa(),l=Fe(La),[u,d]=A.useState(""),[f,m]=A.useState("idle"),[h,x]=A.useState(""),[b,y]=A.useState(null),[T,N]=A.useState(!1),v=A.useRef(null),S=A.useCallback(()=>{v.current&&(clearInterval(v.current),v.current=null)},[]);A.useEffect(()=>()=>S(),[S]),A.useEffect(()=>{let L=!1;return Ex(e,t).then(M=>{!L&&M.body&&(x(M.body),m("preview"))}).catch(()=>{}),()=>{L=!0}},[e,t]);const C=async()=>{if(!(!u.trim()||T)){N(!0);try{const L=await xx(e,t,u.trim());a(L),d(""),Yt.getState().addToast("评论已发布","success")}catch(L){Yt.getState().addToast(L instanceof Error?L.message:"发布失败","error")}finally{N(!1)}}},R=async()=>{if(!(!u.trim()||f==="polishing")){m("polishing");try{const{sessionId:L}=await bC(e,t,u.trim());y(L),v.current=setInterval(async()=>{try{if((await ny(e,L)).type==="idle"){S();const V=await Ex(e,t);x(V.body),m("preview")}}catch{S(),m("idle"),Yt.getState().addToast("润色状态检查失败","error")}},2e3)}catch(L){m("idle"),Yt.getState().addToast(L instanceof Error?L.message:"润色启动失败","error")}}},w=async()=>{if(!(!h.trim()||T)){N(!0);try{const L=await xx(e,t,h.trim());a(L),d(""),x(""),y(null),m("idle"),Yt.getState().addToast("评论已发布","success")}catch(L){Yt.getState().addToast(L instanceof Error?L.message:"发布失败","error")}finally{N(!1)}}},D=()=>{S(),x(""),y(null),m("idle")},K=()=>{!b||!l||(Ie.setState({activeSessionId:b}),s(`/${encodeURIComponent(l)}/run`))};return f==="preview"?o.jsxs("div",{className:"mt-8 border-t border-line pt-6",children:[o.jsxs("h3",{className:"mb-3 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-fg-4",children:[o.jsx(fm,{className:"h-3.5 w-3.5 text-amber-400"}),"AI 润色结果"]}),o.jsx("div",{className:"rounded-lg border border-amber-500/30 bg-amber-500/5 px-4 py-3",children:o.jsx("textarea",{value:h,onChange:L=>x(L.target.value),rows:6,className:"w-full resize-none bg-transparent text-sm text-fg placeholder:text-fg-6 focus:outline-none"})}),o.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[o.jsxs("button",{type:"button",disabled:T,onClick:()=>void w(),className:"flex items-center gap-1.5 rounded-md bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-40",children:[o.jsx(bc,{className:"h-3.5 w-3.5"}),"发布评论"]}),o.jsxs("button",{type:"button",onClick:()=>void R(),className:"flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1.5 text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsx(fm,{className:"h-3.5 w-3.5"}),"重新润色"]}),o.jsx("button",{type:"button",onClick:K,className:"flex items-center gap-1.5 rounded-md border border-line px-2.5 py-1.5 text-xs text-fg-3 transition-colors hover:border-blue-500/50 hover:text-blue-400",children:"转入深度对话"}),o.jsx("button",{type:"button",onClick:D,className:"ml-auto rounded-md px-2.5 py-1.5 text-xs text-fg-5 transition-colors hover:text-fg-3",children:"放弃"})]})]}):o.jsxs("div",{className:"mt-8 border-t border-line pt-6",children:[o.jsx("h3",{className:"mb-3 text-xs font-semibold uppercase tracking-wider text-fg-4",children:"添加评论"}),o.jsx("textarea",{value:u,onChange:L=>d(L.target.value),placeholder:"写下你的评论...",rows:4,disabled:f==="polishing",className:"w-full resize-none rounded-lg border border-line bg-base px-3 py-2.5 text-sm text-fg placeholder:text-fg-6 focus:border-fg-5 focus:outline-none disabled:opacity-50"}),o.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[o.jsxs("button",{type:"button",disabled:!u.trim()||T||f==="polishing",onClick:()=>void C(),className:"flex items-center gap-1.5 rounded-md bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-40",children:[o.jsx(bc,{className:"h-3.5 w-3.5"}),T?"发送中...":"直接发送"]}),o.jsxs("button",{type:"button",disabled:!u.trim()||f==="polishing",onClick:()=>void R(),className:"flex items-center gap-1.5 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-1.5 text-xs font-medium text-amber-400 transition-colors hover:bg-amber-500/20 disabled:opacity-40",children:[o.jsx(fm,{className:"h-3.5 w-3.5"}),f==="polishing"?"润色中...":"AI 润色"]})]})]})}function iE({issue:e,sessionCount:t,isActive:a,isEpic:s,milestone:l,onSelect:u}){return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:u,className:oe("group flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left transition-colors",a?"border-l-2 border-blue-500 bg-elevated/80":"border-l-2 border-transparent hover:bg-elevated/50"),children:[o.jsx("span",{className:oe("flex h-10 w-10 shrink-0 items-center justify-center rounded-full font-mono text-sm font-bold",e.state==="open"?"bg-gradient-to-br from-emerald-500/20 to-emerald-500/5 text-emerald-400 ring-1 ring-emerald-500/25":"bg-gradient-to-br from-purple-500/20 to-purple-500/5 text-purple-400 ring-1 ring-purple-500/25"),children:e.number}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[s&&o.jsx("span",{className:"shrink-0 rounded px-1 py-0.5 text-[9px] font-bold tracking-wide bg-amber-400/12 text-amber-400",children:"EPIC"}),o.jsx("span",{className:"min-w-0 text-xs font-medium text-fg-2 group-hover:text-fg",children:e.title})]}),e.labels&&e.labels.length>0&&o.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:e.labels.map(d=>o.jsx("span",{className:"rounded px-1 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${d.color}20`,color:`#${d.color}`},children:d.name},d.id))}),l&&o.jsxs("span",{className:"mt-1 flex items-center gap-1 text-[10px] text-indigo-400/70",children:[o.jsx(Mh,{className:"h-2.5 w-2.5"}),l.title]})]}),t>0&&o.jsx("span",{className:"shrink-0 rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:t})]})})}function jj({issue:e,sessionCount:t,isEpic:a,milestone:s,onSelect:l}){return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:l,className:"group flex w-full items-center gap-3 border-b border-line px-4 py-3 text-left transition-colors hover:bg-elevated/50",children:[o.jsx("span",{className:oe("flex h-10 w-10 shrink-0 items-center justify-center rounded-full font-mono text-sm font-bold",e.state==="open"?"bg-gradient-to-br from-emerald-500/20 to-emerald-500/5 text-emerald-400 ring-1 ring-emerald-500/25":"bg-gradient-to-br from-purple-500/20 to-purple-500/5 text-purple-400 ring-1 ring-purple-500/25"),children:e.number}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[a&&o.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[9px] font-bold tracking-wide bg-amber-400/12 text-amber-400",children:"EPIC"}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-fg-2 group-hover:text-fg",children:e.title}),s&&o.jsxs("span",{className:"hidden shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium bg-indigo-500/15 text-indigo-400 sm:flex",children:[o.jsx(Mh,{className:"h-2.5 w-2.5"}),s.title]}),t>0&&o.jsxs("span",{className:"shrink-0 rounded-full bg-elevated px-2 py-0.5 font-mono text-[10px] text-fg-5",children:[t," 次运行"]}),e.assignees&&e.assignees.length>0&&o.jsxs("div",{className:"hidden shrink-0 items-center -space-x-1.5 sm:flex",children:[e.assignees.slice(0,3).map(u=>o.jsx("img",{src:u.avatar_url,alt:u.login,title:u.login,className:"h-5 w-5 rounded-full ring-2 ring-surface"},u.login)),e.assignees.length>3&&o.jsxs("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-elevated text-[9px] font-medium text-fg-4 ring-2 ring-surface",children:["+",e.assignees.length-3]})]})]}),o.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[e.authorLogin&&o.jsxs("span",{className:"shrink-0 text-[11px] text-fg-5",title:e.authorLogin,children:[e.authorAvatar&&o.jsx("img",{src:e.authorAvatar,alt:"",className:"mr-1 inline-block h-3.5 w-3.5 rounded-full align-text-bottom"}),e.authorLogin]}),e.authorLogin&&o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsx("span",{className:"shrink-0 text-[11px] text-fg-6",children:Dj(e.createdAt)}),(e.commentCount??0)>0&&o.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-[11px] text-fg-6",children:[o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsx(FA,{className:"h-3 w-3"}),e.commentCount]}),(e.labels&&e.labels.length>0||(e.commentCount??0)>0||e.authorLogin)&&e.labels&&e.labels.length>0&&o.jsx("span",{className:"text-fg-6",children:"·"}),e.labels&&e.labels.length>0?e.labels.map(u=>o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[11px] font-medium",style:{backgroundColor:`#${u.color}20`,color:`#${u.color}`},children:u.name},u.id)):e.authorLogin?null:o.jsx("span",{className:"text-[11px] text-fg-6",children:" "})]})]})]})})}function Bj({issue:e,milestone:t,onBack:a,onClose:s,onToggleSidebar:l}){var J;const u=Aa(),d=Fe(se=>se.activeRepoId),f=Fe(La),[m,h]=A.useState([]),[x,b]=A.useState(!1),[y,T]=A.useState([]),[N,v]=A.useState(0),[S,C]=A.useState(!1),[R,w]=A.useState(!1),[D,K]=A.useState("issue"),L=Ge(se=>se.updateIssueState);A.useEffect(()=>{d&&(b(!0),gC(d,e.number).then(h).catch(()=>h([])).finally(()=>b(!1)))},[d,e.number]),A.useEffect(()=>{d&&gx(d,e.number).then(T).catch(()=>T([]))},[d,e.number]),A.useEffect(()=>{K("issue"),v(0)},[e.id]);const M=y[N]??y[0],V=async se=>{if(!(S||!d||!M)){C(!0);try{await cC(d,e.number,M.number,se),se&&await L(e.number,"closed");const le=await gx(d,e.number);T(le),N>=le.length&&v(Math.max(0,le.length-1)),Yt.getState().addToast(`PR #${M.number} 合入成功`,"success")}catch(le){let re="合入失败";if(le instanceof Qa)try{re=JSON.parse(le.message).error??re}catch{re=le.message}Yt.getState().addToast(re,"error")}finally{C(!1)}}},W=()=>{if(!M)return;const se=`请解决 PR #${M.number} 的合并冲突: ${M.title}`;Ge.getState().setSelectedIssue(e.id),Ge.getState().setPendingDraft(se),Ge.getState().setPreviewIssue(null),Ie.setState({activeSessionId:null}),u(`/${encodeURIComponent(f)}/run`)},j=()=>{Ge.getState().setSelectedIssue(e.id),Ge.getState().setPreviewIssue(null),Ie.setState({activeSessionId:null}),u(`/${encodeURIComponent(f)}/run`)},U=se=>{const le=new Date(se);return le.toLocaleDateString("zh-CN",{month:"short",day:"numeric"})+" "+le.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})};return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[o.jsxs("header",{className:"flex flex-col gap-2 border-b border-line px-4 py-3 md:flex-row md:items-center md:gap-3 md:px-6",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[o.jsx("button",{type:"button",onClick:a,"aria-label":"返回列表",className:"-ml-1 shrink-0 rounded-md p-1.5 text-fg-3 transition-colors hover:bg-elevated hover:text-fg md:hidden",children:o.jsx(Oh,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",e.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",e.number," ",e.state]}),(J=e.labels)==null?void 0:J.map(se=>o.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${se.color}20`,color:`#${se.color}`},children:se.name},se.id)),t&&o.jsxs("span",{className:"flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium bg-indigo-500/15 text-indigo-400",children:[o.jsx(Mh,{className:"h-2.5 w-2.5"}),t.title]})]}),o.jsx("h2",{className:"mt-1 text-base font-semibold text-fg",children:e.title}),(e.authorLogin||e.assignees&&e.assignees.length>0)&&o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2 text-xs text-fg-4",children:[e.authorLogin&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[e.authorAvatar&&o.jsx("img",{src:e.authorAvatar,alt:"",className:"h-4 w-4 rounded-full"}),e.authorLogin]}),e.assignees&&e.assignees.length>0&&o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx("span",{className:"text-fg-5",children:"→"}),o.jsx("span",{className:"flex items-center -space-x-1",children:e.assignees.map(se=>o.jsx("img",{src:se.avatar_url,alt:se.login,title:se.login,className:"h-4 w-4 rounded-full ring-1 ring-surface"},se.login))}),o.jsx("span",{className:"text-fg-4",children:e.assignees.map(se=>se.login).join(", ")})]})]})]})]}),o.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[e.htmlUrl&&o.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 font-mono text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsx(pc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"源站"})]}),o.jsxs("button",{type:"button",onClick:()=>{Ge.getState().enterMatchMode(e.id),Ie.setState({activeSessionId:null}),u(`/${encodeURIComponent(f)}/run`)},className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 text-xs text-fg-3 transition-colors hover:border-blue-500/50 hover:text-blue-400",children:[o.jsx(Ys,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"匹配子任务"})]}),o.jsx("button",{type:"button",disabled:R,onClick:async()=>{w(!0),await L(e.number,e.state==="open"?"closed":"open"),w(!1)},className:oe("flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs font-medium transition-colors disabled:opacity-40",e.state==="open"?"border-red-500/30 text-red-400 hover:border-red-500/60 hover:bg-red-500/10":"border-emerald-500/30 text-emerald-400 hover:border-emerald-500/60 hover:bg-emerald-500/10"),children:e.state==="open"?o.jsxs(o.Fragment,{children:[o.jsx(zE,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"关闭"})]}):o.jsxs(o.Fragment,{children:[o.jsx(mo,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"重新打开"})]})}),o.jsxs("button",{type:"button",onClick:j,className:"flex h-8 items-center gap-1.5 rounded-md bg-blue-600 px-3 text-xs font-medium text-white transition-colors hover:bg-blue-500",children:[o.jsx(Uc,{className:"h-3.5 w-3.5 fill-current"}),o.jsx("span",{className:"hidden sm:inline",children:"开始处理"})]}),l&&o.jsx("button",{type:"button",onClick:l,title:"面板",className:"flex h-8 w-8 items-center justify-center rounded-md border border-line text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-2",children:o.jsx($E,{className:"h-4 w-4"})}),s&&o.jsx("button",{type:"button",onClick:s,title:"关闭详情",className:"hidden h-8 w-8 items-center justify-center rounded-md border border-line text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-2 md:flex",children:o.jsx(gt,{className:"h-4 w-4"})})]})]}),y.length>0&&o.jsxs("div",{className:"flex shrink-0 items-center border-b border-line bg-surface",children:[o.jsxs("button",{type:"button",onClick:()=>K("issue"),className:oe("flex items-center gap-1.5 border-b-2 px-4 py-2.5 text-xs font-medium transition-colors",D==="issue"?"border-blue-500 text-fg":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(mo,{className:"h-3.5 w-3.5"}),"Issue"]}),o.jsxs("button",{type:"button",onClick:()=>K("pr"),className:oe("flex items-center gap-1.5 border-b-2 px-4 py-2.5 text-xs font-medium transition-colors",D==="pr"?"border-blue-500 text-fg":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(ho,{className:"h-3.5 w-3.5"}),"PR",o.jsx("span",{className:oe("rounded-full px-1.5 py-0.5 font-mono text-[10px]",D==="pr"?"bg-blue-500/10 text-blue-500":"bg-elevated text-fg-5"),children:y.length}),y.some(se=>se.mergeable===!1)&&o.jsxs("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-semibold bg-red-500/15 text-red-400",children:[o.jsx(Dn,{className:"inline h-3 w-3 -mt-px"})," Conflict"]})]})]}),D==="issue"||y.length===0?o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6",children:[e.body?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[co],children:e.body})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"该 Issue 没有描述内容"}),x?o.jsx("p",{className:"mt-8 text-center font-mono text-xs text-fg-6",children:"加载评论…"}):m.length>0&&o.jsxs("div",{className:"mt-8 border-t border-line pt-6",children:[o.jsxs("h3",{className:"mb-4 text-xs font-semibold uppercase tracking-wider text-fg-4",children:["评论 (",m.length,")"]}),o.jsx("div",{className:"space-y-4",children:m.map(se=>o.jsxs("div",{className:"rounded-lg border border-line bg-elevated/40 px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:se.user.avatar_url,alt:se.user.login,className:"h-5 w-5 rounded-full"}),o.jsx("span",{className:"text-xs font-semibold text-fg-2",children:se.user.login}),o.jsx("span",{className:"text-[10px] text-fg-6",children:U(se.created_at)})]}),o.jsx("div",{className:"markdown-body mt-2 text-sm leading-relaxed text-fg-3",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[co],children:se.body})})]},se.id))})]}),d&&o.jsx(Lj,{repoId:d,issueNumber:e.number,onPublished:se=>h(le=>[...le,se])},e.id)]})}):o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-line bg-surface px-4 py-0",children:[y.length>1&&y.map((se,le)=>o.jsxs("button",{type:"button",onClick:()=>v(le),className:oe("flex items-center gap-1.5 border-b-2 px-2.5 py-2.5 text-xs font-medium transition-colors",le===N?"border-blue-500 text-fg":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsxs("span",{className:"font-mono text-[10px]",children:["#",se.number]}),o.jsx("span",{className:"max-w-[140px] truncate",children:se.title})]},se.number)),o.jsxs("div",{className:oe("flex items-center gap-2",y.length>1&&"ml-auto"),children:[(M==null?void 0:M.html_url)&&o.jsxs("a",{href:M.html_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 rounded-md border border-line px-2 py-1.5 font-mono text-[11px] text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsx(pc,{className:"h-3 w-3"}),o.jsx("span",{className:"hidden sm:inline",children:"查看"})]}),(M==null?void 0:M.mergeable)===!1&&o.jsxs("button",{type:"button",onClick:W,className:"flex items-center gap-1.5 rounded-md border border-amber-500/30 px-2.5 py-1.5 text-xs font-medium text-amber-400 transition-colors hover:border-amber-500/60 hover:bg-amber-500/10",children:[o.jsx(y3,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"解冲突"})]}),o.jsxs("button",{type:"button",disabled:S||(M==null?void 0:M.mergeable)===!1,onClick:()=>void V(!1),className:"flex items-center gap-1.5 rounded-md border border-emerald-500/30 px-2.5 py-1.5 text-xs font-medium text-emerald-400 transition-colors hover:border-emerald-500/60 hover:bg-emerald-500/10 disabled:opacity-40",children:[o.jsx(gc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"合入"})]}),o.jsxs("button",{type:"button",disabled:S||(M==null?void 0:M.mergeable)===!1,onClick:()=>void V(!0),className:"flex items-center gap-1.5 rounded-md border border-blue-500/30 px-2.5 py-1.5 text-xs font-medium text-blue-400 transition-colors hover:border-blue-500/60 hover:bg-blue-500/10 disabled:opacity-40",children:[o.jsx(gc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"合入并关闭"})]})]})]}),M&&o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6",children:[o.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",M.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",M.number," ",M.state]}),M.mergeable===!1&&o.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold bg-red-500/15 text-red-400",children:"Conflict"}),o.jsx("span",{className:"text-sm font-semibold text-fg",children:M.title})]}),M.body?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[co],children:M.body})}):o.jsx("p",{className:"py-6 text-center font-mono text-xs text-fg-5",children:"该 PR 没有描述内容"})]})})]})]})}function C_({issue:e,childrenMap:t,currentId:a,onSelect:s,depth:l}){const u=t.get(e.id)??[],d=e.id===a;return o.jsxs("div",{children:[o.jsxs("button",{type:"button",onClick:()=>s(e.id),className:oe("group flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-xs transition-colors",d?"bg-blue-500/10 text-blue-400":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),style:{paddingLeft:`${l*18+8}px`},children:[o.jsx("span",{className:oe("h-1.5 w-1.5 shrink-0 rounded-full",e.state==="open"?"bg-emerald-400":"bg-purple-400")}),o.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-fg-6",children:["#",e.number]}),o.jsx("span",{className:"min-w-0 truncate",children:e.title})]}),u.length>0&&o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute top-0 bottom-3 w-px bg-line",style:{left:`${l*18+16}px`}}),u.map(f=>o.jsx(C_,{issue:f,childrenMap:t,currentId:a,onSelect:s,depth:l+1},f.id))]})]})}function Pj(e,t){let a=0,s=0;const l=[...t.get(e)??[]];for(let u=0;u<l.length;u++){const d=l[u];a++,d.state==="closed"&&s++;const f=t.get(d.id);f&&l.push(...f)}return{total:a,closed:s}}function Uj(e){var u;const t=typeof((u=e.time)==null?void 0:u.created)=="number"?e.time.created:e.createdAt?Date.parse(e.createdAt):0;if(!t||Number.isNaN(t))return"";const a=t<1e12?t*1e3:t,s=new Date(a);return s.toDateString()===new Date().toDateString()?s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function lE({session:e,onSelect:t}){var s,l;const a=Uj(e);return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:t,className:"block w-full rounded-md border-l-2 border-transparent px-2.5 py-2 text-left transition-colors hover:bg-elevated/50",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:((s=e.agent)==null?void 0:s.trim())||"默认"}),a&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-fg-5",children:a})]}),o.jsx("div",{className:"mt-0.5 truncate text-sm text-fg-2",children:((l=e.title)==null?void 0:l.trim())||"未命名运行"})]})})}function w_({sessions:e,onSelect:t}){const a=Ge(d=>d.issues),s=new Map(a.map(d=>[d.id,d])),l=new Map,u=[];for(const d of e)if(d.issueId&&s.has(d.issueId)){const f=l.get(d.issueId)??[];f.push(d),l.set(d.issueId,f)}else u.push(d);return o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col border-t border-line",children:[o.jsxs("div",{className:"flex items-center gap-1.5 border-b border-line px-3 py-3",children:[o.jsx(Iv,{className:"h-3.5 w-3.5 text-fg-5"}),o.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-fg-4",children:"运行记录"}),o.jsx("span",{className:"ml-auto rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:e.length})]}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:e.length===0?o.jsx("p",{className:"px-2 py-4 text-center font-mono text-[10px] text-fg-6",children:"暂无运行记录"}):o.jsxs("div",{className:"space-y-3",children:[[...l.entries()].map(([d,f])=>{const m=s.get(d);return o.jsxs("div",{children:[o.jsxs("div",{className:"mb-1 flex items-center gap-1.5 px-1",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-medium",m.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",m.number]}),o.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-fg-3",children:m.title})]}),o.jsx("ul",{className:"space-y-0.5",children:f.map(h=>o.jsx(lE,{session:h,onSelect:()=>t(h.id)},h.id))})]},d)}),u.length>0&&o.jsxs("div",{children:[l.size>0&&o.jsx("div",{className:"mb-1 px-1",children:o.jsx("span",{className:"text-xs font-medium text-fg-5",children:"未关联 Issue"})}),o.jsx("ul",{className:"space-y-0.5",children:u.map(d=>o.jsx(lE,{session:d,onSelect:()=>t(d.id)},d.id))})]})]})})]})}function Hj({rootIssue:e,childrenMap:t,currentId:a,onSelect:s,sessions:l,onSessionSelect:u}){const{total:d,closed:f}=Pj(e.id,t),m=d===0?0:Math.round(f/d*100);return o.jsxs("div",{className:"flex w-full flex-col",children:[o.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[o.jsxs("div",{className:"flex items-center gap-1.5 border-b border-line px-3 py-3",children:[o.jsx(WA,{className:"h-3.5 w-3.5 text-fg-5"}),o.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-fg-4",children:"子任务树"})]}),d>0&&o.jsxs("div",{className:"border-b border-line px-3 py-2",children:[o.jsx("div",{className:"h-1 overflow-hidden rounded-full bg-elevated",children:o.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-emerald-400 to-blue-500 transition-all",style:{width:`${m}%`}})}),o.jsxs("p",{className:"mt-1 font-mono text-[10px] text-fg-6",children:[f," / ",d," completed"]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:o.jsx(C_,{issue:e,childrenMap:t,currentId:a,onSelect:s,depth:0})})]}),o.jsx(w_,{sessions:l,onSelect:u})]})}function Fj({sessions:e,onSessionSelect:t}){return o.jsx("div",{className:"flex w-full flex-col",children:o.jsx(w_,{sessions:e,onSelect:t})})}function zj(){const[e,t]=A.useState("open"),[a,s]=A.useState("stray"),[l,u]=A.useState(!1),[d,f]=A.useState(""),[m,h]=A.useState(null),[x,b]=A.useState(null),[y,T]=A.useState(!1),[N,v]=A.useState(!1),[S,C]=A.useState(null),[R,w]=A.useState(null),[D,K]=A.useState(null),[L,M]=PE(),V=Ge(H=>H.issues),W=Ge(H=>H.syncing),j=Ge(H=>H.syncIssues),U=Ge(H=>H.tags),J=Ge(H=>H.tagFilterMode),se=Ge(H=>H.cycleTagFilter),le=Ge(H=>H.clearTagFilter),re=Ge(H=>H.loadTags),Q=Ge(H=>H.milestones),F=Ge(H=>H.selectedMilestoneId),fe=Ge(H=>H.setMilestoneFilter),Ce=Ge(H=>H.loadMilestones),P=Fe(H=>H.activeRepoId),q=Ie(H=>H.sessions);A.useEffect(()=>{const H=L.get("issueId");H&&V.some(ve=>ve.id===H)&&(h(H),M({},{replace:!0}))},[L,M,V]),A.useEffect(()=>{P&&(re(),Ce())},[P,re,Ce]);const ae=new Map;for(const H of q)H.issueId&&!H.parentID&&ae.set(H.issueId,(ae.get(H.issueId)??0)+1);const I=new Set(V.filter(H=>H.parentId).map(H=>H.parentId)),Te=new Map;for(const H of V)if(H.parentId){const ve=Te.get(H.parentId);ve?ve.push(H):Te.set(H.parentId,[H])}function ke(H){return H.parentId?"task":I.has(H.id)?"epic":"stray"}const Re=new Map(Q.map(H=>[H.id,H])),Ye=e==="all"?V:V.filter(H=>H.state===e),dt=a==="all"?Ye:Ye.filter(H=>ke(H)===a),ut=J.size===0?dt:dt.filter(H=>{var ft;const ve=new Set((H.labels??[]).map(ln=>ln.name));for(const[ln,Wt]of J){const Ot=(ft=U.find(cn=>cn.id===ln))==null?void 0:ft.name;if(Ot&&(Wt==="include"&&!ve.has(Ot)||Wt==="exclude"&&ve.has(Ot)))return!1}return!0}),Ft=d.trim().toLowerCase(),Tn=Ft?ut.filter(H=>`#${H.number} ${H.title}`.toLowerCase().includes(Ft)):ut,da=F?Tn.filter(H=>H.milestoneId===F):Tn,Ca=R?da.filter(H=>H.authorLogin===R):da,un=D?Ca.filter(H=>(H.assignees??[]).some(ve=>ve.login===D)):Ca,Xn=(()=>{const H=new Map;for(const ve of V)ve.authorLogin&&!H.has(ve.authorLogin)&&H.set(ve.authorLogin,{login:ve.authorLogin,avatar:ve.authorAvatar});return[...H.values()]})(),Je=(()=>{const H=new Map;for(const ve of V)for(const ft of ve.assignees??[])H.has(ft.login)||H.set(ft.login,{login:ft.login,avatar:ft.avatar_url});return[...H.values()]})(),Ln=V.filter(H=>H.state==="open").length,wn=V.filter(H=>H.state==="closed").length,fa=Ye.filter(H=>ke(H)==="epic").length,wa=Ye.filter(H=>ke(H)==="task").length,er=Ye.filter(H=>ke(H)==="stray").length,Ba=V.find(H=>H.id===m)??null,wr=Aa(),_t=new Set;if(m&&(_t.add(m),x)){_t.add(x);const H=[...Te.get(x)??[]];for(let ve=0;ve<H.length;ve++){_t.add(H[ve].id);const ft=Te.get(H[ve].id);ft&&H.push(...ft)}}const tr=q.filter(H=>H.issueId&&_t.has(H.issueId)&&!H.parentID),ce=Fe(La),ye=H=>{Ie.setState({activeSessionId:H}),wr(`/${encodeURIComponent(ce)}/run`)},Pe=$T({onSwipeRight:()=>v(!0),onSwipeLeft:()=>T(!0),disabled:!m||N||y});return o.jsxs("div",{className:"flex min-h-0 flex-1",...Pe,children:[o.jsxs("div",{className:oe("shrink-0 flex-col bg-surface",m?"hidden md:flex md:w-80 border-r border-line":"flex w-full"),children:[m?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-line px-3 py-3",children:[o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-fg-3",children:"Issues"}),P&&o.jsx("div",{className:"flex items-center gap-1",children:o.jsx("button",{type:"button",onClick:()=>void j(),disabled:W,title:"同步",className:"flex h-7 w-7 items-center justify-center rounded-md text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2 disabled:opacity-40",children:o.jsx(Fs,{className:oe("h-3.5 w-3.5",W&&"animate-spin")})})})]}),l&&o.jsx(sE,{onDone:()=>u(!1)}),o.jsx("div",{className:"flex border-b border-line",children:rE.map(({key:H,label:ve})=>{const ft=H==="open"?Ln:H==="closed"?wn:V.length;return o.jsxs("button",{type:"button",onClick:()=>t(H),className:oe("flex flex-1 items-center justify-center gap-1.5 py-2 text-xs font-medium transition-colors",e===H?"border-b-2 border-blue-500 text-blue-500":"text-fg-4 hover:text-fg-2"),children:[ve,o.jsx("span",{className:oe("rounded-full px-1.5 py-0.5 font-mono text-[10px]",e===H?"bg-blue-500/10 text-blue-500":"bg-elevated text-fg-5"),children:ft})]},H)})}),o.jsx("div",{className:"border-b border-line px-3 py-2",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-line bg-base px-2 py-1",children:[o.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),o.jsx("input",{type:"text",value:d,onChange:H=>f(H.target.value),placeholder:"搜索 issue...",className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),d&&o.jsx("button",{type:"button",onClick:()=>f(""),className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})})]})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-2.5",children:[o.jsx("span",{className:"shrink-0 text-sm font-semibold text-fg",children:"Issues"}),o.jsx("div",{className:"flex shrink-0 items-center rounded-lg bg-elevated/60 p-0.5",children:rE.map(({key:H,label:ve})=>{const ft=H==="open"?Ln:H==="closed"?wn:V.length;return o.jsxs("button",{type:"button",onClick:()=>t(H),className:oe("flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",e===H?"bg-surface text-fg shadow-sm":"text-fg-4 hover:text-fg-2"),children:[ve,o.jsx("span",{className:oe("rounded-full px-1.5 py-0.5 font-mono text-[10px]",e===H?"bg-blue-500/10 text-blue-500":"text-fg-5"),children:ft})]},H)})}),o.jsx("div",{className:"mx-1 h-4 w-px shrink-0 bg-line"}),o.jsxs("button",{type:"button",onClick:()=>C(S==="type"?null:"type"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",S==="type"?"bg-elevated text-fg":a!=="all"?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["类型",a!=="all"&&o.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-400",children:a==="epic"?"Epic":a==="task"?"任务":"游离"}),o.jsx(Sr,{className:oe("h-3 w-3 transition-transform",S==="type"&&"rotate-180")})]}),o.jsxs("button",{type:"button",onClick:()=>C(S==="tag"?null:"tag"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",S==="tag"?"bg-elevated text-fg":J.size>0?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["标签",J.size>0&&o.jsx("span",{className:"rounded-full bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-400",children:J.size}),o.jsx(Sr,{className:oe("h-3 w-3 transition-transform",S==="tag"&&"rotate-180")})]}),o.jsxs("button",{type:"button",onClick:()=>C(S==="milestone"?null:"milestone"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",S==="milestone"?"bg-elevated text-fg":F?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["Milestone",F&&(()=>{const H=Q.find(ve=>ve.id===F);return H?o.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-400",children:H.title}):null})(),o.jsx(Sr,{className:oe("h-3 w-3 transition-transform",S==="milestone"&&"rotate-180")})]}),o.jsxs("button",{type:"button",onClick:()=>C(S==="author"?null:"author"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",S==="author"?"bg-elevated text-fg":R?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["Author",R&&o.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-400",children:R}),o.jsx(Sr,{className:oe("h-3 w-3 transition-transform",S==="author"&&"rotate-180")})]}),o.jsxs("button",{type:"button",onClick:()=>C(S==="assignee"?null:"assignee"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",S==="assignee"?"bg-elevated text-fg":D?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["Assignee",D&&o.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-400",children:D}),o.jsx(Sr,{className:oe("h-3 w-3 transition-transform",S==="assignee"&&"rotate-180")})]}),o.jsx("div",{className:"min-w-0 flex-1 px-1",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-line bg-base px-2.5 py-1.5",children:[o.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),o.jsx("input",{type:"text",value:d,onChange:H=>f(H.target.value),placeholder:"搜索 issue...",className:"min-w-0 flex-1 bg-transparent text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),d&&o.jsx("button",{type:"button",onClick:()=>f(""),className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})})]})}),P&&o.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.jsx("button",{type:"button",onClick:()=>void j(),disabled:W,title:"同步 Issues",className:"flex h-8 w-8 items-center justify-center rounded-md text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2 disabled:opacity-40",children:o.jsx(Fs,{className:oe("h-3.5 w-3.5",W&&"animate-spin")})}),o.jsx("button",{type:"button",onClick:()=>u(H=>!H),title:"新建 Issue",className:oe("flex h-8 w-8 items-center justify-center rounded-md transition-colors",l?"bg-blue-600 text-white":"text-fg-4 hover:bg-elevated hover:text-fg-2"),children:o.jsx(Xa,{className:"h-3.5 w-3.5"})})]})]}),S==="type"&&o.jsx("div",{className:"flex items-center gap-2 overflow-x-auto border-b border-line px-4 py-2",style:{scrollbarWidth:"none"},children:["epic","stray","task","all"].map(H=>{const ve=H==="epic"?"Epic":H==="stray"?"游离":H==="task"?"任务":"全部",ft=H==="epic"?fa:H==="stray"?er:H==="task"?wa:Ye.length,ln=a===H;return o.jsxs("button",{type:"button",onClick:()=>s(ln&&H!=="all"?"all":H),className:oe("flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-semibold transition-colors",ln?H==="epic"?"bg-amber-400/15 text-amber-400":H==="stray"?"bg-sky-400/15 text-sky-400":H==="task"?"bg-violet-400/15 text-violet-400":"bg-fg-6/20 text-fg-3":"bg-elevated/60 text-fg-5 hover:bg-elevated hover:text-fg-3"),children:[ve,o.jsx("span",{className:oe("rounded-full px-1.5 py-0.5 font-mono text-[10px] font-medium",ln?"opacity-70":"text-fg-6"),children:ft})]},H)})}),S==="tag"&&o.jsx("div",{className:"flex items-center gap-2 overflow-x-auto border-b border-line px-4 py-2",style:{scrollbarWidth:"none"},children:U.length===0?o.jsx("span",{className:"text-xs text-fg-5",children:"暂无标签"}):o.jsxs(o.Fragment,{children:[U.map(H=>{const ve=J.get(H.id);return o.jsxs("button",{type:"button",onClick:()=>se(H.id),className:oe("shrink-0 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",ve==="include"?"ring-1 ring-current shadow-sm":ve==="exclude"?"opacity-90 line-through decoration-2":"opacity-50 hover:opacity-80"),style:ve==="exclude"?{backgroundColor:`#${H.color}10`,color:`#${H.color}`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, #${H.color} 30%, transparent)`}:{backgroundColor:`#${H.color}18`,color:`#${H.color}`,boxShadow:ve==="include"?`inset 0 0 0 1px color-mix(in srgb, #${H.color} 50%, transparent)`:void 0},children:[ve==="exclude"&&o.jsx("span",{className:"mr-1 text-[10px]",children:"✕"}),H.name]},H.id)}),J.size>0&&o.jsx("button",{type:"button",onClick:le,className:"shrink-0 rounded-md px-2 py-1 text-[10px] text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3",children:"清除"})]})}),S==="milestone"&&o.jsx("div",{className:"flex items-center gap-2 overflow-x-auto border-b border-line px-4 py-2",style:{scrollbarWidth:"none"},children:Q.length===0?o.jsx("span",{className:"text-xs text-fg-5",children:"暂无里程碑"}):o.jsxs(o.Fragment,{children:[Q.map(H=>{const ve=F===H.id;return o.jsxs("button",{type:"button",onClick:()=>fe(ve?null:H.id),className:oe("shrink-0 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",ve?"bg-indigo-500/15 text-indigo-400 ring-1 ring-indigo-400/50 shadow-sm":"bg-elevated/60 text-fg-5 hover:bg-elevated hover:text-fg-3"),children:[H.title,H.state==="closed"&&o.jsx("span",{className:"ml-1 text-[10px] opacity-60",children:"✓"})]},H.id)}),F&&o.jsx("button",{type:"button",onClick:()=>fe(null),className:"shrink-0 rounded-md px-2 py-1 text-[10px] text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3",children:"清除"})]})}),S==="author"&&o.jsx("div",{className:"flex items-center gap-2 overflow-x-auto border-b border-line px-4 py-2",style:{scrollbarWidth:"none"},children:Xn.length===0?o.jsx("span",{className:"text-xs text-fg-5",children:"同步后可见作者"}):o.jsxs(o.Fragment,{children:[Xn.map(H=>o.jsxs("button",{type:"button",onClick:()=>w(R===H.login?null:H.login),className:oe("flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",R===H.login?"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30 shadow-sm":"bg-elevated/60 text-fg-5 hover:bg-elevated hover:text-fg-3"),children:[H.avatar&&o.jsx("img",{src:H.avatar,alt:"",className:"h-4 w-4 rounded-full"}),H.login]},H.login)),R&&o.jsx("button",{type:"button",onClick:()=>w(null),className:"shrink-0 rounded-md px-2 py-1 text-[10px] text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3",children:"清除"})]})}),S==="assignee"&&o.jsx("div",{className:"flex items-center gap-2 overflow-x-auto border-b border-line px-4 py-2",style:{scrollbarWidth:"none"},children:Je.length===0?o.jsx("span",{className:"text-xs text-fg-5",children:"同步后可见指派人"}):o.jsxs(o.Fragment,{children:[Je.map(H=>o.jsxs("button",{type:"button",onClick:()=>K(D===H.login?null:H.login),className:oe("flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",D===H.login?"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30 shadow-sm":"bg-elevated/60 text-fg-5 hover:bg-elevated hover:text-fg-3"),children:[H.avatar&&o.jsx("img",{src:H.avatar,alt:"",className:"h-4 w-4 rounded-full"}),H.login]},H.login)),D&&o.jsx("button",{type:"button",onClick:()=>K(null),className:"shrink-0 rounded-md px-2 py-1 text-[10px] text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3",children:"清除"})]})}),l&&o.jsx(sE,{onDone:()=>u(!1)})]}),o.jsx("div",{className:oe("flex-1 overflow-y-auto",m?"px-2 py-2":"px-3 py-3"),children:P?un.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:V.length===0?"点击 ↻ 同步 Issues":"无匹配 Issue"}):o.jsx("ul",{className:oe(m?"space-y-0.5":"space-y-1"),children:un.map(H=>m?o.jsx(iE,{issue:H,sessionCount:ae.get(H.id)??0,isActive:m===H.id,isEpic:ke(H)==="epic",milestone:H.milestoneId?Re.get(H.milestoneId):void 0,onSelect:()=>{h(H.id),b(ke(H)==="epic"?H.id:null)}},H.id):o.jsx(jj,{issue:H,sessionCount:ae.get(H.id)??0,isEpic:ke(H)==="epic",milestone:H.milestoneId?Re.get(H.milestoneId):void 0,onSelect:()=>{h(H.id),b(ke(H)==="epic"?H.id:null)}},H.id))}):o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:"请先选择一个仓库"})})]}),m&&o.jsx(dh,{side:"left",open:N,onClose:()=>v(!1),children:o.jsxs("div",{className:"flex h-full flex-col",children:[o.jsx("div",{className:"border-b border-line px-3 py-3",children:o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-fg-3",children:"Issues"})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:un.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:"无匹配 Issue"}):o.jsx("ul",{className:"space-y-0.5",children:un.map(H=>o.jsx(iE,{issue:H,sessionCount:ae.get(H.id)??0,isActive:m===H.id,isEpic:ke(H)==="epic",milestone:H.milestoneId?Re.get(H.milestoneId):void 0,onSelect:()=>{h(H.id),b(ke(H)==="epic"?H.id:null),v(!1)}},H.id))})})]})}),m&&o.jsx("div",{className:"relative flex min-w-0 flex-1 flex-col bg-term",children:Ba?o.jsxs(o.Fragment,{children:[o.jsx(Bj,{issue:Ba,milestone:Ba.milestoneId?Re.get(Ba.milestoneId):void 0,onBack:()=>{h(null),b(null),T(!1)},onClose:()=>{h(null),b(null),T(!1)},onToggleSidebar:()=>T(H=>!H)}),y&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"absolute inset-0 z-10 bg-black/30",onClick:()=>T(!1)}),o.jsxs("div",{className:"absolute right-0 top-0 bottom-0 z-20 flex w-[280px] flex-col border-l border-line bg-surface shadow-xl",children:[o.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-line px-3 py-2.5",children:[o.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-fg-4",children:x?"子任务树 & 运行记录":"运行记录"}),o.jsx("button",{type:"button",onClick:()=>T(!1),className:"flex h-6 w-6 items-center justify-center rounded-md text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:o.jsx(gt,{className:"h-4 w-4"})})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:x?(()=>{const H=V.find(ve=>ve.id===x);return H?o.jsx(Hj,{rootIssue:H,childrenMap:Te,currentId:m,onSelect:ve=>{h(ve),T(!1)},sessions:tr,onSessionSelect:ye}):null})():o.jsx(Fj,{sessions:tr,onSessionSelect:ye})})]})]})]}):o.jsx("div",{className:"flex flex-1 items-center justify-center",children:o.jsx("p",{className:"font-mono text-xs text-fg-5",children:"Issue 未找到"})})})]})}const oE=[{key:"open",label:"开放"},{key:"merged",label:"已合并"},{key:"closed",label:"已关闭"},{key:"all",label:"全部"}];function k_(e){const t=e<1e12?e*1e3:e,a=Date.now()-t;return a<6e4?"刚刚":a<36e5?`${Math.floor(a/6e4)}分钟前`:a<864e5?`${Math.floor(a/36e5)}小时前`:a<2592e6?`${Math.floor(a/864e5)}天前`:new Date(t).toLocaleDateString("zh-CN",{month:"short",day:"numeric"})}function qj(e){return e==="merged"?"bg-purple-500/15 text-purple-400":e==="closed"?"bg-red-500/15 text-red-400":"bg-emerald-500/15 text-emerald-400"}function Yj({pr:e,isActive:t,onSelect:a}){return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:a,className:oe("group flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left transition-colors",t?"border-l-2 border-blue-500 bg-elevated/80":"border-l-2 border-transparent hover:bg-elevated/50"),children:[o.jsx("span",{className:oe("flex h-10 w-10 shrink-0 items-center justify-center rounded-full font-mono text-sm font-bold ring-1",e.state==="merged"?"bg-gradient-to-br from-purple-500/20 to-purple-500/5 text-purple-400 ring-purple-500/25":e.state==="closed"?"bg-gradient-to-br from-red-500/20 to-red-500/5 text-red-400 ring-red-500/25":"bg-gradient-to-br from-emerald-500/20 to-emerald-500/5 text-emerald-400 ring-emerald-500/25"),children:e.number}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[e.draft===1&&o.jsx("span",{className:"shrink-0 rounded px-1 py-0.5 text-[9px] font-bold bg-fg-6/15 text-fg-4",children:"DRAFT"}),o.jsx("span",{className:"min-w-0 text-xs font-medium text-fg-2 group-hover:text-fg",children:e.title})]}),o.jsxs("div",{className:"mt-0.5 truncate font-mono text-[10px] text-fg-6",children:[e.headBranch," → ",e.baseBranch]}),e.labels&&e.labels.length>0&&o.jsx("div",{className:"mt-1 flex flex-wrap gap-1",children:e.labels.map(s=>o.jsx("span",{className:"rounded px-1 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${s.color}20`,color:`#${s.color}`},children:s.name},s.id))})]})]})})}function $j({pr:e,onSelect:t}){return o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:t,className:"group flex w-full items-center gap-3 border-b border-line px-4 py-3 text-left transition-colors hover:bg-elevated/50",children:[o.jsx("span",{className:oe("flex h-10 w-10 shrink-0 items-center justify-center rounded-full font-mono text-sm font-bold ring-1",e.state==="merged"?"bg-gradient-to-br from-purple-500/20 to-purple-500/5 text-purple-400 ring-purple-500/25":e.state==="closed"?"bg-gradient-to-br from-red-500/20 to-red-500/5 text-red-400 ring-red-500/25":"bg-gradient-to-br from-emerald-500/20 to-emerald-500/5 text-emerald-400 ring-emerald-500/25"),children:e.number}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[e.draft===1&&o.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[9px] font-bold tracking-wide bg-fg-6/15 text-fg-4",children:"DRAFT"}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-fg-2 group-hover:text-fg",children:e.title}),e.mergeable==="false"&&e.state==="open"&&o.jsxs("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold bg-red-500/15 text-red-400",children:[o.jsx(Dn,{className:"inline h-3 w-3 -mt-px"})," Conflict"]}),e.assignees&&e.assignees.length>0&&o.jsx("div",{className:"hidden shrink-0 items-center -space-x-1.5 sm:flex",children:e.assignees.slice(0,3).map(a=>o.jsx("img",{src:a.avatar_url,alt:a.login,title:a.login,className:"h-5 w-5 rounded-full ring-2 ring-surface"},a.login))})]}),o.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[o.jsxs("span",{className:"shrink-0 font-mono text-[11px] text-fg-5",children:[e.headBranch," → ",e.baseBranch]}),o.jsx("span",{className:"text-fg-6",children:"·"}),e.authorLogin&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"shrink-0 text-[11px] text-fg-5",title:e.authorLogin,children:[e.authorAvatar&&o.jsx("img",{src:e.authorAvatar,alt:"",className:"mr-1 inline-block h-3.5 w-3.5 rounded-full align-text-bottom"}),e.authorLogin]}),o.jsx("span",{className:"text-fg-6",children:"·"})]}),o.jsx("span",{className:"shrink-0 text-[11px] text-fg-6",children:k_(e.createdAt)}),e.labels&&e.labels.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-fg-6",children:"·"}),e.labels.map(a=>o.jsx("span",{className:"rounded px-1.5 py-0.5 text-[11px] font-medium",style:{backgroundColor:`#${a.color}20`,color:`#${a.color}`},children:a.name},a.id))]})]})]})]})})}function Gj({issue:e,linked:t,onToggle:a}){return o.jsx("li",{children:o.jsx("button",{type:"button",onClick:a,className:oe("group flex w-full items-start gap-2 rounded-md px-3 py-2.5 text-left transition-colors",t?"border-l-2 border-emerald-500 bg-emerald-500/5":"border-l-2 border-transparent hover:bg-elevated/50"),children:o.jsx("div",{className:"min-w-0 flex-1",children:o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-xs font-medium",e.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",e.number]}),o.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-fg-2",children:e.title}),t&&o.jsx(Bc,{className:"ml-auto h-3.5 w-3.5 shrink-0 text-emerald-400"})]})})})})}function Kj({pr:e,onBack:t,onClose:a,onEnterMatch:s}){var w;const l=Fe(D=>D.activeRepoId),u=Fe(La),[d,f]=A.useState(!1),[m,h]=A.useState([]),[x,b]=A.useState(!1),[y,T]=A.useState([]),N=Aa(),v=Vn(D=>D.unlinkIssue);A.useEffect(()=>{l&&(b(!0),pC(l,e.number).then(h).catch(()=>h([])).finally(()=>b(!1)))},[l,e.number]),A.useEffect(()=>{l&&oy(l,e.number).then(T).catch(()=>T([]))},[l,e.number]);const S=async D=>{if(!(d||!l)){f(!0);try{if(await fC(l,e.number),D&&y.length>0){const K=y.filter(L=>L.state==="open");await Promise.all(K.map(L=>ly(l,L.number,{state:"closed"}))),T(L=>L.map(M=>M.state==="open"?{...M,state:"closed"}:M)),Ge.getState().loadIssues(),Yt.getState().addToast(`PR #${e.number} 合入成功,已关闭 ${K.length} 个 Issue`,"success")}else Yt.getState().addToast(`PR #${e.number} 合入成功`,"success");Vn.getState().loadPulls()}catch(K){let L="合入失败";if(K instanceof Qa)try{L=JSON.parse(K.message).error??L}catch{L=K.message}Yt.getState().addToast(L,"error")}finally{f(!1)}}},C=async D=>{await v(e.number,D)&&T(L=>L.filter(M=>M.number!==D))},R=D=>{const K=new Date(D);return K.toLocaleDateString("zh-CN",{month:"short",day:"numeric"})+" "+K.toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit"})};return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[o.jsxs("header",{className:"flex flex-col gap-2 border-b border-line px-4 py-3 md:flex-row md:items-center md:gap-3 md:px-6",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[o.jsx("button",{type:"button",onClick:t,"aria-label":"返回列表",className:"-ml-1 shrink-0 rounded-md p-1.5 text-fg-3 transition-colors hover:bg-elevated hover:text-fg md:hidden",children:o.jsx(Oh,{className:"h-5 w-5"})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-semibold",qj(e.state)),children:["#",e.number," ",e.state]}),e.draft===1&&o.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-bold bg-fg-6/15 text-fg-4",children:"DRAFT"}),e.mergeable==="false"&&e.state==="open"&&o.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold bg-red-500/15 text-red-400",children:"Conflict"}),(w=e.labels)==null?void 0:w.map(D=>o.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${D.color}20`,color:`#${D.color}`},children:D.name},D.id))]}),o.jsx("h2",{className:"mt-1 text-base font-semibold text-fg",children:e.title}),o.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2 text-xs text-fg-4",children:[o.jsxs("span",{className:"flex min-w-0 items-center gap-1 font-mono text-[11px] text-fg-5",children:[o.jsx(ho,{className:"h-3.5 w-3.5 shrink-0"}),o.jsxs("span",{className:"truncate",children:[e.headBranch," → ",e.baseBranch]})]}),e.authorLogin&&o.jsxs("span",{className:"flex items-center gap-1.5",children:[e.authorAvatar&&o.jsx("img",{src:e.authorAvatar,alt:"",className:"h-4 w-4 rounded-full"}),e.authorLogin]}),e.mergedAt&&o.jsxs("span",{className:"text-purple-400",children:["合并于 ",k_(e.mergedAt)]})]})]})]}),o.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[e.htmlUrl&&o.jsxs("a",{href:e.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 font-mono text-xs text-fg-3 transition-colors hover:border-fg-5 hover:text-fg",children:[o.jsx(pc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"源站"})]}),o.jsxs("button",{type:"button",onClick:s,className:"flex h-8 items-center gap-1.5 rounded-md border border-line px-2.5 text-xs text-fg-3 transition-colors hover:border-blue-500/50 hover:text-blue-400",children:[o.jsx(Bc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"关联 Issue"})]}),e.state==="open"&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",disabled:d||e.mergeable==="false",onClick:()=>void S(!1),className:"flex h-8 items-center gap-1.5 rounded-md border border-emerald-500/30 px-2.5 text-xs font-medium text-emerald-400 transition-colors hover:border-emerald-500/60 hover:bg-emerald-500/10 disabled:opacity-40",children:[o.jsx(gc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"合入"})]}),y.some(D=>D.state==="open")&&o.jsxs("button",{type:"button",disabled:d||e.mergeable==="false",onClick:()=>void S(!0),className:"flex h-8 items-center gap-1.5 rounded-md bg-blue-600 px-3 text-xs font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-40",children:[o.jsx(gc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"合入并关闭 Issues"})]})]}),a&&o.jsx("button",{type:"button",onClick:a,title:"关闭详情",className:"hidden h-8 w-8 items-center justify-center rounded-md border border-line text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-2 md:flex",children:o.jsx(gt,{className:"h-4 w-4"})})]})]}),o.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-6 md:px-6",children:[y.length>0&&o.jsxs("div",{className:"mb-6 rounded-lg border border-line bg-elevated/30 px-4 py-3",children:[o.jsxs("h3",{className:"mb-2 flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-fg-4",children:[o.jsx(mo,{className:"h-3.5 w-3.5"}),"关联 Issues (",y.length,")"]}),o.jsx("div",{className:"space-y-1.5",children:y.map(D=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>N(`/${encodeURIComponent(u)}/issues?issueId=${encodeURIComponent(D.id)}`),className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-0.5 transition-colors hover:bg-elevated/60",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1.5 py-0.5 font-mono text-[10px] font-medium",D.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",D.number]}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-left text-sm text-fg-2",children:D.title})]}),o.jsx("button",{type:"button",onClick:()=>void C(D.number),title:"取消关联",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:bg-red-500/10 hover:text-red-400",children:o.jsx(zE,{className:"h-3.5 w-3.5"})})]},D.id))})]}),e.body?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[co],children:e.body})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"该 PR 没有描述内容"}),x?o.jsx("p",{className:"mt-8 text-center font-mono text-xs text-fg-6",children:"加载评论…"}):m.length>0&&o.jsxs("div",{className:"mt-8 border-t border-line pt-6",children:[o.jsxs("h3",{className:"mb-4 text-xs font-semibold uppercase tracking-wider text-fg-4",children:["评论 (",m.length,")"]}),o.jsx("div",{className:"space-y-4",children:m.map(D=>o.jsxs("div",{className:"rounded-lg border border-line bg-elevated/40 px-4 py-3",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("img",{src:D.user.avatar_url,alt:D.user.login,className:"h-5 w-5 rounded-full"}),o.jsx("span",{className:"text-xs font-semibold text-fg-2",children:D.user.login}),o.jsx("span",{className:"text-[10px] text-fg-6",children:R(D.created_at)})]}),o.jsx("div",{className:"markdown-body mt-2 text-sm leading-relaxed text-fg-3",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[co],children:D.body})})]},D.id))})]})]})})]})}function Vj(){const[e,t]=A.useState("open"),[a,s]=A.useState(""),[l,u]=A.useState(null),[d,f]=A.useState(""),[m,h]=PE(),x=Vn(F=>F.pulls),b=Vn(F=>F.syncing),y=Vn(F=>F.syncPulls),T=Vn(F=>F.matchingPrId),N=Vn(F=>F.enterMatchMode),v=Vn(F=>F.exitMatchMode),S=Vn(F=>F.linkIssue),C=Fe(F=>F.activeRepoId),R=Ge(F=>F.issues);A.useEffect(()=>{const F=m.get("prId");F&&x.some(fe=>fe.id===F)&&(u(F),h({},{replace:!0}))},[m,h,x]);const w=T?x.find(F=>F.id===T)??null:null,[D,K]=A.useState(new Set);A.useEffect(()=>{if(!C||!w){K(new Set);return}oy(C,w.number).then(F=>K(new Set(F.map(fe=>fe.id)))).catch(()=>K(new Set))},[C,w]);const L=async F=>{if(!w)return;D.has(F.id)?await Vn.getState().unlinkIssue(w.number,F.number)&&K(P=>{const q=new Set(P);return q.delete(F.id),q}):await S(w.number,F.number)&&K(P=>new Set(P).add(F.id))},M=x.filter(F=>F.state==="open").length,V=x.filter(F=>F.state==="merged").length,W=x.filter(F=>F.state==="closed").length,j=e==="all"?x:x.filter(F=>F.state===e),U=a.trim().toLowerCase(),J=U?j.filter(F=>`#${F.number} ${F.title} ${F.headBranch} ${F.baseBranch}`.toLowerCase().includes(U)):j,se=d.trim().toLowerCase(),le=se?R.filter(F=>`#${F.number} ${F.title}`.toLowerCase().includes(se)):R,re=x.find(F=>F.id===l)??null,Q=w??re;return o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsxs("div",{className:oe("shrink-0 flex-col bg-surface",Q?"hidden md:flex md:w-80 border-r border-line":"flex w-full"),children:[T?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-line px-3 py-3",children:[o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-blue-400",children:"选择 Issue 关联"}),o.jsxs("button",{type:"button",onClick:v,className:"flex h-7 items-center gap-1 rounded-md px-2 text-xs text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2",children:[o.jsx(gt,{className:"h-3.5 w-3.5"}),"完成"]})]}),o.jsx("div",{className:"border-b border-line px-3 py-2",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-line bg-base px-2 py-1",children:[o.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),o.jsx("input",{type:"text",value:d,onChange:F=>f(F.target.value),placeholder:"搜索 issue...",className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),d&&o.jsx("button",{type:"button",onClick:()=>f(""),className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:le.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:R.length===0?"暂无 Issue,请先同步":"无匹配 Issue"}):o.jsx("ul",{className:"space-y-0.5",children:le.map(F=>o.jsx(Gj,{issue:F,linked:D.has(F.id),onToggle:()=>void L(F)},F.id))})})]}):Q?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex items-center justify-between border-b border-line px-3 py-3",children:[o.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-fg-3",children:"Pull Requests"}),C&&o.jsx("button",{type:"button",onClick:()=>void y(),disabled:b,title:"同步",className:"flex h-7 w-7 items-center justify-center rounded-md text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2 disabled:opacity-40",children:o.jsx(Fs,{className:oe("h-3.5 w-3.5",b&&"animate-spin")})})]}),o.jsx("div",{className:"flex border-b border-line",children:oE.map(({key:F,label:fe})=>{const Ce=F==="open"?M:F==="merged"?V:F==="closed"?W:x.length;return o.jsxs("button",{type:"button",onClick:()=>t(F),className:oe("flex flex-1 items-center justify-center gap-1.5 py-2 text-xs font-medium transition-colors",e===F?"border-b-2 border-blue-500 text-blue-500":"text-fg-4 hover:text-fg-2"),children:[fe,o.jsx("span",{className:oe("rounded-full px-1.5 py-0.5 font-mono text-[10px]",e===F?"bg-blue-500/10 text-blue-500":"bg-elevated text-fg-5"),children:Ce})]},F)})}),o.jsx("div",{className:"border-b border-line px-3 py-2",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-line bg-base px-2 py-1",children:[o.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),o.jsx("input",{type:"text",value:a,onChange:F=>s(F.target.value),placeholder:"搜索 PR...",className:"min-w-0 flex-1 bg-transparent font-mono text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),a&&o.jsx("button",{type:"button",onClick:()=>s(""),className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})})]})})]}):o.jsx(o.Fragment,{children:o.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-2.5",children:[o.jsx("span",{className:"shrink-0 text-sm font-semibold text-fg",children:"Pull Requests"}),o.jsx("div",{className:"flex shrink-0 items-center rounded-lg bg-elevated/60 p-0.5",children:oE.map(({key:F,label:fe})=>{const Ce=F==="open"?M:F==="merged"?V:F==="closed"?W:x.length;return o.jsxs("button",{type:"button",onClick:()=>t(F),className:oe("flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",e===F?"bg-surface text-fg shadow-sm":"text-fg-4 hover:text-fg-2"),children:[fe,o.jsx("span",{className:oe("rounded-full px-1.5 py-0.5 font-mono text-[10px]",e===F?"bg-blue-500/10 text-blue-500":"text-fg-5"),children:Ce})]},F)})}),o.jsx("div",{className:"min-w-0 flex-1 px-1",children:o.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-line bg-base px-2.5 py-1.5",children:[o.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),o.jsx("input",{type:"text",value:a,onChange:F=>s(F.target.value),placeholder:"搜索 PR...",className:"min-w-0 flex-1 bg-transparent text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),a&&o.jsx("button",{type:"button",onClick:()=>s(""),className:"shrink-0 text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})})]})}),o.jsx("button",{type:"button",onClick:()=>void y(),disabled:b||!C,title:"同步 PR",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-line text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-2 disabled:opacity-40",children:o.jsx(Fs,{className:oe("h-4 w-4",b&&"animate-spin")})})]})}),!T&&o.jsx("div",{className:oe("flex-1 overflow-y-auto",Q?"px-2 py-2":"px-3 py-3"),children:C?J.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-16 text-fg-5",children:[o.jsx(ho,{className:"h-8 w-8"}),o.jsx("p",{className:"font-mono text-xs",children:x.length===0?"点击 ↻ 同步 PR":"没有匹配的 PR"})]}):o.jsx("ul",{className:oe(Q?"space-y-0.5":"space-y-1"),children:J.map(F=>Q?o.jsx(Yj,{pr:F,isActive:F.id===(l??T),onSelect:()=>u(F.id)},F.id):o.jsx($j,{pr:F,onSelect:()=>u(F.id)},F.id))}):o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:"请先选择一个仓库"})})]}),Q?o.jsx(Kj,{pr:Q,onBack:()=>{u(null),T&&v()},onClose:()=>{u(null),T&&v()},onEnterMatch:()=>N(Q.id)},`${Q.id}-${T??"view"}`):o.jsx("div",{className:"hidden flex-1 items-center justify-center md:flex",children:o.jsxs("div",{className:"text-center text-fg-5",children:[o.jsx(ho,{className:"mx-auto h-12 w-12 opacity-20"}),o.jsx("p",{className:"mt-3 font-mono text-xs",children:"选择一个 PR 查看详情"})]})})]})}let _r=null;function Qj(e){const t=Date.now()-e,a=Math.floor(t/6e4);return a<1?"刚刚":a<60?`${a} 分钟前`:`${Math.floor(a/60)} 小时前`}const uE=[{id:"usage",label:"Claude 账号",icon:Dh},{id:"git",label:"Git 源站",icon:Ys},{id:"models",label:"模型",icon:lc},{id:"custom-agents",label:"Custom Agents",icon:qv},{id:"agents",label:"AGENTS.md",icon:YE}],Xj={id:"server",label:"服务器",icon:WE};function xh(e){if(!e)return null;const t=new Date(e).getTime()-Date.now();if(t<=0)return"已重置";const a=Math.floor(t/36e5),s=Math.floor(t%36e5/6e4);return a>0?`${a}h ${s}m 后重置`:`${s}m 后重置`}function Wj(e){return e>=90?"bg-red-500":e>=70?"bg-amber-500":"bg-blue-500"}function zm({label:e,window:t}){if(!t)return null;const a=Math.round(t.utilization),s=xh(t.resets_at),l=a>=90,u=a>=70;return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-fg-3",children:e}),o.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s&&o.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-elevated px-1.5 py-0.5 text-[10px] font-medium text-fg-4 tabular-nums",children:[o.jsx(dA,{className:"h-2.5 w-2.5"}),s]}),o.jsxs("span",{className:oe("text-sm font-bold leading-none tabular-nums",l?"text-red-400":u?"text-amber-400":"text-fg"),children:[a,"%"]})]})]}),o.jsx("div",{className:"h-2.5 overflow-hidden rounded-full bg-elevated ring-1 ring-inset ring-line/60",children:o.jsx("div",{className:oe("h-full rounded-full transition-all duration-500 ease-out",Wj(a),l?"shadow-sm shadow-red-500/50":u?"shadow-sm shadow-amber-500/40":null),style:{width:`${Math.min(a,100)}%`}})})]})}function Zj({account:e,onSwitch:t,switching:a}){var l;const s=e.active;return o.jsxs("div",{className:oe("relative overflow-hidden rounded-xl border bg-base p-4 shadow-sm transition-colors",s?"border-blue-500/30 ring-1 ring-inset ring-blue-500/20":"border-line"),children:[s&&o.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1 bg-blue-500"}),o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx("div",{className:oe("flex h-7 w-7 shrink-0 items-center justify-center rounded-lg",s?"bg-blue-500/15 text-blue-500":"bg-elevated text-fg-4"),children:o.jsx(QE,{className:"h-3.5 w-3.5"})}),o.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.label}),s&&o.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 rounded-full bg-blue-500/15 px-2 py-0.5 text-[10px] font-semibold text-blue-500",children:[o.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-blue-500 shadow-sm shadow-blue-500/60"}),"当前"]}),!s&&t&&o.jsxs("button",{type:"button",onClick:()=>t(e.id),disabled:a,className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-line px-2 py-0.5 text-[10px] font-medium text-fg-4 transition-colors hover:border-blue-500/50 hover:text-blue-500 disabled:opacity-40",children:[a&&o.jsx(Sa,{className:"h-2.5 w-2.5 fs-spin"}),"切换"]}),e.excluded&&o.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-elevated px-2 py-0.5 text-[10px] font-medium text-fg-5",children:[o.jsx(Fv,{className:"h-2.5 w-2.5"}),"不自动切"]}),e.needsReauth&&o.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full bg-red-500/15 px-2 py-0.5 text-[10px] font-medium text-red-400",children:[o.jsx(Dn,{className:"h-2.5 w-2.5"}),"需重新登录"]})]}),e.holders&&e.holders.length>0&&o.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-fg-5",children:[o.jsx(XE,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"truncate",children:e.holders.join(", ")})]}),e.error&&!e.usage?o.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg bg-red-500/10 px-3 py-2 text-xs text-red-400",children:[o.jsx(Dn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"min-w-0 break-words",children:e.error})]}):e.usage?o.jsxs("div",{className:"mt-4 space-y-3",children:[o.jsx(zm,{label:"5 小时窗口",window:e.usage.five_hour}),o.jsx(zm,{label:"7 天窗口",window:e.usage.seven_day}),(l=e.usage.scoped)==null?void 0:l.map(u=>o.jsx(zm,{label:u.label,window:u},u.label))]}):null]})}function Jj(){const[e,t]=A.useState((_r==null?void 0:_r.data)??null),[a,s]=A.useState(!_r),[l,u]=A.useState(null),[d,f]=A.useState(null),[m,h]=A.useState((_r==null?void 0:_r.fetchedAt)??null),[,x]=A.useState(0),b=A.useCallback(v=>{const S=Date.now();_r={data:v,fetchedAt:S},t(v),h(S)},[]),y=A.useCallback(()=>{s(!0),u(null),uy().then(v=>{b(v),s(!1)}).catch(v=>{u(v instanceof Error?v.message:String(v)),s(!1)})},[b]);A.useEffect(()=>{_r||y()},[y]),A.useEffect(()=>{const v=setInterval(()=>x(S=>S+1),3e4);return()=>clearInterval(v)},[]);const T=A.useRef(!1),N=A.useCallback(v=>{T.current||(T.current=!0,f(v),cy(v).then(S=>{b(S),f(null)}).catch(S=>{u(S instanceof Error?S.message:String(S)),f(null)}).finally(()=>{T.current=!1}))},[b]);return o.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[o.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-blue-500/10 text-blue-500",children:o.jsx(vA,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Claude 订阅额度"}),o.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"各账号的 Pro/Max 订阅窗口用量。"})]})]}),o.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m&&o.jsx("span",{className:"text-[10px] tabular-nums text-fg-5",children:Qj(m)}),o.jsx("button",{type:"button",onClick:y,disabled:a,className:"rounded-md p-1.5 text-fg-4 transition-colors hover:bg-elevated hover:text-fg-2 disabled:opacity-40",children:o.jsx(Fs,{className:oe("h-4 w-4",a&&"fs-spin")})})]})]}),o.jsx("div",{className:"mt-4 space-y-2.5",children:a&&!e?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[o.jsx(Sa,{className:"h-5 w-5 fs-spin"}),o.jsx("p",{className:"text-xs",children:"加载中…"})]}):l&&!e?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-red-400",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-500/10",children:o.jsx(Dn,{className:"h-5 w-5"})}),o.jsx("p",{className:"max-w-xs text-center text-xs leading-relaxed",children:l})]}):e&&e.accounts.length===0?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[o.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-elevated text-fg-4",children:o.jsx(XE,{className:"h-5 w-5"})}),o.jsx("p",{className:"max-w-xs text-center text-xs leading-relaxed",children:"未找到账号。请在 OpenCode TUI 中通过 claude-accounts-usage 插件登录。"})]}):e?e.accounts.map(v=>o.jsx(Zj,{account:v,onSwitch:N,switching:d===v.id},v.id)):null})]})}function e9({host:e,onDelete:t}){const[a,s]=A.useState(!1);return o.jsxs("div",{className:"group flex items-center gap-3 rounded-lg border border-line bg-base px-4 py-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-medium text-fg",children:e.name}),o.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-4",children:e.platform})]}),o.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-xs text-fg-4",children:[o.jsx("span",{children:e.host}),o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsx("span",{className:"text-fg-5",children:e.token})]})]}),a?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{type:"button",onClick:t,className:"rounded p-1.5 text-red-400 hover:bg-red-500/10",children:o.jsx(oa,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>s(!1),className:"rounded p-1.5 text-fg-4 hover:bg-elevated",children:o.jsx(gt,{className:"h-4 w-4"})})]}):o.jsx("button",{type:"button",onClick:()=>s(!0),className:"rounded p-1.5 text-fg-5 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:o.jsx(zs,{className:"h-4 w-4"})})]})}function t9({onAdded:e}){const[t,a]=A.useState(!1),[s,l]=A.useState(""),[u,d]=A.useState(""),[f,m]=A.useState(""),[h,x]=A.useState("gitea"),[b,y]=A.useState(!1),[T,N]=A.useState(!1),v=()=>{l(""),d(""),m(""),x("gitea"),a(!1)},S=async()=>{if(!(!s.trim()||!u.trim()||!f.trim())){y(!0);try{await kC(s.trim(),u.trim(),f.trim(),h),v(),e()}finally{y(!1)}}};return t?o.jsxs("div",{className:"space-y-3 rounded-lg border border-line bg-base p-4",children:[o.jsxs("div",{className:"flex gap-3",children:[o.jsxs("label",{className:"flex-1",children:[o.jsx("span",{className:"text-xs font-medium text-fg-3",children:"名称"}),o.jsx("input",{type:"text",value:u,onChange:C=>d(C.target.value),placeholder:"公司 Gitea",className:"mt-1 w-full rounded-md border border-line bg-surface px-3 py-1.5 text-sm text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"})]}),o.jsxs("label",{className:"w-28",children:[o.jsx("span",{className:"text-xs font-medium text-fg-3",children:"平台"}),o.jsxs("select",{value:h,onChange:C=>x(C.target.value),className:"mt-1 w-full rounded-md border border-line bg-surface px-3 py-1.5 text-sm text-fg focus:border-blue-500 focus:outline-none",children:[o.jsx("option",{value:"gitea",children:"Gitea"}),o.jsx("option",{value:"github",children:"GitHub"}),o.jsx("option",{value:"gitlab",children:"GitLab"})]})]})]}),o.jsxs("label",{className:"block",children:[o.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Host"}),o.jsx("input",{type:"text",value:s,onChange:C=>l(C.target.value),placeholder:"git.btsai.work",className:"mt-1 w-full rounded-md border border-line bg-surface px-3 py-1.5 font-mono text-sm text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"})]}),o.jsxs("label",{className:"block",children:[o.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Token"}),o.jsxs("div",{className:"relative mt-1",children:[o.jsx("input",{type:T?"text":"password",value:f,onChange:C=>m(C.target.value),placeholder:"Personal Access Token",className:"w-full rounded-md border border-line bg-surface px-3 py-1.5 pr-9 font-mono text-sm text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"}),o.jsx("button",{type:"button",onClick:()=>N(!T),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-fg-5 hover:text-fg-3",children:T?o.jsx(EA,{className:"h-3.5 w-3.5"}):o.jsx(TA,{className:"h-3.5 w-3.5"})})]})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[o.jsx("button",{type:"button",onClick:v,className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),o.jsx("button",{type:"button",onClick:()=>void S(),disabled:b||!s.trim()||!u.trim()||!f.trim(),className:"rounded-md bg-blue-600 px-4 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-40",children:b?"保存中…":"保存"})]})]}):o.jsxs("button",{type:"button",onClick:()=>a(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-line py-2.5 text-xs text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-3",children:[o.jsx(Xa,{className:"h-3.5 w-3.5"})," 添加 Git 源站"]})}function n9(){const[e,t]=A.useState(""),[a,s]=A.useState(""),[l,u]=A.useState(!0),[d,f]=A.useState(!1),[m,h]=A.useState(null);A.useEffect(()=>{yC().then(y=>{t(y.content),s(y.content),u(!1)}).catch(y=>{h(y instanceof Error?y.message:String(y)),u(!1)})},[]);const x=async()=>{f(!0),h(null);try{await TC(e),s(e)}catch(y){h(y instanceof Error?y.message:String(y))}f(!1)},b=e!==a;return o.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[o.jsxs("div",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg",children:"全局 AGENTS.md"}),o.jsx("p",{className:"mt-1 text-xs text-fg-4",children:"此内容会注入到所有仓库的 Agent 系统指令中。修改后 opencode 热加载,即时生效。"})]}),o.jsxs("button",{type:"button",onClick:()=>void x(),disabled:d||!b,className:"flex shrink-0 items-center gap-1.5 rounded-md bg-blue-600 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-blue-500 disabled:opacity-40",children:[o.jsx(Hc,{className:"h-3.5 w-3.5"}),d?"保存中…":"保存"]})]}),m&&o.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg bg-red-500/10 px-3 py-2 text-xs text-red-400",children:[o.jsx(Dn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"min-w-0 break-words",children:m})]}),o.jsx("div",{className:"mt-4",children:l?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[o.jsx(Sa,{className:"h-5 w-5 fs-spin"}),o.jsx("p",{className:"text-xs",children:"加载中…"})]}):o.jsx("textarea",{value:e,onChange:y=>t(y.target.value),spellCheck:!1,className:"h-96 w-full resize-y rounded-lg border border-line bg-base px-4 py-3 font-mono text-sm leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500/20",placeholder:`# AGENTS.md
471
471
 
472
472
  在此编写全局 Agent 指令…`})}),o.jsx("p",{className:"mt-3 text-[11px] text-fg-5",children:"文件路径:~/.config/opencode/AGENTS.md"})]})}function a9(){const[e,t]=A.useState([]),[a,s]=A.useState(!0),l=()=>{wC().then(d=>{t(d),s(!1)}).catch(()=>s(!1))};A.useEffect(l,[]);const u=async d=>{await RC(d),t(f=>f.filter(m=>m.id!==d))};return o.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Git 源站管理"}),o.jsx("p",{className:"mt-1 text-xs text-fg-4",children:"为不同的 Git 托管平台配置访问凭证,用于同步 Issues。系统会根据仓库的 git URL 自动匹配对应的源站。"}),o.jsx("div",{className:"mt-4 space-y-2",children:a?o.jsx("p",{className:"py-4 text-center font-mono text-xs text-fg-5",children:"加载中…"}):o.jsxs(o.Fragment,{children:[e.map(d=>o.jsx(e9,{host:d,onDelete:()=>void u(d.id)},d.id)),o.jsx(t9,{onAdded:l})]})}),o.jsx("p",{className:"mt-4 text-[11px] text-fg-5",children:"Token 存储在数据库中。也可通过环境变量 GITEA_TOKEN 设置全局 fallback。"})]})}const Eh="pinned_models";function r9(e){const t=new Map;for(const a of e){const s=a.providerName||a.providerID,l=t.get(s);l?l.push(a):t.set(s,[a])}return Array.from(t,([a,s])=>({provider:a,models:s})).sort((a,s)=>{const l=a.models.some(d=>d.configured),u=s.models.some(d=>d.configured);return l!==u?l?-1:1:a.provider.localeCompare(s.provider)})}function s9(e){return e?e>=1e6?`${(e/1e6).toFixed(e%1e6===0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e):""}function i9(e){if(!e)return"";const t=[];return e.input!=null&&t.push(`$${e.input}/Mi`),e.output!=null&&t.push(`$${e.output}/Mo`),t.join(" ")}function l9(){const e=Fe(w=>w.activeRepoId),[t,a]=A.useState([]),[s,l]=A.useState(new Set),[u,d]=A.useState(!0),[f,m]=A.useState(null),[h,x]=A.useState(null),[b,y]=A.useState("");A.useEffect(()=>{let w=!1;async function D(){d(!0),m(null);try{const[K,L]=await Promise.all([Fc(),e?Lh(e):Promise.resolve([])]);if(w)return;const M=K[Eh],V=M?JSON.parse(M):[];l(new Set(V)),a(L),x(null),y("")}catch(K){w||m(K instanceof Error?K.message:String(K))}w||d(!1)}return D(),()=>{w=!0}},[e]);const T=async w=>{const D=new Set(s);D.has(w)?D.delete(w):D.add(w),l(D);try{await Xm(Eh,JSON.stringify([...D]))}catch{l(s)}},N=A.useMemo(()=>r9(t),[t]),v=t.filter(w=>s.has(w.id)).length,S=h?N.find(w=>w.provider===h):N[0],C=b.trim().toLowerCase(),R=S?C?S.models.filter(w=>(w.name||w.id).toLowerCase().includes(C)||w.id.toLowerCase().includes(C)):S.models:[];return o.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[o.jsx("div",{className:"flex items-center justify-between gap-3",children:o.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[o.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-blue-500/10 text-blue-500",children:o.jsx(lc,{className:"h-4 w-4"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("h2",{className:"text-sm font-semibold text-fg",children:"常用模型"}),o.jsxs("p",{className:"mt-0.5 text-xs text-fg-4",children:["勾选常用模型,在新建对话时快速选择。",v>0&&o.jsxs("span",{className:"ml-1 text-blue-400",children:["已选 ",v," 个"]})]})]})]})}),o.jsx("div",{className:"mt-4",children:e?u?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[o.jsx(Sa,{className:"h-5 w-5 fs-spin"}),o.jsx("p",{className:"text-xs",children:"加载模型列表…"})]}):f?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-red-400",children:[o.jsx(Dn,{className:"h-5 w-5"}),o.jsx("p",{className:"max-w-xs text-center text-xs leading-relaxed",children:f})]}):t.length===0?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[o.jsx(lc,{className:"h-5 w-5"}),o.jsx("p",{className:"text-xs",children:"当前仓库没有可用模型。"})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex gap-1 overflow-x-auto rounded-lg border border-line bg-base p-1",children:N.map(w=>{var L;const D=w.provider===(h??((L=N[0])==null?void 0:L.provider)),K=w.models.filter(M=>s.has(M.id)).length;return o.jsxs("button",{type:"button",onClick:()=>{x(w.provider),y("")},className:oe("flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",D?"bg-surface text-fg shadow-sm":"text-fg-4 hover:text-fg-3"),children:[w.provider,K>0&&o.jsx("span",{className:"rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-semibold tabular-nums text-blue-500",children:K})]},w.provider)})}),o.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-md border border-line bg-base px-3 py-1.5",children:[o.jsx(os,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),o.jsx("input",{type:"text",value:b,onChange:w=>y(w.target.value),placeholder:"搜索模型…",className:"min-w-0 flex-1 bg-transparent text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),b&&o.jsx("button",{type:"button",onClick:()=>y(""),className:"text-fg-5 hover:text-fg-3",children:o.jsx(gt,{className:"h-3 w-3"})})]}),o.jsx("div",{className:"mt-3 rounded-lg border border-line bg-base",children:R.length===0?o.jsx("div",{className:"px-3 py-6 text-center text-xs text-fg-5",children:"无匹配模型"}):o.jsx("div",{className:"divide-y divide-line/40",children:R.map(w=>{const D=s.has(w.id),K=s9(w.contextLimit),L=i9(w.cost);return o.jsxs("label",{className:oe("flex cursor-pointer items-center gap-3 px-3 py-2 transition-colors hover:bg-elevated/60",D&&"bg-blue-500/5"),children:[o.jsx("input",{type:"checkbox",checked:D,onChange:()=>void T(w.id),className:"h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-line accent-blue-500"}),o.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-fg",children:w.name||w.id}),o.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[K&&o.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5 text-[10px] text-fg-5",children:K}),L&&o.jsx("span",{className:"text-[10px] text-fg-6",children:L})]})]},w.id)})})})]}):o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[o.jsx(lc,{className:"h-5 w-5"}),o.jsx("p",{className:"text-xs",children:"请先在左侧选择一个仓库以加载可用模型。"})]})})]})}const o9=["Sisyphus - ultraworker","Prometheus - Plan Builder","Atlas - Plan Executor"];function u9({agent:e,onEdit:t,onDelete:a}){const[s,l]=A.useState(!1),[u,d]=A.useState(!1),f=async()=>{const h=await fx(e.id),x=new Blob([JSON.stringify(h,null,2)],{type:"application/json"}),b=URL.createObjectURL(x),y=document.createElement("a");y.href=b,y.download=`${e.name.replace(/[^a-zA-Z0-9\u4e00-\u9fff_-]/g,"_")}.json`,y.click(),URL.revokeObjectURL(b)},m=async()=>{const h=await fx(e.id);await navigator.clipboard.writeText(JSON.stringify(h,null,2)),d(!0),setTimeout(()=>d(!1),2e3)};return o.jsxs("div",{className:"group flex items-center gap-3 rounded-lg border border-line bg-base px-4 py-3",children:[o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-medium text-fg",children:e.name}),o.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-4",children:e.baseAgent}),e.model&&o.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:e.model}),e.repoId&&o.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-400",children:"repo"})]}),e.systemPrompt&&o.jsx("p",{className:"mt-0.5 truncate font-mono text-xs text-fg-5",children:e.systemPrompt})]}),o.jsx("div",{className:"flex items-center gap-1",children:s?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:a,className:"rounded p-1.5 text-red-400 hover:bg-red-500/10",children:o.jsx(oa,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>l(!1),className:"rounded p-1.5 text-fg-4 hover:bg-elevated",children:o.jsx(gt,{className:"h-4 w-4"})})]}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>void f(),title:"导出 JSON 文件",className:"rounded p-1.5 text-fg-5 opacity-0 transition-opacity hover:text-fg-3 group-hover:opacity-100",children:o.jsx(gA,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>void m(),title:"复制 JSON 到剪贴板",className:"rounded p-1.5 text-fg-5 opacity-0 transition-opacity hover:text-fg-3 group-hover:opacity-100",children:u?o.jsx(oa,{className:"h-4 w-4 text-green-500"}):o.jsx(uA,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:t,className:"rounded p-1.5 text-fg-5 opacity-0 transition-opacity hover:text-fg-3 group-hover:opacity-100",children:o.jsx(GE,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>l(!0),className:"rounded p-1.5 text-fg-5 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:o.jsx(zs,{className:"h-4 w-4"})})]})})]})}const js="__system_prompt__";function cE({initial:e,availableFragments:t,onSave:a,onCancel:s}){const l=Fe(U=>U.activeRepoId),[u,d]=A.useState((e==null?void 0:e.name)??""),[f,m]=A.useState((e==null?void 0:e.baseAgent)??"Sisyphus - ultraworker"),[h,x]=A.useState((e==null?void 0:e.model)??""),[b,y]=A.useState((e==null?void 0:e.systemPrompt)??""),[T,N]=A.useState(!1),[v,S]=A.useState(!1),[C,R]=A.useState([]);A.useEffect(()=>{if(!l){R([]);return}let U=!1;return(async()=>{try{const[J,se]=await Promise.all([Fc(),Lh(l)]);if(U)return;const le=J[Eh],re=le?JSON.parse(le):[];R(re.length>0?se.filter(Q=>re.includes(Q.id)):[])}catch{U||R([])}})(),()=>{U=!0}},[l]);const[w,D]=A.useState(()=>{const U=(e==null?void 0:e.fragments.map(re=>re.id))??[],J=(e==null?void 0:e.systemPromptPosition)??-1,se=J>=0&&J<=U.length?J:U.length,le=[...U];return le.splice(se,0,js),le}),K=U=>{D(J=>{if(J.includes(U))return J.filter(re=>re!==U);const se=J.indexOf(js),le=[...J];return le.splice(se>=0?se:le.length,0,U),le})},L=(U,J)=>{const se=U+J;se<0||se>=w.length||D(le=>{const re=[...le];return[re[U],re[se]]=[re[se],re[U]],re})},M=w.filter(U=>U!==js),V=(()=>{const U=w.indexOf(js);return U<0?-1:w.slice(0,U).filter(J=>J!==js).length})(),W=w.map(U=>{var J;return U===js?b:(J=t.find(se=>se.id===U))==null?void 0:J.content}).filter(Boolean).join(`