fourth-spark 0.11.22 → 0.11.24

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.
@@ -512,10 +512,10 @@ Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}
512
512
  *
513
513
  * This source code is licensed under the ISC license.
514
514
  * See the LICENSE file in the root directory of this source tree.
515
- */const oz=[["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"}]],hc=Re("zap",oz);function II(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=II(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function re(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=II(e))&&(r&&(r+=" "),r+=t);return r}const t2=e=>{let t;const n=new Set,r=(f,m)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const b=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(x=>x(t,b))}},a=()=>t,c={setState:r,getState:a,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f))},d=t=e(r,a,c);return c},lz=(e=>e?t2(e):t2),uz=e=>e;function cz(e,t=uz){const n=Yd.useSyncExternalStore(e.subscribe,Yd.useCallback(()=>t(e.getState()),[e,t]),Yd.useCallback(()=>t(e.getInitialState()),[e,t]));return Yd.useDebugValue(n),n}const n2=e=>{const t=lz(e),n=r=>cz(t,r);return Object.assign(n,t),n},ai=(e=>e?n2(e):n2),zx="fs-theme";function RI(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function r2(e){return e==="system"?RI():e}function a2(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const sv=ai((e,t)=>({preference:localStorage.getItem(zx)??"system",resolved:r2(localStorage.getItem(zx)??"system"),cycle(){const n=["system","light","dark"],r=n[(n.indexOf(t().preference)+1)%n.length],a=r2(r);localStorage.setItem(zx,r),a2(r),e({preference:r,resolved:a})},init(){a2(t().preference);const n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{const{preference:a}=t();if(a==="system"){const s=RI();e({resolved:s})}};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}})),mp="fourth-spark-server-url";function dz(){if(typeof window>"u")return!1;const t=window.Capacitor;return typeof(t==null?void 0:t.isNativePlatform)=="function"&&t.isNativePlatform()}function H1(){return localStorage.getItem(mp)??""}function fz(e){const t=e.replace(/\/+$/,"");t?localStorage.setItem(mp,t):localStorage.removeItem(mp)}function ov(){return localStorage.getItem(mp)??""}class ss extends Error{constructor(n,r){super(n);kt(this,"status");this.name="ApiError",this.status=r}}async function Ce(e,t){let n;try{n=await fetch(H1()+e,{...t,headers:{Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers}})}catch(a){throw new ss(a instanceof Error?a.message:"Network request failed",0)}if(!n.ok){const a=await n.text().catch(()=>"");throw new ss(a.trim()||`${n.status} ${n.statusText}`,n.status)}if(n.status===204)return;const r=await n.text();if(r)return JSON.parse(r)}function na(e,...t){if(Array.isArray(e))return e;if(e&&typeof e=="object"){const n=e;for(const r of[...t,"data","items"])if(Array.isArray(n[r]))return n[r]}return[]}async function hz(){return na(await Ce("/api/repos"),"repos")}async function mz(e,t,n,r){return Ce("/api/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,localPath:n,runtimeType:r})})}async function pz(e){return Ce("/api/repos/resolve",{method:"POST",body:JSON.stringify({localPath:e})})}async function gz(e,t){return Ce("/api/fs/browse",{method:"POST",body:JSON.stringify({path:e,showHidden:t})})}async function bz(e,t){return Ce("/api/repos/clone",{method:"POST",body:JSON.stringify({gitUrl:e,targetDir:t})})}async function xz(e){await Ce(`/api/repos/${encodeURIComponent(e)}`,{method:"DELETE"})}async function yz(e){await Ce(`/api/repos/${encodeURIComponent(e)}/start`,{method:"POST"})}async function vz(e){await Ce(`/api/repos/${encodeURIComponent(e)}/stop`,{method:"POST"})}async function Ez(e){return Ce(`/api/repos/${encodeURIComponent(e)}/branches`)}async function Nz(e,t){return Ce(`/api/repos/${encodeURIComponent(e)}/checkout`,{method:"POST",body:JSON.stringify({branch:t})})}async function _z(e){return Ce(`/api/repos/${encodeURIComponent(e)}/pull`,{method:"POST"})}function et(e){return`/api/repos/${encodeURIComponent(e)}`}async function Sz(e){return na(await Ce(`${et(e)}/workspaces`),"workspaces")}async function Tz(e,t){await Ce(`${et(e)}/workspaces/${encodeURIComponent(t)}`,{method:"DELETE"})}async function wz(e){return Ce(`${et(e)}/workspaces/cleanup`,{method:"POST"})}async function Az(e,t){await Ce(`/api/repos/${e}/worktree`,{method:"PATCH",body:JSON.stringify({enabled:t})})}async function Cz(e,t){await Ce(`/api/repos/${e}/runtime`,{method:"PATCH",body:JSON.stringify({runtimeType:t})})}async function kz(e){return na(await Ce(`${et(e)}/sessions`),"sessions")}async function Oz(e,t,n,r,a,s,o,c){return Ce(`${et(e)}/sessions`,{method:"POST",body:JSON.stringify({message:t,agent:n,model:r,variant:a,issueId:s,customAgentId:o,files:c})})}async function Iz(e,t){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Rz(e,t,n,r,a,s,o){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/prompt`,{method:"POST",body:JSON.stringify({content:n,agent:r,model:a,variant:s,files:o})})}async function Mz(e,t){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/abort`,{method:"POST"})}async function jz(e,t,n){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/questions/reply`,{method:"POST",body:JSON.stringify({answers:n})})}async function Dz(e,t){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/questions/reject`,{method:"POST"})}async function Lz(e,t,n){return Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/revert`,{method:"POST",body:JSON.stringify({messageID:n})})}function i2(e){const t=e,n=t.info;if(n&&typeof n.id=="string"){const r=Array.isArray(t.parts)?t.parts:void 0;return{...n,...r?{parts:r}:{}}}return t}async function s2(e,t,n){const r=new URLSearchParams;n!=null&&n.limit&&r.set("limit",String(n.limit)),n!=null&&n.before&&r.set("before",n.before);const a=r.toString(),s=`${et(e)}/sessions/${encodeURIComponent(t)}/messages${a?`?${a}`:""}`,o=await Ce(s);if(Array.isArray(o)){const f=o.map(i2);return{messages:f,total:f.length,hasMore:!1}}const c=o,d=Array.isArray(c.messages)?c.messages:[];return{messages:d.map(i2),total:c.total??d.length,hasMore:c.hasMore??!1}}async function Pz(e,t){return Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/status`)}async function Bz(e,t){return Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/links`)}async function Uz(e,t){return Ce(`${et(e)}/sessions/snapshot/${encodeURIComponent(t)}`)}async function MI(e){return Ce(`${et(e)}/sessions/all-links`)}async function Fz(e,t,n,r){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"POST",body:JSON.stringify({type:n,targetId:r})})}async function zz(e,t,n,r){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"DELETE",body:JSON.stringify({type:n,targetId:r})})}async function jI(){return na(await Ce("/api/custom-agents"))}async function Hz(e){return Ce("/api/custom-agents",{method:"POST",body:JSON.stringify(e)})}async function $z(e,t){return Ce(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function DI(e){await Ce(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"DELETE"})}async function o2(e){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/export`)}async function Yz(e){return Ce("/api/custom-agents/import",{method:"POST",body:JSON.stringify(e)})}async function LI(e,t){const n=new URLSearchParams;t!=null&&t.category&&n.set("category",t.category),t!=null&&t.includeSuperseded&&n.set("includeSuperseded","true");const r=n.toString();return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories${r?`?${r}`:""}`)}async function qz(e,t,n){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)})}async function Gz(e,t){await Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Kz(e,t){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/extract`,{method:"POST",body:JSON.stringify({sessionIds:t})})}async function l2(e){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/stats`)}async function Vz(e){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/consolidate`,{method:"POST"})}async function $1(e){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/sessions`)}async function PI(e){return na(await Ce(`${et(e)}/custom-agents`))}async function Wz(e,t){return Ce(`${et(e)}/custom-agents`,{method:"POST",body:JSON.stringify(t)})}async function Df(e){return na(await Ce(`${et(e)}/models`))}async function BI(){return na(await Ce("/api/prompt-fragments"))}async function Xz(e){return Ce("/api/prompt-fragments",{method:"POST",body:JSON.stringify(e)})}async function Qz(e,t){return Ce(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function Zz(e){await Ce(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"DELETE"})}async function u2(e){return na(await Ce(`${et(e)}/tags`))}async function c2(e,t){return na(await Ce(`${et(e)}/milestones`))}async function d2(e,t="open"){return na(await Ce(`${et(e)}/issues?state=${encodeURIComponent(t)}`),"issues")}async function Jz(e,t="all"){return Ce(`${et(e)}/issues/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function eH(e,t,n){return Ce(`${et(e)}/issues`,{method:"POST",body:JSON.stringify({title:t,body:n})})}async function tH(e,t,n){await Ce(`${et(e)}/issues/${t}/children`,{method:"POST",body:JSON.stringify({childNumber:n})})}async function UI(e,t,n){return Ce(`${et(e)}/issues/${t}`,{method:"PATCH",body:JSON.stringify(n)})}async function nH(e,t){return na(await Ce(`${et(e)}/issues/${t}/pulls`))}async function f2(e,t="open"){return na(await Ce(`${et(e)}/pulls?state=${encodeURIComponent(t)}`))}async function rH(e,t="all"){return Ce(`${et(e)}/pulls/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function aH(e,t){return Ce(`${et(e)}/pulls/${t}`)}async function iH(e,t){await Ce(`${et(e)}/pulls/${t}/merge`,{method:"POST"})}async function Y1(e,t){return na(await Ce(`${et(e)}/pulls/${t}/issues`))}async function sH(e,t,n){await Ce(`${et(e)}/pulls/${t}/issues`,{method:"POST",body:JSON.stringify({issueNumber:n})})}async function oH(e,t,n){await Ce(`${et(e)}/pulls/${t}/issues/${n}`,{method:"DELETE"})}async function lH(e,t){return Ce(`${et(e)}/pulls/${t}/comments`)}async function uH(e,t){return Ce(`${et(e)}/issues/${t}/comments`)}async function h2(e,t,n){return Ce(`${et(e)}/issues/${t}/comments`,{method:"POST",body:JSON.stringify({body:n})})}async function cH(e,t,n){return Ce(`${et(e)}/issues/${t}/polish`,{method:"POST",body:JSON.stringify({draft:n})})}async function m2(e,t){return Ce(`${et(e)}/issues/${t}/draft`)}async function dH(e,t,n){return Ce(`${et(e)}/issues/polish-create`,{method:"POST",body:JSON.stringify({title:t,body:n})})}async function p2(e){return Ce(`${et(e)}/issues/draft-create`)}async function fH(e){await Ce(`${et(e)}/issues/draft-create`,{method:"DELETE"})}async function hH(e,t,n){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({title:n})})}async function mH(e,t,n){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({completedAt:n})})}async function pH(e,t,n){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({pinnedAt:n})})}async function gH(){return Ce("/api/agents-md")}async function bH(e){await Ce("/api/agents-md",{method:"PUT",body:JSON.stringify({content:e})})}async function xH(e){return Ce(`/api/repos/${encodeURIComponent(e)}/agents-md`)}async function yH(e,t){await Ce(`/api/repos/${encodeURIComponent(e)}/agents-md`,{method:"PUT",body:JSON.stringify({content:t})})}function vH(e){return`${H1()}${et(e)}/events`}async function EH(e){return Ce(`${et(e)}/sessions/status`)}async function xl(){return Ce("/api/settings")}async function pp(e,t){await Ce(`/api/settings/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({value:t})})}async function lv(){return Ce("/api/cloud/status")}async function NH(){return Ce("/api/cloud/reload",{method:"POST"})}async function _H(e){try{return(await Ce("/api/cloud/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).connected}catch{return!1}}async function q1(){return na(await Ce("/api/git-hosts"),"gitHosts")}async function SH(e,t,n,r="gitea"){return Ce("/api/git-hosts",{method:"POST",body:JSON.stringify({host:e,name:t,token:n,platform:r})})}async function TH(e){await Ce(`/api/git-hosts/${encodeURIComponent(e)}`,{method:"DELETE"})}async function FI(){return Ce("/api/usage")}async function zI(e){return Ce("/api/usage/switch",{method:"POST",body:JSON.stringify({accountId:e})})}async function wH(){return Ce("/api/usage/authorize",{method:"POST"})}async function AH(e,t){return Ce("/api/usage/exchange",{method:"POST",body:JSON.stringify({pendingId:e,code:t})})}async function CH(e,t){return Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/files`)}function kH(e,t,n){return`${H1()}${et(e)}/sessions/${encodeURIComponent(t)}/files/${n}`}async function Hx(e,t,n,r){const a=new URLSearchParams({from:String(e),to:String(t),groupBy:n});return Ce(`/api/analytics/summary?${a}`)}const to="fs-active-repo",Fe=ai((e,t)=>({repos:[],activeRepoId:localStorage.getItem(to),loading:!0,loadError:null,loadRepos:async()=>{e({loading:!0,loadError:null});try{const n=await hz(),r=t().activeRepoId,a=r&&n.some(o=>o.id===r);e({repos:n,loading:!1,activeRepoId:a?r:n.length>0?n[0].id:null});const s=t().activeRepoId;s?localStorage.setItem(to,s):localStorage.removeItem(to)}catch(n){e({loading:!1,loadError:n instanceof Error?n.message:"Failed to load repos"})}},setActiveRepo:n=>{e({activeRepoId:n}),n?localStorage.setItem(to,n):localStorage.removeItem(to)},addRepo:async(n,r,a,s)=>{try{const o=await mz(n,r,a,s);return e(c=>({repos:[...c.repos,o],activeRepoId:o.id})),localStorage.setItem(to,o.id),o}catch(o){return e({loadError:o instanceof Error?o.message:"Failed to add repo"}),null}},removeRepo:async n=>{try{await xz(n)}catch{}e(r=>{const a=r.repos.filter(o=>o.id!==n),s=r.activeRepoId===n?a.length>0?a[0].id:null:r.activeRepoId;return s?localStorage.setItem(to,s):localStorage.removeItem(to),{repos:a,activeRepoId:s}})},updateRepoBranch:(n,r)=>{e(a=>({repos:a.repos.map(s=>s.id===n?{...s,branch:r}:s)}))}})),Br=e=>{var t;return((t=e.repos.find(n=>n.id===e.activeRepoId))==null?void 0:t.name)??null},g2="fs-nav-collapsed",b2="fs-session-panel-collapsed",os=ai(e=>({navCollapsed:localStorage.getItem(g2)==="true",sessionPanelCollapsed:localStorage.getItem(b2)==="true",guideTourOpen:!1,guideTourSection:null,startGuideTour(t){e({guideTourOpen:!0,guideTourSection:t??null})},stopGuideTour(){e({guideTourOpen:!1,guideTourSection:null})},toggleNav(){e(t=>{const n=!t.navCollapsed;return localStorage.setItem(g2,String(n)),{navCollapsed:n}})},toggleSessionPanel(){e(t=>{const n=!t.sessionPanelCollapsed;return localStorage.setItem(b2,String(n)),{sessionPanelCollapsed:n}})}})),uv=[{target:'[data-guide="repo-switcher"]',title:"切换仓库",description:"点击这里可以在已注册的仓库之间快速切换。每个仓库拥有独立的 Agent 运行时和会话。",position:"bottom",section:"repos",padding:4},{target:'[data-guide="manage-repos"]',title:"管理仓库",description:"在仓库下拉菜单底部,点击「管理仓库」可以注册新仓库、启停 Agent 进程、配置运行时类型。",position:"bottom-right",section:"repos",padding:4,triggerClick:'[data-guide="repo-switcher"]'},{target:'[data-guide="repo-overflow-dropdown"]',title:"仓库高级操作",description:"每个仓库卡片的 ⋯ 菜单包含重要功能:切换运行时(OpenCode ↔ Claude Code)、开关 Worktree 任务隔离、编辑 AGENTS.md 配置。",position:"bottom-right",section:"repos",padding:4,route:"/repos",triggerClick:'[data-guide="repo-overflow-btn"]'},{target:'[data-guide="run-new-input"]',title:"新建对话",description:"选择 Agent 后输入指令开始任务。按 Tab 键可快速切换 Agent,底部可选择 Variant(默认 / max / high)控制推理强度。",position:"bottom",section:"run",padding:8,route:"run",mockScope:"run",setupFn:"clearActiveSession"},{target:'[data-guide="run-panel-handle"]',title:"运行记录面板",description:"拖动此手柄可收起/展开左侧运行记录列表。移动端可左右滑动打开。面板内可按「进行中 / 全部」筛选。",position:"bottom",section:"run",padding:6,mockScope:"run",setupFn:"clearActiveSession",mobileSwipeHint:"right"},{target:'[data-guide="run-input-bar"]',title:"快捷短语与追加输入",description:"对话进行中可在此追加指令。上方的快捷短语按钮(如「继续」)支持一键发送,可在设置 → 通用中自定义。底部可切换模型和 Variant。",position:"bottom",section:"run",padding:8,mockScope:"run",setupFn:"selectMockSession"},{target:'[data-guide="run-side-tabs"]',title:"右侧面板",description:"待办:Agent 的任务进度清单。输入:本次对话中你发送的所有消息。关联:Session 关联的 Issue 和 PR。子任务:Agent 派生的子 Session。",position:"bottom-right",section:"run",padding:6,mockScope:"run",setupFn:"selectMockSession",mobileSwipeHint:"left"},{target:'[data-guide="issue-sync-create"]',title:"同步与创建",description:"点击 ↻ 从 Git 平台同步 Issue 和 PR 数据(首次使用必须先同步)。点击 + 可直接创建新 Issue。",position:"bottom",section:"dev",padding:6,route:"dev/issues",mockScope:"dev"},{target:'[data-guide="issue-tag-filter"]',title:"标签筛选(三态)",description:"单击标签 → 包含筛选(高亮);再单击 → 排除筛选(划线);第三次单击 → 取消。支持同时选择多个标签组合筛选。",position:"bottom",section:"dev",padding:4,mockScope:"dev",triggerClick:'[data-guide="issue-tag-filter"]'},{target:'[data-guide="issue-actions"]',title:"Issue 操作",description:"查看源站、关闭/重新打开 Issue、新建 Agent 任务处理此 Issue。右侧面板按钮可展开运行记录侧边栏。",position:"bottom-right",section:"dev",padding:6,mockScope:"dev",setupFn:"selectMockIssue"},{target:'[data-guide="pr-actions"]',title:"PR 操作",description:"查看源站、合入 PR、解决冲突。当 PR 关联了 Issue 时,可选择合入并同时关闭关联的 Issues。",position:"bottom-right",section:"dev",padding:6,route:"dev/pulls",mockScope:"dev",setupFn:"selectMockPr"},{target:'[data-guide="agents-header"]',title:"创建与导入 Agent",description:"点击「创建」基于 base agent + 模型 + 提示词片段组合一个自定义 Agent。点击「导入」可从 JSON 文件恢复其他实例导出的 Agent。",position:"bottom-right",section:"agents",padding:6,route:"agents",mockScope:"agent"},{target:'[data-guide="agents-fragments"]',title:"提示词片段",description:"可复用的提示词模块,可在多个 Agent 间共享。创建 Agent 时选择片段并排序拼接顺序,构建最终的 System Prompt。",position:"bottom",section:"agents",padding:6,mockScope:"agent",triggerClick:'[data-guide="agents-fragments"]'},{target:'[data-guide="agent-detail-actions"]',title:"Agent 导出与共享",description:"下载或复制 Agent 的 JSON 配置,可在不同 Fourth Spark 实例间导入共享。包含提示词片段和所有配置。",position:"bottom-right",section:"agents",padding:4,route:"agents/__MOCK_AGENT__",mockScope:"agent"},{target:'[data-guide="agent-memory-section"]',title:"Agent 记忆",description:"Agent 在每次对话结束后自动提取经验记忆。每条记忆有分类标签和重要度评分(⚡)。系统定期自动整理:合并重复内容、衰减不活跃的记忆、强化反复验证的经验。点击版本标签可查看完整演化历史(首次提取 → 重写 → 合并 → 强化/衰减)。",position:"bottom",section:"agents",padding:6,mockScope:"agent"}];function OH(e){return e?uv.filter(t=>t.section===e):uv}function HI(e){if(e==="/repos"||e==="/settings")return"repos";const t=e.replace(/^\/[^/]+\//,"");return t.startsWith("run")?"run":t.startsWith("dev")?"dev":t.startsWith("agents")?"agents":null}let IH=0;const En=ai(e=>({toasts:[],addToast:(t,n="info",r,a)=>{const s=(a==null?void 0:a.id)??`toast-${++IH}-${Date.now()}`;e(o=>o.toasts.some(c=>c.id===s)?o:{toasts:[...o.toasts,{id:s,message:t,variant:n,sessionId:r,persistent:a==null?void 0:a.persistent}]}),a!=null&&a.persistent||setTimeout(()=>{e(o=>({toasts:o.toasts.filter(c=>c.id!==s)}))},4e3)},removeToast:t=>{e(n=>({toasts:n.toasts.filter(r=>r.id!==t)}))}})),Je=ai((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:n=>e({selectedIssueId:n}),setViewingIssue:(n,r)=>e({viewingIssueId:n,viewingTreeRootId:r??null}),enterMatchMode:n=>e({matchingParentId:n,matchingCandidateId:null}),exitMatchMode:()=>{e({matchingParentId:null,matchingCandidateId:null})},linkChild:async(n,r)=>{var s;const a=Fe.getState().activeRepoId;if(!a)return!1;try{await tH(a,n,r);const o=(s=t().issues.find(c=>c.number===n))==null?void 0:s.id;return o&&e(c=>({issues:c.issues.map(d=>d.number===r?{...d,parentId:o}:d),matchingCandidateId:null})),!0}catch{return!1}},updateIssueState:async(n,r)=>{const a=Fe.getState().activeRepoId;if(!a)return!1;try{const s=await UI(a,n,{state:r});return e(o=>({issues:o.issues.map(c=>c.number===n?{...c,state:s.state}:c)})),!0}catch{return!1}},loadIssues:async()=>{const n=Fe.getState().activeRepoId;if(!n){e({issues:[],loaded:!0});return}try{const r=await d2(n,"all");e({issues:r,loaded:!0})}catch{e({loaded:!0})}},syncIssues:async()=>{const n=Fe.getState().activeRepoId;if(n){e({syncing:!0});try{await Jz(n,"open");const[r,a,s]=await Promise.all([d2(n,"all"),u2(n),c2(n)]);e({issues:r,tags:a,milestones:s,syncing:!1})}catch(r){e({syncing:!1});let a="同步 Issue 失败";if(r instanceof ss)try{const s=JSON.parse(r.message);s.error&&(a=s.error)}catch{r.message&&(a=r.message)}En.getState().addToast(a,"error")}}},createIssue:async(n,r)=>{const a=Fe.getState().activeRepoId;if(!a)return null;try{const s=await eH(a,n,r);return e(o=>({issues:[s,...o.issues]})),s}catch{return null}},loadTags:async()=>{const n=Fe.getState().activeRepoId;if(!n){e({tags:[]});return}try{const r=await u2(n);e({tags:r})}catch{}},cycleTagFilter:n=>{e(r=>{const a=new Map(r.tagFilterMode),s=a.get(n);return s?s==="include"?a.set(n,"exclude"):a.delete(n):a.set(n,"include"),{tagFilterMode:a}})},clearTagFilter:()=>e({tagFilterMode:new Map}),loadMilestones:async()=>{const n=Fe.getState().activeRepoId;if(!n){e({milestones:[]});return}try{const r=await c2(n);e({milestones:r})}catch{}},setMilestoneFilter:n=>e({selectedMilestoneId:n})})),hn=ai((e,t)=>({pulls:[],loaded:!1,syncing:!1,selectedPrId:null,viewingPrId:null,matchingPrId:null,matchingCandidateIssueId:null,clearPulls:()=>e({pulls:[],loaded:!1,selectedPrId:null,viewingPrId:null,matchingPrId:null,matchingCandidateIssueId:null}),setViewingPr:n=>e({viewingPrId:n}),enterMatchMode:n=>e({matchingPrId:n,matchingCandidateIssueId:null}),exitMatchMode:()=>{const n=t().matchingPrId;e({matchingPrId:null,matchingCandidateIssueId:null,selectedPrId:n})},linkIssue:async(n,r)=>{const a=Fe.getState().activeRepoId;if(!a)return!1;try{return await sH(a,n,r),!0}catch{return!1}},unlinkIssue:async(n,r)=>{const a=Fe.getState().activeRepoId;if(!a)return!1;try{return await oH(a,n,r),!0}catch{return!1}},loadPulls:async()=>{const n=Fe.getState().activeRepoId;if(!n){e({pulls:[],loaded:!0});return}try{const r=await f2(n,"all");e({pulls:r,loaded:!0})}catch{e({loaded:!0})}},syncPulls:async()=>{const n=Fe.getState().activeRepoId;if(n){e({syncing:!0});try{await rH(n,"open");const r=await f2(n,"all");e({pulls:r,syncing:!1})}catch(r){e({syncing:!1});let a="同步 PR 失败";if(r instanceof ss)try{const s=JSON.parse(r.message);s.error&&(a=s.error)}catch{r.message&&(a=r.message)}En.getState().addToast(a,"error")}}}})),Pa=ai(e=>({agents:[],loaded:!1,loadAgents:async()=>{const t=Fe.getState().activeRepoId;try{const n=t?await PI(t):await jI();e({agents:n,loaded:!0})}catch{e({loaded:!0})}}})),RH=new Set(["tool","tool-use","tool_use","tool-call","tool_call","tool-result","tool_result"]),MH=new Set(["thinking","reasoning","reason"]),jH=new Set(["text","output_text","message"]),DH=new Set(["file","image"]);function gp(e){var n;const t=((n=e.type)==null?void 0:n.toLowerCase())??"";return RH.has(t)||e.toolName!=null||e.tool!=null?"tool":DH.has(t)?"file":MH.has(t)?"thinking":jH.has(t)||e.content!=null||e.text!=null?"text":"other"}function cv(e){return e.content??e.text??""}function $I(e){return e.toolName??e.tool??"tool"}function Tg(e){var t;return e.input??((t=e.state)==null?void 0:t.input)}function G1(e){var t;return e.output??((t=e.state)==null?void 0:t.output)}function K1(e){var n,r,a;const t=(r=(n=e.state)==null?void 0:n.status)==null?void 0:r.toLowerCase();return t==="completed"||t==="done"||t==="success"?"completed":t==="error"||t==="failed"||((a=e.state)==null?void 0:a.error)!=null?"error":t==="pending"||t==="queued"?"pending":t==="running"||t==="in_progress"?"running":G1(e)!=null?"completed":"running"}function x2(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function yl(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 YI(e){return e.filter(t=>yl(t.status)==="completed").length}function df(e){const t=$I(e).toLowerCase();return t==="question"||t==="mcp_question"}function LH(e){const t=Tg(e);if(!t||typeof t!="object")return null;const n=t;return Array.isArray(n.questions)?n.questions:null}function bp(e){if(!df(e))return!1;const t=K1(e);return t==="pending"||t==="running"}const PH=/\bses_[a-zA-Z0-9]+/;function BH(e){var a;const t=Tg(e);if(t&&typeof t=="object"){const s=t;if(typeof s.task_id=="string"&&s.task_id.startsWith("ses_"))return s.task_id}const n=(a=e.state)==null?void 0:a.metadata;if(n){const s=n.session_id??n.sessionId;if(typeof s=="string"&&s.startsWith("ses_"))return s}const r=G1(e);if(typeof r=="string"){const s=PH.exec(r);if(s)return s[0]}if(r&&typeof r=="object"){const s=r,o=s.session_id??s.sessionId??s.task_id;if(typeof o=="string"&&o.startsWith("ses_"))return o}return null}const UH=ai(()=>({agents:[],loaded:!1}));function qI(e){return`question-${e}`}function $x(e,t){const n=t.find(a=>a.id===e),r=(n==null?void 0:n.title)||e.slice(-8);En.getState().addToast(`${r} — 等待回复`,"warning",e,{id:qI(e),persistent:!0})}function FH(e){var t;for(const n of e)if((t=n.parts)!=null&&t.some(r=>df(r)&&bp(r)))return!0;return!1}const ff=[],hf=[],y2=[],$o={};function v2(e){return e.id??e.callID}function Dn(){return Fe.getState().activeRepoId}async function E2(e,t){const n=Dn();if(n)try{const[r,a]=await Promise.all([Bz(n,e),MI(n).catch(()=>null)]);t(s=>{const o={sessionLinks:{...s.sessionLinks,[e]:r}};return a&&(o.allSessionLinks=a),o})}catch{}}const N2=20,De=ai((e,t)=>({sessions:[],activeSessionId:null,messages:{},messagesMeta:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},sessionFilter:"active",sessionSearch:"",loadingSessions:!1,loadError:null,sendError:null,setSessionFilter:n=>e({sessionFilter:n}),setSessionSearch:n=>e({sessionSearch:n}),toggleSessionPin:async n=>{const r=Dn();if(!r)return;const a=t().sessions.find(o=>o.id===n);if(!a)return;const s=a.pinnedAt?null:Date.now();e(o=>({sessions:o.sessions.map(c=>c.id===n?{...c,pinnedAt:s??void 0}:c)}));try{await pH(r,n,s)}catch{await t().loadSessions()}},toggleSessionComplete:async n=>{const r=Dn();if(!r)return;const a=t().sessions.find(o=>o.id===n);if(!a)return;const s=a.completedAt?null:Date.now();e(o=>({sessions:o.sessions.map(c=>c.id===n?{...c,completedAt:s??void 0}:c)}));try{await mH(r,n,s)}catch{await t().loadSessions()}},loadSessions:async()=>{const n=Dn();if(!n){e({sessions:[],loadingSessions:!1});return}e({loadingSessions:!0,loadError:null});try{const[r,a]=await Promise.all([kz(n),MI(n).catch(()=>null)]);if(Dn()!==n)return;const s={sessions:r,loadingSessions:!1};a&&(s.allSessionLinks=a),e(s)}catch(r){if(Dn()!==n)return;e({loadingSessions:!1,loadError:r instanceof Error?r.message:"Failed to load sessions"})}},createSession:async(n,r,a,s,o,c,d)=>{const f=Dn();if(!f)return null;e({sendError:null});try{const m=await Oz(f,n,r,a,s,o,c,d);return e(p=>({sessions:[m,...p.sessions.filter(b=>b.id!==m.id)],activeSessionId:m.id,messages:{...p.messages,[m.id]:[]}})),t().setSessionStatus(m.id,"busy"),o&&En.getState().addToast("已自动分配为处理人","success"),m}catch(m){return e({sendError:m instanceof Error?m.message:"Failed to create session"}),null}},setActiveSession:async n=>{Dn()&&(e({activeSessionId:n,sendError:null}),await t().refreshSessionData(n))},refreshSessionData:async n=>{var m,p;const r=Dn();if(!r)return;const s=!t().messages[n]||t().messages[n].length===0?{limit:N2}:void 0,[o,c]=await Promise.allSettled([Uz(r,n),s2(r,n,s)]);if(Dn()!==r)return;const d=o.status==="fulfilled"?o.value:null,f=(p=(m=d==null?void 0:d.session)==null?void 0:m.revert)==null?void 0:p.messageID;e(b=>{const x={};if(d&&(d.status&&(x.sessionStatuses={...b.sessionStatuses,[n]:d.status.type}),d.todos&&(x.todos={...b.todos,[n]:d.todos}),d.links&&(x.sessionLinks={...b.sessionLinks,[n]:d.links}),d.session&&(x.sessions=b.sessions.map(E=>E.id===n?{...E,...d.session}:E))),c.status==="fulfilled"){let E=c.value.messages;if(f){const T=E.findIndex(S=>S.id===f);T>=0&&(E=E.slice(0,T+1))}const N=b.messages[n]??[];E.length>=N.length&&(x.messages={...b.messages,[n]:E}),x.messagesMeta={...b.messagesMeta,[n]:{total:Math.max(c.value.total,N.length),hasMore:c.value.hasMore,loading:!1}}}return x}),c.status==="fulfilled"&&FH(c.value.messages)&&$x(n,t().sessions)},loadMoreMessages:async n=>{var c;const r=Dn();if(!r)return;const a=t().messagesMeta[n];if(!(a!=null&&a.hasMore)||a.loading)return;const o=(c=(t().messages[n]??[])[0])==null?void 0:c.id;e(d=>({messagesMeta:{...d.messagesMeta,[n]:{...a,loading:!0}}}));try{const d=await s2(r,n,{limit:N2,before:o});e(f=>{const m=f.messages[n]??[];return{messages:{...f.messages,[n]:[...d.messages,...m]},messagesMeta:{...f.messagesMeta,[n]:{total:d.total,hasMore:d.hasMore,loading:!1}}}})}catch{e(d=>({messagesMeta:{...d.messagesMeta,[n]:{...a,loading:!1}}}))}},addLink:async(n,r,a)=>{const s=Dn();if(!s)return!1;try{return await Fz(s,n,r,a),await E2(n,e),!0}catch{return!1}},removeLink:async(n,r,a)=>{const s=Dn();if(!s)return!1;try{return await zz(s,n,r,a),await E2(n,e),!0}catch{return!1}},deleteSession:async n=>{const r=Dn();if(r)try{await Iz(r,n)}catch{}delete $o[n],e(a=>{const{[n]:s,...o}=a.messages,{[n]:c,...d}=a.messagesMeta,{[n]:f,...m}=a.todos,{[n]:p,...b}=a.sessionStatuses,{[n]:x,...E}=a.errorReasons,{[n]:N,...T}=a.queuedMessageIds,{[n]:S,...C}=a.sessionLinks,{[n]:A,...O}=a.allSessionLinks;return{sessions:a.sessions.filter(R=>R.id!==n),messages:o,messagesMeta:d,todos:m,sessionStatuses:b,errorReasons:E,queuedMessageIds:T,sessionLinks:C,allSessionLinks:O,activeSessionId:a.activeSessionId===n?null:a.activeSessionId}})},sendMessage:async(n,r,a,s)=>{const o=Dn(),c=t().activeSessionId;if(!o||!c)return!1;const d=t().sessions.find(m=>m.id===c),f=t().sessionStatuses[c]==="busy";e({sendError:null}),d!=null&&d.completedAt&&e(m=>({sessions:m.sessions.map(p=>p.id===c?{...p,completedAt:void 0}:p)})),f||t().setSessionStatus(c,"busy");try{const m=UH.getState(),p=d!=null&&d.agent&&m.loaded&&m.agents.some(b=>b.name===d.agent||b.id===d.agent)?d.agent:void 0;return await Rz(o,c,n,p,r,a,s),f&&($o[c]=($o[c]||0)+1),!0}catch(m){return e({sendError:m instanceof Error?m.message:"Failed to send message"}),f||t().setSessionStatus(c,"idle"),!1}},replyQuestion:async n=>{const r=Dn(),a=t().activeSessionId;if(!(!r||!a))try{await jz(r,a,n)}catch(s){e({sendError:s instanceof Error?s.message:"Failed to reply to question"})}},rejectQuestion:async()=>{const n=Dn(),r=t().activeSessionId;if(!(!n||!r))try{await Dz(n,r)}catch{}},abortSession:async()=>{const n=Dn(),r=t().activeSessionId;if(!(!n||!r)){try{await Mz(n,r)}catch{}t().setSessionStatus(r,"idle")}},clearSessions:()=>{for(const n of Object.keys($o))delete $o[n];e({sessions:[],activeSessionId:null,messages:{},messagesMeta:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},sessionSearch:"",loadError:null,sendError:null})},updateMessage:(n,r)=>{var a;e(s=>{const o=s.messages[n]??[],c=o.findIndex(p=>p.id===r.id);let d,f=s.queuedMessageIds,m=s.messagesMeta;if(c>=0){const p={...o[c],...r};(!r.parts||r.parts.length===0)&&o[c].parts&&(p.parts=o[c].parts),d=[...o],d[c]=p}else{d=[...o,r];const p=m[n];p&&(m={...m,[n]:{...p,total:p.total+1}});const b=$o[n]||0;if(r.role==="user"&&b>0){const x=[...f[n]??[]];x.push(r.id),f={...f,[n]:x},$o[n]=b-1}else if(r.role==="assistant"){const x=f[n];x&&x.length>0&&(f={...f,[n]:x.slice(1)})}}return{messages:{...s.messages,[n]:d},messagesMeta:m,queuedMessageIds:f}}),(a=r.parts)!=null&&a.some(s=>df(s)&&bp(s))&&$x(n,t().sessions)},updateMessagePart:(n,r,a)=>{e(s=>{const o=s.messages[n]??[],c=o.findIndex(E=>E.id===r),d=c>=0?o[c]:{id:r,role:"assistant"},f=d.parts?[...d.parts]:[],m=v2(a),p=m!=null?f.findIndex(E=>v2(E)===m):-1;p>=0?f[p]={...f[p],...a}:f.push(a);const b={...d,parts:f},x=c>=0?[...o]:[...o,b];return c>=0&&(x[c]=b),{messages:{...s.messages,[n]:x}}}),df(a)&&bp(a)&&$x(n,t().sessions)},appendMessagePartDelta:(n,r,a,s)=>{e(o=>{const c=o.messages[n]??[],d=c.findIndex(E=>E.id===r),f=d>=0?c[d]:{id:r,role:"assistant"},m=f.parts?[...f.parts]:[],p=m.findIndex(E=>E.id===a);if(p>=0){const E=m[p],N=(E.content??E.text??"")+s;m[p]=E.content!=null?{...E,content:N}:{...E,text:N}}else m.push({id:a,type:"text",text:s});const b={...f,parts:m},x=d>=0?[...c]:[...c,b];return d>=0&&(x[d]=b),{messages:{...o.messages,[n]:x}}})},updateTodos:(n,r)=>{e(a=>({todos:{...a.todos,[n]:r}}))},updateSessionInfo:n=>{e(r=>r.sessions.some(s=>s.id===n.id)?{sessions:r.sessions.map(s=>s.id===n.id?{...s,...n}:s)}:{sessions:[n,...r.sessions]})},setSessionStatus:(n,r,a)=>{const s=t().sessionStatuses[n];if(s!==r){const o=t().sessions.find(d=>d.id===n),c=(o==null?void 0:o.title)||n.slice(-8);if(r==="idle"&&s!==void 0&&s!=="idle")En.getState().removeToast(qI(n)),En.getState().addToast(`${c} — 完成`,"success",n);else if(r==="busy"&&(s===void 0||s==="idle"))En.getState().addToast(`${c} — 开始运行`,"info",n);else if(r==="retry")En.getState().addToast(`${c} — 进入重试`,"warning",n);else if(r==="error"){const d=a?`${c} — 错误: ${a}`:`${c} — 发生错误`;En.getState().addToast(d,"error",n)}}e(o=>{const c=a?{...o.errorReasons,[n]:a}:r!=="error"?(()=>{const{[n]:d,...f}=o.errorReasons;return f})():o.errorReasons;return{sessionStatuses:{...o.sessionStatuses,[n]:r},errorReasons:c}})},bulkSetStatuses:n=>{e({sessionStatuses:{...t().sessionStatuses,...n}})},renameSession:async(n,r)=>{const a=Dn();if(a){e(s=>({sessions:s.sessions.map(o=>o.id===n?{...o,title:r}:o)}));try{await hH(a,n,r)}catch{await t().loadSessions()}}},revertToMessage:async(n,r)=>{const a=Dn();if(!a)return!1;try{return await Lz(a,n,r),await t().refreshSessionData(n),!0}catch{return!1}}})),ll="__guide__",Gt=Date.now(),xn=864e5,GI="guide-agent-",Hu=`${GI}1`,V1="guide-session-run-1",zH={id:V1,title:"示例对话:添加用户认证",agent:"Sisyphus",createdAt:new Date(Gt-36e5).toISOString(),time:{created:Gt-36e5,updated:Gt-6e5},cost:.12,tokens:{input:4200,output:1800,reasoning:320,cache:{read:800,write:200}}},KI=[{id:"guide-issue-1",repoId:ll,number:42,title:"添加用户认证模块",body:"实现 JWT 认证,包括登录、注册和 token 刷新。",state:"open",labels:[{id:1,name:"feature",color:"0075ca"}],htmlUrl:"#",authorLogin:"demo-user",createdAt:Gt-xn,updatedAt:Gt-36e5},{id:"guide-issue-2",repoId:ll,number:41,title:"修复登录页样式错位",body:"移动端登录表单在小屏幕下溢出。",state:"closed",labels:[{id:2,name:"bug",color:"d73a4a"}],htmlUrl:"#",authorLogin:"demo-user",createdAt:Gt-2*xn,updatedAt:Gt-xn}],VI=[{id:"guide-pr-1",repoId:ll,number:10,title:"feat: add auth module",body:"Implements JWT authentication.",state:"open",headBranch:"feat/auth",baseBranch:"main",labels:[{id:1,name:"feature",color:"0075ca"}],htmlUrl:"#",authorLogin:"demo-user",mergeable:"true",draft:0,commentCount:0,additions:320,deletions:12,changedFilesCount:8,createdAt:Gt-xn,updatedAt:Gt-36e5,mergedAt:null},{id:"guide-pr-2",repoId:ll,number:9,title:"fix: login page CSS overflow",state:"merged",headBranch:"fix/login-css",baseBranch:"main",draft:0,commentCount:1,additions:15,deletions:3,changedFilesCount:2,createdAt:Gt-2*xn,updatedAt:Gt-xn,mergedAt:Gt-xn}],HH=[{id:"guide-tag-1",repoId:ll,name:"bug",color:"d73a4a"},{id:"guide-tag-2",repoId:ll,name:"feature",color:"0075ca"},{id:"guide-tag-3",repoId:ll,name:"priority",color:"e4e669"}],$H={id:Hu,name:"示例 Agent",description:"用于功能引导的演示 Agent",baseAgent:"Sisyphus - ultraworker",model:null,variant:null,systemPrompt:"",systemPromptPosition:0,isSystem:0,memoryModel:null,fragments:[],repoId:null,sortOrder:999,createdAt:Gt-7*xn,updatedAt:Gt-xn},_2=[{id:"guide-mem-1",customAgentId:Hu,sessionId:"guide-session-1",mergedFrom:null,content:"用户偏好 TypeScript strict 模式,所有新文件必须启用 strictNullChecks",category:"编码规范",importance:.92,supersededBy:null,history:[{content:"用户使用 TypeScript",importance:.5,category:"编码规范",action:"create",ts:Gt-7*xn},{content:"用户偏好 TypeScript strict 模式",importance:.75,category:"编码规范",action:"update",ts:Gt-3*xn},{content:"用户偏好 TypeScript strict 模式,所有新文件必须启用 strictNullChecks",importance:.92,category:"编码规范",action:"reinforce",ts:Gt-xn}],createdAt:Gt-7*xn,updatedAt:Gt-xn},{id:"guide-mem-2",customAgentId:Hu,sessionId:"guide-session-2",mergedFrom:["guide-mem-old-1","guide-mem-old-2"],content:"项目使用 Tailwind CSS 4 + zustand 状态管理,组件优先使用函数式写法",category:"技术栈",importance:.85,supersededBy:null,history:[{content:"项目使用 Tailwind CSS",importance:.6,category:"技术栈",action:"create",ts:Gt-5*xn},{content:"项目使用 Tailwind CSS 4 + zustand 状态管理,组件优先使用函数式写法",importance:.85,category:"技术栈",action:"merge",ts:Gt-2*xn}],createdAt:Gt-5*xn,updatedAt:Gt-2*xn},{id:"guide-mem-3",customAgentId:Hu,sessionId:"guide-session-1",mergedFrom:null,content:"Git 提交信息使用 conventional commits 格式",category:"工作流",importance:.45,supersededBy:null,history:[{content:"Git 提交信息使用 conventional commits 格式",importance:.7,category:"工作流",action:"create",ts:Gt-10*xn},{content:"Git 提交信息使用 conventional commits 格式",importance:.45,category:"工作流",action:"decay",ts:Gt-4*xn}],createdAt:Gt-10*xn,updatedAt:Gt-4*xn}];let Kt=null;function YH(e){Kt&&(e!=="dev"&&(Je.setState({issues:Kt.issues,tags:Kt.tags,loaded:Kt.issueLoaded,viewingIssueId:null,viewingTreeRootId:null}),hn.setState({pulls:Kt.pulls,loaded:Kt.prLoaded,viewingPrId:null})),e!=="agent"&&Pa.setState({agents:Kt.agents}),e!=="run"&&De.setState({sessions:Kt.sessions,activeSessionId:Kt.activeSessionId}))}function qH(e){if(!Kt){const t=Je.getState(),n=hn.getState(),r=Pa.getState(),a=De.getState();Kt={issues:t.issues,tags:t.tags,issueLoaded:t.loaded,pulls:n.pulls,prLoaded:n.loaded,agents:r.agents,sessions:a.sessions,activeSessionId:a.activeSessionId}}if(YH(e),e==="run"){const t=Kt.sessions.some(n=>n.id===V1);De.setState({sessions:t?Kt.sessions:[...Kt.sessions,zH]})}else if(e==="dev")Je.setState({issues:KI,tags:HH,loaded:!0}),hn.setState({pulls:VI,loaded:!0});else if(e==="agent"){const t=Kt.agents.some(n=>n.id===Hu);Pa.setState({agents:t?Kt.agents:[...Kt.agents,$H]})}}function S2(){Kt&&(Je.setState({issues:Kt.issues,tags:Kt.tags,loaded:Kt.issueLoaded,viewingIssueId:null,viewingTreeRootId:null}),hn.setState({pulls:Kt.pulls,loaded:Kt.prLoaded,viewingPrId:null}),Pa.setState({agents:Kt.agents}),De.setState({sessions:Kt.sessions,activeSessionId:Kt.activeSessionId}),GH("id"),Kt=null)}function WI(e,t){const n=new URL(window.location.href);n.searchParams.set(e,t),window.history.replaceState(null,"",n.toString()),window.dispatchEvent(new PopStateEvent("popstate"))}function GH(e){const t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState(null,"",t.toString()),window.dispatchEvent(new PopStateEvent("popstate")))}function KH(){const e=KI[0].id;Je.setState({viewingIssueId:e}),WI("id",e)}function VH(){const e=VI[0].id;hn.setState({viewingPrId:e}),WI("id",e)}function WH(){De.setState({activeSessionId:V1})}function XH(){De.setState({activeSessionId:null})}function QH(){return Hu}const ZH=6,T2=12,w2=200,A2=80,C2=288,k2=8,JH=768;function e$(e,t){const n=document.querySelector(e);if(!n)return null;const r=n.getBoundingClientRect();return r.width===0&&r.height===0||r.right<0||r.bottom<0||r.left>window.innerWidth||r.top>window.innerHeight?null:{top:r.top-t,left:r.left-t,width:r.width+t*2,height:r.height+t*2}}function t$(e){const{top:t,left:n,width:r,height:a}=e,s=n+r,o=t+a;return`polygon(
515
+ */const oz=[["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"}]],hc=Re("zap",oz);function II(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=II(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function re(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=II(e))&&(r&&(r+=" "),r+=t);return r}const t2=e=>{let t;const n=new Set,r=(f,m)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const b=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(x=>x(t,b))}},a=()=>t,c={setState:r,getState:a,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f))},d=t=e(r,a,c);return c},lz=(e=>e?t2(e):t2),uz=e=>e;function cz(e,t=uz){const n=Yd.useSyncExternalStore(e.subscribe,Yd.useCallback(()=>t(e.getState()),[e,t]),Yd.useCallback(()=>t(e.getInitialState()),[e,t]));return Yd.useDebugValue(n),n}const n2=e=>{const t=lz(e),n=r=>cz(t,r);return Object.assign(n,t),n},ai=(e=>e?n2(e):n2),zx="fs-theme";function RI(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function r2(e){return e==="system"?RI():e}function a2(e){e==="system"?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme",e)}const sv=ai((e,t)=>({preference:localStorage.getItem(zx)??"system",resolved:r2(localStorage.getItem(zx)??"system"),cycle(){const n=["system","light","dark"],r=n[(n.indexOf(t().preference)+1)%n.length],a=r2(r);localStorage.setItem(zx,r),a2(r),e({preference:r,resolved:a})},init(){a2(t().preference);const n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{const{preference:a}=t();if(a==="system"){const s=RI();e({resolved:s})}};return n.addEventListener("change",r),()=>n.removeEventListener("change",r)}})),mp="fourth-spark-server-url";function dz(){if(typeof window>"u")return!1;const t=window.Capacitor;return typeof(t==null?void 0:t.isNativePlatform)=="function"&&t.isNativePlatform()}function H1(){return localStorage.getItem(mp)??""}function fz(e){const t=e.replace(/\/+$/,"");t?localStorage.setItem(mp,t):localStorage.removeItem(mp)}function ov(){return localStorage.getItem(mp)??""}class ss extends Error{constructor(n,r){super(n);kt(this,"status");this.name="ApiError",this.status=r}}async function Ce(e,t){let n;try{n=await fetch(H1()+e,{...t,headers:{Accept:"application/json",...t!=null&&t.body?{"Content-Type":"application/json"}:{},...t==null?void 0:t.headers}})}catch(a){throw new ss(a instanceof Error?a.message:"Network request failed",0)}if(!n.ok){const a=await n.text().catch(()=>"");throw new ss(a.trim()||`${n.status} ${n.statusText}`,n.status)}if(n.status===204)return;const r=await n.text();if(r)return JSON.parse(r)}function na(e,...t){if(Array.isArray(e))return e;if(e&&typeof e=="object"){const n=e;for(const r of[...t,"data","items"])if(Array.isArray(n[r]))return n[r]}return[]}async function hz(){return na(await Ce("/api/repos"),"repos")}async function mz(e,t,n,r){return Ce("/api/repos",{method:"POST",body:JSON.stringify({name:e,gitUrl:t,localPath:n,runtimeType:r})})}async function pz(e){return Ce("/api/repos/resolve",{method:"POST",body:JSON.stringify({localPath:e})})}async function gz(e,t){return Ce("/api/fs/browse",{method:"POST",body:JSON.stringify({path:e,showHidden:t})})}async function bz(e,t){return Ce("/api/repos/clone",{method:"POST",body:JSON.stringify({gitUrl:e,targetDir:t})})}async function xz(e){await Ce(`/api/repos/${encodeURIComponent(e)}`,{method:"DELETE"})}async function yz(e){await Ce(`/api/repos/${encodeURIComponent(e)}/start`,{method:"POST"})}async function vz(e){await Ce(`/api/repos/${encodeURIComponent(e)}/stop`,{method:"POST"})}async function Ez(e){return Ce(`/api/repos/${encodeURIComponent(e)}/branches`)}async function Nz(e,t){return Ce(`/api/repos/${encodeURIComponent(e)}/checkout`,{method:"POST",body:JSON.stringify({branch:t})})}async function _z(e){return Ce(`/api/repos/${encodeURIComponent(e)}/pull`,{method:"POST"})}function et(e){return`/api/repos/${encodeURIComponent(e)}`}async function Sz(e){return na(await Ce(`${et(e)}/workspaces`),"workspaces")}async function Tz(e,t){await Ce(`${et(e)}/workspaces/${encodeURIComponent(t)}`,{method:"DELETE"})}async function wz(e){return Ce(`${et(e)}/workspaces/cleanup`,{method:"POST"})}async function Az(e,t){await Ce(`/api/repos/${e}/worktree`,{method:"PATCH",body:JSON.stringify({enabled:t})})}async function Cz(e,t){await Ce(`/api/repos/${e}/runtime`,{method:"PATCH",body:JSON.stringify({runtimeType:t})})}async function kz(e){return na(await Ce(`${et(e)}/sessions`),"sessions")}async function Oz(e,t,n,r,a,s,o,c){return Ce(`${et(e)}/sessions`,{method:"POST",body:JSON.stringify({message:t,agent:n,model:r,variant:a,issueId:s,customAgentId:o,files:c})})}async function Iz(e,t){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Rz(e,t,n,r,a,s,o){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/prompt`,{method:"POST",body:JSON.stringify({content:n,agent:r,model:a,variant:s,files:o})})}async function Mz(e,t){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/abort`,{method:"POST"})}async function jz(e,t,n){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/questions/reply`,{method:"POST",body:JSON.stringify({answers:n})})}async function Dz(e,t){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/questions/reject`,{method:"POST"})}async function Lz(e,t,n){return Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/revert`,{method:"POST",body:JSON.stringify({messageID:n})})}function i2(e){const t=e,n=t.info;if(n&&typeof n.id=="string"){const r=Array.isArray(t.parts)?t.parts:void 0;return{...n,...r?{parts:r}:{}}}return t}async function s2(e,t,n){const r=new URLSearchParams;n!=null&&n.limit&&r.set("limit",String(n.limit)),n!=null&&n.before&&r.set("before",n.before);const a=r.toString(),s=`${et(e)}/sessions/${encodeURIComponent(t)}/messages${a?`?${a}`:""}`,o=await Ce(s);if(Array.isArray(o)){const f=o.map(i2);return{messages:f,total:f.length,hasMore:!1}}const c=o,d=Array.isArray(c.messages)?c.messages:[];return{messages:d.map(i2),total:c.total??d.length,hasMore:c.hasMore??!1}}async function Pz(e,t){return Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/status`)}async function Bz(e,t){return Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/links`)}async function Uz(e,t){return Ce(`${et(e)}/sessions/snapshot/${encodeURIComponent(t)}`)}async function MI(e){return Ce(`${et(e)}/sessions/all-links`)}async function Fz(e,t,n,r){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"POST",body:JSON.stringify({type:n,targetId:r})})}async function zz(e,t,n,r){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/links`,{method:"DELETE",body:JSON.stringify({type:n,targetId:r})})}async function jI(){return na(await Ce("/api/custom-agents"))}async function Hz(e){return Ce("/api/custom-agents",{method:"POST",body:JSON.stringify(e)})}async function $z(e,t){return Ce(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function DI(e){await Ce(`/api/custom-agents/${encodeURIComponent(e)}`,{method:"DELETE"})}async function o2(e){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/export`)}async function Yz(e){return Ce("/api/custom-agents/import",{method:"POST",body:JSON.stringify(e)})}async function LI(e,t){const n=new URLSearchParams;t!=null&&t.category&&n.set("category",t.category),t!=null&&t.includeSuperseded&&n.set("includeSuperseded","true");const r=n.toString();return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories${r?`?${r}`:""}`)}async function qz(e,t,n){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify(n)})}async function Gz(e,t){await Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Kz(e,t){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/extract`,{method:"POST",body:JSON.stringify({sessionIds:t})})}async function l2(e){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/stats`)}async function Vz(e){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/memories/consolidate`,{method:"POST"})}async function $1(e){return Ce(`/api/custom-agents/${encodeURIComponent(e)}/sessions`)}async function PI(e){return na(await Ce(`${et(e)}/custom-agents`))}async function Wz(e,t){return Ce(`${et(e)}/custom-agents`,{method:"POST",body:JSON.stringify(t)})}async function Df(e){return na(await Ce(`${et(e)}/models`))}async function BI(){return na(await Ce("/api/prompt-fragments"))}async function Xz(e){return Ce("/api/prompt-fragments",{method:"POST",body:JSON.stringify(e)})}async function Qz(e,t){return Ce(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function Zz(e){await Ce(`/api/prompt-fragments/${encodeURIComponent(e)}`,{method:"DELETE"})}async function u2(e){return na(await Ce(`${et(e)}/tags`))}async function c2(e,t){return na(await Ce(`${et(e)}/milestones`))}async function d2(e,t="open"){return na(await Ce(`${et(e)}/issues?state=${encodeURIComponent(t)}`),"issues")}async function Jz(e,t="all"){return Ce(`${et(e)}/issues/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function eH(e,t,n){return Ce(`${et(e)}/issues`,{method:"POST",body:JSON.stringify({title:t,body:n})})}async function tH(e,t,n){await Ce(`${et(e)}/issues/${t}/children`,{method:"POST",body:JSON.stringify({childNumber:n})})}async function UI(e,t,n){return Ce(`${et(e)}/issues/${t}`,{method:"PATCH",body:JSON.stringify(n)})}async function nH(e,t){return na(await Ce(`${et(e)}/issues/${t}/pulls`))}async function f2(e,t="open"){return na(await Ce(`${et(e)}/pulls?state=${encodeURIComponent(t)}`))}async function rH(e,t="all"){return Ce(`${et(e)}/pulls/sync`,{method:"POST",body:JSON.stringify({state:t})})}async function aH(e,t){return Ce(`${et(e)}/pulls/${t}`)}async function iH(e,t){await Ce(`${et(e)}/pulls/${t}/merge`,{method:"POST"})}async function Y1(e,t){return na(await Ce(`${et(e)}/pulls/${t}/issues`))}async function sH(e,t,n){await Ce(`${et(e)}/pulls/${t}/issues`,{method:"POST",body:JSON.stringify({issueNumber:n})})}async function oH(e,t,n){await Ce(`${et(e)}/pulls/${t}/issues/${n}`,{method:"DELETE"})}async function lH(e,t){return Ce(`${et(e)}/pulls/${t}/comments`)}async function uH(e,t){return Ce(`${et(e)}/issues/${t}/comments`)}async function h2(e,t,n){return Ce(`${et(e)}/issues/${t}/comments`,{method:"POST",body:JSON.stringify({body:n})})}async function cH(e,t,n){return Ce(`${et(e)}/issues/${t}/polish`,{method:"POST",body:JSON.stringify({draft:n})})}async function m2(e,t){return Ce(`${et(e)}/issues/${t}/draft`)}async function dH(e,t,n){return Ce(`${et(e)}/issues/polish-create`,{method:"POST",body:JSON.stringify({title:t,body:n})})}async function p2(e){return Ce(`${et(e)}/issues/draft-create`)}async function fH(e){await Ce(`${et(e)}/issues/draft-create`,{method:"DELETE"})}async function hH(e,t,n){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({title:n})})}async function mH(e,t,n){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({completedAt:n})})}async function pH(e,t,n){await Ce(`${et(e)}/sessions/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify({pinnedAt:n})})}async function gH(){return Ce("/api/agents-md")}async function bH(e){await Ce("/api/agents-md",{method:"PUT",body:JSON.stringify({content:e})})}async function xH(e){return Ce(`/api/repos/${encodeURIComponent(e)}/agents-md`)}async function yH(e,t){await Ce(`/api/repos/${encodeURIComponent(e)}/agents-md`,{method:"PUT",body:JSON.stringify({content:t})})}function vH(e){return`${H1()}${et(e)}/events`}async function EH(e){return Ce(`${et(e)}/sessions/status`)}async function xl(){return Ce("/api/settings")}async function pp(e,t){await Ce(`/api/settings/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify({value:t})})}async function lv(){return Ce("/api/cloud/status")}async function NH(){return Ce("/api/cloud/reload",{method:"POST"})}async function _H(e){try{return(await Ce("/api/cloud/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:e})})).connected}catch{return!1}}async function q1(){return na(await Ce("/api/git-hosts"),"gitHosts")}async function SH(e,t,n,r="gitea"){return Ce("/api/git-hosts",{method:"POST",body:JSON.stringify({host:e,name:t,token:n,platform:r})})}async function TH(e){await Ce(`/api/git-hosts/${encodeURIComponent(e)}`,{method:"DELETE"})}async function FI(){return Ce("/api/usage")}async function zI(e){return Ce("/api/usage/switch",{method:"POST",body:JSON.stringify({accountId:e})})}async function wH(){return Ce("/api/usage/authorize",{method:"POST"})}async function AH(e,t){return Ce("/api/usage/exchange",{method:"POST",body:JSON.stringify({pendingId:e,code:t})})}async function CH(e,t){return Ce(`${et(e)}/sessions/${encodeURIComponent(t)}/files`)}function kH(e,t,n){return`${H1()}${et(e)}/sessions/${encodeURIComponent(t)}/files/${n}`}async function Hx(e,t,n,r){const a=new URLSearchParams({from:String(e),to:String(t),groupBy:n});return Ce(`/api/analytics/summary?${a}`)}const to="fs-active-repo",Fe=ai((e,t)=>({repos:[],activeRepoId:localStorage.getItem(to),loading:!0,loadError:null,loadRepos:async()=>{e({loading:!0,loadError:null});try{const n=await hz(),r=t().activeRepoId,a=r&&n.some(o=>o.id===r);e({repos:n,loading:!1,activeRepoId:a?r:n.length>0?n[0].id:null});const s=t().activeRepoId;s?localStorage.setItem(to,s):localStorage.removeItem(to)}catch(n){e({loading:!1,loadError:n instanceof Error?n.message:"Failed to load repos"})}},setActiveRepo:n=>{e({activeRepoId:n}),n?localStorage.setItem(to,n):localStorage.removeItem(to)},addRepo:async(n,r,a,s)=>{try{const o=await mz(n,r,a,s);return e(c=>({repos:[...c.repos,o],activeRepoId:o.id})),localStorage.setItem(to,o.id),o}catch(o){return e({loadError:o instanceof Error?o.message:"Failed to add repo"}),null}},removeRepo:async n=>{try{await xz(n)}catch{}e(r=>{const a=r.repos.filter(o=>o.id!==n),s=r.activeRepoId===n?a.length>0?a[0].id:null:r.activeRepoId;return s?localStorage.setItem(to,s):localStorage.removeItem(to),{repos:a,activeRepoId:s}})},updateRepoBranch:(n,r)=>{e(a=>({repos:a.repos.map(s=>s.id===n?{...s,branch:r}:s)}))}})),Br=e=>{var t;return((t=e.repos.find(n=>n.id===e.activeRepoId))==null?void 0:t.name)??null},g2="fs-nav-collapsed",b2="fs-session-panel-collapsed",os=ai(e=>({navCollapsed:localStorage.getItem(g2)==="true",sessionPanelCollapsed:localStorage.getItem(b2)==="true",guideTourOpen:!1,guideTourSection:null,startGuideTour(t){e({guideTourOpen:!0,guideTourSection:t??null})},stopGuideTour(){e({guideTourOpen:!1,guideTourSection:null})},toggleNav(){e(t=>{const n=!t.navCollapsed;return localStorage.setItem(g2,String(n)),{navCollapsed:n}})},toggleSessionPanel(){e(t=>{const n=!t.sessionPanelCollapsed;return localStorage.setItem(b2,String(n)),{sessionPanelCollapsed:n}})}})),uv=[{target:'[data-guide="repo-switcher"]',title:"切换仓库",description:"点击这里可以在已注册的仓库之间快速切换。每个仓库拥有独立的 Agent 运行时和会话。",position:"bottom",section:"repos",padding:4},{target:'[data-guide="manage-repos"]',title:"管理仓库",description:"在仓库下拉菜单底部,点击「管理仓库」可以注册新仓库、启停 Agent 进程、配置运行时类型。",position:"bottom-right",section:"repos",padding:4,triggerClick:'[data-guide="repo-switcher"]'},{target:'[data-guide="repo-overflow-dropdown"]',title:"仓库高级操作",description:"每个仓库卡片的 ⋯ 菜单包含重要功能:切换运行时(OpenCode ↔ Claude Code)、开关 Worktree 任务隔离、编辑 AGENTS.md 配置。",position:"bottom-right",section:"repos",padding:4,route:"/repos",triggerClick:'[data-guide="repo-overflow-btn"]'},{target:'[data-guide="run-new-input"]',title:"新建对话",description:"选择 Agent 后输入指令开始任务。按 Tab 键可快速切换 Agent,底部可选择 Variant(默认 / max / high)控制推理强度。",position:"bottom",section:"run",padding:8,route:"run",mockScope:"run",setupFn:"clearActiveSession"},{target:'[data-guide="run-panel-handle"]',title:"运行记录面板",description:"拖动此手柄可收起/展开左侧运行记录列表。移动端可左右滑动打开。面板内可按「进行中 / 全部」筛选。",position:"bottom",section:"run",padding:6,mockScope:"run",setupFn:"clearActiveSession",mobileSwipeHint:"right"},{target:'[data-guide="run-input-bar"]',title:"快捷短语与追加输入",description:"对话进行中可在此追加指令。上方的快捷短语按钮(如「继续」)支持一键发送,可在设置 → 通用中自定义。底部可切换模型和 Variant。",position:"bottom",section:"run",padding:8,mockScope:"run",setupFn:"selectMockSession"},{target:'[data-guide="run-side-tabs"]',title:"右侧面板",description:"待办:Agent 的任务进度清单。输入:本次对话中你发送的所有消息。关联:Session 关联的 Issue 和 PR。子任务:Agent 派生的子 Session。",position:"bottom-right",section:"run",padding:6,mockScope:"run",setupFn:"selectMockSession",mobileSwipeHint:"left"},{target:'[data-guide="issue-sync-create"]',title:"同步与创建",description:"点击 ↻ 从 Git 平台同步 Issue 和 PR 数据(首次使用必须先同步)。点击 + 可直接创建新 Issue。",position:"bottom",section:"dev",padding:6,route:"dev/issues",mockScope:"dev"},{target:'[data-guide="issue-tag-filter"]',title:"标签筛选(三态)",description:"单击标签 → 包含筛选(高亮);再单击 → 排除筛选(划线);第三次单击 → 取消。支持同时选择多个标签组合筛选。",position:"bottom",section:"dev",padding:4,mockScope:"dev",triggerClick:'[data-guide="issue-tag-filter"]'},{target:'[data-guide="issue-actions"]',title:"Issue 操作",description:"查看源站、关闭/重新打开 Issue、新建 Agent 任务处理此 Issue。右侧面板按钮可展开运行记录侧边栏。",position:"bottom-right",section:"dev",padding:6,mockScope:"dev",setupFn:"selectMockIssue"},{target:'[data-guide="pr-actions"]',title:"PR 操作",description:"查看源站、合入 PR、解决冲突。当 PR 关联了 Issue 时,可选择合入并同时关闭关联的 Issues。",position:"bottom-right",section:"dev",padding:6,route:"dev/pulls",mockScope:"dev",setupFn:"selectMockPr"},{target:'[data-guide="agents-header"]',title:"创建与导入 Agent",description:"点击「创建」基于 base agent + 模型 + 提示词片段组合一个自定义 Agent。点击「导入」可从 JSON 文件恢复其他实例导出的 Agent。",position:"bottom-right",section:"agents",padding:6,route:"agents",mockScope:"agent"},{target:'[data-guide="agents-fragments"]',title:"提示词片段",description:"可复用的提示词模块,可在多个 Agent 间共享。创建 Agent 时选择片段并排序拼接顺序,构建最终的 System Prompt。",position:"bottom",section:"agents",padding:6,mockScope:"agent",triggerClick:'[data-guide="agents-fragments"]'},{target:'[data-guide="agent-detail-actions"]',title:"Agent 导出与共享",description:"下载或复制 Agent 的 JSON 配置,可在不同 Fourth Spark 实例间导入共享。包含提示词片段和所有配置。",position:"bottom-right",section:"agents",padding:4,route:"agents/__MOCK_AGENT__",mockScope:"agent"},{target:'[data-guide="agent-memory-section"]',title:"Agent 记忆",description:"Agent 在每次对话结束后自动提取经验记忆。每条记忆有分类标签和重要度评分(⚡)。系统定期自动整理:合并重复内容、衰减不活跃的记忆、强化反复验证的经验。",position:"bottom",section:"agents",padding:6,mockScope:"agent"},{target:'[data-guide="agent-memory-version"]',title:"记忆版本历史",description:"点击版本标签可查看这条记忆的完整演化轨迹:首次提取 → 内容重写 → 多条合并 → 反复验证后强化 → 长期未用后衰减。每个版本记录了当时的内容、重要度评分和触发动作。",position:"bottom",section:"agents",padding:4,mockScope:"agent"}];function OH(e){return e?uv.filter(t=>t.section===e):uv}function HI(e){if(e==="/repos"||e==="/settings")return"repos";const t=e.replace(/^\/[^/]+\//,"");return t.startsWith("run")?"run":t.startsWith("dev")?"dev":t.startsWith("agents")?"agents":null}let IH=0;const En=ai(e=>({toasts:[],addToast:(t,n="info",r,a)=>{const s=(a==null?void 0:a.id)??`toast-${++IH}-${Date.now()}`;e(o=>o.toasts.some(c=>c.id===s)?o:{toasts:[...o.toasts,{id:s,message:t,variant:n,sessionId:r,persistent:a==null?void 0:a.persistent}]}),a!=null&&a.persistent||setTimeout(()=>{e(o=>({toasts:o.toasts.filter(c=>c.id!==s)}))},4e3)},removeToast:t=>{e(n=>({toasts:n.toasts.filter(r=>r.id!==t)}))}})),Je=ai((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:n=>e({selectedIssueId:n}),setViewingIssue:(n,r)=>e({viewingIssueId:n,viewingTreeRootId:r??null}),enterMatchMode:n=>e({matchingParentId:n,matchingCandidateId:null}),exitMatchMode:()=>{e({matchingParentId:null,matchingCandidateId:null})},linkChild:async(n,r)=>{var s;const a=Fe.getState().activeRepoId;if(!a)return!1;try{await tH(a,n,r);const o=(s=t().issues.find(c=>c.number===n))==null?void 0:s.id;return o&&e(c=>({issues:c.issues.map(d=>d.number===r?{...d,parentId:o}:d),matchingCandidateId:null})),!0}catch{return!1}},updateIssueState:async(n,r)=>{const a=Fe.getState().activeRepoId;if(!a)return!1;try{const s=await UI(a,n,{state:r});return e(o=>({issues:o.issues.map(c=>c.number===n?{...c,state:s.state}:c)})),!0}catch{return!1}},loadIssues:async()=>{const n=Fe.getState().activeRepoId;if(!n){e({issues:[],loaded:!0});return}try{const r=await d2(n,"all");e({issues:r,loaded:!0})}catch{e({loaded:!0})}},syncIssues:async()=>{const n=Fe.getState().activeRepoId;if(n){e({syncing:!0});try{await Jz(n,"open");const[r,a,s]=await Promise.all([d2(n,"all"),u2(n),c2(n)]);e({issues:r,tags:a,milestones:s,syncing:!1})}catch(r){e({syncing:!1});let a="同步 Issue 失败";if(r instanceof ss)try{const s=JSON.parse(r.message);s.error&&(a=s.error)}catch{r.message&&(a=r.message)}En.getState().addToast(a,"error")}}},createIssue:async(n,r)=>{const a=Fe.getState().activeRepoId;if(!a)return null;try{const s=await eH(a,n,r);return e(o=>({issues:[s,...o.issues]})),s}catch{return null}},loadTags:async()=>{const n=Fe.getState().activeRepoId;if(!n){e({tags:[]});return}try{const r=await u2(n);e({tags:r})}catch{}},cycleTagFilter:n=>{e(r=>{const a=new Map(r.tagFilterMode),s=a.get(n);return s?s==="include"?a.set(n,"exclude"):a.delete(n):a.set(n,"include"),{tagFilterMode:a}})},clearTagFilter:()=>e({tagFilterMode:new Map}),loadMilestones:async()=>{const n=Fe.getState().activeRepoId;if(!n){e({milestones:[]});return}try{const r=await c2(n);e({milestones:r})}catch{}},setMilestoneFilter:n=>e({selectedMilestoneId:n})})),hn=ai((e,t)=>({pulls:[],loaded:!1,syncing:!1,selectedPrId:null,viewingPrId:null,matchingPrId:null,matchingCandidateIssueId:null,clearPulls:()=>e({pulls:[],loaded:!1,selectedPrId:null,viewingPrId:null,matchingPrId:null,matchingCandidateIssueId:null}),setViewingPr:n=>e({viewingPrId:n}),enterMatchMode:n=>e({matchingPrId:n,matchingCandidateIssueId:null}),exitMatchMode:()=>{const n=t().matchingPrId;e({matchingPrId:null,matchingCandidateIssueId:null,selectedPrId:n})},linkIssue:async(n,r)=>{const a=Fe.getState().activeRepoId;if(!a)return!1;try{return await sH(a,n,r),!0}catch{return!1}},unlinkIssue:async(n,r)=>{const a=Fe.getState().activeRepoId;if(!a)return!1;try{return await oH(a,n,r),!0}catch{return!1}},loadPulls:async()=>{const n=Fe.getState().activeRepoId;if(!n){e({pulls:[],loaded:!0});return}try{const r=await f2(n,"all");e({pulls:r,loaded:!0})}catch{e({loaded:!0})}},syncPulls:async()=>{const n=Fe.getState().activeRepoId;if(n){e({syncing:!0});try{await rH(n,"open");const r=await f2(n,"all");e({pulls:r,syncing:!1})}catch(r){e({syncing:!1});let a="同步 PR 失败";if(r instanceof ss)try{const s=JSON.parse(r.message);s.error&&(a=s.error)}catch{r.message&&(a=r.message)}En.getState().addToast(a,"error")}}}})),Pa=ai(e=>({agents:[],loaded:!1,loadAgents:async()=>{const t=Fe.getState().activeRepoId;try{const n=t?await PI(t):await jI();e({agents:n,loaded:!0})}catch{e({loaded:!0})}}})),RH=new Set(["tool","tool-use","tool_use","tool-call","tool_call","tool-result","tool_result"]),MH=new Set(["thinking","reasoning","reason"]),jH=new Set(["text","output_text","message"]),DH=new Set(["file","image"]);function gp(e){var n;const t=((n=e.type)==null?void 0:n.toLowerCase())??"";return RH.has(t)||e.toolName!=null||e.tool!=null?"tool":DH.has(t)?"file":MH.has(t)?"thinking":jH.has(t)||e.content!=null||e.text!=null?"text":"other"}function cv(e){return e.content??e.text??""}function $I(e){return e.toolName??e.tool??"tool"}function Tg(e){var t;return e.input??((t=e.state)==null?void 0:t.input)}function G1(e){var t;return e.output??((t=e.state)==null?void 0:t.output)}function K1(e){var n,r,a;const t=(r=(n=e.state)==null?void 0:n.status)==null?void 0:r.toLowerCase();return t==="completed"||t==="done"||t==="success"?"completed":t==="error"||t==="failed"||((a=e.state)==null?void 0:a.error)!=null?"error":t==="pending"||t==="queued"?"pending":t==="running"||t==="in_progress"?"running":G1(e)!=null?"completed":"running"}function x2(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function yl(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 YI(e){return e.filter(t=>yl(t.status)==="completed").length}function df(e){const t=$I(e).toLowerCase();return t==="question"||t==="mcp_question"}function LH(e){const t=Tg(e);if(!t||typeof t!="object")return null;const n=t;return Array.isArray(n.questions)?n.questions:null}function bp(e){if(!df(e))return!1;const t=K1(e);return t==="pending"||t==="running"}const PH=/\bses_[a-zA-Z0-9]+/;function BH(e){var a;const t=Tg(e);if(t&&typeof t=="object"){const s=t;if(typeof s.task_id=="string"&&s.task_id.startsWith("ses_"))return s.task_id}const n=(a=e.state)==null?void 0:a.metadata;if(n){const s=n.session_id??n.sessionId;if(typeof s=="string"&&s.startsWith("ses_"))return s}const r=G1(e);if(typeof r=="string"){const s=PH.exec(r);if(s)return s[0]}if(r&&typeof r=="object"){const s=r,o=s.session_id??s.sessionId??s.task_id;if(typeof o=="string"&&o.startsWith("ses_"))return o}return null}const UH=ai(()=>({agents:[],loaded:!1}));function qI(e){return`question-${e}`}function $x(e,t){const n=t.find(a=>a.id===e),r=(n==null?void 0:n.title)||e.slice(-8);En.getState().addToast(`${r} — 等待回复`,"warning",e,{id:qI(e),persistent:!0})}function FH(e){var t;for(const n of e)if((t=n.parts)!=null&&t.some(r=>df(r)&&bp(r)))return!0;return!1}const ff=[],hf=[],y2=[],$o={};function v2(e){return e.id??e.callID}function Dn(){return Fe.getState().activeRepoId}async function E2(e,t){const n=Dn();if(n)try{const[r,a]=await Promise.all([Bz(n,e),MI(n).catch(()=>null)]);t(s=>{const o={sessionLinks:{...s.sessionLinks,[e]:r}};return a&&(o.allSessionLinks=a),o})}catch{}}const N2=20,De=ai((e,t)=>({sessions:[],activeSessionId:null,messages:{},messagesMeta:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},sessionFilter:"active",sessionSearch:"",loadingSessions:!1,loadError:null,sendError:null,setSessionFilter:n=>e({sessionFilter:n}),setSessionSearch:n=>e({sessionSearch:n}),toggleSessionPin:async n=>{const r=Dn();if(!r)return;const a=t().sessions.find(o=>o.id===n);if(!a)return;const s=a.pinnedAt?null:Date.now();e(o=>({sessions:o.sessions.map(c=>c.id===n?{...c,pinnedAt:s??void 0}:c)}));try{await pH(r,n,s)}catch{await t().loadSessions()}},toggleSessionComplete:async n=>{const r=Dn();if(!r)return;const a=t().sessions.find(o=>o.id===n);if(!a)return;const s=a.completedAt?null:Date.now();e(o=>({sessions:o.sessions.map(c=>c.id===n?{...c,completedAt:s??void 0}:c)}));try{await mH(r,n,s)}catch{await t().loadSessions()}},loadSessions:async()=>{const n=Dn();if(!n){e({sessions:[],loadingSessions:!1});return}e({loadingSessions:!0,loadError:null});try{const[r,a]=await Promise.all([kz(n),MI(n).catch(()=>null)]);if(Dn()!==n)return;const s={sessions:r,loadingSessions:!1};a&&(s.allSessionLinks=a),e(s)}catch(r){if(Dn()!==n)return;e({loadingSessions:!1,loadError:r instanceof Error?r.message:"Failed to load sessions"})}},createSession:async(n,r,a,s,o,c,d)=>{const f=Dn();if(!f)return null;e({sendError:null});try{const m=await Oz(f,n,r,a,s,o,c,d);return e(p=>({sessions:[m,...p.sessions.filter(b=>b.id!==m.id)],activeSessionId:m.id,messages:{...p.messages,[m.id]:[]}})),t().setSessionStatus(m.id,"busy"),o&&En.getState().addToast("已自动分配为处理人","success"),m}catch(m){return e({sendError:m instanceof Error?m.message:"Failed to create session"}),null}},setActiveSession:async n=>{Dn()&&(e({activeSessionId:n,sendError:null}),await t().refreshSessionData(n))},refreshSessionData:async n=>{var m,p;const r=Dn();if(!r)return;const s=!t().messages[n]||t().messages[n].length===0?{limit:N2}:void 0,[o,c]=await Promise.allSettled([Uz(r,n),s2(r,n,s)]);if(Dn()!==r)return;const d=o.status==="fulfilled"?o.value:null,f=(p=(m=d==null?void 0:d.session)==null?void 0:m.revert)==null?void 0:p.messageID;e(b=>{const x={};if(d&&(d.status&&(x.sessionStatuses={...b.sessionStatuses,[n]:d.status.type}),d.todos&&(x.todos={...b.todos,[n]:d.todos}),d.links&&(x.sessionLinks={...b.sessionLinks,[n]:d.links}),d.session&&(x.sessions=b.sessions.map(E=>E.id===n?{...E,...d.session}:E))),c.status==="fulfilled"){let E=c.value.messages;if(f){const T=E.findIndex(S=>S.id===f);T>=0&&(E=E.slice(0,T+1))}const N=b.messages[n]??[];E.length>=N.length&&(x.messages={...b.messages,[n]:E}),x.messagesMeta={...b.messagesMeta,[n]:{total:Math.max(c.value.total,N.length),hasMore:c.value.hasMore,loading:!1}}}return x}),c.status==="fulfilled"&&FH(c.value.messages)&&$x(n,t().sessions)},loadMoreMessages:async n=>{var c;const r=Dn();if(!r)return;const a=t().messagesMeta[n];if(!(a!=null&&a.hasMore)||a.loading)return;const o=(c=(t().messages[n]??[])[0])==null?void 0:c.id;e(d=>({messagesMeta:{...d.messagesMeta,[n]:{...a,loading:!0}}}));try{const d=await s2(r,n,{limit:N2,before:o});e(f=>{const m=f.messages[n]??[];return{messages:{...f.messages,[n]:[...d.messages,...m]},messagesMeta:{...f.messagesMeta,[n]:{total:d.total,hasMore:d.hasMore,loading:!1}}}})}catch{e(d=>({messagesMeta:{...d.messagesMeta,[n]:{...a,loading:!1}}}))}},addLink:async(n,r,a)=>{const s=Dn();if(!s)return!1;try{return await Fz(s,n,r,a),await E2(n,e),!0}catch{return!1}},removeLink:async(n,r,a)=>{const s=Dn();if(!s)return!1;try{return await zz(s,n,r,a),await E2(n,e),!0}catch{return!1}},deleteSession:async n=>{const r=Dn();if(r)try{await Iz(r,n)}catch{}delete $o[n],e(a=>{const{[n]:s,...o}=a.messages,{[n]:c,...d}=a.messagesMeta,{[n]:f,...m}=a.todos,{[n]:p,...b}=a.sessionStatuses,{[n]:x,...E}=a.errorReasons,{[n]:N,...T}=a.queuedMessageIds,{[n]:S,...C}=a.sessionLinks,{[n]:A,...O}=a.allSessionLinks;return{sessions:a.sessions.filter(R=>R.id!==n),messages:o,messagesMeta:d,todos:m,sessionStatuses:b,errorReasons:E,queuedMessageIds:T,sessionLinks:C,allSessionLinks:O,activeSessionId:a.activeSessionId===n?null:a.activeSessionId}})},sendMessage:async(n,r,a,s)=>{const o=Dn(),c=t().activeSessionId;if(!o||!c)return!1;const d=t().sessions.find(m=>m.id===c),f=t().sessionStatuses[c]==="busy";e({sendError:null}),d!=null&&d.completedAt&&e(m=>({sessions:m.sessions.map(p=>p.id===c?{...p,completedAt:void 0}:p)})),f||t().setSessionStatus(c,"busy");try{const m=UH.getState(),p=d!=null&&d.agent&&m.loaded&&m.agents.some(b=>b.name===d.agent||b.id===d.agent)?d.agent:void 0;return await Rz(o,c,n,p,r,a,s),f&&($o[c]=($o[c]||0)+1),!0}catch(m){return e({sendError:m instanceof Error?m.message:"Failed to send message"}),f||t().setSessionStatus(c,"idle"),!1}},replyQuestion:async n=>{const r=Dn(),a=t().activeSessionId;if(!(!r||!a))try{await jz(r,a,n)}catch(s){e({sendError:s instanceof Error?s.message:"Failed to reply to question"})}},rejectQuestion:async()=>{const n=Dn(),r=t().activeSessionId;if(!(!n||!r))try{await Dz(n,r)}catch{}},abortSession:async()=>{const n=Dn(),r=t().activeSessionId;if(!(!n||!r)){try{await Mz(n,r)}catch{}t().setSessionStatus(r,"idle")}},clearSessions:()=>{for(const n of Object.keys($o))delete $o[n];e({sessions:[],activeSessionId:null,messages:{},messagesMeta:{},todos:{},sessionStatuses:{},errorReasons:{},queuedMessageIds:{},sessionLinks:{},allSessionLinks:{},sessionSearch:"",loadError:null,sendError:null})},updateMessage:(n,r)=>{var a;e(s=>{const o=s.messages[n]??[],c=o.findIndex(p=>p.id===r.id);let d,f=s.queuedMessageIds,m=s.messagesMeta;if(c>=0){const p={...o[c],...r};(!r.parts||r.parts.length===0)&&o[c].parts&&(p.parts=o[c].parts),d=[...o],d[c]=p}else{d=[...o,r];const p=m[n];p&&(m={...m,[n]:{...p,total:p.total+1}});const b=$o[n]||0;if(r.role==="user"&&b>0){const x=[...f[n]??[]];x.push(r.id),f={...f,[n]:x},$o[n]=b-1}else if(r.role==="assistant"){const x=f[n];x&&x.length>0&&(f={...f,[n]:x.slice(1)})}}return{messages:{...s.messages,[n]:d},messagesMeta:m,queuedMessageIds:f}}),(a=r.parts)!=null&&a.some(s=>df(s)&&bp(s))&&$x(n,t().sessions)},updateMessagePart:(n,r,a)=>{e(s=>{const o=s.messages[n]??[],c=o.findIndex(E=>E.id===r),d=c>=0?o[c]:{id:r,role:"assistant"},f=d.parts?[...d.parts]:[],m=v2(a),p=m!=null?f.findIndex(E=>v2(E)===m):-1;p>=0?f[p]={...f[p],...a}:f.push(a);const b={...d,parts:f},x=c>=0?[...o]:[...o,b];return c>=0&&(x[c]=b),{messages:{...s.messages,[n]:x}}}),df(a)&&bp(a)&&$x(n,t().sessions)},appendMessagePartDelta:(n,r,a,s)=>{e(o=>{const c=o.messages[n]??[],d=c.findIndex(E=>E.id===r),f=d>=0?c[d]:{id:r,role:"assistant"},m=f.parts?[...f.parts]:[],p=m.findIndex(E=>E.id===a);if(p>=0){const E=m[p],N=(E.content??E.text??"")+s;m[p]=E.content!=null?{...E,content:N}:{...E,text:N}}else m.push({id:a,type:"text",text:s});const b={...f,parts:m},x=d>=0?[...c]:[...c,b];return d>=0&&(x[d]=b),{messages:{...o.messages,[n]:x}}})},updateTodos:(n,r)=>{e(a=>({todos:{...a.todos,[n]:r}}))},updateSessionInfo:n=>{e(r=>r.sessions.some(s=>s.id===n.id)?{sessions:r.sessions.map(s=>s.id===n.id?{...s,...n}:s)}:{sessions:[n,...r.sessions]})},setSessionStatus:(n,r,a)=>{const s=t().sessionStatuses[n];if(s!==r){const o=t().sessions.find(d=>d.id===n),c=(o==null?void 0:o.title)||n.slice(-8);if(r==="idle"&&s!==void 0&&s!=="idle")En.getState().removeToast(qI(n)),En.getState().addToast(`${c} — 完成`,"success",n);else if(r==="busy"&&(s===void 0||s==="idle"))En.getState().addToast(`${c} — 开始运行`,"info",n);else if(r==="retry")En.getState().addToast(`${c} — 进入重试`,"warning",n);else if(r==="error"){const d=a?`${c} — 错误: ${a}`:`${c} — 发生错误`;En.getState().addToast(d,"error",n)}}e(o=>{const c=a?{...o.errorReasons,[n]:a}:r!=="error"?(()=>{const{[n]:d,...f}=o.errorReasons;return f})():o.errorReasons;return{sessionStatuses:{...o.sessionStatuses,[n]:r},errorReasons:c}})},bulkSetStatuses:n=>{e({sessionStatuses:{...t().sessionStatuses,...n}})},renameSession:async(n,r)=>{const a=Dn();if(a){e(s=>({sessions:s.sessions.map(o=>o.id===n?{...o,title:r}:o)}));try{await hH(a,n,r)}catch{await t().loadSessions()}}},revertToMessage:async(n,r)=>{const a=Dn();if(!a)return!1;try{return await Lz(a,n,r),await t().refreshSessionData(n),!0}catch{return!1}}})),ll="__guide__",Gt=Date.now(),xn=864e5,GI="guide-agent-",Hu=`${GI}1`,V1="guide-session-run-1",zH={id:V1,title:"示例对话:添加用户认证",agent:"Sisyphus",createdAt:new Date(Gt-36e5).toISOString(),time:{created:Gt-36e5,updated:Gt-6e5},cost:.12,tokens:{input:4200,output:1800,reasoning:320,cache:{read:800,write:200}}},KI=[{id:"guide-issue-1",repoId:ll,number:42,title:"添加用户认证模块",body:"实现 JWT 认证,包括登录、注册和 token 刷新。",state:"open",labels:[{id:1,name:"feature",color:"0075ca"}],htmlUrl:"#",authorLogin:"demo-user",createdAt:Gt-xn,updatedAt:Gt-36e5},{id:"guide-issue-2",repoId:ll,number:41,title:"修复登录页样式错位",body:"移动端登录表单在小屏幕下溢出。",state:"closed",labels:[{id:2,name:"bug",color:"d73a4a"}],htmlUrl:"#",authorLogin:"demo-user",createdAt:Gt-2*xn,updatedAt:Gt-xn}],VI=[{id:"guide-pr-1",repoId:ll,number:10,title:"feat: add auth module",body:"Implements JWT authentication.",state:"open",headBranch:"feat/auth",baseBranch:"main",labels:[{id:1,name:"feature",color:"0075ca"}],htmlUrl:"#",authorLogin:"demo-user",mergeable:"true",draft:0,commentCount:0,additions:320,deletions:12,changedFilesCount:8,createdAt:Gt-xn,updatedAt:Gt-36e5,mergedAt:null},{id:"guide-pr-2",repoId:ll,number:9,title:"fix: login page CSS overflow",state:"merged",headBranch:"fix/login-css",baseBranch:"main",draft:0,commentCount:1,additions:15,deletions:3,changedFilesCount:2,createdAt:Gt-2*xn,updatedAt:Gt-xn,mergedAt:Gt-xn}],HH=[{id:"guide-tag-1",repoId:ll,name:"bug",color:"d73a4a"},{id:"guide-tag-2",repoId:ll,name:"feature",color:"0075ca"},{id:"guide-tag-3",repoId:ll,name:"priority",color:"e4e669"}],$H={id:Hu,name:"示例 Agent",description:"用于功能引导的演示 Agent",baseAgent:"Sisyphus - ultraworker",model:null,variant:null,systemPrompt:"",systemPromptPosition:0,isSystem:0,memoryModel:null,fragments:[],repoId:null,sortOrder:999,createdAt:Gt-7*xn,updatedAt:Gt-xn},_2=[{id:"guide-mem-1",customAgentId:Hu,sessionId:"guide-session-1",mergedFrom:null,content:"用户偏好 TypeScript strict 模式,所有新文件必须启用 strictNullChecks",category:"编码规范",importance:.92,supersededBy:null,history:[{content:"用户使用 TypeScript",importance:.5,category:"编码规范",action:"create",ts:Gt-7*xn},{content:"用户偏好 TypeScript strict 模式",importance:.75,category:"编码规范",action:"update",ts:Gt-3*xn},{content:"用户偏好 TypeScript strict 模式,所有新文件必须启用 strictNullChecks",importance:.92,category:"编码规范",action:"reinforce",ts:Gt-xn}],createdAt:Gt-7*xn,updatedAt:Gt-xn},{id:"guide-mem-2",customAgentId:Hu,sessionId:"guide-session-2",mergedFrom:["guide-mem-old-1","guide-mem-old-2"],content:"项目使用 Tailwind CSS 4 + zustand 状态管理,组件优先使用函数式写法",category:"技术栈",importance:.85,supersededBy:null,history:[{content:"项目使用 Tailwind CSS",importance:.6,category:"技术栈",action:"create",ts:Gt-5*xn},{content:"项目使用 Tailwind CSS 4 + zustand 状态管理,组件优先使用函数式写法",importance:.85,category:"技术栈",action:"merge",ts:Gt-2*xn}],createdAt:Gt-5*xn,updatedAt:Gt-2*xn},{id:"guide-mem-3",customAgentId:Hu,sessionId:"guide-session-1",mergedFrom:null,content:"Git 提交信息使用 conventional commits 格式",category:"工作流",importance:.45,supersededBy:null,history:[{content:"Git 提交信息使用 conventional commits 格式",importance:.7,category:"工作流",action:"create",ts:Gt-10*xn},{content:"Git 提交信息使用 conventional commits 格式",importance:.45,category:"工作流",action:"decay",ts:Gt-4*xn}],createdAt:Gt-10*xn,updatedAt:Gt-4*xn}];let Kt=null;function YH(e){Kt&&(e!=="dev"&&(Je.setState({issues:Kt.issues,tags:Kt.tags,loaded:Kt.issueLoaded,viewingIssueId:null,viewingTreeRootId:null}),hn.setState({pulls:Kt.pulls,loaded:Kt.prLoaded,viewingPrId:null})),e!=="agent"&&Pa.setState({agents:Kt.agents}),e!=="run"&&De.setState({sessions:Kt.sessions,activeSessionId:Kt.activeSessionId}))}function qH(e){if(!Kt){const t=Je.getState(),n=hn.getState(),r=Pa.getState(),a=De.getState();Kt={issues:t.issues,tags:t.tags,issueLoaded:t.loaded,pulls:n.pulls,prLoaded:n.loaded,agents:r.agents,sessions:a.sessions,activeSessionId:a.activeSessionId}}if(YH(e),e==="run"){const t=Kt.sessions.some(n=>n.id===V1);De.setState({sessions:t?Kt.sessions:[...Kt.sessions,zH]})}else if(e==="dev")Je.setState({issues:KI,tags:HH,loaded:!0}),hn.setState({pulls:VI,loaded:!0});else if(e==="agent"){const t=Kt.agents.some(n=>n.id===Hu);Pa.setState({agents:t?Kt.agents:[...Kt.agents,$H]})}}function S2(){Kt&&(Je.setState({issues:Kt.issues,tags:Kt.tags,loaded:Kt.issueLoaded,viewingIssueId:null,viewingTreeRootId:null}),hn.setState({pulls:Kt.pulls,loaded:Kt.prLoaded,viewingPrId:null}),Pa.setState({agents:Kt.agents}),De.setState({sessions:Kt.sessions,activeSessionId:Kt.activeSessionId}),GH("id"),Kt=null)}function WI(e,t){const n=new URL(window.location.href);n.searchParams.set(e,t),window.history.replaceState(null,"",n.toString()),window.dispatchEvent(new PopStateEvent("popstate"))}function GH(e){const t=new URL(window.location.href);t.searchParams.has(e)&&(t.searchParams.delete(e),window.history.replaceState(null,"",t.toString()),window.dispatchEvent(new PopStateEvent("popstate")))}function KH(){const e=KI[0].id;Je.setState({viewingIssueId:e}),WI("id",e)}function VH(){const e=VI[0].id;hn.setState({viewingPrId:e}),WI("id",e)}function WH(){De.setState({activeSessionId:V1})}function XH(){De.setState({activeSessionId:null})}function QH(){return Hu}const ZH=6,T2=12,w2=200,A2=80,C2=288,k2=8,JH=768;function e$(e,t){const n=document.querySelector(e);if(!n)return null;const r=n.getBoundingClientRect();return r.width===0&&r.height===0||r.right<0||r.bottom<0||r.left>window.innerWidth||r.top>window.innerHeight?null:{top:r.top-t,left:r.left-t,width:r.width+t*2,height:r.height+t*2}}function t$(e){const{top:t,left:n,width:r,height:a}=e,s=n+r,o=t+a;return`polygon(
516
516
  0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%,
517
517
  ${n}px ${t}px, ${n}px ${o}px, ${s}px ${o}px, ${s}px ${t}px, ${n}px ${t}px
518
- )`}function n$(e,t){const n={position:"fixed"},r=window.innerWidth,a=window.innerHeight,s=e.top+e.height+T2,o=e.top-T2;let c=t==="bottom-right"?e.left+e.width-C2:e.left;return c=Math.max(k2,Math.min(c,r-C2-k2)),n.left=c,s+160<a?n.top=s:n.bottom=a-o,n}function Yx(e){const t=document.querySelector(e);t&&t.click()}const O2={selectMockIssue:KH,selectMockPr:VH,selectMockSession:WH,clearActiveSession:XH};function r$(){return window.innerWidth<JH}function a$({direction:e}){const t=e==="left"?Ng:pl;return u.jsx("div",{className:"pointer-events-none fixed inset-0 z-[9999] flex items-center justify-center",children:u.jsxs("div",{className:`flex items-center gap-1 rounded-full bg-blue-500/20 px-6 py-4 ${e==="left"?"fs-swipe-left":"fs-swipe-right"}`,children:[u.jsx(t,{className:"h-8 w-8 text-blue-400",strokeWidth:2.5}),u.jsx(t,{className:"h-8 w-8 text-blue-400/60",strokeWidth:2.5}),u.jsx(t,{className:"h-8 w-8 text-blue-400/30",strokeWidth:2.5})]})})}function i$({step:e,stepIdx:t,total:n,isFirst:r,isLast:a,onPrev:s,onNext:o,onClose:c}){return u.jsx("div",{className:"fixed inset-x-0 bottom-24 z-[10000] flex justify-center px-4",children:u.jsxs("div",{className:"w-72 rounded-xl border border-line bg-surface p-4 shadow-2xl",children:[u.jsx("button",{type:"button",onClick:c,className:"absolute right-2 top-2 rounded-md p-1 text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3","aria-label":"关闭引导",children:u.jsx(ct,{className:"h-3.5 w-3.5"})}),u.jsx("h3",{className:"pr-6 text-sm font-semibold text-fg",children:e.title}),u.jsx("p",{className:"mt-1.5 text-xs leading-relaxed text-fg-3",children:e.description}),u.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[u.jsxs("span",{className:"font-mono text-[11px] tabular-nums text-fg-5",children:[t+1," / ",n]}),u.jsxs("div",{className:"flex items-center gap-2",children:[!r&&u.jsx("button",{type:"button",onClick:s,className:"rounded-md px-3 py-1 text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"上一步"}),u.jsx("button",{type:"button",onClick:o,className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-500",children:a?"完成":"下一步"})]})]})]})})}function s$(){const e=$n(),t=Jn(),n=os(M=>M.guideTourOpen),r=os(M=>M.guideTourSection),a=os(M=>M.stopGuideTour),s=Fe(Br),[o,c]=y.useState(0),[d,f]=y.useState(null),m=y.useRef(null),p=y.useRef(-1),b=y.useRef(null),x=y.useMemo(()=>n?OH(r):uv,[n,r]),E=o<x.length?x[o]:void 0,N=x.length,T=o===0,S=o===N-1,C=y.useCallback(()=>{if(!n||!E)return;const M=E.padding??ZH;f(e$(E.target,M))},[n,E]),A=y.useCallback(M=>{const z=M.replace("__MOCK_AGENT__",QH());return z.startsWith("/")?z:s?`/${encodeURIComponent(s)}/${z}`:`/${z}`},[s]);y.useEffect(()=>{n&&(c(0),p.current=-1)},[n,r]),y.useEffect(()=>{if(!n||!E)return;const M=p.current,z=M>=0?x[M]:null;z!=null&&z.triggerClick&&document.querySelector(z.target)&&Yx(z.triggerClick);const G=(z==null?void 0:z.mockScope)??null,ae=E.mockScope??null;ae&&ae!==G?(qH(ae),b.current=ae):!ae&&b.current&&(S2(),b.current=null);const Z=E.route?A(E.route):null,W=Z&&!t.pathname.startsWith(Z);W&&e(Z);const H=setTimeout(()=>{E.setupFn&&O2[E.setupFn]&&O2[E.setupFn](),setTimeout(()=>{E.triggerClick&&!document.querySelector(E.target)&&Yx(E.triggerClick),setTimeout(C,A2)},E.setupFn?w2:0)},W?w2:ae&&ae!==G?A2:0);return p.current=o,()=>clearTimeout(H)},[n,o,E,e,t.pathname,C,A]),y.useLayoutEffect(()=>{C()},[C]),y.useEffect(()=>{if(n)return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[n,C]);const O=y.useRef(o);O.current=o;const R=y.useRef(x);R.current=x;const k=y.useCallback(()=>{const M=R.current[O.current];M!=null&&M.triggerClick&&document.querySelector(M.target)&&Yx(M.triggerClick),b.current&&(S2(),b.current=null),a()},[a]);if(y.useEffect(()=>{if(!n)return;const M=z=>{z.key==="Escape"&&k()};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[n,k]),!n||!E)return null;const D=r$()&&E.mobileSwipeHint&&!d;if(!d&&!D)return null;const B=()=>{T||c(M=>M-1)},j=()=>{S?k():c(M=>M+1)};return D?fp.createPortal(u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-[9998] bg-black/60",onClick:k}),u.jsx(a$,{direction:E.mobileSwipeHint}),u.jsx(i$,{step:E,stepIdx:o,total:N,isFirst:T,isLast:S,onPrev:B,onNext:j,onClose:k})]}),document.body):fp.createPortal(u.jsxs("div",{className:"fixed inset-0 z-[9999]",children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 transition-[clip-path] duration-200",style:{clipPath:t$(d)},onClick:k}),u.jsx("div",{className:"pointer-events-none absolute rounded-lg ring-2 ring-blue-500 ring-offset-2 ring-offset-transparent transition-all duration-200",style:{top:d.top,left:d.left,width:d.width,height:d.height}}),u.jsxs("div",{ref:m,className:"fixed z-[10000] w-72 rounded-xl border border-line bg-surface p-4 shadow-2xl",style:n$(d,E.position),children:[u.jsx("button",{type:"button",onClick:k,className:"absolute right-2 top-2 rounded-md p-1 text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3","aria-label":"关闭引导",children:u.jsx(ct,{className:"h-3.5 w-3.5"})}),u.jsx("h3",{className:"pr-6 text-sm font-semibold text-fg",children:E.title}),u.jsx("p",{className:"mt-1.5 text-xs leading-relaxed text-fg-3",children:E.description}),u.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[u.jsxs("span",{className:"font-mono text-[11px] tabular-nums text-fg-5",children:[o+1," / ",N]}),u.jsxs("div",{className:"flex items-center gap-2",children:[!T&&u.jsx("button",{type:"button",onClick:B,className:"rounded-md px-3 py-1 text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"上一步"}),u.jsx("button",{type:"button",onClick:j,className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-500",children:S?"完成":"下一步"})]})]})]})]}),document.body)}const XI=[{segment:"run",icon:z1,label:"运行面板",global:!1},{segment:"dev/issues",icon:O7,label:"研发",global:!1,matchPrefix:"dev"},{segment:"agents",icon:s7,label:"Agents",global:!1}];function QI(e,t,n){return t?`/${e}`:n?`/${encodeURIComponent(n)}/${e}`:`/${e}`}function ZI(e,t,n){if(!e.matchPrefix)return!1;const r=e.global?`/${e.matchPrefix}`:n?`/${encodeURIComponent(n)}/${e.matchPrefix}`:null;return r?t===r||t.startsWith(`${r}/`):!1}function o$(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function l$({repos:e,activeRepoId:t,onRepoChange:n}){const r=$n(),[a,s]=y.useState(!1),o=y.useRef(null),c=e.find(f=>f.id===t),d=y.useCallback(()=>s(!1),[]);return y.useEffect(()=>{if(!a)return;const f=m=>{o.current&&!o.current.contains(m.target)&&d()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[a,d]),u.jsxs("div",{ref:o,className:"relative",children:[u.jsxs("button",{type:"button","data-guide":"repo-switcher",onClick:()=>s(f=>!f),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:[u.jsx(xI,{className:"h-3 w-3 shrink-0 text-fg-4"}),u.jsxs("span",{className:"truncate",children:[u.jsx("span",{className:"sm:hidden",children:c?o$(c.name):""}),u.jsx("span",{className:"hidden sm:inline",children:(c==null?void 0:c.name)??""})]}),u.jsx(Nr,{className:re("h-3 w-3 shrink-0 text-fg-4 transition-transform",a&&"rotate-180")})]}),a&&u.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:[u.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:e.map(f=>u.jsxs("button",{type:"button",onClick:()=>{n(f.id),d()},className:re("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors",f.id===t?"font-medium text-blue-600":"text-fg-2 hover:bg-elevated"),children:[f.id===t?u.jsx(mr,{className:"h-3 w-3 shrink-0"}):u.jsx("span",{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"truncate",children:f.name})]},f.id))}),u.jsx("div",{className:"border-t border-line",children:u.jsxs("button",{type:"button","data-guide":"manage-repos",onClick:()=>{r("/repos"),d()},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:[u.jsx(Sg,{className:"h-3 w-3 shrink-0"}),u.jsx("span",{children:"管理仓库"})]})})]})]})}function u$({repoId:e,currentBranch:t}){const n=Fe(S=>S.updateRepoBranch),[r,a]=y.useState(!1),[s,o]=y.useState(null),[c,d]=y.useState(!1),[f,m]=y.useState(null),[p,b]=y.useState(null),x=y.useRef(null),E=y.useCallback(()=>{a(!1),b(null)},[]);y.useEffect(()=>{if(!r)return;const S=C=>{x.current&&!x.current.contains(C.target)&&E()};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[r,E]);const N=async()=>{if(r){E();return}a(!0),d(!0),b(null);try{o(await Ez(e))}catch{b("加载分支失败")}finally{d(!1)}},T=async S=>{if(!(S===t||f)){m(S),b(null);try{const C=await Nz(e,S);n(e,C.branch),E()}catch(C){b(C instanceof Error?C.message:"切换失败")}finally{m(null)}}};return t?u.jsxs("div",{ref:x,className:"relative",children:[u.jsxs("button",{type:"button",onClick:N,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:[u.jsx(Il,{className:"h-3 w-3"}),t,u.jsx(Nr,{className:re("h-3 w-3 transition-transform",r&&"rotate-180")})]}),r&&u.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:[c?u.jsx("div",{className:"flex items-center justify-center py-4",children:u.jsx(an,{className:"h-4 w-4 animate-spin text-fg-4"})}):s?u.jsxs("div",{className:"max-h-64 overflow-y-auto py-1",children:[s.local.map(S=>u.jsxs("button",{type:"button",disabled:f!==null,onClick:()=>T(S),className:re("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?u.jsx(mr,{className:"h-3 w-3 shrink-0"}):f===S?u.jsx(an,{className:"h-3 w-3 shrink-0 animate-spin"}):u.jsx("span",{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"truncate",children:S})]},S)),s.remote.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"mx-3 my-1 border-t border-line"}),u.jsx("div",{className:"px-3 py-1 text-[10px] font-medium uppercase tracking-wider text-fg-4",children:"Remote"}),s.remote.map(S=>u.jsxs("button",{type:"button",disabled:f!==null,onClick:()=>T(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:[f===S?u.jsx(an,{className:"h-3 w-3 shrink-0 animate-spin"}):u.jsx("span",{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"truncate",children:S})]},`remote-${S}`))]})]}):null,p&&u.jsx("div",{className:"border-t border-line px-3 py-2 text-xs text-red-500",children:p})]})]}):null}function c$(){const[e,t]=y.useState(null);return y.useEffect(()=>{const n=()=>fetch("/api/health").then(s=>s.json()).then(s=>{s.latestVersion&&s.latestVersion!=="0.11.22"&&t(s.latestVersion)}).catch(()=>{});n();const r=setInterval(n,30*6e4),a=()=>n();return window.addEventListener("focus",a),()=>{clearInterval(r),window.removeEventListener("focus",a)}},[]),e}function d$({navigate:e,cycle:t,themeLabel:n,ThemeIcon:r}){const[a,s]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{if(!a)return;const c=d=>{o.current&&!o.current.contains(d.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[a]),u.jsxs("div",{ref:o,className:"relative md:hidden",children:[u.jsx("button",{type:"button",onClick:()=>s(c=>!c),"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:u.jsx(B7,{className:"h-4 w-4"})}),a&&u.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1 w-40 overflow-hidden rounded-lg border border-line bg-surface shadow-lg",children:[u.jsxs("button",{type:"button",onClick:()=>{e("/analytics"),s(!1)},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx(Mf,{className:"h-3.5 w-3.5 text-fg-4"}),"统计"]}),u.jsxs("button",{type:"button",onClick:()=>{e("/settings"),s(!1)},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx(Sg,{className:"h-3.5 w-3.5 text-fg-4"}),"设置"]}),u.jsxs("button",{type:"button",onClick:()=>{t(),s(!1)},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx(r,{className:"h-3.5 w-3.5 text-fg-4"}),n]}),u.jsxs("a",{href:"https://github.com/kinminghao/fourth-spark",target:"_blank",rel:"noopener noreferrer",onClick:()=>s(!1),className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx("svg",{className:"h-3.5 w-3.5 text-fg-4",viewBox:"0 0 24 24",fill:"currentColor",children:u.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"})}),"GitHub"]}),u.jsxs("button",{type:"button",onClick:()=>{os.getState().startGuideTour(HI(window.location.pathname)),s(!1)},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx(yI,{className:"h-3.5 w-3.5 text-fg-4"}),"功能引导"]})]})]})}function f$(){const e=$n(),t=Jn(),n=Fe(p=>p.repos),r=Fe(p=>p.activeRepoId),a=Fe(p=>p.setActiveRepo),s=sv(p=>p.preference),o=sv(p=>p.cycle),c=s==="light"?QF:s==="dark"?OF:CF,d=n.find(p=>p.id===r),f=c$(),m=p=>{var N;if(!p)return;a(p);const b=n.find(T=>T.id===p);if(!b)return;const x=t.pathname.match(/\/dev\/(issues|pulls)/);if(x){e(`/${encodeURIComponent(b.name)}/dev/${x[1]}`);return}const E=((N=t.pathname.match(/\/(run|agents|issues|pulls)/))==null?void 0:N[1])??"run";e(`/${encodeURIComponent(b.name)}/${E}`)};return u.jsxs("header",{className:"shrink-0 border-b border-line bg-surface pt-[var(--safe-top)]",children:[u.jsxs("div",{className:"flex h-12 items-center justify-between px-4",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx(hc,{className:"h-5 w-5 text-blue-500"}),u.jsx("span",{className:"hidden text-sm font-bold tracking-tight text-fg sm:inline",children:"Fourth Spark"}),u.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.11.22"]}),f&&u.jsxs("span",{className:"hidden text-[10px] text-amber-500 sm:inline",children:["→ v",f," 可用,运行 ",u.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})]}),u.jsxs("div",{className:"flex items-center gap-3",children:[n.length>0&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(l$,{repos:n,activeRepoId:r,onRepoChange:m}),d&&r&&u.jsx(u$,{repoId:r,currentBranch:d.branch})]}),u.jsxs("div",{className:"hidden items-center gap-1 md:flex",children:[u.jsx("button",{type:"button",onClick:()=>e("/analytics"),"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:u.jsx(Mf,{className:"h-4 w-4"})}),u.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:u.jsx(Sg,{className:"h-4 w-4"})}),u.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:u.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:u.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"})})}),u.jsx("button",{type:"button",onClick:o,"aria-label":`主题: ${s}`,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:u.jsx(c,{className:"h-4 w-4"})}),u.jsx("button",{type:"button",onClick:()=>os.getState().startGuideTour(HI(t.pathname)),"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:u.jsx(yI,{className:"h-4 w-4"})})]}),u.jsx(d$,{navigate:e,cycle:o,themeLabel:`主题: ${s}`,ThemeIcon:c})]})]}),f&&u.jsx("div",{className:"border-t border-line px-4 py-1.5 sm:hidden",children:u.jsxs("span",{className:"text-[10px] text-amber-500",children:["→ v",f," 可用,运行 ",u.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})})]})}function h$(){const e=Fe(Br),t=os(a=>a.navCollapsed),n=os(a=>a.toggleNav),r=Jn();return u.jsxs("nav",{className:re("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:[u.jsx("div",{className:"flex flex-1 flex-col",children:XI.map(a=>{const s=ZI(a,r.pathname,e);return u.jsxs(dp,{to:QI(a.segment,a.global,e),title:t?a.label:void 0,className:({isActive:o})=>re("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",o||s?"bg-blue-500/10 font-medium text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:[u.jsx(a.icon,{className:"h-4 w-4 shrink-0"}),u.jsx("span",{className:re("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:a.label})]},a.segment)})}),u.jsxs(dp,{to:"/settings",title:t?"设置":void 0,className:({isActive:a})=>re("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",a?"bg-blue-500/10 font-medium text-blue-600":"text-fg-4 hover:bg-elevated hover:text-fg-2"),children:[u.jsx(Sg,{className:"h-4 w-4 shrink-0"}),u.jsx("span",{className:re("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:"设置"})]}),u.jsx("button",{type:"button",onClick:n,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?u.jsx(x7,{className:"h-4 w-4"}):u.jsx(g7,{className:"h-4 w-4"})})]})}function m$(){const e=Fe(Br),t=Jn();return u.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:u.jsx("div",{className:"flex h-14 items-center justify-around",children:XI.map(n=>{const r=ZI(n,t.pathname,e);return u.jsx(dp,{to:QI(n.segment,n.global,e),"aria-label":n.label,className:({isActive:a})=>re("flex h-10 w-10 items-center justify-center rounded-md transition-colors",a||r?"bg-blue-500/10 text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:u.jsx(n.icon,{className:"h-5 w-5 shrink-0"})},n.segment)})})})}function p$(){return u.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-base text-fg",children:[u.jsx(f$,{}),u.jsxs("div",{className:"flex min-h-0 flex-1",children:[u.jsx(h$,{}),u.jsx("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden pb-[calc(3.5rem_+_var(--safe-bottom))] md:pb-0",children:u.jsx(uU,{})})]}),u.jsx(m$,{}),u.jsx(s$,{})]})}const g$=/^[\w.-]+@([\w.-]+):([\w.-]+)\/([\w.-]+?)(?:\.git)?$/,b$=/^https?:\/\/([\w.-]+)(?::\d+)?\/([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:\/)?$/,x$=/^ssh:\/\/[\w.-]+@([\w.-]+)(?::\d+)?\/([\w.-]+)\/([\w.-]+?)(?:\.git)?$/;function JI(e){for(const t of[g$,b$,x$]){const n=e.match(t);if(n)return n[1]}return null}function I2({onSelect:e}){const[t,n]=y.useState(""),[r,a]=y.useState(null),[s,o]=y.useState([]),[c,d]=y.useState(!0),[f,m]=y.useState(""),[p,b]=y.useState(!1),x=y.useCallback(async A=>{d(!0),m("");try{const O=await gz(A,p);n(O.path),a(O.parent),o(O.entries)}catch(O){const R=O instanceof Error?O.message:"无法读取目录";try{const k=JSON.parse(R);m(k.error??R)}catch{m(R)}}d(!1)},[p]);y.useEffect(()=>{x()},[x]);const E=A=>{x(t+"/"+A)},N=()=>{r&&x(r)},T=A=>{const R="/"+t.split("/").filter(Boolean).slice(0,A+1).join("/");x(R)},S=A=>{e(t+"/"+A)},C=t.split("/").filter(Boolean);return u.jsxs("div",{className:"flex flex-col gap-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto text-xs",children:[u.jsx("button",{type:"button",onClick:()=>void x("/"),className:"shrink-0 rounded px-1 py-0.5 text-fg-4 hover:bg-elevated hover:text-fg-2",children:"/"}),C.map((A,O)=>u.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[u.jsx(pl,{className:"h-3 w-3 text-fg-5"}),u.jsx("button",{type:"button",onClick:()=>T(O),className:`rounded px-1 py-0.5 ${O===C.length-1?"font-medium text-fg":"text-fg-4 hover:bg-elevated hover:text-fg-2"}`,children:A})]},O))]}),u.jsx("button",{type:"button",onClick:()=>b(A=>!A),className:"ml-2 shrink-0 rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",title:p?"隐藏隐藏文件":"显示隐藏文件",children:p?u.jsx(SI,{className:"h-3.5 w-3.5"}):u.jsx(_I,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"max-h-52 overflow-y-auto rounded-lg border border-line bg-base",children:c?u.jsx("div",{className:"flex items-center justify-center py-8",children:u.jsx(an,{className:"h-4 w-4 animate-spin text-fg-4"})}):f?u.jsx("div",{className:"px-3 py-4 text-center text-xs text-red-500",children:f}):u.jsxs(u.Fragment,{children:[r!==null&&u.jsxs("button",{type:"button",onClick:N,className:"flex w-full items-center gap-2 border-b border-line px-3 py-2 text-left text-sm text-fg-3 hover:bg-elevated",children:[u.jsx(Zw,{className:"h-3.5 w-3.5 text-fg-5"}),u.jsx("span",{children:".."})]}),s.length===0&&u.jsx("div",{className:"px-3 py-4 text-center text-xs text-fg-5",children:"空目录"}),s.map(A=>u.jsxs("div",{className:"flex items-center border-b border-line last:border-0",children:[u.jsxs("button",{type:"button",onClick:()=>A.isGitRepo?S(A.name):E(A.name),className:"flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-sm hover:bg-elevated",children:[A.isGitRepo?u.jsx(Il,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):u.jsx(Zw,{className:"h-3.5 w-3.5 shrink-0 text-fg-4"}),u.jsx("span",{className:`truncate ${A.isGitRepo?"text-fg font-medium":"text-fg-3"}`,children:A.name}),A.isGitRepo&&u.jsx("span",{className:"ml-auto shrink-0 rounded bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-500",children:"git"})]}),A.isGitRepo&&u.jsx("button",{type:"button",onClick:()=>E(A.name),className:"shrink-0 px-2 py-2 text-fg-5 hover:text-fg-2",title:"进入目录",children:u.jsx(pl,{className:"h-3.5 w-3.5"})})]},A.name))]})})]})}function y$({onClose:e}){const t=$n(),[n,r]=y.useState("browse"),[a,s]=y.useState(""),[o,c]=y.useState(""),[d,f]=y.useState(""),[m,p]=y.useState(""),[b,x]=y.useState(!1),[E,N]=y.useState("opencode"),[T,S]=y.useState(!1),[C,A]=y.useState(!1),[O,R]=y.useState(""),[k,D]=y.useState(null),B=Fe(F=>F.addRepo),j=o.trim()!==""&&d.trim()!==""&&a.trim()!==""&&!T&&!C,M=F=>{const Y=F instanceof Error?F.message:"操作失败";try{return JSON.parse(Y).error??Y}catch{return Y}},z=async F=>{const Y=F.trim();if(Y){S(!0),R("");try{const L=await pz(Y);s(L.localPath),L.name&&c(L.name),L.gitUrl&&f(L.gitUrl)}catch(L){R(M(L))}S(!1)}},G=y.useRef(z);G.current=z,y.useEffect(()=>{if(n!=="browse")return;const F=a.trim();if(!F)return;const Y=setTimeout(()=>{G.current(F)},500);return()=>clearTimeout(Y)},[a,n]),y.useEffect(()=>{const F=d.trim();if(!F){D(null);return}const Y=JI(F);if(!Y){D(null);return}let L=!1;const $=setTimeout(()=>{q1().then(Q=>{if(L)return;const P=Q.some(he=>he.host.toLowerCase()===Y.toLowerCase());D(P?null:Y)}).catch(()=>{L||D(null)})},300);return()=>{L=!0,clearTimeout($)}},[d]);const ae=F=>{s(F),R(""),z(F)},Z=F=>{p(F),x(!1)},W=async()=>{const F=d.trim();if(!F){R("请输入 Git 仓库地址");return}A(!0),R("");try{const Y=m.trim()||void 0,L=await bz(F,Y);s(L.localPath),L.name&&c(L.name),L.gitUrl&&f(L.gitUrl)}catch(Y){R(M(Y))}A(!1)},K=async()=>{if(!j)return;R(""),await B(o.trim(),d.trim(),a.trim(),E)&&e()},H=F=>{r(F),s(""),c(""),f(""),p(""),x(!1),R(""),D(null)};return u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:e,children:u.jsxs("div",{className:"w-full max-w-lg rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:F=>F.stopPropagation(),children:[u.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[u.jsx("h2",{className:"text-base font-semibold text-fg",children:"添加仓库"}),u.jsx("button",{type:"button",onClick:e,className:"rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:u.jsx(ct,{className:"h-4 w-4"})})]}),u.jsxs("div",{className:"mb-4 flex gap-1 rounded-lg border border-line bg-base p-1",children:[u.jsxs("button",{type:"button",onClick:()=>H("browse"),className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${n==="browse"?"bg-elevated text-fg shadow-sm":"text-fg-4 hover:text-fg-2"}`,children:[u.jsx(G7,{className:"h-3.5 w-3.5"}),"已有仓库"]}),u.jsxs("button",{type:"button",onClick:()=>H("clone"),className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${n==="clone"?"bg-elevated text-fg shadow-sm":"text-fg-4 hover:text-fg-2"}`,children:[u.jsx(Il,{className:"h-3.5 w-3.5"}),"克隆新仓库"]})]}),u.jsxs("div",{className:"flex flex-col gap-4",children:[n==="browse"?u.jsxs(u.Fragment,{children:[u.jsx(I2,{onSelect:ae}),u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"m-path",className:"text-xs font-medium text-fg-3",children:"本地路径"}),u.jsx("input",{id:"m-path",value:a,onChange:F=>s(F.target.value),onBlur:F=>void z(F.target.value),placeholder:"/home/you/code/repo",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"}),u.jsx("span",{className:"text-[11px] text-fg-5",children:T?"正在读取 Git 信息…":"点选目录或手动输入路径"})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"m-clone-url",className:"text-xs font-medium text-fg-3",children:"Git 仓库地址"}),u.jsx("input",{id:"m-clone-url",value:d,onChange:F=>f(F.target.value),placeholder:"https://github.com/org/repo.git",autoFocus:!0,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"})]}),u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"text-xs font-medium text-fg-3",children:"目标目录"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{value:m,onChange:F=>p(F.target.value),placeholder:"默认: ~/.fourth-spark/repos/",className:"min-w-0 flex-1 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"}),u.jsx("button",{type:"button",onClick:()=>x(F=>!F),className:`shrink-0 rounded-lg border px-2.5 py-2 text-sm transition-colors ${b?"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:u.jsx(Nr,{className:`h-3.5 w-3.5 transition-transform ${b?"rotate-180":""}`})})]}),b&&u.jsx(I2,{onSelect:Z}),u.jsx("span",{className:"text-[11px] text-fg-5",children:"留空则克隆到默认目录,选择目录后仓库将克隆到该目录下"})]}),u.jsx("button",{type:"button",onClick:W,disabled:C||!d.trim(),className:"w-full rounded-lg bg-emerald-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-fg-6 disabled:text-fg-4",children:C?u.jsxs("span",{className:"flex items-center justify-center gap-1.5",children:[u.jsx(an,{className:"h-3.5 w-3.5 animate-spin"}),"正在克隆仓库…"]}):"克隆"}),a&&u.jsxs("div",{className:"rounded-md bg-emerald-500/10 px-3 py-2 text-xs text-emerald-600",children:["克隆完成: ",u.jsx("span",{className:"font-mono",children:a})]})]}),u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"m-name",className:"text-xs font-medium text-fg-3",children:"名称"}),u.jsx("input",{id:"m-name",value:o,onChange:F=>c(F.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"})]}),n==="browse"&&u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"m-git",className:"text-xs font-medium text-fg-3",children:"Git 远程地址"}),u.jsx("input",{id:"m-git",value:d,onChange:F=>f(F.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"})]}),k&&u.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[u.jsx(Cn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),u.jsxs("span",{children:["源站 ",u.jsx("strong",{children:k})," 尚未配置访问凭证,Issue/PR 同步将不可用。",u.jsx("button",{type:"button",onClick:()=>{e(),t("/settings")},className:"ml-1 font-medium underline hover:text-amber-700",children:"去配置"})]})]}),u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"text-xs font-medium text-fg-3",children:"运行时"}),u.jsx("div",{className:"flex gap-2",children:[{value:"opencode",label:"OpenCode"},{value:"claude-code",label:"Claude Code"}].map(F=>u.jsx("button",{type:"button",onClick:()=>N(F.value),className:`flex-1 rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${E===F.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:F.label},F.value))}),u.jsx("span",{className:"text-[11px] text-fg-5",children:E==="claude-code"?"需要本地安装 Claude Code CLI":"需要本地安装 OpenCode CLI"})]}),O&&u.jsx("p",{className:"rounded-md bg-red-500/10 px-3 py-2 text-xs text-red-500",children:O}),u.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[u.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:"取消"}),u.jsx("button",{type:"button",onClick:K,disabled:!j,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 v$({repoId:e,repoName:t,onClose:n}){const[r,a]=y.useState(""),[s,o]=y.useState(""),[c,d]=y.useState(!0),[f,m]=y.useState(!1),[p,b]=y.useState(null);y.useEffect(()=>{xH(e).then(N=>{a(N.content),o(N.content),d(!1)}).catch(N=>{b(N instanceof Error?N.message:String(N)),d(!1)})},[e]);const x=async()=>{m(!0),b(null);try{await yH(e,r),o(r)}catch(N){b(N instanceof Error?N.message:String(N))}m(!1)},E=r!==s;return u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:n,children:u.jsxs("div",{className:"flex w-full max-w-2xl flex-col rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:N=>N.stopPropagation(),children:[u.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("h2",{className:"text-base font-semibold text-fg",children:[t," — AGENTS.md"]}),u.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"仅对此仓库生效,修改后 opencode 热加载即时生效。"})]}),u.jsx("button",{type:"button",onClick:n,className:"shrink-0 rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:u.jsx(ct,{className:"h-4 w-4"})})]}),p&&u.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:[u.jsx(Cn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),u.jsx("span",{className:"min-w-0 break-words",children:p})]}),c?u.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[u.jsx(an,{className:"h-5 w-5 fs-spin"}),u.jsx("p",{className:"text-xs",children:"加载中…"})]}):u.jsx("textarea",{value:r,onChange:N=>a(N.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
518
+ )`}function n$(e,t){const n={position:"fixed"},r=window.innerWidth,a=window.innerHeight,s=e.top+e.height+T2,o=e.top-T2;let c=t==="bottom-right"?e.left+e.width-C2:e.left;return c=Math.max(k2,Math.min(c,r-C2-k2)),n.left=c,s+160<a?n.top=s:n.bottom=a-o,n}function Yx(e){const t=document.querySelector(e);t&&t.click()}const O2={selectMockIssue:KH,selectMockPr:VH,selectMockSession:WH,clearActiveSession:XH};function r$(){return window.innerWidth<JH}function a$({direction:e}){const t=e==="left"?Ng:pl;return u.jsx("div",{className:"pointer-events-none fixed inset-0 z-[9999] flex items-center justify-center",children:u.jsxs("div",{className:`flex items-center gap-1 rounded-full bg-blue-500/20 px-6 py-4 ${e==="left"?"fs-swipe-left":"fs-swipe-right"}`,children:[u.jsx(t,{className:"h-8 w-8 text-blue-400",strokeWidth:2.5}),u.jsx(t,{className:"h-8 w-8 text-blue-400/60",strokeWidth:2.5}),u.jsx(t,{className:"h-8 w-8 text-blue-400/30",strokeWidth:2.5})]})})}function i$({step:e,stepIdx:t,total:n,isFirst:r,isLast:a,onPrev:s,onNext:o,onClose:c}){return u.jsx("div",{className:"fixed inset-x-0 bottom-24 z-[10000] flex justify-center px-4",children:u.jsxs("div",{className:"w-72 rounded-xl border border-line bg-surface p-4 shadow-2xl",children:[u.jsx("button",{type:"button",onClick:c,className:"absolute right-2 top-2 rounded-md p-1 text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3","aria-label":"关闭引导",children:u.jsx(ct,{className:"h-3.5 w-3.5"})}),u.jsx("h3",{className:"pr-6 text-sm font-semibold text-fg",children:e.title}),u.jsx("p",{className:"mt-1.5 text-xs leading-relaxed text-fg-3",children:e.description}),u.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[u.jsxs("span",{className:"font-mono text-[11px] tabular-nums text-fg-5",children:[t+1," / ",n]}),u.jsxs("div",{className:"flex items-center gap-2",children:[!r&&u.jsx("button",{type:"button",onClick:s,className:"rounded-md px-3 py-1 text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"上一步"}),u.jsx("button",{type:"button",onClick:o,className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-500",children:a?"完成":"下一步"})]})]})]})})}function s$(){const e=$n(),t=Jn(),n=os(M=>M.guideTourOpen),r=os(M=>M.guideTourSection),a=os(M=>M.stopGuideTour),s=Fe(Br),[o,c]=y.useState(0),[d,f]=y.useState(null),m=y.useRef(null),p=y.useRef(-1),b=y.useRef(null),x=y.useMemo(()=>n?OH(r):uv,[n,r]),E=o<x.length?x[o]:void 0,N=x.length,T=o===0,S=o===N-1,C=y.useCallback(()=>{if(!n||!E)return;const M=E.padding??ZH;f(e$(E.target,M))},[n,E]),A=y.useCallback(M=>{const z=M.replace("__MOCK_AGENT__",QH());return z.startsWith("/")?z:s?`/${encodeURIComponent(s)}/${z}`:`/${z}`},[s]);y.useEffect(()=>{n&&(c(0),p.current=-1)},[n,r]),y.useEffect(()=>{if(!n||!E)return;const M=p.current,z=M>=0?x[M]:null;z!=null&&z.triggerClick&&document.querySelector(z.target)&&Yx(z.triggerClick);const G=(z==null?void 0:z.mockScope)??null,ae=E.mockScope??null;ae&&ae!==G?(qH(ae),b.current=ae):!ae&&b.current&&(S2(),b.current=null);const Z=E.route?A(E.route):null,W=Z&&!t.pathname.startsWith(Z);W&&e(Z);const H=setTimeout(()=>{E.setupFn&&O2[E.setupFn]&&O2[E.setupFn](),setTimeout(()=>{E.triggerClick&&!document.querySelector(E.target)&&Yx(E.triggerClick),setTimeout(C,A2)},E.setupFn?w2:0)},W?w2:ae&&ae!==G?A2:0);return p.current=o,()=>clearTimeout(H)},[n,o,E,e,t.pathname,C,A]),y.useLayoutEffect(()=>{C()},[C]),y.useEffect(()=>{if(n)return window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[n,C]);const O=y.useRef(o);O.current=o;const R=y.useRef(x);R.current=x;const k=y.useCallback(()=>{const M=R.current[O.current];M!=null&&M.triggerClick&&document.querySelector(M.target)&&Yx(M.triggerClick),b.current&&(S2(),b.current=null),a()},[a]);if(y.useEffect(()=>{if(!n)return;const M=z=>{z.key==="Escape"&&k()};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[n,k]),!n||!E)return null;const D=r$()&&E.mobileSwipeHint&&!d;if(!d&&!D)return null;const B=()=>{T||c(M=>M-1)},j=()=>{S?k():c(M=>M+1)};return D?fp.createPortal(u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-[9998] bg-black/60",onClick:k}),u.jsx(a$,{direction:E.mobileSwipeHint}),u.jsx(i$,{step:E,stepIdx:o,total:N,isFirst:T,isLast:S,onPrev:B,onNext:j,onClose:k})]}),document.body):fp.createPortal(u.jsxs("div",{className:"fixed inset-0 z-[9999]",children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 transition-[clip-path] duration-200",style:{clipPath:t$(d)},onClick:k}),u.jsx("div",{className:"pointer-events-none absolute rounded-lg ring-2 ring-blue-500 ring-offset-2 ring-offset-transparent transition-all duration-200",style:{top:d.top,left:d.left,width:d.width,height:d.height}}),u.jsxs("div",{ref:m,className:"fixed z-[10000] w-72 rounded-xl border border-line bg-surface p-4 shadow-2xl",style:n$(d,E.position),children:[u.jsx("button",{type:"button",onClick:k,className:"absolute right-2 top-2 rounded-md p-1 text-fg-5 transition-colors hover:bg-elevated hover:text-fg-3","aria-label":"关闭引导",children:u.jsx(ct,{className:"h-3.5 w-3.5"})}),u.jsx("h3",{className:"pr-6 text-sm font-semibold text-fg",children:E.title}),u.jsx("p",{className:"mt-1.5 text-xs leading-relaxed text-fg-3",children:E.description}),u.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[u.jsxs("span",{className:"font-mono text-[11px] tabular-nums text-fg-5",children:[o+1," / ",N]}),u.jsxs("div",{className:"flex items-center gap-2",children:[!T&&u.jsx("button",{type:"button",onClick:B,className:"rounded-md px-3 py-1 text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"上一步"}),u.jsx("button",{type:"button",onClick:j,className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white transition-colors hover:bg-blue-500",children:S?"完成":"下一步"})]})]})]})]}),document.body)}const XI=[{segment:"run",icon:z1,label:"运行面板",global:!1},{segment:"dev/issues",icon:O7,label:"研发",global:!1,matchPrefix:"dev"},{segment:"agents",icon:s7,label:"Agents",global:!1}];function QI(e,t,n){return t?`/${e}`:n?`/${encodeURIComponent(n)}/${e}`:`/${e}`}function ZI(e,t,n){if(!e.matchPrefix)return!1;const r=e.global?`/${e.matchPrefix}`:n?`/${encodeURIComponent(n)}/${e.matchPrefix}`:null;return r?t===r||t.startsWith(`${r}/`):!1}function o$(e){const t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function l$({repos:e,activeRepoId:t,onRepoChange:n}){const r=$n(),[a,s]=y.useState(!1),o=y.useRef(null),c=e.find(f=>f.id===t),d=y.useCallback(()=>s(!1),[]);return y.useEffect(()=>{if(!a)return;const f=m=>{o.current&&!o.current.contains(m.target)&&d()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[a,d]),u.jsxs("div",{ref:o,className:"relative",children:[u.jsxs("button",{type:"button","data-guide":"repo-switcher",onClick:()=>s(f=>!f),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:[u.jsx(xI,{className:"h-3 w-3 shrink-0 text-fg-4"}),u.jsxs("span",{className:"truncate",children:[u.jsx("span",{className:"sm:hidden",children:c?o$(c.name):""}),u.jsx("span",{className:"hidden sm:inline",children:(c==null?void 0:c.name)??""})]}),u.jsx(Nr,{className:re("h-3 w-3 shrink-0 text-fg-4 transition-transform",a&&"rotate-180")})]}),a&&u.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:[u.jsx("div",{className:"max-h-64 overflow-y-auto py-1",children:e.map(f=>u.jsxs("button",{type:"button",onClick:()=>{n(f.id),d()},className:re("flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors",f.id===t?"font-medium text-blue-600":"text-fg-2 hover:bg-elevated"),children:[f.id===t?u.jsx(mr,{className:"h-3 w-3 shrink-0"}):u.jsx("span",{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"truncate",children:f.name})]},f.id))}),u.jsx("div",{className:"border-t border-line",children:u.jsxs("button",{type:"button","data-guide":"manage-repos",onClick:()=>{r("/repos"),d()},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:[u.jsx(Sg,{className:"h-3 w-3 shrink-0"}),u.jsx("span",{children:"管理仓库"})]})})]})]})}function u$({repoId:e,currentBranch:t}){const n=Fe(S=>S.updateRepoBranch),[r,a]=y.useState(!1),[s,o]=y.useState(null),[c,d]=y.useState(!1),[f,m]=y.useState(null),[p,b]=y.useState(null),x=y.useRef(null),E=y.useCallback(()=>{a(!1),b(null)},[]);y.useEffect(()=>{if(!r)return;const S=C=>{x.current&&!x.current.contains(C.target)&&E()};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[r,E]);const N=async()=>{if(r){E();return}a(!0),d(!0),b(null);try{o(await Ez(e))}catch{b("加载分支失败")}finally{d(!1)}},T=async S=>{if(!(S===t||f)){m(S),b(null);try{const C=await Nz(e,S);n(e,C.branch),E()}catch(C){b(C instanceof Error?C.message:"切换失败")}finally{m(null)}}};return t?u.jsxs("div",{ref:x,className:"relative",children:[u.jsxs("button",{type:"button",onClick:N,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:[u.jsx(Il,{className:"h-3 w-3"}),t,u.jsx(Nr,{className:re("h-3 w-3 transition-transform",r&&"rotate-180")})]}),r&&u.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:[c?u.jsx("div",{className:"flex items-center justify-center py-4",children:u.jsx(an,{className:"h-4 w-4 animate-spin text-fg-4"})}):s?u.jsxs("div",{className:"max-h-64 overflow-y-auto py-1",children:[s.local.map(S=>u.jsxs("button",{type:"button",disabled:f!==null,onClick:()=>T(S),className:re("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?u.jsx(mr,{className:"h-3 w-3 shrink-0"}):f===S?u.jsx(an,{className:"h-3 w-3 shrink-0 animate-spin"}):u.jsx("span",{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"truncate",children:S})]},S)),s.remote.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"mx-3 my-1 border-t border-line"}),u.jsx("div",{className:"px-3 py-1 text-[10px] font-medium uppercase tracking-wider text-fg-4",children:"Remote"}),s.remote.map(S=>u.jsxs("button",{type:"button",disabled:f!==null,onClick:()=>T(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:[f===S?u.jsx(an,{className:"h-3 w-3 shrink-0 animate-spin"}):u.jsx("span",{className:"h-3 w-3 shrink-0"}),u.jsx("span",{className:"truncate",children:S})]},`remote-${S}`))]})]}):null,p&&u.jsx("div",{className:"border-t border-line px-3 py-2 text-xs text-red-500",children:p})]})]}):null}function c$(){const[e,t]=y.useState(null);return y.useEffect(()=>{const n=()=>fetch("/api/health").then(s=>s.json()).then(s=>{s.latestVersion&&s.latestVersion!=="0.11.24"&&t(s.latestVersion)}).catch(()=>{});n();const r=setInterval(n,30*6e4),a=()=>n();return window.addEventListener("focus",a),()=>{clearInterval(r),window.removeEventListener("focus",a)}},[]),e}function d$({navigate:e,cycle:t,themeLabel:n,ThemeIcon:r}){const[a,s]=y.useState(!1),o=y.useRef(null);return y.useEffect(()=>{if(!a)return;const c=d=>{o.current&&!o.current.contains(d.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[a]),u.jsxs("div",{ref:o,className:"relative md:hidden",children:[u.jsx("button",{type:"button",onClick:()=>s(c=>!c),"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:u.jsx(B7,{className:"h-4 w-4"})}),a&&u.jsxs("div",{className:"absolute right-0 top-full z-50 mt-1 w-40 overflow-hidden rounded-lg border border-line bg-surface shadow-lg",children:[u.jsxs("button",{type:"button",onClick:()=>{e("/analytics"),s(!1)},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx(Mf,{className:"h-3.5 w-3.5 text-fg-4"}),"统计"]}),u.jsxs("button",{type:"button",onClick:()=>{e("/settings"),s(!1)},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx(Sg,{className:"h-3.5 w-3.5 text-fg-4"}),"设置"]}),u.jsxs("button",{type:"button",onClick:()=>{t(),s(!1)},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx(r,{className:"h-3.5 w-3.5 text-fg-4"}),n]}),u.jsxs("a",{href:"https://github.com/kinminghao/fourth-spark",target:"_blank",rel:"noopener noreferrer",onClick:()=>s(!1),className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx("svg",{className:"h-3.5 w-3.5 text-fg-4",viewBox:"0 0 24 24",fill:"currentColor",children:u.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"})}),"GitHub"]}),u.jsxs("button",{type:"button",onClick:()=>{os.getState().startGuideTour(HI(window.location.pathname)),s(!1)},className:"flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs text-fg-2 transition-colors hover:bg-elevated",children:[u.jsx(yI,{className:"h-3.5 w-3.5 text-fg-4"}),"功能引导"]})]})]})}function f$(){const e=$n(),t=Jn(),n=Fe(p=>p.repos),r=Fe(p=>p.activeRepoId),a=Fe(p=>p.setActiveRepo),s=sv(p=>p.preference),o=sv(p=>p.cycle),c=s==="light"?QF:s==="dark"?OF:CF,d=n.find(p=>p.id===r),f=c$(),m=p=>{var N;if(!p)return;a(p);const b=n.find(T=>T.id===p);if(!b)return;const x=t.pathname.match(/\/dev\/(issues|pulls)/);if(x){e(`/${encodeURIComponent(b.name)}/dev/${x[1]}`);return}const E=((N=t.pathname.match(/\/(run|agents|issues|pulls)/))==null?void 0:N[1])??"run";e(`/${encodeURIComponent(b.name)}/${E}`)};return u.jsxs("header",{className:"shrink-0 border-b border-line bg-surface pt-[var(--safe-top)]",children:[u.jsxs("div",{className:"flex h-12 items-center justify-between px-4",children:[u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx(hc,{className:"h-5 w-5 text-blue-500"}),u.jsx("span",{className:"hidden text-sm font-bold tracking-tight text-fg sm:inline",children:"Fourth Spark"}),u.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.11.24"]}),f&&u.jsxs("span",{className:"hidden text-[10px] text-amber-500 sm:inline",children:["→ v",f," 可用,运行 ",u.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})]}),u.jsxs("div",{className:"flex items-center gap-3",children:[n.length>0&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(l$,{repos:n,activeRepoId:r,onRepoChange:m}),d&&r&&u.jsx(u$,{repoId:r,currentBranch:d.branch})]}),u.jsxs("div",{className:"hidden items-center gap-1 md:flex",children:[u.jsx("button",{type:"button",onClick:()=>e("/analytics"),"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:u.jsx(Mf,{className:"h-4 w-4"})}),u.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:u.jsx(Sg,{className:"h-4 w-4"})}),u.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:u.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 24 24",fill:"currentColor",children:u.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"})})}),u.jsx("button",{type:"button",onClick:o,"aria-label":`主题: ${s}`,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:u.jsx(c,{className:"h-4 w-4"})}),u.jsx("button",{type:"button",onClick:()=>os.getState().startGuideTour(HI(t.pathname)),"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:u.jsx(yI,{className:"h-4 w-4"})})]}),u.jsx(d$,{navigate:e,cycle:o,themeLabel:`主题: ${s}`,ThemeIcon:c})]})]}),f&&u.jsx("div",{className:"border-t border-line px-4 py-1.5 sm:hidden",children:u.jsxs("span",{className:"text-[10px] text-amber-500",children:["→ v",f," 可用,运行 ",u.jsx("code",{className:"rounded bg-amber-500/10 px-1 font-mono",children:"fourth-spark upgrade"})," 更新"]})})]})}function h$(){const e=Fe(Br),t=os(a=>a.navCollapsed),n=os(a=>a.toggleNav),r=Jn();return u.jsxs("nav",{className:re("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:[u.jsx("div",{className:"flex flex-1 flex-col",children:XI.map(a=>{const s=ZI(a,r.pathname,e);return u.jsxs(dp,{to:QI(a.segment,a.global,e),title:t?a.label:void 0,className:({isActive:o})=>re("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",o||s?"bg-blue-500/10 font-medium text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:[u.jsx(a.icon,{className:"h-4 w-4 shrink-0"}),u.jsx("span",{className:re("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:a.label})]},a.segment)})}),u.jsxs(dp,{to:"/settings",title:t?"设置":void 0,className:({isActive:a})=>re("mx-2 flex items-center rounded-md py-2 text-sm transition-colors",t?"justify-center px-2":"gap-2.5 px-3",a?"bg-blue-500/10 font-medium text-blue-600":"text-fg-4 hover:bg-elevated hover:text-fg-2"),children:[u.jsx(Sg,{className:"h-4 w-4 shrink-0"}),u.jsx("span",{className:re("truncate transition-[opacity,max-width] duration-200 ease-in-out",t?"max-w-0 opacity-0":"max-w-[8rem] opacity-100"),children:"设置"})]}),u.jsx("button",{type:"button",onClick:n,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?u.jsx(x7,{className:"h-4 w-4"}):u.jsx(g7,{className:"h-4 w-4"})})]})}function m$(){const e=Fe(Br),t=Jn();return u.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:u.jsx("div",{className:"flex h-14 items-center justify-around",children:XI.map(n=>{const r=ZI(n,t.pathname,e);return u.jsx(dp,{to:QI(n.segment,n.global,e),"aria-label":n.label,className:({isActive:a})=>re("flex h-10 w-10 items-center justify-center rounded-md transition-colors",a||r?"bg-blue-500/10 text-blue-600":"text-fg-3 hover:bg-elevated hover:text-fg"),children:u.jsx(n.icon,{className:"h-5 w-5 shrink-0"})},n.segment)})})})}function p$(){return u.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-base text-fg",children:[u.jsx(f$,{}),u.jsxs("div",{className:"flex min-h-0 flex-1",children:[u.jsx(h$,{}),u.jsx("main",{className:"flex min-w-0 flex-1 flex-col overflow-hidden pb-[calc(3.5rem_+_var(--safe-bottom))] md:pb-0",children:u.jsx(uU,{})})]}),u.jsx(m$,{}),u.jsx(s$,{})]})}const g$=/^[\w.-]+@([\w.-]+):([\w.-]+)\/([\w.-]+?)(?:\.git)?$/,b$=/^https?:\/\/([\w.-]+)(?::\d+)?\/([\w.-]+)\/([\w.-]+?)(?:\.git)?(?:\/)?$/,x$=/^ssh:\/\/[\w.-]+@([\w.-]+)(?::\d+)?\/([\w.-]+)\/([\w.-]+?)(?:\.git)?$/;function JI(e){for(const t of[g$,b$,x$]){const n=e.match(t);if(n)return n[1]}return null}function I2({onSelect:e}){const[t,n]=y.useState(""),[r,a]=y.useState(null),[s,o]=y.useState([]),[c,d]=y.useState(!0),[f,m]=y.useState(""),[p,b]=y.useState(!1),x=y.useCallback(async A=>{d(!0),m("");try{const O=await gz(A,p);n(O.path),a(O.parent),o(O.entries)}catch(O){const R=O instanceof Error?O.message:"无法读取目录";try{const k=JSON.parse(R);m(k.error??R)}catch{m(R)}}d(!1)},[p]);y.useEffect(()=>{x()},[x]);const E=A=>{x(t+"/"+A)},N=()=>{r&&x(r)},T=A=>{const R="/"+t.split("/").filter(Boolean).slice(0,A+1).join("/");x(R)},S=A=>{e(t+"/"+A)},C=t.split("/").filter(Boolean);return u.jsxs("div",{className:"flex flex-col gap-2",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto text-xs",children:[u.jsx("button",{type:"button",onClick:()=>void x("/"),className:"shrink-0 rounded px-1 py-0.5 text-fg-4 hover:bg-elevated hover:text-fg-2",children:"/"}),C.map((A,O)=>u.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[u.jsx(pl,{className:"h-3 w-3 text-fg-5"}),u.jsx("button",{type:"button",onClick:()=>T(O),className:`rounded px-1 py-0.5 ${O===C.length-1?"font-medium text-fg":"text-fg-4 hover:bg-elevated hover:text-fg-2"}`,children:A})]},O))]}),u.jsx("button",{type:"button",onClick:()=>b(A=>!A),className:"ml-2 shrink-0 rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",title:p?"隐藏隐藏文件":"显示隐藏文件",children:p?u.jsx(SI,{className:"h-3.5 w-3.5"}):u.jsx(_I,{className:"h-3.5 w-3.5"})})]}),u.jsx("div",{className:"max-h-52 overflow-y-auto rounded-lg border border-line bg-base",children:c?u.jsx("div",{className:"flex items-center justify-center py-8",children:u.jsx(an,{className:"h-4 w-4 animate-spin text-fg-4"})}):f?u.jsx("div",{className:"px-3 py-4 text-center text-xs text-red-500",children:f}):u.jsxs(u.Fragment,{children:[r!==null&&u.jsxs("button",{type:"button",onClick:N,className:"flex w-full items-center gap-2 border-b border-line px-3 py-2 text-left text-sm text-fg-3 hover:bg-elevated",children:[u.jsx(Zw,{className:"h-3.5 w-3.5 text-fg-5"}),u.jsx("span",{children:".."})]}),s.length===0&&u.jsx("div",{className:"px-3 py-4 text-center text-xs text-fg-5",children:"空目录"}),s.map(A=>u.jsxs("div",{className:"flex items-center border-b border-line last:border-0",children:[u.jsxs("button",{type:"button",onClick:()=>A.isGitRepo?S(A.name):E(A.name),className:"flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-sm hover:bg-elevated",children:[A.isGitRepo?u.jsx(Il,{className:"h-3.5 w-3.5 shrink-0 text-emerald-500"}):u.jsx(Zw,{className:"h-3.5 w-3.5 shrink-0 text-fg-4"}),u.jsx("span",{className:`truncate ${A.isGitRepo?"text-fg font-medium":"text-fg-3"}`,children:A.name}),A.isGitRepo&&u.jsx("span",{className:"ml-auto shrink-0 rounded bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-500",children:"git"})]}),A.isGitRepo&&u.jsx("button",{type:"button",onClick:()=>E(A.name),className:"shrink-0 px-2 py-2 text-fg-5 hover:text-fg-2",title:"进入目录",children:u.jsx(pl,{className:"h-3.5 w-3.5"})})]},A.name))]})})]})}function y$({onClose:e}){const t=$n(),[n,r]=y.useState("browse"),[a,s]=y.useState(""),[o,c]=y.useState(""),[d,f]=y.useState(""),[m,p]=y.useState(""),[b,x]=y.useState(!1),[E,N]=y.useState("opencode"),[T,S]=y.useState(!1),[C,A]=y.useState(!1),[O,R]=y.useState(""),[k,D]=y.useState(null),B=Fe(F=>F.addRepo),j=o.trim()!==""&&d.trim()!==""&&a.trim()!==""&&!T&&!C,M=F=>{const Y=F instanceof Error?F.message:"操作失败";try{return JSON.parse(Y).error??Y}catch{return Y}},z=async F=>{const Y=F.trim();if(Y){S(!0),R("");try{const L=await pz(Y);s(L.localPath),L.name&&c(L.name),L.gitUrl&&f(L.gitUrl)}catch(L){R(M(L))}S(!1)}},G=y.useRef(z);G.current=z,y.useEffect(()=>{if(n!=="browse")return;const F=a.trim();if(!F)return;const Y=setTimeout(()=>{G.current(F)},500);return()=>clearTimeout(Y)},[a,n]),y.useEffect(()=>{const F=d.trim();if(!F){D(null);return}const Y=JI(F);if(!Y){D(null);return}let L=!1;const $=setTimeout(()=>{q1().then(Q=>{if(L)return;const P=Q.some(he=>he.host.toLowerCase()===Y.toLowerCase());D(P?null:Y)}).catch(()=>{L||D(null)})},300);return()=>{L=!0,clearTimeout($)}},[d]);const ae=F=>{s(F),R(""),z(F)},Z=F=>{p(F),x(!1)},W=async()=>{const F=d.trim();if(!F){R("请输入 Git 仓库地址");return}A(!0),R("");try{const Y=m.trim()||void 0,L=await bz(F,Y);s(L.localPath),L.name&&c(L.name),L.gitUrl&&f(L.gitUrl)}catch(Y){R(M(Y))}A(!1)},K=async()=>{if(!j)return;R(""),await B(o.trim(),d.trim(),a.trim(),E)&&e()},H=F=>{r(F),s(""),c(""),f(""),p(""),x(!1),R(""),D(null)};return u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:e,children:u.jsxs("div",{className:"w-full max-w-lg rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:F=>F.stopPropagation(),children:[u.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[u.jsx("h2",{className:"text-base font-semibold text-fg",children:"添加仓库"}),u.jsx("button",{type:"button",onClick:e,className:"rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:u.jsx(ct,{className:"h-4 w-4"})})]}),u.jsxs("div",{className:"mb-4 flex gap-1 rounded-lg border border-line bg-base p-1",children:[u.jsxs("button",{type:"button",onClick:()=>H("browse"),className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${n==="browse"?"bg-elevated text-fg shadow-sm":"text-fg-4 hover:text-fg-2"}`,children:[u.jsx(G7,{className:"h-3.5 w-3.5"}),"已有仓库"]}),u.jsxs("button",{type:"button",onClick:()=>H("clone"),className:`flex flex-1 items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${n==="clone"?"bg-elevated text-fg shadow-sm":"text-fg-4 hover:text-fg-2"}`,children:[u.jsx(Il,{className:"h-3.5 w-3.5"}),"克隆新仓库"]})]}),u.jsxs("div",{className:"flex flex-col gap-4",children:[n==="browse"?u.jsxs(u.Fragment,{children:[u.jsx(I2,{onSelect:ae}),u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"m-path",className:"text-xs font-medium text-fg-3",children:"本地路径"}),u.jsx("input",{id:"m-path",value:a,onChange:F=>s(F.target.value),onBlur:F=>void z(F.target.value),placeholder:"/home/you/code/repo",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"}),u.jsx("span",{className:"text-[11px] text-fg-5",children:T?"正在读取 Git 信息…":"点选目录或手动输入路径"})]})]}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"m-clone-url",className:"text-xs font-medium text-fg-3",children:"Git 仓库地址"}),u.jsx("input",{id:"m-clone-url",value:d,onChange:F=>f(F.target.value),placeholder:"https://github.com/org/repo.git",autoFocus:!0,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"})]}),u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"text-xs font-medium text-fg-3",children:"目标目录"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("input",{value:m,onChange:F=>p(F.target.value),placeholder:"默认: ~/.fourth-spark/repos/",className:"min-w-0 flex-1 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"}),u.jsx("button",{type:"button",onClick:()=>x(F=>!F),className:`shrink-0 rounded-lg border px-2.5 py-2 text-sm transition-colors ${b?"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:u.jsx(Nr,{className:`h-3.5 w-3.5 transition-transform ${b?"rotate-180":""}`})})]}),b&&u.jsx(I2,{onSelect:Z}),u.jsx("span",{className:"text-[11px] text-fg-5",children:"留空则克隆到默认目录,选择目录后仓库将克隆到该目录下"})]}),u.jsx("button",{type:"button",onClick:W,disabled:C||!d.trim(),className:"w-full rounded-lg bg-emerald-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-emerald-500 disabled:cursor-not-allowed disabled:bg-fg-6 disabled:text-fg-4",children:C?u.jsxs("span",{className:"flex items-center justify-center gap-1.5",children:[u.jsx(an,{className:"h-3.5 w-3.5 animate-spin"}),"正在克隆仓库…"]}):"克隆"}),a&&u.jsxs("div",{className:"rounded-md bg-emerald-500/10 px-3 py-2 text-xs text-emerald-600",children:["克隆完成: ",u.jsx("span",{className:"font-mono",children:a})]})]}),u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"m-name",className:"text-xs font-medium text-fg-3",children:"名称"}),u.jsx("input",{id:"m-name",value:o,onChange:F=>c(F.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"})]}),n==="browse"&&u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{htmlFor:"m-git",className:"text-xs font-medium text-fg-3",children:"Git 远程地址"}),u.jsx("input",{id:"m-git",value:d,onChange:F=>f(F.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"})]}),k&&u.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-amber-500/10 px-3 py-2 text-xs text-amber-600",children:[u.jsx(Cn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),u.jsxs("span",{children:["源站 ",u.jsx("strong",{children:k})," 尚未配置访问凭证,Issue/PR 同步将不可用。",u.jsx("button",{type:"button",onClick:()=>{e(),t("/settings")},className:"ml-1 font-medium underline hover:text-amber-700",children:"去配置"})]})]}),u.jsxs("div",{className:"flex flex-col gap-1.5",children:[u.jsx("label",{className:"text-xs font-medium text-fg-3",children:"运行时"}),u.jsx("div",{className:"flex gap-2",children:[{value:"opencode",label:"OpenCode"},{value:"claude-code",label:"Claude Code"}].map(F=>u.jsx("button",{type:"button",onClick:()=>N(F.value),className:`flex-1 rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${E===F.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:F.label},F.value))}),u.jsx("span",{className:"text-[11px] text-fg-5",children:E==="claude-code"?"需要本地安装 Claude Code CLI":"需要本地安装 OpenCode CLI"})]}),O&&u.jsx("p",{className:"rounded-md bg-red-500/10 px-3 py-2 text-xs text-red-500",children:O}),u.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[u.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:"取消"}),u.jsx("button",{type:"button",onClick:K,disabled:!j,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 v$({repoId:e,repoName:t,onClose:n}){const[r,a]=y.useState(""),[s,o]=y.useState(""),[c,d]=y.useState(!0),[f,m]=y.useState(!1),[p,b]=y.useState(null);y.useEffect(()=>{xH(e).then(N=>{a(N.content),o(N.content),d(!1)}).catch(N=>{b(N instanceof Error?N.message:String(N)),d(!1)})},[e]);const x=async()=>{m(!0),b(null);try{await yH(e,r),o(r)}catch(N){b(N instanceof Error?N.message:String(N))}m(!1)},E=r!==s;return u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:n,children:u.jsxs("div",{className:"flex w-full max-w-2xl flex-col rounded-xl border border-line bg-surface p-6 shadow-2xl",onClick:N=>N.stopPropagation(),children:[u.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsxs("h2",{className:"text-base font-semibold text-fg",children:[t," — AGENTS.md"]}),u.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"仅对此仓库生效,修改后 opencode 热加载即时生效。"})]}),u.jsx("button",{type:"button",onClick:n,className:"shrink-0 rounded-md p-1 text-fg-4 hover:bg-elevated hover:text-fg-2",children:u.jsx(ct,{className:"h-4 w-4"})})]}),p&&u.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:[u.jsx(Cn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),u.jsx("span",{className:"min-w-0 break-words",children:p})]}),c?u.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[u.jsx(an,{className:"h-5 w-5 fs-spin"}),u.jsx("p",{className:"text-xs",children:"加载中…"})]}):u.jsx("textarea",{value:r,onChange:N=>a(N.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
519
519
 
520
520
  在此编写该仓库的 Agent 指令…`}),u.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[u.jsx("button",{type:"button",onClick:n,className:"rounded-lg border border-line px-4 py-2 text-sm text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"关闭"}),u.jsxs("button",{type:"button",onClick:()=>void x(),disabled:f||!E,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:[u.jsx(jf,{className:"h-3.5 w-3.5"}),f?"保存中…":"保存"]})]})]})})}const dv=1024,fv=dv*1024,R2=fv*1024;function M2(e){return!e||e<=0?"0 B":e<dv?`${e} B`:e<fv?`${(e/dv).toFixed(1)} KB`:e<R2?`${(e/fv).toFixed(1)} MB`:`${(e/R2).toFixed(2)} GB`}const qx="ws/";function E$({repoId:e}){const[t,n]=y.useState(!1),[r,a]=y.useState(null),[s,o]=y.useState(!1),[c,d]=y.useState(null),[f,m]=y.useState(null),[p,b]=y.useState(!1),x=async()=>{o(!0),d(null);try{const C=await Sz(e);a(C)}catch(C){d(C instanceof ss?C.message:"加载失败")}o(!1)};y.useEffect(()=>{t&&r===null&&x()},[t]);const E=async C=>{m(C);try{await Tz(e,C),await x()}catch(A){d(A instanceof ss?A.message:"删除失败")}m(null)},N=async()=>{b(!0);try{await wz(e),await x()}catch(C){d(C instanceof ss?C.message:"清理失败")}b(!1)},T=(r==null?void 0:r.length)??0,S=(r==null?void 0:r.reduce((C,A)=>C+(A.diskUsage||0),0))??0;return u.jsxs("div",{className:"mt-3 border-t border-line pt-3",children:[u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsxs("button",{type:"button",onClick:()=>n(C=>!C),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?u.jsx(D1,{className:"h-3 w-3 shrink-0"}):u.jsx(Nr,{className:"h-3 w-3 shrink-0"}),u.jsx(Il,{className:"h-3 w-3 shrink-0 text-fg-5"}),u.jsx("span",{children:"工作空间"}),r!==null&&u.jsxs("span",{className:"text-fg-5",children:["(",T,") · ",M2(S)]})]}),t&&T>0&&u.jsxs("button",{type:"button",onClick:()=>void N(),disabled:p,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:[p?u.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):null,"清理已合并"]})]}),t&&u.jsxs("div",{className:"mt-2",children:[c&&u.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:[u.jsx("span",{className:"truncate",children:c}),u.jsx("button",{type:"button",onClick:()=>d(null),className:"shrink-0 rounded p-0.5 transition-colors hover:bg-red-500/10",children:u.jsx(ct,{className:"h-3 w-3"})})]}),s&&r===null?u.jsx("div",{className:"flex justify-center py-3",children:u.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-fg-5 border-t-transparent"})}):T===0?u.jsx("p",{className:"py-2 text-center text-xs text-fg-5",children:"暂无工作空间"}):u.jsx("ul",{className:"space-y-1",children:r==null?void 0:r.map(C=>{const A=C.branch.startsWith(qx),O=A?C.branch.slice(qx.length):C.branch,R=C.status==="active"?"bg-emerald-500/10 text-emerald-600":C.status==="idle"?"bg-amber-500/10 text-amber-600":"bg-fg-6/30 text-fg-4",k=C.status==="active"?"活跃":C.status==="idle"?"空闲":C.status==="merged"?"已合并":C.status==="stale"?"陈旧":C.status,D=C.status!=="active";return u.jsxs("li",{className:"flex items-center gap-2 rounded-md border border-line bg-elevated/40 px-2 py-1.5 text-xs",children:[u.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[C.running&&C.port&&u.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500",title:`运行中 :${C.port}`}),u.jsxs("span",{className:"min-w-0 truncate font-mono",children:[A&&u.jsx("span",{className:"text-fg-5",children:qx}),u.jsx("span",{className:"text-fg-2",children:O})]})]}),u.jsx("span",{className:re("shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium",R),children:k}),u.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-fg-5",children:[u.jsx(aF,{className:"h-2.5 w-2.5"}),M2(C.diskUsage)]}),u.jsx("button",{type:"button",onClick:()=>void E(C.id),disabled:!D||f===C.id,title:D?"删除工作空间":"活跃工作空间无法删除",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:f===C.id?u.jsx("span",{className:"inline-block h-2.5 w-2.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):u.jsx(wi,{className:"h-3 w-3"})})]},C.id)})})]})]})}function eR(){const e=$n(),t=Fe(j=>j.repos),n=Fe(j=>j.activeRepoId),r=Fe(j=>j.setActiveRepo),a=Fe(j=>j.removeRepo),s=Fe(j=>j.loadRepos),[o,c]=y.useState(!1),[d,f]=y.useState(null),[m,p]=y.useState(null),[b,x]=y.useState(null),E=En(j=>j.addToast),[N,T]=y.useState(null),[S,C]=y.useState(null),A=y.useRef(null),[O,R]=y.useState(null);y.useEffect(()=>{q1().then(j=>R(new Set(j.map(M=>M.host.toLowerCase())))).catch(()=>{})},[]);const k=y.useMemo(()=>{if(!O)return new Set;const j=new Set;for(const M of t){const z=JI(M.gitUrl);z&&!O.has(z.toLowerCase())&&j.add(M.id)}return j},[t,O]);y.useEffect(()=>{if(!S)return;const j=M=>{A.current&&!A.current.contains(M.target)&&C(null)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[S]);const D=async(j,M)=>{p(j);try{M?await vz(j):await yz(j),await s()}catch{}p(null)},B=async j=>{x(j);try{const M=await _z(j);await s();const z=M.alreadyUpToDate?"info":"success";E(M.summary,z,void 0,{persistent:!0})}catch(M){let z="拉取失败";if(M instanceof ss)try{z=JSON.parse(M.message).error??M.message}catch{z=M.message}E(z,"error",void 0,{persistent:!0})}x(null)};return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"mb-6 flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h1",{className:"text-lg font-semibold text-fg",children:"仓库管理"}),u.jsx("p",{className:"mt-0.5 text-sm text-fg-4",children:"管理代码仓库,每个仓库对应一个独立的 Agent 运行环境"})]}),u.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:[u.jsx(ta,{className:"h-4 w-4"}),u.jsx("span",{className:"hidden md:inline",children:"添加仓库"})]})]}),t.length===0?u.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed border-line-hard py-16 text-center",children:[u.jsx("div",{className:"rounded-full bg-elevated p-3",children:u.jsx(ta,{className:"h-6 w-6 text-fg-4"})}),u.jsx("p",{className:"text-sm font-medium text-fg-3",children:"暂无代码仓库"}),u.jsx("p",{className:"text-xs text-fg-5",children:"添加一个本地仓库开始使用"}),u.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:"添加仓库"})]}):u.jsx(u.Fragment,{children:u.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:t.map((j,M)=>{const z=j.id===n;return u.jsxs("div",{className:re("rounded-xl border p-4 transition-colors",z?"border-blue-500/40 bg-blue-500/5":"border-line"),children:[u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsxs("button",{type:"button",onClick:()=>r(j.id),className:"flex min-w-0 items-center gap-2 text-left",children:[z?u.jsx(Ol,{className:"h-4 w-4 shrink-0 text-blue-500"}):u.jsx(S7,{className:"h-4 w-4 shrink-0 text-fg-5"}),u.jsx("span",{className:re("truncate font-medium",z?"text-fg":"text-fg-2"),children:j.name})]}),u.jsxs("span",{className:re("inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium",j.running?"bg-emerald-500/10 text-emerald-600":"bg-fg-6/30 text-fg-4"),children:[u.jsx("span",{className:re("h-1.5 w-1.5 rounded-full",j.running?"bg-emerald-500":"bg-fg-5")}),j.running?"运行中":"已停止"]})]}),u.jsxs("dl",{className:"mt-3 space-y-1 font-mono text-xs text-fg-4",children:[u.jsxs("div",{className:"flex gap-2",children:[u.jsx("dt",{className:"shrink-0 text-fg-5",children:"Git"}),u.jsx("dd",{className:"min-w-0 truncate",children:j.gitUrl})]}),u.jsxs("div",{className:"flex gap-2",children:[u.jsx("dt",{className:"shrink-0 text-fg-5",children:"路径"}),u.jsxs("dd",{className:"flex min-w-0 items-center gap-1.5",children:[u.jsx("span",{className:"truncate",children:j.localPath}),u.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(j.localPath),title:"复制路径",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:u.jsx(hp,{className:"h-3 w-3"})})]})]}),j.running&&j.port&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("dt",{className:"shrink-0 text-fg-5",children:"直连"}),u.jsxs("dd",{className:"flex min-w-0 items-center gap-1.5",children:[u.jsxs("a",{href:`http://127.0.0.1:${j.port}`,target:"_blank",rel:"noopener noreferrer",className:"truncate text-blue-500 hover:underline",children:["127.0.0.1:",j.port]}),u.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(`http://127.0.0.1:${j.port}`),title:"复制链接",className:"shrink-0 rounded p-0.5 text-fg-5 transition-colors hover:text-fg-3",children:u.jsx(hp,{className:"h-3 w-3"})})]})]})]}),k.has(j.id)&&u.jsxs("button",{type:"button",onClick:()=>e("/settings"),className:"mt-2 flex w-full items-center gap-1.5 rounded-md bg-amber-500/10 px-2.5 py-1.5 text-left text-xs text-amber-600 transition-colors hover:bg-amber-500/15",children:[u.jsx(Cn,{className:"h-3.5 w-3.5 shrink-0"}),u.jsx("span",{children:"缺少 Git 源站凭证,Issue/PR 同步不可用"})]}),u.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[u.jsx("button",{type:"button",onClick:()=>void B(j.id),disabled:b===j.id,className:"flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-md border border-blue-500/30 px-2.5 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-500/10 disabled:opacity-50",children:b===j.id?u.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):u.jsxs(u.Fragment,{children:[u.jsx(ZU,{className:"h-3 w-3"}),"拉取"]})}),u.jsx("button",{type:"button",onClick:()=>void D(j.id,j.running),disabled:m===j.id,className:re("flex h-8 flex-1 items-center justify-center gap-1.5 rounded-md border text-xs font-medium transition-colors disabled:opacity-50",j.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:m===j.id?u.jsx("span",{className:"inline-block h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"}):j.running?u.jsxs(u.Fragment,{children:[u.jsx(iv,{className:"h-3 w-3 fill-current"}),"停止"]}):u.jsxs(u.Fragment,{children:[u.jsx(z1,{className:"h-3 w-3 fill-current"}),"启动"]})}),u.jsxs("div",{className:"relative",ref:S===j.id?A:void 0,children:[u.jsx("button",{type:"button","data-guide":M===0?"repo-overflow-btn":void 0,onClick:()=>C(S===j.id?null:j.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:u.jsx(L1,{className:"h-4 w-4"})}),S===j.id&&u.jsxs("div",{"data-guide":M===0?"repo-overflow-dropdown":void 0,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:[u.jsx("button",{type:"button",className:re("flex w-full items-center gap-2 px-3 py-2 text-left text-xs transition-colors hover:bg-base/60",j.runtimeType==="claude-code"?"text-orange-500":"text-sky-500"),onClick:async()=>{C(null);const G=j.runtimeType==="claude-code"?"opencode":"claude-code";await Cz(j.id,G),s()},children:j.runtimeType==="claude-code"?"Claude → OpenCode":"OpenCode → Claude"}),u.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()=>{C(null),await Az(j.id,!j.worktreeEnabled),s()},children:[u.jsx(Il,{className:"h-3 w-3"}),u.jsx("span",{children:"Worktree"}),u.jsx("span",{className:re("ml-auto text-[10px]",j.worktreeEnabled?"text-violet-500":"text-fg-5"),children:j.worktreeEnabled?"已开启":"已关闭"})]}),u.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:()=>{C(null),T({id:j.id,name:j.name})},children:[u.jsx(po,{className:"h-3 w-3"}),"配置"]}),u.jsx("div",{className:"my-0.5 border-t border-line"}),u.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:()=>{C(null),f(j.id)},children:[u.jsx(wi,{className:"h-3 w-3"}),"删除仓库"]})]})]})]}),d===j.id&&u.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:[u.jsx("span",{className:"text-xs text-red-500",children:"确认删除此仓库?"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("button",{type:"button",onClick:()=>{a(j.id),f(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:[u.jsx(mr,{className:"h-3 w-3"}),"确认"]}),u.jsx("button",{type:"button",onClick:()=>f(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:"取消"})]})]}),j.worktreeEnabled&&u.jsx(E$,{repoId:j.id})]},j.id)})})}),u.jsxs("p",{className:"mt-3 text-xs text-fg-5",children:[t.length," 个仓库"]}),o&&u.jsx(y$,{onClose:()=>c(!1)}),N&&u.jsx(v$,{repoId:N.id,repoName:N.name,onClose:()=>T(null)})]})}function N$(){return u.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:u.jsx("div",{className:"mx-auto max-w-4xl",children:u.jsx(eR,{})})})}function j2(e){const t=[],n=String(e||"");let r=n.indexOf(","),a=0,s=!1;for(;!s;){r===-1&&(r=n.length,s=!0);const o=n.slice(a,r).trim();(o||!s)&&t.push(o),a=r+1,r=n.indexOf(",",a)}return t}function tR(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const _$=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,S$=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,T$={};function D2(e,t){return(T$.jsx?S$:_$).test(e)}const w$=/[ \t\n\f\r]/g;function A$(e){return typeof e=="object"?e.type==="text"?L2(e.value):!1:L2(e)}function L2(e){return e.replace(w$,"")===""}class Lf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Lf.prototype.normal={};Lf.prototype.property={};Lf.prototype.space=void 0;function nR(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Lf(n,r,t)}function mf(e){return e.toLowerCase()}class ra{constructor(t,n){this.attribute=n,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 C$=0;const it=Rl(),Ln=Rl(),hv=Rl(),Oe=Rl(),qt=Rl(),ul=Rl(),pa=Rl();function Rl(){return 2**++C$}const mv=Object.freeze(Object.defineProperty({__proto__:null,boolean:it,booleanish:Ln,commaOrSpaceSeparated:pa,commaSeparated:ul,number:Oe,overloadedBoolean:hv,spaceSeparated:qt},Symbol.toStringTag,{value:"Module"})),Gx=Object.keys(mv);class W1 extends ra{constructor(t,n,r,a){let s=-1;if(super(t,n),P2(this,"space",a),typeof r=="number")for(;++s<Gx.length;){const o=Gx[s];P2(this,Gx[s],(r&mv[o])===mv[o])}}}W1.prototype.defined=!0;function P2(e,t,n){n&&(e[t]=n)}function mc(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new W1(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[mf(r)]=r,n[mf(s.attribute)]=r}return new Lf(t,n,e.space)}const rR=mc({properties:{ariaActiveDescendant:null,ariaAtomic:Ln,ariaAutoComplete:null,ariaBusy:Ln,ariaChecked:Ln,ariaColCount:Oe,ariaColIndex:Oe,ariaColSpan:Oe,ariaControls:qt,ariaCurrent:null,ariaDescribedBy:qt,ariaDetails:null,ariaDisabled:Ln,ariaDropEffect:qt,ariaErrorMessage:null,ariaExpanded:Ln,ariaFlowTo:qt,ariaGrabbed:Ln,ariaHasPopup:null,ariaHidden:Ln,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:qt,ariaLevel:Oe,ariaLive:null,ariaModal:Ln,ariaMultiLine:Ln,ariaMultiSelectable:Ln,ariaOrientation:null,ariaOwns:qt,ariaPlaceholder:null,ariaPosInSet:Oe,ariaPressed:Ln,ariaReadOnly:Ln,ariaRelevant:null,ariaRequired:Ln,ariaRoleDescription:qt,ariaRowCount:Oe,ariaRowIndex:Oe,ariaRowSpan:Oe,ariaSelected:Ln,ariaSetSize:Oe,ariaSort:null,ariaValueMax:Oe,ariaValueMin:Oe,ariaValueNow:Oe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function aR(e,t){return t in e?e[t]:t}function iR(e,t){return aR(e,t.toLowerCase())}const k$=mc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ul,acceptCharset:qt,accessKey:qt,action:null,allow:null,allowFullScreen:it,allowPaymentRequest:it,allowUserMedia:it,alpha:it,alt:null,as:null,async:it,autoCapitalize:null,autoComplete:qt,autoFocus:it,autoPlay:it,blocking:qt,capture:null,charSet:null,checked:it,cite:null,className:qt,closedBy:null,colorSpace:null,cols:Oe,colSpan:Oe,command:null,commandFor:null,content:null,contentEditable:Ln,controls:it,controlsList:qt,coords:Oe|ul,crossOrigin:null,data:null,dateTime:null,decoding:null,default:it,defer:it,dir:null,dirName:null,disabled:it,download:hv,draggable:Ln,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:it,formTarget:null,headers:qt,height:Oe,hidden:hv,high:Oe,href:null,hrefLang:null,htmlFor:qt,httpEquiv:qt,id:null,imageSizes:null,imageSrcSet:null,inert:it,inputMode:null,integrity:null,is:null,isMap:it,itemId:null,itemProp:qt,itemRef:qt,itemScope:it,itemType:qt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:it,low:Oe,manifest:null,max:null,maxLength:Oe,media:null,method:null,min:null,minLength:Oe,multiple:it,muted:it,name:null,nonce:null,noModule:it,noValidate:it,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:it,optimum:Oe,pattern:null,ping:qt,placeholder:null,playsInline:it,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:it,referrerPolicy:null,rel:qt,required:it,reversed:it,rows:Oe,rowSpan:Oe,sandbox:qt,scope:null,scoped:it,seamless:it,selected:it,shadowRootClonable:it,shadowRootCustomElementRegistry:it,shadowRootDelegatesFocus:it,shadowRootMode:null,shadowRootSerializable:it,shape:null,size:Oe,sizes:null,slot:null,span:Oe,spellCheck:Ln,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Oe,step:null,style:null,tabIndex:Oe,target:null,title:null,translate:null,type:null,typeMustMatch:it,useMap:null,value:Ln,width:Oe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:qt,axis:null,background:null,bgColor:null,border:Oe,borderColor:null,bottomMargin:Oe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:it,declare:it,event:null,face:null,frame:null,frameBorder:null,hSpace:Oe,leftMargin:Oe,link:null,longDesc:null,lowSrc:null,marginHeight:Oe,marginWidth:Oe,noResize:it,noHref:it,noShade:it,noWrap:it,object:null,profile:null,prompt:null,rev:null,rightMargin:Oe,rules:null,scheme:null,scrolling:Ln,standby:null,summary:null,text:null,topMargin:Oe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Oe,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:it,disablePictureInPicture:it,disableRemotePlayback:it,exportParts:ul,part:qt,prefix:null,property:null,results:Oe,security:null,unselectable:null},space:"html",transform:iR}),O$=mc({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:pa,accentHeight:Oe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Oe,amplitude:Oe,arabicForm:null,ascent:Oe,attributeName:null,attributeType:null,azimuth:Oe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Oe,by:null,calcMode:null,capHeight:Oe,className:qt,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:Oe,diffuseConstant:Oe,direction:null,display:null,dur:null,divisor:Oe,dominantBaseline:null,download:it,dx:null,dy:null,edgeMode:null,editable:null,elevation:Oe,enableBackground:null,end:null,event:null,exponent:Oe,externalResourcesRequired:null,fill:null,fillOpacity:Oe,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:ul,g2:ul,glyphName:ul,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Oe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Oe,horizOriginX:Oe,horizOriginY:Oe,id:null,ideographic:Oe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Oe,k:Oe,k1:Oe,k2:Oe,k3:Oe,k4:Oe,kernelMatrix:pa,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Oe,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:Oe,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:Oe,overlineThickness:Oe,paintOrder:null,panose1:null,path:null,pathLength:Oe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:qt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Oe,pointsAtY:Oe,pointsAtZ:Oe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:pa,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:pa,rev:pa,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:pa,requiredFeatures:pa,requiredFonts:pa,requiredFormats:pa,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:Oe,specularExponent:Oe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Oe,strikethroughThickness:Oe,string:null,stroke:null,strokeDashArray:pa,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Oe,strokeOpacity:Oe,strokeWidth:null,style:null,surfaceScale:Oe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:pa,tabIndex:Oe,tableValues:null,target:null,targetX:Oe,targetY:Oe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:pa,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Oe,underlineThickness:Oe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Oe,values:null,vAlphabetic:Oe,vMathematical:Oe,vectorEffect:null,vHanging:Oe,vIdeographic:Oe,version:null,vertAdvY:Oe,vertOriginX:Oe,vertOriginY:Oe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Oe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:aR}),sR=mc({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()}}),oR=mc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:iR}),lR=mc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),I$={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"},R$=/[A-Z]/g,B2=/-[a-z]/g,M$=/^data[-\w.:]+$/i;function wg(e,t){const n=mf(t);let r=t,a=ra;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&M$.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(B2,D$);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!B2.test(s)){let o=s.replace(R$,j$);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=W1}return new a(r,t)}function j$(e){return"-"+e.toLowerCase()}function D$(e){return e.charAt(1).toUpperCase()}const Pf=nR([rR,k$,sR,oR,lR],"html"),bo=nR([rR,O$,sR,oR,lR],"svg");function U2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function uR(e){return e.join(" ").trim()}var Tu={},Kx,F2;function L$(){if(F2)return Kx;F2=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
521
521
  `,f="/",m="*",p="",b="comment",x="declaration";function E(T,S){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];S=S||{};var C=1,A=1;function O(Z){var W=Z.match(t);W&&(C+=W.length);var K=Z.lastIndexOf(d);A=~K?Z.length-K:A+Z.length}function R(){var Z={line:C,column:A};return function(W){return W.position=new k(Z),j(),W}}function k(Z){this.start=Z,this.end={line:C,column:A},this.source=S.source}k.prototype.content=T;function D(Z){var W=new Error(S.source+":"+C+":"+A+": "+Z);if(W.reason=Z,W.filename=S.source,W.line=C,W.column=A,W.source=T,!S.silent)throw W}function B(Z){var W=Z.exec(T);if(W){var K=W[0];return O(K),T=T.slice(K.length),W}}function j(){B(n)}function M(Z){var W;for(Z=Z||[];W=z();)W!==!1&&Z.push(W);return Z}function z(){var Z=R();if(!(f!=T.charAt(0)||m!=T.charAt(1))){for(var W=2;p!=T.charAt(W)&&(m!=T.charAt(W)||f!=T.charAt(W+1));)++W;if(W+=2,p===T.charAt(W-1))return D("End of comment missing");var K=T.slice(2,W-2);return A+=2,O(K),T=T.slice(W),A+=2,Z({type:b,comment:K})}}function G(){var Z=R(),W=B(r);if(W){if(z(),!B(a))return D("property missing ':'");var K=B(s),H=Z({type:x,property:N(W[0].replace(e,p)),value:K?N(K[0].replace(e,p)):p});return B(o),H}}function ae(){var Z=[];M(Z);for(var W;W=G();)W!==!1&&(Z.push(W),M(Z));return Z}return j(),ae()}function N(T){return T?T.replace(c,p):p}return Kx=E,Kx}var z2;function P$(){if(z2)return Tu;z2=1;var e=Tu&&Tu.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.default=n;const t=e(L$());function n(r,a){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),c=typeof a=="function";return o.forEach(d=>{if(d.type!=="declaration")return;const{property:f,value:m}=d;c?a(f,m,d):m&&(s=s||{},s[f]=m)}),s}return Tu}var Ad={},H2;function B$(){if(H2)return Ad;H2=1,Object.defineProperty(Ad,"__esModule",{value:!0}),Ad.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,s=function(f){return!f||n.test(f)||e.test(f)},o=function(f,m){return m.toUpperCase()},c=function(f,m){return"".concat(m,"-")},d=function(f,m){return m===void 0&&(m={}),s(f)?f:(f=f.toLowerCase(),m.reactCompat?f=f.replace(a,c):f=f.replace(r,c),f.replace(t,o))};return Ad.camelCase=d,Ad}var Cd,$2;function U$(){if($2)return Cd;$2=1;var e=Cd&&Cd.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(P$()),n=B$();function r(a,s){var o={};return!a||typeof a!="string"||(0,t.default)(a,function(c,d){c&&d&&(o[(0,n.camelCase)(c,s)]=d)}),o}return r.default=r,Cd=r,Cd}var F$=U$();const z$=Of(F$),Ag=cR("end"),Ri=cR("start");function cR(e){return t;function t(n){const r=n&&n.position&&n.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 H$(e){const t=Ri(e),n=Ag(e);if(t&&n)return{start:t,end:n}}function Wd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Y2(e.position):"start"in e||"end"in e?Y2(e):"line"in e||"column"in e?pv(e):""}function pv(e){return q2(e&&e.line)+":"+q2(e&&e.column)}function Y2(e){return pv(e&&e.start)+"-"+pv(e&&e.end)}function q2(e){return e&&typeof e=="number"?e:1}class Tr extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?a=t:!s.cause&&t&&(o=!0,a=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const d=r.indexOf(":");d===-1?s.ruleId=r:(s.source=r.slice(0,d),s.ruleId=r.slice(d+1))}if(!s.place&&s.ancestors&&s.ancestors){const d=s.ancestors[s.ancestors.length-1];d&&(s.place=d.position)}const c=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=Wd(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Tr.prototype.file="";Tr.prototype.name="";Tr.prototype.reason="";Tr.prototype.message="";Tr.prototype.stack="";Tr.prototype.column=void 0;Tr.prototype.line=void 0;Tr.prototype.ancestors=void 0;Tr.prototype.cause=void 0;Tr.prototype.fatal=void 0;Tr.prototype.place=void 0;Tr.prototype.ruleId=void 0;Tr.prototype.source=void 0;const X1={}.hasOwnProperty,$$=new Map,Y$=/[A-Z]/g,q$=new Set(["table","tbody","thead","tfoot","tr"]),G$=new Set(["td","th"]),dR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function K$(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=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=tY(n,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=eY(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?bo:Pf,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=fR(a,e,void 0);return s&&typeof s!="string"?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function fR(e,t,n){if(t.type==="element")return V$(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return W$(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Q$(e,t,n);if(t.type==="mdxjsEsm")return X$(e,t);if(t.type==="root")return Z$(e,t,n);if(t.type==="text")return J$(e,t)}function V$(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=bo,e.schema=a),e.ancestors.push(t);const s=mR(e,t.tagName,!1),o=nY(e,t);let c=Z1(e,t);return q$.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!A$(d):!0})),hR(e,o,s,t),Q1(o,c),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function W$(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)}pf(e,t.position)}function X$(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);pf(e,t.position)}function Q$(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=bo,e.schema=a),e.ancestors.push(t);const s=t.name===null?e.Fragment:mR(e,t.name,!0),o=rY(e,t),c=Z1(e,t);return hR(e,o,s,t),Q1(o,c),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Z$(e,t,n){const r={};return Q1(r,Z1(e,t)),e.create(t,e.Fragment,r,n)}function J$(e,t){return t.value}function hR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Q1(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function eY(e,t,n){return r;function r(a,s,o,c){const f=Array.isArray(o.children)?n:t;return c?f(s,o,c):f(s,o)}}function tY(e,t){return n;function n(r,a,s,o){const c=Array.isArray(s.children),d=Ri(r);return t(a,s,o,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function nY(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&X1.call(t.properties,a)){const s=aY(e,a,t.properties[a]);if(s){const[o,c]=s;e.tableCellAlignToStyle&&o==="align"&&typeof c=="string"&&G$.has(t.tagName)?r=c:n[o]=c}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function rY(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const c=o.properties[0];c.type,Object.assign(n,e.evaluater.evaluateExpression(c.argument))}else pf(e,t.position);else{const a=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,s=e.evaluater.evaluateExpression(c.expression)}else pf(e,t.position);else s=r.value===null?!0:r.value;n[a]=s}return n}function Z1(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:$$;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const d=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(d){const f=a.get(d)||0;o=d+"-"+f,a.set(d,f+1)}}const c=fR(e,s,o);c!==void 0&&n.push(c)}return n}function aY(e,t,n){const r=wg(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?tR(n):uR(n)),r.property==="style"){let a=typeof n=="object"?n:iY(e,String(n));return e.stylePropertyNameCase==="css"&&(a=sY(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?I$[r.property]||r.property:r.attribute,n]}}function iY(e,t){try{return z$(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new Tr("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=dR+"#cannot-parse-style-attribute",a}}function mR(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let s=-1,o;for(;++s<a.length;){const c=D2(a[s])?{type:"Identifier",name:a[s]}:{type:"Literal",value:a[s]};o=o?{type:"MemberExpression",object:o,property:c,computed:!!(s&&c.type==="Literal"),optional:!1}:c}r=o}else r=D2(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return X1.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);pf(e)}function pf(e,t){const n=new Tr("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=dR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function sY(e){const t={};let n;for(n in e)X1.call(e,n)&&(t[oY(n)]=e[n]);return t}function oY(e){let t=e.replace(Y$,lY);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function lY(e){return"-"+e.toLowerCase()}const Vx={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"]},uY={};function J1(e,t){const n=uY,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return pR(e,r,a)}function pR(e,t,n){if(cY(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return G2(e.children,t,n)}return Array.isArray(e)?G2(e,t,n):""}function G2(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=pR(e[a],t,n);return r.join("")}function cY(e){return!!(e&&typeof e=="object")}const K2=document.createElement("i");function eE(e){const t="&"+e+";";K2.innerHTML=t;const n=K2.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function xa(e,t,n,r){const a=e.length;let s=0,o;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function Ma(e,t){return e.length>0?(xa(e,e.length,0,t),e):t}const V2={}.hasOwnProperty;function gR(e){const t={};let n=-1;for(;++n<e.length;)dY(t,e[n]);return t}function dY(e,t){let n;for(n in t){const a=(V2.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){V2.call(a,o)||(a[o]=[]);const c=s[o];fY(a[o],Array.isArray(c)?c:c?[c]:[])}}}function fY(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);xa(e,0,0,r)}function bR(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function ti(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Dr=xo(/[A-Za-z]/),_r=xo(/[\dA-Za-z]/),hY=xo(/[#-'*+\--9=?A-Z^-~]/);function xp(e){return e!==null&&(e<32||e===127)}const gv=xo(/\d/),mY=xo(/[\dA-Fa-f]/),pY=xo(/[!-/:-@[-`{-~]/);function Xe(e){return e!==null&&e<-2}function Wt(e){return e!==null&&(e<0||e===32)}function gt(e){return e===-2||e===-1||e===32}const Cg=xo(new RegExp("\\p{P}|\\p{S}","u")),vl=xo(/\s/);function xo(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pc(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&_r(e.charCodeAt(n+1))&&_r(e.charCodeAt(n+2)))a=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const c=e.charCodeAt(n+1);s<56320&&c>56319&&c<57344?(o=String.fromCharCode(s,c),a=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+a+1,o=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function St(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(d){return gt(d)?(e.enter(n),c(d)):t(d)}function c(d){return gt(d)&&s++<a?(e.consume(d),c):(e.exit(n),t(d))}}const gY={tokenize:bY};function bY(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),St(e,t,"linePrefix")}function a(c){return e.enter("paragraph"),s(c)}function s(c){const d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,o(c)}function o(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Xe(c)?(e.consume(c),e.exit("chunkText"),s):(e.consume(c),o)}}const xY={tokenize:yY},W2={tokenize:vY};function yY(e){const t=this,n=[];let r=0,a,s,o;return c;function c(A){if(r<n.length){const O=n[r];return t.containerState=O[1],e.attempt(O[0].continuation,d,f)(A)}return f(A)}function d(A){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&C();const O=t.events.length;let R=O,k;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){k=t.events[R][1].end;break}S(r);let D=O;for(;D<t.events.length;)t.events[D][1].end={...k},D++;return xa(t.events,R+1,0,t.events.slice(O)),t.events.length=D,f(A)}return c(A)}function f(A){if(r===n.length){if(!a)return b(A);if(a.currentConstruct&&a.currentConstruct.concrete)return E(A);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(W2,m,p)(A)}function m(A){return a&&C(),S(r),b(A)}function p(A){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,E(A)}function b(A){return t.containerState={},e.attempt(W2,x,E)(A)}function x(A){return r++,n.push([t.currentConstruct,t.containerState]),b(A)}function E(A){if(A===null){a&&C(),S(0),e.consume(A);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:s}),N(A)}function N(A){if(A===null){T(e.exit("chunkFlow"),!0),S(0),e.consume(A);return}return Xe(A)?(e.consume(A),T(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(A),N)}function T(A,O){const R=t.sliceStream(A);if(O&&R.push(null),A.previous=s,s&&(s.next=A),s=A,a.defineSkip(A.start),a.write(R),t.parser.lazy[A.start.line]){let k=a.events.length;for(;k--;)if(a.events[k][1].start.offset<o&&(!a.events[k][1].end||a.events[k][1].end.offset>o))return;const D=t.events.length;let B=D,j,M;for(;B--;)if(t.events[B][0]==="exit"&&t.events[B][1].type==="chunkFlow"){if(j){M=t.events[B][1].end;break}j=!0}for(S(r),k=D;k<t.events.length;)t.events[k][1].end={...M},k++;xa(t.events,B+1,0,t.events.slice(D)),t.events.length=k}}function S(A){let O=n.length;for(;O-- >A;){const R=n[O];t.containerState=R[1],R[0].exit.call(t,e)}n.length=A}function C(){a.write([null]),s=void 0,a=void 0,t.containerState._closeFlow=void 0}}function vY(e,t,n){return St(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Vu(e){if(e===null||Wt(e)||vl(e))return 1;if(Cg(e))return 2}function kg(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const s=e[a].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const bv={name:"attention",resolveAll:EY,tokenize:NY};function EY(e,t){let n=-1,r,a,s,o,c,d,f,m;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;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[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},b={...e[n][1].start};X2(p,-d),X2(b,d),o={type:d>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:b},s={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...o.start},end:{...c.end}},e[r][1].end={...o.start},e[n][1].start={...c.end},f=[],e[r][1].end.offset-e[r][1].start.offset&&(f=Ma(f,[["enter",e[r][1],t],["exit",e[r][1],t]])),f=Ma(f,[["enter",a,t],["enter",o,t],["exit",o,t],["enter",s,t]]),f=Ma(f,kg(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),f=Ma(f,[["exit",s,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,f=Ma(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,xa(e,r-1,n-r+3,f),n=r+f.length-m-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function NY(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Vu(r);let s;return o;function o(d){return s=d,e.enter("attentionSequence"),c(d)}function c(d){if(d===s)return e.consume(d),c;const f=e.exit("attentionSequence"),m=Vu(d),p=!m||m===2&&a||n.includes(d),b=!a||a===2&&m||n.includes(r);return f._open=!!(s===42?p:p&&(a||!b)),f._close=!!(s===42?b:b&&(m||!p)),t(d)}}function X2(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const _Y={name:"autolink",tokenize:SY};function SY(e,t,n){let r=0;return a;function a(x){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(x){return Dr(x)?(e.consume(x),o):x===64?n(x):f(x)}function o(x){return x===43||x===45||x===46||_r(x)?(r=1,c(x)):f(x)}function c(x){return x===58?(e.consume(x),r=0,d):(x===43||x===45||x===46||_r(x))&&r++<32?(e.consume(x),c):(r=0,f(x))}function d(x){return x===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):x===null||x===32||x===60||xp(x)?n(x):(e.consume(x),d)}function f(x){return x===64?(e.consume(x),m):hY(x)?(e.consume(x),f):n(x)}function m(x){return _r(x)?p(x):n(x)}function p(x){return x===46?(e.consume(x),r=0,m):x===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):b(x)}function b(x){if((x===45||_r(x))&&r++<63){const E=x===45?b:p;return e.consume(x),E}return n(x)}}const Bf={partial:!0,tokenize:TY};function TY(e,t,n){return r;function r(s){return gt(s)?St(e,a,"linePrefix")(s):a(s)}function a(s){return s===null||Xe(s)?t(s):n(s)}}const xR={continuation:{tokenize:AY},exit:CY,name:"blockQuote",tokenize:wY};function wY(e,t,n){const r=this;return a;function a(o){if(o===62){const c=r.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return gt(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function AY(e,t,n){const r=this;return a;function a(o){return gt(o)?St(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(xR,t,n)(o)}}function CY(e){e.exit("blockQuote")}const yR={name:"characterEscape",tokenize:kY};function kY(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),a}function a(s){return pY(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const vR={name:"characterReference",tokenize:OY};function OY(e,t,n){const r=this;let a=0,s,o;return c;function c(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),d}function d(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),s=31,o=_r,m(p))}function f(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=mY,m):(e.enter("characterReferenceValue"),s=7,o=gv,m(p))}function m(p){if(p===59&&a){const b=e.exit("characterReferenceValue");return o===_r&&!eE(r.sliceSerialize(b))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(p)&&a++<s?(e.consume(p),m):n(p)}}const Q2={partial:!0,tokenize:RY},Z2={concrete:!0,name:"codeFenced",tokenize:IY};function IY(e,t,n){const r=this,a={partial:!0,tokenize:R};let s=0,o=0,c;return d;function d(k){return f(k)}function f(k){const D=r.events[r.events.length-1];return s=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,c=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m(k)}function m(k){return k===c?(o++,e.consume(k),m):o<3?n(k):(e.exit("codeFencedFenceSequence"),gt(k)?St(e,p,"whitespace")(k):p(k))}function p(k){return k===null||Xe(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(Q2,N,O)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),b(k))}function b(k){return k===null||Xe(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(k)):gt(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),St(e,x,"whitespace")(k)):k===96&&k===c?n(k):(e.consume(k),b)}function x(k){return k===null||Xe(k)?p(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),E(k))}function E(k){return k===null||Xe(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(k)):k===96&&k===c?n(k):(e.consume(k),E)}function N(k){return e.attempt(a,O,T)(k)}function T(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),S}function S(k){return s>0&&gt(k)?St(e,C,"linePrefix",s+1)(k):C(k)}function C(k){return k===null||Xe(k)?e.check(Q2,N,O)(k):(e.enter("codeFlowValue"),A(k))}function A(k){return k===null||Xe(k)?(e.exit("codeFlowValue"),C(k)):(e.consume(k),A)}function O(k){return e.exit("codeFenced"),t(k)}function R(k,D,B){let j=0;return M;function M(W){return k.enter("lineEnding"),k.consume(W),k.exit("lineEnding"),z}function z(W){return k.enter("codeFencedFence"),gt(W)?St(k,G,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):G(W)}function G(W){return W===c?(k.enter("codeFencedFenceSequence"),ae(W)):B(W)}function ae(W){return W===c?(j++,k.consume(W),ae):j>=o?(k.exit("codeFencedFenceSequence"),gt(W)?St(k,Z,"whitespace")(W):Z(W)):B(W)}function Z(W){return W===null||Xe(W)?(k.exit("codeFencedFence"),D(W)):B(W)}}}function RY(e,t,n){const r=this;return a;function a(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Wx={name:"codeIndented",tokenize:jY},MY={partial:!0,tokenize:DY};function jY(e,t,n){const r=this;return a;function a(f){return e.enter("codeIndented"),St(e,s,"linePrefix",5)(f)}function s(f){const m=r.events[r.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?o(f):n(f)}function o(f){return f===null?d(f):Xe(f)?e.attempt(MY,o,d)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||Xe(f)?(e.exit("codeFlowValue"),o(f)):(e.consume(f),c)}function d(f){return e.exit("codeIndented"),t(f)}}function DY(e,t,n){const r=this;return a;function a(o){return r.parser.lazy[r.now().line]?n(o):Xe(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):St(e,s,"linePrefix",5)(o)}function s(o){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(o):Xe(o)?a(o):n(o)}}const LY={name:"codeText",previous:BY,resolve:PY,tokenize:UY};function PY(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function BY(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function UY(e,t,n){let r=0,a,s;return o;function o(p){return e.enter("codeText"),e.enter("codeTextSequence"),c(p)}function c(p){return p===96?(e.consume(p),r++,c):(e.exit("codeTextSequence"),d(p))}function d(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),d):p===96?(s=e.enter("codeTextSequence"),a=0,m(p)):Xe(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("codeTextData"),f(p))}function f(p){return p===null||p===32||p===96||Xe(p)?(e.exit("codeTextData"),d(p)):(e.consume(p),f)}function m(p){return p===96?(e.consume(p),a++,m):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(s.type="codeTextData",f(p))}}class FY{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,n){const r=n??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,n,r){const a=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&kd(this.left,r),s.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),kd(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),kd(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 n=this.left.splice(t,Number.POSITIVE_INFINITY);kd(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);kd(this.left,n.reverse())}}}function kd(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function ER(e){const t={};let n=-1,r,a,s,o,c,d,f;const m=new FY(e);for(;++n<m.length;){for(;n in t;)n=t[n];if(r=m.get(n),n&&r[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,s=0,s<d.length&&d[s][1].type==="lineEndingBlank"&&(s+=2),s<d.length&&d[s][1].type==="content"))for(;++s<d.length&&d[s][1].type!=="content";)d[s][1].type==="chunkText"&&(d[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,zY(m,n)),n=t[n],f=!0);else if(r[1]._container){for(s=n,a=void 0;s--;)if(o=m.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(a&&(m.get(a)[1].type="lineEndingBlank"),o[1].type="lineEnding",a=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;a&&(r[1].end={...m.get(a)[1].start},c=m.slice(a,n),c.unshift(r),m.splice(a,n-a+1,c))}}return xa(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!f}function zY(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const c=o.events,d=[],f={};let m,p,b=-1,x=n,E=0,N=0;const T=[N];for(;x;){for(;e.get(++a)[1]!==x;);s.push(a),x._tokenizer||(m=r.sliceStream(x),x.next||m.push(null),p&&o.defineSkip(x.start),x._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(m),x._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),p=x,x=x.next}for(x=n;++b<c.length;)c[b][0]==="exit"&&c[b-1][0]==="enter"&&c[b][1].type===c[b-1][1].type&&c[b][1].start.line!==c[b][1].end.line&&(N=b+1,T.push(N),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(o.events=[],x?(x._tokenizer=void 0,x.previous=void 0):T.pop(),b=T.length;b--;){const S=c.slice(T[b],T[b+1]),C=s.pop();d.push([C,C+S.length-1]),e.splice(C,2,S)}for(d.reverse(),b=-1;++b<d.length;)f[E+d[b][0]]=E+d[b][1],E+=d[b][1]-d[b][0]-1;return f}const HY={resolve:YY,tokenize:qY},$Y={partial:!0,tokenize:GY};function YY(e){return ER(e),e}function qY(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?s(c):Xe(c)?e.check($Y,o,s)(c):(e.consume(c),a)}function s(c){return e.exit("chunkContent"),e.exit("content"),t(c)}function o(c){return e.consume(c),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function GY(e,t,n){const r=this;return a;function a(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),St(e,s,"linePrefix")}function s(o){if(o===null||Xe(o))return n(o);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function NR(e,t,n,r,a,s,o,c,d){const f=d||Number.POSITIVE_INFINITY;let m=0;return p;function p(S){return S===60?(e.enter(r),e.enter(a),e.enter(s),e.consume(S),e.exit(s),b):S===null||S===32||S===41||xp(S)?n(S):(e.enter(r),e.enter(o),e.enter(c),e.enter("chunkString",{contentType:"string"}),N(S))}function b(S){return S===62?(e.enter(s),e.consume(S),e.exit(s),e.exit(a),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),x(S))}function x(S){return S===62?(e.exit("chunkString"),e.exit(c),b(S)):S===null||S===60||Xe(S)?n(S):(e.consume(S),S===92?E:x)}function E(S){return S===60||S===62||S===92?(e.consume(S),x):x(S)}function N(S){return!m&&(S===null||S===41||Wt(S))?(e.exit("chunkString"),e.exit(c),e.exit(o),e.exit(r),t(S)):m<f&&S===40?(e.consume(S),m++,N):S===41?(e.consume(S),m--,N):S===null||S===32||S===40||xp(S)?n(S):(e.consume(S),S===92?T:N)}function T(S){return S===40||S===41||S===92?(e.consume(S),N):N(S)}}function _R(e,t,n,r,a,s){const o=this;let c=0,d;return f;function f(x){return e.enter(r),e.enter(a),e.consume(x),e.exit(a),e.enter(s),m}function m(x){return c>999||x===null||x===91||x===93&&!d||x===94&&!c&&"_hiddenFootnoteSupport"in o.parser.constructs?n(x):x===93?(e.exit(s),e.enter(a),e.consume(x),e.exit(a),e.exit(r),t):Xe(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===null||x===91||x===93||Xe(x)||c++>999?(e.exit("chunkString"),m(x)):(e.consume(x),d||(d=!gt(x)),x===92?b:p)}function b(x){return x===91||x===92||x===93?(e.consume(x),c++,p):p(x)}}function SR(e,t,n,r,a,s){let o;return c;function c(b){return b===34||b===39||b===40?(e.enter(r),e.enter(a),e.consume(b),e.exit(a),o=b===40?41:b,d):n(b)}function d(b){return b===o?(e.enter(a),e.consume(b),e.exit(a),e.exit(r),t):(e.enter(s),f(b))}function f(b){return b===o?(e.exit(s),d(o)):b===null?n(b):Xe(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),St(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===o||b===null||Xe(b)?(e.exit("chunkString"),f(b)):(e.consume(b),b===92?p:m)}function p(b){return b===o||b===92?(e.consume(b),m):m(b)}}function Xd(e,t){let n;return r;function r(a){return Xe(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):gt(a)?St(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const KY={name:"definition",tokenize:WY},VY={partial:!0,tokenize:XY};function WY(e,t,n){const r=this;let a;return s;function s(x){return e.enter("definition"),o(x)}function o(x){return _R.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function c(x){return a=ti(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),d):n(x)}function d(x){return Wt(x)?Xd(e,f)(x):f(x)}function f(x){return NR(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function m(x){return e.attempt(VY,p,p)(x)}function p(x){return gt(x)?St(e,b,"whitespace")(x):b(x)}function b(x){return x===null||Xe(x)?(e.exit("definition"),r.parser.defined.push(a),t(x)):n(x)}}function XY(e,t,n){return r;function r(c){return Wt(c)?Xd(e,a)(c):n(c)}function a(c){return SR(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function s(c){return gt(c)?St(e,o,"whitespace")(c):o(c)}function o(c){return c===null||Xe(c)?t(c):n(c)}}const QY={name:"hardBreakEscape",tokenize:ZY};function ZY(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),a}function a(s){return Xe(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const JY={name:"headingAtx",resolve:eq,tokenize:tq};function eq(e,t){let n=e.length-2,r=3,a,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},xa(e,r,n-r+1,[["enter",a,t],["enter",s,t],["exit",s,t],["exit",a,t]])),e}function tq(e,t,n){let r=0;return a;function a(m){return e.enter("atxHeading"),s(m)}function s(m){return e.enter("atxHeadingSequence"),o(m)}function o(m){return m===35&&r++<6?(e.consume(m),o):m===null||Wt(m)?(e.exit("atxHeadingSequence"),c(m)):n(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),d(m)):m===null||Xe(m)?(e.exit("atxHeading"),t(m)):gt(m)?St(e,c,"whitespace")(m):(e.enter("atxHeadingText"),f(m))}function d(m){return m===35?(e.consume(m),d):(e.exit("atxHeadingSequence"),c(m))}function f(m){return m===null||m===35||Wt(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),f)}}const nq=["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"],J2=["pre","script","style","textarea"],rq={concrete:!0,name:"htmlFlow",resolveTo:sq,tokenize:oq},aq={partial:!0,tokenize:uq},iq={partial:!0,tokenize:lq};function sq(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 oq(e,t,n){const r=this;let a,s,o,c,d;return f;function f(P){return m(P)}function m(P){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(P),p}function p(P){return P===33?(e.consume(P),b):P===47?(e.consume(P),s=!0,N):P===63?(e.consume(P),a=3,r.interrupt?t:L):Dr(P)?(e.consume(P),o=String.fromCharCode(P),T):n(P)}function b(P){return P===45?(e.consume(P),a=2,x):P===91?(e.consume(P),a=5,c=0,E):Dr(P)?(e.consume(P),a=4,r.interrupt?t:L):n(P)}function x(P){return P===45?(e.consume(P),r.interrupt?t:L):n(P)}function E(P){const he="CDATA[";return P===he.charCodeAt(c++)?(e.consume(P),c===he.length?r.interrupt?t:G:E):n(P)}function N(P){return Dr(P)?(e.consume(P),o=String.fromCharCode(P),T):n(P)}function T(P){if(P===null||P===47||P===62||Wt(P)){const he=P===47,se=o.toLowerCase();return!he&&!s&&J2.includes(se)?(a=1,r.interrupt?t(P):G(P)):nq.includes(o.toLowerCase())?(a=6,he?(e.consume(P),S):r.interrupt?t(P):G(P)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(P):s?C(P):A(P))}return P===45||_r(P)?(e.consume(P),o+=String.fromCharCode(P),T):n(P)}function S(P){return P===62?(e.consume(P),r.interrupt?t:G):n(P)}function C(P){return gt(P)?(e.consume(P),C):M(P)}function A(P){return P===47?(e.consume(P),M):P===58||P===95||Dr(P)?(e.consume(P),O):gt(P)?(e.consume(P),A):M(P)}function O(P){return P===45||P===46||P===58||P===95||_r(P)?(e.consume(P),O):R(P)}function R(P){return P===61?(e.consume(P),k):gt(P)?(e.consume(P),R):A(P)}function k(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),d=P,D):gt(P)?(e.consume(P),k):B(P)}function D(P){return P===d?(e.consume(P),d=null,j):P===null||Xe(P)?n(P):(e.consume(P),D)}function B(P){return P===null||P===34||P===39||P===47||P===60||P===61||P===62||P===96||Wt(P)?R(P):(e.consume(P),B)}function j(P){return P===47||P===62||gt(P)?A(P):n(P)}function M(P){return P===62?(e.consume(P),z):n(P)}function z(P){return P===null||Xe(P)?G(P):gt(P)?(e.consume(P),z):n(P)}function G(P){return P===45&&a===2?(e.consume(P),K):P===60&&a===1?(e.consume(P),H):P===62&&a===4?(e.consume(P),$):P===63&&a===3?(e.consume(P),L):P===93&&a===5?(e.consume(P),Y):Xe(P)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(aq,Q,ae)(P)):P===null||Xe(P)?(e.exit("htmlFlowData"),ae(P)):(e.consume(P),G)}function ae(P){return e.check(iq,Z,Q)(P)}function Z(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),W}function W(P){return P===null||Xe(P)?ae(P):(e.enter("htmlFlowData"),G(P))}function K(P){return P===45?(e.consume(P),L):G(P)}function H(P){return P===47?(e.consume(P),o="",F):G(P)}function F(P){if(P===62){const he=o.toLowerCase();return J2.includes(he)?(e.consume(P),$):G(P)}return Dr(P)&&o.length<8?(e.consume(P),o+=String.fromCharCode(P),F):G(P)}function Y(P){return P===93?(e.consume(P),L):G(P)}function L(P){return P===62?(e.consume(P),$):P===45&&a===2?(e.consume(P),L):G(P)}function $(P){return P===null||Xe(P)?(e.exit("htmlFlowData"),Q(P)):(e.consume(P),$)}function Q(P){return e.exit("htmlFlow"),t(P)}}function lq(e,t,n){const r=this;return a;function a(o){return Xe(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function uq(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Bf,t,n)}}const cq={name:"htmlText",tokenize:dq};function dq(e,t,n){const r=this;let a,s,o;return c;function c(L){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(L),d}function d(L){return L===33?(e.consume(L),f):L===47?(e.consume(L),R):L===63?(e.consume(L),A):Dr(L)?(e.consume(L),B):n(L)}function f(L){return L===45?(e.consume(L),m):L===91?(e.consume(L),s=0,E):Dr(L)?(e.consume(L),C):n(L)}function m(L){return L===45?(e.consume(L),x):n(L)}function p(L){return L===null?n(L):L===45?(e.consume(L),b):Xe(L)?(o=p,H(L)):(e.consume(L),p)}function b(L){return L===45?(e.consume(L),x):p(L)}function x(L){return L===62?K(L):L===45?b(L):p(L)}function E(L){const $="CDATA[";return L===$.charCodeAt(s++)?(e.consume(L),s===$.length?N:E):n(L)}function N(L){return L===null?n(L):L===93?(e.consume(L),T):Xe(L)?(o=N,H(L)):(e.consume(L),N)}function T(L){return L===93?(e.consume(L),S):N(L)}function S(L){return L===62?K(L):L===93?(e.consume(L),S):N(L)}function C(L){return L===null||L===62?K(L):Xe(L)?(o=C,H(L)):(e.consume(L),C)}function A(L){return L===null?n(L):L===63?(e.consume(L),O):Xe(L)?(o=A,H(L)):(e.consume(L),A)}function O(L){return L===62?K(L):A(L)}function R(L){return Dr(L)?(e.consume(L),k):n(L)}function k(L){return L===45||_r(L)?(e.consume(L),k):D(L)}function D(L){return Xe(L)?(o=D,H(L)):gt(L)?(e.consume(L),D):K(L)}function B(L){return L===45||_r(L)?(e.consume(L),B):L===47||L===62||Wt(L)?j(L):n(L)}function j(L){return L===47?(e.consume(L),K):L===58||L===95||Dr(L)?(e.consume(L),M):Xe(L)?(o=j,H(L)):gt(L)?(e.consume(L),j):K(L)}function M(L){return L===45||L===46||L===58||L===95||_r(L)?(e.consume(L),M):z(L)}function z(L){return L===61?(e.consume(L),G):Xe(L)?(o=z,H(L)):gt(L)?(e.consume(L),z):j(L)}function G(L){return L===null||L===60||L===61||L===62||L===96?n(L):L===34||L===39?(e.consume(L),a=L,ae):Xe(L)?(o=G,H(L)):gt(L)?(e.consume(L),G):(e.consume(L),Z)}function ae(L){return L===a?(e.consume(L),a=void 0,W):L===null?n(L):Xe(L)?(o=ae,H(L)):(e.consume(L),ae)}function Z(L){return L===null||L===34||L===39||L===60||L===61||L===96?n(L):L===47||L===62||Wt(L)?j(L):(e.consume(L),Z)}function W(L){return L===47||L===62||Wt(L)?j(L):n(L)}function K(L){return L===62?(e.consume(L),e.exit("htmlTextData"),e.exit("htmlText"),t):n(L)}function H(L){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),F}function F(L){return gt(L)?St(e,Y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):Y(L)}function Y(L){return e.enter("htmlTextData"),o(L)}}const tE={name:"labelEnd",resolveAll:pq,resolveTo:gq,tokenize:bq},fq={tokenize:xq},hq={tokenize:yq},mq={tokenize:vq};function pq(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&xa(e,0,e.length,n),e}function gq(e,t){let n=e.length,r=0,a,s,o,c;for(;n--;)if(a=e[n][1],s){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(s=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(o=n);const d={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},f={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},m={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return c=[["enter",d,t],["enter",f,t]],c=Ma(c,e.slice(s+1,s+r+3)),c=Ma(c,[["enter",m,t]]),c=Ma(c,kg(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),c=Ma(c,[["exit",m,t],e[o-2],e[o-1],["exit",f,t]]),c=Ma(c,e.slice(o+1)),c=Ma(c,[["exit",d,t]]),xa(e,s,e.length,c),e}function bq(e,t,n){const r=this;let a=r.events.length,s,o;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){s=r.events[a][1];break}return c;function c(b){return s?s._inactive?p(b):(o=r.parser.defined.includes(ti(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(b),e.exit("labelMarker"),e.exit("labelEnd"),d):n(b)}function d(b){return b===40?e.attempt(fq,m,o?m:p)(b):b===91?e.attempt(hq,m,o?f:p)(b):o?m(b):p(b)}function f(b){return e.attempt(mq,m,p)(b)}function m(b){return t(b)}function p(b){return s._balanced=!0,n(b)}}function xq(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),a}function a(p){return Wt(p)?Xd(e,s)(p):s(p)}function s(p){return p===41?m(p):NR(e,o,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return Wt(p)?Xd(e,d)(p):m(p)}function c(p){return n(p)}function d(p){return p===34||p===39||p===40?SR(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):m(p)}function f(p){return Wt(p)?Xd(e,m)(p):m(p)}function m(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function yq(e,t,n){const r=this;return a;function a(c){return _R.call(r,e,s,o,"reference","referenceMarker","referenceString")(c)}function s(c){return r.parser.defined.includes(ti(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function o(c){return n(c)}}function vq(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),a}function a(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const Eq={name:"labelStartImage",resolveAll:tE.resolveAll,tokenize:Nq};function Nq(e,t,n){const r=this;return a;function a(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),s}function s(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),o):n(c)}function o(c){return c===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(c):t(c)}}const _q={name:"labelStartLink",resolveAll:tE.resolveAll,tokenize:Sq};function Sq(e,t,n){const r=this;return a;function a(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Xx={name:"lineEnding",tokenize:Tq};function Tq(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),St(e,t,"linePrefix")}}const tp={name:"thematicBreak",tokenize:wq};function wq(e,t,n){let r=0,a;return s;function s(f){return e.enter("thematicBreak"),o(f)}function o(f){return a=f,c(f)}function c(f){return f===a?(e.enter("thematicBreakSequence"),d(f)):r>=3&&(f===null||Xe(f))?(e.exit("thematicBreak"),t(f)):n(f)}function d(f){return f===a?(e.consume(f),r++,d):(e.exit("thematicBreakSequence"),gt(f)?St(e,c,"whitespace")(f):c(f))}}const Xr={continuation:{tokenize:Oq},exit:Rq,name:"list",tokenize:kq},Aq={partial:!0,tokenize:Mq},Cq={partial:!0,tokenize:Iq};function kq(e,t,n){const r=this,a=r.events[r.events.length-1];let s=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,o=0;return c;function c(x){const E=r.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(E==="listUnordered"?!r.containerState.marker||x===r.containerState.marker:gv(x)){if(r.containerState.type||(r.containerState.type=E,e.enter(E,{_container:!0})),E==="listUnordered")return e.enter("listItemPrefix"),x===42||x===45?e.check(tp,n,f)(x):f(x);if(!r.interrupt||x===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(x)}return n(x)}function d(x){return gv(x)&&++o<10?(e.consume(x),d):(!r.interrupt||o<2)&&(r.containerState.marker?x===r.containerState.marker:x===41||x===46)?(e.exit("listItemValue"),f(x)):n(x)}function f(x){return e.enter("listItemMarker"),e.consume(x),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||x,e.check(Bf,r.interrupt?n:m,e.attempt(Aq,b,p))}function m(x){return r.containerState.initialBlankLine=!0,s++,b(x)}function p(x){return gt(x)?(e.enter("listItemPrefixWhitespace"),e.consume(x),e.exit("listItemPrefixWhitespace"),b):n(x)}function b(x){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(x)}}function Oq(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Bf,a,s);function a(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,St(e,t,"listItemIndent",r.containerState.size+1)(c)}function s(c){return r.containerState.furtherBlankLines||!gt(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Cq,t,o)(c))}function o(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,St(e,e.attempt(Xr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function Iq(e,t,n){const r=this;return St(e,a,"listItemIndent",r.containerState.size+1);function a(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Rq(e){e.exit(this.containerState.type)}function Mq(e,t,n){const r=this;return St(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(s){const o=r.events[r.events.length-1];return!gt(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const eA={name:"setextUnderline",resolveTo:jq,tokenize:Dq};function jq(e,t){let n=e.length,r,a,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",s?(e.splice(a,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Dq(e,t,n){const r=this;let a;return s;function s(f){let m=r.events.length,p;for(;m--;)if(r.events[m][1].type!=="lineEnding"&&r.events[m][1].type!=="linePrefix"&&r.events[m][1].type!=="content"){p=r.events[m][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),a=f,o(f)):n(f)}function o(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===a?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),gt(f)?St(e,d,"lineSuffix")(f):d(f))}function d(f){return f===null||Xe(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const Lq={tokenize:Pq};function Pq(e){const t=this,n=e.attempt(Bf,r,e.attempt(this.parser.constructs.flowInitial,a,St(e,e.attempt(this.parser.constructs.flow,a,e.attempt(HY,a)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Bq={resolveAll:wR()},Uq=TR("string"),Fq=TR("text");function TR(e){return{resolveAll:wR(e==="text"?zq:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],s=n.attempt(a,o,c);return o;function o(m){return f(m)?s(m):c(m)}function c(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),d}function d(m){return f(m)?(n.exit("data"),s(m)):(n.consume(m),d)}function f(m){if(m===null)return!0;const p=a[m];let b=-1;if(p)for(;++b<p.length;){const x=p[b];if(!x.previous||x.previous.call(r,r.previous))return!0}return!1}}}function wR(e){return t;function t(n,r){let a=-1,s;for(;++a<=n.length;)s===void 0?n[a]&&n[a][1].type==="data"&&(s=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==s+2&&(n[s][1].end=n[a-1][1].end,n.splice(s+2,a-s-2),a=s+2),s=void 0);return e?e(n,r):n}}function zq(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let s=a.length,o=-1,c=0,d;for(;s--;){const f=a[s];if(typeof f=="string"){for(o=f.length;f.charCodeAt(o-1)===32;)c++,o--;if(o)break;o=-1}else if(f===-2)d=!0,c++;else if(f!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const f={type:n===e.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...f.start},r.start.offset===r.end.offset?Object.assign(r,f):(e.splice(n,0,["enter",f,t],["exit",f,t]),n+=2)}n++}return e}const Hq={42:Xr,43:Xr,45:Xr,48:Xr,49:Xr,50:Xr,51:Xr,52:Xr,53:Xr,54:Xr,55:Xr,56:Xr,57:Xr,62:xR},$q={91:KY},Yq={[-2]:Wx,[-1]:Wx,32:Wx},qq={35:JY,42:tp,45:[eA,tp],60:rq,61:eA,95:tp,96:Z2,126:Z2},Gq={38:vR,92:yR},Kq={[-5]:Xx,[-4]:Xx,[-3]:Xx,33:Eq,38:vR,42:bv,60:[_Y,cq],91:_q,92:[QY,yR],93:tE,95:bv,96:LY},Vq={null:[bv,Bq]},Wq={null:[42,95]},Xq={null:[]},Qq=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Wq,contentInitial:$q,disable:Xq,document:Hq,flow:qq,flowInitial:Yq,insideSpan:Vq,string:Gq,text:Kq},Symbol.toStringTag,{value:"Module"}));function Zq(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},s=[];let o=[],c=[];const d={attempt:D(R),check:D(k),consume:C,enter:A,exit:O,interrupt:D(k,{interrupt:!0})},f={code:null,containerState:{},defineSkip:N,events:[],now:E,parser:e,previous:null,sliceSerialize:b,sliceStream:x,write:p};let m=t.tokenize.call(f,d);return t.resolveAll&&s.push(t),f;function p(z){return o=Ma(o,z),T(),o[o.length-1]!==null?[]:(B(t,0),f.events=kg(s,f.events,f),f.events)}function b(z,G){return eG(x(z),G)}function x(z){return Jq(o,z)}function E(){const{_bufferIndex:z,_index:G,line:ae,column:Z,offset:W}=r;return{_bufferIndex:z,_index:G,line:ae,column:Z,offset:W}}function N(z){a[z.line]=z.column,M()}function T(){let z;for(;r._index<o.length;){const G=o[r._index];if(typeof G=="string")for(z=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===z&&r._bufferIndex<G.length;)S(G.charCodeAt(r._bufferIndex));else S(G)}}function S(z){m=m(z)}function C(z){Xe(z)?(r.line++,r.column=1,r.offset+=z===-3?2:1,M()):z!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),f.previous=z}function A(z,G){const ae=G||{};return ae.type=z,ae.start=E(),f.events.push(["enter",ae,f]),c.push(ae),ae}function O(z){const G=c.pop();return G.end=E(),f.events.push(["exit",G,f]),G}function R(z,G){B(z,G.from)}function k(z,G){G.restore()}function D(z,G){return ae;function ae(Z,W,K){let H,F,Y,L;return Array.isArray(Z)?Q(Z):"tokenize"in Z?Q([Z]):$(Z);function $(V){return be;function be(ye){const fe=ye!==null&&V[ye],we=ye!==null&&V.null,Me=[...Array.isArray(fe)?fe:fe?[fe]:[],...Array.isArray(we)?we:we?[we]:[]];return Q(Me)(ye)}}function Q(V){return H=V,F=0,V.length===0?K:P(V[F])}function P(V){return be;function be(ye){return L=j(),Y=V,V.partial||(f.currentConstruct=V),V.name&&f.parser.constructs.disable.null.includes(V.name)?se():V.tokenize.call(G?Object.assign(Object.create(f),G):f,d,he,se)(ye)}}function he(V){return z(Y,L),W}function se(V){return L.restore(),++F<H.length?P(H[F]):K}}}function B(z,G){z.resolveAll&&!s.includes(z)&&s.push(z),z.resolve&&xa(f.events,G,f.events.length-G,z.resolve(f.events.slice(G),f)),z.resolveTo&&(f.events=z.resolveTo(f.events,f))}function j(){const z=E(),G=f.previous,ae=f.currentConstruct,Z=f.events.length,W=Array.from(c);return{from:Z,restore:K};function K(){r=z,f.previous=G,f.currentConstruct=ae,f.events.length=Z,c=W,M()}}function M(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function Jq(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,s=t.end._bufferIndex;let o;if(n===a)o=[e[n].slice(r,s)];else{if(o=e.slice(n,a),r>-1){const c=o[0];typeof c=="string"?o[0]=c.slice(r):o.shift()}s>0&&o.push(e[a].slice(0,s))}return o}function eG(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
@@ -548,7 +548,7 @@ Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}
548
548
  `))}function d(x,E,N,T){const S=N.enter("tableCell"),C=N.enter("phrasing"),A=N.containerPhrasing(x,{...T,before:s,after:s});return C(),S(),A}function f(x,E){return bV(x,{align:E,alignDelimiters:r,padding:n,stringLength:a})}function m(x,E,N){const T=x.children;let S=-1;const C=[],A=E.enter("table");for(;++S<T.length;)C[S]=p(T[S],E,N);return A(),C}function p(x,E,N){const T=x.children;let S=-1;const C=[],A=E.enter("tableRow");for(;++S<T.length;)C[S]=d(T[S],x,E,N);return A(),C}function b(x,E,N){let T=JR.inlineCode(x,E,N);return N.stack.includes("tableCell")&&(T=T.replace(/\|/g,"\\$&")),T}}function aW(){return{exit:{taskListCheckValueChecked:SA,taskListCheckValueUnchecked:SA,paragraph:sW}}}function iW(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:oW}}}function SA(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function sW(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let s=-1,o;for(;++s<a.length;){const c=a[s];if(c.type==="paragraph"){o=c;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function oW(e,t,n,r){const a=e.children[0],s=typeof e.checked=="boolean"&&a&&a.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);s&&c.move(o);let d=JR.listItem(e,t,n,{...r,...c.current()});return s&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),d;function f(m){return m+o}}function lW(){return[FK(),oV(),dV(),QV(),aW()]}function uW(e){return{extensions:[zK(),lV(e),fV(),rW(e),iW()]}}const cW={tokenize:gW,partial:!0},eM={tokenize:bW,partial:!0},tM={tokenize:xW,partial:!0},nM={tokenize:yW,partial:!0},dW={tokenize:vW,partial:!0},rM={name:"wwwAutolink",tokenize:mW,previous:iM},aM={name:"protocolAutolink",tokenize:pW,previous:sM},ys={name:"emailAutolink",tokenize:hW,previous:oM},Mi={};function fW(){return{text:Mi}}let Yo=48;for(;Yo<123;)Mi[Yo]=ys,Yo++,Yo===58?Yo=65:Yo===91&&(Yo=97);Mi[43]=ys;Mi[45]=ys;Mi[46]=ys;Mi[95]=ys;Mi[72]=[ys,aM];Mi[104]=[ys,aM];Mi[87]=[ys,rM];Mi[119]=[ys,rM];function hW(e,t,n){const r=this;let a,s;return o;function o(p){return!Nv(p)||!oM.call(r,r.previous)||uE(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(p))}function c(p){return Nv(p)?(e.consume(p),c):p===64?(e.consume(p),d):n(p)}function d(p){return p===46?e.check(dW,m,f)(p):p===45||p===95||_r(p)?(s=!0,e.consume(p),d):m(p)}function f(p){return e.consume(p),a=!0,d}function m(p){return s&&a&&Dr(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function mW(e,t,n){const r=this;return a;function a(o){return o!==87&&o!==119||!iM.call(r,r.previous)||uE(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(cW,e.attempt(eM,e.attempt(tM,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function pW(e,t,n){const r=this;let a="",s=!1;return o;function o(p){return(p===72||p===104)&&sM.call(r,r.previous)&&!uE(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(p),e.consume(p),c):n(p)}function c(p){if(Dr(p)&&a.length<5)return a+=String.fromCodePoint(p),e.consume(p),c;if(p===58){const b=a.toLowerCase();if(b==="http"||b==="https")return e.consume(p),d}return n(p)}function d(p){return p===47?(e.consume(p),s?f:(s=!0,d)):n(p)}function f(p){return p===null||xp(p)||Wt(p)||vl(p)||Cg(p)?n(p):e.attempt(eM,e.attempt(tM,m),n)(p)}function m(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function gW(e,t,n){let r=0;return a;function a(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),a):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function bW(e,t,n){let r,a,s;return o;function o(f){return f===46||f===95?e.check(nM,d,c)(f):f===null||Wt(f)||vl(f)||f!==45&&Cg(f)?d(f):(s=!0,e.consume(f),o)}function c(f){return f===95?r=!0:(a=r,r=void 0),e.consume(f),o}function d(f){return a||r||!s?n(f):t(f)}}function xW(e,t){let n=0,r=0;return a;function a(o){return o===40?(n++,e.consume(o),a):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(nM,t,s)(o):o===null||Wt(o)||vl(o)?t(o):(e.consume(o),a)}function s(o){return o===41&&r++,e.consume(o),a}}function yW(e,t,n){return r;function r(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),r):c===38?(e.consume(c),s):c===93?(e.consume(c),a):c===60||c===null||Wt(c)||vl(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||Wt(c)||vl(c)?t(c):r(c)}function s(c){return Dr(c)?o(c):n(c)}function o(c){return c===59?(e.consume(c),r):Dr(c)?(e.consume(c),o):n(c)}}function vW(e,t,n){return r;function r(s){return e.consume(s),a}function a(s){return _r(s)?n(s):t(s)}}function iM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Wt(e)}function sM(e){return!Dr(e)}function oM(e){return!(e===47||Nv(e))}function Nv(e){return e===43||e===45||e===46||e===95||_r(e)}function uE(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const EW={tokenize:kW,partial:!0};function NW(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:wW,continuation:{tokenize:AW},exit:CW}},text:{91:{name:"gfmFootnoteCall",tokenize:TW},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:_W,resolveTo:SW}}}}function _W(e,t,n){const r=this;let a=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;a--;){const d=r.events[a][1];if(d.type==="labelImage"){o=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!o||!o._balanced)return n(d);const f=ti(r.sliceSerialize({start:o.end,end:r.now()}));return f.codePointAt(0)!==94||!s.includes(f.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function SW(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},c=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...c),e}function TW(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),d}function d(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(s>999||p===93&&!o||p===null||p===91||Wt(p))return n(p);if(p===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return a.includes(ti(r.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Wt(p)||(o=!0),s++,e.consume(p),p===92?m:f}function m(p){return p===91||p===92||p===93?(e.consume(p),s++,f):f(p)}}function wW(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,c;return d;function d(E){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(E){return E===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",m):n(E)}function m(E){if(o>999||E===93&&!c||E===null||E===91||Wt(E))return n(E);if(E===93){e.exit("chunkString");const N=e.exit("gfmFootnoteDefinitionLabelString");return s=ti(r.sliceSerialize(N)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(E),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Wt(E)||(c=!0),o++,e.consume(E),E===92?p:m}function p(E){return E===91||E===92||E===93?(e.consume(E),o++,m):m(E)}function b(E){return E===58?(e.enter("definitionMarker"),e.consume(E),e.exit("definitionMarker"),a.includes(s)||a.push(s),St(e,x,"gfmFootnoteDefinitionWhitespace")):n(E)}function x(E){return t(E)}}function AW(e,t,n){return e.check(Bf,t,e.attempt(EW,t,n))}function CW(e){e.exit("gfmFootnoteDefinition")}function kW(e,t,n){const r=this;return St(e,a,"gfmFootnoteDefinitionIndent",5);function a(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function OW(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(o,c){let d=-1;for(;++d<o.length;)if(o[d][0]==="enter"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._close){let f=d;for(;f--;)if(o[f][0]==="exit"&&o[f][1].type==="strikethroughSequenceTemporary"&&o[f][1]._open&&o[d][1].end.offset-o[d][1].start.offset===o[f][1].end.offset-o[f][1].start.offset){o[d][1].type="strikethroughSequence",o[f][1].type="strikethroughSequence";const m={type:"strikethrough",start:Object.assign({},o[f][1].start),end:Object.assign({},o[d][1].end)},p={type:"strikethroughText",start:Object.assign({},o[f][1].end),end:Object.assign({},o[d][1].start)},b=[["enter",m,c],["enter",o[f][1],c],["exit",o[f][1],c],["enter",p,c]],x=c.parser.constructs.insideSpan.null;x&&xa(b,b.length,0,kg(x,o.slice(f+1,d),c)),xa(b,b.length,0,[["exit",p,c],["enter",o[d][1],c],["exit",o[d][1],c],["exit",m,c]]),xa(o,f-1,d-f+3,b),d=f+b.length-2;break}}for(d=-1;++d<o.length;)o[d][1].type==="strikethroughSequenceTemporary"&&(o[d][1].type="data");return o}function s(o,c,d){const f=this.previous,m=this.events;let p=0;return b;function b(E){return f===126&&m[m.length-1][1].type!=="characterEscape"?d(E):(o.enter("strikethroughSequenceTemporary"),x(E))}function x(E){const N=Vu(f);if(E===126)return p>1?d(E):(o.consume(E),p++,x);if(p<2&&!n)return d(E);const T=o.exit("strikethroughSequenceTemporary"),S=Vu(E);return T._open=!S||S===2&&!!N,T._close=!N||N===2&&!!S,c(E)}}}class IW{constructor(){this.map=[]}add(t,n,r){RW(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const s of a)t.push(s);a=r.pop()}this.map.length=0}}function RW(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function MW(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function jW(){return{flow:{null:{name:"table",tokenize:DW,resolveAll:LW}}}}function DW(e,t,n){const r=this;let a=0,s=0,o;return c;function c(M){let z=r.events.length-1;for(;z>-1;){const Z=r.events[z][1].type;if(Z==="lineEnding"||Z==="linePrefix")z--;else break}const G=z>-1?r.events[z][1].type:null,ae=G==="tableHead"||G==="tableRow"?k:d;return ae===k&&r.parser.lazy[r.now().line]?n(M):ae(M)}function d(M){return e.enter("tableHead"),e.enter("tableRow"),f(M)}function f(M){return M===124||(o=!0,s+=1),m(M)}function m(M){return M===null?n(M):Xe(M)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),x):n(M):gt(M)?St(e,m,"whitespace")(M):(s+=1,o&&(o=!1,a+=1),M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),o=!0,m):(e.enter("data"),p(M)))}function p(M){return M===null||M===124||Wt(M)?(e.exit("data"),m(M)):(e.consume(M),M===92?b:p)}function b(M){return M===92||M===124?(e.consume(M),p):p(M)}function x(M){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(M):(e.enter("tableDelimiterRow"),o=!1,gt(M)?St(e,E,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):E(M))}function E(M){return M===45||M===58?T(M):M===124?(o=!0,e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),N):R(M)}function N(M){return gt(M)?St(e,T,"whitespace")(M):T(M)}function T(M){return M===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),S):M===45?(s+=1,S(M)):M===null||Xe(M)?O(M):R(M)}function S(M){return M===45?(e.enter("tableDelimiterFiller"),C(M)):R(M)}function C(M){return M===45?(e.consume(M),C):M===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),A):(e.exit("tableDelimiterFiller"),A(M))}function A(M){return gt(M)?St(e,O,"whitespace")(M):O(M)}function O(M){return M===124?E(M):M===null||Xe(M)?!o||a!==s?R(M):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(M)):R(M)}function R(M){return n(M)}function k(M){return e.enter("tableRow"),D(M)}function D(M){return M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),D):M===null||Xe(M)?(e.exit("tableRow"),t(M)):gt(M)?St(e,D,"whitespace")(M):(e.enter("data"),B(M))}function B(M){return M===null||M===124||Wt(M)?(e.exit("data"),D(M)):(e.consume(M),M===92?j:B)}function j(M){return M===92||M===124?(e.consume(M),B):B(M)}}function LW(e,t){let n=-1,r=!0,a=0,s=[0,0,0,0],o=[0,0,0,0],c=!1,d=0,f,m,p;const b=new IW;for(;++n<e.length;){const x=e[n],E=x[1];x[0]==="enter"?E.type==="tableHead"?(c=!1,d!==0&&(TA(b,t,d,f,m),m=void 0,d=0),f={type:"table",start:Object.assign({},E.start),end:Object.assign({},E.end)},b.add(n,0,[["enter",f,t]])):E.type==="tableRow"||E.type==="tableDelimiterRow"?(r=!0,p=void 0,s=[0,0,0,0],o=[0,n+1,0,0],c&&(c=!1,m={type:"tableBody",start:Object.assign({},E.start),end:Object.assign({},E.end)},b.add(n,0,[["enter",m,t]])),a=E.type==="tableDelimiterRow"?2:m?3:1):a&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],p=Am(b,t,s,a,void 0,p),s=[0,0,0,0]),o[2]=n)):E.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],p=Am(b,t,s,a,void 0,p)),s=o,o=[s[1],n,0,0])):E.type==="tableHead"?(c=!0,d=n):E.type==="tableRow"||E.type==="tableDelimiterRow"?(d=n,s[1]!==0?(o[0]=o[1],p=Am(b,t,s,a,n,p)):o[1]!==0&&(p=Am(b,t,o,a,n,p)),a=0):a&&(E.type==="data"||E.type==="tableDelimiterMarker"||E.type==="tableDelimiterFiller")&&(o[3]=n)}for(d!==0&&TA(b,t,d,f,m),b.consume(t.events),n=-1;++n<t.events.length;){const x=t.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=MW(t.events,n))}return e}function Am(e,t,n,r,a,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(s.end=Object.assign({},ju(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const d=ju(t.events,n[1]);if(s={type:o,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const f=ju(t.events,n[2]),m=ju(t.events,n[3]),p={type:c,start:Object.assign({},f),end:Object.assign({},m)};if(e.add(n[2],0,[["enter",p,t]]),r!==2){const b=t.events[n[2]],x=t.events[n[3]];if(b[1].end=Object.assign({},x[1].end),b[1].type="chunkText",b[1].contentType="text",n[3]>n[2]+1){const E=n[2]+1,N=n[3]-n[2]-1;e.add(E,N,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return a!==void 0&&(s.end=Object.assign({},ju(t.events,a)),e.add(a,0,[["exit",s,t]]),s=void 0),s}function TA(e,t,n,r,a){const s=[],o=ju(t.events,n);a&&(a.end=Object.assign({},o),s.push(["exit",a,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function ju(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const PW={name:"tasklistCheck",tokenize:UW};function BW(){return{text:{91:PW}}}function UW(e,t,n){const r=this;return a;function a(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),s)}function s(d){return Wt(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),o):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),o):n(d)}function o(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(d)}function c(d){return Xe(d)?t(d):gt(d)?e.check({tokenize:FW},t,n)(d):n(d)}}function FW(e,t,n){return St(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function zW(e){return gR([fW(),NW(),OW(e),jW(),BW()])}const HW={};function Nl(e){const t=this,n=e||HW,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(zW(n)),s.push(lW()),o.push(uW(n))}const np=ai(e=>({drafts:{},setDraft:(t,n)=>e(r=>{if(!n.trim()){const{[t]:a,...s}=r.drafts;return{drafts:s}}return{drafts:{...r.drafts,[t]:n}}}),clearDraft:t=>e(n=>{const{[t]:r,...a}=n.drafts;return{drafts:a}})})),$W=5*1024*1024,wA=10,lM=["image/png","image/jpeg","image/gif","image/webp"],YW=5,qW=500;let AA=0;function uM(e){return e.split(`
549
549
  `).length>YW||e.length>qW}function GW(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function KW(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function VW({url:e,label:t,onClose:n}){return y.useEffect(()=>{const r=a=>{a.key==="Escape"&&(a.preventDefault(),n())};return window.addEventListener("keydown",r,!0),()=>window.removeEventListener("keydown",r,!0)},[n]),u.jsx("div",{role:"dialog","aria-modal":"true","aria-label":t,onClick:n,className:"fixed inset-0 z-50 flex cursor-zoom-out items-center justify-center bg-black/80 p-8 backdrop-blur-sm",children:u.jsx("img",{src:e,alt:t,className:"max-h-full max-w-full object-contain"})})}function cE({url:e,label:t,className:n}){const[r,a]=y.useState(!1);return u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:()=>a(!0),"aria-label":`预览 ${t}`,className:"block cursor-zoom-in rounded-md transition-opacity duration-150 hover:opacity-80",children:u.jsx("img",{src:e,alt:t,className:re("rounded-md border border-line",n)})}),r&&u.jsx(VW,{url:e,label:t,onClose:()=>a(!1)})]})}function cM(e=!0){const[t,n]=y.useState([]),[r,a]=y.useState([]),[s,o]=y.useState(null);y.useEffect(()=>{o(null),e||n([])},[e]);const c=async N=>{const T=[],S=[],C=t.length;let A=wA-C;for(const O of N){if(A<=0){S.push(`最多 ${wA} 张图片`);break}if(!lM.includes(O.type)){S.push(`${O.name||"文件"}:格式不支持`);continue}if(O.size>$W){S.push(`${O.name}:超过 5MB`);continue}T.push({_id:`att-${++AA}`,mime:O.type,url:await KW(O),filename:O.name}),A--}T.length>0&&n(O=>[...O,...T]),o(S.length>0?S.join(";"):null)},d=N=>{const T=Array.from(N.clipboardData.files);if(T.length!==0){if(N.preventDefault(),!e){o("当前模型不支持图片");return}c(T)}},f=N=>{const T=++AA,S=N.split(`
550
550
  `).length,C=new TextEncoder().encode(N).byteLength,A=`[粘贴文本 #${T} · ${S}行]`,O={_id:`fold-${T}`,text:N,lineCount:S,byteSize:C,placeholder:A};return a(R=>[...R,O]),O},m=N=>{let T=N;for(const S of r)T=T.replace(S.placeholder,S.text);return T},p=N=>n(T=>T.filter(S=>S._id!==N)),b=N=>a(T=>T.filter(S=>S._id!==N)),x=y.useCallback(()=>{n([]),a([]),o(null)},[]),E=t.map(({mime:N,url:T,filename:S})=>({mime:N,url:T,filename:S}));return{attachments:t,foldedTexts:r,promptFiles:E,error:s,setError:o,addFiles:c,onPaste:d,addFoldedText:f,expandFoldedTexts:m,remove:p,removeFoldedText:b,clear:x}}function WW({text:e,label:t,onClose:n}){y.useEffect(()=>{const s=o=>{o.key==="Escape"&&(o.preventDefault(),n())};return window.addEventListener("keydown",s,!0),()=>window.removeEventListener("keydown",s,!0)},[n]);const r=e.split(`
551
- `),a=String(r.length).length;return u.jsx("div",{role:"dialog","aria-modal":"true","aria-label":t,onClick:n,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm md:p-8",children:u.jsxs("div",{onClick:s=>s.stopPropagation(),className:"flex max-h-full w-full max-w-4xl flex-col overflow-hidden rounded-lg border border-line bg-term",children:[u.jsxs("div",{className:"flex items-center justify-between border-b border-line px-4 py-2",children:[u.jsx("span",{className:"font-mono text-xs text-fg-3",children:t}),u.jsx("button",{type:"button",onClick:n,className:"text-fg-5 hover:text-fg-2",children:u.jsx(ct,{className:"h-4 w-4"})})]}),u.jsx("pre",{className:"overflow-auto p-4 font-mono text-xs leading-relaxed text-fg-2",children:r.map((s,o)=>u.jsxs("div",{children:[u.jsx("span",{className:"mr-3 inline-block select-none text-right text-fg-6",style:{width:`${a}ch`},children:o+1}),s]},o))})]})})}function XW({fold:e,index:t,onRemove:n}){const[r,a]=y.useState(!1),s=`粘贴文本 #${t} · ${e.lineCount}行 · ${GW(e.byteSize)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"group relative flex items-center gap-1.5 rounded-md border border-line bg-elevated/50 px-2.5 py-1.5",children:[u.jsxs("button",{type:"button",onClick:()=>a(!0),className:"flex items-center gap-1.5 font-mono text-xs text-fg-3 transition-colors hover:text-fg",children:[u.jsx(po,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),u.jsx("span",{children:s})]}),u.jsx("button",{type:"button",onClick:n,"aria-label":"移除粘贴文本",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-fg-5 transition-colors hover:text-fg-2",children:u.jsx(ct,{className:"h-2.5 w-2.5",strokeWidth:2.5})})]}),r&&u.jsx(WW,{text:e.text,label:s,onClose:()=>a(!1)})]})}function dM({onFiles:e,disabled:t,allowed:n}){const r=y.useRef(null);return u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:r,type:"file",accept:lM.join(","),multiple:!0,hidden:!0,onChange:a=>{e(Array.from(a.target.files??[])),a.target.value=""}}),u.jsx("button",{type:"button",onClick:()=>{var a;return(a=r.current)==null?void 0:a.click()},disabled:t||!n,"aria-label":"Attach image",title:n?"附加图片":"当前模型不支持图片",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:u.jsx(sF,{className:"h-4 w-4"})})]})}function fM({attachments:e,foldedTexts:t,error:n,onRemove:r,onRemoveFoldedText:a,className:s}){const o=e.length>0||(t??[]).length>0;return!o&&!n?null:u.jsxs("div",{className:s,children:[o&&u.jsxs("div",{className:"mb-2 flex flex-wrap gap-2",children:[e.map(c=>u.jsxs("div",{className:"group relative",children:[u.jsx(cE,{url:c.url,label:c.filename??"attachment",className:"h-16 w-16 object-cover"}),u.jsx("button",{type:"button",onClick:()=>r(c._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:u.jsx(ct,{className:"h-2.5 w-2.5",strokeWidth:2.5})})]},c._id)),(t??[]).map((c,d)=>u.jsx(XW,{fold:c,index:d+1,onRemove:()=>a==null?void 0:a(c._id)},c._id))]}),n&&u.jsx("div",{className:"mb-2 font-mono text-[11px] text-red-400",children:n})]})}function hM({isListening:e,disabled:t,onStart:n,onStop:r}){const a=y.useRef(!1),s=c=>{if(t)return;c.preventDefault(),a.current=!0,n();const d=()=>{document.removeEventListener("touchend",d),document.removeEventListener("touchcancel",d),a.current=!1,r()};document.addEventListener("touchend",d,{once:!0}),document.addEventListener("touchcancel",d,{once:!0})},o=()=>{if(t||a.current)return;n();const c=()=>{document.removeEventListener("mouseup",c),r()};document.addEventListener("mouseup",c,{once:!0})};return u.jsx("button",{type:"button",disabled:t,onTouchStart:s,onMouseDown:o,onContextMenu:c=>c.preventDefault(),"aria-label":"按住说话",title:"按住说话",style:{WebkitTouchCallout:"none"},className:re("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:u.jsx(NF,{className:re("h-6 w-6 sm:h-4 sm:w-4",e&&"animate-pulse")})})}const QW=[.85,1.25,.65,1.4,.75,1.15,.95],uy=4,CA=24;function ZW(e){const t=Math.floor(e/60).toString().padStart(2,"0"),n=Math.floor(e%60).toString().padStart(2,"0");return`${t}:${n}`}function JW({volumeLevel:e}){const t=Math.min(Math.max(e,0),1);return u.jsx("div",{className:"flex h-6 items-center gap-1","aria-hidden":"true",children:QW.map((n,r)=>{const a=uy+t*n*(CA-uy),s=Math.max(uy,Math.min(CA,a));return u.jsx("span",{className:"w-1 rounded-full bg-red-400 transition-[height] duration-150 ease-out",style:{height:`${s}px`}},r)})})}function mM({phase:e,transcript:t,interimTranscript:n,editText:r,onEditTextChange:a,onTextareaKeyDown:s,textareaRef:o,wrapperClassName:c}){if(e==="idle")return null;const d=t.length>0||n.length>0;return u.jsx("div",{className:c,children:u.jsxs("div",{className:"max-h-[40vh] overflow-y-auto px-4 py-4",children:[e==="recording"&&u.jsx("div",{className:"text-xl leading-relaxed",children:d?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-fg",children:t}),n&&u.jsx("span",{className:"text-fg-4",children:n})]}):u.jsx("span",{className:"italic text-fg-5",children:"正在聆听…"})}),e==="recognizing"&&u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(an,{className:"h-5 w-5 shrink-0 text-emerald-400 fs-spin"}),u.jsx("span",{className:"font-mono text-sm text-emerald-400",children:"识别中…"}),n&&u.jsx("span",{className:"truncate text-base text-fg-4",children:n})]}),e==="done"&&u.jsx("textarea",{ref:o,value:r,onChange:f=>a(f.target.value),onKeyDown:s,rows:2,placeholder:"识别结果(可编辑)",className:"w-full resize-none bg-transparent text-xl leading-relaxed text-fg placeholder:text-fg-5 focus:outline-none"})]})})}function pM({phase:e,volumeLevel:t,elapsed:n,editText:r,error:a,onCancel:s,onConfirm:o,idleHint:c,className:d}){return e==="idle"?u.jsx("div",{className:d,children:a?u.jsx("span",{className:"font-mono text-[10px] text-red-400",children:a}):c?u.jsx("span",{className:"font-mono text-[10px] text-fg-6",children:c}):null}):e==="done"?u.jsxs("div",{className:d,children:[u.jsx("span",{className:"hidden font-mono text-[10px] text-fg-6 sm:inline",children:"⌘/Ctrl+⏎ 发送 · Esc 取消"}),u.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[u.jsx("button",{type:"button",onClick:s,className:"rounded-md border border-line px-3 py-1 text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"取消"}),u.jsxs("button",{type:"button",onClick:o,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:[u.jsx(cf,{className:"h-3.5 w-3.5",strokeWidth:2.5}),u.jsx("span",{children:"发送"})]})]})]}):u.jsx("div",{className:d,children:e==="recording"?u.jsxs(u.Fragment,{children:[u.jsx(JW,{volumeLevel:t}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[11px] font-medium text-red-400",children:[u.jsx("span",{className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-red-400"}),"录音中"]}),u.jsx("span",{className:"font-mono text-[11px] tabular-nums text-fg-4",children:ZW(n)})]}):u.jsxs(u.Fragment,{children:[u.jsx(an,{className:"h-4 w-4 shrink-0 text-emerald-400 fs-spin"}),u.jsx("span",{className:"font-mono text-[11px] text-emerald-400",children:"识别中…"})]})})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var Xu;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(Xu||(Xu={}));class cy extends Error{constructor(t,n,r){super(t),this.message=t,this.code=n,this.data=r}}const eX=e=>{var t,n;return e!=null&&e.androidBridge?"android":!((n=(t=e==null?void 0:e.webkit)===null||t===void 0?void 0:t.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},tX=e=>{const t=e.CapacitorCustomPlatform||null,n=e.Capacitor||{},r=n.Plugins=n.Plugins||{},a=()=>t!==null?t.name:eX(e),s=()=>a()!=="web",o=p=>{const b=f.get(p);return!!(b!=null&&b.platforms.has(a())||c(p))},c=p=>{var b;return(b=n.PluginHeaders)===null||b===void 0?void 0:b.find(x=>x.name===p)},d=p=>e.console.error(p),f=new Map,m=(p,b={})=>{const x=f.get(p);if(x)return console.warn(`Capacitor plugin "${p}" already registered. Cannot register plugins twice.`),x.proxy;const E=a(),N=c(p);let T;const S=async()=>(!T&&E in b?T=typeof b[E]=="function"?T=await b[E]():T=b[E]:t!==null&&!T&&"web"in b&&(T=typeof b.web=="function"?T=await b.web():T=b.web),T),C=(B,j)=>{var M,z;if(N){const G=N==null?void 0:N.methods.find(ae=>j===ae.name);if(G)return G.rtype==="promise"?ae=>n.nativePromise(p,j.toString(),ae):(ae,Z)=>n.nativeCallback(p,j.toString(),ae,Z);if(B)return(M=B[j])===null||M===void 0?void 0:M.bind(B)}else{if(B)return(z=B[j])===null||z===void 0?void 0:z.bind(B);throw new cy(`"${p}" plugin is not implemented on ${E}`,Xu.Unimplemented)}},A=B=>{let j;const M=(...z)=>{const G=S().then(ae=>{const Z=C(ae,B);if(Z){const W=Z(...z);return j=W==null?void 0:W.remove,W}else throw new cy(`"${p}.${B}()" is not implemented on ${E}`,Xu.Unimplemented)});return B==="addListener"&&(G.remove=async()=>j()),G};return M.toString=()=>`${B.toString()}() { [capacitor code] }`,Object.defineProperty(M,"name",{value:B,writable:!1,configurable:!1}),M},O=A("addListener"),R=A("removeListener"),k=(B,j)=>{const M=O({eventName:B},j),z=async()=>{const ae=await M;R({eventName:B,callbackId:ae},j)},G=new Promise(ae=>M.then(()=>ae({remove:z})));return G.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await z()},G},D=new Proxy({},{get(B,j){switch(j){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return N?k:O;case"removeListener":return R;default:return A(j)}}});return r[p]=D,f.set(p,{name:p,proxy:D,platforms:new Set([...Object.keys(b),...N?[E]:[]])}),D};return n.convertFileSrc||(n.convertFileSrc=p=>p),n.getPlatform=a,n.handleError=d,n.isNativePlatform=s,n.isPluginAvailable=o,n.registerPlugin=m,n.Exception=cy,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},nX=e=>e.Capacitor=tX(e),Ep=nX(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Rg=Ep.registerPlugin;class dE{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(t,n){let r=!1;this.listeners[t]||(this.listeners[t]=[],r=!0),this.listeners[t].push(n);const s=this.windowListeners[t];s&&!s.registered&&this.addWindowListener(s),r&&this.sendRetainedArgumentsForEvent(t);const o=async()=>this.removeListener(t,n);return Promise.resolve({remove:o})}async removeAllListeners(){this.listeners={};for(const t in this.windowListeners)this.removeWindowListener(this.windowListeners[t]);this.windowListeners={}}notifyListeners(t,n,r){const a=this.listeners[t];if(!a){if(r){let s=this.retainedEventArguments[t];s||(s=[]),s.push(n),this.retainedEventArguments[t]=s}return}a.forEach(s=>s(n))}hasListeners(t){var n;return!!(!((n=this.listeners[t])===null||n===void 0)&&n.length)}registerWindowListener(t,n){this.windowListeners[n]={registered:!1,windowEventName:t,pluginEventName:n,handler:r=>{this.notifyListeners(n,r)}}}unimplemented(t="not implemented"){return new Ep.Exception(t,Xu.Unimplemented)}unavailable(t="not available"){return new Ep.Exception(t,Xu.Unavailable)}async removeListener(t,n){const r=this.listeners[t];if(!r)return;const a=r.indexOf(n);a!==-1&&this.listeners[t].splice(a,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 n=this.retainedEventArguments[t];n&&(delete this.retainedEventArguments[t],n.forEach(r=>{this.notifyListeners(t,r)}))}}const kA=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),OA=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class rX extends dE{async getCookies(){const t=document.cookie,n={};return t.split(";").forEach(r=>{if(r.length<=0)return;let[a,s]=r.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");a=OA(a).trim(),s=OA(s).trim(),n[a]=s}),n}async setCookie(t){try{const n=kA(t.key),r=kA(t.value),a=t.expires?`; expires=${t.expires.replace("expires=","")}`:"",s=(t.path||"/").replace("path=",""),o=t.url!=null&&t.url.length>0?`domain=${t.url}`:"";document.cookie=`${n}=${r||""}${a}; path=${s}; ${o};`}catch(n){return Promise.reject(n)}}async deleteCookie(t){try{document.cookie=`${t.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{const t=document.cookie.split(";")||[];for(const n of t)document.cookie=n.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)}}}Rg("CapacitorCookies",{web:()=>new rX});const aX=async e=>new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const a=r.result;t(a.indexOf(",")>=0?a.split(",")[1]:a)},r.onerror=a=>n(a),r.readAsDataURL(e)}),iX=(e={})=>{const t=Object.keys(e);return Object.keys(e).map(a=>a.toLocaleLowerCase()).reduce((a,s,o)=>(a[s]=e[t[o]],a),{})},sX=(e,t=!0)=>e?Object.entries(e).reduce((r,a)=>{const[s,o]=a;let c,d;return Array.isArray(o)?(d="",o.forEach(f=>{c=t?encodeURIComponent(f):f,d+=`${s}=${c}&`}),d.slice(0,-1)):(c=t?encodeURIComponent(o):o,d=`${s}=${c}`),`${r}&${d}`},"").substr(1):null,oX=(e,t={})=>{const n=Object.assign({method:e.method||"GET",headers:e.headers},t),a=iX(e.headers)["content-type"]||"";if(typeof e.data=="string")n.body=e.data;else if(a.includes("application/x-www-form-urlencoded")){const s=new URLSearchParams;for(const[o,c]of Object.entries(e.data||{}))s.set(o,c);n.body=s.toString()}else if(a.includes("multipart/form-data")||e.data instanceof FormData){const s=new FormData;if(e.data instanceof FormData)e.data.forEach((c,d)=>{s.append(d,c)});else for(const c of Object.keys(e.data))s.append(c,e.data[c]);n.body=s;const o=new Headers(n.headers);o.delete("content-type"),n.headers=o}else(a.includes("application/json")||typeof e.data=="object")&&(n.body=JSON.stringify(e.data));return n};class lX extends dE{async request(t){const n=oX(t,t.webFetchExtra),r=sX(t.params,t.shouldEncodeUrlParams),a=r?`${t.url}?${r}`:t.url,s=await fetch(a,n),o=s.headers.get("content-type")||"";let{responseType:c="text"}=s.ok?t:{};o.includes("application/json")&&(c="json");let d,f;switch(c){case"arraybuffer":case"blob":f=await s.blob(),d=await aX(f);break;case"json":d=await s.json();break;case"document":case"text":default:d=await s.text()}const m={};return s.headers.forEach((p,b)=>{m[b]=p}),{data:d,headers:m,status:s.status,url:s.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"}))}}Rg("CapacitorHttp",{web:()=>new lX});var IA;(function(e){e.Dark="DARK",e.Light="LIGHT",e.Default="DEFAULT"})(IA||(IA={}));var RA;(function(e){e.StatusBar="StatusBar",e.NavigationBar="NavigationBar"})(RA||(RA={}));class uX extends dE{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")}}Rg("SystemBars",{web:()=>new uX});const cX="modulepreload",dX=function(e){return"/"+e},MA={},fX=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let o=function(f){return Promise.all(f.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=o(n.map(f=>{if(f=dX(f),f in MA)return;MA[f]=!0;const m=f.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const b=document.createElement("link");if(b.rel=m?"stylesheet":cX,m||(b.as="script"),b.crossOrigin="",b.href=f,d&&b.setAttribute("nonce",d),document.head.appendChild(b),m)return new Promise((x,E)=>{b.addEventListener("load",x),b.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function s(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return a.then(o=>{for(const c of o||[])c.status==="rejected"&&s(c.reason);return t().catch(s)})},wu=Rg("SpeechRecognition",{web:()=>fX(()=>import("./web-Dcpy6YbD.js"),[]).then(e=>new e.SpeechRecognitionWeb)});function hX(e,t){const n=e.length,r=new ArrayBuffer(44+n*2),a=new DataView(r),s=(o,c)=>{for(let d=0;d<c.length;d++)a.setUint8(o+d,c.charCodeAt(d))};s(0,"RIFF"),a.setUint32(4,36+n*2,!0),s(8,"WAVE"),s(12,"fmt "),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,1,!0),a.setUint32(24,t,!0),a.setUint32(28,t*2,!0),a.setUint16(32,2,!0),a.setUint16(34,16,!0),s(36,"data"),a.setUint32(40,n*2,!0);for(let o=0;o<n;o++){const c=Math.max(-1,Math.min(1,e[o]));a.setInt16(44+o*2,c<0?c*32768:c*32767,!0)}return new Blob([r],{type:"audio/wav"})}const _v=Ep.isNativePlatform(),dy=!_v&&typeof window<"u"?window.SpeechRecognition??window.webkitSpeechRecognition:void 0,fy=16e3;function mX(e="zh-CN"){const[t,n]=y.useState(!1),[r,a]=y.useState(""),[s,o]=y.useState(""),[c,d]=y.useState(null),[f,m]=y.useState(0),[p,b]=y.useState("idle"),x=y.useRef(null),E=y.useRef(!1),N=y.useRef([]),T=y.useRef(!1),S=y.useRef(null),C=y.useRef(!1),A=y.useRef(""),O=y.useRef(null),R=y.useRef(null),k=y.useRef(null),D=y.useRef([]),B=y.useRef(!1),j=!0,M=y.useCallback(async()=>{var P,he,se;(P=k.current)==null||P.disconnect(),(he=R.current)==null||he.getTracks().forEach(V=>V.stop()),await((se=O.current)==null?void 0:se.close().catch(()=>{}));const H=D.current;if(D.current=[],k.current=null,R.current=null,O.current=null,H.length===0||B.current){n(!1),b("idle");return}o("识别中…"),b("recognizing");const F=H.reduce((V,be)=>V+be.length,0),Y=new Float32Array(F);let L=0;for(const V of H)Y.set(V,L),L+=V.length;const $=hX(Y,fy),Q=new FormData;Q.append("audio",$,"recording.wav");try{const V=await fetch("/api/transcribe",{method:"POST",body:Q});if(B.current)return;if(V.ok){const{text:be}=await V.json();be?(a(be),b("done")):b("idle")}else{const be=await V.json().catch(()=>({error:`HTTP ${V.status}`}));d(be.error??`HTTP ${V.status}`),b("idle")}}catch(V){d(`语音识别失败:${V instanceof Error?V.message:String(V)}`),b("idle")}finally{o(""),n(!1)}},[]),z=y.useCallback(async()=>{if(E.current=!0,S.current&&(clearTimeout(S.current),S.current=null),_v){await wu.stop().catch(()=>{});for(const H of N.current)await H.remove().catch(()=>{});N.current=[],n(!1),o("")}else x.current?x.current.stop():O.current?await M():(n(!1),b("idle"))},[M]),G=y.useCallback(async()=>{var L;B.current=!1,a(""),o(""),d(null),b("idle");const{available:H}=await wu.available();if(!H){d("当前设备不支持语音识别");return}if((await wu.requestPermissions()).speechRecognition!=="granted"){d("请允许语音识别权限");return}const Y=[];Y.push(await wu.addListener("partialResults",$=>{o($.matches[0]??"")})),Y.push(await wu.addListener("listeningState",$=>{const Q=$.status==="started";n(Q),Q&&b("recording"),Q||o("")})),N.current=Y;try{const $=await wu.start({language:e,partialResults:!0,maxResults:1});(L=$.matches)!=null&&L.length&&a(Q=>Q+$.matches.join(""))}catch($){d(`语音识别错误:${$ instanceof Error?$.message:String($)}`);for(const Q of Y)await Q.remove().catch(()=>{});N.current=[]}},[e]),ae=y.useCallback(()=>{if(!dy)return!1;B.current=!1,a(""),o(""),A.current="",d(null),b("idle"),E.current=!1;const H=new dy;H.lang=e,H.continuous=!0,H.interimResults=!0,H.maxAlternatives=1,H.onstart=()=>{n(!0),b("recording"),T.current=!1,S.current=setTimeout(()=>{!T.current&&!E.current&&(C.current=!0,E.current=!0,H.stop(),d("语音识别服务不可用(Chrome/Edge 需连接 Google 服务器),下次将使用服务端识别"))},5e3)},H.onresult=F=>{T.current=!0,S.current&&(clearTimeout(S.current),S.current=null);let Y="",L="";for(let $=F.resultIndex;$<F.results.length;$++){const Q=F.results[$][0].transcript;F.results[$].isFinal?Y+=Q:L+=Q}Y&&a($=>$+Y),o(L),A.current=L},H.onerror=F=>{switch(F.error!=="no-speech"&&F.error!=="aborted"&&(E.current=!0),F.error){case"not-allowed":d("请允许麦克风权限");break;case"network":d("网络错误,请检查连接");break;case"no-speech":case"aborted":return;default:d(`语音识别错误:${F.error}`)}},H.onend=()=>{if(E.current&&A.current&&a(F=>F+A.current),o(""),A.current="",!E.current)try{H.start();return}catch{}n(!1),x.current=null},x.current=H;try{return H.start(),!0}catch{return!1}},[e]),Z=y.useCallback(async()=>{B.current=!1,a(""),o(""),d(null),b("idle");try{const $=await fetch("/api/transcribe/status"),{available:Q}=await $.json();if(!Q){d("语音识别服务未就绪,请稍后重试");return}}catch{d("无法连接语音识别服务");return}let H;try{H=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:fy,channelCount:1}})}catch{d("请允许麦克风权限");return}const F=new AudioContext({sampleRate:fy}),Y=F.createMediaStreamSource(H),L=F.createScriptProcessor(4096,1,1);D.current=[],L.onaudioprocess=$=>{D.current.push(new Float32Array($.inputBuffer.getChannelData(0)))},Y.connect(L),L.connect(F.destination),O.current=F,R.current=H,k.current=L,n(!0),b("recording")},[]),W=y.useCallback(()=>{_v?G():dy&&!C.current&&ae()||Z()},[G,ae,Z]);y.useEffect(()=>{if(!t){m(0);return}if(x.current)return;let H=!1,F=null,Y=null,L=0;return(async()=>{try{if(F=await navigator.mediaDevices.getUserMedia({audio:!0}),H){F.getTracks().forEach(V=>V.stop());return}Y=new AudioContext;const $=Y.createMediaStreamSource(F),Q=Y.createAnalyser();Q.fftSize=256,$.connect(Q);const P=new Uint8Array(Q.frequencyBinCount);let he=0;const se=()=>{if(H)return;Q.getByteFrequencyData(P);const V=performance.now();if(V-he>80){let be=0;for(let ye=0;ye<P.length;ye++)be+=P[ye];m(be/(P.length*255)),he=V}L=requestAnimationFrame(se)};L=requestAnimationFrame(se)}catch{}})(),()=>{H=!0,cancelAnimationFrame(L),F==null||F.getTracks().forEach($=>$.stop()),Y==null||Y.close().catch(()=>{}),m(0)}},[t]),y.useEffect(()=>{!t&&p==="recording"&&b(r?"done":"idle")},[t,p,r]),y.useEffect(()=>()=>{var H,F,Y,L;E.current=!0,(H=x.current)==null||H.stop(),(F=k.current)==null||F.disconnect(),(Y=R.current)==null||Y.getTracks().forEach($=>$.stop()),(L=O.current)==null||L.close().catch(()=>{});for(const $ of N.current)$.remove().catch(()=>{})},[]);const K=y.useCallback(()=>{B.current=!0,a(""),o(""),A.current="",b("idle")},[]);return{isSupported:j,isListening:t,phase:p,transcript:r,interimTranscript:s,error:c,volumeLevel:f,start:W,stop:z,resetTranscript:K}}const pX=240,gX=1e3;function gM(e){const t=mX(),[n,r]=y.useState(""),[a,s]=y.useState(0),o=y.useRef(null),c=y.useRef(null),d=y.useRef(0);y.useEffect(()=>(t.phase==="recording"?(d.current=Date.now(),s(0),c.current=setInterval(()=>{s(Math.floor((Date.now()-d.current)/1e3))},gX)):c.current&&(clearInterval(c.current),c.current=null),()=>{c.current&&(clearInterval(c.current),c.current=null)}),[t.phase]),y.useEffect(()=>{t.phase==="done"&&(r(t.transcript),requestAnimationFrame(()=>{const b=o.current;b&&(b.focus(),b.setSelectionRange(b.value.length,b.value.length))}))},[t.phase,t.transcript]),y.useLayoutEffect(()=>{if(t.phase!=="done")return;const b=o.current;b&&(b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,pX)}px`)},[t.phase,n]);const f=y.useCallback(()=>{t.stop(),t.resetTranscript(),r("")},[t]),m=y.useCallback(async()=>{const b=n.trim();if(!b){f();return}await e(b)!==!1&&(t.resetTranscript(),r(""))},[n,e,f,t]);y.useEffect(()=>{if(t.phase==="idle")return;const b=x=>{if(x.key==="Escape"&&t.phase!=="recognizing"){x.preventDefault(),f();return}if(t.phase==="done"&&x.key==="Enter"&&(x.metaKey||x.ctrlKey)){if(x.isComposing)return;x.preventDefault(),m()}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t.phase,f,m]);const p=y.useCallback(b=>{b.nativeEvent.isComposing||b.keyCode===229||b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),m())},[m]);return{stt:t,editText:n,setEditText:r,elapsed:a,textareaRef:o,cancel:f,confirm:m,handleTextareaKeyDown:p}}function bX(e){if(typeof e!="string")return e;const t=e.trim();if(t)try{return JSON.parse(t)}catch{return t}}function Qn(e){return e&&typeof e=="object"?e:null}function Ml(e){const t=Qn(e);return t&&"properties"in t?t.properties:e}function xX(e){const t=Qn(e);return typeof(t==null?void 0:t.type)=="string"?t.type:void 0}function yX(e){const t=Qn(Ml(e));if(!t)return null;const n=Qn(t.info);if(n&&typeof n.id=="string"){const a=Array.isArray(t.parts)?t.parts:void 0;return{...n,...a?{parts:a}:{}}}if(typeof t.id=="string"&&typeof t.role=="string")return t;const r=Qn(t.message);return r&&typeof r.id=="string"?r:null}function vX(e){const t=Qn(Ml(e));if(!t)return{};const n=Qn(t.part)??t;return typeof n.type!="string"?{}:{messageId:typeof n.messageID=="string"&&n.messageID||typeof n.messageId=="string"&&n.messageId||typeof t.messageID=="string"&&t.messageID||typeof t.messageId=="string"&&t.messageId||void 0,part:n}}function bM(e){const t=Qn(Ml(e));if(!t||t.field!=="text")return null;const n=typeof t.messageID=="string"?t.messageID:null,r=typeof t.partID=="string"?t.partID:null,a=typeof t.delta=="string"?t.delta:null;return!n||!r||a===null?null:{messageId:n,partId:r,delta:a}}function EX(e){const t=Ml(e);if(Array.isArray(t))return t;const n=Qn(t);return n&&Array.isArray(n.todos)?n.todos:[]}function mi(e){return typeof e=="number"?e:0}function NX(e){const t=Qn(Ml(e));if(!t||typeof t.id!="string")return null;const n={id:t.id};typeof t.title=="string"&&(n.title=t.title),typeof t.agent=="string"&&(n.agent=t.agent),typeof t.cost=="number"&&(n.cost=t.cost);const r=typeof t.parentID=="string"?t.parentID:typeof t.parent_id=="string"?t.parent_id:void 0;r&&(n.parentID=r);const a=Qn(t.tokens),s=typeof t.tokens_input=="number"||typeof t.tokens_output=="number";if(a||s){const c=a?Qn(a.cache):null;n.tokens={input:mi(a==null?void 0:a.input)||mi(t.tokens_input),output:mi(a==null?void 0:a.output)||mi(t.tokens_output),reasoning:mi(a==null?void 0:a.reasoning)||mi(t.tokens_reasoning),cache:{read:mi(c==null?void 0:c.read)||mi(t.tokens_cache_read),write:mi(c==null?void 0:c.write)||mi(t.tokens_cache_write)}}}const o=Qn(t.model);return o&&(n.model={providerID:typeof o.providerID=="string"?o.providerID:void 0,modelID:typeof o.modelID=="string"?o.modelID:void 0,variant:typeof o.variant=="string"?o.variant:void 0}),n}function _X(e){const t=Qn(Ml(e));if(!t)return null;if(typeof t.message=="string")return t.message;const n=Qn(t.error);if(n){const r=Qn(n.data);if(typeof(r==null?void 0:r.message)=="string")return`${n.name??"Error"}: ${r.message}`;if(typeof n.message=="string")return`${n.name??"Error"}: ${n.message}`;if(typeof n.name=="string")return String(n.name)}return typeof t.reason=="string"?t.reason:null}function SX(e){const t=Ml(e);if(typeof t=="string")return t;const n=Qn(t);if(typeof(n==null?void 0:n.status)=="string")return n.status;const r=Qn(n==null?void 0:n.status);return typeof(r==null?void 0:r.type)=="string"?r.type:typeof(n==null?void 0:n.type)=="string"?n.type:null}function jA(e,t,n,r){switch(e==="message"||e===""?xX(t)??e:e){case"message.updated":{const s=yX(t);s&&r.updateMessage(n,s);break}case"session.updated":{const s=NX(t);s&&r.updateSessionInfo(s);break}case"message.part.updated":{const{messageId:s,part:o}=vX(t);o&&s&&r.updateMessagePart(n,s,o);break}case"message.part.delta":{const s=bM(t);s&&r.appendMessagePartDelta(n,s.messageId,s.partId,s.delta);break}case"todo.updated":{r.updateTodos(n,EX(t));break}case"session.status":{const s=SX(t);s&&r.setSessionStatus(n,s);break}case"session.idle":{r.setSessionStatus(n,"idle");break}case"session.error":{const s=_X(t);r.setSessionStatus(n,"error",s??void 0);break}}}const TX=1e3,wX=5e3,Cm="freeze-mon-buffer",AX=4*1024*1024;class CX{constructor(){kt(this,"ring",[]);kt(this,"counters",{sse:0,delta:0,store:0});kt(this,"workerCount",0);kt(this,"sampleTimer",0);kt(this,"persistTimer",0);kt(this,"running",!1)}tick(t){this.counters[t]++}setGauge(t,n){t==="workers"&&(this.workerCount=n)}exportData(){return localStorage.getItem(Cm)??JSON.stringify(this.ring)}start(){if(this.running)return;this.running=!0;const t=localStorage.getItem(Cm);if(t)try{this.ring=JSON.parse(t)}catch{this.ring=[]}this.sampleTimer=window.setInterval(()=>this.sample(),TX),this.persistTimer=window.setInterval(()=>this.persist(),wX)}stop(){this.running=!1,clearInterval(this.sampleTimer),clearInterval(this.persistTimer),this.persist()}sample(){const t=De.getState(),n=Object.values(t.messages).reduce((a,s)=>a+s.length,0),r=performance.memory;this.ring.push({ts:Date.now(),sse:this.counters.sse,delta:this.counters.delta,store:this.counters.store,workers:this.workerCount,msgs:n,heap:r?Math.round(r.usedJSHeapSize/1048576):void 0}),this.counters.sse=0,this.counters.delta=0,this.counters.store=0,this.trimToFit()}trimToFit(){for(;this.ring.length>1&&!(new Blob([JSON.stringify(this.ring)]).size<=AX);)this.ring.shift()}persist(){try{localStorage.setItem(Cm,JSON.stringify(this.ring))}catch{this.ring.splice(0,Math.floor(this.ring.length/2));try{localStorage.setItem(Cm,JSON.stringify(this.ring))}catch{}}}}const ls=new CX,kX=600*1e3,OX=200;class IX{constructor(t,n){kt(this,"sessionId");kt(this,"idleTimer",null);kt(this,"flushTimer",null);kt(this,"active",!1);kt(this,"alive",!0);kt(this,"callbacks");kt(this,"eventQueue",[]);kt(this,"deltaBuffer",new Map);this.sessionId=t,this.callbacks=n,this.resetIdleTimer()}dispatch(t,n){if(this.alive){if(this.resetIdleTimer(),ls.tick("sse"),t==="message.part.delta"){this.bufferDelta(n),this.scheduleFlush();return}if(t==="session.idle"||t==="session.status"||t==="session.error"){this.flush();const r=De.getState(),a=r.sessionStatuses[this.sessionId];jA(t,n,this.sessionId,r);const s=De.getState().sessionStatuses[this.sessionId];a&&a!=="idle"&&s==="idle"&&this.callbacks.onSessionIdle(this.sessionId);return}this.eventQueue.push({name:t,data:n}),this.scheduleFlush()}}activate(){this.active=!0,this.clearIdleTimer()}deactivate(){this.active=!1,this.resetIdleTimer()}refreshOnIdle(){De.getState().refreshSessionData(this.sessionId)}stop(){this.alive=!1,this.flush(),this.clearIdleTimer(),this.cancelFlush()}scheduleFlush(){this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},OX))}cancelFlush(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null)}bufferDelta(t){const n=bM(t);if(!n)return;const r=this.deltaBuffer.get(n.partId);r?r.text+=n.delta:this.deltaBuffer.set(n.partId,{messageId:n.messageId,text:n.delta})}flush(){if(this.eventQueue.length===0&&this.deltaBuffer.size===0)return;const t=De.getState(),n=this.eventQueue;this.eventQueue=[];for(const r of n)jA(r.name,r.data,this.sessionId,t);if(this.deltaBuffer.size>0){const r=this.deltaBuffer;this.deltaBuffer=new Map;for(const[a,{messageId:s,text:o}]of r)ls.tick("delta"),ls.tick("store"),t.appendMessagePartDelta(this.sessionId,s,a,o)}}resetIdleTimer(){this.clearIdleTimer(),!this.active&&(this.idleTimer=setTimeout(()=>{this.callbacks.onWorkerIdle(this.sessionId)},kX))}clearIdleTimer(){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null)}}const RX=1e3,MX=3e4;class jX{constructor(t,n){kt(this,"source",null);kt(this,"reconnectTimer",null);kt(this,"attempts",0);kt(this,"disposed",!1);kt(this,"repoId");kt(this,"onEvent");this.repoId=t,this.onEvent=n}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=vH(this.repoId),n=new EventSource(t);this.source=n,n.onopen=()=>{this.attempts=0},n.onmessage=a=>{this.handleRaw("message",a)};const r=["message.updated","message.part.updated","message.part.delta","message.removed","todo.updated","session.status","session.idle","session.error","session.updated"];for(const a of r)n.addEventListener(a,s=>{this.handleRaw(a,s)});n.onerror=()=>{if(!(this.disposed||!this.source)&&this.source.readyState===EventSource.CLOSED){this.source.close(),this.source=null;const a=Math.min(RX*2**this.attempts,MX);this.attempts++,this.reconnectTimer=setTimeout(()=>this.connect(),a)}}}handleRaw(t,n){if(!(n instanceof MessageEvent))return;ls.tick("sse");const r=bX(n.data);if(r===void 0)return;const a=this.extractSessionId(r);if(!a)return;let s=t;if(t==="message"||t===""){const o=r&&typeof r=="object"?r:null;typeof(o==null?void 0:o.type)=="string"&&(s=o.type)}this.onEvent(a,s,r)}extractSessionId(t){if(!t||typeof t!="object")return null;const n=t;if(n.properties&&typeof n.properties=="object"){const r=n.properties;if(typeof r.sessionID=="string")return r.sessionID;if(typeof r.id=="string")return r.id}return typeof n.sessionID=="string"?n.sessionID:typeof n.sessionId=="string"?n.sessionId:null}}const DX=6e4;class LX{constructor(t){kt(this,"timer",null);kt(this,"paused",!1);kt(this,"callbacks");this.callbacks=t}start(){this.tick(),this.timer=setInterval(()=>{this.paused||this.tick()},DX)}stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}pause(){this.paused=!0}resume(){this.paused=!1,this.tick()}tick(){const t=Fe.getState().activeRepoId;t&&(De.getState().loadSessions(),EH(t).then(n=>{const r={};for(const[a,s]of Object.entries(n))r[a]=s.type??"idle";De.getState().bulkSetStatuses(r);for(const[a,s]of Object.entries(r))(s==="busy"||s==="retry")&&this.callbacks.ensureWorker(a)}).catch(()=>{}))}}class PX{constructor(){kt(this,"workers",new Map);kt(this,"dispatcher",null);kt(this,"supervisor",null);kt(this,"visibilityHandler",null)}start(t){this.stop();const n={onWorkerIdle:r=>this.removeWorker(r),onSessionIdle:r=>{var a;(a=this.workers.get(r))==null||a.refreshOnIdle()}};this.dispatcher=new jX(t,(r,a,s)=>{this.ensureWorker(r,n).dispatch(a,s)}),this.dispatcher.start(),this.supervisor=new LX({ensureWorker:r=>this.ensureWorker(r,n)}),this.supervisor.start(),this.visibilityHandler=()=>{var r,a;document.hidden?(r=this.supervisor)==null||r.pause():(a=this.supervisor)==null||a.resume()},document.addEventListener("visibilitychange",this.visibilityHandler)}stop(){var t,n;(t=this.dispatcher)==null||t.stop(),this.dispatcher=null,(n=this.supervisor)==null||n.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 a of this.workers.values())a.sessionId!==t&&a.deactivate();if(!t)return;const n={onWorkerIdle:a=>this.removeWorker(a),onSessionIdle:a=>{var s;return(s=this.workers.get(a))==null?void 0:s.refreshOnIdle()}};this.ensureWorker(t,n).activate(),De.getState().refreshSessionData(t)}deactivateSession(t){var n;(n=this.workers.get(t))==null||n.deactivate()}ensureWorker(t,n){let r=this.workers.get(t);return r||(r=new IX(t,n),this.workers.set(t,r),ls.setGauge("workers",this.workers.size)),r}removeWorker(t){const n=De.getState().activeSessionId;if(t===n)return;const r=this.workers.get(t);r&&(r.stop(),this.workers.delete(t),ls.setGauge("workers",this.workers.size))}}const Np=new PX,DA=(function(e,t,n){const r=Uf(n);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]}),jl=(function(e){if(e==null)return FX;if(typeof e=="string")return UX(e);if(typeof e=="object")return BX(e);if(typeof e=="function")return fE(e);throw new Error("Expected function, string, or array as `test`")});function BX(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=jl(e[n]);return fE(r);function r(...a){let s=-1;for(;++s<t.length;)if(t[s].apply(this,a))return!0;return!1}}function UX(e){return fE(t);function t(n){return n.tagName===e}}function fE(e){return t;function t(n,r,a){return!!(zX(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function FX(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function zX(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const LA=/\n/g,PA=/[\t ]+/g,Sv=jl("br"),BA=jl(WX),HX=jl("p"),UA=jl("tr"),$X=jl(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",VX,XX]),xM=jl(["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 YX(e,t){const n=t||{},r="children"in e?e.children:[],a=xM(e),s=EM(e,{whitespace:n.whitespace||"normal"}),o=[];(e.type==="text"||e.type==="comment")&&o.push(...vM(e,{breakBefore:!0,breakAfter:!0}));let c=-1;for(;++c<r.length;)o.push(...yM(r[c],e,{whitespace:s,breakBefore:c?void 0:a,breakAfter:c<r.length-1?Sv(r[c+1]):a}));const d=[];let f;for(c=-1;++c<o.length;){const m=o[c];typeof m=="number"?f!==void 0&&m>f&&(f=m):m&&(f!==void 0&&f>-1&&d.push(`
551
+ `),a=String(r.length).length;return u.jsx("div",{role:"dialog","aria-modal":"true","aria-label":t,onClick:n,className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm md:p-8",children:u.jsxs("div",{onClick:s=>s.stopPropagation(),className:"flex max-h-full w-full max-w-4xl flex-col overflow-hidden rounded-lg border border-line bg-term",children:[u.jsxs("div",{className:"flex items-center justify-between border-b border-line px-4 py-2",children:[u.jsx("span",{className:"font-mono text-xs text-fg-3",children:t}),u.jsx("button",{type:"button",onClick:n,className:"text-fg-5 hover:text-fg-2",children:u.jsx(ct,{className:"h-4 w-4"})})]}),u.jsx("pre",{className:"overflow-auto p-4 font-mono text-xs leading-relaxed text-fg-2",children:r.map((s,o)=>u.jsxs("div",{children:[u.jsx("span",{className:"mr-3 inline-block select-none text-right text-fg-6",style:{width:`${a}ch`},children:o+1}),s]},o))})]})})}function XW({fold:e,index:t,onRemove:n}){const[r,a]=y.useState(!1),s=`粘贴文本 #${t} · ${e.lineCount}行 · ${GW(e.byteSize)}`;return u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"group relative flex items-center gap-1.5 rounded-md border border-line bg-elevated/50 px-2.5 py-1.5",children:[u.jsxs("button",{type:"button",onClick:()=>a(!0),className:"flex items-center gap-1.5 font-mono text-xs text-fg-3 transition-colors hover:text-fg",children:[u.jsx(po,{className:"h-3.5 w-3.5 shrink-0 text-fg-5"}),u.jsx("span",{children:s})]}),u.jsx("button",{type:"button",onClick:n,"aria-label":"移除粘贴文本",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-fg-5 transition-colors hover:text-fg-2",children:u.jsx(ct,{className:"h-2.5 w-2.5",strokeWidth:2.5})})]}),r&&u.jsx(WW,{text:e.text,label:s,onClose:()=>a(!1)})]})}function dM({onFiles:e,disabled:t,allowed:n}){const r=y.useRef(null);return u.jsxs(u.Fragment,{children:[u.jsx("input",{ref:r,type:"file",accept:lM.join(","),multiple:!0,hidden:!0,onChange:a=>{e(Array.from(a.target.files??[])),a.target.value=""}}),u.jsx("button",{type:"button",onClick:()=>{var a;return(a=r.current)==null?void 0:a.click()},disabled:t||!n,"aria-label":"Attach image",title:n?"附加图片":"当前模型不支持图片",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:u.jsx(sF,{className:"h-4 w-4"})})]})}function fM({attachments:e,foldedTexts:t,error:n,onRemove:r,onRemoveFoldedText:a,className:s}){const o=e.length>0||(t??[]).length>0;return!o&&!n?null:u.jsxs("div",{className:s,children:[o&&u.jsxs("div",{className:"mb-2 flex flex-wrap gap-2",children:[e.map(c=>u.jsxs("div",{className:"group relative",children:[u.jsx(cE,{url:c.url,label:c.filename??"attachment",className:"h-16 w-16 object-cover"}),u.jsx("button",{type:"button",onClick:()=>r(c._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:u.jsx(ct,{className:"h-2.5 w-2.5",strokeWidth:2.5})})]},c._id)),(t??[]).map((c,d)=>u.jsx(XW,{fold:c,index:d+1,onRemove:()=>a==null?void 0:a(c._id)},c._id))]}),n&&u.jsx("div",{className:"mb-2 font-mono text-[11px] text-red-400",children:n})]})}function hM({isListening:e,disabled:t,onStart:n,onStop:r}){const a=y.useRef(!1),s=c=>{if(t)return;c.preventDefault(),a.current=!0,n();const d=()=>{document.removeEventListener("touchend",d),document.removeEventListener("touchcancel",d),a.current=!1,r()};document.addEventListener("touchend",d,{once:!0}),document.addEventListener("touchcancel",d,{once:!0})},o=()=>{if(t||a.current)return;n();const c=()=>{document.removeEventListener("mouseup",c),r()};document.addEventListener("mouseup",c,{once:!0})};return u.jsx("button",{type:"button",disabled:t,onTouchStart:s,onMouseDown:o,onContextMenu:c=>c.preventDefault(),"aria-label":"按住说话",title:"按住说话",style:{WebkitTouchCallout:"none"},className:re("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:u.jsx(NF,{className:re("h-6 w-6 sm:h-4 sm:w-4",e&&"animate-pulse")})})}const QW=[.85,1.25,.65,1.4,.75,1.15,.95],uy=4,CA=24;function ZW(e){const t=Math.floor(e/60).toString().padStart(2,"0"),n=Math.floor(e%60).toString().padStart(2,"0");return`${t}:${n}`}function JW({volumeLevel:e}){const t=Math.min(Math.max(e,0),1);return u.jsx("div",{className:"flex h-6 items-center gap-1","aria-hidden":"true",children:QW.map((n,r)=>{const a=uy+t*n*(CA-uy),s=Math.max(uy,Math.min(CA,a));return u.jsx("span",{className:"w-1 rounded-full bg-red-400 transition-[height] duration-150 ease-out",style:{height:`${s}px`}},r)})})}function mM({phase:e,transcript:t,interimTranscript:n,editText:r,onEditTextChange:a,onTextareaKeyDown:s,textareaRef:o,wrapperClassName:c}){if(e==="idle")return null;const d=t.length>0||n.length>0;return u.jsx("div",{className:c,children:u.jsxs("div",{className:"max-h-[40vh] overflow-y-auto px-4 py-4",children:[e==="recording"&&u.jsx("div",{className:"text-xl leading-relaxed",children:d?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"text-fg",children:t}),n&&u.jsx("span",{className:"text-fg-4",children:n})]}):u.jsx("span",{className:"italic text-fg-5",children:"正在聆听…"})}),e==="recognizing"&&u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx(an,{className:"h-5 w-5 shrink-0 text-emerald-400 fs-spin"}),u.jsx("span",{className:"font-mono text-sm text-emerald-400",children:"识别中…"}),n&&u.jsx("span",{className:"truncate text-base text-fg-4",children:n})]}),e==="done"&&u.jsx("textarea",{ref:o,value:r,onChange:f=>a(f.target.value),onKeyDown:s,rows:2,placeholder:"识别结果(可编辑)",className:"w-full resize-none bg-transparent text-xl leading-relaxed text-fg placeholder:text-fg-5 focus:outline-none"})]})})}function pM({phase:e,volumeLevel:t,elapsed:n,editText:r,error:a,onCancel:s,onConfirm:o,idleHint:c,className:d}){return e==="idle"?u.jsx("div",{className:d,children:a?u.jsx("span",{className:"font-mono text-[10px] text-red-400",children:a}):c?u.jsx("span",{className:"font-mono text-[10px] text-fg-6",children:c}):null}):e==="done"?u.jsxs("div",{className:d,children:[u.jsx("span",{className:"hidden font-mono text-[10px] text-fg-6 sm:inline",children:"⌘/Ctrl+⏎ 发送 · Esc 取消"}),u.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[u.jsx("button",{type:"button",onClick:s,className:"rounded-md border border-line px-3 py-1 text-xs text-fg-3 transition-colors hover:bg-elevated hover:text-fg",children:"取消"}),u.jsxs("button",{type:"button",onClick:o,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:[u.jsx(cf,{className:"h-3.5 w-3.5",strokeWidth:2.5}),u.jsx("span",{children:"发送"})]})]})]}):u.jsx("div",{className:d,children:e==="recording"?u.jsxs(u.Fragment,{children:[u.jsx(JW,{volumeLevel:t}),u.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-[11px] font-medium text-red-400",children:[u.jsx("span",{className:"h-1.5 w-1.5 shrink-0 animate-pulse rounded-full bg-red-400"}),"录音中"]}),u.jsx("span",{className:"font-mono text-[11px] tabular-nums text-fg-4",children:ZW(n)})]}):u.jsxs(u.Fragment,{children:[u.jsx(an,{className:"h-4 w-4 shrink-0 text-emerald-400 fs-spin"}),u.jsx("span",{className:"font-mono text-[11px] text-emerald-400",children:"识别中…"})]})})}/*! Capacitor: https://capacitorjs.com/ - MIT License */var Xu;(function(e){e.Unimplemented="UNIMPLEMENTED",e.Unavailable="UNAVAILABLE"})(Xu||(Xu={}));class cy extends Error{constructor(t,n,r){super(t),this.message=t,this.code=n,this.data=r}}const eX=e=>{var t,n;return e!=null&&e.androidBridge?"android":!((n=(t=e==null?void 0:e.webkit)===null||t===void 0?void 0:t.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},tX=e=>{const t=e.CapacitorCustomPlatform||null,n=e.Capacitor||{},r=n.Plugins=n.Plugins||{},a=()=>t!==null?t.name:eX(e),s=()=>a()!=="web",o=p=>{const b=f.get(p);return!!(b!=null&&b.platforms.has(a())||c(p))},c=p=>{var b;return(b=n.PluginHeaders)===null||b===void 0?void 0:b.find(x=>x.name===p)},d=p=>e.console.error(p),f=new Map,m=(p,b={})=>{const x=f.get(p);if(x)return console.warn(`Capacitor plugin "${p}" already registered. Cannot register plugins twice.`),x.proxy;const E=a(),N=c(p);let T;const S=async()=>(!T&&E in b?T=typeof b[E]=="function"?T=await b[E]():T=b[E]:t!==null&&!T&&"web"in b&&(T=typeof b.web=="function"?T=await b.web():T=b.web),T),C=(B,j)=>{var M,z;if(N){const G=N==null?void 0:N.methods.find(ae=>j===ae.name);if(G)return G.rtype==="promise"?ae=>n.nativePromise(p,j.toString(),ae):(ae,Z)=>n.nativeCallback(p,j.toString(),ae,Z);if(B)return(M=B[j])===null||M===void 0?void 0:M.bind(B)}else{if(B)return(z=B[j])===null||z===void 0?void 0:z.bind(B);throw new cy(`"${p}" plugin is not implemented on ${E}`,Xu.Unimplemented)}},A=B=>{let j;const M=(...z)=>{const G=S().then(ae=>{const Z=C(ae,B);if(Z){const W=Z(...z);return j=W==null?void 0:W.remove,W}else throw new cy(`"${p}.${B}()" is not implemented on ${E}`,Xu.Unimplemented)});return B==="addListener"&&(G.remove=async()=>j()),G};return M.toString=()=>`${B.toString()}() { [capacitor code] }`,Object.defineProperty(M,"name",{value:B,writable:!1,configurable:!1}),M},O=A("addListener"),R=A("removeListener"),k=(B,j)=>{const M=O({eventName:B},j),z=async()=>{const ae=await M;R({eventName:B,callbackId:ae},j)},G=new Promise(ae=>M.then(()=>ae({remove:z})));return G.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await z()},G},D=new Proxy({},{get(B,j){switch(j){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return N?k:O;case"removeListener":return R;default:return A(j)}}});return r[p]=D,f.set(p,{name:p,proxy:D,platforms:new Set([...Object.keys(b),...N?[E]:[]])}),D};return n.convertFileSrc||(n.convertFileSrc=p=>p),n.getPlatform=a,n.handleError=d,n.isNativePlatform=s,n.isPluginAvailable=o,n.registerPlugin=m,n.Exception=cy,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},nX=e=>e.Capacitor=tX(e),Ep=nX(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),Rg=Ep.registerPlugin;class dE{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(t,n){let r=!1;this.listeners[t]||(this.listeners[t]=[],r=!0),this.listeners[t].push(n);const s=this.windowListeners[t];s&&!s.registered&&this.addWindowListener(s),r&&this.sendRetainedArgumentsForEvent(t);const o=async()=>this.removeListener(t,n);return Promise.resolve({remove:o})}async removeAllListeners(){this.listeners={};for(const t in this.windowListeners)this.removeWindowListener(this.windowListeners[t]);this.windowListeners={}}notifyListeners(t,n,r){const a=this.listeners[t];if(!a){if(r){let s=this.retainedEventArguments[t];s||(s=[]),s.push(n),this.retainedEventArguments[t]=s}return}a.forEach(s=>s(n))}hasListeners(t){var n;return!!(!((n=this.listeners[t])===null||n===void 0)&&n.length)}registerWindowListener(t,n){this.windowListeners[n]={registered:!1,windowEventName:t,pluginEventName:n,handler:r=>{this.notifyListeners(n,r)}}}unimplemented(t="not implemented"){return new Ep.Exception(t,Xu.Unimplemented)}unavailable(t="not available"){return new Ep.Exception(t,Xu.Unavailable)}async removeListener(t,n){const r=this.listeners[t];if(!r)return;const a=r.indexOf(n);a!==-1&&this.listeners[t].splice(a,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 n=this.retainedEventArguments[t];n&&(delete this.retainedEventArguments[t],n.forEach(r=>{this.notifyListeners(t,r)}))}}const kA=e=>encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),OA=e=>e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class rX extends dE{async getCookies(){const t=document.cookie,n={};return t.split(";").forEach(r=>{if(r.length<=0)return;let[a,s]=r.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");a=OA(a).trim(),s=OA(s).trim(),n[a]=s}),n}async setCookie(t){try{const n=kA(t.key),r=kA(t.value),a=t.expires?`; expires=${t.expires.replace("expires=","")}`:"",s=(t.path||"/").replace("path=",""),o=t.url!=null&&t.url.length>0?`domain=${t.url}`:"";document.cookie=`${n}=${r||""}${a}; path=${s}; ${o};`}catch(n){return Promise.reject(n)}}async deleteCookie(t){try{document.cookie=`${t.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{const t=document.cookie.split(";")||[];for(const n of t)document.cookie=n.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)}}}Rg("CapacitorCookies",{web:()=>new rX});const aX=async e=>new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const a=r.result;t(a.indexOf(",")>=0?a.split(",")[1]:a)},r.onerror=a=>n(a),r.readAsDataURL(e)}),iX=(e={})=>{const t=Object.keys(e);return Object.keys(e).map(a=>a.toLocaleLowerCase()).reduce((a,s,o)=>(a[s]=e[t[o]],a),{})},sX=(e,t=!0)=>e?Object.entries(e).reduce((r,a)=>{const[s,o]=a;let c,d;return Array.isArray(o)?(d="",o.forEach(f=>{c=t?encodeURIComponent(f):f,d+=`${s}=${c}&`}),d.slice(0,-1)):(c=t?encodeURIComponent(o):o,d=`${s}=${c}`),`${r}&${d}`},"").substr(1):null,oX=(e,t={})=>{const n=Object.assign({method:e.method||"GET",headers:e.headers},t),a=iX(e.headers)["content-type"]||"";if(typeof e.data=="string")n.body=e.data;else if(a.includes("application/x-www-form-urlencoded")){const s=new URLSearchParams;for(const[o,c]of Object.entries(e.data||{}))s.set(o,c);n.body=s.toString()}else if(a.includes("multipart/form-data")||e.data instanceof FormData){const s=new FormData;if(e.data instanceof FormData)e.data.forEach((c,d)=>{s.append(d,c)});else for(const c of Object.keys(e.data))s.append(c,e.data[c]);n.body=s;const o=new Headers(n.headers);o.delete("content-type"),n.headers=o}else(a.includes("application/json")||typeof e.data=="object")&&(n.body=JSON.stringify(e.data));return n};class lX extends dE{async request(t){const n=oX(t,t.webFetchExtra),r=sX(t.params,t.shouldEncodeUrlParams),a=r?`${t.url}?${r}`:t.url,s=await fetch(a,n),o=s.headers.get("content-type")||"";let{responseType:c="text"}=s.ok?t:{};o.includes("application/json")&&(c="json");let d,f;switch(c){case"arraybuffer":case"blob":f=await s.blob(),d=await aX(f);break;case"json":d=await s.json();break;case"document":case"text":default:d=await s.text()}const m={};return s.headers.forEach((p,b)=>{m[b]=p}),{data:d,headers:m,status:s.status,url:s.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"}))}}Rg("CapacitorHttp",{web:()=>new lX});var IA;(function(e){e.Dark="DARK",e.Light="LIGHT",e.Default="DEFAULT"})(IA||(IA={}));var RA;(function(e){e.StatusBar="StatusBar",e.NavigationBar="NavigationBar"})(RA||(RA={}));class uX extends dE{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")}}Rg("SystemBars",{web:()=>new uX});const cX="modulepreload",dX=function(e){return"/"+e},MA={},fX=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let o=function(f){return Promise.all(f.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=o(n.map(f=>{if(f=dX(f),f in MA)return;MA[f]=!0;const m=f.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const b=document.createElement("link");if(b.rel=m?"stylesheet":cX,m||(b.as="script"),b.crossOrigin="",b.href=f,d&&b.setAttribute("nonce",d),document.head.appendChild(b),m)return new Promise((x,E)=>{b.addEventListener("load",x),b.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${f}`)))})}))}function s(o){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=o,window.dispatchEvent(c),!c.defaultPrevented)throw o}return a.then(o=>{for(const c of o||[])c.status==="rejected"&&s(c.reason);return t().catch(s)})},wu=Rg("SpeechRecognition",{web:()=>fX(()=>import("./web-CUwAURSN.js"),[]).then(e=>new e.SpeechRecognitionWeb)});function hX(e,t){const n=e.length,r=new ArrayBuffer(44+n*2),a=new DataView(r),s=(o,c)=>{for(let d=0;d<c.length;d++)a.setUint8(o+d,c.charCodeAt(d))};s(0,"RIFF"),a.setUint32(4,36+n*2,!0),s(8,"WAVE"),s(12,"fmt "),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,1,!0),a.setUint32(24,t,!0),a.setUint32(28,t*2,!0),a.setUint16(32,2,!0),a.setUint16(34,16,!0),s(36,"data"),a.setUint32(40,n*2,!0);for(let o=0;o<n;o++){const c=Math.max(-1,Math.min(1,e[o]));a.setInt16(44+o*2,c<0?c*32768:c*32767,!0)}return new Blob([r],{type:"audio/wav"})}const _v=Ep.isNativePlatform(),dy=!_v&&typeof window<"u"?window.SpeechRecognition??window.webkitSpeechRecognition:void 0,fy=16e3;function mX(e="zh-CN"){const[t,n]=y.useState(!1),[r,a]=y.useState(""),[s,o]=y.useState(""),[c,d]=y.useState(null),[f,m]=y.useState(0),[p,b]=y.useState("idle"),x=y.useRef(null),E=y.useRef(!1),N=y.useRef([]),T=y.useRef(!1),S=y.useRef(null),C=y.useRef(!1),A=y.useRef(""),O=y.useRef(null),R=y.useRef(null),k=y.useRef(null),D=y.useRef([]),B=y.useRef(!1),j=!0,M=y.useCallback(async()=>{var P,he,se;(P=k.current)==null||P.disconnect(),(he=R.current)==null||he.getTracks().forEach(V=>V.stop()),await((se=O.current)==null?void 0:se.close().catch(()=>{}));const H=D.current;if(D.current=[],k.current=null,R.current=null,O.current=null,H.length===0||B.current){n(!1),b("idle");return}o("识别中…"),b("recognizing");const F=H.reduce((V,be)=>V+be.length,0),Y=new Float32Array(F);let L=0;for(const V of H)Y.set(V,L),L+=V.length;const $=hX(Y,fy),Q=new FormData;Q.append("audio",$,"recording.wav");try{const V=await fetch("/api/transcribe",{method:"POST",body:Q});if(B.current)return;if(V.ok){const{text:be}=await V.json();be?(a(be),b("done")):b("idle")}else{const be=await V.json().catch(()=>({error:`HTTP ${V.status}`}));d(be.error??`HTTP ${V.status}`),b("idle")}}catch(V){d(`语音识别失败:${V instanceof Error?V.message:String(V)}`),b("idle")}finally{o(""),n(!1)}},[]),z=y.useCallback(async()=>{if(E.current=!0,S.current&&(clearTimeout(S.current),S.current=null),_v){await wu.stop().catch(()=>{});for(const H of N.current)await H.remove().catch(()=>{});N.current=[],n(!1),o("")}else x.current?x.current.stop():O.current?await M():(n(!1),b("idle"))},[M]),G=y.useCallback(async()=>{var L;B.current=!1,a(""),o(""),d(null),b("idle");const{available:H}=await wu.available();if(!H){d("当前设备不支持语音识别");return}if((await wu.requestPermissions()).speechRecognition!=="granted"){d("请允许语音识别权限");return}const Y=[];Y.push(await wu.addListener("partialResults",$=>{o($.matches[0]??"")})),Y.push(await wu.addListener("listeningState",$=>{const Q=$.status==="started";n(Q),Q&&b("recording"),Q||o("")})),N.current=Y;try{const $=await wu.start({language:e,partialResults:!0,maxResults:1});(L=$.matches)!=null&&L.length&&a(Q=>Q+$.matches.join(""))}catch($){d(`语音识别错误:${$ instanceof Error?$.message:String($)}`);for(const Q of Y)await Q.remove().catch(()=>{});N.current=[]}},[e]),ae=y.useCallback(()=>{if(!dy)return!1;B.current=!1,a(""),o(""),A.current="",d(null),b("idle"),E.current=!1;const H=new dy;H.lang=e,H.continuous=!0,H.interimResults=!0,H.maxAlternatives=1,H.onstart=()=>{n(!0),b("recording"),T.current=!1,S.current=setTimeout(()=>{!T.current&&!E.current&&(C.current=!0,E.current=!0,H.stop(),d("语音识别服务不可用(Chrome/Edge 需连接 Google 服务器),下次将使用服务端识别"))},5e3)},H.onresult=F=>{T.current=!0,S.current&&(clearTimeout(S.current),S.current=null);let Y="",L="";for(let $=F.resultIndex;$<F.results.length;$++){const Q=F.results[$][0].transcript;F.results[$].isFinal?Y+=Q:L+=Q}Y&&a($=>$+Y),o(L),A.current=L},H.onerror=F=>{switch(F.error!=="no-speech"&&F.error!=="aborted"&&(E.current=!0),F.error){case"not-allowed":d("请允许麦克风权限");break;case"network":d("网络错误,请检查连接");break;case"no-speech":case"aborted":return;default:d(`语音识别错误:${F.error}`)}},H.onend=()=>{if(E.current&&A.current&&a(F=>F+A.current),o(""),A.current="",!E.current)try{H.start();return}catch{}n(!1),x.current=null},x.current=H;try{return H.start(),!0}catch{return!1}},[e]),Z=y.useCallback(async()=>{B.current=!1,a(""),o(""),d(null),b("idle");try{const $=await fetch("/api/transcribe/status"),{available:Q}=await $.json();if(!Q){d("语音识别服务未就绪,请稍后重试");return}}catch{d("无法连接语音识别服务");return}let H;try{H=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:fy,channelCount:1}})}catch{d("请允许麦克风权限");return}const F=new AudioContext({sampleRate:fy}),Y=F.createMediaStreamSource(H),L=F.createScriptProcessor(4096,1,1);D.current=[],L.onaudioprocess=$=>{D.current.push(new Float32Array($.inputBuffer.getChannelData(0)))},Y.connect(L),L.connect(F.destination),O.current=F,R.current=H,k.current=L,n(!0),b("recording")},[]),W=y.useCallback(()=>{_v?G():dy&&!C.current&&ae()||Z()},[G,ae,Z]);y.useEffect(()=>{if(!t){m(0);return}if(x.current)return;let H=!1,F=null,Y=null,L=0;return(async()=>{try{if(F=await navigator.mediaDevices.getUserMedia({audio:!0}),H){F.getTracks().forEach(V=>V.stop());return}Y=new AudioContext;const $=Y.createMediaStreamSource(F),Q=Y.createAnalyser();Q.fftSize=256,$.connect(Q);const P=new Uint8Array(Q.frequencyBinCount);let he=0;const se=()=>{if(H)return;Q.getByteFrequencyData(P);const V=performance.now();if(V-he>80){let be=0;for(let ye=0;ye<P.length;ye++)be+=P[ye];m(be/(P.length*255)),he=V}L=requestAnimationFrame(se)};L=requestAnimationFrame(se)}catch{}})(),()=>{H=!0,cancelAnimationFrame(L),F==null||F.getTracks().forEach($=>$.stop()),Y==null||Y.close().catch(()=>{}),m(0)}},[t]),y.useEffect(()=>{!t&&p==="recording"&&b(r?"done":"idle")},[t,p,r]),y.useEffect(()=>()=>{var H,F,Y,L;E.current=!0,(H=x.current)==null||H.stop(),(F=k.current)==null||F.disconnect(),(Y=R.current)==null||Y.getTracks().forEach($=>$.stop()),(L=O.current)==null||L.close().catch(()=>{});for(const $ of N.current)$.remove().catch(()=>{})},[]);const K=y.useCallback(()=>{B.current=!0,a(""),o(""),A.current="",b("idle")},[]);return{isSupported:j,isListening:t,phase:p,transcript:r,interimTranscript:s,error:c,volumeLevel:f,start:W,stop:z,resetTranscript:K}}const pX=240,gX=1e3;function gM(e){const t=mX(),[n,r]=y.useState(""),[a,s]=y.useState(0),o=y.useRef(null),c=y.useRef(null),d=y.useRef(0);y.useEffect(()=>(t.phase==="recording"?(d.current=Date.now(),s(0),c.current=setInterval(()=>{s(Math.floor((Date.now()-d.current)/1e3))},gX)):c.current&&(clearInterval(c.current),c.current=null),()=>{c.current&&(clearInterval(c.current),c.current=null)}),[t.phase]),y.useEffect(()=>{t.phase==="done"&&(r(t.transcript),requestAnimationFrame(()=>{const b=o.current;b&&(b.focus(),b.setSelectionRange(b.value.length,b.value.length))}))},[t.phase,t.transcript]),y.useLayoutEffect(()=>{if(t.phase!=="done")return;const b=o.current;b&&(b.style.height="auto",b.style.height=`${Math.min(b.scrollHeight,pX)}px`)},[t.phase,n]);const f=y.useCallback(()=>{t.stop(),t.resetTranscript(),r("")},[t]),m=y.useCallback(async()=>{const b=n.trim();if(!b){f();return}await e(b)!==!1&&(t.resetTranscript(),r(""))},[n,e,f,t]);y.useEffect(()=>{if(t.phase==="idle")return;const b=x=>{if(x.key==="Escape"&&t.phase!=="recognizing"){x.preventDefault(),f();return}if(t.phase==="done"&&x.key==="Enter"&&(x.metaKey||x.ctrlKey)){if(x.isComposing)return;x.preventDefault(),m()}};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[t.phase,f,m]);const p=y.useCallback(b=>{b.nativeEvent.isComposing||b.keyCode===229||b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),m())},[m]);return{stt:t,editText:n,setEditText:r,elapsed:a,textareaRef:o,cancel:f,confirm:m,handleTextareaKeyDown:p}}function bX(e){if(typeof e!="string")return e;const t=e.trim();if(t)try{return JSON.parse(t)}catch{return t}}function Qn(e){return e&&typeof e=="object"?e:null}function Ml(e){const t=Qn(e);return t&&"properties"in t?t.properties:e}function xX(e){const t=Qn(e);return typeof(t==null?void 0:t.type)=="string"?t.type:void 0}function yX(e){const t=Qn(Ml(e));if(!t)return null;const n=Qn(t.info);if(n&&typeof n.id=="string"){const a=Array.isArray(t.parts)?t.parts:void 0;return{...n,...a?{parts:a}:{}}}if(typeof t.id=="string"&&typeof t.role=="string")return t;const r=Qn(t.message);return r&&typeof r.id=="string"?r:null}function vX(e){const t=Qn(Ml(e));if(!t)return{};const n=Qn(t.part)??t;return typeof n.type!="string"?{}:{messageId:typeof n.messageID=="string"&&n.messageID||typeof n.messageId=="string"&&n.messageId||typeof t.messageID=="string"&&t.messageID||typeof t.messageId=="string"&&t.messageId||void 0,part:n}}function bM(e){const t=Qn(Ml(e));if(!t||t.field!=="text")return null;const n=typeof t.messageID=="string"?t.messageID:null,r=typeof t.partID=="string"?t.partID:null,a=typeof t.delta=="string"?t.delta:null;return!n||!r||a===null?null:{messageId:n,partId:r,delta:a}}function EX(e){const t=Ml(e);if(Array.isArray(t))return t;const n=Qn(t);return n&&Array.isArray(n.todos)?n.todos:[]}function mi(e){return typeof e=="number"?e:0}function NX(e){const t=Qn(Ml(e));if(!t||typeof t.id!="string")return null;const n={id:t.id};typeof t.title=="string"&&(n.title=t.title),typeof t.agent=="string"&&(n.agent=t.agent),typeof t.cost=="number"&&(n.cost=t.cost);const r=typeof t.parentID=="string"?t.parentID:typeof t.parent_id=="string"?t.parent_id:void 0;r&&(n.parentID=r);const a=Qn(t.tokens),s=typeof t.tokens_input=="number"||typeof t.tokens_output=="number";if(a||s){const c=a?Qn(a.cache):null;n.tokens={input:mi(a==null?void 0:a.input)||mi(t.tokens_input),output:mi(a==null?void 0:a.output)||mi(t.tokens_output),reasoning:mi(a==null?void 0:a.reasoning)||mi(t.tokens_reasoning),cache:{read:mi(c==null?void 0:c.read)||mi(t.tokens_cache_read),write:mi(c==null?void 0:c.write)||mi(t.tokens_cache_write)}}}const o=Qn(t.model);return o&&(n.model={providerID:typeof o.providerID=="string"?o.providerID:void 0,modelID:typeof o.modelID=="string"?o.modelID:void 0,variant:typeof o.variant=="string"?o.variant:void 0}),n}function _X(e){const t=Qn(Ml(e));if(!t)return null;if(typeof t.message=="string")return t.message;const n=Qn(t.error);if(n){const r=Qn(n.data);if(typeof(r==null?void 0:r.message)=="string")return`${n.name??"Error"}: ${r.message}`;if(typeof n.message=="string")return`${n.name??"Error"}: ${n.message}`;if(typeof n.name=="string")return String(n.name)}return typeof t.reason=="string"?t.reason:null}function SX(e){const t=Ml(e);if(typeof t=="string")return t;const n=Qn(t);if(typeof(n==null?void 0:n.status)=="string")return n.status;const r=Qn(n==null?void 0:n.status);return typeof(r==null?void 0:r.type)=="string"?r.type:typeof(n==null?void 0:n.type)=="string"?n.type:null}function jA(e,t,n,r){switch(e==="message"||e===""?xX(t)??e:e){case"message.updated":{const s=yX(t);s&&r.updateMessage(n,s);break}case"session.updated":{const s=NX(t);s&&r.updateSessionInfo(s);break}case"message.part.updated":{const{messageId:s,part:o}=vX(t);o&&s&&r.updateMessagePart(n,s,o);break}case"message.part.delta":{const s=bM(t);s&&r.appendMessagePartDelta(n,s.messageId,s.partId,s.delta);break}case"todo.updated":{r.updateTodos(n,EX(t));break}case"session.status":{const s=SX(t);s&&r.setSessionStatus(n,s);break}case"session.idle":{r.setSessionStatus(n,"idle");break}case"session.error":{const s=_X(t);r.setSessionStatus(n,"error",s??void 0);break}}}const TX=1e3,wX=5e3,Cm="freeze-mon-buffer",AX=4*1024*1024;class CX{constructor(){kt(this,"ring",[]);kt(this,"counters",{sse:0,delta:0,store:0});kt(this,"workerCount",0);kt(this,"sampleTimer",0);kt(this,"persistTimer",0);kt(this,"running",!1)}tick(t){this.counters[t]++}setGauge(t,n){t==="workers"&&(this.workerCount=n)}exportData(){return localStorage.getItem(Cm)??JSON.stringify(this.ring)}start(){if(this.running)return;this.running=!0;const t=localStorage.getItem(Cm);if(t)try{this.ring=JSON.parse(t)}catch{this.ring=[]}this.sampleTimer=window.setInterval(()=>this.sample(),TX),this.persistTimer=window.setInterval(()=>this.persist(),wX)}stop(){this.running=!1,clearInterval(this.sampleTimer),clearInterval(this.persistTimer),this.persist()}sample(){const t=De.getState(),n=Object.values(t.messages).reduce((a,s)=>a+s.length,0),r=performance.memory;this.ring.push({ts:Date.now(),sse:this.counters.sse,delta:this.counters.delta,store:this.counters.store,workers:this.workerCount,msgs:n,heap:r?Math.round(r.usedJSHeapSize/1048576):void 0}),this.counters.sse=0,this.counters.delta=0,this.counters.store=0,this.trimToFit()}trimToFit(){for(;this.ring.length>1&&!(new Blob([JSON.stringify(this.ring)]).size<=AX);)this.ring.shift()}persist(){try{localStorage.setItem(Cm,JSON.stringify(this.ring))}catch{this.ring.splice(0,Math.floor(this.ring.length/2));try{localStorage.setItem(Cm,JSON.stringify(this.ring))}catch{}}}}const ls=new CX,kX=600*1e3,OX=200;class IX{constructor(t,n){kt(this,"sessionId");kt(this,"idleTimer",null);kt(this,"flushTimer",null);kt(this,"active",!1);kt(this,"alive",!0);kt(this,"callbacks");kt(this,"eventQueue",[]);kt(this,"deltaBuffer",new Map);this.sessionId=t,this.callbacks=n,this.resetIdleTimer()}dispatch(t,n){if(this.alive){if(this.resetIdleTimer(),ls.tick("sse"),t==="message.part.delta"){this.bufferDelta(n),this.scheduleFlush();return}if(t==="session.idle"||t==="session.status"||t==="session.error"){this.flush();const r=De.getState(),a=r.sessionStatuses[this.sessionId];jA(t,n,this.sessionId,r);const s=De.getState().sessionStatuses[this.sessionId];a&&a!=="idle"&&s==="idle"&&this.callbacks.onSessionIdle(this.sessionId);return}this.eventQueue.push({name:t,data:n}),this.scheduleFlush()}}activate(){this.active=!0,this.clearIdleTimer()}deactivate(){this.active=!1,this.resetIdleTimer()}refreshOnIdle(){De.getState().refreshSessionData(this.sessionId)}stop(){this.alive=!1,this.flush(),this.clearIdleTimer(),this.cancelFlush()}scheduleFlush(){this.flushTimer||(this.flushTimer=setTimeout(()=>{this.flushTimer=null,this.flush()},OX))}cancelFlush(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null)}bufferDelta(t){const n=bM(t);if(!n)return;const r=this.deltaBuffer.get(n.partId);r?r.text+=n.delta:this.deltaBuffer.set(n.partId,{messageId:n.messageId,text:n.delta})}flush(){if(this.eventQueue.length===0&&this.deltaBuffer.size===0)return;const t=De.getState(),n=this.eventQueue;this.eventQueue=[];for(const r of n)jA(r.name,r.data,this.sessionId,t);if(this.deltaBuffer.size>0){const r=this.deltaBuffer;this.deltaBuffer=new Map;for(const[a,{messageId:s,text:o}]of r)ls.tick("delta"),ls.tick("store"),t.appendMessagePartDelta(this.sessionId,s,a,o)}}resetIdleTimer(){this.clearIdleTimer(),!this.active&&(this.idleTimer=setTimeout(()=>{this.callbacks.onWorkerIdle(this.sessionId)},kX))}clearIdleTimer(){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null)}}const RX=1e3,MX=3e4;class jX{constructor(t,n){kt(this,"source",null);kt(this,"reconnectTimer",null);kt(this,"attempts",0);kt(this,"disposed",!1);kt(this,"repoId");kt(this,"onEvent");this.repoId=t,this.onEvent=n}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=vH(this.repoId),n=new EventSource(t);this.source=n,n.onopen=()=>{this.attempts=0},n.onmessage=a=>{this.handleRaw("message",a)};const r=["message.updated","message.part.updated","message.part.delta","message.removed","todo.updated","session.status","session.idle","session.error","session.updated"];for(const a of r)n.addEventListener(a,s=>{this.handleRaw(a,s)});n.onerror=()=>{if(!(this.disposed||!this.source)&&this.source.readyState===EventSource.CLOSED){this.source.close(),this.source=null;const a=Math.min(RX*2**this.attempts,MX);this.attempts++,this.reconnectTimer=setTimeout(()=>this.connect(),a)}}}handleRaw(t,n){if(!(n instanceof MessageEvent))return;ls.tick("sse");const r=bX(n.data);if(r===void 0)return;const a=this.extractSessionId(r);if(!a)return;let s=t;if(t==="message"||t===""){const o=r&&typeof r=="object"?r:null;typeof(o==null?void 0:o.type)=="string"&&(s=o.type)}this.onEvent(a,s,r)}extractSessionId(t){if(!t||typeof t!="object")return null;const n=t;if(n.properties&&typeof n.properties=="object"){const r=n.properties;if(typeof r.sessionID=="string")return r.sessionID;if(typeof r.id=="string")return r.id}return typeof n.sessionID=="string"?n.sessionID:typeof n.sessionId=="string"?n.sessionId:null}}const DX=6e4;class LX{constructor(t){kt(this,"timer",null);kt(this,"paused",!1);kt(this,"callbacks");this.callbacks=t}start(){this.tick(),this.timer=setInterval(()=>{this.paused||this.tick()},DX)}stop(){this.timer&&(clearInterval(this.timer),this.timer=null)}pause(){this.paused=!0}resume(){this.paused=!1,this.tick()}tick(){const t=Fe.getState().activeRepoId;t&&(De.getState().loadSessions(),EH(t).then(n=>{const r={};for(const[a,s]of Object.entries(n))r[a]=s.type??"idle";De.getState().bulkSetStatuses(r);for(const[a,s]of Object.entries(r))(s==="busy"||s==="retry")&&this.callbacks.ensureWorker(a)}).catch(()=>{}))}}class PX{constructor(){kt(this,"workers",new Map);kt(this,"dispatcher",null);kt(this,"supervisor",null);kt(this,"visibilityHandler",null)}start(t){this.stop();const n={onWorkerIdle:r=>this.removeWorker(r),onSessionIdle:r=>{var a;(a=this.workers.get(r))==null||a.refreshOnIdle()}};this.dispatcher=new jX(t,(r,a,s)=>{this.ensureWorker(r,n).dispatch(a,s)}),this.dispatcher.start(),this.supervisor=new LX({ensureWorker:r=>this.ensureWorker(r,n)}),this.supervisor.start(),this.visibilityHandler=()=>{var r,a;document.hidden?(r=this.supervisor)==null||r.pause():(a=this.supervisor)==null||a.resume()},document.addEventListener("visibilitychange",this.visibilityHandler)}stop(){var t,n;(t=this.dispatcher)==null||t.stop(),this.dispatcher=null,(n=this.supervisor)==null||n.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 a of this.workers.values())a.sessionId!==t&&a.deactivate();if(!t)return;const n={onWorkerIdle:a=>this.removeWorker(a),onSessionIdle:a=>{var s;return(s=this.workers.get(a))==null?void 0:s.refreshOnIdle()}};this.ensureWorker(t,n).activate(),De.getState().refreshSessionData(t)}deactivateSession(t){var n;(n=this.workers.get(t))==null||n.deactivate()}ensureWorker(t,n){let r=this.workers.get(t);return r||(r=new IX(t,n),this.workers.set(t,r),ls.setGauge("workers",this.workers.size)),r}removeWorker(t){const n=De.getState().activeSessionId;if(t===n)return;const r=this.workers.get(t);r&&(r.stop(),this.workers.delete(t),ls.setGauge("workers",this.workers.size))}}const Np=new PX,DA=(function(e,t,n){const r=Uf(n);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]}),jl=(function(e){if(e==null)return FX;if(typeof e=="string")return UX(e);if(typeof e=="object")return BX(e);if(typeof e=="function")return fE(e);throw new Error("Expected function, string, or array as `test`")});function BX(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=jl(e[n]);return fE(r);function r(...a){let s=-1;for(;++s<t.length;)if(t[s].apply(this,a))return!0;return!1}}function UX(e){return fE(t);function t(n){return n.tagName===e}}function fE(e){return t;function t(n,r,a){return!!(zX(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function FX(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function zX(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const LA=/\n/g,PA=/[\t ]+/g,Sv=jl("br"),BA=jl(WX),HX=jl("p"),UA=jl("tr"),$X=jl(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",VX,XX]),xM=jl(["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 YX(e,t){const n=t||{},r="children"in e?e.children:[],a=xM(e),s=EM(e,{whitespace:n.whitespace||"normal"}),o=[];(e.type==="text"||e.type==="comment")&&o.push(...vM(e,{breakBefore:!0,breakAfter:!0}));let c=-1;for(;++c<r.length;)o.push(...yM(r[c],e,{whitespace:s,breakBefore:c?void 0:a,breakAfter:c<r.length-1?Sv(r[c+1]):a}));const d=[];let f;for(c=-1;++c<o.length;){const m=o[c];typeof m=="number"?f!==void 0&&m>f&&(f=m):m&&(f!==void 0&&f>-1&&d.push(`
552
552
  `.repeat(f)||" "),f=-1,d.push(m))}return d.join("")}function yM(e,t,n){return e.type==="element"?qX(e,t,n):e.type==="text"?n.whitespace==="normal"?vM(e,n):GX(e):[]}function qX(e,t,n){const r=EM(e,n),a=e.children||[];let s=-1,o=[];if($X(e))return o;let c,d;for(Sv(e)||UA(e)&&DA(t,e,UA)?d=`
553
553
  `:HX(e)?(c=2,d=2):xM(e)&&(c=1,d=1);++s<a.length;)o=o.concat(yM(a[s],e,{whitespace:r,breakBefore:s?void 0:c,breakAfter:s<a.length-1?Sv(a[s+1]):d}));return BA(e)&&DA(t,e,BA)&&o.push(" "),c&&o.unshift(c),d&&o.push(d),o}function vM(e,t){const n=String(e.value),r=[],a=[];let s=0;for(;s<=n.length;){LA.lastIndex=s;const d=LA.exec(n),f=d&&"index"in d?d.index:n.length;r.push(KX(n.slice(s,f).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),s===0?t.breakBefore:!0,f===n.length?t.breakAfter:!0)),s=f+1}let o=-1,c;for(;++o<r.length;)r[o].charCodeAt(r[o].length-1)===8203||o<r.length-1&&r[o+1].charCodeAt(0)===8203?(a.push(r[o]),c=void 0):r[o]?(typeof c=="number"&&a.push(c),a.push(r[o]),c=0):(o===0||o===r.length-1)&&a.push(0);return a}function GX(e){return[String(e.value)]}function KX(e,t,n){const r=[];let a=0,s;for(;a<e.length;){PA.lastIndex=a;const o=PA.exec(e);s=o?o.index:e.length,!a&&!s&&o&&!t&&r.push(""),a!==s&&r.push(e.slice(a,s)),a=o?s+o[0].length:s}return a!==s&&!n&&r.push(""),r.join(" ")}function EM(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function VX(e){return!!(e.properties||{}).hidden}function WX(e){return e.tagName==="td"||e.tagName==="th"}function XX(e){return e.tagName==="dialog"&&!(e.properties||{}).open}function QX(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",a="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+t.optional(a)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={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})"/})]},m={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},p={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(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},b={className:"title",begin:t.optional(a)+e.IDENT_RE,relevance:0},x=t.optional(a)+e.IDENT_RE+"\\s*\\(",E=["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"],N=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],T=["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"],O={type:N,keyword:E,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:T},R={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:t.concat(/\b/,`(?!${E.join("|")})`,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},k=[R,p,c,n,e.C_BLOCK_COMMENT_MODE,m,f],D={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:O,contains:k.concat([{begin:/\(/,end:/\)/,keywords:O,contains:k.concat(["self"]),relevance:0}]),relevance:0},B={className:"function",begin:"("+o+"[\\*&\\s]+)+"+x,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:O,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:O,relevance:0},{begin:x,returnBegin:!0,contains:[b],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,m]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:O,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,f,m,c,{begin:/\(/,end:/\)/,keywords:O,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,f,m,c]}]},c,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:O,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(D,B,R,k,[p,{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:O,contains:["self",c]},{begin:e.IDENT_RE+"::",keywords:O},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function ZX(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"]},n=QX(e),r=n.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,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function JX(e){const t=e.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:t.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const a={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},s=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n,a]};a.contains.push(c);const d={match:/\\"/},f={className:"string",begin:/'/,end:/'/},m={match:/\\'/},p={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,n]},b=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],x=e.SHEBANG({binary:`(${b.join("|")})`,relevance:10}),E={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},N=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],T=["true","false"],S={match:/(\/[a-z._-]+)+/},C=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],A=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],O=["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"],R=["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:N,literal:T,built_in:[...C,...A,"set","shopt",...O,...R]},contains:[x,e.SHEBANG(),E,p,s,o,S,c,d,f,m,n]}}function eQ(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",a="[a-zA-Z_]\\w*::",o="("+r+"|"+t.optional(a)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",c={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},f={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})"/})]},m={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},p={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(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},b={className:"title",begin:t.optional(a)+e.IDENT_RE,relevance:0},x=t.optional(a)+e.IDENT_RE+"\\s*\\(",T={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=[p,c,n,e.C_BLOCK_COMMENT_MODE,m,f],C={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:T,contains:S.concat([{begin:/\(/,end:/\)/,keywords:T,contains:S.concat(["self"]),relevance:0}]),relevance:0},A={begin:"("+o+"[\\*&\\s]+)+"+x,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:T,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:T,relevance:0},{begin:x,returnBegin:!0,contains:[e.inherit(b,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,f,m,c,{begin:/\(/,end:/\)/,keywords:T,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,f,m,c]}]},c,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C",aliases:["h"],keywords:T,disableAutodetect:!0,illegal:"</",contains:[].concat(C,A,S,[p,{begin:e.IDENT_RE+"::",keywords:T},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},e.TITLE_MODE]}]),exports:{preprocessor:p,strings:f,keywords:T}}}function tQ(e){const t=e.regex,n=e.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",a="[a-zA-Z_]\\w*::",o="(?!struct)("+r+"|"+t.optional(a)+"[a-zA-Z_]\\w*"+t.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={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})"/})]},m={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},p={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(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,e.C_BLOCK_COMMENT_MODE]},b={className:"title",begin:t.optional(a)+e.IDENT_RE,relevance:0},x=t.optional(a)+e.IDENT_RE+"\\s*\\(",E=["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"],N=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],T=["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"],O={type:N,keyword:E,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:T},R={className:"function.dispatch",relevance:0,keywords:{_hint:S},begin:t.concat(/\b/,`(?!${E.join("|")})`,e.IDENT_RE,t.lookahead(/(<[^<>]+>|)\s*\(/))},k=[R,p,c,n,e.C_BLOCK_COMMENT_MODE,m,f],D={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:O,contains:k.concat([{begin:/\(/,end:/\)/,keywords:O,contains:k.concat(["self"]),relevance:0}]),relevance:0},B={className:"function",begin:"("+o+"[\\*&\\s]+)+"+x,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:O,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:O,relevance:0},{begin:x,returnBegin:!0,contains:[b],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,m]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:O,relevance:0,contains:[n,e.C_BLOCK_COMMENT_MODE,f,m,c,{begin:/\(/,end:/\)/,keywords:O,relevance:0,contains:["self",n,e.C_BLOCK_COMMENT_MODE,f,m,c]}]},c,n,e.C_BLOCK_COMMENT_MODE,p]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:O,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(D,B,R,k,[p,{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:O,contains:["self",c]},{begin:e.IDENT_RE+"::",keywords:O},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function nQ(e){const t=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],a=["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"],s=["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"],o={keyword:a.concat(s),built_in:t,literal:r},c=e.inherit(e.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),d={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},f={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},m={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},p=e.inherit(m,{illegal:/\n/}),b={className:"subst",begin:/\{/,end:/\}/,keywords:o},x=e.inherit(b,{illegal:/\n/}),E={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},e.BACKSLASH_ESCAPE,x]},N={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},b]},T=e.inherit(N,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},x]});b.contains=[N,E,m,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,d,e.C_BLOCK_COMMENT_MODE],x.contains=[T,E,p,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,d,e.inherit(e.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const S={variants:[f,N,E,m,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},C={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},A=e.IDENT_RE+"(<"+e.IDENT_RE+"(\\s*,\\s*"+e.IDENT_RE+")*>)?(\\[\\])?",O={begin:"@"+e.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:o,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,d,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,C,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,C,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:"("+A+"\\s+)+"+e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:o,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:e.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[e.TITLE_MODE,C],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,relevance:0,contains:[S,d,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},O]}}const rQ=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/},UNICODE_RANGE:{scope:"number",begin:/\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,4}(-[0-9A-Fa-f][0-9A-Fa-f]{0,4})?/},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_-]*/}}),aQ=["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"],iQ=["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"],sQ=[...aQ,...iQ],oQ=["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(),lQ=["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(),uQ=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),cQ=["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","unicode-range","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 dQ(e){const t=e.regex,n=rQ(e),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},a="and or not only",s=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",c=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+lQ.join("|")+")"},{begin:":(:)?("+uQ.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+cQ.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,n.UNICODE_RANGE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:t.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:s},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:a,attribute:oQ.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+sQ.join("|")+")\\b"}]}}function fQ(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+,\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 hQ(e){const s={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:s,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:s,illegal:/["']/}]}]}}function mQ(e){const t=e.regex,n=/[_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(n,t.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function pQ(e){const t=e.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:e.NUMBER_RE}]},r=e.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const a={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},s={className:"literal",begin:/\bon|off|true|false|yes|no\b/},o={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,s,a,o,n,"self"],relevance:0},d=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,m=/'[^']*'/,p=t.either(d,f,m),b=t.concat(p,"(\\s*\\.\\s*",p,")*",t.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:b,className:"attr",starts:{end:/$/,contains:[r,c,s,a,o,n]}}]}}var Du="[0-9](_*[0-9])*",km=`\\.(${Du})`,Om="[0-9a-fA-F](_*[0-9a-fA-F])*",FA={className:"number",variants:[{begin:`(\\b(${Du})((${km})|\\.)?|(${km}))[eE][+-]?(${Du})[fFdD]?\\b`},{begin:`\\b(${Du})((${km})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${km})[fFdD]?\\b`},{begin:`\\b(${Du})[fFdD]\\b`},{begin:`\\b0[xX]((${Om})\\.?|(${Om})?\\.(${Om}))[pP][+-]?(${Du})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Om})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function NM(e,t,n){return n===-1?"":e.replace(t,r=>NM(e,t,n-1))}function gQ(e){const t=e.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+NM("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),d={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"]},f={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},m={className:"params",begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:d,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+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[t.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[m,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:d,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:d,relevance:0,contains:[f,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,FA,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},FA,f]}}const zA="[A-Za-z$_][0-9A-Za-z$_]*",bQ=["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"],xQ=["true","false","null","undefined","NaN","Infinity"],_M=["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"],SM=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],TM=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],yQ=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],vQ=[].concat(TM,_M,SM);function EQ(e){const t=e.regex,n=(F,{after:Y})=>{const L="</"+F[0].slice(1);return F.input.indexOf(L,Y)!==-1},r=zA,a={begin:"<>",end:"</>"},s=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,Y)=>{const L=F[0].length+F.index,$=F.input[L];if($==="<"||$===","){Y.ignoreMatch();return}$===">"&&(n(F,{after:L})||Y.ignoreMatch());let Q;const P=F.input.substring(L);if(Q=P.match(/^\s*=/)){Y.ignoreMatch();return}if((Q=P.match(/^\s+extends\s+/))&&Q.index===0){Y.ignoreMatch();return}}},c={$pattern:zA,keyword:bQ,literal:xQ,built_in:vQ,"variable.language":yQ},d="[0-9](_?[0-9])*",f=`\\.(${d})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${m})((${f})|\\.)?|(${f}))[eE][+-]?(${d})\\b`},{begin:`\\b(${m})\\b((${f})\\b|\\.)?|(${f})\\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},b={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"xml"}},E={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"css"}},N={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"graphql"}},T={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,b]},C={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]},A=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,E,N,T,{match:/\$\d+/},p];b.contains=A.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(A)});const O=[].concat(C,b.contains),R=O.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(O)}]),k={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:R},D={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"}}]},B={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:{_:[..._M,...SM]}},j={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},M={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[k],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function G(F){return t.concat("(?!",F.join("|"),")")}const ae={match:t.concat(/\b/,G([...TM,"super","import","await"].map(F=>`${F}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},Z={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},W={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},k]},K="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",H={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(K)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[k]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:R,CLASS_REFERENCE:B},illegal:/#(?![$_A-Za-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),j,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,E,N,T,C,{match:/\$\d+/},p,B,{scope:"attr",match:r+t.lookahead(":"),relevance:0},H,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,e.REGEXP_MODE,{className:"function",begin:K,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:c,contains:R}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:a.begin,end:a.end},{match:s},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},M,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[k,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},Z,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[k]},ae,z,D,W,{match:/\$[(.]/}]}}const NQ="([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",_Q={scope:"number",match:NQ,relevance:0};function SQ(e){const t={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],a={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:r},contains:[t,n,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,a,_Q,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}var Lu="[0-9](_*[0-9])*",Im=`\\.(${Lu})`,Rm="[0-9a-fA-F](_*[0-9a-fA-F])*",TQ={className:"number",variants:[{begin:`(\\b(${Lu})((${Im})|\\.)?|(${Im}))[eE][+-]?(${Lu})[fFdD]?\\b`},{begin:`\\b(${Lu})((${Im})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Im})[fFdD]?\\b`},{begin:`\\b(${Lu})[fFdD]\\b`},{begin:`\\b0[xX]((${Rm})\\.?|(${Rm})?\\.(${Rm}))[pP][+-]?(${Lu})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Rm})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function wQ(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"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"@"},a={className:"subst",begin:/\$\{/,end:/\}/,contains:[e.C_NUMBER_MODE]},s={className:"variable",begin:"\\$"+e.UNDERSCORE_IDENT_RE},o={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[s,a]},{begin:"'",end:"'",illegal:/\n/,contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[e.BACKSLASH_ESCAPE,s,a]}]};a.contains.push(o);const c={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+e.UNDERSCORE_IDENT_RE+")?"},d={className:"meta",begin:"@"+e.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[e.inherit(o,{className:"string"}),"self"]}]},f=TQ,m=e.COMMENT("/\\*","\\*/",{contains:[e.C_BLOCK_COMMENT_MODE]}),p={variants:[{className:"type",begin:e.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},b=p;return b.variants[1].contains=[p],p.variants[1].contains=[b],{name:"Kotlin",aliases:["kt","kts"],keywords:t,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),e.C_LINE_COMMENT_MODE,m,n,r,c,d,{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:[p,e.C_LINE_COMMENT_MODE,m],relevance:0},e.C_LINE_COMMENT_MODE,m,c,d,o,e.C_NUMBER_MODE]},m]},{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},c,d]},o,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
554
554
  `},f]}}const AQ=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/},UNICODE_RANGE:{scope:"number",begin:/\b[Uu]\+[0-9A-Fa-f][0-9A-Fa-f?]{0,4}(-[0-9A-Fa-f][0-9A-Fa-f]{0,4})?/},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_-]*/}}),CQ=["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"],kQ=["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"],OQ=[...CQ,...kQ],IQ=["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(),wM=["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(),AM=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),RQ=["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","unicode-range","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(),MQ=wM.concat(AM).sort().reverse();function jQ(e){const t=AQ(e),n=MQ,r="and or not only",a="[\\w-]+",s="("+a+"|@\\{"+a+"\\})",o=[],c=[],d=function(A){return{className:"string",begin:"~?"+A+".*?"+A}},f=function(A,O,R){return{className:A,begin:O,relevance:R}},m={$pattern:/[a-z-]+/,keyword:r,attribute:IQ.join(" ")},p={begin:"\\(",end:"\\)",contains:c,keywords:m,relevance:0};c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,d("'"),d('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.UNICODE_RANGE,t.HEXCOLOR,p,f("variable","@@?"+a,10),f("variable","@\\{"+a+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:a+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const b=c.concat({begin:/\{/,end:/\}/,contains:o}),x={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(c)},E={begin:s+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+RQ.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},N={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:m,returnEnd:!0,contains:c,relevance:0}},T={className:"variable",variants:[{begin:"@"+a+"\\s*:",relevance:15},{begin:"@"+a}],starts:{end:"[;}]",returnEnd:!0,contains:b}},S={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:s,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,x,f("keyword","all\\b"),f("variable","@\\{"+a+"\\}"),{begin:"\\b("+OQ.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,f("selector-tag",s,0),f("selector-id","#"+s),f("selector-class","\\."+s,0),f("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+wM.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+AM.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:b},{begin:"!important"},t.FUNCTION_DISPATCH]},C={begin:a+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[S]};return o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,N,T,C,E,S,x,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function DQ(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},a=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{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:a.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:a}].concat(a)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}function LQ(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={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,n]},a={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},s={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},o={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,n,r,a,s,o]}}function PQ(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},a={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}]},s={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,d={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),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}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},m={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(f,{contains:[]}),b=e.inherit(m,{contains:[]});f.contains.push(b),m.contains.push(p);let x=[n,d];return[f,m,p,b].forEach(S=>{S.contains=S.contains.concat(x)}),x=x.concat(f,m),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:x},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:x}]}]},n,s,f,m,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},a,r,d,o,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function BQ(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+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,c={"variable.language":["this","super"],$pattern:n,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"]},d={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:c,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:"("+d.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:d,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function UQ(e){const t=e.regex,n=["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}/,a={$pattern:/[\w.]+/,keyword:n.join(" ")},s={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:a},o={begin:/->\{/,end:/\}/},c={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},d={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[c]},f={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},m=[e.BACKSLASH_ESCAPE,s,d],p=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],b=(N,T,S="\\1")=>{const C=S==="\\1"?S:t.concat(S,T);return t.concat(t.concat("(?:",N,")"),T,/(?:\\.|[^\\\/])*?/,C,/(?:\\.|[^\\\/])*?/,S,r)},x=(N,T,S)=>t.concat(t.concat("(?:",N,")"),T,/(?:\\.|[^\\\/])*?/,S,r),E=[d,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:m,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}]},f,{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:b("s|tr|y",t.either(...p,{capture:!0}))},{begin:b("s|tr|y","\\(","\\)")},{begin:b("s|tr|y","\\[","\\]")},{begin:b("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:x("(?:m|qr)?",/\//,/\//)},{begin:x("m|qr",t.either(...p,{capture:!0}),/\1/)},{begin:x("m|qr",/\(/,/\)/)},{begin:x("m|qr",/\[/,/\]/)},{begin:x("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,c]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,c,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return s.contains=E,o.contains=E,{name:"Perl",aliases:["pl","pm"],keywords:a,contains:E}}function FQ(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),a=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),s=t.concat(/[A-Z]+/,n),o={scope:"variable",match:"\\$+"+r},c={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},d={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=e.inherit(e.APOS_STRING_MODE,{illegal:null}),m=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(d)}),p={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(d),"on:begin":(Z,W)=>{W.data._beginMatch=Z[1]||Z[2]},"on:end":(Z,W)=>{W.data._beginMatch!==Z[1]&&W.ignoreMatch()}},b=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),x=`[
@@ -564,7 +564,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Sn=ke,jt=Ge),ft===void
564
564
 
565
565
  ---
566
566
 
567
- `),Z=async()=>{if(!(!s.trim()||!f)){O(!0);try{await n({name:s.trim(),description:c.trim()||void 0,baseAgent:f,model:p.trim()||void 0,variant:x.trim()||void 0,systemPrompt:N,systemPromptPosition:G,fragmentIds:z})}finally{O(!1)}}};return u.jsxs("div",{className:"space-y-3 rounded-xl border border-line bg-surface p-5",children:[u.jsxs("div",{className:"flex gap-3",children:[u.jsxs("label",{className:"flex-1",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"名称"}),u.jsx("input",{type:"text",value:s,onChange:W=>o(W.target.value),placeholder:"代码审查员",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"})]}),u.jsxs("label",{className:"w-36",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Base Agent"}),u.jsx("select",{value:f,onChange:W=>m(W.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:hre.map(W=>u.jsx("option",{value:W,children:W},W))})]})]}),u.jsxs("label",{className:"block",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"描述(可选)"}),u.jsx("input",{type:"text",value:c,onChange:W=>d(W.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"})]}),u.jsxs("div",{className:"flex gap-3",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"模型(可选)"}),u.jsxs("select",{value:p,onChange:W=>b(W.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:[u.jsx("option",{value:"",children:"默认模型"}),R.map(W=>u.jsx("option",{value:W.id,children:W.name||W.id},W.id))]}),R.length===0&&u.jsx("p",{className:"mt-1 text-[11px] text-fg-5",children:"在设置的「模型」中勾选常用模型后可选择。"})]}),u.jsxs("div",{className:"w-28",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Variant"}),u.jsxs("select",{value:x,onChange:W=>E(W.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:[u.jsx("option",{value:"",children:"默认"}),u.jsx("option",{value:"max",children:"max"}),u.jsx("option",{value:"high",children:"high"})]})]})]}),u.jsxs("div",{children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"提示词组合"}),u.jsx("p",{className:"mt-0.5 text-[11px] text-fg-5",children:"排序片段与补充指令的拼接顺序。"}),u.jsxs("div",{className:"mt-1.5 space-y-1",children:[D.map((W,K)=>{if(W===qo)return u.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2 py-1",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("button",{type:"button",onClick:()=>M(K,-1),disabled:K===0,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▲"}),u.jsx("button",{type:"button",onClick:()=>M(K,1),disabled:K===D.length-1,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▼"})]}),u.jsx("span",{className:"flex-1 truncate text-xs font-medium text-amber-400",children:"✎ 补充指令"})]},W);const H=t.find(F=>F.id===W);return H?u.jsxs("div",{className:"flex items-center gap-2 rounded border border-blue-500/30 bg-blue-500/5 px-2 py-1",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("button",{type:"button",onClick:()=>M(K,-1),disabled:K===0,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▲"}),u.jsx("button",{type:"button",onClick:()=>M(K,1),disabled:K===D.length-1,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▼"})]}),u.jsx("span",{className:"flex-1 truncate text-xs text-fg",children:H.name}),u.jsx("button",{type:"button",onClick:()=>j(W),className:"text-fg-5 hover:text-red-400",children:u.jsx(ct,{className:"h-3 w-3"})})]},W):null}),t.filter(W=>!z.includes(W.id)).length>0&&u.jsxs("select",{value:"",onChange:W=>{W.target.value&&j(W.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:[u.jsx("option",{value:"",children:"+ 添加片段…"}),t.filter(W=>!z.includes(W.id)).map(W=>u.jsx("option",{value:W.id,children:W.name},W.id))]})]})]}),u.jsxs("label",{className:"block",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"补充指令内容"}),u.jsx("textarea",{value:N,onChange:W=>T(W.target.value),rows:3,placeholder:"agent 级别的补充指令…",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 placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"})]}),(z.length>0||N)&&u.jsxs("div",{children:[u.jsxs("button",{type:"button",onClick:()=>C(!S),className:"flex items-center gap-1 text-xs font-medium text-fg-4 hover:text-fg-3",children:[u.jsx("span",{children:S?"▾":"▸"})," 预览最终提示词"]}),S&&u.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:ae||"(空)"})]}),u.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[u.jsx("button",{type:"button",onClick:r,className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),u.jsx("button",{type:"button",onClick:()=>void Z(),disabled:A||!s.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:A?"保存中…":e?"更新":"创建"})]})]})}function xre({fragment:e,onEdit:t,onDelete:n}){const[r,a]=y.useState(!1);return u.jsxs("div",{className:"group flex items-center gap-3 rounded-lg border border-line bg-base px-3 py-2",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"text-xs font-medium text-fg",children:e.name}),e.content&&u.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-fg-5",children:e.content})]}),u.jsx("div",{className:"flex items-center gap-1",children:r?u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:n,className:"rounded p-1 text-red-400 hover:bg-red-500/10",children:u.jsx(mr,{className:"h-3.5 w-3.5"})}),u.jsx("button",{type:"button",onClick:()=>a(!1),className:"rounded p-1 text-fg-4 hover:bg-elevated",children:u.jsx(ct,{className:"h-3.5 w-3.5"})})]}):u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:t,className:"rounded p-1 text-fg-5 opacity-0 transition-opacity hover:text-fg-3 group-hover:opacity-100",children:u.jsx(F1,{className:"h-3.5 w-3.5"})}),u.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded p-1 text-fg-5 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:u.jsx(wi,{className:"h-3.5 w-3.5"})})]})})]})}function jC({initial:e,onSave:t,onCancel:n}){const[r,a]=y.useState((e==null?void 0:e.name)??""),[s,o]=y.useState((e==null?void 0:e.content)??""),[c,d]=y.useState(!1),f=async()=>{if(r.trim()){d(!0);try{await t({name:r.trim(),content:s})}finally{d(!1)}}};return u.jsxs("div",{className:"space-y-2 rounded-lg border border-line bg-base p-3",children:[u.jsx("input",{type:"text",value:r,onChange:m=>a(m.target.value),placeholder:"片段名称",className:"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"}),u.jsx("textarea",{value:s,onChange:m=>o(m.target.value),rows:3,placeholder:"提示词内容…",className:"w-full resize-y rounded-md border border-line bg-surface px-3 py-2 font-mono text-sm leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx("button",{type:"button",onClick:n,className:"rounded-md px-3 py-1 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),u.jsx("button",{type:"button",onClick:()=>void f(),disabled:c||!r.trim(),className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white hover:bg-blue-500 disabled:opacity-40",children:c?"保存中…":e?"更新":"创建"})]})]})}function yre({onImported:e,onCancel:t}){const[n,r]=y.useState(""),[a,s]=y.useState(!1),[o,c]=y.useState(null),d=y.useRef(null),f=async p=>{c(null);let b;try{b=JSON.parse(p)}catch{c("JSON 格式无效");return}if(b.type!=="fourth-spark-custom-agent"||!b.agent){c("不是有效的 Custom Agent 导出文件");return}s(!0);try{await Yz(b),e()}catch(x){c(x instanceof Error?x.message:String(x))}finally{s(!1)}},m=p=>{var E;const b=(E=p.target.files)==null?void 0:E[0];if(!b)return;const x=new FileReader;x.onload=()=>{const N=x.result;r(N),f(N)},x.readAsText(b)};return u.jsxs("div",{className:"space-y-3 rounded-xl border border-line bg-surface p-5",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"导入 Custom Agent"}),u.jsx("button",{type:"button",onClick:t,className:"rounded p-1 text-fg-5 hover:text-fg-3",children:u.jsx(ct,{className:"h-3.5 w-3.5"})})]}),u.jsx("input",{ref:d,type:"file",accept:".json",onChange:m,className:"hidden"}),u.jsxs("button",{type:"button",onClick:()=>{var p;return(p=d.current)==null?void 0:p.click()},className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-line py-2.5 text-xs text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-3",children:[u.jsx(AI,{className:"h-3.5 w-3.5"})," 上传 JSON 文件"]}),u.jsx("textarea",{value:n,onChange:p=>r(p.target.value),rows:4,placeholder:"或粘贴 JSON 内容…",className:"w-full resize-y rounded-md border border-line bg-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"}),o&&u.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-red-500/10 px-3 py-2 text-xs text-red-400",children:[u.jsx(Cn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),u.jsx("span",{children:o})]}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx("button",{type:"button",onClick:t,className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),u.jsx("button",{type:"button",onClick:()=>void f(n),disabled:a||!n.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:a?"导入中…":"导入"})]})]})}function vre(){const e=$n(),t=Fe(Br),n=Fe(Z=>Z.activeRepoId),[r,a]=y.useState([]),[s,o]=y.useState([]),[c,d]=y.useState(!0),[f,m]=y.useState(!1),[p,b]=y.useState(!1),[x,E]=y.useState(null),[N,T]=y.useState(!1),[S,C]=y.useState(!1),[A,O]=y.useState({}),[R,k]=y.useState({}),D=y.useCallback(()=>{const Z=n?PI(n):jI();Promise.all([Z,BI()]).then(([W,K])=>{a(W),o(K),d(!1)}).catch(()=>d(!1))},[n]);y.useEffect(()=>{d(!0),D()},[D]),y.useEffect(()=>{if(r.length===0)return;const Z=r.filter(W=>W.isSystem<2);for(const W of Z)LI(W.id).then(K=>{O(H=>({...H,[W.id]:K.filter(F=>!F.supersededBy).length}))}).catch(()=>{}),$1(W.id).then(K=>{k(H=>({...H,[W.id]:K.length}))}).catch(()=>{})},[r]);const B=r.filter(Z=>Z.isSystem<2),j=async Z=>{n?await Wz(n,Z):await Hz(Z),m(!1),D(),Pa.getState().loadAgents()},M=async Z=>{await DI(Z),a(W=>W.filter(K=>K.id!==Z)),Pa.getState().loadAgents()},z=async Z=>{await Xz(Z),b(!1),D()},G=async Z=>{x&&(await Qz(x.id,Z),E(null),D())},ae=async Z=>{await Zz(Z),o(W=>W.filter(K=>K.id!==Z))};return n?u.jsx("div",{className:"flex-1 overflow-y-auto",children:u.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 p-6",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-lg font-bold text-fg",children:"Agents"}),u.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"组合 base agent + 模型 + 提示词片段,创建 Session 时选择。"})]}),u.jsxs("div",{"data-guide":"agents-header",className:"flex items-center gap-2",children:[u.jsxs("button",{type:"button",onClick:()=>{T(!0),m(!1)},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",children:[u.jsx(AI,{className:"h-3.5 w-3.5"})," 导入"]}),u.jsxs("button",{type:"button",onClick:()=>{m(!0),T(!1)},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",children:[u.jsx(ta,{className:"h-3.5 w-3.5"})," 创建"]})]})]}),f&&u.jsx(bre,{availableFragments:s,onSave:j,onCancel:()=>m(!1)}),N&&u.jsx(yre,{onImported:()=>{T(!1),D(),Pa.getState().loadAgents()},onCancel:()=>T(!1)}),c?u.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[u.jsx(an,{className:"h-5 w-5 fs-spin"}),u.jsx("p",{className:"text-xs",children:"加载中…"})]}):B.length===0&&!f?u.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-fg-5",children:[u.jsx(Ku,{className:"h-8 w-8 text-fg-6"}),u.jsx("p",{className:"text-sm",children:"还没有 Agent"}),u.jsx("p",{className:"text-xs text-fg-5",children:"点击上方「创建」开始。"})]}):u.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:B.map(Z=>u.jsx("div",{className:"group",children:u.jsx(gre,{agent:Z,memoryCount:A[Z.id]??0,sessionCount:R[Z.id]??0,onClick:()=>e(`/${encodeURIComponent(t??"")}/agents/${Z.id}`),onDelete:()=>void M(Z.id)})},Z.id))}),u.jsxs("section",{"data-guide":"agents-fragments",className:"rounded-xl border border-line bg-surface",children:[u.jsxs("button",{type:"button",onClick:()=>C(!S),className:"flex w-full items-center justify-between px-5 py-4 text-left",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-fg",children:"提示词片段"}),u.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"可复用的提示词模块,可在多个 Agent 间共享。"})]}),u.jsx(Nr,{className:re("h-4 w-4 shrink-0 text-fg-4 transition-transform",S&&"rotate-180")})]}),S&&u.jsx("div",{className:"border-t border-line px-5 pb-5 pt-3",children:u.jsxs("div",{className:"space-y-1.5",children:[s.map(Z=>(x==null?void 0:x.id)===Z.id?u.jsx(jC,{initial:Z,onSave:G,onCancel:()=>E(null)},Z.id):u.jsx(xre,{fragment:Z,onEdit:()=>E(Z),onDelete:()=>void ae(Z.id)},Z.id)),p?u.jsx(jC,{onSave:z,onCancel:()=>b(!1)}):u.jsxs("button",{type:"button",onClick:()=>b(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-line py-2 text-xs text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-3",children:[u.jsx(ta,{className:"h-3.5 w-3.5"})," 添加片段"]})]})})]})]})}):u.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:u.jsx("p",{className:"text-sm text-fg-4",children:"请先在顶部选择一个仓库。"})})}const Ere=["Sisyphus - ultraworker","Prometheus - Plan Builder","Atlas - Plan Executor"],Nre="pinned_models",Go="__system_prompt__",DC=[{bg:"bg-blue-500/15",text:"text-blue-500"},{bg:"bg-purple-500/15",text:"text-purple-500"},{bg:"bg-emerald-500/15",text:"text-emerald-500"},{bg:"bg-amber-500/15",text:"text-amber-500"},{bg:"bg-rose-500/15",text:"text-rose-500"},{bg:"bg-cyan-500/15",text:"text-cyan-500"},{bg:"bg-indigo-500/15",text:"text-indigo-500"},{bg:"bg-orange-500/15",text:"text-orange-500"}];function _re(e){const t=e.trim(),n=t.charCodeAt(0)||0;return{...DC[n%DC.length],initial:(t.charAt(0)||"?").toUpperCase()}}const LC=[{bg:"bg-blue-500/10",text:"text-blue-400"},{bg:"bg-amber-500/10",text:"text-amber-400"},{bg:"bg-green-500/10",text:"text-green-400"},{bg:"bg-purple-500/10",text:"text-purple-400"},{bg:"bg-cyan-500/10",text:"text-cyan-400"},{bg:"bg-rose-500/10",text:"text-rose-400"},{bg:"bg-indigo-500/10",text:"text-indigo-400"},{bg:"bg-orange-500/10",text:"text-orange-400"}],Sre={bg:"bg-elevated",text:"text-fg-4"};function Ij(e){if(e==="general")return Sre;let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return LC[Math.abs(t)%LC.length]}function Zu(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"刚刚";if(n<60)return`${n} 分钟前`;const r=Math.floor(n/60);if(r<24)return`${r} 小时前`;const a=Math.floor(r/24);return a<30?`${a} 天前`:`${Math.floor(a/30)} 个月前`}const Rj={create:{label:"首次提取",color:"text-green-400"},update:{label:"重写",color:"text-blue-400"},merge:{label:"合并",color:"text-purple-400"},decay:{label:"衰减",color:"text-amber-400"},reinforce:{label:"强化",color:"text-emerald-400"},manual:{label:"手动编辑",color:"text-fg-3"}};function Tre({memory:e,onClose:t}){const n=[...e.history??[]].reverse();return u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:u.jsxs("div",{className:"mx-4 max-h-[80vh] w-full max-w-lg overflow-y-auto rounded-xl border border-line bg-surface p-5 shadow-xl",onClick:r=>r.stopPropagation(),children:[u.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[u.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["版本历史 (",n.length+1," 个版本)"]}),u.jsx("button",{type:"button",onClick:t,className:"rounded p-1 text-fg-4 hover:text-fg-3",children:u.jsx(ct,{className:"h-4 w-4"})})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"rounded-lg border border-blue-500/20 bg-blue-500/5 p-3",children:[u.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[10px]",children:[u.jsx("span",{className:"font-medium text-blue-400",children:"当前版本"}),u.jsx("span",{className:"text-fg-5",children:Zu(e.updatedAt)}),u.jsxs("span",{className:"text-fg-6",children:["⚡ ",e.importance.toFixed(2)]})]}),u.jsx("p",{className:"text-xs leading-relaxed text-fg",children:e.content})]}),n.map((r,a)=>{const s=Rj[r.action]??{label:r.action,color:"text-fg-4"};return u.jsxs("div",{className:"rounded-lg border border-line bg-base p-3",children:[u.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[10px]",children:[u.jsx("span",{className:re("font-medium",s.color),children:s.label}),u.jsx("span",{className:"text-fg-5",children:Zu(r.ts)}),u.jsxs("span",{className:"text-fg-6",children:["⚡ ",r.importance.toFixed(2)]}),r.source&&u.jsxs("span",{className:"text-fg-6",children:["· ",r.source]})]}),u.jsx("p",{className:"text-xs leading-relaxed text-fg-4",children:r.content})]},a)}),n.length===0&&u.jsx("div",{className:"py-4 text-center text-xs text-fg-5",children:"暂无历史版本"})]})]})})}function PC({memory:e,categories:t,onUpdate:n,onDelete:r}){var R;const[a,s]=y.useState(!1),[o,c]=y.useState(e.content),[d,f]=y.useState(e.category),[m,p]=y.useState(!1),[b,x]=y.useState(!1),[E,N]=y.useState(!1),T=Ij(e.category),S=(R=e.history)==null?void 0:R[e.history.length-1],C=S&&Math.abs(S.importance-e.importance)>.001,A=async()=>{p(!0);try{await n(e.id,{content:o,category:d}),s(!1)}finally{p(!1)}},O=async()=>{x(!1),await r(e.id)};return a?u.jsxs("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/5 p-3 space-y-2",children:[u.jsx("textarea",{value:o,onChange:k=>c(k.target.value),rows:3,className:"w-full resize-y rounded-md border border-line bg-surface px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("select",{value:d,onChange:k=>f(k.target.value),className:"rounded-md border border-line bg-surface px-2 py-1 text-xs text-fg focus:border-blue-500 focus:outline-none",children:t.map(k=>u.jsx("option",{value:k,children:k},k))}),u.jsx("div",{className:"flex-1"}),u.jsx("button",{type:"button",onClick:()=>{s(!1),c(e.content),f(e.category)},className:"rounded-md px-3 py-1 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),u.jsx("button",{type:"button",onClick:()=>void A(),disabled:m||!o.trim(),className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white hover:bg-blue-500 disabled:opacity-40",children:m?"保存中…":"保存"})]})]}):u.jsxs("div",{className:"group/mem rounded-lg border border-line bg-base px-3 py-2.5",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx("span",{className:re("mt-0.5 shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",T.bg,T.text),children:e.category}),u.jsx("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-fg",children:e.content})]}),u.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-[11px] text-fg-5",children:[u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hc,{className:"h-3 w-3"}),C&&S?`${S.importance.toFixed(2)}→${e.importance.toFixed(2)}`:e.importance.toFixed(2)]}),u.jsx("span",{children:"·"}),u.jsx("span",{children:Zu(e.updatedAt)}),e.supersededBy&&u.jsxs(u.Fragment,{children:[u.jsx("span",{children:"·"}),u.jsx("span",{className:"text-amber-400",children:e.supersededBy==="user-deleted"?"已删除":e.supersededBy==="consolidated-out"?"已整理":"已合并"})]}),e.history&&e.history.length>0&&(()=>{const k=e.history[e.history.length-1],D=Rj[k.action];return u.jsxs("button",{type:"button",onClick:()=>N(!0),className:re("rounded px-1.5 py-0.5 text-[10px] font-medium transition-opacity hover:opacity-80",k.action==="update"?"bg-blue-500/10 text-blue-400":k.action==="merge"?"bg-purple-500/10 text-purple-400":k.action==="decay"?"bg-amber-500/10 text-amber-400":k.action==="reinforce"?"bg-emerald-500/10 text-emerald-400":k.action==="manual"?"bg-fg/10 text-fg-3":"bg-green-500/10 text-green-400"),children:[(D==null?void 0:D.label)??k.action," · ",e.history.length,"版"]})})(),u.jsx("div",{className:"flex-1"}),!e.supersededBy&&u.jsx("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover/mem:opacity-100",children:b?u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:()=>void O(),className:"rounded p-1 text-red-400 hover:bg-red-500/10",children:u.jsx(mr,{className:"h-3.5 w-3.5"})}),u.jsx("button",{type:"button",onClick:()=>x(!1),className:"rounded p-1 text-fg-4 hover:bg-elevated",children:u.jsx(ct,{className:"h-3.5 w-3.5"})})]}):u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:()=>s(!0),className:"rounded p-1 text-fg-5 hover:text-fg-3",children:u.jsx(F1,{className:"h-3.5 w-3.5"})}),u.jsx("button",{type:"button",onClick:()=>x(!0),className:"rounded p-1 text-fg-5 hover:text-red-400",children:u.jsx(wi,{className:"h-3.5 w-3.5"})})]})})]}),E&&u.jsx(Tre,{memory:e,onClose:()=>N(!1)})]})}const wre=14400*1e3;function Are(e){if(!e)return"下次:待定";const t=e+wre,n=Date.now();if(t<=n)return"下次:即将运行";const r=t-n,a=Math.floor(r/6e4);if(a<60)return`下次:约 ${a} 分钟后`;const s=Math.floor(a/60);return s<24?`下次:约 ${s} 小时后`:`下次:约 ${Math.floor(s/24)} 天后`}function Cre({stats:e,running:t,onTrigger:n}){if(!e)return null;const r=e.lastActions;return u.jsxs("div",{className:"rounded-lg bg-elevated px-3 py-2 text-[11px] tabular-nums text-fg-5",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[u.jsx("span",{children:e.lastConsolidatedAt?`上次整理:${Zu(e.lastConsolidatedAt)}`:"尚未整理"}),u.jsx("span",{className:"text-fg-6",children:"·"}),u.jsx("span",{children:Are(e.lastConsolidatedAt)}),u.jsx("div",{className:"flex-1"}),u.jsx("button",{type:"button",onClick:n,disabled:t,className:"rounded px-2 py-0.5 text-[10px] font-medium text-fg-4 transition-colors hover:bg-surface hover:text-fg-3 disabled:opacity-40",children:t?"整理中…":"立即整理"})]}),u.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[r&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{children:[r.update," 更新 ",r.merge," 合并 ",r.delete," 清理 ",r.decayed," 降权"]}),u.jsx("span",{className:"text-fg-6",children:"·"})]}),u.jsxs("span",{children:["活跃 ",e.totalActive," 条"]}),u.jsx("span",{className:"text-fg-6",children:"·"}),u.jsxs("span",{children:["衰减中 ",e.stale]})]})]})}function kre({agentId:e}){const t=e.startsWith(GI),[n,r]=y.useState(t?_2:[]),[a,s]=y.useState(!t),[o,c]=y.useState(null),[d,f]=y.useState(!1),[m,p]=y.useState([]),[b,x]=y.useState(!0),[E,N]=y.useState(!1),[T,S]=y.useState(new Set),[C,A]=y.useState(!1),[O,R]=y.useState(null),[k,D]=y.useState(null),[B,j]=y.useState(!1),M=y.useCallback(async()=>{if(t){r(_2),s(!1);return}s(!0);try{const Q=await LI(e,{includeSuperseded:d});r(Q)}catch{r([])}s(!1)},[e,d,t]),z=y.useCallback(()=>{t||l2(e).then(D).catch(()=>D(null))},[e]);y.useEffect(()=>{M()},[M]),y.useEffect(()=>{z()},[z]);const G=async()=>{j(!0);try{await Vz(e)}catch{j(!1);return}const Q=setInterval(()=>{l2(e).then(P=>{D(P),P.lastConsolidatedAt&&(!(k!=null&&k.lastConsolidatedAt)||P.lastConsolidatedAt>k.lastConsolidatedAt)&&(clearInterval(Q),j(!1),M())}).catch(()=>{})},5e3);setTimeout(()=>{clearInterval(Q),j(!1)},3e5)};y.useEffect(()=>{if(!E)return;let Q=!1;return x(!0),$1(e).then(P=>{Q||p(P)}).catch(()=>{Q||p([])}).finally(()=>{Q||x(!1)}),()=>{Q=!0}},[e,E]);const ae=n.filter(Q=>!Q.supersededBy),Z=o?ae.filter(Q=>Q.category===o):ae,W=n.filter(Q=>Q.supersededBy),K=y.useMemo(()=>new Set(n.map(Q=>Q.sessionId).filter(Boolean)),[n]),H=async(Q,P)=>{await qz(e,Q,P),await M()},F=async Q=>{await Gz(e,Q),await M()},Y=Q=>{S(P=>{const he=new Set(P);return he.has(Q)?he.delete(Q):he.add(Q),he})},L=async()=>{if(T.size!==0){A(!0),R(null);try{const he=(await Kz(e,[...T])).results;if(he){const se=he.filter(be=>be.status==="ok"),V=he.filter(be=>be.status!=="ok");se.length>0&&R(`提取成功 ${se.reduce((be,ye)=>be+(ye.actions??0),0)} 条记忆`),V.length>0&&R(be=>(be?be+";":"")+V.map(ye=>ye.error??ye.status).join(";")),se.length>0&&await M()}S(new Set)}catch(Q){R(`请求失败: ${Q instanceof Error?Q.message:String(Q)}`)}A(!1)}},$=y.useMemo(()=>[...new Set(ae.map(P=>P.category))].sort(),[ae]);return u.jsxs("section",{"data-guide":"agent-memory-section",className:"rounded-xl border border-line bg-surface p-5 space-y-4",children:[u.jsx("div",{className:"flex items-center justify-between",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ku,{className:"h-4 w-4 text-purple-400"}),u.jsx("h2",{className:"text-sm font-semibold text-fg",children:"记忆"}),!a&&u.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 text-[10px] tabular-nums text-fg-4",children:Z.length})]})}),u.jsx(Cre,{stats:k,running:B,onTrigger:()=>void G()}),u.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[u.jsx("button",{type:"button",onClick:()=>c(null),className:re("rounded-full px-2.5 py-0.5 text-[11px] font-medium transition-colors",o===null?"bg-fg/10 text-fg":"text-fg-4 hover:text-fg-3"),children:"全部"}),$.map(Q=>{const P=Ij(Q);return u.jsx("button",{type:"button",onClick:()=>c(o===Q?null:Q),className:re("rounded-full px-2.5 py-0.5 text-[11px] font-medium transition-colors",o===Q?re(P.bg,P.text):"text-fg-4 hover:text-fg-3"),children:Q},Q)})]}),a?u.jsx("div",{className:"flex items-center justify-center py-8",children:u.jsx(an,{className:"h-4 w-4 fs-spin text-fg-5"})}):Z.length===0&&W.length===0?u.jsx("div",{className:"py-8 text-center text-xs text-fg-5",children:"暂无记忆。使用此 Agent 完成 Session 后将自动提取。"}):u.jsxs("div",{className:"space-y-1.5",children:[Z.map(Q=>u.jsx(PC,{memory:Q,categories:$,onUpdate:H,onDelete:F},Q.id)),W.length>0&&u.jsxs("div",{className:"pt-1",children:[u.jsxs("button",{type:"button",onClick:()=>f(!d),className:"flex items-center gap-1 text-[11px] text-fg-5 hover:text-fg-3",children:[u.jsx("span",{children:d?"▾":"▸"}),"已合并/已删除 (",W.length,")"]}),d&&u.jsx("div",{className:"mt-1.5 space-y-1.5 opacity-60",children:W.map(Q=>u.jsx(PC,{memory:Q,categories:$,onUpdate:H,onDelete:F},Q.id))})]})]}),u.jsxs("div",{className:"border-t border-line pt-3",children:[u.jsxs("button",{type:"button",onClick:()=>N(!E),className:"flex items-center gap-1.5 text-xs font-medium text-fg-4 hover:text-fg-3",children:[u.jsx(_g,{className:"h-3.5 w-3.5"}),u.jsxs("span",{children:[E?"▾":"▸"," 从 Session 提取记忆"]})]}),E&&u.jsx("div",{className:"mt-2 space-y-1.5",children:b?u.jsx("div",{className:"flex items-center justify-center py-4",children:u.jsx(an,{className:"h-4 w-4 fs-spin text-fg-5"})}):m.length===0?u.jsx("p",{className:"py-4 text-center text-xs text-fg-5",children:"暂无 Session 记录。"}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:m.map(Q=>{const P=K.has(Q.id);return u.jsxs("label",{className:re("flex cursor-pointer items-center gap-2.5 rounded-md border px-3 py-2 transition-colors",T.has(Q.id)?"border-purple-500/30 bg-purple-500/5":"border-line bg-base hover:bg-elevated/60"),children:[u.jsx("input",{type:"checkbox",checked:T.has(Q.id),onChange:()=>Y(Q.id),className:"h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-line accent-purple-500"}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate text-xs text-fg",children:Q.title||Q.id.slice(-8)}),u.jsx("span",{className:"text-[11px] text-fg-5",children:Zu(Q.timeCreated)})]}),u.jsx("span",{className:re("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium",P?"bg-green-500/10 text-green-400":"bg-elevated text-fg-5"),children:P?"已提取":"未提取"})]},Q.id)})}),T.size>0&&u.jsxs("button",{type:"button",onClick:()=>void L(),disabled:C,className:"flex w-full items-center justify-center gap-1.5 rounded-lg bg-purple-600 py-2 text-xs font-medium text-white transition-colors hover:bg-purple-500 disabled:opacity-40",children:[C?u.jsx(an,{className:"h-3.5 w-3.5 fs-spin"}):u.jsx(Ku,{className:"h-3.5 w-3.5"}),C?"提取中…":`提取选中 Session 的记忆 (${T.size})`]}),O&&u.jsx("p",{className:re("mt-1.5 rounded-md px-3 py-1.5 text-xs",O.includes("成功")?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"),children:O})]})})]})]})}function Ore({agentId:e}){const[t,n]=y.useState([]),[r,a]=y.useState(!0);return y.useEffect(()=>{let s=!1;return $1(e).then(o=>{s||n(o)}).catch(()=>{s||n([])}).finally(()=>{s||a(!1)}),()=>{s=!0}},[e]),u.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(_g,{className:"h-4 w-4 text-fg-4"}),u.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Session 历史"}),!r&&u.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 text-[10px] tabular-nums text-fg-4",children:t.length})]}),u.jsx("div",{className:"mt-3",children:r?u.jsx("div",{className:"flex items-center justify-center py-8",children:u.jsx(an,{className:"h-4 w-4 fs-spin text-fg-5"})}):t.length===0?u.jsx("p",{className:"py-8 text-center text-xs text-fg-5",children:"暂无 Session 记录。"}):u.jsx("div",{className:"space-y-1",children:t.map(s=>u.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-line bg-base px-4 py-2.5",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate text-xs font-medium text-fg",children:s.title||s.id.slice(-8)}),u.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-fg-5",children:[u.jsx("span",{children:Zu(s.timeCreated)}),s.cost>0&&u.jsxs(u.Fragment,{children:[u.jsx("span",{children:"·"}),u.jsxs("span",{children:["$",s.cost.toFixed(4)]})]}),(s.tokensInput>0||s.tokensOutput>0)&&u.jsxs(u.Fragment,{children:[u.jsx("span",{children:"·"}),u.jsxs("span",{children:[Math.round((s.tokensInput+s.tokensOutput)/1e3),"K tokens"]})]})]})]}),s.completedAt?u.jsx("span",{className:"shrink-0 rounded-full bg-green-500/10 px-2 py-0.5 text-[10px] font-medium text-green-400",children:"完成"}):u.jsx("span",{className:"shrink-0 rounded-full bg-elevated px-2 py-0.5 text-[10px] font-medium text-fg-5",children:"进行中"})]},s.id))})})]})}function Ire({agent:e,fragments:t,onSave:n}){const r=Fe(Y=>Y.activeRepoId),[a,s]=y.useState(!1),[o,c]=y.useState(e.name),[d,f]=y.useState(e.description??""),[m,p]=y.useState(e.baseAgent),[b,x]=y.useState(e.model??""),[E,N]=y.useState(e.variant??""),[T,S]=y.useState(e.memoryModel??""),[C,A]=y.useState(e.systemPrompt),[O,R]=y.useState(!1),[k,D]=y.useState(!1),[B,j]=y.useState([]);y.useEffect(()=>{if(!r){j([]);return}let Y=!1;return(async()=>{try{const[L,$]=await Promise.all([xl(),Df(r)]);if(Y)return;const Q=L[Nre],P=Q?JSON.parse(Q):[],he=P.length>0?$.filter(se=>P.includes(se.id)):$;j(he.length>0?he:$)}catch{Y||j([])}})(),()=>{Y=!0}},[r]);const[M,z]=y.useState(()=>{const Y=e.fragments.map(P=>P.id),L=e.systemPromptPosition??-1,$=L>=0&&L<=Y.length?L:Y.length,Q=[...Y];return Q.splice($,0,Go),Q}),G=Y=>{z(L=>{if(L.includes(Y))return L.filter(P=>P!==Y);const $=L.indexOf(Go),Q=[...L];return Q.splice($>=0?$:Q.length,0,Y),Q})},ae=(Y,L)=>{const $=Y+L;$<0||$>=M.length||z(Q=>{const P=[...Q];return[P[Y],P[$]]=[P[$],P[Y]],P})},Z=M.filter(Y=>Y!==Go),W=(()=>{const Y=M.indexOf(Go);return Y<0?-1:M.slice(0,Y).filter(L=>L!==Go).length})(),K=M.map(Y=>{var L;return Y===Go?C:(L=t.find($=>$.id===Y))==null?void 0:L.content}).filter(Boolean).join(`
567
+ `),Z=async()=>{if(!(!s.trim()||!f)){O(!0);try{await n({name:s.trim(),description:c.trim()||void 0,baseAgent:f,model:p.trim()||void 0,variant:x.trim()||void 0,systemPrompt:N,systemPromptPosition:G,fragmentIds:z})}finally{O(!1)}}};return u.jsxs("div",{className:"space-y-3 rounded-xl border border-line bg-surface p-5",children:[u.jsxs("div",{className:"flex gap-3",children:[u.jsxs("label",{className:"flex-1",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"名称"}),u.jsx("input",{type:"text",value:s,onChange:W=>o(W.target.value),placeholder:"代码审查员",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"})]}),u.jsxs("label",{className:"w-36",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Base Agent"}),u.jsx("select",{value:f,onChange:W=>m(W.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:hre.map(W=>u.jsx("option",{value:W,children:W},W))})]})]}),u.jsxs("label",{className:"block",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"描述(可选)"}),u.jsx("input",{type:"text",value:c,onChange:W=>d(W.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"})]}),u.jsxs("div",{className:"flex gap-3",children:[u.jsxs("div",{className:"flex-1",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"模型(可选)"}),u.jsxs("select",{value:p,onChange:W=>b(W.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:[u.jsx("option",{value:"",children:"默认模型"}),R.map(W=>u.jsx("option",{value:W.id,children:W.name||W.id},W.id))]}),R.length===0&&u.jsx("p",{className:"mt-1 text-[11px] text-fg-5",children:"在设置的「模型」中勾选常用模型后可选择。"})]}),u.jsxs("div",{className:"w-28",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"Variant"}),u.jsxs("select",{value:x,onChange:W=>E(W.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:[u.jsx("option",{value:"",children:"默认"}),u.jsx("option",{value:"max",children:"max"}),u.jsx("option",{value:"high",children:"high"})]})]})]}),u.jsxs("div",{children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"提示词组合"}),u.jsx("p",{className:"mt-0.5 text-[11px] text-fg-5",children:"排序片段与补充指令的拼接顺序。"}),u.jsxs("div",{className:"mt-1.5 space-y-1",children:[D.map((W,K)=>{if(W===qo)return u.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2 py-1",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("button",{type:"button",onClick:()=>M(K,-1),disabled:K===0,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▲"}),u.jsx("button",{type:"button",onClick:()=>M(K,1),disabled:K===D.length-1,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▼"})]}),u.jsx("span",{className:"flex-1 truncate text-xs font-medium text-amber-400",children:"✎ 补充指令"})]},W);const H=t.find(F=>F.id===W);return H?u.jsxs("div",{className:"flex items-center gap-2 rounded border border-blue-500/30 bg-blue-500/5 px-2 py-1",children:[u.jsxs("div",{className:"flex flex-col",children:[u.jsx("button",{type:"button",onClick:()=>M(K,-1),disabled:K===0,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▲"}),u.jsx("button",{type:"button",onClick:()=>M(K,1),disabled:K===D.length-1,className:"text-[10px] leading-none text-fg-5 hover:text-fg-2 disabled:opacity-30",children:"▼"})]}),u.jsx("span",{className:"flex-1 truncate text-xs text-fg",children:H.name}),u.jsx("button",{type:"button",onClick:()=>j(W),className:"text-fg-5 hover:text-red-400",children:u.jsx(ct,{className:"h-3 w-3"})})]},W):null}),t.filter(W=>!z.includes(W.id)).length>0&&u.jsxs("select",{value:"",onChange:W=>{W.target.value&&j(W.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:[u.jsx("option",{value:"",children:"+ 添加片段…"}),t.filter(W=>!z.includes(W.id)).map(W=>u.jsx("option",{value:W.id,children:W.name},W.id))]})]})]}),u.jsxs("label",{className:"block",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"补充指令内容"}),u.jsx("textarea",{value:N,onChange:W=>T(W.target.value),rows:3,placeholder:"agent 级别的补充指令…",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 placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"})]}),(z.length>0||N)&&u.jsxs("div",{children:[u.jsxs("button",{type:"button",onClick:()=>C(!S),className:"flex items-center gap-1 text-xs font-medium text-fg-4 hover:text-fg-3",children:[u.jsx("span",{children:S?"▾":"▸"})," 预览最终提示词"]}),S&&u.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:ae||"(空)"})]}),u.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[u.jsx("button",{type:"button",onClick:r,className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),u.jsx("button",{type:"button",onClick:()=>void Z(),disabled:A||!s.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:A?"保存中…":e?"更新":"创建"})]})]})}function xre({fragment:e,onEdit:t,onDelete:n}){const[r,a]=y.useState(!1);return u.jsxs("div",{className:"group flex items-center gap-3 rounded-lg border border-line bg-base px-3 py-2",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"text-xs font-medium text-fg",children:e.name}),e.content&&u.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-fg-5",children:e.content})]}),u.jsx("div",{className:"flex items-center gap-1",children:r?u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:n,className:"rounded p-1 text-red-400 hover:bg-red-500/10",children:u.jsx(mr,{className:"h-3.5 w-3.5"})}),u.jsx("button",{type:"button",onClick:()=>a(!1),className:"rounded p-1 text-fg-4 hover:bg-elevated",children:u.jsx(ct,{className:"h-3.5 w-3.5"})})]}):u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:t,className:"rounded p-1 text-fg-5 opacity-0 transition-opacity hover:text-fg-3 group-hover:opacity-100",children:u.jsx(F1,{className:"h-3.5 w-3.5"})}),u.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded p-1 text-fg-5 opacity-0 transition-opacity hover:text-red-400 group-hover:opacity-100",children:u.jsx(wi,{className:"h-3.5 w-3.5"})})]})})]})}function jC({initial:e,onSave:t,onCancel:n}){const[r,a]=y.useState((e==null?void 0:e.name)??""),[s,o]=y.useState((e==null?void 0:e.content)??""),[c,d]=y.useState(!1),f=async()=>{if(r.trim()){d(!0);try{await t({name:r.trim(),content:s})}finally{d(!1)}}};return u.jsxs("div",{className:"space-y-2 rounded-lg border border-line bg-base p-3",children:[u.jsx("input",{type:"text",value:r,onChange:m=>a(m.target.value),placeholder:"片段名称",className:"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"}),u.jsx("textarea",{value:s,onChange:m=>o(m.target.value),rows:3,placeholder:"提示词内容…",className:"w-full resize-y rounded-md border border-line bg-surface px-3 py-2 font-mono text-sm leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx("button",{type:"button",onClick:n,className:"rounded-md px-3 py-1 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),u.jsx("button",{type:"button",onClick:()=>void f(),disabled:c||!r.trim(),className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white hover:bg-blue-500 disabled:opacity-40",children:c?"保存中…":e?"更新":"创建"})]})]})}function yre({onImported:e,onCancel:t}){const[n,r]=y.useState(""),[a,s]=y.useState(!1),[o,c]=y.useState(null),d=y.useRef(null),f=async p=>{c(null);let b;try{b=JSON.parse(p)}catch{c("JSON 格式无效");return}if(b.type!=="fourth-spark-custom-agent"||!b.agent){c("不是有效的 Custom Agent 导出文件");return}s(!0);try{await Yz(b),e()}catch(x){c(x instanceof Error?x.message:String(x))}finally{s(!1)}},m=p=>{var E;const b=(E=p.target.files)==null?void 0:E[0];if(!b)return;const x=new FileReader;x.onload=()=>{const N=x.result;r(N),f(N)},x.readAsText(b)};return u.jsxs("div",{className:"space-y-3 rounded-xl border border-line bg-surface p-5",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx("span",{className:"text-xs font-medium text-fg-3",children:"导入 Custom Agent"}),u.jsx("button",{type:"button",onClick:t,className:"rounded p-1 text-fg-5 hover:text-fg-3",children:u.jsx(ct,{className:"h-3.5 w-3.5"})})]}),u.jsx("input",{ref:d,type:"file",accept:".json",onChange:m,className:"hidden"}),u.jsxs("button",{type:"button",onClick:()=>{var p;return(p=d.current)==null?void 0:p.click()},className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-line py-2.5 text-xs text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-3",children:[u.jsx(AI,{className:"h-3.5 w-3.5"})," 上传 JSON 文件"]}),u.jsx("textarea",{value:n,onChange:p=>r(p.target.value),rows:4,placeholder:"或粘贴 JSON 内容…",className:"w-full resize-y rounded-md border border-line bg-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"}),o&&u.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-red-500/10 px-3 py-2 text-xs text-red-400",children:[u.jsx(Cn,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),u.jsx("span",{children:o})]}),u.jsxs("div",{className:"flex justify-end gap-2",children:[u.jsx("button",{type:"button",onClick:t,className:"rounded-md px-3 py-1.5 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),u.jsx("button",{type:"button",onClick:()=>void f(n),disabled:a||!n.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:a?"导入中…":"导入"})]})]})}function vre(){const e=$n(),t=Fe(Br),n=Fe(Z=>Z.activeRepoId),[r,a]=y.useState([]),[s,o]=y.useState([]),[c,d]=y.useState(!0),[f,m]=y.useState(!1),[p,b]=y.useState(!1),[x,E]=y.useState(null),[N,T]=y.useState(!1),[S,C]=y.useState(!1),[A,O]=y.useState({}),[R,k]=y.useState({}),D=y.useCallback(()=>{const Z=n?PI(n):jI();Promise.all([Z,BI()]).then(([W,K])=>{a(W),o(K),d(!1)}).catch(()=>d(!1))},[n]);y.useEffect(()=>{d(!0),D()},[D]),y.useEffect(()=>{if(r.length===0)return;const Z=r.filter(W=>W.isSystem<2);for(const W of Z)LI(W.id).then(K=>{O(H=>({...H,[W.id]:K.filter(F=>!F.supersededBy).length}))}).catch(()=>{}),$1(W.id).then(K=>{k(H=>({...H,[W.id]:K.length}))}).catch(()=>{})},[r]);const B=r.filter(Z=>Z.isSystem<2),j=async Z=>{n?await Wz(n,Z):await Hz(Z),m(!1),D(),Pa.getState().loadAgents()},M=async Z=>{await DI(Z),a(W=>W.filter(K=>K.id!==Z)),Pa.getState().loadAgents()},z=async Z=>{await Xz(Z),b(!1),D()},G=async Z=>{x&&(await Qz(x.id,Z),E(null),D())},ae=async Z=>{await Zz(Z),o(W=>W.filter(K=>K.id!==Z))};return n?u.jsx("div",{className:"flex-1 overflow-y-auto",children:u.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 p-6",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{children:[u.jsx("h1",{className:"text-lg font-bold text-fg",children:"Agents"}),u.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"组合 base agent + 模型 + 提示词片段,创建 Session 时选择。"})]}),u.jsxs("div",{"data-guide":"agents-header",className:"flex items-center gap-2",children:[u.jsxs("button",{type:"button",onClick:()=>{T(!0),m(!1)},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",children:[u.jsx(AI,{className:"h-3.5 w-3.5"})," 导入"]}),u.jsxs("button",{type:"button",onClick:()=>{m(!0),T(!1)},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",children:[u.jsx(ta,{className:"h-3.5 w-3.5"})," 创建"]})]})]}),f&&u.jsx(bre,{availableFragments:s,onSave:j,onCancel:()=>m(!1)}),N&&u.jsx(yre,{onImported:()=>{T(!1),D(),Pa.getState().loadAgents()},onCancel:()=>T(!1)}),c?u.jsxs("div",{className:"flex flex-col items-center gap-2.5 py-16 text-fg-5",children:[u.jsx(an,{className:"h-5 w-5 fs-spin"}),u.jsx("p",{className:"text-xs",children:"加载中…"})]}):B.length===0&&!f?u.jsxs("div",{className:"flex flex-col items-center gap-3 py-16 text-fg-5",children:[u.jsx(Ku,{className:"h-8 w-8 text-fg-6"}),u.jsx("p",{className:"text-sm",children:"还没有 Agent"}),u.jsx("p",{className:"text-xs text-fg-5",children:"点击上方「创建」开始。"})]}):u.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:B.map(Z=>u.jsx("div",{className:"group",children:u.jsx(gre,{agent:Z,memoryCount:A[Z.id]??0,sessionCount:R[Z.id]??0,onClick:()=>e(`/${encodeURIComponent(t??"")}/agents/${Z.id}`),onDelete:()=>void M(Z.id)})},Z.id))}),u.jsxs("section",{"data-guide":"agents-fragments",className:"rounded-xl border border-line bg-surface",children:[u.jsxs("button",{type:"button",onClick:()=>C(!S),className:"flex w-full items-center justify-between px-5 py-4 text-left",children:[u.jsxs("div",{children:[u.jsx("h2",{className:"text-sm font-semibold text-fg",children:"提示词片段"}),u.jsx("p",{className:"mt-0.5 text-xs text-fg-4",children:"可复用的提示词模块,可在多个 Agent 间共享。"})]}),u.jsx(Nr,{className:re("h-4 w-4 shrink-0 text-fg-4 transition-transform",S&&"rotate-180")})]}),S&&u.jsx("div",{className:"border-t border-line px-5 pb-5 pt-3",children:u.jsxs("div",{className:"space-y-1.5",children:[s.map(Z=>(x==null?void 0:x.id)===Z.id?u.jsx(jC,{initial:Z,onSave:G,onCancel:()=>E(null)},Z.id):u.jsx(xre,{fragment:Z,onEdit:()=>E(Z),onDelete:()=>void ae(Z.id)},Z.id)),p?u.jsx(jC,{onSave:z,onCancel:()=>b(!1)}):u.jsxs("button",{type:"button",onClick:()=>b(!0),className:"flex w-full items-center justify-center gap-1.5 rounded-lg border border-dashed border-line py-2 text-xs text-fg-4 transition-colors hover:border-fg-5 hover:text-fg-3",children:[u.jsx(ta,{className:"h-3.5 w-3.5"})," 添加片段"]})]})})]})]})}):u.jsx("div",{className:"flex flex-1 items-center justify-center p-8",children:u.jsx("p",{className:"text-sm text-fg-4",children:"请先在顶部选择一个仓库。"})})}const Ere=["Sisyphus - ultraworker","Prometheus - Plan Builder","Atlas - Plan Executor"],Nre="pinned_models",Go="__system_prompt__",DC=[{bg:"bg-blue-500/15",text:"text-blue-500"},{bg:"bg-purple-500/15",text:"text-purple-500"},{bg:"bg-emerald-500/15",text:"text-emerald-500"},{bg:"bg-amber-500/15",text:"text-amber-500"},{bg:"bg-rose-500/15",text:"text-rose-500"},{bg:"bg-cyan-500/15",text:"text-cyan-500"},{bg:"bg-indigo-500/15",text:"text-indigo-500"},{bg:"bg-orange-500/15",text:"text-orange-500"}];function _re(e){const t=e.trim(),n=t.charCodeAt(0)||0;return{...DC[n%DC.length],initial:(t.charAt(0)||"?").toUpperCase()}}const LC=[{bg:"bg-blue-500/10",text:"text-blue-400"},{bg:"bg-amber-500/10",text:"text-amber-400"},{bg:"bg-green-500/10",text:"text-green-400"},{bg:"bg-purple-500/10",text:"text-purple-400"},{bg:"bg-cyan-500/10",text:"text-cyan-400"},{bg:"bg-rose-500/10",text:"text-rose-400"},{bg:"bg-indigo-500/10",text:"text-indigo-400"},{bg:"bg-orange-500/10",text:"text-orange-400"}],Sre={bg:"bg-elevated",text:"text-fg-4"};function Ij(e){if(e==="general")return Sre;let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return LC[Math.abs(t)%LC.length]}function Zu(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"刚刚";if(n<60)return`${n} 分钟前`;const r=Math.floor(n/60);if(r<24)return`${r} 小时前`;const a=Math.floor(r/24);return a<30?`${a} 天前`:`${Math.floor(a/30)} 个月前`}const Rj={create:{label:"首次提取",color:"text-green-400"},update:{label:"重写",color:"text-blue-400"},merge:{label:"合并",color:"text-purple-400"},decay:{label:"衰减",color:"text-amber-400"},reinforce:{label:"强化",color:"text-emerald-400"},manual:{label:"手动编辑",color:"text-fg-3"}};function Tre({memory:e,onClose:t}){const n=[...e.history??[]].reverse();return u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:t,children:u.jsxs("div",{className:"mx-4 max-h-[80vh] w-full max-w-lg overflow-y-auto rounded-xl border border-line bg-surface p-5 shadow-xl",onClick:r=>r.stopPropagation(),children:[u.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[u.jsxs("h3",{className:"text-sm font-semibold text-fg",children:["版本历史 (",n.length+1," 个版本)"]}),u.jsx("button",{type:"button",onClick:t,className:"rounded p-1 text-fg-4 hover:text-fg-3",children:u.jsx(ct,{className:"h-4 w-4"})})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{className:"rounded-lg border border-blue-500/20 bg-blue-500/5 p-3",children:[u.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[10px]",children:[u.jsx("span",{className:"font-medium text-blue-400",children:"当前版本"}),u.jsx("span",{className:"text-fg-5",children:Zu(e.updatedAt)}),u.jsxs("span",{className:"text-fg-6",children:["⚡ ",e.importance.toFixed(2)]})]}),u.jsx("p",{className:"text-xs leading-relaxed text-fg",children:e.content})]}),n.map((r,a)=>{const s=Rj[r.action]??{label:r.action,color:"text-fg-4"};return u.jsxs("div",{className:"rounded-lg border border-line bg-base p-3",children:[u.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[10px]",children:[u.jsx("span",{className:re("font-medium",s.color),children:s.label}),u.jsx("span",{className:"text-fg-5",children:Zu(r.ts)}),u.jsxs("span",{className:"text-fg-6",children:["⚡ ",r.importance.toFixed(2)]}),r.source&&u.jsxs("span",{className:"text-fg-6",children:["· ",r.source]})]}),u.jsx("p",{className:"text-xs leading-relaxed text-fg-4",children:r.content})]},a)}),n.length===0&&u.jsx("div",{className:"py-4 text-center text-xs text-fg-5",children:"暂无历史版本"})]})]})})}function PC({memory:e,categories:t,onUpdate:n,onDelete:r}){var R;const[a,s]=y.useState(!1),[o,c]=y.useState(e.content),[d,f]=y.useState(e.category),[m,p]=y.useState(!1),[b,x]=y.useState(!1),[E,N]=y.useState(!1),T=Ij(e.category),S=(R=e.history)==null?void 0:R[e.history.length-1],C=S&&Math.abs(S.importance-e.importance)>.001,A=async()=>{p(!0);try{await n(e.id,{content:o,category:d}),s(!1)}finally{p(!1)}},O=async()=>{x(!1),await r(e.id)};return a?u.jsxs("div",{className:"rounded-lg border border-blue-500/30 bg-blue-500/5 p-3 space-y-2",children:[u.jsx("textarea",{value:o,onChange:k=>c(k.target.value),rows:3,className:"w-full resize-y rounded-md border border-line bg-surface px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-6 focus:border-blue-500 focus:outline-none"}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("select",{value:d,onChange:k=>f(k.target.value),className:"rounded-md border border-line bg-surface px-2 py-1 text-xs text-fg focus:border-blue-500 focus:outline-none",children:t.map(k=>u.jsx("option",{value:k,children:k},k))}),u.jsx("div",{className:"flex-1"}),u.jsx("button",{type:"button",onClick:()=>{s(!1),c(e.content),f(e.category)},className:"rounded-md px-3 py-1 text-xs text-fg-4 hover:bg-elevated",children:"取消"}),u.jsx("button",{type:"button",onClick:()=>void A(),disabled:m||!o.trim(),className:"rounded-md bg-blue-600 px-3 py-1 text-xs font-medium text-white hover:bg-blue-500 disabled:opacity-40",children:m?"保存中…":"保存"})]})]}):u.jsxs("div",{className:"group/mem rounded-lg border border-line bg-base px-3 py-2.5",children:[u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx("span",{className:re("mt-0.5 shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",T.bg,T.text),children:e.category}),u.jsx("p",{className:"min-w-0 flex-1 text-xs leading-relaxed text-fg",children:e.content})]}),u.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-[11px] text-fg-5",children:[u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hc,{className:"h-3 w-3"}),C&&S?`${S.importance.toFixed(2)}→${e.importance.toFixed(2)}`:e.importance.toFixed(2)]}),u.jsx("span",{children:"·"}),u.jsx("span",{children:Zu(e.updatedAt)}),e.supersededBy&&u.jsxs(u.Fragment,{children:[u.jsx("span",{children:"·"}),u.jsx("span",{className:"text-amber-400",children:e.supersededBy==="user-deleted"?"已删除":e.supersededBy==="consolidated-out"?"已整理":"已合并"})]}),e.history&&e.history.length>0&&(()=>{const k=e.history[e.history.length-1],D=Rj[k.action];return u.jsxs("button",{type:"button",onClick:()=>N(!0),"data-guide":e.id==="guide-mem-1"?"agent-memory-version":void 0,className:re("rounded px-1.5 py-0.5 text-[10px] font-medium transition-opacity hover:opacity-80",k.action==="update"?"bg-blue-500/10 text-blue-400":k.action==="merge"?"bg-purple-500/10 text-purple-400":k.action==="decay"?"bg-amber-500/10 text-amber-400":k.action==="reinforce"?"bg-emerald-500/10 text-emerald-400":k.action==="manual"?"bg-fg/10 text-fg-3":"bg-green-500/10 text-green-400"),children:[(D==null?void 0:D.label)??k.action," · ",e.history.length,"版"]})})(),u.jsx("div",{className:"flex-1"}),!e.supersededBy&&u.jsx("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover/mem:opacity-100",children:b?u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:()=>void O(),className:"rounded p-1 text-red-400 hover:bg-red-500/10",children:u.jsx(mr,{className:"h-3.5 w-3.5"})}),u.jsx("button",{type:"button",onClick:()=>x(!1),className:"rounded p-1 text-fg-4 hover:bg-elevated",children:u.jsx(ct,{className:"h-3.5 w-3.5"})})]}):u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",onClick:()=>s(!0),className:"rounded p-1 text-fg-5 hover:text-fg-3",children:u.jsx(F1,{className:"h-3.5 w-3.5"})}),u.jsx("button",{type:"button",onClick:()=>x(!0),className:"rounded p-1 text-fg-5 hover:text-red-400",children:u.jsx(wi,{className:"h-3.5 w-3.5"})})]})})]}),E&&u.jsx(Tre,{memory:e,onClose:()=>N(!1)})]})}const wre=14400*1e3;function Are(e){if(!e)return"下次:待定";const t=e+wre,n=Date.now();if(t<=n)return"下次:即将运行";const r=t-n,a=Math.floor(r/6e4);if(a<60)return`下次:约 ${a} 分钟后`;const s=Math.floor(a/60);return s<24?`下次:约 ${s} 小时后`:`下次:约 ${Math.floor(s/24)} 天后`}function Cre({stats:e,running:t,onTrigger:n}){if(!e)return null;const r=e.lastActions;return u.jsxs("div",{className:"rounded-lg bg-elevated px-3 py-2 text-[11px] tabular-nums text-fg-5",children:[u.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[u.jsx("span",{children:e.lastConsolidatedAt?`上次整理:${Zu(e.lastConsolidatedAt)}`:"尚未整理"}),u.jsx("span",{className:"text-fg-6",children:"·"}),u.jsx("span",{children:Are(e.lastConsolidatedAt)}),u.jsx("div",{className:"flex-1"}),u.jsx("button",{type:"button",onClick:n,disabled:t,className:"rounded px-2 py-0.5 text-[10px] font-medium text-fg-4 transition-colors hover:bg-surface hover:text-fg-3 disabled:opacity-40",children:t?"整理中…":"立即整理"})]}),u.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:[r&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{children:[r.update," 更新 ",r.merge," 合并 ",r.delete," 清理 ",r.decayed," 降权"]}),u.jsx("span",{className:"text-fg-6",children:"·"})]}),u.jsxs("span",{children:["活跃 ",e.totalActive," 条"]}),u.jsx("span",{className:"text-fg-6",children:"·"}),u.jsxs("span",{children:["衰减中 ",e.stale]})]})]})}function kre({agentId:e}){const t=e.startsWith(GI),[n,r]=y.useState(t?_2:[]),[a,s]=y.useState(!t),[o,c]=y.useState(null),[d,f]=y.useState(!1),[m,p]=y.useState([]),[b,x]=y.useState(!0),[E,N]=y.useState(!1),[T,S]=y.useState(new Set),[C,A]=y.useState(!1),[O,R]=y.useState(null),[k,D]=y.useState(null),[B,j]=y.useState(!1),M=y.useCallback(async()=>{if(t){r(_2),s(!1);return}s(!0);try{const Q=await LI(e,{includeSuperseded:d});r(Q)}catch{r([])}s(!1)},[e,d,t]),z=y.useCallback(()=>{t||l2(e).then(D).catch(()=>D(null))},[e]);y.useEffect(()=>{M()},[M]),y.useEffect(()=>{z()},[z]);const G=async()=>{j(!0);try{await Vz(e)}catch{j(!1);return}const Q=setInterval(()=>{l2(e).then(P=>{D(P),P.lastConsolidatedAt&&(!(k!=null&&k.lastConsolidatedAt)||P.lastConsolidatedAt>k.lastConsolidatedAt)&&(clearInterval(Q),j(!1),M())}).catch(()=>{})},5e3);setTimeout(()=>{clearInterval(Q),j(!1)},3e5)};y.useEffect(()=>{if(!E)return;let Q=!1;return x(!0),$1(e).then(P=>{Q||p(P)}).catch(()=>{Q||p([])}).finally(()=>{Q||x(!1)}),()=>{Q=!0}},[e,E]);const ae=n.filter(Q=>!Q.supersededBy),Z=o?ae.filter(Q=>Q.category===o):ae,W=n.filter(Q=>Q.supersededBy),K=y.useMemo(()=>new Set(n.map(Q=>Q.sessionId).filter(Boolean)),[n]),H=async(Q,P)=>{await qz(e,Q,P),await M()},F=async Q=>{await Gz(e,Q),await M()},Y=Q=>{S(P=>{const he=new Set(P);return he.has(Q)?he.delete(Q):he.add(Q),he})},L=async()=>{if(T.size!==0){A(!0),R(null);try{const he=(await Kz(e,[...T])).results;if(he){const se=he.filter(be=>be.status==="ok"),V=he.filter(be=>be.status!=="ok");se.length>0&&R(`提取成功 ${se.reduce((be,ye)=>be+(ye.actions??0),0)} 条记忆`),V.length>0&&R(be=>(be?be+";":"")+V.map(ye=>ye.error??ye.status).join(";")),se.length>0&&await M()}S(new Set)}catch(Q){R(`请求失败: ${Q instanceof Error?Q.message:String(Q)}`)}A(!1)}},$=y.useMemo(()=>[...new Set(ae.map(P=>P.category))].sort(),[ae]);return u.jsxs("section",{"data-guide":"agent-memory-section",className:"rounded-xl border border-line bg-surface p-5 space-y-4",children:[u.jsx("div",{className:"flex items-center justify-between",children:u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Ku,{className:"h-4 w-4 text-purple-400"}),u.jsx("h2",{className:"text-sm font-semibold text-fg",children:"记忆"}),!a&&u.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 text-[10px] tabular-nums text-fg-4",children:Z.length})]})}),u.jsx(Cre,{stats:k,running:B,onTrigger:()=>void G()}),u.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[u.jsx("button",{type:"button",onClick:()=>c(null),className:re("rounded-full px-2.5 py-0.5 text-[11px] font-medium transition-colors",o===null?"bg-fg/10 text-fg":"text-fg-4 hover:text-fg-3"),children:"全部"}),$.map(Q=>{const P=Ij(Q);return u.jsx("button",{type:"button",onClick:()=>c(o===Q?null:Q),className:re("rounded-full px-2.5 py-0.5 text-[11px] font-medium transition-colors",o===Q?re(P.bg,P.text):"text-fg-4 hover:text-fg-3"),children:Q},Q)})]}),a?u.jsx("div",{className:"flex items-center justify-center py-8",children:u.jsx(an,{className:"h-4 w-4 fs-spin text-fg-5"})}):Z.length===0&&W.length===0?u.jsx("div",{className:"py-8 text-center text-xs text-fg-5",children:"暂无记忆。使用此 Agent 完成 Session 后将自动提取。"}):u.jsxs("div",{className:"space-y-1.5",children:[Z.map(Q=>u.jsx(PC,{memory:Q,categories:$,onUpdate:H,onDelete:F},Q.id)),W.length>0&&u.jsxs("div",{className:"pt-1",children:[u.jsxs("button",{type:"button",onClick:()=>f(!d),className:"flex items-center gap-1 text-[11px] text-fg-5 hover:text-fg-3",children:[u.jsx("span",{children:d?"▾":"▸"}),"已合并/已删除 (",W.length,")"]}),d&&u.jsx("div",{className:"mt-1.5 space-y-1.5 opacity-60",children:W.map(Q=>u.jsx(PC,{memory:Q,categories:$,onUpdate:H,onDelete:F},Q.id))})]})]}),u.jsxs("div",{className:"border-t border-line pt-3",children:[u.jsxs("button",{type:"button",onClick:()=>N(!E),className:"flex items-center gap-1.5 text-xs font-medium text-fg-4 hover:text-fg-3",children:[u.jsx(_g,{className:"h-3.5 w-3.5"}),u.jsxs("span",{children:[E?"▾":"▸"," 从 Session 提取记忆"]})]}),E&&u.jsx("div",{className:"mt-2 space-y-1.5",children:b?u.jsx("div",{className:"flex items-center justify-center py-4",children:u.jsx(an,{className:"h-4 w-4 fs-spin text-fg-5"})}):m.length===0?u.jsx("p",{className:"py-4 text-center text-xs text-fg-5",children:"暂无 Session 记录。"}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"max-h-64 space-y-1 overflow-y-auto",children:m.map(Q=>{const P=K.has(Q.id);return u.jsxs("label",{className:re("flex cursor-pointer items-center gap-2.5 rounded-md border px-3 py-2 transition-colors",T.has(Q.id)?"border-purple-500/30 bg-purple-500/5":"border-line bg-base hover:bg-elevated/60"),children:[u.jsx("input",{type:"checkbox",checked:T.has(Q.id),onChange:()=>Y(Q.id),className:"h-3.5 w-3.5 shrink-0 cursor-pointer rounded border-line accent-purple-500"}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate text-xs text-fg",children:Q.title||Q.id.slice(-8)}),u.jsx("span",{className:"text-[11px] text-fg-5",children:Zu(Q.timeCreated)})]}),u.jsx("span",{className:re("shrink-0 rounded-full px-2 py-0.5 text-[10px] font-medium",P?"bg-green-500/10 text-green-400":"bg-elevated text-fg-5"),children:P?"已提取":"未提取"})]},Q.id)})}),T.size>0&&u.jsxs("button",{type:"button",onClick:()=>void L(),disabled:C,className:"flex w-full items-center justify-center gap-1.5 rounded-lg bg-purple-600 py-2 text-xs font-medium text-white transition-colors hover:bg-purple-500 disabled:opacity-40",children:[C?u.jsx(an,{className:"h-3.5 w-3.5 fs-spin"}):u.jsx(Ku,{className:"h-3.5 w-3.5"}),C?"提取中…":`提取选中 Session 的记忆 (${T.size})`]}),O&&u.jsx("p",{className:re("mt-1.5 rounded-md px-3 py-1.5 text-xs",O.includes("成功")?"bg-green-500/10 text-green-400":"bg-red-500/10 text-red-400"),children:O})]})})]})]})}function Ore({agentId:e}){const[t,n]=y.useState([]),[r,a]=y.useState(!0);return y.useEffect(()=>{let s=!1;return $1(e).then(o=>{s||n(o)}).catch(()=>{s||n([])}).finally(()=>{s||a(!1)}),()=>{s=!0}},[e]),u.jsxs("section",{className:"rounded-xl border border-line bg-surface p-5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(_g,{className:"h-4 w-4 text-fg-4"}),u.jsx("h2",{className:"text-sm font-semibold text-fg",children:"Session 历史"}),!r&&u.jsx("span",{className:"rounded-full bg-elevated px-1.5 py-0.5 text-[10px] tabular-nums text-fg-4",children:t.length})]}),u.jsx("div",{className:"mt-3",children:r?u.jsx("div",{className:"flex items-center justify-center py-8",children:u.jsx(an,{className:"h-4 w-4 fs-spin text-fg-5"})}):t.length===0?u.jsx("p",{className:"py-8 text-center text-xs text-fg-5",children:"暂无 Session 记录。"}):u.jsx("div",{className:"space-y-1",children:t.map(s=>u.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-line bg-base px-4 py-2.5",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate text-xs font-medium text-fg",children:s.title||s.id.slice(-8)}),u.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-fg-5",children:[u.jsx("span",{children:Zu(s.timeCreated)}),s.cost>0&&u.jsxs(u.Fragment,{children:[u.jsx("span",{children:"·"}),u.jsxs("span",{children:["$",s.cost.toFixed(4)]})]}),(s.tokensInput>0||s.tokensOutput>0)&&u.jsxs(u.Fragment,{children:[u.jsx("span",{children:"·"}),u.jsxs("span",{children:[Math.round((s.tokensInput+s.tokensOutput)/1e3),"K tokens"]})]})]})]}),s.completedAt?u.jsx("span",{className:"shrink-0 rounded-full bg-green-500/10 px-2 py-0.5 text-[10px] font-medium text-green-400",children:"完成"}):u.jsx("span",{className:"shrink-0 rounded-full bg-elevated px-2 py-0.5 text-[10px] font-medium text-fg-5",children:"进行中"})]},s.id))})})]})}function Ire({agent:e,fragments:t,onSave:n}){const r=Fe(Y=>Y.activeRepoId),[a,s]=y.useState(!1),[o,c]=y.useState(e.name),[d,f]=y.useState(e.description??""),[m,p]=y.useState(e.baseAgent),[b,x]=y.useState(e.model??""),[E,N]=y.useState(e.variant??""),[T,S]=y.useState(e.memoryModel??""),[C,A]=y.useState(e.systemPrompt),[O,R]=y.useState(!1),[k,D]=y.useState(!1),[B,j]=y.useState([]);y.useEffect(()=>{if(!r){j([]);return}let Y=!1;return(async()=>{try{const[L,$]=await Promise.all([xl(),Df(r)]);if(Y)return;const Q=L[Nre],P=Q?JSON.parse(Q):[],he=P.length>0?$.filter(se=>P.includes(se.id)):$;j(he.length>0?he:$)}catch{Y||j([])}})(),()=>{Y=!0}},[r]);const[M,z]=y.useState(()=>{const Y=e.fragments.map(P=>P.id),L=e.systemPromptPosition??-1,$=L>=0&&L<=Y.length?L:Y.length,Q=[...Y];return Q.splice($,0,Go),Q}),G=Y=>{z(L=>{if(L.includes(Y))return L.filter(P=>P!==Y);const $=L.indexOf(Go),Q=[...L];return Q.splice($>=0?$:Q.length,0,Y),Q})},ae=(Y,L)=>{const $=Y+L;$<0||$>=M.length||z(Q=>{const P=[...Q];return[P[Y],P[$]]=[P[$],P[Y]],P})},Z=M.filter(Y=>Y!==Go),W=(()=>{const Y=M.indexOf(Go);return Y<0?-1:M.slice(0,Y).filter(L=>L!==Go).length})(),K=M.map(Y=>{var L;return Y===Go?C:(L=t.find($=>$.id===Y))==null?void 0:L.content}).filter(Boolean).join(`
568
568
 
569
569
  ---
570
570