fourth-spark 0.9.7 → 0.9.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.
|
@@ -447,7 +447,7 @@ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}
|
|
|
447
447
|
*
|
|
448
448
|
* This source code is licensed under the ISC license.
|
|
449
449
|
* See the LICENSE file in the root directory of this source tree.
|
|
450
|
-
*/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"}]],Fh=Ce("zap",$3);function ly(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=ly(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=ly(e))&&(s&&(s+=" "),s+=t);return s}const fx=e=>{let t;const a=new Set,s=(h,b)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const y=t;t=b??(typeof g!="object"||g===null)?g:Object.assign({},t,g),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},Y3=(e=>e?fx(e):fx),G3=e=>e;function K3(e,t=G3){const a=Qu.useSyncExternalStore(e.subscribe,Qu.useCallback(()=>t(e.getState()),[e,t]),Qu.useCallback(()=>t(e.getInitialState()),[e,t]));return Qu.useDebugValue(a),a}const mx=e=>{const t=Y3(e),a=s=>K3(t,s);return Object.assign(a,t),a},Za=(e=>e?mx(e):mx),bm="fs-theme";function oy(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function hx(e){return e==="system"?oy():e}function px(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const th=Za((e,t)=>({preference:localStorage.getItem(bm)??"system",resolved:hx(localStorage.getItem(bm)??"system"),setPreference(a){const s=hx(a);localStorage.setItem(bm,a),px(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(){px(t().preference);const a=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>{const{preference:l}=t();if(l==="system"){const u=oy();e({resolved:u})}};return a.addEventListener("change",s),()=>a.removeEventListener("change",s)}})),yc="fourth-spark-server-url";function uy(){if(typeof window>"u")return!1;const t=window.Capacitor;return typeof(t==null?void 0:t.isNativePlatform)=="function"&&t.isNativePlatform()}function cy(){return localStorage.getItem(yc)??""}function V3(e){const t=e.replace(/\/+$/,"");t?localStorage.setItem(yc,t):localStorage.removeItem(yc)}function nh(){return localStorage.getItem(yc)??""}class Xa extends Error{constructor(a,s){super(a);rn(this,"status");this.name="ApiError",this.status=s}}async function ve(e,t){let a;try{a=await fetch(cy()+e,{...t,headers:{Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers}})}catch(l){throw new Xa(l instanceof Error?l.message:"Network request failed",0)}if(!a.ok){const l=await a.text().catch(()=>"");throw new Xa(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 Q3(){return yn(await ve("/api/repos"),"repos")}async function X3(e,t,a,s){return ve("/api/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,localPath:a,runtimeType:s})})}async function W3(e){return ve("/api/repos/resolve",{method:"POST",body:JSON.stringify({localPath:e})})}async function Z3(e){await ve(`/api/repos/${encodeURIComponent(e)}`,{method:"DELETE"})}async function J3(e){await ve(`/api/repos/${encodeURIComponent(e)}/start`,{method:"POST"})}async function eC(e){await ve(`/api/repos/${encodeURIComponent(e)}/stop`,{method:"POST"})}async function tC(e){return ve(`/api/repos/${encodeURIComponent(e)}/branches`)}async function nC(e,t){return ve(`/api/repos/${encodeURIComponent(e)}/checkout`,{method:"POST",body:JSON.stringify({branch:t})})}async function aC(e){return ve(`/api/repos/${encodeURIComponent(e)}/pull`,{method:"POST"})}function Ke(e){return`/api/repos/${encodeURIComponent(e)}`}async function rC(e){return yn(await ve(`${Ke(e)}/workspaces`),"workspaces")}async function sC(e,t){await ve(`${Ke(e)}/workspaces/${encodeURIComponent(t)}`,{method:"DELETE"})}async function iC(e){return ve(`${Ke(e)}/workspaces/cleanup`,{method:"POST"})}async function lC(e,t){await ve(`/api/repos/${e}/worktree`,{method:"PATCH",body:JSON.stringify({enabled:t})})}async function oC(e,t){await ve(`/api/repos/${e}/runtime`,{method:"PATCH",body:JSON.stringify({runtimeType:t})})}async function uC(e){return yn(await ve(`${Ke(e)}/sessions`),"sessions")}async function cC(e,t,a,s,l,u,d,f){return ve(`${Ke(e)}/sessions`,{method:"POST",body:JSON.stringify({message:t,agent:a,model:s,variant:l,issueId:u,customAgentId:d,files:f})})}async function dC(e,t){return ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}`)}async function fC(e,t){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function mC(e,t,a,s,l,u){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/prompt`,{method:"POST",body:JSON.stringify({content:a,agent:s,model:l,files:u})})}async function hC(e,t){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/abort`,{method:"POST"})}async function pC(e,t,a){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/questions/reply`,{method:"POST",body:JSON.stringify({answers:a})})}async function gC(e,t){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/questions/reject`,{method:"POST"})}async function bC(e,t,a){return ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/revert`,{method:"POST",body:JSON.stringify({messageID:a})})}function xC(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 EC(e,t){return yn(await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/messages`),"messages").map(xC)}async function yC(e,t){return yn(await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/todos`),"todos")}async function dy(e,t){return ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/status`)}async function gx(e,t){return ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`)}async function bx(e){return ve(`${Ke(e)}/sessions/all-links`)}async function TC(e,t,a,s){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"POST",body:JSON.stringify({type:a,targetId:s})})}async function _C(e,t,a,s){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"DELETE",body:JSON.stringify({type:a,targetId:s})})}async function NC(e){return yn(await ve(`${Ke(e)}/agents`),"agents")}async function fy(){return yn(await ve("/api/custom-agents"))}async function my(e){return ve("/api/custom-agents",{method:"POST",body:JSON.stringify(e)})}async function hy(e,t){return ve(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function py(e){await ve(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"DELETE"})}async function xx(e){return ve(`/api/custom-agents/${encodeURIComponent(e)}/export`)}async function vC(e){return ve("/api/custom-agents/import",{method:"POST",body:JSON.stringify(e)})}async function SC(e){return yn(await ve(`${Ke(e)}/custom-agents`))}async function AC(e,t){return ve(`${Ke(e)}/custom-agents`,{method:"POST",body:JSON.stringify(t)})}async function Yc(e){return yn(await ve(`${Ke(e)}/models`))}async function CC(){return yn(await ve("/api/prompt-fragments"))}async function wC(e){return ve("/api/prompt-fragments",{method:"POST",body:JSON.stringify(e)})}async function kC(e,t){return ve(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function RC(e){await ve(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"DELETE"})}async function Ex(e){return yn(await ve(`${Ke(e)}/tags`))}async function yx(e,t){return yn(await ve(`${Ke(e)}/milestones`))}async function Tx(e,t="open"){return yn(await ve(`${Ke(e)}/issues?state=${encodeURIComponent(t)}`),"issues")}async function OC(e,t="all"){return ve(`${Ke(e)}/issues/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function IC(e,t,a){return ve(`${Ke(e)}/issues`,{method:"POST",body:JSON.stringify({title:t,body:a})})}async function MC(e,t,a){await ve(`${Ke(e)}/issues/${t}/children`,{method:"POST",body:JSON.stringify({childNumber:a})})}async function gy(e,t,a){return ve(`${Ke(e)}/issues/${t}`,{method:"PATCH",body:JSON.stringify(a)})}async function _x(e,t){return yn(await ve(`${Ke(e)}/issues/${t}/pulls`))}async function DC(e,t,a,s=!1){await ve(`${Ke(e)}/issues/${t}/pulls/${a}/merge`,{method:"POST",body:JSON.stringify({closeIssue:s})})}async function Nx(e,t="open"){return yn(await ve(`${Ke(e)}/pulls?state=${encodeURIComponent(t)}`))}async function LC(e,t="all"){return ve(`${Ke(e)}/pulls/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function jC(e,t){await ve(`${Ke(e)}/pulls/${t}/merge`,{method:"POST"})}async function by(e,t){return yn(await ve(`${Ke(e)}/pulls/${t}/issues`))}async function BC(e,t,a){await ve(`${Ke(e)}/pulls/${t}/issues`,{method:"POST",body:JSON.stringify({issueNumber:a})})}async function PC(e,t,a){await ve(`${Ke(e)}/pulls/${t}/issues/${a}`,{method:"DELETE"})}async function UC(e,t){return ve(`${Ke(e)}/pulls/${t}/comments`)}async function HC(e,t){return ve(`${Ke(e)}/issues/${t}/comments`)}async function vx(e,t,a){return ve(`${Ke(e)}/issues/${t}/comments`,{method:"POST",body:JSON.stringify({body:a})})}async function FC(e,t,a){return ve(`${Ke(e)}/issues/${t}/polish`,{method:"POST",body:JSON.stringify({draft:a})})}async function Sx(e,t){return ve(`${Ke(e)}/issues/${t}/draft`)}async function zC(e,t,a){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({title:a})})}async function qC(e,t,a){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({completedAt:a})})}async function $C(){return ve("/api/agents-md")}async function YC(e){await ve("/api/agents-md",{method:"PUT",body:JSON.stringify({content:e})})}async function GC(e){return ve(`/api/repos/${encodeURIComponent(e)}/agents-md`)}async function KC(e,t){await ve(`/api/repos/${encodeURIComponent(e)}/agents-md`,{method:"PUT",body:JSON.stringify({content:t})})}function VC(e){return`${cy()}${Ke(e)}/events`}async function QC(e){return ve(`${Ke(e)}/sessions/status`)}async function Gc(){return ve("/api/settings")}async function ah(e,t){await ve(`/api/settings/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({value:t})})}async function rh(){return ve("/api/cloud/status")}async function XC(){return ve("/api/cloud/reload",{method:"POST"})}async function WC(e){try{return(await ve("/api/cloud/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).connected}catch{return!1}}async function ZC(){return yn(await ve("/api/git-hosts"),"gitHosts")}async function JC(e,t,a,s="gitea"){return ve("/api/git-hosts",{method:"POST",body:JSON.stringify({host:e,name:t,token:a,platform:s})})}async function ew(e){await ve(`/api/git-hosts/${encodeURIComponent(e)}`,{method:"DELETE"})}async function xy(){return ve("/api/usage")}async function Ey(e){return ve("/api/usage/switch",{method:"POST",body:JSON.stringify({accountId:e})})}async function tw(e,t="ios"){await ve("/api/push/register",{method:"POST",body:JSON.stringify({token:e,platform:t})})}const as="fs-active-repo",He=Za((e,t)=>({repos:[],activeRepoId:localStorage.getItem(as),loading:!1,loadError:null,loadRepos:async()=>{e({loading:!0,loadError:null});try{const a=await Q3(),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,u)=>{try{const d=await X3(a,s,l,u);return e(f=>({repos:[...f.repos,d],activeRepoId:d.id})),localStorage.setItem(as,d.id),d}catch(d){return e({loadError:d instanceof Error?d.message:"Failed to add repo"}),null}},removeRepo:async a=>{try{await Z3(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)}))}})),ja=e=>{var t;return((t=e.repos.find(a=>a.id===e.activeRepoId))==null?void 0:t.name)??null},xm="fs-nav-collapsed",Em="fs-session-panel-collapsed",Tc=Za(e=>({navCollapsed:localStorage.getItem(xm)==="true",sessionPanelCollapsed:localStorage.getItem(Em)==="true",toggleNav(){e(t=>{const a=!t.navCollapsed;return localStorage.setItem(xm,String(a)),{navCollapsed:a}})},toggleSessionPanel(){e(t=>{const a=!t.sessionPanelCollapsed;return localStorage.setItem(Em,String(a)),{sessionPanelCollapsed:a}})},setNavCollapsed(t){localStorage.setItem(xm,String(t)),e({navCollapsed:t})},setSessionPanelCollapsed(t){localStorage.setItem(Em,String(t)),e({sessionPanelCollapsed:t})}})),yy=[{segment:"repos",icon:sA,label:"仓库管理",global:!0},{segment:"run",icon:qc,label:"运行面板",global:!1},{segment:"issues",icon:ho,label:"Issues",global:!1},{segment:"pulls",icon:po,label:"PRs",global:!1},{segment:"settings",icon:R3,label:"设置",global:!0}];function Ty(e,t,a){return t?`/${e}`:a?`/${encodeURIComponent(a)}/${e}`:`/${e}`}function nw({repoId:e,currentBranch:t}){const a=He(C=>C.updateRepoBranch),[s,l]=v.useState(!1),[u,d]=v.useState(null),[f,m]=v.useState(!1),[h,b]=v.useState(null),[g,y]=v.useState(null),T=v.useRef(null),N=v.useCallback(()=>{l(!1),y(null)},[]);v.useEffect(()=>{if(!s)return;const C=A=>{T.current&&!T.current.contains(A.target)&&N()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[s,N]);const S=async()=>{if(s){N();return}l(!0),m(!0),y(null);try{d(await tC(e))}catch{y("加载分支失败")}finally{m(!1)}},w=async C=>{if(!(C===t||h)){b(C),y(null);try{const A=await nC(e,C);a(e,A.branch),N()}catch(A){y(A instanceof Error?A.message:"切换失败")}finally{b(null)}}};return t?o.jsxs("div",{ref:T,className:"relative",children:[o.jsxs("button",{type:"button",onClick:S,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($s,{className:"h-3 w-3"}),t,o.jsx(Ia,{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(va,{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:()=>w(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(va,{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:()=>w(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(va,{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,g&&o.jsx("div",{className:"border-t border-line px-3 py-2 text-xs text-red-500",children:g})]})]}):null}function aw(){const[e,t]=v.useState(null);return v.useEffect(()=>{const a=()=>fetch("/api/health").then(u=>u.json()).then(u=>{u.latestVersion&&u.latestVersion!=="0.9.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 rw(){const e=Aa(),t=ca(),a=He(g=>g.repos),s=He(g=>g.activeRepoId),l=He(g=>g.setActiveRepo),u=th(g=>g.preference),d=th(g=>g.cycle),f=u==="light"?D3:u==="dark"?m3:d3,m=a.find(g=>g.id===s),h=aw(),b=g=>{var N;if(!g)return;l(g);const y=a.find(S=>S.id===g);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(Fh,{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.9.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:g=>b(g.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(g=>o.jsx("option",{value:g.id,children:g.name},g.id))}),m&&s&&o.jsx(nw,{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 sw(){const e=He(ja),t=Tc(s=>s.navCollapsed),a=Tc(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:yy.map(s=>o.jsxs(Bh,{to:Ty(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(gA,{className:"h-4 w-4"}):o.jsx(hA,{className:"h-4 w-4"})})]})}function iw(){const e=He(ja);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:yy.map(t=>o.jsx(Bh,{to:Ty(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 lw(){return o.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-base text-fg",children:[o.jsx(rw,{}),o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsx(sw,{}),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(sS,{})})]}),o.jsx(iw,{})]})}let ow=0;const Ft=Za(e=>({toasts:[],addToast:(t,a="info",s,l)=>{const u=(l==null?void 0:l.id)??`toast-${++ow}-${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 uw({onClose:e}){const[t,a]=v.useState(""),[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState("opencode"),[h,b]=v.useState(!1),[g,y]=v.useState(""),T=He(A=>A.addRepo),N=s.trim()!==""&&u.trim()!==""&&t.trim()!==""&&!h,S=async A=>{const O=A.trim();if(O){b(!0),y("");try{const U=await W3(O);U.name&&!s.trim()&&l(U.name),U.gitUrl&&!u.trim()&&d(U.gitUrl)}catch(U){const Q=U instanceof Error?U.message:"无法解析路径";try{const L=JSON.parse(Q);y(L.error??Q)}catch{y(Q)}}b(!1)}},w=v.useRef(S);w.current=S,v.useEffect(()=>{const A=t.trim();if(!A)return;const O=setTimeout(()=>{w.current(A)},500);return()=>clearTimeout(O)},[t]);const C=async()=>{if(!N)return;y(""),await T(s.trim(),u.trim(),t.trim(),f)&&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:A=>A.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:A=>a(A.target.value),onBlur:A=>void S(A.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:h?"正在读取 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:A=>l(A.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:A=>d(A.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"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{className:"text-xs font-medium text-fg-3",children:"运行时"}),o.jsx("div",{className:"flex gap-2",children:[{value:"opencode",label:"OpenCode"},{value:"claude-code",label:"Claude Code"}].map(A=>o.jsx("button",{type:"button",onClick:()=>m(A.value),className:`flex-1 rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${f===A.value?"border-blue-500 bg-blue-500/10 text-blue-600":"border-line bg-base text-fg-4 hover:bg-elevated hover:text-fg-2"}`,children:A.label},A.value))}),o.jsx("span",{className:"text-[11px] text-fg-5",children:f==="claude-code"?"需要本地安装 Claude Code CLI":"需要本地安装 OpenCode CLI"})]}),g&&o.jsx("p",{className:"rounded-md bg-red-500/10 px-3 py-2 text-xs text-red-500",children:g}),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:C,disabled:!N,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 cw({repoId:e,repoName:t,onClose:a}){const[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState(!0),[h,b]=v.useState(!1),[g,y]=v.useState(null);v.useEffect(()=>{GC(e).then(S=>{l(S.content),d(S.content),m(!1)}).catch(S=>{y(S instanceof Error?S.message:String(S)),m(!1)})},[e]);const T=async()=>{b(!0),y(null);try{await KC(e,s),d(s)}catch(S){y(S instanceof Error?S.message:String(S))}b(!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:S=>S.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"})})]}),g&&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(An,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"min-w-0 break-words",children:g})]}),f?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[o.jsx(va,{className:"h-5 w-5 fs-spin"}),o.jsx("p",{className:"text-xs",children:"加载中…"})]}):o.jsx("textarea",{value:s,onChange:S=>l(S.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
|
|
450
|
+
*/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"}]],Fh=Ce("zap",$3);function ly(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=ly(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=ly(e))&&(s&&(s+=" "),s+=t);return s}const fx=e=>{let t;const a=new Set,s=(h,b)=>{const g=typeof h=="function"?h(t):h;if(!Object.is(g,t)){const y=t;t=b??(typeof g!="object"||g===null)?g:Object.assign({},t,g),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},Y3=(e=>e?fx(e):fx),G3=e=>e;function K3(e,t=G3){const a=Qu.useSyncExternalStore(e.subscribe,Qu.useCallback(()=>t(e.getState()),[e,t]),Qu.useCallback(()=>t(e.getInitialState()),[e,t]));return Qu.useDebugValue(a),a}const mx=e=>{const t=Y3(e),a=s=>K3(t,s);return Object.assign(a,t),a},Za=(e=>e?mx(e):mx),bm="fs-theme";function oy(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function hx(e){return e==="system"?oy():e}function px(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const th=Za((e,t)=>({preference:localStorage.getItem(bm)??"system",resolved:hx(localStorage.getItem(bm)??"system"),setPreference(a){const s=hx(a);localStorage.setItem(bm,a),px(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(){px(t().preference);const a=window.matchMedia("(prefers-color-scheme: dark)"),s=()=>{const{preference:l}=t();if(l==="system"){const u=oy();e({resolved:u})}};return a.addEventListener("change",s),()=>a.removeEventListener("change",s)}})),yc="fourth-spark-server-url";function uy(){if(typeof window>"u")return!1;const t=window.Capacitor;return typeof(t==null?void 0:t.isNativePlatform)=="function"&&t.isNativePlatform()}function cy(){return localStorage.getItem(yc)??""}function V3(e){const t=e.replace(/\/+$/,"");t?localStorage.setItem(yc,t):localStorage.removeItem(yc)}function nh(){return localStorage.getItem(yc)??""}class Xa extends Error{constructor(a,s){super(a);rn(this,"status");this.name="ApiError",this.status=s}}async function ve(e,t){let a;try{a=await fetch(cy()+e,{...t,headers:{Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers}})}catch(l){throw new Xa(l instanceof Error?l.message:"Network request failed",0)}if(!a.ok){const l=await a.text().catch(()=>"");throw new Xa(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 Q3(){return yn(await ve("/api/repos"),"repos")}async function X3(e,t,a,s){return ve("/api/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,localPath:a,runtimeType:s})})}async function W3(e){return ve("/api/repos/resolve",{method:"POST",body:JSON.stringify({localPath:e})})}async function Z3(e){await ve(`/api/repos/${encodeURIComponent(e)}`,{method:"DELETE"})}async function J3(e){await ve(`/api/repos/${encodeURIComponent(e)}/start`,{method:"POST"})}async function eC(e){await ve(`/api/repos/${encodeURIComponent(e)}/stop`,{method:"POST"})}async function tC(e){return ve(`/api/repos/${encodeURIComponent(e)}/branches`)}async function nC(e,t){return ve(`/api/repos/${encodeURIComponent(e)}/checkout`,{method:"POST",body:JSON.stringify({branch:t})})}async function aC(e){return ve(`/api/repos/${encodeURIComponent(e)}/pull`,{method:"POST"})}function Ke(e){return`/api/repos/${encodeURIComponent(e)}`}async function rC(e){return yn(await ve(`${Ke(e)}/workspaces`),"workspaces")}async function sC(e,t){await ve(`${Ke(e)}/workspaces/${encodeURIComponent(t)}`,{method:"DELETE"})}async function iC(e){return ve(`${Ke(e)}/workspaces/cleanup`,{method:"POST"})}async function lC(e,t){await ve(`/api/repos/${e}/worktree`,{method:"PATCH",body:JSON.stringify({enabled:t})})}async function oC(e,t){await ve(`/api/repos/${e}/runtime`,{method:"PATCH",body:JSON.stringify({runtimeType:t})})}async function uC(e){return yn(await ve(`${Ke(e)}/sessions`),"sessions")}async function cC(e,t,a,s,l,u,d,f){return ve(`${Ke(e)}/sessions`,{method:"POST",body:JSON.stringify({message:t,agent:a,model:s,variant:l,issueId:u,customAgentId:d,files:f})})}async function dC(e,t){return ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}`)}async function fC(e,t){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function mC(e,t,a,s,l,u){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/prompt`,{method:"POST",body:JSON.stringify({content:a,agent:s,model:l,files:u})})}async function hC(e,t){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/abort`,{method:"POST"})}async function pC(e,t,a){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/questions/reply`,{method:"POST",body:JSON.stringify({answers:a})})}async function gC(e,t){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/questions/reject`,{method:"POST"})}async function bC(e,t,a){return ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/revert`,{method:"POST",body:JSON.stringify({messageID:a})})}function xC(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 EC(e,t){return yn(await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/messages`),"messages").map(xC)}async function yC(e,t){return yn(await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/todos`),"todos")}async function dy(e,t){return ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/status`)}async function gx(e,t){return ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`)}async function bx(e){return ve(`${Ke(e)}/sessions/all-links`)}async function TC(e,t,a,s){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"POST",body:JSON.stringify({type:a,targetId:s})})}async function _C(e,t,a,s){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"DELETE",body:JSON.stringify({type:a,targetId:s})})}async function NC(e){return yn(await ve(`${Ke(e)}/agents`),"agents")}async function fy(){return yn(await ve("/api/custom-agents"))}async function my(e){return ve("/api/custom-agents",{method:"POST",body:JSON.stringify(e)})}async function hy(e,t){return ve(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function py(e){await ve(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"DELETE"})}async function xx(e){return ve(`/api/custom-agents/${encodeURIComponent(e)}/export`)}async function vC(e){return ve("/api/custom-agents/import",{method:"POST",body:JSON.stringify(e)})}async function SC(e){return yn(await ve(`${Ke(e)}/custom-agents`))}async function AC(e,t){return ve(`${Ke(e)}/custom-agents`,{method:"POST",body:JSON.stringify(t)})}async function Yc(e){return yn(await ve(`${Ke(e)}/models`))}async function CC(){return yn(await ve("/api/prompt-fragments"))}async function wC(e){return ve("/api/prompt-fragments",{method:"POST",body:JSON.stringify(e)})}async function kC(e,t){return ve(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function RC(e){await ve(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"DELETE"})}async function Ex(e){return yn(await ve(`${Ke(e)}/tags`))}async function yx(e,t){return yn(await ve(`${Ke(e)}/milestones`))}async function Tx(e,t="open"){return yn(await ve(`${Ke(e)}/issues?state=${encodeURIComponent(t)}`),"issues")}async function OC(e,t="all"){return ve(`${Ke(e)}/issues/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function IC(e,t,a){return ve(`${Ke(e)}/issues`,{method:"POST",body:JSON.stringify({title:t,body:a})})}async function MC(e,t,a){await ve(`${Ke(e)}/issues/${t}/children`,{method:"POST",body:JSON.stringify({childNumber:a})})}async function gy(e,t,a){return ve(`${Ke(e)}/issues/${t}`,{method:"PATCH",body:JSON.stringify(a)})}async function _x(e,t){return yn(await ve(`${Ke(e)}/issues/${t}/pulls`))}async function DC(e,t,a,s=!1){await ve(`${Ke(e)}/issues/${t}/pulls/${a}/merge`,{method:"POST",body:JSON.stringify({closeIssue:s})})}async function Nx(e,t="open"){return yn(await ve(`${Ke(e)}/pulls?state=${encodeURIComponent(t)}`))}async function LC(e,t="all"){return ve(`${Ke(e)}/pulls/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function jC(e,t){await ve(`${Ke(e)}/pulls/${t}/merge`,{method:"POST"})}async function by(e,t){return yn(await ve(`${Ke(e)}/pulls/${t}/issues`))}async function BC(e,t,a){await ve(`${Ke(e)}/pulls/${t}/issues`,{method:"POST",body:JSON.stringify({issueNumber:a})})}async function PC(e,t,a){await ve(`${Ke(e)}/pulls/${t}/issues/${a}`,{method:"DELETE"})}async function UC(e,t){return ve(`${Ke(e)}/pulls/${t}/comments`)}async function HC(e,t){return ve(`${Ke(e)}/issues/${t}/comments`)}async function vx(e,t,a){return ve(`${Ke(e)}/issues/${t}/comments`,{method:"POST",body:JSON.stringify({body:a})})}async function FC(e,t,a){return ve(`${Ke(e)}/issues/${t}/polish`,{method:"POST",body:JSON.stringify({draft:a})})}async function Sx(e,t){return ve(`${Ke(e)}/issues/${t}/draft`)}async function zC(e,t,a){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({title:a})})}async function qC(e,t,a){await ve(`${Ke(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({completedAt:a})})}async function $C(){return ve("/api/agents-md")}async function YC(e){await ve("/api/agents-md",{method:"PUT",body:JSON.stringify({content:e})})}async function GC(e){return ve(`/api/repos/${encodeURIComponent(e)}/agents-md`)}async function KC(e,t){await ve(`/api/repos/${encodeURIComponent(e)}/agents-md`,{method:"PUT",body:JSON.stringify({content:t})})}function VC(e){return`${cy()}${Ke(e)}/events`}async function QC(e){return ve(`${Ke(e)}/sessions/status`)}async function Gc(){return ve("/api/settings")}async function ah(e,t){await ve(`/api/settings/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({value:t})})}async function rh(){return ve("/api/cloud/status")}async function XC(){return ve("/api/cloud/reload",{method:"POST"})}async function WC(e){try{return(await ve("/api/cloud/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).connected}catch{return!1}}async function ZC(){return yn(await ve("/api/git-hosts"),"gitHosts")}async function JC(e,t,a,s="gitea"){return ve("/api/git-hosts",{method:"POST",body:JSON.stringify({host:e,name:t,token:a,platform:s})})}async function ew(e){await ve(`/api/git-hosts/${encodeURIComponent(e)}`,{method:"DELETE"})}async function xy(){return ve("/api/usage")}async function Ey(e){return ve("/api/usage/switch",{method:"POST",body:JSON.stringify({accountId:e})})}async function tw(e,t="ios"){await ve("/api/push/register",{method:"POST",body:JSON.stringify({token:e,platform:t})})}const as="fs-active-repo",He=Za((e,t)=>({repos:[],activeRepoId:localStorage.getItem(as),loading:!1,loadError:null,loadRepos:async()=>{e({loading:!0,loadError:null});try{const a=await Q3(),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,u)=>{try{const d=await X3(a,s,l,u);return e(f=>({repos:[...f.repos,d],activeRepoId:d.id})),localStorage.setItem(as,d.id),d}catch(d){return e({loadError:d instanceof Error?d.message:"Failed to add repo"}),null}},removeRepo:async a=>{try{await Z3(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)}))}})),ja=e=>{var t;return((t=e.repos.find(a=>a.id===e.activeRepoId))==null?void 0:t.name)??null},xm="fs-nav-collapsed",Em="fs-session-panel-collapsed",Tc=Za(e=>({navCollapsed:localStorage.getItem(xm)==="true",sessionPanelCollapsed:localStorage.getItem(Em)==="true",toggleNav(){e(t=>{const a=!t.navCollapsed;return localStorage.setItem(xm,String(a)),{navCollapsed:a}})},toggleSessionPanel(){e(t=>{const a=!t.sessionPanelCollapsed;return localStorage.setItem(Em,String(a)),{sessionPanelCollapsed:a}})},setNavCollapsed(t){localStorage.setItem(xm,String(t)),e({navCollapsed:t})},setSessionPanelCollapsed(t){localStorage.setItem(Em,String(t)),e({sessionPanelCollapsed:t})}})),yy=[{segment:"repos",icon:sA,label:"仓库管理",global:!0},{segment:"run",icon:qc,label:"运行面板",global:!1},{segment:"issues",icon:ho,label:"Issues",global:!1},{segment:"pulls",icon:po,label:"PRs",global:!1},{segment:"settings",icon:R3,label:"设置",global:!0}];function Ty(e,t,a){return t?`/${e}`:a?`/${encodeURIComponent(a)}/${e}`:`/${e}`}function nw({repoId:e,currentBranch:t}){const a=He(C=>C.updateRepoBranch),[s,l]=v.useState(!1),[u,d]=v.useState(null),[f,m]=v.useState(!1),[h,b]=v.useState(null),[g,y]=v.useState(null),T=v.useRef(null),N=v.useCallback(()=>{l(!1),y(null)},[]);v.useEffect(()=>{if(!s)return;const C=A=>{T.current&&!T.current.contains(A.target)&&N()};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[s,N]);const S=async()=>{if(s){N();return}l(!0),m(!0),y(null);try{d(await tC(e))}catch{y("加载分支失败")}finally{m(!1)}},w=async C=>{if(!(C===t||h)){b(C),y(null);try{const A=await nC(e,C);a(e,A.branch),N()}catch(A){y(A instanceof Error?A.message:"切换失败")}finally{b(null)}}};return t?o.jsxs("div",{ref:T,className:"relative",children:[o.jsxs("button",{type:"button",onClick:S,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($s,{className:"h-3 w-3"}),t,o.jsx(Ia,{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(va,{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:()=>w(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(va,{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:()=>w(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(va,{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,g&&o.jsx("div",{className:"border-t border-line px-3 py-2 text-xs text-red-500",children:g})]})]}):null}function aw(){const[e,t]=v.useState(null);return v.useEffect(()=>{const a=()=>fetch("/api/health").then(u=>u.json()).then(u=>{u.latestVersion&&u.latestVersion!=="0.9.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 rw(){const e=Aa(),t=ca(),a=He(g=>g.repos),s=He(g=>g.activeRepoId),l=He(g=>g.setActiveRepo),u=th(g=>g.preference),d=th(g=>g.cycle),f=u==="light"?D3:u==="dark"?m3:d3,m=a.find(g=>g.id===s),h=aw(),b=g=>{var N;if(!g)return;l(g);const y=a.find(S=>S.id===g);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(Fh,{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.9.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:g=>b(g.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(g=>o.jsx("option",{value:g.id,children:g.name},g.id))}),m&&s&&o.jsx(nw,{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 sw(){const e=He(ja),t=Tc(s=>s.navCollapsed),a=Tc(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:yy.map(s=>o.jsxs(Bh,{to:Ty(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(gA,{className:"h-4 w-4"}):o.jsx(hA,{className:"h-4 w-4"})})]})}function iw(){const e=He(ja);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:yy.map(t=>o.jsx(Bh,{to:Ty(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 lw(){return o.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-base text-fg",children:[o.jsx(rw,{}),o.jsxs("div",{className:"flex min-h-0 flex-1",children:[o.jsx(sw,{}),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(sS,{})})]}),o.jsx(iw,{})]})}let ow=0;const Ft=Za(e=>({toasts:[],addToast:(t,a="info",s,l)=>{const u=(l==null?void 0:l.id)??`toast-${++ow}-${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 uw({onClose:e}){const[t,a]=v.useState(""),[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState("opencode"),[h,b]=v.useState(!1),[g,y]=v.useState(""),T=He(A=>A.addRepo),N=s.trim()!==""&&u.trim()!==""&&t.trim()!==""&&!h,S=async A=>{const O=A.trim();if(O){b(!0),y("");try{const U=await W3(O);U.name&&!s.trim()&&l(U.name),U.gitUrl&&!u.trim()&&d(U.gitUrl)}catch(U){const Q=U instanceof Error?U.message:"无法解析路径";try{const L=JSON.parse(Q);y(L.error??Q)}catch{y(Q)}}b(!1)}},w=v.useRef(S);w.current=S,v.useEffect(()=>{const A=t.trim();if(!A)return;const O=setTimeout(()=>{w.current(A)},500);return()=>clearTimeout(O)},[t]);const C=async()=>{if(!N)return;y(""),await T(s.trim(),u.trim(),t.trim(),f)&&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:A=>A.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:A=>a(A.target.value),onBlur:A=>void S(A.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:h?"正在读取 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:A=>l(A.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:A=>d(A.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"})]}),o.jsxs("div",{className:"flex flex-col gap-1.5",children:[o.jsx("label",{className:"text-xs font-medium text-fg-3",children:"运行时"}),o.jsx("div",{className:"flex gap-2",children:[{value:"opencode",label:"OpenCode"},{value:"claude-code",label:"Claude Code"}].map(A=>o.jsx("button",{type:"button",onClick:()=>m(A.value),className:`flex-1 rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${f===A.value?"border-blue-500 bg-blue-500/10 text-blue-600":"border-line bg-base text-fg-4 hover:bg-elevated hover:text-fg-2"}`,children:A.label},A.value))}),o.jsx("span",{className:"text-[11px] text-fg-5",children:f==="claude-code"?"需要本地安装 Claude Code CLI":"需要本地安装 OpenCode CLI"})]}),g&&o.jsx("p",{className:"rounded-md bg-red-500/10 px-3 py-2 text-xs text-red-500",children:g}),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:C,disabled:!N,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 cw({repoId:e,repoName:t,onClose:a}){const[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState(!0),[h,b]=v.useState(!1),[g,y]=v.useState(null);v.useEffect(()=>{GC(e).then(S=>{l(S.content),d(S.content),m(!1)}).catch(S=>{y(S instanceof Error?S.message:String(S)),m(!1)})},[e]);const T=async()=>{b(!0),y(null);try{await KC(e,s),d(s)}catch(S){y(S instanceof Error?S.message:String(S))}b(!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:S=>S.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"})})]}),g&&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(An,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"min-w-0 break-words",children:g})]}),f?o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[o.jsx(va,{className:"h-5 w-5 fs-spin"}),o.jsx("p",{className:"text-xs",children:"加载中…"})]}):o.jsx("textarea",{value:s,onChange:S=>l(S.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
|
|
451
451
|
|
|
452
452
|
在此编写该仓库的 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($c,{className:"h-3.5 w-3.5"}),h?"保存中…":"保存"]})]})]})})}const sh=1024,ih=sh*1024,Ax=ih*1024;function Cx(e){return!e||e<=0?"0 B":e<sh?`${e} B`:e<ih?`${(e/sh).toFixed(1)} KB`:e<Ax?`${(e/ih).toFixed(1)} MB`:`${(e/Ax).toFixed(2)} GB`}const ym="ws/";function dw({repoId:e}){const[t,a]=v.useState(!1),[s,l]=v.useState(null),[u,d]=v.useState(!1),[f,m]=v.useState(null),[h,b]=v.useState(null),[g,y]=v.useState(!1),T=async()=>{d(!0),m(null);try{const A=await rC(e);l(A)}catch(A){m(A instanceof Xa?A.message:"加载失败")}d(!1)};v.useEffect(()=>{t&&s===null&&T()},[t]);const N=async A=>{b(A);try{await sC(e,A),await T()}catch(O){m(O instanceof Xa?O.message:"删除失败")}b(null)},S=async()=>{y(!0);try{await iC(e),await T()}catch(A){m(A instanceof Xa?A.message:"清理失败")}y(!1)},w=(s==null?void 0:s.length)??0,C=(s==null?void 0:s.reduce((A,O)=>A+(O.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(A=>!A),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(fA,{className:"h-3 w-3 shrink-0"}):o.jsx(Ia,{className:"h-3 w-3 shrink-0"}),o.jsx($s,{className:"h-3 w-3 shrink-0 text-fg-5"}),o.jsx("span",{children:"工作空间"}),s!==null&&o.jsxs("span",{className:"text-fg-5",children:["(",w,") · ",Cx(C)]})]}),t&&w>0&&o.jsxs("button",{type:"button",onClick:()=>void S(),disabled:g,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:[g?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"})}):w===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(A=>{const O=A.branch.startsWith(ym),U=O?A.branch.slice(ym.length):A.branch,Q=A.status==="active"?"bg-emerald-500/10 text-emerald-600":A.status==="idle"?"bg-amber-500/10 text-amber-600":"bg-fg-6/30 text-fg-4",L=A.status==="active"?"活跃":A.status==="idle"?"空闲":A.status==="merged"?"已合并":A.status==="stale"?"陈旧":A.status,F=A.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:[A.running&&A.port&&o.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",title:`运行中 :${A.port}`}),o.jsxs("span",{className:"min-w-0 truncate font-mono",children:[O&&o.jsx("span",{className:"text-fg-5",children:ym}),o.jsx("span",{className:"text-fg-2",children:U})]})]}),o.jsx("span",{className:oe("shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium",Q),children:L}),o.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-fg-5",children:[o.jsx($A,{className:"h-2.5 w-2.5"}),Cx(A.diskUsage)]}),o.jsx("button",{type:"button",onClick:()=>void N(A.id),disabled:!F||h===A.id,title:F?"删除工作空间":"活跃工作空间无法删除",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===A.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"})})]},A.id)})})]})]})}function fw(){const e=He(A=>A.repos),t=He(A=>A.activeRepoId),a=He(A=>A.setActiveRepo),s=He(A=>A.removeRepo),l=He(A=>A.loadRepos),[u,d]=v.useState(!1),[f,m]=v.useState(null),[h,b]=v.useState(null),[g,y]=v.useState(null),T=Ft(A=>A.addToast),[N,S]=v.useState(null),w=async(A,O)=>{b(A);try{O?await eC(A):await J3(A),await l()}catch{}b(null)},C=async A=>{y(A);try{const O=await aC(A);await l();const U=O.alreadyUpToDate?"info":"success";T(O.summary,U,void 0,{persistent:!0})}catch(O){let U="拉取失败";if(O instanceof Xa)try{U=JSON.parse(O.message).error??O.message}catch{U=O.message}T(U,"error",void 0,{persistent:!0})}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(Wa,{className:"h-4 w-4"}),o.jsx("span",{className:"hidden md:inline",children:"添加仓库"})]})]}),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(Wa,{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(A=>{const O=A.id===t;return o.jsxs("div",{className:oe("rounded-xl border p-4 transition-colors",O?"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(A.id),className:"flex min-w-0 items-center gap-2 text-left",children:[O?o.jsx(ho,{className:"h-4 w-4 shrink-0 text-blue-500"}):o.jsx(TA,{className:"h-4 w-4 shrink-0 text-fg-5"}),o.jsx("span",{className:oe("truncate font-medium",O?"text-fg":"text-fg-2"),children:A.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",A.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",A.running?"bg-emerald-500":"bg-fg-5")}),A.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:A.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:A.localPath}),o.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(A.localPath),title:"复制路径",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:o.jsx(gc,{className:"h-3 w-3"})})]})]}),A.running&&A.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:${A.port}`,target:"_blank",rel:"noopener noreferrer",className:"truncate text-blue-500 hover:underline",children:["127.0.0.1:",A.port]}),o.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(`http://127.0.0.1:${A.port}`),title:"复制链接",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:o.jsx(gc,{className:"h-3 w-3"})})]})]})]}),o.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:async()=>{const U=A.runtimeType==="claude-code"?"opencode":"claude-code";await oC(A.id,U),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",A.runtimeType==="claude-code"?"border-orange-500/30 text-orange-600 hover:bg-orange-500/10":"border-sky-500/30 text-sky-600 hover:bg-sky-500/10"),title:`当前运行时: ${A.runtimeType==="claude-code"?"Claude Code":"OpenCode"},点击切换`,children:A.runtimeType==="claude-code"?"Claude":"OpenCode"}),o.jsxs("button",{type:"button",onClick:async()=>{await lC(A.id,!A.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",A.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:A.worktreeEnabled?"Worktree 已开启":"Worktree 已关闭",children:[o.jsx($s,{className:"h-3 w-3"}),"Worktree"]}),o.jsxs("button",{type:"button",onClick:()=>S({id:A.id,name:A.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(ey,{className:"h-3 w-3"}),"配置"]}),o.jsx("button",{type:"button",onClick:()=>void C(A.id),disabled:g===A.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:g===A.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(QS,{className:"h-3 w-3"}),"拉取"]})}),o.jsx("button",{type:"button",onClick:()=>void w(A.id,A.running),disabled:h===A.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",A.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===A.id?o.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):A.running?o.jsxs(o.Fragment,{children:[o.jsx(eh,{className:"h-3 w-3 fill-current"}),"停止"]}):o.jsxs(o.Fragment,{children:[o.jsx(qc,{className:"h-3 w-3 fill-current"}),"启动"]})}),f===A.id?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:()=>{s(A.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(A.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"})})]}),A.worktreeEnabled&&o.jsx(dw,{repoId:A.id})]},A.id)})})}),o.jsxs("p",{className:"mt-3 text-xs text-fg-5",children:[e.length," 个仓库"]})]}),u&&o.jsx(uw,{onClose:()=>d(!1)}),N&&o.jsx(cw,{repoId:N.id,repoName:N.name,onClose:()=>S(null)})]})}const mw=new Set(["tool","tool-use","tool_use","tool-call","tool_call","tool-result","tool_result"]),hw=new Set(["thinking","reasoning","reason"]),pw=new Set(["text","output_text","message"]),gw=new Set(["file","image"]);function _c(e){var a;const t=((a=e.type)==null?void 0:a.toLowerCase())??"";return mw.has(t)||e.toolName!=null||e.tool!=null?"tool":gw.has(t)?"file":hw.has(t)?"thinking":pw.has(t)||e.content!=null||e.text!=null?"text":"other"}function Nc(e){return e.content??e.text??""}function _y(e){return e.toolName??e.tool??"tool"}function Kc(e){var t;return e.input??((t=e.state)==null?void 0:t.input)}function zh(e){var t;return e.output??((t=e.state)==null?void 0:t.output)}function qh(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":zh(e)!=null?"completed":"running"}function wx(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ui(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 bw(e){return e.filter(t=>Ui(t.status)==="completed").length}function go(e){const t=_y(e).toLowerCase();return t==="question"||t==="mcp_question"}function xw(e){const t=Kc(e);if(!t||typeof t!="object")return null;const a=t;return Array.isArray(a.questions)?a.questions:null}function vc(e){if(!go(e))return!1;const t=qh(e);return t==="pending"||t==="running"}const Ew=/\bses_[a-zA-Z0-9]+/;function yw(e){var l;const t=Kc(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=zh(e);if(typeof s=="string"){const u=Ew.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 Tw=["Sisyphus","Prometheus","Atlas"];function _w(e){const t=(e.name||e.id||"").toLowerCase();return Tw.some(a=>t.startsWith(a.toLowerCase()))}const Nw=Za(e=>({agents:[],loaded:!1,loadAgents:async()=>{const t=He.getState().activeRepoId;if(!t){e({agents:[],loaded:!0});return}try{const a=await NC(t);e({agents:a.filter(_w),loaded:!0})}catch{e({loaded:!0})}}}));function Ny(e){return`question-${e}`}function Tm(e,t){const a=t.find(l=>l.id===e),s=(a==null?void 0:a.title)||e.slice(-8);Ft.getState().addToast(`${s} — 等待回复`,"warning",e,{id:Ny(e),persistent:!0})}function vw(e){var t;for(const a of e)if((t=a.parts)!=null&&t.some(s=>go(s)&&vc(s)))return!0;return!1}const bo=[],Sc=[],kx=[],Ds={};function Rx(e){return e.id??e.callID}function Mn(){return He.getState().activeRepoId}const Ie=Za((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=Mn();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 qC(s,a,u)}catch{await t().loadSessions()}},loadSessions:async()=>{const a=Mn();if(!a){e({sessions:[],loadingSessions:!1});return}e({loadingSessions:!0,loadError:null});try{const[s,l]=await Promise.all([uC(a),bx(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,m)=>{const h=Mn();if(!h)return null;e({sendError:null});try{const b=await cC(h,a,s,l,u,d,f,m);return e(g=>({sessions:[b,...g.sessions.filter(y=>y.id!==b.id)],activeSessionId:b.id,messages:{...g.messages,[b.id]:[]}})),t().setSessionStatus(b.id,"busy"),b}catch(b){return e({sendError:b instanceof Error?b.message:"Failed to create session"}),null}},setActiveSession:async a=>{Mn()&&(e({activeSessionId:a,sendError:null}),await t().refreshSessionData(a))},refreshSessionData:async a=>{var b;const s=Mn();if(!s)return;const[l,u,d,f,m]=await Promise.allSettled([EC(s,a),yC(s,a),dy(s,a),dC(s,a),gx(s,a)]),h=f.status==="fulfilled"?(b=f.value.revert)==null?void 0:b.messageID:void 0;e(g=>{const y={};if(l.status==="fulfilled"){let T=l.value;if(h){const N=T.findIndex(S=>S.id===h);N>=0&&(T=T.slice(0,N+1))}y.messages={...g.messages,[a]:T}}if(u.status==="fulfilled"&&(y.todos={...g.todos,[a]:u.value}),d.status==="fulfilled"&&(y.sessionStatuses={...g.sessionStatuses,[a]:d.value.type}),f.status==="fulfilled"){const T=f.value;y.sessions=g.sessions.map(N=>N.id===a?{...N,...T}:N)}return m.status==="fulfilled"&&(y.sessionLinks={...g.sessionLinks,[a]:m.value}),y}),l.status==="fulfilled"&&vw(l.value)&&Tm(a,t().sessions)},refreshSessionLinks:async a=>{const s=Mn();if(s)try{const[l,u]=await Promise.all([gx(s,a),bx(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=Mn();if(!u)return!1;try{return await TC(u,a,s,l),await t().refreshSessionLinks(a),!0}catch{return!1}},removeLink:async(a,s,l)=>{const u=Mn();if(!u)return!1;try{return await _C(u,a,s,l),await t().refreshSessionLinks(a),!0}catch{return!1}},deleteSession:async a=>{const s=Mn();if(s)try{await fC(s,a)}catch{}delete Ds[a],e(l=>{const{[a]:u,...d}=l.messages,{[a]:f,...m}=l.todos,{[a]:h,...b}=l.sessionStatuses,{[a]:g,...y}=l.errorReasons,{[a]:T,...N}=l.queuedMessageIds,{[a]:S,...w}=l.sessionLinks,{[a]:C,...A}=l.allSessionLinks;return{sessions:l.sessions.filter(O=>O.id!==a),messages:d,todos:m,sessionStatuses:b,errorReasons:y,queuedMessageIds:N,sessionLinks:w,allSessionLinks:A,activeSessionId:l.activeSessionId===a?null:l.activeSessionId}})},sendMessage:async(a,s,l)=>{const u=Mn(),d=t().activeSessionId;if(!u||!d)return!1;const f=t().sessions.find(h=>h.id===d),m=t().sessionStatuses[d]==="busy";e({sendError:null}),m||t().setSessionStatus(d,"busy");try{const h=Nw.getState(),b=f!=null&&f.agent&&h.loaded&&h.agents.some(g=>g.name===f.agent||g.id===f.agent)?f.agent:void 0;return await mC(u,d,a,b,s,l),m&&(Ds[d]=(Ds[d]||0)+1),!0}catch(h){return e({sendError:h instanceof Error?h.message:"Failed to send message"}),m||t().setSessionStatus(d,"idle"),!1}},replyQuestion:async a=>{const s=Mn(),l=t().activeSessionId;if(!(!s||!l))try{await pC(s,l,a)}catch(u){e({sendError:u instanceof Error?u.message:"Failed to reply to question"})}},rejectQuestion:async()=>{const a=Mn(),s=t().activeSessionId;if(!(!a||!s))try{await gC(a,s)}catch{}},abortSession:async()=>{const a=Mn(),s=t().activeSessionId;if(!(!a||!s)){try{await hC(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(b=>b.id===s.id);let m,h=u.queuedMessageIds;if(f>=0){const b={...d[f],...s};(!s.parts||s.parts.length===0)&&d[f].parts&&(b.parts=d[f].parts),m=[...d],m[f]=b}else{m=[...d,s];const b=Ds[a]||0;if(s.role==="user"&&b>0){const g=[...h[a]??[]];g.push(s.id),h={...h,[a]:g},Ds[a]=b-1}else if(s.role==="assistant"){const g=h[a];g&&g.length>0&&(h={...h,[a]:g.slice(1)})}}return{messages:{...u.messages,[a]:m},queuedMessageIds:h}}),(l=s.parts)!=null&&l.some(u=>go(u)&&vc(u))&&Tm(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]:[],b=Rx(l),g=b!=null?h.findIndex(N=>Rx(N)===b):-1;g>=0?h[g]={...h[g],...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}}}),go(l)&&vc(l)&&Tm(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"},b=h.parts?[...h.parts]:[],g=b.findIndex(N=>N.id===l);if(g>=0){const N=b[g],S=Nc(N)+u;b[g]=N.content!=null?{...N,content:S}:{...N,text:S}}else b.push({id:l,type:"text",text:u});const y={...h,parts:b},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")Ft.getState().removeToast(Ny(a)),Ft.getState().addToast(`${f} — 完成`,"success",a);else if(s==="busy"&&(u===void 0||u==="idle"))Ft.getState().addToast(`${f} — 开始运行`,"info",a);else if(s==="retry")Ft.getState().addToast(`${f} — 进入重试`,"warning",a);else if(s==="error"){const m=l?`${f} — 错误: ${l}`:`${f} — 发生错误`;Ft.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=Mn();if(l){e(u=>({sessions:u.sessions.map(d=>d.id===a?{...d,title:s}:d)}));try{await zC(l,a,s)}catch{await t().loadSessions()}}},revertToMessage:async(a,s)=>{const l=Mn();if(!l)return!1;try{return await bC(l,a,s),await t().refreshSessionData(a),!0}catch{return!1}}})),Ge=Za((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=He.getState().activeRepoId;if(!l)return!1;try{await MC(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=He.getState().activeRepoId;if(!l)return!1;try{const u=await gy(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=He.getState().activeRepoId;if(!a){e({issues:[],loaded:!0});return}try{const s=await Tx(a,"all");e({issues:s,loaded:!0})}catch{e({loaded:!0})}},syncIssues:async()=>{const a=He.getState().activeRepoId;if(a){e({syncing:!0});try{await OC(a);const[s,l,u]=await Promise.all([Tx(a,"all"),Ex(a),yx(a)]);e({issues:s,tags:l,milestones:u,syncing:!1})}catch(s){e({syncing:!1});let l="同步 Issue 失败";if(s instanceof Xa)try{const u=JSON.parse(s.message);u.error&&(l=u.error)}catch{s.message&&(l=s.message)}Ft.getState().addToast(l,"error")}}},createIssue:async(a,s)=>{const l=He.getState().activeRepoId;if(!l)return null;try{const u=await IC(l,a,s);return e(d=>({issues:[u,...d.issues]})),u}catch{return null}},loadTags:async()=>{const a=He.getState().activeRepoId;if(!a){e({tags:[]});return}try{const s=await Ex(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=He.getState().activeRepoId;if(!a){e({milestones:[]});return}try{const s=await yx(a);e({milestones:s})}catch{}},setMilestoneFilter:a=>e({selectedMilestoneId:a})})),cc=Za(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 Ox(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 vy(e,t){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const Sw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Aw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Cw={};function Ix(e,t){return(Cw.jsx?Aw:Sw).test(e)}const ww=/[ \t\n\f\r]/g;function kw(e){return typeof e=="object"?e.type==="text"?Mx(e.value):!1:Mx(e)}function Mx(e){return e.replace(ww,"")===""}class vo{constructor(t,a,s){this.normal=a,this.property=t,s&&(this.space=s)}}vo.prototype.normal={};vo.prototype.property={};vo.prototype.space=void 0;function Sy(e,t){const a={},s={};for(const l of e)Object.assign(a,l.property),Object.assign(s,l.normal);return new vo(a,s,t)}function xo(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 Rw=0;const Ve=Ys(),sn=Ys(),lh=Ys(),Ee=Ys(),kt=Ys(),Us=Ys(),ia=Ys();function Ys(){return 2**++Rw}const oh=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ve,booleanish:sn,commaOrSpaceSeparated:ia,commaSeparated:Us,number:Ee,overloadedBoolean:lh,spaceSeparated:kt},Symbol.toStringTag,{value:"Module"})),_m=Object.keys(oh);class $h extends Qn{constructor(t,a,s,l){let u=-1;if(super(t,a),Dx(this,"space",l),typeof s=="number")for(;++u<_m.length;){const d=_m[u];Dx(this,_m[u],(s&oh[d])===oh[d])}}}$h.prototype.defined=!0;function Dx(e,t,a){a&&(e[t]=a)}function Ki(e){const t={},a={};for(const[s,l]of Object.entries(e.properties)){const u=new $h(s,e.transform(e.attributes||{},s),l,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(u.mustUseProperty=!0),t[s]=u,a[xo(s)]=s,a[xo(u.attribute)]=s}return new vo(t,a,e.space)}const Ay=Ki({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 Cy(e,t){return t in e?e[t]:t}function wy(e,t){return Cy(e,t.toLowerCase())}const Ow=Ki({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:lh,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:lh,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:wy}),Iw=Ki({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:Cy}),ky=Ki({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()}}),Ry=Ki({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:wy}),Oy=Ki({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Mw={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"},Dw=/[A-Z]/g,Lx=/-[a-z]/g,Lw=/^data[-\w.:]+$/i;function Vc(e,t){const a=xo(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"&&Lw.test(t)){if(t.charAt(4)==="-"){const u=t.slice(5).replace(Lx,Bw);s="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=t.slice(4);if(!Lx.test(u)){let d=u.replace(Dw,jw);d.charAt(0)!=="-"&&(d="-"+d),t="data"+d}}l=$h}return new l(s,t)}function jw(e){return"-"+e.toLowerCase()}function Bw(e){return e.charAt(1).toUpperCase()}const So=Sy([Ay,Ow,ky,Ry,Oy],"html"),ds=Sy([Ay,Iw,ky,Ry,Oy],"svg");function jx(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Iy(e){return e.join(" ").trim()}var Ii={},Nm,Bx;function Pw(){if(Bx)return Nm;Bx=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=`
|
|
453
453
|
`,h="/",b="*",g="",y="comment",T="declaration";function N(w,C){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];C=C||{};var A=1,O=1;function U(te){var ee=te.match(t);ee&&(A+=ee.length);var q=te.lastIndexOf(m);O=~q?te.length-q:O+te.length}function Q(){var te={line:A,column:O};return function(ee){return ee.position=new L(te),ne(),ee}}function L(te){this.start=te,this.end={line:A,column:O},this.source=C.source}L.prototype.content=w;function F(te){var ee=new Error(C.source+":"+A+":"+O+": "+te);if(ee.reason=te,ee.filename=C.source,ee.line=A,ee.column=O,ee.source=w,!C.silent)throw ee}function Z(te){var ee=te.exec(w);if(ee){var q=ee[0];return U(q),w=w.slice(q.length),ee}}function ne(){Z(a)}function j(te){var ee;for(te=te||[];ee=K();)ee!==!1&&te.push(ee);return te}function K(){var te=Q();if(!(h!=w.charAt(0)||b!=w.charAt(1))){for(var ee=2;g!=w.charAt(ee)&&(b!=w.charAt(ee)||h!=w.charAt(ee+1));)++ee;if(ee+=2,g===w.charAt(ee-1))return F("End of comment missing");var q=w.slice(2,ee-2);return O+=2,U(q),w=w.slice(ee),O+=2,te({type:y,comment:q})}}function V(){var te=Q(),ee=Z(s);if(ee){if(K(),!Z(l))return F("property missing ':'");var q=Z(u),k=te({type:T,property:S(ee[0].replace(e,g)),value:q?S(q[0].replace(e,g)):g});return Z(d),k}}function X(){var te=[];j(te);for(var ee;ee=V();)ee!==!1&&(te.push(ee),j(te));return te}return ne(),X()}function S(w){return w?w.replace(f,g):g}return Nm=N,Nm}var Px;function Uw(){if(Px)return Ii;Px=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(Pw());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:b}=m;f?l(h,b,m):b&&(u=u||{},u[h]=b)}),u}return Ii}var Vl={},Ux;function Hw(){if(Ux)return Vl;Ux=1,Object.defineProperty(Vl,"__esModule",{value:!0}),Vl.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,b){return b.toUpperCase()},f=function(h,b){return"".concat(b,"-")},m=function(h,b){return b===void 0&&(b={}),u(h)?h:(h=h.toLowerCase(),b.reactCompat?h=h.replace(l,f):h=h.replace(s,f),h.replace(t,d))};return Vl.camelCase=m,Vl}var Ql,Hx;function Fw(){if(Hx)return Ql;Hx=1;var e=Ql&&Ql.__importDefault||function(l){return l&&l.__esModule?l:{default:l}},t=e(Uw()),a=Hw();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,Ql=s,Ql}var zw=Fw();const qw=jc(zw),Qc=My("end"),Ja=My("start");function My(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 $w(e){const t=Ja(e),a=Qc(e);if(t&&a)return{start:t,end:a}}function ao(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Fx(e.position):"start"in e||"end"in e?Fx(e):"line"in e||"column"in e?uh(e):""}function uh(e){return zx(e&&e.line)+":"+zx(e&&e.column)}function Fx(e){return uh(e&&e.start)+"-"+uh(e&&e.end)}function zx(e){return e&&typeof e=="number"?e:1}class Cn 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=ao(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}}Cn.prototype.file="";Cn.prototype.name="";Cn.prototype.reason="";Cn.prototype.message="";Cn.prototype.stack="";Cn.prototype.column=void 0;Cn.prototype.line=void 0;Cn.prototype.ancestors=void 0;Cn.prototype.cause=void 0;Cn.prototype.fatal=void 0;Cn.prototype.place=void 0;Cn.prototype.ruleId=void 0;Cn.prototype.source=void 0;const Yh={}.hasOwnProperty,Yw=new Map,Gw=/[A-Z]/g,Kw=new Set(["table","tbody","thead","tfoot","tr"]),Vw=new Set(["td","th"]),Dy="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Qw(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=a5(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=n5(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=Ly(l,e,void 0);return u&&typeof u!="string"?u:l.create(e,l.Fragment,{children:u||void 0},void 0)}function Ly(e,t,a){if(t.type==="element")return Xw(e,t,a);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ww(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Jw(e,t,a);if(t.type==="mdxjsEsm")return Zw(e,t);if(t.type==="root")return e5(e,t,a);if(t.type==="text")return t5(e,t)}function Xw(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=By(e,t.tagName,!1),d=r5(e,t);let f=Kh(e,t);return Kw.has(t.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!kw(m):!0})),jy(e,d,u,t),Gh(d,f),e.ancestors.pop(),e.schema=s,e.create(t,u,d,a)}function Ww(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)}Eo(e,t.position)}function Zw(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Eo(e,t.position)}function Jw(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:By(e,t.name,!0),d=s5(e,t),f=Kh(e,t);return jy(e,d,u,t),Gh(d,f),e.ancestors.pop(),e.schema=s,e.create(t,u,d,a)}function e5(e,t,a){const s={};return Gh(s,Kh(e,t)),e.create(t,e.Fragment,s,a)}function t5(e,t){return t.value}function jy(e,t,a,s){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(t.node=s)}function Gh(e,t){if(t.length>0){const a=t.length>1?t:t[0];a&&(e.children=a)}}function n5(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 a5(e,t){return a;function a(s,l,u,d){const f=Array.isArray(u.children),m=Ja(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 r5(e,t){const a={};let s,l;for(l in t.properties)if(l!=="children"&&Yh.call(t.properties,l)){const u=i5(e,l,t.properties[l]);if(u){const[d,f]=u;e.tableCellAlignToStyle&&d==="align"&&typeof f=="string"&&Vw.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 s5(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 Eo(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 Eo(e,t.position);else u=s.value===null?!0:s.value;a[l]=u}return a}function Kh(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=Ly(e,u,d);f!==void 0&&a.push(f)}return a}function i5(e,t,a){const s=Vc(e.schema,t);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=s.commaSeparated?vy(a):Iy(a)),s.property==="style"){let l=typeof a=="object"?a:l5(e,String(a));return e.stylePropertyNameCase==="css"&&(l=o5(l)),["style",l]}return[e.elementAttributeNameCase==="react"&&s.space?Mw[s.property]||s.property:s.attribute,a]}}function l5(e,t){try{return qw(t,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const s=a,l=new Cn("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=Dy+"#cannot-parse-style-attribute",l}}function By(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=Ix(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=Ix(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const l=s.value;return Yh.call(e.components,l)?e.components[l]:l}if(e.evaluater)return e.evaluater.evaluateExpression(s);Eo(e)}function Eo(e,t){const a=new Cn("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=Dy+"#cannot-handle-mdx-estrees-without-createevaluater",a}function o5(e){const t={};let a;for(a in e)Yh.call(e,a)&&(t[u5(a)]=e[a]);return t}function u5(e){let t=e.replace(Gw,c5);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function c5(e){return"-"+e.toLowerCase()}const vm={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"]},d5={};function Vh(e,t){const a=d5,s=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,l=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Py(e,s,l)}function Py(e,t,a){if(f5(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 qx(e.children,t,a)}return Array.isArray(e)?qx(e,t,a):""}function qx(e,t,a){const s=[];let l=-1;for(;++l<e.length;)s[l]=Py(e[l],t,a);return s.join("")}function f5(e){return!!(e&&typeof e=="object")}const $x=document.createElement("i");function Qh(e){const t="&"+e+";";$x.innerHTML=t;const a=$x.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 Yx={}.hasOwnProperty;function Uy(e){const t={};let a=-1;for(;++a<e.length;)m5(t,e[a]);return t}function m5(e,t){let a;for(a in t){const l=(Yx.call(e,a)?e[a]:void 0)||(e[a]={}),u=t[a];let d;if(u)for(d in u){Yx.call(l,d)||(l[d]=[]);const f=u[d];h5(l[d],Array.isArray(f)?f:f?[f]:[])}}}function h5(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 Hy(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 Da(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ln=fs(/[A-Za-z]/),Sn=fs(/[\dA-Za-z]/),p5=fs(/[#-'*+\--9=?A-Z^-~]/);function Ac(e){return e!==null&&(e<32||e===127)}const ch=fs(/\d/),g5=fs(/[\dA-Fa-f]/),b5=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 Xc=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 Vi(e){const t=[];let a=-1,s=0,l=0;for(;++a<e.length;){const u=e.charCodeAt(a);let d="";if(u===37&&Sn(e.charCodeAt(a+1))&&Sn(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 x5={tokenize:E5};function E5(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 y5={tokenize:T5},Gx={tokenize:_5};function T5(e){const t=this,a=[];let s=0,l,u,d;return f;function f(O){if(s<a.length){const U=a[s];return t.containerState=U[1],e.attempt(U[0].continuation,m,h)(O)}return h(O)}function m(O){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,l&&A();const U=t.events.length;let Q=U,L;for(;Q--;)if(t.events[Q][0]==="exit"&&t.events[Q][1].type==="chunkFlow"){L=t.events[Q][1].end;break}C(s);let F=U;for(;F<t.events.length;)t.events[F][1].end={...L},F++;return la(t.events,Q+1,0,t.events.slice(U)),t.events.length=F,h(O)}return f(O)}function h(O){if(s===a.length){if(!l)return y(O);if(l.currentConstruct&&l.currentConstruct.concrete)return N(O);t.interrupt=!!(l.currentConstruct&&!l._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Gx,b,g)(O)}function b(O){return l&&A(),C(s),y(O)}function g(O){return t.parser.lazy[t.now().line]=s!==a.length,d=t.now().offset,N(O)}function y(O){return t.containerState={},e.attempt(Gx,T,N)(O)}function T(O){return s++,a.push([t.currentConstruct,t.containerState]),y(O)}function N(O){if(O===null){l&&A(),C(0),e.consume(O);return}return l=l||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:l,contentType:"flow",previous:u}),S(O)}function S(O){if(O===null){w(e.exit("chunkFlow"),!0),C(0),e.consume(O);return}return Ue(O)?(e.consume(O),w(e.exit("chunkFlow")),s=0,t.interrupt=void 0,f):(e.consume(O),S)}function w(O,U){const Q=t.sliceStream(O);if(U&&Q.push(null),O.previous=u,u&&(u.next=O),u=O,l.defineSkip(O.start),l.write(Q),t.parser.lazy[O.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 F=t.events.length;let Z=F,ne,j;for(;Z--;)if(t.events[Z][0]==="exit"&&t.events[Z][1].type==="chunkFlow"){if(ne){j=t.events[Z][1].end;break}ne=!0}for(C(s),L=F;L<t.events.length;)t.events[L][1].end={...j},L++;la(t.events,Z+1,0,t.events.slice(F)),t.events.length=L}}function C(O){let U=a.length;for(;U-- >O;){const Q=a[U];t.containerState=Q[1],Q[0].exit.call(t,e)}a.length=O}function A(){l.write([null]),u=void 0,l=void 0,t.containerState._closeFlow=void 0}}function _5(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 Hi(e){if(e===null||Rt(e)||qs(e))return 1;if(Xc(e))return 2}function Wc(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 dh={name:"attention",resolveAll:N5,tokenize:v5};function N5(e,t){let a=-1,s,l,u,d,f,m,h,b;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 g={...e[s][1].end},y={...e[a][1].start};Kx(g,-m),Kx(y,m),d={type:m>1?"strongSequence":"emphasisSequence",start:g,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,Wc(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?(b=2,h=_a(h,[["enter",e[a][1],t],["exit",e[a][1],t]])):b=0,la(e,s-1,a-s+3,h),a=s+h.length-b-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function v5(e,t){const a=this.parser.constructs.attentionMarkers.null,s=this.previous,l=Hi(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"),b=Hi(m),g=!b||b===2&&l||a.includes(m),y=!l||l===2&&b||a.includes(s);return h._open=!!(u===42?g:g&&(l||!y)),h._close=!!(u===42?y:y&&(b||!g)),t(m)}}function Kx(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const S5={name:"autolink",tokenize:A5};function A5(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 Ln(T)?(e.consume(T),d):T===64?a(T):h(T)}function d(T){return T===43||T===45||T===46||Sn(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||Sn(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||Ac(T)?a(T):(e.consume(T),m)}function h(T){return T===64?(e.consume(T),b):p5(T)?(e.consume(T),h):a(T)}function b(T){return Sn(T)?g(T):a(T)}function g(T){return T===46?(e.consume(T),s=0,b):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||Sn(T))&&s++<63){const N=T===45?y:g;return e.consume(T),N}return a(T)}}const Ao={partial:!0,tokenize:C5};function C5(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 Fy={continuation:{tokenize:k5},exit:R5,name:"blockQuote",tokenize:w5};function w5(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 k5(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(Fy,t,a)(d)}}function R5(e){e.exit("blockQuote")}const zy={name:"characterEscape",tokenize:O5};function O5(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 b5(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):a(u)}}const qy={name:"characterReference",tokenize:I5};function I5(e,t,a){const s=this;let l=0,u,d;return f;function f(g){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),m}function m(g){return g===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(g),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),u=31,d=Sn,b(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,d=g5,b):(e.enter("characterReferenceValue"),u=7,d=ch,b(g))}function b(g){if(g===59&&l){const y=e.exit("characterReferenceValue");return d===Sn&&!Qh(s.sliceSerialize(y))?a(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return d(g)&&l++<u?(e.consume(g),b):a(g)}}const Vx={partial:!0,tokenize:D5},Qx={concrete:!0,name:"codeFenced",tokenize:M5};function M5(e,t,a){const s=this,l={partial:!0,tokenize:Q};let u=0,d=0,f;return m;function m(L){return h(L)}function h(L){const F=s.events[s.events.length-1];return u=F&&F[1].type==="linePrefix"?F[2].sliceSerialize(F[1],!0).length:0,f=L,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),b(L)}function b(L){return L===f?(d++,e.consume(L),b):d<3?a(L):(e.exit("codeFencedFenceSequence"),rt(L)?ct(e,g,"whitespace")(L):g(L))}function g(L){return L===null||Ue(L)?(e.exit("codeFencedFence"),s.interrupt?t(L):e.check(Vx,S,U)(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"),g(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)?g(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"),g(L)):L===96&&L===f?a(L):(e.consume(L),N)}function S(L){return e.attempt(l,U,w)(L)}function w(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),C}function C(L){return u>0&&rt(L)?ct(e,A,"linePrefix",u+1)(L):A(L)}function A(L){return L===null||Ue(L)?e.check(Vx,S,U)(L):(e.enter("codeFlowValue"),O(L))}function O(L){return L===null||Ue(L)?(e.exit("codeFlowValue"),A(L)):(e.consume(L),O)}function U(L){return e.exit("codeFenced"),t(L)}function Q(L,F,Z){let ne=0;return j;function j(ee){return L.enter("lineEnding"),L.consume(ee),L.exit("lineEnding"),K}function K(ee){return L.enter("codeFencedFence"),rt(ee)?ct(L,V,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ee):V(ee)}function V(ee){return ee===f?(L.enter("codeFencedFenceSequence"),X(ee)):Z(ee)}function X(ee){return ee===f?(ne++,L.consume(ee),X):ne>=d?(L.exit("codeFencedFenceSequence"),rt(ee)?ct(L,te,"whitespace")(ee):te(ee)):Z(ee)}function te(ee){return ee===null||Ue(ee)?(L.exit("codeFencedFence"),F(ee)):Z(ee)}}}function D5(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 Sm={name:"codeIndented",tokenize:j5},L5={partial:!0,tokenize:B5};function j5(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 b=s.events[s.events.length-1];return b&&b[1].type==="linePrefix"&&b[2].sliceSerialize(b[1],!0).length>=4?d(h):a(h)}function d(h){return h===null?m(h):Ue(h)?e.attempt(L5,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 B5(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 P5={name:"codeText",previous:H5,resolve:U5,tokenize:F5};function U5(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 H5(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function F5(e,t,a){let s=0,l,u;return d;function d(g){return e.enter("codeText"),e.enter("codeTextSequence"),f(g)}function f(g){return g===96?(e.consume(g),s++,f):(e.exit("codeTextSequence"),m(g))}function m(g){return g===null?a(g):g===32?(e.enter("space"),e.consume(g),e.exit("space"),m):g===96?(u=e.enter("codeTextSequence"),l=0,b(g)):Ue(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),m):(e.enter("codeTextData"),h(g))}function h(g){return g===null||g===32||g===96||Ue(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),h)}function b(g){return g===96?(e.consume(g),l++,b):l===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(u.type="codeTextData",h(g))}}class z5{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&&Xl(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),Xl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Xl(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);Xl(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Xl(this.left,a.reverse())}}}function Xl(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 $y(e){const t={};let a=-1,s,l,u,d,f,m,h;const b=new z5(e);for(;++a<b.length;){for(;a in t;)a=t[a];if(s=b.get(a),a&&s[1].type==="chunkFlow"&&b.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,q5(b,a)),a=t[a],h=!0);else if(s[1]._container){for(u=a,l=void 0;u--;)if(d=b.get(u),d[1].type==="lineEnding"||d[1].type==="lineEndingBlank")d[0]==="enter"&&(l&&(b.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={...b.get(l)[1].start},f=b.slice(l,a),f.unshift(s),b.splice(l,a-l+1,f))}}return la(e,0,Number.POSITIVE_INFINITY,b.slice(0)),!h}function q5(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 b,g,y=-1,T=a,N=0,S=0;const w=[S];for(;T;){for(;e.get(++l)[1]!==T;);u.push(l),T._tokenizer||(b=s.sliceStream(T),T.next||b.push(null),g&&d.defineSkip(T.start),T._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=!0),d.write(b),T._isInFirstContentOfListItem&&(d._gfmTasklistFirstContentOfListItem=void 0)),g=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&&(S=y+1,w.push(S),T._tokenizer=void 0,T.previous=void 0,T=T.next);for(d.events=[],T?(T._tokenizer=void 0,T.previous=void 0):w.pop(),y=w.length;y--;){const C=f.slice(w[y],w[y+1]),A=u.pop();m.push([A,A+C.length-1]),e.splice(A,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 $5={resolve:G5,tokenize:K5},Y5={partial:!0,tokenize:V5};function G5(e){return $y(e),e}function K5(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 V5(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 Yy(e,t,a,s,l,u,d,f,m){const h=m||Number.POSITIVE_INFINITY;let b=0;return g;function g(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||Ac(C)?a(C):(e.enter(s),e.enter(d),e.enter(f),e.enter("chunkString",{contentType:"string"}),S(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 S(C){return!b&&(C===null||C===41||Rt(C))?(e.exit("chunkString"),e.exit(f),e.exit(d),e.exit(s),t(C)):b<h&&C===40?(e.consume(C),b++,S):C===41?(e.consume(C),b--,S):C===null||C===32||C===40||Ac(C)?a(C):(e.consume(C),C===92?w:S)}function w(C){return C===40||C===41||C===92?(e.consume(C),S):S(C)}}function Gy(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),b}function b(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"),b):(e.enter("chunkString",{contentType:"string"}),g(T))}function g(T){return T===null||T===91||T===93||Ue(T)||f++>999?(e.exit("chunkString"),b(T)):(e.consume(T),m||(m=!rt(T)),T===92?y:g)}function y(T){return T===91||T===92||T===93?(e.consume(T),f++,g):g(T)}}function Ky(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"}),b(y))}function b(y){return y===d||y===null||Ue(y)?(e.exit("chunkString"),h(y)):(e.consume(y),y===92?g:b)}function g(y){return y===d||y===92?(e.consume(y),b):b(y)}}function ro(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 Q5={name:"definition",tokenize:W5},X5={partial:!0,tokenize:Z5};function W5(e,t,a){const s=this;let l;return u;function u(T){return e.enter("definition"),d(T)}function d(T){return Gy.call(s,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(T)}function f(T){return l=Da(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)?ro(e,h)(T):h(T)}function h(T){return Yy(e,b,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(T)}function b(T){return e.attempt(X5,g,g)(T)}function g(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 Z5(e,t,a){return s;function s(f){return Rt(f)?ro(e,l)(f):a(f)}function l(f){return Ky(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 J5={name:"hardBreakEscape",tokenize:ek};function ek(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 tk={name:"headingAtx",resolve:nk,tokenize:ak};function nk(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 ak(e,t,a){let s=0;return l;function l(b){return e.enter("atxHeading"),u(b)}function u(b){return e.enter("atxHeadingSequence"),d(b)}function d(b){return b===35&&s++<6?(e.consume(b),d):b===null||Rt(b)?(e.exit("atxHeadingSequence"),f(b)):a(b)}function f(b){return b===35?(e.enter("atxHeadingSequence"),m(b)):b===null||Ue(b)?(e.exit("atxHeading"),t(b)):rt(b)?ct(e,f,"whitespace")(b):(e.enter("atxHeadingText"),h(b))}function m(b){return b===35?(e.consume(b),m):(e.exit("atxHeadingSequence"),f(b))}function h(b){return b===null||b===35||Rt(b)?(e.exit("atxHeadingText"),f(b)):(e.consume(b),h)}}const rk=["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"],Xx=["pre","script","style","textarea"],sk={concrete:!0,name:"htmlFlow",resolveTo:ok,tokenize:uk},ik={partial:!0,tokenize:dk},lk={partial:!0,tokenize:ck};function ok(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 uk(e,t,a){const s=this;let l,u,d,f,m;return h;function h(D){return b(D)}function b(D){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(D),g}function g(D){return D===33?(e.consume(D),y):D===47?(e.consume(D),u=!0,S):D===63?(e.consume(D),l=3,s.interrupt?t:B):Ln(D)?(e.consume(D),d=String.fromCharCode(D),w):a(D)}function y(D){return D===45?(e.consume(D),l=2,T):D===91?(e.consume(D),l=5,f=0,N):Ln(D)?(e.consume(D),l=4,s.interrupt?t:B):a(D)}function T(D){return D===45?(e.consume(D),s.interrupt?t:B):a(D)}function N(D){const _e="CDATA[";return D===_e.charCodeAt(f++)?(e.consume(D),f===_e.length?s.interrupt?t:V:N):a(D)}function S(D){return Ln(D)?(e.consume(D),d=String.fromCharCode(D),w):a(D)}function w(D){if(D===null||D===47||D===62||Rt(D)){const _e=D===47,ke=d.toLowerCase();return!_e&&!u&&Xx.includes(ke)?(l=1,s.interrupt?t(D):V(D)):rk.includes(d.toLowerCase())?(l=6,_e?(e.consume(D),C):s.interrupt?t(D):V(D)):(l=7,s.interrupt&&!s.parser.lazy[s.now().line]?a(D):u?A(D):O(D))}return D===45||Sn(D)?(e.consume(D),d+=String.fromCharCode(D),w):a(D)}function C(D){return D===62?(e.consume(D),s.interrupt?t:V):a(D)}function A(D){return rt(D)?(e.consume(D),A):j(D)}function O(D){return D===47?(e.consume(D),j):D===58||D===95||Ln(D)?(e.consume(D),U):rt(D)?(e.consume(D),O):j(D)}function U(D){return D===45||D===46||D===58||D===95||Sn(D)?(e.consume(D),U):Q(D)}function Q(D){return D===61?(e.consume(D),L):rt(D)?(e.consume(D),Q):O(D)}function L(D){return D===null||D===60||D===61||D===62||D===96?a(D):D===34||D===39?(e.consume(D),m=D,F):rt(D)?(e.consume(D),L):Z(D)}function F(D){return D===m?(e.consume(D),m=null,ne):D===null||Ue(D)?a(D):(e.consume(D),F)}function Z(D){return D===null||D===34||D===39||D===47||D===60||D===61||D===62||D===96||Rt(D)?Q(D):(e.consume(D),Z)}function ne(D){return D===47||D===62||rt(D)?O(D):a(D)}function j(D){return D===62?(e.consume(D),K):a(D)}function K(D){return D===null||Ue(D)?V(D):rt(D)?(e.consume(D),K):a(D)}function V(D){return D===45&&l===2?(e.consume(D),q):D===60&&l===1?(e.consume(D),k):D===62&&l===4?(e.consume(D),I):D===63&&l===3?(e.consume(D),B):D===93&&l===5?(e.consume(D),Te):Ue(D)&&(l===6||l===7)?(e.exit("htmlFlowData"),e.check(ik,re,X)(D)):D===null||Ue(D)?(e.exit("htmlFlowData"),X(D)):(e.consume(D),V)}function X(D){return e.check(lk,te,re)(D)}function te(D){return e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),ee}function ee(D){return D===null||Ue(D)?X(D):(e.enter("htmlFlowData"),V(D))}function q(D){return D===45?(e.consume(D),B):V(D)}function k(D){return D===47?(e.consume(D),d="",J):V(D)}function J(D){if(D===62){const _e=d.toLowerCase();return Xx.includes(_e)?(e.consume(D),I):V(D)}return Ln(D)&&d.length<8?(e.consume(D),d+=String.fromCharCode(D),J):V(D)}function Te(D){return D===93?(e.consume(D),B):V(D)}function B(D){return D===62?(e.consume(D),I):D===45&&l===2?(e.consume(D),B):V(D)}function I(D){return D===null||Ue(D)?(e.exit("htmlFlowData"),re(D)):(e.consume(D),I)}function re(D){return e.exit("htmlFlow"),t(D)}}function ck(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 dk(e,t,a){return s;function s(l){return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),e.attempt(Ao,t,a)}}const fk={name:"htmlText",tokenize:mk};function mk(e,t,a){const s=this;let l,u,d;return f;function f(B){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(B),m}function m(B){return B===33?(e.consume(B),h):B===47?(e.consume(B),Q):B===63?(e.consume(B),O):Ln(B)?(e.consume(B),Z):a(B)}function h(B){return B===45?(e.consume(B),b):B===91?(e.consume(B),u=0,N):Ln(B)?(e.consume(B),A):a(B)}function b(B){return B===45?(e.consume(B),T):a(B)}function g(B){return B===null?a(B):B===45?(e.consume(B),y):Ue(B)?(d=g,k(B)):(e.consume(B),g)}function y(B){return B===45?(e.consume(B),T):g(B)}function T(B){return B===62?q(B):B===45?y(B):g(B)}function N(B){const I="CDATA[";return B===I.charCodeAt(u++)?(e.consume(B),u===I.length?S:N):a(B)}function S(B){return B===null?a(B):B===93?(e.consume(B),w):Ue(B)?(d=S,k(B)):(e.consume(B),S)}function w(B){return B===93?(e.consume(B),C):S(B)}function C(B){return B===62?q(B):B===93?(e.consume(B),C):S(B)}function A(B){return B===null||B===62?q(B):Ue(B)?(d=A,k(B)):(e.consume(B),A)}function O(B){return B===null?a(B):B===63?(e.consume(B),U):Ue(B)?(d=O,k(B)):(e.consume(B),O)}function U(B){return B===62?q(B):O(B)}function Q(B){return Ln(B)?(e.consume(B),L):a(B)}function L(B){return B===45||Sn(B)?(e.consume(B),L):F(B)}function F(B){return Ue(B)?(d=F,k(B)):rt(B)?(e.consume(B),F):q(B)}function Z(B){return B===45||Sn(B)?(e.consume(B),Z):B===47||B===62||Rt(B)?ne(B):a(B)}function ne(B){return B===47?(e.consume(B),q):B===58||B===95||Ln(B)?(e.consume(B),j):Ue(B)?(d=ne,k(B)):rt(B)?(e.consume(B),ne):q(B)}function j(B){return B===45||B===46||B===58||B===95||Sn(B)?(e.consume(B),j):K(B)}function K(B){return B===61?(e.consume(B),V):Ue(B)?(d=K,k(B)):rt(B)?(e.consume(B),K):ne(B)}function V(B){return B===null||B===60||B===61||B===62||B===96?a(B):B===34||B===39?(e.consume(B),l=B,X):Ue(B)?(d=V,k(B)):rt(B)?(e.consume(B),V):(e.consume(B),te)}function X(B){return B===l?(e.consume(B),l=void 0,ee):B===null?a(B):Ue(B)?(d=X,k(B)):(e.consume(B),X)}function te(B){return B===null||B===34||B===39||B===60||B===61||B===96?a(B):B===47||B===62||Rt(B)?ne(B):(e.consume(B),te)}function ee(B){return B===47||B===62||Rt(B)?ne(B):a(B)}function q(B){return B===62?(e.consume(B),e.exit("htmlTextData"),e.exit("htmlText"),t):a(B)}function k(B){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),J}function J(B){return rt(B)?ct(e,Te,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):Te(B)}function Te(B){return e.enter("htmlTextData"),d(B)}}const Xh={name:"labelEnd",resolveAll:bk,resolveTo:xk,tokenize:Ek},hk={tokenize:yk},pk={tokenize:Tk},gk={tokenize:_k};function bk(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 xk(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}},b={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",b,t]]),f=_a(f,Wc(t.parser.constructs.insideSpan.null,e.slice(u+s+4,d-3),t)),f=_a(f,[["exit",b,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 Ek(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?g(y):(d=s.parser.defined.includes(Da(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(hk,b,d?b:g)(y):y===91?e.attempt(pk,b,d?h:g)(y):d?b(y):g(y)}function h(y){return e.attempt(gk,b,g)(y)}function b(y){return t(y)}function g(y){return u._balanced=!0,a(y)}}function yk(e,t,a){return s;function s(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),l}function l(g){return Rt(g)?ro(e,u)(g):u(g)}function u(g){return g===41?b(g):Yy(e,d,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function d(g){return Rt(g)?ro(e,m)(g):b(g)}function f(g){return a(g)}function m(g){return g===34||g===39||g===40?Ky(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):b(g)}function h(g){return Rt(g)?ro(e,b)(g):b(g)}function b(g){return g===41?(e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),e.exit("resource"),t):a(g)}}function Tk(e,t,a){const s=this;return l;function l(f){return Gy.call(s,e,u,d,"reference","referenceMarker","referenceString")(f)}function u(f){return s.parser.defined.includes(Da(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(f):a(f)}function d(f){return a(f)}}function _k(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 Nk={name:"labelStartImage",resolveAll:Xh.resolveAll,tokenize:vk};function vk(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 Sk={name:"labelStartLink",resolveAll:Xh.resolveAll,tokenize:Ak};function Ak(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 Am={name:"lineEnding",tokenize:Ck};function Ck(e,t){return a;function a(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),ct(e,t,"linePrefix")}}const dc={name:"thematicBreak",tokenize:wk};function wk(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:Ik},exit:Dk,name:"list",tokenize:Ok},kk={partial:!0,tokenize:Lk},Rk={partial:!0,tokenize:Mk};function Ok(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:ch(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(dc,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 ch(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(Ao,s.interrupt?a:b,e.attempt(kk,y,g))}function b(T){return s.containerState.initialBlankLine=!0,u++,y(T)}function g(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 Ik(e,t,a){const s=this;return s.containerState._closeFlow=void 0,e.check(Ao,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(Rk,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 Mk(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 Dk(e){e.exit(this.containerState.type)}function Lk(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 Wx={name:"setextUnderline",resolveTo:jk,tokenize:Bk};function jk(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 Bk(e,t,a){const s=this;let l;return u;function u(h){let b=s.events.length,g;for(;b--;)if(s.events[b][1].type!=="lineEnding"&&s.events[b][1].type!=="linePrefix"&&s.events[b][1].type!=="content"){g=s.events[b][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||g)?(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 Pk={tokenize:Uk};function Uk(e){const t=this,a=e.attempt(Ao,s,e.attempt(this.parser.constructs.flowInitial,l,ct(e,e.attempt(this.parser.constructs.flow,l,e.attempt($5,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 Hk={resolveAll:Qy()},Fk=Vy("string"),zk=Vy("text");function Vy(e){return{resolveAll:Qy(e==="text"?qk: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(b){return h(b)?u(b):f(b)}function f(b){if(b===null){a.consume(b);return}return a.enter("data"),a.consume(b),m}function m(b){return h(b)?(a.exit("data"),u(b)):(a.consume(b),m)}function h(b){if(b===null)return!0;const g=l[b];let y=-1;if(g)for(;++y<g.length;){const T=g[y];if(!T.previous||T.previous.call(s,s.previous))return!0}return!1}}}function Qy(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 qk(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 $k={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:Fy},Yk={91:Q5},Gk={[-2]:Sm,[-1]:Sm,32:Sm},Kk={35:tk,42:dc,45:[Wx,dc],60:sk,61:Wx,95:dc,96:Qx,126:Qx},Vk={38:qy,92:zy},Qk={[-5]:Am,[-4]:Am,[-3]:Am,33:Nk,38:qy,42:dh,60:[S5,fk],91:Sk,92:[J5,zy],93:Xh,95:dh,96:P5},Xk={null:[dh,Hk]},Wk={null:[42,95]},Zk={null:[]},Jk=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Wk,contentInitial:Yk,disable:Zk,document:$k,flow:Kk,flowInitial:Gk,insideSpan:Xk,string:Vk,text:Qk},Symbol.toStringTag,{value:"Module"}));function eR(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:F(Q),check:F(L),consume:A,enter:O,exit:U,interrupt:F(L,{interrupt:!0})},h={code:null,containerState:{},defineSkip:S,events:[],now:N,parser:e,previous:null,sliceSerialize:y,sliceStream:T,write:g};let b=t.tokenize.call(h,m);return t.resolveAll&&u.push(t),h;function g(K){return d=_a(d,K),w(),d[d.length-1]!==null?[]:(Z(t,0),h.events=Wc(u,h.events,h),h.events)}function y(K,V){return nR(T(K),V)}function T(K){return tR(d,K)}function N(){const{_bufferIndex:K,_index:V,line:X,column:te,offset:ee}=s;return{_bufferIndex:K,_index:V,line:X,column:te,offset:ee}}function S(K){l[K.line]=K.column,j()}function w(){let K;for(;s._index<d.length;){const V=d[s._index];if(typeof V=="string")for(K=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===K&&s._bufferIndex<V.length;)C(V.charCodeAt(s._bufferIndex));else C(V)}}function C(K){b=b(K)}function A(K){Ue(K)?(s.line++,s.column=1,s.offset+=K===-3?2:1,j()):K!==-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=K}function O(K,V){const X=V||{};return X.type=K,X.start=N(),h.events.push(["enter",X,h]),f.push(X),X}function U(K){const V=f.pop();return V.end=N(),h.events.push(["exit",V,h]),V}function Q(K,V){Z(K,V.from)}function L(K,V){V.restore()}function F(K,V){return X;function X(te,ee,q){let k,J,Te,B;return Array.isArray(te)?re(te):"tokenize"in te?re([te]):I(te);function I(Re){return $e;function $e(dt){const ut=dt!==null&&Re[dt],zt=dt!==null&&Re.null,Tn=[...Array.isArray(ut)?ut:ut?[ut]:[],...Array.isArray(zt)?zt:zt?[zt]:[]];return re(Tn)(dt)}}function re(Re){return k=Re,J=0,Re.length===0?q:D(Re[J])}function D(Re){return $e;function $e(dt){return B=ne(),Te=Re,Re.partial||(h.currentConstruct=Re),Re.name&&h.parser.constructs.disable.null.includes(Re.name)?ke():Re.tokenize.call(V?Object.assign(Object.create(h),V):h,m,_e,ke)(dt)}}function _e(Re){return K(Te,B),ee}function ke(Re){return B.restore(),++J<k.length?D(k[J]):q}}}function Z(K,V){K.resolveAll&&!u.includes(K)&&u.push(K),K.resolve&&la(h.events,V,h.events.length-V,K.resolve(h.events.slice(V),h)),K.resolveTo&&(h.events=K.resolveTo(h.events,h))}function ne(){const K=N(),V=h.previous,X=h.currentConstruct,te=h.events.length,ee=Array.from(f);return{from:te,restore:q};function q(){s=K,h.previous=V,h.currentConstruct=X,h.events.length=te,f=ee,j()}}function j(){s.line in l&&s.column<2&&(s.column=l[s.line],s.offset+=l[s.line]-1)}}function tR(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 nR(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=`
|
|
@@ -486,7 +486,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Kt=xe,xt=je),et===void
|
|
|
486
486
|
`,1;if(nl>1e5&&nl>De.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Et+=Xe,Xe.length}const pn=On(xe);if(!pn)throw _t(Ct.replace("{}",xe)),new Error('Unknown language: "'+xe+'"');const Po=Wt(pn);let ni="",ze=xt||Po;const Uo={},Jt=new we.__emitter(we);tl();let Et="",Ir=0,ir=0,nl=0,Mr=!1;try{if(pn.__emitTokens)pn.__emitTokens(je,Jt);else{for(ze.matcher.considerAll();;){nl++,Mr?Mr=!1:ze.matcher.considerAll(),ze.matcher.lastIndex=ir;const Ne=ze.matcher.exec(je);if(!Ne)break;const De=je.substring(ir,Ne.index),Xe=ti(De,Ne);ir=Ne.index+Xe}ti(je.substring(ir))}return Jt.finalize(),ni=Jt.toHTML(),{language:xe,value:ni,relevance:Ir,illegal:!1,_emitter:Jt,_top:ze}}catch(Ne){if(Ne.message&&Ne.message.includes("Illegal"))return{language:xe,value:Rn(je),illegal:!0,relevance:0,_illegalBy:{message:Ne.message,index:ir,context:je.slice(ir-100,ir+100),mode:Ne.mode,resultSoFar:ni},_emitter:Jt};if(Mt)return{language:xe,value:Rn(je),illegal:!1,relevance:0,errorRaised:Ne,_emitter:Jt,_top:ze};throw Ne}}function Xs(xe){const je={value:Rn(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(On).filter(Rr).map(It=>ar(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(On(It.language).supersetOf===Zn.language)return 1;if(On(Zn.language).supersetOf===It.language)return-1}return 0}),[Nn,Wn]=Kt,Pn=Nn;return Pn.secondBest=Wn,Pn}function Ha(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=Yt(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 Ua("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",Ha(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=Mo(we,xe)}const kr=()=>{Zs(),de("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Zi(){Zs(),de("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Do=!1;function Zs(){function xe(){Zs()}if(document.readyState==="loading"){Do||window.addEventListener("DOMContentLoaded",xe,!1),Do=!0;return}document.querySelectorAll(we.cssSelector).forEach(Gt)}function Lo(xe,je){let et=null;try{et=je(Y)}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,Y),et.aliases&&rr(et.aliases,{languageName:xe})}function ps(xe){delete me[xe];for(const je of Object.keys(Se))Se[je]===xe&&delete Se[je]}function Ji(){return Object.keys(me)}function On(xe){return xe=(xe||"").toLowerCase(),me[xe]||me[Se[xe]]}function rr(xe,{languageName:je}){typeof xe=="string"&&(xe=[xe]),xe.forEach(et=>{Se[et.toLowerCase()]=je})}function Rr(xe){const je=On(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),Ye.push(xe)}function jo(xe){const je=Ye.indexOf(xe);je!==-1&&Ye.splice(je,1)}function gs(xe,je){const et=xe;Ye.forEach(function(xt){xt[et]&&xt[et](je)})}function sr(xe){return de("10.7.0","highlightBlock will be removed entirely in v12.0"),de("10.7.0","Please use highlightElement now."),Gt(xe)}Object.assign(Y,{highlight:jt,highlightAuto:Ws,highlightAll:Zs,highlightElement:Gt,highlightBlock:sr,configure:_n,initHighlighting:kr,initHighlightingOnLoad:Zi,registerLanguage:Lo,unregisterLanguage:ps,listLanguages:Ji,getLanguage:On,registerAliases:rr,autoDetection:Rr,inherit:Mo,addPlugin:Zt,removePlugin:jo}),Y.debugMode=function(){Mt=!1},Y.safeMode=function(){Mt=!0},Y.versionString=bt,Y.regex={concat:S,lookahead:y,either:C,optional:N,anyNumberOfTimes:T};for(const xe in zt)typeof zt[xe]=="object"&&e(zt[xe]);return Object.assign(Y,zt),Y},Bn=hs({});return Bn.newInstance=()=>hs({}),Fm=Bn,Bn.HighlightJS=Bn,Bn.default=Bn,Fm}var GM=YM();const KM=jc(GM),L1={},VM="hljs-";function QM(e){const t=KM.newInstance();return e&&u(e),{highlight:a,highlightAuto:s,listLanguages:l,register:u,registerAlias:d,registered:f};function a(m,h,b){const g=b||L1,y=typeof g.prefix=="string"?g.prefix:VM;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:XM,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,S=N.data;return S.language=T.language,S.relevance=T.relevance,N}function s(m,h){const g=(h||L1).subset||l();let y=-1,T=0,N;for(;++y<g.length;){const S=g[y];if(!t.getLanguage(S))continue;const w=a(S,m,h);w.data&&w.data.relevance!==void 0&&w.data.relevance>T&&(T=w.data.relevance,N=w)}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 b;for(b in m)Object.hasOwn(m,b)&&t.registerLanguage(b,m[b])}}function d(m,h){if(typeof m=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:m});else{let b;for(b in m)if(Object.hasOwn(m,b)){const g=m[b];t.registerAliases(typeof g=="string"?g:[...g],{languageName:b})}}}function f(m){return!!t.getLanguage(m)}}class XM{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 WM={};function ZM(e){const t=e||WM,a=t.aliases,s=t.detect||!1,l=t.languages||$M,u=t.plainText,d=t.prefix,f=t.subset;let m="hljs";const h=QM(l);if(a&&h.registerAlias(a),d){const b=d.indexOf("-");m=b===-1?d:d.slice(0,b)}return function(b,g){wo(b,"element",function(y,T,N){if(y.tagName!=="code"||!N||N.type!=="element"||N.tagName!=="pre")return;const S=JM(y);if(S===!1||!S&&!s||S&&u&&u.includes(S))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(m)||y.properties.className.unshift(m);const w=b6(y,{whitespace:"pre"});let C;try{C=S?h.highlight(S,w,{prefix:d}):h.highlightAuto(w,{prefix:d,subset:f})}catch(A){const O=A;if(S&&/Unknown language/.test(O.message)){g.message("Cannot highlight as `"+S+"`, it’s not registered",{ancestors:[N,y],cause:O,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw O}!S&&C.data&&C.data.language&&y.properties.className.push("language-"+C.data.language),C.children.length>0&&(y.children=C.children)})}}function JM(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 eD({q:e,pending:t,selected:a,customText:s,onSelect:l,onCustomTextChange:u,onClearSelections:d,onSubmitCustom:f,isSingle:m}){const[h,b]=v.useState(!1),g=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=!g&&((a==null?void 0:a.includes(y.label))??!1);return o.jsxs("button",{type:"button",disabled:!t,onClick:()=>{b(!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:()=>{g?(b(!1),u("")):(b(!0),d())},className:oe("rounded-md border px-3 py-1.5 text-left text-xs transition-colors",g?"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:[g&&o.jsx(oa,{className:"mr-1 inline h-3 w-3"}),o.jsx("span",{className:"font-medium",children:"其他…"})]})]}),g&&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(Ec,{className:"h-3 w-3"})})]})]})}function tD({part:e}){const t=xw(e),a=qh(e),s=a==="pending"||a==="running",l=Ie(Z=>Z.activeSessionId),u=Ie(Z=>Z.replyQuestion),d=Ie(Z=>Z.rejectQuestion),[f,m]=v.useState(null),[h,b]=v.useState({}),[g,y]=v.useState({});if(!t||t.length===0)return null;const T=t.length===1,N=()=>{l&&Ft.getState().removeToast(`question-${l}`)},S=(Z,ne)=>{if(!f){if(y(j=>{const{[Z]:K,...V}=j;return V}),T){m("answered"),N(),u([[ne]]);return}b(j=>{const K=t[Z],V=j[Z]??[];if(K.multiple){const X=V.includes(ne);return{...j,[Z]:X?V.filter(te=>te!==ne):[...V,ne]}}return{...j,[Z]:[ne]}})}},w=(Z,ne)=>{y(j=>{if(ne)return{...j,[Z]:ne};const{[Z]:K,...V}=j;return V})},C=Z=>{b(ne=>{const{[Z]:j,...K}=ne;return K})},A=Z=>{var j;const ne=(j=g[Z])==null?void 0:j.trim();f||!ne||(m("answered"),N(),u([[ne]]))},O=t.filter((Z,ne)=>{var j,K;return(((j=h[ne])==null?void 0:j.length)??0)>0||(((K=g[ne])==null?void 0:K.trim().length)??0)>0}).length,U=!T&&O===t.length,Q=()=>{if(f||!U)return;m("answered"),N();const Z=t.map((ne,j)=>{var V;const K=(V=g[j])==null?void 0:V.trim();return K?[K]:h[j]??[]});u(Z)},L=()=>{f||(m("dismissed"),N(),d())},F=s&&!f;return o.jsxs("div",{className:oe("my-1 overflow-hidden rounded-md border bg-term/70",F?"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(t3,{className:oe("h-3.5 w-3.5 shrink-0",F?"text-blue-400":"text-fg-4")}),o.jsx("span",{className:oe("font-medium",F?"text-blue-300":"text-fg-3"),children:f==="answered"?"已回复":f==="dismissed"?"已取消":F?"等待回复":"Question"}),!T&&F&&o.jsxs("span",{className:"text-fg-5",children:["(",O,"/",t.length,")"]}),F&&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((Z,ne)=>o.jsx(eD,{q:Z,pending:F,selected:h[ne],customText:g[ne]??"",onSelect:j=>S(ne,j),onCustomTextChange:j=>w(ne,j),onClearSelections:()=>C(ne),onSubmitCustom:T?()=>A(ne):void 0,isSingle:T},ne)),!T&&F&&o.jsx("div",{className:"flex justify-end pt-1",children:o.jsxs("button",{type:"button",disabled:!U,onClick:Q,className:oe("flex items-center gap-1.5 rounded-md px-4 py-1.5 text-xs font-medium transition-colors",U?"bg-emerald-600 text-white hover:bg-emerald-500":"bg-surface/50 text-fg-5 cursor-not-allowed"),children:[o.jsx(Ec,{className:"h-3 w-3"}),o.jsx("span",{children:"提交回答"})]})})]})]})}const zm=2e3,nD={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"},aD={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 o0(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:null}function Va(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 rD(e,t){const a=e.toLowerCase(),s=nD[a]??e.charAt(0).toUpperCase()+e.slice(1),l=o0(t);switch(a){case"read":case"write":case"edit":case"patch":return{label:s,arg:Va(l,["filePath","path","file"])};case"grep":{const u=Va(l,["pattern","query"]);return{label:s,arg:u?`"${u}"`:null}}case"glob":return{label:s,arg:Va(l,["pattern","query"])};case"bash":case"shell":{const u=Va(l,["command","cmd","script"]);return{label:s,arg:u?u.split(`
|
|
487
487
|
`)[0]:null}}case"webfetch":case"fetch":return{label:s,arg:Va(l,["url"])};case"task":case"agent":return{label:s,arg:Va(l,["description","prompt","title"])};default:return{label:s,arg:Va(l,["filePath","path","pattern","query","command","url","description"])}}}function sD({oldStr:e,newStr:t}){const a=e.split(`
|
|
488
488
|
`),s=t.split(`
|
|
489
|
-
`);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 j1={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 a_({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=j1[l]??j1.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 iD={"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"},lD={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 oD({record:e}){const[t,a]=v.useState(!1),s=typeof e.category=="string"?e.category:null,l=typeof e.subagent_type=="string"?e.subagent_type:null,u=Va(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,b=s??l,g=(s&&iD[s])??(l&&lD[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:[b&&o.jsx("span",{className:oe("rounded px-1.5 py-0.5 text-[10px] font-medium",g),children:b}),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(Uh,{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 uD(e){const t=yw(e),a=Ie(m=>m.activeSessionId),s=Ie(m=>m.sessions);if(t)return t;if(!a)return null;const l=Kc(e),u=o0(l),d=Va(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 cD({part:e}){const t=uD(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(ZS,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"shrink-0",children:"查看子会话"})]}):null}function dD(e,t){const a=o0(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(sD,{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(a_,{todos:l})}if(s==="bash"||s==="shell"){const l=Va(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(oD,{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 fD(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(a_,{todos:s})}return null}function mD({part:e}){const t=qh(e),a=t==="running"||t==="pending",[s,l]=v.useState(a),[u,d]=v.useState(!1),f=v.useRef(a);v.useEffect(()=>{f.current!==a&&(l(a),f.current=a)},[a]);const m=_y(e),h=m.toLowerCase(),b=h==="task"||h==="agent",g=Kc(e),{label:y,arg:T}=rD(m,g),N=dD(m,g),S=N?null:wx(g),w=zh(e),C=fD(m,w),A=C?"":wx(w),O=aD[t],U=A.length>zm,Q=u||!U?A:`${A.slice(0,zm)}…`;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",O.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",O.color),children:[o.jsx("span",{className:oe(O.spin&&"fs-spin"),children:O.glyph}),o.jsx("span",{children:O.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",O.accent),children:[N&&o.jsx("section",{className:"mb-2",children:N}),S&&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:S})]}),b&&o.jsx(cD,{part:e}),C&&o.jsx("section",{children:C}),A&&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:Q}),U&&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 ${A.length-zm} more chars`})]}),!N&&!S&&!C&&!A&&o.jsx("div",{className:"text-fg-5",children:"no parameters"})]})})]})}function hD({text:e}){const[t,a]=v.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(Ia,{className:"h-3 w-3 shrink-0"}):o.jsx(Uh,{className:"h-3 w-3 shrink-0"}),o.jsx(WE,{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 pD(){const[e,t]=v.useState(0);return v.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(WE,{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 r_({part:e,className:t}){var a;return e.url?(a=e.mime)!=null&&a.startsWith("image/")?o.jsx(IT,{url:e.url,label:e.filename??"attachment",className:oe("object-contain",t??"max-h-80")}):o.jsxs("div",{className:"flex items-center gap-1.5 font-mono text-xs text-fg-5",children:[o.jsx(x3,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{children:e.filename??e.mime??"attachment"})]}):null}function gD({part:e,isStreaming:t}){switch(_c(e)){case"text":{const s=Nc(e);return s.trim()?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[ZM],components:{table:s0},children:s})}):null}case"thinking":{const s=Nc(e);return s.trim()?o.jsx(hD,{text:s}):t?o.jsx(pD,{}):null}case"tool":return go(e)?o.jsx(tD,{part:e}):o.jsx(mD,{part:e});case"file":return o.jsx(r_,{part:e});default:return null}}function bD({message:e,isStreaming:t,queued:a}){var b,g,y,T,N,S;const s=e.role==="user",l=e.parts??[],u=l.filter(w=>_c(w)!=="other");if(s){const w=l.map(Nc).join("").trim(),C=l.filter(U=>_c(U)==="file"),A=(b=e.time)==null?void 0:b.created,O=A?new Date(A*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"}),O&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsx("span",{className:"text-fg-5",children:O})]}),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:w||"…"})]}),C.length>0&&o.jsx("div",{className:"mt-2 flex flex-wrap gap-2 pl-5",children:C.map((U,Q)=>o.jsx(r_,{part:U,className:"max-h-40"},U.id??Q))})]})}const d=((g=e.info)==null?void 0:g.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(An,{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"}),((S=m.data)==null?void 0:S.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((w,C)=>o.jsx(gD,{part:w,isStreaming:t},w.id??w.callID??C)):!m&&(t?o.jsx("span",{className:"text-fg-5",children:"…"}):o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-400/80",children:[o.jsx(An,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{children:"空响应 — Agent 未产出任何内容"})]}))})]})}const xD={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 ED(e){const t=e.find(s=>Ui(s.status)==="in_progress");if(t)return t.content;const a=e.find(s=>Ui(s.status)==="pending");return a?a.content:"all steps complete"}function yD({todos:e,onClick:t}){if(e.length===0)return null;const a=e.length,s=bw(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=xD[Ui(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:ED(e)}),o.jsx("span",{className:"shrink-0 text-[10px] text-fg-5",children:"详情 →"})]})})}function TD({isListening:e,disabled:t,onClick:a,error:s}){return o.jsx("button",{type:"button",onClick:a,disabled:t,"aria-label":e?"停止语音输入":"语音输入",title:s??(e?"点击停止":"语音输入"),className:oe("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors duration-150 disabled:cursor-not-allowed disabled:text-fg-6/40",e?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"text-fg-5 hover:text-fg-3"),children:o.jsx(l3,{className:oe("h-4 w-4",e&&"animate-pulse")})})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var zi;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(zi||(zi={}));class qm extends Error{constructor(t,a,s){super(t),this.message=t,this.code=a,this.data=s}}const _D=e=>{var t,a;return e!=null&&e.androidBridge?"android":!((a=(t=e==null?void 0:e.webkit)===null||t===void 0?void 0:t.messageHandlers)===null||a===void 0)&&a.bridge?"ios":"web"},ND=e=>{const t=e.CapacitorCustomPlatform||null,a=e.Capacitor||{},s=a.Plugins=a.Plugins||{},l=()=>t!==null?t.name:_D(e),u=()=>l()!=="web",d=g=>{const y=h.get(g);return!!(y!=null&&y.platforms.has(l())||f(g))},f=g=>{var y;return(y=a.PluginHeaders)===null||y===void 0?void 0:y.find(T=>T.name===g)},m=g=>e.console.error(g),h=new Map,b=(g,y={})=>{const T=h.get(g);if(T)return console.warn(`Capacitor plugin "${g}" already registered. Cannot register plugins twice.`),T.proxy;const N=l(),S=f(g);let w;const C=async()=>(!w&&N in y?w=typeof y[N]=="function"?w=await y[N]():w=y[N]:t!==null&&!w&&"web"in y&&(w=typeof y.web=="function"?w=await y.web():w=y.web),w),A=(Z,ne)=>{var j,K;if(S){const V=S==null?void 0:S.methods.find(X=>ne===X.name);if(V)return V.rtype==="promise"?X=>a.nativePromise(g,ne.toString(),X):(X,te)=>a.nativeCallback(g,ne.toString(),X,te);if(Z)return(j=Z[ne])===null||j===void 0?void 0:j.bind(Z)}else{if(Z)return(K=Z[ne])===null||K===void 0?void 0:K.bind(Z);throw new qm(`"${g}" plugin is not implemented on ${N}`,zi.Unimplemented)}},O=Z=>{let ne;const j=(...K)=>{const V=C().then(X=>{const te=A(X,Z);if(te){const ee=te(...K);return ne=ee==null?void 0:ee.remove,ee}else throw new qm(`"${g}.${Z}()" is not implemented on ${N}`,zi.Unimplemented)});return Z==="addListener"&&(V.remove=async()=>ne()),V};return j.toString=()=>`${Z.toString()}() { [capacitor code] }`,Object.defineProperty(j,"name",{value:Z,writable:!1,configurable:!1}),j},U=O("addListener"),Q=O("removeListener"),L=(Z,ne)=>{const j=U({eventName:Z},ne),K=async()=>{const X=await j;Q({eventName:Z,callbackId:X},ne)},V=new Promise(X=>j.then(()=>X({remove:K})));return V.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await K()},V},F=new Proxy({},{get(Z,ne){switch(ne){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return S?L:U;case"removeListener":return Q;default:return O(ne)}}});return s[g]=F,h.set(g,{name:g,proxy:F,platforms:new Set([...Object.keys(y),...S?[N]:[]])}),F};return a.convertFileSrc||(a.convertFileSrc=g=>g),a.getPlatform=l,a.handleError=m,a.isNativePlatform=u,a.isPluginAvailable=d,a.registerPlugin=b,a.Exception=qm,a.DEBUG=!!a.DEBUG,a.isLoggingEnabled=!!a.isLoggingEnabled,a},vD=e=>e.Capacitor=ND(e),Ic=vD(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Ro=Ic.registerPlugin;class u0{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(t,a){let s=!1;this.listeners[t]||(this.listeners[t]=[],s=!0),this.listeners[t].push(a);const u=this.windowListeners[t];u&&!u.registered&&this.addWindowListener(u),s&&this.sendRetainedArgumentsForEvent(t);const d=async()=>this.removeListener(t,a);return Promise.resolve({remove:d})}async removeAllListeners(){this.listeners={};for(const t in this.windowListeners)this.removeWindowListener(this.windowListeners[t]);this.windowListeners={}}notifyListeners(t,a,s){const l=this.listeners[t];if(!l){if(s){let u=this.retainedEventArguments[t];u||(u=[]),u.push(a),this.retainedEventArguments[t]=u}return}l.forEach(u=>u(a))}hasListeners(t){var a;return!!(!((a=this.listeners[t])===null||a===void 0)&&a.length)}registerWindowListener(t,a){this.windowListeners[a]={registered:!1,windowEventName:t,pluginEventName:a,handler:s=>{this.notifyListeners(a,s)}}}unimplemented(t="not implemented"){return new Ic.Exception(t,zi.Unimplemented)}unavailable(t="not available"){return new Ic.Exception(t,zi.Unavailable)}async removeListener(t,a){const s=this.listeners[t];if(!s)return;const l=s.indexOf(a);this.listeners[t].splice(l,1),this.listeners[t].length||this.removeWindowListener(this.windowListeners[t])}addWindowListener(t){window.addEventListener(t.windowEventName,t.handler),t.registered=!0}removeWindowListener(t){t&&(window.removeEventListener(t.windowEventName,t.handler),t.registered=!1)}sendRetainedArgumentsForEvent(t){const a=this.retainedEventArguments[t];a&&(delete this.retainedEventArguments[t],a.forEach(s=>{this.notifyListeners(t,s)}))}}const B1=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),P1=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class SD extends u0{async getCookies(){const t=document.cookie,a={};return t.split(";").forEach(s=>{if(s.length<=0)return;let[l,u]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");l=P1(l).trim(),u=P1(u).trim(),a[l]=u}),a}async setCookie(t){try{const a=B1(t.key),s=B1(t.value),l=t.expires?`; expires=${t.expires.replace("expires=","")}`:"",u=(t.path||"/").replace("path=",""),d=t.url!=null&&t.url.length>0?`domain=${t.url}`:"";document.cookie=`${a}=${s||""}${l}; path=${u}; ${d};`}catch(a){return Promise.reject(a)}}async deleteCookie(t){try{document.cookie=`${t.key}=; Max-Age=0`}catch(a){return Promise.reject(a)}}async clearCookies(){try{const t=document.cookie.split(";")||[];for(const a of t)document.cookie=a.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(t){return Promise.reject(t)}}async clearAllCookies(){try{await this.clearCookies()}catch(t){return Promise.reject(t)}}}Ro("CapacitorCookies",{web:()=>new SD});const AD=async e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>{const l=s.result;t(l.indexOf(",")>=0?l.split(",")[1]:l)},s.onerror=l=>a(l),s.readAsDataURL(e)}),CD=(e={})=>{const t=Object.keys(e);return Object.keys(e).map(l=>l.toLocaleLowerCase()).reduce((l,u,d)=>(l[u]=e[t[d]],l),{})},wD=(e,t=!0)=>e?Object.entries(e).reduce((s,l)=>{const[u,d]=l;let f,m;return Array.isArray(d)?(m="",d.forEach(h=>{f=t?encodeURIComponent(h):h,m+=`${u}=${f}&`}),m.slice(0,-1)):(f=t?encodeURIComponent(d):d,m=`${u}=${f}`),`${s}&${m}`},"").substr(1):null,kD=(e,t={})=>{const a=Object.assign({method:e.method||"GET",headers:e.headers},t),l=CD(e.headers)["content-type"]||"";if(typeof e.data=="string")a.body=e.data;else if(l.includes("application/x-www-form-urlencoded")){const u=new URLSearchParams;for(const[d,f]of Object.entries(e.data||{}))u.set(d,f);a.body=u.toString()}else if(l.includes("multipart/form-data")||e.data instanceof FormData){const u=new FormData;if(e.data instanceof FormData)e.data.forEach((f,m)=>{u.append(m,f)});else for(const f of Object.keys(e.data))u.append(f,e.data[f]);a.body=u;const d=new Headers(a.headers);d.delete("content-type"),a.headers=d}else(l.includes("application/json")||typeof e.data=="object")&&(a.body=JSON.stringify(e.data));return a};class RD extends u0{async request(t){const a=kD(t,t.webFetchExtra),s=wD(t.params,t.shouldEncodeUrlParams),l=s?`${t.url}?${s}`:t.url,u=await fetch(l,a),d=u.headers.get("content-type")||"";let{responseType:f="text"}=u.ok?t:{};d.includes("application/json")&&(f="json");let m,h;switch(f){case"arraybuffer":case"blob":h=await u.blob(),m=await AD(h);break;case"json":m=await u.json();break;case"document":case"text":default:m=await u.text()}const b={};return u.headers.forEach((g,y)=>{b[y]=g}),{data:m,headers:b,status:u.status,url:u.url}}async get(t){return this.request(Object.assign(Object.assign({},t),{method:"GET"}))}async post(t){return this.request(Object.assign(Object.assign({},t),{method:"POST"}))}async put(t){return this.request(Object.assign(Object.assign({},t),{method:"PUT"}))}async patch(t){return this.request(Object.assign(Object.assign({},t),{method:"PATCH"}))}async delete(t){return this.request(Object.assign(Object.assign({},t),{method:"DELETE"}))}}Ro("CapacitorHttp",{web:()=>new RD});var U1;(function(e){e.Dark="DARK",e.Light="LIGHT",e.Default="DEFAULT"})(U1||(U1={}));var H1;(function(e){e.StatusBar="StatusBar",e.NavigationBar="NavigationBar"})(H1||(H1={}));class OD extends u0{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}}Ro("SystemBars",{web:()=>new OD});const ID="modulepreload",MD=function(e){return"/"+e},F1={},DD=function(t,a,s){let l=Promise.resolve();if(a&&a.length>0){let d=function(h){return Promise.all(h.map(b=>Promise.resolve(b).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));l=d(a.map(h=>{if(h=MD(h),h in F1)return;F1[h]=!0;const b=h.endsWith(".css"),g=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const y=document.createElement("link");if(y.rel=b?"stylesheet":ID,b||(y.as="script"),y.crossOrigin="",y.href=h,m&&y.setAttribute("nonce",m),document.head.appendChild(y),b)return new Promise((T,N)=>{y.addEventListener("load",T),y.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return l.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return t().catch(u)})},Mi=Ro("SpeechRecognition",{web:()=>DD(()=>import("./web-DQLuJ5FC.js"),[]).then(e=>new e.SpeechRecognitionWeb)});function LD(e,t){const a=e.length,s=new ArrayBuffer(44+a*2),l=new DataView(s),u=(d,f)=>{for(let m=0;m<f.length;m++)l.setUint8(d+m,f.charCodeAt(m))};u(0,"RIFF"),l.setUint32(4,36+a*2,!0),u(8,"WAVE"),u(12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,1,!0),l.setUint16(22,1,!0),l.setUint32(24,t,!0),l.setUint32(28,t*2,!0),l.setUint16(32,2,!0),l.setUint16(34,16,!0),u(36,"data"),l.setUint32(40,a*2,!0);for(let d=0;d<a;d++){const f=Math.max(-1,Math.min(1,e[d]));l.setInt16(44+d*2,f<0?f*32768:f*32767,!0)}return new Blob([s],{type:"audio/wav"})}const xh=Ic.isNativePlatform(),$m=!xh&&typeof window<"u"?window.SpeechRecognition??window.webkitSpeechRecognition:void 0,Ym=16e3;function jD(e="zh-CN"){const[t,a]=v.useState(!1),[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState(null),[h,b]=v.useState(0),g=v.useRef(null),y=v.useRef(!1),T=v.useRef([]),N=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),C=v.useRef(null),A=v.useRef(null),O=v.useRef([]),U=!0,Q=v.useCallback(async()=>{var J,Te,B;(J=A.current)==null||J.disconnect(),(Te=C.current)==null||Te.getTracks().forEach(I=>I.stop()),await((B=w.current)==null?void 0:B.close().catch(()=>{}));const V=O.current;if(O.current=[],A.current=null,C.current=null,w.current=null,V.length===0){a(!1);return}d("识别中…");const X=V.reduce((I,re)=>I+re.length,0),te=new Float32Array(X);let ee=0;for(const I of V)te.set(I,ee),ee+=I.length;const q=LD(te,Ym),k=new FormData;k.append("audio",q,"recording.wav");try{const I=await fetch("/api/transcribe",{method:"POST",body:k});if(I.ok){const{text:re}=await I.json();re&&l(re)}else{const re=await I.json().catch(()=>({error:`HTTP ${I.status}`}));m(re.error??`HTTP ${I.status}`)}}catch(I){m(`语音识别失败:${I instanceof Error?I.message:String(I)}`)}finally{d(""),a(!1)}},[]),L=v.useCallback(async()=>{if(y.current=!0,S.current&&(clearTimeout(S.current),S.current=null),xh){await Mi.stop().catch(()=>{});for(const V of T.current)await V.remove().catch(()=>{});T.current=[],a(!1),d("")}else g.current?g.current.stop():w.current?await Q():a(!1)},[Q]),F=v.useCallback(async()=>{var ee;l(""),d(""),m(null);const{available:V}=await Mi.available();if(!V){m("当前设备不支持语音识别");return}if((await Mi.requestPermissions()).speechRecognition!=="granted"){m("请允许语音识别权限");return}const te=[];te.push(await Mi.addListener("partialResults",q=>{d(q.matches[0]??"")})),te.push(await Mi.addListener("listeningState",q=>{const k=q.status==="started";a(k),k||d("")})),T.current=te;try{const q=await Mi.start({language:e,partialResults:!0,maxResults:1});(ee=q.matches)!=null&&ee.length&&l(k=>k+q.matches.join(""))}catch(q){m(`语音识别错误:${q instanceof Error?q.message:String(q)}`);for(const k of te)await k.remove().catch(()=>{});T.current=[]}},[e]),Z=v.useCallback(()=>{if(!$m)return!1;l(""),d(""),m(null),y.current=!1;const V=new $m;V.lang=e,V.continuous=!0,V.interimResults=!0,V.maxAlternatives=1,V.onstart=()=>{a(!0),N.current=!1,S.current=setTimeout(()=>{!N.current&&!y.current&&m("未检测到语音,请检查麦克风或网络连接(Chrome 需访问 Google 服务器)")},5e3)},V.onresult=X=>{N.current=!0,S.current&&(clearTimeout(S.current),S.current=null);let te="",ee="";for(let q=X.resultIndex;q<X.results.length;q++){const k=X.results[q][0].transcript;X.results[q].isFinal?te+=k:ee+=k}te&&l(q=>q+te),d(ee)},V.onerror=X=>{switch(X.error!=="no-speech"&&X.error!=="aborted"&&(y.current=!0),X.error){case"not-allowed":m("请允许麦克风权限");break;case"network":m("网络错误,请检查连接");break;case"no-speech":case"aborted":return;default:m(`语音识别错误:${X.error}`)}},V.onend=()=>{if(d(""),!y.current)try{V.start();return}catch{}a(!1),g.current=null},g.current=V;try{return V.start(),!0}catch{return!1}},[e]),ne=v.useCallback(async()=>{l(""),d(""),m(null);try{const q=await fetch("/api/transcribe/status"),{available:k}=await q.json();if(!k){m("语音识别服务未就绪,请稍后重试");return}}catch{m("无法连接语音识别服务");return}let V;try{V=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:Ym,channelCount:1}})}catch{m("请允许麦克风权限");return}const X=new AudioContext({sampleRate:Ym}),te=X.createMediaStreamSource(V),ee=X.createScriptProcessor(4096,1,1);O.current=[],ee.onaudioprocess=q=>{O.current.push(new Float32Array(q.inputBuffer.getChannelData(0)))},te.connect(ee),ee.connect(X.destination),w.current=X,C.current=V,A.current=ee,a(!0)},[]),j=v.useCallback(()=>{xh?F():$m&&Z()||ne()},[F,Z,ne]);v.useEffect(()=>{if(!t){b(0);return}let V=!1,X=null,te=null,ee=0;return(async()=>{try{if(X=await navigator.mediaDevices.getUserMedia({audio:!0}),V){X.getTracks().forEach(I=>I.stop());return}te=new AudioContext;const q=te.createMediaStreamSource(X),k=te.createAnalyser();k.fftSize=256,q.connect(k);const J=new Uint8Array(k.frequencyBinCount);let Te=0;const B=()=>{if(V)return;k.getByteFrequencyData(J);const I=performance.now();if(I-Te>80){let re=0;for(let D=0;D<J.length;D++)re+=J[D];b(re/(J.length*255)),Te=I}ee=requestAnimationFrame(B)};ee=requestAnimationFrame(B)}catch{}})(),()=>{V=!0,cancelAnimationFrame(ee),X==null||X.getTracks().forEach(q=>q.stop()),te==null||te.close().catch(()=>{}),b(0)}},[t]),v.useEffect(()=>()=>{var V,X,te,ee;y.current=!0,(V=g.current)==null||V.stop(),(X=A.current)==null||X.disconnect(),(te=C.current)==null||te.getTracks().forEach(q=>q.stop()),(ee=w.current)==null||ee.close().catch(()=>{});for(const q of T.current)q.remove().catch(()=>{})},[]);const K=v.useCallback(()=>{l(""),d("")},[]);return{isSupported:U,isListening:t,transcript:s,interimTranscript:u,error:f,volumeLevel:h,start:j,stop:L,resetTranscript:K}}const BD=200;function PD(){return Ie(e=>{const t=e.activeSessionId;if(!t)return!1;const a=e.messages[t]??bo;for(let s=a.length-1;s>=0;s--){const l=a[s].parts;if(l){for(const u of l)if(_c(u)==="tool"&&vc(u))return!0}}return!1})}function UD(){var q;const[e,t]=v.useState(""),[a,s]=v.useState(""),[l,u]=v.useState([]),d=v.useRef(null),f=jD(),m=v.useRef(""),h=Ie(k=>k.activeSessionId),b=He(k=>k.activeRepoId),g=Ie(k=>{const J=k.activeSessionId;return J?k.sessionStatuses[J]:void 0}),y=Ie(k=>k.sendMessage),T=cc(k=>k.setDraft),N=cc(k=>k.clearDraft),S=PD();v.useEffect(()=>{if(!b){u([]);return}let k=!1;return(async()=>{try{const[J,Te]=await Promise.all([Gc(),Yc(b)]);if(k)return;const B=J.pinned_models,I=B?JSON.parse(B):[];u(I.length>0?Te.filter(re=>I.includes(re.id)):[])}catch{k||u([])}})(),()=>{k=!0}},[b]);const w=g==="busy"&&!S,C=!h;v.useLayoutEffect(()=>{const k=d.current;k&&(k.style.height="auto",k.style.height=`${Math.min(k.scrollHeight,BD)}px`)},[e]);const A=((q=l.find(k=>k.id===a))==null?void 0:q.supportsImage)!==!1,{attachments:O,promptFiles:U,error:Q,addFiles:L,onPaste:F,remove:Z,clear:ne}=MT(A);v.useEffect(()=>{t(h?cc.getState().drafts[h]??"":""),ne(),f.stop()},[h,ne,f.stop]);const j=async()=>{const k=e.trim();if(C||!k&&O.length===0)return;await y(k,a||void 0,U.length>0?U:void 0)&&(t(""),ne(),h&&N(h))},K=k=>{k.nativeEvent.isComposing||k.keyCode===229||k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),j())},V=()=>{f.isListening?f.stop():(m.current=e,f.start())};v.useEffect(()=>{f.isListening&&t(m.current+f.transcript+f.interimTranscript)},[f.isListening,f.transcript,f.interimTranscript]);const X=v.useRef(!1);v.useEffect(()=>{if(X.current&&!f.isListening&&f.transcript){const k=m.current+f.transcript;t(k),h&&T(h,k)}X.current=f.isListening},[f.isListening,f.transcript,h,T]);const te=h?S?"输入回复,或点击上方选项…":w?"输入消息将排队等待处理…":"enter a command…":"select or start a run",ee=h?f.isListening?"text-red-400 fs-blink":w?"text-amber-400 fs-blink":S?"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.jsx(LT,{attachments:O,error:Q,onRemove:Z,className:"mx-auto max-w-4xl"}),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",C?"border-line":f.isListening?"border-red-500/60":"border-fg-5 focus-within:border-fg-4"),children:[o.jsx("span",{className:oe("select-none pt-px font-mono text-sm leading-6",ee),children:"❯"}),o.jsx("textarea",{ref:d,rows:2,value:e,disabled:C,onChange:k=>{const J=k.target.value;t(J),h&&T(h,J)},onKeyDown:K,onPaste:F,placeholder:te,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(DT,{onFiles:k=>void L(k),disabled:C,allowed:A}),o.jsx(TD,{isListening:f.isListening,disabled:C,onClick:V,error:f.error}),o.jsx("button",{type:"button",onClick:j,disabled:C||e.trim().length===0&&O.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(XE,{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:[f.isListening&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"font-mono text-[10px] text-red-400",children:"● 录音中"}),o.jsx("div",{className:"h-1 w-16 overflow-hidden rounded-full bg-fg-6/30",children:o.jsx("div",{className:"h-full rounded-full bg-red-400 transition-[width] duration-75",style:{width:`${Math.round(f.volumeLevel*100)}%`}})})]}),f.error&&o.jsx("span",{className:"font-mono text-[10px] text-red-400",children:f.error}),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:k=>s(k.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(k=>o.jsx("option",{value:k.id,children:k.name||k.id},k.id))]})]})]})}const z1={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 q1({status:e,reason:t}){const a=z1[e??"idle"]??z1.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 HD={"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},$1=1e6;function FD(e){if(!e)return $1;for(const[t,a]of Object.entries(HD))if(e.startsWith(t))return a;return $1}function Y1(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function zD(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>0?`$${e.toFixed(4)}`:"$0"}function qD(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 G1({session:e,messages:t}){var m,h,b;const a=qD(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=FD((b=e==null?void 0:e.model)==null?void 0:b.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:Y1(l)}),o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsxs("span",{className:f,title:`上下文占比 (${Y1(u)} 窗口)`,children:[d,"%"]}),o.jsx("span",{className:"text-fg-6",children:"·"})]}),o.jsx("span",{title:"会话累计费用",children:zD(s)})]})}const $D=144,YD=64;function s_({onToggleSidebar:e}){const[t,a]=v.useState(""),[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState(""),[h,b]=v.useState(!1),g=v.useRef(null),y=v.useRef(null),[T,N]=v.useState([]),S=Ie(I=>I.createSession),w=Ie(I=>I.sendError),C=He(I=>I.activeRepoId),A=Bi(I=>I.agents),O=Ge(I=>I.issues),U=Ge(I=>I.selectedIssueId),Q=Ge(I=>I.pendingDraft);v.useEffect(()=>{if(!C){N([]);return}let I=!1;return Yc(C).then(re=>{I||N(re)}).catch(()=>{I||N([])}),()=>{I=!0}},[C]);const L=T.length===0||T.some(I=>I.supportsImage!==!1),{attachments:F,promptFiles:Z,error:ne,addFiles:j,onPaste:K,remove:V,clear:X}=MT(L);v.useEffect(()=>{U&&(d(U),Ge.getState().setSelectedIssue(null))},[U]),v.useEffect(()=>{Q&&(a(Q),Ge.getState().setPendingDraft(null))},[Q]),v.useLayoutEffect(()=>{const I=g.current;I&&(I.style.height="auto",I.style.height=`${Math.min(I.scrollHeight,$D)}px`)},[t]),v.useEffect(()=>{const I=re=>{y.current&&!y.current.contains(re.target)&&b(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);const te=O.filter(I=>I.state==="open"),ee=O.find(I=>I.id===u),q=f.trim().toLowerCase(),k=q?te.filter(I=>`#${I.number} ${I.title}`.toLowerCase().includes(q)):te,J=!!s||!!u,Te=()=>{const I=t.trim();!C||!I&&!J&&F.length===0||(a(""),X(),S(I,void 0,void 0,void 0,u||void 0,s||void 0,Z.length>0?Z:void 0))},B=I=>{I.nativeEvent.isComposing||I.keyCode===229||I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),Te())};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(zc,{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.jsx(LT,{attachments:F,error:ne,onRemove:V}),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:g,rows:1,value:t,autoFocus:!0,disabled:!C,onChange:I=>a(I.target.value),onKeyDown:B,onPaste:K,placeholder:C?"让 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(DT,{onFiles:I=>void j(I),disabled:!C,allowed:!0}),o.jsx("button",{type:"button",onClick:Te,disabled:!C||!t.trim()&&!J&&F.length===0,"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(XE,{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:I=>l(I.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:"默认"}),A.map(I=>o.jsx("option",{value:I.id,children:I.name},I.id))]})]}),O.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:()=>{b(I=>!I),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:ee?`#${ee.number} ${ee.title}`:"无"}),o.jsx(Ia,{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:I=>m(I.target.value),onKeyDown:I=>{I.key==="Escape"&&b(!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:[!q&&o.jsx("li",{children:o.jsx("button",{type:"button",onClick:()=>{d(""),b(!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:"无"})}),k.map(I=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>{d(I.id),m(""),b(!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",I.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",I.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",I.number]}),o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:I.title})]})},I.id)),k.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+⏎ 开始运行"}),w&&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:w})]})]})}function K1({body:e}){return e?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],components:{table:s0},children:e})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"没有描述内容"})}function V1({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 GD({onToggleSidebar:e}){const t=Ge(b=>b.matchingParentId),a=Ge(b=>b.matchingCandidateId),s=Ge(b=>b.issues.find(g=>g.id===t)),l=Ge(b=>b.issues.find(g=>g.id===a)),u=Ge(b=>b.exitMatchMode),d=Ge(b=>b.linkChild),[f,m]=v.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(zc,{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(V1,{issue:s})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:o.jsx(K1,{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(V1,{issue:l})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:o.jsx(K1,{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 KD({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(s_,{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(zc,{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(bc,{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($s,{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(qc,{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:s0},children:a.body})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"该 Issue 没有描述内容"})})})]})}function VD({onToggleSidebar:e,onToggleRightPanel:t,rightPanelOpen:a}){var ee,q;const s=Aa(),l=He(ja),u=Ie(k=>k.activeSessionId),d=Ge(k=>k.previewIssueId),f=Ie(k=>k.sessions.find(J=>J.id===k.activeSessionId)??null),m=Ie(k=>{const J=k.activeSessionId;return J?k.messages[J]??bo:bo}),h=Ie(k=>{const J=k.activeSessionId;return J?k.todos[J]??Sc:Sc}),b=Ie(k=>{const J=k.activeSessionId;return J?k.sessionStatuses[J]:void 0}),g=Ie(k=>{const J=k.activeSessionId;return J?k.queuedMessageIds[J]??kx:kx}),y=Ie(k=>{const J=k.activeSessionId;return J?k.errorReasons[J]:void 0}),T=Ie(k=>k.sendError),N=Ie(k=>k.abortSession),S=Ie(k=>k.revertToMessage),w=He(k=>k.repos.find(J=>J.id===k.activeRepoId)),C=(w==null?void 0:w.runtimeType)!=="claude-code",[A,O]=v.useState(null),[U,Q]=v.useState(!1),L=Ge(k=>f!=null&&f.issueId?k.issues.find(J=>J.id===f.issueId):void 0);v.useEffect(()=>{if(u)return kc.activateSession(u),()=>kc.deactivateSession(u)},[u]);const F=v.useRef(null),Z=v.useRef(!0),[ne,j]=v.useState(!1);v.useEffect(()=>{const k=F.current;k&&Z.current&&(k.scrollTop=k.scrollHeight)},[m,h]),v.useEffect(()=>{Z.current=!0,j(!1)},[u]),v.useEffect(()=>{if(b!=="busy"&&b!=="retry")return;const k=J=>{if(J.key!=="Escape"||J.defaultPrevented)return;const Te=J.target;Te instanceof HTMLInputElement||Te instanceof HTMLTextAreaElement||Te!=null&&Te.isContentEditable||N()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[b,N]);const K=Ge(k=>k.matchingParentId);if(!u)return K?o.jsx(GD,{onToggleSidebar:e}):d?o.jsx(KD,{onToggleSidebar:e}):o.jsx(s_,{onToggleSidebar:e});const V=b==="busy",X=b==="retry",te=V||X;return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-term",children:[o.jsxs("header",{className:"border-b border-line bg-base md:hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",onClick:()=>Q(k=>!k),children:[o.jsxs("div",{className:"flex items-center gap-1",onClick:k=>k.stopPropagation(),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(zc,{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(Wa,{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:k=>{k.stopPropagation(),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(cx,{className:"h-3 w-3"}),"返回父会话"]}),o.jsx("h2",{className:"text-sm font-medium leading-snug text-fg",children:((ee=f==null?void 0:f.title)==null?void 0:ee.trim())||"untitled run"})]}),te&&o.jsx("span",{className:oe("h-2 w-2 shrink-0 rounded-full","bg-amber-400 animate-pulse")}),!te&&b==="error"&&o.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-red-400"}),o.jsx(Ia,{className:oe("h-4 w-4 shrink-0 text-fg-5 transition-transform duration-200",U&&"rotate-180")})]}),o.jsx("div",{className:oe("grid transition-[grid-template-rows] duration-200 ease-in-out",U?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:o.jsx("div",{className:"overflow-hidden",children:o.jsxs("div",{className:"flex flex-col gap-2.5 border-t border-line/60 px-4 py-3",children:[(f==null?void 0:f.agent)&&o.jsxs("div",{className:"flex items-center gap-2 font-mono text-xs text-fg-4",children:[o.jsx("span",{className:"w-14 shrink-0 text-fg-5",children:"Agent"}),o.jsx("span",{className:"truncate",children:f.agent})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-14 shrink-0 font-mono text-xs text-fg-5",children:"Status"}),o.jsx(q1,{status:b,reason:y})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-14 shrink-0 font-mono text-xs text-fg-5",children:"Context"}),o.jsx(G1,{session:f,messages:m})]}),L&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-14 shrink-0 font-mono text-xs text-fg-5",children:"Issue"}),o.jsxs("button",{type:"button",onClick:()=>s(`/${encodeURIComponent(l)}/issues?issueId=${L.id}`),className:"flex items-center gap-1.5 truncate font-mono text-xs text-fg-3 transition-colors hover:text-blue-400",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 text-[10px] font-semibold",L.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",L.number]}),o.jsx("span",{className:"truncate",children:L.title})]})]}),te&&o.jsxs("button",{type:"button",onClick:()=>void N(),className:"mt-0.5 flex w-full items-center justify-center gap-1.5 rounded-md border border-line px-2.5 py-1.5 font-mono text-xs text-fg-2 transition-colors hover:border-red-500/50 hover:text-red-400",children:[o.jsx(eh,{className:"h-3 w-3 fill-current"}),X?"stop retry":"stop"]})]})})})]}),o.jsxs("header",{className:"hidden items-center gap-3 border-b border-line bg-base px-4 py-2.5 md:flex",children:[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(cx,{className:"h-3 w-3"}),"返回父会话"]}),o.jsx("h2",{className:"truncate text-sm font-medium text-fg",children:((q=f==null?void 0:f.title)==null?void 0:q.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(G1,{session:f,messages:m})]}),L&&o.jsxs("button",{type:"button",onClick:()=>s(`/${encodeURIComponent(l)}/issues?issueId=${L.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",L.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",L.number]}),o.jsx("span",{className:"hidden max-w-[120px] truncate sm:inline",children:L.title})]}),o.jsx(q1,{status:b,reason:y}),t&&o.jsx("button",{type:"button",onClick:t,"aria-label":a?"关闭侧边栏":"打开侧边栏",className:oe("flex items-center justify-center rounded-md border border-line p-1.5 transition-colors",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(ty,{className:"h-4 w-4"})}),te&&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(eh,{className:"h-3 w-3 fill-current"}),X?"stop retry":"stop"]})]}),o.jsxs("div",{className:"relative min-h-0 flex-1",children:[o.jsx("div",{ref:F,onScroll:()=>{const k=F.current;if(!k)return;const J=k.scrollHeight-k.clientHeight-k.scrollTop<=YD;Z.current=J,j(!J)},className:"h-full 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((k,J)=>o.jsxs(v.Fragment,{children:[J>0&&k.role==="user"&&o.jsx("div",{className:"group/revert relative border-t border-line py-2",children:C&&!te&&o.jsxs("button",{type:"button",disabled:A!==null,onClick:async()=>{const Te=m.length-J;window.confirm(`回退到此处?将移除后续 ${Te} 条对话记录(不影响已产生的代码改动)。`)&&(O(k.id),await S(u,k.id),O(null))},className:"absolute left-1/2 top-1/2 z-10 flex -translate-x-1/2 -translate-y-1/2 items-center gap-1 rounded-full border border-line bg-base px-2.5 py-1 font-mono text-[11px] text-fg-4 opacity-60 shadow-sm transition-all duration-150 hover:border-amber-500/50 hover:text-amber-400 md:opacity-30 md:group-hover/revert:opacity-100 disabled:opacity-50",children:[A===k.id?o.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}):o.jsx(S3,{className:"h-3 w-3"}),"回退到此处"]})}),o.jsx("div",{"data-message-id":k.id,children:o.jsx(bD,{message:k,isStreaming:V&&J===m.length-1,queued:g.includes(k.id)})})]},k.id)),h.length>0&&o.jsx(yD,{todos:[...h],onClick:t})]})}),o.jsx("button",{type:"button",onClick:()=>{const k=F.current;k&&(k.scrollTo({top:k.scrollHeight,behavior:"smooth"}),Z.current=!0)},"aria-label":"滚动到底部",className:oe("absolute bottom-4 right-4 z-10 flex h-9 w-9 items-center justify-center rounded-full border border-line bg-surface/90 text-fg-4 shadow-lg backdrop-blur transition-all duration-200","hover:bg-elevated hover:text-fg-2",ne?"translate-y-0 opacity-100":"pointer-events-none translate-y-2 opacity-0"),children:o.jsx(Ia,{className:"h-4 w-4"})})]}),b==="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(An,{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(An,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"truncate",children:T})]}),o.jsx(UD,{})]})}const Vn=Za((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=He.getState().activeRepoId;if(!l)return!1;try{return await BC(l,a,s),!0}catch{return!1}},unlinkIssue:async(a,s)=>{const l=He.getState().activeRepoId;if(!l)return!1;try{return await PC(l,a,s),!0}catch{return!1}},loadPulls:async()=>{const a=He.getState().activeRepoId;if(!a){e({pulls:[],loaded:!0});return}try{const s=await Nx(a,"all");e({pulls:s,loaded:!0})}catch{e({loaded:!0})}},syncPulls:async()=>{const a=He.getState().activeRepoId;if(a){e({syncing:!0});try{await LC(a);const s=await Nx(a,"all");e({pulls:s,syncing:!1})}catch(s){e({syncing:!1});let l="同步 PR 失败";if(s instanceof Xa)try{const u=JSON.parse(s.message);u.error&&(l=u.error)}catch{s.message&&(l=s.message)}Ft.getState().addToast(l,"error")}}}})),QD={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 XD(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 WD(e){if(!e.parts)return"";for(const t of e.parts){const a=t.content??t.text;if(a)return a}return""}function ZD({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=Ui(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=Ui(a.status),l=QD[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 JD({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=WD(s),d=XD(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 eL({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(Fc,{className:"ml-auto h-3 w-3 shrink-0 text-emerald-400"})]})})})}function tL({links:e,sessionId:t}){var L,F,Z,ne;const a=Aa(),s=He(ja),[l,u]=v.useState(null),[d,f]=v.useState(""),m=v.useRef(null),h=Ge(j=>j.issues),b=Vn(j=>j.pulls),g=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(((F=e==null?void 0:e.pullRequests)==null?void 0:F.map(j=>j.id))??[]);v.useEffect(()=>{var j;l&&((j=m.current)==null||j.focus())},[l]);const S=()=>{u(null),f("")},w=async(j,K,V)=>{t&&(V?await y(t,j,K):await g(t,j,K))},C=d.trim().toLowerCase(),A=C?h.filter(j=>`#${j.number} ${j.title}`.toLowerCase().includes(C)):h,O=C?b.filter(j=>`#${j.number} ${j.title} ${j.headBranch}`.toLowerCase().includes(C)):b,U=((Z=e==null?void 0:e.issues)==null?void 0:Z.length)??0,Q=((ne=e==null?void 0:e.pullRequests)==null?void 0:ne.length)??0;if(l){const j=l==="issue",K=j?A:O,V=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:S,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:X=>f(X.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:K.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:(j?h:b).length===0?j?"暂无 Issue,请先同步":"暂无 PR,请先同步":"无匹配结果"}):o.jsx("ul",{className:"space-y-0.5",children:K.map(X=>o.jsx(eL,{linked:V.has(X.id),number:X.number,title:X.title,state:X.state,mergedAt:j?void 0:X.mergedAt,isPr:!j,onToggle:()=>w(l,X.id,V.has(X.id))},X.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:U+Q>0?`${U+Q} 项关联`:"暂无关联"}),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(Wa,{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(Wa,{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:[U>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 (",U,")"]}),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 w("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))})]}),Q>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 (",Q,")"]}),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 w("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))})]}),U===0&&Q===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 nL={"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 aL(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 Gm(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 rL(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 sL(){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)=>(Gm(h)??0)-(Gm(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,b=a[m.id],g=Gm(m),y=(m.agent&&nL[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",aL(b))}),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}),g!=null&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-fg-6",children:rL(g)})]}),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 Q1({todos:e,messages:t,sessionLinks:a,sessionId:s,onScrollToMessage:l}){var N,S;const[u,d]=v.useState("todo"),f=Ie(w=>w.sessions),m=Ie(w=>w.activeSessionId),h=t.filter(w=>w.role==="user").length,b=(((N=a==null?void 0:a.issues)==null?void 0:N.length)??0)+(((S=a==null?void 0:a.pullRequests)==null?void 0:S.length)??0),g=f.find(w=>w.id===m),y=(g==null?void 0:g.parentID)??m,T=f.filter(w=>w.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(QA,{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(s3,{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(Fc,{className:"h-3.5 w-3.5"}),"关联",b>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:b})]}),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($s,{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(ZD,{todos:e}):u==="prompts"?o.jsx(JD,{messages:t,onScrollToMessage:l}):u==="links"?o.jsx(tL,{links:a,sessionId:s}):o.jsx(sL,{})]})}const X1=8;function iL(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 i_({onSwipeLeft:e,onSwipeRight:t,threshold:a=40,disabled:s=!1}={}){const l=v.useRef({x0:0,y0:0,dir:null,on:!1}),u=v.useRef(0),d=v.useCallback(h=>{if(s||iL(h.target,h.currentTarget))return;const b=h.touches[0];l.current={x0:b.clientX,y0:b.clientY,dir:null,on:!0},u.current=0},[s]),f=v.useCallback(h=>{const b=l.current;if(!b.on)return;const g=h.touches[0].clientX-b.x0,y=h.touches[0].clientY-b.y0;if(!b.dir){(Math.abs(g)>X1||Math.abs(y)>X1)&&(b.dir=Math.abs(g)>Math.abs(y)?"h":"v");return}if(b.dir==="v"){b.on=!1;return}u.current=g},[]),m=v.useCallback(()=>{const h=l.current;if(!h.on||h.dir!=="h"){h.on=!1;return}h.on=!1;const b=u.current;b>a?t==null||t():b<-a&&(e==null||e())},[a,e,t]);return{onTouchStart:d,onTouchMove:f,onTouchEnd:m}}function Eh({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 yh(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 lL(e){const t=yh(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 W1(e){navigator.clipboard?navigator.clipboard.writeText(e).catch(()=>Z1(e)):Z1(e)}function Z1(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 oL(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 uL({session:e,isActive:t,isConfirming:a,onSelect:s,onDelete:l,onConfirm:u,onCancelConfirm:d,onRename:f,onToggleComplete:m,status:h,issue:b,linkedItems:g}){var ee,q;const y=cc(k=>k.drafts[e.id]),T=!!e.completedAt,N=lL(e),[S,w]=v.useState(!1),[C,A]=v.useState(""),O=v.useRef(null),U=()=>{var k;A(((k=e.title)==null?void 0:k.trim())||""),w(!0),requestAnimationFrame(()=>{var J;return(J=O.current)==null?void 0:J.focus()})},Q=()=>{var J;w(!1);const k=C.trim();k&&k!==(((J=e.title)==null?void 0:J.trim())||"")&&f(k)},[L,F]=v.useState(0),[Z,ne]=v.useState(!1),j=v.useRef({x0:0,y0:0,base:0,dir:null,on:!1}),K=k=>{const J=k.touches[0];j.current={x0:J.clientX,y0:J.clientY,base:L,dir:null,on:!0},ne(!1)},V=k=>{const J=j.current;if(!J.on)return;const Te=k.touches[0].clientX-J.x0,B=k.touches[0].clientY-J.y0;if(!J.dir){(Math.abs(Te)>5||Math.abs(B)>5)&&(J.dir=Math.abs(Te)>Math.abs(B)?"h":"v");return}J.dir!=="v"&&F(Math.max(-192,Math.min(0,J.base+Te)))},X=()=>{j.current.on=!1,ne(!0),F(k=>k<-192/2?-192:0)},te=()=>{ne(!0),F(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(),te()},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(),te()},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(),te()},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(pm,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{U(),te()},className:"flex w-12 items-center justify-center bg-amber-500 text-white active:bg-amber-600",children:o.jsx(dx,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{var k;W1(JSON.stringify({id:e.id,name:((k=e.title)==null?void 0:k.trim())||""},null,2)),te()},className:"flex w-12 items-center justify-center bg-blue-500 text-white active:bg-blue-600",children:o.jsx(gc,{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",Z&&"transition-transform duration-200 ease-out"),style:{...L!==0?{transform:`translateX(${L}px)`}:{},...L===-192?{pointerEvents:"none"}:{}},onTouchStart:K,onTouchMove:V,onTouchEnd:X,children:[o.jsxs("button",{type:"button",onClick:()=>{S||(s(),te())},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",oL(h))}),o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:((ee=e.agent)==null?void 0:ee.trim())||"默认"}),T&&o.jsx(pm,{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})]}),S?o.jsx("input",{ref:O,type:"text",value:C,onChange:k=>A(k.target.value),onBlur:Q,onKeyDown:k=>{k.key==="Enter"&&Q(),k.key==="Escape"&&w(!1)},onClick:k=>k.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:k=>{k.stopPropagation(),U()},children:[(b||g)&&o.jsxs("div",{className:"mb-0.5 flex flex-wrap gap-1",children:[b&&o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium leading-none",b.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",b.number]}),g==null?void 0:g.map(k=>o.jsx("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium leading-none",k.type==="pr"?k.state==="open"?"bg-blue-500/15 text-blue-400":k.mergedAt?"bg-purple-500/15 text-purple-400":"bg-red-500/15 text-red-400":k.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:k.type==="pr"?`PR#${k.number}`:`#${k.number}`},`${k.type}-${k.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(pm,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:U,title:"重命名",className:"rounded p-1 text-fg-5 hover:text-fg-2",children:o.jsx(dx,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:()=>{var k;W1(JSON.stringify({id:e.id,name:((k=e.title)==null?void 0:k.trim())||""},null,2))},title:"复制 Session JSON",className:"rounded p-1 text-fg-5 hover:text-fg-2",children:o.jsx(gc,{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 J1({onClose:e}){const[t,a]=v.useState(null),s=Ie(A=>A.sessions),l=Ie(A=>A.activeSessionId),u=Ie(A=>A.sessionStatuses),d=Ie(A=>A.sessionFilter),f=Ie(A=>A.setSessionFilter),m=Ie(A=>A.setActiveSession),h=Ie(A=>A.deleteSession),b=Ie(A=>A.renameSession),g=Ie(A=>A.toggleSessionComplete),y=He(A=>A.activeRepoId),T=Ge(A=>A.issues),N=Ie(A=>A.allSessionLinks),S=[...s].filter(A=>A.parentID?!1:d==="active"?!A.completedAt:d==="completed"?!!A.completedAt:!0).sort((A,O)=>yh(O)-yh(A)),w=new Map(T.map(A=>[A.id,A])),C=A=>o.jsx("ul",{className:"space-y-0.5",children:A.map(O=>{const U=O.issueId?w.get(O.issueId):void 0,Q=N[O.id],L=[];if(Q){for(const F of Q.issues)L.push({number:F.number,state:F.state,type:"issue"});for(const F of Q.pullRequests)L.push({number:F.number,state:F.state,type:"pr",mergedAt:F.mergedAt})}return o.jsx(uL,{session:O,isActive:O.id===l,isConfirming:t===O.id,status:u[O.id],issue:U?{number:U.number,title:U.title,state:U.state}:void 0,linkedItems:L.length>0?L:void 0,onSelect:()=>{m(O.id),e==null||e()},onDelete:()=>{h(O.id),a(null)},onConfirm:()=>a(O.id),onCancelConfirm:()=>a(null),onRename:F=>void b(O.id,F),onToggleComplete:()=>void g(O.id)},O.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(Wa,{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(([A,O])=>o.jsx("button",{type:"button",onClick:()=>f(A),className:oe("rounded-md px-2 py-0.5 font-mono text-[11px] transition-colors",d===A?"bg-elevated text-fg-2":"text-fg-5 hover:text-fg-3"),children:O},A))}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:y?S.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(S)}):o.jsx("p",{className:"px-2 py-6 text-center font-mono text-xs text-fg-5",children:"请先选择一个仓库"})})]})})}function cL(){const[e,t]=v.useState(()=>typeof window<"u"&&window.matchMedia("(min-width: 1280px)").matches);return v.useEffect(()=>{const a=window.matchMedia("(min-width: 1280px)"),s=l=>t(l.matches);return a.addEventListener("change",s),()=>a.removeEventListener("change",s)},[]),e}function eE(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 dL(){const[e,t]=v.useState(!1),[a,s]=v.useState(!1),[l,u]=v.useState(!1),d=cL(),f=Ie(w=>w.activeSessionId),m=Tc(w=>w.sessionPanelCollapsed),h=Tc(w=>w.toggleSessionPanel),b=Ie(w=>{const C=w.activeSessionId;return C?w.todos[C]??Sc:Sc}),g=Ie(w=>{const C=w.activeSessionId;return C?w.messages[C]??bo:bo}),y=Ie(w=>{const C=w.activeSessionId;return C?w.sessionLinks[C]:void 0});v.useEffect(()=>{d&&f?u(!0):d||u(!1)},[d,f]);const T=l&&!!f,N=()=>{window.matchMedia("(max-width: 767px)").matches?s(w=>!w):u(w=>!w)},S=i_({onSwipeRight:()=>t(!0),onSwipeLeft:()=>s(!0),disabled:e||a});return o.jsxs("div",{className:"flex min-h-0 flex-1",...S,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(J1,{})})}),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(Uh,{className:"h-3 w-3"}):o.jsx(Ph,{className:"h-3 w-3"})})]}),o.jsx(Eh,{side:"left",open:e,onClose:()=>t(!1),children:o.jsx(J1,{onClose:()=>t(!1)})}),o.jsx(Eh,{side:"right",open:a,onClose:()=>s(!1),children:o.jsx(Q1,{todos:b,messages:g,sessionLinks:y,sessionId:f,onScrollToMessage:w=>{s(!1),setTimeout(()=>eE(w),300)}})}),o.jsx("div",{className:"flex min-w-0 flex-1 flex-col",children:o.jsx(VD,{onToggleSidebar:()=>t(w=>!w),onToggleRightPanel:N,rightPanelOpen:T})}),T&&o.jsx("div",{className:"hidden shrink-0 md:flex",children:o.jsx(Q1,{todos:b,messages:g,sessionLinks:y,sessionId:f,onScrollToMessage:eE})})]})}const tE=/[#.]/g;function fL(e,t){const a=e||"",s={};let l=0,u,d;for(;l<a.length;){tE.lastIndex=l;const f=tE.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 l_(e,t,a){const s=a?gL(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=fL(u,t);const h=m.tagName.toLowerCase(),b=s?s.get(h):void 0;if(m.tagName=b||h,mL(d))f.unshift(d);else for(const[g,y]of Object.entries(d))hL(e,m.properties,g,y)}for(const h of f)Th(m.children,h);return m.type==="element"&&m.tagName==="template"&&(m.content={type:"root",children:m.children},m.children=[]),m}return l}function mL(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 hL(e,t,a,s){const l=Vc(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=jx(s):l.commaSeparated?u=Ox(s):l.commaOrSpaceSeparated?u=jx(Ox(s).join(" ")):u=nE(l,l.property,s):Array.isArray(s)?u=[...s]:u=l.property==="style"?pL(s):String(s);if(Array.isArray(u)){const d=[];for(const f of u)d.push(nE(l,l.property,f));u=d}l.property==="className"&&Array.isArray(t.className)&&(u=t.className.concat(u)),t[l.property]=u}}function Th(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)Th(e,a);else if(typeof t=="object"&&"type"in t)t.type==="root"?Th(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function nE(e,t,a){if(typeof a=="string"){if(e.number&&a&&!Number.isNaN(Number(a)))return Number(a);if((e.boolean||e.overloadedBoolean)&&(a===""||xo(a)===xo(t)))return!0}return a}function pL(e){const t=[];for(const[a,s]of Object.entries(e))t.push([a,s].join(": "));return t.join("; ")}function gL(e){const t=new Map;for(const a of e)t.set(a.toLowerCase(),a);return t}const bL=["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"],xL=l_(So,"div"),EL=l_(ds,"g",bL);function yL(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=aE(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=aE(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 aE(e,t){const a=e.indexOf("\r",t),s=e.indexOf(`
|
|
489
|
+
`);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 j1={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 a_({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=j1[l]??j1.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 iD={"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"},lD={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 oD({record:e}){const[t,a]=v.useState(!1),s=typeof e.category=="string"?e.category:null,l=typeof e.subagent_type=="string"?e.subagent_type:null,u=Va(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,b=s??l,g=(s&&iD[s])??(l&&lD[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:[b&&o.jsx("span",{className:oe("rounded px-1.5 py-0.5 text-[10px] font-medium",g),children:b}),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(Uh,{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 uD(e){const t=yw(e),a=Ie(m=>m.activeSessionId),s=Ie(m=>m.sessions);if(t)return t;if(!a)return null;const l=Kc(e),u=o0(l),d=Va(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 cD({part:e}){const t=uD(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(ZS,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{className:"shrink-0",children:"查看子会话"})]}):null}function dD(e,t){const a=o0(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(sD,{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(a_,{todos:l})}if(s==="bash"||s==="shell"){const l=Va(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(oD,{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 fD(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(a_,{todos:s})}return null}function mD({part:e}){const t=qh(e),a=t==="running"||t==="pending",[s,l]=v.useState(a),[u,d]=v.useState(!1),f=v.useRef(a);v.useEffect(()=>{f.current!==a&&(l(a),f.current=a)},[a]);const m=_y(e),h=m.toLowerCase(),b=h==="task"||h==="agent",g=Kc(e),{label:y,arg:T}=rD(m,g),N=dD(m,g),S=N?null:wx(g),w=zh(e),C=fD(m,w),A=C?"":wx(w),O=aD[t],U=A.length>zm,Q=u||!U?A:`${A.slice(0,zm)}…`;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",O.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",O.color),children:[o.jsx("span",{className:oe(O.spin&&"fs-spin"),children:O.glyph}),o.jsx("span",{children:O.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",O.accent),children:[N&&o.jsx("section",{className:"mb-2",children:N}),S&&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:S})]}),b&&o.jsx(cD,{part:e}),C&&o.jsx("section",{children:C}),A&&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:Q}),U&&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 ${A.length-zm} more chars`})]}),!N&&!S&&!C&&!A&&o.jsx("div",{className:"text-fg-5",children:"no parameters"})]})})]})}function hD({text:e}){const[t,a]=v.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(Ia,{className:"h-3 w-3 shrink-0"}):o.jsx(Uh,{className:"h-3 w-3 shrink-0"}),o.jsx(WE,{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 pD(){const[e,t]=v.useState(0);return v.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(WE,{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 r_({part:e,className:t}){var a;return e.url?(a=e.mime)!=null&&a.startsWith("image/")?o.jsx(IT,{url:e.url,label:e.filename??"attachment",className:oe("object-contain",t??"max-h-80")}):o.jsxs("div",{className:"flex items-center gap-1.5 font-mono text-xs text-fg-5",children:[o.jsx(x3,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{children:e.filename??e.mime??"attachment"})]}):null}function gD({part:e,isStreaming:t}){switch(_c(e)){case"text":{const s=Nc(e);return s.trim()?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[ZM],components:{table:s0},children:s})}):null}case"thinking":{const s=Nc(e);return s.trim()?o.jsx(hD,{text:s}):t?o.jsx(pD,{}):null}case"tool":return go(e)?o.jsx(tD,{part:e}):o.jsx(mD,{part:e});case"file":return o.jsx(r_,{part:e});default:return null}}function bD({message:e,isStreaming:t,queued:a}){var b,g,y,T,N,S;const s=e.role==="user",l=e.parts??[],u=l.filter(w=>_c(w)!=="other");if(s){const w=l.map(Nc).join("").trim(),C=l.filter(U=>_c(U)==="file"),A=(b=e.time)==null?void 0:b.created,O=A?new Date(A*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"}),O&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsx("span",{className:"text-fg-5",children:O})]}),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:w||"…"})]}),C.length>0&&o.jsx("div",{className:"mt-2 flex flex-wrap gap-2 pl-5",children:C.map((U,Q)=>o.jsx(r_,{part:U,className:"max-h-40"},U.id??Q))})]})}const d=((g=e.info)==null?void 0:g.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(An,{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"}),((S=m.data)==null?void 0:S.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((w,C)=>o.jsx(gD,{part:w,isStreaming:t},w.id??w.callID??C)):!m&&(t?o.jsx("span",{className:"text-fg-5",children:"…"}):o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-400/80",children:[o.jsx(An,{className:"h-3 w-3 shrink-0"}),o.jsx("span",{children:"空响应 — Agent 未产出任何内容"})]}))})]})}const xD={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 ED(e){const t=e.find(s=>Ui(s.status)==="in_progress");if(t)return t.content;const a=e.find(s=>Ui(s.status)==="pending");return a?a.content:"all steps complete"}function yD({todos:e,onClick:t}){if(e.length===0)return null;const a=e.length,s=bw(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=xD[Ui(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:ED(e)}),o.jsx("span",{className:"shrink-0 text-[10px] text-fg-5",children:"详情 →"})]})})}function TD({isListening:e,disabled:t,onClick:a,error:s}){return o.jsx("button",{type:"button",onClick:a,disabled:t,"aria-label":e?"停止语音输入":"语音输入",title:s??(e?"点击停止":"语音输入"),className:oe("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors duration-150 disabled:cursor-not-allowed disabled:text-fg-6/40",e?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"text-fg-5 hover:text-fg-3"),children:o.jsx(l3,{className:oe("h-4 w-4",e&&"animate-pulse")})})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var zi;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(zi||(zi={}));class qm extends Error{constructor(t,a,s){super(t),this.message=t,this.code=a,this.data=s}}const _D=e=>{var t,a;return e!=null&&e.androidBridge?"android":!((a=(t=e==null?void 0:e.webkit)===null||t===void 0?void 0:t.messageHandlers)===null||a===void 0)&&a.bridge?"ios":"web"},ND=e=>{const t=e.CapacitorCustomPlatform||null,a=e.Capacitor||{},s=a.Plugins=a.Plugins||{},l=()=>t!==null?t.name:_D(e),u=()=>l()!=="web",d=g=>{const y=h.get(g);return!!(y!=null&&y.platforms.has(l())||f(g))},f=g=>{var y;return(y=a.PluginHeaders)===null||y===void 0?void 0:y.find(T=>T.name===g)},m=g=>e.console.error(g),h=new Map,b=(g,y={})=>{const T=h.get(g);if(T)return console.warn(`Capacitor plugin "${g}" already registered. Cannot register plugins twice.`),T.proxy;const N=l(),S=f(g);let w;const C=async()=>(!w&&N in y?w=typeof y[N]=="function"?w=await y[N]():w=y[N]:t!==null&&!w&&"web"in y&&(w=typeof y.web=="function"?w=await y.web():w=y.web),w),A=(Z,ne)=>{var j,K;if(S){const V=S==null?void 0:S.methods.find(X=>ne===X.name);if(V)return V.rtype==="promise"?X=>a.nativePromise(g,ne.toString(),X):(X,te)=>a.nativeCallback(g,ne.toString(),X,te);if(Z)return(j=Z[ne])===null||j===void 0?void 0:j.bind(Z)}else{if(Z)return(K=Z[ne])===null||K===void 0?void 0:K.bind(Z);throw new qm(`"${g}" plugin is not implemented on ${N}`,zi.Unimplemented)}},O=Z=>{let ne;const j=(...K)=>{const V=C().then(X=>{const te=A(X,Z);if(te){const ee=te(...K);return ne=ee==null?void 0:ee.remove,ee}else throw new qm(`"${g}.${Z}()" is not implemented on ${N}`,zi.Unimplemented)});return Z==="addListener"&&(V.remove=async()=>ne()),V};return j.toString=()=>`${Z.toString()}() { [capacitor code] }`,Object.defineProperty(j,"name",{value:Z,writable:!1,configurable:!1}),j},U=O("addListener"),Q=O("removeListener"),L=(Z,ne)=>{const j=U({eventName:Z},ne),K=async()=>{const X=await j;Q({eventName:Z,callbackId:X},ne)},V=new Promise(X=>j.then(()=>X({remove:K})));return V.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await K()},V},F=new Proxy({},{get(Z,ne){switch(ne){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return S?L:U;case"removeListener":return Q;default:return O(ne)}}});return s[g]=F,h.set(g,{name:g,proxy:F,platforms:new Set([...Object.keys(y),...S?[N]:[]])}),F};return a.convertFileSrc||(a.convertFileSrc=g=>g),a.getPlatform=l,a.handleError=m,a.isNativePlatform=u,a.isPluginAvailable=d,a.registerPlugin=b,a.Exception=qm,a.DEBUG=!!a.DEBUG,a.isLoggingEnabled=!!a.isLoggingEnabled,a},vD=e=>e.Capacitor=ND(e),Ic=vD(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Ro=Ic.registerPlugin;class u0{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(t,a){let s=!1;this.listeners[t]||(this.listeners[t]=[],s=!0),this.listeners[t].push(a);const u=this.windowListeners[t];u&&!u.registered&&this.addWindowListener(u),s&&this.sendRetainedArgumentsForEvent(t);const d=async()=>this.removeListener(t,a);return Promise.resolve({remove:d})}async removeAllListeners(){this.listeners={};for(const t in this.windowListeners)this.removeWindowListener(this.windowListeners[t]);this.windowListeners={}}notifyListeners(t,a,s){const l=this.listeners[t];if(!l){if(s){let u=this.retainedEventArguments[t];u||(u=[]),u.push(a),this.retainedEventArguments[t]=u}return}l.forEach(u=>u(a))}hasListeners(t){var a;return!!(!((a=this.listeners[t])===null||a===void 0)&&a.length)}registerWindowListener(t,a){this.windowListeners[a]={registered:!1,windowEventName:t,pluginEventName:a,handler:s=>{this.notifyListeners(a,s)}}}unimplemented(t="not implemented"){return new Ic.Exception(t,zi.Unimplemented)}unavailable(t="not available"){return new Ic.Exception(t,zi.Unavailable)}async removeListener(t,a){const s=this.listeners[t];if(!s)return;const l=s.indexOf(a);this.listeners[t].splice(l,1),this.listeners[t].length||this.removeWindowListener(this.windowListeners[t])}addWindowListener(t){window.addEventListener(t.windowEventName,t.handler),t.registered=!0}removeWindowListener(t){t&&(window.removeEventListener(t.windowEventName,t.handler),t.registered=!1)}sendRetainedArgumentsForEvent(t){const a=this.retainedEventArguments[t];a&&(delete this.retainedEventArguments[t],a.forEach(s=>{this.notifyListeners(t,s)}))}}const B1=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),P1=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class SD extends u0{async getCookies(){const t=document.cookie,a={};return t.split(";").forEach(s=>{if(s.length<=0)return;let[l,u]=s.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");l=P1(l).trim(),u=P1(u).trim(),a[l]=u}),a}async setCookie(t){try{const a=B1(t.key),s=B1(t.value),l=t.expires?`; expires=${t.expires.replace("expires=","")}`:"",u=(t.path||"/").replace("path=",""),d=t.url!=null&&t.url.length>0?`domain=${t.url}`:"";document.cookie=`${a}=${s||""}${l}; path=${u}; ${d};`}catch(a){return Promise.reject(a)}}async deleteCookie(t){try{document.cookie=`${t.key}=; Max-Age=0`}catch(a){return Promise.reject(a)}}async clearCookies(){try{const t=document.cookie.split(";")||[];for(const a of t)document.cookie=a.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(t){return Promise.reject(t)}}async clearAllCookies(){try{await this.clearCookies()}catch(t){return Promise.reject(t)}}}Ro("CapacitorCookies",{web:()=>new SD});const AD=async e=>new Promise((t,a)=>{const s=new FileReader;s.onload=()=>{const l=s.result;t(l.indexOf(",")>=0?l.split(",")[1]:l)},s.onerror=l=>a(l),s.readAsDataURL(e)}),CD=(e={})=>{const t=Object.keys(e);return Object.keys(e).map(l=>l.toLocaleLowerCase()).reduce((l,u,d)=>(l[u]=e[t[d]],l),{})},wD=(e,t=!0)=>e?Object.entries(e).reduce((s,l)=>{const[u,d]=l;let f,m;return Array.isArray(d)?(m="",d.forEach(h=>{f=t?encodeURIComponent(h):h,m+=`${u}=${f}&`}),m.slice(0,-1)):(f=t?encodeURIComponent(d):d,m=`${u}=${f}`),`${s}&${m}`},"").substr(1):null,kD=(e,t={})=>{const a=Object.assign({method:e.method||"GET",headers:e.headers},t),l=CD(e.headers)["content-type"]||"";if(typeof e.data=="string")a.body=e.data;else if(l.includes("application/x-www-form-urlencoded")){const u=new URLSearchParams;for(const[d,f]of Object.entries(e.data||{}))u.set(d,f);a.body=u.toString()}else if(l.includes("multipart/form-data")||e.data instanceof FormData){const u=new FormData;if(e.data instanceof FormData)e.data.forEach((f,m)=>{u.append(m,f)});else for(const f of Object.keys(e.data))u.append(f,e.data[f]);a.body=u;const d=new Headers(a.headers);d.delete("content-type"),a.headers=d}else(l.includes("application/json")||typeof e.data=="object")&&(a.body=JSON.stringify(e.data));return a};class RD extends u0{async request(t){const a=kD(t,t.webFetchExtra),s=wD(t.params,t.shouldEncodeUrlParams),l=s?`${t.url}?${s}`:t.url,u=await fetch(l,a),d=u.headers.get("content-type")||"";let{responseType:f="text"}=u.ok?t:{};d.includes("application/json")&&(f="json");let m,h;switch(f){case"arraybuffer":case"blob":h=await u.blob(),m=await AD(h);break;case"json":m=await u.json();break;case"document":case"text":default:m=await u.text()}const b={};return u.headers.forEach((g,y)=>{b[y]=g}),{data:m,headers:b,status:u.status,url:u.url}}async get(t){return this.request(Object.assign(Object.assign({},t),{method:"GET"}))}async post(t){return this.request(Object.assign(Object.assign({},t),{method:"POST"}))}async put(t){return this.request(Object.assign(Object.assign({},t),{method:"PUT"}))}async patch(t){return this.request(Object.assign(Object.assign({},t),{method:"PATCH"}))}async delete(t){return this.request(Object.assign(Object.assign({},t),{method:"DELETE"}))}}Ro("CapacitorHttp",{web:()=>new RD});var U1;(function(e){e.Dark="DARK",e.Light="LIGHT",e.Default="DEFAULT"})(U1||(U1={}));var H1;(function(e){e.StatusBar="StatusBar",e.NavigationBar="NavigationBar"})(H1||(H1={}));class OD extends u0{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}}Ro("SystemBars",{web:()=>new OD});const ID="modulepreload",MD=function(e){return"/"+e},F1={},DD=function(t,a,s){let l=Promise.resolve();if(a&&a.length>0){let d=function(h){return Promise.all(h.map(b=>Promise.resolve(b).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const f=document.querySelector("meta[property=csp-nonce]"),m=(f==null?void 0:f.nonce)||(f==null?void 0:f.getAttribute("nonce"));l=d(a.map(h=>{if(h=MD(h),h in F1)return;F1[h]=!0;const b=h.endsWith(".css"),g=b?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${g}`))return;const y=document.createElement("link");if(y.rel=b?"stylesheet":ID,b||(y.as="script"),y.crossOrigin="",y.href=h,m&&y.setAttribute("nonce",m),document.head.appendChild(y),b)return new Promise((T,N)=>{y.addEventListener("load",T),y.addEventListener("error",()=>N(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(d){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=d,window.dispatchEvent(f),!f.defaultPrevented)throw d}return l.then(d=>{for(const f of d||[])f.status==="rejected"&&u(f.reason);return t().catch(u)})},Mi=Ro("SpeechRecognition",{web:()=>DD(()=>import("./web-DlYWWn_M.js"),[]).then(e=>new e.SpeechRecognitionWeb)});function LD(e,t){const a=e.length,s=new ArrayBuffer(44+a*2),l=new DataView(s),u=(d,f)=>{for(let m=0;m<f.length;m++)l.setUint8(d+m,f.charCodeAt(m))};u(0,"RIFF"),l.setUint32(4,36+a*2,!0),u(8,"WAVE"),u(12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,1,!0),l.setUint16(22,1,!0),l.setUint32(24,t,!0),l.setUint32(28,t*2,!0),l.setUint16(32,2,!0),l.setUint16(34,16,!0),u(36,"data"),l.setUint32(40,a*2,!0);for(let d=0;d<a;d++){const f=Math.max(-1,Math.min(1,e[d]));l.setInt16(44+d*2,f<0?f*32768:f*32767,!0)}return new Blob([s],{type:"audio/wav"})}const xh=Ic.isNativePlatform(),$m=!xh&&typeof window<"u"?window.SpeechRecognition??window.webkitSpeechRecognition:void 0,Ym=16e3;function jD(e="zh-CN"){const[t,a]=v.useState(!1),[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState(null),[h,b]=v.useState(0),g=v.useRef(null),y=v.useRef(!1),T=v.useRef([]),N=v.useRef(!1),S=v.useRef(null),w=v.useRef(null),C=v.useRef(null),A=v.useRef(null),O=v.useRef([]),U=!0,Q=v.useCallback(async()=>{var J,Te,B;(J=A.current)==null||J.disconnect(),(Te=C.current)==null||Te.getTracks().forEach(I=>I.stop()),await((B=w.current)==null?void 0:B.close().catch(()=>{}));const V=O.current;if(O.current=[],A.current=null,C.current=null,w.current=null,V.length===0){a(!1);return}d("识别中…");const X=V.reduce((I,re)=>I+re.length,0),te=new Float32Array(X);let ee=0;for(const I of V)te.set(I,ee),ee+=I.length;const q=LD(te,Ym),k=new FormData;k.append("audio",q,"recording.wav");try{const I=await fetch("/api/transcribe",{method:"POST",body:k});if(I.ok){const{text:re}=await I.json();re&&l(re)}else{const re=await I.json().catch(()=>({error:`HTTP ${I.status}`}));m(re.error??`HTTP ${I.status}`)}}catch(I){m(`语音识别失败:${I instanceof Error?I.message:String(I)}`)}finally{d(""),a(!1)}},[]),L=v.useCallback(async()=>{if(y.current=!0,S.current&&(clearTimeout(S.current),S.current=null),xh){await Mi.stop().catch(()=>{});for(const V of T.current)await V.remove().catch(()=>{});T.current=[],a(!1),d("")}else g.current?g.current.stop():w.current?await Q():a(!1)},[Q]),F=v.useCallback(async()=>{var ee;l(""),d(""),m(null);const{available:V}=await Mi.available();if(!V){m("当前设备不支持语音识别");return}if((await Mi.requestPermissions()).speechRecognition!=="granted"){m("请允许语音识别权限");return}const te=[];te.push(await Mi.addListener("partialResults",q=>{d(q.matches[0]??"")})),te.push(await Mi.addListener("listeningState",q=>{const k=q.status==="started";a(k),k||d("")})),T.current=te;try{const q=await Mi.start({language:e,partialResults:!0,maxResults:1});(ee=q.matches)!=null&&ee.length&&l(k=>k+q.matches.join(""))}catch(q){m(`语音识别错误:${q instanceof Error?q.message:String(q)}`);for(const k of te)await k.remove().catch(()=>{});T.current=[]}},[e]),Z=v.useCallback(()=>{if(!$m)return!1;l(""),d(""),m(null),y.current=!1;const V=new $m;V.lang=e,V.continuous=!0,V.interimResults=!0,V.maxAlternatives=1,V.onstart=()=>{a(!0),N.current=!1,S.current=setTimeout(()=>{!N.current&&!y.current&&m("未检测到语音,请检查麦克风或网络连接(Chrome 需访问 Google 服务器)")},5e3)},V.onresult=X=>{N.current=!0,S.current&&(clearTimeout(S.current),S.current=null);let te="",ee="";for(let q=X.resultIndex;q<X.results.length;q++){const k=X.results[q][0].transcript;X.results[q].isFinal?te+=k:ee+=k}te&&l(q=>q+te),d(ee)},V.onerror=X=>{switch(X.error!=="no-speech"&&X.error!=="aborted"&&(y.current=!0),X.error){case"not-allowed":m("请允许麦克风权限");break;case"network":m("网络错误,请检查连接");break;case"no-speech":case"aborted":return;default:m(`语音识别错误:${X.error}`)}},V.onend=()=>{if(d(""),!y.current)try{V.start();return}catch{}a(!1),g.current=null},g.current=V;try{return V.start(),!0}catch{return!1}},[e]),ne=v.useCallback(async()=>{l(""),d(""),m(null);try{const q=await fetch("/api/transcribe/status"),{available:k}=await q.json();if(!k){m("语音识别服务未就绪,请稍后重试");return}}catch{m("无法连接语音识别服务");return}let V;try{V=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:Ym,channelCount:1}})}catch{m("请允许麦克风权限");return}const X=new AudioContext({sampleRate:Ym}),te=X.createMediaStreamSource(V),ee=X.createScriptProcessor(4096,1,1);O.current=[],ee.onaudioprocess=q=>{O.current.push(new Float32Array(q.inputBuffer.getChannelData(0)))},te.connect(ee),ee.connect(X.destination),w.current=X,C.current=V,A.current=ee,a(!0)},[]),j=v.useCallback(()=>{xh?F():$m&&Z()||ne()},[F,Z,ne]);v.useEffect(()=>{if(!t){b(0);return}let V=!1,X=null,te=null,ee=0;return(async()=>{try{if(X=await navigator.mediaDevices.getUserMedia({audio:!0}),V){X.getTracks().forEach(I=>I.stop());return}te=new AudioContext;const q=te.createMediaStreamSource(X),k=te.createAnalyser();k.fftSize=256,q.connect(k);const J=new Uint8Array(k.frequencyBinCount);let Te=0;const B=()=>{if(V)return;k.getByteFrequencyData(J);const I=performance.now();if(I-Te>80){let re=0;for(let D=0;D<J.length;D++)re+=J[D];b(re/(J.length*255)),Te=I}ee=requestAnimationFrame(B)};ee=requestAnimationFrame(B)}catch{}})(),()=>{V=!0,cancelAnimationFrame(ee),X==null||X.getTracks().forEach(q=>q.stop()),te==null||te.close().catch(()=>{}),b(0)}},[t]),v.useEffect(()=>()=>{var V,X,te,ee;y.current=!0,(V=g.current)==null||V.stop(),(X=A.current)==null||X.disconnect(),(te=C.current)==null||te.getTracks().forEach(q=>q.stop()),(ee=w.current)==null||ee.close().catch(()=>{});for(const q of T.current)q.remove().catch(()=>{})},[]);const K=v.useCallback(()=>{l(""),d("")},[]);return{isSupported:U,isListening:t,transcript:s,interimTranscript:u,error:f,volumeLevel:h,start:j,stop:L,resetTranscript:K}}const BD=200;function PD(){return Ie(e=>{const t=e.activeSessionId;if(!t)return!1;const a=e.messages[t]??bo;for(let s=a.length-1;s>=0;s--){const l=a[s].parts;if(l){for(const u of l)if(_c(u)==="tool"&&vc(u))return!0}}return!1})}function UD(){var q;const[e,t]=v.useState(""),[a,s]=v.useState(""),[l,u]=v.useState([]),d=v.useRef(null),f=jD(),m=v.useRef(""),h=Ie(k=>k.activeSessionId),b=He(k=>k.activeRepoId),g=Ie(k=>{const J=k.activeSessionId;return J?k.sessionStatuses[J]:void 0}),y=Ie(k=>k.sendMessage),T=cc(k=>k.setDraft),N=cc(k=>k.clearDraft),S=PD();v.useEffect(()=>{if(!b){u([]);return}let k=!1;return(async()=>{try{const[J,Te]=await Promise.all([Gc(),Yc(b)]);if(k)return;const B=J.pinned_models,I=B?JSON.parse(B):[];u(I.length>0?Te.filter(re=>I.includes(re.id)):[])}catch{k||u([])}})(),()=>{k=!0}},[b]);const w=g==="busy"&&!S,C=!h;v.useLayoutEffect(()=>{const k=d.current;k&&(k.style.height="auto",k.style.height=`${Math.min(k.scrollHeight,BD)}px`)},[e]);const A=((q=l.find(k=>k.id===a))==null?void 0:q.supportsImage)!==!1,{attachments:O,promptFiles:U,error:Q,addFiles:L,onPaste:F,remove:Z,clear:ne}=MT(A);v.useEffect(()=>{t(h?cc.getState().drafts[h]??"":""),ne(),f.stop()},[h,ne,f.stop]);const j=async()=>{const k=e.trim();if(C||!k&&O.length===0)return;await y(k,a||void 0,U.length>0?U:void 0)&&(t(""),ne(),h&&N(h))},K=k=>{k.nativeEvent.isComposing||k.keyCode===229||k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),j())},V=()=>{f.isListening?f.stop():(m.current=e,f.start())};v.useEffect(()=>{f.isListening&&t(m.current+f.transcript+f.interimTranscript)},[f.isListening,f.transcript,f.interimTranscript]);const X=v.useRef(!1);v.useEffect(()=>{if(X.current&&!f.isListening&&f.transcript){const k=m.current+f.transcript;t(k),h&&T(h,k)}X.current=f.isListening},[f.isListening,f.transcript,h,T]);const te=h?S?"输入回复,或点击上方选项…":w?"输入消息将排队等待处理…":"enter a command…":"select or start a run",ee=h?f.isListening?"text-red-400 fs-blink":w?"text-amber-400 fs-blink":S?"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.jsx(LT,{attachments:O,error:Q,onRemove:Z,className:"mx-auto max-w-4xl"}),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",C?"border-line":f.isListening?"border-red-500/60":"border-fg-5 focus-within:border-fg-4"),children:[o.jsx("span",{className:oe("select-none pt-px font-mono text-sm leading-6",ee),children:"❯"}),o.jsx("textarea",{ref:d,rows:2,value:e,disabled:C,onChange:k=>{const J=k.target.value;t(J),h&&T(h,J)},onKeyDown:K,onPaste:F,placeholder:te,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(DT,{onFiles:k=>void L(k),disabled:C,allowed:A}),o.jsx(TD,{isListening:f.isListening,disabled:C,onClick:V,error:f.error}),o.jsx("button",{type:"button",onClick:j,disabled:C||e.trim().length===0&&O.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(XE,{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:[f.isListening&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"font-mono text-[10px] text-red-400",children:"● 录音中"}),o.jsx("div",{className:"h-1 w-16 overflow-hidden rounded-full bg-fg-6/30",children:o.jsx("div",{className:"h-full rounded-full bg-red-400 transition-[width] duration-75",style:{width:`${Math.round(f.volumeLevel*100)}%`}})})]}),f.error&&o.jsx("span",{className:"font-mono text-[10px] text-red-400",children:f.error}),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:k=>s(k.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(k=>o.jsx("option",{value:k.id,children:k.name||k.id},k.id))]})]})]})}const z1={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 q1({status:e,reason:t}){const a=z1[e??"idle"]??z1.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 HD={"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},$1=1e6;function FD(e){if(!e)return $1;for(const[t,a]of Object.entries(HD))if(e.startsWith(t))return a;return $1}function Y1(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function zD(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>0?`$${e.toFixed(4)}`:"$0"}function qD(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 G1({session:e,messages:t}){var m,h,b;const a=qD(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=FD((b=e==null?void 0:e.model)==null?void 0:b.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:Y1(l)}),o.jsx("span",{className:"text-fg-6",children:"·"}),o.jsxs("span",{className:f,title:`上下文占比 (${Y1(u)} 窗口)`,children:[d,"%"]}),o.jsx("span",{className:"text-fg-6",children:"·"})]}),o.jsx("span",{title:"会话累计费用",children:zD(s)})]})}const $D=144,YD=64;function s_({onToggleSidebar:e}){const[t,a]=v.useState(""),[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState(""),[h,b]=v.useState(!1),g=v.useRef(null),y=v.useRef(null),[T,N]=v.useState([]),S=Ie(I=>I.createSession),w=Ie(I=>I.sendError),C=He(I=>I.activeRepoId),A=Bi(I=>I.agents),O=Ge(I=>I.issues),U=Ge(I=>I.selectedIssueId),Q=Ge(I=>I.pendingDraft);v.useEffect(()=>{if(!C){N([]);return}let I=!1;return Yc(C).then(re=>{I||N(re)}).catch(()=>{I||N([])}),()=>{I=!0}},[C]);const L=T.length===0||T.some(I=>I.supportsImage!==!1),{attachments:F,promptFiles:Z,error:ne,addFiles:j,onPaste:K,remove:V,clear:X}=MT(L);v.useEffect(()=>{U&&(d(U),Ge.getState().setSelectedIssue(null))},[U]),v.useEffect(()=>{Q&&(a(Q),Ge.getState().setPendingDraft(null))},[Q]),v.useLayoutEffect(()=>{const I=g.current;I&&(I.style.height="auto",I.style.height=`${Math.min(I.scrollHeight,$D)}px`)},[t]),v.useEffect(()=>{const I=re=>{y.current&&!y.current.contains(re.target)&&b(!1)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[]);const te=O.filter(I=>I.state==="open"),ee=O.find(I=>I.id===u),q=f.trim().toLowerCase(),k=q?te.filter(I=>`#${I.number} ${I.title}`.toLowerCase().includes(q)):te,J=!!s||!!u,Te=()=>{const I=t.trim();!C||!I&&!J&&F.length===0||(a(""),X(),S(I,void 0,void 0,void 0,u||void 0,s||void 0,Z.length>0?Z:void 0))},B=I=>{I.nativeEvent.isComposing||I.keyCode===229||I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),Te())};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(zc,{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.jsx(LT,{attachments:F,error:ne,onRemove:V}),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:g,rows:1,value:t,autoFocus:!0,disabled:!C,onChange:I=>a(I.target.value),onKeyDown:B,onPaste:K,placeholder:C?"让 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(DT,{onFiles:I=>void j(I),disabled:!C,allowed:!0}),o.jsx("button",{type:"button",onClick:Te,disabled:!C||!t.trim()&&!J&&F.length===0,"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(XE,{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:I=>l(I.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:"默认"}),A.map(I=>o.jsx("option",{value:I.id,children:I.name},I.id))]})]}),O.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:()=>{b(I=>!I),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:ee?`#${ee.number} ${ee.title}`:"无"}),o.jsx(Ia,{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:I=>m(I.target.value),onKeyDown:I=>{I.key==="Escape"&&b(!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:[!q&&o.jsx("li",{children:o.jsx("button",{type:"button",onClick:()=>{d(""),b(!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:"无"})}),k.map(I=>o.jsx("li",{children:o.jsxs("button",{type:"button",onClick:()=>{d(I.id),m(""),b(!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",I.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",I.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",I.number]}),o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:I.title})]})},I.id)),k.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+⏎ 开始运行"}),w&&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:w})]})]})}function K1({body:e}){return e?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],components:{table:s0},children:e})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"没有描述内容"})}function V1({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 GD({onToggleSidebar:e}){const t=Ge(b=>b.matchingParentId),a=Ge(b=>b.matchingCandidateId),s=Ge(b=>b.issues.find(g=>g.id===t)),l=Ge(b=>b.issues.find(g=>g.id===a)),u=Ge(b=>b.exitMatchMode),d=Ge(b=>b.linkChild),[f,m]=v.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(zc,{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(V1,{issue:s})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:o.jsx(K1,{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(V1,{issue:l})}),o.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-6",children:o.jsx(K1,{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 KD({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(s_,{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(zc,{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(bc,{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($s,{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(qc,{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:s0},children:a.body})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"该 Issue 没有描述内容"})})})]})}function VD({onToggleSidebar:e,onToggleRightPanel:t,rightPanelOpen:a}){var ee,q;const s=Aa(),l=He(ja),u=Ie(k=>k.activeSessionId),d=Ge(k=>k.previewIssueId),f=Ie(k=>k.sessions.find(J=>J.id===k.activeSessionId)??null),m=Ie(k=>{const J=k.activeSessionId;return J?k.messages[J]??bo:bo}),h=Ie(k=>{const J=k.activeSessionId;return J?k.todos[J]??Sc:Sc}),b=Ie(k=>{const J=k.activeSessionId;return J?k.sessionStatuses[J]:void 0}),g=Ie(k=>{const J=k.activeSessionId;return J?k.queuedMessageIds[J]??kx:kx}),y=Ie(k=>{const J=k.activeSessionId;return J?k.errorReasons[J]:void 0}),T=Ie(k=>k.sendError),N=Ie(k=>k.abortSession),S=Ie(k=>k.revertToMessage),w=He(k=>k.repos.find(J=>J.id===k.activeRepoId)),C=(w==null?void 0:w.runtimeType)!=="claude-code",[A,O]=v.useState(null),[U,Q]=v.useState(!1),L=Ge(k=>f!=null&&f.issueId?k.issues.find(J=>J.id===f.issueId):void 0);v.useEffect(()=>{if(u)return kc.activateSession(u),()=>kc.deactivateSession(u)},[u]);const F=v.useRef(null),Z=v.useRef(!0),[ne,j]=v.useState(!1);v.useEffect(()=>{const k=F.current;k&&Z.current&&(k.scrollTop=k.scrollHeight)},[m,h]),v.useEffect(()=>{Z.current=!0,j(!1)},[u]),v.useEffect(()=>{if(b!=="busy"&&b!=="retry")return;const k=J=>{if(J.key!=="Escape"||J.defaultPrevented)return;const Te=J.target;Te instanceof HTMLInputElement||Te instanceof HTMLTextAreaElement||Te!=null&&Te.isContentEditable||N()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[b,N]);const K=Ge(k=>k.matchingParentId);if(!u)return K?o.jsx(GD,{onToggleSidebar:e}):d?o.jsx(KD,{onToggleSidebar:e}):o.jsx(s_,{onToggleSidebar:e});const V=b==="busy",X=b==="retry",te=V||X;return o.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden bg-term",children:[o.jsxs("header",{className:"border-b border-line bg-base md:hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",onClick:()=>Q(k=>!k),children:[o.jsxs("div",{className:"flex items-center gap-1",onClick:k=>k.stopPropagation(),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(zc,{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(Wa,{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:k=>{k.stopPropagation(),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(cx,{className:"h-3 w-3"}),"返回父会话"]}),o.jsx("h2",{className:"text-sm font-medium leading-snug text-fg",children:((ee=f==null?void 0:f.title)==null?void 0:ee.trim())||"untitled run"})]}),te&&o.jsx("span",{className:oe("h-2 w-2 shrink-0 rounded-full","bg-amber-400 animate-pulse")}),!te&&b==="error"&&o.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-red-400"}),o.jsx(Ia,{className:oe("h-4 w-4 shrink-0 text-fg-5 transition-transform duration-200",U&&"rotate-180")})]}),o.jsx("div",{className:oe("grid transition-[grid-template-rows] duration-200 ease-in-out",U?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:o.jsx("div",{className:"overflow-hidden",children:o.jsxs("div",{className:"flex flex-col gap-2.5 border-t border-line/60 px-4 py-3",children:[(f==null?void 0:f.agent)&&o.jsxs("div",{className:"flex items-center gap-2 font-mono text-xs text-fg-4",children:[o.jsx("span",{className:"w-14 shrink-0 text-fg-5",children:"Agent"}),o.jsx("span",{className:"truncate",children:f.agent})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-14 shrink-0 font-mono text-xs text-fg-5",children:"Status"}),o.jsx(q1,{status:b,reason:y})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-14 shrink-0 font-mono text-xs text-fg-5",children:"Context"}),o.jsx(G1,{session:f,messages:m})]}),L&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"w-14 shrink-0 font-mono text-xs text-fg-5",children:"Issue"}),o.jsxs("button",{type:"button",onClick:()=>s(`/${encodeURIComponent(l)}/issues?issueId=${L.id}`),className:"flex items-center gap-1.5 truncate font-mono text-xs text-fg-3 transition-colors hover:text-blue-400",children:[o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 text-[10px] font-semibold",L.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",L.number]}),o.jsx("span",{className:"truncate",children:L.title})]})]}),te&&o.jsxs("button",{type:"button",onClick:()=>void N(),className:"mt-0.5 flex w-full items-center justify-center gap-1.5 rounded-md border border-line px-2.5 py-1.5 font-mono text-xs text-fg-2 transition-colors hover:border-red-500/50 hover:text-red-400",children:[o.jsx(eh,{className:"h-3 w-3 fill-current"}),X?"stop retry":"stop"]})]})})})]}),o.jsxs("header",{className:"hidden items-center gap-3 border-b border-line bg-base px-4 py-2.5 md:flex",children:[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(cx,{className:"h-3 w-3"}),"返回父会话"]}),o.jsx("h2",{className:"truncate text-sm font-medium text-fg",children:((q=f==null?void 0:f.title)==null?void 0:q.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(G1,{session:f,messages:m})]}),L&&o.jsxs("button",{type:"button",onClick:()=>s(`/${encodeURIComponent(l)}/issues?issueId=${L.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",L.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",L.number]}),o.jsx("span",{className:"hidden max-w-[120px] truncate sm:inline",children:L.title})]}),o.jsx(q1,{status:b,reason:y}),t&&o.jsx("button",{type:"button",onClick:t,"aria-label":a?"关闭侧边栏":"打开侧边栏",className:oe("flex items-center justify-center rounded-md border border-line p-1.5 transition-colors",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(ty,{className:"h-4 w-4"})}),te&&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(eh,{className:"h-3 w-3 fill-current"}),X?"stop retry":"stop"]})]}),o.jsxs("div",{className:"relative min-h-0 flex-1",children:[o.jsx("div",{ref:F,onScroll:()=>{const k=F.current;if(!k)return;const J=k.scrollHeight-k.clientHeight-k.scrollTop<=YD;Z.current=J,j(!J)},className:"h-full 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((k,J)=>o.jsxs(v.Fragment,{children:[J>0&&k.role==="user"&&o.jsx("div",{className:"group/revert relative border-t border-line py-2",children:C&&!te&&o.jsxs("button",{type:"button",disabled:A!==null,onClick:async()=>{const Te=m.length-J;window.confirm(`回退到此处?将移除后续 ${Te} 条对话记录(不影响已产生的代码改动)。`)&&(O(k.id),await S(u,k.id),O(null))},className:"absolute left-1/2 top-1/2 z-10 flex -translate-x-1/2 -translate-y-1/2 items-center gap-1 rounded-full border border-line bg-base px-2.5 py-1 font-mono text-[11px] text-fg-4 opacity-60 shadow-sm transition-all duration-150 hover:border-amber-500/50 hover:text-amber-400 md:opacity-30 md:group-hover/revert:opacity-100 disabled:opacity-50",children:[A===k.id?o.jsx("span",{className:"inline-block h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}):o.jsx(S3,{className:"h-3 w-3"}),"回退到此处"]})}),o.jsx("div",{"data-message-id":k.id,children:o.jsx(bD,{message:k,isStreaming:V&&J===m.length-1,queued:g.includes(k.id)})})]},k.id)),h.length>0&&o.jsx(yD,{todos:[...h],onClick:t})]})}),o.jsx("button",{type:"button",onClick:()=>{const k=F.current;k&&(k.scrollTo({top:k.scrollHeight,behavior:"smooth"}),Z.current=!0)},"aria-label":"滚动到底部",className:oe("absolute bottom-4 right-4 z-10 flex h-9 w-9 items-center justify-center rounded-full border border-line bg-surface/90 text-fg-4 shadow-lg backdrop-blur transition-all duration-200","hover:bg-elevated hover:text-fg-2",ne?"translate-y-0 opacity-100":"pointer-events-none translate-y-2 opacity-0"),children:o.jsx(Ia,{className:"h-4 w-4"})})]}),b==="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(An,{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(An,{className:"h-3.5 w-3.5 shrink-0"}),o.jsx("span",{className:"truncate",children:T})]}),o.jsx(UD,{})]})}const Vn=Za((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=He.getState().activeRepoId;if(!l)return!1;try{return await BC(l,a,s),!0}catch{return!1}},unlinkIssue:async(a,s)=>{const l=He.getState().activeRepoId;if(!l)return!1;try{return await PC(l,a,s),!0}catch{return!1}},loadPulls:async()=>{const a=He.getState().activeRepoId;if(!a){e({pulls:[],loaded:!0});return}try{const s=await Nx(a,"all");e({pulls:s,loaded:!0})}catch{e({loaded:!0})}},syncPulls:async()=>{const a=He.getState().activeRepoId;if(a){e({syncing:!0});try{await LC(a);const s=await Nx(a,"all");e({pulls:s,syncing:!1})}catch(s){e({syncing:!1});let l="同步 PR 失败";if(s instanceof Xa)try{const u=JSON.parse(s.message);u.error&&(l=u.error)}catch{s.message&&(l=s.message)}Ft.getState().addToast(l,"error")}}}})),QD={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 XD(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 WD(e){if(!e.parts)return"";for(const t of e.parts){const a=t.content??t.text;if(a)return a}return""}function ZD({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=Ui(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=Ui(a.status),l=QD[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 JD({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=WD(s),d=XD(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 eL({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(Fc,{className:"ml-auto h-3 w-3 shrink-0 text-emerald-400"})]})})})}function tL({links:e,sessionId:t}){var L,F,Z,ne;const a=Aa(),s=He(ja),[l,u]=v.useState(null),[d,f]=v.useState(""),m=v.useRef(null),h=Ge(j=>j.issues),b=Vn(j=>j.pulls),g=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(((F=e==null?void 0:e.pullRequests)==null?void 0:F.map(j=>j.id))??[]);v.useEffect(()=>{var j;l&&((j=m.current)==null||j.focus())},[l]);const S=()=>{u(null),f("")},w=async(j,K,V)=>{t&&(V?await y(t,j,K):await g(t,j,K))},C=d.trim().toLowerCase(),A=C?h.filter(j=>`#${j.number} ${j.title}`.toLowerCase().includes(C)):h,O=C?b.filter(j=>`#${j.number} ${j.title} ${j.headBranch}`.toLowerCase().includes(C)):b,U=((Z=e==null?void 0:e.issues)==null?void 0:Z.length)??0,Q=((ne=e==null?void 0:e.pullRequests)==null?void 0:ne.length)??0;if(l){const j=l==="issue",K=j?A:O,V=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:S,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:X=>f(X.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:K.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:(j?h:b).length===0?j?"暂无 Issue,请先同步":"暂无 PR,请先同步":"无匹配结果"}):o.jsx("ul",{className:"space-y-0.5",children:K.map(X=>o.jsx(eL,{linked:V.has(X.id),number:X.number,title:X.title,state:X.state,mergedAt:j?void 0:X.mergedAt,isPr:!j,onToggle:()=>w(l,X.id,V.has(X.id))},X.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:U+Q>0?`${U+Q} 项关联`:"暂无关联"}),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(Wa,{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(Wa,{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:[U>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 (",U,")"]}),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 w("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))})]}),Q>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 (",Q,")"]}),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 w("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))})]}),U===0&&Q===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 nL={"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 aL(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 Gm(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 rL(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 sL(){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)=>(Gm(h)??0)-(Gm(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,b=a[m.id],g=Gm(m),y=(m.agent&&nL[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",aL(b))}),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}),g!=null&&o.jsx("span",{className:"ml-auto shrink-0 font-mono text-[10px] tabular-nums text-fg-6",children:rL(g)})]}),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 Q1({todos:e,messages:t,sessionLinks:a,sessionId:s,onScrollToMessage:l}){var N,S;const[u,d]=v.useState("todo"),f=Ie(w=>w.sessions),m=Ie(w=>w.activeSessionId),h=t.filter(w=>w.role==="user").length,b=(((N=a==null?void 0:a.issues)==null?void 0:N.length)??0)+(((S=a==null?void 0:a.pullRequests)==null?void 0:S.length)??0),g=f.find(w=>w.id===m),y=(g==null?void 0:g.parentID)??m,T=f.filter(w=>w.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(QA,{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(s3,{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(Fc,{className:"h-3.5 w-3.5"}),"关联",b>0&&o.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-5",children:b})]}),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($s,{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(ZD,{todos:e}):u==="prompts"?o.jsx(JD,{messages:t,onScrollToMessage:l}):u==="links"?o.jsx(tL,{links:a,sessionId:s}):o.jsx(sL,{})]})}const X1=8;function iL(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 i_({onSwipeLeft:e,onSwipeRight:t,threshold:a=40,disabled:s=!1}={}){const l=v.useRef({x0:0,y0:0,dir:null,on:!1}),u=v.useRef(0),d=v.useCallback(h=>{if(s||iL(h.target,h.currentTarget))return;const b=h.touches[0];l.current={x0:b.clientX,y0:b.clientY,dir:null,on:!0},u.current=0},[s]),f=v.useCallback(h=>{const b=l.current;if(!b.on)return;const g=h.touches[0].clientX-b.x0,y=h.touches[0].clientY-b.y0;if(!b.dir){(Math.abs(g)>X1||Math.abs(y)>X1)&&(b.dir=Math.abs(g)>Math.abs(y)?"h":"v");return}if(b.dir==="v"){b.on=!1;return}u.current=g},[]),m=v.useCallback(()=>{const h=l.current;if(!h.on||h.dir!=="h"){h.on=!1;return}h.on=!1;const b=u.current;b>a?t==null||t():b<-a&&(e==null||e())},[a,e,t]);return{onTouchStart:d,onTouchMove:f,onTouchEnd:m}}function Eh({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 yh(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 lL(e){const t=yh(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 W1(e){navigator.clipboard?navigator.clipboard.writeText(e).catch(()=>Z1(e)):Z1(e)}function Z1(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 oL(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 uL({session:e,isActive:t,isConfirming:a,onSelect:s,onDelete:l,onConfirm:u,onCancelConfirm:d,onRename:f,onToggleComplete:m,status:h,issue:b,linkedItems:g}){var ee,q;const y=cc(k=>k.drafts[e.id]),T=!!e.completedAt,N=lL(e),[S,w]=v.useState(!1),[C,A]=v.useState(""),O=v.useRef(null),U=()=>{var k;A(((k=e.title)==null?void 0:k.trim())||""),w(!0),requestAnimationFrame(()=>{var J;return(J=O.current)==null?void 0:J.focus()})},Q=()=>{var J;w(!1);const k=C.trim();k&&k!==(((J=e.title)==null?void 0:J.trim())||"")&&f(k)},[L,F]=v.useState(0),[Z,ne]=v.useState(!1),j=v.useRef({x0:0,y0:0,base:0,dir:null,on:!1}),K=k=>{const J=k.touches[0];j.current={x0:J.clientX,y0:J.clientY,base:L,dir:null,on:!0},ne(!1)},V=k=>{const J=j.current;if(!J.on)return;const Te=k.touches[0].clientX-J.x0,B=k.touches[0].clientY-J.y0;if(!J.dir){(Math.abs(Te)>5||Math.abs(B)>5)&&(J.dir=Math.abs(Te)>Math.abs(B)?"h":"v");return}J.dir!=="v"&&F(Math.max(-192,Math.min(0,J.base+Te)))},X=()=>{j.current.on=!1,ne(!0),F(k=>k<-192/2?-192:0)},te=()=>{ne(!0),F(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(),te()},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(),te()},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(),te()},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(pm,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{U(),te()},className:"flex w-12 items-center justify-center bg-amber-500 text-white active:bg-amber-600",children:o.jsx(dx,{className:"h-4 w-4"})}),o.jsx("button",{type:"button",onClick:()=>{var k;W1(JSON.stringify({id:e.id,name:((k=e.title)==null?void 0:k.trim())||""},null,2)),te()},className:"flex w-12 items-center justify-center bg-blue-500 text-white active:bg-blue-600",children:o.jsx(gc,{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",Z&&"transition-transform duration-200 ease-out"),style:{...L!==0?{transform:`translateX(${L}px)`}:{},...L===-192?{pointerEvents:"none"}:{}},onTouchStart:K,onTouchMove:V,onTouchEnd:X,children:[o.jsxs("button",{type:"button",onClick:()=>{S||(s(),te())},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",oL(h))}),o.jsx("span",{className:"min-w-0 truncate font-mono text-xs text-fg-3",children:((ee=e.agent)==null?void 0:ee.trim())||"默认"}),T&&o.jsx(pm,{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})]}),S?o.jsx("input",{ref:O,type:"text",value:C,onChange:k=>A(k.target.value),onBlur:Q,onKeyDown:k=>{k.key==="Enter"&&Q(),k.key==="Escape"&&w(!1)},onClick:k=>k.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:k=>{k.stopPropagation(),U()},children:[(b||g)&&o.jsxs("div",{className:"mb-0.5 flex flex-wrap gap-1",children:[b&&o.jsxs("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium leading-none",b.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",b.number]}),g==null?void 0:g.map(k=>o.jsx("span",{className:oe("shrink-0 rounded px-1 py-0.5 font-mono text-[10px] font-medium leading-none",k.type==="pr"?k.state==="open"?"bg-blue-500/15 text-blue-400":k.mergedAt?"bg-purple-500/15 text-purple-400":"bg-red-500/15 text-red-400":k.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:k.type==="pr"?`PR#${k.number}`:`#${k.number}`},`${k.type}-${k.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(pm,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:U,title:"重命名",className:"rounded p-1 text-fg-5 hover:text-fg-2",children:o.jsx(dx,{className:"h-3.5 w-3.5"})}),o.jsx("button",{type:"button",onClick:()=>{var k;W1(JSON.stringify({id:e.id,name:((k=e.title)==null?void 0:k.trim())||""},null,2))},title:"复制 Session JSON",className:"rounded p-1 text-fg-5 hover:text-fg-2",children:o.jsx(gc,{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 J1({onClose:e}){const[t,a]=v.useState(null),s=Ie(A=>A.sessions),l=Ie(A=>A.activeSessionId),u=Ie(A=>A.sessionStatuses),d=Ie(A=>A.sessionFilter),f=Ie(A=>A.setSessionFilter),m=Ie(A=>A.setActiveSession),h=Ie(A=>A.deleteSession),b=Ie(A=>A.renameSession),g=Ie(A=>A.toggleSessionComplete),y=He(A=>A.activeRepoId),T=Ge(A=>A.issues),N=Ie(A=>A.allSessionLinks),S=[...s].filter(A=>A.parentID?!1:d==="active"?!A.completedAt:d==="completed"?!!A.completedAt:!0).sort((A,O)=>yh(O)-yh(A)),w=new Map(T.map(A=>[A.id,A])),C=A=>o.jsx("ul",{className:"space-y-0.5",children:A.map(O=>{const U=O.issueId?w.get(O.issueId):void 0,Q=N[O.id],L=[];if(Q){for(const F of Q.issues)L.push({number:F.number,state:F.state,type:"issue"});for(const F of Q.pullRequests)L.push({number:F.number,state:F.state,type:"pr",mergedAt:F.mergedAt})}return o.jsx(uL,{session:O,isActive:O.id===l,isConfirming:t===O.id,status:u[O.id],issue:U?{number:U.number,title:U.title,state:U.state}:void 0,linkedItems:L.length>0?L:void 0,onSelect:()=>{m(O.id),e==null||e()},onDelete:()=>{h(O.id),a(null)},onConfirm:()=>a(O.id),onCancelConfirm:()=>a(null),onRename:F=>void b(O.id,F),onToggleComplete:()=>void g(O.id)},O.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(Wa,{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(([A,O])=>o.jsx("button",{type:"button",onClick:()=>f(A),className:oe("rounded-md px-2 py-0.5 font-mono text-[11px] transition-colors",d===A?"bg-elevated text-fg-2":"text-fg-5 hover:text-fg-3"),children:O},A))}),o.jsx("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:y?S.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(S)}):o.jsx("p",{className:"px-2 py-6 text-center font-mono text-xs text-fg-5",children:"请先选择一个仓库"})})]})})}function cL(){const[e,t]=v.useState(()=>typeof window<"u"&&window.matchMedia("(min-width: 1280px)").matches);return v.useEffect(()=>{const a=window.matchMedia("(min-width: 1280px)"),s=l=>t(l.matches);return a.addEventListener("change",s),()=>a.removeEventListener("change",s)},[]),e}function eE(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 dL(){const[e,t]=v.useState(!1),[a,s]=v.useState(!1),[l,u]=v.useState(!1),d=cL(),f=Ie(w=>w.activeSessionId),m=Tc(w=>w.sessionPanelCollapsed),h=Tc(w=>w.toggleSessionPanel),b=Ie(w=>{const C=w.activeSessionId;return C?w.todos[C]??Sc:Sc}),g=Ie(w=>{const C=w.activeSessionId;return C?w.messages[C]??bo:bo}),y=Ie(w=>{const C=w.activeSessionId;return C?w.sessionLinks[C]:void 0});v.useEffect(()=>{d&&f?u(!0):d||u(!1)},[d,f]);const T=l&&!!f,N=()=>{window.matchMedia("(max-width: 767px)").matches?s(w=>!w):u(w=>!w)},S=i_({onSwipeRight:()=>t(!0),onSwipeLeft:()=>s(!0),disabled:e||a});return o.jsxs("div",{className:"flex min-h-0 flex-1",...S,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(J1,{})})}),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(Uh,{className:"h-3 w-3"}):o.jsx(Ph,{className:"h-3 w-3"})})]}),o.jsx(Eh,{side:"left",open:e,onClose:()=>t(!1),children:o.jsx(J1,{onClose:()=>t(!1)})}),o.jsx(Eh,{side:"right",open:a,onClose:()=>s(!1),children:o.jsx(Q1,{todos:b,messages:g,sessionLinks:y,sessionId:f,onScrollToMessage:w=>{s(!1),setTimeout(()=>eE(w),300)}})}),o.jsx("div",{className:"flex min-w-0 flex-1 flex-col",children:o.jsx(VD,{onToggleSidebar:()=>t(w=>!w),onToggleRightPanel:N,rightPanelOpen:T})}),T&&o.jsx("div",{className:"hidden shrink-0 md:flex",children:o.jsx(Q1,{todos:b,messages:g,sessionLinks:y,sessionId:f,onScrollToMessage:eE})})]})}const tE=/[#.]/g;function fL(e,t){const a=e||"",s={};let l=0,u,d;for(;l<a.length;){tE.lastIndex=l;const f=tE.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 l_(e,t,a){const s=a?gL(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=fL(u,t);const h=m.tagName.toLowerCase(),b=s?s.get(h):void 0;if(m.tagName=b||h,mL(d))f.unshift(d);else for(const[g,y]of Object.entries(d))hL(e,m.properties,g,y)}for(const h of f)Th(m.children,h);return m.type==="element"&&m.tagName==="template"&&(m.content={type:"root",children:m.children},m.children=[]),m}return l}function mL(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 hL(e,t,a,s){const l=Vc(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=jx(s):l.commaSeparated?u=Ox(s):l.commaOrSpaceSeparated?u=jx(Ox(s).join(" ")):u=nE(l,l.property,s):Array.isArray(s)?u=[...s]:u=l.property==="style"?pL(s):String(s);if(Array.isArray(u)){const d=[];for(const f of u)d.push(nE(l,l.property,f));u=d}l.property==="className"&&Array.isArray(t.className)&&(u=t.className.concat(u)),t[l.property]=u}}function Th(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)Th(e,a);else if(typeof t=="object"&&"type"in t)t.type==="root"?Th(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function nE(e,t,a){if(typeof a=="string"){if(e.number&&a&&!Number.isNaN(Number(a)))return Number(a);if((e.boolean||e.overloadedBoolean)&&(a===""||xo(a)===xo(t)))return!0}return a}function pL(e){const t=[];for(const[a,s]of Object.entries(e))t.push([a,s].join(": "));return t.join("; ")}function gL(e){const t=new Map;for(const a of e)t.set(a.toLowerCase(),a);return t}const bL=["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"],xL=l_(So,"div"),EL=l_(ds,"g",bL);function yL(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=aE(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=aE(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 aE(e,t){const a=e.indexOf("\r",t),s=e.indexOf(`
|
|
490
490
|
`,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/"},o_={}.hasOwnProperty,TL=Object.prototype;function _L(e,t){const a=t||{};return c0({file:a.file||void 0,location:!1,schema:a.space==="svg"?ds:So,verbose:a.verbose||!1},e)}function c0(e,t){let a;switch(t.nodeName){case"#comment":{const s=t;return a={type:"comment",value:s.data},fc(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:u_(e,t.childNodes),data:{quirksMode:l}},e.file&&e.location){const u=String(e.file),d=yL(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"},fc(e,s,a),a}case"#text":{const s=t;return a={type:"text",value:s.value},fc(e,s,a),a}default:return a=NL(e,t),a}}function u_(e,t){let a=-1;const s=[];for(;++a<t.length;){const l=c0(e,t[a]);s.push(l)}return s}function NL(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;o_.call(TL,m)||(l[m]=f.value)}const d=(e.schema.space==="svg"?EL:xL)(t.tagName,l,u_(e,t.childNodes));if(fc(e,t,d),d.tagName==="template"){const f=t,m=f.sourceCodeLocation,h=m&&m.startTag&&Pi(m.startTag),b=m&&m.endTag&&Pi(m.endTag),g=c0(e,f.content);h&&b&&e.file&&(g.position={start:h.end,end:b.start}),d.content=g}return e.schema=a,d}function fc(e,t,a){if("sourceCodeLocation"in t&&t.sourceCodeLocation&&e.file){const s=vL(e,a,t.sourceCodeLocation);s&&(e.location=!0,a.position=s)}}function vL(e,t,a){const s=Pi(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)o_.call(a.attrs,d)&&(u[Vc(e.schema,d).property]=Pi(a.attrs[d]));a.startTag;const f=Pi(a.startTag),m=a.endTag?Pi(a.endTag):void 0,h={opening:f};m&&(h.closing=m),h.properties=u,t.data={position:h}}}return s}function Pi(e){const t=rE({line:e.startLine,column:e.startCol,offset:e.startOffset}),a=rE({line:e.endLine,column:e.endCol,offset:e.endOffset});return t||a?{start:t,end:a}:void 0}function rE(e){return e.line&&e.column?e:void 0}const SL={},AL={}.hasOwnProperty,c_=dT("type",{handlers:{root:wL,element:ML,text:OL,comment:IL,doctype:RL}});function CL(e,t){const s=(t||SL).space;return c_(e,s==="svg"?ds:So)}function wL(e,t){const a={nodeName:"#document",mode:(e.data||{}).quirksMode?"quirks":"no-quirks",childNodes:[]};return a.childNodes=d0(e.children,a,t),Qi(e,a),a}function kL(e,t){const a={nodeName:"#document-fragment",childNodes:[]};return a.childNodes=d0(e.children,a,t),Qi(e,a),a}function RL(e){const t={nodeName:"#documentType",name:"html",publicId:"",systemId:"",parentNode:null};return Qi(e,t),t}function OL(e){const t={nodeName:"#text",value:e.value,parentNode:null};return Qi(e,t),t}function IL(e){const t={nodeName:"#comment",data:e.value,parentNode:null};return Qi(e,t),t}function ML(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"&&AL.call(e.properties,u)){const m=DL(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=d0(e.children,f,s),Qi(e,f),e.tagName==="template"&&e.content&&(f.content=kL(e.content,s)),f}function DL(e,t,a){const s=Vc(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?vy(a):Iy(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 d0(e,t,a){let s=-1;const l=[];if(e)for(;++s<e.length;){const u=c_(e[s],a);u.parentNode=t,l.push(u)}return l}function Qi(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 LL=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"],jL=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 M;(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"})(M||(M={}));const Gn={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function d_(e){return e>=55296&&e<=57343}function BL(e){return e>=56320&&e<=57343}function PL(e,t){return(e-55296)*1024+9216+t}function f_(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function m_(e){return e>=64976&&e<=65007||jL.has(e)}var ce;(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"})(ce||(ce={}));const UL=65536;class HL{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=UL,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(BL(a))return this.pos++,this._addGap(),PL(t,a)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,M.EOF;return this._err(ce.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,M.EOF;const s=this.html.charCodeAt(a);return s===M.CARRIAGE_RETURN?M.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,M.EOF;let t=this.html.charCodeAt(this.pos);return t===M.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,M.LINE_FEED):t===M.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,d_(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===M.LINE_FEED||t===M.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){f_(t)?this._err(ce.controlCharacterInInputStream):m_(t)&&this._err(ce.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 h_(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 FL=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏઑඡ༉༦ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲϏϢϸontourIntegraìȹoɴ\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲy;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱còJTabcdfgorstרׯؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ߂ߐĀiyޱrc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣসে্ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४ĀnrࢃgleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpwਖਛgȀLRlr৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼અઋp;椅y;䐜Ādl੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑඞcy;䐊cute;䅃ƀaeyહાron;䅇dil;䅅;䐝ƀgswે૰ativeƀMTV૨ediumSpace;怋hiĀcn૦ëeryThiîtedĀGLଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷreak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪௫ఄ಄ದൡඅ櫬Āoungruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater;EFGLSTஶஷ扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨setĀ;Eೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂෛ෧ขภยา฿ไlig;䅒cute耻Ó䃓Āiyීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲcr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬืde耻Õ䃕es;樷ml耻Ö䃖erĀBP๋Āar๐๓r;怾acĀek๚;揞et;掴arenthesis;揜ҀacfhilorsງຊຏຒດຝະrtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ檻cedesȀ;EST່້扺qual;檯lantEqual;扼ilde;找me;怳Ādpuct;戏ortionĀ;aȥl;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL憒ar;懥eftArrow;懄eiling;按oǵ\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄቕቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHcቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗ĀeiቻDzኀ\0ኇefore;戴a;䎘ĀcnኘkSpace;쀀 Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtèa;䎖r;愨pf;愤cr;쀀𝒵ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒;Eaeiopᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;eᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;eᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰᝃᝈ០៦ᠹᡐᜍ᥈ᥰot;櫭ĀcrᛶkȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;tbrk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯᝳ;䎲;愶een;扬r;쀀𝔟gcostuvwឍឝឳេ៕៛ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀakoᠦᠵĀcn៲ᠣkƀlst֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ;敛;敘;攘;攔;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģbar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;elƀ;bhᥨᥩᥫ䁜;槅sub;柈ŬᥴlĀ;e怢t»pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭒\0᯽\0ᰌƀcprᦲute;䄇̀;abcdsᦿᧀᧄ᧕᧙戩nd;橄rcup;橉Āau᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r;Ecefms᩠ᩢᩫ᪤᪪旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ\0\0aĀ;t䀬;䁀ƀ;fl戁îᅠeĀmxent»eóɍǧ\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯delprvw᭠᭬᭷ᮂᮬᯔarrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;pᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰻᰿ᱝᱩᱵᲞᲬᲷᴍᵻᶑᶫᶻ᷆᷍ròar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂᳖᳜᳠mƀ;oș᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄĀDoḆᴴoôĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»ṺƀaeiἒἚls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧\0耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₥₰₴⃰℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽ƀ;qsؾٌlanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqrⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0proør;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼ròòΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonóquigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roøurĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨íistĀ;sடr;쀀𝔫ȀEest⩦⩹⩼ƀ;qs⩭ƀ;qs⩴lanôií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast⭕⭚⭟lleìl;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖchimpqu⮽⯍⯙⬄⯤⯯Ȁ;cerല⯆ഷ⯉uå;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭ååഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñĀ;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;cⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācrir;榿;쀀𝔬ͯ\0\0\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕⶥⶨrò᪀Āirⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔǒr;榷rp;榹;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ\0\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ脀¶;l䂶leìЃɩ\0\0m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳ᤈ⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t⾴ïrel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⋢⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔ABHabcdefhilmnoprstuxけさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstwガクシスゼゾダッデナp;極Ā;fゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ìâヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘rrowĀ;tㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowóarpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓ròaòՑ;怏oustĀ;a㈞掱che»mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì耻䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;qኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫwar;椪lig耻ß䃟㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rëƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproøim»ኬsðኞĀas㚺㚮ðrn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈadempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xôheadĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roðtré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜtré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map(e=>e.charCodeAt(0))),zL=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 qL(e){var t;return e>=55296&&e<=57343||e>1114111?65533:(t=zL.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 $L=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 _h(e){return e>=mn.ZERO&&e<=mn.NINE}function YL(e){return e>=mn.UPPER_A&&e<=mn.UPPER_F||e>=mn.LOWER_A&&e<=mn.LOWER_F}function GL(e){return e>=mn.UPPER_A&&e<=mn.UPPER_Z||e>=mn.LOWER_A&&e<=mn.LOWER_Z||_h(e)}function KL(e){return e===mn.EQUALS||GL(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 Sr;(function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"})(Sr||(Sr={}));class VL{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=Sr.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)|$L)===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(_h(l)||YL(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(_h(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===Sr.Strict)return 0;return this.emitCodePoint(qL(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=QL(s,l,this.treeIndex+Math.max(1,u),d),this.treeIndex<0)return this.result===0||this.decodeMode===Sr.Attribute&&(u===0||KL(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!==Sr.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!==Sr.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 QL(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 ae;(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"})(ae||(ae={}));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 XL=new Map([[ae.A,E.A],[ae.ADDRESS,E.ADDRESS],[ae.ANNOTATION_XML,E.ANNOTATION_XML],[ae.APPLET,E.APPLET],[ae.AREA,E.AREA],[ae.ARTICLE,E.ARTICLE],[ae.ASIDE,E.ASIDE],[ae.B,E.B],[ae.BASE,E.BASE],[ae.BASEFONT,E.BASEFONT],[ae.BGSOUND,E.BGSOUND],[ae.BIG,E.BIG],[ae.BLOCKQUOTE,E.BLOCKQUOTE],[ae.BODY,E.BODY],[ae.BR,E.BR],[ae.BUTTON,E.BUTTON],[ae.CAPTION,E.CAPTION],[ae.CENTER,E.CENTER],[ae.CODE,E.CODE],[ae.COL,E.COL],[ae.COLGROUP,E.COLGROUP],[ae.DD,E.DD],[ae.DESC,E.DESC],[ae.DETAILS,E.DETAILS],[ae.DIALOG,E.DIALOG],[ae.DIR,E.DIR],[ae.DIV,E.DIV],[ae.DL,E.DL],[ae.DT,E.DT],[ae.EM,E.EM],[ae.EMBED,E.EMBED],[ae.FIELDSET,E.FIELDSET],[ae.FIGCAPTION,E.FIGCAPTION],[ae.FIGURE,E.FIGURE],[ae.FONT,E.FONT],[ae.FOOTER,E.FOOTER],[ae.FOREIGN_OBJECT,E.FOREIGN_OBJECT],[ae.FORM,E.FORM],[ae.FRAME,E.FRAME],[ae.FRAMESET,E.FRAMESET],[ae.H1,E.H1],[ae.H2,E.H2],[ae.H3,E.H3],[ae.H4,E.H4],[ae.H5,E.H5],[ae.H6,E.H6],[ae.HEAD,E.HEAD],[ae.HEADER,E.HEADER],[ae.HGROUP,E.HGROUP],[ae.HR,E.HR],[ae.HTML,E.HTML],[ae.I,E.I],[ae.IMG,E.IMG],[ae.IMAGE,E.IMAGE],[ae.INPUT,E.INPUT],[ae.IFRAME,E.IFRAME],[ae.KEYGEN,E.KEYGEN],[ae.LABEL,E.LABEL],[ae.LI,E.LI],[ae.LINK,E.LINK],[ae.LISTING,E.LISTING],[ae.MAIN,E.MAIN],[ae.MALIGNMARK,E.MALIGNMARK],[ae.MARQUEE,E.MARQUEE],[ae.MATH,E.MATH],[ae.MENU,E.MENU],[ae.META,E.META],[ae.MGLYPH,E.MGLYPH],[ae.MI,E.MI],[ae.MO,E.MO],[ae.MN,E.MN],[ae.MS,E.MS],[ae.MTEXT,E.MTEXT],[ae.NAV,E.NAV],[ae.NOBR,E.NOBR],[ae.NOFRAMES,E.NOFRAMES],[ae.NOEMBED,E.NOEMBED],[ae.NOSCRIPT,E.NOSCRIPT],[ae.OBJECT,E.OBJECT],[ae.OL,E.OL],[ae.OPTGROUP,E.OPTGROUP],[ae.OPTION,E.OPTION],[ae.P,E.P],[ae.PARAM,E.PARAM],[ae.PLAINTEXT,E.PLAINTEXT],[ae.PRE,E.PRE],[ae.RB,E.RB],[ae.RP,E.RP],[ae.RT,E.RT],[ae.RTC,E.RTC],[ae.RUBY,E.RUBY],[ae.S,E.S],[ae.SCRIPT,E.SCRIPT],[ae.SEARCH,E.SEARCH],[ae.SECTION,E.SECTION],[ae.SELECT,E.SELECT],[ae.SOURCE,E.SOURCE],[ae.SMALL,E.SMALL],[ae.SPAN,E.SPAN],[ae.STRIKE,E.STRIKE],[ae.STRONG,E.STRONG],[ae.STYLE,E.STYLE],[ae.SUB,E.SUB],[ae.SUMMARY,E.SUMMARY],[ae.SUP,E.SUP],[ae.TABLE,E.TABLE],[ae.TBODY,E.TBODY],[ae.TEMPLATE,E.TEMPLATE],[ae.TEXTAREA,E.TEXTAREA],[ae.TFOOT,E.TFOOT],[ae.TD,E.TD],[ae.TH,E.TH],[ae.THEAD,E.THEAD],[ae.TITLE,E.TITLE],[ae.TR,E.TR],[ae.TRACK,E.TRACK],[ae.TT,E.TT],[ae.U,E.U],[ae.UL,E.UL],[ae.SVG,E.SVG],[ae.VAR,E.VAR],[ae.WBR,E.WBR],[ae.XMP,E.XMP]]);function Xi(e){var t;return(t=XL.get(e))!==null&&t!==void 0?t:E.UNKNOWN}const be=E,WL={[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},Nh=new Set([be.H1,be.H2,be.H3,be.H4,be.H5,be.H6]);ae.STYLE,ae.SCRIPT,ae.XMP,ae.IFRAME,ae.NOEMBED,ae.NOFRAMES,ae.PLAINTEXT;var P;(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"})(P||(P={}));const Xt={DATA:P.DATA,RCDATA:P.RCDATA,RAWTEXT:P.RAWTEXT,SCRIPT_DATA:P.SCRIPT_DATA,PLAINTEXT:P.PLAINTEXT,CDATA_SECTION:P.CDATA_SECTION};function ZL(e){return e>=M.DIGIT_0&&e<=M.DIGIT_9}function no(e){return e>=M.LATIN_CAPITAL_A&&e<=M.LATIN_CAPITAL_Z}function JL(e){return e>=M.LATIN_SMALL_A&&e<=M.LATIN_SMALL_Z}function ss(e){return JL(e)||no(e)}function sE(e){return ss(e)||ZL(e)}function ic(e){return e+32}function p_(e){return e===M.SPACE||e===M.LINE_FEED||e===M.TABULATION||e===M.FORM_FEED}function iE(e){return p_(e)||e===M.SOLIDUS||e===M.GREATER_THAN_SIGN}function e8(e){return e===M.NULL?ce.nullCharacterReference:e>1114111?ce.characterReferenceOutsideUnicodeRange:d_(e)?ce.surrogateCharacterReference:m_(e)?ce.noncharacterCharacterReference:f_(e)||e===M.CARRIAGE_RETURN?ce.controlCharacterReference:null}class t8{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=P.DATA,this.returnState=P.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new HL(a),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new VL(FL,(s,l)=>{this.preprocessor.pos=this.entityStartPos+l-1,this._flushCodePointConsumedAsCharacterReference(s)},a.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(ce.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:s=>{this._err(ce.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+s)},validateNumericCharacterReference:s=>{const l=e8(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(h_(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(ce.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=Xi(t.tagName),t.type===tt.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(ce.endTagWithAttributes),t.selfClosing&&this._err(ce.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=p_(t)?tt.WHITESPACE_CHARACTER:t===M.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=P.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Sr.Attribute:Sr.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===P.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===P.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===P.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case P.DATA:{this._stateData(t);break}case P.RCDATA:{this._stateRcdata(t);break}case P.RAWTEXT:{this._stateRawtext(t);break}case P.SCRIPT_DATA:{this._stateScriptData(t);break}case P.PLAINTEXT:{this._statePlaintext(t);break}case P.TAG_OPEN:{this._stateTagOpen(t);break}case P.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case P.TAG_NAME:{this._stateTagName(t);break}case P.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case P.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case P.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case P.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case P.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case P.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case P.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case P.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case P.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case P.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case P.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case P.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case P.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case P.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case P.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case P.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case P.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case P.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case P.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case P.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case P.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case P.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case P.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case P.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case P.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case P.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case P.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case P.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case P.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case P.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case P.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case P.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case P.BOGUS_COMMENT:{this._stateBogusComment(t);break}case P.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case P.COMMENT_START:{this._stateCommentStart(t);break}case P.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case P.COMMENT:{this._stateComment(t);break}case P.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case P.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case P.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case P.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case P.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case P.COMMENT_END:{this._stateCommentEnd(t);break}case P.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case P.DOCTYPE:{this._stateDoctype(t);break}case P.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case P.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case P.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case P.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case P.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case P.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case P.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case P.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case P.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case P.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case P.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case P.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case P.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case P.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case P.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case P.CDATA_SECTION:{this._stateCdataSection(t);break}case P.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case P.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case P.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case P.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case M.LESS_THAN_SIGN:{this.state=P.TAG_OPEN;break}case M.AMPERSAND:{this._startCharacterReference();break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this._emitCodePoint(t);break}case M.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case M.AMPERSAND:{this._startCharacterReference();break}case M.LESS_THAN_SIGN:{this.state=P.RCDATA_LESS_THAN_SIGN;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this._emitChars(Pt);break}case M.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case M.LESS_THAN_SIGN:{this.state=P.RAWTEXT_LESS_THAN_SIGN;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this._emitChars(Pt);break}case M.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case M.LESS_THAN_SIGN:{this.state=P.SCRIPT_DATA_LESS_THAN_SIGN;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this._emitChars(Pt);break}case M.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case M.NULL:{this._err(ce.unexpectedNullCharacter),this._emitChars(Pt);break}case M.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(ss(t))this._createStartTagToken(),this.state=P.TAG_NAME,this._stateTagName(t);else switch(t){case M.EXCLAMATION_MARK:{this.state=P.MARKUP_DECLARATION_OPEN;break}case M.SOLIDUS:{this.state=P.END_TAG_OPEN;break}case M.QUESTION_MARK:{this._err(ce.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=P.BOGUS_COMMENT,this._stateBogusComment(t);break}case M.EOF:{this._err(ce.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(ce.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=P.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(ss(t))this._createEndTagToken(),this.state=P.TAG_NAME,this._stateTagName(t);else switch(t){case M.GREATER_THAN_SIGN:{this._err(ce.missingEndTagName),this.state=P.DATA;break}case M.EOF:{this._err(ce.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(ce.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=P.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const a=this.currentToken;switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:{this.state=P.BEFORE_ATTRIBUTE_NAME;break}case M.SOLIDUS:{this.state=P.SELF_CLOSING_START_TAG;break}case M.GREATER_THAN_SIGN:{this.state=P.DATA,this.emitCurrentTagToken();break}case M.NULL:{this._err(ce.unexpectedNullCharacter),a.tagName+=Pt;break}case M.EOF:{this._err(ce.eofInTag),this._emitEOFToken();break}default:a.tagName+=String.fromCodePoint(no(t)?ic(t):t)}}_stateRcdataLessThanSign(t){t===M.SOLIDUS?this.state=P.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=P.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){ss(t)?(this.state=P.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=P.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 M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=P.BEFORE_ATTRIBUTE_NAME,!1;case M.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=P.SELF_CLOSING_START_TAG,!1;case M.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=P.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=P.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===M.SOLIDUS?this.state=P.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=P.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){ss(t)?(this.state=P.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=P.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=P.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case M.SOLIDUS:{this.state=P.SCRIPT_DATA_END_TAG_OPEN;break}case M.EXCLAMATION_MARK:{this.state=P.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=P.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){ss(t)?(this.state=P.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=P.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=P.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===M.HYPHEN_MINUS?(this.state=P.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=P.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===M.HYPHEN_MINUS?(this.state=P.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=P.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case M.HYPHEN_MINUS:{this.state=P.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case M.LESS_THAN_SIGN:{this.state=P.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this._emitChars(Pt);break}case M.EOF:{this._err(ce.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case M.HYPHEN_MINUS:{this.state=P.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case M.LESS_THAN_SIGN:{this.state=P.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this.state=P.SCRIPT_DATA_ESCAPED,this._emitChars(Pt);break}case M.EOF:{this._err(ce.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=P.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case M.HYPHEN_MINUS:{this._emitChars("-");break}case M.LESS_THAN_SIGN:{this.state=P.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case M.GREATER_THAN_SIGN:{this.state=P.SCRIPT_DATA,this._emitChars(">");break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this.state=P.SCRIPT_DATA_ESCAPED,this._emitChars(Pt);break}case M.EOF:{this._err(ce.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=P.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===M.SOLIDUS?this.state=P.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:ss(t)?(this._emitChars("<"),this.state=P.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=P.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){ss(t)?(this.state=P.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=P.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=P.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Gn.SCRIPT,!1)&&iE(this.preprocessor.peek(Gn.SCRIPT.length))){this._emitCodePoint(t);for(let a=0;a<Gn.SCRIPT.length;a++)this._emitCodePoint(this._consume());this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=P.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case M.HYPHEN_MINUS:{this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case M.LESS_THAN_SIGN:{this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this._emitChars(Pt);break}case M.EOF:{this._err(ce.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case M.HYPHEN_MINUS:{this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case M.LESS_THAN_SIGN:{this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Pt);break}case M.EOF:{this._err(ce.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case M.HYPHEN_MINUS:{this._emitChars("-");break}case M.LESS_THAN_SIGN:{this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case M.GREATER_THAN_SIGN:{this.state=P.SCRIPT_DATA,this._emitChars(">");break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Pt);break}case M.EOF:{this._err(ce.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===M.SOLIDUS?(this.state=P.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Gn.SCRIPT,!1)&&iE(this.preprocessor.peek(Gn.SCRIPT.length))){this._emitCodePoint(t);for(let a=0;a<Gn.SCRIPT.length;a++)this._emitCodePoint(this._consume());this.state=P.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=P.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.SOLIDUS:case M.GREATER_THAN_SIGN:case M.EOF:{this.state=P.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case M.EQUALS_SIGN:{this._err(ce.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=P.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=P.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:case M.SOLIDUS:case M.GREATER_THAN_SIGN:case M.EOF:{this._leaveAttrName(),this.state=P.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case M.EQUALS_SIGN:{this._leaveAttrName(),this.state=P.BEFORE_ATTRIBUTE_VALUE;break}case M.QUOTATION_MARK:case M.APOSTROPHE:case M.LESS_THAN_SIGN:{this._err(ce.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this.currentAttr.name+=Pt;break}default:this.currentAttr.name+=String.fromCodePoint(no(t)?ic(t):t)}}_stateAfterAttributeName(t){switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.SOLIDUS:{this.state=P.SELF_CLOSING_START_TAG;break}case M.EQUALS_SIGN:{this.state=P.BEFORE_ATTRIBUTE_VALUE;break}case M.GREATER_THAN_SIGN:{this.state=P.DATA,this.emitCurrentTagToken();break}case M.EOF:{this._err(ce.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=P.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.QUOTATION_MARK:{this.state=P.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case M.APOSTROPHE:{this.state=P.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case M.GREATER_THAN_SIGN:{this._err(ce.missingAttributeValue),this.state=P.DATA,this.emitCurrentTagToken();break}default:this.state=P.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case M.QUOTATION_MARK:{this.state=P.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case M.AMPERSAND:{this._startCharacterReference();break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this.currentAttr.value+=Pt;break}case M.EOF:{this._err(ce.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case M.APOSTROPHE:{this.state=P.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case M.AMPERSAND:{this._startCharacterReference();break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this.currentAttr.value+=Pt;break}case M.EOF:{this._err(ce.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:{this._leaveAttrValue(),this.state=P.BEFORE_ATTRIBUTE_NAME;break}case M.AMPERSAND:{this._startCharacterReference();break}case M.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=P.DATA,this.emitCurrentTagToken();break}case M.NULL:{this._err(ce.unexpectedNullCharacter),this.currentAttr.value+=Pt;break}case M.QUOTATION_MARK:case M.APOSTROPHE:case M.LESS_THAN_SIGN:case M.EQUALS_SIGN:case M.GRAVE_ACCENT:{this._err(ce.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case M.EOF:{this._err(ce.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:{this._leaveAttrValue(),this.state=P.BEFORE_ATTRIBUTE_NAME;break}case M.SOLIDUS:{this._leaveAttrValue(),this.state=P.SELF_CLOSING_START_TAG;break}case M.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=P.DATA,this.emitCurrentTagToken();break}case M.EOF:{this._err(ce.eofInTag),this._emitEOFToken();break}default:this._err(ce.missingWhitespaceBetweenAttributes),this.state=P.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case M.GREATER_THAN_SIGN:{const a=this.currentToken;a.selfClosing=!0,this.state=P.DATA,this.emitCurrentTagToken();break}case M.EOF:{this._err(ce.eofInTag),this._emitEOFToken();break}default:this._err(ce.unexpectedSolidusInTag),this.state=P.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const a=this.currentToken;switch(t){case M.GREATER_THAN_SIGN:{this.state=P.DATA,this.emitCurrentComment(a);break}case M.EOF:{this.emitCurrentComment(a),this._emitEOFToken();break}case M.NULL:{this._err(ce.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=P.COMMENT_START):this._consumeSequenceIfMatch(Gn.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Gn.DOCTYPE.length+1),this.state=P.DOCTYPE):this._consumeSequenceIfMatch(Gn.CDATA_START,!0)?this.inForeignNode?this.state=P.CDATA_SECTION:(this._err(ce.cdataInHtmlContent),this._createCommentToken(Gn.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=P.BOGUS_COMMENT):this._ensureHibernation()||(this._err(ce.incorrectlyOpenedComment),this._createCommentToken(2),this.state=P.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case M.HYPHEN_MINUS:{this.state=P.COMMENT_START_DASH;break}case M.GREATER_THAN_SIGN:{this._err(ce.abruptClosingOfEmptyComment),this.state=P.DATA;const a=this.currentToken;this.emitCurrentComment(a);break}default:this.state=P.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const a=this.currentToken;switch(t){case M.HYPHEN_MINUS:{this.state=P.COMMENT_END;break}case M.GREATER_THAN_SIGN:{this._err(ce.abruptClosingOfEmptyComment),this.state=P.DATA,this.emitCurrentComment(a);break}case M.EOF:{this._err(ce.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="-",this.state=P.COMMENT,this._stateComment(t)}}_stateComment(t){const a=this.currentToken;switch(t){case M.HYPHEN_MINUS:{this.state=P.COMMENT_END_DASH;break}case M.LESS_THAN_SIGN:{a.data+="<",this.state=P.COMMENT_LESS_THAN_SIGN;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),a.data+=Pt;break}case M.EOF:{this._err(ce.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const a=this.currentToken;switch(t){case M.EXCLAMATION_MARK:{a.data+="!",this.state=P.COMMENT_LESS_THAN_SIGN_BANG;break}case M.LESS_THAN_SIGN:{a.data+="<";break}default:this.state=P.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===M.HYPHEN_MINUS?this.state=P.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=P.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===M.HYPHEN_MINUS?this.state=P.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=P.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==M.GREATER_THAN_SIGN&&t!==M.EOF&&this._err(ce.nestedComment),this.state=P.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const a=this.currentToken;switch(t){case M.HYPHEN_MINUS:{this.state=P.COMMENT_END;break}case M.EOF:{this._err(ce.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="-",this.state=P.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const a=this.currentToken;switch(t){case M.GREATER_THAN_SIGN:{this.state=P.DATA,this.emitCurrentComment(a);break}case M.EXCLAMATION_MARK:{this.state=P.COMMENT_END_BANG;break}case M.HYPHEN_MINUS:{a.data+="-";break}case M.EOF:{this._err(ce.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="--",this.state=P.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const a=this.currentToken;switch(t){case M.HYPHEN_MINUS:{a.data+="--!",this.state=P.COMMENT_END_DASH;break}case M.GREATER_THAN_SIGN:{this._err(ce.incorrectlyClosedComment),this.state=P.DATA,this.emitCurrentComment(a);break}case M.EOF:{this._err(ce.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="--!",this.state=P.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:{this.state=P.BEFORE_DOCTYPE_NAME;break}case M.GREATER_THAN_SIGN:{this.state=P.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case M.EOF:{this._err(ce.eofInDoctype),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ce.missingWhitespaceBeforeDoctypeName),this.state=P.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(no(t))this._createDoctypeToken(String.fromCharCode(ic(t))),this.state=P.DOCTYPE_NAME;else switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.NULL:{this._err(ce.unexpectedNullCharacter),this._createDoctypeToken(Pt),this.state=P.DOCTYPE_NAME;break}case M.GREATER_THAN_SIGN:{this._err(ce.missingDoctypeName),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=P.DATA;break}case M.EOF:{this._err(ce.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=P.DOCTYPE_NAME}}_stateDoctypeName(t){const a=this.currentToken;switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:{this.state=P.AFTER_DOCTYPE_NAME;break}case M.GREATER_THAN_SIGN:{this.state=P.DATA,this.emitCurrentDoctype(a);break}case M.NULL:{this._err(ce.unexpectedNullCharacter),a.name+=Pt;break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.name+=String.fromCodePoint(no(t)?ic(t):t)}}_stateAfterDoctypeName(t){const a=this.currentToken;switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.GREATER_THAN_SIGN:{this.state=P.DATA,this.emitCurrentDoctype(a);break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Gn.PUBLIC,!1)?this.state=P.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Gn.SYSTEM,!1)?this.state=P.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(ce.invalidCharacterSequenceAfterDoctypeName),a.forceQuirks=!0,this.state=P.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const a=this.currentToken;switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:{this.state=P.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case M.QUOTATION_MARK:{this._err(ce.missingWhitespaceAfterDoctypePublicKeyword),a.publicId="",this.state=P.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case M.APOSTROPHE:{this._err(ce.missingWhitespaceAfterDoctypePublicKeyword),a.publicId="",this.state=P.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case M.GREATER_THAN_SIGN:{this._err(ce.missingDoctypePublicIdentifier),a.forceQuirks=!0,this.state=P.DATA,this.emitCurrentDoctype(a);break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ce.missingQuoteBeforeDoctypePublicIdentifier),a.forceQuirks=!0,this.state=P.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const a=this.currentToken;switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.QUOTATION_MARK:{a.publicId="",this.state=P.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case M.APOSTROPHE:{a.publicId="",this.state=P.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case M.GREATER_THAN_SIGN:{this._err(ce.missingDoctypePublicIdentifier),a.forceQuirks=!0,this.state=P.DATA,this.emitCurrentDoctype(a);break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ce.missingQuoteBeforeDoctypePublicIdentifier),a.forceQuirks=!0,this.state=P.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const a=this.currentToken;switch(t){case M.QUOTATION_MARK:{this.state=P.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),a.publicId+=Pt;break}case M.GREATER_THAN_SIGN:{this._err(ce.abruptDoctypePublicIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=P.DATA;break}case M.EOF:{this._err(ce.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 M.APOSTROPHE:{this.state=P.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),a.publicId+=Pt;break}case M.GREATER_THAN_SIGN:{this._err(ce.abruptDoctypePublicIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=P.DATA;break}case M.EOF:{this._err(ce.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 M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:{this.state=P.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case M.GREATER_THAN_SIGN:{this.state=P.DATA,this.emitCurrentDoctype(a);break}case M.QUOTATION_MARK:{this._err(ce.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),a.systemId="",this.state=P.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case M.APOSTROPHE:{this._err(ce.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),a.systemId="",this.state=P.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ce.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=P.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const a=this.currentToken;switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=P.DATA;break}case M.QUOTATION_MARK:{a.systemId="",this.state=P.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case M.APOSTROPHE:{a.systemId="",this.state=P.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ce.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=P.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const a=this.currentToken;switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:{this.state=P.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case M.QUOTATION_MARK:{this._err(ce.missingWhitespaceAfterDoctypeSystemKeyword),a.systemId="",this.state=P.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case M.APOSTROPHE:{this._err(ce.missingWhitespaceAfterDoctypeSystemKeyword),a.systemId="",this.state=P.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case M.GREATER_THAN_SIGN:{this._err(ce.missingDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=P.DATA,this.emitCurrentDoctype(a);break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ce.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=P.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const a=this.currentToken;switch(t){case M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.QUOTATION_MARK:{a.systemId="",this.state=P.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case M.APOSTROPHE:{a.systemId="",this.state=P.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case M.GREATER_THAN_SIGN:{this._err(ce.missingDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=P.DATA,this.emitCurrentDoctype(a);break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ce.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=P.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const a=this.currentToken;switch(t){case M.QUOTATION_MARK:{this.state=P.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),a.systemId+=Pt;break}case M.GREATER_THAN_SIGN:{this._err(ce.abruptDoctypeSystemIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=P.DATA;break}case M.EOF:{this._err(ce.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 M.APOSTROPHE:{this.state=P.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case M.NULL:{this._err(ce.unexpectedNullCharacter),a.systemId+=Pt;break}case M.GREATER_THAN_SIGN:{this._err(ce.abruptDoctypeSystemIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=P.DATA;break}case M.EOF:{this._err(ce.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 M.SPACE:case M.LINE_FEED:case M.TABULATION:case M.FORM_FEED:break;case M.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=P.DATA;break}case M.EOF:{this._err(ce.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(ce.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=P.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const a=this.currentToken;switch(t){case M.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=P.DATA;break}case M.NULL:{this._err(ce.unexpectedNullCharacter);break}case M.EOF:{this.emitCurrentDoctype(a),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case M.RIGHT_SQUARE_BRACKET:{this.state=P.CDATA_SECTION_BRACKET;break}case M.EOF:{this._err(ce.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===M.RIGHT_SQUARE_BRACKET?this.state=P.CDATA_SECTION_END:(this._emitChars("]"),this.state=P.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case M.GREATER_THAN_SIGN:{this.state=P.DATA;break}case M.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=P.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(M.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&sE(this.preprocessor.peek(1))?P.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){sE(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===M.SEMICOLON&&this._err(ce.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}}const g_=new Set([E.DD,E.DT,E.LI,E.OPTGROUP,E.OPTION,E.P,E.RB,E.RP,E.RT,E.RTC]),lE=new Set([...g_,E.CAPTION,E.COLGROUP,E.TBODY,E.TD,E.TFOOT,E.TH,E.THEAD,E.TR]),Mc=new Set([E.APPLET,E.CAPTION,E.HTML,E.MARQUEE,E.OBJECT,E.TABLE,E.TD,E.TEMPLATE,E.TH]),n8=new Set([...Mc,E.OL,E.UL]),a8=new Set([...Mc,E.BUTTON]),oE=new Set([E.ANNOTATION_XML,E.MI,E.MN,E.MO,E.MS,E.MTEXT]),uE=new Set([E.DESC,E.FOREIGN_OBJECT,E.TITLE]),r8=new Set([E.TR,E.TEMPLATE,E.HTML]),s8=new Set([E.TBODY,E.TFOOT,E.THEAD,E.TEMPLATE,E.HTML]),i8=new Set([E.TABLE,E.TEMPLATE,E.HTML]),l8=new Set([E.TD,E.TH]);class o8{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(Nh,ge.HTML)}popUntilTableCellPopped(){this.popUntilPopped(l8,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(i8,ge.HTML)}clearBackToTableBodyContext(){this.clearBackTo(s8,ge.HTML)}clearBackToTableRowContext(){this.clearBackTo(r8,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(uE.has(l))return!1;break}case ge.MATHML:{if(oE.has(l))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,Mc)}hasInListItemScope(t){return this.hasInDynamicScope(t,n8)}hasInButtonScope(t){return this.hasInDynamicScope(t,a8)}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(Nh.has(a))return!0;if(Mc.has(a))return!1;break}case ge.SVG:{if(uE.has(a))return!1;break}case ge.MATHML:{if(oE.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&&g_.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;this.currentTagId!==void 0&&lE.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==void 0&&this.currentTagId!==t&&lE.has(this.currentTagId);)this.pop()}}const Km=3;var Qa;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(Qa||(Qa={}));const cE={type:Qa.Marker};class u8{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===Qa.Marker)break;const{element:h}=m;if(this.treeAdapter.getTagName(h)===u&&this.treeAdapter.getNamespaceURI(h)===d){const b=this.treeAdapter.getAttrList(h);b.length===l&&s.push({idx:f,attrs:b})}}return s}_ensureNoahArkCondition(t){if(this.entries.length<Km)return;const a=this.treeAdapter.getAttrList(t),s=this._getNoahArkConditionCandidates(t,a);if(s.length<Km)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>=Km&&this.entries.splice(f.idx,1))}}insertMarker(){this.entries.unshift(cE)}pushElement(t,a){this._ensureNoahArkCondition(t),this.entries.unshift({type:Qa.Element,element:t,token:a})}insertElementAfterBookmark(t,a){const s=this.entries.indexOf(this.bookmark);this.entries.splice(s,0,{type:Qa.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(cE);t===-1?this.entries.length=0:this.entries.splice(0,t+1)}getElementEntryInScopeWithTagName(t){const a=this.entries.find(s=>s.type===Qa.Marker||this.treeAdapter.getTagName(s.element)===t);return a&&a.type===Qa.Element?a:null}getElementEntry(t){return this.entries.find(a=>a.type===Qa.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}}},b_="html",c8="about:legacy-compat",d8="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",x_=["+//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//"],f8=[...x_,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],m8=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),E_=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],h8=[...E_,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function dE(e,t){return t.some(a=>e.startsWith(a))}function p8(e){return e.name===b_&&e.publicId===null&&(e.systemId===null||e.systemId===c8)}function g8(e){if(e.name!==b_)return Na.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===d8)return Na.QUIRKS;let{publicId:a}=e;if(a!==null){if(a=a.toLowerCase(),m8.has(a))return Na.QUIRKS;let s=t===null?f8:x_;if(dE(a,s))return Na.QUIRKS;if(s=t===null?E_:h8,dE(a,s))return Na.LIMITED_QUIRKS}return Na.NO_QUIRKS}const fE={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},b8="definitionurl",x8="definitionURL",E8=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])),y8=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}]]),T8=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])),_8=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 N8(e){const t=e.tagID;return t===E.FONT&&e.attrs.some(({name:s})=>s===Hs.COLOR||s===Hs.SIZE||s===Hs.FACE)||_8.has(t)}function y_(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===b8){e.attrs[t].name=x8;break}}function T_(e){for(let t=0;t<e.attrs.length;t++){const a=E8.get(e.attrs[t].name);a!=null&&(e.attrs[t].name=a)}}function f0(e){for(let t=0;t<e.attrs.length;t++){const a=y8.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 v8(e){const t=T8.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Xi(e.tagName))}function S8(e,t){return t===ge.MATHML&&(e===E.MI||e===E.MO||e===E.MN||e===E.MS||e===E.MTEXT)}function A8(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===fE.TEXT_HTML||l===fE.APPLICATION_XML}}return t===ge.SVG&&(e===E.FOREIGN_OBJECT||e===E.DESC||e===E.TITLE)}function C8(e,t,a,s){return(!s||s===ge.HTML)&&A8(e,t,a)||(!s||s===ge.MATHML)&&S8(e,t)}const w8="hidden",k8=8,R8=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 O8={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},__=new Set([E.TABLE,E.TBODY,E.TFOOT,E.THEAD,E.TR]),mE={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:is,onParseError:null};class hE{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={...mE,...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 t8(this.options,this),this.activeFormattingElements=new u8(this.treeAdapter),this.fragmentContextID=s?Xi(this.treeAdapter.getTagName(s)):E.UNKNOWN,this._setContextModes(s??this.document,this.fragmentContextID),this.openElements=new o8(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={...mE,...a};t??(t=s.treeAdapter.createElement(ae.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:O8,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)===ae.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(ae.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:b}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(d,{endLine:m,endCol:h,endOffset:b})}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)===ae.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 C8(t,l,u,s)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const a=this.activeFormattingElements.entries.findIndex(l=>l.type===Qa.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 __.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 WL[s].has(a)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){l9(this,t);return}switch(this.insertionMode){case z.INITIAL:{Jl(this,t);break}case z.BEFORE_HTML:{io(this,t);break}case z.BEFORE_HEAD:{lo(this,t);break}case z.IN_HEAD:{oo(this,t);break}case z.IN_HEAD_NO_SCRIPT:{uo(this,t);break}case z.AFTER_HEAD:{co(this,t);break}case z.IN_BODY:case z.IN_CAPTION:case z.IN_CELL:case z.IN_TEMPLATE:{v_(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:{Vm(this,t);break}case z.IN_TABLE_TEXT:{R_(this,t);break}case z.IN_COLUMN_GROUP:{Dc(this,t);break}case z.AFTER_BODY:{Lc(this,t);break}case z.AFTER_AFTER_BODY:{mc(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){i9(this,t);return}switch(this.insertionMode){case z.INITIAL:{Jl(this,t);break}case z.BEFORE_HTML:{io(this,t);break}case z.BEFORE_HEAD:{lo(this,t);break}case z.IN_HEAD:{oo(this,t);break}case z.IN_HEAD_NO_SCRIPT:{uo(this,t);break}case z.AFTER_HEAD:{co(this,t);break}case z.TEXT:{this._insertCharacters(t);break}case z.IN_TABLE:case z.IN_TABLE_BODY:case z.IN_ROW:{Vm(this,t);break}case z.IN_COLUMN_GROUP:{Dc(this,t);break}case z.AFTER_BODY:{Lc(this,t);break}case z.AFTER_AFTER_BODY:{mc(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){vh(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:{vh(this,t);break}case z.IN_TABLE_TEXT:{eo(this,t);break}case z.AFTER_BODY:{P8(this,t);break}case z.AFTER_AFTER_BODY:case z.AFTER_AFTER_FRAMESET:{U8(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case z.INITIAL:{H8(this,t);break}case z.BEFORE_HEAD:case z.IN_HEAD:case z.IN_HEAD_NO_SCRIPT:case z.AFTER_HEAD:{this._err(t,ce.misplacedDoctype);break}case z.IN_TABLE_TEXT:{eo(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,ce.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?o9(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case z.INITIAL:{Jl(this,t);break}case z.BEFORE_HTML:{F8(this,t);break}case z.BEFORE_HEAD:{q8(this,t);break}case z.IN_HEAD:{Ba(this,t);break}case z.IN_HEAD_NO_SCRIPT:{G8(this,t);break}case z.AFTER_HEAD:{V8(this,t);break}case z.IN_BODY:{wn(this,t);break}case z.IN_TABLE:{qi(this,t);break}case z.IN_TABLE_TEXT:{eo(this,t);break}case z.IN_CAPTION:{$j(this,t);break}case z.IN_COLUMN_GROUP:{p0(this,t);break}case z.IN_TABLE_BODY:{nd(this,t);break}case z.IN_ROW:{ad(this,t);break}case z.IN_CELL:{Kj(this,t);break}case z.IN_SELECT:{M_(this,t);break}case z.IN_SELECT_IN_TABLE:{Qj(this,t);break}case z.IN_TEMPLATE:{Wj(this,t);break}case z.AFTER_BODY:{Jj(this,t);break}case z.IN_FRAMESET:{e9(this,t);break}case z.AFTER_FRAMESET:{n9(this,t);break}case z.AFTER_AFTER_BODY:{r9(this,t);break}case z.AFTER_AFTER_FRAMESET:{s9(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?u9(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case z.INITIAL:{Jl(this,t);break}case z.BEFORE_HTML:{z8(this,t);break}case z.BEFORE_HEAD:{$8(this,t);break}case z.IN_HEAD:{Y8(this,t);break}case z.IN_HEAD_NO_SCRIPT:{K8(this,t);break}case z.AFTER_HEAD:{Q8(this,t);break}case z.IN_BODY:{td(this,t);break}case z.TEXT:{Dj(this,t);break}case z.IN_TABLE:{To(this,t);break}case z.IN_TABLE_TEXT:{eo(this,t);break}case z.IN_CAPTION:{Yj(this,t);break}case z.IN_COLUMN_GROUP:{Gj(this,t);break}case z.IN_TABLE_BODY:{Sh(this,t);break}case z.IN_ROW:{I_(this,t);break}case z.IN_CELL:{Vj(this,t);break}case z.IN_SELECT:{D_(this,t);break}case z.IN_SELECT_IN_TABLE:{Xj(this,t);break}case z.IN_TEMPLATE:{Zj(this,t);break}case z.AFTER_BODY:{j_(this,t);break}case z.IN_FRAMESET:{t9(this,t);break}case z.AFTER_FRAMESET:{a9(this,t);break}case z.AFTER_AFTER_BODY:{mc(this,t);break}}}onEof(t){switch(this.insertionMode){case z.INITIAL:{Jl(this,t);break}case z.BEFORE_HTML:{io(this,t);break}case z.BEFORE_HEAD:{lo(this,t);break}case z.IN_HEAD:{oo(this,t);break}case z.IN_HEAD_NO_SCRIPT:{uo(this,t);break}case z.AFTER_HEAD:{co(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:{w_(this,t);break}case z.TEXT:{Lj(this,t);break}case z.IN_TABLE_TEXT:{eo(this,t);break}case z.IN_TEMPLATE:{L_(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:{h0(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===M.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:{N_(this,t);break}case z.IN_TABLE:case z.IN_TABLE_BODY:case z.IN_ROW:{Vm(this,t);break}case z.IN_TABLE_TEXT:{k_(this,t);break}}}}function I8(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):C_(e,t),a}function M8(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 D8(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>=R8;!f||m?(m&&e.activeFormattingElements.removeEntry(f),e.openElements.remove(d)):(d=L8(e,f),s===t&&(e.activeFormattingElements.bookmark=f),e.treeAdapter.detachNode(s),e.treeAdapter.appendChild(d,s),s=d)}return s}function L8(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 j8(e,t,a){const s=e.treeAdapter.getTagName(t),l=Xi(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 B8(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 m0(e,t){for(let a=0;a<k8;a++){const s=I8(e,t);if(!s)break;const l=M8(e,s);if(!l)break;e.activeFormattingElements.bookmark=s;const u=D8(e,l,s.element),d=e.openElements.getCommonAncestor(s.element);e.treeAdapter.detachNode(u),d&&j8(e,d,u),B8(e,l,s)}}function vh(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function P8(e,t){e._appendCommentNode(t,e.openElements.items[0])}function U8(e,t){e._appendCommentNode(t,e.document)}function h0(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 H8(e,t){e._setDocumentType(t);const a=t.forceQuirks?Na.QUIRKS:g8(t);p8(t)||e._err(t,ce.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,a),e.insertionMode=z.BEFORE_HTML}function Jl(e,t){e._err(t,ce.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Na.QUIRKS),e.insertionMode=z.BEFORE_HTML,e._processToken(t)}function F8(e,t){t.tagID===E.HTML?(e._insertElement(t,ge.HTML),e.insertionMode=z.BEFORE_HEAD):io(e,t)}function z8(e,t){const a=t.tagID;(a===E.HTML||a===E.HEAD||a===E.BODY||a===E.BR)&&io(e,t)}function io(e,t){e._insertFakeRootElement(),e.insertionMode=z.BEFORE_HEAD,e._processToken(t)}function q8(e,t){switch(t.tagID){case E.HTML:{wn(e,t);break}case E.HEAD:{e._insertElement(t,ge.HTML),e.headElement=e.openElements.current,e.insertionMode=z.IN_HEAD;break}default:lo(e,t)}}function $8(e,t){const a=t.tagID;a===E.HEAD||a===E.BODY||a===E.HTML||a===E.BR?lo(e,t):e._err(t,ce.endTagWithoutMatchingOpenElement)}function lo(e,t){e._insertFakeElement(ae.HEAD,E.HEAD),e.headElement=e.openElements.current,e.insertionMode=z.IN_HEAD,e._processToken(t)}function Ba(e,t){switch(t.tagID){case E.HTML:{wn(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,ce.misplacedStartTagForHeadElement);break}default:oo(e,t)}}function Y8(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:{oo(e,t);break}case E.TEMPLATE:{Vs(e,t);break}default:e._err(t,ce.endTagWithoutMatchingOpenElement)}}function Vs(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==E.TEMPLATE&&e._err(t,ce.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(E.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,ce.endTagWithoutMatchingOpenElement)}function oo(e,t){e.openElements.pop(),e.insertionMode=z.AFTER_HEAD,e._processToken(t)}function G8(e,t){switch(t.tagID){case E.HTML:{wn(e,t);break}case E.BASEFONT:case E.BGSOUND:case E.HEAD:case E.LINK:case E.META:case E.NOFRAMES:case E.STYLE:{Ba(e,t);break}case E.NOSCRIPT:{e._err(t,ce.nestedNoscriptInHead);break}default:uo(e,t)}}function K8(e,t){switch(t.tagID){case E.NOSCRIPT:{e.openElements.pop(),e.insertionMode=z.IN_HEAD;break}case E.BR:{uo(e,t);break}default:e._err(t,ce.endTagWithoutMatchingOpenElement)}}function uo(e,t){const a=t.type===tt.EOF?ce.openElementsLeftAfterEof:ce.disallowedContentInNoscriptInHead;e._err(t,a),e.openElements.pop(),e.insertionMode=z.IN_HEAD,e._processToken(t)}function V8(e,t){switch(t.tagID){case E.HTML:{wn(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,ce.abandonedHeadElementChild),e.openElements.push(e.headElement,E.HEAD),Ba(e,t),e.openElements.remove(e.headElement);break}case E.HEAD:{e._err(t,ce.misplacedStartTagForHeadElement);break}default:co(e,t)}}function Q8(e,t){switch(t.tagID){case E.BODY:case E.HTML:case E.BR:{co(e,t);break}case E.TEMPLATE:{Vs(e,t);break}default:e._err(t,ce.endTagWithoutMatchingOpenElement)}}function co(e,t){e._insertFakeElement(ae.BODY,E.BODY),e.insertionMode=z.IN_BODY,ed(e,t)}function ed(e,t){switch(t.type){case tt.CHARACTER:{v_(e,t);break}case tt.WHITESPACE_CHARACTER:{N_(e,t);break}case tt.COMMENT:{vh(e,t);break}case tt.START_TAG:{wn(e,t);break}case tt.END_TAG:{td(e,t);break}case tt.EOF:{w_(e,t);break}}}function N_(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function v_(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function X8(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function W8(e,t){const a=e.openElements.tryPeekProperlyNestedBodyElement();a&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(a,t.attrs))}function Z8(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 J8(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML)}function ej(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e.openElements.currentTagId!==void 0&&Nh.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,ge.HTML)}function tj(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function nj(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 aj(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 rj(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._insertElement(t,ge.HTML),e.tokenizer.state=Xt.PLAINTEXT}function sj(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 ij(e,t){const a=e.activeFormattingElements.getElementEntryInScopeWithTagName(ae.A);a&&(m0(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 lj(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function oj(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(E.NOBR)&&(m0(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,ge.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function uj(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function cj(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 S_(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,ge.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function A_(e){const t=h_(e,Hs.TYPE);return t!=null&&t.toLowerCase()===w8}function dj(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,ge.HTML),A_(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function fj(e,t){e._appendElement(t,ge.HTML),t.ackSelfClosing=!0}function mj(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._appendElement(t,ge.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function hj(e,t){t.tagName=ae.IMG,t.tagID=E.IMG,S_(e,t)}function pj(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 gj(e,t){e.openElements.hasInButtonScope(E.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Xt.RAWTEXT)}function bj(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Xt.RAWTEXT)}function pE(e,t){e._switchToTextParsing(t,Xt.RAWTEXT)}function xj(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 Ej(e,t){e.openElements.currentTagId===E.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML)}function yj(e,t){e.openElements.hasInScope(E.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,ge.HTML)}function Tj(e,t){e.openElements.hasInScope(E.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(E.RTC),e._insertElement(t,ge.HTML)}function _j(e,t){e._reconstructActiveFormattingElements(),y_(t),f0(t),t.selfClosing?e._appendElement(t,ge.MATHML):e._insertElement(t,ge.MATHML),t.ackSelfClosing=!0}function Nj(e,t){e._reconstructActiveFormattingElements(),T_(t),f0(t),t.selfClosing?e._appendElement(t,ge.SVG):e._insertElement(t,ge.SVG),t.ackSelfClosing=!0}function gE(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,ge.HTML)}function wn(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:{lj(e,t);break}case E.A:{ij(e,t);break}case E.H1:case E.H2:case E.H3:case E.H4:case E.H5:case E.H6:{ej(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:{J8(e,t);break}case E.LI:case E.DD:case E.DT:{aj(e,t);break}case E.BR:case E.IMG:case E.WBR:case E.AREA:case E.EMBED:case E.KEYGEN:{S_(e,t);break}case E.HR:{mj(e,t);break}case E.RB:case E.RTC:{yj(e,t);break}case E.RT:case E.RP:{Tj(e,t);break}case E.PRE:case E.LISTING:{tj(e,t);break}case E.XMP:{gj(e,t);break}case E.SVG:{Nj(e,t);break}case E.HTML:{X8(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:{Ba(e,t);break}case E.BODY:{W8(e,t);break}case E.FORM:{nj(e,t);break}case E.NOBR:{oj(e,t);break}case E.MATH:{_j(e,t);break}case E.TABLE:{cj(e,t);break}case E.INPUT:{dj(e,t);break}case E.PARAM:case E.TRACK:case E.SOURCE:{fj(e,t);break}case E.IMAGE:{hj(e,t);break}case E.BUTTON:{sj(e,t);break}case E.APPLET:case E.OBJECT:case E.MARQUEE:{uj(e,t);break}case E.IFRAME:{bj(e,t);break}case E.SELECT:{xj(e,t);break}case E.OPTION:case E.OPTGROUP:{Ej(e,t);break}case E.NOEMBED:case E.NOFRAMES:{pE(e,t);break}case E.FRAMESET:{Z8(e,t);break}case E.TEXTAREA:{pj(e,t);break}case E.NOSCRIPT:{e.options.scriptingEnabled?pE(e,t):gE(e,t);break}case E.PLAINTEXT:{rj(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:gE(e,t)}}function vj(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 Sj(e,t){e.openElements.hasInScope(E.BODY)&&(e.insertionMode=z.AFTER_BODY,j_(e,t))}function Aj(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a))}function Cj(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 wj(e){e.openElements.hasInButtonScope(E.P)||e._insertFakeElement(ae.P,E.P),e._closePElement()}function kj(e){e.openElements.hasInListItemScope(E.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(E.LI),e.openElements.popUntilTagNamePopped(E.LI))}function Rj(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTagsWithExclusion(a),e.openElements.popUntilTagNamePopped(a))}function Oj(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function Ij(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a),e.activeFormattingElements.clearToLastMarker())}function Mj(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(ae.BR,E.BR),e.openElements.pop(),e.framesetOk=!1}function C_(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 td(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:{m0(e,t);break}case E.P:{wj(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:{Aj(e,t);break}case E.LI:{kj(e);break}case E.DD:case E.DT:{Rj(e,t);break}case E.H1:case E.H2:case E.H3:case E.H4:case E.H5:case E.H6:{Oj(e);break}case E.BR:{Mj(e);break}case E.BODY:{vj(e,t);break}case E.HTML:{Sj(e,t);break}case E.FORM:{Cj(e);break}case E.APPLET:case E.OBJECT:case E.MARQUEE:{Ij(e,t);break}case E.TEMPLATE:{Vs(e,t);break}default:C_(e,t)}}function w_(e,t){e.tmplInsertionModeStack.length>0?L_(e,t):h0(e,t)}function Dj(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 Lj(e,t){e._err(t,ce.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Vm(e,t){if(e.openElements.currentTagId!==void 0&&__.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:{R_(e,t);break}case tt.WHITESPACE_CHARACTER:{k_(e,t);break}}else Oo(e,t)}function jj(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_CAPTION}function Bj(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_COLUMN_GROUP}function Pj(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(ae.COLGROUP,E.COLGROUP),e.insertionMode=z.IN_COLUMN_GROUP,p0(e,t)}function Uj(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,ge.HTML),e.insertionMode=z.IN_TABLE_BODY}function Hj(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(ae.TBODY,E.TBODY),e.insertionMode=z.IN_TABLE_BODY,nd(e,t)}function Fj(e,t){e.openElements.hasInTableScope(E.TABLE)&&(e.openElements.popUntilTagNamePopped(E.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function zj(e,t){A_(t)?e._appendElement(t,ge.HTML):Oo(e,t),t.ackSelfClosing=!0}function qj(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,ge.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function qi(e,t){switch(t.tagID){case E.TD:case E.TH:case E.TR:{Hj(e,t);break}case E.STYLE:case E.SCRIPT:case E.TEMPLATE:{Ba(e,t);break}case E.COL:{Pj(e,t);break}case E.FORM:{qj(e,t);break}case E.TABLE:{Fj(e,t);break}case E.TBODY:case E.TFOOT:case E.THEAD:{Uj(e,t);break}case E.INPUT:{zj(e,t);break}case E.CAPTION:{jj(e,t);break}case E.COLGROUP:{Bj(e,t);break}default:Oo(e,t)}}function To(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:Oo(e,t)}}function Oo(e,t){const a=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,ed(e,t),e.fosterParentingEnabled=a}function k_(e,t){e.pendingCharacterTokens.push(t)}function R_(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function eo(e,t){let a=0;if(e.hasNonWhitespacePendingCharacterToken)for(;a<e.pendingCharacterTokens.length;a++)Oo(e,e.pendingCharacterTokens[a]);else for(;a<e.pendingCharacterTokens.length;a++)e._insertCharacters(e.pendingCharacterTokens[a]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const O_=new Set([E.CAPTION,E.COL,E.COLGROUP,E.TBODY,E.TD,E.TFOOT,E.TH,E.THEAD,E.TR]);function $j(e,t){const a=t.tagID;O_.has(a)?e.openElements.hasInTableScope(E.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(E.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=z.IN_TABLE,qi(e,t)):wn(e,t)}function Yj(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&&To(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:td(e,t)}}function p0(e,t){switch(t.tagID){case E.HTML:{wn(e,t);break}case E.COL:{e._appendElement(t,ge.HTML),t.ackSelfClosing=!0;break}case E.TEMPLATE:{Ba(e,t);break}default:Dc(e,t)}}function Gj(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:Dc(e,t)}}function Dc(e,t){e.openElements.currentTagId===E.COLGROUP&&(e.openElements.pop(),e.insertionMode=z.IN_TABLE,e._processToken(t))}function nd(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(ae.TR,E.TR),e.insertionMode=z.IN_ROW,ad(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,qi(e,t));break}default:qi(e,t)}}function Sh(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,To(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:To(e,t)}}function ad(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,nd(e,t));break}default:qi(e,t)}}function I_(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,Sh(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,Sh(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:To(e,t)}}function Kj(e,t){const a=t.tagID;O_.has(a)?(e.openElements.hasInTableScope(E.TD)||e.openElements.hasInTableScope(E.TH))&&(e._closeTableCell(),ad(e,t)):wn(e,t)}function Vj(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(),I_(e,t));break}case E.BODY:case E.CAPTION:case E.COL:case E.COLGROUP:case E.HTML:break;default:td(e,t)}}function M_(e,t){switch(t.tagID){case E.HTML:{wn(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:{Ba(e,t);break}}}function D_(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 Qj(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)):M_(e,t)}function Xj(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)):D_(e,t)}function Wj(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:{Ba(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,qi(e,t);break}case E.COL:{e.tmplInsertionModeStack[0]=z.IN_COLUMN_GROUP,e.insertionMode=z.IN_COLUMN_GROUP,p0(e,t);break}case E.TR:{e.tmplInsertionModeStack[0]=z.IN_TABLE_BODY,e.insertionMode=z.IN_TABLE_BODY,nd(e,t);break}case E.TD:case E.TH:{e.tmplInsertionModeStack[0]=z.IN_ROW,e.insertionMode=z.IN_ROW,ad(e,t);break}default:e.tmplInsertionModeStack[0]=z.IN_BODY,e.insertionMode=z.IN_BODY,wn(e,t)}}function Zj(e,t){t.tagID===E.TEMPLATE&&Vs(e,t)}function L_(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(E.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):h0(e,t)}function Jj(e,t){t.tagID===E.HTML?wn(e,t):Lc(e,t)}function j_(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 Lc(e,t)}function Lc(e,t){e.insertionMode=z.IN_BODY,ed(e,t)}function e9(e,t){switch(t.tagID){case E.HTML:{wn(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:{Ba(e,t);break}}}function t9(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 n9(e,t){switch(t.tagID){case E.HTML:{wn(e,t);break}case E.NOFRAMES:{Ba(e,t);break}}}function a9(e,t){t.tagID===E.HTML&&(e.insertionMode=z.AFTER_AFTER_FRAMESET)}function r9(e,t){t.tagID===E.HTML?wn(e,t):mc(e,t)}function mc(e,t){e.insertionMode=z.IN_BODY,ed(e,t)}function s9(e,t){switch(t.tagID){case E.HTML:{wn(e,t);break}case E.NOFRAMES:{Ba(e,t);break}}}function i9(e,t){t.chars=Pt,e._insertCharacters(t)}function l9(e,t){e._insertCharacters(t),e.framesetOk=!1}function B_(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 o9(e,t){if(N8(t))B_(e),e._startTagOutsideForeignContent(t);else{const a=e._getAdjustedCurrentElement(),s=e.treeAdapter.getNamespaceURI(a);s===ge.MATHML?y_(t):s===ge.SVG&&(v8(t),T_(t)),f0(t),t.selfClosing?e._appendElement(t,s):e._insertElement(t,s),t.ackSelfClosing=!0}}function u9(e,t){if(t.tagID===E.P||t.tagID===E.BR){B_(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}}}ae.AREA,ae.BASE,ae.BASEFONT,ae.BGSOUND,ae.BR,ae.COL,ae.EMBED,ae.FRAME,ae.HR,ae.IMG,ae.INPUT,ae.KEYGEN,ae.LINK,ae.META,ae.PARAM,ae.SOURCE,ae.TRACK,ae.WBR;const c9=/<(\/?)(iframe|noembed|noframes|plaintext|script|style|textarea|title|xmp)(?=[\t\n\f\r />])/gi,d9=new Set(["mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression","mdxjsEsm"]),bE={sourceCodeLocationInfo:!0,scriptingEnabled:!1};function P_(e,t){const a=T9(e),s=dT("type",{handlers:{root:f9,element:m9,text:h9,comment:H_,doctype:p9,raw:b9},unknown:x9}),l={parser:a?new hE(bE):hE.getFragmentParser(void 0,bE),handle(f){s(f,l)},stitches:!1,options:t||{}};s(e,l),Wi(l,Ja());const u=a?l.parser.document:l.parser.getFragment(),d=_L(u,{file:l.options.file});return l.stitches&&wo(d,"comment",function(f,m,h){const b=f;if(b.value.stitch&&h&&m!==void 0){const g=h.children;return g[m]=b.value.stitch,m}}),d.type==="root"&&d.children.length===1&&d.children[0].type===e.type?d.children[0]:d}function U_(e,t){let a=-1;if(e)for(;++a<e.length;)t.handle(e[a])}function f9(e,t){U_(e.children,t)}function m9(e,t){E9(e,t),U_(e.children,t),y9(e,t)}function h9(e,t){t.parser.tokenizer.state>4&&(t.parser.tokenizer.state=0);const a={type:tt.CHARACTER,chars:e.value,location:Io(e)};Wi(t,Ja(e)),t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken)}function p9(e,t){const a={type:tt.DOCTYPE,name:"html",forceQuirks:!1,publicId:"",systemId:"",location:Io(e)};Wi(t,Ja(e)),t.parser.currentToken=a,t.parser._processToken(t.parser.currentToken)}function g9(e,t){t.stitches=!0;const a=_9(e);if("children"in e&&"children"in a){const s=P_({type:"root",children:e.children},t.options);a.children=s.children}H_({type:"comment",value:{stitch:a}},t)}function H_(e,t){const a=e.value,s={type:tt.COMMENT,data:a,location:Io(e)};Wi(t,Ja(e)),t.parser.currentToken=s,t.parser._processToken(t.parser.currentToken)}function b9(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,F_(t,Ja(e)),t.parser.tokenizer.write(t.options.tagfilter?e.value.replace(c9,"<$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 x9(e,t){const a=e;if(t.options.passThrough&&t.options.passThrough.includes(a.type))g9(a,t);else{let s="";throw d9.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 Wi(e,t){F_(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 F_(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 E9(e,t){const a=e.tagName.toLowerCase();if(t.parser.tokenizer.state===Xt.PLAINTEXT)return;Wi(t,Ja(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=CL({...e,children:[]},{space:l===Ps.svg?"svg":"html"}),d={type:tt.START_TAG,tagName:a,tagID:Xi(a),selfClosing:!1,ackSelfClosing:!1,attrs:"attrs"in u?u.attrs:[],location:Io(e)};t.parser.currentToken=d,t.parser._processToken(t.parser.currentToken),t.parser.tokenizer.lastStartTagName=a}function y9(e,t){const a=e.tagName.toLowerCase();if(!t.parser.tokenizer.inForeignNode&&LL.includes(a)||t.parser.tokenizer.state===Xt.PLAINTEXT)return;Wi(t,Qc(e));const s={type:tt.END_TAG,tagName:a,tagID:Xi(a),selfClosing:!1,ackSelfClosing:!1,attrs:[],location:Io(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 T9(e){const t=e.type==="root"?e.children[0]:e;return!!(t&&(t.type==="doctype"||t.type==="element"&&t.tagName.toLowerCase()==="html"))}function Io(e){const t=Ja(e)||{line:void 0,column:void 0,offset:void 0},a=Qc(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 _9(e){return"children"in e?Fi({...e,children:[]}):Fi(e)}function fo(e){return function(t,a){return P_(t,{...e,file:a})}}const xE=[{key:"open",label:"开放"},{key:"closed",label:"已关闭"},{key:"all",label:"全部"}];function N9(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 EE({onDone:e}){const[t,a]=v.useState(""),[s,l]=v.useState(""),[u,d]=v.useState(!1),f=Ge(b=>b.createIssue),m=async()=>{!t.trim()||u||(d(!0),await f(t.trim(),s.trim()||void 0),d(!1),e())},h=b=>{(b.metaKey||b.ctrlKey)&&b.key==="Enter"&&(b.preventDefault(),m())};return o.jsxs("div",{className:"border-b border-line px-3 py-3",children:[o.jsx("input",{type:"text",value:t,onChange:b=>a(b.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:b=>l(b.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 v9({repoId:e,issueNumber:t,onPublished:a}){const s=Aa(),l=He(ja),[u,d]=v.useState(""),[f,m]=v.useState("idle"),[h,b]=v.useState(""),[g,y]=v.useState(null),[T,N]=v.useState(!1),S=v.useRef(null),w=v.useCallback(()=>{S.current&&(clearInterval(S.current),S.current=null)},[]);v.useEffect(()=>()=>w(),[w]),v.useEffect(()=>{let L=!1;return Sx(e,t).then(F=>{!L&&F.body&&(b(F.body),m("preview"))}).catch(()=>{}),()=>{L=!0}},[e,t]);const C=async()=>{if(!(!u.trim()||T)){N(!0);try{const L=await vx(e,t,u.trim());a(L),d(""),Ft.getState().addToast("评论已发布","success")}catch(L){Ft.getState().addToast(L instanceof Error?L.message:"发布失败","error")}finally{N(!1)}}},A=async()=>{if(!(!u.trim()||f==="polishing")){m("polishing");try{const{sessionId:L}=await FC(e,t,u.trim());y(L),S.current=setInterval(async()=>{try{if((await dy(e,L)).type==="idle"){w();const Z=await Sx(e,t);b(Z.body),m("preview")}}catch{w(),m("idle"),Ft.getState().addToast("润色状态检查失败","error")}},2e3)}catch(L){m("idle"),Ft.getState().addToast(L instanceof Error?L.message:"润色启动失败","error")}}},O=async()=>{if(!(!h.trim()||T)){N(!0);try{const L=await vx(e,t,h.trim());a(L),d(""),b(""),y(null),m("idle"),Ft.getState().addToast("评论已发布","success")}catch(L){Ft.getState().addToast(L instanceof Error?L.message:"发布失败","error")}finally{N(!1)}}},U=()=>{w(),b(""),y(null),m("idle")},Q=()=>{!g||!l||(Ie.setState({activeSessionId:g}),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(gm,{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=>b(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 O(),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(Ec,{className:"h-3.5 w-3.5"}),"发布评论"]}),o.jsxs("button",{type:"button",onClick:()=>void A(),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(gm,{className:"h-3.5 w-3.5"}),"重新润色"]}),o.jsx("button",{type:"button",onClick:Q,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:U,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(Ec,{className:"h-3.5 w-3.5"}),T?"发送中...":"直接发送"]}),o.jsxs("button",{type:"button",disabled:!u.trim()||f==="polishing",onClick:()=>void A(),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(gm,{className:"h-3.5 w-3.5"}),f==="polishing"?"润色中...":"AI 润色"]})]})]})}function yE({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(Hh,{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 S9({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(Hh,{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:N9(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(a3,{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 A9({issue:e,milestone:t,onBack:a,onClose:s,onToggleSidebar:l}){var V;const u=Aa(),d=He(X=>X.activeRepoId),f=He(ja),[m,h]=v.useState([]),[b,g]=v.useState(!1),[y,T]=v.useState([]),[N,S]=v.useState(0),[w,C]=v.useState(!1),[A,O]=v.useState(!1),[U,Q]=v.useState("issue"),L=Ge(X=>X.updateIssueState);v.useEffect(()=>{d&&(g(!0),HC(d,e.number).then(h).catch(()=>h([])).finally(()=>g(!1)))},[d,e.number]),v.useEffect(()=>{d&&_x(d,e.number).then(T).catch(()=>T([]))},[d,e.number]),v.useEffect(()=>{Q("issue"),S(0)},[e.id]);const F=y[N]??y[0],Z=async X=>{if(!(w||!d||!F)){C(!0);try{await DC(d,e.number,F.number,X),X&&await L(e.number,"closed");const te=await _x(d,e.number);T(te),N>=te.length&&S(Math.max(0,te.length-1)),Ft.getState().addToast(`PR #${F.number} 合入成功`,"success")}catch(te){let ee="合入失败";if(te instanceof Xa)try{ee=JSON.parse(te.message).error??ee}catch{ee=te.message}Ft.getState().addToast(ee,"error")}finally{C(!1)}}},ne=()=>{if(!F)return;const X=`请解决 PR #${F.number} 的合并冲突: ${F.title}`;Ge.getState().setSelectedIssue(e.id),Ge.getState().setPendingDraft(X),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`)},K=X=>{const te=new Date(X);return te.toLocaleDateString("zh-CN",{month:"short",day:"numeric"})+" "+te.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(Ph,{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]}),(V=e.labels)==null?void 0:V.map(X=>o.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{backgroundColor:`#${X.color}20`,color:`#${X.color}`},children:X.name},X.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(Hh,{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(X=>o.jsx("img",{src:X.avatar_url,alt:X.login,title:X.login,className:"h-4 w-4 rounded-full ring-1 ring-surface"},X.login))}),o.jsx("span",{className:"text-fg-4",children:e.assignees.map(X=>X.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(bc,{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($s,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"匹配子任务"})]}),o.jsx("button",{type:"button",disabled:A,onClick:async()=>{O(!0),await L(e.number,e.state==="open"?"closed":"open"),O(!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(ho,{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(qc,{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(ty,{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:()=>Q("issue"),className:oe("flex items-center gap-1.5 border-b-2 px-4 py-2.5 text-xs font-medium transition-colors",U==="issue"?"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"}),"Issue"]}),o.jsxs("button",{type:"button",onClick:()=>Q("pr"),className:oe("flex items-center gap-1.5 border-b-2 px-4 py-2.5 text-xs font-medium transition-colors",U==="pr"?"border-blue-500 text-fg":"border-transparent text-fg-4 hover:text-fg-2"),children:[o.jsx(po,{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]",U==="pr"?"bg-blue-500/10 text-blue-500":"bg-elevated text-fg-5"),children:y.length}),y.some(X=>X.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(An,{className:"inline h-3 w-3 -mt-px"})," Conflict"]})]})]}),U==="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:[fo],children:e.body})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"该 Issue 没有描述内容"}),b?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(X=>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:X.user.avatar_url,alt:X.user.login,className:"h-5 w-5 rounded-full"}),o.jsx("span",{className:"text-xs font-semibold text-fg-2",children:X.user.login}),o.jsx("span",{className:"text-[10px] text-fg-6",children:K(X.created_at)})]}),o.jsx("div",{className:"markdown-body mt-2 text-sm leading-relaxed text-fg-3",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[fo],children:X.body})})]},X.id))})]}),d&&o.jsx(v9,{repoId:d,issueNumber:e.number,onPublished:X=>h(te=>[...te,X])},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((X,te)=>o.jsxs("button",{type:"button",onClick:()=>S(te),className:oe("flex items-center gap-1.5 border-b-2 px-2.5 py-2.5 text-xs font-medium transition-colors",te===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:["#",X.number]}),o.jsx("span",{className:"max-w-[140px] truncate",children:X.title})]},X.number)),o.jsxs("div",{className:oe("flex items-center gap-2",y.length>1&&"ml-auto"),children:[(F==null?void 0:F.html_url)&&o.jsxs("a",{href:F.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(bc,{className:"h-3 w-3"}),o.jsx("span",{className:"hidden sm:inline",children:"查看"})]}),(F==null?void 0:F.mergeable)===!1&&o.jsxs("button",{type:"button",onClick:ne,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(z3,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"解冲突"})]}),o.jsxs("button",{type:"button",disabled:w||(F==null?void 0:F.mergeable)===!1,onClick:()=>void Z(!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(xc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"合入"})]}),o.jsxs("button",{type:"button",disabled:w||(F==null?void 0:F.mergeable)===!1,onClick:()=>void Z(!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(xc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"合入并关闭"})]})]})]}),F&&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",F.state==="open"?"bg-emerald-500/15 text-emerald-400":"bg-purple-500/15 text-purple-400"),children:["#",F.number," ",F.state]}),F.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:F.title})]}),F.body?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[fo],children:F.body})}):o.jsx("p",{className:"py-6 text-center font-mono text-xs text-fg-5",children:"该 PR 没有描述内容"})]})})]})]})}function z_({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(z_,{issue:f,childrenMap:t,currentId:a,onSelect:s,depth:l+1},f.id))]})]})}function C9(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 w9(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 TE({session:e,onSelect:t}){var s,l;const a=w9(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 q_({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(KS,{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(TE,{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(TE,{session:d,onSelect:()=>t(d.id)},d.id))})]})]})})]})}function k9({rootIssue:e,childrenMap:t,currentId:a,onSelect:s,sessions:l,onSessionSelect:u}){const{total:d,closed:f}=C9(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(p3,{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(z_,{issue:e,childrenMap:t,currentId:a,onSelect:s,depth:0})})]}),o.jsx(q_,{sessions:l,onSelect:u})]})}function R9({sessions:e,onSessionSelect:t}){return o.jsx("div",{className:"flex w-full flex-col",children:o.jsx(q_,{sessions:e,onSelect:t})})}function O9(){const[e,t]=v.useState("open"),[a,s]=v.useState("stray"),[l,u]=v.useState(!1),[d,f]=v.useState(""),[m,h]=v.useState(null),[b,g]=v.useState(null),[y,T]=v.useState(!1),[N,S]=v.useState(!1),[w,C]=v.useState(null),[A,O]=v.useState(null),[U,Q]=v.useState(null),[L,F]=VE(),Z=Ge(H=>H.issues),ne=Ge(H=>H.syncing),j=Ge(H=>H.syncIssues),K=Ge(H=>H.tags),V=Ge(H=>H.tagFilterMode),X=Ge(H=>H.cycleTagFilter),te=Ge(H=>H.clearTagFilter),ee=Ge(H=>H.loadTags),q=Ge(H=>H.milestones),k=Ge(H=>H.selectedMilestoneId),J=Ge(H=>H.setMilestoneFilter),Te=Ge(H=>H.loadMilestones),B=He(H=>H.activeRepoId),I=Ie(H=>H.sessions);v.useEffect(()=>{const H=L.get("issueId");H&&Z.some(Ae=>Ae.id===H)&&(h(H),F({},{replace:!0}))},[L,F,Z]),v.useEffect(()=>{B&&(ee(),Te())},[B,ee,Te]);const re=new Map;for(const H of I)H.issueId&&!H.parentID&&re.set(H.issueId,(re.get(H.issueId)??0)+1);const D=new Set(Z.filter(H=>H.parentId).map(H=>H.parentId)),_e=new Map;for(const H of Z)if(H.parentId){const Ae=_e.get(H.parentId);Ae?Ae.push(H):_e.set(H.parentId,[H])}function ke(H){return H.parentId?"task":D.has(H.id)?"epic":"stray"}const Re=new Map(q.map(H=>[H.id,H])),$e=e==="all"?Z:Z.filter(H=>H.state===e),dt=a==="all"?$e:$e.filter(H=>ke(H)===a),ut=V.size===0?dt:dt.filter(H=>{var ft;const Ae=new Set((H.labels??[]).map(ln=>ln.name));for(const[ln,Wt]of V){const Ot=(ft=K.find(cn=>cn.id===ln))==null?void 0:ft.name;if(Ot&&(Wt==="include"&&!Ae.has(Ot)||Wt==="exclude"&&Ae.has(Ot)))return!1}return!0}),zt=d.trim().toLowerCase(),Tn=zt?ut.filter(H=>`#${H.number} ${H.title}`.toLowerCase().includes(zt)):ut,da=k?Tn.filter(H=>H.milestoneId===k):Tn,Ca=A?da.filter(H=>H.authorLogin===A):da,un=U?Ca.filter(H=>(H.assignees??[]).some(Ae=>Ae.login===U)):Ca,Xn=(()=>{const H=new Map;for(const Ae of Z)Ae.authorLogin&&!H.has(Ae.authorLogin)&&H.set(Ae.authorLogin,{login:Ae.authorLogin,avatar:Ae.authorAvatar});return[...H.values()]})(),Je=(()=>{const H=new Map;for(const Ae of Z)for(const ft of Ae.assignees??[])H.has(ft.login)||H.set(ft.login,{login:ft.login,avatar:ft.avatar_url});return[...H.values()]})(),jn=Z.filter(H=>H.state==="open").length,kn=Z.filter(H=>H.state==="closed").length,fa=$e.filter(H=>ke(H)==="epic").length,wa=$e.filter(H=>ke(H)==="task").length,tr=$e.filter(H=>ke(H)==="stray").length,Pa=Z.find(H=>H.id===m)??null,wr=Aa(),_t=new Set;if(m&&(_t.add(m),b)){_t.add(b);const H=[..._e.get(b)??[]];for(let Ae=0;Ae<H.length;Ae++){_t.add(H[Ae].id);const ft=_e.get(H[Ae].id);ft&&H.push(...ft)}}const nr=I.filter(H=>H.issueId&&_t.has(H.issueId)&&!H.parentID),de=He(ja),ye=H=>{Ie.setState({activeSessionId:H}),wr(`/${encodeURIComponent(de)}/run`)},Pe=i_({onSwipeRight:()=>S(!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"}),B&&o.jsx("div",{className:"flex items-center gap-1",children:o.jsx("button",{type:"button",onClick:()=>void j(),disabled:ne,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",ne&&"animate-spin")})})})]}),l&&o.jsx(EE,{onDone:()=>u(!1)}),o.jsx("div",{className:"flex border-b border-line",children:xE.map(({key:H,label:Ae})=>{const ft=H==="open"?jn:H==="closed"?kn:Z.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:[Ae,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 flex-wrap items-center gap-x-2 gap-y-2 border-b border-line px-4 py-2.5",children:[o.jsx("span",{className:"shrink-0 text-sm font-semibold text-fg md:order-1",children:"Issues"}),B&&o.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1 md:order-last md:ml-0",children:[o.jsx("button",{type:"button",onClick:()=>void j(),disabled:ne,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",ne&&"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(Wa,{className:"h-3.5 w-3.5"})})]}),o.jsx("div",{className:"w-full md:order-2 md:w-auto",children:o.jsx("div",{className:"flex shrink-0 items-center rounded-lg bg-elevated/60 p-0.5",children:xE.map(({key:H,label:Ae})=>{const ft=H==="open"?jn:H==="closed"?kn:Z.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:[Ae,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:"w-full md:order-5 md:w-auto md:min-w-0 md:flex-1 md: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"})})]})}),o.jsx("div",{className:"hidden md:order-3 md:mx-1 md:block md:h-4 md:w-px md:shrink-0 md:bg-line"}),o.jsxs("div",{className:"flex w-full gap-2 overflow-x-auto scrollbar-none md:order-4 md:w-auto md:overflow-visible",children:[o.jsxs("button",{type:"button",onClick:()=>C(w==="type"?null:"type"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",w==="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(Ia,{className:oe("h-3 w-3 transition-transform",w==="type"&&"rotate-180")})]}),o.jsxs("button",{type:"button",onClick:()=>C(w==="tag"?null:"tag"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",w==="tag"?"bg-elevated text-fg":V.size>0?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["标签",V.size>0&&o.jsx("span",{className:"rounded-full bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-400",children:V.size}),o.jsx(Ia,{className:oe("h-3 w-3 transition-transform",w==="tag"&&"rotate-180")})]}),o.jsxs("button",{type:"button",onClick:()=>C(w==="milestone"?null:"milestone"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",w==="milestone"?"bg-elevated text-fg":k?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["Milestone",k&&(()=>{const H=q.find(Ae=>Ae.id===k);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(Ia,{className:oe("h-3 w-3 transition-transform",w==="milestone"&&"rotate-180")})]}),o.jsxs("button",{type:"button",onClick:()=>C(w==="author"?null:"author"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",w==="author"?"bg-elevated text-fg":A?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["Author",A&&o.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-400",children:A}),o.jsx(Ia,{className:oe("h-3 w-3 transition-transform",w==="author"&&"rotate-180")})]}),o.jsxs("button",{type:"button",onClick:()=>C(w==="assignee"?null:"assignee"),className:oe("flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",w==="assignee"?"bg-elevated text-fg":U?"text-fg-2":"text-fg-4 hover:bg-elevated/60 hover:text-fg-2"),children:["Assignee",U&&o.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-400",children:U}),o.jsx(Ia,{className:oe("h-3 w-3 transition-transform",w==="assignee"&&"rotate-180")})]})]})]}),w==="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 Ae=H==="epic"?"Epic":H==="stray"?"游离":H==="task"?"任务":"全部",ft=H==="epic"?fa:H==="stray"?tr:H==="task"?wa:$e.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:[Ae,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)})}),w==="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:K.length===0?o.jsx("span",{className:"text-xs text-fg-5",children:"暂无标签"}):o.jsxs(o.Fragment,{children:[K.map(H=>{const Ae=V.get(H.id);return o.jsxs("button",{type:"button",onClick:()=>X(H.id),className:oe("shrink-0 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",Ae==="include"?"ring-1 ring-current shadow-sm":Ae==="exclude"?"opacity-90 line-through decoration-2":"opacity-50 hover:opacity-80"),style:Ae==="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:Ae==="include"?`inset 0 0 0 1px color-mix(in srgb, #${H.color} 50%, transparent)`:void 0},children:[Ae==="exclude"&&o.jsx("span",{className:"mr-1 text-[10px]",children:"✕"}),H.name]},H.id)}),V.size>0&&o.jsx("button",{type:"button",onClick:te,className:"shrink-0 rounded-md px-2 py-1 text-[10px] text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3",children:"清除"})]})}),w==="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 Ae=k===H.id;return o.jsxs("button",{type:"button",onClick:()=>J(Ae?null:H.id),className:oe("shrink-0 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",Ae?"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)}),k&&o.jsx("button",{type:"button",onClick:()=>J(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:"清除"})]})}),w==="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:()=>O(A===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",A===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)),A&&o.jsx("button",{type:"button",onClick:()=>O(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:"清除"})]})}),w==="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:()=>Q(U===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",U===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)),U&&o.jsx("button",{type:"button",onClick:()=>Q(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(EE,{onDone:()=>u(!1)})]}),o.jsx("div",{className:oe("flex-1 overflow-y-auto",m?"px-2 py-2":"px-3 py-3"),children:B?un.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:Z.length===0?"点击 ↻ 同步 Issues":"无匹配 Issue"}):o.jsx("ul",{className:oe(m?"space-y-0.5":"space-y-1"),children:un.map(H=>m?o.jsx(yE,{issue:H,sessionCount:re.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),g(ke(H)==="epic"?H.id:null)}},H.id):o.jsx(S9,{issue:H,sessionCount:re.get(H.id)??0,isEpic:ke(H)==="epic",milestone:H.milestoneId?Re.get(H.milestoneId):void 0,onSelect:()=>{h(H.id),g(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(Eh,{side:"left",open:N,onClose:()=>S(!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(yE,{issue:H,sessionCount:re.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),g(ke(H)==="epic"?H.id:null),S(!1)}},H.id))})})]})}),m&&o.jsx("div",{className:"relative flex min-w-0 flex-1 flex-col bg-term",children:Pa?o.jsxs(o.Fragment,{children:[o.jsx(A9,{issue:Pa,milestone:Pa.milestoneId?Re.get(Pa.milestoneId):void 0,onBack:()=>{h(null),g(null),T(!1)},onClose:()=>{h(null),g(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:b?"子任务树 & 运行记录":"运行记录"}),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:b?(()=>{const H=Z.find(Ae=>Ae.id===b);return H?o.jsx(k9,{rootIssue:H,childrenMap:_e,currentId:m,onSelect:Ae=>{h(Ae),T(!1)},sessions:nr,onSessionSelect:ye}):null})():o.jsx(R9,{sessions:nr,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 _E=[{key:"open",label:"开放"},{key:"merged",label:"已合并"},{key:"closed",label:"已关闭"},{key:"all",label:"全部"}];function $_(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 I9(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 M9({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 D9({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(An,{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:$_(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 L9({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(Fc,{className:"ml-auto h-3.5 w-3.5 shrink-0 text-emerald-400"})]})})})})}function j9({pr:e,onBack:t,onClose:a,onEnterMatch:s}){var O;const l=He(U=>U.activeRepoId),u=He(ja),[d,f]=v.useState(!1),[m,h]=v.useState([]),[b,g]=v.useState(!1),[y,T]=v.useState([]),N=Aa(),S=Vn(U=>U.unlinkIssue);v.useEffect(()=>{l&&(g(!0),UC(l,e.number).then(h).catch(()=>h([])).finally(()=>g(!1)))},[l,e.number]),v.useEffect(()=>{l&&by(l,e.number).then(T).catch(()=>T([]))},[l,e.number]);const w=async U=>{if(!(d||!l)){f(!0);try{if(await jC(l,e.number),U&&y.length>0){const Q=y.filter(L=>L.state==="open");await Promise.all(Q.map(L=>gy(l,L.number,{state:"closed"}))),T(L=>L.map(F=>F.state==="open"?{...F,state:"closed"}:F)),Ge.getState().loadIssues(),Ft.getState().addToast(`PR #${e.number} 合入成功,已关闭 ${Q.length} 个 Issue`,"success")}else Ft.getState().addToast(`PR #${e.number} 合入成功`,"success");Vn.getState().loadPulls()}catch(Q){let L="合入失败";if(Q instanceof Xa)try{L=JSON.parse(Q.message).error??L}catch{L=Q.message}Ft.getState().addToast(L,"error")}finally{f(!1)}}},C=async U=>{await S(e.number,U)&&T(L=>L.filter(F=>F.number!==U))},A=U=>{const Q=new Date(U);return Q.toLocaleDateString("zh-CN",{month:"short",day:"numeric"})+" "+Q.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(Ph,{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",I9(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"}),(O=e.labels)==null?void 0:O.map(U=>o.jsx("span",{className:"shrink-0 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-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(po,{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:["合并于 ",$_(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(bc,{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(Fc,{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 w(!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(xc,{className:"h-3.5 w-3.5"}),o.jsx("span",{className:"hidden sm:inline",children:"合入"})]}),y.some(U=>U.state==="open")&&o.jsxs("button",{type:"button",disabled:d||e.mergeable==="false",onClick:()=>void w(!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(xc,{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(ho,{className:"h-3.5 w-3.5"}),"关联 Issues (",y.length,")"]}),o.jsx("div",{className:"space-y-1.5",children:y.map(U=>o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:()=>N(`/${encodeURIComponent(u)}/issues?issueId=${encodeURIComponent(U.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",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 flex-1 truncate text-left text-sm text-fg-2",children:U.title})]}),o.jsx("button",{type:"button",onClick:()=>void C(U.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"})})]},U.id))})]}),e.body?o.jsx("div",{className:"markdown-body leading-relaxed",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[fo],children:e.body})}):o.jsx("p",{className:"py-10 text-center font-mono text-xs text-fg-5",children:"该 PR 没有描述内容"}),b?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(U=>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:U.user.avatar_url,alt:U.user.login,className:"h-5 w-5 rounded-full"}),o.jsx("span",{className:"text-xs font-semibold text-fg-2",children:U.user.login}),o.jsx("span",{className:"text-[10px] text-fg-6",children:A(U.created_at)})]}),o.jsx("div",{className:"markdown-body mt-2 text-sm leading-relaxed text-fg-3",children:o.jsx(us,{remarkPlugins:[cs],rehypePlugins:[fo],children:U.body})})]},U.id))})]})]})})]})}function B9(){const[e,t]=v.useState("open"),[a,s]=v.useState(""),[l,u]=v.useState(null),[d,f]=v.useState(""),[m,h]=VE(),b=Vn(k=>k.pulls),g=Vn(k=>k.syncing),y=Vn(k=>k.syncPulls),T=Vn(k=>k.matchingPrId),N=Vn(k=>k.enterMatchMode),S=Vn(k=>k.exitMatchMode),w=Vn(k=>k.linkIssue),C=He(k=>k.activeRepoId),A=Ge(k=>k.issues);v.useEffect(()=>{const k=m.get("prId");k&&b.some(J=>J.id===k)&&(u(k),h({},{replace:!0}))},[m,h,b]);const O=T?b.find(k=>k.id===T)??null:null,[U,Q]=v.useState(new Set);v.useEffect(()=>{if(!C||!O){Q(new Set);return}by(C,O.number).then(k=>Q(new Set(k.map(J=>J.id)))).catch(()=>Q(new Set))},[C,O]);const L=async k=>{if(!O)return;U.has(k.id)?await Vn.getState().unlinkIssue(O.number,k.number)&&Q(B=>{const I=new Set(B);return I.delete(k.id),I}):await w(O.number,k.number)&&Q(B=>new Set(B).add(k.id))},F=b.filter(k=>k.state==="open").length,Z=b.filter(k=>k.state==="merged").length,ne=b.filter(k=>k.state==="closed").length,j=e==="all"?b:b.filter(k=>k.state===e),K=a.trim().toLowerCase(),V=K?j.filter(k=>`#${k.number} ${k.title} ${k.headBranch} ${k.baseBranch}`.toLowerCase().includes(K)):j,X=d.trim().toLowerCase(),te=X?A.filter(k=>`#${k.number} ${k.title}`.toLowerCase().includes(X)):A,ee=b.find(k=>k.id===l)??null,q=O??ee;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:S,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:k=>f(k.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:te.length===0?o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:A.length===0?"暂无 Issue,请先同步":"无匹配 Issue"}):o.jsx("ul",{className:"space-y-0.5",children:te.map(k=>o.jsx(L9,{issue:k,linked:U.has(k.id),onToggle:()=>void L(k)},k.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:g,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",g&&"animate-spin")})})]}),o.jsx("div",{className:"flex border-b border-line",children:_E.map(({key:k,label:J})=>{const Te=k==="open"?F:k==="merged"?Z:k==="closed"?ne:b.length;return o.jsxs("button",{type:"button",onClick:()=>t(k),className:oe("flex flex-1 items-center justify-center gap-1.5 py-2 text-xs font-medium transition-colors",e===k?"border-b-2 border-blue-500 text-blue-500":"text-fg-4 hover:text-fg-2"),children:[J,o.jsx("span",{className:oe("rounded-full px-1.5 py-0.5 font-mono text-[10px]",e===k?"bg-blue-500/10 text-blue-500":"bg-elevated text-fg-5"),children:Te})]},k)})}),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:k=>s(k.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 flex-wrap items-center gap-x-2 gap-y-2 border-b border-line px-4 py-2.5",children:[o.jsx("span",{className:"shrink-0 text-sm font-semibold text-fg md:order-1",children:"Pull Requests"}),o.jsx("button",{type:"button",onClick:()=>void y(),disabled:g||!C,title:"同步 PR",className:"ml-auto 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 md:order-last md:ml-0",children:o.jsx(Fs,{className:oe("h-4 w-4",g&&"animate-spin")})}),o.jsx("div",{className:"w-full md:order-2 md:w-auto",children:o.jsx("div",{className:"flex shrink-0 items-center rounded-lg bg-elevated/60 p-0.5",children:_E.map(({key:k,label:J})=>{const Te=k==="open"?F:k==="merged"?Z:k==="closed"?ne:b.length;return o.jsxs("button",{type:"button",onClick:()=>t(k),className:oe("flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs font-medium transition-colors",e===k?"bg-surface text-fg shadow-sm":"text-fg-4 hover:text-fg-2"),children:[J,o.jsx("span",{className:oe("rounded-full px-1.5 py-0.5 font-mono text-[10px]",e===k?"bg-blue-500/10 text-blue-500":"text-fg-5"),children:Te})]},k)})})}),o.jsx("div",{className:"w-full md:order-3 md:w-auto md:min-w-0 md:flex-1 md: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:k=>s(k.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"})})]})})]})}),!T&&o.jsx("div",{className:oe("flex-1 overflow-y-auto",q?"px-2 py-2":"px-3 py-3"),children:C?V.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-16 text-fg-5",children:[o.jsx(po,{className:"h-8 w-8"}),o.jsx("p",{className:"font-mono text-xs",children:b.length===0?"点击 ↻ 同步 PR":"没有匹配的 PR"})]}):o.jsx("ul",{className:oe(q?"space-y-0.5":"space-y-1"),children:V.map(k=>q?o.jsx(M9,{pr:k,isActive:k.id===(l??T),onSelect:()=>u(k.id)},k.id):o.jsx(D9,{pr:k,onSelect:()=>u(k.id)},k.id))}):o.jsx("p",{className:"px-2 py-8 text-center font-mono text-xs text-fg-5",children:"请先选择一个仓库"})})]}),q?o.jsx(j9,{pr:q,onBack:()=>{u(null),T&&S()},onClose:()=>{u(null),T&&S()},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(po,{className:"mx-auto h-12 w-12 opacity-20"}),o.jsx("p",{className:"mt-3 font-mono text-xs",children:"选择一个 PR 查看详情"})]})})]})}let Nr=null;function P9(e){const t=Date.now()-e,a=Math.floor(t/6e4);return a<1?"刚刚":a<60?`${a} 分钟前`:`${Math.floor(a/60)} 小时前`}const NE=[{id:"usage",label:"Claude 账号",icon:Fh},{id:"git",label:"Git 源站",icon:$s},{id:"models",label:"模型",icon:uc},{id:"custom-agents",label:"Custom Agents",icon:aA},{id:"agents",label:"AGENTS.md",icon:ey}],U9={id:"server",label:"服务器",icon:iy};function Ah(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 H9(e){return e>=90?"bg-red-500":e>=70?"bg-amber-500":"bg-blue-500"}function Qm({label:e,window:t}){if(!t)return null;const a=Math.round(t.utilization),s=Ah(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(SA,{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",H9(a),l?"shadow-sm shadow-red-500/50":u?"shadow-sm shadow-amber-500/40":null),style:{width:`${Math.min(a,100)}%`}})})]})}function F9({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(ry,{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(va,{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(tA,{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(An,{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(sy,{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(An,{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(Qm,{label:"5 小时窗口",window:e.usage.five_hour}),o.jsx(Qm,{label:"7 天窗口",window:e.usage.seven_day}),(l=e.usage.scoped)==null?void 0:l.map(u=>o.jsx(Qm,{label:u.label,window:u},u.label))]}):null]})}function z9(){const[e,t]=v.useState((Nr==null?void 0:Nr.data)??null),[a,s]=v.useState(!Nr),[l,u]=v.useState(null),[d,f]=v.useState(null),[m,h]=v.useState((Nr==null?void 0:Nr.fetchedAt)??null),[,b]=v.useState(0),g=v.useCallback(S=>{const w=Date.now();Nr={data:S,fetchedAt:w},t(S),h(w)},[]),y=v.useCallback(()=>{s(!0),u(null),xy().then(S=>{g(S),s(!1)}).catch(S=>{u(S instanceof Error?S.message:String(S)),s(!1)})},[g]);v.useEffect(()=>{Nr||y()},[y]),v.useEffect(()=>{const S=setInterval(()=>b(w=>w+1),3e4);return()=>clearInterval(S)},[]);const T=v.useRef(!1),N=v.useCallback(S=>{T.current||(T.current=!0,f(S),Ey(S).then(w=>{g(w),f(null)}).catch(w=>{u(w instanceof Error?w.message:String(w)),f(null)}).finally(()=>{T.current=!1}))},[g]);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(UA,{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:P9(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(va,{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(An,{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(sy,{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(S=>o.jsx(F9,{account:S,onSwitch:N,switching:d===S.id},S.id)):null})]})}function q9({host:e,onDelete:t}){const[a,s]=v.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 $9({onAdded:e}){const[t,a]=v.useState(!1),[s,l]=v.useState(""),[u,d]=v.useState(""),[f,m]=v.useState(""),[h,b]=v.useState("gitea"),[g,y]=v.useState(!1),[T,N]=v.useState(!1),S=()=>{l(""),d(""),m(""),b("gitea"),a(!1)},w=async()=>{if(!(!s.trim()||!u.trim()||!f.trim())){y(!0);try{await JC(s.trim(),u.trim(),f.trim(),h),S(),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=>b(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(MA,{className:"h-3.5 w-3.5"}):o.jsx(LA,{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:S,className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),o.jsx("button",{type:"button",onClick:()=>void w(),disabled:g||!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:g?"保存中…":"保存"})]})]}):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(Wa,{className:"h-3.5 w-3.5"})," 添加 Git 源站"]})}function Y9(){const[e,t]=v.useState(""),[a,s]=v.useState(""),[l,u]=v.useState(!0),[d,f]=v.useState(!1),[m,h]=v.useState(null);v.useEffect(()=>{$C().then(y=>{t(y.content),s(y.content),u(!1)}).catch(y=>{h(y instanceof Error?y.message:String(y)),u(!1)})},[]);const b=async()=>{f(!0),h(null);try{await YC(e),s(e)}catch(y){h(y instanceof Error?y.message:String(y))}f(!1)},g=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 b(),disabled:d||!g,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($c,{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(An,{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(va,{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
|
|
491
491
|
|
|
492
492
|
在此编写全局 Agent 指令…`})}),o.jsx("p",{className:"mt-3 text-[11px] text-fg-5",children:"文件路径:~/.config/opencode/AGENTS.md"})]})}function G9(){const[e,t]=v.useState([]),[a,s]=v.useState(!0),l=()=>{ZC().then(d=>{t(d),s(!1)}).catch(()=>s(!1))};v.useEffect(l,[]);const u=async d=>{await ew(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(q9,{host:d,onDelete:()=>void u(d.id)},d.id)),o.jsx($9,{onAdded:l})]})}),o.jsx("p",{className:"mt-4 text-[11px] text-fg-5",children:"Token 存储在数据库中。也可通过环境变量 GITEA_TOKEN 设置全局 fallback。"})]})}const Ch="pinned_models";function K9(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 V9(e){return e?e>=1e6?`${(e/1e6).toFixed(e%1e6===0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e):""}function Q9(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 X9(){const e=He(O=>O.activeRepoId),[t,a]=v.useState([]),[s,l]=v.useState(new Set),[u,d]=v.useState(!0),[f,m]=v.useState(null),[h,b]=v.useState(null),[g,y]=v.useState("");v.useEffect(()=>{let O=!1;async function U(){d(!0),m(null);try{const[Q,L]=await Promise.all([Gc(),e?Yc(e):Promise.resolve([])]);if(O)return;const F=Q[Ch],Z=F?JSON.parse(F):[];l(new Set(Z)),a(L),b(null),y("")}catch(Q){O||m(Q instanceof Error?Q.message:String(Q))}O||d(!1)}return U(),()=>{O=!0}},[e]);const T=async O=>{const U=new Set(s);U.has(O)?U.delete(O):U.add(O),l(U);try{await ah(Ch,JSON.stringify([...U]))}catch{l(s)}},N=v.useMemo(()=>K9(t),[t]),S=t.filter(O=>s.has(O.id)).length,w=h?N.find(O=>O.provider===h):N[0],C=g.trim().toLowerCase(),A=w?C?w.models.filter(O=>(O.name||O.id).toLowerCase().includes(C)||O.id.toLowerCase().includes(C)):w.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(uc,{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:["勾选常用模型,在新建对话时快速选择。",S>0&&o.jsxs("span",{className:"ml-1 text-blue-400",children:["已选 ",S," 个"]})]})]})]})}),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(va,{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(An,{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(uc,{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(O=>{var L;const U=O.provider===(h??((L=N[0])==null?void 0:L.provider)),Q=O.models.filter(F=>s.has(F.id)).length;return o.jsxs("button",{type:"button",onClick:()=>{b(O.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",U?"bg-surface text-fg shadow-sm":"text-fg-4 hover:text-fg-3"),children:[O.provider,Q>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:Q})]},O.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:g,onChange:O=>y(O.target.value),placeholder:"搜索模型…",className:"min-w-0 flex-1 bg-transparent text-xs text-fg placeholder:text-fg-6 focus:outline-none"}),g&&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:A.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:A.map(O=>{const U=s.has(O.id),Q=V9(O.contextLimit),L=Q9(O.cost);return o.jsxs("label",{className:oe("flex cursor-pointer items-center gap-3 px-3 py-2 transition-colors hover:bg-elevated/60",U&&"bg-blue-500/5"),children:[o.jsx("input",{type:"checkbox",checked:U,onChange:()=>void T(O.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:O.name||O.id}),o.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[Q&&o.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5 text-[10px] text-fg-5",children:Q}),L&&o.jsx("span",{className:"text-[10px] text-fg-6",children:L})]})]},O.id)})})})]}):o.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[o.jsx(uc,{className:"h-5 w-5"}),o.jsx("p",{className:"text-xs",children:"请先在左侧选择一个仓库以加载可用模型。"})]})})]})}const W9=["Sisyphus - ultraworker","Prometheus - Plan Builder","Atlas - Plan Executor"];function Z9({agent:e,onEdit:t,onDelete:a}){const[s,l]=v.useState(!1),[u,d]=v.useState(!1),f=async()=>{const h=await xx(e.id),b=new Blob([JSON.stringify(h,null,2)],{type:"application/json"}),g=URL.createObjectURL(b),y=document.createElement("a");y.href=g,y.download=`${e.name.replace(/[^a-zA-Z0-9\u4e00-\u9fff_-]/g,"_")}.json`,y.click(),URL.revokeObjectURL(g)},m=async()=>{const h=await xx(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(RA,{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(NA,{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(ny,{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 vE({initial:e,availableFragments:t,onSave:a,onCancel:s}){const l=He(K=>K.activeRepoId),[u,d]=v.useState((e==null?void 0:e.name)??""),[f,m]=v.useState((e==null?void 0:e.baseAgent)??"Sisyphus - ultraworker"),[h,b]=v.useState((e==null?void 0:e.model)??""),[g,y]=v.useState((e==null?void 0:e.systemPrompt)??""),[T,N]=v.useState(!1),[S,w]=v.useState(!1),[C,A]=v.useState([]);v.useEffect(()=>{if(!l){A([]);return}let K=!1;return(async()=>{try{const[V,X]=await Promise.all([Gc(),Yc(l)]);if(K)return;const te=V[Ch],ee=te?JSON.parse(te):[];A(ee.length>0?X.filter(q=>ee.includes(q.id)):[])}catch{K||A([])}})(),()=>{K=!0}},[l]);const[O,U]=v.useState(()=>{const K=(e==null?void 0:e.fragments.map(ee=>ee.id))??[],V=(e==null?void 0:e.systemPromptPosition)??-1,X=V>=0&&V<=K.length?V:K.length,te=[...K];return te.splice(X,0,js),te}),Q=K=>{U(V=>{if(V.includes(K))return V.filter(ee=>ee!==K);const X=V.indexOf(js),te=[...V];return te.splice(X>=0?X:te.length,0,K),te})},L=(K,V)=>{const X=K+V;X<0||X>=O.length||U(te=>{const ee=[...te];return[ee[K],ee[X]]=[ee[X],ee[K]],ee})},F=O.filter(K=>K!==js),Z=(()=>{const K=O.indexOf(js);return K<0?-1:O.slice(0,K).filter(V=>V!==js).length})(),ne=O.map(K=>{var V;return K===js?g:(V=t.find(X=>X.id===K))==null?void 0:V.content}).filter(Boolean).join(`
|