@tea-agent/loop-agent 0.52.0-next.11 → 0.52.0-next.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/build-stamp.json +3 -3
- package/dist/shared/pi-context-pressure/compaction-policy.js +14 -1
- package/dist/worker/console/chat/compaction-errors.js +14 -0
- package/dist/worker/console/chat/pi-runtime.js +13 -0
- package/dist/worker/console/static/assets/{abnfDiagram-N423BO3Z-CT26sIgH.js → abnfDiagram-N423BO3Z-CR1jj_rz.js} +1 -1
- package/dist/worker/console/static/assets/{arc-CPwLqDB0.js → arc-CjxcQfEu.js} +1 -1
- package/dist/worker/console/static/assets/{architectureDiagram-T3A2C74G-CzTSMPU_.js → architectureDiagram-T3A2C74G-D-3u2qFL.js} +1 -1
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-BfgbtJLH.js → blockDiagram-VBNYF7ZC-Bdr7gWVo.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-B9pTjB8U.js → c4Diagram-5PPSVZJV-hQHNe5T3.js} +1 -1
- package/dist/worker/console/static/assets/channel-CBlJfald.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-xORV8QsC.js → chunk-2GRJ4B5K-BEg_su6q.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-BzpYWAHK.js → chunk-2Q5K7J3B-DZnV6VTC.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-D8zcRP6c.js → chunk-5RXB4S5H-Dg0LzAqO.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-DVEXxzQJ.js → chunk-5VM5RSS4-D2vqr52W.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-CKZOJU2z.js → chunk-6Q2QTUOP-D8We_g6R.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-Cgx34Dj8.js → chunk-GF5L2VYU-DbEU8drD.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-ehcSKOcx.js → chunk-JWPE2WC7-Boi8TJYN.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-CiY9emCG.js → chunk-KBJHAD2P-CjJmKa9f.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-Bk9X-ksQ.js → chunk-RYQCIY6F-C-KV-ag7.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-DC0xXfHy.js → chunk-XXDRQBXY-DZlTonsZ.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-mNUYCdDo.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-mNUYCdDo.js +1 -0
- package/dist/worker/console/static/assets/{cose-bilkent-JH36ORCC-C_EVg5l9.js → cose-bilkent-JH36ORCC-BIvFe3yn.js} +1 -1
- package/dist/worker/console/static/assets/{cynefinDiagram-MW4NZA55-DjtUYOlE.js → cynefinDiagram-MW4NZA55-BOBPfv8u.js} +1 -1
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-D2aN2V9t.js → dagre-VZM6K2ZE-BF54orLO.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-D_twhmFi.js → diagram-7IWD3JNH-CxjAP2AP.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-ChzncqLV.js → diagram-B4RE2ZJO-BXYkuNGt.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-LBJQPF4R-B6LO-bF2.js → diagram-LBJQPF4R-DQTu-2Iy.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-Q27KOJAE-GrzM7AFc.js → diagram-Q27KOJAE-DNURuIYc.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-UB23O5K3-Bv-lntaq.js → diagram-UB23O5K3-D69uANY8.js} +1 -1
- package/dist/worker/console/static/assets/{ebnfDiagram-BXEA7PRR-BvD2jkO_.js → ebnfDiagram-BXEA7PRR-C658EcrV.js} +1 -1
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-BirPCcmA.js → erDiagram-JOGREHBK-BRccYtAl.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-Chu1YnGQ.js → flowDiagram-UKHOOZJN-DnIR4sLs.js} +1 -1
- package/dist/worker/console/static/assets/{ganttDiagram-PKOTCBZU-Djn17xhB.js → ganttDiagram-PKOTCBZU-Bo3eWFVC.js} +1 -1
- package/dist/worker/console/static/assets/{gitGraphDiagram-DS77QQ5N-Bx1qbGHx.js → gitGraphDiagram-DS77QQ5N-EyWDCNU_.js} +1 -1
- package/dist/worker/console/static/assets/{infoDiagram-6WML65LV-D-TLMqmb.js → infoDiagram-6WML65LV-B0Eld9u0.js} +1 -1
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DbJoh-6T.js → ishikawaDiagram-WSZJBQD7-DsJQiJ27.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-DsyokZ6e.js → journeyDiagram-NVQOT4AX-fpE0yqjC.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-DlzXTxic.js → kanban-definition-27J2QSJJ-Dq9IrDdT.js} +1 -1
- package/dist/worker/console/static/assets/{linear-ClnZn3vw.js → linear-CFV4BDyf.js} +1 -1
- package/dist/worker/console/static/assets/{main-fc3P1HID.js → main-Dwhb3ZRq.js} +4 -4
- package/dist/worker/console/static/assets/{mermaid.core-DqSlcvbf.js → mermaid.core-BMMXqtrB.js} +4 -4
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-CSFbzpiX.js → mindmap-definition-FAOFIHXS-DurrK_Gi.js} +1 -1
- package/dist/worker/console/static/assets/{pegDiagram-VL7TDLO6-DK80yQqe.js → pegDiagram-VL7TDLO6-CzZayNy2.js} +1 -1
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-DWX7SFGb.js → pieDiagram-7S7Q4E2Y-B1W7Y0cE.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-BEPPhtXs.js → quadrantDiagram-CIZ2JOQS-BdbL83CU.js} +1 -1
- package/dist/worker/console/static/assets/{railroadDiagram-AXF67PYL-Ck_s6fQn.js → railroadDiagram-AXF67PYL-W-bQpd18.js} +1 -1
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-CYig27Rj.js → requirementDiagram-LRYGKXZP-C9bi4tQJ.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-u-0aSx5s.js → sankeyDiagram-W5VNT64P-D4kO56Wd.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-NsEJI9sM.js → sequenceDiagram-SI44F4Z6-CIbesK1e.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-kZ_HK4Sg.js → sheet-workbook-kFN3yUBr.js} +1 -1
- package/dist/worker/console/static/assets/{sizeCapture-X5ZJPWSS-8vneVM5U.js → sizeCapture-X5ZJPWSS-Dk4XAK7C.js} +1 -1
- package/dist/worker/console/static/assets/{stateDiagram-OKZ733FA-CMIobUBh.js → stateDiagram-OKZ733FA-Bz9B6UZ7.js} +1 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-BBRlxIq8.js +1 -0
- package/dist/worker/console/static/assets/{swimlanes-SLNWSIFB-D4Qzt6ug.js → swimlanes-SLNWSIFB-qLEds93n.js} +2 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CRBvOMCQ.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-DMb1LpED.js → timeline-definition-Z64GVDOM-C9rVFC0h.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-C_9eFOs3.js → vennDiagram-T6HMQDX7-CoKJ9hU0.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-DJYMe3uT.js → wardleyDiagram-T6FBY63Y-tHz_S7-L.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-Cv_1Mi3u.js → xychartDiagram-ELKLHX3M-DKzKYnvG.js} +1 -1
- package/dist/worker/console/static/index.html +1 -1
- package/package.json +3 -3
- package/dist/worker/console/static/assets/channel-DtYRMDck.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-DyesHbs5.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-DyesHbs5.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Bd0pHHKP.js +0 -1
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-BzmSZnl_.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BMMXqtrB.js","assets/FilePreviewDocx-ybM3ZqSl.js","assets/sheet-workbook-kFN3yUBr.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as f,j as i,b as S8,t as Le,g as th,_ as tc,F as _8,c as k8}from"./FilePreviewDocx-ybM3ZqSl.js";const Ul={"worker-managed-rerun-unsupported":"这次运行由 Console/Worker 启动,不能只从某个节点续跑","workspace-drift":"工作区在上次运行后又改过文件,旧结果不能接着用","controller-drift":"控制器版本已变化,不能接到上次运行上继续","binding-drift":"任务契约或源文件已变化,不能只续跑旧计划","restart-subgraph-contains-unsafe-shell":"下游包含会执行命令的验证步骤,不能只重跑这一段","restart-subgraph-contains-writer":"下游包含会改代码的写入步骤,不能只重跑这一段","restart-subgraph-contains-decision-gate":"下游包含需要人工决策的门禁,不能只重跑这一段","dynamic-rerun-unsupported":"这次运行含动态展开节点,不支持从节点续跑","parent-lifecycle-ineligible":"当前运行状态不允许从节点续跑","convergence-rerun-unsupported":"收敛型运行不支持从节点续跑","evaluation-rerun-unsupported":"带评估的运行不支持从节点续跑","budget-rerun-unsupported":"此运行需要前端专用恢复,不能通过普通节点续跑恢复","budget-lineage-missing":"缺少累计预算记录,无法安全续跑","budget-lineage-breached":"累计预算已超限,不能继续执行","budget-lineage-drift":"预算限制或累计消耗不一致,请先核对运行记录","workspace-checkpoint-missing":"缺少工作区快照,无法安全地只续跑一段","skill-snapshot-invalid":"技能快照缺失或损坏,不能接到上次运行上继续","unresolved-errors-outside-reset-closure":"选中节点之外还有未解决的失败,只重跑这一段不够","selected-node-missing":"找不到要续跑的起始节点","ambiguous-skipped-rewrite":"跳过的节点有多个上游失败,无法自动选定起点","skipped-without-upstream-error":"该节点被跳过且没有明确的上游失败","parent-facts-invalid":"上次运行的证据不完整或已损坏,不能只续跑一段",RUN_NOT_ACTIVE:"这次运行不在活动状态,不能协作中止",RUN_NOT_CONSOLE_OWNED:"此运行不由当前 Console 持有,暂不支持协作中止",RUNNER_IDENTITY_MISMATCH:"运行身份已变化,不能中止这份过期请求",INTERRUPT_ALREADY_PENDING:"已有一条中止请求等待结算",RUN_ALREADY_TERMINAL:"运行已经结束,没有可中止的活 runner",INTERRUPT_NEEDS_RECONCILE:"中止请求已登记但无法确认 runner 已处理,需要对账"};function C8(){return Object.keys(Ul)}function Fd(e){const t=e.trim().replace(/[.…]+$/,"");if(!t)return null;if(Ul[t])return{code:t};const n=t.lastIndexOf(":");if(n>0){const s=t.slice(n+1),r=t.slice(0,n);if(Ul[s])return{code:s,nodeId:r};const a=C8().find(o=>s.length>=3&&o.startsWith(s));if(a)return{code:a,nodeId:r}}return Ul[t]?{code:t}:null}function I8(e){const t=[];for(const n of e.blockedReasons??[]){const s=Fd(String(n));s&&t.push(s)}for(const n of e.blockingNodes??[]){const s=n.reasonCode?.trim();if(!s)continue;const r=Fd(n.nodeId?`${n.nodeId}:${s}`:s);r&&t.push(r)}if(t.length===0&&e.fallbackMessage?.trim()){const n=e.fallbackMessage.trim().replace(/^从节点重跑不具备安全资格[::]?\s*/,"").replace(/[。..]+$/,"");for(const s of n.split(/[;;]/)){const r=Fd(s);r&&t.push(r)}}return t}function E8(e){const t=new Map;for(const s of e){const r=t.get(s.code)??[];s.nodeId&&!r.includes(s.nodeId)&&r.push(s.nodeId),t.set(s.code,r)}const n=[];for(const[s,r]of t){const a=Ul[s];a&&(r.length>0&&s.startsWith("restart-subgraph-contains-")?n.push(`${a}(${r.join("、")})`):n.push(a))}return n}function N8(e){return e.join("; ").includes("worker-managed-rerun-unsupported")||e.some(n=>Fd(n)?.code==="worker-managed-rerun-unsupported")?"下一步:请点下方「重新排队 Worker Task」,从头完整执行。":"下一步:请改用「带反馈重新执行任务」,重新生成完整 DAG。"}function Nk(e){const t=e.fallbackMessage?.trim();if(t?.startsWith("无法从该节点续跑"))return t;const n=I8(e),s=E8(n),r=n.map(o=>o.code),a=N8(r.length>0?r:[t??""]);return s.length===0?["无法从该节点续跑。这次续跑不够安全(工作区、控制器或下游步骤不允许只重跑一段)。",a].join(`
|
|
3
3
|
`):["无法从该节点续跑,因为:",...s.map(o=>`• ${o}`),"",a].join(`
|
|
4
4
|
`)}function j8(e){const t=e.trim();if(!t)return null;if(t.startsWith("无法从该节点续跑"))return t;if(/从节点重跑不具备安全资格|worker-managed-rerun-unsupported|restart-subgraph-contains-|workspace-drift|controller-drift|binding-drift/.test(t))return Nk({fallbackMessage:t});if(/action must be a mutation-gate target/i.test(t))return"这个操作不能再走确认门。Worker 启动的任务请直接点「重新排队 Worker Task」;独立运行请点「带反馈重新执行任务」。";if(/cannot read dagReport run facts/i.test(t))return"读不到这次运行的失败报告,不能完整重跑。请先点「查看报告」或「Doctor 诊断」。";if(/dagRerunPlan run facts unavailable/i.test(t))return"读不到节点恢复资格,不能直接改走完整重跑。请先点「从失败节点恢复」查看资格,或先「查看报告」。";if(/node rerun plan is eligible/i.test(t))return"节点恢复是安全的,请改用「从失败节点恢复」,不必重新执行完整任务。";if(/does not support autonomous standaloneTaskRerun/i.test(t))return"当前失败不适合自动完整重跑。请先点「查看报告」,按建议操作。";if(/primaryRecovery requires a human decision/i.test(t))return"这次失败需要人工决策,不能自动重跑。请先点「查看报告」。";if(/is not bound to run/i.test(t))return"填写的任务 ID 与这次运行不匹配。请使用该运行绑定的原任务 ID。";if(/cannot read pool doctor/i.test(t))return"读不到任务队列状态,暂时不能重新排队。请稍后重试,或先跑 Doctor 诊断。";if(/not found in the pool doctor inventory/i.test(t))return"任务队列里找不到这个任务,不能重新排队。请确认 Task ID 来自 Worker 队列,而不是只填了 DAG 运行 ID。";if(/only Failed tasks are retry-eligible/i.test(t)){const n=t.match(/is ([A-Za-z_]+); only Failed/)?.[1];return n?`该任务当前是「${n}」,只有失败(Failed)的任务才能重新排队。`:"只有失败(Failed)的任务才能重新排队。请先确认任务已失败。"}return/featureId .+ does not match the pool task/i.test(t)?"Feature ID 与队列中的任务不一致。请改用队列里记录的 Feature ID,或留空后重试。":/RUN_NOT_CONSOLE_OWNED|不由当前 Console 持有/.test(t)?"此运行不由当前 Console 持有,暂不支持协作中止。请用 Doctor / 报告查看。":/RUNNER_IDENTITY_MISMATCH|运行身份已变化/.test(t)?"运行身份已变化,不能中止这份过期请求。请刷新后再试。":/INTERRUPT_ALREADY_PENDING|已有一条中止请求/.test(t)?"已有一条中止请求等待当前节点安全收敛。请稍候刷新,不要重复提交。":/RUN_ALREADY_TERMINAL|运行已经结束/.test(t)?"运行已经结束,没有可中止的活 runner。请改用报告或对账。":/INTERRUPT_NEEDS_RECONCILE|无法确认 runner 已处理/.test(t)?"中止请求已登记,但无法确认 runner 已处理。请用 Doctor 对账,不要当成已经中止。":/RUN_NOT_ACTIVE/.test(t)?"这次运行不在本机活动目录,或已经不是 running,不能协作中止。":null}function T8(e){return e==="validate"||e==="apply"||e==="spine"?"contract":e}async function R8(e,t){const s=await fetch(cs(`/api/dag-runs/${encodeURIComponent(e)}/prewrite-result`),{credentials:"same-origin"});if(!s.ok)return{ok:!1,status:s.status};const r=await s.json();return!r||typeof r.classification!="string"?{ok:!1,status:s.status}:{ok:!0,result:{schemaVersion:typeof r.schemaVersion=="number"?r.schemaVersion:1,schemaId:typeof r.schemaId=="string"?r.schemaId:"",classification:r.classification,failureCode:typeof r.failureCode=="string"?r.failureCode:null,failureReason:typeof r.failureReason=="string"?r.failureReason:null}}}function A8(e){return e==="fail"?"未通过":e==="pass"?"通过":"未知/不可判定"}const Vi="X-Loop-Console-Confirmation",jk="agent-worker web doctor --repo .",Q1=["LOW","MED","HIGH"];function M8(e){if(e.length===0)return"模型值不能为空";if(e.trim()!==e)return"模型值不能包含首尾空白";if(e==="default")return"default 是保留哨兵,不能作为模型值";if(e.startsWith("/")||e.endsWith("/")||e.includes("//"))return"provider/model 格式非法:不允许 /model、provider/ 或 a//b"}function L8(e){const t={};for(const n of Q1){const s=M8(e[n]);s&&(t[n]=s)}return t}function cx(e){return{LOW:e?.LOW?.value??"",MED:e?.MED?.value??"",HIGH:e?.HIGH?.value??""}}function O8(e){return Q1.every(t=>e[t]===void 0)}const $p=[{kind:"standard",label:"后端研发(默认 DAG)",hint:"生成标准 hybrid DAG(contract → implement → verify)"},{kind:"frontend-implementation",label:"前端研发",hint:"生成 frontend-implementation 专用节点链"},{kind:"backend-test",label:"后端测试",hint:"生成 backend-test-dag(分析 / 用例 / pytest)"},{kind:"frontend-test",label:"前端测试",hint:"生成 frontend-test-dag(RAG 用例 + Playwright CLI)"}],Tk={"setup-required":"需要设置",ready:"已就绪",degraded:"降级可用",unknown:"未知"},D8={idle:"未探测",match:"匹配",mismatch:"仓库不匹配",unavailable:"不可用"},Rk={low:"低",medium:"中",high:"高"},Ak={"validation-failed":"校验失败","contract-drift":"契约漂移","runtime-mismatch":"运行时不匹配","pause-on-human":"等待人工","verification-failed":"验证失败","orphan-unknown":"孤立/未知","terminal-failed":"已终止(失败)","terminal-succeeded":"已终止(成功)","needs-reconcile":"需要对账","running-active":"正在运行"},P8={idle:"空闲","not-started":"未开始","not-run":"未运行","n/a (MVP)":"不适用(MVP)",accepted:"已接受",succeeded:"已成功",running:"运行中",ran:"已执行"};function Zc(e){return P8[e]??e}function Gi(){return window.__CONSOLE_CONFIRMATION_TOKEN__??""}function ru(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Mk(e=typeof globalThis.location?.hash=="string"?globalThis.location.hash:""){const t=e.indexOf("?");if(!(t<0))return new URLSearchParams(e.slice(t+1)).get("workspaceId")?.trim()||void 0}function ev(e,t){const n=t?.trim()||Mk();if(!n)return e;const s=e.includes("?")?"&":"?";return`${e}${s}workspaceId=${encodeURIComponent(n)}`}function cs(e,t){return ev(e,t)}async function ko(e,t={},n,s){const r=s?.trim()||Mk(),a={"Content-Type":"application/json",[Vi]:Gi()},o=await fetch("/api/operator/v1/operations",{method:"POST",credentials:"same-origin",headers:a,body:JSON.stringify({action:e,actionParams:t,...r?{workspaceId:r}:{},...n?{clientRequestId:n}:{}})});let l={};try{l=await o.json()}catch{l={ok:!1,error:{code:"INVALID_INPUT",message:"操作响应不是合法 JSON"}}}return{status:o.status,body:l}}const $8=new Set(["runDag","dagRerun","dagReconcileRun","dagRequestInterrupt","standaloneTaskRerun","consoleUpdateAndInit"]);function Kh(e,t){return Nk({blockedReasons:e.blockedReasons,blockingNodes:e.blockingNodes,fallbackMessage:t})}async function Bp(e,t=3e5,n){const s=ev(`/api/operator/v1/operations/${encodeURIComponent(e)}`,n),r=Date.now();for(;Date.now()-r<t;){const a=await fetch(s,{credentials:"same-origin"});if(!a.ok)return null;const o=await a.json(),l=o.operation??o,c=l.state??"";if(c==="succeeded"||c==="failed"||c==="needs-reconcile"||c==="timed-out"||c==="restarting")return l;await new Promise(d=>setTimeout(d,250))}return{state:"timed-out",errorCode:"OPERATION_WAIT_TIMEOUT",errorMessage:`等待操作结果超时(${Math.round(t/1e3)} 秒)。操作可能仍在后台运行:请刷新页面后到操作记录中确认,不要重复提交。`}}function B8(e,t,n){const s=new AbortController,r=ev(`/api/operator/v1/operations/${encodeURIComponent(e)}/events`,n);return(async()=>{let a="";for(;!s.signal.aborted;)try{const o=await fetch(r,{credentials:"same-origin",signal:s.signal,headers:a?{"Last-Event-ID":a}:void 0});if(o.status===410||!o.ok||!o.body)return;const l=o.body.getReader(),c=new TextDecoder;let d="";for(;!s.signal.aborted;){const u=await l.read();if(u.done)break;d+=c.decode(u.value,{stream:!0});const h=d.split(`
|
|
@@ -44,7 +44,7 @@ import{r as f,j as i,b as S8,t as Le,g as th,_ as tc,F as _8,c as k8}from"./File
|
|
|
44
44
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:o,tableCell:c,tableRow:l}};function o(m,g,v,b){return d(u(m,v,b),m.align)}function l(m,g,v,b){const x=h(m,v,b),y=d([x]);return y.slice(0,y.indexOf(`
|
|
45
45
|
`))}function c(m,g,v,b){const x=v.enter("tableCell"),y=v.enter("phrasing"),C=v.containerPhrasing(m,{...b,before:a,after:a});return y(),x(),C}function d(m,g){return DM(m,{align:g,alignDelimiters:s,padding:n,stringLength:r})}function u(m,g,v){const b=m.children;let x=-1;const y=[],C=g.enter("table");for(;++x<b.length;)y[x]=h(b[x],g,v);return C(),y}function h(m,g,v){const b=m.children;let x=-1;const y=[],C=g.enter("tableRow");for(;++x<b.length;)y[x]=c(b[x],m,g,v);return C(),y}function p(m,g,v){let b=C5.inlineCode(m,g,v);return v.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function SL(){return{exit:{taskListCheckValueChecked:my,taskListCheckValueUnchecked:my,paragraph:kL}}}function _L(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:CL}}}function my(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function kL(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 s=n.children[0];if(s&&s.type==="text"){const r=t.children;let a=-1,o;for(;++a<r.length;){const l=r[a];if(l.type==="paragraph"){o=l;break}}o===n&&(s.value=s.value.slice(1),s.value.length===0?n.children.shift():n.position&&s.position&&typeof s.position.start.offset=="number"&&(s.position.start.column++,s.position.start.offset++,n.position.start=Object.assign({},s.position.start)))}}this.exit(e)}function CL(e,t,n,s){const r=e.children[0],a=typeof e.checked=="boolean"&&r&&r.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",l=n.createTracker(s);a&&l.move(o);let c=C5.listItem(e,t,n,{...s,...l.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),c;function d(u){return u+o}}function IL(){return[iM(),IM(),TM(),pL(),SL()]}function EL(e){return{extensions:[aM(),EM(e),RM(),wL(e),_L()]}}const NL={tokenize:LL,partial:!0},I5={tokenize:OL,partial:!0},E5={tokenize:DL,partial:!0},N5={tokenize:PL,partial:!0},jL={tokenize:$L,partial:!0},j5={name:"wwwAutolink",tokenize:AL,previous:R5},T5={name:"protocolAutolink",tokenize:ML,previous:A5},bi={name:"emailAutolink",tokenize:RL,previous:M5},Hr={};function TL(){return{text:Hr}}let la=48;for(;la<123;)Hr[la]=bi,la++,la===58?la=65:la===91&&(la=97);Hr[43]=bi;Hr[45]=bi;Hr[46]=bi;Hr[95]=bi;Hr[72]=[bi,T5];Hr[104]=[bi,T5];Hr[87]=[bi,j5];Hr[119]=[bi,j5];function RL(e,t,n){const s=this;let r,a;return o;function o(h){return!og(h)||!M5.call(s,s.previous)||Tv(s.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(h))}function l(h){return og(h)?(e.consume(h),l):h===64?(e.consume(h),c):n(h)}function c(h){return h===46?e.check(jL,u,d)(h):h===45||h===95||ps(h)?(a=!0,e.consume(h),c):u(h)}function d(h){return e.consume(h),r=!0,c}function u(h){return a&&r&&Is(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function AL(e,t,n){const s=this;return r;function r(o){return o!==87&&o!==119||!R5.call(s,s.previous)||Tv(s.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(NL,e.attempt(I5,e.attempt(E5,a),n),n)(o))}function a(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function ML(e,t,n){const s=this;let r="",a=!1;return o;function o(h){return(h===72||h===104)&&A5.call(s,s.previous)&&!Tv(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(h),e.consume(h),l):n(h)}function l(h){if(Is(h)&&r.length<5)return r+=String.fromCodePoint(h),e.consume(h),l;if(h===58){const p=r.toLowerCase();if(p==="http"||p==="https")return e.consume(h),c}return n(h)}function c(h){return h===47?(e.consume(h),a?d:(a=!0,c)):n(h)}function d(h){return h===null||vu(h)||dn(h)||Ta(h)||dh(h)?n(h):e.attempt(I5,e.attempt(E5,u),n)(h)}function u(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function LL(e,t,n){let s=0;return r;function r(o){return(o===87||o===119)&&s<3?(s++,e.consume(o),r):o===46&&s===3?(e.consume(o),a):n(o)}function a(o){return o===null?n(o):t(o)}}function OL(e,t,n){let s,r,a;return o;function o(d){return d===46||d===95?e.check(N5,c,l)(d):d===null||dn(d)||Ta(d)||d!==45&&dh(d)?c(d):(a=!0,e.consume(d),o)}function l(d){return d===95?s=!0:(r=s,s=void 0),e.consume(d),o}function c(d){return r||s||!a?n(d):t(d)}}function DL(e,t){let n=0,s=0;return r;function r(o){return o===40?(n++,e.consume(o),r):o===41&&s<n?a(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(N5,t,a)(o):o===null||dn(o)||Ta(o)?t(o):(e.consume(o),r)}function a(o){return o===41&&s++,e.consume(o),r}}function PL(e,t,n){return s;function s(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),s):l===38?(e.consume(l),a):l===93?(e.consume(l),r):l===60||l===null||dn(l)||Ta(l)?t(l):n(l)}function r(l){return l===null||l===40||l===91||dn(l)||Ta(l)?t(l):s(l)}function a(l){return Is(l)?o(l):n(l)}function o(l){return l===59?(e.consume(l),s):Is(l)?(e.consume(l),o):n(l)}}function $L(e,t,n){return s;function s(a){return e.consume(a),r}function r(a){return ps(a)?n(a):t(a)}}function R5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||dn(e)}function A5(e){return!Is(e)}function M5(e){return!(e===47||og(e))}function og(e){return e===43||e===45||e===46||e===95||ps(e)}function Tv(e){let t=e.length,n=!1;for(;t--;){const s=e[t][1];if((s.type==="labelLink"||s.type==="labelImage")&&!s._balanced){n=!0;break}if(s._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const BL={tokenize:GL,partial:!0};function FL(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:UL,continuation:{tokenize:WL},exit:VL}},text:{91:{name:"gfmFootnoteCall",tokenize:qL},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:zL,resolveTo:HL}}}}function zL(e,t,n){const s=this;let r=s.events.length;const a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let o;for(;r--;){const c=s.events[r][1];if(c.type==="labelImage"){o=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return l;function l(c){if(!o||!o._balanced)return n(c);const d=gr(s.sliceSerialize({start:o.end,end:s.now()}));return d.codePointAt(0)!==94||!a.includes(d.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function HL(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 s={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},r={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};r.end.column++,r.end.offset++,r.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},r.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},l=[e[n+1],e[n+2],["enter",s,t],e[n+3],e[n+4],["enter",r,t],["exit",r,t],["enter",a,t],["enter",o,t],["exit",o,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",s,t]];return e.splice(n,e.length-n+1,...l),e}function qL(e,t,n){const s=this,r=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let a=0,o;return l;function l(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),c}function c(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(h){if(a>999||h===93&&!o||h===null||h===91||dn(h))return n(h);if(h===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return r.includes(gr(s.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return dn(h)||(o=!0),a++,e.consume(h),h===92?u:d}function u(h){return h===91||h===92||h===93?(e.consume(h),a++,d):d(h)}}function UL(e,t,n){const s=this,r=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let a,o=0,l;return c;function c(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(g)}function u(g){if(o>999||g===93&&!l||g===null||g===91||dn(g))return n(g);if(g===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return a=gr(s.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return dn(g)||(l=!0),o++,e.consume(g),g===92?h:u}function h(g){return g===91||g===92||g===93?(e.consume(g),o++,u):u(g)}function p(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),r.includes(a)||r.push(a),Kt(e,m,"gfmFootnoteDefinitionWhitespace")):n(g)}function m(g){return t(g)}}function WL(e,t,n){return e.check(Ec,t,e.attempt(BL,t,n))}function VL(e){e.exit("gfmFootnoteDefinition")}function GL(e,t,n){const s=this;return Kt(e,r,"gfmFootnoteDefinitionIndent",5);function r(a){const o=s.events[s.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(a):n(a)}}function KL(e){let n=(e||{}).singleTilde;const s={name:"strikethrough",tokenize:a,resolveAll:r};return n==null&&(n=!0),{text:{126:s},insideSpan:{null:[s]},attentionMarkers:{null:[126]}};function r(o,l){let c=-1;for(;++c<o.length;)if(o[c][0]==="enter"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._close){let d=c;for(;d--;)if(o[d][0]==="exit"&&o[d][1].type==="strikethroughSequenceTemporary"&&o[d][1]._open&&o[c][1].end.offset-o[c][1].start.offset===o[d][1].end.offset-o[d][1].start.offset){o[c][1].type="strikethroughSequence",o[d][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[d][1].start),end:Object.assign({},o[c][1].end)},h={type:"strikethroughText",start:Object.assign({},o[d][1].end),end:Object.assign({},o[c][1].start)},p=[["enter",u,l],["enter",o[d][1],l],["exit",o[d][1],l],["enter",h,l]],m=l.parser.constructs.insideSpan.null;m&&Ks(p,p.length,0,uh(m,o.slice(d+1,c),l)),Ks(p,p.length,0,[["exit",h,l],["enter",o[c][1],l],["exit",o[c][1],l],["exit",u,l]]),Ks(o,d-1,c-d+3,p),c=d+p.length-2;break}}for(c=-1;++c<o.length;)o[c][1].type==="strikethroughSequenceTemporary"&&(o[c][1].type="data");return o}function a(o,l,c){const d=this.previous,u=this.events;let h=0;return p;function p(g){return d===126&&u[u.length-1][1].type!=="characterEscape"?c(g):(o.enter("strikethroughSequenceTemporary"),m(g))}function m(g){const v=Ao(d);if(g===126)return h>1?c(g):(o.consume(g),h++,m);if(h<2&&!n)return c(g);const b=o.exit("strikethroughSequenceTemporary"),x=Ao(g);return b._open=!x||x===2&&!!v,b._close=!v||v===2&&!!x,l(g)}}}class YL{constructor(){this.map=[]}add(t,n,s){ZL(this,t,n,s)}consume(t){if(this.map.sort(function(a,o){return a[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const s=[];for(;n>0;)n-=1,s.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];s.push(t.slice()),t.length=0;let r=s.pop();for(;r;){for(const a of r)t.push(a);r=s.pop()}this.map.length=0}}function ZL(e,t,n,s){let r=0;if(!(n===0&&s.length===0)){for(;r<e.map.length;){if(e.map[r][0]===t){e.map[r][1]+=n,e.map[r][2].push(...s);return}r+=1}e.map.push([t,n,s])}}function XL(e,t){let n=!1;const s=[];for(;t<e.length;){const r=e[t];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&s.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=s.length-1;s[a]=s[a]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return s}function JL(){return{flow:{null:{name:"table",tokenize:QL,resolveAll:eO}}}}function QL(e,t,n){const s=this;let r=0,a=0,o;return l;function l(L){let O=s.events.length-1;for(;O>-1;){const A=s.events[O][1].type;if(A==="lineEnding"||A==="linePrefix")O--;else break}const T=O>-1?s.events[O][1].type:null,R=T==="tableHead"||T==="tableRow"?w:c;return R===w&&s.parser.lazy[s.now().line]?n(L):R(L)}function c(L){return e.enter("tableHead"),e.enter("tableRow"),d(L)}function d(L){return L===124||(o=!0,a+=1),u(L)}function u(L){return L===null?n(L):Nt(L)?a>1?(a=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),m):n(L):Zt(L)?Kt(e,u,"whitespace")(L):(a+=1,o&&(o=!1,r+=1),L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),h(L)))}function h(L){return L===null||L===124||dn(L)?(e.exit("data"),u(L)):(e.consume(L),L===92?p:h)}function p(L){return L===92||L===124?(e.consume(L),h):h(L)}function m(L){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(L):(e.enter("tableDelimiterRow"),o=!1,Zt(L)?Kt(e,g,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):g(L))}function g(L){return L===45||L===58?b(L):L===124?(o=!0,e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),v):I(L)}function v(L){return Zt(L)?Kt(e,b,"whitespace")(L):b(L)}function b(L){return L===58?(a+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),x):L===45?(a+=1,x(L)):L===null||Nt(L)?S(L):I(L)}function x(L){return L===45?(e.enter("tableDelimiterFiller"),y(L)):I(L)}function y(L){return L===45?(e.consume(L),y):L===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(L),e.exit("tableDelimiterMarker"),C):(e.exit("tableDelimiterFiller"),C(L))}function C(L){return Zt(L)?Kt(e,S,"whitespace")(L):S(L)}function S(L){return L===124?g(L):L===null||Nt(L)?!o||r!==a?I(L):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(L)):I(L)}function I(L){return n(L)}function w(L){return e.enter("tableRow"),_(L)}function _(L){return L===124?(e.enter("tableCellDivider"),e.consume(L),e.exit("tableCellDivider"),_):L===null||Nt(L)?(e.exit("tableRow"),t(L)):Zt(L)?Kt(e,_,"whitespace")(L):(e.enter("data"),k(L))}function k(L){return L===null||L===124||dn(L)?(e.exit("data"),_(L)):(e.consume(L),L===92?N:k)}function N(L){return L===92||L===124?(e.consume(L),k):k(L)}}function eO(e,t){let n=-1,s=!0,r=0,a=[0,0,0,0],o=[0,0,0,0],l=!1,c=0,d,u,h;const p=new YL;for(;++n<e.length;){const m=e[n],g=m[1];m[0]==="enter"?g.type==="tableHead"?(l=!1,c!==0&&(py(p,t,c,d,u),u=void 0,c=0),d={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",d,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(s=!0,h=void 0,a=[0,0,0,0],o=[0,n+1,0,0],l&&(l=!1,u={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",u,t]])),r=g.type==="tableDelimiterRow"?2:u?3:1):r&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(s=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],h=td(p,t,a,r,void 0,h),a=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(s?s=!1:(a[1]!==0&&(o[0]=o[1],h=td(p,t,a,r,void 0,h)),a=o,o=[a[1],n,0,0])):g.type==="tableHead"?(l=!0,c=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(c=n,a[1]!==0?(o[0]=o[1],h=td(p,t,a,r,n,h)):o[1]!==0&&(h=td(p,t,o,r,n,h)),r=0):r&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(c!==0&&py(p,t,c,d,u),p.consume(t.events),n=-1;++n<t.events.length;){const m=t.events[n];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=XL(t.events,n))}return e}function td(e,t,n,s,r,a){const o=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(a.end=Object.assign({},ao(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=ao(t.events,n[1]);if(a={type:o,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const d=ao(t.events,n[2]),u=ao(t.events,n[3]),h={type:l,start:Object.assign({},d),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",h,t]]),s!==2){const p=t.events[n[2]],m=t.events[n[3]];if(p[1].end=Object.assign({},m[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,v=n[3]-n[2]-1;e.add(g,v,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return r!==void 0&&(a.end=Object.assign({},ao(t.events,r)),e.add(r,0,[["exit",a,t]]),a=void 0),a}function py(e,t,n,s,r){const a=[],o=ao(t.events,n);r&&(r.end=Object.assign({},o),a.push(["exit",r,t])),s.end=Object.assign({},o),a.push(["exit",s,t]),e.add(n+1,0,a)}function ao(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const tO={name:"tasklistCheck",tokenize:sO};function nO(){return{text:{91:tO}}}function sO(e,t,n){const s=this;return r;function r(c){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return dn(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),o):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),o):n(c)}function o(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(c)}function l(c){return Nt(c)?t(c):Zt(c)?e.check({tokenize:rO},t,n)(c):n(c)}}function rO(e,t,n){return Kt(e,s,"whitespace");function s(r){return r===null?n(r):t(r)}}function iO(e){return F3([TL(),FL(),KL(e),JL(),nO()])}const aO={};function L5(e){const t=this,n=e||aO,s=t.data(),r=s.micromarkExtensions||(s.micromarkExtensions=[]),a=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),o=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);r.push(iO(n)),a.push(IL()),o.push(EL(n))}var nd={exports:{}},xf,gy;function Tc(){if(gy)return xf;gy=1;const e="2.0.0",t=256,n=Number.MAX_SAFE_INTEGER||9007199254740991,s=16,r=t-6;return xf={MAX_LENGTH:t,MAX_SAFE_COMPONENT_LENGTH:s,MAX_SAFE_BUILD_LENGTH:r,MAX_SAFE_INTEGER:n,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},xf}var yf,vy;function mh(){if(vy)return yf;vy=1;var e={};return yf=typeof process=="object"&&e&&e.NODE_DEBUG&&/\bsemver\b/i.test(e.NODE_DEBUG)?(...n)=>console.error("SEMVER",...n):()=>{},yf}var by;function Rc(){return by||(by=1,(function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:r}=Tc(),a=mh();t=e.exports={};const o=t.re=[],l=t.safeRe=[],c=t.src=[],d=t.safeSrc=[],u=t.t={};let h=0;const p="[a-zA-Z0-9-]",m=[["\\s",1],["\\d",r],[p,s]],g=b=>{for(const[x,y]of m)b=b.split(`${x}*`).join(`${x}{0,${y}}`).split(`${x}+`).join(`${x}{1,${y}}`);return b},v=(b,x,y)=>{const C=g(x),S=h++;a(b,S,x),u[b]=S,c[S]=x,d[S]=C,o[S]=new RegExp(x,y?"g":void 0),l[S]=new RegExp(C,y?"g":void 0)};v("NUMERICIDENTIFIER","0|[1-9]\\d*"),v("NUMERICIDENTIFIERLOOSE","\\d+"),v("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${p}*`),v("MAINVERSION",`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),v("MAINVERSIONLOOSE",`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),v("PRERELEASEIDENTIFIER",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),v("PRERELEASEIDENTIFIERLOOSE",`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),v("PRERELEASE",`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),v("PRERELEASELOOSE",`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),v("BUILDIDENTIFIER",`${p}+`),v("BUILD",`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),v("FULLPLAIN",`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),v("FULL",`^${c[u.FULLPLAIN]}$`),v("LOOSEPLAIN",`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),v("LOOSE",`^${c[u.LOOSEPLAIN]}$`),v("GTLT","((?:<|>)?=?)"),v("XRANGEIDENTIFIERLOOSE",`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),v("XRANGEIDENTIFIER",`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),v("XRANGEPLAIN",`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),v("XRANGEPLAINLOOSE",`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),v("XRANGE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),v("XRANGELOOSE",`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),v("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),v("COERCE",`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),v("COERCEFULL",c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),v("COERCERTL",c[u.COERCE],!0),v("COERCERTLFULL",c[u.COERCEFULL],!0),v("LONETILDE","(?:~>?)"),v("TILDETRIM",`(\\s*)${c[u.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",v("TILDE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),v("TILDELOOSE",`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),v("LONECARET","(?:\\^)"),v("CARETTRIM",`(\\s*)${c[u.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",v("CARET",`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),v("CARETLOOSE",`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),v("COMPARATORLOOSE",`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),v("COMPARATOR",`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),v("COMPARATORTRIM",`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",v("HYPHENRANGE",`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),v("HYPHENRANGELOOSE",`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),v("STAR","(<|>)?=?\\s*\\*"),v("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),v("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(nd,nd.exports)),nd.exports}var wf,xy;function Rv(){if(xy)return wf;xy=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return wf=s=>s?typeof s!="object"?e:s:t,wf}var Sf,yy;function O5(){if(yy)return Sf;yy=1;const e=/^[0-9]+$/,t=(s,r)=>{if(typeof s=="number"&&typeof r=="number")return s===r?0:s<r?-1:1;const a=e.test(s),o=e.test(r);return a&&o&&(s=+s,r=+r),s===r?0:a&&!o?-1:o&&!a?1:s<r?-1:1};return Sf={compareIdentifiers:t,rcompareIdentifiers:(s,r)=>t(r,s)},Sf}var _f,wy;function xs(){if(wy)return _f;wy=1;const e=mh(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=Tc(),{safeRe:s,t:r}=Rc(),a=Rv(),{compareIdentifiers:o}=O5(),l=(d,u)=>{const h=u.split(".");if(h.length>d.length)return!1;for(let p=0;p<h.length;p++)if(o(d[p],h[p])!==0)return!1;return!0};class c{constructor(u,h){if(h=a(h),u instanceof c){if(u.loose===!!h.loose&&u.includePrerelease===!!h.includePrerelease)return u;u=u.version}else if(typeof u!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof u}".`);if(u.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",u,h),this.options=h,this.loose=!!h.loose,this.includePrerelease=!!h.includePrerelease;const p=u.trim().match(h.loose?s[r.LOOSE]:s[r.FULL]);if(!p)throw new TypeError(`Invalid Version: ${u}`);if(this.raw=u,this.major=+p[1],this.minor=+p[2],this.patch=+p[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");p[4]?this.prerelease=p[4].split(".").map(m=>{if(/^[0-9]+$/.test(m)){const g=+m;if(g>=0&&g<n)return g}return m}):this.prerelease=[],this.build=p[5]?p[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(u){if(e("SemVer.compare",this.version,this.options,u),!(u instanceof c)){if(typeof u=="string"&&u===this.version)return 0;u=new c(u,this.options)}return u.version===this.version?0:this.compareMain(u)||this.comparePre(u)}compareMain(u){return u instanceof c||(u=new c(u,this.options)),this.major<u.major?-1:this.major>u.major?1:this.minor<u.minor?-1:this.minor>u.minor?1:this.patch<u.patch?-1:this.patch>u.patch?1:0}comparePre(u){if(u instanceof c||(u=new c(u,this.options)),this.prerelease.length&&!u.prerelease.length)return-1;if(!this.prerelease.length&&u.prerelease.length)return 1;if(!this.prerelease.length&&!u.prerelease.length)return 0;let h=0;do{const p=this.prerelease[h],m=u.prerelease[h];if(e("prerelease compare",h,p,m),p===void 0&&m===void 0)return 0;if(m===void 0)return 1;if(p===void 0)return-1;if(p===m)continue;return o(p,m)}while(++h)}compareBuild(u){u instanceof c||(u=new c(u,this.options));let h=0;do{const p=this.build[h],m=u.build[h];if(e("build compare",h,p,m),p===void 0&&m===void 0)return 0;if(m===void 0)return 1;if(p===void 0)return-1;if(p===m)continue;return o(p,m)}while(++h)}inc(u,h,p){if(u.startsWith("pre")){if(!h&&p===!1)throw new Error("invalid increment argument: identifier is empty");if(h){const m=`-${h}`.match(this.options.loose?s[r.PRERELEASELOOSE]:s[r.PRERELEASE]);if(!m||m[1]!==h)throw new Error(`invalid identifier: ${h}`)}}switch(u){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",h,p);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",h,p);break;case"prepatch":this.prerelease.length=0,this.inc("patch",h,p),this.inc("pre",h,p);break;case"prerelease":this.prerelease.length===0&&this.inc("patch",h,p),this.inc("pre",h,p);break;case"release":if(this.prerelease.length===0)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case"patch":this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case"pre":{const m=Number(p)?1:0;if(this.prerelease.length===0)this.prerelease=[m];else{let g=this.prerelease.length;for(;--g>=0;)typeof this.prerelease[g]=="number"&&(this.prerelease[g]++,g=-2);if(g===-1){if(h===this.prerelease.join(".")&&p===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(m)}}if(h){let g=[h,m];if(p===!1&&(g=[h]),l(this.prerelease,h)){const v=this.prerelease[h.split(".").length];isNaN(v)&&(this.prerelease=g)}else this.prerelease=g}break}default:throw new Error(`invalid increment argument: ${u}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return _f=c,_f}var kf,Sy;function Da(){if(Sy)return kf;Sy=1;const e=xs();return kf=(n,s,r=!1)=>{if(n instanceof e)return n;try{return new e(n,s)}catch(a){if(!r)return null;throw a}},kf}var Cf,_y;function oO(){if(_y)return Cf;_y=1;const e=Da();return Cf=(n,s)=>{const r=e(n,s);return r?r.version:null},Cf}var If,ky;function lO(){if(ky)return If;ky=1;const e=Da();return If=(n,s)=>{const r=e(n.trim().replace(/^[=v]+/,""),s);return r?r.version:null},If}var Ef,Cy;function cO(){if(Cy)return Ef;Cy=1;const e=xs();return Ef=(n,s,r,a,o)=>{typeof r=="string"&&(o=a,a=r,r=void 0);try{return new e(n instanceof e?n.version:n,r).inc(s,a,o).version}catch{return null}},Ef}var Nf,Iy;function dO(){if(Iy)return Nf;Iy=1;const e=Da();return Nf=(n,s)=>{const r=e(n,null,!0),a=e(s,null,!0),o=r.compare(a);if(o===0)return null;const l=o>0,c=l?r:a,d=l?a:r,u=!!c.prerelease.length;if(!!d.prerelease.length&&!u){if(!d.patch&&!d.minor)return"major";if(d.compareMain(c)===0)return d.minor&&!d.patch?"minor":"patch"}const p=u?"pre":"";return r.major!==a.major?p+"major":r.minor!==a.minor?p+"minor":r.patch!==a.patch?p+"patch":"prerelease"},Nf}var jf,Ey;function uO(){if(Ey)return jf;Ey=1;const e=xs();return jf=(n,s)=>new e(n,s).major,jf}var Tf,Ny;function hO(){if(Ny)return Tf;Ny=1;const e=xs();return Tf=(n,s)=>new e(n,s).minor,Tf}var Rf,jy;function fO(){if(jy)return Rf;jy=1;const e=xs();return Rf=(n,s)=>new e(n,s).patch,Rf}var Af,Ty;function mO(){if(Ty)return Af;Ty=1;const e=Da();return Af=(n,s)=>{const r=e(n,s);return r&&r.prerelease.length?r.prerelease:null},Af}var Mf,Ry;function vr(){if(Ry)return Mf;Ry=1;const e=xs();return Mf=(n,s,r)=>new e(n,r).compare(new e(s,r)),Mf}var Lf,Ay;function pO(){if(Ay)return Lf;Ay=1;const e=vr();return Lf=(n,s,r)=>e(s,n,r),Lf}var Of,My;function gO(){if(My)return Of;My=1;const e=vr();return Of=(n,s)=>e(n,s,!0),Of}var Df,Ly;function Av(){if(Ly)return Df;Ly=1;const e=xs();return Df=(n,s,r)=>{const a=new e(n,r),o=new e(s,r);return a.compare(o)||a.compareBuild(o)},Df}var Pf,Oy;function vO(){if(Oy)return Pf;Oy=1;const e=Av();return Pf=(n,s)=>n.sort((r,a)=>e(r,a,s)),Pf}var $f,Dy;function bO(){if(Dy)return $f;Dy=1;const e=Av();return $f=(n,s)=>n.sort((r,a)=>e(a,r,s)),$f}var Bf,Py;function ph(){if(Py)return Bf;Py=1;const e=vr();return Bf=(n,s,r)=>e(n,s,r)>0,Bf}var Ff,$y;function Mv(){if($y)return Ff;$y=1;const e=vr();return Ff=(n,s,r)=>e(n,s,r)<0,Ff}var zf,By;function D5(){if(By)return zf;By=1;const e=vr();return zf=(n,s,r)=>e(n,s,r)===0,zf}var Hf,Fy;function P5(){if(Fy)return Hf;Fy=1;const e=vr();return Hf=(n,s,r)=>e(n,s,r)!==0,Hf}var qf,zy;function Lv(){if(zy)return qf;zy=1;const e=vr();return qf=(n,s,r)=>e(n,s,r)>=0,qf}var Uf,Hy;function Ov(){if(Hy)return Uf;Hy=1;const e=vr();return Uf=(n,s,r)=>e(n,s,r)<=0,Uf}var Wf,qy;function $5(){if(qy)return Wf;qy=1;const e=D5(),t=P5(),n=ph(),s=Lv(),r=Mv(),a=Ov();return Wf=(l,c,d,u)=>{switch(c){case"===":return typeof l=="object"&&(l=l.version),typeof d=="object"&&(d=d.version),l===d;case"!==":return typeof l=="object"&&(l=l.version),typeof d=="object"&&(d=d.version),l!==d;case"":case"=":case"==":return e(l,d,u);case"!=":return t(l,d,u);case">":return n(l,d,u);case">=":return s(l,d,u);case"<":return r(l,d,u);case"<=":return a(l,d,u);default:throw new TypeError(`Invalid operator: ${c}`)}},Wf}var Vf,Uy;function xO(){if(Uy)return Vf;Uy=1;const e=xs(),t=Da(),{safeRe:n,t:s}=Rc();return Vf=(a,o)=>{if(a instanceof e)return a;if(typeof a=="number"&&(a=String(a)),typeof a!="string")return null;o=o||{};let l=null;if(!o.rtl)l=a.match(o.includePrerelease?n[s.COERCEFULL]:n[s.COERCE]);else{const m=o.includePrerelease?n[s.COERCERTLFULL]:n[s.COERCERTL];let g;for(;(g=m.exec(a))&&(!l||l.index+l[0].length!==a.length);)(!l||g.index+g[0].length!==l.index+l[0].length)&&(l=g),m.lastIndex=g.index+g[1].length+g[2].length;m.lastIndex=-1}if(l===null)return null;const c=l[2],d=l[3]||"0",u=l[4]||"0",h=o.includePrerelease&&l[5]?`-${l[5]}`:"",p=o.includePrerelease&&l[6]?`+${l[6]}`:"";return t(`${c}.${d}.${u}${h}${p}`,o)},Vf}var Gf,Wy;function yO(){if(Wy)return Gf;Wy=1;const e=Da(),t=Tc(),n=xs(),s=(l,c,d)=>{if(!t.RELEASE_TYPES.includes(c))return null;const u=r(l,d);return u&&a(u,c)},r=(l,c)=>{const d=l instanceof n?l.version:l;return e(d,c)},a=(l,c)=>{if(o(c))return l.version;switch(l.prerelease=[],c){case"major":l.minor=0,l.patch=0;break;case"minor":l.patch=0;break}return l.format()},o=l=>l.startsWith("pre");return Gf=s,Gf}var Kf,Vy;function wO(){if(Vy)return Kf;Vy=1;class e{constructor(){this.max=1e3,this.map=new Map}get(n){const s=this.map.get(n);if(s!==void 0)return this.map.delete(n),this.map.set(n,s),s}delete(n){return this.map.delete(n)}set(n,s){if(!this.delete(n)&&s!==void 0){if(this.map.size>=this.max){const a=this.map.keys().next().value;this.delete(a)}this.map.set(n,s)}return this}}return Kf=e,Kf}var Yf,Gy;function br(){if(Gy)return Yf;Gy=1;const e=/\s+/g;class t{constructor(B,G){if(G=r(G),B instanceof t)return B.loose===!!G.loose&&B.includePrerelease===!!G.includePrerelease?B:new t(B.raw,G);if(B instanceof a)return this.raw=B.value,this.set=[[B]],this.formatted=void 0,this;if(this.options=G,this.loose=!!G.loose,this.includePrerelease=!!G.includePrerelease,this.raw=B.trim().replace(e," "),this.set=this.raw.split("||").map(z=>this.parseRange(z.trim())).filter(z=>z.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const z=this.set[0];if(this.set=this.set.filter(Q=>!x(Q[0])),this.set.length===0)this.set=[z];else if(this.set.length>1){for(const Q of this.set)if(Q.length===1&&y(Q[0])){this.set=[Q];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let B=0;B<this.set.length;B++){B>0&&(this.formatted+="||");const G=this.set[B];for(let z=0;z<G.length;z++)z>0&&(this.formatted+=" "),this.formatted+=G[z].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(B){B=B.replace(b,"");const z=((this.options.includePrerelease&&g)|(this.options.loose&&v))+":"+B,Q=s.get(z);if(Q)return Q;const W=this.options.loose,D=W?c[u.HYPHENRANGELOOSE]:c[u.HYPHENRANGE];B=B.replace(D,E(this.options.includePrerelease)),o("hyphen replace",B),B=B.replace(c[u.COMPARATORTRIM],h),o("comparator trim",B),B=B.replace(c[u.TILDETRIM],p),o("tilde trim",B),B=B.replace(c[u.CARETTRIM],m),o("caret trim",B);let ee=B.split(" ").map(q=>S(q,this.options)).join(" ").split(/\s+/).map(q=>A(q,this.options));W&&(ee=ee.filter(q=>(o("loose invalid filter",q,this.options),!!q.match(c[u.COMPARATORLOOSE])))),o("range list",ee);const F=new Map,M=ee.map(q=>new a(q,this.options));for(const q of M){if(x(q))return[q];F.set(q.value,q)}F.size>1&&F.has("")&&F.delete("");const U=[...F.values()];return s.set(z,U),U}intersects(B,G){if(!(B instanceof t))throw new TypeError("a Range is required");return this.set.some(z=>C(z,G)&&B.set.some(Q=>C(Q,G)&&z.every(W=>Q.every(D=>W.intersects(D,G)))))}test(B){if(!B)return!1;if(typeof B=="string")try{B=new l(B,this.options)}catch{return!1}for(let G=0;G<this.set.length;G++)if($(this.set[G],B,this.options))return!0;return!1}}Yf=t;const n=wO(),s=new n,r=Rv(),a=gh(),o=mh(),l=xs(),{safeRe:c,src:d,t:u,comparatorTrimReplace:h,tildeTrimReplace:p,caretTrimReplace:m}=Rc(),{FLAG_INCLUDE_PRERELEASE:g,FLAG_LOOSE:v}=Tc(),b=new RegExp(d[u.BUILD],"g"),x=H=>H.value==="<0.0.0-0",y=H=>H.value==="",C=(H,B)=>{let G=!0;const z=H.slice();let Q=z.pop();for(;G&&z.length;)G=z.every(W=>Q.intersects(W,B)),Q=z.pop();return G},S=(H,B)=>(H=H.replace(c[u.BUILD],""),o("comp",H,B),H=N(H,B),o("caret",H),H=_(H,B),o("tildes",H),H=O(H,B),o("xrange",H),H=R(H,B),o("stars",H),H),I=H=>!H||H.toLowerCase()==="x"||H==="*",w=(H,B,G)=>I(H)&&!I(B)||I(B)&&G&&!I(G),_=(H,B)=>H.trim().split(/\s+/).map(G=>k(G,B)).join(" "),k=(H,B)=>{const G=B.loose?c[u.TILDELOOSE]:c[u.TILDE],z=B.includePrerelease?"-0":"";return H.replace(G,(Q,W,D,ee,F)=>{o("tilde",H,Q,W,D,ee,F);let M;return I(W)?M="":I(D)?M=`>=${W}.0.0${z} <${+W+1}.0.0-0`:I(ee)?M=`>=${W}.${D}.0${z} <${W}.${+D+1}.0-0`:F?(o("replaceTilde pr",F),M=`>=${W}.${D}.${ee}-${F} <${W}.${+D+1}.0-0`):M=`>=${W}.${D}.${ee} <${W}.${+D+1}.0-0`,o("tilde return",M),M})},N=(H,B)=>H.trim().split(/\s+/).map(G=>L(G,B)).join(" "),L=(H,B)=>{o("caret",H,B);const G=B.loose?c[u.CARETLOOSE]:c[u.CARET],z=B.includePrerelease?"-0":"";return H.replace(G,(Q,W,D,ee,F)=>{o("caret",H,Q,W,D,ee,F);let M;return I(W)?M="":I(D)?M=`>=${W}.0.0${z} <${+W+1}.0.0-0`:I(ee)?W==="0"?M=`>=${W}.${D}.0${z} <${W}.${+D+1}.0-0`:M=`>=${W}.${D}.0${z} <${+W+1}.0.0-0`:F?(o("replaceCaret pr",F),W==="0"?D==="0"?M=`>=${W}.${D}.${ee}-${F} <${W}.${D}.${+ee+1}-0`:M=`>=${W}.${D}.${ee}-${F} <${W}.${+D+1}.0-0`:M=`>=${W}.${D}.${ee}-${F} <${+W+1}.0.0-0`):(o("no pr"),W==="0"?D==="0"?M=`>=${W}.${D}.${ee} <${W}.${D}.${+ee+1}-0`:M=`>=${W}.${D}.${ee} <${W}.${+D+1}.0-0`:M=`>=${W}.${D}.${ee} <${+W+1}.0.0-0`),o("caret return",M),M})},O=(H,B)=>(o("replaceXRanges",H,B),H.split(/\s+/).map(G=>T(G,B)).join(" ")),T=(H,B)=>{H=H.trim();const G=B.loose?c[u.XRANGELOOSE]:c[u.XRANGE];return H.replace(G,(z,Q,W,D,ee,F)=>{if(o("xRange",H,z,Q,W,D,ee,F),w(W,D,ee))return H;const M=I(W),U=M||I(D),q=U||I(ee),te=q;return Q==="="&&te&&(Q=""),F=B.includePrerelease?"-0":"",M?Q===">"||Q==="<"?z="<0.0.0-0":z="*":Q&&te?(U&&(D=0),ee=0,Q===">"?(Q=">=",U?(W=+W+1,D=0,ee=0):(D=+D+1,ee=0)):Q==="<="&&(Q="<",U?W=+W+1:D=+D+1),Q==="<"&&(F="-0"),z=`${Q+W}.${D}.${ee}${F}`):U?z=`>=${W}.0.0${F} <${+W+1}.0.0-0`:q&&(z=`>=${W}.${D}.0${F} <${W}.${+D+1}.0-0`),o("xRange return",z),z})},R=(H,B)=>(o("replaceStars",H,B),H.trim().replace(c[u.STAR],"")),A=(H,B)=>(o("replaceGTE0",H,B),H.trim().replace(c[B.includePrerelease?u.GTE0PRE:u.GTE0],"")),E=H=>(B,G,z,Q,W,D,ee,F,M,U,q,te)=>(I(z)?G="":I(Q)?G=`>=${z}.0.0${H?"-0":""}`:I(W)?G=`>=${z}.${Q}.0${H?"-0":""}`:D?G=`>=${G}`:G=`>=${G}${H?"-0":""}`,I(M)?F="":I(U)?F=`<${+M+1}.0.0-0`:I(q)?F=`<${M}.${+U+1}.0-0`:te?F=`<=${M}.${U}.${q}-${te}`:H?F=`<${M}.${U}.${+q+1}-0`:F=`<=${F}`,`${G} ${F}`.trim()),$=(H,B,G)=>{for(let z=0;z<H.length;z++)if(!H[z].test(B))return!1;if(B.prerelease.length&&!G.includePrerelease){for(let z=0;z<H.length;z++)if(o(H[z].semver),H[z].semver!==a.ANY&&H[z].semver.prerelease.length>0){const Q=H[z].semver;if(Q.major===B.major&&Q.minor===B.minor&&Q.patch===B.patch)return!0}return!1}return!0};return Yf}var Zf,Ky;function gh(){if(Ky)return Zf;Ky=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(u,h){if(h=n(h),u instanceof t){if(u.loose===!!h.loose)return u;u=u.value}u=u.trim().split(/\s+/).join(" "),o("comparator",u,h),this.options=h,this.loose=!!h.loose,this.parse(u),this.semver===e?this.value="":this.value=this.operator+this.semver.version,o("comp",this)}parse(u){const h=this.options.loose?s[r.COMPARATORLOOSE]:s[r.COMPARATOR],p=u.match(h);if(!p)throw new TypeError(`Invalid comparator: ${u}`);this.operator=p[1]!==void 0?p[1]:"",this.operator==="="&&(this.operator=""),p[2]?this.semver=new l(p[2],this.options.loose):this.semver=e}toString(){return this.value}test(u){if(o("Comparator.test",u,this.options.loose),this.semver===e||u===e)return!0;if(typeof u=="string")try{u=new l(u,this.options)}catch{return!1}return a(u,this.operator,this.semver,this.options)}intersects(u,h){if(!(u instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new c(u.value,h).test(this.value):u.operator===""?u.value===""?!0:new c(this.value,h).test(u.semver):(h=n(h),h.includePrerelease&&(this.value==="<0.0.0-0"||u.value==="<0.0.0-0")||!h.includePrerelease&&(this.value.startsWith("<0.0.0")||u.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&u.operator.startsWith(">")||this.operator.startsWith("<")&&u.operator.startsWith("<")||this.semver.version===u.semver.version&&this.operator.includes("=")&&u.operator.includes("=")||a(this.semver,"<",u.semver,h)&&this.operator.startsWith(">")&&u.operator.startsWith("<")||a(this.semver,">",u.semver,h)&&this.operator.startsWith("<")&&u.operator.startsWith(">")))}}Zf=t;const n=Rv(),{safeRe:s,t:r}=Rc(),a=$5(),o=mh(),l=xs(),c=br();return Zf}var Xf,Yy;function vh(){if(Yy)return Xf;Yy=1;const e=br();return Xf=(n,s,r)=>{try{s=new e(s,r)}catch{return!1}return s.test(n)},Xf}var Jf,Zy;function SO(){if(Zy)return Jf;Zy=1;const e=br();return Jf=(n,s)=>new e(n,s).set.map(r=>r.map(a=>a.value).join(" ").trim().split(" ")),Jf}var Qf,Xy;function _O(){if(Xy)return Qf;Xy=1;const e=xs(),t=br();return Qf=(s,r,a)=>{let o=null,l=null,c=null;try{c=new t(r,a)}catch{return null}return s.forEach(d=>{c.test(d)&&(!o||l.compare(d)===-1)&&(o=d,l=new e(o,a))}),o},Qf}var em,Jy;function kO(){if(Jy)return em;Jy=1;const e=xs(),t=br();return em=(s,r,a)=>{let o=null,l=null,c=null;try{c=new t(r,a)}catch{return null}return s.forEach(d=>{c.test(d)&&(!o||l.compare(d)===1)&&(o=d,l=new e(o,a))}),o},em}var tm,Qy;function CO(){if(Qy)return tm;Qy=1;const e=xs(),t=br(),n=ph();return tm=(r,a)=>{r=new t(r,a);let o=new e("0.0.0");if(r.test(o)||(o=new e("0.0.0-0"),r.test(o)))return o;o=null;for(let l=0;l<r.set.length;++l){const c=r.set[l];let d=null;c.forEach(u=>{const h=new e(u.semver.version);switch(u.operator){case">":h.prerelease.length===0?h.patch++:h.prerelease.push(0),h.raw=h.format();case"":case">=":(!d||n(h,d))&&(d=h);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${u.operator}`)}}),d&&(!o||n(o,d))&&(o=d)}return o&&r.test(o)?o:null},tm}var nm,ew;function IO(){if(ew)return nm;ew=1;const e=br();return nm=(n,s)=>{try{return new e(n,s).range||"*"}catch{return null}},nm}var sm,tw;function Dv(){if(tw)return sm;tw=1;const e=xs(),t=gh(),{ANY:n}=t,s=br(),r=vh(),a=ph(),o=Mv(),l=Ov(),c=Lv();return sm=(u,h,p,m)=>{u=new e(u,m),h=new s(h,m);let g,v,b,x,y;switch(p){case">":g=a,v=l,b=o,x=">",y=">=";break;case"<":g=o,v=c,b=a,x="<",y="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(r(u,h,m))return!1;for(let C=0;C<h.set.length;++C){const S=h.set[C];let I=null,w=null;if(S.forEach(_=>{_.semver===n&&(_=new t(">=0.0.0")),I=I||_,w=w||_,g(_.semver,I.semver,m)?I=_:b(_.semver,w.semver,m)&&(w=_)}),I.operator===x||I.operator===y||(!w.operator||w.operator===x)&&v(u,w.semver))return!1;if(w.operator===y&&b(u,w.semver))return!1}return!0},sm}var rm,nw;function EO(){if(nw)return rm;nw=1;const e=Dv();return rm=(n,s,r)=>e(n,s,">",r),rm}var im,sw;function NO(){if(sw)return im;sw=1;const e=Dv();return im=(n,s,r)=>e(n,s,"<",r),im}var am,rw;function jO(){if(rw)return am;rw=1;const e=br();return am=(n,s,r)=>(n=new e(n,r),s=new e(s,r),n.intersects(s,r)),am}var om,iw;function TO(){if(iw)return om;iw=1;const e=vh(),t=vr();return om=(n,s,r)=>{const a=[];let o=null,l=null;const c=n.sort((p,m)=>t(p,m,r));for(const p of c)e(p,s,r)?(l=p,o||(o=p)):(l&&a.push([o,l]),l=null,o=null);o&&a.push([o,null]);const d=[];for(const[p,m]of a)p===m?d.push(p):!m&&p===c[0]?d.push("*"):m?p===c[0]?d.push(`<=${m}`):d.push(`${p} - ${m}`):d.push(`>=${p}`);const u=d.join(" || "),h=typeof s.raw=="string"?s.raw:String(s);return u.length<h.length?u:s},om}var lm,aw;function RO(){if(aw)return lm;aw=1;const e=br(),t=gh(),{ANY:n}=t,s=vh(),r=vr(),a=(h,p,m={})=>{if(h===p)return!0;h=new e(h,m),p=new e(p,m);let g=!1;e:for(const v of h.set){for(const b of p.set){const x=c(v,b,m);if(g=g||x!==null,x)continue e}if(g)return!1}return!0},o=[new t(">=0.0.0-0")],l=[new t(">=0.0.0")],c=(h,p,m)=>{if(h===p)return!0;if(h.length===1&&h[0].semver===n){if(p.length===1&&p[0].semver===n)return!0;m.includePrerelease?h=o:h=l}if(p.length===1&&p[0].semver===n){if(m.includePrerelease)return!0;p=l}const g=new Set;let v,b;for(const k of h)k.operator===">"||k.operator===">="?v=d(v,k,m):k.operator==="<"||k.operator==="<="?b=u(b,k,m):g.add(k.semver);if(g.size>1)return null;let x;if(v&&b){if(x=r(v.semver,b.semver,m),x>0)return null;if(x===0&&(v.operator!==">="||b.operator!=="<="))return null}for(const k of g){if(v&&!s(k,String(v),m)||b&&!s(k,String(b),m))return null;for(const N of p)if(!s(k,String(N),m))return!1;return!0}let y,C,S,I,w=b&&!m.includePrerelease&&b.semver.prerelease.length?b.semver:!1,_=v&&!m.includePrerelease&&v.semver.prerelease.length?v.semver:!1;w&&w.prerelease.length===1&&b.operator==="<"&&w.prerelease[0]===0&&(w=!1);for(const k of p){if(I=I||k.operator===">"||k.operator===">=",S=S||k.operator==="<"||k.operator==="<=",v){if(_&&k.semver.prerelease&&k.semver.prerelease.length&&k.semver.major===_.major&&k.semver.minor===_.minor&&k.semver.patch===_.patch&&(_=!1),k.operator===">"||k.operator===">="){if(y=d(v,k,m),y===k&&y!==v)return!1}else if(v.operator===">="&&!k.test(v.semver))return!1}if(b){if(w&&k.semver.prerelease&&k.semver.prerelease.length&&k.semver.major===w.major&&k.semver.minor===w.minor&&k.semver.patch===w.patch&&(w=!1),k.operator==="<"||k.operator==="<="){if(C=u(b,k,m),C===k&&C!==b)return!1}else if(b.operator==="<="&&!k.test(b.semver))return!1}if(!k.operator&&(b||v)&&x!==0)return!1}return!(v&&S&&!b&&x!==0||b&&I&&!v&&x!==0||_||w)},d=(h,p,m)=>{if(!h)return p;const g=r(h.semver,p.semver,m);return g>0?h:g<0||p.operator===">"&&h.operator===">="?p:h},u=(h,p,m)=>{if(!h)return p;const g=r(h.semver,p.semver,m);return g<0?h:g>0||p.operator==="<"&&h.operator==="<="?p:h};return lm=a,lm}var cm,ow;function AO(){if(ow)return cm;ow=1;const e=Rc(),t=Tc(),n=xs(),s=O5(),r=Da(),a=oO(),o=lO(),l=cO(),c=dO(),d=uO(),u=hO(),h=fO(),p=mO(),m=vr(),g=pO(),v=gO(),b=Av(),x=vO(),y=bO(),C=ph(),S=Mv(),I=D5(),w=P5(),_=Lv(),k=Ov(),N=$5(),L=xO(),O=yO(),T=gh(),R=br(),A=vh(),E=SO(),$=_O(),H=kO(),B=CO(),G=IO(),z=Dv(),Q=EO(),W=NO(),D=jO(),ee=TO(),F=RO();return cm={parse:r,valid:a,clean:o,inc:l,diff:c,major:d,minor:u,patch:h,prerelease:p,compare:m,rcompare:g,compareLoose:v,compareBuild:b,sort:x,rsort:y,gt:C,lt:S,eq:I,neq:w,gte:_,lte:k,cmp:N,coerce:L,truncate:O,Comparator:T,Range:R,satisfies:A,toComparators:E,maxSatisfying:$,minSatisfying:H,minVersion:B,validRange:G,outside:z,gtr:Q,ltr:W,intersects:D,simplifyRange:ee,subset:F,SemVer:n,re:e.re,src:e.src,tokens:e.t,SEMVER_SPEC_VERSION:t.SEMVER_SPEC_VERSION,RELEASE_TYPES:t.RELEASE_TYPES,compareIdentifiers:s.compareIdentifiers,rcompareIdentifiers:s.rcompareIdentifiers},cm}var MO=AO();const dm=th(MO);function LO(e){if(!e||/[\\\u0000-\u001f\u007f]/.test(e))return null;if(/^\/docs(?:\/|$|[?#])/.test(e)&&!/%(?:2f|5c|00|2e)/i.test(e)){const t=new URL(e,"https://notes.invalid");if(/^\/docs(?:\/|$)/.test(t.pathname))return e}if(/^https?:\/\//i.test(e))try{const t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?e:null}catch{return null}return null}function B5({body:e}){return i.jsx("div",{className:"oc-notes-markdown",children:i.jsx(l5,{remarkPlugins:[L5],skipHtml:!0,components:{a:({href:t,children:n})=>{const s=LO(t);return s?i.jsx("a",{href:s,rel:"noopener noreferrer",target:"_blank",children:n}):i.jsx("span",{children:n})},img:({alt:t})=>i.jsx("span",{children:t??""})},children:e})})}function lw({section:e}){return i.jsxs("div",{className:"oc-notes-entry",children:[i.jsxs("h4",{children:[e.version,e.date?` · ${e.date}`:""]}),i.jsx(B5,{body:e.body})]})}function lg(e,t){const n=t==="installed"?"已安装版本":"目标版本";switch(e?.reason){case"download-timeout":return"获取目标版本说明超时,请重试。";case"download-failed":return"目标版本说明下载失败,请重试。";case"invalid-package":return"获取到的版本包未通过校验,暂时无法显示说明。";case"changelog-too-large":return"更新说明文件过大,暂时无法读取。";case"read-failed":return`${n}更新说明读取失败,请重试。`;case"missing-changelog":return`${n}包未包含更新说明文件。`;case"missing-section":return"此版本无独立说明:包内未记录与该版本号对应的章节。";case"invalid-candidate":return"目标版本暂不可查询,请先检查更新后重试。";case"check-failed":return"暂时无法确认目标版本,请先检查更新后重试。";default:return!e||e.status==="unavailable"?`${n}说明暂时不可用,请重试。`:"此版本无独立说明。"}}function cw({notes:e,kind:t}){const n=t==="installed"?e.installedVersion:e.targetVersion,r=e.source===t&&(e.status==="ok"||e.status==="not-documented"&&e.reason==="missing-section")&&!!(n&&dm.valid(n)===n)?e.sections.filter(l=>dm.valid(l.version)===l.version&&dm.lte(l.version,n)):[],a=r.find(l=>l.version===n),o=r.filter(l=>l!==a&&l.version!=="Unreleased");return i.jsxs("section",{className:"oc-notes-panel","aria-label":t==="installed"?"已安装版本更新说明":"目标版本更新说明",children:[i.jsx("h3",{children:t==="installed"?"已安装版本更新说明":"目标版本更新说明"}),i.jsxs("p",{className:"oc-notes-source",children:["来源:",t==="installed"?"运行中已安装包":"npm 已发布目标包"]}),a?i.jsxs(i.Fragment,{children:[i.jsxs("h4",{children:[t==="installed"?"本版本说明":"目标版本说明"," · ",n]}),i.jsx(B5,{body:a.body})]}):i.jsxs("p",{role:"status",children:[lg(e,t),t==="installed"&&o.length>0?"可展开下方历史版本说明;这些记录不代表本版本的变化。":""]}),t==="installed"&&o.length>0?i.jsxs("details",{className:"oc-notes-history",children:[i.jsxs("summary",{children:["展开历史版本说明(",Math.min(o.length,10)," 条)"]}),i.jsx("p",{children:"只包含已安装包内保留的章节。"}),o.slice(0,10).map(l=>i.jsx(lw,{section:l},l.version))]}):null,t==="candidate"&&o.length>0?i.jsxs("div",{className:"oc-notes-intermediate",children:[i.jsx("h4",{children:"中间版本章节"}),o.map(l=>i.jsx(lw,{section:l},l.version))]}):null]})}const dw="loop-workspace-initialization-changed",F5="*",OO={"not-initialized":"未初始化",ready:"已就绪","update-available":"有更新","needs-attention":"需要处理",error:"检查失败"},sd=["LOW","MED","HIGH"];function DO(e,t){const[n,s]=f.useState({workspaceId:""}),[r,a]=f.useState(0),o=f.useRef(!1),l=()=>{o.current=!0,a(c=>c+1)};return f.useEffect(()=>{const c=d=>{const u=d.detail;(u===t||u===F5)&&l()};return window.addEventListener(dw,c),()=>window.removeEventListener(dw,c)},[t]),f.useEffect(()=>{if(!t)return;let c=!0;const d=new AbortController,u=o.current;return o.current=!1,(async()=>{try{const p=await fetch(`${e}/api/operator/v1/workspace-initialization?workspaceId=${encodeURIComponent(t)}${u?"&refresh=1":""}`,{credentials:"same-origin",signal:d.signal}),m=await p.json();if(!p.ok||m.initialization?.workspaceId!==t)throw new Error(m.error?.message??"工作区配置检查失败,请重新检查");if(!c)return;s({workspaceId:t,value:m.initialization})}catch(p){c&&s({workspaceId:t,error:p instanceof Error?p.message:"检查失败"})}})(),()=>{c=!1,d.abort()}},[e,t,r]),{...n.workspaceId===t?n:{workspaceId:t??""},recheck:l}}function PO(e){const{value:t,error:n,recheck:s}=DO(e.origin,e.workspaceId),[r,a]=f.useState(!1),[o,l]=f.useState({workspaceId:"",message:""}),[c,d]=f.useState(!1),[u,h]=f.useState(null),[p,m]=f.useState([]),[g,v]=f.useState({}),[b,x]=f.useState({LOW:"",MED:"",HIGH:""}),[y,C]=f.useState("loading"),[S,I]=f.useState(null);f.useEffect(()=>{if(!e.workspaceId)return;let T=!0;const R=new AbortController;C("loading"),I(null);const A=`workspaceId=${encodeURIComponent(e.workspaceId)}`;return Promise.all([fetch(`${e.origin}/api/operator/v1/workspace-initialization/model-catalog?${A}`,{credentials:"same-origin",signal:R.signal}).then(E=>E.json().then($=>({response:E,body:$}))),fetch(`${e.origin}/api/operator/v1/settings/effective?${A}`,{credentials:"same-origin",signal:R.signal}).then(E=>E.json().then($=>({response:E,body:$})))]).then(([E,$])=>{const H=E.body,B=$.body;if(!E.response.ok||!$.response.ok)throw new Error(H.error?.message??B.error?.message??"初始化模型目录读取失败");const G=(H.catalog?.models??[]).filter(W=>typeof W.reference=="string"&&W.eligibleForHarness===!0).map(W=>({reference:W.reference,...W.name?{name:W.name}:{}})),z={LOW:"",MED:"",HIGH:""},Q={};for(const W of B.config?.models??[]){if(!sd.includes(W.tier))continue;const D=W.tier;typeof W.value=="string"&&(z[D]=W.value),typeof W.source=="string"&&(Q[D]=W.source)}T&&(m(G),x(z),v(Q),C("ready"),G.length===0&&I("当前没有可用于初始化的已认证 Pi 模型。"))}).catch(E=>{!T||R.signal.aborted||(C("error"),I(E instanceof Error?E.message:"初始化模型目录读取失败"))}),()=>{T=!1,R.abort()}},[e.origin,e.workspaceId]);const w=new Set(p.map(T=>T.reference)),_=sd.filter(T=>b[T]&&!w.has(b[T])),k=sd.filter(T=>!b[T]);if(!e.workspaceId)return null;const N=t?[`请审查工作区 ${JSON.stringify(t.name)} 的旧版初始化记录。目标路径:${JSON.stringify(t.displayPath)}。`,"手动调用 /skill:init-update,先只读审计,再使用 loop-agent init upgrade 的受控迁移流程;保留项目自定义内容和有效模型配置,无法确定的取舍需确认。",...t.pendingItems.map(T=>JSON.stringify({path:T.path,reason:T.reason,nextStep:T.nextStep}))].join(`
|
|
46
46
|
`):"",L=async()=>{d(!0),h(null);try{if(k.length>0){h(`请选择完整的模型档位,缺少:${k.join(", ")}`);return}if(_.length>0){h(`所选模型已不可用,请重新选择:${_.join(", ")}`);return}const T=await e.runAction?.("workspaceInitialize",{modelSelection:b},{clientRequestId:`workspace-init-${Date.now()}`}),R=T&&typeof T=="object"?T:void 0,A=R?.ok===!1;h(A?`${R?.error?.code?`${R.error.code}:`:""}${R?.error?.message??"初始化失败,请查看操作记录。"}`:"工作区初始化完成,正在刷新状态…"),A||s()}catch(T){h(T instanceof Error?T.message:"初始化失败")}finally{d(!1)}},O=async()=>{const T=e.workspaceId??"";try{await navigator.clipboard.writeText(N),l({workspaceId:T,message:"已复制,可粘贴到对话页。"})}catch{l({workspaceId:T,message:"复制失败,请手动复制下方说明。"})}};return i.jsxs("details",{className:"workspace-init-card oc-maintenance",open:r,onToggle:T=>a(T.currentTarget.open),children:[i.jsxs("summary",{tabIndex:0,children:[i.jsxs("span",{children:["当前工作区",i.jsx("small",{children:"初始化与配置"})]}),i.jsx("span",{className:"oc-maintenance-count",children:t?OO[t.state]:"检查中"})]}),r?i.jsxs(i.Fragment,{children:[i.jsx("p",{className:"workspace-init-help",children:"可在这里显式写入最小项目配置和 repo-local bridge;工作流内置 Skills 无需初始化,也不会在打开项目或 Pi 模式中自动写入。"}),t?i.jsxs("div",{className:"workspace-init-identity",children:[i.jsx("strong",{children:t.name}),i.jsx("code",{children:t.displayPath})]}):null,i.jsx("p",{role:"status",children:n??u??t?.message}),i.jsx("div",{className:"workspace-init-model-grid","aria-label":"初始化模型档位",children:sd.map(T=>i.jsxs("label",{children:[i.jsx("span",{children:T}),i.jsxs("select",{value:b[T],disabled:c||y!=="ready",onChange:R=>x(A=>({...A,[T]:R.target.value})),children:[i.jsx("option",{value:"",children:"请选择模型"}),b[T]&&!p.some(R=>R.reference===b[T])?i.jsxs("option",{value:b[T],children:[b[T],"(当前不可用)"]}):null,p.map(R=>i.jsx("option",{value:R.reference,children:R.name?`${R.name} · ${R.reference}`:R.reference},R.reference))]}),i.jsx("small",{children:g[T]?`来源:${g[T]}`:"未配置"})]},T))}),y==="loading"?i.jsx("p",{role:"status",children:"正在读取可用模型…"}):null,S?i.jsx("p",{className:"oc-settings-error",role:y==="error"?"alert":"status",children:S}):null,i.jsxs("div",{className:"workspace-init-actions",children:[i.jsx("button",{type:"button",disabled:c||!e.runAction||y!=="ready"||k.length>0||_.length>0,onClick:()=>{L()},children:c?"初始化中…":"手动初始化工作区"}),i.jsx("button",{type:"button",onClick:s,children:"重新检查"}),t?.hasLegacyInitialization?i.jsx("button",{type:"button",onClick:()=>{O()},children:"复制迁移说明"}):null]}),t?.pendingItems.length?i.jsx("ul",{className:"oc-maintenance-items",children:t.pendingItems.map((T,R)=>i.jsxs("li",{children:[i.jsx("code",{children:T.path}),i.jsx("p",{children:T.reason}),i.jsx("p",{children:T.nextStep})]},R))}):null,o.workspaceId===e.workspaceId?i.jsx("p",{role:"status",children:o.message}):null,t?.hasLegacyInitialization&&N?i.jsxs("details",{className:"oc-maintenance-instructions",children:[i.jsx("summary",{children:"查看迁移说明"}),i.jsx("pre",{className:"workspace-init-instructions",children:N})]}):null]}):null]})}function $O(e,t){const n=Number.isFinite(e)?Math.max(0,e):0,[s,r,a]=n>=8?[99,99,1]:n>=7?[94,99,3e4]:n>=6?[88,93,2e4]:n>=4?[75,87,15e3]:n>=2?[18,74,6e4]:n>=1?[8,17,1e4]:[2,7,5e3],o=Number.isFinite(t)?Math.max(0,t):0;return Math.min(99,Math.floor(s+(r-s)*o/(o+a)))}function um(e){return/failed to fetch|networkerror|load failed/i.test(e instanceof Error?e.message:String(e??""))}let ls=null;const hm=new Map,fm=new Map;function uw(e){const t=hm.get(e.operationId);if(t)return t;const n=Bp(e.operationId,6e5,e.workspaceId).finally(()=>hm.delete(e.operationId));return hm.set(e.operationId,n),n}function BO(e,t){Lk({schemaVersion:1,operationId:e.operationId,previousConsoleInstanceId:e.previousConsoleInstanceId,workspaceId:e.workspaceId??null,startedAt:e.startedAt,channel:e.channel})}function z5(e){const[t,n]=f.useState(ls?"running":"idle"),[s,r]=f.useState(!1),[a,o]=f.useState(!!ls),[l,c]=f.useState(null),d=l??e.versionInfo?.currentChannel??"latest",u=e.versionInfo?.channels.find(E=>E.channel===d),[h,p]=f.useState(ls?Math.round((Date.now()-ls.startedAt)/1e3):0),[m,g]=f.useState(null),[v,b]=f.useState(null),[x,y]=f.useState({schemaVersion:1,stage:"preflight",completedUnits:0,totalUnits:8,percent:0,message:"正在准备更新…"}),C=f.useRef(Date.now()),S=f.useRef(null),I=f.useRef(0),w=f.useRef(ls?.startedAt??0),_=f.useRef(ls?.previousConsoleInstanceId??null),k=(E,$,H)=>{const B=$??"anonymous";let G=fm.get(B);G||(G=Ok({expectedConsoleInstanceId:H?.expectedConsoleInstanceId??null,previousConsoleInstanceId:_.current,onTargetReady:()=>Fp()}).then(z=>(z||fm.delete(B),z)),fm.set(B,G)),G.then(z=>{z||I.current===E&&g("等待新 Console 就绪超时。请保留本页并稍后刷新;若长时间无响应,可在终端重新运行 agent-worker web。")})},N=(E,$,H)=>{S.current?.(),S.current=null;const B=iE(H);if(B.phase==="failed"){ls=null;const G=pr(`${H?.errorCode??""} ${H?.errorMessage??""}`.trim()||"更新失败");b({ok:!1,lines:B.lines}),g(G),Lk({schemaVersion:1,operationId:$??"unknown",previousConsoleInstanceId:_.current??"",workspaceId:e.workspaceId??null,startedAt:w.current||Date.now(),channel:hx()?.channel??d,outcome:{phase:"failed",lines:B.lines,errorText:G}});return}b({ok:!0,lines:B.lines}),k(E,$,{...B.expectedConsoleInstanceId?{expectedConsoleInstanceId:B.expectedConsoleInstanceId}:{}})},L=f.useRef(!1),O=E=>{let $;try{$=B8}catch{return}if(typeof $!="function")return;S.current?.();const H=I.current;S.current=$(E,B=>{I.current===H&&y(G=>B.completedUnits<G.completedUnits?G:(B.completedUnits>G.completedUnits&&(C.current=Date.now()),B))},e.workspaceId)};f.useEffect(()=>{if(L.current)return;const E=ls?{...ls,outcome:void 0}:hx();if(!E)return;if(E.channel&&c(E.channel),E.outcome?.phase==="failed"){n("done"),o(!1),b({ok:!1,lines:E.outcome.lines}),E.outcome.errorText&&g(E.outcome.errorText);return}if(E.outcome?.phase==="done"){n("done"),o(!1),b({ok:!0,lines:E.outcome.lines});return}ls={operationId:E.operationId,previousConsoleInstanceId:E.previousConsoleInstanceId,workspaceId:E.workspaceId??e.workspaceId,startedAt:E.startedAt,channel:E.channel},_.current=E.previousConsoleInstanceId,w.current=E.startedAt,o(!0),n("running");const $=++I.current,H=E.operationId;return O(H),uw(ls).then(B=>{I.current===$&&(ls=null,o(!1),n("done"),N($,H,B))}).catch(B=>{if(I.current===$){if(ls=null,o(!1),n("done"),um(B)){b({ok:!0,lines:["连接已切换,正在等待新 Console 就绪并刷新…"]}),k($,H);return}g(B instanceof Error?B.message:String(B))}}),()=>S.current?.()},[]),f.useEffect(()=>{if(t!=="running")return;const E=setInterval(()=>{const $=w.current;$>0&&p(Math.floor((Date.now()-$)/1e3))},500);return()=>clearInterval(E)},[t]),f.useEffect(()=>()=>S.current?.(),[]);const T=()=>{r(!1),S.current?.(),S.current=null;const E=++I.current;Fp(),o(!0),n("running"),g(null),b(null),y({schemaVersion:1,stage:"preflight",completedUnits:0,totalUnits:8,percent:0,message:"正在准备更新…"}),p(0),C.current=Date.now(),w.current=Date.now(),L.current=!0,(async()=>{let $;try{const Q=await fetch(`/api/health?ts=${Date.now()}`,{cache:"no-store",signal:AbortSignal.timeout(5e3)}),W=Q.ok?await Q.json():null;if($=typeof W?.consoleInstanceId=="string"?W.consoleInstanceId.trim():"",!$)throw new Error("missing instance identity")}catch{throw new Error("无法确认当前 Console 实例,尚未提交更新,请稍后重试。")}_.current=$;const H=await ko("consoleUpdateAndInit",{channel:d,acknowledgeInterruption:!0},`console-update-${globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(36).slice(2)}`}`,e.workspaceId),B=H.body?.operationId;if(!B){n("done"),o(!1),g(pr(H.body?.error?.message??H.body?.message??"更新操作未被接受"));return}const G={operationId:B,previousConsoleInstanceId:$,workspaceId:e.workspaceId,startedAt:Date.now(),channel:d};ls=G,BO(G),O(B);let z;try{z=await uw(G)}catch(Q){if(!um(Q))throw Q;if(I.current!==E)return;ls=null,o(!1),n("done"),b({ok:!0,lines:["连接已切换,正在等待新 Console 就绪并刷新…"]}),k(E,B);return}I.current===E&&(ls=null,o(!1),n("done"),N(E,B,z))})().catch($=>{if(ls=null,o(!1),n("done"),um($)){b({ok:!0,lines:["连接已切换,正在等待新 Console 就绪并刷新…"]}),k(E,null);return}g($ instanceof Error?$.message:String($??"更新失败"))})},R=$O(x.completedUnits,Date.now()-C.current),A=a||t==="running";return i.jsxs("div",{className:"console-update-control","aria-live":"polite",children:[i.jsx("div",{className:"oc-version-channels",role:"group","aria-label":"更新渠道",children:["latest","next"].map(E=>{const $=e.versionInfo?.channels.find(B=>B.channel===E),H=E==="latest"?"稳定版":"预发布版";return i.jsxs("button",{type:"button",className:`oc-version-channel${d===E?" is-selected":""}`,"aria-pressed":d===E,disabled:A,onClick:()=>c(E),children:[i.jsxs("span",{className:"oc-version-channel-top",children:[i.jsxs("strong",{children:[H," ",i.jsx("small",{children:E})]}),i.jsx("span",{className:"oc-version-radio","aria-hidden":"true"})]}),i.jsx("span",{className:"oc-version-description",children:E==="latest"?"正式发布,适合日常使用。":"提前体验新功能,可能存在不稳定行为。"}),i.jsxs("span",{className:"oc-version-target",children:[i.jsx("code",{children:$?.version??"—"}),i.jsx("span",{children:$?$.status==="newer"?"有新版本":$.status==="current"?"当前版本":$.status==="ahead"?"低于当前版本":"检查失败":"等待检查"})]})]},E)})}),i.jsx("p",{className:"oc-version-hint",children:d==="next"?"next 更新更频繁;切换前请先保存工作。":"推荐使用 latest。稳定版低于当前版本时不会自动降级。"}),i.jsx("button",{type:"button",className:"console-update-button",disabled:A||!u||u.status==="unavailable"||u.status==="current"||d==="latest"&&u.status==="ahead",onClick:()=>r(!0),children:a||t==="running"?"正在更新…":v?.ok===!1?`重试更新到 ${d}`:u?.status==="current"?"已是此渠道版本":u?.status==="ahead"&&d==="next"?"切换到 next 版本":`更新到 ${d}`}),s&&!A?i.jsxs("div",{className:"console-update-result",role:"group","aria-label":"更新确认",children:[i.jsxs("p",{children:["更新到 ",d,":",u?.version]}),i.jsx("p",{children:"更新会重新启动 Console,可能中断所有工作区中的对话、DAG 和 Worker 任务。尚未保存的回复和执行结果可能丢失,任务可能需要手动恢复。"}),i.jsx("p",{children:"确认后将立即开始更新,不再因任务正在执行而阻止本次操作。"}),i.jsx("button",{type:"button",onClick:()=>r(!1),children:"取消"}),i.jsx("button",{type:"button",className:"console-update-confirm",onClick:T,children:"确认风险并更新"})]}):null,t==="running"?i.jsxs("div",{className:"console-update-progress",role:"status","aria-live":"polite",children:[i.jsxs("div",{className:"console-update-progress-label",children:[i.jsx("span",{children:x.message}),i.jsxs("span",{children:[R,"%"]})]}),i.jsxs("p",{children:["已用时 ",h," 秒"]}),i.jsx("div",{className:"console-update-progress-track",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":R,"aria-valuetext":`${x.message},${R}%`,children:i.jsx("span",{className:"console-update-progress-fill",style:{width:`${R}%`}})})]}):null,v?i.jsx("div",{className:`console-update-result${v.ok?"":" console-update-result-error"}`,role:"status",children:v.lines.map(E=>i.jsx("p",{children:E},E))}):null,m?i.jsx("p",{className:"console-update-error",role:"alert",children:m}):null]})}const H5="loop-console.operator-chat.transcript-mode.v1";function FO(e){return e==="compact"||e==="full"?e:null}function q5(e){try{return FO(e?.getItem(H5))??"compact"}catch{return"compact"}}function zO(e,t){try{t?.setItem(H5,e)}catch{}return e}const U5="loop-console.chat-font-size.v2",Mo={text:{variable:"--oc-chat-font-body",min:10,max:22,default:14},code:{variable:"--oc-chat-font-mono",min:10,max:16,default:12}},mm={text:Mo.text.default,code:Mo.code.default},HO=22/14;function dc(e,t){const n=Mo[e];return Number.isFinite(t)?Math.min(n.max,Math.max(n.min,Math.round(t))):n.default}function W5(){if(typeof window>"u")return mm;try{const e=window.localStorage.getItem(U5);if(!e)return mm;const t=JSON.parse(e);return{text:dc("text",typeof t.text=="number"?t.text:Mo.text.default),code:dc("code",typeof t.code=="number"?t.code:Mo.code.default)}}catch{return mm}}function qO(e){if(!(typeof window>"u"))try{window.localStorage.setItem(U5,JSON.stringify(e))}catch{}}function UO(e){const t=dc("text",e.text),n=dc("code",e.code);return{"--oc-chat-font-body":`${t}px`,"--oc-chat-line-body":`${Math.round(t*HO)}px`,"--oc-chat-font-mono":`${n}px`,"--oc-chat-line-mono":`${Math.round(n*1.55)}px`}}function cg(e,t){if(t)for(const[n,s]of Object.entries(UO(e)))t.style.setProperty(n,s)}function hw(e){const[t,n]=f.useState(()=>W5()),s=f.useRef(t);s.current=t;const r=Mo[e.role],a=t[e.role],o=f.useCallback(l=>{const c=dc(e.role,l),d={...s.current,[e.role]:c};s.current=d,n(d),qO(d),cg(d,typeof document>"u"?null:document.documentElement)},[e.role]);return f.useEffect(()=>{cg(t,typeof document>"u"?null:document.documentElement)},[t]),i.jsxs("div",{className:"oc-settings-general-row",children:[i.jsxs("div",{className:"oc-settings-general-text",children:[i.jsx("div",{className:"oc-settings-general-title",children:e.title}),i.jsx("div",{className:"oc-settings-general-desc",children:e.description})]}),i.jsxs("div",{className:"oc-settings-font-control",children:[i.jsxs("div",{className:"oc-settings-font-stepper",children:[i.jsx("span",{className:"oc-settings-font-stepper__value",children:a}),i.jsxs("span",{className:"oc-settings-font-stepper__arrows",children:[i.jsx("button",{type:"button",className:"oc-settings-font-stepper__arrow","aria-label":`${e.title}增大`,disabled:a>=r.max,onClick:()=>o(a+1),children:i.jsx(Wo,{size:9,"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"oc-settings-font-stepper__arrow","aria-label":`${e.title}减小`,disabled:a<=r.min,onClick:()=>o(a-1),children:i.jsx(us,{size:9,"aria-hidden":"true"})})]})]}),i.jsx("span",{className:"oc-settings-font-unit",children:"px"})]})]})}const V5="loop-console.session-order-mode.v1",G5="loop-console.session-order.v1",WO=[{id:"updated",label:"最近更新"},{id:"manual",label:"保持顺序"}];function fw(e){if(e==null||e==="")return null;const t=e instanceof Date?e.getTime():typeof e=="number"?e:Date.parse(e);return Number.isFinite(t)?t:null}function mw(e){return fw(e.updatedAt)??fw(e.createdAt)}function dg(e){return[...e].sort((t,n)=>{const s=mw(t),r=mw(n);return s===null&&r!==null?1:r===null&&s!==null?-1:s!==null&&r!==null&&s!==r?r-s:t.sessionId<n.sessionId?-1:t.sessionId>n.sessionId?1:0})}function VO(e,t){if(!t||t.length===0)return dg(e);const n=new Map(e.map(r=>[r.sessionId,r])),s=[];for(const r of t){const a=n.get(r);a!==void 0&&(s.push(a),n.delete(r))}return[...s,...dg([...n.values()])]}function GO(e,t,n){return t==="manual"?VO(e,n):dg(e)}function K5(){if(typeof window>"u")return"updated";try{return window.localStorage.getItem(V5)==="manual"?"manual":"updated"}catch{return"updated"}}function KO(e){if(!(typeof window>"u"))try{window.localStorage.setItem(V5,e)}catch{}}function YO(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(G5);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function ZO(e){if(!(typeof window>"u"))try{window.localStorage.setItem(G5,JSON.stringify(e))}catch{}}const XO=[{id:"full",label:"标准"},{id:"compact",label:"紧凑"}],Y5=[{id:"default",label:"默认",Icon:iN},{id:"midnight",label:"深色",Icon:yN},{id:"daylight",label:"浅色",Icon:jN}],Z5="loop-console.theme.v1";function JO(){try{const e=window.localStorage.getItem(Z5);return Y5.some(t=>t.id===e)?e:"default"}catch{return"default"}}function QO(e){document.documentElement.dataset.consoleTheme=e;try{window.localStorage.setItem(Z5,e)}catch{}return e}function pw(e){return i.jsxs("div",{className:"oc-settings-general-row",children:[i.jsxs("div",{className:"oc-settings-general-text",children:[i.jsx("div",{className:"oc-settings-general-title",children:e.title}),i.jsx("div",{className:"oc-settings-general-desc",children:e.description})]}),e.children,e.below?i.jsx("div",{className:"oc-settings-general-below",children:e.below}):null]})}function gw(e){const[t,n]=f.useState(!1),s=f.useRef(null),r=e.options.find(a=>a.id===e.value)??e.options[0];return f.useEffect(()=>{if(!t)return;const a=l=>{l.target instanceof Node&&!s.current?.contains(l.target)&&n(!1)},o=l=>{l.key==="Escape"&&n(!1)};return document.addEventListener("pointerdown",a),document.addEventListener("keydown",o),()=>{document.removeEventListener("pointerdown",a),document.removeEventListener("keydown",o)}},[t]),i.jsxs("div",{className:"oc-settings-pill-select",ref:s,children:[i.jsxs("button",{type:"button",className:"oc-settings-pill-trigger","aria-haspopup":"menu","aria-expanded":t,"aria-label":e.ariaLabel,onClick:()=>n(a=>!a),children:[r?.label??"—",i.jsx(us,{size:14,"aria-hidden":"true"})]}),t?i.jsx("div",{className:"oc-settings-pill-menu",role:"menu",children:e.options.map(a=>i.jsx("button",{type:"button",role:"menuitemradio","aria-checked":a.id===e.value,className:a.id===e.value?"is-selected":"",onClick:()=>{e.onChange(a.id),n(!1)},children:a.label},a.id))}):null]})}function eD(){const[e,t]=f.useState(()=>typeof window>"u"?"default":document.documentElement.dataset.consoleTheme??JO());return i.jsxs("div",{className:"oc-settings-appearance",children:[i.jsx("div",{className:"oc-settings-appearance-title",children:"外观"}),i.jsx("div",{className:"oc-settings-appearance-cubes",children:Y5.map(({id:n,label:s,Icon:r})=>i.jsxs("button",{type:"button",className:`oc-settings-theme-cube${e===n?" is-selected":""}`,"aria-pressed":e===n,onClick:()=>t(QO(n)),children:[i.jsx(r,{size:20,"aria-hidden":"true"}),s]},n))})]})}function tD(){const[e,t]=f.useState(()=>q5(typeof window>"u"?null:window.localStorage)),[n,s]=f.useState(()=>K5()),r=f.useCallback(()=>{if(typeof document>"u")return;const a=[...document.querySelectorAll("[data-session-id]")].map(o=>o.getAttribute("data-session-id")).filter(o=>typeof o=="string"&&o.length>0);a.length>0&&ZO(a)},[]);return i.jsxs("div",{className:"oc-settings-general",children:[i.jsx(eD,{}),i.jsx(pw,{title:"对话显示",description:"控制已完成轮次的过程内容;每轮仍可单独展开或收起。",children:i.jsx(gw,{value:e,options:XO,ariaLabel:"对话显示模式",onChange:a=>t(zO(a==="full"?"full":"compact",typeof window>"u"?null:window.localStorage))})}),i.jsx(hw,{role:"text",title:"正文字号",description:"对话正文与过程说明的字号,影响行高。"}),i.jsx(hw,{role:"code",title:"代码字号",description:"行内代码与代码块的字号,与正文分开调整。"}),i.jsx(pw,{title:"会话列表排序",description:"多个会话同时运行时,「最近更新」会让列表不断换位置;「保持顺序」只在出现新会话时插入,已有会话不再移动。",children:i.jsx(gw,{value:n,options:WO,ariaLabel:"会话列表排序",onChange:a=>{const o=a==="manual"?"manual":"updated";o==="manual"&&r(),s(o),KO(o)}})})]})}const X5="loop-console.tasks-auto-open.v1",$i={subagent:!0,jobs:!0,mobileOff:!0};function J5(){if(typeof window>"u")return $i;try{const e=window.localStorage.getItem(X5);if(!e)return $i;const t=JSON.parse(e);return{subagent:typeof t.subagent=="boolean"?t.subagent:$i.subagent,jobs:typeof t.jobs=="boolean"?t.jobs:$i.jobs,mobileOff:typeof t.mobileOff=="boolean"?t.mobileOff:$i.mobileOff}}catch{return $i}}function vw(e){if(!(typeof window>"u"))try{window.localStorage.setItem(X5,JSON.stringify(e))}catch{}}const nD=768;function sD(e){return e<nD}function rD(e,t){return e===null?!1:e===0&&t>0}function iD(e){return!e.prefs[e.kind]||e.prefs.mobileOff&&sD(e.viewportWidth)?!1:!e.detailsOpen}function aD(){const[e,t]=f.useState(()=>J5()),n=f.useCallback(r=>{t(a=>{const o={...a,[r]:!a[r]};return vw(o),o})},[]),s=[{title:"任务管理的自动打开",caption:"右侧栏在后台工作时自动出现。已经打开的侧栏不会被接管。",rows:[{key:"subagent",label:"出现子代理时自动打开",help:"会话里第一次出现子代理时,右侧栏自动打开「任务管理」。切换到已有子代理的会话不会触发。"},{key:"jobs",label:"出现后台任务时自动打开",help:"会话里出现新的后台任务时同样自动打开。与子代理不同,每新增一个任务都会触发一次。"},{key:"mobileOff",label:"窄屏不自动打开",help:"窗口宽度小于 768px 时右侧栏会覆盖整个对话区,因此这两类自动打开都会被抑制。"}]}];return i.jsxs("div",{className:"oc-rail-settings",children:[s.map(r=>i.jsxs("section",{className:"oc-rail-settings-group",children:[i.jsxs("header",{className:"oc-rail-settings-head",children:[i.jsx("strong",{children:r.title}),i.jsx("p",{children:r.caption})]}),r.rows.map(a=>i.jsxs("div",{className:"oc-settings-pet-row",children:[i.jsxs("div",{children:[i.jsx("strong",{children:a.label}),i.jsx("p",{children:a.help})]}),i.jsx("button",{type:"button",className:`oc-toggle${e[a.key]?" is-on":""}`,role:"switch","aria-checked":e[a.key],"aria-label":`${e[a.key]?"关闭":"开启"}${a.label}`,onClick:()=>n(a.key),children:i.jsx("span",{className:"oc-toggle-knob","aria-hidden":"true"})})]},a.key))]},r.title)),i.jsx("button",{type:"button",className:"oc-btn-secondary",onClick:()=>{t($i),vw($i)},children:"恢复默认"})]})}const oD="x-loop-console-confirmation";function rd(e){const t=e.trim();if(t==="")return;const n=Number(t);return Number.isFinite(n)&&n>=0?n:void 0}function ug(e){return{id:e.id,name:e.name??"",contextWindow:e.contextWindow!==void 0?String(e.contextWindow):"",maxTokens:e.maxTokens!==void 0?String(e.maxTokens):"",inputs:e.input??[],reasoning:e.reasoning??!0}}function lD(e,t){const n=ug(t);return e.name!==n.name||e.contextWindow!==n.contextWindow||e.maxTokens!==n.maxTokens||e.reasoning!==n.reasoning||e.inputs.join(",")!==n.inputs.join(",")}function Q5(e){return{id:e.id,...e.name.trim()?{name:e.name.trim()}:{},...rd(e.contextWindow)!==void 0?{contextWindow:rd(e.contextWindow)}:{},...rd(e.maxTokens)!==void 0?{maxTokens:rd(e.maxTokens)}:{},...e.inputs.length?{input:e.inputs}:{},reasoning:e.reasoning}}function cD(e){const[t,n]=f.useState(null),[s,r]=f.useState(null),[a,o]=f.useState(!1),[l,c]=f.useState(null),[d,u]=f.useState(null),h=f.useMemo(()=>{const v=e.workspaceId?.trim()?`?workspaceId=${encodeURIComponent(e.workspaceId.trim())}`:"";return`${e.origin}/api/operator/v1/pi/models-config${v}`},[e.origin,e.workspaceId]),p=f.useCallback(async()=>{r(null);try{const v=await fetch(h,{credentials:"include"}),b=await v.json();if(!v.ok||!b.data)throw new Error(b.error?.message??"读取模型配置失败");n(b.data)}catch(v){r(v instanceof Error?v.message:String(v))}},[h]);f.useEffect(()=>{p()},[p]);const m=f.useCallback(async v=>{if(!t)return!1;o(!0),u(null);try{const b=await fetch(h,{method:"PATCH",credentials:"include",headers:{"content-type":"application/json",[oD]:Rt()},body:JSON.stringify({expectedRevision:t.revision,...v})}),x=await b.json();if(!b.ok||!x.data){if(b.status===409)u("配置已被其他会话修改,已重新读取,请重试保存。"),await p();else throw new Error(x.error?.message??"模型配置保存失败");return!1}return n(x.data),!0}catch(b){return u(b instanceof Error?b.message:String(b)),!1}finally{o(!1)}},[t,h,p]),g=t?.providers??[];return s?i.jsxs("div",{className:"oc-settings-models",children:[i.jsx("p",{className:"oc-models-error",role:"alert",children:s}),i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",onClick:()=>{p()},children:"重试"})]}):t?i.jsxs("div",{className:"oc-settings-models",children:[d?i.jsx("p",{className:"oc-models-notice",role:"status",children:d}):null,g.length===0?i.jsx("div",{className:"oc-models-empty",children:"models.json 中暂无 Provider;用 Pi CLI 配置凭据后再添加模型。"}):null,g.map(v=>i.jsx(dD,{provider:v,open:l===v.name,busy:a,onToggle:()=>c(b=>b===v.name?null:v.name),onDeleted:()=>c(b=>b===v.name?null:b),onMutate:m},v.name))]}):i.jsx("div",{className:"oc-settings-models",children:i.jsx("p",{className:"oc-models-meta",children:"正在读取模型配置…"})})}function dD(e){const{provider:t,open:n,busy:s}=e,[r,a]=f.useState(t.baseUrl??""),[o,l]=f.useState(t.api??""),[c,d]=f.useState(!1);f.useEffect(()=>{a(t.baseUrl??""),l(t.api??"")},[t.baseUrl,t.api]);const u=r.trim()!==(t.baseUrl??"")||o.trim()!==(t.api??""),h=async()=>{await e.onMutate({action:"update-provider",provider:t.name,providerFields:{baseUrl:r.trim(),api:o.trim()}})&&(a(r.trim()),l(o.trim()))};return i.jsxs("div",{className:`oc-models-card${n?" is-open":""}`,children:[i.jsxs("div",{className:"oc-models-card-head",children:[i.jsxs("button",{type:"button",className:"oc-models-card-open","aria-expanded":n,onClick:e.onToggle,children:[i.jsx("span",{className:"oc-models-card-name",children:t.name}),i.jsxs("span",{className:"oc-models-card-tag",children:[t.models.length," 个模型"]}),i.jsx("span",{className:`oc-models-dot${t.credential.configured?" is-ok":""}`,title:t.credential.management==="extension"?"由 Pi 扩展管理认证":t.credential.configured?"凭据已配置(Pi CLI)":"凭据未配置"}),i.jsx("span",{className:"oc-models-card-chevron","aria-hidden":"true",children:n?i.jsx(us,{size:16}):i.jsx(Ns,{size:16})})]}),i.jsx("span",{className:"oc-models-card-hover",children:i.jsx("button",{type:"button",className:"oc-models-icon-btn is-danger","aria-label":`删除 Provider ${t.name}`,title:"删除 Provider",disabled:s,onClick:()=>{window.confirm(`确认删除 Provider ${t.name}?
|
|
47
|
-
models.json 中的该 Provider 配置(含内联字段)会被移除;auth.json 凭据不受影响。`)&&e.onMutate({action:"remove-provider",provider:t.name}).then(p=>{p&&e.onDeleted()})},children:i.jsx(zr,{size:14})})})]}),n?i.jsxs("div",{className:"oc-models-editor",children:[i.jsxs("div",{className:"oc-models-field-grid",children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"Base URL"}),i.jsx("input",{type:"text",value:r,placeholder:"默认(由 Pi CLI 配置)",disabled:s,onChange:p=>a(p.target.value)})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"协议"}),i.jsx("input",{type:"text",value:o,placeholder:"默认(如 openai)",disabled:s,onChange:p=>l(p.target.value)})]})]}),u?i.jsxs("div",{className:"oc-models-editor-actions",children:[i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",disabled:s,onClick:()=>{a(t.baseUrl??""),l(t.api??"")},children:"取消"}),i.jsxs("button",{type:"button",className:"oc-models-btn is-primary",disabled:s,onClick:()=>{h()},children:[s?i.jsx(rc,{className:"oc-spin",size:14}):null,"保存端点"]})]}):null,i.jsxs("div",{className:"oc-models-catalog",children:[i.jsxs("div",{className:"oc-models-catalog-head",children:[i.jsxs("div",{className:"oc-models-catalog-title",children:[i.jsx("span",{children:"模型"}),i.jsx("span",{className:"oc-models-meta",children:t.models.length?`${t.models.length} 个`:"暂无"})]}),i.jsxs("button",{type:"button",className:"oc-models-btn is-add-model",disabled:s,onClick:()=>d(p=>!p),children:[i.jsx(Io,{size:14,"aria-hidden":"true"}),"新增模型"]})]}),c?i.jsx(hD,{provider:t.name,busy:s,onMutate:e.onMutate,onSaved:()=>d(!1),onCancel:()=>d(!1)}):null,t.models.length===0&&!c?i.jsx("div",{className:"oc-models-empty",children:"该 Provider 暂无模型。"}):null,t.models.map(p=>i.jsx(uD,{provider:t.name,model:p,busy:s,onMutate:e.onMutate},`${t.name}/${p.id}`))]})]}):null]})}function uD(e){const{model:t,provider:n,busy:s}=e,[r,a]=f.useState(()=>ug(t)),[o,l]=f.useState(!1),[c,d]=f.useState(!1);f.useEffect(()=>{a(ug(t))},[t]);const u=lD(r,t),h=async()=>{d(!0);try{await e.onMutate({action:"upsert-model",provider:n,model:Q5(r)})}finally{d(!1)}},p=m=>{a(g=>({...g,inputs:g.inputs.includes(m)?g.inputs.filter(v=>v!==m):[...g.inputs,m]}))};return i.jsxs("div",{className:`oc-models-entry${o?" is-open":""}`,children:[i.jsxs("div",{className:"oc-models-entry-row",children:[i.jsx("input",{className:"oc-models-input is-id",type:"text",value:r.name,placeholder:"模型名称","aria-label":"模型名称",disabled:s,onChange:m=>a(g=>({...g,name:m.target.value}))}),i.jsx("input",{className:"oc-models-input is-id-code",type:"text",value:r.id,placeholder:"模型 ID","aria-label":"模型 ID",disabled:!0,title:"模型 ID 是唯一键,不可修改"}),u?i.jsx("button",{type:"button",className:`oc-models-btn is-save${c?" is-busy":""}`,disabled:s||c,"aria-label":`保存模型 ${r.id}`,title:"保存修改",onClick:()=>{h()},children:c?i.jsx(rc,{className:"oc-spin",size:14}):i.jsx(Vo,{size:14})}):null,i.jsx("button",{type:"button",className:"oc-models-icon-btn","aria-expanded":o,"aria-label":`高级字段 ${r.id}`,title:"高级字段",onClick:()=>l(m=>!m),children:o?i.jsx(us,{size:14}):i.jsx(Ns,{size:14})}),i.jsx("span",{className:"oc-models-entry-hover",children:i.jsx("button",{type:"button",className:"oc-models-icon-btn is-danger","aria-label":`删除模型 ${r.id}`,title:"删除模型",disabled:s,onClick:()=>{window.confirm(`确认删除模型 ${n}/${r.id}?`)&&e.onMutate({action:"remove-model",provider:n,model:{id:r.id}})},children:i.jsx(zr,{size:14})})})]}),o?i.jsxs("div",{className:"oc-models-entry-advanced",children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"上下文窗口"}),i.jsx("input",{type:"text",inputMode:"numeric",value:r.contextWindow,placeholder:"默认 128000",disabled:s,onChange:m=>a(g=>({...g,contextWindow:m.target.value}))})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"最大输出"}),i.jsx("input",{type:"text",inputMode:"numeric",value:r.maxTokens,placeholder:"默认 16384",disabled:s,onChange:m=>a(g=>({...g,maxTokens:m.target.value}))})]}),i.jsxs("fieldset",{className:"oc-models-field is-input-types",children:[i.jsx("legend",{className:"oc-models-field-label",children:"输入模态"}),i.jsx("div",{className:"oc-models-input-types",children:["text","image"].map(m=>i.jsxs("label",{className:"oc-models-input-choice",children:[i.jsx("input",{type:"checkbox",checked:r.inputs.includes(m),disabled:s,onChange:()=>p(m)}),m==="text"?"文本":"图像"]},m))})]}),i.jsxs("label",{className:"oc-models-field is-check",children:[i.jsx("span",{className:"oc-models-field-label",children:"推理能力"}),i.jsx("input",{type:"checkbox",checked:r.reasoning,disabled:s,onChange:m=>a(g=>({...g,reasoning:m.target.checked}))})]})]}):null]})}function hD(e){const{busy:t}=e,[n,s]=f.useState(()=>({id:"",name:"",contextWindow:"",maxTokens:"",inputs:["text"],reasoning:!0})),[r,a]=f.useState(!1),o=async c=>{if(c.preventDefault(),!!n.id.trim()){a(!0);try{await e.onMutate({action:"upsert-model",provider:e.provider,model:Q5({...n,id:n.id.trim()})})&&e.onSaved()}finally{a(!1)}}},l=c=>{s(d=>({...d,inputs:d.inputs.includes(c)?d.inputs.filter(u=>u!==c):[...d.inputs,c]}))};return i.jsxs("form",{className:"oc-models-add-card",onSubmit:c=>{o(c)},children:[i.jsx("strong",{className:"oc-models-add-title",children:"新增模型"}),i.jsxs("div",{className:"oc-models-field-grid",children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"模型 ID *"}),i.jsx("input",{type:"text",value:n.id,placeholder:"例如 gpt-6-astra",required:!0,disabled:t||r,onChange:c=>s(d=>({...d,id:c.target.value}))})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"模型名称"}),i.jsx("input",{type:"text",value:n.name,placeholder:"可选",disabled:t||r,onChange:c=>s(d=>({...d,name:c.target.value}))})]})]}),i.jsxs("div",{className:"oc-models-field-grid",children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"上下文窗口"}),i.jsx("input",{type:"text",inputMode:"numeric",value:n.contextWindow,placeholder:"默认 128000",disabled:t||r,onChange:c=>s(d=>({...d,contextWindow:c.target.value}))})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"最大输出"}),i.jsx("input",{type:"text",inputMode:"numeric",value:n.maxTokens,placeholder:"默认 16384",disabled:t||r,onChange:c=>s(d=>({...d,maxTokens:c.target.value}))})]})]}),i.jsxs("div",{className:"oc-models-field-grid",children:[i.jsxs("fieldset",{className:"oc-models-field is-input-types",children:[i.jsx("legend",{className:"oc-models-field-label",children:"输入模态"}),i.jsx("div",{className:"oc-models-input-types",children:["text","image"].map(c=>i.jsxs("label",{className:"oc-models-input-choice",children:[i.jsx("input",{type:"checkbox",checked:n.inputs.includes(c),disabled:t||r,onChange:()=>l(c)}),c==="text"?"文本":"图像"]},c))})]}),i.jsxs("label",{className:"oc-models-field is-check",children:[i.jsx("span",{className:"oc-models-field-label",children:"推理能力"}),i.jsx("input",{type:"checkbox",checked:n.reasoning,disabled:t||r,onChange:c=>s(d=>({...d,reasoning:c.target.checked}))})]})]}),i.jsxs("div",{className:"oc-models-editor-actions",children:[i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",disabled:t||r,onClick:()=>e.onCancel(),children:"取消"}),i.jsxs("button",{type:"submit",className:"oc-models-btn is-primary",disabled:t||r||!n.id.trim(),children:[r?i.jsx(rc,{className:"oc-spin",size:14}):null,"添加"]})]})]})}const bw="/api/operator/v1/pi/compaction-settings",pm=.8,xw=65536,gm=.16,fD=8192;function yw(e){const t=e.trim();if(t==="")return;const n=Number(t);return Number.isFinite(n)?n/100:Number.NaN}function mD(e){const t=e.trim();if(t!=="")return/^\d+$/.test(t)?Number(t):Number.NaN}function pD(e,t,n,s){const r=e-fD,a=r-n;if(r<=0){const c=Math.max(0,e-16384);return{thresholdTokens:c,retainTokens:Math.max(0,Math.floor(c*s))}}if(a<=0){const c=Math.max(0,e-16384);return{thresholdTokens:c,retainTokens:Math.max(0,Math.floor(c*s))}}const o=Math.floor(Math.min(e*t,a));let l=Math.floor(r*s);return l>=o&&(l=Math.max(0,o-1)),{thresholdTokens:o,retainTokens:l}}function gD(e){const[t,n]=f.useState(),[s,r]=f.useState(String(pm*100)),[a,o]=f.useState(String(xw)),[l,c]=f.useState(String(gm*100)),[d,u]=f.useState(!1),[h,p]=f.useState(),[m,g]=f.useState(),v=f.useCallback(async()=>{try{const _=await fetch(bw,{credentials:"include"}),k=await _.json();if(!_.ok||!("ok"in k)||k.ok!==!0)throw new Error("error"in k&&k.error?.message?k.error.message:`无法读取压缩设置(HTTP ${_.status})`);n(k);const N=k.effective;r(String(Math.round(N.thresholdRatio*1e3)/10)),o(String(N.headroomTokens)),c(String(Math.round(N.retainRatio*1e3)/10)),p(void 0)}catch(_){p(_ instanceof Error?_.message:String(_))}},[]);f.useEffect(()=>{v()},[v]);const b=f.useMemo(()=>yw(s),[s]),x=f.useMemo(()=>mD(a),[a]),y=f.useMemo(()=>yw(l),[l]),C=Number.isNaN(b)||Number.isNaN(x)||Number.isNaN(y)||b!==void 0&&(b<=0||b>1)||y!==void 0&&y<=0||b!==void 0&&y!==void 0&&y>=b||x!==void 0&&x<0,S=f.useCallback(async()=>{if(!(C||!t)){u(!0),p(void 0),g(void 0);try{const _={};b!==void 0&&(_.thresholdRatio=b),x!==void 0&&(_.headroomTokens=x),y!==void 0&&(_.retainRatio=y);const k=await fetch(bw,{method:"PUT",credentials:"include",headers:{"content-type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify({expectedRevision:t.revision,settings:_})}),N=await k.json();if(!k.ok||N.ok!==!0)throw new Error(N.error?.message??`保存失败(HTTP ${k.status})`);g("已保存。下一条消息开始按新设置压缩。"),await v()}catch(_){p(_ instanceof Error?_.message:String(_))}finally{u(!1)}}},[x,C,v,b,y,t]),I=typeof e.contextWindow=="number"&&e.contextWindow>0?e.contextWindow:void 0,w=f.useMemo(()=>{if(!(I===void 0||C))return pD(I,b??pm,x??xw,y??gm)},[I,x,C,b,y]);return i.jsxs("div",{className:"oc-compaction","data-testid":"pi-compaction-settings",children:[i.jsxs("div",{className:"oc-compaction-head",children:[i.jsx("span",{className:"oc-compaction-title",children:"上下文压缩"}),i.jsx("p",{className:"oc-compaction-lead",children:"上下文占用达到窗口的一定比例时开始压缩。余量留在触发线与窗口上限之间,窗口越大自动越大。"})]}),i.jsxs("div",{className:"oc-compaction-rows",children:[i.jsx("label",{className:"oc-compaction-label",htmlFor:"pi-threshold-ratio",children:i.jsxs("span",{className:"oc-compaction-label-text",children:["触发窗口比例",t?.envOverrides.thresholdRatio?i.jsx("span",{className:"oc-compaction-hint","data-testid":"threshold-ratio-env-override",children:"当前被环境变量覆盖"}):null]})}),i.jsx("input",{id:"pi-threshold-ratio",className:"oc-compaction-input",type:"number",min:5,max:100,step:1,value:s,onInput:_=>r(_.currentTarget.value),"aria-invalid":C,"data-testid":"pi-threshold-ratio-input"}),i.jsx("span",{className:"oc-compaction-unit",children:"%"}),i.jsx("label",{className:"oc-compaction-label",htmlFor:"pi-headroom-tokens",children:i.jsxs("span",{className:"oc-compaction-label-text",children:["额外余量",t?.envOverrides.headroomTokens?i.jsx("span",{className:"oc-compaction-hint","data-testid":"headroom-env-override",children:"当前被环境变量覆盖"}):null]})}),i.jsx("input",{id:"pi-headroom-tokens",className:"oc-compaction-input",type:"number",min:0,step:1024,value:a,onInput:_=>o(_.currentTarget.value),"aria-invalid":C,"data-testid":"pi-headroom-tokens-input"}),i.jsx("span",{className:"oc-compaction-unit",children:"token"}),i.jsx("label",{className:"oc-compaction-label",htmlFor:"pi-retain-ratio",children:i.jsxs("span",{className:"oc-compaction-label-text",children:["压缩后保留比例",t?.envOverrides.retainRatio?i.jsx("span",{className:"oc-compaction-hint","data-testid":"retain-ratio-env-override",children:"当前被环境变量覆盖"}):null]})}),i.jsx("input",{id:"pi-retain-ratio",className:"oc-compaction-input",type:"number",min:1,max:99,step:1,value:l,onInput:_=>c(_.currentTarget.value),"aria-invalid":C,"data-testid":"pi-retain-ratio-input"}),i.jsx("span",{className:"oc-compaction-unit",children:"%"})]}),w!==void 0?i.jsxs("p",{className:"oc-compaction-note","data-testid":"pi-compaction-effective",children:["压缩触发线 ",i.jsx("strong",{children:w.thresholdTokens})," token,压缩后保留最近"," ",i.jsx("strong",{children:w.retainTokens})," token",i.jsxs("span",{className:"oc-compaction-hint",children:["(当前模型窗口 ",I,")"]}),"。"]}):i.jsxs("p",{className:"oc-compaction-note","data-testid":"pi-compaction-effective",children:["按当前设置,触发线约为窗口的"," ",i.jsxs("strong",{children:[Math.round((b??pm)*100),"%"]}),",并保留最近 ",Math.round((y??gm)*100),"%。"]}),C?i.jsx("p",{className:"oc-compaction-error","data-testid":"pi-compaction-invalid",children:"比例需在 1–100% 之间,保留比例需小于触发比例;余量不能为负。"}):null,h?i.jsx("p",{className:"oc-compaction-error",role:"alert","data-testid":"pi-compaction-error",children:h}):null,m?i.jsx("p",{className:"oc-compaction-note",role:"status","data-testid":"pi-compaction-notice",children:m}):null,i.jsx("div",{className:"oc-compaction-actions",children:i.jsx("button",{type:"button",className:"oc-models-btn is-primary",disabled:d||C||!t,"data-testid":"pi-compaction-save",onClick:()=>{S()},children:d?"保存中…":"保存"})})]})}const vD=[{value:"environment",label:"跟随启动环境"},{value:"direct",label:"直接连接"},{value:"manual",label:"手动代理"}];function bD({origin:e}){const t=`${e.replace(/\/$/,"")}/api/operator/v1/network-proxy`,[n,s]=f.useState(null),[r,a]=f.useState(null),[o,l]=f.useState("loading"),[c,d]=f.useState(null),[u,h]=f.useState(null),[p,m]=f.useState(!1),g=f.useRef({id:0,controller:null}),v=f.useCallback(async(S=!1)=>{g.current.controller?.abort();const I=new AbortController,w=++g.current.id;g.current.controller=I,l("loading"),d(null),h(null);try{const _=await fetch(t,{credentials:"same-origin",cache:"no-store",signal:I.signal}),k=await _.json();if(I.signal.aborted||w!==g.current.id)return;if(!_.ok||!k.ok)throw new Error(k.ok?"网络设置读取失败,请重试。":k.error.message);s(k),a(N=>S&&N?N:k.settings),m(!1),S&&h("已读取最新设置,未保存的修改已保留;请核对后保存。")}catch(_){!I.signal.aborted&&w===g.current.id&&d(_ instanceof Error?_.message:"网络设置读取失败,请重试。")}finally{!I.signal.aborted&&w===g.current.id&&l("idle")}},[t]);f.useEffect(()=>(s(null),a(null),m(!1),v(),()=>{g.current.id++,g.current.controller?.abort()}),[v]);const b=!!(n&&r&&(n.settings.mode!==r.mode||n.settings.proxyUrl!==r.proxyUrl||n.settings.noProxy!==r.noProxy)),x=o!=="idle",y=S=>{a(I=>I&&{...I,...S}),h(null),p||d(null)},C=async()=>{if(!n||!r||x||p||!b)return;g.current.controller?.abort();const S=new AbortController,I=++g.current.id;g.current.controller=S,l("saving"),d(null),h(null);try{const w=await fetch(t,{method:"PUT",credentials:"same-origin",signal:S.signal,headers:{"Content-Type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify({expectedRevision:n.revision,settings:r})}),_=await w.json();if(S.signal.aborted||I!==g.current.id)return;if(w.status===409){m(!0),d("网络设置已在其他页面更新。请先重新加载最新设置;你的未保存修改会保留。");return}if(!w.ok||!_.ok)throw new Error(_.ok?"网络设置保存失败,请重试。":_.error.message);s(_),a(_.settings),h("已保存,新请求立即生效;当前回复保持原连接。尚未验证模型连通性。")}catch(w){!S.signal.aborted&&I===g.current.id&&d(w instanceof Error?w.message:"网络设置保存失败,请重试。")}finally{!S.signal.aborted&&I===g.current.id&&l("idle")}};return i.jsxs("section",{className:"oc-settings-models oc-settings-network","aria-label":"网络代理设置",children:[i.jsx("p",{className:"oc-models-meta",children:"此程序的所有工作区共享。保存后,新请求立即生效,当前回复保持原连接。"}),o==="loading"?i.jsx("p",{className:"oc-models-meta",role:"status",children:"正在读取网络设置…"}):null,c?i.jsx("p",{className:"oc-models-error",role:"alert",children:c}):null,u?i.jsx("p",{className:"oc-models-notice",role:"status",children:u}):null,!n&&o==="idle"?i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",onClick:()=>{v()},children:"重试读取网络设置"}):null,n&&r?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"oc-network-modes",role:"group","aria-label":"代理模式",children:vD.map(S=>i.jsx("button",{type:"button",className:`oc-models-btn ${r.mode===S.value?"is-primary":"is-secondary"}`,"aria-pressed":r.mode===S.value,disabled:x,onClick:()=>y({mode:S.value}),children:S.label},S.value))}),r.mode==="environment"?i.jsx("p",{className:"oc-models-meta",children:"读取启动服务时的 HTTP_PROXY、HTTPS_PROXY 和 NO_PROXY;不会自动扫描操作系统代理设置。"}):null,r.mode==="direct"?i.jsx("p",{className:"oc-models-meta",children:"模型等由此设置管理的请求直接连接,不经过代理。"}):null,r.mode==="manual"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"代理地址"}),i.jsx("input",{type:"text","aria-label":"代理地址",value:r.proxyUrl,placeholder:"http://127.0.0.1:7890",autoComplete:"off",spellCheck:!1,disabled:x,onInput:S=>y({proxyUrl:S.currentTarget.value})}),i.jsx("span",{className:"oc-models-meta",children:"仅支持 HTTP / HTTPS 代理地址,不支持用户名和密码。"})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"不使用代理的地址(可选)"}),i.jsx("input",{type:"text","aria-label":"不使用代理的地址",value:r.noProxy,placeholder:"internal.example,.example.com",autoComplete:"off",spellCheck:!1,disabled:x,onInput:S=>y({noProxy:S.currentTarget.value})}),i.jsx("span",{className:"oc-models-meta",children:"多个地址用逗号分隔;localhost 和本机回环地址始终直连。"})]})]}):null,i.jsxs("div",{className:"oc-network-effective",children:[i.jsx("h3",{children:"上次读取的生效设置"}),i.jsxs("dl",{children:[i.jsx("dt",{children:"HTTP"}),i.jsx("dd",{children:n.effective.httpProxy??"直接连接"}),i.jsx("dt",{children:"HTTPS"}),i.jsx("dd",{children:n.effective.httpsProxy??"直接连接"}),i.jsx("dt",{children:"直连地址"}),i.jsxs("dd",{children:[n.effective.noProxy||"无额外设置",";localhost 和本机回环地址始终直连"]})]})]}),i.jsxs("div",{className:"oc-network-actions",children:[i.jsx("button",{type:"button",className:"oc-models-btn is-primary",disabled:x||p||!b,onClick:()=>{C()},children:o==="saving"?"正在保存…":"保存网络设置"}),i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",disabled:x,onClick:()=>{v(!0)},children:"重新加载(保留草稿)"})]})]}):null,i.jsx("p",{className:"oc-models-meta",children:"仅控制程序内网络请求;SSH、npm 等外部命令仍使用各自的代理配置。"})]})}const e6="loop-console.vcp.preferences.v1",hg="loop-console:vcp-preferences-change",t6=[{id:"auto",label:"智能自选",subtitle:"由模型按场景推荐",scene:"根据正文内容在数据、文献、文学等美学风格间自适应",color:"var(--orange, #f54e00)",bgTint:"color-mix(in srgb, var(--orange, #f54e00) 10%, transparent)"},{id:"porcelain-data",label:"青瓷数据",subtitle:"学术/数据/逻辑时序",scene:"冷静克制,蓝灰主色,明度映射数值,适合报表与指标看板",color:"#3b82f6",bgTint:"rgba(59, 130, 246, 0.12)"},{id:"editorial-minimal",label:"极简杂志",subtitle:"精装杂志/深度商务",scene:"沉静留白,高对比衬线标题,适合深度阅读、决策报告与复盘",color:"#1e293b",bgTint:"rgba(30, 41, 59, 0.1)"},{id:"warm-minimal",label:"暖调极简",subtitle:"轻奢无彩色/纸感",scene:"暖米白宣纸基底,衬线标题搭配黑体正文,适合产品落地页与品牌物料",color:"#b45309",bgTint:"rgba(180, 83, 9, 0.12)"},{id:"ink-letter",label:"笺信书札",subtitle:"纪事/书信/宣纸诗文",scene:"以笺为骨,将数据写成书信,水墨沉敛,适合叙事长文与散文",color:"#475569",bgTint:"rgba(71, 85, 105, 0.12)"},{id:"wabi-sabi",label:"侘寂留白",subtitle:"文学/禅意/残缺美",scene:"不对称构图,枯寂纸质肌理,天然留白,适合散文小说与随笔",color:"#78716c",bgTint:"rgba(120, 113, 108, 0.14)"},{id:"cyberpunk-neon",label:"赛博朋克",subtitle:"终端/黑客/霓虹暗黑",scene:"深底高亮荧光色,等宽代码,HUD 扫描线网格,适合科技与极客场景",color:"#06b6d4",bgTint:"rgba(6, 182, 212, 0.15)"},{id:"wire-news",label:"电讯报刊",subtitle:"快报/榜单/编辑强调",scene:"报纸排版网格,单点警示红,灰阶承载主干,适合新闻与榜单速递",color:"#ef4444",bgTint:"rgba(239, 68, 68, 0.12)"},{id:"pop-flat",label:"波普色块",subtitle:"年轻活力/高饱和插画",scene:"几何扁平撞色,高对比度明黄与粉蓝,适合轻松活泼与消费场景",color:"#ec4899",bgTint:"rgba(236, 72, 153, 0.12)"},{id:"brutalism",label:"粗野主义",subtitle:"直角硬影/先锋态度",scene:"极厚黑边框与直角硬阴影,夸张字号对比,适合潮牌与艺术设计",color:"#0f172a",bgTint:"rgba(15, 23, 42, 0.12)"},{id:"y2k-glass",label:"透光玻璃",subtitle:"未来复古/高透亚克力",scene:"毛玻璃拟态,高饱和渐变光晕,微反光描边,适合时尚与未来感",color:"#8b5cf6",bgTint:"rgba(139, 92, 246, 0.12)"}],Kr={enabled:!0,trustedMode:!0,ioHotWindow:!0,defaultStyle:"auto",exportEmbedFonts:!0,exportFooterMeta:!0};function Lo(){if(typeof window>"u"||!window.localStorage)return{...Kr};try{const e=window.localStorage.getItem(e6);if(!e)return{...Kr};const t=JSON.parse(e);return{enabled:typeof t.enabled=="boolean"?t.enabled:Kr.enabled,trustedMode:typeof t.trustedMode=="boolean"?t.trustedMode:Kr.trustedMode,ioHotWindow:typeof t.ioHotWindow=="boolean"?t.ioHotWindow:Kr.ioHotWindow,defaultStyle:typeof t.defaultStyle=="string"&&t6.some(n=>n.id===t.defaultStyle)?t.defaultStyle:Kr.defaultStyle,exportEmbedFonts:typeof t.exportEmbedFonts=="boolean"?t.exportEmbedFonts:Kr.exportEmbedFonts,exportFooterMeta:typeof t.exportFooterMeta=="boolean"?t.exportFooterMeta:Kr.exportFooterMeta}}catch{return{...Kr}}}function xD(e){const n={...Lo(),...e};if(typeof window<"u"&&window.localStorage)try{window.localStorage.setItem(e6,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(hg,{detail:n}))}catch{}return n}function Pv(){const[e,t]=f.useState(()=>Lo());f.useEffect(()=>{const s=r=>{const a=r;a.detail?t(a.detail):t(Lo())};return window.addEventListener(hg,s),window.addEventListener("storage",s),()=>{window.removeEventListener(hg,s),window.removeEventListener("storage",s)}},[]);const n=f.useCallback(s=>{const r=xD(s);t(r)},[]);return[e,n]}function yD(e){return i.jsx("button",{type:"button",role:"switch",id:e.id,"aria-checked":e.checked,"aria-label":e.ariaLabel,className:`oc-toggle${e.checked?" is-on":""}`,onClick:()=>e.onChange(!e.checked),children:i.jsx("span",{className:"oc-toggle-knob"})})}function hl(e){return i.jsxs("div",{className:"oc-settings-general-row",children:[i.jsxs("div",{className:"oc-settings-general-text",children:[i.jsx("label",{htmlFor:e.id,className:"oc-settings-general-title",children:e.title}),i.jsx("div",{className:"oc-settings-general-desc",children:e.description})]}),i.jsx(yD,{id:e.id,checked:e.checked,onChange:e.onChange,ariaLabel:e.title})]})}function wD(){const[e,t]=Pv();return i.jsxs("div",{className:"oc-settings-vcp",children:[i.jsxs("section",{className:"oc-vcp-group",children:[i.jsx("h3",{className:"oc-vcp-group-title",children:"基础控制"}),i.jsxs("div",{children:[i.jsx(hl,{id:"vcp-enabled",title:"渲染视觉卡片 (VCP)",description:"开启后,模型在正文中输出的 HTML/CSS/JS 卡片将流式呈现为精装排版;关闭则按 Markdown 源码显示",checked:e.enabled,onChange:n=>t({enabled:n})}),i.jsx(hl,{id:"vcp-trusted",title:"可信执行模式",description:"允许卡片运行 JavaScript 脚本、Canvas 交互动画与点击联动,通过沙箱和 CSS 隔离宿主界面",checked:e.trustedMode,onChange:n=>t({trustedMode:n})}),i.jsx(hl,{id:"vcp-hot-window",title:"IO 视口热窗防卡顿",description:"长会话中仅全量渲染屏幕附近的卡片,远古历史卡片自动降级占位,滚动接近无感恢复",checked:e.ioHotWindow,onChange:n=>t({ioHotWindow:n})})]})]}),i.jsxs("section",{className:"oc-vcp-group",children:[i.jsx("h3",{className:"oc-vcp-group-title",children:"排版美学风格库"}),i.jsx("p",{className:"oc-vcp-group-desc",children:"选择默认注入模型设计规范的美学语言,或由模型按内容智能自选"}),i.jsx("div",{className:"oc-vcp-style-grid",role:"radiogroup","aria-label":"排版美学风格",children:t6.map(n=>{const s=e.defaultStyle===n.id;return i.jsxs("button",{type:"button",role:"radio","aria-checked":s,className:`oc-vcp-style-card${s?" is-selected":""}`,onClick:()=>t({defaultStyle:n.id}),children:[i.jsx("span",{className:"oc-vcp-style-swatch",style:{background:n.color}}),i.jsxs("span",{className:"oc-vcp-style-body",children:[i.jsx("span",{className:"oc-vcp-style-name",children:n.label}),i.jsx("span",{className:"oc-vcp-style-sub",children:n.subtitle})]}),s?i.jsx(Vo,{className:"oc-vcp-style-check",size:14,"aria-hidden":"true"}):null]},n.id)})})]}),i.jsxs("section",{className:"oc-vcp-group",children:[i.jsx("h3",{className:"oc-vcp-group-title",children:"下载与导出模版"}),i.jsxs("div",{children:[i.jsx(hl,{id:"vcp-embed-fonts",title:"内嵌离线字体",description:"导出单文件 HTML 时将内置的书法与排版字体转为 Base64 嵌入,保证脱机打开字形完整",checked:e.exportEmbedFonts,onChange:n=>t({exportEmbedFonts:n})}),i.jsx(hl,{id:"vcp-footer-meta",title:"附带导出元信息",description:"在导出文件页脚附带生成时间戳与来源标记",checked:e.exportFooterMeta,onChange:n=>t({exportFooterMeta:n})})]})]})]})}const n6={status:"idle",snapshot:null,error:null,reloading:!1,reloadError:null,mutationBusy:!1,mutationToken:null};function wu(e){if(!e)return!1;const t=e.code??"";return t==="PI_SESSION_NOT_FOUND"||t==="NOT_FOUND"?!0:t==="PI_RUNTIME_UNAVAILABLE"&&/session file missing or not openable|no persisted Pi session file/i.test(e.message??"")}function $v(e){if(!e||typeof e!="object")return{message:"runtime snapshot request failed"};const t=e,n=t.error;if(n&&typeof n=="object"){const s=n;return{...typeof s.code=="string"&&s.code?{code:s.code}:{},...typeof t.status=="number"?{status:t.status}:{},message:typeof s.message=="string"&&s.message?s.message:"runtime snapshot request failed"}}return{...typeof t.status=="number"?{status:t.status}:{},message:typeof t=="object"&&"message"in t&&typeof t.message=="string"&&t.message?t.message:"runtime snapshot request failed"}}function SD(e,t){switch(t.type){case"load-start":return{...e,sessionId:t.sessionId,status:"loading",error:null};case"load-success":return e.snapshot&&e.sessionId===t.sessionId&&t.snapshot.revision<e.snapshot.revision?e:{...e,sessionId:t.sessionId,status:"ready",snapshot:t.snapshot,error:null,reloadError:null,reloading:!1};case"load-failure":return{...e,sessionId:t.sessionId,status:"error",error:t.error,snapshot:null};case"reload-start":return e.reloading?e:{...e,reloading:!0,reloadError:null,...e.status==="error"?{error:null}:{}};case"reload-success":return{...e,status:"ready",snapshot:t.snapshot,reloading:!1,reloadError:null,error:null,sessionId:t.snapshot.sessionId||e.sessionId};case"reload-failure":return{...e,reloading:!1,reloadError:t.error};case"mutation-start":return{...e,mutationBusy:!0,mutationToken:t.token};case"mutation-adopt":return e.mutationToken!==t.token||e.sessionId!==void 0&&e.sessionId!==t.sessionId||e.snapshot&&t.snapshot.revision<e.snapshot.revision?e:{...e,sessionId:t.sessionId,status:"ready",snapshot:t.snapshot,error:null,reloadError:null,reloading:!1};case"mutation-settle":return e.mutationToken!==t.token?e:{...e,mutationBusy:!1,mutationToken:null};case"mutation-reset":return{...e,mutationBusy:!1,mutationToken:null};case"reset":return{...n6};default:return e}}function s6(e){const t=e.selection;return{...t.model?{model:{provider:t.model.provider,modelId:t.model.id}}:{},...t.thinkingSelection==="auto"?t.effectiveThinkingLevel?{thinkingLevel:t.effectiveThinkingLevel}:{}:{thinkingLevel:t.thinkingSelection}}}function _D(e,t,n,s){const r=n&&n.sessionId===s?s6(n):{},a=r.model??e?.model,o=r.thinkingLevel??e?.thinkingLevel;return{readOnly:t.readOnly,systemPrompt:t.systemPrompt,resources:t.resources,suffix:t.suffix,...a?{model:a}:{},...o?{thinkingLevel:o}:{}}}function kD(e=n6){let t=e;const n=new Set;return{getState:()=>t,dispatch:s=>{t=SD(t,s);for(const r of n)r();return t},subscribe:s=>(n.add(s),()=>n.delete(s))}}function CD(e,t,n){return`${e}/api/operator/v1/chat/sessions/${encodeURIComponent(t)}/skills/${encodeURIComponent(n)}/auto-invocation`}async function ID(e){const t=e.fetchImpl??fetch;try{const n=await t(CD(e.origin,e.sessionId,e.resourceId),{method:"PATCH",credentials:"include",headers:{"content-type":"application/json","x-loop-console-confirmation":e.confirmationToken},body:JSON.stringify({autoInvocationEnabled:e.autoInvocationEnabled})}),s=await n.json().catch(()=>({}));if(!n.ok||s.ok===!1)return{ok:!1,error:{...$v(s),status:n.status}};const r=s.preferenceSaved===!0,a=s.reloadApplied===!0;if(!r)return{ok:!1,error:{status:n.status,code:"PI_RESOURCE_PREFERENCES_WRITE_FAILED",message:"preference was not saved"}};if(!a){const o=s.error?.code??"PI_SESSION_BUSY",l=s.error?.message??"preference saved; current session is busy and was not reloaded";return{ok:!0,preferenceSaved:!0,reloadApplied:!1,...s.snapshot?{snapshot:s.snapshot}:{},partialBusy:{code:o,message:l}}}return{ok:!0,preferenceSaved:!0,reloadApplied:!0,...s.snapshot?{snapshot:s.snapshot}:{}}}catch(n){return{ok:!1,error:{message:n instanceof Error?n.message:String(n)}}}}const In=kD();let Dr,go;function r6(e){return`/api/operator/v1/chat/sessions/${encodeURIComponent(e)}`}function ED(e){const t=Dr;if(Dr=e,!(t&&t.sessionId===e.sessionId&&t.origin===e.origin)){if((!t||t.sessionId!==e.sessionId)&&In.dispatch({type:"mutation-reset"}),!e.sessionId){go=void 0,In.dispatch({type:"reset"});return}if(In.dispatch({type:"load-start",sessionId:e.sessionId}),e.deferInitialFetch){go=void 0;return}go=e.sessionId,Bv(e.sessionId,e.origin)}}function ND(e){const t=Dr;!t?.sessionId||t.sessionId!==e||go!==e&&(go=e,Bv(e,t.origin))}async function Bv(e,t){try{const n=await fetch(`${t}${r6(e)}/runtime-snapshot`,{credentials:"include"}),s=await n.json().catch(()=>({}));if(Dr?.sessionId!==e)return;if(!n.ok){const r={...$v(s),status:n.status};if(wu(r)){In.dispatch({type:"reset"}),Dr.onUnrecoverableSession?.(e);return}In.dispatch({type:"load-failure",sessionId:e,error:r});return}if(!s.snapshot){In.dispatch({type:"load-failure",sessionId:e,error:{status:n.status,message:"runtime snapshot missing in response"}});return}In.dispatch({type:"load-success",sessionId:e,snapshot:s.snapshot})}catch(n){if(Dr?.sessionId!==e)return;In.dispatch({type:"load-failure",sessionId:e,error:{message:n instanceof Error?n.message:String(n)}})}}async function Su(){const e=Dr;if(!e?.sessionId||In.getState().reloading)return!1;const t=e.sessionId;In.dispatch({type:"reload-start"});try{const n=await fetch(`${e.origin}${r6(t)}/reload`,{method:"POST",credentials:"include",headers:{"content-type":"application/json","x-loop-console-confirmation":Rt()},body:"{}"}),s=await n.json().catch(()=>({}));return Dr?.sessionId!==t?!1:n.ok?s.snapshot?(In.dispatch({type:"reload-success",snapshot:s.snapshot}),!0):(In.dispatch({type:"reload-failure",error:{status:n.status,message:"reload succeeded but snapshot missing"}}),!1):(In.dispatch({type:"reload-failure",error:{...$v(s),status:n.status}}),!1)}catch(n){return Dr?.sessionId!==t||In.dispatch({type:"reload-failure",error:{message:n instanceof Error?n.message:String(n)}}),!1}}async function fg(){const e=Dr;if(!e?.sessionId)return!1;const t=e.sessionId;return In.dispatch({type:"load-start",sessionId:t}),go=t,Bv(t,e.origin),!0}function jD(e,t,n){return n?(In.dispatch({type:"mutation-adopt",token:e,sessionId:t,snapshot:n}),In.getState().snapshot===n):!1}function TD(e,t,n){return n.sessionRef.current?.sessionId!==t||In.getState().mutationToken!==e?!1:(In.dispatch({type:"mutation-settle",token:e}),!0)}function Ac(){return f.useSyncExternalStore(In.subscribe,In.getState)}function i6(e){In.dispatch(e)}function RD(){return In.getState()}const AD=[{id:"general",label:"通用设置"},{id:"vcp",label:"视觉与排版"},{id:"version",label:"版本"},{id:"pet",label:"宠物"},{id:"sidebar",label:"侧边栏"},{id:"models",label:"模型"},{id:"network",label:"网络"},{id:"skills",label:"技能"},{id:"plugins",label:"插件"},{id:"mcp",label:"MCP"}];function MD(e,t,n){const r=`${e.endsWith("/")?e.slice(0,-1):e}/api/operator/v1/pet/${encodeURIComponent(t)}`;return n?`${r}?workspaceId=${encodeURIComponent(n)}`:r}function LD(e){return e==="models"?i.jsx(Eo,{size:16,"aria-hidden":"true"}):e==="skills"?i.jsx(hN,{size:16,"aria-hidden":"true"}):e==="vcp"?i.jsx(SN,{size:16,"aria-hidden":"true"}):e==="plugins"?i.jsx(BN,{size:16,"aria-hidden":"true"}):e==="mcp"?i.jsx(Qk,{size:16,"aria-hidden":"true"}):e==="network"?i.jsx(LN,{size:16,"aria-hidden":"true"}):e==="general"?i.jsx(ic,{size:16,"aria-hidden":"true"}):e==="sidebar"?i.jsx(IN,{size:16,"aria-hidden":"true"}):e==="version"?i.jsx(_N,{size:16,"aria-hidden":"true"}):e==="pet"?i.jsx(oN,{size:16,"aria-hidden":"true"}):i.jsx(sc,{size:16,"aria-hidden":"true"})}function Ga({children:e}){return i.jsx("p",{className:"oc-settings-empty",children:e})}function OD(e){return e==="loaded"?"已加载":e==="configured"?"已配置":e==="disabled"?"未启用":"状态未知"}function DD(e){const t=_3(e.origin);f.useEffect(()=>{e.onUpdateAvailableChange?.(!!t.info?.updateAvailable)},[t.info?.updateAvailable,e.onUpdateAvailableChange]);const[n,s]=f.useState("general"),[r,a]=f.useState("latest"),[o,l]=f.useState(!1),[c,d]=f.useState(!1),[u,h]=f.useState(null),[p,m]=f.useState("idle"),[g,v]=f.useState(0),[b,x]=f.useState(null),[y,C]=f.useState(null),[S,I]=f.useState("idle"),w=f.useRef({id:0,controller:null}),_=e.open&&n==="version",N=t.info?.channels.find(ae=>ae.channel===r&&ae.status==="newer"&&ae.version)?.version??null,L=N?`${r}:${N}:${t.info?.checkedAt??""}`:null,O=`${e.origin}/api/operator/v1/version/notes`;f.useEffect(()=>{l(!1),d(!1)},[_,O]),f.useEffect(()=>{if(!_){h(null),m("idle");return}const ae=new AbortController;return h(null),m("loading"),fetch(O,{credentials:"same-origin",cache:"no-store",signal:ae.signal}).then(async ne=>{if(!ne.ok)throw new Error("说明读取失败");return await ne.json()}).then(ne=>{if(!ae.signal.aborted){if(ne.source!=="installed"){m("unavailable");return}h(ne),m(ne.status==="unavailable"?"unavailable":"idle")}}).catch(()=>{ae.signal.aborted||m("unavailable")}),()=>ae.abort()},[_,O,g]),f.useEffect(()=>(w.current.id++,w.current.controller?.abort(),w.current.controller=null,x(null),C(null),I("idle"),()=>{w.current.id++,w.current.controller?.abort(),w.current.controller=null}),[_,r,N,t.info?.checkedAt,O]);const T=()=>{if(!_||!N||!L)return;w.current.controller?.abort();const ae=++w.current.id,ne=new AbortController;w.current.controller=ne,x(null),C(L),I("loading");const we=new URLSearchParams({channel:r,version:N});fetch(`${O}?${we}`,{credentials:"same-origin",cache:"no-store",signal:ne.signal}).then(async Ce=>{if(!Ce.ok)throw new Error("目标说明读取失败");return await Ce.json()}).then(Ce=>{if(ne.signal.aborted||w.current.id!==ae)return;const He=Ce.status==="unavailable"&&Ce.targetVersion===void 0&&(Ce.reason==="invalid-candidate"||Ce.reason==="check-failed");if(Ce.source!=="candidate"||Ce.targetVersion!==N&&!He){I("unavailable");return}x(Ce),I(Ce.status==="unavailable"?"unavailable":"idle")}).catch(()=>{!ne.signal.aborted&&w.current.id===ae&&I("unavailable")})},R=()=>{w.current.id++,w.current.controller?.abort(),w.current.controller=null,x(null),C(null),I("idle")},A=()=>{R(),l(!1),d(!1),e.onClose()},[E,$]=f.useState(null),[H,B]=f.useState(null),[G,z]=f.useState(null),[Q,W]=f.useState({}),[D,ee]=f.useState(null),[F,M]=f.useState(null),[U,q]=f.useState(!1),[te,se]=f.useState(!1),[he,X]=f.useState(null),[re,de]=f.useState(""),[xe,K]=f.useState([]),pe=f.useRef(0),Z=f.useRef(null),ue=Ac(),_e=ue.snapshot;Ko({open:e.open,containerRef:Z,triggerRef:e.triggerRef,onEscape:A}),f.useEffect(()=>{if(!e.open)return;let ae=!0;return B(null),fetch(`${e.origin}/api/health`,{credentials:"include"}).then(async ne=>{const we=await ne.json();if(!ne.ok)throw new Error("版本信息读取失败");ae&&$(we)}).catch(ne=>{ae&&B(ne instanceof Error?ne.message:String(ne))}),()=>{ae=!1}},[e.open,e.origin]);const Oe=e.workspaceId??e.activeWorkspaceId??null,Me=ae=>MD(e.origin,ae,Oe);f.useEffect(()=>{const ae=++pe.current;if(K([]),de(""),!e.open||n!=="pet"||!Oe)return;let ne=!0;return se(!0),X(null),fetch(Me("state"),{credentials:"include",cache:"no-store"}).then(async we=>{const Ce=await we.json();if(!we.ok)throw new Error(Ce.error?.message??"宠物设置读取失败");ne&&ae===pe.current&&(q(Ce.display?.visible===!0),de(Ce.petId),K(Ce.pets))}).catch(we=>{ne&&X(we instanceof Error?we.message:String(we))}).finally(()=>{ne&&se(!1)}),()=>{ne=!1,pe.current+=1}},[e.open,e.origin,Oe,n]);const Ie=async ae=>{if(!Oe||te)return;const ne=++pe.current;se(!0),X(null);try{const we=await fetch(Me("select"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify({petId:ae})}),Ce=await we.json();if(!we.ok)throw new Error(Ce.error?.message??"切换宠物失败,请重试");if(ne!==pe.current)return;de(Ce.petId),window.dispatchEvent(new CustomEvent("loop-console-pet-selection",{detail:{workspaceId:Oe,view:Ce}}))}catch(we){ne===pe.current&&X(we instanceof Error?we.message:"切换宠物失败,请重试")}finally{ne===pe.current&&se(!1)}},$e=async()=>{if(!Oe||te)return;const ae=++pe.current,ne=!U;q(ne),se(!0),X(null);try{const we=await fetch(Me("display"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify({visible:ne})}),Ce=await we.json();if(!we.ok)throw new Error(Ce.error?.message??"宠物设置保存失败");if(ae!==pe.current)return;const He=Ce.display?.visible===!0;q(He),window.dispatchEvent(new CustomEvent("loop-console-pet-visibility",{detail:{workspaceId:Oe,visible:He}}))}catch(we){if(ae!==pe.current)return;q(!ne),X(we instanceof Error?we.message:String(we))}finally{ae===pe.current&&se(!1)}},be=f.useMemo(()=>[..._e?.packages.map(ae=>({name:ae.packageName??ae.spec,detail:ae.version?`v${ae.version}`:ae.spec,enabled:ae.enabled}))??[],..._e?.extensions.map(ae=>({name:ae.name,detail:ae.scope,enabled:ae.enabled}))??[]],[_e]);f.useEffect(()=>{z(null),W({}),ee(null),M(null)},[_e?.sessionId]);const oe=(ae,ne)=>Object.hasOwn(Q,ae)?Q[ae]:ne,ge=async ae=>{if(!_e?.sessionId||!ae.resourceId||G)return;const ne=!oe(ae.resourceId,ae.autoInvocationEnabled);z(ae.resourceId),M(null),ee(null),W(Ce=>({...Ce,[ae.resourceId]:ne}));const we=await ID({origin:e.origin,sessionId:_e.sessionId,resourceId:ae.resourceId,autoInvocationEnabled:ne,confirmationToken:Rt()});if(z(null),!we.ok){W(Ce=>{const He={...Ce};return delete He[ae.resourceId],He}),M(`${we.error.code?`${we.error.code}:`:""}${we.error.message}`);return}if(we.reloadApplied&&we.snapshot){i6({type:"load-success",sessionId:_e.sessionId,snapshot:we.snapshot}),W(Ce=>{const He={...Ce};return delete He[ae.resourceId],He});return}we.partialBusy&&ee("设置已保存,将在本轮对话结束并重新加载会话后生效。")};if(!e.open||typeof document>"u")return null;const ke=()=>{if(n==="general")return i.jsx(tD,{});if(n==="vcp")return i.jsx(wD,{});if(n==="models"){const ne=e.activeWorkspaceId??e.workspaceId??null;return i.jsxs("div",{className:"oc-settings-models-stack",children:[i.jsx(cD,{origin:e.origin,workspaceId:ne},ne??"none"),i.jsx(gD,{})]})}if(n==="network")return i.jsx(bD,{origin:e.origin},e.origin);if(n==="version")return i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"oc-version-panel",children:[i.jsxs("header",{className:"oc-version-identity",children:[i.jsx("div",{className:"oc-version-mark","aria-hidden":"true",children:"L"}),i.jsxs("div",{className:"oc-version-identity-copy",children:[i.jsxs("p",{className:"oc-version-product",children:["Loop Agent ",i.jsx("span",{className:"oc-version-badge",children:t.info?.currentChannel==="next"?"预发布版":"稳定版"})]}),i.jsxs("h2",{children:[i.jsx("span",{className:"sr-only",children:"Loop Agent "}),t.info?.currentVersion??E?.packageVersion??"读取中…"]}),i.jsx("p",{className:"oc-version-caption",children:"当前安装版本 · 所有工作区共享"})]})]}),i.jsxs("div",{className:"oc-version-check",children:[i.jsx("h3",{children:"更新渠道"}),i.jsxs("button",{type:"button",disabled:t.checking,onClick:t.recheck,children:[i.jsx(mi,{size:14,"aria-hidden":"true"}),"检查更新"]})]}),i.jsx("p",{className:"oc-version-status","data-update-available":!!t.info?.updateAvailable,role:"status",children:t.checking?"正在检查新版本…":t.error??(t.info?.updateAvailable?"有新版本可用":t.info?.channels.some(ne=>ne.status==="unavailable")?"部分渠道暂时无法检查,30 秒后可重试":"版本检查完成")}),i.jsx(z5,{operatorBusy:!!e.operatorBusy,workspaceId:e.workspaceId??e.activeWorkspaceId??null,versionInfo:t.info}),i.jsxs("div",{className:"oc-version-notes",children:[i.jsx("h3",{className:"oc-version-notes-heading",children:"更新说明"}),i.jsxs("details",{open:o,onToggle:ne=>l(ne.currentTarget.open),children:[i.jsxs("summary",{tabIndex:0,children:[i.jsx(No,{size:17,"aria-hidden":"true"}),i.jsxs("span",{className:"oc-notes-summary-copy",children:[i.jsx("span",{className:"oc-notes-title",children:"本版本更新"}),i.jsx("small",{children:"查看当前安装包的变化"})]}),i.jsx(Ns,{className:"oc-notes-chevron",size:18,"aria-hidden":"true"})]}),o?i.jsxs("section",{className:"oc-notes-installed-content",children:[p==="loading"?i.jsx("p",{role:"status",children:"正在读取已安装版本说明…"}):null,p==="unavailable"?i.jsxs("div",{role:"alert",children:[lg(u,"installed"),i.jsx("button",{type:"button",onClick:()=>v(ne=>ne+1),children:"重试已安装版本说明"})]}):null,p==="idle"&&u?i.jsx(cw,{kind:"installed",notes:u}):null]}):null]}),i.jsxs("details",{className:"oc-notes-candidate",open:c,onToggle:ne=>{const we=ne.currentTarget.open;d(we),we||R()},children:[i.jsxs("summary",{tabIndex:0,onClick:ne=>{ne.currentTarget.parentElement?.hasAttribute("open")&&R()},children:[i.jsx(No,{size:17,"aria-hidden":"true"}),i.jsxs("span",{className:"oc-notes-summary-copy",children:[i.jsx("span",{className:"oc-notes-title",children:"目标版本更新"}),i.jsx("small",{children:"更新前,先了解变化"})]}),i.jsx(Ns,{className:"oc-notes-chevron",size:18,"aria-hidden":"true"})]}),c?i.jsxs("section",{className:"oc-notes-candidate-content",children:[i.jsx("div",{role:"group","aria-label":"目标版本说明渠道",children:["latest","next"].map(ne=>i.jsx("button",{type:"button","aria-pressed":r===ne,onClick:()=>{r!==ne&&(R(),a(ne))},children:ne==="latest"?"稳定版 latest":"预发布版 next"},ne))}),N?i.jsxs("p",{children:["目标版本:",N]}):i.jsx("p",{role:"status",children:t.checking?"正在检查可用目标版本…":"此渠道暂无可查询的新版本说明。"}),N&&(y!==L||S==="idle")&&(!b||y!==L)?i.jsx("button",{type:"button",onClick:T,children:"查看目标版本更新"}):null,y===L&&S==="loading"?i.jsxs("p",{role:"status",children:["正在读取目标版本说明… ",i.jsx("button",{type:"button",onClick:R,children:"取消目标版本说明查询"})]}):null,y===L&&S==="unavailable"?i.jsxs("div",{role:"alert",children:[lg(b,"candidate"),i.jsx("button",{type:"button",onClick:T,children:"重试目标版本说明"})]}):null,y===L&&S==="idle"&&b?i.jsx(cw,{kind:"candidate",notes:b}):null]}):null]})]}),i.jsx("p",{className:"oc-version-footnote",children:"点击更新后才会安装;完成后 Console 自动重启。"})]}),i.jsx(PO,{origin:e.origin,workspaceId:e.activeWorkspaceId??e.workspaceId,runAction:e.runAction},e.activeWorkspaceId??e.workspaceId??"none")]});if(n==="sidebar")return i.jsx(aD,{});if(n==="pet")return i.jsxs("section",{className:"oc-settings-pet",children:[i.jsxs("div",{className:"oc-settings-pet-row",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"显示桌面宠物"}),i.jsx("p",{children:"开启后对话页只出现爪印。展开后才会跟随工作状态活动,可在下方选择喜欢的形象。"})]}),i.jsx("button",{type:"button",className:`oc-toggle${U?" is-on":""}`,role:"switch","aria-checked":U,"aria-label":`${U?"关闭":"开启"}桌面宠物`,disabled:te||!Oe,onClick:()=>{$e()},children:i.jsx("span",{className:"oc-toggle-knob","aria-hidden":"true"})})]}),i.jsxs("div",{className:"oc-settings-pet-choice",children:[i.jsx("strong",{children:"宠物形象"}),i.jsx("div",{className:"pet-switch",role:"group","aria-label":"宠物形象",children:xe.map(ne=>i.jsx("button",{type:"button","aria-pressed":re===ne.id,"data-active":re===ne.id,disabled:te||!Oe,onClick:()=>{Ie(ne.id)},children:ne.displayName},ne.id))})]}),i.jsx("p",{className:"oc-settings-help",children:"默认关闭,按工作区保存。关闭后对话页不出现宠物。爪印不读取宠物状态;展开后才会跟随会话,收起不会关闭此开关。形象、好感度、食物和位置仍然保存。"}),Oe?null:i.jsx("p",{className:"oc-settings-error",children:"请先选择工作区。"}),he?i.jsx("p",{className:"oc-settings-error",role:"alert",children:he}):null]});if(ue.status==="loading"||ue.status==="idle")return i.jsx(Ga,{children:"正在读取当前会话的运行配置…"});if(ue.status==="error")return i.jsx(Ga,{children:ue.error?.message??"运行配置读取失败"});if(!_e)return i.jsx(Ga,{children:"新建或打开一个会话后即可查看。"});if(n==="skills")return _e.skills.length?i.jsxs("div",{className:"oc-settings-skill-section",children:[i.jsx("p",{className:"oc-settings-help",children:"开启后允许模型自动选择并注入该技能上下文;关闭后仍可手动调用。"}),F?i.jsx("p",{className:"oc-settings-error",role:"alert",children:F}):null,D?i.jsx("p",{className:"oc-settings-notice",role:"status",children:D}):null,i.jsx("ul",{className:"oc-settings-list",children:_e.skills.map(ne=>{const we=oe(ne.resourceId,ne.autoInvocationEnabled),Ce=G===ne.resourceId;return i.jsxs("li",{children:[i.jsxs("div",{children:[i.jsx("strong",{children:ne.name}),i.jsx("span",{children:ne.description||ne.scope})]}),i.jsxs("div",{className:"oc-settings-skill-control",children:[i.jsx("em",{children:we?"已启用":"未启用"}),i.jsx("button",{type:"button",className:`oc-toggle${we?" is-on":""}`,role:"switch","aria-checked":we,"aria-label":`${we?"关闭":"开启"} ${ne.name} 自动注入上下文`,disabled:Ce||!!G||!ne.resourceId,title:Ce?"保存中…":"控制模型是否可自动选择该技能",onClick:()=>{ge(ne)},children:i.jsx("span",{className:"oc-toggle-knob","aria-hidden":"true"})})]})]},ne.resourceId)})})]}):i.jsx(Ga,{children:"当前会话没有加载技能。"});if(n==="plugins")return be.length?i.jsx("ul",{className:"oc-settings-list",children:be.map((ne,we)=>i.jsxs("li",{children:[i.jsxs("div",{children:[i.jsx("strong",{children:ne.name}),i.jsx("span",{children:ne.detail})]}),i.jsx("em",{children:ne.enabled?"已启用":"未启用"})]},`${ne.name}-${we}`))}):i.jsx(Ga,{children:"当前会话没有加载插件。"});const ae=_e.mcp?.servers??[];return ae.length?i.jsx("ul",{className:"oc-settings-list",children:ae.map(ne=>i.jsxs("li",{children:[i.jsxs("div",{children:[i.jsx("strong",{children:ne.name}),i.jsxs("span",{children:[ne.tools.length," 个工具 · ",ne.transport??ne.scope]})]}),i.jsx("em",{children:OD(ne.status)})]},ne.name))}):i.jsx(Ga,{children:"当前会话没有加载 MCP 服务。"})};return Xs.createPortal(i.jsx("div",{className:"oc-settings-backdrop",onMouseDown:ae=>{ae.target===ae.currentTarget&&A()},children:i.jsxs("section",{ref:Z,className:"oc-settings-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"oc-settings-title",tabIndex:-1,children:[i.jsxs("nav",{className:"oc-settings-nav","aria-label":"设置分类",children:[i.jsx("div",{className:"oc-settings-nav-title",id:"oc-settings-title",children:"设置"}),i.jsx("div",{className:"oc-settings-nav-list",children:AD.map(ae=>i.jsxs("button",{type:"button",className:n===ae.id?"is-active":"","aria-current":n===ae.id?"page":void 0,onClick:()=>{n==="version"&&ae.id!=="version"&&(R(),d(!1)),s(ae.id)},children:[LD(ae.id),i.jsx("span",{children:ae.label}),ae.id==="version"&&t.info?.updateAvailable?i.jsx("i",{className:"oc-update-dot",role:"img","aria-label":"有新版本可用"}):null]},ae.id))})]}),i.jsxs("div",{className:"oc-settings-content",children:[i.jsx("header",{className:"oc-settings-header",children:i.jsx("button",{type:"button",className:"oc-settings-close",onClick:A,"aria-label":"关闭设置",title:"关闭",children:i.jsx(Wn,{size:16,"aria-hidden":"true"})})}),i.jsx("div",{className:"oc-settings-options",children:ke()})]})]})}),document.body)}function PD(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),i.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function $D(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})})}function ww(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),i.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function BD(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:i.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}function mg({side:e="left"}){return i.jsx("svg",{className:`oc-panel-icon${e==="right"?" is-right":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.67272 0.522841C10.8339 0.522841 11.76 0.522714 12.4963 0.602493C13.2453 0.683657 13.8789 0.854248 14.4264 1.25197C14.7504 1.48739 15.0355 1.77247 15.2709 2.0965C15.6686 2.64394 15.8392 3.27758 15.9204 4.02655C16.0002 4.7629 16 5.68895 16 6.85014V9.14986C16 10.3111 16.0002 11.2371 15.9204 11.9735C15.8392 12.7224 15.6686 13.3561 15.2709 13.9035C15.0355 14.2275 14.7504 14.5126 14.4264 14.748C13.8789 15.1458 13.2453 15.3163 12.4963 15.3975C11.76 15.4773 10.8339 15.4772 9.67272 15.4772H6.3273C5.16611 15.4772 4.24006 15.4773 3.50371 15.3975C2.75474 15.3163 2.1211 15.1458 1.57366 14.748C1.24963 14.5126 0.964549 14.2275 0.729131 13.9035C0.331407 13.3561 0.160817 12.7224 0.0796529 11.9735C-0.000126137 11.2371 0 10.3111 0 9.14986V6.85014C0 5.68895-0.000126137 4.7629 0.0796529 4.02655C0.160817 3.27758 0.331407 2.64394 0.729131 2.0965C0.964549 1.77247 1.24963 1.48739 1.57366 1.25197C2.1211 0.854248 2.75474 0.683657 3.50371 0.602493C4.24006 0.522714 5.16611 0.522841 6.3273 0.522841H9.67272ZM5.54303 1.88715V14.1118C5.78636 14.1128 6.04709 14.1169 6.3273 14.1169H9.67272C10.8639 14.1169 11.7032 14.1164 12.3493 14.0465C12.9824 13.9779 13.3497 13.8494 13.6268 13.6482C13.8354 13.4966 14.0195 13.3125 14.1711 13.1039C14.3723 12.8268 14.5007 12.4595 14.5693 11.8264C14.6393 11.1803 14.6398 10.341 14.6398 9.14986V6.85014C14.6398 5.65896 14.6393 4.81967 14.5693 4.1736C14.5007 3.54048 14.3723 3.17318 14.1711 2.89609C14.0195 2.68747 13.8354 2.50337 13.6268 2.35179C13.3497 2.1506 12.9824 2.02212 12.3493 1.95353C11.7032 1.88358 10.8639 1.88307 9.67272 1.88307H6.3273C6.04709 1.88307 5.78636 1.8862 5.54303 1.88715ZM4.1828 1.91166C3.99125 1.9216 3.8148 1.93577 3.65076 1.95353C3.01764 2.02212 2.65034 2.1506 2.37325 2.35179C2.16463 2.50337 1.98052 2.68747 1.82895 2.89609C1.62776 3.17318 1.49928 3.54048 1.43069 4.1736C1.36074 4.81967 1.36023 5.65896 1.36023 6.85014V9.14986C1.36023 10.341 1.36074 11.1803 1.43069 11.8264C1.49928 12.4595 1.62776 12.8268 1.82895 13.1039C1.98052 13.3125 2.16463 13.4966 2.37325 13.6482C2.65034 13.8494 3.01764 13.9779 3.65076 14.0465C3.81478 14.0642 3.99127 14.0774 4.1828 14.0873V1.91166Z",fill:"currentColor"})})}function FD(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4 4l8 8M12 4l-8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function Xo(){return i.jsx("svg",{className:"oc-tool-chevron",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("polyline",{points:"2.5 4 6 7.5 9.5 4"})})}function zD(e,t,n,s){const r=e.findIndex(c=>c.workspaceId===n),a=e.findIndex(c=>c.workspaceId===t);if(r===-1||a===-1)return;const o=s==="before"?n:e[r+1]?.workspaceId??null;if(o===t)return;const l=o?e.findIndex(c=>c.workspaceId===o):e.length;return l===a||l===a+1?void 0:o}function HD(e){if(!e)return;const t=e;for(const n of t.getAnimations?.({subtree:!0})??[])n.startTime=0}function zn(e){const t=e.size??(e.state==="ongoing"?14:10);return e.state==="ongoing"?i.jsx("svg",{ref:HD,className:`oc-state-dot${e.className?` ${e.className}`:""}`,"data-state":"ongoing",width:t,height:t,viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsxs("g",{className:"oc-state-dot-motion",children:[i.jsx("circle",{className:"oc-state-dot-track",cx:"12",cy:"12",r:"9.5"}),i.jsx("circle",{className:"oc-state-dot-arc",cx:"12",cy:"12",r:"9.5"})]})}):i.jsx("span",{className:`oc-state-dot${e.className?` ${e.className}`:""}`,"data-state":e.state,style:{width:t,height:t},"aria-hidden":"true"})}function qD({open:e}){return i.jsx("svg",{className:`oc-tree-chevron${e?" is-open":""}`,width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 2.4 7.8 6 4.2 9.6",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function UD({open:e}){return i.jsx("svg",{className:`oc-workspace-chevron${e?" is-open":""}`,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M4.25 2.82782V11.1722C4.25 11.6622 4.84243 11.9076 5.18891 11.5611L9.36109 7.38891C9.57588 7.17412 9.57588 6.82588 9.36109 6.61109L5.18891 2.43891C4.84243 2.09243 4.25 2.33782 4.25 2.82782Z",fill:"currentColor"})})}function WD(){return i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3 3.5h10v2H3v-2Zm0 3.5h10v2H3V7Zm0 3.5h7V13H3v-2Z",fill:"currentColor"})})}function VD(){return i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M8 3v10M3 8h10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}function a6(){return i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2 4h5l1 1.5h6V13H2V4Z",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})})}function Sw(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[i.jsx("path",{transform:"translate(9.52 2.52)",d:"M3.55246 0L3.55246 2.44252L6 2.44252L6 3.55748L3.55246 3.55748L3.55246 6L2.43834 6L2.43834 3.55748L0 3.55748L0 2.44252L2.43834 2.44252L2.43834 0L3.55246 0Z",fill:"currentColor"}),i.jsx("path",{transform:"translate(0.3496 2.35)",d:"M4.76367 0C5.36861 1.80598e-05 5.93113 0.310294 6.25488 0.821289L6.78027 1.64941C6.79685 1.67558 6.81791 1.69775 6.83887 1.71973C6.72186 2.15521 6.65702 2.61192 6.65137 3.08301C6.25601 2.96045 5.90909 2.70478 5.68164 2.3457L5.15723 1.5166C5.07183 1.38189 4.92318 1.3008 4.76367 1.30078L2.32422 1.30078C1.7589 1.30078 1.30078 1.7589 1.30078 2.32422L1.30078 10.1338C1.30078 10.6991 1.7589 11.1572 2.32422 11.1572L11.9766 11.1572C12.5419 11.1572 13 10.6991 13 10.1338L13 8.58398C13.4545 8.5135 13.8903 8.38748 14.3008 8.21289L14.3008 10.1338C14.3008 11.4171 13.2598 12.458 11.9766 12.458L2.32422 12.458C1.04093 12.458 0 11.4171 0 10.1338L0 2.32422C0 1.04093 1.04093 0 2.32422 0L4.76367 0Z",fill:"currentColor"})]})}function GD({open:e}){return i.jsx("svg",{className:`oc-tree-glyph${e?" is-folder-open":" is-folder"}`,width:"16",height:"16",viewBox:"0 0 14 14","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 4h3.2l1 1.1H12a.8.8 0 0 1 .8.8v5.3a.8.8 0 0 1-.8.8H2a.8.8 0 0 1-.8-.8V4.8a.8.8 0 0 1 .8-.8Z",fill:"currentColor",opacity:e?.9:.68})})}function KD(e){return[...e].sort((t,n)=>t.kind!==n.kind?t.kind==="directory"?-1:1:t.name.localeCompare(n.name,void 0,{sensitivity:"base"}))}function o6(e){const t=f.useMemo(()=>KD(e.entries),[e.entries]);return t.length?i.jsx("ul",{className:"oc-tree",role:e.depth===0?"tree":"group",children:t.map(n=>{const s=n.kind==="directory"&&e.expanded.has(n.path);return i.jsxs("li",{className:`oc-tree-node is-${n.kind}${s?" is-open":""}`,role:"treeitem","aria-expanded":n.kind==="directory"?s:void 0,children:[i.jsxs("button",{type:"button",className:`oc-tree-row oc-tree-${n.kind==="directory"?"dir":"file"}`,style:{paddingLeft:`${8+e.depth*12}px`},onClick:()=>n.kind==="directory"?e.onToggle(n.path):e.onPreview(n.path),children:[n.kind==="directory"?i.jsxs(i.Fragment,{children:[i.jsx(qD,{open:s}),i.jsx(GD,{open:s})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"oc-tree-chevron-spacer","aria-hidden":"true"}),i.jsx(ih,{name:n.name})]}),i.jsx("span",{className:"oc-tree-label",children:n.name}),i.jsx("span",{className:"oc-tree-at",role:"button",tabIndex:0,"aria-label":`提及 ${n.name}`,title:"在输入框提及此文件",onClick:r=>{r.stopPropagation(),e.onInsert(n.kind==="directory"?`${n.path}/`:n.path)},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),e.onInsert(n.kind==="directory"?`${n.path}/`:n.path))},children:"@"})]}),n.kind==="directory"&&s?i.jsx(o6,{...e,entries:e.tree[n.path]??[],depth:e.depth+1}):null]},n.path)})}):i.jsx("p",{className:"oc-tree-empty",children:"此目录为空或没有可安全浏览的文件。"})}function YD(e){return i.jsxs("section",{className:"oc-details-files","aria-label":"Workspace 文件",children:[i.jsxs("header",{children:[i.jsx("span",{className:"oc-details-workspace-name",title:e.workspaceName,children:e.workspaceName}),i.jsx("button",{type:"button",className:"btn btn-ghost",onClick:e.onRefresh,"aria-label":"刷新文件",title:"刷新文件",children:i.jsx(mi,{size:15,"aria-hidden":"true"})})]}),e.treeError?i.jsx("p",{className:"oc-sidebar-error",role:"alert",children:e.treeError}):null,i.jsx("div",{className:"oc-details-tree-scroll",children:i.jsx(o6,{entries:e.tree[""]??[],tree:e.tree,expanded:e.expanded,depth:0,onToggle:e.onToggle,onInsert:e.onInsert,onPreview:e.onPreview})})]})}function ZD(e,t){const n=e.deferredTurns?.length?e.deferredTurns:e.deferredTurn?[e.deferredTurn]:[];if(t)return null;if(n.some(r=>r.state==="failed"))return{label:"发送失败",title:"排队消息发送失败",state:"failed"};const s=n.filter(r=>r.state==="queued").length;return s>0?{label:String(s),title:`${s} 条排队消息`,state:"queued"}:null}function _w(e,t=Date.now()){const n=new Date(e).getTime();if(!Number.isFinite(n))return"";const s=Math.max(0,t-n),r=Math.floor(s/6e4);if(r<1)return"刚刚";if(r<60)return`${r}分钟`;const a=Math.floor(r/60);if(a<24)return`${a}小时`;const o=Math.floor(a/24);if(o<30)return`${o}天`;const l=Math.floor(o/30);return l<12?`${l}个月`:`${Math.floor(l/12)}年`}function l6(e){const t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"时间未知"}function c6(e=!1){const[t,n]=f.useState(null),s=f.useRef(null),r=f.useRef(null),a=f.useCallback(()=>{s.current!==null&&window.clearTimeout(s.current),r.current!==null&&window.clearTimeout(r.current),s.current=null,r.current=null},[]),o=f.useCallback(()=>{a(),n(null)},[a]);f.useEffect(()=>{e&&o()},[o,e]),f.useEffect(()=>o,[o]);const l=f.useCallback(u=>{if(e||(r.current!==null&&(window.clearTimeout(r.current),r.current=null),t))return;s.current!==null&&window.clearTimeout(s.current);const h=u.currentTarget;s.current=window.setTimeout(()=>{s.current=null,n(h)},800)},[e,t]),c=f.useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),t&&(r.current=window.setTimeout(o,180))},[o,t]),d=f.useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null)},[]);return{anchor:t,close:o,onPointerEnter:l,onPointerLeave:c,onCardPointerEnter:d}}function d6(e){const t=f.useRef(null),[n,s]=f.useState(null);return f.useLayoutEffect(()=>{const r=e.anchor;if(!r){s(null);return}const a=()=>{const l=t.current;if(!l||!r.isConnected){s(null);return}const c=r.getBoundingClientRect(),{width:d,height:u}=l.getBoundingClientRect(),h=8,p=c.right+h;if(p+d<=window.innerWidth-h){s({left:p,top:Math.max(h,Math.min(c.top,window.innerHeight-u-h))});return}const m=Math.max(h,Math.min(c.left,window.innerWidth-d-h));c.bottom+h+u<=window.innerHeight-h?s({left:m,top:c.bottom+h}):c.top-h-u>=h?s({left:m,top:c.top-h-u}):s(null)};a();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(a);return o?.observe(r),t.current&&o?.observe(t.current),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{o?.disconnect(),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[e.anchor]),!e.anchor||typeof document>"u"?null:Xs.createPortal(i.jsx("div",{ref:t,className:"oc-sidebar-hover-card",style:{left:n?.left??0,top:n?.top??0,visibility:n?"visible":"hidden"},onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,children:e.children}),document.body)}function XD(e){const{item:t,active:n,streamingNow:s,turnPhaseNow:r,state:a,deleteConfirming:o,deleting:l}=e,c=r??t.turnPhase,d=t.optimisticState,u=(t.subagentSummary?.active??0)>0,h=s===!0||c==="running"||c==="stopping"||c===void 0&&!!t.activeTurnId,p=h||u,m=ZD(t,n),g=t.isBlank===!0,v=d==="creating"?"正在创建…":g?"新会话":t.title||t.displayTitle||"未命名对话",b=l6(t.updatedAt),x=new Date(t.updatedAt),y=Number.isFinite(x.getTime())?x.toISOString():void 0,C=f.useRef(null),S=f.useRef(null),I=f.useRef(null),[w,_]=f.useState(null),k=c6(!!w||o);return f.useEffect(()=>{const N=T=>{I.current?.contains(T.target)||S.current?.contains(T.target)||(o&&e.onCancelDelete(),_(null))},L=()=>{k.close(),_(null)},O=T=>{T.key==="Escape"&&(k.close(),o&&e.onCancelDelete(),_(null))};return document.addEventListener("mousedown",N),window.addEventListener("scroll",L,!0),window.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("scroll",L,!0),window.removeEventListener("keydown",O)}},[o,k.close,e.onCancelDelete]),f.useEffect(()=>{o&&C.current?.focus()},[o]),i.jsxs("div",{className:`oc-session-item${n?" is-active":""}${o?" is-delete-confirming":""}${w?" is-menu-open":""}${d?` is-optimistic-${d}`:""}`,"data-session-id":t.sessionId,onPointerEnter:k.onPointerEnter,onPointerLeave:k.onPointerLeave,children:[i.jsxs("a",{href:e.href,className:"oc-session-main","aria-disabled":l||d==="creating"||void 0,tabIndex:l||d==="creating"?-1:void 0,onClick:N=>{if(l||d==="creating"){N.preventDefault();return}N.preventDefault(),e.onActivate()},children:[i.jsx("strong",{children:v}),i.jsx("span",{className:`oc-session-mode is-${t.sessionMode==="pi"?"pi":"workflow"}`,children:t.sessionMode==="pi"?"Pi":"工作流"}),g?null:i.jsx("time",{dateTime:y,title:b,children:_w(t.updatedAt,e.now)}),t.subagentSummary&&t.subagentSummary.total>0?i.jsx("span",{className:`oc-session-subagents${t.subagentSummary.active>0?" is-running":t.subagentSummary.failed>0?" is-error":""}`,children:t.subagentSummary.active>0?`${t.subagentSummary.active} 个子代理运行中`:`${t.subagentSummary.total} 个子代理`}):null]}),p?i.jsx("span",{className:"oc-session-running","aria-label":u&&!h?"子代理运行中":"对话进行中",title:u&&!h?"子代理运行中":"对话进行中",children:i.jsx(zn,{state:"ongoing"})}):null,m?i.jsx("span",{className:`oc-session-queue-state is-${m.state}`,"aria-label":m.title,title:m.title,children:m.label}):null,d!=="creating"&&!g?i.jsx("div",{className:"oc-session-actions",children:i.jsx("button",{type:"button",ref:S,className:"oc-session-menu","data-session-delete-id":t.sessionId,title:"更多","aria-label":`${v} 更多操作`,"aria-expanded":!!w,onClick:N=>{if(N.stopPropagation(),k.close(),w){_(null);return}const L=N.currentTarget.getBoundingClientRect();_({left:Math.max(8,Math.min(L.right-176,window.innerWidth-184)),top:Math.min(L.bottom+5,window.innerHeight-128)})},children:i.jsx(iv,{size:16,"aria-hidden":"true"})})}):null,i.jsxs(d6,{anchor:k.anchor,onPointerEnter:k.onCardPointerEnter,onPointerLeave:k.onPointerLeave,children:[i.jsx("strong",{children:v}),g?null:i.jsxs("span",{children:[_w(t.updatedAt,e.now)," · ",b]}),i.jsxs("span",{className:"oc-sidebar-hover-status",children:[i.jsx("i",{className:p?"is-running":""}),m?.title??(p?"对话进行中":a==="archived"?"已归档":"空闲")]})]}),w&&typeof document<"u"?Xs.createPortal(i.jsx("div",{ref:I,className:"oc-session-popover-menu",role:"menu",style:{left:w.left,top:w.top},children:o?i.jsxs("div",{className:"oc-session-menu-confirm",children:[i.jsx("span",{children:"确定删除这个会话?"}),i.jsxs("div",{children:[i.jsx("button",{type:"button",ref:C,className:"is-danger",disabled:l,"aria-label":`确认删除会话:${v}`,"aria-busy":l||void 0,onClick:()=>e.onConfirmDelete(),children:l?"删除中…":"删除"}),i.jsx("button",{type:"button",disabled:l,"aria-label":"取消删除会话",onClick:()=>{e.onCancelDelete(),_(null)},children:"取消"})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(null);const N=window.prompt("会话名称",t.title||t.displayTitle||"");N!==null&&e.onRename(N)},children:[i.jsx(rh,{size:16,"aria-hidden":"true"}),"编辑标题"]}),i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(null),e.onSetState(a==="active"?"archived":"active")},children:[i.jsx(vN,{size:16,"aria-hidden":"true"}),a==="active"?"归档会话":"恢复会话"]}),i.jsxs("button",{type:"button",role:"menuitem",className:"is-danger",onClick:()=>e.onRequestDelete(),children:[i.jsx(zr,{size:16,"aria-hidden":"true"}),"删除会话"]})]})}),document.body):null]})}function u6(e){return i.jsx(i.Fragment,{children:(e.ordered?["all"]:["active","archived"]).map(t=>{const n=t==="all"?e.sessions:e.sessions.filter(s=>s.state===t);return n.length?i.jsx("div",{className:"oc-session-group",children:n.map(s=>i.jsx(XD,{item:s,href:sh(),active:e.activeSessionId===s.sessionId,streamingNow:e.activeSessionId===s.sessionId&&e.activeSessionStreaming===!0,turnPhaseNow:e.activeSessionId===s.sessionId?e.activeSessionTurnPhase:void 0,state:s.state==="archived"?"archived":"active",deleteConfirming:e.pendingDeleteSessionId===s.sessionId,deleting:e.deletingSessionId===s.sessionId,onActivate:()=>e.onActivate(s.sessionId,e.ownerWorkspaceId),onRename:r=>e.onRename(s.sessionId,r),onSetState:r=>e.onSetState(s.sessionId,r),onRequestDelete:()=>e.onRequestDelete(s),onConfirmDelete:()=>e.onConfirmDelete(s.sessionId),onCancelDelete:e.onCancelDelete,now:e.now},s.sessionId))},t):null})})}function JD(e){const{workspace:t,active:n}=e,s=e.deletingSessionId,r=e.cancelDelete,{expanded:a}=e,[o,l]=f.useState(!1),c=f.useRef(null),d=c6(o||e.dragActive);f.useEffect(()=>{if(!o)return;const b=y=>{c.current?.contains(y.target)||l(!1)},x=y=>{y.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",x)}},[o]);const u=f.useMemo(()=>GO(e.sessions.filter(b=>b.workspaceId===t.workspaceId&&(!b.isBlank||b.sessionId===e.activeSessionId)),K5(),YO()),[e.activeSessionId,e.sessions,t.workspaceId]),h=f.useMemo(()=>{const b=u.slice(0,gu);if(e.activeSessionId&&!b.some(x=>x.sessionId===e.activeSessionId)){const x=u.find(y=>y.sessionId===e.activeSessionId);x&&b.push(x)}return b},[u,e.activeSessionId]),p=f.useMemo(()=>e.showAllSessions||e.sessionsExpanded||u.length<=gu?u:h,[u,h,e.sessionsExpanded,e.showAllSessions]),m=Math.max(0,u.length-h.length),g=e.sessionListPhase==="ready"?"此工作区暂无会话。":e.sessionListState==="error"?"会话列表暂时不可用。":"正在加载会话…",v=!!(e.activeSessionId&&u.some(b=>b.sessionId===e.activeSessionId));return i.jsxs("div",{className:`oc-workspace-item${n?" is-active":""}${e.dragging?" is-dragging":""}${e.dropMarker?` is-drop-${e.dropMarker}`:""}`,"data-workspace-id":t.workspaceId,"aria-current":n?"true":void 0,onDragOver:e.dragActive?b=>{b.preventDefault(),b.dataTransfer.dropEffect="move";const x=b.currentTarget.getBoundingClientRect();e.onDragHover(b.clientY<x.top+x.height/2?"before":"after")}:void 0,onDrop:e.dragActive?b=>{b.preventDefault();const x=b.currentTarget.getBoundingClientRect();e.onDragDrop(b.clientY<x.top+x.height/2?"before":"after")}:void 0,children:[i.jsxs("div",{className:"oc-workspace-row",onPointerEnter:d.onPointerEnter,onPointerLeave:d.onPointerLeave,children:[i.jsxs("button",{type:"button",className:"oc-workspace-main",draggable:!o&&!e.removing,onDragStart:b=>{b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",t.workspaceId),e.onDragStart()},onDragEnd:e.onDragEnd,onClick:e.onToggleExpanded,"aria-expanded":a,children:[i.jsx("span",{className:"oc-workspace-caret","aria-hidden":"true",children:i.jsx(UD,{open:a})}),i.jsx("span",{className:`oc-workspace-folder${a&&v?" is-current":""}`,"aria-hidden":"true",children:i.jsx(a6,{})}),i.jsx("strong",{children:t.name})]}),i.jsxs("div",{className:"oc-workspace-actions",ref:c,children:[i.jsx("button",{type:"button",title:"更多","aria-label":`${t.name} 更多操作`,"aria-expanded":o,onClick:b=>{b.stopPropagation(),l(x=>!x)},children:i.jsx(iv,{size:16,"aria-hidden":"true"})}),i.jsx("button",{type:"button",title:"新建对话","aria-label":`在 ${t.name} 新建对话`,disabled:e.creatingSession,onClick:b=>{b.stopPropagation(),e.onCreateSession()},children:e.creatingSession?i.jsx("span",{className:"oc-spinner","aria-hidden":"true"}):i.jsx(Io,{size:16,"aria-hidden":"true"})}),o?i.jsxs("div",{className:"oc-workspace-menu",role:"menu",children:[i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{l(!1),e.onCreateSession()},children:[i.jsx(Io,{size:15,"aria-hidden":"true"}),"新建会话"]}),i.jsxs("button",{type:"button",role:"menuitem",className:"is-danger",disabled:e.removing,onClick:()=>{l(!1),e.onRemove()},children:[i.jsx(zr,{size:15,"aria-hidden":"true"}),e.removing?"移除中…":"移除工作区"]})]}):null]}),i.jsxs(d6,{anchor:d.anchor,onPointerEnter:d.onCardPointerEnter,onPointerLeave:d.onPointerLeave,children:[i.jsx("strong",{children:t.name}),i.jsx("span",{className:"oc-sidebar-hover-path",children:t.displayPath}),t.createdAt?i.jsxs("span",{children:["添加于 ",l6(t.createdAt)]}):null]})]}),a?i.jsxs("div",{className:"oc-workspace-sessions",children:[i.jsx(u6,{sessions:p,ordered:!0,ownerWorkspaceId:t.workspaceId,activeSessionId:e.activeSessionId,activeSessionStreaming:e.activeSessionStreaming,activeSessionTurnPhase:e.activeSessionTurnPhase,pendingDeleteSessionId:e.pendingDeleteSessionId,deletingSessionId:e.deletingSessionId,onActivate:(b,x)=>{s||(r(!1),e.onActivate(b,x))},onRename:e.onRenameSession,onSetState:e.onSetSessionState,onRequestDelete:e.onRequestDeleteSession,onConfirmDelete:e.onConfirmDeleteSession,onCancelDelete:e.onCancelDeleteSession,now:e.now}),m>0&&!e.showAllSessions?i.jsx("button",{type:"button",className:"oc-session-more",onClick:e.onToggleSessionsExpanded,"aria-expanded":e.sessionsExpanded,children:e.sessionsExpanded?"收起":`展开其余 ${m} 个会话`}):null,p.length===0?i.jsx("p",{className:"oc-tree-empty",children:g}):null]}):null]})}function QD(e){const[t,n]=f.useState(!1),[s,r]=f.useState(""),[a,o]=f.useState(!1),[l,c]=f.useState(!1),[d,u]=f.useState(()=>Date.now()),[h,p]=f.useState(!1),m=f.useRef(null),g=f.useMemo(()=>new Set(e.workspaces.map(Z=>Z.workspaceId)),[e.workspaces]),v=f.useMemo(()=>e.sessions.filter(Z=>e.workspacesLoading||!Z.workspaceId||g.has(Z.workspaceId)),[e.sessions,g,e.workspacesLoading]),b=f.useMemo(()=>{const Z=s.trim().toLocaleLowerCase();return v.filter(ue=>!ue.isBlank||ue.sessionId===e.activeSessionId).filter(ue=>!Z||(ue.title||ue.displayTitle||"未命名对话").toLocaleLowerCase().includes(Z))},[v,e.activeSessionId,s]),x=f.useMemo(()=>b.filter(Z=>!Z.workspaceId),[b]),y=f.useMemo(()=>{const Z=x.slice(0,gu);if(e.activeSessionId&&!Z.some(ue=>ue.sessionId===e.activeSessionId)){const ue=x.find(_e=>_e.sessionId===e.activeSessionId);ue&&Z.push(ue)}return Z},[x,e.activeSessionId]),C=f.useMemo(()=>s.trim()||h||x.length<=gu?x:y,[x,y,s,h]),S=Math.max(0,x.length-y.length),[I,w]=f.useState(()=>new Set(e.activeWorkspaceId?[e.activeWorkspaceId]:[])),[_,k]=f.useState(()=>new Set),[N,L]=f.useState(null),O=f.useRef(!1);f.useEffect(()=>{const Z=e.activeWorkspaceId;Z&&w(ue=>{if(ue.has(Z))return ue;const _e=new Set(ue);return _e.add(Z),_e})},[e.activeWorkspaceId]);const T=f.useCallback(Z=>{const ue=I.has(Z);w(_e=>{const Oe=new Set(_e);return Oe.has(Z)?Oe.delete(Z):Oe.add(Z),Oe}),ue&&k(_e=>{if(!_e.has(Z))return _e;const Oe=new Set(_e);return Oe.delete(Z),Oe})},[I]),R=f.useCallback(Z=>{k(ue=>{const _e=new Set(ue);return _e.has(Z)?_e.delete(Z):_e.add(Z),_e})},[]),A=f.useCallback((Z,ue)=>{if(!N||O.current)return;O.current=!0;const _e=N.sourceId;L(null);const Oe=zD(e.workspaces,_e,Z,ue);Oe!==void 0&&e.onReorderWorkspace(_e,Oe)},[e.onReorderWorkspace,e.workspaces,N]),E=f.useCallback(()=>{const Z=N?.over;if(!Z){L(null);return}A(Z.workspaceId,Z.half)},[A,N]);f.useEffect(()=>{if(!N)return;const Z=ue=>ue.preventDefault();return document.addEventListener("dragover",Z),()=>document.removeEventListener("dragover",Z)},[N]),f.useEffect(()=>{const Z=window.setInterval(()=>u(Date.now()),6e4);return()=>window.clearInterval(Z)},[]);const[$,H]=f.useState(null),[B,G]=f.useState(null),z=f.useRef(null),Q=f.useRef(!1),W=e.layoutMode==="comfortable"&&e.open,D=e.layoutMode==="compact",ee=e.drawerOpen&&(e.layoutMode==="compact"||e.layoutMode==="narrow"),F=f.useCallback((Z=!0)=>{if(B)return;const ue=$;H(null),!(!Z||!ue)&&window.requestAnimationFrame(()=>{const _e=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(ue):ue.replace(/["\\]/g,"\\$&");document.querySelector(`[data-session-delete-id="${_e}"]`)?.focus()})},[B,$]),M=f.useCallback(()=>{B||(H(null),e.onCloseDrawer())},[B,e.onCloseDrawer]),U=f.useCallback(()=>{if($){F();return}M()},[F,M,$]);Ko({open:ee,containerRef:z,triggerRef:e.drawerTriggerRef,onEscape:U}),f.useEffect(()=>{Q.current&&!ee&&!B&&H(null),Q.current=ee},[B,ee]),f.useEffect(()=>{$&&!b.some(Z=>Z.sessionId===$)&&H(null),B&&!b.some(Z=>Z.sessionId===B)&&G(null)},[B,$,b]),f.useEffect(()=>{if(ee||!$)return;const Z=ue=>{ue.key==="Escape"&&(ue.preventDefault(),F())};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[F,$,ee]);const q=f.useCallback(async Z=>{if(!(B||$!==Z)){G(Z);try{await e.onDelete(Z)}finally{G(null),H(null)}}},[B,$,e.onDelete]),te=f.useCallback(()=>{B||(F(!1),e.onCreate())},[F,B,e.onCreate]),se=f.useCallback((Z,ue)=>{B||(F(!1),w(_e=>{if(_e.has(Z))return _e;const Oe=new Set(_e);return Oe.add(Z),Oe}),e.onCreateInWorkspace?e.onCreateInWorkspace(Z,ue):e.onCreate(ue))},[F,B,e.onCreateInWorkspace,e.onCreate]),he=f.useCallback(()=>{B||(F(!1),e.onToggleOpen())},[F,B,e.onToggleOpen]),[X,re]=f.useState(!1),de=f.useCallback(async()=>{if(!(X||e.addingWorkspace)){re(!0);try{const Z=await e.onPickWorkspaceDirectory();Z&&await e.onAddWorkspace(Z)}finally{re(!1)}}},[X,e.addingWorkspace,e.onAddWorkspace,e.onPickWorkspaceDirectory]),xe=f.useCallback(()=>{if(n(!0),e.layoutMode==="comfortable"&&!e.open){he();return}(e.layoutMode==="compact"||e.layoutMode==="narrow")&&!e.drawerOpen&&e.onOpenDrawer()},[he,e.drawerOpen,e.layoutMode,e.onOpenDrawer,e.open]),K=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"oc-sidebar-primary-actions",children:[i.jsxs("button",{type:"button",className:"oc-sidebar-new-session","aria-label":"新建会话",onClick:te,disabled:e.creatingSession,"aria-busy":e.creatingSession||void 0,children:[i.jsx(Io,{size:14,"aria-hidden":"true"}),e.creatingSession?"创建中…":"新会话"]}),e.layoutMode==="comfortable"?i.jsx("button",{type:"button",className:"oc-sidebar-toggle",onClick:he,"aria-expanded":!0,"aria-label":"收起侧栏",title:"收起侧栏",children:i.jsx(mg,{})}):i.jsx("button",{type:"button",className:"oc-sidebar-toggle",onClick:M,"aria-label":"关闭侧栏抽屉",title:"关闭",children:i.jsx(Wn,{size:16,"aria-hidden":"true"})})]}),i.jsx("nav",{className:"oc-sidebar-panels","aria-label":"工作区页面",children:i.jsxs("button",{type:"button",className:"oc-sidebar-panel","aria-label":"自动化任务","aria-current":e.automationActive?"page":void 0,onClick:e.onOpenAutomation,children:[i.jsx(jo,{size:16,"aria-hidden":"true"}),i.jsx("span",{children:"自动化任务"})]})}),i.jsxs("section",{className:"oc-sidebar-section oc-workspaces","aria-busy":e.workspacesLoading||e.sessionListState==="loading"||void 0,"aria-label":"Workspace 与会话",children:[i.jsxs("header",{children:[i.jsx("strong",{children:"工作区"}),i.jsxs("div",{className:"oc-sidebar-header-actions",children:[i.jsx("button",{type:"button",className:"oc-sidebar-icon-action","aria-label":"搜索会话",title:"搜索会话","aria-expanded":t,"aria-controls":"oc-session-search",onClick:()=>n(Z=>!Z),children:i.jsx(mo,{size:16,"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"oc-sidebar-icon-action","aria-label":"添加工作区",title:X?"选择目录中…":"添加工作区","aria-busy":X||void 0,disabled:X||e.addingWorkspace,onClick:()=>{de()},children:i.jsx(Sw,{})})]})]}),t?i.jsxs("div",{className:"oc-session-search-wrap",children:[i.jsx(mo,{size:15,"aria-hidden":"true"}),i.jsx("input",{id:"oc-session-search",type:"search",value:s,onChange:Z=>r(Z.target.value),placeholder:"搜索会话…","aria-label":"搜索会话",autoFocus:!0})]}):null,e.workspacesError?i.jsxs("p",{className:"oc-sidebar-error",role:"alert",children:[e.workspacesError," ",i.jsx("button",{type:"button",className:"btn btn-ghost",onClick:e.onDismissWorkspaceError,"aria-label":"关闭错误提示",children:i.jsx(Wn,{size:12,"aria-hidden":"true"})})]}):null,e.sessionListState==="error"&&e.sessionListError?i.jsxs("p",{className:"oc-sidebar-error",role:"alert",children:[e.sessionListError," ",i.jsx("button",{type:"button",className:"btn btn-ghost",onClick:e.onRefreshSessions,"aria-label":"重试加载会话",title:"重试",children:i.jsx(mi,{size:12,"aria-hidden":"true"})})]}):null,i.jsx("div",{className:"oc-workspace-list",children:e.workspacesLoading&&e.workspaces.length===0?i.jsx("p",{className:"oc-workspace-loading",children:"正在加载 Workspace…"}):e.workspaces.length===0&&C.length===0?i.jsx("p",{className:"oc-workspace-empty",children:"还没有工作区。点击右上角的 + 选择一个文件夹开始。"}):i.jsxs(i.Fragment,{children:[e.workspaces.map(Z=>i.jsx(JD,{workspace:Z,active:e.activeWorkspaceId===Z.workspaceId,expanded:I.has(Z.workspaceId)||!!s.trim(),sessionsExpanded:_.has(Z.workspaceId),removing:e.removingWorkspaceId===Z.workspaceId,dragging:N?.sourceId===Z.workspaceId,dragActive:N!==null,dropMarker:N?.over?.workspaceId===Z.workspaceId?N.over.half:null,onDragStart:()=>{O.current=!1,L({sourceId:Z.workspaceId,over:null})},onDragEnd:E,onDragHover:ue=>L(_e=>_e&&{sourceId:_e.sourceId,over:{workspaceId:Z.workspaceId,half:ue}}),onDragDrop:ue=>A(Z.workspaceId,ue),sessions:b,sessionListPhase:e.sessionListPhase,sessionListState:e.sessionListState,activeSessionId:e.activeSessionId,activeSessionStreaming:e.activeSessionStreaming,activeSessionTurnPhase:e.activeSessionTurnPhase,showAllSessions:!!s.trim(),creatingSession:e.creatingSession,pendingDeleteSessionId:$,deletingSessionId:B,cancelDelete:F,onToggleExpanded:()=>T(Z.workspaceId),onToggleSessionsExpanded:()=>R(Z.workspaceId),onRemove:()=>e.onRemoveWorkspace(Z.workspaceId),onCreateSession:ue=>se(Z.workspaceId,ue),onActivate:(ue,_e)=>{B||(F(!1),e.onActivate(ue,_e))},onRenameSession:e.onRename,onSetSessionState:e.onSetState,onRequestDeleteSession:ue=>{B||H(ue.sessionId)},onConfirmDeleteSession:ue=>{q(ue)},onCancelDeleteSession:()=>F(),now:d},Z.workspaceId)),C.length>0?i.jsxs("div",{className:"oc-workspace-item oc-workspace-ungrouped",children:[i.jsx("div",{className:"oc-workspace-row",children:i.jsxs("div",{className:"oc-workspace-main","aria-label":"未归类会话",children:[i.jsx("span",{className:"oc-workspace-caret","aria-hidden":"true"}),i.jsx("span",{className:`oc-workspace-folder${e.activeSessionId&&x.some(Z=>Z.sessionId===e.activeSessionId)?" is-current":""}`,"aria-hidden":"true",children:i.jsx(a6,{})}),i.jsx("strong",{children:"未归类"})]})}),i.jsxs("div",{className:"oc-workspace-sessions",children:[i.jsx(u6,{sessions:C,activeSessionId:e.activeSessionId,activeSessionStreaming:e.activeSessionStreaming,activeSessionTurnPhase:e.activeSessionTurnPhase,pendingDeleteSessionId:$,deletingSessionId:B,onActivate:(Z,ue)=>{B||(F(!1),e.onActivate(Z,ue))},onRename:e.onRename,onSetState:e.onSetState,onRequestDelete:Z=>{B||H(Z.sessionId)},onConfirmDelete:Z=>{q(Z)},onCancelDelete:()=>F(),now:d}),S>0&&!s.trim()?i.jsx("button",{type:"button",className:"oc-session-more",onClick:()=>p(Z=>!Z),"aria-expanded":h,children:h?"收起":`展开其余 ${S} 个会话`}):null]})]}):null]})})]}),i.jsx("div",{className:"oc-sidebar-footer",children:i.jsxs("button",{type:"button",ref:W?m:void 0,className:"oc-sidebar-settings",onClick:()=>c(!0),"aria-label":"打开设置",title:"设置",children:[i.jsx(ic,{size:16,"aria-hidden":"true"}),a?i.jsx("i",{className:"oc-update-dot",role:"img","aria-label":"有新版本可用"}):null,"设置"]})})]}),pe=i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":e.creatingSession?"创建会话中":"新建会话",title:e.creatingSession?"创建中…":"新建会话",onClick:te,disabled:e.creatingSession,"aria-busy":e.creatingSession||void 0,children:i.jsx(VD,{})}),i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":"自动化任务","aria-current":e.automationActive?"page":void 0,title:"自动化任务",onClick:e.onOpenAutomation,children:i.jsx(jo,{size:18,"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":"搜索会话",title:"搜索会话",onClick:xe,children:i.jsx(mo,{size:18,"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":"添加工作区",title:X?"选择目录中…":"添加工作区","aria-busy":X||void 0,disabled:X||e.addingWorkspace,onClick:()=>{de()},children:i.jsx(Sw,{})}),i.jsx("span",{className:"oc-sidebar-rail-spacer","aria-hidden":"true"}),i.jsxs("button",{type:"button",className:"oc-sidebar-rail-btn",ref:W?void 0:m,"aria-label":"打开设置",title:"设置",onClick:()=>c(!0),children:[i.jsx(ic,{size:18,"aria-hidden":"true"}),a?i.jsx("i",{className:"oc-update-dot",role:"img","aria-label":"有新版本可用"}):null]})]});return i.jsxs(i.Fragment,{children:[D?i.jsxs("nav",{className:"oc-sidebar-rail","aria-label":"紧凑侧栏",children:[i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":"打开 Workspace 与会话",title:"Workspace 与会话","aria-expanded":ee,onClick:()=>ee?M():e.onOpenDrawer(),children:i.jsx(WD,{})}),pe]}):null,e.layoutMode==="comfortable"?i.jsx("aside",{className:`oc-sidebar${W?"":" is-collapsed"}`,"aria-label":"Workspace 与会话",children:W?K:i.jsxs("nav",{className:"oc-sidebar-rail","aria-label":"折叠侧栏快捷入口",children:[i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn",onClick:he,"aria-expanded":!1,"aria-label":"展开侧栏",title:"展开侧栏",children:i.jsx(mg,{})}),pe]})}):null,ee?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"oc-overlay-backdrop","aria-label":"关闭侧栏遮罩",onClick:M}),i.jsx("aside",{ref:z,className:"oc-sidebar oc-sidebar-drawer","aria-label":"Workspace 与会话抽屉",role:"dialog","aria-modal":"true",tabIndex:-1,children:K})]}):null,i.jsx(DD,{onUpdateAvailableChange:o,open:l,origin:e.origin,readiness:e.readiness,runAction:e.runAction,operatorBusy:e.operatorBusy,activeWorkspaceId:e.activeWorkspaceId,onClose:()=>c(!1),triggerRef:m})]})}const ai={count:8,quote:4e3,comment:2e3,totalText:16e3,jsonBytes:65536};function mn(e,t=1024){return typeof e=="string"&&e.length>0&&e.length<=t}function fl(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function eP(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;if(!mn(t.workspaceId))return!1;const n={browser:["kind","workspaceId","tabId","documentId","url","tag","selector","rect","truncated"],message:["kind","workspaceId","sessionId","messageId","role","version","anchor"],file:["kind","workspaceId","path","version","versionScope","view","anchor","startLine","endLine","sheet","cellRange"],diff:["kind","workspaceId","path","side","comparison","version","startLine","endLine"],terminal:["kind","workspaceId","terminalSessionId","ownerSessionId","shell","anchor"],api:["kind","workspaceId","method","url","status","elapsedMs","anchor"]},s=typeof t.kind=="string"?n[t.kind]:void 0;if(!s||Object.keys(t).some(r=>!s.includes(r)))return!1;switch(t.kind){case"browser":{const r=t.rect;return fl(t.tabId)&&mn(t.documentId)&&mn(t.url,2048)&&mn(t.tag,64)&&mn(t.selector)&&!!r&&typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).every(a=>["x","y","width","height"].includes(a))&&[r.x,r.y,r.width,r.height].every(a=>typeof a=="number"&&Number.isFinite(a))&&typeof r.width=="number"&&r.width>0&&typeof r.height=="number"&&r.height>0&&(t.truncated===void 0||typeof t.truncated=="boolean")}case"message":return mn(t.sessionId)&&mn(t.messageId)&&(t.role==="user"||t.role==="assistant")&&mn(t.version)&&mn(t.anchor);case"file":return!mn(t.path)||!mn(t.version)||t.versionScope!=="file"&&t.versionScope!=="prefix"||!mn(t.anchor)?!1:t.view==="sheet"?t.startLine===void 0&&t.endLine===void 0&&(t.sheet===void 0||mn(t.sheet,256))&&typeof t.cellRange=="string"&&/^[A-Z]{1,3}[1-9]\d{0,6}(:[A-Z]{1,3}[1-9]\d{0,6})?$/.test(t.cellRange):(t.view==="source"||t.view==="markdown"||t.view==="html")&&t.sheet===void 0&&t.cellRange===void 0&&(t.startLine===void 0&&t.endLine===void 0||t.view==="source"&&fl(t.startLine)&&fl(t.endLine)&&t.endLine>=t.startLine);case"diff":return mn(t.path)&&(t.side==="old"||t.side==="new")&&mn(t.comparison)&&mn(t.version)&&fl(t.startLine)&&fl(t.endLine)&&t.endLine>=t.startLine;case"terminal":return mn(t.terminalSessionId)&&mn(t.ownerSessionId)&&mn(t.shell)&&mn(t.anchor);case"api":return typeof t.method=="string"&&/^[A-Za-z]{1,16}$/.test(t.method)&&mn(t.url,2048)&&typeof t.status=="number"&&Number.isFinite(t.status)&&typeof t.elapsedMs=="number"&&Number.isFinite(t.elapsedMs)&&t.elapsedMs>=0&&mn(t.anchor);default:return!1}}function or(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>ai.count)throw new Error("最多可添加 8 条引用");const t=JSON.stringify(e);if(new TextEncoder().encode(t).byteLength>ai.jsonBytes)throw new Error("引用数据超过 64 KiB");let n=0;const s=new Set;for(const r of e){if(!r||typeof r!="object"||Object.keys(r).some(a=>!["id","capturedAt","quote","comment","source","attachmentId","screenshotId"].includes(a))||!mn(r.id,128)||s.has(r.id)||!mn(r.capturedAt,64)||!Number.isFinite(Date.parse(r.capturedAt))||typeof r.quote!="string"||!r.quote.trim()||r.quote.length>ai.quote||typeof r.comment!="string"||r.comment.length>ai.comment||!eP(r.source)||r.screenshotId!==void 0&&(r.source.kind!=="browser"||typeof r.screenshotId!="string"||!/^[0-9a-f-]{36}$/i.test(r.screenshotId))||r.attachmentId!==void 0&&!mn(r.attachmentId,128))throw new Error("引用格式或长度无效,请重新选择");s.add(r.id),n+=r.quote.length+r.comment.length}if(e.filter(r=>r.screenshotId).length>4)throw new Error("最多添加 4 张引用截图");if(n>ai.totalText)throw new Error("引用原文与评论合计超过 16,000 字符");return structuredClone(e)}function tP(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>8)throw new Error("最多保存 8 份失败提交,请先恢复");return e.map(t=>{if(!t||typeof t!="object"||Object.keys(t).some(n=>n!=="text"&&n!=="references")||typeof t.text!="string"||new TextEncoder().encode(t.text).byteLength>65536)throw new Error("失败草稿格式或长度无效");return{text:t.text,references:or(t.references)}})}function Fv(e){const t=`
|
|
47
|
+
models.json 中的该 Provider 配置(含内联字段)会被移除;auth.json 凭据不受影响。`)&&e.onMutate({action:"remove-provider",provider:t.name}).then(p=>{p&&e.onDeleted()})},children:i.jsx(zr,{size:14})})})]}),n?i.jsxs("div",{className:"oc-models-editor",children:[i.jsxs("div",{className:"oc-models-field-grid",children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"Base URL"}),i.jsx("input",{type:"text",value:r,placeholder:"默认(由 Pi CLI 配置)",disabled:s,onChange:p=>a(p.target.value)})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"协议"}),i.jsx("input",{type:"text",value:o,placeholder:"默认(如 openai)",disabled:s,onChange:p=>l(p.target.value)})]})]}),u?i.jsxs("div",{className:"oc-models-editor-actions",children:[i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",disabled:s,onClick:()=>{a(t.baseUrl??""),l(t.api??"")},children:"取消"}),i.jsxs("button",{type:"button",className:"oc-models-btn is-primary",disabled:s,onClick:()=>{h()},children:[s?i.jsx(rc,{className:"oc-spin",size:14}):null,"保存端点"]})]}):null,i.jsxs("div",{className:"oc-models-catalog",children:[i.jsxs("div",{className:"oc-models-catalog-head",children:[i.jsxs("div",{className:"oc-models-catalog-title",children:[i.jsx("span",{children:"模型"}),i.jsx("span",{className:"oc-models-meta",children:t.models.length?`${t.models.length} 个`:"暂无"})]}),i.jsxs("button",{type:"button",className:"oc-models-btn is-add-model",disabled:s,onClick:()=>d(p=>!p),children:[i.jsx(Io,{size:14,"aria-hidden":"true"}),"新增模型"]})]}),c?i.jsx(hD,{provider:t.name,busy:s,onMutate:e.onMutate,onSaved:()=>d(!1),onCancel:()=>d(!1)}):null,t.models.length===0&&!c?i.jsx("div",{className:"oc-models-empty",children:"该 Provider 暂无模型。"}):null,t.models.map(p=>i.jsx(uD,{provider:t.name,model:p,busy:s,onMutate:e.onMutate},`${t.name}/${p.id}`))]})]}):null]})}function uD(e){const{model:t,provider:n,busy:s}=e,[r,a]=f.useState(()=>ug(t)),[o,l]=f.useState(!1),[c,d]=f.useState(!1);f.useEffect(()=>{a(ug(t))},[t]);const u=lD(r,t),h=async()=>{d(!0);try{await e.onMutate({action:"upsert-model",provider:n,model:Q5(r)})}finally{d(!1)}},p=m=>{a(g=>({...g,inputs:g.inputs.includes(m)?g.inputs.filter(v=>v!==m):[...g.inputs,m]}))};return i.jsxs("div",{className:`oc-models-entry${o?" is-open":""}`,children:[i.jsxs("div",{className:"oc-models-entry-row",children:[i.jsx("input",{className:"oc-models-input is-id",type:"text",value:r.name,placeholder:"模型名称","aria-label":"模型名称",disabled:s,onChange:m=>a(g=>({...g,name:m.target.value}))}),i.jsx("input",{className:"oc-models-input is-id-code",type:"text",value:r.id,placeholder:"模型 ID","aria-label":"模型 ID",disabled:!0,title:"模型 ID 是唯一键,不可修改"}),u?i.jsx("button",{type:"button",className:`oc-models-btn is-save${c?" is-busy":""}`,disabled:s||c,"aria-label":`保存模型 ${r.id}`,title:"保存修改",onClick:()=>{h()},children:c?i.jsx(rc,{className:"oc-spin",size:14}):i.jsx(Vo,{size:14})}):null,i.jsx("button",{type:"button",className:"oc-models-icon-btn","aria-expanded":o,"aria-label":`高级字段 ${r.id}`,title:"高级字段",onClick:()=>l(m=>!m),children:o?i.jsx(us,{size:14}):i.jsx(Ns,{size:14})}),i.jsx("span",{className:"oc-models-entry-hover",children:i.jsx("button",{type:"button",className:"oc-models-icon-btn is-danger","aria-label":`删除模型 ${r.id}`,title:"删除模型",disabled:s,onClick:()=>{window.confirm(`确认删除模型 ${n}/${r.id}?`)&&e.onMutate({action:"remove-model",provider:n,model:{id:r.id}})},children:i.jsx(zr,{size:14})})})]}),o?i.jsxs("div",{className:"oc-models-entry-advanced",children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"上下文窗口"}),i.jsx("input",{type:"text",inputMode:"numeric",value:r.contextWindow,placeholder:"默认 128000",disabled:s,onChange:m=>a(g=>({...g,contextWindow:m.target.value}))})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"最大输出"}),i.jsx("input",{type:"text",inputMode:"numeric",value:r.maxTokens,placeholder:"默认 16384",disabled:s,onChange:m=>a(g=>({...g,maxTokens:m.target.value}))})]}),i.jsxs("fieldset",{className:"oc-models-field is-input-types",children:[i.jsx("legend",{className:"oc-models-field-label",children:"输入模态"}),i.jsx("div",{className:"oc-models-input-types",children:["text","image"].map(m=>i.jsxs("label",{className:"oc-models-input-choice",children:[i.jsx("input",{type:"checkbox",checked:r.inputs.includes(m),disabled:s,onChange:()=>p(m)}),m==="text"?"文本":"图像"]},m))})]}),i.jsxs("label",{className:"oc-models-field is-check",children:[i.jsx("span",{className:"oc-models-field-label",children:"推理能力"}),i.jsx("input",{type:"checkbox",checked:r.reasoning,disabled:s,onChange:m=>a(g=>({...g,reasoning:m.target.checked}))})]})]}):null]})}function hD(e){const{busy:t}=e,[n,s]=f.useState(()=>({id:"",name:"",contextWindow:"",maxTokens:"",inputs:["text"],reasoning:!0})),[r,a]=f.useState(!1),o=async c=>{if(c.preventDefault(),!!n.id.trim()){a(!0);try{await e.onMutate({action:"upsert-model",provider:e.provider,model:Q5({...n,id:n.id.trim()})})&&e.onSaved()}finally{a(!1)}}},l=c=>{s(d=>({...d,inputs:d.inputs.includes(c)?d.inputs.filter(u=>u!==c):[...d.inputs,c]}))};return i.jsxs("form",{className:"oc-models-add-card",onSubmit:c=>{o(c)},children:[i.jsx("strong",{className:"oc-models-add-title",children:"新增模型"}),i.jsxs("div",{className:"oc-models-field-grid",children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"模型 ID *"}),i.jsx("input",{type:"text",value:n.id,placeholder:"例如 gpt-6-astra",required:!0,disabled:t||r,onChange:c=>s(d=>({...d,id:c.target.value}))})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"模型名称"}),i.jsx("input",{type:"text",value:n.name,placeholder:"可选",disabled:t||r,onChange:c=>s(d=>({...d,name:c.target.value}))})]})]}),i.jsxs("div",{className:"oc-models-field-grid",children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"上下文窗口"}),i.jsx("input",{type:"text",inputMode:"numeric",value:n.contextWindow,placeholder:"默认 128000",disabled:t||r,onChange:c=>s(d=>({...d,contextWindow:c.target.value}))})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"最大输出"}),i.jsx("input",{type:"text",inputMode:"numeric",value:n.maxTokens,placeholder:"默认 16384",disabled:t||r,onChange:c=>s(d=>({...d,maxTokens:c.target.value}))})]})]}),i.jsxs("div",{className:"oc-models-field-grid",children:[i.jsxs("fieldset",{className:"oc-models-field is-input-types",children:[i.jsx("legend",{className:"oc-models-field-label",children:"输入模态"}),i.jsx("div",{className:"oc-models-input-types",children:["text","image"].map(c=>i.jsxs("label",{className:"oc-models-input-choice",children:[i.jsx("input",{type:"checkbox",checked:n.inputs.includes(c),disabled:t||r,onChange:()=>l(c)}),c==="text"?"文本":"图像"]},c))})]}),i.jsxs("label",{className:"oc-models-field is-check",children:[i.jsx("span",{className:"oc-models-field-label",children:"推理能力"}),i.jsx("input",{type:"checkbox",checked:n.reasoning,disabled:t||r,onChange:c=>s(d=>({...d,reasoning:c.target.checked}))})]})]}),i.jsxs("div",{className:"oc-models-editor-actions",children:[i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",disabled:t||r,onClick:()=>e.onCancel(),children:"取消"}),i.jsxs("button",{type:"submit",className:"oc-models-btn is-primary",disabled:t||r||!n.id.trim(),children:[r?i.jsx(rc,{className:"oc-spin",size:14}):null,"添加"]})]})]})}const bw="/api/operator/v1/pi/compaction-settings",pm=.8,xw=2e4,gm=.16,fD=8192;function yw(e){const t=e.trim();if(t==="")return;const n=Number(t);return Number.isFinite(n)?n/100:Number.NaN}function mD(e){const t=e.trim();if(t!=="")return/^\d+$/.test(t)?Number(t):Number.NaN}function pD(e,t,n,s){const r=e-fD,a=r-n;if(r<=0){const c=Math.max(0,e-16384);return{thresholdTokens:c,retainTokens:Math.max(0,Math.floor(c*s))}}if(a<=0){const c=Math.max(0,e-16384);return{thresholdTokens:c,retainTokens:Math.max(0,Math.floor(c*s))}}const o=Math.floor(Math.min(e*t,a));let l=Math.floor(r*s);return l>=o&&(l=Math.max(0,o-1)),{thresholdTokens:o,retainTokens:l}}function gD(e){const[t,n]=f.useState(),[s,r]=f.useState(String(pm*100)),[a,o]=f.useState(String(xw)),[l,c]=f.useState(String(gm*100)),[d,u]=f.useState(!1),[h,p]=f.useState(),[m,g]=f.useState(),v=f.useCallback(async()=>{try{const _=await fetch(bw,{credentials:"include"}),k=await _.json();if(!_.ok||!("ok"in k)||k.ok!==!0)throw new Error("error"in k&&k.error?.message?k.error.message:`无法读取压缩设置(HTTP ${_.status})`);n(k);const N=k.effective;r(String(Math.round(N.thresholdRatio*1e3)/10)),o(String(N.headroomTokens)),c(String(Math.round(N.retainRatio*1e3)/10)),p(void 0)}catch(_){p(_ instanceof Error?_.message:String(_))}},[]);f.useEffect(()=>{v()},[v]);const b=f.useMemo(()=>yw(s),[s]),x=f.useMemo(()=>mD(a),[a]),y=f.useMemo(()=>yw(l),[l]),C=Number.isNaN(b)||Number.isNaN(x)||Number.isNaN(y)||b!==void 0&&(b<=0||b>1)||y!==void 0&&y<=0||b!==void 0&&y!==void 0&&y>=b||x!==void 0&&x<0,S=f.useCallback(async()=>{if(!(C||!t)){u(!0),p(void 0),g(void 0);try{const _={};b!==void 0&&(_.thresholdRatio=b),x!==void 0&&(_.headroomTokens=x),y!==void 0&&(_.retainRatio=y);const k=await fetch(bw,{method:"PUT",credentials:"include",headers:{"content-type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify({expectedRevision:t.revision,settings:_})}),N=await k.json();if(!k.ok||N.ok!==!0)throw new Error(N.error?.message??`保存失败(HTTP ${k.status})`);g("已保存。下一条消息开始按新设置压缩。"),await v()}catch(_){p(_ instanceof Error?_.message:String(_))}finally{u(!1)}}},[x,C,v,b,y,t]),I=typeof e.contextWindow=="number"&&e.contextWindow>0?e.contextWindow:void 0,w=f.useMemo(()=>{if(!(I===void 0||C))return pD(I,b??pm,x??xw,y??gm)},[I,x,C,b,y]);return i.jsxs("div",{className:"oc-compaction","data-testid":"pi-compaction-settings",children:[i.jsxs("div",{className:"oc-compaction-head",children:[i.jsx("span",{className:"oc-compaction-title",children:"上下文压缩"}),i.jsx("p",{className:"oc-compaction-lead",children:"上下文占用达到窗口的一定比例时开始压缩。余量留在触发线与窗口上限之间,窗口越大自动越大。"})]}),i.jsxs("div",{className:"oc-compaction-rows",children:[i.jsx("label",{className:"oc-compaction-label",htmlFor:"pi-threshold-ratio",children:i.jsxs("span",{className:"oc-compaction-label-text",children:["触发窗口比例",t?.envOverrides.thresholdRatio?i.jsx("span",{className:"oc-compaction-hint","data-testid":"threshold-ratio-env-override",children:"当前被环境变量覆盖"}):null]})}),i.jsx("input",{id:"pi-threshold-ratio",className:"oc-compaction-input",type:"number",min:5,max:100,step:1,value:s,onInput:_=>r(_.currentTarget.value),"aria-invalid":C,"data-testid":"pi-threshold-ratio-input"}),i.jsx("span",{className:"oc-compaction-unit",children:"%"}),i.jsx("label",{className:"oc-compaction-label",htmlFor:"pi-headroom-tokens",children:i.jsxs("span",{className:"oc-compaction-label-text",children:["额外余量",t?.envOverrides.headroomTokens?i.jsx("span",{className:"oc-compaction-hint","data-testid":"headroom-env-override",children:"当前被环境变量覆盖"}):null]})}),i.jsx("input",{id:"pi-headroom-tokens",className:"oc-compaction-input",type:"number",min:0,step:1024,value:a,onInput:_=>o(_.currentTarget.value),"aria-invalid":C,"data-testid":"pi-headroom-tokens-input"}),i.jsx("span",{className:"oc-compaction-unit",children:"token"}),i.jsx("label",{className:"oc-compaction-label",htmlFor:"pi-retain-ratio",children:i.jsxs("span",{className:"oc-compaction-label-text",children:["压缩后保留比例",t?.envOverrides.retainRatio?i.jsx("span",{className:"oc-compaction-hint","data-testid":"retain-ratio-env-override",children:"当前被环境变量覆盖"}):null]})}),i.jsx("input",{id:"pi-retain-ratio",className:"oc-compaction-input",type:"number",min:1,max:99,step:1,value:l,onInput:_=>c(_.currentTarget.value),"aria-invalid":C,"data-testid":"pi-retain-ratio-input"}),i.jsx("span",{className:"oc-compaction-unit",children:"%"})]}),w!==void 0?i.jsxs("p",{className:"oc-compaction-note","data-testid":"pi-compaction-effective",children:["压缩触发线 ",i.jsx("strong",{children:w.thresholdTokens})," token,压缩后保留最近"," ",i.jsx("strong",{children:w.retainTokens})," token",i.jsxs("span",{className:"oc-compaction-hint",children:["(当前模型窗口 ",I,")"]}),"。"]}):i.jsxs("p",{className:"oc-compaction-note","data-testid":"pi-compaction-effective",children:["按当前设置,触发线约为窗口的"," ",i.jsxs("strong",{children:[Math.round((b??pm)*100),"%"]}),",并保留最近 ",Math.round((y??gm)*100),"%。"]}),C?i.jsx("p",{className:"oc-compaction-error","data-testid":"pi-compaction-invalid",children:"比例需在 1–100% 之间,保留比例需小于触发比例;余量不能为负。"}):null,h?i.jsx("p",{className:"oc-compaction-error",role:"alert","data-testid":"pi-compaction-error",children:h}):null,m?i.jsx("p",{className:"oc-compaction-note",role:"status","data-testid":"pi-compaction-notice",children:m}):null,i.jsx("div",{className:"oc-compaction-actions",children:i.jsx("button",{type:"button",className:"oc-models-btn is-primary",disabled:d||C||!t,"data-testid":"pi-compaction-save",onClick:()=>{S()},children:d?"保存中…":"保存"})})]})}const vD=[{value:"environment",label:"跟随启动环境"},{value:"direct",label:"直接连接"},{value:"manual",label:"手动代理"}];function bD({origin:e}){const t=`${e.replace(/\/$/,"")}/api/operator/v1/network-proxy`,[n,s]=f.useState(null),[r,a]=f.useState(null),[o,l]=f.useState("loading"),[c,d]=f.useState(null),[u,h]=f.useState(null),[p,m]=f.useState(!1),g=f.useRef({id:0,controller:null}),v=f.useCallback(async(S=!1)=>{g.current.controller?.abort();const I=new AbortController,w=++g.current.id;g.current.controller=I,l("loading"),d(null),h(null);try{const _=await fetch(t,{credentials:"same-origin",cache:"no-store",signal:I.signal}),k=await _.json();if(I.signal.aborted||w!==g.current.id)return;if(!_.ok||!k.ok)throw new Error(k.ok?"网络设置读取失败,请重试。":k.error.message);s(k),a(N=>S&&N?N:k.settings),m(!1),S&&h("已读取最新设置,未保存的修改已保留;请核对后保存。")}catch(_){!I.signal.aborted&&w===g.current.id&&d(_ instanceof Error?_.message:"网络设置读取失败,请重试。")}finally{!I.signal.aborted&&w===g.current.id&&l("idle")}},[t]);f.useEffect(()=>(s(null),a(null),m(!1),v(),()=>{g.current.id++,g.current.controller?.abort()}),[v]);const b=!!(n&&r&&(n.settings.mode!==r.mode||n.settings.proxyUrl!==r.proxyUrl||n.settings.noProxy!==r.noProxy)),x=o!=="idle",y=S=>{a(I=>I&&{...I,...S}),h(null),p||d(null)},C=async()=>{if(!n||!r||x||p||!b)return;g.current.controller?.abort();const S=new AbortController,I=++g.current.id;g.current.controller=S,l("saving"),d(null),h(null);try{const w=await fetch(t,{method:"PUT",credentials:"same-origin",signal:S.signal,headers:{"Content-Type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify({expectedRevision:n.revision,settings:r})}),_=await w.json();if(S.signal.aborted||I!==g.current.id)return;if(w.status===409){m(!0),d("网络设置已在其他页面更新。请先重新加载最新设置;你的未保存修改会保留。");return}if(!w.ok||!_.ok)throw new Error(_.ok?"网络设置保存失败,请重试。":_.error.message);s(_),a(_.settings),h("已保存,新请求立即生效;当前回复保持原连接。尚未验证模型连通性。")}catch(w){!S.signal.aborted&&I===g.current.id&&d(w instanceof Error?w.message:"网络设置保存失败,请重试。")}finally{!S.signal.aborted&&I===g.current.id&&l("idle")}};return i.jsxs("section",{className:"oc-settings-models oc-settings-network","aria-label":"网络代理设置",children:[i.jsx("p",{className:"oc-models-meta",children:"此程序的所有工作区共享。保存后,新请求立即生效,当前回复保持原连接。"}),o==="loading"?i.jsx("p",{className:"oc-models-meta",role:"status",children:"正在读取网络设置…"}):null,c?i.jsx("p",{className:"oc-models-error",role:"alert",children:c}):null,u?i.jsx("p",{className:"oc-models-notice",role:"status",children:u}):null,!n&&o==="idle"?i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",onClick:()=>{v()},children:"重试读取网络设置"}):null,n&&r?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"oc-network-modes",role:"group","aria-label":"代理模式",children:vD.map(S=>i.jsx("button",{type:"button",className:`oc-models-btn ${r.mode===S.value?"is-primary":"is-secondary"}`,"aria-pressed":r.mode===S.value,disabled:x,onClick:()=>y({mode:S.value}),children:S.label},S.value))}),r.mode==="environment"?i.jsx("p",{className:"oc-models-meta",children:"读取启动服务时的 HTTP_PROXY、HTTPS_PROXY 和 NO_PROXY;不会自动扫描操作系统代理设置。"}):null,r.mode==="direct"?i.jsx("p",{className:"oc-models-meta",children:"模型等由此设置管理的请求直接连接,不经过代理。"}):null,r.mode==="manual"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"代理地址"}),i.jsx("input",{type:"text","aria-label":"代理地址",value:r.proxyUrl,placeholder:"http://127.0.0.1:7890",autoComplete:"off",spellCheck:!1,disabled:x,onInput:S=>y({proxyUrl:S.currentTarget.value})}),i.jsx("span",{className:"oc-models-meta",children:"仅支持 HTTP / HTTPS 代理地址,不支持用户名和密码。"})]}),i.jsxs("label",{className:"oc-models-field",children:[i.jsx("span",{className:"oc-models-field-label",children:"不使用代理的地址(可选)"}),i.jsx("input",{type:"text","aria-label":"不使用代理的地址",value:r.noProxy,placeholder:"internal.example,.example.com",autoComplete:"off",spellCheck:!1,disabled:x,onInput:S=>y({noProxy:S.currentTarget.value})}),i.jsx("span",{className:"oc-models-meta",children:"多个地址用逗号分隔;localhost 和本机回环地址始终直连。"})]})]}):null,i.jsxs("div",{className:"oc-network-effective",children:[i.jsx("h3",{children:"上次读取的生效设置"}),i.jsxs("dl",{children:[i.jsx("dt",{children:"HTTP"}),i.jsx("dd",{children:n.effective.httpProxy??"直接连接"}),i.jsx("dt",{children:"HTTPS"}),i.jsx("dd",{children:n.effective.httpsProxy??"直接连接"}),i.jsx("dt",{children:"直连地址"}),i.jsxs("dd",{children:[n.effective.noProxy||"无额外设置",";localhost 和本机回环地址始终直连"]})]})]}),i.jsxs("div",{className:"oc-network-actions",children:[i.jsx("button",{type:"button",className:"oc-models-btn is-primary",disabled:x||p||!b,onClick:()=>{C()},children:o==="saving"?"正在保存…":"保存网络设置"}),i.jsx("button",{type:"button",className:"oc-models-btn is-secondary",disabled:x,onClick:()=>{v(!0)},children:"重新加载(保留草稿)"})]})]}):null,i.jsx("p",{className:"oc-models-meta",children:"仅控制程序内网络请求;SSH、npm 等外部命令仍使用各自的代理配置。"})]})}const e6="loop-console.vcp.preferences.v1",hg="loop-console:vcp-preferences-change",t6=[{id:"auto",label:"智能自选",subtitle:"由模型按场景推荐",scene:"根据正文内容在数据、文献、文学等美学风格间自适应",color:"var(--orange, #f54e00)",bgTint:"color-mix(in srgb, var(--orange, #f54e00) 10%, transparent)"},{id:"porcelain-data",label:"青瓷数据",subtitle:"学术/数据/逻辑时序",scene:"冷静克制,蓝灰主色,明度映射数值,适合报表与指标看板",color:"#3b82f6",bgTint:"rgba(59, 130, 246, 0.12)"},{id:"editorial-minimal",label:"极简杂志",subtitle:"精装杂志/深度商务",scene:"沉静留白,高对比衬线标题,适合深度阅读、决策报告与复盘",color:"#1e293b",bgTint:"rgba(30, 41, 59, 0.1)"},{id:"warm-minimal",label:"暖调极简",subtitle:"轻奢无彩色/纸感",scene:"暖米白宣纸基底,衬线标题搭配黑体正文,适合产品落地页与品牌物料",color:"#b45309",bgTint:"rgba(180, 83, 9, 0.12)"},{id:"ink-letter",label:"笺信书札",subtitle:"纪事/书信/宣纸诗文",scene:"以笺为骨,将数据写成书信,水墨沉敛,适合叙事长文与散文",color:"#475569",bgTint:"rgba(71, 85, 105, 0.12)"},{id:"wabi-sabi",label:"侘寂留白",subtitle:"文学/禅意/残缺美",scene:"不对称构图,枯寂纸质肌理,天然留白,适合散文小说与随笔",color:"#78716c",bgTint:"rgba(120, 113, 108, 0.14)"},{id:"cyberpunk-neon",label:"赛博朋克",subtitle:"终端/黑客/霓虹暗黑",scene:"深底高亮荧光色,等宽代码,HUD 扫描线网格,适合科技与极客场景",color:"#06b6d4",bgTint:"rgba(6, 182, 212, 0.15)"},{id:"wire-news",label:"电讯报刊",subtitle:"快报/榜单/编辑强调",scene:"报纸排版网格,单点警示红,灰阶承载主干,适合新闻与榜单速递",color:"#ef4444",bgTint:"rgba(239, 68, 68, 0.12)"},{id:"pop-flat",label:"波普色块",subtitle:"年轻活力/高饱和插画",scene:"几何扁平撞色,高对比度明黄与粉蓝,适合轻松活泼与消费场景",color:"#ec4899",bgTint:"rgba(236, 72, 153, 0.12)"},{id:"brutalism",label:"粗野主义",subtitle:"直角硬影/先锋态度",scene:"极厚黑边框与直角硬阴影,夸张字号对比,适合潮牌与艺术设计",color:"#0f172a",bgTint:"rgba(15, 23, 42, 0.12)"},{id:"y2k-glass",label:"透光玻璃",subtitle:"未来复古/高透亚克力",scene:"毛玻璃拟态,高饱和渐变光晕,微反光描边,适合时尚与未来感",color:"#8b5cf6",bgTint:"rgba(139, 92, 246, 0.12)"}],Kr={enabled:!0,trustedMode:!0,ioHotWindow:!0,defaultStyle:"auto",exportEmbedFonts:!0,exportFooterMeta:!0};function Lo(){if(typeof window>"u"||!window.localStorage)return{...Kr};try{const e=window.localStorage.getItem(e6);if(!e)return{...Kr};const t=JSON.parse(e);return{enabled:typeof t.enabled=="boolean"?t.enabled:Kr.enabled,trustedMode:typeof t.trustedMode=="boolean"?t.trustedMode:Kr.trustedMode,ioHotWindow:typeof t.ioHotWindow=="boolean"?t.ioHotWindow:Kr.ioHotWindow,defaultStyle:typeof t.defaultStyle=="string"&&t6.some(n=>n.id===t.defaultStyle)?t.defaultStyle:Kr.defaultStyle,exportEmbedFonts:typeof t.exportEmbedFonts=="boolean"?t.exportEmbedFonts:Kr.exportEmbedFonts,exportFooterMeta:typeof t.exportFooterMeta=="boolean"?t.exportFooterMeta:Kr.exportFooterMeta}}catch{return{...Kr}}}function xD(e){const n={...Lo(),...e};if(typeof window<"u"&&window.localStorage)try{window.localStorage.setItem(e6,JSON.stringify(n)),window.dispatchEvent(new CustomEvent(hg,{detail:n}))}catch{}return n}function Pv(){const[e,t]=f.useState(()=>Lo());f.useEffect(()=>{const s=r=>{const a=r;a.detail?t(a.detail):t(Lo())};return window.addEventListener(hg,s),window.addEventListener("storage",s),()=>{window.removeEventListener(hg,s),window.removeEventListener("storage",s)}},[]);const n=f.useCallback(s=>{const r=xD(s);t(r)},[]);return[e,n]}function yD(e){return i.jsx("button",{type:"button",role:"switch",id:e.id,"aria-checked":e.checked,"aria-label":e.ariaLabel,className:`oc-toggle${e.checked?" is-on":""}`,onClick:()=>e.onChange(!e.checked),children:i.jsx("span",{className:"oc-toggle-knob"})})}function hl(e){return i.jsxs("div",{className:"oc-settings-general-row",children:[i.jsxs("div",{className:"oc-settings-general-text",children:[i.jsx("label",{htmlFor:e.id,className:"oc-settings-general-title",children:e.title}),i.jsx("div",{className:"oc-settings-general-desc",children:e.description})]}),i.jsx(yD,{id:e.id,checked:e.checked,onChange:e.onChange,ariaLabel:e.title})]})}function wD(){const[e,t]=Pv();return i.jsxs("div",{className:"oc-settings-vcp",children:[i.jsxs("section",{className:"oc-vcp-group",children:[i.jsx("h3",{className:"oc-vcp-group-title",children:"基础控制"}),i.jsxs("div",{children:[i.jsx(hl,{id:"vcp-enabled",title:"渲染视觉卡片 (VCP)",description:"开启后,模型在正文中输出的 HTML/CSS/JS 卡片将流式呈现为精装排版;关闭则按 Markdown 源码显示",checked:e.enabled,onChange:n=>t({enabled:n})}),i.jsx(hl,{id:"vcp-trusted",title:"可信执行模式",description:"允许卡片运行 JavaScript 脚本、Canvas 交互动画与点击联动,通过沙箱和 CSS 隔离宿主界面",checked:e.trustedMode,onChange:n=>t({trustedMode:n})}),i.jsx(hl,{id:"vcp-hot-window",title:"IO 视口热窗防卡顿",description:"长会话中仅全量渲染屏幕附近的卡片,远古历史卡片自动降级占位,滚动接近无感恢复",checked:e.ioHotWindow,onChange:n=>t({ioHotWindow:n})})]})]}),i.jsxs("section",{className:"oc-vcp-group",children:[i.jsx("h3",{className:"oc-vcp-group-title",children:"排版美学风格库"}),i.jsx("p",{className:"oc-vcp-group-desc",children:"选择默认注入模型设计规范的美学语言,或由模型按内容智能自选"}),i.jsx("div",{className:"oc-vcp-style-grid",role:"radiogroup","aria-label":"排版美学风格",children:t6.map(n=>{const s=e.defaultStyle===n.id;return i.jsxs("button",{type:"button",role:"radio","aria-checked":s,className:`oc-vcp-style-card${s?" is-selected":""}`,onClick:()=>t({defaultStyle:n.id}),children:[i.jsx("span",{className:"oc-vcp-style-swatch",style:{background:n.color}}),i.jsxs("span",{className:"oc-vcp-style-body",children:[i.jsx("span",{className:"oc-vcp-style-name",children:n.label}),i.jsx("span",{className:"oc-vcp-style-sub",children:n.subtitle})]}),s?i.jsx(Vo,{className:"oc-vcp-style-check",size:14,"aria-hidden":"true"}):null]},n.id)})})]}),i.jsxs("section",{className:"oc-vcp-group",children:[i.jsx("h3",{className:"oc-vcp-group-title",children:"下载与导出模版"}),i.jsxs("div",{children:[i.jsx(hl,{id:"vcp-embed-fonts",title:"内嵌离线字体",description:"导出单文件 HTML 时将内置的书法与排版字体转为 Base64 嵌入,保证脱机打开字形完整",checked:e.exportEmbedFonts,onChange:n=>t({exportEmbedFonts:n})}),i.jsx(hl,{id:"vcp-footer-meta",title:"附带导出元信息",description:"在导出文件页脚附带生成时间戳与来源标记",checked:e.exportFooterMeta,onChange:n=>t({exportFooterMeta:n})})]})]})]})}const n6={status:"idle",snapshot:null,error:null,reloading:!1,reloadError:null,mutationBusy:!1,mutationToken:null};function wu(e){if(!e)return!1;const t=e.code??"";return t==="PI_SESSION_NOT_FOUND"||t==="NOT_FOUND"?!0:t==="PI_RUNTIME_UNAVAILABLE"&&/session file missing or not openable|no persisted Pi session file/i.test(e.message??"")}function $v(e){if(!e||typeof e!="object")return{message:"runtime snapshot request failed"};const t=e,n=t.error;if(n&&typeof n=="object"){const s=n;return{...typeof s.code=="string"&&s.code?{code:s.code}:{},...typeof t.status=="number"?{status:t.status}:{},message:typeof s.message=="string"&&s.message?s.message:"runtime snapshot request failed"}}return{...typeof t.status=="number"?{status:t.status}:{},message:typeof t=="object"&&"message"in t&&typeof t.message=="string"&&t.message?t.message:"runtime snapshot request failed"}}function SD(e,t){switch(t.type){case"load-start":return{...e,sessionId:t.sessionId,status:"loading",error:null};case"load-success":return e.snapshot&&e.sessionId===t.sessionId&&t.snapshot.revision<e.snapshot.revision?e:{...e,sessionId:t.sessionId,status:"ready",snapshot:t.snapshot,error:null,reloadError:null,reloading:!1};case"load-failure":return{...e,sessionId:t.sessionId,status:"error",error:t.error,snapshot:null};case"reload-start":return e.reloading?e:{...e,reloading:!0,reloadError:null,...e.status==="error"?{error:null}:{}};case"reload-success":return{...e,status:"ready",snapshot:t.snapshot,reloading:!1,reloadError:null,error:null,sessionId:t.snapshot.sessionId||e.sessionId};case"reload-failure":return{...e,reloading:!1,reloadError:t.error};case"mutation-start":return{...e,mutationBusy:!0,mutationToken:t.token};case"mutation-adopt":return e.mutationToken!==t.token||e.sessionId!==void 0&&e.sessionId!==t.sessionId||e.snapshot&&t.snapshot.revision<e.snapshot.revision?e:{...e,sessionId:t.sessionId,status:"ready",snapshot:t.snapshot,error:null,reloadError:null,reloading:!1};case"mutation-settle":return e.mutationToken!==t.token?e:{...e,mutationBusy:!1,mutationToken:null};case"mutation-reset":return{...e,mutationBusy:!1,mutationToken:null};case"reset":return{...n6};default:return e}}function s6(e){const t=e.selection;return{...t.model?{model:{provider:t.model.provider,modelId:t.model.id}}:{},...t.thinkingSelection==="auto"?t.effectiveThinkingLevel?{thinkingLevel:t.effectiveThinkingLevel}:{}:{thinkingLevel:t.thinkingSelection}}}function _D(e,t,n,s){const r=n&&n.sessionId===s?s6(n):{},a=r.model??e?.model,o=r.thinkingLevel??e?.thinkingLevel;return{readOnly:t.readOnly,systemPrompt:t.systemPrompt,resources:t.resources,suffix:t.suffix,...a?{model:a}:{},...o?{thinkingLevel:o}:{}}}function kD(e=n6){let t=e;const n=new Set;return{getState:()=>t,dispatch:s=>{t=SD(t,s);for(const r of n)r();return t},subscribe:s=>(n.add(s),()=>n.delete(s))}}function CD(e,t,n){return`${e}/api/operator/v1/chat/sessions/${encodeURIComponent(t)}/skills/${encodeURIComponent(n)}/auto-invocation`}async function ID(e){const t=e.fetchImpl??fetch;try{const n=await t(CD(e.origin,e.sessionId,e.resourceId),{method:"PATCH",credentials:"include",headers:{"content-type":"application/json","x-loop-console-confirmation":e.confirmationToken},body:JSON.stringify({autoInvocationEnabled:e.autoInvocationEnabled})}),s=await n.json().catch(()=>({}));if(!n.ok||s.ok===!1)return{ok:!1,error:{...$v(s),status:n.status}};const r=s.preferenceSaved===!0,a=s.reloadApplied===!0;if(!r)return{ok:!1,error:{status:n.status,code:"PI_RESOURCE_PREFERENCES_WRITE_FAILED",message:"preference was not saved"}};if(!a){const o=s.error?.code??"PI_SESSION_BUSY",l=s.error?.message??"preference saved; current session is busy and was not reloaded";return{ok:!0,preferenceSaved:!0,reloadApplied:!1,...s.snapshot?{snapshot:s.snapshot}:{},partialBusy:{code:o,message:l}}}return{ok:!0,preferenceSaved:!0,reloadApplied:!0,...s.snapshot?{snapshot:s.snapshot}:{}}}catch(n){return{ok:!1,error:{message:n instanceof Error?n.message:String(n)}}}}const In=kD();let Dr,go;function r6(e){return`/api/operator/v1/chat/sessions/${encodeURIComponent(e)}`}function ED(e){const t=Dr;if(Dr=e,!(t&&t.sessionId===e.sessionId&&t.origin===e.origin)){if((!t||t.sessionId!==e.sessionId)&&In.dispatch({type:"mutation-reset"}),!e.sessionId){go=void 0,In.dispatch({type:"reset"});return}if(In.dispatch({type:"load-start",sessionId:e.sessionId}),e.deferInitialFetch){go=void 0;return}go=e.sessionId,Bv(e.sessionId,e.origin)}}function ND(e){const t=Dr;!t?.sessionId||t.sessionId!==e||go!==e&&(go=e,Bv(e,t.origin))}async function Bv(e,t){try{const n=await fetch(`${t}${r6(e)}/runtime-snapshot`,{credentials:"include"}),s=await n.json().catch(()=>({}));if(Dr?.sessionId!==e)return;if(!n.ok){const r={...$v(s),status:n.status};if(wu(r)){In.dispatch({type:"reset"}),Dr.onUnrecoverableSession?.(e);return}In.dispatch({type:"load-failure",sessionId:e,error:r});return}if(!s.snapshot){In.dispatch({type:"load-failure",sessionId:e,error:{status:n.status,message:"runtime snapshot missing in response"}});return}In.dispatch({type:"load-success",sessionId:e,snapshot:s.snapshot})}catch(n){if(Dr?.sessionId!==e)return;In.dispatch({type:"load-failure",sessionId:e,error:{message:n instanceof Error?n.message:String(n)}})}}async function Su(){const e=Dr;if(!e?.sessionId||In.getState().reloading)return!1;const t=e.sessionId;In.dispatch({type:"reload-start"});try{const n=await fetch(`${e.origin}${r6(t)}/reload`,{method:"POST",credentials:"include",headers:{"content-type":"application/json","x-loop-console-confirmation":Rt()},body:"{}"}),s=await n.json().catch(()=>({}));return Dr?.sessionId!==t?!1:n.ok?s.snapshot?(In.dispatch({type:"reload-success",snapshot:s.snapshot}),!0):(In.dispatch({type:"reload-failure",error:{status:n.status,message:"reload succeeded but snapshot missing"}}),!1):(In.dispatch({type:"reload-failure",error:{...$v(s),status:n.status}}),!1)}catch(n){return Dr?.sessionId!==t||In.dispatch({type:"reload-failure",error:{message:n instanceof Error?n.message:String(n)}}),!1}}async function fg(){const e=Dr;if(!e?.sessionId)return!1;const t=e.sessionId;return In.dispatch({type:"load-start",sessionId:t}),go=t,Bv(t,e.origin),!0}function jD(e,t,n){return n?(In.dispatch({type:"mutation-adopt",token:e,sessionId:t,snapshot:n}),In.getState().snapshot===n):!1}function TD(e,t,n){return n.sessionRef.current?.sessionId!==t||In.getState().mutationToken!==e?!1:(In.dispatch({type:"mutation-settle",token:e}),!0)}function Ac(){return f.useSyncExternalStore(In.subscribe,In.getState)}function i6(e){In.dispatch(e)}function RD(){return In.getState()}const AD=[{id:"general",label:"通用设置"},{id:"vcp",label:"视觉与排版"},{id:"version",label:"版本"},{id:"pet",label:"宠物"},{id:"sidebar",label:"侧边栏"},{id:"models",label:"模型"},{id:"network",label:"网络"},{id:"skills",label:"技能"},{id:"plugins",label:"插件"},{id:"mcp",label:"MCP"}];function MD(e,t,n){const r=`${e.endsWith("/")?e.slice(0,-1):e}/api/operator/v1/pet/${encodeURIComponent(t)}`;return n?`${r}?workspaceId=${encodeURIComponent(n)}`:r}function LD(e){return e==="models"?i.jsx(Eo,{size:16,"aria-hidden":"true"}):e==="skills"?i.jsx(hN,{size:16,"aria-hidden":"true"}):e==="vcp"?i.jsx(SN,{size:16,"aria-hidden":"true"}):e==="plugins"?i.jsx(BN,{size:16,"aria-hidden":"true"}):e==="mcp"?i.jsx(Qk,{size:16,"aria-hidden":"true"}):e==="network"?i.jsx(LN,{size:16,"aria-hidden":"true"}):e==="general"?i.jsx(ic,{size:16,"aria-hidden":"true"}):e==="sidebar"?i.jsx(IN,{size:16,"aria-hidden":"true"}):e==="version"?i.jsx(_N,{size:16,"aria-hidden":"true"}):e==="pet"?i.jsx(oN,{size:16,"aria-hidden":"true"}):i.jsx(sc,{size:16,"aria-hidden":"true"})}function Ga({children:e}){return i.jsx("p",{className:"oc-settings-empty",children:e})}function OD(e){return e==="loaded"?"已加载":e==="configured"?"已配置":e==="disabled"?"未启用":"状态未知"}function DD(e){const t=_3(e.origin);f.useEffect(()=>{e.onUpdateAvailableChange?.(!!t.info?.updateAvailable)},[t.info?.updateAvailable,e.onUpdateAvailableChange]);const[n,s]=f.useState("general"),[r,a]=f.useState("latest"),[o,l]=f.useState(!1),[c,d]=f.useState(!1),[u,h]=f.useState(null),[p,m]=f.useState("idle"),[g,v]=f.useState(0),[b,x]=f.useState(null),[y,C]=f.useState(null),[S,I]=f.useState("idle"),w=f.useRef({id:0,controller:null}),_=e.open&&n==="version",N=t.info?.channels.find(ae=>ae.channel===r&&ae.status==="newer"&&ae.version)?.version??null,L=N?`${r}:${N}:${t.info?.checkedAt??""}`:null,O=`${e.origin}/api/operator/v1/version/notes`;f.useEffect(()=>{l(!1),d(!1)},[_,O]),f.useEffect(()=>{if(!_){h(null),m("idle");return}const ae=new AbortController;return h(null),m("loading"),fetch(O,{credentials:"same-origin",cache:"no-store",signal:ae.signal}).then(async ne=>{if(!ne.ok)throw new Error("说明读取失败");return await ne.json()}).then(ne=>{if(!ae.signal.aborted){if(ne.source!=="installed"){m("unavailable");return}h(ne),m(ne.status==="unavailable"?"unavailable":"idle")}}).catch(()=>{ae.signal.aborted||m("unavailable")}),()=>ae.abort()},[_,O,g]),f.useEffect(()=>(w.current.id++,w.current.controller?.abort(),w.current.controller=null,x(null),C(null),I("idle"),()=>{w.current.id++,w.current.controller?.abort(),w.current.controller=null}),[_,r,N,t.info?.checkedAt,O]);const T=()=>{if(!_||!N||!L)return;w.current.controller?.abort();const ae=++w.current.id,ne=new AbortController;w.current.controller=ne,x(null),C(L),I("loading");const we=new URLSearchParams({channel:r,version:N});fetch(`${O}?${we}`,{credentials:"same-origin",cache:"no-store",signal:ne.signal}).then(async Ce=>{if(!Ce.ok)throw new Error("目标说明读取失败");return await Ce.json()}).then(Ce=>{if(ne.signal.aborted||w.current.id!==ae)return;const He=Ce.status==="unavailable"&&Ce.targetVersion===void 0&&(Ce.reason==="invalid-candidate"||Ce.reason==="check-failed");if(Ce.source!=="candidate"||Ce.targetVersion!==N&&!He){I("unavailable");return}x(Ce),I(Ce.status==="unavailable"?"unavailable":"idle")}).catch(()=>{!ne.signal.aborted&&w.current.id===ae&&I("unavailable")})},R=()=>{w.current.id++,w.current.controller?.abort(),w.current.controller=null,x(null),C(null),I("idle")},A=()=>{R(),l(!1),d(!1),e.onClose()},[E,$]=f.useState(null),[H,B]=f.useState(null),[G,z]=f.useState(null),[Q,W]=f.useState({}),[D,ee]=f.useState(null),[F,M]=f.useState(null),[U,q]=f.useState(!1),[te,se]=f.useState(!1),[he,X]=f.useState(null),[re,de]=f.useState(""),[xe,K]=f.useState([]),pe=f.useRef(0),Z=f.useRef(null),ue=Ac(),_e=ue.snapshot;Ko({open:e.open,containerRef:Z,triggerRef:e.triggerRef,onEscape:A}),f.useEffect(()=>{if(!e.open)return;let ae=!0;return B(null),fetch(`${e.origin}/api/health`,{credentials:"include"}).then(async ne=>{const we=await ne.json();if(!ne.ok)throw new Error("版本信息读取失败");ae&&$(we)}).catch(ne=>{ae&&B(ne instanceof Error?ne.message:String(ne))}),()=>{ae=!1}},[e.open,e.origin]);const Oe=e.workspaceId??e.activeWorkspaceId??null,Me=ae=>MD(e.origin,ae,Oe);f.useEffect(()=>{const ae=++pe.current;if(K([]),de(""),!e.open||n!=="pet"||!Oe)return;let ne=!0;return se(!0),X(null),fetch(Me("state"),{credentials:"include",cache:"no-store"}).then(async we=>{const Ce=await we.json();if(!we.ok)throw new Error(Ce.error?.message??"宠物设置读取失败");ne&&ae===pe.current&&(q(Ce.display?.visible===!0),de(Ce.petId),K(Ce.pets))}).catch(we=>{ne&&X(we instanceof Error?we.message:String(we))}).finally(()=>{ne&&se(!1)}),()=>{ne=!1,pe.current+=1}},[e.open,e.origin,Oe,n]);const Ie=async ae=>{if(!Oe||te)return;const ne=++pe.current;se(!0),X(null);try{const we=await fetch(Me("select"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify({petId:ae})}),Ce=await we.json();if(!we.ok)throw new Error(Ce.error?.message??"切换宠物失败,请重试");if(ne!==pe.current)return;de(Ce.petId),window.dispatchEvent(new CustomEvent("loop-console-pet-selection",{detail:{workspaceId:Oe,view:Ce}}))}catch(we){ne===pe.current&&X(we instanceof Error?we.message:"切换宠物失败,请重试")}finally{ne===pe.current&&se(!1)}},$e=async()=>{if(!Oe||te)return;const ae=++pe.current,ne=!U;q(ne),se(!0),X(null);try{const we=await fetch(Me("display"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify({visible:ne})}),Ce=await we.json();if(!we.ok)throw new Error(Ce.error?.message??"宠物设置保存失败");if(ae!==pe.current)return;const He=Ce.display?.visible===!0;q(He),window.dispatchEvent(new CustomEvent("loop-console-pet-visibility",{detail:{workspaceId:Oe,visible:He}}))}catch(we){if(ae!==pe.current)return;q(!ne),X(we instanceof Error?we.message:String(we))}finally{ae===pe.current&&se(!1)}},be=f.useMemo(()=>[..._e?.packages.map(ae=>({name:ae.packageName??ae.spec,detail:ae.version?`v${ae.version}`:ae.spec,enabled:ae.enabled}))??[],..._e?.extensions.map(ae=>({name:ae.name,detail:ae.scope,enabled:ae.enabled}))??[]],[_e]);f.useEffect(()=>{z(null),W({}),ee(null),M(null)},[_e?.sessionId]);const oe=(ae,ne)=>Object.hasOwn(Q,ae)?Q[ae]:ne,ge=async ae=>{if(!_e?.sessionId||!ae.resourceId||G)return;const ne=!oe(ae.resourceId,ae.autoInvocationEnabled);z(ae.resourceId),M(null),ee(null),W(Ce=>({...Ce,[ae.resourceId]:ne}));const we=await ID({origin:e.origin,sessionId:_e.sessionId,resourceId:ae.resourceId,autoInvocationEnabled:ne,confirmationToken:Rt()});if(z(null),!we.ok){W(Ce=>{const He={...Ce};return delete He[ae.resourceId],He}),M(`${we.error.code?`${we.error.code}:`:""}${we.error.message}`);return}if(we.reloadApplied&&we.snapshot){i6({type:"load-success",sessionId:_e.sessionId,snapshot:we.snapshot}),W(Ce=>{const He={...Ce};return delete He[ae.resourceId],He});return}we.partialBusy&&ee("设置已保存,将在本轮对话结束并重新加载会话后生效。")};if(!e.open||typeof document>"u")return null;const ke=()=>{if(n==="general")return i.jsx(tD,{});if(n==="vcp")return i.jsx(wD,{});if(n==="models"){const ne=e.activeWorkspaceId??e.workspaceId??null;return i.jsxs("div",{className:"oc-settings-models-stack",children:[i.jsx(cD,{origin:e.origin,workspaceId:ne},ne??"none"),i.jsx(gD,{})]})}if(n==="network")return i.jsx(bD,{origin:e.origin},e.origin);if(n==="version")return i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"oc-version-panel",children:[i.jsxs("header",{className:"oc-version-identity",children:[i.jsx("div",{className:"oc-version-mark","aria-hidden":"true",children:"L"}),i.jsxs("div",{className:"oc-version-identity-copy",children:[i.jsxs("p",{className:"oc-version-product",children:["Loop Agent ",i.jsx("span",{className:"oc-version-badge",children:t.info?.currentChannel==="next"?"预发布版":"稳定版"})]}),i.jsxs("h2",{children:[i.jsx("span",{className:"sr-only",children:"Loop Agent "}),t.info?.currentVersion??E?.packageVersion??"读取中…"]}),i.jsx("p",{className:"oc-version-caption",children:"当前安装版本 · 所有工作区共享"})]})]}),i.jsxs("div",{className:"oc-version-check",children:[i.jsx("h3",{children:"更新渠道"}),i.jsxs("button",{type:"button",disabled:t.checking,onClick:t.recheck,children:[i.jsx(mi,{size:14,"aria-hidden":"true"}),"检查更新"]})]}),i.jsx("p",{className:"oc-version-status","data-update-available":!!t.info?.updateAvailable,role:"status",children:t.checking?"正在检查新版本…":t.error??(t.info?.updateAvailable?"有新版本可用":t.info?.channels.some(ne=>ne.status==="unavailable")?"部分渠道暂时无法检查,30 秒后可重试":"版本检查完成")}),i.jsx(z5,{operatorBusy:!!e.operatorBusy,workspaceId:e.workspaceId??e.activeWorkspaceId??null,versionInfo:t.info}),i.jsxs("div",{className:"oc-version-notes",children:[i.jsx("h3",{className:"oc-version-notes-heading",children:"更新说明"}),i.jsxs("details",{open:o,onToggle:ne=>l(ne.currentTarget.open),children:[i.jsxs("summary",{tabIndex:0,children:[i.jsx(No,{size:17,"aria-hidden":"true"}),i.jsxs("span",{className:"oc-notes-summary-copy",children:[i.jsx("span",{className:"oc-notes-title",children:"本版本更新"}),i.jsx("small",{children:"查看当前安装包的变化"})]}),i.jsx(Ns,{className:"oc-notes-chevron",size:18,"aria-hidden":"true"})]}),o?i.jsxs("section",{className:"oc-notes-installed-content",children:[p==="loading"?i.jsx("p",{role:"status",children:"正在读取已安装版本说明…"}):null,p==="unavailable"?i.jsxs("div",{role:"alert",children:[lg(u,"installed"),i.jsx("button",{type:"button",onClick:()=>v(ne=>ne+1),children:"重试已安装版本说明"})]}):null,p==="idle"&&u?i.jsx(cw,{kind:"installed",notes:u}):null]}):null]}),i.jsxs("details",{className:"oc-notes-candidate",open:c,onToggle:ne=>{const we=ne.currentTarget.open;d(we),we||R()},children:[i.jsxs("summary",{tabIndex:0,onClick:ne=>{ne.currentTarget.parentElement?.hasAttribute("open")&&R()},children:[i.jsx(No,{size:17,"aria-hidden":"true"}),i.jsxs("span",{className:"oc-notes-summary-copy",children:[i.jsx("span",{className:"oc-notes-title",children:"目标版本更新"}),i.jsx("small",{children:"更新前,先了解变化"})]}),i.jsx(Ns,{className:"oc-notes-chevron",size:18,"aria-hidden":"true"})]}),c?i.jsxs("section",{className:"oc-notes-candidate-content",children:[i.jsx("div",{role:"group","aria-label":"目标版本说明渠道",children:["latest","next"].map(ne=>i.jsx("button",{type:"button","aria-pressed":r===ne,onClick:()=>{r!==ne&&(R(),a(ne))},children:ne==="latest"?"稳定版 latest":"预发布版 next"},ne))}),N?i.jsxs("p",{children:["目标版本:",N]}):i.jsx("p",{role:"status",children:t.checking?"正在检查可用目标版本…":"此渠道暂无可查询的新版本说明。"}),N&&(y!==L||S==="idle")&&(!b||y!==L)?i.jsx("button",{type:"button",onClick:T,children:"查看目标版本更新"}):null,y===L&&S==="loading"?i.jsxs("p",{role:"status",children:["正在读取目标版本说明… ",i.jsx("button",{type:"button",onClick:R,children:"取消目标版本说明查询"})]}):null,y===L&&S==="unavailable"?i.jsxs("div",{role:"alert",children:[lg(b,"candidate"),i.jsx("button",{type:"button",onClick:T,children:"重试目标版本说明"})]}):null,y===L&&S==="idle"&&b?i.jsx(cw,{kind:"candidate",notes:b}):null]}):null]})]}),i.jsx("p",{className:"oc-version-footnote",children:"点击更新后才会安装;完成后 Console 自动重启。"})]}),i.jsx(PO,{origin:e.origin,workspaceId:e.activeWorkspaceId??e.workspaceId,runAction:e.runAction},e.activeWorkspaceId??e.workspaceId??"none")]});if(n==="sidebar")return i.jsx(aD,{});if(n==="pet")return i.jsxs("section",{className:"oc-settings-pet",children:[i.jsxs("div",{className:"oc-settings-pet-row",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"显示桌面宠物"}),i.jsx("p",{children:"开启后对话页只出现爪印。展开后才会跟随工作状态活动,可在下方选择喜欢的形象。"})]}),i.jsx("button",{type:"button",className:`oc-toggle${U?" is-on":""}`,role:"switch","aria-checked":U,"aria-label":`${U?"关闭":"开启"}桌面宠物`,disabled:te||!Oe,onClick:()=>{$e()},children:i.jsx("span",{className:"oc-toggle-knob","aria-hidden":"true"})})]}),i.jsxs("div",{className:"oc-settings-pet-choice",children:[i.jsx("strong",{children:"宠物形象"}),i.jsx("div",{className:"pet-switch",role:"group","aria-label":"宠物形象",children:xe.map(ne=>i.jsx("button",{type:"button","aria-pressed":re===ne.id,"data-active":re===ne.id,disabled:te||!Oe,onClick:()=>{Ie(ne.id)},children:ne.displayName},ne.id))})]}),i.jsx("p",{className:"oc-settings-help",children:"默认关闭,按工作区保存。关闭后对话页不出现宠物。爪印不读取宠物状态;展开后才会跟随会话,收起不会关闭此开关。形象、好感度、食物和位置仍然保存。"}),Oe?null:i.jsx("p",{className:"oc-settings-error",children:"请先选择工作区。"}),he?i.jsx("p",{className:"oc-settings-error",role:"alert",children:he}):null]});if(ue.status==="loading"||ue.status==="idle")return i.jsx(Ga,{children:"正在读取当前会话的运行配置…"});if(ue.status==="error")return i.jsx(Ga,{children:ue.error?.message??"运行配置读取失败"});if(!_e)return i.jsx(Ga,{children:"新建或打开一个会话后即可查看。"});if(n==="skills")return _e.skills.length?i.jsxs("div",{className:"oc-settings-skill-section",children:[i.jsx("p",{className:"oc-settings-help",children:"开启后允许模型自动选择并注入该技能上下文;关闭后仍可手动调用。"}),F?i.jsx("p",{className:"oc-settings-error",role:"alert",children:F}):null,D?i.jsx("p",{className:"oc-settings-notice",role:"status",children:D}):null,i.jsx("ul",{className:"oc-settings-list",children:_e.skills.map(ne=>{const we=oe(ne.resourceId,ne.autoInvocationEnabled),Ce=G===ne.resourceId;return i.jsxs("li",{children:[i.jsxs("div",{children:[i.jsx("strong",{children:ne.name}),i.jsx("span",{children:ne.description||ne.scope})]}),i.jsxs("div",{className:"oc-settings-skill-control",children:[i.jsx("em",{children:we?"已启用":"未启用"}),i.jsx("button",{type:"button",className:`oc-toggle${we?" is-on":""}`,role:"switch","aria-checked":we,"aria-label":`${we?"关闭":"开启"} ${ne.name} 自动注入上下文`,disabled:Ce||!!G||!ne.resourceId,title:Ce?"保存中…":"控制模型是否可自动选择该技能",onClick:()=>{ge(ne)},children:i.jsx("span",{className:"oc-toggle-knob","aria-hidden":"true"})})]})]},ne.resourceId)})})]}):i.jsx(Ga,{children:"当前会话没有加载技能。"});if(n==="plugins")return be.length?i.jsx("ul",{className:"oc-settings-list",children:be.map((ne,we)=>i.jsxs("li",{children:[i.jsxs("div",{children:[i.jsx("strong",{children:ne.name}),i.jsx("span",{children:ne.detail})]}),i.jsx("em",{children:ne.enabled?"已启用":"未启用"})]},`${ne.name}-${we}`))}):i.jsx(Ga,{children:"当前会话没有加载插件。"});const ae=_e.mcp?.servers??[];return ae.length?i.jsx("ul",{className:"oc-settings-list",children:ae.map(ne=>i.jsxs("li",{children:[i.jsxs("div",{children:[i.jsx("strong",{children:ne.name}),i.jsxs("span",{children:[ne.tools.length," 个工具 · ",ne.transport??ne.scope]})]}),i.jsx("em",{children:OD(ne.status)})]},ne.name))}):i.jsx(Ga,{children:"当前会话没有加载 MCP 服务。"})};return Xs.createPortal(i.jsx("div",{className:"oc-settings-backdrop",onMouseDown:ae=>{ae.target===ae.currentTarget&&A()},children:i.jsxs("section",{ref:Z,className:"oc-settings-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"oc-settings-title",tabIndex:-1,children:[i.jsxs("nav",{className:"oc-settings-nav","aria-label":"设置分类",children:[i.jsx("div",{className:"oc-settings-nav-title",id:"oc-settings-title",children:"设置"}),i.jsx("div",{className:"oc-settings-nav-list",children:AD.map(ae=>i.jsxs("button",{type:"button",className:n===ae.id?"is-active":"","aria-current":n===ae.id?"page":void 0,onClick:()=>{n==="version"&&ae.id!=="version"&&(R(),d(!1)),s(ae.id)},children:[LD(ae.id),i.jsx("span",{children:ae.label}),ae.id==="version"&&t.info?.updateAvailable?i.jsx("i",{className:"oc-update-dot",role:"img","aria-label":"有新版本可用"}):null]},ae.id))})]}),i.jsxs("div",{className:"oc-settings-content",children:[i.jsx("header",{className:"oc-settings-header",children:i.jsx("button",{type:"button",className:"oc-settings-close",onClick:A,"aria-label":"关闭设置",title:"关闭",children:i.jsx(Wn,{size:16,"aria-hidden":"true"})})}),i.jsx("div",{className:"oc-settings-options",children:ke()})]})]})}),document.body)}function PD(){return i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),i.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function $D(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})})}function ww(){return i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),i.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function BD(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:i.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}function mg({side:e="left"}){return i.jsx("svg",{className:`oc-panel-icon${e==="right"?" is-right":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:i.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.67272 0.522841C10.8339 0.522841 11.76 0.522714 12.4963 0.602493C13.2453 0.683657 13.8789 0.854248 14.4264 1.25197C14.7504 1.48739 15.0355 1.77247 15.2709 2.0965C15.6686 2.64394 15.8392 3.27758 15.9204 4.02655C16.0002 4.7629 16 5.68895 16 6.85014V9.14986C16 10.3111 16.0002 11.2371 15.9204 11.9735C15.8392 12.7224 15.6686 13.3561 15.2709 13.9035C15.0355 14.2275 14.7504 14.5126 14.4264 14.748C13.8789 15.1458 13.2453 15.3163 12.4963 15.3975C11.76 15.4773 10.8339 15.4772 9.67272 15.4772H6.3273C5.16611 15.4772 4.24006 15.4773 3.50371 15.3975C2.75474 15.3163 2.1211 15.1458 1.57366 14.748C1.24963 14.5126 0.964549 14.2275 0.729131 13.9035C0.331407 13.3561 0.160817 12.7224 0.0796529 11.9735C-0.000126137 11.2371 0 10.3111 0 9.14986V6.85014C0 5.68895-0.000126137 4.7629 0.0796529 4.02655C0.160817 3.27758 0.331407 2.64394 0.729131 2.0965C0.964549 1.77247 1.24963 1.48739 1.57366 1.25197C2.1211 0.854248 2.75474 0.683657 3.50371 0.602493C4.24006 0.522714 5.16611 0.522841 6.3273 0.522841H9.67272ZM5.54303 1.88715V14.1118C5.78636 14.1128 6.04709 14.1169 6.3273 14.1169H9.67272C10.8639 14.1169 11.7032 14.1164 12.3493 14.0465C12.9824 13.9779 13.3497 13.8494 13.6268 13.6482C13.8354 13.4966 14.0195 13.3125 14.1711 13.1039C14.3723 12.8268 14.5007 12.4595 14.5693 11.8264C14.6393 11.1803 14.6398 10.341 14.6398 9.14986V6.85014C14.6398 5.65896 14.6393 4.81967 14.5693 4.1736C14.5007 3.54048 14.3723 3.17318 14.1711 2.89609C14.0195 2.68747 13.8354 2.50337 13.6268 2.35179C13.3497 2.1506 12.9824 2.02212 12.3493 1.95353C11.7032 1.88358 10.8639 1.88307 9.67272 1.88307H6.3273C6.04709 1.88307 5.78636 1.8862 5.54303 1.88715ZM4.1828 1.91166C3.99125 1.9216 3.8148 1.93577 3.65076 1.95353C3.01764 2.02212 2.65034 2.1506 2.37325 2.35179C2.16463 2.50337 1.98052 2.68747 1.82895 2.89609C1.62776 3.17318 1.49928 3.54048 1.43069 4.1736C1.36074 4.81967 1.36023 5.65896 1.36023 6.85014V9.14986C1.36023 10.341 1.36074 11.1803 1.43069 11.8264C1.49928 12.4595 1.62776 12.8268 1.82895 13.1039C1.98052 13.3125 2.16463 13.4966 2.37325 13.6482C2.65034 13.8494 3.01764 13.9779 3.65076 14.0465C3.81478 14.0642 3.99127 14.0774 4.1828 14.0873V1.91166Z",fill:"currentColor"})})}function FD(){return i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4 4l8 8M12 4l-8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}function Xo(){return i.jsx("svg",{className:"oc-tool-chevron",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("polyline",{points:"2.5 4 6 7.5 9.5 4"})})}function zD(e,t,n,s){const r=e.findIndex(c=>c.workspaceId===n),a=e.findIndex(c=>c.workspaceId===t);if(r===-1||a===-1)return;const o=s==="before"?n:e[r+1]?.workspaceId??null;if(o===t)return;const l=o?e.findIndex(c=>c.workspaceId===o):e.length;return l===a||l===a+1?void 0:o}function HD(e){if(!e)return;const t=e;for(const n of t.getAnimations?.({subtree:!0})??[])n.startTime=0}function zn(e){const t=e.size??(e.state==="ongoing"?14:10);return e.state==="ongoing"?i.jsx("svg",{ref:HD,className:`oc-state-dot${e.className?` ${e.className}`:""}`,"data-state":"ongoing",width:t,height:t,viewBox:"0 0 24 24","aria-hidden":"true",children:i.jsxs("g",{className:"oc-state-dot-motion",children:[i.jsx("circle",{className:"oc-state-dot-track",cx:"12",cy:"12",r:"9.5"}),i.jsx("circle",{className:"oc-state-dot-arc",cx:"12",cy:"12",r:"9.5"})]})}):i.jsx("span",{className:`oc-state-dot${e.className?` ${e.className}`:""}`,"data-state":e.state,style:{width:t,height:t},"aria-hidden":"true"})}function qD({open:e}){return i.jsx("svg",{className:`oc-tree-chevron${e?" is-open":""}`,width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 2.4 7.8 6 4.2 9.6",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function UD({open:e}){return i.jsx("svg",{className:`oc-workspace-chevron${e?" is-open":""}`,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M4.25 2.82782V11.1722C4.25 11.6622 4.84243 11.9076 5.18891 11.5611L9.36109 7.38891C9.57588 7.17412 9.57588 6.82588 9.36109 6.61109L5.18891 2.43891C4.84243 2.09243 4.25 2.33782 4.25 2.82782Z",fill:"currentColor"})})}function WD(){return i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3 3.5h10v2H3v-2Zm0 3.5h10v2H3V7Zm0 3.5h7V13H3v-2Z",fill:"currentColor"})})}function VD(){return i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M8 3v10M3 8h10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})}function a6(){return i.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2 4h5l1 1.5h6V13H2V4Z",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round"})})}function Sw(){return i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:[i.jsx("path",{transform:"translate(9.52 2.52)",d:"M3.55246 0L3.55246 2.44252L6 2.44252L6 3.55748L3.55246 3.55748L3.55246 6L2.43834 6L2.43834 3.55748L0 3.55748L0 2.44252L2.43834 2.44252L2.43834 0L3.55246 0Z",fill:"currentColor"}),i.jsx("path",{transform:"translate(0.3496 2.35)",d:"M4.76367 0C5.36861 1.80598e-05 5.93113 0.310294 6.25488 0.821289L6.78027 1.64941C6.79685 1.67558 6.81791 1.69775 6.83887 1.71973C6.72186 2.15521 6.65702 2.61192 6.65137 3.08301C6.25601 2.96045 5.90909 2.70478 5.68164 2.3457L5.15723 1.5166C5.07183 1.38189 4.92318 1.3008 4.76367 1.30078L2.32422 1.30078C1.7589 1.30078 1.30078 1.7589 1.30078 2.32422L1.30078 10.1338C1.30078 10.6991 1.7589 11.1572 2.32422 11.1572L11.9766 11.1572C12.5419 11.1572 13 10.6991 13 10.1338L13 8.58398C13.4545 8.5135 13.8903 8.38748 14.3008 8.21289L14.3008 10.1338C14.3008 11.4171 13.2598 12.458 11.9766 12.458L2.32422 12.458C1.04093 12.458 0 11.4171 0 10.1338L0 2.32422C0 1.04093 1.04093 0 2.32422 0L4.76367 0Z",fill:"currentColor"})]})}function GD({open:e}){return i.jsx("svg",{className:`oc-tree-glyph${e?" is-folder-open":" is-folder"}`,width:"16",height:"16",viewBox:"0 0 14 14","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 4h3.2l1 1.1H12a.8.8 0 0 1 .8.8v5.3a.8.8 0 0 1-.8.8H2a.8.8 0 0 1-.8-.8V4.8a.8.8 0 0 1 .8-.8Z",fill:"currentColor",opacity:e?.9:.68})})}function KD(e){return[...e].sort((t,n)=>t.kind!==n.kind?t.kind==="directory"?-1:1:t.name.localeCompare(n.name,void 0,{sensitivity:"base"}))}function o6(e){const t=f.useMemo(()=>KD(e.entries),[e.entries]);return t.length?i.jsx("ul",{className:"oc-tree",role:e.depth===0?"tree":"group",children:t.map(n=>{const s=n.kind==="directory"&&e.expanded.has(n.path);return i.jsxs("li",{className:`oc-tree-node is-${n.kind}${s?" is-open":""}`,role:"treeitem","aria-expanded":n.kind==="directory"?s:void 0,children:[i.jsxs("button",{type:"button",className:`oc-tree-row oc-tree-${n.kind==="directory"?"dir":"file"}`,style:{paddingLeft:`${8+e.depth*12}px`},onClick:()=>n.kind==="directory"?e.onToggle(n.path):e.onPreview(n.path),children:[n.kind==="directory"?i.jsxs(i.Fragment,{children:[i.jsx(qD,{open:s}),i.jsx(GD,{open:s})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"oc-tree-chevron-spacer","aria-hidden":"true"}),i.jsx(ih,{name:n.name})]}),i.jsx("span",{className:"oc-tree-label",children:n.name}),i.jsx("span",{className:"oc-tree-at",role:"button",tabIndex:0,"aria-label":`提及 ${n.name}`,title:"在输入框提及此文件",onClick:r=>{r.stopPropagation(),e.onInsert(n.kind==="directory"?`${n.path}/`:n.path)},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),e.onInsert(n.kind==="directory"?`${n.path}/`:n.path))},children:"@"})]}),n.kind==="directory"&&s?i.jsx(o6,{...e,entries:e.tree[n.path]??[],depth:e.depth+1}):null]},n.path)})}):i.jsx("p",{className:"oc-tree-empty",children:"此目录为空或没有可安全浏览的文件。"})}function YD(e){return i.jsxs("section",{className:"oc-details-files","aria-label":"Workspace 文件",children:[i.jsxs("header",{children:[i.jsx("span",{className:"oc-details-workspace-name",title:e.workspaceName,children:e.workspaceName}),i.jsx("button",{type:"button",className:"btn btn-ghost",onClick:e.onRefresh,"aria-label":"刷新文件",title:"刷新文件",children:i.jsx(mi,{size:15,"aria-hidden":"true"})})]}),e.treeError?i.jsx("p",{className:"oc-sidebar-error",role:"alert",children:e.treeError}):null,i.jsx("div",{className:"oc-details-tree-scroll",children:i.jsx(o6,{entries:e.tree[""]??[],tree:e.tree,expanded:e.expanded,depth:0,onToggle:e.onToggle,onInsert:e.onInsert,onPreview:e.onPreview})})]})}function ZD(e,t){const n=e.deferredTurns?.length?e.deferredTurns:e.deferredTurn?[e.deferredTurn]:[];if(t)return null;if(n.some(r=>r.state==="failed"))return{label:"发送失败",title:"排队消息发送失败",state:"failed"};const s=n.filter(r=>r.state==="queued").length;return s>0?{label:String(s),title:`${s} 条排队消息`,state:"queued"}:null}function _w(e,t=Date.now()){const n=new Date(e).getTime();if(!Number.isFinite(n))return"";const s=Math.max(0,t-n),r=Math.floor(s/6e4);if(r<1)return"刚刚";if(r<60)return`${r}分钟`;const a=Math.floor(r/60);if(a<24)return`${a}小时`;const o=Math.floor(a/24);if(o<30)return`${o}天`;const l=Math.floor(o/30);return l<12?`${l}个月`:`${Math.floor(l/12)}年`}function l6(e){const t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):"时间未知"}function c6(e=!1){const[t,n]=f.useState(null),s=f.useRef(null),r=f.useRef(null),a=f.useCallback(()=>{s.current!==null&&window.clearTimeout(s.current),r.current!==null&&window.clearTimeout(r.current),s.current=null,r.current=null},[]),o=f.useCallback(()=>{a(),n(null)},[a]);f.useEffect(()=>{e&&o()},[o,e]),f.useEffect(()=>o,[o]);const l=f.useCallback(u=>{if(e||(r.current!==null&&(window.clearTimeout(r.current),r.current=null),t))return;s.current!==null&&window.clearTimeout(s.current);const h=u.currentTarget;s.current=window.setTimeout(()=>{s.current=null,n(h)},800)},[e,t]),c=f.useCallback(()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),t&&(r.current=window.setTimeout(o,180))},[o,t]),d=f.useCallback(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null)},[]);return{anchor:t,close:o,onPointerEnter:l,onPointerLeave:c,onCardPointerEnter:d}}function d6(e){const t=f.useRef(null),[n,s]=f.useState(null);return f.useLayoutEffect(()=>{const r=e.anchor;if(!r){s(null);return}const a=()=>{const l=t.current;if(!l||!r.isConnected){s(null);return}const c=r.getBoundingClientRect(),{width:d,height:u}=l.getBoundingClientRect(),h=8,p=c.right+h;if(p+d<=window.innerWidth-h){s({left:p,top:Math.max(h,Math.min(c.top,window.innerHeight-u-h))});return}const m=Math.max(h,Math.min(c.left,window.innerWidth-d-h));c.bottom+h+u<=window.innerHeight-h?s({left:m,top:c.bottom+h}):c.top-h-u>=h?s({left:m,top:c.top-h-u}):s(null)};a();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(a);return o?.observe(r),t.current&&o?.observe(t.current),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{o?.disconnect(),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[e.anchor]),!e.anchor||typeof document>"u"?null:Xs.createPortal(i.jsx("div",{ref:t,className:"oc-sidebar-hover-card",style:{left:n?.left??0,top:n?.top??0,visibility:n?"visible":"hidden"},onPointerEnter:e.onPointerEnter,onPointerLeave:e.onPointerLeave,children:e.children}),document.body)}function XD(e){const{item:t,active:n,streamingNow:s,turnPhaseNow:r,state:a,deleteConfirming:o,deleting:l}=e,c=r??t.turnPhase,d=t.optimisticState,u=(t.subagentSummary?.active??0)>0,h=s===!0||c==="running"||c==="stopping"||c===void 0&&!!t.activeTurnId,p=h||u,m=ZD(t,n),g=t.isBlank===!0,v=d==="creating"?"正在创建…":g?"新会话":t.title||t.displayTitle||"未命名对话",b=l6(t.updatedAt),x=new Date(t.updatedAt),y=Number.isFinite(x.getTime())?x.toISOString():void 0,C=f.useRef(null),S=f.useRef(null),I=f.useRef(null),[w,_]=f.useState(null),k=c6(!!w||o);return f.useEffect(()=>{const N=T=>{I.current?.contains(T.target)||S.current?.contains(T.target)||(o&&e.onCancelDelete(),_(null))},L=()=>{k.close(),_(null)},O=T=>{T.key==="Escape"&&(k.close(),o&&e.onCancelDelete(),_(null))};return document.addEventListener("mousedown",N),window.addEventListener("scroll",L,!0),window.addEventListener("keydown",O),()=>{document.removeEventListener("mousedown",N),window.removeEventListener("scroll",L,!0),window.removeEventListener("keydown",O)}},[o,k.close,e.onCancelDelete]),f.useEffect(()=>{o&&C.current?.focus()},[o]),i.jsxs("div",{className:`oc-session-item${n?" is-active":""}${o?" is-delete-confirming":""}${w?" is-menu-open":""}${d?` is-optimistic-${d}`:""}`,"data-session-id":t.sessionId,onPointerEnter:k.onPointerEnter,onPointerLeave:k.onPointerLeave,children:[i.jsxs("a",{href:e.href,className:"oc-session-main","aria-disabled":l||d==="creating"||void 0,tabIndex:l||d==="creating"?-1:void 0,onClick:N=>{if(l||d==="creating"){N.preventDefault();return}N.preventDefault(),e.onActivate()},children:[i.jsx("strong",{children:v}),i.jsx("span",{className:`oc-session-mode is-${t.sessionMode==="pi"?"pi":"workflow"}`,children:t.sessionMode==="pi"?"Pi":"工作流"}),g?null:i.jsx("time",{dateTime:y,title:b,children:_w(t.updatedAt,e.now)}),t.subagentSummary&&t.subagentSummary.total>0?i.jsx("span",{className:`oc-session-subagents${t.subagentSummary.active>0?" is-running":t.subagentSummary.failed>0?" is-error":""}`,children:t.subagentSummary.active>0?`${t.subagentSummary.active} 个子代理运行中`:`${t.subagentSummary.total} 个子代理`}):null]}),p?i.jsx("span",{className:"oc-session-running","aria-label":u&&!h?"子代理运行中":"对话进行中",title:u&&!h?"子代理运行中":"对话进行中",children:i.jsx(zn,{state:"ongoing"})}):null,m?i.jsx("span",{className:`oc-session-queue-state is-${m.state}`,"aria-label":m.title,title:m.title,children:m.label}):null,d!=="creating"&&!g?i.jsx("div",{className:"oc-session-actions",children:i.jsx("button",{type:"button",ref:S,className:"oc-session-menu","data-session-delete-id":t.sessionId,title:"更多","aria-label":`${v} 更多操作`,"aria-expanded":!!w,onClick:N=>{if(N.stopPropagation(),k.close(),w){_(null);return}const L=N.currentTarget.getBoundingClientRect();_({left:Math.max(8,Math.min(L.right-176,window.innerWidth-184)),top:Math.min(L.bottom+5,window.innerHeight-128)})},children:i.jsx(iv,{size:16,"aria-hidden":"true"})})}):null,i.jsxs(d6,{anchor:k.anchor,onPointerEnter:k.onCardPointerEnter,onPointerLeave:k.onPointerLeave,children:[i.jsx("strong",{children:v}),g?null:i.jsxs("span",{children:[_w(t.updatedAt,e.now)," · ",b]}),i.jsxs("span",{className:"oc-sidebar-hover-status",children:[i.jsx("i",{className:p?"is-running":""}),m?.title??(p?"对话进行中":a==="archived"?"已归档":"空闲")]})]}),w&&typeof document<"u"?Xs.createPortal(i.jsx("div",{ref:I,className:"oc-session-popover-menu",role:"menu",style:{left:w.left,top:w.top},children:o?i.jsxs("div",{className:"oc-session-menu-confirm",children:[i.jsx("span",{children:"确定删除这个会话?"}),i.jsxs("div",{children:[i.jsx("button",{type:"button",ref:C,className:"is-danger",disabled:l,"aria-label":`确认删除会话:${v}`,"aria-busy":l||void 0,onClick:()=>e.onConfirmDelete(),children:l?"删除中…":"删除"}),i.jsx("button",{type:"button",disabled:l,"aria-label":"取消删除会话",onClick:()=>{e.onCancelDelete(),_(null)},children:"取消"})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(null);const N=window.prompt("会话名称",t.title||t.displayTitle||"");N!==null&&e.onRename(N)},children:[i.jsx(rh,{size:16,"aria-hidden":"true"}),"编辑标题"]}),i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{_(null),e.onSetState(a==="active"?"archived":"active")},children:[i.jsx(vN,{size:16,"aria-hidden":"true"}),a==="active"?"归档会话":"恢复会话"]}),i.jsxs("button",{type:"button",role:"menuitem",className:"is-danger",onClick:()=>e.onRequestDelete(),children:[i.jsx(zr,{size:16,"aria-hidden":"true"}),"删除会话"]})]})}),document.body):null]})}function u6(e){return i.jsx(i.Fragment,{children:(e.ordered?["all"]:["active","archived"]).map(t=>{const n=t==="all"?e.sessions:e.sessions.filter(s=>s.state===t);return n.length?i.jsx("div",{className:"oc-session-group",children:n.map(s=>i.jsx(XD,{item:s,href:sh(),active:e.activeSessionId===s.sessionId,streamingNow:e.activeSessionId===s.sessionId&&e.activeSessionStreaming===!0,turnPhaseNow:e.activeSessionId===s.sessionId?e.activeSessionTurnPhase:void 0,state:s.state==="archived"?"archived":"active",deleteConfirming:e.pendingDeleteSessionId===s.sessionId,deleting:e.deletingSessionId===s.sessionId,onActivate:()=>e.onActivate(s.sessionId,e.ownerWorkspaceId),onRename:r=>e.onRename(s.sessionId,r),onSetState:r=>e.onSetState(s.sessionId,r),onRequestDelete:()=>e.onRequestDelete(s),onConfirmDelete:()=>e.onConfirmDelete(s.sessionId),onCancelDelete:e.onCancelDelete,now:e.now},s.sessionId))},t):null})})}function JD(e){const{workspace:t,active:n}=e,s=e.deletingSessionId,r=e.cancelDelete,{expanded:a}=e,[o,l]=f.useState(!1),c=f.useRef(null),d=c6(o||e.dragActive);f.useEffect(()=>{if(!o)return;const b=y=>{c.current?.contains(y.target)||l(!1)},x=y=>{y.key==="Escape"&&l(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",x)}},[o]);const u=f.useMemo(()=>GO(e.sessions.filter(b=>b.workspaceId===t.workspaceId&&(!b.isBlank||b.sessionId===e.activeSessionId)),K5(),YO()),[e.activeSessionId,e.sessions,t.workspaceId]),h=f.useMemo(()=>{const b=u.slice(0,gu);if(e.activeSessionId&&!b.some(x=>x.sessionId===e.activeSessionId)){const x=u.find(y=>y.sessionId===e.activeSessionId);x&&b.push(x)}return b},[u,e.activeSessionId]),p=f.useMemo(()=>e.showAllSessions||e.sessionsExpanded||u.length<=gu?u:h,[u,h,e.sessionsExpanded,e.showAllSessions]),m=Math.max(0,u.length-h.length),g=e.sessionListPhase==="ready"?"此工作区暂无会话。":e.sessionListState==="error"?"会话列表暂时不可用。":"正在加载会话…",v=!!(e.activeSessionId&&u.some(b=>b.sessionId===e.activeSessionId));return i.jsxs("div",{className:`oc-workspace-item${n?" is-active":""}${e.dragging?" is-dragging":""}${e.dropMarker?` is-drop-${e.dropMarker}`:""}`,"data-workspace-id":t.workspaceId,"aria-current":n?"true":void 0,onDragOver:e.dragActive?b=>{b.preventDefault(),b.dataTransfer.dropEffect="move";const x=b.currentTarget.getBoundingClientRect();e.onDragHover(b.clientY<x.top+x.height/2?"before":"after")}:void 0,onDrop:e.dragActive?b=>{b.preventDefault();const x=b.currentTarget.getBoundingClientRect();e.onDragDrop(b.clientY<x.top+x.height/2?"before":"after")}:void 0,children:[i.jsxs("div",{className:"oc-workspace-row",onPointerEnter:d.onPointerEnter,onPointerLeave:d.onPointerLeave,children:[i.jsxs("button",{type:"button",className:"oc-workspace-main",draggable:!o&&!e.removing,onDragStart:b=>{b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",t.workspaceId),e.onDragStart()},onDragEnd:e.onDragEnd,onClick:e.onToggleExpanded,"aria-expanded":a,children:[i.jsx("span",{className:"oc-workspace-caret","aria-hidden":"true",children:i.jsx(UD,{open:a})}),i.jsx("span",{className:`oc-workspace-folder${a&&v?" is-current":""}`,"aria-hidden":"true",children:i.jsx(a6,{})}),i.jsx("strong",{children:t.name})]}),i.jsxs("div",{className:"oc-workspace-actions",ref:c,children:[i.jsx("button",{type:"button",title:"更多","aria-label":`${t.name} 更多操作`,"aria-expanded":o,onClick:b=>{b.stopPropagation(),l(x=>!x)},children:i.jsx(iv,{size:16,"aria-hidden":"true"})}),i.jsx("button",{type:"button",title:"新建对话","aria-label":`在 ${t.name} 新建对话`,disabled:e.creatingSession,onClick:b=>{b.stopPropagation(),e.onCreateSession()},children:e.creatingSession?i.jsx("span",{className:"oc-spinner","aria-hidden":"true"}):i.jsx(Io,{size:16,"aria-hidden":"true"})}),o?i.jsxs("div",{className:"oc-workspace-menu",role:"menu",children:[i.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{l(!1),e.onCreateSession()},children:[i.jsx(Io,{size:15,"aria-hidden":"true"}),"新建会话"]}),i.jsxs("button",{type:"button",role:"menuitem",className:"is-danger",disabled:e.removing,onClick:()=>{l(!1),e.onRemove()},children:[i.jsx(zr,{size:15,"aria-hidden":"true"}),e.removing?"移除中…":"移除工作区"]})]}):null]}),i.jsxs(d6,{anchor:d.anchor,onPointerEnter:d.onCardPointerEnter,onPointerLeave:d.onPointerLeave,children:[i.jsx("strong",{children:t.name}),i.jsx("span",{className:"oc-sidebar-hover-path",children:t.displayPath}),t.createdAt?i.jsxs("span",{children:["添加于 ",l6(t.createdAt)]}):null]})]}),a?i.jsxs("div",{className:"oc-workspace-sessions",children:[i.jsx(u6,{sessions:p,ordered:!0,ownerWorkspaceId:t.workspaceId,activeSessionId:e.activeSessionId,activeSessionStreaming:e.activeSessionStreaming,activeSessionTurnPhase:e.activeSessionTurnPhase,pendingDeleteSessionId:e.pendingDeleteSessionId,deletingSessionId:e.deletingSessionId,onActivate:(b,x)=>{s||(r(!1),e.onActivate(b,x))},onRename:e.onRenameSession,onSetState:e.onSetSessionState,onRequestDelete:e.onRequestDeleteSession,onConfirmDelete:e.onConfirmDeleteSession,onCancelDelete:e.onCancelDeleteSession,now:e.now}),m>0&&!e.showAllSessions?i.jsx("button",{type:"button",className:"oc-session-more",onClick:e.onToggleSessionsExpanded,"aria-expanded":e.sessionsExpanded,children:e.sessionsExpanded?"收起":`展开其余 ${m} 个会话`}):null,p.length===0?i.jsx("p",{className:"oc-tree-empty",children:g}):null]}):null]})}function QD(e){const[t,n]=f.useState(!1),[s,r]=f.useState(""),[a,o]=f.useState(!1),[l,c]=f.useState(!1),[d,u]=f.useState(()=>Date.now()),[h,p]=f.useState(!1),m=f.useRef(null),g=f.useMemo(()=>new Set(e.workspaces.map(Z=>Z.workspaceId)),[e.workspaces]),v=f.useMemo(()=>e.sessions.filter(Z=>e.workspacesLoading||!Z.workspaceId||g.has(Z.workspaceId)),[e.sessions,g,e.workspacesLoading]),b=f.useMemo(()=>{const Z=s.trim().toLocaleLowerCase();return v.filter(ue=>!ue.isBlank||ue.sessionId===e.activeSessionId).filter(ue=>!Z||(ue.title||ue.displayTitle||"未命名对话").toLocaleLowerCase().includes(Z))},[v,e.activeSessionId,s]),x=f.useMemo(()=>b.filter(Z=>!Z.workspaceId),[b]),y=f.useMemo(()=>{const Z=x.slice(0,gu);if(e.activeSessionId&&!Z.some(ue=>ue.sessionId===e.activeSessionId)){const ue=x.find(_e=>_e.sessionId===e.activeSessionId);ue&&Z.push(ue)}return Z},[x,e.activeSessionId]),C=f.useMemo(()=>s.trim()||h||x.length<=gu?x:y,[x,y,s,h]),S=Math.max(0,x.length-y.length),[I,w]=f.useState(()=>new Set(e.activeWorkspaceId?[e.activeWorkspaceId]:[])),[_,k]=f.useState(()=>new Set),[N,L]=f.useState(null),O=f.useRef(!1);f.useEffect(()=>{const Z=e.activeWorkspaceId;Z&&w(ue=>{if(ue.has(Z))return ue;const _e=new Set(ue);return _e.add(Z),_e})},[e.activeWorkspaceId]);const T=f.useCallback(Z=>{const ue=I.has(Z);w(_e=>{const Oe=new Set(_e);return Oe.has(Z)?Oe.delete(Z):Oe.add(Z),Oe}),ue&&k(_e=>{if(!_e.has(Z))return _e;const Oe=new Set(_e);return Oe.delete(Z),Oe})},[I]),R=f.useCallback(Z=>{k(ue=>{const _e=new Set(ue);return _e.has(Z)?_e.delete(Z):_e.add(Z),_e})},[]),A=f.useCallback((Z,ue)=>{if(!N||O.current)return;O.current=!0;const _e=N.sourceId;L(null);const Oe=zD(e.workspaces,_e,Z,ue);Oe!==void 0&&e.onReorderWorkspace(_e,Oe)},[e.onReorderWorkspace,e.workspaces,N]),E=f.useCallback(()=>{const Z=N?.over;if(!Z){L(null);return}A(Z.workspaceId,Z.half)},[A,N]);f.useEffect(()=>{if(!N)return;const Z=ue=>ue.preventDefault();return document.addEventListener("dragover",Z),()=>document.removeEventListener("dragover",Z)},[N]),f.useEffect(()=>{const Z=window.setInterval(()=>u(Date.now()),6e4);return()=>window.clearInterval(Z)},[]);const[$,H]=f.useState(null),[B,G]=f.useState(null),z=f.useRef(null),Q=f.useRef(!1),W=e.layoutMode==="comfortable"&&e.open,D=e.layoutMode==="compact",ee=e.drawerOpen&&(e.layoutMode==="compact"||e.layoutMode==="narrow"),F=f.useCallback((Z=!0)=>{if(B)return;const ue=$;H(null),!(!Z||!ue)&&window.requestAnimationFrame(()=>{const _e=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(ue):ue.replace(/["\\]/g,"\\$&");document.querySelector(`[data-session-delete-id="${_e}"]`)?.focus()})},[B,$]),M=f.useCallback(()=>{B||(H(null),e.onCloseDrawer())},[B,e.onCloseDrawer]),U=f.useCallback(()=>{if($){F();return}M()},[F,M,$]);Ko({open:ee,containerRef:z,triggerRef:e.drawerTriggerRef,onEscape:U}),f.useEffect(()=>{Q.current&&!ee&&!B&&H(null),Q.current=ee},[B,ee]),f.useEffect(()=>{$&&!b.some(Z=>Z.sessionId===$)&&H(null),B&&!b.some(Z=>Z.sessionId===B)&&G(null)},[B,$,b]),f.useEffect(()=>{if(ee||!$)return;const Z=ue=>{ue.key==="Escape"&&(ue.preventDefault(),F())};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[F,$,ee]);const q=f.useCallback(async Z=>{if(!(B||$!==Z)){G(Z);try{await e.onDelete(Z)}finally{G(null),H(null)}}},[B,$,e.onDelete]),te=f.useCallback(()=>{B||(F(!1),e.onCreate())},[F,B,e.onCreate]),se=f.useCallback((Z,ue)=>{B||(F(!1),w(_e=>{if(_e.has(Z))return _e;const Oe=new Set(_e);return Oe.add(Z),Oe}),e.onCreateInWorkspace?e.onCreateInWorkspace(Z,ue):e.onCreate(ue))},[F,B,e.onCreateInWorkspace,e.onCreate]),he=f.useCallback(()=>{B||(F(!1),e.onToggleOpen())},[F,B,e.onToggleOpen]),[X,re]=f.useState(!1),de=f.useCallback(async()=>{if(!(X||e.addingWorkspace)){re(!0);try{const Z=await e.onPickWorkspaceDirectory();Z&&await e.onAddWorkspace(Z)}finally{re(!1)}}},[X,e.addingWorkspace,e.onAddWorkspace,e.onPickWorkspaceDirectory]),xe=f.useCallback(()=>{if(n(!0),e.layoutMode==="comfortable"&&!e.open){he();return}(e.layoutMode==="compact"||e.layoutMode==="narrow")&&!e.drawerOpen&&e.onOpenDrawer()},[he,e.drawerOpen,e.layoutMode,e.onOpenDrawer,e.open]),K=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"oc-sidebar-primary-actions",children:[i.jsxs("button",{type:"button",className:"oc-sidebar-new-session","aria-label":"新建会话",onClick:te,disabled:e.creatingSession,"aria-busy":e.creatingSession||void 0,children:[i.jsx(Io,{size:14,"aria-hidden":"true"}),e.creatingSession?"创建中…":"新会话"]}),e.layoutMode==="comfortable"?i.jsx("button",{type:"button",className:"oc-sidebar-toggle",onClick:he,"aria-expanded":!0,"aria-label":"收起侧栏",title:"收起侧栏",children:i.jsx(mg,{})}):i.jsx("button",{type:"button",className:"oc-sidebar-toggle",onClick:M,"aria-label":"关闭侧栏抽屉",title:"关闭",children:i.jsx(Wn,{size:16,"aria-hidden":"true"})})]}),i.jsx("nav",{className:"oc-sidebar-panels","aria-label":"工作区页面",children:i.jsxs("button",{type:"button",className:"oc-sidebar-panel","aria-label":"自动化任务","aria-current":e.automationActive?"page":void 0,onClick:e.onOpenAutomation,children:[i.jsx(jo,{size:16,"aria-hidden":"true"}),i.jsx("span",{children:"自动化任务"})]})}),i.jsxs("section",{className:"oc-sidebar-section oc-workspaces","aria-busy":e.workspacesLoading||e.sessionListState==="loading"||void 0,"aria-label":"Workspace 与会话",children:[i.jsxs("header",{children:[i.jsx("strong",{children:"工作区"}),i.jsxs("div",{className:"oc-sidebar-header-actions",children:[i.jsx("button",{type:"button",className:"oc-sidebar-icon-action","aria-label":"搜索会话",title:"搜索会话","aria-expanded":t,"aria-controls":"oc-session-search",onClick:()=>n(Z=>!Z),children:i.jsx(mo,{size:16,"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"oc-sidebar-icon-action","aria-label":"添加工作区",title:X?"选择目录中…":"添加工作区","aria-busy":X||void 0,disabled:X||e.addingWorkspace,onClick:()=>{de()},children:i.jsx(Sw,{})})]})]}),t?i.jsxs("div",{className:"oc-session-search-wrap",children:[i.jsx(mo,{size:15,"aria-hidden":"true"}),i.jsx("input",{id:"oc-session-search",type:"search",value:s,onChange:Z=>r(Z.target.value),placeholder:"搜索会话…","aria-label":"搜索会话",autoFocus:!0})]}):null,e.workspacesError?i.jsxs("p",{className:"oc-sidebar-error",role:"alert",children:[e.workspacesError," ",i.jsx("button",{type:"button",className:"btn btn-ghost",onClick:e.onDismissWorkspaceError,"aria-label":"关闭错误提示",children:i.jsx(Wn,{size:12,"aria-hidden":"true"})})]}):null,e.sessionListState==="error"&&e.sessionListError?i.jsxs("p",{className:"oc-sidebar-error",role:"alert",children:[e.sessionListError," ",i.jsx("button",{type:"button",className:"btn btn-ghost",onClick:e.onRefreshSessions,"aria-label":"重试加载会话",title:"重试",children:i.jsx(mi,{size:12,"aria-hidden":"true"})})]}):null,i.jsx("div",{className:"oc-workspace-list",children:e.workspacesLoading&&e.workspaces.length===0?i.jsx("p",{className:"oc-workspace-loading",children:"正在加载 Workspace…"}):e.workspaces.length===0&&C.length===0?i.jsx("p",{className:"oc-workspace-empty",children:"还没有工作区。点击右上角的 + 选择一个文件夹开始。"}):i.jsxs(i.Fragment,{children:[e.workspaces.map(Z=>i.jsx(JD,{workspace:Z,active:e.activeWorkspaceId===Z.workspaceId,expanded:I.has(Z.workspaceId)||!!s.trim(),sessionsExpanded:_.has(Z.workspaceId),removing:e.removingWorkspaceId===Z.workspaceId,dragging:N?.sourceId===Z.workspaceId,dragActive:N!==null,dropMarker:N?.over?.workspaceId===Z.workspaceId?N.over.half:null,onDragStart:()=>{O.current=!1,L({sourceId:Z.workspaceId,over:null})},onDragEnd:E,onDragHover:ue=>L(_e=>_e&&{sourceId:_e.sourceId,over:{workspaceId:Z.workspaceId,half:ue}}),onDragDrop:ue=>A(Z.workspaceId,ue),sessions:b,sessionListPhase:e.sessionListPhase,sessionListState:e.sessionListState,activeSessionId:e.activeSessionId,activeSessionStreaming:e.activeSessionStreaming,activeSessionTurnPhase:e.activeSessionTurnPhase,showAllSessions:!!s.trim(),creatingSession:e.creatingSession,pendingDeleteSessionId:$,deletingSessionId:B,cancelDelete:F,onToggleExpanded:()=>T(Z.workspaceId),onToggleSessionsExpanded:()=>R(Z.workspaceId),onRemove:()=>e.onRemoveWorkspace(Z.workspaceId),onCreateSession:ue=>se(Z.workspaceId,ue),onActivate:(ue,_e)=>{B||(F(!1),e.onActivate(ue,_e))},onRenameSession:e.onRename,onSetSessionState:e.onSetState,onRequestDeleteSession:ue=>{B||H(ue.sessionId)},onConfirmDeleteSession:ue=>{q(ue)},onCancelDeleteSession:()=>F(),now:d},Z.workspaceId)),C.length>0?i.jsxs("div",{className:"oc-workspace-item oc-workspace-ungrouped",children:[i.jsx("div",{className:"oc-workspace-row",children:i.jsxs("div",{className:"oc-workspace-main","aria-label":"未归类会话",children:[i.jsx("span",{className:"oc-workspace-caret","aria-hidden":"true"}),i.jsx("span",{className:`oc-workspace-folder${e.activeSessionId&&x.some(Z=>Z.sessionId===e.activeSessionId)?" is-current":""}`,"aria-hidden":"true",children:i.jsx(a6,{})}),i.jsx("strong",{children:"未归类"})]})}),i.jsxs("div",{className:"oc-workspace-sessions",children:[i.jsx(u6,{sessions:C,activeSessionId:e.activeSessionId,activeSessionStreaming:e.activeSessionStreaming,activeSessionTurnPhase:e.activeSessionTurnPhase,pendingDeleteSessionId:$,deletingSessionId:B,onActivate:(Z,ue)=>{B||(F(!1),e.onActivate(Z,ue))},onRename:e.onRename,onSetState:e.onSetState,onRequestDelete:Z=>{B||H(Z.sessionId)},onConfirmDelete:Z=>{q(Z)},onCancelDelete:()=>F(),now:d}),S>0&&!s.trim()?i.jsx("button",{type:"button",className:"oc-session-more",onClick:()=>p(Z=>!Z),"aria-expanded":h,children:h?"收起":`展开其余 ${S} 个会话`}):null]})]}):null]})})]}),i.jsx("div",{className:"oc-sidebar-footer",children:i.jsxs("button",{type:"button",ref:W?m:void 0,className:"oc-sidebar-settings",onClick:()=>c(!0),"aria-label":"打开设置",title:"设置",children:[i.jsx(ic,{size:16,"aria-hidden":"true"}),a?i.jsx("i",{className:"oc-update-dot",role:"img","aria-label":"有新版本可用"}):null,"设置"]})})]}),pe=i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":e.creatingSession?"创建会话中":"新建会话",title:e.creatingSession?"创建中…":"新建会话",onClick:te,disabled:e.creatingSession,"aria-busy":e.creatingSession||void 0,children:i.jsx(VD,{})}),i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":"自动化任务","aria-current":e.automationActive?"page":void 0,title:"自动化任务",onClick:e.onOpenAutomation,children:i.jsx(jo,{size:18,"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":"搜索会话",title:"搜索会话",onClick:xe,children:i.jsx(mo,{size:18,"aria-hidden":"true"})}),i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":"添加工作区",title:X?"选择目录中…":"添加工作区","aria-busy":X||void 0,disabled:X||e.addingWorkspace,onClick:()=>{de()},children:i.jsx(Sw,{})}),i.jsx("span",{className:"oc-sidebar-rail-spacer","aria-hidden":"true"}),i.jsxs("button",{type:"button",className:"oc-sidebar-rail-btn",ref:W?void 0:m,"aria-label":"打开设置",title:"设置",onClick:()=>c(!0),children:[i.jsx(ic,{size:18,"aria-hidden":"true"}),a?i.jsx("i",{className:"oc-update-dot",role:"img","aria-label":"有新版本可用"}):null]})]});return i.jsxs(i.Fragment,{children:[D?i.jsxs("nav",{className:"oc-sidebar-rail","aria-label":"紧凑侧栏",children:[i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn","aria-label":"打开 Workspace 与会话",title:"Workspace 与会话","aria-expanded":ee,onClick:()=>ee?M():e.onOpenDrawer(),children:i.jsx(WD,{})}),pe]}):null,e.layoutMode==="comfortable"?i.jsx("aside",{className:`oc-sidebar${W?"":" is-collapsed"}`,"aria-label":"Workspace 与会话",children:W?K:i.jsxs("nav",{className:"oc-sidebar-rail","aria-label":"折叠侧栏快捷入口",children:[i.jsx("button",{type:"button",className:"oc-sidebar-rail-btn",onClick:he,"aria-expanded":!1,"aria-label":"展开侧栏",title:"展开侧栏",children:i.jsx(mg,{})}),pe]})}):null,ee?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"oc-overlay-backdrop","aria-label":"关闭侧栏遮罩",onClick:M}),i.jsx("aside",{ref:z,className:"oc-sidebar oc-sidebar-drawer","aria-label":"Workspace 与会话抽屉",role:"dialog","aria-modal":"true",tabIndex:-1,children:K})]}):null,i.jsx(DD,{onUpdateAvailableChange:o,open:l,origin:e.origin,readiness:e.readiness,runAction:e.runAction,operatorBusy:e.operatorBusy,activeWorkspaceId:e.activeWorkspaceId,onClose:()=>c(!1),triggerRef:m})]})}const ai={count:8,quote:4e3,comment:2e3,totalText:16e3,jsonBytes:65536};function mn(e,t=1024){return typeof e=="string"&&e.length>0&&e.length<=t}function fl(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function eP(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e;if(!mn(t.workspaceId))return!1;const n={browser:["kind","workspaceId","tabId","documentId","url","tag","selector","rect","truncated"],message:["kind","workspaceId","sessionId","messageId","role","version","anchor"],file:["kind","workspaceId","path","version","versionScope","view","anchor","startLine","endLine","sheet","cellRange"],diff:["kind","workspaceId","path","side","comparison","version","startLine","endLine"],terminal:["kind","workspaceId","terminalSessionId","ownerSessionId","shell","anchor"],api:["kind","workspaceId","method","url","status","elapsedMs","anchor"]},s=typeof t.kind=="string"?n[t.kind]:void 0;if(!s||Object.keys(t).some(r=>!s.includes(r)))return!1;switch(t.kind){case"browser":{const r=t.rect;return fl(t.tabId)&&mn(t.documentId)&&mn(t.url,2048)&&mn(t.tag,64)&&mn(t.selector)&&!!r&&typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).every(a=>["x","y","width","height"].includes(a))&&[r.x,r.y,r.width,r.height].every(a=>typeof a=="number"&&Number.isFinite(a))&&typeof r.width=="number"&&r.width>0&&typeof r.height=="number"&&r.height>0&&(t.truncated===void 0||typeof t.truncated=="boolean")}case"message":return mn(t.sessionId)&&mn(t.messageId)&&(t.role==="user"||t.role==="assistant")&&mn(t.version)&&mn(t.anchor);case"file":return!mn(t.path)||!mn(t.version)||t.versionScope!=="file"&&t.versionScope!=="prefix"||!mn(t.anchor)?!1:t.view==="sheet"?t.startLine===void 0&&t.endLine===void 0&&(t.sheet===void 0||mn(t.sheet,256))&&typeof t.cellRange=="string"&&/^[A-Z]{1,3}[1-9]\d{0,6}(:[A-Z]{1,3}[1-9]\d{0,6})?$/.test(t.cellRange):(t.view==="source"||t.view==="markdown"||t.view==="html")&&t.sheet===void 0&&t.cellRange===void 0&&(t.startLine===void 0&&t.endLine===void 0||t.view==="source"&&fl(t.startLine)&&fl(t.endLine)&&t.endLine>=t.startLine);case"diff":return mn(t.path)&&(t.side==="old"||t.side==="new")&&mn(t.comparison)&&mn(t.version)&&fl(t.startLine)&&fl(t.endLine)&&t.endLine>=t.startLine;case"terminal":return mn(t.terminalSessionId)&&mn(t.ownerSessionId)&&mn(t.shell)&&mn(t.anchor);case"api":return typeof t.method=="string"&&/^[A-Za-z]{1,16}$/.test(t.method)&&mn(t.url,2048)&&typeof t.status=="number"&&Number.isFinite(t.status)&&typeof t.elapsedMs=="number"&&Number.isFinite(t.elapsedMs)&&t.elapsedMs>=0&&mn(t.anchor);default:return!1}}function or(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>ai.count)throw new Error("最多可添加 8 条引用");const t=JSON.stringify(e);if(new TextEncoder().encode(t).byteLength>ai.jsonBytes)throw new Error("引用数据超过 64 KiB");let n=0;const s=new Set;for(const r of e){if(!r||typeof r!="object"||Object.keys(r).some(a=>!["id","capturedAt","quote","comment","source","attachmentId","screenshotId"].includes(a))||!mn(r.id,128)||s.has(r.id)||!mn(r.capturedAt,64)||!Number.isFinite(Date.parse(r.capturedAt))||typeof r.quote!="string"||!r.quote.trim()||r.quote.length>ai.quote||typeof r.comment!="string"||r.comment.length>ai.comment||!eP(r.source)||r.screenshotId!==void 0&&(r.source.kind!=="browser"||typeof r.screenshotId!="string"||!/^[0-9a-f-]{36}$/i.test(r.screenshotId))||r.attachmentId!==void 0&&!mn(r.attachmentId,128))throw new Error("引用格式或长度无效,请重新选择");s.add(r.id),n+=r.quote.length+r.comment.length}if(e.filter(r=>r.screenshotId).length>4)throw new Error("最多添加 4 张引用截图");if(n>ai.totalText)throw new Error("引用原文与评论合计超过 16,000 字符");return structuredClone(e)}function tP(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>8)throw new Error("最多保存 8 份失败提交,请先恢复");return e.map(t=>{if(!t||typeof t!="object"||Object.keys(t).some(n=>n!=="text"&&n!=="references")||typeof t.text!="string"||new TextEncoder().encode(t.text).byteLength>65536)throw new Error("失败草稿格式或长度无效");return{text:t.text,references:or(t.references)}})}function Fv(e){const t=`
|
|
48
48
|
INNER TEXT
|
|
49
49
|
`,n=e.lastIndexOf(t);return(n>=0?e.slice(n+t.length):e).trim().replace(/(已截断)$/,"").trim()||e.trim()}function bh(e){switch(e.kind){case"browser":return e.tag;case"terminal":return e.shell;case"file":return e.view==="sheet"?"表格":e.view==="html"?"HTML":"文件";case"diff":return"差异";case"message":return"消息";case"api":return"API"}}function zv(e){switch(e.kind){case"browser":try{return new URL(e.url).hostname}catch{return e.url}case"file":return e.view==="sheet"&&e.cellRange?`${e.path} · ${e.sheet?`${e.sheet}!`:""}${e.cellRange}`:e.path;case"diff":return e.path;case"message":return"对话中的一段文字";case"terminal":return"终端选文";case"api":return`${e.method} ${nP(e.url)}`}}function nP(e){return e.length>64?`${e.slice(0,61)}…`:e}function h6(e){return e.kind==="browser"||e.kind==="api"?e.url:zv(e)}const sP="无法加入:会话已切换或引用已达上限";function Mc(e){const[t,n]=f.useState(""),[s,r]=f.useState(""),a=e.comment??t,o=e.busy===!0,l=e.canConfirm??!o,c=()=>{l&&e.onConfirm(a)===!1&&r(sP)};return i.jsxs("div",{className:`oc-cite-card${e.placement==="anchored"?" is-anchored":""}`,style:e.style,role:"group","aria-label":e.label,"aria-busy":o,onMouseDown:d=>d.stopPropagation(),onMouseUp:d=>d.stopPropagation(),onKeyDown:d=>{d.key==="Escape"&&(d.stopPropagation(),e.onCancel())},children:[i.jsxs("div",{className:"oc-cite-head",children:[i.jsx("span",{className:"oc-cite-tag",children:e.tag}),i.jsx("p",{className:`oc-cite-quote${e.quoteBlock?" is-block":""}`,title:e.quote,children:e.quote}),i.jsxs("div",{className:"oc-cite-head-actions",children:[e.headActions,i.jsx("button",{type:"button",className:"oc-cite-icon","aria-label":"取消引用",disabled:o,onClick:e.onCancel,children:"×"})]})]}),i.jsxs("label",{className:"oc-cite-comment",children:[i.jsx("span",{children:"想让模型注意什么(可选)"}),i.jsx("input",{"aria-label":e.commentLabel??"引用评论",placeholder:e.placeholder,value:a,maxLength:2e3,disabled:o,autoFocus:!0,onChange:d=>{r(""),e.onComment?e.onComment(d.target.value):n(d.target.value)},onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&(d.preventDefault(),c())}})]}),e.extra,s?i.jsx("p",{className:"oc-cite-error",role:"alert",children:s}):null,i.jsxs("div",{className:"oc-cite-actions",children:[i.jsx("p",{className:"oc-cite-footnote",children:"会出现在输入框上方,随下一条消息发送"}),i.jsx("button",{type:"button",className:"btn",disabled:o,onClick:e.onCancel,children:"取消"}),i.jsx("button",{type:"button",className:"btn btn-primary",disabled:!l,onClick:c,children:o?"正在加入…":"引用到这条消息"})]})]})}function pg(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`text-fnv1a:${(t>>>0).toString(16)}:${e.length}`}function rP(e,t){if(!t||t.isCollapsed||t.rangeCount!==1)return null;const n=t.getRangeAt(0);if(!e.contains(n.startContainer)||!e.contains(n.endContainer))return null;const s=n.startContainer.nodeType===1?n.startContainer:n.startContainer.parentElement,r=n.endContainer.nodeType===1?n.endContainer:n.endContainer.parentElement;if(!s||!r||s.closest("button,input,textarea,[contenteditable=true]")||r.closest("button,input,textarea,[contenteditable=true]")||n.cloneContents().querySelector("button,input,textarea,[contenteditable=true]"))return null;const o=n.toString();if(!o.trim())return null;const l=n.cloneRange();l.selectNodeContents(e),l.setEnd(n.startContainer,n.startOffset);const c=l.toString().length;return{text:o,range:n.cloneRange(),anchor:`rendered:${c}:${c+o.length}`,startElement:s,endElement:r,startOffset:n.startOffset,endOffset:n.endOffset}}const vm=352,kw=200,Cw=56;function iP(e,t){const n=e.getBoundingClientRect(),s=t.getBoundingClientRect(),r=t.getClientRects(),a=r.length?r[r.length-1]:s;return{top:s.top-n.top,bottom:s.bottom-n.top,left:s.left-n.left,endX:a.right-n.left,endBottom:a.bottom-n.top,width:n.width,height:n.height}}function f6(e){const t=e.width<vm?e.width-vm:Math.max(0,Math.min(e.left,e.width-vm)),n=e.bottom+6,s=e.top-6-kw;return{top:n+kw>e.height&&s>=0?s:n,left:t}}function m6(e){return{top:e.endBottom+4,left:Math.max(0,Math.min(e.endX-Cw/2,Math.max(0,e.width-Cw)))}}function Hv(e){const t=f.useRef(null),n=f.useRef(null),[s,r]=f.useState(null),[a,o]=f.useState(!1),[l,c]=f.useState(""),d=()=>{r(null),o(!1)};f.useEffect(()=>{d(),c("")},[e.referenceOwner?.sessionId,e.referenceOwner?.workspaceId,e.referenceOwner?.generation,e.disabled]),f.useEffect(()=>{if(!s||a)return;const p=()=>{window.getSelection()?.isCollapsed!==!1&&d()};return document.addEventListener("selectionchange",p),()=>document.removeEventListener("selectionchange",p)},[s,a]);const u=()=>{if(a||!n.current||!t.current||!e.referenceOwner||!e.onReference||e.disabled)return;const p=rP(n.current,window.getSelection());if(!p){r(null);return}try{const m=e.source(p),g=e.quote?e.quote(p):p.text;if(!m||!g){c("此选区没有可靠来源,请在同一正文或同一侧重新选择"),r(null);return}const v=or([{id:crypto.randomUUID(),capturedAt:new Date().toISOString(),quote:g,comment:"",source:m}])[0];r({reference:v,owner:{...e.referenceOwner},anchor:iP(t.current,p.range)}),c("")}catch(m){r(null),c(m instanceof Error?m.message:"引用无效")}},h=s?.anchor;return i.jsxs("div",{ref:t,className:`oc-cite-scope${e.className?` ${e.className}`:""}`,onScrollCapture:()=>{a||r(null)},children:[i.jsx("div",{ref:n,onMouseUp:u,onKeyUp:p=>{(p.key==="Shift"||p.key.startsWith("Arrow"))&&u()},children:e.children}),s&&h&&!a?i.jsx("button",{type:"button",className:"oc-cite-chip",style:m6(h),onMouseDown:p=>{p.preventDefault(),p.stopPropagation()},onMouseUp:p=>p.stopPropagation(),onClick:()=>o(!0),children:"引用"}):null,s&&h&&a?i.jsx(Mc,{label:"确认选文引用",placement:"anchored",style:f6(h),tag:bh(s.reference.source),quote:s.reference.quote,commentLabel:"选文评论",placeholder:"例如:这里的结论需要核对",onCancel:d,onConfirm:p=>{try{const m=or([{...s.reference,comment:p}])[0];return e.onReference?.(m,s.owner)?(d(),window.getSelection()?.removeAllRanges(),!0):!1}catch{return!1}}},s.reference.id):null,l?i.jsx("p",{className:"oc-cite-error",role:"alert",children:l}):null]})}function aP(e){return e.references?.length?i.jsx("div",{className:"oc-reference-list oc-reference-history","aria-label":"消息引用",children:e.references.map(t=>{const n=Fv(t.quote),s=t.quote.trim()!==n,r=zv(t.source);return i.jsxs("div",{className:"oc-reference-card",children:[i.jsxs("div",{className:"oc-reference-card-head",children:[i.jsx("span",{className:"oc-cite-tag",children:bh(t.source)}),i.jsx("span",{className:"oc-reference-card-meta",title:h6(t.source),children:r})]}),i.jsx("p",{className:"oc-reference-card-quote",title:n,children:n}),t.comment?i.jsx("p",{className:"oc-reference-card-note",children:t.comment}):null,t.screenshotId?i.jsx("img",{className:"oc-reference-preview",alt:"确认时的目标截图",src:`/api/operator/v1/chat/browser/reference-image/${encodeURIComponent(t.screenshotId)}?workspaceId=${encodeURIComponent(t.source.workspaceId)}`}):null,s?i.jsxs("details",{className:"oc-reference-dossier",children:[i.jsx("summary",{children:"查看元素描述"}),i.jsx("pre",{children:t.quote})]}):null]},t.id)})}):null}async function oP(e){const t=new ArrayBuffer(e.byteLength);new Uint8Array(t).set(e);const n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n),s=>s.toString(16).padStart(2,"0")).join("")}function Iw(e){let t="";for(let n=e+1;n>0;n=Math.floor((n-1)/26))t=String.fromCharCode(65+(n-1)%26)+t;return t}function lP(e){const t=`${Iw(e.left)}${e.top+1}`,n=`${Iw(e.right)}${e.bottom+1}`;return t===n?t:`${t}:${n}`}function cP(e){const t=e.getAttribute("data-sheet-row"),n=e.getAttribute("data-sheet-col");if(t===null||n===null)return null;const s=Number(t),r=Number(n);return!Number.isInteger(s)||!Number.isInteger(r)?null:{row:s,col:r,rowSpan:Number(e.getAttribute("rowspan"))||1,colSpan:Number(e.getAttribute("colspan"))||1}}function dP(e,t){return Array.from(e.querySelectorAll("[data-sheet-row]")).filter(n=>{if(!t.intersectsNode(n))return!1;const s=document.createRange();s.selectNodeContents(n);const r=t.compareBoundaryPoints(Range.START_TO_START,s)>0,a=t.compareBoundaryPoints(Range.END_TO_END,s)<0;return r&&s.setStart(t.startContainer,t.startOffset),a&&s.setEnd(t.endContainer,t.endOffset),s.collapsed?!1:s.toString().trim()!==""||!r&&!a})}function uP(e){const t=e.map(cP).filter(n=>n!==null);return t.length?{top:Math.min(...t.map(n=>n.row)),left:Math.min(...t.map(n=>n.col)),bottom:Math.max(...t.map(n=>n.row+n.rowSpan-1)),right:Math.max(...t.map(n=>n.col+n.colSpan-1))}:null}function Ew(e,t,n){const s=[];for(let r=n.left;r<=n.right;r++){const a=e.rows[t]?.[r];s.push(a&&!a.hidden?a.text.replace(/[\t\r\n]+/g," "):"")}return s.join(" ")}function hP(e,t){const n=lP(t),s=[];for(let a=t.top;a<=t.bottom;a++)s.push(Ew(e,a,t));const r=t.top>0?`表头(第 1 行):
|
|
50
50
|
${Ew(e,0,t)}
|
|
@@ -318,7 +318,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),en=Re,Ut=tt),ft===void
|
|
|
318
318
|
`),1;if(ki>1e5&&ki>kt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=Ot,Ot.length}const Ct=_t(Re);if(!Ct)throw $e(Je.replace("{}",Re)),new Error('Unknown language: "'+Re+'"');const fn=He(Ct);let tn="",Tt=Ut||fn;const zc={},Ln=new ze.__emitter(ze);ie();let an="",yr=0,As=0,ki=0,Ci=!1;try{if(Ct.__emitTokens)Ct.__emitTokens(tt,Ln);else{for(Tt.matcher.considerAll();;){ki++,Ci?Ci=!1:Tt.matcher.considerAll(),Tt.matcher.lastIndex=As;const mt=Tt.matcher.exec(tt);if(!mt)break;const kt=tt.substring(As,mt.index),Ot=qe(kt,mt);As=mt.index+Ot}qe(tt.substring(As))}return Ln.finalize(),tn=Ln.toHTML(),{language:Re,value:tn,relevance:yr,illegal:!1,_emitter:Ln,_top:Tt}}catch(mt){if(mt.message&&mt.message.includes("Illegal"))return{language:Re,value:Pe(tt),illegal:!0,relevance:0,_illegalBy:{message:mt.message,index:As,context:tt.slice(As-100,As+100),mode:mt.mode,resultSoFar:tn},_emitter:Ln};if(We)return{language:Re,value:Pe(tt),illegal:!1,relevance:0,errorRaised:mt,_emitter:Ln,_top:Tt};throw mt}}function st(Re){const tt={value:Pe(Re),illegal:!1,relevance:0,_top:Ze,_emitter:new ze.__emitter(ze)};return tt._emitter.addText(Re),tt}function pt(Re,tt){tt=tt||ze.languages||Object.keys(ve);const ft=st(Re),Ut=tt.filter(_t).filter(nn).map(sn=>Xe(sn,Re,!1));Ut.unshift(ft);const en=Ut.sort((sn,os)=>{if(sn.relevance!==os.relevance)return os.relevance-sn.relevance;if(sn.language&&os.language){if(_t(sn.language).supersetOf===os.language)return 1;if(_t(os.language).supersetOf===sn.language)return-1}return 0}),[Nn,vn]=en,Fs=Nn;return Fs.secondBest=vn,Fs}function At(Re,tt,ft){const Ut=tt&&Ae[tt]||ft;Re.classList.add("hljs"),Re.classList.add(`language-${Ut}`)}function Bt(Re){let tt=null;const ft=De(Re);if(ct(ft))return;if(et("before:highlightElement",{el:Re,language:ft}),Re.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Re);return}if(Re.children.length>0&&(ze.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Re)),ze.throwUnescapedHTML))throw new fe("One of your code blocks includes unescaped HTML.",Re.innerHTML);tt=Re;const Ut=tt.textContent,en=ft?Ve(Ut,{language:ft,ignoreIllegals:!0}):pt(Ut);Re.innerHTML=en.value,Re.dataset.highlighted="yes",At(Re,ft,en.language),Re.result={language:en.language,re:en.relevance,relevance:en.relevance},en.secondBest&&(Re.secondBest={language:en.secondBest.language,relevance:en.secondBest.relevance}),et("after:highlightElement",{el:Re,result:en,text:Ut})}function qt(Re){ze=ye(ze,Re)}const hn=()=>{Mt(),oe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Mn(){Mt(),oe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Ke=!1;function Mt(){function Re(){Mt()}if(document.readyState==="loading"){Ke||window.addEventListener("DOMContentLoaded",Re,!1),Ke=!0;return}document.querySelectorAll(ze.cssSelector).forEach(Bt)}function Et(Re,tt){let ft=null;try{ft=tt(le)}catch(Ut){if($e("Language definition for '{}' could not be registered.".replace("{}",Re)),We)$e(Ut);else throw Ut;ft=Ze}ft.name||(ft.name=Re),ve[Re]=ft,ft.rawDefinition=tt.bind(null,le),ft.aliases&&gn(ft.aliases,{languageName:Re})}function yt(Re){delete ve[Re];for(const tt of Object.keys(Ae))Ae[tt]===Re&&delete Ae[tt]}function Pt(){return Object.keys(ve)}function _t(Re){return Re=(Re||"").toLowerCase(),ve[Re]||ve[Ae[Re]]}function gn(Re,{languageName:tt}){typeof Re=="string"&&(Re=[Re]),Re.forEach(ft=>{Ae[ft.toLowerCase()]=tt})}function nn(Re){const tt=_t(Re);return tt&&!tt.disableAutodetect}function Te(Re){Re["before:highlightBlock"]&&!Re["before:highlightElement"]&&(Re["before:highlightElement"]=tt=>{Re["before:highlightBlock"](Object.assign({block:tt.el},tt))}),Re["after:highlightBlock"]&&!Re["after:highlightElement"]&&(Re["after:highlightElement"]=tt=>{Re["after:highlightBlock"](Object.assign({block:tt.el},tt))})}function Xt(Re){Te(Re),Ue.push(Re)}function Ne(Re){const tt=Ue.indexOf(Re);tt!==-1&&Ue.splice(tt,1)}function et(Re,tt){const ft=Re;Ue.forEach(function(Ut){Ut[ft]&&Ut[ft](tt)})}function Be(Re){return oe("10.7.0","highlightBlock will be removed entirely in v12.0"),oe("10.7.0","Please use highlightElement now."),Bt(Re)}Object.assign(le,{highlight:Ve,highlightAuto:pt,highlightAll:Mt,highlightElement:Bt,highlightBlock:Be,configure:qt,initHighlighting:hn,initHighlightingOnLoad:Mn,registerLanguage:Et,unregisterLanguage:yt,listLanguages:Pt,getLanguage:_t,registerAliases:gn,autoDetection:nn,inherit:ye,addPlugin:Xt,removePlugin:Ne}),le.debugMode=function(){We=!1},le.safeMode=function(){We=!0},le.versionString=St,le.regex={concat:v,lookahead:p,either:x,optional:g,anyNumberOfTimes:m};for(const Re in se)typeof se[Re]=="object"&&e(se[Re]);return Object.assign(le,se),le},vt=ut({});return vt.newInstance=()=>ut({}),Om=vt,vt.HighlightJS=vt,vt.default=vt,Om}var Dm,S2;function KB(){if(S2)return Dm;S2=1;function e(t){const n=t.regex,s=n.concat(/[\p{L}_]/u,n.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,a={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=t.inherit(o,{begin:/\(/,end:/\)/}),c=t.inherit(t.APOS_STRING_MODE,{className:"string"}),d=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),u={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[a]},{begin:/'/,end:/'/,contains:[a]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,d,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,l,d,c]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},a,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[d]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[u],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[u],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:n.concat(/</,n.lookahead(n.concat(s,n.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:s,relevance:0,starts:u}]},{className:"tag",begin:n.concat(/<\//,n.lookahead(n.concat(s,/>/))),contains:[{className:"name",begin:s,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}return Dm=e,Dm}var Pm,_2;function YB(){if(_2)return Pm;_2=1;function e(t){const n=t.regex,s={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[s]}]};Object.assign(s,{className:"variable",variants:[{begin:n.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const a={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},o=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,s,a]};a.contains.push(c);const d={match:/\\"/},u={className:"string",begin:/'/,end:/'/},h={match:/\\'/},p={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,s]},m=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],g=t.SHEBANG({binary:`(${m.join("|")})`,relevance:10}),v={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},b=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],x=["true","false"],y={match:/(\/[a-z._-]+)+/},C=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],S=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],I=["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"],w=["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:b,literal:x,built_in:[...C,...S,"set","shopt",...I,...w]},contains:[g,t.SHEBANG(),v,p,o,l,y,c,d,u,h,s]}}return Pm=e,Pm}var $m,k2;function ZB(){if(k2)return $m;k2=1;function e(t){const n=t.regex,s=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",a="[a-zA-Z_]\\w*::",l="("+r+"|"+n.optional(a)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",c={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.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:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={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},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},s,t.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:n.optional(a)+t.IDENT_RE,relevance:0},g=n.optional(a)+t.IDENT_RE+"\\s*\\(",x={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"},y=[p,c,s,t.C_BLOCK_COMMENT_MODE,h,u],C={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:x,contains:y.concat([{begin:/\(/,end:/\)/,keywords:x,contains:y.concat(["self"]),relevance:0}]),relevance:0},S={begin:"("+l+"[\\*&\\s]+)+"+g,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:x,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:x,relevance:0},{begin:g,returnBegin:!0,contains:[t.inherit(m,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:x,relevance:0,contains:[s,t.C_BLOCK_COMMENT_MODE,u,h,c,{begin:/\(/,end:/\)/,keywords:x,relevance:0,contains:["self",s,t.C_BLOCK_COMMENT_MODE,u,h,c]}]},c,s,t.C_BLOCK_COMMENT_MODE,p]};return{name:"C",aliases:["h"],keywords:x,disableAutodetect:!0,illegal:"</",contains:[].concat(C,S,y,[p,{begin:t.IDENT_RE+"::",keywords:x},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:p,strings:u,keywords:x}}}return $m=e,$m}var Bm,C2;function XB(){if(C2)return Bm;C2=1;function e(t){const n=t.regex,s=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",a="[a-zA-Z_]\\w*::",l="(?!struct)("+r+"|"+n.optional(a)+"[a-zA-Z_]\\w*"+n.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},u={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.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:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},h={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},t.inherit(u,{className:"string"}),{className:"string",begin:/<.*?>/},s,t.C_BLOCK_COMMENT_MODE]},m={className:"title",begin:n.optional(a)+t.IDENT_RE,relevance:0},g=n.optional(a)+t.IDENT_RE+"\\s*\\(",v=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],b=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],x=["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"],y=["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"],I={type:b,keyword:v,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:x},w={className:"function.dispatch",relevance:0,keywords:{_hint:y},begin:n.concat(/\b/,`(?!${v.join("|")})`,t.IDENT_RE,n.lookahead(/(<[^<>]+>|)\s*\(/))},_=[w,p,c,s,t.C_BLOCK_COMMENT_MODE,h,u],k={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:I,contains:_.concat([{begin:/\(/,end:/\)/,keywords:I,contains:_.concat(["self"]),relevance:0}]),relevance:0},N={className:"function",begin:"("+l+"[\\*&\\s]+)+"+g,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:I,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:I,relevance:0},{begin:g,returnBegin:!0,contains:[m],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[u,h]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:I,relevance:0,contains:[s,t.C_BLOCK_COMMENT_MODE,u,h,c,{begin:/\(/,end:/\)/,keywords:I,relevance:0,contains:["self",s,t.C_BLOCK_COMMENT_MODE,u,h,c]}]},c,s,t.C_BLOCK_COMMENT_MODE,p]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:I,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(k,N,w,_,[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:I,contains:["self",c]},{begin:t.IDENT_RE+"::",keywords:I},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}return Bm=e,Bm}var Fm,I2;function JB(){if(I2)return Fm;I2=1;function e(t){const n=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],s=["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"],o=["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"],l={keyword:a.concat(o),built_in:n,literal:r},c=t.inherit(t.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},u={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},h={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},p=t.inherit(h,{illegal:/\n/}),m={className:"subst",begin:/\{/,end:/\}/,keywords:l},g=t.inherit(m,{illegal:/\n/}),v={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,g]},b={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},m]},x=t.inherit(b,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},g]});m.contains=[b,v,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.C_BLOCK_COMMENT_MODE],g.contains=[x,v,p,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,d,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const y={variants:[u,b,v,h,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},C={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},S=t.IDENT_RE+"(<"+t.IDENT_RE+"(\\s*,\\s*"+t.IDENT_RE+")*>)?(\\[\\])?",I={begin:"@"+t.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:l,illegal:/::/,contains:[t.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},y,d,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,C,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,C,t.C_LINE_COMMENT_MODE,t.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:"("+S+"\\s+)+"+t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:l,contains:[{beginKeywords:s.join(" "),relevance:0},{begin:t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[t.TITLE_MODE,C],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,relevance:0,contains:[y,d,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},I]}}return Fm=e,Fm}var zm,E2;function QB(){if(E2)return zm;E2=1;const e=d=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:d.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:[d.APOS_STRING_MODE,d.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:d.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_-]*/}}),t=["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"],n=["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"],s=[...t,...n],r=["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(),a=["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(),o=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),l=["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 c(d){const u=d.regex,h=e(d),p={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},m="and or not only",g=/@-?\w[\w]*(-\w+)*/,v="[a-zA-Z-][a-zA-Z0-9_-]*",b=[d.APOS_STRING_MODE,d.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[h.BLOCK_COMMENT,p,h.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+v,relevance:0},h.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+a.join("|")+")"},{begin:":(:)?("+o.join("|")+")"}]},h.CSS_VARIABLE,{className:"attribute",begin:"\\b("+l.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[h.BLOCK_COMMENT,h.HEXCOLOR,h.IMPORTANT,h.CSS_NUMBER_MODE,h.UNICODE_RANGE,...b,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...b,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},h.FUNCTION_DISPATCH]},{begin:u.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:g},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:m,attribute:r.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...b,h.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+s.join("|")+")\\b"}]}}return zm=c,zm}var Hm,N2;function eF(){if(N2)return Hm;N2=1;function e(t){const n=t.regex,s={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}]},o={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={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:n.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}]},u={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=t.inherit(u,{contains:[]}),m=t.inherit(h,{contains:[]});u.contains.push(m),h.contains.push(p);let g=[s,d];return[u,h,p,m].forEach(y=>{y.contains=y.contains.concat(g)}),g=g.concat(u,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:g},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:g}]}]},s,o,u,h,{className:"quote",begin:"^>\\s+",contains:g,end:"$"},a,r,d,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}return Hm=e,Hm}var qm,j2;function tF(){if(j2)return qm;j2=1;function e(t){const n=t.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:n.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+ +\+\d+,\d+ +@@/,/^@@ +-\d+,\d+ +\+\d+ +@@/,/^@@ +-\d+ +\+\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:n.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}return qm=e,qm}var Um,T2;function nF(){if(T2)return Um;T2=1;function e(t){const n=t.regex,s="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=n.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),a=n.concat(r,/(::\w+)*/),l={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},c={className:"doctag",begin:"@[A-Za-z]+"},d={begin:"#<",end:">"},u=[t.COMMENT("#","$",{contains:[c]}),t.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:l},p={className:"string",contains:[t.BACKSLASH_ESCAPE,h],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:n.concat(/<<[-~]?'?/,n.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[t.BACKSLASH_ESCAPE,h]})]}]},m="[1-9](_?[0-9])*|0",g="[0-9](_?[0-9])*",v={className:"number",relevance:0,variants:[{begin:`\\b(${m})(\\.(${g}))?([eE][+-]?(${g})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},b={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:l}]},_=[p,{variants:[{match:[/class\s+/,a,/\s+<\s+/,a]},{match:[/\b(class|module)\s+/,a]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:l},{match:[/(include|extend)\s+/,a],scope:{2:"title.class"},keywords:l},{relevance:0,match:[a,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,s],scope:{1:"keyword",3:"title.function"},contains:[b]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[p,{begin:s}],relevance:0},v,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:l},{begin:"("+t.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[t.BACKSLASH_ESCAPE,h],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(d,u),relevance:0}].concat(d,u);h.contains=_,b.contains=_;const O=[{begin:/^\s*=>/,starts:{end:"$",contains:_}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:l,contains:_}}];return u.unshift(d),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:l,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(O).concat(u).concat(_)}}return Um=e,Um}var Wm,R2;function sF(){if(R2)return Wm;R2=1;function e(t){const o={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:o,illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"string",variants:[t.QUOTE_STRING_MODE,t.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:[t.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:o,illegal:/["']/}]}]}}return Wm=e,Wm}var Vm,A2;function rF(){if(A2)return Vm;A2=1;function e(t){const n=t.regex,s=/[_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:[t.HASH_COMMENT_MODE,t.QUOTE_STRING_MODE,t.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:n.concat(s,n.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}return Vm=e,Vm}var Gm,M2;function iF(){if(M2)return Gm;M2=1;function e(t){const n=t.regex,s={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:t.NUMBER_RE}]},r=t.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const a={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},o={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,o,a,l,s,"self"],relevance:0},d=/[A-Za-z0-9_-]+/,u=/"(\\"|[^"])*"/,h=/'[^']*'/,p=n.either(d,u,h),m=n.concat(p,"(\\s*\\.\\s*",p,")*",n.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:m,className:"attr",starts:{end:/$/,contains:[r,c,o,a,l,s]}}]}}return Gm=e,Gm}var Km,L2;function aF(){if(L2)return Km;L2=1;var e="[0-9](_*[0-9])*",t=`\\.(${e})`,n="[0-9a-fA-F](_*[0-9a-fA-F])*",s={className:"number",variants:[{begin:`(\\b(${e})((${t})|\\.)?|(${t}))[eE][+-]?(${e})[fFdD]?\\b`},{begin:`\\b(${e})((${t})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${t})[fFdD]?\\b`},{begin:`\\b(${e})[fFdD]\\b`},{begin:`\\b0[xX]((${n})\\.?|(${n})?\\.(${n}))[pP][+-]?(${e})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${n})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function r(o,l,c){return c===-1?"":o.replace(l,d=>r(o,l,c-1))}function a(o){const l=o.regex,c="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",d=c+r("(?:<"+c+"~~~(?:\\s*,\\s*"+c+"~~~)*>)?",/~~~/g,2),g={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"]},v={className:"meta",begin:"@"+c,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},b={className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[o.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:g,illegal:/<\/|#/,contains:[o.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},o.C_LINE_COMMENT_MODE,o.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[o.BACKSLASH_ESCAPE]},o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,c],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[l.concat(/(?!else)/,c),/\s+/,c,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,c],className:{1:"keyword",3:"title.class"},contains:[b,o.C_LINE_COMMENT_MODE,o.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+d+"\\s+)",o.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:g,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:g,relevance:0,contains:[v,o.APOS_STRING_MODE,o.QUOTE_STRING_MODE,s,o.C_BLOCK_COMMENT_MODE]},o.C_LINE_COMMENT_MODE,o.C_BLOCK_COMMENT_MODE]},s,v]}}return Km=a,Km}var Ym,O2;function oF(){if(O2)return Ym;O2=1;const e="[A-Za-z$_][0-9A-Za-z$_]*",t=["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"],n=["true","false","null","undefined","NaN","Infinity"],s=["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"],r=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],a=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],o=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],l=[].concat(a,s,r);function c(d){const u=d.regex,h=(U,{after:q})=>{const te="</"+U[0].slice(1);return U.input.indexOf(te,q)!==-1},p=e,m={begin:"<>",end:"</>"},g=/<[A-Za-z0-9\\._:-]+\s*\/>/,v={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(U,q)=>{const te=U[0].length+U.index,se=U.input[te];if(se==="<"||se===","){q.ignoreMatch();return}se===">"&&(h(U,{after:te})||q.ignoreMatch());let he;const X=U.input.substring(te);if(he=X.match(/^\s*=/)){q.ignoreMatch();return}if((he=X.match(/^\s+extends\s+/))&&he.index===0){q.ignoreMatch();return}}},b={$pattern:e,keyword:t,literal:n,built_in:l,"variable.language":o},x="[0-9](_?[0-9])*",y=`\\.(${x})`,C="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",S={className:"number",variants:[{begin:`(\\b(${C})((${y})|\\.)?|(${y}))[eE][+-]?(${x})\\b`},{begin:`\\b(${C})\\b((${y})\\b|\\.)?|(${y})\\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},I={className:"subst",begin:"\\$\\{",end:"\\}",keywords:b,contains:[]},w={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[d.BACKSLASH_ESCAPE,I],subLanguage:"xml"}},_={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[d.BACKSLASH_ESCAPE,I],subLanguage:"css"}},k={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[d.BACKSLASH_ESCAPE,I],subLanguage:"graphql"}},N={className:"string",begin:"`",end:"`",contains:[d.BACKSLASH_ESCAPE,I]},O={className:"comment",variants:[d.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:p+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),d.C_BLOCK_COMMENT_MODE,d.C_LINE_COMMENT_MODE]},T=[d.APOS_STRING_MODE,d.QUOTE_STRING_MODE,w,_,k,N,{match:/\$\d+/},S];I.contains=T.concat({begin:/\{/,end:/\}/,keywords:b,contains:["self"].concat(T)});const R=[].concat(O,I.contains),A=R.concat([{begin:/(\s*)\(/,end:/\)/,keywords:b,contains:["self"].concat(R)}]),E={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:b,contains:A},$={variants:[{match:[/class/,/\s+/,p,/\s+/,/extends/,/\s+/,u.concat(p,"(",u.concat(/\./,p),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,p],scope:{1:"keyword",3:"title.class"}}]},H={relevance:0,match:u.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:{_:[...s,...r]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},G={variants:[{match:[/function/,/\s+/,p,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[E],illegal:/%/},z={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function Q(U){return u.concat("(?!",U.join("|"),")")}const W={match:u.concat(/\b/,Q([...a,"super","import","await"].map(U=>`${U}\\s*\\(`)),p,u.lookahead(/\s*\(/)),className:"title.function",relevance:0},D={begin:u.concat(/\./,u.lookahead(u.concat(p,/(?![0-9A-Za-z$_(])/))),end:p,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},ee={match:[/get|set/,/\s+/,p,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},E]},F="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+d.UNDERSCORE_IDENT_RE+")\\s*=>",M={match:[/const|var|let/,/\s+/,p,/\s*/,/=\s*/,/(async\s*)?/,u.lookahead(F)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[E]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:b,exports:{PARAMS_CONTAINS:A,CLASS_REFERENCE:H},illegal:/#(?![$_A-Za-z])/,contains:[d.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,d.APOS_STRING_MODE,d.QUOTE_STRING_MODE,w,_,k,N,O,{match:/\$\d+/},S,H,{scope:"attr",match:p+u.lookahead(":"),relevance:0},M,{begin:"("+d.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[O,d.REGEXP_MODE,{className:"function",begin:F,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:d.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:b,contains:A}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:m.begin,end:m.end},{match:g},{begin:v.begin,"on:begin":v.isTrulyOpeningTag,end:v.end}],subLanguage:"xml",contains:[{begin:v.begin,end:v.end,skip:!0,contains:["self"]}]}]},G,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+d.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[E,d.inherit(d.TITLE_MODE,{begin:p,className:"title.function"})]},{match:/\.\.\./,relevance:0},D,{match:"\\$"+p,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[E]},W,z,$,ee,{match:/\$[(.]/}]}}return Ym=c,Ym}var Zm,D2;function lF(){if(D2)return Zm;D2=1;const t={scope:"number",match:"([-+]?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)|NaN|[-+]?Infinity",relevance:0};function n(s){const r={className:"attr",begin:/(("(\\.|[^\\"\r\n])*")|('(\\.|[^\\'\r\n])*'))(?=\s*:)/,relevance:1.01},a={match:/[{}[\],:]/,className:"punctuation",relevance:0},o=["true","false","null"],l={scope:"literal",beginKeywords:o.join(" ")};return{name:"JSON",aliases:["jsonc","json5"],keywords:{literal:o},contains:[r,a,s.APOS_STRING_MODE,s.QUOTE_STRING_MODE,l,t,s.C_LINE_COMMENT_MODE,s.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}return Zm=n,Zm}var Xm,P2;function cF(){if(P2)return Xm;P2=1;var e="[0-9](_*[0-9])*",t=`\\.(${e})`,n="[0-9a-fA-F](_*[0-9a-fA-F])*",s={className:"number",variants:[{begin:`(\\b(${e})((${t})|\\.)?|(${t}))[eE][+-]?(${e})[fFdD]?\\b`},{begin:`\\b(${e})((${t})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${t})[fFdD]?\\b`},{begin:`\\b(${e})[fFdD]\\b`},{begin:`\\b0[xX]((${n})\\.?|(${n})?\\.(${n}))[pP][+-]?(${e})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${n})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function r(a){const o={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"},l={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},c={className:"symbol",begin:a.UNDERSCORE_IDENT_RE+"@"},d={className:"subst",begin:/\$\{/,end:/\}/,contains:[a.C_NUMBER_MODE]},u={className:"variable",begin:"\\$"+a.UNDERSCORE_IDENT_RE},h={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[u,d]},{begin:"'",end:"'",illegal:/\n/,contains:[a.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[a.BACKSLASH_ESCAPE,u,d]}]};d.contains.push(h);const p={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+a.UNDERSCORE_IDENT_RE+")?"},m={className:"meta",begin:"@"+a.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[a.inherit(h,{className:"string"}),"self"]}]},g=s,v=a.COMMENT("/\\*","\\*/",{contains:[a.C_BLOCK_COMMENT_MODE]}),b={variants:[{className:"type",begin:a.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},x=b;return x.variants[1].contains=[b],b.variants[1].contains=[x],{name:"Kotlin",aliases:["kt","kts"],keywords:o,contains:[a.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),a.C_LINE_COMMENT_MODE,v,l,c,p,m,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:o,relevance:5,contains:[{begin:a.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[a.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:o,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[b,a.C_LINE_COMMENT_MODE,v],relevance:0},a.C_LINE_COMMENT_MODE,v,p,m,h,a.C_NUMBER_MODE]},v]},{begin:[/class|interface|trait/,/\s+/,a.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},a.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},p,m]},h,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
|
|
319
319
|
`},g]}}return Xm=r,Xm}var Jm,$2;function dF(){if($2)return Jm;$2=1;const e=u=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:u.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:[u.APOS_STRING_MODE,u.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:u.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_-]*/}}),t=["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"],n=["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"],s=[...t,...n],r=["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(),a=["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(),o=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),l=["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(),c=a.concat(o).sort().reverse();function d(u){const h=e(u),p=c,m="and or not only",g="[\\w-]+",v="("+g+"|@\\{"+g+"\\})",b=[],x=[],y=function(R){return{className:"string",begin:"~?"+R+".*?"+R}},C=function(R,A,E){return{className:R,begin:A,relevance:E}},S={$pattern:/[a-z-]+/,keyword:m,attribute:r.join(" ")},I={begin:"\\(",end:"\\)",contains:x,keywords:S,relevance:0};x.push(u.C_LINE_COMMENT_MODE,u.C_BLOCK_COMMENT_MODE,y("'"),y('"'),h.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},h.UNICODE_RANGE,h.HEXCOLOR,I,C("variable","@@?"+g,10),C("variable","@\\{"+g+"\\}"),C("built_in","~?`[^`]*?`"),{className:"attribute",begin:g+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},h.IMPORTANT,{beginKeywords:"and not"},h.FUNCTION_DISPATCH);const w=x.concat({begin:/\{/,end:/\}/,contains:b}),_={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(x)},k={begin:v+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},h.CSS_VARIABLE,{className:"attribute",begin:"\\b("+l.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:x}}]},N={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:S,returnEnd:!0,contains:x,relevance:0}},L={className:"variable",variants:[{begin:"@"+g+"\\s*:",relevance:15},{begin:"@"+g}],starts:{end:"[;}]",returnEnd:!0,contains:w}},O={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:v,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[u.C_LINE_COMMENT_MODE,u.C_BLOCK_COMMENT_MODE,_,C("keyword","all\\b"),C("variable","@\\{"+g+"\\}"),{begin:"\\b("+s.join("|")+")\\b",className:"selector-tag"},h.CSS_NUMBER_MODE,C("selector-tag",v,0),C("selector-id","#"+v),C("selector-class","\\."+v,0),C("selector-tag","&",0),h.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+a.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+o.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:w},{begin:"!important"},h.FUNCTION_DISPATCH]},T={begin:g+`:(:)?(${p.join("|")})`,returnBegin:!0,contains:[O]};return b.push(u.C_LINE_COMMENT_MODE,u.C_BLOCK_COMMENT_MODE,N,L,T,k,O,_,h.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:b}}return Jm=d,Jm}var Qm,B2;function uF(){if(B2)return Qm;B2=1;function e(t){const n="\\[=*\\[",s="\\]=*\\]",r={begin:n,end:s,contains:["self"]},a=[t.COMMENT("--(?!"+n+")","$"),t.COMMENT("--"+n,s,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:t.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:[t.inherit(t.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:a}].concat(a)},t.C_NUMBER_MODE,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{className:"string",begin:n,end:s,contains:[r],relevance:5}])}}return Qm=e,Qm}var e0,F2;function hF(){if(F2)return e0;F2=1;function e(t){const n={className:"variable",variants:[{begin:"\\$\\("+t.UNDERSCORE_IDENT_RE+"\\)",contains:[t.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},s={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n]},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:[n,s]},a={begin:"^"+t.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},o={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},l={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[n]};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:[t.HASH_COMMENT_MODE,n,s,r,a,o,l]}}return e0=e,e0}var t0,z2;function fF(){if(z2)return t0;z2=1;function e(t){const n=t.regex,s=["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:s.join(" ")},o={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:a},l={begin:/->\{/,end:/\}/},c={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},d={scope:"variable",variants:[{begin:/\$\d/},{begin:n.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[c]},u={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},h=[t.BACKSLASH_ESCAPE,o,d],p=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],m=(b,x,y="\\1")=>{const C=y==="\\1"?y:n.concat(y,x);return n.concat(n.concat("(?:",b,")"),x,/(?:\\.|[^\\\/])*?/,C,/(?:\\.|[^\\\/])*?/,y,r)},g=(b,x,y)=>n.concat(n.concat("(?:",b,")"),x,/(?:\\.|[^\\\/])*?/,y,r),v=[d,t.HASH_COMMENT_MODE,t.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),l,{className:"string",contains:h,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:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},u,{begin:"(\\/\\/|"+t.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[t.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:m("s|tr|y",n.either(...p,{capture:!0}))},{begin:m("s|tr|y","\\(","\\)")},{begin:m("s|tr|y","\\[","\\]")},{begin:m("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:g("(?:m|qr)?",/\//,/\//)},{begin:g("m|qr",n.either(...p,{capture:!0}),/\1/)},{begin:g("m|qr",/\(/,/\)/)},{begin:g("m|qr",/\[/,/\]/)},{begin:g("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,c]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,c,u]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return o.contains=v,l.contains=v,{name:"Perl",aliases:["pl","pm"],keywords:a,contains:v}}return t0=e,t0}var n0,H2;function mF(){if(H2)return n0;H2=1;function e(t){const n={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+"},s=/[a-zA-Z@][a-zA-Z0-9_]*/,c={"variable.language":["this","super"],$pattern:s,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:s,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:c,illegal:"</",contains:[n,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,t.C_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[t.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},t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+d.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:d,contains:[t.UNDERSCORE_TITLE_MODE]},{begin:"\\."+t.UNDERSCORE_IDENT_RE,relevance:0}]}}return n0=e,n0}var s0,q2;function pF(){if(q2)return s0;q2=1;function e(t){const n=t.regex,s=/(?![A-Za-z0-9])(?![$])/,r=n.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,s),a=n.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,s),o=n.concat(/[A-Z]+/,s),l={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:/\}/}]},u=t.inherit(t.APOS_STRING_MODE,{illegal:null}),h=t.inherit(t.QUOTE_STRING_MODE,{illegal:null,contains:t.QUOTE_STRING_MODE.contains.concat(d)}),p={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:t.QUOTE_STRING_MODE.contains.concat(d),"on:begin":(E,$)=>{$.data._beginMatch=E[1]||E[2]},"on:end":(E,$)=>{$.data._beginMatch!==E[1]&&$.ignoreMatch()}},m=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),g=`[
|
|
320
320
|
]`,v={scope:"string",variants:[h,u,p,m]},b={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},x=["false","null","true"],y=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],C=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],I={keyword:y,literal:(E=>{const $=[];return E.forEach(H=>{$.push(H),H.toLowerCase()===H?$.push(H.toUpperCase()):$.push(H.toLowerCase())}),$})(x),built_in:C},w=E=>E.map($=>$.replace(/\|\d+$/,"")),_={variants:[{match:[/new/,n.concat(g,"+"),n.concat("(?!",w(C).join("\\b|"),"\\b)"),a],scope:{1:"keyword",4:"title.class"}}]},k=n.concat(r,"\\b(?!\\()"),N={variants:[{match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),k],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[a,n.concat(/::/,n.lookahead(/(?!class\b)/)),k],scope:{1:"title.class",3:"variable.constant"}},{match:[a,n.concat("::",n.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[a,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},L={scope:"attr",match:n.concat(r,n.lookahead(":"),n.lookahead(/(?!::)/))},O={relevance:0,begin:/\(/,end:/\)/,keywords:I,contains:[L,l,N,t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE,t.HASH_COMMENT_MODE,v,b,_]},T={relevance:0,match:[/\b/,n.concat("(?!fn\\b|function\\b|",w(y).join("\\b|"),"|",w(C).join("\\b|"),"\\b)"),r,n.concat(g,"*"),n.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[O]};O.contains.push(T);const R=[L,N,t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE,t.HASH_COMMENT_MODE,v,b,_],A={begin:n.concat(/#\[\s*\\?/,n.either(a,o)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:x,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:x,keyword:["new","array"]},contains:["self",...R]},...R,{scope:"meta",variants:[{match:a},{match:o}]}]};return{case_insensitive:!1,keywords:I,contains:[A,t.HASH_COMMENT_MODE,t.COMMENT("//","$"),t.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:t.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},c,{scope:"variable.language",match:/\$this\b/},l,T,N,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},_,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},t.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:I,contains:["self",A,l,N,t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE,t.HASH_COMMENT_MODE,v,b]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},t.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[t.inherit(t.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},t.UNDERSCORE_TITLE_MODE]},v,b]}}return s0=e,s0}var r0,U2;function gF(){if(U2)return r0;U2=1;function e(t){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},t.inherit(t.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),t.inherit(t.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}return r0=e,r0}var i0,W2;function vF(){if(W2)return i0;W2=1;function e(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}return i0=e,i0}var a0,V2;function bF(){if(V2)return a0;V2=1;function e(t){const n=t.regex,s=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},d={className:"meta",begin:/^(>>>|\.\.\.) /},u={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},h={begin:/\{\{/,relevance:0},p={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,d],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,d,h,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,d,h,u]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,h,u]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,h,u]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},m="[0-9](_?[0-9])*",g=`(\\b(${m}))?\\.(${m})|\\b(${m})\\.`,v=`\\b|${r.join("|")}`,b={className:"number",relevance:0,variants:[{begin:`(\\b(${m})|(${g}))[eE][+-]?(${m})[jJ]?(?=${v})`},{begin:`(${g})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${v})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${v})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${v})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${v})`},{begin:`\\b(${m})[jJ](?=${v})`}]},x={className:"comment",begin:n.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},y={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",d,b,p,t.HASH_COMMENT_MODE]}]};return u.contains=[p,b,d],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[d,b,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,x,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,s],scope:{1:"keyword",3:"title.function"},contains:[y]},{variants:[{match:[/\bclass/,/\s+/,s,/\s*/,/\(\s*/,s,/\s*\)/]},{match:[/\bclass/,/\s+/,s]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[b,y,p]}]}}return a0=e,a0}var o0,G2;function xF(){if(G2)return o0;G2=1;function e(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}return o0=e,o0}var l0,K2;function yF(){if(K2)return l0;K2=1;function e(t){const n=t.regex,s=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=n.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),a=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,o=n.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:s,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[t.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:n.lookahead(n.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:s},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),t.HASH_COMMENT_MODE,{scope:"string",contains:[t.BACKSLASH_ESCAPE],variants:[t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[a,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[o,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[s,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:a},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:o},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}return l0=e,l0}var c0,Y2;function wF(){if(Y2)return c0;Y2=1;function e(t){const n=t.regex,s=/(r#)?/,r=n.concat(s,t.UNDERSCORE_IDENT_RE),a=n.concat(s,t.IDENT_RE),o={className:"title.function.invoke",relevance:0,begin:n.concat(/\b/,/(?!let|for|while|if|else|match\b)/,a,n.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(32|64))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],d=["true","false","Some","None","Ok","Err"],u=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],h=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:h,keyword:c,literal:d,built_in:u},illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*","\\*/",{contains:["self"]}),t.inherit(t.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:t.IDENT_RE+"::",keywords:{keyword:"Self",built_in:u,type:h}},{className:"punctuation",begin:"->"},o]}}return c0=e,c0}var d0,Z2;function SF(){if(Z2)return d0;Z2=1;const e=d=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:d.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:[d.APOS_STRING_MODE,d.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:d.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_-]*/}}),t=["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"],n=["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"],s=[...t,...n],r=["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(),a=["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(),o=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),l=["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 c(d){const u=e(d),h=o,p=a,m="@[a-z-]+",g="and or not only",b={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[d.C_LINE_COMMENT_MODE,d.C_BLOCK_COMMENT_MODE,u.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},u.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+s.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+p.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+h.join("|")+")"},b,{begin:/\(/,end:/\)/,contains:[u.CSS_NUMBER_MODE]},u.CSS_VARIABLE,{className:"attribute",begin:"\\b("+l.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[u.BLOCK_COMMENT,b,u.HEXCOLOR,u.CSS_NUMBER_MODE,u.UNICODE_RANGE,d.QUOTE_STRING_MODE,d.APOS_STRING_MODE,u.IMPORTANT,u.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:m,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:g,attribute:r.join(" ")},contains:[{begin:m,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},b,d.QUOTE_STRING_MODE,d.APOS_STRING_MODE,u.HEXCOLOR,u.CSS_NUMBER_MODE]},u.FUNCTION_DISPATCH]}}return d0=c,d0}var u0,X2;function _F(){if(X2)return u0;X2=1;function e(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}return u0=e,u0}var h0,J2;function kF(){if(J2)return h0;J2=1;function e(t){const n=t.regex,s=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},a={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],l=["double precision","large object","with timezone","without timezone"],c=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],d=["add","asc","collation","desc","final","first","last","view"],u=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],h=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],p=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],m=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],g=h,v=[...u,...d].filter(w=>!h.includes(w)),b={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},x={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},y={match:n.concat(/\b/,n.either(...g),/\s*\(/),relevance:0,keywords:{built_in:g}};function C(w){return n.concat(/\b/,n.either(...w.map(_=>_.replace(/\s+/,"\\s+"))),/\b/)}const S={scope:"keyword",match:C(m),relevance:0};function I(w,{exceptions:_,when:k}={}){const N=k;return _=_||[],w.map(L=>L.match(/\|\d+$/)||_.includes(L)?L:N(L)?`${L}|0`:L)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:I(v,{when:w=>w.length<3}),literal:o,type:c,built_in:p},contains:[{scope:"type",match:C(l)},S,y,b,r,a,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,s,x]}}return h0=e,h0}var f0,Q2;function CF(){if(Q2)return f0;Q2=1;function e(k){return k?typeof k=="string"?k:k.source:null}function t(k){return n("(?=",k,")")}function n(...k){return k.map(L=>e(L)).join("")}function s(k){const N=k[k.length-1];return typeof N=="object"&&N.constructor===Object?(k.splice(k.length-1,1),N):{}}function r(...k){return"("+(s(k).capture?"":"?:")+k.map(O=>e(O)).join("|")+")"}const a=k=>n(/\b/,k,/\w$/.test(k)?/\b/:/\B/),o=["Protocol","Type"].map(a),l=["init","self"].map(a),c=["Any","Self"],d=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],u=["false","nil","true"],h=["assignment","associativity","higherThan","left","lowerThan","none","right"],p=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],m=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],g=r(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),v=r(g,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),b=n(g,v,"*"),x=r(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),y=r(x,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),C=n(x,y,"*"),S=n(/[A-Z]/,y,"*"),I=["attached","autoclosure",n(/convention\(/,r("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",n(/objc\(/,C,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],w=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function _(k){const N={match:/\s+/,relevance:0},L=k.COMMENT("/\\*","\\*/",{contains:["self"]}),O=[k.C_LINE_COMMENT_MODE,L],T={match:[/\./,r(...o,...l)],className:{2:"keyword"}},R={match:n(/\./,r(...d)),relevance:0},A=d.filter(Ee=>typeof Ee=="string").concat(["_|0"]),E=d.filter(Ee=>typeof Ee!="string").concat(c).map(a),$={variants:[{className:"keyword",match:r(...E,...l)}]},H={$pattern:r(/\b\w+/,/#\w+/),keyword:A.concat(p),literal:u},B=[T,R,$],G={match:n(/\./,r(...m)),relevance:0},z={className:"built_in",match:n(/\b/,r(...m),/(?=\()/)},Q=[G,z],W={match:/->/,relevance:0},D={className:"operator",relevance:0,variants:[{match:b},{match:`\\.(\\.|${v})+`}]},ee=[W,D],F="([0-9]_*)+",M="([0-9a-fA-F]_*)+",U={className:"number",relevance:0,variants:[{match:`\\b(${F})(\\.(${F}))?([eE][+-]?(${F}))?\\b`},{match:`\\b0x(${M})(\\.(${M}))?([pP][+-]?(${F}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},q=(Ee="")=>({className:"subst",variants:[{match:n(/\\/,Ee,/[0\\tnr"']/)},{match:n(/\\/,Ee,/u\{[0-9a-fA-F]{1,8}\}/)}]}),te=(Ee="")=>({className:"subst",match:n(/\\/,Ee,/[\t ]*(?:[\r\n]|\r\n)/)}),se=(Ee="")=>({className:"subst",label:"interpol",begin:n(/\\/,Ee,/\(/),end:/\)/}),he=(Ee="")=>({begin:n(Ee,/"""/),end:n(/"""/,Ee),contains:[q(Ee),te(Ee),se(Ee)]}),X=(Ee="")=>({begin:n(Ee,/"/),end:n(/"/,Ee),contains:[q(Ee),se(Ee)]}),re={className:"string",variants:[he(),he("#"),he("##"),he("###"),X(),X("#"),X("##"),X("###")]},de=[k.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[k.BACKSLASH_ESCAPE]}],xe={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:de},K=Ee=>{const Ye=n(Ee,/\//),ut=n(/\//,Ee);return{begin:Ye,end:ut,contains:[...de,{scope:"comment",begin:`#(?!.*${ut})`,end:/$/}]}},pe={scope:"regexp",variants:[K("###"),K("##"),K("#"),xe]},Z={match:n(/`/,C,/`/)},ue={className:"variable",match:/\$\d+/},_e={className:"variable",match:`\\$${y}+`},Oe=[Z,ue,_e],Me={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:w,contains:[...ee,U,re]}]}},Ie={scope:"keyword",match:n(/@/,r(...I),t(r(/\(/,/\s+/)))},$e={scope:"meta",match:n(/@/,C)},be=[Me,Ie,$e],oe={match:t(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:n(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,y,"+")},{className:"type",match:S,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:n(/\s+&\s+/,t(S)),relevance:0}]},ge={begin:/</,end:/>/,keywords:H,contains:[...O,...B,...be,W,oe]};oe.contains.push(ge);const ke={match:n(C,/\s*:/),keywords:"_|0",relevance:0},ae={begin:/\(/,end:/\)/,relevance:0,keywords:H,contains:["self",ke,...O,pe,...B,...Q,...ee,U,re,...Oe,...be,oe]},ne={begin:/</,end:/>/,keywords:"repeat each",contains:[...O,oe]},we={begin:r(t(n(C,/\s*:/)),t(n(C,/\s+/,C,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:C}]},Ce={begin:/\(/,end:/\)/,keywords:H,contains:[we,...O,...B,...ee,U,re,...be,oe,ae],endsParent:!0,illegal:/["']/},He={match:[/(func|macro)/,/\s+/,r(Z.match,C,b)],className:{1:"keyword",3:"title.function"},contains:[ne,Ce,N],illegal:[/\[/,/%/]},ht={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[ne,Ce,N],illegal:/\[|%/},jt={match:[/operator/,/\s+/,b],className:{1:"keyword",3:"title"}},St={begin:[/precedencegroup/,/\s+/,S],className:{1:"keyword",3:"title"},contains:[oe],keywords:[...h,...u],end:/}/},fe={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Pe={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},ye={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,C,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:H,contains:[ne,...B,{begin:/:/,end:/\{/,keywords:H,contains:[{scope:"title.class.inherited",match:S},...B],relevance:0}]};for(const Ee of re.variants){const Ye=Ee.contains.find(vt=>vt.label==="interpol");Ye.keywords=H;const ut=[...B,...Q,...ee,U,re,...Oe];Ye.contains=[...ut,{begin:/\(/,end:/\)/,contains:["self",...ut]}]}return{name:"Swift",keywords:H,contains:[...O,He,ht,fe,Pe,ye,jt,St,{beginKeywords:"import",end:/$/,contains:[...O],relevance:0},pe,...B,...Q,...ee,U,re,...Oe,...be,oe,ae]}}return f0=_,f0}var m0,eS;function IF(){if(eS)return m0;eS=1;function e(t){const n="true false yes no null",s="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},a={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},o={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,a]},c=t.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),m={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},g={end:",",endsWithParent:!0,excludeEnd:!0,keywords:n,relevance:0},v={begin:/\{/,end:/\}/,contains:[g],illegal:"\\n",relevance:0},b={begin:"\\[",end:"\\]",contains:[g],illegal:"\\n",relevance:0},x=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+s},{className:"type",begin:"!<"+s+">"},{className:"type",begin:"!"+s},{className:"type",begin:"!!"+s},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},m,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},v,b,o,l],y=[...x];return y.pop(),y.push(c),g.contains=y,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:x}}return m0=e,m0}var p0,tS;function EF(){if(tS)return p0;tS=1;const e="[A-Za-z$_][0-9A-Za-z$_]*",t=["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"],n=["true","false","null","undefined","NaN","Infinity"],s=["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"],r=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],a=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],o=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],l=[].concat(a,s,r);function c(u){const h=u.regex,p=(q,{after:te})=>{const se="</"+q[0].slice(1);return q.input.indexOf(se,te)!==-1},m=e,g={begin:"<>",end:"</>"},v=/<[A-Za-z0-9\\._:-]+\s*\/>/,b={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(q,te)=>{const se=q[0].length+q.index,he=q.input[se];if(he==="<"||he===","){te.ignoreMatch();return}he===">"&&(p(q,{after:se})||te.ignoreMatch());let X;const re=q.input.substring(se);if(X=re.match(/^\s*=/)){te.ignoreMatch();return}if((X=re.match(/^\s+extends\s+/))&&X.index===0){te.ignoreMatch();return}}},x={$pattern:e,keyword:t,literal:n,built_in:l,"variable.language":o},y="[0-9](_?[0-9])*",C=`\\.(${y})`,S="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",I={className:"number",variants:[{begin:`(\\b(${S})((${C})|\\.)?|(${C}))[eE][+-]?(${y})\\b`},{begin:`\\b(${S})\\b((${C})\\b|\\.)?|(${C})\\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},w={className:"subst",begin:"\\$\\{",end:"\\}",keywords:x,contains:[]},_={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[u.BACKSLASH_ESCAPE,w],subLanguage:"xml"}},k={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[u.BACKSLASH_ESCAPE,w],subLanguage:"css"}},N={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[u.BACKSLASH_ESCAPE,w],subLanguage:"graphql"}},L={className:"string",begin:"`",end:"`",contains:[u.BACKSLASH_ESCAPE,w]},T={className:"comment",variants:[u.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:m+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),u.C_BLOCK_COMMENT_MODE,u.C_LINE_COMMENT_MODE]},R=[u.APOS_STRING_MODE,u.QUOTE_STRING_MODE,_,k,N,L,{match:/\$\d+/},I];w.contains=R.concat({begin:/\{/,end:/\}/,keywords:x,contains:["self"].concat(R)});const A=[].concat(T,w.contains),E=A.concat([{begin:/(\s*)\(/,end:/\)/,keywords:x,contains:["self"].concat(A)}]),$={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:x,contains:E},H={variants:[{match:[/class/,/\s+/,m,/\s+/,/extends/,/\s+/,h.concat(m,"(",h.concat(/\./,m),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,m],scope:{1:"keyword",3:"title.class"}}]},B={relevance:0,match:h.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:{_:[...s,...r]}},G={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,m,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[$],illegal:/%/},Q={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function W(q){return h.concat("(?!",q.join("|"),")")}const D={match:h.concat(/\b/,W([...a,"super","import","await"].map(q=>`${q}\\s*\\(`)),m,h.lookahead(/\s*\(/)),className:"title.function",relevance:0},ee={begin:h.concat(/\./,h.lookahead(h.concat(m,/(?![0-9A-Za-z$_(])/))),end:m,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},F={match:[/get|set/,/\s+/,m,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},$]},M="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+u.UNDERSCORE_IDENT_RE+")\\s*=>",U={match:[/const|var|let/,/\s+/,m,/\s*/,/=\s*/,/(async\s*)?/,h.lookahead(M)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[$]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:x,exports:{PARAMS_CONTAINS:E,CLASS_REFERENCE:B},illegal:/#(?![$_A-Za-z])/,contains:[u.SHEBANG({label:"shebang",binary:"node",relevance:5}),G,u.APOS_STRING_MODE,u.QUOTE_STRING_MODE,_,k,N,L,T,{match:/\$\d+/},I,B,{scope:"attr",match:m+h.lookahead(":"),relevance:0},U,{begin:"("+u.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,u.REGEXP_MODE,{className:"function",begin:M,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:u.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:x,contains:E}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:g.begin,end:g.end},{match:v},{begin:b.begin,"on:begin":b.isTrulyOpeningTag,end:b.end}],subLanguage:"xml",contains:[{begin:b.begin,end:b.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+u.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[$,u.inherit(u.TITLE_MODE,{begin:m,className:"title.function"})]},{match:/\.\.\./,relevance:0},ee,{match:"\\$"+m,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[$]},D,Q,H,F,{match:/\$[(.]/}]}}function d(u){const h=u.regex,p=c(u),m=e,g=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],v={begin:[/namespace/,/\s+/,u.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},b={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:g},contains:[p.exports.CLASS_REFERENCE]},x={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},y=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],C={$pattern:e,keyword:t.concat(y),literal:n,built_in:l.concat(g),"variable.language":o},S={className:"meta",begin:"@"+m},I=(N,L,O)=>{const T=N.contains.findIndex(R=>R.label===L);if(T===-1)throw new Error("can not find mode to replace");N.contains.splice(T,1,O)};Object.assign(p.keywords,C),p.exports.PARAMS_CONTAINS.push(S);const w=p.contains.find(N=>N.scope==="attr"),_=Object.assign({},w,{match:h.concat(m,h.lookahead(/\s*\?:/))});p.exports.PARAMS_CONTAINS.push([p.exports.CLASS_REFERENCE,w,_]),p.contains=p.contains.concat([S,v,b,_]),I(p,"shebang",u.SHEBANG()),I(p,"use_strict",x);const k=p.contains.find(N=>N.label==="func.def");return k.relevance=0,Object.assign(p,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),p}return p0=d,p0}var g0,nS;function NF(){if(nS)return g0;nS=1;function e(t){const n=t.regex,s={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},a=/\d{1,2}\/\d{1,2}\/\d{4}/,o=/\d{4}-\d{1,2}-\d{1,2}/,l=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,c=/\d{1,2}(:\d{1,2}){1,2}/,d={className:"literal",variants:[{begin:n.concat(/# */,n.either(o,a),/ *#/)},{begin:n.concat(/# */,c,/ *#/)},{begin:n.concat(/# */,l,/ *#/)},{begin:n.concat(/# */,n.either(o,a),/ +/,n.either(l,c),/ *#/)}]},u={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},h={className:"label",begin:/^\w+:/},p=t.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),m=t.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[s,r,d,u,h,p,m,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[m]}]}}return g0=e,g0}var v0,sS;function jF(){if(sS)return v0;sS=1;function e(t){t.regex;const n=t.COMMENT(/\(;/,/;\)/);n.contains.push("self");const s=t.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],a={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},o={className:"variable",begin:/\$[\w_]+/},l={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},c={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},d={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},u={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[s,n,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},o,l,a,t.QUOTE_STRING_MODE,d,u,c]}}return v0=e,v0}var b0,rS;function TF(){if(rS)return b0;rS=1;var e=GB();return e.registerLanguage("xml",KB()),e.registerLanguage("bash",YB()),e.registerLanguage("c",ZB()),e.registerLanguage("cpp",XB()),e.registerLanguage("csharp",JB()),e.registerLanguage("css",QB()),e.registerLanguage("markdown",eF()),e.registerLanguage("diff",tF()),e.registerLanguage("ruby",nF()),e.registerLanguage("go",sF()),e.registerLanguage("graphql",rF()),e.registerLanguage("ini",iF()),e.registerLanguage("java",aF()),e.registerLanguage("javascript",oF()),e.registerLanguage("json",lF()),e.registerLanguage("kotlin",cF()),e.registerLanguage("less",dF()),e.registerLanguage("lua",uF()),e.registerLanguage("makefile",hF()),e.registerLanguage("perl",fF()),e.registerLanguage("objectivec",mF()),e.registerLanguage("php",pF()),e.registerLanguage("php-template",gF()),e.registerLanguage("plaintext",vF()),e.registerLanguage("python",bF()),e.registerLanguage("python-repl",xF()),e.registerLanguage("r",yF()),e.registerLanguage("rust",wF()),e.registerLanguage("scss",SF()),e.registerLanguage("shell",_F()),e.registerLanguage("sql",kF()),e.registerLanguage("swift",CF()),e.registerLanguage("yaml",IF()),e.registerLanguage("typescript",EF()),e.registerLanguage("vbnet",NF()),e.registerLanguage("wasm",jF()),e.HighlightJS=e,e.default=e,b0=e,b0}var RF=TF();const fc=th(RF),AF=[[L5,{singleTilde:!1}],[mB,{singleDollarTextMath:!0}]],MF=[VB],ya=new Set;function _C(e){return`${e.length}:${e.slice(0,128)}:${e.slice(-128)}`}function kC(e,t){if(!t){ya.delete(e);return}ya.add(e),ya.size>128&&ya.delete(ya.values().next().value)}function CC(e,t=24e3,n=400){const s=e.slice(0,t);let r=0;for(let a=0;a<s.length;a++)if(s[a]===`
|
|
321
|
-
`&&++r>=n)return s.slice(0,a);return s}let x0=null,iS=null;async function LF(){return x0||(iS??=tc(()=>import("./mermaid.core-
|
|
321
|
+
`&&++r>=n)return s.slice(0,a);return s}let x0=null,iS=null;async function LF(){return x0||(iS??=tc(()=>import("./mermaid.core-BMMXqtrB.js").then(e=>e.bp),__vite__mapDeps([0,1])).then(e=>{e.default.initialize({startOnLoad:!1,securityLevel:"strict",theme:"neutral"});const t=async(n,s)=>{const{svg:r}=await e.default.render(`oc-mermaid-${Math.random().toString(36).slice(2,10)}`,s);n.innerHTML=r};return x0=t,t}).catch(()=>null),iS)}function OF({code:e}){const t=f.useRef(null),[n,s]=f.useState(!1),[r,a]=f.useState(!1);return f.useEffect(()=>{const o=t.current;if(!o)return;if(typeof IntersectionObserver>"u"){a(!0);return}const l=new IntersectionObserver(c=>{c[0]?.isIntersecting&&(a(!0),l.disconnect())},{root:o.closest(".oc-messages"),rootMargin:"400px 0px"});return l.observe(o),()=>l.disconnect()},[]),f.useEffect(()=>{if(!r)return;let o=!1;return LF().then(l=>{if(o||!l||!t.current){l||s(!0);return}l(t.current,e).catch(()=>{o||s(!0)})}),()=>{o=!0}},[e,r]),n?i.jsx(Pg,{lang:"mermaid",text:e}):i.jsx("div",{className:"oc-mermaid",ref:t,role:"img","aria-label":"Mermaid 图表",style:r?void 0:{minHeight:160}})}function Pg({lang:e,text:t,children:n}){const[s,r]=f.useState(!1),a=`code:${e}:${_C(t)}`,[o,l]=f.useState(()=>ya.has(a)),c=o?t:CC(t,12e3,120),d=f.useMemo(()=>{const h=fc.getLanguage(e)?e:"";return h?fc.highlight(c,{language:h,ignoreIllegals:!0}).value:void 0},[e,c]),u=()=>{navigator.clipboard?.writeText(t).then(()=>{r(!0),window.setTimeout(()=>r(!1),1600)},()=>{})};return i.jsxs("div",{className:"oc-codeblock",children:[i.jsxs("div",{className:"oc-codeblock-head",children:[i.jsx("span",{className:"oc-codeblock-lang",children:e||"text"}),i.jsx("button",{type:"button",className:"oc-codeblock-copy",onClick:u,children:s?"已复制":"复制"})]}),i.jsx("pre",{children:d!==void 0?i.jsx("code",{className:`hljs language-${e}`,dangerouslySetInnerHTML:{__html:d}}):i.jsx("code",{className:e?`hljs language-${e}`:"hljs",children:c===t?n??t:c})}),c!==t||o?i.jsx("button",{type:"button",className:"btn btn-ghost oc-markdown-expand",onClick:()=>{l(!o),kC(a,!o)},children:o?"收起代码":"展开完整代码"}):null]})}function DF(e){return e?.children?.find(s=>s.tagName==="thead"||s.tagName==="tbody")?.children?.find(s=>s.tagName==="tr")?.children?.filter(s=>s.tagName==="th"||s.tagName==="td").length??0}function $g(e){if(e==null||typeof e=="boolean")return"";if(typeof e=="string"||typeof e=="number")return String(e);if(Array.isArray(e))return e.map($g).join("");if(typeof e=="object"&&"props"in e){const t=e.props;return $g(t?.children)}return""}const PF={pre({children:e}){return i.jsx(i.Fragment,{children:e})},code({className:e,children:t,...n}){const s=$g(t).replace(/\n$/,""),r=/language-([\w-]+)/.exec(e??"");return r?.[1]==="mermaid"?i.jsx(OF,{code:s}):r||e&&s.includes(`
|
|
322
322
|
`)?i.jsx(Pg,{lang:r?.[1]??"",text:s}):s.includes(`
|
|
323
323
|
`)?i.jsx(Pg,{lang:"",text:s}):i.jsx("code",{className:e,...n,children:t})},a({href:e,children:t,...n}){return y3(e)?i.jsx(pi,{href:e,...n,children:t}):i.jsx("span",{...n,children:t})},img({src:e,alt:t}){return H9(e)?i.jsxs(i.Fragment,{children:[i.jsx("img",{src:e,alt:t??"",loading:"lazy",onError:n=>{const s=n.currentTarget;s.hidden=!0,s.nextElementSibling?.removeAttribute("hidden")}}),i.jsx("span",{className:"oc-md-img-fallback",hidden:!0,title:e??void 0,children:t?`[图片加载失败: ${t}]`:"[图片加载失败]"})]}):i.jsx("span",{className:"oc-md-img-fallback",title:e??void 0,children:t?`[图片: ${t}]`:"[图片已屏蔽]"})},table({children:e,node:t}){const n=DF(t)>=4;return i.jsx("div",{className:`oc-md-table-wrap ${n?"is-wide":"is-fill"}`,tabIndex:n?0:void 0,children:i.jsx("table",{children:e})})},input(e){return e.type==="checkbox"?i.jsx("input",{type:"checkbox",checked:!!e.checked,disabled:!0,readOnly:!0}):i.jsx("input",{...e,disabled:!0,readOnly:!0})}};class $F extends f.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){}componentDidUpdate(t){t.text!==this.props.text&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?i.jsx("div",{className:"oc-md",children:i.jsx("pre",{className:"oc-md-fallback",children:this.props.text})}):this.props.children}}const vi=f.memo(function({text:t,stateKey:n}){const s=`markdown:${n??_C(t)}`,[r,a]=f.useState(()=>ya.has(s)),o=r?t:CC(t);try{return i.jsx($F,{text:t,children:i.jsxs("div",{className:"oc-md",children:[i.jsx(l5,{remarkPlugins:AF,rehypePlugins:MF,components:PF,urlTransform:(l,c)=>c==="href"&&w3(l)?l:c5(l),children:o}),o!==t||r?i.jsx("button",{type:"button",className:"btn btn-ghost oc-markdown-expand",onClick:()=>{a(!r),kC(s,!r)},children:r?"收起长消息":"展开完整消息"}):null]})})}catch{return i.jsx("div",{className:"oc-md",children:i.jsx("pre",{className:"oc-md-fallback",children:t})})}}),Bg="allow-scripts",BF=500,FF=40;function IC(e,t,n="Sheet1"){const s=[];let r=[],a="",o=!1,l=!1,c=!1;const d=()=>{r.length<FF?r.push({text:a}):c=!0,a=""},u=()=>{s.length<BF?s.push(r):l=!0,r=[]};for(let h=0;h<e.length;h+=1){const p=e[h];if(o){p==='"'?e[h+1]==='"'?(a+='"',h+=1):o=!1:a+=p;continue}if(p==='"'){o=!0;continue}if(p===t){d();continue}if(p===`
|
|
324
324
|
`||p==="\r"){p==="\r"&&e[h+1]===`
|
|
@@ -431,7 +431,7 @@ ${sz()}
|
|
|
431
431
|
</body>
|
|
432
432
|
</html>`}function iz(){const e=globalThis.location;if(e?.origin&&e.origin!=="null")return e.origin;if(e?.href)try{return new URL(e.href).origin}catch{}return"http://localhost"}function az(e,t){const n=/^[a-z][a-z0-9+.-]*:\/\//i.test(e)?e:new URL(e,iz()).toString();return`${new URL("/docx-preview.html",n).toString()}?url=${encodeURIComponent(n)}&path=${encodeURIComponent(t)}`}function oz(){const e=globalThis.screen;return{availWidth:e?.availWidth,availHeight:e?.availHeight}}function lz(){const e=globalThis;if(typeof e.open!="function")throw new Error("window.open is unavailable");return{open:e.open.bind(e),createObjectURL:e.URL.createObjectURL.bind(e.URL),revokeObjectURL:e.URL.revokeObjectURL.bind(e.URL)}}function cz(e,t=lz(),n=HF(oz()),s){let r;try{let a;if(Ki(e.language)&&e.htmlPreviewUrl?a=e.htmlPreviewUrl:(e.kind==="image"||e.kind==="pdf")&&e.previewUrl?a=e.previewUrl:e.kind==="docx"&&e.previewUrl&&(a=az(e.previewUrl,e.path)),!a){const l=rz(e,s),c=new Blob([l],{type:"text/html;charset=utf-8"});r=t.createObjectURL(c),a=r}const o=t.open(a,"_blank",n);if(!o)return r&&t.revokeObjectURL(r),{ok:!1,error:aS};try{o.opener=null}catch{}return{ok:!0}}catch{return r&&t.revokeObjectURL(r),{ok:!1,error:aS}}}function dz(e){const{document:t,page:n,scale:s,scrollRoot:r,eager:a,onVisible:o}=e,l=f.useRef(null),c=f.useRef(null),[d,u]=f.useState(a),[h,p]=f.useState(!1);return f.useEffect(()=>{const m=l.current;if(!m||!r)return;if(typeof IntersectionObserver>"u"){u(!0),o(n,1);return}const g=new IntersectionObserver(b=>{b.some(x=>x.isIntersecting)&&u(!0)},{root:r,rootMargin:"100% 0px"}),v=new IntersectionObserver(b=>{const x=b.reduce((y,C)=>Math.max(y,C.intersectionRatio),0);o(n,x)},{root:r,threshold:[0,.15,.5,1]});return g.observe(m),v.observe(m),()=>{g.disconnect(),v.disconnect()}},[o,n,r]),f.useEffect(()=>{if(!d)return;const m=c.current;if(!m)return;let g=!1,v;return p(!1),(async()=>{const b=await t.getPage(n);if(g)return;const x=b.getViewport({scale:s}),y=m.getContext("2d");y&&(m.width=Math.floor(x.width),m.height=Math.floor(x.height),v=b.render({canvasContext:y,viewport:x}),await v.promise,g||p(!0))})().catch(b=>{g||b instanceof Error&&b.name}),()=>{g=!0,v?.cancel()}},[t,n,d,s]),i.jsxs("div",{ref:l,className:"oc-pdf-page","data-pdf-page":n,children:[h?null:i.jsx("div",{className:"oc-pdf-page-placeholder"}),i.jsx("canvas",{ref:c,hidden:!h,role:"img","aria-label":`第 ${n} 页`})]})}function uz(e){const{preview:t}=e,n=f.useRef(null),s=f.useRef(new Map),[r,a]=f.useState(null),[o,l]=f.useState(null),[c,d]=f.useState(t.previewUrl?"loading":"failed"),[u,h]=f.useState(0),[p,m]=f.useState(1),[g,v]=f.useState(1.15),b=f.useCallback((x,y)=>{s.current.set(x,y);let C=1,S=-1;for(const[I,w]of s.current)w>S&&(C=I,S=w);S>0&&m(C)},[]);return f.useEffect(()=>{if(!t.previewUrl)return;let x=!1;const y=new AbortController;return s.current.clear(),d("loading"),l(null),h(0),m(1),(async()=>{const C=await tc(()=>import("./pdf-gh-BrLFn.js"),[]),S=await tc(()=>import("./pdf.worker.min-ocdtAcA3.js"),[]);C.GlobalWorkerOptions.workerSrc=S.default;const I=await fetch(t.previewUrl,{credentials:"include",signal:y.signal});if(!I.ok)throw new Error("pdf fetch failed");const w=new Uint8Array(await I.arrayBuffer()),_=await C.getDocument({data:w}).promise;if(x){await _.destroy();return}const k=_;n.current=k,l(k),h(_.numPages),d("ready")})().catch(()=>{x||d("failed")}),()=>{x=!0,y.abort();const C=n.current;n.current=null,C?.destroy()}},[t.previewUrl]),!t.previewUrl||c==="failed"?i.jsx("p",{className:"oc-file-preview-image-error",role:"alert",children:"PDF 加载失败,请确认文件完好后重试。"}):i.jsxs("div",{className:"oc-file-preview-pdf","data-pdf-preview":c,children:[i.jsxs("div",{className:"oc-pdf-toolbar",children:[i.jsx("span",{children:c==="ready"?`${p} / ${u}`:"正在加载 PDF…"}),i.jsx("button",{type:"button",disabled:c!=="ready",onClick:()=>v(x=>Math.max(.6,Number((x-.2).toFixed(2)))),children:"缩小"}),i.jsx("button",{type:"button",disabled:c!=="ready",onClick:()=>v(x=>Math.min(2.5,Number((x+.2).toFixed(2)))),children:"放大"})]}),i.jsx("div",{className:"oc-pdf-pages",ref:a,children:o&&c==="ready"?Array.from({length:u},(x,y)=>i.jsx(dz,{document:o,page:y+1,scale:g,scrollRoot:r,eager:y===0,onVisible:b},y+1)):null})]})}function hz(e){const t=["ELEMENT",e.opening,"","PATH",e.path];e.attributes.length&&t.push("","ATTRIBUTES",...e.attributes.map(([a,o])=>`${a}: ${o}`)),e.styles.length&&t.push("","COMPUTED STYLES",...e.styles.map(([a,o])=>`${a}: ${o}`));const n=a=>`${Math.round(a)}px`;t.push("","POSITION & SIZE",`top: ${n(e.rect.y)}`,`left: ${n(e.rect.x)}`,`width: ${n(e.rect.width)}`,`height: ${n(e.rect.height)}`,"","INNER TEXT",e.truncated?`${e.quote}(已截断)`:e.quote);const s=t.join(`
|
|
433
433
|
`);if(s.length<=ai.quote)return{quote:s,clipped:!1};const r=`
|
|
434
|
-
…(已截断)`;return{quote:`${s.slice(0,ai.quote-r.length)}${r}`,clipped:!0}}const fz="loop-agent-html-preview-selection",dS=/^rendered:(\d+):(\d+)$/,mz=/^[a-z][a-z0-9-]{0,63}$/,pz=/^[a-z][a-z0-9:-]{0,63}$/,gz=new Set(["color","backgroundColor","fontSize","display","position"]);function TC(e){return typeof e=="number"&&Number.isFinite(e)}function uS(e,t,n,s){if(!Array.isArray(e)||e.length>t)return null;const r=[];for(const a of e){if(!Array.isArray(a)||a.length!==2)return null;const[o,l]=a;if(typeof o!="string"||typeof l!="string"||!n(o)||l.length===0||l.length>s)return null;r.push([o,l])}return r}function vz(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.tag!="string"||!mz.test(t.tag)||typeof t.opening!="string"||t.opening.length===0||t.opening.length>300||!t.opening.startsWith("<")||typeof t.path!="string"||t.path.length===0||t.path.length>1024||typeof t.truncated!="boolean")return null;const n=uS(t.attributes,12,r=>pz.test(r),200),s=uS(t.styles,5,r=>gz.has(r),80);return!n||!s||![t.x,t.y,t.width,t.height].every(TC)||t.width<0||t.height<0?null:{tag:t.tag,opening:t.opening,path:t.path,attributes:n,styles:s,x:t.x,y:t.y,width:t.width,height:t.height,truncated:t.truncated}}function bz(e){if(!e||typeof e!="object")return null;const t=e;if(t.type!==fz)return null;if(t.text==="")return{text:"",anchor:"",x:0,y:0,width:0,height:0};if(typeof t.text!="string"||!t.text.trim()||t.text.length>4e3||typeof t.anchor!="string"||!dS.test(t.anchor))return null;const n=dS.exec(t.anchor),s=Number(n?.[1]),r=Number(n?.[2]);if(!Number.isSafeInteger(s)||!Number.isSafeInteger(r)||r<s||r-s!==t.text.length||![t.x,t.y,t.width,t.height].every(o=>TC(o)))return null;if(t.element!=null){const o=vz(t.element);return o?{text:t.text,anchor:t.anchor,x:t.x,y:t.y,width:t.width,height:t.height,element:o}:null}return{text:t.text,anchor:t.anchor,x:t.x,y:t.y,width:t.width,height:t.height}}function xz(e){return e.element?hz({opening:e.element.opening,path:e.element.path,attributes:e.element.attributes,styles:e.element.styles,rect:{x:e.element.x,y:e.element.y,width:e.element.width,height:e.element.height},quote:e.text,truncated:e.element.truncated}).quote:e.text}function yz(e){const t=f.useRef(null),n=f.useRef(null),s=f.useRef(!1),r=f.useRef(!1),a=f.useRef(e);a.current=e;const[o,l]=f.useState(null),[c,d]=f.useState(!1),[u,h]=f.useState(""),[p,m]=f.useState(0);r.current=c;const g=()=>{s.current=!1,l(null),d(!1)};f.useEffect(()=>{g(),h("")},[e.src,e.sha256,e.referenceOwner?.sessionId,e.referenceOwner?.workspaceId,e.referenceOwner?.generation]),f.useEffect(()=>{const y=C=>{if(C.origin!=="null"||C.source!==n.current?.contentWindow)return;const S=bz(C.data);if(!S)return;if(!S.text){!r.current&&!s.current&&l(null);return}const I=a.current;if(!(r.current||!I.referenceOwner||!I.onReference)){if(!I.workspaceId){h("当前没有工作区,无法引用这段内容"),l(null);return}if(!I.sha256){h("页面还在加载,请稍后再引用"),l(null);return}try{const w=or([{id:crypto.randomUUID(),capturedAt:new Date().toISOString(),quote:xz(S),comment:"",source:{kind:"file",workspaceId:I.workspaceId,path:I.path,version:`sha256:${I.sha256}`,versionScope:I.truncated?"prefix":"file",view:"html",anchor:S.anchor}}])[0];if(!w)return;l(_=>{const k=_&&_.payload.text===S.text&&_.payload.anchor===S.anchor&&_.payload.element?.path===S.element?.path;return{payload:S,reference:k?{..._.reference,quote:w.quote}:w}}),h("")}catch(w){l(null),h(w instanceof Error?w.message:"引用无效")}}};return window.addEventListener("message",y),()=>window.removeEventListener("message",y)},[]),f.useEffect(()=>{if(!o)return;const y=()=>m(C=>C+1);return window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[o]);const v=wz(t.current),b=Sz(o?.payload,n.current,v),x=o&&b&&v?Xs.createPortal(c?i.jsx(Mc,{label:"确认选文引用",placement:"anchored",style:f6(b),tag:o.payload.element?.tag??bh(o.reference.source),quote:Fv(o.reference.quote),commentLabel:"选文评论",placeholder:"例如:把这段标题改短",extra:o.payload.element?i.jsxs("p",{className:"oc-cite-note",children:[o.payload.element.opening," · ",o.payload.element.path]}):void 0,onCancel:g,onConfirm:y=>{if(!e.referenceOwner||!e.onReference)return!1;try{const C=or([{...o.reference,comment:y}])[0];return!C||!e.onReference(C,{...e.referenceOwner})?!1:(g(),!0)}catch{return!1}}},o.reference.id):i.jsx("button",{type:"button",className:"oc-cite-chip",style:m6(b),onMouseDown:y=>{s.current=!0,y.preventDefault(),y.stopPropagation()},onMouseUp:y=>y.stopPropagation(),onClick:()=>d(!0),children:"引用"}),v):null;return i.jsxs("div",{ref:t,className:"oc-file-preview-html-frame",children:[i.jsx("iframe",{ref:n,className:e.className,sandbox:e.sandbox,title:e.title,referrerPolicy:e.referrerPolicy,src:e.src}),x,u?i.jsx("p",{className:"oc-cite-error oc-file-preview-html-cite-error",role:"alert",children:u}):null]})}function wz(e){if(typeof HTMLElement>"u"||!e)return null;const t=e.closest(".oc-cite-scope");return t instanceof HTMLElement?t:e}function Sz(e,t,n){if(!e?.text||!t||!n)return null;const s=n.getBoundingClientRect(),r=t.getBoundingClientRect(),a=r.top-s.top+e.y,o=r.left-s.left+e.x;return{top:a,bottom:a+e.height,left:o,endX:o+e.width,endBottom:a+e.height,width:s.width,height:s.height}}function _z(e){if(!(!e.background&&!e.color&&!e.bold&&!e.italic&&!e.align))return{backgroundColor:e.background,color:e.color,fontWeight:e.bold?700:e.background||e.color?400:void 0,fontStyle:e.italic?"italic":void 0,textAlign:e.align}}function RC(e){return e==="xls"||e==="xlsx"}function hS(e){const t=e.language.trim().toLowerCase();return RC(t)?null:[IC(e.content,t==="tsv"?" ":",")]}function kz(e){const{preview:t}=e,n=t.language.trim().toLowerCase(),s=RC(n),[r,a]=f.useState(()=>hS(t)),[o,l]=f.useState(0),[c,d]=f.useState(null);if(f.useEffect(()=>{let p=!1;if(d(null),l(0),!s){const g=hS(t);a(g),e.onTables?.(g);return}if(!t.previewUrl){d("表格预览地址不可用(缺少有效工作区)。"),a(null),e.onTables?.(null);return}e.onTables?.(null),a(null);const m=new AbortController;return(async()=>{const g=await fetch(t.previewUrl,{credentials:"include",signal:m.signal});if(!g.ok)throw new Error("sheet fetch failed");const v=new Uint8Array(await g.arrayBuffer()),b=await oP(v),x=n==="xlsx"?await tc(()=>import("./sheet-workbook-kZ_HK4Sg.js"),__vite__mapDeps([2,1])).then(y=>y.readStyledXlsx(v)):await tc(()=>import("./sheet-workbook-kZ_HK4Sg.js"),__vite__mapDeps([2,1])).then(y=>y.readStyledXls(v));if(!p){const y=x.length>0?x:[];a(y),e.onDigest?.(b),e.onTables?.(y)}})().catch(()=>{p||(d("表格无法预览,请确认文件完好。"),e.onTables?.(null))}),()=>{p=!0,m.abort()}},[s,n,t.content,t.previewUrl]),c)return i.jsx("p",{className:"oc-file-preview-image-error",role:"alert",children:c});if(!r)return i.jsx("p",{className:"oc-file-preview-sheet-status",role:"status",children:"正在加载表格…"});const u=r[o]??r[0];if(!u||u.rows.length===0)return i.jsx("p",{className:"oc-file-preview-sheet-status",role:"status",children:"表格是空的。"});const h=u.rows.reduce((p,m)=>Math.max(p,m.length),0);return i.jsxs("div",{className:"oc-file-preview-sheet","data-sheet-preview":!0,"data-sheet-name":u.name,children:[r.length>1?i.jsx("div",{className:"oc-sheet-tabs",role:"tablist","aria-label":"工作表",children:r.map((p,m)=>i.jsx("button",{type:"button",role:"tab","aria-selected":m===o,className:m===o?"is-active":"",onClick:()=>l(m),children:p.name},p.name))}):null,u.truncatedRows||u.truncatedCols?i.jsxs("p",{className:"oc-file-preview-truncated",role:"status",children:["表格较大,仅显示前 ",u.rows.length," 行、每行最多 ",h," 列。"]}):null,i.jsx("div",{className:"oc-sheet-scroll",children:i.jsx("table",{className:"oc-sheet-table",children:i.jsx("tbody",{children:u.rows.map((p,m)=>i.jsx("tr",{children:Array.from({length:h},(g,v)=>{const b=p[v]??{text:""};if(b.hidden)return null;const x=m===0?"th":"td";return i.jsx(x,{"data-sheet-row":m,"data-sheet-col":v,colSpan:b.colSpan,rowSpan:b.rowSpan,style:_z(b),children:b.text},v)})},m))})})})]})}const Cz={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",sh:"bash",bash:"bash",zsh:"bash",py:"python",pyw:"python",pyi:"python",json:"json",jsonc:"json",jsonl:"json",ndjson:"json",yml:"yaml",yaml:"yaml",md:"markdown",markdown:"markdown",html:"xml",htm:"xml",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",go:"go",rs:"rust",java:"java",c:"c",h:"c",cc:"cpp",cpp:"cpp",cxx:"cpp",hh:"cpp",hpp:"cpp",hxx:"cpp",cs:"csharp",php:"php",rb:"ruby",kt:"kotlin",kts:"kotlin",swift:"swift",lua:"lua",sql:"sql",diff:"diff",patch:"diff",ini:"ini",conf:"ini",cfg:"ini",toml:"ini",properties:"ini",r:"r",pl:"perl",pm:"perl",mk:"makefile",makefile:"makefile",graphql:"graphql",gql:"graphql"};function fS(e){const t=(e??"").trim().toLowerCase(),n=Cz[t];if(!(!n||!fc.getLanguage(n)))return n}function Iz(e,t){if(!(!t||!fc.getLanguage(t)))return fc.highlight(e,{language:t,ignoreIllegals:!0}).value}const Ez=["repo","session","bench"],Fg={repo:{id:"repo",label:"仓库",description:"当前仓库的文件与 Git",pages:["files","scm"]},session:{id:"session",label:"会话",description:"这次对话的注入与检查",pages:["context","insights","calls","activity","trajectory","goal","tasks","subagents","workflows","dag"]},bench:{id:"bench",label:"工作台",description:"终端、预览、数据库、接口调试",pages:["terminals","ssh","browser","databases","api","regex","json"]}},Nz={files:"repo",scm:"repo",context:"session",insights:"session",calls:"session",activity:"session",trajectory:"session",goal:"session",tasks:"session",subagents:"session",workflows:"session",dag:"session",terminals:"bench",ssh:"bench",browser:"bench",databases:"bench",api:"bench",regex:"bench",json:"bench"};function mS(e){return Nz[e]}function ob(e,t){const n=new Set(Fg[e].pages);return t.filter(s=>n.has(s))}function jz(e){return Ez.filter(t=>ob(t,e).length>0)}function Tz(e,t,n){const s=ob(e,t);return s.length===0?null:n&&s.includes(n)?n:s[0]??null}function Rz(e,t,n){if(t.length<2)return null;const s=t.indexOf(e);return s<0?t[0]??null:t[(s+n+t.length)%t.length]??null}function Az(e,t,n){if(t.length<2)return null;const s=t.indexOf(e);return s<0?t[0]??null:t[(s+n+t.length)%t.length]??null}function Mz(e){switch(e){case"activity":case"goal":return e;default:return null}}function fd(e){const t=e.nodes.length,n=e.nodes.filter(s=>["succeeded","completed","passed"].includes(s.status)).length;return{completed:n,total:t,pct:t?Math.round(n/t*100):0}}function Lz(e){return e==="terminals"?i.jsx(Zi,{size:16,"aria-hidden":"true"}):e==="ssh"?i.jsx(Vp,{size:16,"aria-hidden":"true"}):e==="browser"?i.jsx(Xk,{size:16,"aria-hidden":"true"}):e==="databases"?i.jsx(Eo,{size:16,"aria-hidden":"true"}):e==="api"?i.jsx(ov,{size:16,"aria-hidden":"true"}):e==="regex"?i.jsx(av,{size:16,"aria-hidden":"true"}):e==="json"?i.jsx(Uk,{size:16,"aria-hidden":"true"}):null}function Oz(){if(typeof navigator>"u")return"在文件管理器中打开工作目录";const e=navigator.platform??"";return/mac/i.test(e)?"在访达中打开工作目录":/win/i.test(e)?"在资源管理器中打开工作目录":"在文件管理器中打开工作目录"}function pS(e){const[t,n]=f.useState("files"),[s,r]=f.useState("idle"),[a,o]=f.useState(null),l=e.activeTab??t,c=!!e.dagRunId,d=[{id:"files",label:"文件"},...e.scmContent?[{id:"scm",label:"Git"}]:[],...e.contextContent?[{id:"context",label:"上下文"}]:[],...e.insightsContent?[{id:"insights",label:"洞察"}]:[],...e.callsContent?[{id:"calls",label:"调用记录"}]:[],...e.activityContent?[{id:"activity",label:"运行活动"}]:[],...e.trajectoryContent?[{id:"trajectory",label:"轨迹"}]:[],...e.goalContent?[{id:"goal",label:"目标"}]:[],...e.tasksContent||e.subagentsContent?[{id:"tasks",label:"任务管理"}]:[],...e.workflowsContent?[{id:"workflows",label:"工作流"}]:[],...e.terminalsContent?[{id:"terminals",label:"终端"}]:[],...e.sshContent?[{id:"ssh",label:"SSH"}]:[],...e.browserContent?[{id:"browser",label:"浏览器"}]:[],...e.databaseContent?[{id:"databases",label:"数据库"}]:[],...e.apiContent?[{id:"api",label:"接口"}]:[],...e.regexContent?[{id:"regex",label:"正则"}]:[],...e.jsonContent?[{id:"json",label:"JSON"}]:[],...c?[{id:"dag",label:"DAG"}]:[]],u=d.some(se=>se.id===l)?l:"files",h=d.map(se=>se.id),p=mS(u),m=Fg[p],g=ob(p,h),v=jz(h),b=d.filter(se=>g.includes(se.id)),[x,y]=f.useState({}),C=f.useRef(null),S=f.useRef(null),I=f.useRef(null),w=f.useRef(null),_=f.useRef(null),k=f.useRef(null),N=f.useRef(null),L=f.useRef(null),O=f.useRef(null),T=f.useRef(null),R=f.useRef(null),A=f.useRef(null),E=f.useRef(null),$=f.useRef(null),H=f.useRef(null),B=f.useRef(null),G=f.useRef(null),z=f.useRef(null),Q=f.useRef(null),W=f.useRef(e.open),D=se=>{n(se),y(he=>({...he,[mS(se)]:se})),e.onSelectTab?.(se)},ee=se=>{const he=Tz(se,h,x[se]);he&&D(he)},F=se=>{switch(se){case"context":return S;case"insights":return I;case"calls":return w;case"activity":return _;case"trajectory":return k;case"goal":return N;case"tasks":case"subagents":return L;case"workflows":return O;case"terminals":return T;case"scm":return R;case"browser":return A;case"databases":return E;case"api":return $;case"regex":return H;case"json":return B;case"ssh":return G;case"dag":return z;default:return C}};f.useEffect(()=>{u!==l&&D(u)},[l,u]),f.useEffect(()=>{const se=W.current;W.current=e.open,!se&&e.open&&Q.current?.focus()},[e.open]);const M=se=>{if(g.length<2)return;let he=null;se.key==="ArrowLeft"||se.key==="ArrowRight"?he=Az(u,g,se.key==="ArrowRight"?1:-1):se.key==="Home"?he=g[0]??null:se.key==="End"&&(he=g[g.length-1]??null),he&&(se.preventDefault(),D(he),F(he).current?.focus())},U=se=>{let he=null;se.key==="ArrowLeft"||se.key==="ArrowRight"?he=Rz(p,v,se.key==="ArrowRight"?1:-1):se.key==="Home"?he=v[0]??null:se.key==="End"&&(he=v[v.length-1]??null),he&&(se.preventDefault(),ee(he))},q=Oz(),te=()=>{const se=e.workspaceId?.trim(),he=e.origin?.replace(/\/$/,"")??"";!se||s==="opening"||(r("opening"),o(null),fetch(`${he}/api/operator/v1/chat/repo/open-directory?workspaceId=${encodeURIComponent(se)}`,{method:"POST",credentials:"include",headers:{"x-loop-console-confirmation":Rt()}}).then(async X=>{const re=await X.json().catch(()=>({}));if(!X.ok)throw new Error(re.error?.message??"无法打开工作目录");r("idle")}).catch(X=>{r("failed"),o(X instanceof Error?X.message:"无法打开工作目录")}))};return e.open?i.jsxs("aside",{className:"oc-details-rail","aria-label":"辅助栏","data-surface":p,children:[i.jsxs("header",{className:"oc-details-rail-head",children:[i.jsxs("div",{className:"oc-details-surface-id",children:[i.jsx("h2",{className:"oc-details-surface-title",children:m.label}),i.jsx("p",{className:"oc-details-surface-desc",children:m.description})]}),v.length>1?i.jsx("div",{className:"oc-details-surface-switch",role:"tablist","aria-label":"辅助栏表面",children:v.map(se=>i.jsx("button",{type:"button",role:"tab","aria-selected":p===se,tabIndex:p===se?0:-1,className:`oc-details-surface-switch-btn${p===se?" is-active":""}`,onClick:()=>ee(se),onKeyDown:U,children:Fg[se].label},se))}):null,i.jsx("button",{type:"button",className:"oc-details-rail-toggle",ref:Q,onClick:e.onToggleOpen,"aria-label":"关闭辅助栏","aria-expanded":e.open,"aria-controls":"oc-details-rail-body",title:"关闭辅助栏",children:i.jsx(FD,{})})]}),p!=="bench"?i.jsxs("div",{className:p==="repo"?"oc-details-repo-bar":"oc-details-tabbar",children:[i.jsx("div",{className:"oc-details-tabs",role:"tablist","aria-label":`${m.label}页面`,children:b.map(se=>{const he=Mz(se.id);return i.jsxs("div",{className:`oc-details-tab${u===se.id?" is-active":""}`,role:"presentation",children:[i.jsx("button",{type:"button",id:`oc-details-tab-${se.id}`,ref:F(se.id),role:"tab","aria-selected":u===se.id,"aria-controls":"oc-details-rail-body",tabIndex:u===se.id?0:-1,className:"oc-details-tab-select",onClick:()=>D(se.id),onKeyDown:M,children:se.label}),he&&e.onCloseTab?i.jsx("button",{type:"button",className:"oc-details-tab-close","aria-label":`关闭${se.label}标签页`,title:`关闭${se.label}`,onClick:()=>e.onCloseTab?.(he),children:i.jsx(Wn,{size:13,"aria-hidden":"true"})}):null]},se.id)})}),p==="repo"?i.jsx("button",{type:"button",className:"oc-details-open-directory","data-state":s,"aria-label":q,title:a??q,disabled:s==="opening"||!e.workspaceId?.trim(),onClick:te,children:i.jsx(Zk,{size:16,"aria-hidden":"true"})}):null]}):i.jsx("div",{className:"oc-details-bench-rail",role:"tablist","aria-label":"工作台工具",children:b.map(se=>i.jsx("button",{type:"button",id:`oc-details-tab-${se.id}`,ref:F(se.id),role:"tab","aria-selected":u===se.id,"aria-controls":"oc-details-rail-body","aria-label":se.label,title:se.label,tabIndex:u===se.id?0:-1,className:`oc-details-bench-btn${u===se.id?" is-active":""}`,onClick:()=>D(se.id),onKeyDown:M,children:Lz(se.id)},se.id))}),e.open?i.jsx("div",{id:"oc-details-rail-body",className:"oc-details-rail-body",role:"tabpanel","aria-labelledby":`oc-details-tab-${u}`,"data-tab":u,children:u==="dag"&&e.dagRunId?i.jsxs("section",{className:"oc-details-dag","aria-label":"当前 DAG",children:[i.jsxs("header",{children:[i.jsx("strong",{children:"当前 DAG"}),i.jsx("code",{children:e.dagRunId})]}),e.dagRun?i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"oc-details-dag-point",children:["运行点:",i.jsx("code",{children:e.dagRun.currentNodeId??"—"}),e.dagRun.status?i.jsxs("span",{children:["(",e.dagRun.status,")"]}):null]}),i.jsx("ul",{className:"oc-details-dag-nodes","aria-label":"DAG 节点",children:e.dagRun.nodes.map(se=>i.jsxs("li",{"data-status":se.status,children:[i.jsx("span",{className:"oc-details-dag-node-id",children:se.id}),i.jsx("span",{className:"oc-details-dag-node-status",children:se.status})]},se.id))}),i.jsxs("p",{className:"oc-details-dag-progress",children:["完成 ",fd(e.dagRun).completed,"/",fd(e.dagRun).total]}),i.jsx("div",{className:"oc-details-dag-progressbar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":fd(e.dagRun).pct,"aria-label":"DAG 完成进度",children:i.jsx("div",{className:"oc-details-dag-progressfill",style:{width:`${fd(e.dagRun).pct}%`}})})]}):i.jsx("p",{className:"oc-details-dag-empty-reason",children:"当前运行暂无安全汇总数据,等待运行数据同步。"})]}):u==="context"?e.contextContent:u==="insights"?e.insightsContent:u==="calls"?e.callsContent:u==="activity"?e.activityContent:u==="trajectory"?e.trajectoryContent:u==="goal"?e.goalContent:u==="tasks"||u==="subagents"?e.tasksContent??e.subagentsContent:u==="workflows"?e.workflowsContent:u==="terminals"?e.terminalsContent:u==="scm"?e.scmContent:u==="ssh"?e.sshContent:u==="browser"?e.browserContent:u==="databases"?e.databaseContent:u==="api"?e.apiContent:u==="regex"?e.regexContent:u==="json"?e.jsonContent:e.children},u):null]}):i.jsx("aside",{className:"oc-details-rail is-collapsed","aria-label":"辅助栏","aria-hidden":"true",inert:!0})}function Dz(e){return e.kind==="image"||e.kind==="pdf"||e.kind==="sheet"||e.kind==="docx"?!0:Ki(e.language)||Mh(e.language)}function Pz(e){return e.kind==="image"&&e.language!=="svg"}function $z(e){return Pz(e)||e.kind==="pdf"||e.kind==="docx"||e.kind==="sheet"&&ab(e.language)}function Bz(e){return e&&(Ki(e)||Mh(e)||VF(e)||qF(e)||WF(e)||UF(e))?"preview":"source"}function md(e,t){return t.type==="mode"?t.mode:t.path?Bz(t.language):"source"}function Fz(e){const{preview:t}=e,[n,s]=f.useState("loading");return t.previewUrl?i.jsxs("div",{className:"oc-file-preview-image","data-image-preview":n,"data-image-media-type":t.mediaType,children:[n==="failed"?i.jsx("p",{className:"oc-file-preview-image-status",role:"alert",children:"图片加载失败,请确认文件完好后重试。"}):null,i.jsx("img",{className:"oc-file-preview-image-img",src:t.previewUrl,alt:`图片预览 ${t.path}`,decoding:"async",draggable:!1,referrerPolicy:"no-referrer",hidden:n!=="ready",onLoad:()=>s("ready"),onError:()=>s("failed")})]}):i.jsx("p",{className:"oc-file-preview-image-error",role:"alert",children:"图片预览地址不可用(缺少有效工作区)。"})}function zz(e,t){const n=e.kind;return n===void 0||n==="text"||n==="sheet"||n==="docx"?!(t==="preview"&&Ki(e.language)):!1}function Hz(e){return e.kind==="docx"&&!!e.sha256}function qz(e,t,n){return n||!zz(e,t)?!0:e.kind==="docx"&&!Hz(e)}function Uz(e){const t=e.previews.find(v=>v.path===e.activePath),n=t?Dz(t):!1,s=t?$z(t):!1,r=n&&!s,[a,o]=f.useState(()=>md("source",{type:"file",path:t?.path??null,language:t?.language})),[l,c]=f.useState(null),d=f.useRef(null),u=f.useRef(null),h=f.useRef(null),p=t?.kind==="sheet"&&a==="preview"&&n,m=v=>{const b=v.startElement.closest("[data-sheet-preview]")??v.endElement.closest("[data-sheet-preview]")??v.startElement.querySelector("[data-sheet-preview]"),x=b?.getAttribute("data-sheet-name"),y=u.current?.find(I=>I.name===x),C=b?uP(dP(b,v.range)):null;if(!y||!C)throw new Error("请在表格单元格内拖选,再点「引用」");const S=hP(y,C);if("error"in S)throw new Error(S.error);return{...S,sheet:y.name}},g=t?.kind==="unsupported"?"不支持的文件":t?.kind==="image"?"图片":t?.kind==="docx"?"Word":Ki(t?.language??"")?"HTML":Mh(t?.language??"")?"Markdown":"文本";return f.useEffect(()=>{o(v=>t?.focusLine?"source":md(v,{type:"file",path:t?.path??null,language:t?.language})),c(null),u.current=null,h.current=null},[t?.path,t?.focusLine,n]),f.useEffect(()=>{d.current?.scrollIntoView({block:"center"})},[t,a]),e.loading||e.error?i.jsxs("section",{className:"oc-file-preview","aria-label":`文件预览 ${e.activePath??""}`,children:[i.jsxs("header",{className:"oc-file-preview-header",children:[i.jsx("strong",{className:"oc-file-preview-path",children:e.activePath}),i.jsx("button",{type:"button","aria-label":"关闭文件预览",onClick:()=>e.activePath&&e.onClose(e.activePath),children:i.jsx(Wn,{size:16})})]}),i.jsx("p",{className:"oc-file-preview-status",role:e.error?"alert":"status",children:e.error??"正在读取文件…"})]}):t?i.jsxs(i.Fragment,{children:[t&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"oc-file-preview-backdrop",onMouseDown:v=>{v.target===v.currentTarget&&e.onClose(t.path)}}),i.jsxs("section",{className:"oc-file-preview","aria-label":`文件预览 ${t.path}`,children:[i.jsxs("header",{className:"oc-file-preview-header",children:[i.jsxs("div",{className:"oc-file-preview-path-group",children:[i.jsx("strong",{className:"oc-file-preview-path",title:t.path,children:t.path}),i.jsxs("span",{className:"oc-file-preview-meta","aria-label":`渲染器 ${g}`,children:[g," · ",t.bytes," bytes",t.truncated?" · 源码已截断":""]})]}),i.jsxs("div",{className:"oc-file-preview-actions",children:[r&&i.jsxs("div",{className:"oc-file-view-modes",role:"group","aria-label":"文件查看模式",children:[i.jsx("button",{type:"button",className:`oc-file-view-mode${a==="preview"?" is-active":""}`,"aria-pressed":a==="preview",onClick:()=>o(v=>md(v,{type:"mode",mode:"preview"})),children:"预览"}),i.jsx("button",{type:"button",className:`oc-file-view-mode${a==="source"?" is-active":""}`,"aria-pressed":a==="source",onClick:()=>o(v=>md(v,{type:"mode",mode:"source"})),children:"源文件"})]}),e.onInsert?i.jsx("button",{type:"button",className:"oc-file-preview-cite",title:"在输入框提及此文件","aria-label":`提及 ${zg(t.path)}`,onClick:()=>e.onInsert?.(t.path),children:"@"}):null,e.onReload?i.jsx("button",{type:"button",className:"oc-file-preview-reload",title:"重新读取文件","aria-label":`重新读取 ${zg(t.path)}`,disabled:e.reloading,onClick:()=>e.onReload?.(t.path),children:i.jsx(mi,{size:14,"aria-hidden":"true"})}):null,i.jsx("button",{type:"button",className:"oc-file-preview-open",title:"新窗口打开","aria-label":`新窗口打开 ${t.path}`,onClick:()=>{const v=cz(t,void 0,void 0,u.current??void 0);c(v.ok?null:v.error)},children:i.jsx(CN,{size:16,"aria-hidden":"true"})})]})]}),e.loading?i.jsx("p",{className:"oc-file-preview-status oc-file-preview-loading",role:"status",children:"正在读取文件…"}):null,l?i.jsx("p",{className:"oc-file-preview-status oc-file-preview-open-error",role:"alert",children:l}):null,t.truncated&&(a==="source"||!Ki(t.language))&&t.kind!=="image"&&t.kind!=="unsupported"?i.jsx("p",{className:"oc-file-preview-status oc-file-preview-truncated",role:"status",children:"文件较大,仅展示前 512 KiB。"}):null,i.jsx(Hv,{className:"oc-file-preview-body",referenceOwner:e.referenceOwner,onReference:e.onReference,disabled:qz(t,a,e.loading),quote:v=>p?m(v)?.quote??null:v.text,source:v=>{if(p){const y=t.sha256??h.current;if(!e.workspaceId)throw new Error("当前没有工作区,无法引用这段表格");if(!y)throw new Error("表格还在加载,请稍后再引用");const C=m(v);return C?{kind:"file",workspaceId:e.workspaceId,path:t.path,version:`sha256:${y}`,versionScope:t.truncated?"prefix":"file",view:"sheet",anchor:v.anchor,cellRange:C.cellRange,...C.sheet?{sheet:C.sheet}:{}}:null}if(!e.workspaceId||!t.sha256)return null;if(t.kind==="docx")return{kind:"file",workspaceId:e.workspaceId,path:t.path,version:`sha256:${t.sha256}`,versionScope:"file",view:"markdown",anchor:v.anchor};const b=Number(v.startElement.closest("[data-line]")?.getAttribute("data-line")),x=Number(v.endElement.closest("[data-line]")?.getAttribute("data-line"));return{kind:"file",workspaceId:e.workspaceId,path:t.path,version:`sha256:${t.sha256}`,versionScope:t.truncated?"prefix":"file",view:a==="source"?"source":"markdown",anchor:v.anchor,...a==="source"&&t.lineMappingReliable&&b>0&&x>=b?{startLine:b,endLine:x}:{}}},children:t.kind==="unsupported"?i.jsxs("div",{className:"oc-file-preview-unsupported",role:"status",children:[i.jsx(Wn,{size:18,"aria-hidden":"true"}),i.jsx("p",{children:"此文件类型无法预览"}),i.jsx("p",{className:"oc-file-preview-unsupported-hint",children:"二进制文件不支持内联预览"})]}):a==="preview"&&n?t.kind==="image"?i.jsx(Fz,{preview:t}):t.kind==="pdf"?i.jsx(uz,{preview:t}):t.kind==="docx"?i.jsx(_8,{preview:t}):t.kind==="sheet"?i.jsx(kz,{preview:t,onTables:v=>{u.current=v,v||(h.current=null)},onDigest:v=>{h.current=v}}):Ki(t.language)?i.jsx(yz,{className:"oc-file-preview-html",sandbox:Bg,title:`HTML 预览 ${t.path}`,referrerPolicy:"no-referrer",src:t.htmlPreviewUrl,workspaceId:e.workspaceId,path:t.path,sha256:t.sha256,truncated:t.truncated,referenceOwner:e.referenceOwner,onReference:e.onReference}):i.jsx("div",{className:"oc-file-preview-rendered",children:i.jsx(vi,{text:t.content})}):i.jsx("pre",{className:"oc-file-preview-source",children:i.jsx("code",{className:fS(t.language)?"hljs":void 0,children:t.content.split(`
|
|
434
|
+
…(已截断)`;return{quote:`${s.slice(0,ai.quote-r.length)}${r}`,clipped:!0}}const fz="loop-agent-html-preview-selection",dS=/^rendered:(\d+):(\d+)$/,mz=/^[a-z][a-z0-9-]{0,63}$/,pz=/^[a-z][a-z0-9:-]{0,63}$/,gz=new Set(["color","backgroundColor","fontSize","display","position"]);function TC(e){return typeof e=="number"&&Number.isFinite(e)}function uS(e,t,n,s){if(!Array.isArray(e)||e.length>t)return null;const r=[];for(const a of e){if(!Array.isArray(a)||a.length!==2)return null;const[o,l]=a;if(typeof o!="string"||typeof l!="string"||!n(o)||l.length===0||l.length>s)return null;r.push([o,l])}return r}function vz(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.tag!="string"||!mz.test(t.tag)||typeof t.opening!="string"||t.opening.length===0||t.opening.length>300||!t.opening.startsWith("<")||typeof t.path!="string"||t.path.length===0||t.path.length>1024||typeof t.truncated!="boolean")return null;const n=uS(t.attributes,12,r=>pz.test(r),200),s=uS(t.styles,5,r=>gz.has(r),80);return!n||!s||![t.x,t.y,t.width,t.height].every(TC)||t.width<0||t.height<0?null:{tag:t.tag,opening:t.opening,path:t.path,attributes:n,styles:s,x:t.x,y:t.y,width:t.width,height:t.height,truncated:t.truncated}}function bz(e){if(!e||typeof e!="object")return null;const t=e;if(t.type!==fz)return null;if(t.text==="")return{text:"",anchor:"",x:0,y:0,width:0,height:0};if(typeof t.text!="string"||!t.text.trim()||t.text.length>4e3||typeof t.anchor!="string"||!dS.test(t.anchor))return null;const n=dS.exec(t.anchor),s=Number(n?.[1]),r=Number(n?.[2]);if(!Number.isSafeInteger(s)||!Number.isSafeInteger(r)||r<s||r-s!==t.text.length||![t.x,t.y,t.width,t.height].every(o=>TC(o)))return null;if(t.element!=null){const o=vz(t.element);return o?{text:t.text,anchor:t.anchor,x:t.x,y:t.y,width:t.width,height:t.height,element:o}:null}return{text:t.text,anchor:t.anchor,x:t.x,y:t.y,width:t.width,height:t.height}}function xz(e){return e.element?hz({opening:e.element.opening,path:e.element.path,attributes:e.element.attributes,styles:e.element.styles,rect:{x:e.element.x,y:e.element.y,width:e.element.width,height:e.element.height},quote:e.text,truncated:e.element.truncated}).quote:e.text}function yz(e){const t=f.useRef(null),n=f.useRef(null),s=f.useRef(!1),r=f.useRef(!1),a=f.useRef(e);a.current=e;const[o,l]=f.useState(null),[c,d]=f.useState(!1),[u,h]=f.useState(""),[p,m]=f.useState(0);r.current=c;const g=()=>{s.current=!1,l(null),d(!1)};f.useEffect(()=>{g(),h("")},[e.src,e.sha256,e.referenceOwner?.sessionId,e.referenceOwner?.workspaceId,e.referenceOwner?.generation]),f.useEffect(()=>{const y=C=>{if(C.origin!=="null"||C.source!==n.current?.contentWindow)return;const S=bz(C.data);if(!S)return;if(!S.text){!r.current&&!s.current&&l(null);return}const I=a.current;if(!(r.current||!I.referenceOwner||!I.onReference)){if(!I.workspaceId){h("当前没有工作区,无法引用这段内容"),l(null);return}if(!I.sha256){h("页面还在加载,请稍后再引用"),l(null);return}try{const w=or([{id:crypto.randomUUID(),capturedAt:new Date().toISOString(),quote:xz(S),comment:"",source:{kind:"file",workspaceId:I.workspaceId,path:I.path,version:`sha256:${I.sha256}`,versionScope:I.truncated?"prefix":"file",view:"html",anchor:S.anchor}}])[0];if(!w)return;l(_=>{const k=_&&_.payload.text===S.text&&_.payload.anchor===S.anchor&&_.payload.element?.path===S.element?.path;return{payload:S,reference:k?{..._.reference,quote:w.quote}:w}}),h("")}catch(w){l(null),h(w instanceof Error?w.message:"引用无效")}}};return window.addEventListener("message",y),()=>window.removeEventListener("message",y)},[]),f.useEffect(()=>{if(!o)return;const y=()=>m(C=>C+1);return window.addEventListener("scroll",y,!0),window.addEventListener("resize",y),()=>{window.removeEventListener("scroll",y,!0),window.removeEventListener("resize",y)}},[o]);const v=wz(t.current),b=Sz(o?.payload,n.current,v),x=o&&b&&v?Xs.createPortal(c?i.jsx(Mc,{label:"确认选文引用",placement:"anchored",style:f6(b),tag:o.payload.element?.tag??bh(o.reference.source),quote:Fv(o.reference.quote),commentLabel:"选文评论",placeholder:"例如:把这段标题改短",extra:o.payload.element?i.jsxs("p",{className:"oc-cite-note",children:[o.payload.element.opening," · ",o.payload.element.path]}):void 0,onCancel:g,onConfirm:y=>{if(!e.referenceOwner||!e.onReference)return!1;try{const C=or([{...o.reference,comment:y}])[0];return!C||!e.onReference(C,{...e.referenceOwner})?!1:(g(),!0)}catch{return!1}}},o.reference.id):i.jsx("button",{type:"button",className:"oc-cite-chip",style:m6(b),onMouseDown:y=>{s.current=!0,y.preventDefault(),y.stopPropagation()},onMouseUp:y=>y.stopPropagation(),onClick:()=>d(!0),children:"引用"}),v):null;return i.jsxs("div",{ref:t,className:"oc-file-preview-html-frame",children:[i.jsx("iframe",{ref:n,className:e.className,sandbox:e.sandbox,title:e.title,referrerPolicy:e.referrerPolicy,src:e.src}),x,u?i.jsx("p",{className:"oc-cite-error oc-file-preview-html-cite-error",role:"alert",children:u}):null]})}function wz(e){if(typeof HTMLElement>"u"||!e)return null;const t=e.closest(".oc-cite-scope");return t instanceof HTMLElement?t:e}function Sz(e,t,n){if(!e?.text||!t||!n)return null;const s=n.getBoundingClientRect(),r=t.getBoundingClientRect(),a=r.top-s.top+e.y,o=r.left-s.left+e.x;return{top:a,bottom:a+e.height,left:o,endX:o+e.width,endBottom:a+e.height,width:s.width,height:s.height}}function _z(e){if(!(!e.background&&!e.color&&!e.bold&&!e.italic&&!e.align))return{backgroundColor:e.background,color:e.color,fontWeight:e.bold?700:e.background||e.color?400:void 0,fontStyle:e.italic?"italic":void 0,textAlign:e.align}}function RC(e){return e==="xls"||e==="xlsx"}function hS(e){const t=e.language.trim().toLowerCase();return RC(t)?null:[IC(e.content,t==="tsv"?" ":",")]}function kz(e){const{preview:t}=e,n=t.language.trim().toLowerCase(),s=RC(n),[r,a]=f.useState(()=>hS(t)),[o,l]=f.useState(0),[c,d]=f.useState(null);if(f.useEffect(()=>{let p=!1;if(d(null),l(0),!s){const g=hS(t);a(g),e.onTables?.(g);return}if(!t.previewUrl){d("表格预览地址不可用(缺少有效工作区)。"),a(null),e.onTables?.(null);return}e.onTables?.(null),a(null);const m=new AbortController;return(async()=>{const g=await fetch(t.previewUrl,{credentials:"include",signal:m.signal});if(!g.ok)throw new Error("sheet fetch failed");const v=new Uint8Array(await g.arrayBuffer()),b=await oP(v),x=n==="xlsx"?await tc(()=>import("./sheet-workbook-kFN3yUBr.js"),__vite__mapDeps([2,1])).then(y=>y.readStyledXlsx(v)):await tc(()=>import("./sheet-workbook-kFN3yUBr.js"),__vite__mapDeps([2,1])).then(y=>y.readStyledXls(v));if(!p){const y=x.length>0?x:[];a(y),e.onDigest?.(b),e.onTables?.(y)}})().catch(()=>{p||(d("表格无法预览,请确认文件完好。"),e.onTables?.(null))}),()=>{p=!0,m.abort()}},[s,n,t.content,t.previewUrl]),c)return i.jsx("p",{className:"oc-file-preview-image-error",role:"alert",children:c});if(!r)return i.jsx("p",{className:"oc-file-preview-sheet-status",role:"status",children:"正在加载表格…"});const u=r[o]??r[0];if(!u||u.rows.length===0)return i.jsx("p",{className:"oc-file-preview-sheet-status",role:"status",children:"表格是空的。"});const h=u.rows.reduce((p,m)=>Math.max(p,m.length),0);return i.jsxs("div",{className:"oc-file-preview-sheet","data-sheet-preview":!0,"data-sheet-name":u.name,children:[r.length>1?i.jsx("div",{className:"oc-sheet-tabs",role:"tablist","aria-label":"工作表",children:r.map((p,m)=>i.jsx("button",{type:"button",role:"tab","aria-selected":m===o,className:m===o?"is-active":"",onClick:()=>l(m),children:p.name},p.name))}):null,u.truncatedRows||u.truncatedCols?i.jsxs("p",{className:"oc-file-preview-truncated",role:"status",children:["表格较大,仅显示前 ",u.rows.length," 行、每行最多 ",h," 列。"]}):null,i.jsx("div",{className:"oc-sheet-scroll",children:i.jsx("table",{className:"oc-sheet-table",children:i.jsx("tbody",{children:u.rows.map((p,m)=>i.jsx("tr",{children:Array.from({length:h},(g,v)=>{const b=p[v]??{text:""};if(b.hidden)return null;const x=m===0?"th":"td";return i.jsx(x,{"data-sheet-row":m,"data-sheet-col":v,colSpan:b.colSpan,rowSpan:b.rowSpan,style:_z(b),children:b.text},v)})},m))})})})]})}const Cz={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",sh:"bash",bash:"bash",zsh:"bash",py:"python",pyw:"python",pyi:"python",json:"json",jsonc:"json",jsonl:"json",ndjson:"json",yml:"yaml",yaml:"yaml",md:"markdown",markdown:"markdown",html:"xml",htm:"xml",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",go:"go",rs:"rust",java:"java",c:"c",h:"c",cc:"cpp",cpp:"cpp",cxx:"cpp",hh:"cpp",hpp:"cpp",hxx:"cpp",cs:"csharp",php:"php",rb:"ruby",kt:"kotlin",kts:"kotlin",swift:"swift",lua:"lua",sql:"sql",diff:"diff",patch:"diff",ini:"ini",conf:"ini",cfg:"ini",toml:"ini",properties:"ini",r:"r",pl:"perl",pm:"perl",mk:"makefile",makefile:"makefile",graphql:"graphql",gql:"graphql"};function fS(e){const t=(e??"").trim().toLowerCase(),n=Cz[t];if(!(!n||!fc.getLanguage(n)))return n}function Iz(e,t){if(!(!t||!fc.getLanguage(t)))return fc.highlight(e,{language:t,ignoreIllegals:!0}).value}const Ez=["repo","session","bench"],Fg={repo:{id:"repo",label:"仓库",description:"当前仓库的文件与 Git",pages:["files","scm"]},session:{id:"session",label:"会话",description:"这次对话的注入与检查",pages:["context","insights","calls","activity","trajectory","goal","tasks","subagents","workflows","dag"]},bench:{id:"bench",label:"工作台",description:"终端、预览、数据库、接口调试",pages:["terminals","ssh","browser","databases","api","regex","json"]}},Nz={files:"repo",scm:"repo",context:"session",insights:"session",calls:"session",activity:"session",trajectory:"session",goal:"session",tasks:"session",subagents:"session",workflows:"session",dag:"session",terminals:"bench",ssh:"bench",browser:"bench",databases:"bench",api:"bench",regex:"bench",json:"bench"};function mS(e){return Nz[e]}function ob(e,t){const n=new Set(Fg[e].pages);return t.filter(s=>n.has(s))}function jz(e){return Ez.filter(t=>ob(t,e).length>0)}function Tz(e,t,n){const s=ob(e,t);return s.length===0?null:n&&s.includes(n)?n:s[0]??null}function Rz(e,t,n){if(t.length<2)return null;const s=t.indexOf(e);return s<0?t[0]??null:t[(s+n+t.length)%t.length]??null}function Az(e,t,n){if(t.length<2)return null;const s=t.indexOf(e);return s<0?t[0]??null:t[(s+n+t.length)%t.length]??null}function Mz(e){switch(e){case"activity":case"goal":return e;default:return null}}function fd(e){const t=e.nodes.length,n=e.nodes.filter(s=>["succeeded","completed","passed"].includes(s.status)).length;return{completed:n,total:t,pct:t?Math.round(n/t*100):0}}function Lz(e){return e==="terminals"?i.jsx(Zi,{size:16,"aria-hidden":"true"}):e==="ssh"?i.jsx(Vp,{size:16,"aria-hidden":"true"}):e==="browser"?i.jsx(Xk,{size:16,"aria-hidden":"true"}):e==="databases"?i.jsx(Eo,{size:16,"aria-hidden":"true"}):e==="api"?i.jsx(ov,{size:16,"aria-hidden":"true"}):e==="regex"?i.jsx(av,{size:16,"aria-hidden":"true"}):e==="json"?i.jsx(Uk,{size:16,"aria-hidden":"true"}):null}function Oz(){if(typeof navigator>"u")return"在文件管理器中打开工作目录";const e=navigator.platform??"";return/mac/i.test(e)?"在访达中打开工作目录":/win/i.test(e)?"在资源管理器中打开工作目录":"在文件管理器中打开工作目录"}function pS(e){const[t,n]=f.useState("files"),[s,r]=f.useState("idle"),[a,o]=f.useState(null),l=e.activeTab??t,c=!!e.dagRunId,d=[{id:"files",label:"文件"},...e.scmContent?[{id:"scm",label:"Git"}]:[],...e.contextContent?[{id:"context",label:"上下文"}]:[],...e.insightsContent?[{id:"insights",label:"洞察"}]:[],...e.callsContent?[{id:"calls",label:"调用记录"}]:[],...e.activityContent?[{id:"activity",label:"运行活动"}]:[],...e.trajectoryContent?[{id:"trajectory",label:"轨迹"}]:[],...e.goalContent?[{id:"goal",label:"目标"}]:[],...e.tasksContent||e.subagentsContent?[{id:"tasks",label:"任务管理"}]:[],...e.workflowsContent?[{id:"workflows",label:"工作流"}]:[],...e.terminalsContent?[{id:"terminals",label:"终端"}]:[],...e.sshContent?[{id:"ssh",label:"SSH"}]:[],...e.browserContent?[{id:"browser",label:"浏览器"}]:[],...e.databaseContent?[{id:"databases",label:"数据库"}]:[],...e.apiContent?[{id:"api",label:"接口"}]:[],...e.regexContent?[{id:"regex",label:"正则"}]:[],...e.jsonContent?[{id:"json",label:"JSON"}]:[],...c?[{id:"dag",label:"DAG"}]:[]],u=d.some(se=>se.id===l)?l:"files",h=d.map(se=>se.id),p=mS(u),m=Fg[p],g=ob(p,h),v=jz(h),b=d.filter(se=>g.includes(se.id)),[x,y]=f.useState({}),C=f.useRef(null),S=f.useRef(null),I=f.useRef(null),w=f.useRef(null),_=f.useRef(null),k=f.useRef(null),N=f.useRef(null),L=f.useRef(null),O=f.useRef(null),T=f.useRef(null),R=f.useRef(null),A=f.useRef(null),E=f.useRef(null),$=f.useRef(null),H=f.useRef(null),B=f.useRef(null),G=f.useRef(null),z=f.useRef(null),Q=f.useRef(null),W=f.useRef(e.open),D=se=>{n(se),y(he=>({...he,[mS(se)]:se})),e.onSelectTab?.(se)},ee=se=>{const he=Tz(se,h,x[se]);he&&D(he)},F=se=>{switch(se){case"context":return S;case"insights":return I;case"calls":return w;case"activity":return _;case"trajectory":return k;case"goal":return N;case"tasks":case"subagents":return L;case"workflows":return O;case"terminals":return T;case"scm":return R;case"browser":return A;case"databases":return E;case"api":return $;case"regex":return H;case"json":return B;case"ssh":return G;case"dag":return z;default:return C}};f.useEffect(()=>{u!==l&&D(u)},[l,u]),f.useEffect(()=>{const se=W.current;W.current=e.open,!se&&e.open&&Q.current?.focus()},[e.open]);const M=se=>{if(g.length<2)return;let he=null;se.key==="ArrowLeft"||se.key==="ArrowRight"?he=Az(u,g,se.key==="ArrowRight"?1:-1):se.key==="Home"?he=g[0]??null:se.key==="End"&&(he=g[g.length-1]??null),he&&(se.preventDefault(),D(he),F(he).current?.focus())},U=se=>{let he=null;se.key==="ArrowLeft"||se.key==="ArrowRight"?he=Rz(p,v,se.key==="ArrowRight"?1:-1):se.key==="Home"?he=v[0]??null:se.key==="End"&&(he=v[v.length-1]??null),he&&(se.preventDefault(),ee(he))},q=Oz(),te=()=>{const se=e.workspaceId?.trim(),he=e.origin?.replace(/\/$/,"")??"";!se||s==="opening"||(r("opening"),o(null),fetch(`${he}/api/operator/v1/chat/repo/open-directory?workspaceId=${encodeURIComponent(se)}`,{method:"POST",credentials:"include",headers:{"x-loop-console-confirmation":Rt()}}).then(async X=>{const re=await X.json().catch(()=>({}));if(!X.ok)throw new Error(re.error?.message??"无法打开工作目录");r("idle")}).catch(X=>{r("failed"),o(X instanceof Error?X.message:"无法打开工作目录")}))};return e.open?i.jsxs("aside",{className:"oc-details-rail","aria-label":"辅助栏","data-surface":p,children:[i.jsxs("header",{className:"oc-details-rail-head",children:[i.jsxs("div",{className:"oc-details-surface-id",children:[i.jsx("h2",{className:"oc-details-surface-title",children:m.label}),i.jsx("p",{className:"oc-details-surface-desc",children:m.description})]}),v.length>1?i.jsx("div",{className:"oc-details-surface-switch",role:"tablist","aria-label":"辅助栏表面",children:v.map(se=>i.jsx("button",{type:"button",role:"tab","aria-selected":p===se,tabIndex:p===se?0:-1,className:`oc-details-surface-switch-btn${p===se?" is-active":""}`,onClick:()=>ee(se),onKeyDown:U,children:Fg[se].label},se))}):null,i.jsx("button",{type:"button",className:"oc-details-rail-toggle",ref:Q,onClick:e.onToggleOpen,"aria-label":"关闭辅助栏","aria-expanded":e.open,"aria-controls":"oc-details-rail-body",title:"关闭辅助栏",children:i.jsx(FD,{})})]}),p!=="bench"?i.jsxs("div",{className:p==="repo"?"oc-details-repo-bar":"oc-details-tabbar",children:[i.jsx("div",{className:"oc-details-tabs",role:"tablist","aria-label":`${m.label}页面`,children:b.map(se=>{const he=Mz(se.id);return i.jsxs("div",{className:`oc-details-tab${u===se.id?" is-active":""}`,role:"presentation",children:[i.jsx("button",{type:"button",id:`oc-details-tab-${se.id}`,ref:F(se.id),role:"tab","aria-selected":u===se.id,"aria-controls":"oc-details-rail-body",tabIndex:u===se.id?0:-1,className:"oc-details-tab-select",onClick:()=>D(se.id),onKeyDown:M,children:se.label}),he&&e.onCloseTab?i.jsx("button",{type:"button",className:"oc-details-tab-close","aria-label":`关闭${se.label}标签页`,title:`关闭${se.label}`,onClick:()=>e.onCloseTab?.(he),children:i.jsx(Wn,{size:13,"aria-hidden":"true"})}):null]},se.id)})}),p==="repo"?i.jsx("button",{type:"button",className:"oc-details-open-directory","data-state":s,"aria-label":q,title:a??q,disabled:s==="opening"||!e.workspaceId?.trim(),onClick:te,children:i.jsx(Zk,{size:16,"aria-hidden":"true"})}):null]}):i.jsx("div",{className:"oc-details-bench-rail",role:"tablist","aria-label":"工作台工具",children:b.map(se=>i.jsx("button",{type:"button",id:`oc-details-tab-${se.id}`,ref:F(se.id),role:"tab","aria-selected":u===se.id,"aria-controls":"oc-details-rail-body","aria-label":se.label,title:se.label,tabIndex:u===se.id?0:-1,className:`oc-details-bench-btn${u===se.id?" is-active":""}`,onClick:()=>D(se.id),onKeyDown:M,children:Lz(se.id)},se.id))}),e.open?i.jsx("div",{id:"oc-details-rail-body",className:"oc-details-rail-body",role:"tabpanel","aria-labelledby":`oc-details-tab-${u}`,"data-tab":u,children:u==="dag"&&e.dagRunId?i.jsxs("section",{className:"oc-details-dag","aria-label":"当前 DAG",children:[i.jsxs("header",{children:[i.jsx("strong",{children:"当前 DAG"}),i.jsx("code",{children:e.dagRunId})]}),e.dagRun?i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"oc-details-dag-point",children:["运行点:",i.jsx("code",{children:e.dagRun.currentNodeId??"—"}),e.dagRun.status?i.jsxs("span",{children:["(",e.dagRun.status,")"]}):null]}),i.jsx("ul",{className:"oc-details-dag-nodes","aria-label":"DAG 节点",children:e.dagRun.nodes.map(se=>i.jsxs("li",{"data-status":se.status,children:[i.jsx("span",{className:"oc-details-dag-node-id",children:se.id}),i.jsx("span",{className:"oc-details-dag-node-status",children:se.status})]},se.id))}),i.jsxs("p",{className:"oc-details-dag-progress",children:["完成 ",fd(e.dagRun).completed,"/",fd(e.dagRun).total]}),i.jsx("div",{className:"oc-details-dag-progressbar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":fd(e.dagRun).pct,"aria-label":"DAG 完成进度",children:i.jsx("div",{className:"oc-details-dag-progressfill",style:{width:`${fd(e.dagRun).pct}%`}})})]}):i.jsx("p",{className:"oc-details-dag-empty-reason",children:"当前运行暂无安全汇总数据,等待运行数据同步。"})]}):u==="context"?e.contextContent:u==="insights"?e.insightsContent:u==="calls"?e.callsContent:u==="activity"?e.activityContent:u==="trajectory"?e.trajectoryContent:u==="goal"?e.goalContent:u==="tasks"||u==="subagents"?e.tasksContent??e.subagentsContent:u==="workflows"?e.workflowsContent:u==="terminals"?e.terminalsContent:u==="scm"?e.scmContent:u==="ssh"?e.sshContent:u==="browser"?e.browserContent:u==="databases"?e.databaseContent:u==="api"?e.apiContent:u==="regex"?e.regexContent:u==="json"?e.jsonContent:e.children},u):null]}):i.jsx("aside",{className:"oc-details-rail is-collapsed","aria-label":"辅助栏","aria-hidden":"true",inert:!0})}function Dz(e){return e.kind==="image"||e.kind==="pdf"||e.kind==="sheet"||e.kind==="docx"?!0:Ki(e.language)||Mh(e.language)}function Pz(e){return e.kind==="image"&&e.language!=="svg"}function $z(e){return Pz(e)||e.kind==="pdf"||e.kind==="docx"||e.kind==="sheet"&&ab(e.language)}function Bz(e){return e&&(Ki(e)||Mh(e)||VF(e)||qF(e)||WF(e)||UF(e))?"preview":"source"}function md(e,t){return t.type==="mode"?t.mode:t.path?Bz(t.language):"source"}function Fz(e){const{preview:t}=e,[n,s]=f.useState("loading");return t.previewUrl?i.jsxs("div",{className:"oc-file-preview-image","data-image-preview":n,"data-image-media-type":t.mediaType,children:[n==="failed"?i.jsx("p",{className:"oc-file-preview-image-status",role:"alert",children:"图片加载失败,请确认文件完好后重试。"}):null,i.jsx("img",{className:"oc-file-preview-image-img",src:t.previewUrl,alt:`图片预览 ${t.path}`,decoding:"async",draggable:!1,referrerPolicy:"no-referrer",hidden:n!=="ready",onLoad:()=>s("ready"),onError:()=>s("failed")})]}):i.jsx("p",{className:"oc-file-preview-image-error",role:"alert",children:"图片预览地址不可用(缺少有效工作区)。"})}function zz(e,t){const n=e.kind;return n===void 0||n==="text"||n==="sheet"||n==="docx"?!(t==="preview"&&Ki(e.language)):!1}function Hz(e){return e.kind==="docx"&&!!e.sha256}function qz(e,t,n){return n||!zz(e,t)?!0:e.kind==="docx"&&!Hz(e)}function Uz(e){const t=e.previews.find(v=>v.path===e.activePath),n=t?Dz(t):!1,s=t?$z(t):!1,r=n&&!s,[a,o]=f.useState(()=>md("source",{type:"file",path:t?.path??null,language:t?.language})),[l,c]=f.useState(null),d=f.useRef(null),u=f.useRef(null),h=f.useRef(null),p=t?.kind==="sheet"&&a==="preview"&&n,m=v=>{const b=v.startElement.closest("[data-sheet-preview]")??v.endElement.closest("[data-sheet-preview]")??v.startElement.querySelector("[data-sheet-preview]"),x=b?.getAttribute("data-sheet-name"),y=u.current?.find(I=>I.name===x),C=b?uP(dP(b,v.range)):null;if(!y||!C)throw new Error("请在表格单元格内拖选,再点「引用」");const S=hP(y,C);if("error"in S)throw new Error(S.error);return{...S,sheet:y.name}},g=t?.kind==="unsupported"?"不支持的文件":t?.kind==="image"?"图片":t?.kind==="docx"?"Word":Ki(t?.language??"")?"HTML":Mh(t?.language??"")?"Markdown":"文本";return f.useEffect(()=>{o(v=>t?.focusLine?"source":md(v,{type:"file",path:t?.path??null,language:t?.language})),c(null),u.current=null,h.current=null},[t?.path,t?.focusLine,n]),f.useEffect(()=>{d.current?.scrollIntoView({block:"center"})},[t,a]),e.loading||e.error?i.jsxs("section",{className:"oc-file-preview","aria-label":`文件预览 ${e.activePath??""}`,children:[i.jsxs("header",{className:"oc-file-preview-header",children:[i.jsx("strong",{className:"oc-file-preview-path",children:e.activePath}),i.jsx("button",{type:"button","aria-label":"关闭文件预览",onClick:()=>e.activePath&&e.onClose(e.activePath),children:i.jsx(Wn,{size:16})})]}),i.jsx("p",{className:"oc-file-preview-status",role:e.error?"alert":"status",children:e.error??"正在读取文件…"})]}):t?i.jsxs(i.Fragment,{children:[t&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"oc-file-preview-backdrop",onMouseDown:v=>{v.target===v.currentTarget&&e.onClose(t.path)}}),i.jsxs("section",{className:"oc-file-preview","aria-label":`文件预览 ${t.path}`,children:[i.jsxs("header",{className:"oc-file-preview-header",children:[i.jsxs("div",{className:"oc-file-preview-path-group",children:[i.jsx("strong",{className:"oc-file-preview-path",title:t.path,children:t.path}),i.jsxs("span",{className:"oc-file-preview-meta","aria-label":`渲染器 ${g}`,children:[g," · ",t.bytes," bytes",t.truncated?" · 源码已截断":""]})]}),i.jsxs("div",{className:"oc-file-preview-actions",children:[r&&i.jsxs("div",{className:"oc-file-view-modes",role:"group","aria-label":"文件查看模式",children:[i.jsx("button",{type:"button",className:`oc-file-view-mode${a==="preview"?" is-active":""}`,"aria-pressed":a==="preview",onClick:()=>o(v=>md(v,{type:"mode",mode:"preview"})),children:"预览"}),i.jsx("button",{type:"button",className:`oc-file-view-mode${a==="source"?" is-active":""}`,"aria-pressed":a==="source",onClick:()=>o(v=>md(v,{type:"mode",mode:"source"})),children:"源文件"})]}),e.onInsert?i.jsx("button",{type:"button",className:"oc-file-preview-cite",title:"在输入框提及此文件","aria-label":`提及 ${zg(t.path)}`,onClick:()=>e.onInsert?.(t.path),children:"@"}):null,e.onReload?i.jsx("button",{type:"button",className:"oc-file-preview-reload",title:"重新读取文件","aria-label":`重新读取 ${zg(t.path)}`,disabled:e.reloading,onClick:()=>e.onReload?.(t.path),children:i.jsx(mi,{size:14,"aria-hidden":"true"})}):null,i.jsx("button",{type:"button",className:"oc-file-preview-open",title:"新窗口打开","aria-label":`新窗口打开 ${t.path}`,onClick:()=>{const v=cz(t,void 0,void 0,u.current??void 0);c(v.ok?null:v.error)},children:i.jsx(CN,{size:16,"aria-hidden":"true"})})]})]}),e.loading?i.jsx("p",{className:"oc-file-preview-status oc-file-preview-loading",role:"status",children:"正在读取文件…"}):null,l?i.jsx("p",{className:"oc-file-preview-status oc-file-preview-open-error",role:"alert",children:l}):null,t.truncated&&(a==="source"||!Ki(t.language))&&t.kind!=="image"&&t.kind!=="unsupported"?i.jsx("p",{className:"oc-file-preview-status oc-file-preview-truncated",role:"status",children:"文件较大,仅展示前 512 KiB。"}):null,i.jsx(Hv,{className:"oc-file-preview-body",referenceOwner:e.referenceOwner,onReference:e.onReference,disabled:qz(t,a,e.loading),quote:v=>p?m(v)?.quote??null:v.text,source:v=>{if(p){const y=t.sha256??h.current;if(!e.workspaceId)throw new Error("当前没有工作区,无法引用这段表格");if(!y)throw new Error("表格还在加载,请稍后再引用");const C=m(v);return C?{kind:"file",workspaceId:e.workspaceId,path:t.path,version:`sha256:${y}`,versionScope:t.truncated?"prefix":"file",view:"sheet",anchor:v.anchor,cellRange:C.cellRange,...C.sheet?{sheet:C.sheet}:{}}:null}if(!e.workspaceId||!t.sha256)return null;if(t.kind==="docx")return{kind:"file",workspaceId:e.workspaceId,path:t.path,version:`sha256:${t.sha256}`,versionScope:"file",view:"markdown",anchor:v.anchor};const b=Number(v.startElement.closest("[data-line]")?.getAttribute("data-line")),x=Number(v.endElement.closest("[data-line]")?.getAttribute("data-line"));return{kind:"file",workspaceId:e.workspaceId,path:t.path,version:`sha256:${t.sha256}`,versionScope:t.truncated?"prefix":"file",view:a==="source"?"source":"markdown",anchor:v.anchor,...a==="source"&&t.lineMappingReliable&&b>0&&x>=b?{startLine:b,endLine:x}:{}}},children:t.kind==="unsupported"?i.jsxs("div",{className:"oc-file-preview-unsupported",role:"status",children:[i.jsx(Wn,{size:18,"aria-hidden":"true"}),i.jsx("p",{children:"此文件类型无法预览"}),i.jsx("p",{className:"oc-file-preview-unsupported-hint",children:"二进制文件不支持内联预览"})]}):a==="preview"&&n?t.kind==="image"?i.jsx(Fz,{preview:t}):t.kind==="pdf"?i.jsx(uz,{preview:t}):t.kind==="docx"?i.jsx(_8,{preview:t}):t.kind==="sheet"?i.jsx(kz,{preview:t,onTables:v=>{u.current=v,v||(h.current=null)},onDigest:v=>{h.current=v}}):Ki(t.language)?i.jsx(yz,{className:"oc-file-preview-html",sandbox:Bg,title:`HTML 预览 ${t.path}`,referrerPolicy:"no-referrer",src:t.htmlPreviewUrl,workspaceId:e.workspaceId,path:t.path,sha256:t.sha256,truncated:t.truncated,referenceOwner:e.referenceOwner,onReference:e.onReference}):i.jsx("div",{className:"oc-file-preview-rendered",children:i.jsx(vi,{text:t.content})}):i.jsx("pre",{className:"oc-file-preview-source",children:i.jsx("code",{className:fS(t.language)?"hljs":void 0,children:t.content.split(`
|
|
435
435
|
`).map((v,b,x)=>{const y=b+1,C=t.focusLine===y,S=fS(t.language),I=Iz(v,S),w=b<x.length-1?`
|
|
436
436
|
`:"",_=`oc-file-preview-line${C?" is-focused":""}`;return I!==void 0?i.jsx("span",{ref:C?d:void 0,className:_,"data-line":y,dangerouslySetInnerHTML:{__html:`${I}${w}`}},y):i.jsx("span",{ref:C?d:void 0,className:_,"data-line":y,children:`${v}${w}`},y)})})})},`${t.path}:${t.sha256}:${a}`)]})]}),e.loading&&!t&&i.jsx("div",{className:"oc-file-preview-loading",children:"正在读取文件…"})]}):null}function zg(e){const t=e.split(/[/\\]/).pop();return t&&t.length>0?t:e}function Wz(e){const[t,n]=f.useState(()=>e.previewGeneration>0&&(e.activePath||e.loading||e.error)?"preview":"directory"),s=f.useRef(e.previewGeneration);f.useEffect(()=>{e.previewGeneration!==s.current?(s.current=e.previewGeneration,e.previewGeneration>0&&n("preview")):!e.activePath&&!e.loading&&!e.error&&n("directory")},[e.previewGeneration,e.activePath,e.loading,e.error]);const r=t==="preview"&&(!!e.activePath||e.loading||!!e.error),a=o=>{n("preview"),e.onActivate(o)};return i.jsxs("section",{className:"oc-file-workspace","aria-label":"文件",children:[i.jsxs("div",{className:"oc-file-workspace-tabs",role:"tablist","aria-label":"文件页",children:[i.jsx("div",{className:`oc-file-tab is-pin${r?"":" is-active"}`,children:i.jsxs("button",{type:"button",role:"tab","aria-selected":!r,className:"oc-file-tab-activate",onClick:()=>n("directory"),children:[i.jsx("span",{className:"oc-file-pin","aria-hidden":"true"}),"目录"]})}),e.previews.map(o=>{const l=r&&o.path===e.activePath;return i.jsxs("div",{className:`oc-file-tab${l?" is-active":""}`,title:o.path,children:[i.jsx("button",{type:"button",role:"tab","aria-selected":l,className:"oc-file-tab-activate",onClick:()=>a(o.path),children:zg(o.path)}),i.jsx("button",{type:"button",className:"oc-file-preview-close","aria-label":`关闭预览 ${o.path}`,title:"关闭预览",onClick:()=>{const c=e.previews.filter(d=>d.path!==o.path);e.onClose(o.path),c.length===0&&n("directory")},children:i.jsx(Wn,{size:14,"aria-hidden":"true"})})]},o.path)})]}),r?i.jsx(Uz,{workspaceId:e.workspaceId,referenceOwner:e.referenceOwner,onReference:e.onReference,previews:e.previews,activePath:e.activePath,loading:e.loading,error:e.error,onActivate:a,onClose:e.onClose,onInsert:e.onInsert,...e.onReload?{onReload:e.onReload}:{},...e.reloading!==void 0?{reloading:e.reloading}:{}}):i.jsx(YD,{workspaceName:e.workspaceName,tree:e.tree,expanded:e.expanded,treeError:e.treeError,onRefresh:e.onRefresh,onToggle:e.onToggle,onInsert:e.onInsert,onPreview:o=>{n("preview"),e.onPreview(o)}})]})}const Vz=["workflow","pi"],$r="pi",Ca={workflow:{id:"workflow",label:"工作流",shortLabel:"工作流",description:"规划并推进工作流",createLabel:"新建工作流会话",bannerTitle:"工作流",bannerBody:"用自然语言编排 loop-agent / agent-worker 的全部能力。这是 Operator 面:默认具备完整 Pi 工具与受策略约束的 operator action。软约束:大改与高风险变更优先走受治 DAG。",landingTitle:"开始一段新的对话",landingBody:"用自然语言编排 loop-agent:查询状态、诊断问题、创建与恢复任务。可先点选下方建议,或在输入框描述目标。工作流或 Pi 在输入框上方选择。",emptyTitle:"今天想推进什么?",emptyBody:"会话已就绪。输入框上方可切换工作区或工作流 / Pi。点选建议快速开场,或直接描述目标。业务写入仍经受治理 DAG。"},pi:{id:"pi",label:"Pi",shortLabel:"Pi",description:"保留压缩与 Explore,直接协作编码",createLabel:"新建 Pi 会话",bannerTitle:"Pi",bannerBody:"保留 Console 压缩、Explore 与持续目标,直接协作编码。不注入工作流业务指令与业务工具。",landingTitle:"开始一段 Pi 协作",landingBody:"Pi 模式保留压缩、Explore、持续目标、认证与 SDD 接入,取消工作流业务注入。适合有人监督的直接编码与调试。",emptyTitle:"直接协作编码",emptyBody:"会话已就绪。输入框上方可切换工作区或模式。使用 Pi 工具读写仓库;Explore 负责只读深挖。本会话不加载任务 / DAG 工作流工具。"}},Gz=Object.freeze(["focus-panel:task","focus-panel:contract","focus-panel:dag","focus:interview"]);function gS(e){return Gz.includes(e)}const AC=[{command:"/task",label:"Task context",description:"查看当前任务、Draft 与 assessment",action:"focus-panel:task",source:"operator"},{command:"/contract",label:"Contract",description:"查看 contract diff 与 apply gate",action:"focus-panel:contract",source:"operator"},{command:"/dag",label:"DAG",description:"查看 DAG spine、确认与运行状态",action:"focus-panel:dag",source:"operator"},{command:"/interview",label:"Interview",description:"打开 Requirement Interview",action:"focus:interview",source:"operator"},{command:"/reload",label:"Reload session",description:"重新加载当前 Pi 会话的设置、扩展、技能、提示词、主题、上下文文件及模型与认证配置(不产生消息)",action:"reload",source:"operator"},{command:"/context",label:"Context insights",description:"打开上下文洞察仪表盘:构成、趋势、事件与文件活动",action:"focus:context-insights",source:"operator"}],oo={command:"/sdd-bingo",label:"sdd-bingo",description:"SDD数据对齐",action:"sdd-bingo",source:"operator"},MC=[{command:"/goal",label:"持续目标",description:"创建或编辑一个跨多个回合持续推进的目标",action:"goal",source:"web"},{command:"/compact",label:"压缩上下文",description:"压缩当前会话上下文,释放 token",action:"compact",source:"web"},{command:"/name",label:"重命名会话",description:"设置当前会话标题",action:"name",source:"web"},{command:"/session",label:"会话信息",description:"显示当前会话元信息",action:"session",source:"web"},{command:"/copy",label:"复制回复",description:"复制最后一条助手消息原文",action:"copy",source:"web"}],Sa={operator:0,web:1,extension:2,skill:3,prompt:4};function vS(e){const t=e.trim().split(/\s+/,1)[0]??"";return t?t.startsWith("/")?t.toLowerCase():`/${t.toLowerCase()}`:""}function bS(e){const t=e.trim().split(/\s+/,1)[0]?.toLowerCase();if(!t?.startsWith("/"))return;const n=[...AC,...MC,oo].find(s=>s.command===t);return n?{command:n.command,action:n.action}:{command:t,action:"unknown"}}function Kz(e){if(e==="focus-panel:task"||e==="focus-panel:contract")return"tasks";if(e==="focus-panel:dag")return"recovery"}function Yz(e=[],t={}){const n=new Map,s=a=>{const o=vS(a.command);if(!o)return;const l=n.get(o);if(!l){n.set(o,{...a,command:o});return}Sa[a.source]<Sa[l.source]&&n.set(o,{...a,command:o})},r=t.sessionMode==="pi";for(const a of AC)r&&gS(a.action)||s({command:a.command,label:a.label,description:a.description,source:a.source,action:a.action});for(const a of MC)r&&gS(a.action)||s({command:a.command,label:a.label,description:a.description,source:a.source,action:a.action});t.sddBingo&&s({command:oo.command,label:oo.label,description:oo.description,source:oo.source,action:oo.action});for(const a of e){const o=vS(a.command);o&&s({command:o,label:a.label||o,description:a.description||"",source:a.source,action:"pi-prompt"})}return[...n.values()].sort((a,o)=>{const l=Sa[a.source]-Sa[o.source];return l!==0?l:a.command.localeCompare(o.command)})}function Zz(e,t){const n=(t.trim().split(/\s+/,1)[0]??"").toLowerCase();if((/\s/.test(t.trimStart().slice(1))||t.includes(" "))&&t.trimStart().includes(" "))return[];const s=n.startsWith("/")?n:n?`/${n}`:"/",r=s==="/"?"":s.slice(1),a=[];for(const o of e){const l=o.command.toLowerCase(),c=l.startsWith("/")?l.slice(1):l,d=o.description.toLowerCase();let u=100;if(!r)u=10+Sa[o.source];else if(l===s||c===r)u=0;else if(l.startsWith(s)||c.startsWith(r))u=1;else if(c.includes(r)||l.includes(r))u=2;else if(d.includes(r))u=3;else continue;a.push({...o,score:u})}return a.sort((o,l)=>{if(o.score!==l.score)return o.score-l.score;const c=Sa[o.source]-Sa[l.source];return c!==0?c:o.command.localeCompare(l.command)})}const Xz={operator:"Operator",web:"Pi Web",extension:"Extensions",prompt:"Prompts",skill:"Skills"},Jz=new Set(["operatorCapabilities","operationList","operationGet","operationEventSummary","statsContext","sourceInstructions","spineCheck","inspect","observeLink"]);function Qz(e){return Jz.has(e)?"technical-only":e==="doctor"?"inline-detail":"activity-detail"}const eH={newTask:"创建任务",importPrd:"任务需求",contractShow:"任务边界",contractApply:"更新任务契约",contractDiff:"任务契约差异",contractDraftSave:"任务契约草稿",contractValidate:"检查任务契约",taskAdvance:"推进任务准备",dagRunTask:"执行流程",dagValidate:"校验执行流程",prepareDagConfirmation:"执行确认",confirmDagConfirmation:"确认执行边界",prepareDagExecution:"执行边界",runDag:"任务执行",operationWait:"执行监督",operationGet:"任务活动详情",operationList:"会话活动",operationEventSummary:"执行进展摘要",dagStatus:"执行状态",dagDoctor:"执行诊断",dagReport:"执行结果",dagRerunPlan:"节点恢复评估",dagRerun:"从失败节点恢复",dagInterruptEligibility:"中止资格",standaloneTaskRerun:"带反馈重新执行",workerTaskRetry:"重试 Worker 任务",workerPoolDoctor:"任务池诊断",promoteRun:"任务推进",status:"任务状态"},tH={newTask:{running:"正在创建任务",success:"任务已经创建",error:"创建任务时遇到问题"},importPrd:{running:"正在整理并导入任务需求",success:"任务需求已经导入",error:"导入任务需求时遇到问题"},contractShow:{running:"正在读取任务目标和执行边界",success:"任务目标与执行边界已经读取",error:"读取任务边界时遇到问题"},taskAdvance:{running:"正在推进任务契约并准备执行流程",success:"任务已经推进到下一安全阶段",error:"任务推进被契约或执行边界阻塞"},dagRunTask:{running:"正在生成并校验执行流程",success:"执行流程已经准备好",error:"准备执行流程时遇到问题"},prepareDagExecution:{running:"正在确认任务可以安全执行",success:"执行边界已经确认",error:"执行边界尚未通过确认"},runDag:{running:"正在启动任务执行",success:"任务执行已经启动",error:"启动任务执行时遇到问题"},dagReport:{running:"正在读取本次执行结果",success:"本次执行结果已经读取",error:"读取执行结果时遇到问题"},dagRerunPlan:{running:"正在评估能否从失败节点安全恢复",success:"节点恢复条件评估已经完成",error:"暂时无法确定安全的恢复方式"},dagRerun:{running:"正在创建节点恢复 run",success:"节点恢复 run 已经启动",error:"从失败节点恢复时遇到问题"},dagInterruptEligibility:{running:"正在检查能否协作中止此运行",success:"中止资格已经确认",error:"当前运行不能协作中止"},standaloneTaskRerun:{running:"正在创建新的完整 DAG,并带入上一轮未解决反馈",success:"新的完整 DAG 已经按上一轮反馈重新执行",error:"带反馈重新执行任务时遇到问题"},workerPoolDoctor:{running:"正在读取任务池状态",success:"任务池状态已经读取",error:"读取任务池状态时遇到问题"},promoteRun:{running:"正在推进任务状态",success:"任务状态已经更新",error:"推进任务状态时遇到问题"},status:{running:"正在读取任务状态",success:"任务状态已经更新",error:"读取任务状态时遇到问题"},contractApply:{running:"正在应用任务契约变更",success:"任务契约已经更新",error:"应用任务契约变更时遇到问题"},contractDiff:{running:"正在比较任务契约版本",success:"任务契约差异已经读取",error:"比较任务契约时遇到问题"},contractDraftSave:{running:"正在保存任务契约草稿",success:"任务契约草稿已经保存",error:"保存任务契约草稿时遇到问题"},contractValidate:{running:"正在检查任务契约",success:"任务契约检查已经完成",error:"任务契约检查没有通过"},dagValidate:{running:"正在校验执行流程",success:"执行流程校验已经通过",error:"执行流程校验没有通过"},prepareDagConfirmation:{running:"正在准备执行确认",success:"执行确认已经准备好",error:"准备执行确认时遇到问题"},confirmDagConfirmation:{running:"正在确认执行边界",success:"执行边界已经确认",error:"执行边界尚未通过确认"},operationGet:{running:"正在读取任务活动详情",success:"任务活动详情已经读取",error:"读取任务活动详情时遇到问题"},operationList:{running:"正在读取本次对话的活动",success:"本次对话的活动已经读取",error:"读取对话活动时遇到问题"},operationEventSummary:{running:"正在汇总执行进展",success:"执行进展已经汇总",error:"汇总执行进展时遇到问题"},dagStatus:{running:"正在读取执行状态",success:"执行状态已经更新",error:"读取执行状态时遇到问题"},dagDoctor:{running:"正在诊断本次任务执行",success:"任务执行诊断已经完成",error:"诊断任务执行时遇到问题"},workerTaskRetry:{running:"正在重试失败的任务",success:"失败任务已经重新开始",error:"重试失败任务时遇到问题"},doctor:{running:"正在检查运行环境",success:"运行环境检查已经完成",error:"运行环境检查发现问题"},inspect:{running:"正在读取详细运行信息",success:"详细运行信息已经读取",error:"读取详细运行信息时遇到问题"},observeLink:{running:"正在准备运行看板入口",success:"运行看板入口已经准备好",error:"准备运行看板入口时遇到问题"},operatorCapabilities:{running:"正在读取可用操作能力",success:"可用操作能力已经读取",error:"读取可用操作能力时遇到问题"},sourceInstructions:{running:"正在读取任务来源说明",success:"任务来源说明已经读取",error:"读取任务来源说明时遇到问题"},spineCheck:{running:"正在检查计划执行步骤",success:"计划执行步骤检查已经完成",error:"计划执行步骤检查发现问题"},statsContext:{running:"正在统计上下文使用情况",success:"上下文使用情况已经统计完成",error:"统计上下文使用情况时遇到问题"}},nH=[{pattern:/(?:^|-)contract(?:-pi)?$/i,running:"正在核对任务目标和执行边界",finished:"任务目标与执行边界已确认",error:"任务边界存在冲突,需要先处理"},{pattern:/scout-src/i,running:"正在梳理与任务相关的代码",finished:"相关代码范围已梳理",error:"梳理相关代码时遇到问题"},{pattern:/scout-tests/i,running:"正在检查现有测试和验证方式",finished:"现有测试与验证方式已确认",error:"检查现有测试时遇到问题"},{pattern:/plan/i,running:"正在整理具体实施步骤",finished:"实施步骤已经准备好",error:"实施方案还需要进一步完善"},{pattern:/implement|writer/i,running:"正在修改并保存相关文件",finished:"文件修改已经完成",error:"修改文件时遇到问题"},{pattern:/verify|reverify/i,running:"正在验证本次修改",finished:"本次修改已通过验证",error:"验证没有通过,正在检查原因"},{pattern:/review/i,running:"正在检查改动是否完整",finished:"改动完整性检查已通过",error:"发现需要补充或修正的内容"},{pattern:/closeout/i,running:"正在整理交付结果",finished:"任务已经完成并形成交付记录",error:"交付结果尚未整理完整"}];function LC(e){if(!(!e||typeof e!="object"))return e}function OC(e){if(e&&typeof e=="object")return e;if(typeof e=="string")try{return LC(JSON.parse(e))}catch{return}}function y0(e){const n=OC(e)?.operationId;return typeof n=="string"&&n?n:void 0}function lb(e){const t=e.operationId??y0(e.args)??y0(e.result)??y0(e.resultText);return t?`operation:${t}`:`tool:${e.id}`}function sH(e){if(e.toolName!=="operationWait")return;const t=lb(e);if(t.startsWith("operation:"))return{id:`dag-progress:${t}`,activityRef:t}}function rH(e){return e==="running"?"progress":e==="error"?"error":"success"}function iH(e){return OC(e.resultText??e.result)}function aH(e){return Array.isArray(e.events)?e.events.flatMap(t=>{const n=LC(t);if(!n)return[];const s=n.messagePreview??n.message;return typeof s=="string"?[s]:[]}):[]}function oH(e,t,n){const s=[];for(const c of e)for(const d of c.matchAll(/node-(started|finished)[^\n]*?node=([^\s,]+)/gi)){const u=d[1]?.toLowerCase(),h=d[2]??"",p=c.match(/status=([^\s,]+)/i)?.[1]?.toUpperCase();let m="finished";p==="ERROR"||p==="FAILED"?m="error":u==="started"&&(m="running"),s.push({node:h,status:m})}const r=s.at(-1);if(!r)return;const a=s.some(c=>/scout-src/i.test(c.node)&&c.status==="finished"),o=s.some(c=>/scout-tests/i.test(c.node)&&c.status==="finished");if(a&&o)return{id:t,kind:"success",title:"代码与测试的影响范围已确认",activityRef:n};const l=nH.find(c=>c.pattern.test(r.node));return l?r.status==="running"?{id:t,kind:"progress",title:l.running,activityRef:n}:r.status==="error"?{id:t,kind:"error",title:l.error,activityRef:n}:{id:t,kind:"success",title:l.finished,activityRef:n}:{id:t,kind:"success",title:"执行状态已经更新",activityRef:n}}function lH(e){const t=lb(e),n=`activity:${e.id}`;if(e.status==="running")return{id:n,kind:"progress",title:"正在等待新的执行进展",activityRef:t};if(e.status==="error")return{id:n,kind:"error",title:"等待执行进展时遇到问题",activityRef:t};let s="";typeof e.resultText=="string"?s=e.resultText:typeof e.result=="string"&&(s=e.result);const r=iH(e),a=oH([s,...r?aH(r):[]],n,t);if(a)return a;if(r){if(r.timedOut===!0||r.changed===!1)return{id:n,kind:"warning",title:"等待期间没有新的执行进展",activityRef:t};if(r.changed===!0)return{id:n,kind:"success",title:"已经收到新的执行进展",activityRef:t}}return{id:n,kind:"success",title:"执行状态已经更新",activityRef:t}}function cH(e){const t=Qz(e.toolName);if(t==="technical-only"||t==="inline-detail")return;if(e.toolName==="operationWait")return lH(e);const n=tH[e.toolName];if(!n)return;let s=n.success;return e.status==="running"?s=n.running:e.status==="error"&&(s=n.error),{id:`activity:${e.id}`,kind:rH(e.status),title:s,activityRef:lb(e)}}function DC(e){return eH[e]??"任务活动"}function cb(e){switch(e){case"starting":return{label:"正在启动",kind:"progress"};case"running":return{label:"运行中",kind:"progress"};case"succeeded":case"finished":case"FINISHED":case"pass":return{label:"已完成",kind:"success"};case"failed":case"partial_failed":case"ERROR":case"FAILED":case"timed-out":return{label:"未完成",kind:"error"};case"needs-reconcile":return{label:"需要同步",kind:"warning"};case"cancelled":case"abandoned":case"superseded":return{label:"已停止",kind:"warning"};default:return{label:"状态已更新",kind:"success"}}}function PC(e){return[e.activityRef??`operation:${e.operationId}`,`operation:${e.operationId}`,...e.toolCallId?[`tool:${e.toolCallId}`]:[]]}function $C(e){return[e.activityRef??`gate:${e.cardId}`]}function BC(e){return[e.activityRef??`artifact:${e.artifactId}`]}function dH(e){return new Set([...e.operations.flatMap(PC),...e.gates.flatMap($C),...e.artifacts.flatMap(BC)])}function xS(e){return e.updatedSeq??e.eventSeq}function yS(e){const t=Date.parse(e.updatedAt);return Number.isFinite(t)?t:0}function db(e,t){const n=xS(e),s=xS(t);return n!==void 0&&s!==void 0?n-s:yS(e)-yS(t)}function uH(e){return e.taskId?`task:${e.taskId}`:e.dagRunId?`run:${e.dagRunId}`:`operation:${e.operationId}`}function hH(e){return e.taskId?e.taskId.replace(/^\d{4}-\d{2}-\d{2}-/,"").replace(/[-_]+/g," ").trim()||e.taskId:DC(e.action)}function fH(e){return[...new Set(e)]}function mH(e){const t=new Map;for(const n of e)t.set(n.action,n);return[...t.values()].sort(db).map(n=>{const s=cb(n.state);return{id:n.operationId,label:DC(n.action),stateLabel:s.label,kind:s.kind,at:n.updatedAt}})}function pH(e){const t=new Map;for(const n of e){const s=n.dagRunId??n.runSummary?.runId;if(!s)continue;const r=t.get(s)??[];r.push(n),t.set(s,r)}return[...t.entries()].flatMap(([n,s])=>{const r=[...s].sort((d,u)=>db(u,d)),a=r[0];if(!a)return[];const o=r.find(d=>d.runSummary)?.runSummary,l=o?.status??a.state,c=cb(l);return[{runId:n,state:l,stateLabel:c.label,kind:c.kind,updatedAt:a.updatedAt,operationCount:s.length,firstFailedNode:o?.nodes.find(d=>d.status==="ERROR")?.id,failureCategory:o?.failureCategory,inspectHref:a.inspectHref}]}).sort((n,s)=>Date.parse(s.updatedAt)-Date.parse(n.updatedAt))}function FC(e){const t=new Map;for(const n of e){const s=uH(n),r=t.get(s)??[];r.push(n),t.set(s,r)}return[...t.entries()].flatMap(([n,s])=>{const r=[...s].sort(db),a=r.at(-1);if(!a)return[];const o=cb(a.state);return[{key:n,taskId:a.taskId,displayTitle:hH(a),state:a.state,stateLabel:o.label,kind:o.kind,updatedAt:a.updatedAt,latestOperation:a,operations:r,steps:mH(r),runs:pH(r),activityRefs:fH(r.flatMap(PC)),compactEligible:o.kind==="success"}]}).sort((n,s)=>{const r=n.kind==="progress"||n.kind==="error"?0:1,a=s.kind==="progress"||s.kind==="error"?0:1;return r!==a?r-a:Date.parse(s.updatedAt)-Date.parse(n.updatedAt)})}const gH={operation:"执行记录",contract:"任务契约",dag:"执行流程",report:"报告",html:"HTML 预览"};function vH(e){const{artifact:t}=e,n=!!(t.reportText||t.htmlPreview);return i.jsxs("section",{className:"oc-artifact-card","aria-label":`任务产物:${t.title??t.artifactId}`,"data-activity-ref":t.activityRef??`artifact:${t.artifactId}`,children:[i.jsxs("header",{children:[i.jsxs("div",{children:[i.jsx("small",{children:"任务产物"}),i.jsx("strong",{children:t.title??t.artifactId}),i.jsx("code",{children:t.artifactId})]}),i.jsx("span",{children:gH[t.kind]})]}),t.summary?i.jsx("p",{children:t.summary}):null,n?i.jsxs("details",{className:"oc-artifact-details",children:[i.jsx("summary",{children:"预览与技术详情"}),t.reportText?i.jsx("pre",{children:t.reportText}):null,t.htmlPreview?i.jsx("iframe",{title:`${t.title??t.artifactId} preview`,sandbox:"",srcDoc:t.htmlPreview}):null]}):null,t.inspectHref?i.jsx("footer",{children:i.jsx(pi,{className:"btn btn-ghost",href:t.inspectHref,children:"打开产物"})}):null]})}const wS={prepared:"等待确认",confirmed:"已经确认",dispatched:"正在执行",consumed:"已经完成",stale:"已经失效",expired:"已经过期",error:"处理失败"};function SS(e){return e.gateType==="contract-apply"?"确认任务契约变更":e.gateType==="mutation"?"确认执行工作区修改":"确认启动任务执行"}function bH({card:e,origin:t,sessionId:n}){const[s,r]=f.useState(!1),[a,o]=f.useState(),l=async()=>{r(!0),o(void 0);try{let h="contract-apply";e.gateType==="dag-run"?h=e.state==="prepared"?"dag-confirm":"dag-run":e.gateType==="mutation"&&(h="mutation-apply");const p=e.gateType==="dag-run"?{confirmationId:e.confirmationId,...e.state==="prepared"?{humanGateToken:e.humanGateToken}:{}}:{receiptId:e.receiptId,humanGateToken:e.humanGateToken},m=await fetch(`${t}/api/operator/v1/chat/sessions/${encodeURIComponent(n)}/human-gate/${h}`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","x-loop-console-confirmation":Rt()},body:JSON.stringify(p)}),g=await m.json();if(!m.ok)throw new Error(g.error?.message??`HTTP ${m.status}`)}catch(h){o(h instanceof Error?h.message:String(h))}finally{r(!1)}},c=e.state==="prepared"||e.gateType==="dag-run"&&e.state==="confirmed";let d="确认接受";e.gateType==="mutation"?d="确认执行":e.gateType==="dag-run"&&(d=e.state==="prepared"?"确认边界":"启动执行");const u=(e.displayOnlyChallenges?.length??0)+(e.dagSpine?.length??0);return i.jsxs("section",{className:`oc-human-gate-card is-${e.state}`,"aria-label":`${SS(e)}:${wS[e.state]}`,"data-activity-ref":e.activityRef??`gate:${e.cardId}`,children:[i.jsxs("header",{children:[i.jsxs("div",{children:[i.jsx("small",{children:"人工门禁"}),i.jsx("strong",{children:SS(e)}),i.jsx("code",{children:e.taskId})]}),i.jsx("span",{children:wS[e.state]})]}),e.contractDiffSummary?i.jsx("p",{className:"oc-human-gate-summary",children:e.contractDiffSummary}):null,u>0||e.errorMessage?i.jsxs("details",{className:"oc-human-gate-details",children:[i.jsxs("summary",{children:["门禁详情 · ",u," 项"]}),e.displayOnlyChallenges?.length?i.jsxs("div",{className:"oc-human-gate-challenges",children:[i.jsx("b",{children:"确认前请检查"}),i.jsx("ul",{children:e.displayOnlyChallenges.map(h=>i.jsx("li",{children:h},h))})]}):null,e.dagSpine?.length?i.jsxs("div",{children:[i.jsx("b",{children:"计划执行步骤"}),i.jsx("ol",{children:e.dagSpine.map(h=>i.jsx("li",{children:i.jsx("code",{children:h})},h))})]}):null,e.errorMessage?i.jsx("p",{className:"oc-human-gate-error",children:e.errorMessage}):null]}):null,i.jsxs("footer",{children:[i.jsx(pi,{className:"btn btn-ghost",href:e.inspectHref,destination:e.gateType==="mutation"?void 0:{taskId:e.taskId},children:e.gateType==="mutation"?"查看工作区":"查看记录"}),i.jsx("button",{className:"btn btn-primary",type:"button",disabled:!c||s,onClick:()=>{l()},children:s?"提交中…":d})]}),a?i.jsx("div",{className:"oc-human-gate-error",children:a}):null]})}const xH={validation:"节点输出未通过契约或门禁校验。可在恢复页从失败节点重跑;若错误指向任务契约(如验证命令、Mock 策略),先修正任务配置并重新生成 DAG。",executor:"执行器或模型提供方调用失败(网络、配额或运行时错误)。稍后可在恢复页从失败节点重跑;反复出现请到「模型与认证」页检查配置与凭据。","write-guard":"写入越过了授权边界(writeSet / allowedPaths)。检查计划中的写入路径是否越界,修正后从失败节点重跑。",timeout:"节点执行超时。可在恢复页从失败节点重跑;反复超时建议缩小任务范围或排查卡住的命令。",auth:"模型或服务认证失败。请先到「模型与认证」页检查 API Key 与模型配置,再从失败节点重跑。","human-required":"节点正在等待人工审批。完成审批后该节点可继续执行;也可在恢复页查看对账状态。","human-rejected":"人工审批被拒绝。请调整任务描述或契约后重新发起任务。","shell-command":"验证/构建命令以非零退出。进入 DAG 查看命令输出定位具体失败,修复后从失败节点重跑。","static-error":"静态检查(typecheck / lint 等)失败。修复对应代码错误后从失败节点重跑。","decision-envelope":"决策与证据不匹配(决策包络校验失败)。进入 DAG 查看节点决策依据,修正后重跑。",unknown:"失败原因未归类。进入 DAG 查看节点详情,或在恢复页使用对账 / 诊断入口。"};function yH(e){if(e)return xH[e]}function _S(e,t=900){if(e)return e.length>t?`${e.slice(0,t)}…`:e}function w0(e){return new Date(e).toLocaleString()}function kS(e){if(!e)return;const t=e.trim();if(/taskId[^\n]*(?:placeholder|占位)|["']?<id>["']?/i.test(t))return"任务编号仍是占位符;请提供实际的 YYYY-MM-DD-<slug> 任务编号后重试。";if(/ENOENT|no such file or directory/i.test(t))return"任务活动缺少所需文件或目录,可进入 DAG 查看详情。";if(/command failed|exited with code/i.test(t))return"相关命令没有成功完成,可进入 DAG 查看详情。";if(!(t.length>220||t.startsWith("{")||t.startsWith("[")||t.includes("[dag execute]")||t.includes("schemaVersion")||/[A-Za-z]:\\/.test(t)))return t}function wH(e){const t=e.latestOperation,n=t.runSummary;if(e.kind==="success"||e.kind==="progress")return;const s=n?.nodes.find(o=>o.status==="ERROR")?.id;if(s){const o=n?.failureCategory?`,原因分类为 ${n.failureCategory}`:"";return`执行在 ${s} 阶段未完成${o}。`}const r=n?.next?.description;if(r&&/fail|error|block|cannot|unable/i.test(r))return r;const a=kS(t.stderrPreview)??kS(t.summaryPreview);return a||(e.kind==="error"?"本次任务活动没有完成,可进入 DAG 查看详情或使用恢复选项。":"本次任务活动需要进一步确认,请查看相关记录。")}function SH(e){const{journey:t}=e,n=t.latestOperation,s=t.runs[0],r=t.runs.slice(1),a=n.inspectHref,o={dagRunId:n.dagRunId??s?.runId,taskId:t.taskId},l=wH(t),c=t.kind==="error"||t.kind==="warning",d=t.latestOperation.runSummary,u=d?.nodes.find(m=>m.failureCategory)?.failureCategory??d?.failureCategory,h=c?yH(u):void 0,p=(m,g)=>{e.onNavigateWorkspace?e.onNavigateWorkspace(m,g):window.location.assign(J8(m,g))};return e.compact?i.jsxs("details",{className:"oc-journey-compact",children:[i.jsxs("summary",{children:[i.jsx("span",{className:`oc-journey-dot is-${t.kind}`,"aria-hidden":"true"}),i.jsxs("span",{children:[i.jsx("strong",{children:t.displayTitle}),i.jsxs("small",{children:[t.stateLabel," · ",w0(t.updatedAt)]})]}),i.jsx("span",{"aria-hidden":"true",children:"›"})]}),i.jsxs("div",{className:"oc-journey-compact-body",children:[t.taskId?i.jsx("code",{children:t.taskId}):null,i.jsx(pi,{className:"btn btn-ghost",href:a,destination:o,children:"查看记录"})]})]}):i.jsxs("section",{className:`oc-task-journey-card is-${t.kind}`,"aria-label":`${t.displayTitle}:${t.stateLabel}`,children:[i.jsxs("header",{className:"oc-journey-head",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"oc-journey-state-line",children:[i.jsx("span",{className:`oc-journey-dot is-${t.kind}`,"aria-hidden":"true"}),i.jsx("span",{children:t.stateLabel})]}),i.jsx("strong",{children:t.displayTitle}),t.taskId?i.jsxs("small",{children:["Task · ",i.jsx("code",{children:t.taskId})]}):null]}),i.jsx("time",{dateTime:t.updatedAt,children:w0(t.updatedAt)})]}),i.jsx("div",{className:"oc-journey-steps","aria-label":"任务旅程",children:t.steps.slice(-6).map(m=>i.jsxs("div",{className:"oc-journey-step",children:[i.jsx("span",{className:`oc-journey-step-icon is-${m.kind}`,"aria-hidden":"true",children:m.kind==="success"?"✓":m.kind==="error"?"!":"•"}),i.jsx("span",{children:m.label}),i.jsx("small",{children:m.stateLabel})]},m.id))}),l?i.jsxs("div",{className:`oc-journey-outcome is-${t.kind}`,children:[i.jsx("strong",{children:c?"当前问题":"最新结果"}),i.jsx("p",{children:l}),h?i.jsxs("p",{className:"oc-journey-advice","data-testid":"oc-journey-advice",children:["建议:",h]}):null]}):null,s?i.jsxs("div",{className:"oc-journey-latest-run",children:[i.jsx("span",{children:"最新执行"}),i.jsx("code",{children:s.runId}),i.jsx("b",{className:`is-${s.kind}`,children:s.stateLabel}),s.firstFailedNode?i.jsxs("small",{children:["失败阶段 · ",s.firstFailedNode]}):null]}):null,r.length>0?i.jsxs("details",{className:"oc-journey-history",children:[i.jsxs("summary",{children:["执行历史 ",t.runs.length," 次"]}),i.jsx("div",{children:t.runs.map(m=>i.jsxs("div",{className:"oc-journey-run-row",children:[i.jsx("code",{children:m.runId}),i.jsx("span",{className:`is-${m.kind}`,children:m.stateLabel}),m.firstFailedNode?i.jsx("small",{children:m.firstFailedNode}):null,i.jsx("time",{dateTime:m.updatedAt,children:w0(m.updatedAt)})]},m.runId))})]}):null,i.jsxs("footer",{className:"oc-journey-actions",children:[i.jsx(pi,{className:"btn btn-ghost",href:a,destination:o,children:o.dagRunId?"进入 DAG":"查看记录"}),c&&(t.taskId||n.dagRunId)?i.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>p("recovery",{taskId:t.taskId,dagRunId:n.dagRunId}),children:"恢复选项"}):null]}),i.jsxs("details",{className:"oc-journey-technical",children:[i.jsxs("summary",{children:["技术详情 · ",t.operations.length," 项活动"]}),i.jsx("div",{className:"oc-journey-technical-body",children:t.operations.map(m=>i.jsxs("div",{className:"oc-journey-operation-row",children:[i.jsxs("div",{children:[i.jsx("code",{children:m.operationId}),i.jsx("span",{children:m.action})]}),m.dagRunId?i.jsxs("small",{children:["run · ",m.dagRunId]}):null,m.controller?i.jsxs("small",{children:["controller · ",m.controller]}):null,m.stderrPreview?i.jsx("pre",{className:"is-error",children:_S(m.stderrPreview)}):null,m.summaryPreview?i.jsx("pre",{children:_S(m.summaryPreview)}):null]},m.operationId))})]})]})}function CS(e){return e.state==="prepared"||e.state==="confirmed"?0:e.state==="dispatched"?1:e.state==="error"?2:3}function S0(e,t){return e!==null&&t.includes(e)}function _H(e){return e.operations>0?"operations":e.gates>0?"gates":"artifacts"}function kH(e){const t=f.useRef(null),[n,s]=f.useState("operations"),r=f.useMemo(()=>FC(e.operationCards),[e.operationCards]),a=r.length+e.humanGateCards.length+e.artifactCards.length,o=f.useMemo(()=>[...e.humanGateCards].sort((c,d)=>{const u=CS(c)-CS(d);return u!==0?u:(d.eventSeq??0)-(c.eventSeq??0)}),[e.humanGateCards]),l=f.useMemo(()=>[...e.artifactCards].sort((c,d)=>(d.eventSeq??0)-(c.eventSeq??0)),[e.artifactCards]);return f.useEffect(()=>{s(_H({operations:r.length,gates:e.humanGateCards.length,artifacts:e.artifactCards.length}))},[e.sessionId]),f.useEffect(()=>{e.focusRef&&(e.focusRef.startsWith("gate:")?s("gates"):e.focusRef.startsWith("artifact:")?s("artifacts"):s("operations"))},[e.focusRef]),f.useEffect(()=>{if(!e.focusRef)return;const c=window.requestAnimationFrame(()=>{const d=t.current;if(!d)return;Array.from(d.querySelectorAll("[data-activity-ref], [data-tool-call-id], [data-activity-refs]")).find(p=>{const m=p.dataset.activityRefs?.split(" ")??[];return p.dataset.activityRef===e.focusRef||m.includes(e.focusRef??"")||p.dataset.toolCallId&&`tool:${p.dataset.toolCallId}`===e.focusRef})?.scrollIntoView({block:"nearest",behavior:"smooth"})});return()=>window.cancelAnimationFrame(c)},[n,e.focusRef]),a===0?null:i.jsxs("section",{ref:t,id:"oc-activity-panel",className:"oc-activity-rail is-embedded","aria-label":"本次对话的活动",children:[i.jsxs("header",{className:"oc-activity-rail-head",children:[i.jsxs("div",{children:[i.jsx("strong",{children:"本次对话的活动"}),i.jsx("small",{children:"运行、门禁与任务产物"})]}),i.jsx("span",{className:"oc-activity-count",children:a})]}),i.jsxs("div",{className:"oc-activity-content",children:[i.jsxs("div",{className:"oc-activity-tabs",role:"tablist","aria-label":"活动类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":n==="operations",className:n==="operations"?"is-active":"",onClick:()=>s("operations"),children:["运行 ",i.jsx("span",{children:r.length})]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":n==="gates",className:n==="gates"?"is-active":"",onClick:()=>s("gates"),children:["门禁 ",i.jsx("span",{children:o.length})]}),i.jsxs("button",{type:"button",role:"tab","aria-selected":n==="artifacts",className:n==="artifacts"?"is-active":"",onClick:()=>s("artifacts"),children:["产物 ",i.jsx("span",{children:l.length})]})]}),i.jsxs("div",{className:"oc-activity-list",children:[n==="operations"&&r.length===0?i.jsx("div",{className:"oc-activity-empty",children:"本次对话还没有任务执行记录。"}):null,n==="operations"?r.map((c,d)=>{const u=c.activityRefs;return i.jsxs("div",{"data-activity-refs":u.join(" "),className:`oc-activity-card-wrap${S0(e.focusRef,u)?" is-focused":""}`,children:[i.jsx(SH,{journey:c,compact:d>0&&c.compactEligible,origin:e.origin,onNavigateWorkspace:e.onNavigateWorkspace}),i.jsx("button",{type:"button",className:"oc-activity-locate",onClick:()=>e.onLocateConversation(u),children:"查看对话位置"})]},c.key)}):null,n==="gates"&&o.length===0?i.jsx("div",{className:"oc-activity-empty",children:"本次对话还没有需要展示的门禁。"}):null,n==="gates"?o.map(c=>{const d=$C(c);return i.jsx("div",{className:`oc-activity-card-wrap${S0(e.focusRef,d)?" is-focused":""}`,children:i.jsx(bH,{card:c,origin:e.origin,sessionId:e.sessionId})},c.cardId)}):null,n==="artifacts"&&l.length===0?i.jsx("div",{className:"oc-activity-empty",children:"本次对话还没有任务产物。"}):null,n==="artifacts"?l.map(c=>{const d=BC(c);return i.jsx("div",{className:`oc-activity-card-wrap${S0(e.focusRef,d)?" is-focused":""}`,children:i.jsx(vH,{artifact:c})},c.artifactId)}):null]})]},e.sessionId)]})}function CH(e,t){const n=Date.parse(e.updatedAt),s=Date.parse(t.updatedAt);return Number.isFinite(n)&&Number.isFinite(s)&&n!==s?n-s:(e.updatedSeq??e.eventSeq??0)-(t.updatedSeq??t.eventSeq??0)}function IH(e){let t;for(const n of e)n.dagRunId&&(!t||CH(n,t)>0)&&(t=n);return t?.dagRunId??null}function EH(e,t){return e.find(n=>(n.activityRef??`operation:${n.operationId}`)===t)?.dagRunId}const IS={comfortableMin:620,compactMin:480};function NH(e){return!Number.isFinite(e)||e<0?"extra-compact":e>=IS.comfortableMin?"comfortable":e>=IS.compactMin?"compact":"extra-compact"}function jH(e){return`is-landing-${e}`}const TH=["我要新建任务。请先做需求分析,不要用一句话直接 bootstrapFromPrd。","1. 先问我需求内容和范围(frontend / backend / both,默认 both)。","2. 使用 analyze-product-requirements 完成澄清访谈、校验和需求产物。","3. Product Requirement 为 complete 且校验通过后,使用 analyze-product-dependencies 完成依赖分析和按需的 API 文档。","4. 两套产物都校验通过后,再用 controller-owned bootstrapFromPrd 准备 task advance,并建议 taskKind。"].join(`
|
|
437
437
|
`),RH=[{label:"新建任务",hint:"先走需求分析 skills,再导入创建任务",prompt:TH,requiresWorkflowIntake:!0},{label:"查看任务状态",hint:"列出任务与就绪/阻塞状态",prompt:"列出当前所有 task 及其状态,重点说明哪些是 Ready 可以推进、哪些 Blocked 及阻塞原因。"},{label:"诊断 DAG 运行",hint:"对失败运行跑 Doctor",prompt:"帮我诊断最近失败或异常的 DAG 运行:先列出最近的 DAG 运行,对有问题的运行执行 doctor,总结根因和可执行的恢复方案。"},{label:"恢复或重跑任务",hint:"默认从节点续跑,勿无故新开 task",prompt:"我要恢复失败或卡住的 DAG。请先 dagReport/dagDoctor 看 primaryFailure.nodeId 与 primaryRecovery;默认用 dagRerunPlan→dagRerun 从失败节点续跑(plan 合格后直接 dagRerun,不要 prepareMutationGate)。不要新建 task-id。plan 不合格时:Worker Task Pool Failed 用 workerPoolDoctor 确认后再 workerTaskRetry;独立 Console run 用 standaloneTaskRerun(整单重生,不是从节点续跑)。paused/中断需要 resume 时准备 Human Gate,不要自己调 dagResume。确定后直接帮我发起。"}];function zC(e){const t=e.readiness==="setup-required",n=!!e.disabled||t,s=e.density??"comfortable",r=e.sessionMode??$r,a=Ca[r],o=r==="workflow",l=e.workflowIntake?.status==="ready",c=e.workflowIntake?.status==="blocked",d=e.mode==="no-session"?a.landingTitle:a.emptyTitle,u=e.mode==="no-session"?a.landingBody:a.emptyBody;return i.jsxs("div",{className:`oc-empty ${jH(s)}`,role:"status","data-landing-density":s,"data-session-mode":r,children:[i.jsxs("div",{className:"oc-empty-hero",children:[i.jsx("img",{className:"oc-empty-icon oc-empty-brand",src:"/favicon.svg",alt:"","aria-hidden":"true",draggable:!1}),i.jsxs("div",{className:"oc-empty-copy",children:[i.jsx("h3",{children:d}),i.jsx("p",{children:u})]})]}),o?i.jsx("div",{className:"oc-suggestions","aria-label":"开场建议",children:RH.map(h=>i.jsxs("button",{type:"button",className:"oc-suggestion",onClick:()=>e.onSuggest(h.prompt),disabled:n||!!(h.requiresWorkflowIntake&&!l),children:[i.jsx("strong",{children:h.label}),i.jsx("span",{children:s==="extra-compact"?h.hint.replace(/[,,].*$/,""):h.hint})]},h.label))}):null,o&&c?i.jsxs("p",{className:"oc-empty-capability-error",role:"alert",children:[i.jsx("strong",{children:e.workflowIntake?.code}),i.jsx("span",{children:e.workflowIntake?.message})]}):null,i.jsxs("ul",{className:"oc-empty-tips",children:[i.jsxs("li",{children:[i.jsx("kbd",{children:"@"}),i.jsx("span",{children:"引用仓库文件"})]}),i.jsxs("li",{children:[i.jsx("kbd",{children:"/"}),i.jsx("span",{children:"快捷命令"})]}),i.jsxs("li",{children:[i.jsx("kbd",{children:"Enter"}),i.jsx("span",{children:"发送 · Shift+Enter 换行"})]})]})]})}function AH(e){const[t,n]=f.useState(null),s=f.useRef(null),r=e.workspaces.find(c=>c.workspaceId===e.workspaceId),a=r?.name??"选择工作区",o=Ca[e.sessionMode],l=!!(e.creating||e.disabled);return f.useEffect(()=>{if(!t)return;const c=u=>{s.current?.contains(u.target)||n(null)},d=u=>{u.key==="Escape"&&n(null)};return document.addEventListener("mousedown",c),document.addEventListener("keydown",d),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("keydown",d)}},[t]),i.jsxs("div",{className:"oc-hero-chips",ref:s,children:[i.jsxs("div",{className:"oc-hero-chip-wrap",children:[i.jsxs("button",{type:"button",className:"oc-hero-chip","aria-label":"选择工作区","aria-haspopup":"menu","aria-expanded":t==="workspace",disabled:l||e.workspaces.length===0,onClick:()=>n(c=>c==="workspace"?null:"workspace"),children:[r?i.jsx(Zk,{size:16,"aria-hidden":"true"}):i.jsx(Yk,{size:16,"aria-hidden":"true"}),i.jsx("span",{children:a}),i.jsx(us,{size:14,"aria-hidden":"true"})]}),t==="workspace"?i.jsx("div",{className:"oc-hero-chip-menu",role:"menu","aria-label":"工作区",children:e.workspaces.map(c=>i.jsxs("button",{type:"button",role:"menuitem",className:c.workspaceId===e.workspaceId?"is-selected":void 0,onClick:()=>{n(null),c.workspaceId!==e.workspaceId&&e.onSelectWorkspace(c.workspaceId)},children:[i.jsx("span",{children:c.name}),i.jsx("span",{className:"oc-hero-chip-menu-desc",children:c.displayPath})]},c.workspaceId))}):null]}),i.jsxs("div",{className:"oc-hero-chip-wrap",children:[i.jsxs("button",{type:"button",className:"oc-hero-chip","aria-haspopup":"menu","aria-expanded":t==="mode","aria-label":"选择会话模式",title:"即将开始的这个会话所用的模式",disabled:l,onClick:()=>n(c=>c==="mode"?null:"mode"),children:[i.jsx("span",{children:o.label}),i.jsx(us,{size:14,"aria-hidden":"true"})]}),t==="mode"?i.jsx("div",{className:"oc-hero-chip-menu",role:"menu","aria-label":"会话模式",children:Vz.map(c=>i.jsxs("button",{type:"button",role:"menuitem",className:c===e.sessionMode?"is-selected":void 0,onClick:()=>{n(null),c!==e.sessionMode&&e.onSelectMode(c)},children:[i.jsx("span",{children:Ca[c].label}),i.jsx("span",{className:"oc-hero-chip-menu-desc",children:Ca[c].description})]},c))}):null]})]})}const HC="PROVIDER_EMPTY_COMPLETION";function MH(e){if(!(!e||typeof e!="object"))return e}function Ti(e){return typeof e=="string"?e:void 0}function Ud(e){if(!Array.isArray(e))return;const t=[];for(const n of e){const s=MH(n);if(!s)continue;const r=Ti(s.type)??"";if(r==="thinking"||r==="reasoning"){const a=Ti(s.thinking)??Ti(s.text)??"";t.push({type:"thinking",thinking:a});continue}if(r==="toolCall"||r==="tool_call"||r==="toolUse"||r==="tool_use"){const a=Ti(s.toolCallId)??Ti(s.id)??"";if(!a)continue;const o=Ti(s.toolName)??Ti(s.name);t.push({type:"toolCall",toolCallId:a,...o?{toolName:o}:{},...s.args!==void 0||s.arguments!==void 0?{args:s.args??s.arguments}:{}});continue}if(r==="text"||r==="output_text"||r===""){const a=Ti(s.text);if(a!==void 0){t.push({type:"text",text:a});continue}}t.push({type:"unknown",blockType:r===""?"unknown":r,data:n})}return t}function LH(e,t={}){return e.type==="thinking"&&!t.isStreaming&&e.thinking.trim()===""}function Hg(e,t={}){return e.filter(n=>!LH(n,t))}function ES(e){return e.type==="text"}function OH(e,t={}){const n=Hg(e,t);return t.isStreaming||n.some(r=>r.type==="toolCall")?{answerBlocks:[],processBlocks:n}:{answerBlocks:n.filter(r=>ES(r)&&r.text.trim()!==""),processBlocks:n.filter(r=>!ES(r))}}function DH(e){return e.filter(t=>t.type==="text").map(t=>t.text).join("")}function ju(e,t){return e.eventSeq!==void 0&&t.eventSeq!==void 0&&e.eventSeq!==t.eventSeq?e.eventSeq-t.eventSeq:e.createdAt!==t.createdAt?e.createdAt-t.createdAt:0}function qC(e){const t=[...e];for(let n=0;n<t.length;n+=1){const s=t[n];if(s?.role!=="assistant"||!s.clientRequestId)continue;const r=t.findIndex((o,l)=>l>n&&o.role==="user"&&o.clientRequestId===s.clientRequestId);if(r<0)continue;const[a]=t.splice(r,1);a&&t.splice(n,0,a),n+=1}return t}function PH(e){const t=e.files.filter(n=>n.path).sort((n,s)=>n.display.localeCompare(s.display));if(t.length!==0)return{sessionId:e.sessionId,turnId:e.turnId,...e.turnNumber===void 0?{}:{turnNumber:e.turnNumber},files:t,total:t.length,added:t.reduce((n,s)=>n+s.added,0),deleted:t.reduce((n,s)=>n+s.deleted,0),source:"tool-events",...e.failedTurn?{failedTurn:!0}:{}}}function $H(e,t,n){let s=e;for(const r of t){if(r.type!=="toolCall"||!r.toolName)continue;const a=s.find(l=>l.id===r.toolCallId);if(a&&a.phase!=="preparing")continue;const o={...n,...a,id:r.toolCallId,toolName:r.toolName,args:r.args,status:"running",phase:"preparing"};s=a?s.map(l=>l.id===r.toolCallId?o:l):[...s,o]}return s}function ml(e){return{eventSeq:e.anchorSeq,createdAt:e.at}}function BH(e,t){const n=e.createdAt??(e.kind==="tool"?e.tool.createdAt:void 0)??t.assistants[0]?.createdAt??0,s=e.eventSeq??(e.kind==="tool"?e.tool.eventSeq:void 0);return s===void 0?{createdAt:n}:{eventSeq:s,createdAt:n}}function FH(e,t){return ju(e.order,t.order)}function zH(e,t){if(e.kind==="tool")return`tool:${e.tool.id}`;if(e.kind==="activity")return`activity:${e.activity.id}`;if(e.kind==="dag-progress")return`dag-progress:${e.progress.id}`;const n=t.eventSeq??t.createdAt;return`${e.kind}:${n}`}function Lh(e){const t=e.conversationItems??[],n=t.filter(c=>c.kind==="request"||c.kind==="step"&&c.node.status==="running").sort((c,d)=>ju(ml(c.node),ml(d.node))),s=t.filter(c=>c.kind==="max-tokens"||c.kind==="turn-error").sort((c,d)=>ju(ml(c.node),ml(d.node))),r=new Set(n.map(c=>c.node.key)),a=new Set(s.map(c=>c.node.key)),o=[];for(const c of e.processItems)o.push({source:"process",key:"",item:c,order:BH(c,e)});for(const c of t)r.has(c.node.key)||a.has(c.node.key)||o.push({source:"conversation",key:`conversation:${c.node.key}`,item:c,order:ml(c.node)});o.sort(FH);const l=new Map;for(const c of o){const d=c.source==="conversation"?c.key:zH(c.item,c.order),u=l.get(d)??0;l.set(d,u+1),c.key=u===0?d:`${d}:${u}`}return{prelude:n,process:o,postAnswer:s}}function HH(e){const t=Lh(e);return{prelude:[],process:t.process.filter(n=>n.source==="process"||n.item.kind!=="request"&&n.item.kind!=="step"&&n.item.kind!=="diagnostic"),postAnswer:t.postAnswer}}function Oh(e){const t=new Map;for(const s of e.process)s.source==="process"&&s.item.kind==="tool"&&s.item.tool.toolName==="Agent"&&t.set(s.item.tool.id,[]);const n=[];for(const s of e.process){let r;if(s.source==="process"&&s.item.kind==="tool")r=s.item.tool.parentToolCallId;else if(s.source==="conversation"&&s.item.kind==="explore-note"){const o=s.item.node.data;typeof o.parentToolCallId=="string"&&typeof o.text=="string"&&o.text.trim()&&(r=o.parentToolCallId)}const a=r&&t.get(r);a?a.push(s):n.push(s)}return{main:{...e,process:n},byAgent:t}}function qH(e,t){return{key:e,kind:"turn",...t?{turnId:t}:{},assistants:[],tools:[],processItems:[],conversationItems:[],turnClosed:!1,live:!1}}function Tu(e,t){const n=[],s=[];let r,a=[];const o=l=>{for(const c of a)c.assistantMessageId||(c.assistantMessageId=l),c.turnId||(c.turnId=r);a=[]};for(const l of e){const c=Date.parse(l.at)||Date.now();if(l.role==="user"){r=l.turnId??`restored-${l.id}`,a=[],n.push({id:l.id,sourceMessageId:l.id,role:"user",text:l.text,createdAt:c,...l.clientRequestId?{clientRequestId:l.clientRequestId}:{},...l.eventSeq===void 0?{}:{eventSeq:l.eventSeq},...l.turnId?{turnId:l.turnId}:{},...l.attachments?.length?{attachments:l.attachments}:{},...l.references?.length?{references:structuredClone(l.references)}:{}});continue}if(l.role==="assistant"){l.turnId&&(r=l.turnId),r||(r=`restored-${l.id}`);const d=Ud(l.content);n.push({id:l.id,sourceMessageId:l.id,role:"assistant",text:l.text,createdAt:c,...l.eventSeq===void 0?{}:{eventSeq:l.eventSeq},...l.turnId?{turnId:l.turnId}:{},...l.kind==="provider-error"&&l.providerError?{kind:l.kind,providerError:l.providerError}:{},...d&&d.length>0?{content:d}:{}}),o(l.id);continue}if(l.role==="tool"){l.turnId&&(r=l.turnId),r||(r=`restored-tool-${l.id}`);const d=l.startedAt?Date.parse(l.startedAt):NaN,u=l.finishedAt?Date.parse(l.finishedAt):NaN,h={id:l.toolCallId||l.id,toolName:l.toolName||"tool",...l.args?{args:l.args}:{},...l.interrupted?{interrupted:!0}:{},status:l.isError===!0?"error":"ok",resultText:l.text,result:l.text,createdAt:Number.isFinite(d)?d:c,finishedAt:Number.isFinite(u)?u:c,turnId:l.turnId??r,...l.step===void 0?{}:{step:l.step},...l.parentToolCallId?{parentToolCallId:l.parentToolCallId}:{},...l.eventSeq===void 0?{}:{eventSeq:l.eventSeq},...l.finishedSeq===void 0?{}:{finishedSeq:l.finishedSeq},...l.operationId?{operationId:l.operationId}:{},...l.browserTimeline?{browserTimeline:l.browserTimeline}:{}};s.push(h),l.eventSeq===void 0&&a.push(h)}}for(const l of n)for(const c of l.content??[]){if(c.type!=="toolCall"||!c.toolName)continue;const d=s.find(h=>h.id===c.toolCallId);if(d){d.args??=c.args;continue}const u=!!(t&&l.turnId===t);s.push({id:c.toolCallId,toolName:c.toolName,args:c.args,status:u?"running":"error",...u?{}:{interrupted:!0,finishedAt:l.createdAt},createdAt:l.createdAt,assistantMessageId:l.id,turnId:l.turnId})}return{messages:n,toolCalls:s}}function UC(e){return[...e].sort((t,n)=>t.eventSeq!==void 0&&n.eventSeq!==void 0&&t.eventSeq!==n.eventSeq?t.eventSeq-n.eventSeq:t.createdAt!==n.createdAt?t.createdAt-n.createdAt:t.id<n.id?-1:1)}function pd(e,t){if(t.length===0)return;const n=UC(t);for(const s of n){const r={...s.eventSeq===void 0?{}:{eventSeq:s.eventSeq},createdAt:s.createdAt},a=sH(s);if(a){e.push({kind:"dag-progress",progress:a,toolCallCount:1,...r});continue}const o=cH(s);o?e.push({kind:"activity",activity:o,toolCallCount:1,...r}):e.push({kind:"tool",tool:s,...r})}}function UH(e){const t=[],n=new Map;for(const s of e){if(s.kind!=="dag-progress"){t.push(s);continue}const r=n.get(s.progress.activityRef);if(r===void 0){n.set(s.progress.activityRef,t.length),t.push(s);continue}const a=t[r];a?.kind==="dag-progress"&&(t[r]={...a,toolCallCount:(a.toolCallCount??1)+(s.toolCallCount??1)})}return t}function WH(e){const t=new Set,n=[];let s=0;const r=v=>{v.items.length!==0&&n.push({...v.eventSeq===void 0?{}:{eventSeq:v.eventSeq},createdAt:v.createdAt,insertionOrder:s++,items:v.items})},a=(v,b,x=!1)=>{let y=[],C=v.eventSeq,S=v.createdAt;const I=()=>{r({items:y,...C===void 0?{}:{eventSeq:C},createdAt:S}),y=[]};for(const _ of b){if(_.type==="thinking"){if(!_.thinking.trim())continue;y.push({kind:"thinking",thinking:_.thinking,...C===void 0?{}:{eventSeq:C},createdAt:S});continue}if(_.type==="text"){_.text.trim()&&y.push({kind:"text",text:_.text,assistantMessageId:v.id,...C===void 0?{}:{eventSeq:C},createdAt:S});continue}if(_.type!=="toolCall")continue;const k=e.tools.find(L=>L.id===_.toolCallId);if(!k||t.has(k.id))continue;I(),t.add(k.id);const N=[];pd(N,[k]),r({items:N,...k.eventSeq===void 0?C===void 0?{}:{eventSeq:C}:{eventSeq:k.eventSeq},createdAt:k.createdAt}),C=k.eventSeq??C,S=k.createdAt}x&&v.providerError&&y.push({kind:"provider-error",error:v.providerError,...C===void 0?{}:{eventSeq:C},createdAt:S}),I();const w=e.tools.filter(_=>!t.has(_.id)&&_.eventSeq===void 0&&_.assistantMessageId===v.id);for(const _ of UC(w)){t.add(_.id);const k=[];pd(k,[_]),r({items:k,...C===void 0?{}:{eventSeq:C},createdAt:Math.max(S,_.createdAt)})}},o=e.assistants.at(-1),l=o?.kind==="provider-error"?void 0:o,c=l?e.assistants.lastIndexOf(l):-1;for(const[v,b]of e.assistants.entries())if(v!==c){if(b.kind==="provider-error"&&b.providerError){a(b,Hg(b.content??[]),!0);continue}a(b,Hg(b.content??[]))}const d=l?.content??(l?.text.trim()?[{type:"text",text:l.text}]:[]),u=OH(d,{isStreaming:e.live||e.turnState!=="settled"});l&&a(l,u.processBlocks);for(const v of e.tools){if(t.has(v.id)||v.eventSeq===void 0)continue;t.add(v.id);const b=[];pd(b,[v]),n.push({eventSeq:v.eventSeq,createdAt:v.createdAt,insertionOrder:s++,items:b})}const h=n.every(v=>v.eventSeq!==void 0);n.sort((v,b)=>h&&v.eventSeq!==b.eventSeq?v.eventSeq-b.eventSeq:v.createdAt!==b.createdAt?v.createdAt-b.createdAt:v.insertionOrder-b.insertionOrder);const p=n.flatMap(v=>v.items),m=e.tools.filter(v=>!t.has(v.id));if(m.length>0&&pd(p,m),e.processItems=UH(p),!l||u.answerBlocks.length===0)return;const g=DH(u.answerBlocks);e.answer={...l,text:g,content:u.answerBlocks}}function VH(e){if(e.live)return;const t=new Map;for(const n of e.tools){if(n.toolName!=="edit"&&n.toolName!=="write"||n.status!=="ok"||n.interrupted)continue;const s=ac(n.args),r=typeof s?.path=="string"?s.path:typeof s?.file_path=="string"?s.file_path:"";if(!r||s?.pathTruncated===!0)continue;const a=r.replace(/\\/g,"/"),o=kc(n.resultText??n.result),l=o?.added??0,c=o?.removed??0,d=t.get(a);d?(d.added+=l,d.deleted+=c,d.firstChangedLine===void 0&&o?.firstChangedLine!==void 0&&(d.firstChangedLine=o.firstChangedLine)):t.set(a,{path:r,display:a,added:l,deleted:c,...o?.firstChangedLine!==void 0?{firstChangedLine:o.firstChangedLine}:{},status:n.toolName==="write"?"added":"modified"})}return PH({sessionId:"",turnId:e.turnId??e.key,files:[...t.values()],failedTurn:e.turnState==="failed"||e.turnState==="aborted"})}function GH(e){const t=qC(e.messages.filter(c=>c.role==="user"||c.role==="assistant").sort((c,d)=>c.eventSeq!==void 0&&d.eventSeq!==void 0&&c.eventSeq!==d.eventSeq?c.eventSeq-d.eventSeq:c.createdAt!==d.createdAt?c.createdAt-d.createdAt:c.eventSeq!==void 0&&d.eventSeq===void 0?1:c.eventSeq===void 0&&d.eventSeq!==void 0?-1:0)),n=[];let s=null;const r=(c,d)=>{const u=qH(c,d);return n.push(u),u};for(const c of t){if(c.role==="user"){s=r(`user-${c.id}`,c.turnId),s.user=c;continue}if(c.kind==="compaction"){s=r(`compaction-${c.compaction?.compactionId??c.id}`,c.turnId),s.kind="standalone-event",s.standaloneEvent=c,s=null;continue}s||(s=r(`assistant-${c.id}`,c.turnId)),!s.turnId&&c.turnId&&(s.turnId=c.turnId),s.assistants.push(c)}const a=n.filter(c=>c.kind!=="standalone-event"),o=new Set,l=new Map;for(const c of a)for(const d of c.assistants)l.set(d.id,c);for(const c of e.toolCalls)if(c.assistantMessageId){const d=l.get(c.assistantMessageId);d&&(d.tools.push(c),o.add(c.id))}for(const c of e.toolCalls)if(!o.has(c.id)&&c.turnId){const d=a.find(h=>h.user?.turnId===c.turnId||h.assistants.some(p=>p.turnId===c.turnId)||h.tools.some(p=>p.turnId===c.turnId)||h.key===`turn-${c.turnId}`||h.user&&`restored-${h.user.id}`===c.turnId);if(d){d.tools.push(c),o.add(c.id);continue}const u=a.find(h=>c.turnId===`restored-${h.user?.id}`||h.assistants.some(p=>c.turnId===`restored-${p.id}`));u&&(u.tools.push(c),o.add(c.id))}for(const c of e.toolCalls){if(o.has(c.id))continue;const d=a.find((u,h)=>{const p=u.user?.createdAt??u.assistants[0]?.createdAt??0,m=a[h+1],g=m?.user?.createdAt??m?.assistants[0]?.createdAt??Number.POSITIVE_INFINITY;return c.createdAt>=p&&c.createdAt<g});d&&(d.tools.push(c),o.add(c.id))}for(const c of e.conversationNodes??[]){if(c.location.kind==="session")continue;const d=c.location.turnId;if(!a.some(u=>u.turnId===d)){const u=r(`turn-${d}`,d);a.push(u)}}for(const c of n){if(c.kind==="standalone-event")continue;c.tools.sort((h,p)=>h.eventSeq!==void 0&&p.eventSeq!==void 0?h.eventSeq-p.eventSeq:h.createdAt-p.createdAt);const d=c.turnId?e.turnStatesById?.[c.turnId]:void 0;d!==void 0&&(c.turnState=d),c.turnClosed=d==="settled"||d==="aborted"||d==="failed";const u=e.activeAssistantId!==null&&c.assistants.some(h=>h.id===e.activeAssistantId);c.live=e.streaming&&!c.turnClosed&&(u||d==="running"),WH(c),c.conversationItems=(e.conversationNodes??[]).filter(h=>h.location.kind!=="session"&&h.location.turnId===c.turnId).map(h=>({kind:h.kind,node:h})),c.workspaceChanges=(c.turnId?e.workspaceChanges?.find(h=>h.turnId===c.turnId&&h.source==="tool-events"):void 0)??VH(c),c.conversationItems.some(h=>h.kind==="turn-error")&&(c.processItems=c.processItems.filter(h=>h.kind!=="provider-error"))}return n}function KH(e){return typeof e=="object"?e.key:e}function YH(e,t){const n=e.length;return new Proxy(e,{get(s,r,a){if(typeof r=="string"){const o=r.charCodeAt(0);if(o>=48&&o<=57){const l=+r;if(Number.isInteger(l)&&l>=0&&l<n){let c=s[l];if(typeof c!="object"){const d=t[l*2];c=s[l]={index:l,key:c,start:d,size:t[l*2+1],end:d+t[l*2+1],lane:0}}return c}}if(r==="length")return n}return Reflect.get(s,r,a)}})}function Ya(e,t,n){let s=n.initialDeps??[],r,a=!0;function o(){const l=e();return(l.length!==s.length||l.some((d,u)=>s[u]!==d))&&(s=l,r=t(...l),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(r),a=!1),r}return o.updateDeps=l=>{s=l},o}function NS(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Za=(e,t)=>Math.abs(e-t)<1.01,ZH=(e,t,n)=>{let s;return Object.assign(function(...r){e.clearTimeout(s),s=e.setTimeout(()=>t.apply(this,r),n)},{cancel:()=>{e.clearTimeout(s)}})};let pl;const _0=()=>{if(pl!==void 0)return pl;if(typeof navigator>"u")return pl=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return pl=!0;const e=navigator.maxTouchPoints;return pl=navigator.platform==="MacIntel"&&e!==void 0&&e>0},jS=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},XH=e=>e,JH=e=>{const t=Math.max(e.startIndex-e.overscan,0),s=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=new Array(s);for(let a=0;a<s;a++)r[a]=t+a;return r},QH=(e,t)=>{const n=e.scrollElement;if(!n)return;const s=e.targetWindow;if(!s)return;const r=o=>{const{width:l,height:c}=o;t({width:Math.round(l),height:Math.round(c)})};if(r(jS(n)),!s.ResizeObserver)return()=>{};const a=new s.ResizeObserver(o=>{const l=()=>{const c=o[0];if(c?.borderBoxSize){const d=c.borderBoxSize[0];if(d){r({width:d.inlineSize,height:d.blockSize});return}}r(jS(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},Ru={passive:!0},eq=typeof window>"u"?!0:"onscrollend"in window,tq=(e,t,n)=>{const s=e.scrollElement;if(!s)return;const r=e.targetWindow;if(!r)return;const a=e.options.useScrollendEvent&&eq;let o=0;const l=a?null:ZH(r,()=>t(n(s),!1),e.options.isScrollingResetDelay),c=h=>()=>{o=n(s),l?.(),t(o,h)},d=c(!0),u=c(!1);return s.addEventListener("scroll",d,Ru),a&&s.addEventListener("scrollend",u,Ru),()=>{s.removeEventListener("scroll",d),a&&s.removeEventListener("scrollend",u),l?.cancel()}},nq=(e,t)=>tq(e,t,n=>{const{horizontal:s,isRtl:r}=e.options;return s?n.scrollLeft*(r&&-1||1):n.scrollTop}),sq=(e,t,n)=>{if(n.options.useCachedMeasurements){const s=n.indexFromElement(e),r=n.options.getItemKey(s);return n.itemSizeCache.get(r)??n.options.estimateSize(s)}if(t?.borderBoxSize){const s=t.borderBoxSize[0];if(s)return Math.round(s[n.options.horizontal?"inlineSize":"blockSize"])}if(!t){const s=n.indexFromElement(e),r=n.options.getItemKey(s),a=n.itemSizeCache.get(r);if(a!==void 0)return a}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},rq=(e,{adjustments:t=0,behavior:n},s)=>{var r,a;(a=(r=s.scrollElement)==null?void 0:r.scrollTo)==null||a.call(r,{[s.options.horizontal?"left":"top"]:e+t,behavior:n})},iq=rq;function aq(e,t,n,s){if(t===0)return!1;const r=s(0),a=new Set;let o=0;for(;o<e;){const c=n(o);if(c===r)break;a.add(c),o++}const l=e-o;if(l===0||l>=t)return!1;for(let c=0;c<l;c++)if(s(c)!==n(o+c))return!1;for(let c=l;c<t;c++)if(a.has(s(c)))return!1;return!0}class oq{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this._clampedAdjustment=null,this.elementsCache=new Map,this.now=()=>{var n,s,r;return((r=(s=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:s.now)==null?void 0:r.call(s))??Date.now()},this.observer=(()=>{let n=null;const s=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(r=>{r.forEach(a=>{const o=()=>{const l=a.target,c=this.indexFromElement(l);if(!l.isConnected){this.observer.unobserve(l);for(const[d,u]of this.elementsCache)if(u===l){this.elementsCache.delete(d);break}return}this.isIndexInRange(c)&&this.shouldMeasureDuringScroll(c)&&this.resizeItem(c,this.options.measureElement(l,a,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var r;(r=s())==null||r.disconnect(),n=null},observe:r=>{var a;return(a=s())==null?void 0:a.observe(r,{box:"border-box"})},unobserve:r=>{var a;return(a=s())==null?void 0:a.unobserve(r)}}})(),this.range=null,this.setOptions=n=>{var s;const r={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:XH,rangeExtractor:JH,onChange:()=>{},measureElement:sq,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(const h in n){const p=n[h];p!==void 0&&(r[h]=p)}const a=this.options;let o=null,l=null,c=!1;if(a!==void 0&&a.enabled&&r.enabled&&r.anchorTo==="end"&&this.scrollElement!==null){const h=a.count,p=r.count,m=this.getMeasurements(),g=((s=this._singleLaneMeasurements)==null?void 0:s.items)??m,v=S=>KH(g[S]),b=h>0?v(0):null,x=h>0?v(h-1):null;if(p!==h||h>0&&p>0&&(r.getItemKey(0)!==b||r.getItemKey(p-1)!==x)){c=!0;const S=h>0?this.getVirtualItemForOffset(this.getScrollOffset())??m[0]:null;S&&(o=[S.key,this.getScrollOffset()-S.start]);const I=r.followOnAppend===!0?"auto":r.followOnAppend||null;I&&p>0&&this.isAtEnd(a.scrollEndThreshold)&&(h===0||r.getItemKey(p-1)!==x)&&(p>h||aq(h,p,v,r.getItemKey))&&(l=I)}}this.options=r,c&&(this.pendingMin=0,this.itemSizeCacheVersion++);let d=!1,u=0;if(o&&this.scrollOffset!==null){const[h,p]=o,m=this.getMeasurements(),{count:g,getItemKey:v}=this.options;let b=0;for(;b<g&&v(b)!==h;)b++;if(b<g){const x=m[b];if(x){const y=Math.max(0,x.start+p);!l&&y!==this.scrollOffset&&(u=y-this.scrollOffset,this.scrollOffset=y,d=!0)}}}(d||l)&&(this.pendingScrollAnchor=[d?o[0]:null,d?o[1]:0,l,u])},this.notify=n=>{var s,r;(r=(s=this.options).onChange)==null||r.call(s,this,n)},this.maybeNotify=Ya(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.isScrolling=!1,this.scrollDirection=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._clampedAdjustment=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n,s;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}if(this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(o=>{this.observer.observe(o)}),this.unsubs.push(this.options.observeElementRect(this,o=>{this.scrollRect=o,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(o,l)=>{var c;if(l&&this._intendedScrollOffset===null&&o===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(o-this._intendedScrollOffset)<1.5?o=this._intendedScrollOffset:((c=this.scrollState)==null?void 0:c.index)!=null&&this.scrollState.hasReachedTarget&&!Za(o,this.scrollState.lastTargetOffset)&&!Za(o,this.getScrollStateTarget(this.scrollState))&&(this._clampedAdjustment===null||Math.abs(o-this._clampedAdjustment.maxAtWrite)>=1.5)&&(this.scrollState=null),this._intendedScrollOffset=null,this._clampedAdjustment!==null&&Math.abs(o-this._clampedAdjustment.maxAtWrite)>=1.5&&(this._clampedAdjustment=null),this.scrollAdjustments=0;const d=this.getScrollOffset();this.scrollDirection=l?d===o?this.scrollDirection:d<o?"forward":"backward":null,this.scrollOffset=o,this.isScrolling=l,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),"addEventListener"in this.scrollElement){const o=this.scrollElement,l=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},c=()=>{this._iosTouching=!1,!(!_0()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};o.addEventListener("touchstart",l,Ru),o.addEventListener("touchend",c,Ru),this.unsubs.push(()=>{o.removeEventListener("touchstart",l),o.removeEventListener("touchend",c),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}const a=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,a&&this.scrollElement&&this.options.enabled){const[o,l,c,d]=a;o!==null&&!c&&(_0()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?d!==0&&(this._iosDeferredAdjustment+=d):((s=this.scrollState)==null?void 0:s.behavior)==="smooth"&&!Za(this.getScrollOffset()-d,this.scrollState.lastTargetOffset)||this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),c&&this.scrollToEnd({behavior:c})}this._retryClampedAdjustment()},this._retryClampedAdjustment=()=>{if(this._clampedAdjustment===null||!this.scrollElement||!this.options.enabled)return;const{target:n,maxAtWrite:s}=this._clampedAdjustment,r=this.getMaxScrollOffset();r>s+.5&&(this._clampedAdjustment=n>r+.5?{target:n,maxAtWrite:r}:null,this._scrollToOffset(n,{adjustments:void 0,behavior:void 0}))},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;const n=this.getScrollOffset(),s=this.getMaxScrollOffset();if(n<0||n>s)return;if(this._iosDeferredAdjustment<0&&n>=s-1){this._iosDeferredAdjustment=0;return}const r=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(n,{adjustments:this.scrollAdjustments+=r,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Ya(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(n,s,r,a,o,l,c,d)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMin=null,{count:n,paddingStart:s,scrollMargin:r,getItemKey:a,enabled:o,lanes:l,laneAssignmentMode:c,gap:d}),{key:!1}),this.isIndexInRange=n=>n>=0&&n<this.options.count,this.getMeasurements=Ya(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:n,paddingStart:s,scrollMargin:r,getItemKey:a,enabled:o,lanes:l,laneAssignmentMode:c,gap:d},u)=>{var h;const p=this.itemSizeCache;if(!o)return this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const y of this.laneAssignments.keys())y>=n&&this.laneAssignments.delete(y);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this._singleLaneMeasurements=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(y=>{this.itemSizeCache.set(y.key,y.size)}));const m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1),l===1){const y=n*2;let C=(h=this._singleLaneMeasurements)==null?void 0:h.flat;if(!C||C.length<y){const _=new Float64Array(y);C&&m>0&&_.set(C.subarray(0,m*2)),C=_}const S=m===0?new Array(n):this._singleLaneMeasurements.items.slice();let I;if(m===0)I=s+r;else{const _=m-1;I=C[_*2]+C[_*2+1]+d}for(let _=m;_<n;_++){const k=a(_);S[_]=k;const N=p.get(k),L=typeof N=="number"?N:this.options.estimateSize(_);C[_*2]=I,C[_*2+1]=L,I+=L+d}this._singleLaneMeasurements={flat:C,items:S};const w=YH(S,C);return this.measurementsCache=w,w}const g=this.measurementsCache.slice(0,m),v=new Array(l).fill(void 0),b=new Float64Array(l);let x=0;for(let y=0;y<m;y++){const C=g[y];C&&(v[C.lane]===void 0&&x++,v[C.lane]=y,b[C.lane]=C.end)}for(let y=m;y<n;y++){const C=a(y),S=this.laneAssignments.get(y);let I,w;const _=c==="estimate"||p.has(C);if(S!==void 0&&this.options.lanes>1){I=S;const O=v[I],T=O!==void 0?g[O]:void 0;w=T?T.end+d:s+r}else if(x===l){let O=0,T=b[0],R=v[0];for(let A=1;A<l;A++){const E=b[A];(E<T||E===T&&v[A]<R)&&(O=A,T=E,R=v[A])}I=O,w=T+d,_&&this.laneAssignments.set(y,I)}else I=y%this.options.lanes,w=s+r,_&&this.laneAssignments.set(y,I);const k=p.get(C),N=typeof k=="number"?k:this.options.estimateSize(y),L=w+N;g[y]={index:y,start:w,size:N,end:L,key:C,lane:I},v[I]===void 0&&x++,v[I]=y,b[I]=L}return this.measurementsCache=g,g},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Ya(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,s,r,a)=>n.length===0||s===0?(this.range=null,null):(this.range=cq(n,s,r,a,a===1&&this._singleLaneMeasurements!==null?this._singleLaneMeasurements.flat:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Ya(()=>{let n=null,s=null;const r=this.calculateRange();return r&&(n=r.startIndex,s=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,s]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,s]},(n,s,r,a,o)=>a===null||o===null?[]:n({startIndex:a,endIndex:o,overscan:s,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const s=this.options.indexAttribute,r=n.getAttribute(s);return r?parseInt(r,10):(console.warn(`Missing attribute name '${s}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var s;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const r=this.scrollState.index??((s=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:s.index);if(r!==void 0&&this.range){const a=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,r-a),l=Math.min(this.options.count-1,r+a);return n>=o&&n<=l}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,l)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(l))});return}const s=this.indexFromElement(n);if(!this.isIndexInRange(s))return;const r=this.options.getItemKey(s),a=this.elementsCache.get(r);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(r,n)),n.isConnected&&(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,s)=>{var r,a,o;if(!this.isIndexInRange(n))return;let l,c,d;const u=(r=this._singleLaneMeasurements)==null?void 0:r.flat;if(this.options.lanes===1&&u!=null)d=this.options.getItemKey(n),c=u[n*2],l=u[n*2+1];else{const m=this.measurementsCache[n];if(!m)return;d=m.key,c=m.start,l=m.size}const h=this.itemSizeCache.get(d)??l,p=s-h;if(p!==0){const m=this.options.anchorTo==="end"&&((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,g=m?this.getTotalSize():0,v=this.getScrollOffset()+this.scrollAdjustments,x=!this.itemSizeCache.has(d)?c<v:c+h<=v&&this.scrollDirection!=="backward",y=((o=this.scrollState)==null?void 0:o.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[n]??{index:n,key:d,start:c,size:l,end:c+l,lane:0},p,this):x);(this.pendingMin===null||n<this.pendingMin)&&(this.pendingMin=n),this.itemSizeCache.set(d,s),this.itemSizeCacheVersion++;let C=!1;m?C=this.applyScrollAdjustment(this.getTotalSize()-g):y&&(C=this.applyScrollAdjustment(p)),this.notify(C),this._retryClampedAdjustment()}},this.getVirtualItems=Ya(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,s)=>{const r=[];for(let a=0,o=n.length;a<o;a++){const l=n[a],c=s[l];r.push(c)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{var s;const r=this.getMeasurements();if(r.length===0)return;const a=(s=this._singleLaneMeasurements)==null?void 0:s.flat,o=this.options.lanes===1&&a!=null,l=WC(0,r.length-1,o?c=>a[c*2]:c=>NS(r[c]).start,n);return NS(r[l])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(n=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=n,this.getOffsetForAlignment=(n,s,r=0)=>{if(!this.scrollElement)return 0;const a=this.getSize(),o=this.getScrollOffset();s==="auto"&&(s=n>=o+a?"end":"start"),s==="center"?n+=(r-a)/2:s==="end"&&(n-=a);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,s="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const r=this.getSize(),a=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(s==="auto")if(o.end>=a+r-this.options.scrollPaddingEnd)s="end";else if(o.start<=a+this.options.scrollPaddingStart)s="start";else return[a,s];if(s==="end"&&n===this.options.count-1){const c=this.getMaxScrollOffset(),d=c-this.options.paddingEnd+this.options.scrollPaddingEnd;return[Math.max(Math.min(d,c),0),s]}const l=s==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,s,o.size),s]},this.scrollToOffset=(n,{align:s="start",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0;const a=this.getOffsetForAlignment(n,s),o=this.now();this.scrollState={index:null,align:s,behavior:r,startedAt:o,lastTargetOffset:a,stableFrames:0,hasReachedTarget:!1},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:s="auto",behavior:r="auto"}={})=>{this._iosDeferredAdjustment=0,n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getOffsetForIndex(n,s);if(!a)return;const[o,l]=a,c=this.now();this.scrollState={index:n,align:l,behavior:r,startedAt:c,lastTargetOffset:o,stableFrames:0,hasReachedTarget:Za(o,this.getScrollOffset())},this._scrollToOffset(o,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:s="auto"}={})=>{const r=this.getScrollOffset()+n,a=this.now();this.scrollState={index:null,align:"start",behavior:s,startedAt:a,lastTargetOffset:r,stableFrames:0,hasReachedTarget:!1},this._scrollToOffset(r,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:n="auto"}={})=>{if(this.options.count>0){this._iosDeferredAdjustment=0;const s=Math.max(this.getMaxScrollOffset(),0);this.scrollState={index:this.options.count-1,align:"end",behavior:n,toEnd:!0,startedAt:this.now(),lastTargetOffset:s,stableFrames:0,hasReachedTarget:Za(s,this.getScrollOffset())},this._scrollToOffset(s,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile();return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:n})},this.cancelScroll=()=>{this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null},this.getTotalSize=()=>{var n,s;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1){const o=r.length-1,l=(n=this._singleLaneMeasurements)==null?void 0:n.flat;l!=null?a=l[o*2]+l[o*2+1]:a=((s=r[o])==null?void 0:s.end)??0}else{const o=Array(this.options.lanes).fill(null);let l=r.length-1;for(;l>=0&&o.some(c=>c===null);){const c=r[l];o[c.lane]===null&&(o[c.lane]=c.end),l--}a=Math.max(...o.filter(c=>c!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{const n=[];if(this.itemSizeCache.size===0)return n;const s=this.getMeasurements();for(const r of s)r&&this.itemSizeCache.has(r.key)&&n.push({index:r.index,key:r.key,start:r.start,size:r.size,end:r.end,lane:r.lane});return n},this._scrollToOffset=(n,{adjustments:s,behavior:r})=>{this._intendedScrollOffset=n+(s??0),this.options.scrollToFn(n,{behavior:r,adjustments:s},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(t)}applyScrollAdjustment(t,n){if(t===0)return!1;if(_0()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded))return this._iosDeferredAdjustment+=t,!1;{const s=this.getScrollOffset()+this.scrollAdjustments+t,r=this.scrollElement,a=r!==null&&("scrollHeight"in r||"document"in r)?this.getMaxScrollOffset():null;return this._clampedAdjustment=a!==null&&s>a+.5?{target:s,maxAtWrite:a}:null,this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=t,behavior:n}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0}}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}getScrollStateTarget(t){const n=t.toEnd?[Math.max(this.getMaxScrollOffset(),0)]:t.index!=null?this.getOffsetForIndex(t.index,t.align):void 0;return n?n[0]:t.lastTargetOffset}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const s=this.getScrollStateTarget(this.scrollState),r=this.scrollState.index==null?1:this.options.useAnimationFrameWithResizeObserver?3:2,a=s!==this.scrollState.lastTargetOffset;if(!a&&Za(s,this.getScrollOffset())){if(this.scrollState.hasReachedTarget=!0,this.scrollState.stableFrames++,this.scrollState.stableFrames>=r){this.getScrollOffset()!==s&&this._scrollToOffset(s,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,a){const o=this.getSize()||600,l=Math.abs(s-this.getScrollOffset()),c=this.scrollState.behavior==="smooth"&&l>o;this.scrollState.lastTargetOffset=s,c?this.scrollState.hasReachedTarget=!1:this.scrollState.behavior="auto",this._scrollToOffset(s,{adjustments:void 0,behavior:c?"smooth":"auto"})}this.scheduleScrollReconcile()}}const WC=(e,t,n,s)=>{for(;e<=t;){const r=(e+t)/2|0,a=n(r);if(a<s)e=r+1;else if(a>s)t=r-1;else return r}return e>0?e-1:0};function lq(e,t,n){let s=0;for(;s<=t;){const r=(s+t)/2|0,a=e[r*2];if(a<n)s=r+1;else if(a>n)t=r-1;else return r}return s>0?s-1:0}function cq(e,t,n,s,r){const a=e.length-1;if(e.length<=s)return{startIndex:0,endIndex:a};if(s===1&&r!==null){const d=lq(r,a,n);let u=d;const h=n+t;for(;u<a&&r[u*2]+r[u*2+1]<h;)u++;return{startIndex:d,endIndex:u}}let l=WC(0,a,d=>e[d].start,n),c=l;if(s===1)for(;c<a&&e[c].end<n+t;)c++;else if(s>1){const d=Array(s).fill(0);for(;c<a&&d.some(h=>h<n+t);){const h=e[c];d[h.lane]=h.end,c++}const u=Array(s).fill(n+t);for(;l>=0&&u.some(h=>h>=n);){const h=e[l];u[h.lane]=h.start,l--}l=Math.max(0,l-l%s),c=Math.min(a,c+(s-1-c%s))}return{startIndex:l,endIndex:c}}const k0=typeof document<"u"?f.useLayoutEffect:f.useEffect;function dq({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n="transform",...s}){const r=f.useReducer(p=>p+1,0)[1],a=f.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;const o=f.useRef(!1),l=p=>{const m=a.current;if(!m.enabled||!m.container)return;const g=p.getTotalSize();if(g!==m.lastSize){m.lastSize=g;const v=p.options.horizontal?"width":"height";m.container.style[v]=`${g}px`}},c=(p,m,g)=>{const v=a.current,b=!!p.options.horizontal,x=m.start-p.options.scrollMargin;v.lastPositions.get(g)!==x&&(v.lastPositions.set(g,x),v.mode==="transform"?g.style.transform=b?`translate3d(${x}px, 0, 0)`:`translate3d(0, ${x}px, 0)`:g.style[b?"left":"top"]=`${x}px`)},d=p=>{const m=a.current;if(!(!m.enabled||!m.container)){l(p);for(const g of p.getVirtualItems()){const v=p.elementsCache.get(g.key);v&&c(p,g,v)}}},u={...s,onChange:(p,m)=>{var g;const v=a.current;let b=!0;if(v.enabled){d(p);const x=p.range,y=v.prevRange;b=!y||y.isScrolling!==p.isScrolling||y.startIndex!==x?.startIndex||y.endIndex!==x?.endIndex,b&&(v.prevRange=x?{startIndex:x.startIndex,endIndex:x.endIndex,isScrolling:p.isScrolling}:null)}b&&(e&&m&&!o.current?Xs.flushSync(r):r()),(g=s.onChange)==null||g.call(s,p,m)}},[h]=f.useState(()=>{const p=new oq(u),m=p.measureElement;return p.measureElement=g=>{o.current=!0;try{m(g)}finally{o.current=!1}const v=a.current;if(g!==null&&v.enabled&&v.container){const b=p.measurementsCache[p.indexFromElement(g)];b&&c(p,b,g)}},Object.assign(p,{containerRef:g=>{const v=a.current;v.container=g,v.lastSize=null,g!==null&&d(p)}})});return h.setOptions(u),k0(()=>h._didMount(),[]),k0(()=>(l(h),h._willUpdate())),k0(()=>{d(h)}),h}function uq(e){return dq({observeElementRect:QH,observeElementOffset:nq,scrollToFn:iq,...e})}function Au(e){return e.kind==="group"?`group:${e.group.key}`:`pending:${e.item.clientRequestId}`}function hq(e){const t=f.useRef(null),n=f.useRef(void 0),s=f.useRef(0),[r,a]=f.useState(0),o=f.useCallback(p=>Au(e.entries[p]),[e.entries]),l=typeof window<"u"&&typeof ResizeObserver<"u",c=l&&e.scrollElement!==null,d=uq({count:e.entries.length,getScrollElement:()=>e.scrollElement,getItemKey:o,estimateSize:()=>360,overscan:3,scrollMargin:r,anchorTo:"end",followOnAppend:e.followRef.current,scrollEndThreshold:25,useAnimationFrameWithResizeObserver:!0,enabled:c}),u=f.useCallback(()=>{s.current+=1,d.cancelScroll(),window.cancelAnimationFrame(n.current??0)},[d]),h=f.useCallback(()=>{e.scrollElement&&(u(),c?d.scrollToEnd():e.scrollElement.scrollTop=e.scrollElement.scrollHeight)},[c,e.scrollElement,d,u]);return f.useLayoutEffect(()=>{e.followRef.current&&h()},[e.entries,e.followRef,h]),f.useEffect(()=>u,[u]),f.useLayoutEffect(()=>{const p=t.current,m=e.scrollElement;if(!p||!m)return;const g=()=>a(p.getBoundingClientRect().top-m.getBoundingClientRect().top+m.scrollTop);g();const v=new ResizeObserver(g);return v.observe(m),p.parentElement&&v.observe(p.parentElement),()=>v.disconnect()},[e.scrollElement]),f.useEffect(()=>{const p=t.current?.parentElement;if(!p||!e.scrollElement||!l)return;const m=new ResizeObserver(()=>{e.followRef.current&&h()});return m.observe(p),m.observe(e.scrollElement),()=>m.disconnect()},[l,e.scrollElement,e.followRef,h]),f.useEffect(()=>{const p=e.scrollElement,m=t.current;if(!p||!m||typeof ResizeObserver>"u")return;let g=m.clientWidth;const v=new ResizeObserver(()=>{if(g===m.clientWidth)return;g=m.clientWidth;const b=e.followRef.current,x=d.getVirtualItemForOffset(p.scrollTop),y=x?p.scrollTop-x.start:0;window.cancelAnimationFrame(n.current??0),n.current=requestAnimationFrame(()=>{if(b&&e.followRef.current)h();else if(x){const C=d.getVirtualItems().find(S=>S.key===x.key);C&&d.scrollToOffset(C.start+y)}})});return v.observe(m),()=>{v.disconnect(),window.cancelAnimationFrame(n.current??0)}},[d,e.scrollElement,e.entries,e.followRef,h]),f.useImperativeHandle(e.navigationRef,()=>({scrollToEnd:h,cancelScroll:u,async scrollToKey(p){const m=e.entries.findIndex(v=>Au(v)===p);if(m<0||!c)return!1;u();const g=s.current;return d.scrollToIndex(m,{align:"start",behavior:"auto"}),await new Promise(v=>requestAnimationFrame(()=>requestAnimationFrame(()=>v()))),g!==s.current?!1:(d.scrollToIndex(m,{align:"start",behavior:"auto"}),!0)}}),[c,e.entries,e.navigationRef,d,h,u]),l?i.jsx("div",{ref:t,className:"oc-virtual-timeline",style:{height:d.getTotalSize()},"data-virtual-timeline":"true",children:d.getVirtualItems().map(p=>{const m=e.entries[p.index];return m?i.jsx("div",{className:"oc-virtual-turn","data-index":p.index,"data-turn-key":p.key,ref:d.measureElement,style:{transform:`translateY(${p.start-r}px)`},children:e.renderEntry(m,p.index,e.entries)},p.key):null})}):i.jsx(i.Fragment,{children:e.entries.map(e.renderEntry)})}function fq(e){let t=0,n=0,s=0;const r=new Set;for(const a of e){if(a.source!=="process")continue;const o=a.item;if(o.kind==="tool"){To(o.tool.toolName)?s+=1:t+=1;continue}if(o.kind==="activity"||o.kind==="dag-progress"){t+=o.toolCallCount??0;continue}o.kind!=="text"||o.text.trim()===""||(o.assistantMessageId?r.add(o.assistantMessageId):n+=1)}return n+=r.size,{toolCalls:t,messages:n,subagents:s}}function mq(e){return fq(e)}function pq(e){return[e.toolCalls>0?`${e.toolCalls} 次工具调用`:"",e.messages>0?`${e.messages} 条消息`:"",e.subagents>0?`${e.subagents} 个 subagent`:""].filter(Boolean).join(" · ")||"已思考"}function gq(){return typeof document<"u"&&"onbeforematch"in document.body}function vq(e,t){const n=f.useRef(null);return f.useLayoutEffect(()=>{const s=n.current;if(s!==null){if(e&&s.contains(s.ownerDocument.activeElement)){t();return}e?s.setAttribute("hidden",gq()?"until-found":""):s.removeAttribute("hidden")}},[e,t]),f.useEffect(()=>{const s=n.current;if(s!==null)return s.addEventListener("beforematch",t),()=>{s.removeEventListener("beforematch",t)}},[t]),n}function bq(e){const{interview:t,interviewAnswer:n,onAnswerChange:s,onAnswer:r}=e;return i.jsxs("section",{className:"oc-draft-card","aria-label":"Requirement Interview",children:[i.jsxs("header",{children:[i.jsx("strong",{children:"Requirement Interview"}),i.jsx("span",{children:t.state})]}),t.question&&i.jsxs("div",{className:"oc-interview-bubble",children:[i.jsx("strong",{children:t.question.text}),i.jsxs("p",{children:["建议:",t.question.recommendation]}),i.jsx("textarea",{value:n,onChange:a=>s(a.target.value),placeholder:"输入答案"}),i.jsxs("div",{children:[i.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>r("override"),disabled:!n.trim(),children:"提交答案"}),i.jsx("button",{className:"btn btn-ghost",type:"button",onClick:()=>r("accept-recommendation"),children:"接受建议"})]})]}),t.draft&&i.jsxs("details",{open:!0,children:[i.jsxs("summary",{children:["TaskContractDraftV1 · ",t.draftSha256?.slice(0,12)]}),i.jsx("pre",{children:JSON.stringify(t.draft,null,2)})]}),t.assessment&&i.jsxs("div",{className:`oc-assessment${t.assessment.fresh?" is-fresh":""}`,children:[i.jsxs("strong",{children:["完整性:",t.assessment.outcome]}),(t.assessment.missingFields??[]).length>0&&i.jsxs("p",{children:["缺失:",t.assessment.missingFields?.join("、")]})]}),t.taskKindRecommendation&&i.jsxs("div",{className:"oc-task-kind-card",children:[i.jsx("span",{children:"taskKind 建议"}),i.jsx("strong",{children:t.taskKindRecommendation}),i.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>e.onConfirmTaskKind(),children:"由我确认"}),i.jsx("small",{children:"模型不能代替人类确认。"})]}),t.confirmedTaskKind&&i.jsxs("div",{className:"oc-task-kind-card is-confirmed",children:["已由人类确认:",i.jsx("strong",{children:t.confirmedTaskKind})]})]})}function bo(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toLocaleString()}function xq(e){return e.inputTokens+e.cacheReadTokens+e.cacheWriteTokens}function VC(e,t){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||t<=0||e<0||e>t)return null;const n=BigInt(e),s=BigInt(t);let r=1n,a=0,o;do{if(o=(n*100n*r*2n+s)/(s*2n),e===t||o<100n*r)break;r*=10n,a+=1}while(!0);if(a===0)return String(o);const l=String(o).padStart(a+1,"0");return`${l.slice(0,-a)}.${l.slice(-a)}`.replace(/0+$/,"")}function gd(e){const t=e/1e3;if(t<60)return`${Math.round(t*10)/10}s`;const n=Math.round(t);return`${Math.floor(n/60)}m${n%60}s`}function yq(e){const t=n=>n>=100?String(Math.round(n)):String(Math.round(n*10)/10);return e<1e3?String(e):e<1e6?`${t(e/1e3)}K`:`${t(e/1e6)}M`}function wq(e){if(!Number.isFinite(e)||e<0)return"";if(e<1024)return`${Math.round(e)} B`;const t=["KB","MB","GB","TB"];let n=e/1024,s=0;for(;n>=1024&&s<t.length-1;)n/=1024,s+=1;const r=Math.round(n*10)/10;return`${Number.isInteger(r)?r:r.toFixed(1)} ${t[s]}`}function Sq(e){return typeof e=="string"&&e.toLowerCase().startsWith("image/")}const _q=/(?:^|\n)[ \t]*(<!DOCTYPE\s+html\b[^>]*>[\s\S]*?<html\b[^>]*>|<!DOCTYPE\s+html\b[^>]*>|<html\b[^>]*>)/i;function kq(e,t){const n=/<div\b[^>]*?\bid\s*=\s*["']vcp-root["'][^>]*>/gi;n.lastIndex=t||0;let s=null;for(;s=n.exec(e);){const r=e.lastIndexOf(`
|