@tom2012/cc-web 2026.5.18-l → 2026.5.19-b
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/README.md +1 -1
- package/backend/dist/track-flow/__tests__/prompt-translator.test.js +25 -9
- package/backend/dist/track-flow/__tests__/prompt-translator.test.js.map +1 -1
- package/backend/dist/track-flow/prompt-translator.d.ts +5 -0
- package/backend/dist/track-flow/prompt-translator.d.ts.map +1 -1
- package/backend/dist/track-flow/prompt-translator.js +19 -12
- package/backend/dist/track-flow/prompt-translator.js.map +1 -1
- package/frontend/dist/assets/{ChatOverlay-DMGCmVuj.js → ChatOverlay-CCrB-zxT.js} +1 -1
- package/frontend/dist/assets/{GraphPreview-CdodZR0-.js → GraphPreview-COD5wr7F.js} +2 -2
- package/frontend/dist/assets/{MobilePage-BqMz5I2R.js → MobilePage-C-aiv-6i.js} +3 -3
- package/frontend/dist/assets/{OfficePreview-CILwhejo.js → OfficePreview-BSL5dPUM.js} +2 -2
- package/frontend/dist/assets/{PdfPreview-9EB_7xSS.js → PdfPreview-B8c4Ad75.js} +1 -1
- package/frontend/dist/assets/{ProjectPage-BF2mlQwz.js → ProjectPage-BxmgnsQT.js} +5 -5
- package/frontend/dist/assets/{SettingsPage-DemOlPdB.js → SettingsPage-B9Eay6TM.js} +2 -2
- package/frontend/dist/assets/{SkillHubPage-B92jiX9o.js → SkillHubPage-MSEv2owz.js} +1 -1
- package/frontend/dist/assets/{chevron-down-ClXwTQa0.js → chevron-down-CCqkGk_8.js} +1 -1
- package/frontend/dist/assets/{index-CW9zcZUc.js → index-C6zMjhVt.js} +1 -1
- package/frontend/dist/assets/{index-LK3zQucs.js → index-ChSsEM4z.js} +1 -1
- package/frontend/dist/assets/index-D7mI92Gj.css +1 -0
- package/frontend/dist/assets/{index-CKyL-Dlo.js → index-DaglaYz2.js} +3 -3
- package/frontend/dist/assets/{jszip.min-DpikPhK6.js → jszip.min-AZrJBqFy.js} +1 -1
- package/frontend/dist/assets/{search-DAPnGApV.js → search-BloCxLo6.js} +1 -1
- package/frontend/dist/assets/{select-DqKe_b4e.js → select-D0gOR1E7.js} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +1 -1
- package/frontend/dist/assets/index-COAYISTi.css +0 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A self-hosted web application (distributed as npm package) that provides a browser-based interface for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) CLI sessions. Create projects, each with a persistent terminal running Claude Code, and interact with them through a real-time terminal UI.
|
|
4
4
|
|
|
5
|
-
**Current version**: v2026.5.
|
|
5
|
+
**Current version**: v2026.5.19-b | [GitHub](https://github.com/zbc0315/cc-web) | MIT License
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -16,19 +16,19 @@ const prompt_translator_1 = require("../prompt-translator");
|
|
|
16
16
|
const r = (0, prompt_translator_1.translatePrompt)('@{area}', vars, { area: null }, []);
|
|
17
17
|
(0, vitest_1.expect)(r).toContain('area(研究领域)=null');
|
|
18
18
|
});
|
|
19
|
-
(0, vitest_1.it)('替换 ${key}
|
|
19
|
+
(0, vitest_1.it)('替换 ${key} 为 update-variable 英文指令(v-19-b 起 prompt 英文化)', () => {
|
|
20
20
|
const r = (0, prompt_translator_1.translatePrompt)('修改 ${has_error}', vars, { has_error: null }, ['has_error']);
|
|
21
|
-
(0, vitest_1.expect)(r).toContain('
|
|
21
|
+
(0, vitest_1.expect)(r).toContain('Update variable has_error(文献存在错误; stored at .ccweb-flow-train.json under key:has_error). Current value: null. Write the new value.');
|
|
22
22
|
});
|
|
23
23
|
(0, vitest_1.it)('outputs 非空时追加系统指令段', () => {
|
|
24
|
-
const r = (0, prompt_translator_1.translatePrompt)('
|
|
25
|
-
(0, vitest_1.expect)(r).toContain('
|
|
24
|
+
const r = (0, prompt_translator_1.translatePrompt)('do something ${has_error}', vars, { has_error: null }, ['has_error']);
|
|
25
|
+
(0, vitest_1.expect)(r).toContain('[System Instructions]');
|
|
26
26
|
(0, vitest_1.expect)(r).toContain('.ccweb-flow-train.json');
|
|
27
27
|
(0, vitest_1.expect)(r).toContain('has_error');
|
|
28
28
|
});
|
|
29
29
|
(0, vitest_1.it)('outputs 为空时仍追加系统指令段(v-j:done flag 是完成信号源)', () => {
|
|
30
|
-
const r = (0, prompt_translator_1.translatePrompt)('
|
|
31
|
-
(0, vitest_1.expect)(r).toContain('
|
|
30
|
+
const r = (0, prompt_translator_1.translatePrompt)('just ask @{area}', vars, { area: '逆合成' }, []);
|
|
31
|
+
(0, vitest_1.expect)(r).toContain('[System Instructions]');
|
|
32
32
|
(0, vitest_1.expect)(r).toContain('run-state.json');
|
|
33
33
|
(0, vitest_1.expect)(r).toContain('.done');
|
|
34
34
|
});
|
|
@@ -40,7 +40,12 @@ const prompt_translator_1 = require("../prompt-translator");
|
|
|
40
40
|
});
|
|
41
41
|
(0, vitest_1.it)('done flag 指令对 LLM 多步操作友好(明确说"可多步后标")', () => {
|
|
42
42
|
const r = (0, prompt_translator_1.translatePrompt)('@{area}', vars, { area: 'x' }, [], { basename: 'flow1', nodeId: 'n1' });
|
|
43
|
-
(0, vitest_1.expect)(r).toContain('
|
|
43
|
+
(0, vitest_1.expect)(r).toContain('you may perform multiple steps before marking');
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.it)('placeholder nodeId 不带空格(默认 <node-id>,与 <basename> 风格一致)', () => {
|
|
46
|
+
const r = (0, prompt_translator_1.translatePrompt)('@{area}', vars, { area: 'x' }, []);
|
|
47
|
+
(0, vitest_1.expect)(r).toContain('<node-id>');
|
|
48
|
+
(0, vitest_1.expect)(r).not.toContain('<node id>');
|
|
44
49
|
});
|
|
45
50
|
(0, vitest_1.it)('未声明的 key 保留字面(不替换)', () => {
|
|
46
51
|
const r = (0, prompt_translator_1.translatePrompt)('@{未知}', vars, {}, []);
|
|
@@ -51,8 +56,19 @@ const prompt_translator_1 = require("../prompt-translator");
|
|
|
51
56
|
const r = (0, prompt_translator_1.translatePrompt)(tpl, vars, { area: '逆合成', ref_fp: './test.bibtex', has_error: null }, ['has_error']);
|
|
52
57
|
(0, vitest_1.expect)(r).toContain("ref_fp(文献存储 bibtex 格式文件的路径)='./test.bibtex'");
|
|
53
58
|
(0, vitest_1.expect)(r).toContain("area(研究领域)='逆合成'");
|
|
54
|
-
(0, vitest_1.expect)(r).toContain('
|
|
55
|
-
(0, vitest_1.expect)(r).toContain('
|
|
59
|
+
(0, vitest_1.expect)(r).toContain('Update variable has_error(文献存在错误;');
|
|
60
|
+
(0, vitest_1.expect)(r).toContain('[System Instructions]');
|
|
61
|
+
});
|
|
62
|
+
(0, vitest_1.it)('codex P1 顺修:所有提及 run-state.json 的句子都用完整路径插值(防 LLM 误改根目录)', () => {
|
|
63
|
+
const r = (0, prompt_translator_1.translatePrompt)('@{area}', vars, { area: 'x' }, [], { basename: 'flow1', nodeId: 'n1' });
|
|
64
|
+
// 完整路径在多个句子中重复出现(path + done modify + failed modify + watch sentence)
|
|
65
|
+
const matches = r.match(/\.ccweb\/tracks\/flow1\.run-state\.json/g) ?? [];
|
|
66
|
+
(0, vitest_1.expect)(matches.length).toBeGreaterThanOrEqual(4);
|
|
67
|
+
});
|
|
68
|
+
(0, vitest_1.it)('codex P2 顺修:done/failed 互斥 + 禁动其他字段', () => {
|
|
69
|
+
const r = (0, prompt_translator_1.translatePrompt)('@{area}', vars, { area: 'x' }, [], { basename: 'flow1', nodeId: 'n1' });
|
|
70
|
+
(0, vitest_1.expect)(r).toContain('exactly one of `done` or `failed`');
|
|
71
|
+
(0, vitest_1.expect)(r).toContain('Do not modify other fields');
|
|
56
72
|
});
|
|
57
73
|
(0, vitest_1.it)('数字值不加引号', () => {
|
|
58
74
|
const r = (0, prompt_translator_1.translatePrompt)('@{n}', [{ key: 'n', description: '次数', initialValue: 0 }], { n: 42 }, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-translator.test.js","sourceRoot":"","sources":["../../../src/track-flow/__tests__/prompt-translator.test.ts"],"names":[],"mappings":";;AAAA,mCAA6C;AAC7C,4DAAsD;AAQtD,IAAA,iBAAQ,EAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,MAAM,IAAI,GAAc;QACtB,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE;QACxD,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,qBAAqB,EAAE,YAAY,EAAE,IAAI,EAAE;QACzE,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE;KAChE,CAAA;IAED,IAAA,WAAE,EAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,GAAG,IAAA,mCAAe,EAAC,YAAY,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAA;QAClE,IAAA,eAAM,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;IAEF,IAAA,WAAE,EAAC,sBAAsB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,GAAG,IAAA,mCAAe,EAAC,SAAS,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;QAC9D,IAAA,eAAM,EAAC,CAAC,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;IAEF,IAAA,WAAE,EAAC,
|
|
1
|
+
{"version":3,"file":"prompt-translator.test.js","sourceRoot":"","sources":["../../../src/track-flow/__tests__/prompt-translator.test.ts"],"names":[],"mappings":"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"}
|
|
@@ -15,6 +15,11 @@ export interface VarDecl {
|
|
|
15
15
|
* spec §7(v-j 修订):完成判定从 "outputs 改了 = 完成" 改为 "LLM 自报 done=true",
|
|
16
16
|
* 避免 LLM 第一次 Edit 就被强制结束节点(影响多步操作场景)。
|
|
17
17
|
*
|
|
18
|
+
* v-19-b:发给 LLM 的英文化(CLI LLM 对英文 prompt 执行更稳定)。变量
|
|
19
|
+
* description 字段是用户数据,保留原始(多语言)。codex P1 顺修:所有提到 run-state.json
|
|
20
|
+
* 的句子都用完整路径插值,防止 LLM 误改项目根的 run-state.json;P2 加 done/failed
|
|
21
|
+
* 互斥提示 + outputs 更新指令用显式 slot 替代 `to ...` 省略号。
|
|
22
|
+
*
|
|
18
23
|
* Unknown keys (not in `variables`) are preserved literally to aid debugging.
|
|
19
24
|
*/
|
|
20
25
|
export declare function translatePrompt(template: string, variables: VarDecl[], snapshot: Record<string, unknown>, outputs: string[], ctx?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-translator.d.ts","sourceRoot":"","sources":["../../src/track-flow/prompt-translator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,OAAO,CAAA;CACtB;AAgBD
|
|
1
|
+
{"version":3,"file":"prompt-translator.d.ts","sourceRoot":"","sources":["../../src/track-flow/prompt-translator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,CAAA;IACnB,YAAY,EAAE,OAAO,CAAA;CACtB;AAgBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,OAAO,EAAE,EACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,MAAM,EAAE,EACjB,GAAG,CAAC,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzC,MAAM,CAkBR"}
|
|
@@ -29,6 +29,11 @@ function formatValue(v) {
|
|
|
29
29
|
* spec §7(v-j 修订):完成判定从 "outputs 改了 = 完成" 改为 "LLM 自报 done=true",
|
|
30
30
|
* 避免 LLM 第一次 Edit 就被强制结束节点(影响多步操作场景)。
|
|
31
31
|
*
|
|
32
|
+
* v-19-b:发给 LLM 的英文化(CLI LLM 对英文 prompt 执行更稳定)。变量
|
|
33
|
+
* description 字段是用户数据,保留原始(多语言)。codex P1 顺修:所有提到 run-state.json
|
|
34
|
+
* 的句子都用完整路径插值,防止 LLM 误改项目根的 run-state.json;P2 加 done/failed
|
|
35
|
+
* 互斥提示 + outputs 更新指令用显式 slot 替代 `to ...` 省略号。
|
|
36
|
+
*
|
|
32
37
|
* Unknown keys (not in `variables`) are preserved literally to aid debugging.
|
|
33
38
|
*/
|
|
34
39
|
function translatePrompt(template, variables, snapshot, outputs, ctx) {
|
|
@@ -43,7 +48,7 @@ function translatePrompt(template, variables, snapshot, outputs, ctx) {
|
|
|
43
48
|
const decl = byKey.get(key);
|
|
44
49
|
if (!decl)
|
|
45
50
|
return `\${${key}}`;
|
|
46
|
-
return
|
|
51
|
+
return `Update variable ${key}(${decl.description}; stored at .ccweb-flow-train.json under key:${key}). Current value: ${formatValue(snapshot[key] ?? null)}. Write the new value.`;
|
|
47
52
|
});
|
|
48
53
|
// 系统指令始终追加(v-j:即便 outputs 为空,也得告诉 LLM 通过 done flag 结束节点)
|
|
49
54
|
result += '\n\n' + buildSystemInstruction(outputs, ctx);
|
|
@@ -53,23 +58,25 @@ function buildSystemInstruction(outputs, ctx) {
|
|
|
53
58
|
const runStatePath = ctx
|
|
54
59
|
? `.ccweb/tracks/${ctx.basename}.run-state.json`
|
|
55
60
|
: '.ccweb/tracks/<basename>.run-state.json';
|
|
56
|
-
const nodeId = ctx?.nodeId ?? '
|
|
61
|
+
const nodeId = ctx?.nodeId ?? '<node-id>';
|
|
57
62
|
const lines = [
|
|
58
|
-
'
|
|
59
|
-
'
|
|
60
|
-
|
|
63
|
+
'[System Instructions]',
|
|
64
|
+
'Runtime progress is recorded in `' + runStatePath + '` (path is relative to the project root).',
|
|
65
|
+
`This node's id is \`${nodeId}\`; its state lives under \`nodes.${nodeId}\` in that file.`,
|
|
66
|
+
'',
|
|
67
|
+
`After completing this node's task, use the Edit/Write tool to modify \`${runStatePath}\`:`,
|
|
68
|
+
` Set \`nodes.${nodeId}.done\` to true.`,
|
|
61
69
|
'',
|
|
62
|
-
|
|
63
|
-
`
|
|
70
|
+
`If the task cannot be completed (e.g. invalid user input, unavailable resource), modify \`${runStatePath}\`:`,
|
|
71
|
+
` Set \`nodes.${nodeId}.failed\` to true and set \`nodes.${nodeId}.reason\` to a string explaining why.`,
|
|
64
72
|
'',
|
|
65
|
-
|
|
66
|
-
` 把 \`nodes.${nodeId}.failed\` 设为 true,并把 \`nodes.${nodeId}.reason\` 设为字符串(说明原因)。`,
|
|
73
|
+
`Rules: set exactly one of \`done\` or \`failed\` to true (never both). Do not modify other fields under \`nodes.${nodeId}\` (such as \`iter\`, \`status\`, \`type\`) — ccweb manages those.`,
|
|
67
74
|
'',
|
|
68
|
-
|
|
69
|
-
'
|
|
75
|
+
`ccweb watches \`${runStatePath}\` in real time: once done=true the next node starts; once failed=true the entire flow stops.`,
|
|
76
|
+
'Until you mark done/failed, ccweb does NOT advance — you may perform multiple steps before marking.',
|
|
70
77
|
];
|
|
71
78
|
if (outputs.length > 0) {
|
|
72
|
-
lines.push('', '
|
|
79
|
+
lines.push('', 'Business variables live in `.ccweb-flow-train.json`. Output fields declared by this node: ' + outputs.join(', '), '(Please update these fields with Edit/Write during the task; missing updates are logged as a warning in the audit log but do not block progress.)');
|
|
73
80
|
}
|
|
74
81
|
return lines.join('\n');
|
|
75
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-translator.js","sourceRoot":"","sources":["../../src/track-flow/prompt-translator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"prompt-translator.js","sourceRoot":"","sources":["../../src/track-flow/prompt-translator.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{bF as e,bG as t,r as n,bH as r,c as a,h as i,bI as o,aX as s,j as l,R as c,d as u,U as d,bJ as p,t as m,A as g,q as h,b2 as f,bK as b,a as y,a8 as E,aa as v,a6 as S,a5 as w,a9 as k,a4 as x,bk as T,aG as A,bz as _,bA as I,i as N,bL as R,bM as C,s as O,bN as L,bO as D,bB as M,bP as P,bD as F,S as B,l as U,p as z}from"./index-DaglaYz2.js";import{C as $}from"./chevron-down-CCqkGk_8.js";import{a as G,C as j,u as H,c as q}from"./index-ChSsEM4z.js";function V(){!e.current&&t();const[a]=n.useState(r.current);return a}
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.309.0 - ISC
|
|
4
4
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{c as e,r as t,b as n,j as i,
|
|
1
|
+
import{c as e,r as t,b as n,j as i,U as r,B as o,m as a}from"./index-DaglaYz2.js";import{Z as l,a as s}from"./ProjectPage-BxmgnsQT.js";import"./purify.es-CgRAQgUo.js";import"./ChatOverlay-CCrB-zxT.js";import"./chevron-down-CCqkGk_8.js";import"./index-ChSsEM4z.js";import"./select-D0gOR1E7.js";import"./search-BloCxLo6.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.309.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/const c=e("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);
|
|
8
|
-
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function u(e){return null==e}var p={isNothing:u,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:u(e)?[]:[e]},repeat:function(e,t){var n,i="";for(n=0;n<t;n+=1)i+=e;return i},isNegativeZero:function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},extend:function(e,t){var n,i,r,o;if(t)for(n=0,i=(o=Object.keys(t)).length;n<i;n+=1)e[r=o[n]]=t[r];return e}};function f(e,t){var n="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+="\n\n"+e.mark.snippet),i+" "+n):i}function d(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=f(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,d.prototype.toString=function(e){return this.name+": "+f(this,e)};var h=d;function m(e,t,n,i,r){var o="",a="",l=Math.floor(r/2)-1;return i-t>l&&(t=i-l+(o=" ... ").length),n-i>l&&(n=i+l-(a=" ...").length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:i-t+o.length}}function g(e,t){return p.repeat(" ",t-e.length)+e}var y=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var n,i=/\r?\n|\r|\0/g,r=[0],o=[],a=-1;n=i.exec(e.buffer);)o.push(n.index),r.push(n.index+n[0].length),e.position<=n.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l,s,c="",u=Math.min(e.line+t.linesAfter,o.length).toString().length,f=t.maxLength-(t.indent+u+3);for(l=1;l<=t.linesBefore&&!(a-l<0);l++)s=m(e.buffer,r[a-l],o[a-l],e.position-(r[a]-r[a-l]),f),c=p.repeat(" ",t.indent)+g((e.line-l+1).toString(),u)+" | "+s.str+"\n"+c;for(s=m(e.buffer,r[a],o[a],e.position,f),c+=p.repeat(" ",t.indent)+g((e.line+1).toString(),u)+" | "+s.str+"\n",c+=p.repeat("-",t.indent+u+3+s.pos)+"^\n",l=1;l<=t.linesAfter&&!(a+l>=o.length);l++)s=m(e.buffer,r[a+l],o[a+l],e.position-(r[a]-r[a+l]),f),c+=p.repeat(" ",t.indent)+g((e.line+l+1).toString(),u)+" | "+s.str+"\n";return c.replace(/\n$/,"")},x=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],b=["scalar","sequence","mapping"];var A=function(e,t){var n,i;if(t=t||{},Object.keys(t).forEach(function(t){if(-1===x.indexOf(t))throw new h('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=(n=t.styleAliases||null,i={},null!==n&&Object.keys(n).forEach(function(e){n[e].forEach(function(t){i[String(t)]=e})}),i),-1===b.indexOf(this.kind))throw new h('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function v(e,t){var n=[];return e[t].forEach(function(e){var t=n.length;n.forEach(function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)}),n[t]=e}),n}function k(e){return this.extend(e)}k.prototype.extend=function(e){var t=[],n=[];if(e instanceof A)n.push(e);else if(Array.isArray(e))n=n.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new h("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit))}t.forEach(function(e){if(!(e instanceof A))throw new h("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new h("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new h("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),n.forEach(function(e){if(!(e instanceof A))throw new h("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(k.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(n),i.compiledImplicit=v(i,"implicit"),i.compiledExplicit=v(i,"explicit"),i.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function i(e){e.multi?(n.multi[e.kind].push(e),n.multi.fallback.push(e)):n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(i);return n}(i.compiledImplicit,i.compiledExplicit),i};var w=new k({explicit:[new A("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}}),new A("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}}),new A("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})]});var C=new A("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});var j=new A("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function I(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function N(e){return 48<=e&&e<=55}function S(e){return 48<=e&&e<=57}var M=new A("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n=e.length,i=0,r=!1;if(!n)return!1;if("-"!==(t=e[i])&&"+"!==t||(t=e[++i]),"0"===t){if(i+1===n)return!0;if("b"===(t=e[++i])){for(i++;i<n;i++)if("_"!==(t=e[i])){if("0"!==t&&"1"!==t)return!1;r=!0}return r&&"_"!==t}if("x"===t){for(i++;i<n;i++)if("_"!==(t=e[i])){if(!I(e.charCodeAt(i)))return!1;r=!0}return r&&"_"!==t}if("o"===t){for(i++;i<n;i++)if("_"!==(t=e[i])){if(!N(e.charCodeAt(i)))return!1;r=!0}return r&&"_"!==t}}if("_"===t)return!1;for(;i<n;i++)if("_"!==(t=e[i])){if(!S(e.charCodeAt(i)))return!1;r=!0}return!(!r||"_"===t)},construct:function(e){var t,n=e,i=1;if(-1!==n.indexOf("_")&&(n=n.replace(/_/g,"")),"-"!==(t=n[0])&&"+"!==t||("-"===t&&(i=-1),t=(n=n.slice(1))[0]),"0"===n)return 0;if("0"===t){if("b"===n[1])return i*parseInt(n.slice(2),2);if("x"===n[1])return i*parseInt(n.slice(2),16);if("o"===n[1])return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&e%1==0&&!p.isNegativeZero(e)},represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),O=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var T=/^[-+]?[0-9]+e/;var E=new A("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!O.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||p.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(p.isNegativeZero(e))return"-0.0";return n=e.toString(10),T.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"}),L=w.extend({implicit:[C,j,M,E]}),F=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),_=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");var $=new A("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==F.exec(e)||null!==_.exec(e))},construct:function(e){var t,n,i,r,o,a,l,s,c=0,u=null;if(null===(t=F.exec(e))&&(t=_.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],i=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(n,i,r));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(u=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(u=-u)),s=new Date(Date.UTC(n,i,r,o,a,l,c)),u&&s.setTime(s.getTime()-u),s},instanceOf:Date,represent:function(e){return e.toISOString()}});var Y=new A("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";var U=new A("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i=0,r=e.length,o=D;for(n=0;n<r;n++)if(!((t=o.indexOf(e.charAt(n)))>64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),r=i.length,o=D,a=0,l=[];for(t=0;t<r;t++)t%4==0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return 0===(n=r%4*6)?(l.push(a>>16&255),l.push(a>>8&255),l.push(255&a)):18===n?(l.push(a>>10&255),l.push(a>>2&255)):12===n&&l.push(a>>4&255),new Uint8Array(l)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,n,i="",r=0,o=e.length,a=D;for(t=0;t<o;t++)t%3==0&&t&&(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return 0===(n=o%3)?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2===n?(i+=a[r>>10&63],i+=a[r>>4&63],i+=a[r<<2&63],i+=a[64]):1===n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}}),q=Object.prototype.hasOwnProperty,B=Object.prototype.toString;var R=new A("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=[],l=e;for(t=0,n=l.length;t<n;t+=1){if(i=l[t],o=!1,"[object Object]"!==B.call(i))return!1;for(r in i)if(q.call(i,r)){if(o)return!1;o=!0}if(!o)return!1;if(-1!==a.indexOf(r))return!1;a.push(r)}return!0},construct:function(e){return null!==e?e:[]}}),z=Object.prototype.toString;var W=new A("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(i=a[t],"[object Object]"!==z.call(i))return!1;if(1!==(r=Object.keys(i)).length)return!1;o[t]=[r[0],i[r[0]]]}return!0},construct:function(e){if(null===e)return[];var t,n,i,r,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1)i=a[t],r=Object.keys(i),o[t]=[r[0],i[r[0]]];return o}}),P=Object.prototype.hasOwnProperty;var G=new A("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;var t,n=e;for(t in n)if(P.call(n,t)&&null!==n[t])return!1;return!0},construct:function(e){return null!==e?e:{}}}),Z=L.extend({implicit:[$,Y],explicit:[U,R,W,G]}),V=Object.prototype.hasOwnProperty,X=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,H=/[\x85\u2028\u2029]/,K=/[,\[\]\{\}]/,J=/^(?:!|!!|![a-z\-]+!)$/i,Q=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function ee(e){return Object.prototype.toString.call(e)}function te(e){return 10===e||13===e}function ne(e){return 9===e||32===e}function ie(e){return 9===e||32===e||10===e||13===e}function re(e){return 44===e||91===e||93===e||123===e||125===e}function oe(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function ae(e){return 120===e?2:117===e?4:85===e?8:0}function le(e){return 48<=e&&e<=57?e-48:-1}function se(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"
":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function ce(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}function ue(e,t,n){"__proto__"===t?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}for(var pe=new Array(256),fe=new Array(256),de=0;de<256;de++)pe[de]=se(de)?1:0,fe[de]=se(de);function he(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Z,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function me(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=y(n),new h(t,n)}function ge(e,t){throw me(e,t)}function ye(e,t){e.onWarning&&e.onWarning.call(null,me(e,t))}var xe={YAML:function(e,t,n){var i,r,o;null!==e.version&&ge(e,"duplication of %YAML directive"),1!==n.length&&ge(e,"YAML directive accepts exactly one argument"),null===(i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&ge(e,"ill-formed argument of the YAML directive"),r=parseInt(i[1],10),o=parseInt(i[2],10),1!==r&&ge(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&ye(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var i,r;2!==n.length&&ge(e,"TAG directive accepts exactly two arguments"),i=n[0],r=n[1],J.test(i)||ge(e,"ill-formed tag handle (first argument) of the TAG directive"),V.call(e.tagMap,i)&&ge(e,'there is a previously declared suffix for "'+i+'" tag handle'),Q.test(r)||ge(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(o){ge(e,"tag prefix is malformed: "+r)}e.tagMap[i]=r}};function be(e,t,n,i){var r,o,a,l;if(t<n){if(l=e.input.slice(t,n),i)for(r=0,o=l.length;r<o;r+=1)9===(a=l.charCodeAt(r))||32<=a&&a<=1114111||ge(e,"expected valid JSON character");else X.test(l)&&ge(e,"the stream contains non-printable characters");e.result+=l}}function Ae(e,t,n,i){var r,o,a,l;for(p.isObject(n)||ge(e,"cannot merge mappings; the provided source object is unacceptable"),a=0,l=(r=Object.keys(n)).length;a<l;a+=1)o=r[a],V.call(t,o)||(ue(t,o,n[o]),i[o]=!0)}function ve(e,t,n,i,r,o,a,l,s){var c,u;if(Array.isArray(r))for(c=0,u=(r=Array.prototype.slice.call(r)).length;c<u;c+=1)Array.isArray(r[c])&&ge(e,"nested arrays are not supported inside keys"),"object"==typeof r&&"[object Object]"===ee(r[c])&&(r[c]="[object Object]");if("object"==typeof r&&"[object Object]"===ee(r)&&(r="[object Object]"),r=String(r),null===t&&(t={}),"tag:yaml.org,2002:merge"===i)if(Array.isArray(o))for(c=0,u=o.length;c<u;c+=1)Ae(e,t,o[c],n);else Ae(e,t,o,n);else e.json||V.call(n,r)||!V.call(t,r)||(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=s||e.position,ge(e,"duplicated mapping key")),ue(t,r,o),delete n[r];return t}function ke(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):ge(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function we(e,t,n){for(var i=0,r=e.input.charCodeAt(e.position);0!==r;){for(;ne(r);)9===r&&-1===e.firstTabInLine&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(t&&35===r)do{r=e.input.charCodeAt(++e.position)}while(10!==r&&13!==r&&0!==r);if(!te(r))break;for(ke(e),r=e.input.charCodeAt(e.position),i++,e.lineIndent=0;32===r;)e.lineIndent++,r=e.input.charCodeAt(++e.position)}return-1!==n&&0!==i&&e.lineIndent<n&&ye(e,"deficient indentation"),i}function Ce(e){var t,n=e.position;return!(45!==(t=e.input.charCodeAt(n))&&46!==t||t!==e.input.charCodeAt(n+1)||t!==e.input.charCodeAt(n+2)||(n+=3,0!==(t=e.input.charCodeAt(n))&&!ie(t)))}function je(e,t){1===t?e.result+=" ":t>1&&(e.result+=p.repeat("\n",t-1))}function Ie(e,t){var n,i,r=e.tag,o=e.anchor,a=[],l=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),i=e.input.charCodeAt(e.position);0!==i&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,ge(e,"tab characters must not be used in indentation")),45===i)&&ie(e.input.charCodeAt(e.position+1));)if(l=!0,e.position++,we(e,!0,-1)&&e.lineIndent<=t)a.push(null),i=e.input.charCodeAt(e.position);else if(n=e.line,Me(e,t,3,!1,!0),a.push(e.result),we(e,!0,-1),i=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==i)ge(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return!!l&&(e.tag=r,e.anchor=o,e.kind="sequence",e.result=a,!0)}function Ne(e){var t,n,i,r,o=!1,a=!1;if(33!==(r=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&ge(e,"duplication of a tag property"),60===(r=e.input.charCodeAt(++e.position))?(o=!0,r=e.input.charCodeAt(++e.position)):33===r?(a=!0,n="!!",r=e.input.charCodeAt(++e.position)):n="!",t=e.position,o){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&62!==r);e.position<e.length?(i=e.input.slice(t,e.position),r=e.input.charCodeAt(++e.position)):ge(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==r&&!ie(r);)33===r&&(a?ge(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),J.test(n)||ge(e,"named tag handle cannot contain such characters"),a=!0,t=e.position+1)),r=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),K.test(i)&&ge(e,"tag suffix cannot contain flow indicator characters")}i&&!Q.test(i)&&ge(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch(l){ge(e,"tag name is malformed: "+i)}return o?e.tag=i:V.call(e.tagMap,n)?e.tag=e.tagMap[n]+i:"!"===n?e.tag="!"+i:"!!"===n?e.tag="tag:yaml.org,2002:"+i:ge(e,'undeclared tag handle "'+n+'"'),!0}function Se(e){var t,n;if(38!==(n=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&ge(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!ie(n)&&!re(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&ge(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function Me(e,t,n,i,r){var o,a,l,s,c,u,f,d,h,m=1,g=!1,y=!1;if(null!==e.listener&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=a=l=4===n||3===n,i&&we(e,!0,-1)&&(g=!0,e.lineIndent>t?m=1:e.lineIndent===t?m=0:e.lineIndent<t&&(m=-1)),1===m)for(;Ne(e)||Se(e);)we(e,!0,-1)?(g=!0,l=o,e.lineIndent>t?m=1:e.lineIndent===t?m=0:e.lineIndent<t&&(m=-1)):l=!1;if(l&&(l=g||r),1!==m&&4!==n||(d=1===n||2===n?t:t+1,h=e.position-e.lineStart,1===m?l&&(Ie(e,h)||function(e,t,n){var i,r,o,a,l,s,c,u=e.tag,p=e.anchor,f={},d=Object.create(null),h=null,m=null,g=null,y=!1,x=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=f),c=e.input.charCodeAt(e.position);0!==c;){if(y||-1===e.firstTabInLine||(e.position=e.firstTabInLine,ge(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),o=e.line,63!==c&&58!==c||!ie(i)){if(a=e.line,l=e.lineStart,s=e.position,!Me(e,n,2,!1,!0))break;if(e.line===o){for(c=e.input.charCodeAt(e.position);ne(c);)c=e.input.charCodeAt(++e.position);if(58===c)ie(c=e.input.charCodeAt(++e.position))||ge(e,"a whitespace character is expected after the key-value separator within a block mapping"),y&&(ve(e,f,d,h,m,null,a,l,s),h=m=g=null),x=!0,y=!1,r=!1,h=e.tag,m=e.result;else{if(!x)return e.tag=u,e.anchor=p,!0;ge(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!x)return e.tag=u,e.anchor=p,!0;ge(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===c?(y&&(ve(e,f,d,h,m,null,a,l,s),h=m=g=null),x=!0,y=!0,r=!0):y?(y=!1,r=!0):ge(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,c=i;if((e.line===o||e.lineIndent>t)&&(y&&(a=e.line,l=e.lineStart,s=e.position),Me(e,t,4,!0,r)&&(y?m=e.result:g=e.result),y||(ve(e,f,d,h,m,g,a,l,s),h=m=g=null),we(e,!0,-1),c=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&0!==c)ge(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return y&&ve(e,f,d,h,m,null,a,l,s),x&&(e.tag=u,e.anchor=p,e.kind="mapping",e.result=f),x}(e,h,d))||function(e,t){var n,i,r,o,a,l,s,c,u,p,f,d,h=!0,m=e.tag,g=e.anchor,y=Object.create(null);if(91===(d=e.input.charCodeAt(e.position)))a=93,c=!1,o=[];else{if(123!==d)return!1;a=125,c=!0,o={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=o),d=e.input.charCodeAt(++e.position);0!==d;){if(we(e,!0,t),(d=e.input.charCodeAt(e.position))===a)return e.position++,e.tag=m,e.anchor=g,e.kind=c?"mapping":"sequence",e.result=o,!0;h?44===d&&ge(e,"expected the node content, but found ','"):ge(e,"missed comma between flow collection entries"),f=null,l=s=!1,63===d&&ie(e.input.charCodeAt(e.position+1))&&(l=s=!0,e.position++,we(e,!0,t)),n=e.line,i=e.lineStart,r=e.position,Me(e,t,1,!1,!0),p=e.tag,u=e.result,we(e,!0,t),d=e.input.charCodeAt(e.position),!s&&e.line!==n||58!==d||(l=!0,d=e.input.charCodeAt(++e.position),we(e,!0,t),Me(e,t,1,!1,!0),f=e.result),c?ve(e,o,y,p,u,f,n,i,r):l?o.push(ve(e,null,y,p,u,f,n,i,r)):o.push(u),we(e,!0,t),44===(d=e.input.charCodeAt(e.position))?(h=!0,d=e.input.charCodeAt(++e.position)):h=!1}ge(e,"unexpected end of the stream within a flow collection")}(e,d)?y=!0:(a&&function(e,t){var n,i,r,o,a=1,l=!1,s=!1,c=t,u=0,f=!1;if(124===(o=e.input.charCodeAt(e.position)))i=!1;else{if(62!==o)return!1;i=!0}for(e.kind="scalar",e.result="";0!==o;)if(43===(o=e.input.charCodeAt(++e.position))||45===o)1===a?a=43===o?3:2:ge(e,"repeat of a chomping mode identifier");else{if(!((r=le(o))>=0))break;0===r?ge(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?ge(e,"repeat of an indentation width identifier"):(c=t+r-1,s=!0)}if(ne(o)){do{o=e.input.charCodeAt(++e.position)}while(ne(o));if(35===o)do{o=e.input.charCodeAt(++e.position)}while(!te(o)&&0!==o)}for(;0!==o;){for(ke(e),e.lineIndent=0,o=e.input.charCodeAt(e.position);(!s||e.lineIndent<c)&&32===o;)e.lineIndent++,o=e.input.charCodeAt(++e.position);if(!s&&e.lineIndent>c&&(c=e.lineIndent),te(o))u++;else{if(e.lineIndent<c){3===a?e.result+=p.repeat("\n",l?1+u:u):1===a&&l&&(e.result+="\n");break}for(i?ne(o)?(f=!0,e.result+=p.repeat("\n",l?1+u:u)):f?(f=!1,e.result+=p.repeat("\n",u+1)):0===u?l&&(e.result+=" "):e.result+=p.repeat("\n",u):e.result+=p.repeat("\n",l?1+u:u),l=!0,s=!0,u=0,n=e.position;!te(o)&&0!==o;)o=e.input.charCodeAt(++e.position);be(e,n,e.position,!1)}}return!0}(e,d)||function(e,t){var n,i,r;if(39!==(n=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,i=r=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(be(e,i,e.position,!0),39!==(n=e.input.charCodeAt(++e.position)))return!0;i=e.position,e.position++,r=e.position}else te(n)?(be(e,i,r,!0),je(e,we(e,!1,t)),i=r=e.position):e.position===e.lineStart&&Ce(e)?ge(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);ge(e,"unexpected end of the stream within a single quoted scalar")}(e,d)||function(e,t){var n,i,r,o,a,l;if(34!==(l=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;0!==(l=e.input.charCodeAt(e.position));){if(34===l)return be(e,n,e.position,!0),e.position++,!0;if(92===l){if(be(e,n,e.position,!0),te(l=e.input.charCodeAt(++e.position)))we(e,!1,t);else if(l<256&&pe[l])e.result+=fe[l],e.position++;else if((a=ae(l))>0){for(r=a,o=0;r>0;r--)(a=oe(l=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+a:ge(e,"expected hexadecimal character");e.result+=ce(o),e.position++}else ge(e,"unknown escape sequence");n=i=e.position}else te(l)?(be(e,n,i,!0),je(e,we(e,!1,t)),n=i=e.position):e.position===e.lineStart&&Ce(e)?ge(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}ge(e,"unexpected end of the stream within a double quoted scalar")}(e,d)?y=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!ie(i)&&!re(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&ge(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),V.call(e.anchorMap,n)||ge(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],we(e,!0,-1),!0}(e)?function(e,t,n){var i,r,o,a,l,s,c,u,p=e.kind,f=e.result;if(ie(u=e.input.charCodeAt(e.position))||re(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ie(i=e.input.charCodeAt(e.position+1))||n&&re(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==u;){if(58===u){if(ie(i=e.input.charCodeAt(e.position+1))||n&&re(i))break}else if(35===u){if(ie(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&Ce(e)||n&&re(u))break;if(te(u)){if(l=e.line,s=e.lineStart,c=e.lineIndent,we(e,!1,-1),e.lineIndent>=t){a=!0,u=e.input.charCodeAt(e.position);continue}e.position=o,e.line=l,e.lineStart=s,e.lineIndent=c;break}}a&&(be(e,r,o,!1),je(e,e.line-l),r=o=e.position,a=!1),ne(u)||(o=e.position+1),u=e.input.charCodeAt(++e.position)}return be(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,d,1===n)&&(y=!0,null===e.tag&&(e.tag="?")):(y=!0,null===e.tag&&null===e.anchor||ge(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===m&&(y=l&&Ie(e,h))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&ge(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),s=0,c=e.implicitTypes.length;s<c;s+=1)if((f=e.implicitTypes[s]).resolve(e.result)){e.result=f.construct(e.result),e.tag=f.tag,null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);break}}else if("!"!==e.tag){if(V.call(e.typeMap[e.kind||"fallback"],e.tag))f=e.typeMap[e.kind||"fallback"][e.tag];else for(f=null,s=0,c=(u=e.typeMap.multi[e.kind||"fallback"]).length;s<c;s+=1)if(e.tag.slice(0,u[s].tag.length)===u[s].tag){f=u[s];break}f||ge(e,"unknown tag !<"+e.tag+">"),null!==e.result&&f.kind!==e.kind&&ge(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result,e.tag)?(e.result=f.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):ge(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||y}function Oe(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(we(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!ie(r);)r=e.input.charCodeAt(++e.position);for(i=[],(n=e.input.slice(t,e.position)).length<1&&ge(e,"directive name must not be less than one character in length");0!==r;){for(;ne(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!te(r));break}if(te(r))break;for(t=e.position;0!==r&&!ie(r);)r=e.input.charCodeAt(++e.position);i.push(e.input.slice(t,e.position))}0!==r&&ke(e),V.call(xe,n)?xe[n](e,n,i):ye(e,'unknown document directive "'+n+'"')}we(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,we(e,!0,-1)):a&&ge(e,"directives end mark is expected"),Me(e,e.lineIndent-1,4,!1,!0),we(e,!0,-1),e.checkLineBreaks&&H.test(e.input.slice(o,e.position))&&ye(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Ce(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,we(e,!0,-1)):e.position<e.length-1&&ge(e,"end of the stream or a document separator is expected")}var Te={load:function(e,t){var n=function(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new he(e,t),i=e.indexOf("\0");for(-1!==i&&(n.position=i,ge(n,"null byte is not allowed in input")),n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)Oe(n);return n.documents}(e,t);if(0!==n.length){if(1===n.length)return n[0];throw new h("expected a single document in the stream, but found more")}}}.load;function Ee(e){var t;const n=e.pages||[],i=e.relations||[];if(0===n.length)return{nodes:[],edges:[]};const r=new Map,o=new Map;for(const d of n)r.set(d.id,[]),o.set(d.id,0);for(const d of i)null==(t=r.get(d.from))||t.push(d.to),o.set(d.to,(o.get(d.to)||0)+1);const a=new Map,l=[];for(const d of n)0===(o.get(d.id)||0)&&(l.push(d.id),a.set(d.id,0));let s=0;for(;l.length>0;){const e=l.shift(),t=a.get(e)||0;for(const n of r.get(e)||[]){const e=t+1;e>(a.get(n)||0)&&(a.set(n,e),e>s&&(s=e));const i=(o.get(n)||1)-1;o.set(n,i),i<=0&&l.push(n)}}for(const d of n)a.has(d.id)||a.set(d.id,s+1);const c=new Map;for(const d of n){const e=a.get(d.id)||0;c.has(e)||c.set(e,[]),c.get(e).push(d.id)}const u=[],p=new Map(n.map(e=>[e.id,e]));for(const[d,h]of c){const e=-(160*h.length+60*(h.length-1))/2;h.forEach((t,n)=>{const i=p.get(t);u.push({id:t,title:(null==i?void 0:i.title)||t,x:e+220*n+80,y:130*d,layer:d})})}const f=i.map(e=>({from:e.from,to:e.to,label:e.label}));return{nodes:u,edges:f}}const Le=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#06b6d4","#f97316","#6366f1"];function Fe({folderPath:e}){const[u,p]=t.useState(null),[f,d]=t.useState(!0),[h,m]=t.useState(null),[g,y]=t.useState(1),[x,b]=t.useState({x:0,y:0}),A=t.useRef(!1),v=t.useRef({x:0,y:0}),[,k]=t.useState(0),w=t.useRef(null),C=t.useRef(null),j=`${e}/.notebook/graph.yaml`,I=t.useCallback(async()=>{d(!0),m(null);try{const e=await n(j);if(!e.content)return m("graph.yaml is empty"),void p(null);const t=Te(e.content);p(t),y(1),b({x:0,y:0})}catch{m("Cannot read .notebook/graph.yaml"),p(null)}finally{d(!1)}},[j]);t.useEffect(()=>{I()},[I]);const N=t.useCallback(e=>{e.preventDefault();const t=e.deltaY>0?-.1:.1;y(e=>Math.max(.2,Math.min(3,e+t)))},[]),S=t.useCallback(e=>{0===e.button&&(A.current=!0,k(e=>e+1),b(t=>(v.current={x:e.clientX-t.x,y:e.clientY-t.y},t)))},[]),M=t.useCallback(e=>{A.current&&b({x:e.clientX-v.current.x,y:e.clientY-v.current.y})},[]),O=t.useCallback(()=>{A.current=!1,k(e=>e+1)},[]),T=t.useCallback(()=>{if(!u||!C.current)return;const{nodes:e}=Ee(u);if(0===e.length)return;const t=Math.min(...e.map(e=>e.x))-100,n=Math.max(...e.map(e=>e.x))+100,i=Math.min(...e.map(e=>e.y))-40,r=Math.max(...e.map(e=>e.y))+60,o=n-t,a=r-i,l=C.current.clientWidth,s=C.current.clientHeight,c=.9*Math.min(l/o,s/a,1.5);y(c),b({x:l/2-(t+n)/2*c,y:s/2-(i+r)/2*c})},[u]),{nodes:E,edges:L}=t.useMemo(()=>u?Ee(u):{nodes:[],edges:[]},[u]),F=t.useMemo(()=>new Map(E.map(e=>[e.id,e])),[E]);return t.useEffect(()=>{if(u&&!f){const e=setTimeout(T,50);return()=>clearTimeout(e)}},[u,f,T]),f?i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:i.jsx(r,{className:"h-5 w-5 animate-spin"})}):h||!u?i.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-muted-foreground text-sm px-4 text-center",children:[i.jsx("p",{children:h||"No graph data"}),i.jsxs(o,{variant:"ghost",size:"sm",onClick:()=>{I()},children:[i.jsx(a,{className:"h-3 w-3 mr-1"})," Retry"]})]}):i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b shrink-0",children:[i.jsxs("span",{className:"text-xs text-muted-foreground mr-auto",children:[E.length," pages, ",L.length," relations"]}),i.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>y(e=>Math.min(3,e+.2)),children:i.jsx(l,{className:"h-3 w-3"})}),i.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>y(e=>Math.max(.2,e-.2)),children:i.jsx(s,{className:"h-3 w-3"})}),i.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:T,children:i.jsx(c,{className:"h-3 w-3"})}),i.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{I()},children:i.jsx(a,{className:"h-3 w-3"})})]}),i.jsx("div",{ref:C,className:"flex-1 overflow-hidden cursor-grab active:cursor-grabbing bg-muted/30",onWheel:N,onMouseDown:S,onMouseMove:M,onMouseUp:O,onMouseLeave:O,children:i.jsxs("svg",{ref:w,width:"100%",height:"100%",style:{userSelect:"none"},children:[i.jsx("defs",{children:i.jsx("marker",{id:"arrowhead",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"8",markerHeight:"6",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",className:"fill-muted-foreground/60"})})}),i.jsxs("g",{transform:`translate(${x.x}, ${x.y}) scale(${g})`,children:[L.map((e,t)=>{const n=F.get(e.from),r=F.get(e.to);if(!n||!r)return null;const o=n.y+20,a=r.y-20,l=(o+a)/2;return i.jsxs("g",{children:[i.jsx("path",{d:`M ${n.x} ${o} C ${n.x} ${l}, ${r.x} ${l}, ${r.x} ${a}`,fill:"none",className:"stroke-muted-foreground/40",strokeWidth:1.5,markerEnd:"url(#arrowhead)"}),e.label&&i.jsx("text",{x:(n.x+r.x)/2,y:l-4,textAnchor:"middle",className:"fill-muted-foreground/60",fontSize:9,children:e.label})]},`edge-${t}`)}),E.map(e=>{const t=Le[e.layer%Le.length];return i.jsxs("g",{transform:`translate(${e.x-70}, ${e.y-18})`,children:[i.jsx("rect",{width:140,height:36,rx:8,fill:t,fillOpacity:.15,stroke:t,strokeWidth:1.5}),i.jsx("text",{x:70,y:19,textAnchor:"middle",dominantBaseline:"middle",className:"fill-foreground",fontSize:11,fontWeight:500,children:e.title.length>14?e.title.slice(0,13)+"…":e.title})]},e.id)})]})]})})]})}export{Fe as GraphPreview};
|
|
8
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function u(e){return null==e}var p={isNothing:u,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:u(e)?[]:[e]},repeat:function(e,t){var n,i="";for(n=0;n<t;n+=1)i+=e;return i},isNegativeZero:function(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e},extend:function(e,t){var n,i,r,o;if(t)for(n=0,i=(o=Object.keys(t)).length;n<i;n+=1)e[r=o[n]]=t[r];return e}};function f(e,t){var n="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+="\n\n"+e.mark.snippet),i+" "+n):i}function d(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=f(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}d.prototype=Object.create(Error.prototype),d.prototype.constructor=d,d.prototype.toString=function(e){return this.name+": "+f(this,e)};var h=d;function m(e,t,n,i,r){var o="",a="",l=Math.floor(r/2)-1;return i-t>l&&(t=i-l+(o=" ... ").length),n-i>l&&(n=i+l-(a=" ...").length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:i-t+o.length}}function g(e,t){return p.repeat(" ",t-e.length)+e}var y=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var n,i=/\r?\n|\r|\0/g,r=[0],o=[],a=-1;n=i.exec(e.buffer);)o.push(n.index),r.push(n.index+n[0].length),e.position<=n.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l,s,c="",u=Math.min(e.line+t.linesAfter,o.length).toString().length,f=t.maxLength-(t.indent+u+3);for(l=1;l<=t.linesBefore&&!(a-l<0);l++)s=m(e.buffer,r[a-l],o[a-l],e.position-(r[a]-r[a-l]),f),c=p.repeat(" ",t.indent)+g((e.line-l+1).toString(),u)+" | "+s.str+"\n"+c;for(s=m(e.buffer,r[a],o[a],e.position,f),c+=p.repeat(" ",t.indent)+g((e.line+1).toString(),u)+" | "+s.str+"\n",c+=p.repeat("-",t.indent+u+3+s.pos)+"^\n",l=1;l<=t.linesAfter&&!(a+l>=o.length);l++)s=m(e.buffer,r[a+l],o[a+l],e.position-(r[a]-r[a+l]),f),c+=p.repeat(" ",t.indent)+g((e.line+l+1).toString(),u)+" | "+s.str+"\n";return c.replace(/\n$/,"")},x=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],b=["scalar","sequence","mapping"];var A=function(e,t){var n,i;if(t=t||{},Object.keys(t).forEach(function(t){if(-1===x.indexOf(t))throw new h('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=(n=t.styleAliases||null,i={},null!==n&&Object.keys(n).forEach(function(e){n[e].forEach(function(t){i[String(t)]=e})}),i),-1===b.indexOf(this.kind))throw new h('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function v(e,t){var n=[];return e[t].forEach(function(e){var t=n.length;n.forEach(function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)}),n[t]=e}),n}function k(e){return this.extend(e)}k.prototype.extend=function(e){var t=[],n=[];if(e instanceof A)n.push(e);else if(Array.isArray(e))n=n.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new h("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit))}t.forEach(function(e){if(!(e instanceof A))throw new h("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new h("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new h("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),n.forEach(function(e){if(!(e instanceof A))throw new h("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(k.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(n),i.compiledImplicit=v(i,"implicit"),i.compiledExplicit=v(i,"explicit"),i.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function i(e){e.multi?(n.multi[e.kind].push(e),n.multi.fallback.push(e)):n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e<t;e+=1)arguments[e].forEach(i);return n}(i.compiledImplicit,i.compiledExplicit),i};var w=new k({explicit:[new A("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return null!==e?e:""}}),new A("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return null!==e?e:[]}}),new A("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return null!==e?e:{}}})]});var C=new A("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(e){if(null===e)return!0;var t=e.length;return 1===t&&"~"===e||4===t&&("null"===e||"Null"===e||"NULL"===e)},construct:function(){return null},predicate:function(e){return null===e},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});var j=new A("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t=e.length;return 4===t&&("true"===e||"True"===e||"TRUE"===e)||5===t&&("false"===e||"False"===e||"FALSE"===e)},construct:function(e){return"true"===e||"True"===e||"TRUE"===e},predicate:function(e){return"[object Boolean]"===Object.prototype.toString.call(e)},represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function I(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function N(e){return 48<=e&&e<=55}function S(e){return 48<=e&&e<=57}var M=new A("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n=e.length,i=0,r=!1;if(!n)return!1;if("-"!==(t=e[i])&&"+"!==t||(t=e[++i]),"0"===t){if(i+1===n)return!0;if("b"===(t=e[++i])){for(i++;i<n;i++)if("_"!==(t=e[i])){if("0"!==t&&"1"!==t)return!1;r=!0}return r&&"_"!==t}if("x"===t){for(i++;i<n;i++)if("_"!==(t=e[i])){if(!I(e.charCodeAt(i)))return!1;r=!0}return r&&"_"!==t}if("o"===t){for(i++;i<n;i++)if("_"!==(t=e[i])){if(!N(e.charCodeAt(i)))return!1;r=!0}return r&&"_"!==t}}if("_"===t)return!1;for(;i<n;i++)if("_"!==(t=e[i])){if(!S(e.charCodeAt(i)))return!1;r=!0}return!(!r||"_"===t)},construct:function(e){var t,n=e,i=1;if(-1!==n.indexOf("_")&&(n=n.replace(/_/g,"")),"-"!==(t=n[0])&&"+"!==t||("-"===t&&(i=-1),t=(n=n.slice(1))[0]),"0"===n)return 0;if("0"===t){if("b"===n[1])return i*parseInt(n.slice(2),2);if("x"===n[1])return i*parseInt(n.slice(2),16);if("o"===n[1])return i*parseInt(n.slice(2),8)}return i*parseInt(n,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&e%1==0&&!p.isNegativeZero(e)},represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),O=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var T=/^[-+]?[0-9]+e/;var E=new A("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!O.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||p.isNegativeZero(e))},represent:function(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(p.isNegativeZero(e))return"-0.0";return n=e.toString(10),T.test(n)?n.replace("e",".e"):n},defaultStyle:"lowercase"}),L=w.extend({implicit:[C,j,M,E]}),F=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),_=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");var $=new A("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==F.exec(e)||null!==_.exec(e))},construct:function(e){var t,n,i,r,o,a,l,s,c=0,u=null;if(null===(t=F.exec(e))&&(t=_.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],i=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(n,i,r));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(u=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(u=-u)),s=new Date(Date.UTC(n,i,r,o,a,l,c)),u&&s.setTime(s.getTime()-u),s},instanceOf:Date,represent:function(e){return e.toISOString()}});var Y=new A("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";var D=new A("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i=0,r=e.length,o=U;for(n=0;n<r;n++)if(!((t=o.indexOf(e.charAt(n)))>64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),r=i.length,o=U,a=0,l=[];for(t=0;t<r;t++)t%4==0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return 0===(n=r%4*6)?(l.push(a>>16&255),l.push(a>>8&255),l.push(255&a)):18===n?(l.push(a>>10&255),l.push(a>>2&255)):12===n&&l.push(a>>4&255),new Uint8Array(l)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,n,i="",r=0,o=e.length,a=U;for(t=0;t<o;t++)t%3==0&&t&&(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return 0===(n=o%3)?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2===n?(i+=a[r>>10&63],i+=a[r>>4&63],i+=a[r<<2&63],i+=a[64]):1===n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}}),q=Object.prototype.hasOwnProperty,B=Object.prototype.toString;var R=new A("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=[],l=e;for(t=0,n=l.length;t<n;t+=1){if(i=l[t],o=!1,"[object Object]"!==B.call(i))return!1;for(r in i)if(q.call(i,r)){if(o)return!1;o=!0}if(!o)return!1;if(-1!==a.indexOf(r))return!1;a.push(r)}return!0},construct:function(e){return null!==e?e:[]}}),z=Object.prototype.toString;var W=new A("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(i=a[t],"[object Object]"!==z.call(i))return!1;if(1!==(r=Object.keys(i)).length)return!1;o[t]=[r[0],i[r[0]]]}return!0},construct:function(e){if(null===e)return[];var t,n,i,r,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1)i=a[t],r=Object.keys(i),o[t]=[r[0],i[r[0]]];return o}}),P=Object.prototype.hasOwnProperty;var G=new A("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(e){if(null===e)return!0;var t,n=e;for(t in n)if(P.call(n,t)&&null!==n[t])return!1;return!0},construct:function(e){return null!==e?e:{}}}),Z=L.extend({implicit:[$,Y],explicit:[D,R,W,G]}),V=Object.prototype.hasOwnProperty,X=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,H=/[\x85\u2028\u2029]/,K=/[,\[\]\{\}]/,J=/^(?:!|!!|![a-z\-]+!)$/i,Q=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function ee(e){return Object.prototype.toString.call(e)}function te(e){return 10===e||13===e}function ne(e){return 9===e||32===e}function ie(e){return 9===e||32===e||10===e||13===e}function re(e){return 44===e||91===e||93===e||123===e||125===e}function oe(e){var t;return 48<=e&&e<=57?e-48:97<=(t=32|e)&&t<=102?t-97+10:-1}function ae(e){return 120===e?2:117===e?4:85===e?8:0}function le(e){return 48<=e&&e<=57?e-48:-1}function se(e){return 48===e?"\0":97===e?"":98===e?"\b":116===e||9===e?"\t":110===e?"\n":118===e?"\v":102===e?"\f":114===e?"\r":101===e?"":32===e?" ":34===e?'"':47===e?"/":92===e?"\\":78===e?"
":95===e?" ":76===e?"\u2028":80===e?"\u2029":""}function ce(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(55296+(e-65536>>10),56320+(e-65536&1023))}function ue(e,t,n){"__proto__"===t?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}for(var pe=new Array(256),fe=new Array(256),de=0;de<256;de++)pe[de]=se(de)?1:0,fe[de]=se(de);function he(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Z,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function me(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=y(n),new h(t,n)}function ge(e,t){throw me(e,t)}function ye(e,t){e.onWarning&&e.onWarning.call(null,me(e,t))}var xe={YAML:function(e,t,n){var i,r,o;null!==e.version&&ge(e,"duplication of %YAML directive"),1!==n.length&&ge(e,"YAML directive accepts exactly one argument"),null===(i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&ge(e,"ill-formed argument of the YAML directive"),r=parseInt(i[1],10),o=parseInt(i[2],10),1!==r&&ge(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&ye(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var i,r;2!==n.length&&ge(e,"TAG directive accepts exactly two arguments"),i=n[0],r=n[1],J.test(i)||ge(e,"ill-formed tag handle (first argument) of the TAG directive"),V.call(e.tagMap,i)&&ge(e,'there is a previously declared suffix for "'+i+'" tag handle'),Q.test(r)||ge(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(o){ge(e,"tag prefix is malformed: "+r)}e.tagMap[i]=r}};function be(e,t,n,i){var r,o,a,l;if(t<n){if(l=e.input.slice(t,n),i)for(r=0,o=l.length;r<o;r+=1)9===(a=l.charCodeAt(r))||32<=a&&a<=1114111||ge(e,"expected valid JSON character");else X.test(l)&&ge(e,"the stream contains non-printable characters");e.result+=l}}function Ae(e,t,n,i){var r,o,a,l;for(p.isObject(n)||ge(e,"cannot merge mappings; the provided source object is unacceptable"),a=0,l=(r=Object.keys(n)).length;a<l;a+=1)o=r[a],V.call(t,o)||(ue(t,o,n[o]),i[o]=!0)}function ve(e,t,n,i,r,o,a,l,s){var c,u;if(Array.isArray(r))for(c=0,u=(r=Array.prototype.slice.call(r)).length;c<u;c+=1)Array.isArray(r[c])&&ge(e,"nested arrays are not supported inside keys"),"object"==typeof r&&"[object Object]"===ee(r[c])&&(r[c]="[object Object]");if("object"==typeof r&&"[object Object]"===ee(r)&&(r="[object Object]"),r=String(r),null===t&&(t={}),"tag:yaml.org,2002:merge"===i)if(Array.isArray(o))for(c=0,u=o.length;c<u;c+=1)Ae(e,t,o[c],n);else Ae(e,t,o,n);else e.json||V.call(n,r)||!V.call(t,r)||(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=s||e.position,ge(e,"duplicated mapping key")),ue(t,r,o),delete n[r];return t}function ke(e){var t;10===(t=e.input.charCodeAt(e.position))?e.position++:13===t?(e.position++,10===e.input.charCodeAt(e.position)&&e.position++):ge(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function we(e,t,n){for(var i=0,r=e.input.charCodeAt(e.position);0!==r;){for(;ne(r);)9===r&&-1===e.firstTabInLine&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(t&&35===r)do{r=e.input.charCodeAt(++e.position)}while(10!==r&&13!==r&&0!==r);if(!te(r))break;for(ke(e),r=e.input.charCodeAt(e.position),i++,e.lineIndent=0;32===r;)e.lineIndent++,r=e.input.charCodeAt(++e.position)}return-1!==n&&0!==i&&e.lineIndent<n&&ye(e,"deficient indentation"),i}function Ce(e){var t,n=e.position;return!(45!==(t=e.input.charCodeAt(n))&&46!==t||t!==e.input.charCodeAt(n+1)||t!==e.input.charCodeAt(n+2)||(n+=3,0!==(t=e.input.charCodeAt(n))&&!ie(t)))}function je(e,t){1===t?e.result+=" ":t>1&&(e.result+=p.repeat("\n",t-1))}function Ie(e,t){var n,i,r=e.tag,o=e.anchor,a=[],l=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),i=e.input.charCodeAt(e.position);0!==i&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,ge(e,"tab characters must not be used in indentation")),45===i)&&ie(e.input.charCodeAt(e.position+1));)if(l=!0,e.position++,we(e,!0,-1)&&e.lineIndent<=t)a.push(null),i=e.input.charCodeAt(e.position);else if(n=e.line,Me(e,t,3,!1,!0),a.push(e.result),we(e,!0,-1),i=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==i)ge(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break;return!!l&&(e.tag=r,e.anchor=o,e.kind="sequence",e.result=a,!0)}function Ne(e){var t,n,i,r,o=!1,a=!1;if(33!==(r=e.input.charCodeAt(e.position)))return!1;if(null!==e.tag&&ge(e,"duplication of a tag property"),60===(r=e.input.charCodeAt(++e.position))?(o=!0,r=e.input.charCodeAt(++e.position)):33===r?(a=!0,n="!!",r=e.input.charCodeAt(++e.position)):n="!",t=e.position,o){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&62!==r);e.position<e.length?(i=e.input.slice(t,e.position),r=e.input.charCodeAt(++e.position)):ge(e,"unexpected end of the stream within a verbatim tag")}else{for(;0!==r&&!ie(r);)33===r&&(a?ge(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),J.test(n)||ge(e,"named tag handle cannot contain such characters"),a=!0,t=e.position+1)),r=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),K.test(i)&&ge(e,"tag suffix cannot contain flow indicator characters")}i&&!Q.test(i)&&ge(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch(l){ge(e,"tag name is malformed: "+i)}return o?e.tag=i:V.call(e.tagMap,n)?e.tag=e.tagMap[n]+i:"!"===n?e.tag="!"+i:"!!"===n?e.tag="tag:yaml.org,2002:"+i:ge(e,'undeclared tag handle "'+n+'"'),!0}function Se(e){var t,n;if(38!==(n=e.input.charCodeAt(e.position)))return!1;for(null!==e.anchor&&ge(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;0!==n&&!ie(n)&&!re(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&ge(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function Me(e,t,n,i,r){var o,a,l,s,c,u,f,d,h,m=1,g=!1,y=!1;if(null!==e.listener&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,o=a=l=4===n||3===n,i&&we(e,!0,-1)&&(g=!0,e.lineIndent>t?m=1:e.lineIndent===t?m=0:e.lineIndent<t&&(m=-1)),1===m)for(;Ne(e)||Se(e);)we(e,!0,-1)?(g=!0,l=o,e.lineIndent>t?m=1:e.lineIndent===t?m=0:e.lineIndent<t&&(m=-1)):l=!1;if(l&&(l=g||r),1!==m&&4!==n||(d=1===n||2===n?t:t+1,h=e.position-e.lineStart,1===m?l&&(Ie(e,h)||function(e,t,n){var i,r,o,a,l,s,c,u=e.tag,p=e.anchor,f={},d=Object.create(null),h=null,m=null,g=null,y=!1,x=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=f),c=e.input.charCodeAt(e.position);0!==c;){if(y||-1===e.firstTabInLine||(e.position=e.firstTabInLine,ge(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),o=e.line,63!==c&&58!==c||!ie(i)){if(a=e.line,l=e.lineStart,s=e.position,!Me(e,n,2,!1,!0))break;if(e.line===o){for(c=e.input.charCodeAt(e.position);ne(c);)c=e.input.charCodeAt(++e.position);if(58===c)ie(c=e.input.charCodeAt(++e.position))||ge(e,"a whitespace character is expected after the key-value separator within a block mapping"),y&&(ve(e,f,d,h,m,null,a,l,s),h=m=g=null),x=!0,y=!1,r=!1,h=e.tag,m=e.result;else{if(!x)return e.tag=u,e.anchor=p,!0;ge(e,"can not read an implicit mapping pair; a colon is missed")}}else{if(!x)return e.tag=u,e.anchor=p,!0;ge(e,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else 63===c?(y&&(ve(e,f,d,h,m,null,a,l,s),h=m=g=null),x=!0,y=!0,r=!0):y?(y=!1,r=!0):ge(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,c=i;if((e.line===o||e.lineIndent>t)&&(y&&(a=e.line,l=e.lineStart,s=e.position),Me(e,t,4,!0,r)&&(y?m=e.result:g=e.result),y||(ve(e,f,d,h,m,g,a,l,s),h=m=g=null),we(e,!0,-1),c=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&0!==c)ge(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return y&&ve(e,f,d,h,m,null,a,l,s),x&&(e.tag=u,e.anchor=p,e.kind="mapping",e.result=f),x}(e,h,d))||function(e,t){var n,i,r,o,a,l,s,c,u,p,f,d,h=!0,m=e.tag,g=e.anchor,y=Object.create(null);if(91===(d=e.input.charCodeAt(e.position)))a=93,c=!1,o=[];else{if(123!==d)return!1;a=125,c=!0,o={}}for(null!==e.anchor&&(e.anchorMap[e.anchor]=o),d=e.input.charCodeAt(++e.position);0!==d;){if(we(e,!0,t),(d=e.input.charCodeAt(e.position))===a)return e.position++,e.tag=m,e.anchor=g,e.kind=c?"mapping":"sequence",e.result=o,!0;h?44===d&&ge(e,"expected the node content, but found ','"):ge(e,"missed comma between flow collection entries"),f=null,l=s=!1,63===d&&ie(e.input.charCodeAt(e.position+1))&&(l=s=!0,e.position++,we(e,!0,t)),n=e.line,i=e.lineStart,r=e.position,Me(e,t,1,!1,!0),p=e.tag,u=e.result,we(e,!0,t),d=e.input.charCodeAt(e.position),!s&&e.line!==n||58!==d||(l=!0,d=e.input.charCodeAt(++e.position),we(e,!0,t),Me(e,t,1,!1,!0),f=e.result),c?ve(e,o,y,p,u,f,n,i,r):l?o.push(ve(e,null,y,p,u,f,n,i,r)):o.push(u),we(e,!0,t),44===(d=e.input.charCodeAt(e.position))?(h=!0,d=e.input.charCodeAt(++e.position)):h=!1}ge(e,"unexpected end of the stream within a flow collection")}(e,d)?y=!0:(a&&function(e,t){var n,i,r,o,a=1,l=!1,s=!1,c=t,u=0,f=!1;if(124===(o=e.input.charCodeAt(e.position)))i=!1;else{if(62!==o)return!1;i=!0}for(e.kind="scalar",e.result="";0!==o;)if(43===(o=e.input.charCodeAt(++e.position))||45===o)1===a?a=43===o?3:2:ge(e,"repeat of a chomping mode identifier");else{if(!((r=le(o))>=0))break;0===r?ge(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?ge(e,"repeat of an indentation width identifier"):(c=t+r-1,s=!0)}if(ne(o)){do{o=e.input.charCodeAt(++e.position)}while(ne(o));if(35===o)do{o=e.input.charCodeAt(++e.position)}while(!te(o)&&0!==o)}for(;0!==o;){for(ke(e),e.lineIndent=0,o=e.input.charCodeAt(e.position);(!s||e.lineIndent<c)&&32===o;)e.lineIndent++,o=e.input.charCodeAt(++e.position);if(!s&&e.lineIndent>c&&(c=e.lineIndent),te(o))u++;else{if(e.lineIndent<c){3===a?e.result+=p.repeat("\n",l?1+u:u):1===a&&l&&(e.result+="\n");break}for(i?ne(o)?(f=!0,e.result+=p.repeat("\n",l?1+u:u)):f?(f=!1,e.result+=p.repeat("\n",u+1)):0===u?l&&(e.result+=" "):e.result+=p.repeat("\n",u):e.result+=p.repeat("\n",l?1+u:u),l=!0,s=!0,u=0,n=e.position;!te(o)&&0!==o;)o=e.input.charCodeAt(++e.position);be(e,n,e.position,!1)}}return!0}(e,d)||function(e,t){var n,i,r;if(39!==(n=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,i=r=e.position;0!==(n=e.input.charCodeAt(e.position));)if(39===n){if(be(e,i,e.position,!0),39!==(n=e.input.charCodeAt(++e.position)))return!0;i=e.position,e.position++,r=e.position}else te(n)?(be(e,i,r,!0),je(e,we(e,!1,t)),i=r=e.position):e.position===e.lineStart&&Ce(e)?ge(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);ge(e,"unexpected end of the stream within a single quoted scalar")}(e,d)||function(e,t){var n,i,r,o,a,l;if(34!==(l=e.input.charCodeAt(e.position)))return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;0!==(l=e.input.charCodeAt(e.position));){if(34===l)return be(e,n,e.position,!0),e.position++,!0;if(92===l){if(be(e,n,e.position,!0),te(l=e.input.charCodeAt(++e.position)))we(e,!1,t);else if(l<256&&pe[l])e.result+=fe[l],e.position++;else if((a=ae(l))>0){for(r=a,o=0;r>0;r--)(a=oe(l=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+a:ge(e,"expected hexadecimal character");e.result+=ce(o),e.position++}else ge(e,"unknown escape sequence");n=i=e.position}else te(l)?(be(e,n,i,!0),je(e,we(e,!1,t)),n=i=e.position):e.position===e.lineStart&&Ce(e)?ge(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}ge(e,"unexpected end of the stream within a double quoted scalar")}(e,d)?y=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!ie(i)&&!re(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&ge(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),V.call(e.anchorMap,n)||ge(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],we(e,!0,-1),!0}(e)?function(e,t,n){var i,r,o,a,l,s,c,u,p=e.kind,f=e.result;if(ie(u=e.input.charCodeAt(e.position))||re(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(ie(i=e.input.charCodeAt(e.position+1))||n&&re(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==u;){if(58===u){if(ie(i=e.input.charCodeAt(e.position+1))||n&&re(i))break}else if(35===u){if(ie(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&Ce(e)||n&&re(u))break;if(te(u)){if(l=e.line,s=e.lineStart,c=e.lineIndent,we(e,!1,-1),e.lineIndent>=t){a=!0,u=e.input.charCodeAt(e.position);continue}e.position=o,e.line=l,e.lineStart=s,e.lineIndent=c;break}}a&&(be(e,r,o,!1),je(e,e.line-l),r=o=e.position,a=!1),ne(u)||(o=e.position+1),u=e.input.charCodeAt(++e.position)}return be(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,d,1===n)&&(y=!0,null===e.tag&&(e.tag="?")):(y=!0,null===e.tag&&null===e.anchor||ge(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===m&&(y=l&&Ie(e,h))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&ge(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),s=0,c=e.implicitTypes.length;s<c;s+=1)if((f=e.implicitTypes[s]).resolve(e.result)){e.result=f.construct(e.result),e.tag=f.tag,null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);break}}else if("!"!==e.tag){if(V.call(e.typeMap[e.kind||"fallback"],e.tag))f=e.typeMap[e.kind||"fallback"][e.tag];else for(f=null,s=0,c=(u=e.typeMap.multi[e.kind||"fallback"]).length;s<c;s+=1)if(e.tag.slice(0,u[s].tag.length)===u[s].tag){f=u[s];break}f||ge(e,"unknown tag !<"+e.tag+">"),null!==e.result&&f.kind!==e.kind&&ge(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result,e.tag)?(e.result=f.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):ge(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||y}function Oe(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(we(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!ie(r);)r=e.input.charCodeAt(++e.position);for(i=[],(n=e.input.slice(t,e.position)).length<1&&ge(e,"directive name must not be less than one character in length");0!==r;){for(;ne(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!te(r));break}if(te(r))break;for(t=e.position;0!==r&&!ie(r);)r=e.input.charCodeAt(++e.position);i.push(e.input.slice(t,e.position))}0!==r&&ke(e),V.call(xe,n)?xe[n](e,n,i):ye(e,'unknown document directive "'+n+'"')}we(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,we(e,!0,-1)):a&&ge(e,"directives end mark is expected"),Me(e,e.lineIndent-1,4,!1,!0),we(e,!0,-1),e.checkLineBreaks&&H.test(e.input.slice(o,e.position))&&ye(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Ce(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,we(e,!0,-1)):e.position<e.length-1&&ge(e,"end of the stream or a document separator is expected")}var Te={load:function(e,t){var n=function(e,t){t=t||{},0!==(e=String(e)).length&&(10!==e.charCodeAt(e.length-1)&&13!==e.charCodeAt(e.length-1)&&(e+="\n"),65279===e.charCodeAt(0)&&(e=e.slice(1)));var n=new he(e,t),i=e.indexOf("\0");for(-1!==i&&(n.position=i,ge(n,"null byte is not allowed in input")),n.input+="\0";32===n.input.charCodeAt(n.position);)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)Oe(n);return n.documents}(e,t);if(0!==n.length){if(1===n.length)return n[0];throw new h("expected a single document in the stream, but found more")}}}.load;function Ee(e){var t;const n=e.pages||[],i=e.relations||[];if(0===n.length)return{nodes:[],edges:[]};const r=new Map,o=new Map;for(const d of n)r.set(d.id,[]),o.set(d.id,0);for(const d of i)null==(t=r.get(d.from))||t.push(d.to),o.set(d.to,(o.get(d.to)||0)+1);const a=new Map,l=[];for(const d of n)0===(o.get(d.id)||0)&&(l.push(d.id),a.set(d.id,0));let s=0;for(;l.length>0;){const e=l.shift(),t=a.get(e)||0;for(const n of r.get(e)||[]){const e=t+1;e>(a.get(n)||0)&&(a.set(n,e),e>s&&(s=e));const i=(o.get(n)||1)-1;o.set(n,i),i<=0&&l.push(n)}}for(const d of n)a.has(d.id)||a.set(d.id,s+1);const c=new Map;for(const d of n){const e=a.get(d.id)||0;c.has(e)||c.set(e,[]),c.get(e).push(d.id)}const u=[],p=new Map(n.map(e=>[e.id,e]));for(const[d,h]of c){const e=-(160*h.length+60*(h.length-1))/2;h.forEach((t,n)=>{const i=p.get(t);u.push({id:t,title:(null==i?void 0:i.title)||t,x:e+220*n+80,y:130*d,layer:d})})}const f=i.map(e=>({from:e.from,to:e.to,label:e.label}));return{nodes:u,edges:f}}const Le=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#06b6d4","#f97316","#6366f1"];function Fe({folderPath:e}){const[u,p]=t.useState(null),[f,d]=t.useState(!0),[h,m]=t.useState(null),[g,y]=t.useState(1),[x,b]=t.useState({x:0,y:0}),A=t.useRef(!1),v=t.useRef({x:0,y:0}),[,k]=t.useState(0),w=t.useRef(null),C=t.useRef(null),j=`${e}/.notebook/graph.yaml`,I=t.useCallback(async()=>{d(!0),m(null);try{const e=await n(j);if(!e.content)return m("graph.yaml is empty"),void p(null);const t=Te(e.content);p(t),y(1),b({x:0,y:0})}catch{m("Cannot read .notebook/graph.yaml"),p(null)}finally{d(!1)}},[j]);t.useEffect(()=>{I()},[I]);const N=t.useCallback(e=>{e.preventDefault();const t=e.deltaY>0?-.1:.1;y(e=>Math.max(.2,Math.min(3,e+t)))},[]),S=t.useCallback(e=>{0===e.button&&(A.current=!0,k(e=>e+1),b(t=>(v.current={x:e.clientX-t.x,y:e.clientY-t.y},t)))},[]),M=t.useCallback(e=>{A.current&&b({x:e.clientX-v.current.x,y:e.clientY-v.current.y})},[]),O=t.useCallback(()=>{A.current=!1,k(e=>e+1)},[]),T=t.useCallback(()=>{if(!u||!C.current)return;const{nodes:e}=Ee(u);if(0===e.length)return;const t=Math.min(...e.map(e=>e.x))-100,n=Math.max(...e.map(e=>e.x))+100,i=Math.min(...e.map(e=>e.y))-40,r=Math.max(...e.map(e=>e.y))+60,o=n-t,a=r-i,l=C.current.clientWidth,s=C.current.clientHeight,c=.9*Math.min(l/o,s/a,1.5);y(c),b({x:l/2-(t+n)/2*c,y:s/2-(i+r)/2*c})},[u]),{nodes:E,edges:L}=t.useMemo(()=>u?Ee(u):{nodes:[],edges:[]},[u]),F=t.useMemo(()=>new Map(E.map(e=>[e.id,e])),[E]);return t.useEffect(()=>{if(u&&!f){const e=setTimeout(T,50);return()=>clearTimeout(e)}},[u,f,T]),f?i.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground",children:i.jsx(r,{className:"h-5 w-5 animate-spin"})}):h||!u?i.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2 text-muted-foreground text-sm px-4 text-center",children:[i.jsx("p",{children:h||"No graph data"}),i.jsxs(o,{variant:"ghost",size:"sm",onClick:()=>{I()},children:[i.jsx(a,{className:"h-3 w-3 mr-1"})," Retry"]})]}):i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b shrink-0",children:[i.jsxs("span",{className:"text-xs text-muted-foreground mr-auto",children:[E.length," pages, ",L.length," relations"]}),i.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>y(e=>Math.min(3,e+.2)),children:i.jsx(l,{className:"h-3 w-3"})}),i.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>y(e=>Math.max(.2,e-.2)),children:i.jsx(s,{className:"h-3 w-3"})}),i.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:T,children:i.jsx(c,{className:"h-3 w-3"})}),i.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>{I()},children:i.jsx(a,{className:"h-3 w-3"})})]}),i.jsx("div",{ref:C,className:"flex-1 overflow-hidden cursor-grab active:cursor-grabbing bg-muted/30",onWheel:N,onMouseDown:S,onMouseMove:M,onMouseUp:O,onMouseLeave:O,children:i.jsxs("svg",{ref:w,width:"100%",height:"100%",style:{userSelect:"none"},children:[i.jsx("defs",{children:i.jsx("marker",{id:"arrowhead",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"8",markerHeight:"6",orient:"auto",children:i.jsx("polygon",{points:"0 0, 10 3.5, 0 7",className:"fill-muted-foreground/60"})})}),i.jsxs("g",{transform:`translate(${x.x}, ${x.y}) scale(${g})`,children:[L.map((e,t)=>{const n=F.get(e.from),r=F.get(e.to);if(!n||!r)return null;const o=n.y+20,a=r.y-20,l=(o+a)/2;return i.jsxs("g",{children:[i.jsx("path",{d:`M ${n.x} ${o} C ${n.x} ${l}, ${r.x} ${l}, ${r.x} ${a}`,fill:"none",className:"stroke-muted-foreground/40",strokeWidth:1.5,markerEnd:"url(#arrowhead)"}),e.label&&i.jsx("text",{x:(n.x+r.x)/2,y:l-4,textAnchor:"middle",className:"fill-muted-foreground/60",fontSize:9,children:e.label})]},`edge-${t}`)}),E.map(e=>{const t=Le[e.layer%Le.length];return i.jsxs("g",{transform:`translate(${e.x-70}, ${e.y-18})`,children:[i.jsx("rect",{width:140,height:36,rx:8,fill:t,fillOpacity:.15,stroke:t,strokeWidth:1.5}),i.jsx("text",{x:70,y:19,textAnchor:"middle",dominantBaseline:"middle",className:"fill-foreground",fontSize:11,fontWeight:500,children:e.title.length>14?e.title.slice(0,13)+"…":e.title})]},e.id)})]})]})})]})}export{Fe as GraphPreview};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OfficePreview-
|
|
2
|
-
import{c as e,aH as t,
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OfficePreview-BSL5dPUM.js","assets/index-DaglaYz2.js","assets/index-D7mI92Gj.css","assets/purify.es-CgRAQgUo.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as e,aH as t,br as s,aJ as a,r as n,bs as r,bt as l,j as o,bu as c,m as i,d,bv as u,bw as x,bx as m,by as h,bz as p,bA as f,ak as g,aj as b,bB as j,bC as v,t as y,ai as N,aK as w,U as k,bD as C,a as S,b as I,g as P,D as z,h as M,R as U,_ as T,l as $,X as D,p as R,aV as A,bE as E,C as L,A as H,q as O}from"./index-DaglaYz2.js";import{A as _,g as q,T as F,i as W,j as B,G as V,M as K,r as J,a as G,b as Q,c as X,e as Y,h as Z,o as ee,d as te,I as se,F as ae}from"./ChatOverlay-CCrB-zxT.js";import{a as ne}from"./index-ChSsEM4z.js";import{C as re}from"./chevron-down-CCqkGk_8.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license lucide-react v0.309.0 - ISC
|
|
5
5
|
*
|
|
@@ -11,4 +11,4 @@ import{c as e,aH as t,bt as s,aJ as a,r as n,bu as r,bv as l,j as o,bw as c,m as
|
|
|
11
11
|
*
|
|
12
12
|
* This source code is licensed under the ISC license.
|
|
13
13
|
* See the LICENSE file in the root directory of this source tree.
|
|
14
|
-
*/function ue({onSelectProject:e}){const h=t(),p=s(e=>e.clearToken),{projects:f,fetchProjects:g,hasFetched:b,loading:j}=a(),v=n.useCallback(()=>{a.getState().setProjects([]),p(),h("/login")},[p,h]),[y,N]=n.useState(new Map),[w,k]=n.useState(new Set),[C,S]=n.useState(!1);n.useEffect(()=>{g()},[g]);const I=n.useCallback(e=>{e.status&&N(t=>{const s=new Map(t);return s.set(e.projectId,e.status),s}),void 0!==e.active&&k(t=>{const s=new Set(t);return e.active?s.add(e.projectId):s.delete(e.projectId),s})},[]);r({onActivityUpdate:I});const{applyOrder:P}=l(),z=P(f.filter(e=>!e.archived));return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 h-12 border-b border-border shrink-0",children:[o.jsx("span",{className:"font-semibold text-base flex-1",children:"CC Web"}),o.jsx(c,{}),o.jsx("button",{onClick:()=>{(async()=>{S(!0);try{await g()}finally{S(!1)}})()},className:"text-muted-foreground active:text-foreground",disabled:C,"aria-label":"Refresh",children:o.jsx(i,{className:d("h-4 w-4",C&&"animate-spin")})}),o.jsx("button",{onClick:()=>h("/settings"),className:"text-muted-foreground active:text-foreground","aria-label":"Settings",children:o.jsx(u,{className:"h-4 w-4"})}),o.jsx("button",{onClick:v,className:"text-muted-foreground active:text-foreground","aria-label":"Logout",children:o.jsx(x,{className:"h-4 w-4"})}),!de&&o.jsx("button",{onClick:()=>h("/"),className:"text-muted-foreground active:text-foreground","aria-label":"Desktop mode",children:o.jsx(m,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[j&&!b&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"加载中..."}),b&&0===z.length&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"暂无项目"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:z.map(t=>{var s;const a="running"===(s=t,y.get(s.id)??s.status??"stopped"),n=w.has(t.id),r=o.jsxs("button",{onClick:()=>e(t.id),className:d("w-full text-left rounded-xl border bg-card p-2.5 active:bg-accent transition-colors",n?"border-transparent":"border-border"),children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[o.jsx("span",{className:d("w-2 h-2 rounded-full shrink-0",a?"bg-green-500":"bg-zinc-400")}),o.jsx("span",{className:"font-medium text-sm truncate flex-1",children:t.name})]}),o.jsx("div",{className:"text-[10px] text-muted-foreground font-mono truncate",children:t.cliTool??"claude"})]});return o.jsx("div",{className:n?"card-active-glow rounded-xl":void 0,children:r},t.id)})})]})]})}function xe(e){if(!e.phase)return null;if("thinking"===e.phase)return"思考中";if("tool_result"===e.phase)return"处理结果";if("tool_use"===e.phase){const t=(e.detail||"").toLowerCase();return"bash"===t?"执行命令":"read"===t?"读取文件":"edit"===t||"multiedit"===t?"编辑文件":"write"===t?"写入文件":"grep"===t?"搜索内容":"glob"===t?"匹配文件":"webfetch"===t||"websearch"===t?"访问网络":"task"===t?"调度子任务":"todowrite"===t?"更新任务列表":"notebookedit"===t?"编辑 Notebook":e.detail?`调用 ${e.detail}`:"调用工具"}return null}function me({project:e,onBack:t,onOpenPanel:s,onContextUpdate:a}){const[r,l]=n.useState(""),c=n.useRef(null),i=n.useRef(null),[u,x]=n.useState([]),m=n.useCallback(e=>{x(t=>{const s=[...t,e];return s.length>200?s.slice(-200):s})},[]),S=n.useRef(null),I=n.useCallback(e=>{var t;"stopped"===e&&(null==(t=S.current)||t.call(S,"stopped"))},[]),[P,z]=n.useState([]),M=n.useRef(new Set),U=n.useCallback(e=>{M.current.has(e.toolUseId)||z(t=>t.some(t=>t.toolUseId===e.toolUseId)?t:[...t,{projectId:e.projectId,toolUseId:e.toolUseId,toolName:e.toolName,toolInput:e.toolInput,sessionId:e.sessionId,createdAt:e.createdAt}])},[]),T=n.useCallback(e=>{M.current.add(e.toolUseId),z(t=>t.filter(t=>t.toolUseId!==e.toolUseId))},[]),$=n.useCallback(e=>{M.current.add(e),z(t=>t.filter(t=>t.toolUseId!==e))},[]),[D,E]=n.useState(null),R=n.useRef(0),A=n.useCallback(e=>{var t,s,a;if(!e.active)return void E(null);if("text"===(null==(t=e.semantic)?void 0:t.phase))return void E(null);const n=null==(s=e.semantic)?void 0:s.phase,r=null==(a=e.semantic)?void 0:a.detail;E(e=>e?e.phase===n&&e.detail===r?e:{...e,phase:n,detail:r}:{id:"mab"+ ++R.current,phase:n,detail:r})},[]),{sendInput:L,connected:H}=h({projectId:e.id,enabled:!0,onChatMessage:m,onStatusChange:I,onContextUpdate:a,onApprovalRequest:U,onApprovalResolved:T,onSemanticUpdate:A});n.useEffect(()=>{if(!H)return;if("claude"!==e.cliTool)return;let t=!1;return p(e.id).then(e=>{if(t)return;const s=e.pending.filter(e=>!M.current.has(e.toolUseId));z(e=>{const t=new Map;for(const a of s)t.set(a.toolUseId,a);for(const s of e)t.has(s.toolUseId)||M.current.has(s.toolUseId)||t.set(s.toolUseId,s);return[...t.values()]})}).catch(()=>{}),()=>{t=!0}},[e.id,e.cliTool,H]);const{state:F,setState:K,messages:G,hasMoreHistory:J,loadMoreHistory:Q,sendMessage:X,isWaking:Y}=f({project:e,liveMessages:u,ws:{send:L,connected:H},historyLimit:20});S.current=K;const Z=n.useRef(H);n.useEffect(()=>{!Z.current&&H&&x([]),Z.current=H},[H]);const ee=(()=>{for(let e=G.length-1;e>=0;e--)if("assistant"===G[e].role)return e;return-1})(),[te,se]=n.useState([]),[ae,oe]=n.useState([]),[ce,de]=n.useState(null),[ue,me]=n.useState(null),he=n.useRef(!1);n.useEffect(()=>{g().then(se).catch(()=>{}),b(e.id).then(oe).catch(()=>{})},[e.id]);const pe=n.useCallback(e=>{const t=i.current;if(!t)return void l(t=>t+e);const s=t.selectionStart??r.length,a=t.selectionEnd??r.length,n=r.slice(0,s)+e+r.slice(a);l(n),requestAnimationFrame(()=>{t.focus();const a=s+e.length;t.setSelectionRange(a,a),t.style.height="auto",t.style.height=Math.min(t.scrollHeight,128)+"px"})},[r]),fe=n.useCallback(e=>{de(null),pe(e+" ")},[pe]),ge=n.useCallback(t=>{const s=e.folderPath;let a=t;s&&(t===s||t.startsWith(s+"/")||t.startsWith(s+"\\"))&&(a=t.slice(s.length).replace(/^[/\\]+/,"")),de(null),pe(`@${a} `)},[e.folderPath,pe]),be=n.useCallback(async()=>{if("skills"!==ce){if(!he.current){he.current=!0;try{const t=await j(e.cliTool??"claude",e.id);me(t)}catch{me({builtin:[],custom:[],plugins:[],mcp:[]})}finally{he.current=!1}}de("skills")}else de(null)},[ce,e.cliTool,e.id]),je=n.useCallback(async()=>{const e=c.current,t=(null==e?void 0:e.scrollHeight)??0;await Q(),requestAnimationFrame(()=>{e&&(e.scrollTop+=e.scrollHeight-t)})},[Q]),ve=n.useRef(0);n.useEffect(()=>{const e=c.current;if(!e)return;const t=G.length>ve.current,s=0===ve.current&&G.length>0;ve.current=G.length,s?e.scrollTo({top:e.scrollHeight}):t&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[G,P.length]);const[ye,Ne]=n.useState(!1),we=n.useCallback(async()=>{const e=r.trim();if(!e||ye)return;Ne(!0);const t=await X(e);Ne(!1),"delivered"===t&&(l(""),i.current&&(i.current.style.height="auto"))},[r,ye,X]),ke=v(we,"shift"),Ce=n.useCallback(async(t,s)=>{de(null);try{"failed"===await X(t.command)?y.error("快捷命令未送达,请重试或检查会话"):"project"===s&&N(e.id,t.id,!0).catch(e=>{console.error("Failed to mark shortcut used:",e)})}catch(a){console.error("Shortcut send error:",a),y.error("快捷命令发送失败")}},[X,e.id]),Se="live"===F;return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(w,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[o.jsx("span",{className:"font-medium text-sm truncate",children:e.name}),o.jsx("span",{className:d("w-2 h-2 rounded-full shrink-0",Se?"bg-green-500":Y?"bg-yellow-400 animate-pulse":"bg-zinc-400")})]}),o.jsx("button",{onClick:s,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(ie,{className:"h-5 w-5"})})]}),o.jsxs("div",{ref:c,className:"flex-1 overflow-y-auto px-3 py-3 space-y-3 min-h-0",children:[J&&o.jsx("div",{className:"flex justify-center pb-1",children:o.jsxs("button",{onClick:()=>{je()},className:"flex items-center gap-1 px-3 py-1.5 rounded-full text-xs text-muted-foreground border border-border active:bg-accent transition-colors",children:[o.jsx(ne,{className:"h-3 w-3"}),"加载更早消息"]})}),G.map((e,t)=>{const s="user"===e.role;return o.jsx("div",{className:d("flex",s?"justify-end":"justify-start"),children:o.jsx("div",{className:d("max-w-[85%] rounded-xl px-3 py-2 break-words text-sm leading-relaxed",s?"bg-blue-500/15 text-foreground border border-blue-500/20 rounded-br-sm whitespace-pre-wrap":"bg-secondary text-secondary-foreground border border-border rounded-bl-sm"),children:s?e.content:o.jsx(O,{content:e.content,blocks:e.blocks,isLatest:t===ee})})},e.id)}),P.map(e=>o.jsx(_,{approval:e,onResolved:$},e.toolUseId)),D&&0===P.length&&o.jsx("div",{className:"flex justify-start",children:o.jsxs("div",{className:"rounded-2xl rounded-bl-md px-3 py-1.5 bg-black/5 dark:bg-white/10 border border-black/10 dark:border-white/15 flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(q,{}),xe(D)&&o.jsx("span",{children:xe(D)})]})},D.id),0===G.length&&0===P.length&&!D&&"stopped"===F&&o.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/40 text-sm",children:"暂无对话记录"}),Y&&o.jsx("div",{className:"flex items-center justify-center py-4 text-yellow-400 text-sm animate-pulse",children:"启动中..."})]}),"global"===ce||"project"===ce?o.jsx("div",{className:"border-t border-border max-h-48 overflow-y-auto shrink-0",children:o.jsxs("div",{className:"px-3 py-2 space-y-1",children:[("global"===ce?te:ae).map(e=>o.jsxs("button",{onClick:()=>Ce(e,ce),disabled:Y,className:d("w-full text-left rounded-md px-2.5 py-2 text-sm active:bg-accent transition-colors border border-border/50",Y&&"opacity-50 cursor-not-allowed"),children:[o.jsx("div",{className:"font-medium text-xs",children:e.label}),o.jsx("div",{className:"text-[11px] text-muted-foreground font-mono truncate",children:e.command})]},e.id)),0===("global"===ce?te:ae).length&&o.jsx("div",{className:"text-center text-muted-foreground text-xs py-3",children:"暂无快捷 Prompts"})]})}):"skills"===ce&&ue?o.jsx("div",{className:"border-t border-border shrink-0",children:o.jsx(W,{data:ue,onCommand:fe})}):"files"===ce&&e.folderPath?o.jsx("div",{className:"border-t border-border shrink-0",children:o.jsx(B,{projectPath:e.folderPath,onSelect:ge})}):null,o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-t border-border shrink-0",children:[o.jsx("button",{onClick:()=>{be()},title:"斜杠命令",className:d("flex items-center justify-center w-7 h-7 rounded font-mono text-base transition-colors","skills"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:"/"}),o.jsx("button",{onClick:()=>de(e=>"files"===e?null:"files"),disabled:!e.folderPath,title:"引用文件",className:d("flex items-center justify-center w-7 h-7 rounded font-mono text-base transition-colors","files"===ce?"bg-accent text-foreground font-medium":e.folderPath?"text-muted-foreground active:bg-accent":"text-muted-foreground/30 cursor-not-allowed"),children:"@"}),te.length>0&&o.jsxs("button",{onClick:()=>de(e=>"global"===e?null:"global"),className:d("flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors","global"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:[o.jsx(V,{className:"h-3 w-3"}),"全局","global"===ce&&o.jsx(re,{className:"h-3 w-3"})]}),ae.length>0&&o.jsxs("button",{onClick:()=>de(e=>"project"===e?null:"project"),className:d("flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors","project"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:[o.jsx(le,{className:"h-3 w-3"}),"项目","project"===ce&&o.jsx(re,{className:"h-3 w-3"})]})]}),o.jsx("div",{className:"border-t border-border px-3 py-2 shrink-0",style:{paddingBottom:"max(0.5rem, env(safe-area-inset-bottom))"},children:o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsx("textarea",{ref:i,value:r,onChange:e=>l(e.target.value),onKeyDown:ke,disabled:Y||ye,placeholder:Y?"启动中...":ye?"发送中…":"stopped"===F?"输入消息(自动启动)...":"输入消息...",rows:1,className:d("flex-1 resize-none rounded-md border border-input bg-transparent px-3 py-2 text-sm outline-none","focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50","max-h-32 overflow-y-auto",(Y||ye)&&"opacity-50 cursor-not-allowed"),style:{minHeight:"2.5rem"},onInput:e=>{const t=e.currentTarget;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,128)+"px"}}),o.jsx("button",{onClick:we,disabled:Y||ye||!r.trim(),className:d("shrink-0 p-2 rounded-md transition-colors",r.trim()&&!ye?"text-blue-500 active:bg-blue-500/10":"text-muted-foreground/30"),children:ye?o.jsx(k,{className:"h-5 w-5 animate-spin"}):o.jsx(C,{className:"h-5 w-5"})})]})})]})}const he=U.lazy(()=>T(()=>import("./OfficePreview-CILwhejo.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.OfficePreview}))),pe=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),fe=new Set(["docx","xlsx","xls","pptx"]),ge={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};function be(e){return e.split("/").pop()??e}function je({filePath:e,onBack:t}){const[s,a]=n.useState(null),[r,l]=n.useState(!0),[c,i]=n.useState(null),{resolved:d}=S(),u=function(e){const t=e.split("/").pop()??"",s=t.toLowerCase();if("dockerfile"===s)return"dockerfile";if("makefile"===s)return"makefile";const a=t.lastIndexOf(".");return a>=0?t.slice(a+1).toLowerCase():""}(e),x=pe.has(u),m=fe.has(u),h=ge[u],p="dark"===d;n.useEffect(()=>{x||m?l(!1):(l(!0),i(null),I(e).then(a).catch(e=>i(e instanceof Error?e.message:"Failed to load")).finally(()=>l(!1)))},[e,x,m]);const f=M(e),g=n.useMemo(()=>{const e=P();return e?`${f}&token=${encodeURIComponent(e)}`:f},[f]),b=n.useMemo(()=>x?`${g}&t=${Date.now()}`:"",[g,x]);return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(w,{className:"h-5 w-5"})}),o.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:be(e)}),o.jsx("a",{href:g,download:!0,className:"text-muted-foreground active:text-foreground p-1",onClick:e=>e.stopPropagation(),children:o.jsx(z,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-auto min-h-0",children:[r&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),c&&o.jsx("div",{className:"text-center text-destructive text-sm py-12 px-4",children:c}),x&&o.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:o.jsx("img",{src:b,alt:be(e),className:"max-w-full max-h-full object-contain rounded",style:{touchAction:"pinch-zoom"}})}),m&&o.jsx(n.Suspense,{fallback:o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),children:o.jsx(he,{filePath:e,ext:u,zoom:100})}),s&&(s.binary||s.tooLarge)&&o.jsxs("div",{className:"text-center py-12 px-4 space-y-3",children:[o.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.binary?"二进制文件":"文件过大",s.size>0&&` (${j=s.size,j<1024?`${j} B`:j<1048576?`${(j/1024).toFixed(1)} KB`:`${(j/1048576).toFixed(1)} MB`})`]}),o.jsxs("a",{href:g,download:!0,className:"inline-flex items-center gap-1.5 text-sm text-blue-500 active:text-blue-400",children:[o.jsx(z,{className:"h-4 w-4"}),"下载文件"]})]}),s&&!s.binary&&!s.tooLarge&&null!=s.content&&o.jsxs(o.Fragment,{children:["md"===u&&o.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none px-4 py-3",children:o.jsx(K,{remarkPlugins:[J,Q],rehypePlugins:[G],urlTransform:(e,t,s)=>"src"===t&&"img"===s.tagName?e:Y(e),components:{img:({src:t,alt:s,...a})=>o.jsx("img",{...a,src:X(e,t,P()),alt:s??"",loading:"lazy",style:{maxWidth:"100%",height:"auto"}})},children:s.content})}),"md"!==u&&h&&o.jsx(Z,{language:h,style:p?ee:te,customStyle:{margin:0,fontSize:"12px",borderRadius:0},showLineNumbers:!0,children:s.content}),"md"!==u&&!h&&o.jsx("pre",{className:"p-4 text-xs font-mono whitespace-pre-wrap break-words",children:s.content})]})]})]});var j}const ve=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),ye=new Set(["js","jsx","ts","tsx","py","rb","go","rs","java","c","cpp","h","swift","kt","cs","php","sh","bash","zsh","r","lua","dart","zig","css","scss","less","html","htm","xml","sql"]),Ne=new Set(["json","yaml","yml","toml","csv","tsv"]);function we({entry:e}){if("dir"===e.type)return o.jsx(E,{className:"h-8 w-8 text-blue-400"});const t=function(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}(e.name);return ve.has(t)?o.jsx(se,{className:"h-8 w-8 text-emerald-400"}):ye.has(t)?o.jsx(oe,{className:"h-8 w-8 text-orange-400"}):Ne.has(t)?o.jsx(ce,{className:"h-8 w-8 text-yellow-400"}):"md"===t?o.jsx(ae,{className:"h-8 w-8 text-sky-400"}):o.jsx(R,{className:"h-8 w-8 text-muted-foreground"})}function ke({rootPath:e,onClose:t}){const[s,a]=n.useState(e),[r,l]=n.useState([]),[c,i]=n.useState(!0),[d,u]=n.useState(null),x=n.useCallback(async e=>{i(!0);try{const t=[...(await $(e)).entries].sort((e,t)=>e.type!==t.type?"dir"===e.type?-1:1:e.name.localeCompare(t.name));l(t),a(e)}catch{l([])}finally{i(!1)}},[]);n.useEffect(()=>{x(e)},[e,x]);const m=s!==e,h=s.startsWith(e)?s.slice(e.length)||"/":s;return d?o.jsx(je,{filePath:d,onBack:()=>u(null)}):o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(D,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0 text-sm",children:[m&&o.jsx("button",{onClick:()=>{if(s===e)return;const t=s.replace(/\/[^/]+$/,"")||"/";t.startsWith(e)&&x(t)},className:"text-muted-foreground active:text-foreground p-0.5 shrink-0",children:o.jsx(w,{className:"h-4 w-4"})}),o.jsx("span",{className:"truncate text-muted-foreground font-mono text-xs",children:h})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[c&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!c&&0===r.length&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"空目录"}),!c&&o.jsx("div",{className:"grid grid-cols-3 gap-1",children:r.map(e=>o.jsxs("button",{onClick:()=>(e=>{"dir"===e.type?x(e.path):u(e.path)})(e),className:"flex flex-col items-center gap-1 p-2 rounded-md active:bg-accent transition-colors",children:[o.jsx(we,{entry:e}),o.jsx("span",{className:"text-[11px] text-center leading-tight w-full line-clamp-2 break-all",children:e.name})]},e.path))})]})]})}function Ce(e){return e<50?"text-green-400":e<80?"text-yellow-400":"text-red-400"}function Se(e){return e<50?"bg-green-500":e<80?"bg-yellow-500":"bg-red-500"}function Ie({projectName:e,cliTool:t,folderPath:s,contextData:a,onClose:r}){const[l,c]=n.useState(new Set(["context","usage","files"])),[u,x]=n.useState(null),[m,h]=n.useState(!1),p=e=>{c(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};n.useEffect(()=>{h(!0),A(t).then(x).catch(()=>x(null)).finally(()=>h(!1))},[t]);const f=a?Math.round(a.usedPercentage):null;return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:r,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(D,{className:"h-5 w-5"})}),o.jsx("span",{className:"flex-1 font-medium text-sm truncate",children:e})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.jsxs("button",{onClick:()=>p("context"),className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 active:bg-accent",children:[l.has("context")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"上下文"}),null!==f&&o.jsxs("span",{className:d("text-xs font-mono ml-auto",Ce(f)),children:[f,"%"]})]}),l.has("context")&&o.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:null!==f&&a?o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 h-2 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:d("h-full rounded-full transition-all",Se(f)),style:{width:`${Math.min(f,100)}%`}})}),o.jsxs("span",{className:d("text-xs font-mono w-10 text-right",Ce(f)),children:[f,"%"]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[o.jsx("span",{children:"窗口大小"}),o.jsx("span",{className:"text-right font-mono",children:a.contextWindowSize>=1e6?`${(a.contextWindowSize/1e6).toFixed(1)}M`:`${Math.round(a.contextWindowSize/1e3)}K`}),o.jsx("span",{children:"输入 tokens"}),o.jsx("span",{className:"text-right font-mono",children:a.inputTokens.toLocaleString()}),o.jsx("span",{children:"输出 tokens"}),o.jsx("span",{className:"text-right font-mono",children:a.outputTokens.toLocaleString()})]})]}):o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center py-2",children:"暂无数据"})}),o.jsxs("div",{className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 cursor-pointer",role:"button",tabIndex:0,onClick:()=>p("usage"),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||p("usage")},children:[l.has("usage")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"用量"}),o.jsx("button",{onClick:e=>{e.stopPropagation(),(async()=>{h(!0);try{const{refreshUsage:e}=await T(async()=>{const{refreshUsage:e}=await import("./index-CKyL-Dlo.js").then(e=>e.bU);return{refreshUsage:e}},__vite__mapDeps([1,2]));x(await e(t))}catch{}finally{h(!1)}})()},className:"ml-auto text-muted-foreground active:text-foreground",children:o.jsx(i,{className:d("h-3 w-3",m&&"animate-spin")})})]}),l.has("usage")&&o.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:u?o.jsxs("div",{className:"space-y-2",children:[u.planName&&o.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Plan: ",o.jsx("span",{className:"font-medium text-foreground",children:u.planName})]}),o.jsx(Pe,{label:"5h",bucket:u.fiveHour}),o.jsx(Pe,{label:"7d",bucket:u.sevenDay}),u.sevenDaySonnet&&o.jsx(Pe,{label:"7d Sonnet",bucket:u.sevenDaySonnet}),u.sevenDayOpus&&o.jsx(Pe,{label:"7d Opus",bucket:u.sevenDayOpus}),!u.fiveHour&&!u.sevenDay&&o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center",children:"暂无数据"})]}):o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center py-2",children:m?"加载中...":"暂无数据"})}),o.jsxs("button",{onClick:()=>p("files"),className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 active:bg-accent",children:[l.has("files")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"文件"})]}),l.has("files")&&o.jsx("div",{className:"h-[60vh]",children:o.jsx(ke,{rootPath:s,onClose:()=>p("files")})})]})]})}function Pe({label:e,bucket:t}){if(!t||void 0===t.utilization)return null;const s=t.utilization,a=function(e){if(!e)return"";const t=new Date(e).getTime()-Date.now();if(t<=0)return"即将重置";const s=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4);return s>0?`${s}h${a}m`:`${a}m`}(t.resetAt);return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground w-16",children:e}),o.jsx("div",{className:"flex-1 h-1.5 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:d("h-full rounded-full",Se(s)),style:{width:`${Math.min(s,100)}%`}})}),o.jsxs("span",{className:d("text-xs font-mono w-8 text-right",Ce(s)),children:[s,"%"]}),a&&o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:a})]})}function ze(){n.useEffect(()=>{const e=document.querySelector('meta[name="viewport"]');if(!e)return;const t=e.getAttribute("content")??"";return e.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"),()=>{e.setAttribute("content",t)}},[]);const[e,t]=n.useState({screen:"list"}),[s,r]=n.useState(null),l=a(e=>e.projects),c=n.useCallback(e=>{t({screen:"chat",projectId:e}),r(null)},[]),i=n.useCallback(e=>{t({screen:"panel",projectId:e})},[]),d=n.useCallback(()=>{t(e=>"panel"===e.screen?{screen:"chat",projectId:e.projectId}:{screen:"list"})},[]),u="list"!==e.screen?l.find(t=>t.id===e.projectId):void 0;return o.jsxs("div",{className:"fixed inset-0 bg-background overflow-hidden",children:[o.jsxs(H,{mode:"wait",children:["list"===e.screen&&o.jsx(F.div,{className:"absolute inset-0",initial:{opacity:0},animate:{opacity:1},exit:{x:"-30%",opacity:0},transition:{duration:.2},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(ue,{onSelectProject:c})},"list"),"chat"===e.screen&&u&&o.jsx(F.div,{className:"absolute inset-0",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(me,{project:u,onBack:d,onOpenPanel:()=>i(e.projectId),onContextUpdate:r})},`chat-${e.projectId}`)]}),o.jsx(H,{children:"panel"===e.screen&&u&&o.jsx(F.div,{className:"absolute inset-0 z-50 bg-background",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(Ie,{projectName:u.name,cliTool:u.cliTool??"claude",folderPath:u.folderPath,contextData:s,onClose:d})},"panel")})]})}export{ze as MobilePage};
|
|
14
|
+
*/function ue({onSelectProject:e}){const h=t(),p=s(e=>e.clearToken),{projects:f,fetchProjects:g,hasFetched:b,loading:j}=a(),v=n.useCallback(()=>{a.getState().setProjects([]),p(),h("/login")},[p,h]),[y,N]=n.useState(new Map),[w,k]=n.useState(new Set),[C,S]=n.useState(!1);n.useEffect(()=>{g()},[g]);const I=n.useCallback(e=>{e.status&&N(t=>{const s=new Map(t);return s.set(e.projectId,e.status),s}),void 0!==e.active&&k(t=>{const s=new Set(t);return e.active?s.add(e.projectId):s.delete(e.projectId),s})},[]);r({onActivityUpdate:I});const{applyOrder:P}=l(),z=P(f.filter(e=>!e.archived));return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 h-12 border-b border-border shrink-0",children:[o.jsx("span",{className:"font-semibold text-base flex-1",children:"CC Web"}),o.jsx(c,{}),o.jsx("button",{onClick:()=>{(async()=>{S(!0);try{await g()}finally{S(!1)}})()},className:"text-muted-foreground active:text-foreground",disabled:C,"aria-label":"Refresh",children:o.jsx(i,{className:d("h-4 w-4",C&&"animate-spin")})}),o.jsx("button",{onClick:()=>h("/settings"),className:"text-muted-foreground active:text-foreground","aria-label":"Settings",children:o.jsx(u,{className:"h-4 w-4"})}),o.jsx("button",{onClick:v,className:"text-muted-foreground active:text-foreground","aria-label":"Logout",children:o.jsx(x,{className:"h-4 w-4"})}),!de&&o.jsx("button",{onClick:()=>h("/"),className:"text-muted-foreground active:text-foreground","aria-label":"Desktop mode",children:o.jsx(m,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[j&&!b&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"加载中..."}),b&&0===z.length&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"暂无项目"}),o.jsx("div",{className:"grid grid-cols-2 gap-2",children:z.map(t=>{var s;const a="running"===(s=t,y.get(s.id)??s.status??"stopped"),n=w.has(t.id),r=o.jsxs("button",{onClick:()=>e(t.id),className:d("w-full text-left rounded-xl border bg-card p-2.5 active:bg-accent transition-colors",n?"border-transparent":"border-border"),children:[o.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[o.jsx("span",{className:d("w-2 h-2 rounded-full shrink-0",a?"bg-green-500":"bg-zinc-400")}),o.jsx("span",{className:"font-medium text-sm truncate flex-1",children:t.name})]}),o.jsx("div",{className:"text-[10px] text-muted-foreground font-mono truncate",children:t.cliTool??"claude"})]});return o.jsx("div",{className:n?"card-active-glow rounded-xl":void 0,children:r},t.id)})})]})]})}function xe(e){if(!e.phase)return null;if("thinking"===e.phase)return"思考中";if("tool_result"===e.phase)return"处理结果";if("tool_use"===e.phase){const t=(e.detail||"").toLowerCase();return"bash"===t?"执行命令":"read"===t?"读取文件":"edit"===t||"multiedit"===t?"编辑文件":"write"===t?"写入文件":"grep"===t?"搜索内容":"glob"===t?"匹配文件":"webfetch"===t||"websearch"===t?"访问网络":"task"===t?"调度子任务":"todowrite"===t?"更新任务列表":"notebookedit"===t?"编辑 Notebook":e.detail?`调用 ${e.detail}`:"调用工具"}return null}function me({project:e,onBack:t,onOpenPanel:s,onContextUpdate:a}){const[r,l]=n.useState(""),c=n.useRef(null),i=n.useRef(null),[u,x]=n.useState([]),m=n.useCallback(e=>{x(t=>{const s=[...t,e];return s.length>200?s.slice(-200):s})},[]),S=n.useRef(null),I=n.useCallback(e=>{var t;"stopped"===e&&(null==(t=S.current)||t.call(S,"stopped"))},[]),[P,z]=n.useState([]),M=n.useRef(new Set),U=n.useCallback(e=>{M.current.has(e.toolUseId)||z(t=>t.some(t=>t.toolUseId===e.toolUseId)?t:[...t,{projectId:e.projectId,toolUseId:e.toolUseId,toolName:e.toolName,toolInput:e.toolInput,sessionId:e.sessionId,createdAt:e.createdAt}])},[]),T=n.useCallback(e=>{M.current.add(e.toolUseId),z(t=>t.filter(t=>t.toolUseId!==e.toolUseId))},[]),$=n.useCallback(e=>{M.current.add(e),z(t=>t.filter(t=>t.toolUseId!==e))},[]),[D,R]=n.useState(null),A=n.useRef(0),E=n.useCallback(e=>{var t,s,a;if(!e.active)return void R(null);if("text"===(null==(t=e.semantic)?void 0:t.phase))return void R(null);const n=null==(s=e.semantic)?void 0:s.phase,r=null==(a=e.semantic)?void 0:a.detail;R(e=>e?e.phase===n&&e.detail===r?e:{...e,phase:n,detail:r}:{id:"mab"+ ++A.current,phase:n,detail:r})},[]),{sendInput:L,connected:H}=h({projectId:e.id,enabled:!0,onChatMessage:m,onStatusChange:I,onContextUpdate:a,onApprovalRequest:U,onApprovalResolved:T,onSemanticUpdate:E});n.useEffect(()=>{if(!H)return;if("claude"!==e.cliTool)return;let t=!1;return p(e.id).then(e=>{if(t)return;const s=e.pending.filter(e=>!M.current.has(e.toolUseId));z(e=>{const t=new Map;for(const a of s)t.set(a.toolUseId,a);for(const s of e)t.has(s.toolUseId)||M.current.has(s.toolUseId)||t.set(s.toolUseId,s);return[...t.values()]})}).catch(()=>{}),()=>{t=!0}},[e.id,e.cliTool,H]);const{state:O,setState:K,messages:J,hasMoreHistory:G,loadMoreHistory:Q,sendMessage:X,isWaking:Y}=f({project:e,liveMessages:u,ws:{send:L,connected:H},historyLimit:20});S.current=K;const Z=n.useRef(H);n.useEffect(()=>{!Z.current&&H&&x([]),Z.current=H},[H]);const ee=(()=>{for(let e=J.length-1;e>=0;e--)if("assistant"===J[e].role)return e;return-1})(),[te,se]=n.useState([]),[ae,oe]=n.useState([]),[ce,de]=n.useState(null),[ue,me]=n.useState(null),he=n.useRef(!1);n.useEffect(()=>{g().then(se).catch(()=>{}),b(e.id).then(oe).catch(()=>{})},[e.id]);const pe=n.useCallback(e=>{const t=i.current;if(!t)return void l(t=>t+e);const s=t.selectionStart??r.length,a=t.selectionEnd??r.length,n=r.slice(0,s)+e+r.slice(a);l(n),requestAnimationFrame(()=>{t.focus();const a=s+e.length;t.setSelectionRange(a,a),t.style.height="auto",t.style.height=Math.min(t.scrollHeight,128)+"px"})},[r]),fe=n.useCallback(e=>{de(null),pe(e+" ")},[pe]),ge=n.useCallback(t=>{const s=e.folderPath;let a=t;s&&(t===s||t.startsWith(s+"/")||t.startsWith(s+"\\"))&&(a=t.slice(s.length).replace(/^[/\\]+/,"")),de(null),pe(`@${a} `)},[e.folderPath,pe]),be=n.useCallback(async()=>{if("skills"!==ce){if(!he.current){he.current=!0;try{const t=await j(e.cliTool??"claude",e.id);me(t)}catch{me({builtin:[],custom:[],plugins:[],mcp:[]})}finally{he.current=!1}}de("skills")}else de(null)},[ce,e.cliTool,e.id]),je=n.useCallback(async()=>{const e=c.current,t=(null==e?void 0:e.scrollHeight)??0;await Q(),requestAnimationFrame(()=>{e&&(e.scrollTop+=e.scrollHeight-t)})},[Q]),ve=n.useRef(0);n.useEffect(()=>{const e=c.current;if(!e)return;const t=J.length>ve.current,s=0===ve.current&&J.length>0;ve.current=J.length,s?e.scrollTo({top:e.scrollHeight}):t&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"})},[J,P.length]);const[ye,Ne]=n.useState(!1),we=n.useCallback(async()=>{const e=r.trim();if(!e||ye)return;Ne(!0);const t=await X(e);Ne(!1),"delivered"===t&&(l(""),i.current&&(i.current.style.height="auto"))},[r,ye,X]),ke=v(we,"shift"),Ce=n.useCallback(async(t,s)=>{de(null);try{"failed"===await X(t.command)?y.error("快捷命令未送达,请重试或检查会话"):"project"===s&&N(e.id,t.id,!0).catch(e=>{console.error("Failed to mark shortcut used:",e)})}catch(a){console.error("Shortcut send error:",a),y.error("快捷命令发送失败")}},[X,e.id]),Se="live"===O;return o.jsxs("div",{className:"flex flex-col h-full bg-background",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(w,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-1 min-w-0",children:[o.jsx("span",{className:"font-medium text-sm truncate",children:e.name}),o.jsx("span",{className:d("w-2 h-2 rounded-full shrink-0",Se?"bg-green-500":Y?"bg-yellow-400 animate-pulse":"bg-zinc-400")})]}),o.jsx("button",{onClick:s,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(ie,{className:"h-5 w-5"})})]}),o.jsxs("div",{ref:c,className:"flex-1 overflow-y-auto px-3 py-3 space-y-3 min-h-0",children:[G&&o.jsx("div",{className:"flex justify-center pb-1",children:o.jsxs("button",{onClick:()=>{je()},className:"flex items-center gap-1 px-3 py-1.5 rounded-full text-xs text-muted-foreground border border-border active:bg-accent transition-colors",children:[o.jsx(ne,{className:"h-3 w-3"}),"加载更早消息"]})}),J.map((e,t)=>{const s="user"===e.role;return o.jsx("div",{className:d("flex",s?"justify-end":"justify-start"),children:o.jsx("div",{className:d("max-w-[85%] rounded-xl px-3 py-2 break-words text-sm leading-relaxed",s?"bg-blue-500/15 text-foreground border border-blue-500/20 rounded-br-sm whitespace-pre-wrap":"bg-secondary text-secondary-foreground border border-border rounded-bl-sm"),children:s?e.content:o.jsx(_,{content:e.content,blocks:e.blocks,isLatest:t===ee})})},e.id)}),P.map(e=>o.jsx(q,{approval:e,onResolved:$},e.toolUseId)),D&&0===P.length&&o.jsx("div",{className:"flex justify-start",children:o.jsxs("div",{className:"rounded-2xl rounded-bl-md px-3 py-1.5 bg-black/5 dark:bg-white/10 border border-black/10 dark:border-white/15 flex items-center gap-2 text-xs text-muted-foreground",children:[o.jsx(F,{}),xe(D)&&o.jsx("span",{children:xe(D)})]})},D.id),0===J.length&&0===P.length&&!D&&"stopped"===O&&o.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground/40 text-sm",children:"暂无对话记录"}),Y&&o.jsx("div",{className:"flex items-center justify-center py-4 text-yellow-400 text-sm animate-pulse",children:"启动中..."})]}),"global"===ce||"project"===ce?o.jsx("div",{className:"border-t border-border max-h-48 overflow-y-auto shrink-0",children:o.jsxs("div",{className:"px-3 py-2 space-y-1",children:[("global"===ce?te:ae).map(e=>o.jsxs("button",{onClick:()=>Ce(e,ce),disabled:Y,className:d("w-full text-left rounded-md px-2.5 py-2 text-sm active:bg-accent transition-colors border border-border/50",Y&&"opacity-50 cursor-not-allowed"),children:[o.jsx("div",{className:"font-medium text-xs",children:e.label}),o.jsx("div",{className:"text-[11px] text-muted-foreground font-mono truncate",children:e.command})]},e.id)),0===("global"===ce?te:ae).length&&o.jsx("div",{className:"text-center text-muted-foreground text-xs py-3",children:"暂无快捷 Prompts"})]})}):"skills"===ce&&ue?o.jsx("div",{className:"border-t border-border shrink-0",children:o.jsx(W,{data:ue,onCommand:fe})}):"files"===ce&&e.folderPath?o.jsx("div",{className:"border-t border-border shrink-0",children:o.jsx(B,{projectPath:e.folderPath,onSelect:ge})}):null,o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 border-t border-border shrink-0",children:[o.jsx("button",{onClick:()=>{be()},title:"斜杠命令",className:d("flex items-center justify-center w-7 h-7 rounded font-mono text-base transition-colors","skills"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:"/"}),o.jsx("button",{onClick:()=>de(e=>"files"===e?null:"files"),disabled:!e.folderPath,title:"引用文件",className:d("flex items-center justify-center w-7 h-7 rounded font-mono text-base transition-colors","files"===ce?"bg-accent text-foreground font-medium":e.folderPath?"text-muted-foreground active:bg-accent":"text-muted-foreground/30 cursor-not-allowed"),children:"@"}),te.length>0&&o.jsxs("button",{onClick:()=>de(e=>"global"===e?null:"global"),className:d("flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors","global"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:[o.jsx(V,{className:"h-3 w-3"}),"全局","global"===ce&&o.jsx(re,{className:"h-3 w-3"})]}),ae.length>0&&o.jsxs("button",{onClick:()=>de(e=>"project"===e?null:"project"),className:d("flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors","project"===ce?"bg-accent text-foreground font-medium":"text-muted-foreground active:bg-accent"),children:[o.jsx(le,{className:"h-3 w-3"}),"项目","project"===ce&&o.jsx(re,{className:"h-3 w-3"})]})]}),o.jsx("div",{className:"border-t border-border px-3 py-2 shrink-0",style:{paddingBottom:"max(0.5rem, env(safe-area-inset-bottom))"},children:o.jsxs("div",{className:"flex items-end gap-2",children:[o.jsx("textarea",{ref:i,value:r,onChange:e=>l(e.target.value),onKeyDown:ke,disabled:Y||ye,placeholder:Y?"启动中...":ye?"发送中…":"stopped"===O?"输入消息(自动启动)...":"输入消息...",rows:1,className:d("flex-1 resize-none rounded-md border border-input bg-transparent px-3 py-2 text-sm outline-none","focus:ring-1 focus:ring-ring placeholder:text-muted-foreground/50","max-h-32 overflow-y-auto",(Y||ye)&&"opacity-50 cursor-not-allowed"),style:{minHeight:"2.5rem"},onInput:e=>{const t=e.currentTarget;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,128)+"px"}}),o.jsx("button",{onClick:we,disabled:Y||ye||!r.trim(),className:d("shrink-0 p-2 rounded-md transition-colors",r.trim()&&!ye?"text-blue-500 active:bg-blue-500/10":"text-muted-foreground/30"),children:ye?o.jsx(k,{className:"h-5 w-5 animate-spin"}):o.jsx(C,{className:"h-5 w-5"})})]})})]})}const he=U.lazy(()=>T(()=>import("./OfficePreview-BSL5dPUM.js"),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.OfficePreview}))),pe=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),fe=new Set(["docx","xlsx","xls","pptx"]),ge={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};function be(e){return e.split("/").pop()??e}function je({filePath:e,onBack:t}){const[s,a]=n.useState(null),[r,l]=n.useState(!0),[c,i]=n.useState(null),{resolved:d}=S(),u=function(e){const t=e.split("/").pop()??"",s=t.toLowerCase();if("dockerfile"===s)return"dockerfile";if("makefile"===s)return"makefile";const a=t.lastIndexOf(".");return a>=0?t.slice(a+1).toLowerCase():""}(e),x=pe.has(u),m=fe.has(u),h=ge[u],p="dark"===d;n.useEffect(()=>{x||m?l(!1):(l(!0),i(null),I(e).then(a).catch(e=>i(e instanceof Error?e.message:"Failed to load")).finally(()=>l(!1)))},[e,x,m]);const f=M(e),g=n.useMemo(()=>{const e=P();return e?`${f}&token=${encodeURIComponent(e)}`:f},[f]),b=n.useMemo(()=>x?`${g}&t=${Date.now()}`:"",[g,x]);return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(w,{className:"h-5 w-5"})}),o.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:be(e)}),o.jsx("a",{href:g,download:!0,className:"text-muted-foreground active:text-foreground p-1",onClick:e=>e.stopPropagation(),children:o.jsx(z,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"flex-1 overflow-auto min-h-0",children:[r&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),c&&o.jsx("div",{className:"text-center text-destructive text-sm py-12 px-4",children:c}),x&&o.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:o.jsx("img",{src:b,alt:be(e),className:"max-w-full max-h-full object-contain rounded",style:{touchAction:"pinch-zoom"}})}),m&&o.jsx(n.Suspense,{fallback:o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),children:o.jsx(he,{filePath:e,ext:u,zoom:100})}),s&&(s.binary||s.tooLarge)&&o.jsxs("div",{className:"text-center py-12 px-4 space-y-3",children:[o.jsxs("p",{className:"text-muted-foreground text-sm",children:[s.binary?"二进制文件":"文件过大",s.size>0&&` (${j=s.size,j<1024?`${j} B`:j<1048576?`${(j/1024).toFixed(1)} KB`:`${(j/1048576).toFixed(1)} MB`})`]}),o.jsxs("a",{href:g,download:!0,className:"inline-flex items-center gap-1.5 text-sm text-blue-500 active:text-blue-400",children:[o.jsx(z,{className:"h-4 w-4"}),"下载文件"]})]}),s&&!s.binary&&!s.tooLarge&&null!=s.content&&o.jsxs(o.Fragment,{children:["md"===u&&o.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none px-4 py-3",children:o.jsx(K,{remarkPlugins:[G,Q],rehypePlugins:[J],urlTransform:(e,t,s)=>"src"===t&&"img"===s.tagName?e:Y(e),components:{img:({src:t,alt:s,...a})=>o.jsx("img",{...a,src:X(e,t,P()),alt:s??"",loading:"lazy",style:{maxWidth:"100%",height:"auto"}})},children:s.content})}),"md"!==u&&h&&o.jsx(Z,{language:h,style:p?ee:te,customStyle:{margin:0,fontSize:"12px",borderRadius:0},showLineNumbers:!0,children:s.content}),"md"!==u&&!h&&o.jsx("pre",{className:"p-4 text-xs font-mono whitespace-pre-wrap break-words",children:s.content})]})]})]});var j}const ve=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif"]),ye=new Set(["js","jsx","ts","tsx","py","rb","go","rs","java","c","cpp","h","swift","kt","cs","php","sh","bash","zsh","r","lua","dart","zig","css","scss","less","html","htm","xml","sql"]),Ne=new Set(["json","yaml","yml","toml","csv","tsv"]);function we({entry:e}){if("dir"===e.type)return o.jsx(R,{className:"h-8 w-8 text-blue-400"});const t=function(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t+1).toLowerCase():""}(e.name);return ve.has(t)?o.jsx(se,{className:"h-8 w-8 text-emerald-400"}):ye.has(t)?o.jsx(oe,{className:"h-8 w-8 text-orange-400"}):Ne.has(t)?o.jsx(ce,{className:"h-8 w-8 text-yellow-400"}):"md"===t?o.jsx(ae,{className:"h-8 w-8 text-sky-400"}):o.jsx(A,{className:"h-8 w-8 text-muted-foreground"})}function ke({rootPath:e,onClose:t}){const[s,a]=n.useState(e),[r,l]=n.useState([]),[c,i]=n.useState(!0),[d,u]=n.useState(null),x=n.useCallback(async e=>{i(!0);try{const t=[...(await $(e)).entries].sort((e,t)=>e.type!==t.type?"dir"===e.type?-1:1:e.name.localeCompare(t.name));l(t),a(e)}catch{l([])}finally{i(!1)}},[]);n.useEffect(()=>{x(e)},[e,x]);const m=s!==e,h=s.startsWith(e)?s.slice(e.length)||"/":s;return d?o.jsx(je,{filePath:d,onBack:()=>u(null)}):o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:t,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(D,{className:"h-5 w-5"})}),o.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0 text-sm",children:[m&&o.jsx("button",{onClick:()=>{if(s===e)return;const t=s.replace(/\/[^/]+$/,"")||"/";t.startsWith(e)&&x(t)},className:"text-muted-foreground active:text-foreground p-0.5 shrink-0",children:o.jsx(w,{className:"h-4 w-4"})}),o.jsx("span",{className:"truncate text-muted-foreground font-mono text-xs",children:h})]})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3",children:[c&&o.jsx("div",{className:"flex items-center justify-center py-12",children:o.jsx(k,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!c&&0===r.length&&o.jsx("div",{className:"text-center text-muted-foreground text-sm py-12",children:"空目录"}),!c&&o.jsx("div",{className:"grid grid-cols-3 gap-1",children:r.map(e=>o.jsxs("button",{onClick:()=>(e=>{"dir"===e.type?x(e.path):u(e.path)})(e),className:"flex flex-col items-center gap-1 p-2 rounded-md active:bg-accent transition-colors",children:[o.jsx(we,{entry:e}),o.jsx("span",{className:"text-[11px] text-center leading-tight w-full line-clamp-2 break-all",children:e.name})]},e.path))})]})]})}function Ce(e){return e<50?"text-green-400":e<80?"text-yellow-400":"text-red-400"}function Se(e){return e<50?"bg-green-500":e<80?"bg-yellow-500":"bg-red-500"}function Ie({projectName:e,cliTool:t,folderPath:s,contextData:a,onClose:r}){const[l,c]=n.useState(new Set(["context","usage","files"])),[u,x]=n.useState(null),[m,h]=n.useState(!1),p=e=>{c(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})};n.useEffect(()=>{h(!0),E(t).then(x).catch(()=>x(null)).finally(()=>h(!1))},[t]);const f=a?Math.round(a.usedPercentage):null;return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 h-12 border-b border-border shrink-0",children:[o.jsx("button",{onClick:r,className:"text-muted-foreground active:text-foreground p-1",children:o.jsx(D,{className:"h-5 w-5"})}),o.jsx("span",{className:"flex-1 font-medium text-sm truncate",children:e})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.jsxs("button",{onClick:()=>p("context"),className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 active:bg-accent",children:[l.has("context")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"上下文"}),null!==f&&o.jsxs("span",{className:d("text-xs font-mono ml-auto",Ce(f)),children:[f,"%"]})]}),l.has("context")&&o.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:null!==f&&a?o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("div",{className:"flex-1 h-2 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:d("h-full rounded-full transition-all",Se(f)),style:{width:`${Math.min(f,100)}%`}})}),o.jsxs("span",{className:d("text-xs font-mono w-10 text-right",Ce(f)),children:[f,"%"]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-[11px] text-muted-foreground",children:[o.jsx("span",{children:"窗口大小"}),o.jsx("span",{className:"text-right font-mono",children:a.contextWindowSize>=1e6?`${(a.contextWindowSize/1e6).toFixed(1)}M`:`${Math.round(a.contextWindowSize/1e3)}K`}),o.jsx("span",{children:"输入 tokens"}),o.jsx("span",{className:"text-right font-mono",children:a.inputTokens.toLocaleString()}),o.jsx("span",{children:"输出 tokens"}),o.jsx("span",{className:"text-right font-mono",children:a.outputTokens.toLocaleString()})]})]}):o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center py-2",children:"暂无数据"})}),o.jsxs("div",{className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 cursor-pointer",role:"button",tabIndex:0,onClick:()=>p("usage"),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||p("usage")},children:[l.has("usage")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"用量"}),o.jsx("button",{onClick:e=>{e.stopPropagation(),(async()=>{h(!0);try{const{refreshUsage:e}=await T(async()=>{const{refreshUsage:e}=await import("./index-DaglaYz2.js").then(e=>e.bS);return{refreshUsage:e}},__vite__mapDeps([1,2]));x(await e(t))}catch{}finally{h(!1)}})()},className:"ml-auto text-muted-foreground active:text-foreground",children:o.jsx(i,{className:d("h-3 w-3",m&&"animate-spin")})})]}),l.has("usage")&&o.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:u?o.jsxs("div",{className:"space-y-2",children:[u.planName&&o.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Plan: ",o.jsx("span",{className:"font-medium text-foreground",children:u.planName})]}),o.jsx(Pe,{label:"5h",bucket:u.fiveHour}),o.jsx(Pe,{label:"7d",bucket:u.sevenDay}),u.sevenDaySonnet&&o.jsx(Pe,{label:"7d Sonnet",bucket:u.sevenDaySonnet}),u.sevenDayOpus&&o.jsx(Pe,{label:"7d Opus",bucket:u.sevenDayOpus}),!u.fiveHour&&!u.sevenDay&&o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center",children:"暂无数据"})]}):o.jsx("div",{className:"text-xs text-muted-foreground/50 text-center py-2",children:m?"加载中...":"暂无数据"})}),o.jsxs("button",{onClick:()=>p("files"),className:"w-full flex items-center gap-2 px-4 py-2.5 border-b border-border/50 active:bg-accent",children:[l.has("files")?o.jsx(re,{className:"h-3.5 w-3.5 text-muted-foreground"}):o.jsx(L,{className:"h-3.5 w-3.5 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-medium",children:"文件"})]}),l.has("files")&&o.jsx("div",{className:"h-[60vh]",children:o.jsx(ke,{rootPath:s,onClose:()=>p("files")})})]})]})}function Pe({label:e,bucket:t}){if(!t||void 0===t.utilization)return null;const s=t.utilization,a=function(e){if(!e)return"";const t=new Date(e).getTime()-Date.now();if(t<=0)return"即将重置";const s=Math.floor(t/36e5),a=Math.floor(t%36e5/6e4);return s>0?`${s}h${a}m`:`${a}m`}(t.resetAt);return o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-xs text-muted-foreground w-16",children:e}),o.jsx("div",{className:"flex-1 h-1.5 bg-secondary rounded-full overflow-hidden",children:o.jsx("div",{className:d("h-full rounded-full",Se(s)),style:{width:`${Math.min(s,100)}%`}})}),o.jsxs("span",{className:d("text-xs font-mono w-8 text-right",Ce(s)),children:[s,"%"]}),a&&o.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:a})]})}function ze(){n.useEffect(()=>{const e=document.querySelector('meta[name="viewport"]');if(!e)return;const t=e.getAttribute("content")??"";return e.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"),()=>{e.setAttribute("content",t)}},[]);const[e,t]=n.useState({screen:"list"}),[s,r]=n.useState(null),l=a(e=>e.projects),c=n.useCallback(e=>{t({screen:"chat",projectId:e}),r(null)},[]),i=n.useCallback(e=>{t({screen:"panel",projectId:e})},[]),d=n.useCallback(()=>{t(e=>"panel"===e.screen?{screen:"chat",projectId:e.projectId}:{screen:"list"})},[]),u="list"!==e.screen?l.find(t=>t.id===e.projectId):void 0;return o.jsxs("div",{className:"fixed inset-0 bg-background overflow-hidden",children:[o.jsxs(H,{mode:"wait",children:["list"===e.screen&&o.jsx(O.div,{className:"absolute inset-0",initial:{opacity:0},animate:{opacity:1},exit:{x:"-30%",opacity:0},transition:{duration:.2},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(ue,{onSelectProject:c})},"list"),"chat"===e.screen&&u&&o.jsx(O.div,{className:"absolute inset-0",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(me,{project:u,onBack:d,onOpenPanel:()=>i(e.projectId),onContextUpdate:r})},`chat-${e.projectId}`)]}),o.jsx(H,{children:"panel"===e.screen&&u&&o.jsx(O.div,{className:"absolute inset-0 z-50 bg-background",initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{type:"tween",duration:.25},style:{paddingTop:"env(safe-area-inset-top)"},children:o.jsx(Ie,{projectName:u.name,cliTool:u.cliTool??"claude",folderPath:u.folderPath,contextData:s,onClose:d})},"panel")})]})}export{ze as MobilePage};
|