fourth-spark 0.10.9 → 0.10.11

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.
@@ -457,9 +457,9 @@ Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}
457
457
  *
458
458
  * This source code is licensed under the ISC license.
459
459
  * See the LICENSE file in the root directory of this source tree.
460
- */const N5=[["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"}]],Qc=ke("zap",N5);function Cy(e){var t,a,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=Cy(e[t]))&&(r&&(r+=" "),r+=a)}else for(a in e)e[a]&&(r&&(r+=" "),r+=a);return r}function ne(){for(var e,t,a=0,r="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=Cy(e))&&(r&&(r+=" "),r+=t);return r}const Nx=e=>{let t;const a=new Set,r=(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(N=>N(t,y))}},o=()=>t,f={setState:r,getState:o,getInitialState:()=>m,subscribe:h=>(a.add(h),()=>a.delete(h))},m=t=e(r,o,f);return f},T5=(e=>e?Nx(e):Nx),_5=e=>e;function v5(e,t=_5){const a=ac.useSyncExternalStore(e.subscribe,ac.useCallback(()=>t(e.getState()),[e,t]),ac.useCallback(()=>t(e.getInitialState()),[e,t]));return ac.useDebugValue(a),a}const Tx=e=>{const t=T5(e),a=r=>v5(t,r);return Object.assign(a,t),a},es=(e=>e?Tx(e):Tx),Nm="fs-theme";function wy(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function _x(e){return e==="system"?wy():e}function vx(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const ah=es((e,t)=>({preference:localStorage.getItem(Nm)??"system",resolved:_x(localStorage.getItem(Nm)??"system"),cycle(){const a=["system","light","dark"],r=a[(a.indexOf(t().preference)+1)%a.length],o=_x(r);localStorage.setItem(Nm,r),vx(r),e({preference:r,resolved:o})},init(){vx(t().preference);const a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{const{preference:o}=t();if(o==="system"){const u=wy();e({resolved:u})}};return a.addEventListener("change",r),()=>a.removeEventListener("change",r)}})),Ac="fourth-spark-server-url";function ky(){if(typeof window>"u")return!1;const t=window.Capacitor;return typeof(t==null?void 0:t.isNativePlatform)=="function"&&t.isNativePlatform()}function Ry(){return localStorage.getItem(Ac)??""}function S5(e){const t=e.replace(/\/+$/,"");t?localStorage.setItem(Ac,t):localStorage.removeItem(Ac)}function sh(){return localStorage.getItem(Ac)??""}class Ss extends Error{constructor(a,r){super(a);sn(this,"status");this.name="ApiError",this.status=r}}async function Se(e,t){let a;try{a=await fetch(Ry()+e,{...t,headers:{Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers}})}catch(o){throw new Ss(o instanceof Error?o.message:"Network request failed",0)}if(!a.ok){const o=await a.text().catch(()=>"");throw new Ss(o.trim()||`${a.status} ${a.statusText}`,a.status)}if(a.status===204)return;const r=await a.text();if(r)return JSON.parse(r)}function sa(e,...t){if(Array.isArray(e))return e;if(e&&typeof e=="object"){const a=e;for(const r of[...t,"data","items"])if(Array.isArray(a[r]))return a[r]}return[]}async function A5(){return sa(await Se("/api/repos"),"repos")}async function C5(e,t,a,r){return Se("/api/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,localPath:a,runtimeType:r})})}async function w5(e){return Se("/api/repos/resolve",{method:"POST",body:JSON.stringify({localPath:e})})}async function k5(e){await Se(`/api/repos/${encodeURIComponent(e)}`,{method:"DELETE"})}async function R5(e){await Se(`/api/repos/${encodeURIComponent(e)}/start`,{method:"POST"})}async function O5(e){await Se(`/api/repos/${encodeURIComponent(e)}/stop`,{method:"POST"})}async function I5(e){return Se(`/api/repos/${encodeURIComponent(e)}/branches`)}async function M5(e,t){return Se(`/api/repos/${encodeURIComponent(e)}/checkout`,{method:"POST",body:JSON.stringify({branch:t})})}async function D5(e){return Se(`/api/repos/${encodeURIComponent(e)}/pull`,{method:"POST"})}function Ge(e){return`/api/repos/${encodeURIComponent(e)}`}async function L5(e){return sa(await Se(`${Ge(e)}/workspaces`),"workspaces")}async function j5(e,t){await Se(`${Ge(e)}/workspaces/${encodeURIComponent(t)}`,{method:"DELETE"})}async function B5(e){return Se(`${Ge(e)}/workspaces/cleanup`,{method:"POST"})}async function P5(e,t){await Se(`/api/repos/${e}/worktree`,{method:"PATCH",body:JSON.stringify({enabled:t})})}async function U5(e,t){await Se(`/api/repos/${e}/runtime`,{method:"PATCH",body:JSON.stringify({runtimeType:t})})}async function H5(e){return sa(await Se(`${Ge(e)}/sessions`),"sessions")}async function F5(e,t,a,r,o,u,c,f){return Se(`${Ge(e)}/sessions`,{method:"POST",body:JSON.stringify({message:t,agent:a,model:r,variant:o,issueId:u,customAgentId:c,files:f})})}async function z5(e,t){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function $5(e,t,a,r,o,u,c){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/prompt`,{method:"POST",body:JSON.stringify({content:a,agent:r,model:o,variant:u,files:c})})}async function q5(e,t){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/abort`,{method:"POST"})}async function Y5(e,t,a){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/questions/reply`,{method:"POST",body:JSON.stringify({answers:a})})}async function G5(e,t){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/questions/reject`,{method:"POST"})}async function K5(e,t,a){return Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/revert`,{method:"POST",body:JSON.stringify({messageID:a})})}function Sx(e){const t=e,a=t.info;if(a&&typeof a.id=="string"){const r=Array.isArray(t.parts)?t.parts:void 0;return{...a,...r?{parts:r}:{}}}return t}async function Ax(e,t,a){const r=new URLSearchParams;a!=null&&a.limit&&r.set("limit",String(a.limit)),a!=null&&a.before&&r.set("before",a.before);const o=r.toString(),u=`${Ge(e)}/sessions/${encodeURIComponent(t)}/messages${o?`?${o}`:""}`,c=await Se(u);if(Array.isArray(c)){const h=c.map(Sx);return{messages:h,total:h.length,hasMore:!1}}const f=c,m=Array.isArray(f.messages)?f.messages:[];return{messages:m.map(Sx),total:f.total??m.length,hasMore:f.hasMore??!1}}async function V5(e,t){return Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/status`)}async function X5(e,t){return Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/links`)}async function Q5(e,t){return Se(`${Ge(e)}/sessions/snapshot/${encodeURIComponent(t)}`)}async function Oy(e){return Se(`${Ge(e)}/sessions/all-links`)}async function W5(e,t,a,r){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"POST",body:JSON.stringify({type:a,targetId:r})})}async function Z5(e,t,a,r){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"DELETE",body:JSON.stringify({type:a,targetId:r})})}async function Iy(){return sa(await Se("/api/custom-agents"))}async function J5(e){return Se("/api/custom-agents",{method:"POST",body:JSON.stringify(e)})}async function eC(e,t){return Se(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function My(e){await Se(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"DELETE"})}async function Cx(e){return Se(`/api/custom-agents/${encodeURIComponent(e)}/export`)}async function tC(e){return Se("/api/custom-agents/import",{method:"POST",body:JSON.stringify(e)})}async function Dy(e,t){const a=new URLSearchParams;t!=null&&t.category&&a.set("category",t.category),t!=null&&t.includeSuperseded&&a.set("includeSuperseded","true");const r=a.toString();return Se(`/api/custom-agents/${encodeURIComponent(e)}/memories${r?`?${r}`:""}`)}async function nC(e,t,a){return Se(`/api/custom-agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(a)})}async function aC(e,t){await Se(`/api/custom-agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t)}`,{method:"DELETE"})}async function sC(e,t){return Se(`/api/custom-agents/${encodeURIComponent(e)}/memories/extract`,{method:"POST",body:JSON.stringify({sessionIds:t})})}async function Xh(e){return Se(`/api/custom-agents/${encodeURIComponent(e)}/sessions`)}async function Ly(e){return sa(await Se(`${Ge(e)}/custom-agents`))}async function rC(e,t){return Se(`${Ge(e)}/custom-agents`,{method:"POST",body:JSON.stringify(t)})}async function Ro(e){return sa(await Se(`${Ge(e)}/models`))}async function jy(){return sa(await Se("/api/prompt-fragments"))}async function iC(e){return Se("/api/prompt-fragments",{method:"POST",body:JSON.stringify(e)})}async function lC(e,t){return Se(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function oC(e){await Se(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"DELETE"})}async function wx(e){return sa(await Se(`${Ge(e)}/tags`))}async function kx(e,t){return sa(await Se(`${Ge(e)}/milestones`))}async function Rx(e,t="open"){return sa(await Se(`${Ge(e)}/issues?state=${encodeURIComponent(t)}`),"issues")}async function uC(e,t="all"){return Se(`${Ge(e)}/issues/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function cC(e,t,a){return Se(`${Ge(e)}/issues`,{method:"POST",body:JSON.stringify({title:t,body:a})})}async function dC(e,t,a){await Se(`${Ge(e)}/issues/${t}/children`,{method:"POST",body:JSON.stringify({childNumber:a})})}async function By(e,t,a){return Se(`${Ge(e)}/issues/${t}`,{method:"PATCH",body:JSON.stringify(a)})}async function fC(e,t){return sa(await Se(`${Ge(e)}/issues/${t}/pulls`))}async function Ox(e,t="open"){return sa(await Se(`${Ge(e)}/pulls?state=${encodeURIComponent(t)}`))}async function mC(e,t="all"){return Se(`${Ge(e)}/pulls/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function hC(e,t){return Se(`${Ge(e)}/pulls/${t}`)}async function pC(e,t){await Se(`${Ge(e)}/pulls/${t}/merge`,{method:"POST"})}async function Qh(e,t){return sa(await Se(`${Ge(e)}/pulls/${t}/issues`))}async function gC(e,t,a){await Se(`${Ge(e)}/pulls/${t}/issues`,{method:"POST",body:JSON.stringify({issueNumber:a})})}async function bC(e,t,a){await Se(`${Ge(e)}/pulls/${t}/issues/${a}`,{method:"DELETE"})}async function xC(e,t){return Se(`${Ge(e)}/pulls/${t}/comments`)}async function EC(e,t){return Se(`${Ge(e)}/issues/${t}/comments`)}async function Ix(e,t,a){return Se(`${Ge(e)}/issues/${t}/comments`,{method:"POST",body:JSON.stringify({body:a})})}async function yC(e,t,a){return Se(`${Ge(e)}/issues/${t}/polish`,{method:"POST",body:JSON.stringify({draft:a})})}async function Mx(e,t){return Se(`${Ge(e)}/issues/${t}/draft`)}async function NC(e,t,a){return Se(`${Ge(e)}/issues/polish-create`,{method:"POST",body:JSON.stringify({title:t,body:a})})}async function Dx(e){return Se(`${Ge(e)}/issues/draft-create`)}async function TC(e){await Se(`${Ge(e)}/issues/draft-create`,{method:"DELETE"})}async function _C(e,t,a){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({title:a})})}async function vC(e,t,a){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({completedAt:a})})}async function SC(){return Se("/api/agents-md")}async function AC(e){await Se("/api/agents-md",{method:"PUT",body:JSON.stringify({content:e})})}async function CC(e){return Se(`/api/repos/${encodeURIComponent(e)}/agents-md`)}async function wC(e,t){await Se(`/api/repos/${encodeURIComponent(e)}/agents-md`,{method:"PUT",body:JSON.stringify({content:t})})}function kC(e){return`${Ry()}${Ge(e)}/events`}async function RC(e){return Se(`${Ge(e)}/sessions/status`)}async function Oo(){return Se("/api/settings")}async function rh(e,t){await Se(`/api/settings/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({value:t})})}async function ih(){return Se("/api/cloud/status")}async function OC(){return Se("/api/cloud/reload",{method:"POST"})}async function IC(e){try{return(await Se("/api/cloud/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).connected}catch{return!1}}async function MC(){return sa(await Se("/api/git-hosts"),"gitHosts")}async function DC(e,t,a,r="gitea"){return Se("/api/git-hosts",{method:"POST",body:JSON.stringify({host:e,name:t,token:a,platform:r})})}async function LC(e){await Se(`/api/git-hosts/${encodeURIComponent(e)}`,{method:"DELETE"})}async function Py(){return Se("/api/usage")}async function Uy(e){return Se("/api/usage/switch",{method:"POST",body:JSON.stringify({accountId:e})})}async function jC(e,t="ios"){await Se("/api/push/register",{method:"POST",body:JSON.stringify({token:e,platform:t})})}const ar="fs-active-repo",je=es((e,t)=>({repos:[],activeRepoId:localStorage.getItem(ar),loading:!1,loadError:null,loadRepos:async()=>{e({loading:!0,loadError:null});try{const a=await A5(),r=t().activeRepoId,o=r&&a.some(c=>c.id===r);e({repos:a,loading:!1,activeRepoId:o?r:a.length>0?a[0].id:null});const u=t().activeRepoId;u?localStorage.setItem(ar,u):localStorage.removeItem(ar)}catch(a){e({loading:!1,loadError:a instanceof Error?a.message:"Failed to load repos"})}},setActiveRepo:a=>{e({activeRepoId:a}),a?localStorage.setItem(ar,a):localStorage.removeItem(ar)},addRepo:async(a,r,o,u)=>{try{const c=await C5(a,r,o,u);return e(f=>({repos:[...f.repos,c],activeRepoId:c.id})),localStorage.setItem(ar,c.id),c}catch(c){return e({loadError:c instanceof Error?c.message:"Failed to add repo"}),null}},removeRepo:async a=>{try{await k5(a)}catch{}e(r=>{const o=r.repos.filter(c=>c.id!==a),u=r.activeRepoId===a?o.length>0?o[0].id:null:r.activeRepoId;return u?localStorage.setItem(ar,u):localStorage.removeItem(ar),{repos:o,activeRepoId:u}})},updateRepoBranch:(a,r)=>{e(o=>({repos:o.repos.map(u=>u.id===a?{...u,branch:r}:u)}))}})),zn=e=>{var t;return((t=e.repos.find(a=>a.id===e.activeRepoId))==null?void 0:t.name)??null},Lx="fs-nav-collapsed",jx="fs-session-panel-collapsed",Cc=es(e=>({navCollapsed:localStorage.getItem(Lx)==="true",sessionPanelCollapsed:localStorage.getItem(jx)==="true",toggleNav(){e(t=>{const a=!t.navCollapsed;return localStorage.setItem(Lx,String(a)),{navCollapsed:a}})},toggleSessionPanel(){e(t=>{const a=!t.sessionPanelCollapsed;return localStorage.setItem(jx,String(a)),{sessionPanelCollapsed:a}})}})),Hy=[{segment:"run",icon:Kh,label:"运行面板",global:!1},{segment:"agents",icon:DA,label:"Agents",global:!1},{segment:"dev/issues",icon:a3,label:"研发",global:!1,matchPrefix:"dev"}];function Fy(e,t,a){return t?`/${e}`:a?`/${encodeURIComponent(a)}/${e}`:`/${e}`}function zy(e,t,a){if(!e.matchPrefix)return!1;const r=e.global?`/${e.matchPrefix}`:a?`/${encodeURIComponent(a)}/${e.matchPrefix}`:null;return r?t===r||t.startsWith(`${r}/`):!1}function BC(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function PC({repos:e,activeRepoId:t,onRepoChange:a}){const r=vn(),[o,u]=T.useState(!1),c=T.useRef(null),f=e.find(h=>h.id===t),m=T.useCallback(()=>u(!1),[]);return T.useEffect(()=>{if(!o)return;const h=b=>{c.current&&!c.current.contains(b.target)&&m()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o,m]),i.jsxs("div",{ref:c,className:"relative",children:[i.jsxs("button",{type:"button",onClick:()=>u(h=>!h),className:"flex max-w-[140px] items-center gap-1 rounded-md border border-line bg-base px-2 py-1 text-xs text-fg-2 transition-colors hover:border-blue-500 sm:max-w-[200px]",children:[i.jsx(xy,{className:"h-3 w-3 shrink-0 text-fg-4"}),i.jsxs("span",{className:"truncate",children:[i.jsx("span",{className:"sm:hidden",children:f?BC(f.name):""}),i.jsx("span",{className:"hidden sm:inline",children:(f==null?void 0:f.name)??""})]}),i.jsx(ba,{className:ne("h-3 w-3 shrink-0 text-fg-4 transition-transform",o&&"rotate-180")})]}),o&&i.jsxs("div",{className:"absolute left-0 top-full z-50 mt-1 w-64 overflow-hidden rounded-lg border border-line bg-surface shadow-lg",children:[i.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:e.map(h=>i.jsxs("button",{type:"button",onClick:()=>{a(h.id),m()},className:ne("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors",h.id===t?"font-medium text-blue-600":"text-fg-2 hover:bg-elevated"),children:[h.id===t?i.jsx(On,{className:"h-3 w-3 shrink-0"}):i.jsx("span",{className:"h-3 w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:h.name})]},h.id))}),i.jsx("div",{className:"border-t border-line",children:i.jsxs("button",{type:"button",onClick:()=>{r("/repos"),m()},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:[i.jsx(Vh,{className:"h-3 w-3 shrink-0"}),i.jsx("span",{children:"管理仓库"})]})})]})]})}function UC({repoId:e,currentBranch:t}){const a=je(S=>S.updateRepoBranch),[r,o]=T.useState(!1),[u,c]=T.useState(null),[f,m]=T.useState(!1),[h,b]=T.useState(null),[g,y]=T.useState(null),N=T.useRef(null),v=T.useCallback(()=>{o(!1),y(null)},[]);T.useEffect(()=>{if(!r)return;const S=M=>{N.current&&!N.current.contains(M.target)&&v()};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[r,v]);const A=async()=>{if(r){v();return}o(!0),m(!0),y(null);try{c(await I5(e))}catch{y("加载分支失败")}finally{m(!1)}},C=async S=>{if(!(S===t||h)){b(S),y(null);try{const M=await M5(e,S);a(e,M.branch),v()}catch(M){y(M instanceof Error?M.message:"切换失败")}finally{b(null)}}};return t?i.jsxs("div",{ref:N,className:"relative",children:[i.jsxs("button",{type:"button",onClick:A,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:[i.jsx(ko,{className:"h-3 w-3"}),t,i.jsx(ba,{className:ne("h-3 w-3 transition-transform",r&&"rotate-180")})]}),r&&i.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?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(ln,{className:"h-4 w-4 animate-spin text-fg-4"})}):u?i.jsxs("div",{className:"max-h-64 overflow-y-auto py-1",children:[u.local.map(S=>i.jsxs("button",{type:"button",disabled:h!==null,onClick:()=>C(S),className:ne("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors",S===t?"font-medium text-blue-600":"text-fg-2 hover:bg-elevated"),children:[S===t?i.jsx(On,{className:"h-3 w-3 shrink-0"}):h===S?i.jsx(ln,{className:"h-3 w-3 shrink-0 animate-spin"}):i.jsx("span",{className:"h-3 w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:S})]},S)),u.remote.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mx-3 my-1 border-t border-line"}),i.jsx("div",{className:"px-3 py-1 text-[10px] font-medium uppercase tracking-wider text-fg-4",children:"Remote"}),u.remote.map(S=>i.jsxs("button",{type:"button",disabled:h!==null,onClick:()=>C(S),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===S?i.jsx(ln,{className:"h-3 w-3 shrink-0 animate-spin"}):i.jsx("span",{className:"h-3 w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:S})]},`remote-${S}`))]})]}):null,g&&i.jsx("div",{className:"border-t border-line px-3 py-2 text-xs text-red-500",children:g})]})]}):null}function HC(){const[e,t]=T.useState(null);return T.useEffect(()=>{const a=()=>fetch("/api/health").then(u=>u.json()).then(u=>{u.latestVersion&&u.latestVersion!=="0.10.9"&&t(u.latestVersion)}).catch(()=>{});a();const r=setInterval(a,30*6e4),o=()=>a();return window.addEventListener("focus",o),()=>{clearInterval(r),window.removeEventListener("focus",o)}},[]),e}function FC(){const e=vn(),t=_n(),a=je(g=>g.repos),r=je(g=>g.activeRepoId),o=je(g=>g.setActiveRepo),u=ah(g=>g.preference),c=ah(g=>g.cycle),f=u==="light"?d5:u==="dark"?Y3:$3,m=a.find(g=>g.id===r),h=HC(),b=g=>{var A;if(!g)return;o(g);const y=a.find(C=>C.id===g);if(!y)return;const N=t.pathname.match(/\/dev\/(issues|pulls)/);if(N){e(`/${encodeURIComponent(y.name)}/dev/${N[1]}`);return}const v=((A=t.pathname.match(/\/(run|agents|issues|pulls)/))==null?void 0:A[1])??"run";e(`/${encodeURIComponent(y.name)}/${v}`)};return i.jsxs("header",{className:"shrink-0 border-b border-line bg-surface pt-[var(--safe-top)]",children:[i.jsxs("div",{className:"flex h-12 items-center justify-between px-4",children:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(Qc,{className:"h-5 w-5 text-blue-500"}),i.jsx("span",{className:"hidden text-sm font-bold tracking-tight text-fg sm:inline",children:"Fourth Spark"}),i.jsxs("span",{className:"hidden rounded bg-elevated px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-fg-4 sm:inline",children:["v","0.10.9"]}),h&&i.jsxs("span",{className:"hidden text-[10px] text-amber-500 sm:inline",children:["→ v",h," 可用,运行 ",i.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[a.length>0&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(PC,{repos:a,activeRepoId:r,onRepoChange:b}),m&&r&&i.jsx(UC,{repoId:r,currentBranch:m.branch})]}),i.jsx("button",{type:"button",onClick:()=>e("/settings"),"aria-label":"设置",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:i.jsx(Vh,{className:"h-4 w-4"})}),i.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:i.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:i.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"})})}),i.jsx("button",{type:"button",onClick:c,"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:i.jsx(f,{className:"h-4 w-4"})})]})]}),h&&i.jsx("div",{className:"border-t border-line px-4 py-1.5 sm:hidden",children:i.jsxs("span",{className:"text-[10px] text-amber-500",children:["→ v",h," 可用,运行 ",i.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})})]})}function zC(){const e=je(zn),t=Cc(o=>o.navCollapsed),a=Cc(o=>o.toggleNav),r=_n();return i.jsxs("nav",{className:ne("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:[i.jsx("div",{className:"flex flex-1 flex-col",children:Hy.map(o=>{const u=zy(o,r.pathname,e);return i.jsxs(vc,{to:Fy(o.segment,o.global,e),title:t?o.label:void 0,className:({isActive:c})=>ne("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",c||u?"bg-blue-500/10 font-medium text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:[i.jsx(o.icon,{className:"h-4 w-4 shrink-0"}),i.jsx("span",{className:ne("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:o.label})]},o.segment)})}),i.jsxs(vc,{to:"/settings",title:t?"设置":void 0,className:({isActive:o})=>ne("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",o?"bg-blue-500/10 font-medium text-blue-600":"text-fg-4 hover:bg-elevated hover:text-fg-2"),children:[i.jsx(Vh,{className:"h-4 w-4 shrink-0"}),i.jsx("span",{className:ne("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:"设置"})]}),i.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?i.jsx(GA,{className:"h-4 w-4"}):i.jsx(qA,{className:"h-4 w-4"})})]})}function $C(){const e=je(zn),t=_n();return i.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:i.jsx("div",{className:"flex h-14 items-center justify-around",children:Hy.map(a=>{const r=zy(a,t.pathname,e);return i.jsx(vc,{to:Fy(a.segment,a.global,e),"aria-label":a.label,className:({isActive:o})=>ne("flex h-10 w-10 items-center justify-center rounded-md transition-colors",o||r?"bg-blue-500/10 text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:i.jsx(a.icon,{className:"h-5 w-5 shrink-0"})},a.segment)})})})}function qC(){return i.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-base text-fg",children:[i.jsx(FC,{}),i.jsxs("div",{className:"flex min-h-0 flex-1",children:[i.jsx(zC,{}),i.jsx("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden pb-[calc(3.5rem_+_var(--safe-bottom))] md:pb-0",children:i.jsx(jS,{})})]}),i.jsx($C,{})]})}let YC=0;const Qt=es(e=>({toasts:[],addToast:(t,a="info",r,o)=>{const u=(o==null?void 0:o.id)??`toast-${++YC}-${Date.now()}`;e(c=>c.toasts.some(f=>f.id===u)?c:{toasts:[...c.toasts,{id:u,message:t,variant:a,sessionId:r,persistent:o==null?void 0:o.persistent}]}),o!=null&&o.persistent||setTimeout(()=>{e(c=>({toasts:c.toasts.filter(f=>f.id!==u)}))},4e3)},removeToast:t=>{e(a=>({toasts:a.toasts.filter(r=>r.id!==t)}))}}));function GC({onClose:e}){const[t,a]=T.useState(""),[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState("opencode"),[h,b]=T.useState(!1),[g,y]=T.useState(""),N=je(M=>M.addRepo),v=r.trim()!==""&&u.trim()!==""&&t.trim()!==""&&!h,A=async M=>{const O=M.trim();if(O){b(!0),y("");try{const j=await w5(O);j.name&&!r.trim()&&o(j.name),j.gitUrl&&!u.trim()&&c(j.gitUrl)}catch(j){const I=j instanceof Error?j.message:"无法解析路径";try{const U=JSON.parse(I);y(U.error??I)}catch{y(I)}}b(!1)}},C=T.useRef(A);C.current=A,T.useEffect(()=>{const M=t.trim();if(!M)return;const O=setTimeout(()=>{C.current(M)},500);return()=>clearTimeout(O)},[t]);const S=async()=>{if(!v)return;y(""),await N(r.trim(),u.trim(),t.trim(),f)&&e()};return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:e,children:i.jsxs("div",{className:"w-full max-w-md rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:M=>M.stopPropagation(),children:[i.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[i.jsx("h2",{className:"text-base font-semibold text-fg",children:"添加仓库"}),i.jsx("button",{type:"button",onClick:e,className:"rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:i.jsx(gt,{className:"h-4 w-4"})})]}),i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{htmlFor:"m-path",className:"text-xs font-medium text-fg-3",children:"本地路径"}),i.jsx("input",{id:"m-path",value:t,onChange:M=>a(M.target.value),onBlur:M=>void A(M.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"}),i.jsx("span",{className:"text-[11px] text-fg-5",children:h?"正在读取 Git 信息…":"输入路径后自动读取仓库信息"})]}),i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{htmlFor:"m-name",className:"text-xs font-medium text-fg-3",children:"名称"}),i.jsx("input",{id:"m-name",value:r,onChange:M=>o(M.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"})]}),i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{htmlFor:"m-git",className:"text-xs font-medium text-fg-3",children:"Git 远程地址"}),i.jsx("input",{id:"m-git",value:u,onChange:M=>c(M.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"})]}),i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{className:"text-xs font-medium text-fg-3",children:"运行时"}),i.jsx("div",{className:"flex gap-2",children:[{value:"opencode",label:"OpenCode"},{value:"claude-code",label:"Claude Code"}].map(M=>i.jsx("button",{type:"button",onClick:()=>m(M.value),className:`flex-1 rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${f===M.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:M.label},M.value))}),i.jsx("span",{className:"text-[11px] text-fg-5",children:f==="claude-code"?"需要本地安装 Claude Code CLI":"需要本地安装 OpenCode CLI"})]}),g&&i.jsx("p",{className:"rounded-md bg-red-500/10 px-3 py-2 text-xs text-red-500",children:g}),i.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[i.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:"取消"}),i.jsx("button",{type:"button",onClick:S,disabled:!v,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 KC({repoId:e,repoName:t,onClose:a}){const[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState(!0),[h,b]=T.useState(!1),[g,y]=T.useState(null);T.useEffect(()=>{CC(e).then(A=>{o(A.content),c(A.content),m(!1)}).catch(A=>{y(A instanceof Error?A.message:String(A)),m(!1)})},[e]);const N=async()=>{b(!0),y(null);try{await wC(e,r),c(r)}catch(A){y(A instanceof Error?A.message:String(A))}b(!1)},v=r!==u;return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:a,children:i.jsxs("div",{className:"flex w-full max-w-2xl flex-col rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:A=>A.stopPropagation(),children:[i.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsxs("h2",{className:"text-base font-semibold text-fg",children:[t," — AGENTS.md"]}),i.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"仅对此仓库生效,修改后 opencode 热加载即时生效。"})]}),i.jsx("button",{type:"button",onClick:a,className:"shrink-0 rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:i.jsx(gt,{className:"h-4 w-4"})})]}),g&&i.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:[i.jsx(Tn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 break-words",children:g})]}),f?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[i.jsx(ln,{className:"h-5 w-5 fs-spin"}),i.jsx("p",{className:"text-xs",children:"加载中…"})]}):i.jsx("textarea",{value:r,onChange:A=>o(A.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
460
+ */const N5=[["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"}]],Qc=ke("zap",N5);function Cy(e){var t,a,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(a=Cy(e[t]))&&(r&&(r+=" "),r+=a)}else for(a in e)e[a]&&(r&&(r+=" "),r+=a);return r}function ne(){for(var e,t,a=0,r="",o=arguments.length;a<o;a++)(e=arguments[a])&&(t=Cy(e))&&(r&&(r+=" "),r+=t);return r}const Nx=e=>{let t;const a=new Set,r=(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(N=>N(t,y))}},o=()=>t,f={setState:r,getState:o,getInitialState:()=>m,subscribe:h=>(a.add(h),()=>a.delete(h))},m=t=e(r,o,f);return f},T5=(e=>e?Nx(e):Nx),_5=e=>e;function v5(e,t=_5){const a=ac.useSyncExternalStore(e.subscribe,ac.useCallback(()=>t(e.getState()),[e,t]),ac.useCallback(()=>t(e.getInitialState()),[e,t]));return ac.useDebugValue(a),a}const Tx=e=>{const t=T5(e),a=r=>v5(t,r);return Object.assign(a,t),a},es=(e=>e?Tx(e):Tx),Nm="fs-theme";function wy(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function _x(e){return e==="system"?wy():e}function vx(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const ah=es((e,t)=>({preference:localStorage.getItem(Nm)??"system",resolved:_x(localStorage.getItem(Nm)??"system"),cycle(){const a=["system","light","dark"],r=a[(a.indexOf(t().preference)+1)%a.length],o=_x(r);localStorage.setItem(Nm,r),vx(r),e({preference:r,resolved:o})},init(){vx(t().preference);const a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{const{preference:o}=t();if(o==="system"){const u=wy();e({resolved:u})}};return a.addEventListener("change",r),()=>a.removeEventListener("change",r)}})),Ac="fourth-spark-server-url";function ky(){if(typeof window>"u")return!1;const t=window.Capacitor;return typeof(t==null?void 0:t.isNativePlatform)=="function"&&t.isNativePlatform()}function Ry(){return localStorage.getItem(Ac)??""}function S5(e){const t=e.replace(/\/+$/,"");t?localStorage.setItem(Ac,t):localStorage.removeItem(Ac)}function sh(){return localStorage.getItem(Ac)??""}class Ss extends Error{constructor(a,r){super(a);sn(this,"status");this.name="ApiError",this.status=r}}async function Se(e,t){let a;try{a=await fetch(Ry()+e,{...t,headers:{Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers}})}catch(o){throw new Ss(o instanceof Error?o.message:"Network request failed",0)}if(!a.ok){const o=await a.text().catch(()=>"");throw new Ss(o.trim()||`${a.status} ${a.statusText}`,a.status)}if(a.status===204)return;const r=await a.text();if(r)return JSON.parse(r)}function sa(e,...t){if(Array.isArray(e))return e;if(e&&typeof e=="object"){const a=e;for(const r of[...t,"data","items"])if(Array.isArray(a[r]))return a[r]}return[]}async function A5(){return sa(await Se("/api/repos"),"repos")}async function C5(e,t,a,r){return Se("/api/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,localPath:a,runtimeType:r})})}async function w5(e){return Se("/api/repos/resolve",{method:"POST",body:JSON.stringify({localPath:e})})}async function k5(e){await Se(`/api/repos/${encodeURIComponent(e)}`,{method:"DELETE"})}async function R5(e){await Se(`/api/repos/${encodeURIComponent(e)}/start`,{method:"POST"})}async function O5(e){await Se(`/api/repos/${encodeURIComponent(e)}/stop`,{method:"POST"})}async function I5(e){return Se(`/api/repos/${encodeURIComponent(e)}/branches`)}async function M5(e,t){return Se(`/api/repos/${encodeURIComponent(e)}/checkout`,{method:"POST",body:JSON.stringify({branch:t})})}async function D5(e){return Se(`/api/repos/${encodeURIComponent(e)}/pull`,{method:"POST"})}function Ge(e){return`/api/repos/${encodeURIComponent(e)}`}async function L5(e){return sa(await Se(`${Ge(e)}/workspaces`),"workspaces")}async function j5(e,t){await Se(`${Ge(e)}/workspaces/${encodeURIComponent(t)}`,{method:"DELETE"})}async function B5(e){return Se(`${Ge(e)}/workspaces/cleanup`,{method:"POST"})}async function P5(e,t){await Se(`/api/repos/${e}/worktree`,{method:"PATCH",body:JSON.stringify({enabled:t})})}async function U5(e,t){await Se(`/api/repos/${e}/runtime`,{method:"PATCH",body:JSON.stringify({runtimeType:t})})}async function H5(e){return sa(await Se(`${Ge(e)}/sessions`),"sessions")}async function F5(e,t,a,r,o,u,c,f){return Se(`${Ge(e)}/sessions`,{method:"POST",body:JSON.stringify({message:t,agent:a,model:r,variant:o,issueId:u,customAgentId:c,files:f})})}async function z5(e,t){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function $5(e,t,a,r,o,u,c){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/prompt`,{method:"POST",body:JSON.stringify({content:a,agent:r,model:o,variant:u,files:c})})}async function q5(e,t){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/abort`,{method:"POST"})}async function Y5(e,t,a){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/questions/reply`,{method:"POST",body:JSON.stringify({answers:a})})}async function G5(e,t){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/questions/reject`,{method:"POST"})}async function K5(e,t,a){return Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/revert`,{method:"POST",body:JSON.stringify({messageID:a})})}function Sx(e){const t=e,a=t.info;if(a&&typeof a.id=="string"){const r=Array.isArray(t.parts)?t.parts:void 0;return{...a,...r?{parts:r}:{}}}return t}async function Ax(e,t,a){const r=new URLSearchParams;a!=null&&a.limit&&r.set("limit",String(a.limit)),a!=null&&a.before&&r.set("before",a.before);const o=r.toString(),u=`${Ge(e)}/sessions/${encodeURIComponent(t)}/messages${o?`?${o}`:""}`,c=await Se(u);if(Array.isArray(c)){const h=c.map(Sx);return{messages:h,total:h.length,hasMore:!1}}const f=c,m=Array.isArray(f.messages)?f.messages:[];return{messages:m.map(Sx),total:f.total??m.length,hasMore:f.hasMore??!1}}async function V5(e,t){return Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/status`)}async function X5(e,t){return Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/links`)}async function Q5(e,t){return Se(`${Ge(e)}/sessions/snapshot/${encodeURIComponent(t)}`)}async function Oy(e){return Se(`${Ge(e)}/sessions/all-links`)}async function W5(e,t,a,r){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"POST",body:JSON.stringify({type:a,targetId:r})})}async function Z5(e,t,a,r){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"DELETE",body:JSON.stringify({type:a,targetId:r})})}async function Iy(){return sa(await Se("/api/custom-agents"))}async function J5(e){return Se("/api/custom-agents",{method:"POST",body:JSON.stringify(e)})}async function eC(e,t){return Se(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function My(e){await Se(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"DELETE"})}async function Cx(e){return Se(`/api/custom-agents/${encodeURIComponent(e)}/export`)}async function tC(e){return Se("/api/custom-agents/import",{method:"POST",body:JSON.stringify(e)})}async function Dy(e,t){const a=new URLSearchParams;t!=null&&t.category&&a.set("category",t.category),t!=null&&t.includeSuperseded&&a.set("includeSuperseded","true");const r=a.toString();return Se(`/api/custom-agents/${encodeURIComponent(e)}/memories${r?`?${r}`:""}`)}async function nC(e,t,a){return Se(`/api/custom-agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(a)})}async function aC(e,t){await Se(`/api/custom-agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t)}`,{method:"DELETE"})}async function sC(e,t){return Se(`/api/custom-agents/${encodeURIComponent(e)}/memories/extract`,{method:"POST",body:JSON.stringify({sessionIds:t})})}async function Xh(e){return Se(`/api/custom-agents/${encodeURIComponent(e)}/sessions`)}async function Ly(e){return sa(await Se(`${Ge(e)}/custom-agents`))}async function rC(e,t){return Se(`${Ge(e)}/custom-agents`,{method:"POST",body:JSON.stringify(t)})}async function Ro(e){return sa(await Se(`${Ge(e)}/models`))}async function jy(){return sa(await Se("/api/prompt-fragments"))}async function iC(e){return Se("/api/prompt-fragments",{method:"POST",body:JSON.stringify(e)})}async function lC(e,t){return Se(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function oC(e){await Se(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"DELETE"})}async function wx(e){return sa(await Se(`${Ge(e)}/tags`))}async function kx(e,t){return sa(await Se(`${Ge(e)}/milestones`))}async function Rx(e,t="open"){return sa(await Se(`${Ge(e)}/issues?state=${encodeURIComponent(t)}`),"issues")}async function uC(e,t="all"){return Se(`${Ge(e)}/issues/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function cC(e,t,a){return Se(`${Ge(e)}/issues`,{method:"POST",body:JSON.stringify({title:t,body:a})})}async function dC(e,t,a){await Se(`${Ge(e)}/issues/${t}/children`,{method:"POST",body:JSON.stringify({childNumber:a})})}async function By(e,t,a){return Se(`${Ge(e)}/issues/${t}`,{method:"PATCH",body:JSON.stringify(a)})}async function fC(e,t){return sa(await Se(`${Ge(e)}/issues/${t}/pulls`))}async function Ox(e,t="open"){return sa(await Se(`${Ge(e)}/pulls?state=${encodeURIComponent(t)}`))}async function mC(e,t="all"){return Se(`${Ge(e)}/pulls/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function hC(e,t){return Se(`${Ge(e)}/pulls/${t}`)}async function pC(e,t){await Se(`${Ge(e)}/pulls/${t}/merge`,{method:"POST"})}async function Qh(e,t){return sa(await Se(`${Ge(e)}/pulls/${t}/issues`))}async function gC(e,t,a){await Se(`${Ge(e)}/pulls/${t}/issues`,{method:"POST",body:JSON.stringify({issueNumber:a})})}async function bC(e,t,a){await Se(`${Ge(e)}/pulls/${t}/issues/${a}`,{method:"DELETE"})}async function xC(e,t){return Se(`${Ge(e)}/pulls/${t}/comments`)}async function EC(e,t){return Se(`${Ge(e)}/issues/${t}/comments`)}async function Ix(e,t,a){return Se(`${Ge(e)}/issues/${t}/comments`,{method:"POST",body:JSON.stringify({body:a})})}async function yC(e,t,a){return Se(`${Ge(e)}/issues/${t}/polish`,{method:"POST",body:JSON.stringify({draft:a})})}async function Mx(e,t){return Se(`${Ge(e)}/issues/${t}/draft`)}async function NC(e,t,a){return Se(`${Ge(e)}/issues/polish-create`,{method:"POST",body:JSON.stringify({title:t,body:a})})}async function Dx(e){return Se(`${Ge(e)}/issues/draft-create`)}async function TC(e){await Se(`${Ge(e)}/issues/draft-create`,{method:"DELETE"})}async function _C(e,t,a){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({title:a})})}async function vC(e,t,a){await Se(`${Ge(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({completedAt:a})})}async function SC(){return Se("/api/agents-md")}async function AC(e){await Se("/api/agents-md",{method:"PUT",body:JSON.stringify({content:e})})}async function CC(e){return Se(`/api/repos/${encodeURIComponent(e)}/agents-md`)}async function wC(e,t){await Se(`/api/repos/${encodeURIComponent(e)}/agents-md`,{method:"PUT",body:JSON.stringify({content:t})})}function kC(e){return`${Ry()}${Ge(e)}/events`}async function RC(e){return Se(`${Ge(e)}/sessions/status`)}async function Oo(){return Se("/api/settings")}async function rh(e,t){await Se(`/api/settings/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({value:t})})}async function ih(){return Se("/api/cloud/status")}async function OC(){return Se("/api/cloud/reload",{method:"POST"})}async function IC(e){try{return(await Se("/api/cloud/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).connected}catch{return!1}}async function MC(){return sa(await Se("/api/git-hosts"),"gitHosts")}async function DC(e,t,a,r="gitea"){return Se("/api/git-hosts",{method:"POST",body:JSON.stringify({host:e,name:t,token:a,platform:r})})}async function LC(e){await Se(`/api/git-hosts/${encodeURIComponent(e)}`,{method:"DELETE"})}async function Py(){return Se("/api/usage")}async function Uy(e){return Se("/api/usage/switch",{method:"POST",body:JSON.stringify({accountId:e})})}async function jC(e,t="ios"){await Se("/api/push/register",{method:"POST",body:JSON.stringify({token:e,platform:t})})}const ar="fs-active-repo",je=es((e,t)=>({repos:[],activeRepoId:localStorage.getItem(ar),loading:!1,loadError:null,loadRepos:async()=>{e({loading:!0,loadError:null});try{const a=await A5(),r=t().activeRepoId,o=r&&a.some(c=>c.id===r);e({repos:a,loading:!1,activeRepoId:o?r:a.length>0?a[0].id:null});const u=t().activeRepoId;u?localStorage.setItem(ar,u):localStorage.removeItem(ar)}catch(a){e({loading:!1,loadError:a instanceof Error?a.message:"Failed to load repos"})}},setActiveRepo:a=>{e({activeRepoId:a}),a?localStorage.setItem(ar,a):localStorage.removeItem(ar)},addRepo:async(a,r,o,u)=>{try{const c=await C5(a,r,o,u);return e(f=>({repos:[...f.repos,c],activeRepoId:c.id})),localStorage.setItem(ar,c.id),c}catch(c){return e({loadError:c instanceof Error?c.message:"Failed to add repo"}),null}},removeRepo:async a=>{try{await k5(a)}catch{}e(r=>{const o=r.repos.filter(c=>c.id!==a),u=r.activeRepoId===a?o.length>0?o[0].id:null:r.activeRepoId;return u?localStorage.setItem(ar,u):localStorage.removeItem(ar),{repos:o,activeRepoId:u}})},updateRepoBranch:(a,r)=>{e(o=>({repos:o.repos.map(u=>u.id===a?{...u,branch:r}:u)}))}})),zn=e=>{var t;return((t=e.repos.find(a=>a.id===e.activeRepoId))==null?void 0:t.name)??null},Lx="fs-nav-collapsed",jx="fs-session-panel-collapsed",Cc=es(e=>({navCollapsed:localStorage.getItem(Lx)==="true",sessionPanelCollapsed:localStorage.getItem(jx)==="true",toggleNav(){e(t=>{const a=!t.navCollapsed;return localStorage.setItem(Lx,String(a)),{navCollapsed:a}})},toggleSessionPanel(){e(t=>{const a=!t.sessionPanelCollapsed;return localStorage.setItem(jx,String(a)),{sessionPanelCollapsed:a}})}})),Hy=[{segment:"run",icon:Kh,label:"运行面板",global:!1},{segment:"dev/issues",icon:a3,label:"研发",global:!1,matchPrefix:"dev"},{segment:"agents",icon:DA,label:"Agents",global:!1}];function Fy(e,t,a){return t?`/${e}`:a?`/${encodeURIComponent(a)}/${e}`:`/${e}`}function zy(e,t,a){if(!e.matchPrefix)return!1;const r=e.global?`/${e.matchPrefix}`:a?`/${encodeURIComponent(a)}/${e.matchPrefix}`:null;return r?t===r||t.startsWith(`${r}/`):!1}function BC(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function PC({repos:e,activeRepoId:t,onRepoChange:a}){const r=vn(),[o,u]=T.useState(!1),c=T.useRef(null),f=e.find(h=>h.id===t),m=T.useCallback(()=>u(!1),[]);return T.useEffect(()=>{if(!o)return;const h=b=>{c.current&&!c.current.contains(b.target)&&m()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[o,m]),i.jsxs("div",{ref:c,className:"relative",children:[i.jsxs("button",{type:"button",onClick:()=>u(h=>!h),className:"flex max-w-[140px] items-center gap-1 rounded-md border border-line bg-base px-2 py-1 text-xs text-fg-2 transition-colors hover:border-blue-500 sm:max-w-[200px]",children:[i.jsx(xy,{className:"h-3 w-3 shrink-0 text-fg-4"}),i.jsxs("span",{className:"truncate",children:[i.jsx("span",{className:"sm:hidden",children:f?BC(f.name):""}),i.jsx("span",{className:"hidden sm:inline",children:(f==null?void 0:f.name)??""})]}),i.jsx(ba,{className:ne("h-3 w-3 shrink-0 text-fg-4 transition-transform",o&&"rotate-180")})]}),o&&i.jsxs("div",{className:"absolute left-0 top-full z-50 mt-1 w-64 overflow-hidden rounded-lg border border-line bg-surface shadow-lg",children:[i.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:e.map(h=>i.jsxs("button",{type:"button",onClick:()=>{a(h.id),m()},className:ne("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors",h.id===t?"font-medium text-blue-600":"text-fg-2 hover:bg-elevated"),children:[h.id===t?i.jsx(On,{className:"h-3 w-3 shrink-0"}):i.jsx("span",{className:"h-3 w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:h.name})]},h.id))}),i.jsx("div",{className:"border-t border-line",children:i.jsxs("button",{type:"button",onClick:()=>{r("/repos"),m()},className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:[i.jsx(Vh,{className:"h-3 w-3 shrink-0"}),i.jsx("span",{children:"管理仓库"})]})})]})]})}function UC({repoId:e,currentBranch:t}){const a=je(S=>S.updateRepoBranch),[r,o]=T.useState(!1),[u,c]=T.useState(null),[f,m]=T.useState(!1),[h,b]=T.useState(null),[g,y]=T.useState(null),N=T.useRef(null),v=T.useCallback(()=>{o(!1),y(null)},[]);T.useEffect(()=>{if(!r)return;const S=M=>{N.current&&!N.current.contains(M.target)&&v()};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[r,v]);const A=async()=>{if(r){v();return}o(!0),m(!0),y(null);try{c(await I5(e))}catch{y("加载分支失败")}finally{m(!1)}},C=async S=>{if(!(S===t||h)){b(S),y(null);try{const M=await M5(e,S);a(e,M.branch),v()}catch(M){y(M instanceof Error?M.message:"切换失败")}finally{b(null)}}};return t?i.jsxs("div",{ref:N,className:"relative",children:[i.jsxs("button",{type:"button",onClick:A,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:[i.jsx(ko,{className:"h-3 w-3"}),t,i.jsx(ba,{className:ne("h-3 w-3 transition-transform",r&&"rotate-180")})]}),r&&i.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?i.jsx("div",{className:"flex items-center justify-center py-4",children:i.jsx(ln,{className:"h-4 w-4 animate-spin text-fg-4"})}):u?i.jsxs("div",{className:"max-h-64 overflow-y-auto py-1",children:[u.local.map(S=>i.jsxs("button",{type:"button",disabled:h!==null,onClick:()=>C(S),className:ne("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors",S===t?"font-medium text-blue-600":"text-fg-2 hover:bg-elevated"),children:[S===t?i.jsx(On,{className:"h-3 w-3 shrink-0"}):h===S?i.jsx(ln,{className:"h-3 w-3 shrink-0 animate-spin"}):i.jsx("span",{className:"h-3 w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:S})]},S)),u.remote.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"mx-3 my-1 border-t border-line"}),i.jsx("div",{className:"px-3 py-1 text-[10px] font-medium uppercase tracking-wider text-fg-4",children:"Remote"}),u.remote.map(S=>i.jsxs("button",{type:"button",disabled:h!==null,onClick:()=>C(S),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===S?i.jsx(ln,{className:"h-3 w-3 shrink-0 animate-spin"}):i.jsx("span",{className:"h-3 w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:S})]},`remote-${S}`))]})]}):null,g&&i.jsx("div",{className:"border-t border-line px-3 py-2 text-xs text-red-500",children:g})]})]}):null}function HC(){const[e,t]=T.useState(null);return T.useEffect(()=>{const a=()=>fetch("/api/health").then(u=>u.json()).then(u=>{u.latestVersion&&u.latestVersion!=="0.10.11"&&t(u.latestVersion)}).catch(()=>{});a();const r=setInterval(a,30*6e4),o=()=>a();return window.addEventListener("focus",o),()=>{clearInterval(r),window.removeEventListener("focus",o)}},[]),e}function FC(){const e=vn(),t=_n(),a=je(g=>g.repos),r=je(g=>g.activeRepoId),o=je(g=>g.setActiveRepo),u=ah(g=>g.preference),c=ah(g=>g.cycle),f=u==="light"?d5:u==="dark"?Y3:$3,m=a.find(g=>g.id===r),h=HC(),b=g=>{var A;if(!g)return;o(g);const y=a.find(C=>C.id===g);if(!y)return;const N=t.pathname.match(/\/dev\/(issues|pulls)/);if(N){e(`/${encodeURIComponent(y.name)}/dev/${N[1]}`);return}const v=((A=t.pathname.match(/\/(run|agents|issues|pulls)/))==null?void 0:A[1])??"run";e(`/${encodeURIComponent(y.name)}/${v}`)};return i.jsxs("header",{className:"shrink-0 border-b border-line bg-surface pt-[var(--safe-top)]",children:[i.jsxs("div",{className:"flex h-12 items-center justify-between px-4",children:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(Qc,{className:"h-5 w-5 text-blue-500"}),i.jsx("span",{className:"hidden text-sm font-bold tracking-tight text-fg sm:inline",children:"Fourth Spark"}),i.jsxs("span",{className:"hidden rounded bg-elevated px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-fg-4 sm:inline",children:["v","0.10.11"]}),h&&i.jsxs("span",{className:"hidden text-[10px] text-amber-500 sm:inline",children:["→ v",h," 可用,运行 ",i.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[a.length>0&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(PC,{repos:a,activeRepoId:r,onRepoChange:b}),m&&r&&i.jsx(UC,{repoId:r,currentBranch:m.branch})]}),i.jsx("button",{type:"button",onClick:()=>e("/settings"),"aria-label":"设置",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:i.jsx(Vh,{className:"h-4 w-4"})}),i.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:i.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:i.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"})})}),i.jsx("button",{type:"button",onClick:c,"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:i.jsx(f,{className:"h-4 w-4"})})]})]}),h&&i.jsx("div",{className:"border-t border-line px-4 py-1.5 sm:hidden",children:i.jsxs("span",{className:"text-[10px] text-amber-500",children:["→ v",h," 可用,运行 ",i.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})})]})}function zC(){const e=je(zn),t=Cc(o=>o.navCollapsed),a=Cc(o=>o.toggleNav),r=_n();return i.jsxs("nav",{className:ne("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:[i.jsx("div",{className:"flex flex-1 flex-col",children:Hy.map(o=>{const u=zy(o,r.pathname,e);return i.jsxs(vc,{to:Fy(o.segment,o.global,e),title:t?o.label:void 0,className:({isActive:c})=>ne("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",c||u?"bg-blue-500/10 font-medium text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:[i.jsx(o.icon,{className:"h-4 w-4 shrink-0"}),i.jsx("span",{className:ne("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:o.label})]},o.segment)})}),i.jsxs(vc,{to:"/settings",title:t?"设置":void 0,className:({isActive:o})=>ne("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",o?"bg-blue-500/10 font-medium text-blue-600":"text-fg-4 hover:bg-elevated hover:text-fg-2"),children:[i.jsx(Vh,{className:"h-4 w-4 shrink-0"}),i.jsx("span",{className:ne("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:"设置"})]}),i.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?i.jsx(GA,{className:"h-4 w-4"}):i.jsx(qA,{className:"h-4 w-4"})})]})}function $C(){const e=je(zn),t=_n();return i.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:i.jsx("div",{className:"flex h-14 items-center justify-around",children:Hy.map(a=>{const r=zy(a,t.pathname,e);return i.jsx(vc,{to:Fy(a.segment,a.global,e),"aria-label":a.label,className:({isActive:o})=>ne("flex h-10 w-10 items-center justify-center rounded-md transition-colors",o||r?"bg-blue-500/10 text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:i.jsx(a.icon,{className:"h-5 w-5 shrink-0"})},a.segment)})})})}function qC(){return i.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-base text-fg",children:[i.jsx(FC,{}),i.jsxs("div",{className:"flex min-h-0 flex-1",children:[i.jsx(zC,{}),i.jsx("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden pb-[calc(3.5rem_+_var(--safe-bottom))] md:pb-0",children:i.jsx(jS,{})})]}),i.jsx($C,{})]})}let YC=0;const Qt=es(e=>({toasts:[],addToast:(t,a="info",r,o)=>{const u=(o==null?void 0:o.id)??`toast-${++YC}-${Date.now()}`;e(c=>c.toasts.some(f=>f.id===u)?c:{toasts:[...c.toasts,{id:u,message:t,variant:a,sessionId:r,persistent:o==null?void 0:o.persistent}]}),o!=null&&o.persistent||setTimeout(()=>{e(c=>({toasts:c.toasts.filter(f=>f.id!==u)}))},4e3)},removeToast:t=>{e(a=>({toasts:a.toasts.filter(r=>r.id!==t)}))}}));function GC({onClose:e}){const[t,a]=T.useState(""),[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState("opencode"),[h,b]=T.useState(!1),[g,y]=T.useState(""),N=je(M=>M.addRepo),v=r.trim()!==""&&u.trim()!==""&&t.trim()!==""&&!h,A=async M=>{const O=M.trim();if(O){b(!0),y("");try{const j=await w5(O);j.name&&!r.trim()&&o(j.name),j.gitUrl&&!u.trim()&&c(j.gitUrl)}catch(j){const I=j instanceof Error?j.message:"无法解析路径";try{const U=JSON.parse(I);y(U.error??I)}catch{y(I)}}b(!1)}},C=T.useRef(A);C.current=A,T.useEffect(()=>{const M=t.trim();if(!M)return;const O=setTimeout(()=>{C.current(M)},500);return()=>clearTimeout(O)},[t]);const S=async()=>{if(!v)return;y(""),await N(r.trim(),u.trim(),t.trim(),f)&&e()};return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:e,children:i.jsxs("div",{className:"w-full max-w-md rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:M=>M.stopPropagation(),children:[i.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[i.jsx("h2",{className:"text-base font-semibold text-fg",children:"添加仓库"}),i.jsx("button",{type:"button",onClick:e,className:"rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:i.jsx(gt,{className:"h-4 w-4"})})]}),i.jsxs("div",{className:"flex flex-col gap-4",children:[i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{htmlFor:"m-path",className:"text-xs font-medium text-fg-3",children:"本地路径"}),i.jsx("input",{id:"m-path",value:t,onChange:M=>a(M.target.value),onBlur:M=>void A(M.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"}),i.jsx("span",{className:"text-[11px] text-fg-5",children:h?"正在读取 Git 信息…":"输入路径后自动读取仓库信息"})]}),i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{htmlFor:"m-name",className:"text-xs font-medium text-fg-3",children:"名称"}),i.jsx("input",{id:"m-name",value:r,onChange:M=>o(M.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"})]}),i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{htmlFor:"m-git",className:"text-xs font-medium text-fg-3",children:"Git 远程地址"}),i.jsx("input",{id:"m-git",value:u,onChange:M=>c(M.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"})]}),i.jsxs("div",{className:"flex flex-col gap-1.5",children:[i.jsx("label",{className:"text-xs font-medium text-fg-3",children:"运行时"}),i.jsx("div",{className:"flex gap-2",children:[{value:"opencode",label:"OpenCode"},{value:"claude-code",label:"Claude Code"}].map(M=>i.jsx("button",{type:"button",onClick:()=>m(M.value),className:`flex-1 rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${f===M.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:M.label},M.value))}),i.jsx("span",{className:"text-[11px] text-fg-5",children:f==="claude-code"?"需要本地安装 Claude Code CLI":"需要本地安装 OpenCode CLI"})]}),g&&i.jsx("p",{className:"rounded-md bg-red-500/10 px-3 py-2 text-xs text-red-500",children:g}),i.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[i.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:"取消"}),i.jsx("button",{type:"button",onClick:S,disabled:!v,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 KC({repoId:e,repoName:t,onClose:a}){const[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState(!0),[h,b]=T.useState(!1),[g,y]=T.useState(null);T.useEffect(()=>{CC(e).then(A=>{o(A.content),c(A.content),m(!1)}).catch(A=>{y(A instanceof Error?A.message:String(A)),m(!1)})},[e]);const N=async()=>{b(!0),y(null);try{await wC(e,r),c(r)}catch(A){y(A instanceof Error?A.message:String(A))}b(!1)},v=r!==u;return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:a,children:i.jsxs("div",{className:"flex w-full max-w-2xl flex-col rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:A=>A.stopPropagation(),children:[i.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsxs("h2",{className:"text-base font-semibold text-fg",children:[t," — AGENTS.md"]}),i.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"仅对此仓库生效,修改后 opencode 热加载即时生效。"})]}),i.jsx("button",{type:"button",onClick:a,className:"shrink-0 rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:i.jsx(gt,{className:"h-4 w-4"})})]}),g&&i.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:[i.jsx(Tn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 break-words",children:g})]}),f?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[i.jsx(ln,{className:"h-5 w-5 fs-spin"}),i.jsx("p",{className:"text-xs",children:"加载中…"})]}):i.jsx("textarea",{value:r,onChange:A=>o(A.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
461
461
 
462
- 在此编写该仓库的 Agent 指令…`}),i.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[i.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:"关闭"}),i.jsxs("button",{type:"button",onClick:()=>void N(),disabled:h||!v,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:[i.jsx(Xc,{className:"h-3.5 w-3.5"}),h?"保存中…":"保存"]})]})]})})}const lh=1024,oh=lh*1024,Bx=oh*1024;function Px(e){return!e||e<=0?"0 B":e<lh?`${e} B`:e<oh?`${(e/lh).toFixed(1)} KB`:e<Bx?`${(e/oh).toFixed(1)} MB`:`${(e/Bx).toFixed(2)} GB`}const Tm="ws/";function VC({repoId:e}){const[t,a]=T.useState(!1),[r,o]=T.useState(null),[u,c]=T.useState(!1),[f,m]=T.useState(null),[h,b]=T.useState(null),[g,y]=T.useState(!1),N=async()=>{c(!0),m(null);try{const M=await L5(e);o(M)}catch(M){m(M instanceof Ss?M.message:"加载失败")}c(!1)};T.useEffect(()=>{t&&r===null&&N()},[t]);const v=async M=>{b(M);try{await j5(e,M),await N()}catch(O){m(O instanceof Ss?O.message:"删除失败")}b(null)},A=async()=>{y(!0);try{await B5(e),await N()}catch(M){m(M instanceof Ss?M.message:"清理失败")}y(!1)},C=(r==null?void 0:r.length)??0,S=(r==null?void 0:r.reduce((M,O)=>M+(O.diskUsage||0),0))??0;return i.jsxs("div",{className:"mt-3 border-t border-line pt-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>a(M=>!M),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?i.jsx(zA,{className:"h-3 w-3 shrink-0"}):i.jsx(ba,{className:"h-3 w-3 shrink-0"}),i.jsx(ko,{className:"h-3 w-3 shrink-0 text-fg-5"}),i.jsx("span",{children:"工作空间"}),r!==null&&i.jsxs("span",{className:"text-fg-5",children:["(",C,") · ",Px(S)]})]}),t&&C>0&&i.jsxs("button",{type:"button",onClick:()=>void A(),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?i.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):null,"清理已合并"]})]}),t&&i.jsxs("div",{className:"mt-2",children:[f&&i.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:[i.jsx("span",{className:"truncate",children:f}),i.jsx("button",{type:"button",onClick:()=>m(null),className:"shrink-0 rounded p-0.5 transition-colors hover:bg-red-500/10",children:i.jsx(gt,{className:"h-3 w-3"})})]}),u&&r===null?i.jsx("div",{className:"flex justify-center py-3",children:i.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-fg-5 border-t-transparent"})}):C===0?i.jsx("p",{className:"py-2 text-center text-xs text-fg-5",children:"暂无工作空间"}):i.jsx("ul",{className:"space-y-1",children:r==null?void 0:r.map(M=>{const O=M.branch.startsWith(Tm),j=O?M.branch.slice(Tm.length):M.branch,I=M.status==="active"?"bg-emerald-500/10 text-emerald-600":M.status==="idle"?"bg-amber-500/10 text-amber-600":"bg-fg-6/30 text-fg-4",U=M.status==="active"?"活跃":M.status==="idle"?"空闲":M.status==="merged"?"已合并":M.status==="stale"?"陈旧":M.status,$=M.status!=="active";return i.jsxs("li",{className:"flex items-center gap-2 rounded-md border border-line bg-elevated/40 px-2 py-1.5 text-xs",children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[M.running&&M.port&&i.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",title:`运行中 :${M.port}`}),i.jsxs("span",{className:"min-w-0 truncate font-mono",children:[O&&i.jsx("span",{className:"text-fg-5",children:Tm}),i.jsx("span",{className:"text-fg-2",children:j})]})]}),i.jsx("span",{className:ne("shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium",I),children:U}),i.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-fg-5",children:[i.jsx(v3,{className:"h-2.5 w-2.5"}),Px(M.diskUsage)]}),i.jsx("button",{type:"button",onClick:()=>void v(M.id),disabled:!$||h===M.id,title:$?"删除工作空间":"活跃工作空间无法删除",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===M.id?i.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):i.jsx(Cs,{className:"h-3 w-3"})})]},M.id)})})]})]})}function $y(){const e=je(I=>I.repos),t=je(I=>I.activeRepoId),a=je(I=>I.setActiveRepo),r=je(I=>I.removeRepo),o=je(I=>I.loadRepos),[u,c]=T.useState(!1),[f,m]=T.useState(null),[h,b]=T.useState(null),[g,y]=T.useState(null),N=Qt(I=>I.addToast),[v,A]=T.useState(null),[C,S]=T.useState(null),M=T.useRef(null);T.useEffect(()=>{if(!C)return;const I=U=>{M.current&&!M.current.contains(U.target)&&S(null)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[C]);const O=async(I,U)=>{b(I);try{U?await O5(I):await R5(I),await o()}catch{}b(null)},j=async I=>{y(I);try{const U=await D5(I);await o();const $=U.alreadyUpToDate?"info":"success";N(U.summary,$,void 0,{persistent:!0})}catch(U){let $="拉取失败";if(U instanceof Ss)try{$=JSON.parse(U.message).error??U.message}catch{$=U.message}N($,"error",void 0,{persistent:!0})}y(null)};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-6 flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h1",{className:"text-lg font-semibold text-fg",children:"仓库管理"}),i.jsx("p",{className:"mt-0.5 text-sm text-fg-4",children:"管理代码仓库,每个仓库对应一个独立的 Agent 运行环境"})]}),i.jsxs("button",{type:"button",onClick:()=>c(!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:[i.jsx(Ia,{className:"h-4 w-4"}),i.jsx("span",{className:"hidden md:inline",children:"添加仓库"})]})]}),e.length===0?i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed border-line-hard py-16 text-center",children:[i.jsx("div",{className:"rounded-full bg-elevated p-3",children:i.jsx(Ia,{className:"h-6 w-6 text-fg-4"})}),i.jsx("p",{className:"text-sm font-medium text-fg-3",children:"暂无代码仓库"}),i.jsx("p",{className:"text-xs text-fg-5",children:"添加一个本地仓库开始使用"}),i.jsx("button",{type:"button",onClick:()=>c(!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:"添加仓库"})]}):i.jsx(i.Fragment,{children:i.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:e.map(I=>{const U=I.id===t;return i.jsxs("div",{className:ne("rounded-xl border p-4 transition-colors",U?"border-blue-500/40 bg-blue-500/5":"border-line"),children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>a(I.id),className:"flex min-w-0 items-center gap-2 text-left",children:[U?i.jsx(Yr,{className:"h-4 w-4 shrink-0 text-blue-500"}):i.jsx(WA,{className:"h-4 w-4 shrink-0 text-fg-5"}),i.jsx("span",{className:ne("truncate font-medium",U?"text-fg":"text-fg-2"),children:I.name})]}),i.jsxs("span",{className:ne("inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium",I.running?"bg-emerald-500/10 text-emerald-600":"bg-fg-6/30 text-fg-4"),children:[i.jsx("span",{className:ne("h-1.5 w-1.5 rounded-full",I.running?"bg-emerald-500":"bg-fg-5")}),I.running?"运行中":"已停止"]})]}),i.jsxs("dl",{className:"mt-3 space-y-1 font-mono text-xs text-fg-4",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx("dt",{className:"shrink-0 text-fg-5",children:"Git"}),i.jsx("dd",{className:"min-w-0 truncate",children:I.gitUrl})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("dt",{className:"shrink-0 text-fg-5",children:"路径"}),i.jsxs("dd",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("span",{className:"truncate",children:I.localPath}),i.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(I.localPath),title:"复制路径",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:i.jsx(Sc,{className:"h-3 w-3"})})]})]}),I.running&&I.port&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("dt",{className:"shrink-0 text-fg-5",children:"直连"}),i.jsxs("dd",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsxs("a",{href:`http://127.0.0.1:${I.port}`,target:"_blank",rel:"noopener noreferrer",className:"truncate text-blue-500 hover:underline",children:["127.0.0.1:",I.port]}),i.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(`http://127.0.0.1:${I.port}`),title:"复制链接",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:i.jsx(Sc,{className:"h-3 w-3"})})]})]})]}),i.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>void j(I.id),disabled:g===I.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===I.id?i.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):i.jsxs(i.Fragment,{children:[i.jsx(AA,{className:"h-3 w-3"}),"拉取"]})}),i.jsx("button",{type:"button",onClick:()=>void O(I.id,I.running),disabled:h===I.id,className:ne("flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md border text-xs font-medium transition-colors disabled:opacity-50",I.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===I.id?i.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):I.running?i.jsxs(i.Fragment,{children:[i.jsx(nh,{className:"h-3 w-3 fill-current"}),"停止"]}):i.jsxs(i.Fragment,{children:[i.jsx(Kh,{className:"h-3 w-3 fill-current"}),"启动"]})}),i.jsxs("div",{className:"relative",ref:C===I.id?M:void 0,children:[i.jsx("button",{type:"button",onClick:()=>S(C===I.id?null:I.id),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 hover:text-fg-2",children:i.jsx(Fh,{className:"h-4 w-4"})}),C===I.id&&i.jsxs("div",{className:"absolute right-0 top-full z-20 mt-1 min-w-[160px] overflow-hidden rounded-lg border border-line bg-elevated shadow-lg",children:[i.jsx("button",{type:"button",className:ne("flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-base/60",I.runtimeType==="claude-code"?"text-orange-500":"text-sky-500"),onClick:async()=>{S(null);const $=I.runtimeType==="claude-code"?"opencode":"claude-code";await U5(I.id,$),o()},children:I.runtimeType==="claude-code"?"Claude → OpenCode":"OpenCode → Claude"}),i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs text-fg-3 transition-colors hover:bg-base/60",onClick:async()=>{S(null),await P5(I.id,!I.worktreeEnabled),o()},children:[i.jsx(ko,{className:"h-3 w-3"}),i.jsx("span",{children:"Worktree"}),i.jsx("span",{className:ne("ml-auto text-[10px]",I.worktreeEnabled?"text-violet-500":"text-fg-5"),children:I.worktreeEnabled?"已开启":"已关闭"})]}),i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs text-fg-3 transition-colors hover:bg-base/60",onClick:()=>{S(null),A({id:I.id,name:I.name})},children:[i.jsx(zh,{className:"h-3 w-3"}),"配置"]}),i.jsx("div",{className:"my-0.5 border-t border-line"}),i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs text-red-500 transition-colors hover:bg-red-500/10",onClick:()=>{S(null),m(I.id)},children:[i.jsx(Cs,{className:"h-3 w-3"}),"删除仓库"]})]})]})]}),f===I.id&&i.jsxs("div",{className:"mt-2 flex items-center justify-between rounded-md border border-red-500/20 bg-red-500/5 px-3 py-2",children:[i.jsx("span",{className:"text-xs text-red-500",children:"确认删除此仓库?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>{r(I.id),m(null)},className:"flex h-6 items-center gap-1 rounded border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10",children:[i.jsx(On,{className:"h-3 w-3"}),"确认"]}),i.jsx("button",{type:"button",onClick:()=>m(null),className:"flex h-6 items-center gap-1 rounded border border-line px-2 text-xs text-fg-4 transition-colors hover:bg-elevated",children:"取消"})]})]}),I.worktreeEnabled&&i.jsx(VC,{repoId:I.id})]},I.id)})})}),i.jsxs("p",{className:"mt-3 text-xs text-fg-5",children:[e.length," 个仓库"]}),u&&i.jsx(GC,{onClose:()=>c(!1)}),v&&i.jsx(KC,{repoId:v.id,repoName:v.name,onClose:()=>A(null)})]})}function XC(){return i.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:i.jsx("div",{className:"mx-auto max-w-4xl",children:i.jsx($y,{})})})}const QC=new Set(["tool","tool-use","tool_use","tool-call","tool_call","tool-result","tool_result"]),WC=new Set(["thinking","reasoning","reason"]),ZC=new Set(["text","output_text","message"]),JC=new Set(["file","image"]);function wc(e){var a;const t=((a=e.type)==null?void 0:a.toLowerCase())??"";return QC.has(t)||e.toolName!=null||e.tool!=null?"tool":JC.has(t)?"file":WC.has(t)?"thinking":ZC.has(t)||e.content!=null||e.text!=null?"text":"other"}function kc(e){return e.content??e.text??""}function qy(e){return e.toolName??e.tool??"tool"}function Wc(e){var t;return e.input??((t=e.state)==null?void 0:t.input)}function Wh(e){var t;return e.output??((t=e.state)==null?void 0:t.output)}function Zh(e){var a,r,o;const t=(r=(a=e.state)==null?void 0:a.status)==null?void 0:r.toLowerCase();return t==="completed"||t==="done"||t==="success"?"completed":t==="error"||t==="failed"||((o=e.state)==null?void 0:o.error)!=null?"error":t==="pending"||t==="queued"?"pending":t==="running"||t==="in_progress"?"running":Wh(e)!=null?"completed":"running"}function Ux(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function $r(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 Yy(e){return e.filter(t=>$r(t.status)==="completed").length}function yo(e){const t=qy(e).toLowerCase();return t==="question"||t==="mcp_question"}function ew(e){const t=Wc(e);if(!t||typeof t!="object")return null;const a=t;return Array.isArray(a.questions)?a.questions:null}function Rc(e){if(!yo(e))return!1;const t=Zh(e);return t==="pending"||t==="running"}const tw=/\bses_[a-zA-Z0-9]+/;function nw(e){var o;const t=Wc(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=(o=e.state)==null?void 0:o.metadata;if(a){const u=a.session_id??a.sessionId;if(typeof u=="string"&&u.startsWith("ses_"))return u}const r=Wh(e);if(typeof r=="string"){const u=tw.exec(r);if(u)return u[0]}if(r&&typeof r=="object"){const u=r,c=u.session_id??u.sessionId??u.task_id;if(typeof c=="string"&&c.startsWith("ses_"))return c}return null}const aw=es(()=>({agents:[],loaded:!1}));function Gy(e){return`question-${e}`}function _m(e,t){const a=t.find(o=>o.id===e),r=(a==null?void 0:a.title)||e.slice(-8);Qt.getState().addToast(`${r} — 等待回复`,"warning",e,{id:Gy(e),persistent:!0})}function sw(e){var t;for(const a of e)if((t=a.parts)!=null&&t.some(r=>yo(r)&&Rc(r)))return!0;return!1}const No=[],To=[],Hx=[],Ir={};function Fx(e){return e.id??e.callID}function kn(){return je.getState().activeRepoId}async function zx(e,t){const a=kn();if(a)try{const[r,o]=await Promise.all([X5(a,e),Oy(a).catch(()=>null)]);t(u=>{const c={sessionLinks:{...u.sessionLinks,[e]:r}};return o&&(c.allSessionLinks=o),c})}catch{}}const $x=20,Re=es((e,t)=>({sessions:[],activeSessionId:null,messages:{},messagesMeta:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},sessionFilter:"active",loadingSessions:!1,loadError:null,sendError:null,setSessionFilter:a=>e({sessionFilter:a}),toggleSessionComplete:async a=>{const r=kn();if(!r)return;const o=t().sessions.find(c=>c.id===a);if(!o)return;const u=o.completedAt?null:Date.now();e(c=>({sessions:c.sessions.map(f=>f.id===a?{...f,completedAt:u??void 0}:f)}));try{await vC(r,a,u)}catch{await t().loadSessions()}},loadSessions:async()=>{const a=kn();if(!a){e({sessions:[],loadingSessions:!1});return}e({loadingSessions:!0,loadError:null});try{const[r,o]=await Promise.all([H5(a),Oy(a).catch(()=>null)]),u={sessions:r,loadingSessions:!1};o&&(u.allSessionLinks=o),e(u)}catch(r){e({loadingSessions:!1,loadError:r instanceof Error?r.message:"Failed to load sessions"})}},createSession:async(a,r,o,u,c,f,m)=>{const h=kn();if(!h)return null;e({sendError:null});try{const b=await F5(h,a,r,o,u,c,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=>{kn()&&(e({activeSessionId:a,sendError:null}),await t().refreshSessionData(a))},refreshSessionData:async a=>{var b,g;const r=kn();if(!r)return;const u=!t().messages[a]||t().messages[a].length===0?{limit:$x}:void 0,[c,f]=await Promise.allSettled([Q5(r,a),Ax(r,a,u)]),m=c.status==="fulfilled"?c.value:null,h=(g=(b=m==null?void 0:m.session)==null?void 0:b.revert)==null?void 0:g.messageID;e(y=>{const N={};if(m&&(m.status&&(N.sessionStatuses={...y.sessionStatuses,[a]:m.status.type}),m.todos&&(N.todos={...y.todos,[a]:m.todos}),m.links&&(N.sessionLinks={...y.sessionLinks,[a]:m.links}),m.session&&(N.sessions=y.sessions.map(v=>v.id===a?{...v,...m.session}:v))),f.status==="fulfilled"){let v=f.value.messages;if(h){const C=v.findIndex(S=>S.id===h);C>=0&&(v=v.slice(0,C+1))}const A=y.messages[a]??[];v.length>=A.length&&(N.messages={...y.messages,[a]:v}),N.messagesMeta={...y.messagesMeta,[a]:{total:Math.max(f.value.total,A.length),hasMore:f.value.hasMore,loading:!1}}}return N}),f.status==="fulfilled"&&sw(f.value.messages)&&_m(a,t().sessions)},loadMoreMessages:async a=>{var f;const r=kn();if(!r)return;const o=t().messagesMeta[a];if(!(o!=null&&o.hasMore)||o.loading)return;const c=(f=(t().messages[a]??[])[0])==null?void 0:f.id;e(m=>({messagesMeta:{...m.messagesMeta,[a]:{...o,loading:!0}}}));try{const m=await Ax(r,a,{limit:$x,before:c});e(h=>{const b=h.messages[a]??[];return{messages:{...h.messages,[a]:[...m.messages,...b]},messagesMeta:{...h.messagesMeta,[a]:{total:m.total,hasMore:m.hasMore,loading:!1}}}})}catch{e(m=>({messagesMeta:{...m.messagesMeta,[a]:{...o,loading:!1}}}))}},addLink:async(a,r,o)=>{const u=kn();if(!u)return!1;try{return await W5(u,a,r,o),await zx(a,e),!0}catch{return!1}},removeLink:async(a,r,o)=>{const u=kn();if(!u)return!1;try{return await Z5(u,a,r,o),await zx(a,e),!0}catch{return!1}},deleteSession:async a=>{const r=kn();if(r)try{await z5(r,a)}catch{}delete Ir[a],e(o=>{const{[a]:u,...c}=o.messages,{[a]:f,...m}=o.messagesMeta,{[a]:h,...b}=o.todos,{[a]:g,...y}=o.sessionStatuses,{[a]:N,...v}=o.errorReasons,{[a]:A,...C}=o.queuedMessageIds,{[a]:S,...M}=o.sessionLinks,{[a]:O,...j}=o.allSessionLinks;return{sessions:o.sessions.filter(I=>I.id!==a),messages:c,messagesMeta:m,todos:b,sessionStatuses:y,errorReasons:v,queuedMessageIds:C,sessionLinks:M,allSessionLinks:j,activeSessionId:o.activeSessionId===a?null:o.activeSessionId}})},sendMessage:async(a,r,o,u)=>{const c=kn(),f=t().activeSessionId;if(!c||!f)return!1;const m=t().sessions.find(b=>b.id===f),h=t().sessionStatuses[f]==="busy";e({sendError:null}),h||t().setSessionStatus(f,"busy");try{const b=aw.getState(),g=m!=null&&m.agent&&b.loaded&&b.agents.some(y=>y.name===m.agent||y.id===m.agent)?m.agent:void 0;return await $5(c,f,a,g,r,o,u),h&&(Ir[f]=(Ir[f]||0)+1),!0}catch(b){return e({sendError:b instanceof Error?b.message:"Failed to send message"}),h||t().setSessionStatus(f,"idle"),!1}},replyQuestion:async a=>{const r=kn(),o=t().activeSessionId;if(!(!r||!o))try{await Y5(r,o,a)}catch(u){e({sendError:u instanceof Error?u.message:"Failed to reply to question"})}},rejectQuestion:async()=>{const a=kn(),r=t().activeSessionId;if(!(!a||!r))try{await G5(a,r)}catch{}},abortSession:async()=>{const a=kn(),r=t().activeSessionId;if(!(!a||!r)){try{await q5(a,r)}catch{}t().setSessionStatus(r,"idle")}},clearSessions:()=>{for(const a of Object.keys(Ir))delete Ir[a];e({sessions:[],activeSessionId:null,messages:{},messagesMeta:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},loadError:null,sendError:null})},updateMessage:(a,r)=>{var o;e(u=>{const c=u.messages[a]??[],f=c.findIndex(g=>g.id===r.id);let m,h=u.queuedMessageIds,b=u.messagesMeta;if(f>=0){const g={...c[f],...r};(!r.parts||r.parts.length===0)&&c[f].parts&&(g.parts=c[f].parts),m=[...c],m[f]=g}else{m=[...c,r];const g=b[a];g&&(b={...b,[a]:{...g,total:g.total+1}});const y=Ir[a]||0;if(r.role==="user"&&y>0){const N=[...h[a]??[]];N.push(r.id),h={...h,[a]:N},Ir[a]=y-1}else if(r.role==="assistant"){const N=h[a];N&&N.length>0&&(h={...h,[a]:N.slice(1)})}}return{messages:{...u.messages,[a]:m},messagesMeta:b,queuedMessageIds:h}}),(o=r.parts)!=null&&o.some(u=>yo(u)&&Rc(u))&&_m(a,t().sessions)},updateMessagePart:(a,r,o)=>{e(u=>{const c=u.messages[a]??[],f=c.findIndex(v=>v.id===r),m=f>=0?c[f]:{id:r,role:"assistant"},h=m.parts?[...m.parts]:[],b=Fx(o),g=b!=null?h.findIndex(v=>Fx(v)===b):-1;g>=0?h[g]={...h[g],...o}:h.push(o);const y={...m,parts:h},N=f>=0?[...c]:[...c,y];return f>=0&&(N[f]=y),{messages:{...u.messages,[a]:N}}}),yo(o)&&Rc(o)&&_m(a,t().sessions)},appendMessagePartDelta:(a,r,o,u)=>{e(c=>{const f=c.messages[a]??[],m=f.findIndex(v=>v.id===r),h=m>=0?f[m]:{id:r,role:"assistant"},b=h.parts?[...h.parts]:[],g=b.findIndex(v=>v.id===o);if(g>=0){const v=b[g],A=kc(v)+u;b[g]=v.content!=null?{...v,content:A}:{...v,text:A}}else b.push({id:o,type:"text",text:u});const y={...h,parts:b},N=m>=0?[...f]:[...f,y];return m>=0&&(N[m]=y),{messages:{...c.messages,[a]:N}}})},updateTodos:(a,r)=>{e(o=>({todos:{...o.todos,[a]:r}}))},updateSessionInfo:a=>{e(r=>r.sessions.some(u=>u.id===a.id)?{sessions:r.sessions.map(u=>u.id===a.id?{...u,...a}:u)}:{sessions:[a,...r.sessions]})},setSessionStatus:(a,r,o)=>{const u=t().sessionStatuses[a];if(u!==r){const c=t().sessions.find(m=>m.id===a),f=(c==null?void 0:c.title)||a.slice(-8);if(r==="idle"&&u!==void 0&&u!=="idle")Qt.getState().removeToast(Gy(a)),Qt.getState().addToast(`${f} — 完成`,"success",a);else if(r==="busy"&&(u===void 0||u==="idle"))Qt.getState().addToast(`${f} — 开始运行`,"info",a);else if(r==="retry")Qt.getState().addToast(`${f} — 进入重试`,"warning",a);else if(r==="error"){const m=o?`${f} — 错误: ${o}`:`${f} — 发生错误`;Qt.getState().addToast(m,"error",a)}}e(c=>{const f=o?{...c.errorReasons,[a]:o}:r!=="error"?(()=>{const{[a]:m,...h}=c.errorReasons;return h})():c.errorReasons;return{sessionStatuses:{...c.sessionStatuses,[a]:r},errorReasons:f}})},bulkSetStatuses:a=>{e({sessionStatuses:{...t().sessionStatuses,...a}})},renameSession:async(a,r)=>{const o=kn();if(o){e(u=>({sessions:u.sessions.map(c=>c.id===a?{...c,title:r}:c)}));try{await _C(o,a,r)}catch{await t().loadSessions()}}},revertToMessage:async(a,r)=>{const o=kn();if(!o)return!1;try{return await K5(o,a,r),await t().refreshSessionData(a),!0}catch{return!1}}})),Ve=es((e,t)=>({issues:[],tags:[],tagFilterMode:new Map,milestones:[],selectedMilestoneId:null,loaded:!1,syncing:!1,selectedIssueId:null,viewingIssueId:null,viewingTreeRootId:null,matchingParentId:null,matchingCandidateId:null,clearIssues:()=>e({issues:[],tags:[],tagFilterMode:new Map,milestones:[],selectedMilestoneId:null,loaded:!1,selectedIssueId:null,viewingIssueId:null,viewingTreeRootId:null,matchingParentId:null,matchingCandidateId:null}),setSelectedIssue:a=>e({selectedIssueId:a}),setViewingIssue:(a,r)=>e({viewingIssueId:a,viewingTreeRootId:r??null}),enterMatchMode:a=>e({matchingParentId:a,matchingCandidateId:null}),exitMatchMode:()=>{e({matchingParentId:null,matchingCandidateId:null})},linkChild:async(a,r)=>{var u;const o=je.getState().activeRepoId;if(!o)return!1;try{await dC(o,a,r);const c=(u=t().issues.find(f=>f.number===a))==null?void 0:u.id;return c&&e(f=>({issues:f.issues.map(m=>m.number===r?{...m,parentId:c}:m),matchingCandidateId:null})),!0}catch{return!1}},updateIssueState:async(a,r)=>{const o=je.getState().activeRepoId;if(!o)return!1;try{const u=await By(o,a,{state:r});return e(c=>({issues:c.issues.map(f=>f.number===a?{...f,state:u.state}:f)})),!0}catch{return!1}},loadIssues:async()=>{const a=je.getState().activeRepoId;if(!a){e({issues:[],loaded:!0});return}try{const r=await Rx(a,"all");e({issues:r,loaded:!0})}catch{e({loaded:!0})}},syncIssues:async()=>{const a=je.getState().activeRepoId;if(a){e({syncing:!0});try{await uC(a,"open");const[r,o,u]=await Promise.all([Rx(a,"all"),wx(a),kx(a)]);e({issues:r,tags:o,milestones:u,syncing:!1})}catch(r){e({syncing:!1});let o="同步 Issue 失败";if(r instanceof Ss)try{const u=JSON.parse(r.message);u.error&&(o=u.error)}catch{r.message&&(o=r.message)}Qt.getState().addToast(o,"error")}}},createIssue:async(a,r)=>{const o=je.getState().activeRepoId;if(!o)return null;try{const u=await cC(o,a,r);return e(c=>({issues:[u,...c.issues]})),u}catch{return null}},loadTags:async()=>{const a=je.getState().activeRepoId;if(!a){e({tags:[]});return}try{const r=await wx(a);e({tags:r})}catch{}},cycleTagFilter:a=>{e(r=>{const o=new Map(r.tagFilterMode),u=o.get(a);return u?u==="include"?o.set(a,"exclude"):o.delete(a):o.set(a,"include"),{tagFilterMode:o}})},clearTagFilter:()=>e({tagFilterMode:new Map}),loadMilestones:async()=>{const a=je.getState().activeRepoId;if(!a){e({milestones:[]});return}try{const r=await kx(a);e({milestones:r})}catch{}},setMilestoneFilter:a=>e({selectedMilestoneId:a})})),xc=es(e=>({drafts:{},setDraft:(t,a)=>e(r=>{if(!a.trim()){const{[t]:o,...u}=r.drafts;return{drafts:u}}return{drafts:{...r.drafts,[t]:a}}}),clearDraft:t=>e(a=>{const{[t]:r,...o}=a.drafts;return{drafts:o}})}));function qx(e){const t=[],a=String(e||"");let r=a.indexOf(","),o=0,u=!1;for(;!u;){r===-1&&(r=a.length,u=!0);const c=a.slice(o,r).trim();(c||!u)&&t.push(c),o=r+1,r=a.indexOf(",",o)}return t}function Ky(e,t){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const rw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,iw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lw={};function Yx(e,t){return(lw.jsx?iw:rw).test(e)}const ow=/[ \t\n\f\r]/g;function uw(e){return typeof e=="object"?e.type==="text"?Gx(e.value):!1:Gx(e)}function Gx(e){return e.replace(ow,"")===""}class Io{constructor(t,a,r){this.normal=a,this.property=t,r&&(this.space=r)}}Io.prototype.normal={};Io.prototype.property={};Io.prototype.space=void 0;function Vy(e,t){const a={},r={};for(const o of e)Object.assign(a,o.property),Object.assign(r,o.normal);return new Io(a,r,t)}function _o(e){return e.toLowerCase()}class ra{constructor(t,a){this.attribute=a,this.property=t}}ra.prototype.attribute="";ra.prototype.booleanish=!1;ra.prototype.boolean=!1;ra.prototype.commaOrSpaceSeparated=!1;ra.prototype.commaSeparated=!1;ra.prototype.defined=!1;ra.prototype.mustUseProperty=!1;ra.prototype.number=!1;ra.prototype.overloadedBoolean=!1;ra.prototype.property="";ra.prototype.spaceSeparated=!1;ra.prototype.space=void 0;let cw=0;const Xe=Gr(),rn=Gr(),uh=Gr(),_e=Gr(),Rt=Gr(),Ur=Gr(),ga=Gr();function Gr(){return 2**++cw}const ch=Object.freeze(Object.defineProperty({__proto__:null,boolean:Xe,booleanish:rn,commaOrSpaceSeparated:ga,commaSeparated:Ur,number:_e,overloadedBoolean:uh,spaceSeparated:Rt},Symbol.toStringTag,{value:"Module"})),vm=Object.keys(ch);class Jh extends ra{constructor(t,a,r,o){let u=-1;if(super(t,a),Kx(this,"space",o),typeof r=="number")for(;++u<vm.length;){const c=vm[u];Kx(this,vm[u],(r&ch[c])===ch[c])}}}Jh.prototype.defined=!0;function Kx(e,t,a){a&&(e[t]=a)}function Zi(e){const t={},a={};for(const[r,o]of Object.entries(e.properties)){const u=new Jh(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(u.mustUseProperty=!0),t[r]=u,a[_o(r)]=r,a[_o(u.attribute)]=r}return new Io(t,a,e.space)}const Xy=Zi({properties:{ariaActiveDescendant:null,ariaAtomic:rn,ariaAutoComplete:null,ariaBusy:rn,ariaChecked:rn,ariaColCount:_e,ariaColIndex:_e,ariaColSpan:_e,ariaControls:Rt,ariaCurrent:null,ariaDescribedBy:Rt,ariaDetails:null,ariaDisabled:rn,ariaDropEffect:Rt,ariaErrorMessage:null,ariaExpanded:rn,ariaFlowTo:Rt,ariaGrabbed:rn,ariaHasPopup:null,ariaHidden:rn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Rt,ariaLevel:_e,ariaLive:null,ariaModal:rn,ariaMultiLine:rn,ariaMultiSelectable:rn,ariaOrientation:null,ariaOwns:Rt,ariaPlaceholder:null,ariaPosInSet:_e,ariaPressed:rn,ariaReadOnly:rn,ariaRelevant:null,ariaRequired:rn,ariaRoleDescription:Rt,ariaRowCount:_e,ariaRowIndex:_e,ariaRowSpan:_e,ariaSelected:rn,ariaSetSize:_e,ariaSort:null,ariaValueMax:_e,ariaValueMin:_e,ariaValueNow:_e,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Qy(e,t){return t in e?e[t]:t}function Wy(e,t){return Qy(e,t.toLowerCase())}const dw=Zi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ur,acceptCharset:Rt,accessKey:Rt,action:null,allow:null,allowFullScreen:Xe,allowPaymentRequest:Xe,allowUserMedia:Xe,alpha:Xe,alt:null,as:null,async:Xe,autoCapitalize:null,autoComplete:Rt,autoFocus:Xe,autoPlay:Xe,blocking:Rt,capture:null,charSet:null,checked:Xe,cite:null,className:Rt,closedBy:null,colorSpace:null,cols:_e,colSpan:_e,command:null,commandFor:null,content:null,contentEditable:rn,controls:Xe,controlsList:Rt,coords:_e|Ur,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Xe,defer:Xe,dir:null,dirName:null,disabled:Xe,download:uh,draggable:rn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Xe,formTarget:null,headers:Rt,height:_e,hidden:uh,high:_e,href:null,hrefLang:null,htmlFor:Rt,httpEquiv:Rt,id:null,imageSizes:null,imageSrcSet:null,inert:Xe,inputMode:null,integrity:null,is:null,isMap:Xe,itemId:null,itemProp:Rt,itemRef:Rt,itemScope:Xe,itemType:Rt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Xe,low:_e,manifest:null,max:null,maxLength:_e,media:null,method:null,min:null,minLength:_e,multiple:Xe,muted:Xe,name:null,nonce:null,noModule:Xe,noValidate:Xe,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:Xe,optimum:_e,pattern:null,ping:Rt,placeholder:null,playsInline:Xe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Xe,referrerPolicy:null,rel:Rt,required:Xe,reversed:Xe,rows:_e,rowSpan:_e,sandbox:Rt,scope:null,scoped:Xe,seamless:Xe,selected:Xe,shadowRootClonable:Xe,shadowRootCustomElementRegistry:Xe,shadowRootDelegatesFocus:Xe,shadowRootMode:null,shadowRootSerializable:Xe,shape:null,size:_e,sizes:null,slot:null,span:_e,spellCheck:rn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:_e,step:null,style:null,tabIndex:_e,target:null,title:null,translate:null,type:null,typeMustMatch:Xe,useMap:null,value:rn,width:_e,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Rt,axis:null,background:null,bgColor:null,border:_e,borderColor:null,bottomMargin:_e,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Xe,declare:Xe,event:null,face:null,frame:null,frameBorder:null,hSpace:_e,leftMargin:_e,link:null,longDesc:null,lowSrc:null,marginHeight:_e,marginWidth:_e,noResize:Xe,noHref:Xe,noShade:Xe,noWrap:Xe,object:null,profile:null,prompt:null,rev:null,rightMargin:_e,rules:null,scheme:null,scrolling:rn,standby:null,summary:null,text:null,topMargin:_e,valueType:null,version:null,vAlign:null,vLink:null,vSpace:_e,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Xe,disablePictureInPicture:Xe,disableRemotePlayback:Xe,exportParts:Ur,part:Rt,prefix:null,property:null,results:_e,security:null,unselectable:null},space:"html",transform:Wy}),fw=Zi({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:ga,accentHeight:_e,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:_e,amplitude:_e,arabicForm:null,ascent:_e,attributeName:null,attributeType:null,azimuth:_e,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:_e,by:null,calcMode:null,capHeight:_e,className:Rt,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:_e,diffuseConstant:_e,direction:null,display:null,dur:null,divisor:_e,dominantBaseline:null,download:Xe,dx:null,dy:null,edgeMode:null,editable:null,elevation:_e,enableBackground:null,end:null,event:null,exponent:_e,externalResourcesRequired:null,fill:null,fillOpacity:_e,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:Ur,g2:Ur,glyphName:Ur,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:_e,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:_e,horizOriginX:_e,horizOriginY:_e,id:null,ideographic:_e,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:_e,k:_e,k1:_e,k2:_e,k3:_e,k4:_e,kernelMatrix:ga,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:_e,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:_e,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:_e,overlineThickness:_e,paintOrder:null,panose1:null,path:null,pathLength:_e,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Rt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:_e,pointsAtY:_e,pointsAtZ:_e,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ga,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ga,rev:ga,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ga,requiredFeatures:ga,requiredFonts:ga,requiredFormats:ga,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:_e,specularExponent:_e,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:_e,strikethroughThickness:_e,string:null,stroke:null,strokeDashArray:ga,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:_e,strokeOpacity:_e,strokeWidth:null,style:null,surfaceScale:_e,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ga,tabIndex:_e,tableValues:null,target:null,targetX:_e,targetY:_e,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ga,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:_e,underlineThickness:_e,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:_e,values:null,vAlphabetic:_e,vMathematical:_e,vectorEffect:null,vHanging:_e,vIdeographic:_e,version:null,vertAdvY:_e,vertOriginX:_e,vertOriginY:_e,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:_e,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Qy}),Zy=Zi({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()}}),Jy=Zi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Wy}),eN=Zi({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"},hw=/[A-Z]/g,Vx=/-[a-z]/g,pw=/^data[-\w.:]+$/i;function Zc(e,t){const a=_o(t);let r=t,o=ra;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&pw.test(t)){if(t.charAt(4)==="-"){const u=t.slice(5).replace(Vx,bw);r="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=t.slice(4);if(!Vx.test(u)){let c=u.replace(hw,gw);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}o=Jh}return new o(r,t)}function gw(e){return"-"+e.toLowerCase()}function bw(e){return e.charAt(1).toUpperCase()}const Mo=Vy([Xy,dw,Zy,Jy,eN],"html"),ur=Vy([Xy,fw,Zy,Jy,eN],"svg");function Xx(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function tN(e){return e.join(" ").trim()}var Di={},Sm,Qx;function xw(){if(Qx)return Sm;Qx=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,a=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
462
+ 在此编写该仓库的 Agent 指令…`}),i.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[i.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:"关闭"}),i.jsxs("button",{type:"button",onClick:()=>void N(),disabled:h||!v,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:[i.jsx(Xc,{className:"h-3.5 w-3.5"}),h?"保存中…":"保存"]})]})]})})}const lh=1024,oh=lh*1024,Bx=oh*1024;function Px(e){return!e||e<=0?"0 B":e<lh?`${e} B`:e<oh?`${(e/lh).toFixed(1)} KB`:e<Bx?`${(e/oh).toFixed(1)} MB`:`${(e/Bx).toFixed(2)} GB`}const Tm="ws/";function VC({repoId:e}){const[t,a]=T.useState(!1),[r,o]=T.useState(null),[u,c]=T.useState(!1),[f,m]=T.useState(null),[h,b]=T.useState(null),[g,y]=T.useState(!1),N=async()=>{c(!0),m(null);try{const M=await L5(e);o(M)}catch(M){m(M instanceof Ss?M.message:"加载失败")}c(!1)};T.useEffect(()=>{t&&r===null&&N()},[t]);const v=async M=>{b(M);try{await j5(e,M),await N()}catch(O){m(O instanceof Ss?O.message:"删除失败")}b(null)},A=async()=>{y(!0);try{await B5(e),await N()}catch(M){m(M instanceof Ss?M.message:"清理失败")}y(!1)},C=(r==null?void 0:r.length)??0,S=(r==null?void 0:r.reduce((M,O)=>M+(O.diskUsage||0),0))??0;return i.jsxs("div",{className:"mt-3 border-t border-line pt-3",children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>a(M=>!M),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?i.jsx(zA,{className:"h-3 w-3 shrink-0"}):i.jsx(ba,{className:"h-3 w-3 shrink-0"}),i.jsx(ko,{className:"h-3 w-3 shrink-0 text-fg-5"}),i.jsx("span",{children:"工作空间"}),r!==null&&i.jsxs("span",{className:"text-fg-5",children:["(",C,") · ",Px(S)]})]}),t&&C>0&&i.jsxs("button",{type:"button",onClick:()=>void A(),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?i.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):null,"清理已合并"]})]}),t&&i.jsxs("div",{className:"mt-2",children:[f&&i.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:[i.jsx("span",{className:"truncate",children:f}),i.jsx("button",{type:"button",onClick:()=>m(null),className:"shrink-0 rounded p-0.5 transition-colors hover:bg-red-500/10",children:i.jsx(gt,{className:"h-3 w-3"})})]}),u&&r===null?i.jsx("div",{className:"flex justify-center py-3",children:i.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-fg-5 border-t-transparent"})}):C===0?i.jsx("p",{className:"py-2 text-center text-xs text-fg-5",children:"暂无工作空间"}):i.jsx("ul",{className:"space-y-1",children:r==null?void 0:r.map(M=>{const O=M.branch.startsWith(Tm),j=O?M.branch.slice(Tm.length):M.branch,I=M.status==="active"?"bg-emerald-500/10 text-emerald-600":M.status==="idle"?"bg-amber-500/10 text-amber-600":"bg-fg-6/30 text-fg-4",U=M.status==="active"?"活跃":M.status==="idle"?"空闲":M.status==="merged"?"已合并":M.status==="stale"?"陈旧":M.status,$=M.status!=="active";return i.jsxs("li",{className:"flex items-center gap-2 rounded-md border border-line bg-elevated/40 px-2 py-1.5 text-xs",children:[i.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[M.running&&M.port&&i.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",title:`运行中 :${M.port}`}),i.jsxs("span",{className:"min-w-0 truncate font-mono",children:[O&&i.jsx("span",{className:"text-fg-5",children:Tm}),i.jsx("span",{className:"text-fg-2",children:j})]})]}),i.jsx("span",{className:ne("shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium",I),children:U}),i.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-fg-5",children:[i.jsx(v3,{className:"h-2.5 w-2.5"}),Px(M.diskUsage)]}),i.jsx("button",{type:"button",onClick:()=>void v(M.id),disabled:!$||h===M.id,title:$?"删除工作空间":"活跃工作空间无法删除",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===M.id?i.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):i.jsx(Cs,{className:"h-3 w-3"})})]},M.id)})})]})]})}function $y(){const e=je(I=>I.repos),t=je(I=>I.activeRepoId),a=je(I=>I.setActiveRepo),r=je(I=>I.removeRepo),o=je(I=>I.loadRepos),[u,c]=T.useState(!1),[f,m]=T.useState(null),[h,b]=T.useState(null),[g,y]=T.useState(null),N=Qt(I=>I.addToast),[v,A]=T.useState(null),[C,S]=T.useState(null),M=T.useRef(null);T.useEffect(()=>{if(!C)return;const I=U=>{M.current&&!M.current.contains(U.target)&&S(null)};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[C]);const O=async(I,U)=>{b(I);try{U?await O5(I):await R5(I),await o()}catch{}b(null)},j=async I=>{y(I);try{const U=await D5(I);await o();const $=U.alreadyUpToDate?"info":"success";N(U.summary,$,void 0,{persistent:!0})}catch(U){let $="拉取失败";if(U instanceof Ss)try{$=JSON.parse(U.message).error??U.message}catch{$=U.message}N($,"error",void 0,{persistent:!0})}y(null)};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mb-6 flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h1",{className:"text-lg font-semibold text-fg",children:"仓库管理"}),i.jsx("p",{className:"mt-0.5 text-sm text-fg-4",children:"管理代码仓库,每个仓库对应一个独立的 Agent 运行环境"})]}),i.jsxs("button",{type:"button",onClick:()=>c(!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:[i.jsx(Ia,{className:"h-4 w-4"}),i.jsx("span",{className:"hidden md:inline",children:"添加仓库"})]})]}),e.length===0?i.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed border-line-hard py-16 text-center",children:[i.jsx("div",{className:"rounded-full bg-elevated p-3",children:i.jsx(Ia,{className:"h-6 w-6 text-fg-4"})}),i.jsx("p",{className:"text-sm font-medium text-fg-3",children:"暂无代码仓库"}),i.jsx("p",{className:"text-xs text-fg-5",children:"添加一个本地仓库开始使用"}),i.jsx("button",{type:"button",onClick:()=>c(!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:"添加仓库"})]}):i.jsx(i.Fragment,{children:i.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:e.map(I=>{const U=I.id===t;return i.jsxs("div",{className:ne("rounded-xl border p-4 transition-colors",U?"border-blue-500/40 bg-blue-500/5":"border-line"),children:[i.jsxs("div",{className:"flex items-center justify-between gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>a(I.id),className:"flex min-w-0 items-center gap-2 text-left",children:[U?i.jsx(Yr,{className:"h-4 w-4 shrink-0 text-blue-500"}):i.jsx(WA,{className:"h-4 w-4 shrink-0 text-fg-5"}),i.jsx("span",{className:ne("truncate font-medium",U?"text-fg":"text-fg-2"),children:I.name})]}),i.jsxs("span",{className:ne("inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium",I.running?"bg-emerald-500/10 text-emerald-600":"bg-fg-6/30 text-fg-4"),children:[i.jsx("span",{className:ne("h-1.5 w-1.5 rounded-full",I.running?"bg-emerald-500":"bg-fg-5")}),I.running?"运行中":"已停止"]})]}),i.jsxs("dl",{className:"mt-3 space-y-1 font-mono text-xs text-fg-4",children:[i.jsxs("div",{className:"flex gap-2",children:[i.jsx("dt",{className:"shrink-0 text-fg-5",children:"Git"}),i.jsx("dd",{className:"min-w-0 truncate",children:I.gitUrl})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("dt",{className:"shrink-0 text-fg-5",children:"路径"}),i.jsxs("dd",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsx("span",{className:"truncate",children:I.localPath}),i.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(I.localPath),title:"复制路径",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:i.jsx(Sc,{className:"h-3 w-3"})})]})]}),I.running&&I.port&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("dt",{className:"shrink-0 text-fg-5",children:"直连"}),i.jsxs("dd",{className:"flex min-w-0 items-center gap-1.5",children:[i.jsxs("a",{href:`http://127.0.0.1:${I.port}`,target:"_blank",rel:"noopener noreferrer",className:"truncate text-blue-500 hover:underline",children:["127.0.0.1:",I.port]}),i.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(`http://127.0.0.1:${I.port}`),title:"复制链接",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:i.jsx(Sc,{className:"h-3 w-3"})})]})]})]}),i.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:()=>void j(I.id),disabled:g===I.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===I.id?i.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):i.jsxs(i.Fragment,{children:[i.jsx(AA,{className:"h-3 w-3"}),"拉取"]})}),i.jsx("button",{type:"button",onClick:()=>void O(I.id,I.running),disabled:h===I.id,className:ne("flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md border text-xs font-medium transition-colors disabled:opacity-50",I.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===I.id?i.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):I.running?i.jsxs(i.Fragment,{children:[i.jsx(nh,{className:"h-3 w-3 fill-current"}),"停止"]}):i.jsxs(i.Fragment,{children:[i.jsx(Kh,{className:"h-3 w-3 fill-current"}),"启动"]})}),i.jsxs("div",{className:"relative",ref:C===I.id?M:void 0,children:[i.jsx("button",{type:"button",onClick:()=>S(C===I.id?null:I.id),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 hover:text-fg-2",children:i.jsx(Fh,{className:"h-4 w-4"})}),C===I.id&&i.jsxs("div",{className:"absolute right-0 top-full z-20 mt-1 min-w-[160px] overflow-hidden rounded-lg border border-line bg-elevated shadow-lg",children:[i.jsx("button",{type:"button",className:ne("flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-base/60",I.runtimeType==="claude-code"?"text-orange-500":"text-sky-500"),onClick:async()=>{S(null);const $=I.runtimeType==="claude-code"?"opencode":"claude-code";await U5(I.id,$),o()},children:I.runtimeType==="claude-code"?"Claude → OpenCode":"OpenCode → Claude"}),i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs text-fg-3 transition-colors hover:bg-base/60",onClick:async()=>{S(null),await P5(I.id,!I.worktreeEnabled),o()},children:[i.jsx(ko,{className:"h-3 w-3"}),i.jsx("span",{children:"Worktree"}),i.jsx("span",{className:ne("ml-auto text-[10px]",I.worktreeEnabled?"text-violet-500":"text-fg-5"),children:I.worktreeEnabled?"已开启":"已关闭"})]}),i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs text-fg-3 transition-colors hover:bg-base/60",onClick:()=>{S(null),A({id:I.id,name:I.name})},children:[i.jsx(zh,{className:"h-3 w-3"}),"配置"]}),i.jsx("div",{className:"my-0.5 border-t border-line"}),i.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-left text-xs text-red-500 transition-colors hover:bg-red-500/10",onClick:()=>{S(null),m(I.id)},children:[i.jsx(Cs,{className:"h-3 w-3"}),"删除仓库"]})]})]})]}),f===I.id&&i.jsxs("div",{className:"mt-2 flex items-center justify-between rounded-md border border-red-500/20 bg-red-500/5 px-3 py-2",children:[i.jsx("span",{className:"text-xs text-red-500",children:"确认删除此仓库?"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>{r(I.id),m(null)},className:"flex h-6 items-center gap-1 rounded border border-red-500/30 px-2 text-xs text-red-500 transition-colors hover:bg-red-500/10",children:[i.jsx(On,{className:"h-3 w-3"}),"确认"]}),i.jsx("button",{type:"button",onClick:()=>m(null),className:"flex h-6 items-center gap-1 rounded border border-line px-2 text-xs text-fg-4 transition-colors hover:bg-elevated",children:"取消"})]})]}),I.worktreeEnabled&&i.jsx(VC,{repoId:I.id})]},I.id)})})}),i.jsxs("p",{className:"mt-3 text-xs text-fg-5",children:[e.length," 个仓库"]}),u&&i.jsx(GC,{onClose:()=>c(!1)}),v&&i.jsx(KC,{repoId:v.id,repoName:v.name,onClose:()=>A(null)})]})}function XC(){return i.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:i.jsx("div",{className:"mx-auto max-w-4xl",children:i.jsx($y,{})})})}const QC=new Set(["tool","tool-use","tool_use","tool-call","tool_call","tool-result","tool_result"]),WC=new Set(["thinking","reasoning","reason"]),ZC=new Set(["text","output_text","message"]),JC=new Set(["file","image"]);function wc(e){var a;const t=((a=e.type)==null?void 0:a.toLowerCase())??"";return QC.has(t)||e.toolName!=null||e.tool!=null?"tool":JC.has(t)?"file":WC.has(t)?"thinking":ZC.has(t)||e.content!=null||e.text!=null?"text":"other"}function kc(e){return e.content??e.text??""}function qy(e){return e.toolName??e.tool??"tool"}function Wc(e){var t;return e.input??((t=e.state)==null?void 0:t.input)}function Wh(e){var t;return e.output??((t=e.state)==null?void 0:t.output)}function Zh(e){var a,r,o;const t=(r=(a=e.state)==null?void 0:a.status)==null?void 0:r.toLowerCase();return t==="completed"||t==="done"||t==="success"?"completed":t==="error"||t==="failed"||((o=e.state)==null?void 0:o.error)!=null?"error":t==="pending"||t==="queued"?"pending":t==="running"||t==="in_progress"?"running":Wh(e)!=null?"completed":"running"}function Ux(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function $r(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 Yy(e){return e.filter(t=>$r(t.status)==="completed").length}function yo(e){const t=qy(e).toLowerCase();return t==="question"||t==="mcp_question"}function ew(e){const t=Wc(e);if(!t||typeof t!="object")return null;const a=t;return Array.isArray(a.questions)?a.questions:null}function Rc(e){if(!yo(e))return!1;const t=Zh(e);return t==="pending"||t==="running"}const tw=/\bses_[a-zA-Z0-9]+/;function nw(e){var o;const t=Wc(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=(o=e.state)==null?void 0:o.metadata;if(a){const u=a.session_id??a.sessionId;if(typeof u=="string"&&u.startsWith("ses_"))return u}const r=Wh(e);if(typeof r=="string"){const u=tw.exec(r);if(u)return u[0]}if(r&&typeof r=="object"){const u=r,c=u.session_id??u.sessionId??u.task_id;if(typeof c=="string"&&c.startsWith("ses_"))return c}return null}const aw=es(()=>({agents:[],loaded:!1}));function Gy(e){return`question-${e}`}function _m(e,t){const a=t.find(o=>o.id===e),r=(a==null?void 0:a.title)||e.slice(-8);Qt.getState().addToast(`${r} — 等待回复`,"warning",e,{id:Gy(e),persistent:!0})}function sw(e){var t;for(const a of e)if((t=a.parts)!=null&&t.some(r=>yo(r)&&Rc(r)))return!0;return!1}const No=[],To=[],Hx=[],Ir={};function Fx(e){return e.id??e.callID}function kn(){return je.getState().activeRepoId}async function zx(e,t){const a=kn();if(a)try{const[r,o]=await Promise.all([X5(a,e),Oy(a).catch(()=>null)]);t(u=>{const c={sessionLinks:{...u.sessionLinks,[e]:r}};return o&&(c.allSessionLinks=o),c})}catch{}}const $x=20,Re=es((e,t)=>({sessions:[],activeSessionId:null,messages:{},messagesMeta:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},sessionFilter:"active",loadingSessions:!1,loadError:null,sendError:null,setSessionFilter:a=>e({sessionFilter:a}),toggleSessionComplete:async a=>{const r=kn();if(!r)return;const o=t().sessions.find(c=>c.id===a);if(!o)return;const u=o.completedAt?null:Date.now();e(c=>({sessions:c.sessions.map(f=>f.id===a?{...f,completedAt:u??void 0}:f)}));try{await vC(r,a,u)}catch{await t().loadSessions()}},loadSessions:async()=>{const a=kn();if(!a){e({sessions:[],loadingSessions:!1});return}e({loadingSessions:!0,loadError:null});try{const[r,o]=await Promise.all([H5(a),Oy(a).catch(()=>null)]),u={sessions:r,loadingSessions:!1};o&&(u.allSessionLinks=o),e(u)}catch(r){e({loadingSessions:!1,loadError:r instanceof Error?r.message:"Failed to load sessions"})}},createSession:async(a,r,o,u,c,f,m)=>{const h=kn();if(!h)return null;e({sendError:null});try{const b=await F5(h,a,r,o,u,c,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=>{kn()&&(e({activeSessionId:a,sendError:null}),await t().refreshSessionData(a))},refreshSessionData:async a=>{var b,g;const r=kn();if(!r)return;const u=!t().messages[a]||t().messages[a].length===0?{limit:$x}:void 0,[c,f]=await Promise.allSettled([Q5(r,a),Ax(r,a,u)]),m=c.status==="fulfilled"?c.value:null,h=(g=(b=m==null?void 0:m.session)==null?void 0:b.revert)==null?void 0:g.messageID;e(y=>{const N={};if(m&&(m.status&&(N.sessionStatuses={...y.sessionStatuses,[a]:m.status.type}),m.todos&&(N.todos={...y.todos,[a]:m.todos}),m.links&&(N.sessionLinks={...y.sessionLinks,[a]:m.links}),m.session&&(N.sessions=y.sessions.map(v=>v.id===a?{...v,...m.session}:v))),f.status==="fulfilled"){let v=f.value.messages;if(h){const C=v.findIndex(S=>S.id===h);C>=0&&(v=v.slice(0,C+1))}const A=y.messages[a]??[];v.length>=A.length&&(N.messages={...y.messages,[a]:v}),N.messagesMeta={...y.messagesMeta,[a]:{total:Math.max(f.value.total,A.length),hasMore:f.value.hasMore,loading:!1}}}return N}),f.status==="fulfilled"&&sw(f.value.messages)&&_m(a,t().sessions)},loadMoreMessages:async a=>{var f;const r=kn();if(!r)return;const o=t().messagesMeta[a];if(!(o!=null&&o.hasMore)||o.loading)return;const c=(f=(t().messages[a]??[])[0])==null?void 0:f.id;e(m=>({messagesMeta:{...m.messagesMeta,[a]:{...o,loading:!0}}}));try{const m=await Ax(r,a,{limit:$x,before:c});e(h=>{const b=h.messages[a]??[];return{messages:{...h.messages,[a]:[...m.messages,...b]},messagesMeta:{...h.messagesMeta,[a]:{total:m.total,hasMore:m.hasMore,loading:!1}}}})}catch{e(m=>({messagesMeta:{...m.messagesMeta,[a]:{...o,loading:!1}}}))}},addLink:async(a,r,o)=>{const u=kn();if(!u)return!1;try{return await W5(u,a,r,o),await zx(a,e),!0}catch{return!1}},removeLink:async(a,r,o)=>{const u=kn();if(!u)return!1;try{return await Z5(u,a,r,o),await zx(a,e),!0}catch{return!1}},deleteSession:async a=>{const r=kn();if(r)try{await z5(r,a)}catch{}delete Ir[a],e(o=>{const{[a]:u,...c}=o.messages,{[a]:f,...m}=o.messagesMeta,{[a]:h,...b}=o.todos,{[a]:g,...y}=o.sessionStatuses,{[a]:N,...v}=o.errorReasons,{[a]:A,...C}=o.queuedMessageIds,{[a]:S,...M}=o.sessionLinks,{[a]:O,...j}=o.allSessionLinks;return{sessions:o.sessions.filter(I=>I.id!==a),messages:c,messagesMeta:m,todos:b,sessionStatuses:y,errorReasons:v,queuedMessageIds:C,sessionLinks:M,allSessionLinks:j,activeSessionId:o.activeSessionId===a?null:o.activeSessionId}})},sendMessage:async(a,r,o,u)=>{const c=kn(),f=t().activeSessionId;if(!c||!f)return!1;const m=t().sessions.find(b=>b.id===f),h=t().sessionStatuses[f]==="busy";e({sendError:null}),m!=null&&m.completedAt&&e(b=>({sessions:b.sessions.map(g=>g.id===f?{...g,completedAt:void 0}:g)})),h||t().setSessionStatus(f,"busy");try{const b=aw.getState(),g=m!=null&&m.agent&&b.loaded&&b.agents.some(y=>y.name===m.agent||y.id===m.agent)?m.agent:void 0;return await $5(c,f,a,g,r,o,u),h&&(Ir[f]=(Ir[f]||0)+1),!0}catch(b){return e({sendError:b instanceof Error?b.message:"Failed to send message"}),h||t().setSessionStatus(f,"idle"),!1}},replyQuestion:async a=>{const r=kn(),o=t().activeSessionId;if(!(!r||!o))try{await Y5(r,o,a)}catch(u){e({sendError:u instanceof Error?u.message:"Failed to reply to question"})}},rejectQuestion:async()=>{const a=kn(),r=t().activeSessionId;if(!(!a||!r))try{await G5(a,r)}catch{}},abortSession:async()=>{const a=kn(),r=t().activeSessionId;if(!(!a||!r)){try{await q5(a,r)}catch{}t().setSessionStatus(r,"idle")}},clearSessions:()=>{for(const a of Object.keys(Ir))delete Ir[a];e({sessions:[],activeSessionId:null,messages:{},messagesMeta:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},loadError:null,sendError:null})},updateMessage:(a,r)=>{var o;e(u=>{const c=u.messages[a]??[],f=c.findIndex(g=>g.id===r.id);let m,h=u.queuedMessageIds,b=u.messagesMeta;if(f>=0){const g={...c[f],...r};(!r.parts||r.parts.length===0)&&c[f].parts&&(g.parts=c[f].parts),m=[...c],m[f]=g}else{m=[...c,r];const g=b[a];g&&(b={...b,[a]:{...g,total:g.total+1}});const y=Ir[a]||0;if(r.role==="user"&&y>0){const N=[...h[a]??[]];N.push(r.id),h={...h,[a]:N},Ir[a]=y-1}else if(r.role==="assistant"){const N=h[a];N&&N.length>0&&(h={...h,[a]:N.slice(1)})}}return{messages:{...u.messages,[a]:m},messagesMeta:b,queuedMessageIds:h}}),(o=r.parts)!=null&&o.some(u=>yo(u)&&Rc(u))&&_m(a,t().sessions)},updateMessagePart:(a,r,o)=>{e(u=>{const c=u.messages[a]??[],f=c.findIndex(v=>v.id===r),m=f>=0?c[f]:{id:r,role:"assistant"},h=m.parts?[...m.parts]:[],b=Fx(o),g=b!=null?h.findIndex(v=>Fx(v)===b):-1;g>=0?h[g]={...h[g],...o}:h.push(o);const y={...m,parts:h},N=f>=0?[...c]:[...c,y];return f>=0&&(N[f]=y),{messages:{...u.messages,[a]:N}}}),yo(o)&&Rc(o)&&_m(a,t().sessions)},appendMessagePartDelta:(a,r,o,u)=>{e(c=>{const f=c.messages[a]??[],m=f.findIndex(v=>v.id===r),h=m>=0?f[m]:{id:r,role:"assistant"},b=h.parts?[...h.parts]:[],g=b.findIndex(v=>v.id===o);if(g>=0){const v=b[g],A=kc(v)+u;b[g]=v.content!=null?{...v,content:A}:{...v,text:A}}else b.push({id:o,type:"text",text:u});const y={...h,parts:b},N=m>=0?[...f]:[...f,y];return m>=0&&(N[m]=y),{messages:{...c.messages,[a]:N}}})},updateTodos:(a,r)=>{e(o=>({todos:{...o.todos,[a]:r}}))},updateSessionInfo:a=>{e(r=>r.sessions.some(u=>u.id===a.id)?{sessions:r.sessions.map(u=>u.id===a.id?{...u,...a}:u)}:{sessions:[a,...r.sessions]})},setSessionStatus:(a,r,o)=>{const u=t().sessionStatuses[a];if(u!==r){const c=t().sessions.find(m=>m.id===a),f=(c==null?void 0:c.title)||a.slice(-8);if(r==="idle"&&u!==void 0&&u!=="idle")Qt.getState().removeToast(Gy(a)),Qt.getState().addToast(`${f} — 完成`,"success",a);else if(r==="busy"&&(u===void 0||u==="idle"))Qt.getState().addToast(`${f} — 开始运行`,"info",a);else if(r==="retry")Qt.getState().addToast(`${f} — 进入重试`,"warning",a);else if(r==="error"){const m=o?`${f} — 错误: ${o}`:`${f} — 发生错误`;Qt.getState().addToast(m,"error",a)}}e(c=>{const f=o?{...c.errorReasons,[a]:o}:r!=="error"?(()=>{const{[a]:m,...h}=c.errorReasons;return h})():c.errorReasons;return{sessionStatuses:{...c.sessionStatuses,[a]:r},errorReasons:f}})},bulkSetStatuses:a=>{e({sessionStatuses:{...t().sessionStatuses,...a}})},renameSession:async(a,r)=>{const o=kn();if(o){e(u=>({sessions:u.sessions.map(c=>c.id===a?{...c,title:r}:c)}));try{await _C(o,a,r)}catch{await t().loadSessions()}}},revertToMessage:async(a,r)=>{const o=kn();if(!o)return!1;try{return await K5(o,a,r),await t().refreshSessionData(a),!0}catch{return!1}}})),Ve=es((e,t)=>({issues:[],tags:[],tagFilterMode:new Map,milestones:[],selectedMilestoneId:null,loaded:!1,syncing:!1,selectedIssueId:null,viewingIssueId:null,viewingTreeRootId:null,matchingParentId:null,matchingCandidateId:null,clearIssues:()=>e({issues:[],tags:[],tagFilterMode:new Map,milestones:[],selectedMilestoneId:null,loaded:!1,selectedIssueId:null,viewingIssueId:null,viewingTreeRootId:null,matchingParentId:null,matchingCandidateId:null}),setSelectedIssue:a=>e({selectedIssueId:a}),setViewingIssue:(a,r)=>e({viewingIssueId:a,viewingTreeRootId:r??null}),enterMatchMode:a=>e({matchingParentId:a,matchingCandidateId:null}),exitMatchMode:()=>{e({matchingParentId:null,matchingCandidateId:null})},linkChild:async(a,r)=>{var u;const o=je.getState().activeRepoId;if(!o)return!1;try{await dC(o,a,r);const c=(u=t().issues.find(f=>f.number===a))==null?void 0:u.id;return c&&e(f=>({issues:f.issues.map(m=>m.number===r?{...m,parentId:c}:m),matchingCandidateId:null})),!0}catch{return!1}},updateIssueState:async(a,r)=>{const o=je.getState().activeRepoId;if(!o)return!1;try{const u=await By(o,a,{state:r});return e(c=>({issues:c.issues.map(f=>f.number===a?{...f,state:u.state}:f)})),!0}catch{return!1}},loadIssues:async()=>{const a=je.getState().activeRepoId;if(!a){e({issues:[],loaded:!0});return}try{const r=await Rx(a,"all");e({issues:r,loaded:!0})}catch{e({loaded:!0})}},syncIssues:async()=>{const a=je.getState().activeRepoId;if(a){e({syncing:!0});try{await uC(a,"open");const[r,o,u]=await Promise.all([Rx(a,"all"),wx(a),kx(a)]);e({issues:r,tags:o,milestones:u,syncing:!1})}catch(r){e({syncing:!1});let o="同步 Issue 失败";if(r instanceof Ss)try{const u=JSON.parse(r.message);u.error&&(o=u.error)}catch{r.message&&(o=r.message)}Qt.getState().addToast(o,"error")}}},createIssue:async(a,r)=>{const o=je.getState().activeRepoId;if(!o)return null;try{const u=await cC(o,a,r);return e(c=>({issues:[u,...c.issues]})),u}catch{return null}},loadTags:async()=>{const a=je.getState().activeRepoId;if(!a){e({tags:[]});return}try{const r=await wx(a);e({tags:r})}catch{}},cycleTagFilter:a=>{e(r=>{const o=new Map(r.tagFilterMode),u=o.get(a);return u?u==="include"?o.set(a,"exclude"):o.delete(a):o.set(a,"include"),{tagFilterMode:o}})},clearTagFilter:()=>e({tagFilterMode:new Map}),loadMilestones:async()=>{const a=je.getState().activeRepoId;if(!a){e({milestones:[]});return}try{const r=await kx(a);e({milestones:r})}catch{}},setMilestoneFilter:a=>e({selectedMilestoneId:a})})),xc=es(e=>({drafts:{},setDraft:(t,a)=>e(r=>{if(!a.trim()){const{[t]:o,...u}=r.drafts;return{drafts:u}}return{drafts:{...r.drafts,[t]:a}}}),clearDraft:t=>e(a=>{const{[t]:r,...o}=a.drafts;return{drafts:o}})}));function qx(e){const t=[],a=String(e||"");let r=a.indexOf(","),o=0,u=!1;for(;!u;){r===-1&&(r=a.length,u=!0);const c=a.slice(o,r).trim();(c||!u)&&t.push(c),o=r+1,r=a.indexOf(",",o)}return t}function Ky(e,t){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const rw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,iw=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lw={};function Yx(e,t){return(lw.jsx?iw:rw).test(e)}const ow=/[ \t\n\f\r]/g;function uw(e){return typeof e=="object"?e.type==="text"?Gx(e.value):!1:Gx(e)}function Gx(e){return e.replace(ow,"")===""}class Io{constructor(t,a,r){this.normal=a,this.property=t,r&&(this.space=r)}}Io.prototype.normal={};Io.prototype.property={};Io.prototype.space=void 0;function Vy(e,t){const a={},r={};for(const o of e)Object.assign(a,o.property),Object.assign(r,o.normal);return new Io(a,r,t)}function _o(e){return e.toLowerCase()}class ra{constructor(t,a){this.attribute=a,this.property=t}}ra.prototype.attribute="";ra.prototype.booleanish=!1;ra.prototype.boolean=!1;ra.prototype.commaOrSpaceSeparated=!1;ra.prototype.commaSeparated=!1;ra.prototype.defined=!1;ra.prototype.mustUseProperty=!1;ra.prototype.number=!1;ra.prototype.overloadedBoolean=!1;ra.prototype.property="";ra.prototype.spaceSeparated=!1;ra.prototype.space=void 0;let cw=0;const Xe=Gr(),rn=Gr(),uh=Gr(),_e=Gr(),Rt=Gr(),Ur=Gr(),ga=Gr();function Gr(){return 2**++cw}const ch=Object.freeze(Object.defineProperty({__proto__:null,boolean:Xe,booleanish:rn,commaOrSpaceSeparated:ga,commaSeparated:Ur,number:_e,overloadedBoolean:uh,spaceSeparated:Rt},Symbol.toStringTag,{value:"Module"})),vm=Object.keys(ch);class Jh extends ra{constructor(t,a,r,o){let u=-1;if(super(t,a),Kx(this,"space",o),typeof r=="number")for(;++u<vm.length;){const c=vm[u];Kx(this,vm[u],(r&ch[c])===ch[c])}}}Jh.prototype.defined=!0;function Kx(e,t,a){a&&(e[t]=a)}function Zi(e){const t={},a={};for(const[r,o]of Object.entries(e.properties)){const u=new Jh(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(u.mustUseProperty=!0),t[r]=u,a[_o(r)]=r,a[_o(u.attribute)]=r}return new Io(t,a,e.space)}const Xy=Zi({properties:{ariaActiveDescendant:null,ariaAtomic:rn,ariaAutoComplete:null,ariaBusy:rn,ariaChecked:rn,ariaColCount:_e,ariaColIndex:_e,ariaColSpan:_e,ariaControls:Rt,ariaCurrent:null,ariaDescribedBy:Rt,ariaDetails:null,ariaDisabled:rn,ariaDropEffect:Rt,ariaErrorMessage:null,ariaExpanded:rn,ariaFlowTo:Rt,ariaGrabbed:rn,ariaHasPopup:null,ariaHidden:rn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Rt,ariaLevel:_e,ariaLive:null,ariaModal:rn,ariaMultiLine:rn,ariaMultiSelectable:rn,ariaOrientation:null,ariaOwns:Rt,ariaPlaceholder:null,ariaPosInSet:_e,ariaPressed:rn,ariaReadOnly:rn,ariaRelevant:null,ariaRequired:rn,ariaRoleDescription:Rt,ariaRowCount:_e,ariaRowIndex:_e,ariaRowSpan:_e,ariaSelected:rn,ariaSetSize:_e,ariaSort:null,ariaValueMax:_e,ariaValueMin:_e,ariaValueNow:_e,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Qy(e,t){return t in e?e[t]:t}function Wy(e,t){return Qy(e,t.toLowerCase())}const dw=Zi({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ur,acceptCharset:Rt,accessKey:Rt,action:null,allow:null,allowFullScreen:Xe,allowPaymentRequest:Xe,allowUserMedia:Xe,alpha:Xe,alt:null,as:null,async:Xe,autoCapitalize:null,autoComplete:Rt,autoFocus:Xe,autoPlay:Xe,blocking:Rt,capture:null,charSet:null,checked:Xe,cite:null,className:Rt,closedBy:null,colorSpace:null,cols:_e,colSpan:_e,command:null,commandFor:null,content:null,contentEditable:rn,controls:Xe,controlsList:Rt,coords:_e|Ur,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Xe,defer:Xe,dir:null,dirName:null,disabled:Xe,download:uh,draggable:rn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Xe,formTarget:null,headers:Rt,height:_e,hidden:uh,high:_e,href:null,hrefLang:null,htmlFor:Rt,httpEquiv:Rt,id:null,imageSizes:null,imageSrcSet:null,inert:Xe,inputMode:null,integrity:null,is:null,isMap:Xe,itemId:null,itemProp:Rt,itemRef:Rt,itemScope:Xe,itemType:Rt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Xe,low:_e,manifest:null,max:null,maxLength:_e,media:null,method:null,min:null,minLength:_e,multiple:Xe,muted:Xe,name:null,nonce:null,noModule:Xe,noValidate:Xe,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:Xe,optimum:_e,pattern:null,ping:Rt,placeholder:null,playsInline:Xe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Xe,referrerPolicy:null,rel:Rt,required:Xe,reversed:Xe,rows:_e,rowSpan:_e,sandbox:Rt,scope:null,scoped:Xe,seamless:Xe,selected:Xe,shadowRootClonable:Xe,shadowRootCustomElementRegistry:Xe,shadowRootDelegatesFocus:Xe,shadowRootMode:null,shadowRootSerializable:Xe,shape:null,size:_e,sizes:null,slot:null,span:_e,spellCheck:rn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:_e,step:null,style:null,tabIndex:_e,target:null,title:null,translate:null,type:null,typeMustMatch:Xe,useMap:null,value:rn,width:_e,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Rt,axis:null,background:null,bgColor:null,border:_e,borderColor:null,bottomMargin:_e,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Xe,declare:Xe,event:null,face:null,frame:null,frameBorder:null,hSpace:_e,leftMargin:_e,link:null,longDesc:null,lowSrc:null,marginHeight:_e,marginWidth:_e,noResize:Xe,noHref:Xe,noShade:Xe,noWrap:Xe,object:null,profile:null,prompt:null,rev:null,rightMargin:_e,rules:null,scheme:null,scrolling:rn,standby:null,summary:null,text:null,topMargin:_e,valueType:null,version:null,vAlign:null,vLink:null,vSpace:_e,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Xe,disablePictureInPicture:Xe,disableRemotePlayback:Xe,exportParts:Ur,part:Rt,prefix:null,property:null,results:_e,security:null,unselectable:null},space:"html",transform:Wy}),fw=Zi({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:ga,accentHeight:_e,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:_e,amplitude:_e,arabicForm:null,ascent:_e,attributeName:null,attributeType:null,azimuth:_e,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:_e,by:null,calcMode:null,capHeight:_e,className:Rt,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:_e,diffuseConstant:_e,direction:null,display:null,dur:null,divisor:_e,dominantBaseline:null,download:Xe,dx:null,dy:null,edgeMode:null,editable:null,elevation:_e,enableBackground:null,end:null,event:null,exponent:_e,externalResourcesRequired:null,fill:null,fillOpacity:_e,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:Ur,g2:Ur,glyphName:Ur,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:_e,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:_e,horizOriginX:_e,horizOriginY:_e,id:null,ideographic:_e,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:_e,k:_e,k1:_e,k2:_e,k3:_e,k4:_e,kernelMatrix:ga,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:_e,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:_e,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:_e,overlineThickness:_e,paintOrder:null,panose1:null,path:null,pathLength:_e,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Rt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:_e,pointsAtY:_e,pointsAtZ:_e,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ga,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ga,rev:ga,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ga,requiredFeatures:ga,requiredFonts:ga,requiredFormats:ga,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:_e,specularExponent:_e,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:_e,strikethroughThickness:_e,string:null,stroke:null,strokeDashArray:ga,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:_e,strokeOpacity:_e,strokeWidth:null,style:null,surfaceScale:_e,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ga,tabIndex:_e,tableValues:null,target:null,targetX:_e,targetY:_e,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ga,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:_e,underlineThickness:_e,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:_e,values:null,vAlphabetic:_e,vMathematical:_e,vectorEffect:null,vHanging:_e,vIdeographic:_e,version:null,vertAdvY:_e,vertOriginX:_e,vertOriginY:_e,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:_e,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Qy}),Zy=Zi({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()}}),Jy=Zi({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Wy}),eN=Zi({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"},hw=/[A-Z]/g,Vx=/-[a-z]/g,pw=/^data[-\w.:]+$/i;function Zc(e,t){const a=_o(t);let r=t,o=ra;if(a in e.normal)return e.property[e.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&pw.test(t)){if(t.charAt(4)==="-"){const u=t.slice(5).replace(Vx,bw);r="data"+u.charAt(0).toUpperCase()+u.slice(1)}else{const u=t.slice(4);if(!Vx.test(u)){let c=u.replace(hw,gw);c.charAt(0)!=="-"&&(c="-"+c),t="data"+c}}o=Jh}return new o(r,t)}function gw(e){return"-"+e.toLowerCase()}function bw(e){return e.charAt(1).toUpperCase()}const Mo=Vy([Xy,dw,Zy,Jy,eN],"html"),ur=Vy([Xy,fw,Zy,Jy,eN],"svg");function Xx(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function tN(e){return e.join(" ").trim()}var Di={},Sm,Qx;function xw(){if(Qx)return Sm;Qx=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,a=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,u=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,f=/^\s+|\s+$/g,m=`
463
463
  `,h="/",b="*",g="",y="comment",N="declaration";function v(C,S){if(typeof C!="string")throw new TypeError("First argument must be a string");if(!C)return[];S=S||{};var M=1,O=1;function j(Q){var q=Q.match(t);q&&(M+=q.length);var F=Q.lastIndexOf(m);O=~F?Q.length-F:O+Q.length}function I(){var Q={line:M,column:O};return function(q){return q.position=new U(Q),K(),q}}function U(Q){this.start=Q,this.end={line:M,column:O},this.source=S.source}U.prototype.content=C;function $(Q){var q=new Error(S.source+":"+M+":"+O+": "+Q);if(q.reason=Q,q.filename=S.source,q.line=M,q.column=O,q.source=C,!S.silent)throw q}function Z(Q){var q=Q.exec(C);if(q){var F=q[0];return j(F),C=C.slice(F.length),q}}function K(){Z(a)}function D(Q){var q;for(Q=Q||[];q=te();)q!==!1&&Q.push(q);return Q}function te(){var Q=I();if(!(h!=C.charAt(0)||b!=C.charAt(1))){for(var q=2;g!=C.charAt(q)&&(b!=C.charAt(q)||h!=C.charAt(q+1));)++q;if(q+=2,g===C.charAt(q-1))return $("End of comment missing");var F=C.slice(2,q-2);return O+=2,j(F),C=C.slice(q),O+=2,Q({type:y,comment:F})}}function le(){var Q=I(),q=Z(r);if(q){if(te(),!Z(o))return $("property missing ':'");var F=Z(u),k=Q({type:N,property:A(q[0].replace(e,g)),value:F?A(F[0].replace(e,g)):g});return Z(c),k}}function pe(){var Q=[];D(Q);for(var q;q=le();)q!==!1&&(Q.push(q),D(Q));return Q}return K(),pe()}function A(C){return C?C.replace(f,g):g}return Sm=v,Sm}var Wx;function Ew(){if(Wx)return Di;Wx=1;var e=Di&&Di.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Di,"__esModule",{value:!0}),Di.default=a;const t=e(xw());function a(r,o){let u=null;if(!r||typeof r!="string")return u;const c=(0,t.default)(r),f=typeof o=="function";return c.forEach(m=>{if(m.type!=="declaration")return;const{property:h,value:b}=m;f?o(h,b,m):b&&(u=u||{},u[h]=b)}),u}return Di}var Jl={},Zx;function yw(){if(Zx)return Jl;Zx=1,Object.defineProperty(Jl,"__esModule",{value:!0}),Jl.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,a=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,u=function(h){return!h||a.test(h)||e.test(h)},c=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(o,f):h=h.replace(r,f),h.replace(t,c))};return Jl.camelCase=m,Jl}var eo,Jx;function Nw(){if(Jx)return eo;Jx=1;var e=eo&&eo.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},t=e(Ew()),a=yw();function r(o,u){var c={};return!o||typeof o!="string"||(0,t.default)(o,function(f,m){f&&m&&(c[(0,a.camelCase)(f,u)]=m)}),c}return r.default=r,eo=r,eo}var Tw=Nw();const _w=zc(Tw),Jc=nN("end"),ts=nN("start");function nN(e){return t;function t(a){const r=a&&a.position&&a.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function vw(e){const t=ts(e),a=Jc(e);if(t&&a)return{start:t,end:a}}function oo(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?e1(e.position):"start"in e||"end"in e?e1(e):"line"in e||"column"in e?dh(e):""}function dh(e){return t1(e&&e.line)+":"+t1(e&&e.column)}function e1(e){return dh(e&&e.start)+"-"+dh(e&&e.end)}function t1(e){return e&&typeof e=="number"?e:1}class In extends Error{constructor(t,a,r){super(),typeof a=="string"&&(r=a,a=void 0);let o="",u={},c=!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"?o=t:!u.cause&&t&&(c=!0,o=t.message,u.cause=t),!u.ruleId&&!u.source&&typeof r=="string"){const m=r.indexOf(":");m===-1?u.ruleId=r:(u.source=r.slice(0,m),u.ruleId=r.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=o,this.line=f?f.line:void 0,this.name=oo(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=c&&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}}In.prototype.file="";In.prototype.name="";In.prototype.reason="";In.prototype.message="";In.prototype.stack="";In.prototype.column=void 0;In.prototype.line=void 0;In.prototype.ancestors=void 0;In.prototype.cause=void 0;In.prototype.fatal=void 0;In.prototype.place=void 0;In.prototype.ruleId=void 0;In.prototype.source=void 0;const ep={}.hasOwnProperty,Sw=new Map,Aw=/[A-Z]/g,Cw=new Set(["table","tbody","thead","tfoot","tr"]),ww=new Set(["td","th"]),aN="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function kw(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Bw(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");r=jw(a,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,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"?ur:Mo,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},u=sN(o,e,void 0);return u&&typeof u!="string"?u:o.create(e,o.Fragment,{children:u||void 0},void 0)}function sN(e,t,a){if(t.type==="element")return Rw(e,t,a);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return Ow(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Mw(e,t,a);if(t.type==="mdxjsEsm")return Iw(e,t);if(t.type==="root")return Dw(e,t,a);if(t.type==="text")return Lw(e,t)}function Rw(e,t,a){const r=e.schema;let o=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(o=ur,e.schema=o),e.ancestors.push(t);const u=iN(e,t.tagName,!1),c=Pw(e,t);let f=np(e,t);return Cw.has(t.tagName)&&(f=f.filter(function(m){return typeof m=="string"?!uw(m):!0})),rN(e,c,u,t),tp(c,f),e.ancestors.pop(),e.schema=r,e.create(t,u,c,a)}function Ow(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}vo(e,t.position)}function Iw(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);vo(e,t.position)}function Mw(e,t,a){const r=e.schema;let o=r;t.name==="svg"&&r.space==="html"&&(o=ur,e.schema=o),e.ancestors.push(t);const u=t.name===null?e.Fragment:iN(e,t.name,!0),c=Uw(e,t),f=np(e,t);return rN(e,c,u,t),tp(c,f),e.ancestors.pop(),e.schema=r,e.create(t,u,c,a)}function Dw(e,t,a){const r={};return tp(r,np(e,t)),e.create(t,e.Fragment,r,a)}function Lw(e,t){return t.value}function rN(e,t,a,r){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(t.node=r)}function tp(e,t){if(t.length>0){const a=t.length>1?t:t[0];a&&(e.children=a)}}function jw(e,t,a){return r;function r(o,u,c,f){const h=Array.isArray(c.children)?a:t;return f?h(u,c,f):h(u,c)}}function Bw(e,t){return a;function a(r,o,u,c){const f=Array.isArray(u.children),m=ts(r);return t(o,u,c,f,{columnNumber:m?m.column-1:void 0,fileName:e,lineNumber:m?m.line:void 0},void 0)}}function Pw(e,t){const a={};let r,o;for(o in t.properties)if(o!=="children"&&ep.call(t.properties,o)){const u=Hw(e,o,t.properties[o]);if(u){const[c,f]=u;e.tableCellAlignToStyle&&c==="align"&&typeof f=="string"&&ww.has(t.tagName)?r=f:a[c]=f}}if(r){const u=a.style||(a.style={});u[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return a}function Uw(e,t){const a={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const u=r.data.estree.body[0];u.type;const c=u.expression;c.type;const f=c.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else vo(e,t.position);else{const o=r.name;let u;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const f=r.value.data.estree.body[0];f.type,u=e.evaluater.evaluateExpression(f.expression)}else vo(e,t.position);else u=r.value===null?!0:r.value;a[o]=u}return a}function np(e,t){const a=[];let r=-1;const o=e.passKeys?new Map:Sw;for(;++r<t.children.length;){const u=t.children[r];let c;if(e.passKeys){const m=u.type==="element"?u.tagName:u.type==="mdxJsxFlowElement"||u.type==="mdxJsxTextElement"?u.name:void 0;if(m){const h=o.get(m)||0;c=m+"-"+h,o.set(m,h+1)}}const f=sN(e,u,c);f!==void 0&&a.push(f)}return a}function Hw(e,t,a){const r=Zc(e.schema,t);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=r.commaSeparated?Ky(a):tN(a)),r.property==="style"){let o=typeof a=="object"?a:Fw(e,String(a));return e.stylePropertyNameCase==="css"&&(o=zw(o)),["style",o]}return[e.elementAttributeNameCase==="react"&&r.space?mw[r.property]||r.property:r.attribute,a]}}function Fw(e,t){try{return _w(t,{reactCompat:!0})}catch(a){if(e.ignoreInvalidStyle)return{};const r=a,o=new In("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=e.filePath||void 0,o.url=aN+"#cannot-parse-style-attribute",o}}function iN(e,t,a){let r;if(!a)r={type:"Literal",value:t};else if(t.includes(".")){const o=t.split(".");let u=-1,c;for(;++u<o.length;){const f=Yx(o[u])?{type:"Identifier",name:o[u]}:{type:"Literal",value:o[u]};c=c?{type:"MemberExpression",object:c,property:f,computed:!!(u&&f.type==="Literal"),optional:!1}:f}r=c}else r=Yx(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const o=r.value;return ep.call(e.components,o)?e.components[o]:o}if(e.evaluater)return e.evaluater.evaluateExpression(r);vo(e)}function vo(e,t){const a=new In("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=aN+"#cannot-handle-mdx-estrees-without-createevaluater",a}function zw(e){const t={};let a;for(a in e)ep.call(e,a)&&(t[$w(a)]=e[a]);return t}function $w(e){let t=e.replace(Aw,qw);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function qw(e){return"-"+e.toLowerCase()}const Am={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"]},Yw={};function ap(e,t){const a=Yw,r=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,o=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return lN(e,r,o)}function lN(e,t,a){if(Gw(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 n1(e.children,t,a)}return Array.isArray(e)?n1(e,t,a):""}function n1(e,t,a){const r=[];let o=-1;for(;++o<e.length;)r[o]=lN(e[o],t,a);return r.join("")}function Gw(e){return!!(e&&typeof e=="object")}const a1=document.createElement("i");function sp(e){const t="&"+e+";";a1.innerHTML=t;const a=a1.textContent;return a.charCodeAt(a.length-1)===59&&e!=="semi"||a===t?!1:a}function xa(e,t,a,r){const o=e.length;let u=0,c;if(t<0?t=-t>o?0:o+t:t=t>o?o:t,a=a>0?a:0,r.length<1e4)c=Array.from(r),c.unshift(t,a),e.splice(...c);else for(a&&e.splice(t,a);u<r.length;)c=r.slice(u,u+1e4),c.unshift(t,0),e.splice(...c),u+=1e4,t+=1e4}function ka(e,t){return e.length>0?(xa(e,e.length,0,t),e):t}const s1={}.hasOwnProperty;function oN(e){const t={};let a=-1;for(;++a<e.length;)Kw(t,e[a]);return t}function Kw(e,t){let a;for(a in t){const o=(s1.call(e,a)?e[a]:void 0)||(e[a]={}),u=t[a];let c;if(u)for(c in u){s1.call(o,c)||(o[c]=[]);const f=u[c];Vw(o[c],Array.isArray(f)?f:f?[f]:[])}}}function Vw(e,t){let a=-1;const r=[];for(;++a<t.length;)(t[a].add==="after"?e:r).push(t[a]);xa(e,0,0,r)}function uN(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 Ha(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Fn=cr(/[A-Za-z]/),Rn=cr(/[\dA-Za-z]/),Xw=cr(/[#-'*+\--9=?A-Z^-~]/);function Oc(e){return e!==null&&(e<32||e===127)}const fh=cr(/\d/),Qw=cr(/[\dA-Fa-f]/),Ww=cr(/[!-/:-@[-`{-~]/);function Fe(e){return e!==null&&e<-2}function Ot(e){return e!==null&&(e<0||e===32)}function it(e){return e===-2||e===-1||e===32}const ed=cr(new RegExp("\\p{P}|\\p{S}","u")),qr=cr(/\s/);function cr(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function Ji(e){const t=[];let a=-1,r=0,o=0;for(;++a<e.length;){const u=e.charCodeAt(a);let c="";if(u===37&&Rn(e.charCodeAt(a+1))&&Rn(e.charCodeAt(a+2)))o=2;else if(u<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(u))||(c=String.fromCharCode(u));else if(u>55295&&u<57344){const f=e.charCodeAt(a+1);u<56320&&f>56319&&f<57344?(c=String.fromCharCode(u,f),o=1):c="�"}else c=String.fromCharCode(u);c&&(t.push(e.slice(r,a),encodeURIComponent(c)),r=a+o+1,c=""),o&&(a+=o,o=0)}return t.join("")+e.slice(r)}function ft(e,t,a,r){const o=r?r-1:Number.POSITIVE_INFINITY;let u=0;return c;function c(m){return it(m)?(e.enter(a),f(m)):t(m)}function f(m){return it(m)&&u++<o?(e.consume(m),f):(e.exit(a),t(m))}}const Zw={tokenize:Jw};function Jw(e){const t=e.attempt(this.parser.constructs.contentInitial,r,o);let a;return t;function r(f){if(f===null){e.consume(f);return}return e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),ft(e,t,"linePrefix")}function o(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,c(f)}function c(f){if(f===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(f);return}return Fe(f)?(e.consume(f),e.exit("chunkText"),u):(e.consume(f),c)}}const ek={tokenize:tk},r1={tokenize:nk};function tk(e){const t=this,a=[];let r=0,o,u,c;return f;function f(O){if(r<a.length){const j=a[r];return t.containerState=j[1],e.attempt(j[0].continuation,m,h)(O)}return h(O)}function m(O){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&M();const j=t.events.length;let I=j,U;for(;I--;)if(t.events[I][0]==="exit"&&t.events[I][1].type==="chunkFlow"){U=t.events[I][1].end;break}S(r);let $=j;for(;$<t.events.length;)t.events[$][1].end={...U},$++;return xa(t.events,I+1,0,t.events.slice(j)),t.events.length=$,h(O)}return f(O)}function h(O){if(r===a.length){if(!o)return y(O);if(o.currentConstruct&&o.currentConstruct.concrete)return v(O);t.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(r1,b,g)(O)}function b(O){return o&&M(),S(r),y(O)}function g(O){return t.parser.lazy[t.now().line]=r!==a.length,c=t.now().offset,v(O)}function y(O){return t.containerState={},e.attempt(r1,N,v)(O)}function N(O){return r++,a.push([t.currentConstruct,t.containerState]),y(O)}function v(O){if(O===null){o&&M(),S(0),e.consume(O);return}return o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:u}),A(O)}function A(O){if(O===null){C(e.exit("chunkFlow"),!0),S(0),e.consume(O);return}return Fe(O)?(e.consume(O),C(e.exit("chunkFlow")),r=0,t.interrupt=void 0,f):(e.consume(O),A)}function C(O,j){const I=t.sliceStream(O);if(j&&I.push(null),O.previous=u,u&&(u.next=O),u=O,o.defineSkip(O.start),o.write(I),t.parser.lazy[O.start.line]){let U=o.events.length;for(;U--;)if(o.events[U][1].start.offset<c&&(!o.events[U][1].end||o.events[U][1].end.offset>c))return;const $=t.events.length;let Z=$,K,D;for(;Z--;)if(t.events[Z][0]==="exit"&&t.events[Z][1].type==="chunkFlow"){if(K){D=t.events[Z][1].end;break}K=!0}for(S(r),U=$;U<t.events.length;)t.events[U][1].end={...D},U++;xa(t.events,Z+1,0,t.events.slice($)),t.events.length=U}}function S(O){let j=a.length;for(;j-- >O;){const I=a[j];t.containerState=I[1],I[0].exit.call(t,e)}a.length=O}function M(){o.write([null]),u=void 0,o=void 0,t.containerState._closeFlow=void 0}}function nk(e,t,a){return ft(e,e.attempt(this.parser.constructs.document,t,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function $i(e){if(e===null||Ot(e)||qr(e))return 1;if(ed(e))return 2}function td(e,t,a){const r=[];let o=-1;for(;++o<e.length;){const u=e[o].resolveAll;u&&!r.includes(u)&&(t=u(t,a),r.push(u))}return t}const mh={name:"attention",resolveAll:ak,tokenize:sk};function ak(e,t){let a=-1,r,o,u,c,f,m,h,b;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(r=a;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[r][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;m=e[r][1].end.offset-e[r][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const g={...e[r][1].end},y={...e[a][1].start};i1(g,-m),i1(y,m),c={type:m>1?"strongSequence":"emphasisSequence",start:g,end:{...e[r][1].end}},f={type:m>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:y},u={type:m>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[a][1].start}},o={type:m>1?"strong":"emphasis",start:{...c.start},end:{...f.end}},e[r][1].end={...c.start},e[a][1].start={...f.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=ka(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=ka(h,[["enter",o,t],["enter",c,t],["exit",c,t],["enter",u,t]]),h=ka(h,td(t.parser.constructs.insideSpan.null,e.slice(r+1,a),t)),h=ka(h,[["exit",u,t],["enter",f,t],["exit",f,t],["exit",o,t]]),e[a][1].end.offset-e[a][1].start.offset?(b=2,h=ka(h,[["enter",e[a][1],t],["exit",e[a][1],t]])):b=0,xa(e,r-1,a-r+3,h),a=r+h.length-b-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function sk(e,t){const a=this.parser.constructs.attentionMarkers.null,r=this.previous,o=$i(r);let u;return c;function c(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=$i(m),g=!b||b===2&&o||a.includes(m),y=!o||o===2&&b||a.includes(r);return h._open=!!(u===42?g:g&&(o||!y)),h._close=!!(u===42?y:y&&(b||!g)),t(m)}}function i1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const rk={name:"autolink",tokenize:ik};function ik(e,t,a){let r=0;return o;function o(N){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(N),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),u}function u(N){return Fn(N)?(e.consume(N),c):N===64?a(N):h(N)}function c(N){return N===43||N===45||N===46||Rn(N)?(r=1,f(N)):h(N)}function f(N){return N===58?(e.consume(N),r=0,m):(N===43||N===45||N===46||Rn(N))&&r++<32?(e.consume(N),f):(r=0,h(N))}function m(N){return N===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(N),e.exit("autolinkMarker"),e.exit("autolink"),t):N===null||N===32||N===60||Oc(N)?a(N):(e.consume(N),m)}function h(N){return N===64?(e.consume(N),b):Xw(N)?(e.consume(N),h):a(N)}function b(N){return Rn(N)?g(N):a(N)}function g(N){return N===46?(e.consume(N),r=0,b):N===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(N),e.exit("autolinkMarker"),e.exit("autolink"),t):y(N)}function y(N){if((N===45||Rn(N))&&r++<63){const v=N===45?y:g;return e.consume(N),v}return a(N)}}const Do={partial:!0,tokenize:lk};function lk(e,t,a){return r;function r(u){return it(u)?ft(e,o,"linePrefix")(u):o(u)}function o(u){return u===null||Fe(u)?t(u):a(u)}}const cN={continuation:{tokenize:uk},exit:ck,name:"blockQuote",tokenize:ok};function ok(e,t,a){const r=this;return o;function o(c){if(c===62){const f=r.containerState;return f.open||(e.enter("blockQuote",{_container:!0}),f.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(c),e.exit("blockQuoteMarker"),u}return a(c)}function u(c){return it(c)?(e.enter("blockQuotePrefixWhitespace"),e.consume(c),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(c))}}function uk(e,t,a){const r=this;return o;function o(c){return it(c)?ft(e,u,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):u(c)}function u(c){return e.attempt(cN,t,a)(c)}}function ck(e){e.exit("blockQuote")}const dN={name:"characterEscape",tokenize:dk};function dk(e,t,a){return r;function r(u){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(u),e.exit("escapeMarker"),o}function o(u){return Ww(u)?(e.enter("characterEscapeValue"),e.consume(u),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):a(u)}}const fN={name:"characterReference",tokenize:fk};function fk(e,t,a){const r=this;let o=0,u,c;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,c=Rn,b(g))}function h(g){return g===88||g===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(g),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),u=6,c=Qw,b):(e.enter("characterReferenceValue"),u=7,c=fh,b(g))}function b(g){if(g===59&&o){const y=e.exit("characterReferenceValue");return c===Rn&&!sp(r.sliceSerialize(y))?a(g):(e.enter("characterReferenceMarker"),e.consume(g),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return c(g)&&o++<u?(e.consume(g),b):a(g)}}const l1={partial:!0,tokenize:hk},o1={concrete:!0,name:"codeFenced",tokenize:mk};function mk(e,t,a){const r=this,o={partial:!0,tokenize:I};let u=0,c=0,f;return m;function m(U){return h(U)}function h(U){const $=r.events[r.events.length-1];return u=$&&$[1].type==="linePrefix"?$[2].sliceSerialize($[1],!0).length:0,f=U,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),b(U)}function b(U){return U===f?(c++,e.consume(U),b):c<3?a(U):(e.exit("codeFencedFenceSequence"),it(U)?ft(e,g,"whitespace")(U):g(U))}function g(U){return U===null||Fe(U)?(e.exit("codeFencedFence"),r.interrupt?t(U):e.check(l1,A,j)(U)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),y(U))}function y(U){return U===null||Fe(U)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),g(U)):it(U)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ft(e,N,"whitespace")(U)):U===96&&U===f?a(U):(e.consume(U),y)}function N(U){return U===null||Fe(U)?g(U):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),v(U))}function v(U){return U===null||Fe(U)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),g(U)):U===96&&U===f?a(U):(e.consume(U),v)}function A(U){return e.attempt(o,j,C)(U)}function C(U){return e.enter("lineEnding"),e.consume(U),e.exit("lineEnding"),S}function S(U){return u>0&&it(U)?ft(e,M,"linePrefix",u+1)(U):M(U)}function M(U){return U===null||Fe(U)?e.check(l1,A,j)(U):(e.enter("codeFlowValue"),O(U))}function O(U){return U===null||Fe(U)?(e.exit("codeFlowValue"),M(U)):(e.consume(U),O)}function j(U){return e.exit("codeFenced"),t(U)}function I(U,$,Z){let K=0;return D;function D(q){return U.enter("lineEnding"),U.consume(q),U.exit("lineEnding"),te}function te(q){return U.enter("codeFencedFence"),it(q)?ft(U,le,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):le(q)}function le(q){return q===f?(U.enter("codeFencedFenceSequence"),pe(q)):Z(q)}function pe(q){return q===f?(K++,U.consume(q),pe):K>=c?(U.exit("codeFencedFenceSequence"),it(q)?ft(U,Q,"whitespace")(q):Q(q)):Z(q)}function Q(q){return q===null||Fe(q)?(U.exit("codeFencedFence"),$(q)):Z(q)}}}function hk(e,t,a){const r=this;return o;function o(c){return c===null?a(c):(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u)}function u(c){return r.parser.lazy[r.now().line]?a(c):t(c)}}const Cm={name:"codeIndented",tokenize:gk},pk={partial:!0,tokenize:bk};function gk(e,t,a){const r=this;return o;function o(h){return e.enter("codeIndented"),ft(e,u,"linePrefix",5)(h)}function u(h){const b=r.events[r.events.length-1];return b&&b[1].type==="linePrefix"&&b[2].sliceSerialize(b[1],!0).length>=4?c(h):a(h)}function c(h){return h===null?m(h):Fe(h)?e.attempt(pk,c,m)(h):(e.enter("codeFlowValue"),f(h))}function f(h){return h===null||Fe(h)?(e.exit("codeFlowValue"),c(h)):(e.consume(h),f)}function m(h){return e.exit("codeIndented"),t(h)}}function bk(e,t,a){const r=this;return o;function o(c){return r.parser.lazy[r.now().line]?a(c):Fe(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),o):ft(e,u,"linePrefix",5)(c)}function u(c){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):Fe(c)?o(c):a(c)}}const xk={name:"codeText",previous:yk,resolve:Ek,tokenize:Nk};function Ek(e){let t=e.length-4,a=3,r,o;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=a;++r<t;)if(e[r][1].type==="codeTextData"){e[a][1].type="codeTextPadding",e[t][1].type="codeTextPadding",a+=2,t-=2;break}}for(r=a-1,t++;++r<=t;)o===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(o=r):(r===t||e[r][1].type==="lineEnding")&&(e[o][1].type="codeTextData",r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),t-=r-o-2,r=o+2),o=void 0);return e}function yk(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Nk(e,t,a){let r=0,o,u;return c;function c(g){return e.enter("codeText"),e.enter("codeTextSequence"),f(g)}function f(g){return g===96?(e.consume(g),r++,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"),o=0,b(g)):Fe(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||Fe(g)?(e.exit("codeTextData"),m(g)):(e.consume(g),h)}function b(g){return g===96?(e.consume(g),o++,b):o===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(g)):(u.type="codeTextData",h(g))}}class Tk{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 r=a??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,a,r){const o=a||0;this.setCursor(Math.trunc(t));const u=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return r&&to(this.left,r),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),to(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),to(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);to(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);to(this.left,a.reverse())}}}function to(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 mN(e){const t={};let a=-1,r,o,u,c,f,m,h;const b=new Tk(e);for(;++a<b.length;){for(;a in t;)a=t[a];if(r=b.get(a),a&&r[1].type==="chunkFlow"&&b.get(a-1)[1].type==="listItemPrefix"&&(m=r[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(r[0]==="enter")r[1].contentType&&(Object.assign(t,_k(b,a)),a=t[a],h=!0);else if(r[1]._container){for(u=a,o=void 0;u--;)if(c=b.get(u),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(o&&(b.get(o)[1].type="lineEndingBlank"),c[1].type="lineEnding",o=u);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;o&&(r[1].end={...b.get(o)[1].start},f=b.slice(o,a),f.unshift(r),b.splice(o,a-o+1,f))}}return xa(e,0,Number.POSITIVE_INFINITY,b.slice(0)),!h}function _k(e,t){const a=e.get(t)[1],r=e.get(t)[2];let o=t-1;const u=[];let c=a._tokenizer;c||(c=r.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const f=c.events,m=[],h={};let b,g,y=-1,N=a,v=0,A=0;const C=[A];for(;N;){for(;e.get(++o)[1]!==N;);u.push(o),N._tokenizer||(b=r.sliceStream(N),N.next||b.push(null),g&&c.defineSkip(N.start),N._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(b),N._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=N,N=N.next}for(N=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&&(A=y+1,C.push(A),N._tokenizer=void 0,N.previous=void 0,N=N.next);for(c.events=[],N?(N._tokenizer=void 0,N.previous=void 0):C.pop(),y=C.length;y--;){const S=f.slice(C[y],C[y+1]),M=u.pop();m.push([M,M+S.length-1]),e.splice(M,2,S)}for(m.reverse(),y=-1;++y<m.length;)h[v+m[y][0]]=v+m[y][1],v+=m[y][1]-m[y][0]-1;return h}const vk={resolve:Ak,tokenize:Ck},Sk={partial:!0,tokenize:wk};function Ak(e){return mN(e),e}function Ck(e,t){let a;return r;function r(f){return e.enter("content"),a=e.enter("chunkContent",{contentType:"content"}),o(f)}function o(f){return f===null?u(f):Fe(f)?e.check(Sk,c,u)(f):(e.consume(f),o)}function u(f){return e.exit("chunkContent"),e.exit("content"),t(f)}function c(f){return e.consume(f),e.exit("chunkContent"),a.next=e.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,o}}function wk(e,t,a){const r=this;return o;function o(c){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),ft(e,u,"linePrefix")}function u(c){if(c===null||Fe(c))return a(c);const f=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?t(c):e.interrupt(r.parser.constructs.flow,a,t)(c)}}function hN(e,t,a,r,o,u,c,f,m){const h=m||Number.POSITIVE_INFINITY;let b=0;return g;function g(S){return S===60?(e.enter(r),e.enter(o),e.enter(u),e.consume(S),e.exit(u),y):S===null||S===32||S===41||Oc(S)?a(S):(e.enter(r),e.enter(c),e.enter(f),e.enter("chunkString",{contentType:"string"}),A(S))}function y(S){return S===62?(e.enter(u),e.consume(S),e.exit(u),e.exit(o),e.exit(r),t):(e.enter(f),e.enter("chunkString",{contentType:"string"}),N(S))}function N(S){return S===62?(e.exit("chunkString"),e.exit(f),y(S)):S===null||S===60||Fe(S)?a(S):(e.consume(S),S===92?v:N)}function v(S){return S===60||S===62||S===92?(e.consume(S),N):N(S)}function A(S){return!b&&(S===null||S===41||Ot(S))?(e.exit("chunkString"),e.exit(f),e.exit(c),e.exit(r),t(S)):b<h&&S===40?(e.consume(S),b++,A):S===41?(e.consume(S),b--,A):S===null||S===32||S===40||Oc(S)?a(S):(e.consume(S),S===92?C:A)}function C(S){return S===40||S===41||S===92?(e.consume(S),A):A(S)}}function pN(e,t,a,r,o,u){const c=this;let f=0,m;return h;function h(N){return e.enter(r),e.enter(o),e.consume(N),e.exit(o),e.enter(u),b}function b(N){return f>999||N===null||N===91||N===93&&!m||N===94&&!f&&"_hiddenFootnoteSupport"in c.parser.constructs?a(N):N===93?(e.exit(u),e.enter(o),e.consume(N),e.exit(o),e.exit(r),t):Fe(N)?(e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),b):(e.enter("chunkString",{contentType:"string"}),g(N))}function g(N){return N===null||N===91||N===93||Fe(N)||f++>999?(e.exit("chunkString"),b(N)):(e.consume(N),m||(m=!it(N)),N===92?y:g)}function y(N){return N===91||N===92||N===93?(e.consume(N),f++,g):g(N)}}function gN(e,t,a,r,o,u){let c;return f;function f(y){return y===34||y===39||y===40?(e.enter(r),e.enter(o),e.consume(y),e.exit(o),c=y===40?41:y,m):a(y)}function m(y){return y===c?(e.enter(o),e.consume(y),e.exit(o),e.exit(r),t):(e.enter(u),h(y))}function h(y){return y===c?(e.exit(u),m(c)):y===null?a(y):Fe(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),ft(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),b(y))}function b(y){return y===c||y===null||Fe(y)?(e.exit("chunkString"),h(y)):(e.consume(y),y===92?g:b)}function g(y){return y===c||y===92?(e.consume(y),b):b(y)}}function uo(e,t){let a;return r;function r(o){return Fe(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,r):it(o)?ft(e,r,a?"linePrefix":"lineSuffix")(o):t(o)}}const kk={name:"definition",tokenize:Ok},Rk={partial:!0,tokenize:Ik};function Ok(e,t,a){const r=this;let o;return u;function u(N){return e.enter("definition"),c(N)}function c(N){return pN.call(r,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(N)}function f(N){return o=Ha(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),N===58?(e.enter("definitionMarker"),e.consume(N),e.exit("definitionMarker"),m):a(N)}function m(N){return Ot(N)?uo(e,h)(N):h(N)}function h(N){return hN(e,b,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(N)}function b(N){return e.attempt(Rk,g,g)(N)}function g(N){return it(N)?ft(e,y,"whitespace")(N):y(N)}function y(N){return N===null||Fe(N)?(e.exit("definition"),r.parser.defined.push(o),t(N)):a(N)}}function Ik(e,t,a){return r;function r(f){return Ot(f)?uo(e,o)(f):a(f)}function o(f){return gN(e,u,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function u(f){return it(f)?ft(e,c,"whitespace")(f):c(f)}function c(f){return f===null||Fe(f)?t(f):a(f)}}const Mk={name:"hardBreakEscape",tokenize:Dk};function Dk(e,t,a){return r;function r(u){return e.enter("hardBreakEscape"),e.consume(u),o}function o(u){return Fe(u)?(e.exit("hardBreakEscape"),t(u)):a(u)}}const Lk={name:"headingAtx",resolve:jk,tokenize:Bk};function jk(e,t){let a=e.length-2,r=3,o,u;return e[r][1].type==="whitespace"&&(r+=2),a-2>r&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(r===a-1||a-4>r&&e[a-2][1].type==="whitespace")&&(a-=r+1===a?2:4),a>r&&(o={type:"atxHeadingText",start:e[r][1].start,end:e[a][1].end},u={type:"chunkText",start:e[r][1].start,end:e[a][1].end,contentType:"text"},xa(e,r,a-r+1,[["enter",o,t],["enter",u,t],["exit",u,t],["exit",o,t]])),e}function Bk(e,t,a){let r=0;return o;function o(b){return e.enter("atxHeading"),u(b)}function u(b){return e.enter("atxHeadingSequence"),c(b)}function c(b){return b===35&&r++<6?(e.consume(b),c):b===null||Ot(b)?(e.exit("atxHeadingSequence"),f(b)):a(b)}function f(b){return b===35?(e.enter("atxHeadingSequence"),m(b)):b===null||Fe(b)?(e.exit("atxHeading"),t(b)):it(b)?ft(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||Ot(b)?(e.exit("atxHeadingText"),f(b)):(e.consume(b),h)}}const Pk=["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"],u1=["pre","script","style","textarea"],Uk={concrete:!0,name:"htmlFlow",resolveTo:zk,tokenize:$k},Hk={partial:!0,tokenize:Yk},Fk={partial:!0,tokenize:qk};function zk(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 $k(e,t,a){const r=this;let o,u,c,f,m;return h;function h(L){return b(L)}function b(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),g}function g(L){return L===33?(e.consume(L),y):L===47?(e.consume(L),u=!0,A):L===63?(e.consume(L),o=3,r.interrupt?t:w):Fn(L)?(e.consume(L),c=String.fromCharCode(L),C):a(L)}function y(L){return L===45?(e.consume(L),o=2,N):L===91?(e.consume(L),o=5,f=0,v):Fn(L)?(e.consume(L),o=4,r.interrupt?t:w):a(L)}function N(L){return L===45?(e.consume(L),r.interrupt?t:w):a(L)}function v(L){const Ne="CDATA[";return L===Ne.charCodeAt(f++)?(e.consume(L),f===Ne.length?r.interrupt?t:le:v):a(L)}function A(L){return Fn(L)?(e.consume(L),c=String.fromCharCode(L),C):a(L)}function C(L){if(L===null||L===47||L===62||Ot(L)){const Ne=L===47,Te=c.toLowerCase();return!Ne&&!u&&u1.includes(Te)?(o=1,r.interrupt?t(L):le(L)):Pk.includes(c.toLowerCase())?(o=6,Ne?(e.consume(L),S):r.interrupt?t(L):le(L)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?a(L):u?M(L):O(L))}return L===45||Rn(L)?(e.consume(L),c+=String.fromCharCode(L),C):a(L)}function S(L){return L===62?(e.consume(L),r.interrupt?t:le):a(L)}function M(L){return it(L)?(e.consume(L),M):D(L)}function O(L){return L===47?(e.consume(L),D):L===58||L===95||Fn(L)?(e.consume(L),j):it(L)?(e.consume(L),O):D(L)}function j(L){return L===45||L===46||L===58||L===95||Rn(L)?(e.consume(L),j):I(L)}function I(L){return L===61?(e.consume(L),U):it(L)?(e.consume(L),I):O(L)}function U(L){return L===null||L===60||L===61||L===62||L===96?a(L):L===34||L===39?(e.consume(L),m=L,$):it(L)?(e.consume(L),U):Z(L)}function $(L){return L===m?(e.consume(L),m=null,K):L===null||Fe(L)?a(L):(e.consume(L),$)}function Z(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||Ot(L)?I(L):(e.consume(L),Z)}function K(L){return L===47||L===62||it(L)?O(L):a(L)}function D(L){return L===62?(e.consume(L),te):a(L)}function te(L){return L===null||Fe(L)?le(L):it(L)?(e.consume(L),te):a(L)}function le(L){return L===45&&o===2?(e.consume(L),F):L===60&&o===1?(e.consume(L),k):L===62&&o===4?(e.consume(L),H):L===63&&o===3?(e.consume(L),w):L===93&&o===5?(e.consume(L),J):Fe(L)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(Hk,se,pe)(L)):L===null||Fe(L)?(e.exit("htmlFlowData"),pe(L)):(e.consume(L),le)}function pe(L){return e.check(Fk,Q,se)(L)}function Q(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),q}function q(L){return L===null||Fe(L)?pe(L):(e.enter("htmlFlowData"),le(L))}function F(L){return L===45?(e.consume(L),w):le(L)}function k(L){return L===47?(e.consume(L),c="",P):le(L)}function P(L){if(L===62){const Ne=c.toLowerCase();return u1.includes(Ne)?(e.consume(L),H):le(L)}return Fn(L)&&c.length<8?(e.consume(L),c+=String.fromCharCode(L),P):le(L)}function J(L){return L===93?(e.consume(L),w):le(L)}function w(L){return L===62?(e.consume(L),H):L===45&&o===2?(e.consume(L),w):le(L)}function H(L){return L===null||Fe(L)?(e.exit("htmlFlowData"),se(L)):(e.consume(L),H)}function se(L){return e.exit("htmlFlow"),t(L)}}function qk(e,t,a){const r=this;return o;function o(c){return Fe(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u):a(c)}function u(c){return r.parser.lazy[r.now().line]?a(c):t(c)}}function Yk(e,t,a){return r;function r(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(Do,t,a)}}const Gk={name:"htmlText",tokenize:Kk};function Kk(e,t,a){const r=this;let o,u,c;return f;function f(w){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(w),m}function m(w){return w===33?(e.consume(w),h):w===47?(e.consume(w),I):w===63?(e.consume(w),O):Fn(w)?(e.consume(w),Z):a(w)}function h(w){return w===45?(e.consume(w),b):w===91?(e.consume(w),u=0,v):Fn(w)?(e.consume(w),M):a(w)}function b(w){return w===45?(e.consume(w),N):a(w)}function g(w){return w===null?a(w):w===45?(e.consume(w),y):Fe(w)?(c=g,k(w)):(e.consume(w),g)}function y(w){return w===45?(e.consume(w),N):g(w)}function N(w){return w===62?F(w):w===45?y(w):g(w)}function v(w){const H="CDATA[";return w===H.charCodeAt(u++)?(e.consume(w),u===H.length?A:v):a(w)}function A(w){return w===null?a(w):w===93?(e.consume(w),C):Fe(w)?(c=A,k(w)):(e.consume(w),A)}function C(w){return w===93?(e.consume(w),S):A(w)}function S(w){return w===62?F(w):w===93?(e.consume(w),S):A(w)}function M(w){return w===null||w===62?F(w):Fe(w)?(c=M,k(w)):(e.consume(w),M)}function O(w){return w===null?a(w):w===63?(e.consume(w),j):Fe(w)?(c=O,k(w)):(e.consume(w),O)}function j(w){return w===62?F(w):O(w)}function I(w){return Fn(w)?(e.consume(w),U):a(w)}function U(w){return w===45||Rn(w)?(e.consume(w),U):$(w)}function $(w){return Fe(w)?(c=$,k(w)):it(w)?(e.consume(w),$):F(w)}function Z(w){return w===45||Rn(w)?(e.consume(w),Z):w===47||w===62||Ot(w)?K(w):a(w)}function K(w){return w===47?(e.consume(w),F):w===58||w===95||Fn(w)?(e.consume(w),D):Fe(w)?(c=K,k(w)):it(w)?(e.consume(w),K):F(w)}function D(w){return w===45||w===46||w===58||w===95||Rn(w)?(e.consume(w),D):te(w)}function te(w){return w===61?(e.consume(w),le):Fe(w)?(c=te,k(w)):it(w)?(e.consume(w),te):K(w)}function le(w){return w===null||w===60||w===61||w===62||w===96?a(w):w===34||w===39?(e.consume(w),o=w,pe):Fe(w)?(c=le,k(w)):it(w)?(e.consume(w),le):(e.consume(w),Q)}function pe(w){return w===o?(e.consume(w),o=void 0,q):w===null?a(w):Fe(w)?(c=pe,k(w)):(e.consume(w),pe)}function Q(w){return w===null||w===34||w===39||w===60||w===61||w===96?a(w):w===47||w===62||Ot(w)?K(w):(e.consume(w),Q)}function q(w){return w===47||w===62||Ot(w)?K(w):a(w)}function F(w){return w===62?(e.consume(w),e.exit("htmlTextData"),e.exit("htmlText"),t):a(w)}function k(w){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(w),e.exit("lineEnding"),P}function P(w){return it(w)?ft(e,J,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(w):J(w)}function J(w){return e.enter("htmlTextData"),c(w)}}const rp={name:"labelEnd",resolveAll:Wk,resolveTo:Zk,tokenize:Jk},Vk={tokenize:eR},Xk={tokenize:tR},Qk={tokenize:nR};function Wk(e){let t=-1;const a=[];for(;++t<e.length;){const r=e[t][1];if(a.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const o=r.type==="labelImage"?4:2;r.type="data",t+=o}}return e.length!==a.length&&xa(e,0,e.length,a),e}function Zk(e,t){let a=e.length,r=0,o,u,c,f;for(;a--;)if(o=e[a][1],u){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;e[a][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(c){if(e[a][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(u=a,o.type!=="labelLink")){r=2;break}}else o.type==="labelEnd"&&(c=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[c][1].end}},b={type:"labelText",start:{...e[u+r+2][1].end},end:{...e[c-2][1].start}};return f=[["enter",m,t],["enter",h,t]],f=ka(f,e.slice(u+1,u+r+3)),f=ka(f,[["enter",b,t]]),f=ka(f,td(t.parser.constructs.insideSpan.null,e.slice(u+r+4,c-3),t)),f=ka(f,[["exit",b,t],e[c-2],e[c-1],["exit",h,t]]),f=ka(f,e.slice(c+1)),f=ka(f,[["exit",m,t]]),xa(e,u,e.length,f),e}function Jk(e,t,a){const r=this;let o=r.events.length,u,c;for(;o--;)if((r.events[o][1].type==="labelImage"||r.events[o][1].type==="labelLink")&&!r.events[o][1]._balanced){u=r.events[o][1];break}return f;function f(y){return u?u._inactive?g(y):(c=r.parser.defined.includes(Ha(r.sliceSerialize({start:u.end,end:r.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(Vk,b,c?b:g)(y):y===91?e.attempt(Xk,b,c?h:g)(y):c?b(y):g(y)}function h(y){return e.attempt(Qk,b,g)(y)}function b(y){return t(y)}function g(y){return u._balanced=!0,a(y)}}function eR(e,t,a){return r;function r(g){return e.enter("resource"),e.enter("resourceMarker"),e.consume(g),e.exit("resourceMarker"),o}function o(g){return Ot(g)?uo(e,u)(g):u(g)}function u(g){return g===41?b(g):hN(e,c,f,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return Ot(g)?uo(e,m)(g):b(g)}function f(g){return a(g)}function m(g){return g===34||g===39||g===40?gN(e,h,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):b(g)}function h(g){return Ot(g)?uo(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 tR(e,t,a){const r=this;return o;function o(f){return pN.call(r,e,u,c,"reference","referenceMarker","referenceString")(f)}function u(f){return r.parser.defined.includes(Ha(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(f):a(f)}function c(f){return a(f)}}function nR(e,t,a){return r;function r(u){return e.enter("reference"),e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),o}function o(u){return u===93?(e.enter("referenceMarker"),e.consume(u),e.exit("referenceMarker"),e.exit("reference"),t):a(u)}}const aR={name:"labelStartImage",resolveAll:rp.resolveAll,tokenize:sR};function sR(e,t,a){const r=this;return o;function o(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"),c):a(f)}function c(f){return f===94&&"_hiddenFootnoteSupport"in r.parser.constructs?a(f):t(f)}}const rR={name:"labelStartLink",resolveAll:rp.resolveAll,tokenize:iR};function iR(e,t,a){const r=this;return o;function o(c){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelLink"),u}function u(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?a(c):t(c)}}const wm={name:"lineEnding",tokenize:lR};function lR(e,t){return a;function a(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),ft(e,t,"linePrefix")}}const Ec={name:"thematicBreak",tokenize:oR};function oR(e,t,a){let r=0,o;return u;function u(h){return e.enter("thematicBreak"),c(h)}function c(h){return o=h,f(h)}function f(h){return h===o?(e.enter("thematicBreakSequence"),m(h)):r>=3&&(h===null||Fe(h))?(e.exit("thematicBreak"),t(h)):a(h)}function m(h){return h===o?(e.consume(h),r++,m):(e.exit("thematicBreakSequence"),it(h)?ft(e,f,"whitespace")(h):f(h))}}const aa={continuation:{tokenize:fR},exit:hR,name:"list",tokenize:dR},uR={partial:!0,tokenize:pR},cR={partial:!0,tokenize:mR};function dR(e,t,a){const r=this,o=r.events[r.events.length-1];let u=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,c=0;return f;function f(N){const v=r.containerState.type||(N===42||N===43||N===45?"listUnordered":"listOrdered");if(v==="listUnordered"?!r.containerState.marker||N===r.containerState.marker:fh(N)){if(r.containerState.type||(r.containerState.type=v,e.enter(v,{_container:!0})),v==="listUnordered")return e.enter("listItemPrefix"),N===42||N===45?e.check(Ec,a,h)(N):h(N);if(!r.interrupt||N===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),m(N)}return a(N)}function m(N){return fh(N)&&++c<10?(e.consume(N),m):(!r.interrupt||c<2)&&(r.containerState.marker?N===r.containerState.marker:N===41||N===46)?(e.exit("listItemValue"),h(N)):a(N)}function h(N){return e.enter("listItemMarker"),e.consume(N),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||N,e.check(Do,r.interrupt?a:b,e.attempt(uR,y,g))}function b(N){return r.containerState.initialBlankLine=!0,u++,y(N)}function g(N){return it(N)?(e.enter("listItemPrefixWhitespace"),e.consume(N),e.exit("listItemPrefixWhitespace"),y):a(N)}function y(N){return r.containerState.size=u+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(N)}}function fR(e,t,a){const r=this;return r.containerState._closeFlow=void 0,e.check(Do,o,u);function o(f){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,ft(e,t,"listItemIndent",r.containerState.size+1)(f)}function u(f){return r.containerState.furtherBlankLines||!it(f)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,c(f)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(cR,t,c)(f))}function c(f){return r.containerState._closeFlow=!0,r.interrupt=void 0,ft(e,e.attempt(aa,t,a),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function mR(e,t,a){const r=this;return ft(e,o,"listItemIndent",r.containerState.size+1);function o(u){const c=r.events[r.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===r.containerState.size?t(u):a(u)}}function hR(e){e.exit(this.containerState.type)}function pR(e,t,a){const r=this;return ft(e,o,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(u){const c=r.events[r.events.length-1];return!it(u)&&c&&c[1].type==="listItemPrefixWhitespace"?t(u):a(u)}}const c1={name:"setextUnderline",resolveTo:gR,tokenize:bR};function gR(e,t){let a=e.length,r,o,u;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){r=a;break}e[a][1].type==="paragraph"&&(o=a)}else e[a][1].type==="content"&&e.splice(a,1),!u&&e[a][1].type==="definition"&&(u=a);const c={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",u?(e.splice(o,0,["enter",c,t]),e.splice(u+1,0,["exit",e[r][1],t]),e[r][1].end={...e[u][1].end}):e[r][1]=c,e.push(["exit",c,t]),e}function bR(e,t,a){const r=this;let o;return u;function u(h){let b=r.events.length,g;for(;b--;)if(r.events[b][1].type!=="lineEnding"&&r.events[b][1].type!=="linePrefix"&&r.events[b][1].type!=="content"){g=r.events[b][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||g)?(e.enter("setextHeadingLine"),o=h,c(h)):a(h)}function c(h){return e.enter("setextHeadingLineSequence"),f(h)}function f(h){return h===o?(e.consume(h),f):(e.exit("setextHeadingLineSequence"),it(h)?ft(e,m,"lineSuffix")(h):m(h))}function m(h){return h===null||Fe(h)?(e.exit("setextHeadingLine"),t(h)):a(h)}}const xR={tokenize:ER};function ER(e){const t=this,a=e.attempt(Do,r,e.attempt(this.parser.constructs.flowInitial,o,ft(e,e.attempt(this.parser.constructs.flow,o,e.attempt(vk,o)),"linePrefix")));return a;function r(u){if(u===null){e.consume(u);return}return e.enter("lineEndingBlank"),e.consume(u),e.exit("lineEndingBlank"),t.currentConstruct=void 0,a}function o(u){if(u===null){e.consume(u);return}return e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),t.currentConstruct=void 0,a}}const yR={resolveAll:xN()},NR=bN("string"),TR=bN("text");function bN(e){return{resolveAll:xN(e==="text"?_R:void 0),tokenize:t};function t(a){const r=this,o=this.parser.constructs[e],u=a.attempt(o,c,f);return c;function c(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=o[b];let y=-1;if(g)for(;++y<g.length;){const N=g[y];if(!N.previous||N.previous.call(r,r.previous))return!0}return!1}}}function xN(e){return t;function t(a,r){let o=-1,u;for(;++o<=a.length;)u===void 0?a[o]&&a[o][1].type==="data"&&(u=o,o++):(!a[o]||a[o][1].type!=="data")&&(o!==u+2&&(a[u][1].end=a[o-1][1].end,a.splice(u+2,o-u-2),o=u+2),u=void 0);return e?e(a,r):a}}function _R(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 r=e[a-1][1],o=t.sliceStream(r);let u=o.length,c=-1,f=0,m;for(;u--;){const h=o[u];if(typeof h=="string"){for(c=h.length;h.charCodeAt(c-1)===32;)f++,c--;if(c)break;c=-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?c:r.start._bufferIndex+c,_index:r.start._index+u,line:r.end.line,column:r.end.column-f,offset:r.end.offset-f},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(a,0,["enter",h,t],["exit",h,t]),a+=2)}a++}return e}const vR={42:aa,43:aa,45:aa,48:aa,49:aa,50:aa,51:aa,52:aa,53:aa,54:aa,55:aa,56:aa,57:aa,62:cN},SR={91:kk},AR={[-2]:Cm,[-1]:Cm,32:Cm},CR={35:Lk,42:Ec,45:[c1,Ec],60:Uk,61:c1,95:Ec,96:o1,126:o1},wR={38:fN,92:dN},kR={[-5]:wm,[-4]:wm,[-3]:wm,33:aR,38:fN,42:mh,60:[rk,Gk],91:rR,92:[Mk,dN],93:rp,95:mh,96:xk},RR={null:[mh,yR]},OR={null:[42,95]},IR={null:[]},MR=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:OR,contentInitial:SR,disable:IR,document:vR,flow:CR,flowInitial:AR,insideSpan:RR,string:wR,text:kR},Symbol.toStringTag,{value:"Module"}));function DR(e,t,a){let r={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const o={},u=[];let c=[],f=[];const m={attempt:$(I),check:$(U),consume:M,enter:O,exit:j,interrupt:$(U,{interrupt:!0})},h={code:null,containerState:{},defineSkip:A,events:[],now:v,parser:e,previous:null,sliceSerialize:y,sliceStream:N,write:g};let b=t.tokenize.call(h,m);return t.resolveAll&&u.push(t),h;function g(te){return c=ka(c,te),C(),c[c.length-1]!==null?[]:(Z(t,0),h.events=td(u,h.events,h),h.events)}function y(te,le){return jR(N(te),le)}function N(te){return LR(c,te)}function v(){const{_bufferIndex:te,_index:le,line:pe,column:Q,offset:q}=r;return{_bufferIndex:te,_index:le,line:pe,column:Q,offset:q}}function A(te){o[te.line]=te.column,D()}function C(){let te;for(;r._index<c.length;){const le=c[r._index];if(typeof le=="string")for(te=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===te&&r._bufferIndex<le.length;)S(le.charCodeAt(r._bufferIndex));else S(le)}}function S(te){b=b(te)}function M(te){Fe(te)?(r.line++,r.column=1,r.offset+=te===-3?2:1,D()):te!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===c[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=te}function O(te,le){const pe=le||{};return pe.type=te,pe.start=v(),h.events.push(["enter",pe,h]),f.push(pe),pe}function j(te){const le=f.pop();return le.end=v(),h.events.push(["exit",le,h]),le}function I(te,le){Z(te,le.from)}function U(te,le){le.restore()}function $(te,le){return pe;function pe(Q,q,F){let k,P,J,w;return Array.isArray(Q)?se(Q):"tokenize"in Q?se([Q]):H(Q);function H(V){return ve;function ve(Be){const Ue=Be!==null&&V[Be],xt=Be!==null&&V.null,un=[...Array.isArray(Ue)?Ue:Ue?[Ue]:[],...Array.isArray(xt)?xt:xt?[xt]:[]];return se(un)(Be)}}function se(V){return k=V,P=0,V.length===0?F:L(V[P])}function L(V){return ve;function ve(Be){return w=K(),J=V,V.partial||(h.currentConstruct=V),V.name&&h.parser.constructs.disable.null.includes(V.name)?Te():V.tokenize.call(le?Object.assign(Object.create(h),le):h,m,Ne,Te)(Be)}}function Ne(V){return te(J,w),q}function Te(V){return w.restore(),++P<k.length?L(k[P]):F}}}function Z(te,le){te.resolveAll&&!u.includes(te)&&u.push(te),te.resolve&&xa(h.events,le,h.events.length-le,te.resolve(h.events.slice(le),h)),te.resolveTo&&(h.events=te.resolveTo(h.events,h))}function K(){const te=v(),le=h.previous,pe=h.currentConstruct,Q=h.events.length,q=Array.from(f);return{from:Q,restore:F};function F(){r=te,h.previous=le,h.currentConstruct=pe,h.events.length=Q,f=q,D()}}function D(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function LR(e,t){const a=t.start._index,r=t.start._bufferIndex,o=t.end._index,u=t.end._bufferIndex;let c;if(a===o)c=[e[a].slice(r,u)];else{if(c=e.slice(a,o),r>-1){const f=c[0];typeof f=="string"?c[0]=f.slice(r):c.shift()}u>0&&c.push(e[o].slice(0,u))}return c}function jR(e,t){let a=-1;const r=[];let o;for(;++a<e.length;){const u=e[a];let c;if(typeof u=="string")c=u;else switch(u){case-5:{c="\r";break}case-4:{c=`
464
464
  `;break}case-3:{c=`\r
465
465
  `;break}case-2:{c=t?" ":" ";break}case-1:{if(!t&&o)continue;c=" ";break}default:c=String.fromCharCode(u)}o=u===-2,r.push(c)}return r.join("")}function BR(e){const r={constructs:oN([MR,...(e||{}).extensions||[]]),content:o(Zw),defined:[],document:o(ek),flow:o(xR),lazy:{},string:o(NR),text:o(TR)};return r;function o(u){return c;function c(f){return DR(r,u,f)}}}function PR(e){for(;!mN(e););return e}const d1=/[\0\t\n\r]/g;function UR(){let e=1,t="",a=!0,r;return o;function o(u,c,f){const m=[];let h,b,g,y,N;for(u=t+(typeof u=="string"?u.toString():new TextDecoder(c||void 0).decode(u)),g=0,t="",a&&(u.charCodeAt(0)===65279&&g++,a=void 0);g<u.length;){if(d1.lastIndex=g,h=d1.exec(u),y=h&&h.index!==void 0?h.index:u.length,N=u.charCodeAt(y),!h){t=u.slice(g);break}if(N===10&&g===y&&r)m.push(-3),r=void 0;else switch(r&&(m.push(-5),r=void 0),g<y&&(m.push(u.slice(g,y)),e+=y-g),N){case 0:{m.push(65533),e++;break}case 9:{for(b=Math.ceil(e/4)*4,m.push(-2);e++<b;)m.push(-1);break}case 10:{m.push(-4),e=1;break}default:r=!0,e=1}g=y+1}return f&&(r&&m.push(-5),t&&m.push(t),m.push(null)),m}}const HR=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function FR(e){return e.replace(HR,zR)}function zR(e,t,a){if(t)return t;if(a.charCodeAt(0)===35){const o=a.charCodeAt(1),u=o===120||o===88;return uN(a.slice(u?2:1),u?16:10)}return sp(a)||e}const EN={}.hasOwnProperty;function $R(e,t,a){return t&&typeof t=="object"&&(a=t,t=void 0),qR(a)(PR(BR(a).document().write(UR()(e,t,!0))))}function qR(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:u(Yn),autolinkProtocol:K,autolinkEmail:K,atxHeading:u($n),blockQuote:u(xt),characterEscape:K,characterReference:K,codeFenced:u(un),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:u(un,c),codeText:u(cn,c),codeTextData:K,data:K,codeFlowValue:K,definition:u(za),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:u(Dn),hardBreakEscape:u(et),hardBreakTrailing:u(et),htmlFlow:u(qn,c),htmlFlowData:K,htmlText:u(qn,c),htmlTextData:K,image:u(Ln),label:c,link:u(Yn),listItem:u(be),listItemValue:y,listOrdered:u(Da,g),listUnordered:u(Da),paragraph:u(ct),reference:L,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:u($n),strong:u(ia),thematicBreak:u(Qr)},exit:{atxHeading:m(),atxHeadingSequence:I,autolink:m(),autolinkEmail:Ue,autolinkProtocol:Be,blockQuote:m(),characterEscapeValue:D,characterReferenceMarkerHexadecimal:Te,characterReferenceMarkerNumeric:Te,characterReferenceValue:V,characterReference:ve,codeFenced:m(C),codeFencedFence:A,codeFencedFenceInfo:N,codeFencedFenceMeta:v,codeFlowValue:D,codeIndented:m(S),codeText:m(q),codeTextData:D,data:D,definition:m(),definitionDestinationString:j,definitionLabelString:M,definitionTitleString:O,emphasis:m(),hardBreakEscape:m(le),hardBreakTrailing:m(le),htmlFlow:m(pe),htmlFlowData:D,htmlText:m(Q),htmlTextData:D,image:m(k),label:J,labelText:P,lineEnding:te,link:m(F),listItem:m(),listOrdered:m(),listUnordered:m(),paragraph:m(),referenceString:Ne,resourceDestinationString:w,resourceTitleString:H,resource:se,setextHeading:m(Z),setextHeadingLineSequence:$,setextHeadingText:U,strong:m(),thematicBreak:m()}};yN(t,(e||{}).mdastExtensions||[]);const a={};return r;function r(de){let Ae={type:"root",children:[]};const ze={stack:[Ae],tokenStack:[],config:t,enter:f,exit:h,buffer:c,resume:b,data:a},tt=[];let mt=-1;for(;++mt<de.length;)if(de[mt][1].type==="listOrdered"||de[mt][1].type==="listUnordered")if(de[mt][0]==="enter")tt.push(mt);else{const jn=tt.pop();mt=o(de,jn,mt)}for(mt=-1;++mt<de.length;){const jn=t[de[mt][0]];EN.call(jn,de[mt][1].type)&&jn[de[mt][1].type].call(Object.assign({sliceSerialize:de[mt][2].sliceSerialize},ze),de[mt][1])}if(ze.tokenStack.length>0){const jn=ze.tokenStack[ze.tokenStack.length-1];(jn[1]||f1).call(ze,void 0,jn[0])}for(Ae.position={start:sr(de.length>0?de[0][1].start:{line:1,column:1,offset:0}),end:sr(de.length>0?de[de.length-2][1].end:{line:1,column:1,offset:0})},mt=-1;++mt<t.transforms.length;)Ae=t.transforms[mt](Ae)||Ae;return Ae}function o(de,Ae,ze){let tt=Ae-1,mt=-1,jn=!1,La,gn,zt,Sn;for(;++tt<=ze;){const Et=de[tt];switch(Et[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Et[0]==="enter"?mt++:mt--,Sn=void 0;break}case"lineEndingBlank":{Et[0]==="enter"&&(La&&!Sn&&!mt&&!zt&&(zt=tt),Sn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Sn=void 0}if(!mt&&Et[0]==="enter"&&Et[1].type==="listItemPrefix"||mt===-1&&Et[0]==="exit"&&(Et[1].type==="listUnordered"||Et[1].type==="listOrdered")){if(La){let $a=tt;for(gn=void 0;$a--;){const Bn=de[$a];if(Bn[1].type==="lineEnding"||Bn[1].type==="lineEndingBlank"){if(Bn[0]==="exit")continue;gn&&(de[gn][1].type="lineEndingBlank",jn=!0),Bn[1].type="lineEnding",gn=$a}else if(!(Bn[1].type==="linePrefix"||Bn[1].type==="blockQuotePrefix"||Bn[1].type==="blockQuotePrefixWhitespace"||Bn[1].type==="blockQuoteMarker"||Bn[1].type==="listItemIndent"))break}zt&&(!gn||zt<gn)&&(La._spread=!0),La.end=Object.assign({},gn?de[gn][1].start:Et[1].end),de.splice(gn||tt,0,["exit",La,Et[2]]),tt++,ze++}if(Et[1].type==="listItemPrefix"){const $a={type:"listItem",_spread:!1,start:Object.assign({},Et[1].start),end:void 0};La=$a,de.splice(tt,0,["enter",$a,Et[2]]),tt++,ze++,zt=void 0,Sn=!0}}}return de[Ae][1]._spread=jn,ze}function u(de,Ae){return ze;function ze(tt){f.call(this,de(tt),tt),Ae&&Ae.call(this,tt)}}function c(){this.stack.push({type:"fragment",children:[]})}function f(de,Ae,ze){this.stack[this.stack.length-1].children.push(de),this.stack.push(de),this.tokenStack.push([Ae,ze||void 0]),de.position={start:sr(Ae.start),end:void 0}}function m(de){return Ae;function Ae(ze){de&&de.call(this,ze),h.call(this,ze)}}function h(de,Ae){const ze=this.stack.pop(),tt=this.tokenStack.pop();if(tt)tt[0].type!==de.type&&(Ae?Ae.call(this,de,tt[0]):(tt[1]||f1).call(this,de,tt[0]));else throw new Error("Cannot close `"+de.type+"` ("+oo({start:de.start,end:de.end})+"): it’s not open");ze.position.end=sr(de.end)}function b(){return ap(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function y(de){if(this.data.expectingFirstListItemValue){const Ae=this.stack[this.stack.length-2];Ae.start=Number.parseInt(this.sliceSerialize(de),10),this.data.expectingFirstListItemValue=void 0}}function N(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.lang=de}function v(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.meta=de}function A(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function C(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de.replace(/(\r?\n|\r)$/g,"")}function M(de){const Ae=this.resume(),ze=this.stack[this.stack.length-1];ze.label=Ae,ze.identifier=Ha(this.sliceSerialize(de)).toLowerCase()}function O(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=de}function j(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=de}function I(de){const Ae=this.stack[this.stack.length-1];if(!Ae.depth){const ze=this.sliceSerialize(de).length;Ae.depth=ze}}function U(){this.data.setextHeadingSlurpLineEnding=!0}function $(de){const Ae=this.stack[this.stack.length-1];Ae.depth=this.sliceSerialize(de).codePointAt(0)===61?1:2}function Z(){this.data.setextHeadingSlurpLineEnding=void 0}function K(de){const ze=this.stack[this.stack.length-1].children;let tt=ze[ze.length-1];(!tt||tt.type!=="text")&&(tt=It(),tt.position={start:sr(de.start),end:void 0},ze.push(tt)),this.stack.push(tt)}function D(de){const Ae=this.stack.pop();Ae.value+=this.sliceSerialize(de),Ae.position.end=sr(de.end)}function te(de){const Ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ze=Ae.children[Ae.children.length-1];ze.position.end=sr(de.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ae.type)&&(K.call(this,de),D.call(this,de))}function le(){this.data.atHardBreak=!0}function pe(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de}function Q(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de}function q(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=de}function F(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=Ae,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function k(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=Ae,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function P(de){const Ae=this.sliceSerialize(de),ze=this.stack[this.stack.length-2];ze.label=FR(Ae),ze.identifier=Ha(Ae).toLowerCase()}function J(){const de=this.stack[this.stack.length-1],Ae=this.resume(),ze=this.stack[this.stack.length-1];if(this.data.inReference=!0,ze.type==="link"){const tt=de.children;ze.children=tt}else ze.alt=Ae}function w(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=de}function H(){const de=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=de}function se(){this.data.inReference=void 0}function L(){this.data.referenceType="collapsed"}function Ne(de){const Ae=this.resume(),ze=this.stack[this.stack.length-1];ze.label=Ae,ze.identifier=Ha(this.sliceSerialize(de)).toLowerCase(),this.data.referenceType="full"}function Te(de){this.data.characterReferenceType=de.type}function V(de){const Ae=this.sliceSerialize(de),ze=this.data.characterReferenceType;let tt;ze?(tt=uN(Ae,ze==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):tt=sp(Ae);const mt=this.stack[this.stack.length-1];mt.value+=tt}function ve(de){const Ae=this.stack.pop();Ae.position.end=sr(de.end)}function Be(de){D.call(this,de);const Ae=this.stack[this.stack.length-1];Ae.url=this.sliceSerialize(de)}function Ue(de){D.call(this,de);const Ae=this.stack[this.stack.length-1];Ae.url="mailto:"+this.sliceSerialize(de)}function xt(){return{type:"blockquote",children:[]}}function un(){return{type:"code",lang:null,meta:null,value:""}}function cn(){return{type:"inlineCode",value:""}}function za(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Dn(){return{type:"emphasis",children:[]}}function $n(){return{type:"heading",depth:0,children:[]}}function et(){return{type:"break"}}function qn(){return{type:"html",value:""}}function Ln(){return{type:"image",title:null,url:"",alt:null}}function Yn(){return{type:"link",title:null,url:"",children:[]}}function Da(de){return{type:"list",ordered:de.type==="listOrdered",start:null,spread:de._spread,children:[]}}function be(de){return{type:"listItem",spread:de._spread,checked:null,children:[]}}function ct(){return{type:"paragraph",children:[]}}function ia(){return{type:"strong",children:[]}}function It(){return{type:"text",value:""}}function Qr(){return{type:"thematicBreak"}}}function sr(e){return{line:e.line,column:e.column,offset:e.offset}}function yN(e,t){let a=-1;for(;++a<t.length;){const r=t[a];Array.isArray(r)?yN(e,r):YR(e,r)}}function YR(e,t){let a;for(a in t)if(EN.call(t,a))switch(a){case"canContainEols":{const r=t[a];r&&e[a].push(...r);break}case"transforms":{const r=t[a];r&&e[a].push(...r);break}case"enter":case"exit":{const r=t[a];r&&Object.assign(e[a],r);break}}}function f1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+oo({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+oo({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+oo({start:t.start,end:t.end})+") is still open")}function GR(e){const t=this;t.parser=a;function a(r){return $R(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function KR(e,t){const a={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,a),e.applyData(t,a)}function VR(e,t){const a={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,a),[e.applyData(t,a),{type:"text",value:`
@@ -487,7 +487,7 @@ Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}
487
487
  `))+1))}const c="#".repeat(o),f=a.enter("headingAtx"),m=a.enter("phrasing");u.move(c+" ");let h=a.containerPhrasing(e,{before:"# ",after:`
488
488
  `,...u.current()});return/^[\t ]/.test(h)&&(h=So(h.charCodeAt(0))+h.slice(1)),h=h?c+" "+h:c,a.options.closeAtx&&(h+=" "+c),m(),f(),h}jN.peek=fI;function jN(e){return e.value||""}function fI(){return"<"}BN.peek=mI;function BN(e,t,a,r){const o=dp(a),u=o==='"'?"Quote":"Apostrophe",c=a.enter("image");let f=a.enter("label");const m=a.createTracker(r);let h=m.move("![");return h+=m.move(a.safe(e.alt,{before:h,after:"]",...m.current()})),h+=m.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),h+=m.move("<"),h+=m.move(a.safe(e.url,{before:h,after:">",...m.current()})),h+=m.move(">")):(f=a.enter("destinationRaw"),h+=m.move(a.safe(e.url,{before:h,after:e.title?" ":")",...m.current()}))),f(),e.title&&(f=a.enter(`title${u}`),h+=m.move(" "+o),h+=m.move(a.safe(e.title,{before:h,after:o,...m.current()})),h+=m.move(o),f()),h+=m.move(")"),c(),h}function mI(){return"!"}PN.peek=hI;function PN(e,t,a,r){const o=e.referenceType,u=a.enter("imageReference");let c=a.enter("label");const f=a.createTracker(r);let m=f.move("![");const h=a.safe(e.alt,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),c();const b=a.stack;a.stack=[],c=a.enter("reference");const g=a.safe(a.associationId(e),{before:m,after:"]",...f.current()});return c(),a.stack=b,u(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function hI(){return"!"}UN.peek=pI;function UN(e,t,a){let r=e.value||"",o="`",u=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++u<a.unsafe.length;){const c=a.unsafe[u],f=a.compilePattern(c);let m;if(c.atBreak)for(;m=f.exec(r);){let h=m.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(m.index+1)}}return o+r+o}function pI(){return"`"}function HN(e,t){const a=ap(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(a===e.url||"mailto:"+a===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}FN.peek=gI;function FN(e,t,a,r){const o=dp(a),u=o==='"'?"Quote":"Apostrophe",c=a.createTracker(r);let f,m;if(HN(e,a)){const b=a.stack;a.stack=[],f=a.enter("autolink");let g=c.move("<");return g+=c.move(a.containerPhrasing(e,{before:g,after:">",...c.current()})),g+=c.move(">"),f(),a.stack=b,g}f=a.enter("link"),m=a.enter("label");let h=c.move("[");return h+=c.move(a.containerPhrasing(e,{before:h,after:"](",...c.current()})),h+=c.move("]("),m(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(m=a.enter("destinationLiteral"),h+=c.move("<"),h+=c.move(a.safe(e.url,{before:h,after:">",...c.current()})),h+=c.move(">")):(m=a.enter("destinationRaw"),h+=c.move(a.safe(e.url,{before:h,after:e.title?" ":")",...c.current()}))),m(),e.title&&(m=a.enter(`title${u}`),h+=c.move(" "+o),h+=c.move(a.safe(e.title,{before:h,after:o,...c.current()})),h+=c.move(o),m()),h+=c.move(")"),f(),h}function gI(e,t,a){return HN(e,a)?"<":"["}zN.peek=bI;function zN(e,t,a,r){const o=e.referenceType,u=a.enter("linkReference");let c=a.enter("label");const f=a.createTracker(r);let m=f.move("[");const h=a.containerPhrasing(e,{before:m,after:"]",...f.current()});m+=f.move(h+"]["),c();const b=a.stack;a.stack=[],c=a.enter("reference");const g=a.safe(a.associationId(e),{before:m,after:"]",...f.current()});return c(),a.stack=b,u(),o==="full"||!h||h!==g?m+=f.move(g+"]"):o==="shortcut"?m=m.slice(0,-1):m+=f.move("]"),m}function bI(){return"["}function fp(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function xI(e){const t=fp(e),a=e.options.bulletOther;if(!a)return t==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+a+"`) to be different");return a}function EI(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function $N(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function yI(e,t,a,r){const o=a.enter("list"),u=a.bulletCurrent;let c=e.ordered?EI(a):fp(a);const f=e.ordered?c==="."?")":".":xI(a);let m=t&&a.bulletLastUsed?c===a.bulletLastUsed:!1;if(!e.ordered){const b=e.children?e.children[0]:void 0;if((c==="*"||c==="-")&&b&&(!b.children||!b.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(m=!0),$N(a)===c&&b){let g=-1;for(;++g<e.children.length;){const y=e.children[g];if(y&&y.type==="listItem"&&y.children&&y.children[0]&&y.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(c=f),a.bulletCurrent=c;const h=a.containerFlow(e,r);return a.bulletLastUsed=c,a.bulletCurrent=u,o(),h}function NI(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function TI(e,t,a,r){const o=NI(a);let u=a.bulletCurrent||fp(a);t&&t.type==="list"&&t.ordered&&(u=(typeof t.start=="number"&&t.start>-1?t.start:1)+(a.options.incrementListMarker===!1?0:t.children.indexOf(e))+u);let c=u.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(c=Math.ceil(c/4)*4);const f=a.createTracker(r);f.move(u+" ".repeat(c-u.length)),f.shift(c);const m=a.enter("listItem"),h=a.indentLines(a.containerFlow(e,f.current()),b);return m(),h;function b(g,y,N){return y?(N?"":" ".repeat(c))+g:(N?u:u+" ".repeat(c-u.length))+g}}function _I(e,t,a,r){const o=a.enter("paragraph"),u=a.enter("phrasing"),c=a.containerPhrasing(e,r);return u(),o(),c}const vI=Lo(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function SI(e,t,a,r){return(e.children.some(function(c){return vI(c)})?a.containerPhrasing:a.containerFlow).call(a,e,r)}function AI(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}qN.peek=CI;function qN(e,t,a,r){const o=AI(a),u=a.enter("strong"),c=a.createTracker(r),f=c.move(o+o);let m=c.move(a.containerPhrasing(e,{after:o,before:f,...c.current()}));const h=m.charCodeAt(0),b=Mc(r.before.charCodeAt(r.before.length-1),h,o);b.inside&&(m=So(h)+m.slice(1));const g=m.charCodeAt(m.length-1),y=Mc(r.after.charCodeAt(0),g,o);y.inside&&(m=m.slice(0,-1)+So(g));const N=c.move(o+o);return u(),a.attentionEncodeSurroundingInfo={after:y.outside,before:b.outside},f+m+N}function CI(e,t,a){return a.options.strong||"*"}function wI(e,t,a,r){return a.safe(e.value,r)}function kI(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function RI(e,t,a){const r=($N(a)+(a.options.ruleSpaces?" ":"")).repeat(kI(a));return a.options.ruleSpaces?r.slice(0,-1):r}const YN={blockquote:JO,break:I1,code:rI,definition:lI,emphasis:LN,hardBreak:I1,heading:dI,html:jN,image:BN,imageReference:PN,inlineCode:UN,link:FN,linkReference:zN,list:yI,listItem:TI,paragraph:_I,root:SI,strong:qN,text:wI,thematicBreak:RI};function OI(){return{enter:{table:II,tableData:M1,tableHeader:M1,tableRow:DI},exit:{codeText:LI,table:MI,tableData:Hm,tableHeader:Hm,tableRow:Hm}}}function II(e){const t=e._align;this.enter({type:"table",align:t.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function MI(e){this.exit(e),this.data.inTable=void 0}function DI(e){this.enter({type:"tableRow",children:[]},e)}function Hm(e){this.exit(e)}function M1(e){this.enter({type:"tableCell",children:[]},e)}function LI(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,jI));const a=this.stack[this.stack.length-1];a.type,a.value=t,this.exit(e)}function jI(e,t){return t==="|"?t:e}function BI(e){const t=e||{},a=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,u=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
489
489
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:y,table:c,tableCell:m,tableRow:f}};function c(N,v,A,C){return h(b(N,A,C),N.align)}function f(N,v,A,C){const S=g(N,A,C),M=h([S]);return M.slice(0,M.indexOf(`
490
- `))}function m(N,v,A,C){const S=A.enter("tableCell"),M=A.enter("phrasing"),O=A.containerPhrasing(N,{...C,before:u,after:u});return M(),S(),O}function h(N,v){return WO(N,{align:v,alignDelimiters:r,padding:a,stringLength:o})}function b(N,v,A){const C=N.children;let S=-1;const M=[],O=v.enter("table");for(;++S<C.length;)M[S]=g(C[S],v,A);return O(),M}function g(N,v,A){const C=N.children;let S=-1;const M=[],O=v.enter("tableRow");for(;++S<C.length;)M[S]=m(C[S],N,v,A);return O(),M}function y(N,v,A){let C=YN.inlineCode(N,v,A);return A.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function PI(){return{exit:{taskListCheckValueChecked:D1,taskListCheckValueUnchecked:D1,paragraph:HI}}}function UI(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:FI}}}function D1(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function HI(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const r=a.children[0];if(r&&r.type==="text"){const o=t.children;let u=-1,c;for(;++u<o.length;){const f=o[u];if(f.type==="paragraph"){c=f;break}}c===a&&(r.value=r.value.slice(1),r.value.length===0?a.children.shift():a.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,a.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function FI(e,t,a,r){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",f=a.createTracker(r);u&&f.move(c);let m=YN.listItem(e,t,a,{...r,...f.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),m;function h(b){return b+c}}function zI(){return[yO(),FO(),YO(),OI(),PI()]}function $I(e){return{extensions:[NO(),zO(e),GO(),BI(e),UI()]}}const qI={tokenize:QI,partial:!0},GN={tokenize:WI,partial:!0},KN={tokenize:ZI,partial:!0},VN={tokenize:JI,partial:!0},YI={tokenize:e6,partial:!0},XN={name:"wwwAutolink",tokenize:VI,previous:WN},QN={name:"protocolAutolink",tokenize:XI,previous:ZN},ws={name:"emailAutolink",tokenize:KI,previous:JN},ns={};function GI(){return{text:ns}}let Mr=48;for(;Mr<123;)ns[Mr]=ws,Mr++,Mr===58?Mr=65:Mr===91&&(Mr=97);ns[43]=ws;ns[45]=ws;ns[46]=ws;ns[95]=ws;ns[72]=[ws,QN];ns[104]=[ws,QN];ns[87]=[ws,XN];ns[119]=[ws,XN];function KI(e,t,a){const r=this;let o,u;return c;function c(g){return!xh(g)||!JN.call(r,r.previous)||mp(r.events)?a(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return xh(g)?(e.consume(g),f):g===64?(e.consume(g),m):a(g)}function m(g){return g===46?e.check(YI,b,h)(g):g===45||g===95||Rn(g)?(u=!0,e.consume(g),m):b(g)}function h(g){return e.consume(g),o=!0,m}function b(g){return u&&o&&Fn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):a(g)}}function VI(e,t,a){const r=this;return o;function o(c){return c!==87&&c!==119||!WN.call(r,r.previous)||mp(r.events)?a(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(qI,e.attempt(GN,e.attempt(KN,u),a),a)(c))}function u(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function XI(e,t,a){const r=this;let o="",u=!1;return c;function c(g){return(g===72||g===104)&&ZN.call(r,r.previous)&&!mp(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):a(g)}function f(g){if(Fn(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const y=o.toLowerCase();if(y==="http"||y==="https")return e.consume(g),m}return a(g)}function m(g){return g===47?(e.consume(g),u?h:(u=!0,m)):a(g)}function h(g){return g===null||Oc(g)||Ot(g)||qr(g)||ed(g)?a(g):e.attempt(GN,e.attempt(KN,b),a)(g)}function b(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function QI(e,t,a){let r=0;return o;function o(c){return(c===87||c===119)&&r<3?(r++,e.consume(c),o):c===46&&r===3?(e.consume(c),u):a(c)}function u(c){return c===null?a(c):t(c)}}function WI(e,t,a){let r,o,u;return c;function c(h){return h===46||h===95?e.check(VN,m,f)(h):h===null||Ot(h)||qr(h)||h!==45&&ed(h)?m(h):(u=!0,e.consume(h),c)}function f(h){return h===95?r=!0:(o=r,r=void 0),e.consume(h),c}function m(h){return o||r||!u?a(h):t(h)}}function ZI(e,t){let a=0,r=0;return o;function o(c){return c===40?(a++,e.consume(c),o):c===41&&r<a?u(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(VN,t,u)(c):c===null||Ot(c)||qr(c)?t(c):(e.consume(c),o)}function u(c){return c===41&&r++,e.consume(c),o}}function JI(e,t,a){return r;function r(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),r):f===38?(e.consume(f),u):f===93?(e.consume(f),o):f===60||f===null||Ot(f)||qr(f)?t(f):a(f)}function o(f){return f===null||f===40||f===91||Ot(f)||qr(f)?t(f):r(f)}function u(f){return Fn(f)?c(f):a(f)}function c(f){return f===59?(e.consume(f),r):Fn(f)?(e.consume(f),c):a(f)}}function e6(e,t,a){return r;function r(u){return e.consume(u),o}function o(u){return Rn(u)?a(u):t(u)}}function WN(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ot(e)}function ZN(e){return!Fn(e)}function JN(e){return!(e===47||xh(e))}function xh(e){return e===43||e===45||e===46||e===95||Rn(e)}function mp(e){let t=e.length,a=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){a=!0;break}if(r._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const t6={tokenize:u6,partial:!0};function n6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:i6,continuation:{tokenize:l6},exit:o6}},text:{91:{name:"gfmFootnoteCall",tokenize:r6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:a6,resolveTo:s6}}}}function a6(e,t,a){const r=this;let o=r.events.length;const u=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let c;for(;o--;){const m=r.events[o][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return f;function f(m){if(!c||!c._balanced)return a(m);const h=Ha(r.sliceSerialize({start:c.end,end:r.now()}));return h.codePointAt(0)!==94||!u.includes(h.slice(1))?a(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),t(m))}}function s6(e,t){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[a+1],e[a+2],["enter",r,t],e[a+3],e[a+4],["enter",o,t],["exit",o,t],["enter",u,t],["enter",c,t],["exit",c,t],["exit",u,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(a,e.length-a+1,...f),e}function r6(e,t,a){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u=0,c;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?a(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(u>999||g===93&&!c||g===null||g===91||Ot(g))return a(g);if(g===93){e.exit("chunkString");const y=e.exit("gfmFootnoteCallString");return o.includes(Ha(r.sliceSerialize(y)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):a(g)}return Ot(g)||(c=!0),u++,e.consume(g),g===92?b:h}function b(g){return g===91||g===92||g===93?(e.consume(g),u++,h):h(g)}}function i6(e,t,a){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u,c=0,f;return m;function m(v){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(v){return v===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",b):a(v)}function b(v){if(c>999||v===93&&!f||v===null||v===91||Ot(v))return a(v);if(v===93){e.exit("chunkString");const A=e.exit("gfmFootnoteDefinitionLabelString");return u=Ha(r.sliceSerialize(A)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),y}return Ot(v)||(f=!0),c++,e.consume(v),v===92?g:b}function g(v){return v===91||v===92||v===93?(e.consume(v),c++,b):b(v)}function y(v){return v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),o.includes(u)||o.push(u),ft(e,N,"gfmFootnoteDefinitionWhitespace")):a(v)}function N(v){return t(v)}}function l6(e,t,a){return e.check(Do,t,e.attempt(t6,t,a))}function o6(e){e.exit("gfmFootnoteDefinition")}function u6(e,t,a){const r=this;return ft(e,o,"gfmFootnoteDefinitionIndent",5);function o(u){const c=r.events[r.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(u):a(u)}}function c6(e){let a=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:u,resolveAll:o};return a==null&&(a=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(c,f){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let h=m;for(;h--;)if(c[h][0]==="exit"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[h][1].end.offset-c[h][1].start.offset){c[m][1].type="strikethroughSequence",c[h][1].type="strikethroughSequence";const b={type:"strikethrough",start:Object.assign({},c[h][1].start),end:Object.assign({},c[m][1].end)},g={type:"strikethroughText",start:Object.assign({},c[h][1].end),end:Object.assign({},c[m][1].start)},y=[["enter",b,f],["enter",c[h][1],f],["exit",c[h][1],f],["enter",g,f]],N=f.parser.constructs.insideSpan.null;N&&xa(y,y.length,0,td(N,c.slice(h+1,m),f)),xa(y,y.length,0,[["exit",g,f],["enter",c[m][1],f],["exit",c[m][1],f],["exit",b,f]]),xa(c,h-1,m-h+3,y),m=h+y.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function u(c,f,m){const h=this.previous,b=this.events;let g=0;return y;function y(v){return h===126&&b[b.length-1][1].type!=="characterEscape"?m(v):(c.enter("strikethroughSequenceTemporary"),N(v))}function N(v){const A=$i(h);if(v===126)return g>1?m(v):(c.consume(v),g++,N);if(g<2&&!a)return m(v);const C=c.exit("strikethroughSequenceTemporary"),S=$i(v);return C._open=!S||S===2&&!!A,C._close=!A||A===2&&!!S,f(v)}}}class d6{constructor(){this.map=[]}add(t,a,r){f6(this,t,a,r)}consume(t){if(this.map.sort(function(u,c){return u[0]-c[0]}),this.map.length===0)return;let a=this.map.length;const r=[];for(;a>0;)a-=1,r.push(t.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),t.length=this.map[a][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const u of o)t.push(u);o=r.pop()}this.map.length=0}}function f6(e,t,a,r){let o=0;if(!(a===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=a,e.map[o][2].push(...r);return}o+=1}e.map.push([t,a,r])}}function m6(e,t){let a=!1;const r=[];for(;t<e.length;){const o=e[t];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const u=r.length-1;r[u]=r[u]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);t+=1}return r}function h6(){return{flow:{null:{name:"table",tokenize:p6,resolveAll:g6}}}}function p6(e,t,a){const r=this;let o=0,u=0,c;return f;function f(D){let te=r.events.length-1;for(;te>-1;){const Q=r.events[te][1].type;if(Q==="lineEnding"||Q==="linePrefix")te--;else break}const le=te>-1?r.events[te][1].type:null,pe=le==="tableHead"||le==="tableRow"?U:m;return pe===U&&r.parser.lazy[r.now().line]?a(D):pe(D)}function m(D){return e.enter("tableHead"),e.enter("tableRow"),h(D)}function h(D){return D===124||(c=!0,u+=1),b(D)}function b(D){return D===null?a(D):Fe(D)?u>1?(u=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),N):a(D):it(D)?ft(e,b,"whitespace")(D):(u+=1,c&&(c=!1,o+=1),D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),c=!0,b):(e.enter("data"),g(D)))}function g(D){return D===null||D===124||Ot(D)?(e.exit("data"),b(D)):(e.consume(D),D===92?y:g)}function y(D){return D===92||D===124?(e.consume(D),g):g(D)}function N(D){return r.interrupt=!1,r.parser.lazy[r.now().line]?a(D):(e.enter("tableDelimiterRow"),c=!1,it(D)?ft(e,v,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):v(D))}function v(D){return D===45||D===58?C(D):D===124?(c=!0,e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),A):I(D)}function A(D){return it(D)?ft(e,C,"whitespace")(D):C(D)}function C(D){return D===58?(u+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),S):D===45?(u+=1,S(D)):D===null||Fe(D)?j(D):I(D)}function S(D){return D===45?(e.enter("tableDelimiterFiller"),M(D)):I(D)}function M(D){return D===45?(e.consume(D),M):D===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),O):(e.exit("tableDelimiterFiller"),O(D))}function O(D){return it(D)?ft(e,j,"whitespace")(D):j(D)}function j(D){return D===124?v(D):D===null||Fe(D)?!c||o!==u?I(D):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(D)):I(D)}function I(D){return a(D)}function U(D){return e.enter("tableRow"),$(D)}function $(D){return D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),$):D===null||Fe(D)?(e.exit("tableRow"),t(D)):it(D)?ft(e,$,"whitespace")(D):(e.enter("data"),Z(D))}function Z(D){return D===null||D===124||Ot(D)?(e.exit("data"),$(D)):(e.consume(D),D===92?K:Z)}function K(D){return D===92||D===124?(e.consume(D),Z):Z(D)}}function g6(e,t){let a=-1,r=!0,o=0,u=[0,0,0,0],c=[0,0,0,0],f=!1,m=0,h,b,g;const y=new d6;for(;++a<e.length;){const N=e[a],v=N[1];N[0]==="enter"?v.type==="tableHead"?(f=!1,m!==0&&(L1(y,t,m,h,b),b=void 0,m=0),h={type:"table",start:Object.assign({},v.start),end:Object.assign({},v.end)},y.add(a,0,[["enter",h,t]])):v.type==="tableRow"||v.type==="tableDelimiterRow"?(r=!0,g=void 0,u=[0,0,0,0],c=[0,a+1,0,0],f&&(f=!1,b={type:"tableBody",start:Object.assign({},v.start),end:Object.assign({},v.end)},y.add(a,0,[["enter",b,t]])),o=v.type==="tableDelimiterRow"?2:b?3:1):o&&(v.type==="data"||v.type==="tableDelimiterMarker"||v.type==="tableDelimiterFiller")?(r=!1,c[2]===0&&(u[1]!==0&&(c[0]=c[1],g=oc(y,t,u,o,void 0,g),u=[0,0,0,0]),c[2]=a)):v.type==="tableCellDivider"&&(r?r=!1:(u[1]!==0&&(c[0]=c[1],g=oc(y,t,u,o,void 0,g)),u=c,c=[u[1],a,0,0])):v.type==="tableHead"?(f=!0,m=a):v.type==="tableRow"||v.type==="tableDelimiterRow"?(m=a,u[1]!==0?(c[0]=c[1],g=oc(y,t,u,o,a,g)):c[1]!==0&&(g=oc(y,t,c,o,a,g)),o=0):o&&(v.type==="data"||v.type==="tableDelimiterMarker"||v.type==="tableDelimiterFiller")&&(c[3]=a)}for(m!==0&&L1(y,t,m,h,b),y.consume(t.events),a=-1;++a<t.events.length;){const N=t.events[a];N[0]==="enter"&&N[1].type==="table"&&(N[1]._align=m6(t.events,a))}return e}function oc(e,t,a,r,o,u){const c=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(u.end=Object.assign({},ji(t.events,a[0])),e.add(a[0],0,[["exit",u,t]]));const m=ji(t.events,a[1]);if(u={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(a[1],0,[["enter",u,t]]),a[2]!==0){const h=ji(t.events,a[2]),b=ji(t.events,a[3]),g={type:f,start:Object.assign({},h),end:Object.assign({},b)};if(e.add(a[2],0,[["enter",g,t]]),r!==2){const y=t.events[a[2]],N=t.events[a[3]];if(y[1].end=Object.assign({},N[1].end),y[1].type="chunkText",y[1].contentType="text",a[3]>a[2]+1){const v=a[2]+1,A=a[3]-a[2]-1;e.add(v,A,[])}}e.add(a[3]+1,0,[["exit",g,t]])}return o!==void 0&&(u.end=Object.assign({},ji(t.events,o)),e.add(o,0,[["exit",u,t]]),u=void 0),u}function L1(e,t,a,r,o){const u=[],c=ji(t.events,a);o&&(o.end=Object.assign({},c),u.push(["exit",o,t])),r.end=Object.assign({},c),u.push(["exit",r,t]),e.add(a+1,0,u)}function ji(e,t){const a=e[t],r=a[0]==="enter"?"start":"end";return a[1][r]}const b6={name:"tasklistCheck",tokenize:E6};function x6(){return{text:{91:b6}}}function E6(e,t,a){const r=this;return o;function o(m){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?a(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),u)}function u(m){return Ot(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):a(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):a(m)}function f(m){return Fe(m)?t(m):it(m)?e.check({tokenize:y6},t,a)(m):a(m)}}function y6(e,t,a){return ft(e,r,"whitespace");function r(o){return o===null?a(o):t(o)}}function N6(e){return oN([GI(),n6(),c6(e),h6(),x6()])}const T6={};function Gi(e){const t=this,a=e||T6,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),u=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),c=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(N6(a)),u.push(zI()),c.push($I(a))}const _6=5*1024*1024,j1=10,eT=["image/png","image/jpeg","image/gif","image/webp"];let v6=0;function S6(e){return new Promise((t,a)=>{const r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>a(r.error),r.readAsDataURL(e)})}function A6({url:e,label:t,onClose:a}){return T.useEffect(()=>{const r=o=>{o.key==="Escape"&&(o.preventDefault(),a())};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[a]),i.jsx("div",{role:"dialog","aria-modal":"true","aria-label":t,onClick:a,className:"fixed inset-0 z-50 flex cursor-zoom-out items-center justify-center bg-black/80 p-8 backdrop-blur-sm",children:i.jsx("img",{src:e,alt:t,className:"max-h-full max-w-full object-contain"})})}function tT({url:e,label:t,className:a}){const[r,o]=T.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:()=>o(!0),"aria-label":`预览 ${t}`,className:"block cursor-zoom-in rounded-md transition-opacity duration-150 hover:opacity-80",children:i.jsx("img",{src:e,alt:t,className:ne("rounded-md border border-line",a)})}),r&&i.jsx(A6,{url:e,label:t,onClose:()=>o(!1)})]})}function nT(e=!0){const[t,a]=T.useState([]),[r,o]=T.useState(null);T.useEffect(()=>{o(null),e||a([])},[e]);const u=async b=>{const g=[],y=[],N=t.length;let v=j1-N;for(const A of b){if(v<=0){y.push(`最多 ${j1} 张图片`);break}if(!eT.includes(A.type)){y.push(`${A.name||"文件"}:格式不支持`);continue}if(A.size>_6){y.push(`${A.name}:超过 5MB`);continue}g.push({_id:`att-${++v6}`,mime:A.type,url:await S6(A),filename:A.name}),v--}g.length>0&&a(A=>[...A,...g]),o(y.length>0?y.join(";"):null)},c=b=>{const g=Array.from(b.clipboardData.files);if(g.length!==0){if(b.preventDefault(),!e){o("当前模型不支持图片");return}u(g)}},f=b=>a(g=>g.filter(y=>y._id!==b)),m=T.useCallback(()=>{a([]),o(null)},[]),h=t.map(({mime:b,url:g,filename:y})=>({mime:b,url:g,filename:y}));return{attachments:t,promptFiles:h,error:r,setError:o,addFiles:u,onPaste:c,remove:f,clear:m}}function aT({onFiles:e,disabled:t,allowed:a}){const r=T.useRef(null);return i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:r,type:"file",accept:eT.join(","),multiple:!0,hidden:!0,onChange:o=>{e(Array.from(o.target.files??[])),o.target.value=""}}),i.jsx("button",{type:"button",onClick:()=>{var o;return(o=r.current)==null?void 0:o.click()},disabled:t||!a,"aria-label":"Attach image",title:a?"附加图片":"当前模型不支持图片",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-fg-5 transition-colors duration-150 hover:text-fg-3 disabled:cursor-not-allowed disabled:text-fg-6/40",children:i.jsx(A3,{className:"h-4 w-4"})})]})}function sT({attachments:e,error:t,onRemove:a,className:r}){return e.length===0&&!t?null:i.jsxs("div",{className:r,children:[e.length>0&&i.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:e.map(o=>i.jsxs("div",{className:"group relative",children:[i.jsx(tT,{url:o.url,label:o.filename??"attachment",className:"h-16 w-16 object-cover"}),i.jsx("button",{type:"button",onClick:()=>a(o._id),"aria-label":"Remove attachment",className:"absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-line bg-term text-fg-4 opacity-0 transition-opacity duration-150 hover:text-fg-2 group-hover:opacity-100",children:i.jsx(gt,{className:"h-2.5 w-2.5",strokeWidth:2.5})})]},o._id))}),t&&i.jsx("div",{className:"mb-2 font-mono text-[11px] text-red-400",children:t})]})}function rT({isListening:e,disabled:t,onStart:a,onStop:r}){const o=T.useRef(!1),u=f=>{if(t)return;f.preventDefault(),o.current=!0,a();const m=()=>{document.removeEventListener("touchend",m),document.removeEventListener("touchcancel",m),o.current=!1,r()};document.addEventListener("touchend",m,{once:!0}),document.addEventListener("touchcancel",m,{once:!0})},c=()=>{if(t||o.current)return;a();const f=()=>{document.removeEventListener("mouseup",f),r()};document.addEventListener("mouseup",f,{once:!0})};return i.jsx("button",{type:"button",disabled:t,onTouchStart:u,onMouseDown:c,onContextMenu:f=>f.preventDefault(),"aria-label":"按住说话",title:"按住说话",style:{WebkitTouchCallout:"none"},className:ne("flex shrink-0 select-none touch-none items-center justify-center transition-colors duration-150 disabled:cursor-not-allowed disabled:text-fg-6/40","order-first self-stretch w-12 rounded-xl sm:order-none sm:self-auto sm:h-7 sm:w-7 sm:rounded-md",e?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"text-fg-5 hover:text-fg-3"),children:i.jsx(B3,{className:ne("h-6 w-6 sm:h-4 sm:w-4",e&&"animate-pulse")})})}const C6=[.85,1.25,.65,1.4,.75,1.15,.95],Fm=4,B1=24;function w6(e){const t=Math.floor(e/60).toString().padStart(2,"0"),a=Math.floor(e%60).toString().padStart(2,"0");return`${t}:${a}`}function k6({volumeLevel:e}){const t=Math.min(Math.max(e,0),1);return i.jsx("div",{className:"flex h-6 items-center gap-1","aria-hidden":"true",children:C6.map((a,r)=>{const o=Fm+t*a*(B1-Fm),u=Math.max(Fm,Math.min(B1,o));return i.jsx("span",{className:"w-1 rounded-full bg-red-400 transition-[height] duration-150 ease-out",style:{height:`${u}px`}},r)})})}function iT({phase:e,transcript:t,interimTranscript:a,editText:r,onEditTextChange:o,onTextareaKeyDown:u,textareaRef:c,wrapperClassName:f}){if(e==="idle")return null;const m=t.length>0||a.length>0;return i.jsx("div",{className:f,children:i.jsxs("div",{className:"max-h-[40vh] overflow-y-auto px-4 py-4",children:[e==="recording"&&i.jsx("div",{className:"text-xl leading-relaxed",children:m?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-fg",children:t}),a&&i.jsx("span",{className:"text-fg-4",children:a})]}):i.jsx("span",{className:"italic text-fg-5",children:"正在聆听…"})}),e==="recognizing"&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ln,{className:"h-5 w-5 shrink-0 text-emerald-400 fs-spin"}),i.jsx("span",{className:"font-mono text-sm text-emerald-400",children:"识别中…"}),a&&i.jsx("span",{className:"truncate text-base text-fg-4",children:a})]}),e==="done"&&i.jsx("textarea",{ref:c,value:r,onChange:h=>o(h.target.value),onKeyDown:u,rows:2,placeholder:"识别结果(可编辑)",className:"w-full resize-none bg-transparent text-xl leading-relaxed text-fg placeholder:text-fg-5 focus:outline-none"})]})})}function lT({phase:e,volumeLevel:t,elapsed:a,editText:r,error:o,onCancel:u,onConfirm:c,idleHint:f,className:m}){return e==="idle"?i.jsx("div",{className:m,children:o?i.jsx("span",{className:"font-mono text-[10px] text-red-400",children:o}):f?i.jsx("span",{className:"font-mono text-[10px] text-fg-6",children:f}):null}):e==="done"?i.jsxs("div",{className:m,children:[i.jsx("span",{className:"hidden font-mono text-[10px] text-fg-6 sm:inline",children:"⌘/Ctrl+⏎ 发送 · Esc 取消"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:u,className:"rounded-md border border-line px-3 py-1 text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"取消"}),i.jsxs("button",{type:"button",onClick:c,disabled:r.trim().length===0,"aria-label":"发送",className:"flex items-center gap-1.5 rounded-md bg-emerald-600 px-3 py-1 text-xs font-medium text-white transition-colors hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-fg-6/30 disabled:text-fg-5",children:[i.jsx(Eo,{className:"h-3.5 w-3.5",strokeWidth:2.5}),i.jsx("span",{children:"发送"})]})]})]}):i.jsx("div",{className:m,children:e==="recording"?i.jsxs(i.Fragment,{children:[i.jsx(k6,{volumeLevel:t}),i.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[11px] font-medium text-red-400",children:[i.jsx("span",{className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-red-400"}),"录音中"]}),i.jsx("span",{className:"font-mono text-[11px] tabular-nums text-fg-4",children:w6(a)})]}):i.jsxs(i.Fragment,{children:[i.jsx(ln,{className:"h-4 w-4 shrink-0 text-emerald-400 fs-spin"}),i.jsx("span",{className:"font-mono text-[11px] text-emerald-400",children:"识别中…"})]})})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var Ki;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(Ki||(Ki={}));class zm extends Error{constructor(t,a,r){super(t),this.message=t,this.code=a,this.data=r}}const R6=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"},O6=e=>{const t=e.CapacitorCustomPlatform||null,a=e.Capacitor||{},r=a.Plugins=a.Plugins||{},o=()=>t!==null?t.name:R6(e),u=()=>o()!=="web",c=g=>{const y=h.get(g);return!!(y!=null&&y.platforms.has(o())||f(g))},f=g=>{var y;return(y=a.PluginHeaders)===null||y===void 0?void 0:y.find(N=>N.name===g)},m=g=>e.console.error(g),h=new Map,b=(g,y={})=>{const N=h.get(g);if(N)return console.warn(`Capacitor plugin "${g}" already registered. Cannot register plugins twice.`),N.proxy;const v=o(),A=f(g);let C;const S=async()=>(!C&&v in y?C=typeof y[v]=="function"?C=await y[v]():C=y[v]:t!==null&&!C&&"web"in y&&(C=typeof y.web=="function"?C=await y.web():C=y.web),C),M=(Z,K)=>{var D,te;if(A){const le=A==null?void 0:A.methods.find(pe=>K===pe.name);if(le)return le.rtype==="promise"?pe=>a.nativePromise(g,K.toString(),pe):(pe,Q)=>a.nativeCallback(g,K.toString(),pe,Q);if(Z)return(D=Z[K])===null||D===void 0?void 0:D.bind(Z)}else{if(Z)return(te=Z[K])===null||te===void 0?void 0:te.bind(Z);throw new zm(`"${g}" plugin is not implemented on ${v}`,Ki.Unimplemented)}},O=Z=>{let K;const D=(...te)=>{const le=S().then(pe=>{const Q=M(pe,Z);if(Q){const q=Q(...te);return K=q==null?void 0:q.remove,q}else throw new zm(`"${g}.${Z}()" is not implemented on ${v}`,Ki.Unimplemented)});return Z==="addListener"&&(le.remove=async()=>K()),le};return D.toString=()=>`${Z.toString()}() { [capacitor code] }`,Object.defineProperty(D,"name",{value:Z,writable:!1,configurable:!1}),D},j=O("addListener"),I=O("removeListener"),U=(Z,K)=>{const D=j({eventName:Z},K),te=async()=>{const pe=await D;I({eventName:Z,callbackId:pe},K)},le=new Promise(pe=>D.then(()=>pe({remove:te})));return le.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await te()},le},$=new Proxy({},{get(Z,K){switch(K){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return A?U:j;case"removeListener":return I;default:return O(K)}}});return r[g]=$,h.set(g,{name:g,proxy:$,platforms:new Set([...Object.keys(y),...A?[v]:[]])}),$};return a.convertFileSrc||(a.convertFileSrc=g=>g),a.getPlatform=o,a.handleError=m,a.isNativePlatform=u,a.isPluginAvailable=c,a.registerPlugin=b,a.Exception=zm,a.DEBUG=!!a.DEBUG,a.isLoggingEnabled=!!a.isLoggingEnabled,a},I6=e=>e.Capacitor=O6(e),Dc=I6(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Po=Dc.registerPlugin;class hp{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(t,a){let r=!1;this.listeners[t]||(this.listeners[t]=[],r=!0),this.listeners[t].push(a);const u=this.windowListeners[t];u&&!u.registered&&this.addWindowListener(u),r&&this.sendRetainedArgumentsForEvent(t);const c=async()=>this.removeListener(t,a);return Promise.resolve({remove:c})}async removeAllListeners(){this.listeners={};for(const t in this.windowListeners)this.removeWindowListener(this.windowListeners[t]);this.windowListeners={}}notifyListeners(t,a,r){const o=this.listeners[t];if(!o){if(r){let u=this.retainedEventArguments[t];u||(u=[]),u.push(a),this.retainedEventArguments[t]=u}return}o.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:r=>{this.notifyListeners(a,r)}}}unimplemented(t="not implemented"){return new Dc.Exception(t,Ki.Unimplemented)}unavailable(t="not available"){return new Dc.Exception(t,Ki.Unavailable)}async removeListener(t,a){const r=this.listeners[t];if(!r)return;const o=r.indexOf(a);this.listeners[t].splice(o,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(r=>{this.notifyListeners(t,r)}))}}const P1=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),U1=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class M6 extends hp{async getCookies(){const t=document.cookie,a={};return t.split(";").forEach(r=>{if(r.length<=0)return;let[o,u]=r.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");o=U1(o).trim(),u=U1(u).trim(),a[o]=u}),a}async setCookie(t){try{const a=P1(t.key),r=P1(t.value),o=t.expires?`; expires=${t.expires.replace("expires=","")}`:"",u=(t.path||"/").replace("path=",""),c=t.url!=null&&t.url.length>0?`domain=${t.url}`:"";document.cookie=`${a}=${r||""}${o}; path=${u}; ${c};`}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)}}}Po("CapacitorCookies",{web:()=>new M6});const D6=async e=>new Promise((t,a)=>{const r=new FileReader;r.onload=()=>{const o=r.result;t(o.indexOf(",")>=0?o.split(",")[1]:o)},r.onerror=o=>a(o),r.readAsDataURL(e)}),L6=(e={})=>{const t=Object.keys(e);return Object.keys(e).map(o=>o.toLocaleLowerCase()).reduce((o,u,c)=>(o[u]=e[t[c]],o),{})},j6=(e,t=!0)=>e?Object.entries(e).reduce((r,o)=>{const[u,c]=o;let f,m;return Array.isArray(c)?(m="",c.forEach(h=>{f=t?encodeURIComponent(h):h,m+=`${u}=${f}&`}),m.slice(0,-1)):(f=t?encodeURIComponent(c):c,m=`${u}=${f}`),`${r}&${m}`},"").substr(1):null,B6=(e,t={})=>{const a=Object.assign({method:e.method||"GET",headers:e.headers},t),o=L6(e.headers)["content-type"]||"";if(typeof e.data=="string")a.body=e.data;else if(o.includes("application/x-www-form-urlencoded")){const u=new URLSearchParams;for(const[c,f]of Object.entries(e.data||{}))u.set(c,f);a.body=u.toString()}else if(o.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 c=new Headers(a.headers);c.delete("content-type"),a.headers=c}else(o.includes("application/json")||typeof e.data=="object")&&(a.body=JSON.stringify(e.data));return a};class P6 extends hp{async request(t){const a=B6(t,t.webFetchExtra),r=j6(t.params,t.shouldEncodeUrlParams),o=r?`${t.url}?${r}`:t.url,u=await fetch(o,a),c=u.headers.get("content-type")||"";let{responseType:f="text"}=u.ok?t:{};c.includes("application/json")&&(f="json");let m,h;switch(f){case"arraybuffer":case"blob":h=await u.blob(),m=await D6(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"}))}}Po("CapacitorHttp",{web:()=>new P6});var H1;(function(e){e.Dark="DARK",e.Light="LIGHT",e.Default="DEFAULT"})(H1||(H1={}));var F1;(function(e){e.StatusBar="StatusBar",e.NavigationBar="NavigationBar"})(F1||(F1={}));class U6 extends hp{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")}}Po("SystemBars",{web:()=>new U6});const H6="modulepreload",F6=function(e){return"/"+e},z1={},z6=function(t,a,r){let o=Promise.resolve();if(a&&a.length>0){let c=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"));o=c(a.map(h=>{if(h=F6(h),h in z1)return;z1[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":H6,b||(y.as="script"),y.crossOrigin="",y.href=h,m&&y.setAttribute("nonce",m),document.head.appendChild(y),b)return new Promise((N,v)=>{y.addEventListener("load",N),y.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return o.then(c=>{for(const f of c||[])f.status==="rejected"&&u(f.reason);return t().catch(u)})},Li=Po("SpeechRecognition",{web:()=>z6(()=>import("./web-BwkOHrGT.js"),[]).then(e=>new e.SpeechRecognitionWeb)});function $6(e,t){const a=e.length,r=new ArrayBuffer(44+a*2),o=new DataView(r),u=(c,f)=>{for(let m=0;m<f.length;m++)o.setUint8(c+m,f.charCodeAt(m))};u(0,"RIFF"),o.setUint32(4,36+a*2,!0),u(8,"WAVE"),u(12,"fmt "),o.setUint32(16,16,!0),o.setUint16(20,1,!0),o.setUint16(22,1,!0),o.setUint32(24,t,!0),o.setUint32(28,t*2,!0),o.setUint16(32,2,!0),o.setUint16(34,16,!0),u(36,"data"),o.setUint32(40,a*2,!0);for(let c=0;c<a;c++){const f=Math.max(-1,Math.min(1,e[c]));o.setInt16(44+c*2,f<0?f*32768:f*32767,!0)}return new Blob([r],{type:"audio/wav"})}const Eh=Dc.isNativePlatform(),$m=!Eh&&typeof window<"u"?window.SpeechRecognition??window.webkitSpeechRecognition:void 0,qm=16e3;function q6(e="zh-CN"){const[t,a]=T.useState(!1),[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState(null),[h,b]=T.useState(0),[g,y]=T.useState("idle"),N=T.useRef(null),v=T.useRef(!1),A=T.useRef([]),C=T.useRef(!1),S=T.useRef(null),M=T.useRef(!1),O=T.useRef(null),j=T.useRef(null),I=T.useRef(null),U=T.useRef([]),$=T.useRef(!1),Z=!0,K=T.useCallback(async()=>{var se,L,Ne;(se=I.current)==null||se.disconnect(),(L=j.current)==null||L.getTracks().forEach(Te=>Te.stop()),await((Ne=O.current)==null?void 0:Ne.close().catch(()=>{}));const F=U.current;if(U.current=[],I.current=null,j.current=null,O.current=null,F.length===0||$.current){a(!1),y("idle");return}c("识别中…"),y("recognizing");const k=F.reduce((Te,V)=>Te+V.length,0),P=new Float32Array(k);let J=0;for(const Te of F)P.set(Te,J),J+=Te.length;const w=$6(P,qm),H=new FormData;H.append("audio",w,"recording.wav");try{const Te=await fetch("/api/transcribe",{method:"POST",body:H});if($.current)return;if(Te.ok){const{text:V}=await Te.json();V?(o(V),y("done")):y("idle")}else{const V=await Te.json().catch(()=>({error:`HTTP ${Te.status}`}));m(V.error??`HTTP ${Te.status}`),y("idle")}}catch(Te){m(`语音识别失败:${Te instanceof Error?Te.message:String(Te)}`),y("idle")}finally{c(""),a(!1)}},[]),D=T.useCallback(async()=>{if(v.current=!0,S.current&&(clearTimeout(S.current),S.current=null),Eh){await Li.stop().catch(()=>{});for(const F of A.current)await F.remove().catch(()=>{});A.current=[],a(!1),c("")}else N.current?N.current.stop():O.current?await K():(a(!1),y("idle"))},[K]),te=T.useCallback(async()=>{var J;$.current=!1,o(""),c(""),m(null),y("idle");const{available:F}=await Li.available();if(!F){m("当前设备不支持语音识别");return}if((await Li.requestPermissions()).speechRecognition!=="granted"){m("请允许语音识别权限");return}const P=[];P.push(await Li.addListener("partialResults",w=>{c(w.matches[0]??"")})),P.push(await Li.addListener("listeningState",w=>{const H=w.status==="started";a(H),H&&y("recording"),H||c("")})),A.current=P;try{const w=await Li.start({language:e,partialResults:!0,maxResults:1});(J=w.matches)!=null&&J.length&&o(H=>H+w.matches.join(""))}catch(w){m(`语音识别错误:${w instanceof Error?w.message:String(w)}`);for(const H of P)await H.remove().catch(()=>{});A.current=[]}},[e]),le=T.useCallback(()=>{if(!$m)return!1;$.current=!1,o(""),c(""),m(null),y("idle"),v.current=!1;const F=new $m;F.lang=e,F.continuous=!0,F.interimResults=!0,F.maxAlternatives=1,F.onstart=()=>{a(!0),y("recording"),C.current=!1,S.current=setTimeout(()=>{!C.current&&!v.current&&(M.current=!0,v.current=!0,F.stop(),m("语音识别服务不可用(Chrome/Edge 需连接 Google 服务器),下次将使用服务端识别"))},5e3)},F.onresult=k=>{C.current=!0,S.current&&(clearTimeout(S.current),S.current=null);let P="",J="";for(let w=k.resultIndex;w<k.results.length;w++){const H=k.results[w][0].transcript;k.results[w].isFinal?P+=H:J+=H}P&&o(w=>w+P),c(J)},F.onerror=k=>{switch(k.error!=="no-speech"&&k.error!=="aborted"&&(v.current=!0),k.error){case"not-allowed":m("请允许麦克风权限");break;case"network":m("网络错误,请检查连接");break;case"no-speech":case"aborted":return;default:m(`语音识别错误:${k.error}`)}},F.onend=()=>{if(c(""),!v.current)try{F.start();return}catch{}a(!1),N.current=null},N.current=F;try{return F.start(),!0}catch{return!1}},[e]),pe=T.useCallback(async()=>{$.current=!1,o(""),c(""),m(null),y("idle");try{const w=await fetch("/api/transcribe/status"),{available:H}=await w.json();if(!H){m("语音识别服务未就绪,请稍后重试");return}}catch{m("无法连接语音识别服务");return}let F;try{F=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:qm,channelCount:1}})}catch{m("请允许麦克风权限");return}const k=new AudioContext({sampleRate:qm}),P=k.createMediaStreamSource(F),J=k.createScriptProcessor(4096,1,1);U.current=[],J.onaudioprocess=w=>{U.current.push(new Float32Array(w.inputBuffer.getChannelData(0)))},P.connect(J),J.connect(k.destination),O.current=k,j.current=F,I.current=J,a(!0),y("recording")},[]),Q=T.useCallback(()=>{Eh?te():$m&&!M.current&&le()||pe()},[te,le,pe]);T.useEffect(()=>{if(!t){b(0);return}if(N.current)return;let F=!1,k=null,P=null,J=0;return(async()=>{try{if(k=await navigator.mediaDevices.getUserMedia({audio:!0}),F){k.getTracks().forEach(Te=>Te.stop());return}P=new AudioContext;const w=P.createMediaStreamSource(k),H=P.createAnalyser();H.fftSize=256,w.connect(H);const se=new Uint8Array(H.frequencyBinCount);let L=0;const Ne=()=>{if(F)return;H.getByteFrequencyData(se);const Te=performance.now();if(Te-L>80){let V=0;for(let ve=0;ve<se.length;ve++)V+=se[ve];b(V/(se.length*255)),L=Te}J=requestAnimationFrame(Ne)};J=requestAnimationFrame(Ne)}catch{}})(),()=>{F=!0,cancelAnimationFrame(J),k==null||k.getTracks().forEach(w=>w.stop()),P==null||P.close().catch(()=>{}),b(0)}},[t]),T.useEffect(()=>{!t&&g==="recording"&&y(r?"done":"idle")},[t,g,r]),T.useEffect(()=>()=>{var F,k,P,J;v.current=!0,(F=N.current)==null||F.stop(),(k=I.current)==null||k.disconnect(),(P=j.current)==null||P.getTracks().forEach(w=>w.stop()),(J=O.current)==null||J.close().catch(()=>{});for(const w of A.current)w.remove().catch(()=>{})},[]);const q=T.useCallback(()=>{$.current=!0,o(""),c(""),y("idle")},[]);return{isSupported:Z,isListening:t,phase:g,transcript:r,interimTranscript:u,error:f,volumeLevel:h,start:Q,stop:D,resetTranscript:q}}const Y6=240,G6=1e3;function oT(e){const t=q6(),[a,r]=T.useState(""),[o,u]=T.useState(0),c=T.useRef(null),f=T.useRef(null),m=T.useRef(0);T.useEffect(()=>(t.phase==="recording"?(m.current=Date.now(),u(0),f.current=setInterval(()=>{u(Math.floor((Date.now()-m.current)/1e3))},G6)):f.current&&(clearInterval(f.current),f.current=null),()=>{f.current&&(clearInterval(f.current),f.current=null)}),[t.phase]),T.useEffect(()=>{t.phase==="done"&&(r(t.transcript),requestAnimationFrame(()=>{const y=c.current;y&&(y.focus(),y.setSelectionRange(y.value.length,y.value.length))}))},[t.phase,t.transcript]),T.useLayoutEffect(()=>{if(t.phase!=="done")return;const y=c.current;y&&(y.style.height="auto",y.style.height=`${Math.min(y.scrollHeight,Y6)}px`)},[t.phase,a]);const h=T.useCallback(()=>{t.stop(),t.resetTranscript(),r("")},[t]),b=T.useCallback(async()=>{const y=a.trim();if(!y){h();return}await e(y)!==!1&&(t.resetTranscript(),r(""))},[a,e,h,t]);T.useEffect(()=>{if(t.phase==="idle")return;const y=N=>{if(N.key==="Escape"&&t.phase!=="recognizing"){N.preventDefault(),h();return}if(t.phase==="done"&&N.key==="Enter"&&(N.metaKey||N.ctrlKey)){if(N.isComposing)return;N.preventDefault(),b()}};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[t.phase,h,b]);const g=T.useCallback(y=>{y.nativeEvent.isComposing||y.keyCode===229||y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),b())},[b]);return{stt:t,editText:a,setEditText:r,elapsed:o,textareaRef:c,cancel:h,confirm:b,handleTextareaKeyDown:g}}const or=es(e=>({agents:[],loaded:!1,loadAgents:async()=>{const t=je.getState().activeRepoId;try{const a=t?await Ly(t):await Iy();e({agents:a,loaded:!0})}catch{e({loaded:!0})}}}));function K6(e){if(typeof e!="string")return e;const t=e.trim();if(t)try{return JSON.parse(t)}catch{return t}}function pn(e){return e&&typeof e=="object"?e:null}function Kr(e){const t=pn(e);return t&&"properties"in t?t.properties:e}function V6(e){const t=pn(e);return typeof(t==null?void 0:t.type)=="string"?t.type:void 0}function X6(e){const t=pn(Kr(e));if(!t)return null;const a=pn(t.info);if(a&&typeof a.id=="string"){const o=Array.isArray(t.parts)?t.parts:void 0;return{...a,...o?{parts:o}:{}}}if(typeof t.id=="string"&&typeof t.role=="string")return t;const r=pn(t.message);return r&&typeof r.id=="string"?r:null}function Q6(e){const t=pn(Kr(e));if(!t)return{};const a=pn(t.part)??t;return typeof a.type!="string"?{}:{messageId:typeof a.messageID=="string"&&a.messageID||typeof a.messageId=="string"&&a.messageId||typeof t.messageID=="string"&&t.messageID||typeof t.messageId=="string"&&t.messageId||void 0,part:a}}function W6(e){const t=pn(Kr(e));if(!t||t.field!=="text")return null;const a=typeof t.messageID=="string"?t.messageID:null,r=typeof t.partID=="string"?t.partID:null,o=typeof t.delta=="string"?t.delta:null;return!a||!r||o===null?null:{messageId:a,partId:r,delta:o}}function Z6(e){const t=Kr(e);if(Array.isArray(t))return t;const a=pn(t);return a&&Array.isArray(a.todos)?a.todos:[]}function Xa(e){return typeof e=="number"?e:0}function J6(e){const t=pn(Kr(e));if(!t||typeof t.id!="string")return null;const a={id:t.id};typeof t.title=="string"&&(a.title=t.title),typeof t.agent=="string"&&(a.agent=t.agent),typeof t.cost=="number"&&(a.cost=t.cost);const r=typeof t.parentID=="string"?t.parentID:typeof t.parent_id=="string"?t.parent_id:void 0;r&&(a.parentID=r);const o=pn(t.tokens),u=typeof t.tokens_input=="number"||typeof t.tokens_output=="number";if(o||u){const f=o?pn(o.cache):null;a.tokens={input:Xa(o==null?void 0:o.input)||Xa(t.tokens_input),output:Xa(o==null?void 0:o.output)||Xa(t.tokens_output),reasoning:Xa(o==null?void 0:o.reasoning)||Xa(t.tokens_reasoning),cache:{read:Xa(f==null?void 0:f.read)||Xa(t.tokens_cache_read),write:Xa(f==null?void 0:f.write)||Xa(t.tokens_cache_write)}}}const c=pn(t.model);return c&&(a.model={providerID:typeof c.providerID=="string"?c.providerID:void 0,modelID:typeof c.modelID=="string"?c.modelID:void 0,variant:typeof c.variant=="string"?c.variant:void 0}),a}function eM(e){const t=pn(Kr(e));if(!t)return null;if(typeof t.message=="string")return t.message;const a=pn(t.error);if(a){const r=pn(a.data);if(typeof(r==null?void 0:r.message)=="string")return`${a.name??"Error"}: ${r.message}`;if(typeof a.message=="string")return`${a.name??"Error"}: ${a.message}`;if(typeof a.name=="string")return String(a.name)}return typeof t.reason=="string"?t.reason:null}function tM(e){const t=Kr(e);if(typeof t=="string")return t;const a=pn(t);if(typeof(a==null?void 0:a.status)=="string")return a.status;const r=pn(a==null?void 0:a.status);return typeof(r==null?void 0:r.type)=="string"?r.type:typeof(a==null?void 0:a.type)=="string"?a.type:null}function nM(e,t,a,r){switch(e==="message"||e===""?V6(t)??e:e){case"message.updated":{const u=X6(t);u&&r.updateMessage(a,u);break}case"session.updated":{const u=J6(t);u&&r.updateSessionInfo(u);break}case"message.part.updated":{const{messageId:u,part:c}=Q6(t);c&&u&&r.updateMessagePart(a,u,c);break}case"message.part.delta":{const u=W6(t);u&&r.appendMessagePartDelta(a,u.messageId,u.partId,u.delta);break}case"todo.updated":{r.updateTodos(a,Z6(t));break}case"session.status":{const u=tM(t);u&&r.setSessionStatus(a,u);break}case"session.idle":{r.setSessionStatus(a,"idle");break}case"session.error":{const u=eM(t);r.setSessionStatus(a,"error",u??void 0);break}}}const aM=600*1e3;class sM{constructor(t,a){sn(this,"sessionId");sn(this,"idleTimer",null);sn(this,"active",!1);sn(this,"alive",!0);sn(this,"callbacks");this.sessionId=t,this.callbacks=a,this.resetIdleTimer()}dispatch(t,a){if(!this.alive)return;this.resetIdleTimer();const r=Re.getState();nM(t,a,this.sessionId,r)}activate(){this.active=!0,this.clearIdleTimer()}deactivate(){this.active=!1,this.resetIdleTimer()}refreshOnIdle(){Re.getState().refreshSessionData(this.sessionId)}stop(){this.alive=!1,this.clearIdleTimer()}resetIdleTimer(){this.clearIdleTimer(),!this.active&&(this.idleTimer=setTimeout(()=>{this.callbacks.onWorkerIdle(this.sessionId)},aM))}clearIdleTimer(){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null)}}const rM=1e3,iM=3e4;class lM{constructor(t,a){sn(this,"source",null);sn(this,"reconnectTimer",null);sn(this,"attempts",0);sn(this,"disposed",!1);sn(this,"repoId");sn(this,"onEvent");this.repoId=t,this.onEvent=a}start(){this.connect()}stop(){var t;this.disposed=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(t=this.source)==null||t.close(),this.source=null}connect(){if(this.disposed)return;const t=kC(this.repoId),a=new EventSource(t);this.source=a,a.onopen=()=>{this.attempts=0},a.onmessage=o=>{this.handleRaw("message",o)};const r=["message.updated","message.part.updated","message.part.delta","message.removed","todo.updated","session.status","session.idle","session.error","session.updated"];for(const o of r)a.addEventListener(o,u=>{this.handleRaw(o,u)});a.onerror=()=>{if(!(this.disposed||!this.source)&&this.source.readyState===EventSource.CLOSED){this.source.close(),this.source=null;const o=Math.min(rM*2**this.attempts,iM);this.attempts++,this.reconnectTimer=setTimeout(()=>this.connect(),o)}}}handleRaw(t,a){if(!(a instanceof MessageEvent))return;const r=K6(a.data);if(r===void 0)return;const o=this.extractSessionId(r);if(!o)return;let u=t;if(t==="message"||t===""){const c=r&&typeof r=="object"?r:null;typeof(c==null?void 0:c.type)=="string"&&(u=c.type)}this.onEvent(o,u,r)}extractSessionId(t){if(!t||typeof t!="object")return null;const a=t;if(a.properties&&typeof a.properties=="object"){const r=a.properties;if(typeof r.sessionID=="string")return r.sessionID;if(typeof r.id=="string")return r.id}return typeof a.sessionID=="string"?a.sessionID:typeof a.sessionId=="string"?a.sessionId:null}}const oM=6e4;class uM{constructor(t){sn(this,"timer",null);sn(this,"paused",!1);sn(this,"callbacks");this.callbacks=t}start(){this.tick(),this.timer=setInterval(()=>{this.paused||this.tick()},oM)}stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}pause(){this.paused=!0}resume(){this.paused=!1,this.tick()}tick(){const t=je.getState().activeRepoId;t&&(Re.getState().loadSessions(),RC(t).then(a=>{const r={};for(const[o,u]of Object.entries(a))r[o]=u.type??"idle";Re.getState().bulkSetStatuses(r);for(const[o,u]of Object.entries(r))(u==="busy"||u==="retry")&&this.callbacks.ensureWorker(o)}).catch(()=>{}))}}class cM{constructor(){sn(this,"workers",new Map);sn(this,"dispatcher",null);sn(this,"supervisor",null);sn(this,"visibilityHandler",null)}start(t){this.stop();const a={onWorkerIdle:r=>this.removeWorker(r)};this.dispatcher=new lM(t,(r,o,u)=>{const c=this.ensureWorker(r,a);if(o==="session.idle"||o==="session.status"){const f=Re.getState().sessionStatuses[r];c.dispatch(o,u);const m=Re.getState().sessionStatuses[r];f&&f!=="idle"&&m==="idle"&&c.refreshOnIdle()}else c.dispatch(o,u)}),this.dispatcher.start(),this.supervisor=new uM({ensureWorker:r=>this.ensureWorker(r,a)}),this.supervisor.start(),this.visibilityHandler=()=>{var r,o;document.hidden?(r=this.supervisor)==null||r.pause():(o=this.supervisor)==null||o.resume()},document.addEventListener("visibilitychange",this.visibilityHandler)}stop(){var t,a;(t=this.dispatcher)==null||t.stop(),this.dispatcher=null,(a=this.supervisor)==null||a.stop(),this.supervisor=null;for(const r of this.workers.values())r.stop();this.workers.clear(),this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}activateSession(t){for(const o of this.workers.values())o.sessionId!==t&&o.deactivate();if(!t)return;const a={onWorkerIdle:o=>this.removeWorker(o)};this.ensureWorker(t,a).activate(),Re.getState().refreshSessionData(t)}deactivateSession(t){var a;(a=this.workers.get(t))==null||a.deactivate()}ensureWorker(t,a){let r=this.workers.get(t);return r||(r=new sM(t,a),this.workers.set(t,r)),r}removeWorker(t){const a=Re.getState().activeSessionId;if(t===a)return;const r=this.workers.get(t);r&&(r.stop(),this.workers.delete(t))}}const Lc=new cM,$1=(function(e,t,a){const r=Lo(a);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]}),Vr=(function(e){if(e==null)return mM;if(typeof e=="string")return fM(e);if(typeof e=="object")return dM(e);if(typeof e=="function")return pp(e);throw new Error("Expected function, string, or array as `test`")});function dM(e){const t=[];let a=-1;for(;++a<e.length;)t[a]=Vr(e[a]);return pp(r);function r(...o){let u=-1;for(;++u<t.length;)if(t[u].apply(this,o))return!0;return!1}}function fM(e){return pp(t);function t(a){return a.tagName===e}}function pp(e){return t;function t(a,r,o){return!!(hM(a)&&e.call(this,a,typeof r=="number"?r:void 0,o||void 0))}}function mM(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function hM(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const q1=/\n/g,Y1=/[\t ]+/g,yh=Vr("br"),G1=Vr(TM),pM=Vr("p"),K1=Vr("tr"),gM=Vr(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",NM,_M]),uT=Vr(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function bM(e,t){const a=t||{},r="children"in e?e.children:[],o=uT(e),u=fT(e,{whitespace:a.whitespace||"normal"}),c=[];(e.type==="text"||e.type==="comment")&&c.push(...dT(e,{breakBefore:!0,breakAfter:!0}));let f=-1;for(;++f<r.length;)c.push(...cT(r[f],e,{whitespace:u,breakBefore:f?void 0:o,breakAfter:f<r.length-1?yh(r[f+1]):o}));const m=[];let h;for(f=-1;++f<c.length;){const b=c[f];typeof b=="number"?h!==void 0&&b>h&&(h=b):b&&(h!==void 0&&h>-1&&m.push(`
490
+ `))}function m(N,v,A,C){const S=A.enter("tableCell"),M=A.enter("phrasing"),O=A.containerPhrasing(N,{...C,before:u,after:u});return M(),S(),O}function h(N,v){return WO(N,{align:v,alignDelimiters:r,padding:a,stringLength:o})}function b(N,v,A){const C=N.children;let S=-1;const M=[],O=v.enter("table");for(;++S<C.length;)M[S]=g(C[S],v,A);return O(),M}function g(N,v,A){const C=N.children;let S=-1;const M=[],O=v.enter("tableRow");for(;++S<C.length;)M[S]=m(C[S],N,v,A);return O(),M}function y(N,v,A){let C=YN.inlineCode(N,v,A);return A.stack.includes("tableCell")&&(C=C.replace(/\|/g,"\\$&")),C}}function PI(){return{exit:{taskListCheckValueChecked:D1,taskListCheckValueUnchecked:D1,paragraph:HI}}}function UI(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:FI}}}function D1(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function HI(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const r=a.children[0];if(r&&r.type==="text"){const o=t.children;let u=-1,c;for(;++u<o.length;){const f=o[u];if(f.type==="paragraph"){c=f;break}}c===a&&(r.value=r.value.slice(1),r.value.length===0?a.children.shift():a.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,a.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function FI(e,t,a,r){const o=e.children[0],u=typeof e.checked=="boolean"&&o&&o.type==="paragraph",c="["+(e.checked?"x":" ")+"] ",f=a.createTracker(r);u&&f.move(c);let m=YN.listItem(e,t,a,{...r,...f.current()});return u&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),m;function h(b){return b+c}}function zI(){return[yO(),FO(),YO(),OI(),PI()]}function $I(e){return{extensions:[NO(),zO(e),GO(),BI(e),UI()]}}const qI={tokenize:QI,partial:!0},GN={tokenize:WI,partial:!0},KN={tokenize:ZI,partial:!0},VN={tokenize:JI,partial:!0},YI={tokenize:e6,partial:!0},XN={name:"wwwAutolink",tokenize:VI,previous:WN},QN={name:"protocolAutolink",tokenize:XI,previous:ZN},ws={name:"emailAutolink",tokenize:KI,previous:JN},ns={};function GI(){return{text:ns}}let Mr=48;for(;Mr<123;)ns[Mr]=ws,Mr++,Mr===58?Mr=65:Mr===91&&(Mr=97);ns[43]=ws;ns[45]=ws;ns[46]=ws;ns[95]=ws;ns[72]=[ws,QN];ns[104]=[ws,QN];ns[87]=[ws,XN];ns[119]=[ws,XN];function KI(e,t,a){const r=this;let o,u;return c;function c(g){return!xh(g)||!JN.call(r,r.previous)||mp(r.events)?a(g):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),f(g))}function f(g){return xh(g)?(e.consume(g),f):g===64?(e.consume(g),m):a(g)}function m(g){return g===46?e.check(YI,b,h)(g):g===45||g===95||Rn(g)?(u=!0,e.consume(g),m):b(g)}function h(g){return e.consume(g),o=!0,m}function b(g){return u&&o&&Fn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(g)):a(g)}}function VI(e,t,a){const r=this;return o;function o(c){return c!==87&&c!==119||!WN.call(r,r.previous)||mp(r.events)?a(c):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(qI,e.attempt(GN,e.attempt(KN,u),a),a)(c))}function u(c){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(c)}}function XI(e,t,a){const r=this;let o="",u=!1;return c;function c(g){return(g===72||g===104)&&ZN.call(r,r.previous)&&!mp(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(g),e.consume(g),f):a(g)}function f(g){if(Fn(g)&&o.length<5)return o+=String.fromCodePoint(g),e.consume(g),f;if(g===58){const y=o.toLowerCase();if(y==="http"||y==="https")return e.consume(g),m}return a(g)}function m(g){return g===47?(e.consume(g),u?h:(u=!0,m)):a(g)}function h(g){return g===null||Oc(g)||Ot(g)||qr(g)||ed(g)?a(g):e.attempt(GN,e.attempt(KN,b),a)(g)}function b(g){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(g)}}function QI(e,t,a){let r=0;return o;function o(c){return(c===87||c===119)&&r<3?(r++,e.consume(c),o):c===46&&r===3?(e.consume(c),u):a(c)}function u(c){return c===null?a(c):t(c)}}function WI(e,t,a){let r,o,u;return c;function c(h){return h===46||h===95?e.check(VN,m,f)(h):h===null||Ot(h)||qr(h)||h!==45&&ed(h)?m(h):(u=!0,e.consume(h),c)}function f(h){return h===95?r=!0:(o=r,r=void 0),e.consume(h),c}function m(h){return o||r||!u?a(h):t(h)}}function ZI(e,t){let a=0,r=0;return o;function o(c){return c===40?(a++,e.consume(c),o):c===41&&r<a?u(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?e.check(VN,t,u)(c):c===null||Ot(c)||qr(c)?t(c):(e.consume(c),o)}function u(c){return c===41&&r++,e.consume(c),o}}function JI(e,t,a){return r;function r(f){return f===33||f===34||f===39||f===41||f===42||f===44||f===46||f===58||f===59||f===63||f===95||f===126?(e.consume(f),r):f===38?(e.consume(f),u):f===93?(e.consume(f),o):f===60||f===null||Ot(f)||qr(f)?t(f):a(f)}function o(f){return f===null||f===40||f===91||Ot(f)||qr(f)?t(f):r(f)}function u(f){return Fn(f)?c(f):a(f)}function c(f){return f===59?(e.consume(f),r):Fn(f)?(e.consume(f),c):a(f)}}function e6(e,t,a){return r;function r(u){return e.consume(u),o}function o(u){return Rn(u)?a(u):t(u)}}function WN(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ot(e)}function ZN(e){return!Fn(e)}function JN(e){return!(e===47||xh(e))}function xh(e){return e===43||e===45||e===46||e===95||Rn(e)}function mp(e){let t=e.length,a=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){a=!0;break}if(r._gfmAutolinkLiteralWalkedInto){a=!1;break}}return e.length>0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const t6={tokenize:u6,partial:!0};function n6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:i6,continuation:{tokenize:l6},exit:o6}},text:{91:{name:"gfmFootnoteCall",tokenize:r6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:a6,resolveTo:s6}}}}function a6(e,t,a){const r=this;let o=r.events.length;const u=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let c;for(;o--;){const m=r.events[o][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return f;function f(m){if(!c||!c._balanced)return a(m);const h=Ha(r.sliceSerialize({start:c.end,end:r.now()}));return h.codePointAt(0)!==94||!u.includes(h.slice(1))?a(m):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),t(m))}}function s6(e,t){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const u={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},u.start),end:Object.assign({},u.end)},f=[e[a+1],e[a+2],["enter",r,t],e[a+3],e[a+4],["enter",o,t],["exit",o,t],["enter",u,t],["enter",c,t],["exit",c,t],["exit",u,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(a,e.length-a+1,...f),e}function r6(e,t,a){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u=0,c;return f;function f(g){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),m}function m(g){return g!==94?a(g):(e.enter("gfmFootnoteCallMarker"),e.consume(g),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",h)}function h(g){if(u>999||g===93&&!c||g===null||g===91||Ot(g))return a(g);if(g===93){e.exit("chunkString");const y=e.exit("gfmFootnoteCallString");return o.includes(Ha(r.sliceSerialize(y)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(g),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):a(g)}return Ot(g)||(c=!0),u++,e.consume(g),g===92?b:h}function b(g){return g===91||g===92||g===93?(e.consume(g),u++,h):h(g)}}function i6(e,t,a){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u,c=0,f;return m;function m(v){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionLabelMarker"),h}function h(v){return v===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",b):a(v)}function b(v){if(c>999||v===93&&!f||v===null||v===91||Ot(v))return a(v);if(v===93){e.exit("chunkString");const A=e.exit("gfmFootnoteDefinitionLabelString");return u=Ha(r.sliceSerialize(A)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(v),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),y}return Ot(v)||(f=!0),c++,e.consume(v),v===92?g:b}function g(v){return v===91||v===92||v===93?(e.consume(v),c++,b):b(v)}function y(v){return v===58?(e.enter("definitionMarker"),e.consume(v),e.exit("definitionMarker"),o.includes(u)||o.push(u),ft(e,N,"gfmFootnoteDefinitionWhitespace")):a(v)}function N(v){return t(v)}}function l6(e,t,a){return e.check(Do,t,e.attempt(t6,t,a))}function o6(e){e.exit("gfmFootnoteDefinition")}function u6(e,t,a){const r=this;return ft(e,o,"gfmFootnoteDefinitionIndent",5);function o(u){const c=r.events[r.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?t(u):a(u)}}function c6(e){let a=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:u,resolveAll:o};return a==null&&(a=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(c,f){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let h=m;for(;h--;)if(c[h][0]==="exit"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[h][1].end.offset-c[h][1].start.offset){c[m][1].type="strikethroughSequence",c[h][1].type="strikethroughSequence";const b={type:"strikethrough",start:Object.assign({},c[h][1].start),end:Object.assign({},c[m][1].end)},g={type:"strikethroughText",start:Object.assign({},c[h][1].end),end:Object.assign({},c[m][1].start)},y=[["enter",b,f],["enter",c[h][1],f],["exit",c[h][1],f],["enter",g,f]],N=f.parser.constructs.insideSpan.null;N&&xa(y,y.length,0,td(N,c.slice(h+1,m),f)),xa(y,y.length,0,[["exit",g,f],["enter",c[m][1],f],["exit",c[m][1],f],["exit",b,f]]),xa(c,h-1,m-h+3,y),m=h+y.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function u(c,f,m){const h=this.previous,b=this.events;let g=0;return y;function y(v){return h===126&&b[b.length-1][1].type!=="characterEscape"?m(v):(c.enter("strikethroughSequenceTemporary"),N(v))}function N(v){const A=$i(h);if(v===126)return g>1?m(v):(c.consume(v),g++,N);if(g<2&&!a)return m(v);const C=c.exit("strikethroughSequenceTemporary"),S=$i(v);return C._open=!S||S===2&&!!A,C._close=!A||A===2&&!!S,f(v)}}}class d6{constructor(){this.map=[]}add(t,a,r){f6(this,t,a,r)}consume(t){if(this.map.sort(function(u,c){return u[0]-c[0]}),this.map.length===0)return;let a=this.map.length;const r=[];for(;a>0;)a-=1,r.push(t.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),t.length=this.map[a][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const u of o)t.push(u);o=r.pop()}this.map.length=0}}function f6(e,t,a,r){let o=0;if(!(a===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=a,e.map[o][2].push(...r);return}o+=1}e.map.push([t,a,r])}}function m6(e,t){let a=!1;const r=[];for(;t<e.length;){const o=e[t];if(a){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const u=r.length-1;r[u]=r[u]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(a=!0);t+=1}return r}function h6(){return{flow:{null:{name:"table",tokenize:p6,resolveAll:g6}}}}function p6(e,t,a){const r=this;let o=0,u=0,c;return f;function f(D){let te=r.events.length-1;for(;te>-1;){const Q=r.events[te][1].type;if(Q==="lineEnding"||Q==="linePrefix")te--;else break}const le=te>-1?r.events[te][1].type:null,pe=le==="tableHead"||le==="tableRow"?U:m;return pe===U&&r.parser.lazy[r.now().line]?a(D):pe(D)}function m(D){return e.enter("tableHead"),e.enter("tableRow"),h(D)}function h(D){return D===124||(c=!0,u+=1),b(D)}function b(D){return D===null?a(D):Fe(D)?u>1?(u=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),N):a(D):it(D)?ft(e,b,"whitespace")(D):(u+=1,c&&(c=!1,o+=1),D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),c=!0,b):(e.enter("data"),g(D)))}function g(D){return D===null||D===124||Ot(D)?(e.exit("data"),b(D)):(e.consume(D),D===92?y:g)}function y(D){return D===92||D===124?(e.consume(D),g):g(D)}function N(D){return r.interrupt=!1,r.parser.lazy[r.now().line]?a(D):(e.enter("tableDelimiterRow"),c=!1,it(D)?ft(e,v,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):v(D))}function v(D){return D===45||D===58?C(D):D===124?(c=!0,e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),A):I(D)}function A(D){return it(D)?ft(e,C,"whitespace")(D):C(D)}function C(D){return D===58?(u+=1,c=!0,e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),S):D===45?(u+=1,S(D)):D===null||Fe(D)?j(D):I(D)}function S(D){return D===45?(e.enter("tableDelimiterFiller"),M(D)):I(D)}function M(D){return D===45?(e.consume(D),M):D===58?(c=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),O):(e.exit("tableDelimiterFiller"),O(D))}function O(D){return it(D)?ft(e,j,"whitespace")(D):j(D)}function j(D){return D===124?v(D):D===null||Fe(D)?!c||o!==u?I(D):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(D)):I(D)}function I(D){return a(D)}function U(D){return e.enter("tableRow"),$(D)}function $(D){return D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),$):D===null||Fe(D)?(e.exit("tableRow"),t(D)):it(D)?ft(e,$,"whitespace")(D):(e.enter("data"),Z(D))}function Z(D){return D===null||D===124||Ot(D)?(e.exit("data"),$(D)):(e.consume(D),D===92?K:Z)}function K(D){return D===92||D===124?(e.consume(D),Z):Z(D)}}function g6(e,t){let a=-1,r=!0,o=0,u=[0,0,0,0],c=[0,0,0,0],f=!1,m=0,h,b,g;const y=new d6;for(;++a<e.length;){const N=e[a],v=N[1];N[0]==="enter"?v.type==="tableHead"?(f=!1,m!==0&&(L1(y,t,m,h,b),b=void 0,m=0),h={type:"table",start:Object.assign({},v.start),end:Object.assign({},v.end)},y.add(a,0,[["enter",h,t]])):v.type==="tableRow"||v.type==="tableDelimiterRow"?(r=!0,g=void 0,u=[0,0,0,0],c=[0,a+1,0,0],f&&(f=!1,b={type:"tableBody",start:Object.assign({},v.start),end:Object.assign({},v.end)},y.add(a,0,[["enter",b,t]])),o=v.type==="tableDelimiterRow"?2:b?3:1):o&&(v.type==="data"||v.type==="tableDelimiterMarker"||v.type==="tableDelimiterFiller")?(r=!1,c[2]===0&&(u[1]!==0&&(c[0]=c[1],g=oc(y,t,u,o,void 0,g),u=[0,0,0,0]),c[2]=a)):v.type==="tableCellDivider"&&(r?r=!1:(u[1]!==0&&(c[0]=c[1],g=oc(y,t,u,o,void 0,g)),u=c,c=[u[1],a,0,0])):v.type==="tableHead"?(f=!0,m=a):v.type==="tableRow"||v.type==="tableDelimiterRow"?(m=a,u[1]!==0?(c[0]=c[1],g=oc(y,t,u,o,a,g)):c[1]!==0&&(g=oc(y,t,c,o,a,g)),o=0):o&&(v.type==="data"||v.type==="tableDelimiterMarker"||v.type==="tableDelimiterFiller")&&(c[3]=a)}for(m!==0&&L1(y,t,m,h,b),y.consume(t.events),a=-1;++a<t.events.length;){const N=t.events[a];N[0]==="enter"&&N[1].type==="table"&&(N[1]._align=m6(t.events,a))}return e}function oc(e,t,a,r,o,u){const c=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",f="tableContent";a[0]!==0&&(u.end=Object.assign({},ji(t.events,a[0])),e.add(a[0],0,[["exit",u,t]]));const m=ji(t.events,a[1]);if(u={type:c,start:Object.assign({},m),end:Object.assign({},m)},e.add(a[1],0,[["enter",u,t]]),a[2]!==0){const h=ji(t.events,a[2]),b=ji(t.events,a[3]),g={type:f,start:Object.assign({},h),end:Object.assign({},b)};if(e.add(a[2],0,[["enter",g,t]]),r!==2){const y=t.events[a[2]],N=t.events[a[3]];if(y[1].end=Object.assign({},N[1].end),y[1].type="chunkText",y[1].contentType="text",a[3]>a[2]+1){const v=a[2]+1,A=a[3]-a[2]-1;e.add(v,A,[])}}e.add(a[3]+1,0,[["exit",g,t]])}return o!==void 0&&(u.end=Object.assign({},ji(t.events,o)),e.add(o,0,[["exit",u,t]]),u=void 0),u}function L1(e,t,a,r,o){const u=[],c=ji(t.events,a);o&&(o.end=Object.assign({},c),u.push(["exit",o,t])),r.end=Object.assign({},c),u.push(["exit",r,t]),e.add(a+1,0,u)}function ji(e,t){const a=e[t],r=a[0]==="enter"?"start":"end";return a[1][r]}const b6={name:"tasklistCheck",tokenize:E6};function x6(){return{text:{91:b6}}}function E6(e,t,a){const r=this;return o;function o(m){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?a(m):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),u)}function u(m){return Ot(m)?(e.enter("taskListCheckValueUnchecked"),e.consume(m),e.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(e.enter("taskListCheckValueChecked"),e.consume(m),e.exit("taskListCheckValueChecked"),c):a(m)}function c(m){return m===93?(e.enter("taskListCheckMarker"),e.consume(m),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):a(m)}function f(m){return Fe(m)?t(m):it(m)?e.check({tokenize:y6},t,a)(m):a(m)}}function y6(e,t,a){return ft(e,r,"whitespace");function r(o){return o===null?a(o):t(o)}}function N6(e){return oN([GI(),n6(),c6(e),h6(),x6()])}const T6={};function Gi(e){const t=this,a=e||T6,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),u=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),c=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(N6(a)),u.push(zI()),c.push($I(a))}const _6=5*1024*1024,j1=10,eT=["image/png","image/jpeg","image/gif","image/webp"];let v6=0;function S6(e){return new Promise((t,a)=>{const r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>a(r.error),r.readAsDataURL(e)})}function A6({url:e,label:t,onClose:a}){return T.useEffect(()=>{const r=o=>{o.key==="Escape"&&(o.preventDefault(),a())};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[a]),i.jsx("div",{role:"dialog","aria-modal":"true","aria-label":t,onClick:a,className:"fixed inset-0 z-50 flex cursor-zoom-out items-center justify-center bg-black/80 p-8 backdrop-blur-sm",children:i.jsx("img",{src:e,alt:t,className:"max-h-full max-w-full object-contain"})})}function tT({url:e,label:t,className:a}){const[r,o]=T.useState(!1);return i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",onClick:()=>o(!0),"aria-label":`预览 ${t}`,className:"block cursor-zoom-in rounded-md transition-opacity duration-150 hover:opacity-80",children:i.jsx("img",{src:e,alt:t,className:ne("rounded-md border border-line",a)})}),r&&i.jsx(A6,{url:e,label:t,onClose:()=>o(!1)})]})}function nT(e=!0){const[t,a]=T.useState([]),[r,o]=T.useState(null);T.useEffect(()=>{o(null),e||a([])},[e]);const u=async b=>{const g=[],y=[],N=t.length;let v=j1-N;for(const A of b){if(v<=0){y.push(`最多 ${j1} 张图片`);break}if(!eT.includes(A.type)){y.push(`${A.name||"文件"}:格式不支持`);continue}if(A.size>_6){y.push(`${A.name}:超过 5MB`);continue}g.push({_id:`att-${++v6}`,mime:A.type,url:await S6(A),filename:A.name}),v--}g.length>0&&a(A=>[...A,...g]),o(y.length>0?y.join(";"):null)},c=b=>{const g=Array.from(b.clipboardData.files);if(g.length!==0){if(b.preventDefault(),!e){o("当前模型不支持图片");return}u(g)}},f=b=>a(g=>g.filter(y=>y._id!==b)),m=T.useCallback(()=>{a([]),o(null)},[]),h=t.map(({mime:b,url:g,filename:y})=>({mime:b,url:g,filename:y}));return{attachments:t,promptFiles:h,error:r,setError:o,addFiles:u,onPaste:c,remove:f,clear:m}}function aT({onFiles:e,disabled:t,allowed:a}){const r=T.useRef(null);return i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:r,type:"file",accept:eT.join(","),multiple:!0,hidden:!0,onChange:o=>{e(Array.from(o.target.files??[])),o.target.value=""}}),i.jsx("button",{type:"button",onClick:()=>{var o;return(o=r.current)==null?void 0:o.click()},disabled:t||!a,"aria-label":"Attach image",title:a?"附加图片":"当前模型不支持图片",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-fg-5 transition-colors duration-150 hover:text-fg-3 disabled:cursor-not-allowed disabled:text-fg-6/40",children:i.jsx(A3,{className:"h-4 w-4"})})]})}function sT({attachments:e,error:t,onRemove:a,className:r}){return e.length===0&&!t?null:i.jsxs("div",{className:r,children:[e.length>0&&i.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:e.map(o=>i.jsxs("div",{className:"group relative",children:[i.jsx(tT,{url:o.url,label:o.filename??"attachment",className:"h-16 w-16 object-cover"}),i.jsx("button",{type:"button",onClick:()=>a(o._id),"aria-label":"Remove attachment",className:"absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-line bg-term text-fg-4 opacity-0 transition-opacity duration-150 hover:text-fg-2 group-hover:opacity-100",children:i.jsx(gt,{className:"h-2.5 w-2.5",strokeWidth:2.5})})]},o._id))}),t&&i.jsx("div",{className:"mb-2 font-mono text-[11px] text-red-400",children:t})]})}function rT({isListening:e,disabled:t,onStart:a,onStop:r}){const o=T.useRef(!1),u=f=>{if(t)return;f.preventDefault(),o.current=!0,a();const m=()=>{document.removeEventListener("touchend",m),document.removeEventListener("touchcancel",m),o.current=!1,r()};document.addEventListener("touchend",m,{once:!0}),document.addEventListener("touchcancel",m,{once:!0})},c=()=>{if(t||o.current)return;a();const f=()=>{document.removeEventListener("mouseup",f),r()};document.addEventListener("mouseup",f,{once:!0})};return i.jsx("button",{type:"button",disabled:t,onTouchStart:u,onMouseDown:c,onContextMenu:f=>f.preventDefault(),"aria-label":"按住说话",title:"按住说话",style:{WebkitTouchCallout:"none"},className:ne("flex shrink-0 select-none touch-none items-center justify-center transition-colors duration-150 disabled:cursor-not-allowed disabled:text-fg-6/40","order-first self-stretch w-12 rounded-xl sm:order-none sm:self-auto sm:h-7 sm:w-7 sm:rounded-md",e?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"text-fg-5 hover:text-fg-3"),children:i.jsx(B3,{className:ne("h-6 w-6 sm:h-4 sm:w-4",e&&"animate-pulse")})})}const C6=[.85,1.25,.65,1.4,.75,1.15,.95],Fm=4,B1=24;function w6(e){const t=Math.floor(e/60).toString().padStart(2,"0"),a=Math.floor(e%60).toString().padStart(2,"0");return`${t}:${a}`}function k6({volumeLevel:e}){const t=Math.min(Math.max(e,0),1);return i.jsx("div",{className:"flex h-6 items-center gap-1","aria-hidden":"true",children:C6.map((a,r)=>{const o=Fm+t*a*(B1-Fm),u=Math.max(Fm,Math.min(B1,o));return i.jsx("span",{className:"w-1 rounded-full bg-red-400 transition-[height] duration-150 ease-out",style:{height:`${u}px`}},r)})})}function iT({phase:e,transcript:t,interimTranscript:a,editText:r,onEditTextChange:o,onTextareaKeyDown:u,textareaRef:c,wrapperClassName:f}){if(e==="idle")return null;const m=t.length>0||a.length>0;return i.jsx("div",{className:f,children:i.jsxs("div",{className:"max-h-[40vh] overflow-y-auto px-4 py-4",children:[e==="recording"&&i.jsx("div",{className:"text-xl leading-relaxed",children:m?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-fg",children:t}),a&&i.jsx("span",{className:"text-fg-4",children:a})]}):i.jsx("span",{className:"italic text-fg-5",children:"正在聆听…"})}),e==="recognizing"&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ln,{className:"h-5 w-5 shrink-0 text-emerald-400 fs-spin"}),i.jsx("span",{className:"font-mono text-sm text-emerald-400",children:"识别中…"}),a&&i.jsx("span",{className:"truncate text-base text-fg-4",children:a})]}),e==="done"&&i.jsx("textarea",{ref:c,value:r,onChange:h=>o(h.target.value),onKeyDown:u,rows:2,placeholder:"识别结果(可编辑)",className:"w-full resize-none bg-transparent text-xl leading-relaxed text-fg placeholder:text-fg-5 focus:outline-none"})]})})}function lT({phase:e,volumeLevel:t,elapsed:a,editText:r,error:o,onCancel:u,onConfirm:c,idleHint:f,className:m}){return e==="idle"?i.jsx("div",{className:m,children:o?i.jsx("span",{className:"font-mono text-[10px] text-red-400",children:o}):f?i.jsx("span",{className:"font-mono text-[10px] text-fg-6",children:f}):null}):e==="done"?i.jsxs("div",{className:m,children:[i.jsx("span",{className:"hidden font-mono text-[10px] text-fg-6 sm:inline",children:"⌘/Ctrl+⏎ 发送 · Esc 取消"}),i.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i.jsx("button",{type:"button",onClick:u,className:"rounded-md border border-line px-3 py-1 text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"取消"}),i.jsxs("button",{type:"button",onClick:c,disabled:r.trim().length===0,"aria-label":"发送",className:"flex items-center gap-1.5 rounded-md bg-emerald-600 px-3 py-1 text-xs font-medium text-white transition-colors hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-fg-6/30 disabled:text-fg-5",children:[i.jsx(Eo,{className:"h-3.5 w-3.5",strokeWidth:2.5}),i.jsx("span",{children:"发送"})]})]})]}):i.jsx("div",{className:m,children:e==="recording"?i.jsxs(i.Fragment,{children:[i.jsx(k6,{volumeLevel:t}),i.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[11px] font-medium text-red-400",children:[i.jsx("span",{className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-red-400"}),"录音中"]}),i.jsx("span",{className:"font-mono text-[11px] tabular-nums text-fg-4",children:w6(a)})]}):i.jsxs(i.Fragment,{children:[i.jsx(ln,{className:"h-4 w-4 shrink-0 text-emerald-400 fs-spin"}),i.jsx("span",{className:"font-mono text-[11px] text-emerald-400",children:"识别中…"})]})})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var Ki;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(Ki||(Ki={}));class zm extends Error{constructor(t,a,r){super(t),this.message=t,this.code=a,this.data=r}}const R6=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"},O6=e=>{const t=e.CapacitorCustomPlatform||null,a=e.Capacitor||{},r=a.Plugins=a.Plugins||{},o=()=>t!==null?t.name:R6(e),u=()=>o()!=="web",c=g=>{const y=h.get(g);return!!(y!=null&&y.platforms.has(o())||f(g))},f=g=>{var y;return(y=a.PluginHeaders)===null||y===void 0?void 0:y.find(N=>N.name===g)},m=g=>e.console.error(g),h=new Map,b=(g,y={})=>{const N=h.get(g);if(N)return console.warn(`Capacitor plugin "${g}" already registered. Cannot register plugins twice.`),N.proxy;const v=o(),A=f(g);let C;const S=async()=>(!C&&v in y?C=typeof y[v]=="function"?C=await y[v]():C=y[v]:t!==null&&!C&&"web"in y&&(C=typeof y.web=="function"?C=await y.web():C=y.web),C),M=(Z,K)=>{var D,te;if(A){const le=A==null?void 0:A.methods.find(pe=>K===pe.name);if(le)return le.rtype==="promise"?pe=>a.nativePromise(g,K.toString(),pe):(pe,Q)=>a.nativeCallback(g,K.toString(),pe,Q);if(Z)return(D=Z[K])===null||D===void 0?void 0:D.bind(Z)}else{if(Z)return(te=Z[K])===null||te===void 0?void 0:te.bind(Z);throw new zm(`"${g}" plugin is not implemented on ${v}`,Ki.Unimplemented)}},O=Z=>{let K;const D=(...te)=>{const le=S().then(pe=>{const Q=M(pe,Z);if(Q){const q=Q(...te);return K=q==null?void 0:q.remove,q}else throw new zm(`"${g}.${Z}()" is not implemented on ${v}`,Ki.Unimplemented)});return Z==="addListener"&&(le.remove=async()=>K()),le};return D.toString=()=>`${Z.toString()}() { [capacitor code] }`,Object.defineProperty(D,"name",{value:Z,writable:!1,configurable:!1}),D},j=O("addListener"),I=O("removeListener"),U=(Z,K)=>{const D=j({eventName:Z},K),te=async()=>{const pe=await D;I({eventName:Z,callbackId:pe},K)},le=new Promise(pe=>D.then(()=>pe({remove:te})));return le.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await te()},le},$=new Proxy({},{get(Z,K){switch(K){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return A?U:j;case"removeListener":return I;default:return O(K)}}});return r[g]=$,h.set(g,{name:g,proxy:$,platforms:new Set([...Object.keys(y),...A?[v]:[]])}),$};return a.convertFileSrc||(a.convertFileSrc=g=>g),a.getPlatform=o,a.handleError=m,a.isNativePlatform=u,a.isPluginAvailable=c,a.registerPlugin=b,a.Exception=zm,a.DEBUG=!!a.DEBUG,a.isLoggingEnabled=!!a.isLoggingEnabled,a},I6=e=>e.Capacitor=O6(e),Dc=I6(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Po=Dc.registerPlugin;class hp{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(t,a){let r=!1;this.listeners[t]||(this.listeners[t]=[],r=!0),this.listeners[t].push(a);const u=this.windowListeners[t];u&&!u.registered&&this.addWindowListener(u),r&&this.sendRetainedArgumentsForEvent(t);const c=async()=>this.removeListener(t,a);return Promise.resolve({remove:c})}async removeAllListeners(){this.listeners={};for(const t in this.windowListeners)this.removeWindowListener(this.windowListeners[t]);this.windowListeners={}}notifyListeners(t,a,r){const o=this.listeners[t];if(!o){if(r){let u=this.retainedEventArguments[t];u||(u=[]),u.push(a),this.retainedEventArguments[t]=u}return}o.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:r=>{this.notifyListeners(a,r)}}}unimplemented(t="not implemented"){return new Dc.Exception(t,Ki.Unimplemented)}unavailable(t="not available"){return new Dc.Exception(t,Ki.Unavailable)}async removeListener(t,a){const r=this.listeners[t];if(!r)return;const o=r.indexOf(a);this.listeners[t].splice(o,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(r=>{this.notifyListeners(t,r)}))}}const P1=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),U1=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class M6 extends hp{async getCookies(){const t=document.cookie,a={};return t.split(";").forEach(r=>{if(r.length<=0)return;let[o,u]=r.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");o=U1(o).trim(),u=U1(u).trim(),a[o]=u}),a}async setCookie(t){try{const a=P1(t.key),r=P1(t.value),o=t.expires?`; expires=${t.expires.replace("expires=","")}`:"",u=(t.path||"/").replace("path=",""),c=t.url!=null&&t.url.length>0?`domain=${t.url}`:"";document.cookie=`${a}=${r||""}${o}; path=${u}; ${c};`}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)}}}Po("CapacitorCookies",{web:()=>new M6});const D6=async e=>new Promise((t,a)=>{const r=new FileReader;r.onload=()=>{const o=r.result;t(o.indexOf(",")>=0?o.split(",")[1]:o)},r.onerror=o=>a(o),r.readAsDataURL(e)}),L6=(e={})=>{const t=Object.keys(e);return Object.keys(e).map(o=>o.toLocaleLowerCase()).reduce((o,u,c)=>(o[u]=e[t[c]],o),{})},j6=(e,t=!0)=>e?Object.entries(e).reduce((r,o)=>{const[u,c]=o;let f,m;return Array.isArray(c)?(m="",c.forEach(h=>{f=t?encodeURIComponent(h):h,m+=`${u}=${f}&`}),m.slice(0,-1)):(f=t?encodeURIComponent(c):c,m=`${u}=${f}`),`${r}&${m}`},"").substr(1):null,B6=(e,t={})=>{const a=Object.assign({method:e.method||"GET",headers:e.headers},t),o=L6(e.headers)["content-type"]||"";if(typeof e.data=="string")a.body=e.data;else if(o.includes("application/x-www-form-urlencoded")){const u=new URLSearchParams;for(const[c,f]of Object.entries(e.data||{}))u.set(c,f);a.body=u.toString()}else if(o.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 c=new Headers(a.headers);c.delete("content-type"),a.headers=c}else(o.includes("application/json")||typeof e.data=="object")&&(a.body=JSON.stringify(e.data));return a};class P6 extends hp{async request(t){const a=B6(t,t.webFetchExtra),r=j6(t.params,t.shouldEncodeUrlParams),o=r?`${t.url}?${r}`:t.url,u=await fetch(o,a),c=u.headers.get("content-type")||"";let{responseType:f="text"}=u.ok?t:{};c.includes("application/json")&&(f="json");let m,h;switch(f){case"arraybuffer":case"blob":h=await u.blob(),m=await D6(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"}))}}Po("CapacitorHttp",{web:()=>new P6});var H1;(function(e){e.Dark="DARK",e.Light="LIGHT",e.Default="DEFAULT"})(H1||(H1={}));var F1;(function(e){e.StatusBar="StatusBar",e.NavigationBar="NavigationBar"})(F1||(F1={}));class U6 extends hp{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")}}Po("SystemBars",{web:()=>new U6});const H6="modulepreload",F6=function(e){return"/"+e},z1={},z6=function(t,a,r){let o=Promise.resolve();if(a&&a.length>0){let c=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"));o=c(a.map(h=>{if(h=F6(h),h in z1)return;z1[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":H6,b||(y.as="script"),y.crossOrigin="",y.href=h,m&&y.setAttribute("nonce",m),document.head.appendChild(y),b)return new Promise((N,v)=>{y.addEventListener("load",N),y.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${h}`)))})}))}function u(c){const f=new Event("vite:preloadError",{cancelable:!0});if(f.payload=c,window.dispatchEvent(f),!f.defaultPrevented)throw c}return o.then(c=>{for(const f of c||[])f.status==="rejected"&&u(f.reason);return t().catch(u)})},Li=Po("SpeechRecognition",{web:()=>z6(()=>import("./web-CsMK9uDO.js"),[]).then(e=>new e.SpeechRecognitionWeb)});function $6(e,t){const a=e.length,r=new ArrayBuffer(44+a*2),o=new DataView(r),u=(c,f)=>{for(let m=0;m<f.length;m++)o.setUint8(c+m,f.charCodeAt(m))};u(0,"RIFF"),o.setUint32(4,36+a*2,!0),u(8,"WAVE"),u(12,"fmt "),o.setUint32(16,16,!0),o.setUint16(20,1,!0),o.setUint16(22,1,!0),o.setUint32(24,t,!0),o.setUint32(28,t*2,!0),o.setUint16(32,2,!0),o.setUint16(34,16,!0),u(36,"data"),o.setUint32(40,a*2,!0);for(let c=0;c<a;c++){const f=Math.max(-1,Math.min(1,e[c]));o.setInt16(44+c*2,f<0?f*32768:f*32767,!0)}return new Blob([r],{type:"audio/wav"})}const Eh=Dc.isNativePlatform(),$m=!Eh&&typeof window<"u"?window.SpeechRecognition??window.webkitSpeechRecognition:void 0,qm=16e3;function q6(e="zh-CN"){const[t,a]=T.useState(!1),[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState(null),[h,b]=T.useState(0),[g,y]=T.useState("idle"),N=T.useRef(null),v=T.useRef(!1),A=T.useRef([]),C=T.useRef(!1),S=T.useRef(null),M=T.useRef(!1),O=T.useRef(null),j=T.useRef(null),I=T.useRef(null),U=T.useRef([]),$=T.useRef(!1),Z=!0,K=T.useCallback(async()=>{var se,L,Ne;(se=I.current)==null||se.disconnect(),(L=j.current)==null||L.getTracks().forEach(Te=>Te.stop()),await((Ne=O.current)==null?void 0:Ne.close().catch(()=>{}));const F=U.current;if(U.current=[],I.current=null,j.current=null,O.current=null,F.length===0||$.current){a(!1),y("idle");return}c("识别中…"),y("recognizing");const k=F.reduce((Te,V)=>Te+V.length,0),P=new Float32Array(k);let J=0;for(const Te of F)P.set(Te,J),J+=Te.length;const w=$6(P,qm),H=new FormData;H.append("audio",w,"recording.wav");try{const Te=await fetch("/api/transcribe",{method:"POST",body:H});if($.current)return;if(Te.ok){const{text:V}=await Te.json();V?(o(V),y("done")):y("idle")}else{const V=await Te.json().catch(()=>({error:`HTTP ${Te.status}`}));m(V.error??`HTTP ${Te.status}`),y("idle")}}catch(Te){m(`语音识别失败:${Te instanceof Error?Te.message:String(Te)}`),y("idle")}finally{c(""),a(!1)}},[]),D=T.useCallback(async()=>{if(v.current=!0,S.current&&(clearTimeout(S.current),S.current=null),Eh){await Li.stop().catch(()=>{});for(const F of A.current)await F.remove().catch(()=>{});A.current=[],a(!1),c("")}else N.current?N.current.stop():O.current?await K():(a(!1),y("idle"))},[K]),te=T.useCallback(async()=>{var J;$.current=!1,o(""),c(""),m(null),y("idle");const{available:F}=await Li.available();if(!F){m("当前设备不支持语音识别");return}if((await Li.requestPermissions()).speechRecognition!=="granted"){m("请允许语音识别权限");return}const P=[];P.push(await Li.addListener("partialResults",w=>{c(w.matches[0]??"")})),P.push(await Li.addListener("listeningState",w=>{const H=w.status==="started";a(H),H&&y("recording"),H||c("")})),A.current=P;try{const w=await Li.start({language:e,partialResults:!0,maxResults:1});(J=w.matches)!=null&&J.length&&o(H=>H+w.matches.join(""))}catch(w){m(`语音识别错误:${w instanceof Error?w.message:String(w)}`);for(const H of P)await H.remove().catch(()=>{});A.current=[]}},[e]),le=T.useCallback(()=>{if(!$m)return!1;$.current=!1,o(""),c(""),m(null),y("idle"),v.current=!1;const F=new $m;F.lang=e,F.continuous=!0,F.interimResults=!0,F.maxAlternatives=1,F.onstart=()=>{a(!0),y("recording"),C.current=!1,S.current=setTimeout(()=>{!C.current&&!v.current&&(M.current=!0,v.current=!0,F.stop(),m("语音识别服务不可用(Chrome/Edge 需连接 Google 服务器),下次将使用服务端识别"))},5e3)},F.onresult=k=>{C.current=!0,S.current&&(clearTimeout(S.current),S.current=null);let P="",J="";for(let w=k.resultIndex;w<k.results.length;w++){const H=k.results[w][0].transcript;k.results[w].isFinal?P+=H:J+=H}P&&o(w=>w+P),c(J)},F.onerror=k=>{switch(k.error!=="no-speech"&&k.error!=="aborted"&&(v.current=!0),k.error){case"not-allowed":m("请允许麦克风权限");break;case"network":m("网络错误,请检查连接");break;case"no-speech":case"aborted":return;default:m(`语音识别错误:${k.error}`)}},F.onend=()=>{if(c(""),!v.current)try{F.start();return}catch{}a(!1),N.current=null},N.current=F;try{return F.start(),!0}catch{return!1}},[e]),pe=T.useCallback(async()=>{$.current=!1,o(""),c(""),m(null),y("idle");try{const w=await fetch("/api/transcribe/status"),{available:H}=await w.json();if(!H){m("语音识别服务未就绪,请稍后重试");return}}catch{m("无法连接语音识别服务");return}let F;try{F=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:qm,channelCount:1}})}catch{m("请允许麦克风权限");return}const k=new AudioContext({sampleRate:qm}),P=k.createMediaStreamSource(F),J=k.createScriptProcessor(4096,1,1);U.current=[],J.onaudioprocess=w=>{U.current.push(new Float32Array(w.inputBuffer.getChannelData(0)))},P.connect(J),J.connect(k.destination),O.current=k,j.current=F,I.current=J,a(!0),y("recording")},[]),Q=T.useCallback(()=>{Eh?te():$m&&!M.current&&le()||pe()},[te,le,pe]);T.useEffect(()=>{if(!t){b(0);return}if(N.current)return;let F=!1,k=null,P=null,J=0;return(async()=>{try{if(k=await navigator.mediaDevices.getUserMedia({audio:!0}),F){k.getTracks().forEach(Te=>Te.stop());return}P=new AudioContext;const w=P.createMediaStreamSource(k),H=P.createAnalyser();H.fftSize=256,w.connect(H);const se=new Uint8Array(H.frequencyBinCount);let L=0;const Ne=()=>{if(F)return;H.getByteFrequencyData(se);const Te=performance.now();if(Te-L>80){let V=0;for(let ve=0;ve<se.length;ve++)V+=se[ve];b(V/(se.length*255)),L=Te}J=requestAnimationFrame(Ne)};J=requestAnimationFrame(Ne)}catch{}})(),()=>{F=!0,cancelAnimationFrame(J),k==null||k.getTracks().forEach(w=>w.stop()),P==null||P.close().catch(()=>{}),b(0)}},[t]),T.useEffect(()=>{!t&&g==="recording"&&y(r?"done":"idle")},[t,g,r]),T.useEffect(()=>()=>{var F,k,P,J;v.current=!0,(F=N.current)==null||F.stop(),(k=I.current)==null||k.disconnect(),(P=j.current)==null||P.getTracks().forEach(w=>w.stop()),(J=O.current)==null||J.close().catch(()=>{});for(const w of A.current)w.remove().catch(()=>{})},[]);const q=T.useCallback(()=>{$.current=!0,o(""),c(""),y("idle")},[]);return{isSupported:Z,isListening:t,phase:g,transcript:r,interimTranscript:u,error:f,volumeLevel:h,start:Q,stop:D,resetTranscript:q}}const Y6=240,G6=1e3;function oT(e){const t=q6(),[a,r]=T.useState(""),[o,u]=T.useState(0),c=T.useRef(null),f=T.useRef(null),m=T.useRef(0);T.useEffect(()=>(t.phase==="recording"?(m.current=Date.now(),u(0),f.current=setInterval(()=>{u(Math.floor((Date.now()-m.current)/1e3))},G6)):f.current&&(clearInterval(f.current),f.current=null),()=>{f.current&&(clearInterval(f.current),f.current=null)}),[t.phase]),T.useEffect(()=>{t.phase==="done"&&(r(t.transcript),requestAnimationFrame(()=>{const y=c.current;y&&(y.focus(),y.setSelectionRange(y.value.length,y.value.length))}))},[t.phase,t.transcript]),T.useLayoutEffect(()=>{if(t.phase!=="done")return;const y=c.current;y&&(y.style.height="auto",y.style.height=`${Math.min(y.scrollHeight,Y6)}px`)},[t.phase,a]);const h=T.useCallback(()=>{t.stop(),t.resetTranscript(),r("")},[t]),b=T.useCallback(async()=>{const y=a.trim();if(!y){h();return}await e(y)!==!1&&(t.resetTranscript(),r(""))},[a,e,h,t]);T.useEffect(()=>{if(t.phase==="idle")return;const y=N=>{if(N.key==="Escape"&&t.phase!=="recognizing"){N.preventDefault(),h();return}if(t.phase==="done"&&N.key==="Enter"&&(N.metaKey||N.ctrlKey)){if(N.isComposing)return;N.preventDefault(),b()}};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[t.phase,h,b]);const g=T.useCallback(y=>{y.nativeEvent.isComposing||y.keyCode===229||y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),b())},[b]);return{stt:t,editText:a,setEditText:r,elapsed:o,textareaRef:c,cancel:h,confirm:b,handleTextareaKeyDown:g}}const or=es(e=>({agents:[],loaded:!1,loadAgents:async()=>{const t=je.getState().activeRepoId;try{const a=t?await Ly(t):await Iy();e({agents:a,loaded:!0})}catch{e({loaded:!0})}}}));function K6(e){if(typeof e!="string")return e;const t=e.trim();if(t)try{return JSON.parse(t)}catch{return t}}function pn(e){return e&&typeof e=="object"?e:null}function Kr(e){const t=pn(e);return t&&"properties"in t?t.properties:e}function V6(e){const t=pn(e);return typeof(t==null?void 0:t.type)=="string"?t.type:void 0}function X6(e){const t=pn(Kr(e));if(!t)return null;const a=pn(t.info);if(a&&typeof a.id=="string"){const o=Array.isArray(t.parts)?t.parts:void 0;return{...a,...o?{parts:o}:{}}}if(typeof t.id=="string"&&typeof t.role=="string")return t;const r=pn(t.message);return r&&typeof r.id=="string"?r:null}function Q6(e){const t=pn(Kr(e));if(!t)return{};const a=pn(t.part)??t;return typeof a.type!="string"?{}:{messageId:typeof a.messageID=="string"&&a.messageID||typeof a.messageId=="string"&&a.messageId||typeof t.messageID=="string"&&t.messageID||typeof t.messageId=="string"&&t.messageId||void 0,part:a}}function W6(e){const t=pn(Kr(e));if(!t||t.field!=="text")return null;const a=typeof t.messageID=="string"?t.messageID:null,r=typeof t.partID=="string"?t.partID:null,o=typeof t.delta=="string"?t.delta:null;return!a||!r||o===null?null:{messageId:a,partId:r,delta:o}}function Z6(e){const t=Kr(e);if(Array.isArray(t))return t;const a=pn(t);return a&&Array.isArray(a.todos)?a.todos:[]}function Xa(e){return typeof e=="number"?e:0}function J6(e){const t=pn(Kr(e));if(!t||typeof t.id!="string")return null;const a={id:t.id};typeof t.title=="string"&&(a.title=t.title),typeof t.agent=="string"&&(a.agent=t.agent),typeof t.cost=="number"&&(a.cost=t.cost);const r=typeof t.parentID=="string"?t.parentID:typeof t.parent_id=="string"?t.parent_id:void 0;r&&(a.parentID=r);const o=pn(t.tokens),u=typeof t.tokens_input=="number"||typeof t.tokens_output=="number";if(o||u){const f=o?pn(o.cache):null;a.tokens={input:Xa(o==null?void 0:o.input)||Xa(t.tokens_input),output:Xa(o==null?void 0:o.output)||Xa(t.tokens_output),reasoning:Xa(o==null?void 0:o.reasoning)||Xa(t.tokens_reasoning),cache:{read:Xa(f==null?void 0:f.read)||Xa(t.tokens_cache_read),write:Xa(f==null?void 0:f.write)||Xa(t.tokens_cache_write)}}}const c=pn(t.model);return c&&(a.model={providerID:typeof c.providerID=="string"?c.providerID:void 0,modelID:typeof c.modelID=="string"?c.modelID:void 0,variant:typeof c.variant=="string"?c.variant:void 0}),a}function eM(e){const t=pn(Kr(e));if(!t)return null;if(typeof t.message=="string")return t.message;const a=pn(t.error);if(a){const r=pn(a.data);if(typeof(r==null?void 0:r.message)=="string")return`${a.name??"Error"}: ${r.message}`;if(typeof a.message=="string")return`${a.name??"Error"}: ${a.message}`;if(typeof a.name=="string")return String(a.name)}return typeof t.reason=="string"?t.reason:null}function tM(e){const t=Kr(e);if(typeof t=="string")return t;const a=pn(t);if(typeof(a==null?void 0:a.status)=="string")return a.status;const r=pn(a==null?void 0:a.status);return typeof(r==null?void 0:r.type)=="string"?r.type:typeof(a==null?void 0:a.type)=="string"?a.type:null}function nM(e,t,a,r){switch(e==="message"||e===""?V6(t)??e:e){case"message.updated":{const u=X6(t);u&&r.updateMessage(a,u);break}case"session.updated":{const u=J6(t);u&&r.updateSessionInfo(u);break}case"message.part.updated":{const{messageId:u,part:c}=Q6(t);c&&u&&r.updateMessagePart(a,u,c);break}case"message.part.delta":{const u=W6(t);u&&r.appendMessagePartDelta(a,u.messageId,u.partId,u.delta);break}case"todo.updated":{r.updateTodos(a,Z6(t));break}case"session.status":{const u=tM(t);u&&r.setSessionStatus(a,u);break}case"session.idle":{r.setSessionStatus(a,"idle");break}case"session.error":{const u=eM(t);r.setSessionStatus(a,"error",u??void 0);break}}}const aM=600*1e3;class sM{constructor(t,a){sn(this,"sessionId");sn(this,"idleTimer",null);sn(this,"active",!1);sn(this,"alive",!0);sn(this,"callbacks");this.sessionId=t,this.callbacks=a,this.resetIdleTimer()}dispatch(t,a){if(!this.alive)return;this.resetIdleTimer();const r=Re.getState();nM(t,a,this.sessionId,r)}activate(){this.active=!0,this.clearIdleTimer()}deactivate(){this.active=!1,this.resetIdleTimer()}refreshOnIdle(){Re.getState().refreshSessionData(this.sessionId)}stop(){this.alive=!1,this.clearIdleTimer()}resetIdleTimer(){this.clearIdleTimer(),!this.active&&(this.idleTimer=setTimeout(()=>{this.callbacks.onWorkerIdle(this.sessionId)},aM))}clearIdleTimer(){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null)}}const rM=1e3,iM=3e4;class lM{constructor(t,a){sn(this,"source",null);sn(this,"reconnectTimer",null);sn(this,"attempts",0);sn(this,"disposed",!1);sn(this,"repoId");sn(this,"onEvent");this.repoId=t,this.onEvent=a}start(){this.connect()}stop(){var t;this.disposed=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),(t=this.source)==null||t.close(),this.source=null}connect(){if(this.disposed)return;const t=kC(this.repoId),a=new EventSource(t);this.source=a,a.onopen=()=>{this.attempts=0},a.onmessage=o=>{this.handleRaw("message",o)};const r=["message.updated","message.part.updated","message.part.delta","message.removed","todo.updated","session.status","session.idle","session.error","session.updated"];for(const o of r)a.addEventListener(o,u=>{this.handleRaw(o,u)});a.onerror=()=>{if(!(this.disposed||!this.source)&&this.source.readyState===EventSource.CLOSED){this.source.close(),this.source=null;const o=Math.min(rM*2**this.attempts,iM);this.attempts++,this.reconnectTimer=setTimeout(()=>this.connect(),o)}}}handleRaw(t,a){if(!(a instanceof MessageEvent))return;const r=K6(a.data);if(r===void 0)return;const o=this.extractSessionId(r);if(!o)return;let u=t;if(t==="message"||t===""){const c=r&&typeof r=="object"?r:null;typeof(c==null?void 0:c.type)=="string"&&(u=c.type)}this.onEvent(o,u,r)}extractSessionId(t){if(!t||typeof t!="object")return null;const a=t;if(a.properties&&typeof a.properties=="object"){const r=a.properties;if(typeof r.sessionID=="string")return r.sessionID;if(typeof r.id=="string")return r.id}return typeof a.sessionID=="string"?a.sessionID:typeof a.sessionId=="string"?a.sessionId:null}}const oM=6e4;class uM{constructor(t){sn(this,"timer",null);sn(this,"paused",!1);sn(this,"callbacks");this.callbacks=t}start(){this.tick(),this.timer=setInterval(()=>{this.paused||this.tick()},oM)}stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}pause(){this.paused=!0}resume(){this.paused=!1,this.tick()}tick(){const t=je.getState().activeRepoId;t&&(Re.getState().loadSessions(),RC(t).then(a=>{const r={};for(const[o,u]of Object.entries(a))r[o]=u.type??"idle";Re.getState().bulkSetStatuses(r);for(const[o,u]of Object.entries(r))(u==="busy"||u==="retry")&&this.callbacks.ensureWorker(o)}).catch(()=>{}))}}class cM{constructor(){sn(this,"workers",new Map);sn(this,"dispatcher",null);sn(this,"supervisor",null);sn(this,"visibilityHandler",null)}start(t){this.stop();const a={onWorkerIdle:r=>this.removeWorker(r)};this.dispatcher=new lM(t,(r,o,u)=>{const c=this.ensureWorker(r,a);if(o==="session.idle"||o==="session.status"){const f=Re.getState().sessionStatuses[r];c.dispatch(o,u);const m=Re.getState().sessionStatuses[r];f&&f!=="idle"&&m==="idle"&&c.refreshOnIdle()}else c.dispatch(o,u)}),this.dispatcher.start(),this.supervisor=new uM({ensureWorker:r=>this.ensureWorker(r,a)}),this.supervisor.start(),this.visibilityHandler=()=>{var r,o;document.hidden?(r=this.supervisor)==null||r.pause():(o=this.supervisor)==null||o.resume()},document.addEventListener("visibilitychange",this.visibilityHandler)}stop(){var t,a;(t=this.dispatcher)==null||t.stop(),this.dispatcher=null,(a=this.supervisor)==null||a.stop(),this.supervisor=null;for(const r of this.workers.values())r.stop();this.workers.clear(),this.visibilityHandler&&(document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}activateSession(t){for(const o of this.workers.values())o.sessionId!==t&&o.deactivate();if(!t)return;const a={onWorkerIdle:o=>this.removeWorker(o)};this.ensureWorker(t,a).activate(),Re.getState().refreshSessionData(t)}deactivateSession(t){var a;(a=this.workers.get(t))==null||a.deactivate()}ensureWorker(t,a){let r=this.workers.get(t);return r||(r=new sM(t,a),this.workers.set(t,r)),r}removeWorker(t){const a=Re.getState().activeSessionId;if(t===a)return;const r=this.workers.get(t);r&&(r.stop(),this.workers.delete(t))}}const Lc=new cM,$1=(function(e,t,a){const r=Lo(a);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(r(e.children[t],t,e))return e.children[t]}),Vr=(function(e){if(e==null)return mM;if(typeof e=="string")return fM(e);if(typeof e=="object")return dM(e);if(typeof e=="function")return pp(e);throw new Error("Expected function, string, or array as `test`")});function dM(e){const t=[];let a=-1;for(;++a<e.length;)t[a]=Vr(e[a]);return pp(r);function r(...o){let u=-1;for(;++u<t.length;)if(t[u].apply(this,o))return!0;return!1}}function fM(e){return pp(t);function t(a){return a.tagName===e}}function pp(e){return t;function t(a,r,o){return!!(hM(a)&&e.call(this,a,typeof r=="number"?r:void 0,o||void 0))}}function mM(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function hM(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const q1=/\n/g,Y1=/[\t ]+/g,yh=Vr("br"),G1=Vr(TM),pM=Vr("p"),K1=Vr("tr"),gM=Vr(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",NM,_M]),uT=Vr(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function bM(e,t){const a=t||{},r="children"in e?e.children:[],o=uT(e),u=fT(e,{whitespace:a.whitespace||"normal"}),c=[];(e.type==="text"||e.type==="comment")&&c.push(...dT(e,{breakBefore:!0,breakAfter:!0}));let f=-1;for(;++f<r.length;)c.push(...cT(r[f],e,{whitespace:u,breakBefore:f?void 0:o,breakAfter:f<r.length-1?yh(r[f+1]):o}));const m=[];let h;for(f=-1;++f<c.length;){const b=c[f];typeof b=="number"?h!==void 0&&b>h&&(h=b):b&&(h!==void 0&&h>-1&&m.push(`
491
491
  `.repeat(h)||" "),h=-1,m.push(b))}return m.join("")}function cT(e,t,a){return e.type==="element"?xM(e,t,a):e.type==="text"?a.whitespace==="normal"?dT(e,a):EM(e):[]}function xM(e,t,a){const r=fT(e,a),o=e.children||[];let u=-1,c=[];if(gM(e))return c;let f,m;for(yh(e)||K1(e)&&$1(t,e,K1)?m=`
492
492
  `:pM(e)?(f=2,m=2):uT(e)&&(f=1,m=1);++u<o.length;)c=c.concat(cT(o[u],e,{whitespace:r,breakBefore:u?void 0:f,breakAfter:u<o.length-1?yh(o[u+1]):m}));return G1(e)&&$1(t,e,G1)&&c.push(" "),f&&c.unshift(f),m&&c.push(m),c}function dT(e,t){const a=String(e.value),r=[],o=[];let u=0;for(;u<=a.length;){q1.lastIndex=u;const m=q1.exec(a),h=m&&"index"in m?m.index:a.length;r.push(yM(a.slice(u,h).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),u===0?t.breakBefore:!0,h===a.length?t.breakAfter:!0)),u=h+1}let c=-1,f;for(;++c<r.length;)r[c].charCodeAt(r[c].length-1)===8203||c<r.length-1&&r[c+1].charCodeAt(0)===8203?(o.push(r[c]),f=void 0):r[c]?(typeof f=="number"&&o.push(f),o.push(r[c]),f=0):(c===0||c===r.length-1)&&o.push(0);return o}function EM(e){return[String(e.value)]}function yM(e,t,a){const r=[];let o=0,u;for(;o<e.length;){Y1.lastIndex=o;const c=Y1.exec(e);u=c?c.index:e.length,!o&&!u&&c&&!t&&r.push(""),o!==u&&r.push(e.slice(o,u)),o=c?u+c[0].length:u}return o!==u&&!a&&r.push(""),r.join(" ")}function fT(e,t){if(e.type==="element"){const a=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return a.wrap?"pre-wrap":"pre";case"td":case"th":return a.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function NM(e){return!!(e.properties||{}).hidden}function TM(e){return e.tagName==="td"||e.tagName==="th"}function _M(e){return e.tagName==="dialog"&&!(e.properties||{}).open}function vM(e){const t=e.regex,a=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",o="[a-zA-Z_]\\w*::",c="(?!struct)("+r+"|"+t.optional(o)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",f={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},b={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},g={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},a,e.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:t.optional(o)+e.IDENT_RE,relevance:0},N=t.optional(o)+e.IDENT_RE+"\\s*\\(",v=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],A=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],C=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],S=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],j={type:A,keyword:v,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:C},I={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},U=[I,g,f,a,e.C_BLOCK_COMMENT_MODE,b,h],$={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:j,contains:U.concat([{begin:/\(/,end:/\)/,keywords:j,contains:U.concat(["self"]),relevance:0}]),relevance:0},Z={className:"function",begin:"("+c+"[\\*&\\s]+)+"+N,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:j,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:j,relevance:0},{begin:N,returnBegin:!0,contains:[y],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[h,b]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:j,relevance:0,contains:[a,e.C_BLOCK_COMMENT_MODE,h,b,f,{begin:/\(/,end:/\)/,keywords:j,relevance:0,contains:["self",a,e.C_BLOCK_COMMENT_MODE,h,b,f]}]},f,a,e.C_BLOCK_COMMENT_MODE,g]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:j,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat($,Z,I,U,[g,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:j,contains:["self",f]},{begin:e.IDENT_RE+"::",keywords:j},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function SM(e){const t={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},a=vM(e),r=a.keywords;return r.type=[...r.type,...t.type],r.literal=[...r.literal,...t.literal],r.built_in=[...r.built_in,...t.built_in],r._hints=t._hints,a.name="Arduino",a.aliases=["ino"],a.supersetOf="cpp",a}function AM(e){const t=e.regex,a={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[a]}]};Object.assign(a,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const o={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},u=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),c={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},f={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,a,o]};o.contains.push(f);const m={match:/\\"/},h={className:"string",begin:/'/,end:/'/},b={match:/\\'/},g={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,a]},y=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],N=e.SHEBANG({binary:`(${y.join("|")})`,relevance:10}),v={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},A=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],C=["true","false"],S={match:/(\/[a-z._-]+)+/},M=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],O=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],j=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],I=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:A,literal:C,built_in:[...M,...O,"set","shopt",...j,...I]},contains:[N,e.SHEBANG(),v,g,u,c,S,f,m,h,b,a]}}function CM(e){const t=e.regex,a=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",o="[a-zA-Z_]\\w*::",c="("+r+"|"+t.optional(o)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",f={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},b={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},g={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},a,e.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:t.optional(o)+e.IDENT_RE,relevance:0},N=t.optional(o)+e.IDENT_RE+"\\s*\\(",C={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},S=[g,f,a,e.C_BLOCK_COMMENT_MODE,b,h],M={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:C,contains:S.concat([{begin:/\(/,end:/\)/,keywords:C,contains:S.concat(["self"]),relevance:0}]),relevance:0},O={begin:"("+c+"[\\*&\\s]+)+"+N,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:C,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:C,relevance:0},{begin:N,returnBegin:!0,contains:[e.inherit(y,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:C,relevance:0,contains:[a,e.C_BLOCK_COMMENT_MODE,h,b,f,{begin:/\(/,end:/\)/,keywords:C,relevance:0,contains:["self",a,e.C_BLOCK_COMMENT_MODE,h,b,f]}]},f,a,e.C_BLOCK_COMMENT_MODE,g]};return{name:"C",aliases:["h"],keywords:C,disableAutodetect:!0,illegal:"</",contains:[].concat(M,O,S,[g,{begin:e.IDENT_RE+"::",keywords:C},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:g,strings:h,keywords:C}}}function wM(e){const t=e.regex,a=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",o="[a-zA-Z_]\\w*::",c="(?!struct)("+r+"|"+t.optional(o)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",f={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},h={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},e.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},b={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},g={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(h,{className:"string"}),{className:"string",begin:/<.*?>/},a,e.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:t.optional(o)+e.IDENT_RE,relevance:0},N=t.optional(o)+e.IDENT_RE+"\\s*\\(",v=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],A=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],C=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],S=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],j={type:A,keyword:v,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:C},I={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:t.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},U=[I,g,f,a,e.C_BLOCK_COMMENT_MODE,b,h],$={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:j,contains:U.concat([{begin:/\(/,end:/\)/,keywords:j,contains:U.concat(["self"]),relevance:0}]),relevance:0},Z={className:"function",begin:"("+c+"[\\*&\\s]+)+"+N,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:j,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:j,relevance:0},{begin:N,returnBegin:!0,contains:[y],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[h,b]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:j,relevance:0,contains:[a,e.C_BLOCK_COMMENT_MODE,h,b,f,{begin:/\(/,end:/\)/,keywords:j,relevance:0,contains:["self",a,e.C_BLOCK_COMMENT_MODE,h,b,f]}]},f,a,e.C_BLOCK_COMMENT_MODE,g]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:j,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat($,Z,I,U,[g,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:j,contains:["self",f]},{begin:e.IDENT_RE+"::",keywords:j},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function kM(e){const t=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],a=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],o=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],u=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],c={keyword:o.concat(u),built_in:t,literal:r},f=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),m={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},h={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},b={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},g=e.inherit(b,{illegal:/\n/}),y={className:"subst",begin:/\{/,end:/\}/,keywords:c},N=e.inherit(y,{illegal:/\n/}),v={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,N]},A={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},y]},C=e.inherit(A,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},N]});y.contains=[A,v,b,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,e.C_BLOCK_COMMENT_MODE],N.contains=[C,v,g,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const S={variants:[h,A,v,b,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},M={begin:"<",end:">",contains:[{beginKeywords:"in out"},f]},O=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",j={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:c,illegal:/::/,contains:[e.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},S,m,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},f,M,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[f,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[f,M,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+O+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:c,contains:[{beginKeywords:a.join(" "),relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,M],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,relevance:0,contains:[S,m,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},j]}}const RM=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),OM=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],IM=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],MM=[...OM,...IM],DM=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),LM=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),jM=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),BM=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function PM(e){const t=e.regex,a=RM(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},o="and or not only",u=/@-?\w[\w]*(-\w+)*/,c="[a-zA-Z-][a-zA-Z0-9_-]*",f=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[a.BLOCK_COMMENT,r,a.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+c,relevance:0},a.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+LM.join("|")+")"},{begin:":(:)?("+jM.join("|")+")"}]},a.CSS_VARIABLE,{className:"attribute",begin:"\\b("+BM.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[a.BLOCK_COMMENT,a.HEXCOLOR,a.IMPORTANT,a.CSS_NUMBER_MODE,...f,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...f,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},a.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:u},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:o,attribute:DM.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...f,a.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+MM.join("|")+")\\b"}]}}function UM(e){const t=e.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:t.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:t.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function HM(e){const u={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:u,illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{className:"string",variants:[e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[e.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:u,illegal:/["']/}]}]}}function FM(e){const t=e.regex,a=/[_A-Za-z][_0-9A-Za-z]*/;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[e.HASH_COMMENT_MODE,e.QUOTE_STRING_MODE,e.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:t.concat(a,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function zM(e){const t=e.regex,a={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const o={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},u={className:"literal",begin:/\bon|off|true|false|yes|no\b/},c={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},f={begin:/\[/,end:/\]/,contains:[r,u,o,c,a,"self"],relevance:0},m=/[A-Za-z0-9_-]+/,h=/"(\\"|[^"])*"/,b=/'[^']*'/,g=t.either(m,h,b),y=t.concat(g,"(\\s*\\.\\s*",g,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:y,className:"attr",starts:{end:/$/,contains:[r,f,u,o,c,a]}}]}}var Bi="[0-9](_*[0-9])*",uc=`\\.(${Bi})`,cc="[0-9a-fA-F](_*[0-9a-fA-F])*",V1={className:"number",variants:[{begin:`(\\b(${Bi})((${uc})|\\.)?|(${uc}))[eE][+-]?(${Bi})[fFdD]?\\b`},{begin:`\\b(${Bi})((${uc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${uc})[fFdD]?\\b`},{begin:`\\b(${Bi})[fFdD]\\b`},{begin:`\\b0[xX]((${cc})\\.?|(${cc})?\\.(${cc}))[pP][+-]?(${Bi})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${cc})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function mT(e,t,a){return a===-1?"":e.replace(t,r=>mT(e,t,a-1))}function $M(e){const t=e.regex,a="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=a+mT("(?:<"+a+"~~~(?:\\s*,\\s*"+a+"~~~)*>)?",/~~~/g,2),m={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},h={className:"meta",begin:"@"+a,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},b={className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:m,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,a],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,a),/\s+/,a,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,a],className:{1:"keyword",3:"title.class"},contains:[b,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:m,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:m,relevance:0,contains:[h,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,V1,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},V1,h]}}const X1="[A-Za-z$_][0-9A-Za-z$_]*",qM=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],YM=["true","false","null","undefined","NaN","Infinity"],hT=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],pT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],gT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],GM=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],KM=[].concat(gT,hT,pT);function VM(e){const t=e.regex,a=(P,{after:J})=>{const w="</"+P[0].slice(1);return P.input.indexOf(w,J)!==-1},r=X1,o={begin:"<>",end:"</>"},u=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(P,J)=>{const w=P[0].length+P.index,H=P.input[w];if(H==="<"||H===","){J.ignoreMatch();return}H===">"&&(a(P,{after:w})||J.ignoreMatch());let se;const L=P.input.substring(w);if(se=L.match(/^\s*=/)){J.ignoreMatch();return}if((se=L.match(/^\s+extends\s+/))&&se.index===0){J.ignoreMatch();return}}},f={$pattern:X1,keyword:qM,literal:YM,built_in:KM,"variable.language":GM},m="[0-9](_?[0-9])*",h=`\\.(${m})`,b="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${b})((${h})|\\.)?|(${h}))[eE][+-]?(${m})\\b`},{begin:`\\b(${b})\\b((${h})\\b|\\.)?|(${h})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:f,contains:[]},N={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"css"}},A={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},C={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,y]},M={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},O=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,N,v,A,C,{match:/\$\d+/},g];y.contains=O.concat({begin:/\{/,end:/\}/,keywords:f,contains:["self"].concat(O)});const j=[].concat(M,y.contains),I=j.concat([{begin:/(\s*)\(/,end:/\)/,keywords:f,contains:["self"].concat(j)}]),U={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:I},$={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},Z={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...hT,...pT]}},K={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},D={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[U],illegal:/%/},te={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function le(P){return t.concat("(?!",P.join("|"),")")}const pe={match:t.concat(/\b/,le([...gT,"super","import"].map(P=>`${P}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},Q={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},q={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},U]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",k={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[U]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:f,exports:{PARAMS_CONTAINS:I,CLASS_REFERENCE:Z},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),K,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,N,v,A,C,M,{match:/\$\d+/},g,Z,{scope:"attr",match:r+t.lookahead(":"),relevance:0},k,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[M,e.REGEXP_MODE,{className:"function",begin:F,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:f,contains:I}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:u},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},D,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[U,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},Q,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[U]},pe,te,$,q,{match:/\$[(.]/}]}}function XM(e){const t={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},a={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],o={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[t,a,e.QUOTE_STRING_MODE,o,e.C_NUMBER_MODE,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var Pi="[0-9](_*[0-9])*",dc=`\\.(${Pi})`,fc="[0-9a-fA-F](_*[0-9a-fA-F])*",QM={className:"number",variants:[{begin:`(\\b(${Pi})((${dc})|\\.)?|(${dc}))[eE][+-]?(${Pi})[fFdD]?\\b`},{begin:`\\b(${Pi})((${dc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${dc})[fFdD]?\\b`},{begin:`\\b(${Pi})[fFdD]\\b`},{begin:`\\b0[xX]((${fc})\\.?|(${fc})?\\.(${fc}))[pP][+-]?(${Pi})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${fc})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function WM(e){const t={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},a={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},o={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},u={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},c={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[u,o]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,u,o]}]};o.contains.push(c);const f={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},m={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(c,{className:"string"}),"self"]}]},h=QM,b=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),g={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},y=g;return y.variants[1].contains=[g],g.variants[1].contains=[y],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,b,a,r,f,m,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:t,relevance:5,contains:[{begin:e.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[e.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:t,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[g,e.C_LINE_COMMENT_MODE,b],relevance:0},e.C_LINE_COMMENT_MODE,b,f,m,c,e.C_NUMBER_MODE]},b]},{begin:[/class|interface|trait/,/\s+/,e.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},e.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},f,m]},c,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
493
493
  `},h]}}const ZM=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),JM=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],eD=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],tD=[...JM,...eD],nD=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),bT=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),xT=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),aD=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),sD=bT.concat(xT).sort().reverse();function rD(e){const t=ZM(e),a=sD,r="and or not only",o="[\\w-]+",u="("+o+"|@\\{"+o+"\\})",c=[],f=[],m=function(O){return{className:"string",begin:"~?"+O+".*?"+O}},h=function(O,j,I){return{className:O,begin:j,relevance:I}},b={$pattern:/[a-z-]+/,keyword:r,attribute:nD.join(" ")},g={begin:"\\(",end:"\\)",contains:f,keywords:b,relevance:0};f.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m("'"),m('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,g,h("variable","@@?"+o,10),h("variable","@\\{"+o+"\\}"),h("built_in","~?`[^`]*?`"),{className:"attribute",begin:o+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const y=f.concat({begin:/\{/,end:/\}/,contains:c}),N={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(f)},v={begin:u+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+aD.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:f}}]},A={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:b,returnEnd:!0,contains:f,relevance:0}},C={className:"variable",variants:[{begin:"@"+o+"\\s*:",relevance:15},{begin:"@"+o}],starts:{end:"[;}]",returnEnd:!0,contains:y}},S={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:u,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,N,h("keyword","all\\b"),h("variable","@\\{"+o+"\\}"),{begin:"\\b("+tD.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,h("selector-tag",u,0),h("selector-id","#"+u),h("selector-class","\\."+u,0),h("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+bT.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+xT.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},t.FUNCTION_DISPATCH]},M={begin:o+`:(:)?(${a.join("|")})`,returnBegin:!0,contains:[S]};return c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,A,C,M,v,S,N,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:c}}function iD(e){const t="\\[=*\\[",a="\\]=*\\]",r={begin:t,end:a,contains:["self"]},o=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,a,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:o.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:o}].concat(o)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:a,contains:[r],relevance:5}])}}function lD(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},a={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,a]},o={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},u={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},c={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,a,r,o,u,c]}}function oD(e){const t=e.regex,a={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},o={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},u={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},c={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},f=/[A-Za-z][A-Za-z0-9+.-]*/,m={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,f,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},b={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(h,{contains:[]}),y=e.inherit(b,{contains:[]});h.contains.push(y),b.contains.push(g);let N=[a,m];return[h,b,g,y].forEach(S=>{S.contains=S.contains.concat(N)}),N=N.concat(h,b),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:N},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:N}]}]},a,u,h,b,{className:"quote",begin:"^>\\s+",contains:N,end:"$"},o,r,m,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function uD(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},a=/[a-zA-Z@][a-zA-Z0-9_]*/,f={"variable.language":["this","super"],$pattern:a,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},m={$pattern:a,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:f,illegal:"</",contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+m.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:m,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function cD(e){const t=e.regex,a=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,o={$pattern:/[\w.]+/,keyword:a.join(" ")},u={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:o},c={begin:/->\{/,end:/\}/},f={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},m={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[f]},h={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},b=[e.BACKSLASH_ESCAPE,u,m],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],y=(A,C,S="\\1")=>{const M=S==="\\1"?S:t.concat(S,C);return t.concat(t.concat("(?:",A,")"),C,/(?:\\.|[^\\\/])*?/,M,/(?:\\.|[^\\\/])*?/,S,r)},N=(A,C,S)=>t.concat(t.concat("(?:",A,")"),C,/(?:\\.|[^\\\/])*?/,S,r),v=[m,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),c,{className:"string",contains:b,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},h,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:y("s|tr|y",t.either(...g,{capture:!0}))},{begin:y("s|tr|y","\\(","\\)")},{begin:y("s|tr|y","\\[","\\]")},{begin:y("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:N("(?:m|qr)?",/\//,/\//)},{begin:N("m|qr",t.either(...g,{capture:!0}),/\1/)},{begin:N("m|qr",/\(/,/\)/)},{begin:N("m|qr",/\[/,/\]/)},{begin:N("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,f]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,f,h]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return u.contains=v,c.contains=v,{name:"Perl",aliases:["pl","pm"],keywords:o,contains:v}}function dD(e){const t=e.regex,a=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,a),o=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,a),u=t.concat(/[A-Z]+/,a),c={scope:"variable",match:"\\$+"+r},f={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},m={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},h=e.inherit(e.APOS_STRING_MODE,{illegal:null}),b=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(m)}),g={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(m),"on:begin":(Q,q)=>{q.data._beginMatch=Q[1]||Q[2]},"on:end":(Q,q)=>{q.data._beginMatch!==Q[1]&&q.ignoreMatch()}},y=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),N=`[
@@ -507,6 +507,6 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Kt=ye,yt=Pe),nt===void
507
507
 
508
508
  ---
509
509
 
510
- `),q=async()=>{if(!(!c.trim()||!b)){I(!0);try{await a({name:c.trim(),description:m.trim()||void 0,baseAgent:b,model:y.trim()||void 0,variant:v.trim()||void 0,systemPrompt:C,systemPromptPosition:pe,fragmentIds:le}),u(!1)}finally{I(!1)}}},F=e.isSystem>=1;return o?i.jsxs("section",{className:"rounded-xl border border-blue-500/30 bg-surface p-5 space-y-3",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"编辑配置"}),i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("label",{className:"flex-1",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"名称"}),i.jsx("input",{type:"text",value:c,onChange:k=>f(k.target.value),className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 text-sm text-fg focus:border-blue-500 focus:outline-none"})]}),i.jsxs("label",{className:"w-36",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Base Agent"}),i.jsx("select",{value:b,onChange:k=>g(k.target.value),className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 text-sm text-fg focus:border-blue-500 focus:outline-none",children:jB.map(k=>i.jsx("option",{value:k,children:k},k))})]})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"描述(可选)"}),i.jsx("input",{type:"text",value:m,onChange:k=>h(k.target.value),placeholder:"一句话描述这个 Agent 的用途",className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 text-sm text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"模型(可选)"}),i.jsxs("select",{value:y,onChange:k=>N(k.target.value),className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 font-mono text-sm text-fg focus:border-blue-500 focus:outline-none",children:[i.jsx("option",{value:"",children:"默认模型"}),U.map(k=>i.jsx("option",{value:k.id,children:k.name||k.id},k.id))]})]}),i.jsxs("div",{className:"w-28",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Variant"}),i.jsxs("select",{value:v,onChange:k=>A(k.target.value),className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 font-mono text-sm text-fg focus:border-blue-500 focus:outline-none",children:[i.jsx("option",{value:"",children:"默认"}),i.jsx("option",{value:"max",children:"max"}),i.jsx("option",{value:"high",children:"high"})]})]})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"提示词组合"}),i.jsxs("div",{className:"mt-1.5 space-y-1",children:[Z.map((k,P)=>{if(k===Lr)return i.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2 py-1",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("button",{type:"button",onClick:()=>te(P,-1),disabled:P===0,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▲"}),i.jsx("button",{type:"button",onClick:()=>te(P,1),disabled:P===Z.length-1,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▼"})]}),i.jsx("span",{className:"flex-1 truncate text-xs font-medium text-amber-400",children:"✎ 补充指令"})]},k);const J=t.find(w=>w.id===k);return J?i.jsxs("div",{className:"flex items-center gap-2 rounded border border-blue-500/30 bg-blue-500/5 px-2 py-1",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("button",{type:"button",onClick:()=>te(P,-1),disabled:P===0,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▲"}),i.jsx("button",{type:"button",onClick:()=>te(P,1),disabled:P===Z.length-1,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▼"})]}),i.jsx("span",{className:"flex-1 truncate text-xs text-fg",children:J.name}),i.jsx("button",{type:"button",onClick:()=>D(k),className:"text-fg-5 hover:text-red-400",children:i.jsx(gt,{className:"h-3 w-3"})})]},k):null}),t.filter(k=>!le.includes(k.id)).length>0&&i.jsxs("select",{value:"",onChange:k=>{k.target.value&&D(k.target.value)},className:"w-full rounded border border-dashed border-line bg-base px-2 py-1 text-xs text-fg-4 focus:border-blue-500 focus:outline-none",children:[i.jsx("option",{value:"",children:"+ 添加片段…"}),t.filter(k=>!le.includes(k.id)).map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]})]})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"补充指令内容"}),i.jsx("textarea",{value:C,onChange:k=>S(k.target.value),rows:4,className:"mt-1 w-full resize-y rounded-md border border-line bg-base px-3 py-2 font-mono text-sm leading-relaxed text-fg focus:border-blue-500 focus:outline-none"})]}),(le.length>0||C)&&i.jsxs("div",{children:[i.jsxs("button",{type:"button",onClick:()=>O(!M),className:"flex items-center gap-1 text-xs font-medium text-fg-4 hover:text-fg-3",children:[i.jsx("span",{children:M?"▾":"▸"})," 预览最终提示词"]}),M&&i.jsx("pre",{className:"mt-1 max-h-48 overflow-auto rounded border border-line bg-elevated px-3 py-2 font-mono text-xs leading-relaxed text-fg-4",children:Q||"(空)"})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[i.jsx("button",{type:"button",onClick:()=>u(!1),className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),i.jsx("button",{type:"button",onClick:()=>void q(),disabled:j||!c.trim(),className:"rounded-md bg-blue-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-blue-500 disabled:opacity-40",children:j?"保存中…":"保存"})]})]}):i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"配置"}),!F&&i.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex items-center gap-1 rounded-md border border-line px-2.5 py-1 text-xs text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:[i.jsx(Gh,{className:"h-3 w-3"})," 编辑"]})]}),i.jsxs("div",{className:"mt-3 space-y-2.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 text-fg-5",children:"Base Agent"}),i.jsx("span",{className:"font-mono text-fg",children:e.baseAgent})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 text-fg-5",children:"模型"}),i.jsx("span",{className:"font-mono text-fg",children:e.model||"默认"})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 text-fg-5",children:"Variant"}),i.jsx("span",{className:"font-mono text-fg",children:e.variant||"默认"})]}),e.fragments.length>0&&i.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 pt-0.5 text-fg-5",children:"片段"}),i.jsx("div",{className:"flex flex-wrap gap-1",children:e.fragments.map(k=>i.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-400",children:k.name},k.id))})]}),e.systemPrompt&&i.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 pt-0.5 text-fg-5",children:"补充指令"}),i.jsx("p",{className:"min-w-0 truncate font-mono text-fg-4",children:e.systemPrompt})]})]})]})}function zB(){const{agentId:e}=uy(),t=vn(),a=je(zn),r=or(S=>S.agents),o=r.find(S=>S.id===e),[u,c]=T.useState([]),[f,m]=T.useState(!1),[h,b]=T.useState(!1);T.useEffect(()=>{jy().then(c).catch(()=>c([]))},[]),T.useEffect(()=>{r.length>0&&!o&&t(a?`/${encodeURIComponent(a)}/agents`:"/repos",{replace:!0})},[r,o,t,a]);const g=async S=>{e&&(await eC(e,S),or.getState().loadAgents())},y=async()=>{e&&(await My(e),or.getState().loadAgents(),t(a?`/${encodeURIComponent(a)}/agents`:"/repos",{replace:!0}))},N=async()=>{if(!e||!o)return;const S=await Cx(e),M=new Blob([JSON.stringify(S,null,2)],{type:"application/json"}),O=URL.createObjectURL(M),j=document.createElement("a");j.href=O,j.download=`${o.name.replace(/[^a-zA-Z0-9\u4e00-\u9fff_-]/g,"_")}.json`,j.click(),URL.revokeObjectURL(O)},v=async()=>{if(!e)return;const S=await Cx(e);await navigator.clipboard.writeText(JSON.stringify(S,null,2)),m(!0),setTimeout(()=>m(!1),2e3)};if(!o||!e)return i.jsx("div",{className:"flex flex-1 items-center justify-center",children:i.jsx(ln,{className:"h-5 w-5 fs-spin text-fg-5"})});const A=o.isSystem>=1,C=PB(o.name);return i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("button",{type:"button",onClick:()=>t(a?`/${encodeURIComponent(a)}/agents`:"/repos"),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-line text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:i.jsx(xo,{className:"h-4 w-4"})}),i.jsx("div",{className:ne("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-sm font-semibold",C.bg,C.text),children:C.initial}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h1",{className:"truncate text-lg font-bold text-fg",children:o.name}),A&&i.jsx("span",{className:"shrink-0 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-400",children:"系统"}),o.repoId&&i.jsx("span",{className:"shrink-0 rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-400",children:"repo"})]}),i.jsxs("p",{className:"mt-0.5 text-xs text-fg-4",children:[i.jsx("span",{className:"font-mono",children:o.baseAgent}),o.model&&i.jsxs("span",{className:"ml-1.5 text-fg-5",children:["· ",o.model]})]}),o.description&&i.jsx("p",{className:"mt-1 text-xs text-fg-4",children:o.description})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>void N(),title:"导出 JSON",className:"rounded-md border border-line p-1.5 text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:i.jsx(l3,{className:"h-4 w-4"})}),i.jsx("button",{type:"button",onClick:()=>void v(),title:"复制 JSON",className:"rounded-md border border-line p-1.5 text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:f?i.jsx(On,{className:"h-4 w-4 text-green-500"}):i.jsx(JA,{className:"h-4 w-4"})}),!A&&(h?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{type:"button",onClick:()=>void y(),className:"rounded-md border border-red-500/30 p-1.5 text-red-400 hover:bg-red-500/10",children:i.jsx(On,{className:"h-4 w-4"})}),i.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-md border border-line p-1.5 text-fg-4 hover:bg-elevated",children:i.jsx(gt,{className:"h-4 w-4"})})]}):i.jsx("button",{type:"button",onClick:()=>b(!0),title:"删除",className:"rounded-md border border-line p-1.5 text-fg-4 transition-colors hover:border-red-500/30 hover:text-red-400",children:i.jsx(Cs,{className:"h-4 w-4"})}))]})]}),i.jsx(FB,{agent:o,fragments:u,onSave:g}),i.jsx(UB,{agentId:e}),i.jsx(HB,{agentId:e})]})})}let _s=null;function $B(e){const t=Date.now()-e,a=Math.floor(t/6e4);return a<1?"刚刚":a<60?`${a} 分钟前`:`${Math.floor(a/60)} 小时前`}const qE=[{id:"repos",label:"仓库",icon:xy},{id:"usage",label:"Claude 账号",icon:Qc},{id:"git",label:"Git 源站",icon:ko},{id:"models",label:"模型",icon:bc},{id:"agents",label:"AGENTS.md",icon:zh}],qB={id:"server",label:"服务器",icon:Ay};function kh(e){if(!e)return null;const t=new Date(e).getTime()-Date.now();if(t<=0)return"已重置";const a=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return a>0?`${a}h ${r}m 后重置`:`${r}m 后重置`}function YB(e){return e>=90?"bg-red-500":e>=70?"bg-amber-500":"bg-blue-500"}function Zm({label:e,window:t}){if(!t)return null;const a=Math.round(t.utilization),r=kh(t.resets_at),o=a>=90,u=a>=70;return i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-fg-3",children:e}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r&&i.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:[i.jsx(Vc,{className:"h-2.5 w-2.5"}),r]}),i.jsxs("span",{className:ne("text-sm font-bold leading-none tabular-nums",o?"text-red-400":u?"text-amber-400":"text-fg"),children:[a,"%"]})]})]}),i.jsx("div",{className:"h-2.5 overflow-hidden rounded-full bg-elevated ring-1 ring-inset ring-line/60",children:i.jsx("div",{className:ne("h-full rounded-full transition-all duration-500 ease-out",YB(a),o?"shadow-sm shadow-red-500/50":u?"shadow-sm shadow-amber-500/40":null),style:{width:`${Math.min(a,100)}%`}})})]})}function GB({account:e,onSwitch:t,switching:a}){var o;const r=e.active;return i.jsxs("div",{className:ne("relative overflow-hidden rounded-xl border bg-base p-4 shadow-sm transition-colors",r?"border-blue-500/30 ring-1 ring-inset ring-blue-500/20":"border-line"),children:[r&&i.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1 bg-blue-500"}),i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx("div",{className:ne("flex h-7 w-7 shrink-0 items-center justify-center rounded-lg",r?"bg-blue-500/15 text-blue-500":"bg-elevated text-fg-4"),children:i.jsx(vy,{className:"h-3.5 w-3.5"})}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.label}),r&&i.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:[i.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-blue-500 shadow-sm shadow-blue-500/60"}),"当前"]}),!r&&t&&i.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&&i.jsx(ln,{className:"h-2.5 w-2.5 fs-spin"}),"切换"]}),e.excluded&&i.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:[i.jsx(IA,{className:"h-2.5 w-2.5"}),"不自动切"]}),e.needsReauth&&i.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:[i.jsx(Tn,{className:"h-2.5 w-2.5"}),"需重新登录"]})]}),e.holders&&e.holders.length>0&&i.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-fg-5",children:[i.jsx(Sy,{className:"h-3 w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:e.holders.join(", ")})]}),e.error&&!e.usage?i.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:[i.jsx(Tn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 break-words",children:e.error})]}):e.usage?i.jsxs("div",{className:"mt-4 space-y-3",children:[i.jsx(Zm,{label:"5 小时窗口",window:e.usage.five_hour}),i.jsx(Zm,{label:"7 天窗口",window:e.usage.seven_day}),(o=e.usage.scoped)==null?void 0:o.map(u=>i.jsx(Zm,{label:u.label,window:u},u.label))]}):null]})}function KB(){const[e,t]=T.useState((_s==null?void 0:_s.data)??null),[a,r]=T.useState(!_s),[o,u]=T.useState(null),[c,f]=T.useState(null),[m,h]=T.useState((_s==null?void 0:_s.fetchedAt)??null),[,b]=T.useState(0),g=T.useCallback(A=>{const C=Date.now();_s={data:A,fetchedAt:C},t(A),h(C)},[]),y=T.useCallback(()=>{r(!0),u(null),Py().then(A=>{g(A),r(!1)}).catch(A=>{u(A instanceof Error?A.message:String(A)),r(!1)})},[g]);T.useEffect(()=>{_s||y()},[y]),T.useEffect(()=>{const A=setInterval(()=>b(C=>C+1),3e4);return()=>clearInterval(A)},[]);const N=T.useRef(!1),v=T.useCallback(A=>{N.current||(N.current=!0,f(A),Uy(A).then(C=>{g(C),f(null)}).catch(C=>{u(C instanceof Error?C.message:String(C)),f(null)}).finally(()=>{N.current=!1}))},[g]);return i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-blue-500/10 text-blue-500",children:i.jsx(b3,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Claude 订阅额度"}),i.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"各账号的 Pro/Max 订阅窗口用量。"})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m&&i.jsx("span",{className:"text-[10px] tabular-nums text-fg-5",children:$B(m)}),i.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:i.jsx(zr,{className:ne("h-4 w-4",a&&"fs-spin")})})]})]}),i.jsx("div",{className:"mt-4 space-y-2.5",children:a&&!e?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx(ln,{className:"h-5 w-5 fs-spin"}),i.jsx("p",{className:"text-xs",children:"加载中…"})]}):o&&!e?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-red-400",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-500/10",children:i.jsx(Tn,{className:"h-5 w-5"})}),i.jsx("p",{className:"max-w-xs text-center text-xs leading-relaxed",children:o})]}):e&&e.accounts.length===0?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-elevated text-fg-4",children:i.jsx(Sy,{className:"h-5 w-5"})}),i.jsx("p",{className:"max-w-xs text-center text-xs leading-relaxed",children:"未找到账号。请在 OpenCode TUI 中通过 claude-accounts-usage 插件登录。"})]}):e?e.accounts.map(A=>i.jsx(GB,{account:A,onSwitch:v,switching:c===A.id},A.id)):null})]})}function VB({host:e,onDelete:t}){const[a,r]=T.useState(!1);return i.jsxs("div",{className:"group flex items-center gap-3 rounded-lg border border-line bg-base px-4 py-3",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-medium text-fg",children:e.name}),i.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-4",children:e.platform})]}),i.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-xs text-fg-4",children:[i.jsx("span",{children:e.host}),i.jsx("span",{className:"text-fg-6",children:"·"}),i.jsx("span",{className:"text-fg-5",children:e.token})]})]}),a?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{type:"button",onClick:t,className:"rounded p-1.5 text-red-400 hover:bg-red-500/10",children:i.jsx(On,{className:"h-4 w-4"})}),i.jsx("button",{type:"button",onClick:()=>r(!1),className:"rounded p-1.5 text-fg-4 hover:bg-elevated",children:i.jsx(gt,{className:"h-4 w-4"})})]}):i.jsx("button",{type:"button",onClick:()=>r(!0),className:"rounded p-1.5 text-fg-5 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:i.jsx(Cs,{className:"h-4 w-4"})})]})}function XB({onAdded:e}){const[t,a]=T.useState(!1),[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState(""),[h,b]=T.useState("gitea"),[g,y]=T.useState(!1),[N,v]=T.useState(!1),A=()=>{o(""),c(""),m(""),b("gitea"),a(!1)},C=async()=>{if(!(!r.trim()||!u.trim()||!f.trim())){y(!0);try{await DC(r.trim(),u.trim(),f.trim(),h),A(),e()}finally{y(!1)}}};return t?i.jsxs("div",{className:"space-y-3 rounded-lg border border-line bg-base p-4",children:[i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("label",{className:"flex-1",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"名称"}),i.jsx("input",{type:"text",value:u,onChange:S=>c(S.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"})]}),i.jsxs("label",{className:"w-28",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"平台"}),i.jsxs("select",{value:h,onChange:S=>b(S.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:[i.jsx("option",{value:"gitea",children:"Gitea"}),i.jsx("option",{value:"github",children:"GitHub"}),i.jsx("option",{value:"gitlab",children:"GitLab"})]})]})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Host"}),i.jsx("input",{type:"text",value:r,onChange:S=>o(S.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"})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Token"}),i.jsxs("div",{className:"relative mt-1",children:[i.jsx("input",{type:N?"text":"password",value:f,onChange:S=>m(S.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"}),i.jsx("button",{type:"button",onClick:()=>v(!N),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-fg-5 hover:text-fg-3",children:N?i.jsx(d3,{className:"h-3.5 w-3.5"}):i.jsx(m3,{className:"h-3.5 w-3.5"})})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[i.jsx("button",{type:"button",onClick:A,className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),i.jsx("button",{type:"button",onClick:()=>void C(),disabled:g||!r.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?"保存中…":"保存"})]})]}):i.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:[i.jsx(Ia,{className:"h-3.5 w-3.5"})," 添加 Git 源站"]})}function QB(){const[e,t]=T.useState(""),[a,r]=T.useState(""),[o,u]=T.useState(!0),[c,f]=T.useState(!1),[m,h]=T.useState(null);T.useEffect(()=>{SC().then(y=>{t(y.content),r(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 AC(e),r(e)}catch(y){h(y instanceof Error?y.message:String(y))}f(!1)},g=e!==a;return i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"全局 AGENTS.md"}),i.jsx("p",{className:"mt-1 text-xs text-fg-4",children:"此内容会注入到所有仓库的 Agent 系统指令中。修改后 opencode 热加载,即时生效。"})]}),i.jsxs("button",{type:"button",onClick:()=>void b(),disabled:c||!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:[i.jsx(Xc,{className:"h-3.5 w-3.5"}),c?"保存中…":"保存"]})]}),m&&i.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:[i.jsx(Tn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 break-words",children:m})]}),i.jsx("div",{className:"mt-4",children:o?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx(ln,{className:"h-5 w-5 fs-spin"}),i.jsx("p",{className:"text-xs",children:"加载中…"})]}):i.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
510
+ `),q=async()=>{if(!(!c.trim()||!b)){I(!0);try{await a({name:c.trim(),description:m.trim()||void 0,baseAgent:b,model:y.trim()||void 0,variant:v.trim()||void 0,systemPrompt:C,systemPromptPosition:pe,fragmentIds:le}),u(!1)}finally{I(!1)}}},F=e.isSystem>=1;return o?i.jsxs("section",{className:"rounded-xl border border-blue-500/30 bg-surface p-5 space-y-3",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"编辑配置"}),!F&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("label",{className:"flex-1",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"名称"}),i.jsx("input",{type:"text",value:c,onChange:k=>f(k.target.value),className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 text-sm text-fg focus:border-blue-500 focus:outline-none"})]}),i.jsxs("label",{className:"w-36",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Base Agent"}),i.jsx("select",{value:b,onChange:k=>g(k.target.value),className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 text-sm text-fg focus:border-blue-500 focus:outline-none",children:jB.map(k=>i.jsx("option",{value:k,children:k},k))})]})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"描述(可选)"}),i.jsx("input",{type:"text",value:m,onChange:k=>h(k.target.value),placeholder:"一句话描述这个 Agent 的用途",className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 text-sm text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"})]})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"模型(可选)"}),i.jsxs("select",{value:y,onChange:k=>N(k.target.value),className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 font-mono text-sm text-fg focus:border-blue-500 focus:outline-none",children:[i.jsx("option",{value:"",children:"默认模型"}),U.map(k=>i.jsx("option",{value:k.id,children:k.name||k.id},k.id))]})]}),i.jsxs("div",{className:"w-28",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Variant"}),i.jsxs("select",{value:v,onChange:k=>A(k.target.value),className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-1.5 font-mono text-sm text-fg focus:border-blue-500 focus:outline-none",children:[i.jsx("option",{value:"",children:"默认"}),i.jsx("option",{value:"max",children:"max"}),i.jsx("option",{value:"high",children:"high"})]})]})]}),!F&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"提示词组合"}),i.jsxs("div",{className:"mt-1.5 space-y-1",children:[Z.map((k,P)=>{if(k===Lr)return i.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2 py-1",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("button",{type:"button",onClick:()=>te(P,-1),disabled:P===0,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▲"}),i.jsx("button",{type:"button",onClick:()=>te(P,1),disabled:P===Z.length-1,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▼"})]}),i.jsx("span",{className:"flex-1 truncate text-xs font-medium text-amber-400",children:"✎ 补充指令"})]},k);const J=t.find(w=>w.id===k);return J?i.jsxs("div",{className:"flex items-center gap-2 rounded border border-blue-500/30 bg-blue-500/5 px-2 py-1",children:[i.jsxs("div",{className:"flex flex-col",children:[i.jsx("button",{type:"button",onClick:()=>te(P,-1),disabled:P===0,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▲"}),i.jsx("button",{type:"button",onClick:()=>te(P,1),disabled:P===Z.length-1,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▼"})]}),i.jsx("span",{className:"flex-1 truncate text-xs text-fg",children:J.name}),i.jsx("button",{type:"button",onClick:()=>D(k),className:"text-fg-5 hover:text-red-400",children:i.jsx(gt,{className:"h-3 w-3"})})]},k):null}),t.filter(k=>!le.includes(k.id)).length>0&&i.jsxs("select",{value:"",onChange:k=>{k.target.value&&D(k.target.value)},className:"w-full rounded border border-dashed border-line bg-base px-2 py-1 text-xs text-fg-4 focus:border-blue-500 focus:outline-none",children:[i.jsx("option",{value:"",children:"+ 添加片段…"}),t.filter(k=>!le.includes(k.id)).map(k=>i.jsx("option",{value:k.id,children:k.name},k.id))]})]})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"补充指令内容"}),i.jsx("textarea",{value:C,onChange:k=>S(k.target.value),rows:4,className:"mt-1 w-full resize-y rounded-md border border-line bg-base px-3 py-2 font-mono text-sm leading-relaxed text-fg focus:border-blue-500 focus:outline-none"})]}),(le.length>0||C)&&i.jsxs("div",{children:[i.jsxs("button",{type:"button",onClick:()=>O(!M),className:"flex items-center gap-1 text-xs font-medium text-fg-4 hover:text-fg-3",children:[i.jsx("span",{children:M?"▾":"▸"})," 预览最终提示词"]}),M&&i.jsx("pre",{className:"mt-1 max-h-48 overflow-auto rounded border border-line bg-elevated px-3 py-2 font-mono text-xs leading-relaxed text-fg-4",children:Q||"(空)"})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[i.jsx("button",{type:"button",onClick:()=>u(!1),className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),i.jsx("button",{type:"button",onClick:()=>void q(),disabled:j||!c.trim(),className:"rounded-md bg-blue-600 px-4 py-1.5 text-xs font-medium text-white hover:bg-blue-500 disabled:opacity-40",children:j?"保存中…":"保存"})]})]}):i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"配置"}),i.jsxs("button",{type:"button",onClick:()=>u(!0),className:"flex items-center gap-1 rounded-md border border-line px-2.5 py-1 text-xs text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:[i.jsx(Gh,{className:"h-3 w-3"})," 编辑"]})]}),i.jsxs("div",{className:"mt-3 space-y-2.5",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 text-fg-5",children:"Base Agent"}),i.jsx("span",{className:"font-mono text-fg",children:e.baseAgent})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 text-fg-5",children:"模型"}),i.jsx("span",{className:"font-mono text-fg",children:e.model||"默认"})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 text-fg-5",children:"Variant"}),i.jsx("span",{className:"font-mono text-fg",children:e.variant||"默认"})]}),e.fragments.length>0&&i.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 pt-0.5 text-fg-5",children:"片段"}),i.jsx("div",{className:"flex flex-wrap gap-1",children:e.fragments.map(k=>i.jsx("span",{className:"rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-400",children:k.name},k.id))})]}),e.systemPrompt&&i.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[i.jsx("span",{className:"w-20 shrink-0 pt-0.5 text-fg-5",children:"补充指令"}),i.jsx("p",{className:"min-w-0 truncate font-mono text-fg-4",children:e.systemPrompt})]})]})]})}function zB(){const{agentId:e}=uy(),t=vn(),a=je(zn),r=or(S=>S.agents),o=r.find(S=>S.id===e),[u,c]=T.useState([]),[f,m]=T.useState(!1),[h,b]=T.useState(!1);T.useEffect(()=>{jy().then(c).catch(()=>c([]))},[]),T.useEffect(()=>{r.length>0&&!o&&t(a?`/${encodeURIComponent(a)}/agents`:"/repos",{replace:!0})},[r,o,t,a]);const g=async S=>{e&&(await eC(e,S),or.getState().loadAgents())},y=async()=>{e&&(await My(e),or.getState().loadAgents(),t(a?`/${encodeURIComponent(a)}/agents`:"/repos",{replace:!0}))},N=async()=>{if(!e||!o)return;const S=await Cx(e),M=new Blob([JSON.stringify(S,null,2)],{type:"application/json"}),O=URL.createObjectURL(M),j=document.createElement("a");j.href=O,j.download=`${o.name.replace(/[^a-zA-Z0-9\u4e00-\u9fff_-]/g,"_")}.json`,j.click(),URL.revokeObjectURL(O)},v=async()=>{if(!e)return;const S=await Cx(e);await navigator.clipboard.writeText(JSON.stringify(S,null,2)),m(!0),setTimeout(()=>m(!1),2e3)};if(!o||!e)return i.jsx("div",{className:"flex flex-1 items-center justify-center",children:i.jsx(ln,{className:"h-5 w-5 fs-spin text-fg-5"})});const A=o.isSystem>=1,C=PB(o.name);return i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"mx-auto max-w-3xl space-y-6 p-6",children:[i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx("button",{type:"button",onClick:()=>t(a?`/${encodeURIComponent(a)}/agents`:"/repos"),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-line text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:i.jsx(xo,{className:"h-4 w-4"})}),i.jsx("div",{className:ne("flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-sm font-semibold",C.bg,C.text),children:C.initial}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h1",{className:"truncate text-lg font-bold text-fg",children:o.name}),A&&i.jsx("span",{className:"shrink-0 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-400",children:"系统"}),o.repoId&&i.jsx("span",{className:"shrink-0 rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-medium text-blue-400",children:"repo"})]}),i.jsxs("p",{className:"mt-0.5 text-xs text-fg-4",children:[i.jsx("span",{className:"font-mono",children:o.baseAgent}),o.model&&i.jsxs("span",{className:"ml-1.5 text-fg-5",children:["· ",o.model]})]}),o.description&&i.jsx("p",{className:"mt-1 text-xs text-fg-4",children:o.description})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[i.jsx("button",{type:"button",onClick:()=>void N(),title:"导出 JSON",className:"rounded-md border border-line p-1.5 text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:i.jsx(l3,{className:"h-4 w-4"})}),i.jsx("button",{type:"button",onClick:()=>void v(),title:"复制 JSON",className:"rounded-md border border-line p-1.5 text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:f?i.jsx(On,{className:"h-4 w-4 text-green-500"}):i.jsx(JA,{className:"h-4 w-4"})}),!A&&(h?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{type:"button",onClick:()=>void y(),className:"rounded-md border border-red-500/30 p-1.5 text-red-400 hover:bg-red-500/10",children:i.jsx(On,{className:"h-4 w-4"})}),i.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-md border border-line p-1.5 text-fg-4 hover:bg-elevated",children:i.jsx(gt,{className:"h-4 w-4"})})]}):i.jsx("button",{type:"button",onClick:()=>b(!0),title:"删除",className:"rounded-md border border-line p-1.5 text-fg-4 transition-colors hover:border-red-500/30 hover:text-red-400",children:i.jsx(Cs,{className:"h-4 w-4"})}))]})]}),i.jsx(FB,{agent:o,fragments:u,onSave:g}),i.jsx(UB,{agentId:e}),i.jsx(HB,{agentId:e})]})})}let _s=null;function $B(e){const t=Date.now()-e,a=Math.floor(t/6e4);return a<1?"刚刚":a<60?`${a} 分钟前`:`${Math.floor(a/60)} 小时前`}const qE=[{id:"repos",label:"仓库",icon:xy},{id:"usage",label:"Claude 账号",icon:Qc},{id:"git",label:"Git 源站",icon:ko},{id:"models",label:"模型",icon:bc},{id:"agents",label:"AGENTS.md",icon:zh}],qB={id:"server",label:"服务器",icon:Ay};function kh(e){if(!e)return null;const t=new Date(e).getTime()-Date.now();if(t<=0)return"已重置";const a=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return a>0?`${a}h ${r}m 后重置`:`${r}m 后重置`}function YB(e){return e>=90?"bg-red-500":e>=70?"bg-amber-500":"bg-blue-500"}function Zm({label:e,window:t}){if(!t)return null;const a=Math.round(t.utilization),r=kh(t.resets_at),o=a>=90,u=a>=70;return i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-fg-3",children:e}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[r&&i.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:[i.jsx(Vc,{className:"h-2.5 w-2.5"}),r]}),i.jsxs("span",{className:ne("text-sm font-bold leading-none tabular-nums",o?"text-red-400":u?"text-amber-400":"text-fg"),children:[a,"%"]})]})]}),i.jsx("div",{className:"h-2.5 overflow-hidden rounded-full bg-elevated ring-1 ring-inset ring-line/60",children:i.jsx("div",{className:ne("h-full rounded-full transition-all duration-500 ease-out",YB(a),o?"shadow-sm shadow-red-500/50":u?"shadow-sm shadow-amber-500/40":null),style:{width:`${Math.min(a,100)}%`}})})]})}function GB({account:e,onSwitch:t,switching:a}){var o;const r=e.active;return i.jsxs("div",{className:ne("relative overflow-hidden rounded-xl border bg-base p-4 shadow-sm transition-colors",r?"border-blue-500/30 ring-1 ring-inset ring-blue-500/20":"border-line"),children:[r&&i.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-1 bg-blue-500"}),i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx("div",{className:ne("flex h-7 w-7 shrink-0 items-center justify-center rounded-lg",r?"bg-blue-500/15 text-blue-500":"bg-elevated text-fg-4"),children:i.jsx(vy,{className:"h-3.5 w-3.5"})}),i.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-fg",children:e.label}),r&&i.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:[i.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-blue-500 shadow-sm shadow-blue-500/60"}),"当前"]}),!r&&t&&i.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&&i.jsx(ln,{className:"h-2.5 w-2.5 fs-spin"}),"切换"]}),e.excluded&&i.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:[i.jsx(IA,{className:"h-2.5 w-2.5"}),"不自动切"]}),e.needsReauth&&i.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:[i.jsx(Tn,{className:"h-2.5 w-2.5"}),"需重新登录"]})]}),e.holders&&e.holders.length>0&&i.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[11px] text-fg-5",children:[i.jsx(Sy,{className:"h-3 w-3 shrink-0"}),i.jsx("span",{className:"truncate",children:e.holders.join(", ")})]}),e.error&&!e.usage?i.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:[i.jsx(Tn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 break-words",children:e.error})]}):e.usage?i.jsxs("div",{className:"mt-4 space-y-3",children:[i.jsx(Zm,{label:"5 小时窗口",window:e.usage.five_hour}),i.jsx(Zm,{label:"7 天窗口",window:e.usage.seven_day}),(o=e.usage.scoped)==null?void 0:o.map(u=>i.jsx(Zm,{label:u.label,window:u},u.label))]}):null]})}function KB(){const[e,t]=T.useState((_s==null?void 0:_s.data)??null),[a,r]=T.useState(!_s),[o,u]=T.useState(null),[c,f]=T.useState(null),[m,h]=T.useState((_s==null?void 0:_s.fetchedAt)??null),[,b]=T.useState(0),g=T.useCallback(A=>{const C=Date.now();_s={data:A,fetchedAt:C},t(A),h(C)},[]),y=T.useCallback(()=>{r(!0),u(null),Py().then(A=>{g(A),r(!1)}).catch(A=>{u(A instanceof Error?A.message:String(A)),r(!1)})},[g]);T.useEffect(()=>{_s||y()},[y]),T.useEffect(()=>{const A=setInterval(()=>b(C=>C+1),3e4);return()=>clearInterval(A)},[]);const N=T.useRef(!1),v=T.useCallback(A=>{N.current||(N.current=!0,f(A),Uy(A).then(C=>{g(C),f(null)}).catch(C=>{u(C instanceof Error?C.message:String(C)),f(null)}).finally(()=>{N.current=!1}))},[g]);return i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-blue-500/10 text-blue-500",children:i.jsx(b3,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Claude 订阅额度"}),i.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"各账号的 Pro/Max 订阅窗口用量。"})]})]}),i.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[m&&i.jsx("span",{className:"text-[10px] tabular-nums text-fg-5",children:$B(m)}),i.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:i.jsx(zr,{className:ne("h-4 w-4",a&&"fs-spin")})})]})]}),i.jsx("div",{className:"mt-4 space-y-2.5",children:a&&!e?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx(ln,{className:"h-5 w-5 fs-spin"}),i.jsx("p",{className:"text-xs",children:"加载中…"})]}):o&&!e?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-red-400",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-red-500/10",children:i.jsx(Tn,{className:"h-5 w-5"})}),i.jsx("p",{className:"max-w-xs text-center text-xs leading-relaxed",children:o})]}):e&&e.accounts.length===0?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-elevated text-fg-4",children:i.jsx(Sy,{className:"h-5 w-5"})}),i.jsx("p",{className:"max-w-xs text-center text-xs leading-relaxed",children:"未找到账号。请在 OpenCode TUI 中通过 claude-accounts-usage 插件登录。"})]}):e?e.accounts.map(A=>i.jsx(GB,{account:A,onSwitch:v,switching:c===A.id},A.id)):null})]})}function VB({host:e,onDelete:t}){const[a,r]=T.useState(!1);return i.jsxs("div",{className:"group flex items-center gap-3 rounded-lg border border-line bg-base px-4 py-3",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-medium text-fg",children:e.name}),i.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-4",children:e.platform})]}),i.jsxs("div",{className:"mt-0.5 flex items-center gap-2 font-mono text-xs text-fg-4",children:[i.jsx("span",{children:e.host}),i.jsx("span",{className:"text-fg-6",children:"·"}),i.jsx("span",{className:"text-fg-5",children:e.token})]})]}),a?i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{type:"button",onClick:t,className:"rounded p-1.5 text-red-400 hover:bg-red-500/10",children:i.jsx(On,{className:"h-4 w-4"})}),i.jsx("button",{type:"button",onClick:()=>r(!1),className:"rounded p-1.5 text-fg-4 hover:bg-elevated",children:i.jsx(gt,{className:"h-4 w-4"})})]}):i.jsx("button",{type:"button",onClick:()=>r(!0),className:"rounded p-1.5 text-fg-5 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:i.jsx(Cs,{className:"h-4 w-4"})})]})}function XB({onAdded:e}){const[t,a]=T.useState(!1),[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState(""),[h,b]=T.useState("gitea"),[g,y]=T.useState(!1),[N,v]=T.useState(!1),A=()=>{o(""),c(""),m(""),b("gitea"),a(!1)},C=async()=>{if(!(!r.trim()||!u.trim()||!f.trim())){y(!0);try{await DC(r.trim(),u.trim(),f.trim(),h),A(),e()}finally{y(!1)}}};return t?i.jsxs("div",{className:"space-y-3 rounded-lg border border-line bg-base p-4",children:[i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("label",{className:"flex-1",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"名称"}),i.jsx("input",{type:"text",value:u,onChange:S=>c(S.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"})]}),i.jsxs("label",{className:"w-28",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"平台"}),i.jsxs("select",{value:h,onChange:S=>b(S.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:[i.jsx("option",{value:"gitea",children:"Gitea"}),i.jsx("option",{value:"github",children:"GitHub"}),i.jsx("option",{value:"gitlab",children:"GitLab"})]})]})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Host"}),i.jsx("input",{type:"text",value:r,onChange:S=>o(S.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"})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Token"}),i.jsxs("div",{className:"relative mt-1",children:[i.jsx("input",{type:N?"text":"password",value:f,onChange:S=>m(S.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"}),i.jsx("button",{type:"button",onClick:()=>v(!N),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-fg-5 hover:text-fg-3",children:N?i.jsx(d3,{className:"h-3.5 w-3.5"}):i.jsx(m3,{className:"h-3.5 w-3.5"})})]})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[i.jsx("button",{type:"button",onClick:A,className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),i.jsx("button",{type:"button",onClick:()=>void C(),disabled:g||!r.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?"保存中…":"保存"})]})]}):i.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:[i.jsx(Ia,{className:"h-3.5 w-3.5"})," 添加 Git 源站"]})}function QB(){const[e,t]=T.useState(""),[a,r]=T.useState(""),[o,u]=T.useState(!0),[c,f]=T.useState(!1),[m,h]=T.useState(null);T.useEffect(()=>{SC().then(y=>{t(y.content),r(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 AC(e),r(e)}catch(y){h(y instanceof Error?y.message:String(y))}f(!1)},g=e!==a;return i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"全局 AGENTS.md"}),i.jsx("p",{className:"mt-1 text-xs text-fg-4",children:"此内容会注入到所有仓库的 Agent 系统指令中。修改后 opencode 热加载,即时生效。"})]}),i.jsxs("button",{type:"button",onClick:()=>void b(),disabled:c||!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:[i.jsx(Xc,{className:"h-3.5 w-3.5"}),c?"保存中…":"保存"]})]}),m&&i.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:[i.jsx(Tn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),i.jsx("span",{className:"min-w-0 break-words",children:m})]}),i.jsx("div",{className:"mt-4",children:o?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx(ln,{className:"h-5 w-5 fs-spin"}),i.jsx("p",{className:"text-xs",children:"加载中…"})]}):i.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
511
511
 
512
512
  在此编写全局 Agent 指令…`})}),i.jsx("p",{className:"mt-3 text-[11px] text-fg-5",children:"文件路径:~/.config/opencode/AGENTS.md"})]})}function WB(){const[e,t]=T.useState([]),[a,r]=T.useState(!0),o=()=>{MC().then(c=>{t(c),r(!1)}).catch(()=>r(!1))};T.useEffect(o,[]);const u=async c=>{await LC(c),t(f=>f.filter(m=>m.id!==c))};return i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Git 源站管理"}),i.jsx("p",{className:"mt-1 text-xs text-fg-4",children:"为不同的 Git 托管平台配置访问凭证,用于同步 Issues。系统会根据仓库的 git URL 自动匹配对应的源站。"}),i.jsx("div",{className:"mt-4 space-y-2",children:a?i.jsx("p",{className:"py-4 text-center font-mono text-xs text-fg-5",children:"加载中…"}):i.jsxs(i.Fragment,{children:[e.map(c=>i.jsx(VB,{host:c,onDelete:()=>void u(c.id)},c.id)),i.jsx(XB,{onAdded:o})]})}),i.jsx("p",{className:"mt-4 text-[11px] text-fg-5",children:"Token 存储在数据库中。也可通过环境变量 GITEA_TOKEN 设置全局 fallback。"})]})}const YE="pinned_models";function ZB(e){const t=new Map;for(const a of e){const r=a.providerName||a.providerID,o=t.get(r);o?o.push(a):t.set(r,[a])}return Array.from(t,([a,r])=>({provider:a,models:r})).sort((a,r)=>{const o=a.models.some(c=>c.configured),u=r.models.some(c=>c.configured);return o!==u?o?-1:1:a.provider.localeCompare(r.provider)})}function JB(e){return e?e>=1e6?`${(e/1e6).toFixed(e%1e6===0?0:1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e):""}function eP(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 tP(){const e=je(O=>O.activeRepoId),[t,a]=T.useState([]),[r,o]=T.useState(new Set),[u,c]=T.useState(!0),[f,m]=T.useState(null),[h,b]=T.useState(null),[g,y]=T.useState("");T.useEffect(()=>{let O=!1;async function j(){c(!0),m(null);try{const[I,U]=await Promise.all([Oo(),e?Ro(e):Promise.resolve([])]);if(O)return;const $=I[YE],Z=$?JSON.parse($):[];o(new Set(Z)),a(U),b(null),y("")}catch(I){O||m(I instanceof Error?I.message:String(I))}O||c(!1)}return j(),()=>{O=!0}},[e]);const N=async O=>{const j=new Set(r);j.has(O)?j.delete(O):j.add(O),o(j);try{await rh(YE,JSON.stringify([...j]))}catch{o(r)}},v=T.useMemo(()=>ZB(t),[t]),A=t.filter(O=>r.has(O.id)).length,C=h?v.find(O=>O.provider===h):v[0],S=g.trim().toLowerCase(),M=C?S?C.models.filter(O=>(O.name||O.id).toLowerCase().includes(S)||O.id.toLowerCase().includes(S)):C.models:[];return i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsx("div",{className:"flex items-center justify-between gap-3",children:i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-blue-500/10 text-blue-500",children:i.jsx(bc,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"常用模型"}),i.jsxs("p",{className:"mt-0.5 text-xs text-fg-4",children:["勾选常用模型,在新建对话时快速选择。",A>0&&i.jsxs("span",{className:"ml-1 text-blue-400",children:["已选 ",A," 个"]})]})]})]})}),i.jsx("div",{className:"mt-4",children:e?u?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx(ln,{className:"h-5 w-5 fs-spin"}),i.jsx("p",{className:"text-xs",children:"加载模型列表…"})]}):f?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-red-400",children:[i.jsx(Tn,{className:"h-5 w-5"}),i.jsx("p",{className:"max-w-xs text-center text-xs leading-relaxed",children:f})]}):t.length===0?i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx(bc,{className:"h-5 w-5"}),i.jsx("p",{className:"text-xs",children:"当前仓库没有可用模型。"})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex gap-1 overflow-x-auto rounded-lg border border-line bg-base p-1",children:v.map(O=>{var U;const j=O.provider===(h??((U=v[0])==null?void 0:U.provider)),I=O.models.filter($=>r.has($.id)).length;return i.jsxs("button",{type:"button",onClick:()=>{b(O.provider),y("")},className:ne("flex shrink-0 items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",j?"bg-surface text-fg shadow-sm":"text-fg-4 hover:text-fg-3"),children:[O.provider,I>0&&i.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:I})]},O.provider)})}),i.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-md border border-line bg-base px-3 py-1.5",children:[i.jsx(Pr,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),i.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&&i.jsx("button",{type:"button",onClick:()=>y(""),className:"text-fg-5 hover:text-fg-3",children:i.jsx(gt,{className:"h-3 w-3"})})]}),i.jsx("div",{className:"mt-3 rounded-lg border border-line bg-base",children:M.length===0?i.jsx("div",{className:"px-3 py-6 text-center text-xs text-fg-5",children:"无匹配模型"}):i.jsx("div",{className:"divide-y divide-line/40",children:M.map(O=>{const j=r.has(O.id),I=JB(O.contextLimit),U=eP(O.cost);return i.jsxs("label",{className:ne("flex cursor-pointer items-center gap-3 px-3 py-2 transition-colors hover:bg-elevated/60",j&&"bg-blue-500/5"),children:[i.jsx("input",{type:"checkbox",checked:j,onChange:()=>void N(O.id),className:"h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-line accent-blue-500"}),i.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-fg",children:O.name||O.id}),i.jsxs("span",{className:"flex shrink-0 items-center gap-2",children:[I&&i.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5 text-[10px] text-fg-5",children:I}),U&&i.jsx("span",{className:"text-[10px] text-fg-6",children:U})]})]},O.id)})})})]}):i.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-10 text-fg-5",children:[i.jsx(bc,{className:"h-5 w-5"}),i.jsx("p",{className:"text-xs",children:"请先在左侧选择一个仓库以加载可用模型。"})]})})]})}function nP(){const[e,t]=T.useState(sh),[a,r]=T.useState(!1),[o,u]=T.useState(null),[c,f]=T.useState(sh),m=e!==c,h=async()=>{const g=e.replace(/\/+$/,"");if(g){r(!0),u(null);try{const y=await fetch(`${g}/api/health`,{signal:AbortSignal.timeout(5e3)});u(y.ok?"ok":"fail")}catch{u("fail")}r(!1)}},b=()=>{const g=e.replace(/\/+$/,"");S5(g),f(g),t(g)};return i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-blue-500/10 text-blue-500",children:i.jsx(Ay,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"服务器连接"}),i.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"配置远程 Fourth Spark Server 地址。"})]})]}),i.jsxs("div",{className:"mt-4 space-y-3",children:[i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"服务器地址"}),i.jsx("input",{type:"url",value:e,onChange:g=>{t(g.target.value),u(null)},placeholder:"http://192.168.1.100:3000",className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-2 font-mono text-sm text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>void h(),disabled:a||!e.trim(),className:"flex items-center gap-1.5 rounded-md border border-line px-3 py-1.5 text-xs font-medium text-fg-3 transition-colors hover:bg-elevated disabled:opacity-40",children:[a?i.jsx(ln,{className:"h-3.5 w-3.5 fs-spin"}):i.jsx(zr,{className:"h-3.5 w-3.5"}),"测试连接"]}),i.jsxs("button",{type:"button",onClick:b,disabled:!m,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:[i.jsx(Xc,{className:"h-3.5 w-3.5"}),"保存"]}),o==="ok"&&i.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-green-500",children:[i.jsx(On,{className:"h-3.5 w-3.5"})," 连接成功"]}),o==="fail"&&i.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-red-400",children:[i.jsx(Tn,{className:"h-3.5 w-3.5"})," 连接失败"]})]})]}),i.jsx("p",{className:"mt-4 text-[11px] text-fg-5",children:"保存后需重新打开 App 生效。确保手机与开发机在同一局域网。"})]})}function aP(){const[e,t]=T.useState("local"),[a,r]=T.useState(!1),[o,u]=T.useState(!1);T.useEffect(()=>{ih().then(f=>{const m=f.mode==="worker";r(m),t(m?"cloud":"local")}).catch(()=>{}).finally(()=>u(!0))},[]);const c=T.useCallback(f=>{const m=f.mode==="worker";r(m),m&&t("cloud")},[]);return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex gap-1 rounded-lg border border-line bg-base p-1",children:[i.jsxs("button",{type:"button",onClick:()=>{a||t("local")},disabled:a,className:ne("flex flex-1 items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",e==="local"?"bg-surface text-fg shadow-sm":"text-fg-4 hover:text-fg-3",a&&e!=="local"&&"cursor-not-allowed opacity-40"),title:a?"需先断开账号池连接":void 0,children:[i.jsx(Qc,{className:"h-3.5 w-3.5"}),"本地模式"]}),i.jsxs("button",{type:"button",onClick:()=>t("cloud"),className:ne("flex flex-1 items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",e==="cloud"?"bg-surface text-fg shadow-sm":"text-fg-4 hover:text-fg-3"),children:[i.jsx(yy,{className:"h-3.5 w-3.5"}),"账号池"]})]}),o&&e==="local"&&i.jsx(KB,{}),o&&e==="cloud"&&i.jsx(rP,{onStatusChange:c})]})}function sP({onClose:e,onSwitched:t}){const[a,r]=T.useState([]),[o,u]=T.useState(!0),[c,f]=T.useState(null),[m,h]=T.useState(null);T.useEffect(()=>{Py().then(N=>r(N.accounts)).catch(()=>{}).finally(()=>u(!1))},[]);const b=async N=>{f(N),h(null);try{await Uy(N),t(),e()}catch(v){const A=v instanceof Error?v.message:String(v);h(A||"切换失败"),f(null)}},g=N=>{var v;return(v=N.usage)==null?void 0:v.five_hour},y=N=>{var v;return(v=N.usage)==null?void 0:v.seven_day};return i.jsx("div",{className:"fixed inset-0 z-50 flex items-end justify-center bg-black/50 backdrop-blur-sm sm:items-center",onClick:e,children:i.jsxs("div",{className:"flex max-h-[85vh] w-full flex-col rounded-t-2xl border border-line bg-surface p-4 shadow-2xl sm:mx-4 sm:max-w-lg sm:rounded-xl sm:p-5",onClick:N=>N.stopPropagation(),children:[i.jsxs("div",{className:"flex shrink-0 items-center justify-between",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"切换账号"}),i.jsx("button",{type:"button",onClick:e,className:"rounded-md p-1 text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:i.jsx(gt,{className:"h-4 w-4"})})]}),o?i.jsx("div",{className:"flex items-center justify-center py-10",children:i.jsx(ln,{className:"h-5 w-5 fs-spin text-fg-4"})}):a.length===0?i.jsx("p",{className:"py-10 text-center text-xs text-fg-4",children:"暂无可用账号"}):i.jsx("div",{className:"mt-3 min-h-0 flex-1 space-y-1.5 overflow-y-auto pb-[var(--safe-bottom)]",children:a.map(N=>i.jsxs("button",{type:"button",disabled:c!==null,onClick:()=>{N.active||b(N.id)},className:ne("flex w-full items-center gap-2 rounded-lg border px-3 py-2.5 text-left transition-colors sm:gap-3",N.active?"border-blue-500/40 bg-blue-500/5":"border-line hover:bg-elevated",c===N.id&&"opacity-60"),children:[i.jsx("div",{className:"min-w-0 flex-1",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"truncate text-xs font-medium text-fg",children:N.label}),N.active&&i.jsx("span",{className:"rounded bg-blue-500/15 px-1.5 py-0.5 text-[9px] font-semibold text-blue-500",children:"当前"}),c===N.id&&i.jsx(ln,{className:"h-3 w-3 fs-spin text-blue-500"})]})}),i.jsxs("div",{className:"flex shrink-0 gap-2 text-right sm:gap-4",children:[i.jsxs("div",{className:"w-14 sm:w-20",children:[i.jsx("div",{className:"text-[10px] text-fg-5",children:"5h"}),g(N)?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ne("text-xs font-medium",g(N).utilization>80?"text-red-400":"text-fg-3"),children:[Math.round(g(N).utilization),"%"]}),i.jsx("div",{className:"hidden text-[9px] text-fg-5 sm:block",children:g(N).resets_at?kh(g(N).resets_at):""})]}):i.jsx("div",{className:"text-[10px] text-fg-5",children:"—"})]}),i.jsxs("div",{className:"w-14 sm:w-20",children:[i.jsx("div",{className:"text-[10px] text-fg-5",children:"7d"}),y(N)?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:ne("text-xs font-medium",y(N).utilization>80?"text-red-400":"text-fg-3"),children:[Math.round(y(N).utilization),"%"]}),i.jsx("div",{className:"hidden text-[9px] text-fg-5 sm:block",children:y(N).resets_at?kh(y(N).resets_at):""})]}):i.jsx("div",{className:"text-[10px] text-fg-5",children:"—"})]})]})]},N.id))}),m&&i.jsxs("div",{className:"mt-3 flex shrink-0 items-center gap-1.5 rounded-md border border-red-400/30 bg-red-400/5 px-3 py-2",children:[i.jsx(Tn,{className:"h-3.5 w-3.5 shrink-0 text-red-400"}),i.jsx("span",{className:"text-xs text-red-400",children:m})]})]})})}function rP({onStatusChange:e}){const[t,a]=T.useState(""),[r,o]=T.useState(""),[u,c]=T.useState(""),[f,m]=T.useState(""),[h,b]=T.useState(!1),[g,y]=T.useState(null),[N,v]=T.useState(!1),[A,C]=T.useState(null),[S,M]=T.useState(!1);T.useEffect(()=>{let K=!1;return(async()=>{const[D,te]=await Promise.all([Oo().catch(()=>({})),ih().catch(()=>null)]);if(K)return;const le=D.cloud_master_url??"",pe=D.cloud_worker_id||(te==null?void 0:te.defaultWorkerId)||"";a(le),c(le),o(pe),m(D.cloud_worker_id??""),C(te)})(),()=>{K=!0}},[]);const j=((A==null?void 0:A.mode)??(u?"worker":"local"))==="worker",I=!j&&!!t.trim()&&!!r.trim(),U=t!==u||r!==f||I,$=async()=>{const K=t.replace(/\/+$/,"");if(!K)return;b(!0),y(null);const D=await IC(K);y(D?"ok":"fail"),b(!1)},Z=async()=>{const K=t.replace(/\/+$/,""),D=r.trim();v(!0);try{await rh("cloud_master_url",K),await rh("cloud_worker_id",D),c(K),m(D),a(K),o(D);const te=await OC().catch(()=>null);te&&(C(te),e==null||e(te))}finally{v(!1)}};return i.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[i.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[i.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-blue-500/10 text-blue-500",children:i.jsx(yy,{className:"h-4 w-4"})}),i.jsxs("div",{className:"min-w-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg",children:"账号池配置"}),i.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"连接 claude-accounts-pool Master,共享多账号池。"})]})]}),i.jsxs("div",{className:"mt-4 space-y-2",children:[i.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-line bg-base px-3 py-2",children:[i.jsx("span",{className:ne("h-2 w-2 shrink-0 rounded-full",j?"bg-blue-500 shadow-sm shadow-blue-500/60":"bg-green-500 shadow-sm shadow-green-500/60")}),i.jsx("span",{className:"text-xs font-medium text-fg-3",children:j?"Worker 模式":"本地模式"}),j&&(A==null?void 0:A.workerId)&&i.jsx("span",{className:"rounded bg-elevated px-1.5 py-0.5 font-mono text-[10px] text-fg-4",children:A.workerId}),j&&(A==null?void 0:A.connected)!=null&&i.jsx("span",{className:ne("ml-auto text-[10px] font-medium",A.connected?"text-green-500":"text-red-400"),children:A.connected?"已连接":"未连接"})]}),j&&(A==null?void 0:A.heldAccount)&&i.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-line bg-base px-3 py-2",children:[i.jsx(vy,{className:"h-3.5 w-3.5 shrink-0 text-blue-500"}),i.jsx("span",{className:"text-xs text-fg-4",children:"当前账号"}),i.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-fg",children:A.heldAccount.label}),i.jsx("button",{type:"button",onClick:()=>M(!0),className:"ml-auto rounded-md border border-line px-2 py-0.5 text-[10px] font-medium text-fg-4 transition-colors hover:bg-elevated hover:text-fg-3",children:"切换账号"})]})]}),i.jsxs("div",{className:"mt-4 space-y-3",children:[i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Master URL"}),i.jsx("input",{type:"url",value:t,onChange:K=>{a(K.target.value),y(null)},placeholder:"http://100.64.0.36:8787",className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-2 font-mono text-sm text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"})]}),i.jsxs("label",{className:"block",children:[i.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Worker ID"}),i.jsx("input",{type:"text",value:r,onChange:K=>o(K.target.value),placeholder:"fourth-spark-1",className:"mt-1 w-full rounded-md border border-line bg-base px-3 py-2 font-mono text-sm text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"}),i.jsx("span",{className:"mt-1 block text-[11px] text-fg-5",children:"此 Worker 在账号池中的唯一标识,建议用小写字母、数字和连字符。"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{type:"button",onClick:()=>void $(),disabled:h||!t.trim(),className:"flex items-center gap-1.5 rounded-md border border-line px-3 py-1.5 text-xs font-medium text-fg-3 transition-colors hover:bg-elevated disabled:opacity-40",children:[h?i.jsx(ln,{className:"h-3.5 w-3.5 fs-spin"}):i.jsx(zr,{className:"h-3.5 w-3.5"}),"测试连接"]}),i.jsxs("button",{type:"button",onClick:()=>void Z(),disabled:!U||N,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:[i.jsx(Xc,{className:"h-3.5 w-3.5"}),N?"保存中…":"保存"]}),g==="ok"&&i.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-green-500",children:[i.jsx(On,{className:"h-3.5 w-3.5"})," 连接成功"]}),g==="fail"&&i.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-red-400",children:[i.jsx(Tn,{className:"h-3.5 w-3.5"})," 连接失败"]})]})]}),i.jsx("p",{className:"mt-4 text-[11px] text-fg-5",children:"清空 Master URL 可切回本地模式。"}),S&&i.jsx(sP,{onClose:()=>M(!1),onSwitched:async()=>{const K=await ih().catch(()=>null);K&&(C(K),e==null||e(K))}})]})}function iP(){const[e,t]=T.useState("usage"),a=T.useMemo(()=>ky()||sh()?[...qE,qB]:qE,[]);return i.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:i.jsxs("div",{className:ne("mx-auto",e==="repos"?"max-w-4xl":"max-w-2xl"),children:[i.jsx("h1",{className:"text-lg font-semibold text-fg",children:"设置"}),i.jsx("p",{className:"mt-0.5 text-sm text-fg-4",children:"全局配置"}),i.jsx("div",{className:"mt-6 flex gap-1 overflow-x-auto rounded-lg border border-line bg-surface p-1 scrollbar-none",children:a.map(r=>i.jsxs("button",{type:"button",onClick:()=>t(r.id),className:ne("flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap rounded-md px-3 py-1.5 text-xs font-medium transition-colors",e===r.id?"bg-base text-fg shadow-sm":"text-fg-4 hover:text-fg-3"),children:[i.jsx(r.icon,{className:"h-3.5 w-3.5"}),r.label]},r.id))}),i.jsxs("div",{className:"mt-4",children:[e==="repos"&&i.jsx($y,{}),e==="usage"&&i.jsx(aP,{}),e==="git"&&i.jsx(WB,{}),e==="models"&&i.jsx(tP,{}),e==="agents"&&i.jsx(QB,{}),e==="server"&&i.jsx(nP,{})]})]})})}const lP=300,oP=4e3,uP={info:{icon:"ℹ",badge:"bg-fg/10 text-fg-2",bar:"bg-fg-4"},success:{icon:"✓",badge:"bg-emerald-500/10 text-emerald-500",bar:"bg-emerald-500"},warning:{icon:"⚠",badge:"bg-amber-500/10 text-amber-500",bar:"bg-amber-500"},error:{icon:"✕",badge:"bg-red-500/10 text-red-500",bar:"bg-red-500"}};function cP(){const e=Qt(h=>h.toasts),t=Qt(h=>h.removeToast),a=Re(h=>h.setActiveSession),r=je(zn),o=vn(),u=h=>{t(h.id),h.sessionId&&(a(h.sessionId),o(`/${encodeURIComponent(r)}/run`))},[c,f]=T.useState([]),m=T.useRef(new Map);return T.useEffect(()=>{const h=new Set(e.map(b=>b.id));f(b=>{let g=b.map(y=>h.has(y.id)||y.exiting?y:{...y,exiting:!0});for(const y of e)g.some(N=>N.id===y.id)||(g=[...g,{...y}]);return g})},[e]),T.useEffect(()=>{const h=m.current;for(const b of c)b.exiting&&!h.has(b.id)&&h.set(b.id,setTimeout(()=>{h.delete(b.id),f(g=>g.filter(y=>y.id!==b.id))},lP))},[c]),T.useEffect(()=>{const h=m.current;return()=>h.forEach(clearTimeout)},[]),c.length===0?null:i.jsx("div",{className:"pointer-events-none fixed top-4 right-4 z-50 flex w-[calc(100%-2rem)] max-w-sm flex-col","aria-live":"polite","aria-atomic":"false",children:c.map(h=>{const b=uP[h.variant];return i.jsx("div",{className:"grid w-full transition-[grid-template-rows] duration-300 ease-out",style:{gridTemplateRows:h.exiting?"0fr":"1fr"},children:i.jsx("div",{className:"min-h-0 overflow-hidden",children:i.jsxs("div",{role:"status",onClick:()=>u(h),style:{animation:`${h.exiting?"toast-out":"toast-in"} 0.3s ease-out forwards`},className:"pointer-events-auto relative mb-2 flex cursor-pointer items-start gap-3 overflow-hidden rounded-xl border border-line bg-surface/80 px-3.5 py-3 shadow-lg shadow-black/5 backdrop-blur-md transition-colors hover:border-line-hard hover:bg-surface/90",children:[i.jsx("span",{"aria-hidden":!0,className:`mt-px flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-xs font-semibold ${b.badge}`,children:b.icon}),i.jsx("p",{className:"min-w-0 flex-1 text-sm leading-snug break-words text-fg",children:h.message}),h.persistent&&!h.exiting&&i.jsx("button",{type:"button","aria-label":"关闭",onClick:g=>{g.stopPropagation(),t(h.id)},className:"mt-px flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-fg-4 transition-colors hover:bg-fg/10 hover:text-fg",children:"✕"}),!h.exiting&&!h.persistent&&i.jsx("span",{"aria-hidden":!0,className:`absolute bottom-0 left-0 h-0.5 w-full origin-left ${b.bar}`,style:{animation:`toast-progress ${oP}ms linear forwards`}})]})})},h.id)})})}const io=Po("PushNotifications",{});let GE=!1;async function dP(e){!ky()||GE||(GE=!0,(await io.requestPermissions()).receive!=="granted")||(io.addListener("registration",async a=>{try{await jC(a.value,"ios")}catch{}}),io.addListener("registrationError",()=>{}),io.addListener("pushNotificationActionPerformed",a=>{const r=a.notification.data,o=r==null?void 0:r.sessionId;if(o){const u=zn(je.getState());u&&e(`/${encodeURIComponent(u)}/run?session=${o}`)}}),await io.register())}function fP(e){const t=e.match(/^\/([^/]+)\/(run|agents|issues|pulls|dev)/);return t?decodeURIComponent(t[1]):null}function mP(){const e=je(r=>r.repos),a=je(zn)??(e.length>0?e[0].name:null);return a?i.jsx(Fi,{to:`/${encodeURIComponent(a)}/run`,replace:!0}):i.jsx(Fi,{to:"/repos",replace:!0})}function KE({segment:e}){const{repoId:t}=uy(),{search:a}=_n();return t?i.jsx(Fi,{to:`/${encodeURIComponent(t)}/dev/${e}${a}`,replace:!0}):i.jsx(Fi,{to:"/repos",replace:!0})}function hP(){const e=vn(),t=_n(),a=je(f=>f.activeRepoId),r=je(f=>f.repos),o=je(f=>f.setActiveRepo),u=Re(f=>f.loadSessions),c=Re(f=>f.clearSessions);return T.useEffect(()=>(je.getState().loadRepos(),dP(e),ah.getState().init()),[e]),T.useEffect(()=>{if(r.length===0)return;const f=fP(t.pathname);if(!f)return;const m=r.find(h=>h.name===f);m&&m.id!==je.getState().activeRepoId&&o(m.id)},[t.pathname,r,o]),T.useEffect(()=>(a?(c(),Ve.getState().clearIssues(),mn.getState().clearPulls(),u(),or.getState().loadAgents(),Ve.getState().loadIssues(),mn.getState().loadPulls(),Lc.start(a)):(c(),Ve.getState().clearIssues(),mn.getState().clearPulls()),()=>Lc.stop()),[a,u,c]),i.jsxs(i.Fragment,{children:[i.jsx(PS,{children:i.jsxs(na,{element:i.jsx(qC,{}),children:[i.jsx(na,{path:"/repos",element:i.jsx(XC,{})}),i.jsx(na,{path:"/settings",element:i.jsx(iP,{})}),i.jsx(na,{path:"/:repoId/run",element:i.jsx(WL,{})}),i.jsx(na,{path:"/:repoId/agents",element:i.jsx(LB,{})}),i.jsx(na,{path:"/:repoId/agents/:agentId",element:i.jsx(zB,{})}),i.jsx(na,{path:"/:repoId/dev",element:i.jsx(Fi,{to:"issues",replace:!0})}),i.jsx(na,{path:"/:repoId/dev/issues",element:i.jsx(UE,{})}),i.jsx(na,{path:"/:repoId/dev/pulls",element:i.jsx(UE,{})}),i.jsx(na,{path:"/:repoId/issues",element:i.jsx(KE,{segment:"issues"})}),i.jsx(na,{path:"/:repoId/pulls",element:i.jsx(KE,{segment:"pulls"})}),i.jsx(na,{path:"/:repoId",element:i.jsx(Fi,{to:"run",replace:!0})}),i.jsx(na,{path:"*",element:i.jsx(mP,{})})]})}),i.jsx(cP,{})]})}function pP(){return i.jsx(uA,{children:i.jsx(hP,{})})}const T_=document.getElementById("root");if(!T_)throw new Error("Root element #root not found in index.html");jv.createRoot(T_).render(i.jsx(T.StrictMode,{children:i.jsx(pP,{})}));export{hp as W};