diff --git a/frontend/src/create/NewAgentWorkbench.tsx b/frontend/src/create/NewAgentWorkbench.tsx
index fb2e35c1f..df7080de1 100644
--- a/frontend/src/create/NewAgentWorkbench.tsx
+++ b/frontend/src/create/NewAgentWorkbench.tsx
@@ -850,12 +850,16 @@ export function NewAgentWorkbench({
const min = Number(minInstance);
const max = Number(maxInstance);
if (
+ !minInstance.trim() ||
+ !maxInstance.trim() ||
!Number.isSafeInteger(min) ||
- min < 1 ||
+ min < 0 ||
!Number.isSafeInteger(max) ||
max < 1
) {
- setDeploymentValidationError("实例数必须为大于 0 的整数");
+ setDeploymentValidationError(
+ "最小实例数必须为大于等于 0 的整数,最大实例数必须为大于 0 的整数",
+ );
return;
}
if (min > max) {
@@ -1252,7 +1256,7 @@ export function NewAgentWorkbench({
max) {
return { valid: false, error: "最小实例数不能大于最大实例数。" };
@@ -2609,7 +2612,7 @@ export function ProjectPreview({
{
workbenchSource,
/className="new-agent-workbench__instance-fields"[\s\S]*?className="new-agent-workbench__model-field-label">\s*最小实例数[\s\S]*?className="new-agent-workbench__model-field-label">\s*最大实例数/,
);
+ assert.match(
+ workbenchSource,
+ /最小实例数[\s\S]*?type="number"[\s\S]*?min=\{0\}[\s\S]*?value=\{minInstance\}/,
+ );
+ assert.match(workbenchSource, /min < 0/);
+ assert.match(
+ workbenchSource,
+ /!minInstance\.trim\(\)[\s\S]*?!maxInstance\.trim\(\)/,
+ );
+ assert.match(
+ workbenchSource,
+ /最小实例数必须为大于等于 0 的整数,最大实例数必须为大于 0 的整数/,
+ );
assert.match(
workbenchSource,
/role="table"[\s\S]*?aria-label="环境变量"[\s\S]*?role="columnheader">名称[\s\S]*?role="columnheader">值[\s\S]*?role="columnheader">操作/,
diff --git a/frontend/tests/runtimeScalingDeploy.test.mjs b/frontend/tests/runtimeScalingDeploy.test.mjs
index 48fae2037..0072cc4e3 100644
--- a/frontend/tests/runtimeScalingDeploy.test.mjs
+++ b/frontend/tests/runtimeScalingDeploy.test.mjs
@@ -46,7 +46,7 @@ test("renders Runtime instance inputs with memory-aware and Sidecar-safe default
);
assert.match(
projectPreviewSource,
- /id="runtime-min-instance"[\s\S]*?type="number"[\s\S]*?value=\{minInstance\}/,
+ /id="runtime-min-instance"[\s\S]*?type="number"[\s\S]*?min="0"[\s\S]*?value=\{minInstance\}/,
);
assert.match(
projectPreviewSource,
@@ -56,6 +56,11 @@ test("renders Runtime instance inputs with memory-aware and Sidecar-safe default
projectPreviewSource,
/disabled=\{deploying \|\| sidecarEnabled\}/,
);
+ assert.match(projectPreviewSource, /min < 0/);
+ assert.match(
+ projectPreviewSource,
+ /最小实例数必须为大于等于 0 的整数,最大实例数必须为大于 0 的整数。/,
+ );
assert.match(
projectPreviewSource,
/inMemorySession \|\| sidecarEnabled[\s\S]*?className="pp-instance-note"[\s\S]*?Harness Sidecar 首期仅支持单实例,Runtime 固定为 1~1[\s\S]*?为避免多实例间会话丢失,推荐将 Runtime 固定为 1~1/,
diff --git a/tests/cli/test_studio_rbac.py b/tests/cli/test_studio_rbac.py
index e4d01b770..e713f9a61 100644
--- a/tests/cli/test_studio_rbac.py
+++ b/tests/cli/test_studio_rbac.py
@@ -5498,6 +5498,7 @@ async def _mark_validated_oauth_token(request: Request, call_next):
[
("in-memory", 1, 1, True, False),
("persistent", 1, 5, False, False),
+ ("persistent", 0, 5, True, False),
("persistent", 2, 4, True, False),
("persistent", 1, 5, False, True),
],
@@ -5694,8 +5695,30 @@ def test_deployment_rejects_internal_runtime_environment(
@pytest.mark.parametrize(
("min_instance", "max_instance", "detail"),
[
- (0, 1, "Runtime instance range must use positive integers"),
- ("1", 5, "Runtime instance range must use positive integers"),
+ (
+ -1,
+ 1,
+ (
+ "Runtime minInstance must be a non-negative integer and "
+ "maxInstance must be a positive integer"
+ ),
+ ),
+ (
+ 0,
+ 0,
+ (
+ "Runtime minInstance must be a non-negative integer and "
+ "maxInstance must be a positive integer"
+ ),
+ ),
+ (
+ "1",
+ 5,
+ (
+ "Runtime minInstance must be a non-negative integer and "
+ "maxInstance must be a positive integer"
+ ),
+ ),
(2, 1, "Runtime minInstance cannot exceed maxInstance"),
],
)
diff --git a/veadk/cli/cli_frontend.py b/veadk/cli/cli_frontend.py
index 97666826c..9be59a43f 100644
--- a/veadk/cli/cli_frontend.py
+++ b/veadk/cli/cli_frontend.py
@@ -5771,12 +5771,15 @@ async def _deploy_to_agentkit(request: Request):
or isinstance(max_instance, bool)
or not isinstance(min_instance, int)
or not isinstance(max_instance, int)
- or min_instance < 1
+ or min_instance < 0
or max_instance < 1
):
raise HTTPException(
status_code=400,
- detail="Runtime instance range must use positive integers",
+ detail=(
+ "Runtime minInstance must be a non-negative integer and "
+ "maxInstance must be a positive integer"
+ ),
)
if min_instance > max_instance:
raise HTTPException(
diff --git a/veadk/webui/assets/app/index-Ch6a-P8E.js b/veadk/webui/assets/app/index-z3uMxcpH.js
similarity index 99%
rename from veadk/webui/assets/app/index-Ch6a-P8E.js
rename to veadk/webui/assets/app/index-z3uMxcpH.js
index 58e203306..734586df7 100644
--- a/veadk/webui/assets/app/index-Ch6a-P8E.js
+++ b/veadk/webui/assets/app/index-z3uMxcpH.js
@@ -1,4 +1,4 @@
-const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/visualizations/mermaid/mermaid.core-BJxhX8WV.js","assets/chunks/purify.es-BnINGy_Y.js","assets/chunks/MarkdownPromptEditor-BL6zJDeA.js","assets/styles/MarkdownPromptEditor-ZH9qtki0.css"])))=>i.map(i=>d[i]);
+const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/visualizations/mermaid/mermaid.core-BcqeQUkk.js","assets/chunks/purify.es-BnINGy_Y.js","assets/chunks/MarkdownPromptEditor-YxGdWdMM.js","assets/styles/MarkdownPromptEditor-ZH9qtki0.css"])))=>i.map(i=>d[i]);
var mke=Object.defineProperty;var EF=e=>{throw TypeError(e)};var gke=(e,t,n)=>t in e?mke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var wr=(e,t,n)=>gke(e,typeof t!="symbol"?t+"":t,n),kF=(e,t,n)=>t.has(e)||EF("Cannot "+n);var qa=(e,t,n)=>(kF(e,t,"read from private field"),n?n.call(e):t.get(e)),_F=(e,t,n)=>t.has(e)?EF("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),pI=(e,t,n,r)=>(kF(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);function bke(e,t){for(var n=0;nr[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var lp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function A1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xte={exports:{}},nN={};/**
* @license React
* react-jsx-runtime.production.js
@@ -552,8 +552,8 @@ https://github.com/highlightjs/highlight.js/issues/2277`),L=N,F=j),B===void 0&&(
`+s+w+`,
`+y+"]"}return i.pop(),s=y,v}};const Vot={parse:Lot,stringify:zot};var Ige=Vot;const Hot=2e5,qot=new Set(["__proto__","constructor","prototype"]),Xot=/^(?:https?:|data:|blob:|file:|javascript:|image:\/\/)/i;function Yx(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function sA(e,t=0){if(t>30)throw new Error("ECharts option nesting is too deep");if(typeof e=="number"&&!Number.isFinite(e))throw new Error("ECharts option contains a non-finite number");if(typeof e=="string"&&Xot.test(e.trim()))throw new Error("ECharts option contains an external resource");if(Array.isArray(e)){for(const n of e)sA(n,t+1);return}if(Yx(e))for(const[n,r]of Object.entries(e)){if(qot.has(n))throw new Error("ECharts option contains an unsafe key");sA(r,t+1)}}function Got(e){var r;const t=e.trim(),n=t.match(/^(?:(?:const|let|var)\s+)?option\s*=\s*([\s\S]*?)\s*;?$/);return((r=n==null?void 0:n[1])==null?void 0:r.trim())||t}function Wot(e,t){let n=1,r="",i=!1,s=!1,a=!1;for(let l=t+1;lr+2)throw new Error("Invalid ECharts gradient argument count");const i=n.slice(0,r).map(Yot),s=n[r],a=n[r+1]??!1;if(!Array.isArray(s)||typeof a!="boolean")throw new Error("Invalid ECharts gradient data");return e==="linear"?{type:e,x:i[0],y:i[1],x2:i[2],y2:i[3],colorStops:s,global:a}:{type:e,x:i[0],y:i[1],r:i[2],colorStops:s,global:a}}function Kot(e,t){const n=/^(?:new\s+)?echarts\.graphic\.(LinearGradient|RadialGradient)\s*\(/;let r="",i=!1,s=!1,a=!1;for(let l=t;lHot)throw new Error("ECharts option is too large");const n=Jot(Got(e));let r;try{r=Ige.parse(n)}catch(a){throw/\bfunction\s*\(|=>/.test(n)?new Error("ECharts function callbacks are not supported"):a}if(!Yx(r))throw new Error("ECharts option must be a data object");sA(r);const i={...r};i.aria={...Yx(i.aria)?i.aria:{},enabled:!0};const s=i.tooltip;return Yx(s)?i.tooltip={...s,renderMode:"richText"}:Array.isArray(s)&&(i.tooltip=s.map(a=>Yx(a)?{...a,renderMode:"richText"}:a)),t&&(i.animation=!1),i}let xD;function tlt(){return xD??(xD=fd(()=>import("../visualizations/echarts/index-CGT341lL.js"),[]).catch(e=>{throw xD=void 0,e})),xD}function nlt({source:e}){const t=p.useRef(null),[n,r]=p.useState(!1),[i,s]=p.useState("");return p.useEffect(()=>{let a=!1,l,c,u;r(!1);try{u=elt(e,window.matchMedia("(prefers-reduced-motion: reduce)").matches),s("")}catch{s("ECharts 配置不是有效且安全的数据对象,请切换到代码检查内容。");return}return tlt().then(d=>{const f=t.current;a||!f||(l=d.init(f,void 0,{renderer:"svg"}),l.setOption(u,{notMerge:!0}),typeof ResizeObserver<"u"&&(c=new ResizeObserver(()=>l==null?void 0:l.resize()),c.observe(f)),r(!0))}).catch(()=>{l==null||l.dispose(),l=void 0,a||s("图表暂时无法渲染,请切换到代码检查内容。")}),()=>{a=!0,c==null||c.disconnect(),l==null||l.dispose()}},[e]),o.jsxs("div",{className:`echarts-diagram${i?" echarts-diagram--error":""}`,role:"img","aria-label":"ECharts 图表预览","aria-busy":!n&&!i,children:[o.jsx("div",{ref:t,className:"echarts-diagram__canvas",hidden:!!i}),!n&&!i?o.jsx("div",{className:"echarts-diagram__state","aria-live":"polite",children:o.jsx(wn,{duration:2.2,spread:15,children:"正在渲染图表…"})}):null,i?o.jsx("p",{className:"echarts-diagram__error",role:"alert",children:i}):null]})}const rlt=p.memo(nlt);let MW,LW=Promise.resolve(),ilt=0;function slt(){return MW??(MW=fd(async()=>{const{default:e}=await import("../visualizations/mermaid/mermaid.core-BJxhX8WV.js").then(t=>t.ay);return{default:e}},__vite__mapDeps([0,1])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:"neutral"}),e))),MW}function alt(e){const t=LW.then(async()=>{const n=await slt(),r=`mermaid-diagram-${ilt+=1}`;return n.render(r,e)});return LW=t.then(()=>{},()=>{}),t}function olt({source:e}){const t=p.useRef(null),[n,r]=p.useState(null),[i,s]=p.useState(!1);return p.useEffect(()=>{let a=!1;return r(null),s(!1),alt(e).then(l=>{a||r(l)}).catch(()=>{a||s(!0)}),()=>{a=!0}},[e]),p.useEffect(()=>{!(n!=null&&n.bindFunctions)||!t.current||n.bindFunctions(t.current)},[n]),i?o.jsx("div",{className:"mermaid-diagram mermaid-diagram--error",children:o.jsx("p",{className:"mermaid-diagram__error",role:"alert",children:"图表暂时无法渲染,请切换到代码查看 Mermaid 内容。"})}):n?o.jsx("div",{ref:t,className:"mermaid-diagram",role:"img","aria-label":"Mermaid 图表预览",dangerouslySetInnerHTML:{__html:n.svg}}):o.jsx("div",{className:"mermaid-diagram mermaid-diagram--loading","aria-live":"polite",children:o.jsx(wn,{duration:2.2,spread:15,children:"正在渲染图表…"})})}const llt=p.memo(olt),clt="_SegmentedControl_1sl7d_1",ult="_SegmentedControlOption_1sl7d_140",dlt="_SegmentedControlThumb_1sl7d_219",bL={SegmentedControl:clt,SegmentedControlOption:ult,SegmentedControlThumb:dlt},zs=({value:e,onChange:t,children:n,block:r,pill:i=!0,size:s="md",gutterSize:a,className:l,onClick:c,...u})=>{const d=p.useRef(null),f=p.useRef(null),h=p.useCallback(g=>{const b=d.current,y=f.current;if(!b||!y)return;const O=b==null?void 0:b.querySelector('[data-state="on"]');if(!O)return;const v=b.clientWidth;let x=Math.floor(O.clientWidth);const w=O.offsetLeft;if(v-(x+w)<2&&(x=x-1),y.style.width=`${Math.floor(x)}px`,y.style.transform=`translateX(${w}px)`,b.scrollWidth>v){const S=v*.15,E=b.scrollLeft,k=O.offsetLeft,_=k+x;(kE+v-S)&&g&&O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}},[]);Tle({ref:d,onResize:()=>{const g=f.current;if(!g)return;const b=g.style.transition;g.style.transition="",h(!1),g.style.transition=b}}),p.useLayoutEffect(()=>{const g=d.current,b=f.current;!g||!b||(h(!!b.style.transition),b.style.transition||SC(()=>{b.style.transition="width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)"}))},[h,e,s,a,i]);const m=g=>{g&&t&&t(g)};return o.jsxs(YLe,{ref:d,className:sr(bL.SegmentedControl,l),type:"single",value:e,loop:!1,onValueChange:m,onClick:c,"data-block":r?"":void 0,"data-pill":i?"":void 0,"data-size":s,"data-gutter-size":a,...u,children:[o.jsx("div",{className:bL.SegmentedControlThumb,ref:f}),n]})},flt=({children:e,...t})=>o.jsx(t6e,{className:bL.SegmentedControlOption,...t,onPointerEnter:C9,children:o.jsx("span",{className:"relative",children:e})});zs.Option=flt;function hlt({children:e,label:t,language:n,source:r,streaming:i=!1}){const[s,a]=p.useState("preview"),l=i?"code":s;return o.jsxs("section",{className:"visualization-card","aria-label":`${t} 图表`,children:[o.jsx("div",{className:"visualization-card__toolbar",children:o.jsxs(zs,{className:"visualization-card__tabs",value:l,size:"sm",gutterSize:"sm",pill:!1,"aria-label":`${t} 显示方式`,onChange:c=>{i||a(c)},children:[o.jsx(zs.Option,{value:"preview",disabled:i,children:"预览"}),o.jsx(zs.Option,{value:"code",children:"代码"})]})}),o.jsx("div",{className:"visualization-card__body",children:l==="code"?o.jsx("pre",{className:"visualization-card__code",children:o.jsx("code",{className:`language-${n}`,children:r})}):e})]})}const plt=p.memo(hlt);function mlt(e){const t=e==null?void 0:e.trim().toLowerCase();if(t==="mermaid")return"mermaid";if(t==="echart"||t==="echarts")return"echarts"}const Dge=[".mp4",".webm",".mov",".m4v",".ogg",".avi"];function yL(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(yL).join(""):p.isValidElement(e)?yL(e.props.children):""}function glt(e){var r;const t=p.Children.toArray(e)[0];if(!p.isValidElement(t))return;const n=(r=t.props.className)==null?void 0:r.split(/\s+/).find(i=>i.startsWith("language-"));return mlt(n==null?void 0:n.slice(9))}function Pge(e){if(!e)return!1;try{const t=e.toLowerCase();return Dge.some(n=>t.includes(n))}catch{return!1}}function blt(e){var r;const t=(r=e==null?void 0:e.properties)==null?void 0:r.href;if(!t)return!1;if(Pge(t))return!0;const n=e==null?void 0:e.children;if(n&&Array.isArray(n)){const i=n.map(s=>(s==null?void 0:s.value)||"").join("").toLowerCase();return Dge.some(s=>i.includes(s))}return!1}function ylt({text:e,className:t,allowRawHtml:n=!0,streaming:r=!1}){const[i,s]=p.useState(null),a=(u,d)=>{if(u.src)return u.src;if(d){const f=m=>{var g;if(!m)return null;if(m.type==="source"&&((g=m.properties)!=null&&g.src))return m.properties.src;if(m.children)for(const b of m.children){const y=f(b);if(y)return y}return null},h=f({children:d});if(h)return h}return""},l=u=>{try{const f=new URL(u).pathname.split("/");return f[f.length-1]||"video.mp4"}catch{return"video.mp4"}},c=u=>u?Array.isArray(u)?u.map(d=>(d==null?void 0:d.value)||"").join("")||"video":(u==null?void 0:u.value)||"video":"video";return o.jsxs("div",{className:t?`md ${t}`:"md",children:[o.jsx(DJe,{remarkPlugins:[Wtt],rehypePlugins:n?[jot,gW]:[gW],components:{pre:({node:u,children:d,...f})=>{const h=glt(d);if(h==="mermaid"||h==="echarts"){const m=yL(d).replace(/\n$/,"");return o.jsx(plt,{label:h==="mermaid"?"Mermaid":"ECharts",language:h,source:m,streaming:r,children:h==="mermaid"?o.jsx(llt,{source:m}):o.jsx(rlt,{source:m})})}return o.jsx("pre",{...f,children:d})},a:({node:u,...d})=>{const f=d.href;if(f&&(Pge(f)||blt(u))){const h=f,m=c(u==null?void 0:u.children);return o.jsxs("div",{className:"video-container",children:[o.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":`点击播放视频: ${m}`,onClick:()=>s({src:h,title:m}),children:[o.jsx("video",{src:h,playsInline:!0,className:"video-thumbnail",preload:"metadata"}),o.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:o.jsx(cy,{})})]}),o.jsx("div",{className:"video-caption",children:o.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"video-link-text",children:m})})]})}return o.jsx("a",{...d,target:"_blank",rel:"noopener noreferrer"})},img:({node:u,src:d,alt:f,...h})=>{const m=o.jsx("img",{...h,src:d,alt:f??"",loading:"lazy"});return d?o.jsx(Tae,{src:d,children:o.jsxs("button",{type:"button",className:"image-preview-trigger","aria-label":`放大预览:${f||"图片"}`,children:[m,o.jsx("span",{className:"image-preview-hint","aria-hidden":"true",children:o.jsx(cy,{})})]})}):m},video:({node:u,src:d,children:f,...h})=>{const m=a({src:d},f);return m?o.jsx("div",{className:"video-container",children:o.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":"点击放大视频",onClick:()=>s({src:m}),children:[o.jsx("video",{src:m,...h,playsInline:!0,className:"video-thumbnail",children:f}),o.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:o.jsx(cy,{})})]})}):o.jsx("video",{src:d,controls:!0,playsInline:!0,className:"video-inline",...h,children:f})}},children:e}),i&&o.jsx("div",{className:"video-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":"视频预览",onClick:()=>s(null),children:o.jsxs("div",{className:"video-viewer",onClick:u=>u.stopPropagation(),children:[o.jsxs("div",{className:"video-viewer-header",children:[o.jsx("div",{className:"video-viewer-title",children:i.title||l(i.src)}),o.jsxs("nav",{className:"video-viewer-nav",children:[o.jsx("a",{href:i.src,download:i.title||l(i.src),"aria-label":"下载视频",title:"下载视频",className:"video-viewer-download",children:o.jsx(jN,{})}),o.jsx("button",{type:"button",className:"video-viewer-close","aria-label":"关闭",onClick:()=>s(null),children:o.jsx(Ea,{})})]})]}),o.jsx("div",{className:"video-viewer-body",children:o.jsx("video",{src:i.src,controls:!0,autoPlay:!0,playsInline:!0,className:"video-fullscreen"})})]})})]})}const Ou=p.memo(ylt),Olt="未知来源",xlt="未知创建者";function zv(e){return(e==null?void 0:e.trim())||Olt}function Mge(e){return(e==null?void 0:e.trim())||xlt}function vlt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5 5.5A2.5 2.5 0 0 1 7.5 3H19v16H7.5A2.5 2.5 0 0 0 5 21.5v-16Z"}),o.jsx("path",{d:"M5 18.5A2.5 2.5 0 0 1 7.5 16H19"}),o.jsx("path",{d:"M9 7h6M9 10h4"})]})}function wlt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3h8l4 4v14H6V3Z"}),o.jsx("path",{d:"M14 3v5h5M9 12h6M9 16h6"})]})}function Slt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function Elt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"M12 5v14M5 12h14"})})}function AE({title:e,children:t,onClose:n,busy:r=!1,className:i=""}){const s=p.useId(),a=p.useRef(null),l=p.useRef(null),c=p.useRef(r),u=p.useRef(n);return p.useEffect(()=>{c.current=r,u.current=n},[r,n]),p.useEffect(()=>{var m;const d=document.activeElement instanceof HTMLElement?document.activeElement:null,f=document.body.style.overflow;document.body.style.overflow="hidden",(m=a.current)==null||m.focus();const h=g=>{if(g.key==="Escape"&&!c.current){u.current();return}if(g.key!=="Tab")return;const b=l.current;if(!b)return;const y=Array.from(b.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], audio[controls], video[controls], iframe, [tabindex]:not([tabindex="-1"])')).filter(x=>x.getClientRects().length>0);if(y.length===0){g.preventDefault();return}const O=y[0],v=y[y.length-1];g.shiftKey&&(document.activeElement===O||!b.contains(document.activeElement))?(g.preventDefault(),v.focus()):!g.shiftKey&&(document.activeElement===v||!b.contains(document.activeElement))&&(g.preventDefault(),O.focus())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h),document.body.style.overflow=f,d!=null&&d.isConnected&&d.focus()}},[]),kr.createPortal(o.jsx("div",{className:"knowledge-dialog-backdrop",onMouseDown:d=>{d.target===d.currentTarget&&!r&&n()},children:o.jsxs("section",{ref:l,className:`knowledge-dialog${i?` ${i}`:""}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":r||void 0,children:[o.jsxs("header",{className:"knowledge-dialog__header",children:[o.jsx("h2",{id:s,children:e}),o.jsx("button",{ref:a,type:"button",onClick:n,disabled:r,"aria-label":"关闭",children:o.jsx(Slt,{})})]}),t]})}),document.body)}function Zw({message:e}){return e?o.jsx("div",{className:"knowledge-form-error",role:"alert",children:e}):null}function OL(e){return e instanceof DOMException&&e.name==="AbortError"}function klt(e){if(!e)return"";const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):e}const Lge=[".jpg",".jpeg",".png"].join(","),_lt=new Set(Lge.split(",")),$ge=[".pdf",".pptx",".docx",".xlsx",".txt"].join(","),Tlt=new Set($ge.split(",")),Clt=200*1024*1024;function xL(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t).toLocaleLowerCase()}function Alt(e,t){return e.size>Clt?"单个文件不能超过 200 MB":t==="image"?_lt.has(xL(e.name))?"":"请选择 PNG、JPG 或 JPEG 图片":Tlt.has(xL(e.name))?"":"请选择 PDF、PPTX、DOCX、XLSX 或 TXT 文件"}function jB(e){return e<=0?"-":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vL(e){var i;const t=e.type.trim().replace(/^\./,"");if(t)return t.toUpperCase();const n=e.name.trim(),r=n.includes(".")?(i=n.split(".").pop())==null?void 0:i.trim():"";return r?r.toUpperCase():"-"}function Nlt({region:e,onClose:t,onCreated:n}){const[r,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[f,h]=p.useState(""),m=r.trim(),g=!!(m&&!/^[A-Za-z][A-Za-z0-9_]{0,47}$/.test(m)),b=async y=>{if(y.preventDefault(),c(!0),!m||g)return;d(!0),h("");const O={name:m,description:s.trim()||void 0,region:e};try{n(await GGe(O))}catch(v){h(Ga(v,"创建知识库失败"))}finally{d(!1)}};return o.jsx(AE,{title:"新建知识库",onClose:t,busy:u,children:o.jsxs("form",{onSubmit:y=>void b(y),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{autoFocus:!0,value:r,maxLength:48,"aria-invalid":l&&g||void 0,"aria-describedby":"knowledge-name-help",onBlur:()=>c(!0),onChange:y=>i(y.target.value)})]}),o.jsx("p",{id:"knowledge-name-help",className:`knowledge-dialog__note${l&&g?" is-error":""}`,role:l&&g?"alert":void 0,children:l&&g?"名称必须以字母开头,且只能包含字母、数字和下划线。":"以字母开头,仅支持字母、数字和下划线,最多 48 个字符。"}),o.jsxs("label",{children:[o.jsx("span",{children:"描述(可选)"}),o.jsx("textarea",{value:s,maxLength:80,onChange:y=>a(y.target.value)})]}),o.jsx(Zw,{message:f})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:u,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:u||!m||g,children:u?"创建中":"创建"})]})]})})}function jlt({item:e,onClose:t,onUpdated:n}){const[r,i]=p.useState(e.description),[s,a]=p.useState(!1),[l,c]=p.useState(""),u=async d=>{d.preventDefault(),a(!0),c("");try{n(await WGe(e.id,e.region,{description:r.trim()}))}catch(f){c(Ga(f,"更新知识库失败"))}finally{a(!1)}};return o.jsx(AE,{title:"编辑知识库",onClose:t,busy:s,children:o.jsxs("form",{onSubmit:d=>void u(d),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{value:e.name,disabled:!0})]}),o.jsxs("label",{children:[o.jsx("span",{children:"描述"}),o.jsx("textarea",{autoFocus:!0,value:r,maxLength:80,onChange:d=>i(d.target.value)})]}),o.jsx("p",{className:"knowledge-dialog__note",children:"AgentKit 当前仅支持更新知识库描述。"}),o.jsx(Zw,{message:l})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:s,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:s,children:s?"保存中":"保存"})]})]})})}function Bge(e){if(!e.trim())return{};const t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!="object")throw new Error("Metadata 必须是 JSON 对象");return t}function Rlt({base:e,onClose:t,onCreated:n,onAssociationInvalid:r}){const[i,s]=p.useState("document"),[a,l]=p.useState(""),[c,u]=p.useState(""),[d,f]=p.useState(""),[h,m]=p.useState(null),[g,b]=p.useState(!1),[y,O]=p.useState("{}"),[v,x]=p.useState(""),[w,S]=p.useState(""),[E,k]=p.useState(null),_=p.useRef(null),T=p.useRef(null),C=p.useRef(null),A=p.useRef(0),R=!!v;p.useEffect(()=>{var j;E&&!R&&((j=C.current)==null||j.focus())},[R,E]);const M=j=>{R||j===i||(s(j),m(null),f(""),l(""),u(""),S(""),k(null),b(!1),A.current=0,_.current&&(_.current.value=""))},I=j=>{if(!j||i==="web")return;const B=Alt(j,i);if(B){m(null),l(""),u(""),S(B);return}m(j),S(""),l(j.name.replace(/\.[^.]+$/,"")),u(xL(j.name).slice(1))},$=async j=>{if(j.preventDefault(),i==="web"?!d.trim():!h)return;let B;try{B=Bge(y)}catch(F){S(Ga(F,"Metadata 格式错误"));return}x(i==="web"?E?"save":"preview":"upload"),S("");try{if(i==="web")if(E){const F={sourceType:"url",metadata:E.metadata,url:E.preview.url,sourceTitle:E.preview.name,sourceMarkdown:E.preview.sourceMarkdown};await JGe(e.id,e.region,F),n()}else{const F=await eWe(e.id,e.region,{url:d.trim()});if(!F.sourceMarkdown.trim())throw new Error("网页没有可预览的 Markdown 内容");k({preview:F,metadata:B})}else h&&(await tWe(e.id,e.region,{file:h,name:a.trim()||void 0,documentType:c.trim()||void 0,metadata:B}),n())}catch(F){F instanceof Sj&&F.errorCode===Khe?r(F):S(Ga(F,i==="web"?E?"添加网页失败":"生成网页预览失败":"上传文件失败"))}finally{x("")}},N=()=>{R||(k(null),S(""),requestAnimationFrame(()=>{var j;return(j=T.current)==null?void 0:j.focus()}))};return o.jsx(AE,{title:E?"预览网页内容":"添加数据",onClose:t,busy:R,className:E?"knowledge-dialog--preview knowledge-dialog--web-confirm":"",children:o.jsx("form",{onSubmit:j=>void $(j),children:E?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"knowledge-preview knowledge-web-preview",children:[o.jsxs("div",{className:"knowledge-preview__meta",children:[o.jsx("strong",{title:E.preview.name,children:E.preview.name}),o.jsx("a",{href:E.preview.url,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"})]}),o.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:o.jsx("div",{className:"knowledge-preview__markdown-shell",children:o.jsx(Ou,{text:E.preview.sourceMarkdown,allowRawHtml:!1,className:"knowledge-preview__markdown"})})}),w?o.jsx("div",{className:"knowledge-web-preview__error",children:o.jsx(Zw,{message:w})}):null]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",className:"is-back",onClick:N,disabled:R,children:"返回修改"}),o.jsx("button",{type:"button",onClick:t,disabled:R,children:"取消"}),o.jsx("button",{ref:C,type:"submit",className:"is-primary",disabled:R,children:v==="save"?"添加中":"确认添加"})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsx("div",{className:"knowledge-source-tabs",role:"tablist","aria-label":"知识来源",children:[["image","图片"],["document","文档文件"],["web","在线网页"]].map(([j,B])=>o.jsx("button",{type:"button",role:"tab",id:`knowledge-source-${j}-tab`,"aria-controls":`knowledge-source-${j}-panel`,"aria-selected":i===j,tabIndex:i===j?0:-1,className:i===j?"is-active":"",disabled:R,onClick:()=>M(j),onKeyDown:F=>{const L=["image","document","web"];if(!["ArrowLeft","ArrowRight","Home","End"].includes(F.key))return;F.preventDefault();const H=L.indexOf(j),z=F.key==="Home"?L[0]:F.key==="End"?L[L.length-1]:L[(H+(F.key==="ArrowRight"?1:-1)+L.length)%L.length];M(z),requestAnimationFrame(()=>{var Q;return(Q=document.getElementById(`knowledge-source-${z}-tab`))==null?void 0:Q.focus()})},children:B},j))}),o.jsx("div",{id:`knowledge-source-${i}-panel`,className:"knowledge-source-panel",role:"tabpanel","aria-labelledby":`knowledge-source-${i}-tab`,children:i==="web"?o.jsxs(o.Fragment,{children:[o.jsxs("label",{children:[o.jsx("span",{children:"网页 URL"}),o.jsx("input",{ref:T,autoFocus:!0,type:"url",value:d,disabled:R,onChange:j=>{f(j.target.value),S("")},placeholder:"https://example.com/article"})]}),o.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:v==="preview"?o.jsx(wn,{children:"正在抓取网页并生成 Markdown 预览"}):null})]}):o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:_,className:"knowledge-upload-input",type:"file","aria-label":"选择知识文件",accept:i==="image"?Lge:$ge,disabled:R,onChange:j=>{var B;I(((B=j.currentTarget.files)==null?void 0:B[0])??null),j.currentTarget.value=""}}),o.jsxs("button",{type:"button",className:`knowledge-upload-dropzone${g?" is-dragging":""}${h?" is-ready":""}`,disabled:R,onClick:()=>{var j;return(j=_.current)==null?void 0:j.click()},onDragEnter:j=>{j.preventDefault(),!R&&(A.current+=1,b(!0))},onDragOver:j=>{j.preventDefault(),R||(j.dataTransfer.dropEffect="copy")},onDragLeave:j=>{j.preventDefault(),A.current=Math.max(0,A.current-1),A.current===0&&b(!1)},onDrop:j=>{var B;j.preventDefault(),A.current=0,b(!1),R||I(((B=j.dataTransfer.files)==null?void 0:B[0])??null)},children:[o.jsx("strong",{children:h?h.name:"选择文件或拖拽到这里"}),o.jsx("span",{children:h?`${jB(h.size)} · 点击可重新选择`:i==="image"?"支持 PNG、JPG 和 JPEG,单个文件不超过 200 MB":"支持 PDF、PPTX、DOCX、XLSX 和 TXT,单个文件不超过 200 MB"})]}),o.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:R?o.jsx(wn,{children:"正在上传文件并添加到知识库"}):null})]})}),i!=="web"?o.jsxs("div",{className:"knowledge-dialog__fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称(可选)"}),o.jsx("input",{value:a,disabled:R,maxLength:256,onChange:j=>l(j.target.value)})]}),o.jsxs("label",{children:[o.jsx("span",{children:"类型(可选)"}),o.jsx("input",{value:c,disabled:R,maxLength:64,onChange:j=>u(j.target.value),placeholder:"pdf、docx、png"})]})]}):null,o.jsxs("label",{children:[o.jsx("span",{children:"Metadata(JSON)"}),o.jsx("textarea",{className:"is-code",value:y,disabled:R,onChange:j=>O(j.target.value),spellCheck:!1})]}),o.jsx(Zw,{message:w})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:R,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:R||(i==="web"?!d.trim():!h),children:R?i==="web"?"生成中":"上传中":i==="web"?"生成预览":"上传文件"})]})]})})})}function Ilt({base:e,item:t,onClose:n,onUpdated:r}){const[i,s]=p.useState(()=>JSON.stringify(t.metadata??{},null,2)),[a,l]=p.useState(!1),[c,u]=p.useState(""),d=async f=>{f.preventDefault();let h;try{h=Bge(i)}catch(m){u(Ga(m,"Metadata 格式错误"));return}l(!0),u("");try{r(await nWe(e.id,t.id,e.region,{metadata:h}))}catch(m){u(Ga(m,"更新知识失败"))}finally{l(!1)}};return o.jsx(AE,{title:"编辑知识 Metadata",onClose:n,busy:a,children:o.jsxs("form",{onSubmit:f=>void d(f),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"知识"}),o.jsx("input",{value:t.name||t.id,disabled:!0})]}),o.jsxs("label",{children:[o.jsx("span",{children:"Metadata(JSON)"}),o.jsx("textarea",{autoFocus:!0,className:"is-code knowledge-metadata-editor",value:i,onChange:f=>s(f.target.value),spellCheck:!1})]}),o.jsx(Zw,{message:c})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:n,disabled:a,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:a,children:a?"保存中":"保存"})]})]})})}const Qge=new Set(["avif","bmp","gif","jpeg","jpg","png","svg","webp"]),Uge=new Set(["aac","flac","m4a","mp3","ogg","wav","webm"]),Fge=new Set(["m4v","mov","mp4","mpeg","mpg","ogg","webm"]),Dlt=new Set(["pdf"]),Plt=new Set(["doc","docx","ppt","pptx","xls","xlsx"]),Mlt=new Set(["creating","indexing","pending","processing","queued","submitted"]),Llt=new Set(["error","failed","unavailable"]);function $W(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function A2(e){if(e==null||e==="")return"-";if(["string","number","boolean"].includes(typeof e))return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function $lt(e){if(Array.isArray(e)){if(e.length===0)return null;const r=e.map($W);if(r.some(i=>Object.keys(i).length>0)){const i=[...new Set(r.flatMap(s=>Object.keys(s)))];return{columns:i,rows:r.map(s=>i.map(a=>A2(s[a])))}}return{columns:["值"],rows:e.map(i=>[A2(i)])}}const t=$W(e),n=Object.entries(t);if(n.length===0)return null;if(n.every(([,r])=>Array.isArray(r))){const r=n.map(([s])=>s),i=Math.max(...n.map(([,s])=>s.length));return{columns:r,rows:Array.from({length:i},(s,a)=>n.map(([,l])=>A2(l[a])))}}return{columns:["字段","值"],rows:n.map(([r,i])=>[r,A2(i)])}}function zge(e){const t=e.trim();if(!t||t.startsWith("//"))return"";if(t.startsWith("/"))return t;try{const n=new URL(t);return["http:","https:"].includes(n.protocol)?n.href:""}catch{return""}}function Blt(e){const t=zge(e);return t.startsWith("http://")||t.startsWith("https://")?t:""}function Qlt(e){var i;const t=e.attachmentType.trim().toLocaleLowerCase();if(t==="image"||t==="doc-image"||t.startsWith("image/"))return"image";if(t==="audio"||t.startsWith("audio/"))return"audio";if(t==="video"||t.startsWith("video/"))return"video";if(t==="pdf"||t==="application/pdf")return"pdf";const n=e.attachmentUrl.split(/[?#]/,1)[0],r=n.includes(".")?((i=n.split(".").pop())==null?void 0:i.toLocaleLowerCase())??"":"";return Qge.has(r)?"image":Uge.has(r)?"audio":Fge.has(r)?"video":Dlt.has(r)?"pdf":t||r?"file":"none"}function Ult(e){const t=e.status.trim().toLocaleLowerCase();if(Mlt.has(t))return{title:"数据正在处理中",detail:"知识库完成解析后即可预览,请稍后重新加载。"};if(Llt.has(t))return{title:"数据解析失败",detail:"请检查源文件或网页地址后重新添加,也可以重新加载最新状态。"};const n=vL(e).toLocaleLowerCase();return n==="pdf"||Plt.has(n)?{title:"暂时没有可预览的解析内容",detail:"此类文件会在知识库完成解析后显示文本、表格或页面图片。"}:Qge.has(n)||Uge.has(n)||Fge.has(n)?{title:"暂时没有可预览的媒体内容",detail:"知识库尚未返回可访问的媒体预览,请稍后重新加载。"}:{title:"暂无可预览的数据内容",detail:"知识库尚未返回解析结果,请稍后重新加载。"}}function Flt({chunk:e}){const[t,n]=p.useState(!1),r=zge(e.attachmentUrl),i=Qlt(e);return!r||i==="none"?null:t?o.jsx("div",{className:"knowledge-preview__attachment-error",children:"附件无法预览,请稍后重试。"}):i==="image"?o.jsx("img",{className:"knowledge-preview__image",src:r,alt:e.title||"知识数据图片",loading:"lazy",onError:()=>n(!0)}):i==="audio"?o.jsx("audio",{className:"knowledge-preview__audio",src:r,controls:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持音频预览。"}):i==="video"?o.jsx("video",{className:"knowledge-preview__video",src:r,controls:!0,playsInline:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持视频预览。"}):i==="pdf"?o.jsxs("div",{className:"knowledge-preview__pdf",children:[o.jsx("iframe",{src:r,title:e.title?`${e.title} PDF 预览`:"PDF 预览",sandbox:"",referrerPolicy:"no-referrer",onError:()=>n(!0)}),o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"无法显示时,在新窗口打开 PDF"})]}):o.jsxs("div",{className:"knowledge-preview__file-fallback",children:[o.jsx("p",{children:"当前格式暂不支持直接在线预览,已优先显示解析后的内容。"}),o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"打开原文件"})]})}function zlt({base:e,item:t,onClose:n}){const[r,i]=p.useState([]),[s,a]=p.useState(t),[l,c]=p.useState(""),[u,d]=p.useState(!0),[f,h]=p.useState(!1),[m,g]=p.useState(!1),[b,y]=p.useState(""),O=p.useRef(0),v=p.useRef(null),x=p.useCallback(async(k=0)=>{var C;(C=v.current)==null||C.abort();const _=new AbortController;v.current=_;const T=O.current+1;O.current=T,k>0?h(!0):d(!0),y(""),k===0&&(i([]),g(!1));try{const A=await KGe(e.id,t.id,{region:e.region,offset:k,signal:_.signal});if(O.current!==T)return;a(A.document.id?A.document:t),c(A.sourceMarkdown||A.document.sourceMarkdown),i(R=>k>0?[...R,...A.chunks]:A.chunks),g(A.hasMore)}catch(A){!OL(A)&&O.current===T&&y(Ga(A,"加载数据预览失败"))}finally{O.current===T&&(d(!1),h(!1))}},[e.id,e.region,t]);p.useEffect(()=>(x(),()=>{var k;(k=v.current)==null||k.abort(),O.current+=1}),[x]);const w=Blt(s.url||t.url),S=Ult(s),E=s.metadata._veadk_content_format==="markdown";return o.jsx(AE,{title:s.name||t.name||t.id,onClose:n,className:"knowledge-dialog--preview",children:o.jsxs("div",{className:"knowledge-preview",children:[s.sizeBytes>0||w?o.jsxs("div",{className:"knowledge-preview__meta",children:[s.sizeBytes>0?o.jsx("span",{children:jB(s.sizeBytes)}):null,w?o.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"}):null]}):null,o.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:l?o.jsx("div",{className:"knowledge-preview__markdown-shell",children:o.jsx(Ou,{text:l,allowRawHtml:!1,className:"knowledge-preview__markdown"})}):u?o.jsx("div",{className:"knowledge-preview__state",role:"status",children:o.jsx(wn,{as:"span",duration:2.4,children:"正在加载数据预览"})}):b&&r.length===0?o.jsxs("div",{className:"knowledge-preview__state is-error",role:"alert",children:[o.jsx("p",{children:b}),o.jsx("button",{type:"button",onClick:()=>void x(),children:"重试"})]}):r.length===0?o.jsxs("div",{className:"knowledge-preview__state",children:[o.jsx("p",{children:S.title}),o.jsx("span",{children:w?"您可以打开原网页查看来源内容。":S.detail}),o.jsx("button",{type:"button",onClick:()=>void x(),children:"重新加载"})]}):o.jsxs("div",{className:"knowledge-preview__chunks",children:[r.map((k,_)=>{const T=$lt(k.tableFields),C=k.id||`${_}:${k.title}`;return o.jsxs("article",{className:"knowledge-preview__chunk",children:[o.jsx("header",{children:o.jsx("h3",{children:k.title||`片段 ${_+1}`})}),k.content?E?o.jsx(Ou,{text:k.content,allowRawHtml:!1,className:"knowledge-preview__markdown"}):o.jsx("p",{className:"knowledge-preview__content",children:k.content}):null,T?o.jsx("div",{className:"knowledge-preview__table-wrap",children:o.jsxs("table",{children:[o.jsx("thead",{children:o.jsx("tr",{children:T.columns.map((A,R)=>o.jsx("th",{scope:"col",children:A},`${A}:${R}`))})}),o.jsx("tbody",{children:T.rows.map((A,R)=>o.jsx("tr",{children:A.map((M,I)=>o.jsx("td",{children:M},I))},R))})]})}):null,o.jsx(Flt,{chunk:k})]},C)}),b?o.jsx("div",{className:"knowledge-preview__more-error",role:"alert",children:b}):null,m?o.jsx("button",{type:"button",className:"knowledge-preview__load-more",disabled:f,onClick:()=>void x(r.length),children:f?o.jsx(wn,{as:"span",duration:2.4,children:"正在加载更多"}):"加载更多"}):null]})})]})})}function Vlt({cloudProvider:e,region:t,active:n=!0,activationRevision:r=0,onDetailChange:i,toolbarLeading:s,toolbarFilters:a}){const[l,c]=p.useState([]),[u,d]=p.useState({}),[f,h]=p.useState([]),[m,g]=p.useState(""),[b,y]=p.useState("overview"),[O,v]=p.useState(""),[x,w]=p.useState(""),[S,E]=p.useState(!0),[k,_]=p.useState(!1),[T,C]=p.useState(""),[A,R]=p.useState([]),[M,I]=p.useState(!1),[$,N]=p.useState(""),[j,B]=p.useState(""),[F,L]=p.useState(""),[H,z]=p.useState(!1),[Q,V]=p.useState(!1),[K,se]=p.useState(!1),[ge,ie]=p.useState(null),[q,G]=p.useState(null),[J,ue]=p.useState(null),[Oe,Qe]=p.useState(null),[je,ze]=p.useState(null),[Ge,Ae]=p.useState(!1),Be=p.useRef(0),he=p.useRef(0),be=p.useRef([]),Se=p.useRef(!1),Ee=p.useRef(!1),tt=p.useRef(null),Ue=p.useRef(null),re=p.useRef({}),ce=p.useRef(!1),Me=p.useRef(null),Ye=p.useRef(null),Z=p.useRef(null),_e=p.useRef(null),rt=p.useMemo(()=>[t],[t]),Re=p.useCallback(ve=>`${ve.region}\0${ve.id}`,[]),We=l.find(ve=>Re(ve)===m)??null,ct=!!(We&&F===Re(We));p.useEffect(()=>{i==null||i(!!We)},[i,We]),p.useEffect(()=>{y("overview"),w("")},[m]);const kt=p.useMemo(()=>{const ve=O.trim().toLocaleLowerCase();return ve?l.filter(He=>[He.name,He.description,He.ownerLabel,He.providerKnowledgeId].some(pt=>pt.toLocaleLowerCase().includes(ve))):l},[l,O]),qt=p.useMemo(()=>{const ve=x.trim().toLocaleLowerCase();return ve?A.filter(He=>[He.name,He.id,vL(He)].some(pt=>pt.toLocaleLowerCase().includes(ve))):A},[x,A]);p.useEffect(()=>{G(null)},[We==null?void 0:We.id,We==null?void 0:We.region]);const Dt=p.useCallback(async(ve=!1)=>{var _t;if(ve&&(ce.current||Object.keys(re.current).length===0))return;(_t=tt.current)==null||_t.abort();const He=new AbortController;tt.current=He;const pt=Be.current+1;Be.current=pt,ce.current=!0,ve?_(!0):E(!0),C(""),ve||h([]);try{const It=await XGe({regions:rt,nextTokens:ve?re.current:void 0,signal:He.signal});if(Be.current!==pt)return;c(en=>ve?[...en,...It.items.filter(le=>!en.some(Xt=>Re(Xt)===Re(le)))]:It.items),re.current=It.nextTokens,d(It.nextTokens);const Kt=It.failures.map(({region:en,error:le})=>`${Jf(en,e)}:${Ga(le,"加载失败")}`);h(en=>ve?[...new Set([...en,...Kt])]:Kt),ve||g(en=>It.items.some(le=>Re(le)===en)?en:"")}catch(It){if(OL(It))return;Be.current===pt&&(ve?h(Kt=>[...new Set([...Kt,Ga(It,"加载更多知识库失败")])]):C(Ga(It,"加载知识库失败")))}finally{Be.current===pt&&(ce.current=!1,E(!1),_(!1))}},[Re,e,rt]),Xe=p.useCallback(async(ve,He=!1)=>{var It;if(He&&Se.current)return;(It=Ue.current)==null||It.abort();const pt=new AbortController;Ue.current=pt;const _t=he.current+1;he.current=_t,He||(be.current=[],Ee.current=!1,R([]),z(!1),B("")),Se.current=!0,I(!0),He?B(""):N("");try{const Kt=await ZGe(ve.id,{region:ve.region,offset:He?be.current.length:0,signal:pt.signal});if(he.current!==_t)return;L(Fe=>Fe===Re(ve)?"":Fe);const en=be.current,le=He?[...en,...Kt.items.filter(Fe=>!Fe.id||!en.some(Pt=>Pt.id===Fe.id))]:Kt.items,Xt=Kt.hasMore&&(!He||le.length>en.length);be.current=le,Ee.current=Xt,R(le),z(Xt)}catch(Kt){if(OL(Kt))return;he.current===_t&&(Kt instanceof Sj&&Kt.errorCode===Khe&&(L(Re(ve)),ie(le=>le&&Re(le)===Re(ve)?null:le)),He?B(Ga(Kt,"加载更多数据失败")):N(Ga(Kt,"加载数据失败")))}finally{he.current===_t&&(Se.current=!1,I(!1))}},[Re]);p.useEffect(()=>{var ve;(ve=tt.current)==null||ve.abort(),Be.current+=1,ce.current=!1,re.current={},c([]),d({}),h([]),g(""),L(""),C(""),E(!0)},[e]),p.useEffect(()=>{if(n)return Dt(),()=>{var ve;(ve=tt.current)==null||ve.abort(),Be.current+=1,ce.current=!1}},[n,r,Dt]),p.useEffect(()=>{var ve,He;if(!n){(ve=Ue.current)==null||ve.abort(),he.current+=1,Se.current=!1;return}if(!We){(He=Ue.current)==null||He.abort(),he.current+=1,be.current=[],Se.current=!1,Ee.current=!1,R([]),z(!1),B("");return}return Xe(We),()=>{var pt;(pt=Ue.current)==null||pt.abort(),he.current+=1,Se.current=!1}},[n,r,We==null?void 0:We.id,We==null?void 0:We.region]);const nt=n&&!We&&!O.trim()&&!S&&!k&&!T&&Object.keys(u).length>0;p.useEffect(()=>{const ve=Ye.current,He=Me.current;if(!ve||!He||!nt)return;const pt=new IntersectionObserver(([_t])=>{_t.isIntersecting&&Dt(!0)},{root:He,rootMargin:"240px 0px",threshold:.01});return pt.observe(ve),()=>pt.disconnect()},[nt,Dt]);const ft=()=>{const ve=Me.current;!ve||!nt||ve.scrollHeight-ve.scrollTop-ve.clientHeight<=240&&Dt(!0)},xt=!!(We&&A.length>0&&H&&!M&&!j);p.useEffect(()=>{const ve=_e.current,He=Z.current;if(!We||!ve||!He||!xt)return;const pt=new IntersectionObserver(([_t])=>{_t.isIntersecting&&Xe(We,!0)},{root:Z.current,rootMargin:"240px 0px",threshold:.01});return pt.observe(ve),()=>pt.disconnect()},[xt,Xe,We==null?void 0:We.id,We==null?void 0:We.region]);const Ie=()=>{const ve=Z.current;if(!We||!ve||!Ee.current||Se.current||j)return;const{scrollHeight:He,scrollTop:pt,clientHeight:_t}=ve;He-pt-_t<=240&&Xe(We,!0)},xe=ve=>{c(He=>He.map(pt=>Re(pt)===Re(ve)?ve:pt))},$e=async()=>{if(Oe){Ae(!0);try{await YGe(Oe.id,Oe.region),c(ve=>ve.filter(He=>Re(He)!==Re(Oe))),L(ve=>ve===Re(Oe)?"":ve),m===Re(Oe)&&g(""),Qe(null)}catch(ve){C(Ga(ve,"删除知识库失败")),Qe(null)}finally{Ae(!1)}}},it=async()=>{if(!(!We||!je)){Ae(!0);try{await rWe(We.id,je.id,We.region);const ve=be.current.filter(He=>He.id!==je.id);be.current=ve,R(ve),ze(null)}catch(ve){N(Ga(ve,"删除知识失败")),ze(null)}finally{Ae(!1)}}};return o.jsxs("section",{className:`knowledge-library${We?" is-detail":" resource-collection"}`,"aria-label":"知识库",children:[We?o.jsx(gE,{className:"knowledge-library__detail",title:We.name,description:We.description||"暂无描述",identitySeed:We.name,backLabel:"返回知识库列表",onBack:()=>g(""),sections:[{key:"overview",label:"概览",content:o.jsx("section",{className:"knowledge-overview",children:o.jsxs(Y7,{className:"knowledge-overview__summary",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"Provider"}),o.jsx("dd",{children:We.providerType||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"Knowledge ID"}),o.jsx("dd",{className:"knowledge-keyboard-reveal",tabIndex:0,title:We.providerKnowledgeId,children:We.providerKnowledgeId||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"项目"}),o.jsx("dd",{children:We.projectName||"default"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"创建者"}),o.jsx("dd",{children:zv(We.ownerLabel)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"更新时间"}),o.jsx("dd",{children:klt(We.updatedAt)||"-"})]})]})})},{key:"data",label:"数据",content:o.jsx("section",{className:"knowledge-documents",children:o.jsx("div",{className:`knowledge-documents__body${A.length>0?" is-table":""}`,"aria-live":"polite",children:M&&A.length===0?o.jsx(yd,{}):$&&A.length===0?o.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[o.jsx("p",{children:$}),ct&&We.canManage?o.jsx("button",{type:"button",onClick:()=>Qe(We),children:"删除失效关联"}):o.jsx("button",{type:"button",onClick:()=>void Xe(We),children:"重试"})]}):A.length===0?o.jsxs("div",{className:"knowledge-library__state",children:[o.jsx(wlt,{}),o.jsx("p",{children:"这个知识库还没有数据"}),We.canManage&&o.jsx("button",{type:"button",onClick:()=>ie(We),children:"添加第一项数据"})]}):o.jsx(fGe,{rows:qt,rowKey:ve=>ve.id,rowLabel:ve=>ve.name||ve.id,columns:[{key:"name",header:"名称",className:"is-primary-column",render:ve=>o.jsx("span",{title:ve.name||ve.id,children:ve.name||ve.id})},{key:"format",header:"格式",className:"is-compact-column",render:ve=>vL(ve)},{key:"size",header:"大小",className:"is-compact-column",render:ve=>jB(ve.sizeBytes)}],searchValue:x,onSearchChange:w,searchPlaceholder:"搜索数据",searchLabel:"搜索知识库数据",primaryAction:We.canManage?{label:ct?"关联已失效":"添加数据",disabled:ct,title:ct?"底层 Provider 知识库已不存在":void 0,onClick:()=>ie(We)}:void 0,rowActions:ve=>[{label:"预览",onSelect:()=>G(ve)},...We.canManage?[{label:"编辑",onSelect:()=>ue(ve)},{label:"删除",onSelect:()=>ze(ve),danger:!0}]:[]],scrollRef:Z,onScroll:Ie,busy:M,emptyLabel:"没有匹配的数据",footer:M?o.jsxs("div",{className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),o.jsx("span",{children:"正在加载更多数据"})]}):j?o.jsxs("div",{className:"knowledge-document-pagination is-error",role:"alert",children:[o.jsx("span",{children:j}),o.jsx("button",{type:"button",onClick:()=>void Xe(We,!0),children:"重试加载"})]}):H?o.jsx("div",{ref:_e,className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:"继续下滑加载更多"}):null})})})}],activeSectionKey:b,navigationLabel:"知识库详情",onSectionChange:y,actions:We.canManage?o.jsxs(o.Fragment,{children:[o.jsx(jt,{type:"button",color:"danger",variant:"soft",size:"lg",pill:!1,onClick:()=>Qe(We),children:"删除"}),o.jsx(jt,{type:"button",color:"primary",size:"lg",pill:!1,onClick:()=>se(!0),children:"编辑"})]}):void 0}):o.jsxs(o.Fragment,{children:[o.jsxs(g0,{className:"knowledge-library__toolbar library-resource-toolbar",children:[s,o.jsxs("div",{className:"resource-toolbar__actions",children:[a,o.jsx(Wp,{value:O,onChange:ve=>v(ve.target.value),placeholder:"搜索知识库","aria-label":"搜索知识库"})]})]}),o.jsxs(b0,{ref:Me,"aria-live":"polite",onScroll:ft,children:[f.length>0&&!S&&o.jsxs("div",{className:"knowledge-region-warning",role:"status",children:[o.jsx("span",{children:"部分知识库暂时无法加载,已展示其余可用内容。"}),o.jsx("button",{type:"button",onClick:()=>void Dt(),children:"重试"})]}),S&&l.length===0?o.jsx(yd,{}):T?o.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[o.jsx("p",{children:T}),o.jsx("button",{type:"button",onClick:()=>void Dt(),children:"重试"})]}):kt.length===0&&O.trim()?o.jsxs("div",{className:"knowledge-library__state",children:[o.jsx(vlt,{}),o.jsx("p",{children:"没有匹配的知识库"})]}):o.jsxs(sO,{children:[O.trim()?null:o.jsx(Vg,{"aria-label":"新建知识库",icon:o.jsx(Elt,{}),onClick:()=>V(!0),children:"新建知识库"}),kt.map(ve=>o.jsx(xE,{className:"knowledge-card",title:ve.name,description:ve.description||"暂无描述",metadata:[{label:"创建者",value:zv(ve.ownerLabel),title:zv(ve.ownerLabel)},{label:"项目",value:ve.projectName||"default",title:ve.projectName||"default"}],action:{label:F===Re(ve)?"关联已失效":"添加数据",icon:"plus",disabled:!ve.canManage||F===Re(ve),title:ve.canManage?F===Re(ve)?"底层 Provider 知识库已不存在":void 0:"您没有管理此知识库的权限",onClick:()=>ie(ve)},detailAction:{label:"查看详情",onClick:()=>g(Re(ve))}},Re(ve)))]}),nt||k?o.jsx("div",{ref:Ye,className:"my-agent-load-more",role:"status","aria-live":"polite",children:k?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),o.jsx("span",{children:"正在加载更多知识库"})]}):nt?o.jsx("span",{children:"继续下滑加载更多"}):null}):null]})]}),Q&&o.jsx(Nlt,{region:t,onClose:()=>V(!1),onCreated:ve=>{c(He=>[ve,...He]),g(Re(ve)),V(!1)}}),We&&K&&o.jsx(jlt,{item:We,onClose:()=>se(!1),onUpdated:ve=>{xe(ve),se(!1)}}),We&&q&&o.jsx(zlt,{base:We,item:q,onClose:()=>G(null)}),ge&&o.jsx(Rlt,{base:ge,onClose:()=>ie(null),onAssociationInvalid:ve=>{L(Re(ge)),We&&Re(We)===Re(ge)&&N(Ga(ve,"知识库关联已失效")),ie(null)},onCreated:()=>{We&&Re(We)===Re(ge)&&Xe(We),ie(null)}}),We&&J&&o.jsx(Ilt,{base:We,item:J,onClose:()=>ue(null),onUpdated:ve=>{const He=be.current.map(pt=>pt.id===ve.id?ve:pt);be.current=He,R(He),ue(null)}}),Oe&&o.jsx(ql,{title:"删除知识库?",description:`将删除 ${Oe.name} 的 AgentKit 关联;如果它由 Studio 创建,也会同时删除 Provider 资源。此操作无法撤销。`,confirmLabel:Ge?"删除中":"删除",variant:"danger",busy:Ge,onCancel:()=>Qe(null),onConfirm:()=>void $e()}),je&&o.jsx(ql,{title:"删除知识?",description:`将从 Provider 知识库中删除 ${je.name||je.id},此操作无法撤销。`,confirmLabel:Ge?"删除中":"删除",variant:"danger",busy:Ge,onCancel:()=>ze(null),onConfirm:()=>void it()})]})}const Hlt="_EmptyMessage_1r5gu_1",qlt="_IconBadge_1r5gu_16",Xlt="_Title_1r5gu_54",Glt="_Description_1r5gu_69",Wlt="_ActionRow_1r5gu_77",NE={EmptyMessage:Hlt,IconBadge:qlt,Title:Xlt,Description:Glt,ActionRow:Wlt},yn=({children:e,className:t,fill:n="static"})=>o.jsx("div",{className:sr(NE.EmptyMessage,t),"data-fill":n,children:e}),Ylt=({size:e="md",color:t="secondary",children:n,className:r})=>o.jsx("div",{className:sr(NE.IconBadge,r),"data-size":e,"data-color":t,children:n}),Zlt=({children:e,className:t,color:n="secondary"})=>o.jsx("div",{className:sr(NE.Title,t),"data-color":n,children:e}),Klt=({children:e,className:t})=>o.jsx("div",{className:sr(NE.Description,t),children:e}),Jlt=({children:e,className:t})=>o.jsx("div",{className:sr(NE.ActionRow,t),children:e});yn.Icon=Ylt;yn.Title=Zlt;yn.Description=Klt;yn.ActionRow=Jlt;const ect="/web/skill-management";class tct extends Error{constructor(t,n,r="SKILL_MANAGEMENT_ERROR",i="",s,a=""){super(t),this.status=n,this.code=r,this.statusText=i,this.originalError=s,this.rawResponse=a,this.name="SkillManagementApiError"}}async function xh(e,t={},n=Ao){return fetch(So(`${ect}${e}`),{...t,headers:ph(t.headers),signal:il(t.signal,n)})}async function Vge(e,t){let n=t,r="SKILL_MANAGEMENT_ERROR",i;const s=await e.text().catch(()=>"");try{const a=JSON.parse(s);typeof a.detail=="string"?n=a.detail:a.detail&&(n=a.detail.message||t,r=a.detail.code||r,i=a.detail.originalError)}catch{s.trim()&&(n=`${t}:${s.trim()}`)}return new tct(n,e.status,r,e.statusText,i,s)}async function vh(e,t){if(!e.ok)throw await Vge(e,t);return e.json()}async function nct(e){const t=new URLSearchParams({region:e.region,page:String(e.page),page_size:String(e.pageSize)});return e.project&&t.set("project",e.project),vh(await xh(`/spaces?${t}`,{signal:e.signal}),"读取 Skill 空间失败")}async function rct(e){return vh(await xh("/spaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),"创建 Skill 空间失败")}async function ict(e){return vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description,region:e.region})}),"更新 Skill 空间失败")}async function sct(e){const t=new URLSearchParams({region:e.region});await vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}?${t}`,{method:"DELETE"}),"删除 Skill 空间失败")}async function act(e){const t=new URLSearchParams({region:e.region});return e.project&&t.set("project",e.project),vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}/skills?${t}`,{method:"POST",headers:{"Content-Type":"application/zip"},body:e.file},es),"上传 Skill 失败")}async function oct(e){return vh(await xh("/validate",{method:"POST",headers:{"Content-Type":"application/zip"},body:e},es),"校验 Skill 失败")}async function lct(e){const t=new URLSearchParams({region:e.region});await vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}?${t}`,{method:"DELETE"}),"删除 Skill 失败")}async function cct(e){const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version),e.skillSpaceName&&t.set("skill_space_name",e.skillSpaceName),e.skillName&&t.set("skill_name",e.skillName);const n=await vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/files?${t}`),"读取 Skill 文件失败");return Array.isArray(n.files)?n.files:[]}async function uct(e){var l;const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version),e.skillSpaceName&&t.set("skill_space_name",e.skillSpaceName),e.skillName&&t.set("skill_name",e.skillName);const n=await xh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/archive?${t}`,{},es);n.ok||await vh(n,"下载 Skill 失败");const i=((l=(n.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:l[1])||`${e.fallbackName}.zip`,s=URL.createObjectURL(await n.blob()),a=document.createElement("a");a.href=s,a.download=i,a.click(),URL.revokeObjectURL(s)}async function Mj(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:il(void 0,Ao)});if(!t.ok)throw await Vge(t,"AgentKit Skills 请求失败");return t.json()}async function Hge(){return(await Mj("/web/skill-spaces")).items||[]}async function qge(e,t){const n=t?`?region=${encodeURIComponent(t)}`:"";return(await Mj(`/web/skill-spaces/${encodeURIComponent(e)}/skills${n}`)).items||[]}async function dct(e,t){const n=new URLSearchParams({region:t.region,page:String(t.page),page_size:String(t.pageSize)});return t.project&&n.set("project",t.project),Mj(`/web/skill-spaces/${encodeURIComponent(e)}/skills?${n.toString()}`)}async function fct(e,t,n,r,i,s,a){const l=[];n&&l.push(`version=${encodeURIComponent(n)}`),r&&l.push(`region=${encodeURIComponent(r)}`),i&&l.push(`project=${encodeURIComponent(i)}`),s&&l.push(`skill_name=${encodeURIComponent(s)}`),a&&l.push(`skill_space_name=${encodeURIComponent(a)}`);const c=l.length>0?`?${l.join("&")}`:"";return Mj(`/web/skill-spaces/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}${c}`)}function hct(e,t){return{source:"skillspace",id:`ss:${e.id}/${t.skillId}/${t.version}`,name:t.skillName,description:t.skillDescription,folder:t.skillName,skillSpaceId:e.id,skillSpaceName:e.name,skillSpaceRegion:e.region,skillId:t.skillId,version:t.version}}function pct(e,t,n="volcengine"){return n==="byteplus"?"":`https://console.volcengine.com/agentkit/${(t||"cn-beijing")==="cn-beijing"?"cn":"cn-shanghai"}/skillspace/detail/${encodeURIComponent(e)}`}const mct="/web/skill-workbench";class wL extends Error{constructor(t,n,r="SKILL_WORKBENCH_ERROR",i=!1,s="",a,l=""){super(t),this.status=n,this.code=r,this.retryable=i,this.statusText=s,this.originalError=a,this.rawResponse=l,this.name="SkillWorkbenchApiError"}}function Rc(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function BW(e,t){if(e!=null){if(typeof e!="string"||!e.trim()||e.trim().length>256)throw new Error(`${t}格式错误。`);return e.trim()}}function gct(e){if(e!=null){if(e==="pending"||e==="ready"||e==="failed"||e==="unknown")return e;throw new Error("Skill 恢复点状态格式错误。")}}async function Od(e,t={},n=Ao){return fetch(So(`${mct}${e}`),{...t,headers:ph(t.headers),signal:il(t.signal,n)})}async function RB(e,t){var r;const n=await e.text().catch(()=>"");try{const i=Rc(JSON.parse(n),"错误响应"),s=i.detail&&typeof i.detail=="object"?Rc(i.detail,"错误详情"):i;return new wL(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"SKILL_WORKBENCH_ERROR",s.retryable===!0,e.statusText,s.originalError&&typeof s.originalError=="object"?s.originalError:void 0,n)}catch{const i=((r=e.headers.get("content-type"))==null?void 0:r.split(";",1)[0])||"Content-Type 缺失";return new wL(`${t}(HTTP ${e.status},Content-Type: ${i})。请检查代理或网关配置。`,e.status,"SKILL_WORKBENCH_ERROR",!1,e.statusText,void 0,n)}}async function Zp(e,t){if(!e.ok)throw await RB(e,t);const n=e.headers.get("content-type")??"";if(!n.includes("application/json")){const r=n.split(";",1)[0]||"Content-Type 缺失";throw new Error(`${t}:服务端返回非 JSON 响应(HTTP ${e.status},Content-Type: ${r}),请检查代理或网关配置。`)}return e.json()}function bct(e){return Array.isArray(e)?e.map(t=>{const n=Rc(t,"Skill 会话活动"),r=n.kind,i=n.status;if(typeof n.id!="string"||!["status","thinking","message","tool"].includes(String(r))||!["running","done"].includes(String(i)))throw new Error("Skill 会话活动格式错误。");if(r==="tool"){if(typeof n.name!="string")throw new Error("Skill 工具活动格式错误。");return{id:n.id,kind:r,status:i,name:n.name,...n.input!==void 0?{args:n.input}:{},...n.output!==void 0?{response:n.output}:{}}}if(typeof n.text!="string")throw new Error("Skill 文本活动格式错误。");return{id:n.id,kind:r,status:i,text:n.text}}):[]}function yct(e){if(e==null)return;const t=Rc(e,"Skill 发布结果");if(typeof t.revision!="number"||typeof t.skillId!="string"||typeof t.version!="string"||!Array.isArray(t.skillSpaceIds)||!t.skillSpaceIds.every(n=>typeof n=="string")||t.disposition!=="create-new"&&t.disposition!=="update-source"||!GS(t.region)||typeof t.projectName!="string")throw new Error("Skill 发布结果格式错误。");return{revision:t.revision,skillId:t.skillId,version:t.version,skillSpaceIds:t.skillSpaceIds,disposition:t.disposition,region:t.region,projectName:t.projectName}}function Kw(e){const t=Rc(e,"Skill 会话");if(typeof t.jobId!="string"||t.operation!=="create"&&t.operation!=="optimize"||typeof t.intent!="string"||typeof t.revision!="number"||typeof t.state!="string")throw new Error("Skill 会话格式错误。");const n=Array.isArray(t.files)?t.files.flatMap(l=>{const c=Rc(l,"Skill 文件");return typeof c.path=="string"&&typeof c.size=="number"?[{path:c.path,size:c.size}]:[]}):[];if(!["running","ready","failed","cancelled","expired","published"].includes(t.state))throw new Error("Skill 会话状态无法识别。");const i=BW(t.toolId,"Tool ID"),s=BW(t.sessionId,"Session ID"),a=gct(t.recoveryStatus);return{jobId:t.jobId,operation:t.operation,intent:t.intent,...typeof t.model=="string"?{model:t.model}:{},...typeof t.style=="string"?{style:t.style}:{},...typeof t.requestedName=="string"?{requestedName:t.requestedName}:{},revision:t.revision,...i?{toolId:i}:{},...s?{sessionId:s}:{},...typeof t.sessionTtlSeconds=="number"?{sessionTtlSeconds:t.sessionTtlSeconds}:{},...typeof t.expiresAt=="string"?{expiresAt:t.expiresAt}:{},...typeof t.recoveryAvailable=="boolean"?{recoveryAvailable:t.recoveryAvailable}:{},...a?{recoveryStatus:a}:{},...typeof t.recoveredFromSnapshot=="boolean"?{recoveredFromSnapshot:t.recoveredFromSnapshot}:{},state:t.state,stage:typeof t.stage=="string"?t.stage:"generating",activities:bct(t.activities),files:n,...t.source&&typeof t.source=="object"?{source:t.source}:{},...typeof t.name=="string"?{name:t.name}:{},...typeof t.description=="string"?{description:t.description}:{},...typeof t.skillMd=="string"?{skillMd:t.skillMd}:{},...typeof t.error=="string"?{error:t.error}:{},...t.validation&&typeof t.validation=="object"?{validation:t.validation}:{},...t.publication?{publication:yct(t.publication)}:{}}}async function Lj(e){const t=Rc(await Zp(await Od("/capabilities",{signal:e}),"读取 Skill 工作台能力失败"),"Skill 工作台能力");return{enabled:t.enabled===!0,reason:typeof t.reason=="string"?t.reason:"",operations:Array.isArray(t.operations)?t.operations.filter(n=>n==="create"||n==="optimize"):[],models:Array.isArray(t.models)?t.models.flatMap(n=>{if(!n||typeof n!="object")return[];const r=n;return typeof r.id=="string"&&typeof r.label=="string"?[{id:r.id,label:r.label}]:[]}):[],styles:t.styles&&typeof t.styles=="object"&&!Array.isArray(t.styles)?Object.fromEntries(Object.entries(t.styles).filter(n=>typeof n[1]=="string")):{},...typeof t.maxUploadBytes=="number"?{maxUploadBytes:t.maxUploadBytes}:{}}}async function Oct(e){if(e.file){const n=new URLSearchParams({operation:"optimize",intent:e.intent});e.jobId&&n.set("job_id",e.jobId),e.model&&n.set("model",e.model),e.style&&n.set("style",e.style),e.name&&n.set("name",e.name);const r=await Od(`/tasks/from-upload?${n}`,{method:"POST",body:e.file,headers:{"Content-Type":"application/zip"},signal:e.signal},es);return Kw(await Zp(r,"开始优化 Skill 失败"))}const t=await Od("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:e.operation,intent:e.intent,...e.model?{model:e.model}:{},...e.style?{style:e.style}:{},...e.name?{name:e.name}:{},...e.jobId?{jobId:e.jobId}:{},...e.source?{source:{kind:"skill-center",skillId:e.source.skillId,skillName:e.source.name,version:e.source.version,region:e.source.region,projectName:e.source.projectName,skillSpaceId:e.source.skillSpaceId,skillSpaceName:e.source.skillSpaceName}}:{}}),signal:e.signal},es);return Kw(await Zp(t,"开始 Skill 会话失败"))}async function xct(e,t){return Kw(await Zp(await Od(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取 Skill 会话失败"))}async function vD(e,t,n){const r=new URLSearchParams;r.set("expected_revision",String(t));const i=Rc(await Zp(await Od(`/tasks/${encodeURIComponent(e)}/artifact?${r.toString()}`,{signal:n}),"读取 Skill 产物失败"),"Skill 产物");if(i.jobId!==e||i.revision!==t||!Number.isSafeInteger(i.revision)||i.revision<1||typeof i.sha256!="string"||!/^[0-9a-f]{64}$/.test(i.sha256)||typeof i.name!="string"||typeof i.description!="string"||!Array.isArray(i.files))throw new Error("Skill 产物格式错误。");const s=i.files.map(a=>{const l=Rc(a,"Skill 产物文件");if(typeof l.path!="string"||typeof l.size!="number"||typeof l.content!="string")throw new Error("Skill 产物文件格式错误。");return{path:l.path,size:l.size,content:l.content}});return{jobId:i.jobId,revision:i.revision,sha256:i.sha256,name:i.name,description:i.description,files:s}}async function wD(e){const t=await Od(`/tasks/${encodeURIComponent(e.jobId)}/refinements`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:e.intent,expectedRevision:e.expectedRevision})},es);return Kw(await Zp(t,"继续调整 Skill 失败"))}async function vct(e){const t=await Od(`/tasks/${encodeURIComponent(e.jobId)}/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedRevision:e.expectedRevision})});return Kw(await Zp(t,"停止当前 Skill 任务失败"))}async function wct(e){const t=await Od(`/tasks/${encodeURIComponent(e.jobId)}/publish-stream`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},body:JSON.stringify({disposition:e.disposition,expectedRevision:e.expectedRevision,expectedArtifactSha256:e.expectedArtifactSha256,skillSpaceIds:e.skillSpaceIds??[],projectName:e.projectName,region:e.region}),signal:e.signal},0);if(!t.ok)throw await RB(t,"发布 Skill 失败");if(!(t.headers.get("content-type")??"").includes("application/x-ndjson"))throw new Error("发布 Skill 失败:服务端返回了非 NDJSON 响应。");if(!t.body)throw new Error("发布 Skill 失败:服务端没有返回进度流。");const r=new Set(["preparing","uploading","registering","activating","publishing"]);let i=null,s="";const a=new TextDecoder,l=t.body.getReader(),c=u=>{var h;if(!u.trim())return;const d=Rc(JSON.parse(u),"发布进度");if(d.type==="progress"){if(typeof d.phase!="string"||!r.has(d.phase)||typeof d.message!="string")throw new Error("发布进度格式错误。");(h=e.onProgress)==null||h.call(e,{phase:d.phase,message:d.message});return}if(d.type==="error"){const m=Rc(d.error,"发布错误");throw new wL(typeof m.message=="string"?m.message:"发布 Skill 失败",500,typeof m.code=="string"?m.code:"SKILL_PUBLISH_FAILED",m.retryable===!0,"",m.originalError&&typeof m.originalError=="object"?m.originalError:void 0,JSON.stringify(d.error))}if(d.type!=="complete")throw new Error("未知的发布进度事件。");const f=Rc(d.result,"发布结果");if(typeof f.skillId!="string"||typeof f.version!="string"||!Array.isArray(f.skillSpaceIds)||!f.skillSpaceIds.every(m=>typeof m=="string")||f.disposition!=="create-new"&&f.disposition!=="update-source"||!GS(f.region)||typeof f.projectName!="string")throw new Error("发布结果格式错误。");i={skillId:f.skillId,version:f.version,skillSpaceIds:f.skillSpaceIds,disposition:f.disposition,region:f.region,projectName:f.projectName}};for(;;){const{value:u,done:d}=await l.read();s+=a.decode(u,{stream:!d});const f=s.split(`
-`);if(s=f.pop()??"",f.forEach(c),d)break}if(c(s),!i)throw new Error("发布进度流提前结束,无法确认发布结果。请刷新技能中心确认状态。");return i}async function Sct(e){await Zp(await Od(`/tasks/${encodeURIComponent(e)}`,{method:"DELETE"}),"删除 Skill 会话失败")}async function Ect(e,t,n){var c;const r=new URLSearchParams;r.set("expected_revision",String(t)),r.set("expected_sha256",n);const i=await Od(`/tasks/${encodeURIComponent(e)}/download?${r.toString()}`,{},es);if(!i.ok)throw await RB(i,"下载 Skill 失败");const a=((c=(i.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:c[1])??"skill.zip",l=URL.createObjectURL(await i.blob());try{const u=document.createElement("a");u.href=l,u.download=a,u.click()}finally{URL.revokeObjectURL(l)}}const kct={formatDate(e){const t=e.value??e.date??e.timestamp;if(t==null)return"";const n=new Date(t);return isNaN(n.getTime())?String(t):n.toLocaleString()}};function _ct(e,t){if(!t||t==="/")return e;const n=t.replace(/^\//,"").split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const i of n){if(r==null||typeof r!="object")return;r=r[i]}return r}function Tct(e){return typeof e=="object"&&e!==null&&typeof e.path=="string"}function Cct(e){return typeof e=="object"&&e!==null&&typeof e.call=="string"}function IB(e,t){if(Tct(e))return _ct(t,e.path);if(Cct(e)){const n=kct[e.call],r={};for(const[i,s]of Object.entries(e.args??{}))r[i]=IB(s,t);return n?n(r):`[unknown fn: ${e.call}]`}return e}function Act(e,t){const n=IB(e,t);return n==null?"":typeof n=="string"?n:String(n)}const Xge=new Map;function S0(e,t){Xge.set(e,t)}function Nct(e){return Xge.get(e)}function jct(e,t,n){const r=t.replace(/^\//,"").split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~"));let i=e;for(let s=0;sIB(r,e.dataModel),resolveString:r=>Act(r,e.dataModel),dispatchAction:t,render:r=>{if(!r)return null;const i=e.components[r];if(!i)return null;const s=Nct(i.component)??Rct;return o.jsx(s,{node:i,ctx:n},r)}};return o.jsx("div",{className:"a2ui-surface","data-a2ui-surface":e.surfaceId,children:n.render(e.rootId)})}function Wge(e){const t=p.useRef(null),n=p.useRef(!0),r=28,i=p.useCallback(()=>{const s=t.current;s&&(n.current=s.scrollHeight-s.scrollTop-s.clientHeight{const s=t.current;s&&n.current&&(s.scrollTop=s.scrollHeight)},[e]),{ref:t,onScroll:i}}function $j({value:e,skillPrefix:t="/",onRemoveSkill:n,onRemoveAgent:r}){return e.skills.length===0&&!e.targetAgent?null:o.jsxs("div",{className:"invocation-chips","aria-label":"本轮调用上下文",children:[e.skills.map(i=>o.jsxs("span",{className:"invocation-chip invocation-chip--skill",title:i.description,children:[o.jsx(Sw,{"aria-hidden":!0}),o.jsxs("span",{children:[t,i.name]}),n?o.jsx("button",{type:"button",onClick:()=>n(i.name),"aria-label":`移除技能 ${i.name}`,children:o.jsx(Ea,{})}):null]},i.name)),e.targetAgent?o.jsxs("span",{className:"invocation-chip invocation-chip--agent",title:e.targetAgent.description,children:[o.jsx(Pae,{"aria-hidden":!0}),o.jsx("span",{children:e.targetAgent.name}),r?o.jsx("button",{type:"button",onClick:r,"aria-label":`移除 Agent ${e.targetAgent.name}`,children:o.jsx(Ea,{})}):null]}):null]})}function DB(e=""){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e==="application/pdf"?"pdf":e==="text/markdown"?"markdown":"text"}function Yge(e){var n,r,i,s;const t=DB(e.mimeType);return t==="pdf"?"PDF":t==="markdown"?"MD":t==="video"?((r=(n=e.mimeType)==null?void 0:n.split("/")[1])==null?void 0:r.toUpperCase())??"VIDEO":t==="image"?((s=(i=e.mimeType)==null?void 0:i.split("/")[1])==null?void 0:s.toUpperCase())??"IMAGE":"TXT"}function Zge(e){return e?e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function Kge(e,t){return e.previewUrl?e.previewUrl:e.data?`data:${e.mimeType??"application/octet-stream"};base64,${e.data}`:e.uri?poe(t,e.uri):""}function Dct({kind:e}){return e==="image"?o.jsx(s9,{}):e==="video"?o.jsx($ae,{}):e==="pdf"?o.jsx(XRe,{}):o.jsx(r9,{})}function Bj({appName:e,items:t,compact:n=!1,onRemove:r}){const[i,s]=p.useState(null);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`media-grid${n?" media-grid--compact":""}`,children:t.map(a=>{const l=DB(a.mimeType),c=Kge(a,e),u=a.status==="uploading"||a.status==="error"||!c,d=o.jsxs("button",{type:"button",className:"media-card-main",disabled:u,onClick:l==="image"?void 0:()=>s(a),"aria-label":`预览 ${a.name??"附件"}`,children:[l==="image"&&c?o.jsx("img",{className:"media-card-image",src:c,alt:a.name??"图片",loading:"lazy"}):l==="video"&&c?o.jsxs("div",{className:"media-card-video-container",children:[o.jsx("video",{className:"media-card-video",src:c,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),o.jsx("span",{className:"media-card-video-play",children:o.jsx(sIe,{})})]}):o.jsx("span",{className:"media-card-icon",children:o.jsx(Dct,{kind:l})}),o.jsxs("span",{className:"media-card-copy",children:[o.jsx("span",{className:"media-card-name",children:a.name??"附件"}),o.jsxs("span",{className:"media-card-meta",children:[o.jsx("span",{className:"media-card-type",children:Yge(a)}),a.status==="uploading"?o.jsxs(o.Fragment,{children:[o.jsx(rr,{className:"media-card-spinner"})," 上传中"]}):a.status==="error"?a.error??"上传失败":Zge(a.sizeBytes)]})]}),!n&&a.status!=="uploading"&&a.status!=="error"?o.jsx(cy,{className:"media-card-open"}):null]});return o.jsxs(ai.div,{className:`media-card media-card--${l}${a.status==="error"?" media-card--error":""}`,layout:!0,initial:{opacity:0,scale:.985,y:4},animate:{opacity:1,scale:1,y:0},children:[l==="image"&&!u?o.jsx(Tae,{src:c,children:d}):d,r?o.jsx("button",{type:"button",className:"media-card-remove","aria-label":`移除 ${a.name??"附件"}`,onClick:()=>r(a.id),children:o.jsx(Ea,{})}):null]},a.id)})}),o.jsx(fu,{children:i?o.jsx(Pct,{appName:e,item:i,onClose:()=>s(null)}):null})]})}function Pct({appName:e,item:t,onClose:n}){const r=p.useMemo(()=>Kge(t,e),[e,t]),i=DB(t.mimeType),[s,a]=p.useState(""),[l,c]=p.useState(i==="text"||i==="markdown"),[u,d]=p.useState("");return p.useEffect(()=>{const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),p.useEffect(()=>{if(i!=="text"&&i!=="markdown")return;const f=new AbortController;return c(!0),d(""),fetch(r,{signal:f.signal}).then(h=>{if(!h.ok)throw new Error(`HTTP ${h.status}`);return h.text()}).then(a).catch(h=>{f.signal.aborted||d(h instanceof Error?h.message:String(h))}).finally(()=>{f.signal.aborted||c(!1)}),()=>f.abort()},[i,r]),o.jsx(ai.div,{className:"media-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":t.name??"附件预览",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onMouseDown:f=>{f.target===f.currentTarget&&n()},children:o.jsxs(ai.div,{className:"media-viewer",initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.99},transition:{type:"spring",stiffness:420,damping:30},children:[o.jsxs("header",{className:"media-viewer-header",children:[o.jsxs("div",{children:[o.jsx("strong",{children:t.name??"附件"}),o.jsxs("span",{children:[Yge(t),t.sizeBytes?` · ${Zge(t.sizeBytes)}`:""]})]}),o.jsxs("nav",{children:[o.jsx("a",{href:r,download:t.name,"aria-label":"下载",children:o.jsx(jN,{})}),o.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",children:o.jsx(Ea,{})})]})]}),o.jsxs("div",{className:`media-viewer-body media-viewer-body--${i}`,children:[i==="image"?o.jsx("img",{src:r,alt:t.name??"图片"}):null,i==="video"?o.jsx("div",{className:"media-viewer-video-wrapper",children:o.jsx("video",{src:r,controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",className:"media-viewer-video"})}):null,i==="pdf"?o.jsx("iframe",{src:r,title:t.name??"PDF"}):null,l?o.jsxs("div",{className:"media-viewer-loading",children:[o.jsx(rr,{})," 正在读取文档…"]}):null,!l&&u?o.jsxs("div",{className:"media-viewer-loading",children:["文档加载失败:",u]}):null,!l&&i==="markdown"?o.jsx("div",{className:"media-document",children:o.jsx(Ou,{text:s})}):null,!l&&i==="text"?o.jsx("pre",{className:"media-document media-document--plain",children:s}):null]})]})})}function Mct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"10.25",cy:"10.25",r:"6.25"}),o.jsx("path",{d:"M4.15 10.25h12.2M10.25 4c1.65 1.72 2.5 3.8 2.5 6.25s-.85 4.53-2.5 6.25M10.25 4c-1.65 1.72-2.5 3.8-2.5 6.25s.85 4.53 2.5 6.25M14.8 14.8 20 20"})]})}function Lct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.25",y:"5.25",width:"15.5",height:"13.5",rx:"2.25"}),o.jsx("circle",{cx:"8.1",cy:"9.3",r:"1.35"}),o.jsx("path",{d:"m4.7 16.5 3.65-3.7 2.45 2.25 2.2-2.2 4.35 4.1"}),o.jsx("path",{d:"m19.4 2.75.48 1.37 1.37.48-1.37.48-.48 1.37-.48-1.37-1.37-.48 1.37-.48.48-1.37Z",fill:"currentColor",stroke:"none"})]})}function PB(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{className:"video-generate-icon__body",d:"M3.25 9h17.5v7.35a2.4 2.4 0 0 1-2.4 2.4H5.65a2.4 2.4 0 0 1-2.4-2.4V9Z"}),o.jsxs("g",{className:"video-generate-icon__clapper",children:[o.jsx("path",{d:"M3.25 9V7.65a2.4 2.4 0 0 1 2.4-2.4h12.7a2.4 2.4 0 0 1 2.4 2.4V9H3.25Z"}),o.jsx("path",{d:"M6.75 5.25 9.3 9M12 5.25 14.55 9M17.25 5.25 19.8 9"})]}),o.jsx("path",{d:"m10.25 11.45 4 2.55-4 2.55v-5.1Z"})]})}function $ct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 5.25h15.5v10.5H4.25zM8.25 19.75h7.5M12 15.75v4"}),o.jsx("path",{d:"m7.25 12.75 2.35-2.4 2.15 1.65 3.4-3.6 1.6 1.55"}),o.jsx("circle",{cx:"7.25",cy:"8.4",r:".7",fill:"currentColor",stroke:"none"})]})}function Bct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5 7.4c0-1.55 3.13-2.8 7-2.8s7 1.25 7 2.8-3.13 2.8-7 2.8-7-1.25-7-2.8Z"}),o.jsx("path",{d:"M5 7.4v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8V7.4M5 11.95v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8v-4.55"}),o.jsx("path",{d:"M8.2 12.25h.01M8.2 16.8h.01"})]})}function Qct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 4.25h4.5v15.5h-4.5zM8.75 5.75h5v14h-5zM13.75 4.25h4.1v10.25h-4.1z"}),o.jsx("path",{d:"M5.75 7h1.5M10.25 8.25h2M10.25 11h2M15.15 7h1.3"}),o.jsx("circle",{cx:"17.45",cy:"17.35",r:"2.45"}),o.jsx("path",{d:"m19.25 19.15 1.55 1.55"})]})}function Uct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 6.25h6.25c1 0 1.5.55 1.5 1.45v11.05c0-.9-.5-1.45-1.5-1.45H4.25V6.25Z"}),o.jsx("path",{d:"M19.75 9.1v8.2H13.5c-1 0-1.5.55-1.5 1.45V7.7c0-.9.5-1.45 1.5-1.45h2.15"}),o.jsx("path",{d:"m19 3.2.58 1.62 1.62.58-1.62.58L19 7.6l-.58-1.62-1.62-.58 1.62-.58L19 3.2Z",fill:"currentColor",stroke:"none"})]})}function Fct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"m4.2 8.4 1.15 10.2h13.3L19.8 8.4"}),o.jsx("path",{d:"M4.2 8.4h15.6L17.9 5H6.1L4.2 8.4Z"}),o.jsx("path",{d:"M7.2 12.2c1.1-1 2.25 1.25 3.4.25 1.05-.9 2.15 1.3 3.3.25"}),o.jsx("path",{d:"m8.2 15.1 1.45 1.35 1.45-1.35M13.55 16.45h2.35"})]})}function zct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"6",cy:"6.25",r:"2.25"}),o.jsx("circle",{cx:"18",cy:"6.25",r:"2.25"}),o.jsx("circle",{cx:"12",cy:"17.75",r:"2.25"}),o.jsx("path",{d:"m7.7 7.75 2.7 7.55M16.3 7.75l-2.7 7.55M8.25 6.25h7.5"})]})}function QW(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"9",cy:"8",r:"3"}),o.jsx("path",{d:"M3.75 18.75c.45-3.05 2.2-4.65 5.25-4.65s4.8 1.6 5.25 4.65"}),o.jsx("path",{d:"M17.75 4.25v5.5M15 7h5.5M16 13.25h4.25M18.125 11.125v4.25"})]})}function Vct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"4",y:"4.25",width:"16",height:"5",rx:"1.5"}),o.jsx("rect",{x:"4",y:"14.75",width:"16",height:"5",rx:"1.5"}),o.jsx("path",{d:"M7.25 6.75h.01M7.25 17.25h.01M10 6.75h6.5M10 17.25h6.5"})]})}function Hct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3.75h8l4 4v12.5H6V3.75Z"}),o.jsx("path",{d:"M14 3.75v4h4M8.75 11h6.5M8.75 14.25h6.5M8.75 17.5h4"})]})}function qct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.75",y:"4.5",width:"16.5",height:"15",rx:"2.5"}),o.jsx("path",{d:"m7.5 9 2.75 2.5L7.5 14M12.5 14h4"}),o.jsx("path",{d:"M3.75 7.5h16.5",opacity:".62"})]})}function MB(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m6 3.25 4.5 4.75L6 12.75"})})}function Xct({definition:e,label:t,done:n,open:r,onToggle:i}){const s=e.icon,a=t??(n?e.doneLabel:e.runningLabel);return o.jsxs("button",{type:"button",className:`builtin-tool-head${n?" is-done":" is-running"}`,"data-tool-tone":e.tone,onClick:i,"aria-expanded":r,children:[o.jsx("span",{className:"builtin-tool-icon","aria-hidden":"true",children:o.jsx(s,{})}),n?o.jsx("span",{className:"builtin-tool-label",children:a}):o.jsx(wn,{className:"builtin-tool-label",duration:2.4,spread:18,"aria-live":"polite",children:a}),o.jsx(MB,{className:`builtin-tool-chevron${r?" is-open":""}`})]})}function Ul(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function gn(e){return typeof e=="string"?e:""}function UW(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Sc(e){return Array.isArray(e)?e:[]}function SL(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch{return{}}const n=Ul(t)??{};return Ul(n.result)??n}function Qj(e){if(typeof e=="string")try{return Qj(JSON.parse(e))}catch{return e}const t=Ul(e);if(!t)return"";const n=Ul(t.result);return gn(t.error)||gn(t.message)||gn(n==null?void 0:n.error)||gn(n==null?void 0:n.message)}function Gct(e){if(e.kind==="tool")return"tool";if(e.kind==="knowledge_base")return"knowledge_base";const t=Ul(e.metadata),n=gn(t==null?void 0:t.source_type).toLowerCase(),r=gn(e.source).toLowerCase();return n==="skillhub"||r.startsWith("skill_hub:")?"skill_hub":"skill_space"}function Wct(e){return e==="veadk_builtin_tools"?"工具":e==="agentkit_knowledge"?"AgentKit 知识库":e.startsWith("skill_hub:")?`Skill Hub ${e.slice(10)}`:e.startsWith("skill_space:")?`AgentKit 技能中心 ${e.slice(12)}`:e||"未知来源"}function Yct(e){return e==="veadk_builtin_tools"?"tool":e==="agentkit_knowledge"?"knowledge_base":e.startsWith("skill_hub:")?"skill_hub":"skill_space"}function Zct(e){const t=SL(e),n=Ul(t.capabilities)??{},r=Sc(t.resources).flatMap(s=>{const a=Ul(s);if(!a)return[];const l=a.kind==="tool"?"tool":a.kind==="knowledge_base"?"knowledge_base":"skill";return[{ref:gn(a.ref),kind:l,category:Gct(a),name:gn(a.name)||gn(a.ref)||"未命名资源",description:gn(a.description),source:gn(a.source),version:gn(a.version)}]}),i=Sc(t.sources).flatMap(s=>{const a=Ul(s);if(!a)return[];const l=gn(a.source),c=gn(a.status),u=c==="error"?"error":c==="skipped"?"skipped":"ok";return[{source:l,category:Yct(l),label:Wct(l),status:u,count:UW(a.count),message:gn(a.message),searchKeywords:Sc(a.search_keywords).map(gn).filter(Boolean)}]});return{collectionId:gn(t.collection_id),capabilities:{googleAdkVersion:gn(n.google_adk_version),agentTypes:Sc(n.agent_types).map(gn).filter(Boolean),maxOrchestrationDepth:UW(n.max_orchestration_depth)},resources:r,sources:i,counts:{all:r.length,skill_hub:r.filter(s=>s.category==="skill_hub").length,skill_space:r.filter(s=>s.category==="skill_space").length,knowledge_base:r.filter(s=>s.category==="knowledge_base").length,tool:r.filter(s=>s.category==="tool").length}}}function Kct(e,t){return{resources:e.resources.filter(n=>n.category===t),sources:e.sources.filter(n=>n.category===t)}}function Jge(e,t){const n=SL(e),r=SL(t),i=new Map(Sc(r.results).flatMap(u=>{const d=Ul(u),f=gn(d==null?void 0:d.name);return d&&f?[[f,d]]:[]})),s=Sc(n.agents).flatMap(u=>{const d=Ul(u),f=gn(d==null?void 0:d.name);return d&&f?[d]:[]}),a=new Set(s.map(u=>gn(u.name))),l=[...i.entries()].filter(([u])=>!a.has(u)).map(([u])=>({name:u})),c=[...s,...l].map(u=>{const d=gn(u.name),f=Sc(u.nodes).flatMap(E=>{const k=Ul(E);return k?[k]:[]}),h=gn(u.root_node),m=f.find(E=>gn(E.id)===h),g=f.filter(E=>gn(E.id)!==h).map(E=>({id:gn(E.id)||"未命名 Agent",type:gn(E.type)||"llm",description:gn(E.description)})),b=i.get(d),y=gn(b==null?void 0:b.status),O=y==="failed"?"failed":y==="completed"?"completed":"running",v=FW(b==null?void 0:b.resources),x=v.length>0?v:FW(f.flatMap(E=>Sc(E.resources))),w=zW(b==null?void 0:b.python_tools),S=w.length>0?w:zW(f.flatMap(E=>Sc(E.python_tools)));return{name:d,description:gn(b==null?void 0:b.description)||gn(m==null?void 0:m.description)||gn(u.task),task:gn(u.task),rootType:gn(b==null?void 0:b.root_type)||gn(m==null?void 0:m.type)||"llm",nodeCount:f.length,subAgentCount:g.length,resourceCount:x.length,pythonToolCount:S.length,skills:x.filter(E=>E.kind==="skill"),knowledgeBases:x.filter(E=>E.kind==="knowledge_base"),builtinTools:x.filter(E=>E.kind==="tool"),pythonTools:S,subAgents:g,status:O,output:gn(b==null?void 0:b.output),error:gn(b==null?void 0:b.error)}});return{collectionId:gn(r.collection_id)||gn(n.collection_id),agents:c,completedCount:c.filter(u=>u.status==="completed").length,failedCount:c.filter(u=>u.status==="failed").length,runningCount:c.filter(u=>u.status==="running").length}}function Jct(e,t){return!!Qj(t)||Jge(e,t).failedCount>0}function FW(e){const t=new Set;return Sc(e).flatMap(n=>{const r=Ul(n),i=gn(r?r.ref:n);if(!i||t.has(i))return[];t.add(i);const s=gn(r==null?void 0:r.kind),a=s==="tool"||i.startsWith("veadk_tool:")?"tool":s==="knowledge_base"||i.startsWith("agentkit_kb:")?"knowledge_base":"skill",l=i.split(":");return[{ref:i,kind:a,name:gn(r==null?void 0:r.name)||l[l.length-1]||i,description:gn(r==null?void 0:r.description),version:gn(r==null?void 0:r.version),source:gn(r==null?void 0:r.source)}]})}function zW(e){const t=new Set;return Sc(e).flatMap(n=>{const r=Ul(n),i=gn(r==null?void 0:r.name),s=gn(r==null?void 0:r.code),a=`${i}\0${s}`;return!r||!i||t.has(a)?[]:(t.add(a),[{name:i,description:gn(r.description),code:s,entrypoint:gn(r.entrypoint)||i,dependencies:Sc(r.dependencies).map(gn).filter(Boolean)}])})}function eut({branch:e}){return o.jsxs("div",{className:`branch-compare__body${e.status==="running"?" is-streaming":""}`,"aria-live":"polite",children:[e.content?o.jsx(Ou,{text:e.content,streaming:e.status==="running"}):null,e.status==="running"?o.jsx("span",{className:"branch-compare__caret","aria-hidden":"true"}):null,e.error?o.jsx("p",{className:"branch-compare__error",children:e.error}):null]})}function tut({args:e,response:t,status:n,onBranchSelect:r}){const i=p.useMemo(()=>Ele(e,t,n),[e,t,n]),[s,a]=p.useState(0);return o.jsxs("section",{className:"branch-compare","aria-label":"分支对比",children:[o.jsx("div",{className:"branch-compare__tabs",role:"tablist","aria-label":"选择方向",children:i.branches.map((l,c)=>o.jsx("button",{className:`branch-compare__tab${s===c?" is-active":""}`,type:"button",role:"tab","aria-selected":s===c,"aria-controls":`branch-compare-panel-${c}`,onClick:()=>a(c),children:o.jsx(sa,{color:"info",size:"sm",variant:"soft",children:l.label})},`${l.label}:${c}`))}),o.jsx("div",{className:"branch-compare__branches",children:i.branches.map((l,c)=>o.jsxs("article",{className:`branch-compare__branch${s===c?" is-active":""}`,id:`branch-compare-panel-${c}`,role:"tabpanel",children:[o.jsx("header",{className:"branch-compare__head",children:o.jsx(sa,{color:"info",size:"sm",variant:"soft",children:l.label})}),o.jsx(eut,{branch:l}),o.jsx("footer",{className:"branch-compare__footer",children:o.jsx(jt,{type:"button",color:"info",variant:"ghost",size:"sm",pill:!1,disabled:l.status!=="completed",onClick:()=>r==null?void 0:r(l),children:"继续这个方向"})})]},`${l.label}:${c}`))})]})}function e0e({controlled:e,default:t,name:n,state:r="value"}){const{current:i}=p.useRef(e!==void 0),[s,a]=p.useState(t),l=i?e:s,c=p.useCallback(u=>{i||a(u)},[]);return[l,c]}const LB={...r0},VW={};function qg(e,t){const n=p.useRef(VW);return n.current===VW&&(n.current=e(t)),n}const SD=LB.useInsertionEffect,nut=SD&&SD!==LB.useLayoutEffect?SD:e=>e();function Da(e){const t=qg(rut).current;return t.next=e,nut(t.effect),t.trampoline}function rut(){const e={next:void 0,callback:iut,trampoline:(...t)=>{var n;return(n=e.callback)==null?void 0:n.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function iut(){}const sut=()=>{},Jo=typeof document<"u"?p.useLayoutEffect:sut,t0e=p.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function aut(){return p.useContext(t0e)}function out(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,s=Da(i),[,a]=p.useState(!1),l=qg(cut).current,c=qg(lut).current,u=p.useRef(0),d=p.useRef(!0),f=p.useRef([]),h=p.useRef(null),m=Da(()=>{d.current||(d.current=!0,a(S=>!S))}),g=Da((S,E)=>{c.set(S,E),m()}),b=Da(S=>{c.delete(S),m()}),y=Da(S=>{const E=new Map;return n.current.length=0,r&&(r.current.length=0),S.forEach(k=>{var _,T;E.set(k.element,{...k.registration.metadata??{},index:k.index}),n.current[k.index]=k.element,r&&(r.current[k.index]=k.registration.label!==void 0?k.registration.label:((T=(_=k.registration.textRef)==null?void 0:_.current)==null?void 0:T.textContent)??k.element.textContent)}),u.current=n.current.length,E});function O(S){var _;if((_=h.current)==null||_.disconnect(),h.current=null,typeof MutationObserver!="function"||S.length<2)return;const E=new MutationObserver(T=>{if(!fut(T))return;let C=null;for(const A of S)if(A.isConnected){if(C&&n0e(C,A)>0){E.disconnect(),m();return}C=A}});h.current=E;const k=new Set;for(let T=1;TE.observe(T,{childList:!0}))}const v=Da(()=>{const[S,E]=uut(c),k=y(S);O(E),f.current=S,d.current=!1,l.forEach(_=>_(k)),s(k)});Jo(()=>(d.current||y(f.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,y]),Jo(()=>{d.current&&v()}),Jo(()=>()=>{var S;(S=h.current)==null||S.disconnect(),d.current=!0},[]);const x=Da(S=>(l.add(S),()=>{l.delete(S)})),w=p.useMemo(()=>({register:g,unregister:b,subscribeMapChange:x,nextIndexRef:u}),[g,b,x,u]);return o.jsx(t0e.Provider,{value:w,children:t})}function lut(){return new Map}function cut(){return new Set}function uut(e){const t=new Set,n=[],r=[];e.forEach((s,a)=>{if(!a.isConnected)return;const l=s.index,c={index:l??-1,element:a,registration:s};l===null?r.push(c):l>=0&&(t.add(l),n.push(c))});let i=0;return r.sort((s,a)=>n0e(s.element,a.element)),r.forEach(s=>{for(;t.has(i);)i+=1;s.index=i,n.push(s),i+=1}),t.size>0&&n.sort((s,a)=>s.index-a.index),[n,r.map(s=>s.element)]}function dut(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function fut(e){for(const t of e)for(let n=0;ns.searchParams.append("args[]",a)),`${t} error #${r}; visit ${s} for the full message.`}}const jE=hut("https://base-ui.com/production-error","Base UI"),r0e=p.createContext(void 0);function i0e(){const e=p.useContext(r0e);if(e===void 0)throw new Error(jE(10));return e}function aA(e,t,n,r){const i=qg(s0e).current;return mut(i,e,t,n,r)&&a0e(i,[e,t,n,r]),i.callback}function put(e){const t=qg(s0e).current;return gut(t,e)&&a0e(t,e),t.callback}function s0e(){return{callback:null,cleanup:null,refs:[]}}function mut(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function gut(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function a0e(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let i=0;i{for(let i=0;i=e}function HW(e){if(!p.isValidElement(e))return null;const t=e,n=t.props;return(yut(19)?n==null?void 0:n.ref:t.ref)??null}function EL(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}const Out=Object.freeze([]),Xb=Object.freeze({});function xut(e,t){const n={};for(const r in e){const i=e[r];if(t!=null&&t.hasOwnProperty(r)){const s=t[r](i);s!=null&&Object.assign(n,s);continue}i===!0?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function vut(e,t){return typeof e=="function"?e(t):e}function o0e(e,t){return typeof e=="function"?e(t):e}const $B={};function BB(e,t,n,r,i){if(!n&&!r&&!e)return oA(t);let s=oA(e);return t&&(s=dT(s,t)),n&&(s=dT(s,n)),r&&(s=dT(s,r)),s}function wut(e){if(e.length===0)return $B;if(e.length===1)return oA(e[0]);let t=oA(e[0]);for(let n=1;n=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function QB(e){return typeof e=="function"}function c0e(e,t){return QB(e)?e(t):e??$B}function kut(e,t){return t?e?(...n)=>{const r=n[0];if(f0e(r)){const s=r;lA(s);const a=t(...n);return s.baseUIHandlerPrevented||e==null||e(...n),a}const i=t(...n);return e==null||e(...n),i}:u0e(t):e}function u0e(e){return e&&((...t)=>{const n=t[0];return f0e(n)&&lA(n),e(...t)})}function lA(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function d0e(e,t){return t?e?t+" "+e:t:e}function f0e(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function RE(e,t,n={}){const r=t.render,i=_ut(t,n);if(n.enabled===!1)return null;const s=n.state??Xb;return Aut(e,r,i,s)}function _ut(e,t={}){const{className:n,style:r,render:i}=e,{state:s=Xb,ref:a,props:l,stateAttributesMapping:c,enabled:u=!0}=t,d=u?vut(n,s):void 0,f=u?o0e(r,s):void 0,h=u?xut(s,c):Xb,m=u&&l?Tut(l):void 0,g=u?EL(h,m)??{}:Xb;return typeof document<"u"&&(u?Array.isArray(a)?g.ref=put([g.ref,HW(i),...a]):g.ref=aA(g.ref,HW(i),a):aA(null,null)),u?(d!==void 0&&(g.className=d0e(g.className,d)),f!==void 0&&(g.style=EL(g.style,f)),g):Xb}function Tut(e){return Array.isArray(e)?wut(e):BB(void 0,e)}const Cut=Symbol.for("react.lazy");function Aut(e,t,n,r){if(t){if(typeof t=="function")return t(n,r);const i=BB(n,t.props);i.ref=n.ref;let s=t;return(s==null?void 0:s.$$typeof)===Cut&&(s=p.Children.toArray(t)[0]),p.cloneElement(s,i)}if(e&&typeof e=="string")return Nut(e,n);throw new Error(jE(8))}function Nut(e,t){return e==="button"?p.createElement("button",{type:"button",...t,key:t.key}):e==="img"?p.createElement("img",{alt:"",...t,key:t.key}):p.createElement(e,t)}const jut={value:()=>null},h0e=p.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,hiddenUntilFound:a,keepMounted:l,loopFocus:c,onValueChange:u,multiple:d=!1,orientation:f="vertical",value:h,defaultValue:m,style:g,...b}=t,y=p.useMemo(()=>{if(h===void 0)return m??[]},[h,m]),O=p.useRef([]),[v,x]=e0e({controlled:h,default:y,name:"Accordion",state:"value"}),w=Da((_,T,C)=>{if(d)if(T){const A=v.slice();if(A.push(_),u==null||u(A,C),C.isCanceled)return;x(A)}else{const A=v.filter(R=>R!==_);if(u==null||u(A,C),C.isCanceled)return;x(A)}else{const A=v[0]===_?[]:[_];if(u==null||u(A,C),C.isCanceled)return;x(A)}}),S=p.useMemo(()=>({value:v,disabled:s,orientation:f}),[v,s,f]),E=p.useMemo(()=>({disabled:s,handleValueChange:w,hiddenUntilFound:a??!1,keepMounted:l??!1,state:S,value:v}),[s,w,a,l,S,v]),k=RE("div",t,{state:S,ref:n,props:b,stateAttributesMapping:jut});return o.jsx(r0e.Provider,{value:E,children:o.jsx(out,{elementsRef:O,children:k})})});let qW=0;function Rut(e,t="mui"){const[n,r]=p.useState(e),i=e||n;return p.useEffect(()=>{n==null&&(qW+=1,r(`${t}-${qW}`))},[n,t]),i}const XW=LB.useId;function Iut(e,t){if(XW!==void 0){const n=XW();return`${t}-${n}`}return Rut(e,t)}function kL(e){return Iut(e,"base-ui")}const Dut="none",Put="trigger-press";function p0e(e,t,n,r){let i=!1,s=!1;const a=Xb;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){s=!0},get isCanceled(){return i},get isPropagationAllowed(){return s},trigger:n,...a}}function Mut(e){p.useEffect(e,Out)}const N2=null;let Lut=class{constructor(){wr(this,"callbacks",[]);wr(this,"callbacksCount",0);wr(this,"nextId",1);wr(this,"startId",1);wr(this,"isScheduled",!1);wr(this,"tick",t=>{var i;this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}},j2=new Lut;class Cl{constructor(){wr(this,"currentId",N2);wr(this,"cancel",()=>{this.currentId!==N2&&(j2.cancel(this.currentId),this.currentId=N2)});wr(this,"disposeEffect",()=>this.cancel)}static create(){return new Cl}static request(t){return j2.request(t)}static cancel(t){return j2.cancel(t)}request(t){this.cancel(),this.currentId=j2.request(()=>{this.currentId=N2,t()})}}function $ut(){const e=qg(Cl.create).current;return Mut(e.disposeEffect),e}function But(e,t=!1,n=!1){const[r,i]=p.useState(e&&t?"idle":void 0),[s,a]=p.useState(e);return e&&!s&&(a(!0),i("starting")),!e&&s&&r!=="ending"&&!n&&i("ending"),!e&&!s&&r==="ending"&&i(void 0),Jo(()=>{if(!e&&s&&r!=="ending"&&n){const l=Cl.request(()=>{i("ending")});return()=>{Cl.cancel(l)}}},[e,s,r,n]),Jo(()=>{if(!e||t)return;const l=Cl.request(()=>{i(void 0)});return()=>{Cl.cancel(l)}},[t,e]),Jo(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&i("starting");const l=Cl.request(()=>{i("idle")});return()=>{Cl.cancel(l)}},[t,e,s,r]),{mounted:s,setMounted:a,transitionStatus:r}}function Qut(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,[s,a]=e0e({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=But(s,!0,!0),d=kL(),[f,h]=p.useState(),m=f===null?void 0:f??d,g=Da(b=>{const y=!s,O=p0e(Put,b.nativeEvent);r(y,O),!O.isCanceled&&a(y)});return p.useMemo(()=>({defaultPanelId:d,disabled:i,handleTrigger:g,mounted:l,open:s,panelId:m,setMounted:c,setOpen:a,setPanelIdState:h,transitionStatus:u}),[d,i,g,l,s,m,c,a,h,u])}const m0e=p.createContext(void 0);function g0e(){const e=p.useContext(m0e);if(e===void 0)throw new Error(jE(15));return e}function Uut(e={}){const{guess:t,label:n,metadata:r,textRef:i,index:s}=e,{register:a,unregister:l,subscribeMapChange:c,nextIndexRef:u}=aut(),d=p.useRef(-1),[f,h]=p.useState(s==null&&t?()=>{if(d.current===-1){const y=u.current;u.current+=1,d.current=y}return d.current}:-1),m=s??f,g=p.useRef(null),b=p.useCallback(y=>{const O=g.current;O&&l(O),g.current=y,y&&a(y,{metadata:r??null,index:s??null,label:n,textRef:i})},[s,a,l,r,n,i]);return Jo(()=>{if(s==null)return c(y=>{var v;const O=g.current?(v=y.get(g.current))==null?void 0:v.index:null;O!=null&&h(O)})},[s,c]),{ref:b,index:m}}const b0e=p.createContext(void 0);function UB(){const e=p.useContext(b0e);if(e===void 0)throw new Error(jE(9));return e}let GW=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const Fut={"data-starting-style":""},zut={"data-ending-style":""},Vut={transitionStatus(e){return e==="starting"?Fut:e==="ending"?zut:null}};let FB=function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=GW.startingStyle]="startingStyle",e[e.endingStyle=GW.endingStyle]="endingStyle",e}({}),Hut=function(e){return e.panelOpen="data-panel-open",e}({});const qut={[FB.open]:""},Xut={[FB.closed]:""},Gut={open(e){return e?{[Hut.panelOpen]:""}:null}},Wut={open(e){return e?qut:Xut}};let Yut=function(e){return e.index="data-index",e.disabled="data-disabled",e.open="data-open",e}({});const zB={...Wut,index:e=>({[Yut.index]:String(e)}),...Vut,value:()=>null},y0e=p.forwardRef(function(t,n){const{className:r,disabled:i=!1,onOpenChange:s,render:a,value:l,style:c,...u}=t,{ref:d,index:f}=Uut(),h=aA(n,d),{disabled:m,handleValueChange:g,state:b,value:y}=i0e(),O=kL(),v=l??O,x=i||m,w=y.indexOf(v)!==-1,S=Da((N,j)=>{s==null||s(N,j),!j.isCanceled&&g(v,N,j)}),E=Qut({open:w,onOpenChange:S,disabled:x}),k=p.useMemo(()=>({open:E.open,disabled:E.disabled,transitionStatus:E.transitionStatus}),[E.open,E.disabled,E.transitionStatus]),_=p.useMemo(()=>({...E,onOpenChange:S,state:k}),[E,k,S]),T=p.useMemo(()=>({...b,hidden:!w&&!E.mounted,index:f,disabled:x,open:w}),[E.mounted,x,f,w,b]),C=kL(),[A,R]=p.useState(),M=A===null?void 0:A??C,I=p.useMemo(()=>({defaultTriggerId:C,open:w,state:T,setTriggerId:R,triggerId:M}),[C,w,T,R,M]),$=RE("div",t,{state:T,ref:h,props:u,stateAttributesMapping:zB});return o.jsx(m0e.Provider,{value:_,children:o.jsx(b0e.Provider,{value:I,children:$})})}),O0e=p.forwardRef(function(t,n){const{render:r,className:i,style:s,...a}=t,{state:l}=UB();return RE("h3",t,{state:l,ref:n,props:a,stateAttributesMapping:zB})}),Zut=p.createContext(void 0);function Kut(e=!1){const t=p.useContext(Zut);if(t===void 0&&!e)throw new Error(jE(16));return t}function Jut(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:s}=e,a=r&&t!==!1,l=r&&t===!1;return{props:p.useMemo(()=>{const u={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(u.tabIndex=i,!s&&n&&(u.tabIndex=t?i:-1)),(s&&(t||a)||!s&&n)&&(u["aria-disabled"]=n),s&&(!t||l)&&(u.disabled=n),u},[r,n,t,a,l,s,i])}}function ED(e,t,{detail:n=0}={}){e.dispatchEvent(new(Ka(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function edt(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:s}=e,a=p.useRef(null),l=Kut(!0),c=s??l!==void 0,{props:u}=Jut({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),d=p.useCallback(()=>{const m=a.current;kD(m)&&c&&t&&u.disabled===void 0&&m.disabled&&(m.disabled=!1)},[t,u.disabled,c]);Jo(d,[d]);const f=p.useCallback((m={})=>{const{onClick:g,onMouseDown:b,onKeyUp:y,onKeyDown:O,onPointerDown:v,...x}=m;return BB({onClick(w){if(t){w.preventDefault();return}g==null||g(w)},onMouseDown(w){t||b==null||b(w)},onKeyDown(w){if(t||(lA(w),O==null||O(w),w.baseUIHandlerPrevented))return;const S=w.target===w.currentTarget,E=w.currentTarget,k=kD(E),_=!i&&tdt(E),T=S&&(i?k:!_),C=w.key==="Enter",A=w.key===" ",R=E.getAttribute("role"),M=(R==null?void 0:R.startsWith("menuitem"))||R==="option"||R==="gridcell";if(S&&c&&A){if(w.defaultPrevented&&M)return;w.preventDefault(),(!i||k)&&(w.preventBaseUIHandler(),ED(E,w));return}if(!T||i||!A&&!C){S&&_&&A&&w.preventDefault();return}w.defaultPrevented||(w.preventDefault(),C&&(w.preventBaseUIHandler(),ED(E,w)))},onKeyUp(w){if(!t){if(lA(w),y==null||y(w),w.target===w.currentTarget&&i&&c&&kD(w.currentTarget)&&w.key===" "){w.preventDefault();return}w.baseUIHandlerPrevented||w.target===w.currentTarget&&!i&&!c&&!w.defaultPrevented&&w.key===" "&&(w.preventBaseUIHandler(),ED(w.currentTarget,w))}},onPointerDown(w){if(t){w.preventDefault();return}v==null||v(w)}},i?{type:"button"}:{role:"button"},u,x)},[t,u,c,i]),h=Da(m=>{a.current=m,d()});return{getButtonProps:f,buttonRef:h}}function kD(e){return _d(e)&&e.tagName==="BUTTON"}function tdt(e){return _d(e)&&e.tagName==="A"&&!!e.href}const x0e=p.forwardRef(function(t,n){const{disabled:r,className:i,id:s,render:a,nativeButton:l=!0,style:c,...u}=t,{panelId:d,open:f,handleTrigger:h,disabled:m}=g0e(),g=r||m,{getButtonProps:b,buttonRef:y}=edt({disabled:g,focusableWhenDisabled:!0,native:l}),{defaultTriggerId:O,state:v,setTriggerId:x}=UB(),w=s||void 0,S=w??O;return Jo(()=>(x(_=>w??(_===null?void 0:_)),()=>{x(_=>_===w?null:_)}),[w,x]),RE("button",t,{state:v,ref:[n,y],props:[{"aria-controls":f?d:void 0,"aria-expanded":f,id:S,onClick:h},u,b],stateAttributesMapping:Gut})});function ndt(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function rdt(e){const t=qg(idt,e).current;return t.next=e,Jo(t.effect),t}function idt(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function sdt(e){return e==null?e:"current"in e?e.current:e}function v0e(e,t=!1){const n=$ut();return Da((r,i=null)=>{n.cancel();const s=sdt(e);if(s==null)return;const a=s,l=()=>{kr.flushSync(r)};if(typeof a.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){r();return}function c(){Promise.all(a.getAnimations().map(u=>u.finished)).then(()=>{i!=null&&i.aborted||l()},()=>{if(i!=null&&i.aborted)return;if(a.getAnimations().some(d=>d.pending||d.playState!=="finished")){c();return}l()})}if(t){const u="data-starting-style";if(!a.hasAttribute(u)){n.request(c);return}const d=new MutationObserver(()=>{a.hasAttribute(u)||(d.disconnect(),c())});d.observe(a,{attributes:!0,attributeFilter:[u]}),i==null||i.addEventListener("abort",()=>d.disconnect(),{once:!0});return}n.request(c)})}function adt(e){const{enabled:t=!0,open:n,ref:r,onComplete:i}=e,s=Da(i),a=v0e(r,n);p.useEffect(()=>{if(!t)return;const l=new AbortController;return a(s,l.signal),()=>{l.abort()}},[t,n,s,a])}const dx={height:void 0,width:void 0};function odt(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:s,onOpenChange:a,open:l,setMounted:c,setOpen:u,transitionStatus:d}=e,f=p.useRef(null),h=p.useRef(null),[m,g]=p.useState(dx),b=p.useRef(dx),y=p.useRef(!1),O=p.useRef(l),v=p.useRef(!1),[x,w]=p.useState(!1),S=p.useRef(null),E=aA(t,f),k=rdt(l),_=v0e(f),T=!l&&!s,C=x?"idle":d,A=l&&(O.current||v.current),R=!l&&s&&h.current==="css-animation"&&m.height===void 0&&m.width===void 0?b.current:m,M=n&&T&&h.current!=="css-animation",I=Da((F,L=!0)=>{L&&(b.current=F),g(F)}),$=Da(()=>{var F;(F=S.current)==null||F.call(S),S.current=null}),N=Da(F=>{$(),S.current=()=>{S.current=null,F()}}),j=Da(()=>{l&&s&&h.current==="css-animation"&&(v.current=!0)});Jo(()=>{!x||d==="starting"||w(!1)},[x,d]),p.useEffect(()=>()=>{j(),$()},[j,$]),Jo(()=>{const F=f.current;if(!F)return;!l&&S.current&&$();const L=ldt(F,A);if(h.current=L,l&&d==="idle"&&O.current&&L==="css-animation"){b.current=J0(F);return}if(l&&d==="starting"){const Q=y.current;if(y.current=!1,L==="none"){I(J0(F)),w(!0);return}if(L==="css-transition"){const se=cdt(F);if(I(J0(F)),!Q)return se;const ge=R2(F,"transition-duration","0s");return N(ge),w(!0),se}I(J0(F));const V=R2(F,"animation-name","none");if(!Q){V();return}const K=R2(F,"animation-duration","0s");V(),N(K),w(!0);return}if(!l&&s&&(d==="idle"||d==="starting")){if(O.current=!1,v.current=!1,L==="none"){I(dx,!1),c(!1);return}I(J0(F));return}if(d!=="ending")return;if(L==="none"){c(!1);return}const H=J0(F);if(!(H.height>0||H.width>0)){c(!1);return}I(H),L==="css-animation"&&R2(F,"animation-name","none")()},[s,l,$,I,c,N,A,d]),adt({enabled:l&&s&&C==="idle",open:!0,ref:f,onComplete(){l&&I(dx,!1)}}),p.useEffect(()=>{if(l||!s||C!=="ending"||!f.current)return;const L=new AbortController;let H=-1;function z(){k.current||(c(!1),I(dx,!1))}return H=Cl.request(()=>{_(z,L.signal)}),()=>{Cl.cancel(H),L.abort()}},[k,s,l,C,_,I,c]),Jo(()=>{const F=f.current;!F||!n||!T||F.setAttribute("hidden","until-found")},[T,n]),p.useEffect(function(){const L=f.current;if(!L)return;function H(z){const Q=p0e(Dut,z);a(!0,Q),!Q.isCanceled&&(y.current=!0,u(!0))}return ndt(L,"beforematch",H)},[a,u]);const B=i||n||s||l;return{height:R.height,props:{...M?{[FB.startingStyle]:""}:void 0,hidden:T,id:r},ref:E,shouldPreventOpenAnimation:A,shouldRender:B,transitionStatus:C,width:R.width}}function J0(e){return{height:e.scrollHeight,width:e.scrollWidth}}function ldt(e,t){const n=Ka(e).getComputedStyle(e),r=(n.animationName.split(",").map(s=>s.trim()).some(s=>s!==""&&s!=="none")||t)&&WW(n.animationDuration),i=WW(n.transitionDuration);return r&&i||i?"css-transition":r?"css-animation":"none"}function WW(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function R2(e,t,n){const r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function cdt(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(i=>{e.style.setProperty(i,"initial","important")});function n(){Object.entries(t).forEach(([i,s])=>{if(s===""){e.style.removeProperty(i);return}e.style.setProperty(i,s)})}const r=Cl.request(n);return()=>{Cl.cancel(r),n()}}let YW=function(e){return e.accordionPanelHeight="--accordion-panel-height",e.accordionPanelWidth="--accordion-panel-width",e}({});const w0e=p.forwardRef(function(t,n){const{className:r,hiddenUntilFound:i,keepMounted:s,id:a,render:l,style:c,...u}=t,{hiddenUntilFound:d,keepMounted:f}=i0e(),{defaultPanelId:h,mounted:m,onOpenChange:g,open:b,setMounted:y,setOpen:O,setPanelIdState:v,transitionStatus:x}=g0e(),w=i??d,S=s??f,E=a||void 0,k=a??h;Jo(()=>(v(L=>E??(L===null?void 0:L)),()=>{v(L=>L===E?null:L)}),[E,v]);const{height:_,props:T,ref:C,shouldPreventOpenAnimation:A,shouldRender:R,transitionStatus:M,width:I}=odt({externalRef:n,hiddenUntilFound:w,id:k,keepMounted:S,mounted:m,onOpenChange:g,open:b,setMounted:y,setOpen:O,transitionStatus:x}),{state:$,triggerId:N}=UB(),j={...$,transitionStatus:M},B=o0e(c,j),F=RE("div",{...t,style:void 0},{state:j,ref:C,props:[T,{"aria-labelledby":N,role:"region",style:{[YW.accordionPanelHeight]:_===void 0?"auto":`${_}px`,[YW.accordionPanelWidth]:I===void 0?"auto":`${I}px`}},u,B?{style:B}:void 0,A?{style:{animationName:"none"}}:void 0],stateAttributesMapping:zB});return R?F:null}),udt=(e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=ddt(r,n.getBoundingClientRect()),s=fdt(r,i),a=hdt(t.getBoundingClientRect());return mdt([...s,...a])};function ddt(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function fdt(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function hdt(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function pdt(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;sr!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(i=!i)}return i}function mdt(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),gdt(t)}function gdt(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}const bdt="_Transition_1wdpp_1",ydt="_Popover_1wdpp_3",S0e={Transition:bdt,Popover:ydt},E0e=p.createContext(null),Uj=()=>{const e=p.use(E0e);if(!e)throw new Error("Popover components must be wrapped in ");return e},Rp=({open:e,onOpenChange:t,showOnHover:n=!1,hoverOpenDelay:r=150,children:i})=>{const[s,a]=p.useState(!1),[l,c]=p.useState(!1),u=p.useRef(null),d=p.useRef(null),f=p.useRef(void 0),h=p.useRef(!1),m=p.useRef(!1),g=e??s,[b,y]=p.useState(!1);T9(()=>y(!1),b?500:null);const O=Gp(t),v=Gp(k=>{var _,T;clearTimeout(f.current),g!==k&&(k||(c(!1),n&&h.current&&((_=u.current)==null||_.focus()),h.current=!1),(T=O.current)==null||T.call(O,k),a(k),n&&y(k))}),x=p.useCallback(k=>{v.current(k)},[v]),w=p.useCallback(()=>{f.current=setTimeout(()=>x(!0),r)},[x,r]),S=p.useCallback(()=>{clearTimeout(f.current)},[]);p.useEffect(()=>()=>{clearTimeout(f.current)},[]);const E=p.useMemo(()=>({open:g,setOpen:x,shake:l,setShake:c,showOnHover:n,temporarilyPreventClickToClose:b,onTriggerEnter:w,onTriggerLeave:S,isPointerInTransitRef:m,triggerRef:u,contentRef:d,hoverOpenFocusedWithTab:h}),[g,x,l,c,n,b,h,m,w,S]);return o.jsx(E0e,{value:E,children:o.jsx(mue,{open:g,onOpenChange:x,modal:!1,children:i})})},Odt=({children:e,onPointerDown:t,onClick:n})=>{const{setOpen:r,showOnHover:i,temporarilyPreventClickToClose:s,onTriggerEnter:a,onTriggerLeave:l,isPointerInTransitRef:c,triggerRef:u,contentRef:d}=Uj(),f=p.useRef(!1),h=b=>{!(b.currentTarget.nodeName.toLocaleLowerCase()==="a")&&s&&(b.preventDefault(),b.stopPropagation())},m=b=>{b.pointerType!=="touch"&&!f.current&&!c.current&&(a(),f.current=!0)},g=()=>{f.current&&(l(),f.current=!1)};return o.jsx(gue,{asChild:!0,ref:u,onPointerDown:b=>{h(b),t==null||t(b)},onClick:b=>{h(b),n==null||n(b)},onPointerMove:i?m:void 0,onPointerLeave:i?g:void 0,onFocus:i?()=>r(!0):void 0,onBlur:i?()=>{setTimeout(()=>{var b;(b=d.current)!=null&&b.contains(document.activeElement)||r(!1)},50)}:void 0,children:e})},k0e=({children:e,avoidCollisions:t,width:n,minWidth:r,maxWidth:i,side:s,sideOffset:a=8,align:l,alignOffset:c,translucent:u,className:d,autoFocus:f=!0})=>{const{showOnHover:h,shake:m,contentRef:g}=Uj(),b=y=>{const O=g.current;if(O&&y.target===O&&y.key==="Tab"&&y.shiftKey){y.preventDefault(),y.stopPropagation();const v=Nle(O),x=v[v.length-1];x==null||x.focus()}};return p.useEffect(()=>{const y=g.current;!y||!f||y!=null&&y.contains(document.activeElement)||h||y.focus({preventScroll:!0})},[g,h,f]),o.jsx(yue,{forceMount:!0,ref:g,className:sr(S0e.Popover,d),style:d0({"popover-width":n,"popover-min-width":r,"popover-max-width":i}),onCloseAutoFocus:h?Mf:void 0,"data-animate":m?"shake":void 0,"data-translucent":u?"true":void 0,side:s,sideOffset:a,align:l,alignOffset:c??(l==="center"?0:-5),avoidCollisions:t??!0,hideWhenDetached:!0,collisionPadding:20,onOpenAutoFocus:Mf,onEscapeKeyDown:Mf,onKeyDown:b,children:e})},xdt=e=>{const{setOpen:t,triggerRef:n,contentRef:r,isPointerInTransitRef:i,hoverOpenFocusedWithTab:s}=Uj(),[a,l]=p.useState(null),c=p.useCallback(()=>{l(null),i.current=!1},[i]),u=p.useCallback((d,f)=>{const h=udt(d,f);l(h),i.current=!0},[i]);return p.useEffect(()=>()=>c(),[c]),p.useEffect(()=>{const d=n.current,f=r.current;if(!d||!f)return;const h=g=>u(g,f),m=g=>u(g,d);return d.addEventListener("pointerleave",h),f.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",h),f.removeEventListener("pointerleave",m)}},[r,n,u,c]),p.useEffect(()=>{if(!a)return;const d=f=>{const h=n.current,m=r.current,g=f.target,b={x:f.clientX,y:f.clientY},y=(h==null?void 0:h.contains(g))||(m==null?void 0:m.contains(g)),O=!pdt(b,a),v=g.hasAttribute("aria-haspopup");y?c():(O||v)&&(c(),t(!1))};return document.addEventListener("pointermove",d),()=>document.removeEventListener("pointermove",d)},[a,t,c,n,r]),p.useEffect(()=>{const d=f=>{if(r.current&&f.key==="Tab"&&!f.shiftKey){const[h]=Nle(r.current);h&&(f.preventDefault(),h.focus(),s.current=!0,document.removeEventListener("keydown",d))}};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r,s]),o.jsx(k0e,{...e})},vdt=e=>{const{open:t,showOnHover:n,setOpen:r}=Uj();return iE(t,()=>{r(!1)}),o.jsx(bue,{forceMount:!0,children:o.jsx(nO,{enterDuration:600,exitDuration:300,className:S0e.Transition,disableAnimations:!0,children:t&&(n?o.jsx(xdt,{...e},"popover-hover"):o.jsx(k0e,{...e},"popover"))})})};Rp.Trigger=Odt;Rp.Content=vdt;const wdt=[{value:"skill_hub",label:"Skill Hub"},{value:"skill_space",label:"AgentKit 技能中心"},{value:"knowledge_base",label:"知识库"},{value:"tool",label:"工具"}],_0e={llm:"LLM Agent",sequential:"顺序 Agent",parallel:"并行 Agent",loop:"循环 Agent",workflow:"Workflow"};function T0e(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m4 6 4 4 4-4"})})}function C0e({label:e}){return o.jsx("div",{className:"create-agent-card__loading",role:"status","aria-label":e,children:[0,1,2].map(t=>o.jsxs("div",{className:"create-agent-card__skeleton-row","aria-hidden":"true",children:[o.jsx("span",{}),o.jsx("span",{})]},t))})}function Sdt(e){return e.kind==="tool"?"内置工具":e.kind==="knowledge_base"?"知识库":e.source.startsWith("skill_hub:")?"Skill Hub":e.source.startsWith("skill_space:")?"AgentKit 技能中心":"Skill"}function _D({label:e,resources:t}){return t.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:e}),o.jsx("div",{className:"create-agent-card__popover-list",children:t.map(n=>o.jsxs("div",{className:"create-agent-card__popover-item",children:[o.jsxs("div",{className:"create-agent-card__popover-item-heading",children:[o.jsx("strong",{children:n.name}),o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:Sdt(n)})]}),n.description?o.jsx("p",{children:n.description}):null]},n.ref))})]})}function Edt({tools:e}){return e.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:"自写工具"}),o.jsx(h0e,{children:e.map((t,n)=>o.jsxs(y0e,{className:"create-agent-card__python-tool",value:`${t.name}:${n}`,children:[o.jsx(O0e,{className:"create-agent-card__python-tool-header",children:o.jsxs(x0e,{className:"create-agent-card__python-tool-trigger",children:[o.jsxs("span",{children:[o.jsx("strong",{children:t.name}),t.description?o.jsx("small",{children:t.description}):null]}),o.jsxs("span",{className:"create-agent-card__python-tool-meta",children:[o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:"自写工具"}),o.jsx(T0e,{className:"create-agent-card__python-tool-chevron"})]})]})}),o.jsxs(w0e,{className:"create-agent-card__python-tool-panel",children:[t.dependencies.length>0?o.jsxs("div",{className:"create-agent-card__python-tool-dependencies",children:["依赖:",t.dependencies.join(", ")]}):null,o.jsx("pre",{tabIndex:0,"aria-label":`${t.name} 完整代码`,children:o.jsx("code",{children:t.code})})]})]},`${t.name}:${n}`))})]})}function kdt({agents:e}){return e.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:"Sub Agent"}),o.jsx("div",{className:"create-agent-card__popover-list",children:e.map(t=>o.jsxs("div",{className:"create-agent-card__popover-item",children:[o.jsxs("div",{className:"create-agent-card__popover-item-heading",children:[o.jsx("strong",{children:t.id}),o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:_0e[t.type]??t.type})]}),t.description?o.jsx("p",{children:t.description}):null]},t.id))})]})}function I2({label:e,count:t,icon:n,children:r}){const i=o.jsxs("button",{className:"create-agent-card__resource-metric",type:"button",disabled:t===0,"aria-label":`${e} ${t} 项`,children:[n,o.jsx("span",{children:t})]});return t===0?i:o.jsxs(Rp,{showOnHover:!0,hoverOpenDelay:120,children:[o.jsx(Rp.Trigger,{children:i}),o.jsx(Rp.Content,{side:"top",align:"start",minWidth:"auto",maxWidth:360,className:"create-agent-card__resource-popover",children:r})]})}function _dt({response:e,status:t}){const n=p.useMemo(()=>Zct(e),[e]),r=p.useMemo(()=>wdt.map(a=>{const l=Kct(n,a.value);return{...a,...l,searchKeywords:[...new Set(l.sources.flatMap(c=>c.searchKeywords))]}}),[n]),i=t==="failed",s=i?Qj(e):"";return o.jsx("section",{className:"create-agent-tool-card","aria-label":"召回资源信息",children:t==="running"?o.jsx(C0e,{label:"正在检索资源"}):i?o.jsxs("div",{className:"create-agent-card__message is-error",role:"alert",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"资源检索未完成"}),o.jsx("span",{children:s||"请检查资源服务配置后重试。"})]}):o.jsx(h0e,{className:"create-agent-card__accordion",children:r.map(a=>o.jsxs(y0e,{className:"create-agent-card__accordion-item",value:a.value,children:[o.jsx(O0e,{className:"create-agent-card__accordion-header",children:o.jsxs(x0e,{className:"create-agent-card__accordion-trigger",children:[o.jsx("span",{children:a.label}),o.jsxs("span",{className:"create-agent-card__accordion-meta",children:[o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:a.sources.length===0?a.value==="skill_hub"?"未检索":"未配置":a.resources.length}),o.jsx(T0e,{className:"create-agent-card__accordion-chevron"})]})]})}),o.jsx(w0e,{className:"create-agent-card__accordion-content",children:o.jsxs("div",{className:"create-agent-card__accordion-scroll",role:"region","aria-label":`${a.label}资源列表`,tabIndex:0,children:[a.value==="skill_hub"&&a.searchKeywords.length>0?o.jsxs("div",{className:"create-agent-card__search-keywords",children:[o.jsx("span",{children:"检索关键词"}),o.jsx("span",{children:a.searchKeywords.join("、")})]}):null,a.resources.length>0?o.jsx("div",{className:"create-agent-card__resource-list",children:a.resources.map(l=>o.jsx("div",{className:"create-agent-card__resource",children:o.jsxs("div",{className:"create-agent-card__resource-main",children:[o.jsxs("div",{className:"create-agent-card__resource-title",children:[o.jsx("span",{className:"create-agent-card__resource-name",children:l.name}),l.version?o.jsx(sa,{className:"create-agent-card__resource-version",color:"secondary",size:"sm",variant:"soft",children:l.version}):null]}),l.description?o.jsx("p",{children:l.description}):null]})},l.ref))}):o.jsxs("div",{className:"create-agent-card__empty-category",children:[o.jsx("p",{children:a.sources.length===0?a.value==="skill_hub"?"未提供检索关键词,本次未检索 Skill Hub。":`未配置 ${a.label},本次未检索该来源。`:"本次检索未返回该类别的资源。"}),a.sources.filter(l=>l.message).map(l=>o.jsx("p",{className:"create-agent-card__raw-source-error",children:l.message},l.source))]})]})})]},a.value))},n.collectionId||"collected-resources")})}function Tdt({args:e,response:t,status:n}){const r=p.useMemo(()=>Jge(e,t),[e,t]),i=n==="failed"?Qj(t):"";return o.jsxs("section",{className:"create-agent-tool-card is-agent-results","aria-label":"创建 Agent 结果",children:[i?o.jsxs("div",{className:"create-agent-card__message is-error",role:"alert",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"Agent 创建未完成"}),o.jsx("span",{children:i})]}):null,r.agents.length>0?o.jsx("div",{className:"create-agent-card__agent-grid",children:r.agents.map(s=>{const a=n==="failed"?"failed":s.status,l=s.error||a==="failed"&&i,c=s.builtinTools.length+s.pythonTools.length;return o.jsxs(Z7,{className:`create-agent-card__agent-card${l?" is-error":""}`,children:[o.jsx(K7,{leading:o.jsx(u1,{seed:s.name}),title:s.name,titleText:s.name,status:o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:_0e[s.rootType]??s.rootType})}),s.description?o.jsx(J7,{children:s.description}):null,l?o.jsx("div",{className:"create-agent-card__agent-result is-error",role:"alert",children:l}):null,o.jsxs("div",{className:"create-agent-card__agent-resources","aria-label":`${s.name} 具备的资源`,children:[o.jsx(I2,{label:"Skill",count:s.skills.length,icon:o.jsx(Q_,{"aria-hidden":"true"}),children:o.jsx(_D,{label:"Skill",resources:s.skills})}),o.jsx(I2,{label:"知识库",count:s.knowledgeBases.length,icon:o.jsx(que,{"aria-hidden":"true"}),children:o.jsx(_D,{label:"知识库",resources:s.knowledgeBases})}),o.jsxs(I2,{label:"工具",count:c,icon:o.jsx(TRe,{"aria-hidden":"true"}),children:[o.jsx(_D,{label:"内置工具",resources:s.builtinTools}),o.jsx(Edt,{tools:s.pythonTools})]}),o.jsx(I2,{label:"Sub Agent",count:s.subAgentCount,icon:o.jsx(ARe,{"aria-hidden":"true"}),children:o.jsx(kdt,{agents:s.subAgents})})]})]},s.name)})}):n==="running"?o.jsx(C0e,{label:"正在创建 Agent"}):o.jsxs("div",{className:"create-agent-card__message",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"没有可展示的 Agent"}),o.jsx("span",{children:"工具返回中未包含 Agent 配置或执行结果。"})]})]})}const Cdt={web_search:{name:"web_search",runningLabel:"正在进行网络搜索",doneLabel:"已完成网络搜索",tone:"search",icon:Mct},run_code:{name:"run_code",runningLabel:"正在 AgentKit 沙箱中执行代码",doneLabel:"已在 AgentKit 沙箱中完成代码执行",tone:"sandbox",icon:Fct},list_envs:{name:"list_envs",runningLabel:"正在查看可用环境",doneLabel:"已读取可用环境",tone:"resources",icon:Vct},get_env_manifest:{name:"get_env_manifest",runningLabel:"正在读取环境 Manifest",doneLabel:"已读取环境 Manifest",tone:"knowledge",icon:Hct},execute_in_sandbox:{name:"execute_in_sandbox",runningLabel:"正在环境中执行命令",doneLabel:"已在环境中完成命令执行",tone:"sandbox",icon:qct},image_generate:{name:"image_generate",runningLabel:"正在生成图片",doneLabel:"已完成图片生成",tone:"image",icon:Lct},video_generate:{name:"video_generate",runningLabel:"正在生成视频",doneLabel:"已完成视频生成",tone:"video",icon:PB},ppt_generate:{name:"ppt_generate",runningLabel:"正在生成 PPT",doneLabel:"已完成 PPT 生成",tone:"presentation",icon:$ct},load_memory:{name:"load_memory",runningLabel:"正在检索长期记忆",doneLabel:"已完成记忆检索",tone:"memory",icon:Bct},load_knowledgebase:{name:"load_knowledgebase",runningLabel:"正在检索知识库",doneLabel:"已完成知识库检索",tone:"knowledge",icon:Qct},load_skill:{name:"load_skill",runningLabel:"正在加载技能",doneLabel:"已加载技能",tone:"skill",icon:Uct},collect_resources:{name:"collect_resources",runningLabel:"正在收集可用资源",doneLabel:"已完成资源收集",failedLabel:"资源收集失败",tone:"resources",icon:zct,detailRenderer:_dt},create_agents:{name:"create_agents",runningLabel:"正在创建并运行 Agent",doneLabel:"已完成 Agent 创建",failedLabel:"Agent 创建失败",tone:"agent",icon:QW,detailRenderer:Tdt},branch_compare:{name:"branch_compare",runningLabel:"",doneLabel:"",failedLabel:"",tone:"search",icon:QW,detailRenderer:tut,hideHeader:!0}};function Adt(e){return Cdt[e]}function A0e(e){return o.jsx("svg",{viewBox:"0 0 111 117",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M0 5.6016C7.82288e-05 0.621244 6.02226 -1.87314 9.54395 1.64847L40.1289 32.2334L68.5732 3.7891C69.5834 2.77903 70.9533 2.21099 72.3818 2.21097H82.7031C82.7917 2.20658 82.8806 2.20414 82.9697 2.20414H104.775C109.574 2.20427 111.977 8.00691 108.584 11.4004L64.916 55.0664C64.3075 55.8528 63.9436 56.7647 63.8242 57.6993C63.7142 56.4884 63.1964 55.3069 62.2695 54.3799L45.4082 37.5186H45.4072L40.124 32.2354L17.832 54.5284C16.7671 55.5933 16.2416 56.993 16.2549 58.3887C16.2417 59.7843 16.7672 61.1842 17.832 62.2491L39.9287 84.3467L9.54395 114.733C6.0223 118.255 0.000223474 115.761 0 110.78V5.6016ZM63.8018 58.8702C63.8962 59.9086 64.2936 60.9229 64.9961 61.7735L108.591 105.368C111.984 108.762 109.58 114.564 104.781 114.564H94.4336C94.3543 114.568 94.274 114.569 94.1934 114.569H72.3877C70.9592 114.569 69.5892 114.002 68.5791 112.992L39.9336 84.3467L58.4531 65.8282L58.4453 65.8203L62.2695 61.9981C63.1476 61.12 63.6567 60.0136 63.8018 58.8702Z",fill:"currentColor"})})}function Ndt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3h8l4 4v14H6Z"}),o.jsx("path",{d:"M14 3v5h5"}),o.jsx("path",{d:"m10 12-2 2 2 2M14 12l2 2-2 2"})]})}function jdt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M12 3 19 6v5c0 4.6-2.8 7.8-7 10-4.2-2.2-7-5.4-7-10V6l7-3Z"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]})}function Rdt(e,t){const n=new Map(e.map(a=>[a.path,a.content])),r=new Map(t.map(a=>[a.path,a.content])),i=new Set([...n.keys(),...r.keys()]),s=[];for(const a of[...i].sort((l,c)=>l.localeCompare(c))){const l=n.get(a),c=r.get(a);l!==c&&s.push({path:a,status:l===void 0?"added":c===void 0?"deleted":"modified",before:l??"",after:c??""})}return s}function Idt(e){return e==="added"?"新增":e==="deleted"?"删除":"修改"}function gm(e){return{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,...e}}function N0e(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"m9 7-5 5 5 5M15 7l5 5-5 5M13.5 4l-3 16"})})}function TD(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"M6.5 3.75h7l4 4V20.25h-11zM13.5 3.75v4h4M9 12h6M9 15.5h4.5"})})}function Ddt(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"M3.75 7.25h6l1.75 2h8.75v9.25H3.75zM3.75 7.25V5.5h5l1.5 1.75"})})}function Pdt(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"m9 5 7 7-7 7"})})}function j0e(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function Mdt(e){return o.jsxs("svg",{...gm(e),children:[o.jsx("circle",{cx:"12",cy:"12",r:"3.25"}),o.jsx("path",{d:"M12 2.75v2M12 19.25v2M2.75 12h2M19.25 12h2M5.45 5.45l1.4 1.4M17.15 17.15l1.4 1.4M18.55 5.45l-1.4 1.4M6.85 17.15l-1.4 1.4"})]})}function Ldt(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"M19.25 15.25A8 8 0 0 1 8.75 4.75a8 8 0 1 0 10.5 10.5Z"})})}function $dt(e){return o.jsxs("svg",{...gm(e),children:[o.jsx("path",{d:"M19.25 8.25V4.5l-1.8 1.8a7.5 7.5 0 1 0 1.8 7.65"}),o.jsx("path",{d:"M19.25 4.5H15.5"})]})}const Bdt=p.lazy(()=>fd(()=>Promise.resolve().then(()=>ave),void 0)),Qdt=p.lazy(()=>fd(()=>import("../chunks/CodeDiffEditor-DLkdb2YA.js"),[])),R0e="veadk-code-workspace-theme";function Udt(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let i=t;r.forEach((s,a)=>{let l=i.children.get(s);l||(l={name:s,children:new Map},i.children.set(s,l)),a===r.length-1&&(l.path=n.path),i=l})}return t}function Fdt(e,t=!1){return[...e.children.values()].sort((n,r)=>{const i=n.children.size>0&&n.path===void 0,s=r.children.size>0&&r.path===void 0;return i!==s?t?i?1:-1:i?-1:1:n.name.localeCompare(r.name)})}function zdt(){if(typeof window>"u")return"light";try{return window.localStorage.getItem(R0e)==="dark"?"dark":"light"}catch{return"light"}}function Vdt(e){return e===""?0:e.split(`
+`||c==="\r")&&(s=!1);continue}if(a){c==="*"&&u==="/"&&(a=!1,l+=1);continue}if(r){i?i=!1:c==="\\"?i=!0:c===r&&(r="");continue}if(c==="/"&&u==="/"){s=!0,l+=1;continue}if(c==="/"&&u==="*"){a=!0,l+=1;continue}if(c==="'"||c==='"'){r=c;continue}const d=e.slice(l).match(n);if(d)return{index:l,openingIndex:l+d[0].lastIndexOf("("),type:d[1]==="LinearGradient"?"linear":"radial"}}}function Jot(e){let t=e,n=0;for(;;){const r=Kot(t,n);if(!r)return t;const i=Wot(t,r.openingIndex),s=t.slice(r.openingIndex+1,i),a=JSON.stringify(Zot(r.type,s));t=`${t.slice(0,r.index)}${a}${t.slice(i+1)}`,n=r.index+a.length}}function elt(e,t=!1){if(e.length>Hot)throw new Error("ECharts option is too large");const n=Jot(Got(e));let r;try{r=Ige.parse(n)}catch(a){throw/\bfunction\s*\(|=>/.test(n)?new Error("ECharts function callbacks are not supported"):a}if(!Yx(r))throw new Error("ECharts option must be a data object");sA(r);const i={...r};i.aria={...Yx(i.aria)?i.aria:{},enabled:!0};const s=i.tooltip;return Yx(s)?i.tooltip={...s,renderMode:"richText"}:Array.isArray(s)&&(i.tooltip=s.map(a=>Yx(a)?{...a,renderMode:"richText"}:a)),t&&(i.animation=!1),i}let xD;function tlt(){return xD??(xD=fd(()=>import("../visualizations/echarts/index-CGT341lL.js"),[]).catch(e=>{throw xD=void 0,e})),xD}function nlt({source:e}){const t=p.useRef(null),[n,r]=p.useState(!1),[i,s]=p.useState("");return p.useEffect(()=>{let a=!1,l,c,u;r(!1);try{u=elt(e,window.matchMedia("(prefers-reduced-motion: reduce)").matches),s("")}catch{s("ECharts 配置不是有效且安全的数据对象,请切换到代码检查内容。");return}return tlt().then(d=>{const f=t.current;a||!f||(l=d.init(f,void 0,{renderer:"svg"}),l.setOption(u,{notMerge:!0}),typeof ResizeObserver<"u"&&(c=new ResizeObserver(()=>l==null?void 0:l.resize()),c.observe(f)),r(!0))}).catch(()=>{l==null||l.dispose(),l=void 0,a||s("图表暂时无法渲染,请切换到代码检查内容。")}),()=>{a=!0,c==null||c.disconnect(),l==null||l.dispose()}},[e]),o.jsxs("div",{className:`echarts-diagram${i?" echarts-diagram--error":""}`,role:"img","aria-label":"ECharts 图表预览","aria-busy":!n&&!i,children:[o.jsx("div",{ref:t,className:"echarts-diagram__canvas",hidden:!!i}),!n&&!i?o.jsx("div",{className:"echarts-diagram__state","aria-live":"polite",children:o.jsx(wn,{duration:2.2,spread:15,children:"正在渲染图表…"})}):null,i?o.jsx("p",{className:"echarts-diagram__error",role:"alert",children:i}):null]})}const rlt=p.memo(nlt);let MW,LW=Promise.resolve(),ilt=0;function slt(){return MW??(MW=fd(async()=>{const{default:e}=await import("../visualizations/mermaid/mermaid.core-BcqeQUkk.js").then(t=>t.ay);return{default:e}},__vite__mapDeps([0,1])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:"strict",suppressErrorRendering:!0,theme:"neutral"}),e))),MW}function alt(e){const t=LW.then(async()=>{const n=await slt(),r=`mermaid-diagram-${ilt+=1}`;return n.render(r,e)});return LW=t.then(()=>{},()=>{}),t}function olt({source:e}){const t=p.useRef(null),[n,r]=p.useState(null),[i,s]=p.useState(!1);return p.useEffect(()=>{let a=!1;return r(null),s(!1),alt(e).then(l=>{a||r(l)}).catch(()=>{a||s(!0)}),()=>{a=!0}},[e]),p.useEffect(()=>{!(n!=null&&n.bindFunctions)||!t.current||n.bindFunctions(t.current)},[n]),i?o.jsx("div",{className:"mermaid-diagram mermaid-diagram--error",children:o.jsx("p",{className:"mermaid-diagram__error",role:"alert",children:"图表暂时无法渲染,请切换到代码查看 Mermaid 内容。"})}):n?o.jsx("div",{ref:t,className:"mermaid-diagram",role:"img","aria-label":"Mermaid 图表预览",dangerouslySetInnerHTML:{__html:n.svg}}):o.jsx("div",{className:"mermaid-diagram mermaid-diagram--loading","aria-live":"polite",children:o.jsx(wn,{duration:2.2,spread:15,children:"正在渲染图表…"})})}const llt=p.memo(olt),clt="_SegmentedControl_1sl7d_1",ult="_SegmentedControlOption_1sl7d_140",dlt="_SegmentedControlThumb_1sl7d_219",bL={SegmentedControl:clt,SegmentedControlOption:ult,SegmentedControlThumb:dlt},zs=({value:e,onChange:t,children:n,block:r,pill:i=!0,size:s="md",gutterSize:a,className:l,onClick:c,...u})=>{const d=p.useRef(null),f=p.useRef(null),h=p.useCallback(g=>{const b=d.current,y=f.current;if(!b||!y)return;const O=b==null?void 0:b.querySelector('[data-state="on"]');if(!O)return;const v=b.clientWidth;let x=Math.floor(O.clientWidth);const w=O.offsetLeft;if(v-(x+w)<2&&(x=x-1),y.style.width=`${Math.floor(x)}px`,y.style.transform=`translateX(${w}px)`,b.scrollWidth>v){const S=v*.15,E=b.scrollLeft,k=O.offsetLeft,_=k+x;(kE+v-S)&&g&&O.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}},[]);Tle({ref:d,onResize:()=>{const g=f.current;if(!g)return;const b=g.style.transition;g.style.transition="",h(!1),g.style.transition=b}}),p.useLayoutEffect(()=>{const g=d.current,b=f.current;!g||!b||(h(!!b.style.transition),b.style.transition||SC(()=>{b.style.transition="width 300ms var(--cubic-enter), transform 300ms var(--cubic-enter)"}))},[h,e,s,a,i]);const m=g=>{g&&t&&t(g)};return o.jsxs(YLe,{ref:d,className:sr(bL.SegmentedControl,l),type:"single",value:e,loop:!1,onValueChange:m,onClick:c,"data-block":r?"":void 0,"data-pill":i?"":void 0,"data-size":s,"data-gutter-size":a,...u,children:[o.jsx("div",{className:bL.SegmentedControlThumb,ref:f}),n]})},flt=({children:e,...t})=>o.jsx(t6e,{className:bL.SegmentedControlOption,...t,onPointerEnter:C9,children:o.jsx("span",{className:"relative",children:e})});zs.Option=flt;function hlt({children:e,label:t,language:n,source:r,streaming:i=!1}){const[s,a]=p.useState("preview"),l=i?"code":s;return o.jsxs("section",{className:"visualization-card","aria-label":`${t} 图表`,children:[o.jsx("div",{className:"visualization-card__toolbar",children:o.jsxs(zs,{className:"visualization-card__tabs",value:l,size:"sm",gutterSize:"sm",pill:!1,"aria-label":`${t} 显示方式`,onChange:c=>{i||a(c)},children:[o.jsx(zs.Option,{value:"preview",disabled:i,children:"预览"}),o.jsx(zs.Option,{value:"code",children:"代码"})]})}),o.jsx("div",{className:"visualization-card__body",children:l==="code"?o.jsx("pre",{className:"visualization-card__code",children:o.jsx("code",{className:`language-${n}`,children:r})}):e})]})}const plt=p.memo(hlt);function mlt(e){const t=e==null?void 0:e.trim().toLowerCase();if(t==="mermaid")return"mermaid";if(t==="echart"||t==="echarts")return"echarts"}const Dge=[".mp4",".webm",".mov",".m4v",".ogg",".avi"];function yL(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(yL).join(""):p.isValidElement(e)?yL(e.props.children):""}function glt(e){var r;const t=p.Children.toArray(e)[0];if(!p.isValidElement(t))return;const n=(r=t.props.className)==null?void 0:r.split(/\s+/).find(i=>i.startsWith("language-"));return mlt(n==null?void 0:n.slice(9))}function Pge(e){if(!e)return!1;try{const t=e.toLowerCase();return Dge.some(n=>t.includes(n))}catch{return!1}}function blt(e){var r;const t=(r=e==null?void 0:e.properties)==null?void 0:r.href;if(!t)return!1;if(Pge(t))return!0;const n=e==null?void 0:e.children;if(n&&Array.isArray(n)){const i=n.map(s=>(s==null?void 0:s.value)||"").join("").toLowerCase();return Dge.some(s=>i.includes(s))}return!1}function ylt({text:e,className:t,allowRawHtml:n=!0,streaming:r=!1}){const[i,s]=p.useState(null),a=(u,d)=>{if(u.src)return u.src;if(d){const f=m=>{var g;if(!m)return null;if(m.type==="source"&&((g=m.properties)!=null&&g.src))return m.properties.src;if(m.children)for(const b of m.children){const y=f(b);if(y)return y}return null},h=f({children:d});if(h)return h}return""},l=u=>{try{const f=new URL(u).pathname.split("/");return f[f.length-1]||"video.mp4"}catch{return"video.mp4"}},c=u=>u?Array.isArray(u)?u.map(d=>(d==null?void 0:d.value)||"").join("")||"video":(u==null?void 0:u.value)||"video":"video";return o.jsxs("div",{className:t?`md ${t}`:"md",children:[o.jsx(DJe,{remarkPlugins:[Wtt],rehypePlugins:n?[jot,gW]:[gW],components:{pre:({node:u,children:d,...f})=>{const h=glt(d);if(h==="mermaid"||h==="echarts"){const m=yL(d).replace(/\n$/,"");return o.jsx(plt,{label:h==="mermaid"?"Mermaid":"ECharts",language:h,source:m,streaming:r,children:h==="mermaid"?o.jsx(llt,{source:m}):o.jsx(rlt,{source:m})})}return o.jsx("pre",{...f,children:d})},a:({node:u,...d})=>{const f=d.href;if(f&&(Pge(f)||blt(u))){const h=f,m=c(u==null?void 0:u.children);return o.jsxs("div",{className:"video-container",children:[o.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":`点击播放视频: ${m}`,onClick:()=>s({src:h,title:m}),children:[o.jsx("video",{src:h,playsInline:!0,className:"video-thumbnail",preload:"metadata"}),o.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:o.jsx(cy,{})})]}),o.jsx("div",{className:"video-caption",children:o.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"video-link-text",children:m})})]})}return o.jsx("a",{...d,target:"_blank",rel:"noopener noreferrer"})},img:({node:u,src:d,alt:f,...h})=>{const m=o.jsx("img",{...h,src:d,alt:f??"",loading:"lazy"});return d?o.jsx(Tae,{src:d,children:o.jsxs("button",{type:"button",className:"image-preview-trigger","aria-label":`放大预览:${f||"图片"}`,children:[m,o.jsx("span",{className:"image-preview-hint","aria-hidden":"true",children:o.jsx(cy,{})})]})}):m},video:({node:u,src:d,children:f,...h})=>{const m=a({src:d},f);return m?o.jsx("div",{className:"video-container",children:o.jsxs("button",{type:"button",className:"video-preview-trigger","aria-label":"点击放大视频",onClick:()=>s({src:m}),children:[o.jsx("video",{src:m,...h,playsInline:!0,className:"video-thumbnail",children:f}),o.jsx("span",{className:"video-preview-hint","aria-hidden":"true",children:o.jsx(cy,{})})]})}):o.jsx("video",{src:d,controls:!0,playsInline:!0,className:"video-inline",...h,children:f})}},children:e}),i&&o.jsx("div",{className:"video-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":"视频预览",onClick:()=>s(null),children:o.jsxs("div",{className:"video-viewer",onClick:u=>u.stopPropagation(),children:[o.jsxs("div",{className:"video-viewer-header",children:[o.jsx("div",{className:"video-viewer-title",children:i.title||l(i.src)}),o.jsxs("nav",{className:"video-viewer-nav",children:[o.jsx("a",{href:i.src,download:i.title||l(i.src),"aria-label":"下载视频",title:"下载视频",className:"video-viewer-download",children:o.jsx(jN,{})}),o.jsx("button",{type:"button",className:"video-viewer-close","aria-label":"关闭",onClick:()=>s(null),children:o.jsx(Ea,{})})]})]}),o.jsx("div",{className:"video-viewer-body",children:o.jsx("video",{src:i.src,controls:!0,autoPlay:!0,playsInline:!0,className:"video-fullscreen"})})]})})]})}const Ou=p.memo(ylt),Olt="未知来源",xlt="未知创建者";function zv(e){return(e==null?void 0:e.trim())||Olt}function Mge(e){return(e==null?void 0:e.trim())||xlt}function vlt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5 5.5A2.5 2.5 0 0 1 7.5 3H19v16H7.5A2.5 2.5 0 0 0 5 21.5v-16Z"}),o.jsx("path",{d:"M5 18.5A2.5 2.5 0 0 1 7.5 16H19"}),o.jsx("path",{d:"M9 7h6M9 10h4"})]})}function wlt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3h8l4 4v14H6V3Z"}),o.jsx("path",{d:"M14 3v5h5M9 12h6M9 16h6"})]})}function Slt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function Elt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"M12 5v14M5 12h14"})})}function AE({title:e,children:t,onClose:n,busy:r=!1,className:i=""}){const s=p.useId(),a=p.useRef(null),l=p.useRef(null),c=p.useRef(r),u=p.useRef(n);return p.useEffect(()=>{c.current=r,u.current=n},[r,n]),p.useEffect(()=>{var m;const d=document.activeElement instanceof HTMLElement?document.activeElement:null,f=document.body.style.overflow;document.body.style.overflow="hidden",(m=a.current)==null||m.focus();const h=g=>{if(g.key==="Escape"&&!c.current){u.current();return}if(g.key!=="Tab")return;const b=l.current;if(!b)return;const y=Array.from(b.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), a[href], audio[controls], video[controls], iframe, [tabindex]:not([tabindex="-1"])')).filter(x=>x.getClientRects().length>0);if(y.length===0){g.preventDefault();return}const O=y[0],v=y[y.length-1];g.shiftKey&&(document.activeElement===O||!b.contains(document.activeElement))?(g.preventDefault(),v.focus()):!g.shiftKey&&(document.activeElement===v||!b.contains(document.activeElement))&&(g.preventDefault(),O.focus())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h),document.body.style.overflow=f,d!=null&&d.isConnected&&d.focus()}},[]),kr.createPortal(o.jsx("div",{className:"knowledge-dialog-backdrop",onMouseDown:d=>{d.target===d.currentTarget&&!r&&n()},children:o.jsxs("section",{ref:l,className:`knowledge-dialog${i?` ${i}`:""}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":r||void 0,children:[o.jsxs("header",{className:"knowledge-dialog__header",children:[o.jsx("h2",{id:s,children:e}),o.jsx("button",{ref:a,type:"button",onClick:n,disabled:r,"aria-label":"关闭",children:o.jsx(Slt,{})})]}),t]})}),document.body)}function Zw({message:e}){return e?o.jsx("div",{className:"knowledge-form-error",role:"alert",children:e}):null}function OL(e){return e instanceof DOMException&&e.name==="AbortError"}function klt(e){if(!e)return"";const t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(t):e}const Lge=[".jpg",".jpeg",".png"].join(","),_lt=new Set(Lge.split(",")),$ge=[".pdf",".pptx",".docx",".xlsx",".txt"].join(","),Tlt=new Set($ge.split(",")),Clt=200*1024*1024;function xL(e){const t=e.lastIndexOf(".");return t<0?"":e.slice(t).toLocaleLowerCase()}function Alt(e,t){return e.size>Clt?"单个文件不能超过 200 MB":t==="image"?_lt.has(xL(e.name))?"":"请选择 PNG、JPG 或 JPEG 图片":Tlt.has(xL(e.name))?"":"请选择 PDF、PPTX、DOCX、XLSX 或 TXT 文件"}function jB(e){return e<=0?"-":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vL(e){var i;const t=e.type.trim().replace(/^\./,"");if(t)return t.toUpperCase();const n=e.name.trim(),r=n.includes(".")?(i=n.split(".").pop())==null?void 0:i.trim():"";return r?r.toUpperCase():"-"}function Nlt({region:e,onClose:t,onCreated:n}){const[r,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[f,h]=p.useState(""),m=r.trim(),g=!!(m&&!/^[A-Za-z][A-Za-z0-9_]{0,47}$/.test(m)),b=async y=>{if(y.preventDefault(),c(!0),!m||g)return;d(!0),h("");const O={name:m,description:s.trim()||void 0,region:e};try{n(await GGe(O))}catch(v){h(Ga(v,"创建知识库失败"))}finally{d(!1)}};return o.jsx(AE,{title:"新建知识库",onClose:t,busy:u,children:o.jsxs("form",{onSubmit:y=>void b(y),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{autoFocus:!0,value:r,maxLength:48,"aria-invalid":l&&g||void 0,"aria-describedby":"knowledge-name-help",onBlur:()=>c(!0),onChange:y=>i(y.target.value)})]}),o.jsx("p",{id:"knowledge-name-help",className:`knowledge-dialog__note${l&&g?" is-error":""}`,role:l&&g?"alert":void 0,children:l&&g?"名称必须以字母开头,且只能包含字母、数字和下划线。":"以字母开头,仅支持字母、数字和下划线,最多 48 个字符。"}),o.jsxs("label",{children:[o.jsx("span",{children:"描述(可选)"}),o.jsx("textarea",{value:s,maxLength:80,onChange:y=>a(y.target.value)})]}),o.jsx(Zw,{message:f})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:u,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:u||!m||g,children:u?"创建中":"创建"})]})]})})}function jlt({item:e,onClose:t,onUpdated:n}){const[r,i]=p.useState(e.description),[s,a]=p.useState(!1),[l,c]=p.useState(""),u=async d=>{d.preventDefault(),a(!0),c("");try{n(await WGe(e.id,e.region,{description:r.trim()}))}catch(f){c(Ga(f,"更新知识库失败"))}finally{a(!1)}};return o.jsx(AE,{title:"编辑知识库",onClose:t,busy:s,children:o.jsxs("form",{onSubmit:d=>void u(d),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称"}),o.jsx("input",{value:e.name,disabled:!0})]}),o.jsxs("label",{children:[o.jsx("span",{children:"描述"}),o.jsx("textarea",{autoFocus:!0,value:r,maxLength:80,onChange:d=>i(d.target.value)})]}),o.jsx("p",{className:"knowledge-dialog__note",children:"AgentKit 当前仅支持更新知识库描述。"}),o.jsx(Zw,{message:l})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:s,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:s,children:s?"保存中":"保存"})]})]})})}function Bge(e){if(!e.trim())return{};const t=JSON.parse(e);if(!t||Array.isArray(t)||typeof t!="object")throw new Error("Metadata 必须是 JSON 对象");return t}function Rlt({base:e,onClose:t,onCreated:n,onAssociationInvalid:r}){const[i,s]=p.useState("document"),[a,l]=p.useState(""),[c,u]=p.useState(""),[d,f]=p.useState(""),[h,m]=p.useState(null),[g,b]=p.useState(!1),[y,O]=p.useState("{}"),[v,x]=p.useState(""),[w,S]=p.useState(""),[E,k]=p.useState(null),_=p.useRef(null),T=p.useRef(null),C=p.useRef(null),A=p.useRef(0),R=!!v;p.useEffect(()=>{var j;E&&!R&&((j=C.current)==null||j.focus())},[R,E]);const M=j=>{R||j===i||(s(j),m(null),f(""),l(""),u(""),S(""),k(null),b(!1),A.current=0,_.current&&(_.current.value=""))},I=j=>{if(!j||i==="web")return;const B=Alt(j,i);if(B){m(null),l(""),u(""),S(B);return}m(j),S(""),l(j.name.replace(/\.[^.]+$/,"")),u(xL(j.name).slice(1))},$=async j=>{if(j.preventDefault(),i==="web"?!d.trim():!h)return;let B;try{B=Bge(y)}catch(F){S(Ga(F,"Metadata 格式错误"));return}x(i==="web"?E?"save":"preview":"upload"),S("");try{if(i==="web")if(E){const F={sourceType:"url",metadata:E.metadata,url:E.preview.url,sourceTitle:E.preview.name,sourceMarkdown:E.preview.sourceMarkdown};await JGe(e.id,e.region,F),n()}else{const F=await eWe(e.id,e.region,{url:d.trim()});if(!F.sourceMarkdown.trim())throw new Error("网页没有可预览的 Markdown 内容");k({preview:F,metadata:B})}else h&&(await tWe(e.id,e.region,{file:h,name:a.trim()||void 0,documentType:c.trim()||void 0,metadata:B}),n())}catch(F){F instanceof Sj&&F.errorCode===Khe?r(F):S(Ga(F,i==="web"?E?"添加网页失败":"生成网页预览失败":"上传文件失败"))}finally{x("")}},N=()=>{R||(k(null),S(""),requestAnimationFrame(()=>{var j;return(j=T.current)==null?void 0:j.focus()}))};return o.jsx(AE,{title:E?"预览网页内容":"添加数据",onClose:t,busy:R,className:E?"knowledge-dialog--preview knowledge-dialog--web-confirm":"",children:o.jsx("form",{onSubmit:j=>void $(j),children:E?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"knowledge-preview knowledge-web-preview",children:[o.jsxs("div",{className:"knowledge-preview__meta",children:[o.jsx("strong",{title:E.preview.name,children:E.preview.name}),o.jsx("a",{href:E.preview.url,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"})]}),o.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:o.jsx("div",{className:"knowledge-preview__markdown-shell",children:o.jsx(Ou,{text:E.preview.sourceMarkdown,allowRawHtml:!1,className:"knowledge-preview__markdown"})})}),w?o.jsx("div",{className:"knowledge-web-preview__error",children:o.jsx(Zw,{message:w})}):null]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",className:"is-back",onClick:N,disabled:R,children:"返回修改"}),o.jsx("button",{type:"button",onClick:t,disabled:R,children:"取消"}),o.jsx("button",{ref:C,type:"submit",className:"is-primary",disabled:R,children:v==="save"?"添加中":"确认添加"})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsx("div",{className:"knowledge-source-tabs",role:"tablist","aria-label":"知识来源",children:[["image","图片"],["document","文档文件"],["web","在线网页"]].map(([j,B])=>o.jsx("button",{type:"button",role:"tab",id:`knowledge-source-${j}-tab`,"aria-controls":`knowledge-source-${j}-panel`,"aria-selected":i===j,tabIndex:i===j?0:-1,className:i===j?"is-active":"",disabled:R,onClick:()=>M(j),onKeyDown:F=>{const L=["image","document","web"];if(!["ArrowLeft","ArrowRight","Home","End"].includes(F.key))return;F.preventDefault();const H=L.indexOf(j),z=F.key==="Home"?L[0]:F.key==="End"?L[L.length-1]:L[(H+(F.key==="ArrowRight"?1:-1)+L.length)%L.length];M(z),requestAnimationFrame(()=>{var Q;return(Q=document.getElementById(`knowledge-source-${z}-tab`))==null?void 0:Q.focus()})},children:B},j))}),o.jsx("div",{id:`knowledge-source-${i}-panel`,className:"knowledge-source-panel",role:"tabpanel","aria-labelledby":`knowledge-source-${i}-tab`,children:i==="web"?o.jsxs(o.Fragment,{children:[o.jsxs("label",{children:[o.jsx("span",{children:"网页 URL"}),o.jsx("input",{ref:T,autoFocus:!0,type:"url",value:d,disabled:R,onChange:j=>{f(j.target.value),S("")},placeholder:"https://example.com/article"})]}),o.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:v==="preview"?o.jsx(wn,{children:"正在抓取网页并生成 Markdown 预览"}):null})]}):o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:_,className:"knowledge-upload-input",type:"file","aria-label":"选择知识文件",accept:i==="image"?Lge:$ge,disabled:R,onChange:j=>{var B;I(((B=j.currentTarget.files)==null?void 0:B[0])??null),j.currentTarget.value=""}}),o.jsxs("button",{type:"button",className:`knowledge-upload-dropzone${g?" is-dragging":""}${h?" is-ready":""}`,disabled:R,onClick:()=>{var j;return(j=_.current)==null?void 0:j.click()},onDragEnter:j=>{j.preventDefault(),!R&&(A.current+=1,b(!0))},onDragOver:j=>{j.preventDefault(),R||(j.dataTransfer.dropEffect="copy")},onDragLeave:j=>{j.preventDefault(),A.current=Math.max(0,A.current-1),A.current===0&&b(!1)},onDrop:j=>{var B;j.preventDefault(),A.current=0,b(!1),R||I(((B=j.dataTransfer.files)==null?void 0:B[0])??null)},children:[o.jsx("strong",{children:h?h.name:"选择文件或拖拽到这里"}),o.jsx("span",{children:h?`${jB(h.size)} · 点击可重新选择`:i==="image"?"支持 PNG、JPG 和 JPEG,单个文件不超过 200 MB":"支持 PDF、PPTX、DOCX、XLSX 和 TXT,单个文件不超过 200 MB"})]}),o.jsx("div",{className:"knowledge-upload-status",role:"status","aria-live":"polite",children:R?o.jsx(wn,{children:"正在上传文件并添加到知识库"}):null})]})}),i!=="web"?o.jsxs("div",{className:"knowledge-dialog__fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"名称(可选)"}),o.jsx("input",{value:a,disabled:R,maxLength:256,onChange:j=>l(j.target.value)})]}),o.jsxs("label",{children:[o.jsx("span",{children:"类型(可选)"}),o.jsx("input",{value:c,disabled:R,maxLength:64,onChange:j=>u(j.target.value),placeholder:"pdf、docx、png"})]})]}):null,o.jsxs("label",{children:[o.jsx("span",{children:"Metadata(JSON)"}),o.jsx("textarea",{className:"is-code",value:y,disabled:R,onChange:j=>O(j.target.value),spellCheck:!1})]}),o.jsx(Zw,{message:w})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:t,disabled:R,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:R||(i==="web"?!d.trim():!h),children:R?i==="web"?"生成中":"上传中":i==="web"?"生成预览":"上传文件"})]})]})})})}function Ilt({base:e,item:t,onClose:n,onUpdated:r}){const[i,s]=p.useState(()=>JSON.stringify(t.metadata??{},null,2)),[a,l]=p.useState(!1),[c,u]=p.useState(""),d=async f=>{f.preventDefault();let h;try{h=Bge(i)}catch(m){u(Ga(m,"Metadata 格式错误"));return}l(!0),u("");try{r(await nWe(e.id,t.id,e.region,{metadata:h}))}catch(m){u(Ga(m,"更新知识失败"))}finally{l(!1)}};return o.jsx(AE,{title:"编辑知识 Metadata",onClose:n,busy:a,children:o.jsxs("form",{onSubmit:f=>void d(f),children:[o.jsxs("div",{className:"knowledge-dialog__body",children:[o.jsxs("label",{children:[o.jsx("span",{children:"知识"}),o.jsx("input",{value:t.name||t.id,disabled:!0})]}),o.jsxs("label",{children:[o.jsx("span",{children:"Metadata(JSON)"}),o.jsx("textarea",{autoFocus:!0,className:"is-code knowledge-metadata-editor",value:i,onChange:f=>s(f.target.value),spellCheck:!1})]}),o.jsx(Zw,{message:c})]}),o.jsxs("footer",{className:"knowledge-dialog__actions",children:[o.jsx("button",{type:"button",onClick:n,disabled:a,children:"取消"}),o.jsx("button",{type:"submit",className:"is-primary",disabled:a,children:a?"保存中":"保存"})]})]})})}const Qge=new Set(["avif","bmp","gif","jpeg","jpg","png","svg","webp"]),Uge=new Set(["aac","flac","m4a","mp3","ogg","wav","webm"]),Fge=new Set(["m4v","mov","mp4","mpeg","mpg","ogg","webm"]),Dlt=new Set(["pdf"]),Plt=new Set(["doc","docx","ppt","pptx","xls","xlsx"]),Mlt=new Set(["creating","indexing","pending","processing","queued","submitted"]),Llt=new Set(["error","failed","unavailable"]);function $W(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function A2(e){if(e==null||e==="")return"-";if(["string","number","boolean"].includes(typeof e))return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function $lt(e){if(Array.isArray(e)){if(e.length===0)return null;const r=e.map($W);if(r.some(i=>Object.keys(i).length>0)){const i=[...new Set(r.flatMap(s=>Object.keys(s)))];return{columns:i,rows:r.map(s=>i.map(a=>A2(s[a])))}}return{columns:["值"],rows:e.map(i=>[A2(i)])}}const t=$W(e),n=Object.entries(t);if(n.length===0)return null;if(n.every(([,r])=>Array.isArray(r))){const r=n.map(([s])=>s),i=Math.max(...n.map(([,s])=>s.length));return{columns:r,rows:Array.from({length:i},(s,a)=>n.map(([,l])=>A2(l[a])))}}return{columns:["字段","值"],rows:n.map(([r,i])=>[r,A2(i)])}}function zge(e){const t=e.trim();if(!t||t.startsWith("//"))return"";if(t.startsWith("/"))return t;try{const n=new URL(t);return["http:","https:"].includes(n.protocol)?n.href:""}catch{return""}}function Blt(e){const t=zge(e);return t.startsWith("http://")||t.startsWith("https://")?t:""}function Qlt(e){var i;const t=e.attachmentType.trim().toLocaleLowerCase();if(t==="image"||t==="doc-image"||t.startsWith("image/"))return"image";if(t==="audio"||t.startsWith("audio/"))return"audio";if(t==="video"||t.startsWith("video/"))return"video";if(t==="pdf"||t==="application/pdf")return"pdf";const n=e.attachmentUrl.split(/[?#]/,1)[0],r=n.includes(".")?((i=n.split(".").pop())==null?void 0:i.toLocaleLowerCase())??"":"";return Qge.has(r)?"image":Uge.has(r)?"audio":Fge.has(r)?"video":Dlt.has(r)?"pdf":t||r?"file":"none"}function Ult(e){const t=e.status.trim().toLocaleLowerCase();if(Mlt.has(t))return{title:"数据正在处理中",detail:"知识库完成解析后即可预览,请稍后重新加载。"};if(Llt.has(t))return{title:"数据解析失败",detail:"请检查源文件或网页地址后重新添加,也可以重新加载最新状态。"};const n=vL(e).toLocaleLowerCase();return n==="pdf"||Plt.has(n)?{title:"暂时没有可预览的解析内容",detail:"此类文件会在知识库完成解析后显示文本、表格或页面图片。"}:Qge.has(n)||Uge.has(n)||Fge.has(n)?{title:"暂时没有可预览的媒体内容",detail:"知识库尚未返回可访问的媒体预览,请稍后重新加载。"}:{title:"暂无可预览的数据内容",detail:"知识库尚未返回解析结果,请稍后重新加载。"}}function Flt({chunk:e}){const[t,n]=p.useState(!1),r=zge(e.attachmentUrl),i=Qlt(e);return!r||i==="none"?null:t?o.jsx("div",{className:"knowledge-preview__attachment-error",children:"附件无法预览,请稍后重试。"}):i==="image"?o.jsx("img",{className:"knowledge-preview__image",src:r,alt:e.title||"知识数据图片",loading:"lazy",onError:()=>n(!0)}):i==="audio"?o.jsx("audio",{className:"knowledge-preview__audio",src:r,controls:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持音频预览。"}):i==="video"?o.jsx("video",{className:"knowledge-preview__video",src:r,controls:!0,playsInline:!0,preload:"metadata",onError:()=>n(!0),children:"当前浏览器不支持视频预览。"}):i==="pdf"?o.jsxs("div",{className:"knowledge-preview__pdf",children:[o.jsx("iframe",{src:r,title:e.title?`${e.title} PDF 预览`:"PDF 预览",sandbox:"",referrerPolicy:"no-referrer",onError:()=>n(!0)}),o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"无法显示时,在新窗口打开 PDF"})]}):o.jsxs("div",{className:"knowledge-preview__file-fallback",children:[o.jsx("p",{children:"当前格式暂不支持直接在线预览,已优先显示解析后的内容。"}),o.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",children:"打开原文件"})]})}function zlt({base:e,item:t,onClose:n}){const[r,i]=p.useState([]),[s,a]=p.useState(t),[l,c]=p.useState(""),[u,d]=p.useState(!0),[f,h]=p.useState(!1),[m,g]=p.useState(!1),[b,y]=p.useState(""),O=p.useRef(0),v=p.useRef(null),x=p.useCallback(async(k=0)=>{var C;(C=v.current)==null||C.abort();const _=new AbortController;v.current=_;const T=O.current+1;O.current=T,k>0?h(!0):d(!0),y(""),k===0&&(i([]),g(!1));try{const A=await KGe(e.id,t.id,{region:e.region,offset:k,signal:_.signal});if(O.current!==T)return;a(A.document.id?A.document:t),c(A.sourceMarkdown||A.document.sourceMarkdown),i(R=>k>0?[...R,...A.chunks]:A.chunks),g(A.hasMore)}catch(A){!OL(A)&&O.current===T&&y(Ga(A,"加载数据预览失败"))}finally{O.current===T&&(d(!1),h(!1))}},[e.id,e.region,t]);p.useEffect(()=>(x(),()=>{var k;(k=v.current)==null||k.abort(),O.current+=1}),[x]);const w=Blt(s.url||t.url),S=Ult(s),E=s.metadata._veadk_content_format==="markdown";return o.jsx(AE,{title:s.name||t.name||t.id,onClose:n,className:"knowledge-dialog--preview",children:o.jsxs("div",{className:"knowledge-preview",children:[s.sizeBytes>0||w?o.jsxs("div",{className:"knowledge-preview__meta",children:[s.sizeBytes>0?o.jsx("span",{children:jB(s.sizeBytes)}):null,w?o.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",children:"打开原网页"}):null]}):null,o.jsx("div",{className:"knowledge-preview__body","aria-live":"polite",children:l?o.jsx("div",{className:"knowledge-preview__markdown-shell",children:o.jsx(Ou,{text:l,allowRawHtml:!1,className:"knowledge-preview__markdown"})}):u?o.jsx("div",{className:"knowledge-preview__state",role:"status",children:o.jsx(wn,{as:"span",duration:2.4,children:"正在加载数据预览"})}):b&&r.length===0?o.jsxs("div",{className:"knowledge-preview__state is-error",role:"alert",children:[o.jsx("p",{children:b}),o.jsx("button",{type:"button",onClick:()=>void x(),children:"重试"})]}):r.length===0?o.jsxs("div",{className:"knowledge-preview__state",children:[o.jsx("p",{children:S.title}),o.jsx("span",{children:w?"您可以打开原网页查看来源内容。":S.detail}),o.jsx("button",{type:"button",onClick:()=>void x(),children:"重新加载"})]}):o.jsxs("div",{className:"knowledge-preview__chunks",children:[r.map((k,_)=>{const T=$lt(k.tableFields),C=k.id||`${_}:${k.title}`;return o.jsxs("article",{className:"knowledge-preview__chunk",children:[o.jsx("header",{children:o.jsx("h3",{children:k.title||`片段 ${_+1}`})}),k.content?E?o.jsx(Ou,{text:k.content,allowRawHtml:!1,className:"knowledge-preview__markdown"}):o.jsx("p",{className:"knowledge-preview__content",children:k.content}):null,T?o.jsx("div",{className:"knowledge-preview__table-wrap",children:o.jsxs("table",{children:[o.jsx("thead",{children:o.jsx("tr",{children:T.columns.map((A,R)=>o.jsx("th",{scope:"col",children:A},`${A}:${R}`))})}),o.jsx("tbody",{children:T.rows.map((A,R)=>o.jsx("tr",{children:A.map((M,I)=>o.jsx("td",{children:M},I))},R))})]})}):null,o.jsx(Flt,{chunk:k})]},C)}),b?o.jsx("div",{className:"knowledge-preview__more-error",role:"alert",children:b}):null,m?o.jsx("button",{type:"button",className:"knowledge-preview__load-more",disabled:f,onClick:()=>void x(r.length),children:f?o.jsx(wn,{as:"span",duration:2.4,children:"正在加载更多"}):"加载更多"}):null]})})]})})}function Vlt({cloudProvider:e,region:t,active:n=!0,activationRevision:r=0,onDetailChange:i,toolbarLeading:s,toolbarFilters:a}){const[l,c]=p.useState([]),[u,d]=p.useState({}),[f,h]=p.useState([]),[m,g]=p.useState(""),[b,y]=p.useState("overview"),[O,v]=p.useState(""),[x,w]=p.useState(""),[S,E]=p.useState(!0),[k,_]=p.useState(!1),[T,C]=p.useState(""),[A,R]=p.useState([]),[M,I]=p.useState(!1),[$,N]=p.useState(""),[j,B]=p.useState(""),[F,L]=p.useState(""),[H,z]=p.useState(!1),[Q,V]=p.useState(!1),[K,se]=p.useState(!1),[ge,ie]=p.useState(null),[q,G]=p.useState(null),[J,ue]=p.useState(null),[Oe,Qe]=p.useState(null),[je,ze]=p.useState(null),[Ge,Ae]=p.useState(!1),Be=p.useRef(0),he=p.useRef(0),be=p.useRef([]),Se=p.useRef(!1),Ee=p.useRef(!1),tt=p.useRef(null),Ue=p.useRef(null),re=p.useRef({}),ce=p.useRef(!1),Me=p.useRef(null),Ye=p.useRef(null),Z=p.useRef(null),_e=p.useRef(null),rt=p.useMemo(()=>[t],[t]),Re=p.useCallback(ve=>`${ve.region}\0${ve.id}`,[]),We=l.find(ve=>Re(ve)===m)??null,ct=!!(We&&F===Re(We));p.useEffect(()=>{i==null||i(!!We)},[i,We]),p.useEffect(()=>{y("overview"),w("")},[m]);const kt=p.useMemo(()=>{const ve=O.trim().toLocaleLowerCase();return ve?l.filter(He=>[He.name,He.description,He.ownerLabel,He.providerKnowledgeId].some(pt=>pt.toLocaleLowerCase().includes(ve))):l},[l,O]),qt=p.useMemo(()=>{const ve=x.trim().toLocaleLowerCase();return ve?A.filter(He=>[He.name,He.id,vL(He)].some(pt=>pt.toLocaleLowerCase().includes(ve))):A},[x,A]);p.useEffect(()=>{G(null)},[We==null?void 0:We.id,We==null?void 0:We.region]);const Dt=p.useCallback(async(ve=!1)=>{var _t;if(ve&&(ce.current||Object.keys(re.current).length===0))return;(_t=tt.current)==null||_t.abort();const He=new AbortController;tt.current=He;const pt=Be.current+1;Be.current=pt,ce.current=!0,ve?_(!0):E(!0),C(""),ve||h([]);try{const It=await XGe({regions:rt,nextTokens:ve?re.current:void 0,signal:He.signal});if(Be.current!==pt)return;c(en=>ve?[...en,...It.items.filter(le=>!en.some(Xt=>Re(Xt)===Re(le)))]:It.items),re.current=It.nextTokens,d(It.nextTokens);const Kt=It.failures.map(({region:en,error:le})=>`${Jf(en,e)}:${Ga(le,"加载失败")}`);h(en=>ve?[...new Set([...en,...Kt])]:Kt),ve||g(en=>It.items.some(le=>Re(le)===en)?en:"")}catch(It){if(OL(It))return;Be.current===pt&&(ve?h(Kt=>[...new Set([...Kt,Ga(It,"加载更多知识库失败")])]):C(Ga(It,"加载知识库失败")))}finally{Be.current===pt&&(ce.current=!1,E(!1),_(!1))}},[Re,e,rt]),Xe=p.useCallback(async(ve,He=!1)=>{var It;if(He&&Se.current)return;(It=Ue.current)==null||It.abort();const pt=new AbortController;Ue.current=pt;const _t=he.current+1;he.current=_t,He||(be.current=[],Ee.current=!1,R([]),z(!1),B("")),Se.current=!0,I(!0),He?B(""):N("");try{const Kt=await ZGe(ve.id,{region:ve.region,offset:He?be.current.length:0,signal:pt.signal});if(he.current!==_t)return;L(Fe=>Fe===Re(ve)?"":Fe);const en=be.current,le=He?[...en,...Kt.items.filter(Fe=>!Fe.id||!en.some(Pt=>Pt.id===Fe.id))]:Kt.items,Xt=Kt.hasMore&&(!He||le.length>en.length);be.current=le,Ee.current=Xt,R(le),z(Xt)}catch(Kt){if(OL(Kt))return;he.current===_t&&(Kt instanceof Sj&&Kt.errorCode===Khe&&(L(Re(ve)),ie(le=>le&&Re(le)===Re(ve)?null:le)),He?B(Ga(Kt,"加载更多数据失败")):N(Ga(Kt,"加载数据失败")))}finally{he.current===_t&&(Se.current=!1,I(!1))}},[Re]);p.useEffect(()=>{var ve;(ve=tt.current)==null||ve.abort(),Be.current+=1,ce.current=!1,re.current={},c([]),d({}),h([]),g(""),L(""),C(""),E(!0)},[e]),p.useEffect(()=>{if(n)return Dt(),()=>{var ve;(ve=tt.current)==null||ve.abort(),Be.current+=1,ce.current=!1}},[n,r,Dt]),p.useEffect(()=>{var ve,He;if(!n){(ve=Ue.current)==null||ve.abort(),he.current+=1,Se.current=!1;return}if(!We){(He=Ue.current)==null||He.abort(),he.current+=1,be.current=[],Se.current=!1,Ee.current=!1,R([]),z(!1),B("");return}return Xe(We),()=>{var pt;(pt=Ue.current)==null||pt.abort(),he.current+=1,Se.current=!1}},[n,r,We==null?void 0:We.id,We==null?void 0:We.region]);const nt=n&&!We&&!O.trim()&&!S&&!k&&!T&&Object.keys(u).length>0;p.useEffect(()=>{const ve=Ye.current,He=Me.current;if(!ve||!He||!nt)return;const pt=new IntersectionObserver(([_t])=>{_t.isIntersecting&&Dt(!0)},{root:He,rootMargin:"240px 0px",threshold:.01});return pt.observe(ve),()=>pt.disconnect()},[nt,Dt]);const ft=()=>{const ve=Me.current;!ve||!nt||ve.scrollHeight-ve.scrollTop-ve.clientHeight<=240&&Dt(!0)},xt=!!(We&&A.length>0&&H&&!M&&!j);p.useEffect(()=>{const ve=_e.current,He=Z.current;if(!We||!ve||!He||!xt)return;const pt=new IntersectionObserver(([_t])=>{_t.isIntersecting&&Xe(We,!0)},{root:Z.current,rootMargin:"240px 0px",threshold:.01});return pt.observe(ve),()=>pt.disconnect()},[xt,Xe,We==null?void 0:We.id,We==null?void 0:We.region]);const Ie=()=>{const ve=Z.current;if(!We||!ve||!Ee.current||Se.current||j)return;const{scrollHeight:He,scrollTop:pt,clientHeight:_t}=ve;He-pt-_t<=240&&Xe(We,!0)},xe=ve=>{c(He=>He.map(pt=>Re(pt)===Re(ve)?ve:pt))},$e=async()=>{if(Oe){Ae(!0);try{await YGe(Oe.id,Oe.region),c(ve=>ve.filter(He=>Re(He)!==Re(Oe))),L(ve=>ve===Re(Oe)?"":ve),m===Re(Oe)&&g(""),Qe(null)}catch(ve){C(Ga(ve,"删除知识库失败")),Qe(null)}finally{Ae(!1)}}},it=async()=>{if(!(!We||!je)){Ae(!0);try{await rWe(We.id,je.id,We.region);const ve=be.current.filter(He=>He.id!==je.id);be.current=ve,R(ve),ze(null)}catch(ve){N(Ga(ve,"删除知识失败")),ze(null)}finally{Ae(!1)}}};return o.jsxs("section",{className:`knowledge-library${We?" is-detail":" resource-collection"}`,"aria-label":"知识库",children:[We?o.jsx(gE,{className:"knowledge-library__detail",title:We.name,description:We.description||"暂无描述",identitySeed:We.name,backLabel:"返回知识库列表",onBack:()=>g(""),sections:[{key:"overview",label:"概览",content:o.jsx("section",{className:"knowledge-overview",children:o.jsxs(Y7,{className:"knowledge-overview__summary",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"Provider"}),o.jsx("dd",{children:We.providerType||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"Knowledge ID"}),o.jsx("dd",{className:"knowledge-keyboard-reveal",tabIndex:0,title:We.providerKnowledgeId,children:We.providerKnowledgeId||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"项目"}),o.jsx("dd",{children:We.projectName||"default"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"创建者"}),o.jsx("dd",{children:zv(We.ownerLabel)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"更新时间"}),o.jsx("dd",{children:klt(We.updatedAt)||"-"})]})]})})},{key:"data",label:"数据",content:o.jsx("section",{className:"knowledge-documents",children:o.jsx("div",{className:`knowledge-documents__body${A.length>0?" is-table":""}`,"aria-live":"polite",children:M&&A.length===0?o.jsx(yd,{}):$&&A.length===0?o.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[o.jsx("p",{children:$}),ct&&We.canManage?o.jsx("button",{type:"button",onClick:()=>Qe(We),children:"删除失效关联"}):o.jsx("button",{type:"button",onClick:()=>void Xe(We),children:"重试"})]}):A.length===0?o.jsxs("div",{className:"knowledge-library__state",children:[o.jsx(wlt,{}),o.jsx("p",{children:"这个知识库还没有数据"}),We.canManage&&o.jsx("button",{type:"button",onClick:()=>ie(We),children:"添加第一项数据"})]}):o.jsx(fGe,{rows:qt,rowKey:ve=>ve.id,rowLabel:ve=>ve.name||ve.id,columns:[{key:"name",header:"名称",className:"is-primary-column",render:ve=>o.jsx("span",{title:ve.name||ve.id,children:ve.name||ve.id})},{key:"format",header:"格式",className:"is-compact-column",render:ve=>vL(ve)},{key:"size",header:"大小",className:"is-compact-column",render:ve=>jB(ve.sizeBytes)}],searchValue:x,onSearchChange:w,searchPlaceholder:"搜索数据",searchLabel:"搜索知识库数据",primaryAction:We.canManage?{label:ct?"关联已失效":"添加数据",disabled:ct,title:ct?"底层 Provider 知识库已不存在":void 0,onClick:()=>ie(We)}:void 0,rowActions:ve=>[{label:"预览",onSelect:()=>G(ve)},...We.canManage?[{label:"编辑",onSelect:()=>ue(ve)},{label:"删除",onSelect:()=>ze(ve),danger:!0}]:[]],scrollRef:Z,onScroll:Ie,busy:M,emptyLabel:"没有匹配的数据",footer:M?o.jsxs("div",{className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),o.jsx("span",{children:"正在加载更多数据"})]}):j?o.jsxs("div",{className:"knowledge-document-pagination is-error",role:"alert",children:[o.jsx("span",{children:j}),o.jsx("button",{type:"button",onClick:()=>void Xe(We,!0),children:"重试加载"})]}):H?o.jsx("div",{ref:_e,className:"knowledge-document-pagination",role:"status","aria-live":"polite",children:"继续下滑加载更多"}):null})})})}],activeSectionKey:b,navigationLabel:"知识库详情",onSectionChange:y,actions:We.canManage?o.jsxs(o.Fragment,{children:[o.jsx(jt,{type:"button",color:"danger",variant:"soft",size:"lg",pill:!1,onClick:()=>Qe(We),children:"删除"}),o.jsx(jt,{type:"button",color:"primary",size:"lg",pill:!1,onClick:()=>se(!0),children:"编辑"})]}):void 0}):o.jsxs(o.Fragment,{children:[o.jsxs(g0,{className:"knowledge-library__toolbar library-resource-toolbar",children:[s,o.jsxs("div",{className:"resource-toolbar__actions",children:[a,o.jsx(Wp,{value:O,onChange:ve=>v(ve.target.value),placeholder:"搜索知识库","aria-label":"搜索知识库"})]})]}),o.jsxs(b0,{ref:Me,"aria-live":"polite",onScroll:ft,children:[f.length>0&&!S&&o.jsxs("div",{className:"knowledge-region-warning",role:"status",children:[o.jsx("span",{children:"部分知识库暂时无法加载,已展示其余可用内容。"}),o.jsx("button",{type:"button",onClick:()=>void Dt(),children:"重试"})]}),S&&l.length===0?o.jsx(yd,{}):T?o.jsxs("div",{className:"knowledge-library__state is-error",role:"alert",children:[o.jsx("p",{children:T}),o.jsx("button",{type:"button",onClick:()=>void Dt(),children:"重试"})]}):kt.length===0&&O.trim()?o.jsxs("div",{className:"knowledge-library__state",children:[o.jsx(vlt,{}),o.jsx("p",{children:"没有匹配的知识库"})]}):o.jsxs(sO,{children:[O.trim()?null:o.jsx(Vg,{"aria-label":"新建知识库",icon:o.jsx(Elt,{}),onClick:()=>V(!0),children:"新建知识库"}),kt.map(ve=>o.jsx(xE,{className:"knowledge-card",title:ve.name,description:ve.description||"暂无描述",metadata:[{label:"创建者",value:zv(ve.ownerLabel),title:zv(ve.ownerLabel)},{label:"项目",value:ve.projectName||"default",title:ve.projectName||"default"}],action:{label:F===Re(ve)?"关联已失效":"添加数据",icon:"plus",disabled:!ve.canManage||F===Re(ve),title:ve.canManage?F===Re(ve)?"底层 Provider 知识库已不存在":void 0:"您没有管理此知识库的权限",onClick:()=>ie(ve)},detailAction:{label:"查看详情",onClick:()=>g(Re(ve))}},Re(ve)))]}),nt||k?o.jsx("div",{ref:Ye,className:"my-agent-load-more",role:"status","aria-live":"polite",children:k?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"my-agent-loading-mark","aria-hidden":"true"}),o.jsx("span",{children:"正在加载更多知识库"})]}):nt?o.jsx("span",{children:"继续下滑加载更多"}):null}):null]})]}),Q&&o.jsx(Nlt,{region:t,onClose:()=>V(!1),onCreated:ve=>{c(He=>[ve,...He]),g(Re(ve)),V(!1)}}),We&&K&&o.jsx(jlt,{item:We,onClose:()=>se(!1),onUpdated:ve=>{xe(ve),se(!1)}}),We&&q&&o.jsx(zlt,{base:We,item:q,onClose:()=>G(null)}),ge&&o.jsx(Rlt,{base:ge,onClose:()=>ie(null),onAssociationInvalid:ve=>{L(Re(ge)),We&&Re(We)===Re(ge)&&N(Ga(ve,"知识库关联已失效")),ie(null)},onCreated:()=>{We&&Re(We)===Re(ge)&&Xe(We),ie(null)}}),We&&J&&o.jsx(Ilt,{base:We,item:J,onClose:()=>ue(null),onUpdated:ve=>{const He=be.current.map(pt=>pt.id===ve.id?ve:pt);be.current=He,R(He),ue(null)}}),Oe&&o.jsx(ql,{title:"删除知识库?",description:`将删除 ${Oe.name} 的 AgentKit 关联;如果它由 Studio 创建,也会同时删除 Provider 资源。此操作无法撤销。`,confirmLabel:Ge?"删除中":"删除",variant:"danger",busy:Ge,onCancel:()=>Qe(null),onConfirm:()=>void $e()}),je&&o.jsx(ql,{title:"删除知识?",description:`将从 Provider 知识库中删除 ${je.name||je.id},此操作无法撤销。`,confirmLabel:Ge?"删除中":"删除",variant:"danger",busy:Ge,onCancel:()=>ze(null),onConfirm:()=>void it()})]})}const Hlt="_EmptyMessage_1r5gu_1",qlt="_IconBadge_1r5gu_16",Xlt="_Title_1r5gu_54",Glt="_Description_1r5gu_69",Wlt="_ActionRow_1r5gu_77",NE={EmptyMessage:Hlt,IconBadge:qlt,Title:Xlt,Description:Glt,ActionRow:Wlt},yn=({children:e,className:t,fill:n="static"})=>o.jsx("div",{className:sr(NE.EmptyMessage,t),"data-fill":n,children:e}),Ylt=({size:e="md",color:t="secondary",children:n,className:r})=>o.jsx("div",{className:sr(NE.IconBadge,r),"data-size":e,"data-color":t,children:n}),Zlt=({children:e,className:t,color:n="secondary"})=>o.jsx("div",{className:sr(NE.Title,t),"data-color":n,children:e}),Klt=({children:e,className:t})=>o.jsx("div",{className:sr(NE.Description,t),children:e}),Jlt=({children:e,className:t})=>o.jsx("div",{className:sr(NE.ActionRow,t),children:e});yn.Icon=Ylt;yn.Title=Zlt;yn.Description=Klt;yn.ActionRow=Jlt;const ect="/web/skill-management";class tct extends Error{constructor(t,n,r="SKILL_MANAGEMENT_ERROR",i="",s,a=""){super(t),this.status=n,this.code=r,this.statusText=i,this.originalError=s,this.rawResponse=a,this.name="SkillManagementApiError"}}async function xh(e,t={},n=Ao){return fetch(So(`${ect}${e}`),{...t,headers:ph(t.headers),signal:il(t.signal,n)})}async function Vge(e,t){let n=t,r="SKILL_MANAGEMENT_ERROR",i;const s=await e.text().catch(()=>"");try{const a=JSON.parse(s);typeof a.detail=="string"?n=a.detail:a.detail&&(n=a.detail.message||t,r=a.detail.code||r,i=a.detail.originalError)}catch{s.trim()&&(n=`${t}:${s.trim()}`)}return new tct(n,e.status,r,e.statusText,i,s)}async function vh(e,t){if(!e.ok)throw await Vge(e,t);return e.json()}async function nct(e){const t=new URLSearchParams({region:e.region,page:String(e.page),page_size:String(e.pageSize)});return e.project&&t.set("project",e.project),vh(await xh(`/spaces?${t}`,{signal:e.signal}),"读取 Skill 空间失败")}async function rct(e){return vh(await xh("/spaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),"创建 Skill 空间失败")}async function ict(e){return vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,description:e.description,region:e.region})}),"更新 Skill 空间失败")}async function sct(e){const t=new URLSearchParams({region:e.region});await vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}?${t}`,{method:"DELETE"}),"删除 Skill 空间失败")}async function act(e){const t=new URLSearchParams({region:e.region});return e.project&&t.set("project",e.project),vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}/skills?${t}`,{method:"POST",headers:{"Content-Type":"application/zip"},body:e.file},es),"上传 Skill 失败")}async function oct(e){return vh(await xh("/validate",{method:"POST",headers:{"Content-Type":"application/zip"},body:e},es),"校验 Skill 失败")}async function lct(e){const t=new URLSearchParams({region:e.region});await vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}?${t}`,{method:"DELETE"}),"删除 Skill 失败")}async function cct(e){const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version),e.skillSpaceName&&t.set("skill_space_name",e.skillSpaceName),e.skillName&&t.set("skill_name",e.skillName);const n=await vh(await xh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/files?${t}`),"读取 Skill 文件失败");return Array.isArray(n.files)?n.files:[]}async function uct(e){var l;const t=new URLSearchParams({region:e.region});e.version&&t.set("version",e.version),e.skillSpaceName&&t.set("skill_space_name",e.skillSpaceName),e.skillName&&t.set("skill_name",e.skillName);const n=await xh(`/spaces/${encodeURIComponent(e.spaceId)}/skills/${encodeURIComponent(e.skillId)}/archive?${t}`,{},es);n.ok||await vh(n,"下载 Skill 失败");const i=((l=(n.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:l[1])||`${e.fallbackName}.zip`,s=URL.createObjectURL(await n.blob()),a=document.createElement("a");a.href=s,a.download=i,a.click(),URL.revokeObjectURL(s)}async function Mj(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:il(void 0,Ao)});if(!t.ok)throw await Vge(t,"AgentKit Skills 请求失败");return t.json()}async function Hge(){return(await Mj("/web/skill-spaces")).items||[]}async function qge(e,t){const n=t?`?region=${encodeURIComponent(t)}`:"";return(await Mj(`/web/skill-spaces/${encodeURIComponent(e)}/skills${n}`)).items||[]}async function dct(e,t){const n=new URLSearchParams({region:t.region,page:String(t.page),page_size:String(t.pageSize)});return t.project&&n.set("project",t.project),Mj(`/web/skill-spaces/${encodeURIComponent(e)}/skills?${n.toString()}`)}async function fct(e,t,n,r,i,s,a){const l=[];n&&l.push(`version=${encodeURIComponent(n)}`),r&&l.push(`region=${encodeURIComponent(r)}`),i&&l.push(`project=${encodeURIComponent(i)}`),s&&l.push(`skill_name=${encodeURIComponent(s)}`),a&&l.push(`skill_space_name=${encodeURIComponent(a)}`);const c=l.length>0?`?${l.join("&")}`:"";return Mj(`/web/skill-spaces/${encodeURIComponent(e)}/skills/${encodeURIComponent(t)}${c}`)}function hct(e,t){return{source:"skillspace",id:`ss:${e.id}/${t.skillId}/${t.version}`,name:t.skillName,description:t.skillDescription,folder:t.skillName,skillSpaceId:e.id,skillSpaceName:e.name,skillSpaceRegion:e.region,skillId:t.skillId,version:t.version}}function pct(e,t,n="volcengine"){return n==="byteplus"?"":`https://console.volcengine.com/agentkit/${(t||"cn-beijing")==="cn-beijing"?"cn":"cn-shanghai"}/skillspace/detail/${encodeURIComponent(e)}`}const mct="/web/skill-workbench";class wL extends Error{constructor(t,n,r="SKILL_WORKBENCH_ERROR",i=!1,s="",a,l=""){super(t),this.status=n,this.code=r,this.retryable=i,this.statusText=s,this.originalError=a,this.rawResponse=l,this.name="SkillWorkbenchApiError"}}function Rc(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function BW(e,t){if(e!=null){if(typeof e!="string"||!e.trim()||e.trim().length>256)throw new Error(`${t}格式错误。`);return e.trim()}}function gct(e){if(e!=null){if(e==="pending"||e==="ready"||e==="failed"||e==="unknown")return e;throw new Error("Skill 恢复点状态格式错误。")}}async function Od(e,t={},n=Ao){return fetch(So(`${mct}${e}`),{...t,headers:ph(t.headers),signal:il(t.signal,n)})}async function RB(e,t){var r;const n=await e.text().catch(()=>"");try{const i=Rc(JSON.parse(n),"错误响应"),s=i.detail&&typeof i.detail=="object"?Rc(i.detail,"错误详情"):i;return new wL(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"SKILL_WORKBENCH_ERROR",s.retryable===!0,e.statusText,s.originalError&&typeof s.originalError=="object"?s.originalError:void 0,n)}catch{const i=((r=e.headers.get("content-type"))==null?void 0:r.split(";",1)[0])||"Content-Type 缺失";return new wL(`${t}(HTTP ${e.status},Content-Type: ${i})。请检查代理或网关配置。`,e.status,"SKILL_WORKBENCH_ERROR",!1,e.statusText,void 0,n)}}async function Zp(e,t){if(!e.ok)throw await RB(e,t);const n=e.headers.get("content-type")??"";if(!n.includes("application/json")){const r=n.split(";",1)[0]||"Content-Type 缺失";throw new Error(`${t}:服务端返回非 JSON 响应(HTTP ${e.status},Content-Type: ${r}),请检查代理或网关配置。`)}return e.json()}function bct(e){return Array.isArray(e)?e.map(t=>{const n=Rc(t,"Skill 会话活动"),r=n.kind,i=n.status;if(typeof n.id!="string"||!["status","thinking","message","tool"].includes(String(r))||!["running","done"].includes(String(i)))throw new Error("Skill 会话活动格式错误。");if(r==="tool"){if(typeof n.name!="string")throw new Error("Skill 工具活动格式错误。");return{id:n.id,kind:r,status:i,name:n.name,...n.input!==void 0?{args:n.input}:{},...n.output!==void 0?{response:n.output}:{}}}if(typeof n.text!="string")throw new Error("Skill 文本活动格式错误。");return{id:n.id,kind:r,status:i,text:n.text}}):[]}function yct(e){if(e==null)return;const t=Rc(e,"Skill 发布结果");if(typeof t.revision!="number"||typeof t.skillId!="string"||typeof t.version!="string"||!Array.isArray(t.skillSpaceIds)||!t.skillSpaceIds.every(n=>typeof n=="string")||t.disposition!=="create-new"&&t.disposition!=="update-source"||!GS(t.region)||typeof t.projectName!="string")throw new Error("Skill 发布结果格式错误。");return{revision:t.revision,skillId:t.skillId,version:t.version,skillSpaceIds:t.skillSpaceIds,disposition:t.disposition,region:t.region,projectName:t.projectName}}function Kw(e){const t=Rc(e,"Skill 会话");if(typeof t.jobId!="string"||t.operation!=="create"&&t.operation!=="optimize"||typeof t.intent!="string"||typeof t.revision!="number"||typeof t.state!="string")throw new Error("Skill 会话格式错误。");const n=Array.isArray(t.files)?t.files.flatMap(l=>{const c=Rc(l,"Skill 文件");return typeof c.path=="string"&&typeof c.size=="number"?[{path:c.path,size:c.size}]:[]}):[];if(!["running","ready","failed","cancelled","expired","published"].includes(t.state))throw new Error("Skill 会话状态无法识别。");const i=BW(t.toolId,"Tool ID"),s=BW(t.sessionId,"Session ID"),a=gct(t.recoveryStatus);return{jobId:t.jobId,operation:t.operation,intent:t.intent,...typeof t.model=="string"?{model:t.model}:{},...typeof t.style=="string"?{style:t.style}:{},...typeof t.requestedName=="string"?{requestedName:t.requestedName}:{},revision:t.revision,...i?{toolId:i}:{},...s?{sessionId:s}:{},...typeof t.sessionTtlSeconds=="number"?{sessionTtlSeconds:t.sessionTtlSeconds}:{},...typeof t.expiresAt=="string"?{expiresAt:t.expiresAt}:{},...typeof t.recoveryAvailable=="boolean"?{recoveryAvailable:t.recoveryAvailable}:{},...a?{recoveryStatus:a}:{},...typeof t.recoveredFromSnapshot=="boolean"?{recoveredFromSnapshot:t.recoveredFromSnapshot}:{},state:t.state,stage:typeof t.stage=="string"?t.stage:"generating",activities:bct(t.activities),files:n,...t.source&&typeof t.source=="object"?{source:t.source}:{},...typeof t.name=="string"?{name:t.name}:{},...typeof t.description=="string"?{description:t.description}:{},...typeof t.skillMd=="string"?{skillMd:t.skillMd}:{},...typeof t.error=="string"?{error:t.error}:{},...t.validation&&typeof t.validation=="object"?{validation:t.validation}:{},...t.publication?{publication:yct(t.publication)}:{}}}async function Lj(e){const t=Rc(await Zp(await Od("/capabilities",{signal:e}),"读取 Skill 工作台能力失败"),"Skill 工作台能力");return{enabled:t.enabled===!0,reason:typeof t.reason=="string"?t.reason:"",operations:Array.isArray(t.operations)?t.operations.filter(n=>n==="create"||n==="optimize"):[],models:Array.isArray(t.models)?t.models.flatMap(n=>{if(!n||typeof n!="object")return[];const r=n;return typeof r.id=="string"&&typeof r.label=="string"?[{id:r.id,label:r.label}]:[]}):[],styles:t.styles&&typeof t.styles=="object"&&!Array.isArray(t.styles)?Object.fromEntries(Object.entries(t.styles).filter(n=>typeof n[1]=="string")):{},...typeof t.maxUploadBytes=="number"?{maxUploadBytes:t.maxUploadBytes}:{}}}async function Oct(e){if(e.file){const n=new URLSearchParams({operation:"optimize",intent:e.intent});e.jobId&&n.set("job_id",e.jobId),e.model&&n.set("model",e.model),e.style&&n.set("style",e.style),e.name&&n.set("name",e.name);const r=await Od(`/tasks/from-upload?${n}`,{method:"POST",body:e.file,headers:{"Content-Type":"application/zip"},signal:e.signal},es);return Kw(await Zp(r,"开始优化 Skill 失败"))}const t=await Od("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:e.operation,intent:e.intent,...e.model?{model:e.model}:{},...e.style?{style:e.style}:{},...e.name?{name:e.name}:{},...e.jobId?{jobId:e.jobId}:{},...e.source?{source:{kind:"skill-center",skillId:e.source.skillId,skillName:e.source.name,version:e.source.version,region:e.source.region,projectName:e.source.projectName,skillSpaceId:e.source.skillSpaceId,skillSpaceName:e.source.skillSpaceName}}:{}}),signal:e.signal},es);return Kw(await Zp(t,"开始 Skill 会话失败"))}async function xct(e,t){return Kw(await Zp(await Od(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取 Skill 会话失败"))}async function vD(e,t,n){const r=new URLSearchParams;r.set("expected_revision",String(t));const i=Rc(await Zp(await Od(`/tasks/${encodeURIComponent(e)}/artifact?${r.toString()}`,{signal:n}),"读取 Skill 产物失败"),"Skill 产物");if(i.jobId!==e||i.revision!==t||!Number.isSafeInteger(i.revision)||i.revision<1||typeof i.sha256!="string"||!/^[0-9a-f]{64}$/.test(i.sha256)||typeof i.name!="string"||typeof i.description!="string"||!Array.isArray(i.files))throw new Error("Skill 产物格式错误。");const s=i.files.map(a=>{const l=Rc(a,"Skill 产物文件");if(typeof l.path!="string"||typeof l.size!="number"||typeof l.content!="string")throw new Error("Skill 产物文件格式错误。");return{path:l.path,size:l.size,content:l.content}});return{jobId:i.jobId,revision:i.revision,sha256:i.sha256,name:i.name,description:i.description,files:s}}async function wD(e){const t=await Od(`/tasks/${encodeURIComponent(e.jobId)}/refinements`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:e.intent,expectedRevision:e.expectedRevision})},es);return Kw(await Zp(t,"继续调整 Skill 失败"))}async function vct(e){const t=await Od(`/tasks/${encodeURIComponent(e.jobId)}/stop`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedRevision:e.expectedRevision})});return Kw(await Zp(t,"停止当前 Skill 任务失败"))}async function wct(e){const t=await Od(`/tasks/${encodeURIComponent(e.jobId)}/publish-stream`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},body:JSON.stringify({disposition:e.disposition,expectedRevision:e.expectedRevision,expectedArtifactSha256:e.expectedArtifactSha256,skillSpaceIds:e.skillSpaceIds??[],projectName:e.projectName,region:e.region}),signal:e.signal},0);if(!t.ok)throw await RB(t,"发布 Skill 失败");if(!(t.headers.get("content-type")??"").includes("application/x-ndjson"))throw new Error("发布 Skill 失败:服务端返回了非 NDJSON 响应。");if(!t.body)throw new Error("发布 Skill 失败:服务端没有返回进度流。");const r=new Set(["preparing","uploading","registering","activating","publishing"]);let i=null,s="";const a=new TextDecoder,l=t.body.getReader(),c=u=>{var h;if(!u.trim())return;const d=Rc(JSON.parse(u),"发布进度");if(d.type==="progress"){if(typeof d.phase!="string"||!r.has(d.phase)||typeof d.message!="string")throw new Error("发布进度格式错误。");(h=e.onProgress)==null||h.call(e,{phase:d.phase,message:d.message});return}if(d.type==="error"){const m=Rc(d.error,"发布错误");throw new wL(typeof m.message=="string"?m.message:"发布 Skill 失败",500,typeof m.code=="string"?m.code:"SKILL_PUBLISH_FAILED",m.retryable===!0,"",m.originalError&&typeof m.originalError=="object"?m.originalError:void 0,JSON.stringify(d.error))}if(d.type!=="complete")throw new Error("未知的发布进度事件。");const f=Rc(d.result,"发布结果");if(typeof f.skillId!="string"||typeof f.version!="string"||!Array.isArray(f.skillSpaceIds)||!f.skillSpaceIds.every(m=>typeof m=="string")||f.disposition!=="create-new"&&f.disposition!=="update-source"||!GS(f.region)||typeof f.projectName!="string")throw new Error("发布结果格式错误。");i={skillId:f.skillId,version:f.version,skillSpaceIds:f.skillSpaceIds,disposition:f.disposition,region:f.region,projectName:f.projectName}};for(;;){const{value:u,done:d}=await l.read();s+=a.decode(u,{stream:!d});const f=s.split(`
+`);if(s=f.pop()??"",f.forEach(c),d)break}if(c(s),!i)throw new Error("发布进度流提前结束,无法确认发布结果。请刷新技能中心确认状态。");return i}async function Sct(e){await Zp(await Od(`/tasks/${encodeURIComponent(e)}`,{method:"DELETE"}),"删除 Skill 会话失败")}async function Ect(e,t,n){var c;const r=new URLSearchParams;r.set("expected_revision",String(t)),r.set("expected_sha256",n);const i=await Od(`/tasks/${encodeURIComponent(e)}/download?${r.toString()}`,{},es);if(!i.ok)throw await RB(i,"下载 Skill 失败");const a=((c=(i.headers.get("content-disposition")??"").match(/filename="([^"]+)"/))==null?void 0:c[1])??"skill.zip",l=URL.createObjectURL(await i.blob());try{const u=document.createElement("a");u.href=l,u.download=a,u.click()}finally{URL.revokeObjectURL(l)}}const kct={formatDate(e){const t=e.value??e.date??e.timestamp;if(t==null)return"";const n=new Date(t);return isNaN(n.getTime())?String(t):n.toLocaleString()}};function _ct(e,t){if(!t||t==="/")return e;const n=t.replace(/^\//,"").split("/").map(i=>i.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const i of n){if(r==null||typeof r!="object")return;r=r[i]}return r}function Tct(e){return typeof e=="object"&&e!==null&&typeof e.path=="string"}function Cct(e){return typeof e=="object"&&e!==null&&typeof e.call=="string"}function IB(e,t){if(Tct(e))return _ct(t,e.path);if(Cct(e)){const n=kct[e.call],r={};for(const[i,s]of Object.entries(e.args??{}))r[i]=IB(s,t);return n?n(r):`[unknown fn: ${e.call}]`}return e}function Act(e,t){const n=IB(e,t);return n==null?"":typeof n=="string"?n:String(n)}const Xge=new Map;function S0(e,t){Xge.set(e,t)}function Nct(e){return Xge.get(e)}function jct(e,t,n){const r=t.replace(/^\//,"").split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~"));let i=e;for(let s=0;sIB(r,e.dataModel),resolveString:r=>Act(r,e.dataModel),dispatchAction:t,render:r=>{if(!r)return null;const i=e.components[r];if(!i)return null;const s=Nct(i.component)??Rct;return o.jsx(s,{node:i,ctx:n},r)}};return o.jsx("div",{className:"a2ui-surface","data-a2ui-surface":e.surfaceId,children:n.render(e.rootId)})}function Wge(e){const t=p.useRef(null),n=p.useRef(!0),r=28,i=p.useCallback(()=>{const s=t.current;s&&(n.current=s.scrollHeight-s.scrollTop-s.clientHeight{const s=t.current;s&&n.current&&(s.scrollTop=s.scrollHeight)},[e]),{ref:t,onScroll:i}}function $j({value:e,skillPrefix:t="/",onRemoveSkill:n,onRemoveAgent:r}){return e.skills.length===0&&!e.targetAgent?null:o.jsxs("div",{className:"invocation-chips","aria-label":"本轮调用上下文",children:[e.skills.map(i=>o.jsxs("span",{className:"invocation-chip invocation-chip--skill",title:i.description,children:[o.jsx(Sw,{"aria-hidden":!0}),o.jsxs("span",{children:[t,i.name]}),n?o.jsx("button",{type:"button",onClick:()=>n(i.name),"aria-label":`移除技能 ${i.name}`,children:o.jsx(Ea,{})}):null]},i.name)),e.targetAgent?o.jsxs("span",{className:"invocation-chip invocation-chip--agent",title:e.targetAgent.description,children:[o.jsx(Pae,{"aria-hidden":!0}),o.jsx("span",{children:e.targetAgent.name}),r?o.jsx("button",{type:"button",onClick:r,"aria-label":`移除 Agent ${e.targetAgent.name}`,children:o.jsx(Ea,{})}):null]}):null]})}function DB(e=""){return e.startsWith("image/")?"image":e.startsWith("video/")?"video":e==="application/pdf"?"pdf":e==="text/markdown"?"markdown":"text"}function Yge(e){var n,r,i,s;const t=DB(e.mimeType);return t==="pdf"?"PDF":t==="markdown"?"MD":t==="video"?((r=(n=e.mimeType)==null?void 0:n.split("/")[1])==null?void 0:r.toUpperCase())??"VIDEO":t==="image"?((s=(i=e.mimeType)==null?void 0:i.split("/")[1])==null?void 0:s.toUpperCase())??"IMAGE":"TXT"}function Zge(e){return e?e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:""}function Kge(e,t){return e.previewUrl?e.previewUrl:e.data?`data:${e.mimeType??"application/octet-stream"};base64,${e.data}`:e.uri?poe(t,e.uri):""}function Dct({kind:e}){return e==="image"?o.jsx(s9,{}):e==="video"?o.jsx($ae,{}):e==="pdf"?o.jsx(XRe,{}):o.jsx(r9,{})}function Bj({appName:e,items:t,compact:n=!1,onRemove:r}){const[i,s]=p.useState(null);return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:`media-grid${n?" media-grid--compact":""}`,children:t.map(a=>{const l=DB(a.mimeType),c=Kge(a,e),u=a.status==="uploading"||a.status==="error"||!c,d=o.jsxs("button",{type:"button",className:"media-card-main",disabled:u,onClick:l==="image"?void 0:()=>s(a),"aria-label":`预览 ${a.name??"附件"}`,children:[l==="image"&&c?o.jsx("img",{className:"media-card-image",src:c,alt:a.name??"图片",loading:"lazy"}):l==="video"&&c?o.jsxs("div",{className:"media-card-video-container",children:[o.jsx("video",{className:"media-card-video",src:c,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}),o.jsx("span",{className:"media-card-video-play",children:o.jsx(sIe,{})})]}):o.jsx("span",{className:"media-card-icon",children:o.jsx(Dct,{kind:l})}),o.jsxs("span",{className:"media-card-copy",children:[o.jsx("span",{className:"media-card-name",children:a.name??"附件"}),o.jsxs("span",{className:"media-card-meta",children:[o.jsx("span",{className:"media-card-type",children:Yge(a)}),a.status==="uploading"?o.jsxs(o.Fragment,{children:[o.jsx(rr,{className:"media-card-spinner"})," 上传中"]}):a.status==="error"?a.error??"上传失败":Zge(a.sizeBytes)]})]}),!n&&a.status!=="uploading"&&a.status!=="error"?o.jsx(cy,{className:"media-card-open"}):null]});return o.jsxs(ai.div,{className:`media-card media-card--${l}${a.status==="error"?" media-card--error":""}`,layout:!0,initial:{opacity:0,scale:.985,y:4},animate:{opacity:1,scale:1,y:0},children:[l==="image"&&!u?o.jsx(Tae,{src:c,children:d}):d,r?o.jsx("button",{type:"button",className:"media-card-remove","aria-label":`移除 ${a.name??"附件"}`,onClick:()=>r(a.id),children:o.jsx(Ea,{})}):null]},a.id)})}),o.jsx(fu,{children:i?o.jsx(Pct,{appName:e,item:i,onClose:()=>s(null)}):null})]})}function Pct({appName:e,item:t,onClose:n}){const r=p.useMemo(()=>Kge(t,e),[e,t]),i=DB(t.mimeType),[s,a]=p.useState(""),[l,c]=p.useState(i==="text"||i==="markdown"),[u,d]=p.useState("");return p.useEffect(()=>{const f=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n]),p.useEffect(()=>{if(i!=="text"&&i!=="markdown")return;const f=new AbortController;return c(!0),d(""),fetch(r,{signal:f.signal}).then(h=>{if(!h.ok)throw new Error(`HTTP ${h.status}`);return h.text()}).then(a).catch(h=>{f.signal.aborted||d(h instanceof Error?h.message:String(h))}).finally(()=>{f.signal.aborted||c(!1)}),()=>f.abort()},[i,r]),o.jsx(ai.div,{className:"media-viewer-backdrop",role:"dialog","aria-modal":"true","aria-label":t.name??"附件预览",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onMouseDown:f=>{f.target===f.currentTarget&&n()},children:o.jsxs(ai.div,{className:"media-viewer",initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.99},transition:{type:"spring",stiffness:420,damping:30},children:[o.jsxs("header",{className:"media-viewer-header",children:[o.jsxs("div",{children:[o.jsx("strong",{children:t.name??"附件"}),o.jsxs("span",{children:[Yge(t),t.sizeBytes?` · ${Zge(t.sizeBytes)}`:""]})]}),o.jsxs("nav",{children:[o.jsx("a",{href:r,download:t.name,"aria-label":"下载",children:o.jsx(jN,{})}),o.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",children:o.jsx(Ea,{})})]})]}),o.jsxs("div",{className:`media-viewer-body media-viewer-body--${i}`,children:[i==="image"?o.jsx("img",{src:r,alt:t.name??"图片"}):null,i==="video"?o.jsx("div",{className:"media-viewer-video-wrapper",children:o.jsx("video",{src:r,controls:!0,autoPlay:!0,playsInline:!0,preload:"auto",className:"media-viewer-video"})}):null,i==="pdf"?o.jsx("iframe",{src:r,title:t.name??"PDF"}):null,l?o.jsxs("div",{className:"media-viewer-loading",children:[o.jsx(rr,{})," 正在读取文档…"]}):null,!l&&u?o.jsxs("div",{className:"media-viewer-loading",children:["文档加载失败:",u]}):null,!l&&i==="markdown"?o.jsx("div",{className:"media-document",children:o.jsx(Ou,{text:s})}):null,!l&&i==="text"?o.jsx("pre",{className:"media-document media-document--plain",children:s}):null]})]})})}function Mct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"10.25",cy:"10.25",r:"6.25"}),o.jsx("path",{d:"M4.15 10.25h12.2M10.25 4c1.65 1.72 2.5 3.8 2.5 6.25s-.85 4.53-2.5 6.25M10.25 4c-1.65 1.72-2.5 3.8-2.5 6.25s.85 4.53 2.5 6.25M14.8 14.8 20 20"})]})}function Lct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.25",y:"5.25",width:"15.5",height:"13.5",rx:"2.25"}),o.jsx("circle",{cx:"8.1",cy:"9.3",r:"1.35"}),o.jsx("path",{d:"m4.7 16.5 3.65-3.7 2.45 2.25 2.2-2.2 4.35 4.1"}),o.jsx("path",{d:"m19.4 2.75.48 1.37 1.37.48-1.37.48-.48 1.37-.48-1.37-1.37-.48 1.37-.48.48-1.37Z",fill:"currentColor",stroke:"none"})]})}function PB(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{className:"video-generate-icon__body",d:"M3.25 9h17.5v7.35a2.4 2.4 0 0 1-2.4 2.4H5.65a2.4 2.4 0 0 1-2.4-2.4V9Z"}),o.jsxs("g",{className:"video-generate-icon__clapper",children:[o.jsx("path",{d:"M3.25 9V7.65a2.4 2.4 0 0 1 2.4-2.4h12.7a2.4 2.4 0 0 1 2.4 2.4V9H3.25Z"}),o.jsx("path",{d:"M6.75 5.25 9.3 9M12 5.25 14.55 9M17.25 5.25 19.8 9"})]}),o.jsx("path",{d:"m10.25 11.45 4 2.55-4 2.55v-5.1Z"})]})}function $ct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 5.25h15.5v10.5H4.25zM8.25 19.75h7.5M12 15.75v4"}),o.jsx("path",{d:"m7.25 12.75 2.35-2.4 2.15 1.65 3.4-3.6 1.6 1.55"}),o.jsx("circle",{cx:"7.25",cy:"8.4",r:".7",fill:"currentColor",stroke:"none"})]})}function Bct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M5 7.4c0-1.55 3.13-2.8 7-2.8s7 1.25 7 2.8-3.13 2.8-7 2.8-7-1.25-7-2.8Z"}),o.jsx("path",{d:"M5 7.4v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8V7.4M5 11.95v4.55c0 1.55 3.13 2.8 7 2.8s7-1.25 7-2.8v-4.55"}),o.jsx("path",{d:"M8.2 12.25h.01M8.2 16.8h.01"})]})}function Qct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 4.25h4.5v15.5h-4.5zM8.75 5.75h5v14h-5zM13.75 4.25h4.1v10.25h-4.1z"}),o.jsx("path",{d:"M5.75 7h1.5M10.25 8.25h2M10.25 11h2M15.15 7h1.3"}),o.jsx("circle",{cx:"17.45",cy:"17.35",r:"2.45"}),o.jsx("path",{d:"m19.25 19.15 1.55 1.55"})]})}function Uct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M4.25 6.25h6.25c1 0 1.5.55 1.5 1.45v11.05c0-.9-.5-1.45-1.5-1.45H4.25V6.25Z"}),o.jsx("path",{d:"M19.75 9.1v8.2H13.5c-1 0-1.5.55-1.5 1.45V7.7c0-.9.5-1.45 1.5-1.45h2.15"}),o.jsx("path",{d:"m19 3.2.58 1.62 1.62.58-1.62.58L19 7.6l-.58-1.62-1.62-.58 1.62-.58L19 3.2Z",fill:"currentColor",stroke:"none"})]})}function Fct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"m4.2 8.4 1.15 10.2h13.3L19.8 8.4"}),o.jsx("path",{d:"M4.2 8.4h15.6L17.9 5H6.1L4.2 8.4Z"}),o.jsx("path",{d:"M7.2 12.2c1.1-1 2.25 1.25 3.4.25 1.05-.9 2.15 1.3 3.3.25"}),o.jsx("path",{d:"m8.2 15.1 1.45 1.35 1.45-1.35M13.55 16.45h2.35"})]})}function zct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"6",cy:"6.25",r:"2.25"}),o.jsx("circle",{cx:"18",cy:"6.25",r:"2.25"}),o.jsx("circle",{cx:"12",cy:"17.75",r:"2.25"}),o.jsx("path",{d:"m7.7 7.75 2.7 7.55M16.3 7.75l-2.7 7.55M8.25 6.25h7.5"})]})}function QW(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"9",cy:"8",r:"3"}),o.jsx("path",{d:"M3.75 18.75c.45-3.05 2.2-4.65 5.25-4.65s4.8 1.6 5.25 4.65"}),o.jsx("path",{d:"M17.75 4.25v5.5M15 7h5.5M16 13.25h4.25M18.125 11.125v4.25"})]})}function Vct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"4",y:"4.25",width:"16",height:"5",rx:"1.5"}),o.jsx("rect",{x:"4",y:"14.75",width:"16",height:"5",rx:"1.5"}),o.jsx("path",{d:"M7.25 6.75h.01M7.25 17.25h.01M10 6.75h6.5M10 17.25h6.5"})]})}function Hct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3.75h8l4 4v12.5H6V3.75Z"}),o.jsx("path",{d:"M14 3.75v4h4M8.75 11h6.5M8.75 14.25h6.5M8.75 17.5h4"})]})}function qct(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"3.75",y:"4.5",width:"16.5",height:"15",rx:"2.5"}),o.jsx("path",{d:"m7.5 9 2.75 2.5L7.5 14M12.5 14h4"}),o.jsx("path",{d:"M3.75 7.5h16.5",opacity:".62"})]})}function MB(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m6 3.25 4.5 4.75L6 12.75"})})}function Xct({definition:e,label:t,done:n,open:r,onToggle:i}){const s=e.icon,a=t??(n?e.doneLabel:e.runningLabel);return o.jsxs("button",{type:"button",className:`builtin-tool-head${n?" is-done":" is-running"}`,"data-tool-tone":e.tone,onClick:i,"aria-expanded":r,children:[o.jsx("span",{className:"builtin-tool-icon","aria-hidden":"true",children:o.jsx(s,{})}),n?o.jsx("span",{className:"builtin-tool-label",children:a}):o.jsx(wn,{className:"builtin-tool-label",duration:2.4,spread:18,"aria-live":"polite",children:a}),o.jsx(MB,{className:`builtin-tool-chevron${r?" is-open":""}`})]})}function Ul(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function gn(e){return typeof e=="string"?e:""}function UW(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Sc(e){return Array.isArray(e)?e:[]}function SL(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch{return{}}const n=Ul(t)??{};return Ul(n.result)??n}function Qj(e){if(typeof e=="string")try{return Qj(JSON.parse(e))}catch{return e}const t=Ul(e);if(!t)return"";const n=Ul(t.result);return gn(t.error)||gn(t.message)||gn(n==null?void 0:n.error)||gn(n==null?void 0:n.message)}function Gct(e){if(e.kind==="tool")return"tool";if(e.kind==="knowledge_base")return"knowledge_base";const t=Ul(e.metadata),n=gn(t==null?void 0:t.source_type).toLowerCase(),r=gn(e.source).toLowerCase();return n==="skillhub"||r.startsWith("skill_hub:")?"skill_hub":"skill_space"}function Wct(e){return e==="veadk_builtin_tools"?"工具":e==="agentkit_knowledge"?"AgentKit 知识库":e.startsWith("skill_hub:")?`Skill Hub ${e.slice(10)}`:e.startsWith("skill_space:")?`AgentKit 技能中心 ${e.slice(12)}`:e||"未知来源"}function Yct(e){return e==="veadk_builtin_tools"?"tool":e==="agentkit_knowledge"?"knowledge_base":e.startsWith("skill_hub:")?"skill_hub":"skill_space"}function Zct(e){const t=SL(e),n=Ul(t.capabilities)??{},r=Sc(t.resources).flatMap(s=>{const a=Ul(s);if(!a)return[];const l=a.kind==="tool"?"tool":a.kind==="knowledge_base"?"knowledge_base":"skill";return[{ref:gn(a.ref),kind:l,category:Gct(a),name:gn(a.name)||gn(a.ref)||"未命名资源",description:gn(a.description),source:gn(a.source),version:gn(a.version)}]}),i=Sc(t.sources).flatMap(s=>{const a=Ul(s);if(!a)return[];const l=gn(a.source),c=gn(a.status),u=c==="error"?"error":c==="skipped"?"skipped":"ok";return[{source:l,category:Yct(l),label:Wct(l),status:u,count:UW(a.count),message:gn(a.message),searchKeywords:Sc(a.search_keywords).map(gn).filter(Boolean)}]});return{collectionId:gn(t.collection_id),capabilities:{googleAdkVersion:gn(n.google_adk_version),agentTypes:Sc(n.agent_types).map(gn).filter(Boolean),maxOrchestrationDepth:UW(n.max_orchestration_depth)},resources:r,sources:i,counts:{all:r.length,skill_hub:r.filter(s=>s.category==="skill_hub").length,skill_space:r.filter(s=>s.category==="skill_space").length,knowledge_base:r.filter(s=>s.category==="knowledge_base").length,tool:r.filter(s=>s.category==="tool").length}}}function Kct(e,t){return{resources:e.resources.filter(n=>n.category===t),sources:e.sources.filter(n=>n.category===t)}}function Jge(e,t){const n=SL(e),r=SL(t),i=new Map(Sc(r.results).flatMap(u=>{const d=Ul(u),f=gn(d==null?void 0:d.name);return d&&f?[[f,d]]:[]})),s=Sc(n.agents).flatMap(u=>{const d=Ul(u),f=gn(d==null?void 0:d.name);return d&&f?[d]:[]}),a=new Set(s.map(u=>gn(u.name))),l=[...i.entries()].filter(([u])=>!a.has(u)).map(([u])=>({name:u})),c=[...s,...l].map(u=>{const d=gn(u.name),f=Sc(u.nodes).flatMap(E=>{const k=Ul(E);return k?[k]:[]}),h=gn(u.root_node),m=f.find(E=>gn(E.id)===h),g=f.filter(E=>gn(E.id)!==h).map(E=>({id:gn(E.id)||"未命名 Agent",type:gn(E.type)||"llm",description:gn(E.description)})),b=i.get(d),y=gn(b==null?void 0:b.status),O=y==="failed"?"failed":y==="completed"?"completed":"running",v=FW(b==null?void 0:b.resources),x=v.length>0?v:FW(f.flatMap(E=>Sc(E.resources))),w=zW(b==null?void 0:b.python_tools),S=w.length>0?w:zW(f.flatMap(E=>Sc(E.python_tools)));return{name:d,description:gn(b==null?void 0:b.description)||gn(m==null?void 0:m.description)||gn(u.task),task:gn(u.task),rootType:gn(b==null?void 0:b.root_type)||gn(m==null?void 0:m.type)||"llm",nodeCount:f.length,subAgentCount:g.length,resourceCount:x.length,pythonToolCount:S.length,skills:x.filter(E=>E.kind==="skill"),knowledgeBases:x.filter(E=>E.kind==="knowledge_base"),builtinTools:x.filter(E=>E.kind==="tool"),pythonTools:S,subAgents:g,status:O,output:gn(b==null?void 0:b.output),error:gn(b==null?void 0:b.error)}});return{collectionId:gn(r.collection_id)||gn(n.collection_id),agents:c,completedCount:c.filter(u=>u.status==="completed").length,failedCount:c.filter(u=>u.status==="failed").length,runningCount:c.filter(u=>u.status==="running").length}}function Jct(e,t){return!!Qj(t)||Jge(e,t).failedCount>0}function FW(e){const t=new Set;return Sc(e).flatMap(n=>{const r=Ul(n),i=gn(r?r.ref:n);if(!i||t.has(i))return[];t.add(i);const s=gn(r==null?void 0:r.kind),a=s==="tool"||i.startsWith("veadk_tool:")?"tool":s==="knowledge_base"||i.startsWith("agentkit_kb:")?"knowledge_base":"skill",l=i.split(":");return[{ref:i,kind:a,name:gn(r==null?void 0:r.name)||l[l.length-1]||i,description:gn(r==null?void 0:r.description),version:gn(r==null?void 0:r.version),source:gn(r==null?void 0:r.source)}]})}function zW(e){const t=new Set;return Sc(e).flatMap(n=>{const r=Ul(n),i=gn(r==null?void 0:r.name),s=gn(r==null?void 0:r.code),a=`${i}\0${s}`;return!r||!i||t.has(a)?[]:(t.add(a),[{name:i,description:gn(r.description),code:s,entrypoint:gn(r.entrypoint)||i,dependencies:Sc(r.dependencies).map(gn).filter(Boolean)}])})}function eut({branch:e}){return o.jsxs("div",{className:`branch-compare__body${e.status==="running"?" is-streaming":""}`,"aria-live":"polite",children:[e.content?o.jsx(Ou,{text:e.content,streaming:e.status==="running"}):null,e.status==="running"?o.jsx("span",{className:"branch-compare__caret","aria-hidden":"true"}):null,e.error?o.jsx("p",{className:"branch-compare__error",children:e.error}):null]})}function tut({args:e,response:t,status:n,onBranchSelect:r}){const i=p.useMemo(()=>Ele(e,t,n),[e,t,n]),[s,a]=p.useState(0);return o.jsxs("section",{className:"branch-compare","aria-label":"分支对比",children:[o.jsx("div",{className:"branch-compare__tabs",role:"tablist","aria-label":"选择方向",children:i.branches.map((l,c)=>o.jsx("button",{className:`branch-compare__tab${s===c?" is-active":""}`,type:"button",role:"tab","aria-selected":s===c,"aria-controls":`branch-compare-panel-${c}`,onClick:()=>a(c),children:o.jsx(sa,{color:"info",size:"sm",variant:"soft",children:l.label})},`${l.label}:${c}`))}),o.jsx("div",{className:"branch-compare__branches",children:i.branches.map((l,c)=>o.jsxs("article",{className:`branch-compare__branch${s===c?" is-active":""}`,id:`branch-compare-panel-${c}`,role:"tabpanel",children:[o.jsx("header",{className:"branch-compare__head",children:o.jsx(sa,{color:"info",size:"sm",variant:"soft",children:l.label})}),o.jsx(eut,{branch:l}),o.jsx("footer",{className:"branch-compare__footer",children:o.jsx(jt,{type:"button",color:"info",variant:"ghost",size:"sm",pill:!1,disabled:l.status!=="completed",onClick:()=>r==null?void 0:r(l),children:"继续这个方向"})})]},`${l.label}:${c}`))})]})}function e0e({controlled:e,default:t,name:n,state:r="value"}){const{current:i}=p.useRef(e!==void 0),[s,a]=p.useState(t),l=i?e:s,c=p.useCallback(u=>{i||a(u)},[]);return[l,c]}const LB={...r0},VW={};function qg(e,t){const n=p.useRef(VW);return n.current===VW&&(n.current=e(t)),n}const SD=LB.useInsertionEffect,nut=SD&&SD!==LB.useLayoutEffect?SD:e=>e();function Da(e){const t=qg(rut).current;return t.next=e,nut(t.effect),t.trampoline}function rut(){const e={next:void 0,callback:iut,trampoline:(...t)=>{var n;return(n=e.callback)==null?void 0:n.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function iut(){}const sut=()=>{},Jo=typeof document<"u"?p.useLayoutEffect:sut,t0e=p.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function aut(){return p.useContext(t0e)}function out(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,s=Da(i),[,a]=p.useState(!1),l=qg(cut).current,c=qg(lut).current,u=p.useRef(0),d=p.useRef(!0),f=p.useRef([]),h=p.useRef(null),m=Da(()=>{d.current||(d.current=!0,a(S=>!S))}),g=Da((S,E)=>{c.set(S,E),m()}),b=Da(S=>{c.delete(S),m()}),y=Da(S=>{const E=new Map;return n.current.length=0,r&&(r.current.length=0),S.forEach(k=>{var _,T;E.set(k.element,{...k.registration.metadata??{},index:k.index}),n.current[k.index]=k.element,r&&(r.current[k.index]=k.registration.label!==void 0?k.registration.label:((T=(_=k.registration.textRef)==null?void 0:_.current)==null?void 0:T.textContent)??k.element.textContent)}),u.current=n.current.length,E});function O(S){var _;if((_=h.current)==null||_.disconnect(),h.current=null,typeof MutationObserver!="function"||S.length<2)return;const E=new MutationObserver(T=>{if(!fut(T))return;let C=null;for(const A of S)if(A.isConnected){if(C&&n0e(C,A)>0){E.disconnect(),m();return}C=A}});h.current=E;const k=new Set;for(let T=1;TE.observe(T,{childList:!0}))}const v=Da(()=>{const[S,E]=uut(c),k=y(S);O(E),f.current=S,d.current=!1,l.forEach(_=>_(k)),s(k)});Jo(()=>(d.current||y(f.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,y]),Jo(()=>{d.current&&v()}),Jo(()=>()=>{var S;(S=h.current)==null||S.disconnect(),d.current=!0},[]);const x=Da(S=>(l.add(S),()=>{l.delete(S)})),w=p.useMemo(()=>({register:g,unregister:b,subscribeMapChange:x,nextIndexRef:u}),[g,b,x,u]);return o.jsx(t0e.Provider,{value:w,children:t})}function lut(){return new Map}function cut(){return new Set}function uut(e){const t=new Set,n=[],r=[];e.forEach((s,a)=>{if(!a.isConnected)return;const l=s.index,c={index:l??-1,element:a,registration:s};l===null?r.push(c):l>=0&&(t.add(l),n.push(c))});let i=0;return r.sort((s,a)=>n0e(s.element,a.element)),r.forEach(s=>{for(;t.has(i);)i+=1;s.index=i,n.push(s),i+=1}),t.size>0&&n.sort((s,a)=>s.index-a.index),[n,r.map(s=>s.element)]}function dut(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function fut(e){for(const t of e)for(let n=0;ns.searchParams.append("args[]",a)),`${t} error #${r}; visit ${s} for the full message.`}}const jE=hut("https://base-ui.com/production-error","Base UI"),r0e=p.createContext(void 0);function i0e(){const e=p.useContext(r0e);if(e===void 0)throw new Error(jE(10));return e}function aA(e,t,n,r){const i=qg(s0e).current;return mut(i,e,t,n,r)&&a0e(i,[e,t,n,r]),i.callback}function put(e){const t=qg(s0e).current;return gut(t,e)&&a0e(t,e),t.callback}function s0e(){return{callback:null,cleanup:null,refs:[]}}function mut(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function gut(e,t){return e.refs.length!==t.length||e.refs.some((n,r)=>n!==t[r])}function a0e(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const r=Array(t.length).fill(null);for(let i=0;i{for(let i=0;i=e}function HW(e){if(!p.isValidElement(e))return null;const t=e,n=t.props;return(yut(19)?n==null?void 0:n.ref:t.ref)??null}function EL(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}const Out=Object.freeze([]),Xb=Object.freeze({});function xut(e,t){const n={};for(const r in e){const i=e[r];if(t!=null&&t.hasOwnProperty(r)){const s=t[r](i);s!=null&&Object.assign(n,s);continue}i===!0?n[`data-${r.toLowerCase()}`]="":i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function vut(e,t){return typeof e=="function"?e(t):e}function o0e(e,t){return typeof e=="function"?e(t):e}const $B={};function BB(e,t,n,r,i){if(!n&&!r&&!e)return oA(t);let s=oA(e);return t&&(s=dT(s,t)),n&&(s=dT(s,n)),r&&(s=dT(s,r)),s}function wut(e){if(e.length===0)return $B;if(e.length===1)return oA(e[0]);let t=oA(e[0]);for(let n=1;n=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function QB(e){return typeof e=="function"}function c0e(e,t){return QB(e)?e(t):e??$B}function kut(e,t){return t?e?(...n)=>{const r=n[0];if(f0e(r)){const s=r;lA(s);const a=t(...n);return s.baseUIHandlerPrevented||e==null||e(...n),a}const i=t(...n);return e==null||e(...n),i}:u0e(t):e}function u0e(e){return e&&((...t)=>{const n=t[0];return f0e(n)&&lA(n),e(...t)})}function lA(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function d0e(e,t){return t?e?t+" "+e:t:e}function f0e(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function RE(e,t,n={}){const r=t.render,i=_ut(t,n);if(n.enabled===!1)return null;const s=n.state??Xb;return Aut(e,r,i,s)}function _ut(e,t={}){const{className:n,style:r,render:i}=e,{state:s=Xb,ref:a,props:l,stateAttributesMapping:c,enabled:u=!0}=t,d=u?vut(n,s):void 0,f=u?o0e(r,s):void 0,h=u?xut(s,c):Xb,m=u&&l?Tut(l):void 0,g=u?EL(h,m)??{}:Xb;return typeof document<"u"&&(u?Array.isArray(a)?g.ref=put([g.ref,HW(i),...a]):g.ref=aA(g.ref,HW(i),a):aA(null,null)),u?(d!==void 0&&(g.className=d0e(g.className,d)),f!==void 0&&(g.style=EL(g.style,f)),g):Xb}function Tut(e){return Array.isArray(e)?wut(e):BB(void 0,e)}const Cut=Symbol.for("react.lazy");function Aut(e,t,n,r){if(t){if(typeof t=="function")return t(n,r);const i=BB(n,t.props);i.ref=n.ref;let s=t;return(s==null?void 0:s.$$typeof)===Cut&&(s=p.Children.toArray(t)[0]),p.cloneElement(s,i)}if(e&&typeof e=="string")return Nut(e,n);throw new Error(jE(8))}function Nut(e,t){return e==="button"?p.createElement("button",{type:"button",...t,key:t.key}):e==="img"?p.createElement("img",{alt:"",...t,key:t.key}):p.createElement(e,t)}const jut={value:()=>null},h0e=p.forwardRef(function(t,n){const{render:r,className:i,disabled:s=!1,hiddenUntilFound:a,keepMounted:l,loopFocus:c,onValueChange:u,multiple:d=!1,orientation:f="vertical",value:h,defaultValue:m,style:g,...b}=t,y=p.useMemo(()=>{if(h===void 0)return m??[]},[h,m]),O=p.useRef([]),[v,x]=e0e({controlled:h,default:y,name:"Accordion",state:"value"}),w=Da((_,T,C)=>{if(d)if(T){const A=v.slice();if(A.push(_),u==null||u(A,C),C.isCanceled)return;x(A)}else{const A=v.filter(R=>R!==_);if(u==null||u(A,C),C.isCanceled)return;x(A)}else{const A=v[0]===_?[]:[_];if(u==null||u(A,C),C.isCanceled)return;x(A)}}),S=p.useMemo(()=>({value:v,disabled:s,orientation:f}),[v,s,f]),E=p.useMemo(()=>({disabled:s,handleValueChange:w,hiddenUntilFound:a??!1,keepMounted:l??!1,state:S,value:v}),[s,w,a,l,S,v]),k=RE("div",t,{state:S,ref:n,props:b,stateAttributesMapping:jut});return o.jsx(r0e.Provider,{value:E,children:o.jsx(out,{elementsRef:O,children:k})})});let qW=0;function Rut(e,t="mui"){const[n,r]=p.useState(e),i=e||n;return p.useEffect(()=>{n==null&&(qW+=1,r(`${t}-${qW}`))},[n,t]),i}const XW=LB.useId;function Iut(e,t){if(XW!==void 0){const n=XW();return`${t}-${n}`}return Rut(e,t)}function kL(e){return Iut(e,"base-ui")}const Dut="none",Put="trigger-press";function p0e(e,t,n,r){let i=!1,s=!1;const a=Xb;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){s=!0},get isCanceled(){return i},get isPropagationAllowed(){return s},trigger:n,...a}}function Mut(e){p.useEffect(e,Out)}const N2=null;let Lut=class{constructor(){wr(this,"callbacks",[]);wr(this,"callbacksCount",0);wr(this,"nextId",1);wr(this,"startId",1);wr(this,"isScheduled",!1);wr(this,"tick",t=>{var i;this.isScheduled=!1;const n=this.callbacks,r=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,r>0)for(let s=0;s=this.callbacks.length||(this.callbacks[n]=null,this.callbacksCount-=1)}},j2=new Lut;class Cl{constructor(){wr(this,"currentId",N2);wr(this,"cancel",()=>{this.currentId!==N2&&(j2.cancel(this.currentId),this.currentId=N2)});wr(this,"disposeEffect",()=>this.cancel)}static create(){return new Cl}static request(t){return j2.request(t)}static cancel(t){return j2.cancel(t)}request(t){this.cancel(),this.currentId=j2.request(()=>{this.currentId=N2,t()})}}function $ut(){const e=qg(Cl.create).current;return Mut(e.disposeEffect),e}function But(e,t=!1,n=!1){const[r,i]=p.useState(e&&t?"idle":void 0),[s,a]=p.useState(e);return e&&!s&&(a(!0),i("starting")),!e&&s&&r!=="ending"&&!n&&i("ending"),!e&&!s&&r==="ending"&&i(void 0),Jo(()=>{if(!e&&s&&r!=="ending"&&n){const l=Cl.request(()=>{i("ending")});return()=>{Cl.cancel(l)}}},[e,s,r,n]),Jo(()=>{if(!e||t)return;const l=Cl.request(()=>{i(void 0)});return()=>{Cl.cancel(l)}},[t,e]),Jo(()=>{if(!e||!t)return;e&&s&&r!=="idle"&&i("starting");const l=Cl.request(()=>{i("idle")});return()=>{Cl.cancel(l)}},[t,e,s,r]),{mounted:s,setMounted:a,transitionStatus:r}}function Qut(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:i}=e,[s,a]=e0e({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=But(s,!0,!0),d=kL(),[f,h]=p.useState(),m=f===null?void 0:f??d,g=Da(b=>{const y=!s,O=p0e(Put,b.nativeEvent);r(y,O),!O.isCanceled&&a(y)});return p.useMemo(()=>({defaultPanelId:d,disabled:i,handleTrigger:g,mounted:l,open:s,panelId:m,setMounted:c,setOpen:a,setPanelIdState:h,transitionStatus:u}),[d,i,g,l,s,m,c,a,h,u])}const m0e=p.createContext(void 0);function g0e(){const e=p.useContext(m0e);if(e===void 0)throw new Error(jE(15));return e}function Uut(e={}){const{guess:t,label:n,metadata:r,textRef:i,index:s}=e,{register:a,unregister:l,subscribeMapChange:c,nextIndexRef:u}=aut(),d=p.useRef(-1),[f,h]=p.useState(s==null&&t?()=>{if(d.current===-1){const y=u.current;u.current+=1,d.current=y}return d.current}:-1),m=s??f,g=p.useRef(null),b=p.useCallback(y=>{const O=g.current;O&&l(O),g.current=y,y&&a(y,{metadata:r??null,index:s??null,label:n,textRef:i})},[s,a,l,r,n,i]);return Jo(()=>{if(s==null)return c(y=>{var v;const O=g.current?(v=y.get(g.current))==null?void 0:v.index:null;O!=null&&h(O)})},[s,c]),{ref:b,index:m}}const b0e=p.createContext(void 0);function UB(){const e=p.useContext(b0e);if(e===void 0)throw new Error(jE(9));return e}let GW=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const Fut={"data-starting-style":""},zut={"data-ending-style":""},Vut={transitionStatus(e){return e==="starting"?Fut:e==="ending"?zut:null}};let FB=function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=GW.startingStyle]="startingStyle",e[e.endingStyle=GW.endingStyle]="endingStyle",e}({}),Hut=function(e){return e.panelOpen="data-panel-open",e}({});const qut={[FB.open]:""},Xut={[FB.closed]:""},Gut={open(e){return e?{[Hut.panelOpen]:""}:null}},Wut={open(e){return e?qut:Xut}};let Yut=function(e){return e.index="data-index",e.disabled="data-disabled",e.open="data-open",e}({});const zB={...Wut,index:e=>({[Yut.index]:String(e)}),...Vut,value:()=>null},y0e=p.forwardRef(function(t,n){const{className:r,disabled:i=!1,onOpenChange:s,render:a,value:l,style:c,...u}=t,{ref:d,index:f}=Uut(),h=aA(n,d),{disabled:m,handleValueChange:g,state:b,value:y}=i0e(),O=kL(),v=l??O,x=i||m,w=y.indexOf(v)!==-1,S=Da((N,j)=>{s==null||s(N,j),!j.isCanceled&&g(v,N,j)}),E=Qut({open:w,onOpenChange:S,disabled:x}),k=p.useMemo(()=>({open:E.open,disabled:E.disabled,transitionStatus:E.transitionStatus}),[E.open,E.disabled,E.transitionStatus]),_=p.useMemo(()=>({...E,onOpenChange:S,state:k}),[E,k,S]),T=p.useMemo(()=>({...b,hidden:!w&&!E.mounted,index:f,disabled:x,open:w}),[E.mounted,x,f,w,b]),C=kL(),[A,R]=p.useState(),M=A===null?void 0:A??C,I=p.useMemo(()=>({defaultTriggerId:C,open:w,state:T,setTriggerId:R,triggerId:M}),[C,w,T,R,M]),$=RE("div",t,{state:T,ref:h,props:u,stateAttributesMapping:zB});return o.jsx(m0e.Provider,{value:_,children:o.jsx(b0e.Provider,{value:I,children:$})})}),O0e=p.forwardRef(function(t,n){const{render:r,className:i,style:s,...a}=t,{state:l}=UB();return RE("h3",t,{state:l,ref:n,props:a,stateAttributesMapping:zB})}),Zut=p.createContext(void 0);function Kut(e=!1){const t=p.useContext(Zut);if(t===void 0&&!e)throw new Error(jE(16));return t}function Jut(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:s}=e,a=r&&t!==!1,l=r&&t===!1;return{props:p.useMemo(()=>{const u={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(u.tabIndex=i,!s&&n&&(u.tabIndex=t?i:-1)),(s&&(t||a)||!s&&n)&&(u["aria-disabled"]=n),s&&(!t||l)&&(u.disabled=n),u},[r,n,t,a,l,s,i])}}function ED(e,t,{detail:n=0}={}){e.dispatchEvent(new(Ka(e)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function edt(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:s}=e,a=p.useRef(null),l=Kut(!0),c=s??l!==void 0,{props:u}=Jut({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),d=p.useCallback(()=>{const m=a.current;kD(m)&&c&&t&&u.disabled===void 0&&m.disabled&&(m.disabled=!1)},[t,u.disabled,c]);Jo(d,[d]);const f=p.useCallback((m={})=>{const{onClick:g,onMouseDown:b,onKeyUp:y,onKeyDown:O,onPointerDown:v,...x}=m;return BB({onClick(w){if(t){w.preventDefault();return}g==null||g(w)},onMouseDown(w){t||b==null||b(w)},onKeyDown(w){if(t||(lA(w),O==null||O(w),w.baseUIHandlerPrevented))return;const S=w.target===w.currentTarget,E=w.currentTarget,k=kD(E),_=!i&&tdt(E),T=S&&(i?k:!_),C=w.key==="Enter",A=w.key===" ",R=E.getAttribute("role"),M=(R==null?void 0:R.startsWith("menuitem"))||R==="option"||R==="gridcell";if(S&&c&&A){if(w.defaultPrevented&&M)return;w.preventDefault(),(!i||k)&&(w.preventBaseUIHandler(),ED(E,w));return}if(!T||i||!A&&!C){S&&_&&A&&w.preventDefault();return}w.defaultPrevented||(w.preventDefault(),C&&(w.preventBaseUIHandler(),ED(E,w)))},onKeyUp(w){if(!t){if(lA(w),y==null||y(w),w.target===w.currentTarget&&i&&c&&kD(w.currentTarget)&&w.key===" "){w.preventDefault();return}w.baseUIHandlerPrevented||w.target===w.currentTarget&&!i&&!c&&!w.defaultPrevented&&w.key===" "&&(w.preventBaseUIHandler(),ED(w.currentTarget,w))}},onPointerDown(w){if(t){w.preventDefault();return}v==null||v(w)}},i?{type:"button"}:{role:"button"},u,x)},[t,u,c,i]),h=Da(m=>{a.current=m,d()});return{getButtonProps:f,buttonRef:h}}function kD(e){return _d(e)&&e.tagName==="BUTTON"}function tdt(e){return _d(e)&&e.tagName==="A"&&!!e.href}const x0e=p.forwardRef(function(t,n){const{disabled:r,className:i,id:s,render:a,nativeButton:l=!0,style:c,...u}=t,{panelId:d,open:f,handleTrigger:h,disabled:m}=g0e(),g=r||m,{getButtonProps:b,buttonRef:y}=edt({disabled:g,focusableWhenDisabled:!0,native:l}),{defaultTriggerId:O,state:v,setTriggerId:x}=UB(),w=s||void 0,S=w??O;return Jo(()=>(x(_=>w??(_===null?void 0:_)),()=>{x(_=>_===w?null:_)}),[w,x]),RE("button",t,{state:v,ref:[n,y],props:[{"aria-controls":f?d:void 0,"aria-expanded":f,id:S,onClick:h},u,b],stateAttributesMapping:Gut})});function ndt(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function rdt(e){const t=qg(idt,e).current;return t.next=e,Jo(t.effect),t}function idt(e){const t={current:e,next:e,effect:()=>{t.current=t.next}};return t}function sdt(e){return e==null?e:"current"in e?e.current:e}function v0e(e,t=!1){const n=$ut();return Da((r,i=null)=>{n.cancel();const s=sdt(e);if(s==null)return;const a=s,l=()=>{kr.flushSync(r)};if(typeof a.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){r();return}function c(){Promise.all(a.getAnimations().map(u=>u.finished)).then(()=>{i!=null&&i.aborted||l()},()=>{if(i!=null&&i.aborted)return;if(a.getAnimations().some(d=>d.pending||d.playState!=="finished")){c();return}l()})}if(t){const u="data-starting-style";if(!a.hasAttribute(u)){n.request(c);return}const d=new MutationObserver(()=>{a.hasAttribute(u)||(d.disconnect(),c())});d.observe(a,{attributes:!0,attributeFilter:[u]}),i==null||i.addEventListener("abort",()=>d.disconnect(),{once:!0});return}n.request(c)})}function adt(e){const{enabled:t=!0,open:n,ref:r,onComplete:i}=e,s=Da(i),a=v0e(r,n);p.useEffect(()=>{if(!t)return;const l=new AbortController;return a(s,l.signal),()=>{l.abort()}},[t,n,s,a])}const dx={height:void 0,width:void 0};function odt(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:i,mounted:s,onOpenChange:a,open:l,setMounted:c,setOpen:u,transitionStatus:d}=e,f=p.useRef(null),h=p.useRef(null),[m,g]=p.useState(dx),b=p.useRef(dx),y=p.useRef(!1),O=p.useRef(l),v=p.useRef(!1),[x,w]=p.useState(!1),S=p.useRef(null),E=aA(t,f),k=rdt(l),_=v0e(f),T=!l&&!s,C=x?"idle":d,A=l&&(O.current||v.current),R=!l&&s&&h.current==="css-animation"&&m.height===void 0&&m.width===void 0?b.current:m,M=n&&T&&h.current!=="css-animation",I=Da((F,L=!0)=>{L&&(b.current=F),g(F)}),$=Da(()=>{var F;(F=S.current)==null||F.call(S),S.current=null}),N=Da(F=>{$(),S.current=()=>{S.current=null,F()}}),j=Da(()=>{l&&s&&h.current==="css-animation"&&(v.current=!0)});Jo(()=>{!x||d==="starting"||w(!1)},[x,d]),p.useEffect(()=>()=>{j(),$()},[j,$]),Jo(()=>{const F=f.current;if(!F)return;!l&&S.current&&$();const L=ldt(F,A);if(h.current=L,l&&d==="idle"&&O.current&&L==="css-animation"){b.current=J0(F);return}if(l&&d==="starting"){const Q=y.current;if(y.current=!1,L==="none"){I(J0(F)),w(!0);return}if(L==="css-transition"){const se=cdt(F);if(I(J0(F)),!Q)return se;const ge=R2(F,"transition-duration","0s");return N(ge),w(!0),se}I(J0(F));const V=R2(F,"animation-name","none");if(!Q){V();return}const K=R2(F,"animation-duration","0s");V(),N(K),w(!0);return}if(!l&&s&&(d==="idle"||d==="starting")){if(O.current=!1,v.current=!1,L==="none"){I(dx,!1),c(!1);return}I(J0(F));return}if(d!=="ending")return;if(L==="none"){c(!1);return}const H=J0(F);if(!(H.height>0||H.width>0)){c(!1);return}I(H),L==="css-animation"&&R2(F,"animation-name","none")()},[s,l,$,I,c,N,A,d]),adt({enabled:l&&s&&C==="idle",open:!0,ref:f,onComplete(){l&&I(dx,!1)}}),p.useEffect(()=>{if(l||!s||C!=="ending"||!f.current)return;const L=new AbortController;let H=-1;function z(){k.current||(c(!1),I(dx,!1))}return H=Cl.request(()=>{_(z,L.signal)}),()=>{Cl.cancel(H),L.abort()}},[k,s,l,C,_,I,c]),Jo(()=>{const F=f.current;!F||!n||!T||F.setAttribute("hidden","until-found")},[T,n]),p.useEffect(function(){const L=f.current;if(!L)return;function H(z){const Q=p0e(Dut,z);a(!0,Q),!Q.isCanceled&&(y.current=!0,u(!0))}return ndt(L,"beforematch",H)},[a,u]);const B=i||n||s||l;return{height:R.height,props:{...M?{[FB.startingStyle]:""}:void 0,hidden:T,id:r},ref:E,shouldPreventOpenAnimation:A,shouldRender:B,transitionStatus:C,width:R.width}}function J0(e){return{height:e.scrollHeight,width:e.scrollWidth}}function ldt(e,t){const n=Ka(e).getComputedStyle(e),r=(n.animationName.split(",").map(s=>s.trim()).some(s=>s!==""&&s!=="none")||t)&&WW(n.animationDuration),i=WW(n.transitionDuration);return r&&i||i?"css-transition":r?"css-animation":"none"}function WW(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function R2(e,t,n){const r=e.style.getPropertyValue(t),i=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,i)}}function cdt(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(i=>{e.style.setProperty(i,"initial","important")});function n(){Object.entries(t).forEach(([i,s])=>{if(s===""){e.style.removeProperty(i);return}e.style.setProperty(i,s)})}const r=Cl.request(n);return()=>{Cl.cancel(r),n()}}let YW=function(e){return e.accordionPanelHeight="--accordion-panel-height",e.accordionPanelWidth="--accordion-panel-width",e}({});const w0e=p.forwardRef(function(t,n){const{className:r,hiddenUntilFound:i,keepMounted:s,id:a,render:l,style:c,...u}=t,{hiddenUntilFound:d,keepMounted:f}=i0e(),{defaultPanelId:h,mounted:m,onOpenChange:g,open:b,setMounted:y,setOpen:O,setPanelIdState:v,transitionStatus:x}=g0e(),w=i??d,S=s??f,E=a||void 0,k=a??h;Jo(()=>(v(L=>E??(L===null?void 0:L)),()=>{v(L=>L===E?null:L)}),[E,v]);const{height:_,props:T,ref:C,shouldPreventOpenAnimation:A,shouldRender:R,transitionStatus:M,width:I}=odt({externalRef:n,hiddenUntilFound:w,id:k,keepMounted:S,mounted:m,onOpenChange:g,open:b,setMounted:y,setOpen:O,transitionStatus:x}),{state:$,triggerId:N}=UB(),j={...$,transitionStatus:M},B=o0e(c,j),F=RE("div",{...t,style:void 0},{state:j,ref:C,props:[T,{"aria-labelledby":N,role:"region",style:{[YW.accordionPanelHeight]:_===void 0?"auto":`${_}px`,[YW.accordionPanelWidth]:I===void 0?"auto":`${I}px`}},u,B?{style:B}:void 0,A?{style:{animationName:"none"}}:void 0],stateAttributesMapping:zB});return R?F:null}),udt=(e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=ddt(r,n.getBoundingClientRect()),s=fdt(r,i),a=hdt(t.getBoundingClientRect());return mdt([...s,...a])};function ddt(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function fdt(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function hdt(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function pdt(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;sr!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(i=!i)}return i}function mdt(e){const t=e.slice();return t.sort((n,r)=>n.xr.x?1:n.yr.y?1:0),gdt(t)}function gdt(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}const bdt="_Transition_1wdpp_1",ydt="_Popover_1wdpp_3",S0e={Transition:bdt,Popover:ydt},E0e=p.createContext(null),Uj=()=>{const e=p.use(E0e);if(!e)throw new Error("Popover components must be wrapped in ");return e},Rp=({open:e,onOpenChange:t,showOnHover:n=!1,hoverOpenDelay:r=150,children:i})=>{const[s,a]=p.useState(!1),[l,c]=p.useState(!1),u=p.useRef(null),d=p.useRef(null),f=p.useRef(void 0),h=p.useRef(!1),m=p.useRef(!1),g=e??s,[b,y]=p.useState(!1);T9(()=>y(!1),b?500:null);const O=Gp(t),v=Gp(k=>{var _,T;clearTimeout(f.current),g!==k&&(k||(c(!1),n&&h.current&&((_=u.current)==null||_.focus()),h.current=!1),(T=O.current)==null||T.call(O,k),a(k),n&&y(k))}),x=p.useCallback(k=>{v.current(k)},[v]),w=p.useCallback(()=>{f.current=setTimeout(()=>x(!0),r)},[x,r]),S=p.useCallback(()=>{clearTimeout(f.current)},[]);p.useEffect(()=>()=>{clearTimeout(f.current)},[]);const E=p.useMemo(()=>({open:g,setOpen:x,shake:l,setShake:c,showOnHover:n,temporarilyPreventClickToClose:b,onTriggerEnter:w,onTriggerLeave:S,isPointerInTransitRef:m,triggerRef:u,contentRef:d,hoverOpenFocusedWithTab:h}),[g,x,l,c,n,b,h,m,w,S]);return o.jsx(E0e,{value:E,children:o.jsx(mue,{open:g,onOpenChange:x,modal:!1,children:i})})},Odt=({children:e,onPointerDown:t,onClick:n})=>{const{setOpen:r,showOnHover:i,temporarilyPreventClickToClose:s,onTriggerEnter:a,onTriggerLeave:l,isPointerInTransitRef:c,triggerRef:u,contentRef:d}=Uj(),f=p.useRef(!1),h=b=>{!(b.currentTarget.nodeName.toLocaleLowerCase()==="a")&&s&&(b.preventDefault(),b.stopPropagation())},m=b=>{b.pointerType!=="touch"&&!f.current&&!c.current&&(a(),f.current=!0)},g=()=>{f.current&&(l(),f.current=!1)};return o.jsx(gue,{asChild:!0,ref:u,onPointerDown:b=>{h(b),t==null||t(b)},onClick:b=>{h(b),n==null||n(b)},onPointerMove:i?m:void 0,onPointerLeave:i?g:void 0,onFocus:i?()=>r(!0):void 0,onBlur:i?()=>{setTimeout(()=>{var b;(b=d.current)!=null&&b.contains(document.activeElement)||r(!1)},50)}:void 0,children:e})},k0e=({children:e,avoidCollisions:t,width:n,minWidth:r,maxWidth:i,side:s,sideOffset:a=8,align:l,alignOffset:c,translucent:u,className:d,autoFocus:f=!0})=>{const{showOnHover:h,shake:m,contentRef:g}=Uj(),b=y=>{const O=g.current;if(O&&y.target===O&&y.key==="Tab"&&y.shiftKey){y.preventDefault(),y.stopPropagation();const v=Nle(O),x=v[v.length-1];x==null||x.focus()}};return p.useEffect(()=>{const y=g.current;!y||!f||y!=null&&y.contains(document.activeElement)||h||y.focus({preventScroll:!0})},[g,h,f]),o.jsx(yue,{forceMount:!0,ref:g,className:sr(S0e.Popover,d),style:d0({"popover-width":n,"popover-min-width":r,"popover-max-width":i}),onCloseAutoFocus:h?Mf:void 0,"data-animate":m?"shake":void 0,"data-translucent":u?"true":void 0,side:s,sideOffset:a,align:l,alignOffset:c??(l==="center"?0:-5),avoidCollisions:t??!0,hideWhenDetached:!0,collisionPadding:20,onOpenAutoFocus:Mf,onEscapeKeyDown:Mf,onKeyDown:b,children:e})},xdt=e=>{const{setOpen:t,triggerRef:n,contentRef:r,isPointerInTransitRef:i,hoverOpenFocusedWithTab:s}=Uj(),[a,l]=p.useState(null),c=p.useCallback(()=>{l(null),i.current=!1},[i]),u=p.useCallback((d,f)=>{const h=udt(d,f);l(h),i.current=!0},[i]);return p.useEffect(()=>()=>c(),[c]),p.useEffect(()=>{const d=n.current,f=r.current;if(!d||!f)return;const h=g=>u(g,f),m=g=>u(g,d);return d.addEventListener("pointerleave",h),f.addEventListener("pointerleave",m),()=>{d.removeEventListener("pointerleave",h),f.removeEventListener("pointerleave",m)}},[r,n,u,c]),p.useEffect(()=>{if(!a)return;const d=f=>{const h=n.current,m=r.current,g=f.target,b={x:f.clientX,y:f.clientY},y=(h==null?void 0:h.contains(g))||(m==null?void 0:m.contains(g)),O=!pdt(b,a),v=g.hasAttribute("aria-haspopup");y?c():(O||v)&&(c(),t(!1))};return document.addEventListener("pointermove",d),()=>document.removeEventListener("pointermove",d)},[a,t,c,n,r]),p.useEffect(()=>{const d=f=>{if(r.current&&f.key==="Tab"&&!f.shiftKey){const[h]=Nle(r.current);h&&(f.preventDefault(),h.focus(),s.current=!0,document.removeEventListener("keydown",d))}};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[r,s]),o.jsx(k0e,{...e})},vdt=e=>{const{open:t,showOnHover:n,setOpen:r}=Uj();return iE(t,()=>{r(!1)}),o.jsx(bue,{forceMount:!0,children:o.jsx(nO,{enterDuration:600,exitDuration:300,className:S0e.Transition,disableAnimations:!0,children:t&&(n?o.jsx(xdt,{...e},"popover-hover"):o.jsx(k0e,{...e},"popover"))})})};Rp.Trigger=Odt;Rp.Content=vdt;const wdt=[{value:"skill_hub",label:"Skill Hub"},{value:"skill_space",label:"AgentKit 技能中心"},{value:"knowledge_base",label:"知识库"},{value:"tool",label:"工具"}],_0e={llm:"LLM Agent",sequential:"顺序 Agent",parallel:"并行 Agent",loop:"循环 Agent",workflow:"Workflow"};function T0e(e){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m4 6 4 4 4-4"})})}function C0e({label:e}){return o.jsx("div",{className:"create-agent-card__loading",role:"status","aria-label":e,children:[0,1,2].map(t=>o.jsxs("div",{className:"create-agent-card__skeleton-row","aria-hidden":"true",children:[o.jsx("span",{}),o.jsx("span",{})]},t))})}function Sdt(e){return e.kind==="tool"?"内置工具":e.kind==="knowledge_base"?"知识库":e.source.startsWith("skill_hub:")?"Skill Hub":e.source.startsWith("skill_space:")?"AgentKit 技能中心":"Skill"}function _D({label:e,resources:t}){return t.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:e}),o.jsx("div",{className:"create-agent-card__popover-list",children:t.map(n=>o.jsxs("div",{className:"create-agent-card__popover-item",children:[o.jsxs("div",{className:"create-agent-card__popover-item-heading",children:[o.jsx("strong",{children:n.name}),o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:Sdt(n)})]}),n.description?o.jsx("p",{children:n.description}):null]},n.ref))})]})}function Edt({tools:e}){return e.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:"自写工具"}),o.jsx(h0e,{children:e.map((t,n)=>o.jsxs(y0e,{className:"create-agent-card__python-tool",value:`${t.name}:${n}`,children:[o.jsx(O0e,{className:"create-agent-card__python-tool-header",children:o.jsxs(x0e,{className:"create-agent-card__python-tool-trigger",children:[o.jsxs("span",{children:[o.jsx("strong",{children:t.name}),t.description?o.jsx("small",{children:t.description}):null]}),o.jsxs("span",{className:"create-agent-card__python-tool-meta",children:[o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:"自写工具"}),o.jsx(T0e,{className:"create-agent-card__python-tool-chevron"})]})]})}),o.jsxs(w0e,{className:"create-agent-card__python-tool-panel",children:[t.dependencies.length>0?o.jsxs("div",{className:"create-agent-card__python-tool-dependencies",children:["依赖:",t.dependencies.join(", ")]}):null,o.jsx("pre",{tabIndex:0,"aria-label":`${t.name} 完整代码`,children:o.jsx("code",{children:t.code})})]})]},`${t.name}:${n}`))})]})}function kdt({agents:e}){return e.length===0?null:o.jsxs("section",{className:"create-agent-card__popover-section",children:[o.jsx("h4",{children:"Sub Agent"}),o.jsx("div",{className:"create-agent-card__popover-list",children:e.map(t=>o.jsxs("div",{className:"create-agent-card__popover-item",children:[o.jsxs("div",{className:"create-agent-card__popover-item-heading",children:[o.jsx("strong",{children:t.id}),o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:_0e[t.type]??t.type})]}),t.description?o.jsx("p",{children:t.description}):null]},t.id))})]})}function I2({label:e,count:t,icon:n,children:r}){const i=o.jsxs("button",{className:"create-agent-card__resource-metric",type:"button",disabled:t===0,"aria-label":`${e} ${t} 项`,children:[n,o.jsx("span",{children:t})]});return t===0?i:o.jsxs(Rp,{showOnHover:!0,hoverOpenDelay:120,children:[o.jsx(Rp.Trigger,{children:i}),o.jsx(Rp.Content,{side:"top",align:"start",minWidth:"auto",maxWidth:360,className:"create-agent-card__resource-popover",children:r})]})}function _dt({response:e,status:t}){const n=p.useMemo(()=>Zct(e),[e]),r=p.useMemo(()=>wdt.map(a=>{const l=Kct(n,a.value);return{...a,...l,searchKeywords:[...new Set(l.sources.flatMap(c=>c.searchKeywords))]}}),[n]),i=t==="failed",s=i?Qj(e):"";return o.jsx("section",{className:"create-agent-tool-card","aria-label":"召回资源信息",children:t==="running"?o.jsx(C0e,{label:"正在检索资源"}):i?o.jsxs("div",{className:"create-agent-card__message is-error",role:"alert",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"资源检索未完成"}),o.jsx("span",{children:s||"请检查资源服务配置后重试。"})]}):o.jsx(h0e,{className:"create-agent-card__accordion",children:r.map(a=>o.jsxs(y0e,{className:"create-agent-card__accordion-item",value:a.value,children:[o.jsx(O0e,{className:"create-agent-card__accordion-header",children:o.jsxs(x0e,{className:"create-agent-card__accordion-trigger",children:[o.jsx("span",{children:a.label}),o.jsxs("span",{className:"create-agent-card__accordion-meta",children:[o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:a.sources.length===0?a.value==="skill_hub"?"未检索":"未配置":a.resources.length}),o.jsx(T0e,{className:"create-agent-card__accordion-chevron"})]})]})}),o.jsx(w0e,{className:"create-agent-card__accordion-content",children:o.jsxs("div",{className:"create-agent-card__accordion-scroll",role:"region","aria-label":`${a.label}资源列表`,tabIndex:0,children:[a.value==="skill_hub"&&a.searchKeywords.length>0?o.jsxs("div",{className:"create-agent-card__search-keywords",children:[o.jsx("span",{children:"检索关键词"}),o.jsx("span",{children:a.searchKeywords.join("、")})]}):null,a.resources.length>0?o.jsx("div",{className:"create-agent-card__resource-list",children:a.resources.map(l=>o.jsx("div",{className:"create-agent-card__resource",children:o.jsxs("div",{className:"create-agent-card__resource-main",children:[o.jsxs("div",{className:"create-agent-card__resource-title",children:[o.jsx("span",{className:"create-agent-card__resource-name",children:l.name}),l.version?o.jsx(sa,{className:"create-agent-card__resource-version",color:"secondary",size:"sm",variant:"soft",children:l.version}):null]}),l.description?o.jsx("p",{children:l.description}):null]})},l.ref))}):o.jsxs("div",{className:"create-agent-card__empty-category",children:[o.jsx("p",{children:a.sources.length===0?a.value==="skill_hub"?"未提供检索关键词,本次未检索 Skill Hub。":`未配置 ${a.label},本次未检索该来源。`:"本次检索未返回该类别的资源。"}),a.sources.filter(l=>l.message).map(l=>o.jsx("p",{className:"create-agent-card__raw-source-error",children:l.message},l.source))]})]})})]},a.value))},n.collectionId||"collected-resources")})}function Tdt({args:e,response:t,status:n}){const r=p.useMemo(()=>Jge(e,t),[e,t]),i=n==="failed"?Qj(t):"";return o.jsxs("section",{className:"create-agent-tool-card is-agent-results","aria-label":"创建 Agent 结果",children:[i?o.jsxs("div",{className:"create-agent-card__message is-error",role:"alert",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"Agent 创建未完成"}),o.jsx("span",{children:i})]}):null,r.agents.length>0?o.jsx("div",{className:"create-agent-card__agent-grid",children:r.agents.map(s=>{const a=n==="failed"?"failed":s.status,l=s.error||a==="failed"&&i,c=s.builtinTools.length+s.pythonTools.length;return o.jsxs(Z7,{className:`create-agent-card__agent-card${l?" is-error":""}`,children:[o.jsx(K7,{leading:o.jsx(u1,{seed:s.name}),title:s.name,titleText:s.name,status:o.jsx(sa,{color:"secondary",size:"sm",variant:"soft",children:_0e[s.rootType]??s.rootType})}),s.description?o.jsx(J7,{children:s.description}):null,l?o.jsx("div",{className:"create-agent-card__agent-result is-error",role:"alert",children:l}):null,o.jsxs("div",{className:"create-agent-card__agent-resources","aria-label":`${s.name} 具备的资源`,children:[o.jsx(I2,{label:"Skill",count:s.skills.length,icon:o.jsx(Q_,{"aria-hidden":"true"}),children:o.jsx(_D,{label:"Skill",resources:s.skills})}),o.jsx(I2,{label:"知识库",count:s.knowledgeBases.length,icon:o.jsx(que,{"aria-hidden":"true"}),children:o.jsx(_D,{label:"知识库",resources:s.knowledgeBases})}),o.jsxs(I2,{label:"工具",count:c,icon:o.jsx(TRe,{"aria-hidden":"true"}),children:[o.jsx(_D,{label:"内置工具",resources:s.builtinTools}),o.jsx(Edt,{tools:s.pythonTools})]}),o.jsx(I2,{label:"Sub Agent",count:s.subAgentCount,icon:o.jsx(ARe,{"aria-hidden":"true"}),children:o.jsx(kdt,{agents:s.subAgents})})]})]},s.name)})}):n==="running"?o.jsx(C0e,{label:"正在创建 Agent"}):o.jsxs("div",{className:"create-agent-card__message",children:[o.jsx("span",{className:"create-agent-card__message-title",children:"没有可展示的 Agent"}),o.jsx("span",{children:"工具返回中未包含 Agent 配置或执行结果。"})]})]})}const Cdt={web_search:{name:"web_search",runningLabel:"正在进行网络搜索",doneLabel:"已完成网络搜索",tone:"search",icon:Mct},run_code:{name:"run_code",runningLabel:"正在 AgentKit 沙箱中执行代码",doneLabel:"已在 AgentKit 沙箱中完成代码执行",tone:"sandbox",icon:Fct},list_envs:{name:"list_envs",runningLabel:"正在查看可用环境",doneLabel:"已读取可用环境",tone:"resources",icon:Vct},get_env_manifest:{name:"get_env_manifest",runningLabel:"正在读取环境 Manifest",doneLabel:"已读取环境 Manifest",tone:"knowledge",icon:Hct},execute_in_sandbox:{name:"execute_in_sandbox",runningLabel:"正在环境中执行命令",doneLabel:"已在环境中完成命令执行",tone:"sandbox",icon:qct},image_generate:{name:"image_generate",runningLabel:"正在生成图片",doneLabel:"已完成图片生成",tone:"image",icon:Lct},video_generate:{name:"video_generate",runningLabel:"正在生成视频",doneLabel:"已完成视频生成",tone:"video",icon:PB},ppt_generate:{name:"ppt_generate",runningLabel:"正在生成 PPT",doneLabel:"已完成 PPT 生成",tone:"presentation",icon:$ct},load_memory:{name:"load_memory",runningLabel:"正在检索长期记忆",doneLabel:"已完成记忆检索",tone:"memory",icon:Bct},load_knowledgebase:{name:"load_knowledgebase",runningLabel:"正在检索知识库",doneLabel:"已完成知识库检索",tone:"knowledge",icon:Qct},load_skill:{name:"load_skill",runningLabel:"正在加载技能",doneLabel:"已加载技能",tone:"skill",icon:Uct},collect_resources:{name:"collect_resources",runningLabel:"正在收集可用资源",doneLabel:"已完成资源收集",failedLabel:"资源收集失败",tone:"resources",icon:zct,detailRenderer:_dt},create_agents:{name:"create_agents",runningLabel:"正在创建并运行 Agent",doneLabel:"已完成 Agent 创建",failedLabel:"Agent 创建失败",tone:"agent",icon:QW,detailRenderer:Tdt},branch_compare:{name:"branch_compare",runningLabel:"",doneLabel:"",failedLabel:"",tone:"search",icon:QW,detailRenderer:tut,hideHeader:!0}};function Adt(e){return Cdt[e]}function A0e(e){return o.jsx("svg",{viewBox:"0 0 111 117",fill:"none","aria-hidden":"true",...e,children:o.jsx("path",{d:"M0 5.6016C7.82288e-05 0.621244 6.02226 -1.87314 9.54395 1.64847L40.1289 32.2334L68.5732 3.7891C69.5834 2.77903 70.9533 2.21099 72.3818 2.21097H82.7031C82.7917 2.20658 82.8806 2.20414 82.9697 2.20414H104.775C109.574 2.20427 111.977 8.00691 108.584 11.4004L64.916 55.0664C64.3075 55.8528 63.9436 56.7647 63.8242 57.6993C63.7142 56.4884 63.1964 55.3069 62.2695 54.3799L45.4082 37.5186H45.4072L40.124 32.2354L17.832 54.5284C16.7671 55.5933 16.2416 56.993 16.2549 58.3887C16.2417 59.7843 16.7672 61.1842 17.832 62.2491L39.9287 84.3467L9.54395 114.733C6.0223 118.255 0.000223474 115.761 0 110.78V5.6016ZM63.8018 58.8702C63.8962 59.9086 64.2936 60.9229 64.9961 61.7735L108.591 105.368C111.984 108.762 109.58 114.564 104.781 114.564H94.4336C94.3543 114.568 94.274 114.569 94.1934 114.569H72.3877C70.9592 114.569 69.5892 114.002 68.5791 112.992L39.9336 84.3467L58.4531 65.8282L58.4453 65.8203L62.2695 61.9981C63.1476 61.12 63.6567 60.0136 63.8018 58.8702Z",fill:"currentColor"})})}function Ndt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6 3h8l4 4v14H6Z"}),o.jsx("path",{d:"M14 3v5h5"}),o.jsx("path",{d:"m10 12-2 2 2 2M14 12l2 2-2 2"})]})}function jdt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M12 3 19 6v5c0 4.6-2.8 7.8-7 10-4.2-2.2-7-5.4-7-10V6l7-3Z"}),o.jsx("path",{d:"m9 12 2 2 4-4"})]})}function Rdt(e,t){const n=new Map(e.map(a=>[a.path,a.content])),r=new Map(t.map(a=>[a.path,a.content])),i=new Set([...n.keys(),...r.keys()]),s=[];for(const a of[...i].sort((l,c)=>l.localeCompare(c))){const l=n.get(a),c=r.get(a);l!==c&&s.push({path:a,status:l===void 0?"added":c===void 0?"deleted":"modified",before:l??"",after:c??""})}return s}function Idt(e){return e==="added"?"新增":e==="deleted"?"删除":"修改"}function gm(e){return{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,...e}}function N0e(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"m9 7-5 5 5 5M15 7l5 5-5 5M13.5 4l-3 16"})})}function TD(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"M6.5 3.75h7l4 4V20.25h-11zM13.5 3.75v4h4M9 12h6M9 15.5h4.5"})})}function Ddt(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"M3.75 7.25h6l1.75 2h8.75v9.25H3.75zM3.75 7.25V5.5h5l1.5 1.75"})})}function Pdt(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"m9 5 7 7-7 7"})})}function j0e(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function Mdt(e){return o.jsxs("svg",{...gm(e),children:[o.jsx("circle",{cx:"12",cy:"12",r:"3.25"}),o.jsx("path",{d:"M12 2.75v2M12 19.25v2M2.75 12h2M19.25 12h2M5.45 5.45l1.4 1.4M17.15 17.15l1.4 1.4M18.55 5.45l-1.4 1.4M6.85 17.15l-1.4 1.4"})]})}function Ldt(e){return o.jsx("svg",{...gm(e),children:o.jsx("path",{d:"M19.25 15.25A8 8 0 0 1 8.75 4.75a8 8 0 1 0 10.5 10.5Z"})})}function $dt(e){return o.jsxs("svg",{...gm(e),children:[o.jsx("path",{d:"M19.25 8.25V4.5l-1.8 1.8a7.5 7.5 0 1 0 1.8 7.65"}),o.jsx("path",{d:"M19.25 4.5H15.5"})]})}const Bdt=p.lazy(()=>fd(()=>Promise.resolve().then(()=>ave),void 0)),Qdt=p.lazy(()=>fd(()=>import("../chunks/CodeDiffEditor-DWPwBXPg.js"),[])),R0e="veadk-code-workspace-theme";function Udt(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let i=t;r.forEach((s,a)=>{let l=i.children.get(s);l||(l={name:s,children:new Map},i.children.set(s,l)),a===r.length-1&&(l.path=n.path),i=l})}return t}function Fdt(e,t=!1){return[...e.children.values()].sort((n,r)=>{const i=n.children.size>0&&n.path===void 0,s=r.children.size>0&&r.path===void 0;return i!==s?t?i?1:-1:i?-1:1:n.name.localeCompare(r.name)})}function zdt(){if(typeof window>"u")return"light";try{return window.localStorage.getItem(R0e)==="dark"?"dark":"light"}catch{return"light"}}function Vdt(e){return e===""?0:e.split(`
`).length}function Jw({project:e,open:t,onClose:n,onChange:r,readOnly:i=!1,comparison:s}){var R;const a=p.useId(),l=p.useRef(null),c=p.useRef(null),u=p.useRef(n),[d,f]=p.useState(zdt),h=p.useMemo(()=>s?Rdt(s.baseProject.files,e.files):[],[s,e.files]),m=p.useMemo(()=>s?h.map(M=>({path:M.path,content:M.status==="deleted"?M.before:M.after})):e.files,[h,s,e.files]),g=p.useMemo(()=>new Map(h.map(M=>[M.path,M.status])),[h]),[b,y]=p.useState(((R=m[0])==null?void 0:R.path)??null),[O,v]=p.useState(new Set),x=p.useMemo(()=>Udt(m),[m]),w=m.find(M=>M.path===b)??null,S=h.find(M=>M.path===b)??null;if(u.current=n,p.useEffect(()=>{try{window.localStorage.setItem(R0e,d)}catch{}},[d]),p.useEffect(()=>{var N;if(!t)return;const M=document.body.style.overflow,I=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(N=c.current)==null||N.focus();const $=j=>{if(j.key==="Escape"){j.preventDefault(),u.current();return}if(j.key!=="Tab"||!l.current)return;const B=[...l.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')].filter(H=>H.offsetParent!==null);if(B.length===0)return;const F=B[0],L=B[B.length-1];j.shiftKey&&document.activeElement===F?(j.preventDefault(),L.focus()):!j.shiftKey&&document.activeElement===L&&(j.preventDefault(),F.focus())};return window.addEventListener("keydown",$),()=>{document.body.style.overflow=M,window.removeEventListener("keydown",$),I!=null&&I.isConnected&&I.focus()}},[t]),p.useEffect(()=>{w||m.length===0||y(m[0].path)},[m,w]),!t)return null;function E(M){v(I=>{const $=new Set(I);return $.has(M)?$.delete(M):$.add(M),$})}function k(M){return M?o.jsx("span",{className:`code-browser-change is-${M}`,children:Idt(M)}):null}function _(M,I,$){return Fdt(M,I===0).map(N=>{const j=$?`${$}/${N.name}`:N.name;if(!(N.children.size>0&&N.path===void 0)&&N.path){const L=g.get(N.path);return o.jsxs("button",{type:"button",className:`code-browser-file${b===N.path?" is-active":""}`,style:{paddingLeft:`${12+I*16}px`},onClick:()=>y(N.path??null),title:N.path,"aria-pressed":b===N.path,children:[o.jsx(TD,{}),o.jsx("span",{children:N.name}),k(L)]},j)}const F=O.has(j);return o.jsxs("div",{children:[o.jsxs("button",{type:"button",className:"code-browser-folder",style:{paddingLeft:`${10+I*16}px`},onClick:()=>E(j),"aria-expanded":!F,children:[o.jsx(Pdt,{className:F?"":"is-open"}),o.jsx(Ddt,{}),o.jsx("span",{children:N.name})]}),!F&&_(N,I+1,j)]},j)})}function T(M){!w||s||r({...e,files:e.files.map(I=>I.path===w.path?{...I,content:M}:I)})}const C=d==="light"?"dark":"light",A=s?"两个版本的源码没有差异":"从左侧选择文件以查看代码";return kr.createPortal(o.jsx("div",{className:"code-browser-backdrop",onMouseDown:M=>{M.target===M.currentTarget&&n()},children:o.jsxs("section",{ref:l,className:`code-browser-dialog is-${d}`,role:"dialog","aria-modal":"true","aria-labelledby":a,children:[o.jsxs("header",{className:"code-browser-head",children:[o.jsxs("div",{className:"code-browser-title-wrap",children:[o.jsx("span",{className:"code-browser-title-icon",children:o.jsx(N0e,{})}),o.jsxs("div",{children:[o.jsx("h2",{id:a,children:s?"版本对比":"源码工作区"}),o.jsx("p",{title:e.name,children:e.name||"Agent 项目"})]})]}),o.jsxs("div",{className:"code-browser-head-actions",children:[o.jsx("button",{type:"button",className:"code-browser-icon-button",onClick:()=>f(C),"aria-label":"切换源码主题",title:`切换为${C==="dark"?"深色":"浅色"}主题`,children:d==="light"?o.jsx(Ldt,{}):o.jsx(Mdt,{})}),o.jsx("button",{ref:c,type:"button",className:"code-browser-icon-button",onClick:n,"aria-label":"关闭源码工作区",title:"关闭",children:o.jsx(j0e,{})})]})]}),o.jsxs("div",{className:"code-browser-workspace",children:[o.jsxs("aside",{className:"code-browser-sidebar","aria-label":s?"变更文件":"项目文件",children:[o.jsxs("div",{className:"code-browser-sidebar-head",children:[o.jsx("span",{children:s?"变更":"文件"}),o.jsx("span",{children:m.length})]}),o.jsx("div",{className:"code-browser-tree",children:m.length>0?_(x,0,""):o.jsx("div",{className:"code-browser-empty",children:A})})]}),o.jsxs("main",{className:"code-browser-main",children:[o.jsx("div",{className:"code-browser-tabs",role:"tablist","aria-label":"打开的文件",children:w?o.jsxs("div",{className:"code-browser-tab",role:"tab","aria-selected":"true",children:[o.jsx(TD,{}),o.jsx("span",{children:w.path.split("/").pop()}),k(S==null?void 0:S.status)]}):null}),o.jsxs("div",{className:"code-browser-path",children:[o.jsx(TD,{}),o.jsx("span",{children:(w==null?void 0:w.path)??"未选择文件"})]}),s?o.jsxs("div",{className:"code-browser-diff-labels","aria-label":"对比方向",children:[o.jsx("span",{children:s.baseLabel??"优化前"}),o.jsx("span",{children:s.targetLabel??"优化后"})]}):null,o.jsx("div",{className:"code-browser-editor",children:w?o.jsx(p.Suspense,{fallback:o.jsx("div",{className:"code-browser-empty",children:"正在加载编辑器…"}),children:S?o.jsx(Qdt,{before:S.before,after:S.after,path:S.path,theme:d}):o.jsx(Bdt,{value:w.content,path:w.path,onChange:T,readOnly:i,theme:d})}):o.jsx("div",{className:"code-browser-empty",children:A})}),o.jsxs("footer",{className:"code-browser-statusbar",children:[o.jsx("span",{children:s?`${h.length} 个文件有变更`:`${e.files.length} 个文件`}),o.jsx("span",{children:w?`${Vdt(w.content)} 行 · UTF-8`:"UTF-8"})]})]})]})]})}),document.body)}function Hdt({project:e,onChange:t,className:n="",label:r="查看源码"}){const[i,s]=p.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:`code-browser-trigger ${n}`.trim(),onClick:()=>s(!0),"aria-label":"查看和编辑项目源码",title:r,children:[o.jsx(N0e,{}),o.jsx("span",{children:r})]}),o.jsx(Jw,{project:e,open:i,onClose:()=>s(!1),onChange:t})]})}const I0e="send_a2ui_json_to_client",qdt=28,Xdt=3e3;function Gdt(e,t,n){let r=t;for(let i=0;i65535?2:1}return r}function Wdt(e){return e<=4?1:Math.min(18,Math.max(2,Math.ceil(e/6)))}function D0e(e,t,n,r){const[i,s]=p.useState(()=>t?"":e),a=p.useRef(i),l=p.useRef(e),c=p.useRef(null),u=p.useRef(0),d=p.useRef(n);return l.current=e,d.current=n,p.useEffect(()=>{const f=a.current,h=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(!t||h||!e.startsWith(f)){c.current!==null&&window.cancelAnimationFrame(c.current),c.current=null,f!==e&&(a.current=e,s(e));return}if(f===e||c.current!==null)return;const m=g=>{const b=l.current,y=a.current;if(!b.startsWith(y)){a.current=b,s(b),c.current=null;return}if(g-u.current{var f;(f=d.current)==null||f.call(d)},[i]),p.useEffect(()=>{i===e&&(r==null||r())},[i,r,e]),p.useEffect(()=>()=>{c.current!==null&&(window.cancelAnimationFrame(c.current),c.current=null)},[]),i}function Ydt(){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("path",{d:"M14.3 5.25a4.6 4.6 0 0 0-5.55 5.55L3.6 15.95a1.8 1.8 0 0 0 0 2.55l1.9 1.9a1.8 1.8 0 0 0 2.55 0l5.15-5.15a4.6 4.6 0 0 0 5.55-5.55l-2.9 2.9-2.45-.55-.55-2.45 2.9-2.9a4.6 4.6 0 0 0-1.45-1.45Z"})})}function Zdt(){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"m4.5 7 1.8 1.8L9.5 5.5"}),o.jsx("path",{d:"M12 7h7.5"}),o.jsx("path",{d:"m4.5 13 1.8 1.8 3.2-3.3"}),o.jsx("path",{d:"M12 13h7.5"}),o.jsx("path",{d:"M5 19h4"}),o.jsx("path",{d:"M12 19h7.5"})]})}function Kdt(e,t){if(e!=="load_skill"||t==null||typeof t!="object"||Array.isArray(t))return;const n=t.skill_name;if(!(typeof n!="string"||!n.trim()))return`使用 ${n.trim()} 技能`}function P0e({text:e,done:t,answerStarted:n=!1,streaming:r=!1,onStreamFrame:i}){const[s,a]=p.useState(!(t||n)),l=p.useRef(!1);p.useEffect(()=>{l.current||a(!(t||n))},[n,t]);const c=()=>{l.current=!0,a(m=>!m)},u=e.replace(/^\s+/,""),d=D0e(u,!t||r,i),{ref:f,onScroll:h}=Wge(d);return o.jsxs("div",{className:"block-thinking",children:[o.jsxs("button",{className:"think-head",onClick:c,type:"button",children:[o.jsx("span",{className:"think-icon","aria-hidden":"true",children:o.jsx(A0e,{className:`thinking-logo ${t?"":"is-active"}`})}),t?o.jsx("span",{className:"think-label think-label--done",children:"已完成思考"}):o.jsx(wn,{className:"think-label",duration:2.4,spread:18,children:"思考中"}),o.jsx(XS,{className:`chev ${s?"open":""}`})]}),o.jsx("div",{className:`think-collapse ${s&&d?"open":""}`,children:o.jsx("div",{className:"think-collapse-inner",children:o.jsx("div",{className:"think-body scroll",ref:f,onScroll:h,children:d})})})]})}function Jdt({text:e}){return o.jsx("div",{className:"block-progress",role:"status","aria-live":"polite","aria-atomic":"true",children:o.jsxs("div",{className:"think-head progress-head",children:[o.jsx("span",{className:"think-icon","aria-hidden":"true",children:o.jsx(A0e,{className:"thinking-logo is-active"})}),o.jsx(wn,{className:"think-label",duration:2.4,spread:18,children:e})]})})}function eft({value:e,onResolve:t,onResolveComparison:n,onDownload:r,onDeploy:i}){const[s,a]=p.useState(e.files?e:null),[l,c]=p.useState(!1),[u,d]=p.useState(!1),[f,h]=p.useState(null),[m,g]=p.useState(null),[b,y]=p.useState(""),[O,v]=p.useState(null),x=new Date(e.validatedAt),w=e.validatedAt?Number.isNaN(x.getTime())?e.validatedAt:x.toLocaleString("zh-CN",{hour12:!1}):"刚刚";p.useEffect(()=>{if(!O)return;const C=window.setTimeout(()=>v(null),Xdt);return()=>window.clearTimeout(C)},[O]);async function S(){if(s)return s;if(!t)throw new Error("暂时无法读取生成的源码,请稍后重试。");const C=await t(e);return a(C),C}async function E(){g("source"),y(""),v(null);try{await S(),c(!0)}catch(C){y(C instanceof Error?C.message:String(C))}finally{g(null)}}async function k(){if(r){g("download"),y(""),v(null);try{await r(e),v({message:"已开始下载"})}catch(C){y(C instanceof Error?C.message:String(C))}finally{g(null)}}}async function _(){if(n){g("compare"),y(""),v(null);try{const C=f??await n(e);h(C),d(!0)}catch(C){y(C instanceof Error?C.message:String(C))}finally{g(null)}}}async function T(){g("deploy"),y(""),v(null);try{i==null||i(await S())}catch(C){y(C instanceof Error?C.message:String(C))}finally{g(null)}}return o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:`delivery-card${e.verified?" is-verified":" is-unverified"}`,"aria-label":e.verified?"已验证交付物":"生成的 Agent 源码",children:[o.jsxs("header",{className:"delivery-card-header",children:[o.jsx("span",{className:"delivery-card-icon",children:e.verified?o.jsx(jdt,{}):o.jsx(Ndt,{})}),o.jsxs("div",{children:[o.jsx("strong",{children:e.verified?"已验证交付物":"生成的 Agent 源码"}),o.jsx("span",{children:e.agentName})]})]}),o.jsxs("dl",{className:"delivery-card-grid",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"入口"}),o.jsx("dd",{children:o.jsx("code",{children:e.entryPoint})})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"文件数"}),o.jsx("dd",{children:e.fileCount})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"大小"}),o.jsxs("dd",{children:[(e.artifactSize/1024).toFixed(1)," KiB"]})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e.verified?"验证时间":"生成时间"}),o.jsx("dd",{children:w})]})]}),o.jsxs("p",{className:"delivery-card-gates",children:[e.verified?`${e.gateSummary.length} 项检查通过`:"源码已准备好,可部署"," ·"," ",o.jsx("code",{children:e.artifactSha256.slice(0,12)})]}),e.verified?null:o.jsx("p",{className:"delivery-card-guidance",children:"源码已准备好,可查看、下载或部署;部署前请确认 Runtime 配置。"}),o.jsxs("div",{className:"delivery-card-actions",children:[o.jsxs("button",{type:"button",className:"delivery-card-secondary",onClick:()=>void E(),disabled:!t||m!==null,children:[m==="source"?o.jsx(rr,{className:"spin","aria-hidden":"true"}):null,"查看源码"]}),e.projectId&&e.versionId&&e.parentVersionId?o.jsxs("button",{type:"button",className:"delivery-card-secondary",onClick:()=>void _(),disabled:!n||m!==null,children:[m==="compare"?o.jsx(rr,{className:"spin","aria-hidden":"true"}):null,m==="compare"?"正在准备…":"查看本次变更"]}):null,o.jsxs("button",{type:"button",className:"delivery-card-secondary",onClick:()=>void k(),disabled:!r||m!==null,"aria-busy":m==="download",children:[m==="download"?o.jsx(rr,{className:"spin","aria-hidden":"true"}):null,m==="download"?"正在准备…":"下载源码"]}),o.jsxs("button",{type:"button",onClick:()=>void T(),disabled:!e.deployable||!i||!t||m!==null,title:e.deployable?void 0:"源码尚未准备好",children:[m==="deploy"?o.jsx(rr,{className:"spin","aria-hidden":"true"}):null,"手动部署到 Runtime"]})]}),b?o.jsx("p",{className:"delivery-card-error",role:"alert",children:b}):null,O?o.jsx("p",{className:"delivery-card-status",role:"status","aria-live":"polite",children:O.message}):null]}),o.jsx(Jw,{project:{name:e.agentName,files:(s==null?void 0:s.files)??[]},open:l,onClose:()=>c(!1),onChange:()=>{},readOnly:!0}),o.jsx(Jw,{project:{name:(f==null?void 0:f.target.agentName)??e.agentName,files:(f==null?void 0:f.target.files)??[]},comparison:f?{baseProject:{name:f.base.agentName,files:f.base.files??[]},baseLabel:"优化前",targetLabel:"优化后"}:void 0,open:u,onClose:()=>d(!1),onChange:()=>{},readOnly:!0})]})}function M0e(){return o.jsx(P0e,{text:"",done:!1})}const tft=p.memo(function({text:t,streaming:n,onStreamFrame:r,onStreamComplete:i}){const s=D0e(t,n,r,i);return s?o.jsx("div",{className:"bubble",children:o.jsx(Ou,{text:s,streaming:n})}):null}),nft={pending:"待处理",in_progress:"进行中",completed:"已完成",failed:"未完成"};function rft({title:e,summary:t,items:n,done:r}){const[i,s]=p.useState(!r),a=p.useRef(!1);p.useEffect(()=>{a.current||s(!r)},[r]);const l=()=>{a.current=!0,s(c=>!c)};return o.jsxs("div",{className:"block-plan",children:[o.jsxs("button",{className:"plan-head",type:"button",onClick:l,"aria-expanded":n.length>0?i:void 0,disabled:n.length===0,children:[o.jsx("span",{className:"plan-icon","aria-hidden":"true",children:o.jsx(Zdt,{})}),r?o.jsx("span",{className:"plan-title",children:e}):o.jsx(wn,{className:"plan-title",duration:2.2,spread:15,children:e}),t?o.jsx("span",{className:"plan-summary",children:t}):null,n.length>0?o.jsx(MB,{className:`plan-chevron${i?" is-open":""}`}):null]}),o.jsx("div",{className:`think-collapse ${i&&n.length>0?"open":""}`,children:o.jsx("div",{className:"think-collapse-inner",children:n.length>0?o.jsx("ol",{className:"plan-items",children:n.map((c,u)=>o.jsxs("li",{"data-status":c.status,children:[o.jsx("span",{className:"plan-item-marker","aria-hidden":"true"}),o.jsx("span",{className:"plan-item-text",children:c.text}),o.jsx("small",{children:nft[c.status]})]},`${u}:${c.text}`))}):null})})]})}function ift(e){if(!e||typeof e!="object")return[];const t=e,n=t.result;let r=[];if(Array.isArray(t.studio_artifacts))r=t.studio_artifacts;else if(n&&typeof n=="object"){const i=n.studio_artifacts;Array.isArray(i)&&(r=i)}return r.flatMap(i=>{if(!i||typeof i!="object")return[];const s=i;return typeof s.name=="string"&&typeof s.contentUrl=="string"?[{name:s.name,contentUrl:s.contentUrl}]:[]})}function sft({name:e,args:t,response:n,done:r,status:i,defaultOpen:s=!1,retrying:a=!1,onBranchSelect:l}){const u=e==="create_agents"&&r&&Jct(t,n)?"failed":i??(r?"completed":"running"),d=e==="create_agents"&&u==="failed"&&a,f=Adt(e),h=f==null?void 0:f.detailRenderer,m=(f==null?void 0:f.hideHeader)===!0,g=m||s||!!h,[b,y]=p.useState(g),O=p.useRef(!1);p.useEffect(()=>{!O.current&&g&&y(!0)},[g]);const v=()=>{O.current=!0,y(k=>!k)},x=e===I0e?"渲染 UI":e,w=ift(n),S=n==null?null:typeof n=="string"?n:JSON.stringify(n,null,2),E=S&&S.length>2e3?S.slice(0,2e3)+`
…(已截断)`:S;return o.jsxs(ai.div,{className:`block-tool${f?" block-tool--builtin":""}`,"data-status":u,initial:{opacity:0,y:4},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[f&&!m?o.jsx(Xct,{definition:f,label:d?"Agent 正在调整":u==="failed"?f.failedLabel:Kdt(e,t),done:r,open:b,onToggle:v}):f?null:o.jsxs("button",{className:"tool-head tool-head--generic",onClick:v,type:"button","aria-expanded":b,children:[o.jsx("span",{className:"tool-icon tool-icon--generic","aria-hidden":"true",children:o.jsx(Ydt,{})}),r?o.jsx("span",{className:"tool-name",children:x}):o.jsx(wn,{className:"tool-name",duration:2.2,spread:15,children:x}),o.jsx(MB,{className:`tool-chevron${b?" is-open":""}`})]}),o.jsx("div",{className:`${m?"":"think-collapse "}${b?"open":""}`,children:o.jsx("div",{className:"think-collapse-inner",children:h?o.jsx(h,{args:t,response:n,status:u,onBranchSelect:l}):o.jsxs("div",{className:"tool-detail",children:[t!=null&&o.jsxs("div",{className:"tool-section",children:[o.jsx("div",{className:"tool-section-label",children:"参数"}),o.jsx("pre",{className:"tool-args",children:JSON.stringify(t,null,2)})]}),E!=null&&o.jsxs("div",{className:"tool-section",children:[o.jsx("div",{className:"tool-section-label",children:"返回"}),o.jsx("pre",{className:"tool-args tool-result",children:E})]}),w.length>0&&o.jsxs("div",{className:"tool-section",children:[o.jsx("div",{className:"tool-section-label",children:"产物"}),o.jsx("div",{className:"studio-tool-artifacts",children:w.map(k=>o.jsxs("a",{href:k.contentUrl,download:k.name,children:["下载 ",k.name]},`${k.contentUrl}:${k.name}`))})]})]})})})]})}function aft({block:e,onDownload:t,onPreview:n}){const[r,i]=p.useState(""),[s,a]=p.useState(""),[l,c]=p.useState(null);p.useEffect(()=>()=>{l&&URL.revokeObjectURL(l.url)},[l]);const u=()=>c(null),d=async(m,g)=>{if(t){i(`download:${m}`),a("");try{await t(m,g)}catch(b){a(b instanceof Error?b.message:String(b))}finally{i("")}}},f=async(m,g,b)=>{if(n){i(`preview:${b}`),a("");try{const y=await n(m,g);c({name:b,url:y})}catch(y){a(y instanceof Error?y.message:String(y))}finally{i("")}}},h=e.files.filter(m=>!m.filename.endsWith(".preview.webp"));return o.jsxs("div",{className:"artifact-list",children:[h.map(m=>{const g=`${m.filename.replace(/\.pptx$/i,"")}.preview.webp`,b=e.files.find(y=>y.filename===g);return o.jsxs("div",{className:"artifact-card",children:[o.jsx("span",{className:"artifact-card__icon","aria-hidden":"true",children:o.jsx(r9,{})}),o.jsxs("span",{className:"artifact-card__copy",children:[o.jsx("span",{className:"artifact-card__name",children:m.filename}),o.jsx("span",{className:"artifact-card__hint",children:"PowerPoint 演示文稿"})]}),o.jsxs("span",{className:"artifact-card__actions",children:[b&&o.jsxs("button",{className:"artifact-card__action",type:"button",disabled:!n||r!=="",onClick:()=>void f(b.filename,b.version,m.filename),children:[r===`preview:${m.filename}`?o.jsx(rr,{className:"spin"}):o.jsx(VRe,{}),"预览"]}),o.jsxs("button",{className:"artifact-card__action artifact-card__action--primary",type:"button",disabled:!t||r!=="",onClick:()=>void d(m.filename,m.version),children:[r===`download:${m.filename}`?o.jsx(rr,{className:"spin"}):o.jsx(jN,{}),"下载"]})]})]},`${m.filename}:${m.version}`)}),s&&o.jsx("div",{className:"artifact-card__error",children:s}),l&&o.jsxs("div",{className:"artifact-preview",role:"dialog","aria-modal":"true","aria-label":`${l.name} 预览`,children:[o.jsx("button",{className:"artifact-preview__backdrop",type:"button","aria-label":"关闭预览",onClick:u}),o.jsxs("div",{className:"artifact-preview__panel",children:[o.jsxs("div",{className:"artifact-preview__header",children:[o.jsx("span",{children:l.name}),o.jsx("button",{type:"button","aria-label":"关闭预览",onClick:u,children:o.jsx(Ea,{})})]}),o.jsx("div",{className:"artifact-preview__canvas",children:o.jsx("img",{src:l.url,alt:`${l.name} 幻灯片预览`})})]})]})]})}function oft({block:e,onAuth:t}){const[n,r]=p.useState(e.done?"done":"idle"),[i,s]=p.useState(""),a=e.label||"MCP 工具集",l=(()=>{try{return e.authUri?new URL(e.authUri).host:""}catch{return""}})(),c=async()=>{if(t){s(""),r("authorizing");try{await t(e),r("done")}catch(d){s(d instanceof Error?d.message:String(d)),r("idle")}}};return e.done||n==="done"?o.jsxs(ai.div,{className:"auth-card-collapsed",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},children:[o.jsx(SH,{className:"auth-card-icon auth-card-icon--done"}),o.jsxs("span",{children:["已授权 · ",a]})]}):o.jsxs(ai.div,{className:"auth-card",initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2,ease:"easeOut"},children:[o.jsxs("div",{className:"auth-card-head",children:[o.jsx(SH,{className:"auth-card-icon"}),o.jsxs("span",{className:"auth-card-title",children:[a," 需要授权"]})]}),o.jsxs("p",{className:"auth-card-desc",children:["工具集 ",o.jsx("code",{className:"auth-card-code",children:a})," 使用 OAuth 保护, 需登录授权后方可调用。",l&&o.jsxs(o.Fragment,{children:[" ","将跳转至 ",o.jsx("code",{className:"auth-card-code",children:l})," 完成登录,"]}),"授权完成后对话自动继续。"]}),o.jsx("button",{className:"auth-card-btn",onClick:c,disabled:n==="authorizing"||!e.authUri,children:n==="authorizing"?o.jsxs(o.Fragment,{children:[o.jsx(rr,{className:"cw-i spin"})," 等待授权…"]}):o.jsx(o.Fragment,{children:"去授权"})}),!e.authUri&&o.jsx("div",{className:"auth-card-err",children:"未在事件中找到授权地址。"}),i&&o.jsx("div",{className:"auth-card-err",children:i})]})}function Fj({blocks:e,appName:t="",streaming:n=!1,onStreamFrame:r,onStreamComplete:i,onAction:s,onAuth:a,onArtifactDownload:l,onArtifactPreview:c,onResolveDelivery:u,onResolveDeliveryComparison:d,onDownloadDelivery:f,onDeployDelivery:h,onBranchSelect:m}){const g=e.reduce((b,y,O)=>y.kind==="text"?O:b,-1);return o.jsx(o.Fragment,{children:e.map((b,y)=>{switch(b.kind){case"progress":return o.jsx(Jdt,{text:b.text},"build-progress");case"thinking":{const O=e.slice(y+1).some(v=>v.kind==="text"&&!!v.text.trim());return o.jsx(P0e,{text:b.text,done:b.done,answerStarted:O,streaming:n,onStreamFrame:r},y)}case"text":{const O=b.text.replace(/^\s+/,"");return O?o.jsx(tft,{text:O,streaming:n,onStreamFrame:r,onStreamComplete:y===g?i:void 0},y):null}case"plan":return o.jsx(rft,{title:b.title,summary:b.summary,items:b.items,done:b.done},y);case"attachment":return o.jsx(Bj,{appName:t,items:b.files},y);case"artifact":return o.jsx(aft,{block:b,onDownload:l,onPreview:c},y);case"delivery":return o.jsx(eft,{value:b.value,onResolve:u,onResolveComparison:d,onDownload:f,onDeploy:h},y);case"invocation":return o.jsx($j,{value:b.value},y);case"tool":{if(b.name===I0e&&b.done)return null;const O=b.name==="create_agents"&&e.slice(y+1).some(v=>v.kind==="tool"&&v.name==="create_agents");return o.jsx(sft,{name:b.name,args:b.args,response:b.response,done:b.done,status:b.status,defaultOpen:b.defaultOpen,retrying:b.name==="create_agents"&&(n||O),onBranchSelect:m},y)}case"agent-transfer":return null;case"auth":return o.jsx(oft,{block:b,onAuth:a},y);case"a2ui":return Gge(b.messages).filter(O=>O.components[O.rootId]).map(O=>o.jsx(ai.div,{initial:{opacity:0,y:8,scale:.985},animate:{opacity:1,y:0,scale:1},transition:{type:"spring",stiffness:380,damping:30},children:o.jsx(Ict,{surface:O,onAction:s})},`${y}-${O.surfaceId}`));default:return null}})})}const lft=()=>{};function cft(e){if(e.kind==="message")return{kind:"text",text:e.text};if(e.kind==="thinking")return{kind:"thinking",text:e.text,done:e.status==="done"};if(e.kind==="tool")return{kind:"tool",name:e.name,args:e.args,response:e.response,done:e.status==="done"};throw new Error("不支持的 Skill 对话活动")}function uft({activities:e}){const t=p.useMemo(()=>e.filter(n=>n.kind!=="status").map(cft),[e]);return t.length===0?null:o.jsx("div",{className:"skill-conversation","aria-label":"Skill 生成对话","aria-live":"polite",children:o.jsx(Fj,{blocks:t,onAction:lft})})}function ZW(){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:o.jsx("path",{d:"m7 9 5 5 5-5",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})})}function fT({label:e,value:t,options:n,onChange:r,disabled:i=!1,allowCustom:s=!1,required:a=!1,placeholder:l="请选择",error:c}){const u=p.useId(),d=p.useId(),f=p.useId(),h=p.useRef(null),m=p.useRef(null),g=p.useRef(null),b=p.useRef(null),y=p.useRef([]),O=n.findIndex(M=>M.value===t),v=t.trim().toLocaleLowerCase(),x=s&&v?n.filter(M=>M.value.toLocaleLowerCase().includes(v)||M.label.toLocaleLowerCase().includes(v)):n,[w,S]=p.useState(!1),[E,k]=p.useState(Math.max(0,O)),_=O>=0?n[O]:void 0,T=i||!s&&n.length===0,C=(M=!1)=>{S(!1),M&&window.requestAnimationFrame(()=>{var I,$;return s?(I=g.current)==null?void 0:I.focus():($=m.current)==null?void 0:$.focus()})},A=M=>{T||x.length!==0&&(k(Math.min(Math.max(M,0),x.length-1)),S(!0))};p.useEffect(()=>{if(!w)return;const M=b.current,I=s?void 0:window.requestAnimationFrame(()=>{var B;(B=y.current[E])==null||B.focus()}),$=B=>{if(!M)return;const F=M.scrollTop<=0,L=M.scrollTop+M.clientHeight>=M.scrollHeight-1;(M.scrollHeight<=M.clientHeight||B.deltaY<0&&F||B.deltaY>0&&L)&&B.preventDefault(),B.stopPropagation()},N=B=>{var F;B.target instanceof Node&&!((F=h.current)!=null&&F.contains(B.target))&&C()},j=B=>{B.key==="Escape"&&C(!0)};return M==null||M.addEventListener("wheel",$,{passive:!1}),window.addEventListener("pointerdown",N),window.addEventListener("keydown",j),()=>{I!==void 0&&window.cancelAnimationFrame(I),M==null||M.removeEventListener("wheel",$),window.removeEventListener("pointerdown",N),window.removeEventListener("keydown",j)}},[E,s,w]);const R=M=>{var $;if(x.length===0)return;const I=(M+x.length)%x.length;k(I),($=y.current[I])==null||$.focus()};return o.jsxs("div",{ref:h,className:`skill-config-select${w?" is-open":""}`,onBlur:M=>{var I;(!M.relatedTarget||!((I=h.current)!=null&&I.contains(M.relatedTarget)))&&C()},children:[o.jsxs("span",{id:d,className:"skill-config-select__label",children:[e,a?o.jsx("span",{className:"skill-required-mark","aria-hidden":"true",children:"*"}):null]}),s?o.jsxs("div",{className:`skill-config-select__trigger is-editable${i?" is-disabled":""}`,"aria-expanded":w,children:[o.jsx("input",{ref:g,value:t,disabled:i,role:"combobox","aria-autocomplete":"list","aria-expanded":w,"aria-controls":w?u:void 0,"aria-labelledby":d,"aria-required":a,"aria-invalid":!!c,"aria-describedby":c?f:void 0,placeholder:l,onChange:M=>{r(M.target.value),k(0),n.length>0&&S(!0)},onClick:()=>{!w&&x.length>0&&A(0)},onKeyDown:M=>{var I,$;if(!(M.nativeEvent.isComposing||M.keyCode===229))if(M.key==="ArrowDown")M.preventDefault(),w?(I=y.current[E])==null||I.focus():A(0);else if(M.key==="ArrowUp")M.preventDefault(),w?($=y.current[x.length-1])==null||$.focus():A(x.length-1);else if(M.key==="Enter"&&w){M.preventDefault();const N=x[E];N&&r(N.value),C()}else M.key==="Escape"&&(M.preventDefault(),C())}}),o.jsx("button",{type:"button",className:"skill-config-select__toggle",disabled:i||n.length===0,"aria-label":w?"收起模型选项":"展开模型选项",onClick:()=>{w?C():A(0)},children:o.jsx(ZW,{})})]}):o.jsxs("button",{ref:m,type:"button",className:"skill-config-select__trigger",disabled:T,"aria-haspopup":"listbox","aria-expanded":w,"aria-controls":w?u:void 0,"aria-labelledby":d,"aria-required":a,onClick:()=>{w?C():A(O>=0?O:0)},onKeyDown:M=>{M.key==="ArrowDown"?(M.preventDefault(),A(O>=0?O:0)):M.key==="ArrowUp"&&(M.preventDefault(),A(O>=0?O:n.length-1))},children:[o.jsx("span",{className:_?void 0:"is-placeholder",title:_==null?void 0:_.label,children:(_==null?void 0:_.label)||(n.length===0?"暂无可用选项":l)}),o.jsx(ZW,{})]}),w?o.jsxs("div",{ref:b,id:u,className:"skill-config-select__menu",role:"listbox","aria-labelledby":d,children:[x.length===0?o.jsx("div",{className:"skill-config-select__empty",role:"status",children:"没有匹配项,可直接使用当前模型 ID"}):null,x.map((M,I)=>{const $=M.value===t;return o.jsx("button",{ref:N=>{y.current[I]=N},type:"button",role:"option","aria-selected":$,tabIndex:I===E?0:-1,className:`skill-config-select__option${$?" is-selected":""}`,title:M.label,onFocus:()=>k(I),onClick:()=>{r(M.value),C(!0)},onKeyDown:N=>{N.key==="Enter"||N.key===" "?(N.preventDefault(),r(M.value),C(!0)):N.key==="ArrowDown"?(N.preventDefault(),R(I+1)):N.key==="ArrowUp"?(N.preventDefault(),R(I-1)):N.key==="Home"?(N.preventDefault(),R(0)):N.key==="End"&&(N.preventDefault(),R(n.length-1))},children:M.label},M.value)})]}):null,c?o.jsx("span",{id:f,className:"skill-config-select__error",role:"alert",children:c}):null]})}function ma(e,t){return e instanceof Error?e:typeof e=="string"&&e.trim()?new Error(e.trim()):new Error(t)}function Ho({error:e}){var i,s,a,l,c;const t=e,n=(s=(i=t.originalError)==null?void 0:i.message)==null?void 0:s.trim(),r=[typeof t.status=="number"?`HTTP ${t.status}${t.statusText?` ${t.statusText}`:""}`:"",t.code?`错误码:${t.code}`:"",(a=t.originalError)!=null&&a.type?`错误类型:${t.originalError.type}`:"",(l=t.originalError)!=null&&l.repr&&t.originalError.repr!==n?`异常表示:${t.originalError.repr}`:"",(c=t.rawResponse)!=null&&c.trim()?`服务端原始响应:
${t.rawResponse.trim()}`:""].filter(Boolean);return o.jsxs("div",{className:"skill-error-details",children:[o.jsx("div",{className:"skill-error-details__summary",children:e.message}),n?o.jsxs("div",{className:"skill-error-details__original",children:["原始错误:",n]}):null,r.length>0?o.jsxs("details",{children:[o.jsx("summary",{children:"详细信息"}),o.jsx("pre",{children:r.join(`
@@ -1130,12 +1130,12 @@ README.md
${c}`:e}}return`${e}
${t}`}function Ajt(e,t){if(e.length<=t)return{text:e,omitted:!1};let n=e.slice(-t);const r=n.indexOf(`
`);return r>=0&&(n=n.slice(r+1)),{text:n,omitted:!0}}function Njt(e,t,n=Tjt){const r=Cjt((e==null?void 0:e.text)??"",t.text??""),i=Ajt(r,n),s=i.text?i.text.split(`
-`).length:0,a=!!(t.snapshotTruncated||t.truncated),l=!!(e!=null&&e.omittedEarly||i.omitted);return{...t,text:i.text,lineCount:s,truncated:!!(e!=null&&e.truncated||t.truncated||l),omittedEarly:l,snapshotTruncated:!!(e!=null&&e.snapshotTruncated||a)}}function jjt(e){const t=e.trim();if(!t)return"GitHub 仓库";const n=t.match(/github\.com[:/](?[^/\s]+)\/(?[^/\s#?]+?)(?:\.git)?(?:[/?#].*)?$/);return n!=null&&n.groups?`${n.groups.owner}/${n.groups.repo}`:t}function ob(e){return e.trim()||"main"}function jee(e){return e instanceof Tv?e.detail:e instanceof Error?{message:e.message}:{message:String(e||"同步 GitHub 代码失败")}}function Rjt(e){return e.status==="cicd-bound"?"已挂载":e.status==="bound"?"已绑定":e.status==="succeeded"?"已同步":e.status||"已创建"}function Ijt(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6.2 3.8H4.3A1.8 1.8 0 0 0 2.5 5.6v6.1a1.8 1.8 0 0 0 1.8 1.8h6.1a1.8 1.8 0 0 0 1.8-1.8V9.8"}),o.jsx("path",{d:"M8.7 2.5h4.8v4.8"}),o.jsx("path",{d:"m13.1 2.9-6 6"})]})}function Ree(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.24"}),o.jsx("path",{d:"M13.5 8A5.5 5.5 0 0 0 8 2.5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function Djt({project:e,region:t,cloudProvider:n,runtimeId:r,binding:i,disabled:s=!1,showSetup:a=!0,onPendingCicdChange:l,onBindingChange:c}){var ie,q,G;const[u,d]=p.useState(""),[f,h]=p.useState(""),[m,g]=p.useState("main"),[b,y]=p.useState(""),[O,v]=p.useState(""),[x,w]=p.useState(""),[S,E]=p.useState("source"),[k,_]=p.useState(!1),[T,C]=p.useState(!1),[A,R]=p.useState(null),[M,I]=p.useState(null),[$,N]=p.useState(!1);p.useEffect(()=>{(i!=null&&i.pipelineId||i!=null&&i.runtimeId||i!=null&&i.status)&&R(i)},[i]),p.useEffect(()=>{let J=!1;if(!r){R(null),c==null||c(null);return}return C(!0),Xoe(r).then(ue=>{J||(R(ue),c==null||c(ue))}).catch(ue=>{J||I(jee(ue))}).finally(()=>{J||C(!1)}),()=>{J=!0}},[c,r]),p.useEffect(()=>{if(!l)return;if(r||S!=="cicd"||!a){l(null),N(!1);return}const J=u.trim(),ue=f.trim(),Oe=b.trim(),Qe=O.trim();if(!J||!ue||!Oe||!Qe||e.files.length===0){l(null),N(!1);return}l({githubUrl:J,githubToken:f,baseBranch:ob(m),volcengineAccessKey:Oe,volcengineSecretKey:O,volcengineSessionToken:x.trim(),pipelineId:A==null?void 0:A.pipelineId,cloudProvider:n})},[m,n,f,u,S,l,e.files.length,A==null?void 0:A.pipelineId,r,a,b,O,x]);const j=p.useMemo(()=>jjt(u),[u]),B=A==null?void 0:A.github,F=B!=null&&B.owner&&B.repo?`${B.owner}/${B.repo}`:(B==null?void 0:B.repo)??j,L=(B==null?void 0:B.branch)??ob(m),H=A==null?void 0:A.runtimeId,z=S==="cicd",Q=n==="byteplus"?"BytePlus":"火山",V=!a&&!!r,K=a&&!s&&!k&&u.trim().length>0&&f.trim().length>0&&(z?b.trim().length>0&&O.trim().length>0&&(!!r||e.files.length>0):e.files.length>0),se=z?r?"挂载持续交付":$?"已选择,部署时挂载":"部署时挂载持续交付":"同步代码";async function ge(J){if(J.preventDefault(),!!K){_(!0),R(null),I(null);try{if(z&&!r){l==null||l({githubUrl:u.trim(),githubToken:f,baseBranch:ob(m),volcengineAccessKey:b.trim(),volcengineSecretKey:O,volcengineSessionToken:x.trim(),cloudProvider:n}),N(!0);return}const ue=z&&r?await Hoe({githubUrl:u.trim(),githubToken:f,baseBranch:ob(m),runtimeName:e.name,runtimeId:r??"",region:t,cloudProvider:n,projectPath:".",volcengineAccessKey:b.trim(),volcengineSecretKey:O,volcengineSessionToken:x.trim()}):await Voe({project:e,githubUrl:u.trim(),githubToken:f,baseBranch:ob(m),region:t,cloudProvider:n}),Oe=!z&&r&&ue.pipelineId?await S9({pipelineId:ue.pipelineId,runtimeId:r,region:t,cloudProvider:n}):ue;R(Oe),c==null||c(Oe),z&&!r&&Oe.pipelineId&&(l==null||l({githubUrl:u.trim(),githubToken:f,baseBranch:ob(m),volcengineAccessKey:b.trim(),volcengineSecretKey:O,volcengineSessionToken:x.trim(),pipelineId:Oe.pipelineId,cloudProvider:n})),(!z||r)&&(h(""),y(""),v(""),w(""))}catch(ue){I(jee(ue))}finally{_(!1)}}}return V&&!T&&!A?null:o.jsxs("section",{className:"pp-config-section pp-github-cicd",children:[o.jsxs("div",{className:"pp-config-label pp-github-cicd-title",children:[a?o.jsxs("div",{className:"pp-github-cicd-tabs",role:"tablist","aria-label":"GitHub 交付模式",children:[o.jsx("button",{type:"button",className:S==="source"?"is-active":"",role:"tab","aria-selected":S==="source",onClick:()=>E("source"),children:"GitHub 代码同步"}),o.jsx("button",{type:"button",role:"tab",className:S==="cicd"?"is-active":"","aria-selected":S==="cicd",onClick:()=>E("cicd"),children:"挂载持续交付"})]}):o.jsx("span",{children:"GitHub 交付"}),(k||T)&&o.jsxs("span",{className:"pp-github-cicd-status",role:"status",children:[o.jsx(Ree,{className:"pp-ic spin"}),T?"读取中":"执行中"]})]}),a&&o.jsx("p",{className:"pp-github-cicd-copy",children:z?r?"写入 AgentKit Runtime GitHub Actions workflow,后续 GitHub 提交会更新绑定 Runtime。":"首次部署成功后初始化目标分支,后续 GitHub 提交会更新绑定 Runtime。":"Studio 会直接 push 到目标分支;该分支由 Studio 管理,远端冲突时同步会失败。Runtime 仍由部署按钮发布。"}),a&&o.jsxs("form",{className:"pp-github-cicd-form",onSubmit:ge,children:[o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsx("span",{children:"GitHub URL"}),o.jsx("input",{value:u,placeholder:"https://github.com/org/repo",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),d(J.currentTarget.value)}})]}),o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsx("span",{children:"Token"}),o.jsx("input",{type:"password",value:f,placeholder:"repo 或 contents write 权限",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),h(J.currentTarget.value)}})]}),o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsx("span",{children:"目标分支"}),o.jsx("input",{value:m,placeholder:"main",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),g(J.currentTarget.value)}})]}),z&&o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsxs("span",{children:[Q," AK"]}),o.jsx("input",{type:"password",value:b,placeholder:"用于写入 GitHub Actions Secret",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),y(J.currentTarget.value)}})]}),o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsxs("span",{children:[Q," SK"]}),o.jsx("input",{type:"password",value:O,placeholder:"用于写入 GitHub Actions Secret",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),v(J.currentTarget.value)}})]}),o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsxs("span",{children:[Q," Session Token"]}),o.jsx("input",{type:"password",value:x,placeholder:"临时凭证可选",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),w(J.currentTarget.value)}})]})]}),o.jsx("button",{type:"submit",className:"pp-github-cicd-submit",disabled:!K,children:k?o.jsxs(o.Fragment,{children:[o.jsx(Ree,{className:"pp-ic spin"}),"同步中…"]}):se})]}),$&&!A&&o.jsx("p",{className:"pp-github-cicd-bound-note",children:"已选择挂载持续交付。点击部署后,Studio 会等待 Runtime 创建完成并初始化 GitHub 目标分支,初始化成功后才完成部署流程。"}),A&&o.jsxs("div",{className:"pp-github-cicd-result",role:"status",children:[o.jsxs("div",{className:"pp-github-cicd-result-head",children:[o.jsx("strong",{children:(ie=A.cicd)!=null&&ie.enabled?A.runtimeId?"已挂载持续交付":"已选择挂载持续交付":H?"已绑定 GitHub":"代码已同步"}),o.jsx("span",{children:Rjt(A)})]}),o.jsxs("dl",{className:"pp-github-cicd-result-grid",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"仓库"}),o.jsx("dd",{children:F})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"分支"}),o.jsx("dd",{children:L})]}),H&&o.jsxs("div",{children:[o.jsx("dt",{children:"Runtime"}),o.jsx("dd",{children:H})]}),(B==null?void 0:B.commitSha)&&o.jsxs("div",{children:[o.jsx("dt",{children:"Commit"}),o.jsx("dd",{children:B.commitSha.slice(0,12)})]}),((q=A.cicd)==null?void 0:q.workflowPath)&&o.jsxs("div",{children:[o.jsx("dt",{children:"Workflow"}),o.jsx("dd",{children:A.cicd.workflowPath})]})]}),o.jsx("div",{className:"pp-github-cicd-links",children:(B==null?void 0:B.pullRequestUrl)&&o.jsxs("a",{href:B.pullRequestUrl,target:"_blank",rel:"noopener noreferrer",children:[o.jsx(Ijt,{className:"pp-ic"}),"查看 PR"]})}),H&&o.jsx("p",{className:"pp-github-cicd-bound-note",children:(G=A.cicd)!=null&&G.enabled?"目标分支提交会触发 Runtime 持续交付。":"更新并发布时会先同步当前源码到这个分支。"})]}),M&&o.jsxs("div",{className:"pp-github-cicd-error",role:"alert",children:[o.jsx("strong",{children:"创建失败"}),o.jsx("p",{children:M.message}),(M.phase||M.runtimeId||M.logPath)&&o.jsxs("dl",{children:[M.phase&&o.jsxs("div",{children:[o.jsx("dt",{children:"阶段"}),o.jsx("dd",{children:M.phase})]}),M.runtimeId&&o.jsxs("div",{children:[o.jsx("dt",{children:"Runtime"}),o.jsx("dd",{children:M.runtimeId})]}),M.logPath&&o.jsxs("div",{children:[o.jsx("dt",{children:"日志"}),o.jsx("dd",{children:M.logPath})]})]})]})]})}eo.registerLanguage("python",Eme);eo.registerLanguage("typescript",Mme);eo.registerLanguage("javascript",yme);eo.registerLanguage("json",Ome);eo.registerLanguage("yaml",Lme);eo.registerLanguage("markdown",Sme);eo.registerLanguage("bash",yB);eo.registerLanguage("ini",hme);eo.registerLanguage("dockerfile",cnt);eo.registerLanguage("makefile",wme);function Iee(e){switch(e){case"prepare":case"upload":case"build":case"deploy":case"publish":case"update":case"evaluation":return e;default:return"unknown"}}const Dee={prepare:0,upload:1,build:2,deploy:3,publish:4,update:5,evaluation:6,complete:7,github:8},p_="构建任务已经提交,但暂时无法确认最终状态。请稍后在 Code Pipeline 查看构建结果,避免重复部署。";function Pjt(e){const t=e instanceof Error?e.message:String(e);return/RunPipeline result could not be reconciled|Polling build status failed/i.test(t)}function Mjt(e,t){if(!t)return e??"prepare";if(!e)return t;const n=Dee[e],r=Dee[t];return n===void 0||r===void 0||r>=n?t:e}const Ljt=p.lazy(()=>fd(()=>Promise.resolve().then(()=>ave),void 0)),Vh=()=>{};function $jt({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M2.75 12s3.35-5.25 9.25-5.25S21.25 12 21.25 12 17.9 17.25 12 17.25 2.75 12 2.75 12Z"}),o.jsx("circle",{cx:"12",cy:"12",r:"2.5"})]})}function Bjt({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M3 3l18 18"}),o.jsx("path",{d:"M9.7 6.95A9.7 9.7 0 0 1 12 6.68c5.9 0 9.25 5.32 9.25 5.32a16 16 0 0 1-2.28 2.85"}),o.jsx("path",{d:"M14.35 14.55A3.25 3.25 0 0 1 9.5 10.2"}),o.jsx("path",{d:"M6.25 8.12A16.4 16.4 0 0 0 2.75 12S6.1 17.32 12 17.32c.8 0 1.55-.1 2.25-.27"})]})}const n3={status:"hidden",apiKeyId:"",value:"",error:""};function Qjt({open:e,isUpdate:t,title:n,description:r,confirmLabel:i,onCancel:s,onConfirm:a}){const l=p.useRef(null);return p.useEffect(()=>{var d;if(!e)return;const c=document.body.style.overflow;document.body.style.overflow="hidden",(d=l.current)==null||d.focus();const u=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>{document.body.style.overflow=c,window.removeEventListener("keydown",u)}},[s,e]),e?kr.createPortal(o.jsx("div",{className:"code-browser-backdrop pp-confirm-backdrop",onMouseDown:c=>{c.target===c.currentTarget&&s()},children:o.jsxs("section",{className:"code-browser-dialog pp-confirm-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"pp-confirm-title","aria-describedby":"pp-confirm-description",children:[o.jsxs("header",{className:"code-browser-head pp-confirm-head",children:[o.jsxs("div",{className:"code-browser-title-wrap",children:[o.jsx("span",{className:"code-browser-title-icon pp-confirm-icon","aria-hidden":"true",children:o.jsx(uIe,{})}),o.jsx("h2",{id:"pp-confirm-title",children:n??(t?"确认更新":"确认部署")})]}),o.jsx("button",{type:"button",className:"code-browser-close",onClick:s,"aria-label":"关闭部署确认",children:o.jsx(Ea,{"aria-hidden":"true"})})]}),o.jsx("div",{className:"pp-confirm-body",children:o.jsx("p",{id:"pp-confirm-description",children:r??(t?"将更新并发布到当前云端 Runtime,过程可能需要几分钟。确定继续吗?":"将创建新的云端 Runtime,部署过程可能需要几分钟。确定继续吗?")})}),o.jsxs("footer",{className:"pp-confirm-actions",children:[o.jsx("button",{ref:l,type:"button",onClick:s,children:"取消"}),o.jsx("button",{type:"button",className:"is-primary",onClick:a,children:i??(t?"确定更新":"确定部署")})]})]})}),document.body):null}function Ujt({value:e,disabled:t,onChange:n}){const[r,i]=p.useState([]),[s,a]=p.useState(!0),[l,c]=p.useState(null),[u,d]=p.useState(0);p.useEffect(()=>{const m=new AbortController;return a(!0),c(null),BN(m.signal).then(g=>i(g)).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||(i([]),c(g instanceof Error?g.message:String(g)))}).finally(()=>{m.signal.aborted||a(!1)}),()=>m.abort()},[u]);const f=p.useMemo(()=>[...r].sort((m,g)=>Number(g.isCurrent)-Number(m.isCurrent)).map(m=>({value:m.uid,label:m.name.trim()||"未命名用户池",description:m.domain||m.uid,badge:m.isCurrent?"当前用户池":void 0})),[r]),h=r.find(m=>m.uid===e);return o.jsxs("div",{className:"pp-user-pool-picker",children:[o.jsx(GE,{ariaLabel:"部署用户池",value:e,placeholder:s?"正在加载用户池…":"请选择用户池",options:f,disabled:t||s||!!l,onChange:n}),l?o.jsxs("div",{className:"pp-user-pool-error",role:"alert",children:[o.jsx("span",{children:l}),o.jsx("button",{type:"button",onClick:()=>d(m=>m+1),children:"重试"})]}):s?o.jsxs("span",{className:"pp-user-pool-status","aria-live":"polite",children:[o.jsx(rr,{"aria-hidden":"true",className:"pp-user-pool-spinner"}),"正在加载 Identity 用户池…"]}):r.length===0?o.jsx("span",{className:"pp-user-pool-status",children:"当前账号下暂无 Identity 用户池。"}):h!=null&&h.isCurrent?o.jsx("span",{className:"pp-user-pool-status",children:"当前 Studio 的登录 JWT 将透传访问此 Runtime。"}):h?o.jsx("div",{className:"pp-user-pool-error",role:"alert",children:o.jsx("span",{children:"所选用户池不是当前 Studio 使用的用户池,部署后无法从 Studio 调用此 Runtime。"})}):o.jsx("span",{className:"pp-user-pool-status",children:"当前 Studio 使用的用户池已在列表中标注。"})]})}const Fjt=[{value:"api_key",label:"API Key",description:"默认方式,使用 Runtime API Key 访问"},{value:"user_pool",label:"用户池",description:"使用 Identity 用户池签发的 JWT"}],zjt={py:"python",pyi:"python",ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",yaml:"yaml",yml:"yaml",md:"markdown",markdown:"markdown",sh:"bash",bash:"bash",zsh:"bash",toml:"ini",ini:"ini",cfg:"ini",conf:"ini",env:"ini",txt:"plaintext"},Pee={dockerfile:"dockerfile","requirements.txt":"plaintext","requirements-dev.txt":"plaintext",".env":"ini",".gitignore":"plaintext",makefile:"makefile"};function Mee(e){return e.replace(/&/g,"&").replace(//g,">")}function Vjt(e){const n=(e.split("/").pop()??e).toLowerCase();if(Pee[n])return Pee[n];if(n.startsWith("dockerfile"))return"dockerfile";if(n.startsWith(".env"))return"ini";const r=n.lastIndexOf(".");if(r===-1)return null;const i=n.slice(r+1);return zjt[i]??null}function Hjt(e,t){try{const n=Vjt(t);return n&&eo.getLanguage(n)?eo.highlight(e,{language:n,ignoreIllegals:!0}).value:n===null?eo.highlightAuto(e).value:Mee(e)}catch{return Mee(e)}}const qjt=[{phase:"build",label:"构建镜像"},{phase:"deploy",label:"部署"},{phase:"publish",label:"发布"}],Xjt={phase:"github",label:"同步代码"},Gjt=[{phase:"upload",label:"上传代码包"},{phase:"build",label:"镜像打包"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}],Wjt={phase:"update",label:"更新实例配置"},Yjt={phase:"evaluation",label:"创建评测集"};function Zjt(e){return e?!e.memory.shortTerm||(e.shortTermBackend||"local")==="local":!1}function Kjt(e,t){const n=Number(e),r=Number(t);return!e.trim()||!t.trim()||!Number.isSafeInteger(n)||!Number.isSafeInteger(r)||n<1||r<1?{valid:!1,error:"实例数必须为大于 0 的整数。"}:n>r?{valid:!1,error:"最小实例数不能大于最大实例数。"}:{valid:!0,min:n,max:r}}function Jjt(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let i=t;r.forEach((s,a)=>{let l=i.children.get(s);l||(l={name:s,children:new Map},i.children.set(s,l)),a===r.length-1&&(l.path=n.path),i=l})}return t}function eRt(e,t=!1){return[...e.children.values()].sort((n,r)=>{const i=n.children.size>0&&n.path===void 0,s=r.children.size>0&&r.path===void 0;return i!==s?t?i?1:-1:i?-1:1:n.name.localeCompare(r.name)})}function tRt(e="",t=""){return{id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,key:e,value:t}}function nRt({left:e,right:t}){const[n,r]=p.useState(null);return p.useLayoutEffect(()=>{const i=document.getElementById("veadk-page-header-left"),s=document.getElementById("veadk-page-header-actions");i&&s&&r({left:i,right:s})},[]),n?o.jsxs(o.Fragment,{children:[kr.createPortal(e,n.left),kr.createPortal(t,n.right)]}):o.jsxs("header",{className:"pp-toolbar",children:[e,t]})}function _R({project:e,embedded:t=!1,deployDisabledReason:n,agentDraft:r,agentName:i,agentCount:s,releaseConfiguration:a,onChange:l,onDeploy:c,onAgentAdded:u,onDeploymentComplete:d,deploymentActionLabel:f="部署",deploymentConfirmation:h,deploymentActionTargetId:m,deploymentRuntimeId:g,deploymentRuntimeName:b,deploymentRuntimeNameCustomized:y=!1,onDeploymentRuntimeNameChange:O,onDeploymentStarted:v,onDeploymentTaskChange:x,feishuEnabled:w=!1,onFeishuEnabledChange:S,configuredRuntimeEnvKeys:E=[],deploymentEnv:k=[],requiredSecretEnv:_=[],requiredSecretEnvValues:T,onRequiredSecretEnvChange:C,deploymentEnvValues:A={},onDeploymentEnvChange:R,onFeishuCredentialsChange:M,network:I,onNetworkChange:$,cloudProvider:N="volcengine",deployRegion:j=Zr(N),onDeployRegionChange:B,deploymentTelemetry:F={source:"unknown",createMode:"unknown",aiAssisted:!1},onBack:L,backLabel:H="返回配置",onExportYaml:z,deploymentPrimaryPane:Q,deployDisabled:V=!1}){var xs,lo,vs,Ar,la,ca;const K=typeof l=="function",se=!!g,ge=p.useMemo(()=>new Set(E),[E]),ie=Zjt(r),q=(i==null?void 0:i.trim())||(r==null?void 0:r.name)||e.name,G=p.useMemo(()=>Kve(q),[q]),[J,ue]=p.useState(null),Oe=se?b??q:y?b??"":J??G,Qe=se?null:WE(Oe),[je,ze]=p.useState(null),[Ge,Ae]=p.useState(!1),Be=`${j}\0${Oe.trim()}`,he=p.useRef(Be);he.current=Be;const be=(je==null?void 0:je.key)===Be?je.message:null,Se=Qe??be,Ee=((lo=(xs=r==null?void 0:r.deployment)==null?void 0:xs.modelApiKeyId)==null?void 0:lo.trim())??"",tt=((vs=r==null?void 0:r.harnessSidecar)==null?void 0:vs.enabled)===!0,[Ue,re]=p.useState(((la=(Ar=e==null?void 0:e.files)==null?void 0:Ar[0])==null?void 0:la.path)??null);p.useEffect(()=>{ue(null),ze(null)},[q]);const[ce,Me]=p.useState(new Set),[Ye,Z]=p.useState(!1),[_e,rt]=p.useState(""),[Re,We]=p.useState(!1),[ct,kt]=p.useState(!1),[qt,Dt]=p.useState(!1),[Xe,nt]=p.useState(!1),[ft,xt]=p.useState(null),[Ie,xe]=p.useState(null),[$e,it]=p.useState(null),[ve,He]=p.useState(null),[pt,_t]=p.useState({}),[It,Kt]=p.useState(null),[en,le]=p.useState(!1),[Xt,Fe]=p.useState([]),[Pt,Ce]=p.useState(n3),gt=p.useRef(null),Vt=p.useRef(Ee);Vt.current=Ee;const[ot,ln]=p.useState({}),Kn=T??ot,[_r,Ve]=p.useState(null),[et,mn]=p.useState({}),Mt=p.useRef(new Map),[ar,pr]=p.useState(Lve),[Gn,zn]=p.useState(null),[Pr,Lr]=p.useState(!1),Kr=p.useId(),qr=p.useId(),mr=p.useId(),Xr=p.useId(),[Tr,oi]=p.useState("api_key"),[Ii,bi]=p.useState(""),Jr=Ed(N),Di=Jf(j,N),[rs,oa]=p.useState("1"),[Qr,Ws]=p.useState(ie||tt?"1":"5"),[is,ka]=p.useState(!0),Ys=N!=="byteplus",_a=Ys&&is,[Ds,Pi]=p.useState(null),Cr=p.useRef(!0),yi=_.map(fe=>`${fe.key}:${fe.label}`).join("|"),bs=k.map(fe=>`${fe.key}:${fe.required}:${fe.serverManaged??!1}:${(fe.requiredBy??[]).join(",")}`).join("|"),Ps=p.useRef(j),pn=Kjt(rs,Qr),Oi=!se&&pn.valid&&(pn.min!==1||pn.max!==5),Ur=Q?Gjt:qjt,ys=Oi?[...Ur,Wjt]:Ur,pe=_a?[...ys,Yjt]:ys,Le=g&&($e!=null&&$e.pipelineId)||ve?[...pe,Xjt]:pe;function At(){var fe;(fe=gt.current)==null||fe.abort(),gt.current=null,Ce(n3)}async function sn(){var St;const fe=Vt.current;if(!fe){Ce({status:"error",apiKeyId:"",value:"",error:"请先在模型配置中选择 API Key。"});return}(St=gt.current)==null||St.abort();const Je=new AbortController;gt.current=Je,Ce({status:"loading",apiKeyId:fe,value:"",error:""});try{const dn=await Zae(fe,Je.signal);if(Je.signal.aborted||Vt.current!==fe)return;Ce({status:"visible",apiKeyId:fe,value:dn.value,error:""})}catch(dn){if(Je.signal.aborted)return;Ce({status:"error",apiKeyId:fe,value:"",error:dn instanceof Error?dn.message:"加载 API Key 失败,请重试。"})}finally{gt.current===Je&&(gt.current=null)}}p.useEffect(()=>{At(),Ee&&mn(fe=>{if(!("MODEL_AGENT_API_KEY"in fe))return fe;const Je={...fe};return delete Je.MODEL_AGENT_API_KEY,Je})},[Ee]),p.useEffect(()=>(window.addEventListener("pagehide",At),()=>{window.removeEventListener("pagehide",At),At()}),[]),p.useEffect(()=>{const fe=new Set(_.map(Je=>Je.key));T===void 0&&ln(Je=>Object.fromEntries(Object.entries(Je).filter(([St])=>fe.has(St)))),Ve(Je=>Je&&fe.has(Je)?Je:null)},[yi,T]),p.useEffect(()=>{const fe=new Set(k.map(Je=>Je.key));mn(Je=>{const St=Object.fromEntries(Object.entries(Je).filter(([dn])=>fe.has(dn)));return Object.keys(St).length===Object.keys(Je).length?Je:St})},[bs]),p.useEffect(()=>{!B||se||Jr.some(fe=>fe.value===j)||B(Zr(N))},[N,j,Jr,se,B]),p.useEffect(()=>{if(!m){Pi(null);return}Pi(document.getElementById(m))},[m]);const An=fe=>o.jsxs("div",{className:`pp-network-region${Pr?" is-open":""}`,onKeyDown:Je=>{Je.key==="Escape"&&Lr(!1)},children:[fe&&o.jsx("span",{children:"发布区域"}),o.jsxs("button",{type:"button",className:"pp-region-trigger","aria-label":"部署区域","aria-haspopup":"listbox","aria-expanded":Pr,"aria-describedby":se?Kr:void 0,disabled:Re||se||!B,onClick:()=>Lr(Je=>!Je),children:[o.jsx("span",{children:Di}),o.jsx(LRe,{className:`pp-region-chevron${Pr?" is-open":""}`})]}),Pr&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>Lr(!1)}),o.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"部署区域",children:Jr.map(Je=>{const St=Je.value===j;return o.jsxs("button",{type:"button",role:"option","aria-selected":St,className:`pp-region-option${St?" is-selected":""}`,onClick:()=>{B==null||B(Je.value),Lr(!1)},children:[o.jsx("span",{children:Je.label}),St&&o.jsx(Su,{"aria-hidden":"true"})]},Je.value)})})]}),se&&o.jsx("span",{id:Kr,className:"pp-region-help",children:"更新时沿用现有 Runtime 的部署区域,无法修改。"})]});p.useEffect(()=>(Cr.current=!0,()=>{Cr.current=!1}),[]),p.useEffect(()=>{oa("1"),Ws(ie||tt?"1":"5")},[ie,tt]),p.useEffect(()=>{Ps.current!==j&&(Ps.current=j,pr(fe=>({tos:fe.tos.mode==="existing"?{mode:"existing"}:fe.tos,cr:fe.cr.mode==="existing"?{mode:"existing"}:fe.cr,codePipeline:fe.codePipeline.mode==="existing"?{mode:"existing"}:fe.codePipeline})),zn(null))},[j]),p.useEffect(()=>{if(!qt)return;const fe=document.body.style.overflow;document.body.style.overflow="hidden";const Je=St=>{St.key==="Escape"&&Dt(!1)};return window.addEventListener("keydown",Je),()=>{document.body.style.overflow=fe,window.removeEventListener("keydown",Je)}},[qt]);const $r=p.useMemo(()=>!(e!=null&&e.files)||!Array.isArray(e.files)?{name:"",children:new Map}:Jjt(e.files),[e==null?void 0:e.files]);if(!e||!Array.isArray(e.files))return o.jsx("div",{className:"pp-error",children:"项目数据无效"});const Gr=e.files.find(fe=>fe.path===Ue)??null,Zs=(I==null?void 0:I.mode)??"public",Ta=()=>({agentId:String((i==null?void 0:i.trim())||e.name||"unknown"),deployAction:g?"update":"create",deploySource:F.source,createMode:F.createMode,aiAssisted:F.aiAssisted?1:0,deployRegion:String(j),runtimeNetworkType:Zs,feishuEnabled:w?1:0}),No=new Set(_.map(fe=>fe.key)),Va=cjt(w?[...k,...qx]:k,A).filter(fe=>!No.has(fe.key)),Dd=Va.length+_.length+Xt.length,Ks=Pt.apiKeyId===Ee?Pt:n3,so=Ks.status==="visible",jo=Ee?Ks.status==="loading"?"正在显示 API Key":so?"隐藏 API Key":Ks.status==="error"?"重试显示 API Key":"显示 API Key":"请先选择 API Key";function Pd(fe){Me(Je=>{const St=new Set(Je);return St.has(fe)?St.delete(fe):St.add(fe),St})}function ao(fe,Je){l&&(l({...e,files:fe}),Je!==void 0&&re(Je))}function ol(fe){Gr&&ao(e.files.map(Je=>Je.path===Gr.path?{...Je,content:fe}:Je))}function oo(){const fe=_e.trim();if(Z(!1),rt(""),!!fe){if(e.files.some(Je=>Je.path===fe)){re(fe);return}ao([...e.files,{path:fe,content:""}],fe)}}function Yl(){if(!Gr)return;const fe=window.prompt("重命名文件",Gr.path),Je=fe==null?void 0:fe.trim();!Je||Je===Gr.path||e.files.some(St=>St.path===Je)||ao(e.files.map(St=>St.path===Gr.path?{...St,path:Je}:St),Je)}function Ru(){var Je;if(!Gr)return;const fe=e.files.filter(St=>St.path!==Gr.path);ao(fe,((Je=fe[0])==null?void 0:Je.path)??null)}function Fc(fe,Je){Fe(St=>St.map(dn=>dn.id===fe?{...dn,...Je}:dn))}function Iu(fe){Fe(Je=>Je.filter(St=>St.id!==fe))}function Ro(){Fe(fe=>[...fe,tRt()])}function zc(fe){mn(Je=>{if(!(fe in Je))return Je;const St={...Je};return delete St[fe],St})}function Zl(fe){window.requestAnimationFrame(()=>{const Je=Mt.current.get(fe);Je&&(Je.focus({preventScroll:!0}),Je.scrollIntoView({block:"center",behavior:"smooth"}))})}function Md(fe){$&&$(fe==="public"?void 0:{...I??{mode:fe},mode:fe})}function kn(fe){$==null||$({...I??{mode:"private"},...fe})}function Vc(){var dn,Zt,Tt,Lt;const fe=new Map(Xt.map(Ne=>({key:Ne.key.trim(),value:Ne.value})).filter(Ne=>Ne.key.length>0).map(Ne=>[Ne.key,Ne.value])),Je=w?[...k,...qx]:k;for(const Ne of CU(Je,A))fe.set(Ne.key,Ne.value);for(const Ne of _){const tn=Kn[Ne.key]??"";tn.trim()&&fe.set(Ne.key,tn)}const St=Ne=>Ne.agentType==="llm"&&am(Ne,N)==="ark"||Ne.subAgents.some(St);if(r&&St(r)){const Ne=(Zt=(dn=r.deployment)==null?void 0:dn.modelApiKeyId)==null?void 0:Zt.trim(),tn=(Lt=(Tt=r.deployment)==null?void 0:Tt.modelApiKeyName)==null?void 0:Lt.trim();Ne&&fe.set("MODEL_AGENT_API_KEY_ID",Ne),tn&&fe.set("MODEL_AGENT_API_KEY_NAME",tn)}return[...fe].map(([Ne,tn])=>({key:Ne,value:tn}))}async function _h(){if(!(!S||Re||Xe)){xt(null),nt(!0);try{await S(!w)}catch(fe){Cr.current&&xt(`更新飞书配置失败:${fe instanceof Error?fe.message:String(fe)}`)}finally{Cr.current&&nt(!1)}}}const ae=p.useCallback(fe=>{it(fe)},[]);async function In(){var Tt;if(!c||Re||Ge||V)return;if(Se){xt(Se);return}if(!se){const Lt=Bve(ar);if(Lt){zn(Lt),xt(Lt);return}}if(zn(null),!pn.valid){xt(pn.error);return}if(!se&&Tr==="user_pool"&&!Ii){xt("请选择用于 Runtime 鉴权的用户池。");return}if(Zs!=="public"&&!((Tt=I==null?void 0:I.vpcId)!=null&&Tt.trim())){xt("使用 VPC 网络时,请填写 VPC ID。");return}const fe=_.find(Lt=>!(Kn[Lt.key]??"").trim());if(fe){Ve(fe.key),xt(`请填写 ${fe.label},用于访问对应的自定义模型地址。`);return}Ve(null);const Je=Nwe(k,A),St=k.find(Lt=>Lt.key==="MODEL_AGENT_API_KEY"&&Lt.required&&Lt.serverManaged&&!Ee),dn=[...St?[St]:[],...Je];if(dn.length){const Lt=Object.fromEntries(dn.map(Ne=>{var tn;return[Ne.key,Ne.serverManaged?`${((tn=Cee(Ne))==null?void 0:tn.replace(/。$/,""))||Ne.comment||Ne.key},请先返回模型配置选择 API Key。`:djt(Ne)]}));mn(Lt),xt(Lt[dn[0].key]),Zl(dn[0].key);return}mn({});const Zt=n$(k,A);if(Zt){xt(`${Zt.spec.comment||Zt.spec.key}:${Zt.error}`);return}if(w){const Lt=qx.find(Ne=>!String(A[Ne.key]??"").trim()&&!ge.has(Ne.key));if(Lt){const Ne=qx.find(tn=>tn.key===Lt.key);xt(`启用飞书后,请填写${(Ne==null?void 0:Ne.comment)||(Ne==null?void 0:Ne.key)}。`);return}}if(!se){const Lt=Oe.trim(),Ne=`${j}\0${Lt}`;Ae(!0),xt(null);try{const tn=await $N(Lt,j);if(!Cr.current||he.current!==Ne)return;if(!tn.available){const or="Runtime 名称已存在,请修改后重试。";ze({key:Ne,message:or}),xt(or);return}ze(null)}catch(tn){if(!Cr.current)return;xt(tn instanceof Error?tn.message:String(tn));return}finally{Cr.current&&Ae(!1)}}kt(!0)}async function Vn(){var gr,Nr;if(!c||Re)return;if(Se){kt(!1),xt(Se);return}if(!pn.valid){kt(!1),xt(pn.error);return}kt(!1);const fe=Vc();Cr.current&&(xt(null),xe(null),_t({}),Kt(null),We(!0));const Je=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,St=(i==null?void 0:i.trim())||(r==null?void 0:r.name)||e.name,dn=Oe.trim();let Zt=dn;const Tt=Date.now(),Lt=lwe(Ta()),Ne={id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"running",phase:"prepare",label:"准备部署",agentDraft:r,githubDelivery:!!ve,instanceRange:Oi?{min:pn.min,max:pn.max}:void 0,createEvaluationSets:_a};x==null||x(Ne),v==null||v(Ne);let tn,or,W=Ne.phase??"prepare",Te=Ne.message;const dt=xn=>tn?{...tn,status:xn,updatedAt:Date.now()}:void 0,nn=xn=>{const Jt=dt(xn);return Jt?{buildLog:Jt}:{}},an=()=>({source:"code-pipeline",status:"running",text:"",lineCount:0,truncated:!1,updatedAt:Date.now(),pendingMessage:"正在等待构建日志…"}),on=(xn,Jt="running")=>{const Un=[(or==null?void 0:or.text)??"",xn].filter(Boolean).join(`
+`).length:0,a=!!(t.snapshotTruncated||t.truncated),l=!!(e!=null&&e.omittedEarly||i.omitted);return{...t,text:i.text,lineCount:s,truncated:!!(e!=null&&e.truncated||t.truncated||l),omittedEarly:l,snapshotTruncated:!!(e!=null&&e.snapshotTruncated||a)}}function jjt(e){const t=e.trim();if(!t)return"GitHub 仓库";const n=t.match(/github\.com[:/](?[^/\s]+)\/(?[^/\s#?]+?)(?:\.git)?(?:[/?#].*)?$/);return n!=null&&n.groups?`${n.groups.owner}/${n.groups.repo}`:t}function ob(e){return e.trim()||"main"}function jee(e){return e instanceof Tv?e.detail:e instanceof Error?{message:e.message}:{message:String(e||"同步 GitHub 代码失败")}}function Rjt(e){return e.status==="cicd-bound"?"已挂载":e.status==="bound"?"已绑定":e.status==="succeeded"?"已同步":e.status||"已创建"}function Ijt(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M6.2 3.8H4.3A1.8 1.8 0 0 0 2.5 5.6v6.1a1.8 1.8 0 0 0 1.8 1.8h6.1a1.8 1.8 0 0 0 1.8-1.8V9.8"}),o.jsx("path",{d:"M8.7 2.5h4.8v4.8"}),o.jsx("path",{d:"m13.1 2.9-6 6"})]})}function Ree(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.24"}),o.jsx("path",{d:"M13.5 8A5.5 5.5 0 0 0 8 2.5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]})}function Djt({project:e,region:t,cloudProvider:n,runtimeId:r,binding:i,disabled:s=!1,showSetup:a=!0,onPendingCicdChange:l,onBindingChange:c}){var ie,q,G;const[u,d]=p.useState(""),[f,h]=p.useState(""),[m,g]=p.useState("main"),[b,y]=p.useState(""),[O,v]=p.useState(""),[x,w]=p.useState(""),[S,E]=p.useState("source"),[k,_]=p.useState(!1),[T,C]=p.useState(!1),[A,R]=p.useState(null),[M,I]=p.useState(null),[$,N]=p.useState(!1);p.useEffect(()=>{(i!=null&&i.pipelineId||i!=null&&i.runtimeId||i!=null&&i.status)&&R(i)},[i]),p.useEffect(()=>{let J=!1;if(!r){R(null),c==null||c(null);return}return C(!0),Xoe(r).then(ue=>{J||(R(ue),c==null||c(ue))}).catch(ue=>{J||I(jee(ue))}).finally(()=>{J||C(!1)}),()=>{J=!0}},[c,r]),p.useEffect(()=>{if(!l)return;if(r||S!=="cicd"||!a){l(null),N(!1);return}const J=u.trim(),ue=f.trim(),Oe=b.trim(),Qe=O.trim();if(!J||!ue||!Oe||!Qe||e.files.length===0){l(null),N(!1);return}l({githubUrl:J,githubToken:f,baseBranch:ob(m),volcengineAccessKey:Oe,volcengineSecretKey:O,volcengineSessionToken:x.trim(),pipelineId:A==null?void 0:A.pipelineId,cloudProvider:n})},[m,n,f,u,S,l,e.files.length,A==null?void 0:A.pipelineId,r,a,b,O,x]);const j=p.useMemo(()=>jjt(u),[u]),B=A==null?void 0:A.github,F=B!=null&&B.owner&&B.repo?`${B.owner}/${B.repo}`:(B==null?void 0:B.repo)??j,L=(B==null?void 0:B.branch)??ob(m),H=A==null?void 0:A.runtimeId,z=S==="cicd",Q=n==="byteplus"?"BytePlus":"火山",V=!a&&!!r,K=a&&!s&&!k&&u.trim().length>0&&f.trim().length>0&&(z?b.trim().length>0&&O.trim().length>0&&(!!r||e.files.length>0):e.files.length>0),se=z?r?"挂载持续交付":$?"已选择,部署时挂载":"部署时挂载持续交付":"同步代码";async function ge(J){if(J.preventDefault(),!!K){_(!0),R(null),I(null);try{if(z&&!r){l==null||l({githubUrl:u.trim(),githubToken:f,baseBranch:ob(m),volcengineAccessKey:b.trim(),volcengineSecretKey:O,volcengineSessionToken:x.trim(),cloudProvider:n}),N(!0);return}const ue=z&&r?await Hoe({githubUrl:u.trim(),githubToken:f,baseBranch:ob(m),runtimeName:e.name,runtimeId:r??"",region:t,cloudProvider:n,projectPath:".",volcengineAccessKey:b.trim(),volcengineSecretKey:O,volcengineSessionToken:x.trim()}):await Voe({project:e,githubUrl:u.trim(),githubToken:f,baseBranch:ob(m),region:t,cloudProvider:n}),Oe=!z&&r&&ue.pipelineId?await S9({pipelineId:ue.pipelineId,runtimeId:r,region:t,cloudProvider:n}):ue;R(Oe),c==null||c(Oe),z&&!r&&Oe.pipelineId&&(l==null||l({githubUrl:u.trim(),githubToken:f,baseBranch:ob(m),volcengineAccessKey:b.trim(),volcengineSecretKey:O,volcengineSessionToken:x.trim(),pipelineId:Oe.pipelineId,cloudProvider:n})),(!z||r)&&(h(""),y(""),v(""),w(""))}catch(ue){I(jee(ue))}finally{_(!1)}}}return V&&!T&&!A?null:o.jsxs("section",{className:"pp-config-section pp-github-cicd",children:[o.jsxs("div",{className:"pp-config-label pp-github-cicd-title",children:[a?o.jsxs("div",{className:"pp-github-cicd-tabs",role:"tablist","aria-label":"GitHub 交付模式",children:[o.jsx("button",{type:"button",className:S==="source"?"is-active":"",role:"tab","aria-selected":S==="source",onClick:()=>E("source"),children:"GitHub 代码同步"}),o.jsx("button",{type:"button",role:"tab",className:S==="cicd"?"is-active":"","aria-selected":S==="cicd",onClick:()=>E("cicd"),children:"挂载持续交付"})]}):o.jsx("span",{children:"GitHub 交付"}),(k||T)&&o.jsxs("span",{className:"pp-github-cicd-status",role:"status",children:[o.jsx(Ree,{className:"pp-ic spin"}),T?"读取中":"执行中"]})]}),a&&o.jsx("p",{className:"pp-github-cicd-copy",children:z?r?"写入 AgentKit Runtime GitHub Actions workflow,后续 GitHub 提交会更新绑定 Runtime。":"首次部署成功后初始化目标分支,后续 GitHub 提交会更新绑定 Runtime。":"Studio 会直接 push 到目标分支;该分支由 Studio 管理,远端冲突时同步会失败。Runtime 仍由部署按钮发布。"}),a&&o.jsxs("form",{className:"pp-github-cicd-form",onSubmit:ge,children:[o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsx("span",{children:"GitHub URL"}),o.jsx("input",{value:u,placeholder:"https://github.com/org/repo",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),d(J.currentTarget.value)}})]}),o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsx("span",{children:"Token"}),o.jsx("input",{type:"password",value:f,placeholder:"repo 或 contents write 权限",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),h(J.currentTarget.value)}})]}),o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsx("span",{children:"目标分支"}),o.jsx("input",{value:m,placeholder:"main",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),g(J.currentTarget.value)}})]}),z&&o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsxs("span",{children:[Q," AK"]}),o.jsx("input",{type:"password",value:b,placeholder:"用于写入 GitHub Actions Secret",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),y(J.currentTarget.value)}})]}),o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsxs("span",{children:[Q," SK"]}),o.jsx("input",{type:"password",value:O,placeholder:"用于写入 GitHub Actions Secret",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),v(J.currentTarget.value)}})]}),o.jsxs("label",{className:"pp-github-cicd-field",children:[o.jsxs("span",{children:[Q," Session Token"]}),o.jsx("input",{type:"password",value:x,placeholder:"临时凭证可选",disabled:s||k,autoComplete:"off",onChange:J=>{N(!1),w(J.currentTarget.value)}})]})]}),o.jsx("button",{type:"submit",className:"pp-github-cicd-submit",disabled:!K,children:k?o.jsxs(o.Fragment,{children:[o.jsx(Ree,{className:"pp-ic spin"}),"同步中…"]}):se})]}),$&&!A&&o.jsx("p",{className:"pp-github-cicd-bound-note",children:"已选择挂载持续交付。点击部署后,Studio 会等待 Runtime 创建完成并初始化 GitHub 目标分支,初始化成功后才完成部署流程。"}),A&&o.jsxs("div",{className:"pp-github-cicd-result",role:"status",children:[o.jsxs("div",{className:"pp-github-cicd-result-head",children:[o.jsx("strong",{children:(ie=A.cicd)!=null&&ie.enabled?A.runtimeId?"已挂载持续交付":"已选择挂载持续交付":H?"已绑定 GitHub":"代码已同步"}),o.jsx("span",{children:Rjt(A)})]}),o.jsxs("dl",{className:"pp-github-cicd-result-grid",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"仓库"}),o.jsx("dd",{children:F})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"分支"}),o.jsx("dd",{children:L})]}),H&&o.jsxs("div",{children:[o.jsx("dt",{children:"Runtime"}),o.jsx("dd",{children:H})]}),(B==null?void 0:B.commitSha)&&o.jsxs("div",{children:[o.jsx("dt",{children:"Commit"}),o.jsx("dd",{children:B.commitSha.slice(0,12)})]}),((q=A.cicd)==null?void 0:q.workflowPath)&&o.jsxs("div",{children:[o.jsx("dt",{children:"Workflow"}),o.jsx("dd",{children:A.cicd.workflowPath})]})]}),o.jsx("div",{className:"pp-github-cicd-links",children:(B==null?void 0:B.pullRequestUrl)&&o.jsxs("a",{href:B.pullRequestUrl,target:"_blank",rel:"noopener noreferrer",children:[o.jsx(Ijt,{className:"pp-ic"}),"查看 PR"]})}),H&&o.jsx("p",{className:"pp-github-cicd-bound-note",children:(G=A.cicd)!=null&&G.enabled?"目标分支提交会触发 Runtime 持续交付。":"更新并发布时会先同步当前源码到这个分支。"})]}),M&&o.jsxs("div",{className:"pp-github-cicd-error",role:"alert",children:[o.jsx("strong",{children:"创建失败"}),o.jsx("p",{children:M.message}),(M.phase||M.runtimeId||M.logPath)&&o.jsxs("dl",{children:[M.phase&&o.jsxs("div",{children:[o.jsx("dt",{children:"阶段"}),o.jsx("dd",{children:M.phase})]}),M.runtimeId&&o.jsxs("div",{children:[o.jsx("dt",{children:"Runtime"}),o.jsx("dd",{children:M.runtimeId})]}),M.logPath&&o.jsxs("div",{children:[o.jsx("dt",{children:"日志"}),o.jsx("dd",{children:M.logPath})]})]})]})]})}eo.registerLanguage("python",Eme);eo.registerLanguage("typescript",Mme);eo.registerLanguage("javascript",yme);eo.registerLanguage("json",Ome);eo.registerLanguage("yaml",Lme);eo.registerLanguage("markdown",Sme);eo.registerLanguage("bash",yB);eo.registerLanguage("ini",hme);eo.registerLanguage("dockerfile",cnt);eo.registerLanguage("makefile",wme);function Iee(e){switch(e){case"prepare":case"upload":case"build":case"deploy":case"publish":case"update":case"evaluation":return e;default:return"unknown"}}const Dee={prepare:0,upload:1,build:2,deploy:3,publish:4,update:5,evaluation:6,complete:7,github:8},p_="构建任务已经提交,但暂时无法确认最终状态。请稍后在 Code Pipeline 查看构建结果,避免重复部署。";function Pjt(e){const t=e instanceof Error?e.message:String(e);return/RunPipeline result could not be reconciled|Polling build status failed/i.test(t)}function Mjt(e,t){if(!t)return e??"prepare";if(!e)return t;const n=Dee[e],r=Dee[t];return n===void 0||r===void 0||r>=n?t:e}const Ljt=p.lazy(()=>fd(()=>Promise.resolve().then(()=>ave),void 0)),Vh=()=>{};function $jt({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M2.75 12s3.35-5.25 9.25-5.25S21.25 12 21.25 12 17.9 17.25 12 17.25 2.75 12 2.75 12Z"}),o.jsx("circle",{cx:"12",cy:"12",r:"2.5"})]})}function Bjt({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M3 3l18 18"}),o.jsx("path",{d:"M9.7 6.95A9.7 9.7 0 0 1 12 6.68c5.9 0 9.25 5.32 9.25 5.32a16 16 0 0 1-2.28 2.85"}),o.jsx("path",{d:"M14.35 14.55A3.25 3.25 0 0 1 9.5 10.2"}),o.jsx("path",{d:"M6.25 8.12A16.4 16.4 0 0 0 2.75 12S6.1 17.32 12 17.32c.8 0 1.55-.1 2.25-.27"})]})}const n3={status:"hidden",apiKeyId:"",value:"",error:""};function Qjt({open:e,isUpdate:t,title:n,description:r,confirmLabel:i,onCancel:s,onConfirm:a}){const l=p.useRef(null);return p.useEffect(()=>{var d;if(!e)return;const c=document.body.style.overflow;document.body.style.overflow="hidden",(d=l.current)==null||d.focus();const u=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",u),()=>{document.body.style.overflow=c,window.removeEventListener("keydown",u)}},[s,e]),e?kr.createPortal(o.jsx("div",{className:"code-browser-backdrop pp-confirm-backdrop",onMouseDown:c=>{c.target===c.currentTarget&&s()},children:o.jsxs("section",{className:"code-browser-dialog pp-confirm-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"pp-confirm-title","aria-describedby":"pp-confirm-description",children:[o.jsxs("header",{className:"code-browser-head pp-confirm-head",children:[o.jsxs("div",{className:"code-browser-title-wrap",children:[o.jsx("span",{className:"code-browser-title-icon pp-confirm-icon","aria-hidden":"true",children:o.jsx(uIe,{})}),o.jsx("h2",{id:"pp-confirm-title",children:n??(t?"确认更新":"确认部署")})]}),o.jsx("button",{type:"button",className:"code-browser-close",onClick:s,"aria-label":"关闭部署确认",children:o.jsx(Ea,{"aria-hidden":"true"})})]}),o.jsx("div",{className:"pp-confirm-body",children:o.jsx("p",{id:"pp-confirm-description",children:r??(t?"将更新并发布到当前云端 Runtime,过程可能需要几分钟。确定继续吗?":"将创建新的云端 Runtime,部署过程可能需要几分钟。确定继续吗?")})}),o.jsxs("footer",{className:"pp-confirm-actions",children:[o.jsx("button",{ref:l,type:"button",onClick:s,children:"取消"}),o.jsx("button",{type:"button",className:"is-primary",onClick:a,children:i??(t?"确定更新":"确定部署")})]})]})}),document.body):null}function Ujt({value:e,disabled:t,onChange:n}){const[r,i]=p.useState([]),[s,a]=p.useState(!0),[l,c]=p.useState(null),[u,d]=p.useState(0);p.useEffect(()=>{const m=new AbortController;return a(!0),c(null),BN(m.signal).then(g=>i(g)).catch(g=>{g instanceof DOMException&&g.name==="AbortError"||(i([]),c(g instanceof Error?g.message:String(g)))}).finally(()=>{m.signal.aborted||a(!1)}),()=>m.abort()},[u]);const f=p.useMemo(()=>[...r].sort((m,g)=>Number(g.isCurrent)-Number(m.isCurrent)).map(m=>({value:m.uid,label:m.name.trim()||"未命名用户池",description:m.domain||m.uid,badge:m.isCurrent?"当前用户池":void 0})),[r]),h=r.find(m=>m.uid===e);return o.jsxs("div",{className:"pp-user-pool-picker",children:[o.jsx(GE,{ariaLabel:"部署用户池",value:e,placeholder:s?"正在加载用户池…":"请选择用户池",options:f,disabled:t||s||!!l,onChange:n}),l?o.jsxs("div",{className:"pp-user-pool-error",role:"alert",children:[o.jsx("span",{children:l}),o.jsx("button",{type:"button",onClick:()=>d(m=>m+1),children:"重试"})]}):s?o.jsxs("span",{className:"pp-user-pool-status","aria-live":"polite",children:[o.jsx(rr,{"aria-hidden":"true",className:"pp-user-pool-spinner"}),"正在加载 Identity 用户池…"]}):r.length===0?o.jsx("span",{className:"pp-user-pool-status",children:"当前账号下暂无 Identity 用户池。"}):h!=null&&h.isCurrent?o.jsx("span",{className:"pp-user-pool-status",children:"当前 Studio 的登录 JWT 将透传访问此 Runtime。"}):h?o.jsx("div",{className:"pp-user-pool-error",role:"alert",children:o.jsx("span",{children:"所选用户池不是当前 Studio 使用的用户池,部署后无法从 Studio 调用此 Runtime。"})}):o.jsx("span",{className:"pp-user-pool-status",children:"当前 Studio 使用的用户池已在列表中标注。"})]})}const Fjt=[{value:"api_key",label:"API Key",description:"默认方式,使用 Runtime API Key 访问"},{value:"user_pool",label:"用户池",description:"使用 Identity 用户池签发的 JWT"}],zjt={py:"python",pyi:"python",ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",jsonc:"json",yaml:"yaml",yml:"yaml",md:"markdown",markdown:"markdown",sh:"bash",bash:"bash",zsh:"bash",toml:"ini",ini:"ini",cfg:"ini",conf:"ini",env:"ini",txt:"plaintext"},Pee={dockerfile:"dockerfile","requirements.txt":"plaintext","requirements-dev.txt":"plaintext",".env":"ini",".gitignore":"plaintext",makefile:"makefile"};function Mee(e){return e.replace(/&/g,"&").replace(//g,">")}function Vjt(e){const n=(e.split("/").pop()??e).toLowerCase();if(Pee[n])return Pee[n];if(n.startsWith("dockerfile"))return"dockerfile";if(n.startsWith(".env"))return"ini";const r=n.lastIndexOf(".");if(r===-1)return null;const i=n.slice(r+1);return zjt[i]??null}function Hjt(e,t){try{const n=Vjt(t);return n&&eo.getLanguage(n)?eo.highlight(e,{language:n,ignoreIllegals:!0}).value:n===null?eo.highlightAuto(e).value:Mee(e)}catch{return Mee(e)}}const qjt=[{phase:"build",label:"构建镜像"},{phase:"deploy",label:"部署"},{phase:"publish",label:"发布"}],Xjt={phase:"github",label:"同步代码"},Gjt=[{phase:"upload",label:"上传代码包"},{phase:"build",label:"镜像打包"},{phase:"deploy",label:"创建 Runtime"},{phase:"publish",label:"发布服务"}],Wjt={phase:"update",label:"更新实例配置"},Yjt={phase:"evaluation",label:"创建评测集"};function Zjt(e){return e?!e.memory.shortTerm||(e.shortTermBackend||"local")==="local":!1}function Kjt(e,t){const n=Number(e),r=Number(t);return!e.trim()||!t.trim()||!Number.isSafeInteger(n)||!Number.isSafeInteger(r)||n<0||r<1?{valid:!1,error:"最小实例数必须为大于等于 0 的整数,最大实例数必须为大于 0 的整数。"}:n>r?{valid:!1,error:"最小实例数不能大于最大实例数。"}:{valid:!0,min:n,max:r}}function Jjt(e){const t={name:"",children:new Map};for(const n of e){const r=n.path.split("/").filter(Boolean);let i=t;r.forEach((s,a)=>{let l=i.children.get(s);l||(l={name:s,children:new Map},i.children.set(s,l)),a===r.length-1&&(l.path=n.path),i=l})}return t}function eRt(e,t=!1){return[...e.children.values()].sort((n,r)=>{const i=n.children.size>0&&n.path===void 0,s=r.children.size>0&&r.path===void 0;return i!==s?t?i?1:-1:i?-1:1:n.name.localeCompare(r.name)})}function tRt(e="",t=""){return{id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,key:e,value:t}}function nRt({left:e,right:t}){const[n,r]=p.useState(null);return p.useLayoutEffect(()=>{const i=document.getElementById("veadk-page-header-left"),s=document.getElementById("veadk-page-header-actions");i&&s&&r({left:i,right:s})},[]),n?o.jsxs(o.Fragment,{children:[kr.createPortal(e,n.left),kr.createPortal(t,n.right)]}):o.jsxs("header",{className:"pp-toolbar",children:[e,t]})}function _R({project:e,embedded:t=!1,deployDisabledReason:n,agentDraft:r,agentName:i,agentCount:s,releaseConfiguration:a,onChange:l,onDeploy:c,onAgentAdded:u,onDeploymentComplete:d,deploymentActionLabel:f="部署",deploymentConfirmation:h,deploymentActionTargetId:m,deploymentRuntimeId:g,deploymentRuntimeName:b,deploymentRuntimeNameCustomized:y=!1,onDeploymentRuntimeNameChange:O,onDeploymentStarted:v,onDeploymentTaskChange:x,feishuEnabled:w=!1,onFeishuEnabledChange:S,configuredRuntimeEnvKeys:E=[],deploymentEnv:k=[],requiredSecretEnv:_=[],requiredSecretEnvValues:T,onRequiredSecretEnvChange:C,deploymentEnvValues:A={},onDeploymentEnvChange:R,onFeishuCredentialsChange:M,network:I,onNetworkChange:$,cloudProvider:N="volcengine",deployRegion:j=Zr(N),onDeployRegionChange:B,deploymentTelemetry:F={source:"unknown",createMode:"unknown",aiAssisted:!1},onBack:L,backLabel:H="返回配置",onExportYaml:z,deploymentPrimaryPane:Q,deployDisabled:V=!1}){var xs,lo,vs,Ar,la,ca;const K=typeof l=="function",se=!!g,ge=p.useMemo(()=>new Set(E),[E]),ie=Zjt(r),q=(i==null?void 0:i.trim())||(r==null?void 0:r.name)||e.name,G=p.useMemo(()=>Kve(q),[q]),[J,ue]=p.useState(null),Oe=se?b??q:y?b??"":J??G,Qe=se?null:WE(Oe),[je,ze]=p.useState(null),[Ge,Ae]=p.useState(!1),Be=`${j}\0${Oe.trim()}`,he=p.useRef(Be);he.current=Be;const be=(je==null?void 0:je.key)===Be?je.message:null,Se=Qe??be,Ee=((lo=(xs=r==null?void 0:r.deployment)==null?void 0:xs.modelApiKeyId)==null?void 0:lo.trim())??"",tt=((vs=r==null?void 0:r.harnessSidecar)==null?void 0:vs.enabled)===!0,[Ue,re]=p.useState(((la=(Ar=e==null?void 0:e.files)==null?void 0:Ar[0])==null?void 0:la.path)??null);p.useEffect(()=>{ue(null),ze(null)},[q]);const[ce,Me]=p.useState(new Set),[Ye,Z]=p.useState(!1),[_e,rt]=p.useState(""),[Re,We]=p.useState(!1),[ct,kt]=p.useState(!1),[qt,Dt]=p.useState(!1),[Xe,nt]=p.useState(!1),[ft,xt]=p.useState(null),[Ie,xe]=p.useState(null),[$e,it]=p.useState(null),[ve,He]=p.useState(null),[pt,_t]=p.useState({}),[It,Kt]=p.useState(null),[en,le]=p.useState(!1),[Xt,Fe]=p.useState([]),[Pt,Ce]=p.useState(n3),gt=p.useRef(null),Vt=p.useRef(Ee);Vt.current=Ee;const[ot,ln]=p.useState({}),Kn=T??ot,[_r,Ve]=p.useState(null),[et,mn]=p.useState({}),Mt=p.useRef(new Map),[ar,pr]=p.useState(Lve),[Gn,zn]=p.useState(null),[Pr,Lr]=p.useState(!1),Kr=p.useId(),qr=p.useId(),mr=p.useId(),Xr=p.useId(),[Tr,oi]=p.useState("api_key"),[Ii,bi]=p.useState(""),Jr=Ed(N),Di=Jf(j,N),[rs,oa]=p.useState("1"),[Qr,Ws]=p.useState(ie||tt?"1":"5"),[is,ka]=p.useState(!0),Ys=N!=="byteplus",_a=Ys&&is,[Ds,Pi]=p.useState(null),Cr=p.useRef(!0),yi=_.map(fe=>`${fe.key}:${fe.label}`).join("|"),bs=k.map(fe=>`${fe.key}:${fe.required}:${fe.serverManaged??!1}:${(fe.requiredBy??[]).join(",")}`).join("|"),Ps=p.useRef(j),pn=Kjt(rs,Qr),Oi=!se&&pn.valid&&(pn.min!==1||pn.max!==5),Ur=Q?Gjt:qjt,ys=Oi?[...Ur,Wjt]:Ur,pe=_a?[...ys,Yjt]:ys,Le=g&&($e!=null&&$e.pipelineId)||ve?[...pe,Xjt]:pe;function At(){var fe;(fe=gt.current)==null||fe.abort(),gt.current=null,Ce(n3)}async function sn(){var St;const fe=Vt.current;if(!fe){Ce({status:"error",apiKeyId:"",value:"",error:"请先在模型配置中选择 API Key。"});return}(St=gt.current)==null||St.abort();const Je=new AbortController;gt.current=Je,Ce({status:"loading",apiKeyId:fe,value:"",error:""});try{const dn=await Zae(fe,Je.signal);if(Je.signal.aborted||Vt.current!==fe)return;Ce({status:"visible",apiKeyId:fe,value:dn.value,error:""})}catch(dn){if(Je.signal.aborted)return;Ce({status:"error",apiKeyId:fe,value:"",error:dn instanceof Error?dn.message:"加载 API Key 失败,请重试。"})}finally{gt.current===Je&&(gt.current=null)}}p.useEffect(()=>{At(),Ee&&mn(fe=>{if(!("MODEL_AGENT_API_KEY"in fe))return fe;const Je={...fe};return delete Je.MODEL_AGENT_API_KEY,Je})},[Ee]),p.useEffect(()=>(window.addEventListener("pagehide",At),()=>{window.removeEventListener("pagehide",At),At()}),[]),p.useEffect(()=>{const fe=new Set(_.map(Je=>Je.key));T===void 0&&ln(Je=>Object.fromEntries(Object.entries(Je).filter(([St])=>fe.has(St)))),Ve(Je=>Je&&fe.has(Je)?Je:null)},[yi,T]),p.useEffect(()=>{const fe=new Set(k.map(Je=>Je.key));mn(Je=>{const St=Object.fromEntries(Object.entries(Je).filter(([dn])=>fe.has(dn)));return Object.keys(St).length===Object.keys(Je).length?Je:St})},[bs]),p.useEffect(()=>{!B||se||Jr.some(fe=>fe.value===j)||B(Zr(N))},[N,j,Jr,se,B]),p.useEffect(()=>{if(!m){Pi(null);return}Pi(document.getElementById(m))},[m]);const An=fe=>o.jsxs("div",{className:`pp-network-region${Pr?" is-open":""}`,onKeyDown:Je=>{Je.key==="Escape"&&Lr(!1)},children:[fe&&o.jsx("span",{children:"发布区域"}),o.jsxs("button",{type:"button",className:"pp-region-trigger","aria-label":"部署区域","aria-haspopup":"listbox","aria-expanded":Pr,"aria-describedby":se?Kr:void 0,disabled:Re||se||!B,onClick:()=>Lr(Je=>!Je),children:[o.jsx("span",{children:Di}),o.jsx(LRe,{className:`pp-region-chevron${Pr?" is-open":""}`})]}),Pr&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>Lr(!1)}),o.jsx("div",{className:"pp-region-menu",role:"listbox","aria-label":"部署区域",children:Jr.map(Je=>{const St=Je.value===j;return o.jsxs("button",{type:"button",role:"option","aria-selected":St,className:`pp-region-option${St?" is-selected":""}`,onClick:()=>{B==null||B(Je.value),Lr(!1)},children:[o.jsx("span",{children:Je.label}),St&&o.jsx(Su,{"aria-hidden":"true"})]},Je.value)})})]}),se&&o.jsx("span",{id:Kr,className:"pp-region-help",children:"更新时沿用现有 Runtime 的部署区域,无法修改。"})]});p.useEffect(()=>(Cr.current=!0,()=>{Cr.current=!1}),[]),p.useEffect(()=>{oa("1"),Ws(ie||tt?"1":"5")},[ie,tt]),p.useEffect(()=>{Ps.current!==j&&(Ps.current=j,pr(fe=>({tos:fe.tos.mode==="existing"?{mode:"existing"}:fe.tos,cr:fe.cr.mode==="existing"?{mode:"existing"}:fe.cr,codePipeline:fe.codePipeline.mode==="existing"?{mode:"existing"}:fe.codePipeline})),zn(null))},[j]),p.useEffect(()=>{if(!qt)return;const fe=document.body.style.overflow;document.body.style.overflow="hidden";const Je=St=>{St.key==="Escape"&&Dt(!1)};return window.addEventListener("keydown",Je),()=>{document.body.style.overflow=fe,window.removeEventListener("keydown",Je)}},[qt]);const $r=p.useMemo(()=>!(e!=null&&e.files)||!Array.isArray(e.files)?{name:"",children:new Map}:Jjt(e.files),[e==null?void 0:e.files]);if(!e||!Array.isArray(e.files))return o.jsx("div",{className:"pp-error",children:"项目数据无效"});const Gr=e.files.find(fe=>fe.path===Ue)??null,Zs=(I==null?void 0:I.mode)??"public",Ta=()=>({agentId:String((i==null?void 0:i.trim())||e.name||"unknown"),deployAction:g?"update":"create",deploySource:F.source,createMode:F.createMode,aiAssisted:F.aiAssisted?1:0,deployRegion:String(j),runtimeNetworkType:Zs,feishuEnabled:w?1:0}),No=new Set(_.map(fe=>fe.key)),Va=cjt(w?[...k,...qx]:k,A).filter(fe=>!No.has(fe.key)),Dd=Va.length+_.length+Xt.length,Ks=Pt.apiKeyId===Ee?Pt:n3,so=Ks.status==="visible",jo=Ee?Ks.status==="loading"?"正在显示 API Key":so?"隐藏 API Key":Ks.status==="error"?"重试显示 API Key":"显示 API Key":"请先选择 API Key";function Pd(fe){Me(Je=>{const St=new Set(Je);return St.has(fe)?St.delete(fe):St.add(fe),St})}function ao(fe,Je){l&&(l({...e,files:fe}),Je!==void 0&&re(Je))}function ol(fe){Gr&&ao(e.files.map(Je=>Je.path===Gr.path?{...Je,content:fe}:Je))}function oo(){const fe=_e.trim();if(Z(!1),rt(""),!!fe){if(e.files.some(Je=>Je.path===fe)){re(fe);return}ao([...e.files,{path:fe,content:""}],fe)}}function Yl(){if(!Gr)return;const fe=window.prompt("重命名文件",Gr.path),Je=fe==null?void 0:fe.trim();!Je||Je===Gr.path||e.files.some(St=>St.path===Je)||ao(e.files.map(St=>St.path===Gr.path?{...St,path:Je}:St),Je)}function Ru(){var Je;if(!Gr)return;const fe=e.files.filter(St=>St.path!==Gr.path);ao(fe,((Je=fe[0])==null?void 0:Je.path)??null)}function Fc(fe,Je){Fe(St=>St.map(dn=>dn.id===fe?{...dn,...Je}:dn))}function Iu(fe){Fe(Je=>Je.filter(St=>St.id!==fe))}function Ro(){Fe(fe=>[...fe,tRt()])}function zc(fe){mn(Je=>{if(!(fe in Je))return Je;const St={...Je};return delete St[fe],St})}function Zl(fe){window.requestAnimationFrame(()=>{const Je=Mt.current.get(fe);Je&&(Je.focus({preventScroll:!0}),Je.scrollIntoView({block:"center",behavior:"smooth"}))})}function Md(fe){$&&$(fe==="public"?void 0:{...I??{mode:fe},mode:fe})}function kn(fe){$==null||$({...I??{mode:"private"},...fe})}function Vc(){var dn,Zt,Tt,Lt;const fe=new Map(Xt.map(Ne=>({key:Ne.key.trim(),value:Ne.value})).filter(Ne=>Ne.key.length>0).map(Ne=>[Ne.key,Ne.value])),Je=w?[...k,...qx]:k;for(const Ne of CU(Je,A))fe.set(Ne.key,Ne.value);for(const Ne of _){const tn=Kn[Ne.key]??"";tn.trim()&&fe.set(Ne.key,tn)}const St=Ne=>Ne.agentType==="llm"&&am(Ne,N)==="ark"||Ne.subAgents.some(St);if(r&&St(r)){const Ne=(Zt=(dn=r.deployment)==null?void 0:dn.modelApiKeyId)==null?void 0:Zt.trim(),tn=(Lt=(Tt=r.deployment)==null?void 0:Tt.modelApiKeyName)==null?void 0:Lt.trim();Ne&&fe.set("MODEL_AGENT_API_KEY_ID",Ne),tn&&fe.set("MODEL_AGENT_API_KEY_NAME",tn)}return[...fe].map(([Ne,tn])=>({key:Ne,value:tn}))}async function _h(){if(!(!S||Re||Xe)){xt(null),nt(!0);try{await S(!w)}catch(fe){Cr.current&&xt(`更新飞书配置失败:${fe instanceof Error?fe.message:String(fe)}`)}finally{Cr.current&&nt(!1)}}}const ae=p.useCallback(fe=>{it(fe)},[]);async function In(){var Tt;if(!c||Re||Ge||V)return;if(Se){xt(Se);return}if(!se){const Lt=Bve(ar);if(Lt){zn(Lt),xt(Lt);return}}if(zn(null),!pn.valid){xt(pn.error);return}if(!se&&Tr==="user_pool"&&!Ii){xt("请选择用于 Runtime 鉴权的用户池。");return}if(Zs!=="public"&&!((Tt=I==null?void 0:I.vpcId)!=null&&Tt.trim())){xt("使用 VPC 网络时,请填写 VPC ID。");return}const fe=_.find(Lt=>!(Kn[Lt.key]??"").trim());if(fe){Ve(fe.key),xt(`请填写 ${fe.label},用于访问对应的自定义模型地址。`);return}Ve(null);const Je=Nwe(k,A),St=k.find(Lt=>Lt.key==="MODEL_AGENT_API_KEY"&&Lt.required&&Lt.serverManaged&&!Ee),dn=[...St?[St]:[],...Je];if(dn.length){const Lt=Object.fromEntries(dn.map(Ne=>{var tn;return[Ne.key,Ne.serverManaged?`${((tn=Cee(Ne))==null?void 0:tn.replace(/。$/,""))||Ne.comment||Ne.key},请先返回模型配置选择 API Key。`:djt(Ne)]}));mn(Lt),xt(Lt[dn[0].key]),Zl(dn[0].key);return}mn({});const Zt=n$(k,A);if(Zt){xt(`${Zt.spec.comment||Zt.spec.key}:${Zt.error}`);return}if(w){const Lt=qx.find(Ne=>!String(A[Ne.key]??"").trim()&&!ge.has(Ne.key));if(Lt){const Ne=qx.find(tn=>tn.key===Lt.key);xt(`启用飞书后,请填写${(Ne==null?void 0:Ne.comment)||(Ne==null?void 0:Ne.key)}。`);return}}if(!se){const Lt=Oe.trim(),Ne=`${j}\0${Lt}`;Ae(!0),xt(null);try{const tn=await $N(Lt,j);if(!Cr.current||he.current!==Ne)return;if(!tn.available){const or="Runtime 名称已存在,请修改后重试。";ze({key:Ne,message:or}),xt(or);return}ze(null)}catch(tn){if(!Cr.current)return;xt(tn instanceof Error?tn.message:String(tn));return}finally{Cr.current&&Ae(!1)}}kt(!0)}async function Vn(){var gr,Nr;if(!c||Re)return;if(Se){kt(!1),xt(Se);return}if(!pn.valid){kt(!1),xt(pn.error);return}kt(!1);const fe=Vc();Cr.current&&(xt(null),xe(null),_t({}),Kt(null),We(!0));const Je=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,St=(i==null?void 0:i.trim())||(r==null?void 0:r.name)||e.name,dn=Oe.trim();let Zt=dn;const Tt=Date.now(),Lt=lwe(Ta()),Ne={id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"running",phase:"prepare",label:"准备部署",agentDraft:r,githubDelivery:!!ve,instanceRange:Oi?{min:pn.min,max:pn.max}:void 0,createEvaluationSets:_a};x==null||x(Ne),v==null||v(Ne);let tn,or,W=Ne.phase??"prepare",Te=Ne.message;const dt=xn=>tn?{...tn,status:xn,updatedAt:Date.now()}:void 0,nn=xn=>{const Jt=dt(xn);return Jt?{buildLog:Jt}:{}},an=()=>({source:"code-pipeline",status:"running",text:"",lineCount:0,truncated:!1,updatedAt:Date.now(),pendingMessage:"正在等待构建日志…"}),on=(xn,Jt="running")=>{const Un=[(or==null?void 0:or.text)??"",xn].filter(Boolean).join(`
`);return or={source:"github-delivery",status:Jt,text:Un,lineCount:Un?Un.split(`
-`).length:0,truncated:!1,updatedAt:Date.now(),pendingMessage:Jt==="running"?"正在等待 GitHub 挂载日志…":void 0},or},er=()=>{if(!(W!=="build"||!(tn!=null&&tn.text)))return tn={...tn,status:"error",updatedAt:Date.now()},tn},Wr=xn=>W==="build"&&(tn!=null&&tn.text)?Iy(tn.text,{preserveEnd:!0}):Iy(xn);try{let xn=$e;if(g&&($e!=null&&$e.pipelineId)){W="github";const Ut=on("正在同步当前源码到 GitHub"),Un={level:"info",phase:"github",message:"正在同步当前源码到 GitHub",pct:0};Cr.current&&(_t(ci=>({...ci,github:Un})),Kt("github")),x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"running",phase:"github",label:"同步 GitHub 代码",message:Un.message,pct:0,githubDelivery:!0,githubLog:Ut});const _n=await Woe({runtimeId:g,project:e});if(xn=_n,Cr.current&&(it(_n),_t(ci=>({...ci,github:{level:"success",phase:"github",message:"GitHub 代码已同步",pct:100}})),Kt(null)),(gr=_n.cicd)!=null&&gr.enabled){x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"success",phase:"github",label:"GitHub 代码已提交",message:"代码已提交到 GitHub,GitHub Actions 正在更新同一个 Runtime",pct:100,githubDelivery:!0,githubLog:on("代码已提交到 GitHub,GitHub Actions 正在更新同一个 Runtime","complete")});return}}const Jt=await c(e,Ut=>{var _n;Ut.runtimeName&&(Zt=Ut.runtimeName);const Un=Mjt(W,Ut.phase);Ut.buildLog?tn=Njt(tn,Ut.buildLog):Ut.phase==="build"&&!tn&&(tn=an()),Ut.phase===Un&&(Te=Ut.message),W=Un,Cr.current&&(_t(ci=>({...ci,[Ut.phase]:Ut})),Kt(W)),x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"running",phase:W,label:((_n=Le.find(ci=>ci.phase===W))==null?void 0:_n.label)??W,message:Te,pct:Ut.pct,...tn?{buildLog:tn}:{}})},{taskId:Je,runtimeName:dn,sessionStorage:ie?"in-memory":"persistent",minInstance:pn.min,maxInstance:pn.max,...se?{}:{authentication:Tr==="user_pool"?{type:"user_pool",userPoolUid:Ii}:{type:"api_key"}},createEvaluationSets:_a,...w?{im:{feishu:{enabled:!0}}}:{},envs:fe,...se?{}:{resources:ar}});if(!g&&ve&&Jt.runtimeId){W="github";const Ut=on("开始初始化 GitHub main 分支与 Actions workflow"),Un={level:"info",phase:"github",message:"正在初始化 GitHub 持续交付目标分支",pct:0};Cr.current&&(_t(_n=>({..._n,github:Un})),Kt("github")),x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId,region:Jt.region||j,startedAt:Tt,status:"running",phase:"github",label:"挂载 GitHub 持续交付",message:Un.message,pct:0,githubDelivery:!0,githubLog:Ut});try{const _n=await qoe({project:e,githubUrl:ve.githubUrl,githubToken:ve.githubToken,baseBranch:ve.baseBranch,runtimeName:Jt.agentName||Zt,runtimeId:Jt.runtimeId,region:Jt.region||j,cloudProvider:ve.cloudProvider,projectPath:".",volcengineAccessKey:ve.volcengineAccessKey,volcengineSecretKey:ve.volcengineSecretKey,volcengineSessionToken:ve.volcengineSessionToken});xn=_n,Cr.current&&(it(_n),He(null),_t(ci=>({...ci,github:{level:"success",phase:"github",message:"GitHub 持续交付已初始化目标分支",pct:100}})),Kt(null)),x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId,region:Jt.region||j,startedAt:Tt,status:"running",phase:"github",label:"GitHub 持续交付已挂载",message:"GitHub 持续交付已初始化目标分支",pct:100,githubDelivery:!0,githubLog:on("GitHub 持续交付已初始化目标分支","complete")})}catch(_n){const ci=on(`GitHub 持续交付挂载失败:${_n instanceof Error?_n.message:String(_n)}`,"error");throw x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId,region:Jt.region||j,startedAt:Tt,status:"error",phase:"github",label:"挂载 GitHub 持续交付失败",message:"挂载 GitHub 持续交付失败,详见 GitHub 日志。",pct:100,githubDelivery:!0,githubLog:ci}),new Error(`部署成功,但挂载 GitHub 持续交付失败:${_n instanceof Error?_n.message:String(_n)}`)}}else if(!g&&(xn!=null&&xn.pipelineId)&&Jt.runtimeId)try{const Ut=await S9({pipelineId:xn.pipelineId,runtimeId:Jt.runtimeId,region:Jt.region||j,cloudProvider:xn.cloudProvider??N});xn=Ut,Cr.current&&it(Ut)}catch(Ut){Cr.current&&xt(`部署成功,但绑定 GitHub 失败:${Ut instanceof Error?Ut.message:String(Ut)}`)}Cr.current&&(xe(Jt),Kt(null)),Lt.succeed({runtimeId:String(Jt.runtimeId||g||"")}),x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId||g,region:Jt.region||j,startedAt:Tt,status:"success",phase:"complete",label:"部署完成",message:(Nr=Jt.warnings)==null?void 0:Nr.join(";"),githubDelivery:!!(ve||or),...or?{githubLog:or}:{},...nn("complete")});try{await(d==null?void 0:d(Jt))}catch(Ut){if(!(Ut instanceof _s))throw Ut;x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId||g,region:Jt.region||j,startedAt:Tt,status:"success",phase:"complete",label:"部署完成,暂未连接",message:Ut.message,...nn("complete")})}}catch(xn){const Jt=xn instanceof Error?xn.message:String(xn);if(xn instanceof DOMException&&xn.name==="AbortError"){Lt.fail({failedPhase:Iee(W),...mo(xn,{phase:W}),errorMessage:Iy(xn)}),Cr.current&&(xt(null),Kt(null)),x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"cancelled",label:"已取消",message:"部署已取消,相关 Runtime 资源已请求销毁。",...nn("complete")});return}const Ut=W==="build"&&Pjt(xn),Un=Ut?p_:Jt;Cr.current&&xt(Un),Cr.current&&xe(null);const _n=er();Lt.fail({failedPhase:Iee(W),...mo(xn,{phase:W}),errorMessage:Wr(xn)});const ci=!!_n,co=W==="github"&&!!or;x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"error",phase:W,label:Ut?"构建状态待确认":"部署失败",message:Ut?p_:ci?"构建镜像失败,详见构建日志。":co?"挂载 GitHub 持续交付失败,详见 GitHub 日志。":Jt,..._n?{buildLog:_n}:nn("complete"),...co?{githubDelivery:!0,githubLog:or}:{},...Ut?{}:{retry:In}})}finally{Cr.current&&We(!1)}}function Os(){kt(!1)}async function Jn(){if(!(!Ie||en)){le(!0),xt(null);try{const{addConnection:fe,addRuntimeConnection:Je,remoteAppId:St,loadConnections:dn}=await fd(async()=>{const{addConnection:Lt,addRuntimeConnection:Ne,remoteAppId:tn,loadConnections:or}=await Promise.resolve().then(()=>mJ);return{addConnection:Lt,addRuntimeConnection:Ne,remoteAppId:tn,loadConnections:or}},void 0),{probeRuntimeApps:Zt}=await fd(async()=>{const{probeRuntimeApps:Lt}=await Promise.resolve().then(()=>$5e);return{probeRuntimeApps:Lt}},void 0);let Tt;if(Ie.runtimeId){const Lt=Ie.region??j,Ne=await Zt(Ie.runtimeId,Lt,{retryProbe:!0})??[];Tt=Je(Ie.runtimeId,Ie.runtimeName,Lt,Ne,Ne.length>0?{[Ne[0]]:Ie.agentName}:void 0,Ie.version)}else Tt=await fe(Ie.agentName,Ie.url,Ie.apikey,"");if(Tt.apps.length===0)xt("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。");else{const Lt={[Tt.apps[0]]:Ie.agentName},Ne={...Tt,appLabels:{...Tt.appLabels??{},...Lt}},or=dn().map(Te=>Te.id===Tt.id?Ne:Te);localStorage.setItem("veadk_agentkit_connections",JSON.stringify(or));const{registerConnections:W}=await fd(async()=>{const{registerConnections:Te}=await Promise.resolve().then(()=>mJ);return{registerConnections:Te}},void 0);if(W(or),u){const Te=St(Tt.id,Tt.apps[0]);await u(Te,Ie.agentName)}else alert(`🎉 Agent "${Ie.agentName}" 已添加到左上角下拉列表!`)}}catch(fe){xt(`添加 Agent 失败:${fe instanceof Error?fe.message:String(fe)}`)}finally{le(!1)}}}function li(){const fe=Ta(),Je=cwe({agentId:fe.agentId,deployAction:fe.deployAction,deploySource:fe.deploySource,createMode:fe.createMode,aiAssisted:fe.aiAssisted});try{const St=pjt(e.files),dn=URL.createObjectURL(St),Zt=document.createElement("a");Zt.href=dn,Zt.download=`${e.name||"project"}.zip`,document.body.appendChild(Zt),Zt.click(),document.body.removeChild(Zt),URL.revokeObjectURL(dn),Je.succeed({fileCount:e.files.length,zipSizeBytes:St.size})}catch(St){throw Je.fail({fileCount:e.files.length,...mo(St)}),St}}const Ld=o.jsxs("div",{className:`pp-artifact-actions${t?" is-rail":""}`,"aria-label":"发布产物操作",children:[z&&o.jsxs("button",{type:"button",className:"pp-secondary",onClick:z,children:[o.jsx(HRe,{className:"pp-ic"}),"导出 YAML"]}),K&&l&&o.jsx(Hdt,{project:e,onChange:l,className:"pp-artifact-source",label:"查看源代码"}),e.files.length>0&&o.jsxs("button",{type:"button",className:"pp-secondary",onClick:li,children:[o.jsx(jN,{className:"pp-ic"}),"下载源代码"]})]});function ll(fe,Je,St){return eRt(fe,Je===0).map(dn=>{const Zt=St?`${St}/${dn.name}`:dn.name,Tt=dn.path!==void 0,Lt={paddingLeft:8+Je*14};if(Tt){const tn=dn.path===Ue;return o.jsxs("button",{type:"button",className:`pp-row pp-file${tn?" pp-active":""}`,style:Lt,onClick:()=>re(dn.path),title:dn.path,children:[o.jsx(GRe,{className:"pp-ic"}),o.jsx("span",{className:"pp-label",children:dn.name})]},Zt)}const Ne=ce.has(Zt);return o.jsxs("div",{children:[o.jsxs("button",{type:"button",className:"pp-row pp-folder",style:Lt,onClick:()=>Pd(Zt),children:[o.jsx(XS,{className:`pp-ic pp-chevron${Ne?"":" pp-open"}`}),o.jsx(YRe,{className:"pp-ic"}),o.jsx("span",{className:"pp-label",children:dn.name})]}),!Ne&&ll(dn,Je+1,Zt)]},Zt)})}return o.jsxs("div",{className:`pp-root${c?" is-deploy":""}${t?" is-embedded":""}${Q?" has-primary-pane":""}`,children:[c&&!t&&o.jsx(nRt,{left:o.jsxs("div",{className:"pp-toolbar-left",children:[L&&o.jsxs("button",{type:"button",className:"pp-toolbar-back",onClick:L,children:[o.jsx(Dae,{className:"pp-ic"}),H]}),o.jsxs("span",{className:"pp-toolbar-title",children:["部署 ",i||e.name||"未命名 Agent",s&&s>1?` 等 ${s} 个智能体`:""]})]}),right:null}),o.jsxs("div",{className:"pp-body",children:[c&&!Q&&o.jsx("section",{className:"pp-release-overview","aria-label":"发布概览",children:o.jsxs("div",{className:`pp-release-preview${t?" is-embedded":""}`,children:[o.jsxs("div",{className:"pp-flow-thumbnail",children:[r&&o.jsx(zw,{draft:r,direction:"horizontal",selectedPath:[],onSelect:Vh,onAdd:Vh,onInsert:Vh,onDelete:Vh,readOnly:!0,interactivePreview:!0}),o.jsx("button",{type:"button",className:"pp-flow-expand",onClick:()=>Dt(!0),"aria-label":"放大查看执行流程",title:"放大查看",children:o.jsx(cy,{"aria-hidden":!0})})]}),t&&Ld,!t&&o.jsxs("div",{className:"pp-release-info",children:[o.jsx("div",{className:"pp-release-card-head",children:"Agent 概览"}),o.jsxs("div",{className:"pp-release-info-body",children:[o.jsxs("div",{className:"pp-release-info-main",children:[o.jsx("h2",{children:i||e.name||"未命名 Agent"}),(r==null?void 0:r.description)&&o.jsx("p",{className:"pp-release-description",title:r.description,children:r.description}),o.jsxs("dl",{className:"pp-release-facts",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"Agent 数量"}),o.jsx("dd",{children:s??1})]}),a&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("dt",{children:"模型"}),o.jsx("dd",{children:a.modelName})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"描述"}),o.jsx("dd",{className:"pp-release-fact-long",children:a.description})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"系统提示词"}),o.jsx("dd",{className:"pp-release-fact-long pp-release-prompt",children:a.instruction})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"优化选项"}),o.jsx("dd",{children:a.optimizations.length>0?a.optimizations.join("、"):"未启用"})]}),a.effectiveOptimizations&&a.effectiveOptimizations.length>0&&o.jsxs("div",{children:[o.jsx("dt",{children:"生效能力"}),o.jsx("dd",{children:a.effectiveOptimizations.join("、")})]}),a.autoAddedOptimizations&&a.autoAddedOptimizations.length>0&&o.jsxs("div",{children:[o.jsx("dt",{children:"自动保护"}),o.jsx("dd",{children:a.autoAddedOptimizations.join("、")})]}),a.planHash&&o.jsxs("div",{children:[o.jsx("dt",{children:"Plan Hash"}),o.jsx("dd",{className:"pp-release-fact-long",children:a.planHash})]})]})]})]}),Ld]})]})]})}),o.jsxs("div",{className:"pp-files-area",children:[o.jsxs("div",{className:"pp-sidebar",children:[o.jsxs("div",{className:"pp-sidebar-head",children:[o.jsx("span",{className:"pp-project-name",title:e.name,children:"文件预览"}),K&&o.jsx("button",{type:"button",className:"pp-icon-btn",title:"新建文件",onClick:()=>{Z(!0),rt("")},children:o.jsx(qRe,{className:"pp-ic"})})]}),o.jsxs("div",{className:"pp-tree",children:[Ye&&o.jsx("input",{className:"pp-new-input",autoFocus:!0,placeholder:"path/to/file.py",value:_e,onChange:fe=>rt(fe.target.value),onBlur:oo,onKeyDown:fe=>{fe.key==="Enter"&&oo(),fe.key==="Escape"&&(Z(!1),rt(""))}}),e.files.length===0&&!Ye?o.jsx("div",{className:"pp-empty",children:"暂无文件"}):ll($r,0,"")]})]}),o.jsxs("div",{className:"pp-main",children:[o.jsxs("div",{className:"pp-main-head",children:[o.jsx("span",{className:"pp-path",title:Gr==null?void 0:Gr.path,children:(Gr==null?void 0:Gr.path)??"未选择文件"}),o.jsx("div",{className:"pp-actions",children:K&&Gr&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"pp-icon-btn",title:"重命名",onClick:Yl,children:o.jsx(iIe,{className:"pp-ic"})}),o.jsx("button",{type:"button",className:"pp-icon-btn pp-danger",title:"删除",onClick:Ru,children:o.jsx(Fp,{className:"pp-ic"})})]})})]}),o.jsx("div",{className:"pp-content",children:Gr==null?o.jsx("div",{className:"pp-placeholder",children:"选择左侧文件以查看内容"}):K?o.jsx("div",{className:"pp-codemirror",children:o.jsx(p.Suspense,{fallback:o.jsx("div",{className:"pp-editor-loading",children:"加载编辑器…"}),children:o.jsx(Ljt,{value:Gr.content,path:Gr.path,onChange:ol})})}):o.jsx("pre",{className:"pp-pre hljs",dangerouslySetInnerHTML:{__html:Hjt(Gr.content,Gr.path)}})})]})]}),c&&o.jsxs("aside",{className:"pp-config","aria-label":"部署配置",children:[o.jsx("div",{className:"pp-config-head",children:o.jsx("div",{className:"pp-config-title",children:"部署配置"})}),o.jsxs("div",{className:"pp-config-scroll",children:[Q,!Q&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("label",{className:"pp-config-label",htmlFor:qr,children:"Runtime 名称"}),o.jsxs("div",{className:"pp-runtime-name-field",children:[o.jsx("input",{id:qr,className:"pp-runtime-name-input",value:Oe,disabled:Re||Ge||se,maxLength:64,autoComplete:"off","aria-label":"Runtime 名称","aria-invalid":!!Se,"aria-describedby":`${mr}${Se?` ${Xr}`:""}`,onChange:fe=>{const Je=fe.currentTarget.value;ze(null),xt(null),O?O(Je):ue(Je)}}),o.jsx("p",{id:mr,className:"pp-config-note",children:se?"更新时保持现有 Runtime 名称不变。":"默认根据 Root Agent 名称生成,并添加随机后缀避免重名;支持 4-64 位字母、数字、连字符和下划线"}),Se&&o.jsx("p",{id:Xr,className:"pp-runtime-name-error",role:"alert",children:Se})]})]}),!Q&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"发布区域"}),An(!1)]}),!Q&&o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"pp-config-section pp-auth-section",children:[o.jsx("div",{className:"pp-config-label",children:"访问鉴权"}),se?o.jsx("p",{className:"pp-config-note pp-auth-preserved-note",children:"更新时保持现有 Runtime 的鉴权方式不变。"}):o.jsxs("div",{className:"pp-auth-fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"鉴权方式"}),o.jsx(GE,{ariaLabel:"部署鉴权方式",value:Tr,placeholder:"请选择鉴权方式",options:Fjt,disabled:Re,onChange:fe=>{xt(null),oi(fe)}})]}),Tr==="user_pool"&&o.jsxs("label",{children:[o.jsx("span",{children:"用户池"}),o.jsx(Ujt,{value:Ii,disabled:Re,onChange:fe=>{xt(null),bi(fe)}})]})]})]}),o.jsx(Djt,{project:e,region:j,cloudProvider:N,runtimeId:g,binding:$e,showSetup:!se,onPendingCicdChange:He,onBindingChange:ae,disabled:Re||Xe||V||!!n})]}),!Q&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"消息渠道"}),o.jsx(kjt,{enabled:w,updating:Xe,disabled:Re||Ge||!S||!M,agentName:i||e.name,appId:A.FEISHU_APP_ID??"",appSecret:A.FEISHU_APP_SECRET??"",appIdConfigured:ge.has("FEISHU_APP_ID"),appSecretConfigured:ge.has("FEISHU_APP_SECRET"),onToggle:_h,onCredentialsChange:(fe,Je)=>{M==null||M(fe,Je)}})]}),!se&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"实例设置"}),o.jsxs("div",{className:"pp-instance-fields",children:[o.jsxs("label",{htmlFor:"runtime-min-instance",children:[o.jsx("span",{children:"最小实例数"}),o.jsx("input",{id:"runtime-min-instance",type:"number",min:"1",step:"1",inputMode:"numeric",value:rs,disabled:Re||tt,"aria-invalid":!pn.valid,onChange:fe=>oa(fe.currentTarget.value)})]}),o.jsxs("label",{htmlFor:"runtime-max-instance",children:[o.jsx("span",{children:"最大实例数"}),o.jsx("input",{id:"runtime-max-instance",type:"number",min:"1",step:"1",inputMode:"numeric",value:Qr,disabled:Re||tt,"aria-invalid":!pn.valid,onChange:fe=>Ws(fe.currentTarget.value)})]})]}),(ie||tt)&&o.jsx("p",{className:"pp-instance-note",role:"note",children:tt?"Harness Sidecar 首期仅支持单实例,Runtime 固定为 1~1":"为避免多实例间会话丢失,推荐将 Runtime 固定为 1~1"}),!pn.valid&&o.jsx("p",{className:"pp-instance-error",role:"alert",children:pn.error})]}),o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"网络"}),Q&&An(!0),se&&o.jsx("p",{className:"pp-config-note",children:"现有 Runtime 的区域与网络模式保持不变。"}),o.jsxs("div",{className:"pp-network-layout",children:[o.jsx("div",{className:"pp-network-modes",role:"radiogroup","aria-label":"网络模式",children:["public","private","both"].map(fe=>o.jsxs("label",{className:"pp-network-option",children:[o.jsx("input",{type:"radio",name:"deployment-network-mode",value:fe,checked:Zs===fe,onChange:()=>Md(fe),disabled:Re||se||!$}),o.jsx("span",{children:fe==="public"?"公网":fe==="private"?"VPC":"公网 + VPC"})]},fe))}),Zs!=="public"&&o.jsxs("div",{className:"pp-network-fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"VPC ID"}),o.jsx("input",{value:(I==null?void 0:I.vpcId)??"",placeholder:"vpc-xxxxxxxx",disabled:Re||se,onChange:fe=>kn({vpcId:fe.target.value})})]}),o.jsxs("label",{children:[o.jsxs("span",{children:["子网 ID ",o.jsx("small",{children:"可选,多个用逗号分隔"})]}),o.jsx("input",{value:(I==null?void 0:I.subnetIds)??"",placeholder:"subnet-xxx, subnet-yyy",disabled:Re||se,onChange:fe=>kn({subnetIds:fe.target.value})})]}),o.jsxs("label",{className:"pp-network-check",children:[o.jsx("input",{type:"checkbox",checked:!!(I!=null&&I.enableSharedInternetAccess),disabled:Re||se,onChange:fe=>kn({enableSharedInternetAccess:fe.target.checked})}),"VPC 内共享公网出口"]})]})]})]}),Ys&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"评测集"}),o.jsxs("label",{className:"pp-evaluation-set-option",children:[o.jsx("input",{type:"checkbox",checked:is,disabled:Re,onChange:fe=>ka(fe.currentTarget.checked)}),o.jsxs("span",{children:[o.jsx("strong",{children:"自动创建评测集"}),o.jsx("small",{children:"部署成功后,自动创建 Good Case 和 Bad Case 评测集。"})]})]})]}),!se&&o.jsxs("section",{className:"pp-config-section pp-resource-section",children:[o.jsx("div",{className:"pp-config-label",children:"资源配置"}),o.jsx(Qve,{value:ar,agentName:i||e.name||"agentkit-app",runtimeName:Oe,region:j,disabled:Re,validationError:Gn,onChange:fe=>{pr(fe),zn(null)}})]}),o.jsxs("section",{className:"pp-config-section pp-env-section",children:[o.jsx("div",{className:"pp-env-head",children:o.jsxs("div",{children:[o.jsxs("div",{className:"pp-config-label",children:["环境变量",o.jsxs("span",{className:"pp-agent-child-count pp-env-count",children:[Dd," 项"]})]}),o.jsx("div",{className:"pp-env-sub",children:"组件配置会自动同步到这里,部署前可核对最终值。"})]})}),o.jsxs("button",{type:"button",className:"pp-env-add",onClick:Ro,disabled:Re,children:[o.jsx(vo,{className:"pp-ic"}),"添加变量"]}),(Va.length>0||_.length>0||Xt.length>0)&&o.jsxs("div",{className:"pp-env-table",children:[Va.length>0&&o.jsxs("div",{className:"pp-env-group",children:[o.jsxs("div",{className:"pp-env-group-head",children:[o.jsx("span",{children:"组件自动生成"}),o.jsxs("small",{children:[Va.length," 项"]})]}),Va.map(fe=>{const Je=fe.readOnly||fe.key.startsWith("ENABLE_"),St=fe.serverManaged&&fe.key==="MODEL_AGENT_API_KEY",dn=St?so?Ks.value:"由所选 API Key 注入":fe.value,Zt=AU(fe,A),Tt=et[fe.key],Lt=`deployment-env-${fe.key.toLowerCase()}-error`,Ne=Cee(fe)||fe.help||fe.comment,tn=fe.multiline||fe.format==="json";return o.jsxs("div",{className:`pp-env-row pp-env-row-derived${tn?" is-multiline":""}`,children:[o.jsxs("div",{className:"pp-env-key-fixed pp-env-key-cell","aria-label":`${fe.key} 环境变量名`,"aria-disabled":Re,children:[o.jsx("span",{title:fe.key,children:fe.key}),Ne&&o.jsxs("span",{className:"pp-env-help",tabIndex:0,"data-help":Ne,"aria-label":`${fe.key}说明:${Ne}`,children:["?",o.jsx("span",{className:"pp-env-help-popover",role:"tooltip",children:Ne})]}),fe.link&&o.jsx("a",{className:"pp-env-link",href:fe.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开 OpenViking ${fe.link.label}`,"aria-label":`${fe.key}:打开 OpenViking ${fe.link.label}`,children:o.jsx(Dg,{"aria-hidden":"true"})})]}),o.jsxs("div",{className:"pp-env-value-wrap",children:[tn?o.jsx("textarea",{ref:or=>{or?Mt.current.set(fe.key,or):Mt.current.delete(fe.key)},className:"pp-env-value pp-env-json-value",value:fe.value,placeholder:fe.placeholder||(fe.required?"必填,尚未填写":"可选,尚未填写"),readOnly:Je,disabled:Re||!Je&&!R,autoComplete:"off",spellCheck:!1,"aria-invalid":!!(Tt||Zt),"aria-describedby":Tt?Lt:void 0,"aria-label":`${fe.key} 环境变量值`,onChange:or=>{const W=or.currentTarget.value;R==null||R(fe.key,W),Tt&&W.trim()&&(zc(fe.key),xt(null))}}):o.jsxs("div",{className:St?"pp-env-secret-control":void 0,children:[o.jsx("input",{ref:or=>{or?Mt.current.set(fe.key,or):Mt.current.delete(fe.key)},className:"pp-env-value",type:St?"text":fe.secret?"password":"text",value:dn,placeholder:fe.placeholder||(fe.required?"必填,尚未填写":"可选,尚未填写"),readOnly:Je,disabled:Re||!Je&&!R,autoComplete:fe.secret?"new-password":"off",spellCheck:fe.secret?!1:void 0,"aria-invalid":!!(Tt||Zt),"aria-describedby":Tt?Lt:void 0,"aria-label":`${fe.key} 环境变量值`,onChange:or=>{const W=or.currentTarget.value;R==null||R(fe.key,W),Tt&&W.trim()&&(zc(fe.key),xt(null))}}),St&&o.jsx("button",{type:"button",className:"pp-env-secret-toggle","aria-label":jo,title:jo,"aria-pressed":so,disabled:Ks.status==="loading"||!Ee,onClick:()=>{so?At():sn()},children:Ks.status==="loading"?o.jsx(rr,{className:"pp-env-secret-spinner","aria-hidden":"true"}):so?o.jsx(Bjt,{}):o.jsx($jt,{})})]}),Tt&&o.jsx("span",{id:Lt,className:"pp-env-error",role:"alert",children:Tt}),Zt&&o.jsx("span",{className:"pp-env-error",children:Zt}),St&&Ks.status==="error"&&o.jsx("span",{className:"pp-env-reveal-error",role:"alert",children:Ks.error})]}),o.jsx("span",{className:"pp-env-source",children:Je?"自动":"同步"})]},fe.key)})]}),_.length>0&&o.jsxs("div",{className:"pp-env-group",children:[o.jsxs("div",{className:"pp-env-group-head",children:[o.jsx("span",{children:"自定义模型凭据"}),o.jsxs("small",{children:[_.length," 项"]})]}),_.map(fe=>{const Je=_r===fe.key,St=`${fe.key.toLowerCase()}-error`;return o.jsxs("div",{className:"pp-env-row pp-env-row-derived",children:[o.jsx("label",{className:"pp-env-key-fixed pp-env-key-cell",htmlFor:fe.key,title:fe.label,children:o.jsx("span",{children:fe.key})}),o.jsxs("div",{className:"pp-env-value-wrap",children:[o.jsx("input",{id:fe.key,className:"pp-env-value",type:"password",value:Kn[fe.key]??"",placeholder:"必填,仅用于本次发布",disabled:Re,autoComplete:"new-password",spellCheck:!1,"aria-invalid":Je,"aria-describedby":Je?St:void 0,"aria-label":fe.label,onChange:dn=>{const Zt=dn.currentTarget.value;C?C(fe.key,Zt):ln(Tt=>({...Tt,[fe.key]:Zt})),Je&&Zt.trim()&&(Ve(null),xt(null))}}),Je&&o.jsx("span",{id:St,className:"pp-env-error",role:"alert",children:"请填写此模型地址对应的 API Key。"})]}),o.jsx("span",{className:"pp-env-source",children:"本次发布"})]},fe.key)})]}),Xt.length>0&&o.jsxs("div",{className:"pp-env-group-head pp-env-group-head-custom",children:[o.jsx("span",{children:"自定义变量"}),o.jsxs("small",{children:[Xt.length," 项"]})]}),Xt.map(fe=>o.jsxs("div",{className:"pp-env-row",children:[o.jsx("input",{value:fe.key,placeholder:"名称",disabled:Re,autoComplete:"off",onChange:Je=>Fc(fe.id,{key:Je.currentTarget.value})}),o.jsx("input",{type:"text",value:fe.value,placeholder:"值",disabled:Re,autoComplete:"off",onChange:Je=>Fc(fe.id,{value:Je.currentTarget.value})}),o.jsx("button",{type:"button",className:"pp-icon-btn pp-env-remove",title:"删除变量",disabled:Re,onClick:()=>Iu(fe.id),children:o.jsx(Ea,{className:"pp-ic"})})]},fe.id))]})]}),(Re||Ie||Object.keys(pt).length>0)&&o.jsxs("section",{className:"pp-config-section pp-progress-section",children:[o.jsx("div",{className:"pp-config-label",children:"部署进度"}),o.jsx("ol",{className:"pp-steps",children:Le.map((fe,Je)=>{const St=It?Le.findIndex(Lt=>Lt.phase===It):-1,dn=!!ft&&(St===-1?Je===0:Je===St),Zt=pt[fe.phase];let Tt;return Ie||(Zt==null?void 0:Zt.level)==="success"?Tt="done":dn?Tt="failed":St===-1?Tt=Re?"active":"pending":Jefe.phase===It))==null?void 0:ca.label)??It}阶段):`:""}${ft}`,onRetry:ft===p_?void 0:In,retryLabel:se?"重试更新":"重试部署"}),Ie&&o.jsxs("section",{className:"pp-deploy-result",children:[o.jsx("div",{className:"pp-deploy-result-header",children:se?"更新成功":"部署成功"}),o.jsxs("div",{className:"pp-deploy-result-body",children:[Ie.warnings&&Ie.warnings.length>0&&o.jsx("div",{className:"pp-deploy-result-warning",role:"status",children:Ie.warnings.map(fe=>o.jsx("span",{children:fe},fe))}),Ie.region&&o.jsxs("div",{className:"pp-deploy-result-field",children:[o.jsx("label",{children:"区域"}),o.jsx("code",{children:Jf(Ie.region,N)})]}),o.jsxs("div",{className:"pp-deploy-result-field",children:[o.jsx("label",{children:"Agent 名称"}),o.jsx("code",{children:Ie.agentName})]}),o.jsxs("div",{className:"pp-deploy-result-field",children:[o.jsx("label",{children:"Runtime 名称"}),o.jsx("code",{children:Ie.runtimeName})]}),o.jsxs("div",{className:"pp-deploy-result-field",children:[o.jsx("label",{children:"API 端点"}),o.jsx("code",{className:"pp-deploy-result-url",children:Ie.url})]})]}),o.jsxs("div",{className:"pp-deploy-result-actions",children:[o.jsxs("button",{type:"button",className:"pp-deploy-result-btn",onClick:Jn,disabled:en,children:[en?o.jsx(rr,{className:"pp-ic spin"}):o.jsx(Qae,{className:"pp-ic"}),en?"连接中…":"立即对话"]}),Ie.consoleUrl&&o.jsxs("a",{href:Ie.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"pp-console-link pp-console-link-btn",children:[o.jsx(Dg,{className:"pp-ic"}),"控制台"]})]})]})]}),o.jsx("div",{className:`pp-config-actions${Ds?" is-external":""}`,children:Ds?kr.createPortal(o.jsx("button",{type:"button",className:"pp-deploy studio-update-action",onClick:In,disabled:Re||Ge||Xe||V||!!n||!!Se,title:n||Se||void 0,children:Re?`${f}中…`:Ge?"正在检查名称…":ft?`重试${f}`:f}),Ds):o.jsx("button",{type:"button",className:"pp-deploy studio-update-action",onClick:In,disabled:Re||Ge||Xe||V||!!n||!!Se,title:n||Se||void 0,children:Re?`${f}中…`:Ge?"正在检查名称…":ft?`重试${f}`:f})})]})]}),qt&&r&&kr.createPortal(o.jsx("div",{className:"pp-flow-backdrop",onMouseDown:fe=>{fe.target===fe.currentTarget&&Dt(!1)},children:o.jsxs("section",{className:"pp-flow-dialog",role:"dialog","aria-modal":"true","aria-label":"执行流程预览",children:[o.jsxs("header",{children:[o.jsxs("div",{children:[o.jsx("strong",{children:"执行流程"}),o.jsx("span",{children:"只读预览,可缩放与拖动画布"})]}),o.jsx("button",{type:"button",onClick:()=>Dt(!1),"aria-label":"关闭执行流程预览",children:o.jsx(Ea,{"aria-hidden":!0})})]}),o.jsx("div",{className:"pp-flow-dialog-canvas",children:o.jsx(zw,{draft:r,direction:"horizontal",selectedPath:[],onSelect:Vh,onAdd:Vh,onInsert:Vh,onDelete:Vh,readOnly:!0,interactivePreview:!0})})]})}),document.body),o.jsx(Qjt,{open:ct,isUpdate:se,...h,onCancel:Os,onConfirm:()=>void Vn()})]})}const rRt=new Set(["MODEL_AGENT_API_KEY"]),iRt=new Set(["MODEL_AGENT_NAME","MODEL_NAME"]),sRt=new Set(["VOLCENGINE_ACCESS_KEY","VOLCENGINE_SECRET_KEY","VOLCENGINE_SESSION_TOKEN","BYTEPLUS_ACCESS_KEY","BYTEPLUS_SECRET_KEY","BYTEPLUS_SESSION_TOKEN","VEADK_DISABLE_EXPIRE_AT"]);function Tg(e){return!sRt.has(e)}function NS(e){return rRt.has(e)||/(?:API_KEY|ACCESS_KEY|SECRET_KEY|PRIVATE_KEY|TOKEN|SECRET|PASSWORD|PASSWD|PWD|CREDENTIAL)$/.test(e)}function aRt(e,t){const n={},r=new Set([...e.environment.required,...e.environment.optional]);for(const i of r){if(!Tg(i)||NS(i))continue;const s=i==="MODEL_AGENT_API_BASE"?nl(t):iRt.has(i)?eh(t):e.environment.defaults[i];s!=null&&s.trim()&&(n[i]=s)}return n}function oRt({delivery:e,onBack:t,onAgentAdded:n,onDeploymentTaskChange:r,onDeploymentStarted:i,onDeploymentComplete:s,cloudProvider:a="volcengine",initialDeployRegion:l}){const[c,u]=p.useState(l??Zr(a)),[d,f]=p.useState(),[h,m]=p.useState(null),[g,b]=p.useState(!1),[y,O]=p.useState(()=>({name:Kve(e.agentName),files:e.files??[]})),v=e.environment??{required:[],optional:[],defaults:{}},[x,w]=p.useState(()=>({...v.defaults})),S=v.required.filter(Tg).filter(NS).map(C=>({key:C,label:C})),E=[...v.required.filter(Tg).filter(C=>!NS(C)).map(C=>({key:C,required:!0,comment:C,placeholder:`请输入 ${C}`})),...v.optional.filter(Tg).map(C=>({key:C,required:!1,comment:C,placeholder:`可选:${C}`}))],k=WE(y.name);p.useEffect(()=>{if(k){m(null);return}const C=new AbortController,A=window.setTimeout(()=>{b(!0),$N(y.name,c).then(R=>{C.signal.aborted||m(R.available===!0)}).catch(()=>{C.signal.aborted||m(null)}).finally(()=>{C.signal.aborted||b(!1)})},250);return()=>{window.clearTimeout(A),C.abort()}},[c,y.name,k]);const _={kind:"intelligentDevelopment",sessionId:e.sessionId,...e.projectId&&e.versionId?{projectId:e.projectId,versionId:e.versionId}:{},artifactSha256:e.artifactSha256,validationReportSha256:e.validationReportSha256,...e.verified?{}:{acknowledgeUnverified:!0}};async function T(C,A,R){const M=d&&d.mode!=="public"?{mode:d.mode,vpc_id:d.vpcId,subnet_ids:d.subnetIds,enable_shared_internet_access:d.enableSharedInternetAccess}:void 0;return z1(C.name,[],{region:c,projectName:"default",network:M},{...R,onStage:A,runtimeName:C.name,source:_})}return o.jsx(_R,{cloudProvider:a,project:y,agentName:y.name,onDeploy:T,onAgentAdded:n,onDeploymentTaskChange:r,onDeploymentStarted:i,onDeploymentComplete:s,network:d,onNetworkChange:f,deployRegion:c,onDeployRegionChange:u,deploymentEnv:E,requiredSecretEnv:S,deploymentEnvValues:x,onDeploymentEnvChange:(C,A)=>w(R=>({...R,[C]:A})),deploymentActionLabel:"部署",deployDisabled:!!k||h===!1||g,deployDisabledReason:k??(h===!1?"Runtime 名称已存在,请更换后重试":g?"正在检查 Runtime 名称":void 0),deploymentTelemetry:{source:"intelligent_development",createMode:"intelligent",aiAssisted:!0},onBack:t,backLabel:"返回开发会话",deploymentPrimaryPane:o.jsxs("section",{className:"trusted-source-pane","aria-label":e.verified?"已验证源码":"可部署源码",children:[o.jsx("div",{className:"trusted-source-pane__badge",children:e.verified?"已通过 Codex 云端验证":"可部署源码"}),o.jsx("h2",{children:e.agentName}),o.jsxs("label",{className:"trusted-source-pane__runtime-name",children:[o.jsx("span",{children:"Runtime 名称"}),o.jsx("input",{value:y.name,maxLength:64,onChange:C=>O(A=>({...A,name:C.target.value}))})]}),o.jsxs("dl",{children:[o.jsxs("div",{children:[o.jsx("dt",{children:"入口"}),o.jsx("dd",{children:o.jsx("code",{children:e.entryPoint})})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"文件"}),o.jsx("dd",{children:e.fileCount})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"Artifact"}),o.jsx("dd",{children:o.jsx("code",{children:e.artifactSha256.slice(0,16)})})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"验证报告"}),o.jsx("dd",{children:o.jsx("code",{children:e.validationReportSha256.slice(0,16)})})]})]}),o.jsx("p",{children:e.verified?"源码由服务端从已验证交付物物化,浏览器文件不能替换。":"源码已由服务端安全物化,部署前请确认 Runtime 配置。"})]})})}const lRt="_Container_1tuad_1",cRt="_Checkbox_1tuad_22",uRt="_CheckMark_1tuad_92",dRt="_Label_1tuad_162",m_={Container:lRt,Checkbox:cRt,CheckMark:uRt,Label:dRt},jU=({className:e,label:t,id:n,disabled:r,orientation:i="left",...s})=>{const a=p.useId(),l=n??a;return o.jsxs("div",{"data-disabled":r?"":void 0,"data-has-label":t?"":void 0,"data-orientation":i,className:sr(e,m_.Container),children:[o.jsx(o3e,{className:m_.Checkbox,id:l,disabled:r,...s,children:o.jsx(c3e,{className:m_.CheckMark})}),t&&o.jsx("label",{htmlFor:l,className:m_.Label,onMouseDown:c=>{!c.defaultPrevented&&c.detail>1&&c.preventDefault()},children:t})]})};function fRt({className:e,...t}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[o.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),o.jsx("path",{d:"M12 6.5c.4 2.4 1 3 3.4 3.4-2.4.4-3 1-3.4 3.4-.4-2.4-1-3-3.4-3.4 2.4-.4 3-1 3.4-3.4Z"})]})}const Sb={llm:{id:"llm",label:"LLM 智能体",desc:"大模型驱动,自主完成任务",icon:fRt},sequential:{id:"sequential",label:"顺序型智能体",desc:"子 Agent 按顺序依次执行",icon:ZRe},parallel:{id:"parallel",label:"并行型智能体",desc:"子 Agent 并行执行后汇总",icon:cIe},loop:{id:"loop",label:"循环型智能体",desc:"子 Agent 循环执行到满足条件",icon:Fae},a2a:{id:"a2a",label:"远程智能体",desc:"通过 A2A 协议调用远程 Agent",icon:RN}},hRt=[Sb.llm,Sb.sequential,Sb.parallel,Sb.loop,Sb.a2a];function Rwe(e){return Sb[e??"llm"]}const Iwe=e=>e==="sequential"||e==="parallel"||e==="loop",TR=e=>e==="a2a";function Cg(e,t){const n=e.trim().toLocaleLowerCase();return n?t.some(r=>r==null?void 0:r.toLocaleLowerCase().includes(n)):!0}const Dwe=new Set(["local","sqlite","mysql","postgresql"]),Pwe=new Set(["local","opensearch","redis","viking","openviking","mem0"]),Mwe=new Set(["opensearch","viking","context_search","openviking"]),Lwe=new Set(["apmplus","cozeloop","tls"]),$we=new Set(["web_search","parallel_web_search","link_reader","web_scraper","image_generate","image_edit","video_generate","text_to_speech","run_code","vesearch"]),pRt=new Set(["llm","sequential","parallel","loop","a2a"]),mRt=new Set(["lark-cli","github-cli","pandoc"]),gRt=new Set(["default","ops"]);function bn(e,t=""){return typeof e=="string"?e:t}function Fo(e){return e===!0}function bRt(e){return typeof e=="string"&&gRt.has(e)?e:"default"}function Dy(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function yRt(e){return Array.from(new Set(Dy(e).filter(t=>mRt.has(t))))}function ORt(e){return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}function Bwe(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"?{name:bn(t.name),description:bn(t.description)}:null).filter(t=>!!t&&!!t.name.trim()):[]}function Py(e,t,n){return typeof e=="string"&&t.has(e)?e:n}function Qwe(e){return typeof e=="string"&&pRt.has(e)?e:"llm"}function Uwe(e){return e==="byteplus"?"byteplus":"volcengine"}function Fwe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):3}function zwe(e){const t=e&&typeof e=="object"?e:{};return{enabled:Fo(t.enabled),registrySpaceId:bn(t.registrySpaceId),registryTopK:bn(t.registryTopK),registryRegion:bn(t.registryRegion),registryEndpoint:bn(t.registryEndpoint)}}function xRt(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=t.componentOverrides&&typeof t.componentOverrides=="object"?t.componentOverrides:{},r=Object.fromEntries(tO.map(l=>[l,n[l]===!0])),i={enabled:Object.values(r).some(Boolean),profile:bRt(t.profile),componentOverrides:r},s=bn(t.catalogVersion).trim(),a=bn(t.planHash).trim();return s&&(i.catalogVersion=s),a&&(i.planHash=a),z7(i)}function Vwe(e,t="volcengine"){return Array.isArray(e)?e.map(n=>{const r=n&&typeof n=="object"?n:{},i=Uwe(r.cloudProvider??t),s=r.memory&&typeof r.memory=="object"?r.memory:{},a=zwe(r.a2aRegistry),l=Qwe(r.agentType),c=a.enabled&&l==="llm"?"a2a":l;return{...Bl(i),cloudProvider:i,name:bn(r.name),description:bn(r.description),instruction:bn(r.instruction),agentType:c,maxIterations:Fwe(r.maxIterations),a2aUrl:bn(r.a2aUrl),modelName:bn(r.modelName),modelSource:r.modelSource==="custom"||r.modelSource==="ark"?r.modelSource:void 0,modelProvider:bn(r.modelProvider),modelApiBase:bn(r.modelApiBase),builtinTools:Dy(r.builtinTools).filter(u=>$we.has(u)),customTools:Bwe(r.customTools),memory:{shortTerm:Fo(s.shortTerm),longTerm:Fo(s.longTerm)},shortTermBackend:Py(r.shortTermBackend,Dwe,"local"),longTermBackend:Py(r.longTermBackend,Pwe,"local"),longTermMemoryIndex:bn(r.longTermMemoryIndex),autoSaveSession:Fo(r.autoSaveSession),knowledgebase:Fo(r.knowledgebase),knowledgebaseBackend:Py(r.knowledgebaseBackend,Mwe,jp),knowledgebaseIndex:bn(r.knowledgebaseIndex),tracing:Fo(r.tracing),tracingExporters:Dy(r.tracingExporters).filter(u=>Lwe.has(u)),a2aRegistry:c==="a2a"?{...a,enabled:!0}:a,subAgents:Vwe(r.subAgents,i),selectedSkills:Hwe(r)}}):[]}function Hwe(e){if(!Array.isArray(e.selectedSkills))return[];const t=[];for(const n of e.selectedSkills){const r=n&&typeof n=="object"?n:{},i=bn(r.source),s=i==="local"||i==="skillspace"||i==="skillhub"||i==="runtime"?i:"skillhub",a=bn(r.name)||bn(r.slug)||bn(r.skillName)||bn(r.skillId)||"skill",l=bn(r.folder)||a,c=bn(r.description);if(s==="runtime"){if(l!==a)continue;t.push({source:s,folder:l,name:a,description:c});continue}if(s==="skillhub"){const f=bn(r.slug);if(!f)continue;t.push({source:s,folder:l,name:a,description:c,slug:f,namespace:bn(r.namespace)||"public"});continue}if(s==="local"){const h=(Array.isArray(r.localFiles)?r.localFiles:[]).map(m=>{const g=m&&typeof m=="object"?m:{},b=bn(g.path),y=bn(g.content);return b?{path:b,content:y}:null}).filter(m=>m!==null);if(h.length===0)continue;t.push({source:s,folder:l,name:a,description:c,localFiles:h});continue}const u=bn(r.skillSpaceId),d=bn(r.skillId);!u||!d||t.push({source:s,folder:l,name:a,description:c,skillSpaceId:u,skillSpaceName:bn(r.skillSpaceName),skillId:d,version:bn(r.version)})}return t}function vRt(e){const t=e&&typeof e=="object"?e:{},n=t.memory&&typeof t.memory=="object"?t.memory:{},r=t.deployment&&typeof t.deployment=="object"?t.deployment:{},i=ORt(r.envValues),s=t.cloudEnvironment&&typeof t.cloudEnvironment=="object"?t.cloudEnvironment:{},a=zwe(t.a2aRegistry),l=Qwe(t.agentType),c=a.enabled&&l==="llm"?"a2a":l,u=Uwe(t.cloudProvider),d=Array.isArray(t.mcpTools)?t.mcpTools.map(f=>{const h=f&&typeof f=="object"?f:{},m=h.transport==="stdio"?"stdio":"http";return{name:bn(h.name),transport:m,url:bn(h.url),authToken:bn(h.authToken),authTokenEnv:bn(h.authTokenEnv),credentialConfigured:h.credentialConfigured===!0,command:bn(h.command),args:Dy(h.args)}}).filter(f=>f.transport==="http"?!!f.url:!!f.command):[];return{...Bl(u),cloudProvider:u,name:bn(t.name)||"my_agent",description:bn(t.description),instruction:bn(t.instruction)||"You are a helpful assistant.",dynamicAgentDelegation:Fo(t.dynamicAgentDelegation),agentType:c,maxIterations:Fwe(t.maxIterations),a2aUrl:bn(t.a2aUrl),modelName:bn(t.modelName),modelSource:t.modelSource==="custom"||t.modelSource==="ark"?t.modelSource:void 0,modelProvider:bn(t.modelProvider),modelApiBase:bn(t.modelApiBase),builtinTools:Dy(t.builtinTools).filter(f=>$we.has(f)),customTools:Bwe(t.customTools),mcpTools:d,a2aRegistry:c==="a2a"?{...a,enabled:!0}:a,memory:{shortTerm:Fo(n.shortTerm),longTerm:Fo(n.longTerm)},shortTermBackend:Py(t.shortTermBackend,Dwe,"local"),longTermBackend:Py(t.longTermBackend,Pwe,"local"),longTermMemoryIndex:bn(t.longTermMemoryIndex),autoSaveSession:Fo(t.autoSaveSession),knowledgebase:Fo(t.knowledgebase),knowledgebaseBackend:Py(t.knowledgebaseBackend,Mwe,jp),knowledgebaseIndex:bn(t.knowledgebaseIndex),tracing:Fo(t.tracing),tracingExporters:Dy(t.tracingExporters).filter(f=>Lwe.has(f)),deployment:{feishuEnabled:Fo(r.feishuEnabled),runtimeName:bn(r.runtimeName),runtimeNameCustomized:Fo(r.runtimeNameCustomized)||!!bn(r.runtimeName).trim(),modelApiKeyId:bn(r.modelApiKeyId),modelApiKeyName:bn(r.modelApiKeyName),...Object.keys(i).length>0?{envValues:i}:{}},cloudEnvironment:{environmentId:bn(s.environmentId),environmentVersionId:bn(s.environmentVersionId),cliTools:yRt(s.cliTools),...typeof s.dockerfile=="string"?{dockerfile:s.dockerfile}:{}},harnessSidecar:xRt(t.harnessSidecar),subAgents:Vwe(t.subAgents,u),selectedSkills:Hwe(t)}}function qwe(e,t=e.cloudProvider??"volcengine"){const n=e.cloudProvider??t,r=new Set(phe(n).map(i=>i.id));return{...e,builtinTools:(e.builtinTools??[]).filter(i=>r.has(i)),tracing:!1,tracingExporters:[],memory:{shortTerm:!1,longTerm:!1},shortTermBackend:"local",longTermBackend:"local",longTermMemoryIndex:"",autoSaveSession:!1,knowledgebase:!1,knowledgebaseBackend:jp,knowledgebaseIndex:"",subAgents:e.subAgents.map(i=>qwe(i,n))}}const wRt=/^[A-Za-z_][A-Za-z0-9_]*$/,CR=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;function Lee(e,t){return e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function SRt(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}_${n}`);)n+=1;return`${e}_${n}`}function _O(e){var n,r,i;const t=(n=e.authTokenEnv)==null?void 0:n.trim();return t&&wRt.test(t)?t:((i=(r=e.authToken)==null?void 0:r.trim().match(CR))==null?void 0:i[1])??""}function WA(e,t){var n;for(const r of e.mcpTools??[])t(r);for(const r of e.subAgents)WA(r,t);for(const r of((n=e.workflow)==null?void 0:n.nodes)??[])WA(r.agent,t)}function ERt(e){const t=new Set;return WA(e,n=>{const r=_O(n);n.credentialConfigured&&r&&t.add(r)}),[...t]}function Xwe(e){const t=new Set;return WA(e,n=>{const r=_O(n);r&&t.add(r)}),[...t]}function kRt(e,t){const n=new Set(Xwe(t));return[...new Set(e)].filter(r=>!n.has(r))}function _Rt(e){if(e.credentialUpdate==="pending")return"";if(e.authToken)return e.authToken;if(e.credentialConfigured)return"";const t=_O(e);return t?`\${${t}}`:""}function TRt(e,t){if(!t){if(e.authToken){const i={...e,credentialConfigured:!1};return delete i.authToken,delete i.authTokenEnv,i}if(e.credentialConfigured){const i={...e};return delete i.authToken,i}const r={...e};return delete r.authToken,delete r.authTokenEnv,r}const n=t.trim().match(CR);if(n){const r={...e,authTokenEnv:n[1],credentialConfigured:e.credentialConfigured&&_O(e)===n[1],...e.credentialSourceUrl?{credentialUpdate:"replace"}:{}};return delete r.authToken,r}return{...e,authToken:t,credentialConfigured:!1,...e.credentialSourceUrl?{credentialUpdate:"replace"}:{}}}function CRt(e){const t={...e,credentialConfigured:!1};return delete t.authToken,delete t.authTokenEnv,t}function ARt(e){if(!e.trim())return!1;try{return!new URL(e).pathname.replace(/\/+$/,"").endsWith("/mcp")}catch{return!1}}function $ee(e){return(e??"").trim().replace(/\/+$/,"")}function Gwe(e){return e.credentialUpdate==="pending"}function NRt(e,t){var s;const n=e.credentialSourceUrl??(e.credentialConfigured?((s=e.url)==null?void 0:s.trim())??"":""),r=e.credentialSourceAuthTokenEnv??(e.credentialConfigured?_O(e):"");if(!n||!r)return{...e,url:t};if($ee(t)===$ee(n)){const a={...e,url:t,authTokenEnv:r,credentialConfigured:!0,credentialSourceUrl:n,credentialSourceAuthTokenEnv:r};return delete a.authToken,delete a.credentialUpdate,a}const i={...e,url:t,authTokenEnv:r,credentialConfigured:!1,credentialSourceUrl:n,credentialSourceAuthTokenEnv:r,credentialUpdate:"pending"};return delete i.authToken,i}function jRt(e){return e.credentialSourceAuthTokenEnv?{...e,authTokenEnv:e.credentialSourceAuthTokenEnv,credentialConfigured:!1,credentialUpdate:"reuse"}:e}function r$(e){const t={...e,credentialConfigured:!1,credentialUpdate:"replace"};return delete t.authToken,delete t.authTokenEnv,t}function RRt(e){const t=r$(e);return t.credentialUpdate="remove",t}function IRt(e){const t=ZE(e),n={},r=a=>{var l,c;Object.assign(n,((l=a.deployment)==null?void 0:l.envValues)??{}),a.subAgents.forEach(r),(c=a.workflow)==null||c.nodes.forEach(u=>r(u.agent))};r(e),Object.assign(n,t.envValues);const i=[],s=a=>{var l,c,u;for(const d of a.mcpTools??[]){const f=((l=d.authTokenEnv)==null?void 0:l.trim())??"",h=f?(n[f]??"").trim():"";d.transport!=="http"||!h||i.push({agentName:a.name.trim(),name:d.name.trim(),url:((c=d.url)==null?void 0:c.trim())??"",value:h})}a.subAgents.forEach(s),(u=a.workflow)==null||u.nodes.forEach(d=>s(d.agent))};return s(t.draft),i}function DRt(e){const t=[],n=r=>{var i,s,a;for(const l of r.mcpTools??[]){const c=((i=l.authToken)==null?void 0:i.trim())??"";l.transport!=="http"||!c||CR.test(c)||t.push({agentName:r.name.trim(),name:l.name.trim(),url:((s=l.url)==null?void 0:s.trim())??"",value:c})}r.subAgents.forEach(n),(a=r.workflow)==null||a.nodes.forEach(l=>n(l.agent))};return n(e),t}function PRt(e){const t=[],n=r=>{var i,s,a;for(const l of r.mcpTools??[]){const c=((i=l.credentialSourceAuthTokenEnv)==null?void 0:i.trim())??"";l.transport==="http"&&l.credentialUpdate==="reuse"&&c&&t.push({agentName:r.name.trim(),name:l.name.trim(),url:((s=l.url)==null?void 0:s.trim())??"",sourceAuthTokenEnv:c})}r.subAgents.forEach(n),(a=r.workflow)==null||a.nodes.forEach(l=>n(l.agent))};return n(e),t}function ZE(e){const t=new Set,n={},r=i=>{var u;const s=Lee(i.name,"AGENT"),a=(u=i.mcpTools)==null?void 0:u.map((d,f)=>{var O,v;const h=((O=d.authToken)==null?void 0:O.trim())??"",m=((v=h.match(CR))==null?void 0:v[1])??"";let b=_O(d);if(!b&&h){const x=Lee(d.name,`TOOL_${f+1}`);b=SRt(`MCP_${s}_${x}_AUTH_TOKEN`,t)}b&&t.add(b),b&&h&&!m&&(n[b]=h);const y={...d};return delete y.authToken,delete y.credentialConfigured,delete y.credentialSourceUrl,delete y.credentialSourceAuthTokenEnv,delete y.credentialUpdate,b?y.authTokenEnv=b:delete y.authTokenEnv,y}),l=i.subAgents.map(r),c=i.workflow?{...i.workflow,nodes:i.workflow.nodes.map(d=>({...d,agent:r(d.agent)}))}:void 0;return{...i,subAgents:l,...a?{mcpTools:a}:{},...c?{workflow:c}:{}}};return{draft:r(e),envValues:n}}function Wwe(e,t=!0){var r,i,s,a,l,c,u,d,f,h,m,g,b,y,O,v,x,w,S,E,k,_,T,C,A,R,M,I,$,N,j,B,F,L,H,z,Q,V,K,se,ge,ie,q,G;const n={agentType:e.agentType??"llm"};if(e.agentType==="a2a"){if((r=e.a2aRegistry)!=null&&r.enabled){const J=wj(e.cloudProvider??"volcengine"),ue={enabled:!0};(i=e.a2aRegistry.registrySpaceId)!=null&&i.trim()&&(ue.registrySpaceId=e.a2aRegistry.registrySpaceId.trim()),ue.registryTopK=((s=e.a2aRegistry.registryTopK)==null?void 0:s.trim())||J.topK,ue.registryRegion=((a=e.a2aRegistry.registryRegion)==null?void 0:a.trim())||J.region,ue.registryEndpoint=((l=e.a2aRegistry.registryEndpoint)==null?void 0:l.trim())||J.endpoint,n.a2aRegistry=ue}return n}if(n.name=e.name,n.description=e.description,n.instruction=e.instruction,e.agentType==="loop"&&(n.maxIterations=e.maxIterations??3),(c=e.modelName)!=null&&c.trim()&&(n.modelName=e.modelName.trim()),e.modelSource&&(n.modelSource=e.modelSource),e.modelSource!=="ark"&&((u=e.modelProvider)!=null&&u.trim()&&(n.modelProvider=e.modelProvider.trim()),(d=e.modelApiBase)!=null&&d.trim()&&(n.modelApiBase=e.modelApiBase.trim())),(f=e.builtinTools)!=null&&f.length&&(n.builtinTools=[...e.builtinTools]),(h=e.customTools)!=null&&h.length&&(n.customTools=e.customTools.map(J=>({name:J.name,description:J.description}))),(m=e.mcpTools)!=null&&m.length&&(n.mcpTools=e.mcpTools.map(J=>{var Oe,Qe,je,ze;const ue={name:J.name,transport:J.transport};return(Oe=J.url)!=null&&Oe.trim()&&(ue.url=J.url.trim()),(Qe=J.authTokenEnv)!=null&&Qe.trim()&&(ue.authTokenEnv=J.authTokenEnv.trim()),(je=J.command)!=null&&je.trim()&&(ue.command=J.command.trim()),(ze=J.args)!=null&&ze.length&&(ue.args=J.args),ue})),((g=e.memory)!=null&&g.shortTerm||(b=e.memory)!=null&&b.longTerm)&&(n.memory={shortTerm:!!e.memory.shortTerm,longTerm:!!e.memory.longTerm},e.memory.shortTerm&&(n.shortTermBackend=e.shortTermBackend||"local"),e.memory.longTerm&&(n.longTermBackend=e.longTermBackend||"local",(y=e.longTermMemoryIndex)!=null&&y.trim()&&(n.longTermMemoryIndex=e.longTermMemoryIndex.trim()),n.autoSaveSession=!!e.autoSaveSession)),e.knowledgebase&&(n.knowledgebase=!0,n.knowledgebaseBackend=e.knowledgebaseBackend||"viking",(O=e.knowledgebaseIndex)!=null&&O.trim()&&(n.knowledgebaseIndex=e.knowledgebaseIndex.trim())),e.tracing&&((v=e.tracingExporters)!=null&&v.length)&&(n.tracing=!0,n.tracingExporters=[...e.tracingExporters]),t&&((x=e.harnessSidecar)!=null&&x.enabled)&&(n.harnessSidecar={enabled:!0,profile:e.harnessSidecar.profile,componentOverrides:{...e.harnessSidecar.componentOverrides}}),((w=e.cloudEnvironment)!=null&&w.environmentId||(S=e.cloudEnvironment)!=null&&S.environmentVersionId||(k=(E=e.cloudEnvironment)==null?void 0:E.cliTools)!=null&&k.length||((_=e.cloudEnvironment)==null?void 0:_.dockerfile)!==void 0)&&(n.cloudEnvironment={environmentId:e.cloudEnvironment.environmentId,environmentVersionId:e.cloudEnvironment.environmentVersionId,...(T=e.cloudEnvironment.cliTools)!=null&&T.length?{cliTools:[...e.cloudEnvironment.cliTools]}:{},...e.cloudEnvironment.dockerfile!==void 0?{dockerfile:e.cloudEnvironment.dockerfile}:{}}),(C=e.deployment)!=null&&C.feishuEnabled||(R=(A=e.deployment)==null?void 0:A.runtimeName)!=null&&R.trim()||(M=e.deployment)!=null&&M.runtimeNameCustomized||($=(I=e.deployment)==null?void 0:I.modelApiKeyId)!=null&&$.trim()||(j=(N=e.deployment)==null?void 0:N.modelApiKeyName)!=null&&j.trim()||Object.keys(((B=e.deployment)==null?void 0:B.envValues)??{}).length>0){const J={feishuEnabled:!!((F=e.deployment)!=null&&F.feishuEnabled)};(H=(L=e.deployment)==null?void 0:L.runtimeName)!=null&&H.trim()&&(J.runtimeName=e.deployment.runtimeName.trim()),(z=e.deployment)!=null&&z.runtimeNameCustomized&&(J.runtimeNameCustomized=!0),(V=(Q=e.deployment)==null?void 0:Q.modelApiKeyId)!=null&&V.trim()&&(J.modelApiKeyId=e.deployment.modelApiKeyId.trim()),(se=(K=e.deployment)==null?void 0:K.modelApiKeyName)!=null&&se.trim()&&(J.modelApiKeyName=e.deployment.modelApiKeyName.trim()),Object.keys(((ge=e.deployment)==null?void 0:ge.envValues)??{}).length>0&&(J.envValues={...(ie=e.deployment)==null?void 0:ie.envValues}),n.deployment=J}return(q=e.selectedSkills)!=null&&q.length&&(n.selectedSkills=e.selectedSkills.map(J=>{const ue={source:J.source,name:J.name,folder:J.folder};return J.description&&(ue.description=J.description),J.source==="skillhub"?(ue.slug=J.slug,ue.namespace=J.namespace??"public"):J.source==="local"?ue.localFiles=J.localFiles??[]:J.source==="skillspace"&&(ue.skillSpaceId=J.skillSpaceId,ue.skillSpaceName=J.skillSpaceName,ue.skillId=J.skillId,J.version&&(ue.version=J.version)),ue})),(G=e.subAgents)!=null&&G.length&&(n.subAgents=e.subAgents.map(J=>Wwe(J,!1))),n}function MRt(e){var i;const t=ZE(e),n={...((i=t.draft.deployment)==null?void 0:i.envValues)??{},...t.envValues},r={...t.draft,deployment:{...t.draft.deployment??{feishuEnabled:!1},envValues:n}};return`# VeADK Agent 结构配置
+`).length:0,truncated:!1,updatedAt:Date.now(),pendingMessage:Jt==="running"?"正在等待 GitHub 挂载日志…":void 0},or},er=()=>{if(!(W!=="build"||!(tn!=null&&tn.text)))return tn={...tn,status:"error",updatedAt:Date.now()},tn},Wr=xn=>W==="build"&&(tn!=null&&tn.text)?Iy(tn.text,{preserveEnd:!0}):Iy(xn);try{let xn=$e;if(g&&($e!=null&&$e.pipelineId)){W="github";const Ut=on("正在同步当前源码到 GitHub"),Un={level:"info",phase:"github",message:"正在同步当前源码到 GitHub",pct:0};Cr.current&&(_t(ci=>({...ci,github:Un})),Kt("github")),x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"running",phase:"github",label:"同步 GitHub 代码",message:Un.message,pct:0,githubDelivery:!0,githubLog:Ut});const _n=await Woe({runtimeId:g,project:e});if(xn=_n,Cr.current&&(it(_n),_t(ci=>({...ci,github:{level:"success",phase:"github",message:"GitHub 代码已同步",pct:100}})),Kt(null)),(gr=_n.cicd)!=null&&gr.enabled){x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"success",phase:"github",label:"GitHub 代码已提交",message:"代码已提交到 GitHub,GitHub Actions 正在更新同一个 Runtime",pct:100,githubDelivery:!0,githubLog:on("代码已提交到 GitHub,GitHub Actions 正在更新同一个 Runtime","complete")});return}}const Jt=await c(e,Ut=>{var _n;Ut.runtimeName&&(Zt=Ut.runtimeName);const Un=Mjt(W,Ut.phase);Ut.buildLog?tn=Njt(tn,Ut.buildLog):Ut.phase==="build"&&!tn&&(tn=an()),Ut.phase===Un&&(Te=Ut.message),W=Un,Cr.current&&(_t(ci=>({...ci,[Ut.phase]:Ut})),Kt(W)),x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"running",phase:W,label:((_n=Le.find(ci=>ci.phase===W))==null?void 0:_n.label)??W,message:Te,pct:Ut.pct,...tn?{buildLog:tn}:{}})},{taskId:Je,runtimeName:dn,sessionStorage:ie?"in-memory":"persistent",minInstance:pn.min,maxInstance:pn.max,...se?{}:{authentication:Tr==="user_pool"?{type:"user_pool",userPoolUid:Ii}:{type:"api_key"}},createEvaluationSets:_a,...w?{im:{feishu:{enabled:!0}}}:{},envs:fe,...se?{}:{resources:ar}});if(!g&&ve&&Jt.runtimeId){W="github";const Ut=on("开始初始化 GitHub main 分支与 Actions workflow"),Un={level:"info",phase:"github",message:"正在初始化 GitHub 持续交付目标分支",pct:0};Cr.current&&(_t(_n=>({..._n,github:Un})),Kt("github")),x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId,region:Jt.region||j,startedAt:Tt,status:"running",phase:"github",label:"挂载 GitHub 持续交付",message:Un.message,pct:0,githubDelivery:!0,githubLog:Ut});try{const _n=await qoe({project:e,githubUrl:ve.githubUrl,githubToken:ve.githubToken,baseBranch:ve.baseBranch,runtimeName:Jt.agentName||Zt,runtimeId:Jt.runtimeId,region:Jt.region||j,cloudProvider:ve.cloudProvider,projectPath:".",volcengineAccessKey:ve.volcengineAccessKey,volcengineSecretKey:ve.volcengineSecretKey,volcengineSessionToken:ve.volcengineSessionToken});xn=_n,Cr.current&&(it(_n),He(null),_t(ci=>({...ci,github:{level:"success",phase:"github",message:"GitHub 持续交付已初始化目标分支",pct:100}})),Kt(null)),x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId,region:Jt.region||j,startedAt:Tt,status:"running",phase:"github",label:"GitHub 持续交付已挂载",message:"GitHub 持续交付已初始化目标分支",pct:100,githubDelivery:!0,githubLog:on("GitHub 持续交付已初始化目标分支","complete")})}catch(_n){const ci=on(`GitHub 持续交付挂载失败:${_n instanceof Error?_n.message:String(_n)}`,"error");throw x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId,region:Jt.region||j,startedAt:Tt,status:"error",phase:"github",label:"挂载 GitHub 持续交付失败",message:"挂载 GitHub 持续交付失败,详见 GitHub 日志。",pct:100,githubDelivery:!0,githubLog:ci}),new Error(`部署成功,但挂载 GitHub 持续交付失败:${_n instanceof Error?_n.message:String(_n)}`)}}else if(!g&&(xn!=null&&xn.pipelineId)&&Jt.runtimeId)try{const Ut=await S9({pipelineId:xn.pipelineId,runtimeId:Jt.runtimeId,region:Jt.region||j,cloudProvider:xn.cloudProvider??N});xn=Ut,Cr.current&&it(Ut)}catch(Ut){Cr.current&&xt(`部署成功,但绑定 GitHub 失败:${Ut instanceof Error?Ut.message:String(Ut)}`)}Cr.current&&(xe(Jt),Kt(null)),Lt.succeed({runtimeId:String(Jt.runtimeId||g||"")}),x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId||g,region:Jt.region||j,startedAt:Tt,status:"success",phase:"complete",label:"部署完成",message:(Nr=Jt.warnings)==null?void 0:Nr.join(";"),githubDelivery:!!(ve||or),...or?{githubLog:or}:{},...nn("complete")});try{await(d==null?void 0:d(Jt))}catch(Ut){if(!(Ut instanceof _s))throw Ut;x==null||x({id:Je,agentName:Jt.agentName||St,runtimeName:Jt.runtimeName||Zt,runtimeId:Jt.runtimeId||g,region:Jt.region||j,startedAt:Tt,status:"success",phase:"complete",label:"部署完成,暂未连接",message:Ut.message,...nn("complete")})}}catch(xn){const Jt=xn instanceof Error?xn.message:String(xn);if(xn instanceof DOMException&&xn.name==="AbortError"){Lt.fail({failedPhase:Iee(W),...mo(xn,{phase:W}),errorMessage:Iy(xn)}),Cr.current&&(xt(null),Kt(null)),x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"cancelled",label:"已取消",message:"部署已取消,相关 Runtime 资源已请求销毁。",...nn("complete")});return}const Ut=W==="build"&&Pjt(xn),Un=Ut?p_:Jt;Cr.current&&xt(Un),Cr.current&&xe(null);const _n=er();Lt.fail({failedPhase:Iee(W),...mo(xn,{phase:W}),errorMessage:Wr(xn)});const ci=!!_n,co=W==="github"&&!!or;x==null||x({id:Je,agentName:St,runtimeName:Zt,runtimeId:g,region:j,startedAt:Tt,status:"error",phase:W,label:Ut?"构建状态待确认":"部署失败",message:Ut?p_:ci?"构建镜像失败,详见构建日志。":co?"挂载 GitHub 持续交付失败,详见 GitHub 日志。":Jt,..._n?{buildLog:_n}:nn("complete"),...co?{githubDelivery:!0,githubLog:or}:{},...Ut?{}:{retry:In}})}finally{Cr.current&&We(!1)}}function Os(){kt(!1)}async function Jn(){if(!(!Ie||en)){le(!0),xt(null);try{const{addConnection:fe,addRuntimeConnection:Je,remoteAppId:St,loadConnections:dn}=await fd(async()=>{const{addConnection:Lt,addRuntimeConnection:Ne,remoteAppId:tn,loadConnections:or}=await Promise.resolve().then(()=>mJ);return{addConnection:Lt,addRuntimeConnection:Ne,remoteAppId:tn,loadConnections:or}},void 0),{probeRuntimeApps:Zt}=await fd(async()=>{const{probeRuntimeApps:Lt}=await Promise.resolve().then(()=>$5e);return{probeRuntimeApps:Lt}},void 0);let Tt;if(Ie.runtimeId){const Lt=Ie.region??j,Ne=await Zt(Ie.runtimeId,Lt,{retryProbe:!0})??[];Tt=Je(Ie.runtimeId,Ie.runtimeName,Lt,Ne,Ne.length>0?{[Ne[0]]:Ie.agentName}:void 0,Ie.version)}else Tt=await fe(Ie.agentName,Ie.url,Ie.apikey,"");if(Tt.apps.length===0)xt("连接成功,但该地址未发现任何 Agent(/list-apps 为空)。");else{const Lt={[Tt.apps[0]]:Ie.agentName},Ne={...Tt,appLabels:{...Tt.appLabels??{},...Lt}},or=dn().map(Te=>Te.id===Tt.id?Ne:Te);localStorage.setItem("veadk_agentkit_connections",JSON.stringify(or));const{registerConnections:W}=await fd(async()=>{const{registerConnections:Te}=await Promise.resolve().then(()=>mJ);return{registerConnections:Te}},void 0);if(W(or),u){const Te=St(Tt.id,Tt.apps[0]);await u(Te,Ie.agentName)}else alert(`🎉 Agent "${Ie.agentName}" 已添加到左上角下拉列表!`)}}catch(fe){xt(`添加 Agent 失败:${fe instanceof Error?fe.message:String(fe)}`)}finally{le(!1)}}}function li(){const fe=Ta(),Je=cwe({agentId:fe.agentId,deployAction:fe.deployAction,deploySource:fe.deploySource,createMode:fe.createMode,aiAssisted:fe.aiAssisted});try{const St=pjt(e.files),dn=URL.createObjectURL(St),Zt=document.createElement("a");Zt.href=dn,Zt.download=`${e.name||"project"}.zip`,document.body.appendChild(Zt),Zt.click(),document.body.removeChild(Zt),URL.revokeObjectURL(dn),Je.succeed({fileCount:e.files.length,zipSizeBytes:St.size})}catch(St){throw Je.fail({fileCount:e.files.length,...mo(St)}),St}}const Ld=o.jsxs("div",{className:`pp-artifact-actions${t?" is-rail":""}`,"aria-label":"发布产物操作",children:[z&&o.jsxs("button",{type:"button",className:"pp-secondary",onClick:z,children:[o.jsx(HRe,{className:"pp-ic"}),"导出 YAML"]}),K&&l&&o.jsx(Hdt,{project:e,onChange:l,className:"pp-artifact-source",label:"查看源代码"}),e.files.length>0&&o.jsxs("button",{type:"button",className:"pp-secondary",onClick:li,children:[o.jsx(jN,{className:"pp-ic"}),"下载源代码"]})]});function ll(fe,Je,St){return eRt(fe,Je===0).map(dn=>{const Zt=St?`${St}/${dn.name}`:dn.name,Tt=dn.path!==void 0,Lt={paddingLeft:8+Je*14};if(Tt){const tn=dn.path===Ue;return o.jsxs("button",{type:"button",className:`pp-row pp-file${tn?" pp-active":""}`,style:Lt,onClick:()=>re(dn.path),title:dn.path,children:[o.jsx(GRe,{className:"pp-ic"}),o.jsx("span",{className:"pp-label",children:dn.name})]},Zt)}const Ne=ce.has(Zt);return o.jsxs("div",{children:[o.jsxs("button",{type:"button",className:"pp-row pp-folder",style:Lt,onClick:()=>Pd(Zt),children:[o.jsx(XS,{className:`pp-ic pp-chevron${Ne?"":" pp-open"}`}),o.jsx(YRe,{className:"pp-ic"}),o.jsx("span",{className:"pp-label",children:dn.name})]}),!Ne&&ll(dn,Je+1,Zt)]},Zt)})}return o.jsxs("div",{className:`pp-root${c?" is-deploy":""}${t?" is-embedded":""}${Q?" has-primary-pane":""}`,children:[c&&!t&&o.jsx(nRt,{left:o.jsxs("div",{className:"pp-toolbar-left",children:[L&&o.jsxs("button",{type:"button",className:"pp-toolbar-back",onClick:L,children:[o.jsx(Dae,{className:"pp-ic"}),H]}),o.jsxs("span",{className:"pp-toolbar-title",children:["部署 ",i||e.name||"未命名 Agent",s&&s>1?` 等 ${s} 个智能体`:""]})]}),right:null}),o.jsxs("div",{className:"pp-body",children:[c&&!Q&&o.jsx("section",{className:"pp-release-overview","aria-label":"发布概览",children:o.jsxs("div",{className:`pp-release-preview${t?" is-embedded":""}`,children:[o.jsxs("div",{className:"pp-flow-thumbnail",children:[r&&o.jsx(zw,{draft:r,direction:"horizontal",selectedPath:[],onSelect:Vh,onAdd:Vh,onInsert:Vh,onDelete:Vh,readOnly:!0,interactivePreview:!0}),o.jsx("button",{type:"button",className:"pp-flow-expand",onClick:()=>Dt(!0),"aria-label":"放大查看执行流程",title:"放大查看",children:o.jsx(cy,{"aria-hidden":!0})})]}),t&&Ld,!t&&o.jsxs("div",{className:"pp-release-info",children:[o.jsx("div",{className:"pp-release-card-head",children:"Agent 概览"}),o.jsxs("div",{className:"pp-release-info-body",children:[o.jsxs("div",{className:"pp-release-info-main",children:[o.jsx("h2",{children:i||e.name||"未命名 Agent"}),(r==null?void 0:r.description)&&o.jsx("p",{className:"pp-release-description",title:r.description,children:r.description}),o.jsxs("dl",{className:"pp-release-facts",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"Agent 数量"}),o.jsx("dd",{children:s??1})]}),a&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("dt",{children:"模型"}),o.jsx("dd",{children:a.modelName})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"描述"}),o.jsx("dd",{className:"pp-release-fact-long",children:a.description})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"系统提示词"}),o.jsx("dd",{className:"pp-release-fact-long pp-release-prompt",children:a.instruction})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"优化选项"}),o.jsx("dd",{children:a.optimizations.length>0?a.optimizations.join("、"):"未启用"})]}),a.effectiveOptimizations&&a.effectiveOptimizations.length>0&&o.jsxs("div",{children:[o.jsx("dt",{children:"生效能力"}),o.jsx("dd",{children:a.effectiveOptimizations.join("、")})]}),a.autoAddedOptimizations&&a.autoAddedOptimizations.length>0&&o.jsxs("div",{children:[o.jsx("dt",{children:"自动保护"}),o.jsx("dd",{children:a.autoAddedOptimizations.join("、")})]}),a.planHash&&o.jsxs("div",{children:[o.jsx("dt",{children:"Plan Hash"}),o.jsx("dd",{className:"pp-release-fact-long",children:a.planHash})]})]})]})]}),Ld]})]})]})}),o.jsxs("div",{className:"pp-files-area",children:[o.jsxs("div",{className:"pp-sidebar",children:[o.jsxs("div",{className:"pp-sidebar-head",children:[o.jsx("span",{className:"pp-project-name",title:e.name,children:"文件预览"}),K&&o.jsx("button",{type:"button",className:"pp-icon-btn",title:"新建文件",onClick:()=>{Z(!0),rt("")},children:o.jsx(qRe,{className:"pp-ic"})})]}),o.jsxs("div",{className:"pp-tree",children:[Ye&&o.jsx("input",{className:"pp-new-input",autoFocus:!0,placeholder:"path/to/file.py",value:_e,onChange:fe=>rt(fe.target.value),onBlur:oo,onKeyDown:fe=>{fe.key==="Enter"&&oo(),fe.key==="Escape"&&(Z(!1),rt(""))}}),e.files.length===0&&!Ye?o.jsx("div",{className:"pp-empty",children:"暂无文件"}):ll($r,0,"")]})]}),o.jsxs("div",{className:"pp-main",children:[o.jsxs("div",{className:"pp-main-head",children:[o.jsx("span",{className:"pp-path",title:Gr==null?void 0:Gr.path,children:(Gr==null?void 0:Gr.path)??"未选择文件"}),o.jsx("div",{className:"pp-actions",children:K&&Gr&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"pp-icon-btn",title:"重命名",onClick:Yl,children:o.jsx(iIe,{className:"pp-ic"})}),o.jsx("button",{type:"button",className:"pp-icon-btn pp-danger",title:"删除",onClick:Ru,children:o.jsx(Fp,{className:"pp-ic"})})]})})]}),o.jsx("div",{className:"pp-content",children:Gr==null?o.jsx("div",{className:"pp-placeholder",children:"选择左侧文件以查看内容"}):K?o.jsx("div",{className:"pp-codemirror",children:o.jsx(p.Suspense,{fallback:o.jsx("div",{className:"pp-editor-loading",children:"加载编辑器…"}),children:o.jsx(Ljt,{value:Gr.content,path:Gr.path,onChange:ol})})}):o.jsx("pre",{className:"pp-pre hljs",dangerouslySetInnerHTML:{__html:Hjt(Gr.content,Gr.path)}})})]})]}),c&&o.jsxs("aside",{className:"pp-config","aria-label":"部署配置",children:[o.jsx("div",{className:"pp-config-head",children:o.jsx("div",{className:"pp-config-title",children:"部署配置"})}),o.jsxs("div",{className:"pp-config-scroll",children:[Q,!Q&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("label",{className:"pp-config-label",htmlFor:qr,children:"Runtime 名称"}),o.jsxs("div",{className:"pp-runtime-name-field",children:[o.jsx("input",{id:qr,className:"pp-runtime-name-input",value:Oe,disabled:Re||Ge||se,maxLength:64,autoComplete:"off","aria-label":"Runtime 名称","aria-invalid":!!Se,"aria-describedby":`${mr}${Se?` ${Xr}`:""}`,onChange:fe=>{const Je=fe.currentTarget.value;ze(null),xt(null),O?O(Je):ue(Je)}}),o.jsx("p",{id:mr,className:"pp-config-note",children:se?"更新时保持现有 Runtime 名称不变。":"默认根据 Root Agent 名称生成,并添加随机后缀避免重名;支持 4-64 位字母、数字、连字符和下划线"}),Se&&o.jsx("p",{id:Xr,className:"pp-runtime-name-error",role:"alert",children:Se})]})]}),!Q&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"发布区域"}),An(!1)]}),!Q&&o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"pp-config-section pp-auth-section",children:[o.jsx("div",{className:"pp-config-label",children:"访问鉴权"}),se?o.jsx("p",{className:"pp-config-note pp-auth-preserved-note",children:"更新时保持现有 Runtime 的鉴权方式不变。"}):o.jsxs("div",{className:"pp-auth-fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"鉴权方式"}),o.jsx(GE,{ariaLabel:"部署鉴权方式",value:Tr,placeholder:"请选择鉴权方式",options:Fjt,disabled:Re,onChange:fe=>{xt(null),oi(fe)}})]}),Tr==="user_pool"&&o.jsxs("label",{children:[o.jsx("span",{children:"用户池"}),o.jsx(Ujt,{value:Ii,disabled:Re,onChange:fe=>{xt(null),bi(fe)}})]})]})]}),o.jsx(Djt,{project:e,region:j,cloudProvider:N,runtimeId:g,binding:$e,showSetup:!se,onPendingCicdChange:He,onBindingChange:ae,disabled:Re||Xe||V||!!n})]}),!Q&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"消息渠道"}),o.jsx(kjt,{enabled:w,updating:Xe,disabled:Re||Ge||!S||!M,agentName:i||e.name,appId:A.FEISHU_APP_ID??"",appSecret:A.FEISHU_APP_SECRET??"",appIdConfigured:ge.has("FEISHU_APP_ID"),appSecretConfigured:ge.has("FEISHU_APP_SECRET"),onToggle:_h,onCredentialsChange:(fe,Je)=>{M==null||M(fe,Je)}})]}),!se&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"实例设置"}),o.jsxs("div",{className:"pp-instance-fields",children:[o.jsxs("label",{htmlFor:"runtime-min-instance",children:[o.jsx("span",{children:"最小实例数"}),o.jsx("input",{id:"runtime-min-instance",type:"number",min:"0",step:"1",inputMode:"numeric",value:rs,disabled:Re||tt,"aria-invalid":!pn.valid,onChange:fe=>oa(fe.currentTarget.value)})]}),o.jsxs("label",{htmlFor:"runtime-max-instance",children:[o.jsx("span",{children:"最大实例数"}),o.jsx("input",{id:"runtime-max-instance",type:"number",min:"1",step:"1",inputMode:"numeric",value:Qr,disabled:Re||tt,"aria-invalid":!pn.valid,onChange:fe=>Ws(fe.currentTarget.value)})]})]}),(ie||tt)&&o.jsx("p",{className:"pp-instance-note",role:"note",children:tt?"Harness Sidecar 首期仅支持单实例,Runtime 固定为 1~1":"为避免多实例间会话丢失,推荐将 Runtime 固定为 1~1"}),!pn.valid&&o.jsx("p",{className:"pp-instance-error",role:"alert",children:pn.error})]}),o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"网络"}),Q&&An(!0),se&&o.jsx("p",{className:"pp-config-note",children:"现有 Runtime 的区域与网络模式保持不变。"}),o.jsxs("div",{className:"pp-network-layout",children:[o.jsx("div",{className:"pp-network-modes",role:"radiogroup","aria-label":"网络模式",children:["public","private","both"].map(fe=>o.jsxs("label",{className:"pp-network-option",children:[o.jsx("input",{type:"radio",name:"deployment-network-mode",value:fe,checked:Zs===fe,onChange:()=>Md(fe),disabled:Re||se||!$}),o.jsx("span",{children:fe==="public"?"公网":fe==="private"?"VPC":"公网 + VPC"})]},fe))}),Zs!=="public"&&o.jsxs("div",{className:"pp-network-fields",children:[o.jsxs("label",{children:[o.jsx("span",{children:"VPC ID"}),o.jsx("input",{value:(I==null?void 0:I.vpcId)??"",placeholder:"vpc-xxxxxxxx",disabled:Re||se,onChange:fe=>kn({vpcId:fe.target.value})})]}),o.jsxs("label",{children:[o.jsxs("span",{children:["子网 ID ",o.jsx("small",{children:"可选,多个用逗号分隔"})]}),o.jsx("input",{value:(I==null?void 0:I.subnetIds)??"",placeholder:"subnet-xxx, subnet-yyy",disabled:Re||se,onChange:fe=>kn({subnetIds:fe.target.value})})]}),o.jsxs("label",{className:"pp-network-check",children:[o.jsx("input",{type:"checkbox",checked:!!(I!=null&&I.enableSharedInternetAccess),disabled:Re||se,onChange:fe=>kn({enableSharedInternetAccess:fe.target.checked})}),"VPC 内共享公网出口"]})]})]})]}),Ys&&o.jsxs("section",{className:"pp-config-section",children:[o.jsx("div",{className:"pp-config-label",children:"评测集"}),o.jsxs("label",{className:"pp-evaluation-set-option",children:[o.jsx("input",{type:"checkbox",checked:is,disabled:Re,onChange:fe=>ka(fe.currentTarget.checked)}),o.jsxs("span",{children:[o.jsx("strong",{children:"自动创建评测集"}),o.jsx("small",{children:"部署成功后,自动创建 Good Case 和 Bad Case 评测集。"})]})]})]}),!se&&o.jsxs("section",{className:"pp-config-section pp-resource-section",children:[o.jsx("div",{className:"pp-config-label",children:"资源配置"}),o.jsx(Qve,{value:ar,agentName:i||e.name||"agentkit-app",runtimeName:Oe,region:j,disabled:Re,validationError:Gn,onChange:fe=>{pr(fe),zn(null)}})]}),o.jsxs("section",{className:"pp-config-section pp-env-section",children:[o.jsx("div",{className:"pp-env-head",children:o.jsxs("div",{children:[o.jsxs("div",{className:"pp-config-label",children:["环境变量",o.jsxs("span",{className:"pp-agent-child-count pp-env-count",children:[Dd," 项"]})]}),o.jsx("div",{className:"pp-env-sub",children:"组件配置会自动同步到这里,部署前可核对最终值。"})]})}),o.jsxs("button",{type:"button",className:"pp-env-add",onClick:Ro,disabled:Re,children:[o.jsx(vo,{className:"pp-ic"}),"添加变量"]}),(Va.length>0||_.length>0||Xt.length>0)&&o.jsxs("div",{className:"pp-env-table",children:[Va.length>0&&o.jsxs("div",{className:"pp-env-group",children:[o.jsxs("div",{className:"pp-env-group-head",children:[o.jsx("span",{children:"组件自动生成"}),o.jsxs("small",{children:[Va.length," 项"]})]}),Va.map(fe=>{const Je=fe.readOnly||fe.key.startsWith("ENABLE_"),St=fe.serverManaged&&fe.key==="MODEL_AGENT_API_KEY",dn=St?so?Ks.value:"由所选 API Key 注入":fe.value,Zt=AU(fe,A),Tt=et[fe.key],Lt=`deployment-env-${fe.key.toLowerCase()}-error`,Ne=Cee(fe)||fe.help||fe.comment,tn=fe.multiline||fe.format==="json";return o.jsxs("div",{className:`pp-env-row pp-env-row-derived${tn?" is-multiline":""}`,children:[o.jsxs("div",{className:"pp-env-key-fixed pp-env-key-cell","aria-label":`${fe.key} 环境变量名`,"aria-disabled":Re,children:[o.jsx("span",{title:fe.key,children:fe.key}),Ne&&o.jsxs("span",{className:"pp-env-help",tabIndex:0,"data-help":Ne,"aria-label":`${fe.key}说明:${Ne}`,children:["?",o.jsx("span",{className:"pp-env-help-popover",role:"tooltip",children:Ne})]}),fe.link&&o.jsx("a",{className:"pp-env-link",href:fe.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开 OpenViking ${fe.link.label}`,"aria-label":`${fe.key}:打开 OpenViking ${fe.link.label}`,children:o.jsx(Dg,{"aria-hidden":"true"})})]}),o.jsxs("div",{className:"pp-env-value-wrap",children:[tn?o.jsx("textarea",{ref:or=>{or?Mt.current.set(fe.key,or):Mt.current.delete(fe.key)},className:"pp-env-value pp-env-json-value",value:fe.value,placeholder:fe.placeholder||(fe.required?"必填,尚未填写":"可选,尚未填写"),readOnly:Je,disabled:Re||!Je&&!R,autoComplete:"off",spellCheck:!1,"aria-invalid":!!(Tt||Zt),"aria-describedby":Tt?Lt:void 0,"aria-label":`${fe.key} 环境变量值`,onChange:or=>{const W=or.currentTarget.value;R==null||R(fe.key,W),Tt&&W.trim()&&(zc(fe.key),xt(null))}}):o.jsxs("div",{className:St?"pp-env-secret-control":void 0,children:[o.jsx("input",{ref:or=>{or?Mt.current.set(fe.key,or):Mt.current.delete(fe.key)},className:"pp-env-value",type:St?"text":fe.secret?"password":"text",value:dn,placeholder:fe.placeholder||(fe.required?"必填,尚未填写":"可选,尚未填写"),readOnly:Je,disabled:Re||!Je&&!R,autoComplete:fe.secret?"new-password":"off",spellCheck:fe.secret?!1:void 0,"aria-invalid":!!(Tt||Zt),"aria-describedby":Tt?Lt:void 0,"aria-label":`${fe.key} 环境变量值`,onChange:or=>{const W=or.currentTarget.value;R==null||R(fe.key,W),Tt&&W.trim()&&(zc(fe.key),xt(null))}}),St&&o.jsx("button",{type:"button",className:"pp-env-secret-toggle","aria-label":jo,title:jo,"aria-pressed":so,disabled:Ks.status==="loading"||!Ee,onClick:()=>{so?At():sn()},children:Ks.status==="loading"?o.jsx(rr,{className:"pp-env-secret-spinner","aria-hidden":"true"}):so?o.jsx(Bjt,{}):o.jsx($jt,{})})]}),Tt&&o.jsx("span",{id:Lt,className:"pp-env-error",role:"alert",children:Tt}),Zt&&o.jsx("span",{className:"pp-env-error",children:Zt}),St&&Ks.status==="error"&&o.jsx("span",{className:"pp-env-reveal-error",role:"alert",children:Ks.error})]}),o.jsx("span",{className:"pp-env-source",children:Je?"自动":"同步"})]},fe.key)})]}),_.length>0&&o.jsxs("div",{className:"pp-env-group",children:[o.jsxs("div",{className:"pp-env-group-head",children:[o.jsx("span",{children:"自定义模型凭据"}),o.jsxs("small",{children:[_.length," 项"]})]}),_.map(fe=>{const Je=_r===fe.key,St=`${fe.key.toLowerCase()}-error`;return o.jsxs("div",{className:"pp-env-row pp-env-row-derived",children:[o.jsx("label",{className:"pp-env-key-fixed pp-env-key-cell",htmlFor:fe.key,title:fe.label,children:o.jsx("span",{children:fe.key})}),o.jsxs("div",{className:"pp-env-value-wrap",children:[o.jsx("input",{id:fe.key,className:"pp-env-value",type:"password",value:Kn[fe.key]??"",placeholder:"必填,仅用于本次发布",disabled:Re,autoComplete:"new-password",spellCheck:!1,"aria-invalid":Je,"aria-describedby":Je?St:void 0,"aria-label":fe.label,onChange:dn=>{const Zt=dn.currentTarget.value;C?C(fe.key,Zt):ln(Tt=>({...Tt,[fe.key]:Zt})),Je&&Zt.trim()&&(Ve(null),xt(null))}}),Je&&o.jsx("span",{id:St,className:"pp-env-error",role:"alert",children:"请填写此模型地址对应的 API Key。"})]}),o.jsx("span",{className:"pp-env-source",children:"本次发布"})]},fe.key)})]}),Xt.length>0&&o.jsxs("div",{className:"pp-env-group-head pp-env-group-head-custom",children:[o.jsx("span",{children:"自定义变量"}),o.jsxs("small",{children:[Xt.length," 项"]})]}),Xt.map(fe=>o.jsxs("div",{className:"pp-env-row",children:[o.jsx("input",{value:fe.key,placeholder:"名称",disabled:Re,autoComplete:"off",onChange:Je=>Fc(fe.id,{key:Je.currentTarget.value})}),o.jsx("input",{type:"text",value:fe.value,placeholder:"值",disabled:Re,autoComplete:"off",onChange:Je=>Fc(fe.id,{value:Je.currentTarget.value})}),o.jsx("button",{type:"button",className:"pp-icon-btn pp-env-remove",title:"删除变量",disabled:Re,onClick:()=>Iu(fe.id),children:o.jsx(Ea,{className:"pp-ic"})})]},fe.id))]})]}),(Re||Ie||Object.keys(pt).length>0)&&o.jsxs("section",{className:"pp-config-section pp-progress-section",children:[o.jsx("div",{className:"pp-config-label",children:"部署进度"}),o.jsx("ol",{className:"pp-steps",children:Le.map((fe,Je)=>{const St=It?Le.findIndex(Lt=>Lt.phase===It):-1,dn=!!ft&&(St===-1?Je===0:Je===St),Zt=pt[fe.phase];let Tt;return Ie||(Zt==null?void 0:Zt.level)==="success"?Tt="done":dn?Tt="failed":St===-1?Tt=Re?"active":"pending":Jefe.phase===It))==null?void 0:ca.label)??It}阶段):`:""}${ft}`,onRetry:ft===p_?void 0:In,retryLabel:se?"重试更新":"重试部署"}),Ie&&o.jsxs("section",{className:"pp-deploy-result",children:[o.jsx("div",{className:"pp-deploy-result-header",children:se?"更新成功":"部署成功"}),o.jsxs("div",{className:"pp-deploy-result-body",children:[Ie.warnings&&Ie.warnings.length>0&&o.jsx("div",{className:"pp-deploy-result-warning",role:"status",children:Ie.warnings.map(fe=>o.jsx("span",{children:fe},fe))}),Ie.region&&o.jsxs("div",{className:"pp-deploy-result-field",children:[o.jsx("label",{children:"区域"}),o.jsx("code",{children:Jf(Ie.region,N)})]}),o.jsxs("div",{className:"pp-deploy-result-field",children:[o.jsx("label",{children:"Agent 名称"}),o.jsx("code",{children:Ie.agentName})]}),o.jsxs("div",{className:"pp-deploy-result-field",children:[o.jsx("label",{children:"Runtime 名称"}),o.jsx("code",{children:Ie.runtimeName})]}),o.jsxs("div",{className:"pp-deploy-result-field",children:[o.jsx("label",{children:"API 端点"}),o.jsx("code",{className:"pp-deploy-result-url",children:Ie.url})]})]}),o.jsxs("div",{className:"pp-deploy-result-actions",children:[o.jsxs("button",{type:"button",className:"pp-deploy-result-btn",onClick:Jn,disabled:en,children:[en?o.jsx(rr,{className:"pp-ic spin"}):o.jsx(Qae,{className:"pp-ic"}),en?"连接中…":"立即对话"]}),Ie.consoleUrl&&o.jsxs("a",{href:Ie.consoleUrl,target:"_blank",rel:"noopener noreferrer",className:"pp-console-link pp-console-link-btn",children:[o.jsx(Dg,{className:"pp-ic"}),"控制台"]})]})]})]}),o.jsx("div",{className:`pp-config-actions${Ds?" is-external":""}`,children:Ds?kr.createPortal(o.jsx("button",{type:"button",className:"pp-deploy studio-update-action",onClick:In,disabled:Re||Ge||Xe||V||!!n||!!Se,title:n||Se||void 0,children:Re?`${f}中…`:Ge?"正在检查名称…":ft?`重试${f}`:f}),Ds):o.jsx("button",{type:"button",className:"pp-deploy studio-update-action",onClick:In,disabled:Re||Ge||Xe||V||!!n||!!Se,title:n||Se||void 0,children:Re?`${f}中…`:Ge?"正在检查名称…":ft?`重试${f}`:f})})]})]}),qt&&r&&kr.createPortal(o.jsx("div",{className:"pp-flow-backdrop",onMouseDown:fe=>{fe.target===fe.currentTarget&&Dt(!1)},children:o.jsxs("section",{className:"pp-flow-dialog",role:"dialog","aria-modal":"true","aria-label":"执行流程预览",children:[o.jsxs("header",{children:[o.jsxs("div",{children:[o.jsx("strong",{children:"执行流程"}),o.jsx("span",{children:"只读预览,可缩放与拖动画布"})]}),o.jsx("button",{type:"button",onClick:()=>Dt(!1),"aria-label":"关闭执行流程预览",children:o.jsx(Ea,{"aria-hidden":!0})})]}),o.jsx("div",{className:"pp-flow-dialog-canvas",children:o.jsx(zw,{draft:r,direction:"horizontal",selectedPath:[],onSelect:Vh,onAdd:Vh,onInsert:Vh,onDelete:Vh,readOnly:!0,interactivePreview:!0})})]})}),document.body),o.jsx(Qjt,{open:ct,isUpdate:se,...h,onCancel:Os,onConfirm:()=>void Vn()})]})}const rRt=new Set(["MODEL_AGENT_API_KEY"]),iRt=new Set(["MODEL_AGENT_NAME","MODEL_NAME"]),sRt=new Set(["VOLCENGINE_ACCESS_KEY","VOLCENGINE_SECRET_KEY","VOLCENGINE_SESSION_TOKEN","BYTEPLUS_ACCESS_KEY","BYTEPLUS_SECRET_KEY","BYTEPLUS_SESSION_TOKEN","VEADK_DISABLE_EXPIRE_AT"]);function Tg(e){return!sRt.has(e)}function NS(e){return rRt.has(e)||/(?:API_KEY|ACCESS_KEY|SECRET_KEY|PRIVATE_KEY|TOKEN|SECRET|PASSWORD|PASSWD|PWD|CREDENTIAL)$/.test(e)}function aRt(e,t){const n={},r=new Set([...e.environment.required,...e.environment.optional]);for(const i of r){if(!Tg(i)||NS(i))continue;const s=i==="MODEL_AGENT_API_BASE"?nl(t):iRt.has(i)?eh(t):e.environment.defaults[i];s!=null&&s.trim()&&(n[i]=s)}return n}function oRt({delivery:e,onBack:t,onAgentAdded:n,onDeploymentTaskChange:r,onDeploymentStarted:i,onDeploymentComplete:s,cloudProvider:a="volcengine",initialDeployRegion:l}){const[c,u]=p.useState(l??Zr(a)),[d,f]=p.useState(),[h,m]=p.useState(null),[g,b]=p.useState(!1),[y,O]=p.useState(()=>({name:Kve(e.agentName),files:e.files??[]})),v=e.environment??{required:[],optional:[],defaults:{}},[x,w]=p.useState(()=>({...v.defaults})),S=v.required.filter(Tg).filter(NS).map(C=>({key:C,label:C})),E=[...v.required.filter(Tg).filter(C=>!NS(C)).map(C=>({key:C,required:!0,comment:C,placeholder:`请输入 ${C}`})),...v.optional.filter(Tg).map(C=>({key:C,required:!1,comment:C,placeholder:`可选:${C}`}))],k=WE(y.name);p.useEffect(()=>{if(k){m(null);return}const C=new AbortController,A=window.setTimeout(()=>{b(!0),$N(y.name,c).then(R=>{C.signal.aborted||m(R.available===!0)}).catch(()=>{C.signal.aborted||m(null)}).finally(()=>{C.signal.aborted||b(!1)})},250);return()=>{window.clearTimeout(A),C.abort()}},[c,y.name,k]);const _={kind:"intelligentDevelopment",sessionId:e.sessionId,...e.projectId&&e.versionId?{projectId:e.projectId,versionId:e.versionId}:{},artifactSha256:e.artifactSha256,validationReportSha256:e.validationReportSha256,...e.verified?{}:{acknowledgeUnverified:!0}};async function T(C,A,R){const M=d&&d.mode!=="public"?{mode:d.mode,vpc_id:d.vpcId,subnet_ids:d.subnetIds,enable_shared_internet_access:d.enableSharedInternetAccess}:void 0;return z1(C.name,[],{region:c,projectName:"default",network:M},{...R,onStage:A,runtimeName:C.name,source:_})}return o.jsx(_R,{cloudProvider:a,project:y,agentName:y.name,onDeploy:T,onAgentAdded:n,onDeploymentTaskChange:r,onDeploymentStarted:i,onDeploymentComplete:s,network:d,onNetworkChange:f,deployRegion:c,onDeployRegionChange:u,deploymentEnv:E,requiredSecretEnv:S,deploymentEnvValues:x,onDeploymentEnvChange:(C,A)=>w(R=>({...R,[C]:A})),deploymentActionLabel:"部署",deployDisabled:!!k||h===!1||g,deployDisabledReason:k??(h===!1?"Runtime 名称已存在,请更换后重试":g?"正在检查 Runtime 名称":void 0),deploymentTelemetry:{source:"intelligent_development",createMode:"intelligent",aiAssisted:!0},onBack:t,backLabel:"返回开发会话",deploymentPrimaryPane:o.jsxs("section",{className:"trusted-source-pane","aria-label":e.verified?"已验证源码":"可部署源码",children:[o.jsx("div",{className:"trusted-source-pane__badge",children:e.verified?"已通过 Codex 云端验证":"可部署源码"}),o.jsx("h2",{children:e.agentName}),o.jsxs("label",{className:"trusted-source-pane__runtime-name",children:[o.jsx("span",{children:"Runtime 名称"}),o.jsx("input",{value:y.name,maxLength:64,onChange:C=>O(A=>({...A,name:C.target.value}))})]}),o.jsxs("dl",{children:[o.jsxs("div",{children:[o.jsx("dt",{children:"入口"}),o.jsx("dd",{children:o.jsx("code",{children:e.entryPoint})})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"文件"}),o.jsx("dd",{children:e.fileCount})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"Artifact"}),o.jsx("dd",{children:o.jsx("code",{children:e.artifactSha256.slice(0,16)})})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"验证报告"}),o.jsx("dd",{children:o.jsx("code",{children:e.validationReportSha256.slice(0,16)})})]})]}),o.jsx("p",{children:e.verified?"源码由服务端从已验证交付物物化,浏览器文件不能替换。":"源码已由服务端安全物化,部署前请确认 Runtime 配置。"})]})})}const lRt="_Container_1tuad_1",cRt="_Checkbox_1tuad_22",uRt="_CheckMark_1tuad_92",dRt="_Label_1tuad_162",m_={Container:lRt,Checkbox:cRt,CheckMark:uRt,Label:dRt},jU=({className:e,label:t,id:n,disabled:r,orientation:i="left",...s})=>{const a=p.useId(),l=n??a;return o.jsxs("div",{"data-disabled":r?"":void 0,"data-has-label":t?"":void 0,"data-orientation":i,className:sr(e,m_.Container),children:[o.jsx(o3e,{className:m_.Checkbox,id:l,disabled:r,...s,children:o.jsx(c3e,{className:m_.CheckMark})}),t&&o.jsx("label",{htmlFor:l,className:m_.Label,onMouseDown:c=>{!c.defaultPrevented&&c.detail>1&&c.preventDefault()},children:t})]})};function fRt({className:e,...t}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...t,children:[o.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),o.jsx("path",{d:"M12 6.5c.4 2.4 1 3 3.4 3.4-2.4.4-3 1-3.4 3.4-.4-2.4-1-3-3.4-3.4 2.4-.4 3-1 3.4-3.4Z"})]})}const Sb={llm:{id:"llm",label:"LLM 智能体",desc:"大模型驱动,自主完成任务",icon:fRt},sequential:{id:"sequential",label:"顺序型智能体",desc:"子 Agent 按顺序依次执行",icon:ZRe},parallel:{id:"parallel",label:"并行型智能体",desc:"子 Agent 并行执行后汇总",icon:cIe},loop:{id:"loop",label:"循环型智能体",desc:"子 Agent 循环执行到满足条件",icon:Fae},a2a:{id:"a2a",label:"远程智能体",desc:"通过 A2A 协议调用远程 Agent",icon:RN}},hRt=[Sb.llm,Sb.sequential,Sb.parallel,Sb.loop,Sb.a2a];function Rwe(e){return Sb[e??"llm"]}const Iwe=e=>e==="sequential"||e==="parallel"||e==="loop",TR=e=>e==="a2a";function Cg(e,t){const n=e.trim().toLocaleLowerCase();return n?t.some(r=>r==null?void 0:r.toLocaleLowerCase().includes(n)):!0}const Dwe=new Set(["local","sqlite","mysql","postgresql"]),Pwe=new Set(["local","opensearch","redis","viking","openviking","mem0"]),Mwe=new Set(["opensearch","viking","context_search","openviking"]),Lwe=new Set(["apmplus","cozeloop","tls"]),$we=new Set(["web_search","parallel_web_search","link_reader","web_scraper","image_generate","image_edit","video_generate","text_to_speech","run_code","vesearch"]),pRt=new Set(["llm","sequential","parallel","loop","a2a"]),mRt=new Set(["lark-cli","github-cli","pandoc"]),gRt=new Set(["default","ops"]);function bn(e,t=""){return typeof e=="string"?e:t}function Fo(e){return e===!0}function bRt(e){return typeof e=="string"&&gRt.has(e)?e:"default"}function Dy(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function yRt(e){return Array.from(new Set(Dy(e).filter(t=>mRt.has(t))))}function ORt(e){return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"))}function Bwe(e){return Array.isArray(e)?e.map(t=>t&&typeof t=="object"?{name:bn(t.name),description:bn(t.description)}:null).filter(t=>!!t&&!!t.name.trim()):[]}function Py(e,t,n){return typeof e=="string"&&t.has(e)?e:n}function Qwe(e){return typeof e=="string"&&pRt.has(e)?e:"llm"}function Uwe(e){return e==="byteplus"?"byteplus":"volcengine"}function Fwe(e){return typeof e=="number"&&Number.isFinite(e)&&e>0?Math.floor(e):3}function zwe(e){const t=e&&typeof e=="object"?e:{};return{enabled:Fo(t.enabled),registrySpaceId:bn(t.registrySpaceId),registryTopK:bn(t.registryTopK),registryRegion:bn(t.registryRegion),registryEndpoint:bn(t.registryEndpoint)}}function xRt(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n=t.componentOverrides&&typeof t.componentOverrides=="object"?t.componentOverrides:{},r=Object.fromEntries(tO.map(l=>[l,n[l]===!0])),i={enabled:Object.values(r).some(Boolean),profile:bRt(t.profile),componentOverrides:r},s=bn(t.catalogVersion).trim(),a=bn(t.planHash).trim();return s&&(i.catalogVersion=s),a&&(i.planHash=a),z7(i)}function Vwe(e,t="volcengine"){return Array.isArray(e)?e.map(n=>{const r=n&&typeof n=="object"?n:{},i=Uwe(r.cloudProvider??t),s=r.memory&&typeof r.memory=="object"?r.memory:{},a=zwe(r.a2aRegistry),l=Qwe(r.agentType),c=a.enabled&&l==="llm"?"a2a":l;return{...Bl(i),cloudProvider:i,name:bn(r.name),description:bn(r.description),instruction:bn(r.instruction),agentType:c,maxIterations:Fwe(r.maxIterations),a2aUrl:bn(r.a2aUrl),modelName:bn(r.modelName),modelSource:r.modelSource==="custom"||r.modelSource==="ark"?r.modelSource:void 0,modelProvider:bn(r.modelProvider),modelApiBase:bn(r.modelApiBase),builtinTools:Dy(r.builtinTools).filter(u=>$we.has(u)),customTools:Bwe(r.customTools),memory:{shortTerm:Fo(s.shortTerm),longTerm:Fo(s.longTerm)},shortTermBackend:Py(r.shortTermBackend,Dwe,"local"),longTermBackend:Py(r.longTermBackend,Pwe,"local"),longTermMemoryIndex:bn(r.longTermMemoryIndex),autoSaveSession:Fo(r.autoSaveSession),knowledgebase:Fo(r.knowledgebase),knowledgebaseBackend:Py(r.knowledgebaseBackend,Mwe,jp),knowledgebaseIndex:bn(r.knowledgebaseIndex),tracing:Fo(r.tracing),tracingExporters:Dy(r.tracingExporters).filter(u=>Lwe.has(u)),a2aRegistry:c==="a2a"?{...a,enabled:!0}:a,subAgents:Vwe(r.subAgents,i),selectedSkills:Hwe(r)}}):[]}function Hwe(e){if(!Array.isArray(e.selectedSkills))return[];const t=[];for(const n of e.selectedSkills){const r=n&&typeof n=="object"?n:{},i=bn(r.source),s=i==="local"||i==="skillspace"||i==="skillhub"||i==="runtime"?i:"skillhub",a=bn(r.name)||bn(r.slug)||bn(r.skillName)||bn(r.skillId)||"skill",l=bn(r.folder)||a,c=bn(r.description);if(s==="runtime"){if(l!==a)continue;t.push({source:s,folder:l,name:a,description:c});continue}if(s==="skillhub"){const f=bn(r.slug);if(!f)continue;t.push({source:s,folder:l,name:a,description:c,slug:f,namespace:bn(r.namespace)||"public"});continue}if(s==="local"){const h=(Array.isArray(r.localFiles)?r.localFiles:[]).map(m=>{const g=m&&typeof m=="object"?m:{},b=bn(g.path),y=bn(g.content);return b?{path:b,content:y}:null}).filter(m=>m!==null);if(h.length===0)continue;t.push({source:s,folder:l,name:a,description:c,localFiles:h});continue}const u=bn(r.skillSpaceId),d=bn(r.skillId);!u||!d||t.push({source:s,folder:l,name:a,description:c,skillSpaceId:u,skillSpaceName:bn(r.skillSpaceName),skillId:d,version:bn(r.version)})}return t}function vRt(e){const t=e&&typeof e=="object"?e:{},n=t.memory&&typeof t.memory=="object"?t.memory:{},r=t.deployment&&typeof t.deployment=="object"?t.deployment:{},i=ORt(r.envValues),s=t.cloudEnvironment&&typeof t.cloudEnvironment=="object"?t.cloudEnvironment:{},a=zwe(t.a2aRegistry),l=Qwe(t.agentType),c=a.enabled&&l==="llm"?"a2a":l,u=Uwe(t.cloudProvider),d=Array.isArray(t.mcpTools)?t.mcpTools.map(f=>{const h=f&&typeof f=="object"?f:{},m=h.transport==="stdio"?"stdio":"http";return{name:bn(h.name),transport:m,url:bn(h.url),authToken:bn(h.authToken),authTokenEnv:bn(h.authTokenEnv),credentialConfigured:h.credentialConfigured===!0,command:bn(h.command),args:Dy(h.args)}}).filter(f=>f.transport==="http"?!!f.url:!!f.command):[];return{...Bl(u),cloudProvider:u,name:bn(t.name)||"my_agent",description:bn(t.description),instruction:bn(t.instruction)||"You are a helpful assistant.",dynamicAgentDelegation:Fo(t.dynamicAgentDelegation),agentType:c,maxIterations:Fwe(t.maxIterations),a2aUrl:bn(t.a2aUrl),modelName:bn(t.modelName),modelSource:t.modelSource==="custom"||t.modelSource==="ark"?t.modelSource:void 0,modelProvider:bn(t.modelProvider),modelApiBase:bn(t.modelApiBase),builtinTools:Dy(t.builtinTools).filter(f=>$we.has(f)),customTools:Bwe(t.customTools),mcpTools:d,a2aRegistry:c==="a2a"?{...a,enabled:!0}:a,memory:{shortTerm:Fo(n.shortTerm),longTerm:Fo(n.longTerm)},shortTermBackend:Py(t.shortTermBackend,Dwe,"local"),longTermBackend:Py(t.longTermBackend,Pwe,"local"),longTermMemoryIndex:bn(t.longTermMemoryIndex),autoSaveSession:Fo(t.autoSaveSession),knowledgebase:Fo(t.knowledgebase),knowledgebaseBackend:Py(t.knowledgebaseBackend,Mwe,jp),knowledgebaseIndex:bn(t.knowledgebaseIndex),tracing:Fo(t.tracing),tracingExporters:Dy(t.tracingExporters).filter(f=>Lwe.has(f)),deployment:{feishuEnabled:Fo(r.feishuEnabled),runtimeName:bn(r.runtimeName),runtimeNameCustomized:Fo(r.runtimeNameCustomized)||!!bn(r.runtimeName).trim(),modelApiKeyId:bn(r.modelApiKeyId),modelApiKeyName:bn(r.modelApiKeyName),...Object.keys(i).length>0?{envValues:i}:{}},cloudEnvironment:{environmentId:bn(s.environmentId),environmentVersionId:bn(s.environmentVersionId),cliTools:yRt(s.cliTools),...typeof s.dockerfile=="string"?{dockerfile:s.dockerfile}:{}},harnessSidecar:xRt(t.harnessSidecar),subAgents:Vwe(t.subAgents,u),selectedSkills:Hwe(t)}}function qwe(e,t=e.cloudProvider??"volcengine"){const n=e.cloudProvider??t,r=new Set(phe(n).map(i=>i.id));return{...e,builtinTools:(e.builtinTools??[]).filter(i=>r.has(i)),tracing:!1,tracingExporters:[],memory:{shortTerm:!1,longTerm:!1},shortTermBackend:"local",longTermBackend:"local",longTermMemoryIndex:"",autoSaveSession:!1,knowledgebase:!1,knowledgebaseBackend:jp,knowledgebaseIndex:"",subAgents:e.subAgents.map(i=>qwe(i,n))}}const wRt=/^[A-Za-z_][A-Za-z0-9_]*$/,CR=/^\$\{([A-Za-z_][A-Za-z0-9_]*)\}$/;function Lee(e,t){return e.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"")||t}function SRt(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}_${n}`);)n+=1;return`${e}_${n}`}function _O(e){var n,r,i;const t=(n=e.authTokenEnv)==null?void 0:n.trim();return t&&wRt.test(t)?t:((i=(r=e.authToken)==null?void 0:r.trim().match(CR))==null?void 0:i[1])??""}function WA(e,t){var n;for(const r of e.mcpTools??[])t(r);for(const r of e.subAgents)WA(r,t);for(const r of((n=e.workflow)==null?void 0:n.nodes)??[])WA(r.agent,t)}function ERt(e){const t=new Set;return WA(e,n=>{const r=_O(n);n.credentialConfigured&&r&&t.add(r)}),[...t]}function Xwe(e){const t=new Set;return WA(e,n=>{const r=_O(n);r&&t.add(r)}),[...t]}function kRt(e,t){const n=new Set(Xwe(t));return[...new Set(e)].filter(r=>!n.has(r))}function _Rt(e){if(e.credentialUpdate==="pending")return"";if(e.authToken)return e.authToken;if(e.credentialConfigured)return"";const t=_O(e);return t?`\${${t}}`:""}function TRt(e,t){if(!t){if(e.authToken){const i={...e,credentialConfigured:!1};return delete i.authToken,delete i.authTokenEnv,i}if(e.credentialConfigured){const i={...e};return delete i.authToken,i}const r={...e};return delete r.authToken,delete r.authTokenEnv,r}const n=t.trim().match(CR);if(n){const r={...e,authTokenEnv:n[1],credentialConfigured:e.credentialConfigured&&_O(e)===n[1],...e.credentialSourceUrl?{credentialUpdate:"replace"}:{}};return delete r.authToken,r}return{...e,authToken:t,credentialConfigured:!1,...e.credentialSourceUrl?{credentialUpdate:"replace"}:{}}}function CRt(e){const t={...e,credentialConfigured:!1};return delete t.authToken,delete t.authTokenEnv,t}function ARt(e){if(!e.trim())return!1;try{return!new URL(e).pathname.replace(/\/+$/,"").endsWith("/mcp")}catch{return!1}}function $ee(e){return(e??"").trim().replace(/\/+$/,"")}function Gwe(e){return e.credentialUpdate==="pending"}function NRt(e,t){var s;const n=e.credentialSourceUrl??(e.credentialConfigured?((s=e.url)==null?void 0:s.trim())??"":""),r=e.credentialSourceAuthTokenEnv??(e.credentialConfigured?_O(e):"");if(!n||!r)return{...e,url:t};if($ee(t)===$ee(n)){const a={...e,url:t,authTokenEnv:r,credentialConfigured:!0,credentialSourceUrl:n,credentialSourceAuthTokenEnv:r};return delete a.authToken,delete a.credentialUpdate,a}const i={...e,url:t,authTokenEnv:r,credentialConfigured:!1,credentialSourceUrl:n,credentialSourceAuthTokenEnv:r,credentialUpdate:"pending"};return delete i.authToken,i}function jRt(e){return e.credentialSourceAuthTokenEnv?{...e,authTokenEnv:e.credentialSourceAuthTokenEnv,credentialConfigured:!1,credentialUpdate:"reuse"}:e}function r$(e){const t={...e,credentialConfigured:!1,credentialUpdate:"replace"};return delete t.authToken,delete t.authTokenEnv,t}function RRt(e){const t=r$(e);return t.credentialUpdate="remove",t}function IRt(e){const t=ZE(e),n={},r=a=>{var l,c;Object.assign(n,((l=a.deployment)==null?void 0:l.envValues)??{}),a.subAgents.forEach(r),(c=a.workflow)==null||c.nodes.forEach(u=>r(u.agent))};r(e),Object.assign(n,t.envValues);const i=[],s=a=>{var l,c,u;for(const d of a.mcpTools??[]){const f=((l=d.authTokenEnv)==null?void 0:l.trim())??"",h=f?(n[f]??"").trim():"";d.transport!=="http"||!h||i.push({agentName:a.name.trim(),name:d.name.trim(),url:((c=d.url)==null?void 0:c.trim())??"",value:h})}a.subAgents.forEach(s),(u=a.workflow)==null||u.nodes.forEach(d=>s(d.agent))};return s(t.draft),i}function DRt(e){const t=[],n=r=>{var i,s,a;for(const l of r.mcpTools??[]){const c=((i=l.authToken)==null?void 0:i.trim())??"";l.transport!=="http"||!c||CR.test(c)||t.push({agentName:r.name.trim(),name:l.name.trim(),url:((s=l.url)==null?void 0:s.trim())??"",value:c})}r.subAgents.forEach(n),(a=r.workflow)==null||a.nodes.forEach(l=>n(l.agent))};return n(e),t}function PRt(e){const t=[],n=r=>{var i,s,a;for(const l of r.mcpTools??[]){const c=((i=l.credentialSourceAuthTokenEnv)==null?void 0:i.trim())??"";l.transport==="http"&&l.credentialUpdate==="reuse"&&c&&t.push({agentName:r.name.trim(),name:l.name.trim(),url:((s=l.url)==null?void 0:s.trim())??"",sourceAuthTokenEnv:c})}r.subAgents.forEach(n),(a=r.workflow)==null||a.nodes.forEach(l=>n(l.agent))};return n(e),t}function ZE(e){const t=new Set,n={},r=i=>{var u;const s=Lee(i.name,"AGENT"),a=(u=i.mcpTools)==null?void 0:u.map((d,f)=>{var O,v;const h=((O=d.authToken)==null?void 0:O.trim())??"",m=((v=h.match(CR))==null?void 0:v[1])??"";let b=_O(d);if(!b&&h){const x=Lee(d.name,`TOOL_${f+1}`);b=SRt(`MCP_${s}_${x}_AUTH_TOKEN`,t)}b&&t.add(b),b&&h&&!m&&(n[b]=h);const y={...d};return delete y.authToken,delete y.credentialConfigured,delete y.credentialSourceUrl,delete y.credentialSourceAuthTokenEnv,delete y.credentialUpdate,b?y.authTokenEnv=b:delete y.authTokenEnv,y}),l=i.subAgents.map(r),c=i.workflow?{...i.workflow,nodes:i.workflow.nodes.map(d=>({...d,agent:r(d.agent)}))}:void 0;return{...i,subAgents:l,...a?{mcpTools:a}:{},...c?{workflow:c}:{}}};return{draft:r(e),envValues:n}}function Wwe(e,t=!0){var r,i,s,a,l,c,u,d,f,h,m,g,b,y,O,v,x,w,S,E,k,_,T,C,A,R,M,I,$,N,j,B,F,L,H,z,Q,V,K,se,ge,ie,q,G;const n={agentType:e.agentType??"llm"};if(e.agentType==="a2a"){if((r=e.a2aRegistry)!=null&&r.enabled){const J=wj(e.cloudProvider??"volcengine"),ue={enabled:!0};(i=e.a2aRegistry.registrySpaceId)!=null&&i.trim()&&(ue.registrySpaceId=e.a2aRegistry.registrySpaceId.trim()),ue.registryTopK=((s=e.a2aRegistry.registryTopK)==null?void 0:s.trim())||J.topK,ue.registryRegion=((a=e.a2aRegistry.registryRegion)==null?void 0:a.trim())||J.region,ue.registryEndpoint=((l=e.a2aRegistry.registryEndpoint)==null?void 0:l.trim())||J.endpoint,n.a2aRegistry=ue}return n}if(n.name=e.name,n.description=e.description,n.instruction=e.instruction,e.agentType==="loop"&&(n.maxIterations=e.maxIterations??3),(c=e.modelName)!=null&&c.trim()&&(n.modelName=e.modelName.trim()),e.modelSource&&(n.modelSource=e.modelSource),e.modelSource!=="ark"&&((u=e.modelProvider)!=null&&u.trim()&&(n.modelProvider=e.modelProvider.trim()),(d=e.modelApiBase)!=null&&d.trim()&&(n.modelApiBase=e.modelApiBase.trim())),(f=e.builtinTools)!=null&&f.length&&(n.builtinTools=[...e.builtinTools]),(h=e.customTools)!=null&&h.length&&(n.customTools=e.customTools.map(J=>({name:J.name,description:J.description}))),(m=e.mcpTools)!=null&&m.length&&(n.mcpTools=e.mcpTools.map(J=>{var Oe,Qe,je,ze;const ue={name:J.name,transport:J.transport};return(Oe=J.url)!=null&&Oe.trim()&&(ue.url=J.url.trim()),(Qe=J.authTokenEnv)!=null&&Qe.trim()&&(ue.authTokenEnv=J.authTokenEnv.trim()),(je=J.command)!=null&&je.trim()&&(ue.command=J.command.trim()),(ze=J.args)!=null&&ze.length&&(ue.args=J.args),ue})),((g=e.memory)!=null&&g.shortTerm||(b=e.memory)!=null&&b.longTerm)&&(n.memory={shortTerm:!!e.memory.shortTerm,longTerm:!!e.memory.longTerm},e.memory.shortTerm&&(n.shortTermBackend=e.shortTermBackend||"local"),e.memory.longTerm&&(n.longTermBackend=e.longTermBackend||"local",(y=e.longTermMemoryIndex)!=null&&y.trim()&&(n.longTermMemoryIndex=e.longTermMemoryIndex.trim()),n.autoSaveSession=!!e.autoSaveSession)),e.knowledgebase&&(n.knowledgebase=!0,n.knowledgebaseBackend=e.knowledgebaseBackend||"viking",(O=e.knowledgebaseIndex)!=null&&O.trim()&&(n.knowledgebaseIndex=e.knowledgebaseIndex.trim())),e.tracing&&((v=e.tracingExporters)!=null&&v.length)&&(n.tracing=!0,n.tracingExporters=[...e.tracingExporters]),t&&((x=e.harnessSidecar)!=null&&x.enabled)&&(n.harnessSidecar={enabled:!0,profile:e.harnessSidecar.profile,componentOverrides:{...e.harnessSidecar.componentOverrides}}),((w=e.cloudEnvironment)!=null&&w.environmentId||(S=e.cloudEnvironment)!=null&&S.environmentVersionId||(k=(E=e.cloudEnvironment)==null?void 0:E.cliTools)!=null&&k.length||((_=e.cloudEnvironment)==null?void 0:_.dockerfile)!==void 0)&&(n.cloudEnvironment={environmentId:e.cloudEnvironment.environmentId,environmentVersionId:e.cloudEnvironment.environmentVersionId,...(T=e.cloudEnvironment.cliTools)!=null&&T.length?{cliTools:[...e.cloudEnvironment.cliTools]}:{},...e.cloudEnvironment.dockerfile!==void 0?{dockerfile:e.cloudEnvironment.dockerfile}:{}}),(C=e.deployment)!=null&&C.feishuEnabled||(R=(A=e.deployment)==null?void 0:A.runtimeName)!=null&&R.trim()||(M=e.deployment)!=null&&M.runtimeNameCustomized||($=(I=e.deployment)==null?void 0:I.modelApiKeyId)!=null&&$.trim()||(j=(N=e.deployment)==null?void 0:N.modelApiKeyName)!=null&&j.trim()||Object.keys(((B=e.deployment)==null?void 0:B.envValues)??{}).length>0){const J={feishuEnabled:!!((F=e.deployment)!=null&&F.feishuEnabled)};(H=(L=e.deployment)==null?void 0:L.runtimeName)!=null&&H.trim()&&(J.runtimeName=e.deployment.runtimeName.trim()),(z=e.deployment)!=null&&z.runtimeNameCustomized&&(J.runtimeNameCustomized=!0),(V=(Q=e.deployment)==null?void 0:Q.modelApiKeyId)!=null&&V.trim()&&(J.modelApiKeyId=e.deployment.modelApiKeyId.trim()),(se=(K=e.deployment)==null?void 0:K.modelApiKeyName)!=null&&se.trim()&&(J.modelApiKeyName=e.deployment.modelApiKeyName.trim()),Object.keys(((ge=e.deployment)==null?void 0:ge.envValues)??{}).length>0&&(J.envValues={...(ie=e.deployment)==null?void 0:ie.envValues}),n.deployment=J}return(q=e.selectedSkills)!=null&&q.length&&(n.selectedSkills=e.selectedSkills.map(J=>{const ue={source:J.source,name:J.name,folder:J.folder};return J.description&&(ue.description=J.description),J.source==="skillhub"?(ue.slug=J.slug,ue.namespace=J.namespace??"public"):J.source==="local"?ue.localFiles=J.localFiles??[]:J.source==="skillspace"&&(ue.skillSpaceId=J.skillSpaceId,ue.skillSpaceName=J.skillSpaceName,ue.skillId=J.skillId,J.version&&(ue.version=J.version)),ue})),(G=e.subAgents)!=null&&G.length&&(n.subAgents=e.subAgents.map(J=>Wwe(J,!1))),n}function MRt(e){var i;const t=ZE(e),n={...((i=t.draft.deployment)==null?void 0:i.envValues)??{},...t.envValues},r={...t.draft,deployment:{...t.draft.deployment??{feishuEnabled:!1},envValues:n}};return`# VeADK Agent 结构配置
# 可在「创建 Agent」页通过「导入 YAML」重新载入。
-`+iQ(Wwe(r))}const LRt={missing_http_tool:"请返回“添加 MCP 工具”并添加至少一个 HTTP MCP 服务;MCP 稳定性治理不支持 stdio 服务。",missing_url:"已添加的 HTTP MCP 工具缺少有效服务地址,请返回“添加 MCP 工具”补充后再发布。"};function Bee(e){return{ok:!1,reason:e,message:LRt[e]}}function $Rt(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function BRt(e){var a;const t=[],n=new Set,r=l=>{var c;n.has(l)||(n.add(l),t.push(l),l.subAgents.forEach(r),(c=l.workflow)==null||c.nodes.forEach(u=>r(u.agent)))};r(e);const i=t.flatMap(l=>(l.mcpTools??[]).filter(c=>c.transport==="http"));if(i.length===0)return Bee("missing_http_tool");const s=[];for(const l of i){const c=((a=l.url)==null?void 0:a.trim())??"";if(!c||!$Rt(c))return Bee("missing_url");s.push(c)}return{ok:!0,urls:s}}const i$="__default_environment__",QRt={value:i$,label:"默认环境",description:"使用部署 Runtime 的默认基础镜像"};function URt(e){const t=e instanceof Error?e.message:String(e);return t.includes("HTTP 503")&&t.includes("管理员未配置持久化存储")}const FRt={preparing:"准备中",queued:"排队中",building:"构建中",scanning:"扫描中",available:"可用",failed:"构建失败"};function Qee(e){return e.latestVersion?FRt[e.latestVersion.status]:"未构建"}function zRt(e){var t,n;return((t=e.latestVersion)==null?void 0:t.status)==="available"?"success":((n=e.latestVersion)==null?void 0:n.status)==="failed"?"danger":e.latestVersion?"warning":"secondary"}function Ywe({value:e,onChange:t,disabled:n=!1,controlSize:r="lg",controlClassName:i,optionClassName:s}){var k,_;const a=p.useId(),l=p.useRef(t),[c,u]=p.useState([]),[d,f]=p.useState(!0),[h,m]=p.useState(""),[g,b]=p.useState(!1),[y,O]=p.useState(0);p.useEffect(()=>{l.current=t},[t]),p.useEffect(()=>{const T=new AbortController;return f(!0),m(""),b(!1),ZS(T.signal).then(C=>{T.signal.aborted||u(C)}).catch(C=>{!T.signal.aborted&&(C==null?void 0:C.name)!=="AbortError"&&(URt(C)?(u([]),b(!0),l.current({environmentId:"",environmentVersionId:""})):m(C instanceof Error?C.message:String(C)))}).finally(()=>{T.signal.aborted||f(!1)}),()=>T.abort()},[y]);const v=p.useMemo(()=>[QRt,...c.map(T=>{var C;return{value:T.id,label:T.name,description:`${H4(T.operatingSystem)} · ${Qf(T.language)} · ${Qee(T)}`,disabled:((C=T.latestVersion)==null?void 0:C.status)!=="available",environment:T}})],[c]),x=c.find(T=>T.id===e.environmentId),w=((k=x==null?void 0:x.latestVersion)==null?void 0:k.versionId)===e.environmentVersionId?x.latestVersion:null,S=x?q7.flatMap(T=>T.options).filter(T=>x.optionIds.includes(T.id)).map(T=>T.label):[],E=T=>{var A;if(T.value===i$||!T.environment){t({environmentId:"",environmentVersionId:""});return}const C=((A=T.environment.latestVersion)==null?void 0:A.versionId)??"";t({environmentId:T.value,environmentVersionId:C})};return d&&c.length===0?o.jsx("div",{className:"cloud-env-state",role:"status",children:o.jsx(wn,{duration:1.25,children:"正在加载环境..."})}):h&&c.length===0?o.jsxs("div",{className:"cloud-env-state cloud-env-state--error",role:"alert",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"环境加载失败"}),o.jsx("p",{children:h})]}),o.jsx(jt,{color:"secondary",variant:"soft",size:"sm",onClick:()=>O(T=>T+1),children:"重试"})]}):o.jsxs("section",{className:"cloud-env-config","aria-labelledby":`${a}-title`,children:[o.jsxs("label",{className:"cloud-env-field",id:`${a}-title`,htmlFor:a,children:[o.jsx("span",{children:"环境"}),o.jsx(Wo,{id:a,value:e.environmentId||i$,options:v,size:r,triggerClassName:i,optionClassName:s,pill:!1,disabled:n,placeholder:"选择一个已构建的环境",searchPlaceholder:"搜索环境",searchEmptyMessage:"没有匹配的环境",onChange:E}),o.jsx("small",{children:"仅可选择构建状态为“可用”的环境,部署时会固定到当前镜像版本。"})]}),x?o.jsxs("div",{className:"cloud-env-summary","aria-live":"polite",children:[o.jsxs("div",{className:"cloud-env-summary__head",children:[o.jsxs("div",{children:[o.jsx("strong",{children:x.name}),x.description?o.jsx("p",{children:x.description}):null]}),o.jsx(sa,{color:zRt(x),variant:"soft",size:"sm",children:Qee(x)})]}),o.jsxs("dl",{className:"cloud-env-details",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"操作系统"}),o.jsx("dd",{children:H4(x.operatingSystem)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"语言"}),o.jsx("dd",{children:Qf(x.language)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"工具"}),o.jsx("dd",{children:S.length?S.join("、"):"无额外工具"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"技能"}),o.jsx("dd",{children:(_=x.selectedSkills)!=null&&_.length?x.selectedSkills.map(T=>T.name).join("、"):"无环境技能"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"镜像版本"}),o.jsx("dd",{children:(w==null?void 0:w.versionId)||e.environmentVersionId||"不可用"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"镜像"}),o.jsx("dd",{title:(w==null?void 0:w.image)||"",children:(w==null?void 0:w.image)||"当前固定版本已不在列表中,请重新选择环境"})]})]}),w?null:o.jsx("p",{className:"cloud-env-version-warning",role:"alert",children:"此环境的可用版本已变化,请重新选择后再发布。"})]}):e.environmentId?o.jsx("div",{className:"cloud-env-version-warning",role:"alert",children:"已选择的环境不存在或无权访问,请重新选择。"}):o.jsx("p",{className:`cloud-env-guidance ${g?"cloud-env-guidance--fallback":""}`,children:g?"管理员未配置持久化存储,将使用部署 Runtime 时的默认基础镜像。":c.length===0?"暂无自定义环境,将使用部署 Runtime 的默认基础镜像。":"当前使用 AgentKit 默认运行环境;选择自定义环境后,会基于对应镜像构建并加载环境技能。"})]})}const Sf="new-agent-workbench__select-option";function VRt({label:e,metadata:t}){return o.jsx("span",{className:"new-agent-workbench__model-option-view",children:o.jsxs("span",{className:"new-agent-workbench__model-option-copy",children:[o.jsx("span",{className:"new-agent-workbench__model-option-label",children:e}),t?o.jsx("span",{className:"new-agent-workbench__model-option-metadata",children:t}):null]})})}function HRt(e,t){var r,i;const n=t.trim().toLocaleLowerCase();return n?[e.label,e.metadata,(r=e.model)==null?void 0:r.name,(i=e.model)==null?void 0:i.vendorName].some(s=>s==null?void 0:s.toLocaleLowerCase().includes(n)):!0}const qRt=["local","sqlite","mysql","postgresql"];function Uee(e){return qRt.includes(e)}function XRt(e){return e==="local"?"in-memory":"persistent"}const g_=[{id:"agent",label:"智能体",title:"基本信息",description:"设置智能体的名称、用途、行为方式与能力"},{id:"environment",label:"执行环境",title:"配置执行环境",description:"选择默认环境或已构建的自定义环境"},{id:"deployment",label:"部署偏好",title:"部署偏好",description:"定义 AgentKit 云上参数"}];function GRt({cloudProvider:e,source:t,value:n,apiKeyId:r,apiKeyName:i,provider:s,apiBase:a,customApiKey:l,onSourceChange:c,onApiKeyChange:u,onModelNameChange:d,onProviderChange:f,onApiBaseChange:h,onCustomApiKeyChange:m,onLoadingChange:g}){const[b,y]=p.useState([]),[O,v]=p.useState([]),[x,w]=p.useState(!0),[S,E]=p.useState(!1),[k,_]=p.useState(null),[T,C]=p.useState("");p.useEffect(()=>{const I=new AbortController;if(t==="ark")return w(!0),C(""),f9(I.signal).then($=>{if(I.signal.aborted)return;y($.keys);const N=$.keys.find(j=>j.id===r)??$.keys.find(j=>j.name===i)??$.keys.find(j=>j.id===$.defaultKeyId)??$.keys[0];N&&N.id!==r&&u(N)}).catch($=>{I.signal.aborted||C($ instanceof Error?$.message:"模型凭据加载失败")}).finally(()=>{I.signal.aborted||w(!1)}),()=>I.abort()},[r,i,e,u,t]),p.useEffect(()=>{if(t!=="ark"||!r){v([]),E(!1),_(null);return}const I=new AbortController;return E(!0),_(null),C(""),Q1({apiKeyId:r,signal:I.signal}).then($=>{I.signal.aborted||v($.models)}).catch($=>{I.signal.aborted||C($ instanceof Error?$.message:"模型列表加载失败")}).finally(()=>{I.signal.aborted||(E(!1),_(r))}),()=>I.abort()},[r,e,t]),p.useEffect(()=>{g(t==="ark"&&(x||!!r&&(S||k!==r)))},[r,k,x,S,g,t]);const A=[{value:"ark",label:e==="byteplus"?"BytePlus ModelArk":"火山方舟"},{value:"custom",label:"自定义"},{value:"gateway",label:"模型网关",description:"待上线",disabled:!0}],R=b.map(I=>({value:I.id,label:I.name}));r&&!R.some(I=>I.value===r)&&R.unshift({value:r,label:i||"当前 API Key"});const M=p.useMemo(()=>{const I=O.filter($=>$.available||$.lifecycleStatus==="Retiring").map($=>({value:$.id,label:$.displayName||$.name||$.id,metadata:$.vendorName?`${$.id} | ${$.vendorName}`:$.id,model:$}));return n&&!I.some($=>$.value===n)&&I.unshift({value:n,label:n,metadata:n}),I},[O,n]);return o.jsxs("div",{className:"new-agent-workbench__model-group",children:[o.jsx("span",{className:"new-agent-workbench__model-group-label",children:"模型"}),o.jsxs("div",{className:"new-agent-workbench__model-fields",children:[o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"模型来源"}),o.jsx(Wo,{value:t,options:A,size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,onChange:I=>c(I.value)})]}),t==="ark"?o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsxs("span",{className:"new-agent-workbench__model-field-label",children:["API Key",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Wo,{value:r??"",options:R,loading:x,loadingPlaceholder:"正在加载 API Key",placeholder:"选择 API Key",searchPlaceholder:"搜索 API Key 名称",searchEmptyMessage:"暂无可用 API Key",size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,onChange:I=>{const $=b.find(N=>N.id===I.value);$&&(g(!0),u($))}})]}),o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsxs("span",{className:"new-agent-workbench__model-field-label",children:["模型",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Wo,{value:n,options:M,loading:S,loadingPlaceholder:"正在加载模型",placeholder:"选择模型",searchPlaceholder:"搜索名称、Model ID 或服务商",searchEmptyMessage:"没有可用的模型",size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:`${Sf} new-agent-workbench__model-option`,OptionView:VRt,searchPredicate:HRt,pill:!1,disabled:!r,onChange:I=>d(I.value)})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsxs("span",{className:"new-agent-workbench__model-field-label",children:["模型名称",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Ui,{value:n,size:"xl",gutterSize:"md",pill:!1,onChange:I=>d(I.currentTarget.value)})]}),o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"服务商 Provider"}),o.jsx(Ui,{value:s,placeholder:"openai",size:"xl",gutterSize:"md",pill:!1,onChange:I=>f(I.currentTarget.value)})]}),o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"API Base"}),o.jsx(Ui,{value:a,placeholder:nl(e),size:"xl",gutterSize:"md",pill:!1,onChange:I=>h(I.currentTarget.value)})]}),o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsxs("span",{className:"new-agent-workbench__model-field-label",children:["API Key",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Ui,{type:"password",value:l,placeholder:"请输入模型 API Key",autoComplete:"new-password",size:"xl",gutterSize:"md",pill:!1,onChange:I=>m(I.currentTarget.value)})]})]}),T?o.jsx("p",{className:"new-agent-workbench__error",role:"alert",children:T}):null]})]})}function WRt({value:e,disabled:t,onChange:n}){const[r,i]=p.useState([]),[s,a]=p.useState(!0),[l,c]=p.useState(""),[u,d]=p.useState(0);p.useEffect(()=>{const m=new AbortController;return a(!0),c(""),BN(m.signal).then(g=>{m.signal.aborted||i(g)}).catch(g=>{!m.signal.aborted&&(g==null?void 0:g.name)!=="AbortError"&&(i([]),c(g instanceof Error?g.message:String(g)))}).finally(()=>{m.signal.aborted||a(!1)}),()=>m.abort()},[u]);const f=p.useMemo(()=>[...r].sort((m,g)=>Number(g.isCurrent)-Number(m.isCurrent)).map(m=>({value:m.uid,label:m.name.trim()||"未命名用户池",description:m.isCurrent?`${m.domain||m.uid}(当前用户池)`:m.domain||m.uid})),[r]),h=r.find(m=>m.uid===e);return o.jsxs("div",{className:"new-agent-workbench__field",children:[o.jsxs("span",{children:["用户池",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Wo,{value:e,options:f,loading:s,loadingPlaceholder:"正在加载用户池",placeholder:"请选择用户池",searchPlaceholder:"搜索用户池",searchEmptyMessage:"当前账号下暂无 Identity 用户池",size:"xl",pill:!1,disabled:t||!!l,triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,onChange:m=>n(m.value)}),l?o.jsxs("div",{className:"new-agent-workbench__inline-error",role:"alert",children:[o.jsx("span",{children:l}),o.jsx(jt,{color:"secondary",variant:"ghost",size:"sm",pill:!1,onClick:()=>d(m=>m+1),children:"重试"})]}):h!=null&&h.isCurrent?o.jsx("small",{className:"new-agent-workbench__helper-text",children:"当前 Studio 的登录 JWT 将透传访问此 Runtime"}):h?o.jsx("small",{className:"new-agent-workbench__error",children:"所选用户池不是当前 Studio 使用的用户池,部署后无法从 Studio 调用此 Runtime"}):o.jsx("small",{className:"new-agent-workbench__helper-text",children:"当前 Studio 使用的用户池已在列表中标注"})]})}function Fee({name:e,value:t,required:n=!1,placeholder:r,locked:i=!1,onRename:s,onValueChange:a,onRemove:l}){const[c,u]=p.useState(e);p.useEffect(()=>u(e),[e]);const d=()=>{const f=c.trim().toUpperCase();if(!f){u(e);return}u(f),f!==e&&s(e,f)};return o.jsxs("div",{className:`new-agent-workbench__env-row${i?" is-locked":""}`,role:"row",children:[o.jsx("div",{className:"new-agent-workbench__env-cell",role:"cell",children:o.jsx(Ui,{"aria-label":"环境变量名称",value:c,title:i?e:void 0,size:"xl",gutterSize:"md",pill:!1,disabled:i,onChange:f=>u(f.currentTarget.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}})}),o.jsx("div",{className:"new-agent-workbench__env-cell",role:"cell",children:o.jsx(Ui,{"aria-label":`${e} 的值`,value:t,size:"xl",gutterSize:"md",pill:!1,type:/(SECRET|PASSWORD|KEY|TOKEN)$/.test(e)?"password":"text",placeholder:r,required:n,onChange:f=>a(f.currentTarget.value)})}),o.jsx("div",{className:"new-agent-workbench__env-action",role:"cell",children:i?n?o.jsx("span",{className:"new-agent-workbench__required","aria-label":"必填",children:"*"}):null:o.jsx(jt,{color:"secondary",variant:"ghost",size:"lg",uniform:!0,pill:!1,"aria-label":`删除 ${e}`,onClick:l,children:o.jsx(CRe,{"aria-hidden":!0})})})]})}function YRt({draft:e,cloudProvider:t,deployRegion:n,runtimeName:r,isRuntimeUpdate:i=!1,deploying:s,deployStage:a,deployError:l,deploySucceeded:c,showErrors:u,onBack:d,onDraftPatch:f,onDeploymentPatch:h,onModelApiKeyChange:m,customModelApiKey:g,onCustomModelApiKeyChange:b,onSelectedSkillsChange:y,onCloudEnvironmentChange:O,onDeployRegionChange:v,onRuntimeNameChange:x,onNetworkChange:w,onDeploy:S}){var ve,He,pt,_t,It,Kt,en,le,Xt;const E=J8(),[k,_]=p.useState("agent"),[T,C]=p.useState(!1),A=p.useRef(null),[R,M]=p.useState(!1),[I,$]=p.useState(!1),[N,j]=p.useState(!0),[B,F]=p.useState("api_key"),[L,H]=p.useState(""),[z,Q]=p.useState(()=>{const Fe=e.shortTermBackend||"local";return e.memory.shortTerm&&Uee(Fe)?Fe:"local"}),V=XRt(z),[K,se]=p.useState("1"),[ge,ie]=p.useState(V==="in-memory"?"1":"5"),[q,G]=p.useState(!0),[J,ue]=p.useState(Lve),[Oe,Qe]=p.useState(""),[je,ze]=p.useState(null),[Ge,Ae]=p.useState({top:!1,bottom:!1}),Be=p.useRef(null),he=g_.findIndex(Fe=>Fe.id===k),be=g_[he],Se=C1(e.name),Ee=Se!==null,tt=!e.description.trim(),Ue=!e.instruction.trim(),re=am(e,t),ce=!((ve=e.modelName)!=null&&ve.trim()),Me=re==="ark"&&!((pt=(He=e.deployment)==null?void 0:He.modelApiKeyId)!=null&&pt.trim()),Ye=Ee||tt||Ue||ce||Me,Z=((It=(_t=e.deployment)==null?void 0:_t.network)==null?void 0:It.mode)??"public",_e=(Kt=e.deployment)==null?void 0:Kt.network,rt=Ed(t),Re=((en=e.deployment)==null?void 0:en.envValues)??{},We=by.find(Fe=>Fe.id===z)??by[0],ct=((We==null?void 0:We.env)??[]).filter(Fe=>!Fe.hidden),kt=new Set(ct.map(Fe=>Fe.key)),qt=Object.entries(Re).filter(([Fe])=>Fe!=="FEISHU_APP_ID"&&Fe!=="FEISHU_APP_SECRET"&&!kt.has(Fe)),Dt=(Fe,Pt)=>{h({envValues:{...Re,[Fe]:Pt}})},Xe=(Fe,Pt)=>{const Ce=Object.fromEntries(Object.entries(Re).map(([gt,Vt])=>gt===Fe?[Pt,Vt]:[gt,Vt]));h({envValues:Ce})},nt=Fe=>{const Pt={...Re};delete Pt[Fe],h({envValues:Pt})},ft=()=>{let Fe=qt.length+1,Pt=`CUSTOM_ENV_${Fe}`;for(;Pt in Re;)Pt=`CUSTOM_ENV_${++Fe}`;Dt(Pt,"")};p.useEffect(()=>{const Fe=Be.current;if(!Fe)return;const Pt=()=>{const ot={top:Fe.scrollTop>1,bottom:Fe.scrollTop+Fe.clientHeightln.top===ot.top&&ln.bottom===ot.bottom?ln:ot)};Fe.scrollTo({top:0,behavior:"auto"}),Fe.addEventListener("scroll",Pt,{passive:!0});const Ce=new ResizeObserver(Pt);Ce.observe(Fe);const gt=new MutationObserver(Pt);gt.observe(Fe,{childList:!0,subtree:!0});const Vt=window.requestAnimationFrame(Pt);return()=>{window.cancelAnimationFrame(Vt),Fe.removeEventListener("scroll",Pt),Ce.disconnect(),gt.disconnect()}},[k]),p.useEffect(()=>{se("1"),ie(V==="in-memory"?"1":"5")},[V]);const xt=()=>{if(he===0){if(T)return;if(E){d();return}A.current=d,C(!0);return}_(g_[he-1].id)},Ie=()=>{if(!T)return;const Fe=A.current;A.current=null,Fe==null||Fe()},xe=()=>{if(k==="agent"){if(M(!0),Ye)return;_("environment");return}if(k==="environment"){_("deployment");return}const Fe=Number(K),Pt=Number(ge);if(!Number.isSafeInteger(Fe)||Fe<1||!Number.isSafeInteger(Pt)||Pt<1){Qe("实例数必须为大于 0 的整数");return}if(Fe>Pt){Qe("最小实例数不能大于最大实例数");return}if(B==="user_pool"&&!L){Qe("请选择用于 Runtime 鉴权的用户池");return}const Ce=Bve(J);if(Ce){ze(Ce),Qe(Ce);return}ze(null),Qe(""),S({authentication:B==="user_pool"?{type:"user_pool",userPoolUid:L}:{type:"api_key"},sessionStorage:V,sessionBackend:z,minInstance:Fe,maxInstance:Pt,createEvaluationSets:t==="byteplus"?!1:q,resources:J})},$e=u||R,it=$e||I;return o.jsxs(ai.div,{className:`new-agent-workbench${T?" is-leaving":""}`,initial:E?!1:{opacity:0},animate:{opacity:T?0:1},transition:{duration:T?.12:.18,ease:[.16,1,.3,1]},onAnimationComplete:Ie,children:[o.jsx("main",{className:"new-agent-workbench__main","aria-label":"快速模式创建",children:o.jsxs("section",{className:"new-agent-workbench__form","aria-labelledby":"new-agent-workbench-title",children:[o.jsx(fu,{mode:"wait",initial:!1,children:o.jsxs(ai.div,{className:"new-agent-workbench__heading",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:[o.jsx("h1",{id:"new-agent-workbench-title",children:be.title}),o.jsx("p",{children:be.description})]},`heading-${k}`)}),o.jsxs("div",{className:"new-agent-workbench__panel-frame",children:[o.jsx("div",{ref:Be,className:"new-agent-workbench__panel",children:o.jsxs(fu,{mode:"wait",initial:!1,children:[k==="agent"?o.jsxs(ai.div,{className:"new-agent-workbench__fields",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:[o.jsxs("label",{className:"new-agent-workbench__field","data-validation-field":"name",children:[o.jsxs("span",{className:"new-agent-workbench__field-heading",children:[o.jsxs("span",{children:["名称",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsxs("small",{children:[e.name.length,"/50"]})]}),o.jsx(Ui,{value:e.name,maxLength:50,size:"xl",gutterSize:"md",pill:!1,invalid:it&&Ee,placeholder:"输入智能体名称","aria-describedby":it&&Se?"new-agent-workbench-name-error":void 0,onBlur:()=>$(!0),onChange:Fe=>{$(!0),f({name:Fe.currentTarget.value})}}),it&&Se?o.jsx("small",{id:"new-agent-workbench-name-error",className:"new-agent-workbench__error",role:"alert",children:Se}):null]}),o.jsxs("label",{className:"new-agent-workbench__field","data-validation-field":"description",children:[o.jsxs("span",{children:["描述",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(md,{value:e.description,rows:4,maxRows:8,autoResize:!0,size:"xl",gutterSize:"md",invalid:$e&&tt,placeholder:"说明这个智能体可以做什么",onChange:Fe=>f({description:Fe.currentTarget.value})}),$e&&tt?o.jsx("small",{className:"new-agent-workbench__error",children:"请输入描述"}):null]}),o.jsxs("label",{className:"new-agent-workbench__field","data-validation-field":"instruction",children:[o.jsxs("span",{children:["提示词",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(md,{value:e.instruction,rows:10,maxRows:18,autoResize:!0,size:"xl",gutterSize:"md",invalid:$e&&Ue,placeholder:"定义角色、目标和行为边界",onChange:Fe=>f({instruction:Fe.currentTarget.value})}),$e&&Ue?o.jsx("small",{className:"new-agent-workbench__error",children:"请输入提示词"}):null]}),o.jsx(GRt,{cloudProvider:t,source:re,value:e.modelName??"",apiKeyId:(le=e.deployment)==null?void 0:le.modelApiKeyId,apiKeyName:(Xt=e.deployment)==null?void 0:Xt.modelApiKeyName,provider:e.modelProvider??"",apiBase:e.modelApiBase??"",customApiKey:g,onSourceChange:Fe=>{var Pt;j(Fe==="ark"),f({modelSource:Fe,modelName:Fe==="custom"&&re==="ark"?"":Fe==="ark"&&!((Pt=e.modelName)!=null&&Pt.trim())?eh(t):e.modelName})},onApiKeyChange:m,onModelNameChange:Fe=>f({modelName:Fe}),onProviderChange:Fe=>f({modelProvider:Fe}),onApiBaseChange:Fe=>f({modelApiBase:Fe}),onCustomApiKeyChange:b,onLoadingChange:j}),$e&&ce?o.jsx("p",{className:"new-agent-workbench__error",role:"alert",children:"请选择模型"}):null,o.jsxs("div",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"技能"}),o.jsx(mU,{selected:e.selectedSkills??[],onChange:y,cloudProvider:t,disabled:s,addLabel:"添加技能",showSelectedCount:!1})]})]},"agent"):null,k==="environment"?o.jsx(ai.div,{className:"new-agent-workbench__fields",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:o.jsx("div",{className:"new-agent-workbench__environment",children:o.jsx(Ywe,{value:e.cloudEnvironment??{environmentId:"",environmentVersionId:""},onChange:O,disabled:s,controlSize:"xl",controlClassName:"new-agent-workbench__select-trigger",optionClassName:Sf})})},"environment"):null,k==="deployment"?o.jsxs(ai.div,{className:"new-agent-workbench__fields",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsxs("span",{children:["Runtime 名称",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Ui,{value:r,disabled:s||i,size:"xl",gutterSize:"md",pill:!1,placeholder:"agent-runtime",onChange:Fe=>x(Fe.currentTarget.value)}),o.jsx("small",{className:"new-agent-workbench__helper-text",children:i?"更新时保持现有 Runtime 名称不变":"仅支持英文字母、数字、下划线和连字符"})]}),o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsxs("span",{children:["发布区域",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Wo,{value:n,options:rt,size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,disabled:s||i,onChange:Fe=>v(Fe.value)})]}),o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"鉴权方式"}),o.jsx(Wo,{value:B,options:[{value:"api_key",label:"API Key",description:"默认方式,使用 Runtime API Key 访问"},{value:"user_pool",label:"用户池",description:"使用 Identity 用户池签发的 JWT"}],size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,disabled:s,onChange:Fe=>{F(Fe.value),Qe("")}})]}),B==="user_pool"?o.jsx(WRt,{value:L,disabled:s,onChange:Fe=>{H(Fe),Qe("")}}):null]}),o.jsx("div",{className:"new-agent-workbench__deployment-section",children:o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"会话存储"}),o.jsx(Wo,{value:z,options:by.map(Fe=>({value:Fe.id,label:Fe.id==="local"?"In-memory 临时存储":Fe.label})),size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,disabled:s,onChange:Fe=>{Uee(Fe.value)&&(Q(Fe.value),f({memory:{...e.memory,shortTerm:Fe.value!=="local"},shortTermBackend:Fe.value}),Qe(""))}})]})}),o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsx("strong",{className:"new-agent-workbench__section-title",children:"实例设置"}),o.jsxs("div",{className:"new-agent-workbench__instance-fields",children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"最小实例数"}),o.jsx(Ui,{type:"number",min:1,step:1,value:K,size:"xl",gutterSize:"md",pill:!1,disabled:s,onChange:Fe=>{se(Fe.currentTarget.value),Qe("")}})]}),o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"最大实例数"}),o.jsx(Ui,{type:"number",min:1,step:1,value:ge,size:"xl",gutterSize:"md",pill:!1,disabled:s,onChange:Fe=>{ie(Fe.currentTarget.value),Qe("")}})]})]}),V==="in-memory"?o.jsx("small",{className:"new-agent-workbench__helper-text",children:"为避免多实例间会话丢失,推荐将 Runtime 固定为 1~1"}):null]}),o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"网络模式"}),o.jsx(Wo,{value:Z,options:[{value:"public",label:"公网"},{value:"private",label:"私网"},{value:"both",label:"公网与私网"}],size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,onChange:Fe=>w(Fe.value==="public"?void 0:{..._e??{},mode:Fe.value})})]}),Z!=="public"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"new-agent-workbench__field-row",children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsxs("span",{children:["VPC ID",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Ui,{value:(_e==null?void 0:_e.vpcId)??"",size:"xl",gutterSize:"md",pill:!1,placeholder:"vpc-xxx",onChange:Fe=>w({..._e??{mode:Z},vpcId:Fe.currentTarget.value})})]}),o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"子网 ID(可选,多个用逗号分隔)"}),o.jsx(Ui,{value:(_e==null?void 0:_e.subnetIds)??"",size:"xl",gutterSize:"md",pill:!1,placeholder:"subnet-xxx",onChange:Fe=>w({..._e??{mode:Z},subnetIds:Fe.currentTarget.value})})]})]}),o.jsxs("div",{className:"new-agent-workbench__switch-row",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"VPC 内共享公网出口"}),o.jsx("span",{children:"允许私网 Runtime 通过共享出口访问公网"})]}),o.jsx(W6,{checked:!!(_e!=null&&_e.enableSharedInternetAccess),onCheckedChange:Fe=>w({..._e??{mode:Z},enableSharedInternetAccess:Fe}),"aria-label":"VPC 内共享公网出口"})]})]}):null]}),t!=="byteplus"?o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsx("strong",{className:"new-agent-workbench__section-title",children:"评测集"}),o.jsxs("div",{className:"new-agent-workbench__switch-row",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"自动创建评测集"}),o.jsx("span",{children:"部署成功后自动创建 Good Case 和 Bad Case 评测集"})]}),o.jsx(W6,{checked:q,onCheckedChange:G,"aria-label":"自动创建评测集"})]})]}):null,o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsx("strong",{className:"new-agent-workbench__section-title",children:"资源配置"}),o.jsx(Qve,{value:J,agentName:e.name||"agentkit-app",runtimeName:r,region:n,disabled:s,validationError:je,onChange:Fe=>{ue(Fe),ze(null),Qe("")}})]}),o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsxs("div",{className:"new-agent-workbench__env-head",children:[o.jsx("strong",{className:"new-agent-workbench__section-title",children:"环境变量"}),o.jsxs(jt,{color:"secondary",variant:"ghost",size:"sm",pill:!1,onClick:ft,children:[o.jsx(Nae,{"aria-hidden":!0}),"添加变量"]})]}),o.jsxs("div",{className:"new-agent-workbench__env-table",role:"table","aria-label":"环境变量",children:[o.jsxs("div",{className:"new-agent-workbench__env-table-head",role:"row",children:[o.jsx("span",{role:"columnheader",children:"名称"}),o.jsx("span",{role:"columnheader",children:"值"}),o.jsx("span",{role:"columnheader",children:"操作"})]}),o.jsxs("div",{className:"new-agent-workbench__env-table-body",role:"rowgroup",children:[ct.map(Fe=>o.jsx(Fee,{name:Fe.key,value:Re[Fe.key]??Fe.defaultValue??"",required:Fe.required,placeholder:Fe.placeholder,locked:!0,onRename:()=>{},onValueChange:Pt=>Dt(Fe.key,Pt),onRemove:()=>{}},Fe.key)),qt.map(([Fe,Pt])=>o.jsx(Fee,{name:Fe,value:Pt,onRename:Xe,onValueChange:Ce=>Dt(Fe,Ce),onRemove:()=>nt(Fe)},Fe)),!ct.length&&!qt.length?o.jsx("div",{className:"new-agent-workbench__empty-row new-agent-workbench__env-table-empty",role:"row",children:o.jsx("span",{role:"cell",children:"无"})}):null]})]})]}),Oe?o.jsx(t0,{message:Oe,defaultExpanded:!0}):l?o.jsx(t0,{message:l,defaultExpanded:!0}):a||c?o.jsxs("div",{className:"new-agent-workbench__deploy-status",role:"status",children:[c?o.jsx(Cae,{"aria-hidden":!0}):null,o.jsx("span",{children:(a==null?void 0:a.message)||(c?"部署已完成":"正在准备部署…")}),typeof(a==null?void 0:a.pct)=="number"?o.jsxs("strong",{children:[Math.round(a.pct),"%"]}):null]}):null]},"deployment"):null]})}),o.jsx("span",{className:`new-agent-workbench__scroll-fade is-top${Ge.top?" is-visible":""}`,"aria-hidden":"true"}),o.jsx("span",{className:`new-agent-workbench__scroll-fade is-bottom${Ge.bottom?" is-visible":""}`,"aria-hidden":"true"})]}),o.jsx(fu,{mode:"wait",initial:!1,children:o.jsxs(ai.div,{className:"new-agent-workbench__actions",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:[o.jsxs(jt,{color:"secondary",variant:"outline",size:"lg",pill:!1,disabled:s,onClick:xt,children:[o.jsx(cRe,{"aria-hidden":!0}),he===0?"返回":"上一步"]}),o.jsx(jt,{color:"primary",size:"lg",pill:!1,loading:s,disabled:s||k==="agent"&&N,onClick:xe,children:k==="deployment"?c?i?"再次更新":"重新部署":i?"更新并发布":"部署":"下一步"})]},`actions-${k}`)})]})}),o.jsx("footer",{className:"new-agent-workbench__footer",children:o.jsx("div",{className:"new-agent-workbench__footer-inner",children:o.jsx("nav",{"aria-label":"快速模式创建进度",children:o.jsx("ol",{className:"new-agent-workbench__progress",children:g_.map((Fe,Pt)=>o.jsx("li",{className:Pt===he?"is-active":"","aria-current":Pt===he?"step":void 0,"aria-label":Fe.label,title:Fe.label,children:o.jsx("span",{"aria-hidden":"true"})},Fe.id))})})})})]})}async function ZRt(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:il(void 0,Ao)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 AgentKit 智能体中心");if(t.status===401)throw new Error("请先登录以访问 AgentKit 智能体中心");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function KRt(e={}){const t=new URLSearchParams({page_size:String(e.pageSize??100),project:e.project||"default"});return e.region&&t.set("region",e.region),(await ZRt(`/web/a2a-spaces?${t.toString()}`)).items||[]}async function JRt(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:il(void 0,Ao)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 VikingDB 知识库");if(t.status===401)throw new Error("请先登录以访问 VikingDB 知识库");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function eIt(e={}){const t=new URLSearchParams;e.project&&t.set("project",e.project),e.region&&t.set("region",e.region);const n=t.toString();return(await JRt(`/web/viking-knowledgebases${n?`?${n}`:""}`)).items||[]}async function tIt(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:il(void 0,Ao)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 VikingDB 记忆库");if(t.status===401)throw new Error("请先登录以访问 VikingDB 记忆库");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function nIt(e={}){const t=new URLSearchParams;e.project&&t.set("project",e.project),e.region&&t.set("region",e.region);const n=t.toString();return(await tIt(`/web/viking-memories${n?`?${n}`:""}`)).items||[]}const zee=["#6366f1","#0ea5e9","#10b981","#f59e0b","#f43f5e","#a855f7","#14b8a6","#f472b6"];function r3(e){let t=0;for(let n=0;n>>0;return zee[t%zee.length]}const rIt=2,iIt=1500;function sIt(e){return e.includes("HTTP 425")||e.includes("仍在采集中")?"collecting":e.includes("HTTP 404")||e.includes("未开启链路观测")?"disabled":/HTTP 40[13]/.test(e)||e.includes("无权限读取 APMPlus")?"forbidden":"error"}const Vee={collecting:"调用链路仍在采集中,请稍候。",disabled:"该 Agent 未开启链路观测,请到控制台开启后重试。",forbidden:"当前账号无权读取 APMPlus 调用链路,请联系管理员补充只读权限。",error:"调用链路加载失败,请稍后重试。"},aIt={loading:"加载中",ready:"",collecting:"采集中",disabled:"未开启",forbidden:"权限不足",error:"加载失败"};function oIt(e){const t=new Map;e.forEach(u=>t.set(u.span_id,u));const n=new Map,r=[];for(const u of e)u.parent_span_id!=null&&t.has(u.parent_span_id)?(n.get(u.parent_span_id)??n.set(u.parent_span_id,[]).get(u.parent_span_id)).push(u):r.push(u);const i=(u,d)=>u.start_time-d.start_time,s=(u,d)=>({span:u,depth:d,children:(n.get(u.span_id)??[]).sort(i).map(f=>s(f,d+1))}),a=r.sort(i).map(u=>s(u,0)),l=e.length?Math.min(...e.map(u=>u.start_time)):0,c=e.length?Math.max(...e.map(u=>u.end_time)):1;return{rootNodes:a,min:l,total:c-l||1}}function lIt(e,t){const n=[],r=i=>{n.push(i),t.has(i.span.span_id)||i.children.forEach(r)};return e.forEach(r),n}function Hee(e){const t=e/1e6;return t>=1e3?`${(t/1e3).toFixed(2)} s`:`${t.toFixed(t<10?2:1)} ms`}const cIt=e=>e.replace(/^(gen_ai|a2ui|adk)\./,"");function qee(e){return Object.entries(e.attributes).filter(([,t])=>t!=null&&typeof t!="object").map(([t,n])=>{const r=String(n);return{key:cIt(t),value:r,long:r.length>80||r.includes(`
-`)}}).sort((t,n)=>Number(t.long)-Number(n.long))}function Zwe({appName:e,testRunId:t,sessionId:n,endTimeMs:r,onClose:i,title:s="调用链路观测"}){const[a,l]=p.useState(null),[c,u]=p.useState("loading"),[d,f]=p.useState(0),[h,m]=p.useState(new Set),[g,b]=p.useState(null),y=p.useRef(0),O=`${e??""}:${t??""}:${n}:${r??""}`,v=p.useRef(O);p.useEffect(()=>{v.current!==O&&(v.current=O,y.current=0),l(null),u("loading");let A=!1,R,M;if(t)M=xle(t,n);else if(e)M=vC(e,n,r);else{u("error");return}return M.then(I=>{A||(l(I),u("ready"),b(I.length?I.reduce(($,N)=>$.start_time<=N.start_time?$:N).span_id:null))}).catch(I=>{if(A)return;const $=sIt(I instanceof Error?I.message:String(I));u($),$==="collecting"&&y.currentf(N=>N+1),iIt))}),()=>{A=!0,R!==void 0&&window.clearTimeout(R)}},[e,r,d,n,O,t]);const x=()=>{y.current=0,f(A=>A+1)},{rootNodes:w,min:S,total:E}=p.useMemo(()=>oIt(a??[]),[a]),k=p.useMemo(()=>lIt(w,h),[w,h]),_=(a==null?void 0:a.find(A=>A.span_id===g))??null,T=E/1e6,C=A=>m(R=>{const M=new Set(R);return M.has(A)?M.delete(A):M.add(A),M});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"drawer-scrim",onClick:i}),o.jsxs("aside",{className:"drawer drawer--trace",children:[o.jsxs("header",{className:"drawer-head",children:[o.jsxs("div",{children:[o.jsx("div",{className:"drawer-title",children:s}),o.jsx("div",{className:"drawer-sub",children:c==="ready"&&a?`${a.length} 个调用 · ${T.toFixed(1)} ms`:aIt[c]})]}),o.jsx("button",{className:"drawer-close",onClick:i,"aria-label":"关闭",children:o.jsx(Ea,{className:"icon"})})]}),c==="loading"&&o.jsxs("div",{className:"drawer-loading",children:[o.jsx(rr,{className:"icon spin"})," 加载调用链路…"]}),c==="collecting"&&o.jsxs("div",{className:"drawer-loading",role:"status","aria-live":"polite",children:[o.jsx(rr,{className:"icon spin"}),o.jsx("span",{children:Vee.collecting}),o.jsx(jt,{type:"button",color:"secondary",variant:"outline",size:"sm",pill:!1,onClick:x,children:"立即重试"})]}),(c==="disabled"||c==="forbidden"||c==="error")&&o.jsxs("div",{className:"drawer-empty trace-state",role:"alert",children:[o.jsx("span",{children:Vee[c]}),c==="error"&&o.jsx(jt,{type:"button",color:"secondary",variant:"outline",size:"sm",pill:!1,onClick:x,children:"重新加载"})]}),c==="ready"&&a&&a.length===0&&o.jsx("div",{className:"drawer-empty",children:"该会话暂无调用链路(可能尚未产生调用)。"}),k.length>0&&o.jsxs("div",{className:"trace-split",children:[o.jsx("div",{className:"trace-tree scroll",children:k.map(A=>{const R=A.span,M=(R.start_time-S)/E*100,I=Math.max((R.end_time-R.start_time)/E*100,.6),$=A.children.length>0;return o.jsxs("button",{className:`trace-row ${g===R.span_id?"active":""}`,onClick:()=>b(R.span_id),children:[o.jsxs("span",{className:"trace-label",style:{paddingLeft:A.depth*14},children:[o.jsx("span",{className:`trace-caret ${$?"":"hidden"} ${h.has(R.span_id)?"":"open"}`,onClick:N=>{N.stopPropagation(),$&&C(R.span_id)},children:o.jsx(XS,{className:"chev"})}),o.jsx("span",{className:"trace-dot",style:{background:r3(R.name)}}),o.jsx("span",{className:"trace-name",title:R.name,children:R.name})]}),o.jsx("span",{className:"trace-dur",children:Hee(R.end_time-R.start_time)}),o.jsx("span",{className:"trace-track",children:o.jsx("span",{className:"trace-bar",style:{left:`${M}%`,width:`${I}%`,background:r3(R.name)}})})]},R.span_id)})}),o.jsx("div",{className:"trace-detail scroll",children:_?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"td-title",children:_.name}),o.jsxs("div",{className:"td-dur",children:[o.jsx("span",{className:"td-dot",style:{background:r3(_.name)}}),Hee(_.end_time-_.start_time)]}),o.jsx("div",{className:"td-section",children:"属性"}),o.jsx("div",{className:"td-props",children:qee(_).filter(A=>!A.long).map(A=>o.jsxs("div",{className:"td-prop",children:[o.jsx("span",{className:"td-key",children:A.key}),o.jsx("span",{className:"td-val",children:A.value})]},A.key))}),qee(_).filter(A=>A.long).map(A=>o.jsxs("div",{className:"td-block",children:[o.jsx("div",{className:"td-section",children:A.key}),o.jsx("pre",{className:"td-pre",children:A.value})]},A.key))]}):o.jsx("div",{className:"drawer-empty",children:"选择左侧的一个调用查看详情"})})]})]})]})}const uIt=p.lazy(()=>fd(()=>import("../chunks/MarkdownPromptEditor-BL6zJDeA.js"),__vite__mapDeps([2,3]))),s$="veadk.generatedAgentTestRuns",Xee=4;function RU(){if(typeof window>"u")return[];try{const e=JSON.parse(window.sessionStorage.getItem(s$)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}catch{return[]}}function Kwe(e){if(typeof window>"u")return;const t=Array.from(new Set(e)).slice(-20);try{t.length?window.sessionStorage.setItem(s$,JSON.stringify(t)):window.sessionStorage.removeItem(s$)}catch{}}function dIt(e){Kwe([...RU(),e])}function kx(e){Kwe(RU().filter(t=>t!==e))}function fIt(e,t,n="text/plain"){const r=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}const hIt=[{id:"type",label:"Agent 类型",hint:"选择 Agent 类型",icon:oIe,required:!0},{id:"basic",label:"基本信息",hint:"名称、描述与系统提示词",icon:Sd,required:!0},{id:"model",label:"模型配置",hint:"模型与服务(可选)",icon:zRe},{id:"tools",label:"工具",hint:"可调用的能力",icon:dIe},{id:"skills",label:"技能",hint:"声明式技能",icon:Sw},{id:"knowledge",label:"知识库",hint:"外部知识检索",icon:U_},{id:"memory",label:"记忆",hint:"短期与长期记忆",icon:Bae},{id:"subagents",label:"子 Agent",hint:"嵌套协作",icon:MRe},{id:"review",label:"完成",hint:"预览并创建",icon:aIe}];function pIt({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M9 7.15v9.7a1.15 1.15 0 0 0 1.78.96l7.2-4.85a1.15 1.15 0 0 0 0-1.92l-7.2-4.85A1.15 1.15 0 0 0 9 7.15Z"}),o.jsx("path",{d:"M5.75 8.25v7.5",opacity:"0.8"}),o.jsx("path",{d:"M3 10v4",opacity:"0.45"}),o.jsx("path",{d:"M17.9 5.25v2.2M19 6.35h-2.2",strokeWidth:"1.55"})]})}function Gee({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M4.75 7.25h14.5"}),o.jsx("path",{d:"M9.1 4.75h5.8l.75 2.5h-7.3l.75-2.5Z"}),o.jsx("path",{d:"m6.75 7.25.75 12h9l.75-12"}),o.jsx("path",{d:"M10 10.25v5.75M14 10.25v5.75"})]})}function IU({className:e}){return o.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("path",{d:"m7 9 5 5 5-5"})})}function DU({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M18.25 8.2A7.1 7.1 0 0 0 6.1 6.65L4.5 8.25"}),o.jsx("path",{d:"M4.5 4.75v3.5H8"}),o.jsx("path",{d:"M5.75 15.8A7.1 7.1 0 0 0 17.9 17.35l1.6-1.6"}),o.jsx("path",{d:"M19.5 19.25v-3.5H16"})]})}const mIt={llm:"智能体",sequential:"分步协作",parallel:"同时处理",loop:"循环执行",a2a:"远程智能体"},Wee={REGISTRY_SPACE_ID:"registrySpaceId",REGISTRY_TOP_K:"registryTopK",REGISTRY_REGION:"registryRegion",REGISTRY_ENDPOINT:"registryEndpoint"},Jwe="REGISTRY_SPACE_ID",gIt=hhe.filter(e=>e.key!==Jwe);function eSe(e,t,n="volcengine"){var s,a,l;if(!(e!=null&&e.enabled))return{};const r=wj(n),i={REGISTRY_SPACE_ID:e.registrySpaceId??""};return t.includeDefaults?(i.REGISTRY_TOP_K=((s=e.registryTopK)==null?void 0:s.trim())||r.topK,i.REGISTRY_REGION=((a=e.registryRegion)==null?void 0:a.trim())||r.region,i.REGISTRY_ENDPOINT=((l=e.registryEndpoint)==null?void 0:l.trim())||r.endpoint):(i.REGISTRY_TOP_K=e.registryTopK??"",i.REGISTRY_REGION=e.registryRegion??"",i.REGISTRY_ENDPOINT=e.registryEndpoint??""),i}function Eb(e,t){if(t!=="byteplus")return e;const n=wj(t);return e.map(r=>r.key==="REGISTRY_REGION"?{...r,placeholder:n.region}:r.key==="REGISTRY_ENDPOINT"?{...r,placeholder:n.endpoint}:r.key==="MODEL_EMBEDDING_NAME"?{...r,placeholder:h5e(t)}:r.key==="MODEL_EMBEDDING_API_BASE"?{...r,placeholder:nl(t)}:r.key==="MODEL_IMAGE_NAME"?{...r,placeholder:m5e(t)}:r.key==="MODEL_EDIT_NAME"?{...r,placeholder:g5e(t)}:r.key==="MODEL_VIDEO_NAME"?{...r,placeholder:b5e(t)}:r.key==="MODEL_IMAGE_API_BASE"||r.key==="MODEL_EDIT_API_BASE"||r.key==="MODEL_VIDEO_API_BASE"?{...r,placeholder:nl(t)}:r)}function bIt({items:e,selected:t,onToggle:n,scrollRows:r}){return o.jsx("div",{className:`cw-checklist ${r?"cw-checklist-tools":""}`,style:r?{"--cw-checklist-max-height":`${r*40+(r-1)*8}px`}:void 0,children:e.map(i=>{const s=t.includes(i.id);return o.jsx(jU,{id:`cw-check-${i.id}`,className:`cw-check ${s?"is-on":""}`,checked:s,onCheckedChange:a=>{a!==s&&n(i.id)},label:o.jsx("span",{className:"cw-check-text",children:o.jsx("span",{className:"cw-check-title",children:i.label})})},i.id)})})}function i3({options:e,value:t,onChange:n}){return o.jsx("div",{className:"cw-segmented",children:e.map(r=>{var s;const i=(t??((s=e[0])==null?void 0:s.id))===r.id;return o.jsx("button",{type:"button",className:`cw-seg ${i?"is-on":""}`,onClick:()=>n(r.id),"aria-pressed":i,children:o.jsx("span",{className:"cw-seg-title",children:r.label})},r.id)})})}function yIt(e){return/(SECRET|PASSWORD|KEY|TOKEN)$/.test(e)}function _x({env:e,values:t,onChange:n,renderAfterField:r}){const i=e.filter(s=>!s.hidden);return i.length===0?o.jsx("p",{className:"cw-env-empty",children:"此后端无需额外运行参数。"}):o.jsx("div",{className:"cw-env-fields",children:i.map(s=>{const a=t[s.key]??s.defaultValue??"",l=AU(s,t),c=`cw-env-${s.key}`;return o.jsxs(p.Fragment,{children:[o.jsxs("label",{className:"cw-env-field",htmlFor:c,children:[o.jsxs("span",{className:"cw-env-field-head",children:[o.jsxs("span",{className:"cw-env-field-title",children:[o.jsxs("span",{className:"cw-env-field-label",children:[s.comment||s.key,s.required&&o.jsx("span",{className:"cw-req",children:"*"})]}),s.help&&o.jsxs("span",{className:"cw-env-help",tabIndex:0,"data-help":s.help,"aria-label":`${s.comment||s.key}说明:${s.help}`,children:["?",o.jsx("span",{className:"cw-env-help-popover",role:"tooltip",children:s.help})]}),s.link&&o.jsx("a",{className:"cw-env-link",href:s.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开 OpenViking ${s.link.label}`,"aria-label":`打开 OpenViking ${s.link.label}`,onClick:u=>u.stopPropagation(),children:o.jsx(Dg,{"aria-hidden":"true"})})]}),s.comment&&o.jsx("code",{title:s.key,children:s.key})]}),s.multiline||s.format==="json"?o.jsx("textarea",{id:c,className:"cw-input cw-env-textarea",value:a,placeholder:s.placeholder||"请输入参数值",autoComplete:"off",spellCheck:!1,"aria-invalid":!!l,onChange:u=>n(s.key,u.currentTarget.value)}):o.jsx("input",{id:c,className:"cw-input",type:yIt(s.key)?"password":"text",value:a,placeholder:s.placeholder||"请输入参数值",autoComplete:"off","aria-invalid":!!l,onChange:u=>n(s.key,u.currentTarget.value)}),l&&o.jsx("span",{className:"cw-env-error",children:l})]}),r==null?void 0:r(s)]},s.key)})})}const s3="默认值:留空;生成项目时使用 Agent 名自动生成,例如 my_agent_kb。未配置 DATABASE_OPENVIKING_TARGET_URI 时,默认 URI 拼接为 viking://user/{知识库归属 ID,未填则 default}/resources/{资源索引}/;如果填写了 DATABASE_OPENVIKING_TARGET_URI,则直接使用该完整 URI。";function OIt({value:e,onChange:t}){const n="cw-openviking-knowledge-index";return o.jsxs("label",{className:"cw-env-field",htmlFor:n,children:[o.jsx("span",{className:"cw-env-field-head",children:o.jsxs("span",{className:"cw-env-field-title",children:[o.jsx("span",{className:"cw-env-field-label",children:"OpenViking 资源索引"}),o.jsxs("span",{className:"cw-env-help",tabIndex:0,"data-help":s3,"aria-label":`OpenViking 资源索引说明:${s3}`,children:["?",o.jsx("span",{className:"cw-env-help-popover",role:"tooltip",children:s3})]})]})}),o.jsx("input",{id:n,className:"cw-input",value:e,placeholder:"",autoComplete:"off",onChange:r=>t(r.currentTarget.value)})]})}function a3(e){return e.name.trim()||"未命名智能体中心"}function Yee(e){const t=e.name.trim()||e.id||"未命名知识库",n=[e.sourceLabel,e.projectName].filter(Boolean);return n.length?`${t} · ${n.join(" · ")}`:t}function Zee(e){return e.name.trim()||e.id||"未命名记忆库"}function xIt(e){return e.available?"已开通":e.lifecycleStatus==="Retiring"?"即将下线":e.activationState&&e.activationState!=="Available"?"未开通":"暂不可用"}function vIt(e){return e.available||e.lifecycleStatus==="Retiring"}function Kee({selectedLabel:e,placeholder:t,disabled:n,triggerAriaLabel:r,menuAriaLabel:i,searchAriaLabel:s,searchValue:a,searchPlaceholder:l,onSearchChange:c,empty:u,emptyLabel:d,triggerClassName:f="",optionsClassName:h="",renderOptions:m}){const[g,b]=p.useState(!1),y=p.useRef(null),O=p.useRef(null),v=p.useRef(null),x=p.useId(),[w,S]=p.useState(null);p.useEffect(()=>{if(!g)return;const _=C=>{var R;const A=C.target;A instanceof Node&&y.current&&!y.current.contains(A)&&!((R=v.current)!=null&&R.contains(A))&&b(!1)},T=C=>{var A;C.key==="Escape"&&(b(!1),(A=O.current)==null||A.focus())};return window.addEventListener("pointerdown",_),window.addEventListener("keydown",T),()=>{window.removeEventListener("pointerdown",_),window.removeEventListener("keydown",T)}},[g]),p.useEffect(()=>{if(!g){S(null);return}const _=()=>{const T=O.current;if(!T)return;const C=T.getBoundingClientRect(),A=12,R=6,M=window.innerHeight-C.bottom-A-R,I=C.top-A-R,$=M<300&&I>M,N=Math.max(96,$?I:M),j=Math.min(C.width,window.innerWidth-A*2),B=Math.min(Math.max(A,C.left),window.innerWidth-A-j);S({...$?{bottom:window.innerHeight-C.top+R}:{top:C.bottom+R},left:B,width:j,maxHeight:N,opensUp:$})};return _(),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[g]);const E=()=>b(!1),k=_=>{var R,M;if(!["ArrowDown","ArrowUp","Home","End"].includes(_.key))return;const T=Array.from(((R=v.current)==null?void 0:R.querySelectorAll('[role="option"]:not(:disabled)'))??[]);if(!T.length)return;_.preventDefault();const C=T.findIndex(I=>I===document.activeElement),A=_.key==="Home"?0:_.key==="End"?T.length-1:_.key==="ArrowUp"?C<=0?T.length-1:C-1:C<0||C===T.length-1?0:C+1;(M=T[A])==null||M.focus()};return o.jsxs("div",{className:`cw-a2a-space-select-wrap cw-catalog-select${g?" is-open":""}`,ref:y,children:[o.jsxs("button",{ref:O,type:"button",className:`cw-a2a-space-trigger ${f}`.trim(),disabled:n,"aria-haspopup":"listbox","aria-controls":g?x:void 0,"aria-expanded":g,"aria-label":r,title:e,onClick:()=>{g||c(""),b(_=>!_)},children:[o.jsx("span",{className:t?"is-placeholder":void 0,children:e}),o.jsx(IU,{className:"cw-a2a-space-trigger-icon"})]}),g&&w&&kr.createPortal(o.jsxs("div",{ref:v,className:`cw-a2a-space-menu cw-catalog-menu cw-catalog-menu-portal${w.opensUp?" is-up":""}`,style:{top:w.top??"auto",bottom:w.bottom??"auto",left:w.left,width:w.width,maxHeight:w.maxHeight},onKeyDown:k,children:[o.jsx("div",{className:"cw-picker-search",children:o.jsx("input",{className:"cw-picker-search-input",type:"search",value:a,autoFocus:!0,autoComplete:"off","aria-label":s,placeholder:l,onChange:_=>c(_.currentTarget.value)})}),o.jsxs("div",{id:x,className:`cw-picker-options cw-catalog-options ${h}`.trim(),role:"listbox","aria-label":i,children:[m(E),u&&o.jsx("div",{className:"cw-picker-empty",children:d})]})]}),document.body)]})}function wIt({value:e,cloudProvider:t,apiKeyId:n,apiKeyName:r,onApiKeyChange:i,onChange:s}){const[a,l]=p.useState([]),[c,u]=p.useState(!1),[d,f]=p.useState([]),[h,m]=p.useState(null),[g,b]=p.useState(!1),[y,O]=p.useState(null),[v,x]=p.useState(0),[w,S]=p.useState(0),[E,k]=p.useState(""),[_,T]=p.useState("");p.useEffect(()=>{const Q=new AbortController;return u(!0),O(null),f9(Q.signal,v>0).then(V=>{if(Q.signal.aborted)return;l(V.keys);const K=V.keys.find(se=>se.id===n)??V.keys.find(se=>se.name===r)??V.keys.find(se=>se.id===V.defaultKeyId)??V.keys[0];K&&i(K)}).catch(V=>{Q.signal.aborted||O(V instanceof Error?V.message:"加载 Ark API Key 失败")}).finally(()=>{Q.signal.aborted||u(!1)}),()=>Q.abort()},[t,v]),p.useEffect(()=>{if(!n){f([]);return}const Q=new AbortController;return b(!0),O(null),m(null),Q1({signal:Q.signal,apiKeyId:n,refresh:v>0||w>0}).then(V=>{Q.signal.aborted||(f(V.models),m(n))}).catch(V=>{Q.signal.aborted||O(V instanceof Error?V.message:"加载模型列表失败")}).finally(()=>{Q.signal.aborted||b(!1)}),()=>Q.abort()},[n,t,w,v]);const C=e.trim(),A=h===n,R=A?d:[],M=a.find(Q=>Q.id===n),I=M?M.name:n?"当前 API Key":c?"正在加载 API Key…":a.length===0?"暂无可用 API Key":"请选择 API Key",$=p.useMemo(()=>a.filter(Q=>Cg(E,[Q.name])),[E,a]),N=R.find(Q=>Q.id===C),j=g&&!A?"正在刷新模型列表…":N?`${N.displayName} (${N.id})`:C||"请选择模型",B=p.useMemo(()=>R.filter(Q=>Cg(_,[Q.displayName,Q.id,Q.name,Q.vendorName,Q.activationState,Q.lifecycleStatus])),[_,R]),F=!!(C&&!N&&Cg(_,[C])),L=R.filter(Q=>Q.available).length,H=t==="byteplus"?"BytePlus ModelArk":"火山方舟",z=f5e(t);return o.jsxs("div",{className:"cw-a2a-space-picker cw-model-picker",children:[o.jsxs("div",{className:"cw-model-picker-stack",children:[o.jsxs("div",{className:"cw-model-picker-field",children:[o.jsx("span",{className:"cw-model-picker-label",children:"API Key"}),o.jsx(Kee,{selectedLabel:I,placeholder:!n,disabled:c,triggerAriaLabel:"选择 API Key",menuAriaLabel:"API Key 列表",searchAriaLabel:"搜索 API Key",searchValue:E,searchPlaceholder:"搜索 API Key 名称",onSearchChange:k,empty:$.length===0,emptyLabel:"未找到匹配的 API Key",optionsClassName:"cw-model-key-options",renderOptions:Q=>$.map(V=>{const K=V.id===n;return o.jsx("button",{type:"button",role:"option","aria-selected":K,className:`cw-a2a-space-option cw-model-key-option ${K?"is-selected":""}`,title:V.name,onClick:()=>{S(se=>se+1),i(V),Q()},children:o.jsx("span",{children:V.name})},V.id)})})]}),o.jsxs("div",{className:"cw-model-picker-field",children:[o.jsx("span",{className:"cw-model-picker-label",children:"模型"}),o.jsxs("div",{className:"cw-a2a-space-row",children:[o.jsx(Kee,{selectedLabel:j,placeholder:!C,disabled:g,triggerAriaLabel:`选择${H}模型`,menuAriaLabel:`${H}模型`,searchAriaLabel:"搜索模型",searchValue:_,searchPlaceholder:"搜索名称、Model ID 或服务商",onSearchChange:T,empty:!F&&B.length===0,emptyLabel:"未找到匹配的模型",triggerClassName:"cw-model-trigger",optionsClassName:"cw-model-options",renderOptions:Q=>o.jsxs(o.Fragment,{children:[F&&o.jsxs("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option cw-model-option is-selected",onClick:()=>{s(C),Q()},children:[o.jsxs("span",{className:"cw-model-option-copy",children:[o.jsx("strong",{children:"当前配置"}),o.jsx("small",{children:C})]}),o.jsx("span",{className:"cw-model-status is-unknown",children:"状态未知"})]}),B.map(V=>{const K=V.id===C,se=vIt(V);return!se&&V.activationState!=="Available"?o.jsxs("button",{type:"button",role:"option","aria-selected":!1,className:"cw-a2a-space-option cw-model-option is-activation-link",title:`前往${H}开通 ${V.displayName}`,onClick:()=>{window.open(z,"_blank","noopener,noreferrer"),Q()},children:[o.jsxs("span",{className:"cw-model-option-copy",children:[o.jsx("strong",{children:V.displayName}),o.jsxs("small",{children:[V.id,V.vendorName?` · ${V.vendorName}`:""]})]}),o.jsx("span",{className:"cw-model-status is-unavailable",children:"未开通,去开通"})]},V.id):o.jsxs("button",{type:"button",role:"option","aria-selected":K,disabled:!se,className:`cw-a2a-space-option cw-model-option ${K?"is-selected":""}`,title:`${V.displayName} (${V.id})`,onClick:()=>{s(V.id),Q()},children:[o.jsxs("span",{className:"cw-model-option-copy",children:[o.jsx("strong",{children:V.displayName}),o.jsxs("small",{children:[V.id,V.vendorName?` · ${V.vendorName}`:""]})]}),o.jsx("span",{className:`cw-model-status ${V.available?"is-available":V.lifecycleStatus==="Retiring"?"is-retiring":"is-unavailable"}`,children:xIt(V)})]},V.id)})]})}),o.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新 API Key 和模型列表","aria-label":"刷新 API Key 和模型列表",disabled:g||c,onClick:()=>x(Q=>Q+1),children:g||c?o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}):o.jsx(DU,{className:"cw-i cw-i-sm"})})]})]})]}),y?o.jsxs("div",{className:"cw-banner cw-a2a-space-error",role:"alert",children:[o.jsx(Sd,{className:"cw-i"}),o.jsx("span",{children:y})]}):g?o.jsxs("span",{className:"cw-help cw-a2a-space-status","aria-live":"polite",children:[o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}),"正在加载模型列表…"]}):R.length===0?o.jsx("span",{className:"cw-help",children:"当前账号下暂无可配置模型。"}):o.jsxs("span",{className:"cw-help",children:["已加载 ",R.length," 个模型,其中 ",L," 个已开通。"]})]})}function SIt({value:e,region:t,invalid:n,onChange:r}){const i=t.trim()||gy.region,[s,a]=p.useState([]),[l,c]=p.useState(!1),[u,d]=p.useState(null),[f,h]=p.useState(0),[m,g]=p.useState(!1),[b,y]=p.useState(""),O=p.useRef(null);p.useEffect(()=>{let T=!1;return c(!0),d(null),KRt({region:i}).then(C=>{T||a(C)}).catch(C=>{T||(a([]),d(C instanceof Error?C.message:"加载失败"))}).finally(()=>{T||c(!1)}),()=>{T=!0}},[i,f]);const v=!e||s.some(T=>T.id===e.trim()),x=s.find(T=>T.id===e.trim()),w=x?a3(x):e&&!v?"已选择的智能体中心":"请选择智能体中心",S=l&&s.length===0,E=p.useMemo(()=>s.filter(T=>Cg(b,[a3(T),T.id,T.projectName])),[b,s]),k=!!(e&&!v&&Cg(b,["已选择的智能体中心",e]));p.useEffect(()=>{if(!m)return;const T=A=>{const R=A.target;R instanceof Node&&O.current&&!O.current.contains(R)&&g(!1)},C=A=>{A.key==="Escape"&&g(!1)};return window.addEventListener("pointerdown",T),window.addEventListener("keydown",C),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",C)}},[m]);const _=T=>{r(T),g(!1)};return o.jsxs("div",{className:`cw-a2a-space-picker${m?" is-open":""}`,ref:O,children:[o.jsxs("div",{className:"cw-a2a-space-row",children:[o.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[o.jsxs("button",{type:"button",className:`cw-a2a-space-trigger ${n?"is-error":""}`,disabled:S,"aria-haspopup":"listbox","aria-expanded":m,"aria-label":"选择 AgentKit 智能体中心",onClick:()=>{y(""),g(T=>!T)},children:[o.jsx("span",{className:e?void 0:"is-placeholder",children:w}),o.jsx(IU,{className:"cw-a2a-space-trigger-icon"})]}),m&&o.jsxs("div",{className:"cw-a2a-space-menu",children:[o.jsx("div",{className:"cw-picker-search",children:o.jsx("input",{className:"cw-picker-search-input",type:"search",value:b,autoFocus:!0,autoComplete:"off","aria-label":"搜索 AgentKit 智能体中心",placeholder:"搜索名称或 ID",onChange:T=>y(T.currentTarget.value)})}),o.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"AgentKit 智能体中心",children:[k&&o.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>_(e),children:"已选择的智能体中心"}),E.map(T=>{const C=a3(T),A=T.id===e;return o.jsx("button",{type:"button",role:"option","aria-selected":A,className:`cw-a2a-space-option ${A?"is-selected":""}`,title:`${C} (${T.id})`,onClick:()=>_(T.id),children:C},T.id)}),!k&&E.length===0&&o.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的智能体中心"})]})]})]}),o.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新智能体中心列表","aria-label":"刷新智能体中心列表",disabled:l,onClick:()=>h(T=>T+1),children:l?o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}):o.jsx(DU,{className:"cw-i cw-i-sm"})})]}),u?o.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[o.jsx(Sd,{className:"cw-i"}),o.jsx("span",{children:u})]}):l?o.jsxs("span",{className:"cw-help cw-a2a-space-status",children:[o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}),"正在加载 AgentKit 智能体中心…"]}):s.length===0?o.jsx("span",{className:"cw-help",children:"此账号下暂无 AgentKit 智能体中心。"}):o.jsxs("span",{className:"cw-help",children:["已加载 ",s.length," 个智能体中心,列表仅展示中心名称。"]})]})}function tSe({value:e,items:t,loading:n,error:r,pickerClassName:i,selectLabel:s,searchLabel:a,listLabel:l,placeholder:c,emptyMessage:u,loadedMessage:d,refreshLabel:f,noMatchesMessage:h,getLabel:m,getSearchFields:g,getKey:b,getOptionIds:y,makeUnknownItem:O,onChange:v,onRefresh:x}){const[w,S]=p.useState(!1),[E,k]=p.useState(""),_=p.useRef(null),T=!e||t.some(N=>N.id===e.trim()),C=t.find(N=>N.id===e.trim()),A=C?m(C):e&&!T?e:c,R=n&&t.length===0,M=p.useMemo(()=>t.filter(N=>Cg(E,g(N))),[g,t,E]),I=!!(e&&!T&&Cg(E,[e]));p.useEffect(()=>{if(!w)return;const N=B=>{const F=B.target;F instanceof Node&&_.current&&!_.current.contains(F)&&S(!1)},j=B=>{B.key==="Escape"&&S(!1)};return window.addEventListener("pointerdown",N),window.addEventListener("keydown",j),()=>{window.removeEventListener("pointerdown",N),window.removeEventListener("keydown",j)}},[w]);const $=N=>{v(N),S(!1)};return n&&t.length===0?o.jsxs("span",{className:"cw-viking-kb-inline-status",role:"status",children:[o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}),"正在加载…"]}):o.jsxs("div",{className:`cw-a2a-space-picker ${i}${w?" is-open":""}`,ref:_,children:[o.jsxs("div",{className:"cw-a2a-space-row",children:[o.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[o.jsxs("button",{type:"button",className:"cw-a2a-space-trigger",disabled:R,"aria-haspopup":"listbox","aria-expanded":w,"aria-label":s,onClick:()=>{k(""),S(N=>!N)},children:[o.jsx("span",{className:e?void 0:"is-placeholder",children:A}),o.jsx(IU,{className:"cw-a2a-space-trigger-icon"})]}),w&&o.jsxs("div",{className:"cw-a2a-space-menu cw-viking-kb-menu",children:[o.jsx("div",{className:"cw-picker-search",children:o.jsx("input",{className:"cw-picker-search-input",type:"search",value:E,autoFocus:!0,autoComplete:"off","aria-label":a,placeholder:"搜索名称或 ID",onChange:N=>k(N.currentTarget.value)})}),o.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":l,children:[I&&o.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>$(O(e)),children:e}),M.map(N=>{const j=m(N),B=N.id===e,F=y(N).filter(Boolean).join(" / ");return o.jsx("button",{type:"button",role:"option","aria-selected":B,className:`cw-a2a-space-option ${B?"is-selected":""}`,title:F?`${j} (${F})`:j,onClick:()=>$(N),children:j},b(N))}),!I&&M.length===0&&o.jsx("div",{className:"cw-picker-empty",children:h})]})]})]}),o.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh cw-viking-kb-refresh",title:f,"aria-label":f,disabled:n,onClick:x,children:n?o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}):o.jsx(DU,{className:"cw-i cw-i-sm"})})]}),r?o.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[o.jsx(Sd,{className:"cw-i"}),o.jsx("span",{children:r})]}):t.length===0?o.jsx("span",{className:"cw-help",children:u}):o.jsx("span",{className:"cw-help",children:d(t.length)})]})}function EIt({value:e,onChange:t}){const[n,r]=p.useState([]),[i,s]=p.useState(!1),[a,l]=p.useState(null),[c,u]=p.useState(0);return p.useEffect(()=>{let d=!1;return s(!0),l(null),eIt().then(f=>{d||r(f)}).catch(f=>{d||(r([]),l(f instanceof Error?f.message:"加载失败"))}).finally(()=>{d||s(!1)}),()=>{d=!0}},[c]),o.jsx(tSe,{value:e,items:n,loading:i,error:a,pickerClassName:"cw-viking-kb-picker",selectLabel:"选择 VikingDB 知识库",searchLabel:"搜索 VikingDB 知识库",listLabel:"VikingDB 知识库",placeholder:"请选择 VikingDB 知识库",emptyMessage:"此账号下暂无 VikingDB 知识库。",loadedMessage:d=>`已加载 ${d} 个知识库,选择的知识库会用于当前 Agent。`,refreshLabel:"刷新知识库列表",noMatchesMessage:"未找到匹配的知识库",getLabel:Yee,getSearchFields:d=>[Yee(d),d.id,d.description,d.projectName,d.resourceId,d.agentkitKnowledgeId,d.providerKnowledgeId,d.sourceLabel],getKey:d=>d.id,getOptionIds:d=>[d.id,d.resourceId,d.agentkitKnowledgeId,d.providerKnowledgeId],makeUnknownItem:d=>({id:d,name:d,description:"",projectName:"",region:"",sourceKind:"knowledge",sourceLabel:"Knowledge Engine",resourceId:""}),onChange:t,onRefresh:()=>u(d=>d+1)})}function kIt({value:e,onChange:t}){const[n,r]=p.useState([]),[i,s]=p.useState(!1),[a,l]=p.useState(null),[c,u]=p.useState(0);return p.useEffect(()=>{let d=!1;return s(!0),l(null),nIt().then(f=>{d||r(f)}).catch(f=>{d||(r([]),l(f instanceof Error?f.message:"加载失败"))}).finally(()=>{d||s(!1)}),()=>{d=!0}},[c]),o.jsx(tSe,{value:e,items:n,loading:i,error:a,pickerClassName:"cw-viking-memory-picker",selectLabel:"选择 VikingDB 记忆库",searchLabel:"搜索 VikingDB 记忆库",listLabel:"VikingDB 记忆库",placeholder:"请选择 VikingDB 记忆库,不选择则自动创建",emptyMessage:"此账号下暂无 VikingDB 记忆库,未选择时会自动创建。",loadedMessage:d=>`已加载 ${d} 个记忆库;不选择时会自动创建。`,refreshLabel:"刷新记忆库列表",noMatchesMessage:"未找到匹配的记忆库",getLabel:Zee,getSearchFields:d=>[Zee(d),d.id,d.description,d.projectName,d.region,d.resourceId,...d.memoryTypes??[]],getKey:d=>`${d.projectName}:${d.region}:${d.id}`,getOptionIds:d=>[d.id,d.resourceId],makeUnknownItem:d=>({id:d,name:d,description:"",projectName:"",region:"",resourceId:"",memoryTypes:[]}),onChange:t,onRefresh:()=>u(d=>d+1)})}function _It({tools:e,onChange:t}){const n=(s,a)=>t(e.map((l,c)=>c===s?{...l,...a}:l)),r=s=>t(e.filter((a,l)=>l!==s)),i=()=>t([...e,{name:"",transport:"http",url:""}]);return o.jsxs("div",{className:"cw-mcp",children:[e.length>0&&o.jsx("div",{className:"cw-mcp-list",children:o.jsx(fu,{initial:!1,children:e.map((s,a)=>o.jsxs(ai.div,{className:"cw-mcp-row",layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.16},children:[o.jsxs("div",{className:"cw-mcp-rowhead",children:[o.jsxs("div",{className:"cw-mcp-transport",children:[o.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${s.transport==="http"?"is-on":""}`,onClick:()=>n(a,{transport:"http"}),"aria-pressed":s.transport==="http",children:o.jsx("span",{className:"cw-seg-title",children:"HTTP"})}),o.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${s.transport==="stdio"?"is-on":""}`,onClick:()=>n(a,{transport:"stdio"}),"aria-pressed":s.transport==="stdio",children:o.jsx("span",{className:"cw-seg-title",children:"stdio"})})]}),o.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger",onClick:()=>r(a),"aria-label":"移除 MCP 工具",children:o.jsx(Fp,{className:"cw-i cw-i-sm"})})]}),o.jsx("input",{className:"cw-input",value:s.name,placeholder:"名称(用于命名,可留空)",onChange:l=>n(a,{name:l.target.value})}),s.transport==="http"?o.jsxs(o.Fragment,{children:[o.jsx("input",{className:"cw-input",value:s.url??"",placeholder:"MCP 服务地址(StreamableHTTP)",onChange:l=>t(e.map((c,u)=>u===a?NRt(c,l.target.value):c))}),ARt(s.url??"")&&o.jsxs("p",{className:"cw-mcp-warning",children:[o.jsx(Sd,{"aria-hidden":"true"}),o.jsx("span",{children:"当前地址不是以 /mcp 结尾,请确认它是实际的 MCP Endpoint。Studio 会保留该地址,不会自动补充路径。"})]}),o.jsx("input",{className:"cw-input","aria-invalid":Gwe(s),value:_Rt(s),placeholder:s.credentialConfigured&&!s.authToken?"认证已配置;留空继续使用":"Bearer Token(可选)",onChange:l=>t(e.map((c,u)=>u===a?TRt(c,l.target.value):c))}),s.credentialUpdate==="pending"&&o.jsxs("div",{className:"cw-mcp-auth-state is-warning",role:"alert",children:[o.jsx("span",{children:"MCP 地址已变化,请重新填写 Key 或确认沿用原凭证。"}),o.jsxs("div",{className:"cw-mcp-auth-actions",children:[o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?jRt(l):l)),children:"沿用原凭证"}),o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?r$(l):l)),children:"重新填写 Key"}),o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?RRt(l):l)),children:"新地址无需认证"})]})]}),s.credentialUpdate==="reuse"&&o.jsxs("div",{className:"cw-mcp-auth-state",role:"status",children:[o.jsx("span",{children:"发布时将沿用原凭证,并绑定到新的 MCP 地址。"}),o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?r$(l):l)),children:"改为重新填写"})]}),s.credentialConfigured&&!s.authToken&&!s.credentialUpdate&&o.jsxs("div",{className:"cw-mcp-auth-state",role:"status",children:[o.jsx("span",{children:"认证已配置,旧值不会显示在页面中。"}),o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?CRt(l):l)),children:"移除认证"})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("input",{className:"cw-input",value:s.command??"",placeholder:"启动命令,例如 npx",onChange:l=>n(a,{command:l.target.value})}),o.jsx("input",{className:"cw-input",value:(s.args??[]).join(" "),placeholder:"参数(用空格分隔),例如 -y @playwright/mcp@latest",onChange:l=>n(a,{args:l.target.value.split(/\s+/).filter(Boolean)})}),o.jsx("p",{className:"cw-mcp-note",children:"stdio MCP 暂不参与调试运行;点击“去部署”时会完整保留这项配置并生成对应代码。"})]})]},a))})}),o.jsxs("button",{type:"button",className:"cw-add-sub",onClick:i,children:[o.jsx(vo,{className:"cw-i"}),"添加 MCP 工具"]})]})}function b_({checked:e,onChange:t,title:n,desc:r,showDescription:i=!1}){return o.jsxs("button",{type:"button",className:`cw-toggle ${e?"is-on":""}`,onClick:()=>t(!e),"aria-pressed":e,children:[o.jsxs("span",{className:"cw-toggle-text",children:[o.jsx("span",{className:"cw-toggle-title",children:n}),i&&o.jsx("span",{className:"cw-toggle-help",children:r})]}),o.jsx("span",{className:"cw-switch","aria-hidden":!0,children:o.jsx(ai.span,{className:"cw-switch-knob",layout:!0,transition:{type:"spring",stiffness:520,damping:34}})})]})}function TIt(e,t){var r;let n=e;for(const i of t)if(n=(r=n.subAgents)==null?void 0:r[i],!n)return!1;return!0}function y_(e,t){let n=e;for(const r of t)n=n.subAgents[r];return n}function KE(e,t,n){if(t.length===0)return n(e);const[r,...i]=t,s=e.subAgents.slice();return s[r]=KE(s[r],i,n),{...e,subAgents:s}}function CIt(e,t,n="volcengine"){return KE(e,t,r=>({...r,subAgents:[...r.subAgents,Bl(n)]}))}function AIt(e,t,n,r="volcengine"){return KE(e,t,i=>{const s=i.subAgents.slice();return s.splice(n,0,Bl(r)),{...i,subAgents:s}})}function NIt(e,t){if(t.length===0)return e;const n=t.slice(0,-1),r=t[t.length-1];return KE(e,n,i=>({...i,subAgents:i.subAgents.filter((s,a)=>a!==r)}))}const a$=e=>!TR(e.agentType),Jee=3;function jIt(e,t,n=!1){var i;if(TR(e.agentType))return n?"远程 Agent 只能作为子 Agent":(i=e.a2aRegistry)!=null&&i.registrySpaceId.trim()?null:"缺少 AgentKit 智能体中心";const r=C1(e.name);return r||(t.has(e.name)?"Agent 名称在当前结构中必须唯一":e.description.trim().length===0?"缺少描述":(e.mcpTools??[]).some(Gwe)?"MCP 地址变化后需要确认认证方式":Iwe(e.agentType)?e.subAgents.length===0?"缺少子 Agent":null:e.instruction.trim().length===0?"缺少系统提示词":null)}function nSe(e,t,n=[]){const r=[],i=TR(e.agentType),s=jIt(e,t,n.length===0);return s&&r.push({path:n,name:i?"远程 Agent":e.name.trim()||"未命名",typeLabel:Rwe(e.agentType).label,problem:s}),a$(e)&&e.subAgents.forEach((a,l)=>r.push(...nSe(a,t,[...n,l]))),r}function RIt(e){return`${e.typeLabel}至少需要添加一个子 Agent 后才能调试或发布。`}function rSe(e){return 1+e.subAgents.reduce((t,n)=>t+rSe(n),0)}function o$(e,t=!1){const n=ZE(e),r=VC(n.draft).includes("mcp_resilience"),i=[],s={...n.envValues},a=n.draft.cloudProvider??"volcengine",l=_He(n.draft).map(Rv);let c=!1,u="";for(const h of kwe(n.draft,nl(a))){const m=[{key:h.apiKeyKey,required:!0,comment:h.label}];h.providerKey&&(m.push({key:h.providerKey,required:!0}),s[h.providerKey]=h.provider),h.apiBaseKey&&(m.push({key:h.apiBaseKey,required:!0}),s[h.apiBaseKey]=h.apiBase),i.push({env:m})}const d=h=>{var m,g,b,y;h.agentType==="llm"&&am(h,a)==="ark"&&(c=!0,u||(u=(h.modelName??"").trim()));for(const O of h.builtinTools??[]){const v=eO.find(x=>x.id===O);v&&i.push({env:Eb(v.env,a)})}for(const O of h.mcpTools??[])O.authTokenEnv&&i.push({env:[{key:O.authTokenEnv,required:!1,comment:`${O.name.trim()||"MCP"} Bearer Token`,secret:!0,readOnly:r,serverManaged:r,hidden:r}]});if((m=h.a2aRegistry)!=null&&m.enabled&&(i.push({env:Eb(hhe,a)}),Object.assign(s,eSe(h.a2aRegistry,{includeDefaults:!0},a))),h.memory.shortTerm&&i.push({env:Eb(((g=by.find(O=>O.id===(h.shortTermBackend??"local")))==null?void 0:g.env)??[],a)}),h.memory.longTerm&&i.push({env:Eb(((b=F4.find(O=>O.id===(h.longTermBackend??"local")))==null?void 0:b.env)??[],a)}),h.knowledgebase&&i.push({env:Eb(((y=z4.find(O=>O.id===(h.knowledgebaseBackend??jp)))==null?void 0:y.env)??[],a)}),h.tracing)for(const O of h.tracingExporters??[]){const v=mHe.find(x=>x.id===O);v&&i.push({env:v.env,enableFlag:v.enableFlag})}h.subAgents.forEach(d)};if(d(n.draft),c){i.push({env:[{key:"MODEL_AGENT_PROVIDER",required:!0},{key:"MODEL_AGENT_API_BASE",required:!0},{key:"MODEL_AGENT_API_KEY",required:!0,comment:"Ark API Key",placeholder:"由所选 API Key 注入",secret:!0,readOnly:!0,serverManaged:!0,requiredBy:l}]}),s.MODEL_AGENT_PROVIDER="openai",s.MODEL_AGENT_API_BASE=nl(a);const h=u||eh(a);s.MODEL_AGENT_NAME=h,s.MODEL_NAME=h}if(r){if(t){i.push({env:[{key:"MCP_SERVERS_JSON",required:!0,comment:"由已添加的 MCP 工具注入",placeholder:"由 Studio 服务端安全恢复",help:"更新时由 Studio 服务端合并 MCP 地址与认证,不向浏览器返回旧密钥。",readOnly:!0,serverManaged:!0,hidden:!0,requiredBy:[Rv("mcp_resilience")]}]});const g=t$(i);return{specs:g.specs,fixedValues:{...g.fixedValues,...s}}}const h=BRt(n.draft),m=h.ok?void 0:h.message;i.push({env:[{key:"MCP_SERVERS_JSON",required:!0,comment:"由已添加的 MCP 工具注入",placeholder:t?"由 Studio 服务端安全恢复":"由已添加的 HTTP MCP 工具自动生成",help:"Studio 服务端自动合并 MCP 地址与可选认证,不向浏览器返回旧密钥。",secret:!0,readOnly:!0,serverManaged:h.ok,hidden:!0,requiredBy:[Rv("mcp_resilience")],missingError:m}]})}const f=t$(i);return{specs:f.specs,fixedValues:{...f.fixedValues,...s}}}function IIt(e,t){const n=r=>(r??"").trim().replace(/\/+$/,"");return n(e)===n(t)}function DIt(e,t,n){const r=(e??"").trim();return!r||r===eh(t)?!0:r===eh(n)?!1:n==="byteplus"&&r.includes("doubao-")}function ng(e,t){const n=e.cloudProvider??"volcengine",r=am(e,n),i=e.subAgents.map(u=>ng(u,t)),s=r==="ark"&&DIt(e.modelName,n,t)?eh(t):e.modelName,l=IIt(e.modelApiBase,nl(n))||t==="byteplus"&&(e.modelApiBase??"").includes("volces.com")?nl(t):e.modelApiBase;return e.cloudProvider!==t||s!==e.modelName||l!==e.modelApiBase||i.some((u,d)=>u!==e.subAgents[d])?{...e,cloudProvider:t,modelName:s,modelApiBase:l,subAgents:i}:e}function PIt(e,t){var l;const n=ng(e,t),r=_we(n,nl(t)),i=new Set(r.map(({key:c})=>c)),s=((l=n.deployment)==null?void 0:l.envValues)??{},a=Object.fromEntries(Object.entries(s).filter(([c,u])=>i.has(c)&&!!u.trim()));return Object.keys(a).length===0?{draft:n,customModelSecretValues:a}:{draft:{...n,deployment:{...n.deployment??{feishuEnabled:!1},envValues:Object.fromEntries(Object.entries(s).filter(([c])=>!i.has(c)))}},customModelSecretValues:a}}function iv(e){var r,i,s;const t=ZE(e).draft;return{...Awe(t,t.cloudProvider??"volcengine"),deployment:{feishuEnabled:!!((r=e.deployment)!=null&&r.feishuEnabled),modelApiKeyId:((i=e.deployment)==null?void 0:i.modelApiKeyId)??"",modelApiKeyName:((s=e.deployment)==null?void 0:s.modelApiKeyName)??""}}}function l$(e){var n;const t=(n=e.modelName)==null?void 0:n.trim();if(t)return t;for(const r of e.subAgents){const i=l$(r);if(i)return i}return""}function iSe(e,t={}){var i,s,a,l;const n=o$(e),r={...((i=e.deployment)==null?void 0:i.envValues)??{},...t,...n.fixedValues};return{...iv(e),deployment:{feishuEnabled:!!((s=e.deployment)!=null&&s.feishuEnabled),modelApiKeyId:((a=e.deployment)==null?void 0:a.modelApiKeyId)??"",modelApiKeyName:((l=e.deployment)==null?void 0:l.modelApiKeyName)??"",envValues:Object.fromEntries(CU(n.specs,r).map(({key:c,value:u})=>[c,u]))}}}function MIt(e,t={}){return JSON.stringify(iSe(e,t))}function YA(e,t){return JSON.stringify({draftSnapshot:e,modelName:t.modelName,description:t.description,instruction:t.instruction})}function ty(e){return JSON.stringify({modelName:e.modelName.trim(),description:e.description.trim(),instruction:e.instruction.trim()})}function LIt({enabled:e,disabledReason:t,variants:n,draftSnapshot:r,input:i,onInput:s,onSend:a,onStartVariant:l,onUseVariant:c,onAddVariant:u,onRemoveVariant:d,onToggleConfig:f,onCompleteConfig:h,onConfigChange:m,onOpenTrace:g}){const b=n.filter(v=>v.phase!=="ready"?!1:v.runtimeSnapshot===YA(r,v)),y=n.some(v=>v.phase==="sending"),O=b.length>0&&!y;return o.jsxs("section",{className:"cw-ab-workspace","aria-label":"A/B 调试工作台",children:[o.jsx("div",{className:"cw-ab-stage",children:e?o.jsx("div",{className:"cw-ab-grid",style:{"--cw-ab-column-count":n.length},children:n.map((v,x)=>{const w=v.modelName.trim(),S=v.description.trim(),E=v.instruction.trim(),k=ty(v),_=!!(w&&S&&E&&n.findIndex(B=>ty(B)===k)!==x),T=!w||!S||!E||_,C=!!(v.runtimeSnapshot&&v.runtimeSnapshot!==YA(r,v)),A=v.phase==="starting",R=v.phase==="ready"&&!C,M=A||v.phase==="sending",I=R&&v.phase!=="sending"&&v.messages.some(B=>B.role==="assistant"),$=M||v.configOpen||T,N=w?S?E?_?"该配置与已有测试组相同":"":"请填写系统提示词":"请填写描述":"请先选择模型",j=A?"正在启动":C?"应用配置并重启":R||v.phase==="error"?"重新启动环境":"启动环境";return o.jsx("article",{className:"cw-ab-card",children:o.jsxs("div",{className:`cw-ab-card-inner${v.configOpen?" is-flipped":""}`,children:[o.jsxs("section",{className:"cw-ab-card-face cw-ab-card-front","aria-hidden":v.configOpen,children:[o.jsxs("header",{className:"cw-ab-card-head",children:[o.jsxs("div",{className:"cw-ab-card-title",children:[o.jsx("strong",{children:v.name}),o.jsx("span",{children:v.modelName||"默认模型"})]}),o.jsxs("div",{className:"cw-ab-card-actions",children:[o.jsx("button",{type:"button",className:"cw-ab-config-trigger",disabled:v.configOpen||M,onClick:()=>f(v.id),children:"测试配置"}),v.id!=="baseline"&&o.jsx("button",{type:"button",className:"cw-ab-remove","aria-label":`删除${v.name}`,disabled:v.configOpen||M,onClick:()=>d(v.id),children:o.jsx(Gee,{className:"cw-i"})})]})]}),o.jsx("div",{className:"cw-ab-conversation",children:v.error?o.jsx(t0,{message:v.error,className:"cw-debug-error-detail",defaultExpanded:!0}):A?o.jsxs("div",{className:"cw-ab-empty cw-ab-starting",children:[o.jsx(rr,{className:"cw-i cw-spin"}),o.jsx("span",{children:"正在创建独立测试环境"})]}):C?o.jsx("div",{className:"cw-ab-empty cw-ab-launch",children:o.jsx("span",{children:"配置已变更,请重新启动此环境"})}):v.messages.length===0?o.jsx("div",{className:"cw-ab-empty cw-ab-launch",children:R?o.jsxs(o.Fragment,{children:[o.jsx("strong",{className:"cw-ab-ready-title",children:"已就绪"}),o.jsx("span",{className:"cw-ab-launch-hint",children:"可在下方输入测试消息"})]}):o.jsx("span",{className:"cw-ab-launch-hint",children:N||"启动环境后即可加入本轮测试"})}):v.messages.map((B,F)=>o.jsx("div",{className:`cw-debug-msg cw-debug-msg-${B.role}`,children:o.jsx("div",{className:"cw-debug-content",children:B.role==="user"?B.content:B.error?o.jsx(t0,{message:B.error,className:"cw-debug-msg-error",defaultExpanded:!0}):B.blocks&&B.blocks.length>0?o.jsx(Fj,{blocks:B.blocks,onAction:()=>{}}):B.content?B.content:F===v.messages.length-1&&v.phase==="sending"?o.jsx(M0e,{}):null})},F))}),o.jsxs("footer",{className:"cw-ab-deploy-footer",children:[o.jsx("button",{type:"button",className:"cw-ab-trace",disabled:!I,title:I?`查看${v.name}调用链路`:"完成一次调试后可查看调用链路",onClick:()=>g(v.id),children:"调用链路"}),o.jsxs("button",{type:"button",className:"cw-ab-start cw-ab-footer-start",disabled:$,title:N||void 0,onClick:()=>l(v.id),children:[R||C||v.phase==="error"?o.jsx(Uae,{className:"cw-i"}):o.jsx(pIt,{className:"cw-i cw-debug-run-icon"}),j]}),o.jsx("button",{type:"button",className:"cw-ab-deploy",disabled:M||!w,onClick:()=>c(v.id),children:"使用该配置"})]})]}),o.jsxs("section",{className:"cw-ab-card-face cw-ab-card-back","aria-hidden":!v.configOpen,children:[o.jsxs("header",{className:"cw-ab-config-head",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"测试配置"}),o.jsx("span",{children:v.name})]}),o.jsxs("div",{className:"cw-ab-config-head-actions",children:[v.id!=="baseline"&&o.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger cw-ab-config-remove","aria-label":`删除${v.name}`,title:"删除配置组",disabled:M,onClick:()=>d(v.id),children:o.jsx(Gee,{className:"cw-i cw-i-sm"})}),o.jsxs("span",{className:`cw-ab-config-done-wrap${N?" is-disabled":""}`,tabIndex:N?0:void 0,children:[o.jsx("button",{type:"button",className:"cw-ab-config-done",disabled:!v.configOpen||T,onClick:()=>h(v.id),children:v.id==="baseline"?"完成配置":"完成并启动"}),N&&o.jsx("span",{className:"cw-ab-config-done-tip",role:"tooltip",children:N})]})]})]}),o.jsxs("div",{className:"cw-ab-config",children:[o.jsxs("label",{children:[o.jsx("span",{children:"模型"}),o.jsx("input",{value:v.modelName,placeholder:"使用 Agent 当前模型",disabled:!v.configOpen,onChange:B=>m(v.id,"modelName",B.target.value)})]}),o.jsxs("label",{children:[o.jsx("span",{children:"描述"}),o.jsx("textarea",{rows:2,value:v.description,disabled:!v.configOpen,onChange:B=>m(v.id,"description",B.target.value)})]}),o.jsxs("label",{children:[o.jsx("span",{children:"系统提示词"}),o.jsx("textarea",{rows:5,value:v.instruction,disabled:!v.configOpen,onChange:B=>m(v.id,"instruction",B.target.value)})]}),o.jsx("p",{children:"设置完成后返回正面,再启动当前测试环境。"})]})]})]})},v.id)})}):o.jsx("div",{className:"cw-debug-empty",children:t})}),o.jsxs("div",{className:"cw-ab-composer",children:[o.jsxs("div",{className:"cw-debug-composerbox",children:[o.jsx("textarea",{className:"cw-debug-input",rows:1,value:i,placeholder:O?"输入测试消息,将发送到所有已启动测试组...":"请先启动至少一个测试组",disabled:!O,onChange:v=>s(v.target.value),onKeyDown:v=>{SR(v.nativeEvent)||v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),a())}}),o.jsx("button",{type:"button",className:"cw-debug-send",title:"发送",disabled:!O||!i.trim(),onClick:a,children:y?o.jsx(rr,{className:"cw-i cw-spin"}):o.jsx(DRe,{className:"cw-i"})})]}),e&&n.length<3&&o.jsxs("button",{type:"button",className:"cw-btn cw-btn-soft cw-ab-add",onClick:u,children:[o.jsx(vo,{className:"cw-i"}),"添加对照组"]})]})]})}function $It({profile:e,optimizations:t,unavailableMessage:n,onProfileChange:r,onOptimizationChange:i}){return o.jsx("section",{className:"cw-optimize-workspace","aria-label":"智能体优化选项",children:o.jsxs("div",{className:"cw-optimize-panel",children:[n?o.jsxs("div",{className:"cw-banner",role:"alert",children:[o.jsx(Sd,{className:"cw-i"}),o.jsx("span",{children:n})]}):null,o.jsxs("fieldset",{className:"cw-optimize-section",children:[o.jsx("legend",{children:"优化场景"}),o.jsx(fa,{className:"cw-optimize-profile-options","aria-label":"优化场景",value:e,onChange:r,children:U7.map(s=>o.jsx("div",{className:`cw-optimize-profile-option${e===s.id?" is-on":""}`,children:o.jsx(fa.Item,{value:s.id,block:!0,className:"cw-optimize-profile-control",children:o.jsxs("span",{className:"cw-optimize-profile-copy",children:[o.jsx("strong",{children:s.displayName}),o.jsx("small",{children:s.description})]})})},s.id))})]}),o.jsxs("fieldset",{className:"cw-optimize-section",children:[o.jsx("legend",{children:"优化组件"}),o.jsx("div",{className:"cw-optimize-option-list",children:yHe.map(s=>o.jsxs("section",{className:"cw-optimize-option-group","aria-labelledby":`cw-optimize-group-${s.id}`,children:[o.jsx("h3",{id:`cw-optimize-group-${s.id}`,className:"cw-optimize-option-group-title",children:s.displayName}),o.jsx("div",{className:"cw-optimize-option-group-items",children:s.componentIds.map(a=>{const l=Q7.find(u=>u.id===a);if(!l)return null;const c=t.includes(l.id);return o.jsx(jU,{checked:c,onCheckedChange:u=>{const d=!!u;d!==c&&i(l.id,d)},label:o.jsxs("span",{className:"cw-optimize-option-copy",children:[o.jsx("strong",{children:l.displayName}),o.jsx("small",{children:l.description})]}),className:"cw-optimize-option"},l.id)})})]},s.id))})]})]})})}const O_=[{id:"build",label:"架构"},{id:"validate",label:"调试"},{id:"optimize",label:"优化"},{id:"environment",label:"环境"},{id:"publish",label:"发布"}],BIt={build:"个性化您的智能体架构",validate:"调试您的智能体",optimize:"为您的智能体选择优化项",environment:"配置云上环境",publish:"准备好部署您的智能体"};function QIt({mode:e}){return o.jsx("header",{className:"cw-workspace-header",children:o.jsx("h1",{children:BIt[e]})})}function UIt({mode:e,busy:t,onChange:n,assistant:r,accessory:i}){const s=O_.findIndex(c=>c.id===e),a=O_[s-1],l=O_[s+1];return o.jsxs("footer",{className:"cw-workspace-footer",children:[i?o.jsx("div",{className:"cw-workspace-footer-accessory",children:i}):null,o.jsxs("div",{className:`cw-workspace-nav-actions${r?" has-assistant":""}`,children:[o.jsx("button",{type:"button",className:`cw-workspace-nav-button${e==="build"?" is-placeholder":""}`,"aria-hidden":e==="build"||void 0,tabIndex:e==="build"?-1:0,disabled:!a||t,onClick:()=>a&&n(a.id),children:"上一步"}),o.jsx("span",{"aria-hidden":"true"}),r?o.jsx("div",{className:"cw-workspace-ai-slot",children:r}):null,e==="publish"?o.jsx("div",{id:"cw-publish-primary-action",className:"cw-publish-action-slot"}):o.jsx("button",{type:"button",className:"cw-workspace-nav-button is-primary",disabled:!l||t,onClick:()=>l&&n(l.id),children:"下一步"})]}),o.jsx("nav",{className:"cw-workspace-progress","aria-label":"Agent 创建进度",children:O_.map((c,u)=>{const d=c.id===e;return o.jsx("button",{type:"button",className:`${d?"is-active":""}${un(c.id),children:o.jsx("span",{"aria-hidden":"true"})},c.id)})})]})}function FIt({onBack:e,onCreate:t,onAgentAdded:n,initialDraft:r,features:i,onDeploymentTaskChange:s,createMode:a="custom",freshCreationSurface:l="traditional",workspaceDraftId:c,deploymentTarget:u,cloudProvider:d="volcengine",initialDeployRegion:f=Zr(d),onDeploymentComplete:h,onDeploymentStarted:m,onDraftChange:g,onDiscard:b}){var li,Ld,ll,xs,lo,vs,Ar,la,ca,fe,Je,St,dn,Zt,Tt,Lt,Ne,tn,or;const y=a==="custom"&&l==="vulcan",O=y&&!r,[v]=p.useState(()=>{const W=r??Bl(d),Te=O?{...W,name:W.name.trim()?W.name:"assistant",dynamicAgentDelegation:!0}:W;return PIt(Te,d)}),[x,w]=p.useState(v.draft),S=y,[E,k]=p.useState(v.customModelSecretValues),_=((li=x.deployment)==null?void 0:li.runtimeName)??"",T=u?u.name:wTt(x.name,_,(Ld=x.deployment)==null?void 0:Ld.runtimeNameCustomized),C=E;p.useEffect(()=>{w(W=>ng(W,d))},[d]);const[A,R]=p.useState(""),[M,I]=p.useState(!1),[$,N]=p.useState(!1),[j,B]=p.useState(!1),[F,L]=p.useState(null),H=A.trim(),z=H.length>0&&H.length{ge.current=g},[g]),p.useEffect(()=>{var W;K!==V.current&&(V.current=K,(W=ge.current)==null||W.call(ge,ng(x,d),se))},[d,x,se,K]);const[ie,q]=p.useState("build"),[G,J]=p.useState(!1),[ue,Oe]=p.useState(()=>new Set),[Qe,je]=p.useState(0),[ze,Ge]=p.useState(null),[Ae,Be]=p.useState(!1),[he,be]=p.useState((u==null?void 0:u.region)??f),Se=(i==null?void 0:i.generatedAgentTestRun)===!0,Ee=(i==null?void 0:i.generatedAgentTestRunDisabledReason)||"当前后端暂不支持生成 Agent 调试运行。",[tt,Ue]=p.useState(()=>{const W=ng(r??Bl(d),d);return[{id:"baseline",name:"基准组",modelName:l$(W),description:W.description,instruction:W.instruction,configOpen:!1,phase:"idle",runtimeSnapshot:"",messages:[],error:null}]}),[re,ce]=p.useState("baseline"),Me=p.useRef(1),Ye=p.useRef(!1),Z=p.useRef(new Map),[_e,rt]=p.useState(0),[Re,We]=p.useState(""),[ct,kt]=p.useState(null),[qt,Dt]=p.useState(!1),[Xe,nt]=p.useState(!1),ft=p.useRef(null),[xt,Ie]=p.useState(""),[xe,$e]=p.useState(!1),[it,ve]=p.useState(null),[He,pt]=p.useState(""),[_t,It]=p.useState(!1),[Kt,en]=p.useState(!1),[le,Xt]=p.useState([]),Fe=p.useRef(null),Pt=p.useRef({});async function Ce(){const W=new Set([...Z.current.values()].map(({run:dt})=>dt.runId)),Te=RU().filter(dt=>!W.has(dt));Te.length&&await Promise.all(Te.map(async dt=>{try{await pb(dt),kx(dt)}catch(nn){console.warn("清理遗留调试运行失败",nn)}}))}p.useEffect(()=>(Ce(),()=>{for(const{run:W}of Z.current.values())pb(W.runId).then(()=>kx(W.runId)).catch(Te=>console.warn("清理调试运行失败",Te));Z.current.clear()}),[]),p.useEffect(()=>()=>{var W;(W=ft.current)==null||W.call(ft,!1),ft.current=null},[]);const gt=p.useRef(null);gt.current||(gt.current=({meta:W,children:Te})=>o.jsxs("section",{ref:dt=>{Pt.current[W.id]=dt},id:`cw-sec-${W.id}`,"data-step-id":W.id,className:"cw-section",children:[o.jsx("header",{className:"cw-sec-head",children:o.jsx("h2",{className:"cw-sec-title",children:W.label})}),o.jsx("div",{className:"cw-sec-body",children:Te})]}));const Vt=TIt(x,le)?le:[],ot=y_(x,Vt),ln=Vt.length===0,Kn=Vt.join(".")||"root",_r=()=>{Oe(W=>W.has(Kn)?W:new Set(W).add(Kn))},Ve=`cw-a2a-registry-advanced-${Vt.join("-")||"root"}`,et=W=>w(Te=>KE(Te,Vt,dt=>({...dt,...W}))),mn=W=>w(Te=>{var dt;return{...Te,deployment:{...Te.deployment??{feishuEnabled:!1},envValues:{...((dt=Te.deployment)==null?void 0:dt.envValues)??{},...W}}}}),Mt=(W,Te)=>mn({[W]:Te}),ar=W=>et({a2aRegistry:{...ot.a2aRegistry??{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},...W}}),pr=(W,Te)=>{if(!(W in Wee))return;const dt=Wee[W];ar({[dt]:Te}),Mt(W,Te)},Gn=W=>{if(!(ln&&W==="a2a")){if(W==="a2a"){et({agentType:W,a2aRegistry:{...ot.a2aRegistry??{registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},enabled:!0}});return}et({agentType:W,a2aRegistry:ot.a2aRegistry?{...ot.a2aRegistry,enabled:!1}:void 0})}},zn=(W,Te)=>{w(W),Te&&Xt(Te)},Pr=async()=>{const W=A.trim();if(!(!W||M)&&!(W.length{const Te=y_(x,W);if(!a$(Te)||W.length>=Jee)return;const dt=CIt(x,W,d),nn=y_(dt,W).subAgents.length-1;zn(dt,[...W,nn])},Kr=(W,Te)=>{const dt=y_(x,W);if(!a$(dt)||W.length>=Jee)return;const nn=Math.max(0,Math.min(Te,dt.subAgents.length)),an=AIt(x,W,nn,d);zn(an,[...W,nn])},qr=()=>{window.confirm("清空根 Agent 的全部配置和子 Agent?此操作无法撤销。")&&(w(Bl(d)),Xt([]),J(!1))},mr=W=>{if(W.length===0){qr();return}zn(NIt(x,W),W.slice(0,-1))},Xr=ot.builtinTools??[],Tr=p.useMemo(()=>phe(d),[d]),oi=p.useMemo(()=>new Set(Tr.map(W=>W.id)),[Tr]),Ii=ot.mcpTools??[],bi=ot.selectedSkills??[],Jr=W=>{oi.has(W)&&et({builtinTools:Xr.includes(W)?Xr.filter(Te=>Te!==W):[...Xr,W]})},Di=Iwe(ot.agentType),rs=TR(ot.agentType),oa=wj(d),Qr=am(ot,d),Ws=W=>{var dt;const Te=W==="custom"&&Qr==="ark"?"":W==="ark"&&!((dt=ot.modelName)!=null&&dt.trim())?eh(d):ot.modelName;et({modelSource:W,modelName:Te})},is=p.useMemo(()=>JCt(x),[x]),ka=rs?null:C1(ot.name)??(is.has(ot.name)?"Agent 名称在当前结构中必须唯一":null),Ys=ka!==null,_a=G||ue.has(Kn),Ds=!rs&&ot.description.trim().length===0,Pi=ot.instruction.trim().length===0,Cr=rs&&!((ll=ot.a2aRegistry)!=null&&ll.registrySpaceId.trim()),yi=(W,Te=G)=>Te&&W?`is-error cw-error-shake-${Qe%2}`:"",bs=p.useMemo(()=>nSe(x,is),[x,is]),Ps=bs.length===0,pn=p.useMemo(()=>ng(x,d),[d,x]),Oi=kHe(x),Ur=VC(x),ys=xHe(d),pe=p.useMemo(()=>MIt(pn,C),[pn,C]),Le=tt.find(W=>W.id===re)??tt[0],At=p.useMemo(()=>o$(pn,(u==null?void 0:u.editMode)==="source-preserving"),[u==null?void 0:u.editMode,pn]),sn=p.useMemo(()=>_we(pn,nl(d)),[d,pn]),An=sn.find(W=>W.label===`${ot.name.trim()||"自定义模型"} 模型 API Key`),$r=p.useCallback(W=>{w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},modelApiKeyId:W.id,modelApiKeyName:W.name}}))},[]);function Gr(W){const Te=W.problem==="缺少子 Agent"?"type":"basic",dt=Pt.current[Te];dt==null||dt.scrollIntoView({behavior:"smooth",block:"start"});const nn=W.problem==="缺少描述"?"description":W.problem==="缺少系统提示词"?"instruction":W.problem==="缺少 AgentKit 智能体中心"?"a2a-registry":W.problem==="缺少子 Agent"||W.problem==="远程 Agent 只能作为子 Agent"?null:"name",an=nn?dt==null?void 0:dt.querySelector(`[data-validation-field="${nn}"]`):dt,on=an!=null&&an.matches('input, textarea, button:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])')?an:an==null?void 0:an.querySelector('input, textarea, button:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])');on==null||on.focus({preventScroll:!0})}const Zs=()=>Ps?!0:(J(!0),je(W=>W+1),bs[0]&&(Xt(bs[0].path),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>Gr(bs[0]))})),!1),Ta=async()=>{kt(null);const W=[...Z.current.values()];Z.current.clear(),rt(0),Ue(Te=>Te.map(dt=>({...dt,phase:"idle",runtimeSnapshot:"",messages:[],error:null}))),await Promise.all(W.map(async({run:Te})=>{try{await pb(Te.runId),kx(Te.runId)}catch(dt){console.warn("清理调试运行失败",dt)}}))},No=async W=>{const Te=Z.current.get(W);if(Te){Z.current.delete(W),rt(Z.current.size);try{await pb(Te.run.runId),kx(Te.run.runId)}catch(dt){console.warn("清理调试运行失败",dt)}}},Va=W=>{const Te=Z.current.get(W),dt=tt.find(nn=>nn.id===W);!Te||!dt||kt({runId:Te.run.runId,sessionId:Te.sessionId,variantName:dt.name})},Dd=W=>{const Te=ft.current;ft.current=null,Te==null||Te(W)},Ks=()=>{Xe||(Dt(!1),Dd(!1))},so=async()=>{if(!Xe){nt(!0);try{await Ta(),Dt(!1),Dd(!0)}finally{nt(!1)}}},jo=async()=>ie!=="validate"||_e===0?!0:ft.current?!1:new Promise(W=>{ft.current=W,Dt(!0)}),Pd=async W=>{if(await jo()){if(!Zs()){q("build");return}W&&ce(W),q("environment")}},ao=async W=>{var dt,nn;if(Ie(""),!Zs()){q("build");return}if((dt=pn.harnessSidecar)!=null&&dt.enabled&&ys){Ie(ys),q("optimize");return}const Te=n$(At.specs,((nn=pn.deployment)==null?void 0:nn.envValues)??{});if(Te){Ie(`${Te.spec.comment||Te.spec.key}:${Te.error}`),q("build");return}Be(!0);try{const an=W?tt.find(Wr=>Wr.id===W):Le;an&&ce(an.id);const on=an?EHe(pn,an):pn,er=await Cv(iv(on));w(on),Ge(er),q("publish")}catch(an){Ie(an instanceof Error?an.message:String(an))}finally{Be(!1)}},ol=async()=>{if(await jo()){if(!Zs()){q("build");return}q("optimize")}},oo=async W=>{if(!Se||Ae||!Zs())return;const Te=tt.find(Un=>Un.id===W);if(!Te||Te.phase==="starting"||Te.phase==="sending")return;const dt=Te.modelName.trim(),nn=Te.description.trim(),an=Te.instruction.trim(),on=ty(Te),er=tt.findIndex(Un=>Un.id===W),Wr=tt.findIndex(Un=>ty(Un)===on);if(!dt||!nn||!an||Wr!==er)return;const gr=YA(pe,Te);Ue(Un=>Un.map(_n=>_n.id===W?{..._n,configOpen:!1,phase:"starting",messages:[],error:null}:_n)),We("");let Nr=null,xn="unknown";const Jt=W==="baseline"?"baseline":"comparison",Ut=ZCt({agentId:String(pn.name||"unknown"),variantType:Jt});try{await No(W),await Ce();const Un={...pn,modelName:Te.modelName||pn.modelName,description:Te.description,instruction:Te.instruction};xn="create_test_run",Nr=await yle(iSe(Un,C),u?{runtimeId:u.runtimeId,region:u.region}:void 0),dIt(Nr.runId),xn="create_test_session";const _n=await Ole(Nr.runId,"test_user");Z.current.set(W,{run:Nr,sessionId:_n}),rt(Z.current.size),Ue(ci=>ci.map(co=>co.id===W?{...co,phase:"ready",runtimeSnapshot:gr}:co)),Ut.succeed({debugRunId:String(Nr.runId)})}catch(Un){if(Nr)try{await pb(Nr.runId),kx(Nr.runId)}catch(_n){console.warn("清理调试运行失败",_n)}Ue(_n=>_n.map(ci=>ci.id===W?{...ci,phase:"error",runtimeSnapshot:"",error:Un instanceof Error?Un.message:String(Un)}:ci)),Ut.fail({failedPhase:xn,...mo(Un,{phase:xn})})}},Yl=async()=>{const W=Re.trim(),Te=tt.filter(nn=>nn.phase==="ready"&&nn.runtimeSnapshot===YA(pe,nn)&&Z.current.has(nn.id));if(!W||Te.length===0)return;We("");const dt=new Set(Te.map(nn=>nn.id));Ue(nn=>nn.map(an=>dt.has(an.id)?{...an,phase:"sending",messages:[...an.messages,{role:"user",content:W},{role:"assistant",content:"",blocks:[]}]}:an)),await Promise.all(Te.map(async nn=>{const an=Z.current.get(nn.id);if(an)try{let on=Tf();for await(const er of vle({runId:an.run.runId,userId:"test_user",sessionId:an.sessionId,text:W})){const Wr=er.error||er.errorMessage||er.error_message;if(Wr||(on=wC(on,er)),Ue(gr=>gr.map(Nr=>{if(Nr.id!==nn.id)return Nr;const xn=[...Nr.messages],Jt={...xn[xn.length-1]};return Wr?Jt.error=String(Wr):(Jt.content=on.blocks.filter(Ut=>Ut.kind==="text").map(Ut=>Ut.text).join(""),Jt.blocks=on.blocks),xn[xn.length-1]=Jt,{...Nr,messages:xn}})),Wr)break}}catch(on){Ue(er=>er.map(Wr=>{if(Wr.id!==nn.id)return Wr;const gr=[...Wr.messages],Nr={...gr[gr.length-1]};return Nr.error=on instanceof Error?on.message:String(on),gr[gr.length-1]=Nr,{...Wr,messages:gr}}))}finally{Ue(on=>on.map(er=>er.id===nn.id?{...er,phase:"ready"}:er))}}))},Ru=()=>{Ue(W=>{if(W.length>=3)return W;const Te=Me.current++,dt=`variant-${Te}`;return[...W,{id:dt,name:`对照组 ${Te}`,modelName:x.modelName??"",description:x.description,instruction:x.instruction,configOpen:!0,phase:"idle",runtimeSnapshot:"",messages:[],error:null}]})},Fc=async W=>{await No(W),Ue(Te=>Te.filter(dt=>dt.id!==W)),re===W&&ce("baseline")},Iu=(W,Te)=>Ue(dt=>dt.map(nn=>nn.id===W?{...nn,...Te}:nn)),Ro=(W,Te)=>{if(Te&&ys){Ie(ys);return}const dt=Te?[...new Set([...Ur,W])]:Ur.filter(an=>an!==W),nn=Oi==="ops"?"default":Oi;w(an=>({...an,harnessSidecar:sg(dt,nn)})),Ie(""),Ge(null)},zc=W=>{const Te=F7(W);if(Te.length>0&&ys){Ie(ys);return}w(dt=>({...dt,harnessSidecar:sg(Te,W)})),Ie(""),Ge(null)},Zl=(W,Te,dt)=>{W==="baseline"&&Te==="modelName"&&(Ye.current=!0),Iu(W,{[Te]:dt}),!(re!==W||W==="baseline")&&ce("baseline")},Md=W=>{const Te=tt.find(gr=>gr.id===W);if(!Te)return;const dt=Te.modelName.trim(),nn=Te.description.trim(),an=Te.instruction.trim(),on=ty(Te),er=tt.findIndex(gr=>gr.id===W),Wr=tt.findIndex(gr=>ty(gr)===on);if(!(!dt||!nn||!an||Wr!==er)){if(W==="baseline"){Iu(W,{configOpen:!1});return}oo(W)}},kn=async(W,Te,dt)=>{var Wr,gr,Nr;const nn=(u==null?void 0:u.editMode)==="source-preserving",an=VC(x).includes("mcp_resilience"),on=(Wr=x.deployment)==null?void 0:Wr.network,er=on&&on.mode&&on.mode!=="public"?{mode:on.mode,vpc_id:on.vpcId,subnet_ids:on.subnetIds,enable_shared_internet_access:on.enableSharedInternetAccess}:void 0;return z1(W.name,W.files,{region:(u==null?void 0:u.region)??he,projectName:"default",network:er},{...dt,onStage:Te,runtimeId:u==null?void 0:u.runtimeId,runtimeName:(dt==null?void 0:dt.runtimeName)??T,appName:u==null?void 0:u.appName,editMode:u==null?void 0:u.editMode,draft:u||an?iv(x):void 0,updateEtag:u==null?void 0:u.etag,baseRuntimeVersion:u==null?void 0:u.currentVersion,envs:nn?[]:dt==null?void 0:dt.envs,mcpSecretValues:nn?DRt(x):an?IRt(x):void 0,mcpCredentialReuses:u?PRt(x):void 0,removeRuntimeEnvKeys:u?[...kRt(u.configuredMcpEnvKeys??[],x),...(gr=x.deployment)!=null&&gr.feishuEnabled?[]:["FEISHU_APP_ID","FEISHU_APP_SECRET"]]:void 0,description:x.description,harnessSidecar:x.harnessSidecar,environment:(Nr=x.cloudEnvironment)!=null&&Nr.environmentId?{environmentId:x.cloudEnvironment.environmentId,environmentVersionId:x.cloudEnvironment.environmentVersionId}:void 0})},Vc=()=>{Zs()&&(Ue(W=>W.map(Te=>Te.id==="baseline"&&!Z.current.has(Te.id)?{...Te,modelName:Ye.current?Te.modelName:l$(pn),description:pn.description,instruction:pn.instruction}:Te)),q("validate"))},_h=async W=>{if(W==="publish"){if(!await jo())return;await ao();return}if(W==="validate"){Vc();return}if(W==="optimize"){await ol();return}if(W==="environment"){Pd();return}await jo()&&q(W)},ae=W=>{w(Te=>({...Te,cloudEnvironment:W})),Ie(""),Ge(null)},In=async W=>{var Jt,Ut,Un,_n,ci,co,ym,Kl,_0,T0,ei,Du;if(xe||(pt(""),It(!1),!Zs()))return;const Te=WE(T.trim());if(Te){pt(Te);return}const dt={...pn,memory:{...pn.memory,shortTerm:W.sessionBackend!=="local"},shortTermBackend:W.sessionBackend},nn=o$(dt,(u==null?void 0:u.editMode)==="source-preserving"),an=(Jt=dt.deployment)==null?void 0:Jt.network;if((an==null?void 0:an.mode)!==void 0&&an.mode!=="public"&&!((Ut=an.vpcId)!=null&&Ut.trim())){pt("使用 VPC 网络时,请填写 VPC ID。");return}if(am(dt,d)==="ark"&&!((_n=(Un=dt.deployment)==null?void 0:Un.modelApiKeyId)!=null&&_n.trim())){pt("请先选择模型使用的 API Key。");return}const on={...((ci=dt.deployment)==null?void 0:ci.envValues)??{},...E,...nn.fixedValues},er=Object.keys(on).find(Io=>Io&&!/^[A-Za-z_][A-Za-z0-9_]*$/.test(Io));if(er){pt(`环境变量名称不合法:${er}`);return}const Wr=(co=dt.deployment)!=null&&co.feishuEnabled?[...nn.specs,...qx]:nn.specs,gr=ujt(Wr,on);if(gr){pt(`${gr.comment||gr.key}:请填写必填环境变量`);return}const Nr=n$(Wr,on);if(Nr){pt(`${Nr.spec.comment||Nr.spec.key}:${Nr.error}`);return}$e(!0),ve({level:"info",phase:"prepare",message:"正在生成部署配置",pct:0});let xn=null;try{if(!u&&!(await $N(T.trim(),he)).available)throw new Error("Runtime 名称已存在,请修改后重试。");const Io=await Cv(iv(dt));Ge(Io);const Pu=crypto.randomUUID(),Jl=Date.now();let Hc="prepare",ec="准备部署",tc="正在生成部署配置";const cl={id:Pu,...c?{draftId:c}:{},agentName:dt.name,runtimeName:T.trim(),region:he,startedAt:Jl,agentDraft:dt},Th={...cl,status:"running",phase:Hc,label:ec,message:tc,pct:0};xn=Th,s==null||s(Th),m==null||m(Th);const $d=new Map(Object.entries(on).map(([xi,tr])=>[xi.trim(),tr]).filter(([xi,tr])=>xi&&tr.trim()));for(const xi of CU(Wr,on))$d.set(xi.key,xi.value);const Et=(Kl=(ym=dt.deployment)==null?void 0:ym.modelApiKeyId)==null?void 0:Kl.trim(),Bd=(T0=(_0=dt.deployment)==null?void 0:_0.modelApiKeyName)==null?void 0:T0.trim();Et&&$d.set("MODEL_AGENT_API_KEY_ID",Et),Bd&&$d.set("MODEL_AGENT_API_KEY_NAME",Bd);const qc=await kn(Io,xi=>{Hc=xi.phase,ec=xi.phase==="build"?"构建镜像":xi.phase==="deploy"?"部署 Runtime":xi.phase==="publish"?"发布服务":"部署中",tc=xi.message,ve(xi),s==null||s({...cl,runtimeName:xi.runtimeName||cl.runtimeName,status:"running",phase:Hc,label:ec,message:tc,pct:xi.pct,...xi.buildLog?{buildLog:xi.buildLog}:{}})},{taskId:Pu,runtimeName:T.trim(),sessionStorage:W.sessionStorage,minInstance:W.minInstance,maxInstance:W.maxInstance,authentication:W.authentication,createEvaluationSets:W.createEvaluationSets,resources:W.resources,...(ei=dt.deployment)!=null&&ei.feishuEnabled?{im:{feishu:{enabled:!0}}}:{},envs:[...$d].map(([xi,tr])=>({key:xi,value:tr}))});It(!0),ve({level:"success",phase:"complete",message:"部署已完成",pct:100}),s==null||s({...cl,runtimeName:qc.runtimeName||cl.runtimeName,runtimeId:qc.runtimeId,region:qc.region||he,status:"success",phase:"complete",label:"部署完成",message:(Du=qc.warnings)==null?void 0:Du.join(";"),pct:100}),await(h==null?void 0:h(qc))}catch(Io){const Pu=Io instanceof Error?Io.message:String(Io);pt(Pu),ve(null);const Jl={...xn??{id:crypto.randomUUID(),agentName:pn.name||"未命名智能体",runtimeName:T.trim(),region:he,startedAt:Date.now()},status:"error",phase:xn==null?void 0:xn.phase,label:"部署失败",message:Pu,retry:()=>In(W)};s==null||s(Jl)}finally{$e(!1)}},Vn=gt.current,Os=W=>hIt.find(Te=>Te.id===W),Jn=o.jsx("section",{className:`cw-ai-compose${M?" is-generating":""}${$?" is-success":""}`,"aria-label":"AI 自动填写 Agent 配置",children:o.jsx(fu,{initial:!1,mode:"wait",children:$?o.jsxs(ai.div,{className:"cw-ai-compose-success",role:"status",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.22,ease:[.22,1,.36,1]},children:[o.jsx("span",{className:"cw-ai-success-check","aria-hidden":!0}),o.jsx("strong",{children:"生成成功"}),o.jsx("button",{type:"button",className:"cw-ai-regenerate",onClick:()=>N(!1),children:"重新生成"})]},"success"):o.jsxs(ai.div,{className:"cw-ai-compose-entry",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.2,ease:[.22,1,.36,1]},children:[o.jsxs("form",{className:"cw-ai-compose-form",onSubmit:W=>{W.preventDefault(),Pr()},children:[o.jsx("input",{type:"text",value:A,maxLength:8e3,disabled:M,placeholder:`描述目标,使用 ${p5e(d)} 模型一键生成配置`,"aria-invalid":!!z,"aria-describedby":z?"ai-requirement-error":void 0,onChange:W=>R(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),Pr())}}),o.jsx("button",{type:"submit",disabled:M||!H||!!z,"aria-label":M?"正在智能生成":"智能生成",children:M?o.jsx("span",{className:"cw-ai-orb","aria-hidden":!0,children:o.jsx("span",{})}):"智能生成"})]}),z&&o.jsx("p",{className:"cw-ai-requirement-error",id:"ai-requirement-error",role:"alert",children:z})]},"compose")})});return S?o.jsx(YRt,{draft:pn,cloudProvider:d,deployRegion:he,runtimeName:T,isRuntimeUpdate:!!u,deploying:xe,deployStage:it,deployError:He,deploySucceeded:_t,showErrors:G,onBack:e,onDraftPatch:W=>{w(Te=>({...Te,...W})),Ge(null),Ie("")},onDeploymentPatch:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},...W}})),onModelApiKeyChange:$r,customModelApiKey:An?E[An.key]??"":"",onCustomModelApiKeyChange:W=>{An&&k(Te=>({...Te,[An.key]:W}))},onSelectedSkillsChange:W=>w(Te=>({...Te,selectedSkills:W})),onCloudEnvironmentChange:ae,onDeployRegionChange:be,onRuntimeNameChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},runtimeName:W,runtimeNameCustomized:!0}})),onNetworkChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},network:W}})),onDeploy:W=>void In(W)}):o.jsxs("div",{className:`cw-root is-${ie}`,children:[o.jsx(QIt,{mode:ie}),xt&&o.jsx(t0,{className:"cw-workspace-alert",message:xt}),o.jsxs("main",{className:"cw-workspace-main",id:"cw-workspace-main",children:[ie==="build"&&o.jsx("div",{className:"cw-build-workspace",children:o.jsxs("div",{className:"cw-editor",children:[o.jsx(zw,{draft:x,direction:"horizontal",selectedPath:Vt,onSelect:Xt,onAdd:Lr,onInsert:Kr,onDelete:mr}),o.jsx("div",{className:"cw-detail",children:o.jsx("div",{className:"cw-detail-scroll",ref:Fe,children:o.jsx("div",{className:"cw-detail-inner",children:o.jsx("div",{className:"cw-lower",children:o.jsxs("div",{className:"cw-form-col",children:[o.jsxs(Vn,{meta:Os("type"),children:[o.jsx(fa,{className:"cw-agent-type-options","aria-label":"Agent 类型",value:ot.agentType??"llm",onChange:Gn,children:hRt.map(W=>{const Te=(ot.agentType??"llm")===W.id,dt=ln&&W.id==="a2a",nn=dt?"cw-remote-agent-disabled-hint":void 0;return o.jsxs("div",{"data-agent-type":W.id,className:`cw-agent-type-option ${Te?"is-on":""} ${dt?"is-disabled":""}`,tabIndex:dt?0:void 0,"aria-describedby":nn,children:[o.jsx(fa.Item,{value:W.id,disabled:dt,block:!0,className:"cw-agent-type-control",children:o.jsx("span",{className:"cw-agent-type-copy",children:o.jsx("strong",{children:mIt[W.id]})})}),dt&&o.jsx("span",{id:nn,className:"cw-agent-type-disabled-hint",role:"tooltip",children:"远程智能体只能作为子步骤使用"})]},W.id)})}),G&&Di&&ot.subAgents.length===0&&o.jsx("span",{className:"cw-error-text",children:RIt({name:ot.name.trim()||"未命名",typeLabel:Rwe(ot.agentType).label})})]}),o.jsx(Vn,{meta:Os("basic"),children:o.jsxs("div",{className:"cw-form",children:[!rs&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"cw-field",children:[o.jsxs("label",{className:"cw-label",children:[ln?"Agent 名称":"名称",o.jsx("span",{className:"cw-req",children:"*"})]}),o.jsx("input",{className:`cw-input ${yi(Ys,_a)}`,"data-validation-field":"name",value:ot.name,placeholder:"assistant","aria-invalid":_a&&Ys,"aria-describedby":_a&&ka?"cw-agent-name-error":void 0,onBlur:_r,onChange:W=>{_r(),et({name:W.target.value})}}),_a&&ka?o.jsx("span",{id:"cw-agent-name-error",role:"alert",className:"cw-error-text",children:ka}):o.jsx("span",{className:"cw-help",children:"遵循 Google ADK 命名规则,且在执行流程中保持唯一。"})]}),o.jsxs("div",{className:"cw-field",children:[o.jsxs("label",{className:"cw-label",children:[ln?"描述":"智能体描述",o.jsx("span",{className:"cw-req",children:"*"})]}),o.jsx("textarea",{className:`cw-textarea cw-textarea-sm ${yi(Ds)}`,"data-validation-field":"description",value:ot.description,placeholder:"简要描述这个 Agent 的用途,便于团队识别…","aria-invalid":G&&Ds,"aria-describedby":G&&Ds?"cw-agent-description-error":void 0,onChange:W=>et({description:W.target.value})}),G&&Ds?o.jsx("span",{id:"cw-agent-description-error",role:"alert",className:"cw-error-text",children:"描述为必填项"}):o.jsx("span",{className:"cw-help",children:ln?"完整描述会保留;部署时会自动整理为符合 Runtime 规范的单行描述。":"描述会显示在 Agent 列表与选择器中。"})]})]}),Di?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"cw-section-desc cw-dependency-hint",children:"这是一个协作容器,本身不生成回答。请在左侧画布中 添加任务步骤,并通过拖拽调整它们的位置。"}),ot.agentType==="loop"&&o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"最大轮次"}),o.jsx("input",{className:"cw-input",type:"number",min:1,value:ot.maxIterations??3,onChange:W=>et({maxIterations:Math.max(1,Number(W.target.value)||1)})}),o.jsx("span",{className:"cw-help",children:"循环编排反复执行子 Agent,直到满足条件或达到该轮次上限。"})]})]}):rs?o.jsxs("div",{className:"cw-field cw-remote-center-fields","data-validation-field":"a2a-registry",children:[o.jsxs("div",{className:"cw-remote-center-head",children:[o.jsxs("div",{className:"cw-label",children:["AgentKit 智能体中心",o.jsx("span",{className:"cw-req",children:"*"})]}),o.jsx("p",{className:"cw-help cw-remote-center-description",children:"远程 Agent 的名称、描述和能力来自中心返回的 Agent Card。 系统会根据每轮任务动态发现并挂载匹配的 Agent。"})]}),o.jsx(SIt,{value:((xs=ot.a2aRegistry)==null?void 0:xs.registrySpaceId)??"",region:((lo=ot.a2aRegistry)==null?void 0:lo.registryRegion)||oa.region,invalid:G&&Cr,onChange:W=>pr(Jwe,W)}),o.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":Kt,"aria-controls":Ve,onClick:()=>en(W=>!W),children:[o.jsx("span",{children:"更多选项"}),o.jsx(XS,{className:`cw-more-options-chevron ${Kt?"is-open":""}`,"aria-hidden":!0})]}),o.jsx(fu,{initial:!1,children:Kt&&o.jsx(ai.div,{id:Ve,className:"cw-model-advanced",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeOut"},children:o.jsx(_x,{env:Eb(gIt,d),values:eSe(ot.a2aRegistry,{includeDefaults:!1},d),onChange:pr})})}),G&&Cr&&o.jsx("span",{className:"cw-error-text",role:"alert",children:"请选择 AgentKit 智能体中心"})]}):o.jsxs("div",{className:"cw-field","data-validation-field":"instruction",children:[o.jsxs("label",{className:"cw-label",children:["系统提示词",o.jsx("span",{className:"cw-req",children:"*"})]}),o.jsx(p.Suspense,{fallback:o.jsx("div",{className:"cw-markdown-loading",role:"status",children:"正在加载 Markdown 编辑器…"}),children:o.jsx(uIt,{value:ot.instruction,invalid:Pi,onChange:W=>et({instruction:W})})}),G&&Pi?o.jsx("span",{className:"cw-error-text",role:"alert",children:"系统提示词为必填项"}):o.jsx("span",{className:"cw-help",children:"支持 Markdown 快捷输入,例如键入 ## 加空格创建二级标题。"})]})]})}),!Di&&!rs&&o.jsxs(o.Fragment,{children:[o.jsx(Vn,{meta:Os("model"),children:o.jsxs("div",{className:"cw-form",children:[o.jsxs("div",{className:"cw-field cw-model-source-field",children:[o.jsx("label",{className:"cw-label",children:"模型来源"}),o.jsx(fa,{className:"cw-model-source-options","aria-label":"模型来源",value:Qr,onChange:W=>{W!=="gateway"&&Ws(W)},children:[{value:"ark",label:d==="byteplus"?"BytePlus ModelArk":"火山方舟"},{value:"custom",label:"自定义"},{value:"gateway",label:"模型网关",disabled:!0}].map(W=>o.jsx("div",{className:`cw-model-source-option ${Qr===W.value?"is-on":""}${W.disabled?" is-disabled":""}`,children:o.jsxs(fa.Item,{value:W.value,disabled:W.disabled,block:!0,className:"cw-model-source-control",children:[o.jsx("span",{children:W.label}),W.disabled&&o.jsx("span",{className:"cw-model-source-coming-soon",children:"待上线"})]})},W.value))})]}),Qr==="ark"?o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"模型配置"}),o.jsx(wIt,{value:ot.modelName??"",cloudProvider:d,apiKeyId:(vs=x.deployment)==null?void 0:vs.modelApiKeyId,apiKeyName:(Ar=x.deployment)==null?void 0:Ar.modelApiKeyName,onApiKeyChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},modelApiKeyId:W.id,modelApiKeyName:W.name}})),onChange:W=>et({modelName:W})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"模型名称"}),o.jsx("input",{className:"cw-input",value:ot.modelName??"",onChange:W=>et({modelName:W.target.value})})]}),o.jsxs("div",{className:"cw-field",children:[o.jsxs("label",{className:"cw-label cw-label-with-link",children:[o.jsx("span",{children:"服务商 Provider"}),o.jsxs("a",{href:"https://docs.litellm.ai/docs/providers",target:"_blank",rel:"noopener noreferrer",onClick:W=>W.stopPropagation(),children:["LiteLLM 支持列表",o.jsx(Dg,{"aria-hidden":"true"})]})]}),o.jsx("input",{className:"cw-input",value:ot.modelProvider??"",placeholder:"openai",onChange:W=>et({modelProvider:W.target.value})})]}),o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"API Base"}),o.jsx("input",{className:"cw-input",value:ot.modelApiBase??"",placeholder:nl(d),onChange:W=>et({modelApiBase:W.target.value})})]}),o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"API Key"}),o.jsx("input",{className:"cw-input",type:"password",value:An?E[An.key]??"":"",placeholder:"请输入模型 API Key",autoComplete:"new-password",onChange:W=>{if(!An)return;const Te=W.currentTarget.value;k(dt=>({...dt,[An.key]:Te}))}})]})]})]})}),o.jsx(Vn,{meta:Os("tools"),children:o.jsxs("div",{className:"cw-form",children:[o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"内置工具"}),o.jsx("span",{className:"cw-help",children:"勾选 VeADK 提供的内置能力,生成时会自动补全 import 与所需环境变量。"}),o.jsx("div",{className:"cw-tools-list-shell",children:o.jsx(bIt,{items:Tr,selected:Xr,onToggle:Jr,scrollRows:6})}),o.jsx(fu,{initial:!1,children:Xr.includes("run_code")&&o.jsxs(ai.div,{className:"cw-tool-config",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:"easeOut"},children:[o.jsxs("div",{className:"cw-tool-config-head",children:[o.jsx("span",{className:"cw-label",children:"代码执行配置"}),o.jsx("span",{className:"cw-help",children:"指定 AgentKit 代码执行沙箱。"})]}),o.jsx(_x,{env:((la=eO.find(W=>W.id==="run_code"))==null?void 0:la.env)??[],values:((ca=x.deployment)==null?void 0:ca.envValues)??{},onChange:Mt})]})})]}),o.jsxs("div",{className:"cw-field cw-mcp-field",children:[o.jsx("label",{className:"cw-label",children:"MCP 工具"}),o.jsx(_It,{tools:Ii,onChange:W=>et({mcpTools:W})})]})]})}),o.jsx(Vn,{meta:Os("skills"),children:o.jsx("div",{className:"cw-form",children:o.jsx(mU,{selected:bi,onChange:W=>et({selectedSkills:W}),cloudProvider:d})})}),o.jsx(Vn,{meta:Os("knowledge"),children:o.jsxs("div",{className:"cw-form cw-toggle-stack",children:[o.jsx(b_,{checked:ot.knowledgebase,onChange:W=>et({knowledgebase:W}),title:"知识库",desc:"启用外部知识检索(RAG),让 Agent 基于你的资料作答。",icon:U_}),ot.knowledgebase&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"知识库后端"}),o.jsx(i3,{options:z4,value:ot.knowledgebaseBackend,onChange:W=>et({knowledgebaseBackend:W,knowledgebaseIndex:W==="viking"||W==="openviking"?ot.knowledgebaseIndex:""})}),(ot.knowledgebaseBackend??jp)==="viking"&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"VikingDB 知识库"}),o.jsx(EIt,{value:ot.knowledgebaseIndex??"",onChange:W=>{et({knowledgebaseIndex:W.id}),W.projectName&&Mt("DATABASE_VIKING_PROJECT",W.projectName),W.region&&Mt("DATABASE_VIKING_REGION",W.region),W.sourceKind&&Mt("DATABASE_VIKING_COLLECTION_KIND",W.sourceKind),Mt("DATABASE_VIKING_RESOURCE_ID",W.resourceId??"")}})]}),o.jsx(_x,{env:((fe=z4.find(W=>W.id===(ot.knowledgebaseBackend??jp)))==null?void 0:fe.env)??[],values:((Je=x.deployment)==null?void 0:Je.envValues)??{},onChange:Mt,renderAfterField:(ot.knowledgebaseBackend??jp)==="openviking"?W=>W.key==="DATABASE_OPENVIKING_USER_ID"?o.jsx(OIt,{value:ot.knowledgebaseIndex??"",onChange:Te=>et({knowledgebaseIndex:Te})}):null:void 0})]})]})}),ln&&o.jsx(Vn,{meta:Os("memory"),children:o.jsxs("div",{className:"cw-form cw-toggle-stack",children:[o.jsx(b_,{checked:ot.memory.shortTerm,onChange:W=>et({memory:{...ot.memory,shortTerm:W}}),title:"短期记忆",desc:"存储单会话上下文",showDescription:!0,icon:Bae}),ot.memory.shortTerm&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"短期记忆后端"}),o.jsx(i3,{options:by,value:ot.shortTermBackend,onChange:W=>et({shortTermBackend:W})}),o.jsx(_x,{env:((St=by.find(W=>W.id===(ot.shortTermBackend??"local")))==null?void 0:St.env)??[],values:((dn=x.deployment)==null?void 0:dn.envValues)??{},onChange:Mt})]}),o.jsx(b_,{checked:ot.memory.longTerm,onChange:W=>et({memory:{...ot.memory,longTerm:W}}),title:"长期记忆",desc:"存储跨会话上下文,通常使用向量化检索",showDescription:!0,icon:U_}),ot.memory.longTerm&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"长期记忆后端"}),o.jsx(i3,{options:F4,value:ot.longTermBackend,onChange:W=>et({longTermBackend:W,longTermMemoryIndex:W==="viking"?ot.longTermMemoryIndex:""})}),(ot.longTermBackend??"local")==="viking"&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"VikingDB 记忆库"}),o.jsx(kIt,{value:ot.longTermMemoryIndex??"",onChange:W=>{et({longTermMemoryIndex:W.id}),Mt("DATABASE_VIKINGMEM_PROJECT",W.projectName),Mt("DATABASE_VIKING_REGION",W.region),Mt("DATABASE_VIKINGMEM_MEMORY_TYPE",(W.memoryTypes??[]).join(","))}})]}),o.jsx(_x,{env:((Zt=F4.find(W=>W.id===(ot.longTermBackend??"local")))==null?void 0:Zt.env)??[],values:((Tt=x.deployment)==null?void 0:Tt.envValues)??{},onChange:Mt}),o.jsx(b_,{checked:!!ot.autoSaveSession,onChange:W=>et({autoSaveSession:W}),title:"自动保存会话到长期记忆",desc:"会话结束时自动把内容写入长期记忆,无需手动调用。",icon:U_})]})]})})]})]})})})})})]})}),ie==="validate"&&o.jsx("div",{className:"cw-validation-workspace",children:o.jsx("div",{className:"cw-validation-content",children:o.jsx(LIt,{enabled:Se,disabledReason:Ee,variants:tt,draftSnapshot:pe,input:Re,onInput:We,onSend:Yl,onStartVariant:oo,onUseVariant:W=>void Pd(W),onAddVariant:Ru,onRemoveVariant:Fc,onToggleConfig:W=>{const Te=tt.find(dt=>dt.id===W);Te&&Iu(W,{configOpen:!Te.configOpen})},onCompleteConfig:Md,onConfigChange:Zl,onOpenTrace:Va})})}),ie==="optimize"&&o.jsx($It,{profile:Oi,optimizations:Ur,unavailableMessage:ys,onProfileChange:zc,onOptimizationChange:Ro}),ie==="environment"&&o.jsx("div",{className:"cw-environment-workspace",children:o.jsx(Ywe,{value:x.cloudEnvironment??{environmentId:"",environmentVersionId:""},onChange:ae,disabled:Ae})}),ie==="publish"&&o.jsx("div",{className:"cw-preview-body",children:ze?o.jsx(_R,{embedded:!0,cloudProvider:d,project:ze,agentDraft:x,agentName:x.name||"未命名 Agent",agentCount:rSe(x),releaseConfiguration:Le?{modelName:Le.modelName||x.modelName||"默认模型",description:Le.description,instruction:Le.instruction,optimizations:[`优化场景:${ghe(Oi)}`,...Ur.map(Rv)]}:void 0,onChange:Ge,onDeploy:kn,onAgentAdded:n,onDeploymentTaskChange:s,deploymentActionLabel:u?"更新并发布":"部署",deploymentActionTargetId:"cw-publish-primary-action",deploymentRuntimeId:u==null?void 0:u.runtimeId,deploymentRuntimeName:T,deploymentRuntimeNameCustomized:!!u||!!((Lt=x.deployment)!=null&&Lt.runtimeNameCustomized),onDeploymentRuntimeNameChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},runtimeName:W,runtimeNameCustomized:!0}})),onDeploymentStarted:m,onDeploymentComplete:h,feishuEnabled:!!((Ne=x.deployment)!=null&&Ne.feishuEnabled),configuredRuntimeEnvKeys:u==null?void 0:u.configuredRuntimeEnvKeys,onFeishuEnabledChange:async W=>{const Te={...x,deployment:{...x.deployment??{feishuEnabled:!1},feishuEnabled:W}},dt=await Cv(iv(Te));w(Te),Ge(dt)},deploymentEnv:At.specs,requiredSecretEnv:sn,requiredSecretEnvValues:E,onRequiredSecretEnvChange:(W,Te)=>k(dt=>({...dt,[W]:Te})),deploymentEnvValues:{...(tn=pn.deployment)==null?void 0:tn.envValues,...E,...At.fixedValues},onDeploymentEnvChange:Mt,onFeishuCredentialsChange:(W,Te)=>mn({FEISHU_APP_ID:W,FEISHU_APP_SECRET:Te}),network:(or=x.deployment)==null?void 0:or.network,onNetworkChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},network:W}})),deployRegion:he,onDeployRegionChange:be,deploymentTelemetry:{source:"scratch",createMode:a,aiAssisted:j},onExportYaml:()=>fIt(`${pn.name||"agent"}.yaml`,MRt(pn),"text/yaml")}):o.jsxs("div",{className:"cw-publish-loading",role:"status",children:[o.jsx(rr,{className:"cw-i cw-spin"}),o.jsx("strong",{children:"正在生成发布配置"}),o.jsx("span",{children:"校验 Agent 结构并准备部署快照…"})]})})]}),o.jsx(UIt,{mode:ie,busy:Ae,onChange:_h,assistant:ie==="build"?Jn:void 0}),ct&&o.jsx(Zwe,{testRunId:ct.runId,sessionId:ct.sessionId,title:`调用链路 · ${ct.variantName}`,onClose:()=>kt(null)}),qt&&o.jsx(ql,{variant:"warning",title:"离开调试?",description:"离开调试页面后,当前环境将被清理。您可以通过重新启动环境进行新的测试。",confirmLabel:Xe?"清理中...":"确定离开",closeLabel:"关闭离开调试确认",busy:Xe,onCancel:Ks,onConfirm:()=>void so()}),F&&o.jsx("div",{className:"confirm-scrim",onClick:()=>L(null),children:o.jsxs("div",{className:"confirm-box cw-ai-error-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"ai-generate-error-title","aria-describedby":"ai-generate-error-message",onClick:W=>W.stopPropagation(),children:[o.jsx("div",{className:"confirm-title",id:"ai-generate-error-title",children:"智能生成失败"}),o.jsx("div",{className:"cw-ai-error-message",id:"ai-generate-error-message",children:F}),o.jsx("div",{className:"confirm-actions",children:o.jsx("button",{type:"button",className:"confirm-btn cw-ai-error-close",onClick:()=>L(null),children:"关闭"})})]})})]})}function Kc({name:e}){const t={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};switch(e){case"branch":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"6",cy:"5",r:"2"}),o.jsx("circle",{cx:"18",cy:"7",r:"2"}),o.jsx("circle",{cx:"18",cy:"17",r:"2"}),o.jsx("path",{d:"M8 5h2.5A3.5 3.5 0 0 1 14 8.5v7A1.5 1.5 0 0 0 15.5 17H16"}),o.jsx("path",{d:"M14 10.5v-2A1.5 1.5 0 0 1 15.5 7H16"})]});case"plan":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M6.5 3.5h11a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2h-11a2 2 0 0 1-2-2v-13a2 2 0 0 1 2-2Z"}),o.jsx("path",{d:"m8 9 1.4 1.4L12 7.8M13.5 10H16M8 15l1.4 1.4 2.6-2.6M13.5 16H16"})]});case"collaborate":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"8",cy:"8",r:"3"}),o.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),o.jsx("path",{d:"M3.5 19a4.5 4.5 0 0 1 9 0M13.5 15.5A4 4 0 0 1 20.5 18"})]});case"summary":return o.jsx("svg",{...t,children:o.jsx("path",{d:"M5 4h14v16H5zM8 8h8M8 12h8M8 16h5"})});case"skills":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M5 5h5v5H5zM14 5h5v5h-5zM5 14h5v5H5z"}),o.jsx("path",{d:"M14 16.5h5M16.5 14v5"})]});case"trace":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"6",cy:"6",r:"2"}),o.jsx("circle",{cx:"18",cy:"12",r:"2"}),o.jsx("circle",{cx:"8",cy:"18",r:"2"}),o.jsx("path",{d:"M8 6h3a3 3 0 0 1 3 3v0a3 3 0 0 0 2 2.83M16.2 13.2 9.8 16.8"})]});case"structure":return o.jsxs("svg",{...t,children:[o.jsx("rect",{x:"3.5",y:"4",width:"7",height:"5",rx:"1"}),o.jsx("rect",{x:"13.5",y:"15",width:"7",height:"5",rx:"1"}),o.jsx("path",{d:"M10.5 6.5h3A3.5 3.5 0 0 1 17 10v5M7 9v7a2 2 0 0 0 2 2h4.5"})]});case"model":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M8 3.5v3M16 3.5v3M8 17.5v3M16 17.5v3M3.5 8h3M17.5 8h3M3.5 16h3M17.5 16h3"}),o.jsx("rect",{x:"6.5",y:"6.5",width:"11",height:"11",rx:"2"}),o.jsx("path",{d:"M10 10h4v4h-4z"})]});case"environment":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M4 7.5h16M7 4h10l3 3.5v10L17 20H7l-3-2.5v-10Z"}),o.jsx("path",{d:"m8 12 2 2-2 2M12.5 16H16"})]});case"deploy":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M12 3.5v11M7.5 8 12 3.5 16.5 8"}),o.jsx("path",{d:"M5 13.5v5A1.5 1.5 0 0 0 6.5 20h11a1.5 1.5 0 0 0 1.5-1.5v-5"})]});case"workflow":return o.jsxs("svg",{...t,children:[o.jsx("rect",{x:"4",y:"4",width:"6",height:"5",rx:"1"}),o.jsx("rect",{x:"14",y:"15",width:"6",height:"5",rx:"1"}),o.jsx("path",{d:"M10 6.5h2a4 4 0 0 1 4 4V15M7 9v3a4 4 0 0 0 4 4h3"})]})}}function zIt({onSelectVulcan:e,onSelectTraditional:t}){const n=J8(),[r,i]=p.useState(!1),s=p.useRef(null),a=c=>{if(!r){if(n){c();return}s.current=c,i(!0)}},l=()=>{if(!r)return;const c=s.current;s.current=null,c==null||c()};return o.jsx(ai.main,{className:`agent-creation-mode-picker${r?" is-leaving":""}`,initial:n?!1:{opacity:0},animate:{opacity:r?0:1},transition:{duration:r?.12:.18,ease:[.16,1,.3,1]},onAnimationComplete:l,children:o.jsxs("section",{className:"agent-creation-mode-picker__content","aria-labelledby":"agent-creation-mode-picker-title",children:[o.jsxs("header",{className:"agent-creation-mode-picker__header",children:[o.jsx("h1",{id:"agent-creation-mode-picker-title",children:"选择创建方式"}),o.jsx("p",{children:"以不同模式构建您的智能体"})]}),o.jsxs("div",{className:"agent-creation-mode-picker__options",children:[o.jsxs(jt,{type:"button",className:"agent-creation-mode-picker__card",color:"secondary",variant:"outline",pill:!1,block:!0,onClick:()=>a(e),children:[o.jsxs("span",{className:"agent-creation-mode-picker__card-header",children:[o.jsx(u1,{className:"agent-creation-mode-picker__avatar is-vulcan",seed:"快速模式"}),o.jsxs("span",{className:"agent-creation-mode-picker__card-copy",children:[o.jsx("span",{className:"agent-creation-mode-picker__card-title",children:"快速模式"}),o.jsx("span",{className:"agent-creation-mode-picker__card-description",children:"动态派生子智能体自主完成任务"})]})]}),o.jsx("span",{className:"agent-creation-mode-picker__divider","aria-hidden":"true"}),o.jsxs("span",{className:"agent-creation-mode-picker__features",children:[o.jsx("span",{children:"特性"}),o.jsxs("span",{className:"agent-creation-mode-picker__feature-grid",children:[o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"branch"})}),o.jsx("span",{children:"动态派生子智能体"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"plan"})}),o.jsx("span",{children:"自主规划执行"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"collaborate"})}),o.jsx("span",{children:"多智能体协作"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"summary"})}),o.jsx("span",{children:"自动汇总结果"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"skills"})}),o.jsx("span",{children:"按需调用技能"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"trace"})}),o.jsx("span",{children:"任务过程可追踪"})]})]})]})]}),o.jsxs(jt,{type:"button",className:"agent-creation-mode-picker__card",color:"secondary",variant:"outline",pill:!1,block:!0,onClick:()=>a(t),children:[o.jsxs("span",{className:"agent-creation-mode-picker__card-header",children:[o.jsx(u1,{className:"agent-creation-mode-picker__avatar is-traditional",seed:"传统模式"}),o.jsxs("span",{className:"agent-creation-mode-picker__card-copy",children:[o.jsx("span",{className:"agent-creation-mode-picker__card-title",children:"传统模式"}),o.jsx("span",{className:"agent-creation-mode-picker__card-description",children:"高度自定义您的智能体结构"})]})]}),o.jsx("span",{className:"agent-creation-mode-picker__divider","aria-hidden":"true"}),o.jsxs("span",{className:"agent-creation-mode-picker__features",children:[o.jsx("span",{children:"特性"}),o.jsxs("span",{className:"agent-creation-mode-picker__feature-grid",children:[o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"structure"})}),o.jsx("span",{children:"可视化配置"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"model"})}),o.jsx("span",{children:"存量智能体迁移"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"environment"})}),o.jsx("span",{children:"实时调试"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"deploy"})}),o.jsx("span",{children:"可选性能优化"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"workflow"})}),o.jsx("span",{children:"精细参数控制"})]})]})]})]})]})]})})}const ete=50*1024*1024,c$=800,VIt={name:"code_package",files:[]};function HIt(e){let n=e.replace(/\.zip$/i,"").trim().replace(/[^A-Za-z0-9_]+/g,"_").replace(/^_+|_+$/g,"");return n||(n="uploaded_agent"),/^[A-Za-z_]/.test(n)||(n=`agent_${n}`),n==="user"&&(n="uploaded_agent"),n.slice(0,64)}function sSe(e){const t=e.replace(/\\/g,"/").replace(/^\.\//,"");if(!t||t.endsWith("/"))return null;if(t.startsWith("/")||t.includes("\0"))throw new Error(`压缩包包含非法路径:${e}`);const n=t.split("/");if(n.some(r=>!r||r==="."||r===".."))throw new Error(`压缩包包含非法路径:${e}`);return n[0]==="__MACOSX"||n[n.length-1]===".DS_Store"?null:n.join("/")}function qIt(e){const t=e.flatMap(a=>{const l=sSe(a.name);return l?[{path:l,content:a.text}]:[]});if(t.length===0)throw new Error("压缩包中没有可部署的文件。");if(t.length>c$)throw new Error(`代码包文件数不能超过 ${c$} 个。`);const i=new Set(t.map(a=>a.path.split("/")[0])).size===1&&t.every(a=>a.path.includes("/"))?t.map(a=>({...a,path:a.path.split("/").slice(1).join("/")})):t,s=new Set;for(const a of i){if(s.has(a.path))throw new Error(`代码包包含重复文件:${a.path}`);s.add(a.path)}return XIt(i),i}function XIt(e){const t=new Set(e.map(i=>i.path)),n=e.find(i=>i.path==="agentkit.yaml");let r="app.py";if(n){let i;try{i=xht(n.content)}catch(l){throw new Error(`agentkit.yaml 无法解析:${l instanceof Error?l.message:String(l)}`)}if(i!==null&&(typeof i!="object"||Array.isArray(i)))throw new Error("agentkit.yaml 根节点必须是对象。");const s=i&&typeof i=="object"&&!Array.isArray(i)?i.common:void 0;if(s!==void 0&&(s===null||typeof s!="object"||Array.isArray(s)))throw new Error("agentkit.yaml 的 common 必须是对象。");const a=s&&typeof s=="object"&&!Array.isArray(s)?s.entry_point:void 0;if(a!==void 0){if(typeof a!="string")throw new Error("agentkit.yaml 的 common.entry_point 必须是文件路径。");const l=sSe(a);if(!l)throw new Error("agentkit.yaml 的 common.entry_point 不是有效文件路径。");r=l}}if(!t.has(r))throw n&&r!=="app.py"?new Error(`代码包中不存在 agentkit.yaml 声明的启动入口:${r}`):new Error("代码包根目录必须包含 app.py,或在 agentkit.yaml 的 common.entry_point 中声明已有入口。");return r}function GIt({onBack:e,onAgentAdded:t,onDeploymentTaskChange:n,onDeploymentStarted:r,onDeploymentComplete:i,cloudProvider:s="volcengine",initialDeployRegion:a=Zr(s)}){const l=p.useRef(null),c=p.useRef(0),[u,d]=p.useState(null),[f,h]=p.useState(""),[m,g]=p.useState(!1),[b,y]=p.useState(!1),[O,v]=p.useState(!1),[x,w]=p.useState(""),[S,E]=p.useState(a),[k,_]=p.useState();p.useEffect(()=>()=>{c.current+=1},[]);async function T(M){const I=++c.current;if(w(""),!M.name.toLowerCase().endsWith(".zip")){w("请选择 .zip 格式的代码包。");return}if(M.size>ete){w("代码包不能超过 50 MB。");return}y(!0);try{const $=await Nve(new Uint8Array(await M.arrayBuffer()),{maxEntries:c$,maxUncompressedBytes:ete}),N=qIt($);if(I!==c.current)return;h(M.name),d({name:HIt(M.name),files:N})}catch($){if(I!==c.current)return;h(""),d(null),w($ instanceof Error?$.message:String($))}finally{I===c.current&&y(!1)}}function C(M){var $;const I=($=M.currentTarget.files)==null?void 0:$[0];M.currentTarget.value="",I&&T(I)}function A(M){var $;M.preventDefault(),v(!1);const I=($=M.dataTransfer.files)==null?void 0:$[0];I&&T(I)}async function R(M,I,$){const N=k&&k.mode!=="public"?{mode:k.mode,vpc_id:k.vpcId,subnet_ids:k.subnetIds,enable_shared_internet_access:k.enableSharedInternetAccess}:void 0;return z1(M.name,M.files,{region:S,projectName:"default",network:N},{...$,onStage:I})}return o.jsxs("div",{className:"package-create package-create-preview",children:[o.jsx(_R,{cloudProvider:s,project:u??VIt,agentName:(u==null?void 0:u.name)||"代码包",onChange:u?d:void 0,onDeploy:R,onAgentAdded:t,onDeploymentTaskChange:n,onDeploymentStarted:r,onDeploymentComplete:i,network:k,onNetworkChange:_,deployRegion:S,onDeployRegionChange:E,deploymentTelemetry:{source:"code_package",createMode:"code_package",aiAssisted:!1},onBack:e,backLabel:"返回创建方式",deployDisabled:!u||b,deployDisabledReason:b?"正在读取代码包":u?void 0:"请先上传代码包",deploymentPrimaryPane:o.jsxs("section",{className:"package-source-pane","aria-label":"代码包上传",children:[o.jsx("div",{className:"package-source-label",children:"代码包"}),o.jsxs("div",{className:`package-dropzone${O?" is-dragging":""}${u?" is-ready":""}`,onDragEnter:M=>{M.preventDefault(),v(!0)},onDragOver:M=>M.preventDefault(),onDragLeave:M=>{M.currentTarget.contains(M.relatedTarget)||v(!1)},onDrop:A,onClick:()=>{var M;b||(M=l.current)==null||M.click()},onKeyDown:M=>{var I;!b&&(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),(I=l.current)==null||I.click())},role:"button",tabIndex:b?-1:0,"aria-label":u?"重新上传代码包":"上传代码包","aria-disabled":b,children:[o.jsx("strong",{children:b?"正在读取代码包…":u?f:"请上传代码包"}),o.jsx("span",{children:u?`已识别 ${u.files.length} 个文件,点击区域可重新上传`:"点击或拖拽上传,支持 .zip 格式,最大 50 MB;可使用 app.py,或由 agentkit.yaml 声明入口"}),o.jsx("div",{className:"package-upload-actions",children:u&&o.jsx("button",{type:"button",className:"package-upload-secondary",onClick:M=>{M.stopPropagation(),g(!0)},onKeyDown:M=>M.stopPropagation(),children:"查看文件"})}),o.jsx("input",{ref:l,type:"file",accept:".zip,application/zip","aria-label":"选择代码包",onChange:C})]}),x&&o.jsx("div",{className:"package-create-error",role:"alert",children:x})]})}),u&&o.jsx(Jw,{project:u,open:m,onClose:()=>g(!1),onChange:d})]})}const WIt="/web/agent-migrations",AR=39e4;class Uo extends Error{constructor(t,n,r="MIGRATION_ERROR",i=!1,s="",a=""){super(t),this.status=n,this.code=r,this.retryable=i,this.statusText=s,this.rawResponse=a,this.name="MigrationApiError"}}const YIt=new Set(["langchain","langgraph","adk","strands","agentcore","dify","any"]),ZIt=new Set(["awaiting_upload","analyzing","needs_input","analysis_ready","migrating","validating","packaging","succeeded","succeeded_with_warnings","partial","failed","cancelled","expired"]),KIt=new Set(["reasoning","message","plan","command","status"]),JIt=new Set(["running","completed","failed"]),e5t=new Set(["pending","in_progress","completed","failed"]);function Mr(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function hg(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"))throw new Error(`${t}格式错误。`);return e}function nw(e,t){if(typeof e!="string"||!YIt.has(e))throw new Error(`${t}格式错误。`);return e}function t5t(e){const t=Mr(e,"迁移分析结果"),n=t.recommended===null?null:Mr(t.recommended,"迁移建议"),r=Mr(t.boundary,"迁移边界");if(t.schema_version!==1||!["needs_input","recommendation_ready","unsupported"].includes(String(t.status))||typeof t.attempt!="number"||typeof t.input_sha256!="string"||typeof t.summary!="string"||!Array.isArray(t.frameworks)||!Array.isArray(t.entries)||!Array.isArray(t.questions))throw new Error("迁移分析结果格式错误。");return{schema_version:1,status:t.status,attempt:t.attempt,input_sha256:t.input_sha256,summary:t.summary,frameworks:t.frameworks.map(i=>{const s=Mr(i,"框架候选");if(!["high","medium","low"].includes(String(s.confidence))||!Array.isArray(s.evidence))throw new Error("框架候选格式错误。");return{id:nw(s.id,"框架候选"),confidence:s.confidence,evidence:s.evidence.map(a=>{const l=Mr(a,"分析证据");if(typeof l.path!="string"||typeof l.line!="number"||typeof l.reason!="string")throw new Error("分析证据格式错误。");return{path:l.path,line:l.line,reason:l.reason}})}}),recommended:n===null?null:{framework:nw(n.framework,"推荐框架"),entry:n.entry===null||typeof n.entry=="string"?n.entry:null,reason:typeof n.reason=="string"?n.reason:""},entries:t.entries.map(i=>{const s=Mr(i,"入口候选");if(typeof s.value!="string"||typeof s.evidence!="string")throw new Error("入口候选格式错误。");return{value:s.value,framework:nw(s.framework,"入口框架"),evidence:s.evidence}}),boundary:{include:hg(r.include,"迁移包含范围"),exclude:hg(r.exclude,"迁移排除范围")},assumptions:hg(t.assumptions,"分析假设"),questions:t.questions.map(i=>{const s=Mr(i,"待确认问题");if(typeof s.id!="string"||typeof s.prompt!="string"||typeof s.required!="boolean")throw new Error("待确认问题格式错误。");return{id:s.id,prompt:s.prompt,required:s.required}}),warnings:hg(t.warnings,"迁移警告")}}function E0(e){const t=Mr(e,"迁移会话"),n=Mr(t.artifact,"迁移产物状态");if(typeof t.id!="string"||typeof t.state!="string"||!ZIt.has(t.state)||typeof t.message!="string"||typeof t.sourceFileName!="string"||typeof t.instruction!="string"||typeof t.createdAt!="string"&&typeof t.createdAt!="number"||typeof t.expiresAt!="string"||typeof t.sessionTtlSeconds!="number"||typeof t.canModify!="boolean"||typeof t.canUpload!="boolean"||typeof t.canAnswer!="boolean"||typeof t.canConfirm!="boolean"||typeof t.canStop!="boolean")throw new Error("迁移会话格式错误。");const r={id:t.id,state:t.state,message:t.message,sourceFileName:t.sourceFileName,instruction:t.instruction,createdAt:t.createdAt,expiresAt:t.expiresAt,sessionTtlSeconds:t.sessionTtlSeconds,canModify:t.canModify,canUpload:t.canUpload,canAnswer:t.canAnswer,canConfirm:t.canConfirm,canStop:t.canStop,artifact:{state:typeof n.state=="string"?n.state:"none",previewReady:n.previewReady===!0,downloadReady:n.downloadReady===!0,deployReady:n.deployReady===!0}};if(typeof t.modelId=="string"&&t.modelId.trim()&&(r.modelId=t.modelId),t.analysis!==void 0&&(r.analysis=t5t(t.analysis)),t.analysisRef!==void 0){const i=Mr(t.analysisRef,"分析结果引用");if(typeof i.attempt!="number"||typeof i.sha256!="string"||typeof i.inputSha256!="string")throw new Error("分析结果引用格式错误。");r.analysisRef={attempt:i.attempt,sha256:i.sha256,inputSha256:i.inputSha256}}if(t.confirmation!==void 0){const i=Mr(t.confirmation,"迁移确认");r.confirmation={...i.framework!==void 0?{framework:nw(i.framework,"确认框架")}:{},...i.entry===null||typeof i.entry=="string"?{entry:i.entry}:{},...typeof i.app_name=="string"?{app_name:i.app_name}:{}}}if(t.error!==void 0){const i=Mr(t.error,"迁移错误");r.error={code:typeof i.code=="string"?i.code:"MIGRATION_ERROR",message:typeof i.message=="string"?i.message:t.message,retryable:i.retryable===!0}}if(t.persistence!==void 0){const i=Mr(t.persistence,"迁移源码保存状态");if(!["saving","saved","failed","unavailable"].includes(String(i.state))||typeof i.message!="string"||i.projectId!==void 0&&typeof i.projectId!="string"||i.versionId!==void 0&&typeof i.versionId!="string"||i.retryable!==void 0&&typeof i.retryable!="boolean")throw new Error("迁移源码保存状态格式错误。");r.persistence={state:i.state,message:i.message,...typeof i.projectId=="string"?{projectId:i.projectId}:{},...typeof i.versionId=="string"?{versionId:i.versionId}:{},...typeof i.retryable=="boolean"?{retryable:i.retryable}:{}}}return r}function n5t(e){const t=Mr(e,"迁移执行动态");if(typeof t.available!="boolean"||typeof t.complete!="boolean"||!Array.isArray(t.items))throw new Error("迁移执行动态格式错误。");return{available:t.available,complete:t.complete,items:t.items.map(n=>{const r=Mr(n,"迁移执行动态项");if(typeof r.id!="string"||typeof r.kind!="string"||!KIt.has(r.kind)||typeof r.status!="string"||!JIt.has(r.status)||typeof r.title!="string"||r.detail!==void 0&&typeof r.detail!="string")throw new Error("迁移执行动态项格式错误。");let i;if(r.tool!==void 0){const a=Mr(r.tool,"迁移执行工具项");if(typeof a.name!="string"||a.error!==void 0&&typeof a.error!="string"||a.exitCode!==void 0&&!Number.isInteger(a.exitCode))throw new Error("迁移执行工具项格式错误。");i={name:a.name,...Object.prototype.hasOwnProperty.call(a,"input")?{input:a.input}:{},...Object.prototype.hasOwnProperty.call(a,"output")?{output:a.output}:{},...typeof a.error=="string"?{error:a.error}:{},...typeof a.exitCode=="number"?{exitCode:a.exitCode}:{}}}let s;if(r.plan!==void 0){if(!Array.isArray(r.plan))throw new Error("迁移执行计划格式错误。");s=r.plan.map(a=>{const l=Mr(a,"迁移执行计划项");if(typeof l.text!="string"||typeof l.status!="string"||!e5t.has(l.status))throw new Error("迁移执行计划项格式错误。");return{text:l.text,status:l.status}})}return{id:r.id,kind:r.kind,status:r.status,title:r.title,...typeof r.detail=="string"?{detail:r.detail}:{},...i?{tool:i}:{},...s?{plan:s}:{}}})}}function r5t(e){const t=Mr(e,"迁移产物"),n=Mr(t.cli,"CLI 信息"),r=Mr(t.migration,"迁移信息"),i=Mr(t.startup,"启动信息"),s=Mr(t.environment,"环境变量信息"),a=Mr(t.verification,"校验信息"),l=Mr(t.report,"迁移报告"),c=Mr(t.artifact,"产物归档"),u=s.defaults===void 0?{}:Mr(s.defaults,"环境变量默认值");if(t.schema_version!==1||!["succeeded","succeeded_with_warnings","partial"].includes(String(t.status))||typeof n.name!="string"||typeof n.version!="string"||!["structured","agentic"].includes(String(r.engine))||typeof r.framework!="string"||!Array.isArray(t.files)||typeof i.module!="string"||typeof i.object!="string"||!["passed","failed","degraded"].includes(String(a.status))||!Array.isArray(a.checks)||typeof l.path!="string"||c.path!=="migration-result.zip"||typeof c.size!="number"||typeof c.sha256!="string"||typeof t.created_at!="string")throw new Error("迁移产物格式错误。");const d=hg(s.required,"必需环境变量"),f=hg(s.optional,"可选环境变量"),h=new Set([...d,...f]),m=Object.fromEntries(Object.entries(u).map(([g,b])=>{if(!h.has(g)||typeof b!="string")throw new Error("环境变量默认值格式错误。");return[g,b]}));return{schema_version:1,...typeof t.run_id=="string"?{run_id:t.run_id}:{},cli:{name:n.name,version:n.version},migration:{engine:r.engine,framework:r.framework,...typeof r.entry=="string"?{entry:r.entry}:{},...typeof r.source_sha256=="string"?{source_sha256:r.source_sha256}:{},...typeof r.provenance_sha256=="string"?{provenance_sha256:r.provenance_sha256}:{}},status:t.status,files:t.files.map(g=>{const b=Mr(g,"迁移产物文件");if(typeof b.path!="string"||typeof b.size!="number"||typeof b.sha256!="string"||typeof b.mode!="string")throw new Error("迁移产物文件格式错误。");return{path:b.path,size:b.size,sha256:b.sha256,mode:b.mode}}),startup:{module:i.module,object:i.object,...Array.isArray(i.command)&&i.command.every(g=>typeof g=="string")?{command:i.command}:{}},environment:{required:d,optional:f,defaults:m},verification:{status:a.status,checks:a.checks.map(g=>{const b=Mr(g,"迁移校验项");if(typeof b.name!="string"||!["passed","failed"].includes(String(b.status)))throw new Error("迁移校验项格式错误。");return{name:b.name,status:b.status,...typeof b.detail=="string"?{detail:b.detail}:{}}})},warnings:hg(t.warnings,"迁移产物警告"),report:{path:l.path},artifact:{path:"migration-result.zip",size:c.size,sha256:c.sha256},created_at:t.created_at}}async function Uc(e,t={},n=Ao){return fetch(So(`${WIt}${e}`),{...t,headers:ph(t.headers),signal:il(t.signal,n)})}function i5t(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t))return"";const n=t,r=Array.isArray(n.loc)?n.loc.filter(s=>typeof s=="string"||typeof s=="number").join("."):"",i=typeof n.msg=="string"?n.msg:"";return i?r?`${r}: ${i}`:i:""}).filter(Boolean).join(";"):""}async function PU(e,t){var r;const n=await e.text().catch(()=>"");try{const i=Mr(JSON.parse(n),"错误响应");if(Array.isArray(i.detail)){const a=i5t(i.detail);return new Uo(a?`请求参数校验失败:${a}`:t,e.status,"MIGRATION_REQUEST_INVALID",!1,e.statusText,n)}if(typeof i.detail=="string")return new Uo(i.detail,e.status,typeof i.code=="string"?i.code:"MIGRATION_ERROR",i.retryable===!0,e.statusText,n);const s=i.detail&&typeof i.detail=="object"?Mr(i.detail,"错误详情"):i;return new Uo(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"MIGRATION_ERROR",s.retryable===!0,e.statusText,n)}catch{const i=((r=e.headers.get("content-type"))==null?void 0:r.split(";",1)[0])||"Content-Type 缺失";return new Uo(`${t}(HTTP ${e.status},Content-Type: ${i})。请检查代理或网关配置。`,e.status,"MIGRATION_ERROR",!1,e.statusText,n)}}async function Id(e,t){if(!e.ok)throw await PU(e,t);if(!(e.headers.get("content-type")??"").includes("application/json"))throw new Uo(`${t}:服务端返回非 JSON 响应(HTTP ${e.status})。请检查代理或网关配置。`,e.status,"MIGRATION_RESPONSE_INVALID",!1,e.statusText);return e.json()}async function s5t(e){const t=Mr(await Id(await Uc("/capabilities",{signal:e}),"读取迁移能力失败"),"迁移能力");if(typeof t.enabled!="boolean"||typeof t.reason!="string"||typeof t.maxUploadBytes!="number"||typeof t.sessionTtlSeconds!="number"||!Array.isArray(t.frameworks))throw new Error("迁移能力格式错误。");const n={enabled:t.enabled,reason:t.reason,maxUploadBytes:t.maxUploadBytes,sessionTtlSeconds:t.sessionTtlSeconds,frameworks:t.frameworks.map(r=>nw(r,"迁移框架"))};if(t.model!==void 0){const r=Mr(t.model,"迁移模型能力");if(typeof r.configured!="boolean"||typeof r.id!="string")throw new Error("迁移模型能力格式错误。");n.model={configured:r.configured,id:r.id}}return n}async function o3(e){const t=Mr(await Id(await Uc("/tasks",{signal:e}),"读取迁移会话失败"),"迁移会话列表");if(!Array.isArray(t.items))throw new Error("迁移会话列表格式错误。");return t.items.map(E0)}async function a5t(e){return E0(await Id(await Uc("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.taskId,sourceFileName:e.sourceFileName,instruction:e.instruction,...e.modelId?{modelId:e.modelId}:{}}),signal:e.signal},AR),"创建迁移会话失败"))}async function tte(e,t,n){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e)}/source`,{method:"PUT",headers:{"Content-Type":"application/zip"},body:t,signal:n},AR),"上传迁移项目失败"))}async function l3(e,t){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取迁移会话失败"))}async function o5t(e,t){return n5t(await Id(await Uc(`/tasks/${encodeURIComponent(e)}/activity`,{signal:t,cache:"no-store"}),"读取迁移执行动态失败"))}async function l5t(e){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e.taskId)}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({framework:e.framework,entry:e.entry||null,appName:e.appName,instruction:e.instruction,analysisAttempt:e.analysisAttempt,analysisSha256:e.analysisSha256,inputSha256:e.inputSha256,boundaryConfirmed:!0}),signal:e.signal},AR),"启动迁移失败"))}async function c5t(e){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e.taskId)}/answers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({analysisAttempt:e.analysisAttempt,analysisSha256:e.analysisSha256,inputSha256:e.inputSha256,answers:e.answers}),signal:e.signal},AR),"提交分析补充信息失败"))}async function u5t(e,t){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e)}/stop`,{method:"POST",signal:t}),"终止迁移失败"))}async function d5t(e,t){return r5t(await Id(await Uc(`/tasks/${encodeURIComponent(e)}/artifact`,{signal:t}),"读取迁移产物失败"))}async function f5t(e,t,n){var s;const r=new URLSearchParams({path:t}),i=await Uc(`/tasks/${encodeURIComponent(e)}/artifact/file?${r}`,{signal:n},es);if(!i.ok)throw await PU(i,"读取迁移产物文件失败");return{blob:await i.blob(),mimeType:((s=i.headers.get("content-type"))==null?void 0:s.split(";",1)[0])||"application/octet-stream"}}function h5t(e,t){var r;return((r=(e.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:r[1])||t}async function p5t(e,t,n){const r=await Uc(`/tasks/${encodeURIComponent(e)}/download`,{signal:n},es);if(!r.ok)throw await PU(r,"下载迁移产物失败");const i=URL.createObjectURL(await r.blob()),s=document.createElement("a");s.href=i,s.download=h5t(r,`${t}-migrated.zip`),s.click(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3)}function k0({children:e,...t}){return o.jsx("svg",{...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e})}function m5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"m10 6-6 6 6 6M4 12h16"})})}function g5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M12 3v12m-4-4 4 4 4-4M5 20h14"})})}function sv(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M6 3.5h8l4 4V20H6zM14 3.5v4h4M9 12h6M9 15.5h6"})})}function b5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M12 5v14M5 12h14"})})}function y5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M14.5 4.5c2.3-.9 4.2-.8 5-.6.2.8.3 2.7-.6 5l-5.1 5.1-3.8-3.8zM15.4 8.6h.1M10.3 10.5l-3.8.7-2.1 2.1 5.3.2M13.5 13.7l-.7 3.8-2.1 2.1-.2-5.3M7.2 16.8l-2.8 2.8"})})}function O5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M12 16V4m-4 4 4-4 4 4M5 20h14"})})}function nte(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}function x5t(e){return e.flatMap(t=>{if(t.kind==="reasoning"&&t.detail)return[{kind:"thinking",text:t.detail,done:t.status!=="running"}];if(t.kind==="message"&&t.detail)return[{kind:"text",text:t.detail}];if(t.kind==="plan")return[{kind:"plan",title:t.title,summary:t.detail,items:t.plan??[],done:t.status!=="running"}];if(t.kind==="command"){const n=t.tool,r=n!=null&&n.error||typeof(n==null?void 0:n.exitCode)=="number"?{...n.output!==void 0?{output:n.output}:{},...n.error?{error:n.error}:{},...typeof n.exitCode=="number"?{exitCode:n.exitCode}:{}}:n==null?void 0:n.output;return[{kind:"tool",name:(n==null?void 0:n.name)??t.title,args:n==null?void 0:n.input,response:r,done:t.status!=="running",status:t.status,...t.status==="failed"?{defaultOpen:!0}:{}}]}return t.kind==="status"&&t.status!=="completed"?[{kind:"tool",name:t.title,response:t.detail,done:t.status!=="running",status:t.status,...t.status==="failed"?{defaultOpen:!0}:{}}]:[]})}function v5t({baseVersion:e,capabilities:t,loading:n,preparationStage:r,error:i,onCancel:s,onClose:a,onCreate:l}){const c=p.useId(),u=p.useRef(null),d=r!==null,f=p.useRef(d),h=p.useRef(a);return f.current=d,h.current=a,p.useEffect(()=>{const m=document.body.style.overflow,g=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var y,O;(O=(y=u.current)==null?void 0:y.querySelector("textarea"))==null||O.focus()});const b=y=>{if(y.key==="Escape"){f.current||h.current();return}if(y.key!=="Tab"||!u.current)return;const O=[...u.current.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')].filter(w=>w.offsetParent!==null);if(O.length===0)return;const v=O[0],x=O[O.length-1];y.shiftKey&&document.activeElement===v?(y.preventDefault(),x.focus()):!y.shiftKey&&document.activeElement===x&&(y.preventDefault(),v.focus())};return window.addEventListener("keydown",b),()=>{document.body.style.overflow=m,window.removeEventListener("keydown",b),g!=null&&g.isConnected&&g.focus()}},[]),kr.createPortal(o.jsx("div",{className:"migration-optimize-backdrop",onMouseDown:m=>{m.target===m.currentTarget&&!d&&a()},children:o.jsxs("section",{ref:u,className:"migration-optimize-dialog",role:"dialog","aria-modal":"true","aria-labelledby":c,"aria-busy":d||void 0,children:[o.jsxs("header",{className:"migration-optimize-dialog__header",children:[o.jsxs("div",{children:[o.jsx("h2",{id:c,children:"优化迁移项目"}),o.jsx("p",{title:e.projectName,children:e.projectName})]}),o.jsx("button",{type:"button",className:"migration-optimize-dialog__close",onClick:a,disabled:d,"aria-label":"关闭优化窗口",title:"关闭",children:o.jsx(j0e,{})})]}),o.jsx("div",{className:"migration-optimize-dialog__body",children:o.jsx(Swe,{capabilities:t,loading:n,preparationStage:r,error:i,onCancel:s,onCreate:async(m,g)=>{await l(m,g,e)},baseVersion:e})})]})}),document.body)}function w5t({capabilities:e,capabilitiesLoading:t,preparationStage:n,optimizationError:r,initialProjectId:i,onOptimize:s,onCancelOptimization:a,onDownload:l,onDeploy:c}){const[u,d]=p.useState();return o.jsxs(o.Fragment,{children:[o.jsxs("main",{className:"migration-main migration-projects-page",children:[o.jsx("header",{className:"migration-main__header",children:o.jsxs("div",{children:[o.jsx("h2",{children:"已迁移项目"}),o.jsx("p",{children:"管理迁移后的源码版本,也可以选择任一版本继续优化。"})]})}),o.jsx("div",{className:"migration-projects-page__content",children:o.jsx(wwe,{origin:"migration",title:"项目与版本",description:"查看、下载、部署或对比源码版本,也可以基于任一版本继续优化。",emptyTitle:"还没有已迁移的项目",emptyDescription:"迁移完成后,源码会自动保存在这里。",capabilities:e,capabilitiesLoading:t,creating:n!==null,initialProjectId:i,onSelectBaseVersion:d,onClearBaseVersion:()=>{},onDownload:l,onDeploy:c})})]}),u?o.jsx(v5t,{baseVersion:u,capabilities:e,loading:t,preparationStage:n,error:r,onCancel:a,onClose:()=>d(void 0),onCreate:s}):null]})}const S5t=20*1024*1024,c3=1200,rte=3e3,E5t=5e3,ite=500,k5t=()=>{},aSe={langchain:"LangChain",langgraph:"LangGraph",adk:"Google ADK",strands:"Strands",agentcore:"AgentCore",dify:"Dify",any:"Any(通用迁移)"},u3=new Set(["langchain","langgraph","adk","strands","agentcore"]);function _5t(e){switch(e){case"awaiting_upload":return"待上传";case"analyzing":return"分析中";case"needs_input":return"待补充";case"analysis_ready":return"待确认";case"migrating":return"迁移中";case"validating":return"校验中";case"packaging":return"打包中";case"succeeded":return"已完成";case"succeeded_with_warnings":return"已完成,有提示";case"partial":return"部分完成";case"failed":return"失败";case"cancelled":return"已终止";case"expired":return"已过期"}}function d3(e){return e.state==="partial"&&e.artifact.previewReady?"迁移产物已生成,但交付不完整,请查看迁移提示。":["succeeded","succeeded_with_warnings"].includes(e.state)&&e.artifact.previewReady?e.state==="succeeded_with_warnings"?"迁移产物已生成,请查看迁移提示。":"迁移产物已生成。":e.message}function T5t(e){switch(e){case"passed":return"产物校验通过";case"failed":return"产物校验未通过";case"degraded":return"产物校验未完成"}}function f3({stage:e}){const t=[{id:"session",label:"创建迁移环境"},{id:"upload",label:"上传项目"},{id:"analysis",label:"分析项目"}],n=t.findIndex(r=>r.id===e);return o.jsx("div",{className:"migration-transfer-progress",role:"status",children:t.map((r,i)=>o.jsxs("div",{className:i=s)return{title:"临时迁移环境已结束",detail:n?"已保存项目仍可查看、下载、部署或优化":"任务记录和临时产物已无法访问"};const a=Math.max(0,s-t),l=Math.floor(a/6e4),c=Math.floor(a%6e4/1e3);return{title:`临时迁移环境将在 ${l} 分 ${c} 秒后结束`,detail:i}}function P5t(e,t){let n=!1;const r=e.map(i=>{var l;if(i.state==="expired")return i;const s=new Date(i.expiresAt).getTime();if(!Number.isFinite(s)||tr.id!==t.id);return[t,...n].sort((r,i)=>{const s=typeof r.createdAt=="number"?r.createdAt*1e3:new Date(r.createdAt).getTime();return(typeof i.createdAt=="number"?i.createdAt*1e3:new Date(i.createdAt).getTime())-s})}function M5t(e,t){return e.find(n=>n.id===t)??null}function L5t(e,t){return e.startsWith("text/")||/(?:json|javascript|xml|yaml)/i.test(e)||/\.(?:py|ts|tsx|js|jsx|json|ya?ml|md|txt|toml|ini|cfg|env|sh|dockerfile)$/i.test(t)}function $5t({analysis:e}){var t;return o.jsxs("div",{className:"migration-analysis",children:[o.jsx(Ou,{text:e.summary,allowRawHtml:!1}),o.jsxs("div",{className:"migration-analysis__facts",children:[e.recommended?o.jsxs("section",{children:[o.jsx("h3",{children:"建议迁移方式"}),o.jsx("strong",{children:aSe[e.recommended.framework]}),o.jsx("p",{children:e.recommended.reason})]}):null,o.jsxs("section",{children:[o.jsx("h3",{children:"迁移范围"}),o.jsx("ul",{children:e.boundary.include.map(n=>o.jsx("li",{children:n},n))})]}),e.boundary.exclude.length>0?o.jsxs("section",{children:[o.jsx("h3",{children:"不在本次范围"}),o.jsx("ul",{children:e.boundary.exclude.map(n=>o.jsx("li",{children:n},n))})]}):null]}),(t=e.frameworks[0])!=null&&t.evidence.length?o.jsxs("details",{className:"migration-analysis__evidence",children:[o.jsx("summary",{children:"查看分析证据"}),o.jsx("ul",{children:e.frameworks.flatMap(n=>n.evidence.map(r=>o.jsxs("li",{children:[o.jsxs("code",{children:[r.path,":",r.line]}),o.jsx("span",{children:r.reason})]},`${n.id}:${r.path}:${r.line}`)))})]}):null,e.warnings.length>0?o.jsx("div",{className:"migration-analysis__warnings",children:e.warnings.map(n=>o.jsx("p",{children:n},n))}):null,e.assumptions.length>0?o.jsxs("details",{className:"migration-analysis__evidence",children:[o.jsx("summary",{children:"查看关键假设"}),o.jsx("ul",{children:e.assumptions.map(n=>o.jsx("li",{children:n},n))})]}):null]})}function B5t({activity:e,loading:t,error:n,analyzing:r}){const i=(e==null?void 0:e.items)??[],s=x5t(i);return o.jsxs("section",{className:"migration-activity","aria-label":"Codex 执行动态",children:[o.jsxs("div",{className:"migration-activity__heading",children:[o.jsx("span",{className:`migration-activity__marker${e!=null&&e.complete?" is-complete":""}`,"aria-hidden":"true"}),o.jsx("strong",{children:"Codex 执行动态"})]}),s.length>0?o.jsx("div",{className:"migration-activity__stream",children:o.jsx(Fj,{blocks:s,onAction:k5t})}):t||!(e!=null&&e.complete)?o.jsx(wn,{children:r?"Codex 正在开始分析…":"Codex 正在开始迁移…"}):null,n?o.jsx("p",{className:"migration-activity__error",role:"status",children:n}):null]})}function Q5t({task:e,artifact:t}){var d;const[n,r]=p.useState(""),[i,s]=p.useState(((d=t.files[0])==null?void 0:d.path)??""),[a,l]=p.useState(null),c=t.files.find(f=>f.path===i)??t.files[0],u=p.useMemo(()=>{const f=n.trim().toLocaleLowerCase();return(f?t.files.filter(m=>m.path.toLocaleLowerCase().includes(f)):t.files).slice(0,ite)},[t.files,n]);return p.useEffect(()=>{if(!c)return;if(c.size>2*1024*1024){l({path:c.path,loading:!1,error:"该文件超过 2 MiB,请下载完整产物后查看。"});return}const f=new AbortController;let h="";return l({path:c.path,loading:!0}),f5t(e.id,c.path,f.signal).then(async({blob:m,mimeType:g})=>{if(!f.signal.aborted){if(g.startsWith("image/")){h=URL.createObjectURL(m),l({path:c.path,loading:!1,imageUrl:h});return}if(L5t(g,c.path)){const b=await m.text();if(f.signal.aborted)return;l({path:c.path,loading:!1,text:b});return}l({path:c.path,loading:!1,error:"该文件不支持在线预览,请下载完整产物后查看。"})}}).catch(m=>{f.signal.aborted||l({path:c.path,loading:!1,error:m instanceof Error?m.message:String(m)})}),()=>{f.abort(),h&&URL.revokeObjectURL(h)}},[c,e.id]),o.jsxs("div",{className:"migration-artifact-browser",children:[o.jsxs("aside",{"aria-label":"迁移产物文件",children:[o.jsxs("label",{className:"migration-artifact-browser__search",children:[o.jsx("span",{className:"sr-only",children:"搜索产物文件"}),o.jsx("input",{value:n,onChange:f=>r(f.currentTarget.value),placeholder:"搜索文件"})]}),o.jsx("div",{className:"migration-artifact-browser__files",children:u.map(f=>o.jsxs("button",{type:"button",className:f.path===(c==null?void 0:c.path)?"is-active":"",onClick:()=>s(f.path),title:f.path,children:[o.jsx(sv,{}),o.jsx("span",{children:f.path}),o.jsx("small",{children:ZA(f.size)})]},f.path))}),t.files.length>u.length?o.jsxs("p",{className:"migration-artifact-browser__limit",children:["仅展示前 ",ite," 项,请搜索具体文件。"]}):null]}),o.jsxs("section",{children:[o.jsxs("header",{children:[o.jsx("span",{title:c==null?void 0:c.path,children:(c==null?void 0:c.path)||"未选择文件"}),c?o.jsx("small",{children:ZA(c.size)}):null]}),o.jsx("div",{className:"migration-artifact-browser__preview",children:c?(a==null?void 0:a.path)!==c.path||a.loading?o.jsx(wn,{children:"正在读取产物文件…"}):a.error?o.jsx("p",{role:"status",children:a.error}):a.imageUrl?o.jsx("img",{src:a.imageUrl,alt:c.path}):o.jsx(gR,{value:a.text??"",path:c.path,readOnly:!0,onChange:()=>{}}):o.jsx("p",{children:"暂无可预览文件。"})})]})]})}function U5t({cloudProvider:e,onBack:t,onAgentAdded:n,onDeploymentTaskChange:r,onDeploymentStarted:i,onDeploymentComplete:s,initialDeployRegion:a=Zr(e),projectCapabilities:l,projectCapabilitiesLoading:c,optimizationPreparationStage:u,optimizationError:d,onOptimizeVersion:f,onCancelOptimization:h,onDownloadSavedVersion:m,onDeploySavedVersion:g,initialPage:b="new",initialProjectId:y=""}){var ka,Ys,_a,Ds,Pi,Cr,yi,bs,Ps,pn,Oi,Ur,ys;const O=p.useRef(null),v=p.useRef(""),x=p.useRef(null),[w,S]=p.useState(null),[E,k]=p.useState([]),[_,T]=p.useState(b),[C,A]=p.useState(y),[R,M]=p.useState(""),[I,$]=p.useState(null),[N,j]=p.useState([]),[B,F]=p.useState(""),[L,H]=p.useState(!1),[z,Q]=p.useState(""),[V,K]=p.useState(0),[se,ge]=p.useState(!1),[ie,q]=p.useState(!0),[G,J]=p.useState(""),[ue,Oe]=p.useState(""),[Qe,je]=p.useState(""),[ze,Ge]=p.useState(!1),[Ae,Be]=p.useState(Date.now()),[he,be]=p.useState(null),[Se,Ee]=p.useState("langchain"),[tt,Ue]=p.useState(""),[re,ce]=p.useState(""),[Me,Ye]=p.useState({}),[Z,_e]=p.useState(null),[rt,Re]=p.useState(""),[We,ct]=p.useState(!1),[kt,qt]=p.useState(0),[Dt,Xe]=p.useState(null),[nt,ft]=p.useState(!1),[xt,Ie]=p.useState(""),[xe,$e]=p.useState(!1),[it,ve]=p.useState(!1),[He,pt]=p.useState(a),[_t,It]=p.useState(),[Kt,en]=p.useState({}),le=M5t(E,R),Xt=(w==null?void 0:w.maxUploadBytes)??S5t,Fe=j5t(Xt),Pt=p.useMemo(()=>new Set((w==null?void 0:w.unsupportedModelIds)??[]),[w==null?void 0:w.unsupportedModelIds]),Ce=p.useMemo(()=>N.filter(pe=>A5t(pe,Pt)),[N,Pt]),gt=(le==null?void 0:le.modelId)||B,Vt=p.useMemo(()=>{var sn;const pe=Ce.map(An=>({value:An.id,label:An.displayName,description:[An.id,An.vendorName,An.lifecycleStatus==="Retiring"?"即将下线":""].filter(Boolean).join(" · ")})),Le=((le==null?void 0:le.modelId)||B||((sn=w==null?void 0:w.model)==null?void 0:sn.id)||"").trim(),At=(le==null?void 0:le.modelId)===Le;return Le&&(At||!Pt.has(Le))&&!pe.some(An=>An.value===Le)&&pe.unshift({value:Le,label:Le,description:"当前默认模型"}),pe},[(ka=w==null?void 0:w.model)==null?void 0:ka.id,Ce,B,le==null?void 0:le.modelId,Pt]),ot=he?Math.max(0,Math.floor((Ae-he)/1e3)):0,ln=Dt==null?void 0:Dt.items[Dt.items.length-1],Kn=[(Dt==null?void 0:Dt.items.length)??0,(ln==null?void 0:ln.id)??"",(ln==null?void 0:ln.status)??"",((Ys=ln==null?void 0:ln.detail)==null?void 0:Ys.length)??0].join(":"),{ref:_r,onScroll:Ve}=Wge(`${(le==null?void 0:le.id)??"new"}:${(le==null?void 0:le.state)??"new"}:${Kn}`);async function et(pe,Le=!0,At){try{const sn=await l3(pe,At);return At!=null&&At.aborted?null:(k(An=>ef(An,sn)),je(""),Ge(!1),sn)}catch(sn){return At!=null&&At.aborted||Le&&(je(sn instanceof Error?sn.message:String(sn)),Ge(sn instanceof Uo&&sn.retryable)),null}}async function mn(pe){try{const Le=await o3(pe);if(pe!=null&&pe.aborted)return;k(Le),je(""),Ge(!1)}catch(Le){if(pe!=null&&pe.aborted)return;je(Le instanceof Error?Le.message:String(Le)),Ge(Le instanceof Uo&&Le.retryable)}}p.useEffect(()=>{const pe=new AbortController;return q(!0),Oe(""),Promise.all([s5t(pe.signal),o3(pe.signal)]).then(([Le,At])=>{pe.signal.aborted||(S(Le),k(At))}).catch(Le=>{pe.signal.aborted||Oe(Le instanceof Error?Le.message:String(Le))}).finally(()=>{pe.signal.aborted||q(!1)}),()=>pe.abort()},[]),p.useEffect(()=>{const pe=new AbortController;return H(!0),Q(""),Q1({signal:pe.signal,refresh:V>0}).then(Le=>{pe.signal.aborted||j(Le.models)}).catch(Le=>{pe.signal.aborted||Q(Le instanceof Error?Le.message:"加载模型列表失败")}).finally(()=>{pe.signal.aborted||H(!1)}),()=>pe.abort()},[e,V]),p.useEffect(()=>{var At,sn;if(!w||B)return;const pe=((At=w.model)==null?void 0:At.id.trim())||"",Le=pe&&!Pt.has(pe)?pe:((sn=Ce[0])==null?void 0:sn.id)||"";Le&&F(Le)},[w,Ce,B,Pt]),p.useEffect(()=>()=>{var pe;(pe=x.current)==null||pe.abort(),x.current=null},[]),p.useEffect(()=>{const pe=window.setInterval(()=>{const Le=Date.now();Be(Le),k(At=>P5t(At,Le))},1e3);return()=>window.clearInterval(pe)},[]),p.useEffect(()=>{if(!E.some(At=>Pm(At.state)))return;const pe=new AbortController,Le=window.setInterval(()=>{o3(pe.signal).then(At=>{pe.signal.aborted||k(At),je(""),Ge(!1)}).catch(At=>{pe.signal.aborted||(je(At instanceof Error?At.message:String(At)),Ge(At instanceof Uo&&At.retryable),At instanceof Uo&&At.retryable||window.clearInterval(Le))})},E5t);return()=>{pe.abort(),window.clearInterval(Le)}},[E.some(pe=>Pm(pe.state))]),p.useEffect(()=>{var sn;if(!le||!Pm(le.state)&&((sn=le.persistence)==null?void 0:sn.state)!=="saving")return;const pe=new AbortController;let Le;const At=async()=>{var An;try{const $r=await l3(le.id,pe.signal);if(pe.signal.aborted)return;k(Gr=>ef(Gr,$r)),je(""),Ge(!1),(Pm($r.state)||((An=$r.persistence)==null?void 0:An.state)==="saving")&&(Le=window.setTimeout(()=>void At(),c3))}catch($r){if(pe.signal.aborted)return;je($r instanceof Error?$r.message:String($r)),Ge($r instanceof Uo&&$r.retryable),$r instanceof Uo&&$r.retryable&&(Le=window.setTimeout(()=>void At(),c3))}};return Le=window.setTimeout(()=>void At(),c3),()=>{pe.abort(),Le!==void 0&&window.clearTimeout(Le)}},[le==null?void 0:le.id,le==null?void 0:le.state,(_a=le==null?void 0:le.persistence)==null?void 0:_a.state]),p.useEffect(()=>{const pe=_r.current;pe&&(pe.scrollTop=pe.scrollHeight,Ve())},[R,_r,Ve]),p.useEffect(()=>{Xe(null),Ie(""),ft(!1)},[le==null?void 0:le.id]),p.useEffect(()=>{if(!le||!ste(le))return;const pe=new AbortController;let Le;const At=async()=>{ft(!0);try{const sn=await o5t(le.id,pe.signal);if(pe.signal.aborted)return;Xe(sn),Ie(""),!sn.complete&&Pm(le.state)&&(Le=window.setTimeout(()=>void At(),rte))}catch(sn){if(pe.signal.aborted)return;Ie("暂时无法读取 Codex 执行动态,不影响当前任务。"),Pm(le.state)&&sn instanceof Uo&&sn.retryable&&(Le=window.setTimeout(()=>void At(),rte))}finally{pe.signal.aborted||ft(!1)}};return At(),()=>{pe.abort(),Le!==void 0&&window.clearTimeout(Le)}},[le==null?void 0:le.id,le==null?void 0:le.state,(Ds=le==null?void 0:le.analysisRef)==null?void 0:Ds.sha256,(Pi=le==null?void 0:le.confirmation)==null?void 0:Pi.framework]),p.useEffect(()=>{if(!(le!=null&&le.analysis)||!le.analysisRef||!["needs_input","analysis_ready"].includes(le.state))return;const pe=`${le.id}:${le.analysisRef.attempt}:${le.analysisRef.sha256}`;if(v.current===pe||(v.current=pe,Ye({}),le.state!=="analysis_ready"))return;const Le=le.analysis.recommended;Le&&(Ee(Le.framework),Ue(Le.entry||""),ce(ate(le.sourceFileName)))},[le]),p.useEffect(()=>{if(_e(null),Re(""),ct(!1),ve(!1),en({}),!(le!=null&&le.artifact.previewReady))return;const pe=new AbortController;return d5t(le.id,pe.signal).then(Le=>{pe.signal.aborted||_e(Le)}).catch(Le=>{pe.signal.aborted||(Re(Le instanceof Error?Le.message:String(Le)),ct(Le instanceof Uo&&Le.retryable))}),()=>pe.abort()},[le==null?void 0:le.id,le==null?void 0:le.artifact.previewReady,kt]),p.useEffect(()=>{if(!Z)return;const pe=aRt(Z,e);en(Le=>{var sn;const At={...Le};for(const[An,$r]of Object.entries(pe))(sn=At[An])!=null&&sn.trim()||(At[An]=$r);return At})},[Z,e]);function Mt(pe){if(!x.current&&(Oe(""),!!pe)){if(!pe.name.toLowerCase().endsWith(".zip")){$(null),Oe("请选择 .zip 格式的本地项目文件。");return}if(pe.name.length>255||/[/\\\u0000-\u001f]/.test(pe.name)){$(null),Oe("ZIP 文件名无效,请重命名后重新选择。");return}if(pe.size>Xt){$(null),Oe(`项目 ZIP 不能超过 ${Fe}。`);return}if(pe.size===0){$(null),Oe("项目 ZIP 不能为空。");return}$(pe)}}function ar(pe){var At;const Le=(At=pe.currentTarget.files)==null?void 0:At[0];pe.currentTarget.value="",Mt(Le)}async function pr(){if(!I||G||x.current)return;const pe=new AbortController;x.current=pe;const Le=()=>x.current===pe&&!pe.signal.aborted,At=`migration-v1-${crypto.randomUUID().replace(/-/g,"")}`;J("create"),be(Date.now()),Oe("");try{const sn=await a5t({taskId:At,sourceFileName:I.name,instruction:"",modelId:B||void 0,signal:pe.signal});if(!Le())return;k($r=>ef($r,sn)),M(sn.id),J("upload"),be(null);const An=await tte(sn.id,I,pe.signal);if(!Le())return;k($r=>ef($r,An)),$(null)}catch(sn){if(!Le())return;const An=await et(At,!1,pe.signal);if(!Le())return;if(An){if(M(An.id),An.state!=="awaiting_upload"){$(null);return}}else if(await mn(pe.signal),!Le())return;Oe(sn instanceof Error?sn.message:String(sn))}finally{x.current===pe&&(x.current=null,be(null),J(""))}}async function Gn(){if(!(le!=null&&le.canUpload)||!I||G||x.current)return;const pe=new AbortController;x.current=pe;const Le=()=>x.current===pe&&!pe.signal.aborted;J("upload"),Oe("");try{const At=await tte(le.id,I,pe.signal);if(!Le())return;k(sn=>ef(sn,At)),$(null)}catch(At){if(!Le())return;const sn=await et(le.id,!0,pe.signal);if(!Le())return;if(sn&&sn.state!=="awaiting_upload"){$(null);return}Oe(At instanceof Error?At.message:String(At))}finally{x.current===pe&&(x.current=null,J(""))}}const zn=p.useMemo(()=>{var pe;return(((pe=le==null?void 0:le.analysis)==null?void 0:pe.entries)??[]).filter(Le=>Le.framework===Se).map(Le=>({value:Le.value,label:Le.value,description:Le.evidence}))},[Se,(Cr=le==null?void 0:le.analysis)==null?void 0:Cr.entries]),Pr=(((yi=le==null?void 0:le.analysis)==null?void 0:yi.questions)??[]).every(pe=>{var Le;return!pe.required||!!((Le=Me[pe.id])!=null&&Le.trim())}),Lr=N5t(re),Kr=!!(le!=null&&le.canConfirm&&le.analysisRef&&!G&&!Lr&&(!u3.has(Se)||tt.trim())),qr=!!(le!=null&&le.canAnswer&&le.analysisRef&&!G&&Pr);async function mr(){if(!(!(le!=null&&le.analysisRef)||!qr)){J("answer"),Oe("");try{const pe=await c5t({taskId:le.id,analysisAttempt:le.analysisRef.attempt,analysisSha256:le.analysisRef.sha256,inputSha256:le.analysisRef.inputSha256,answers:Me});k(Le=>ef(Le,pe))}catch(pe){const Le=await et(le.id);if(Le&&Le.state!=="needs_input")return;Oe(pe instanceof Error?pe.message:String(pe))}finally{J("")}}}async function Xr(){if(!(!(le!=null&&le.analysisRef)||!Kr)){J("confirm"),Oe("");try{const pe=await l5t({taskId:le.id,framework:Se,entry:u3.has(Se)?tt.trim():void 0,appName:re.trim(),instruction:"",analysisAttempt:le.analysisRef.attempt,analysisSha256:le.analysisRef.sha256,inputSha256:le.analysisRef.inputSha256});k(Le=>ef(Le,pe))}catch(pe){const Le=await et(le.id);if(Le&&Le.state!=="analysis_ready")return;Oe(pe instanceof Error?pe.message:String(pe))}finally{J("")}}}async function Tr(){if(!(!(le!=null&&le.canStop)||G)){J("stop"),Oe("");try{const pe=await u5t(le.id);k(Le=>ef(Le,pe)),$e(!1)}catch(pe){const Le=await et(le.id);if(Le&&!Le.canStop){$e(!1);return}Oe(pe instanceof Error?pe.message:String(pe))}finally{J("")}}}async function oi(){if(!(!(le!=null&&le.artifact.downloadReady)||G)){J("download"),Oe("");try{await p5t(le.id,IT(le.sourceFileName))}catch(pe){Oe(pe instanceof Error?pe.message:String(pe))}finally{J("")}}}function Ii(){var pe,Le;T("new"),A(""),M(""),$(null),Oe(""),je(""),Ge(!1),_e(null),Re(""),ct(!1),ve(!1),$e(!1),F(((pe=w==null?void 0:w.model)==null?void 0:pe.id.trim())||((Le=Ce[0])==null?void 0:Le.id)||"")}const bi=Z?{name:((bs=le==null?void 0:le.confirmation)==null?void 0:bs.app_name)||ate((le==null?void 0:le.sourceFileName)||"migration.zip"),files:[{path:"migration-result.json",content:`${JSON.stringify(Z,null,2)}
+`+iQ(Wwe(r))}const LRt={missing_http_tool:"请返回“添加 MCP 工具”并添加至少一个 HTTP MCP 服务;MCP 稳定性治理不支持 stdio 服务。",missing_url:"已添加的 HTTP MCP 工具缺少有效服务地址,请返回“添加 MCP 工具”补充后再发布。"};function Bee(e){return{ok:!1,reason:e,message:LRt[e]}}function $Rt(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function BRt(e){var a;const t=[],n=new Set,r=l=>{var c;n.has(l)||(n.add(l),t.push(l),l.subAgents.forEach(r),(c=l.workflow)==null||c.nodes.forEach(u=>r(u.agent)))};r(e);const i=t.flatMap(l=>(l.mcpTools??[]).filter(c=>c.transport==="http"));if(i.length===0)return Bee("missing_http_tool");const s=[];for(const l of i){const c=((a=l.url)==null?void 0:a.trim())??"";if(!c||!$Rt(c))return Bee("missing_url");s.push(c)}return{ok:!0,urls:s}}const i$="__default_environment__",QRt={value:i$,label:"默认环境",description:"使用部署 Runtime 的默认基础镜像"};function URt(e){const t=e instanceof Error?e.message:String(e);return t.includes("HTTP 503")&&t.includes("管理员未配置持久化存储")}const FRt={preparing:"准备中",queued:"排队中",building:"构建中",scanning:"扫描中",available:"可用",failed:"构建失败"};function Qee(e){return e.latestVersion?FRt[e.latestVersion.status]:"未构建"}function zRt(e){var t,n;return((t=e.latestVersion)==null?void 0:t.status)==="available"?"success":((n=e.latestVersion)==null?void 0:n.status)==="failed"?"danger":e.latestVersion?"warning":"secondary"}function Ywe({value:e,onChange:t,disabled:n=!1,controlSize:r="lg",controlClassName:i,optionClassName:s}){var k,_;const a=p.useId(),l=p.useRef(t),[c,u]=p.useState([]),[d,f]=p.useState(!0),[h,m]=p.useState(""),[g,b]=p.useState(!1),[y,O]=p.useState(0);p.useEffect(()=>{l.current=t},[t]),p.useEffect(()=>{const T=new AbortController;return f(!0),m(""),b(!1),ZS(T.signal).then(C=>{T.signal.aborted||u(C)}).catch(C=>{!T.signal.aborted&&(C==null?void 0:C.name)!=="AbortError"&&(URt(C)?(u([]),b(!0),l.current({environmentId:"",environmentVersionId:""})):m(C instanceof Error?C.message:String(C)))}).finally(()=>{T.signal.aborted||f(!1)}),()=>T.abort()},[y]);const v=p.useMemo(()=>[QRt,...c.map(T=>{var C;return{value:T.id,label:T.name,description:`${H4(T.operatingSystem)} · ${Qf(T.language)} · ${Qee(T)}`,disabled:((C=T.latestVersion)==null?void 0:C.status)!=="available",environment:T}})],[c]),x=c.find(T=>T.id===e.environmentId),w=((k=x==null?void 0:x.latestVersion)==null?void 0:k.versionId)===e.environmentVersionId?x.latestVersion:null,S=x?q7.flatMap(T=>T.options).filter(T=>x.optionIds.includes(T.id)).map(T=>T.label):[],E=T=>{var A;if(T.value===i$||!T.environment){t({environmentId:"",environmentVersionId:""});return}const C=((A=T.environment.latestVersion)==null?void 0:A.versionId)??"";t({environmentId:T.value,environmentVersionId:C})};return d&&c.length===0?o.jsx("div",{className:"cloud-env-state",role:"status",children:o.jsx(wn,{duration:1.25,children:"正在加载环境..."})}):h&&c.length===0?o.jsxs("div",{className:"cloud-env-state cloud-env-state--error",role:"alert",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"环境加载失败"}),o.jsx("p",{children:h})]}),o.jsx(jt,{color:"secondary",variant:"soft",size:"sm",onClick:()=>O(T=>T+1),children:"重试"})]}):o.jsxs("section",{className:"cloud-env-config","aria-labelledby":`${a}-title`,children:[o.jsxs("label",{className:"cloud-env-field",id:`${a}-title`,htmlFor:a,children:[o.jsx("span",{children:"环境"}),o.jsx(Wo,{id:a,value:e.environmentId||i$,options:v,size:r,triggerClassName:i,optionClassName:s,pill:!1,disabled:n,placeholder:"选择一个已构建的环境",searchPlaceholder:"搜索环境",searchEmptyMessage:"没有匹配的环境",onChange:E}),o.jsx("small",{children:"仅可选择构建状态为“可用”的环境,部署时会固定到当前镜像版本。"})]}),x?o.jsxs("div",{className:"cloud-env-summary","aria-live":"polite",children:[o.jsxs("div",{className:"cloud-env-summary__head",children:[o.jsxs("div",{children:[o.jsx("strong",{children:x.name}),x.description?o.jsx("p",{children:x.description}):null]}),o.jsx(sa,{color:zRt(x),variant:"soft",size:"sm",children:Qee(x)})]}),o.jsxs("dl",{className:"cloud-env-details",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"操作系统"}),o.jsx("dd",{children:H4(x.operatingSystem)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"语言"}),o.jsx("dd",{children:Qf(x.language)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"工具"}),o.jsx("dd",{children:S.length?S.join("、"):"无额外工具"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"技能"}),o.jsx("dd",{children:(_=x.selectedSkills)!=null&&_.length?x.selectedSkills.map(T=>T.name).join("、"):"无环境技能"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"镜像版本"}),o.jsx("dd",{children:(w==null?void 0:w.versionId)||e.environmentVersionId||"不可用"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"镜像"}),o.jsx("dd",{title:(w==null?void 0:w.image)||"",children:(w==null?void 0:w.image)||"当前固定版本已不在列表中,请重新选择环境"})]})]}),w?null:o.jsx("p",{className:"cloud-env-version-warning",role:"alert",children:"此环境的可用版本已变化,请重新选择后再发布。"})]}):e.environmentId?o.jsx("div",{className:"cloud-env-version-warning",role:"alert",children:"已选择的环境不存在或无权访问,请重新选择。"}):o.jsx("p",{className:`cloud-env-guidance ${g?"cloud-env-guidance--fallback":""}`,children:g?"管理员未配置持久化存储,将使用部署 Runtime 时的默认基础镜像。":c.length===0?"暂无自定义环境,将使用部署 Runtime 的默认基础镜像。":"当前使用 AgentKit 默认运行环境;选择自定义环境后,会基于对应镜像构建并加载环境技能。"})]})}const Sf="new-agent-workbench__select-option";function VRt({label:e,metadata:t}){return o.jsx("span",{className:"new-agent-workbench__model-option-view",children:o.jsxs("span",{className:"new-agent-workbench__model-option-copy",children:[o.jsx("span",{className:"new-agent-workbench__model-option-label",children:e}),t?o.jsx("span",{className:"new-agent-workbench__model-option-metadata",children:t}):null]})})}function HRt(e,t){var r,i;const n=t.trim().toLocaleLowerCase();return n?[e.label,e.metadata,(r=e.model)==null?void 0:r.name,(i=e.model)==null?void 0:i.vendorName].some(s=>s==null?void 0:s.toLocaleLowerCase().includes(n)):!0}const qRt=["local","sqlite","mysql","postgresql"];function Uee(e){return qRt.includes(e)}function XRt(e){return e==="local"?"in-memory":"persistent"}const g_=[{id:"agent",label:"智能体",title:"基本信息",description:"设置智能体的名称、用途、行为方式与能力"},{id:"environment",label:"执行环境",title:"配置执行环境",description:"选择默认环境或已构建的自定义环境"},{id:"deployment",label:"部署偏好",title:"部署偏好",description:"定义 AgentKit 云上参数"}];function GRt({cloudProvider:e,source:t,value:n,apiKeyId:r,apiKeyName:i,provider:s,apiBase:a,customApiKey:l,onSourceChange:c,onApiKeyChange:u,onModelNameChange:d,onProviderChange:f,onApiBaseChange:h,onCustomApiKeyChange:m,onLoadingChange:g}){const[b,y]=p.useState([]),[O,v]=p.useState([]),[x,w]=p.useState(!0),[S,E]=p.useState(!1),[k,_]=p.useState(null),[T,C]=p.useState("");p.useEffect(()=>{const I=new AbortController;if(t==="ark")return w(!0),C(""),f9(I.signal).then($=>{if(I.signal.aborted)return;y($.keys);const N=$.keys.find(j=>j.id===r)??$.keys.find(j=>j.name===i)??$.keys.find(j=>j.id===$.defaultKeyId)??$.keys[0];N&&N.id!==r&&u(N)}).catch($=>{I.signal.aborted||C($ instanceof Error?$.message:"模型凭据加载失败")}).finally(()=>{I.signal.aborted||w(!1)}),()=>I.abort()},[r,i,e,u,t]),p.useEffect(()=>{if(t!=="ark"||!r){v([]),E(!1),_(null);return}const I=new AbortController;return E(!0),_(null),C(""),Q1({apiKeyId:r,signal:I.signal}).then($=>{I.signal.aborted||v($.models)}).catch($=>{I.signal.aborted||C($ instanceof Error?$.message:"模型列表加载失败")}).finally(()=>{I.signal.aborted||(E(!1),_(r))}),()=>I.abort()},[r,e,t]),p.useEffect(()=>{g(t==="ark"&&(x||!!r&&(S||k!==r)))},[r,k,x,S,g,t]);const A=[{value:"ark",label:e==="byteplus"?"BytePlus ModelArk":"火山方舟"},{value:"custom",label:"自定义"},{value:"gateway",label:"模型网关",description:"待上线",disabled:!0}],R=b.map(I=>({value:I.id,label:I.name}));r&&!R.some(I=>I.value===r)&&R.unshift({value:r,label:i||"当前 API Key"});const M=p.useMemo(()=>{const I=O.filter($=>$.available||$.lifecycleStatus==="Retiring").map($=>({value:$.id,label:$.displayName||$.name||$.id,metadata:$.vendorName?`${$.id} | ${$.vendorName}`:$.id,model:$}));return n&&!I.some($=>$.value===n)&&I.unshift({value:n,label:n,metadata:n}),I},[O,n]);return o.jsxs("div",{className:"new-agent-workbench__model-group",children:[o.jsx("span",{className:"new-agent-workbench__model-group-label",children:"模型"}),o.jsxs("div",{className:"new-agent-workbench__model-fields",children:[o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"模型来源"}),o.jsx(Wo,{value:t,options:A,size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,onChange:I=>c(I.value)})]}),t==="ark"?o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsxs("span",{className:"new-agent-workbench__model-field-label",children:["API Key",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Wo,{value:r??"",options:R,loading:x,loadingPlaceholder:"正在加载 API Key",placeholder:"选择 API Key",searchPlaceholder:"搜索 API Key 名称",searchEmptyMessage:"暂无可用 API Key",size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,onChange:I=>{const $=b.find(N=>N.id===I.value);$&&(g(!0),u($))}})]}),o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsxs("span",{className:"new-agent-workbench__model-field-label",children:["模型",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Wo,{value:n,options:M,loading:S,loadingPlaceholder:"正在加载模型",placeholder:"选择模型",searchPlaceholder:"搜索名称、Model ID 或服务商",searchEmptyMessage:"没有可用的模型",size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:`${Sf} new-agent-workbench__model-option`,OptionView:VRt,searchPredicate:HRt,pill:!1,disabled:!r,onChange:I=>d(I.value)})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsxs("span",{className:"new-agent-workbench__model-field-label",children:["模型名称",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Ui,{value:n,size:"xl",gutterSize:"md",pill:!1,onChange:I=>d(I.currentTarget.value)})]}),o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"服务商 Provider"}),o.jsx(Ui,{value:s,placeholder:"openai",size:"xl",gutterSize:"md",pill:!1,onChange:I=>f(I.currentTarget.value)})]}),o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"API Base"}),o.jsx(Ui,{value:a,placeholder:nl(e),size:"xl",gutterSize:"md",pill:!1,onChange:I=>h(I.currentTarget.value)})]}),o.jsxs("label",{className:"new-agent-workbench__field new-agent-workbench__model-field",children:[o.jsxs("span",{className:"new-agent-workbench__model-field-label",children:["API Key",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Ui,{type:"password",value:l,placeholder:"请输入模型 API Key",autoComplete:"new-password",size:"xl",gutterSize:"md",pill:!1,onChange:I=>m(I.currentTarget.value)})]})]}),T?o.jsx("p",{className:"new-agent-workbench__error",role:"alert",children:T}):null]})]})}function WRt({value:e,disabled:t,onChange:n}){const[r,i]=p.useState([]),[s,a]=p.useState(!0),[l,c]=p.useState(""),[u,d]=p.useState(0);p.useEffect(()=>{const m=new AbortController;return a(!0),c(""),BN(m.signal).then(g=>{m.signal.aborted||i(g)}).catch(g=>{!m.signal.aborted&&(g==null?void 0:g.name)!=="AbortError"&&(i([]),c(g instanceof Error?g.message:String(g)))}).finally(()=>{m.signal.aborted||a(!1)}),()=>m.abort()},[u]);const f=p.useMemo(()=>[...r].sort((m,g)=>Number(g.isCurrent)-Number(m.isCurrent)).map(m=>({value:m.uid,label:m.name.trim()||"未命名用户池",description:m.isCurrent?`${m.domain||m.uid}(当前用户池)`:m.domain||m.uid})),[r]),h=r.find(m=>m.uid===e);return o.jsxs("div",{className:"new-agent-workbench__field",children:[o.jsxs("span",{children:["用户池",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Wo,{value:e,options:f,loading:s,loadingPlaceholder:"正在加载用户池",placeholder:"请选择用户池",searchPlaceholder:"搜索用户池",searchEmptyMessage:"当前账号下暂无 Identity 用户池",size:"xl",pill:!1,disabled:t||!!l,triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,onChange:m=>n(m.value)}),l?o.jsxs("div",{className:"new-agent-workbench__inline-error",role:"alert",children:[o.jsx("span",{children:l}),o.jsx(jt,{color:"secondary",variant:"ghost",size:"sm",pill:!1,onClick:()=>d(m=>m+1),children:"重试"})]}):h!=null&&h.isCurrent?o.jsx("small",{className:"new-agent-workbench__helper-text",children:"当前 Studio 的登录 JWT 将透传访问此 Runtime"}):h?o.jsx("small",{className:"new-agent-workbench__error",children:"所选用户池不是当前 Studio 使用的用户池,部署后无法从 Studio 调用此 Runtime"}):o.jsx("small",{className:"new-agent-workbench__helper-text",children:"当前 Studio 使用的用户池已在列表中标注"})]})}function Fee({name:e,value:t,required:n=!1,placeholder:r,locked:i=!1,onRename:s,onValueChange:a,onRemove:l}){const[c,u]=p.useState(e);p.useEffect(()=>u(e),[e]);const d=()=>{const f=c.trim().toUpperCase();if(!f){u(e);return}u(f),f!==e&&s(e,f)};return o.jsxs("div",{className:`new-agent-workbench__env-row${i?" is-locked":""}`,role:"row",children:[o.jsx("div",{className:"new-agent-workbench__env-cell",role:"cell",children:o.jsx(Ui,{"aria-label":"环境变量名称",value:c,title:i?e:void 0,size:"xl",gutterSize:"md",pill:!1,disabled:i,onChange:f=>u(f.currentTarget.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&f.currentTarget.blur()}})}),o.jsx("div",{className:"new-agent-workbench__env-cell",role:"cell",children:o.jsx(Ui,{"aria-label":`${e} 的值`,value:t,size:"xl",gutterSize:"md",pill:!1,type:/(SECRET|PASSWORD|KEY|TOKEN)$/.test(e)?"password":"text",placeholder:r,required:n,onChange:f=>a(f.currentTarget.value)})}),o.jsx("div",{className:"new-agent-workbench__env-action",role:"cell",children:i?n?o.jsx("span",{className:"new-agent-workbench__required","aria-label":"必填",children:"*"}):null:o.jsx(jt,{color:"secondary",variant:"ghost",size:"lg",uniform:!0,pill:!1,"aria-label":`删除 ${e}`,onClick:l,children:o.jsx(CRe,{"aria-hidden":!0})})})]})}function YRt({draft:e,cloudProvider:t,deployRegion:n,runtimeName:r,isRuntimeUpdate:i=!1,deploying:s,deployStage:a,deployError:l,deploySucceeded:c,showErrors:u,onBack:d,onDraftPatch:f,onDeploymentPatch:h,onModelApiKeyChange:m,customModelApiKey:g,onCustomModelApiKeyChange:b,onSelectedSkillsChange:y,onCloudEnvironmentChange:O,onDeployRegionChange:v,onRuntimeNameChange:x,onNetworkChange:w,onDeploy:S}){var ve,He,pt,_t,It,Kt,en,le,Xt;const E=J8(),[k,_]=p.useState("agent"),[T,C]=p.useState(!1),A=p.useRef(null),[R,M]=p.useState(!1),[I,$]=p.useState(!1),[N,j]=p.useState(!0),[B,F]=p.useState("api_key"),[L,H]=p.useState(""),[z,Q]=p.useState(()=>{const Fe=e.shortTermBackend||"local";return e.memory.shortTerm&&Uee(Fe)?Fe:"local"}),V=XRt(z),[K,se]=p.useState("1"),[ge,ie]=p.useState(V==="in-memory"?"1":"5"),[q,G]=p.useState(!0),[J,ue]=p.useState(Lve),[Oe,Qe]=p.useState(""),[je,ze]=p.useState(null),[Ge,Ae]=p.useState({top:!1,bottom:!1}),Be=p.useRef(null),he=g_.findIndex(Fe=>Fe.id===k),be=g_[he],Se=C1(e.name),Ee=Se!==null,tt=!e.description.trim(),Ue=!e.instruction.trim(),re=am(e,t),ce=!((ve=e.modelName)!=null&&ve.trim()),Me=re==="ark"&&!((pt=(He=e.deployment)==null?void 0:He.modelApiKeyId)!=null&&pt.trim()),Ye=Ee||tt||Ue||ce||Me,Z=((It=(_t=e.deployment)==null?void 0:_t.network)==null?void 0:It.mode)??"public",_e=(Kt=e.deployment)==null?void 0:Kt.network,rt=Ed(t),Re=((en=e.deployment)==null?void 0:en.envValues)??{},We=by.find(Fe=>Fe.id===z)??by[0],ct=((We==null?void 0:We.env)??[]).filter(Fe=>!Fe.hidden),kt=new Set(ct.map(Fe=>Fe.key)),qt=Object.entries(Re).filter(([Fe])=>Fe!=="FEISHU_APP_ID"&&Fe!=="FEISHU_APP_SECRET"&&!kt.has(Fe)),Dt=(Fe,Pt)=>{h({envValues:{...Re,[Fe]:Pt}})},Xe=(Fe,Pt)=>{const Ce=Object.fromEntries(Object.entries(Re).map(([gt,Vt])=>gt===Fe?[Pt,Vt]:[gt,Vt]));h({envValues:Ce})},nt=Fe=>{const Pt={...Re};delete Pt[Fe],h({envValues:Pt})},ft=()=>{let Fe=qt.length+1,Pt=`CUSTOM_ENV_${Fe}`;for(;Pt in Re;)Pt=`CUSTOM_ENV_${++Fe}`;Dt(Pt,"")};p.useEffect(()=>{const Fe=Be.current;if(!Fe)return;const Pt=()=>{const ot={top:Fe.scrollTop>1,bottom:Fe.scrollTop+Fe.clientHeightln.top===ot.top&&ln.bottom===ot.bottom?ln:ot)};Fe.scrollTo({top:0,behavior:"auto"}),Fe.addEventListener("scroll",Pt,{passive:!0});const Ce=new ResizeObserver(Pt);Ce.observe(Fe);const gt=new MutationObserver(Pt);gt.observe(Fe,{childList:!0,subtree:!0});const Vt=window.requestAnimationFrame(Pt);return()=>{window.cancelAnimationFrame(Vt),Fe.removeEventListener("scroll",Pt),Ce.disconnect(),gt.disconnect()}},[k]),p.useEffect(()=>{se("1"),ie(V==="in-memory"?"1":"5")},[V]);const xt=()=>{if(he===0){if(T)return;if(E){d();return}A.current=d,C(!0);return}_(g_[he-1].id)},Ie=()=>{if(!T)return;const Fe=A.current;A.current=null,Fe==null||Fe()},xe=()=>{if(k==="agent"){if(M(!0),Ye)return;_("environment");return}if(k==="environment"){_("deployment");return}const Fe=Number(K),Pt=Number(ge);if(!K.trim()||!ge.trim()||!Number.isSafeInteger(Fe)||Fe<0||!Number.isSafeInteger(Pt)||Pt<1){Qe("最小实例数必须为大于等于 0 的整数,最大实例数必须为大于 0 的整数");return}if(Fe>Pt){Qe("最小实例数不能大于最大实例数");return}if(B==="user_pool"&&!L){Qe("请选择用于 Runtime 鉴权的用户池");return}const Ce=Bve(J);if(Ce){ze(Ce),Qe(Ce);return}ze(null),Qe(""),S({authentication:B==="user_pool"?{type:"user_pool",userPoolUid:L}:{type:"api_key"},sessionStorage:V,sessionBackend:z,minInstance:Fe,maxInstance:Pt,createEvaluationSets:t==="byteplus"?!1:q,resources:J})},$e=u||R,it=$e||I;return o.jsxs(ai.div,{className:`new-agent-workbench${T?" is-leaving":""}`,initial:E?!1:{opacity:0},animate:{opacity:T?0:1},transition:{duration:T?.12:.18,ease:[.16,1,.3,1]},onAnimationComplete:Ie,children:[o.jsx("main",{className:"new-agent-workbench__main","aria-label":"快速模式创建",children:o.jsxs("section",{className:"new-agent-workbench__form","aria-labelledby":"new-agent-workbench-title",children:[o.jsx(fu,{mode:"wait",initial:!1,children:o.jsxs(ai.div,{className:"new-agent-workbench__heading",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:[o.jsx("h1",{id:"new-agent-workbench-title",children:be.title}),o.jsx("p",{children:be.description})]},`heading-${k}`)}),o.jsxs("div",{className:"new-agent-workbench__panel-frame",children:[o.jsx("div",{ref:Be,className:"new-agent-workbench__panel",children:o.jsxs(fu,{mode:"wait",initial:!1,children:[k==="agent"?o.jsxs(ai.div,{className:"new-agent-workbench__fields",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:[o.jsxs("label",{className:"new-agent-workbench__field","data-validation-field":"name",children:[o.jsxs("span",{className:"new-agent-workbench__field-heading",children:[o.jsxs("span",{children:["名称",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsxs("small",{children:[e.name.length,"/50"]})]}),o.jsx(Ui,{value:e.name,maxLength:50,size:"xl",gutterSize:"md",pill:!1,invalid:it&&Ee,placeholder:"输入智能体名称","aria-describedby":it&&Se?"new-agent-workbench-name-error":void 0,onBlur:()=>$(!0),onChange:Fe=>{$(!0),f({name:Fe.currentTarget.value})}}),it&&Se?o.jsx("small",{id:"new-agent-workbench-name-error",className:"new-agent-workbench__error",role:"alert",children:Se}):null]}),o.jsxs("label",{className:"new-agent-workbench__field","data-validation-field":"description",children:[o.jsxs("span",{children:["描述",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(md,{value:e.description,rows:4,maxRows:8,autoResize:!0,size:"xl",gutterSize:"md",invalid:$e&&tt,placeholder:"说明这个智能体可以做什么",onChange:Fe=>f({description:Fe.currentTarget.value})}),$e&&tt?o.jsx("small",{className:"new-agent-workbench__error",children:"请输入描述"}):null]}),o.jsxs("label",{className:"new-agent-workbench__field","data-validation-field":"instruction",children:[o.jsxs("span",{children:["提示词",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(md,{value:e.instruction,rows:10,maxRows:18,autoResize:!0,size:"xl",gutterSize:"md",invalid:$e&&Ue,placeholder:"定义角色、目标和行为边界",onChange:Fe=>f({instruction:Fe.currentTarget.value})}),$e&&Ue?o.jsx("small",{className:"new-agent-workbench__error",children:"请输入提示词"}):null]}),o.jsx(GRt,{cloudProvider:t,source:re,value:e.modelName??"",apiKeyId:(le=e.deployment)==null?void 0:le.modelApiKeyId,apiKeyName:(Xt=e.deployment)==null?void 0:Xt.modelApiKeyName,provider:e.modelProvider??"",apiBase:e.modelApiBase??"",customApiKey:g,onSourceChange:Fe=>{var Pt;j(Fe==="ark"),f({modelSource:Fe,modelName:Fe==="custom"&&re==="ark"?"":Fe==="ark"&&!((Pt=e.modelName)!=null&&Pt.trim())?eh(t):e.modelName})},onApiKeyChange:m,onModelNameChange:Fe=>f({modelName:Fe}),onProviderChange:Fe=>f({modelProvider:Fe}),onApiBaseChange:Fe=>f({modelApiBase:Fe}),onCustomApiKeyChange:b,onLoadingChange:j}),$e&&ce?o.jsx("p",{className:"new-agent-workbench__error",role:"alert",children:"请选择模型"}):null,o.jsxs("div",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"技能"}),o.jsx(mU,{selected:e.selectedSkills??[],onChange:y,cloudProvider:t,disabled:s,addLabel:"添加技能",showSelectedCount:!1})]})]},"agent"):null,k==="environment"?o.jsx(ai.div,{className:"new-agent-workbench__fields",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:o.jsx("div",{className:"new-agent-workbench__environment",children:o.jsx(Ywe,{value:e.cloudEnvironment??{environmentId:"",environmentVersionId:""},onChange:O,disabled:s,controlSize:"xl",controlClassName:"new-agent-workbench__select-trigger",optionClassName:Sf})})},"environment"):null,k==="deployment"?o.jsxs(ai.div,{className:"new-agent-workbench__fields",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsxs("span",{children:["Runtime 名称",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Ui,{value:r,disabled:s||i,size:"xl",gutterSize:"md",pill:!1,placeholder:"agent-runtime",onChange:Fe=>x(Fe.currentTarget.value)}),o.jsx("small",{className:"new-agent-workbench__helper-text",children:i?"更新时保持现有 Runtime 名称不变":"仅支持英文字母、数字、下划线和连字符"})]}),o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsxs("span",{children:["发布区域",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Wo,{value:n,options:rt,size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,disabled:s||i,onChange:Fe=>v(Fe.value)})]}),o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"鉴权方式"}),o.jsx(Wo,{value:B,options:[{value:"api_key",label:"API Key",description:"默认方式,使用 Runtime API Key 访问"},{value:"user_pool",label:"用户池",description:"使用 Identity 用户池签发的 JWT"}],size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,disabled:s,onChange:Fe=>{F(Fe.value),Qe("")}})]}),B==="user_pool"?o.jsx(WRt,{value:L,disabled:s,onChange:Fe=>{H(Fe),Qe("")}}):null]}),o.jsx("div",{className:"new-agent-workbench__deployment-section",children:o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"会话存储"}),o.jsx(Wo,{value:z,options:by.map(Fe=>({value:Fe.id,label:Fe.id==="local"?"In-memory 临时存储":Fe.label})),size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,disabled:s,onChange:Fe=>{Uee(Fe.value)&&(Q(Fe.value),f({memory:{...e.memory,shortTerm:Fe.value!=="local"},shortTermBackend:Fe.value}),Qe(""))}})]})}),o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsx("strong",{className:"new-agent-workbench__section-title",children:"实例设置"}),o.jsxs("div",{className:"new-agent-workbench__instance-fields",children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"最小实例数"}),o.jsx(Ui,{type:"number",min:0,step:1,value:K,size:"xl",gutterSize:"md",pill:!1,disabled:s,onChange:Fe=>{se(Fe.currentTarget.value),Qe("")}})]}),o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{className:"new-agent-workbench__model-field-label",children:"最大实例数"}),o.jsx(Ui,{type:"number",min:1,step:1,value:ge,size:"xl",gutterSize:"md",pill:!1,disabled:s,onChange:Fe=>{ie(Fe.currentTarget.value),Qe("")}})]})]}),V==="in-memory"?o.jsx("small",{className:"new-agent-workbench__helper-text",children:"为避免多实例间会话丢失,推荐将 Runtime 固定为 1~1"}):null]}),o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"网络模式"}),o.jsx(Wo,{value:Z,options:[{value:"public",label:"公网"},{value:"private",label:"私网"},{value:"both",label:"公网与私网"}],size:"xl",triggerClassName:"new-agent-workbench__select-trigger",optionClassName:Sf,pill:!1,onChange:Fe=>w(Fe.value==="public"?void 0:{..._e??{},mode:Fe.value})})]}),Z!=="public"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"new-agent-workbench__field-row",children:[o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsxs("span",{children:["VPC ID",o.jsx("span",{className:"new-agent-workbench__required",children:"*"})]}),o.jsx(Ui,{value:(_e==null?void 0:_e.vpcId)??"",size:"xl",gutterSize:"md",pill:!1,placeholder:"vpc-xxx",onChange:Fe=>w({..._e??{mode:Z},vpcId:Fe.currentTarget.value})})]}),o.jsxs("label",{className:"new-agent-workbench__field",children:[o.jsx("span",{children:"子网 ID(可选,多个用逗号分隔)"}),o.jsx(Ui,{value:(_e==null?void 0:_e.subnetIds)??"",size:"xl",gutterSize:"md",pill:!1,placeholder:"subnet-xxx",onChange:Fe=>w({..._e??{mode:Z},subnetIds:Fe.currentTarget.value})})]})]}),o.jsxs("div",{className:"new-agent-workbench__switch-row",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"VPC 内共享公网出口"}),o.jsx("span",{children:"允许私网 Runtime 通过共享出口访问公网"})]}),o.jsx(W6,{checked:!!(_e!=null&&_e.enableSharedInternetAccess),onCheckedChange:Fe=>w({..._e??{mode:Z},enableSharedInternetAccess:Fe}),"aria-label":"VPC 内共享公网出口"})]})]}):null]}),t!=="byteplus"?o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsx("strong",{className:"new-agent-workbench__section-title",children:"评测集"}),o.jsxs("div",{className:"new-agent-workbench__switch-row",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"自动创建评测集"}),o.jsx("span",{children:"部署成功后自动创建 Good Case 和 Bad Case 评测集"})]}),o.jsx(W6,{checked:q,onCheckedChange:G,"aria-label":"自动创建评测集"})]})]}):null,o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsx("strong",{className:"new-agent-workbench__section-title",children:"资源配置"}),o.jsx(Qve,{value:J,agentName:e.name||"agentkit-app",runtimeName:r,region:n,disabled:s,validationError:je,onChange:Fe=>{ue(Fe),ze(null),Qe("")}})]}),o.jsxs("div",{className:"new-agent-workbench__deployment-section",children:[o.jsxs("div",{className:"new-agent-workbench__env-head",children:[o.jsx("strong",{className:"new-agent-workbench__section-title",children:"环境变量"}),o.jsxs(jt,{color:"secondary",variant:"ghost",size:"sm",pill:!1,onClick:ft,children:[o.jsx(Nae,{"aria-hidden":!0}),"添加变量"]})]}),o.jsxs("div",{className:"new-agent-workbench__env-table",role:"table","aria-label":"环境变量",children:[o.jsxs("div",{className:"new-agent-workbench__env-table-head",role:"row",children:[o.jsx("span",{role:"columnheader",children:"名称"}),o.jsx("span",{role:"columnheader",children:"值"}),o.jsx("span",{role:"columnheader",children:"操作"})]}),o.jsxs("div",{className:"new-agent-workbench__env-table-body",role:"rowgroup",children:[ct.map(Fe=>o.jsx(Fee,{name:Fe.key,value:Re[Fe.key]??Fe.defaultValue??"",required:Fe.required,placeholder:Fe.placeholder,locked:!0,onRename:()=>{},onValueChange:Pt=>Dt(Fe.key,Pt),onRemove:()=>{}},Fe.key)),qt.map(([Fe,Pt])=>o.jsx(Fee,{name:Fe,value:Pt,onRename:Xe,onValueChange:Ce=>Dt(Fe,Ce),onRemove:()=>nt(Fe)},Fe)),!ct.length&&!qt.length?o.jsx("div",{className:"new-agent-workbench__empty-row new-agent-workbench__env-table-empty",role:"row",children:o.jsx("span",{role:"cell",children:"无"})}):null]})]})]}),Oe?o.jsx(t0,{message:Oe,defaultExpanded:!0}):l?o.jsx(t0,{message:l,defaultExpanded:!0}):a||c?o.jsxs("div",{className:"new-agent-workbench__deploy-status",role:"status",children:[c?o.jsx(Cae,{"aria-hidden":!0}):null,o.jsx("span",{children:(a==null?void 0:a.message)||(c?"部署已完成":"正在准备部署…")}),typeof(a==null?void 0:a.pct)=="number"?o.jsxs("strong",{children:[Math.round(a.pct),"%"]}):null]}):null]},"deployment"):null]})}),o.jsx("span",{className:`new-agent-workbench__scroll-fade is-top${Ge.top?" is-visible":""}`,"aria-hidden":"true"}),o.jsx("span",{className:`new-agent-workbench__scroll-fade is-bottom${Ge.bottom?" is-visible":""}`,"aria-hidden":"true"})]}),o.jsx(fu,{mode:"wait",initial:!1,children:o.jsxs(ai.div,{className:"new-agent-workbench__actions",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.16,ease:"easeOut"},children:[o.jsxs(jt,{color:"secondary",variant:"outline",size:"lg",pill:!1,disabled:s,onClick:xt,children:[o.jsx(cRe,{"aria-hidden":!0}),he===0?"返回":"上一步"]}),o.jsx(jt,{color:"primary",size:"lg",pill:!1,loading:s,disabled:s||k==="agent"&&N,onClick:xe,children:k==="deployment"?c?i?"再次更新":"重新部署":i?"更新并发布":"部署":"下一步"})]},`actions-${k}`)})]})}),o.jsx("footer",{className:"new-agent-workbench__footer",children:o.jsx("div",{className:"new-agent-workbench__footer-inner",children:o.jsx("nav",{"aria-label":"快速模式创建进度",children:o.jsx("ol",{className:"new-agent-workbench__progress",children:g_.map((Fe,Pt)=>o.jsx("li",{className:Pt===he?"is-active":"","aria-current":Pt===he?"step":void 0,"aria-label":Fe.label,title:Fe.label,children:o.jsx("span",{"aria-hidden":"true"})},Fe.id))})})})})]})}async function ZRt(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:il(void 0,Ao)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 AgentKit 智能体中心");if(t.status===401)throw new Error("请先登录以访问 AgentKit 智能体中心");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function KRt(e={}){const t=new URLSearchParams({page_size:String(e.pageSize??100),project:e.project||"default"});return e.region&&t.set("region",e.region),(await ZRt(`/web/a2a-spaces?${t.toString()}`)).items||[]}async function JRt(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:il(void 0,Ao)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 VikingDB 知识库");if(t.status===401)throw new Error("请先登录以访问 VikingDB 知识库");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function eIt(e={}){const t=new URLSearchParams;e.project&&t.set("project",e.project),e.region&&t.set("region",e.region);const n=t.toString();return(await JRt(`/web/viking-knowledgebases${n?`?${n}`:""}`)).items||[]}async function tIt(e){const t=await fetch(e,{headers:{accept:"application/json"},signal:il(void 0,Ao)});if(t.status===409)throw new Error("服务端未配置云厂商 AK/SK,无法访问 VikingDB 记忆库");if(t.status===401)throw new Error("请先登录以访问 VikingDB 记忆库");if(!t.ok){let n="";try{n=(await t.json()).detail||""}catch{}throw new Error(`请求失败 (${t.status})${n?": "+n:""}`)}return t.json()}async function nIt(e={}){const t=new URLSearchParams;e.project&&t.set("project",e.project),e.region&&t.set("region",e.region);const n=t.toString();return(await tIt(`/web/viking-memories${n?`?${n}`:""}`)).items||[]}const zee=["#6366f1","#0ea5e9","#10b981","#f59e0b","#f43f5e","#a855f7","#14b8a6","#f472b6"];function r3(e){let t=0;for(let n=0;n>>0;return zee[t%zee.length]}const rIt=2,iIt=1500;function sIt(e){return e.includes("HTTP 425")||e.includes("仍在采集中")?"collecting":e.includes("HTTP 404")||e.includes("未开启链路观测")?"disabled":/HTTP 40[13]/.test(e)||e.includes("无权限读取 APMPlus")?"forbidden":"error"}const Vee={collecting:"调用链路仍在采集中,请稍候。",disabled:"该 Agent 未开启链路观测,请到控制台开启后重试。",forbidden:"当前账号无权读取 APMPlus 调用链路,请联系管理员补充只读权限。",error:"调用链路加载失败,请稍后重试。"},aIt={loading:"加载中",ready:"",collecting:"采集中",disabled:"未开启",forbidden:"权限不足",error:"加载失败"};function oIt(e){const t=new Map;e.forEach(u=>t.set(u.span_id,u));const n=new Map,r=[];for(const u of e)u.parent_span_id!=null&&t.has(u.parent_span_id)?(n.get(u.parent_span_id)??n.set(u.parent_span_id,[]).get(u.parent_span_id)).push(u):r.push(u);const i=(u,d)=>u.start_time-d.start_time,s=(u,d)=>({span:u,depth:d,children:(n.get(u.span_id)??[]).sort(i).map(f=>s(f,d+1))}),a=r.sort(i).map(u=>s(u,0)),l=e.length?Math.min(...e.map(u=>u.start_time)):0,c=e.length?Math.max(...e.map(u=>u.end_time)):1;return{rootNodes:a,min:l,total:c-l||1}}function lIt(e,t){const n=[],r=i=>{n.push(i),t.has(i.span.span_id)||i.children.forEach(r)};return e.forEach(r),n}function Hee(e){const t=e/1e6;return t>=1e3?`${(t/1e3).toFixed(2)} s`:`${t.toFixed(t<10?2:1)} ms`}const cIt=e=>e.replace(/^(gen_ai|a2ui|adk)\./,"");function qee(e){return Object.entries(e.attributes).filter(([,t])=>t!=null&&typeof t!="object").map(([t,n])=>{const r=String(n);return{key:cIt(t),value:r,long:r.length>80||r.includes(`
+`)}}).sort((t,n)=>Number(t.long)-Number(n.long))}function Zwe({appName:e,testRunId:t,sessionId:n,endTimeMs:r,onClose:i,title:s="调用链路观测"}){const[a,l]=p.useState(null),[c,u]=p.useState("loading"),[d,f]=p.useState(0),[h,m]=p.useState(new Set),[g,b]=p.useState(null),y=p.useRef(0),O=`${e??""}:${t??""}:${n}:${r??""}`,v=p.useRef(O);p.useEffect(()=>{v.current!==O&&(v.current=O,y.current=0),l(null),u("loading");let A=!1,R,M;if(t)M=xle(t,n);else if(e)M=vC(e,n,r);else{u("error");return}return M.then(I=>{A||(l(I),u("ready"),b(I.length?I.reduce(($,N)=>$.start_time<=N.start_time?$:N).span_id:null))}).catch(I=>{if(A)return;const $=sIt(I instanceof Error?I.message:String(I));u($),$==="collecting"&&y.currentf(N=>N+1),iIt))}),()=>{A=!0,R!==void 0&&window.clearTimeout(R)}},[e,r,d,n,O,t]);const x=()=>{y.current=0,f(A=>A+1)},{rootNodes:w,min:S,total:E}=p.useMemo(()=>oIt(a??[]),[a]),k=p.useMemo(()=>lIt(w,h),[w,h]),_=(a==null?void 0:a.find(A=>A.span_id===g))??null,T=E/1e6,C=A=>m(R=>{const M=new Set(R);return M.has(A)?M.delete(A):M.add(A),M});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"drawer-scrim",onClick:i}),o.jsxs("aside",{className:"drawer drawer--trace",children:[o.jsxs("header",{className:"drawer-head",children:[o.jsxs("div",{children:[o.jsx("div",{className:"drawer-title",children:s}),o.jsx("div",{className:"drawer-sub",children:c==="ready"&&a?`${a.length} 个调用 · ${T.toFixed(1)} ms`:aIt[c]})]}),o.jsx("button",{className:"drawer-close",onClick:i,"aria-label":"关闭",children:o.jsx(Ea,{className:"icon"})})]}),c==="loading"&&o.jsxs("div",{className:"drawer-loading",children:[o.jsx(rr,{className:"icon spin"})," 加载调用链路…"]}),c==="collecting"&&o.jsxs("div",{className:"drawer-loading",role:"status","aria-live":"polite",children:[o.jsx(rr,{className:"icon spin"}),o.jsx("span",{children:Vee.collecting}),o.jsx(jt,{type:"button",color:"secondary",variant:"outline",size:"sm",pill:!1,onClick:x,children:"立即重试"})]}),(c==="disabled"||c==="forbidden"||c==="error")&&o.jsxs("div",{className:"drawer-empty trace-state",role:"alert",children:[o.jsx("span",{children:Vee[c]}),c==="error"&&o.jsx(jt,{type:"button",color:"secondary",variant:"outline",size:"sm",pill:!1,onClick:x,children:"重新加载"})]}),c==="ready"&&a&&a.length===0&&o.jsx("div",{className:"drawer-empty",children:"该会话暂无调用链路(可能尚未产生调用)。"}),k.length>0&&o.jsxs("div",{className:"trace-split",children:[o.jsx("div",{className:"trace-tree scroll",children:k.map(A=>{const R=A.span,M=(R.start_time-S)/E*100,I=Math.max((R.end_time-R.start_time)/E*100,.6),$=A.children.length>0;return o.jsxs("button",{className:`trace-row ${g===R.span_id?"active":""}`,onClick:()=>b(R.span_id),children:[o.jsxs("span",{className:"trace-label",style:{paddingLeft:A.depth*14},children:[o.jsx("span",{className:`trace-caret ${$?"":"hidden"} ${h.has(R.span_id)?"":"open"}`,onClick:N=>{N.stopPropagation(),$&&C(R.span_id)},children:o.jsx(XS,{className:"chev"})}),o.jsx("span",{className:"trace-dot",style:{background:r3(R.name)}}),o.jsx("span",{className:"trace-name",title:R.name,children:R.name})]}),o.jsx("span",{className:"trace-dur",children:Hee(R.end_time-R.start_time)}),o.jsx("span",{className:"trace-track",children:o.jsx("span",{className:"trace-bar",style:{left:`${M}%`,width:`${I}%`,background:r3(R.name)}})})]},R.span_id)})}),o.jsx("div",{className:"trace-detail scroll",children:_?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"td-title",children:_.name}),o.jsxs("div",{className:"td-dur",children:[o.jsx("span",{className:"td-dot",style:{background:r3(_.name)}}),Hee(_.end_time-_.start_time)]}),o.jsx("div",{className:"td-section",children:"属性"}),o.jsx("div",{className:"td-props",children:qee(_).filter(A=>!A.long).map(A=>o.jsxs("div",{className:"td-prop",children:[o.jsx("span",{className:"td-key",children:A.key}),o.jsx("span",{className:"td-val",children:A.value})]},A.key))}),qee(_).filter(A=>A.long).map(A=>o.jsxs("div",{className:"td-block",children:[o.jsx("div",{className:"td-section",children:A.key}),o.jsx("pre",{className:"td-pre",children:A.value})]},A.key))]}):o.jsx("div",{className:"drawer-empty",children:"选择左侧的一个调用查看详情"})})]})]})]})}const uIt=p.lazy(()=>fd(()=>import("../chunks/MarkdownPromptEditor-YxGdWdMM.js"),__vite__mapDeps([2,3]))),s$="veadk.generatedAgentTestRuns",Xee=4;function RU(){if(typeof window>"u")return[];try{const e=JSON.parse(window.sessionStorage.getItem(s$)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}catch{return[]}}function Kwe(e){if(typeof window>"u")return;const t=Array.from(new Set(e)).slice(-20);try{t.length?window.sessionStorage.setItem(s$,JSON.stringify(t)):window.sessionStorage.removeItem(s$)}catch{}}function dIt(e){Kwe([...RU(),e])}function kx(e){Kwe(RU().filter(t=>t!==e))}function fIt(e,t,n="text/plain"){const r=URL.createObjectURL(new Blob([t],{type:`${n};charset=utf-8`})),i=document.createElement("a");i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}const hIt=[{id:"type",label:"Agent 类型",hint:"选择 Agent 类型",icon:oIe,required:!0},{id:"basic",label:"基本信息",hint:"名称、描述与系统提示词",icon:Sd,required:!0},{id:"model",label:"模型配置",hint:"模型与服务(可选)",icon:zRe},{id:"tools",label:"工具",hint:"可调用的能力",icon:dIe},{id:"skills",label:"技能",hint:"声明式技能",icon:Sw},{id:"knowledge",label:"知识库",hint:"外部知识检索",icon:U_},{id:"memory",label:"记忆",hint:"短期与长期记忆",icon:Bae},{id:"subagents",label:"子 Agent",hint:"嵌套协作",icon:MRe},{id:"review",label:"完成",hint:"预览并创建",icon:aIe}];function pIt({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M9 7.15v9.7a1.15 1.15 0 0 0 1.78.96l7.2-4.85a1.15 1.15 0 0 0 0-1.92l-7.2-4.85A1.15 1.15 0 0 0 9 7.15Z"}),o.jsx("path",{d:"M5.75 8.25v7.5",opacity:"0.8"}),o.jsx("path",{d:"M3 10v4",opacity:"0.45"}),o.jsx("path",{d:"M17.9 5.25v2.2M19 6.35h-2.2",strokeWidth:"1.55"})]})}function Gee({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M4.75 7.25h14.5"}),o.jsx("path",{d:"M9.1 4.75h5.8l.75 2.5h-7.3l.75-2.5Z"}),o.jsx("path",{d:"m6.75 7.25.75 12h9l.75-12"}),o.jsx("path",{d:"M10 10.25v5.75M14 10.25v5.75"})]})}function IU({className:e}){return o.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("path",{d:"m7 9 5 5 5-5"})})}function DU({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("path",{d:"M18.25 8.2A7.1 7.1 0 0 0 6.1 6.65L4.5 8.25"}),o.jsx("path",{d:"M4.5 4.75v3.5H8"}),o.jsx("path",{d:"M5.75 15.8A7.1 7.1 0 0 0 17.9 17.35l1.6-1.6"}),o.jsx("path",{d:"M19.5 19.25v-3.5H16"})]})}const mIt={llm:"智能体",sequential:"分步协作",parallel:"同时处理",loop:"循环执行",a2a:"远程智能体"},Wee={REGISTRY_SPACE_ID:"registrySpaceId",REGISTRY_TOP_K:"registryTopK",REGISTRY_REGION:"registryRegion",REGISTRY_ENDPOINT:"registryEndpoint"},Jwe="REGISTRY_SPACE_ID",gIt=hhe.filter(e=>e.key!==Jwe);function eSe(e,t,n="volcengine"){var s,a,l;if(!(e!=null&&e.enabled))return{};const r=wj(n),i={REGISTRY_SPACE_ID:e.registrySpaceId??""};return t.includeDefaults?(i.REGISTRY_TOP_K=((s=e.registryTopK)==null?void 0:s.trim())||r.topK,i.REGISTRY_REGION=((a=e.registryRegion)==null?void 0:a.trim())||r.region,i.REGISTRY_ENDPOINT=((l=e.registryEndpoint)==null?void 0:l.trim())||r.endpoint):(i.REGISTRY_TOP_K=e.registryTopK??"",i.REGISTRY_REGION=e.registryRegion??"",i.REGISTRY_ENDPOINT=e.registryEndpoint??""),i}function Eb(e,t){if(t!=="byteplus")return e;const n=wj(t);return e.map(r=>r.key==="REGISTRY_REGION"?{...r,placeholder:n.region}:r.key==="REGISTRY_ENDPOINT"?{...r,placeholder:n.endpoint}:r.key==="MODEL_EMBEDDING_NAME"?{...r,placeholder:h5e(t)}:r.key==="MODEL_EMBEDDING_API_BASE"?{...r,placeholder:nl(t)}:r.key==="MODEL_IMAGE_NAME"?{...r,placeholder:m5e(t)}:r.key==="MODEL_EDIT_NAME"?{...r,placeholder:g5e(t)}:r.key==="MODEL_VIDEO_NAME"?{...r,placeholder:b5e(t)}:r.key==="MODEL_IMAGE_API_BASE"||r.key==="MODEL_EDIT_API_BASE"||r.key==="MODEL_VIDEO_API_BASE"?{...r,placeholder:nl(t)}:r)}function bIt({items:e,selected:t,onToggle:n,scrollRows:r}){return o.jsx("div",{className:`cw-checklist ${r?"cw-checklist-tools":""}`,style:r?{"--cw-checklist-max-height":`${r*40+(r-1)*8}px`}:void 0,children:e.map(i=>{const s=t.includes(i.id);return o.jsx(jU,{id:`cw-check-${i.id}`,className:`cw-check ${s?"is-on":""}`,checked:s,onCheckedChange:a=>{a!==s&&n(i.id)},label:o.jsx("span",{className:"cw-check-text",children:o.jsx("span",{className:"cw-check-title",children:i.label})})},i.id)})})}function i3({options:e,value:t,onChange:n}){return o.jsx("div",{className:"cw-segmented",children:e.map(r=>{var s;const i=(t??((s=e[0])==null?void 0:s.id))===r.id;return o.jsx("button",{type:"button",className:`cw-seg ${i?"is-on":""}`,onClick:()=>n(r.id),"aria-pressed":i,children:o.jsx("span",{className:"cw-seg-title",children:r.label})},r.id)})})}function yIt(e){return/(SECRET|PASSWORD|KEY|TOKEN)$/.test(e)}function _x({env:e,values:t,onChange:n,renderAfterField:r}){const i=e.filter(s=>!s.hidden);return i.length===0?o.jsx("p",{className:"cw-env-empty",children:"此后端无需额外运行参数。"}):o.jsx("div",{className:"cw-env-fields",children:i.map(s=>{const a=t[s.key]??s.defaultValue??"",l=AU(s,t),c=`cw-env-${s.key}`;return o.jsxs(p.Fragment,{children:[o.jsxs("label",{className:"cw-env-field",htmlFor:c,children:[o.jsxs("span",{className:"cw-env-field-head",children:[o.jsxs("span",{className:"cw-env-field-title",children:[o.jsxs("span",{className:"cw-env-field-label",children:[s.comment||s.key,s.required&&o.jsx("span",{className:"cw-req",children:"*"})]}),s.help&&o.jsxs("span",{className:"cw-env-help",tabIndex:0,"data-help":s.help,"aria-label":`${s.comment||s.key}说明:${s.help}`,children:["?",o.jsx("span",{className:"cw-env-help-popover",role:"tooltip",children:s.help})]}),s.link&&o.jsx("a",{className:"cw-env-link",href:s.link.url,target:"_blank",rel:"noopener noreferrer",title:`打开 OpenViking ${s.link.label}`,"aria-label":`打开 OpenViking ${s.link.label}`,onClick:u=>u.stopPropagation(),children:o.jsx(Dg,{"aria-hidden":"true"})})]}),s.comment&&o.jsx("code",{title:s.key,children:s.key})]}),s.multiline||s.format==="json"?o.jsx("textarea",{id:c,className:"cw-input cw-env-textarea",value:a,placeholder:s.placeholder||"请输入参数值",autoComplete:"off",spellCheck:!1,"aria-invalid":!!l,onChange:u=>n(s.key,u.currentTarget.value)}):o.jsx("input",{id:c,className:"cw-input",type:yIt(s.key)?"password":"text",value:a,placeholder:s.placeholder||"请输入参数值",autoComplete:"off","aria-invalid":!!l,onChange:u=>n(s.key,u.currentTarget.value)}),l&&o.jsx("span",{className:"cw-env-error",children:l})]}),r==null?void 0:r(s)]},s.key)})})}const s3="默认值:留空;生成项目时使用 Agent 名自动生成,例如 my_agent_kb。未配置 DATABASE_OPENVIKING_TARGET_URI 时,默认 URI 拼接为 viking://user/{知识库归属 ID,未填则 default}/resources/{资源索引}/;如果填写了 DATABASE_OPENVIKING_TARGET_URI,则直接使用该完整 URI。";function OIt({value:e,onChange:t}){const n="cw-openviking-knowledge-index";return o.jsxs("label",{className:"cw-env-field",htmlFor:n,children:[o.jsx("span",{className:"cw-env-field-head",children:o.jsxs("span",{className:"cw-env-field-title",children:[o.jsx("span",{className:"cw-env-field-label",children:"OpenViking 资源索引"}),o.jsxs("span",{className:"cw-env-help",tabIndex:0,"data-help":s3,"aria-label":`OpenViking 资源索引说明:${s3}`,children:["?",o.jsx("span",{className:"cw-env-help-popover",role:"tooltip",children:s3})]})]})}),o.jsx("input",{id:n,className:"cw-input",value:e,placeholder:"",autoComplete:"off",onChange:r=>t(r.currentTarget.value)})]})}function a3(e){return e.name.trim()||"未命名智能体中心"}function Yee(e){const t=e.name.trim()||e.id||"未命名知识库",n=[e.sourceLabel,e.projectName].filter(Boolean);return n.length?`${t} · ${n.join(" · ")}`:t}function Zee(e){return e.name.trim()||e.id||"未命名记忆库"}function xIt(e){return e.available?"已开通":e.lifecycleStatus==="Retiring"?"即将下线":e.activationState&&e.activationState!=="Available"?"未开通":"暂不可用"}function vIt(e){return e.available||e.lifecycleStatus==="Retiring"}function Kee({selectedLabel:e,placeholder:t,disabled:n,triggerAriaLabel:r,menuAriaLabel:i,searchAriaLabel:s,searchValue:a,searchPlaceholder:l,onSearchChange:c,empty:u,emptyLabel:d,triggerClassName:f="",optionsClassName:h="",renderOptions:m}){const[g,b]=p.useState(!1),y=p.useRef(null),O=p.useRef(null),v=p.useRef(null),x=p.useId(),[w,S]=p.useState(null);p.useEffect(()=>{if(!g)return;const _=C=>{var R;const A=C.target;A instanceof Node&&y.current&&!y.current.contains(A)&&!((R=v.current)!=null&&R.contains(A))&&b(!1)},T=C=>{var A;C.key==="Escape"&&(b(!1),(A=O.current)==null||A.focus())};return window.addEventListener("pointerdown",_),window.addEventListener("keydown",T),()=>{window.removeEventListener("pointerdown",_),window.removeEventListener("keydown",T)}},[g]),p.useEffect(()=>{if(!g){S(null);return}const _=()=>{const T=O.current;if(!T)return;const C=T.getBoundingClientRect(),A=12,R=6,M=window.innerHeight-C.bottom-A-R,I=C.top-A-R,$=M<300&&I>M,N=Math.max(96,$?I:M),j=Math.min(C.width,window.innerWidth-A*2),B=Math.min(Math.max(A,C.left),window.innerWidth-A-j);S({...$?{bottom:window.innerHeight-C.top+R}:{top:C.bottom+R},left:B,width:j,maxHeight:N,opensUp:$})};return _(),window.addEventListener("resize",_),window.addEventListener("scroll",_,!0),()=>{window.removeEventListener("resize",_),window.removeEventListener("scroll",_,!0)}},[g]);const E=()=>b(!1),k=_=>{var R,M;if(!["ArrowDown","ArrowUp","Home","End"].includes(_.key))return;const T=Array.from(((R=v.current)==null?void 0:R.querySelectorAll('[role="option"]:not(:disabled)'))??[]);if(!T.length)return;_.preventDefault();const C=T.findIndex(I=>I===document.activeElement),A=_.key==="Home"?0:_.key==="End"?T.length-1:_.key==="ArrowUp"?C<=0?T.length-1:C-1:C<0||C===T.length-1?0:C+1;(M=T[A])==null||M.focus()};return o.jsxs("div",{className:`cw-a2a-space-select-wrap cw-catalog-select${g?" is-open":""}`,ref:y,children:[o.jsxs("button",{ref:O,type:"button",className:`cw-a2a-space-trigger ${f}`.trim(),disabled:n,"aria-haspopup":"listbox","aria-controls":g?x:void 0,"aria-expanded":g,"aria-label":r,title:e,onClick:()=>{g||c(""),b(_=>!_)},children:[o.jsx("span",{className:t?"is-placeholder":void 0,children:e}),o.jsx(IU,{className:"cw-a2a-space-trigger-icon"})]}),g&&w&&kr.createPortal(o.jsxs("div",{ref:v,className:`cw-a2a-space-menu cw-catalog-menu cw-catalog-menu-portal${w.opensUp?" is-up":""}`,style:{top:w.top??"auto",bottom:w.bottom??"auto",left:w.left,width:w.width,maxHeight:w.maxHeight},onKeyDown:k,children:[o.jsx("div",{className:"cw-picker-search",children:o.jsx("input",{className:"cw-picker-search-input",type:"search",value:a,autoFocus:!0,autoComplete:"off","aria-label":s,placeholder:l,onChange:_=>c(_.currentTarget.value)})}),o.jsxs("div",{id:x,className:`cw-picker-options cw-catalog-options ${h}`.trim(),role:"listbox","aria-label":i,children:[m(E),u&&o.jsx("div",{className:"cw-picker-empty",children:d})]})]}),document.body)]})}function wIt({value:e,cloudProvider:t,apiKeyId:n,apiKeyName:r,onApiKeyChange:i,onChange:s}){const[a,l]=p.useState([]),[c,u]=p.useState(!1),[d,f]=p.useState([]),[h,m]=p.useState(null),[g,b]=p.useState(!1),[y,O]=p.useState(null),[v,x]=p.useState(0),[w,S]=p.useState(0),[E,k]=p.useState(""),[_,T]=p.useState("");p.useEffect(()=>{const Q=new AbortController;return u(!0),O(null),f9(Q.signal,v>0).then(V=>{if(Q.signal.aborted)return;l(V.keys);const K=V.keys.find(se=>se.id===n)??V.keys.find(se=>se.name===r)??V.keys.find(se=>se.id===V.defaultKeyId)??V.keys[0];K&&i(K)}).catch(V=>{Q.signal.aborted||O(V instanceof Error?V.message:"加载 Ark API Key 失败")}).finally(()=>{Q.signal.aborted||u(!1)}),()=>Q.abort()},[t,v]),p.useEffect(()=>{if(!n){f([]);return}const Q=new AbortController;return b(!0),O(null),m(null),Q1({signal:Q.signal,apiKeyId:n,refresh:v>0||w>0}).then(V=>{Q.signal.aborted||(f(V.models),m(n))}).catch(V=>{Q.signal.aborted||O(V instanceof Error?V.message:"加载模型列表失败")}).finally(()=>{Q.signal.aborted||b(!1)}),()=>Q.abort()},[n,t,w,v]);const C=e.trim(),A=h===n,R=A?d:[],M=a.find(Q=>Q.id===n),I=M?M.name:n?"当前 API Key":c?"正在加载 API Key…":a.length===0?"暂无可用 API Key":"请选择 API Key",$=p.useMemo(()=>a.filter(Q=>Cg(E,[Q.name])),[E,a]),N=R.find(Q=>Q.id===C),j=g&&!A?"正在刷新模型列表…":N?`${N.displayName} (${N.id})`:C||"请选择模型",B=p.useMemo(()=>R.filter(Q=>Cg(_,[Q.displayName,Q.id,Q.name,Q.vendorName,Q.activationState,Q.lifecycleStatus])),[_,R]),F=!!(C&&!N&&Cg(_,[C])),L=R.filter(Q=>Q.available).length,H=t==="byteplus"?"BytePlus ModelArk":"火山方舟",z=f5e(t);return o.jsxs("div",{className:"cw-a2a-space-picker cw-model-picker",children:[o.jsxs("div",{className:"cw-model-picker-stack",children:[o.jsxs("div",{className:"cw-model-picker-field",children:[o.jsx("span",{className:"cw-model-picker-label",children:"API Key"}),o.jsx(Kee,{selectedLabel:I,placeholder:!n,disabled:c,triggerAriaLabel:"选择 API Key",menuAriaLabel:"API Key 列表",searchAriaLabel:"搜索 API Key",searchValue:E,searchPlaceholder:"搜索 API Key 名称",onSearchChange:k,empty:$.length===0,emptyLabel:"未找到匹配的 API Key",optionsClassName:"cw-model-key-options",renderOptions:Q=>$.map(V=>{const K=V.id===n;return o.jsx("button",{type:"button",role:"option","aria-selected":K,className:`cw-a2a-space-option cw-model-key-option ${K?"is-selected":""}`,title:V.name,onClick:()=>{S(se=>se+1),i(V),Q()},children:o.jsx("span",{children:V.name})},V.id)})})]}),o.jsxs("div",{className:"cw-model-picker-field",children:[o.jsx("span",{className:"cw-model-picker-label",children:"模型"}),o.jsxs("div",{className:"cw-a2a-space-row",children:[o.jsx(Kee,{selectedLabel:j,placeholder:!C,disabled:g,triggerAriaLabel:`选择${H}模型`,menuAriaLabel:`${H}模型`,searchAriaLabel:"搜索模型",searchValue:_,searchPlaceholder:"搜索名称、Model ID 或服务商",onSearchChange:T,empty:!F&&B.length===0,emptyLabel:"未找到匹配的模型",triggerClassName:"cw-model-trigger",optionsClassName:"cw-model-options",renderOptions:Q=>o.jsxs(o.Fragment,{children:[F&&o.jsxs("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option cw-model-option is-selected",onClick:()=>{s(C),Q()},children:[o.jsxs("span",{className:"cw-model-option-copy",children:[o.jsx("strong",{children:"当前配置"}),o.jsx("small",{children:C})]}),o.jsx("span",{className:"cw-model-status is-unknown",children:"状态未知"})]}),B.map(V=>{const K=V.id===C,se=vIt(V);return!se&&V.activationState!=="Available"?o.jsxs("button",{type:"button",role:"option","aria-selected":!1,className:"cw-a2a-space-option cw-model-option is-activation-link",title:`前往${H}开通 ${V.displayName}`,onClick:()=>{window.open(z,"_blank","noopener,noreferrer"),Q()},children:[o.jsxs("span",{className:"cw-model-option-copy",children:[o.jsx("strong",{children:V.displayName}),o.jsxs("small",{children:[V.id,V.vendorName?` · ${V.vendorName}`:""]})]}),o.jsx("span",{className:"cw-model-status is-unavailable",children:"未开通,去开通"})]},V.id):o.jsxs("button",{type:"button",role:"option","aria-selected":K,disabled:!se,className:`cw-a2a-space-option cw-model-option ${K?"is-selected":""}`,title:`${V.displayName} (${V.id})`,onClick:()=>{s(V.id),Q()},children:[o.jsxs("span",{className:"cw-model-option-copy",children:[o.jsx("strong",{children:V.displayName}),o.jsxs("small",{children:[V.id,V.vendorName?` · ${V.vendorName}`:""]})]}),o.jsx("span",{className:`cw-model-status ${V.available?"is-available":V.lifecycleStatus==="Retiring"?"is-retiring":"is-unavailable"}`,children:xIt(V)})]},V.id)})]})}),o.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新 API Key 和模型列表","aria-label":"刷新 API Key 和模型列表",disabled:g||c,onClick:()=>x(Q=>Q+1),children:g||c?o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}):o.jsx(DU,{className:"cw-i cw-i-sm"})})]})]})]}),y?o.jsxs("div",{className:"cw-banner cw-a2a-space-error",role:"alert",children:[o.jsx(Sd,{className:"cw-i"}),o.jsx("span",{children:y})]}):g?o.jsxs("span",{className:"cw-help cw-a2a-space-status","aria-live":"polite",children:[o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}),"正在加载模型列表…"]}):R.length===0?o.jsx("span",{className:"cw-help",children:"当前账号下暂无可配置模型。"}):o.jsxs("span",{className:"cw-help",children:["已加载 ",R.length," 个模型,其中 ",L," 个已开通。"]})]})}function SIt({value:e,region:t,invalid:n,onChange:r}){const i=t.trim()||gy.region,[s,a]=p.useState([]),[l,c]=p.useState(!1),[u,d]=p.useState(null),[f,h]=p.useState(0),[m,g]=p.useState(!1),[b,y]=p.useState(""),O=p.useRef(null);p.useEffect(()=>{let T=!1;return c(!0),d(null),KRt({region:i}).then(C=>{T||a(C)}).catch(C=>{T||(a([]),d(C instanceof Error?C.message:"加载失败"))}).finally(()=>{T||c(!1)}),()=>{T=!0}},[i,f]);const v=!e||s.some(T=>T.id===e.trim()),x=s.find(T=>T.id===e.trim()),w=x?a3(x):e&&!v?"已选择的智能体中心":"请选择智能体中心",S=l&&s.length===0,E=p.useMemo(()=>s.filter(T=>Cg(b,[a3(T),T.id,T.projectName])),[b,s]),k=!!(e&&!v&&Cg(b,["已选择的智能体中心",e]));p.useEffect(()=>{if(!m)return;const T=A=>{const R=A.target;R instanceof Node&&O.current&&!O.current.contains(R)&&g(!1)},C=A=>{A.key==="Escape"&&g(!1)};return window.addEventListener("pointerdown",T),window.addEventListener("keydown",C),()=>{window.removeEventListener("pointerdown",T),window.removeEventListener("keydown",C)}},[m]);const _=T=>{r(T),g(!1)};return o.jsxs("div",{className:`cw-a2a-space-picker${m?" is-open":""}`,ref:O,children:[o.jsxs("div",{className:"cw-a2a-space-row",children:[o.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[o.jsxs("button",{type:"button",className:`cw-a2a-space-trigger ${n?"is-error":""}`,disabled:S,"aria-haspopup":"listbox","aria-expanded":m,"aria-label":"选择 AgentKit 智能体中心",onClick:()=>{y(""),g(T=>!T)},children:[o.jsx("span",{className:e?void 0:"is-placeholder",children:w}),o.jsx(IU,{className:"cw-a2a-space-trigger-icon"})]}),m&&o.jsxs("div",{className:"cw-a2a-space-menu",children:[o.jsx("div",{className:"cw-picker-search",children:o.jsx("input",{className:"cw-picker-search-input",type:"search",value:b,autoFocus:!0,autoComplete:"off","aria-label":"搜索 AgentKit 智能体中心",placeholder:"搜索名称或 ID",onChange:T=>y(T.currentTarget.value)})}),o.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":"AgentKit 智能体中心",children:[k&&o.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>_(e),children:"已选择的智能体中心"}),E.map(T=>{const C=a3(T),A=T.id===e;return o.jsx("button",{type:"button",role:"option","aria-selected":A,className:`cw-a2a-space-option ${A?"is-selected":""}`,title:`${C} (${T.id})`,onClick:()=>_(T.id),children:C},T.id)}),!k&&E.length===0&&o.jsx("div",{className:"cw-picker-empty",children:"未找到匹配的智能体中心"})]})]})]}),o.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh",title:"刷新智能体中心列表","aria-label":"刷新智能体中心列表",disabled:l,onClick:()=>h(T=>T+1),children:l?o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}):o.jsx(DU,{className:"cw-i cw-i-sm"})})]}),u?o.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[o.jsx(Sd,{className:"cw-i"}),o.jsx("span",{children:u})]}):l?o.jsxs("span",{className:"cw-help cw-a2a-space-status",children:[o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}),"正在加载 AgentKit 智能体中心…"]}):s.length===0?o.jsx("span",{className:"cw-help",children:"此账号下暂无 AgentKit 智能体中心。"}):o.jsxs("span",{className:"cw-help",children:["已加载 ",s.length," 个智能体中心,列表仅展示中心名称。"]})]})}function tSe({value:e,items:t,loading:n,error:r,pickerClassName:i,selectLabel:s,searchLabel:a,listLabel:l,placeholder:c,emptyMessage:u,loadedMessage:d,refreshLabel:f,noMatchesMessage:h,getLabel:m,getSearchFields:g,getKey:b,getOptionIds:y,makeUnknownItem:O,onChange:v,onRefresh:x}){const[w,S]=p.useState(!1),[E,k]=p.useState(""),_=p.useRef(null),T=!e||t.some(N=>N.id===e.trim()),C=t.find(N=>N.id===e.trim()),A=C?m(C):e&&!T?e:c,R=n&&t.length===0,M=p.useMemo(()=>t.filter(N=>Cg(E,g(N))),[g,t,E]),I=!!(e&&!T&&Cg(E,[e]));p.useEffect(()=>{if(!w)return;const N=B=>{const F=B.target;F instanceof Node&&_.current&&!_.current.contains(F)&&S(!1)},j=B=>{B.key==="Escape"&&S(!1)};return window.addEventListener("pointerdown",N),window.addEventListener("keydown",j),()=>{window.removeEventListener("pointerdown",N),window.removeEventListener("keydown",j)}},[w]);const $=N=>{v(N),S(!1)};return n&&t.length===0?o.jsxs("span",{className:"cw-viking-kb-inline-status",role:"status",children:[o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}),"正在加载…"]}):o.jsxs("div",{className:`cw-a2a-space-picker ${i}${w?" is-open":""}`,ref:_,children:[o.jsxs("div",{className:"cw-a2a-space-row",children:[o.jsxs("div",{className:"cw-a2a-space-select-wrap",children:[o.jsxs("button",{type:"button",className:"cw-a2a-space-trigger",disabled:R,"aria-haspopup":"listbox","aria-expanded":w,"aria-label":s,onClick:()=>{k(""),S(N=>!N)},children:[o.jsx("span",{className:e?void 0:"is-placeholder",children:A}),o.jsx(IU,{className:"cw-a2a-space-trigger-icon"})]}),w&&o.jsxs("div",{className:"cw-a2a-space-menu cw-viking-kb-menu",children:[o.jsx("div",{className:"cw-picker-search",children:o.jsx("input",{className:"cw-picker-search-input",type:"search",value:E,autoFocus:!0,autoComplete:"off","aria-label":a,placeholder:"搜索名称或 ID",onChange:N=>k(N.currentTarget.value)})}),o.jsxs("div",{className:"cw-picker-options",role:"listbox","aria-label":l,children:[I&&o.jsx("button",{type:"button",role:"option","aria-selected":!0,className:"cw-a2a-space-option is-selected",onClick:()=>$(O(e)),children:e}),M.map(N=>{const j=m(N),B=N.id===e,F=y(N).filter(Boolean).join(" / ");return o.jsx("button",{type:"button",role:"option","aria-selected":B,className:`cw-a2a-space-option ${B?"is-selected":""}`,title:F?`${j} (${F})`:j,onClick:()=>$(N),children:j},b(N))}),!I&&M.length===0&&o.jsx("div",{className:"cw-picker-empty",children:h})]})]})]}),o.jsx("button",{type:"button",className:"cw-icon-btn cw-a2a-space-refresh cw-viking-kb-refresh",title:f,"aria-label":f,disabled:n,onClick:x,children:n?o.jsx(rr,{className:"cw-i cw-i-sm cw-spin"}):o.jsx(DU,{className:"cw-i cw-i-sm"})})]}),r?o.jsxs("div",{className:"cw-banner cw-a2a-space-error",children:[o.jsx(Sd,{className:"cw-i"}),o.jsx("span",{children:r})]}):t.length===0?o.jsx("span",{className:"cw-help",children:u}):o.jsx("span",{className:"cw-help",children:d(t.length)})]})}function EIt({value:e,onChange:t}){const[n,r]=p.useState([]),[i,s]=p.useState(!1),[a,l]=p.useState(null),[c,u]=p.useState(0);return p.useEffect(()=>{let d=!1;return s(!0),l(null),eIt().then(f=>{d||r(f)}).catch(f=>{d||(r([]),l(f instanceof Error?f.message:"加载失败"))}).finally(()=>{d||s(!1)}),()=>{d=!0}},[c]),o.jsx(tSe,{value:e,items:n,loading:i,error:a,pickerClassName:"cw-viking-kb-picker",selectLabel:"选择 VikingDB 知识库",searchLabel:"搜索 VikingDB 知识库",listLabel:"VikingDB 知识库",placeholder:"请选择 VikingDB 知识库",emptyMessage:"此账号下暂无 VikingDB 知识库。",loadedMessage:d=>`已加载 ${d} 个知识库,选择的知识库会用于当前 Agent。`,refreshLabel:"刷新知识库列表",noMatchesMessage:"未找到匹配的知识库",getLabel:Yee,getSearchFields:d=>[Yee(d),d.id,d.description,d.projectName,d.resourceId,d.agentkitKnowledgeId,d.providerKnowledgeId,d.sourceLabel],getKey:d=>d.id,getOptionIds:d=>[d.id,d.resourceId,d.agentkitKnowledgeId,d.providerKnowledgeId],makeUnknownItem:d=>({id:d,name:d,description:"",projectName:"",region:"",sourceKind:"knowledge",sourceLabel:"Knowledge Engine",resourceId:""}),onChange:t,onRefresh:()=>u(d=>d+1)})}function kIt({value:e,onChange:t}){const[n,r]=p.useState([]),[i,s]=p.useState(!1),[a,l]=p.useState(null),[c,u]=p.useState(0);return p.useEffect(()=>{let d=!1;return s(!0),l(null),nIt().then(f=>{d||r(f)}).catch(f=>{d||(r([]),l(f instanceof Error?f.message:"加载失败"))}).finally(()=>{d||s(!1)}),()=>{d=!0}},[c]),o.jsx(tSe,{value:e,items:n,loading:i,error:a,pickerClassName:"cw-viking-memory-picker",selectLabel:"选择 VikingDB 记忆库",searchLabel:"搜索 VikingDB 记忆库",listLabel:"VikingDB 记忆库",placeholder:"请选择 VikingDB 记忆库,不选择则自动创建",emptyMessage:"此账号下暂无 VikingDB 记忆库,未选择时会自动创建。",loadedMessage:d=>`已加载 ${d} 个记忆库;不选择时会自动创建。`,refreshLabel:"刷新记忆库列表",noMatchesMessage:"未找到匹配的记忆库",getLabel:Zee,getSearchFields:d=>[Zee(d),d.id,d.description,d.projectName,d.region,d.resourceId,...d.memoryTypes??[]],getKey:d=>`${d.projectName}:${d.region}:${d.id}`,getOptionIds:d=>[d.id,d.resourceId],makeUnknownItem:d=>({id:d,name:d,description:"",projectName:"",region:"",resourceId:"",memoryTypes:[]}),onChange:t,onRefresh:()=>u(d=>d+1)})}function _It({tools:e,onChange:t}){const n=(s,a)=>t(e.map((l,c)=>c===s?{...l,...a}:l)),r=s=>t(e.filter((a,l)=>l!==s)),i=()=>t([...e,{name:"",transport:"http",url:""}]);return o.jsxs("div",{className:"cw-mcp",children:[e.length>0&&o.jsx("div",{className:"cw-mcp-list",children:o.jsx(fu,{initial:!1,children:e.map((s,a)=>o.jsxs(ai.div,{className:"cw-mcp-row",layout:!0,initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},transition:{duration:.16},children:[o.jsxs("div",{className:"cw-mcp-rowhead",children:[o.jsxs("div",{className:"cw-mcp-transport",children:[o.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${s.transport==="http"?"is-on":""}`,onClick:()=>n(a,{transport:"http"}),"aria-pressed":s.transport==="http",children:o.jsx("span",{className:"cw-seg-title",children:"HTTP"})}),o.jsx("button",{type:"button",className:`cw-seg cw-seg-sm ${s.transport==="stdio"?"is-on":""}`,onClick:()=>n(a,{transport:"stdio"}),"aria-pressed":s.transport==="stdio",children:o.jsx("span",{className:"cw-seg-title",children:"stdio"})})]}),o.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger",onClick:()=>r(a),"aria-label":"移除 MCP 工具",children:o.jsx(Fp,{className:"cw-i cw-i-sm"})})]}),o.jsx("input",{className:"cw-input",value:s.name,placeholder:"名称(用于命名,可留空)",onChange:l=>n(a,{name:l.target.value})}),s.transport==="http"?o.jsxs(o.Fragment,{children:[o.jsx("input",{className:"cw-input",value:s.url??"",placeholder:"MCP 服务地址(StreamableHTTP)",onChange:l=>t(e.map((c,u)=>u===a?NRt(c,l.target.value):c))}),ARt(s.url??"")&&o.jsxs("p",{className:"cw-mcp-warning",children:[o.jsx(Sd,{"aria-hidden":"true"}),o.jsx("span",{children:"当前地址不是以 /mcp 结尾,请确认它是实际的 MCP Endpoint。Studio 会保留该地址,不会自动补充路径。"})]}),o.jsx("input",{className:"cw-input","aria-invalid":Gwe(s),value:_Rt(s),placeholder:s.credentialConfigured&&!s.authToken?"认证已配置;留空继续使用":"Bearer Token(可选)",onChange:l=>t(e.map((c,u)=>u===a?TRt(c,l.target.value):c))}),s.credentialUpdate==="pending"&&o.jsxs("div",{className:"cw-mcp-auth-state is-warning",role:"alert",children:[o.jsx("span",{children:"MCP 地址已变化,请重新填写 Key 或确认沿用原凭证。"}),o.jsxs("div",{className:"cw-mcp-auth-actions",children:[o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?jRt(l):l)),children:"沿用原凭证"}),o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?r$(l):l)),children:"重新填写 Key"}),o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?RRt(l):l)),children:"新地址无需认证"})]})]}),s.credentialUpdate==="reuse"&&o.jsxs("div",{className:"cw-mcp-auth-state",role:"status",children:[o.jsx("span",{children:"发布时将沿用原凭证,并绑定到新的 MCP 地址。"}),o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?r$(l):l)),children:"改为重新填写"})]}),s.credentialConfigured&&!s.authToken&&!s.credentialUpdate&&o.jsxs("div",{className:"cw-mcp-auth-state",role:"status",children:[o.jsx("span",{children:"认证已配置,旧值不会显示在页面中。"}),o.jsx("button",{type:"button",onClick:()=>t(e.map((l,c)=>c===a?CRt(l):l)),children:"移除认证"})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("input",{className:"cw-input",value:s.command??"",placeholder:"启动命令,例如 npx",onChange:l=>n(a,{command:l.target.value})}),o.jsx("input",{className:"cw-input",value:(s.args??[]).join(" "),placeholder:"参数(用空格分隔),例如 -y @playwright/mcp@latest",onChange:l=>n(a,{args:l.target.value.split(/\s+/).filter(Boolean)})}),o.jsx("p",{className:"cw-mcp-note",children:"stdio MCP 暂不参与调试运行;点击“去部署”时会完整保留这项配置并生成对应代码。"})]})]},a))})}),o.jsxs("button",{type:"button",className:"cw-add-sub",onClick:i,children:[o.jsx(vo,{className:"cw-i"}),"添加 MCP 工具"]})]})}function b_({checked:e,onChange:t,title:n,desc:r,showDescription:i=!1}){return o.jsxs("button",{type:"button",className:`cw-toggle ${e?"is-on":""}`,onClick:()=>t(!e),"aria-pressed":e,children:[o.jsxs("span",{className:"cw-toggle-text",children:[o.jsx("span",{className:"cw-toggle-title",children:n}),i&&o.jsx("span",{className:"cw-toggle-help",children:r})]}),o.jsx("span",{className:"cw-switch","aria-hidden":!0,children:o.jsx(ai.span,{className:"cw-switch-knob",layout:!0,transition:{type:"spring",stiffness:520,damping:34}})})]})}function TIt(e,t){var r;let n=e;for(const i of t)if(n=(r=n.subAgents)==null?void 0:r[i],!n)return!1;return!0}function y_(e,t){let n=e;for(const r of t)n=n.subAgents[r];return n}function KE(e,t,n){if(t.length===0)return n(e);const[r,...i]=t,s=e.subAgents.slice();return s[r]=KE(s[r],i,n),{...e,subAgents:s}}function CIt(e,t,n="volcengine"){return KE(e,t,r=>({...r,subAgents:[...r.subAgents,Bl(n)]}))}function AIt(e,t,n,r="volcengine"){return KE(e,t,i=>{const s=i.subAgents.slice();return s.splice(n,0,Bl(r)),{...i,subAgents:s}})}function NIt(e,t){if(t.length===0)return e;const n=t.slice(0,-1),r=t[t.length-1];return KE(e,n,i=>({...i,subAgents:i.subAgents.filter((s,a)=>a!==r)}))}const a$=e=>!TR(e.agentType),Jee=3;function jIt(e,t,n=!1){var i;if(TR(e.agentType))return n?"远程 Agent 只能作为子 Agent":(i=e.a2aRegistry)!=null&&i.registrySpaceId.trim()?null:"缺少 AgentKit 智能体中心";const r=C1(e.name);return r||(t.has(e.name)?"Agent 名称在当前结构中必须唯一":e.description.trim().length===0?"缺少描述":(e.mcpTools??[]).some(Gwe)?"MCP 地址变化后需要确认认证方式":Iwe(e.agentType)?e.subAgents.length===0?"缺少子 Agent":null:e.instruction.trim().length===0?"缺少系统提示词":null)}function nSe(e,t,n=[]){const r=[],i=TR(e.agentType),s=jIt(e,t,n.length===0);return s&&r.push({path:n,name:i?"远程 Agent":e.name.trim()||"未命名",typeLabel:Rwe(e.agentType).label,problem:s}),a$(e)&&e.subAgents.forEach((a,l)=>r.push(...nSe(a,t,[...n,l]))),r}function RIt(e){return`${e.typeLabel}至少需要添加一个子 Agent 后才能调试或发布。`}function rSe(e){return 1+e.subAgents.reduce((t,n)=>t+rSe(n),0)}function o$(e,t=!1){const n=ZE(e),r=VC(n.draft).includes("mcp_resilience"),i=[],s={...n.envValues},a=n.draft.cloudProvider??"volcengine",l=_He(n.draft).map(Rv);let c=!1,u="";for(const h of kwe(n.draft,nl(a))){const m=[{key:h.apiKeyKey,required:!0,comment:h.label}];h.providerKey&&(m.push({key:h.providerKey,required:!0}),s[h.providerKey]=h.provider),h.apiBaseKey&&(m.push({key:h.apiBaseKey,required:!0}),s[h.apiBaseKey]=h.apiBase),i.push({env:m})}const d=h=>{var m,g,b,y;h.agentType==="llm"&&am(h,a)==="ark"&&(c=!0,u||(u=(h.modelName??"").trim()));for(const O of h.builtinTools??[]){const v=eO.find(x=>x.id===O);v&&i.push({env:Eb(v.env,a)})}for(const O of h.mcpTools??[])O.authTokenEnv&&i.push({env:[{key:O.authTokenEnv,required:!1,comment:`${O.name.trim()||"MCP"} Bearer Token`,secret:!0,readOnly:r,serverManaged:r,hidden:r}]});if((m=h.a2aRegistry)!=null&&m.enabled&&(i.push({env:Eb(hhe,a)}),Object.assign(s,eSe(h.a2aRegistry,{includeDefaults:!0},a))),h.memory.shortTerm&&i.push({env:Eb(((g=by.find(O=>O.id===(h.shortTermBackend??"local")))==null?void 0:g.env)??[],a)}),h.memory.longTerm&&i.push({env:Eb(((b=F4.find(O=>O.id===(h.longTermBackend??"local")))==null?void 0:b.env)??[],a)}),h.knowledgebase&&i.push({env:Eb(((y=z4.find(O=>O.id===(h.knowledgebaseBackend??jp)))==null?void 0:y.env)??[],a)}),h.tracing)for(const O of h.tracingExporters??[]){const v=mHe.find(x=>x.id===O);v&&i.push({env:v.env,enableFlag:v.enableFlag})}h.subAgents.forEach(d)};if(d(n.draft),c){i.push({env:[{key:"MODEL_AGENT_PROVIDER",required:!0},{key:"MODEL_AGENT_API_BASE",required:!0},{key:"MODEL_AGENT_API_KEY",required:!0,comment:"Ark API Key",placeholder:"由所选 API Key 注入",secret:!0,readOnly:!0,serverManaged:!0,requiredBy:l}]}),s.MODEL_AGENT_PROVIDER="openai",s.MODEL_AGENT_API_BASE=nl(a);const h=u||eh(a);s.MODEL_AGENT_NAME=h,s.MODEL_NAME=h}if(r){if(t){i.push({env:[{key:"MCP_SERVERS_JSON",required:!0,comment:"由已添加的 MCP 工具注入",placeholder:"由 Studio 服务端安全恢复",help:"更新时由 Studio 服务端合并 MCP 地址与认证,不向浏览器返回旧密钥。",readOnly:!0,serverManaged:!0,hidden:!0,requiredBy:[Rv("mcp_resilience")]}]});const g=t$(i);return{specs:g.specs,fixedValues:{...g.fixedValues,...s}}}const h=BRt(n.draft),m=h.ok?void 0:h.message;i.push({env:[{key:"MCP_SERVERS_JSON",required:!0,comment:"由已添加的 MCP 工具注入",placeholder:t?"由 Studio 服务端安全恢复":"由已添加的 HTTP MCP 工具自动生成",help:"Studio 服务端自动合并 MCP 地址与可选认证,不向浏览器返回旧密钥。",secret:!0,readOnly:!0,serverManaged:h.ok,hidden:!0,requiredBy:[Rv("mcp_resilience")],missingError:m}]})}const f=t$(i);return{specs:f.specs,fixedValues:{...f.fixedValues,...s}}}function IIt(e,t){const n=r=>(r??"").trim().replace(/\/+$/,"");return n(e)===n(t)}function DIt(e,t,n){const r=(e??"").trim();return!r||r===eh(t)?!0:r===eh(n)?!1:n==="byteplus"&&r.includes("doubao-")}function ng(e,t){const n=e.cloudProvider??"volcengine",r=am(e,n),i=e.subAgents.map(u=>ng(u,t)),s=r==="ark"&&DIt(e.modelName,n,t)?eh(t):e.modelName,l=IIt(e.modelApiBase,nl(n))||t==="byteplus"&&(e.modelApiBase??"").includes("volces.com")?nl(t):e.modelApiBase;return e.cloudProvider!==t||s!==e.modelName||l!==e.modelApiBase||i.some((u,d)=>u!==e.subAgents[d])?{...e,cloudProvider:t,modelName:s,modelApiBase:l,subAgents:i}:e}function PIt(e,t){var l;const n=ng(e,t),r=_we(n,nl(t)),i=new Set(r.map(({key:c})=>c)),s=((l=n.deployment)==null?void 0:l.envValues)??{},a=Object.fromEntries(Object.entries(s).filter(([c,u])=>i.has(c)&&!!u.trim()));return Object.keys(a).length===0?{draft:n,customModelSecretValues:a}:{draft:{...n,deployment:{...n.deployment??{feishuEnabled:!1},envValues:Object.fromEntries(Object.entries(s).filter(([c])=>!i.has(c)))}},customModelSecretValues:a}}function iv(e){var r,i,s;const t=ZE(e).draft;return{...Awe(t,t.cloudProvider??"volcengine"),deployment:{feishuEnabled:!!((r=e.deployment)!=null&&r.feishuEnabled),modelApiKeyId:((i=e.deployment)==null?void 0:i.modelApiKeyId)??"",modelApiKeyName:((s=e.deployment)==null?void 0:s.modelApiKeyName)??""}}}function l$(e){var n;const t=(n=e.modelName)==null?void 0:n.trim();if(t)return t;for(const r of e.subAgents){const i=l$(r);if(i)return i}return""}function iSe(e,t={}){var i,s,a,l;const n=o$(e),r={...((i=e.deployment)==null?void 0:i.envValues)??{},...t,...n.fixedValues};return{...iv(e),deployment:{feishuEnabled:!!((s=e.deployment)!=null&&s.feishuEnabled),modelApiKeyId:((a=e.deployment)==null?void 0:a.modelApiKeyId)??"",modelApiKeyName:((l=e.deployment)==null?void 0:l.modelApiKeyName)??"",envValues:Object.fromEntries(CU(n.specs,r).map(({key:c,value:u})=>[c,u]))}}}function MIt(e,t={}){return JSON.stringify(iSe(e,t))}function YA(e,t){return JSON.stringify({draftSnapshot:e,modelName:t.modelName,description:t.description,instruction:t.instruction})}function ty(e){return JSON.stringify({modelName:e.modelName.trim(),description:e.description.trim(),instruction:e.instruction.trim()})}function LIt({enabled:e,disabledReason:t,variants:n,draftSnapshot:r,input:i,onInput:s,onSend:a,onStartVariant:l,onUseVariant:c,onAddVariant:u,onRemoveVariant:d,onToggleConfig:f,onCompleteConfig:h,onConfigChange:m,onOpenTrace:g}){const b=n.filter(v=>v.phase!=="ready"?!1:v.runtimeSnapshot===YA(r,v)),y=n.some(v=>v.phase==="sending"),O=b.length>0&&!y;return o.jsxs("section",{className:"cw-ab-workspace","aria-label":"A/B 调试工作台",children:[o.jsx("div",{className:"cw-ab-stage",children:e?o.jsx("div",{className:"cw-ab-grid",style:{"--cw-ab-column-count":n.length},children:n.map((v,x)=>{const w=v.modelName.trim(),S=v.description.trim(),E=v.instruction.trim(),k=ty(v),_=!!(w&&S&&E&&n.findIndex(B=>ty(B)===k)!==x),T=!w||!S||!E||_,C=!!(v.runtimeSnapshot&&v.runtimeSnapshot!==YA(r,v)),A=v.phase==="starting",R=v.phase==="ready"&&!C,M=A||v.phase==="sending",I=R&&v.phase!=="sending"&&v.messages.some(B=>B.role==="assistant"),$=M||v.configOpen||T,N=w?S?E?_?"该配置与已有测试组相同":"":"请填写系统提示词":"请填写描述":"请先选择模型",j=A?"正在启动":C?"应用配置并重启":R||v.phase==="error"?"重新启动环境":"启动环境";return o.jsx("article",{className:"cw-ab-card",children:o.jsxs("div",{className:`cw-ab-card-inner${v.configOpen?" is-flipped":""}`,children:[o.jsxs("section",{className:"cw-ab-card-face cw-ab-card-front","aria-hidden":v.configOpen,children:[o.jsxs("header",{className:"cw-ab-card-head",children:[o.jsxs("div",{className:"cw-ab-card-title",children:[o.jsx("strong",{children:v.name}),o.jsx("span",{children:v.modelName||"默认模型"})]}),o.jsxs("div",{className:"cw-ab-card-actions",children:[o.jsx("button",{type:"button",className:"cw-ab-config-trigger",disabled:v.configOpen||M,onClick:()=>f(v.id),children:"测试配置"}),v.id!=="baseline"&&o.jsx("button",{type:"button",className:"cw-ab-remove","aria-label":`删除${v.name}`,disabled:v.configOpen||M,onClick:()=>d(v.id),children:o.jsx(Gee,{className:"cw-i"})})]})]}),o.jsx("div",{className:"cw-ab-conversation",children:v.error?o.jsx(t0,{message:v.error,className:"cw-debug-error-detail",defaultExpanded:!0}):A?o.jsxs("div",{className:"cw-ab-empty cw-ab-starting",children:[o.jsx(rr,{className:"cw-i cw-spin"}),o.jsx("span",{children:"正在创建独立测试环境"})]}):C?o.jsx("div",{className:"cw-ab-empty cw-ab-launch",children:o.jsx("span",{children:"配置已变更,请重新启动此环境"})}):v.messages.length===0?o.jsx("div",{className:"cw-ab-empty cw-ab-launch",children:R?o.jsxs(o.Fragment,{children:[o.jsx("strong",{className:"cw-ab-ready-title",children:"已就绪"}),o.jsx("span",{className:"cw-ab-launch-hint",children:"可在下方输入测试消息"})]}):o.jsx("span",{className:"cw-ab-launch-hint",children:N||"启动环境后即可加入本轮测试"})}):v.messages.map((B,F)=>o.jsx("div",{className:`cw-debug-msg cw-debug-msg-${B.role}`,children:o.jsx("div",{className:"cw-debug-content",children:B.role==="user"?B.content:B.error?o.jsx(t0,{message:B.error,className:"cw-debug-msg-error",defaultExpanded:!0}):B.blocks&&B.blocks.length>0?o.jsx(Fj,{blocks:B.blocks,onAction:()=>{}}):B.content?B.content:F===v.messages.length-1&&v.phase==="sending"?o.jsx(M0e,{}):null})},F))}),o.jsxs("footer",{className:"cw-ab-deploy-footer",children:[o.jsx("button",{type:"button",className:"cw-ab-trace",disabled:!I,title:I?`查看${v.name}调用链路`:"完成一次调试后可查看调用链路",onClick:()=>g(v.id),children:"调用链路"}),o.jsxs("button",{type:"button",className:"cw-ab-start cw-ab-footer-start",disabled:$,title:N||void 0,onClick:()=>l(v.id),children:[R||C||v.phase==="error"?o.jsx(Uae,{className:"cw-i"}):o.jsx(pIt,{className:"cw-i cw-debug-run-icon"}),j]}),o.jsx("button",{type:"button",className:"cw-ab-deploy",disabled:M||!w,onClick:()=>c(v.id),children:"使用该配置"})]})]}),o.jsxs("section",{className:"cw-ab-card-face cw-ab-card-back","aria-hidden":!v.configOpen,children:[o.jsxs("header",{className:"cw-ab-config-head",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"测试配置"}),o.jsx("span",{children:v.name})]}),o.jsxs("div",{className:"cw-ab-config-head-actions",children:[v.id!=="baseline"&&o.jsx("button",{type:"button",className:"cw-icon-btn cw-icon-danger cw-ab-config-remove","aria-label":`删除${v.name}`,title:"删除配置组",disabled:M,onClick:()=>d(v.id),children:o.jsx(Gee,{className:"cw-i cw-i-sm"})}),o.jsxs("span",{className:`cw-ab-config-done-wrap${N?" is-disabled":""}`,tabIndex:N?0:void 0,children:[o.jsx("button",{type:"button",className:"cw-ab-config-done",disabled:!v.configOpen||T,onClick:()=>h(v.id),children:v.id==="baseline"?"完成配置":"完成并启动"}),N&&o.jsx("span",{className:"cw-ab-config-done-tip",role:"tooltip",children:N})]})]})]}),o.jsxs("div",{className:"cw-ab-config",children:[o.jsxs("label",{children:[o.jsx("span",{children:"模型"}),o.jsx("input",{value:v.modelName,placeholder:"使用 Agent 当前模型",disabled:!v.configOpen,onChange:B=>m(v.id,"modelName",B.target.value)})]}),o.jsxs("label",{children:[o.jsx("span",{children:"描述"}),o.jsx("textarea",{rows:2,value:v.description,disabled:!v.configOpen,onChange:B=>m(v.id,"description",B.target.value)})]}),o.jsxs("label",{children:[o.jsx("span",{children:"系统提示词"}),o.jsx("textarea",{rows:5,value:v.instruction,disabled:!v.configOpen,onChange:B=>m(v.id,"instruction",B.target.value)})]}),o.jsx("p",{children:"设置完成后返回正面,再启动当前测试环境。"})]})]})]})},v.id)})}):o.jsx("div",{className:"cw-debug-empty",children:t})}),o.jsxs("div",{className:"cw-ab-composer",children:[o.jsxs("div",{className:"cw-debug-composerbox",children:[o.jsx("textarea",{className:"cw-debug-input",rows:1,value:i,placeholder:O?"输入测试消息,将发送到所有已启动测试组...":"请先启动至少一个测试组",disabled:!O,onChange:v=>s(v.target.value),onKeyDown:v=>{SR(v.nativeEvent)||v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),a())}}),o.jsx("button",{type:"button",className:"cw-debug-send",title:"发送",disabled:!O||!i.trim(),onClick:a,children:y?o.jsx(rr,{className:"cw-i cw-spin"}):o.jsx(DRe,{className:"cw-i"})})]}),e&&n.length<3&&o.jsxs("button",{type:"button",className:"cw-btn cw-btn-soft cw-ab-add",onClick:u,children:[o.jsx(vo,{className:"cw-i"}),"添加对照组"]})]})]})}function $It({profile:e,optimizations:t,unavailableMessage:n,onProfileChange:r,onOptimizationChange:i}){return o.jsx("section",{className:"cw-optimize-workspace","aria-label":"智能体优化选项",children:o.jsxs("div",{className:"cw-optimize-panel",children:[n?o.jsxs("div",{className:"cw-banner",role:"alert",children:[o.jsx(Sd,{className:"cw-i"}),o.jsx("span",{children:n})]}):null,o.jsxs("fieldset",{className:"cw-optimize-section",children:[o.jsx("legend",{children:"优化场景"}),o.jsx(fa,{className:"cw-optimize-profile-options","aria-label":"优化场景",value:e,onChange:r,children:U7.map(s=>o.jsx("div",{className:`cw-optimize-profile-option${e===s.id?" is-on":""}`,children:o.jsx(fa.Item,{value:s.id,block:!0,className:"cw-optimize-profile-control",children:o.jsxs("span",{className:"cw-optimize-profile-copy",children:[o.jsx("strong",{children:s.displayName}),o.jsx("small",{children:s.description})]})})},s.id))})]}),o.jsxs("fieldset",{className:"cw-optimize-section",children:[o.jsx("legend",{children:"优化组件"}),o.jsx("div",{className:"cw-optimize-option-list",children:yHe.map(s=>o.jsxs("section",{className:"cw-optimize-option-group","aria-labelledby":`cw-optimize-group-${s.id}`,children:[o.jsx("h3",{id:`cw-optimize-group-${s.id}`,className:"cw-optimize-option-group-title",children:s.displayName}),o.jsx("div",{className:"cw-optimize-option-group-items",children:s.componentIds.map(a=>{const l=Q7.find(u=>u.id===a);if(!l)return null;const c=t.includes(l.id);return o.jsx(jU,{checked:c,onCheckedChange:u=>{const d=!!u;d!==c&&i(l.id,d)},label:o.jsxs("span",{className:"cw-optimize-option-copy",children:[o.jsx("strong",{children:l.displayName}),o.jsx("small",{children:l.description})]}),className:"cw-optimize-option"},l.id)})})]},s.id))})]})]})})}const O_=[{id:"build",label:"架构"},{id:"validate",label:"调试"},{id:"optimize",label:"优化"},{id:"environment",label:"环境"},{id:"publish",label:"发布"}],BIt={build:"个性化您的智能体架构",validate:"调试您的智能体",optimize:"为您的智能体选择优化项",environment:"配置云上环境",publish:"准备好部署您的智能体"};function QIt({mode:e}){return o.jsx("header",{className:"cw-workspace-header",children:o.jsx("h1",{children:BIt[e]})})}function UIt({mode:e,busy:t,onChange:n,assistant:r,accessory:i}){const s=O_.findIndex(c=>c.id===e),a=O_[s-1],l=O_[s+1];return o.jsxs("footer",{className:"cw-workspace-footer",children:[i?o.jsx("div",{className:"cw-workspace-footer-accessory",children:i}):null,o.jsxs("div",{className:`cw-workspace-nav-actions${r?" has-assistant":""}`,children:[o.jsx("button",{type:"button",className:`cw-workspace-nav-button${e==="build"?" is-placeholder":""}`,"aria-hidden":e==="build"||void 0,tabIndex:e==="build"?-1:0,disabled:!a||t,onClick:()=>a&&n(a.id),children:"上一步"}),o.jsx("span",{"aria-hidden":"true"}),r?o.jsx("div",{className:"cw-workspace-ai-slot",children:r}):null,e==="publish"?o.jsx("div",{id:"cw-publish-primary-action",className:"cw-publish-action-slot"}):o.jsx("button",{type:"button",className:"cw-workspace-nav-button is-primary",disabled:!l||t,onClick:()=>l&&n(l.id),children:"下一步"})]}),o.jsx("nav",{className:"cw-workspace-progress","aria-label":"Agent 创建进度",children:O_.map((c,u)=>{const d=c.id===e;return o.jsx("button",{type:"button",className:`${d?"is-active":""}${un(c.id),children:o.jsx("span",{"aria-hidden":"true"})},c.id)})})]})}function FIt({onBack:e,onCreate:t,onAgentAdded:n,initialDraft:r,features:i,onDeploymentTaskChange:s,createMode:a="custom",freshCreationSurface:l="traditional",workspaceDraftId:c,deploymentTarget:u,cloudProvider:d="volcengine",initialDeployRegion:f=Zr(d),onDeploymentComplete:h,onDeploymentStarted:m,onDraftChange:g,onDiscard:b}){var li,Ld,ll,xs,lo,vs,Ar,la,ca,fe,Je,St,dn,Zt,Tt,Lt,Ne,tn,or;const y=a==="custom"&&l==="vulcan",O=y&&!r,[v]=p.useState(()=>{const W=r??Bl(d),Te=O?{...W,name:W.name.trim()?W.name:"assistant",dynamicAgentDelegation:!0}:W;return PIt(Te,d)}),[x,w]=p.useState(v.draft),S=y,[E,k]=p.useState(v.customModelSecretValues),_=((li=x.deployment)==null?void 0:li.runtimeName)??"",T=u?u.name:wTt(x.name,_,(Ld=x.deployment)==null?void 0:Ld.runtimeNameCustomized),C=E;p.useEffect(()=>{w(W=>ng(W,d))},[d]);const[A,R]=p.useState(""),[M,I]=p.useState(!1),[$,N]=p.useState(!1),[j,B]=p.useState(!1),[F,L]=p.useState(null),H=A.trim(),z=H.length>0&&H.length{ge.current=g},[g]),p.useEffect(()=>{var W;K!==V.current&&(V.current=K,(W=ge.current)==null||W.call(ge,ng(x,d),se))},[d,x,se,K]);const[ie,q]=p.useState("build"),[G,J]=p.useState(!1),[ue,Oe]=p.useState(()=>new Set),[Qe,je]=p.useState(0),[ze,Ge]=p.useState(null),[Ae,Be]=p.useState(!1),[he,be]=p.useState((u==null?void 0:u.region)??f),Se=(i==null?void 0:i.generatedAgentTestRun)===!0,Ee=(i==null?void 0:i.generatedAgentTestRunDisabledReason)||"当前后端暂不支持生成 Agent 调试运行。",[tt,Ue]=p.useState(()=>{const W=ng(r??Bl(d),d);return[{id:"baseline",name:"基准组",modelName:l$(W),description:W.description,instruction:W.instruction,configOpen:!1,phase:"idle",runtimeSnapshot:"",messages:[],error:null}]}),[re,ce]=p.useState("baseline"),Me=p.useRef(1),Ye=p.useRef(!1),Z=p.useRef(new Map),[_e,rt]=p.useState(0),[Re,We]=p.useState(""),[ct,kt]=p.useState(null),[qt,Dt]=p.useState(!1),[Xe,nt]=p.useState(!1),ft=p.useRef(null),[xt,Ie]=p.useState(""),[xe,$e]=p.useState(!1),[it,ve]=p.useState(null),[He,pt]=p.useState(""),[_t,It]=p.useState(!1),[Kt,en]=p.useState(!1),[le,Xt]=p.useState([]),Fe=p.useRef(null),Pt=p.useRef({});async function Ce(){const W=new Set([...Z.current.values()].map(({run:dt})=>dt.runId)),Te=RU().filter(dt=>!W.has(dt));Te.length&&await Promise.all(Te.map(async dt=>{try{await pb(dt),kx(dt)}catch(nn){console.warn("清理遗留调试运行失败",nn)}}))}p.useEffect(()=>(Ce(),()=>{for(const{run:W}of Z.current.values())pb(W.runId).then(()=>kx(W.runId)).catch(Te=>console.warn("清理调试运行失败",Te));Z.current.clear()}),[]),p.useEffect(()=>()=>{var W;(W=ft.current)==null||W.call(ft,!1),ft.current=null},[]);const gt=p.useRef(null);gt.current||(gt.current=({meta:W,children:Te})=>o.jsxs("section",{ref:dt=>{Pt.current[W.id]=dt},id:`cw-sec-${W.id}`,"data-step-id":W.id,className:"cw-section",children:[o.jsx("header",{className:"cw-sec-head",children:o.jsx("h2",{className:"cw-sec-title",children:W.label})}),o.jsx("div",{className:"cw-sec-body",children:Te})]}));const Vt=TIt(x,le)?le:[],ot=y_(x,Vt),ln=Vt.length===0,Kn=Vt.join(".")||"root",_r=()=>{Oe(W=>W.has(Kn)?W:new Set(W).add(Kn))},Ve=`cw-a2a-registry-advanced-${Vt.join("-")||"root"}`,et=W=>w(Te=>KE(Te,Vt,dt=>({...dt,...W}))),mn=W=>w(Te=>{var dt;return{...Te,deployment:{...Te.deployment??{feishuEnabled:!1},envValues:{...((dt=Te.deployment)==null?void 0:dt.envValues)??{},...W}}}}),Mt=(W,Te)=>mn({[W]:Te}),ar=W=>et({a2aRegistry:{...ot.a2aRegistry??{enabled:!1,registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},...W}}),pr=(W,Te)=>{if(!(W in Wee))return;const dt=Wee[W];ar({[dt]:Te}),Mt(W,Te)},Gn=W=>{if(!(ln&&W==="a2a")){if(W==="a2a"){et({agentType:W,a2aRegistry:{...ot.a2aRegistry??{registrySpaceId:"",registryTopK:"",registryRegion:"",registryEndpoint:""},enabled:!0}});return}et({agentType:W,a2aRegistry:ot.a2aRegistry?{...ot.a2aRegistry,enabled:!1}:void 0})}},zn=(W,Te)=>{w(W),Te&&Xt(Te)},Pr=async()=>{const W=A.trim();if(!(!W||M)&&!(W.length{const Te=y_(x,W);if(!a$(Te)||W.length>=Jee)return;const dt=CIt(x,W,d),nn=y_(dt,W).subAgents.length-1;zn(dt,[...W,nn])},Kr=(W,Te)=>{const dt=y_(x,W);if(!a$(dt)||W.length>=Jee)return;const nn=Math.max(0,Math.min(Te,dt.subAgents.length)),an=AIt(x,W,nn,d);zn(an,[...W,nn])},qr=()=>{window.confirm("清空根 Agent 的全部配置和子 Agent?此操作无法撤销。")&&(w(Bl(d)),Xt([]),J(!1))},mr=W=>{if(W.length===0){qr();return}zn(NIt(x,W),W.slice(0,-1))},Xr=ot.builtinTools??[],Tr=p.useMemo(()=>phe(d),[d]),oi=p.useMemo(()=>new Set(Tr.map(W=>W.id)),[Tr]),Ii=ot.mcpTools??[],bi=ot.selectedSkills??[],Jr=W=>{oi.has(W)&&et({builtinTools:Xr.includes(W)?Xr.filter(Te=>Te!==W):[...Xr,W]})},Di=Iwe(ot.agentType),rs=TR(ot.agentType),oa=wj(d),Qr=am(ot,d),Ws=W=>{var dt;const Te=W==="custom"&&Qr==="ark"?"":W==="ark"&&!((dt=ot.modelName)!=null&&dt.trim())?eh(d):ot.modelName;et({modelSource:W,modelName:Te})},is=p.useMemo(()=>JCt(x),[x]),ka=rs?null:C1(ot.name)??(is.has(ot.name)?"Agent 名称在当前结构中必须唯一":null),Ys=ka!==null,_a=G||ue.has(Kn),Ds=!rs&&ot.description.trim().length===0,Pi=ot.instruction.trim().length===0,Cr=rs&&!((ll=ot.a2aRegistry)!=null&&ll.registrySpaceId.trim()),yi=(W,Te=G)=>Te&&W?`is-error cw-error-shake-${Qe%2}`:"",bs=p.useMemo(()=>nSe(x,is),[x,is]),Ps=bs.length===0,pn=p.useMemo(()=>ng(x,d),[d,x]),Oi=kHe(x),Ur=VC(x),ys=xHe(d),pe=p.useMemo(()=>MIt(pn,C),[pn,C]),Le=tt.find(W=>W.id===re)??tt[0],At=p.useMemo(()=>o$(pn,(u==null?void 0:u.editMode)==="source-preserving"),[u==null?void 0:u.editMode,pn]),sn=p.useMemo(()=>_we(pn,nl(d)),[d,pn]),An=sn.find(W=>W.label===`${ot.name.trim()||"自定义模型"} 模型 API Key`),$r=p.useCallback(W=>{w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},modelApiKeyId:W.id,modelApiKeyName:W.name}}))},[]);function Gr(W){const Te=W.problem==="缺少子 Agent"?"type":"basic",dt=Pt.current[Te];dt==null||dt.scrollIntoView({behavior:"smooth",block:"start"});const nn=W.problem==="缺少描述"?"description":W.problem==="缺少系统提示词"?"instruction":W.problem==="缺少 AgentKit 智能体中心"?"a2a-registry":W.problem==="缺少子 Agent"||W.problem==="远程 Agent 只能作为子 Agent"?null:"name",an=nn?dt==null?void 0:dt.querySelector(`[data-validation-field="${nn}"]`):dt,on=an!=null&&an.matches('input, textarea, button:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])')?an:an==null?void 0:an.querySelector('input, textarea, button:not([disabled]), [contenteditable="true"], [tabindex]:not([tabindex="-1"])');on==null||on.focus({preventScroll:!0})}const Zs=()=>Ps?!0:(J(!0),je(W=>W+1),bs[0]&&(Xt(bs[0].path),window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>Gr(bs[0]))})),!1),Ta=async()=>{kt(null);const W=[...Z.current.values()];Z.current.clear(),rt(0),Ue(Te=>Te.map(dt=>({...dt,phase:"idle",runtimeSnapshot:"",messages:[],error:null}))),await Promise.all(W.map(async({run:Te})=>{try{await pb(Te.runId),kx(Te.runId)}catch(dt){console.warn("清理调试运行失败",dt)}}))},No=async W=>{const Te=Z.current.get(W);if(Te){Z.current.delete(W),rt(Z.current.size);try{await pb(Te.run.runId),kx(Te.run.runId)}catch(dt){console.warn("清理调试运行失败",dt)}}},Va=W=>{const Te=Z.current.get(W),dt=tt.find(nn=>nn.id===W);!Te||!dt||kt({runId:Te.run.runId,sessionId:Te.sessionId,variantName:dt.name})},Dd=W=>{const Te=ft.current;ft.current=null,Te==null||Te(W)},Ks=()=>{Xe||(Dt(!1),Dd(!1))},so=async()=>{if(!Xe){nt(!0);try{await Ta(),Dt(!1),Dd(!0)}finally{nt(!1)}}},jo=async()=>ie!=="validate"||_e===0?!0:ft.current?!1:new Promise(W=>{ft.current=W,Dt(!0)}),Pd=async W=>{if(await jo()){if(!Zs()){q("build");return}W&&ce(W),q("environment")}},ao=async W=>{var dt,nn;if(Ie(""),!Zs()){q("build");return}if((dt=pn.harnessSidecar)!=null&&dt.enabled&&ys){Ie(ys),q("optimize");return}const Te=n$(At.specs,((nn=pn.deployment)==null?void 0:nn.envValues)??{});if(Te){Ie(`${Te.spec.comment||Te.spec.key}:${Te.error}`),q("build");return}Be(!0);try{const an=W?tt.find(Wr=>Wr.id===W):Le;an&&ce(an.id);const on=an?EHe(pn,an):pn,er=await Cv(iv(on));w(on),Ge(er),q("publish")}catch(an){Ie(an instanceof Error?an.message:String(an))}finally{Be(!1)}},ol=async()=>{if(await jo()){if(!Zs()){q("build");return}q("optimize")}},oo=async W=>{if(!Se||Ae||!Zs())return;const Te=tt.find(Un=>Un.id===W);if(!Te||Te.phase==="starting"||Te.phase==="sending")return;const dt=Te.modelName.trim(),nn=Te.description.trim(),an=Te.instruction.trim(),on=ty(Te),er=tt.findIndex(Un=>Un.id===W),Wr=tt.findIndex(Un=>ty(Un)===on);if(!dt||!nn||!an||Wr!==er)return;const gr=YA(pe,Te);Ue(Un=>Un.map(_n=>_n.id===W?{..._n,configOpen:!1,phase:"starting",messages:[],error:null}:_n)),We("");let Nr=null,xn="unknown";const Jt=W==="baseline"?"baseline":"comparison",Ut=ZCt({agentId:String(pn.name||"unknown"),variantType:Jt});try{await No(W),await Ce();const Un={...pn,modelName:Te.modelName||pn.modelName,description:Te.description,instruction:Te.instruction};xn="create_test_run",Nr=await yle(iSe(Un,C),u?{runtimeId:u.runtimeId,region:u.region}:void 0),dIt(Nr.runId),xn="create_test_session";const _n=await Ole(Nr.runId,"test_user");Z.current.set(W,{run:Nr,sessionId:_n}),rt(Z.current.size),Ue(ci=>ci.map(co=>co.id===W?{...co,phase:"ready",runtimeSnapshot:gr}:co)),Ut.succeed({debugRunId:String(Nr.runId)})}catch(Un){if(Nr)try{await pb(Nr.runId),kx(Nr.runId)}catch(_n){console.warn("清理调试运行失败",_n)}Ue(_n=>_n.map(ci=>ci.id===W?{...ci,phase:"error",runtimeSnapshot:"",error:Un instanceof Error?Un.message:String(Un)}:ci)),Ut.fail({failedPhase:xn,...mo(Un,{phase:xn})})}},Yl=async()=>{const W=Re.trim(),Te=tt.filter(nn=>nn.phase==="ready"&&nn.runtimeSnapshot===YA(pe,nn)&&Z.current.has(nn.id));if(!W||Te.length===0)return;We("");const dt=new Set(Te.map(nn=>nn.id));Ue(nn=>nn.map(an=>dt.has(an.id)?{...an,phase:"sending",messages:[...an.messages,{role:"user",content:W},{role:"assistant",content:"",blocks:[]}]}:an)),await Promise.all(Te.map(async nn=>{const an=Z.current.get(nn.id);if(an)try{let on=Tf();for await(const er of vle({runId:an.run.runId,userId:"test_user",sessionId:an.sessionId,text:W})){const Wr=er.error||er.errorMessage||er.error_message;if(Wr||(on=wC(on,er)),Ue(gr=>gr.map(Nr=>{if(Nr.id!==nn.id)return Nr;const xn=[...Nr.messages],Jt={...xn[xn.length-1]};return Wr?Jt.error=String(Wr):(Jt.content=on.blocks.filter(Ut=>Ut.kind==="text").map(Ut=>Ut.text).join(""),Jt.blocks=on.blocks),xn[xn.length-1]=Jt,{...Nr,messages:xn}})),Wr)break}}catch(on){Ue(er=>er.map(Wr=>{if(Wr.id!==nn.id)return Wr;const gr=[...Wr.messages],Nr={...gr[gr.length-1]};return Nr.error=on instanceof Error?on.message:String(on),gr[gr.length-1]=Nr,{...Wr,messages:gr}}))}finally{Ue(on=>on.map(er=>er.id===nn.id?{...er,phase:"ready"}:er))}}))},Ru=()=>{Ue(W=>{if(W.length>=3)return W;const Te=Me.current++,dt=`variant-${Te}`;return[...W,{id:dt,name:`对照组 ${Te}`,modelName:x.modelName??"",description:x.description,instruction:x.instruction,configOpen:!0,phase:"idle",runtimeSnapshot:"",messages:[],error:null}]})},Fc=async W=>{await No(W),Ue(Te=>Te.filter(dt=>dt.id!==W)),re===W&&ce("baseline")},Iu=(W,Te)=>Ue(dt=>dt.map(nn=>nn.id===W?{...nn,...Te}:nn)),Ro=(W,Te)=>{if(Te&&ys){Ie(ys);return}const dt=Te?[...new Set([...Ur,W])]:Ur.filter(an=>an!==W),nn=Oi==="ops"?"default":Oi;w(an=>({...an,harnessSidecar:sg(dt,nn)})),Ie(""),Ge(null)},zc=W=>{const Te=F7(W);if(Te.length>0&&ys){Ie(ys);return}w(dt=>({...dt,harnessSidecar:sg(Te,W)})),Ie(""),Ge(null)},Zl=(W,Te,dt)=>{W==="baseline"&&Te==="modelName"&&(Ye.current=!0),Iu(W,{[Te]:dt}),!(re!==W||W==="baseline")&&ce("baseline")},Md=W=>{const Te=tt.find(gr=>gr.id===W);if(!Te)return;const dt=Te.modelName.trim(),nn=Te.description.trim(),an=Te.instruction.trim(),on=ty(Te),er=tt.findIndex(gr=>gr.id===W),Wr=tt.findIndex(gr=>ty(gr)===on);if(!(!dt||!nn||!an||Wr!==er)){if(W==="baseline"){Iu(W,{configOpen:!1});return}oo(W)}},kn=async(W,Te,dt)=>{var Wr,gr,Nr;const nn=(u==null?void 0:u.editMode)==="source-preserving",an=VC(x).includes("mcp_resilience"),on=(Wr=x.deployment)==null?void 0:Wr.network,er=on&&on.mode&&on.mode!=="public"?{mode:on.mode,vpc_id:on.vpcId,subnet_ids:on.subnetIds,enable_shared_internet_access:on.enableSharedInternetAccess}:void 0;return z1(W.name,W.files,{region:(u==null?void 0:u.region)??he,projectName:"default",network:er},{...dt,onStage:Te,runtimeId:u==null?void 0:u.runtimeId,runtimeName:(dt==null?void 0:dt.runtimeName)??T,appName:u==null?void 0:u.appName,editMode:u==null?void 0:u.editMode,draft:u||an?iv(x):void 0,updateEtag:u==null?void 0:u.etag,baseRuntimeVersion:u==null?void 0:u.currentVersion,envs:nn?[]:dt==null?void 0:dt.envs,mcpSecretValues:nn?DRt(x):an?IRt(x):void 0,mcpCredentialReuses:u?PRt(x):void 0,removeRuntimeEnvKeys:u?[...kRt(u.configuredMcpEnvKeys??[],x),...(gr=x.deployment)!=null&&gr.feishuEnabled?[]:["FEISHU_APP_ID","FEISHU_APP_SECRET"]]:void 0,description:x.description,harnessSidecar:x.harnessSidecar,environment:(Nr=x.cloudEnvironment)!=null&&Nr.environmentId?{environmentId:x.cloudEnvironment.environmentId,environmentVersionId:x.cloudEnvironment.environmentVersionId}:void 0})},Vc=()=>{Zs()&&(Ue(W=>W.map(Te=>Te.id==="baseline"&&!Z.current.has(Te.id)?{...Te,modelName:Ye.current?Te.modelName:l$(pn),description:pn.description,instruction:pn.instruction}:Te)),q("validate"))},_h=async W=>{if(W==="publish"){if(!await jo())return;await ao();return}if(W==="validate"){Vc();return}if(W==="optimize"){await ol();return}if(W==="environment"){Pd();return}await jo()&&q(W)},ae=W=>{w(Te=>({...Te,cloudEnvironment:W})),Ie(""),Ge(null)},In=async W=>{var Jt,Ut,Un,_n,ci,co,ym,Kl,_0,T0,ei,Du;if(xe||(pt(""),It(!1),!Zs()))return;const Te=WE(T.trim());if(Te){pt(Te);return}const dt={...pn,memory:{...pn.memory,shortTerm:W.sessionBackend!=="local"},shortTermBackend:W.sessionBackend},nn=o$(dt,(u==null?void 0:u.editMode)==="source-preserving"),an=(Jt=dt.deployment)==null?void 0:Jt.network;if((an==null?void 0:an.mode)!==void 0&&an.mode!=="public"&&!((Ut=an.vpcId)!=null&&Ut.trim())){pt("使用 VPC 网络时,请填写 VPC ID。");return}if(am(dt,d)==="ark"&&!((_n=(Un=dt.deployment)==null?void 0:Un.modelApiKeyId)!=null&&_n.trim())){pt("请先选择模型使用的 API Key。");return}const on={...((ci=dt.deployment)==null?void 0:ci.envValues)??{},...E,...nn.fixedValues},er=Object.keys(on).find(Io=>Io&&!/^[A-Za-z_][A-Za-z0-9_]*$/.test(Io));if(er){pt(`环境变量名称不合法:${er}`);return}const Wr=(co=dt.deployment)!=null&&co.feishuEnabled?[...nn.specs,...qx]:nn.specs,gr=ujt(Wr,on);if(gr){pt(`${gr.comment||gr.key}:请填写必填环境变量`);return}const Nr=n$(Wr,on);if(Nr){pt(`${Nr.spec.comment||Nr.spec.key}:${Nr.error}`);return}$e(!0),ve({level:"info",phase:"prepare",message:"正在生成部署配置",pct:0});let xn=null;try{if(!u&&!(await $N(T.trim(),he)).available)throw new Error("Runtime 名称已存在,请修改后重试。");const Io=await Cv(iv(dt));Ge(Io);const Pu=crypto.randomUUID(),Jl=Date.now();let Hc="prepare",ec="准备部署",tc="正在生成部署配置";const cl={id:Pu,...c?{draftId:c}:{},agentName:dt.name,runtimeName:T.trim(),region:he,startedAt:Jl,agentDraft:dt},Th={...cl,status:"running",phase:Hc,label:ec,message:tc,pct:0};xn=Th,s==null||s(Th),m==null||m(Th);const $d=new Map(Object.entries(on).map(([xi,tr])=>[xi.trim(),tr]).filter(([xi,tr])=>xi&&tr.trim()));for(const xi of CU(Wr,on))$d.set(xi.key,xi.value);const Et=(Kl=(ym=dt.deployment)==null?void 0:ym.modelApiKeyId)==null?void 0:Kl.trim(),Bd=(T0=(_0=dt.deployment)==null?void 0:_0.modelApiKeyName)==null?void 0:T0.trim();Et&&$d.set("MODEL_AGENT_API_KEY_ID",Et),Bd&&$d.set("MODEL_AGENT_API_KEY_NAME",Bd);const qc=await kn(Io,xi=>{Hc=xi.phase,ec=xi.phase==="build"?"构建镜像":xi.phase==="deploy"?"部署 Runtime":xi.phase==="publish"?"发布服务":"部署中",tc=xi.message,ve(xi),s==null||s({...cl,runtimeName:xi.runtimeName||cl.runtimeName,status:"running",phase:Hc,label:ec,message:tc,pct:xi.pct,...xi.buildLog?{buildLog:xi.buildLog}:{}})},{taskId:Pu,runtimeName:T.trim(),sessionStorage:W.sessionStorage,minInstance:W.minInstance,maxInstance:W.maxInstance,authentication:W.authentication,createEvaluationSets:W.createEvaluationSets,resources:W.resources,...(ei=dt.deployment)!=null&&ei.feishuEnabled?{im:{feishu:{enabled:!0}}}:{},envs:[...$d].map(([xi,tr])=>({key:xi,value:tr}))});It(!0),ve({level:"success",phase:"complete",message:"部署已完成",pct:100}),s==null||s({...cl,runtimeName:qc.runtimeName||cl.runtimeName,runtimeId:qc.runtimeId,region:qc.region||he,status:"success",phase:"complete",label:"部署完成",message:(Du=qc.warnings)==null?void 0:Du.join(";"),pct:100}),await(h==null?void 0:h(qc))}catch(Io){const Pu=Io instanceof Error?Io.message:String(Io);pt(Pu),ve(null);const Jl={...xn??{id:crypto.randomUUID(),agentName:pn.name||"未命名智能体",runtimeName:T.trim(),region:he,startedAt:Date.now()},status:"error",phase:xn==null?void 0:xn.phase,label:"部署失败",message:Pu,retry:()=>In(W)};s==null||s(Jl)}finally{$e(!1)}},Vn=gt.current,Os=W=>hIt.find(Te=>Te.id===W),Jn=o.jsx("section",{className:`cw-ai-compose${M?" is-generating":""}${$?" is-success":""}`,"aria-label":"AI 自动填写 Agent 配置",children:o.jsx(fu,{initial:!1,mode:"wait",children:$?o.jsxs(ai.div,{className:"cw-ai-compose-success",role:"status",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.22,ease:[.22,1,.36,1]},children:[o.jsx("span",{className:"cw-ai-success-check","aria-hidden":!0}),o.jsx("strong",{children:"生成成功"}),o.jsx("button",{type:"button",className:"cw-ai-regenerate",onClick:()=>N(!1),children:"重新生成"})]},"success"):o.jsxs(ai.div,{className:"cw-ai-compose-entry",initial:{opacity:0,scale:.98},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.98},transition:{duration:.2,ease:[.22,1,.36,1]},children:[o.jsxs("form",{className:"cw-ai-compose-form",onSubmit:W=>{W.preventDefault(),Pr()},children:[o.jsx("input",{type:"text",value:A,maxLength:8e3,disabled:M,placeholder:`描述目标,使用 ${p5e(d)} 模型一键生成配置`,"aria-invalid":!!z,"aria-describedby":z?"ai-requirement-error":void 0,onChange:W=>R(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),Pr())}}),o.jsx("button",{type:"submit",disabled:M||!H||!!z,"aria-label":M?"正在智能生成":"智能生成",children:M?o.jsx("span",{className:"cw-ai-orb","aria-hidden":!0,children:o.jsx("span",{})}):"智能生成"})]}),z&&o.jsx("p",{className:"cw-ai-requirement-error",id:"ai-requirement-error",role:"alert",children:z})]},"compose")})});return S?o.jsx(YRt,{draft:pn,cloudProvider:d,deployRegion:he,runtimeName:T,isRuntimeUpdate:!!u,deploying:xe,deployStage:it,deployError:He,deploySucceeded:_t,showErrors:G,onBack:e,onDraftPatch:W=>{w(Te=>({...Te,...W})),Ge(null),Ie("")},onDeploymentPatch:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},...W}})),onModelApiKeyChange:$r,customModelApiKey:An?E[An.key]??"":"",onCustomModelApiKeyChange:W=>{An&&k(Te=>({...Te,[An.key]:W}))},onSelectedSkillsChange:W=>w(Te=>({...Te,selectedSkills:W})),onCloudEnvironmentChange:ae,onDeployRegionChange:be,onRuntimeNameChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},runtimeName:W,runtimeNameCustomized:!0}})),onNetworkChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},network:W}})),onDeploy:W=>void In(W)}):o.jsxs("div",{className:`cw-root is-${ie}`,children:[o.jsx(QIt,{mode:ie}),xt&&o.jsx(t0,{className:"cw-workspace-alert",message:xt}),o.jsxs("main",{className:"cw-workspace-main",id:"cw-workspace-main",children:[ie==="build"&&o.jsx("div",{className:"cw-build-workspace",children:o.jsxs("div",{className:"cw-editor",children:[o.jsx(zw,{draft:x,direction:"horizontal",selectedPath:Vt,onSelect:Xt,onAdd:Lr,onInsert:Kr,onDelete:mr}),o.jsx("div",{className:"cw-detail",children:o.jsx("div",{className:"cw-detail-scroll",ref:Fe,children:o.jsx("div",{className:"cw-detail-inner",children:o.jsx("div",{className:"cw-lower",children:o.jsxs("div",{className:"cw-form-col",children:[o.jsxs(Vn,{meta:Os("type"),children:[o.jsx(fa,{className:"cw-agent-type-options","aria-label":"Agent 类型",value:ot.agentType??"llm",onChange:Gn,children:hRt.map(W=>{const Te=(ot.agentType??"llm")===W.id,dt=ln&&W.id==="a2a",nn=dt?"cw-remote-agent-disabled-hint":void 0;return o.jsxs("div",{"data-agent-type":W.id,className:`cw-agent-type-option ${Te?"is-on":""} ${dt?"is-disabled":""}`,tabIndex:dt?0:void 0,"aria-describedby":nn,children:[o.jsx(fa.Item,{value:W.id,disabled:dt,block:!0,className:"cw-agent-type-control",children:o.jsx("span",{className:"cw-agent-type-copy",children:o.jsx("strong",{children:mIt[W.id]})})}),dt&&o.jsx("span",{id:nn,className:"cw-agent-type-disabled-hint",role:"tooltip",children:"远程智能体只能作为子步骤使用"})]},W.id)})}),G&&Di&&ot.subAgents.length===0&&o.jsx("span",{className:"cw-error-text",children:RIt({name:ot.name.trim()||"未命名",typeLabel:Rwe(ot.agentType).label})})]}),o.jsx(Vn,{meta:Os("basic"),children:o.jsxs("div",{className:"cw-form",children:[!rs&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"cw-field",children:[o.jsxs("label",{className:"cw-label",children:[ln?"Agent 名称":"名称",o.jsx("span",{className:"cw-req",children:"*"})]}),o.jsx("input",{className:`cw-input ${yi(Ys,_a)}`,"data-validation-field":"name",value:ot.name,placeholder:"assistant","aria-invalid":_a&&Ys,"aria-describedby":_a&&ka?"cw-agent-name-error":void 0,onBlur:_r,onChange:W=>{_r(),et({name:W.target.value})}}),_a&&ka?o.jsx("span",{id:"cw-agent-name-error",role:"alert",className:"cw-error-text",children:ka}):o.jsx("span",{className:"cw-help",children:"遵循 Google ADK 命名规则,且在执行流程中保持唯一。"})]}),o.jsxs("div",{className:"cw-field",children:[o.jsxs("label",{className:"cw-label",children:[ln?"描述":"智能体描述",o.jsx("span",{className:"cw-req",children:"*"})]}),o.jsx("textarea",{className:`cw-textarea cw-textarea-sm ${yi(Ds)}`,"data-validation-field":"description",value:ot.description,placeholder:"简要描述这个 Agent 的用途,便于团队识别…","aria-invalid":G&&Ds,"aria-describedby":G&&Ds?"cw-agent-description-error":void 0,onChange:W=>et({description:W.target.value})}),G&&Ds?o.jsx("span",{id:"cw-agent-description-error",role:"alert",className:"cw-error-text",children:"描述为必填项"}):o.jsx("span",{className:"cw-help",children:ln?"完整描述会保留;部署时会自动整理为符合 Runtime 规范的单行描述。":"描述会显示在 Agent 列表与选择器中。"})]})]}),Di?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"cw-section-desc cw-dependency-hint",children:"这是一个协作容器,本身不生成回答。请在左侧画布中 添加任务步骤,并通过拖拽调整它们的位置。"}),ot.agentType==="loop"&&o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"最大轮次"}),o.jsx("input",{className:"cw-input",type:"number",min:1,value:ot.maxIterations??3,onChange:W=>et({maxIterations:Math.max(1,Number(W.target.value)||1)})}),o.jsx("span",{className:"cw-help",children:"循环编排反复执行子 Agent,直到满足条件或达到该轮次上限。"})]})]}):rs?o.jsxs("div",{className:"cw-field cw-remote-center-fields","data-validation-field":"a2a-registry",children:[o.jsxs("div",{className:"cw-remote-center-head",children:[o.jsxs("div",{className:"cw-label",children:["AgentKit 智能体中心",o.jsx("span",{className:"cw-req",children:"*"})]}),o.jsx("p",{className:"cw-help cw-remote-center-description",children:"远程 Agent 的名称、描述和能力来自中心返回的 Agent Card。 系统会根据每轮任务动态发现并挂载匹配的 Agent。"})]}),o.jsx(SIt,{value:((xs=ot.a2aRegistry)==null?void 0:xs.registrySpaceId)??"",region:((lo=ot.a2aRegistry)==null?void 0:lo.registryRegion)||oa.region,invalid:G&&Cr,onChange:W=>pr(Jwe,W)}),o.jsxs("button",{type:"button",className:"cw-more-options","aria-expanded":Kt,"aria-controls":Ve,onClick:()=>en(W=>!W),children:[o.jsx("span",{children:"更多选项"}),o.jsx(XS,{className:`cw-more-options-chevron ${Kt?"is-open":""}`,"aria-hidden":!0})]}),o.jsx(fu,{initial:!1,children:Kt&&o.jsx(ai.div,{id:Ve,className:"cw-model-advanced",initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18,ease:"easeOut"},children:o.jsx(_x,{env:Eb(gIt,d),values:eSe(ot.a2aRegistry,{includeDefaults:!1},d),onChange:pr})})}),G&&Cr&&o.jsx("span",{className:"cw-error-text",role:"alert",children:"请选择 AgentKit 智能体中心"})]}):o.jsxs("div",{className:"cw-field","data-validation-field":"instruction",children:[o.jsxs("label",{className:"cw-label",children:["系统提示词",o.jsx("span",{className:"cw-req",children:"*"})]}),o.jsx(p.Suspense,{fallback:o.jsx("div",{className:"cw-markdown-loading",role:"status",children:"正在加载 Markdown 编辑器…"}),children:o.jsx(uIt,{value:ot.instruction,invalid:Pi,onChange:W=>et({instruction:W})})}),G&&Pi?o.jsx("span",{className:"cw-error-text",role:"alert",children:"系统提示词为必填项"}):o.jsx("span",{className:"cw-help",children:"支持 Markdown 快捷输入,例如键入 ## 加空格创建二级标题。"})]})]})}),!Di&&!rs&&o.jsxs(o.Fragment,{children:[o.jsx(Vn,{meta:Os("model"),children:o.jsxs("div",{className:"cw-form",children:[o.jsxs("div",{className:"cw-field cw-model-source-field",children:[o.jsx("label",{className:"cw-label",children:"模型来源"}),o.jsx(fa,{className:"cw-model-source-options","aria-label":"模型来源",value:Qr,onChange:W=>{W!=="gateway"&&Ws(W)},children:[{value:"ark",label:d==="byteplus"?"BytePlus ModelArk":"火山方舟"},{value:"custom",label:"自定义"},{value:"gateway",label:"模型网关",disabled:!0}].map(W=>o.jsx("div",{className:`cw-model-source-option ${Qr===W.value?"is-on":""}${W.disabled?" is-disabled":""}`,children:o.jsxs(fa.Item,{value:W.value,disabled:W.disabled,block:!0,className:"cw-model-source-control",children:[o.jsx("span",{children:W.label}),W.disabled&&o.jsx("span",{className:"cw-model-source-coming-soon",children:"待上线"})]})},W.value))})]}),Qr==="ark"?o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"模型配置"}),o.jsx(wIt,{value:ot.modelName??"",cloudProvider:d,apiKeyId:(vs=x.deployment)==null?void 0:vs.modelApiKeyId,apiKeyName:(Ar=x.deployment)==null?void 0:Ar.modelApiKeyName,onApiKeyChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},modelApiKeyId:W.id,modelApiKeyName:W.name}})),onChange:W=>et({modelName:W})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"模型名称"}),o.jsx("input",{className:"cw-input",value:ot.modelName??"",onChange:W=>et({modelName:W.target.value})})]}),o.jsxs("div",{className:"cw-field",children:[o.jsxs("label",{className:"cw-label cw-label-with-link",children:[o.jsx("span",{children:"服务商 Provider"}),o.jsxs("a",{href:"https://docs.litellm.ai/docs/providers",target:"_blank",rel:"noopener noreferrer",onClick:W=>W.stopPropagation(),children:["LiteLLM 支持列表",o.jsx(Dg,{"aria-hidden":"true"})]})]}),o.jsx("input",{className:"cw-input",value:ot.modelProvider??"",placeholder:"openai",onChange:W=>et({modelProvider:W.target.value})})]}),o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"API Base"}),o.jsx("input",{className:"cw-input",value:ot.modelApiBase??"",placeholder:nl(d),onChange:W=>et({modelApiBase:W.target.value})})]}),o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"API Key"}),o.jsx("input",{className:"cw-input",type:"password",value:An?E[An.key]??"":"",placeholder:"请输入模型 API Key",autoComplete:"new-password",onChange:W=>{if(!An)return;const Te=W.currentTarget.value;k(dt=>({...dt,[An.key]:Te}))}})]})]})]})}),o.jsx(Vn,{meta:Os("tools"),children:o.jsxs("div",{className:"cw-form",children:[o.jsxs("div",{className:"cw-field",children:[o.jsx("label",{className:"cw-label",children:"内置工具"}),o.jsx("span",{className:"cw-help",children:"勾选 VeADK 提供的内置能力,生成时会自动补全 import 与所需环境变量。"}),o.jsx("div",{className:"cw-tools-list-shell",children:o.jsx(bIt,{items:Tr,selected:Xr,onToggle:Jr,scrollRows:6})}),o.jsx(fu,{initial:!1,children:Xr.includes("run_code")&&o.jsxs(ai.div,{className:"cw-tool-config",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.16,ease:"easeOut"},children:[o.jsxs("div",{className:"cw-tool-config-head",children:[o.jsx("span",{className:"cw-label",children:"代码执行配置"}),o.jsx("span",{className:"cw-help",children:"指定 AgentKit 代码执行沙箱。"})]}),o.jsx(_x,{env:((la=eO.find(W=>W.id==="run_code"))==null?void 0:la.env)??[],values:((ca=x.deployment)==null?void 0:ca.envValues)??{},onChange:Mt})]})})]}),o.jsxs("div",{className:"cw-field cw-mcp-field",children:[o.jsx("label",{className:"cw-label",children:"MCP 工具"}),o.jsx(_It,{tools:Ii,onChange:W=>et({mcpTools:W})})]})]})}),o.jsx(Vn,{meta:Os("skills"),children:o.jsx("div",{className:"cw-form",children:o.jsx(mU,{selected:bi,onChange:W=>et({selectedSkills:W}),cloudProvider:d})})}),o.jsx(Vn,{meta:Os("knowledge"),children:o.jsxs("div",{className:"cw-form cw-toggle-stack",children:[o.jsx(b_,{checked:ot.knowledgebase,onChange:W=>et({knowledgebase:W}),title:"知识库",desc:"启用外部知识检索(RAG),让 Agent 基于你的资料作答。",icon:U_}),ot.knowledgebase&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"知识库后端"}),o.jsx(i3,{options:z4,value:ot.knowledgebaseBackend,onChange:W=>et({knowledgebaseBackend:W,knowledgebaseIndex:W==="viking"||W==="openviking"?ot.knowledgebaseIndex:""})}),(ot.knowledgebaseBackend??jp)==="viking"&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"VikingDB 知识库"}),o.jsx(EIt,{value:ot.knowledgebaseIndex??"",onChange:W=>{et({knowledgebaseIndex:W.id}),W.projectName&&Mt("DATABASE_VIKING_PROJECT",W.projectName),W.region&&Mt("DATABASE_VIKING_REGION",W.region),W.sourceKind&&Mt("DATABASE_VIKING_COLLECTION_KIND",W.sourceKind),Mt("DATABASE_VIKING_RESOURCE_ID",W.resourceId??"")}})]}),o.jsx(_x,{env:((fe=z4.find(W=>W.id===(ot.knowledgebaseBackend??jp)))==null?void 0:fe.env)??[],values:((Je=x.deployment)==null?void 0:Je.envValues)??{},onChange:Mt,renderAfterField:(ot.knowledgebaseBackend??jp)==="openviking"?W=>W.key==="DATABASE_OPENVIKING_USER_ID"?o.jsx(OIt,{value:ot.knowledgebaseIndex??"",onChange:Te=>et({knowledgebaseIndex:Te})}):null:void 0})]})]})}),ln&&o.jsx(Vn,{meta:Os("memory"),children:o.jsxs("div",{className:"cw-form cw-toggle-stack",children:[o.jsx(b_,{checked:ot.memory.shortTerm,onChange:W=>et({memory:{...ot.memory,shortTerm:W}}),title:"短期记忆",desc:"存储单会话上下文",showDescription:!0,icon:Bae}),ot.memory.shortTerm&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"短期记忆后端"}),o.jsx(i3,{options:by,value:ot.shortTermBackend,onChange:W=>et({shortTermBackend:W})}),o.jsx(_x,{env:((St=by.find(W=>W.id===(ot.shortTermBackend??"local")))==null?void 0:St.env)??[],values:((dn=x.deployment)==null?void 0:dn.envValues)??{},onChange:Mt})]}),o.jsx(b_,{checked:ot.memory.longTerm,onChange:W=>et({memory:{...ot.memory,longTerm:W}}),title:"长期记忆",desc:"存储跨会话上下文,通常使用向量化检索",showDescription:!0,icon:U_}),ot.memory.longTerm&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"长期记忆后端"}),o.jsx(i3,{options:F4,value:ot.longTermBackend,onChange:W=>et({longTermBackend:W,longTermMemoryIndex:W==="viking"?ot.longTermMemoryIndex:""})}),(ot.longTermBackend??"local")==="viking"&&o.jsxs("div",{className:"cw-field cw-subfield",children:[o.jsx("label",{className:"cw-label",children:"VikingDB 记忆库"}),o.jsx(kIt,{value:ot.longTermMemoryIndex??"",onChange:W=>{et({longTermMemoryIndex:W.id}),Mt("DATABASE_VIKINGMEM_PROJECT",W.projectName),Mt("DATABASE_VIKING_REGION",W.region),Mt("DATABASE_VIKINGMEM_MEMORY_TYPE",(W.memoryTypes??[]).join(","))}})]}),o.jsx(_x,{env:((Zt=F4.find(W=>W.id===(ot.longTermBackend??"local")))==null?void 0:Zt.env)??[],values:((Tt=x.deployment)==null?void 0:Tt.envValues)??{},onChange:Mt}),o.jsx(b_,{checked:!!ot.autoSaveSession,onChange:W=>et({autoSaveSession:W}),title:"自动保存会话到长期记忆",desc:"会话结束时自动把内容写入长期记忆,无需手动调用。",icon:U_})]})]})})]})]})})})})})]})}),ie==="validate"&&o.jsx("div",{className:"cw-validation-workspace",children:o.jsx("div",{className:"cw-validation-content",children:o.jsx(LIt,{enabled:Se,disabledReason:Ee,variants:tt,draftSnapshot:pe,input:Re,onInput:We,onSend:Yl,onStartVariant:oo,onUseVariant:W=>void Pd(W),onAddVariant:Ru,onRemoveVariant:Fc,onToggleConfig:W=>{const Te=tt.find(dt=>dt.id===W);Te&&Iu(W,{configOpen:!Te.configOpen})},onCompleteConfig:Md,onConfigChange:Zl,onOpenTrace:Va})})}),ie==="optimize"&&o.jsx($It,{profile:Oi,optimizations:Ur,unavailableMessage:ys,onProfileChange:zc,onOptimizationChange:Ro}),ie==="environment"&&o.jsx("div",{className:"cw-environment-workspace",children:o.jsx(Ywe,{value:x.cloudEnvironment??{environmentId:"",environmentVersionId:""},onChange:ae,disabled:Ae})}),ie==="publish"&&o.jsx("div",{className:"cw-preview-body",children:ze?o.jsx(_R,{embedded:!0,cloudProvider:d,project:ze,agentDraft:x,agentName:x.name||"未命名 Agent",agentCount:rSe(x),releaseConfiguration:Le?{modelName:Le.modelName||x.modelName||"默认模型",description:Le.description,instruction:Le.instruction,optimizations:[`优化场景:${ghe(Oi)}`,...Ur.map(Rv)]}:void 0,onChange:Ge,onDeploy:kn,onAgentAdded:n,onDeploymentTaskChange:s,deploymentActionLabel:u?"更新并发布":"部署",deploymentActionTargetId:"cw-publish-primary-action",deploymentRuntimeId:u==null?void 0:u.runtimeId,deploymentRuntimeName:T,deploymentRuntimeNameCustomized:!!u||!!((Lt=x.deployment)!=null&&Lt.runtimeNameCustomized),onDeploymentRuntimeNameChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},runtimeName:W,runtimeNameCustomized:!0}})),onDeploymentStarted:m,onDeploymentComplete:h,feishuEnabled:!!((Ne=x.deployment)!=null&&Ne.feishuEnabled),configuredRuntimeEnvKeys:u==null?void 0:u.configuredRuntimeEnvKeys,onFeishuEnabledChange:async W=>{const Te={...x,deployment:{...x.deployment??{feishuEnabled:!1},feishuEnabled:W}},dt=await Cv(iv(Te));w(Te),Ge(dt)},deploymentEnv:At.specs,requiredSecretEnv:sn,requiredSecretEnvValues:E,onRequiredSecretEnvChange:(W,Te)=>k(dt=>({...dt,[W]:Te})),deploymentEnvValues:{...(tn=pn.deployment)==null?void 0:tn.envValues,...E,...At.fixedValues},onDeploymentEnvChange:Mt,onFeishuCredentialsChange:(W,Te)=>mn({FEISHU_APP_ID:W,FEISHU_APP_SECRET:Te}),network:(or=x.deployment)==null?void 0:or.network,onNetworkChange:W=>w(Te=>({...Te,deployment:{...Te.deployment??{feishuEnabled:!1},network:W}})),deployRegion:he,onDeployRegionChange:be,deploymentTelemetry:{source:"scratch",createMode:a,aiAssisted:j},onExportYaml:()=>fIt(`${pn.name||"agent"}.yaml`,MRt(pn),"text/yaml")}):o.jsxs("div",{className:"cw-publish-loading",role:"status",children:[o.jsx(rr,{className:"cw-i cw-spin"}),o.jsx("strong",{children:"正在生成发布配置"}),o.jsx("span",{children:"校验 Agent 结构并准备部署快照…"})]})})]}),o.jsx(UIt,{mode:ie,busy:Ae,onChange:_h,assistant:ie==="build"?Jn:void 0}),ct&&o.jsx(Zwe,{testRunId:ct.runId,sessionId:ct.sessionId,title:`调用链路 · ${ct.variantName}`,onClose:()=>kt(null)}),qt&&o.jsx(ql,{variant:"warning",title:"离开调试?",description:"离开调试页面后,当前环境将被清理。您可以通过重新启动环境进行新的测试。",confirmLabel:Xe?"清理中...":"确定离开",closeLabel:"关闭离开调试确认",busy:Xe,onCancel:Ks,onConfirm:()=>void so()}),F&&o.jsx("div",{className:"confirm-scrim",onClick:()=>L(null),children:o.jsxs("div",{className:"confirm-box cw-ai-error-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"ai-generate-error-title","aria-describedby":"ai-generate-error-message",onClick:W=>W.stopPropagation(),children:[o.jsx("div",{className:"confirm-title",id:"ai-generate-error-title",children:"智能生成失败"}),o.jsx("div",{className:"cw-ai-error-message",id:"ai-generate-error-message",children:F}),o.jsx("div",{className:"confirm-actions",children:o.jsx("button",{type:"button",className:"confirm-btn cw-ai-error-close",onClick:()=>L(null),children:"关闭"})})]})})]})}function Kc({name:e}){const t={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0};switch(e){case"branch":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"6",cy:"5",r:"2"}),o.jsx("circle",{cx:"18",cy:"7",r:"2"}),o.jsx("circle",{cx:"18",cy:"17",r:"2"}),o.jsx("path",{d:"M8 5h2.5A3.5 3.5 0 0 1 14 8.5v7A1.5 1.5 0 0 0 15.5 17H16"}),o.jsx("path",{d:"M14 10.5v-2A1.5 1.5 0 0 1 15.5 7H16"})]});case"plan":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M6.5 3.5h11a2 2 0 0 1 2 2v13a2 2 0 0 1-2 2h-11a2 2 0 0 1-2-2v-13a2 2 0 0 1 2-2Z"}),o.jsx("path",{d:"m8 9 1.4 1.4L12 7.8M13.5 10H16M8 15l1.4 1.4 2.6-2.6M13.5 16H16"})]});case"collaborate":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"8",cy:"8",r:"3"}),o.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),o.jsx("path",{d:"M3.5 19a4.5 4.5 0 0 1 9 0M13.5 15.5A4 4 0 0 1 20.5 18"})]});case"summary":return o.jsx("svg",{...t,children:o.jsx("path",{d:"M5 4h14v16H5zM8 8h8M8 12h8M8 16h5"})});case"skills":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M5 5h5v5H5zM14 5h5v5h-5zM5 14h5v5H5z"}),o.jsx("path",{d:"M14 16.5h5M16.5 14v5"})]});case"trace":return o.jsxs("svg",{...t,children:[o.jsx("circle",{cx:"6",cy:"6",r:"2"}),o.jsx("circle",{cx:"18",cy:"12",r:"2"}),o.jsx("circle",{cx:"8",cy:"18",r:"2"}),o.jsx("path",{d:"M8 6h3a3 3 0 0 1 3 3v0a3 3 0 0 0 2 2.83M16.2 13.2 9.8 16.8"})]});case"structure":return o.jsxs("svg",{...t,children:[o.jsx("rect",{x:"3.5",y:"4",width:"7",height:"5",rx:"1"}),o.jsx("rect",{x:"13.5",y:"15",width:"7",height:"5",rx:"1"}),o.jsx("path",{d:"M10.5 6.5h3A3.5 3.5 0 0 1 17 10v5M7 9v7a2 2 0 0 0 2 2h4.5"})]});case"model":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M8 3.5v3M16 3.5v3M8 17.5v3M16 17.5v3M3.5 8h3M17.5 8h3M3.5 16h3M17.5 16h3"}),o.jsx("rect",{x:"6.5",y:"6.5",width:"11",height:"11",rx:"2"}),o.jsx("path",{d:"M10 10h4v4h-4z"})]});case"environment":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M4 7.5h16M7 4h10l3 3.5v10L17 20H7l-3-2.5v-10Z"}),o.jsx("path",{d:"m8 12 2 2-2 2M12.5 16H16"})]});case"deploy":return o.jsxs("svg",{...t,children:[o.jsx("path",{d:"M12 3.5v11M7.5 8 12 3.5 16.5 8"}),o.jsx("path",{d:"M5 13.5v5A1.5 1.5 0 0 0 6.5 20h11a1.5 1.5 0 0 0 1.5-1.5v-5"})]});case"workflow":return o.jsxs("svg",{...t,children:[o.jsx("rect",{x:"4",y:"4",width:"6",height:"5",rx:"1"}),o.jsx("rect",{x:"14",y:"15",width:"6",height:"5",rx:"1"}),o.jsx("path",{d:"M10 6.5h2a4 4 0 0 1 4 4V15M7 9v3a4 4 0 0 0 4 4h3"})]})}}function zIt({onSelectVulcan:e,onSelectTraditional:t}){const n=J8(),[r,i]=p.useState(!1),s=p.useRef(null),a=c=>{if(!r){if(n){c();return}s.current=c,i(!0)}},l=()=>{if(!r)return;const c=s.current;s.current=null,c==null||c()};return o.jsx(ai.main,{className:`agent-creation-mode-picker${r?" is-leaving":""}`,initial:n?!1:{opacity:0},animate:{opacity:r?0:1},transition:{duration:r?.12:.18,ease:[.16,1,.3,1]},onAnimationComplete:l,children:o.jsxs("section",{className:"agent-creation-mode-picker__content","aria-labelledby":"agent-creation-mode-picker-title",children:[o.jsxs("header",{className:"agent-creation-mode-picker__header",children:[o.jsx("h1",{id:"agent-creation-mode-picker-title",children:"选择创建方式"}),o.jsx("p",{children:"以不同模式构建您的智能体"})]}),o.jsxs("div",{className:"agent-creation-mode-picker__options",children:[o.jsxs(jt,{type:"button",className:"agent-creation-mode-picker__card",color:"secondary",variant:"outline",pill:!1,block:!0,onClick:()=>a(e),children:[o.jsxs("span",{className:"agent-creation-mode-picker__card-header",children:[o.jsx(u1,{className:"agent-creation-mode-picker__avatar is-vulcan",seed:"快速模式"}),o.jsxs("span",{className:"agent-creation-mode-picker__card-copy",children:[o.jsx("span",{className:"agent-creation-mode-picker__card-title",children:"快速模式"}),o.jsx("span",{className:"agent-creation-mode-picker__card-description",children:"动态派生子智能体自主完成任务"})]})]}),o.jsx("span",{className:"agent-creation-mode-picker__divider","aria-hidden":"true"}),o.jsxs("span",{className:"agent-creation-mode-picker__features",children:[o.jsx("span",{children:"特性"}),o.jsxs("span",{className:"agent-creation-mode-picker__feature-grid",children:[o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"branch"})}),o.jsx("span",{children:"动态派生子智能体"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"plan"})}),o.jsx("span",{children:"自主规划执行"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"collaborate"})}),o.jsx("span",{children:"多智能体协作"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"summary"})}),o.jsx("span",{children:"自动汇总结果"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"skills"})}),o.jsx("span",{children:"按需调用技能"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"trace"})}),o.jsx("span",{children:"任务过程可追踪"})]})]})]})]}),o.jsxs(jt,{type:"button",className:"agent-creation-mode-picker__card",color:"secondary",variant:"outline",pill:!1,block:!0,onClick:()=>a(t),children:[o.jsxs("span",{className:"agent-creation-mode-picker__card-header",children:[o.jsx(u1,{className:"agent-creation-mode-picker__avatar is-traditional",seed:"传统模式"}),o.jsxs("span",{className:"agent-creation-mode-picker__card-copy",children:[o.jsx("span",{className:"agent-creation-mode-picker__card-title",children:"传统模式"}),o.jsx("span",{className:"agent-creation-mode-picker__card-description",children:"高度自定义您的智能体结构"})]})]}),o.jsx("span",{className:"agent-creation-mode-picker__divider","aria-hidden":"true"}),o.jsxs("span",{className:"agent-creation-mode-picker__features",children:[o.jsx("span",{children:"特性"}),o.jsxs("span",{className:"agent-creation-mode-picker__feature-grid",children:[o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"structure"})}),o.jsx("span",{children:"可视化配置"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"model"})}),o.jsx("span",{children:"存量智能体迁移"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"environment"})}),o.jsx("span",{children:"实时调试"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"deploy"})}),o.jsx("span",{children:"可选性能优化"})]}),o.jsxs("span",{className:"agent-creation-mode-picker__feature",children:[o.jsx("span",{className:"agent-creation-mode-picker__feature-icon",children:o.jsx(Kc,{name:"workflow"})}),o.jsx("span",{children:"精细参数控制"})]})]})]})]})]})]})})}const ete=50*1024*1024,c$=800,VIt={name:"code_package",files:[]};function HIt(e){let n=e.replace(/\.zip$/i,"").trim().replace(/[^A-Za-z0-9_]+/g,"_").replace(/^_+|_+$/g,"");return n||(n="uploaded_agent"),/^[A-Za-z_]/.test(n)||(n=`agent_${n}`),n==="user"&&(n="uploaded_agent"),n.slice(0,64)}function sSe(e){const t=e.replace(/\\/g,"/").replace(/^\.\//,"");if(!t||t.endsWith("/"))return null;if(t.startsWith("/")||t.includes("\0"))throw new Error(`压缩包包含非法路径:${e}`);const n=t.split("/");if(n.some(r=>!r||r==="."||r===".."))throw new Error(`压缩包包含非法路径:${e}`);return n[0]==="__MACOSX"||n[n.length-1]===".DS_Store"?null:n.join("/")}function qIt(e){const t=e.flatMap(a=>{const l=sSe(a.name);return l?[{path:l,content:a.text}]:[]});if(t.length===0)throw new Error("压缩包中没有可部署的文件。");if(t.length>c$)throw new Error(`代码包文件数不能超过 ${c$} 个。`);const i=new Set(t.map(a=>a.path.split("/")[0])).size===1&&t.every(a=>a.path.includes("/"))?t.map(a=>({...a,path:a.path.split("/").slice(1).join("/")})):t,s=new Set;for(const a of i){if(s.has(a.path))throw new Error(`代码包包含重复文件:${a.path}`);s.add(a.path)}return XIt(i),i}function XIt(e){const t=new Set(e.map(i=>i.path)),n=e.find(i=>i.path==="agentkit.yaml");let r="app.py";if(n){let i;try{i=xht(n.content)}catch(l){throw new Error(`agentkit.yaml 无法解析:${l instanceof Error?l.message:String(l)}`)}if(i!==null&&(typeof i!="object"||Array.isArray(i)))throw new Error("agentkit.yaml 根节点必须是对象。");const s=i&&typeof i=="object"&&!Array.isArray(i)?i.common:void 0;if(s!==void 0&&(s===null||typeof s!="object"||Array.isArray(s)))throw new Error("agentkit.yaml 的 common 必须是对象。");const a=s&&typeof s=="object"&&!Array.isArray(s)?s.entry_point:void 0;if(a!==void 0){if(typeof a!="string")throw new Error("agentkit.yaml 的 common.entry_point 必须是文件路径。");const l=sSe(a);if(!l)throw new Error("agentkit.yaml 的 common.entry_point 不是有效文件路径。");r=l}}if(!t.has(r))throw n&&r!=="app.py"?new Error(`代码包中不存在 agentkit.yaml 声明的启动入口:${r}`):new Error("代码包根目录必须包含 app.py,或在 agentkit.yaml 的 common.entry_point 中声明已有入口。");return r}function GIt({onBack:e,onAgentAdded:t,onDeploymentTaskChange:n,onDeploymentStarted:r,onDeploymentComplete:i,cloudProvider:s="volcengine",initialDeployRegion:a=Zr(s)}){const l=p.useRef(null),c=p.useRef(0),[u,d]=p.useState(null),[f,h]=p.useState(""),[m,g]=p.useState(!1),[b,y]=p.useState(!1),[O,v]=p.useState(!1),[x,w]=p.useState(""),[S,E]=p.useState(a),[k,_]=p.useState();p.useEffect(()=>()=>{c.current+=1},[]);async function T(M){const I=++c.current;if(w(""),!M.name.toLowerCase().endsWith(".zip")){w("请选择 .zip 格式的代码包。");return}if(M.size>ete){w("代码包不能超过 50 MB。");return}y(!0);try{const $=await Nve(new Uint8Array(await M.arrayBuffer()),{maxEntries:c$,maxUncompressedBytes:ete}),N=qIt($);if(I!==c.current)return;h(M.name),d({name:HIt(M.name),files:N})}catch($){if(I!==c.current)return;h(""),d(null),w($ instanceof Error?$.message:String($))}finally{I===c.current&&y(!1)}}function C(M){var $;const I=($=M.currentTarget.files)==null?void 0:$[0];M.currentTarget.value="",I&&T(I)}function A(M){var $;M.preventDefault(),v(!1);const I=($=M.dataTransfer.files)==null?void 0:$[0];I&&T(I)}async function R(M,I,$){const N=k&&k.mode!=="public"?{mode:k.mode,vpc_id:k.vpcId,subnet_ids:k.subnetIds,enable_shared_internet_access:k.enableSharedInternetAccess}:void 0;return z1(M.name,M.files,{region:S,projectName:"default",network:N},{...$,onStage:I})}return o.jsxs("div",{className:"package-create package-create-preview",children:[o.jsx(_R,{cloudProvider:s,project:u??VIt,agentName:(u==null?void 0:u.name)||"代码包",onChange:u?d:void 0,onDeploy:R,onAgentAdded:t,onDeploymentTaskChange:n,onDeploymentStarted:r,onDeploymentComplete:i,network:k,onNetworkChange:_,deployRegion:S,onDeployRegionChange:E,deploymentTelemetry:{source:"code_package",createMode:"code_package",aiAssisted:!1},onBack:e,backLabel:"返回创建方式",deployDisabled:!u||b,deployDisabledReason:b?"正在读取代码包":u?void 0:"请先上传代码包",deploymentPrimaryPane:o.jsxs("section",{className:"package-source-pane","aria-label":"代码包上传",children:[o.jsx("div",{className:"package-source-label",children:"代码包"}),o.jsxs("div",{className:`package-dropzone${O?" is-dragging":""}${u?" is-ready":""}`,onDragEnter:M=>{M.preventDefault(),v(!0)},onDragOver:M=>M.preventDefault(),onDragLeave:M=>{M.currentTarget.contains(M.relatedTarget)||v(!1)},onDrop:A,onClick:()=>{var M;b||(M=l.current)==null||M.click()},onKeyDown:M=>{var I;!b&&(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),(I=l.current)==null||I.click())},role:"button",tabIndex:b?-1:0,"aria-label":u?"重新上传代码包":"上传代码包","aria-disabled":b,children:[o.jsx("strong",{children:b?"正在读取代码包…":u?f:"请上传代码包"}),o.jsx("span",{children:u?`已识别 ${u.files.length} 个文件,点击区域可重新上传`:"点击或拖拽上传,支持 .zip 格式,最大 50 MB;可使用 app.py,或由 agentkit.yaml 声明入口"}),o.jsx("div",{className:"package-upload-actions",children:u&&o.jsx("button",{type:"button",className:"package-upload-secondary",onClick:M=>{M.stopPropagation(),g(!0)},onKeyDown:M=>M.stopPropagation(),children:"查看文件"})}),o.jsx("input",{ref:l,type:"file",accept:".zip,application/zip","aria-label":"选择代码包",onChange:C})]}),x&&o.jsx("div",{className:"package-create-error",role:"alert",children:x})]})}),u&&o.jsx(Jw,{project:u,open:m,onClose:()=>g(!1),onChange:d})]})}const WIt="/web/agent-migrations",AR=39e4;class Uo extends Error{constructor(t,n,r="MIGRATION_ERROR",i=!1,s="",a=""){super(t),this.status=n,this.code=r,this.retryable=i,this.statusText=s,this.rawResponse=a,this.name="MigrationApiError"}}const YIt=new Set(["langchain","langgraph","adk","strands","agentcore","dify","any"]),ZIt=new Set(["awaiting_upload","analyzing","needs_input","analysis_ready","migrating","validating","packaging","succeeded","succeeded_with_warnings","partial","failed","cancelled","expired"]),KIt=new Set(["reasoning","message","plan","command","status"]),JIt=new Set(["running","completed","failed"]),e5t=new Set(["pending","in_progress","completed","failed"]);function Mr(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t}格式错误。`);return e}function hg(e,t){if(!Array.isArray(e)||!e.every(n=>typeof n=="string"))throw new Error(`${t}格式错误。`);return e}function nw(e,t){if(typeof e!="string"||!YIt.has(e))throw new Error(`${t}格式错误。`);return e}function t5t(e){const t=Mr(e,"迁移分析结果"),n=t.recommended===null?null:Mr(t.recommended,"迁移建议"),r=Mr(t.boundary,"迁移边界");if(t.schema_version!==1||!["needs_input","recommendation_ready","unsupported"].includes(String(t.status))||typeof t.attempt!="number"||typeof t.input_sha256!="string"||typeof t.summary!="string"||!Array.isArray(t.frameworks)||!Array.isArray(t.entries)||!Array.isArray(t.questions))throw new Error("迁移分析结果格式错误。");return{schema_version:1,status:t.status,attempt:t.attempt,input_sha256:t.input_sha256,summary:t.summary,frameworks:t.frameworks.map(i=>{const s=Mr(i,"框架候选");if(!["high","medium","low"].includes(String(s.confidence))||!Array.isArray(s.evidence))throw new Error("框架候选格式错误。");return{id:nw(s.id,"框架候选"),confidence:s.confidence,evidence:s.evidence.map(a=>{const l=Mr(a,"分析证据");if(typeof l.path!="string"||typeof l.line!="number"||typeof l.reason!="string")throw new Error("分析证据格式错误。");return{path:l.path,line:l.line,reason:l.reason}})}}),recommended:n===null?null:{framework:nw(n.framework,"推荐框架"),entry:n.entry===null||typeof n.entry=="string"?n.entry:null,reason:typeof n.reason=="string"?n.reason:""},entries:t.entries.map(i=>{const s=Mr(i,"入口候选");if(typeof s.value!="string"||typeof s.evidence!="string")throw new Error("入口候选格式错误。");return{value:s.value,framework:nw(s.framework,"入口框架"),evidence:s.evidence}}),boundary:{include:hg(r.include,"迁移包含范围"),exclude:hg(r.exclude,"迁移排除范围")},assumptions:hg(t.assumptions,"分析假设"),questions:t.questions.map(i=>{const s=Mr(i,"待确认问题");if(typeof s.id!="string"||typeof s.prompt!="string"||typeof s.required!="boolean")throw new Error("待确认问题格式错误。");return{id:s.id,prompt:s.prompt,required:s.required}}),warnings:hg(t.warnings,"迁移警告")}}function E0(e){const t=Mr(e,"迁移会话"),n=Mr(t.artifact,"迁移产物状态");if(typeof t.id!="string"||typeof t.state!="string"||!ZIt.has(t.state)||typeof t.message!="string"||typeof t.sourceFileName!="string"||typeof t.instruction!="string"||typeof t.createdAt!="string"&&typeof t.createdAt!="number"||typeof t.expiresAt!="string"||typeof t.sessionTtlSeconds!="number"||typeof t.canModify!="boolean"||typeof t.canUpload!="boolean"||typeof t.canAnswer!="boolean"||typeof t.canConfirm!="boolean"||typeof t.canStop!="boolean")throw new Error("迁移会话格式错误。");const r={id:t.id,state:t.state,message:t.message,sourceFileName:t.sourceFileName,instruction:t.instruction,createdAt:t.createdAt,expiresAt:t.expiresAt,sessionTtlSeconds:t.sessionTtlSeconds,canModify:t.canModify,canUpload:t.canUpload,canAnswer:t.canAnswer,canConfirm:t.canConfirm,canStop:t.canStop,artifact:{state:typeof n.state=="string"?n.state:"none",previewReady:n.previewReady===!0,downloadReady:n.downloadReady===!0,deployReady:n.deployReady===!0}};if(typeof t.modelId=="string"&&t.modelId.trim()&&(r.modelId=t.modelId),t.analysis!==void 0&&(r.analysis=t5t(t.analysis)),t.analysisRef!==void 0){const i=Mr(t.analysisRef,"分析结果引用");if(typeof i.attempt!="number"||typeof i.sha256!="string"||typeof i.inputSha256!="string")throw new Error("分析结果引用格式错误。");r.analysisRef={attempt:i.attempt,sha256:i.sha256,inputSha256:i.inputSha256}}if(t.confirmation!==void 0){const i=Mr(t.confirmation,"迁移确认");r.confirmation={...i.framework!==void 0?{framework:nw(i.framework,"确认框架")}:{},...i.entry===null||typeof i.entry=="string"?{entry:i.entry}:{},...typeof i.app_name=="string"?{app_name:i.app_name}:{}}}if(t.error!==void 0){const i=Mr(t.error,"迁移错误");r.error={code:typeof i.code=="string"?i.code:"MIGRATION_ERROR",message:typeof i.message=="string"?i.message:t.message,retryable:i.retryable===!0}}if(t.persistence!==void 0){const i=Mr(t.persistence,"迁移源码保存状态");if(!["saving","saved","failed","unavailable"].includes(String(i.state))||typeof i.message!="string"||i.projectId!==void 0&&typeof i.projectId!="string"||i.versionId!==void 0&&typeof i.versionId!="string"||i.retryable!==void 0&&typeof i.retryable!="boolean")throw new Error("迁移源码保存状态格式错误。");r.persistence={state:i.state,message:i.message,...typeof i.projectId=="string"?{projectId:i.projectId}:{},...typeof i.versionId=="string"?{versionId:i.versionId}:{},...typeof i.retryable=="boolean"?{retryable:i.retryable}:{}}}return r}function n5t(e){const t=Mr(e,"迁移执行动态");if(typeof t.available!="boolean"||typeof t.complete!="boolean"||!Array.isArray(t.items))throw new Error("迁移执行动态格式错误。");return{available:t.available,complete:t.complete,items:t.items.map(n=>{const r=Mr(n,"迁移执行动态项");if(typeof r.id!="string"||typeof r.kind!="string"||!KIt.has(r.kind)||typeof r.status!="string"||!JIt.has(r.status)||typeof r.title!="string"||r.detail!==void 0&&typeof r.detail!="string")throw new Error("迁移执行动态项格式错误。");let i;if(r.tool!==void 0){const a=Mr(r.tool,"迁移执行工具项");if(typeof a.name!="string"||a.error!==void 0&&typeof a.error!="string"||a.exitCode!==void 0&&!Number.isInteger(a.exitCode))throw new Error("迁移执行工具项格式错误。");i={name:a.name,...Object.prototype.hasOwnProperty.call(a,"input")?{input:a.input}:{},...Object.prototype.hasOwnProperty.call(a,"output")?{output:a.output}:{},...typeof a.error=="string"?{error:a.error}:{},...typeof a.exitCode=="number"?{exitCode:a.exitCode}:{}}}let s;if(r.plan!==void 0){if(!Array.isArray(r.plan))throw new Error("迁移执行计划格式错误。");s=r.plan.map(a=>{const l=Mr(a,"迁移执行计划项");if(typeof l.text!="string"||typeof l.status!="string"||!e5t.has(l.status))throw new Error("迁移执行计划项格式错误。");return{text:l.text,status:l.status}})}return{id:r.id,kind:r.kind,status:r.status,title:r.title,...typeof r.detail=="string"?{detail:r.detail}:{},...i?{tool:i}:{},...s?{plan:s}:{}}})}}function r5t(e){const t=Mr(e,"迁移产物"),n=Mr(t.cli,"CLI 信息"),r=Mr(t.migration,"迁移信息"),i=Mr(t.startup,"启动信息"),s=Mr(t.environment,"环境变量信息"),a=Mr(t.verification,"校验信息"),l=Mr(t.report,"迁移报告"),c=Mr(t.artifact,"产物归档"),u=s.defaults===void 0?{}:Mr(s.defaults,"环境变量默认值");if(t.schema_version!==1||!["succeeded","succeeded_with_warnings","partial"].includes(String(t.status))||typeof n.name!="string"||typeof n.version!="string"||!["structured","agentic"].includes(String(r.engine))||typeof r.framework!="string"||!Array.isArray(t.files)||typeof i.module!="string"||typeof i.object!="string"||!["passed","failed","degraded"].includes(String(a.status))||!Array.isArray(a.checks)||typeof l.path!="string"||c.path!=="migration-result.zip"||typeof c.size!="number"||typeof c.sha256!="string"||typeof t.created_at!="string")throw new Error("迁移产物格式错误。");const d=hg(s.required,"必需环境变量"),f=hg(s.optional,"可选环境变量"),h=new Set([...d,...f]),m=Object.fromEntries(Object.entries(u).map(([g,b])=>{if(!h.has(g)||typeof b!="string")throw new Error("环境变量默认值格式错误。");return[g,b]}));return{schema_version:1,...typeof t.run_id=="string"?{run_id:t.run_id}:{},cli:{name:n.name,version:n.version},migration:{engine:r.engine,framework:r.framework,...typeof r.entry=="string"?{entry:r.entry}:{},...typeof r.source_sha256=="string"?{source_sha256:r.source_sha256}:{},...typeof r.provenance_sha256=="string"?{provenance_sha256:r.provenance_sha256}:{}},status:t.status,files:t.files.map(g=>{const b=Mr(g,"迁移产物文件");if(typeof b.path!="string"||typeof b.size!="number"||typeof b.sha256!="string"||typeof b.mode!="string")throw new Error("迁移产物文件格式错误。");return{path:b.path,size:b.size,sha256:b.sha256,mode:b.mode}}),startup:{module:i.module,object:i.object,...Array.isArray(i.command)&&i.command.every(g=>typeof g=="string")?{command:i.command}:{}},environment:{required:d,optional:f,defaults:m},verification:{status:a.status,checks:a.checks.map(g=>{const b=Mr(g,"迁移校验项");if(typeof b.name!="string"||!["passed","failed"].includes(String(b.status)))throw new Error("迁移校验项格式错误。");return{name:b.name,status:b.status,...typeof b.detail=="string"?{detail:b.detail}:{}}})},warnings:hg(t.warnings,"迁移产物警告"),report:{path:l.path},artifact:{path:"migration-result.zip",size:c.size,sha256:c.sha256},created_at:t.created_at}}async function Uc(e,t={},n=Ao){return fetch(So(`${WIt}${e}`),{...t,headers:ph(t.headers),signal:il(t.signal,n)})}function i5t(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t))return"";const n=t,r=Array.isArray(n.loc)?n.loc.filter(s=>typeof s=="string"||typeof s=="number").join("."):"",i=typeof n.msg=="string"?n.msg:"";return i?r?`${r}: ${i}`:i:""}).filter(Boolean).join(";"):""}async function PU(e,t){var r;const n=await e.text().catch(()=>"");try{const i=Mr(JSON.parse(n),"错误响应");if(Array.isArray(i.detail)){const a=i5t(i.detail);return new Uo(a?`请求参数校验失败:${a}`:t,e.status,"MIGRATION_REQUEST_INVALID",!1,e.statusText,n)}if(typeof i.detail=="string")return new Uo(i.detail,e.status,typeof i.code=="string"?i.code:"MIGRATION_ERROR",i.retryable===!0,e.statusText,n);const s=i.detail&&typeof i.detail=="object"?Mr(i.detail,"错误详情"):i;return new Uo(typeof s.message=="string"?s.message:t,e.status,typeof s.code=="string"?s.code:"MIGRATION_ERROR",s.retryable===!0,e.statusText,n)}catch{const i=((r=e.headers.get("content-type"))==null?void 0:r.split(";",1)[0])||"Content-Type 缺失";return new Uo(`${t}(HTTP ${e.status},Content-Type: ${i})。请检查代理或网关配置。`,e.status,"MIGRATION_ERROR",!1,e.statusText,n)}}async function Id(e,t){if(!e.ok)throw await PU(e,t);if(!(e.headers.get("content-type")??"").includes("application/json"))throw new Uo(`${t}:服务端返回非 JSON 响应(HTTP ${e.status})。请检查代理或网关配置。`,e.status,"MIGRATION_RESPONSE_INVALID",!1,e.statusText);return e.json()}async function s5t(e){const t=Mr(await Id(await Uc("/capabilities",{signal:e}),"读取迁移能力失败"),"迁移能力");if(typeof t.enabled!="boolean"||typeof t.reason!="string"||typeof t.maxUploadBytes!="number"||typeof t.sessionTtlSeconds!="number"||!Array.isArray(t.frameworks))throw new Error("迁移能力格式错误。");const n={enabled:t.enabled,reason:t.reason,maxUploadBytes:t.maxUploadBytes,sessionTtlSeconds:t.sessionTtlSeconds,frameworks:t.frameworks.map(r=>nw(r,"迁移框架"))};if(t.model!==void 0){const r=Mr(t.model,"迁移模型能力");if(typeof r.configured!="boolean"||typeof r.id!="string")throw new Error("迁移模型能力格式错误。");n.model={configured:r.configured,id:r.id}}return n}async function o3(e){const t=Mr(await Id(await Uc("/tasks",{signal:e}),"读取迁移会话失败"),"迁移会话列表");if(!Array.isArray(t.items))throw new Error("迁移会话列表格式错误。");return t.items.map(E0)}async function a5t(e){return E0(await Id(await Uc("/tasks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({taskId:e.taskId,sourceFileName:e.sourceFileName,instruction:e.instruction,...e.modelId?{modelId:e.modelId}:{}}),signal:e.signal},AR),"创建迁移会话失败"))}async function tte(e,t,n){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e)}/source`,{method:"PUT",headers:{"Content-Type":"application/zip"},body:t,signal:n},AR),"上传迁移项目失败"))}async function l3(e,t){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e)}`,{signal:t}),"读取迁移会话失败"))}async function o5t(e,t){return n5t(await Id(await Uc(`/tasks/${encodeURIComponent(e)}/activity`,{signal:t,cache:"no-store"}),"读取迁移执行动态失败"))}async function l5t(e){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e.taskId)}/confirm`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({framework:e.framework,entry:e.entry||null,appName:e.appName,instruction:e.instruction,analysisAttempt:e.analysisAttempt,analysisSha256:e.analysisSha256,inputSha256:e.inputSha256,boundaryConfirmed:!0}),signal:e.signal},AR),"启动迁移失败"))}async function c5t(e){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e.taskId)}/answers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({analysisAttempt:e.analysisAttempt,analysisSha256:e.analysisSha256,inputSha256:e.inputSha256,answers:e.answers}),signal:e.signal},AR),"提交分析补充信息失败"))}async function u5t(e,t){return E0(await Id(await Uc(`/tasks/${encodeURIComponent(e)}/stop`,{method:"POST",signal:t}),"终止迁移失败"))}async function d5t(e,t){return r5t(await Id(await Uc(`/tasks/${encodeURIComponent(e)}/artifact`,{signal:t}),"读取迁移产物失败"))}async function f5t(e,t,n){var s;const r=new URLSearchParams({path:t}),i=await Uc(`/tasks/${encodeURIComponent(e)}/artifact/file?${r}`,{signal:n},es);if(!i.ok)throw await PU(i,"读取迁移产物文件失败");return{blob:await i.blob(),mimeType:((s=i.headers.get("content-type"))==null?void 0:s.split(";",1)[0])||"application/octet-stream"}}function h5t(e,t){var r;return((r=(e.headers.get("content-disposition")||"").match(/filename="([^"]+)"/))==null?void 0:r[1])||t}async function p5t(e,t,n){const r=await Uc(`/tasks/${encodeURIComponent(e)}/download`,{signal:n},es);if(!r.ok)throw await PU(r,"下载迁移产物失败");const i=URL.createObjectURL(await r.blob()),s=document.createElement("a");s.href=i,s.download=h5t(r,`${t}-migrated.zip`),s.click(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3)}function k0({children:e,...t}){return o.jsx("svg",{...t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",children:e})}function m5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"m10 6-6 6 6 6M4 12h16"})})}function g5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M12 3v12m-4-4 4 4 4-4M5 20h14"})})}function sv(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M6 3.5h8l4 4V20H6zM14 3.5v4h4M9 12h6M9 15.5h6"})})}function b5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M12 5v14M5 12h14"})})}function y5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M14.5 4.5c2.3-.9 4.2-.8 5-.6.2.8.3 2.7-.6 5l-5.1 5.1-3.8-3.8zM15.4 8.6h.1M10.3 10.5l-3.8.7-2.1 2.1 5.3.2M13.5 13.7l-.7 3.8-2.1 2.1-.2-5.3M7.2 16.8l-2.8 2.8"})})}function O5t(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"M12 16V4m-4 4 4-4 4 4M5 20h14"})})}function nte(e){return o.jsx(k0,{...e,children:o.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}function x5t(e){return e.flatMap(t=>{if(t.kind==="reasoning"&&t.detail)return[{kind:"thinking",text:t.detail,done:t.status!=="running"}];if(t.kind==="message"&&t.detail)return[{kind:"text",text:t.detail}];if(t.kind==="plan")return[{kind:"plan",title:t.title,summary:t.detail,items:t.plan??[],done:t.status!=="running"}];if(t.kind==="command"){const n=t.tool,r=n!=null&&n.error||typeof(n==null?void 0:n.exitCode)=="number"?{...n.output!==void 0?{output:n.output}:{},...n.error?{error:n.error}:{},...typeof n.exitCode=="number"?{exitCode:n.exitCode}:{}}:n==null?void 0:n.output;return[{kind:"tool",name:(n==null?void 0:n.name)??t.title,args:n==null?void 0:n.input,response:r,done:t.status!=="running",status:t.status,...t.status==="failed"?{defaultOpen:!0}:{}}]}return t.kind==="status"&&t.status!=="completed"?[{kind:"tool",name:t.title,response:t.detail,done:t.status!=="running",status:t.status,...t.status==="failed"?{defaultOpen:!0}:{}}]:[]})}function v5t({baseVersion:e,capabilities:t,loading:n,preparationStage:r,error:i,onCancel:s,onClose:a,onCreate:l}){const c=p.useId(),u=p.useRef(null),d=r!==null,f=p.useRef(d),h=p.useRef(a);return f.current=d,h.current=a,p.useEffect(()=>{const m=document.body.style.overflow,g=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",window.requestAnimationFrame(()=>{var y,O;(O=(y=u.current)==null?void 0:y.querySelector("textarea"))==null||O.focus()});const b=y=>{if(y.key==="Escape"){f.current||h.current();return}if(y.key!=="Tab"||!u.current)return;const O=[...u.current.querySelectorAll('button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')].filter(w=>w.offsetParent!==null);if(O.length===0)return;const v=O[0],x=O[O.length-1];y.shiftKey&&document.activeElement===v?(y.preventDefault(),x.focus()):!y.shiftKey&&document.activeElement===x&&(y.preventDefault(),v.focus())};return window.addEventListener("keydown",b),()=>{document.body.style.overflow=m,window.removeEventListener("keydown",b),g!=null&&g.isConnected&&g.focus()}},[]),kr.createPortal(o.jsx("div",{className:"migration-optimize-backdrop",onMouseDown:m=>{m.target===m.currentTarget&&!d&&a()},children:o.jsxs("section",{ref:u,className:"migration-optimize-dialog",role:"dialog","aria-modal":"true","aria-labelledby":c,"aria-busy":d||void 0,children:[o.jsxs("header",{className:"migration-optimize-dialog__header",children:[o.jsxs("div",{children:[o.jsx("h2",{id:c,children:"优化迁移项目"}),o.jsx("p",{title:e.projectName,children:e.projectName})]}),o.jsx("button",{type:"button",className:"migration-optimize-dialog__close",onClick:a,disabled:d,"aria-label":"关闭优化窗口",title:"关闭",children:o.jsx(j0e,{})})]}),o.jsx("div",{className:"migration-optimize-dialog__body",children:o.jsx(Swe,{capabilities:t,loading:n,preparationStage:r,error:i,onCancel:s,onCreate:async(m,g)=>{await l(m,g,e)},baseVersion:e})})]})}),document.body)}function w5t({capabilities:e,capabilitiesLoading:t,preparationStage:n,optimizationError:r,initialProjectId:i,onOptimize:s,onCancelOptimization:a,onDownload:l,onDeploy:c}){const[u,d]=p.useState();return o.jsxs(o.Fragment,{children:[o.jsxs("main",{className:"migration-main migration-projects-page",children:[o.jsx("header",{className:"migration-main__header",children:o.jsxs("div",{children:[o.jsx("h2",{children:"已迁移项目"}),o.jsx("p",{children:"管理迁移后的源码版本,也可以选择任一版本继续优化。"})]})}),o.jsx("div",{className:"migration-projects-page__content",children:o.jsx(wwe,{origin:"migration",title:"项目与版本",description:"查看、下载、部署或对比源码版本,也可以基于任一版本继续优化。",emptyTitle:"还没有已迁移的项目",emptyDescription:"迁移完成后,源码会自动保存在这里。",capabilities:e,capabilitiesLoading:t,creating:n!==null,initialProjectId:i,onSelectBaseVersion:d,onClearBaseVersion:()=>{},onDownload:l,onDeploy:c})})]}),u?o.jsx(v5t,{baseVersion:u,capabilities:e,loading:t,preparationStage:n,error:r,onCancel:a,onClose:()=>d(void 0),onCreate:s}):null]})}const S5t=20*1024*1024,c3=1200,rte=3e3,E5t=5e3,ite=500,k5t=()=>{},aSe={langchain:"LangChain",langgraph:"LangGraph",adk:"Google ADK",strands:"Strands",agentcore:"AgentCore",dify:"Dify",any:"Any(通用迁移)"},u3=new Set(["langchain","langgraph","adk","strands","agentcore"]);function _5t(e){switch(e){case"awaiting_upload":return"待上传";case"analyzing":return"分析中";case"needs_input":return"待补充";case"analysis_ready":return"待确认";case"migrating":return"迁移中";case"validating":return"校验中";case"packaging":return"打包中";case"succeeded":return"已完成";case"succeeded_with_warnings":return"已完成,有提示";case"partial":return"部分完成";case"failed":return"失败";case"cancelled":return"已终止";case"expired":return"已过期"}}function d3(e){return e.state==="partial"&&e.artifact.previewReady?"迁移产物已生成,但交付不完整,请查看迁移提示。":["succeeded","succeeded_with_warnings"].includes(e.state)&&e.artifact.previewReady?e.state==="succeeded_with_warnings"?"迁移产物已生成,请查看迁移提示。":"迁移产物已生成。":e.message}function T5t(e){switch(e){case"passed":return"产物校验通过";case"failed":return"产物校验未通过";case"degraded":return"产物校验未完成"}}function f3({stage:e}){const t=[{id:"session",label:"创建迁移环境"},{id:"upload",label:"上传项目"},{id:"analysis",label:"分析项目"}],n=t.findIndex(r=>r.id===e);return o.jsx("div",{className:"migration-transfer-progress",role:"status",children:t.map((r,i)=>o.jsxs("div",{className:i=s)return{title:"临时迁移环境已结束",detail:n?"已保存项目仍可查看、下载、部署或优化":"任务记录和临时产物已无法访问"};const a=Math.max(0,s-t),l=Math.floor(a/6e4),c=Math.floor(a%6e4/1e3);return{title:`临时迁移环境将在 ${l} 分 ${c} 秒后结束`,detail:i}}function P5t(e,t){let n=!1;const r=e.map(i=>{var l;if(i.state==="expired")return i;const s=new Date(i.expiresAt).getTime();if(!Number.isFinite(s)||tr.id!==t.id);return[t,...n].sort((r,i)=>{const s=typeof r.createdAt=="number"?r.createdAt*1e3:new Date(r.createdAt).getTime();return(typeof i.createdAt=="number"?i.createdAt*1e3:new Date(i.createdAt).getTime())-s})}function M5t(e,t){return e.find(n=>n.id===t)??null}function L5t(e,t){return e.startsWith("text/")||/(?:json|javascript|xml|yaml)/i.test(e)||/\.(?:py|ts|tsx|js|jsx|json|ya?ml|md|txt|toml|ini|cfg|env|sh|dockerfile)$/i.test(t)}function $5t({analysis:e}){var t;return o.jsxs("div",{className:"migration-analysis",children:[o.jsx(Ou,{text:e.summary,allowRawHtml:!1}),o.jsxs("div",{className:"migration-analysis__facts",children:[e.recommended?o.jsxs("section",{children:[o.jsx("h3",{children:"建议迁移方式"}),o.jsx("strong",{children:aSe[e.recommended.framework]}),o.jsx("p",{children:e.recommended.reason})]}):null,o.jsxs("section",{children:[o.jsx("h3",{children:"迁移范围"}),o.jsx("ul",{children:e.boundary.include.map(n=>o.jsx("li",{children:n},n))})]}),e.boundary.exclude.length>0?o.jsxs("section",{children:[o.jsx("h3",{children:"不在本次范围"}),o.jsx("ul",{children:e.boundary.exclude.map(n=>o.jsx("li",{children:n},n))})]}):null]}),(t=e.frameworks[0])!=null&&t.evidence.length?o.jsxs("details",{className:"migration-analysis__evidence",children:[o.jsx("summary",{children:"查看分析证据"}),o.jsx("ul",{children:e.frameworks.flatMap(n=>n.evidence.map(r=>o.jsxs("li",{children:[o.jsxs("code",{children:[r.path,":",r.line]}),o.jsx("span",{children:r.reason})]},`${n.id}:${r.path}:${r.line}`)))})]}):null,e.warnings.length>0?o.jsx("div",{className:"migration-analysis__warnings",children:e.warnings.map(n=>o.jsx("p",{children:n},n))}):null,e.assumptions.length>0?o.jsxs("details",{className:"migration-analysis__evidence",children:[o.jsx("summary",{children:"查看关键假设"}),o.jsx("ul",{children:e.assumptions.map(n=>o.jsx("li",{children:n},n))})]}):null]})}function B5t({activity:e,loading:t,error:n,analyzing:r}){const i=(e==null?void 0:e.items)??[],s=x5t(i);return o.jsxs("section",{className:"migration-activity","aria-label":"Codex 执行动态",children:[o.jsxs("div",{className:"migration-activity__heading",children:[o.jsx("span",{className:`migration-activity__marker${e!=null&&e.complete?" is-complete":""}`,"aria-hidden":"true"}),o.jsx("strong",{children:"Codex 执行动态"})]}),s.length>0?o.jsx("div",{className:"migration-activity__stream",children:o.jsx(Fj,{blocks:s,onAction:k5t})}):t||!(e!=null&&e.complete)?o.jsx(wn,{children:r?"Codex 正在开始分析…":"Codex 正在开始迁移…"}):null,n?o.jsx("p",{className:"migration-activity__error",role:"status",children:n}):null]})}function Q5t({task:e,artifact:t}){var d;const[n,r]=p.useState(""),[i,s]=p.useState(((d=t.files[0])==null?void 0:d.path)??""),[a,l]=p.useState(null),c=t.files.find(f=>f.path===i)??t.files[0],u=p.useMemo(()=>{const f=n.trim().toLocaleLowerCase();return(f?t.files.filter(m=>m.path.toLocaleLowerCase().includes(f)):t.files).slice(0,ite)},[t.files,n]);return p.useEffect(()=>{if(!c)return;if(c.size>2*1024*1024){l({path:c.path,loading:!1,error:"该文件超过 2 MiB,请下载完整产物后查看。"});return}const f=new AbortController;let h="";return l({path:c.path,loading:!0}),f5t(e.id,c.path,f.signal).then(async({blob:m,mimeType:g})=>{if(!f.signal.aborted){if(g.startsWith("image/")){h=URL.createObjectURL(m),l({path:c.path,loading:!1,imageUrl:h});return}if(L5t(g,c.path)){const b=await m.text();if(f.signal.aborted)return;l({path:c.path,loading:!1,text:b});return}l({path:c.path,loading:!1,error:"该文件不支持在线预览,请下载完整产物后查看。"})}}).catch(m=>{f.signal.aborted||l({path:c.path,loading:!1,error:m instanceof Error?m.message:String(m)})}),()=>{f.abort(),h&&URL.revokeObjectURL(h)}},[c,e.id]),o.jsxs("div",{className:"migration-artifact-browser",children:[o.jsxs("aside",{"aria-label":"迁移产物文件",children:[o.jsxs("label",{className:"migration-artifact-browser__search",children:[o.jsx("span",{className:"sr-only",children:"搜索产物文件"}),o.jsx("input",{value:n,onChange:f=>r(f.currentTarget.value),placeholder:"搜索文件"})]}),o.jsx("div",{className:"migration-artifact-browser__files",children:u.map(f=>o.jsxs("button",{type:"button",className:f.path===(c==null?void 0:c.path)?"is-active":"",onClick:()=>s(f.path),title:f.path,children:[o.jsx(sv,{}),o.jsx("span",{children:f.path}),o.jsx("small",{children:ZA(f.size)})]},f.path))}),t.files.length>u.length?o.jsxs("p",{className:"migration-artifact-browser__limit",children:["仅展示前 ",ite," 项,请搜索具体文件。"]}):null]}),o.jsxs("section",{children:[o.jsxs("header",{children:[o.jsx("span",{title:c==null?void 0:c.path,children:(c==null?void 0:c.path)||"未选择文件"}),c?o.jsx("small",{children:ZA(c.size)}):null]}),o.jsx("div",{className:"migration-artifact-browser__preview",children:c?(a==null?void 0:a.path)!==c.path||a.loading?o.jsx(wn,{children:"正在读取产物文件…"}):a.error?o.jsx("p",{role:"status",children:a.error}):a.imageUrl?o.jsx("img",{src:a.imageUrl,alt:c.path}):o.jsx(gR,{value:a.text??"",path:c.path,readOnly:!0,onChange:()=>{}}):o.jsx("p",{children:"暂无可预览文件。"})})]})]})}function U5t({cloudProvider:e,onBack:t,onAgentAdded:n,onDeploymentTaskChange:r,onDeploymentStarted:i,onDeploymentComplete:s,initialDeployRegion:a=Zr(e),projectCapabilities:l,projectCapabilitiesLoading:c,optimizationPreparationStage:u,optimizationError:d,onOptimizeVersion:f,onCancelOptimization:h,onDownloadSavedVersion:m,onDeploySavedVersion:g,initialPage:b="new",initialProjectId:y=""}){var ka,Ys,_a,Ds,Pi,Cr,yi,bs,Ps,pn,Oi,Ur,ys;const O=p.useRef(null),v=p.useRef(""),x=p.useRef(null),[w,S]=p.useState(null),[E,k]=p.useState([]),[_,T]=p.useState(b),[C,A]=p.useState(y),[R,M]=p.useState(""),[I,$]=p.useState(null),[N,j]=p.useState([]),[B,F]=p.useState(""),[L,H]=p.useState(!1),[z,Q]=p.useState(""),[V,K]=p.useState(0),[se,ge]=p.useState(!1),[ie,q]=p.useState(!0),[G,J]=p.useState(""),[ue,Oe]=p.useState(""),[Qe,je]=p.useState(""),[ze,Ge]=p.useState(!1),[Ae,Be]=p.useState(Date.now()),[he,be]=p.useState(null),[Se,Ee]=p.useState("langchain"),[tt,Ue]=p.useState(""),[re,ce]=p.useState(""),[Me,Ye]=p.useState({}),[Z,_e]=p.useState(null),[rt,Re]=p.useState(""),[We,ct]=p.useState(!1),[kt,qt]=p.useState(0),[Dt,Xe]=p.useState(null),[nt,ft]=p.useState(!1),[xt,Ie]=p.useState(""),[xe,$e]=p.useState(!1),[it,ve]=p.useState(!1),[He,pt]=p.useState(a),[_t,It]=p.useState(),[Kt,en]=p.useState({}),le=M5t(E,R),Xt=(w==null?void 0:w.maxUploadBytes)??S5t,Fe=j5t(Xt),Pt=p.useMemo(()=>new Set((w==null?void 0:w.unsupportedModelIds)??[]),[w==null?void 0:w.unsupportedModelIds]),Ce=p.useMemo(()=>N.filter(pe=>A5t(pe,Pt)),[N,Pt]),gt=(le==null?void 0:le.modelId)||B,Vt=p.useMemo(()=>{var sn;const pe=Ce.map(An=>({value:An.id,label:An.displayName,description:[An.id,An.vendorName,An.lifecycleStatus==="Retiring"?"即将下线":""].filter(Boolean).join(" · ")})),Le=((le==null?void 0:le.modelId)||B||((sn=w==null?void 0:w.model)==null?void 0:sn.id)||"").trim(),At=(le==null?void 0:le.modelId)===Le;return Le&&(At||!Pt.has(Le))&&!pe.some(An=>An.value===Le)&&pe.unshift({value:Le,label:Le,description:"当前默认模型"}),pe},[(ka=w==null?void 0:w.model)==null?void 0:ka.id,Ce,B,le==null?void 0:le.modelId,Pt]),ot=he?Math.max(0,Math.floor((Ae-he)/1e3)):0,ln=Dt==null?void 0:Dt.items[Dt.items.length-1],Kn=[(Dt==null?void 0:Dt.items.length)??0,(ln==null?void 0:ln.id)??"",(ln==null?void 0:ln.status)??"",((Ys=ln==null?void 0:ln.detail)==null?void 0:Ys.length)??0].join(":"),{ref:_r,onScroll:Ve}=Wge(`${(le==null?void 0:le.id)??"new"}:${(le==null?void 0:le.state)??"new"}:${Kn}`);async function et(pe,Le=!0,At){try{const sn=await l3(pe,At);return At!=null&&At.aborted?null:(k(An=>ef(An,sn)),je(""),Ge(!1),sn)}catch(sn){return At!=null&&At.aborted||Le&&(je(sn instanceof Error?sn.message:String(sn)),Ge(sn instanceof Uo&&sn.retryable)),null}}async function mn(pe){try{const Le=await o3(pe);if(pe!=null&&pe.aborted)return;k(Le),je(""),Ge(!1)}catch(Le){if(pe!=null&&pe.aborted)return;je(Le instanceof Error?Le.message:String(Le)),Ge(Le instanceof Uo&&Le.retryable)}}p.useEffect(()=>{const pe=new AbortController;return q(!0),Oe(""),Promise.all([s5t(pe.signal),o3(pe.signal)]).then(([Le,At])=>{pe.signal.aborted||(S(Le),k(At))}).catch(Le=>{pe.signal.aborted||Oe(Le instanceof Error?Le.message:String(Le))}).finally(()=>{pe.signal.aborted||q(!1)}),()=>pe.abort()},[]),p.useEffect(()=>{const pe=new AbortController;return H(!0),Q(""),Q1({signal:pe.signal,refresh:V>0}).then(Le=>{pe.signal.aborted||j(Le.models)}).catch(Le=>{pe.signal.aborted||Q(Le instanceof Error?Le.message:"加载模型列表失败")}).finally(()=>{pe.signal.aborted||H(!1)}),()=>pe.abort()},[e,V]),p.useEffect(()=>{var At,sn;if(!w||B)return;const pe=((At=w.model)==null?void 0:At.id.trim())||"",Le=pe&&!Pt.has(pe)?pe:((sn=Ce[0])==null?void 0:sn.id)||"";Le&&F(Le)},[w,Ce,B,Pt]),p.useEffect(()=>()=>{var pe;(pe=x.current)==null||pe.abort(),x.current=null},[]),p.useEffect(()=>{const pe=window.setInterval(()=>{const Le=Date.now();Be(Le),k(At=>P5t(At,Le))},1e3);return()=>window.clearInterval(pe)},[]),p.useEffect(()=>{if(!E.some(At=>Pm(At.state)))return;const pe=new AbortController,Le=window.setInterval(()=>{o3(pe.signal).then(At=>{pe.signal.aborted||k(At),je(""),Ge(!1)}).catch(At=>{pe.signal.aborted||(je(At instanceof Error?At.message:String(At)),Ge(At instanceof Uo&&At.retryable),At instanceof Uo&&At.retryable||window.clearInterval(Le))})},E5t);return()=>{pe.abort(),window.clearInterval(Le)}},[E.some(pe=>Pm(pe.state))]),p.useEffect(()=>{var sn;if(!le||!Pm(le.state)&&((sn=le.persistence)==null?void 0:sn.state)!=="saving")return;const pe=new AbortController;let Le;const At=async()=>{var An;try{const $r=await l3(le.id,pe.signal);if(pe.signal.aborted)return;k(Gr=>ef(Gr,$r)),je(""),Ge(!1),(Pm($r.state)||((An=$r.persistence)==null?void 0:An.state)==="saving")&&(Le=window.setTimeout(()=>void At(),c3))}catch($r){if(pe.signal.aborted)return;je($r instanceof Error?$r.message:String($r)),Ge($r instanceof Uo&&$r.retryable),$r instanceof Uo&&$r.retryable&&(Le=window.setTimeout(()=>void At(),c3))}};return Le=window.setTimeout(()=>void At(),c3),()=>{pe.abort(),Le!==void 0&&window.clearTimeout(Le)}},[le==null?void 0:le.id,le==null?void 0:le.state,(_a=le==null?void 0:le.persistence)==null?void 0:_a.state]),p.useEffect(()=>{const pe=_r.current;pe&&(pe.scrollTop=pe.scrollHeight,Ve())},[R,_r,Ve]),p.useEffect(()=>{Xe(null),Ie(""),ft(!1)},[le==null?void 0:le.id]),p.useEffect(()=>{if(!le||!ste(le))return;const pe=new AbortController;let Le;const At=async()=>{ft(!0);try{const sn=await o5t(le.id,pe.signal);if(pe.signal.aborted)return;Xe(sn),Ie(""),!sn.complete&&Pm(le.state)&&(Le=window.setTimeout(()=>void At(),rte))}catch(sn){if(pe.signal.aborted)return;Ie("暂时无法读取 Codex 执行动态,不影响当前任务。"),Pm(le.state)&&sn instanceof Uo&&sn.retryable&&(Le=window.setTimeout(()=>void At(),rte))}finally{pe.signal.aborted||ft(!1)}};return At(),()=>{pe.abort(),Le!==void 0&&window.clearTimeout(Le)}},[le==null?void 0:le.id,le==null?void 0:le.state,(Ds=le==null?void 0:le.analysisRef)==null?void 0:Ds.sha256,(Pi=le==null?void 0:le.confirmation)==null?void 0:Pi.framework]),p.useEffect(()=>{if(!(le!=null&&le.analysis)||!le.analysisRef||!["needs_input","analysis_ready"].includes(le.state))return;const pe=`${le.id}:${le.analysisRef.attempt}:${le.analysisRef.sha256}`;if(v.current===pe||(v.current=pe,Ye({}),le.state!=="analysis_ready"))return;const Le=le.analysis.recommended;Le&&(Ee(Le.framework),Ue(Le.entry||""),ce(ate(le.sourceFileName)))},[le]),p.useEffect(()=>{if(_e(null),Re(""),ct(!1),ve(!1),en({}),!(le!=null&&le.artifact.previewReady))return;const pe=new AbortController;return d5t(le.id,pe.signal).then(Le=>{pe.signal.aborted||_e(Le)}).catch(Le=>{pe.signal.aborted||(Re(Le instanceof Error?Le.message:String(Le)),ct(Le instanceof Uo&&Le.retryable))}),()=>pe.abort()},[le==null?void 0:le.id,le==null?void 0:le.artifact.previewReady,kt]),p.useEffect(()=>{if(!Z)return;const pe=aRt(Z,e);en(Le=>{var sn;const At={...Le};for(const[An,$r]of Object.entries(pe))(sn=At[An])!=null&&sn.trim()||(At[An]=$r);return At})},[Z,e]);function Mt(pe){if(!x.current&&(Oe(""),!!pe)){if(!pe.name.toLowerCase().endsWith(".zip")){$(null),Oe("请选择 .zip 格式的本地项目文件。");return}if(pe.name.length>255||/[/\\\u0000-\u001f]/.test(pe.name)){$(null),Oe("ZIP 文件名无效,请重命名后重新选择。");return}if(pe.size>Xt){$(null),Oe(`项目 ZIP 不能超过 ${Fe}。`);return}if(pe.size===0){$(null),Oe("项目 ZIP 不能为空。");return}$(pe)}}function ar(pe){var At;const Le=(At=pe.currentTarget.files)==null?void 0:At[0];pe.currentTarget.value="",Mt(Le)}async function pr(){if(!I||G||x.current)return;const pe=new AbortController;x.current=pe;const Le=()=>x.current===pe&&!pe.signal.aborted,At=`migration-v1-${crypto.randomUUID().replace(/-/g,"")}`;J("create"),be(Date.now()),Oe("");try{const sn=await a5t({taskId:At,sourceFileName:I.name,instruction:"",modelId:B||void 0,signal:pe.signal});if(!Le())return;k($r=>ef($r,sn)),M(sn.id),J("upload"),be(null);const An=await tte(sn.id,I,pe.signal);if(!Le())return;k($r=>ef($r,An)),$(null)}catch(sn){if(!Le())return;const An=await et(At,!1,pe.signal);if(!Le())return;if(An){if(M(An.id),An.state!=="awaiting_upload"){$(null);return}}else if(await mn(pe.signal),!Le())return;Oe(sn instanceof Error?sn.message:String(sn))}finally{x.current===pe&&(x.current=null,be(null),J(""))}}async function Gn(){if(!(le!=null&&le.canUpload)||!I||G||x.current)return;const pe=new AbortController;x.current=pe;const Le=()=>x.current===pe&&!pe.signal.aborted;J("upload"),Oe("");try{const At=await tte(le.id,I,pe.signal);if(!Le())return;k(sn=>ef(sn,At)),$(null)}catch(At){if(!Le())return;const sn=await et(le.id,!0,pe.signal);if(!Le())return;if(sn&&sn.state!=="awaiting_upload"){$(null);return}Oe(At instanceof Error?At.message:String(At))}finally{x.current===pe&&(x.current=null,J(""))}}const zn=p.useMemo(()=>{var pe;return(((pe=le==null?void 0:le.analysis)==null?void 0:pe.entries)??[]).filter(Le=>Le.framework===Se).map(Le=>({value:Le.value,label:Le.value,description:Le.evidence}))},[Se,(Cr=le==null?void 0:le.analysis)==null?void 0:Cr.entries]),Pr=(((yi=le==null?void 0:le.analysis)==null?void 0:yi.questions)??[]).every(pe=>{var Le;return!pe.required||!!((Le=Me[pe.id])!=null&&Le.trim())}),Lr=N5t(re),Kr=!!(le!=null&&le.canConfirm&&le.analysisRef&&!G&&!Lr&&(!u3.has(Se)||tt.trim())),qr=!!(le!=null&&le.canAnswer&&le.analysisRef&&!G&&Pr);async function mr(){if(!(!(le!=null&&le.analysisRef)||!qr)){J("answer"),Oe("");try{const pe=await c5t({taskId:le.id,analysisAttempt:le.analysisRef.attempt,analysisSha256:le.analysisRef.sha256,inputSha256:le.analysisRef.inputSha256,answers:Me});k(Le=>ef(Le,pe))}catch(pe){const Le=await et(le.id);if(Le&&Le.state!=="needs_input")return;Oe(pe instanceof Error?pe.message:String(pe))}finally{J("")}}}async function Xr(){if(!(!(le!=null&&le.analysisRef)||!Kr)){J("confirm"),Oe("");try{const pe=await l5t({taskId:le.id,framework:Se,entry:u3.has(Se)?tt.trim():void 0,appName:re.trim(),instruction:"",analysisAttempt:le.analysisRef.attempt,analysisSha256:le.analysisRef.sha256,inputSha256:le.analysisRef.inputSha256});k(Le=>ef(Le,pe))}catch(pe){const Le=await et(le.id);if(Le&&Le.state!=="analysis_ready")return;Oe(pe instanceof Error?pe.message:String(pe))}finally{J("")}}}async function Tr(){if(!(!(le!=null&&le.canStop)||G)){J("stop"),Oe("");try{const pe=await u5t(le.id);k(Le=>ef(Le,pe)),$e(!1)}catch(pe){const Le=await et(le.id);if(Le&&!Le.canStop){$e(!1);return}Oe(pe instanceof Error?pe.message:String(pe))}finally{J("")}}}async function oi(){if(!(!(le!=null&&le.artifact.downloadReady)||G)){J("download"),Oe("");try{await p5t(le.id,IT(le.sourceFileName))}catch(pe){Oe(pe instanceof Error?pe.message:String(pe))}finally{J("")}}}function Ii(){var pe,Le;T("new"),A(""),M(""),$(null),Oe(""),je(""),Ge(!1),_e(null),Re(""),ct(!1),ve(!1),$e(!1),F(((pe=w==null?void 0:w.model)==null?void 0:pe.id.trim())||((Le=Ce[0])==null?void 0:Le.id)||"")}const bi=Z?{name:((bs=le==null?void 0:le.confirmation)==null?void 0:bs.app_name)||ate((le==null?void 0:le.sourceFileName)||"migration.zip"),files:[{path:"migration-result.json",content:`${JSON.stringify(Z,null,2)}
`}]}:null,Jr=Z?Z.environment.required.filter(Tg).filter(NS).map(pe=>({key:pe,label:pe})):[],Di=Z?[...Z.environment.required.filter(Tg).filter(pe=>!NS(pe)).map(pe=>({key:pe,required:!0,comment:pe,placeholder:`请输入 ${pe}`})),...Z.environment.optional.filter(Tg).map(pe=>({key:pe,required:!1,comment:pe,placeholder:`可选:${pe}`}))]:[];async function rs(pe,Le,At){if(!le||!Z)throw new Error("迁移产物尚未准备完成。");const sn=_t&&_t.mode!=="public"?{mode:_t.mode,vpc_id:_t.vpcId,subnet_ids:_t.subnetIds,enable_shared_internet_access:_t.enableSharedInternetAccess}:void 0;return z1(pe.name,pe.files,{region:He,projectName:"default",network:sn},{...At,migrationTaskId:le.id,onStage:Le})}if(it&&bi&&le&&Z)return o.jsx("div",{className:"migration-deployment",children:o.jsx(_R,{cloudProvider:e,project:bi,agentName:bi.name,onDeploy:rs,onAgentAdded:n,onDeploymentTaskChange:r,onDeploymentStarted:i,onDeploymentComplete:s,network:_t,onNetworkChange:It,deployRegion:He,onDeployRegionChange:pt,deploymentEnv:Di,requiredSecretEnv:Jr,deploymentEnvValues:Kt,onDeploymentEnvChange:(pe,Le)=>en(At=>({...At,[pe]:Le})),deploymentTelemetry:{source:"migration",createMode:"migration",aiAssisted:!0},onBack:()=>ve(!1),backLabel:"返回迁移结果",deploymentPrimaryPane:o.jsxs("section",{className:"migration-deployment-summary",children:[o.jsx("strong",{children:"迁移产物"}),o.jsx("span",{children:le.sourceFileName}),o.jsxs("dl",{children:[o.jsxs("div",{children:[o.jsx("dt",{children:"迁移方式"}),o.jsx("dd",{children:Z.migration.framework})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"启动文件"}),o.jsx("dd",{children:Z.startup.module})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"文件数"}),o.jsx("dd",{children:Z.files.length})]})]})]})})});const oa=I,Qr=G==="create"||G==="upload",Ws=!le||le.canUpload,is=le?D5t(le,Ae):null;return o.jsxs(o.Fragment,{children:[o.jsxs("section",{className:"migration-workspace",children:[o.jsxs("aside",{className:"migration-history",children:[o.jsxs("header",{children:[o.jsx("button",{type:"button",className:"migration-icon-button",onClick:t,"aria-label":"返回添加 Agent",title:"返回",children:o.jsx(m5t,{})}),o.jsx("h1",{children:"从存量迁移"})]}),o.jsxs("button",{type:"button",className:"migration-new-button","aria-current":_==="new"&&!le?"page":void 0,onClick:Ii,disabled:Qr,children:[o.jsx(b5t,{}),o.jsx("span",{children:"新建迁移"})]}),o.jsxs("button",{type:"button",className:`migration-new-button${_==="projects"?" is-active":""}`,"aria-current":_==="projects"?"page":void 0,onClick:()=>T("projects"),disabled:Qr,children:[o.jsx(sv,{}),o.jsx("span",{children:"已迁移项目"})]}),o.jsx("div",{className:"migration-history__label",children:"最近迁移"}),o.jsx("nav",{"aria-label":"迁移会话",children:ie?o.jsx(wn,{children:"正在读取迁移会话…"}):E.length===0?o.jsx("p",{className:"migration-history__empty",children:"暂无迁移会话"}):E.map(pe=>o.jsxs("button",{type:"button",className:pe.id===R?"is-active":"","aria-current":_==="new"&&pe.id===R?"page":void 0,disabled:Qr,onClick:()=>{T("new"),M(pe.id),Oe(""),je(""),Ge(!1)},children:[o.jsx("span",{children:IT(pe.sourceFileName)}),o.jsxs("small",{children:[o.jsx("span",{"data-state":pe.state,children:_5t(pe.state)}),o.jsx("time",{children:I5t(pe.createdAt)})]})]},pe.id))})]}),_==="projects"?o.jsx(w5t,{capabilities:l,capabilitiesLoading:c,preparationStage:u,optimizationError:d,initialProjectId:C,onOptimize:f,onCancelOptimization:h,onDownload:m,onDeploy:g}):o.jsxs("main",{className:"migration-main",children:[o.jsxs("header",{className:"migration-main__header",children:[o.jsxs("div",{children:[o.jsx("h2",{children:le?IT(le.sourceFileName):"迁移存量 Agent 项目"}),o.jsx("p",{children:le?d3(le):"上传本地项目 ZIP,Codex 将先进行只读分析,再由你确认迁移方式。"})]}),le?o.jsxs("div",{className:"migration-main__header-actions",children:[le!=null&&le.canStop?o.jsx("button",{type:"button",className:"migration-stop-button",onClick:()=>$e(!0),disabled:!!G,children:G==="stop"?"正在终止…":"终止迁移"}):null,is?o.jsxs("div",{className:"migration-ttl","aria-live":"off",children:[o.jsx("strong",{children:is.title}),o.jsx("small",{children:is.detail})]}):null]}):null]}),o.jsxs("div",{className:"migration-conversation",role:"log","aria-live":"polite",ref:_r,onScroll:Ve,children:[!(w!=null&&w.enabled)&&!ie?o.jsxs("div",{className:"migration-system-state is-error",role:"alert",children:[o.jsx("strong",{children:"迁移能力暂不可用"}),o.jsx("p",{children:(w==null?void 0:w.reason)||"Dev Sandbox 暂不可用,请联系管理员检查配置。"})]}):null,le?o.jsxs(o.Fragment,{children:[o.jsx("article",{className:"migration-turn is-user",children:o.jsxs("div",{className:"migration-user-message",children:[o.jsxs("span",{className:"migration-file-chip",children:[o.jsx(sv,{}),o.jsx("span",{title:le.sourceFileName,children:le.sourceFileName})]}),le.instruction?o.jsx("p",{children:le.instruction}):null]})}),o.jsxs("article",{className:"migration-turn is-assistant",children:[o.jsx("div",{className:"migration-assistant-mark",children:"AI"}),o.jsxs("div",{className:"migration-assistant-content",children:[G==="upload"?o.jsxs(o.Fragment,{children:[o.jsx(f3,{stage:"upload"}),o.jsx("p",{className:"migration-running-note",children:"ZIP 上传完成后将自动开始只读分析。"})]}):le.state==="analyzing"?o.jsxs(o.Fragment,{children:[o.jsx(f3,{stage:"analysis"}),o.jsx("p",{className:"migration-running-note",children:"Codex 正在识别框架、入口和迁移边界,不会执行实际迁移。"})]}):Pm(le.state)?o.jsxs(o.Fragment,{children:[o.jsx(wn,{children:d3(le)}),o.jsx("p",{className:"migration-running-note",children:"迁移执行中不能修改附件或迁移方式。你可以等待当前任务结束,或主动终止。"})]}):le.state==="needs_input"&&le.analysis?o.jsxs(o.Fragment,{children:[o.jsx("p",{children:le.analysis.summary}),o.jsx("p",{children:"只读分析已暂停。请仅回答下面列出的问题,提交后会在同一 迁移环境中重新分析,不会开始实际迁移。"}),(Ps=le.analysis.frameworks[0])!=null&&Ps.evidence.length?o.jsxs("details",{className:"migration-analysis__evidence",children:[o.jsx("summary",{children:"查看源码证据"}),o.jsx("ul",{children:le.analysis.frameworks.flatMap(pe=>pe.evidence.map(Le=>o.jsxs("li",{children:[o.jsxs("code",{children:[Le.path,":",Le.line]}),o.jsx("span",{children:Le.reason})]},`${pe.id}:${Le.path}:${Le.line}`)))})]}):null]}):le.state==="analysis_ready"&&le.analysis?o.jsxs(o.Fragment,{children:[o.jsx("p",{children:"只读分析已完成。请检查建议,并确认最终迁移方式。"}),o.jsx($5t,{analysis:le.analysis})]}):le.state==="awaiting_upload"?o.jsx("p",{children:"迁移环境已创建,请重新选择本地 ZIP 继续上传。"}):le.state==="expired"?o.jsxs("div",{className:"migration-expired",children:[o.jsx("strong",{children:"迁移环境已过期"}),o.jsx("p",{children:"迁移内容和产物已无法预览、下载或部署。如已完成 Runtime 部署,可返回智能体页面继续使用。"})]}):le.state==="failed"?((pn=le.error)==null?void 0:pn.code)==="MIGRATION_ANALYSIS_UNSUPPORTED"&&le.analysis?o.jsxs("div",{className:"migration-system-state is-error",children:[o.jsx("strong",{children:"当前 ZIP 暂时无法迁移"}),o.jsx(Ou,{text:le.analysis.summary,allowRawHtml:!1}),le.analysis.warnings.length>0?o.jsx("ul",{children:le.analysis.warnings.map(pe=>o.jsx("li",{children:pe},pe))}):null,o.jsx("p",{children:"请按提示整理项目后,新建迁移并重新上传。"})]}):o.jsxs("div",{className:"migration-system-state is-error",children:[o.jsx("strong",{children:"迁移未完成"}),o.jsx("p",{children:le.message})]}):le.state==="cancelled"?o.jsx("p",{children:"当前迁移已终止。你可以新建迁移并重新上传项目。"}):o.jsx("p",{children:d3(le)}),ste(le)&&(nt||Dt!=null&&Dt.available||xt)?o.jsx(B5t,{activity:Dt,loading:nt,error:xt,analyzing:le.state==="analyzing"}):null]})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("article",{className:"migration-turn is-assistant",children:[o.jsx("div",{className:"migration-assistant-mark",children:"AI"}),o.jsxs("div",{children:[o.jsx("p",{children:"请提供本地项目 ZIP。上传后我会识别框架、入口和迁移边界, 并在执行实际迁移前请你确认迁移方式。"}),o.jsxs("small",{children:["仅支持本地 ZIP,最大 ",Fe,";迁移环境从创建起保留 1 小时。"]})]})]}),G==="create"&&I?o.jsxs(o.Fragment,{children:[o.jsx("article",{className:"migration-turn is-user",children:o.jsx("div",{className:"migration-user-message",children:o.jsxs("span",{className:"migration-file-chip",children:[o.jsx(sv,{}),o.jsx("span",{title:I.name,children:I.name})]})})}),o.jsxs("article",{className:"migration-turn is-assistant",children:[o.jsx("div",{className:"migration-assistant-mark",children:"AI"}),o.jsxs("div",{className:"migration-assistant-content",children:[o.jsx(f3,{stage:"session"}),o.jsx(wn,{as:"strong",children:"正在创建 Dev Sandbox"}),o.jsx("p",{className:"migration-running-note",children:"正在初始化迁移工作目录,并检查 AgentKit CLI、Codex 和迁移能力。环境就绪后将自动上传项目。"}),o.jsxs("small",{children:["已等待 ",R5t(ot)]})]})]})]}):null]}),(le==null?void 0:le.state)==="needs_input"&&le.analysis?o.jsxs("section",{className:"migration-confirmation","aria-label":"补充项目分析信息",children:[o.jsxs("div",{className:"migration-confirmation__heading",children:[o.jsx("strong",{children:"补充分析所需信息"}),o.jsx("span",{children:"附件保持锁定,提交后仅继续只读分析"})]}),le.analysis.questions.map(pe=>o.jsxs("label",{className:"migration-field",children:[o.jsxs("span",{children:[pe.prompt,pe.required?o.jsx("b",{"aria-hidden":"true",children:"*"}):null]}),o.jsx("textarea",{value:Me[pe.id]||"",maxLength:4e3,required:pe.required,"aria-required":pe.required,onChange:Le=>{const At=Le.currentTarget.value;Ye(sn=>({...sn,[pe.id]:At}))},disabled:!!G})]},pe.id)),o.jsx("div",{className:"migration-confirmation__actions",children:o.jsx("button",{type:"button",className:"migration-primary-button",onClick:()=>void mr(),disabled:!qr,children:G==="answer"?"正在继续分析…":"提交并继续分析"})})]}):null,(le==null?void 0:le.state)==="analysis_ready"&&le.analysis?o.jsxs("section",{className:"migration-confirmation","aria-label":"确认迁移方式",children:[o.jsxs("div",{className:"migration-confirmation__heading",children:[o.jsx("strong",{children:"确认迁移方式"}),o.jsx("span",{children:"确认后才会执行实际迁移"})]}),o.jsxs("div",{className:"migration-confirmation__grid",children:[o.jsx(Hf,{label:"迁移方式",value:Se,options:((w==null?void 0:w.frameworks)??[]).map(pe=>({value:pe,label:aSe[pe]})),onChange:pe=>{var sn;const Le=pe;Ee(Le);const At=(sn=le.analysis)==null?void 0:sn.entries.find(An=>An.framework===Le);Ue((At==null?void 0:At.value)||"")},placeholder:"选择迁移方式",disabled:!!G}),o.jsxs("label",{className:"migration-field",children:[o.jsxs("span",{children:["Agent 名称",o.jsx("b",{"aria-hidden":"true",children:"*"})]}),o.jsx("input",{value:re,onChange:pe=>ce(pe.currentTarget.value),maxLength:63,required:!0,disabled:!!G,"aria-invalid":!!Lr,"aria-required":"true"}),Lr?o.jsx("small",{role:"alert",children:Lr}):null]}),u3.has(Se)?zn.length>0?o.jsx(Hf,{label:"项目入口",value:tt,options:zn,onChange:Ue,placeholder:"选择项目入口",disabled:!!G}):o.jsxs("label",{className:"migration-field",children:[o.jsxs("span",{children:["项目入口",o.jsx("b",{"aria-hidden":"true",children:"*"})]}),o.jsx("input",{value:tt,onChange:pe=>Ue(pe.currentTarget.value),placeholder:"例如 agent.py:agent",maxLength:512,required:!0,disabled:!!G,"aria-required":"true"})]}):null]}),o.jsx("p",{className:"migration-running-note",children:"点击“确认并开始迁移”即确认上述迁移范围、排除项和关键假设。"}),o.jsx("div",{className:"migration-confirmation__actions",children:o.jsx("button",{type:"button",className:"migration-primary-button",onClick:()=>void Xr(),disabled:!Kr,children:G==="confirm"?"正在启动迁移…":"确认并开始迁移"})})]}):null,le&&C5t(le.state)&&le.artifact.previewReady?o.jsxs("section",{className:"migration-result",children:[o.jsxs("header",{children:[o.jsxs("div",{children:[o.jsx("strong",{children:"迁移产物"}),o.jsx("span",{children:((Oi=le.persistence)==null?void 0:Oi.state)==="saved"?"源码已保存,可继续查看、下载、部署或优化。":((Ur=le.persistence)==null?void 0:Ur.state)==="saving"?"产物已生成,正在保存源码版本。":le.artifact.deployReady?"产物可预览、下载和部署,正在等待源码保存状态。":"产物可预览和下载,但当前交付状态不支持部署。"})]}),o.jsxs("div",{className:"migration-result__actions",children:[((ys=le.persistence)==null?void 0:ys.state)==="saved"?o.jsx("button",{type:"button",onClick:()=>{var pe;A(((pe=le.persistence)==null?void 0:pe.projectId)??""),T("projects")},children:o.jsx("span",{children:"查看已迁移项目"})}):null,o.jsxs("button",{type:"button",onClick:()=>void oi(),disabled:!le.artifact.downloadReady||!!G,children:[o.jsx(g5t,{}),o.jsx("span",{children:G==="download"?"下载中…":"下载 ZIP"})]}),o.jsxs("button",{type:"button",className:"is-primary",onClick:()=>ve(!0),disabled:!le.artifact.deployReady||!Z,title:le.artifact.deployReady?"部署迁移产物":"当前交付状态不支持部署",children:[o.jsx(y5t,{}),o.jsx("span",{children:"部署到 Runtime"})]})]})]}),le.persistence&&["failed","unavailable"].includes(le.persistence.state)?o.jsx("div",{className:"migration-system-state is-error",role:"alert",children:o.jsx("p",{children:le.persistence.message})}):null,rt?o.jsxs("div",{className:"migration-system-state is-error",role:"alert",children:[o.jsx("p",{children:rt}),We?o.jsx("button",{type:"button",className:"migration-retry-button",onClick:()=>{Re(""),ct(!1),qt(pe=>pe+1)},children:"重新读取"}):null]}):Z?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"migration-result__summary",children:[o.jsxs("span",{children:[Z.files.length," 个文件"]}),o.jsxs("span",{children:["CLI ",Z.cli.version]}),o.jsxs("span",{children:["启动文件 ",Z.startup.module]}),o.jsx("span",{children:T5t(Z.verification.status)})]}),o.jsx(Q5t,{task:le,artifact:Z})]}):o.jsx(wn,{children:"正在读取迁移产物…"})]}):null,Qe?o.jsxs("div",{className:"migration-inline-error",role:"alert",children:[o.jsx("span",{children:Qe}),ze?o.jsx("button",{type:"button",onClick:()=>{le&&(je(""),Ge(!1),l3(le.id).then(pe=>k(Le=>ef(Le,pe))).catch(pe=>{je(pe instanceof Error?pe.message:String(pe)),Ge(pe instanceof Uo&&pe.retryable)}))},children:"刷新状态"}):null]}):null,ue?o.jsxs("div",{className:"migration-inline-error",role:"alert",children:[o.jsx("span",{children:ue}),o.jsx("button",{type:"button",onClick:()=>Oe(""),"aria-label":"关闭错误提示",children:o.jsx(nte,{})})]}):null]}),Ws&&(w!=null&&w.enabled)?o.jsxs("div",{className:"migration-composer",children:[o.jsxs("div",{className:`migration-composer__box${se?" is-dragging":""}`,onDragEnter:pe=>{pe.preventDefault(),!Qr&&ge(!0)},onDragOver:pe=>{pe.preventDefault(),pe.dataTransfer.dropEffect=Qr?"none":"copy"},onDragLeave:pe=>{pe.currentTarget.contains(pe.relatedTarget)||ge(!1)},onDrop:pe=>{var Le;pe.preventDefault(),ge(!1),!Qr&&Mt((Le=pe.dataTransfer.files)==null?void 0:Le[0])},children:[o.jsx("div",{className:"migration-composer__content",children:oa?o.jsxs("div",{className:"migration-composer__file",children:[o.jsx(sv,{}),o.jsx("span",{children:oa.name}),o.jsx("small",{children:ZA(oa.size)}),o.jsx("button",{type:"button",onClick:()=>$(null),"aria-label":"移除项目 ZIP",disabled:Qr,children:o.jsx(nte,{})})]}):o.jsx("p",{children:le?"重新选择项目 ZIP":"选择或拖入本地项目 ZIP"})}),o.jsxs("div",{className:"migration-composer__actions",children:[o.jsxs("div",{className:"migration-composer__tools",children:[o.jsxs("button",{type:"button",className:"migration-attach-button",onClick:()=>{var pe;return(pe=O.current)==null?void 0:pe.click()},disabled:Qr,children:[o.jsx(O5t,{}),o.jsx("span",{children:I?"重新选择":"选择 ZIP"})]}),o.jsx("div",{className:"migration-composer__model-select",children:o.jsx(Hf,{label:"模型",hideLabel:!0,value:gt,options:Vt,onChange:F,placeholder:"选择模型",searchable:!0,loading:L,error:z,disabled:Qr||!!le,onRetry:()=>K(pe=>pe+1)})})]}),o.jsx("button",{type:"button",className:"migration-confirm-upload-button",onClick:()=>void(le?Gn():pr()),disabled:!I||Qr,children:le?"继续上传":"开始迁移"})]}),o.jsx("input",{ref:O,type:"file",accept:".zip,application/zip",onChange:ar,"aria-label":"选择本地项目 ZIP",disabled:Qr})]}),o.jsx("p",{children:"临时迁移环境从创建完成起保留 1 小时;保存成功的源码版本不受影响。"})]}):null]})]}),xe&&le?o.jsx(ql,{title:"终止当前迁移?",description:"终止后,当前分析或迁移进程将停止,已执行的步骤不会继续。",confirmLabel:G==="stop"?"正在终止…":"终止迁移",variant:"danger",busy:G==="stop",onCancel:()=>$e(!1),onConfirm:()=>void Tr()}):null]})}const oSe=1,F5t="MODEL_AGENT_API_KEY";function KA(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function z5t(e){return KA(e)&&typeof e.id=="string"&&typeof e.updatedAt=="number"&&(e.creationMode===void 0||e.creationMode==="quick"||e.creationMode==="traditional")&&KA(e.draft)}function h3(e){return e.creationMode?e.creationMode:e.draft.dynamicAgentDelegation===!0?"quick":"traditional"}function NR(e){return`veadk.agentDrafts.${encodeURIComponent(e)}`}function u$(e,t,n){const r=e.deployment,i=r==null?void 0:r.envValues,s=r?{...r,...i?{envValues:Object.fromEntries(Object.entries(i).filter(([a])=>a!==F5t&&!t.has(a)))}:{}}:void 0;return{...e,...e.mcpTools?{mcpTools:e.mcpTools.map(a=>{if(!a.authTokenEnv||!n.has(a.authTokenEnv))return a;const l={...a};return delete l.authTokenEnv,l})}:{},...s?{deployment:s}:{},subAgents:e.subAgents.map(a=>u$(a,t,n)),...e.workflow?{workflow:{...e.workflow,nodes:e.workflow.nodes.map(a=>({...a,agent:u$(a.agent,t,n)}))}}:{}}}function d$(e,t){return{...e,...e.mcpTools?{mcpTools:e.mcpTools.map((n,r)=>{var i,s;return{...n,...((s=(i=t.mcpTools)==null?void 0:i[r])==null?void 0:s.credentialConfigured)===!0?{credentialConfigured:!0}:{}}})}:{},subAgents:e.subAgents.map((n,r)=>d$(n,t.subAgents[r]??n)),...e.workflow?{workflow:{...e.workflow,nodes:e.workflow.nodes.map((n,r)=>{var i,s;return{...n,agent:d$(n.agent,((s=(i=t.workflow)==null?void 0:i.nodes[r])==null?void 0:s.agent)??n.agent)}})}}:{}}}function V5t(e){const t=ZE(e),n=d$(t.draft,e);return u$(n,new Set(Xwe(t.draft)),new Set(Object.keys(t.envValues)))}function lSe(e){return{...e,draft:V5t(e.draft)}}function H5t(e){const t=Array.isArray(e)?e:KA(e)&&e.version===oSe?e.drafts:void 0;if(!Array.isArray(t)||!t.every(z5t))throw KA(e)&&typeof e.version=="number"?new Error("本机草稿版本暂不受支持,请升级 Studio 后重试。"):new Error("本机草稿数据格式无效。");return t.map(lSe)}function q5t(e,t){if(!t)return[];const n=e.getItem(NR(t));if(!n)return[];try{return H5t(JSON.parse(n))}catch(r){throw r instanceof Error&&r.message.startsWith("本机草稿")?r:new Error("无法读取本机草稿,浏览器中的草稿数据可能已损坏。")}}function ote(e,t,n){if(!t)return;const r={version:oSe,drafts:n.map(lSe)};try{e.setItem(NR(t),JSON.stringify(r))}catch(i){throw i instanceof DOMException&&(i.name==="QuotaExceededError"||i.name==="NS_ERROR_DOM_QUOTA_REACHED")?new Error("浏览器存储空间不足,草稿未保存。请删除不需要的草稿或清理此站点的浏览器存储后重试。"):new Error("浏览器拒绝保存草稿,请检查站点存储权限后重试。")}}const X5t=/[;;]/;function G5t(e){const t=new Set;for(const n of e)for(const r of n.split(X5t)){const i=r.trim();i&&t.add(i)}return[...t]}function W5t(e){return[]}const Y5t=3*60*1e3,Z5t=3e3,K5t=10*60*1e3,J5t=45e3,JA="veadk.studio.pending-update",MU="veadk.studio.update-handoff",cSe={permissions:"预检 OTA 所需权限",resolving:"读取目标版本信息",downloading:"下载并校验完整更新包",preparing:"准备 VeFaaS Function 代码",provisioning:"检查并补齐 Studio 云资源",scheduler:"更新定时任务调度服务",submitting:"提交 Function 更新",publishing:"发布新 Revision 并重启服务"},lte=Object.entries(cSe).map(([e,t])=>({id:e,label:t})),cte={...cSe,permissions:"预检 OTA 权限",resolving:"读取版本信息",downloading:"下载更新包",preparing:"准备 Function 代码",provisioning:"补齐 Studio 云资源",submitting:"提交 Function 更新",publishing:"发布 Revision",checking:"检查更新",unknown:"未知阶段"};function eDt(e){return e<60?`${e} 秒`:`${Math.floor(e/60)} 分 ${e%60} 秒`}function tDt(e,t){return e===t?!0:/^\d{14}$/.test(e)&&/^\d{14}$/.test(t)&&e>t}function nDt(e){return!!(e!=null&&e.some(t=>t.includes("部署应用成功")||t.toLowerCase().includes("application deployed successfully")))}function rDt(){if(typeof window>"u")return null;const e=window.localStorage.getItem(JA);if(!e)return null;try{const t=JSON.parse(e);if(typeof t.targetVersion=="string"&&typeof t.startedAt=="number")return{targetVersion:t.targetVersion,startedAt:t.startedAt}}catch{}return window.localStorage.removeItem(JA),null}function p3(e,t){window.localStorage.setItem(JA,JSON.stringify({targetVersion:e,startedAt:t}))}function Tx(){window.localStorage.removeItem(JA)}function iDt(){return typeof window>"u"?"":window.sessionStorage.getItem(MU)??""}function sDt(e){window.sessionStorage.setItem(MU,e)}function ute(){window.sessionStorage.removeItem(MU)}function dte({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M19.2 8.3A8 8 0 1 0 20 13"}),o.jsx("path",{d:"M19.2 4.8v3.5h-3.5"}),o.jsx("path",{d:"M12 7.8v7.7"}),o.jsx("path",{d:"m9.2 12.7 2.8 2.8 2.8-2.8"})]})}function aDt(){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:o.jsx("path",{d:"m4 6 4 4 4-4"})})}function oDt(){return o.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:o.jsx("path",{d:"m3.5 8.2 2.8 2.8 6.2-6"})})}function f$(){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:[o.jsx("path",{d:"M6.25 3.75H3.5v8.75h8.75V9.75"}),o.jsx("path",{d:"M8.5 3.5h4v4"}),o.jsx("path",{d:"m7.25 8.75 5-5"})]})}function fte({href:e}){return o.jsxs("div",{className:"studio-update-permission-notice",role:"status",children:[o.jsxs("p",{children:["无法读取 VeFaaS 发布日志。Function 角色缺少",o.jsx("code",{children:"vefaas:GetApplicationRevisionLog"})," 权限,更新会继续。"]}),o.jsxs("a",{href:e,target:"_blank",rel:"noreferrer",children:["前往 IAM 控制台配置权限",o.jsx(f$,{})]})]})}function hte({lines:e,phase:t,copyState:n,onCopy:r}){const i=p.useRef(null),s=p.useRef(!0),[a,l]=p.useState(e);return p.useEffect(()=>{e.length&&l(e)},[e]),p.useEffect(()=>{const c=i.current;c&&s.current&&(c.scrollTop=c.scrollHeight)},[a]),o.jsxs("section",{className:"studio-update-live-log","aria-label":"部署进度",children:[o.jsxs("div",{className:"studio-update-log-header",children:[o.jsxs("span",{children:[o.jsx("i",{className:`is-${t}`,"aria-hidden":!0}),"部署进度",o.jsx("small",{children:t==="active"?"实时":t==="complete"?"已完成":"已停止"})]}),o.jsx("button",{type:"button",onClick:()=>r(a),disabled:!a.length,children:n==="copied"?"已复制":n==="error"?"复制失败":"复制日志"})]}),o.jsx("div",{ref:i,className:"studio-update-log-lines",role:"log","aria-live":"off","aria-busy":t==="active",tabIndex:0,onScroll:c=>{const u=c.currentTarget;s.current=u.scrollHeight-u.scrollTop-u.clientHeight<24},children:a.length?a.map((c,u)=>o.jsx("div",{children:c},`${u}-${c}`)):o.jsx("p",{children:t==="active"?"等待 VeFaaS 返回更新日志…":"本次更新未返回发布日志"})})]})}function lDt({variant:e="default"}){var H,z;const[t]=p.useState(rDt),[n,r]=p.useState(null),[i,s]=p.useState(t?"submitting":"idle"),[a,l]=p.useState(!!t),[c,u]=p.useState(""),[d,f]=p.useState(null),[h,m]=p.useState((t==null?void 0:t.targetVersion)??""),[g,b]=p.useState(!1),[y,O]=p.useState("idle"),[v,x]=p.useState(0),w=p.useRef(null),S=p.useRef((t==null?void 0:t.targetVersion)??""),E=p.useRef((t==null?void 0:t.startedAt)??0),k=p.useRef(iDt()),_=p.useRef(0);p.useEffect(()=>{if(!g)return;const Q=K=>{var se;K.target instanceof Node&&!((se=w.current)!=null&&se.contains(K.target))&&b(!1)},V=K=>{K.key==="Escape"&&b(!1)};return window.addEventListener("pointerdown",Q),window.addEventListener("keydown",V),()=>{window.removeEventListener("pointerdown",Q),window.removeEventListener("keydown",V)}},[g]);const T=p.useCallback(async()=>{const Q=await ele(S.current||void 0,E.current||void 0);return r(Q),Q},[]);if(p.useEffect(()=>{let Q=!0;const V=()=>{T().catch(()=>{Q&&r(se=>se)})};V();const K=window.setInterval(V,Y5t);return()=>{Q=!1,window.clearInterval(K)}},[T]),p.useEffect(()=>{if(i!=="submitting")return;const Q=window.setInterval(()=>{T().then(V=>{const K=S.current;if(K&&tDt(V.currentVersion,K)||!K&&!V.available&&V.latestVersion){const se=Date.now();if(_.current||(_.current=se),V.updateLogsVisible!==!1&&!nDt(V.updateLogs)&&se-_.currentK5t&&(window.clearInterval(Q),Tx(),s("error"),u("等待 VeFaaS 发布超时,请稍后重新检查版本"))}).catch(()=>{})},Z5t);return()=>window.clearInterval(Q)},[i,T]),p.useEffect(()=>{i!=="idle"||(n==null?void 0:n.state)!=="updating"||(S.current=n.targetVersion,E.current=n.startedAt||Date.now(),p3(n.targetVersion,E.current),m(n.targetVersion),s("submitting"))},[i,n]),p.useEffect(()=>{if(i!=="submitting"){x(0);return}const Q=()=>{const K=E.current||Date.now();x(Math.max(0,Math.floor((Date.now()-K)/1e3)))};Q();const V=window.setInterval(Q,1e3);return()=>window.clearInterval(V)},[i]),!(n!=null&&n.enabled)||!(n.available||n.state==="updating"||i!=="idle"))return null;const A=n.releases??[],R=h||((H=A[0])==null?void 0:H.version)||n.latestVersion,M=A.find(Q=>Q.version===R),I=G5t((M==null?void 0:M.changelog)??[]),$=async()=>{ute(),k.current="",S.current=R,E.current=Date.now(),s("checking-permissions"),u(""),O("idle");try{const Q=await tle();if(f(Q),!Q.ready){Tx(),s("permission");return}f(null),p3(R,E.current),s("submitting");const V=await nle(R);S.current=V.version,p3(V.version,E.current),u("更新已提交,正在等待 VeFaaS 发布新版本")}catch(Q){if(Q instanceof TypeError||Q instanceof Error&&(Q.name==="TimeoutError"||Q.name==="AbortError")){u("连接已切换,正在确认新版本状态");return}Tx(),s("error");const V=Q instanceof Error?Q.message:"Studio 更新失败";try{const K=await T();u(K.message||V)}catch{u(V)}}},N=(z=n.updateLogs)!=null&&z.length?n.updateLogs:(n.errorLog||n.progressMessage||c).split(`
`).filter(Boolean),j=lte.findIndex(Q=>Q.id===n.progressStage),B=i==="submitting"&&n.progressStage!=="idle"&&j<0,F=async Q=>{try{await navigator.clipboard.writeText(Q.join(`
`)),O("copied")}catch{O("error")}},L=()=>{var Q;b(!1),O("idle"),u(""),f(null),m(S.current||((Q=A[0])==null?void 0:Q.version)||""),s("confirm")};return o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:e==="feature-link"?"welcome-feature-link studio-update-trigger--feature":`studio-update-trigger is-${i}`,title:i==="checking-permissions"?"正在检查 OTA 权限":i==="permission"?"需要 IAM 授权":i==="submitting"?"正在更新 Studio":i==="published"?"Studio 已更新":`更新 Studio 至 ${n.latestVersion}`,onClick:()=>{var Q;i==="published"?window.location.reload():(i==="checking-permissions"||i==="permission"||i==="submitting"||i==="error"||(m(((Q=A[0])==null?void 0:Q.version)||n.latestVersion),s("confirm")),l(!0))},children:[e!=="feature-link"&&o.jsx(dte,{className:"studio-update-icon"}),i==="checking-permissions"?o.jsx(wn,{as:"span",children:"检查更新权限"}):i==="permission"?o.jsx("span",{children:"需要授权"}):i==="submitting"?o.jsx(wn,{as:"span",children:"正在更新"}):i==="published"?o.jsx("span",{children:"刷新使用新版"}):i==="error"?o.jsx("span",{children:"更新失败"}):e==="feature-link"?o.jsx("span",{children:"立即更新"}):o.jsx("span",{children:"有新版更新"})]}),a&&i!=="idle"&&kr.createPortal(o.jsx("div",{className:"confirm-scrim",role:"presentation",children:o.jsxs("section",{className:`confirm-box studio-update-dialog${i==="submitting"||i==="published"||i==="error"?" is-progress":""}`,role:"dialog","aria-modal":"true","aria-labelledby":"studio-update-title",children:[o.jsx("div",{className:"studio-update-dialog-mark",children:o.jsx(dte,{})}),o.jsx("div",{id:"studio-update-title",className:"confirm-title",children:i==="error"?"Studio 更新失败":i==="checking-permissions"?"正在检查更新权限":i==="permission"?"需要 IAM 授权":i==="submitting"?"正在更新 Studio":i==="published"?"Studio 更新完成":"发现新版本"}),i==="checking-permissions"?o.jsxs("div",{className:"studio-update-permission-checking",role:"status",children:[o.jsx(wn,{as:"p",children:"正在核对 OTA 与定时任务所需的全部 IAM 权限…"}),o.jsx("p",{children:"权限全部满足后才会开始下载、更新或发布云资源。"})]}):i==="permission"&&d?o.jsxs("div",{className:"studio-update-authorization-panel",children:[o.jsxs("p",{className:"confirm-text",children:["当前 Function 角色缺少 ",d.missingActions.length," 项 OTA 更新权限,尚未执行任何云资源变更。"]}),o.jsxs("dl",{className:"studio-update-authorization-principal",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"Function 角色"}),o.jsx("dd",{children:d.principalName||"当前运行角色"})]}),d.policyName&&o.jsxs("div",{children:[o.jsx("dt",{children:"将更新策略"}),o.jsx("dd",{children:d.policyName})]})]}),o.jsxs("ol",{className:"studio-update-authorization-steps",children:[o.jsx("li",{children:"打开授权页面,确认已预填的策略名称和完整策略内容。"}),o.jsx("li",{children:"点击页面中的“发起调试”,完成策略更新。"}),o.jsx("li",{children:"返回此窗口,点击“我已授权,重新检查”。"})]}),o.jsxs("div",{className:"studio-update-missing-actions",children:[o.jsx("span",{children:"缺少的权限"}),o.jsx("ul",{children:d.missingActions.map(Q=>o.jsx("li",{children:o.jsx("code",{children:Q})},Q))})]}),o.jsxs("a",{className:"studio-update-authorization-link",href:d.authorizationUrl||d.iamConsoleUrl,target:"_blank",rel:"noreferrer",children:[d.authorizationUrl?"打开已预填的 IAM 授权页面":"前往 IAM 控制台手动配置",o.jsx(f$,{})]}),!d.authorizationUrl&&o.jsx("p",{className:"studio-update-authorization-note",children:"当前角色没有唯一可安全更新的自定义策略,请由管理员将上述权限加入该角色。"})]}):i==="error"?o.jsxs("div",{className:"studio-update-error-panel",children:[o.jsx("p",{className:"confirm-text studio-update-error",children:c}),o.jsxs("dl",{className:"studio-update-error-meta",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"失败阶段"}),o.jsx("dd",{children:cte[n.errorStage]||n.errorStage||"未知阶段"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"错误 ID"}),o.jsx("dd",{children:n.errorId||"未生成"})]})]}),n.updateLogsVisible!==!1&&o.jsx(hte,{lines:N,phase:"error",copyState:y,onCopy:Q=>void F(Q)}),n.updateLogsVisible===!1&&o.jsx(fte,{href:n.permissionConsoleUrl}),n.consoleUrl&&o.jsxs("a",{className:"studio-update-console-link",href:n.consoleUrl,target:"_blank",rel:"noreferrer",children:["前往 VeFaaS 控制台查看 Function 日志",o.jsx(f$,{})]})]}):i==="submitting"||i==="published"?o.jsxs("div",{className:"studio-update-progress-body",children:[o.jsxs("div",{className:"studio-update-progress-summary",children:[o.jsxs("div",{children:[o.jsx("span",{children:"目标版本"}),o.jsx("strong",{children:S.current||R})]}),o.jsxs("div",{children:[o.jsx("span",{children:i==="published"?"更新状态":"已用时"}),o.jsx("strong",{children:i==="published"?"已完成":eDt(v)})]})]}),o.jsxs("ol",{className:"studio-update-progress","aria-label":"Studio 更新进度",children:[B&&o.jsxs("li",{className:"is-active","aria-current":"step",children:[o.jsx("span",{className:"studio-update-progress-dot","aria-hidden":!0}),o.jsxs("div",{children:[o.jsx("span",{children:cte[n.progressStage]||"正在处理更新"}),o.jsx(wn,{as:"small",children:n.progressMessage||c||"正在处理"})]})]}),lte.map((Q,V)=>{const K=i==="published"||Vvoid F(Q)}),n.updateLogsVisible===!1&&o.jsx(fte,{href:n.permissionConsoleUrl}),o.jsx("p",{className:"studio-update-progress-note",children:"发布阶段会短暂中断连接;关闭此窗口不会停止更新,可随时点击右上角按钮重新查看。"})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"confirm-text",children:"更新会重启 Studio 服务,预计约 3–5 分钟完成更新与发布。期间正在进行的对话、 流式响应或部署任务可能中断,登录态不会受到影响。"}),o.jsxs("div",{className:"studio-update-field",ref:w,children:[o.jsx("span",{children:"选择版本"}),o.jsxs("button",{type:"button",className:"studio-update-version-trigger","aria-label":"选择版本","aria-haspopup":"listbox","aria-expanded":g,onClick:()=>b(Q=>!Q),onKeyDown:Q=>{(Q.key==="ArrowDown"||Q.key==="ArrowUp")&&(Q.preventDefault(),b(!0))},children:[o.jsx("span",{children:R}),o.jsx(aDt,{})]}),g&&o.jsx("div",{className:"studio-update-version-menu",role:"listbox","aria-label":"选择版本",children:A.map(Q=>{const V=Q.version===R;return o.jsxs("button",{type:"button",role:"option","aria-selected":V,className:`studio-update-version-option${V?" is-selected":""}`,onClick:()=>{m(Q.version),b(!1)},children:[o.jsx("span",{children:Q.version}),V&&o.jsx(oDt,{})]},Q.version)})})]}),o.jsxs("dl",{className:"studio-update-versions",children:[o.jsxs("div",{children:[o.jsx("dt",{children:"当前版本"}),o.jsx("dd",{children:n.currentVersion})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"目标版本"}),o.jsx("dd",{children:R})]}),o.jsxs("div",{children:[o.jsx("dt",{children:"Commit"}),o.jsx("dd",{children:((M==null?void 0:M.gitSha)||n.latestGitSha).slice(0,8)})]})]}),o.jsxs("section",{className:"studio-update-changelog","aria-labelledby":"studio-update-changelog-title",children:[o.jsx("div",{id:"studio-update-changelog-title",children:"更新内容"}),I.length?o.jsx("ul",{children:I.map(Q=>o.jsx("li",{children:Q},Q))}):o.jsx("p",{children:"暂无更新说明"})]})]}),o.jsxs("div",{className:"confirm-actions",children:[o.jsx("button",{type:"button",className:"confirm-btn",onClick:()=>{l(!1),b(!1),i==="confirm"&&(s("idle"),u(""))},children:i==="submitting"?"后台运行":i==="confirm"?"取消":"关闭"}),i==="confirm"&&o.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:()=>void $(),children:"立即更新"}),i==="permission"&&o.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:()=>void $(),children:"我已授权,重新检查"}),i==="error"&&o.jsx("button",{type:"button",className:"confirm-btn studio-update-confirm",onClick:L,children:"重新尝试"})]})]})}),document.body)]})}const cDt=["多地域智能体:并行加载北京与上海 Runtime,列表下滑即可继续加载。","会话内切换:在输入框旁选择智能体,并直接开启一段新会话。","可视化执行画布:通过横向画布查看多智能体结构,并支持全屏浏览。"],pte=W5t(),uDt=pte.length?pte:cDt;function dDt({canUpdate:e=!1}){return o.jsxs("div",{className:"welcome-feature-pill",children:[o.jsx("span",{children:"焕然一新"}),o.jsx("span",{className:"welcome-feature-divider","aria-hidden":"true"}),o.jsx("button",{type:"button",className:"welcome-feature-link","aria-describedby":"welcome-feature-popover",children:"查看新特性"}),o.jsxs("section",{id:"welcome-feature-popover",className:"welcome-feature-popover",role:"tooltip",children:[o.jsx("strong",{children:"本次更新"}),o.jsx("ul",{children:uDt.map(t=>o.jsx("li",{children:t},t))})]}),e&&o.jsx(lDt,{variant:"feature-link"})]})}const fDt=1e4;async function uSe(e){const t=await fetch(So(e),{headers:ph({Accept:"application/json"}),signal:il(void 0,fDt)});if(!t.ok)throw new Error(`读取会话模式能力失败(HTTP ${t.status})`);const n=await t.json();if(typeof n.enabled!="boolean")throw new Error("会话模式能力响应格式错误");return{enabled:n.enabled,reason:typeof n.reason=="string"?n.reason:void 0,endpointExportEnabled:n.endpointExportEnabled===!0}}async function hDt(){return uSe("/web/sandbox/capabilities")}async function pDt(e){return uSe(`/web/${e}/capabilities`)}function mDt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m7 7 10 10M17 7 7 17"})})}function gDt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M12 3.5v11m-4-4 4 4 4-4"}),o.jsx("path",{d:"M5 19.5h14"})]})}function mte(e){return o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",...e,children:[o.jsx("circle",{cx:"8",cy:"8",r:"5.5",stroke:"currentColor",strokeWidth:"1.5",opacity:"0.22"}),o.jsx("path",{d:"M8 2.5A5.5 5.5 0 0 1 13.5 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function bDt({open:e,task:t,onClose:n,onRetry:r,onDownload:i}){const s=p.useId(),a=p.useRef(null),l=p.useRef(null),c=p.useRef(null),[u,d]=p.useState(()=>Date.now()),f=p.useRef(n);if(f.current=n,p.useEffect(()=>{if(!e||!t)return;c.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const S=document.body.style.overflow;document.body.style.overflow="hidden";const E=window.requestAnimationFrame(()=>{var _;return(_=l.current)==null?void 0:_.focus()}),k=_=>{var R;if(_.key==="Escape"){_.preventDefault(),f.current();return}if(_.key!=="Tab")return;const T=Array.from(((R=a.current)==null?void 0:R.querySelectorAll('button:not(:disabled), a[href], video[controls], [tabindex]:not([tabindex="-1"])'))??[]);if(T.length===0)return;const C=T[0],A=T[T.length-1];if(document.activeElement===l.current){_.preventDefault(),(_.shiftKey?A:C).focus();return}_.shiftKey&&document.activeElement===C?(_.preventDefault(),A.focus()):!_.shiftKey&&document.activeElement===A&&(_.preventDefault(),C.focus())};return window.addEventListener("keydown",k),()=>{var _;window.cancelAnimationFrame(E),document.body.style.overflow=S,window.removeEventListener("keydown",k),(_=c.current)!=null&&_.isConnected&&c.current.focus()}},[e,t==null?void 0:t.localId]),p.useEffect(()=>{if(!e||(t==null?void 0:t.status)!=="generating"||t.generationStartedAt===null)return;const S=()=>d(Date.now());S();const E=window.setInterval(S,1e3);return()=>window.clearInterval(E)},[e,t==null?void 0:t.localId,t==null?void 0:t.runId,t==null?void 0:t.status,t==null?void 0:t.generationStartedAt]),!e||!t)return null;const h=e$(t),m=t.status==="optimizing"||t.status==="generating",g=t.errorStage==="optimization"?"重试提示词优化":"重试视频生成",b=gwe(t.resolvedMode??t.requestedMode),y=t.error.includes("尚未开通"),O=INt(t),v=t.generationStartedAt===null?"":RNt(u-t.generationStartedAt),x=t.providerStatus==="queued"?"等待模型调度":t.providerStatus==="running"?"模型生成中":"正在提交任务",w=t.providerStatus==="queued"?"任务已提交,模型开始处理后状态会自动更新":"这可能持续数分钟,完成后将在这里显示视频预览";return kr.createPortal(o.jsx("div",{className:"new-chat-video-task-backdrop",onMouseDown:S=>{S.target===S.currentTarget&&n()},children:o.jsxs("section",{ref:a,className:`new-chat-video-task-dialog is-${t.status}`,role:"dialog","aria-modal":"true","aria-labelledby":s,"aria-busy":m||void 0,children:[o.jsxs("header",{className:"new-chat-video-task-dialog__head",children:[o.jsxs("div",{children:[o.jsx("h2",{ref:l,id:s,tabIndex:-1,children:"视频生成任务"}),o.jsxs("p",{children:[b," · ",t.generationModel]})]}),o.jsx("button",{type:"button",className:"new-chat-video-task-dialog__close",onClick:n,"aria-label":"关闭视频生成任务弹窗",children:o.jsx(mDt,{})})]}),o.jsxs("div",{className:"new-chat-video-task-dialog__body",children:[o.jsx("ol",{className:"new-chat-video-task-steps","aria-label":"视频生成进度","aria-live":"polite","aria-atomic":"true",children:h.map(S=>o.jsx("li",{className:`is-${S.status}`,children:o.jsxs("span",{className:"new-chat-video-task-step__label",children:[S.status==="active"?o.jsx(mte,{className:"new-chat-video-task-step__loading"}):null,o.jsx("span",{children:S.label})]})},S.id))}),t.error?o.jsx("div",{className:"new-chat-video-task-error",role:"alert",children:o.jsx("p",{children:t.error})}):null,t.optimizedPrompt?o.jsxs("section",{className:"new-chat-video-task-prompt","aria-labelledby":`${s}-prompt`,children:[o.jsx("h3",{id:`${s}-prompt`,children:"优化后的提示词"}),o.jsx("p",{children:t.optimizedPrompt})]}):null,t.status==="generating"?o.jsxs("div",{className:"new-chat-video-task-preview is-loading",children:[o.jsx(mte,{className:"new-chat-video-task-preview__loading"}),o.jsx(wn,{as:"strong",duration:2.2,spread:18,"aria-live":"polite",children:O}),o.jsx("div",{className:"new-chat-video-task-progress",role:"progressbar","aria-label":`${b}处理进度`,"aria-valuetext":`${O}${v?`,已等待${v}`:""}`,children:o.jsx("span",{"aria-hidden":"true"})}),o.jsxs("div",{className:"new-chat-video-task-progress__meta",children:[o.jsx("span",{children:x}),v?o.jsxs("span",{children:["已等待 ",v]}):null]}),o.jsx("span",{children:w})]}):t.output?o.jsx("div",{className:"new-chat-video-task-preview",children:o.jsx("video",{src:t.output.previewUrl,controls:!0,playsInline:!0,preload:"metadata","aria-label":"生成结果预览"})}):null]}),o.jsxs("footer",{className:"new-chat-video-task-dialog__actions",children:[o.jsx("p",{children:m?"可以关闭弹窗,任务会继续在后台运行":t.status==="success"?"视频已生成,可预览或下载":y?"请先在模型控制台开通服务,再重试生成":"修正问题后可重试当前步骤"}),o.jsxs("div",{children:[o.jsx("button",{type:"button",className:"new-chat-video-task-button",onClick:n,children:"关闭"}),t.status==="error"?o.jsx("button",{type:"button",className:"new-chat-video-task-button is-primary",onClick:r,children:g}):t.output?o.jsxs("button",{type:"button",className:"new-chat-video-task-button is-primary",onClick:i,children:[o.jsx(gDt,{}),"下载视频"]}):null]})]})]})}),document.body)}const Cx="/web/agentkit-cli",x_=6e4,yDt=33e4,h$="管理员未配置 AgentKit Dev Sandbox,请配置后再使用";function Ax(e=!1){const t=new Headers({Accept:"application/json"});return e&&t.set("Content-Type","application/json"),t}async function Nx(e,t){return new Error(await Wt(e,t))}function gte(e){const t=e;if(typeof(t==null?void 0:t.sessionId)!="string"||typeof t.status!="string")throw new Error("AgentKit CLI 返回了无效的 Session。");return{id:t.sessionId,status:t.status,displayName:typeof t.displayName=="string"?t.displayName:"",expireAt:typeof t.expireAt=="string"?t.expireAt:""}}const kb={async capabilities(e={}){const t=await jn(`${Cx}/capabilities`,{headers:Ax(),signal:e.signal},x_);if(!t.ok)throw await Nx(t,"无法读取 AgentKit CLI 配置。");const n=await t.json();if(typeof n.enabled!="boolean")throw new Error("AgentKit CLI 返回了无效的配置状态。");return{enabled:n.enabled,reason:typeof n.reason=="string"?n.reason:""}},async listSessions(e={}){const t=await jn(`${Cx}/sessions`,{headers:Ax(),signal:e.signal},x_);if(!t.ok)throw await Nx(t,"无法读取 AgentKit CLI Session。");const n=await t.json();if(!Array.isArray(n.sessions))throw new Error("AgentKit CLI 返回了无效的 Session 列表。");return n.sessions.map(gte)},async createSession(e={}){const t=await jn(`${Cx}/sessions`,{method:"POST",headers:Ax(!0),body:JSON.stringify({persistent:!1}),signal:e.signal},yDt);if(!t.ok)throw await Nx(t,"无法创建 AgentKit CLI Session。");return gte(await t.json())},async openSession(e,t={}){const n=await jn(`${Cx}/sessions/${encodeURIComponent(e)}/open`,{method:"POST",headers:Ax(),signal:t.signal},x_);if(!n.ok)throw await Nx(n,"无法打开 AgentKit CLI Session。")},async launchTerminal(e,t={}){const n=await jn(`${Cx}/sessions/${encodeURIComponent(e)}/terminal`,{method:"POST",headers:Ax(),signal:t.signal},x_);if(!n.ok)throw await Nx(n,"无法打开 AgentKit CLI 终端。");const r=await n.json();if(typeof r.url!="string"||!r.url)throw new Error("AgentKit CLI 返回了无效的终端地址。");return{url:r.url,...typeof r.shellSessionId=="string"?{shellSessionId:r.shellSessionId}:{}}}};function TO({open:e,keepMounted:t=!1,title:n,subtitle:r,icon:i,className:s="",onClose:a,children:l}){const c=p.useId(),u=p.useRef(null),d=p.useRef(null),f=p.useRef(a);return f.current=a,p.useEffect(()=>{var g;if(!e)return;d.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const h=document.body.style.overflow;document.body.style.overflow="hidden",(g=u.current)==null||g.focus();const m=b=>{var w;if(b.key==="Escape"){b.preventDefault(),f.current();return}if(b.key!=="Tab")return;const y=(w=u.current)==null?void 0:w.closest("[role=dialog]"),O=Array.from((y==null?void 0:y.querySelectorAll('button:not(:disabled), input:not(:disabled), iframe, [tabindex]:not([tabindex="-1"])'))??[]);if(O.length===0)return;const v=O[0],x=O[O.length-1];b.shiftKey&&document.activeElement===v?(b.preventDefault(),x.focus()):!b.shiftKey&&document.activeElement===x&&(b.preventDefault(),v.focus())};return window.addEventListener("keydown",m),()=>{var b;document.body.style.overflow=h,window.removeEventListener("keydown",m),(b=d.current)==null||b.focus()}},[e]),!e&&!t?null:kr.createPortal(o.jsx("div",{className:"sandbox-control-backdrop",hidden:!e,onMouseDown:h=>{h.target===h.currentTarget&&a()},children:o.jsxs("section",{className:`sandbox-control-dialog ${s}`.trim(),role:"dialog","aria-modal":"true","aria-labelledby":c,children:[o.jsxs("header",{className:"sandbox-control-head",children:[o.jsx("span",{className:"sandbox-control-head-icon","aria-hidden":"true",children:i}),o.jsxs("div",{children:[o.jsx("h2",{id:c,children:n}),r?o.jsx("p",{children:r}):null]}),o.jsx("button",{ref:u,type:"button",className:"sandbox-control-close","aria-label":`关闭${n}`,onClick:a,children:o.jsx(hwe,{})})]}),l]})}),document.body)}function ODt({open:e,kind:t,launch:n,loading:r,error:i,onReload:s,onClose:a}){const l=t==="terminal",c=l?"Terminal":"Sandbox Browser";return o.jsxs(TO,{open:e,title:c,subtitle:l?"连接当前 AgentKit Session 的交互式终端":"在当前 AgentKit Session 中查看与操作浏览器",icon:l?o.jsx(n0,{}):o.jsx(fwe,{}),className:`sandbox-tool-dialog sandbox-tool-dialog--${t}`,onClose:a,children:[o.jsx("div",{className:"sandbox-tool-toolbar",children:o.jsxs("span",{children:[o.jsx("i",{className:r?"is-loading":n?"is-ready":""}),r?"正在连接…":n?"已连接":"尚未连接"]})}),o.jsx("div",{className:"sandbox-tool-surface",children:r?o.jsxs("div",{className:"sandbox-control-state",children:[o.jsx(du,{className:"spin"}),o.jsxs("strong",{children:["正在打开 ",c]}),o.jsx("span",{children:"工具正在连接当前 AgentKit Session。"})]}):i?o.jsxs("div",{className:"sandbox-control-state is-error",children:[o.jsxs("strong",{children:[c," 打开失败"]}),o.jsx("span",{children:i}),o.jsx("button",{type:"button",onClick:s,children:"重试"})]}):n?o.jsx("iframe",{src:n.url,title:c,allow:"clipboard-read; clipboard-write",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-pointer-lock allow-same-origin allow-scripts"}):null})]})}function xDt({open:e,threads:t,currentThreadId:n,loading:r,error:i,onSelect:s,onClose:a}){return o.jsx(TO,{open:e,title:"恢复 Codex 对话",subtitle:"选择当前 Sandbox Session 中最近更新的 Thread",icon:o.jsx(ZAt,{}),className:"sandbox-threads-dialog",onClose:a,children:o.jsx("div",{className:"sandbox-thread-list",children:r?o.jsxs("div",{className:"sandbox-control-state",children:[o.jsx(du,{className:"spin"}),o.jsx("strong",{children:"正在读取历史对话"})]}):i?o.jsxs("div",{className:"sandbox-control-state is-error",children:[o.jsx("strong",{children:"历史对话读取失败"}),o.jsx("span",{children:i})]}):t.length===0?o.jsx("div",{className:"sandbox-control-state",children:o.jsx("strong",{children:"暂无可恢复的对话"})}):t.map(l=>{const c=l.id===n,u=l.name||l.preview||`Thread ${l.id.slice(0,8)}`;return o.jsxs("button",{type:"button",className:c?"is-active":"",disabled:c,onClick:()=>s(l.id),children:[o.jsxs("span",{children:[o.jsx("strong",{children:u}),o.jsx("small",{children:l.preview||l.cwd||l.id})]}),o.jsx("time",{children:l.updatedAt?new Date(l.updatedAt*1e3).toLocaleString():""}),o.jsx(J6,{})]},l.id)})})})}const vDt=[{value:"read-only",label:"只读",detail:"允许读取文件,不允许写入工作空间。"},{value:"workspace-write",label:"工作区写入",detail:"允许在当前工作空间内读取与修改文件。"},{value:"danger-full-access",label:"完全访问",detail:"不启用沙箱隔离,适合明确可信的任务。",danger:!0}],wDt=[{value:"untrusted",label:"仅不可信命令",detail:"只对 Codex 判断为不可信的操作发起审批。"},{value:"on-request",label:"按需审批",detail:"Codex 可在必要时请求你确认命令或文件修改。"},{value:"never",label:"不审批",detail:"Codex 不会暂停并请求人工批准。",danger:!0}],SDt=[{value:"user",label:"由我审批",detail:"审批请求会显示在 Studio 中,由你决定。"},{value:"auto_review",label:"自动审查",detail:"使用 Codex 自动审查流程处理审批请求。"}];function EDt({open:e,value:t,busy:n,error:r,onSave:i,onClose:s}){const[a,l]=p.useState(t);return p.useEffect(()=>{e&&l(t)},[e,t]),o.jsxs(TO,{open:e,title:"Codex 权限",subtitle:"设置会保存到当前 Sandbox Session,并同步到其中的所有 Thread",icon:o.jsx(TU,{}),className:"sandbox-settings-dialog",onClose:s,children:[o.jsxs("div",{className:"sandbox-control-body",children:[o.jsx(m3,{label:"沙箱模式",choices:vDt,value:a.sandboxMode,disabled:n,onChange:c=>l(u=>({...u,sandboxMode:c,networkAccess:c==="danger-full-access"?!0:u.networkAccess}))}),o.jsx(m3,{label:"审批策略",choices:wDt,value:a.approvalPolicy,disabled:n,onChange:c=>l(u=>({...u,approvalPolicy:c}))}),o.jsx(m3,{label:"审批方式",choices:SDt,value:a.approvalsReviewer,disabled:n,onChange:c=>l(u=>({...u,approvalsReviewer:c}))}),o.jsxs("label",{className:`sandbox-network-toggle${a.sandboxMode==="danger-full-access"?" is-disabled":""}`,children:[o.jsxs("span",{children:[o.jsx("strong",{children:"允许网络访问"}),o.jsx("small",{children:"控制 workspace-write 与只读模式中的外部网络访问。"})]}),o.jsx("input",{type:"checkbox",checked:a.networkAccess,disabled:n||a.sandboxMode==="danger-full-access",onChange:c=>l(u=>({...u,networkAccess:c.target.checked}))})]}),a.sandboxMode==="danger-full-access"?o.jsx("div",{className:"sandbox-control-note is-danger",children:"完全访问会关闭文件系统与网络隔离,请只在可信任务中使用。"}):null,r?o.jsx("div",{className:"sandbox-control-error",children:r}):null]}),o.jsxs("footer",{className:"sandbox-control-actions",children:[o.jsx("button",{type:"button",onClick:s,disabled:n,children:"取消"}),o.jsxs("button",{type:"button",className:"is-primary",disabled:n,onClick:()=>i(a),children:[n?o.jsx(du,{className:"spin"}):null,"保存权限"]})]})]})}function m3({label:e,choices:t,value:n,disabled:r,onChange:i}){return o.jsxs("fieldset",{className:"sandbox-choice-group",disabled:r,role:"radiogroup","aria-label":e,children:[o.jsx("legend",{children:e}),o.jsx("div",{className:"sandbox-choice-list",children:t.map(s=>o.jsxs("button",{type:"button",role:"radio",className:`${n===s.value?"is-active":""}${s.danger?" is-danger":""}`.trim(),"aria-checked":n===s.value,onClick:()=>i(s.value),onKeyDown:a=>{var d,f;const l=t.findIndex(h=>h.value===s.value);let c=l;if(a.key==="ArrowRight"||a.key==="ArrowDown")c=(l+1)%t.length;else if(a.key==="ArrowLeft"||a.key==="ArrowUp")c=(l-1+t.length)%t.length;else if(a.key==="Home")c=0;else if(a.key==="End")c=t.length-1;else return;a.preventDefault(),i(t[c].value);const u=(d=a.currentTarget.parentElement)==null?void 0:d.querySelectorAll('[role="radio"]');(f=u==null?void 0:u[c])==null||f.focus()},children:[o.jsx("i",{}),o.jsxs("span",{children:[o.jsx("strong",{children:s.label}),o.jsx("small",{children:s.detail})]})]},s.value))})]})}function kDt({open:e,cwd:t,locked:n,busy:r,error:i,browse:s,onSave:a,onClose:l}){const[c,u]=p.useState(t||"/"),[d,f]=p.useState(null),[h,m]=p.useState(!1),[g,b]=p.useState("");p.useEffect(()=>{if(!e)return;const O=t||"/";u(O),y(O)},[t,e]);async function y(O){m(!0),b("");try{const v=await s(O);f(v),u(v.path)}catch(v){b(v instanceof Error?v.message:String(v))}finally{m(!1)}}return o.jsxs(TO,{open:e,title:"工作空间",subtitle:"选择当前 Codex Thread 执行命令与修改文件的目录",icon:o.jsx(RT,{}),className:"sandbox-workspace-dialog",onClose:l,children:[o.jsxs("div",{className:"sandbox-control-body",children:[o.jsxs("label",{className:"sandbox-workspace-input",children:[o.jsx("span",{children:"绝对路径"}),o.jsxs("div",{children:[o.jsx("input",{value:c,disabled:r||n,spellCheck:!1,onChange:O=>u(O.target.value),onKeyDown:O=>{O.key==="Enter"&&c.startsWith("/")&&(O.preventDefault(),y(c))}}),o.jsx("button",{type:"button",disabled:r||h||!c.startsWith("/"),onClick:()=>void y(c),children:"浏览"})]})]}),o.jsxs("div",{className:"sandbox-directory-browser",children:[o.jsxs("div",{className:"sandbox-directory-head",children:[o.jsx("span",{title:d==null?void 0:d.path,children:(d==null?void 0:d.path)??c}),h?o.jsx(du,{className:"spin"}):null]}),o.jsxs("div",{className:"sandbox-directory-list",children:[d!=null&&d.parent?o.jsxs("button",{type:"button",disabled:h,onClick:()=>void y(d.parent??"/"),children:[o.jsx(RT,{}),o.jsx("span",{children:"上一级"}),o.jsx("small",{children:d.parent}),o.jsx(J6,{})]}):null,d==null?void 0:d.directories.map(O=>o.jsxs("button",{type:"button",disabled:h,onClick:()=>void y(O.path),children:[o.jsx(RT,{}),o.jsx("span",{children:O.name}),o.jsx(J6,{})]},O.path)),!h&&(d==null?void 0:d.directories.length)===0?o.jsx("div",{className:"sandbox-directory-empty",children:"当前目录没有子目录"}):null]})]}),n?o.jsx("div",{className:"sandbox-control-note",children:"当前对话已经开始,工作空间已锁定。新建 Sandbox 会话后可重新选择。"}):null,g||i?o.jsx("div",{className:"sandbox-control-error",children:g||i}):null]}),o.jsxs("footer",{className:"sandbox-control-actions",children:[o.jsx("button",{type:"button",onClick:l,disabled:r,children:"取消"}),o.jsxs("button",{type:"button",className:"is-primary",disabled:r||n||!c.startsWith("/"),onClick:()=>a(c),children:[r?o.jsx(du,{className:"spin"}):null,"使用此目录"]})]})]})}function _Dt({approval:e,busy:t,error:n,onDecision:r}){var a;const i=(a=e==null?void 0:e.command)==null?void 0:a.trim(),s=(e==null?void 0:e.changes)===void 0?"":JSON.stringify(e.changes,null,2);return o.jsxs(TO,{open:e!==null,title:(e==null?void 0:e.kind)==="file"?"允许修改文件?":"允许执行命令?",subtitle:"Codex 正在等待你的决定",icon:o.jsx(TU,{}),className:"sandbox-approval-dialog",onClose:()=>{t||r("cancel")},children:[o.jsxs("div",{className:"sandbox-control-body",children:[e!=null&&e.reason?o.jsx("div",{className:"sandbox-approval-reason",children:e.reason}):null,i?o.jsx("pre",{children:i}):null,s?o.jsx("pre",{children:s}):null,e!=null&&e.cwd?o.jsxs("div",{className:"sandbox-approval-meta",children:["执行目录 ",o.jsx("code",{children:e.cwd})]}):null,n?o.jsx("div",{className:"sandbox-control-error",children:n}):null]}),o.jsxs("footer",{className:"sandbox-control-actions sandbox-approval-actions",children:[o.jsx("button",{type:"button",disabled:t,onClick:()=>r("decline"),children:"拒绝"}),o.jsx("button",{type:"button",disabled:t,onClick:()=>r("accept"),children:"仅本次允许"}),o.jsxs("button",{type:"button",className:"is-primary",disabled:t,onClick:()=>r("acceptForSession"),children:[t?o.jsx(du,{className:"spin"}):null,"本会话允许"]})]})]})}const bte={searching:"正在查找已有环境",creating:"环境初始化中",connecting:"正在连接已有环境"},dSe=new Set(["creating","pending","running","starting","initializing"]),fSe="ready",TDt=1500,CDt=80;function p$(e){return e.status.trim().toLowerCase()}function ADt(e){return new Promise((t,n)=>{const r=window.setTimeout(t,TDt);e.addEventListener("abort",()=>{window.clearTimeout(r),n(new DOMException("Aborted","AbortError"))},{once:!0})})}async function NDt(e,t){let n=e;for(let r=0;rl.id===n.id);if(!a)throw new Error("AgentKit CLI Session 不存在或已过期,请重试。");n=a}throw new Error("AgentKit CLI 环境初始化超时,请稍后重试。")}async function jDt(e,t){t("searching");const n=await kb.capabilities({signal:e});if(!n.enabled)throw new Error(n.reason||h$);const r=await kb.listSessions({signal:e});let i=r.find(s=>p$(s)===fSe)??r.find(s=>dSe.has(p$(s)));return i?t("connecting"):(t("creating"),i=await kb.createSession({signal:e})),i=await NDt(i,e),t("connecting"),await kb.openSession(i.id,{signal:e}),{launch:await kb.launchTerminal(i.id,{signal:e}),session:i}}function RDt(e){return e==="searching"||e==="creating"||e==="connecting"}function IDt(e,t){const n=Date.parse(e);return Number.isFinite(n)&&n>t}function DDt(e,t){const n=Date.parse(e);if(!Number.isFinite(n))return"非持久化环境";const r=Math.max(0,Math.ceil((n-t)/6e4)),i=Math.floor(r/60),s=r%60;return i>0?`${i} 小时 ${s} 分钟后环境回收`:`${s} 分钟后环境回收`}function PDt(e){const t=e instanceof Error?e.message:String(e);return e instanceof TypeError?`无法连接 Studio 服务,未收到服务端响应。
@@ -1143,7 +1143,7 @@ ${t}`}function Ajt(e,t){if(e.length<=t)return{text:e,omitted:!1};let n=e.slice(-
`))return;const q=t.slice(1),G=q.search(/\s/),J=(G<0?q:q.slice(0,G)).toLocaleLowerCase(),ue=G<0?"":q.slice(G).trim();if(!(G>=0&&J!=="model"))return{command:J,argument:ue,modelMode:G>=0}},[t]),B=p.useMemo(()=>{const q=/(^|\s)\$([^\s$]*)$/.exec(t);if(q)return{query:q[2],start:t.length-q[2].length-1,end:t.length}},[t]),F=p.useMemo(()=>{if(B){const q=B.query.toLocaleLowerCase();return y.filter(G=>!x.some(J=>J.id===G.id||J.name===G.name)).filter(G=>`${G.name} ${G.description}`.toLocaleLowerCase().includes(q)).slice(0,12).map(G=>({kind:"skill",skill:G}))}return j!=null&&j.modelMode?GDt(f,j.argument).map(q=>({kind:"model",model:q})):j?XDt(j.command).map(q=>({kind:"command",command:q})):[]},[B,f,x,y,j]),L=!E&&!$&&!!(B||j);p.useEffect(()=>{I(0)},[t]),p.useEffect(()=>{j!=null&&j.modelMode&&!m&&!h&&b()},[m,h,b,j==null?void 0:j.modelMode]),p.useEffect(()=>{B&&!v&&!O&&w()},[B,w,v,O]);const H=l.some(q=>q.status!=="ready"),z=a&&!!i,Q=!s&&!a&&!H&&(t.trim().length>0||l.length>0);function V(q){N(!1),R(!1),n(q)}function K(q){if(q.kind==="skill"){if(!B)return;const G=t.slice(0,B.start)+t.slice(B.end);S([...x,q.skill]),V(G),N(!0),requestAnimationFrame(()=>{var J,ue;(J=k.current)==null||J.focus(),(ue=k.current)==null||ue.setSelectionRange(B.start,B.start)});return}if(q.kind==="model"){V(`/model ${q.model.id}`),N(!0),requestAnimationFrame(()=>{var G;return(G=k.current)==null?void 0:G.focus()});return}if(q.command.name==="model"){V("/model "),b(),requestAnimationFrame(()=>{var G;return(G=k.current)==null?void 0:G.focus()});return}if(q.command.name==="skill"||q.command.name==="skills"){V(`/${q.command.name}`),N(!0),requestAnimationFrame(()=>{var G;return(G=k.current)==null?void 0:G.focus()});return}V(`/${q.command.name}`),N(!0),requestAnimationFrame(()=>{var G;return(G=k.current)==null?void 0:G.focus()})}function se(q){var G;R(!1),(G=q.current)==null||G.click()}function ge(q){const G=q.target.files?Array.from(q.target.files):[];G.length&&c(G),q.target.value=""}const ie=B?"可用 Skills":j!=null&&j.modelMode?"选择模型":"Codex 快捷命令";return o.jsxs("div",{className:"composer sandbox-codex-composer",children:[l.length>0?o.jsx(Bj,{appName:e,compact:!0,items:l,onRemove:u}):null,o.jsxs("div",{className:"composer-box",children:[L?o.jsxs("div",{className:"composer-command-menu",role:"listbox","aria-label":ie,children:[o.jsxs("div",{className:"composer-command-head",children:[o.jsx(YAt,{}),o.jsx("span",{children:ie}),j!=null&&j.modelMode&&g?o.jsxs("small",{children:["当前:",g]}):null,o.jsx("kbd",{children:B?"$":"/"})]}),B&&O?o.jsxs("div",{className:"composer-command-empty",children:[o.jsx(du,{className:"spin"})," 正在发现当前工作区的 Skills…"]}):j!=null&&j.modelMode&&h?o.jsxs("div",{className:"composer-command-empty",children:[o.jsx(du,{className:"spin"})," 正在读取模型…"]}):F.length===0?o.jsx("div",{className:"composer-command-empty",children:B?"当前工作区没有匹配的 Skill":j!=null&&j.modelMode?"没有匹配模型,也可以直接输入模型 ID":"没有匹配的快捷命令"}):o.jsx("div",{className:"composer-command-list",children:F.map((q,G)=>{const J=q.kind==="command"?`command:${q.command.name}`:q.kind==="model"?`model:${q.model.id}`:`skill:${q.skill.id}`,ue=q.kind==="command"?q.command.usage:q.kind==="model"?q.model.displayName:`$${q.skill.name}`,Oe=q.kind==="command"?q.command.description:q.kind==="model"?q.model.description||q.model.id:q.skill.description||"加载并执行该 Skill";return o.jsxs("button",{type:"button",role:"option","aria-selected":G===M,className:`composer-command-item${G===M?" is-active":""}`,onMouseDown:Qe=>{Qe.preventDefault(),K(q)},onMouseEnter:()=>I(G),children:[o.jsx("span",{className:`composer-command-icon composer-command-icon--${q.kind}`,"aria-hidden":"true",children:q.kind==="command"?"/":q.kind==="model"?"◇":"$"}),o.jsxs("span",{className:"composer-command-copy",children:[o.jsx("strong",{children:ue}),o.jsx("span",{children:Oe})]}),G===M?o.jsx("kbd",{children:"↵"}):null]},J)})})]}):null,o.jsx("div",{className:"composer-left-controls",children:!E&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"composer-menu-wrap",children:[o.jsx("button",{type:"button",className:"comp-icon",title:"添加","aria-label":"添加",disabled:s,onClick:()=>R(q=>!q),children:o.jsx(VAt,{className:"icon"})}),A?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"menu-scrim",onClick:()=>R(!1)}),o.jsxs("div",{className:"composer-menu",role:"menu",children:[o.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>se(_),children:[o.jsx(XAt,{className:"icon"}),"上传图片"]}),o.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>se(T),children:[o.jsx(GAt,{className:"icon"}),"上传文档或 PDF"]}),o.jsxs("button",{type:"button",className:"menu-item",disabled:d.uploadBusy,onClick:()=>se(C),children:[o.jsx(WAt,{className:"icon"}),"上传视频"]}),o.jsx("div",{className:"composer-menu-separator",role:"separator"}),o.jsxs("button",{type:"button",className:"menu-item",onClick:()=>{R(!1),d.onOpenTerminal()},children:[o.jsx(n0,{className:"icon"}),"进入终端"]}),o.jsxs("button",{type:"button",className:"menu-item",onClick:()=>{R(!1),d.onOpenBrowser()},children:[o.jsx(fwe,{className:"icon"}),"查看浏览器"]})]})]}):null]}),o.jsx("button",{type:"button",className:"comp-icon sandbox-composer-control",title:"Codex 权限","aria-label":"Codex 权限",disabled:d.settingsBusy||a,onClick:d.onOpenPermissions,children:o.jsx(TU,{})}),o.jsx("button",{type:"button",className:`comp-icon sandbox-composer-control${d.workspaceLocked?" is-locked":""}`,title:d.workspaceLocked?"对话已开始,工作空间已锁定":"选择工作空间","aria-label":"Codex 工作空间",disabled:d.settingsBusy||a,onClick:d.onOpenWorkspace,children:o.jsx(RT,{})}),d.endpointCopyEnabled&&d.onCopyEndpoint?o.jsx("button",{type:"button",className:"comp-icon sandbox-composer-control",title:d.endpointCopyState==="copied"?"Endpoint 已复制":"复制 Sandbox Endpoint","aria-label":d.endpointCopyState==="copied"?"Endpoint 已复制":"复制 Sandbox Endpoint",disabled:d.endpointCopyState==="copying",onClick:d.onCopyEndpoint,children:d.endpointCopyState==="copying"?o.jsx(du,{className:"spin"}):d.endpointCopyState==="copied"?o.jsx(JAt,{}):o.jsx(KAt,{})}):null]})}),o.jsxs("div",{className:"composer-input-stack sandbox-composer-input",children:[!E&&x.length>0?o.jsx($j,{skillPrefix:"$",value:{skills:x.map(({name:q,description:G})=>({name:q,description:G}))},onRemoveSkill:q=>S(x.filter(G=>G.name!==q))}):null,o.jsx("textarea",{ref:k,className:"comp-input scroll",rows:1,value:t,disabled:s,placeholder:E?"继续说明你想实现或调整的内容":"向 AgentKit 沙箱发送消息,输入 / 查看命令,输入 $ 调用 Skill…","aria-expanded":L,onChange:q=>V(q.target.value),onBlur:()=>window.setTimeout(()=>N(!0),0),onKeyDown:q=>{if(!SR(q.nativeEvent)){if(L){if((q.key==="ArrowDown"||q.key==="Tab"&&!q.shiftKey)&&F.length>0){q.preventDefault(),I(G=>(G+1)%F.length);return}if((q.key==="ArrowUp"||q.key==="Tab"&&q.shiftKey)&&F.length>0){q.preventDefault(),I(G=>(G-1+F.length)%F.length);return}if(q.key==="Enter"&&!q.shiftKey&&F[M]){q.preventDefault(),K(F[M]);return}if(q.key==="Escape"){q.preventDefault(),N(!0);return}}if(q.key==="Backspace"&&!t&&q.currentTarget.selectionStart===0&&x.length>0){q.preventDefault(),S(x.slice(0,-1));return}q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),Q&&r(t))}}})]}),o.jsx("button",{type:"button",className:"comp-send",disabled:z?!1:!Q,onClick:z?i:()=>r(t),"aria-label":z?"停止生成":"发送",title:z?"停止生成":void 0,children:z?o.jsx(qAt,{className:"icon"}):a?o.jsx(du,{className:"icon spin"}):o.jsx(HAt,{className:"icon"})})]}),o.jsx("input",{ref:_,type:"file",accept:"image/*",multiple:!0,hidden:!0,onChange:ge}),o.jsx("input",{ref:T,type:"file",accept:".txt,.md,.markdown,.pdf,text/plain,text/markdown,application/pdf",multiple:!0,hidden:!0,onChange:ge}),o.jsx("input",{ref:C,type:"file",accept:"video/mp4,video/webm,video/quicktime",multiple:!0,hidden:!0,onChange:ge})]})}function JDt(e){return e.trim().replace(/\/+$/,"")||window.location.origin}function ePt(e){return["使用 AgentKit Studio Plugin 端云接力当前会话、项目和任务。请直接执行,不要让我手动打开终端。",`Studio:${JDt(e.studioUrl)}`,`配对码:${e.pairingCode}`].join(`
`)}function pSe(){return["codex plugin marketplace add volcengine/veadk-python","--sparse .agents/plugins","--sparse plugins/agentkit-studio","&& codex plugin add agentkit-studio@veadk-python"].join(" ")}function tPt(){return["请安装 AgentKit Studio Plugin。请直接执行以下安装命令,不要让我手动打开终端。",`安装命令:${pSe()}`].join(`
`)}function xte(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m6.5 6.5 11 11M17.5 6.5l-11 11"})})}function vte(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("rect",{x:"8",y:"8",width:"11",height:"11",rx:"2"}),o.jsx("path",{d:"M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2"})]})}function g3(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m5 12.5 4.25 4.25L19 7"})})}function wte(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"M19 8a8 8 0 1 0 .35 7"}),o.jsx("path",{d:"M19 4v4h-4"})]})}function nPt(e,t){const n=Math.max(0,Math.ceil((Date.parse(e)-t)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),s=n%60;return[r,i,s].map(a=>String(a).padStart(2,"0")).join(":")}const rPt=[{id:"request",label:"等待端侧请求"},{id:"session",label:"创建云端 Session"},{id:"restore",label:"恢复项目"},{id:"continue",label:"发送续跑任务"}];function iPt(e){switch(e.state){case"issued":return 0;case"creating":return 1;case"session-created":return 2;case"continuing":return 3;case"running":return 4;case"completed":return 4;case"failed":return e.failedStage==="creating-session"?1:e.failedStage==="uploading-project"||e.failedStage==="restoring-project"?2:3}}function sPt(e,t){const n=iPt(e);return e.state==="failed"&&t===n?"failed":ttPt(),[]),M=p.useMemo(()=>pSe(),[]),I=p.useMemo(()=>h?ePt(h):"",[h]);if(p.useEffect(()=>{if(!e)return;m(null),b(null),f("conversation"),T(null),A(""),k(!1),S(Date.now());const H=new AbortController,z=++l.current;return x(!0),di.createCodexProjectHandoffPairing({signal:H.signal}).then(Q=>{l.current===z&&(m(Q),b({state:"issued",expireAt:Q.expireAt}))}).catch(Q=>{(Q==null?void 0:Q.name)!=="AbortError"&&l.current===z&&T({message:Q instanceof Error?Q.message:String(Q),retryPairing:!0})}).finally(()=>{l.current===z&&x(!1)}),()=>{H.abort()}},[y,e]),p.useEffect(()=>{if(!e||!h)return;S(Date.now());const H=window.setInterval(()=>S(Date.now()),1e3);return()=>window.clearInterval(H)},[e,h]),p.useEffect(()=>{if(!e||!h)return;let H=!1,z;const Q=new AbortController,V=async()=>{if(!(H||Date.now()>=Date.parse(h.expireAt))){try{const K=await di.getCodexProjectHandoffStatus(h.pairingCode,{signal:Q.signal});if(H||(b(K),K.state==="completed"||K.state==="failed"))return;z=window.setTimeout(()=>void V(),1500);return}catch(K){if((K==null?void 0:K.name)==="AbortError"||H)return;T({message:K instanceof Error?K.message:String(K),retryPairing:!1})}z=window.setTimeout(()=>void V(),1500)}};return V(),()=>{H=!0,Q.abort(),z!==void 0&&window.clearTimeout(z)}},[e,h]),p.useEffect(()=>{(g==null?void 0:g.state)!=="running"&&(g==null?void 0:g.state)!=="completed"||!h||u.current===h.pairingCode||(u.current=h.pairingCode,n())},[g==null?void 0:g.state,n,h]),p.useEffect(()=>()=>{c.current!==void 0&&window.clearTimeout(c.current)},[]),p.useEffect(()=>{if(!e)return;const H=document.body.style.overflow;document.body.style.overflow="hidden";const z=window.requestAnimationFrame(()=>{var V;return(V=s.current)==null?void 0:V.focus()}),Q=V=>{var ie;if(V.key==="Escape"){V.preventDefault(),a.current();return}if(V.key!=="Tab")return;const K=(ie=i.current)==null?void 0:ie.querySelectorAll('button:not(:disabled), input:not(:disabled), [tabindex]:not([tabindex="-1"])');if(!(K!=null&&K.length))return;const se=K[0],ge=K[K.length-1];V.shiftKey&&document.activeElement===se?(V.preventDefault(),ge.focus()):!V.shiftKey&&document.activeElement===ge&&(V.preventDefault(),se.focus())};return window.addEventListener("keydown",Q),()=>{window.cancelAnimationFrame(z),document.body.style.overflow=H,window.removeEventListener("keydown",Q)}},[e]),!e)return null;async function $(H,z){var Q;if(!(!H||C)){T(null),A(z);try{if(!((Q=navigator.clipboard)!=null&&Q.writeText))throw new Error("当前浏览器不支持写入剪贴板。");await navigator.clipboard.writeText(H),c.current!==void 0&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{A(V=>V===z?"":V),c.current=void 0},1400)}catch(V){A(""),T({message:V instanceof Error?V.message:String(V),retryPairing:!1})}}}async function N(){const H=g==null?void 0:g.sessionId;if(!(!H||E)){T(null),k(!0);try{await r(H)}catch(z){T({message:z instanceof Error?z.message:String(z),retryPairing:!1}),k(!1)}}}function j(H){var z;f(H),(z=document.getElementById(`sandbox-project-upload-install-${H}-tab`))==null||z.focus()}function B(H){const z=["conversation","terminal"],Q=z.indexOf(d);let V=null;H.key==="ArrowRight"&&(V=(Q+1)%z.length),H.key==="ArrowLeft"&&(V=(Q-1+z.length)%z.length),H.key==="Home"&&(V=0),H.key==="End"&&(V=z.length-1),V!==null&&(H.preventDefault(),j(z[V]))}const F=h?nPt(h.expireAt,w):"00:00:00",L=h?w>=Date.parse(h.expireAt):!1;return kr.createPortal(o.jsx("div",{className:"sandbox-project-upload-backdrop",onMouseDown:H=>{H.target===H.currentTarget&&t()},children:o.jsxs("section",{ref:i,className:"sandbox-project-upload-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"sandbox-project-upload-title","aria-describedby":"sandbox-project-upload-description",children:[o.jsxs("header",{className:"sandbox-project-upload-head",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"sandbox-project-upload-title-row",children:[o.jsx("h2",{id:"sandbox-project-upload-title",children:"接力到云端继续执行"}),o.jsx(sa,{className:"sandbox-project-upload-beta",color:"discovery",size:"sm",pill:!0,children:"Beta"})]}),o.jsx("p",{id:"sandbox-project-upload-description",children:"按顺序复制两段提示词,Codex 会通过插件将您的本地任务接力到云端"})]}),o.jsx("button",{ref:s,type:"button",className:"sandbox-project-upload-close",onClick:t,"aria-label":"关闭本地迁移引导",children:o.jsx(xte,{})})]}),o.jsxs("div",{className:"sandbox-project-upload-body",children:[_?o.jsxs("div",{className:"sandbox-project-upload-error",role:"alert",children:[o.jsx("span",{children:_.message}),_.retryPairing?o.jsxs("button",{type:"button",onClick:()=>O(H=>H+1),children:[o.jsx(wte,{}),"重试"]}):null]}):null,o.jsxs("section",{className:"sandbox-project-upload-stage",children:[o.jsxs("div",{className:"sandbox-project-upload-stage-head",children:[o.jsx("span",{className:"sandbox-project-upload-stage-number",children:"1"}),o.jsxs("div",{children:[o.jsx("h3",{children:"安装插件"}),o.jsx("p",{children:"首次使用时,请选择一种安装方式。"})]}),o.jsxs("button",{type:"button",onClick:()=>void $(d==="conversation"?R:M,d==="conversation"?"install-conversation":"install-terminal"),disabled:C!=="",children:[C===`install-${d}`?o.jsx(g3,{}):o.jsx(vte,{}),C===`install-${d}`?"已复制":d==="conversation"?"复制安装提示词":"复制安装命令"]})]}),o.jsxs("div",{className:`sandbox-project-upload-install-tabs is-${d}`,role:"tablist","aria-label":"插件安装方式",children:[o.jsx("span",{"aria-hidden":"true"}),o.jsx("button",{id:"sandbox-project-upload-install-conversation-tab",type:"button",role:"tab","aria-controls":"sandbox-project-upload-install-panel","aria-selected":d==="conversation",tabIndex:d==="conversation"?0:-1,onClick:()=>f("conversation"),onKeyDown:B,children:"与 Codex 对话安装"}),o.jsx("button",{id:"sandbox-project-upload-install-terminal-tab",type:"button",role:"tab","aria-controls":"sandbox-project-upload-install-panel","aria-selected":d==="terminal",tabIndex:d==="terminal"?0:-1,onClick:()=>f("terminal"),onKeyDown:B,children:"从终端安装"})]}),o.jsx("div",{id:"sandbox-project-upload-install-panel",className:`sandbox-project-upload-prompt${d==="terminal"?" is-command":""}`,role:"tabpanel","aria-labelledby":`sandbox-project-upload-install-${d}-tab`,children:o.jsx("pre",{tabIndex:0,children:o.jsx("code",{children:d==="conversation"?R:M})})})]}),o.jsxs("section",{className:"sandbox-project-upload-stage",children:[o.jsxs("div",{className:"sandbox-project-upload-stage-head",children:[o.jsx("span",{className:"sandbox-project-upload-stage-number",children:"2"}),o.jsxs("div",{children:[o.jsx("h3",{children:"任务接力"}),o.jsx("p",{children:"插件安装完成后复制,Codex 会迁移当前项目并继续执行任务。"})]}),o.jsxs("button",{type:"button",onClick:()=>void $(I,"handoff"),disabled:!I||v||C!=="",children:[C==="handoff"?o.jsx(g3,{}):o.jsx(vte,{}),C==="handoff"?"已复制":"复制接力提示词"]})]}),o.jsxs("div",{className:"sandbox-project-upload-pairing-notice",role:"status",children:[o.jsx("span",{children:v?"正在生成新的配对码":L?"配对码已过期":o.jsxs(o.Fragment,{children:["配对码有效期剩余 ",o.jsx("time",{children:F})]})}),o.jsxs("button",{type:"button",disabled:v,onClick:()=>O(H=>H+1),children:[o.jsx(wte,{}),v?"刷新中":"刷新配对码"]})]}),o.jsx("div",{className:"sandbox-project-upload-prompt",children:v?o.jsxs("div",{className:"sandbox-project-upload-loading",role:"status",children:[o.jsx("i",{"aria-hidden":"true"}),"正在生成配对码"]}):I?o.jsx("pre",{tabIndex:0,children:o.jsx("code",{children:I})}):o.jsx("div",{className:"sandbox-project-upload-loading",children:"配对码尚未生成。"})}),h&&g?o.jsxs("section",{className:"sandbox-project-upload-progress","aria-live":"polite","aria-label":"端云接力状态",children:[o.jsxs("header",{children:[o.jsxs("div",{children:[o.jsx("span",{children:"接力状态"}),g.state!=="issued"?o.jsxs("p",{children:["已收到",g.agentName?`“${g.agentName}”`:g.projectName?`“${g.projectName}”`:"当前项目","的端云接力请求"]}):o.jsx("p",{children:"复制接力提示词后,Codex 的请求会显示在这里。"})]}),o.jsx("strong",{"data-state":g.state,children:aPt(g)})]}),o.jsx("ol",{children:rPt.map((H,z)=>{const Q=sPt(g,z);return o.jsxs("li",{"data-state":Q,children:[o.jsxs("span",{className:"sandbox-project-upload-progress-marker",children:[Q==="done"?o.jsx(g3,{}):null,Q==="failed"?o.jsx(xte,{}):null]}),o.jsx("span",{children:H.label})]},H.id)})}),g.state==="failed"&&g.error?o.jsx("p",{className:"sandbox-project-upload-progress-error",role:"alert",children:g.error}):null]}):null]})]}),o.jsxs("footer",{className:"sandbox-project-upload-actions",children:[o.jsx("button",{type:"button",onClick:t,children:"关闭"}),((g==null?void 0:g.state)==="running"||(g==null?void 0:g.state)==="completed")&&g.sessionId?o.jsx("button",{type:"button",className:"is-primary",disabled:E,onClick:()=>void N(),children:E?"正在进入":"进入 Codex"}):null]})]})}),document.body)}function lPt({client:e=di,allowSkillSelection:t=!0,allowThreadManagement:n=!0,session:r,conversationBusy:i,onInputChange:s,onSessionPatch:a,onSnapshot:l,onActivity:c,onError:u}){const d=p.useRef((r==null?void 0:r.id)??""),f=p.useRef(0),h=p.useRef(null);d.current=(r==null?void 0:r.id)??"";const[m,g]=p.useState(!1),[b,y]=p.useState([]),[O,v]=p.useState(!1),[x,w]=p.useState(!1),[S,E]=p.useState([]),[k,_]=p.useState(!1),[T,C]=p.useState(!1),[A,R]=p.useState([]),[M,I]=p.useState(!1),[$,N]=p.useState([]),[j,B]=p.useState(!1),[F,L]=p.useState(""),[H,z]=p.useState(""),[Q,V]=p.useState("");p.useEffect(()=>{var Ae;(Ae=h.current)==null||Ae.abort(),h.current=null,f.current+=1,g(!1),y([]),v(!1),w(!1),E([]),_(!1),C(!1),R([]),I(!1),N([]),B(!1),L(""),z(""),V("")},[r==null?void 0:r.id]);const K=p.useCallback(async()=>{const Ae=d.current;if(!Ae)return[];v(!0);try{const Be=await e.listModels(Ae);return d.current===Ae&&(y(Be),w(!0)),Be}catch(Be){return d.current===Ae&&(w(!0),u(Be instanceof Error?Be.message:String(Be))),[]}finally{d.current===Ae&&v(!1)}},[e,u]),se=p.useCallback(async()=>{if(!t)return[];const Ae=d.current;if(!Ae)return[];_(!0);try{const Be=await e.listSkills(Ae);return d.current===Ae&&(E(Be),C(!0)),Be}catch(Be){return d.current===Ae&&(C(!0),u(Be instanceof Error?Be.message:String(Be))),[]}finally{d.current===Ae&&_(!1)}},[t,e,u]),ge=p.useCallback(async(Ae="",Be=!1)=>{var Ee;const he=d.current;if(!he)return;(Ee=h.current)==null||Ee.abort();const be=new AbortController;h.current=be;const Se=++f.current;B(!0),L("");try{const tt=await e.listThreads(he,Ae?{cursor:Ae}:{},{signal:be.signal});d.current===he&&f.current===Se&&(N(Ue=>{if(!Be)return tt.threads;const re=new Map(Ue.map(ce=>[ce.id,ce]));for(const ce of tt.threads)re.set(ce.id,ce);return[...re.values()]}),z(tt.nextCursor??""))}catch(tt){if((tt==null?void 0:tt.name)==="AbortError")return;d.current===he&&f.current===Se&&L(tt instanceof Error?tt.message:String(tt))}finally{h.current===be&&(h.current=null),d.current===he&&f.current===Se&&B(!1)}},[e]),ie=p.useCallback(()=>ge("",!1),[ge]),q=p.useCallback(async()=>{!H||j||await ge(H,!0)},[ge,j,H]),G=p.useCallback(async()=>{I(!0),await ie()},[ie]);p.useEffect(()=>{if(!(!n||!(r!=null&&r.id)))return ie(),()=>{var Ae;(Ae=h.current)==null||Ae.abort(),h.current=null,f.current+=1}},[n,ie,r==null?void 0:r.id]);function J(Ae){l(Ae),N(Be=>[Ae.thread,...Be.filter(he=>he.id!==Ae.thread.id)]),R([]),E([]),C(!1),I(!1)}async function ue(Ae){const Be=await e.newThread(Ae);d.current===Ae&&(J(Be),c("已新建 Codex 对话",[{label:"Thread",value:Be.threadId,code:!0}]))}async function Oe(){const Ae=d.current;if(!(!Ae||m||i)){g(!0),L(""),u("");try{await ue(Ae)}catch(Be){if(d.current===Ae){const he=Be instanceof Error?Be.message:String(Be);L(he),u(he)}}finally{d.current===Ae&&g(!1)}}}async function Qe(Ae){const Be=d.current;if(!(!Be||m||i)){if(Ae===(r==null?void 0:r.threadId)){I(!1);return}g(!0),u("");try{const he=await e.resumeThread(Be,Ae);if(d.current!==Be)return;J(he),c("已恢复 Codex 对话",[{label:"Thread",value:he.threadId,code:!0}])}catch(he){d.current===Be&&u(he instanceof Error?he.message:String(he))}finally{d.current===Be&&g(!1)}}}async function je(Ae){const Be=d.current;if(!Be||m||i)return!1;f.current+=1,B(!1),g(!0),V(Ae),L(""),u("");try{const he=await e.deleteThread(Be,Ae);return d.current!==Be?!1:(he.snapshot&&J(he.snapshot),N(be=>be.filter(Se=>Se.id!==Ae)),c("已删除 Codex 历史会话",[{label:"Thread",value:Ae,code:!0}]),!0)}catch(he){if(d.current===Be){const be=he instanceof Error?he.message:String(he);L(be),u(be)}return!1}finally{d.current===Be&&(g(!1),V(""))}}async function ze(Ae){const Be=r,he=Ae.trim();if(!he.startsWith("/"))return!1;if(!Be||i||m)return!0;const be=qDt(he),Se=be&&jR.find(Ee=>Ee.name===be.name);if(!be||!Se)return u(`未知快捷命令:${he.split(/\s/,1)[0]}。输入 /help 查看可用命令。`),!0;if(u(""),R([]),Se.name==="model"&&!be.argument)return s("/model "),x||await K(),!0;if(Se.name==="skill"||Se.name==="skills")return t?(s("$"),T||(await se()).length===0&&s(""),!0):(u("智能开发模式会自动使用开发能力,无需手动选择 Skill。"),!0);if(Se.name==="resume"&&!be.argument)return s(""),await G(),!0;s(""),g(!0);try{if(Se.name==="model"){const Ee=await e.setModel(Be.id,be.argument);if(d.current!==Be.id)return!0;a({model:Ee}),c("已切换 Codex 模型",[{label:"模型",value:Ee,code:!0}])}else if(Se.name==="models"){const Ee=x?b:await K();if(d.current!==Be.id)return!0;c(Ee.length>0?"Codex 可用模型":"当前没有可用模型",YDt(Ee,Be.model))}else if(Se.name==="new"||Se.name==="clear")await ue(Be.id);else if(Se.name==="resume"){const Ee=await e.resumeThread(Be.id,be.argument);if(d.current!==Be.id)return!0;J(Ee),c("已恢复 Codex 对话",[{label:"Thread",value:Ee.threadId,code:!0}])}else if(Se.name==="fork"){const Ee=await e.forkThread(Be.id);if(d.current!==Be.id)return!0;J(Ee),c("已分叉 Codex 对话",[{label:"Thread",value:Ee.threadId,code:!0}])}else if(Se.name==="compact"){if(await e.compactThread(Be.id),d.current!==Be.id)return!0;c("已开始压缩当前 Codex 对话",[{label:"Thread",value:Be.threadId,code:!0}])}else if(Se.name==="archive"){const Ee=Be.threadId,tt=await e.archiveThread(Be.id,Ee);if(d.current!==Be.id)return!0;tt.snapshot&&J(tt.snapshot),N(Ue=>Ue.filter(re=>re.id!==Ee)),c("已归档 Codex 对话",[{label:"Thread",value:Ee,code:!0}])}else if(Se.name==="status"){const Ee=await e.getStatus(Be.id);if(d.current!==Be.id)return!0;a(Ee),c("Codex 当前状态",ZDt(Ee))}else Se.name==="help"&&c("Sandbox 支持的 Codex 快捷命令",WDt())}catch(Ee){d.current===Be.id&&(s(he),u(Ee instanceof Error?Ee.message:String(Ee)))}finally{d.current===Be.id&&g(!1)}return!0}function Ge(){E([]),C(!1),R([])}return{commandBusy:m,models:b,modelsLoading:O,modelsLoaded:x,loadModels:K,skills:S,skillsLoading:k,skillsLoaded:T,loadSkills:se,selectedSkills:A,setSelectedSkills:R,invalidateSkills:Ge,threadsOpen:M,threads:$,threadsLoading:j,threadsError:F,threadsHasMore:!!H,threadActionId:Q,openThreads:G,refreshThreads:ie,loadMoreThreads:q,closeThreads:()=>{m||(I(!1),L(""))},newThread:Oe,resumeThread:Qe,deleteThread:je,executeSlash:ze}}const cPt={volcengine:"火山引擎 AgentKit 提供企业级 Agent 解决方案",byteplus:"BytePlus AgentKit 提供企业级 Agent 解决方案"},uPt={volcengine:"https://docs.volcengine.com/docs/86681/1925174?lang=zh",byteplus:"https://docs.byteplus.com/en/docs/legal"};function dPt(e){return e.toLowerCase()==="github"?o.jsx(KRe,{className:"icon"}):o.jsx(eIe,{className:"icon"})}function fPt({branding:e,cloudProvider:t,onUsername:n}){const[r,i]=p.useState(null),[s,a]=p.useState(""),[l,c]=p.useState(0),[u,d]=p.useState(""),f=p.useRef(null);p.useEffect(()=>{let y=!0;return i(null),a(""),Vae().then(O=>{y&&i(O)}).catch(O=>{y&&a(O instanceof Error?O.message:String(O))}),()=>{y=!1}},[l]);const h=r!==null&&r.length===0;p.useEffect(()=>{var y;h&&((y=f.current)==null||y.focus())},[h]);const m=gIe.test(u),g=t==="byteplus"?g7:rj,b=()=>{m&&n(u)};return o.jsxs("div",{className:"login",children:[o.jsx("header",{className:"login-top",children:o.jsxs("span",{className:"login-brand",children:[o.jsx("img",{className:"login-brand-logo",src:e.logoUrl||g,width:20,height:20,alt:"","aria-hidden":!0}),e.title]})}),o.jsx("main",{className:"login-main",children:o.jsxs("div",{className:"login-card",children:[o.jsx(wn,{as:"h1",className:"login-title",duration:4.8,spread:22,children:e.title}),s?o.jsxs("div",{className:"login-provider-error",role:"alert",children:[o.jsx("p",{children:s}),o.jsx("button",{type:"button",onClick:()=>c(y=>y+1),children:"重试"})]}):r===null?null:r.length>0?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"login-sub",children:"登录以继续使用"}),o.jsx("div",{className:"login-providers",children:r.map(y=>o.jsxs("button",{className:"login-btn",onClick:()=>yIe(y.loginUrl),children:[dPt(y.id),o.jsxs("span",{children:["使用 ",y.label," 登录"]})]},y.id))})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"login-sub",children:"输入一个用户名即可开始"}),o.jsxs("form",{className:"login-name",onSubmit:y=>{y.preventDefault(),b()},children:[o.jsx("input",{ref:f,className:"login-name-input",value:u,onChange:y=>d(y.target.value),placeholder:"用户名(字母 + 数字,最多 16 位)",maxLength:16}),o.jsx("button",{type:"submit",className:"login-name-go",disabled:!m,"aria-label":"进入",children:o.jsx(Ev,{className:"icon"})})]}),o.jsx("p",{className:"login-hint","aria-live":"polite",children:u&&!m?"只能包含大小写字母和数字,最多 16 位。":""})]}),o.jsx("p",{className:"login-powered",children:cPt[t]}),o.jsxs("p",{className:"login-legal",children:["继续即表示你已阅读并同意 AgentKit"," ",o.jsx("a",{href:uPt[t],target:"_blank",rel:"noreferrer",children:"产品和服务条款"})]})]})}),o.jsx("footer",{className:"login-footer",children:"© 2026 VeADK. All rights reserved."})]})}function hPt({open:e,checking:t,error:n,onLogin:r}){const i=p.useRef(null);return p.useEffect(()=>{var a;if(!e)return;const s=document.body.style.overflow;return document.body.style.overflow="hidden",(a=i.current)==null||a.focus(),()=>{document.body.style.overflow=s}},[e]),e?kr.createPortal(o.jsx("div",{className:"auth-expired-backdrop",children:o.jsxs("section",{className:"auth-expired-dialog",role:"alertdialog","aria-modal":"true","aria-labelledby":"auth-expired-title","aria-describedby":"auth-expired-description",children:[o.jsx("div",{className:"auth-expired-mark","aria-hidden":"true",children:o.jsx(Lae,{})}),o.jsxs("div",{className:"auth-expired-copy",children:[o.jsx("h2",{id:"auth-expired-title",children:"登录状态已过期"}),o.jsx("p",{id:"auth-expired-description",children:"当前编辑内容会保留。重新登录后,刚才的操作将自动继续。"}),n&&o.jsx("p",{className:"auth-expired-error",role:"alert",children:n})]}),o.jsx("footer",{className:"auth-expired-actions",children:o.jsx("button",{ref:i,type:"button",onClick:r,disabled:t,children:t?"等待登录完成…":"重新登录"})})]})}),document.body):null}const pPt=[{value:"slow",label:"执行速度慢"},{value:"crash",label:"运行崩溃"},{value:"incorrect",label:"结果不准确"},{value:"tool_error",label:"工具调用失败"},{value:"other",label:"其他问题"}];function mPt(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"m7 7 10 10"}),o.jsx("path",{d:"m17 7-10 10"})]})}function gPt(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m5 12.5 4.2 4.2L19 7"})})}function bPt({onClose:e,onSubmit:t}){const n=p.useId(),r=p.useId(),i=p.useRef(null),s=p.useRef(null),a=p.useRef(!1),l=p.useRef(e),[c,u]=p.useState(()=>new Set),[d,f]=p.useState(""),[h,m]=p.useState(!1),[g,b]=p.useState(""),[y,O]=p.useState(!1);a.current=h,l.current=e,p.useEffect(()=>{var _;const S=document.body.style.overflow,E=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(_=s.current)==null||_.focus();const k=T=>{var M;if(T.key==="Escape"&&!a.current){T.preventDefault(),l.current();return}if(T.key!=="Tab")return;const C=Array.from(((M=i.current)==null?void 0:M.querySelectorAll("button:not(:disabled), textarea:not(:disabled)"))??[]);if(C.length===0)return;const A=C[0],R=C[C.length-1];T.shiftKey&&document.activeElement===A?(T.preventDefault(),R.focus()):!T.shiftKey&&document.activeElement===R&&(T.preventDefault(),A.focus())};return window.addEventListener("keydown",k),()=>{document.body.style.overflow=S,window.removeEventListener("keydown",k),E!=null&&E.isConnected&&E.focus()}},[]);const v=S=>{u(E=>{const k=new Set(E);return k.has(S)?k.delete(S):k.add(S),k})},x=async()=>{if(!(h||y)){m(!0),b("");try{await t({issues:[...c],description:d.trim()}),O(!0)}catch(S){b(S instanceof Error?S.message:String(S))}finally{m(!1)}}},w=c.size>0||d.trim().length>0;return kr.createPortal(o.jsx("div",{className:"issue-feedback-backdrop",onMouseDown:S=>{S.target===S.currentTarget&&!h&&e()},children:o.jsxs("section",{ref:i,className:"issue-feedback-dialog",role:"dialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":y?`${r}-success`:r,"aria-busy":h||void 0,children:[o.jsxs("header",{className:"issue-feedback-head",children:[o.jsx("h2",{id:n,children:"问题反馈"}),o.jsx("button",{type:"button",className:"issue-feedback-close",onClick:e,disabled:h,"aria-label":"关闭问题反馈",children:o.jsx(mPt,{})})]}),y?o.jsxs("div",{className:"issue-feedback-success",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"issue-feedback-success-mark","aria-hidden":"true",children:o.jsx(gPt,{})}),o.jsxs("div",{children:[o.jsx("h3",{children:"上报成功,感谢您的反馈"}),o.jsx("p",{id:`${r}-success`,children:"AgentKit 团队会尽快查看您提交的问题。"})]})]}):o.jsxs("div",{className:"issue-feedback-body",children:[o.jsx("p",{id:r,className:"issue-feedback-intro",children:"请选择遇到的问题,也可以补充具体表现。"}),o.jsx("p",{className:"issue-feedback-privacy",role:"alert",children:"您的对话数据将会上报到 AgentKit 团队,请注意隐私保护。"}),o.jsx("div",{className:"issue-feedback-chips","aria-label":"常见问题",children:pPt.map(S=>o.jsx("button",{type:"button",className:"issue-feedback-chip","aria-pressed":c.has(S.value),onClick:()=>v(S.value),disabled:h,children:S.label},S.value))}),o.jsxs("label",{className:"issue-feedback-field",children:[o.jsx("span",{children:"问题描述"}),o.jsx("textarea",{ref:s,value:d,onChange:S=>f(S.target.value),placeholder:"请描述问题发生时的表现(选填)",maxLength:4e3,rows:5,disabled:h})]}),g&&o.jsx("p",{className:"issue-feedback-error",role:"alert",children:g})]}),o.jsx("footer",{className:"issue-feedback-actions",children:y?o.jsx("button",{type:"button",className:"is-primary",onClick:e,children:"完成"}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",onClick:e,disabled:h,children:"取消"}),o.jsx("button",{type:"button",className:"is-primary",onClick:()=>void x(),disabled:!w||h,children:h?"正在上报…":"提交反馈"})]})})]})}),document.body)}function yPt(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const OPt=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Pp(e){const t=[];for(let n=0,r=e.length;nxl||e.height>xl)&&(e.width>xl&&e.height>xl?e.width>e.height?(e.height*=xl/e.width,e.width=xl):(e.width*=xl/e.height,e.height=xl):e.width>xl?(e.height*=xl/e.width,e.width=xl):(e.width*=xl/e.height,e.height=xl))}function EPt(e,t={}){return e.toBlob?new Promise(n=>{e.toBlob(n,t.type?t.type:"image/png",t.quality?t.quality:1)}):new Promise(n=>{const r=window.atob(e.toDataURL(t.type?t.type:void 0,t.quality?t.quality:void 0).split(",")[1]),i=r.length,s=new Uint8Array(i);for(let a=0;a{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function kPt(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function _Pt(e,t,n){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),i.appendChild(s),s.appendChild(e),kPt(i)}const el=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||el(n,t)};function TPt(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function CPt(e,t){return mSe(t).map(n=>{const r=e.getPropertyValue(n),i=e.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function APt(e,t,n,r){const i=`.${e}:${t}`,s=n.cssText?TPt(n):CPt(n,r);return document.createTextNode(`${i}{${s}}`)}function Ste(e,t,n,r){const i=window.getComputedStyle(e,n),s=i.getPropertyValue("content");if(s===""||s==="none")return;const a=OPt();try{t.className=`${t.className} ${a}`}catch{return}const l=document.createElement("style");l.appendChild(APt(a,n,i,r)),t.appendChild(l)}function NPt(e,t,n){Ste(e,t,":before",n),Ste(e,t,":after",n)}const Ete="application/font-woff",kte="image/jpeg",jPt={woff:Ete,woff2:Ete,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:kte,jpeg:kte,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function RPt(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function LU(e){const t=RPt(e).toLowerCase();return jPt[t]||""}function IPt(e){return e.split(/,/)[1]}function m$(e){return e.search(/^(data:)/)!==-1}function DPt(e,t){return`data:${t};base64,${e}`}async function bSe(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((s,a)=>{const l=new FileReader;l.onerror=a,l.onloadend=()=>{try{s(n({res:r,result:l.result}))}catch(c){a(c)}},l.readAsDataURL(i)})}const b3={};function PPt(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function $U(e,t,n){const r=PPt(e,t,n.includeQueryParams);if(b3[r]!=null)return b3[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const s=await bSe(e,n.fetchRequestInit,({res:a,result:l})=>(t||(t=a.headers.get("Content-Type")||""),IPt(l)));i=DPt(s,t)}catch(s){i=n.imagePlaceholder||"";let a=`Failed to fetch resource: ${e}`;s&&(a=typeof s=="string"?s:s.message),a&&console.warn(a)}return b3[r]=i,i}async function MPt(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):tN(t)}async function LPt(e,t){if(e.currentSrc){const s=document.createElement("canvas"),a=s.getContext("2d");s.width=e.clientWidth,s.height=e.clientHeight,a==null||a.drawImage(e,0,0,s.width,s.height);const l=s.toDataURL();return tN(l)}const n=e.poster,r=LU(n),i=await $U(n,r,t);return tN(i)}async function $Pt(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await RR(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function BPt(e,t){return el(e,HTMLCanvasElement)?MPt(e):el(e,HTMLVideoElement)?LPt(e,t):el(e,HTMLIFrameElement)?$Pt(e,t):e.cloneNode(ySe(e))}const QPt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",ySe=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function UPt(e,t,n){var r,i;if(ySe(t))return t;let s=[];return QPt(e)&&e.assignedNodes?s=Pp(e.assignedNodes()):el(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?s=Pp(e.contentDocument.body.childNodes):s=Pp(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),s.length===0||el(e,HTMLVideoElement)||await s.reduce((a,l)=>a.then(()=>RR(l,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function FPt(e,t,n){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):mSe(n).forEach(s=>{let a=i.getPropertyValue(s);s==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),el(e,HTMLIFrameElement)&&s==="display"&&a==="inline"&&(a="block"),s==="d"&&t.getAttribute("d")&&(a=`path(${t.getAttribute("d")})`),r.setProperty(s,a,i.getPropertyPriority(s))})}function zPt(e,t){el(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),el(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function VPt(e,t){if(el(e,HTMLSelectElement)){const n=t,r=Array.from(n.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function HPt(e,t,n){return el(t,Element)&&(FPt(e,t,n),NPt(e,t,n),zPt(e,t),VPt(e,t)),t}async function qPt(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let s=0;sBPt(r,t)).then(r=>UPt(e,r,t)).then(r=>HPt(e,r,t)).then(r=>qPt(r,t))}const OSe=/url\((['"]?)([^'"]+?)\1\)/g,XPt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,GPt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function WPt(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function YPt(e){const t=[];return e.replace(OSe,(n,r,i)=>(t.push(i),n)),t.filter(n=>!m$(n))}async function ZPt(e,t,n,r,i){try{const s=n?yPt(t,n):t,a=LU(t);let l;return i||(l=await $U(s,a,r)),e.replace(WPt(t),`$1${l}$3`)}catch{}return e}function KPt(e,{preferredFontFormat:t}){return t?e.replace(GPt,n=>{for(;;){const[r,,i]=XPt.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function xSe(e){return e.search(OSe)!==-1}async function vSe(e,t,n){if(!xSe(e))return e;const r=KPt(e,n);return YPt(r).reduce((s,a)=>s.then(l=>ZPt(l,a,t,n)),Promise.resolve(r))}async function cb(e,t,n){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const s=await vSe(i,null,n);return t.style.setProperty(e,s,t.style.getPropertyPriority(e)),!0}return!1}async function JPt(e,t){await cb("background",e,t)||await cb("background-image",e,t),await cb("mask",e,t)||await cb("-webkit-mask",e,t)||await cb("mask-image",e,t)||await cb("-webkit-mask-image",e,t)}async function e3t(e,t){const n=el(e,HTMLImageElement);if(!(n&&!m$(e.src))&&!(el(e,SVGImageElement)&&!m$(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,i=await $U(r,LU(r),t);await new Promise((s,a)=>{e.onload=s,e.onerror=t.onImageErrorHandler?(...c)=>{try{s(t.onImageErrorHandler(...c))}catch(u){a(u)}}:a;const l=e;l.decode&&(l.decode=s),l.loading==="lazy"&&(l.loading="eager"),n?(e.srcset="",e.src=i):e.href.baseVal=i})}async function t3t(e,t){const r=Pp(e.childNodes).map(i=>wSe(i,t));await Promise.all(r).then(()=>e)}async function wSe(e,t){el(e,Element)&&(await JPt(e,t),await e3t(e,t),await t3t(e,t))}function n3t(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),e}const _te={};async function Tte(e){let t=_te[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},_te[e]=t,t}async function Cte(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(n.match(/url\([^)]+\)/g)||[]).map(async a=>{let l=a.replace(r,"$1");return l.startsWith("https://")||(l=new URL(l,e.url).href),bSe(l,t.fetchRequestInit,({result:c})=>(n=n.replace(a,`url(${c})`),[a,c]))});return Promise.all(s).then(()=>n)}function Ate(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=i.exec(r);if(c===null)break;t.push(c[0])}r=r.replace(i,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",l=new RegExp(a,"gi");for(;;){let c=s.exec(r);if(c===null){if(c=l.exec(r),c===null)break;s.lastIndex=l.lastIndex}else l.lastIndex=s.lastIndex;t.push(c[0])}return t}async function r3t(e,t){const n=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{Pp(i.cssRules||[]).forEach((s,a)=>{if(s.type===CSSRule.IMPORT_RULE){let l=a+1;const c=s.href,u=Tte(c).then(d=>Cte(d,t)).then(d=>Ate(d).forEach(f=>{try{i.insertRule(f,f.startsWith("@import")?l+=1:i.cssRules.length)}catch(h){console.error("Error inserting rule from remote css",{rule:f,error:h})}})).catch(d=>{console.error("Error loading remote css",d.toString())});r.push(u)}})}catch(s){const a=e.find(l=>l.href==null)||document.styleSheets[0];i.href!=null&&r.push(Tte(i.href).then(l=>Cte(l,t)).then(l=>Ate(l).forEach(c=>{a.insertRule(c,a.cssRules.length)})).catch(l=>{console.error("Error loading remote stylesheet",l)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{Pp(i.cssRules||[]).forEach(s=>{n.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${i.href}`,s)}}),n))}function i3t(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>xSe(t.style.getPropertyValue("src")))}async function s3t(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Pp(e.ownerDocument.styleSheets),r=await r3t(n,t);return i3t(r)}function SSe(e){return e.trim().replace(/["']/g,"")}function a3t(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(SSe(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&n(s)})}return n(e),t}async function o3t(e,t){const n=await s3t(e,t),r=a3t(e);return(await Promise.all(n.filter(s=>r.has(SSe(s.style.fontFamily))).map(s=>{const a=s.parentStyleSheet?s.parentStyleSheet.href:null;return vSe(s.cssText,a,t)}))).join(`
-`)}async function l3t(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await o3t(e,t);if(n){const r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function c3t(e,t={}){const{width:n,height:r}=gSe(e,t),i=await RR(e,t,!0);return await l3t(i,t),await wSe(i,t),n3t(i,t),await _Pt(i,n,r)}async function u3t(e,t={}){const{width:n,height:r}=gSe(e,t),i=await c3t(e,t),s=await tN(i),a=document.createElement("canvas"),l=a.getContext("2d"),c=t.pixelRatio||wPt(),u=t.canvasWidth||n,d=t.canvasHeight||r;return a.width=u*c,a.height=d*c,t.skipAutoScale||SPt(a),a.style.width=`${u}`,a.style.height=`${d}`,t.backgroundColor&&(l.fillStyle=t.backgroundColor,l.fillRect(0,0,a.width,a.height)),l.drawImage(s,0,0,a.width,a.height),a}async function d3t(e,t={}){const n=await u3t(e,t);return await EPt(n)}const f3t=16384,h3t=32e6,v_=10;function p3t(){return new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function m3t(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"m7 7 10 10"}),o.jsx("path",{d:"m17 7-10 10"})]})}function g3t(){const e=getComputedStyle(document.documentElement).getPropertyValue("--background").trim();return e?`hsl(${e})`:"white"}function b3t(e,t){const n=Math.min(Math.max(window.devicePixelRatio||1,1),2),r=f3t/Math.max(e,t),i=Math.sqrt(h3t/Math.max(e*t,1));return Math.min(n,r,i)}function y3t(e){const t=e.closest(".transcript");if(!t)return[e];const n=Array.from(t.children).filter(i=>i instanceof HTMLElement&&i.matches(".turn--user, .turn--assistant")),r=n.indexOf(e);return r>=0?n.slice(0,r+1):[e]}function O3t(e){const t=document.createElement("section");t.className="share-message-export",t.setAttribute("aria-hidden","true");for(const r of y3t(e)){const i=r.cloneNode(!0);i.removeAttribute("data-share-message-source"),i.classList.remove("is-feedback-target"),i.style.opacity="1",i.style.transform="none",i.style.animation="none",i.querySelectorAll("[data-share-image-exclude]").forEach(s=>s.remove()),t.append(i)}const n=document.createElement("p");return n.className="share-message-export-note",n.textContent="上述会话由 AgentKit Studio 导出,仅供参考",t.append(n),document.body.append(t),t}async function x3t(e){var n;(n=document.fonts)!=null&&n.ready&&await document.fonts.ready;const t=O3t(e);try{const r=Math.ceil(t.scrollWidth),i=Math.ceil(t.scrollHeight),s=b3t(r,i);if(s<.2)throw new Error("当前会话过长,暂时无法生成单张图片。");const a=await d3t(t,{width:r,height:i,pixelRatio:s,backgroundColor:g3t(),cacheBust:!0,style:{position:"static",top:"auto",left:"auto",width:`${r}px`,height:`${i}px`,margin:"0",overflow:"visible",animation:"none"}});if(!a)throw new Error("图片生成失败,请重试。");return a}finally{t.remove()}}function v3t(e){return`agentkit-conversation-${new Date().toISOString().replace(/[:.]/g,"-")}${e==="pdf"?".pdf":".png"}`}function w3t(e){return new Promise((t,n)=>{const r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t(i)},i.onerror=()=>{URL.revokeObjectURL(r),n(new Error("无法读取会话图片,请重试。"))},i.src=r})}function S3t(e,t,n){const r=Math.min(n-t,Math.max(96,Math.round((n-t)*.16))),i=Math.max(t+1,n-r),s=document.createElement("canvas");s.width=e.naturalWidth,s.height=n-i;const a=s.getContext("2d",{willReadFrequently:!0});if(!a||s.height<4)return n;a.drawImage(e,0,i,e.naturalWidth,s.height,0,0,e.naturalWidth,s.height);const l=a.getImageData(0,0,s.width,s.height).data,c=u=>{const d=u*s.width*4,f=l[d],h=l[d+1],m=l[d+2];let g=0;for(let b=0;b42&&(g+=1)}return g<=Math.max(2,Math.floor(s.width/300))};for(let u=s.height-1;u>=3;u-=1)if(c(u)&&c(u-1)&&c(u-2)&&c(u-3))return i+u-1;return n}async function E3t(e){const[{jsPDF:t},n]=await Promise.all([fd(()=>import("../chunks/jspdf.es.min-DdJSjEtu.js").then(f=>f.j),[]),w3t(e)]),r=new t({orientation:"portrait",unit:"mm",format:"a4",compress:!0}),i=r.internal.pageSize.getWidth(),s=r.internal.pageSize.getHeight(),a=i-v_*2,l=s-v_*2,c=Math.max(1,Math.floor(n.naturalWidth*l/a));let u=0,d=0;for(;u0&&r.addPage(),r.addImage(y,"PNG",v_,v_,a,O,`conversation-export-${d}`,"FAST"),g.width=0,g.height=0,u=h,d+=1}return new Blob([r.output("arraybuffer")],{type:"application/pdf"})}function k3t(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.append(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}function _3t({targetTurn:e,onClose:t}){const n=p.useId(),r=p.useId(),i=p.useId(),s=p.useRef(null),a=p.useRef(null),l=p.useRef(t),c=p.useRef(void 0),u=p.useRef(!0),[d,f]=p.useState("generating"),[h,m]=p.useState(0),[g,b]=p.useState(null),[y,O]=p.useState(""),[v,x]=p.useState(""),[w,S]=p.useState("idle"),[E,k]=p.useState("idle"),[_,T]=p.useState("png");l.current=t,p.useEffect(()=>{var j;u.current=!0;const I=document.body.style.overflow,$=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(j=a.current)==null||j.focus();const N=B=>{var z;if(B.key==="Escape"){B.preventDefault(),l.current();return}if(B.key!=="Tab")return;const F=Array.from(((z=s.current)==null?void 0:z.querySelectorAll("button:not(:disabled)"))??[]);if(F.length===0)return;const L=F[0],H=F[F.length-1];B.shiftKey&&document.activeElement===L?(B.preventDefault(),H.focus()):!B.shiftKey&&document.activeElement===H&&(B.preventDefault(),L.focus())};return window.addEventListener("keydown",N),()=>{u.current=!1,document.body.style.overflow=I,window.removeEventListener("keydown",N),c.current!==void 0&&window.clearTimeout(c.current),$!=null&&$.isConnected&&$.focus()}},[]),p.useEffect(()=>{let I=!1,$="";return f("generating"),b(null),O(""),x(""),S("idle"),(async()=>{try{if(await p3t(),I)return;const j=await x3t(e);if($=URL.createObjectURL(j),I){URL.revokeObjectURL($);return}b(j),O($),f("ready")}catch(j){if(I)return;f("error"),x(j instanceof Error?j.message:String(j))}})(),()=>{I=!0,$&&URL.revokeObjectURL($)}},[h,e]);const C=async()=>{var I;if(!(!g||w==="copying")){S("copying"),x("");try{if(!((I=navigator.clipboard)!=null&&I.write)||typeof ClipboardItem>"u")throw new Error("当前浏览器不支持复制图片,请下载后使用。");await navigator.clipboard.write([new ClipboardItem({"image/png":g})]),S("copied"),c.current=window.setTimeout(()=>S("idle"),1500)}catch($){S("idle"),x($ instanceof Error?$.message:String($))}}},A=I=>{T(I),S("idle"),x("")},R=(I,$)=>{var L,H;const N=["png","pdf"],j=N.indexOf($);let B=j;if(I.key==="ArrowRight"||I.key==="ArrowDown")B=(j+1)%N.length;else if(I.key==="ArrowLeft"||I.key==="ArrowUp")B=(j-1+N.length)%N.length;else if(I.key==="Home")B=0;else if(I.key==="End")B=N.length-1;else return;I.preventDefault();const F=N[B];A(F),(H=(L=s.current)==null?void 0:L.querySelector(`[data-export-format="${F}"]`))==null||H.focus()},M=async()=>{if(!(!g||E==="downloading")){k("downloading"),x("");try{const I=_==="pdf"?await E3t(g):g;k3t(I,v3t(_))}catch(I){u.current&&x(I instanceof Error?I.message:"导出失败,请重试。")}finally{u.current&&k("idle")}}};return kr.createPortal(o.jsx("div",{className:"share-message-backdrop",onMouseDown:I=>{I.target===I.currentTarget&&t()},children:o.jsxs("section",{ref:s,className:"share-message-dialog",role:"dialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":r,"aria-busy":d==="generating"||E==="downloading",children:[o.jsxs("header",{className:"share-message-head",children:[o.jsxs("div",{children:[o.jsx("h2",{id:n,children:"导出会话"}),o.jsx("p",{id:r,children:"选择格式并下载截至当前回复的全部输入与输出。"})]}),o.jsx("button",{ref:a,type:"button",className:"share-message-close","aria-label":"关闭",title:"关闭",onClick:t,children:o.jsx(m3t,{})})]}),o.jsxs("div",{className:"share-message-body",children:[d==="generating"?o.jsx("div",{className:"share-message-generating",role:"status",children:o.jsx(wn,{children:"正在生成导出内容…"})}):d==="error"?o.jsxs("div",{className:"share-message-failure",children:[o.jsx("p",{role:"alert",children:v||"图片生成失败,请重试。"}),o.jsx("button",{type:"button",onClick:()=>m(I=>I+1),children:"重试生成"})]}):o.jsx("div",{className:"share-message-preview",children:o.jsx("img",{src:y,alt:"会话导出内容预览"})}),d!=="error"&&v&&o.jsx("p",{className:"share-message-error",role:"alert",children:v})]}),o.jsxs("div",{className:"share-message-options",children:[o.jsx("span",{id:i,className:"share-message-format-label",children:"导出格式"}),o.jsx("div",{className:"share-message-format",role:"radiogroup","aria-labelledby":i,children:["png","pdf"].map(I=>o.jsx("button",{type:"button",role:"radio","data-export-format":I,className:_===I?"is-active":"","aria-checked":_===I,tabIndex:_===I?0:-1,disabled:E==="downloading",onClick:()=>A(I),onKeyDown:$=>R($,I),children:I.toUpperCase()},I))})]}),o.jsxs("footer",{className:"share-message-actions",children:[o.jsx("span",{className:"share-message-download-status","aria-live":"polite",children:E==="downloading"?`正在生成 ${_.toUpperCase()}…`:""}),_==="png"&&o.jsx("button",{type:"button",onClick:()=>void C(),disabled:!g||d!=="ready"||w==="copying",children:w==="copying"?"正在复制…":w==="copied"?"已复制":"复制图片"}),o.jsx("button",{type:"button",className:"is-primary",onClick:()=>void M(),disabled:!g||d!=="ready"||E==="downloading",children:E==="downloading"?"正在生成…":`下载 ${_.toUpperCase()}`})]})]})}),document.body)}const T3t=2e3,C3t=700,ESe=1200;function BU(e,t){const n=Array.from(e);return n.length<=t?e:`${n.slice(0,t-1).join("").trimEnd()}…`}function kSe(e){return BU(e.trim(),C3t)}function _Se(e){return BU(e,ESe)}function Nte(e){return e.trim().length>0}function A3t(e,t){const n=kSe(e),r=_Se(t.trim());return BU(`选中片段:${n}
+`)}async function l3t(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await o3t(e,t);if(n){const r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function c3t(e,t={}){const{width:n,height:r}=gSe(e,t),i=await RR(e,t,!0);return await l3t(i,t),await wSe(i,t),n3t(i,t),await _Pt(i,n,r)}async function u3t(e,t={}){const{width:n,height:r}=gSe(e,t),i=await c3t(e,t),s=await tN(i),a=document.createElement("canvas"),l=a.getContext("2d"),c=t.pixelRatio||wPt(),u=t.canvasWidth||n,d=t.canvasHeight||r;return a.width=u*c,a.height=d*c,t.skipAutoScale||SPt(a),a.style.width=`${u}`,a.style.height=`${d}`,t.backgroundColor&&(l.fillStyle=t.backgroundColor,l.fillRect(0,0,a.width,a.height)),l.drawImage(s,0,0,a.width,a.height),a}async function d3t(e,t={}){const n=await u3t(e,t);return await EPt(n)}const f3t=16384,h3t=32e6,v_=10;function p3t(){return new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function m3t(e){return o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round","aria-hidden":"true",...e,children:[o.jsx("path",{d:"m7 7 10 10"}),o.jsx("path",{d:"m17 7-10 10"})]})}function g3t(){const e=getComputedStyle(document.documentElement).getPropertyValue("--background").trim();return e?`hsl(${e})`:"white"}function b3t(e,t){const n=Math.min(Math.max(window.devicePixelRatio||1,1),2),r=f3t/Math.max(e,t),i=Math.sqrt(h3t/Math.max(e*t,1));return Math.min(n,r,i)}function y3t(e){const t=e.closest(".transcript");if(!t)return[e];const n=Array.from(t.children).filter(i=>i instanceof HTMLElement&&i.matches(".turn--user, .turn--assistant")),r=n.indexOf(e);return r>=0?n.slice(0,r+1):[e]}function O3t(e){const t=document.createElement("section");t.className="share-message-export",t.setAttribute("aria-hidden","true");for(const r of y3t(e)){const i=r.cloneNode(!0);i.removeAttribute("data-share-message-source"),i.classList.remove("is-feedback-target"),i.style.opacity="1",i.style.transform="none",i.style.animation="none",i.querySelectorAll("[data-share-image-exclude]").forEach(s=>s.remove()),t.append(i)}const n=document.createElement("p");return n.className="share-message-export-note",n.textContent="上述会话由 AgentKit Studio 导出,仅供参考",t.append(n),document.body.append(t),t}async function x3t(e){var n;(n=document.fonts)!=null&&n.ready&&await document.fonts.ready;const t=O3t(e);try{const r=Math.ceil(t.scrollWidth),i=Math.ceil(t.scrollHeight),s=b3t(r,i);if(s<.2)throw new Error("当前会话过长,暂时无法生成单张图片。");const a=await d3t(t,{width:r,height:i,pixelRatio:s,backgroundColor:g3t(),cacheBust:!0,style:{position:"static",top:"auto",left:"auto",width:`${r}px`,height:`${i}px`,margin:"0",overflow:"visible",animation:"none"}});if(!a)throw new Error("图片生成失败,请重试。");return a}finally{t.remove()}}function v3t(e){return`agentkit-conversation-${new Date().toISOString().replace(/[:.]/g,"-")}${e==="pdf"?".pdf":".png"}`}function w3t(e){return new Promise((t,n)=>{const r=URL.createObjectURL(e),i=new Image;i.onload=()=>{URL.revokeObjectURL(r),t(i)},i.onerror=()=>{URL.revokeObjectURL(r),n(new Error("无法读取会话图片,请重试。"))},i.src=r})}function S3t(e,t,n){const r=Math.min(n-t,Math.max(96,Math.round((n-t)*.16))),i=Math.max(t+1,n-r),s=document.createElement("canvas");s.width=e.naturalWidth,s.height=n-i;const a=s.getContext("2d",{willReadFrequently:!0});if(!a||s.height<4)return n;a.drawImage(e,0,i,e.naturalWidth,s.height,0,0,e.naturalWidth,s.height);const l=a.getImageData(0,0,s.width,s.height).data,c=u=>{const d=u*s.width*4,f=l[d],h=l[d+1],m=l[d+2];let g=0;for(let b=0;b42&&(g+=1)}return g<=Math.max(2,Math.floor(s.width/300))};for(let u=s.height-1;u>=3;u-=1)if(c(u)&&c(u-1)&&c(u-2)&&c(u-3))return i+u-1;return n}async function E3t(e){const[{jsPDF:t},n]=await Promise.all([fd(()=>import("../chunks/jspdf.es.min-CKI8Ibko.js").then(f=>f.j),[]),w3t(e)]),r=new t({orientation:"portrait",unit:"mm",format:"a4",compress:!0}),i=r.internal.pageSize.getWidth(),s=r.internal.pageSize.getHeight(),a=i-v_*2,l=s-v_*2,c=Math.max(1,Math.floor(n.naturalWidth*l/a));let u=0,d=0;for(;u0&&r.addPage(),r.addImage(y,"PNG",v_,v_,a,O,`conversation-export-${d}`,"FAST"),g.width=0,g.height=0,u=h,d+=1}return new Blob([r.output("arraybuffer")],{type:"application/pdf"})}function k3t(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.style.display="none",document.body.append(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}function _3t({targetTurn:e,onClose:t}){const n=p.useId(),r=p.useId(),i=p.useId(),s=p.useRef(null),a=p.useRef(null),l=p.useRef(t),c=p.useRef(void 0),u=p.useRef(!0),[d,f]=p.useState("generating"),[h,m]=p.useState(0),[g,b]=p.useState(null),[y,O]=p.useState(""),[v,x]=p.useState(""),[w,S]=p.useState("idle"),[E,k]=p.useState("idle"),[_,T]=p.useState("png");l.current=t,p.useEffect(()=>{var j;u.current=!0;const I=document.body.style.overflow,$=document.activeElement instanceof HTMLElement?document.activeElement:null;document.body.style.overflow="hidden",(j=a.current)==null||j.focus();const N=B=>{var z;if(B.key==="Escape"){B.preventDefault(),l.current();return}if(B.key!=="Tab")return;const F=Array.from(((z=s.current)==null?void 0:z.querySelectorAll("button:not(:disabled)"))??[]);if(F.length===0)return;const L=F[0],H=F[F.length-1];B.shiftKey&&document.activeElement===L?(B.preventDefault(),H.focus()):!B.shiftKey&&document.activeElement===H&&(B.preventDefault(),L.focus())};return window.addEventListener("keydown",N),()=>{u.current=!1,document.body.style.overflow=I,window.removeEventListener("keydown",N),c.current!==void 0&&window.clearTimeout(c.current),$!=null&&$.isConnected&&$.focus()}},[]),p.useEffect(()=>{let I=!1,$="";return f("generating"),b(null),O(""),x(""),S("idle"),(async()=>{try{if(await p3t(),I)return;const j=await x3t(e);if($=URL.createObjectURL(j),I){URL.revokeObjectURL($);return}b(j),O($),f("ready")}catch(j){if(I)return;f("error"),x(j instanceof Error?j.message:String(j))}})(),()=>{I=!0,$&&URL.revokeObjectURL($)}},[h,e]);const C=async()=>{var I;if(!(!g||w==="copying")){S("copying"),x("");try{if(!((I=navigator.clipboard)!=null&&I.write)||typeof ClipboardItem>"u")throw new Error("当前浏览器不支持复制图片,请下载后使用。");await navigator.clipboard.write([new ClipboardItem({"image/png":g})]),S("copied"),c.current=window.setTimeout(()=>S("idle"),1500)}catch($){S("idle"),x($ instanceof Error?$.message:String($))}}},A=I=>{T(I),S("idle"),x("")},R=(I,$)=>{var L,H;const N=["png","pdf"],j=N.indexOf($);let B=j;if(I.key==="ArrowRight"||I.key==="ArrowDown")B=(j+1)%N.length;else if(I.key==="ArrowLeft"||I.key==="ArrowUp")B=(j-1+N.length)%N.length;else if(I.key==="Home")B=0;else if(I.key==="End")B=N.length-1;else return;I.preventDefault();const F=N[B];A(F),(H=(L=s.current)==null?void 0:L.querySelector(`[data-export-format="${F}"]`))==null||H.focus()},M=async()=>{if(!(!g||E==="downloading")){k("downloading"),x("");try{const I=_==="pdf"?await E3t(g):g;k3t(I,v3t(_))}catch(I){u.current&&x(I instanceof Error?I.message:"导出失败,请重试。")}finally{u.current&&k("idle")}}};return kr.createPortal(o.jsx("div",{className:"share-message-backdrop",onMouseDown:I=>{I.target===I.currentTarget&&t()},children:o.jsxs("section",{ref:s,className:"share-message-dialog",role:"dialog","aria-modal":"true","aria-labelledby":n,"aria-describedby":r,"aria-busy":d==="generating"||E==="downloading",children:[o.jsxs("header",{className:"share-message-head",children:[o.jsxs("div",{children:[o.jsx("h2",{id:n,children:"导出会话"}),o.jsx("p",{id:r,children:"选择格式并下载截至当前回复的全部输入与输出。"})]}),o.jsx("button",{ref:a,type:"button",className:"share-message-close","aria-label":"关闭",title:"关闭",onClick:t,children:o.jsx(m3t,{})})]}),o.jsxs("div",{className:"share-message-body",children:[d==="generating"?o.jsx("div",{className:"share-message-generating",role:"status",children:o.jsx(wn,{children:"正在生成导出内容…"})}):d==="error"?o.jsxs("div",{className:"share-message-failure",children:[o.jsx("p",{role:"alert",children:v||"图片生成失败,请重试。"}),o.jsx("button",{type:"button",onClick:()=>m(I=>I+1),children:"重试生成"})]}):o.jsx("div",{className:"share-message-preview",children:o.jsx("img",{src:y,alt:"会话导出内容预览"})}),d!=="error"&&v&&o.jsx("p",{className:"share-message-error",role:"alert",children:v})]}),o.jsxs("div",{className:"share-message-options",children:[o.jsx("span",{id:i,className:"share-message-format-label",children:"导出格式"}),o.jsx("div",{className:"share-message-format",role:"radiogroup","aria-labelledby":i,children:["png","pdf"].map(I=>o.jsx("button",{type:"button",role:"radio","data-export-format":I,className:_===I?"is-active":"","aria-checked":_===I,tabIndex:_===I?0:-1,disabled:E==="downloading",onClick:()=>A(I),onKeyDown:$=>R($,I),children:I.toUpperCase()},I))})]}),o.jsxs("footer",{className:"share-message-actions",children:[o.jsx("span",{className:"share-message-download-status","aria-live":"polite",children:E==="downloading"?`正在生成 ${_.toUpperCase()}…`:""}),_==="png"&&o.jsx("button",{type:"button",onClick:()=>void C(),disabled:!g||d!=="ready"||w==="copying",children:w==="copying"?"正在复制…":w==="copied"?"已复制":"复制图片"}),o.jsx("button",{type:"button",className:"is-primary",onClick:()=>void M(),disabled:!g||d!=="ready"||E==="downloading",children:E==="downloading"?"正在生成…":`下载 ${_.toUpperCase()}`})]})]})}),document.body)}const T3t=2e3,C3t=700,ESe=1200;function BU(e,t){const n=Array.from(e);return n.length<=t?e:`${n.slice(0,t-1).join("").trimEnd()}…`}function kSe(e){return BU(e.trim(),C3t)}function _Se(e){return BU(e,ESe)}function Nte(e){return e.trim().length>0}function A3t(e,t){const n=kSe(e),r=_Se(t.trim());return BU(`选中片段:${n}
批注:${r}`,T3t)}function jte(e){return e?e instanceof Element?e:e.parentElement:null}function N3t(e,t){if(!t||t.isCollapsed||t.rangeCount===0)return null;const n=jte(t.anchorNode),r=jte(t.focusNode);if(!n||!r||!e.contains(n)||!e.contains(r)||!n.closest(".bubble")||!r.closest(".bubble"))return null;const i=t.toString().trim();if(!i)return null;const s=t.getRangeAt(0).getBoundingClientRect();return s.width<=0||s.height<=0?null:{text:i,anchor:{left:s.left+s.width/2,top:s.top,height:s.height}}}function j3t({anchor:e,selectedText:t,onClose:n,onSubmit:r}){const i=p.useRef(!1),[s,a]=p.useState(""),[l,c]=p.useState(!1),[u,d]=p.useState(""),[f,h]=p.useState(!1),m=kSe(t),g=p.useCallback(()=>{var y;(y=window.getSelection())==null||y.removeAllRanges(),n()},[n]);i.current=l,p.useEffect(()=>{const y=()=>{i.current||g()},O=v=>{const x=v.target;x instanceof Element&&x.closest(".response-annotation-popover")||i.current||g()};return window.addEventListener("resize",y),window.addEventListener("scroll",O,!0),()=>{window.removeEventListener("resize",y),window.removeEventListener("scroll",O,!0)}},[g]);const b=async()=>{if(!(l||f||!Nte(s))){c(!0),d("");try{await r(s.trim()),h(!0)}catch(y){d(y instanceof Error?y.message:String(y))}finally{c(!1)}}};return o.jsxs(Rp,{open:!0,onOpenChange:y=>{!y&&!l&&g()},children:[o.jsx(Rp.Trigger,{children:o.jsx("span",{className:"response-annotation-anchor",style:{left:e.left,top:e.top,height:e.height},"aria-hidden":"true"})}),o.jsx(Rp.Content,{side:"top",sideOffset:8,align:"center",minWidth:"auto",className:"response-annotation-popover",children:f?o.jsxs("div",{className:"response-annotation-success",role:"status","aria-live":"polite",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"已加入 Bad case 评测集"}),o.jsx("p",{children:"这条批注已关联当前问题和完整模型回复。"})]}),o.jsx(jt,{type:"button",color:"secondary",size:"sm",pill:!1,onClick:g,children:"完成"})]}):o.jsxs("form",{className:"response-annotation-form","aria-label":"批注选中的模型回复","aria-busy":l||void 0,onSubmit:y=>{y.preventDefault(),b()},children:[o.jsx("div",{className:"response-annotation-header",children:o.jsx("h2",{children:"添加批注"})}),o.jsx("blockquote",{title:m,children:m}),o.jsxs("label",{className:"response-annotation-field",children:[o.jsx("span",{children:"批注内容"}),o.jsx(md,{value:s,rows:3,maxRows:6,autoResize:!0,maxLength:ESe,disabled:l,invalid:!!u,"aria-label":"批注内容",placeholder:"说明问题或期望的修改方式",onChange:y=>{a(_Se(y.target.value)),u&&d("")}})]}),u&&o.jsxs("p",{className:"response-annotation-error",role:"alert",children:[u,",请重试。"]}),o.jsxs("div",{className:"response-annotation-actions",children:[o.jsx(jt,{className:"response-annotation-action",type:"button",color:"secondary",variant:"ghost",size:"sm",pill:!1,disabled:l,onClick:g,children:"取消"}),o.jsx(jt,{className:"response-annotation-action",type:"submit",color:"primary",size:"sm",pill:!1,loading:l,disabled:!Nte(s),children:"加入 Bad Case"})]})]})})]})}const R3t=[{value:"conversation",label:"对话"},{value:"agents",label:"智能体"},{value:"applications",label:"自动化"},{value:"search",label:"搜索"},{value:"other",label:"其他"}],I3t=[{value:"page_slow",label:"页面加载慢"},{value:"feature_unavailable",label:"功能无法使用"},{value:"display_error",label:"页面显示异常"},{value:"no_response",label:"操作无响应"},{value:"other",label:"其他问题"}],D3t=["点击后没有反应","页面一直处于加载状态","部分内容显示不完整","操作后出现错误提示"];function P3t(e){return o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...e,children:o.jsx("path",{d:"m5 12.5 4.2 4.2L19 7"})})}function M3t({initialModule:e,onSubmit:t}){const n=p.useRef(null),[r,i]=p.useState(()=>new Set),[s,a]=p.useState(e),[l,c]=p.useState(""),[u,d]=p.useState(!1),[f,h]=p.useState(""),[m,g]=p.useState(!1),b=x=>{i(w=>{const S=new Set(w);return S.has(x)?S.delete(x):S.add(x),S})},y=x=>{var w;c(S=>S.trim()?S.includes(x)?S:`${S.trimEnd()}
${x}`:x),(w=n.current)==null||w.focus()},O=async x=>{if(x.preventDefault(),!(u||m)){d(!0),h("");try{await t({module:s,issues:[...r],description:l.trim()}),g(!0)}catch(w){h(w instanceof Error?w.message:String(w))}finally{d(!1)}}},v=r.size>0||l.trim().length>0;return o.jsxs("div",{className:"platform-feedback-page",children:[o.jsxs("header",{className:"platform-feedback-header",children:[o.jsx("h1",{children:"问题反馈"}),o.jsx("p",{children:"告诉我们您在使用 AgentKit Studio 时遇到的问题。"})]}),o.jsx("div",{className:"platform-feedback-scroll",children:m?o.jsxs("section",{className:"platform-feedback-success","aria-labelledby":"feedback-success-title","aria-live":"polite",role:"status",children:[o.jsx("span",{className:"platform-feedback-success-icon","aria-hidden":"true",children:o.jsx(P3t,{})}),o.jsxs("div",{children:[o.jsx("h2",{id:"feedback-success-title",children:"上报成功,感谢您的反馈"}),o.jsx("p",{children:"AgentKit 团队会尽快查看您提交的问题。"})]})]}):o.jsxs("form",{className:"platform-feedback-form",onSubmit:x=>void O(x),children:[o.jsxs("section",{className:"platform-feedback-section",children:[o.jsx("div",{className:"platform-feedback-section-heading",children:o.jsx("h2",{children:"所属模块"})}),o.jsx("div",{className:"platform-feedback-pills","aria-label":"所属模块",children:R3t.map(x=>o.jsx("button",{type:"button","aria-pressed":s===x.value,onClick:()=>a(x.value),disabled:u,children:x.label},x.value))})]}),o.jsx("section",{className:"platform-feedback-section",children:o.jsxs("div",{className:"platform-feedback-suggestions",children:[o.jsx("span",{children:"常见问题(可多选)"}),o.jsx("div",{className:"platform-feedback-pills","aria-label":"问题类型",children:I3t.map(x=>o.jsx("button",{type:"button","aria-pressed":r.has(x.value),onClick:()=>b(x.value),disabled:u,children:x.label},x.value))})]})}),o.jsxs("section",{className:"platform-feedback-section",children:[o.jsxs("label",{className:"platform-feedback-field",children:[o.jsx("span",{children:"问题描述"}),o.jsx("textarea",{ref:n,value:l,onChange:x=>c(x.target.value),placeholder:"请描述问题发生时的页面、操作和表现",maxLength:4e3,rows:6,disabled:u})]}),o.jsxs("div",{className:"platform-feedback-suggestions",children:[o.jsx("span",{children:"快捷补充"}),o.jsx("div",{className:"platform-feedback-pills","aria-label":"问题描述推荐",children:D3t.map(x=>o.jsx("button",{type:"button",onClick:()=>y(x),disabled:u,children:x},x))})]})]}),o.jsx("p",{className:"platform-feedback-privacy",role:"alert",children:"您的数据将会上报到 AgentKit 团队,请注意隐私保护。"}),f&&o.jsx("p",{className:"platform-feedback-error",role:"alert",children:f}),o.jsx("div",{className:"platform-feedback-actions",children:o.jsx("button",{type:"submit",disabled:!v||u,children:u?"正在上报…":"提交反馈"})})]})})]})}function L3t({node:e,ctx:t}){const n=e.variant??"default";return o.jsx("button",{type:"button",className:`a2ui-button a2ui-button--${n}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component,onClick:()=>t.dispatchAction(e.action,e),children:t.render(e.child)})}S0("Button",L3t);function $3t({node:e,ctx:t}){return o.jsx("div",{className:"a2ui-card","data-a2ui-id":e.id,"data-a2ui-component":e.component,children:t.render(e.child)})}S0("Card",$3t);const B3t={start:"flex-start",center:"center",end:"flex-end",spaceBetween:"space-between",spaceAround:"space-around",spaceEvenly:"space-evenly",stretch:"stretch"},Q3t={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"};function TSe(e){return B3t[e]??"flex-start"}function CSe(e){return Q3t[e]??"stretch"}function U3t({node:e,ctx:t}){const n=e.children??[];return o.jsx("div",{className:"a2ui-column","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"column",justifyContent:TSe(e.justify),alignItems:CSe(e.align)},children:n.map(r=>t.render(r))})}S0("Column",U3t);function F3t({node:e}){const t=e.axis==="vertical";return o.jsx("div",{className:`a2ui-divider ${t?"a2ui-divider--v":"a2ui-divider--h"}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component})}S0("Divider",F3t);const z3t={send:"✈️",check:"✅",close:"✖️",star:"⭐",favorite:"❤️",info:"ℹ️",help:"❓",error:"⛔",calendarToday:"📅",event:"📅",schedule:"🕒",locationOn:"📍",accountCircle:"👤",mail:"✉️",call:"📞",home:"🏠",settings:"⚙️",search:"🔍"};function V3t({node:e}){const t=e.name??"";return o.jsx("span",{className:"a2ui-icon",title:t,"aria-label":t,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:z3t[t]??"•"})}S0("Icon",V3t);function H3t({node:e,ctx:t}){const n=e.children??[];return o.jsx("div",{className:"a2ui-row","data-a2ui-id":e.id,"data-a2ui-component":e.component,style:{display:"flex",flexDirection:"row",justifyContent:TSe(e.justify),alignItems:CSe(e.align??"center")},children:n.map(r=>t.render(r))})}S0("Row",H3t);const q3t=new Set(["h1","h2","h3","h4","h5"]);function X3t({node:e,ctx:t}){const n=e.variant??"body",r=t.resolveString(e.text),i=q3t.has(n)?n:"p";return o.jsx(i,{className:`a2ui-text a2ui-text--${n}`,"data-a2ui-id":e.id,"data-a2ui-component":e.component,children:r})}S0("Text",X3t);function G3t(e){return e==="agents"?"agents":e==="applications"?"applications":e==="search"?"search":["conversation","new-chat","sandbox"].includes(e)?"conversation":"other"}async function y3(e){const[t,n,r]=await Promise.allSettled([hDt(),pDt("deepseek-harness"),Lj()]);return{agentId:e,ready:!0,temporaryEnabled:t.status==="fulfilled"&&t.value.enabled,deepseekHarnessEnabled:n.status==="fulfilled"&&n.value.enabled,sandboxEndpointExportEnabled:t.status==="fulfilled"&&t.value.endpointExportEnabled===!0,skillCustomizationEnabled:r.status==="fulfilled"&&r.value.enabled}}async function Rte(e,t){const n=await m9(e,t),r=await Promise.allSettled(n.map(s=>{var a;return(a=s.events)!=null&&a.length?Promise.resolve(s):MN(e,t,s.id)})),i=r.find(s=>s.status==="rejected"&&!/get session failed:\s*404\b/i.test(String(s.reason)));if((i==null?void 0:i.status)==="rejected")throw i.reason;return r.flatMap(s=>s.status==="fulfilled"?[s.value]:[])}const Jc={app:"veadk.appName",view:"veadk.view",session:"veadk.sessionId"},W3t=600,Y3t=1e3,Ite=5e3,Z3t=500,K3t=new Set,J3t=[],tf=["list_envs","get_env_manifest","execute_in_sandbox"];function uc(){return{skills:[]}}function jx(e,t,n){return`${e}\0${t}\0${n}`}async function eMt(e){let t;if(e.threadId)try{const i=await di.readThread(e.id,e.threadId);if(i.messages.length>0)return i}catch(i){t=i}const n=await di.listThreads(e.id),r=n.threads.find(i=>i.id!==e.threadId)??n.threads[0];if(!r){if(t)throw t;return null}return di.resumeThread(e.id,r.id)}function Dte(e,t){const n=hSe(e),r=n[n.length-1];return!t||(r==null?void 0:r.role)!=="user"?n:[...n,{role:"assistant",blocks:[],meta:{localId:`sandbox-background-${e.threadId}`}}]}function O3(e){return`${NR(e)}.active`}function g$(e){return`veadk.agentOrder.${encodeURIComponent(e)}`}function tMt(e){if(!e)return[];try{const t=JSON.parse(localStorage.getItem(g$(e))||"[]");return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function b$(e,t){if(e.name===t||e.id===t)return e;for(const n of e.children){const r=b$(n,t);if(r)return r}}function nMt(e){return e.replace(/__[0-9a-f]{10}(?:__.*)?$/i,"")}function ASe(e){const t=[];for(const n of e.children)n.mentionable&&(t.push({name:n.name,description:n.description,type:n.type,path:n.path}),t.push(...ASe(n)));return t}function Pte(){const e=typeof localStorage<"u"?localStorage.getItem(Jc.view):null;return e==="intelligent"?e:["menu","custom","template","workflow"].includes(e??"")?"custom":e==="package"||e==="migration"?e:null}function Mte(e){const t=e.trim().toLowerCase();switch(t){case"creating":case"starting":case"initializing":case"pending":case"running":case"ready":case"failed":case"error":case"stopped":case"expired":case"deleting":case"deleted":return t;default:return"unknown"}}function Lte({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("rect",{x:"3.75",y:"3.75",width:"16.5",height:"16.5",rx:"3.25"}),o.jsx("path",{d:"M12 8.5v7M8.5 12h7"}),o.jsx("path",{d:"M6.75 6.75h1M16.25 17.25h1",opacity:"0.6"})]})}function rMt({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("rect",{x:"3.5",y:"5",width:"17",height:"14.75",rx:"2.25"}),o.jsx("path",{d:"M3.5 9h17M9.25 12.25 7.1 14.4l2.15 2.15M14.75 12.25l2.15 2.15-2.15 2.15M12.8 11.85l-1.6 5.1"})]})}function iMt({className:e}){return o.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[o.jsx("rect",{x:"2.75",y:"5",width:"6.5",height:"14",rx:"1.6"}),o.jsx("path",{d:"M5.25 8.5h1.5M5.25 11.5h1.5"}),o.jsx("rect",{x:"14.75",y:"5",width:"6.5",height:"14",rx:"1.6"}),o.jsx("path",{d:"M17.25 15.5h1.5M17.25 12.5h1.5M8.75 12h6.5m-2.5-2.5 2.5 2.5-2.5 2.5"})]})}function sMt(){return o.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round","aria-hidden":!0,children:[o.jsx("rect",{x:"3",y:"4",width:"14",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none"}),o.jsx("rect",{x:"6",y:"10.4",width:"13",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.7"}),o.jsx("rect",{x:"9",y:"16.8",width:"9",height:"3.2",rx:"1.2",fill:"currentColor",stroke:"none",opacity:"0.45"})]})}function y$(e){return e?new Date(e*1e3).toLocaleString("zh-CN",{timeZone:"Asia/Shanghai",hour12:!1,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}):""}function aMt(e){if(!e)return"";const t=[];return e.ts&&t.push(y$(e.ts)),e.tokens!=null&&t.push(`${e.tokens.toLocaleString()} tokens`),t.join(" · ")}function Gh(e){return e.blocks.map(t=>t.kind==="text"?t.text:"").join("").trim()}function x3(e,t){for(let n=t-1;n>=0;n-=1)if(e[n].role==="user")return Gh(e[n]);return""}const oMt="send_a2ui_json_to_client";function v3(e){return e.blocks.some(t=>t.kind==="text"?t.text.trim().length>0:t.kind==="attachment"||t.kind==="artifact"?t.files.length>0:t.kind==="delivery"?!0:t.kind==="tool"?!(t.name===oMt&&t.done):t.kind==="agent-transfer"?!1:t.kind==="a2ui"?Gge(t.messages).some(n=>n.components[n.rootId]):t.kind==="auth")}function w3(e){return e.blocks.some(t=>t.kind==="auth"&&!t.done)}function lMt(e){return new Promise((t,n)=>{let r="";try{r=new URL(e,window.location.href).protocol}catch{}if(r!=="http:"&&r!=="https:"){n(new Error("授权链接不是 http/https 地址,已阻止打开。"));return}const i=window.open(e,"veadk_oauth","width=520,height=720");if(!i){n(new Error("弹窗被拦截,请允许弹窗后重试。"));return}let s=!1;const a=()=>{clearInterval(u),window.removeEventListener("message",c)},l=d=>{if(!s){s=!0,a();try{i.close()}catch{}t(d)}},c=d=>{if(d.origin!==window.location.origin)return;const f=d.data;f&&f.veadkOAuth&&typeof f.url=="string"&&l(f.url)};window.addEventListener("message",c);const u=setInterval(()=>{if(!s){if(i.closed){a();const d=window.prompt("授权完成后,请粘贴回调页面(浏览器地址栏)的完整 URL:");d&&d.trim()?(s=!0,t(d.trim())):n(new Error("授权已取消。"));return}try{const d=i.location.href;d&&d!=="about:blank"&&new URL(d).origin===window.location.origin&&/[?&](code|state|error)=/.test(d)&&l(d)}catch{}}},500)})}function cMt(e,t){const n=JSON.parse(JSON.stringify(e??{})),r=n.exchangedAuthCredential??n.exchanged_auth_credential??{},i=r.oauth2??{};return i.authResponseUri=t,i.auth_response_uri=t,r.oauth2=i,n.exchangedAuthCredential=r,n}function $te({text:e}){const[t,n]=p.useState(!1);return o.jsx("button",{className:"icon-btn",title:t?"已复制":"复制",disabled:!e,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}},children:t?o.jsx(Su,{className:"icon"}):o.jsx(NN,{className:"icon"})})}function uMt({onClick:e}){return o.jsx("button",{type:"button",className:"icon-btn","aria-label":"导出会话",title:"导出会话",onClick:e,children:o.jsx(kRe,{className:"icon","aria-hidden":"true"})})}const Bte=["今天想做点什么?","有什么可以帮你的?","需要我帮你查点什么吗?","有问题尽管问我","嗨,我们开始吧","开始一段新对话吧","今天想先解决哪件事?","把你的想法告诉我吧","我们从哪里开始?","有什么任务交给我?","准备好一起推进了吗?","说说你现在最关心的问题","今天也一起把事情做好","我在,随时可以开始"],Qte=()=>Bte[Math.floor(Math.random()*Bte.length)];function S3(e){var t;for(const n of e)(t=n.previewUrl)!=null&&t.startsWith("blob:")&&URL.revokeObjectURL(n.previewUrl)}function Ute(){return`draft-${Date.now()}-${Math.random().toString(36).slice(2)}`}function Fte(e){var n;if(e.type)return e.type;const t=(n=e.name.split(".").pop())==null?void 0:n.toLowerCase();return t==="md"||t==="markdown"?"text/markdown":t==="txt"?"text/plain":"application/octet-stream"}const dMt={"read-only":"只读","workspace-write":"工作区写入","danger-full-access":"完全访问"},fMt={untrusted:"仅不可信命令","on-request":"按需审批",never:"不审批"},hMt={user:"由我审批",auto_review:"自动审查"};function pMt(e,t){const n=e.kind==="file"?"文件修改":"命令执行";return t==="accept"?`已允许本次${n}`:t==="acceptForSession"?`已在本会话中允许${n}`:t==="decline"?`已拒绝${n}`:`已取消${n}审批`}function mMt(e){var n,r,i;const t=[];return(n=e.command)!=null&&n.trim()&&t.push({label:"命令",value:e.command.trim(),code:!0}),(r=e.grantRoot)!=null&&r.trim()&&t.push({label:"授权路径",value:e.grantRoot.trim(),code:!0}),(i=e.cwd)!=null&&i.trim()&&t.push({label:"执行目录",value:e.cwd.trim(),code:!0}),t}function zte(e){return e.flatMap(t=>t.apps.map(n=>gu(t.id,n)))}function gMt(e,t){var n;return((n=e.find(r=>r.runtimeId&&r.apps.some(i=>gu(r.id,i)===t)))==null?void 0:n.runtimeId)??""}function Vte(e,t){for(const n of e){const r=n.apps.find(i=>gu(n.id,i)===t);if(r&&n.runtimeId)return{runtimeId:n.runtimeId,region:n.region??"cn-beijing",appName:r}}return null}function Hte(e){return e.taskMode==="text_to_video"?[]:(e.taskMode==="first_last_frame"?[e.firstFrame?{file:e.firstFrame,kind:"first_frame"}:null,e.lastFrame?{file:e.lastFrame,kind:"last_frame"}:null]:[e.referenceImage?{file:e.referenceImage,kind:"reference_image"}:null,e.referenceVideo?{file:e.referenceVideo,kind:"reference_video"}:null]).filter(n=>n!==null)}function bMt(e,t){return`video-${e.replace(/[^A-Za-z0-9_-]/g,"").slice(0,36)||"result"}.${t}`}function Rx(e,t){return`${e}${t}`}function yMt(){var wF;const[e,t]=p.useState([]),[n,r]=p.useState(""),[i,s]=p.useState([]),[a,l]=p.useState(""),c=p.useRef(null),u=p.useRef(0),d=p.useRef(0),f=p.useRef(null),[h,m]=p.useState(!1),[g,b]=p.useState([]),[y,O]=p.useState(null),[v,x]=p.useState([]),[w,S]=p.useState(!1),[E,k]=p.useState(!1),[_,T]=p.useState(""),[C,A]=p.useState(!1),[R,M]=p.useState(!1),[I,$]=p.useState(null),[N,j]=p.useState(null),[B,F]=p.useState(!1),[L,H]=p.useState(""),[z,Q]=p.useState(null),[V,K]=p.useState(!1),[se,ge]=p.useState(""),[ie,q]=p.useState(!1),[G,J]=p.useState("idle"),[ue,Oe]=p.useState(!1),[Qe,je]=p.useState("confirm"),[ze,Ge]=p.useState(""),[Ae,Be]=p.useState("codex"),[he,be]=p.useState(!1),[Se,Ee]=p.useState(!1),[tt,Ue]=p.useState(0),[re,ce]=p.useState("general"),[Me,Ye]=p.useState(null),[Z,_e]=p.useState(null),[rt,Re]=p.useState(null),We=p.useRef(null),ct=p.useRef(null),kt=p.useRef(null),qt=p.useRef(null),[Dt,Xe]=p.useState(!1),nt=p.useRef(null),ft=p.useRef((y==null?void 0:y.id)??""),xt=p.useRef(""),Ie=p.useRef(0),xe=p.useRef(void 0),$e=p.useRef(new Set);ft.current=(y==null?void 0:y.id)??"",p.useEffect(()=>()=>{xe.current!==void 0&&window.clearTimeout(xe.current);for(const P of $e.current)URL.revokeObjectURL(P);$e.current.clear()},[]);function it(P){const U=URL.createObjectURL(P);return $e.current.add(U),U}function ve(P){!P||!$e.current.delete(P)||URL.revokeObjectURL(P)}function He(){for(const P of $e.current)URL.revokeObjectURL(P);$e.current.clear()}const pt=p.useCallback(()=>{xe.current!==void 0&&(window.clearTimeout(xe.current),xe.current=void 0),J("idle")},[]);p.useEffect(()=>{pt()},[pt,y==null?void 0:y.id]);const[_t,It]=p.useState({}),[Kt,en]=p.useState({}),le=a?_t[a]??[]:g,Xt=y?v:le,Fe=a?Kt[Rx(n,a)]??G_:G_,Pt=(P,U)=>It(X=>({...X,[P]:typeof U=="function"?U(X[P]??[]):U})),Ce=(P,U,X)=>{const ne=Rx(P,U);en(me=>{const ye=me[ne]??G_,ke=wle(ye,X);return ke===ye?me:{...me,[ne]:ke}})};function gt(P,U,X=[],ne=""){if(ft.current!==P)return;const me=crypto.randomUUID(),ye={role:"system",blocks:[],activity:{id:me,title:U,...X.length>0?{details:X}:{}},meta:{localId:me,ts:Date.now()/1e3}};x(ke=>{if(!ne)return[...ke,ye];const mt=ke.findIndex(st=>{var Gt;return((Gt=st.meta)==null?void 0:Gt.localId)===ne});return mt<0?[...ke,ye]:[...ke.slice(0,mt),ye,...ke.slice(mt)]})}const[Vt,ot]=p.useState(""),[ln,Kn]=p.useState("agent"),[_r,Ve]=p.useState("agent"),[et,mn]=p.useState("create"),[Mt,ar]=p.useState(null),[pr,Gn]=p.useState(null),[zn,Pr]=p.useState(null),[Lr,Kr]=p.useState(!0),[qr,mr]=p.useState(""),[Xr,Tr]=p.useState(null),[oi,Ii]=p.useState(),[bi,Jr]=p.useState(null),Di=p.useCallback(P=>{Jr(P);const U=new URL(window.location.href);if(P)U.searchParams.set("view","runtime-deploy"),U.searchParams.set("source","intelligent-development"),U.searchParams.set("sessionId",P.sessionId),U.searchParams.set("artifactSha256",P.artifactSha256),U.searchParams.set("validationReportSha256",P.validationReportSha256),P.projectId&&P.versionId?(U.searchParams.set("projectId",P.projectId),U.searchParams.set("versionId",P.versionId)):(U.searchParams.delete("projectId"),U.searchParams.delete("versionId"));else for(const X of["view","source","sessionId","artifactSha256","validationReportSha256","projectId","versionId"])U.searchParams.delete(X);window.history.replaceState(null,"",U)},[]),rs=p.useCallback(P=>P.projectId&&P.versionId?_ee(P.projectId,P.versionId,P.sessionId,P.artifactSha256,P.validationReportSha256):Tee(P.sessionId,P.artifactSha256,P.validationReportSha256),[]),oa=p.useCallback(async P=>{if(!P.projectId||!P.versionId||!P.parentVersionId)throw new Error("当前版本没有可对比的优化前版本。");const U=await xwe(P.projectId),X=U.find(ke=>ke.versionId===P.versionId),ne=U.find(ke=>ke.versionId===P.parentVersionId);if(!X||!ne)throw new Error("无法找到本次优化对应的项目版本,可能已被删除。");const[me,ye]=await Promise.all([ey(ne),ey(X)]);return{base:me,target:ye}},[]),Qr=p.useCallback(async P=>{const U=cwe({agentId:P.agentName,deployAction:"create",deploySource:"intelligent_development",createMode:"intelligent",aiAssisted:1});try{const{blob:X,filename:ne}=await WNt(P),me=URL.createObjectURL(X),ye=document.createElement("a");ye.href=me,ye.download=ne,ye.hidden=!0;try{document.body.appendChild(ye),ye.click()}finally{ye.remove(),window.setTimeout(()=>URL.revokeObjectURL(me),1e3)}U.succeed({fileCount:P.fileCount,zipSizeBytes:X.size})}catch(X){throw U.fail({fileCount:P.fileCount,...mo(X)}),X}},[]),[Ws,is]=p.useState(null),[ka,Ys]=p.useState(!1),[_a,Ds]=p.useState(!1),Pi=p.useRef(null),Cr=p.useRef(null),[yi,bs]=p.useState({}),Ps=p.useRef(new Map),pn=yi.ready===!0&&yi.agentId===n,[Oi,Ur]=p.useState([]),[ys,pe]=p.useState(uc),[Le,At]=p.useState(null),[sn,An]=p.useState(!1),[$r,Gr]=p.useState(""),[Zs,Ta]=p.useState(null),[No,Va]=p.useState([]),[Dd,Ks]=p.useState({}),[so,jo]=p.useState([]),[Pd,ao]=p.useState([]),[ol,oo]=p.useState(!1),[Yl,Ru]=p.useState(""),[Fc,Iu]=p.useState({}),[Ro,zc]=p.useState({}),[Zl,Md]=p.useState({}),[kn,Vc]=p.useState(null),[_h,ae]=p.useState(0),[In,Vn]=p.useState(!1),Os=p.useRef(new Set),[Jn,li]=p.useState(()=>new Set),[Ld,ll]=p.useState(()=>new Set),[xs,lo]=p.useState(()=>new Set),vs=p.useRef(new Map),Ar=p.useRef(new Map),la=p.useRef(void 0),ca=p.useRef(()=>{}),fe=(P,U)=>li(X=>{const ne=new Set(X);return U?ne.add(P):ne.delete(P),ne}),Je=P=>{const U=Ar.current.get(P);U!==void 0&&window.clearTimeout(U),Ar.current.delete(P),ll(X=>new Set(X).add(P))},St=P=>{const U=Ar.current.get(P);U!==void 0&&window.clearTimeout(U),Ar.current.delete(P),ll(X=>{if(!X.has(P))return X;const ne=new Set(X);return ne.delete(P),ne})},dn=P=>{const U=Ar.current.get(P);U!==void 0&&window.clearTimeout(U);const X=window.setTimeout(()=>{St(P)},2400);Ar.current.set(P,X)},Zt=(P,U)=>{lo(X=>{if(X.has(P)===U)return X;const ne=new Set(X);return ne.delete(P),ne})},Tt=p.useRef(""),[Lt,Ne]=p.useState("");function tn(P,U,X){const ne=Pi.current;if(!ne||ne.localId!==P||ne.runId!==U)return null;const me=yee(ne,X);return Pi.current=me,is(me),me}async function or(P,U,X){var ye;(ye=Cr.current)==null||ye.abort();const ne=new AbortController;Cr.current=ne;let me=X;try{let ke=Pi.current;if(!ke||ke.localId!==P||ke.runId!==U)return;if(me==="optimization"&&ke.assetIds.length===0){const st=Hte(ke.config);if(st.length>0){const Gt=await Promise.all(st.map(yt=>MAt(yt.file,yt.kind,ne.signal)));if(ne.signal.aborted||(ke=tn(P,U,{type:"assets_uploaded",assetIds:Gt.map(yt=>yt.assetId)}),!ke))return}}if(me==="optimization"){const st=await LAt({prompt:ke.requestedPrompt,taskMode:ke.requestedMode,assetIds:ke.assetIds,ratio:ke.config.aspectRatio,resolution:ke.config.resolution,durationSeconds:ke.config.durationSeconds},ne.signal);if(ne.signal.aborted||(ke=tn(P,U,{type:"optimization_succeeded",optimizedPrompt:st.enhancedPrompt,resolvedMode:st.resolvedTaskMode,enhancerModel:st.enhancerModel}),!ke))return;me="generation"}if(!ke.optimizedPrompt||!ke.resolvedMode)throw new Error("提示词优化结果不完整,请重新优化后再试。");const mt=await $At({enhancedPrompt:ke.optimizedPrompt,resolvedTaskMode:ke.resolvedMode,assetIds:ke.assetIds,ratio:ke.config.aspectRatio,resolution:ke.config.resolution,durationSeconds:ke.config.durationSeconds},ne.signal);if(ne.signal.aborted||(ke=tn(P,U,{type:"generation_started",remoteTaskId:mt.taskId,generationModel:mt.generationModel,startedAt:Date.now()}),!ke))return;for(;!ne.signal.aborted;){const st=await BAt(mt.taskId,ne.signal);if(ne.signal.aborted)return;if((st.status==="queued"||st.status==="running")&&tn(P,U,{type:"generation_status_changed",providerStatus:st.status}),st.status==="failed")throw new Error(st.error||"视频生成失败,请稍后重试。");if(st.status==="succeeded"){if(!st.videoUrl)throw new Error("视频任务已完成,但服务端未返回预览地址。");tn(P,U,{type:"generation_succeeded",output:{previewUrl:UAt(st.videoUrl),fileName:bMt(mt.taskId,st.outputFormat),mimeType:st.outputFormat==="mov"?"video/quicktime":"video/mp4"}});return}await new Promise(Gt=>window.setTimeout(Gt,1800))}}catch(ke){if(ne.signal.aborted)return;tn(P,U,{type:"failed",stage:me,error:ke instanceof Error?ke.message:String(ke)})}}function W(P,U,X){if(bwe(Pi.current)){Ys(!0);return}if(U.taskMode==="video_editing"&&!U.referenceVideo){Ne("视频编辑需要先添加待编辑视频。");return}if(U.taskMode==="video_extension"&&!U.referenceVideo){Ne("视频续写需要先添加基础视频。");return}if(U.taskMode==="reference_to_video"&&!U.referenceImage&&!U.referenceVideo){Ne("参考素材生视频需要至少添加一项参考图片或参考视频。");return}if(U.taskMode==="text_to_video"&&(U.referenceImage||U.referenceVideo||U.firstFrame||U.lastFrame)){Ne("文生视频不使用参考素材,请先移除已添加的图片或视频。");return}if(U.taskMode==="first_last_frame"&&!U.firstFrame){Ne("首尾帧生成需要先添加首帧图片。");return}if(X.supportedModes.length>0&&U.taskMode!=="auto"&&!X.supportedModes.includes(U.taskMode)){Ne("当前平台暂不支持所选视频任务模式。");return}const ne=Hte(U);if(ne.length>0&&!X.assetStorageAvailable){Ne(X.assetStorageUnavailableReason||"管理员未配置持久化存储");return}const me=ne.find(({file:ke})=>X.maxAssetBytes>0&&ke.size>X.maxAssetBytes);if(me){Ne(`${me.file.name} 超出当前平台允许的素材大小。`);return}const ye=jNt({prompt:P,config:U,enhancerModel:X.enhancerModel,generationModel:X.generationModel});Pi.current=ye,is(ye),Ys(!0),ot(""),Ne(""),or(ye.localId,ye.runId,"optimization")}function Te(){const P=Pi.current;if(!P||P.status!=="error"||!P.errorStage)return;const U=P.errorStage,X=yee(P,{type:"retry",stage:U});Pi.current=X,is(X),Ys(!0),or(X.localId,X.runId,U)}async function dt(){const P=Pi.current;if(!(!(P!=null&&P.remoteTaskId)||!P.output))try{const U=await QAt(P.remoteTaskId),X=URL.createObjectURL(U),ne=document.createElement("a");ne.href=X,ne.download=P.output.fileName,ne.click(),window.setTimeout(()=>URL.revokeObjectURL(X),1e3)}catch(U){Ne(U instanceof Error?U.message:String(U))}}p.useEffect(()=>()=>{var P;(P=Cr.current)==null||P.abort()},[]);const[nn,an]=p.useState(""),[on,er]=p.useState(()=>new Set),[Wr,gr]=p.useState(null),[Nr,xn]=p.useState(null),[Jt,Ut]=p.useState(null),[Un,_n]=p.useState(null);p.useEffect(()=>{Ut(null)},[n,a]);const[ci,co]=p.useState(!1),[ym,Kl]=p.useState(),[_0,T0]=p.useState(Qte),[ei,Du]=p.useState(null),[Io,Pu]=p.useState(!1),[Jl,Hc]=p.useState(!1),[ec,tc]=p.useState(""),cl=p.useRef(!1),[Th,$d]=p.useState(null),[Et,Bd]=p.useState(""),[qc,xi]=p.useState(),[tr,Qd]=p.useState(null),CO=(tr==null?void 0:tr.capabilities.runtimeScope)??"mine",[AO,JE]=p.useState({newChat:!0,search:!0,skillCenter:!0,history:!0,addAgent:!0,manageAgents:!0,agentUsage:!1,addAgentkit:!0}),[nc,IR]=p.useState("cloud"),[Om,DR]=p.useState(kw),[Dn,PR]=p.useState("volcengine"),[MR,LR]=p.useState(""),[NO,$R]=p.useState(""),[C0,ek]=p.useState(!1),[Ch,A0]=p.useState(!1),[tk,jO]=p.useState(!1),[nk,ee]=p.useState({}),[we,Pe]=p.useState({}),[lt,$t]=p.useState({}),qe=Jn.has(a),Ln=Ld.has(a),qi=qe||h,Tn=y?w:qi,Js=Tn||!y&&Ln,Mi=(y==null?void 0:y.intelligentDevelopment)===!0?Fh:di,Wn=lPt({client:Mi,allowSkillSelection:(y==null?void 0:y.intelligentDevelopment)!==!0,allowThreadManagement:(y==null?void 0:y.intelligentDevelopment)!==!0,session:y,conversationBusy:w,onInputChange:ot,onSessionPatch:P=>{const U=ft.current;O(X=>(X==null?void 0:X.id)===U?{...X,...P}:X)},onSnapshot:P=>{const U=ft.current;He(),x(hSe(P)),O(X=>(X==null?void 0:X.id)===U?{...X,threadId:P.threadId,cwd:P.cwd??X.cwd,model:P.model??X.model,workspaceLocked:P.workspaceLocked,permissions:P.permissions,busy:!1}:X)},onActivity:(P,U=[])=>{const X=ft.current;X&>(X,P,U)},onError:Ne});p.useEffect(()=>{const P=y;if(!P||!w||kt.current)return;let U=!1,X;const ne=new AbortController,me=async()=>{try{const ye=P.intelligentDevelopment?Fh:di,ke=await ye.getStatus(P.id,{signal:ne.signal});if(U||ft.current!==P.id)return;const mt=ke.threadId?await ye.readThread(P.id,ke.threadId,{signal:ne.signal}):null;if(U||ft.current!==P.id)return;if(mt&&x(Dte(mt,ke.busy)),O(st=>(st==null?void 0:st.id)===P.id?{...st,...ke,...mt?{threadId:mt.threadId,cwd:mt.cwd??ke.cwd,model:mt.model??ke.model,workspaceLocked:mt.workspaceLocked,permissions:mt.permissions}:{}}:st),S(ke.busy),!ke.busy){const st=mt==null?void 0:mt.messages[mt.messages.length-1];(st==null?void 0:st.role)==="user"&&Ne("云端 Codex 已结束,但没有生成回复,请重新发送任务。");return}}catch(ye){if((ye==null?void 0:ye.name)==="AbortError"||U)return;if(P.intelligentDevelopment){Ne(CJ(ye)),X=window.setTimeout(me,1500);return}S(!1),O(ke=>(ke==null?void 0:ke.id)===P.id?{...ke,busy:!1}:ke),Ne(ye instanceof Error?ye.message:String(ye));return}X=window.setTimeout(me,1500)};return X=window.setTimeout(me,1500),()=>{U=!0,ne.abort(),X!==void 0&&window.clearTimeout(X)}},[w,y==null?void 0:y.id]);const rk=nk[a]??"",ik=we[a]??K3t,NSe=lt[a]??J3t,ls=kn==null?void 0:kn.graph,QU=[kn==null?void 0:kn.name,ls==null?void 0:ls.name,ls==null?void 0:ls.id].filter(P=>!!P),BR=ys.targetAgent&&ls?b$(ls,ys.targetAgent.name):ls,jSe=(BR==null?void 0:BR.skills)??(ys.targetAgent?[]:(kn==null?void 0:kn.skills)??[]),RSe=ls?ASe(ls):[],UU=(ls==null?void 0:ls.instruction)??((wF=kn==null?void 0:kn.draft)==null?void 0:wF.instruction),ISe=kn&&UU!==void 0?z5e({instruction:UU,tools:[...new Set([...(ls==null?void 0:ls.tools)??kn.tools,...a?Dd[jx(n,Et,a)]??[]:No])],skills:(ls==null?void 0:ls.skills)??kn.skills}):null;function sk(P){S3(P);for(const U of P)U.status==="uploading"?Os.current.add(U.id):U.uri&&V_(n,U.uri).catch(X=>Ne(String(X)))}async function FU(P){try{await VM(n,Et,P),await zM(n,Et,P),s(U=>U.filter(X=>X.id!==P)),It(U=>{const{[P]:X,...ne}=U;return ne})}catch(U){Ne(String(U))}}function DSe(P){const U=Oi.find(me=>me.id===P);if(!U)return;const X=Oi.filter(me=>me.id!==P);S3([U]),U.status==="uploading"&&Os.current.add(P),Ur(X),X.length===0&&!Vt.trim()&&!!a&&Xt.length===0?(Tt.current="",l(""),FU(a)):U.uri&&V_(n,U.uri).catch(me=>Ne(String(me)))}const zU=(P,U)=>{var ye,ke,mt,st,Gt;const X=U.author&&U.author!=="user"?U.author:void 0;X&&(ee(yt=>({...yt,[P]:X})),Pe(yt=>({...yt,[P]:new Set(yt[P]??[]).add(X)})),$t(yt=>{var Sn;return(Sn=yt[P])!=null&&Sn.length?yt:{...yt,[P]:[X]}}));const ne=((ye=U.actions)==null?void 0:ye.transferToAgent)??((ke=U.actions)==null?void 0:ke.transfer_to_agent);ne&&$t(yt=>{const Sn=yt[P]??[];return Sn[Sn.length-1]===ne?yt:{...yt,[P]:[...Sn,ne]}}),(((mt=U.actions)==null?void 0:mt.endOfAgent)??((st=U.actions)==null?void 0:st.end_of_agent)??((Gt=U.actions)==null?void 0:Gt.escalate))&&$t(yt=>{const Sn=yt[P]??[];return Sn.length<=1?yt:{...yt,[P]:Sn.slice(0,-1)}})},[ul,Pn]=p.useState(Pte),[VU,HU]=p.useState([]),[PSe,QR]=p.useState({}),N0=p.useCallback(P=>{HU(U=>{const X=U.findIndex(me=>me.id===P.id);if(X===-1)return[P,...U];const ne=[...U];return ne[X]={...ne[X],...P},ne})},[]),[MSe,LSe]=p.useState(!0),[j0,cs]=p.useState(!1),[$Se,UR]=p.useState("skills"),[BSe,FR]=p.useState("技能库"),[QSe,ak]=p.useState(null),[ok,Xi]=p.useState(!1),[R0,lr]=p.useState(!1),[USe,Ud]=p.useState("entry"),[zR,I0]=p.useState("traditional"),[qU,Ca]=p.useState(null),[FSe,RO]=p.useState("custom"),[XU,VR]=p.useState([]),Ah=p.useRef([]),Nh=p.useRef(null),D0=p.useRef(null),[GU,lk]=p.useState([]),[Ms,dl]=p.useState(""),Do=p.useRef(null),[IO,us]=p.useState(!1),[jh,ti]=p.useState(!1),[WU,HR]=p.useState(""),[zSe,VSe]=p.useState("good"),[HSe,ck]=p.useState("basic"),[qSe,XSe]=p.useState("good"),[DO,uk]=p.useState(""),[GSe,WSe]=p.useState(null),[fl,ni]=p.useState(!1),[dk,rc]=p.useState(!1),[qR,ic]=p.useState(!1),[YU,uo]=p.useState([]),P0=YU[YU.length-1],M0=P0==null?void 0:P0.page,XR=M0==="system-info",GR=M0==="developer-resources",WR=p.useCallback(P=>{uo(U=>{var X;return((X=U[U.length-1])==null?void 0:X.page)===P.page?U:[...U,P]})},[]),xm=p.useCallback(P=>{uo(U=>{var ne;if(((ne=U[U.length-1])==null?void 0:ne.page)===P)return U.slice(0,-1);const X=U.findIndex(me=>me.page===P);return X===-1?U:U.filter((me,ye)=>ye!==X)})},[]),[sc,Aa]=p.useState(null),[fk,ac]=p.useState(!1),YR=p.useRef(null),[Xc,PO]=p.useState(()=>{const P=su();return wO(P),P}),[YSe,ZU]=p.useState(!1),[ZSe,KU]=p.useState(""),[JU,hk]=p.useState(null),[KSe,eF]=p.useState({}),[JSe,tF]=p.useState(()=>new Set),[Gc,oc]=p.useState(null),[L0,pk]=p.useState(Zr(Dn)),[nF,ea]=p.useState(""),[rF,ta]=p.useState(""),[vr,Na]=p.useState(null),Mu=p.useCallback(()=>{xm("agent-detail"),Na(null),ni(!1),ti(!1)},[xm]),[eEe,ZR]=p.useState(!1),mk=p.useRef(!1),$0=p.useRef(!1),Lu=p.useCallback(P=>{if(!Et)return!1;try{ote(localStorage,Et,P)}catch(U){return an(U instanceof Error?U.message:"浏览器拒绝保存草稿,请稍后重试。"),!1}return Ah.current=P,VR(P),an(""),!0},[Et]),$u=p.useCallback(P=>{var U;P&&((U=Nh.current)==null?void 0:U.id)!==P||(Nh.current=null,D0.current!==null&&(window.clearTimeout(D0.current),D0.current=null))},[]),Rh=p.useCallback(()=>{const P=Nh.current;if(!P)return!0;const U=Lu([P,...Ah.current.filter(X=>X.id!==P.id)]);return U&&$u(),U},[$u,Lu]),tEe=p.useCallback((P,U,X,ne)=>{!P||!Et||(Nh.current&&Nh.current.id!==P&&Rh(),Nh.current={id:P,draft:U,updatedAt:Date.now(),deploymentTarget:X,creationMode:ne},D0.current!==null&&window.clearTimeout(D0.current),D0.current=window.setTimeout(Rh,W3t))},[Rh,Et]),KR=p.useCallback(P=>{!P||!Et||($u(P),Lu(Ah.current.filter(U=>U.id!==P)))},[$u,Lu,Et]),iF=p.useCallback(P=>{if(!Et||P.length===0)return;const U=new Set(P.map(X=>X.id));Nh.current&&U.has(Nh.current.id)&&$u(),Lu(Ah.current.filter(X=>!U.has(X.id))),QR(X=>Object.fromEntries(Object.entries(X).filter(([ne])=>!U.has(ne)))),U.has(Ms)&&(dl(""),Ca(null),oc(null),Do.current=null,localStorage.removeItem(O3(Et)))},[$u,Lu,Ms,Et]),sF=p.useCallback(P=>{if(!P||!Et)return;$u(P);const U=Do.current,X=Ah.current.filter(ne=>ne.id!==P);Lu((U==null?void 0:U.id)===P?[U,...X]:X)},[$u,Lu,Et]);p.useEffect(()=>(window.addEventListener("pagehide",Rh),()=>{window.removeEventListener("pagehide",Rh)}),[Rh]),p.useEffect(()=>{if(!Et){$u(),Ah.current=[],VR([]),lk([]),dl(""),an(""),Do.current=null;return}let P=[],U="";try{P=q5t(localStorage,Et),localStorage.getItem(NR(Et))!==null&&ote(localStorage,Et,P),U=localStorage.getItem(O3(Et))||"",an("")}catch(ne){an(ne instanceof Error?ne.message:"无法读取本机草稿,请稍后重试。")}Ah.current=P,VR(P),lk(tMt(Et));const X=P.find(ne=>ne.id===U);Do.current=X??null,ul==="custom"&&X&&(dl(X.id),Ca(X.draft),I0(h3(X)==="quick"?"vulcan":"traditional"),oc(X.deploymentTarget??null))},[$u,Et]),p.useEffect(()=>{if(!Et)return;const P=O3(Et);try{ul==="custom"&&Ms?localStorage.setItem(P,Ms):localStorage.removeItem(P)}catch{an("浏览器拒绝保存当前草稿位置,请检查站点存储权限后重试。")}},[ul,Ms,Et]);const nEe=p.useCallback(P=>{if(!Et)return;const U=[...new Set(P.filter(Boolean))];lk(U),localStorage.setItem(g$(Et),JSON.stringify(U))},[Et]),rEe=p.useCallback(async P=>{const U=P.filter(st=>!!st.runtimeId&&st.canDelete===!0);if(U.length===0)return;const X=gMt(Xc,n),ne=new Set(U.map(st=>st.runtimeId));tF(st=>{const Gt=new Set(st);for(const yt of ne)Gt.add(yt);return Gt}),d_(ne);const me=new Set,ye=new Set,ke=new Set,mt=[];for(const st of U)try{if(!st.region)throw new Error("Runtime 缺少地域信息,无法删除");await ple(st.runtimeId,st.region),qA(st.runtimeId),me.add(st.runtimeId),ye.add(st.id)}catch(Gt){const yt=Gt instanceof Error?Gt.message:String(Gt);ke.add(st.runtimeId),mt.push(`${st.label}: ${yt}`)}if(me.size>0&&(d_(me),PO(su()),hk(Gt=>{if(!Gt)return Gt;const yt=new Set(Gt);for(const Sn of me)yt.delete(Sn);return yt}),eF(Gt=>Object.fromEntries(Object.entries(Gt).filter(([yt])=>!me.has(yt)))),lk(Gt=>{const yt=Gt.filter(Sn=>!ye.has(Sn));return Et&&localStorage.setItem(g$(Et),JSON.stringify(yt)),yt}),Lu(Ah.current.filter(Gt=>{var yt;return!((yt=Gt.deploymentTarget)!=null&&yt.runtimeId)||!me.has(Gt.deploymentTarget.runtimeId)})),(X?me.has(X):U.some(Gt=>Gt.id===n))&&(jEe(),Pn(null),cs(!1),Xi(!1),lr(!1),us(!1),ti(!1),Na(null),ea(""),ta(""),ni(!0),Ne("")),vr!=null&&vr.runtime&&me.has(vr.runtime.runtimeId)&&(Pn(null),cs(!1),Xi(!1),lr(!1),us(!1),Mu(),ea(""),ta(""),ni(!0),Ne(""))),ke.size>0&&tF(st=>{const Gt=new Set(st);for(const yt of ke)Gt.delete(yt);return Gt}),mt.length>0){const st=mt.slice(0,3).join(";"),Gt=mt.length>3?`;另有 ${mt.length-3} 个失败`:"";throw new Error(`${mt.length} 个 Agent 删除失败:${st}${Gt}`)}},[vr,n,Lu,Xc,Mu,Et]),JR=p.useCallback(async()=>{ZU(!0),KU("");try{const P=[];let U="";do{const X=await V1({scope:CO,region:"all",pageSize:100,nextToken:U});P.push(...X.runtimes),U=X.nextToken}while(U&&P.length<2e3);hk(new Set(P.map(X=>X.runtimeId))),eF(Object.fromEntries(P.map(X=>[X.runtimeId,{canDelete:X.canDelete}])))}catch(P){KU(P instanceof Error?P.message:String(P))}finally{ZU(!1)}},[CO]);function iEe(P){console.log("create agent draft:",P),Pn(null),Fd()}function eI(P,U){console.log("Agent added, navigating to:",P,U),PO(su()),hk(null),d_(),KR(Ms),dl(""),Do.current=null,oc(null),ea(""),ta(P),ck("basic"),Pn(null),ti(!0),r(P)}const tI=p.useCallback(P=>{Pn(null),lr(!1),Mu(),ti(!0),ta(""),ck("basic"),ea(P.id),Ne("")},[Mu]),gk=p.useCallback(P=>{Rh();const U=Ms?{...P,draftId:Ms}:P;Ms&&QR(X=>({...X,[Ms]:P.id})),N0(U),tI(U)},[Ms,Rh,tI,N0]),bk=p.useCallback(async P=>{if(!P.runtimeId)throw new Error("部署完成,但未返回 Runtime ID。");const U=Ms;U&&(KR(U),QR(ye=>{if(!ye[U])return ye;const ke={...ye};return delete ke[U],ke})),dl(""),Do.current=null,oc(null);const X=(Gc==null?void 0:Gc.region)??L0,ne=await NT(P.runtimeId,P.runtimeName,P.region??X,P.version,{waitForReady:!0,agentName:P.agentName});PO(su()),ae(ye=>ye+1);const me=await y3(ne);Ps.current.set(ne,me),bs(me),hk(ye=>{const ke=new Set(ye??[]);return ke.add(P.runtimeId),ke}),d_(),ta(ne),ck("basic"),ea(""),Pn(null),ti(!0),r(ne)},[Ms,L0,KR,Gc]),B0=p.useRef(null),nI=p.useRef(new Map),sEe=p.useRef(0),aF=p.useRef(new Map),oF=Xc.some(P=>!!(P.runtimeId&&P.region)&&P.apps.some(U=>gu(P.id,U)===n));p.useLayoutEffect(()=>{const P=new Map;Xt.forEach((U,X)=>{var ke;const ne=((ke=U.meta)==null?void 0:ke.eventId)??"",me=!!(oF&&ne&&Gh(U)),ye=X===Xt.length-1&&(Tn||Ln);P.set(X,{enabled:!!(me&&Dn!=="byteplus"&&!ye&&!w3(U)),turn:U,input:me?x3(Xt,X):""})}),aF.current=P},[Tn,Dn,Ln,oF,Xt]);const lF=p.useCallback(()=>{var ke;const P=window.getSelection(),U=(P==null?void 0:P.anchorNode)instanceof Element?P.anchorNode:(ke=P==null?void 0:P.anchorNode)==null?void 0:ke.parentElement,X=U==null?void 0:U.closest(".turn--assistant");if(!X)return;const ne=Number(X.dataset.responseAnnotationIndex);if(!Number.isInteger(ne))return;const me=aF.current.get(ne);if(!(me!=null&&me.enabled))return;const ye=N3t(X,P);ye&&Ut({selectionId:++sEe.current,turn:me.turn,input:me.input,selectedText:ye.text,anchor:ye.anchor})},[]);p.useEffect(()=>{let P=null;const U=X=>{X.target instanceof Element&&X.target.closest(".response-annotation-popover")||(P!==null&&window.cancelAnimationFrame(P),P=window.requestAnimationFrame(()=>{P=null,lF()}))};return document.addEventListener("mouseup",U,!0),document.addEventListener("keyup",U,!0),()=>{P!==null&&window.cancelAnimationFrame(P),document.removeEventListener("mouseup",U,!0),document.removeEventListener("keyup",U,!0)}},[lF]);const Ih=p.useRef(!0),Dh=p.useRef(!1),vm=p.useRef(null),cF=p.useRef({key:"",turnCount:0}),rI=(y==null?void 0:y.id)??a;p.useLayoutEffect(()=>{const P=B0.current,U=cF.current,X=U.key!==rI,ne=!X&&Xt.length>U.turnCount;if(cF.current={key:rI,turnCount:Xt.length},!P||Xt.length===0||!X&&!ne)return;Ih.current=!0,Dh.current=!1,vm.current!==null&&(window.clearTimeout(vm.current),vm.current=null);const me=window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(X||me){P.scrollTop=P.scrollHeight;return}Dh.current=!0,P.scrollTo({top:P.scrollHeight,behavior:"smooth"}),vm.current=window.setTimeout(()=>{Dh.current=!1,vm.current=null;const ye=B0.current;ye&&Ih.current&&(ye.scrollTop=ye.scrollHeight)},450)},[rI,Xt.length]),p.useLayoutEffect(()=>{const P=B0.current;!P||!Ih.current||Dh.current||(P.scrollTop=P.scrollHeight)},[Tn,Xt]),p.useEffect(()=>{if(!DO||jh||Xt.length===0)return;const P=nI.current.get(DO);if(!P)return;Ih.current=!1,P.scrollIntoView({behavior:"smooth",block:"center"});const U=window.setTimeout(()=>{uk("")},2600);return()=>window.clearTimeout(U)},[DO,jh,Xt]),p.useEffect(()=>()=>{vm.current!==null&&window.clearTimeout(vm.current)},[]);const aEe=p.useCallback(()=>{const P=B0.current;!P||Dh.current||(Ih.current=P.scrollHeight-P.scrollTop-P.clientHeight<32)},[]),oEe=p.useCallback(P=>{P.deltaY<0&&(Dh.current=!1,Ih.current=!1)},[]),lEe=p.useCallback(()=>{Dh.current=!1,Ih.current=!1},[]),cEe=p.useCallback(()=>{const P=B0.current;!P||!Ih.current||Dh.current||(P.scrollTop=P.scrollHeight)},[]),iI=p.useCallback(()=>{$d(null),BM().then(P=>{Bd(P.userId),xi(P.info),A0(!!P.local),Du(P.status),P.status==="authenticated"&&(mk.current=!0,$0.current=!0,localStorage.removeItem(Jc.app),r(""),Pn(null),cs(!1),Xi(!1),lr(!1),us(!1),ti(!1),ni(!1))}).catch(P=>{$d(P instanceof Error?P.message:String(P))})},[]);p.useEffect(()=>{iI()},[iI]),p.useEffect(()=>{const P=()=>{tc(""),Pu(!0)};return window.addEventListener(QM,P),TIe()&&P(),()=>window.removeEventListener(QM,P)},[]);const uEe=p.useCallback(async()=>{if(cl.current)return;cl.current=!0;const P=OIe();if(!P){cl.current=!1,tc("登录窗口被浏览器拦截,请允许弹出窗口后重试。");return}Hc(!0),tc("");try{for(;;){await new Promise(U=>window.setTimeout(U,1e3));try{const U=await BM();if(U.status==="authenticated"){Bd(U.userId),xi(U.info),A0(!!U.local),Du(U.status),Pu(!1),CIe(),P.close();return}}catch{}if(P.closed){tc("登录窗口已关闭,请重新登录以继续当前操作。");return}}}finally{cl.current=!1,Hc(!1)}},[]);p.useEffect(()=>{Ch&&Et&&kH(Et)},[Ch,Et]),p.useEffect(()=>{if(ei!=="authenticated"||!Et||bi)return;const P=new URLSearchParams(window.location.search);if(P.get("view")!=="runtime-deploy"||P.get("source")!=="intelligent-development")return;const U=P.get("sessionId")??"",X=P.get("artifactSha256")??"",ne=P.get("validationReportSha256")??"",me=P.get("projectId")??"",ye=P.get("versionId")??"";if(!U||!X||!ne)return;const ke=new AbortController;return(me&&ye?_ee(me,ye,U,X,ne,ke.signal):Tee(U,X,ne,ke.signal)).then(st=>{if(!ke.signal.aborted){if(!st.deployable){mr("该源码尚未准备好,请返回对话继续处理。");return}Jr({...st,validatedAt:st.validatedAt||"",gateSummary:st.gateSummary||[]})}}).catch(st=>{ke.signal.aborted||mr(st instanceof Error?st.message:String(st))}),()=>ke.abort()},[ei,bi,Et]),p.useEffect(()=>{if(!R0&&!["intelligent","migration"].includes(ul??""))return;if(ei!=="authenticated"||!Et){Pr(null),mr(""),Kr(!0);return}const P=new AbortController;return Kr(!0),mr(""),fetch(So("/web/intelligent-development/capabilities"),{headers:ph({Accept:"application/json"}),signal:P.signal}).then(async U=>{if(!U.ok)throw new Error(`智能开发能力检查失败(HTTP ${U.status})`);return U.json()}).then(U=>{if(P.signal.aborted)return;const X={enabled:U.enabled===!0,reason:typeof U.reason=="string"?U.reason:"",projectStorageEnabled:U.projectStorageEnabled===!0,projectStorageReason:typeof U.projectStorageReason=="string"?U.projectStorageReason:""};if(U.model!==void 0){if(typeof U.model!="object"||U.model===null)throw new Error("智能开发模型能力格式错误。");const ne=U.model;if(typeof ne.configured=="boolean"&&typeof ne.id=="string")X.model={configured:ne.configured,id:ne.id};else throw new Error("智能开发模型能力格式错误。")}Pr(X)}).catch(U=>{P.signal.aborted||mr(U instanceof Error?U.message:String(U))}).finally(()=>{P.signal.aborted||Kr(!1)}),()=>P.abort()},[R0,ei,ul,Et]),p.useEffect(()=>{if(ei!=="authenticated"||!Et){bs({});return}const P=f.current;if((P==null?void 0:P.agentId)===n&&P.userId===Et)return;const U=Ps.current.get(n);if(U){bs(U);return}let X=!1;return bs({}),y3(n).then(ne=>{X||(Ps.current.set(n,ne),bs(ne))}),()=>{X=!0}},[n,ei,Et]),p.useLayoutEffect(()=>{!pn||yi.skillCustomizationEnabled!==!1||_r!=="skill"||(Ve("agent"),ar(null),Gn(null))},[yi.skillCustomizationEnabled,pn,_r]),p.useEffect(()=>{if(ei!=="authenticated"||!Et){Qd(null);return}let P=!1;return Qd(null),Joe().then(U=>{P||Qd(U)}).catch(U=>{console.warn("[app] /web/access failed; using ordinary-user access:",U),P||Qd(Koe)}),()=>{P=!0}},[ei,Et]),p.useEffect(()=>{Zoe().then(P=>{const U="prod";HCt({enabled:P.telemetry.enabled,environment:U});const X=P.telemetry.studio;qCt({userPoolId:(X==null?void 0:X.userPoolId)??"",studioDeployId:(X==null?void 0:X.deployId)??"",applicationId:(X==null?void 0:X.applicationId)??"",functionId:(X==null?void 0:X.functionId)??"",studioRegion:(X==null?void 0:X.region)??"",studioProject:(X==null?void 0:X.project)??"",studioVersion:(X==null?void 0:X.version)||P.version,environment:U,cloudProvider:P.provider,accountId:(X==null?void 0:X.accountId)??"",accountIdResolutionError:(X==null?void 0:X.accountIdResolutionError)??""}),GCt({authState:"anonymous"}),JE(P.features),IR(P.agentsSource),PR(P.provider),$R((X==null?void 0:X.region)||Zr(P.provider)),DR(P.branding),LR(P.version),ek(!0)})},[]),p.useEffect(()=>{if(ei!=="authenticated"||!qc||!tr||!C0)return;const P=String(tr.telemetry.userId).trim();P&&(XCt({userUniqueId:P,accountId:tr.telemetry.accountId??"",userRole:tr.role==="admin"?"admin":"member",userSource:Ch?"local":"sso"}),WCt({agentsSource:nc}))},[tr,nc,ei,Ch,C0,qc]),p.useEffect(()=>{pk(P=>{const U=Zr(Dn);return!P||Dn==="byteplus"&&P.startsWith("cn-")||Dn==="volcengine"&&P.startsWith("ap-")?U:P})},[Dn]),p.useEffect(()=>{tr&&(tr.capabilities.createAgents||(Pn(null),Ca(null),Xi(!1),lr(!1),HU([])),tr.capabilities.manageAgents||ti(!1))},[tr]);let fo={kind:"home"};if(ei==="authenticated"){if(Un!==null)fo={kind:"page",title:"问题反馈"};else if(XR)fo={kind:"page",title:"系统信息"};else if(fk)fo={kind:"page",title:"定时任务"};else if(sc)fo={kind:"page",title:sc==="catalog"?"自动化":twe(sc).name};else if(Z)fo={kind:"page",title:Z.session.displayName||"智能体"};else if(Me)fo={kind:"page",title:Me.displayName||"智能体"};else if(fl||jh)fo={kind:"page",title:(vr==null?void 0:vr.name)||"智能体"};else if(R0)fo={kind:"page",title:"创建智能体"};else if(IO)fo={kind:"page",title:"搜索"};else if(ok)fo={kind:"page",title:"添加智能体"};else if(j0)fo={kind:"page",title:BSe||"资源库"};else if(ul)fo={kind:"page",title:ul==="custom"?Gc!=null&&Gc.name?`更新 ${Gc.name}`:"创建智能体":ul==="package"?"从代码包添加":"迁移智能体"};else if(y){const P=Wn.threads.find(U=>U.id===y.threadId);fo={kind:"conversation",title:(P==null?void 0:P.name)||(P==null?void 0:P.preview)||y.displayName}}else if(a){const P=i.find(X=>X.id===a),U=UN(P==null?void 0:P.events);fo=U==="新会话"?{kind:"home"}:{kind:"conversation",title:U}}}const uF=RAt(Om.title,fo);p.useEffect(()=>{ei!=="authenticated"||nc!=="cloud"||!C0||!jh||vr||JR()},[vr,nc,ei,jh,JR,C0]),p.useEffect(()=>{document.title=uF;let P=document.querySelector('link[rel~="icon"]');P||(P=document.createElement("link"),P.rel="icon",document.head.appendChild(P)),P.removeAttribute("type"),P.href=Om.logoUrl||(Dn==="byteplus"?g7:rj)},[Dn,Om.logoUrl,uF]),p.useEffect(()=>{fetch("/web/runtime-config",{signal:AbortSignal.timeout(1e4)}).then(P=>P.ok?P.json():null).then(P=>{P&&LSe(!!P.credentials)}).catch(P=>{console.warn("[app] /web/runtime-config probe failed; workbench stays hidden:",P)})},[]);function dEe(P){kH(P),mk.current=!0,$0.current=!0,localStorage.removeItem(Jc.app),Qd(null),Pn(null),Ca(null),cs(!1),Xi(!1),lr(!1),us(!1),ti(!1),Fd(),r(""),ni(!1),Bd(P),xi({name:P}),A0(!0),Du("authenticated")}function fEe(){Qd(null),Ch?(bIe(),Bd(""),xi(void 0),Du("unauthenticated")):vIe()}p.useEffect(()=>{if(ei==="authenticated"){if(nc==="cloud"){const P=zte(Xc);r(U=>U&&P.includes(U)?U:(U&&($0.current=!0,localStorage.removeItem(Jc.app)),""));return}Kae().then(P=>{t(P);const U=zte(Xc);r(X=>X&&(P.includes(X)||U.includes(X))?X:(X&&($0.current=!0,localStorage.removeItem(Jc.app)),""))}).catch(P=>Ne(String(P)))}},[ei,nc,Xc]),p.useEffect(()=>{n?($0.current=!1,localStorage.setItem(Jc.app,n)):localStorage.removeItem(Jc.app)},[n]),p.useEffect(()=>{const P=f.current;if((P==null?void 0:P.agentId)===n&&P.userId===Et){Vn(!1);return}let U=!1;if(Vc(null),pe(uc()),ei!=="authenticated"||fl||vr||!n){Vn(!1);return}return Vn(!0),qM(n).then(X=>{U||Vc(X)}).catch(()=>{U||Vc(null)}).finally(()=>{U||Vn(!1)}),()=>{U=!0}},[vr,n,_h,ei,fl]),p.useEffect(()=>{tr&&localStorage.setItem(Jc.view,tr.capabilities.createAgents?ul??"chat":"chat")},[tr,ul]),p.useEffect(()=>{localStorage.setItem(Jc.session,a),Tt.current=a},[a]),p.useEffect(()=>{const P=Vte(Xc,n);if(!P||!Et){ca.current=()=>{},lo(ri=>ri.size===0?ri:new Set);return}const{runtimeId:U,region:X,appName:ne}=P;let me=!1,ye=0;function ke(){la.current!==void 0&&(window.clearTimeout(la.current),la.current=void 0)}function mt(ri){ke(),la.current=window.setTimeout(()=>void Gt(),ri)}function st(ri){const _i=new Set(ri.items.filter(Nn=>Nn.state==="running").map(Nn=>Nn.sessionId));if(lo(Nn=>Nn.size===_i.size&&[..._i].every(Yr=>Nn.has(Yr))?Nn:_i),_i.size>0){mt(Y3t);return}const Bt=ri.items.filter(Nn=>Nn.state==="pending").map(Nn=>Date.parse(Nn.dueAt)).filter(Number.isFinite);Bt.length>0&&mt(Math.max(Z3t,Math.min(...Bt)-Date.now()))}async function Gt(){const ri=++ye;try{const _i=await FM({runtimeId:U,region:X,appName:ne,userId:Et});if(me||ri!==ye)return;st(_i)}catch{!me&&ri===ye&&mt(Ite)}}const yt=()=>{ke(),Gt()};ca.current=yt;const Sn=f.current;return(Sn==null?void 0:Sn.agentId)===n&&Sn.userId===Et?Sn.automaticEvaluationStatuses?st(Sn.automaticEvaluationStatuses):mt(Ite):yt(),()=>{me=!0,ye+=1,ke(),ca.current===yt&&(ca.current=()=>{})}},[n,Xc,Et]),p.useEffect(()=>()=>{d.current+=1,f.current=null},[]),p.useEffect(()=>()=>vs.current.forEach(P=>P.abort()),[]),p.useEffect(()=>()=>Ar.current.forEach(P=>{window.clearTimeout(P)}),[]),p.useEffect(()=>()=>{var P,U,X;(P=We.current)==null||P.abort(),(U=ct.current)==null||U.abort(),(X=kt.current)==null||X.abort()},[]),p.useEffect(()=>{if(fl||vr||y||!n||!Et)return;const P=f.current;if((P==null?void 0:P.agentId)===n&&P.userId===Et){f.current=null;return}let U=!1;return(async()=>{const X=await MO(n);if(!U){if(!mk.current){mk.current=!0;const ne=localStorage.getItem(Jc.session)||"";if(Pte()===null&&ne&&X.some(me=>me.id===ne)){LO(ne);return}}Fd()}})(),()=>{U=!0}},[vr,n,fl,y,Et]),p.useEffect(()=>{const P=YR.current;P&&P.app===n&&(YR.current=null,LO(P.sid))},[n]);function dF(P,U){us(!1),P===n?LO(U):(YR.current={app:P,sid:U},r(P))}function fF(P,U){en(X=>{const ne={...X};for(const me of U)ne[Rx(P,me.id)]=RH(me.events??[]);return ne}),s(U)}async function MO(P){const U=u.current+1;u.current=U;try{const X=await Rte(P,Et);return u.current!==U||fF(P,X),X}catch(X){return u.current===U&&Ne(String(X)),[]}}function sI(P="codex",U=!1){y||(Ne(""),Ge(""),je("confirm"),Be(P),be(U),Oe(!0))}function hEe(){var P;(P=We.current)==null||P.abort(),We.current=null,Oe(!1),je("confirm"),Ge(""),!y&&ln!=="agent"&&!he&&Kn("agent")}async function pEe(P,U){var me;(me=We.current)==null||me.abort();const X=new AbortController;We.current=X,je("loading"),Ge("");const ne=YCt({sandboxKind:Ae,sandboxSource:he?"my_agents":"new_chat"});try{const ye=Ae==="codex"?await di.startSession({displayName:P,persistent:U,signal:X.signal}):await di.startAgentSession(Ae,{displayName:P,persistent:U,signal:X.signal});if(We.current!==X){ne.fail({errorKind:"abort"});return}if(ne.succeed({sandboxId:String(ye.id)}),he){Ue(mt=>mt+1),Oe(!1),je("confirm"),ni(!0);return}if(Ae!=="codex"){const mt=await di.openAgentSession(Ae,ye.id,{signal:X.signal});if(We.current!==X)return;Tt.current="",l(""),b([]),ot(""),pe(uc()),Kn(Ae==="deepseek-harness"?"deepseek-harness":"agent"),sk(Oi),Ur([]),He(),x([]),O(null),Pn(null),cs(!1),Xi(!1),lr(!1),us(!1),ti(!1),Na(null),ni(!1),Ye(null),_e(mt),Oe(!1),je("confirm");return}const ke=await di.connectSession(ye.id,{signal:X.signal});if(We.current!==X)return;Tt.current="",l(""),b([]),ot(""),pe(uc()),Kn("temporary"),sk(Oi),Ur([]),He(),x([]),O(ke),Pn(null),cs(!1),Xi(!1),lr(!1),us(!1),ti(!1),Na(null),ni(!1),Ye(null),_e(null),Oe(!1),je("confirm")}catch(ye){if(ne.fail(mo(ye)),(ye==null?void 0:ye.name)==="AbortError"||We.current!==X)return;Ge(ye instanceof Error?ye.message:String(ye)),je("error")}finally{We.current===X&&(We.current=null)}}function mEe(P,U){Tt.current="",l(""),b([]),ot(""),pe(uc()),sk(Oi),Ur([]),He(),x(U),ft.current=P.id,O(P),S(P.busy),Pn(null),cs(!1),Xi(!1),lr(!1),us(!1),ti(!1),Na(null),ni(!1),uo([]),Aa(null),ac(!1),Ye(null),_e(null)}async function yk(P,U="my_agents"){Ne("");const X=qP({targetId:String(P.id),agentKind:P.toolName,connectSource:U});try{const ne=P.resourceType==="snapshot"?await di.resumeSnapshot(P.toolName,P.snapshotId):P;if(P.resourceType==="snapshot"&&Ue(ye=>ye+1),ne.toolName==="codex"){const ye=await di.connectSession(ne.id),ke=await eMt(ye);X.succeed({sandboxStatus:Mte(ye.status)}),Tt.current="",l(""),b([]),ot(""),pe(uc()),He(),ke?(x(Dte(ke,ye.busy)),O({...ye,threadId:ke.threadId,cwd:ke.cwd??ye.cwd,workspaceLocked:ke.workspaceLocked,permissions:ke.permissions,...ke.model?{model:ke.model}:{}})):(x([]),O(ye)),S(ye.busy),xm("sandbox-agent-detail"),Ye(null),_e(null),ni(!1),ti(!1);return}const me=await di.openAgentSession(ne.toolName,ne.id);X.succeed({sandboxStatus:Mte(me.session.status)}),xm("sandbox-agent-detail"),_e(me),Ye(null),ni(!1),ti(!1)}catch(ne){throw X.fail(mo(ne)),Ne(ne instanceof Error?ne.message:String(ne)),ne}}async function gEe(P){const X=(await di.listSessions()).find(ne=>ne.resourceType==="session"&&ne.toolName==="codex"&&ne.id===P);if(!X)throw new Error("云端 Codex Session 暂未出现在列表中,请稍后重试。");await yk(X,"my_agents"),Ee(!1)}function bEe(P){ce(P.toolName),WR({page:"sandbox-agent-detail",returnTo:"agents"}),Ye(P),_e(null),ni(!0),ti(!1),Ne("")}async function yEe(P){P.resourceType==="snapshot"?await di.deleteSnapshot(P.toolName,P.snapshotId):((y==null?void 0:y.id)===P.id&&lc(),P.toolName==="codex"?await di.deleteSession(P.id):await di.deleteAgentSession(P.toolName,P.id)),ce(P.toolName),xm("sandbox-agent-detail"),Ye(null),_e(null),Ue(U=>U+1),ni(!0)}async function OEe(){const P=rt;if(!P)return;await Wn.deleteThread(P.id)&&Re(null)}function lc(P=!0){var X;(X=kt.current)==null||X.abort(),kt.current=null,ft.current="",xt.current="",S(!1),He(),x([]),Ur([]),ot(""),Ne(""),Kn("agent"),k(!1),T(""),A(!1),M(!1),$(null),j(null),F(!1),H(""),Q(null),K(!1),ge(""),pt(),Re(null),q(!1),Ie.current+=1;const U=y;O(null),U&&P&&(U.intelligentDevelopment?Fh:di).closeSession(U.id).catch(me=>Ne(String(me)))}async function aI(P){const U=y;if(U){$(P),j(null),H(""),F(!0);try{const X=P==="terminal"?await Mi.launchTerminal(U.id):await Mi.launchBrowser(U.id);j(X)}catch(X){H(X instanceof Error?X.message:String(X))}finally{F(!1)}}}async function xEe(){var U;const P=y;if(!(!P||G==="copying")){J("copying"),Ne("");try{if(!((U=navigator.clipboard)!=null&&U.writeText))throw new Error("当前浏览器不支持写入剪贴板。");const X=await di.getEndpoint(P.id);if(await navigator.clipboard.writeText(X.endpoint),ft.current!==P.id)return;J("copied"),xe.current!==void 0&&window.clearTimeout(xe.current),xe.current=window.setTimeout(()=>{J("idle"),xe.current=void 0},1600)}catch(X){if(ft.current!==P.id)return;J("idle"),Ne(X instanceof Error?X.message:String(X))}}}async function vEe(P){const U=y;if(!(!U||E)){k(!0),T("");try{const X=await Mi.updatePermissions(U.id,P);O(ne=>(ne==null?void 0:ne.id)===U.id?{...ne,permissions:X}:ne),gt(U.id,"已更新当前 Sandbox Session 的 Codex 权限",[{label:"沙箱模式",value:dMt[X.sandboxMode]},{label:"审批策略",value:fMt[X.approvalPolicy]},{label:"审批方式",value:hMt[X.approvalsReviewer]},{label:"网络访问",value:X.networkAccess?"允许":"关闭"}]),ft.current===U.id&&A(!1)}catch(X){T(X instanceof Error?X.message:String(X))}finally{k(!1)}}}const wEe=p.useCallback(async P=>{const U=y==null?void 0:y.id;if(!U)throw new Error("当前没有已连接的 Sandbox。");return Mi.listDirectories(U,P)},[y==null?void 0:y.id]);async function SEe(P){const U=y;if(!(!U||U.workspaceLocked||E)){k(!0),T("");try{const X=await Mi.updateWorkspace(U.id,P);O(ne=>(ne==null?void 0:ne.id)===U.id?{...ne,cwd:X}:ne),Wn.invalidateSkills(),gt(U.id,"已更新工作空间",[{label:"工作目录",value:X,code:!0}]),ft.current===U.id&&M(!1)}catch(X){T(X instanceof Error?X.message:String(X))}finally{k(!1)}}}async function EEe(P){const U=y,X=z;if(!(!U||!X||V)){K(!0),ge("");try{await Mi.resolveApproval(U.id,X.id,P),gt(U.id,pMt(X,P),mMt(X),xt.current),Q(ne=>(ne==null?void 0:ne.id)===X.id?null:ne)}catch(ne){ge(ne instanceof Error?ne.message:String(ne))}finally{K(!1)}}}async function kEe(P){const U=y;if(!U||ie)return;const X=++Ie.current;Ne(""),q(!0);const ne=Array.from(P).map(me=>{const ye={id:Ute(),mimeType:Fte(me),name:me.name,sizeBytes:me.size,status:"uploading",previewUrl:it(me)};return{file:me,attachment:ye}});Ur(me=>[...me,...ne.map(({attachment:ye})=>ye)]);try{const ye=(await Promise.all(ne.map(async({file:ke,attachment:mt})=>{try{const st=await Mi.uploadFile(U.id,ke);return Ie.current!==X?null:(Ur(Gt=>Gt.map(yt=>yt.id===mt.id?{...yt,id:st.id,uri:st.path,name:st.name,mimeType:st.mimeType,sizeBytes:st.sizeBytes,status:"ready"}:yt)),st)}catch(st){if(Ie.current!==X)return null;const Gt=st instanceof Error?st.message:String(st);return Ur(yt=>yt.map(Sn=>Sn.id===mt.id?{...Sn,status:"error",error:Gt}:Sn)),Ne(Gt),null}}))).filter(ke=>ke!==null);Ie.current===X&&ye.length>0&>(U.id,ye.length===1?"已上传文件到 Sandbox":`已上传 ${ye.length} 个文件到 Sandbox`,ye.map((ke,mt)=>({label:ye.length===1?"文件":`文件 ${mt+1}`,value:ke.path,code:!0})))}finally{if(Ie.current===X)q(!1);else for(const{attachment:me}of ne)ve(me.previewUrl)}}function _Ee(P){const U=Oi.find(X=>X.id===P);U&&(ve(U.previewUrl),Ur(X=>X.filter(ne=>ne.id!==P)))}function TEe(){var X;const P=kt.current,U=y;if(P){if(U!=null&&U.intelligentDevelopment){if(((X=nt.current)==null?void 0:X.controller)===P)return;const ne=Fh.interruptSession(U.id).then(()=>{var me;return((me=nt.current)==null?void 0:me.controller)===P&&P.abort(),!0}).catch(me=>{var ye;return((ye=nt.current)==null?void 0:ye.controller)===P&&(nt.current=null),ft.current===U.id&&kt.current===P&&Ne(me instanceof Error?me.message:String(me)),!1});nt.current={controller:P,promise:ne};return}P.abort(),U&&di.interruptSession(U.id).catch(ne=>{ft.current===U.id&&Ne(ne instanceof Error?ne.message:String(ne))})}}function hl(P){if(y!=null&&y.intelligentDevelopment&&w){qt.current=P,Xe(!0);return}P()}function CEe(){var ne;const P=y,U=qt.current;if(!(P!=null&&P.intelligentDevelopment)||!U){Xe(!1),qt.current=null;return}Ne("");const X=Fh.interruptSession(P.id);(ne=kt.current)==null||ne.abort(),qt.current=null,Xe(!1),U(),X.catch(()=>{ft.current||Ne("已离开开发环境,但未能确认本轮构建已停止。任务可能仍在运行,请稍后从历史会话检查状态。")})}async function oI(P,U=[],X=[],ne){var zt;const me=ne??y,ye=U.filter(Nt=>Nt.status==="ready"&&Nt.uri);if(!me||w||!P.trim()&&ye.length===0)return;Ne(""),Q(null),ge("");const ke=eee({agentId:String(me.id),agentKind:me.toolName,messageSource:"composer",sessionState:"existing",sessionId:String(me.id)}),mt=new AbortController;(zt=kt.current)==null||zt.abort(),kt.current=mt;const st=[];X.length>0&&st.push({kind:"invocation",value:{skills:X.map(({name:Nt,description:fn})=>({name:Nt,description:fn}))}}),ye.length>0&&st.push({kind:"attachment",files:ye.map(Nt=>({id:Nt.id,mimeType:Nt.mimeType,name:Nt.name,sizeBytes:Nt.sizeBytes,previewUrl:Nt.previewUrl}))}),P.trim()&&st.push({kind:"text",text:P});const Gt=ye.map(Nt=>Nt.uri).filter(Nt=>!!Nt),Sn=[X.map(Nt=>`$${Nt.name}`).join(" "),P.trim()].filter(Boolean).join(" "),ri=Gt.length>0?[Sn,"以下文件已上传到当前 Sandbox 工作空间,请在任务中使用:",...Gt.map(Nt=>`- ${Nt}`)].filter(Boolean).join(`
diff --git a/veadk/webui/assets/chunks/CodeDiffEditor-DLkdb2YA.js b/veadk/webui/assets/chunks/CodeDiffEditor-DWPwBXPg.js
similarity index 99%
rename from veadk/webui/assets/chunks/CodeDiffEditor-DLkdb2YA.js
rename to veadk/webui/assets/chunks/CodeDiffEditor-DWPwBXPg.js
index f29a207b1..c7760af3a 100644
--- a/veadk/webui/assets/chunks/CodeDiffEditor-DLkdb2YA.js
+++ b/veadk/webui/assets/chunks/CodeDiffEditor-DWPwBXPg.js
@@ -1,3 +1,3 @@
-import{T as Fe,i as $,f as L,E as te,b as Ve,S as R,C as je,u as W,af as Ie,B as at,F as Ue,v as dt,D as k,m as G,G as oe,W as J,ao as ft,ai as ht,R as We,aj as ct,an as ne,n as ut,ap as He,ay as Q,av as mt,H as gt}from"../app/index-Ch6a-P8E.js";class v{constructor(e,n,l,r){this.fromA=e,this.toA=n,this.fromB=l,this.toB=r}offset(e,n=e){return new v(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function y(t,e,n,l,r,i){if(t==l)return[];let s=de(t,e,n,l,r,i),o=fe(t,e+s,n,l,r+s,i);e+=s,n-=o,r+=s,i-=o;let d=n-e,h=i-r;if(!d||!h)return[new v(e,n,r,i)];if(d>h){let f=t.slice(e,n).indexOf(l.slice(r,i));if(f>-1)return[new v(e,e+f,r,r),new v(e+f+h,n,i,i)]}else if(h>d){let f=l.slice(r,i).indexOf(t.slice(e,n));if(f>-1)return[new v(e,e,r,r+f),new v(n,n,r+f+d,i)]}if(d==1||h==1)return[new v(e,n,r,i)];let a=qe(t,e,n,l,r,i);if(a){let[f,c,u]=a;return y(t,e,f,l,r,c).concat(y(t,f+u,n,l,c+u,i))}return pt(t,e,n,l,r,i)}let j=1e9,I=0,ae=!1;function pt(t,e,n,l,r,i){let s=n-e,o=i-r;if(j<1e9&&Math.min(s,o)>j*16||I>0&&Date.now()>I)return Math.min(s,o)>j*64?[new v(e,n,r,i)]:ge(t,e,n,l,r,i);let d=Math.ceil((s+o)/2);X.reset(d),ee.reset(d);let h=(u,m)=>t.charCodeAt(e+u)==l.charCodeAt(r+m),a=(u,m)=>t.charCodeAt(n-u-1)==l.charCodeAt(i-m-1),f=(s-o)%2!=0?ee:null,c=f?null:X;for(let u=0;uj||I>0&&!(u&63)&&Date.now()>I)return ge(t,e,n,l,r,i);let m=X.advance(u,s,o,d,f,!1,h)||ee.advance(u,s,o,d,c,!0,a);if(m)return Ct(t,e,n,e+m[0],l,r,i,r+m[1])}return[new v(e,n,r,i)]}class Pe{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;nn)this.end+=2;else if(f>l)this.start+=2;else if(i){let c=r+(n-l)-d;if(c>=0&&c=n-a)return[u,r+u-c]}else{let u=n-i.vec[c];if(a>=u)return[a,f]}}}return null}}const X=new Pe,ee=new Pe;function Ct(t,e,n,l,r,i,s,o){let d=!1;return!N(t,l)&&++l==n&&(d=!0),!N(r,o)&&++o==s&&(d=!0),d?[new v(e,n,i,s)]:y(t,e,l,r,i,o).concat(y(t,l,n,r,o,s))}function ze(t,e){let n=1,l=Math.min(t,e);for(;nn||a>i||t.slice(o,h)!=l.slice(d,a)){if(s==1)return o-e-(N(t,o)?0:1);s=s>>1}else{if(h==n||a==i)return h-e;o=h,d=a}}}function fe(t,e,n,l,r,i){if(e==n||r==i||t.charCodeAt(n-1)!=l.charCodeAt(i-1))return 0;let s=ze(n-e,i-r);for(let o=n,d=i;;){let h=o-s,a=d-s;if(h>1}else{if(h==e||a==r)return n-h;o=h,d=a}}}function ie(t,e,n,l,r,i,s,o){let d=l.slice(r,i),h=null;for(;;){if(h||s=n)break;let c=t.slice(a,f),u=-1;for(;(u=d.indexOf(c,u+1))!=-1;){let m=de(t,f,n,l,r+u+c.length,i),p=fe(t,e,a,l,r,r+u),g=c.length+m+p;(!h||h[2]>1}}function qe(t,e,n,l,r,i){let s=n-e,o=i-r;if(sr.fromA-e&&l.toB>r.fromB-e&&(t[n-1]=new v(l.fromA,r.toA,l.fromB,r.toB),t.splice(n--,1))}}function vt(t,e,n){for(;;){_e(n,1);let l=!1;for(let r=0;r3||o>3){let d=r==t.length-1?e.length:t[r+1].fromA,h=i.fromA-l,a=d-i.toA,f=Ce(e,i.fromA,h),c=pe(e,i.toA,a),u=i.fromA-f,m=c-i.toA;if((!s||!o)&&u&&m){let p=Math.max(s,o),[g,C,S]=s?[e,i.fromA,i.toA]:[n,i.fromB,i.toB];p>u&&e.slice(f,i.fromA)==g.slice(S-u,S)?(i=t[r]=new v(f,f+s,i.fromB-u,i.toB-u),f=i.fromA,c=pe(e,i.toA,d-i.toA)):p>m&&e.slice(i.toA,c)==g.slice(C,C+m)&&(i=t[r]=new v(c-s,c,i.fromB+m,i.toB+m),c=i.toA,f=Ce(e,i.fromA,i.fromA-l)),u=i.fromA-f,m=c-i.toA}if(u||m)i=t[r]=new v(i.fromA-u,i.toA+m,i.fromB-u,i.toB+m);else if(s){if(!o){let p=Ae(e,i.fromA,i.toA),g,C=p<0?-1:ve(e,i.toA,i.fromA);p>-1&&(g=p-i.fromA)<=a&&e.slice(i.fromA,p)==e.slice(i.toA,i.toA+g)?i=t[r]=i.offset(g):C>-1&&(g=i.toA-C)<=h&&e.slice(i.fromA-g,i.fromA)==e.slice(C,i.toA)&&(i=t[r]=i.offset(-g))}}else{let p=Ae(n,i.fromB,i.toB),g,C=p<0?-1:ve(n,i.toB,i.fromB);p>-1&&(g=p-i.fromB)<=a&&n.slice(i.fromB,p)==n.slice(i.toB,i.toB+g)?i=t[r]=i.offset(g):C>-1&&(g=i.toB-C)<=h&&n.slice(i.fromB-g,i.fromB)==n.slice(C,i.toB)&&(i=t[r]=i.offset(-g))}}l=i.toA}return _e(t,3),t}let O;try{O=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Qe(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function Ye(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?Qe(n)?1:0:O?!Ke(n)||e==t.length-1?O.test(String.fromCharCode(n))?1:0:O.test(t.slice(e,e+2))?2:0:0}function $e(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?Qe(n)?1:0:O?!Ze(n)||e==1?O.test(String.fromCharCode(n))?1:0:O.test(t.slice(e-2,e))?2:0:0}const Je=8;function pe(t,e,n){if(e==t.length||!$e(t,e))return e;for(let l=e,r=e+n,i=0;ir)return l;l+=s}return e}function Ce(t,e,n){if(!e||!Ye(t,e))return e;for(let l=e,r=e-n,i=0;it>=55296&&t<=56319,Ze=t=>t>=56320&&t<=57343;function N(t,e){return!e||e==t.length||!Ke(t.charCodeAt(e-1))||!Ze(t.charCodeAt(e))}function xt(t,e,n){var l;let r=n==null?void 0:n.override;return r?r(t,e):(j=((l=n==null?void 0:n.scanLimit)!==null&&l!==void 0?l:1e9)>>1,I=n!=null&&n.timeout?Date.now()+n.timeout:0,ae=!1,vt(t,e,y(t,0,t.length,e,0,e.length)))}function Xe(){return!ae}function et(t,e,n){return At(xt(t,e,n),t,e)}const B=Ue.define({combine:t=>t[0]}),re=R.define(),tt=Ue.define(),b=W.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(re)&&(t=n.value);for(let n of e.state.facet(tt))t=n(t,e);return t}});class E{constructor(e,n,l,r,i,s=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=r,this.toB=i,this.precise=s}offset(e,n){return e||n?new E(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let r=et(e.toString(),n.toString(),l);return nt(r,e,n,0,0,Xe())}static updateA(e,n,l,r,i){return ke(Be(e,r,!0,l.length),e,n,l,i)}static updateB(e,n,l,r,i){return ke(Be(e,r,!1,n.length),e,n,l,i)}}function xe(t,e,n,l){let r=n.lineAt(t),i=l.lineAt(e);return r.to==t&&i.to==e&&tf+1&&g>c+1)break;u.push(m.offset(-h+l,-a+r)),[f,c]=we(m.toA+l,m.toB+r,e,n),o++}s.push(new E(u,h,Math.max(h,f),a,Math.max(a,c),i))}return s}const H=1e3;function be(t,e,n,l){let r=0,i=t.length;for(;;){if(r==i){let a=0,f=0;r&&({toA:a,toB:f}=t[r-1]);let c=e-(n?a:f);return[a+c,f+c]}let s=r+i>>1,o=t[s],[d,h]=n?[o.fromA,o.toA]:[o.fromB,o.toB];if(d>e)i=s;else if(h<=e)r=s+1;else return l?[o.fromA,o.fromB]:[o.toA,o.toB]}}function Be(t,e,n,l){let r=[];return e.iterChangedRanges((i,s,o,d)=>{let h=0,a=n?e.length:l,f=0,c=n?l:e.length;i>H&&([h,f]=be(t,i-H,n,!0)),s=h?r[r.length-1]={fromA:m.fromA,fromB:m.fromB,toA:a,toB:c,diffA:m.diffA+p,diffB:m.diffB+g}:r.push({fromA:h,toA:a,fromB:f,toB:c,diffA:p,diffB:g})}),r}function ke(t,e,n,l,r){if(!t.length)return e;let i=[];for(let s=0,o=0,d=0,h=0;;s++){let a=s==t.length?null:t[s],f=a?a.fromA+o:n.length,c=a?a.fromB+d:l.length;for(;hf||g.toB+d>c))break;i.push(g.offset(o,d)),h++}if(!a)break;let u=a.toA+o+a.diffA,m=a.toB+d+a.diffB,p=et(n.sliceString(f,u),l.sliceString(c,m),r);for(let g of nt(p,n,l,f,c,Xe()))i.push(g);for(o+=a.diffA,d+=a.diffB;hu&&g.fromB+d>m)break;h++}}return i}const it={scanLimit:500},K=at.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Le(t))}update(t){(t.docChanged||t.viewportChanged||wt(t.startState,t.state)||bt(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Le(t.view))}},{decorations:t=>t.deco}),P=$.low(Ie({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(K))===null||e===void 0?void 0:e.gutter)||We.empty}}));function wt(t,e){return t.field(b,!1)!=e.field(b,!1)}function bt(t,e){return t.facet(B)!=e.facet(B)}const Me=k.line({class:"cm-changedLine"}),rt=k.mark({class:"cm-changedText"}),Bt=k.mark({tagName:"ins",class:"cm-insertedLine"}),kt=k.mark({tagName:"del",class:"cm-deletedLine"}),De=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Mt(t,e,n,l,r,i){let s=n?t.fromA:t.fromB,o=n?t.toA:t.toB,d=0;if(s!=o){r.add(s,s,Me),r.add(s,o,n?kt:Bt),i&&i.add(s,s,De);for(let h=e.iterRange(s,o-1),a=s;!h.next().done;){if(h.lineBreak){a++,r.add(a,a,Me),i&&i.add(a,a,De);continue}let f=a+h.value.length;if(l)for(;d=a)break;(s?f.toA:f.toB)>h&&(!i||!i(t.state,f,o,d))&&Mt(f,t.state.doc,s,l,o,d)}return{deco:o.finish(),gutter:d&&d.finish()}}class z extends J{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const Y=R.define({map:(t,e)=>t.map(e)}),U=W.define({create:()=>k.none,update:(t,e)=>{for(let n of e.effects)if(n.is(Y))return n.value;return t.map(e.changes)},provide:t=>L.decorations.from(t)}),q=.01;function Se(t,e){if(t.size!=e.size)return!1;let n=t.iter(),l=e.iter();for(;n.value;){if(n.from!=l.from||Math.abs(n.value.spec.widget.height-l.value.spec.widget.height)>1)return!1;n.next(),l.next()}return!0}function Dt(t,e,n){let l=new G,r=new G,i=t.state.field(U).iter(),s=e.state.field(U).iter(),o=0,d=0,h=0,a=0,f=t.viewport,c=e.viewport;for(let g=0;;g++){let C=gq&&(a+=w,r.add(d,d,k.widget({widget:new z(w),block:!0,side:-1})))}if(S>o+1e3&&of.from&&dc.from){let x=Math.min(f.from-o,c.from-d);o+=x,d+=x,g--}else if(C)o=C.toA,d=C.toB;else break;for(;i.value&&i.fromq&&r.add(e.state.doc.length,e.state.doc.length,k.widget({widget:new z(u),block:!0,side:1}));let m=l.finish(),p=r.finish();Se(m,t.state.field(U))||t.dispatch({effects:Y.of(m)}),Se(p,e.state.field(U))||e.dispatch({effects:Y.of(p)})}const le=R.define({map:(t,e)=>e.mapPos(t)});class Lt extends J{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let r=e.posAtDOM(l.target);e.dispatch({effects:le.of(r)});let{side:i,sibling:s}=e.state.facet(B);s&&s().dispatch({effects:le.of(St(r,e.state.field(b),i=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function St(t,e,n){let l=0,r=0;for(let i=0;;i++){let s=i=t)return r+(t-l);[l,r]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const Et=W.define({create(t){return k.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(le)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(b)!=e.startState.field(b,!1)){let n=e.state.facet(B).side=="a",l=[];for(let r of e.state.field(b))t.between(n?r.fromA:r.fromB,n?r.toA:r.toB,i=>{l.push(i)});l.length&&(t=t.update({filter:r=>l.indexOf(r)<0}))}return t},provide:t=>L.decorations.from(t)});function se({margin:t=3,minSize:e=4}){return Et.init(n=>Ot(n,t,e))}function Ot(t,e,n){let l=new G,r=t.facet(B).side=="a",i=t.field(b),s=1;for(let o=0;;o++){let d=o=n&&l.add(t.doc.line(h).from,t.doc.line(a).to,k.replace({widget:new Lt(f),block:!0})),!d)break;s=t.doc.lineAt(Math.min(t.doc.length,r?d.toA:d.toB)).number}return l.finish()}const yt=L.styleModule.of(new dt({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),lt=L.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),Ee=new Ve,_=new Ve;class Tt{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||it;let n=[$.low(K),lt,yt,U,L.updateListener.of(f=>{this.measuring<0&&(f.heightChanged||f.viewportChanged)&&!f.transactions.some(c=>c.effects.some(u=>u.is(Y)))&&this.measure()})],l=[B.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&l.push(P);let r=te.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],L.editorAttributes.of({class:"cm-merge-a"}),_.of(l),n]}),i=[B.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(P);let s=te.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],L.editorAttributes.of({class:"cm-merge-b"}),_.of(i),n]});this.chunks=E.build(r.doc,s.doc,this.diffConf);let o=[b.init(()=>this.chunks),Ee.of(e.collapseUnchanged?se(e.collapseUnchanged):[])];r=r.update({effects:R.appendConfig.of(o)}).state,s=s.update({effects:R.appendConfig.of(o)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let d=e.orientation||"a-b",h=document.createElement("div");h.className="cm-mergeViewEditor";let a=document.createElement("div");a.className="cm-mergeViewEditor",this.editorDOM.appendChild(d=="a-b"?h:a),this.editorDOM.appendChild(d=="a-b"?a:h),this.a=new L({state:r,parent:h,root:e.root,dispatchTransactions:f=>this.dispatch(f,this.a)}),this.b=new L({state:s,parent:a,root:e.root,dispatchTransactions:f=>this.dispatch(f,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(l=>l.docChanged)){let l=e[e.length-1],r=e.reduce((s,o)=>s.compose(o.changes),je.empty(e[0].startState.doc.length));this.chunks=n==this.a?E.updateA(this.chunks,l.newDoc,this.b.state.doc,r,this.diffConf):E.updateB(this.chunks,this.a.state.doc,l.newDoc,r,this.diffConf),n.update([...e,l.state.update({effects:re.of(this.chunks)})]);let i=n==this.a?this.b:this.a;i.update([i.state.update({effects:re.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let i=e.orientation!="b-a";if(i!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let s=this.a.dom.parentNode,o=this.b.dom.parentNode;s.remove(),o.remove(),this.editorDOM.insertBefore(i?s:o,this.editorDOM.firstChild),this.editorDOM.appendChild(i?o:s),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let i=!!this.revertDOM,s=this.revertToA,o=this.renderRevert;"revertControls"in e&&(i=!!e.revertControls,s=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(i,s,o)}let n="highlightChanges"in e,l="gutter"in e,r="collapseUnchanged"in e;if(n||l||r){let i=[],s=[];if(n||l){let o=this.a.state.facet(B),d=l?e.gutter!==!1:o.markGutter,h=n?e.highlightChanges!==!1:o.highlightChanges;i.push(_.reconfigure([B.of({side:"a",sibling:()=>this.b,highlightChanges:h,markGutter:d}),d?P:[]])),s.push(_.reconfigure([B.of({side:"b",sibling:()=>this.a,highlightChanges:h,markGutter:d}),d?P:[]]))}if(r){let o=Ee.reconfigure(e.collapseUnchanged?se(e.collapseUnchanged):[]);i.push(o),s.push(o)}this.a.dispatch({effects:i}),this.b.dispatch({effects:s})}this.scheduleMeasure()}setupRevertControls(e,n,l){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=l,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",r=>this.revertClicked(r)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){Dt(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,l=this.a.viewport,r=this.b.viewport;for(let i=0;il.to||s.fromB>r.to)break;if(s.fromA-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function Oe(t){let e=t.nextSibling;return t.remove(),e}const Rt=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Gt=$.low(Ie({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(K))===null||e===void 0?void 0:e.gutter)||We.empty},widgetMarker:(t,e)=>e instanceof st?Rt:null}));function Nt(t){var e;let n=typeof t.original=="string"?Fe.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||it;return[$.low(K),It,lt,L.editorAttributes.of({class:"cm-merge-b"}),tt.of((r,i)=>{let s=i.effects.find(o=>o.is(he));return s&&(r=E.updateA(r,s.value.doc,i.startState.doc,s.value.changes,l)),i.docChanged&&(r=E.updateB(r,i.state.field(F),i.newDoc,i.changes,l)),r}),B.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:Pt,side:"b"}),F.init(()=>n),t.gutter!==!1?Gt:[],t.collapseUnchanged?se(t.collapseUnchanged):[],b.init(r=>E.build(n,r.doc,l))]}const he=R.define(),F=W.define({create:()=>Fe.empty,update(t,e){for(let n of e.effects)n.is(he)&&(t=n.value.doc);return t}}),ye=new WeakMap;class st extends J{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Ft(t,e,n){let l=ye.get(e.changes);if(l)return l;let r=s=>{let{highlightChanges:o,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:h,mergeControls:a}=t.facet(B),f=document.createElement("div");if(f.className="cm-deletedChunk",a){let x=f.appendChild(document.createElement("div"));x.className="cm-chunkButtons";let M=A=>{A.preventDefault(),Vt(s,s.posAtDOM(f))},w=A=>{A.preventDefault(),jt(s,s.posAtDOM(f))};if(typeof a=="function")x.appendChild(a("accept",M)),x.appendChild(a("reject",w));else{let A=x.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=M;let D=x.appendChild(document.createElement("button"));D.name="reject",D.textContent=t.phrase("Reject"),D.onmousedown=w}}if(n||e.fromA>=e.toA)return f;let c=s.state.field(F).sliceString(e.fromA,e.endA),u=d&&t.facet(ft),m=S(),p=e.changes,g=0,C=!1;function S(){let x=f.appendChild(document.createElement("div"));return x.className="cm-deletedLine",x.appendChild(document.createElement("del"))}function T(x,M,w){for(let A=x;Ah){let f=t.slice(e,n).indexOf(l.slice(r,i));if(f>-1)return[new v(e,e+f,r,r),new v(e+f+h,n,i,i)]}else if(h>d){let f=l.slice(r,i).indexOf(t.slice(e,n));if(f>-1)return[new v(e,e,r,r+f),new v(n,n,r+f+d,i)]}if(d==1||h==1)return[new v(e,n,r,i)];let a=qe(t,e,n,l,r,i);if(a){let[f,c,u]=a;return y(t,e,f,l,r,c).concat(y(t,f+u,n,l,c+u,i))}return pt(t,e,n,l,r,i)}let j=1e9,I=0,ae=!1;function pt(t,e,n,l,r,i){let s=n-e,o=i-r;if(j<1e9&&Math.min(s,o)>j*16||I>0&&Date.now()>I)return Math.min(s,o)>j*64?[new v(e,n,r,i)]:ge(t,e,n,l,r,i);let d=Math.ceil((s+o)/2);X.reset(d),ee.reset(d);let h=(u,m)=>t.charCodeAt(e+u)==l.charCodeAt(r+m),a=(u,m)=>t.charCodeAt(n-u-1)==l.charCodeAt(i-m-1),f=(s-o)%2!=0?ee:null,c=f?null:X;for(let u=0;uj||I>0&&!(u&63)&&Date.now()>I)return ge(t,e,n,l,r,i);let m=X.advance(u,s,o,d,f,!1,h)||ee.advance(u,s,o,d,c,!0,a);if(m)return Ct(t,e,n,e+m[0],l,r,i,r+m[1])}return[new v(e,n,r,i)]}class Pe{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;nn)this.end+=2;else if(f>l)this.start+=2;else if(i){let c=r+(n-l)-d;if(c>=0&&c=n-a)return[u,r+u-c]}else{let u=n-i.vec[c];if(a>=u)return[a,f]}}}return null}}const X=new Pe,ee=new Pe;function Ct(t,e,n,l,r,i,s,o){let d=!1;return!N(t,l)&&++l==n&&(d=!0),!N(r,o)&&++o==s&&(d=!0),d?[new v(e,n,i,s)]:y(t,e,l,r,i,o).concat(y(t,l,n,r,o,s))}function ze(t,e){let n=1,l=Math.min(t,e);for(;nn||a>i||t.slice(o,h)!=l.slice(d,a)){if(s==1)return o-e-(N(t,o)?0:1);s=s>>1}else{if(h==n||a==i)return h-e;o=h,d=a}}}function fe(t,e,n,l,r,i){if(e==n||r==i||t.charCodeAt(n-1)!=l.charCodeAt(i-1))return 0;let s=ze(n-e,i-r);for(let o=n,d=i;;){let h=o-s,a=d-s;if(h>1}else{if(h==e||a==r)return n-h;o=h,d=a}}}function ie(t,e,n,l,r,i,s,o){let d=l.slice(r,i),h=null;for(;;){if(h||s=n)break;let c=t.slice(a,f),u=-1;for(;(u=d.indexOf(c,u+1))!=-1;){let m=de(t,f,n,l,r+u+c.length,i),p=fe(t,e,a,l,r,r+u),g=c.length+m+p;(!h||h[2]>1}}function qe(t,e,n,l,r,i){let s=n-e,o=i-r;if(sr.fromA-e&&l.toB>r.fromB-e&&(t[n-1]=new v(l.fromA,r.toA,l.fromB,r.toB),t.splice(n--,1))}}function vt(t,e,n){for(;;){_e(n,1);let l=!1;for(let r=0;r3||o>3){let d=r==t.length-1?e.length:t[r+1].fromA,h=i.fromA-l,a=d-i.toA,f=Ce(e,i.fromA,h),c=pe(e,i.toA,a),u=i.fromA-f,m=c-i.toA;if((!s||!o)&&u&&m){let p=Math.max(s,o),[g,C,S]=s?[e,i.fromA,i.toA]:[n,i.fromB,i.toB];p>u&&e.slice(f,i.fromA)==g.slice(S-u,S)?(i=t[r]=new v(f,f+s,i.fromB-u,i.toB-u),f=i.fromA,c=pe(e,i.toA,d-i.toA)):p>m&&e.slice(i.toA,c)==g.slice(C,C+m)&&(i=t[r]=new v(c-s,c,i.fromB+m,i.toB+m),c=i.toA,f=Ce(e,i.fromA,i.fromA-l)),u=i.fromA-f,m=c-i.toA}if(u||m)i=t[r]=new v(i.fromA-u,i.toA+m,i.fromB-u,i.toB+m);else if(s){if(!o){let p=Ae(e,i.fromA,i.toA),g,C=p<0?-1:ve(e,i.toA,i.fromA);p>-1&&(g=p-i.fromA)<=a&&e.slice(i.fromA,p)==e.slice(i.toA,i.toA+g)?i=t[r]=i.offset(g):C>-1&&(g=i.toA-C)<=h&&e.slice(i.fromA-g,i.fromA)==e.slice(C,i.toA)&&(i=t[r]=i.offset(-g))}}else{let p=Ae(n,i.fromB,i.toB),g,C=p<0?-1:ve(n,i.toB,i.fromB);p>-1&&(g=p-i.fromB)<=a&&n.slice(i.fromB,p)==n.slice(i.toB,i.toB+g)?i=t[r]=i.offset(g):C>-1&&(g=i.toB-C)<=h&&n.slice(i.fromB-g,i.fromB)==n.slice(C,i.toB)&&(i=t[r]=i.offset(-g))}}l=i.toA}return _e(t,3),t}let O;try{O=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function Qe(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function Ye(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?Qe(n)?1:0:O?!Ke(n)||e==t.length-1?O.test(String.fromCharCode(n))?1:0:O.test(t.slice(e,e+2))?2:0:0}function $e(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?Qe(n)?1:0:O?!Ze(n)||e==1?O.test(String.fromCharCode(n))?1:0:O.test(t.slice(e-2,e))?2:0:0}const Je=8;function pe(t,e,n){if(e==t.length||!$e(t,e))return e;for(let l=e,r=e+n,i=0;ir)return l;l+=s}return e}function Ce(t,e,n){if(!e||!Ye(t,e))return e;for(let l=e,r=e-n,i=0;it>=55296&&t<=56319,Ze=t=>t>=56320&&t<=57343;function N(t,e){return!e||e==t.length||!Ke(t.charCodeAt(e-1))||!Ze(t.charCodeAt(e))}function xt(t,e,n){var l;let r=n==null?void 0:n.override;return r?r(t,e):(j=((l=n==null?void 0:n.scanLimit)!==null&&l!==void 0?l:1e9)>>1,I=n!=null&&n.timeout?Date.now()+n.timeout:0,ae=!1,vt(t,e,y(t,0,t.length,e,0,e.length)))}function Xe(){return!ae}function et(t,e,n){return At(xt(t,e,n),t,e)}const B=Ue.define({combine:t=>t[0]}),re=R.define(),tt=Ue.define(),b=W.define({create(t){return null},update(t,e){for(let n of e.effects)n.is(re)&&(t=n.value);for(let n of e.state.facet(tt))t=n(t,e);return t}});class E{constructor(e,n,l,r,i,s=!0){this.changes=e,this.fromA=n,this.toA=l,this.fromB=r,this.toB=i,this.precise=s}offset(e,n){return e||n?new E(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,l){let r=et(e.toString(),n.toString(),l);return nt(r,e,n,0,0,Xe())}static updateA(e,n,l,r,i){return ke(Be(e,r,!0,l.length),e,n,l,i)}static updateB(e,n,l,r,i){return ke(Be(e,r,!1,n.length),e,n,l,i)}}function xe(t,e,n,l){let r=n.lineAt(t),i=l.lineAt(e);return r.to==t&&i.to==e&&tf+1&&g>c+1)break;u.push(m.offset(-h+l,-a+r)),[f,c]=we(m.toA+l,m.toB+r,e,n),o++}s.push(new E(u,h,Math.max(h,f),a,Math.max(a,c),i))}return s}const H=1e3;function be(t,e,n,l){let r=0,i=t.length;for(;;){if(r==i){let a=0,f=0;r&&({toA:a,toB:f}=t[r-1]);let c=e-(n?a:f);return[a+c,f+c]}let s=r+i>>1,o=t[s],[d,h]=n?[o.fromA,o.toA]:[o.fromB,o.toB];if(d>e)i=s;else if(h<=e)r=s+1;else return l?[o.fromA,o.fromB]:[o.toA,o.toB]}}function Be(t,e,n,l){let r=[];return e.iterChangedRanges((i,s,o,d)=>{let h=0,a=n?e.length:l,f=0,c=n?l:e.length;i>H&&([h,f]=be(t,i-H,n,!0)),s=h?r[r.length-1]={fromA:m.fromA,fromB:m.fromB,toA:a,toB:c,diffA:m.diffA+p,diffB:m.diffB+g}:r.push({fromA:h,toA:a,fromB:f,toB:c,diffA:p,diffB:g})}),r}function ke(t,e,n,l,r){if(!t.length)return e;let i=[];for(let s=0,o=0,d=0,h=0;;s++){let a=s==t.length?null:t[s],f=a?a.fromA+o:n.length,c=a?a.fromB+d:l.length;for(;hf||g.toB+d>c))break;i.push(g.offset(o,d)),h++}if(!a)break;let u=a.toA+o+a.diffA,m=a.toB+d+a.diffB,p=et(n.sliceString(f,u),l.sliceString(c,m),r);for(let g of nt(p,n,l,f,c,Xe()))i.push(g);for(o+=a.diffA,d+=a.diffB;hu&&g.fromB+d>m)break;h++}}return i}const it={scanLimit:500},K=at.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Le(t))}update(t){(t.docChanged||t.viewportChanged||wt(t.startState,t.state)||bt(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Le(t.view))}},{decorations:t=>t.deco}),P=$.low(Ie({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(K))===null||e===void 0?void 0:e.gutter)||We.empty}}));function wt(t,e){return t.field(b,!1)!=e.field(b,!1)}function bt(t,e){return t.facet(B)!=e.facet(B)}const Me=k.line({class:"cm-changedLine"}),rt=k.mark({class:"cm-changedText"}),Bt=k.mark({tagName:"ins",class:"cm-insertedLine"}),kt=k.mark({tagName:"del",class:"cm-deletedLine"}),De=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function Mt(t,e,n,l,r,i){let s=n?t.fromA:t.fromB,o=n?t.toA:t.toB,d=0;if(s!=o){r.add(s,s,Me),r.add(s,o,n?kt:Bt),i&&i.add(s,s,De);for(let h=e.iterRange(s,o-1),a=s;!h.next().done;){if(h.lineBreak){a++,r.add(a,a,Me),i&&i.add(a,a,De);continue}let f=a+h.value.length;if(l)for(;d=a)break;(s?f.toA:f.toB)>h&&(!i||!i(t.state,f,o,d))&&Mt(f,t.state.doc,s,l,o,d)}return{deco:o.finish(),gutter:d&&d.finish()}}class z extends J{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const Y=R.define({map:(t,e)=>t.map(e)}),U=W.define({create:()=>k.none,update:(t,e)=>{for(let n of e.effects)if(n.is(Y))return n.value;return t.map(e.changes)},provide:t=>L.decorations.from(t)}),q=.01;function Se(t,e){if(t.size!=e.size)return!1;let n=t.iter(),l=e.iter();for(;n.value;){if(n.from!=l.from||Math.abs(n.value.spec.widget.height-l.value.spec.widget.height)>1)return!1;n.next(),l.next()}return!0}function Dt(t,e,n){let l=new G,r=new G,i=t.state.field(U).iter(),s=e.state.field(U).iter(),o=0,d=0,h=0,a=0,f=t.viewport,c=e.viewport;for(let g=0;;g++){let C=gq&&(a+=w,r.add(d,d,k.widget({widget:new z(w),block:!0,side:-1})))}if(S>o+1e3&&of.from&&dc.from){let x=Math.min(f.from-o,c.from-d);o+=x,d+=x,g--}else if(C)o=C.toA,d=C.toB;else break;for(;i.value&&i.fromq&&r.add(e.state.doc.length,e.state.doc.length,k.widget({widget:new z(u),block:!0,side:1}));let m=l.finish(),p=r.finish();Se(m,t.state.field(U))||t.dispatch({effects:Y.of(m)}),Se(p,e.state.field(U))||e.dispatch({effects:Y.of(p)})}const le=R.define({map:(t,e)=>e.mapPos(t)});class Lt extends J{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",l=>{let r=e.posAtDOM(l.target);e.dispatch({effects:le.of(r)});let{side:i,sibling:s}=e.state.facet(B);s&&s().dispatch({effects:le.of(St(r,e.state.field(b),i=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function St(t,e,n){let l=0,r=0;for(let i=0;;i++){let s=i=t)return r+(t-l);[l,r]=n?[s.toA,s.toB]:[s.toB,s.toA]}}const Et=W.define({create(t){return k.none},update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(le)&&(t=t.update({filter:l=>l!=n.value}));if(t.size&&e.state.field(b)!=e.startState.field(b,!1)){let n=e.state.facet(B).side=="a",l=[];for(let r of e.state.field(b))t.between(n?r.fromA:r.fromB,n?r.toA:r.toB,i=>{l.push(i)});l.length&&(t=t.update({filter:r=>l.indexOf(r)<0}))}return t},provide:t=>L.decorations.from(t)});function se({margin:t=3,minSize:e=4}){return Et.init(n=>Ot(n,t,e))}function Ot(t,e,n){let l=new G,r=t.facet(B).side=="a",i=t.field(b),s=1;for(let o=0;;o++){let d=o=n&&l.add(t.doc.line(h).from,t.doc.line(a).to,k.replace({widget:new Lt(f),block:!0})),!d)break;s=t.doc.lineAt(Math.min(t.doc.length,r?d.toA:d.toB)).number}return l.finish()}const yt=L.styleModule.of(new dt({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),lt=L.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine, .cm-inlineChangedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer","&:before":{content:'"⦚"',marginInlineEnd:"7px"},"&:after":{content:'"⦚"',marginInlineStart:"7px"}},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"},".cm-inlineChangedLineGutter":{background:"#75d"}}),Ee=new Ve,_=new Ve;class Tt{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||it;let n=[$.low(K),lt,yt,U,L.updateListener.of(f=>{this.measuring<0&&(f.heightChanged||f.viewportChanged)&&!f.transactions.some(c=>c.effects.some(u=>u.is(Y)))&&this.measure()})],l=[B.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&l.push(P);let r=te.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],L.editorAttributes.of({class:"cm-merge-a"}),_.of(l),n]}),i=[B.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&i.push(P);let s=te.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],L.editorAttributes.of({class:"cm-merge-b"}),_.of(i),n]});this.chunks=E.build(r.doc,s.doc,this.diffConf);let o=[b.init(()=>this.chunks),Ee.of(e.collapseUnchanged?se(e.collapseUnchanged):[])];r=r.update({effects:R.appendConfig.of(o)}).state,s=s.update({effects:R.appendConfig.of(o)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let d=e.orientation||"a-b",h=document.createElement("div");h.className="cm-mergeViewEditor";let a=document.createElement("div");a.className="cm-mergeViewEditor",this.editorDOM.appendChild(d=="a-b"?h:a),this.editorDOM.appendChild(d=="a-b"?a:h),this.a=new L({state:r,parent:h,root:e.root,dispatchTransactions:f=>this.dispatch(f,this.a)}),this.b=new L({state:s,parent:a,root:e.root,dispatchTransactions:f=>this.dispatch(f,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(l=>l.docChanged)){let l=e[e.length-1],r=e.reduce((s,o)=>s.compose(o.changes),je.empty(e[0].startState.doc.length));this.chunks=n==this.a?E.updateA(this.chunks,l.newDoc,this.b.state.doc,r,this.diffConf):E.updateB(this.chunks,this.a.state.doc,l.newDoc,r,this.diffConf),n.update([...e,l.state.update({effects:re.of(this.chunks)})]);let i=n==this.a?this.b:this.a;i.update([i.state.update({effects:re.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let i=e.orientation!="b-a";if(i!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let s=this.a.dom.parentNode,o=this.b.dom.parentNode;s.remove(),o.remove(),this.editorDOM.insertBefore(i?s:o,this.editorDOM.firstChild),this.editorDOM.appendChild(i?o:s),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let i=!!this.revertDOM,s=this.revertToA,o=this.renderRevert;"revertControls"in e&&(i=!!e.revertControls,s=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(i,s,o)}let n="highlightChanges"in e,l="gutter"in e,r="collapseUnchanged"in e;if(n||l||r){let i=[],s=[];if(n||l){let o=this.a.state.facet(B),d=l?e.gutter!==!1:o.markGutter,h=n?e.highlightChanges!==!1:o.highlightChanges;i.push(_.reconfigure([B.of({side:"a",sibling:()=>this.b,highlightChanges:h,markGutter:d}),d?P:[]])),s.push(_.reconfigure([B.of({side:"b",sibling:()=>this.a,highlightChanges:h,markGutter:d}),d?P:[]]))}if(r){let o=Ee.reconfigure(e.collapseUnchanged?se(e.collapseUnchanged):[]);i.push(o),s.push(o)}this.a.dispatch({effects:i}),this.b.dispatch({effects:s})}this.scheduleMeasure()}setupRevertControls(e,n,l){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=l,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",r=>this.revertClicked(r)),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame(()=>{this.measuring=-1,this.measure()})}}measure(){Dt(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,l=this.a.viewport,r=this.b.viewport;for(let i=0;il.to||s.fromB>r.to)break;if(s.fromA-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function Oe(t){let e=t.nextSibling;return t.remove(),e}const Rt=new class extends oe{constructor(){super(...arguments),this.elementClass="cm-deletedLineGutter"}},Gt=$.low(Ie({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(K))===null||e===void 0?void 0:e.gutter)||We.empty},widgetMarker:(t,e)=>e instanceof st?Rt:null}));function Nt(t){var e;let n=typeof t.original=="string"?Fe.of(t.original.split(/\r?\n/)):t.original,l=t.diffConfig||it;return[$.low(K),It,lt,L.editorAttributes.of({class:"cm-merge-b"}),tt.of((r,i)=>{let s=i.effects.find(o=>o.is(he));return s&&(r=E.updateA(r,s.value.doc,i.startState.doc,s.value.changes,l)),i.docChanged&&(r=E.updateB(r,i.state.field(F),i.newDoc,i.changes,l)),r}),B.of({highlightChanges:t.highlightChanges!==!1,markGutter:t.gutter!==!1,syntaxHighlightDeletions:t.syntaxHighlightDeletions!==!1,syntaxHighlightDeletionsMaxLength:3e3,mergeControls:(e=t.mergeControls)!==null&&e!==void 0?e:!0,overrideChunk:Pt,side:"b"}),F.init(()=>n),t.gutter!==!1?Gt:[],t.collapseUnchanged?se(t.collapseUnchanged):[],b.init(r=>E.build(n,r.doc,l))]}const he=R.define(),F=W.define({create:()=>Fe.empty,update(t,e){for(let n of e.effects)n.is(he)&&(t=n.value.doc);return t}}),ye=new WeakMap;class st extends J{constructor(e){super(),this.buildDOM=e,this.dom=null}eq(e){return this.dom==e.dom}toDOM(e){return this.dom||(this.dom=this.buildDOM(e))}}function Ft(t,e,n){let l=ye.get(e.changes);if(l)return l;let r=s=>{let{highlightChanges:o,syntaxHighlightDeletions:d,syntaxHighlightDeletionsMaxLength:h,mergeControls:a}=t.facet(B),f=document.createElement("div");if(f.className="cm-deletedChunk",a){let x=f.appendChild(document.createElement("div"));x.className="cm-chunkButtons";let M=A=>{A.preventDefault(),Vt(s,s.posAtDOM(f))},w=A=>{A.preventDefault(),jt(s,s.posAtDOM(f))};if(typeof a=="function")x.appendChild(a("accept",M)),x.appendChild(a("reject",w));else{let A=x.appendChild(document.createElement("button"));A.name="accept",A.textContent=t.phrase("Accept"),A.onmousedown=M;let D=x.appendChild(document.createElement("button"));D.name="reject",D.textContent=t.phrase("Reject"),D.onmousedown=w}}if(n||e.fromA>=e.toA)return f;let c=s.state.field(F).sliceString(e.fromA,e.endA),u=d&&t.facet(ft),m=S(),p=e.changes,g=0,C=!1;function S(){let x=f.appendChild(document.createElement("div"));return x.className="cm-deletedLine",x.appendChild(document.createElement("del"))}function T(x,M,w){for(let A=x;A-1&&ZA){let V=document.createTextNode(c.slice(A,D));if(ce){let me=m.appendChild(document.createElement("span"));me.className=ce,me.appendChild(V)}else m.appendChild(V);A=D}ue&&(C=!C)}}if(u&&e.toA-e.fromA<=h){let x=u.parser.parse(c),M=0;ht(x,{style:w=>ct(t,w)},(w,A,D)=>{w>M&&T(M,w,""),T(w,A,D),M=A}),T(M,c.length,"")}else T(0,c.length,"");return m.firstChild||m.appendChild(document.createElement("br")),f},i=k.widget({block:!0,side:-1,widget:new st(r)});return ye.set(e.changes,i),i}function Vt(t,e){let{state:n}=t,l=e??n.selection.main.head,r=t.state.field(b).find(d=>d.fromB<=l&&d.endB>=l);if(!r)return!1;let i=t.state.sliceDoc(r.fromB,Math.max(r.fromB,r.toB-1)),s=t.state.field(F);r.fromB!=r.toB&&r.toA<=s.length&&(i+=t.state.lineBreak);let o=je.of({from:r.fromA,to:Math.min(s.length,r.toA),insert:i},s.length);return t.dispatch({effects:he.of({doc:o.apply(s),changes:o}),userEvent:"accept"}),!0}function jt(t,e){let{state:n}=t,l=e??n.selection.main.head,r=n.field(b).find(o=>o.fromB<=l&&o.endB>=l);if(!r)return!1;let s=n.field(F).sliceString(r.fromA,Math.max(r.fromA,r.toA-1));return r.fromA!=r.toA&&r.toB<=n.doc.length&&(s+=n.lineBreak),t.dispatch({changes:{from:r.fromB,to:Math.min(n.doc.length,r.toB),insert:s},userEvent:"revert"}),!0}function Te(t){let e=new G;for(let n of t.field(b)){let l=t.facet(B).overrideChunk&&ot(t,n);e.add(n.fromB,n.fromB,Ft(t,n,!!l))}return e.finish()}const It=W.define({create:t=>Te(t),update(t,e){return e.state.field(b,!1)!=e.startState.field(b,!1)?Te(e.state):t},provide:t=>L.decorations.from(t)}),Re=new WeakMap;function ot(t,e){let n=Re.get(e);if(n!==void 0)return n;n=null;let l=t.field(F),r=t.doc,i=l.lineAt(e.endA).number-l.lineAt(e.fromA).number+1,s=r.lineAt(e.endB).number-r.lineAt(e.fromB).number+1;e:if(i==s&&i<10){let o=[],d=0,h=e.fromA,a=e.fromB;for(let f of e.changes){if(f.fromA=e.endB)break;s=t.doc.lineAt(s.to+1)}return!0}const Ge="(max-width: 760px)";function zt(){const[t,e]=Q.useState(()=>typeof window<"u"&&window.matchMedia(Ge).matches);return Q.useEffect(()=>{const n=window.matchMedia(Ge),l=()=>e(n.matches);return l(),n.addEventListener("change",l),()=>n.removeEventListener("change",l)},[]),t}function Ne(t,e){return[gt({lineNumbers:!0,foldGutter:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1,autocompletion:!1}),...He(t),te.readOnly.of(!0),...e==="dark"?[mt]:[]]}function qt({before:t,after:e,path:n,theme:l}){const r=Q.useRef(null);return Q.useEffect(()=>{if(!r.current)return;const i=new Tt({a:{doc:t,extensions:Ne(n,l)},b:{doc:e,extensions:Ne(n,l)},parent:r.current,highlightChanges:!0,gutter:!0,collapseUnchanged:{margin:3,minSize:6},diffConfig:{scanLimit:2e3,timeout:1e3}});return()=>i.destroy()},[e,t,n,l]),ne.jsx("div",{ref:r,className:"code-browser-merge"})}function Qt(t){return zt()?ne.jsx(ut,{value:t.after,height:"100%",theme:t.theme,editable:!1,extensions:[...He(t.path),...Nt({original:t.before,highlightChanges:!0,gutter:!0,mergeControls:!1,collapseUnchanged:{margin:3,minSize:6},diffConfig:{scanLimit:2e3,timeout:1e3}})],basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!1,highlightActiveLineGutter:!1,autocompletion:!1}}):ne.jsx(qt,{...t})}export{Qt as default};
diff --git a/veadk/webui/assets/chunks/MarkdownPromptEditor-BL6zJDeA.js b/veadk/webui/assets/chunks/MarkdownPromptEditor-YxGdWdMM.js
similarity index 99%
rename from veadk/webui/assets/chunks/MarkdownPromptEditor-BL6zJDeA.js
rename to veadk/webui/assets/chunks/MarkdownPromptEditor-YxGdWdMM.js
index 073cf2b07..72211d6d8 100644
--- a/veadk/webui/assets/chunks/MarkdownPromptEditor-BL6zJDeA.js
+++ b/veadk/webui/assets/chunks/MarkdownPromptEditor-YxGdWdMM.js
@@ -1,4 +1,4 @@
-var T0=Object.defineProperty;var E0=(n,e,t)=>e in n?T0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var $=(n,e,t)=>E0(n,typeof e!="symbol"?e+"":e,t);import{ay as I,aH as Rn,an as F,A as k0,k as Kt,M as at,aM as jo,P as N0,j as M0,aG as hc,aL as Fh,ax as Uo,U as Rh,O as $0,ah as L0,aK as O0,o as A0,g as I0,e as P0,Q as Hh,Y as D0,c as F0,z as R0,aJ as Vh,aI as Fu,s as H0,I as V0,x as B0,X as Bh,Z as zh,r as z0,w as J0,a5 as Ru,a6 as K0,a0 as W0,a2 as aa,aw as j0,aN as U0,ag as Z0,p as T,$ as Hu,J as Vu,V as Qe,au as nn,aE as Di,aC as $l,az as q0,K as Bu,aq as jt,as as hs,a4 as gc,ar as Wn,aF as En,aD as Pt,N as So,a7 as G0,ab as Y0,a9 as X0,aa as Q0,a8 as e5,ae as t5,ac as n5,ad as r5,l as o5,t as i5,y as s5,h as l5,d as a5}from"../app/index-Ch6a-P8E.js";var c5=Object.defineProperty,u5=(n,e)=>c5(n,"name",{value:e,configurable:!0});function Jh(n){const e=I.useRef({value:n,previous:n});return I.useMemo(()=>(e.current.value!==n&&(e.current.previous=e.current.value,e.current.value=n),e.current.previous),[n])}u5(Jh,"usePrevious");var f5=Object.defineProperty,d5=(n,e)=>f5(n,"name",{value:e,configurable:!0});function ca(n,[e,t]){return Math.min(t,Math.max(e,n))}d5(ca,"clamp");var h5=Object.defineProperty,be=(n,e)=>h5(n,"name",{value:e,configurable:!0}),g5=[" ","Enter","ArrowUp","ArrowDown"],p5=[" ","Enter"],oo="Select",[Us,pc,m5]=$0(oo),[vr,gv]=Hh(oo,[m5,Rh]),mc=Rh(),[_5,Hn]=vr(oo),[x5,y5]=vr(oo);function Kh(n){const{__scopeSelect:e,children:t,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:l,onValueChange:a,dir:c,name:u,autoComplete:f,disabled:d,required:g,form:h,internal_do_not_use_render:_}=n,m=mc(e),[p,y]=I.useState(null),[C,x]=I.useState(null),[w,k]=I.useState(!1),b=Vh(c),[v,E]=Fu({prop:r,defaultProp:o??!1,onChange:i,caller:oo}),[M,L]=Fu({prop:s,defaultProp:l,onChange:a,caller:oo}),H=I.useRef(null),R=I.useRef(M);I.useEffect(()=>{const Te=h?p==null?void 0:p.ownerDocument.getElementById(h):p==null?void 0:p.form;if(Te instanceof HTMLFormElement){const Se=be(()=>L(R.current),"reset");return Te.addEventListener("reset",Se),()=>Te.removeEventListener("reset",Se)}},[h,p,L]);const V=p?!!h||!!p.closest("form"):!0,[Z,G]=I.useState(new Set),z=Fh(),re=Array.from(Z).map(Te=>Te.props.value).join(";"),ee=I.useCallback(Te=>{G(Se=>new Set(Se).add(Te))},[]),ne=I.useCallback(Te=>{G(Se=>{const Ke=new Set(Se);return Ke.delete(Te),Ke})},[]),ae={required:g,trigger:p,onTriggerChange:y,valueNode:C,onValueNodeChange:x,valueNodeHasChildren:w,onValueNodeHasChildrenChange:k,contentId:z,value:M,onValueChange:L,open:v,onOpenChange:E,dir:b,triggerPointerDownPosRef:H,disabled:d,name:u,autoComplete:f,form:h,nativeOptions:Z,nativeSelectKey:re,isFormControl:V};return F.jsx(H0,{...m,children:F.jsx(_5,{scope:e,...ae,children:F.jsx(Us.Provider,{scope:e,children:F.jsx(x5,{scope:e,onNativeOptionAdd:ee,onNativeOptionRemove:ne,children:jh(_)?_(ae):t})})})})}be(Kh,"SelectProvider");var C5=be(n=>{const{__scopeSelect:e,children:t,...r}=n;return F.jsx(Kh,{__scopeSelect:e,...r,internal_do_not_use_render:({isFormControl:o})=>F.jsxs(F.Fragment,{children:[t,o?F.jsx(W5,{__scopeSelect:e}):null]})})},"Select"),v5="SelectTrigger",b5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,disabled:o=!1,...i}=e,s=mc(r),l=Hn(v5,r),a=l.disabled||o,c=Rn(t,l.onTriggerChange),u=pc(r),f=I.useRef("touch"),[d,g,h]=_c(m=>{const p=u().filter(x=>!x.disabled),y=p.find(x=>x.value===l.value),C=xc(p,m,y);C!==void 0&&l.onValueChange(C.value)}),_=be(m=>{a||(l.onOpenChange(!0),h()),m&&(l.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})},"handleOpen");return F.jsx(k0,{asChild:!0,...s,children:F.jsx(Kt.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":yi(l.value)?"":void 0,...i,ref:c,onClick:at(i.onClick,m=>{m.currentTarget.focus(),f.current!=="mouse"&&_(m)}),onPointerDown:at(i.onPointerDown,m=>{f.current=m.pointerType;const p=m.target;p.hasPointerCapture(m.pointerId)&&p.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(_(m),m.preventDefault())}),onKeyDown:at(i.onKeyDown,m=>{const p=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&g(m.key),!(p&&m.key===" ")&&g5.includes(m.key)&&(_(),m.preventDefault())})})})},"SelectTrigger")),S5="SelectValue",w5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,className:o,style:i,children:s,placeholder:l="",...a}=e,c=Hn(S5,r),{onValueNodeHasChildrenChange:u}=c,f=s!==void 0,d=Rn(t,c.onValueNodeChange);jo(()=>{u(f)},[u,f]);const g=yi(c.value);return F.jsx(Kt.span,{...a,asChild:g?!1:a.asChild,ref:d,style:{pointerEvents:"none"},children:F.jsx(I.Fragment,{children:g?l:s},g?"placeholder":"value")})},"SelectValue")),T5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,children:o,...i}=e;return F.jsx(Kt.span,{"aria-hidden":!0,...i,ref:t,children:o||"▼"})},"SelectIcon")),E5="SelectPortal",[k5,N5]=vr(E5,{forceMount:void 0}),M5=be(n=>{const{__scopeSelect:e,forceMount:t,...r}=n;return F.jsx(k5,{scope:n.__scopeSelect,forceMount:t,children:F.jsx(N0,{asChild:!0,...r})})},"SelectPortal"),sr="SelectContent",$5=I.forwardRef(be(function(e,t){const r=N5(sr,e.__scopeSelect),{forceMount:o=r.forceMount,...i}=e,s=Hn(sr,e.__scopeSelect),[l,a]=I.useState();return jo(()=>{a(new DocumentFragment)},[]),F.jsx(M0,{present:o||s.open,children:({present:c})=>c?F.jsx(A5,{...i,ref:t}):F.jsx(L5,{...i,fragment:l})})},"SelectContent")),L5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,children:o,fragment:i}=e;return i?Uo.createPortal(F.jsx(Wh,{scope:r,children:F.jsx(Us.Slot,{scope:r,children:F.jsx("div",{ref:t,children:o})})}),i):null},"SelectContentFragment")),Ft=10,[Wh,Zs]=vr(sr),O5=D0("SelectContent.RemoveScroll"),A5=I.forwardRef(be(function(e,t){const{__scopeSelect:r}=e,{position:o="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:l,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:g,collisionPadding:h,sticky:_,hideWhenDetached:m,avoidCollisions:p,...y}=e,C=Hn(sr,r),[x,w]=I.useState(null),[k,b]=I.useState(null),v=Rn(t,w),[E,M]=I.useState(null),[L,H]=I.useState(null),R=pc(r),[V,Z]=I.useState(!1),G=I.useRef(!1);I.useEffect(()=>{if(x)return L0(x)},[x]),O0();const z=I.useCallback(W=>{const[ce,...Ie]=R().map(xe=>xe.ref.current),[ue]=Ie.slice(-1),de=document.activeElement;for(const xe of W)if(xe===de||(xe==null||xe.scrollIntoView({block:"nearest"}),xe===ce&&k&&(k.scrollTop=0),xe===ue&&k&&(k.scrollTop=k.scrollHeight),xe==null||xe.focus(),document.activeElement!==de))return},[R,k]),re=I.useCallback(()=>z([E,x]),[z,E,x]);I.useEffect(()=>{V&&re()},[V,re]);const{onOpenChange:ee,triggerPointerDownPosRef:ne}=C;I.useEffect(()=>{if(x){let W={x:0,y:0};const ce=be(ue=>{var de,xe;W={x:Math.abs(Math.round(ue.pageX)-(((de=ne.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((xe=ne.current)==null?void 0:xe.y)??0))}},"handlePointerMove"),Ie=be(ue=>{W.x<=10&&W.y<=10?ue.preventDefault():ue.composedPath().includes(x)||ee(!1),document.removeEventListener("pointermove",ce),ne.current=null},"handlePointerUp");return ne.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",Ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",Ie,{capture:!0})}}},[x,ee,ne]),I.useEffect(()=>{const W=be(()=>ee(!1),"close");return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[ee]);const[ae,Te]=_c(W=>{const ce=R().filter(de=>!de.disabled),Ie=ce.find(de=>de.ref.current===document.activeElement),ue=xc(ce,W,Ie);ue&&setTimeout(()=>{var de;return(de=ue.ref.current)==null?void 0:de.focus()})}),Se=I.useCallback((W,ce,Ie)=>{const ue=!G.current&&!Ie;(C.value!==void 0&&C.value===ce||ue)&&(M(W),ue&&(G.current=!0))},[C.value]),Ke=I.useCallback(()=>x==null?void 0:x.focus(),[x]),Ye=I.useCallback((W,ce,Ie)=>{const ue=!G.current&&!Ie;(C.value!==void 0&&C.value===ce||ue)&&H(W)},[C.value]),ie=o==="popper"?zu:I5,_e=ie===zu?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:g,collisionPadding:h,sticky:_,hideWhenDetached:m,avoidCollisions:p}:{};return F.jsx(Wh,{scope:r,content:x,viewport:k,onViewportChange:b,itemRefCallback:Se,selectedItem:E,onItemLeave:Ke,itemTextRefCallback:Ye,focusSelectedItem:re,selectedItemText:L,position:o,isPositioned:V,searchRef:ae,children:F.jsx(A0,{as:O5,allowPinchZoom:!0,children:F.jsx(I0,{asChild:!0,trapped:C.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:at(i,W=>{var ce;(ce=C.trigger)==null||ce.focus({preventScroll:!0}),W.preventDefault()}),children:F.jsx(P0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:F.jsx(ie,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:W=>W.preventDefault(),...y,..._e,onPlaced:()=>Z(!0),ref:v,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:at(y.onKeyDown,W=>{const ce=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!ce&&W.key.length===1&&Te(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ue=R().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const de=W.target,xe=ue.indexOf(de);ue=ue.slice(xe+1)}setTimeout(()=>z(ue)),W.preventDefault()}})})})})})})},"SelectContentImpl")),I5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,onPlaced:o,...i}=e,s=Hn(sr,r),l=Zs(sr,r),[a,c]=I.useState(null),[u,f]=I.useState(null),d=Rn(t,f),g=pc(r),h=I.useRef(!1),_=I.useRef(!0),{viewport:m,selectedItem:p,selectedItemText:y,focusSelectedItem:C}=l,x=I.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&m&&p&&y){const v=s.trigger.getBoundingClientRect(),E=u.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const de=L.left-E.left,xe=M.left-de,en=v.left-xe,tn=v.width+en,Ir=Math.max(tn,E.width),bo=window.innerWidth-Ft,Pr=ca(xe,[Ft,Math.max(Ft,bo-Ir)]);a.style.minWidth=tn+"px",a.style.left=Pr+"px"}else{const de=E.right-L.right,xe=window.innerWidth-M.right-de,en=window.innerWidth-v.right-xe,tn=v.width+en,Ir=Math.max(tn,E.width),bo=window.innerWidth-Ft,Pr=ca(xe,[Ft,Math.max(Ft,bo-Ir)]);a.style.minWidth=tn+"px",a.style.right=Pr+"px"}const H=g(),R=window.innerHeight-Ft*2,V=m.scrollHeight,Z=window.getComputedStyle(u),G=parseInt(Z.borderTopWidth,10),z=parseInt(Z.paddingTop,10),re=parseInt(Z.borderBottomWidth,10),ee=parseInt(Z.paddingBottom,10),ne=G+z+V+ee+re,ae=Math.min(p.offsetHeight*5,ne),Te=window.getComputedStyle(m),Se=parseInt(Te.paddingTop,10),Ke=parseInt(Te.paddingBottom,10),Ye=v.top+v.height/2-Ft,ie=R-Ye,_e=p.offsetHeight/2,W=p.offsetTop+_e,ce=G+z+W,Ie=ne-ce;if(ce<=Ye){const de=H.length>0&&p===H[H.length-1].ref.current;a.style.bottom="0px";const xe=u.clientHeight-m.offsetTop-m.offsetHeight,en=Math.max(ie,_e+(de?Ke:0)+xe+re),tn=ce+en;a.style.height=tn+"px"}else{const de=H.length>0&&p===H[0].ref.current;a.style.top="0px";const en=Math.max(Ye,G+m.offsetTop+(de?Se:0)+_e)+Ie;a.style.height=en+"px",m.scrollTop=ce-Ye+m.offsetTop}a.style.margin=`${Ft}px 0`,a.style.minHeight=ae+"px",a.style.maxHeight=R+"px",o==null||o(),requestAnimationFrame(()=>h.current=!0)}},[g,s.trigger,s.valueNode,a,u,m,p,y,s.dir,o]);jo(()=>x(),[x]);const[w,k]=I.useState();jo(()=>{u&&k(window.getComputedStyle(u).zIndex)},[u]);const b=I.useCallback(v=>{v&&_.current===!0&&(x(),C==null||C(),_.current=!1)},[x,C]);return F.jsx(P5,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:b,children:F.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:F.jsx(Kt.div,{...i,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})},"SelectItemAlignedPosition")),zu=I.forwardRef(be(function(e,t){const{__scopeSelect:r,align:o="start",collisionPadding:i=Ft,...s}=e,l=mc(r);return F.jsx(F0,{...l,...s,ref:t,align:o,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[P5,D5]=vr(sr,{}),Ju="SelectViewport",F5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,nonce:o,...i}=e,s=Zs(Ju,r),l=D5(Ju,r),a=Rn(t,s.onViewportChange),c=I.useRef(0);return F.jsxs(F.Fragment,{children:[F.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),F.jsx(Us.Slot,{scope:r,children:F.jsx(Kt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:at(i.onScroll,u=>{const f=u.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&d){const h=Math.abs(c.current-f.scrollTop);if(h>0){const _=window.innerHeight-Ft*2,m=parseFloat(d.style.minHeight),p=parseFloat(d.style.height),y=Math.max(m,p);if(y<_){const C=y+h,x=Math.min(_,C),w=C-x;d.style.height=x+"px",d.style.bottom==="0px"&&(f.scrollTop=w>0?w:0,d.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})},"SelectViewport")),R5="SelectGroup",[pv,mv]=vr(R5),ua="SelectItem",[H5,V5]=vr(ua),B5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,value:o,disabled:i=!1,textValue:s,...l}=e,a=Hn(ua,r),c=Zs(ua,r),u=a.value===o,[f,d]=I.useState(s??""),[g,h]=I.useState(!1),_=hc(x=>{var w;return(w=c.itemRefCallback)==null?void 0:w.call(c,x,o,i)}),m=Rn(t,_),p=Fh(),y=I.useRef("touch"),C=be(()=>{i||(a.onValueChange(o),a.onOpenChange(!1))},"handleSelect");return F.jsx(H5,{scope:r,value:o,disabled:i,textId:p,isSelected:u,onItemTextChange:I.useCallback(x=>{d(w=>w||((x==null?void 0:x.textContent)??"").trim())},[]),children:F.jsx(Us.ItemSlot,{scope:r,value:o,disabled:i,textValue:f,children:F.jsx(Kt.div,{role:"option","aria-labelledby":p,"data-highlighted":g?"":void 0,"aria-selected":u&&g,"data-state":u?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:m,onFocus:at(l.onFocus,()=>h(!0)),onBlur:at(l.onBlur,()=>h(!1)),onClick:at(l.onClick,()=>{y.current!=="mouse"&&C()}),onPointerUp:at(l.onPointerUp,()=>{y.current==="mouse"&&C()}),onPointerDown:at(l.onPointerDown,x=>{y.current=x.pointerType}),onPointerMove:at(l.onPointerMove,x=>{var w;y.current=x.pointerType,i?(w=c.onItemLeave)==null||w.call(c):y.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:at(l.onPointerLeave,x=>{var w;x.currentTarget===document.activeElement&&((w=c.onItemLeave)==null||w.call(c))}),onKeyDown:at(l.onKeyDown,x=>{var k;i||x.target!==x.currentTarget||((k=c.searchRef)==null?void 0:k.current)!==""&&x.key===" "||(p5.includes(x.key)&&C(),x.key===" "&&x.preventDefault())})})})})},"SelectItem")),Fi="SelectItemText",z5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,className:o,style:i,...s}=e,l=Hn(Fi,r),a=Zs(Fi,r),c=V5(Fi,r),u=y5(Fi,r),[f,d]=I.useState(null),g=hc(C=>{var x;return(x=a.itemTextRefCallback)==null?void 0:x.call(a,C,c.value,c.disabled)}),h=Rn(t,d,c.onItemTextChange,g),_=f==null?void 0:f.textContent,m=I.useMemo(()=>F.jsx("option",{value:c.value,disabled:c.disabled,children:_},c.value),[c.disabled,c.value,_]),{onNativeOptionAdd:p,onNativeOptionRemove:y}=u;return jo(()=>(p(m),()=>y(m)),[p,y,m]),F.jsxs(F.Fragment,{children:[F.jsx(Kt.span,{id:c.textId,...s,ref:h}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!yi(l.value)?Uo.createPortal(s.children,l.valueNode):null]})},"SelectItemText")),J5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,...o}=e;return F.jsx(Kt.div,{"aria-hidden":!0,...o,ref:t})},"SelectSeparator")),K5="SelectBubbleInput",W5=I.forwardRef(be(function({__scopeSelect:e,...t},r){const o=Hn(K5,e),{value:i,onValueChange:s,required:l,disabled:a,name:c,autoComplete:u,form:f}=o,{nativeOptions:d,nativeSelectKey:g}=o,h=I.useRef(null),_=Rn(r,h),m=i??"",p=Jh(m),y=Array.from(d).some(C=>(C.props.value??"")==="");return I.useEffect(()=>{const C=h.current;if(!C)return;const x=window.HTMLSelectElement.prototype,k=Object.getOwnPropertyDescriptor(x,"value").set;if(p!==m&&k){const b=new Event("change",{bubbles:!0});k.call(C,m),C.dispatchEvent(b)}},[p,m]),F.jsxs(Kt.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:c,autoComplete:u,disabled:a,form:f,onChange:C=>s(C.target.value),...t,style:{...R0,...t.style},ref:_,defaultValue:m,children:[yi(i)&&!y?F.jsx("option",{value:""}):null,Array.from(d)]},g)},"SelectBubbleInput"));function jh(n){return typeof n=="function"}be(jh,"isFunction");function yi(n){return n===""||n===void 0}be(yi,"shouldShowPlaceholder");function _c(n){const e=hc(n),t=I.useRef(""),r=I.useRef(0),o=I.useCallback(s=>{const l=t.current+s;e(l),be(function a(c){t.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>a(""),1e3))},"updateSearch")(l)},[e]),i=I.useCallback(()=>{t.current="",window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[t,o,i]}be(_c,"useTypeaheadSearch");function xc(n,e,t){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let s=Uh(n,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==t));const a=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return a!==t?a:void 0}be(xc,"findNextItem");function Uh(n,e){return n.map((t,r)=>n[(e+r)%n.length])}be(Uh,"wrapArray");var j5=Object.defineProperty,qs=(n,e)=>j5(n,"name",{value:e,configurable:!0}),Zh="Toolbar",[U5,_v]=Hh(Zh,[Bh,zh]),qh=Bh(),Gh=zh(),[Z5,q5]=U5(Zh),G5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,orientation:o="horizontal",dir:i,loop:s=!0,...l}=e,a=qh(r),c=Vh(i);return F.jsx(Z5,{scope:r,orientation:o,dir:c,children:F.jsx(z0,{asChild:!0,...a,orientation:o,dir:c,loop:s,children:F.jsx(Kt.div,{role:"toolbar","aria-orientation":o,dir:c,...l,ref:t})})})},"Toolbar")),Yh=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=qh(r);return F.jsx(V0,{asChild:!0,...i,focusable:!e.disabled,children:F.jsx(Kt.button,{type:"button",...o,ref:t})})},"ToolbarButton")),Y5="ToolbarToggleGroup",X5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=q5(Y5,r),s=Gh(r);return F.jsx(J0,{"data-orientation":i.orientation,dir:i.dir,...s,...o,ref:t,rovingFocus:!1})},"ToolbarToggleGroup")),Q5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=Gh(r),s={__scopeToolbar:e.__scopeToolbar};return F.jsx(Yh,{asChild:!0,...s,children:F.jsx(B0,{...i,...o,ref:t})})},"ToolbarToggleItem")),e2=G5,t2=Yh,yc=X5,n2=Q5;const r2={}.hasOwnProperty;function Xh(n,e){let t=-1,r;if(e.extensions)for(;++te in n?T0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var $=(n,e,t)=>E0(n,typeof e!="symbol"?e+"":e,t);import{ay as I,aH as Rn,an as F,A as k0,k as Kt,M as at,aM as jo,P as N0,j as M0,aG as hc,aL as Fh,ax as Uo,U as Rh,O as $0,ah as L0,aK as O0,o as A0,g as I0,e as P0,Q as Hh,Y as D0,c as F0,z as R0,aJ as Vh,aI as Fu,s as H0,I as V0,x as B0,X as Bh,Z as zh,r as z0,w as J0,a5 as Ru,a6 as K0,a0 as W0,a2 as aa,aw as j0,aN as U0,ag as Z0,p as T,$ as Hu,J as Vu,V as Qe,au as nn,aE as Di,aC as $l,az as q0,K as Bu,aq as jt,as as hs,a4 as gc,ar as Wn,aF as En,aD as Pt,N as So,a7 as G0,ab as Y0,a9 as X0,aa as Q0,a8 as e5,ae as t5,ac as n5,ad as r5,l as o5,t as i5,y as s5,h as l5,d as a5}from"../app/index-z3uMxcpH.js";var c5=Object.defineProperty,u5=(n,e)=>c5(n,"name",{value:e,configurable:!0});function Jh(n){const e=I.useRef({value:n,previous:n});return I.useMemo(()=>(e.current.value!==n&&(e.current.previous=e.current.value,e.current.value=n),e.current.previous),[n])}u5(Jh,"usePrevious");var f5=Object.defineProperty,d5=(n,e)=>f5(n,"name",{value:e,configurable:!0});function ca(n,[e,t]){return Math.min(t,Math.max(e,n))}d5(ca,"clamp");var h5=Object.defineProperty,be=(n,e)=>h5(n,"name",{value:e,configurable:!0}),g5=[" ","Enter","ArrowUp","ArrowDown"],p5=[" ","Enter"],oo="Select",[Us,pc,m5]=$0(oo),[vr,gv]=Hh(oo,[m5,Rh]),mc=Rh(),[_5,Hn]=vr(oo),[x5,y5]=vr(oo);function Kh(n){const{__scopeSelect:e,children:t,open:r,defaultOpen:o,onOpenChange:i,value:s,defaultValue:l,onValueChange:a,dir:c,name:u,autoComplete:f,disabled:d,required:g,form:h,internal_do_not_use_render:_}=n,m=mc(e),[p,y]=I.useState(null),[C,x]=I.useState(null),[w,k]=I.useState(!1),b=Vh(c),[v,E]=Fu({prop:r,defaultProp:o??!1,onChange:i,caller:oo}),[M,L]=Fu({prop:s,defaultProp:l,onChange:a,caller:oo}),H=I.useRef(null),R=I.useRef(M);I.useEffect(()=>{const Te=h?p==null?void 0:p.ownerDocument.getElementById(h):p==null?void 0:p.form;if(Te instanceof HTMLFormElement){const Se=be(()=>L(R.current),"reset");return Te.addEventListener("reset",Se),()=>Te.removeEventListener("reset",Se)}},[h,p,L]);const V=p?!!h||!!p.closest("form"):!0,[Z,G]=I.useState(new Set),z=Fh(),re=Array.from(Z).map(Te=>Te.props.value).join(";"),ee=I.useCallback(Te=>{G(Se=>new Set(Se).add(Te))},[]),ne=I.useCallback(Te=>{G(Se=>{const Ke=new Set(Se);return Ke.delete(Te),Ke})},[]),ae={required:g,trigger:p,onTriggerChange:y,valueNode:C,onValueNodeChange:x,valueNodeHasChildren:w,onValueNodeHasChildrenChange:k,contentId:z,value:M,onValueChange:L,open:v,onOpenChange:E,dir:b,triggerPointerDownPosRef:H,disabled:d,name:u,autoComplete:f,form:h,nativeOptions:Z,nativeSelectKey:re,isFormControl:V};return F.jsx(H0,{...m,children:F.jsx(_5,{scope:e,...ae,children:F.jsx(Us.Provider,{scope:e,children:F.jsx(x5,{scope:e,onNativeOptionAdd:ee,onNativeOptionRemove:ne,children:jh(_)?_(ae):t})})})})}be(Kh,"SelectProvider");var C5=be(n=>{const{__scopeSelect:e,children:t,...r}=n;return F.jsx(Kh,{__scopeSelect:e,...r,internal_do_not_use_render:({isFormControl:o})=>F.jsxs(F.Fragment,{children:[t,o?F.jsx(W5,{__scopeSelect:e}):null]})})},"Select"),v5="SelectTrigger",b5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,disabled:o=!1,...i}=e,s=mc(r),l=Hn(v5,r),a=l.disabled||o,c=Rn(t,l.onTriggerChange),u=pc(r),f=I.useRef("touch"),[d,g,h]=_c(m=>{const p=u().filter(x=>!x.disabled),y=p.find(x=>x.value===l.value),C=xc(p,m,y);C!==void 0&&l.onValueChange(C.value)}),_=be(m=>{a||(l.onOpenChange(!0),h()),m&&(l.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})},"handleOpen");return F.jsx(k0,{asChild:!0,...s,children:F.jsx(Kt.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":yi(l.value)?"":void 0,...i,ref:c,onClick:at(i.onClick,m=>{m.currentTarget.focus(),f.current!=="mouse"&&_(m)}),onPointerDown:at(i.onPointerDown,m=>{f.current=m.pointerType;const p=m.target;p.hasPointerCapture(m.pointerId)&&p.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(_(m),m.preventDefault())}),onKeyDown:at(i.onKeyDown,m=>{const p=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&g(m.key),!(p&&m.key===" ")&&g5.includes(m.key)&&(_(),m.preventDefault())})})})},"SelectTrigger")),S5="SelectValue",w5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,className:o,style:i,children:s,placeholder:l="",...a}=e,c=Hn(S5,r),{onValueNodeHasChildrenChange:u}=c,f=s!==void 0,d=Rn(t,c.onValueNodeChange);jo(()=>{u(f)},[u,f]);const g=yi(c.value);return F.jsx(Kt.span,{...a,asChild:g?!1:a.asChild,ref:d,style:{pointerEvents:"none"},children:F.jsx(I.Fragment,{children:g?l:s},g?"placeholder":"value")})},"SelectValue")),T5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,children:o,...i}=e;return F.jsx(Kt.span,{"aria-hidden":!0,...i,ref:t,children:o||"▼"})},"SelectIcon")),E5="SelectPortal",[k5,N5]=vr(E5,{forceMount:void 0}),M5=be(n=>{const{__scopeSelect:e,forceMount:t,...r}=n;return F.jsx(k5,{scope:n.__scopeSelect,forceMount:t,children:F.jsx(N0,{asChild:!0,...r})})},"SelectPortal"),sr="SelectContent",$5=I.forwardRef(be(function(e,t){const r=N5(sr,e.__scopeSelect),{forceMount:o=r.forceMount,...i}=e,s=Hn(sr,e.__scopeSelect),[l,a]=I.useState();return jo(()=>{a(new DocumentFragment)},[]),F.jsx(M0,{present:o||s.open,children:({present:c})=>c?F.jsx(A5,{...i,ref:t}):F.jsx(L5,{...i,fragment:l})})},"SelectContent")),L5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,children:o,fragment:i}=e;return i?Uo.createPortal(F.jsx(Wh,{scope:r,children:F.jsx(Us.Slot,{scope:r,children:F.jsx("div",{ref:t,children:o})})}),i):null},"SelectContentFragment")),Ft=10,[Wh,Zs]=vr(sr),O5=D0("SelectContent.RemoveScroll"),A5=I.forwardRef(be(function(e,t){const{__scopeSelect:r}=e,{position:o="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:s,onPointerDownOutside:l,side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:g,collisionPadding:h,sticky:_,hideWhenDetached:m,avoidCollisions:p,...y}=e,C=Hn(sr,r),[x,w]=I.useState(null),[k,b]=I.useState(null),v=Rn(t,w),[E,M]=I.useState(null),[L,H]=I.useState(null),R=pc(r),[V,Z]=I.useState(!1),G=I.useRef(!1);I.useEffect(()=>{if(x)return L0(x)},[x]),O0();const z=I.useCallback(W=>{const[ce,...Ie]=R().map(xe=>xe.ref.current),[ue]=Ie.slice(-1),de=document.activeElement;for(const xe of W)if(xe===de||(xe==null||xe.scrollIntoView({block:"nearest"}),xe===ce&&k&&(k.scrollTop=0),xe===ue&&k&&(k.scrollTop=k.scrollHeight),xe==null||xe.focus(),document.activeElement!==de))return},[R,k]),re=I.useCallback(()=>z([E,x]),[z,E,x]);I.useEffect(()=>{V&&re()},[V,re]);const{onOpenChange:ee,triggerPointerDownPosRef:ne}=C;I.useEffect(()=>{if(x){let W={x:0,y:0};const ce=be(ue=>{var de,xe;W={x:Math.abs(Math.round(ue.pageX)-(((de=ne.current)==null?void 0:de.x)??0)),y:Math.abs(Math.round(ue.pageY)-(((xe=ne.current)==null?void 0:xe.y)??0))}},"handlePointerMove"),Ie=be(ue=>{W.x<=10&&W.y<=10?ue.preventDefault():ue.composedPath().includes(x)||ee(!1),document.removeEventListener("pointermove",ce),ne.current=null},"handlePointerUp");return ne.current!==null&&(document.addEventListener("pointermove",ce),document.addEventListener("pointerup",Ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ce),document.removeEventListener("pointerup",Ie,{capture:!0})}}},[x,ee,ne]),I.useEffect(()=>{const W=be(()=>ee(!1),"close");return window.addEventListener("blur",W),window.addEventListener("resize",W),()=>{window.removeEventListener("blur",W),window.removeEventListener("resize",W)}},[ee]);const[ae,Te]=_c(W=>{const ce=R().filter(de=>!de.disabled),Ie=ce.find(de=>de.ref.current===document.activeElement),ue=xc(ce,W,Ie);ue&&setTimeout(()=>{var de;return(de=ue.ref.current)==null?void 0:de.focus()})}),Se=I.useCallback((W,ce,Ie)=>{const ue=!G.current&&!Ie;(C.value!==void 0&&C.value===ce||ue)&&(M(W),ue&&(G.current=!0))},[C.value]),Ke=I.useCallback(()=>x==null?void 0:x.focus(),[x]),Ye=I.useCallback((W,ce,Ie)=>{const ue=!G.current&&!Ie;(C.value!==void 0&&C.value===ce||ue)&&H(W)},[C.value]),ie=o==="popper"?zu:I5,_e=ie===zu?{side:a,sideOffset:c,align:u,alignOffset:f,arrowPadding:d,collisionBoundary:g,collisionPadding:h,sticky:_,hideWhenDetached:m,avoidCollisions:p}:{};return F.jsx(Wh,{scope:r,content:x,viewport:k,onViewportChange:b,itemRefCallback:Se,selectedItem:E,onItemLeave:Ke,itemTextRefCallback:Ye,focusSelectedItem:re,selectedItemText:L,position:o,isPositioned:V,searchRef:ae,children:F.jsx(A0,{as:O5,allowPinchZoom:!0,children:F.jsx(I0,{asChild:!0,trapped:C.open,onMountAutoFocus:W=>{W.preventDefault()},onUnmountAutoFocus:at(i,W=>{var ce;(ce=C.trigger)==null||ce.focus({preventScroll:!0}),W.preventDefault()}),children:F.jsx(P0,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:W=>W.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:F.jsx(ie,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:W=>W.preventDefault(),...y,..._e,onPlaced:()=>Z(!0),ref:v,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:at(y.onKeyDown,W=>{const ce=W.ctrlKey||W.altKey||W.metaKey;if(W.key==="Tab"&&W.preventDefault(),!ce&&W.key.length===1&&Te(W.key),["ArrowUp","ArrowDown","Home","End"].includes(W.key)){let ue=R().filter(de=>!de.disabled).map(de=>de.ref.current);if(["ArrowUp","End"].includes(W.key)&&(ue=ue.slice().reverse()),["ArrowUp","ArrowDown"].includes(W.key)){const de=W.target,xe=ue.indexOf(de);ue=ue.slice(xe+1)}setTimeout(()=>z(ue)),W.preventDefault()}})})})})})})},"SelectContentImpl")),I5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,onPlaced:o,...i}=e,s=Hn(sr,r),l=Zs(sr,r),[a,c]=I.useState(null),[u,f]=I.useState(null),d=Rn(t,f),g=pc(r),h=I.useRef(!1),_=I.useRef(!0),{viewport:m,selectedItem:p,selectedItemText:y,focusSelectedItem:C}=l,x=I.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&m&&p&&y){const v=s.trigger.getBoundingClientRect(),E=u.getBoundingClientRect(),M=s.valueNode.getBoundingClientRect(),L=y.getBoundingClientRect();if(s.dir!=="rtl"){const de=L.left-E.left,xe=M.left-de,en=v.left-xe,tn=v.width+en,Ir=Math.max(tn,E.width),bo=window.innerWidth-Ft,Pr=ca(xe,[Ft,Math.max(Ft,bo-Ir)]);a.style.minWidth=tn+"px",a.style.left=Pr+"px"}else{const de=E.right-L.right,xe=window.innerWidth-M.right-de,en=window.innerWidth-v.right-xe,tn=v.width+en,Ir=Math.max(tn,E.width),bo=window.innerWidth-Ft,Pr=ca(xe,[Ft,Math.max(Ft,bo-Ir)]);a.style.minWidth=tn+"px",a.style.right=Pr+"px"}const H=g(),R=window.innerHeight-Ft*2,V=m.scrollHeight,Z=window.getComputedStyle(u),G=parseInt(Z.borderTopWidth,10),z=parseInt(Z.paddingTop,10),re=parseInt(Z.borderBottomWidth,10),ee=parseInt(Z.paddingBottom,10),ne=G+z+V+ee+re,ae=Math.min(p.offsetHeight*5,ne),Te=window.getComputedStyle(m),Se=parseInt(Te.paddingTop,10),Ke=parseInt(Te.paddingBottom,10),Ye=v.top+v.height/2-Ft,ie=R-Ye,_e=p.offsetHeight/2,W=p.offsetTop+_e,ce=G+z+W,Ie=ne-ce;if(ce<=Ye){const de=H.length>0&&p===H[H.length-1].ref.current;a.style.bottom="0px";const xe=u.clientHeight-m.offsetTop-m.offsetHeight,en=Math.max(ie,_e+(de?Ke:0)+xe+re),tn=ce+en;a.style.height=tn+"px"}else{const de=H.length>0&&p===H[0].ref.current;a.style.top="0px";const en=Math.max(Ye,G+m.offsetTop+(de?Se:0)+_e)+Ie;a.style.height=en+"px",m.scrollTop=ce-Ye+m.offsetTop}a.style.margin=`${Ft}px 0`,a.style.minHeight=ae+"px",a.style.maxHeight=R+"px",o==null||o(),requestAnimationFrame(()=>h.current=!0)}},[g,s.trigger,s.valueNode,a,u,m,p,y,s.dir,o]);jo(()=>x(),[x]);const[w,k]=I.useState();jo(()=>{u&&k(window.getComputedStyle(u).zIndex)},[u]);const b=I.useCallback(v=>{v&&_.current===!0&&(x(),C==null||C(),_.current=!1)},[x,C]);return F.jsx(P5,{scope:r,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:b,children:F.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:F.jsx(Kt.div,{...i,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})},"SelectItemAlignedPosition")),zu=I.forwardRef(be(function(e,t){const{__scopeSelect:r,align:o="start",collisionPadding:i=Ft,...s}=e,l=mc(r);return F.jsx(F0,{...l,...s,ref:t,align:o,collisionPadding:i,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[P5,D5]=vr(sr,{}),Ju="SelectViewport",F5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,nonce:o,...i}=e,s=Zs(Ju,r),l=D5(Ju,r),a=Rn(t,s.onViewportChange),c=I.useRef(0);return F.jsxs(F.Fragment,{children:[F.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),F.jsx(Us.Slot,{scope:r,children:F.jsx(Kt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:at(i.onScroll,u=>{const f=u.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&d){const h=Math.abs(c.current-f.scrollTop);if(h>0){const _=window.innerHeight-Ft*2,m=parseFloat(d.style.minHeight),p=parseFloat(d.style.height),y=Math.max(m,p);if(y<_){const C=y+h,x=Math.min(_,C),w=C-x;d.style.height=x+"px",d.style.bottom==="0px"&&(f.scrollTop=w>0?w:0,d.style.justifyContent="flex-end")}}}c.current=f.scrollTop})})})]})},"SelectViewport")),R5="SelectGroup",[pv,mv]=vr(R5),ua="SelectItem",[H5,V5]=vr(ua),B5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,value:o,disabled:i=!1,textValue:s,...l}=e,a=Hn(ua,r),c=Zs(ua,r),u=a.value===o,[f,d]=I.useState(s??""),[g,h]=I.useState(!1),_=hc(x=>{var w;return(w=c.itemRefCallback)==null?void 0:w.call(c,x,o,i)}),m=Rn(t,_),p=Fh(),y=I.useRef("touch"),C=be(()=>{i||(a.onValueChange(o),a.onOpenChange(!1))},"handleSelect");return F.jsx(H5,{scope:r,value:o,disabled:i,textId:p,isSelected:u,onItemTextChange:I.useCallback(x=>{d(w=>w||((x==null?void 0:x.textContent)??"").trim())},[]),children:F.jsx(Us.ItemSlot,{scope:r,value:o,disabled:i,textValue:f,children:F.jsx(Kt.div,{role:"option","aria-labelledby":p,"data-highlighted":g?"":void 0,"aria-selected":u&&g,"data-state":u?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...l,ref:m,onFocus:at(l.onFocus,()=>h(!0)),onBlur:at(l.onBlur,()=>h(!1)),onClick:at(l.onClick,()=>{y.current!=="mouse"&&C()}),onPointerUp:at(l.onPointerUp,()=>{y.current==="mouse"&&C()}),onPointerDown:at(l.onPointerDown,x=>{y.current=x.pointerType}),onPointerMove:at(l.onPointerMove,x=>{var w;y.current=x.pointerType,i?(w=c.onItemLeave)==null||w.call(c):y.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:at(l.onPointerLeave,x=>{var w;x.currentTarget===document.activeElement&&((w=c.onItemLeave)==null||w.call(c))}),onKeyDown:at(l.onKeyDown,x=>{var k;i||x.target!==x.currentTarget||((k=c.searchRef)==null?void 0:k.current)!==""&&x.key===" "||(p5.includes(x.key)&&C(),x.key===" "&&x.preventDefault())})})})})},"SelectItem")),Fi="SelectItemText",z5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,className:o,style:i,...s}=e,l=Hn(Fi,r),a=Zs(Fi,r),c=V5(Fi,r),u=y5(Fi,r),[f,d]=I.useState(null),g=hc(C=>{var x;return(x=a.itemTextRefCallback)==null?void 0:x.call(a,C,c.value,c.disabled)}),h=Rn(t,d,c.onItemTextChange,g),_=f==null?void 0:f.textContent,m=I.useMemo(()=>F.jsx("option",{value:c.value,disabled:c.disabled,children:_},c.value),[c.disabled,c.value,_]),{onNativeOptionAdd:p,onNativeOptionRemove:y}=u;return jo(()=>(p(m),()=>y(m)),[p,y,m]),F.jsxs(F.Fragment,{children:[F.jsx(Kt.span,{id:c.textId,...s,ref:h}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!yi(l.value)?Uo.createPortal(s.children,l.valueNode):null]})},"SelectItemText")),J5=I.forwardRef(be(function(e,t){const{__scopeSelect:r,...o}=e;return F.jsx(Kt.div,{"aria-hidden":!0,...o,ref:t})},"SelectSeparator")),K5="SelectBubbleInput",W5=I.forwardRef(be(function({__scopeSelect:e,...t},r){const o=Hn(K5,e),{value:i,onValueChange:s,required:l,disabled:a,name:c,autoComplete:u,form:f}=o,{nativeOptions:d,nativeSelectKey:g}=o,h=I.useRef(null),_=Rn(r,h),m=i??"",p=Jh(m),y=Array.from(d).some(C=>(C.props.value??"")==="");return I.useEffect(()=>{const C=h.current;if(!C)return;const x=window.HTMLSelectElement.prototype,k=Object.getOwnPropertyDescriptor(x,"value").set;if(p!==m&&k){const b=new Event("change",{bubbles:!0});k.call(C,m),C.dispatchEvent(b)}},[p,m]),F.jsxs(Kt.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:c,autoComplete:u,disabled:a,form:f,onChange:C=>s(C.target.value),...t,style:{...R0,...t.style},ref:_,defaultValue:m,children:[yi(i)&&!y?F.jsx("option",{value:""}):null,Array.from(d)]},g)},"SelectBubbleInput"));function jh(n){return typeof n=="function"}be(jh,"isFunction");function yi(n){return n===""||n===void 0}be(yi,"shouldShowPlaceholder");function _c(n){const e=hc(n),t=I.useRef(""),r=I.useRef(0),o=I.useCallback(s=>{const l=t.current+s;e(l),be(function a(c){t.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>a(""),1e3))},"updateSearch")(l)},[e]),i=I.useCallback(()=>{t.current="",window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[t,o,i]}be(_c,"useTypeaheadSearch");function xc(n,e,t){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,i=t?n.indexOf(t):-1;let s=Uh(n,Math.max(i,0));o.length===1&&(s=s.filter(c=>c!==t));const a=s.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return a!==t?a:void 0}be(xc,"findNextItem");function Uh(n,e){return n.map((t,r)=>n[(e+r)%n.length])}be(Uh,"wrapArray");var j5=Object.defineProperty,qs=(n,e)=>j5(n,"name",{value:e,configurable:!0}),Zh="Toolbar",[U5,_v]=Hh(Zh,[Bh,zh]),qh=Bh(),Gh=zh(),[Z5,q5]=U5(Zh),G5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,orientation:o="horizontal",dir:i,loop:s=!0,...l}=e,a=qh(r),c=Vh(i);return F.jsx(Z5,{scope:r,orientation:o,dir:c,children:F.jsx(z0,{asChild:!0,...a,orientation:o,dir:c,loop:s,children:F.jsx(Kt.div,{role:"toolbar","aria-orientation":o,dir:c,...l,ref:t})})})},"Toolbar")),Yh=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=qh(r);return F.jsx(V0,{asChild:!0,...i,focusable:!e.disabled,children:F.jsx(Kt.button,{type:"button",...o,ref:t})})},"ToolbarButton")),Y5="ToolbarToggleGroup",X5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=q5(Y5,r),s=Gh(r);return F.jsx(J0,{"data-orientation":i.orientation,dir:i.dir,...s,...o,ref:t,rovingFocus:!1})},"ToolbarToggleGroup")),Q5=I.forwardRef(qs(function(e,t){const{__scopeToolbar:r,...o}=e,i=Gh(r),s={__scopeToolbar:e.__scopeToolbar};return F.jsx(Yh,{asChild:!0,...s,children:F.jsx(B0,{...i,...o,ref:t})})},"ToolbarToggleItem")),e2=G5,t2=Yh,yc=X5,n2=Q5;const r2={}.hasOwnProperty;function Xh(n,e){let t=-1,r;if(e.extensions)for(;++tr*r+j*j&&(O=E,Q=p),{cx:O,cy:Q,x01:-n,y01:-d,x11:O*(v/T-1),y11:Q*(v/T-1)}}function hn(){var l=cn,h=yn,q=S(0),w=null,v=gn,A=dn,Y=mn,a=null,z=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,Z=rn(c-f),t=c>f;if(a||(a=n=z()),sy))a.moveTo(0,0);else if(Z>tn-y)a.moveTo(s*B(f),s*b(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*B(c),u*b(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=Z,I=Z,O=Y.apply(this,arguments)/2,Q=O>y&&(w?+w.apply(this,arguments):G(u*u+s*s)),E=_(rn(s-u)/2,+q.apply(this,arguments)),p=E,x=E,e,r;if(Q>y){var j=sn(Q/u*b(O)),H=sn(Q/s*b(O));(P-=j*2)>y?(j*=t?1:-1,R+=j,T-=j):(P=0,R=T=(f+c)/2),(I-=H*2)>y?(H*=t?1:-1,m+=H,g-=H):(I=0,m=g=(f+c)/2)}var C=s*B(m),F=s*b(m),J=u*B(T),K=u*b(T);if(E>y){var L=s*B(g),M=s*b(g),U=u*B(R),V=u*b(R),D;if(Zy?x>y?(e=N(U,V,C,F,s,x,t),r=N(L,M,J,K,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),xy)||!(P>y)?a.lineTo(J,K):p>y?(e=N(J,K,L,M,u,-p,t),r=N(C,F,U,V,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),pr*r+j*j&&(O=E,Q=p),{cx:O,cy:Q,x01:-n,y01:-d,x11:O*(v/T-1),y11:Q*(v/T-1)}}function hn(){var l=cn,h=yn,q=S(0),w=null,v=gn,A=dn,Y=mn,a=null,z=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,Z=rn(c-f),t=c>f;if(a||(a=n=z()),sy))a.moveTo(0,0);else if(Z>tn-y)a.moveTo(s*B(f),s*b(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*B(c),u*b(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=Z,I=Z,O=Y.apply(this,arguments)/2,Q=O>y&&(w?+w.apply(this,arguments):G(u*u+s*s)),E=_(rn(s-u)/2,+q.apply(this,arguments)),p=E,x=E,e,r;if(Q>y){var j=sn(Q/u*b(O)),H=sn(Q/s*b(O));(P-=j*2)>y?(j*=t?1:-1,R+=j,T-=j):(P=0,R=T=(f+c)/2),(I-=H*2)>y?(H*=t?1:-1,m+=H,g-=H):(I=0,m=g=(f+c)/2)}var C=s*B(m),F=s*b(m),J=u*B(T),K=u*b(T);if(E>y){var L=s*B(g),M=s*b(g),U=u*B(R),V=u*b(R),D;if(Zy?x>y?(e=N(U,V,C,F,s,x,t),r=N(L,M,J,K,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),xy)||!(P>y)?a.lineTo(J,K):p>y?(e=N(J,K,L,M,u,-p,t),r=N(C,F,U,V,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),pa.lang.round(n.parse(r)[o]);export{t as c};
+import{U as a,C as n}from"../visualizations/mermaid/mermaid.core-BcqeQUkk.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
diff --git a/veadk/webui/assets/chunks/index.es-CE6umRqJ.js b/veadk/webui/assets/chunks/index.es-By-P9X2v.js
similarity index 99%
rename from veadk/webui/assets/chunks/index.es-CE6umRqJ.js
rename to veadk/webui/assets/chunks/index.es-By-P9X2v.js
index ca0d6e483..31e38743f 100644
--- a/veadk/webui/assets/chunks/index.es-CE6umRqJ.js
+++ b/veadk/webui/assets/chunks/index.es-By-P9X2v.js
@@ -1,4 +1,4 @@
-import{L as Ke,a8 as Do}from"../app/index-Ch6a-P8E.js";import{_ as Xa}from"./jspdf.es.min-DdJSjEtu.js";var vt=function(a){return a&&a.Math===Math&&a},_=vt(typeof globalThis=="object"&&globalThis)||vt(typeof window=="object"&&window)||vt(typeof self=="object"&&self)||vt(typeof Ke=="object"&&Ke)||vt(typeof Ke=="object"&&Ke)||function(){return this}()||Function("return this")(),$t={},D=function(a){try{return!!a()}catch{return!0}},Pl=D,he=!Pl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),Rl=D,br=!Rl(function(){var a=(function(){}).bind();return typeof a!="function"||a.hasOwnProperty("prototype")}),Nl=br,Ft=Function.prototype.call,Y=Nl?Ft.bind(Ft):function(){return Ft.apply(Ft,arguments)},Lo={},ko={}.propertyIsEnumerable,Bo=Object.getOwnPropertyDescriptor,Il=Bo&&!ko.call({1:2},1);Lo.f=Il?function(e){var t=Bo(this,e);return!!t&&t.enumerable}:ko;var Si=function(a,e){return{enumerable:!(a&1),configurable:!(a&2),writable:!(a&4),value:e}},jo=br,Fo=Function.prototype,Wa=Fo.call,Ml=jo&&Fo.bind.bind(Wa,Wa),L=jo?Ml:function(a){return function(){return Wa.apply(a,arguments)}},Uo=L,_l=Uo({}.toString),Vl=Uo("".slice),Ce=function(a){return Vl(_l(a),8,-1)},Dl=L,Ll=D,kl=Ce,ea=Object,Bl=Dl("".split),Go=Ll(function(){return!ea("z").propertyIsEnumerable(0)})?function(a){return kl(a)==="String"?Bl(a,""):ea(a)}:ea,xr=function(a){return a==null},jl=xr,Fl=TypeError,ve=function(a){if(jl(a))throw new Fl("Can't call method on "+a);return a},Ul=Go,Gl=ve,wt=function(a){return Ul(Gl(a))},ta=typeof document=="object"&&document.all,k=typeof ta>"u"&&ta!==void 0?function(a){return typeof a=="function"||a===ta}:function(a){return typeof a=="function"},zl=k,ae=function(a){return typeof a=="object"?a!==null:zl(a)},ra=_,Hl=k,Yl=function(a){return Hl(a)?a:void 0},Fe=function(a,e){return arguments.length<2?Yl(ra[a]):ra[a]&&ra[a][e]},Xl=L,Tr=Xl({}.isPrototypeOf),Wl=_,pn=Wl.navigator,yn=pn&&pn.userAgent,Ct=yn?String(yn):"",zo=_,aa=Ct,mn=zo.process,bn=zo.Deno,xn=mn&&mn.versions||bn&&bn.version,Tn=xn&&xn.v8,le,cr;Tn&&(le=Tn.split("."),cr=le[0]>0&&le[0]<4?1:+(le[0]+le[1]));!cr&&aa&&(le=aa.match(/Edge\/(\d+)/),(!le||le[1]>=74)&&(le=aa.match(/Chrome\/(\d+)/),le&&(cr=+le[1])));var Ei=cr,On=Ei,ql=D,Ql=_,Kl=Ql.String,Ho=!!Object.getOwnPropertySymbols&&!ql(function(){var a=Symbol("symbol detection");return!Kl(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&On&&On<41}),Zl=Ho,Yo=Zl&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Jl=Fe,eh=k,th=Tr,rh=Yo,ah=Object,Xo=rh?function(a){return typeof a=="symbol"}:function(a){var e=Jl("Symbol");return eh(e)&&th(e.prototype,ah(a))},ih=String,Or=function(a){try{return ih(a)}catch{return"Object"}},nh=k,sh=Or,oh=TypeError,Ae=function(a){if(nh(a))return a;throw new oh(sh(a)+" is not a function")},uh=Ae,lh=xr,ot=function(a,e){var t=a[e];return lh(t)?void 0:uh(t)},ia=Y,na=k,sa=ae,hh=TypeError,vh=function(a,e){var t,r;if(e==="string"&&na(t=a.toString)&&!sa(r=ia(t,a))||na(t=a.valueOf)&&!sa(r=ia(t,a))||e!=="string"&&na(t=a.toString)&&!sa(r=ia(t,a)))return r;throw new hh("Can't convert object to primitive value")},Wo={exports:{}},Sn=_,fh=Object.defineProperty,$i=function(a,e){try{fh(Sn,a,{value:e,configurable:!0,writable:!0})}catch{Sn[a]=e}return e},ch=_,gh=$i,En="__core-js_shared__",$n=Wo.exports=ch[En]||gh(En,{});($n.versions||($n.versions=[])).push({version:"3.50.0",mode:"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.50.0/LICENSE",source:"https://github.com/zloirock/core-js"});var wi=Wo.exports,wn=wi,dh=Object.create||Object,Ci=function(a,e){return wn[a]||(wn[a]=e||dh(null))},ph=ve,yh=Object,Sr=function(a){return yh(ph(a))},mh=L,bh=Sr,xh=mh({}.hasOwnProperty),fe=Object.hasOwn||function(e,t){return xh(bh(e),t)},Th=L,Oh=0,Sh=Math.random(),Eh=Th(1.1.toString),qo=function(a){return"Symbol("+(a===void 0?"":a)+")_"+Eh(++Oh+Sh,36)},$h=_,wh=Ci,Cn=fe,Ch=qo,Ah=Ho,Ph=Yo,Ze=$h.Symbol,oa=wh("wks"),Rh=Ph?Ze.for||Ze:Ze&&Ze.withoutSetter||Ch,z=function(a){return Cn(oa,a)||(oa[a]=Ah&&Cn(Ze,a)?Ze[a]:Rh("Symbol."+a)),oa[a]},Nh=Y,An=ae,Pn=Xo,Ih=ot,Mh=vh,_h=z,Vh=TypeError,Dh=_h("toPrimitive"),Lh=function(a,e){if(!An(a)||Pn(a))return a;var t=Ih(a,Dh),r;if(t){if(e===void 0&&(e="default"),r=Nh(t,a,e),!An(r)||Pn(r))return r;throw new Vh("Can't convert object to primitive value")}return e===void 0&&(e="number"),Mh(a,e)},kh=Lh,Bh=Xo,Qo=function(a){var e=kh(a,"string");return Bh(e)?e:e+""},jh=_,Rn=ae,qa=jh.document,Fh=Rn(qa)&&Rn(qa.createElement),Er=function(a){return Fh?qa.createElement(a):{}},Uh=he,Gh=D,zh=Er,Ko=!Uh&&!Gh(function(){return Object.defineProperty(zh("div"),"a",{get:function(){return 7}}).a!==7}),Hh=he,Yh=Y,Xh=Lo,Wh=Si,qh=wt,Qh=Qo,Kh=fe,Zh=Ko,Nn=Object.getOwnPropertyDescriptor;$t.f=Hh?Nn:function(e,t){if(e=qh(e),t=Qh(t),Zh)try{return Nn(e,t)}catch{}if(Kh(e,t))return Wh(!Yh(Xh.f,e,t),e[t])};var Te={},Jh=he,ev=D,Zo=Jh&&ev(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),tv=ae,rv=String,av=TypeError,J=function(a){if(tv(a))return a;throw new av(rv(a)+" is not an object")},iv=he,nv=Ko,sv=Zo,Ut=J,In=Qo,ov=TypeError,ua=Object.defineProperty,uv=Object.getOwnPropertyDescriptor,la="enumerable",ha="configurable",va="writable";Te.f=iv?sv?function(e,t,r){if(Ut(e),t=In(t),Ut(r),typeof e=="function"&&t==="prototype"&&"value"in r&&va in r&&!r[va]){var i=uv(e,t);i&&i[va]&&(e[t]=r.value,r={configurable:ha in r?r[ha]:i[ha],enumerable:la in r?r[la]:i[la],writable:!1})}return ua(e,t,r)}:ua:function(e,t,r){if(Ut(e),t=In(t),Ut(r),nv)try{return ua(e,t,r)}catch{}if("get"in r||"set"in r)throw new ov("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var lv=he,hv=Te,vv=Si,At=lv?function(a,e,t){return hv.f(a,e,vv(1,t))}:function(a,e,t){return a[e]=t,a},Jo={exports:{}},Qa=he,fv=fe,eu=Function.prototype,cv=Qa&&Object.getOwnPropertyDescriptor,tu=fv(eu,"name"),gv=tu&&(function(){}).name==="something",dv=tu&&(!Qa||Qa&&cv(eu,"name").configurable),$r={PROPER:gv,CONFIGURABLE:dv},pv=L,yv=k,Ka=wi,mv=pv(Function.toString);yv(Ka.inspectSource)||(Ka.inspectSource=function(a){return mv(a)});var Ai=Ka.inspectSource,bv=_,xv=k,Mn=bv.WeakMap,Tv=xv(Mn)&&/native code/.test(String(Mn)),Ov=Ci,Sv=qo,_n=Ov("keys"),Pi=function(a){return _n[a]||(_n[a]=Sv(a))},Ri={},Ev=Tv,ru=_,$v=ae,wv=At,fa=fe,ca=wi,Cv=Pi,Av=Ri,Vn="Object already initialized",Za=ru.TypeError,Pv=ru.WeakMap,gr,Ot,dr,Rv=function(a){return dr(a)?Ot(a):gr(a,{})},Nv=function(a){return function(e){var t;if(!$v(e)||(t=Ot(e)).type!==a)throw new Za("Incompatible receiver, "+a+" required");return t}};if(Ev||ca.state){var de=ca.state||(ca.state=new Pv);de.get=de.get,de.has=de.has,de.set=de.set,gr=function(a,e){if(de.has(a))throw new Za(Vn);return e.facade=a,de.set(a,e),e},Ot=function(a){return de.get(a)||{}},dr=function(a){return de.has(a)}}else{var Ye=Cv("state");Av[Ye]=!0,gr=function(a,e){if(fa(a,Ye))throw new Za(Vn);return e.facade=a,wv(a,Ye,e),e},Ot=function(a){return fa(a,Ye)?a[Ye]:{}},dr=function(a){return fa(a,Ye)}}var wr={set:gr,get:Ot,has:dr,enforce:Rv,getterFor:Nv},Ni=L,Iv=D,Mv=k,Gt=fe,Ja=he,_v=$r.CONFIGURABLE,Vv=Ai,au=wr,Dv=au.enforce,Lv=au.get,Dn=String,or=Object.defineProperty,kv=Ni("".slice),Bv=Ni("".replace),jv=Ni([].join),Fv=Ja&&!Iv(function(){return or(function(){},"length",{value:8}).length!==8}),Uv=String(String).split("String"),Gv=Jo.exports=function(a,e,t){kv(Dn(e),0,7)==="Symbol("&&(e="["+Bv(Dn(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!Gt(a,"name")||_v&&a.name!==e)&&(Ja?or(a,"name",{value:e,configurable:!0}):a.name=e),Fv&&t&&Gt(t,"arity")&&a.length!==t.arity&&or(a,"length",{value:t.arity});try{t&&Gt(t,"constructor")&&t.constructor?Ja&&or(a,"prototype",{writable:!1}):a.prototype&&(a.prototype=void 0)}catch{}var r=Dv(a);return Gt(r,"source")||(r.source=jv(Uv,typeof e=="string"?e:"")),a};Function.prototype.toString=Gv(function(){return Mv(this)&&Lv(this).source||Vv(this)},"toString");var iu=Jo.exports,zv=k,Hv=Te,Yv=iu,Xv=$i,Ue=function(a,e,t,r){r||(r={});var i=r.enumerable,n=r.name!==void 0?r.name:e;if(zv(t)&&Yv(t,n,r),r.global)i?a[e]=t:Xv(e,t);else{try{r.unsafe?a[e]&&(i=!0):delete a[e]}catch{}i?a[e]=t:Hv.f(a,e,{value:t,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return a},nu={},Wv=Math.ceil,qv=Math.floor,Qv=Math.trunc||function(e){var t=+e;return(t>0?qv:Wv)(t)},Kv=Qv,Cr=function(a){var e=+a;return e!==e||e===0?0:Kv(e)},Zv=Cr,Jv=Math.max,ef=Math.min,tf=function(a,e){var t=Zv(a);return t<0?Jv(t+e,0):ef(t,e)},rf=Cr,af=Math.min,ut=function(a){var e=rf(a);return e>0?af(e,9007199254740991):0},nf=ut,Ii=function(a){return nf(a.length)},sf=wt,of=tf,uf=Ii,lf=function(a){return function(e,t,r){var i=sf(e),n=uf(i);if(n===0)return!a&&-1;var o=of(r,n),s;if(a&&t!==t){for(;n>o;)if(s=i[o++],s!==s)return!0}else for(;n>o;o++)if((a||o in i)&&i[o]===t)return a||o||0;return!a&&-1}},su={indexOf:lf(!1)},hf=L,ga=fe,vf=wt,ff=su.indexOf,cf=Ri,Ln=hf([].push),ou=function(a,e){var t=vf(a),r=0,i=[],n;for(n in t)!ga(cf,n)&&ga(t,n)&&Ln(i,n);for(;e.length>r;)ga(t,n=e[r++])&&(~ff(i,n)||Ln(i,n));return i},Mi=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],gf=ou,df=Mi,pf=df.concat("length","prototype");nu.f=Object.getOwnPropertyNames||function(e){return gf(e,pf)};var uu={};uu.f=Object.getOwnPropertySymbols;var yf=Fe,mf=L,bf=nu,xf=uu,Tf=J,Of=mf([].concat),Sf=yf("Reflect","ownKeys")||function(e){var t=bf.f(Tf(e)),r=xf.f;return r?Of(t,r(e)):t},kn=fe,Ef=Sf,$f=$t,wf=Te,Cf=function(a,e,t){for(var r=Ef(e),i=wf.f,n=$f.f,o=0;of;f++)if(v=y(a[f]),v&&ms(xs,v))return v;return new hr(!1)}l=wd(a,h)}for(g=n?a.next:l.next;!(d=Td(g,l)).done;){var T=d.value;try{v=y(T)}catch(b){if(l)bs(l,"throw",b);else throw b}if(typeof v=="object"&&v&&ms(xs,v))return v}return new hr(!1)},Pd=z,Gu=Pd("iterator"),zu=!1;try{var Rd=0,Ts={next:function(){return{done:!!Rd++}},return:function(){zu=!0}};Ts[Gu]=function(){return this},Array.from(Ts,function(){throw 2})}catch{}var Nd=function(a,e){try{if(!e&&!zu)return!1}catch{return!1}var t=!1;try{var r={};r[Gu]=function(){return{next:function(){return{done:t=!0}}}},a(r)}catch{}return t},Id=Nr,Md=Nd,_d=Rt.CONSTRUCTOR,Hu=_d||!Md(function(a){Id.all(a).then(void 0,function(){})}),Vd=ee,Dd=Y,Ld=Ae,kd=lt,Bd=Li,jd=Uu,Fd=Hu;Vd({target:"Promise",stat:!0,forced:Fd},{all:function(e){var t=this,r=kd.f(t),i=r.resolve,n=r.reject,o=Bd(function(){var s=Ld(t.resolve),u=[],l=0,h=1;jd(e,function(f){var c=l++,v=!1;h++,Dd(s,t,f).then(function(g){v||(v=!0,u[c]=g,--h||i(u))},n)}),--h||i(u)});return o.error&&n(o.value),r.promise}});var Ud=ee,Gd=Rt.CONSTRUCTOR,si=Nr,zd=Fe,Hd=k,Yd=Ue,Os=si&&si.prototype;Ud({target:"Promise",proto:!0,forced:Gd,real:!0},{catch:function(a){return this.then(void 0,a)}});if(Hd(si)){var Ss=zd("Promise").prototype.catch;Os.catch!==Ss&&Yd(Os,"catch",Ss,{unsafe:!0})}var Xd=ee,Wd=Y,qd=Ae,Qd=lt,Kd=Li,Zd=Uu,Jd=Hu;Xd({target:"Promise",stat:!0,forced:Jd},{race:function(e){var t=this,r=Qd.f(t),i=r.reject,n=Kd(function(){var o=qd(t.resolve);Zd(e,function(s){Wd(o,t,s).then(r.resolve,i)})});return n.error&&i(n.value),r.promise}});var ep=ee,tp=lt,rp=Rt.CONSTRUCTOR;ep({target:"Promise",stat:!0,forced:rp},{reject:function(e){var t=tp.f(this),r=t.reject;return r(e),t.promise}});var ap=J,ip=ae,np=lt,sp=function(a,e){if(ap(a),ip(e)&&e.constructor===a)return e;var t=np.f(a),r=t.resolve;return r(e),t.promise},op=ee,up=Fe,lp=Rt.CONSTRUCTOR,hp=sp;up("Promise");op({target:"Promise",stat:!0,forced:lp},{resolve:function(e){return hp(this,e)}});function Es(a,e,t,r,i,n,o){try{var s=a[n](o),u=s.value}catch(l){return void t(l)}s.done?e(u):Promise.resolve(u).then(r,i)}function xe(a){return function(){var e=this,t=arguments;return new Promise(function(r,i){var n=a.apply(e,t);function o(u){Es(n,r,i,o,s,"next",u)}function s(u){Es(n,r,i,o,s,"throw",u)}o(void 0)})}}var vp=cu,fp=String,pe=function(a){if(vp(a)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return fp(a)},cp=J,Yu=function(){var a=cp(this),e="";return a.hasIndices&&(e+="d"),a.global&&(e+="g"),a.ignoreCase&&(e+="i"),a.multiline&&(e+="m"),a.dotAll&&(e+="s"),a.unicode&&(e+="u"),a.unicodeSets&&(e+="v"),a.sticky&&(e+="y"),e},Ui=D,gp=_,Gi=gp.RegExp,zi=Ui(function(){var a=Gi("a","y");return a.lastIndex=2,a.exec("abcd")!==null});zi||Ui(function(){return!Gi("a","y").sticky});var dp=zi||Ui(function(){var a=Gi("^r","gy");return a.lastIndex=2,a.exec("str")!==null}),Xu={BROKEN_CARET:dp,UNSUPPORTED_Y:zi},Wu={},pp=ou,yp=Mi,mp=Object.keys||function(e){return pp(e,yp)},bp=he,xp=Zo,Tp=Te,Op=J,Sp=wt,Ep=mp;Wu.f=bp&&!xp?Object.defineProperties:function(e,t){Op(e);for(var r=Sp(t),i=Ep(t),n=i.length,o=0,s;n>o;)Tp.f(e,s=i[o++],r[s]);return e};var $p=J,wp=Wu,$s=Mi,Cp=Ri,Ap=Tu,Pp=Er,Rp=Pi,ws=">",Cs="<",oi="prototype",ui="script",qu=Rp("IE_PROTO"),wa=function(){},Qu=function(a){return Cs+ui+ws+a+Cs+"/"+ui+ws},As=function(a){a.write(Qu("")),a.close();var e=a.parentWindow.Object;return a=null,e},Np=function(){var a=Pp("iframe"),e="java"+ui+":",t;return a.style.display="none",Ap.appendChild(a),a.src=String(e),t=a.contentWindow.document,t.open(),t.write(Qu("document.F=Object")),t.close(),t.F},Zt,vr=function(){try{Zt=new ActiveXObject("htmlfile")}catch{}vr=typeof document<"u"?document.domain&&Zt?As(Zt):Np():As(Zt);for(var a=$s.length;a--;)delete vr[oi][$s[a]];return vr()};Cp[qu]=!0;var Hi=Object.create||function(e,t){var r;return e!==null?(wa[oi]=$p(e),r=new wa,wa[oi]=null,r[qu]=e):r=vr(),t===void 0?r:wp.f(r,t)},Ip=D,Mp=_,_p=Mp.RegExp,Vp=Ip(function(){var a=_p(".","s");return!(a.dotAll&&a.test(`
+import{L as Ke,a8 as Do}from"../app/index-z3uMxcpH.js";import{_ as Xa}from"./jspdf.es.min-CKI8Ibko.js";var vt=function(a){return a&&a.Math===Math&&a},_=vt(typeof globalThis=="object"&&globalThis)||vt(typeof window=="object"&&window)||vt(typeof self=="object"&&self)||vt(typeof Ke=="object"&&Ke)||vt(typeof Ke=="object"&&Ke)||function(){return this}()||Function("return this")(),$t={},D=function(a){try{return!!a()}catch{return!0}},Pl=D,he=!Pl(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),Rl=D,br=!Rl(function(){var a=(function(){}).bind();return typeof a!="function"||a.hasOwnProperty("prototype")}),Nl=br,Ft=Function.prototype.call,Y=Nl?Ft.bind(Ft):function(){return Ft.apply(Ft,arguments)},Lo={},ko={}.propertyIsEnumerable,Bo=Object.getOwnPropertyDescriptor,Il=Bo&&!ko.call({1:2},1);Lo.f=Il?function(e){var t=Bo(this,e);return!!t&&t.enumerable}:ko;var Si=function(a,e){return{enumerable:!(a&1),configurable:!(a&2),writable:!(a&4),value:e}},jo=br,Fo=Function.prototype,Wa=Fo.call,Ml=jo&&Fo.bind.bind(Wa,Wa),L=jo?Ml:function(a){return function(){return Wa.apply(a,arguments)}},Uo=L,_l=Uo({}.toString),Vl=Uo("".slice),Ce=function(a){return Vl(_l(a),8,-1)},Dl=L,Ll=D,kl=Ce,ea=Object,Bl=Dl("".split),Go=Ll(function(){return!ea("z").propertyIsEnumerable(0)})?function(a){return kl(a)==="String"?Bl(a,""):ea(a)}:ea,xr=function(a){return a==null},jl=xr,Fl=TypeError,ve=function(a){if(jl(a))throw new Fl("Can't call method on "+a);return a},Ul=Go,Gl=ve,wt=function(a){return Ul(Gl(a))},ta=typeof document=="object"&&document.all,k=typeof ta>"u"&&ta!==void 0?function(a){return typeof a=="function"||a===ta}:function(a){return typeof a=="function"},zl=k,ae=function(a){return typeof a=="object"?a!==null:zl(a)},ra=_,Hl=k,Yl=function(a){return Hl(a)?a:void 0},Fe=function(a,e){return arguments.length<2?Yl(ra[a]):ra[a]&&ra[a][e]},Xl=L,Tr=Xl({}.isPrototypeOf),Wl=_,pn=Wl.navigator,yn=pn&&pn.userAgent,Ct=yn?String(yn):"",zo=_,aa=Ct,mn=zo.process,bn=zo.Deno,xn=mn&&mn.versions||bn&&bn.version,Tn=xn&&xn.v8,le,cr;Tn&&(le=Tn.split("."),cr=le[0]>0&&le[0]<4?1:+(le[0]+le[1]));!cr&&aa&&(le=aa.match(/Edge\/(\d+)/),(!le||le[1]>=74)&&(le=aa.match(/Chrome\/(\d+)/),le&&(cr=+le[1])));var Ei=cr,On=Ei,ql=D,Ql=_,Kl=Ql.String,Ho=!!Object.getOwnPropertySymbols&&!ql(function(){var a=Symbol("symbol detection");return!Kl(a)||!(Object(a)instanceof Symbol)||!Symbol.sham&&On&&On<41}),Zl=Ho,Yo=Zl&&!Symbol.sham&&typeof Symbol.iterator=="symbol",Jl=Fe,eh=k,th=Tr,rh=Yo,ah=Object,Xo=rh?function(a){return typeof a=="symbol"}:function(a){var e=Jl("Symbol");return eh(e)&&th(e.prototype,ah(a))},ih=String,Or=function(a){try{return ih(a)}catch{return"Object"}},nh=k,sh=Or,oh=TypeError,Ae=function(a){if(nh(a))return a;throw new oh(sh(a)+" is not a function")},uh=Ae,lh=xr,ot=function(a,e){var t=a[e];return lh(t)?void 0:uh(t)},ia=Y,na=k,sa=ae,hh=TypeError,vh=function(a,e){var t,r;if(e==="string"&&na(t=a.toString)&&!sa(r=ia(t,a))||na(t=a.valueOf)&&!sa(r=ia(t,a))||e!=="string"&&na(t=a.toString)&&!sa(r=ia(t,a)))return r;throw new hh("Can't convert object to primitive value")},Wo={exports:{}},Sn=_,fh=Object.defineProperty,$i=function(a,e){try{fh(Sn,a,{value:e,configurable:!0,writable:!0})}catch{Sn[a]=e}return e},ch=_,gh=$i,En="__core-js_shared__",$n=Wo.exports=ch[En]||gh(En,{});($n.versions||($n.versions=[])).push({version:"3.50.0",mode:"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.50.0/LICENSE",source:"https://github.com/zloirock/core-js"});var wi=Wo.exports,wn=wi,dh=Object.create||Object,Ci=function(a,e){return wn[a]||(wn[a]=e||dh(null))},ph=ve,yh=Object,Sr=function(a){return yh(ph(a))},mh=L,bh=Sr,xh=mh({}.hasOwnProperty),fe=Object.hasOwn||function(e,t){return xh(bh(e),t)},Th=L,Oh=0,Sh=Math.random(),Eh=Th(1.1.toString),qo=function(a){return"Symbol("+(a===void 0?"":a)+")_"+Eh(++Oh+Sh,36)},$h=_,wh=Ci,Cn=fe,Ch=qo,Ah=Ho,Ph=Yo,Ze=$h.Symbol,oa=wh("wks"),Rh=Ph?Ze.for||Ze:Ze&&Ze.withoutSetter||Ch,z=function(a){return Cn(oa,a)||(oa[a]=Ah&&Cn(Ze,a)?Ze[a]:Rh("Symbol."+a)),oa[a]},Nh=Y,An=ae,Pn=Xo,Ih=ot,Mh=vh,_h=z,Vh=TypeError,Dh=_h("toPrimitive"),Lh=function(a,e){if(!An(a)||Pn(a))return a;var t=Ih(a,Dh),r;if(t){if(e===void 0&&(e="default"),r=Nh(t,a,e),!An(r)||Pn(r))return r;throw new Vh("Can't convert object to primitive value")}return e===void 0&&(e="number"),Mh(a,e)},kh=Lh,Bh=Xo,Qo=function(a){var e=kh(a,"string");return Bh(e)?e:e+""},jh=_,Rn=ae,qa=jh.document,Fh=Rn(qa)&&Rn(qa.createElement),Er=function(a){return Fh?qa.createElement(a):{}},Uh=he,Gh=D,zh=Er,Ko=!Uh&&!Gh(function(){return Object.defineProperty(zh("div"),"a",{get:function(){return 7}}).a!==7}),Hh=he,Yh=Y,Xh=Lo,Wh=Si,qh=wt,Qh=Qo,Kh=fe,Zh=Ko,Nn=Object.getOwnPropertyDescriptor;$t.f=Hh?Nn:function(e,t){if(e=qh(e),t=Qh(t),Zh)try{return Nn(e,t)}catch{}if(Kh(e,t))return Wh(!Yh(Xh.f,e,t),e[t])};var Te={},Jh=he,ev=D,Zo=Jh&&ev(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),tv=ae,rv=String,av=TypeError,J=function(a){if(tv(a))return a;throw new av(rv(a)+" is not an object")},iv=he,nv=Ko,sv=Zo,Ut=J,In=Qo,ov=TypeError,ua=Object.defineProperty,uv=Object.getOwnPropertyDescriptor,la="enumerable",ha="configurable",va="writable";Te.f=iv?sv?function(e,t,r){if(Ut(e),t=In(t),Ut(r),typeof e=="function"&&t==="prototype"&&"value"in r&&va in r&&!r[va]){var i=uv(e,t);i&&i[va]&&(e[t]=r.value,r={configurable:ha in r?r[ha]:i[ha],enumerable:la in r?r[la]:i[la],writable:!1})}return ua(e,t,r)}:ua:function(e,t,r){if(Ut(e),t=In(t),Ut(r),nv)try{return ua(e,t,r)}catch{}if("get"in r||"set"in r)throw new ov("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var lv=he,hv=Te,vv=Si,At=lv?function(a,e,t){return hv.f(a,e,vv(1,t))}:function(a,e,t){return a[e]=t,a},Jo={exports:{}},Qa=he,fv=fe,eu=Function.prototype,cv=Qa&&Object.getOwnPropertyDescriptor,tu=fv(eu,"name"),gv=tu&&(function(){}).name==="something",dv=tu&&(!Qa||Qa&&cv(eu,"name").configurable),$r={PROPER:gv,CONFIGURABLE:dv},pv=L,yv=k,Ka=wi,mv=pv(Function.toString);yv(Ka.inspectSource)||(Ka.inspectSource=function(a){return mv(a)});var Ai=Ka.inspectSource,bv=_,xv=k,Mn=bv.WeakMap,Tv=xv(Mn)&&/native code/.test(String(Mn)),Ov=Ci,Sv=qo,_n=Ov("keys"),Pi=function(a){return _n[a]||(_n[a]=Sv(a))},Ri={},Ev=Tv,ru=_,$v=ae,wv=At,fa=fe,ca=wi,Cv=Pi,Av=Ri,Vn="Object already initialized",Za=ru.TypeError,Pv=ru.WeakMap,gr,Ot,dr,Rv=function(a){return dr(a)?Ot(a):gr(a,{})},Nv=function(a){return function(e){var t;if(!$v(e)||(t=Ot(e)).type!==a)throw new Za("Incompatible receiver, "+a+" required");return t}};if(Ev||ca.state){var de=ca.state||(ca.state=new Pv);de.get=de.get,de.has=de.has,de.set=de.set,gr=function(a,e){if(de.has(a))throw new Za(Vn);return e.facade=a,de.set(a,e),e},Ot=function(a){return de.get(a)||{}},dr=function(a){return de.has(a)}}else{var Ye=Cv("state");Av[Ye]=!0,gr=function(a,e){if(fa(a,Ye))throw new Za(Vn);return e.facade=a,wv(a,Ye,e),e},Ot=function(a){return fa(a,Ye)?a[Ye]:{}},dr=function(a){return fa(a,Ye)}}var wr={set:gr,get:Ot,has:dr,enforce:Rv,getterFor:Nv},Ni=L,Iv=D,Mv=k,Gt=fe,Ja=he,_v=$r.CONFIGURABLE,Vv=Ai,au=wr,Dv=au.enforce,Lv=au.get,Dn=String,or=Object.defineProperty,kv=Ni("".slice),Bv=Ni("".replace),jv=Ni([].join),Fv=Ja&&!Iv(function(){return or(function(){},"length",{value:8}).length!==8}),Uv=String(String).split("String"),Gv=Jo.exports=function(a,e,t){kv(Dn(e),0,7)==="Symbol("&&(e="["+Bv(Dn(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!Gt(a,"name")||_v&&a.name!==e)&&(Ja?or(a,"name",{value:e,configurable:!0}):a.name=e),Fv&&t&&Gt(t,"arity")&&a.length!==t.arity&&or(a,"length",{value:t.arity});try{t&&Gt(t,"constructor")&&t.constructor?Ja&&or(a,"prototype",{writable:!1}):a.prototype&&(a.prototype=void 0)}catch{}var r=Dv(a);return Gt(r,"source")||(r.source=jv(Uv,typeof e=="string"?e:"")),a};Function.prototype.toString=Gv(function(){return Mv(this)&&Lv(this).source||Vv(this)},"toString");var iu=Jo.exports,zv=k,Hv=Te,Yv=iu,Xv=$i,Ue=function(a,e,t,r){r||(r={});var i=r.enumerable,n=r.name!==void 0?r.name:e;if(zv(t)&&Yv(t,n,r),r.global)i?a[e]=t:Xv(e,t);else{try{r.unsafe?a[e]&&(i=!0):delete a[e]}catch{}i?a[e]=t:Hv.f(a,e,{value:t,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return a},nu={},Wv=Math.ceil,qv=Math.floor,Qv=Math.trunc||function(e){var t=+e;return(t>0?qv:Wv)(t)},Kv=Qv,Cr=function(a){var e=+a;return e!==e||e===0?0:Kv(e)},Zv=Cr,Jv=Math.max,ef=Math.min,tf=function(a,e){var t=Zv(a);return t<0?Jv(t+e,0):ef(t,e)},rf=Cr,af=Math.min,ut=function(a){var e=rf(a);return e>0?af(e,9007199254740991):0},nf=ut,Ii=function(a){return nf(a.length)},sf=wt,of=tf,uf=Ii,lf=function(a){return function(e,t,r){var i=sf(e),n=uf(i);if(n===0)return!a&&-1;var o=of(r,n),s;if(a&&t!==t){for(;n>o;)if(s=i[o++],s!==s)return!0}else for(;n>o;o++)if((a||o in i)&&i[o]===t)return a||o||0;return!a&&-1}},su={indexOf:lf(!1)},hf=L,ga=fe,vf=wt,ff=su.indexOf,cf=Ri,Ln=hf([].push),ou=function(a,e){var t=vf(a),r=0,i=[],n;for(n in t)!ga(cf,n)&&ga(t,n)&&Ln(i,n);for(;e.length>r;)ga(t,n=e[r++])&&(~ff(i,n)||Ln(i,n));return i},Mi=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],gf=ou,df=Mi,pf=df.concat("length","prototype");nu.f=Object.getOwnPropertyNames||function(e){return gf(e,pf)};var uu={};uu.f=Object.getOwnPropertySymbols;var yf=Fe,mf=L,bf=nu,xf=uu,Tf=J,Of=mf([].concat),Sf=yf("Reflect","ownKeys")||function(e){var t=bf.f(Tf(e)),r=xf.f;return r?Of(t,r(e)):t},kn=fe,Ef=Sf,$f=$t,wf=Te,Cf=function(a,e,t){for(var r=Ef(e),i=wf.f,n=$f.f,o=0;of;f++)if(v=y(a[f]),v&&ms(xs,v))return v;return new hr(!1)}l=wd(a,h)}for(g=n?a.next:l.next;!(d=Td(g,l)).done;){var T=d.value;try{v=y(T)}catch(b){if(l)bs(l,"throw",b);else throw b}if(typeof v=="object"&&v&&ms(xs,v))return v}return new hr(!1)},Pd=z,Gu=Pd("iterator"),zu=!1;try{var Rd=0,Ts={next:function(){return{done:!!Rd++}},return:function(){zu=!0}};Ts[Gu]=function(){return this},Array.from(Ts,function(){throw 2})}catch{}var Nd=function(a,e){try{if(!e&&!zu)return!1}catch{return!1}var t=!1;try{var r={};r[Gu]=function(){return{next:function(){return{done:t=!0}}}},a(r)}catch{}return t},Id=Nr,Md=Nd,_d=Rt.CONSTRUCTOR,Hu=_d||!Md(function(a){Id.all(a).then(void 0,function(){})}),Vd=ee,Dd=Y,Ld=Ae,kd=lt,Bd=Li,jd=Uu,Fd=Hu;Vd({target:"Promise",stat:!0,forced:Fd},{all:function(e){var t=this,r=kd.f(t),i=r.resolve,n=r.reject,o=Bd(function(){var s=Ld(t.resolve),u=[],l=0,h=1;jd(e,function(f){var c=l++,v=!1;h++,Dd(s,t,f).then(function(g){v||(v=!0,u[c]=g,--h||i(u))},n)}),--h||i(u)});return o.error&&n(o.value),r.promise}});var Ud=ee,Gd=Rt.CONSTRUCTOR,si=Nr,zd=Fe,Hd=k,Yd=Ue,Os=si&&si.prototype;Ud({target:"Promise",proto:!0,forced:Gd,real:!0},{catch:function(a){return this.then(void 0,a)}});if(Hd(si)){var Ss=zd("Promise").prototype.catch;Os.catch!==Ss&&Yd(Os,"catch",Ss,{unsafe:!0})}var Xd=ee,Wd=Y,qd=Ae,Qd=lt,Kd=Li,Zd=Uu,Jd=Hu;Xd({target:"Promise",stat:!0,forced:Jd},{race:function(e){var t=this,r=Qd.f(t),i=r.reject,n=Kd(function(){var o=qd(t.resolve);Zd(e,function(s){Wd(o,t,s).then(r.resolve,i)})});return n.error&&i(n.value),r.promise}});var ep=ee,tp=lt,rp=Rt.CONSTRUCTOR;ep({target:"Promise",stat:!0,forced:rp},{reject:function(e){var t=tp.f(this),r=t.reject;return r(e),t.promise}});var ap=J,ip=ae,np=lt,sp=function(a,e){if(ap(a),ip(e)&&e.constructor===a)return e;var t=np.f(a),r=t.resolve;return r(e),t.promise},op=ee,up=Fe,lp=Rt.CONSTRUCTOR,hp=sp;up("Promise");op({target:"Promise",stat:!0,forced:lp},{resolve:function(e){return hp(this,e)}});function Es(a,e,t,r,i,n,o){try{var s=a[n](o),u=s.value}catch(l){return void t(l)}s.done?e(u):Promise.resolve(u).then(r,i)}function xe(a){return function(){var e=this,t=arguments;return new Promise(function(r,i){var n=a.apply(e,t);function o(u){Es(n,r,i,o,s,"next",u)}function s(u){Es(n,r,i,o,s,"throw",u)}o(void 0)})}}var vp=cu,fp=String,pe=function(a){if(vp(a)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return fp(a)},cp=J,Yu=function(){var a=cp(this),e="";return a.hasIndices&&(e+="d"),a.global&&(e+="g"),a.ignoreCase&&(e+="i"),a.multiline&&(e+="m"),a.dotAll&&(e+="s"),a.unicode&&(e+="u"),a.unicodeSets&&(e+="v"),a.sticky&&(e+="y"),e},Ui=D,gp=_,Gi=gp.RegExp,zi=Ui(function(){var a=Gi("a","y");return a.lastIndex=2,a.exec("abcd")!==null});zi||Ui(function(){return!Gi("a","y").sticky});var dp=zi||Ui(function(){var a=Gi("^r","gy");return a.lastIndex=2,a.exec("str")!==null}),Xu={BROKEN_CARET:dp,UNSUPPORTED_Y:zi},Wu={},pp=ou,yp=Mi,mp=Object.keys||function(e){return pp(e,yp)},bp=he,xp=Zo,Tp=Te,Op=J,Sp=wt,Ep=mp;Wu.f=bp&&!xp?Object.defineProperties:function(e,t){Op(e);for(var r=Sp(t),i=Ep(t),n=i.length,o=0,s;n>o;)Tp.f(e,s=i[o++],r[s]);return e};var $p=J,wp=Wu,$s=Mi,Cp=Ri,Ap=Tu,Pp=Er,Rp=Pi,ws=">",Cs="<",oi="prototype",ui="script",qu=Rp("IE_PROTO"),wa=function(){},Qu=function(a){return Cs+ui+ws+a+Cs+"/"+ui+ws},As=function(a){a.write(Qu("")),a.close();var e=a.parentWindow.Object;return a=null,e},Np=function(){var a=Pp("iframe"),e="java"+ui+":",t;return a.style.display="none",Ap.appendChild(a),a.src=String(e),t=a.contentWindow.document,t.open(),t.write(Qu("document.F=Object")),t.close(),t.F},Zt,vr=function(){try{Zt=new ActiveXObject("htmlfile")}catch{}vr=typeof document<"u"?document.domain&&Zt?As(Zt):Np():As(Zt);for(var a=$s.length;a--;)delete vr[oi][$s[a]];return vr()};Cp[qu]=!0;var Hi=Object.create||function(e,t){var r;return e!==null?(wa[oi]=$p(e),r=new wa,wa[oi]=null,r[qu]=e):r=vr(),t===void 0?r:wp.f(r,t)},Ip=D,Mp=_,_p=Mp.RegExp,Vp=Ip(function(){var a=_p(".","s");return!(a.dotAll&&a.test(`
`)&&a.flags==="s")}),Dp=D,Lp=_,kp=Lp.RegExp,Bp=Dp(function(){var a=kp("(?b)","g");return a.exec("b").groups.a!=="b"||"b".replace(a,"$c")!=="bc"}),et=Y,_r=L,jp=pe,Fp=Yu,Up=Xu,Gp=Ci,zp=Hi,Hp=wr.get,Yp=Vp,Xp=Bp,Wp=Gp("native-string-replace",String.prototype.replace),mr=RegExp.prototype.exec,li=mr,qp=_r("".charAt),Qp=_r("".indexOf),Kp=_r("".replace),Ps=_r("".slice),hi=function(){var a=/a/,e=/b*/g;return et(mr,a,"a"),et(mr,e,"a"),a.lastIndex!==0||e.lastIndex!==0}(),Ku=Up.BROKEN_CARET,vi=/()??/.exec("")[1]!==void 0,Zp=hi||vi||Ku||Yp||Xp,Rs=function(a,e){for(var t=a.groups=zp(null),r=0;r0&&qp(i,t.lastIndex-1);t.lastIndex>0&&(!t.multiline||t.multiline&&d!==`
`&&d!=="\r"&&d!=="\u2028"&&d!=="\u2029")&&(c="(?: (?:"+c+"))",g=" "+g,v++),s=new RegExp("^(?:"+c+")",f)}vi&&(s=new RegExp("^"+c+"$(?!\\s)",f)),hi&&(u=t.lastIndex);var p=et(mr,h?s:t,g);return h?p?(p.input=i,p[0]=Ps(p[0],v),p.index=t.lastIndex,t.lastIndex+=p[0].length):t.lastIndex=0:hi&&p&&(t.lastIndex=t.global?p.index+p[0].length:u),vi&&p&&p.length>1&&et(Wp,p[0],s,function(){for(var y=1;y=n?a?"":void 0:(o=Vs(r,i),o<55296||o>56319||i+1===n||(s=Vs(r,i+1))<56320||s>57343?a?sy(r,i):o:a?oy(r,i,i+2):(o-55296<<10)+(s-56320)+65536)}},ly={charAt:uy(!0)},hy=ly.charAt,qi=function(a,e,t){return e+(t&&hy(a,e).length||1)},vy=_,fy=D,Ds=vy.RegExp,cy=!fy(function(){var a=!0;try{Ds(".","d")}catch{a=!1}var e={},t="",r=a?"dgimsy":"gimsy",i=function(u,l){Object.defineProperty(e,u,{get:function(){return t+=l,!0}})},n={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};a&&(n.hasIndices="d");for(var o in n)i(o,n[o]);var s=Object.getOwnPropertyDescriptor(Ds.prototype,"flags").get.call(e);return s!==r||t!==r}),gy={correct:cy},dy=Y,py=fe,yy=Tr,Ls=gy,my=Yu,by=RegExp.prototype,Vr=Ls.correct?function(a){return a.flags}:function(a){return!Ls.correct&&yy(by,a)&&!py(a,"flags")?dy(my,a):a.flags},ks=Y,xy=J,Ty=k,Oy=Ce,Sy=Yi,Ey=TypeError,Qi=function(a,e){var t=a.exec;if(Ty(t)){var r=ks(t,a,e);return r!==null&&xy(r),r}if(Oy(a)==="RegExp")return ks(Sy,a,e);throw new Ey("RegExp#exec called on incompatible receiver")},$y=Y,wy=L,Cy=Xi,Ay=J,Py=ae,Ry=ut,Jt=pe,Ny=ve,Iy=ot,My=qi,_y=Vr,Bs=Qi,Aa=wy("".indexOf);Cy("match",function(a,e,t){return[function(i){var n=Ny(this),o=Py(i)?Iy(i,a):void 0;if(o)return $y(o,i,n);var s=Jt(n);return new RegExp(i)[a](s)},function(r){var i=Ay(this),n=Jt(r),o=t(e,i,n);if(o.done)return o.value;var s=Jt(_y(i));if(!~Aa(s,"g"))return Bs(i,n);var u=!!~Aa(s,"u")||!!~Aa(s,"v");i.lastIndex=0;for(var l=[],h=0,f;(f=Bs(i,n))!==null;){var c=Jt(f[0]);l[h]=c,c===""&&(i.lastIndex=My(n,Ry(i.lastIndex),u)),h++}return h===0?null:l}]});var Ki=L,Vy=Sr,Dy=Math.floor,Pa=Ki("".charAt),Ly=Ki("".replace),Ra=Ki("".slice),ky=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,By=/\$([$&'`]|\d{1,2})/g,jy=function(a,e,t,r,i,n){var o=t+a.length,s=r.length,u=By;return i!==void 0&&(i=Vy(i),u=ky),Ly(n,u,function(l,h){var f;switch(Pa(h,0)){case"$":return"$";case"&":return a;case"`":return Ra(e,0,t);case"'":return Ra(e,o);case"<":f=i[Ra(h,1,-1)];break;default:var c=+h;if(c===0)return l;if(c>s){var v=Dy(c/10);return v===0?l:v<=s?r[v-1]===void 0?Pa(h,1):r[v-1]+Pa(h,1):l}f=r[c-1]}return f===void 0?"":f})},Fy=xu,js=Y,Dr=L,Uy=Xi,Gy=D,zy=J,Hy=k,Yy=ae,Xy=Cr,Wy=ut,_e=pe,qy=ve,Qy=qi,Ky=ot,Zy=jy,Jy=Vr,em=Qi,tm=z,fi=tm("replace"),rm=Math.max,am=Math.min,im=Dr([].concat),Na=Dr([].push),We=Dr("".indexOf),Fs=Dr("".slice),nm=function(a){return a===void 0?a:String(a)},sm=function(){return"a".replace(/./,"$0")==="$0"}(),Us=function(){return/./[fi]?/./[fi]("a","$0")==="":!1}(),om=!Gy(function(){var a=/./;return a.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(a,"$")!=="7"});Uy("replace",function(a,e,t){var r=Us?"$":"$0";return[function(n,o){var s=qy(this),u=Yy(n)?Ky(n,fi):void 0;return u?js(u,n,s,o):js(e,_e(s),n,o)},function(i,n){var o=zy(this),s=_e(i),u=Hy(n);u||(n=_e(n));var l=_e(Jy(o));if(typeof n=="string"&&!~We(n,r)&&!~We(n,"$<")&&!~We(l,"y")){var h=t(e,o,s,n);if(h.done)return h.value}var f=!!~We(l,"g"),c;f&&(c=!!~We(l,"u")||!!~We(l,"v"),o.lastIndex=0);for(var v=[],g;g=em(o,s),!(g===null||(Na(v,g),!f));){var d=_e(g[0]);d===""&&(o.lastIndex=Qy(s,Wy(o.lastIndex),c))}for(var p="",y=0,T=0;T=y&&(p+=Fs(s,y,x)+E,y=x+b.length)}return p+Fs(s,y)}]},!om||!sm||Us);var um=ae,lm=Ce,hm=z,vm=hm("match"),fm=function(a){var e;return um(a)&&((e=a[vm])!==void 0?!!e:lm(a)==="RegExp")},cm=fm,gm=TypeError,Zi=function(a){if(cm(a))throw new gm("The method doesn't accept regular expressions");return a},dm=z,pm=dm("match"),Ji=function(a){var e=/./;try{"/./"[a](e)}catch{try{return e[pm]=!1,"/./"[a](e)}catch{}}return!1},ym=ee,mm=Rr,bm=$t.f,xm=ut,Gs=pe,Tm=Zi,Om=ve,Sm=Ji,Em=mm("".slice),$m=Math.min,Ju=Sm("startsWith"),wm=!Ju&&!!function(){var a=bm(String.prototype,"startsWith");return a&&!a.writable}();ym({target:"String",proto:!0,forced:!wm&&!Ju},{startsWith:function(e){var t=Gs(Om(this));Tm(e);var r=Gs(e),i=xm($m(arguments.length>1?arguments[1]:void 0,t.length));return Em(t,i,i+r.length)===r}});var Cm=z,Am=Hi,Pm=Te.f,ci=Cm("unscopables"),gi=Array.prototype;gi[ci]===void 0&&Pm(gi,ci,{configurable:!0,value:Am(null)});var Rm=function(a){gi[ci][a]=!0},Nm=D,Im=!Nm(function(){function a(){}return a.prototype.constructor=null,Object.getPrototypeOf(new a)!==a.prototype}),Mm=fe,_m=k,Vm=Sr,Dm=Pi,Lm=Im,zs=Dm("IE_PROTO"),di=Object,km=di.prototype,el=Lm?di.getPrototypeOf:function(a){var e=Vm(a);if(Mm(e,zs))return e[zs];var t=e.constructor;return _m(t)&&e instanceof t?t.prototype:e instanceof di?km:null},Bm=D,jm=k,Fm=ae,Hs=el,Um=Ue,Gm=z,pi=Gm("iterator"),tl=!1,Be,Ia,Ma;[].keys&&(Ma=[].keys(),"next"in Ma?(Ia=Hs(Hs(Ma)),Ia!==Object.prototype&&(Be=Ia)):tl=!0);var zm=!Fm(Be)||Bm(function(){var a={};return Be[pi].call(a)!==a});zm&&(Be={});jm(Be[pi])||Um(Be,pi,function(){return this});var rl={IteratorPrototype:Be,BUGGY_SAFARI_ITERATORS:tl},Hm=rl.IteratorPrototype,Ym=Hi,Xm=Si,Wm=Pr,qm=Mr,Qm=function(){return this},Km=function(a,e,t,r){var i=e+" Iterator";return a.prototype=Ym(Hm,{next:Xm(+!r,t)}),Wm(a,i,!1),qm[i]=Qm,a},Zm=ee,Jm=Y,al=$r,e0=k,t0=Km,Ys=el,Xs=vu,r0=Pr,a0=At,_a=Ue,i0=z,n0=Mr,il=rl,s0=al.PROPER,o0=al.CONFIGURABLE,Ws=il.IteratorPrototype,er=il.BUGGY_SAFARI_ITERATORS,gt=i0("iterator"),qs="keys",dt="values",Qs="entries",u0=function(){return this},l0=function(a,e,t,r,i,n,o){t0(t,e,r);var s=function(y){if(y===i&&c)return c;if(!er&&y&&y in h)return h[y];switch(y){case qs:return function(){return new t(this,y)};case dt:return function(){return new t(this,y)};case Qs:return function(){return new t(this,y)}}return function(){return new t(this)}},u=e+" Iterator",l=!1,h=a.prototype,f=h[gt]||h["@@iterator"]||i&&h[i],c=!er&&f||s(i),v=e==="Array"&&h.entries||f,g,d,p;if(v&&(g=Ys(v.call(new a)),g!==Object.prototype&&g.next&&(Ys(g)!==Ws&&(Xs?Xs(g,Ws):e0(g[gt])||_a(g,gt,u0)),r0(g,u,!0))),s0&&i===dt&&f&&f.name!==dt&&(o0?a0(h,"name",dt):(l=!0,c=function(){return Jm(f,this)})),i)if(d={values:s(dt),keys:n?c:s(qs),entries:s(Qs)},o)for(p in d)(er||l||!(p in h))&&_a(h,p,d[p]);else Zm({target:e,proto:!0,forced:er||l},d);return h[gt]!==c&&_a(h,gt,c,{name:i}),n0[e]=c,d},h0=function(a,e){return{value:a,done:e}},v0=wt,en=Rm,Ks=Mr,nl=wr,f0=Te.f,c0=l0,tr=h0,g0=he,sl="Array Iterator",d0=nl.set,p0=nl.getterFor(sl),y0=c0(Array,"Array",function(a,e){d0(this,{type:sl,target:v0(a),index:0,kind:e})},function(){var a=p0(this),e=a.target,t=a.index++;if(!e||t>=e.length)return a.target=null,tr(void 0,!0);switch(a.kind){case"keys":return tr(t,!1);case"values":return tr(e[t],!1)}return tr([t,e[t]],!1)},"values"),Zs=Ks.Arguments=Ks.Array;en("keys");en("values");en("entries");if(g0&&Zs.name!=="values")try{f0(Zs,"name",{value:"values"})}catch{}var m0={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},b0=Er,Va=b0("span").classList,Js=Va&&Va.constructor&&Va.constructor.prototype,x0=Js===Object.prototype?void 0:Js,eo=_,ol=m0,T0=x0,yt=y0,to=At,O0=Pr,S0=z,Da=S0("iterator"),La=yt.values,ul=function(a,e){if(a){if(a[Da]!==La)try{to(a,Da,La)}catch{a[Da]=La}if(O0(a,e,!0),ol[e]){for(var t in yt)if(a[t]!==yt[t])try{to(a,t,yt[t])}catch{a[t]=yt[t]}}}};for(var ka in ol)ul(eo[ka]&&eo[ka].prototype,ka);ul(T0,"DOMTokenList");function E0(a,e){if(Xa(a)!="object"||!a)return a;var t=a[Symbol.toPrimitive];if(t!==void 0){var r=t.call(a,e);if(Xa(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(a)}function $0(a){var e=E0(a,"string");return Xa(e)=="symbol"?e:e+""}function tn(a,e,t){return(e=$0(e))in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}var w0=Ae,C0=Sr,A0=Go,P0=Ii,ro=TypeError,ao="Reduce of empty array with no initial value",R0=function(a){return function(e,t,r,i){var n=C0(e),o=A0(n),s=P0(n);if(w0(t),s===0&&r<2)throw new ro(ao);var u=a?s-1:0,l=a?-1:1;if(r<2)for(;;){if(u in o){i=o[u],u+=l;break}if(u+=l,a?u<0:s<=u)throw new ro(ao)}for(;a?u>=0:s>u;u+=l)u in o&&(i=t(i,o[u],u,n));return i}},N0={left:R0(!1)},I0=D,ll=function(a,e){var t=[][a];return!!t&&I0(function(){t.call(null,e||function(){return 1},1)})},M0=ee,_0=N0.left,V0=ll,io=Ei,D0=Ar,L0=!D0&&io>79&&io<83,k0=L0||!V0("reduce");M0({target:"Array",proto:!0,forced:k0},{reduce:function(e){var t=arguments.length;return _0(this,e,t,t>1?arguments[1]:void 0)}});var B0=ee,j0=Rr,F0=$t.f,U0=ut,no=pe,G0=Zi,z0=ve,H0=Ji,Y0=j0("".slice),X0=Math.min,hl=H0("endsWith"),W0=!hl&&!!function(){var a=F0(String.prototype,"endsWith");return a&&!a.writable}();B0({target:"String",proto:!0,forced:!W0&&!hl},{endsWith:function(e){var t=no(z0(this));G0(e);var r=no(e),i=arguments.length>1?arguments[1]:void 0,n=t.length,o=i===void 0?n:X0(U0(i),n);return Y0(t,o-r.length,o)===r}});var Ba=Y,rn=L,q0=Xi,Q0=J,K0=ae,Z0=ve,J0=mu,eb=qi,tb=ut,ja=pe,rb=ot,ab=Vr,so=Qi,ib=Xu,nb=D,qe=ib.UNSUPPORTED_Y,sb=4294967295,ob=Math.min,Fa=rn([].push),Ua=rn("".slice),rr=rn("".indexOf),ub=!nb(function(){var a=/(?:)/,e=a.exec;a.exec=function(){return e.apply(this,arguments)};var t="ab".split(a);return t.length!==2||t[0]!=="a"||t[1]!=="b"}),oo="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;q0("split",function(a,e,t){var r="0".split(void 0,0).length?function(i,n){return i===void 0&&n===0?[]:Ba(e,this,i,n)}:e;return[function(n,o){var s=Z0(this),u=K0(n)?rb(n,a):void 0;return u?Ba(u,n,s,o):Ba(r,ja(s),n,o)},function(i,n){var o=Q0(this),s=ja(i);if(!oo){var u=t(r,o,s,n,r!==e);if(u.done)return u.value}var l=J0(o,RegExp),h=ja(ab(o)),f=!!~rr(h,"u")||!!~rr(h,"v");qe?~rr(h,"g")||(h+="g"):~rr(h,"y")||(h+="y");var c=new l(qe?"^(?:"+o.source+")":o,h),v=n===void 0?sb:n>>>0;if(v===0)return[];if(s.length===0)return so(c,s)===null?[s]:[];for(var g=0,d=0,p=[];d"u"?Ke:window,ar=["moz","webkit"],rt="AnimationFrame",st=be["request"+rt],Et=be["cancel"+rt]||be["cancelRequest"+rt];for(var pt=0;!st&&pt3&&(this.alpha=s[3]),this.ok=!0}}this.r=this.r<0||isNaN(this.r)?0:this.r>255?255:this.r,this.g=this.g<0||isNaN(this.g)?0:this.g>255?255:this.g,this.b=this.b<0||isNaN(this.b)?0:this.b>255?255:this.b,this.alpha=this.alpha<0?0:this.alpha>1||isNaN(this.alpha)?1:this.alpha,this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"},this.toRGBA=function(){return"rgba("+this.r+", "+this.g+", "+this.b+", "+this.alpha+")"},this.toHex=function(){var u=this.r.toString(16),l=this.g.toString(16),h=this.b.toString(16);return u.length==1&&(u="0"+u),l.length==1&&(l="0"+l),h.length==1&&(h="0"+h),"#"+u+l+h},this.getHelpXML=function(){for(var u=new Array,l=0;l "+d.toRGB()+" -> "+d.toHex());g.appendChild(p),g.appendChild(y),v.appendChild(g)}catch{}return v}};const mi=Do(wb);var Cb=ee,Ab=Rr,Pb=su.indexOf,Rb=ll,bi=Ab([].indexOf),fl=!!bi&&1/bi([1],1,-0)<0,Nb=fl||!Rb("indexOf");Cb({target:"Array",proto:!0,forced:Nb},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return fl?bi(this,e,t)||0:Pb(this,e,t)}});var Ib=ee,Mb=L,_b=Zi,Vb=ve,fo=pe,Db=Ji,Lb=Mb("".indexOf);Ib({target:"String",proto:!0,forced:!Db("includes")},{includes:function(e){return!!~Lb(fo(Vb(this)),fo(_b(e)),arguments.length>1?arguments[1]:void 0)}});var kb=Ce,Bb=Array.isArray||function(e){return kb(e)==="Array"},jb=ee,Fb=L,Ub=Bb,Gb=Fb([].reverse),co=[1,2];jb({target:"Array",proto:!0,forced:String(co)===String(co.reverse())},{reverse:function(){return Ub(this)&&(this.length=this.length),Gb(this)}});/*! *****************************************************************************
diff --git a/veadk/webui/assets/chunks/jspdf.es.min-DdJSjEtu.js b/veadk/webui/assets/chunks/jspdf.es.min-CKI8Ibko.js
similarity index 99%
rename from veadk/webui/assets/chunks/jspdf.es.min-DdJSjEtu.js
rename to veadk/webui/assets/chunks/jspdf.es.min-CKI8Ibko.js
index 5a6a4ebc3..6f912a959 100644
--- a/veadk/webui/assets/chunks/jspdf.es.min-DdJSjEtu.js
+++ b/veadk/webui/assets/chunks/jspdf.es.min-CKI8Ibko.js
@@ -1,5 +1,5 @@
-const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/index.es-CE6umRqJ.js","assets/app/index-Ch6a-P8E.js","assets/styles/index-VvaO_aPK.css"])))=>i.map(i=>d[i]);
-var kh=Object.defineProperty;var Ph=(r,e,t)=>e in r?kh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _e=(r,e,t)=>Ph(r,typeof e!="symbol"?e+"":e,t);import{_ as go}from"../app/index-Ch6a-P8E.js";function Ae(r){"@babel/helpers - typeof";return Ae=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ae(r)}var Qr=Uint8Array,Or=Uint16Array,Jo=Int32Array,Ko=new Qr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Xo=new Qr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ml=new Qr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zu=function(r,e){for(var t=new Or(31),i=0;i<31;++i)t[i]=e+=1<>1|(Fe&21845)<<1;Qn=(Qn&52428)>>2|(Qn&13107)<<2,Qn=(Qn&61680)>>4|(Qn&3855)<<4,To[Fe]=((Qn&65280)>>8|(Qn&255)<<8)>>1}var Ia=function(r,e,t){for(var i=r.length,s=0,a=new Or(e);s>h]=d}else for(l=new Or(i),s=0;s>15-r[s]);return l},Ii=new Qr(288);for(var Fe=0;Fe<144;++Fe)Ii[Fe]=8;for(var Fe=144;Fe<256;++Fe)Ii[Fe]=9;for(var Fe=256;Fe<280;++Fe)Ii[Fe]=7;for(var Fe=280;Fe<288;++Fe)Ii[Fe]=8;var Fs=new Qr(32);for(var Fe=0;Fe<32;++Fe)Fs[Fe]=5;var Fh=Ia(Ii,9,0),Eh=Ia(Fs,5,0),tf=function(r){return(r+7)/8|0},Oh=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new Qr(r.subarray(e,t))},Bn=function(r,e,t){t<<=e&7;var i=e/8|0;r[i]|=t,r[i+1]|=t>>8},ka=function(r,e,t){t<<=e&7;var i=e/8|0;r[i]|=t,r[i+1]|=t>>8,r[i+2]|=t>>16},mo=function(r,e){for(var t=[],i=0;ik&&(k=a[i].s);var p=new Or(k+1),j=Do(t[m-1],p,0);if(j>e){var i=0,O=0,M=j-e,S=1<e)O+=S-(1<>=M;O>0;){var G=a[i].s;p[G]=0&&O;--i){var D=a[i].s;p[D]==e&&(--p[D],++O)}j=e}return{t:new Qr(p),l:j}},Do=function(r,e,t){return r.s==-1?Math.max(Do(r.l,e,t+1),Do(r.r,e,t+1)):e[r.s]=t},Tl=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new Or(++e),i=0,s=r[0],a=1,c=function(h){t[i++]=h},l=1;l<=e;++l)if(r[l]==s&&l!=e)++a;else{if(!s&&a>2){for(;a>138;a-=138)c(32754);a>2&&(c(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(c(s),--a;a>6;a-=6)c(8304);a>2&&(c(a-3<<5|8208),a=0)}for(;a--;)c(s);a=1,s=r[l]}return{c:t.subarray(0,i),n:e}},Pa=function(r,e){for(var t=0,i=0;i>8,r[s+2]=r[s]^255,r[s+3]=r[s+1]^255;for(var a=0;a4&&!tt[Ml[F-1]];--F);var z=d+5<<3,U=Pa(s,Ii)+Pa(a,Fs)+c,nt=Pa(s,k)+Pa(a,O)+c+14+3*F+Pa(ct,tt)+2*ct[16]+3*ct[17]+7*ct[18];if(h>=0&&z<=U&&z<=nt)return ef(e,m,r.subarray(h,h+d));var ot,ut,rt,ht;if(Bn(e,m,1+(nt15&&(Bn(e,m,B[K]>>5&127),m+=B[K]>>12)}}else ot=Fh,ut=Ii,rt=Eh,ht=Fs;for(var K=0;K255){var T=H>>18&31;ka(e,m,ot[T+257]),m+=ut[T+257],T>7&&(Bn(e,m,H>>23&31),m+=Ko[T]);var J=H&31;ka(e,m,rt[J]),m+=ht[J],J>3&&(ka(e,m,H>>5&8191),m+=Xo[J])}else ka(e,m,ot[H]),m+=ut[H]}return ka(e,m,ot[256]),m+ut[256]},jh=new Jo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),rf=new Qr(0),Bh=function(r,e,t,i,s,a){var c=a.z||r.length,l=new Qr(i+c+5*(1+Math.ceil(c/7e3))+s),h=l.subarray(i,l.length-s),d=a.l,m=(a.r||0)&7;if(e){m&&(h[0]=a.r>>3);for(var _=jh[e-1],k=_>>13,p=_&8191,j=(1<7e3||tt>24576)&&(ot>423||!d)){m=Dl(r,h,0,D,it,mt,K,tt,F,R-F,m),tt=ct=K=0,F=R;for(var ut=0;ut<286;++ut)it[ut]=0;for(var ut=0;ut<30;++ut)mt[ut]=0}var rt=2,ht=0,At=p,wt=U-nt&32767;if(ot>2&&z==G(R-wt))for(var x=Math.min(k,ot)-1,B=Math.min(32767,R),T=Math.min(258,ot);wt<=B&&--At&&U!=nt;){if(r[R+rt]==r[R+rt-wt]){for(var H=0;Hrt){if(rt=H,ht=wt,H>x)break;for(var J=Math.min(wt,H-2),Z=0,ut=0;utZ&&(Z=gt,nt=at)}}}U=nt,nt=O[U],wt+=U-nt&32767}if(ht){D[tt++]=268435456|Ro[rt]<<18|Rl[ht];var _t=Ro[rt]&31,kt=Rl[ht]&31;K+=Ko[_t]+Xo[kt],++it[257+_t],++mt[kt],N=R+rt,++ct}else D[tt++]=r[R],++it[r[R]]}}for(R=Math.max(R,N);R=c&&(h[m/8|0]=d,St=c),m=ef(h,m+1,r.subarray(R,St))}a.i=c}return Oh(l,0,i+tf(m)+s)},nf=function(){var r=1,e=0;return{p:function(t){for(var i=r,s=e,a=t.length|0,c=0;c!=a;){for(var l=Math.min(c+2655,a);c>16),s=(s&65535)+15*(s>>16)}r=i,e=s},d:function(){return r%=65521,e%=65521,(r&255)<<24|(r&65280)<<8|(e&255)<<8|e>>8}}},Mh=function(r,e,t,i,s){if(!s&&(s={l:1},e.dictionary)){var a=e.dictionary.subarray(-32768),c=new Qr(a.length+r.length);c.set(a),c.set(r,a.length),r=c,s.w=a.length}return Bh(r,e.level==null?6:e.level,e.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+e.mem,t,i,s)},af=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},Rh=function(r,e){var t=e.level,i=t==0?0:t<6?1:t==9?3:2;if(r[0]=120,r[1]=i<<6|(e.dictionary&&32),r[1]|=31-(r[0]<<8|r[1])%31,e.dictionary){var s=nf();s.p(e.dictionary),af(r,2,s.d())}};function qo(r,e){e||(e={});var t=nf();t.p(r);var i=Mh(r,e,e.dictionary?6:2,4);return Rh(i,e),af(i,i.length-4,t.d()),i}var Th=typeof TextDecoder<"u"&&new TextDecoder,Dh=0;try{Th.decode(rf,{stream:!0}),Dh=1}catch{}function qh(r){if(Array.isArray(r))return r}function Uh(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var i,s,a,c,l=[],h=!0,d=!1;try{if(a=(t=t.call(r)).next,e!==0)for(;!(h=(i=a.call(t)).done)&&(l.push(i.value),l.length!==e);h=!0);}catch(m){d=!0,s=m}finally{try{if(!h&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(d)throw s}}return l}}function ql(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=Array(e);ti.map(i=>d[i]);
+var kh=Object.defineProperty;var Ph=(r,e,t)=>e in r?kh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _e=(r,e,t)=>Ph(r,typeof e!="symbol"?e+"":e,t);import{_ as go}from"../app/index-z3uMxcpH.js";function Ae(r){"@babel/helpers - typeof";return Ae=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ae(r)}var Qr=Uint8Array,Or=Uint16Array,Jo=Int32Array,Ko=new Qr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Xo=new Qr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ml=new Qr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zu=function(r,e){for(var t=new Or(31),i=0;i<31;++i)t[i]=e+=1<>1|(Fe&21845)<<1;Qn=(Qn&52428)>>2|(Qn&13107)<<2,Qn=(Qn&61680)>>4|(Qn&3855)<<4,To[Fe]=((Qn&65280)>>8|(Qn&255)<<8)>>1}var Ia=function(r,e,t){for(var i=r.length,s=0,a=new Or(e);s>h]=d}else for(l=new Or(i),s=0;s>15-r[s]);return l},Ii=new Qr(288);for(var Fe=0;Fe<144;++Fe)Ii[Fe]=8;for(var Fe=144;Fe<256;++Fe)Ii[Fe]=9;for(var Fe=256;Fe<280;++Fe)Ii[Fe]=7;for(var Fe=280;Fe<288;++Fe)Ii[Fe]=8;var Fs=new Qr(32);for(var Fe=0;Fe<32;++Fe)Fs[Fe]=5;var Fh=Ia(Ii,9,0),Eh=Ia(Fs,5,0),tf=function(r){return(r+7)/8|0},Oh=function(r,e,t){return(t==null||t>r.length)&&(t=r.length),new Qr(r.subarray(e,t))},Bn=function(r,e,t){t<<=e&7;var i=e/8|0;r[i]|=t,r[i+1]|=t>>8},ka=function(r,e,t){t<<=e&7;var i=e/8|0;r[i]|=t,r[i+1]|=t>>8,r[i+2]|=t>>16},mo=function(r,e){for(var t=[],i=0;ik&&(k=a[i].s);var p=new Or(k+1),j=Do(t[m-1],p,0);if(j>e){var i=0,O=0,M=j-e,S=1<e)O+=S-(1<>=M;O>0;){var G=a[i].s;p[G]=0&&O;--i){var D=a[i].s;p[D]==e&&(--p[D],++O)}j=e}return{t:new Qr(p),l:j}},Do=function(r,e,t){return r.s==-1?Math.max(Do(r.l,e,t+1),Do(r.r,e,t+1)):e[r.s]=t},Tl=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new Or(++e),i=0,s=r[0],a=1,c=function(h){t[i++]=h},l=1;l<=e;++l)if(r[l]==s&&l!=e)++a;else{if(!s&&a>2){for(;a>138;a-=138)c(32754);a>2&&(c(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(c(s),--a;a>6;a-=6)c(8304);a>2&&(c(a-3<<5|8208),a=0)}for(;a--;)c(s);a=1,s=r[l]}return{c:t.subarray(0,i),n:e}},Pa=function(r,e){for(var t=0,i=0;i>8,r[s+2]=r[s]^255,r[s+3]=r[s+1]^255;for(var a=0;a4&&!tt[Ml[F-1]];--F);var z=d+5<<3,U=Pa(s,Ii)+Pa(a,Fs)+c,nt=Pa(s,k)+Pa(a,O)+c+14+3*F+Pa(ct,tt)+2*ct[16]+3*ct[17]+7*ct[18];if(h>=0&&z<=U&&z<=nt)return ef(e,m,r.subarray(h,h+d));var ot,ut,rt,ht;if(Bn(e,m,1+(nt15&&(Bn(e,m,B[K]>>5&127),m+=B[K]>>12)}}else ot=Fh,ut=Ii,rt=Eh,ht=Fs;for(var K=0;K255){var T=H>>18&31;ka(e,m,ot[T+257]),m+=ut[T+257],T>7&&(Bn(e,m,H>>23&31),m+=Ko[T]);var J=H&31;ka(e,m,rt[J]),m+=ht[J],J>3&&(ka(e,m,H>>5&8191),m+=Xo[J])}else ka(e,m,ot[H]),m+=ut[H]}return ka(e,m,ot[256]),m+ut[256]},jh=new Jo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),rf=new Qr(0),Bh=function(r,e,t,i,s,a){var c=a.z||r.length,l=new Qr(i+c+5*(1+Math.ceil(c/7e3))+s),h=l.subarray(i,l.length-s),d=a.l,m=(a.r||0)&7;if(e){m&&(h[0]=a.r>>3);for(var _=jh[e-1],k=_>>13,p=_&8191,j=(1<7e3||tt>24576)&&(ot>423||!d)){m=Dl(r,h,0,D,it,mt,K,tt,F,R-F,m),tt=ct=K=0,F=R;for(var ut=0;ut<286;++ut)it[ut]=0;for(var ut=0;ut<30;++ut)mt[ut]=0}var rt=2,ht=0,At=p,wt=U-nt&32767;if(ot>2&&z==G(R-wt))for(var x=Math.min(k,ot)-1,B=Math.min(32767,R),T=Math.min(258,ot);wt<=B&&--At&&U!=nt;){if(r[R+rt]==r[R+rt-wt]){for(var H=0;Hrt){if(rt=H,ht=wt,H>x)break;for(var J=Math.min(wt,H-2),Z=0,ut=0;utZ&&(Z=gt,nt=at)}}}U=nt,nt=O[U],wt+=U-nt&32767}if(ht){D[tt++]=268435456|Ro[rt]<<18|Rl[ht];var _t=Ro[rt]&31,kt=Rl[ht]&31;K+=Ko[_t]+Xo[kt],++it[257+_t],++mt[kt],N=R+rt,++ct}else D[tt++]=r[R],++it[r[R]]}}for(R=Math.max(R,N);R=c&&(h[m/8|0]=d,St=c),m=ef(h,m+1,r.subarray(R,St))}a.i=c}return Oh(l,0,i+tf(m)+s)},nf=function(){var r=1,e=0;return{p:function(t){for(var i=r,s=e,a=t.length|0,c=0;c!=a;){for(var l=Math.min(c+2655,a);c>16),s=(s&65535)+15*(s>>16)}r=i,e=s},d:function(){return r%=65521,e%=65521,(r&255)<<24|(r&65280)<<8|(e&255)<<8|e>>8}}},Mh=function(r,e,t,i,s){if(!s&&(s={l:1},e.dictionary)){var a=e.dictionary.subarray(-32768),c=new Qr(a.length+r.length);c.set(a),c.set(r,a.length),r=c,s.w=a.length}return Bh(r,e.level==null?6:e.level,e.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):20:12+e.mem,t,i,s)},af=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8},Rh=function(r,e){var t=e.level,i=t==0?0:t<6?1:t==9?3:2;if(r[0]=120,r[1]=i<<6|(e.dictionary&&32),r[1]|=31-(r[0]<<8|r[1])%31,e.dictionary){var s=nf();s.p(e.dictionary),af(r,2,s.d())}};function qo(r,e){e||(e={});var t=nf();t.p(r);var i=Mh(r,e,e.dictionary?6:2,4);return Rh(i,e),af(i,i.length-4,t.d()),i}var Th=typeof TextDecoder<"u"&&new TextDecoder,Dh=0;try{Th.decode(rf,{stream:!0}),Dh=1}catch{}function qh(r){if(Array.isArray(r))return r}function Uh(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var i,s,a,c,l=[],h=!0,d=!1;try{if(a=(t=t.call(r)).next,e!==0)for(;!(h=(i=a.call(t)).done)&&(l.push(i.value),l.length!==e);h=!0);}catch(m){d=!0,s=m}finally{try{if(!h&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(d)throw s}}return l}}function ql(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,i=Array(e);t{const r=new Uint8Array(4),e=new Uint32Array(r.buffer);return!((e[0]=1)&r[0])})(),vo={int8:globalThis.Int8Array,uint8:globalThis.Uint8Array,int16:globalThis.Int16Array,uint16:globalThis.Uint16Array,int32:globalThis.Int32Array,uint32:globalThis.Uint32Array,uint64:globalThis.BigUint64Array,int64:globalThis.BigInt64Array,float32:globalThis.Float32Array,float64:globalThis.Float64Array};class $o{constructor(e=Gh,t={}){_e(this,"buffer");_e(this,"byteLength");_e(this,"byteOffset");_e(this,"length");_e(this,"offset");_e(this,"lastWrittenByte");_e(this,"littleEndian");_e(this,"_data");_e(this,"_mark");_e(this,"_marks");let i=!1;typeof e=="number"?e=new ArrayBuffer(e):(i=!0,this.lastWrittenByte=e.byteLength);const s=t.offset?t.offset>>>0:0,a=e.byteLength-s;let c=s;(ArrayBuffer.isView(e)||e instanceof $o)&&(e.byteLength!==e.buffer.byteLength&&(c=e.byteOffset+s),e=e.buffer),i?this.lastWrittenByte=a:this.lastWrittenByte=0,this.buffer=e,this.length=a,this.byteLength=a,this.byteOffset=c,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,c,a),this._mark=0,this._marks=[]}available(e=1){return this.offset+e<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(e=1){return this.offset+=e,this}back(e=1){return this.offset-=e,this}seek(e){return this.offset=e,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){const e=this._marks.pop();if(e===void 0)throw new Error("Mark stack empty");return this.seek(e),this}rewind(){return this.offset=0,this}ensureAvailable(e=1){if(!this.available(e)){const i=(this.offset+e)*2,s=new Uint8Array(i);s.set(new Uint8Array(this.buffer)),this.buffer=s.buffer,this.length=i,this.byteLength=i,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(e=1){return this.readArray(e,"uint8")}readArray(e,t){const i=vo[t].BYTES_PER_ELEMENT*e,s=this.byteOffset+this.offset,a=this.buffer.slice(s,s+i);if(this.littleEndian===Yh&&t!=="uint8"&&t!=="int8"){const l=new Uint8Array(this.buffer.slice(s,s+i));l.reverse();const h=new vo[t](l.buffer);return this.offset+=i,h.reverse(),h}const c=new vo[t](a);return this.offset+=i,c}readInt16(){const e=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}readUint16(){const e=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,e}readInt32(){const e=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}readUint32(){const e=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat32(){const e=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}readFloat64(){const e=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}readBigInt64(){const e=this._data.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,e}readBigUint64(){const e=this._data.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,e}readChar(){return String.fromCharCode(this.readInt8())}readChars(e=1){let t="";for(let i=0;ithis.lastWrittenByte&&(this.lastWrittenByte=this.offset)}}function Zi(r){let e=r.length;for(;--e>=0;)r[e]=0}const Jh=3,Kh=258,sf=29,Xh=256,$h=Xh+1+sf,of=30,Zh=512,Qh=new Array(($h+2)*2);Zi(Qh);const tc=new Array(of*2);Zi(tc);const ec=new Array(Zh);Zi(ec);const rc=new Array(Kh-Jh+1);Zi(rc);const nc=new Array(sf);Zi(nc);const ic=new Array(of);Zi(ic);const ac=(r,e,t,i)=>{let s=r&65535|0,a=r>>>16&65535|0,c=0;for(;t!==0;){c=t>2e3?2e3:t,t-=c;do s=s+e[i++]|0,a=a+s|0;while(--c);s%=65521,a%=65521}return s|a<<16|0};var Uo=ac;const sc=()=>{let r,e=[];for(var t=0;t<256;t++){r=t;for(var i=0;i<8;i++)r=r&1?3988292384^r>>>1:r>>>1;e[t]=r}return e},oc=new Uint32Array(sc()),lc=(r,e,t,i)=>{const s=oc,a=i+t;r^=-1;for(let c=i;c>>8^s[(r^e[c])&255];return r^-1};var cn=lc,zo={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},lf={Z_NO_FLUSH:0,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_DEFLATED:8};const uc=(r,e)=>Object.prototype.hasOwnProperty.call(r,e);var fc=function(r){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const t=e.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const i in t)uc(t,i)&&(r[i]=t[i])}}return r},hc=r=>{let e=0;for(let i=0,s=r.length;i=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;Ba[254]=Ba[255]=1;var cc=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let e,t,i,s,a,c=r.length,l=0;for(s=0;s>>6,e[a++]=128|t&63):t<65536?(e[a++]=224|t>>>12,e[a++]=128|t>>>6&63,e[a++]=128|t&63):(e[a++]=240|t>>>18,e[a++]=128|t>>>12&63,e[a++]=128|t>>>6&63,e[a++]=128|t&63);return e};const dc=(r,e)=>{if(e<65534&&r.subarray&&ff)return String.fromCharCode.apply(null,r.length===e?r:r.subarray(0,e));let t="";for(let i=0;i{const t=e||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,e));let i,s;const a=new Array(t*2);for(s=0,i=0;i4){a[s++]=65533,i+=l-1;continue}for(c&=l===2?31:l===3?15:7;l>1&&i1){a[s++]=65533;continue}c<65536?a[s++]=c:(c-=65536,a[s++]=55296|c>>10&1023,a[s++]=56320|c&1023)}return dc(a,s)},gc=(r,e)=>{e=e||r.length,e>r.length&&(e=r.length);let t=e-1;for(;t>=0&&(r[t]&192)===128;)t--;return t<0||t===0?e:t+Ba[r[t]]>e?t:e},Ho={string2buf:cc,buf2string:pc,utf8border:gc};function mc(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var vc=mc;const ys=16209,bc=16191;var wc=function(e,t){let i,s,a,c,l,h,d,m,_,k,p,j,O,M,S,V,G,D,it,mt,ct,K,R,tt;const N=e.state;i=e.next_in,R=e.input,s=i+(e.avail_in-5),a=e.next_out,tt=e.output,c=a-(t-e.avail_out),l=a+(e.avail_out-257),h=N.dmax,d=N.wsize,m=N.whave,_=N.wnext,k=N.window,p=N.hold,j=N.bits,O=N.lencode,M=N.distcode,S=(1<>>24,p>>>=D,j-=D,D=G>>>16&255,D===0)tt[a++]=G&65535;else if(D&16){it=G&65535,D&=15,D&&(j>>=D,j-=D),j<15&&(p+=R[i++]<>>24,p>>>=D,j-=D,D=G>>>16&255,D&16){if(mt=G&65535,D&=15,jh){e.msg="invalid distance too far back",N.mode=ys;break t}if(p>>>=D,j-=D,D=a-c,mt>D){if(D=mt-D,D>m&&N.sane){e.msg="invalid distance too far back",N.mode=ys;break t}if(ct=0,K=k,_===0){if(ct+=d-D,D2;)tt[a++]=K[ct++],tt[a++]=K[ct++],tt[a++]=K[ct++],it-=3;it&&(tt[a++]=K[ct++],it>1&&(tt[a++]=K[ct++]))}else{ct=a-mt;do tt[a++]=tt[ct++],tt[a++]=tt[ct++],tt[a++]=tt[ct++],it-=3;while(it>2);it&&(tt[a++]=tt[ct++],it>1&&(tt[a++]=tt[ct++]))}}else if(D&64){e.msg="invalid distance code",N.mode=ys;break t}else{G=M[(G&65535)+(p&(1<>3,i-=it,j-=it<<3,p&=(1<{const h=l.bits;let d=0,m=0,_=0,k=0,p=0,j=0,O=0,M=0,S=0,V=0,G,D,it,mt,ct,K=null,R;const tt=new Uint16Array(Gi+1),N=new Uint16Array(Gi+1);let F=null,z,U,nt;for(d=0;d<=Gi;d++)tt[d]=0;for(m=0;m=1&&tt[k]===0;k--);if(p>k&&(p=k),k===0)return s[a++]=1<<24|64<<16|0,s[a++]=1<<24|64<<16|0,l.bits=1,0;for(_=1;_0&&(r===Vl||k!==1))return-1;for(N[1]=0,d=1;dHl||r===Gl&&S>Wl)return 1;for(;;){z=d-O,c[m]+1=R?(U=F[c[m]-R],nt=K[c[m]-R]):(U=96,nt=0),G=1<>O)+D]=z<<24|U<<16|nt|0;while(D!==0);for(G=1<>=1;if(G!==0?(V&=G-1,V+=G):V=0,m++,--tt[d]===0){if(d===k)break;d=e[t+c[m]]}if(d>p&&(V&mt)!==it){for(O===0&&(O=p),ct+=_,j=d-O,M=1<Hl||r===Gl&&S>Wl)return 1;it=V&mt,s[it]=p<<24|j<<16|ct-a|0}}return V!==0&&(s[ct+V]=d-O<<24|64<<16|0),l.bits=p,0};var Ca=Nc;const Lc=0,hf=1,cf=2,{Z_FINISH:Yl,Z_BLOCK:Sc,Z_TREES:xs,Z_OK:Ci,Z_STREAM_END:kc,Z_NEED_DICT:Pc,Z_STREAM_ERROR:Hr,Z_DATA_ERROR:df,Z_MEM_ERROR:pf,Z_BUF_ERROR:Ic,Z_DEFLATED:Jl}=lf,js=16180,Kl=16181,Xl=16182,$l=16183,Zl=16184,Ql=16185,tu=16186,eu=16187,ru=16188,nu=16189,Es=16190,Mn=16191,wo=16192,iu=16193,yo=16194,au=16195,su=16196,ou=16197,lu=16198,_s=16199,As=16200,uu=16201,fu=16202,hu=16203,cu=16204,du=16205,xo=16206,pu=16207,gu=16208,je=16209,gf=16210,mf=16211,Cc=852,Fc=592,Ec=15,Oc=Ec,mu=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function jc(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Fi=r=>{if(!r)return 1;const e=r.state;return!e||e.strm!==r||e.modemf?1:0},vf=r=>{if(Fi(r))return Hr;const e=r.state;return r.total_in=r.total_out=e.total=0,r.msg="",e.wrap&&(r.adler=e.wrap&1),e.mode=js,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(Cc),e.distcode=e.distdyn=new Int32Array(Fc),e.sane=1,e.back=-1,Ci},bf=r=>{if(Fi(r))return Hr;const e=r.state;return e.wsize=0,e.whave=0,e.wnext=0,vf(r)},wf=(r,e)=>{let t;if(Fi(r))return Hr;const i=r.state;return e<0?(t=0,e=-e):(t=(e>>4)+5,e<48&&(e&=15)),e&&(e<8||e>15)?Hr:(i.window!==null&&i.wbits!==e&&(i.window=null),i.wrap=t,i.wbits=e,bf(r))},yf=(r,e)=>{if(!r)return Hr;const t=new jc;r.state=t,t.strm=r,t.window=null,t.mode=js;const i=wf(r,e);return i!==Ci&&(r.state=null),i},Bc=r=>yf(r,Oc);let vu=!0,_o,Ao;const Mc=r=>{if(vu){_o=new Int32Array(512),Ao=new Int32Array(32);let e=0;for(;e<144;)r.lens[e++]=8;for(;e<256;)r.lens[e++]=9;for(;e<280;)r.lens[e++]=7;for(;e<288;)r.lens[e++]=8;for(Ca(hf,r.lens,0,288,_o,0,r.work,{bits:9}),e=0;e<32;)r.lens[e++]=5;Ca(cf,r.lens,0,32,Ao,0,r.work,{bits:5}),vu=!1}r.lencode=_o,r.lenbits=9,r.distcode=Ao,r.distbits=5},xf=(r,e,t,i)=>{let s;const a=r.state;return a.window===null&&(a.window=new Uint8Array(1<=a.wsize?(a.window.set(e.subarray(t-a.wsize,t),0),a.wnext=0,a.whave=a.wsize):(s=a.wsize-a.wnext,s>i&&(s=i),a.window.set(e.subarray(t-i,t-i+s),a.wnext),i-=s,i?(a.window.set(e.subarray(t-i,t),0),a.wnext=i,a.whave=a.wsize):(a.wnext+=s,a.wnext===a.wsize&&(a.wnext=0),a.whave{let t,i,s,a,c,l,h,d,m,_,k,p,j,O,M=0,S,V,G,D,it,mt,ct,K;const R=new Uint8Array(4);let tt,N;const F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Fi(r)||!r.output||!r.input&&r.avail_in!==0)return Hr;t=r.state,t.mode===Mn&&(t.mode=wo),c=r.next_out,s=r.output,h=r.avail_out,a=r.next_in,i=r.input,l=r.avail_in,d=t.hold,m=t.bits,_=l,k=h,K=Ci;t:for(;;)switch(t.mode){case js:if(t.wrap===0){t.mode=wo;break}for(;m<16;){if(l===0)break t;l--,d+=i[a++]<>>8&255,t.check=cn(t.check,R,2,0),d=0,m=0,t.mode=Kl;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((d&255)<<8)+(d>>8))%31){r.msg="incorrect header check",t.mode=je;break}if((d&15)!==Jl){r.msg="unknown compression method",t.mode=je;break}if(d>>>=4,m-=4,ct=(d&15)+8,t.wbits===0&&(t.wbits=ct),ct>15||ct>t.wbits){r.msg="invalid window size",t.mode=je;break}t.dmax=1<>8&1),t.flags&512&&t.wrap&4&&(R[0]=d&255,R[1]=d>>>8&255,t.check=cn(t.check,R,2,0)),d=0,m=0,t.mode=Xl;case Xl:for(;m<32;){if(l===0)break t;l--,d+=i[a++]<>>8&255,R[2]=d>>>16&255,R[3]=d>>>24&255,t.check=cn(t.check,R,4,0)),d=0,m=0,t.mode=$l;case $l:for(;m<16;){if(l===0)break t;l--,d+=i[a++]<>8),t.flags&512&&t.wrap&4&&(R[0]=d&255,R[1]=d>>>8&255,t.check=cn(t.check,R,2,0)),d=0,m=0,t.mode=Zl;case Zl:if(t.flags&1024){for(;m<16;){if(l===0)break t;l--,d+=i[a++]<>>8&255,t.check=cn(t.check,R,2,0)),d=0,m=0}else t.head&&(t.head.extra=null);t.mode=Ql;case Ql:if(t.flags&1024&&(p=t.length,p>l&&(p=l),p&&(t.head&&(ct=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(i.subarray(a,a+p),ct)),t.flags&512&&t.wrap&4&&(t.check=cn(t.check,i,p,a)),l-=p,a+=p,t.length-=p),t.length))break t;t.length=0,t.mode=tu;case tu:if(t.flags&2048){if(l===0)break t;p=0;do ct=i[a+p++],t.head&&ct&&t.length<65536&&(t.head.name+=String.fromCharCode(ct));while(ct&&p>9&1,t.head.done=!0),r.adler=t.check=0,t.mode=Mn;break;case nu:for(;m<32;){if(l===0)break t;l--,d+=i[a++]<>>=m&7,m-=m&7,t.mode=xo;break}for(;m<3;){if(l===0)break t;l--,d+=i[a++]<>>=1,m-=1,d&3){case 0:t.mode=iu;break;case 1:if(Mc(t),t.mode=_s,e===xs){d>>>=2,m-=2;break t}break;case 2:t.mode=su;break;case 3:r.msg="invalid block type",t.mode=je}d>>>=2,m-=2;break;case iu:for(d>>>=m&7,m-=m&7;m<32;){if(l===0)break t;l--,d+=i[a++]<>>16^65535)){r.msg="invalid stored block lengths",t.mode=je;break}if(t.length=d&65535,d=0,m=0,t.mode=yo,e===xs)break t;case yo:t.mode=au;case au:if(p=t.length,p){if(p>l&&(p=l),p>h&&(p=h),p===0)break t;s.set(i.subarray(a,a+p),c),l-=p,a+=p,h-=p,c+=p,t.length-=p;break}t.mode=Mn;break;case su:for(;m<14;){if(l===0)break t;l--,d+=i[a++]<>>=5,m-=5,t.ndist=(d&31)+1,d>>>=5,m-=5,t.ncode=(d&15)+4,d>>>=4,m-=4,t.nlen>286||t.ndist>30){r.msg="too many length or distance symbols",t.mode=je;break}t.have=0,t.mode=ou;case ou:for(;t.have>>=3,m-=3}for(;t.have<19;)t.lens[F[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,tt={bits:t.lenbits},K=Ca(Lc,t.lens,0,19,t.lencode,0,t.work,tt),t.lenbits=tt.bits,K){r.msg="invalid code lengths set",t.mode=je;break}t.have=0,t.mode=lu;case lu:for(;t.have>>24,V=M>>>16&255,G=M&65535,!(S<=m);){if(l===0)break t;l--,d+=i[a++]<>>=S,m-=S,t.lens[t.have++]=G;else{if(G===16){for(N=S+2;m>>=S,m-=S,t.have===0){r.msg="invalid bit length repeat",t.mode=je;break}ct=t.lens[t.have-1],p=3+(d&3),d>>>=2,m-=2}else if(G===17){for(N=S+3;m>>=S,m-=S,ct=0,p=3+(d&7),d>>>=3,m-=3}else{for(N=S+7;m>>=S,m-=S,ct=0,p=11+(d&127),d>>>=7,m-=7}if(t.have+p>t.nlen+t.ndist){r.msg="invalid bit length repeat",t.mode=je;break}for(;p--;)t.lens[t.have++]=ct}}if(t.mode===je)break;if(t.lens[256]===0){r.msg="invalid code -- missing end-of-block",t.mode=je;break}if(t.lenbits=9,tt={bits:t.lenbits},K=Ca(hf,t.lens,0,t.nlen,t.lencode,0,t.work,tt),t.lenbits=tt.bits,K){r.msg="invalid literal/lengths set",t.mode=je;break}if(t.distbits=6,t.distcode=t.distdyn,tt={bits:t.distbits},K=Ca(cf,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,tt),t.distbits=tt.bits,K){r.msg="invalid distances set",t.mode=je;break}if(t.mode=_s,e===xs)break t;case _s:t.mode=As;case As:if(l>=6&&h>=258){r.next_out=c,r.avail_out=h,r.next_in=a,r.avail_in=l,t.hold=d,t.bits=m,wc(r,k),c=r.next_out,s=r.output,h=r.avail_out,a=r.next_in,i=r.input,l=r.avail_in,d=t.hold,m=t.bits,t.mode===Mn&&(t.back=-1);break}for(t.back=0;M=t.lencode[d&(1<>>24,V=M>>>16&255,G=M&65535,!(S<=m);){if(l===0)break t;l--,d+=i[a++]<>D)],S=M>>>24,V=M>>>16&255,G=M&65535,!(D+S<=m);){if(l===0)break t;l--,d+=i[a++]<>>=D,m-=D,t.back+=D}if(d>>>=S,m-=S,t.back+=S,t.length=G,V===0){t.mode=du;break}if(V&32){t.back=-1,t.mode=Mn;break}if(V&64){r.msg="invalid literal/length code",t.mode=je;break}t.extra=V&15,t.mode=uu;case uu:if(t.extra){for(N=t.extra;m>>=t.extra,m-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=fu;case fu:for(;M=t.distcode[d&(1<>>24,V=M>>>16&255,G=M&65535,!(S<=m);){if(l===0)break t;l--,d+=i[a++]<>D)],S=M>>>24,V=M>>>16&255,G=M&65535,!(D+S<=m);){if(l===0)break t;l--,d+=i[a++]<>>=D,m-=D,t.back+=D}if(d>>>=S,m-=S,t.back+=S,V&64){r.msg="invalid distance code",t.mode=je;break}t.offset=G,t.extra=V&15,t.mode=hu;case hu:if(t.extra){for(N=t.extra;m>>=t.extra,m-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){r.msg="invalid distance too far back",t.mode=je;break}t.mode=cu;case cu:if(h===0)break t;if(p=k-h,t.offset>p){if(p=t.offset-p,p>t.whave&&t.sane){r.msg="invalid distance too far back",t.mode=je;break}p>t.wnext?(p-=t.wnext,j=t.wsize-p):j=t.wnext-p,p>t.length&&(p=t.length),O=t.window}else O=s,j=c-t.offset,p=t.length;p>h&&(p=h),h-=p,t.length-=p;do s[c++]=O[j++];while(--p);t.length===0&&(t.mode=As);break;case du:if(h===0)break t;s[c++]=t.length,h--,t.mode=As;break;case xo:if(t.wrap){for(;m<32;){if(l===0)break t;l--,d|=i[a++]<{if(Fi(r))return Hr;let e=r.state;return e.window&&(e.window=null),r.state=null,Ci},Dc=(r,e)=>{if(Fi(r))return Hr;const t=r.state;return t.wrap&2?(t.head=e,e.done=!1,Ci):Hr},qc=(r,e)=>{const t=e.length;let i,s,a;return Fi(r)||(i=r.state,i.wrap!==0&&i.mode!==Es)?Hr:i.mode===Es&&(s=1,s=Uo(s,e,t,0),s!==i.check)?df:(a=xf(r,e,t,t),a?(i.mode=gf,pf):(i.havedict=1,Ci))};var Uc=bf,zc=wf,Hc=vf,Wc=Bc,Vc=yf,Gc=Rc,Yc=Tc,Jc=Dc,Kc=qc,Xc="pako inflate (from Nodeca project)",pn={inflateReset:Uc,inflateReset2:zc,inflateResetKeep:Hc,inflateInit:Wc,inflateInit2:Vc,inflate:Gc,inflateEnd:Yc,inflateGetHeader:Jc,inflateSetDictionary:Kc,inflateInfo:Xc};function $c(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Zc=$c;const _f=Object.prototype.toString,{Z_NO_FLUSH:Qc,Z_FINISH:bu,Z_OK:$i,Z_STREAM_END:No,Z_NEED_DICT:Lo,Z_STREAM_ERROR:t1,Z_DATA_ERROR:wu,Z_MEM_ERROR:e1,Z_BUF_ERROR:yu}=lf,r1={chunkSize:1024*64,windowBits:15,to:""};function Ra(r){this.options=uf.assign({},r1,r||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,e.windowBits===0&&(e.windowBits=-15)),e.windowBits>=0&&e.windowBits<16&&!(r&&r.windowBits)&&(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(e.windowBits&15||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new vc,this.strm.avail_out=0;let t=pn.inflateInit2(this.strm,e.windowBits);if(t!==$i)throw new Error(zo[t]);if(this.header=new Zc,pn.inflateGetHeader(this.strm,this.header),e.dictionary&&(typeof e.dictionary=="string"?e.dictionary=Ho.string2buf(e.dictionary):_f.call(e.dictionary)==="[object ArrayBuffer]"&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=pn.inflateSetDictionary(this.strm,e.dictionary),t!==$i)))throw new Error(zo[t])}Ra.prototype.push=function(r,e){const t=this.strm,i=this.options.chunkSize,s=this.options.dictionary;let a,c,l;if(this.ended)return!1;for(e===~~e?c=e:c=e===!0?bu:Qc,_f.call(r)==="[object ArrayBuffer]"?t.input=new Uint8Array(r):t.input=r,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(i),t.next_out=0,t.avail_out=i),a=pn.inflate(t,c),a===Lo&&s&&(a=pn.inflateSetDictionary(t,s),a===$i?a=pn.inflate(t,c):a===wu&&(a=Lo));t.avail_in>0&&a===No&&t.state.wrap&2&&t.state.flags!==0&&t.input[t.next_in]!==0;)pn.inflateReset(t),a=pn.inflate(t,c);switch(a){case t1:case wu:case Lo:case e1:return this.onEnd(a),this.ended=!0,!1}if(l=t.avail_out,t.next_out&&(t.avail_out===0||a===No||c>0))if(this.options.to==="string"){let h=Ho.utf8border(t.output,t.next_out),d=t.next_out-h,m=Ho.buf2string(t.output,h);t.next_out=d,t.avail_out=i-d,d&&t.output.set(t.output.subarray(h,h+d),0),this.onData(m)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out)),t.avail_out=0,t.next_out=0;if(!((a===$i||a===yu)&&l===0)){if(a===No)return a=pn.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,!0;if(t.avail_in===0){if(c===bu)return a=pn.inflateEnd(this.strm),this.onEnd(a===$i?yu:a),this.ended=!0,!1;break}}}return!0};Ra.prototype.onData=function(r){this.chunks.push(r)};Ra.prototype.onEnd=function(r){r===$i&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=uf.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function n1(r,e){const t=new Ra(e);if(t.push(r,!0),t.err)throw t.msg||zo[t.err];return t.result}var i1=Ra,a1=n1,s1={Inflate:i1,inflate:a1};const{Inflate:o1,inflate:l1}=s1;var xu=o1,u1=l1;const Af=[];for(let r=0;r<256;r++){let e=r;for(let t=0;t<8;t++)e&1?e=3988292384^e>>>1:e=e>>>1;Af[r]=e}const _u=4294967295;function f1(r,e,t){let i=r;for(let s=0;s>>8;return i}function h1(r,e){return(f1(_u,r,e)^_u)>>>0}function Au(r,e,t){const i=r.readUint32(),s=h1(new Uint8Array(r.buffer,r.byteOffset+r.offset-e-4,e),e);if(s!==i)throw new Error(`CRC mismatch for chunk ${t}. Expected ${i}, found ${s}`)}function Nf(r,e,t){for(let i=0;i>1)&255}else{for(;a>1)&255;for(;a>1)&255}}function Pf(r,e,t,i,s){let a=0;if(t.length===0){for(;a=t||mt>=i))for(let ct=0;ct>8&255}const w1=new Uint16Array([255]),y1=new Uint8Array(w1.buffer),x1=y1[0]===255,_1=new Uint8Array(0);function Nu(r){const{data:e,width:t,height:i,channels:s,depth:a}=r,c=Math.ceil(a/8)*s,l=Math.ceil(a/8*s*t),h=new Uint8Array(i*l);let d=_1,m=0,_,k;for(let p=0;p>8&255}const Is=Uint8Array.of(137,80,78,71,13,10,26,10);function Lu(r){if(!N1(r.readBytes(Is.length)))throw new Error("wrong PNG signature")}function N1(r){if(r.length79)throw new Error("keyword length must be between 1 and 79")}const P1=/^[\u0000-\u00FF]*$/;function I1(r){if(!P1.test(r))throw new Error("invalid latin1 text")}function C1(r,e,t){const i=Cf(e);r[i]=F1(e,t-i.length-1)}function Cf(r){for(r.mark();r.readByte()!==S1;);const e=r.offset;r.reset();const t=If.decode(r.readBytes(e-r.offset-1));return r.skip(1),k1(t),t}function F1(r,e){return If.decode(r.readBytes(e))}const Er={UNKNOWN:-1,GREYSCALE:0,TRUECOLOUR:2,INDEXED_COLOUR:3,GREYSCALE_ALPHA:4,TRUECOLOUR_ALPHA:6},So={UNKNOWN:-1,DEFLATE:0},Su={UNKNOWN:-1,ADAPTIVE:0},ko={UNKNOWN:-1,NO_INTERLACE:0,ADAM7:1},Ns={NONE:0,BACKGROUND:1,PREVIOUS:2},Po={SOURCE:0,OVER:1};class E1 extends $o{constructor(t,i={}){super(t);_e(this,"_checkCrc");_e(this,"_inflator");_e(this,"_png");_e(this,"_apng");_e(this,"_end");_e(this,"_hasPalette");_e(this,"_palette");_e(this,"_hasTransparency");_e(this,"_transparency");_e(this,"_compressionMethod");_e(this,"_filterMethod");_e(this,"_interlaceMethod");_e(this,"_colorType");_e(this,"_isAnimated");_e(this,"_numberOfFrames");_e(this,"_numberOfPlays");_e(this,"_frames");_e(this,"_writingDataChunks");const{checkCrc:s=!1}=i;this._checkCrc=s,this._inflator=new xu,this._png={width:-1,height:-1,channels:-1,data:new Uint8Array(0),depth:1,text:{}},this._apng={width:-1,height:-1,channels:-1,depth:1,numberOfFrames:1,numberOfPlays:0,text:{},frames:[]},this._end=!1,this._hasPalette=!1,this._palette=[],this._hasTransparency=!1,this._transparency=new Uint16Array(0),this._compressionMethod=So.UNKNOWN,this._filterMethod=Su.UNKNOWN,this._interlaceMethod=ko.UNKNOWN,this._colorType=Er.UNKNOWN,this._isAnimated=!1,this._numberOfFrames=1,this._numberOfPlays=0,this._frames=[],this._writingDataChunks=!1,this.setBigEndian()}decode(){for(Lu(this);!this._end;){const t=this.readUint32(),i=this.readChars(4);this.decodeChunk(t,i)}return this.decodeImage(),this._png}decodeApng(){for(Lu(this);!this._end;){const t=this.readUint32(),i=this.readChars(4);this.decodeApngChunk(t,i)}return this.decodeApngImage(),this._apng}decodeChunk(t,i){const s=this.offset;switch(i){case"IHDR":this.decodeIHDR();break;case"PLTE":this.decodePLTE(t);break;case"IDAT":this.decodeIDAT(t);break;case"IEND":this._end=!0;break;case"tRNS":this.decodetRNS(t);break;case"iCCP":this.decodeiCCP(t);break;case L1:C1(this._png.text,this,t);break;case"pHYs":this.decodepHYs();break;default:this.skip(t);break}if(this.offset-s!==t)throw new Error(`Length mismatch while decoding chunk ${i}`);this._checkCrc?Au(this,t+4,i):this.skip(4)}decodeApngChunk(t,i){const s=this.offset;switch(i!=="fdAT"&&i!=="IDAT"&&this._writingDataChunks&&this.pushDataToFrame(),i){case"acTL":this.decodeACTL();break;case"fcTL":this.decodeFCTL();break;case"fdAT":this.decodeFDAT(t);break;default:this.decodeChunk(t,i),this.offset=s+t;break}if(this.offset-s!==t)throw new Error(`Length mismatch while decoding chunk ${i}`);this._checkCrc?Au(this,t+4,i):this.skip(4)}decodeIHDR(){const t=this._png;t.width=this.readUint32(),t.height=this.readUint32(),t.depth=O1(this.readUint8());const i=this.readUint8();this._colorType=i;let s;switch(i){case Er.GREYSCALE:s=1;break;case Er.TRUECOLOUR:s=3;break;case Er.INDEXED_COLOUR:s=1;break;case Er.GREYSCALE_ALPHA:s=2;break;case Er.TRUECOLOUR_ALPHA:s=4;break;case Er.UNKNOWN:default:throw new Error(`Unknown color type: ${i}`)}if(this._png.channels=s,this._compressionMethod=this.readUint8(),this._compressionMethod!==So.DEFLATE)throw new Error(`Unsupported compression method: ${this._compressionMethod}`);this._filterMethod=this.readUint8(),this._interlaceMethod=this.readUint8()}decodeACTL(){this._numberOfFrames=this.readUint32(),this._numberOfPlays=this.readUint32(),this._isAnimated=!0}decodeFCTL(){const t={sequenceNumber:this.readUint32(),width:this.readUint32(),height:this.readUint32(),xOffset:this.readUint32(),yOffset:this.readUint32(),delayNumber:this.readUint16(),delayDenominator:this.readUint16(),disposeOp:this.readUint8(),blendOp:this.readUint8(),data:new Uint8Array(0)};this._frames.push(t)}decodePLTE(t){if(t%3!==0)throw new RangeError(`PLTE field length must be a multiple of 3. Got ${t}`);const i=t/3;this._hasPalette=!0;const s=[];this._palette=s;for(let a=0;athis._png.width*this._png.height)throw new Error(`tRNS chunk contains more alpha values than there are pixels (${t/2} vs ${this._png.width*this._png.height})`);this._hasTransparency=!0,this._transparency=new Uint16Array(t/2);for(let i=0;ithis._palette.length)throw new Error(`tRNS chunk contains more alpha values than there are palette colors (${t} vs ${this._palette.length})`);let i=0;for(;i{const h=((c+i.yOffset)*this._png.width+i.xOffset+l)*this._png.channels,d=(c*i.width+l)*this._png.channels;return{index:h,frameIndex:d}};switch(i.blendOp){case Po.SOURCE:for(let c=0;c=200&&e.status<=299}function Ls(r){try{r.dispatchEvent(new MouseEvent("click"))}catch{var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),r.dispatchEvent(e)}}var Ai=Jt.saveAs||((typeof window>"u"?"undefined":Ae(window))!=="object"||window!==Jt?function(){}:typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype?function(r,e,t){var i=Jt.URL||Jt.webkitURL,s=document.createElement("a");e=e||r.name||"download",s.download=e,s.rel="noopener",typeof r=="string"?(s.href=r,s.origin!==location.origin?Pu(s.href)?Co(r,e,t):Ls(s,s.target="_blank"):Ls(s)):(s.href=i.createObjectURL(r),setTimeout(function(){i.revokeObjectURL(s.href)},4e4),setTimeout(function(){Ls(s)},0))}:"msSaveOrOpenBlob"in navigator?function(r,e,t){if(e=e||r.name||"download",typeof r=="string")if(Pu(r))Co(r,e,t);else{var i=document.createElement("a");i.href=r,i.target="_blank",setTimeout(function(){Ls(i)})}else navigator.msSaveOrOpenBlob(function(s,a){return a===void 0?a={autoBom:!1}:Ae(a)!=="object"&&(Se.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(s.type)?new Blob(["\uFEFF",s],{type:s.type}):s}(r,t),e)}:function(r,e,t,i){if((i=i||open("","_blank"))&&(i.document.title=i.document.body.innerText="downloading..."),typeof r=="string")return Co(r,e,t);var s=r.type==="application/octet-stream",a=/constructor/i.test(Jt.HTMLElement)||Jt.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||s&&a)&&(typeof FileReader>"u"?"undefined":Ae(FileReader))==="object"){var l=new FileReader;l.onloadend=function(){var m=l.result;m=c?m:m.replace(/^data:[^;]*;/,"data:attachment/file;"),i?i.location.href=m:location=m,i=null},l.readAsDataURL(r)}else{var h=Jt.URL||Jt.webkitURL,d=h.createObjectURL(r);i?i.location=d:location.href=d,i=null,setTimeout(function(){h.revokeObjectURL(d)},4e4)}});/**
* A class to parse color values
* @author Stoyan Stefanov
@@ -114,7 +114,7 @@ T* `):u.join(` Tj
endobj\r
`},t.outline.count_r=function(i,s){for(var a=0;a1){U=!0,ot=void 0;var J=R*tt;ut=new Uint8Array(J);for(var Z=new DataView(N.buffer),at=0;at=0;r--){for(var i=this.bottom_up?r:this.height-1-r,s=0;s>7-l&1];this.data[c+4*l]=h.blue,this.data[c+4*l+1]=h.green,this.data[c+4*l+2]=h.red,this.data[c+4*l+3]=255}t!==0&&(this.pos+=4-t)}},Zr.prototype.bit4=function(){for(var r=Math.ceil(this.width/2),e=r%4,t=this.height-1;t>=0;t--){for(var i=this.bottom_up?t:this.height-1-t,s=0;s>4,h=15&a,d=this.palette[l];if(this.data[c]=d.blue,this.data[c+1]=d.green,this.data[c+2]=d.red,this.data[c+3]=255,2*s+1>=this.width)break;d=this.palette[h],this.data[c+4]=d.blue,this.data[c+4+1]=d.green,this.data[c+4+2]=d.red,this.data[c+4+3]=255}e!==0&&(this.pos+=4-e)}},Zr.prototype.bit8=function(){for(var r=this.width%4,e=this.height-1;e>=0;e--){for(var t=this.bottom_up?e:this.height-1-e,i=0;i=0;t--){for(var i=this.bottom_up?t:this.height-1-t,s=0;s>5&e)/e*255|0,h=(a>>10&e)/e*255|0,d=a>>15?255:0,m=i*this.width*4+4*s;this.data[m]=h,this.data[m+1]=l,this.data[m+2]=c,this.data[m+3]=d}this.pos+=r}},Zr.prototype.bit16=function(){for(var r=this.width%3,e=parseInt("11111",2),t=parseInt("111111",2),i=this.height-1;i>=0;i--){for(var s=this.bottom_up?i:this.height-1-i,a=0;a>5&t)/t*255|0,d=(c>>11)/e*255|0,m=s*this.width*4+4*a;this.data[m]=d,this.data[m+1]=h,this.data[m+2]=l,this.data[m+3]=255}this.pos+=r}},Zr.prototype.bit24=function(){for(var r=this.height-1;r>=0;r--){for(var e=this.bottom_up?r:this.height-1-r,t=0;t=0;r--)for(var e=this.bottom_up?r:this.height-1-r,t=0;ti&&(s.push(r.slice(h,a)),l=0,h=a),l+=e[a],a++;return h!==a&&s.push(r.slice(h,a)),s},zu=function(r,e,t){t||(t={});var i,s,a,c,l,h,d,m=[],_=[m],k=t.textIndent||0,p=0,j=0,O=r.split(" "),M=Ps.apply(this,[" ",t])[0];if(h=t.lineIndent===-1?O[0].length+2:t.lineIndent||0){var S=Array(h).join(" "),V=[];O.map(function(D){(D=D.split(/\s*\n/)).length>1?V=V.concat(D.map(function(it,mt){return(mt&&it.length?`
`:"")+it})):V.push(D[0])}),O=V,h=qu.apply(this,[S,t])}for(a=0,c=O.length;ae||G){if(j>e){for(l=Uu.apply(this,[i,s,e-(k+p),e]),m.push(l.shift()),m=[l.pop()];l.length;)_.push([l.shift()]);j=s.slice(i.length-(m[0]?m[0].length:0)).reduce(function(D,it){return D+it},0)}else m=[i];_.push(m),k=j+h,p=M}else m.push(i),k+=p+j,p=M}return d=h?function(D,it){return(it?S:"")+D.join(" ")}:function(D){return D.join(" ")},_.map(d)},Ji.splitTextToSize=function(r,e,t){var i,s=(t=t||{}).fontSize||this.internal.getFontSize(),a=(function(m){if(m.widths&&m.kerning)return{widths:m.widths,kerning:m.kerning};var _=this.internal.getFont(m.fontName,m.fontStyle),k="Unicode";return _.metadata[k]?{widths:_.metadata[k].widths||{0:1},kerning:_.metadata[k].kerning||{}}:{font:_.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}).call(this,t);i=Array.isArray(r)?r:String(r).split(/\r?\n/);var c=1*this.internal.scaleFactor*e/s;a.textIndent=t.textIndent?1*t.textIndent*this.internal.scaleFactor/s:0,a.lineIndent=t.lineIndent;var l,h,d=[];for(l=0,h=i.length;limport("./index.es-CE6umRqJ.js"),__vite__mapDeps([0,1,2]))).catch(function(k){return Promise.reject(new Error("Could not load canvg: "+k))}).then(function(k){return k.default?k.default:k}).then(function(k){return k.fromString(d,r,m)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(k){return k.render(m)}).then(function(){_.addImage(h.toDataURL("image/jpeg",1),e,t,i,s,c,l)})},Mt.API.putTotalPages=function(r){var e,t=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(r,"g"),t=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(r,this.internal.getFont()),"g"),t=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var i=1;i<=this.internal.getNumberOfPages();i++)for(var s=0;s1){for(m=0;me||G){if(j>e){for(l=Uu.apply(this,[i,s,e-(k+p),e]),m.push(l.shift()),m=[l.pop()];l.length;)_.push([l.shift()]);j=s.slice(i.length-(m[0]?m[0].length:0)).reduce(function(D,it){return D+it},0)}else m=[i];_.push(m),k=j+h,p=M}else m.push(i),k+=p+j,p=M}return d=h?function(D,it){return(it?S:"")+D.join(" ")}:function(D){return D.join(" ")},_.map(d)},Ji.splitTextToSize=function(r,e,t){var i,s=(t=t||{}).fontSize||this.internal.getFontSize(),a=(function(m){if(m.widths&&m.kerning)return{widths:m.widths,kerning:m.kerning};var _=this.internal.getFont(m.fontName,m.fontStyle),k="Unicode";return _.metadata[k]?{widths:_.metadata[k].widths||{0:1},kerning:_.metadata[k].kerning||{}}:{font:_.metadata,fontSize:this.internal.getFontSize(),charSpace:this.internal.getCharSpace()}}).call(this,t);i=Array.isArray(r)?r:String(r).split(/\r?\n/);var c=1*this.internal.scaleFactor*e/s;a.textIndent=t.textIndent?1*t.textIndent*this.internal.scaleFactor/s:0,a.lineIndent=t.lineIndent;var l,h,d=[];for(l=0,h=i.length;limport("./index.es-By-P9X2v.js"),__vite__mapDeps([0,1,2]))).catch(function(k){return Promise.reject(new Error("Could not load canvg: "+k))}).then(function(k){return k.default?k.default:k}).then(function(k){return k.fromString(d,r,m)},function(){return Promise.reject(new Error("Could not load canvg."))}).then(function(k){return k.render(m)}).then(function(){_.addImage(h.toDataURL("image/jpeg",1),e,t,i,s,c,l)})},Mt.API.putTotalPages=function(r){var e,t=0;parseInt(this.internal.getFont().id.substr(1),10)<15?(e=new RegExp(r,"g"),t=this.internal.getNumberOfPages()):(e=new RegExp(this.pdfEscape16(r,this.internal.getFont()),"g"),t=this.pdfEscape16(this.internal.getNumberOfPages()+"",this.internal.getFont()));for(var i=1;i<=this.internal.getNumberOfPages();i++)for(var s=0;s1){for(m=0;mr?1:n>=r?0:NaN}function z(n,r){return n==null||r==null?NaN:rn?1:r>=n?0:NaN}function w(n){let r,i,t;n.length!==2?(r=g,i=(u,o)=>g(n(u),o),t=(u,o)=>n(u)-o):(r=n===g||n===z?n:I,i=n,t=n);function f(u,o,e=0,m=u.length){if(e>>1;i(u[l],o)<0?e=l+1:m=l}while(e>>1;i(u[l],o)<=0?e=l+1:m=l}while(ee&&t(u[l-1],o)>-t(u[l],o)?l-1:l}return{left:f,center:a,right:c}}function I(){return 0}function P(n){return n===null?NaN:+n}const $=w(g),j=$.right;w(P).center;const x=Math.sqrt(50),B=Math.sqrt(10),C=Math.sqrt(2);function v(n,r,i){const t=(r-n)/Math.max(0,i),f=Math.floor(Math.log10(t)),c=t/Math.pow(10,f),a=c>=x?10:c>=B?5:c>=C?2:1;let u,o,e;return f<0?(e=Math.pow(10,-f)/a,u=Math.round(n*e),o=Math.round(r*e),u/er&&--o,e=-e):(e=Math.pow(10,f)*a,u=Math.round(n/e),o=Math.round(r/e),u*er&&--o),o